grooph 0.4.0 → 0.5.0
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/README.md +33 -31
- package/THIRD-PARTY-NOTICES.md +5 -1
- package/dist/app/assets/App-CT9KxzfQ.css +1 -0
- package/dist/app/assets/App-D1pDFbEY.js +5 -0
- package/dist/app/assets/EmbedApp-CTausQWY.js +1 -0
- package/dist/app/assets/ExportPanel-CbRH4C69.js +8 -0
- package/dist/app/assets/Import-DF0XLxRI.js +1 -0
- package/dist/app/assets/SketchView-BjeUHG4X.js +143 -0
- package/dist/app/assets/brakes-B9b3hDX8.js +1 -0
- package/dist/app/assets/{builtins-Cbs5iQtH.js → builtins-DzyPaYdd.js} +1 -1
- package/dist/app/assets/{compile-BAvi-rd0.js → compile-DL2budwP.js} +8 -8
- package/dist/app/assets/{front-BRl7rl-u.js → front-OxfL-OaD.js} +1 -1
- package/dist/app/assets/full-C0asYORc.js +1 -0
- package/dist/app/assets/graph-more-Dn_hNa20.js +2 -0
- package/dist/app/assets/graph-stage-CwNePnN4.js +4 -0
- package/dist/app/assets/graph-views-CmkQ41zC.js +2 -0
- package/dist/app/assets/{index-BoSi6XYh.js → index-B5ZkSF4L.js} +2 -2
- package/dist/app/assets/mermaid-read-cyqJ32v-.js +17 -0
- package/dist/app/assets/{plan-templates-BQu8G2sX.js → plan-templates-u2fF3GnS.js} +1 -1
- package/dist/app/assets/runs-BA5HKtsx.js +1 -0
- package/dist/app/assets/screens-CMMuexid.js +16 -0
- package/dist/app/assets/share-DV3wsAsJ.js +8 -0
- package/dist/app/assets/site-looks.v1.css +223 -0
- package/dist/app/assets/space-Cuy4YqyZ.js +1 -0
- package/dist/app/assets/styles-Dlp-yYlE.css +1 -0
- package/dist/app/assets/templates-DbAhWvP6.js +2 -0
- package/dist/app/assets/{themes-DtOBrLk0.js → themes-C34TrvOJ.js} +1 -1
- package/dist/app/assets/{units-DRaa5U2m.js → units-DlniUjfH.js} +1 -1
- package/dist/app/assets/{views-DCEDX6Qx.js → views-CFqRShXD.js} +2 -1
- package/dist/app/grooph-app.json +1 -1
- package/dist/app/index.html +14 -11
- package/dist/app/llms.txt +6 -7
- package/dist/app/manifest.webmanifest +1 -1
- package/dist/app/og.png +0 -0
- package/dist/app/routes.json +42 -33
- package/dist/app/sw.js +7 -2
- package/dist/browser/grooph.d.ts +44 -0
- package/dist/browser/grooph.global.js +7 -0
- package/dist/browser/grooph.js +7 -0
- package/dist/bundle/grooph.js +7082 -2606
- package/hooks/grooph-event.mjs +163 -14
- package/package.json +14 -6
- package/dist/app/assets/App-CFO6bPna.js +0 -5
- package/dist/app/assets/App-Cv1auMeh.css +0 -1
- package/dist/app/assets/EmbedApp-B5LWao3x.js +0 -1
- package/dist/app/assets/ExportPanel-VWus7GM3.js +0 -8
- package/dist/app/assets/Import-YEKofx4_.js +0 -1
- package/dist/app/assets/brakes-9E9PsV_Z.js +0 -1
- package/dist/app/assets/graph-more-BKW9C4-h.js +0 -2
- package/dist/app/assets/graph-stage-CWh3OWga.js +0 -4
- package/dist/app/assets/graph-views-tFUJK-be.js +0 -2
- package/dist/app/assets/runs-DcjRi7S6.js +0 -1
- package/dist/app/assets/screens-YUd2HaLm.js +0 -16
- package/dist/app/assets/share-BzIzB4EY.js +0 -8
- package/dist/app/assets/space-DWgrlnfB.js +0 -1
- package/dist/app/assets/styles-BA1aVO9R.css +0 -1
- package/dist/app/assets/templates-DvzLa5sE.js +0 -2
- package/dist/app/demo/run.txt +0 -1
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-views-tFUJK-be.js","assets/index-BoSi6XYh.js","assets/share-BzIzB4EY.js","assets/units-DRaa5U2m.js","assets/groups-CjEPiwfv.js","assets/ExportPanel-VWus7GM3.js","assets/App-CFO6bPna.js","assets/templates-DvzLa5sE.js","assets/runs-DcjRi7S6.js","assets/App-Cv1auMeh.css","assets/brakes-9E9PsV_Z.js","assets/views-DCEDX6Qx.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,c as t,i as n,n as r,o as i,r as a,t as o}from"./index-BoSi6XYh.js";import{At as s,B as c,C as l,Ct as u,Dt as d,Et as f,Ft as p,G as m,H as h,Ht as g,I as _,It as v,K as y,L as b,Lt as x,Mt as S,Nt as C,Ot as w,P as T,Pt as E,Qt as D,R as O,Rt as k,St as A,Tt as j,U as M,V as N,Vt as P,W as F,X as I,Xt as L,Z as R,_ as z,_t as B,a as V,an as H,at as U,b as ee,bt as W,c as te,ct as ne,d as re,dt as ie,f as ae,fn as oe,ft as se,g as ce,gt as G,h as le,ht as ue,it as de,jt as fe,k as pe,kt as me,l as he,lt as ge,m as _e,mt as ve,nt as ye,o as be,on as xe,p as Se,q as Ce,rn as we,rt as Te,st as Ee,t as De,tn as Oe,tt as ke,u as Ae,ut as je,v as Me,vt as Ne,wt as Pe,x as Fe,xt as Ie,y as Le,yt as Re,z as ze,zt as Be}from"./share-BzIzB4EY.js";import{a as Ve,c as He,f as Ue,i as We,m as Ge,n as Ke,r as qe,s as Je,t as Ye,u as Xe}from"./templates-DvzLa5sE.js";import{C as Ze,D as Qe,E as $e,O as et,S as tt,T as nt,_ as rt,a as it,b as at,d as ot,f as st,g as ct,h as lt,i as ut,j as dt,k as ft,n as pt,o as mt,t as ht,u as gt,v as _t,w as vt,x as yt,y as bt}from"./runs-DcjRi7S6.js";import{_ as xt,a as St,b as Ct,c as wt,d as Tt,f as Et,g as Dt,i as Ot,l as kt,n as At,o as jt,p as Mt,r as Nt,s as Pt,u as Ft}from"./App-CFO6bPna.js";var It=()=>r(`themes`,()=>a(()=>import(`./themes-DtOBrLk0.js`),[])),Lt=`(?:blueprint|ink|phosphor|transit|chalk)`,Rt=RegExp(`^#/open\\?(?:[^&]*&)*?theme=${Lt}(?:-(?:light|dark|auto))?(?:&|$)`),zt=RegExp(`^${Lt}$`);function Bt(){if(Rt.test(location.hash))return!0;try{return zt.test(localStorage.getItem(`groophPicture`)??``)}catch{return!1}}function Vt(e){e.removeAttribute(`data-pressed`);let t=e.closest(`.site-theme`)??e.parentElement;t.querySelector(`[data-no-themes]`)?.remove();let n=document.activeElement,r=()=>e.isConnected&&(document.activeElement===n||document.activeElement===document.body);It().then(t=>{r()&&t.open(e)},()=>{if(!e.isConnected)return;let n=document.createElement(`p`);n.className=`site-theme-list`,n.setAttribute(`role`,`status`),n.setAttribute(`data-no-themes`,``),n.style.padding=`12px 14px`,n.textContent=`The picture themes could not be fetched. They need a connection the first time.`,t.append(n),setTimeout(()=>n.remove(),6e3),r()&&t.querySelector(`.site-theme-toggle`)?.focus()})}addEventListener(`hashchange`,()=>{Bt()&&It().catch(()=>void 0)}),addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-pictures]`);t&&Vt(t)});var Ht=document.querySelector(`[data-pressed]`);if(Ht&&Vt(Ht),Bt()){let e=document.createElement(`style`);e.textContent=`main.stage,.map-picture{visibility:hidden}`,document.head.append(e);let t=()=>e.remove();It().then(t,t),setTimeout(t,800)}var K=t(e(),1),q=o();function J(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=J(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Ut={value:()=>{}};function Wt(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Gt(n)}function Gt(e){this._=e}function Kt(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Gt.prototype=Wt.prototype={constructor:Gt,on:function(e,t){var n=this._,r=Kt(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=qt(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Jt(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Jt(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Gt(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function qt(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Jt(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Ut,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Yt={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Xt(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Yt.hasOwnProperty(t)?{space:Yt[t],local:e}:e}function Zt(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Qt(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function $t(e){var t=Xt(e);return(t.local?Qt:Zt)(t)}function en(){}function tn(e){return e==null?en:function(){return this.querySelector(e)}}function nn(e){typeof e!=`function`&&(e=tn(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Gr(r,this._parents)}function rn(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function an(){return[]}function on(e){return e==null?an:function(){return this.querySelectorAll(e)}}function sn(e){return function(){return rn(e.apply(this,arguments))}}function cn(e){e=typeof e==`function`?sn(e):on(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Gr(r,i)}function ln(e){return function(){return this.matches(e)}}function un(e){return function(t){return t.matches(e)}}var dn=Array.prototype.find;function fn(e){return function(){return dn.call(this.children,e)}}function pn(){return this.firstElementChild}function mn(e){return this.select(e==null?pn:fn(typeof e==`function`?e:un(e)))}var hn=Array.prototype.filter;function gn(){return Array.from(this.children)}function _n(e){return function(){return hn.call(this.children,e)}}function vn(e){return this.selectAll(e==null?gn:_n(typeof e==`function`?e:un(e)))}function yn(e){typeof e!=`function`&&(e=ln(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Gr(r,this._parents)}function bn(e){return Array(e.length)}function xn(){return new Gr(this._enter||this._groups.map(bn),this._parents)}function Sn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Sn.prototype={constructor:Sn,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 Cn(e){return function(){return e}}function wn(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new Sn(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Tn(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new Sn(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function En(e){return e.__data__}function Dn(e,t){if(!arguments.length)return Array.from(this,En);var n=t?Tn:wn,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Cn(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=On(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Gr(o,r),o._enter=s,o._exit=c,o}function On(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function kn(){return new Gr(this._exit||this._groups.map(bn),this._parents)}function An(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function jn(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Gr(s,this._parents)}function Mn(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Nn(e){e||=Pn;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Gr(i,this._parents).order()}function Pn(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Fn(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function In(){return Array.from(this)}function Ln(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Rn(){let e=0;for(let t of this)++e;return e}function zn(){return!this.node()}function Bn(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function Vn(e){return function(){this.removeAttribute(e)}}function Hn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Un(e,t){return function(){this.setAttribute(e,t)}}function Wn(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Gn(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Kn(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 qn(e,t){var n=Xt(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Hn:Vn:typeof t==`function`?n.local?Kn:Gn:n.local?Wn:Un)(n,t))}function Jn(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Yn(e){return function(){this.style.removeProperty(e)}}function Xn(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Zn(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Qn(e,t,n){return arguments.length>1?this.each((t==null?Yn:typeof t==`function`?Zn:Xn)(e,t,n??``)):$n(this.node(),e)}function $n(e,t){return e.style.getPropertyValue(t)||Jn(e).getComputedStyle(e,null).getPropertyValue(t)}function er(e){return function(){delete this[e]}}function tr(e,t){return function(){this[e]=t}}function nr(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function rr(e,t){return arguments.length>1?this.each((t==null?er:typeof t==`function`?nr:tr)(e,t)):this.node()[e]}function ir(e){return e.trim().split(/^|\s+/)}function ar(e){return e.classList||new or(e)}function or(e){this._node=e,this._names=ir(e.getAttribute(`class`)||``)}or.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function sr(e,t){for(var n=ar(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function cr(e,t){for(var n=ar(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function lr(e){return function(){sr(this,e)}}function ur(e){return function(){cr(this,e)}}function dr(e,t){return function(){(t.apply(this,arguments)?sr:cr)(this,e)}}function fr(e,t){var n=ir(e+``);if(arguments.length<2){for(var r=ar(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?dr:t?lr:ur)(n,t))}function pr(){this.textContent=``}function mr(e){return function(){this.textContent=e}}function hr(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function gr(e){return arguments.length?this.each(e==null?pr:(typeof e==`function`?hr:mr)(e)):this.node().textContent}function _r(){this.innerHTML=``}function vr(e){return function(){this.innerHTML=e}}function yr(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function br(e){return arguments.length?this.each(e==null?_r:(typeof e==`function`?yr:vr)(e)):this.node().innerHTML}function xr(){this.nextSibling&&this.parentNode.appendChild(this)}function Sr(){return this.each(xr)}function Cr(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function wr(){return this.each(Cr)}function Tr(e){var t=typeof e==`function`?e:$t(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Er(){return null}function Dr(e,t){var n=typeof e==`function`?e:$t(e),r=t==null?Er:typeof t==`function`?t:tn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Or(){var e=this.parentNode;e&&e.removeChild(this)}function kr(){return this.each(Or)}function Ar(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jr(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Mr(e){return this.select(e?jr:Ar)}function Nr(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Pr(e){return function(t){e.call(this,t,this.__data__)}}function Fr(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Ir(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Lr(e,t,n){return function(){var r=this.__on,i,a=Pr(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function Rr(e,t,n){var r=Fr(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?Lr:Ir,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function zr(e,t,n){var r=Jn(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Br(e,t){return function(){return zr(this,e,t)}}function Vr(e,t){return function(){return zr(this,e,t.apply(this,arguments))}}function Hr(e,t){return this.each((typeof t==`function`?Vr:Br)(e,t))}function*Ur(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Wr=[null];function Gr(e,t){this._groups=e,this._parents=t}function Kr(){return new Gr([[document.documentElement]],Wr)}function qr(){return this}Gr.prototype=Kr.prototype={constructor:Gr,select:nn,selectAll:cn,selectChild:mn,selectChildren:vn,filter:yn,data:Dn,enter:xn,exit:kn,join:An,merge:jn,selection:qr,order:Mn,sort:Nn,call:Fn,nodes:In,node:Ln,size:Rn,empty:zn,each:Bn,attr:qn,style:Qn,property:rr,classed:fr,text:gr,html:br,raise:Sr,lower:wr,append:Tr,insert:Dr,remove:kr,clone:Mr,datum:Nr,on:Rr,dispatch:Hr,[Symbol.iterator]:Ur};function Jr(e){return typeof e==`string`?new Gr([[document.querySelector(e)]],[document.documentElement]):new Gr([[e]],Wr)}function Yr(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Xr(e,t){if(e=Yr(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var Zr={passive:!1},Qr={capture:!0,passive:!1};function $r(e){e.stopImmediatePropagation()}function ei(e){e.preventDefault(),e.stopImmediatePropagation()}function ti(e){var t=e.document.documentElement,n=Jr(e).on(`dragstart.drag`,ei,Qr);`onselectstart`in t?n.on(`selectstart.drag`,ei,Qr):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function ni(e,t){var n=e.document.documentElement,r=Jr(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,ei,Qr),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var ri=e=>()=>e;function ii(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}ii.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ai(e){return!e.ctrlKey&&!e.button}function oi(){return this.parentNode}function si(e,t){return t??{x:e.x,y:e.y}}function ci(){return navigator.maxTouchPoints||`ontouchstart`in this}function li(){var e=ai,t=oi,n=si,r=ci,i={},a=Wt(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,Zr).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(Jr(n.view).on(`mousemove.drag`,m,Qr).on(`mouseup.drag`,h,Qr),ti(n.view),$r(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(ei(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){Jr(e.view).on(`mousemove.drag mouseup.drag`,null),ni(e.view,l),ei(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&($r(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(ei(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&($r(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=Xr(l||r,t),p,m,h;if((h=n.call(e,new ii(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=Xr(l||a,t),_=o}u.call(r,e,new ii(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:ri(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:ri(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:ri(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:ri(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function ui(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function di(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function fi(){}var pi=.7,mi=1/pi,hi=`\\s*([+-]?\\d+)\\s*`,gi=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,_i=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,vi=/^#([0-9a-f]{3,8})$/,yi=RegExp(`^rgb\\(${hi},${hi},${hi}\\)$`),bi=RegExp(`^rgb\\(${_i},${_i},${_i}\\)$`),xi=RegExp(`^rgba\\(${hi},${hi},${hi},${gi}\\)$`),Si=RegExp(`^rgba\\(${_i},${_i},${_i},${gi}\\)$`),Ci=RegExp(`^hsl\\(${gi},${_i},${_i}\\)$`),wi=RegExp(`^hsla\\(${gi},${_i},${_i},${gi}\\)$`),Ti={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};ui(fi,Ai,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ei,formatHex:Ei,formatHex8:Di,formatHsl:Oi,formatRgb:ki,toString:ki});function Ei(){return this.rgb().formatHex()}function Di(){return this.rgb().formatHex8()}function Oi(){return Ui(this).formatHsl()}function ki(){return this.rgb().formatRgb()}function Ai(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=vi.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ji(t):n===3?new Fi(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mi(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=yi.exec(e))?new Fi(t[1],t[2],t[3],1):(t=bi.exec(e))?new Fi(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=xi.exec(e))?Mi(t[1],t[2],t[3],t[4]):(t=Si.exec(e))?Mi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Ci.exec(e))?Hi(t[1],t[2]/100,t[3]/100,1):(t=wi.exec(e))?Hi(t[1],t[2]/100,t[3]/100,t[4]):Ti.hasOwnProperty(e)?ji(Ti[e]):e===`transparent`?new Fi(NaN,NaN,NaN,0):null}function ji(e){return new Fi(e>>16&255,e>>8&255,e&255,1)}function Mi(e,t,n,r){return r<=0&&(e=t=n=NaN),new Fi(e,t,n,r)}function Ni(e){return e instanceof fi||(e=Ai(e)),e?(e=e.rgb(),new Fi(e.r,e.g,e.b,e.opacity)):new Fi}function Pi(e,t,n,r){return arguments.length===1?Ni(e):new Fi(e,t,n,r??1)}function Fi(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}ui(Fi,Pi,di(fi,{brighter(e){return e=e==null?mi:mi**+e,new Fi(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?pi:pi**+e,new Fi(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Fi(Bi(this.r),Bi(this.g),Bi(this.b),zi(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:Ii,formatHex:Ii,formatHex8:Li,formatRgb:Ri,toString:Ri}));function Ii(){return`#${Vi(this.r)}${Vi(this.g)}${Vi(this.b)}`}function Li(){return`#${Vi(this.r)}${Vi(this.g)}${Vi(this.b)}${Vi((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ri(){let e=zi(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Bi(this.r)}, ${Bi(this.g)}, ${Bi(this.b)}${e===1?`)`:`, ${e})`}`}function zi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Bi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Vi(e){return e=Bi(e),(e<16?`0`:``)+e.toString(16)}function Hi(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Gi(e,t,n,r)}function Ui(e){if(e instanceof Gi)return new Gi(e.h,e.s,e.l,e.opacity);if(e instanceof fi||(e=Ai(e)),!e)return new Gi;if(e instanceof Gi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Gi(o,s,c,e.opacity)}function Wi(e,t,n,r){return arguments.length===1?Ui(e):new Gi(e,t,n,r??1)}function Gi(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}ui(Gi,Wi,di(fi,{brighter(e){return e=e==null?mi:mi**+e,new Gi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?pi:pi**+e,new Gi(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Fi(Ji(e>=240?e-240:e+120,i,r),Ji(e,i,r),Ji(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Gi(Ki(this.h),qi(this.s),qi(this.l),zi(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(){let e=zi(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Ki(this.h)}, ${qi(this.s)*100}%, ${qi(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Ki(e){return e=(e||0)%360,e<0?e+360:e}function qi(e){return Math.max(0,Math.min(1,e||0))}function Ji(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Yi=e=>()=>e;function Xi(e,t){return function(n){return e+n*t}}function Zi(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Qi(e){return(e=+e)==1?$i:function(t,n){return n-t?Zi(t,n,e):Yi(isNaN(t)?n:t)}}function $i(e,t){var n=t-e;return n?Xi(e,n):Yi(isNaN(e)?t:e)}var ea=(function e(t){var n=Qi(t);function r(e,t){var r=n((e=Pi(e)).r,(t=Pi(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=$i(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function ta(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function na(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ra(e,t){for(var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o=0;o<r;++o)i[o]=fa(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function ia(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function aa(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function oa(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=fa(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var sa=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ca=new RegExp(sa.source,`g`);function la(e){return function(){return e}}function ua(e){return function(t){return e(t)+``}}function da(e,t){var n=sa.lastIndex=ca.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=sa.exec(e))&&(i=ca.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:aa(r,i)})),n=ca.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?ua(c[0].x):la(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function fa(e,t){var n=typeof t,r;return t==null||n===`boolean`?Yi(t):(n===`number`?aa:n===`string`?(r=Ai(t))?(t=r,ea):da:t instanceof Ai?ea:t instanceof Date?ia:na(t)?ta:Array.isArray(t)?ra:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?oa:aa)(e,t)}var pa=180/Math.PI,ma={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ha(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*pa,skewX:Math.atan(c)*pa,scaleX:o,scaleY:s}}var ga;function _a(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?ma:ha(t.a,t.b,t.c,t.d,t.e,t.f)}function va(e){return e==null||(ga||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),ga.setAttribute(`transform`,e),!(e=ga.transform.baseVal.consolidate()))?ma:(e=e.matrix,ha(e.a,e.b,e.c,e.d,e.e,e.f))}function ya(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:aa(e,i)},{i:c-2,x:aa(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:aa(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:aa(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:aa(e,n)},{i:s-2,x:aa(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var ba=ya(_a,`px, `,`px)`,`deg)`),xa=ya(va,`, `,`)`,`)`),Sa=1e-12;function Ca(e){return((e=Math.exp(e))+1/e)/2}function wa(e){return((e=Math.exp(e))-1/e)/2}function Ta(e){return((e=Math.exp(2*e))-1)/(e+1)}var Ea=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<Sa)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=Ca(y),c=s/(n*g)*(i*Ta(t*r+y)-wa(y));return[a+c*d,o+c*f,s*i/Ca(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),Da=0,Oa=0,ka=0,Aa=1e3,ja,Ma,Na=0,Pa=0,Fa=0,Ia=typeof performance==`object`&&performance.now?performance:Date,La=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ra(){return Pa||=(La(za),Ia.now()+Fa)}function za(){Pa=0}function Ba(){this._call=this._time=this._next=null}Ba.prototype=Va.prototype={constructor:Ba,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Ra():+n)+(t==null?0:+t),!this._next&&Ma!==this&&(Ma?Ma._next=this:ja=this,Ma=this),this._call=e,this._time=n,Ka()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ka())}};function Va(e,t,n){var r=new Ba;return r.restart(e,t,n),r}function Ha(){Ra(),++Da;for(var e=ja,t;e;)(t=Pa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Da}function Ua(){Pa=(Na=Ia.now())+Fa,Da=Oa=0;try{Ha()}finally{Da=0,Ga(),Pa=0}}function Wa(){var e=Ia.now(),t=e-Na;t>Aa&&(Fa-=t,Na=e)}function Ga(){for(var e,t=ja,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ja=n);Ma=e,Ka(r)}function Ka(e){Da||(Oa&&=clearTimeout(Oa),e-Pa>24?(e<1/0&&(Oa=setTimeout(Ua,e-Ia.now()-Fa)),ka&&=clearInterval(ka)):(ka||=(Na=Ia.now(),setInterval(Wa,Aa)),Da=1,La(Ua)))}function qa(e,t,n){var r=new Ba;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Ja=Wt(`start`,`end`,`cancel`,`interrupt`),Ya=[];function Xa(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;eo(e,n,{name:t,index:r,group:i,on:Ja,tween:Ya,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Za(e,t){var n=$a(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Qa(e,t){var n=$a(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function $a(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function eo(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Va(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return qa(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(qa(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function to(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function no(e){return this.each(function(){to(this,e)})}function ro(e,t){var n,r;return function(){var i=Qa(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function io(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=Qa(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function ao(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=$a(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?ro:io)(n,e,t))}function oo(e,t,n){var r=e._id;return e.each(function(){var e=Qa(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return $a(e,r).value[t]}}function so(e,t){var n;return(typeof t==`number`?aa:t instanceof Ai?ea:(n=Ai(t))?(t=n,ea):da)(e,t)}function co(e){return function(){this.removeAttribute(e)}}function lo(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uo(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function fo(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function po(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function mo(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ho(e,t){var n=Xt(e),r=n===`transform`?xa:so;return this.attrTween(e,typeof t==`function`?(n.local?mo:po)(n,r,oo(this,`attr.`+e,t)):t==null?(n.local?lo:co)(n):(n.local?fo:uo)(n,r,t))}function go(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function _o(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function vo(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&_o(e,i)),n}return i._value=t,i}function yo(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&go(e,i)),n}return i._value=t,i}function bo(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=Xt(e);return this.tween(n,(r.local?vo:yo)(r,t))}function xo(e,t){return function(){Za(this,e).delay=+t.apply(this,arguments)}}function So(e,t){return t=+t,function(){Za(this,e).delay=t}}function Co(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?xo:So)(t,e)):$a(this.node(),t).delay}function wo(e,t){return function(){Qa(this,e).duration=+t.apply(this,arguments)}}function To(e,t){return t=+t,function(){Qa(this,e).duration=t}}function Eo(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?wo:To)(t,e)):$a(this.node(),t).duration}function Do(e,t){if(typeof t!=`function`)throw Error();return function(){Qa(this,e).ease=t}}function Oo(e){var t=this._id;return arguments.length?this.each(Do(t,e)):$a(this.node(),t).ease}function ko(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();Qa(this,e).ease=n}}function Ao(e){if(typeof e!=`function`)throw Error();return this.each(ko(this._id,e))}function jo(e){typeof e!=`function`&&(e=ln(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new os(r,this._parents,this._name,this._id)}function Mo(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new os(o,this._parents,this._name,this._id)}function No(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Po(e,t,n){var r,i,a=No(t)?Za:Qa;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Fo(e,t){var n=this._id;return arguments.length<2?$a(this.node(),n).on.on(e):this.each(Po(n,e,t))}function Io(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Lo(){return this.on(`end.remove`,Io(this._id))}function Ro(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=tn(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,Xa(l[f],t,n,f,l,$a(u,n)));return new os(a,this._parents,t,n)}function zo(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=on(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=$a(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&Xa(p,t,n,h,f,m);a.push(f),o.push(u)}return new os(a,o,t,n)}var Bo=Kr.prototype.constructor;function Vo(){return new Bo(this._groups,this._parents)}function Ho(e,t){var n,r,i;return function(){var a=$n(this,e),o=(this.style.removeProperty(e),$n(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Uo(e){return function(){this.style.removeProperty(e)}}function Wo(e,t,n){var r,i=n+``,a;return function(){var o=$n(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Go(e,t,n){var r,i,a;return function(){var o=$n(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),$n(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Ko(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=Qa(this,e),l=c.on,u=c.value[a]==null?s||=Uo(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function qo(e,t,n){var r=(e+=``)==`transform`?ba:so;return t==null?this.styleTween(e,Ho(e,r)).on(`end.style.`+e,Uo(e)):typeof t==`function`?this.styleTween(e,Go(e,r,oo(this,`style.`+e,t))).each(Ko(this._id,e)):this.styleTween(e,Wo(e,r,t),n).on(`end.style.`+e,null)}function Jo(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Yo(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Jo(e,a,n)),r}return a._value=t,a}function Xo(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Yo(e,t,n??``))}function Zo(e){return function(){this.textContent=e}}function Qo(e){return function(){var t=e(this);this.textContent=t??``}}function $o(e){return this.tween(`text`,typeof e==`function`?Qo(oo(this,`text`,e)):Zo(e==null?``:e+``))}function es(e){return function(t){this.textContent=e.call(this,t)}}function ts(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&es(r)),t}return r._value=e,r}function ns(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,ts(e))}function rs(){for(var e=this._name,t=this._id,n=ss(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=$a(c,t);Xa(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new os(r,this._parents,e,n)}function is(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=Qa(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var as=0;function os(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ss(){return++as}var cs=Kr.prototype;os.prototype={constructor:os,select:Ro,selectAll:zo,selectChild:cs.selectChild,selectChildren:cs.selectChildren,filter:jo,merge:Mo,selection:Vo,transition:rs,call:cs.call,nodes:cs.nodes,node:cs.node,size:cs.size,empty:cs.empty,each:cs.each,on:Fo,attr:ho,attrTween:bo,style:qo,styleTween:Xo,text:$o,textTween:ns,remove:Lo,tween:ao,delay:Co,duration:Eo,ease:Oo,easeVarying:Ao,end:is,[Symbol.iterator]:cs[Symbol.iterator]};function ls(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var us={time:null,delay:0,duration:250,ease:ls};function ds(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function fs(e){var t,n;e instanceof os?(t=e._id,e=e._name):(t=ss(),(n=us).time=Ra(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Xa(c,e,t,l,o,n||ds(c,t));return new os(r,this._parents,e,t)}Kr.prototype.interrupt=no,Kr.prototype.transition=fs;var ps=e=>()=>e;function ms(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function hs(e,t,n){this.k=e,this.x=t,this.y=n}hs.prototype={constructor:hs,scale:function(e){return e===1?this:new hs(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new hs(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 gs=new hs(1,0,0);_s.prototype=hs.prototype;function _s(e){for(;!e.__zoom;)if(!(e=e.parentNode))return gs;return e.__zoom}function vs(e){e.stopImmediatePropagation()}function ys(e){e.preventDefault(),e.stopImmediatePropagation()}function bs(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function xs(){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 Ss(){return this.__zoom||gs}function Cs(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ws(){return navigator.maxTouchPoints||`ontouchstart`in this}function Ts(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function Es(){var e=bs,t=xs,n=Ts,r=Cs,i=ws,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=Ea,l=Wt(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Ss).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Ss),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(gs.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new hs(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new hs(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new hs(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Jr(this.that).datum();l.call(e,this.that,new ms(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Xr(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],to(this),s.start();ys(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Jr(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Xr(t,i),l=t.clientX,u=t.clientY;ti(t.view),vs(t),a.mouse=[c,this.__zoom.invert(c)],to(this),a.start();function d(e){if(ys(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Xr(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),ni(e.view,a.moved),ys(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Xr(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);ys(r),s>0?Jr(this).transition().duration(s).call(x,d,c,r):Jr(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(vs(t),s=0;s<i;++s)c=r[s],l=Xr(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),to(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(ys(e),s=0;s<a;++s)c=i[s],l=Xr(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(vs(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=Xr(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=Jr(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:ps(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:ps(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:ps(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:ps([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var Ds={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Os=[[-1/0,-1/0],[1/0,1/0]],ks=[`Enter`,` `,`Escape`],As={"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`},js;(function(e){e.Strict=`strict`,e.Loose=`loose`})(js||={});var Ms;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(Ms||={});var Ns;(function(e){e.Partial=`partial`,e.Full=`full`})(Ns||={});var Ps={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},Fs;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(Fs||={});var Is;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(Is||={});var Y;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Y||={});var Ls={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top},Rs=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,zs=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),Bs=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),Vs=(e,t=[0,0])=>{let{width:n,height:r}=xc(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Hs=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):Bs(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,tc(e,ac(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?rc(r):{x:0,y:0,width:0,height:0}},Us=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=tc(n,ac(e)),r=!0)}),r?rc(n):{x:0,y:0,width:0,height:0}},Ws=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=sc(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},Gs=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function Ks(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=xc(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function qs({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=vc(Us(Ks(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function Js({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,Ds.error005());else{let{width:e,height:t}=xc(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&bc(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=bc(d)?Zs(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,Ds.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function Ys({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=Gs(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var Xs=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Zs=(e={x:0,y:0},t,n)=>({x:Xs(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Xs(e.y,t[0][1],t[1][1]-(n?.height??0))});function Qs(e,t,n){let{width:r,height:i}=xc(n),{x:a,y:o}=n.internals.positionAbsolute;return Zs(e,[[a,o],[a+r,o+i]],t)}var $s=(e,t,n)=>e<t?Xs(Math.abs(e-t),1,t)/t:e>n?-Xs(Math.abs(e-n),1,t)/t:0,ec=(e,t,n=15,r=40)=>[$s(e.x,r,t.width-r)*n,$s(e.y,r,t.height-r)*n],tc=(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)}),nc=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),rc=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ic=(e,t=[0,0])=>{let{x:n,y:r}=Bs(e)?e.internals.positionAbsolute:Vs(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},ac=(e,t=[0,0])=>{let{x:n,y:r}=Bs(e)?e.internals.positionAbsolute:Vs(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},oc=(e,t)=>rc(tc(nc(e),nc(t))),sc=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},cc=(e,t)=>sc(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),lc=e=>uc(e.width)&&uc(e.height)&&uc(e.x)&&uc(e.y),uc=e=>!isNaN(e)&&isFinite(e),dc=(e,t)=>(e,t)=>{},fc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),pc=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?fc(s,o):s},mc=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function hc(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function gc(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=hc(e,n),i=hc(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=hc(e.top??e.y??0,n),i=hc(e.bottom??e.y??0,n),a=hc(e.left??e.x??0,t),o=hc(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function _c(e,t,n,r,i,a){let{x:o,y:s}=mc(e,[t,n,r]),{x:c,y:l}=mc({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var vc=(e,t,n,r,i,a)=>{let o=gc(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Xs(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=_c(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},yc=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function bc(e){return e!=null&&e!==`parent`}function xc(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Sc(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Cc(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function wc(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Tc(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ec(e){return{...As,...e||{}}}function Dc(e){return e===null?null:e?`valid`:`invalid`}function Oc(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=Pc(e),s=pc({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?fc(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var kc=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ac=e=>e?.getRootNode?.()||window?.document,jc=[`INPUT`,`SELECT`,`TEXTAREA`];function Mc(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?jc.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Nc=e=>`clientX`in e,Pc=(e,t)=>{let n=Nc(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},Fc=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...kc(t)}})};function Ic({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function Lc(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Rc({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Y.Left:return[t-Lc(t-r,a),n];case Y.Right:return[t+Lc(r-t,a),n];case Y.Top:return[t,n-Lc(n-i,a)];case Y.Bottom:return[t,n+Lc(i-n,a)]}}function zc({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top,curvature:o=.25}){let[s,c]=Rc({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Rc({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=Ic({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function Bc({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function Vc({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function Hc({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=tc(ac(e),ac(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),cc({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},rc(a))>0}var Uc=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Wc=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Gc=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,Ds.error006()),t;let r=n.getEdgeId||Uc,i;return i=Rs(e)?{...e}:{...e,id:r(e)},Wc(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Kc({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Bc({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var qc={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},Jc=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.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},Yc=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Xc({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:r=Y.Top,center:i,offset:a,stepPosition:o}){let s=qc[t],c=qc[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=Jc({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=Bc({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function Zc(e,t,n,r){let i=Math.min(Yc(e,t)/2,Yc(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function Qc({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Xc({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=Zc(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function $c(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function el(e){let{sourceNode:t,targetNode:n}=e;if(!$c(t)||!$c(n))return null;let r=t.internals.handleBounds||tl(t.handles),i=n.internals.handleBounds||tl(n.handles),a=rl(r?.source??[],e.sourceHandle),o=rl(e.connectionMode===js.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,Ds.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||Y.Bottom,c=o?.position||Y.Top,l=nl(t,a,s),u=nl(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function tl(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function nl(e,t,n=Y.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??xc(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case Y.Top:return{x:i+o/2,y:a};case Y.Right:return{x:i+o,y:a+s/2};case Y.Bottom:return{x:i+o/2,y:a+s};case Y.Left:return{x:i,y:a+s/2}}}function rl(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function il(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function al(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=il(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var ol=1e3,sl=10,cl={nodeOrigin:[0,0],nodeExtent:Os,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},ll={...cl,checkEquality:!0};function ul(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function dl(e,t,n){let r=ul(cl,n);for(let n of e.values())if(n.parentId)gl(n,e,t,r);else{let e=Zs(Vs(n,r.nodeOrigin),bc(n.extent)?n.extent:r.nodeExtent,xc(n));n.internals.positionAbsolute=e}}function fl(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function pl(e){return e===`manual`}function ml(e,t,n,r={}){let i=ul(ll,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!pl(i.zIndexMode)?ol:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Zs(Vs(u,i.nodeOrigin),bc(u.extent)?u.extent:i.nodeExtent,xc(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:fl(u,e),z:_l(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&gl(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function hl(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function gl(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=ul(cl,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}hl(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*sl),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=vl(e,u,o,s,a&&!pl(c)?ol:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function _l(e,t,n){let r=uc(e.zIndex)?e.zIndex:0;return pl(n)?r:r+(e.selected?t:0)}function vl(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=xc(e),l=Vs(e,n),u=bc(e.extent)?Zs(l,e.extent,c):l,d=Zs({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Qs(d,c,t));let f=_l(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function yl(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=oc(a.get(n.parentId)?.expandedRect??ic(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=xc(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function bl(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=kc(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=bc(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=Qs(h,s,n))}else m&&(h=Zs(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:Fc(`source`,r.nodeElement,p,d,e.id),target:Fc(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&gl(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:ic(g,i)}))}}if(f.length>0){let e=yl(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function xl({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function Sl(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function Cl(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;Sl(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),Sl(`target`,s,c,e,i,o),t.set(r.id,r)}}function wl(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:wl(n,t):!1}function Tl(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function El(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!wl(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function Dl({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function Ol({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=fc(a,t);return{x:o.x-a.x,y:o.y-a.y}}function kl({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=Jr(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?nc(Us(s)):null,x=v&&l?Ol({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:fc(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=Js({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=Dl({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=ec(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=Oc(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=El(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=Dl({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=li().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=Oc(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=Pc(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Oc(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=Pc(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=Pc(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=Dl({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!Tl(t,`.${g}`,v))&&(!_||Tl(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function Al(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())cc(i,ic(e))>0&&r.push(e);return r}var jl=250;function Ml(e,t,n,r){let i=[],a=1/0,o=Al(e,n,t+jl);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=nl(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function Nl(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...nl(o,c,c.position,!0)}:c}function Pl(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Fl(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Il=()=>!0;function Ll(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=Il,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=Ac(e.target),E=0,D,{x:O,y:k}=Pc(e),A=Pl(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=Nl(i,A,r,c,t);if(!N)return;let P=Pc(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=ec(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),H={inProgress:!0,isValid:null,from:nl(V,B,Y.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:Ls[B.position],toNode:null,pointer:P};function U(){M=!0,y(H),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&U();function ee(e){if(!M){let{x:t,y:n}=Pc(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;U()}if(!x()||!B){W(e);return}let a=b();P=Pc(e,j),D=Ml(pc(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=Rl(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=Fl(!!D,s.isValid);let u=c.get(i),f=u?nl(u,B,Y.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?mc({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:Ls[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),H=p}function W(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=H,r={...n,toPosition:H.toHandle?H.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ee),T.removeEventListener(`mouseup`,W),T.removeEventListener(`touchmove`,ee),T.removeEventListener(`touchend`,W)}}T.addEventListener(`mousemove`,ee),T.addEventListener(`mouseup`,W),T.addEventListener(`touchmove`,ee),T.addEventListener(`touchend`,W)}function Rl(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Il,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=Pc(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=Pl(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===js.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=Nl(t,e,a,u,n,!0)}return _}var zl={onPointerDown:Ll,isValid:Rl};function Bl({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=Jr(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&yc()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=Es().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:Xr}}var Vl=e=>({x:e.x,y:e.y,zoom:e.k}),Hl=({x:e,y:t,zoom:n})=>gs.translate(e,t).scale(n),Ul=(e,t)=>e.target.closest(`.${t}`),Wl=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Gl=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Kl=(e,t=0,n=Gl,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},ql=e=>{let t=e.ctrlKey&&yc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Jl({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Ul(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=Xr(u),t=d*2**ql(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===Ms.Vertical?0:u.deltaX*f,m=i===Ms.Horizontal?0:u.deltaY*f;!yc()&&u.shiftKey&&i!==Ms.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=Vl(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function Yl({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=Ul(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Xl({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=Vl(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Zl({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&Wl(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,Vl(a.transform))}}function Ql({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&Wl(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=Vl(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function $l({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(Ul(f,`${u}-flow__node`)||Ul(f,`${u}-flow__edge`)||Ul(f,`${u}-flow__selection`)||Ul(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||Ul(f,c)&&h||Ul(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function eu({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=Es().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=Jr(e).call(f);y({x:i.x,y:i.y,zoom:Xs(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(ql);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fa:Ea).transform(Kl(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,panActivationKeyPressed:S=!1,zoomActivationKeyPressed:C,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&v();let k=i&&!C&&!r;f.clickDistance(O?1/0:!uc(D)||D<0?0:D);let A=k?Jl({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Yl({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=Xl({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=Zl({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=Ql({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=$l({panActivationKeyPressed:S,zoomActivationKeyPressed:C,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});f.filter(P),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=Hl(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=Hl(e);return await g(n,t),n}function x(e){if(p){let t=Hl(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?_s(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fa:Ea).scaleTo(Kl(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fa:Ea).scaleBy(Kl(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!uc(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var tu;(function(e){e.Line=`line`,e.Handle=`handle`})(tu||={});function nu({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function ru(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function iu(e,t){return Math.max(0,t-e)}function au(e,t){return Math.max(0,e-t)}function ou(e,t,n){return Math.max(0,t-e,e-n)}function su(e,t){return e?!t:t}function cu(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=ou(E,h,g),j=ou(D,_,v);if(o){let e=0,t=0;c&&w<0?e=iu(y+w+O,o[0][0]):!c&&w>0&&(e=au(y+E+O,o[1][0])),l&&T<0?t=iu(b+T+k,o[0][1]):!l&&T>0&&(t=au(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=au(y+w,s[0][0]):!c&&w<0&&(e=iu(y+E,s[1][0])),l&&T>0?t=au(b+T,s[0][1]):!l&&T<0&&(t=iu(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=ou(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?au(b+k+E/C,o[1][1])*C:iu(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?iu(b+E/C,s[1][1])*C:au(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=ou(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?au(y+D*C+O,o[1][0])/C:iu(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?iu(y+D*C,s[1][0])/C:au(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(su(c,l)?-w:w)/C:w=(su(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var lu={width:0,height:0,x:0,y:0},uu={...lu,pointerX:0,pointerY:0,aspectRatio:1};function du(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function fu({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=Jr(e),o={controlDirection:ru(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...lu},h={...uu};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:ru(e)};let g,_=null,v=[],y,b,x,S=!1,C=li().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=Oc(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=bc(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=du(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=Oc(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=cu(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=nu({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var pu=i((t=>{var n=e();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useState,o=n.useEffect,s=n.useLayoutEffect,c=n.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;t.useSyncExternalStore=n.useSyncExternalStore===void 0?f:n.useSyncExternalStore})),mu=i(((e,t)=>{t.exports=pu()})),hu=i((t=>{var n=e(),r=mu();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=n.useRef,c=n.useEffect,l=n.useMemo,u=n.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),gu=t(i(((e,t)=>{t.exports=hu()}))(),1),_u=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},vu=e=>e?_u(e):_u,{useDebugValue:yu}=K.default,{useSyncExternalStoreWithSelector:bu}=gu.default,xu=e=>e;function Su(e,t=xu,n){let r=bu(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yu(r),r}var Cu=(e,t)=>{let n=vu(e),r=(e,r=t)=>Su(n,e,r);return Object.assign(r,n),r},wu=(e,t)=>e?Cu(e,t):Cu;function X(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var Tu=n(),Eu=(0,K.createContext)(null),Du=Eu.Provider,Ou=Ds.error001(`react`);function Z(e,t){let n=(0,K.useContext)(Eu);if(n===null)throw Error(Ou);return Su(n,e,t)}function Q(){let e=(0,K.useContext)(Eu);if(e===null)throw Error(Ou);return(0,K.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var ku={display:`none`},Au={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},ju=`react-flow__node-desc`,Mu=`react-flow__edge-desc`,Nu=`react-flow__aria-live`,Pu=e=>e.ariaLiveMessage,Fu=e=>e.ariaLabelConfig;function Iu({rfId:e}){let t=Z(Pu);return(0,q.jsx)(`div`,{id:`${Nu}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Au,children:t})}function Lu({rfId:e,disableKeyboardA11y:t}){let n=Z(Fu);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{id:`${ju}-${e}`,style:ku,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,q.jsx)(`div`,{id:`${Mu}-${e}`,style:ku,children:n[`edge.a11yDescription.default`]}),!t&&(0,q.jsx)(Iu,{rfId:e})]})}var Ru=(0,K.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,q.jsx)(`div`,{className:J([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});Ru.displayName=`Panel`;var zu=`https://reactflow.dev?utm_source=attribution`;function Bu({proOptions:e,position:t=`bottom-right`}){return(0,K.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,q.jsx)(Ru,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${zu}`,children:(0,q.jsx)(`a`,{href:zu,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var Vu=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},Hu=e=>e.id;function Uu(e,t){return X(e.selectedNodes.map(Hu),t.selectedNodes.map(Hu))&&X(e.selectedEdges.map(Hu),t.selectedEdges.map(Hu))}function Wu({onSelectionChange:e}){let t=Q(),{selectedNodes:n,selectedEdges:r}=Z(Vu,Uu);return(0,K.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Gu=e=>!!e.onSelectionChangeHandlers;function Ku({onSelectionChange:e}){let t=Z(Gu);return e||t?(0,q.jsx)(Wu,{onSelectionChange:e}):null}var qu=[0,0],Ju={x:0,y:0,zoom:1},Yu=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],Xu=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}),Zu={translateExtent:Os,nodeOrigin:qu,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Qu(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Z(Xu,X),l=Q();(0,K.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Zu,s()}),[]);let u=(0,K.useRef)(Zu);return(0,K.useEffect)(()=>{for(let s of Yu){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Ec(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Yu.map(t=>e[t])),null}function $u(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function ed(e){let[t,n]=(0,K.useState)(e===`system`?null:e);return(0,K.useEffect)(()=>{if(e!==`system`){n(e);return}let t=$u(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?$u()?.matches?`dark`:`light`:t}var td=typeof document<`u`?document:null;function nd(e=null,t={target:td,actInsideInputWithModifier:!0}){let[n,r]=(0,K.useState)(!1),i=(0,K.useRef)(!1),a=(0,K.useRef)(new Set([])),[o,s]=(0,K.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
|
|
3
|
-
`).replace(`
|
|
4
|
-
|
|
5
|
-
`,`
|
|
6
|
-
+`).split(`
|
|
7
|
-
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,K.useEffect)(()=>{let n=t?.target??td,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&Mc(e))return!1;let n=id(e.code,s);if(a.current.add(e[n]),rd(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=id(e.code,s);rd(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function rd(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function id(e,t){return t.includes(e)?`code`:`key`}var ad=()=>{let e=Q();return(0,K.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=vc(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return pc(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=mc(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function od(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)sd(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function sd(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(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)}}function cd(e,t){return od(e,t)}function ld(e,t){return od(e,t)}function ud(e,t){return{id:e,type:`select`,selected:t}}function dd(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);(a.selected!==void 0||e)&&a.selected!==e&&(n&&(a.selected=e),r.push(ud(a.id,e)))}return r}function fd({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function pd(e){return{id:e.id,type:`remove`}}var md=dc(`React Flow`,`https://reactflow.dev/`);function hd(e,t,n={}){return Gc(e,t,{...n,onError:n.onError??md})}var gd=e=>zs(e),_d=e=>Rs(e);function vd(e){return(0,K.forwardRef)(e)}var yd=typeof window<`u`?K.useLayoutEffect:K.useEffect;function bd(e){let[t,n]=(0,K.useState)(BigInt(0)),[r]=(0,K.useState)(()=>xd(()=>n(e=>e+BigInt(1))));return yd(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function xd(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Sd=(0,K.createContext)(null);function Cd({children:e}){let t=Q(),n=bd((0,K.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=fd({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=bd((0,K.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(fd({items:s,lookup:o}))},[])),i=(0,K.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,q.jsx)(Sd.Provider,{value:i,children:e})}function wd(){let e=(0,K.useContext)(Sd);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var Td=e=>!!e.panZoom;function Ed(){let e=ad(),t=Q(),n=wd(),r=Z(Td),i=(0,K.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=gd(e)?e:n.get(e.id),a=i.parentId?Cc(i.position,i.measured,i.parentId,n,r):i.position;return ic({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&gd(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&_d(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await Ys({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(pd);o?.(f),c(e)}if(m){let e=d.map(pd);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=lc(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=ic(s?r:a),l=cc(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=lc(e)?e:a(e);if(!r)return!1;let i=cc(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return Hs(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??Tc();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,K.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var Dd=e=>e.selected,Od=typeof window<`u`?window:void 0;function kd({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=Q(),{deleteElements:r}=Ed(),i=nd(e,{actInsideInputWithModifier:!1}),a=nd(t,{target:Od});(0,K.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(Dd),edges:e.filter(Dd)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,K.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function Ad(e){let t=Q();(0,K.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=kc(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,Ds.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var jd={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},Md=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Nd({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=Ms.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:_,onViewportChange:v,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=Q(),C=(0,K.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=Z(Md,X),D=nd(p),O=(0,K.useRef)();Ad(C);let k=(0,K.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,K.useEffect)(()=>{if(C.current){O.current=eu({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,K.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:D,preventScrolling:m,noPanClassName:_,userSelectionActive:w,noWheelClassName:g,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,s,c,D,m,_,w,g,T,k,E,x,b]),(0,q.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:jd,children:h})}var Pd=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Fd(){let{userSelectionActive:e,userSelectionRect:t}=Z(Pd,X);return e&&t?(0,q.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var Id=(e,t)=>n=>{n.target===t.current&&e?.(n)},Ld=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Rd({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ns.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,K.useRef)(0),_=Q(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=Z(Ld,X),C=y&&(e||v),w=(0,K.useRef)(null),T=(0,K.useRef)(),E=(0,K.useRef)(new Set),D=(0,K.useRef)(new Set),O=(0,K.useRef)(!1),k=(0,K.useRef)(!1),A=(0,K.useRef)({x:0,y:0}),j=(0,K.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=_.getState();if(T.current=i?.getBoundingClientRect(),!T.current)return;let s=n.target===w.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:c,y:l}=Pc(n.nativeEvent,T.current),u=pc({x:c,y:l},a);_.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=mc(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(Ws(a,m,i,n===Ns.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}wc(h,E.current)||c(dd(a,E.current,!0)),wc(g,D.current)||l(dd(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!i||!T.current)return;let[e,t]=ec(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(R);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(R)})}let z=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,K.useEffect)(()=>()=>z(),[]);let B=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=Pc(e.nativeEvent,T.current);A.current={x:o,y:c};let l=mc({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(R(),!0),L(o,c)},V=e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),z())},H=e=>{e.target?.releasePointerCapture?.(e.pointerId),z()},U=r===!0||Array.isArray(r)&&r.includes(0);return(0,q.jsxs)(`div`,{className:J([`react-flow__pane`,{draggable:U,dragging:b,selection:e}]),onClick:C?void 0:Id(M,w),onContextMenu:Id(N,w),onWheel:Id(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?B:p,onPointerUp:V,onPointerCancel:C?H:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:jd,children:[h,(0,q.jsx)(Fd,{})]})}function zd({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,Ds.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function Bd({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=Q(),[c,l]=(0,K.useState)(!1),u=(0,K.useRef)();return(0,K.useEffect)(()=>{if(!t)return u.current=kl({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{zd({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,K.useEffect)(()=>{!t&&e.current&&u.current&&u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var Vd=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Hd(){let e=Q();return(0,K.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=Vd(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=fc(t,i));let{position:a,positionAbsolute:s}=Js({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Ud=(0,K.createContext)(null),Wd=Ud.Provider;Ud.Consumer;var Gd=()=>(0,K.useContext)(Ud),Kd=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),qd=(0,K.createContext)(null);function Jd({children:e}){let t=Z(Kd,X);return(0,q.jsx)(qd.Provider,{value:t,children:e})}function Yd(){let e=(0,K.useContext)(qd);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Xd={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Zd=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Xd;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===js.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Qd({type:e=`source`,position:t=Y.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=Q(),_=Gd(),{connectOnClick:v,noPanClassName:y,rfId:b}=Yd(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=Z(Zd(_,m,e),X);_||g.getState().onError?.(`010`,Ds.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(hd(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=Nc(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();zl.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,q.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:J([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=Ac(t.target),h=n||c,{connection:v,isValid:y}=zl.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var $d=(0,K.memo)(vd(Qd));function ef({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return(0,q.jsxs)(q.Fragment,{children:[e?.label,(0,q.jsx)($d,{type:`source`,position:n,isConnectable:t})]})}function tf({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:r=Y.Bottom}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)($d,{type:`target`,position:n,isConnectable:t}),e?.label,(0,q.jsx)($d,{type:`source`,position:r,isConnectable:t})]})}function nf(){return null}function rf({data:e,isConnectable:t,targetPosition:n=Y.Top}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)($d,{type:`target`,position:n,isConnectable:t}),e?.label]})}var af={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},of={input:ef,default:tf,output:rf,group:nf};function sf(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}}var cf=e=>{let{width:t,height:n,x:r,y:i}=Us(e.nodeLookup,{filter:e=>!!e.selected});return{width:uc(t)?t:null,height:uc(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function lf({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=Q(),{width:i,height:a,transformString:o,userSelectionActive:s}=Z(cf,X),c=Hd(),l=(0,K.useRef)(null);(0,K.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(Bd({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,q.jsx)(`div`,{className:J([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,q.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(af,e.key)&&(e.preventDefault(),c({direction:af[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var uf=typeof window<`u`?window:void 0,df=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function ff({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=Z(df,X),z=nd(l,{target:uf}),B=nd(h,{target:uf}),V=B||w,H=B||b,U=u&&V!==!0,ee=z||R||U;return kd({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,q.jsx)(Nd,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:H,panActivationKeyPressed:B,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!z&&V,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:U,children:(0,q.jsxs)(Rd,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:V,autoPanOnSelection:T,isSelecting:!!ee,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:U,children:[e,L&&(0,q.jsx)(lf,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}ff.displayName=`FlowRenderer`;var pf=(0,K.memo)(ff),mf=e=>t=>e?Ws(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function hf(e){return Z((0,K.useCallback)(mf(e),[e]),X)}var gf=e=>e.updateNodeInternals;function _f(){let e=Z(gf),[t]=(0,K.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,K.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function vf({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=Q(),a=(0,K.useRef)(null),o=(0,K.useRef)(null),s=(0,K.useRef)(e.sourcePosition),c=(0,K.useRef)(e.targetPosition),l=(0,K.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,K.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,K.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,K.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function yf({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=Z(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},X),S=y.type||`default`,C=g?.[S]||of[S];C===void 0&&(v?.(`003`,Ds.error003(S)),S=`default`,C=g?.default||of.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=Q(),k=Sc(y),A=vf({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=Bd({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=Hd();if(y.hidden)return null;let N=xc(y),P=sf(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,V=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&zd({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},H=t=>{if(!(Mc(t.nativeEvent)||m)){if(ks.includes(t.key)&&T){let n=t.key===`Escape`;zd({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(af,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:af[t.key],factor:t.shiftKey?4:1})}}},U=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(Ws(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,q.jsx)(`div`,{className:J([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:V,onDoubleClick:B,onKeyDown:D?H:void 0,tabIndex:D?0:void 0,onFocus:D?U:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${ju}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,q.jsx)(Wd,{value:e,children:(0,q.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var bf=(0,K.memo)(yf),xf=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Sf(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=Z(xf,X),a=hf(e.onlyRenderVisibleElements),o=_f();return(0,q.jsx)(`div`,{className:`react-flow__nodes`,style:jd,children:a.map(a=>(0,q.jsx)(bf,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}Sf.displayName=`NodeRenderer`;var Cf=(0,K.memo)(Sf);function wf(e){return Z((0,K.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Hc({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),X)}var Tf=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,q.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},Ef=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,q.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},Df={[Is.Arrow]:Tf,[Is.ArrowClosed]:Ef};function Of(e){let t=Q();return(0,K.useMemo)(()=>Object.prototype.hasOwnProperty.call(Df,e)?Df[e]:(t.getState().onError?.(`009`,Ds.error009(e)),null),[e])}var kf=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=Of(t);return c?(0,q.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,q.jsx)(c,{color:n,strokeWidth:o})}):null},Af=({defaultColor:e,rfId:t})=>{let n=Z(e=>e.edges),r=Z(e=>e.defaultEdgeOptions),i=(0,K.useMemo)(()=>al(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,q.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,q.jsx)(`defs`,{children:i.map(e=>(0,q.jsx)(kf,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};Af.displayName=`MarkerDefinitions`;var jf=(0,K.memo)(Af);function Mf({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,K.useState)({x:1,y:0,width:0,height:0}),p=J([`react-flow__edge-textwrapper`,l]),m=(0,K.useRef)(null);return(0,K.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,q.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,q.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,q.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}Mf.displayName=`EdgeText`;var Nf=(0,K.memo)(Mf);function Pf({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`path`,{...u,d:e,fill:`none`,className:J([`react-flow__edge-path`,u.className])}),l?(0,q.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&uc(t)&&uc(n)?(0,q.jsx)(Nf,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function Ff({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Y.Left||e===Y.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function If({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top}){let[o,s]=Ff({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=Ff({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=Ic({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function Lf(e){return(0,K.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=If({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,q.jsx)(Pf,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var Rf=Lf({isInternal:!1}),zf=Lf({isInternal:!0});Rf.displayName=`SimpleBezierEdge`,zf.displayName=`SimpleBezierEdgeInternal`;function Bf(e){return(0,K.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Y.Bottom,targetPosition:m=Y.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Qc({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,q.jsx)(Pf,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var Vf=Bf({isInternal:!1}),Hf=Bf({isInternal:!0});Vf.displayName=`SmoothStepEdge`,Hf.displayName=`SmoothStepEdgeInternal`;function Uf(e){return(0,K.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,q.jsx)(Vf,{...n,id:r,pathOptions:(0,K.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Wf=Uf({isInternal:!1}),Gf=Uf({isInternal:!0});Wf.displayName=`StepEdge`,Gf.displayName=`StepEdgeInternal`;function Kf(e){return(0,K.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Kc({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,q.jsx)(Pf,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var qf=Kf({isInternal:!1}),Jf=Kf({isInternal:!0});qf.displayName=`StraightEdge`,Jf.displayName=`StraightEdgeInternal`;function Yf(e){return(0,K.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Y.Bottom,targetPosition:s=Y.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=zc({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,q.jsx)(Pf,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var Xf=Yf({isInternal:!1}),Zf=Yf({isInternal:!0});Xf.displayName=`BezierEdge`,Zf.displayName=`BezierEdgeInternal`;var Qf={default:Zf,straight:Jf,step:Gf,smoothstep:Hf,simplebezier:zf},$f={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},ep=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,tp=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,np=`react-flow__edgeupdater`;function rp({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,q.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:J([np,`${np}-${s}`]),cx:ep(t,r,e),cy:tp(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function ip({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=Q(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;zl.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,q.jsxs)(q.Fragment,{children:[(e===!0||e===`source`)&&(0,q.jsx)(rp,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,q.jsx)(rp,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function ap({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=Z(t=>t.edgeLookup.get(e)),b=Z(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||Qf[x];S===void 0&&(_?.(`011`,Ds.error011(x)),x=`default`,S=h?.default||Qf.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,K.useRef)(null),[D,O]=(0,K.useState)(!1),[k,A]=(0,K.useState)(!1),j=Q(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=Z((0,K.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return $f;let i=el({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=Vc({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||$f,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex,_]),X),z=(0,K.useMemo)(()=>y.markerStart?`url('#${il(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,K.useMemo)(()=>y.markerEnd?`url('#${il(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let V=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},H=a?e=>{a(e,{...y})}:void 0,U=o?e=>{o(e,{...y})}:void 0,ee=s?e=>{s(e,{...y})}:void 0,W=c?e=>{c(e,{...y})}:void 0,te=l?e=>{l(e,{...y})}:void 0;return(0,q.jsx)(`svg`,{style:{zIndex:M},children:(0,q.jsxs)(`g`,{className:J([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:V,onDoubleClick:H,onContextMenu:U,onMouseEnter:ee,onMouseMove:W,onMouseLeave:te,onKeyDown:C?t=>{if(!v&&ks.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${Mu}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,q.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,q.jsx)(ip,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var op=(0,K.memo)(ap),sp=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function cp({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=Z(sp,X),b=wf(t);return(0,q.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,q.jsx)(jf,{defaultColor:e,rfId:n}),b.map(e=>(0,q.jsx)(op,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}cp.displayName=`EdgeRenderer`;var lp=(0,K.memo)(cp),up=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function dp({children:e}){let t=Q(),n=(0,K.useRef)(null),[r]=(0,K.useState)(()=>t.getState().transform);return yd(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=up(r)))};return r(),t.subscribe(r)},[t]),(0,q.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:up(r)},children:e})}function fp(e){let t=Ed(),n=(0,K.useRef)(!1);(0,K.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var pp=e=>e.panZoom?.syncViewport;function mp(e){let t=Z(pp),n=Q();return(0,K.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function hp(e){return e.connection.inProgress?{...e.connection,to:pc(e.connection.to,e.transform)}:{...e.connection}}function gp(e){return e?t=>e(hp(t)):hp}function _p(e){return Z(gp(e),X)}var vp=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function yp({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Z(vp,X);return a&&i&&c?(0,q.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,q.jsx)(`g`,{className:J([`react-flow__connection`,Dc(s)]),children:(0,q.jsx)(bp,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var bp=({style:e,type:t=Fs.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=_p();if(!i)return;if(n)return(0,q.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Dc(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case Fs.Bezier:[m]=zc(h);break;case Fs.SimpleBezier:[m]=If(h);break;case Fs.Step:[m]=Qc({...h,borderRadius:0});break;case Fs.SmoothStep:[m]=Qc(h);break;default:[m]=Kc(h)}return(0,q.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};bp.displayName=`ConnectionLine`;var xp={};function Sp(e=xp){(0,K.useRef)(e),Q(),(0,K.useEffect)(()=>{},[e])}function Cp(){Q(),(0,K.useRef)(!1),(0,K.useEffect)(()=>{},[])}function wp({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,autoPanOnSelection:B,onPaneClick:V,onPaneMouseEnter:H,onPaneMouseMove:U,onPaneMouseLeave:ee,onPaneScroll:W,onPaneContextMenu:te,paneClickDistance:ne,nodeClickDistance:re,onEdgeContextMenu:ie,onEdgeMouseEnter:ae,onEdgeMouseMove:oe,onEdgeMouseLeave:se,reconnectRadius:ce,onReconnect:G,onReconnectStart:le,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:fe,noPanClassName:pe,disableKeyboardA11y:me,nodeExtent:he,rfId:ge,viewport:_e,onViewportChange:ve,nodesDraggable:ye}){return Sp(e),Sp(t),Cp(),fp(n),mp(_e),(0,q.jsx)(pf,{onPaneClick:V,onPaneMouseEnter:H,onPaneMouseMove:U,onPaneMouseLeave:ee,onPaneContextMenu:te,onPaneScroll:W,paneClickDistance:ne,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:B,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:de,noWheelClassName:fe,noPanClassName:pe,disableKeyboardA11y:me,onViewportChange:ve,isControlledViewport:!!_e,children:(0,q.jsxs)(dp,{children:[(0,q.jsx)(lp,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:G,onReconnectStart:le,onReconnectEnd:ue,onlyRenderVisibleElements:T,onEdgeContextMenu:ie,onEdgeMouseEnter:ae,onEdgeMouseMove:oe,onEdgeMouseLeave:se,reconnectRadius:ce,defaultMarkerColor:M,noPanClassName:pe,disableKeyboardA11y:me,rfId:ge}),(0,q.jsx)(yp,{style:h,type:m,component:g,containerStyle:_}),(0,q.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,q.jsx)(Cf,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:re,onlyRenderVisibleElements:T,noPanClassName:pe,noDragClassName:de,disableKeyboardA11y:me,nodeExtent:he,rfId:ge,nodesDraggable:ye}),(0,q.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}wp.displayName=`GraphView`;var Tp=(0,K.memo)(wp),Ep=dc(`React Flow`,`https://reactflow.dev/`),Dp=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??Os;Cl(h,g,_);let{nodesInitialized:x}=ml(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=vc(Us(p,{filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Os,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:js.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,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:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...Ps},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Ep,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:As,zIndexMode:f,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}},Op=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>wu((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await qs({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...Dp({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=ml(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();Cl(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=bl(e,n,r,i,a,o,l);d&&(dl(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=nl(e,o.fromHandle,Y.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=yl(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(cd(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(ld(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>ud(e,!0)));return}i(dd(r,new Set([...e]),!0)),a(dd(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>ud(e,!0)));return}a(dd(n,new Set([...e]))),i(dd(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(ud(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(ud(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,ud(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,ud(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(ml(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return xl({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...Ps}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...Dp()})}},Object.is);function kp({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,K.useState)(()=>Op({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,q.jsx)(Du,{value:m,children:(0,q.jsx)(Cd,{children:(0,q.jsx)(Jd,{children:p})})})}function Ap({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,K.useContext)(Eu)?(0,q.jsx)(q.Fragment,{children:e}):(0,q.jsx)(kp,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var jp={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function Mp({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=Fs.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,deleteKeyCode:H=`Backspace`,selectionKeyCode:U=`Shift`,selectionOnDrag:ee=!1,selectionMode:W=Ns.Full,panActivationKeyCode:te=`Space`,multiSelectionKeyCode:ne=yc()?`Meta`:`Control`,zoomActivationKeyCode:re=yc()?`Meta`:`Control`,snapToGrid:ie,snapGrid:ae,onlyRenderVisibleElements:oe=!1,selectNodesOnDrag:se,nodesDraggable:ce,autoPanOnNodeFocus:G,nodesConnectable:le,nodesFocusable:ue,nodeOrigin:de=qu,edgesFocusable:fe,edgesReconnectable:pe,elementsSelectable:me=!0,defaultViewport:he=Ju,minZoom:ge=.5,maxZoom:_e=2,translateExtent:ve=Os,preventScrolling:ye=!0,nodeExtent:be,defaultMarkerColor:xe=`#b1b1b7`,zoomOnScroll:Se=!0,zoomOnPinch:Ce=!0,panOnScroll:we=!1,panOnScrollSpeed:Te=.5,panOnScrollMode:Ee=Ms.Free,zoomOnDoubleClick:De=!0,panOnDrag:Oe=!0,onPaneClick:ke,onPaneMouseEnter:Ae,onPaneMouseMove:je,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:Fe=1,nodeClickDistance:Ie=0,children:Le,onReconnect:Re,onReconnectStart:ze,onReconnectEnd:Be,onEdgeContextMenu:Ve,onEdgeDoubleClick:He,onEdgeMouseEnter:Ue,onEdgeMouseMove:We,onEdgeMouseLeave:Ge,reconnectRadius:Ke=10,onNodesChange:qe,onEdgesChange:Je,noDragClassName:Ye=`nodrag`,noWheelClassName:Xe=`nowheel`,noPanClassName:Ze=`nopan`,fitView:Qe,fitViewOptions:$e,connectOnClick:et,attributionPosition:tt,proOptions:nt,defaultEdgeOptions:rt,elevateNodesOnSelect:it=!0,elevateEdgesOnSelect:at=!1,disableKeyboardA11y:ot=!1,autoPanOnConnect:st,autoPanOnNodeDrag:ct,autoPanOnSelection:lt=!0,autoPanSpeed:ut,connectionRadius:dt,isValidConnection:ft,onError:pt,style:mt,id:ht,nodeDragThreshold:gt,connectionDragThreshold:_t,viewport:vt,onViewportChange:yt,width:bt,height:xt,colorMode:St=`light`,debug:Ct,onScroll:wt,ariaLabelConfig:Tt,zIndexMode:Et=`basic`,...Dt},Ot){let kt=ht||`1`,At=ed(St),jt=(0,K.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),wt?.(e)},[wt]);return(0,q.jsx)(`div`,{"data-testid":`rf__wrapper`,...Dt,onScroll:jt,style:{...mt,...jp},ref:Ot,className:J([`react-flow`,i,At]),id:ht,role:`application`,children:(0,q.jsxs)(Ap,{nodes:e,edges:t,width:bt,height:xt,fitView:Qe,fitViewOptions:$e,minZoom:ge,maxZoom:_e,nodeOrigin:de,nodeExtent:be,zIndexMode:Et,children:[(0,q.jsx)(Qu,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:ce,autoPanOnNodeFocus:G,nodesConnectable:le,nodesFocusable:ue,edgesFocusable:fe,edgesReconnectable:pe,elementsSelectable:me,elevateNodesOnSelect:it,elevateEdgesOnSelect:at,minZoom:ge,maxZoom:_e,nodeExtent:be,onNodesChange:qe,onEdgesChange:Je,snapToGrid:ie,snapGrid:ae,connectionMode:L,translateExtent:ve,connectOnClick:et,defaultEdgeOptions:rt,fitView:Qe,fitViewOptions:$e,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Ze,nodeOrigin:de,rfId:kt,autoPanOnConnect:st,autoPanOnNodeDrag:ct,autoPanSpeed:ut,onError:pt,connectionRadius:dt,isValidConnection:ft,selectNodesOnDrag:se,nodeDragThreshold:gt,connectionDragThreshold:_t,onBeforeDelete:I,debug:Ct,ariaLabelConfig:Tt,zIndexMode:Et}),(0,q.jsx)(Tp,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,selectionKeyCode:U,selectionOnDrag:ee,selectionMode:W,deleteKeyCode:H,multiSelectionKeyCode:ne,panActivationKeyCode:te,zoomActivationKeyCode:re,onlyRenderVisibleElements:oe,defaultViewport:he,translateExtent:ve,minZoom:ge,maxZoom:_e,preventScrolling:ye,zoomOnScroll:Se,zoomOnPinch:Ce,zoomOnDoubleClick:De,panOnScroll:we,panOnScrollSpeed:Te,panOnScrollMode:Ee,panOnDrag:Oe,autoPanOnSelection:lt,onPaneClick:ke,onPaneMouseEnter:Ae,onPaneMouseMove:je,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:Fe,nodeClickDistance:Ie,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Re,onReconnectStart:ze,onReconnectEnd:Be,onEdgeContextMenu:Ve,onEdgeDoubleClick:He,onEdgeMouseEnter:Ue,onEdgeMouseMove:We,onEdgeMouseLeave:Ge,reconnectRadius:Ke,defaultMarkerColor:xe,noDragClassName:Ye,noWheelClassName:Xe,noPanClassName:Ze,rfId:kt,disableKeyboardA11y:ot,nodeExtent:be,viewport:vt,onViewportChange:yt,nodesDraggable:ce}),(0,q.jsx)(Ku,{onSelectionChange:k}),Le,(0,q.jsx)(Bu,{proOptions:nt,position:tt}),(0,q.jsx)(Lu,{rfId:kt,disableKeyboardA11y:ot})]})})}var Np=vd(Mp),Pp=e=>e.domNode?.querySelector(`.react-flow__viewport-portal`);function Fp({children:e}){let t=Z(Pp);return t?(0,Tu.createPortal)(e,t):null}var Ip=e=>t=>{if(!e.includeHiddenNodes)return t.nodesInitialized;if(t.nodeLookup.size===0)return!1;for(let[,{internals:e}]of t.nodeLookup)if(e.handleBounds===void 0||!Sc(e.userNode))return!1;return!0};function Lp(e={includeHiddenNodes:!1}){return Z(Ip(e))}Ds.error014();function Rp(e){return Z((0,K.useCallback)(t=>t.nodeLookup.get(e),[e]),X)}function zp({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,q.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:J([`react-flow__background-pattern`,n,r])})}function Bp({radius:e,className:t}){return(0,q.jsx)(`circle`,{cx:e,cy:e,r:e,className:J([`react-flow__background-pattern`,`dots`,t])})}var Vp;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(Vp||={});var Hp={[Vp.Dots]:1,[Vp.Lines]:1,[Vp.Cross]:6},Up=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Wp({id:e,variant:t=Vp.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,K.useRef)(null),{transform:f,patternId:p}=Z(Up,X),m=r||Hp[t],h=t===Vp.Dots,g=t===Vp.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]+x[0]/2,b[1]*f[2]+x[1]/2],C=`${p}${e||``}`;return(0,q.jsxs)(`svg`,{className:J([`react-flow__background`,l]),style:{...c,...jd,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,q.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,q.jsx)(Bp,{radius:y/2,className:u}):(0,q.jsx)(zp,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,q.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}Wp.displayName=`Background`;var Gp=(0,K.memo)(Wp);function Kp(){return(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,q.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function qp(){return(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,q.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function Jp(){return(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,q.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function Yp(){return(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,q.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function Xp(){return(0,q.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,q.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function Zp({children:e,className:t,...n}){return(0,q.jsx)(`button`,{type:`button`,className:J([`react-flow__controls-button`,t]),...n,children:e})}var Qp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function $p({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=Q(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Z(Qp,X),{zoomIn:y,zoomOut:b,fitView:x}=Ed();return(0,q.jsxs)(Ru,{className:J([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Zp,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,q.jsx)(Kp,{})}),(0,q.jsx)(Zp,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,q.jsx)(qp,{})})]}),n&&(0,q.jsx)(Zp,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,q.jsx)(Jp,{})}),r&&(0,q.jsx)(Zp,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,q.jsx)(Xp,{}):(0,q.jsx)(Yp,{})}),u]})}$p.displayName=`Controls`,(0,K.memo)($p);function em({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,q.jsx)(`rect`,{className:J([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var tm=(0,K.memo)(em),nm=e=>e.nodes.map(e=>e.id),rm=e=>e instanceof Function?e:()=>e;function im({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=tm,onClick:o}){let s=Z(nm,X),c=rm(t),l=rm(e),u=rm(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,q.jsx)(q.Fragment,{children:s.map(e=>(0,q.jsx)(om,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function am({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=Z(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=xc(r);return{node:r,x:i,y:a,width:o,height:s}},X);return!l||l.hidden||!Sc(l)?null:(0,q.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var om=(0,K.memo)(am),sm=(0,K.memo)(im),cm=200,lm=150,um=e=>!e.hidden,dm=e=>{let 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]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?oc(Us(e.nodeLookup,{filter:um}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},fm=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,pm=(e,t)=>fm(e.viewBB,t.viewBB)&&fm(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,mm=`react-flow__minimap-desc`;function hm({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=Q(),S=(0,K.useRef)(null),{boundingRect:C,panZoom:w,viewBB:T,rfId:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=Z(dm,pm),j=e?.width??cm,M=e?.height??lm,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,V=I+R*2,H=L+R*2,U=`${mm}-${E}`,ee=(0,K.useRef)(0),W=(0,K.useRef)();ee.current=F,(0,K.useEffect)(()=>{let e=x.getState().panZoom;if(S.current&&e)return W.current=Bl({domNode:S.current,panZoom:e,getTransform:()=>x.getState().transform,getViewScale:()=>ee.current}),()=>{W.current?.destroy()}},[w]),(0,K.useEffect)(()=>{W.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let te=p?e=>{let[t,n]=W.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ne=(0,K.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),re=m?ne:void 0,ie=_??A[`minimap.ariaLabel`];return(0,q.jsx)(Ru,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:J([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,q.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${V} ${H}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":U,ref:S,onClick:te,children:[ie&&(0,q.jsx)(`title`,{id:U,children:ie}),(0,q.jsx)(sm,{onClick:re,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,q.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${V+R*2}v${H+R*2}h${-V-R*2}z
|
|
8
|
-
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}hm.displayName=`MiniMap`,(0,K.memo)(hm);var gm=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,_m={[tu.Line]:`right`,[tu.Handle]:`bottom-right`};function vm({nodeId:e,position:t,variant:n=tu.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Gd(),y=typeof e==`string`?e:v,b=Q(),x=(0,K.useRef)(null),S=n===tu.Handle,C=Z((0,K.useCallback)(gm(S&&p),[S,p]),X),w=(0,K.useRef)(null),T=t??_m[n];(0,K.useEffect)(()=>{if(x.current&&y)return w.current||=fu({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=yl([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Cc({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,q.jsx)(`div`,{className:J([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,K.memo)(vm);var ym=e=>L(e)?P.person:Ee[e.kind],bm=[`lead`,`planner`,`builder`,`critic`,`tester`,`researcher`,`red-team`,`judge`,`synthesizer`],xm=[`frontier`,`strong`,`fast`],Sm=[`low`,`medium`,`high`,`max`],Cm=[`read-files`,`edit-files`,`write-outputs`,`run-commands`,`run-tests`,`web`,`spawn-agents`],wm=[`merge`,`publish`,`spend`,`delete`],Tm=[`command`,`tests`,`diff`,`metric`,`evidence`],Em=[`file`,`url`,`metric`,`checklist`,`answer-key`,`artifact`],Dm=[`bar-passed`,`max-iterations`,`budget`,`human`,`diminishing-returns`,`evidence-invalid`],Om=[`dispatches`,`minutes`,`usd`,`turns`,`tokens`],km=[`agent`,`human-gate`,`check`,`stop`],Am={"bar-passed":`Bar passed`,"max-iterations":`Max iterations`,budget:`Budget`,human:`Human halt`,"diminishing-returns":`Diminishing returns`,"evidence-invalid":`Evidence invalid`};function jm(e,t,n){let r=t.target?.harness,i=n.map(e=>e.title).join(` or `);if(e.code===`E_NO_TARGET`)return r?.trim()?`grooph has no compiler for "${r}". It has one for ${i}: choose it from the list of harnesses.`:`A harness grooph has a compiler for: ${i}. This graph names none, which is right for a plan.`;if(e.code===`E_NO_GOAL`)return`A goal: the lead's brief is built from it.`;if(e.code===`E_PERSON_STEP_NOT_COMPILED`){let n=e.at.map(e=>t.nodes.find(t=>t.id===e)?.name||e);return`Every step an agent's: ${n.join(`, `)} ${n.length===1?`is a person's`:`are people's`}, and grooph cannot yet hand a step to a person inside a harness.`}return e.message}var Mm=()=>({nodes:new Set,edges:new Set,loops:new Set,graph:!1});function Nm(e,t){let n=Mm();for(let r of t){r===e.id&&(n.graph=!0),e.nodes.some(e=>e.id===r)&&n.nodes.add(r),e.edges.some(e=>e.id===r)&&n.edges.add(r);let t=e.loops.find(e=>e.id===r);if(t){n.loops.add(r);for(let e of t.members)n.nodes.add(e);for(let e of t.back)n.edges.add(e)}let i=e.groups?.find(e=>e.id===r);if(i)for(let t of i.members)e.nodes.some(e=>e.id===t)&&n.nodes.add(t)}return n}function Pm(e){let t=new Map;for(let n of e)for(let e of n.at)t.get(e)!==`error`&&t.set(e,n.severity);return t}var Fm=e=>({errors:e.filter(e=>e.severity===`error`).length,warnings:e.filter(e=>e.severity===`warning`).length}),Im=Fe.width,Lm=Fe.height,Rm=Fe;function zm(){return typeof window<`u`&&window.innerWidth<640?2:4}var Bm=(e,t=zm())=>l(e,t,Rm),Vm=0;function Hm(e){Vm++;try{return e()}finally{Vm--}}var Um=class{now;doc;listeners=new Set;past=[];future=[];lastEdit={at:0,fields:null};history={canUndo:!1,canRedo:!1};constructor(e,t=()=>Date.now()){this.now=t,this.doc=e}get=()=>this.doc;set=e=>{if(e===this.doc)return;let t=this.now(),n=Vm>0?qm(this.doc,e):null,r=this.lastEdit.fields;n!==null&&r!==null&&[...n].some(e=>r.has(e))&&t-this.lastEdit.at<1200&&this.past.length>0||(this.past.push(this.doc),this.past.length>100&&this.past.shift()),this.future=[],this.lastEdit={at:t,fields:n},this.replace(e)};update=e=>this.set(e(this.doc));updateWith=e=>{let t=e(this.doc);return this.set(t.doc),t};undo=()=>{let e=this.past.pop();return e!==void 0&&(this.future.push(this.doc),this.lastEdit={at:0,fields:null},this.replace(e),!0)};redo=()=>{let e=this.future.pop();return e!==void 0&&(this.past.push(this.doc),this.lastEdit={at:0,fields:null},this.replace(e),!0)};getHistory=()=>this.history;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));replace(e){this.doc=e;let t=this.past.length>0,n=this.future.length>0;(t!==this.history.canUndo||n!==this.history.canRedo)&&(this.history={canUndo:t,canRedo:n});for(let e of this.listeners)e()}},Wm=e=>(0,K.useSyncExternalStore)(e.subscribe,e.get),Gm=e=>(0,K.useSyncExternalStore)(e.subscribe,e.getHistory),Km=e=>typeof e==`string`||typeof e==`number`;function qm(e,t){let n=[],r=(e,t,i)=>{if(e===t)return!0;if(Km(e)&&Km(t)&&typeof e==typeof t)return n.push(i),!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>r(e,t[n],`${i}/${n}`));if(e&&t&&typeof e==`object`&&typeof t==`object`&&!Array.isArray(e)&&!Array.isArray(t)){let a=e,o=t;for(let e of new Set([...Object.keys(a),...Object.keys(o)])){let t=`${i}/${e}`;if(e in a&&e in o){if(!r(a[e],o[e],t))return!1}else if(Km(e in a?a[e]:o[e]))n.push(t);else return!1}return!0}return!1};return r(e,t,``)&&n.length>0?new Set(n):null}var Jm=(0,K.createContext)(null);function Ym(){let e=(0,K.useContext)(Jm);if(!e)throw Error(`useEditor outside the editor`);return e}var Xm=14,Zm=26,Qm=420;function $m(e,t){let n=new Set(e.loops.flatMap(e=>e.back)),r=new Map,i=new Map;for(let a of e.edges){let e=t[a.from],o=t[a.to];if(!e||!o||a.from===a.to)continue;let s={x:e.x+e.w/2,y:e.y+e.h/2},c={x:o.x+o.w/2,y:o.y+o.h/2},l=Math.hypot(c.x-s.x,c.y-s.y)||1,u={x:(c.x-s.x)/l,y:(c.y-s.y)/l},d={x:-u.y,y:u.x},f=0,p=0,m=!1;for(let[e,n]of Object.entries(t)){if(e===a.from||e===a.to)continue;let t=[[n.x-Xm,n.y-Xm],[n.x+n.w+Xm,n.y-Xm],[n.x-Xm,n.y+n.h+Xm],[n.x+n.w+Xm,n.y+n.h+Xm]].map(([e,t])=>({t:((e-s.x)*u.x+(t-s.y)*u.y)/l,d:(e-s.x)*d.x+(t-s.y)*d.y})),r=Math.min(...t.map(e=>e.t)),i=Math.max(...t.map(e=>e.t)),o=Math.min(...t.map(e=>e.d)),c=Math.max(...t.map(e=>e.d));if(i<=0||r>=1||o>0||c<0)continue;m=!0;let h=Math.min(Math.max((r+i)/2,.15),.85),g=4*h*(1-h);f=Math.max(f,c/g),p=Math.max(p,-o/g)}let h=[a.from,a.to].sort().join(`|`),g=r.get(h)??0;r.set(h,g+1);let _=0;n.has(a.id)?_=Math.max(Math.min(Math.max(l*.3,48),200),m?f:0):m&&(_=f<=p?f:-p),g>0&&(_+=(_<0?-1:1)*g*Zm),i.set(a.id,Math.max(-420,Math.min(Qm,_)))}return i}var eh=e=>({x:e.x+e.w/2,y:e.y+e.h/2});function th(e,t,n){let r=eh(e),i=t.x-r.x,a=t.y-r.y;if(i===0&&a===0)return r;let o=Math.min(i===0?1/0:e.w/2/Math.abs(i),a===0?1/0:e.h/2/Math.abs(a)),s=Math.hypot(i,a);return{x:r.x+i*o+i/s*n,y:r.y+a*o+a/s*n}}function nh(e,t,n){let r=eh(e),i=eh(t);if(n===0)return{start:th(e,i,2),end:th(t,r,4)};let a=Math.hypot(i.x-r.x,i.y-r.y)||1,o=-(i.y-r.y)/a,s=(i.x-r.x)/a,c={x:(r.x+i.x)/2+o*n*2,y:(r.y+i.y)/2+s*n*2};return{start:th(e,c,2),end:th(t,c,4),control:c}}function rh({start:e,end:t,control:n},r){if(!n)return{x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r};let i=1-r;return{x:i*i*e.x+2*i*r*n.x+r*r*t.x,y:i*i*e.y+2*i*r*n.y+r*r*t.y}}var ih=28,ah=4;function oh(e,t){return e===``&&!t?{w:14,h:14}:{w:22+e.length*6.9+(t?66:0),h:ih}}function sh(e){let t=e.when??`always`;return typeof t==`string`?t:`verdict: ${t.verdict||`…`}`}function ch(e){let t=sh(e),n=!!e.approval;return t===`always`&&!n?oh(``,!1):oh(t,n)}function lh(e,t,n){let r=new Map,i=[],a=Object.values(t),o=(e,t,n)=>t.some(t=>e.x<t.x+t.w+n&&e.x+e.w>t.x-n&&e.y<t.y+t.h+n&&e.y+e.h>t.y-n),s=[.5,.42,.58,.34,.66,.26,.74,.2,.8,.15,.85];for(let c of e.edges){let e=t[c.from],l=t[c.to];if(!e||!l||c.from===c.to)continue;let u=nh(e,l,n.get(c.id)??0),d=ch(c),f=e=>{let t=rh(u,e);return{x:t.x-d.w/2,y:t.y-d.h/2,w:d.w,h:d.h}},p=s.filter(e=>!o(f(e),a,ah)),m=p.find(e=>!o(f(e),i,2))??p[0]??.5;r.set(c.id,m),i.push(f(m))}return r}var uh,dh=()=>uh,fh=()=>void 0,ph,mh=(e,t)=>n=>{let i=t(n),o=!!i.groups?.some(e=>e.from),[s,c]=(0,K.useState)(uh),[l,u]=(0,K.useState)(ph);return(0,K.useEffect)(()=>{l||r(`graph-views`,()=>a(()=>import(`./graph-views-tFUJK-be.js`),__vite__mapDeps([0,1,2]))).then(e=>u(ph=e),fh)},[]),(0,K.useEffect)(()=>{o&&s===void 0&&r(`units`,()=>a(()=>import(`./units-DRaa5U2m.js`),__vite__mapDeps([3,1,4]))).then(e=>c(uh=e),()=>c(uh=null))},[o,s]),(0,K.createElement)(K.Fragment,null,o&&s===void 0?null:(0,K.createElement)(e,{key:+!!s,...n,useBoxes:o&&s?s.useBoxes:fh}),l?(0,K.createElement)(l.Views,{doc:i,of:n}):null)},hh={top:72,bottom:92,x:20},gh={top:64,bottom:100,x:20},_h={top:56,bottom:12,x:12},vh=()=>typeof window<`u`&&window.innerWidth>=1100,yh=()=>vh()?1.3:1,bh=e=>vh()?Math.max(e.x,56):e.x,xh=e=>({get padding(){return{top:`${e.top}px`,bottom:`${e.bottom}px`,x:`${bh(e)}px`}},get maxZoom(){return yh()}}),Sh=xh(hh),Ch=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches?0:180,wh=.5;function Th(e,t,n){let r=bh(n),i=Math.max(1,t.width-2*r),a=Math.max(1,t.height-n.top-n.bottom),o=Math.min(i/Math.max(1,e.width),a/Math.max(1,e.height),yh()),s=Math.max(o,wh),c=(e,t,n,r)=>t*s>n?r-e*s:r+(n-t*s)/2-e*s;return{x:c(e.x,e.width,i,r),y:c(e.y,e.height,a,n.top),zoom:s,fits:o>=wh}}var Eh=900;function Dh({pad:e,control:t,refit:n}){let r=Ed(),i=Lp(),a=Z(e=>e.width),o=Z(e=>e.height),s=(0,K.useRef)(!1),c=(0,K.useRef)(null),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(!i||s.current||a===0||o===0)return;s.current=!0,c.current={width:a,height:o};let t=r.getNodes();if(t.length===0)return;let{fits:n,...l}=Th(r.getNodesBounds(t),{width:a,height:o},e);n||requestAnimationFrame(()=>requestAnimationFrame(()=>{r.setViewport(l),u(l)}))},[i,a,o,r,e]),(0,K.useEffect)(()=>{if(!n||!s.current||a===0||o===0)return;let t=c.current;if(c.current={width:a,height:o},t===null||t.width===a&&t.height===o||n.current||window.innerWidth<Eh)return;let i=r.getNodes();if(i.length===0)return;let{fits:l,...d}=Th(r.getNodesBounds(i),{width:a,height:o},e);l?r.fitView({...xh(e),duration:Ch()}):r.setViewport(d,{duration:Ch()}),l||u(d),f(l)},[a,o,n,r,e]),!t||l===null?null:(0,q.jsxs)(`button`,{type:`button`,className:`view-fit`,"aria-pressed":d,onClick:()=>{d?r.setViewport(l,{duration:Ch()}):r.fitView({...xh(e),duration:Ch()}),n&&(n.current=!1),f(!d)},children:[(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:d?(0,q.jsx)(`path`,{d:`M9 4v5H4M15 4v5h5M20 15h-5v5M4 15h5v5`}):(0,q.jsx)(`path`,{d:`M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5`})}),d?`Readable size`:`Show all`]})}var Oh=e=>({x:e.internals.positionAbsolute.x,y:e.internals.positionAbsolute.y,w:e.measured.width??0,h:e.measured.height??0});function kh(e,t,n,r){let i=nh(e,t,n),{start:a,end:o,control:s}=i,c=s?`M${a.x},${a.y} Q${s.x},${s.y} ${o.x},${o.y}`:`M${a.x},${a.y} L${o.x},${o.y}`,l=s??a,u=Math.hypot(o.x-l.x,o.y-l.y)||1;return{path:c,label:rh(i,r),tip:o,dir:{x:(o.x-l.x)/u,y:(o.y-l.y)/u}}}function Ah(e){let t=e.x+e.w,n=e.y+e.h*.3,r=e.y+e.h*.7;return{path:`M${t},${n} C${t+70},${n-30} ${t+70},${r+30} ${t+4},${r}`,label:{x:t+54,y:(n+r)/2},tip:{x:t+4,y:r},dir:{x:-.9,y:-.3}}}var jh=(0,K.memo)(function({id:e,source:t,target:n,data:r}){let i=(0,K.useContext)(Jm),a=Rp(t),o=Rp(n);if(!a||!o||!r||!a.measured.width||!o.measured.width)return null;let s=t===n?Ah(Oh(a)):kh(Oh(a),Oh(o),r.bend,r.labelAt??.5),{edge:c}=r,l=-s.dir.y,u=s.dir.x,d=`M${s.tip.x},${s.tip.y} L${s.tip.x-s.dir.x*9+l*9*.55},${s.tip.y-s.dir.y*9+u*9*.55} L${s.tip.x-s.dir.x*9-l*9*.55},${s.tip.y-s.dir.y*9-u*9*.55} Z`,f=[`gedge`,r.back&&`is-back`,r.loopColor!==void 0&&`loop-c${r.loopColor%4}`,r.selected&&`is-selected`,r.highlighted&&`is-highlighted`,r.picked===!0&&`is-picked`,r.picked===!1&&`is-unpicked`,r.severity&&`has-${r.severity}`].filter(Boolean).join(` `),p=sh(c),m=p===`always`&&!c.approval&&!r.selected&&!r.highlighted&&r.picked===void 0;return(0,q.jsxs)(`g`,{className:f,children:[(0,q.jsx)(`path`,{d:s.path,className:`gedge-hit`,fill:`none`,strokeWidth:26,stroke:`transparent`}),(0,q.jsx)(`path`,{d:s.path,className:`gedge-line`,fill:`none`}),(0,q.jsx)(`path`,{d,className:`gedge-arrow`}),(0,q.jsx)(Fp,{children:(0,q.jsxs)(`button`,{type:`button`,className:`gedge-label nodrag nopan${m?` is-quiet`:``}${r.selected?` is-selected`:``}${r.picked===!0?` is-picked`:``}${r.back?` is-back`:``}${r.loopColor===void 0?``:` loop-c${r.loopColor%4}`}`,style:{transform:`translate(-50%, -50%) translate(${s.label.x}px, ${s.label.y}px)`},"aria-label":`Edge ${c.from} to ${c.to}, ${p}${c.approval?`, needs approval`:``}`,"data-edge-id":e,tabIndex:i?void 0:-1,onClick:t=>{t.stopPropagation(),i?.onEdgeTap(e)},children:[m?``:p,c.approval?(0,q.jsx)(`span`,{className:`gedge-approval`,children:`approval`}):null]})})]})});function Mh({state:e}){return(0,q.jsxs)(`svg`,{className:`state-icon state-${e}`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[e===`pending`?(0,q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`}):null,e===`running`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`}),(0,q.jsx)(`circle`,{cx:`8`,cy:`8`,r:`2.2`,className:`fill`})]}):null,e===`passed`?(0,q.jsx)(`path`,{d:`M3.5 8.5l3 3 6-7`}):null,e===`failed`?(0,q.jsx)(`path`,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`}):null,e===`halted`?(0,q.jsx)(`path`,{d:`M6 4v8M10 4v8`}):null]})}var Nh=e=>`${ym(e)}: ${e.name||e.id}`,Ph=e=>t=>{let n=t.key===`Enter`&&t.target instanceof HTMLElement&&t.target.classList.contains(`react-flow__node`)?t.target.dataset.id:void 0;n!==void 0&&e?.(n)};function Fh(e){switch(e.kind){case`agent`:{let t=typeof e.role==`string`?e.role:e.role.custom||`custom`;return L(e)?t:[t,e.model?.tier,e.effort].filter(Boolean).join(` · `)}case`human-gate`:return e.options?.length?e.options.join(` / `):`asks a human`;case`check`:return e.check.kind+(e.check.run?` · ${e.check.run}`:``);case`merge`:return e.merges.length?`merges ${e.merges.join(`, `)}`:`merge`;case`stop`:return e.outcome??`ends the run`}}var Ih={"--kind":`var(--kind-human-gate)`},Lh=(0,K.memo)(function({data:e}){let{node:t}=e,n=`unit`in t&&dh()?.UnitNode;if(n)return(0,q.jsx)(n,{unit:t.unit,Handle:$d,glyph:ee});let r=[`gnode`,`gnode-${t.kind}`,e.selected&&`is-selected`,e.highlighted&&`is-highlighted`,e.connectFrom&&`is-source`,e.picked===!0&&`is-picked`,e.picked===!1&&`is-unpicked`,e.loopColor!==void 0&&`in-loop loop-c${e.loopColor%4}`,e.run&&`run-state run-${e.run.state}`].filter(Boolean).join(` `);return(0,q.jsxs)(`div`,{className:r,"data-node-id":t.id,children:[(0,q.jsx)($d,{type:`target`,position:Y.Top,isConnectable:!1,className:`ghandle`}),(0,q.jsxs)(`div`,{className:`gnode-kind`,style:L(t)?Ih:void 0,children:[(0,q.jsx)(`span`,{className:`kind-mark kind-${L(t)?`human-gate`:t.kind}`,"aria-hidden":`true`}),ym(t)]}),(0,q.jsx)(`div`,{className:`gnode-name`,children:t.name||(0,q.jsx)(`span`,{className:`muted`,children:`unnamed`})}),(0,q.jsx)(`div`,{className:`gnode-sub`,children:Fh(t)}),e.run?(0,q.jsxs)(`div`,{className:`run-badge run-badge-${e.run.state}`,"data-run-state":e.run.state,children:[(0,q.jsx)(Mh,{state:e.run.state}),(0,q.jsx)(`span`,{children:e.run.label}),e.run.runs>1?(0,q.jsxs)(`span`,{className:`run-count`,"aria-label":`${e.run.runs} runs`,children:[`×`,e.run.runs]}):null]}):null,e.loops.length>0?(0,q.jsx)(`div`,{className:`gnode-loops`,"aria-label":`In loop ${e.loops.map(e=>e.name).join(`, `)}`,children:e.loops.map(e=>(0,q.jsx)(`span`,{className:`loop-dot loop-c${e.color%4}`,title:e.name},e.id))}):null,e.severity?(0,q.jsx)(`span`,{className:`gnode-issue issue-dot-${e.severity}`,role:`img`,"aria-label":`has ${e.severity}s`}):null,(0,q.jsx)($d,{type:`source`,position:Y.Bottom,isConnectable:!1,className:`ghandle`})]})}),Rh={graph:Lh},zh={graph:jh},Bh=mh(Vh,()=>Wm(Ym().store));function Vh({issues:e,onNodeTap:t,useBoxes:n}){let r=Ym(),i=Wm(r.store),[a,o]=(0,K.useState)({}),s=(0,K.useRef)(a),c=e=>{s.current=e,o(e)},[l,u]=(0,K.useState)({}),d=(0,K.useMemo)(()=>Bm(i).positions,[i]),f=(0,K.useMemo)(()=>Pm(e),[e]),{panel:p,mode:m,highlight:h}=r,g=p?.type===`node`?p.id:void 0,_=n(i,d,l,f,h.nodes,g),v=_?.doc??i,y=_?.positions??d,b=p?.type===`edge`?p.id:void 0,x=m.type===`pick`?v.loops.find(e=>e.id===m.loopId):p?.type===`loop`?v.loops.find(e=>e.id===p.id):void 0,S=x?v.loops.indexOf(x):void 0,C=m.type===`pick`?x:void 0,T=(0,K.useMemo)(()=>v.nodes.map(e=>{let t=v.loops.map((e,t)=>({id:e.id,name:e.name,color:t,members:e.members})).filter(t=>t.members.includes(e.id)).map(({members:e,...t})=>t);return{id:e.id,type:`graph`,position:a[e.id]??y[e.id]??{x:0,y:0},ariaLabel:Nh(e),...l[e.id]?{measured:l[e.id]}:{},data:{node:e,severity:f.get(e.id),loops:t,selected:e.id===g,highlighted:h.nodes.has(e.id),connectFrom:m.type===`connect`&&m.from===e.id,picked:C?C.members.includes(e.id):void 0,loopColor:x?.members.includes(e.id)?S:void 0}}}),[v,y,a,l,f,g,h,m,C,x,S]),E=(0,K.useMemo)(()=>{let e={};for(let t of v.nodes){let n=a[t.id]??y[t.id]??{x:0,y:0},r=l[t.id];e[t.id]={x:n.x,y:n.y,w:r?.width??Im,h:r?.height??Lm}}let t=$m(v,e);return{bends:t,spots:lh(v,e,t)}},[v,y,a,l]),D=(0,K.useMemo)(()=>{let e=new Set(v.nodes.map(e=>e.id));return v.edges.filter(t=>e.has(t.from)&&e.has(t.to)).map(e=>{let t=v.loops.findIndex(t=>t.back.includes(e.id));return{id:e.id,source:e.from,target:e.to,type:`graph`,data:{edge:e,back:t>=0,loopColor:t>=0?t:void 0,bend:E.bends.get(e.id)??0,labelAt:E.spots.get(e.id),severity:f.get(e.id),selected:e.id===b,highlighted:h.edges.has(e.id),picked:C?C.back.includes(e.id):void 0}}})},[v,E,f,b,h,C]),O=(0,K.useCallback)(e=>{let t={},n={},i=[];for(let r of e)r.type===`dimensions`&&r.dimensions&&(t[r.id]=r.dimensions),r.type===`position`&&(r.dragging&&r.position?n[r.id]=r.position:r.dragging===!1&&i.push(r.id));if(Object.keys(t).length>0&&u(e=>({...e,...t})),Object.keys(n).length>0&&c({...s.current,...n}),i.length>0){let e={},t={...s.current};for(let n of i)t[n]&&(e[n]=t[n]),delete t[n];Object.keys(e).length>0&&r.store.update(t=>{let n=Bm(t);return w(t,n.unplaced.length>0?{...n.positions,...e}:e)}),c(t)}},[r.store]);return(0,q.jsxs)(Np,{nodes:_?.with(T)??T,edges:D,nodeTypes:Rh,edgeTypes:zh,onNodesChange:O,onNodeClick:(e,n)=>t(n.id),onKeyDown:Ph(t),onEdgeClick:(e,t)=>r.onEdgeTap(t.id),onMove:e=>{e&&(r.viewMoved.current=!0)},onPaneClick:()=>{r.mode.type===`idle`&&(r.setHighlight({nodes:new Set,edges:new Set,loops:new Set,graph:!1}),r.setSelection([]),r.panel&&[`node`,`edge`,`loop`,`add`].includes(r.panel.type)&&r.openPanel(null))},nodesConnectable:!1,edgesFocusable:!1,elementsSelectable:!1,deleteKeyCode:null,selectionKeyCode:null,multiSelectionKeyCode:null,nodeDragThreshold:6,nodeClickDistance:6,paneClickDistance:6,minZoom:.2,maxZoom:2,fitView:!0,fitViewOptions:Sh,attributionPosition:`top-right`,children:[(0,q.jsx)(Gp,{variant:Vp.Dots,gap:24,size:1.2}),(0,q.jsx)(Dh,{pad:hh,refit:r.viewMoved})]})}var Hh=`.stage>.look-dot{z-index:var(--z-overlay);position:absolute;top:74px;right:10px}.stage:has(>.graph-views.is-space)>.look-dot{display:none}.stage:has(.graph-views-note)>.look-dot{top:160px}`,Uh=document.createElement(`style`);Uh.textContent=Hh,document.head.append(Uh);function Wh(){return(0,q.jsx)(`div`,{className:`site-theme look-dot`,style:Gh,children:(0,q.jsx)(`button`,{className:`site-theme-toggle`,type:`button`,"aria-label":`Picture theme`,"aria-haspopup":`menu`,"data-pictures":``,style:Kh,children:(0,q.jsx)(`span`,{className:`site-theme-dot`,"aria-hidden":`true`})})})}var Gh={"--night-line":`var(--line-strong)`,"--night-2":`var(--surface)`,"--night-ink":`var(--ink)`,"--bright":`var(--accent)`,"--shadow-night":`var(--shadow)`},Kh={background:`var(--surface)`,boxShadow:`var(--shadow)`},qh=`0.4.0`,Jh=e=>h(e),Yh=(e,t)=>Jh(e)?Ae(e,{theme:t}):te(e,{theme:t}),Xh=(e,t,n,r=``)=>`${e.id||`graph`}.${r&&`${r}-`}${t}.${n}`,Zh=()=>r(`offline`,()=>a(()=>import(`./offline-Byh4d-Wf.js`),[])).then(({offlinePageWith:e})=>t=>e(V,t,{version:qh})),Qh=e=>`${e.id||`graph`}.html`;async function $h(e,t=3){let n=/<svg[^>]* width="([\d.]+)" height="([\d.]+)"/.exec(e);if(!n)throw Error(`the picture has no size`);let r=Math.round(Number(n[1])*t),i=Math.round(Number(n[2])*t),a=URL.createObjectURL(new Blob([e],{type:`image/svg+xml;charset=utf-8`}));try{let e=new Image;e.decoding=`sync`,await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(Error(`the browser could not draw the picture`)),e.src=a});let t=document.createElement(`canvas`);t.width=r,t.height=i;let n=t.getContext(`2d`);if(!n)throw Error(`this browser has no canvas to draw on`);return n.drawImage(e,0,0,r,i),await new Promise((e,n)=>t.toBlob(t=>t?e(t):n(Error(`the browser could not make a PNG`)),`image/png`))}finally{URL.revokeObjectURL(a)}}function eg(e){let t=(0,K.useId)();return(0,q.jsxs)(`div`,{className:e.wide?`field field-wide`:`field`,children:[(0,q.jsx)(`label`,{className:`field-label`,htmlFor:t,children:e.label}),e.children(t),e.hint?(0,q.jsx)(`div`,{className:`field-hint`,children:e.hint}):null]})}function $(e){let t=(0,K.useRef)(!1);return(0,q.jsx)(eg,{label:e.label,hint:e.hint,children:n=>(0,q.jsx)(`input`,{id:n,className:e.mono?`input mono`:`input`,value:e.value,placeholder:e.placeholder,autoFocus:e.autoFocus,onFocus:n=>{e.autoFocus&&!t.current&&(t.current=!0,n.target.select())},autoComplete:`off`,autoCapitalize:e.mono?`off`:`sentences`,spellCheck:!e.mono,onChange:t=>Hm(()=>e.onChange(t.target.value))})})}function tg(e){return(0,q.jsx)(eg,{label:e.label,hint:e.hint,children:t=>(0,q.jsx)(ng,{id:t,value:e.value,placeholder:e.placeholder,rows:e.rows??3,onChange:e.onChange})})}function ng(e){let t=(0,K.useRef)(null);return(0,K.useEffect)(()=>{let e=t.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+2}px`)},[e.value]),(0,q.jsx)(`textarea`,{ref:t,id:e.id,className:`input textarea`,rows:e.rows,value:e.value,placeholder:e.placeholder,onChange:t=>Hm(()=>e.onChange(t.target.value)),onFocus:e.onFocus,onBlur:e.onBlur})}var rg=e=>e.split(`
|
|
9
|
-
`).map(e=>e.trim()).filter(e=>e!==``);function ig(e){let t=(e.value??[]).join(`
|
|
10
|
-
`),[n,r]=(0,K.useState)(t),i=(0,K.useRef)(!1);return(0,K.useEffect)(()=>{r(e=>i.current&&rg(e).join(`
|
|
11
|
-
`)===t?e:t)},[t]),(0,q.jsx)(eg,{label:e.label,hint:e.hint??`One per line.`,children:a=>(0,q.jsx)(ng,{id:a,rows:2,value:n,placeholder:e.placeholder,onFocus:()=>i.current=!0,onBlur:()=>{i.current=!1,r(t)},onChange:n=>{r(n);let i=rg(n);i.join(`
|
|
12
|
-
`)!==t&&Hm(()=>e.onChange(i))}})})}function ag(e){let t=e.value===void 0?``:String(e.value),[n,r]=(0,K.useState)(t),i=(0,K.useRef)(!1),a=t=>{let n=Number(t);return t.trim()===``||!Number.isFinite(n)?void 0:e.integer?Math.trunc(n):n};return(0,K.useEffect)(()=>{r(n=>i.current&&a(n)===e.value?n:t)},[t]),(0,q.jsx)(eg,{label:e.label,hint:e.hint,children:a=>(0,q.jsx)(`input`,{id:a,className:`input`,inputMode:e.integer?`numeric`:`decimal`,value:n,placeholder:e.placeholder,onFocus:()=>i.current=!0,onBlur:()=>{i.current=!1,r(t)},onChange:t=>{let n=t.target.value;r(n);let i=Number(n);n.trim()===``?Hm(()=>e.onChange(void 0)):Number.isFinite(i)&&Hm(()=>e.onChange(e.integer?Math.trunc(i):i))}})})}function og(e){let t=(0,K.useId)();return(0,q.jsxs)(`div`,{className:`field`,children:[(0,q.jsx)(`div`,{className:`field-label`,id:t,children:e.label}),(0,q.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":t,children:e.options.map(t=>(0,q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t.value,className:e.value===t.value?`seg seg-on`:`seg`,onClick:()=>e.onChange(t.value),children:t.label},t.value))}),e.hint?(0,q.jsx)(`div`,{className:`field-hint`,children:e.hint}):null]})}function sg(e){return(0,q.jsx)(eg,{label:e.label,hint:e.hint,children:t=>(0,q.jsx)(`select`,{id:t,className:`input select`,value:e.value,onChange:t=>e.onChange(t.target.value),children:e.options.map(e=>(0,q.jsx)(`option`,{value:e.value,children:e.label},e.value))})})}function cg(e){let t=(0,K.useId)();return(0,q.jsxs)(`div`,{className:`field`,children:[(0,q.jsxs)(`label`,{className:`toggle`,htmlFor:t,children:[(0,q.jsx)(`input`,{id:t,type:`checkbox`,checked:e.checked,onChange:t=>e.onChange(t.target.checked)}),(0,q.jsx)(`span`,{className:`toggle-track`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`toggle-label`,children:e.label})]}),e.hint?(0,q.jsx)(`div`,{className:`field-hint`,children:e.hint}):null]})}function lg(e){let t=e.value??[],[n,r]=(0,K.useState)(``),i=(0,K.useId)(),a=n=>e.onChange(t.includes(n)?t.filter(e=>e!==n):[...t,n]),o=t.filter(t=>!e.catalog.includes(t));return(0,q.jsxs)(`div`,{className:`field`,children:[(0,q.jsx)(`div`,{className:`field-label`,id:i,children:e.label}),(0,q.jsxs)(`div`,{className:`chips`,role:`group`,"aria-labelledby":i,children:[e.catalog.map(e=>(0,q.jsx)(`button`,{type:`button`,"aria-pressed":t.includes(e),className:t.includes(e)?`chip chip-on`:`chip`,onClick:()=>a(e),children:e},e)),o.map(e=>(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":`true`,className:`chip chip-on`,onClick:()=>a(e),children:[e,` `,(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`×`}),(0,q.jsx)(`span`,{className:`sr-only`,children:` (remove)`})]},e))]}),(0,q.jsxs)(`div`,{className:`inline-add`,children:[(0,q.jsx)(`input`,{className:`input mono`,value:n,"aria-label":`Custom ${e.label.toLowerCase()}`,placeholder:e.customPlaceholder??`custom…`,autoCapitalize:`off`,onChange:e=>r(e.target.value)}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,disabled:n.trim()===``,onClick:()=>{let i=n.trim();i!==``&&!t.includes(i)&&e.onChange([...t,i]),r(``)},children:`Add`})]}),e.hint?(0,q.jsx)(`div`,{className:`field-hint`,children:e.hint}):null]})}function ug(e){return(0,q.jsxs)(`section`,{className:`section`,children:[(0,q.jsxs)(`div`,{className:`section-head`,children:[(0,q.jsx)(`h3`,{children:e.title}),e.aside]}),e.children]})}function dg(e){return(0,q.jsxs)(`details`,{className:`more`,children:[(0,q.jsx)(`summary`,{children:e.title??`More fields`}),(0,q.jsx)(`div`,{className:`more-body`,children:e.children})]})}var fg=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches,pg=async()=>{if(document.querySelector(`main.stage[data-look]`)||Bt())try{return(await It()).look()}catch{return null}},mg=`The picture themes could not be fetched (they need a connection the first time), so this copy is in Paper.`,hg=`The offline page could not be made: its maker could not be fetched. It needs a connection the first time. The pictures above are made without it.`;function gg({doc:e}){let[t,n]=(0,K.useState)(()=>fg()?`dark`:`light`),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(!1),s=async()=>{let n=await pg();return i(n===null?mg:null),n?{svg:n.picture(Yh(e,`auto`),t),look:n.id}:{svg:Yh(e,t),look:``}},c=async()=>{try{let{svg:n,look:r}=await s();xt(Xh(e,t,`png`,r),await $h(n),`image/png`)}catch(e){i(`${e.message}. The SVG picture is the same drawing.`)}},l=async()=>{let n=await s();xt(Xh(e,t,`svg`,n.look),n.svg,`image/svg+xml`)},u=async()=>{let t=await pg();i(t===null?mg:null),o(!0);let n;try{n=await Zh()}catch{i(hg);return}finally{o(!1)}let r=n(e);xt(Qh(e),t?t.page(r):r,`text/html`)};return(0,q.jsxs)(`div`,{className:`keep`,role:`group`,"aria-label":`Keep a copy`,children:[(0,q.jsx)(`h3`,{className:`files-title`,children:`Keep a copy`}),(0,q.jsx)(`div`,{className:`site-theme`,style:Gh,children:(0,q.jsx)(`button`,{type:`button`,className:`btn`,"data-pictures":``,"aria-haspopup":`menu`,children:`Picture theme`})}),(0,q.jsx)(og,{label:`Picture colors`,value:t,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:n}),(0,q.jsxs)(`div`,{className:`export-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>void c(),children:`Picture (PNG)`}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>void l(),children:`Picture (SVG)`}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,disabled:a,"aria-busy":a,onClick:()=>void u(),children:`Offline page (.html)`})]}),r?(0,q.jsx)(`p`,{className:`refusal`,role:`alert`,children:r}):null,(0,q.jsx)(`p`,{className:`field-hint`,children:`The picture is laid out for a phone. The offline page holds the picture, every brief and the document itself in one file, and opens with no network.`})]})}var _g=we.map(e=>({id:e,title:H(e)??e})),vg,yg=()=>r(`ExportPanel`,()=>a(()=>import(`./ExportPanel-VWus7GM3.js`),__vite__mapDeps([5,1,2,6,7,8,9]))).then(e=>vg=e);function bg(){let[e,t]=(0,K.useState)(vg?`here`:`coming`);(0,K.useEffect)(()=>{if(e!==`coming`)return;let n=!1;return yg().then(()=>!n&&t(`here`),()=>!n&&t(`failed`)),()=>{n=!0}},[e]);let n=Ym(),r=Wm(n.store),i=(0,K.useMemo)(()=>et(r),[r]),a=(0,K.useMemo)(()=>ft(r).map(e=>jm(e,r,_g)),[r]);return e===`here`&&vg?(0,q.jsx)(vg.ExportPanel,{doc:r,own:i,needs:a,keep:(0,q.jsx)(gg,{doc:r}),open:e=>n.openPanel({type:e}),exported:n.markExported}):(0,q.jsx)(`div`,{className:`inspector`,children:e===`failed`?(0,q.jsxs)(`div`,{className:`refusal`,role:`alert`,children:[(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`strong`,{children:`The Export panel could not be fetched.`}),` It needs a connection the first time. Nothing of the graph is lost.`]}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>t(`coming`),children:`Try again`})]}):(0,q.jsx)(`p`,{className:`field-hint`,role:`status`,children:`Opening export…`})})}function xg({id:e,name:t,graph:n,onRenamed:r}){let i=Ym(),[a,o]=(0,K.useState)(e),[s,c]=(0,K.useState)();(0,K.useEffect)(()=>o(e),[e]);let l=()=>{let t=Be(a,``);if(t===``||t===e){o(e),c(void 0);return}if(x(i.store.get()).has(t)){o(e),c(`"${t}" is already used in this graph.`);return}c(void 0),i.store.update(r=>n?{...r,id:t}:Ie(r,e,t)),o(t),r?.(t)};return(0,q.jsx)(eg,{label:`Id`,hint:s??(t!==void 0&&k(e,t)?`Follows the name until you change it here. References update with it.`:`References to it update when you change it.`),children:e=>(0,q.jsx)(`input`,{id:e,className:`input mono`,value:a,autoCapitalize:`off`,autoComplete:`off`,spellCheck:!1,onChange:e=>o(e.target.value),onBlur:l})})}function Sg({id:e}){let t=Ym(),n=Wm(t.store),r=n.edges.find(t=>t.id===e);if(!r)return(0,q.jsx)(`p`,{className:`empty`,children:`This edge is no longer in the graph.`});let i=n=>t.store.update(t=>C(t,e,n)),a=e=>n.nodes.find(t=>t.id===e)?.name??e,o=r.when??`always`,s=typeof o==`string`?o:`verdict`,c=n.loops.filter(t=>t.back.includes(e));return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsxs)(`p`,{className:`edge-route`,children:[(0,q.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>t.openPanel({type:`node`,id:r.from}),children:a(r.from)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:` → `}),(0,q.jsx)(`span`,{className:`sr-only`,children:` to `}),(0,q.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>t.openPanel({type:`node`,id:r.to}),children:a(r.to)})]}),c.length>0?(0,q.jsx)(`div`,{className:`inspector-actions`,children:c.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:()=>t.openPanel({type:`loop`,id:e.id}),children:[`Back edge of `,e.name]},e.id))}):null,(0,q.jsx)(og,{label:`When`,value:s,options:[{value:`always`,label:`always`},{value:`pass`,label:`pass`},{value:`fail`,label:`fail`},{value:`verdict`,label:`verdict…`}],hint:s===`always`&&r.when===void 0?`Default: always.`:void 0,onChange:e=>i(t=>v(t,`when`,e===`verdict`?{verdict:typeof t.when==`object`?t.when.verdict:``}:e))}),typeof o==`object`?(0,q.jsx)($,{label:`Verdict label`,value:o.verdict,mono:!0,placeholder:`needs-evidence`,onChange:e=>i(t=>({...t,when:{verdict:e}}))}):null,(0,q.jsx)(og,{label:`Isolation`,value:r.isolation??`default`,options:[{value:`default`,label:`default`},{value:`fresh`,label:`fresh`},{value:`shared`,label:`shared`}],hint:`Fresh (the default): the next worker sees only its brief, its inputs and the evidence below.`,onChange:e=>i(t=>v(t,`isolation`,e==="default"?void 0:e))}),(0,q.jsx)(ig,{label:`Evidence`,value:r.evidence,hint:`One per line. What the downstream node may inspect; everything else is hidden.`,onChange:e=>i(t=>v(t,`evidence`,ue(e)))}),(0,q.jsx)(cg,{label:`Needs human approval`,checked:r.approval===!0,onChange:e=>i(t=>v(t,`approval`,e?!0:void 0))}),(0,q.jsxs)(dg,{children:[(0,q.jsx)(xg,{id:e,onRenamed:e=>t.openPanel({type:`edge`,id:e})}),(0,q.jsx)($,{label:`Label`,value:r.label??``,onChange:e=>i(t=>v(t,`label`,G(e)))}),(0,q.jsx)(ag,{label:`Concurrency cap`,integer:!0,value:r.concurrency?.max,onChange:e=>i(t=>v(t,`concurrency`,e===void 0?void 0:{max:e}))}),(0,q.jsx)(ag,{label:`Retries`,integer:!0,value:r.retry?.max,onChange:e=>i(t=>v(t,`retry`,e===void 0?void 0:{max:e}))})]}),(0,q.jsx)(`div`,{className:`danger-zone`,children:(0,q.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:()=>{let n=t.store.get().edges.find(t=>t.id===e);t.store.update(t=>B(t,e)),t.openPanel(null),t.deleted(n?`edge ${n.from} → ${n.to}`:`edge`)},children:`Delete edge`})})]})}var Cg=`__other`,wg=[{value:`adaptive`,label:`adaptive`,line:`The lead may amend its copy of the graph during a run, visibly; brakes never loosen.`},{value:`propose`,label:`propose`,line:`The lead changes nothing and records proposals for you.`},{value:`fixed`,label:`fixed`,line:`The lead follows the graph exactly and halts to ask when it cannot.`}];function Tg({autoFocusName:e,renameWarning:t}){let n=Ym(),r=Wm(n.store),i=r.target?.harness,a=i===void 0||we.includes(i),[o,c]=(0,K.useState)(!a),{unplaced:l}=Bm(r);return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)($,{label:`Name`,value:r.name,autoFocus:e,onChange:e=>n.store.update(t=>j(t,e))}),t,(0,q.jsx)(xg,{id:r.id,name:r.name,graph:!0}),(0,q.jsx)(tg,{label:`Goal`,value:r.goal??``,rows:3,placeholder:`What this is for. A package for a harness needs it; a plan does not.`,onChange:e=>n.store.update(t=>Pe(t,`goal`,G(e)))}),(0,q.jsx)(sg,{label:`Target harness`,value:o?Cg:i??``,options:[{value:``,label:`None: this is a plan`},...we.map(e=>({value:e,label:H(e)??e})),{value:Cg,label:`other…`}],hint:i===void 0?`A plan needs no harness. Choose one when a coding harness is to run this: a package is compiled for it.`:a?`Export compiles a package for the selected harness.`:`grooph has no compiler for "${i}". The plan can still be kept; a package needs ${we.map(e=>H(e)??e).join(` or `)}, chosen from this list.`,onChange:e=>{c(e===Cg),e!==Cg&&n.store.update(t=>s(t,e===``?void 0:e))}}),o?(0,q.jsx)($,{label:`Harness id`,value:i??``,mono:!0,onChange:e=>n.store.update(t=>s(t,G(e)))}):null,(0,q.jsx)(og,{label:`Adaptation`,value:r.adaptation??`adaptive`,options:wg,onChange:e=>n.store.update(t=>Pe(t,`adaptation`,e===`adaptive`?void 0:e)),hint:(0,q.jsx)(`ul`,{className:`level-list`,children:wg.map(e=>(0,q.jsxs)(`li`,{className:e.value===(r.adaptation??`adaptive`)?`is-on`:void 0,children:[(0,q.jsx)(`strong`,{children:e.label}),e.value===`adaptive`?` (default)`:``,` — `,e.line]},e.value))})}),(0,q.jsxs)(ug,{title:`Constraints`,children:[(0,q.jsx)($,{label:`Budget`,value:r.constraints?.budget??``,placeholder:`about 40 lead turns`,onChange:e=>n.store.update(t=>u(t,`budget`,G(e)))}),(0,q.jsx)($,{label:`Time`,value:r.constraints?.time??``,onChange:e=>n.store.update(t=>u(t,`time`,G(e)))}),(0,q.jsx)(tg,{label:`Other`,value:r.constraints?.other??``,rows:2,onChange:e=>n.store.update(t=>u(t,`other`,G(e)))})]}),(0,q.jsx)(tg,{label:`Description`,value:r.description??``,rows:3,placeholder:`One paragraph a human or an executive can read.`,onChange:e=>n.store.update(t=>Pe(t,`description`,G(e)))}),(0,q.jsxs)(ug,{title:`Loops`,children:[r.loops.length===0?(0,q.jsx)(`p`,{className:`field-hint`,children:`No loops yet. Use Loop in the toolbar.`}):null,(0,q.jsx)(`div`,{className:`chips`,children:r.loops.map(e=>(0,q.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>n.openPanel({type:`loop`,id:e.id}),children:e.name||e.id},e.id))})]}),(0,q.jsxs)(ug,{title:`Reuse`,children:[(0,q.jsx)(`p`,{className:`field-hint`,children:`Keep this graph, or some of its nodes, as a template in Yours, to start from or insert later.`}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>n.openPanel({type:`save-template`}),children:`Save as template…`})]}),(0,q.jsxs)(ug,{title:`Layout`,children:[(0,q.jsx)(`p`,{className:`field-hint`,children:l.length===0?`Every node's position is saved in the document.`:r.layout?`${l.length} node${l.length===1?` is`:`s are`} placed automatically and not saved yet.`:`Placed automatically. Positions are saved when you move a node, or now:`}),l.length>0?(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>n.store.update(e=>w(e,Bm(e).positions)),children:`Save layout`}):null]}),(0,q.jsx)(ug,{title:`In the document, not editable here yet`,children:(0,q.jsxs)(`dl`,{className:`readonly`,children:[(0,q.jsx)(`dt`,{children:`Version`}),(0,q.jsx)(`dd`,{children:r.version}),r.lineage?.pattern?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{children:`Pattern`}),(0,q.jsx)(`dd`,{className:`mono`,children:r.lineage.pattern})]}):null,r.lineage?.from?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{children:`Derived from`}),(0,q.jsx)(`dd`,{className:`mono`,children:r.lineage.from})]}):null,(0,q.jsx)(`dt`,{children:`Policies`}),(0,q.jsx)(`dd`,{children:(r.policies??[]).length===0?`none`:(r.policies??[]).map(e=>(0,q.jsxs)(`span`,{className:`mono readonly-item`,children:[typeof e.kind==`string`?e.kind:`custom: ${e.kind.custom}`,` (`,e.scope,`)`]},e.id))}),(0,q.jsx)(`dt`,{children:`Groups`}),(0,q.jsx)(`dd`,{children:(r.groups??[]).length===0?`none`:(r.groups??[]).map(e=>e.name).join(`, `)}),(0,q.jsx)(`dt`,{children:`Run notes`}),(0,q.jsx)(`dd`,{children:(r.notes??[]).length})]})})]})}function Eg({id:e}){let t=Ym(),n=Wm(t.store),r=n.loops.find(t=>t.id===e);if(!r)return(0,q.jsx)(`p`,{className:`empty`,children:`This loop is no longer in the graph.`});let i=n=>t.store.update(t=>E(t,e,n)),a=t.mode.type===`pick`&&t.mode.loopId===e,o=D(xe(n),{...r,mode:void 0}),s=new Set(r.members),c=n.edges.filter(e=>s.has(e.from)&&s.has(e.to)||r.back.includes(e.id)),l=e=>n.nodes.find(t=>t.id===e)?.name??e;return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)($,{label:`Name`,value:r.name,onChange:n=>{let r=t.store.updateWith(t=>f(t,e,n));r.id!==e&&(t.openPanel({type:`loop`,id:r.id}),a&&t.setMode({type:`pick`,loopId:r.id}))}}),(0,q.jsx)(xg,{id:e,name:r.name,onRenamed:e=>t.openPanel({type:`loop`,id:e})}),(0,q.jsxs)(ug,{title:`Members and back edges`,aside:(0,q.jsx)(`button`,{type:`button`,className:a?`btn btn-primary`:`btn`,"aria-pressed":a,onClick:()=>t.setMode(a?{type:`idle`}:{type:`pick`,loopId:e}),children:a?`Done picking`:`Pick on canvas`}),children:[(0,q.jsx)(`p`,{className:`field-hint`,children:a?`Tap nodes to add or remove members. Tap an edge's label to mark it as a back edge.`:`The cycle lives inside the members; a back edge returns work to an earlier member.`}),(0,q.jsxs)(`div`,{className:`field`,children:[(0,q.jsx)(`div`,{className:`field-label`,children:`Members`}),(0,q.jsxs)(`div`,{className:`chips`,children:[n.nodes.map(n=>(0,q.jsx)(`button`,{type:`button`,"aria-pressed":s.has(n.id),className:s.has(n.id)?`chip chip-on`:`chip`,onClick:()=>t.store.update(t=>S(t,e,n.id)),children:n.name||n.id},n.id)),n.nodes.length===0?(0,q.jsx)(`span`,{className:`field-hint`,children:`No nodes yet.`}):null]})]}),(0,q.jsxs)(`div`,{className:`field`,children:[(0,q.jsx)(`div`,{className:`field-label`,children:`Back edges`}),(0,q.jsxs)(`div`,{className:`chips`,children:[c.map(n=>(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":r.back.includes(n.id),className:r.back.includes(n.id)?`chip chip-on`:`chip`,onClick:()=>t.store.update(t=>fe(t,e,n.id)),children:[l(n.from),` → `,l(n.to)]},n.id)),c.length===0?(0,q.jsx)(`span`,{className:`field-hint`,children:`Add members first; edges between them appear here.`}):null]})]})]}),(0,q.jsx)(og,{label:`Mode`,value:r.mode??`auto`,options:[{value:`auto`,label:`auto (${o})`},{value:`judgment`,label:`judgment`},{value:`grind`,label:`grind`}],hint:`Judgment loops need a bar. Auto: grind when every back edge starts at a check node.`,onChange:e=>i(t=>v(t,`mode`,e===`auto`?void 0:e))}),(0,q.jsx)(Dg,{doc:n,loop:r}),(0,q.jsx)(Og,{doc:n,loop:r}),(0,q.jsxs)(`div`,{className:`danger-zone`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:()=>{t.store.update(t=>Ne(t,e)),t.setMode({type:`idle`}),t.openPanel(null),t.deleted(`loop ${r.name||e}`)},children:`Delete loop`}),(0,q.jsx)(`p`,{className:`field-hint`,children:`The nodes and edges stay; only the loop goes.`})]})]})}function Dg({doc:e,loop:t}){let n=Ym(),r=t.bar,i=e=>n.store.update(n=>A(n,t.id,e));if(!r)return(0,q.jsxs)(ug,{title:`Bar`,children:[(0,q.jsx)(`p`,{className:`field-hint`,children:`What “good enough to stop” is, and what a critic inspects to decide it.`}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>i({name:``,inspects:[],acceptance:``}),children:`Add bar`})]});let a=(e,t)=>i({...r,inspects:r.inspects.map((n,r)=>r===e?t(n):n)});return(0,q.jsxs)(ug,{title:`Bar`,aside:(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:()=>i(void 0),children:`Remove bar`}),children:[(0,q.jsx)($,{label:`Bar name`,value:r.name,onChange:e=>i({...r,name:e})}),(0,q.jsxs)(`div`,{className:`field`,children:[(0,q.jsx)(`div`,{className:`field-label`,children:`Inspects`}),r.inspects.map((e,t)=>(0,q.jsxs)(`div`,{className:`card`,role:`group`,"aria-label":`Evidence ${t+1}`,children:[(0,q.jsx)(sg,{label:`Kind`,value:e.kind,options:Em.map(e=>({value:e,label:e})),onChange:e=>a(t,t=>({...t,kind:e}))}),(0,q.jsx)($,{label:`Ref`,value:e.ref,mono:!0,onChange:e=>a(t,t=>({...t,ref:e}))}),(0,q.jsx)($,{label:`Note`,value:e.note??``,onChange:e=>a(t,t=>v(t,`note`,G(e)))}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:()=>i({...r,inspects:r.inspects.filter((e,n)=>n!==t)}),children:`Remove evidence`})]},t)),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>i({...r,inspects:[...r.inspects,{kind:`file`,ref:``}]}),children:`Add evidence`}),(0,q.jsx)(`div`,{className:`field-hint`,children:`An adjective is not a bar: name a file, url, metric, checklist or artifact.`})]}),(0,q.jsx)(tg,{label:`Acceptance`,value:r.acceptance,placeholder:`Reachable “good enough to stop”.`,onChange:e=>i({...r,acceptance:e})}),(0,q.jsx)(tg,{label:`Aspiration`,value:r.aspiration??``,placeholder:`Optional. Directional; never the stop condition.`,onChange:e=>i(v(r,`aspiration`,G(e)))}),(0,q.jsx)(sg,{label:`Answer key from`,value:r.answerKeyFrom??``,options:[{value:``,label:`(none)`},...e.nodes.map(e=>({value:e.id,label:e.name||e.id}))],onChange:e=>i(v(r,`answerKeyFrom`,e===``?void 0:e))})]})}function Og({doc:e,loop:t}){let n=Ym(),[r,i]=(0,K.useState)(t.stops.some(e=>e.kind===`bar-passed`)?`max-iterations`:`bar-passed`),a=(e,r)=>n.store.update(n=>me(n,t.id,e,r)),o=[{value:``,label:`(default)`},...e.nodes.map(e=>({value:e.id,label:e.name||e.id}))];return(0,q.jsxs)(ug,{title:`Stops`,children:[(0,q.jsx)(`p`,{className:`field-hint`,children:`Checked after every pass, in this order; the first that fires wins.`}),t.stops.map((e,r)=>(0,q.jsxs)(`div`,{className:`card`,role:`group`,"aria-label":`Stop ${r+1}`,"data-stop-kind":e.kind,children:[(0,q.jsxs)(`div`,{className:`card-head`,children:[(0,q.jsx)(`span`,{className:`card-index`,children:r+1}),(0,q.jsx)(sg,{label:`Stop`,value:e.kind,options:Dm.map(e=>({value:e,label:Am[e]})),onChange:t=>a(r,ve(t,e))})]}),(0,q.jsx)(kg,{stop:e,onChange:e=>a(r,e)}),(0,q.jsx)(sg,{label:`Then continue at`,value:e.then??``,options:o,onChange:t=>a(r,v(e,`then`,t===``?void 0:t))}),(0,q.jsxs)(`div`,{className:`card-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,disabled:r===0,"aria-label":`Move stop ${r+1} up`,onClick:()=>n.store.update(e=>se(e,t.id,r,-1)),children:`Up`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,disabled:r===t.stops.length-1,"aria-label":`Move stop ${r+1} down`,onClick:()=>n.store.update(e=>se(e,t.id,r,1)),children:`Down`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet btn-danger-text`,"aria-label":`Remove stop ${r+1}`,onClick:()=>n.store.update(e=>W(e,t.id,r)),children:`Remove`})]})]},r)),(0,q.jsxs)(`div`,{className:`inline-add`,children:[(0,q.jsx)(`select`,{className:`input select`,"aria-label":`Stop kind to add`,value:r,onChange:e=>i(e.target.value),children:Dm.map(e=>(0,q.jsx)(`option`,{value:e,children:Am[e]},e))}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>n.store.update(e=>je(e,t.id,r)),children:`Add stop`})]})]})}function kg({stop:e,onChange:t}){switch(e.kind){case`human`:return(0,q.jsx)(ag,{label:`Ask every N rounds`,integer:!0,value:e.every,placeholder:`only at the end`,onChange:n=>t(v(e,`every`,n))});case`budget`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(og,{label:`Measure`,value:e.measure,options:Om.map(e=>({value:e,label:e})),onChange:n=>t({...e,measure:n})}),(0,q.jsx)(ag,{label:`Limit`,value:e.limit,onChange:n=>t(n===void 0?Ag(e,`limit`):{...e,limit:n})})]});case`bar-passed`:return(0,q.jsx)(`p`,{className:`field-hint`,children:`Fires when the bar's acceptance is met; then the loop's pass edges are followed.`});case`diminishing-returns`:return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ag,{label:`Rounds`,integer:!0,value:e.rounds,onChange:n=>t(n===void 0?Ag(e,`rounds`):{...e,rounds:n})}),(0,q.jsx)($,{label:`Metric`,value:e.metric??``,onChange:n=>t(v(e,`metric`,G(n)))}),(0,q.jsx)(ag,{label:`Threshold`,value:e.threshold,onChange:n=>t(v(e,`threshold`,n))})]});case`evidence-invalid`:return(0,q.jsx)(ag,{label:`Rounds`,integer:!0,value:e.rounds,onChange:n=>t(n===void 0?Ag(e,`rounds`):{...e,rounds:n})});case`max-iterations`:return(0,q.jsx)(ag,{label:`Rounds at most`,integer:!0,value:e.n,onChange:n=>t(n===void 0?Ag(e,`n`):{...e,n})})}}var Ag=(e,t)=>{let n={...e};return delete n[t],n};function jg({node:e,update:t}){let n=e.model?.pin??{},[r,i]=(0,K.useState)(we[0]??`claude-code`),[a,o]=(0,K.useState)(``),s=e.model?.tier,c=e=>t(t=>{let n=t;return n.model?{...n,model:v(n.model,`pin`,Object.keys(e).length===0?void 0:e)}:t});return(0,q.jsx)(eg,{label:`Model pins`,hint:s?`Overrides the tier for one harness.`:`Choose a model tier first; a pin sits beside it.`,children:e=>(0,q.jsxs)(`div`,{className:`pins`,id:e,children:[Object.entries(n).map(([e,t])=>(0,q.jsxs)(`div`,{className:`pin-row`,children:[(0,q.jsx)(`span`,{className:`mono`,children:e}),(0,q.jsx)(`span`,{className:`mono pin-model`,children:t}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,"aria-label":`Remove pin for ${e}`,onClick:()=>{let{[e]:t,...r}=n;c(r)},children:`Remove`})]},e)),(0,q.jsxs)(`div`,{className:`inline-add`,children:[(0,q.jsx)(`input`,{className:`input mono`,"aria-label":`Pin harness`,value:r,autoCapitalize:`off`,onChange:e=>i(e.target.value)}),(0,q.jsx)(`input`,{className:`input mono`,"aria-label":`Pinned model`,placeholder:`model name`,value:a,autoCapitalize:`off`,onChange:e=>o(e.target.value)}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,disabled:!s||r.trim()===``||a.trim()===``,onClick:()=>{c({...n,[r.trim()]:a.trim()}),o(``)},children:`Pin`})]})]})})}function Mg({id:e,focusName:t}){let n=Ym(),r=Wm(n.store),i=r.nodes.find(t=>t.id===e);if(!i)return(0,q.jsx)(`p`,{className:`empty`,children:`This node is no longer in the graph.`});let a=t=>n.store.update(n=>p(n,e,t)),o=r.loops.filter(t=>t.members.includes(e));return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsxs)(`div`,{className:`inspector-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{n.setMode({type:`connect`,from:e})},children:`Connect from here`}),o.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:()=>n.openPanel({type:`loop`,id:e.id}),children:[`Loop: `,e.name]},e.id))]}),(0,q.jsx)($,{label:`Name`,value:i.name,autoFocus:t,onChange:t=>{let r=n.store.updateWith(n=>d(n,e,t));r.id!==e&&n.openPanel({type:`node`,id:r.id})}}),(0,q.jsx)(xg,{id:e,name:i.name,onRenamed:e=>n.openPanel({type:`node`,id:e})}),i.kind===`agent`?(0,q.jsx)(Lg,{node:i,update:a}):null,i.kind===`human-gate`?(0,q.jsx)(Rg,{node:i,update:a}):null,i.kind===`check`?(0,q.jsx)(zg,{node:i,update:a}):null,i.kind===`merge`?(0,q.jsx)(Bg,{node:i,update:a}):null,i.kind===`stop`?(0,q.jsx)(Vg,{node:i,update:a}):null,(0,q.jsxs)(dg,{children:[(0,q.jsx)(tg,{label:`Description`,value:i.description??``,onChange:e=>a(t=>v(t,`description`,G(e)))}),(0,q.jsx)(cg,{label:`Coupled`,checked:i.coupled===!0,hint:`Work that should not be fanned out.`,onChange:e=>a(t=>v(t,`coupled`,e?!0:void 0))}),i.kind===`agent`&&!L(i)?(0,q.jsx)(jg,{node:i,update:a}):null]}),(0,q.jsxs)(`div`,{className:`danger-zone`,children:[(0,q.jsxs)(`button`,{type:`button`,className:`btn btn-danger`,onClick:()=>{n.store.update(t=>Re(t,e)),n.openPanel(null),n.deleted(i.name||e)},children:[`Delete `,ym(i).toLowerCase()]}),(0,q.jsx)(`p`,{className:`field-hint`,children:`Also removes its edges and its place in loops.`})]})]})}var Ng=e=>t=>e(t),Pg=`__custom`,Fg=[`model`,`effort`,`skills`,`allow`,`deny`],Ig=(e,t)=>{let{by:n,...r}=e;if(t===`agent`)return r;let{model:i,effort:a,skills:o,allow:s,deny:c,...l}=r;return{...l,by:`person`}};function Lg({node:e,update:t}){let n=e=>t(Ng(e)),r=typeof e.role!=`string`,i=L(e),a=i&&Fg.some(t=>e[t]!==void 0&&!(Array.isArray(e[t])&&e[t].length===0));return(0,q.jsxs)(q.Fragment,{children:[e.role===`lead`&&!i?null:(0,q.jsx)(og,{label:`Done by`,value:Oe(e),options:[{value:`agent`,label:`an agent`},{value:`person`,label:`a person`}],hint:a?(0,q.jsxs)(q.Fragment,{children:[`A person does this step, and it still has an agent's model, effort, skills or capabilities, which are not read.`,` `,(0,q.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>n(e=>Ig(e,`person`)),children:`Take them off`})]}):i?`A person does this step. It has no model, effort, skills or capabilities; a graph with a person's step is a plan, and no package is made of it yet.`:void 0,onChange:e=>n(t=>Ig(t,e))}),(0,q.jsx)(sg,{label:`Role`,value:r?Pg:e.role,options:[...bm.map(e=>({value:e,label:e})),{value:Pg,label:`custom…`}],onChange:e=>n(t=>({...t,role:e===Pg?{custom:r?t.role.custom:``}:e}))}),r?(0,q.jsx)($,{label:`Custom role`,value:e.role.custom,onChange:e=>n(t=>({...t,role:{custom:e}})),hint:`A custom role joins no family unless the node owns artifacts (then it is a writer).`}):null,i?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(og,{label:`Model tier`,value:e.model?.tier??`default`,options:[...e.model?.pin?[]:[{value:`default`,label:`default`}],...xm.map(e=>({value:e,label:e}))],onChange:e=>n(t=>v(t,`model`,e==="default"?void 0:{...t.model,tier:e}))}),(0,q.jsx)(og,{label:`Effort`,value:e.effort??`default`,options:[{value:`default`,label:`default`},...Sm.map(e=>({value:e,label:e}))],onChange:e=>n(t=>v(t,`effort`,e==="default"?void 0:e))})]}),(0,q.jsx)(tg,{label:`Brief`,value:e.brief,rows:4,placeholder:i?`What the person does at this step.`:`What this node may and may not do.`,onChange:e=>n(t=>({...t,brief:e}))}),(0,q.jsx)(ig,{label:`Inputs`,value:e.inputs,onChange:e=>n(t=>v(t,`inputs`,ue(e)))}),(0,q.jsx)(ig,{label:`Outputs`,value:e.outputs,hint:`One per line. At least one: what it must leave behind.`,onChange:e=>n(t=>({...t,outputs:e}))}),i?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(lg,{label:`Allow`,value:e.allow,catalog:Cm,onChange:e=>n(t=>v(t,`allow`,ue(e)))}),(0,q.jsx)(lg,{label:`Deny`,value:e.deny,catalog:Cm,onChange:e=>n(t=>v(t,`deny`,ue(e)))})]}),(0,q.jsx)(ig,{label:`Owns`,value:e.owns,hint:`One artifact id per line. Only this node writes them.`,onChange:e=>n(t=>v(t,`owns`,ue(e)))}),(0,q.jsx)(lg,{label:`Irreversible actions`,value:e.irreversible,catalog:wm,onChange:e=>n(t=>v(t,`irreversible`,ue(e)))})]})}function Rg({node:e,update:t}){let n=e=>t(Ng(e));return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(tg,{label:`Prompt`,value:e.prompt,placeholder:`What the human is asked.`,onChange:e=>n(t=>({...t,prompt:e}))}),(0,q.jsx)(ig,{label:`Options`,value:e.options,onChange:e=>n(t=>v(t,`options`,ue(e)))})]})}function zg({node:e,update:t}){let n=e=>t(Ng(e)),r=e.check,i=e=>n(t=>({...t,check:e(t.check)}));return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(og,{label:`Check kind`,value:r.kind,options:Tm.map(e=>({value:e,label:e})),onChange:e=>i(t=>({...t,kind:e}))}),(0,q.jsx)($,{label:`Run`,value:r.run??``,mono:!0,onChange:e=>i(t=>v(t,`run`,G(e)))}),(0,q.jsx)($,{label:`Pass when`,value:r.pass,onChange:e=>i(t=>({...t,pass:e}))}),(0,q.jsx)(ag,{label:`Threshold`,value:r.threshold,onChange:e=>i(t=>v(t,`threshold`,e))})]})}function Bg({node:e,update:t}){let n=e=>t(Ng(e));return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ig,{label:`Merges`,value:e.merges,hint:`One artifact id per line.`,onChange:e=>n(t=>({...t,merges:e}))}),(0,q.jsx)($,{label:`Strategy`,value:e.strategy??``,onChange:e=>n(t=>v(t,`strategy`,G(e)))})]})}function Vg({node:e,update:t}){let n=e=>t(Ng(e));return(0,q.jsx)(og,{label:`Outcome`,value:e.outcome??`none`,options:[{value:`none`,label:`unset`},{value:`success`,label:`success`},{value:`halt`,label:`halt`}],onChange:e=>n(t=>v(t,`outcome`,e===`none`?void 0:e))})}function Hg({doc:e,onOpen:t,current:n}){let r=(0,K.useMemo)(()=>be(e),[e]),i=(0,K.useRef)(null);(0,K.useEffect)(()=>{i.current?.querySelector(`.is-current`)?.scrollIntoView({block:`nearest`})},[n]);let a=(e,r)=>(0,q.jsxs)(`section`,{className:r>0&&e.id===n?`outline-section is-current`:`outline-section`,"data-outline-id":e.id,children:[(0,q.jsx)(`p`,{className:`outline-kind`,children:e.kind}),(0,q.jsxs)(`div`,{className:`outline-head`,children:[(0,q.jsx)(`h3`,{children:e.title}),t&&r>0&&e.kind!==`Policy`&&e.kind!==`Subgrooph`?(0,q.jsx)(`button`,{type:`button`,className:`chip chip-small`,onClick:()=>t(e.id,e.kind),children:`Edit`}):null]}),(0,q.jsx)(`dl`,{className:`outline-items`,children:e.items.map(e=>(0,q.jsxs)(`div`,{className:`outline-item`,children:[(0,q.jsx)(`dt`,{children:e.label}),(0,q.jsx)(`dd`,{children:e.list?(0,q.jsx)(`ul`,{className:`plain-list`,children:e.list.map((e,t)=>(0,q.jsx)(`li`,{children:e},t))}):e.text})]},e.label))})]},`${e.kind}-${e.id}`),o=dh()?.OutlineFold;return(0,q.jsx)(`div`,{className:`outline`,ref:i,children:o?(0,q.jsx)(o,{sections:r,current:n,one:a}):r.map(a)})}function Ug({on:e,onClick:t}){return(0,q.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":`Outline`,"aria-pressed":e,onClick:t,children:(0,q.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,q.jsx)(`path`,{d:`M9 7h11M9 12h11M9 17h11`}),(0,q.jsx)(`circle`,{cx:`4.5`,cy:`7`,r:`1.2`}),(0,q.jsx)(`circle`,{cx:`4.5`,cy:`12`,r:`1.2`}),(0,q.jsx)(`circle`,{cx:`4.5`,cy:`17`,r:`1.2`})]})})}var Wg=we.map(e=>({id:e,title:H(e)??e}));function Gg({doc:e,onOpen:t}){let n=ft(e);return n.length===0?null:(0,q.jsxs)(`div`,{className:`keep`,role:`group`,"aria-label":`For a package`,children:[(0,q.jsx)(`h3`,{className:`files-title`,children:`For a package`}),(0,q.jsx)(`p`,{className:`field-hint`,children:`Not needed for a plan. To write the files a coding harness runs this graph from, grooph would still need:`}),(0,q.jsx)(`ul`,{className:`files`,children:n.map((t,n)=>(0,q.jsx)(`li`,{className:`field-hint`,children:jm(t,e,Wg)},`${t.code}-${n}`))}),t?(0,q.jsx)(`button`,{type:`button`,className:`chip chip-small`,onClick:t,children:`Open graph`}):null]})}function Kg({issues:e}){let t=Ym(),n=Wm(t.store),{errors:r,warnings:i}=Fm(e),a=(0,q.jsx)(Gg,{doc:n,onOpen:()=>t.openPanel({type:`graph`})});if(e.length===0)return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)(`p`,{className:`all-clear`,children:ft(n).length===0?`No issues. The graph validates for export.`:`No issues. The graph validates.`}),a]});let o=e=>e===n.id?`graph`:n.nodes.find(t=>t.id===e)?.name||n.loops.find(t=>t.id===e)?.name||e;return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsxs)(`p`,{className:`issue-summary`,children:[r,` error`,r===1?``:`s`,`, `,i,` warning`,i===1?``:`s`,`.`,` `,r>0?`A package waits until the errors are fixed; the plan can be kept as it is.`:`Warnings are carried into the lead brief.`]}),(0,q.jsx)(`ul`,{className:`issues`,children:e.map((e,r)=>{let i=Nm(n,e.at),a=e.at.length>0&&e.at.every(e=>t.highlight.nodes.has(e)||t.highlight.edges.has(e)||t.highlight.loops.has(e)||e===n.id&&t.highlight.graph);return(0,q.jsxs)(`li`,{children:[(0,q.jsxs)(`button`,{type:`button`,className:`issue issue-${e.severity}${a?` issue-active`:``}`,onClick:()=>{if(t.setHighlight(i),i.nodes.size>0)t.reveal([...i.nodes]);else if(i.edges.size>0){let e=n.edges.filter(e=>i.edges.has(e.id)).flatMap(e=>[e.from,e.to]);t.reveal(e)}},children:[(0,q.jsxs)(`span`,{className:`issue-head`,children:[(0,q.jsx)(`span`,{className:`issue-severity`,children:e.severity}),(0,q.jsx)(`span`,{className:`issue-code mono`,children:e.code})]}),(0,q.jsx)(`span`,{className:`issue-message`,children:e.message})]}),e.at.length>0?(0,q.jsx)(`div`,{className:`issue-at`,children:e.at.map(e=>(0,q.jsxs)(`button`,{type:`button`,className:`chip chip-small`,onClick:()=>{e===n.id?t.openPanel({type:`graph`}):n.nodes.some(t=>t.id===e)?t.openPanel({type:`node`,id:e}):n.edges.some(t=>t.id===e)?t.openPanel({type:`edge`,id:e}):n.loops.some(t=>t.id===e)&&t.openPanel({type:`loop`,id:e})},children:[`Open `,o(e)]},e))}):null]},`${e.code}-${r}`)})}),a]})}function qg(e){let{rail:t,onClose:n}=e;return(0,K.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||e.isComposing||t&&document.querySelector(`.sheet:not(.sheet-rail)`)||(e.preventDefault(),e.target instanceof HTMLElement&&e.target.closest(`[data-own-undo]`)?e.target.blur():n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,q.jsxs)(`aside`,{className:t?`sheet sheet-rail`:`sheet`,"aria-label":e.title,children:[(0,q.jsxs)(`div`,{className:`sheet-head`,children:[(0,q.jsxs)(`div`,{className:`sheet-title`,children:[(0,q.jsx)(`h2`,{children:e.title}),e.subtitle?(0,q.jsx)(`span`,{className:e.subtitle.includes(` `)?`sheet-sub`:`sheet-sub mono`,children:e.subtitle}):null]}),(0,q.jsx)(`button`,{type:`button`,className:`icon-btn sheet-toggle`,"aria-label":e.expanded?`Shrink panel`:`Expand panel`,"aria-expanded":e.expanded,onClick:e.onToggle,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:e.expanded?`M6 9l6 6 6-6`:`M6 15l6-6 6 6`})})}),(0,q.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":`Close panel`,onClick:n,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M6 6l12 12M18 6 6 18`})})})]}),(0,q.jsx)(`div`,{className:`sheet-body`,children:e.children})]})}function Jg(e,t){let n=[...e.map(e=>({source:`yours`,doc:e})),...t.map(e=>({source:`built-in`,doc:e}))],r=e=>e.doc.template?.kind===`fragment`?0:1;return n.sort((e,t)=>r(e)-r(t))}function Yg(){let e=Ym(),[t,n]=(0,K.useState)(null),r=jt(),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(null);(0,K.useEffect)(()=>{let e=!0;return kt().then(t=>e&&n(t)),()=>{e=!1}},[]);let c=Wm(e.store);return(0,K.useEffect)(()=>{o&&!o.nodes.every(e=>c.nodes.some(t=>t.id===e))&&s(null)},[c,o]),o?(0,q.jsx)(Zg,{inserted:o,onDone:()=>e.openPanel(null)}):i?(0,q.jsx)(Xg,{entry:i,onBack:()=>a(null),onInsert:(t,n)=>{let r=i.doc,a=e.store.updateWith(e=>de(e,r,{values:t,prefix:n})),o=r.nodes.map(e=>a.ids[e.id]).filter(Boolean),c=Mm();for(let e of o)c.nodes.add(e);e.setHighlight(c),e.setSelection(o),e.reveal(o),s({title:r.template.title,ids:a.ids,nodes:o,edges:r.edges.length,loops:r.loops.length})}}):t===null?(0,q.jsx)(`div`,{className:`inspector`}):r===void 0?(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(`p`,{className:`field-hint`,children:`Opening…`})}):(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)(`p`,{className:`field-hint`,children:`Its nodes join this graph unconnected; ids that are taken here get a number. Connect them where they belong.`}),r===null?(0,q.jsx)(`p`,{className:`field-hint`,children:`The built-in templates could not be fetched. They need a connection the first time; yours are below.`}):null,(0,q.jsx)(`ul`,{className:`insert-list`,"aria-label":`Templates to insert`,children:Jg(t,r??[]).map(e=>{let t=e.doc.template;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,className:`insert-row`,onClick:()=>a(e),children:[(0,q.jsxs)(`span`,{className:`template-title`,children:[t.title,(0,q.jsx)(`span`,{className:`badge badge-quiet`,children:t.kind===`fragment`?`fragment`:`graph · ${e.doc.nodes.length} nodes`}),e.source===`yours`?(0,q.jsx)(`span`,{className:`badge badge-quiet`,children:`yours`}):null]}),(0,q.jsx)(`span`,{className:`insert-summary`,children:t.summary})]})},`${e.source}/${e.doc.id}`)})})]})}function Xg({entry:e,onBack:t,onInsert:n}){let r=e.doc.template,i=Ue(e.doc),[a,o]=(0,K.useState)({}),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(null);return(0,q.jsxs)(`form`,{className:`inspector`,"data-own-undo":!0,onSubmit:e=>{e.preventDefault();try{n(Je(a),s.trim()===``?void 0:s.trim())}catch(e){if(!(e instanceof ye))throw e;u(e.message)}},children:[(0,q.jsxs)(`p`,{className:`insert-chosen`,children:[(0,q.jsx)(`strong`,{children:r.title}),` — `,r.summary]}),i.map(e=>(0,q.jsx)(tg,{label:e.ask,value:a[e.key]??``,rows:2,placeholder:e.example,hint:(0,q.jsx)(`span`,{className:`mono`,children:`{{${e.key}}}`}),onChange:t=>o(n=>({...n,[e.key]:t}))},e.key)),(0,q.jsx)($,{label:`Id prefix (optional)`,value:s,mono:!0,placeholder:`ship`,onChange:c,hint:`Prefix every id it brings in, as ship-gate.`}),l?(0,q.jsx)(`p`,{className:`refusal`,role:`alert`,children:l}):null,(0,q.jsxs)(`div`,{className:`export-actions`,children:[(0,q.jsxs)(`button`,{type:`submit`,className:`btn btn-primary`,children:[`Insert `,r.kind===`fragment`?`fragment`:`as a subgraph`]}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:t,children:`Choose another`})]})]})}function Zg({inserted:e,onDone:t}){let n=Object.entries(e.ids),r=n.filter(([e,t])=>e!==t).length;return(0,q.jsxs)(`div`,{className:`inspector`,role:`status`,children:[(0,q.jsxs)(`p`,{className:`all-clear`,children:[`Inserted `,e.title,`: `,e.nodes.length,` node`,e.nodes.length===1?``:`s`,`, `,e.edges,` edge`,e.edges===1?``:`s`,`,`,` `,e.loops,` loop`,e.loops===1?``:`s`,`. `,r===0?`Every id kept its name.`:`${r} id${r===1?``:`s`} changed to fit this graph.`]}),(0,q.jsx)(`h3`,{className:`files-title`,children:`Where each id landed`}),(0,q.jsx)(`ul`,{className:`id-map`,"aria-label":`Id map`,children:n.map(([e,t])=>(0,q.jsxs)(`li`,{className:e===t?void 0:`is-renamed`,children:[(0,q.jsx)(`span`,{className:`mono`,children:e}),` → `,(0,q.jsx)(`span`,{className:`mono`,children:t})]},e))}),(0,q.jsx)(`p`,{className:`field-hint`,children:`The new nodes are highlighted on the canvas. This list is not kept.`}),(0,q.jsx)(`div`,{className:`export-actions`,children:(0,q.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:t,children:`Done`})})]})}function Qg(e,t,n,r,i){try{let a=Te(e,{kind:t,...t===`fragment`?{nodeIds:n}:{},meta:{id:r.id,title:r.title.trim()||`Untitled`,summary:r.summary.trim(),whenToUse:r.whenToUse.trim(),...r.notFor.trim()===``?{}:{notFor:r.notFor.trim()},...i?{profile:i}:{}}});return{template:a,refusal:Ge(a,e)}}catch(e){if(e instanceof ye)return{problem:e.message};throw e}}function $g(){let e=Ym(),t=Wm(e.store),[n,r]=(0,K.useState)(e.selection.length>0?`fragment`:`graph`),[i,a]=(0,K.useState)(()=>e.selection.filter(e=>t.nodes.some(t=>t.id===e))),[o,s]=(0,K.useState)(()=>({id:Be(t.name,`template`),title:t.name,summary:``,whenToUse:``,notFor:``})),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),f=(0,K.useMemo)(()=>{let e=Qg(t,n,i,{...o,id:o.id||`template`});return`template`in e?e.template.template.profile:null},[t,n,i,o]),p=c??f??{cost:`medium`,speed:`medium`,rigor:`standard`},m=[`title`,`summary`,`whenToUse`].filter(e=>o[e].trim()===``),h=Qg(t,n,i,o,p),g=m.length===0&&`template`in h&&h.refusal===null,_=e=>t=>{s(n=>({...n,[e]:e===`id`?t.toLowerCase().replace(/[^a-z0-9-]/g,`-`):t})),u&&`exists`in u&&d(null)},v=async e=>{if(!(`template`in h)||h.refusal!==null)return;let t=await Ft(h.template,{replace:e});d(`exists`in t?t:{saved:t.saved.doc,replaced:t.replaced})};if(u&&`saved`in u){let t=u.saved;return(0,q.jsxs)(`div`,{className:`inspector`,role:`status`,children:[(0,q.jsxs)(`p`,{className:`all-clear`,children:[u.replaced?`Replaced`:`Saved`,` `,(0,q.jsx)(`strong`,{children:t.template.title}),` in Yours as `,(0,q.jsx)(`span`,{className:`mono`,children:t.id}),`, version `,t.version,`.`]}),(0,q.jsxs)(`div`,{className:`export-actions`,children:[(0,q.jsx)(`a`,{className:`btn btn-primary`,href:St(`yours`,t.id),children:`Open in Templates`}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>xt(Tt(t),Et(t),`application/json`),children:`Download template (.grooph.json)`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:()=>e.openPanel({type:`graph`}),children:`Back to the graph`})]})]})}return(0,q.jsxs)(`form`,{className:`inspector`,"data-own-undo":!0,onSubmit:e=>{e.preventDefault(),g&&v(!1)},children:[(0,q.jsx)(og,{label:`Save`,value:n,options:[{value:`graph`,label:`Whole graph`},{value:`fragment`,label:`Selected nodes`}],onChange:r,hint:n===`graph`?`Keeps the goal, target and layout; drops run notes.`:`A fragment: these nodes, the edges and loops wholly among them. Graph-level fields stay behind.`}),n===`fragment`?(0,q.jsxs)(`div`,{className:`field`,children:[(0,q.jsxs)(`div`,{className:`field-label`,id:`fragment-nodes`,children:[`Nodes (`,i.length,` selected)`]}),(0,q.jsx)(`div`,{className:`chips`,role:`group`,"aria-labelledby":`fragment-nodes`,children:t.nodes.map(e=>{let n=i.includes(e.id);return(0,q.jsx)(`button`,{type:`button`,"aria-pressed":n,className:n?`chip chip-on`:`chip`,onClick:()=>a(r=>n?r.filter(t=>t!==e.id):t.nodes.map(e=>e.id).filter(t=>t===e.id||r.includes(t))),children:e.name||e.id},e.id)})})]}):null,`template`in h&&h.refusal?(0,q.jsxs)(`div`,{className:`refusal`,role:`alert`,children:[(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`strong`,{children:`Not saved: the template would carry these errors.`}),` Yours keeps only templates that validate, as `,(0,q.jsx)(`span`,{className:`mono`,children:`grooph template save`}),` does.`]}),h.refusal.hints.map(e=>(0,q.jsx)(`p`,{className:`refusal-hint`,children:e},e)),(0,q.jsx)(`pre`,{className:`issue-lines`,children:h.refusal.issues.map(oe).join(`
|
|
13
|
-
`)})]}):null,(0,q.jsx)($,{label:`Template id`,value:o.id,mono:!0,onChange:_(`id`),hint:`Its name in Templates and in a registry, kebab-case.`}),(0,q.jsx)($,{label:`Title`,value:o.title,onChange:_(`title`)}),(0,q.jsx)(tg,{label:`Summary`,value:o.summary,rows:2,placeholder:`One sentence: what it does.`,onChange:_(`summary`)}),(0,q.jsx)(tg,{label:`When to use`,value:o.whenToUse,rows:2,placeholder:`The situation it fits.`,onChange:_(`whenToUse`)}),(0,q.jsx)(tg,{label:`Not for (optional)`,value:o.notFor,rows:2,placeholder:`Where people wrongly reach for it.`,onChange:_(`notFor`)}),(0,q.jsxs)(`div`,{className:`field`,children:[(0,q.jsx)(`div`,{className:`field-label`,children:`Profile`}),(0,q.jsx)(`div`,{className:`field-hint`,children:c?`Corrected by you.`:`Estimated from the graph. Correct it if it reads wrong.`})]}),[`cost`,`speed`,`rigor`].map(e=>(0,q.jsx)(og,{label:e[0].toUpperCase()+e.slice(1),value:p[e],options:qe[e].map(e=>({value:e,label:e})),onChange:t=>l({...p,[e]:t})},e)),c?(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:()=>l(null),children:`Use the estimate again`}):null,`problem`in h?(0,q.jsx)(`p`,{className:`refusal`,role:`alert`,children:h.problem}):null,u&&`exists`in u?(0,q.jsxs)(`div`,{className:`rename-warning`,role:`alert`,children:[(0,q.jsxs)(`p`,{children:[`Yours already has `,(0,q.jsx)(`span`,{className:`mono`,children:o.id}),` (`,u.exists.template?.title,`, version `,u.exists.version,`). Replace it, or choose another id.`]}),(0,q.jsxs)(`button`,{type:`button`,className:`btn btn-danger`,onClick:()=>void v(!0),children:[`Replace it (version `,u.exists.version+1,`)`]})]}):null,(0,q.jsxs)(`div`,{className:`export-actions`,children:[(0,q.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,disabled:!g,children:`Save to Yours`}),m.length>0?(0,q.jsxs)(`p`,{className:`field-hint`,children:[`Needs `,m.map(e=>e===`whenToUse`?`when to use`:e).join(`, `),`.`]}):null]})]})}function e_({graphKey:e,fresh:t}){let[n,r]=(0,K.useState)(void 0);return(0,K.useEffect)(()=>{let t=!0;return dt().then(t=>t.get(e)).then(e=>t&&r(e??null)),()=>{t=!1}},[e]),(0,K.useEffect)(()=>{let e=window.setTimeout(()=>{Ct().catch(()=>void 0),yg().catch(()=>void 0)},1200);return()=>window.clearTimeout(e)},[]),n===void 0?(0,q.jsx)(`div`,{className:`loading`,children:`Opening…`}):n===null?(0,q.jsxs)(`div`,{className:`notfound`,children:[(0,q.jsx)(`p`,{children:`This graph is not on this device.`}),(0,q.jsx)(`a`,{className:`btn btn-primary`,href:`#/`,children:`Back to graphs`})]}):(0,q.jsx)(kp,{children:(0,q.jsx)(n_,{record:n,fresh:t})})}function t_(e,t){let[n,r]=(0,K.useState)(`saved`),i=(0,K.useRef)(void 0),a=(0,K.useCallback)(async()=>{window.clearTimeout(i.current),i.current=void 0;let n=await dt();t.current={...t.current,doc:e.get(),updatedAt:Date.now()},await n.put(t.current),r(n.persistent?`saved`:`memory`)},[e,t]);return(0,K.useEffect)(()=>{dt().then(e=>!e.persistent&&r(`memory`));let t=e.subscribe(()=>{r(e=>e===`memory`?e:`saving`),window.clearTimeout(i.current),i.current=window.setTimeout(()=>void a(),250)}),n=()=>{i.current!==void 0&&a()};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`pagehide`,n),()=>{t(),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`pagehide`,n),i.current!==void 0&&a()}},[e,a]),{state:n,flush:a}}function n_({record:e,fresh:t}){let n=(0,K.useMemo)(()=>new Um(e.doc),[e]),r=Wm(n),i=Gm(n),a=(0,K.useRef)(e),{state:o,flush:s}=t_(n,a),[c,l]=(0,K.useState)(e.exported?.id),u=Ed(),d=(0,K.useRef)(null),f=(0,K.useRef)(null),[p,m]=(0,K.useState)([]),h=(0,K.useRef)(!1),[g,_]=(0,K.useState)(null),v=(0,K.useCallback)(()=>_(null),[]),[y,b]=(0,K.useState)(t?{type:`graph`}:null),[x,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)({type:`idle`}),[E,D]=(0,K.useState)(Mm),[O,A]=(0,K.useState)(!1),[j,M]=(0,K.useState)(null),N=w.type!==`idle`;(0,K.useEffect)(()=>{N&&requestAnimationFrame(()=>requestAnimationFrame(()=>void u.fitView({...Sh,duration:Ch()})))},[N,u]);let P=(0,K.useMemo)(()=>et(r),[r]),{errors:F,warnings:I}=Fm(P),L=(0,K.useCallback)(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>{u.fitView({...Sh,maxZoom:1,nodes:e.map(e=>({id:e})),duration:Ch()})}))},[u]),R=(0,K.useCallback)(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>{let t=d.current?.getBoundingClientRect(),n=d.current?.querySelector(`.react-flow__node[data-id="${CSS.escape(e)}"]`);if(!t||!n)return;let r=n.getBoundingClientRect(),i=f.current?.getBoundingClientRect(),a=i&&i.height>0&&i.top<t.bottom&&i.bottom>t.top?Math.min(i.top,t.bottom)-8:t.bottom-8;if(r.top>=t.top+56&&r.bottom<=a&&r.left>=t.left&&r.right<=t.right)return;let o=u.getInternalNode(e);if(!o)return;let{x:s,y:c}=o.internals.positionAbsolute,l=o.measured.width??Im,p=o.measured.height??Lm;u.setCenter(s+l/2,c+p/2,{zoom:u.getZoom(),duration:Ch()})}))},[u]),z=(0,K.useCallback)(e=>{b(e),e?.type===`outline`?A(!0):(e===null||![`node`,`edge`,`loop`].includes(e.type))&&A(!1),T(t=>t.type===`pick`&&(e?.type!==`loop`||e.id!==t.loopId)?{type:`idle`}:t)},[]),B=(0,K.useCallback)(e=>{if(w.type===`pick`){n.update(t=>fe(t,w.loopId,e));return}T({type:`idle`}),z({type:`edge`,id:e})},[w,n,z]),V=(0,K.useCallback)(e=>{if(w.type===`pick`){n.update(t=>S(t,w.loopId,e));return}if(w.type===`connect`){if(w.from===void 0)T({type:`connect`,from:e});else if(w.from===e)T({type:`connect`});else{let t=w.from,{id:r}=n.updateWith(n=>ie(n,t,e));T({type:`idle`}),z({type:`edge`,id:r}),L([t,e])}return}z({type:`node`,id:e}),m([e]),R(e)},[w,n,z,R,L]),H=(0,K.useCallback)(()=>{let e=n.get();if(!e.layout)return;let{positions:t}=Bm(e),r,i=y?.type===`node`?t[y.id]:void 0;if(i)r={x:i.x,y:i.y+Lm+64};else{let e=d.current?.getBoundingClientRect(),t=e?u.screenToFlowPosition({x:e.left+e.width/2,y:e.top+e.height/2}):{x:0,y:0};r={x:t.x-Im/2,y:t.y-Lm/2}}let a=Object.values(t);for(;a.some(e=>Math.abs(e.x-r.x)<Im*.6&&Math.abs(e.y-r.y)<Lm*.8);)r={x:r.x,y:r.y+Lm+24};return r},[n,y,u]),U=e=>{let{id:t}=n.updateWith(t=>ge(t,e,{at:H()}));T({type:`idle`}),z({type:`node`,id:t}),M(t),L([t])},ee=()=>{let e=y?.type===`node`?[y.id]:[],{id:t}=n.updateWith(t=>ne(t,e));b({type:`loop`,id:t}),T({type:`pick`,loopId:t})},W=(0,K.useCallback)(()=>{n.undo(),_(null)},[n]),te=(0,K.useCallback)(()=>{n.redo(),_(null)},[n]);(0,K.useEffect)(()=>{let e=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey||e.target instanceof Element&&e.target.closest(`[data-own-undo]`))return;let t=e.key.toLowerCase();t===`z`?(e.preventDefault(),e.shiftKey?te():W()):t===`y`&&e.ctrlKey&&!e.metaKey&&(e.preventDefault(),te())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[W,te]),(0,K.useEffect)(()=>{y&&(y.type===`node`||y.type===`edge`||y.type===`loop`)&&((y.type===`node`?r.nodes:y.type===`edge`?r.edges:r.loops).some(e=>e.id===y.id)||z(null)),w.type===`pick`&&!r.loops.some(e=>e.id===w.loopId)&&T({type:`idle`}),w.type===`connect`&&w.from!==void 0&&!r.nodes.some(e=>e.id===w.from)&&T({type:`connect`})},[r,y,w,z]),(0,K.useEffect)(()=>{g&&r!==g.after&&_(null)},[r,g]);let re={store:n,panel:y,openPanel:z,mode:w,setMode:T,highlight:E,setHighlight:D,reveal:L,onEdgeTap:B,selection:p,setSelection:m,deleted:(0,K.useCallback)(e=>{let t=n.get();_({id:Date.now(),text:`Deleted ${e}`,after:t,undo:()=>n.get()===t&&n.undo()})},[n]),viewMoved:h,exportedAs:c,markExported:(0,K.useCallback)(()=>{let e=n.get().id;a.current={...a.current,exported:{id:e,at:Date.now()}},l(e),s()},[n,s])},ae=c!==void 0&&r.id!==c&&k(r.id,r.name),oe=(e,t)=>z(t===`Loop`?{type:`loop`,id:e}:{type:`node`,id:e}),se=x||y?.type===`outline`,ce=()=>{se?(C(!1),y?.type===`outline`&&z(null)):vh()?C(!0):z({type:`outline`})},G=i_(y,r,P,t,j,ae?(0,q.jsx)(At,{exportedAs:c,nextId:r.id,onKeep:()=>n.update(e=>ot(e,c))}):null),le=F>0?`status-error`:I>0?`status-warning`:`status-ok`,ue=F>0?`${F} error${F===1?``:`s`}`:I>0?`${I} warning${I===1?``:`s`}`:`Valid`;return(0,q.jsx)(Jm.Provider,{value:re,children:(0,q.jsxs)(`div`,{className:`editor${y||x?` has-sheet`:``}${O&&!N?` sheet-expanded`:``}${N?` mode-active`:``}${se?` has-rail`:``}${G?` has-side`:``}`,children:[(0,q.jsxs)(`header`,{className:`topbar`,children:[(0,q.jsx)(`a`,{className:`icon-btn`,href:`#/`,"aria-label":`All graphs`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M15 5 8 12l7 7`})})}),(0,q.jsxs)(`button`,{type:`button`,className:`title-btn${E.graph?` is-highlighted`:``}`,onClick:()=>z(y?.type===`graph`?null:{type:`graph`}),children:[(0,q.jsx)(`span`,{className:`title-name`,children:r.name||`Untitled`}),(0,q.jsxs)(`span`,{className:`title-sub`,children:[r_(r),` · `,o===`memory`?`not saved on this device`:o===`saving`?`saving…`:`saved`]})]}),(0,q.jsx)(Ug,{on:se,onClick:ce}),(0,q.jsx)(`button`,{type:`button`,className:`status ${le}`,"aria-label":`Validation: ${ue}`,onClick:()=>z(y?.type===`issues`?null:{type:`issues`}),children:ue}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-primary topbar-export`,onClick:()=>z(y?.type===`export`?null:{type:`export`}),children:`Export`})]}),(0,q.jsx)(Nt,{className:`editor-notice`}),se?(0,q.jsx)(qg,{rail:!0,title:`Outline`,subtitle:`the whole graph, to read`,expanded:O,onToggle:()=>A(e=>!e),onClose:()=>{y?.type===`outline`&&T({type:`idle`}),ce()},children:(0,q.jsx)(Hg,{doc:r,onOpen:oe,current:y&&`id`in y?y.id:void 0})}):null,(0,q.jsxs)(`main`,{className:`stage`,ref:d,children:[(0,q.jsx)(Bh,{issues:P,onNodeTap:V}),(0,q.jsx)(Wh,{}),r.loops.length>0?(0,q.jsx)(`nav`,{className:`loop-legend`,"aria-label":`Loops`,children:r.loops.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:`loop-pill loop-c${t%4}${y?.type===`loop`&&y.id===e.id?` is-on`:``}`,onClick:()=>z({type:`loop`,id:e.id}),children:[(0,q.jsx)(`span`,{className:`loop-dot loop-c${t%4}`,"aria-hidden":`true`}),e.name||e.id]},e.id))}):null,w.type===`idle`?null:(0,q.jsx)(s_,{mode:w,doc:r,onDone:()=>T({type:`idle`})}),(0,q.jsx)(Ot,{toast:g,onDone:v}),r.nodes.length===0?(0,q.jsxs)(`div`,{className:`empty-canvas`,children:[(0,q.jsx)(`p`,{children:`An empty graph.`}),(0,q.jsx)(`p`,{className:`muted`,children:`Add a node to start: an agent, a human gate, a check, or a stop.`})]}):null,(0,q.jsxs)(`div`,{className:`toolbar`,role:`toolbar`,"aria-label":`Canvas`,ref:f,children:[(0,q.jsxs)(`button`,{type:`button`,className:`tool`,onClick:()=>z(y?.type===`add`?null:{type:`add`}),"aria-pressed":y?.type===`add`,children:[(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M12 5v14M5 12h14`})}),`Add`]}),(0,q.jsxs)(`button`,{type:`button`,className:`tool`,"aria-pressed":w.type===`connect`,disabled:r.nodes.length<2,onClick:()=>T(w.type===`connect`?{type:`idle`}:{type:`connect`,from:y?.type===`node`?y.id:void 0}),children:[(0,q.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,q.jsx)(`circle`,{cx:`6`,cy:`7`,r:`2.5`}),(0,q.jsx)(`circle`,{cx:`18`,cy:`17`,r:`2.5`}),(0,q.jsx)(`path`,{d:`M8 8.5 16 15.5`})]}),`Connect`]}),(0,q.jsxs)(`button`,{type:`button`,className:`tool`,disabled:r.nodes.length===0,"aria-pressed":w.type===`pick`,onClick:ee,children:[(0,q.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,q.jsx)(`path`,{d:`M7 8a6 6 0 1 1-1 7`}),(0,q.jsx)(`path`,{d:`M3 13.5 6 15l2-3`})]}),`Loop`]}),(0,q.jsxs)(`button`,{type:`button`,className:`tool`,disabled:r.nodes.length===0,onClick:()=>{h.current=!1,u.fitView({...Sh,duration:Ch()})},children:[(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5`})}),`Fit`]}),(0,q.jsxs)(`button`,{type:`button`,className:`tool`,disabled:!i.canUndo,onClick:W,"aria-keyshortcuts":`Control+Z Meta+Z`,children:[(0,q.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,q.jsx)(`path`,{d:`M9 14 4 9l5-5`}),(0,q.jsx)(`path`,{d:`M4 9h10a6 6 0 0 1 0 12h-3`})]}),`Undo`]}),(0,q.jsxs)(`button`,{type:`button`,className:`tool`,disabled:!i.canRedo,onClick:te,"aria-keyshortcuts":`Control+Shift+Z Meta+Shift+Z`,children:[(0,q.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,q.jsx)(`path`,{d:`m15 14 5-5-5-5`}),(0,q.jsx)(`path`,{d:`M20 9H10a6 6 0 0 0 0 12h3`})]}),`Redo`]})]})]}),G?(0,q.jsx)(qg,{title:G.title,subtitle:G.subtitle,expanded:O,onToggle:()=>A(e=>!e),onClose:()=>{z(null),T({type:`idle`})},children:y?.type===`add`?(0,q.jsx)(o_,{onAdd:U,onInsert:()=>z({type:`insert`})}):G.body}):null]})})}var r_=e=>((e.nodes??[]).some(L)?void 0:e.target?.harness)??`a plan`;function i_(e,t,n,r,i,a){if(!e||e.type===`outline`)return null;switch(e.type){case`node`:{let n=t.nodes.find(t=>t.id===e.id);return{title:n?ym(n):`Node`,subtitle:n?.id,body:(0,q.jsx)(Mg,{id:e.id,focusName:i===e.id},`node`)}}case`edge`:return{title:`Edge`,subtitle:t.edges.find(t=>t.id===e.id)?.id,body:(0,q.jsx)(Sg,{id:e.id},`edge`)};case`loop`:return{title:`Loop`,subtitle:e.id,body:(0,q.jsx)(Eg,{id:e.id},`loop`)};case`graph`:return{title:`Graph`,subtitle:t.id,body:(0,q.jsx)(Tg,{autoFocusName:r&&t.nodes.length===0,renameWarning:a})};case`issues`:return{title:`Validation`,subtitle:`the graph's own findings`,body:(0,q.jsx)(Kg,{issues:n})};case`export`:return{title:`Export`,subtitle:r_(t),body:(0,q.jsx)(bg,{})};case`add`:return{title:`Add a node`,subtitle:void 0,body:null};case`insert`:return{title:`Insert a template`,subtitle:`into this graph`,body:(0,q.jsx)(Yg,{},`insert`)};case`save-template`:return{title:`Save as template`,subtitle:`to Yours, on this device`,body:(0,q.jsx)($g,{},`save-template`)}}}var a_={agent:`A worker with a role, a brief and outputs.`,"human-gate":`The run stops and asks a person.`,check:`A command, tests or a metric that passes or fails.`,stop:`Where the run ends.`};function o_({onAdd:e,onInsert:t}){return(0,q.jsxs)(`div`,{className:`add-menu`,children:[km.map(t=>(0,q.jsxs)(`button`,{type:`button`,className:`add-kind add-${t}`,onClick:()=>e(t),children:[(0,q.jsxs)(`span`,{className:`add-kind-name`,children:[(0,q.jsx)(`span`,{className:`kind-mark kind-${t}`,"aria-hidden":`true`}),Ee[t]]}),(0,q.jsx)(`span`,{className:`add-kind-hint`,children:a_[t]})]},t)),(0,q.jsxs)(`button`,{type:`button`,className:`add-kind add-template`,onClick:t,children:[(0,q.jsxs)(`span`,{className:`add-kind-name`,children:[(0,q.jsx)(`span`,{className:`kind-mark kind-template`,"aria-hidden":`true`}),`Insert a template`]}),(0,q.jsx)(`span`,{className:`add-kind-hint`,children:`A fragment or a whole pattern, from Templates.`})]})]})}function s_({mode:e,doc:t,onDone:n}){let r=e=>t.nodes.find(t=>t.id===e)?.name??e,i;if(e.type===`connect`)i=e.from?`From ${r(e.from)}: tap the node the edge goes to.`:`Tap the node the edge starts from.`;else if(e.type===`pick`)i=`Picking ${t.loops.find(t=>t.id===e.loopId)?.name??`loop`}: tap nodes to add members, tap an edge label to mark a back edge.`;else return null;return(0,q.jsxs)(`div`,{className:`mode-banner`,role:`status`,children:[(0,q.jsx)(`span`,{children:i}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:n,children:e.type===`pick`?`Done`:`Cancel`})]})}var c_={graph:Lh},l_={graph:jh},u_=mh(d_,e=>e.doc);function d_(e){let t=e.run?_h:gh,[n,r]=(0,K.useState)({}),i=(0,K.useRef)(!1),a=(0,K.useMemo)(()=>Bm(e.doc).positions,[e.doc]),o=(0,K.useMemo)(()=>Pm(e.issues??[]),[e.issues]),s=e.useBoxes(e.doc,a,n,o,e.highlight?.nodes,e.selected,!!e.run),c=s?.doc??e.doc,l=s?.positions??a,u=(0,K.useMemo)(()=>c.nodes.map(t=>{let r=c.loops.map((e,t)=>({id:e.id,name:e.name,color:t,members:e.members})).filter(e=>e.members.includes(t.id)),i={id:t.id,position:l[t.id]??{x:0,y:0},ariaLabel:Nh(t),...n[t.id]?{measured:n[t.id]}:{}},a=e.run?.nodes[t.id],s=e.highlight?.loop===void 0?-1:c.loops.findIndex(t=>t.id===e.highlight.loop);return{...i,type:`graph`,data:{node:t,severity:o.get(t.id),loops:r.map(({members:e,...t})=>t),selected:t.id===e.selected,highlighted:s<0&&(e.highlight?.nodes.includes(t.id)??!1),connectFrom:!1,...s>=0&&c.loops[s].members.includes(t.id)?{loopColor:s}:{},...a?{run:{state:a.state,label:nt(a.state,a.lastOutcome),runs:a.runs}}:{}}}}),[c,l,n,o,e.selected,e.run,e.highlight]),d=(0,K.useMemo)(()=>{let t=new Set(c.nodes.map(e=>e.id)),r={};for(let e of c.nodes){let t=l[e.id]??{x:0,y:0};r[e.id]={x:t.x,y:t.y,w:n[e.id]?.width??Im,h:n[e.id]?.height??Lm}}let i=$m(c,r),a=lh(c,r,i);return c.edges.filter(e=>t.has(e.from)&&t.has(e.to)).map(t=>{let n=c.loops.findIndex(e=>e.back.includes(t.id));return{id:t.id,source:t.from,target:t.to,type:`graph`,data:{edge:t,back:n>=0,loopColor:n>=0?n:void 0,bend:i.get(t.id)??0,labelAt:a.get(t.id),severity:o.get(t.id),selected:!1,highlighted:e.highlight?.edges.includes(t.id)??!1}}})},[c,l,n,o,e.highlight]);return(0,q.jsxs)(Np,{nodes:s?.with(u)??u,edges:d,nodeTypes:c_,edgeTypes:l_,onNodesChange:e=>{let t={};for(let n of e)n.type===`dimensions`&&n.dimensions&&(t[n.id]=n.dimensions);Object.keys(t).length>0&&r(e=>({...e,...t}))},onNodeClick:(t,n)=>e.onNodeTap?.(n.id),onKeyDown:Ph(e.onNodeTap),edgesFocusable:!1,onMove:e=>{e&&(i.current=!0)},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,deleteKeyCode:null,selectionKeyCode:null,multiSelectionKeyCode:null,panOnScroll:!1,nodeClickDistance:6,minZoom:.2,maxZoom:2,fitView:!0,fitViewOptions:xh(t),attributionPosition:`top-right`,children:[(0,q.jsx)(Gp,{variant:Vp.Dots,gap:24,size:1.2}),(0,q.jsx)(Dh,{pad:t,control:!0,refit:i}),e.highlight?(0,q.jsx)(f_,{ids:e.highlight.nodes}):null]})}function f_({ids:e}){let t=Ed(),n=e.join(` `);return(0,K.useEffect)(()=>{if(n===``)return;let e=t.getZoom();t.fitView({nodes:n.split(` `).map(e=>({id:e})),padding:.5,maxZoom:e,duration:Ch()})},[n,t]),null}function p_(){let[e,t]=(0,K.useState)({}),[n,r]=(0,K.useState)(null);return{saved:e,busy:n,save:(0,K.useCallback)(async(e,n)=>{r(e);try{let{record:r,existed:i}=await lt(n),a={key:r.key,existed:i,persistent:(await dt()).persistent};return t(t=>({...t,[e]:a})),a}finally{r(null)}},[])}}var m_=e=>`#/g/${encodeURIComponent(e)}`,h_=e=>typeof e==`string`?e:JSON.stringify(e,null,2);function g_({field:e}){let t=rt(e.before,e.after);return t&&!t.reordered?(0,q.jsxs)(`div`,{className:`field-change`,children:[(0,q.jsx)(`span`,{className:`field-key mono`,children:e.key}),(0,q.jsxs)(`ul`,{className:`field-diff`,children:[t.removed.map((e,t)=>(0,q.jsxs)(`li`,{className:`del`,children:[(0,q.jsx)(`span`,{className:`sign`,"aria-label":`removed`,children:`−`}),(0,q.jsx)(`del`,{children:e})]},`d${t}`)),t.added.map((e,t)=>(0,q.jsxs)(`li`,{className:`ins`,children:[(0,q.jsx)(`span`,{className:`sign`,"aria-label":`added`,children:`+`}),(0,q.jsx)(`ins`,{children:e})]},`a${t}`))]}),t.kept>0?(0,q.jsxs)(`p`,{className:`field-kept`,children:[t.kept,` unchanged`]}):null]}):(0,q.jsxs)(`div`,{className:`field-change`,children:[(0,q.jsx)(`span`,{className:`field-key mono`,children:e.key}),t?.reordered?(0,q.jsx)(`p`,{className:`field-kept`,children:`the same items in another order`}):null,e.before===void 0?null:(0,q.jsxs)(`div`,{className:`field-diff del`,children:[(0,q.jsx)(`span`,{className:`sign`,"aria-label":`before`,children:`−`}),(0,q.jsx)(`del`,{className:`prose`,children:h_(e.before)})]}),e.after===void 0?null:(0,q.jsxs)(`div`,{className:`field-diff ins`,children:[(0,q.jsx)(`span`,{className:`sign`,"aria-label":`after`,children:`+`}),(0,q.jsx)(`ins`,{className:`prose`,children:h_(e.after)})]})]})}function __({model:e,onNote:t}){let{bundle:n,diff:i,why:o,adoption:s,moved:c}=e,{source:l,working:u}=n,[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(null),_=new Map(e.summary.amendments.map(e=>[e.id,e])),v=l.version+1,y=async()=>{if(s.ok){m(!0);try{let e=await r(`brakes`,()=>a(()=>import(`./brakes-9E9PsV_Z.js`),__vite__mapDeps([10,1,2]))).then(e=>e.judge(l,s.doc,n.run),()=>void 0);if(g(e?e.view:(0,q.jsx)(`p`,{className:`refusal`,role:`alert`,children:`Could not check this working copy's brakes, so nothing was saved. Press Adopt to try again.`})),!e?.ok)return;let t=await mt(s.doc);f({kind:`adopted`,key:t.key,version:s.doc.version})}finally{m(!1)}}};return(0,q.jsxs)(`div`,{className:`run-changes`,children:[(0,q.jsxs)(`p`,{className:`run-intro`,children:[`The run's working copy against the source it started from, `,l.name||l.id,` version `,l.version,`. Layout and notes aside.`]}),c?(0,q.jsx)(`div`,{className:`warnings`,role:`note`,children:(0,q.jsxs)(`p`,{children:[`This run worked on version `,u.version,`, but the source it came with is version `,l.version,`: the source changed after the run started, so these are the differences from the source as it is now, not only what the run did.`]})}):null,i.changes.length===0?(0,q.jsx)(`p`,{className:`all-clear`,children:`No changes: the run followed the graph as it was.`}):(0,q.jsx)(`ol`,{className:`change-list`,children:i.changes.map((e,n)=>{let r=o[n];return(0,q.jsxs)(`li`,{className:`change`,"data-change-at":e.at,children:[(0,q.jsx)(`p`,{className:`change-line`,children:e.line}),e.fields.map(e=>(0,q.jsx)(g_,{field:e},e.key)),r.length>0?(0,q.jsxs)(`p`,{className:`change-why`,children:[(0,q.jsx)(`span`,{className:`change-why-label`,children:`Why:`}),` `,r.map(e=>(0,q.jsxs)(`span`,{className:`change-why-note`,children:[(0,q.jsx)(`button`,{type:`button`,className:`link mono`,onClick:()=>t(e),children:e}),` `,_.get(e)?.amendment?.reason]},e))]}):(0,q.jsx)(`p`,{className:`change-why is-unexplained`,children:`No amendment note explains this change. A run should record every change it makes; ask the lead why.`})]},n)})}),i.changes.length>0&&!i.exact?(0,q.jsx)(`p`,{className:`field-hint`,children:`Not every change here is a grooph op; adopting takes the working copy itself, whatever the list can express.`}):null,(0,q.jsx)(`div`,{className:`adopt`,"aria-label":`Adopt or discard`,children:d?.kind===`adopted`?(0,q.jsxs)(`p`,{className:`adopt-done`,role:`status`,children:[`Saved version `,d.version,` of `,l.name||l.id,` to this device as a new graph. The source stays as it was.`,` `,(0,q.jsxs)(`a`,{href:m_(d.key),children:[`Open version `,d.version]}),h]}):d?.kind===`discarded`?(0,q.jsxs)(`p`,{className:`adopt-done`,role:`status`,children:[`Discarded. Nothing on this device changed, and the source stays at version `,l.version,`.`,` `,(0,q.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>f(null),children:`Undo`})]}):s.ok?c?(0,q.jsx)(`div`,{className:`refusal`,children:(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`strong`,{children:`Not adoptable here.`}),` Adopting a run of version `,u.version,` over version `,l.version,` would undo what changed in between. Compare them by hand, or adopt a run of version `,l.version,`.`]})}):i.changes.length===0?(0,q.jsx)(`p`,{className:`field-hint`,children:`Nothing to adopt: the working copy is the source.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`field-hint`,children:[`Adopt saves the working copy as version `,v,` of `,l.name||l.id,`, a new graph on this device; the source stays as it is. Discard leaves everything as it was.`]}),h,(0,q.jsxs)(`div`,{className:`actions-row`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:p,onClick:()=>void y(),children:p?`Checking its brakes…`:`Adopt as version ${v}`}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>f({kind:`discarded`}),children:`Discard`})]})]}):(0,q.jsxs)(`div`,{className:`refusal`,children:[(0,q.jsxs)(`p`,{children:[(0,q.jsx)(`strong`,{children:`This working copy cannot be adopted.`}),` `,s.message]}),(0,q.jsx)(`pre`,{className:`issue-lines`,children:s.issues.map(oe).join(`
|
|
14
|
-
`)}),(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>f({kind:`discarded`}),children:`Discard`})]})})]})}function v_(e){let t=[`id`,`key`,`loop`,`from`,`kind`].map(t=>e[t]).find(e=>typeof e==`string`),n=e.set&&typeof e.set==`object`?Object.keys(e.set):[];return`${e.op}${t?` ${String(t)}`:``}${n.length>0?`: ${n.join(`, `)}`:``}`}function y_({bundle:e,proposals:t,onNote:n}){let[i,o]=(0,K.useState)({}),[s,c]=(0,K.useState)(!1),l=async(t,n)=>{let i=yt(e,t);if(!i.ok){o(e=>({...e,[n]:{ok:!1,message:i.message}}));return}c(!0);try{let t=await mt(i.doc),s=await r(`brakes`,()=>a(()=>import(`./brakes-9E9PsV_Z.js`),__vite__mapDeps([10,1,2]))).then(t=>t.loosened(e.source,i.doc,i.graph)).catch(()=>(0,q.jsx)(`p`,{className:`field-hint`,children:`Its brakes could not be compared with the graph's: the piece that compares them did not load. Open the copy and read its limits before you use it.`}));o(e=>({...e,[n]:{ok:!0,key:t.key,brakes:s,version:i.doc.version,errors:i.issues.filter(e=>e.severity===`error`).length,warnings:i.issues.filter(e=>e.severity===`warning`).length}}))}catch{o(e=>({...e,[n]:{ok:!1,again:!0,message:`The copy could not be saved on this device. Press Apply to a copy to try again.`}}))}finally{c(!1)}};return t.length===0?(0,q.jsx)(`p`,{className:`run-intro`,children:`The run proposed nothing.`}):(0,q.jsxs)(`div`,{className:`run-proposals`,children:[(0,q.jsx)(`p`,{className:`run-intro`,children:`Changes the run proposed and did not make. Nothing is applied without you.`}),(0,q.jsx)(`ol`,{className:`proposal-list`,children:t.map((t,r)=>{let a=pe(t.proposal.patch),o=i[r];return(0,q.jsxs)(`li`,{className:`proposal`,"data-proposal":t.id,children:[(0,q.jsx)(`p`,{className:`proposal-summary`,children:t.proposal.summary}),(0,q.jsxs)(`p`,{className:`proposal-meta`,children:[(0,q.jsx)(`button`,{type:`button`,className:`link mono`,onClick:()=>n(t.id),children:t.id}),` `,`· `,Qe(_t(t),e.working)]}),t.text?(0,q.jsx)(`p`,{className:`prose proposal-text`,children:t.text}):null,a.kind===`ops`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`ul`,{className:`op-list`,"aria-label":`Patch`,children:a.ops.map((e,t)=>(0,q.jsx)(`li`,{className:`mono`,children:v_(e)},t))}),(0,q.jsxs)(`details`,{className:`more`,children:[(0,q.jsx)(`summary`,{children:`The patch as grooph ops`}),(0,q.jsx)(`pre`,{className:`issue-lines`,children:JSON.stringify(a.ops,null,2)})]})]}):a.kind===`other`?(0,q.jsxs)(`div`,{className:`proposal-other`,children:[(0,q.jsx)(`p`,{className:`field-hint`,children:a.why}),(0,q.jsx)(`pre`,{className:`issue-lines`,children:JSON.stringify(t.proposal.patch,null,2)})]}):(0,q.jsx)(`p`,{className:`field-hint`,children:`No patch: the summary is the whole proposal.`}),o?.ok?(0,q.jsxs)(`div`,{role:`status`,children:[o.brakes,(0,q.jsxs)(`p`,{className:`adopt-done`,children:[`Saved a copy of the working copy with `,t.id,` applied, as version `,o.version,`, for you to inspect`,o.errors>0?`; it has ${o.errors} error${o.errors===1?``:`s`}, which the editor lists`:o.warnings>0?`; ${o.warnings} warning${o.warnings===1?``:`s`}`:`; it validates`,`. Nothing else changed. `,(0,q.jsx)(`a`,{href:m_(o.key),children:`Open the copy`})]})]}):(0,q.jsxs)(q.Fragment,{children:[o?(0,q.jsx)(`p`,{className:`refusal-hint`,role:`status`,children:o.message}):null,a.kind===`ops`&&(!o||o.again)?(0,q.jsx)(`button`,{type:`button`,className:`btn`,disabled:s,onClick:()=>void l(t,r),children:`Apply to a copy`}):null]})]},r)})})]})}var b_=e=>{if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):e},x_=e=>e.text??e.amendment?.summary??e.proposal?.summary??``;function S_(e){let{bundle:t}=e;return(0,q.jsxs)(`div`,{className:`timeline`,children:[(0,q.jsxs)(`p`,{className:`run-intro`,children:[e.newestFirst?`Newest first, while the run is live.`:`In the order the run wrote them.`,` Tap a note to find it on the graph.`]}),(0,q.jsx)(`ol`,{className:`tl-list`,children:e.notes.map(n=>{let r=e.selected===n.id,i=_t(n),a=at(n.outcome);return(0,q.jsxs)(`li`,{className:`tl-item${r?` is-on`:``}`,"data-note-id":n.id,children:[(0,q.jsxs)(`button`,{type:`button`,className:`tl-note`,"aria-expanded":r,onClick:()=>e.onSelect(n.id),children:[(0,q.jsxs)(`span`,{className:`tl-head`,children:[a?(0,q.jsx)(Mh,{state:a}):(0,q.jsx)(`span`,{className:`tl-dot`,"aria-hidden":`true`}),(0,q.jsx)(`span`,{className:`tl-where`,children:Qe(i,t.working)}),n.round===void 0?null:(0,q.jsxs)(`span`,{className:`tl-round`,children:[`round `,n.round]}),n.stop?(0,q.jsxs)(`span`,{className:`tl-stop`,children:[`stop: `,n.stop]}):null,n.outcome?(0,q.jsxs)(`span`,{className:`tl-outcome outcome-${a??`passed`}`,children:[n.outcome,n.verdict&&n.verdict!==n.outcome?` · ${n.verdict}`:``]}):null,(0,q.jsx)(`span`,{className:`tl-id mono`,children:n.id})]}),n.amendment||n.proposal?(0,q.jsxs)(`span`,{className:`tl-marks`,children:[n.amendment?(0,q.jsx)(`span`,{className:`mark mark-amendment`,children:`Amendment`}):null,n.proposal?(0,q.jsx)(`span`,{className:`mark mark-proposal`,children:`Proposal`}):null]}):null,x_(n)?(0,q.jsx)(`span`,{className:`tl-text`,children:x_(n)}):null]}),r?(0,q.jsx)(C_,{bundle:t,note:n,onShow:e.onShow}):null]},n.id)})}),t.issues&&t.issues.length>0?(0,q.jsxs)(`div`,{className:`warnings tl-unread`,children:[(0,q.jsxs)(`p`,{children:[(0,q.jsxs)(`strong`,{children:[t.issues.length,` line`,t.issues.length===1?``:`s`,` of notes.jsonl could not be read.`]}),` `,`The notes around `,t.issues.length===1?`it`:`them`,` are shown; a line cut short while the lead was writing it looks like this.`]}),(0,q.jsx)(`ul`,{className:`plain-list`,children:t.issues.map(e=>(0,q.jsxs)(`li`,{children:[`line `,e.line,`: `,e.message]},e.line))})]}):null]})}function C_({bundle:e,note:t,onShow:n}){let[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(!1),s=ct(t.started,t.ended),c=[[`When`,[b_(t.started),b_(t.ended)].filter(Boolean).join(` → `)+(s?` (${s})`:``)||void 0],[`Stop fired`,t.stop],[`Evidence`,t.evidence],[`Gaps`,t.gaps],[`Cost`,t.cost?`${t.cost.amount} ${t.cost.measure}`:void 0],[`Amendment`,t.amendment?t.amendment.summary:void 0],[`Why`,t.amendment?.reason],[`Proposal`,t.proposal?.summary],[`Note`,t.text&&(t.amendment||t.proposal)?t.text:void 0]];return(0,q.jsxs)(`div`,{className:`tl-details`,children:[(0,q.jsx)(`dl`,{className:`readonly`,children:c.filter(([,e])=>e!==void 0&&e!==``&&!(Array.isArray(e)&&e.length===0)).map(([e,t])=>(0,q.jsxs)(`div`,{className:`readonly-row`,children:[(0,q.jsx)(`dt`,{children:e}),(0,q.jsx)(`dd`,{children:Array.isArray(t)?(0,q.jsx)(`ul`,{className:`plain-list`,children:t.map((e,t)=>(0,q.jsx)(`li`,{children:e},t))}):(0,q.jsx)(`p`,{className:`prose`,children:t})})]},e))}),(0,q.jsxs)(`div`,{className:`tl-actions`,children:[r?(0,q.jsxs)(`p`,{className:`tl-pinned`,role:`status`,children:[r.already?`Already pinned to ${r.record.doc.name}.`:r.created?`Saved ${r.record.doc.name} to this device with ${r.id} pinned to it.`:`Pinned ${r.id} to ${r.record.doc.name} on this device.`,` `,(0,q.jsx)(`a`,{href:m_(r.record.key),children:`Open the graph`})]}):(0,q.jsx)(`button`,{type:`button`,className:`btn`,disabled:a,onClick:async()=>{o(!0);try{i(await ut(e,t))}finally{o(!1)}},children:`Pin to graph`}),t.amendment?(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:()=>n(`changes`),children:`See what changed`}):null,t.proposal?(0,q.jsx)(`button`,{type:`button`,className:`btn btn-quiet`,onClick:()=>n(`proposals`),children:`See the proposal`}):null]})]})}var w_={"bar-passed":`bar passed`,"max-iterations":`max iterations`,budget:`budget`,"diminishing-returns":`diminishing returns`,"evidence-invalid":`evidence invalid`,human:`human stop`},T_=e=>{let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<5?`just now`:t<60?`${t} s ago`:`${Math.floor(t/60)} min ago`};function E_(e,t){if(e.state===`running`)return;let n=e=>e.at.startsWith(`node:`)?t.nodes.find(t=>t.id===e.at.slice(5)):void 0,r=[...e.timeline].reverse(),i=r.find(e=>e.at!==`graph`&&e.outcome!==void 0)??r.find(e=>e.at!==`graph`);if(!i)return;let a=e.state===`halted`,o=n(i),s=t.nodes.filter(e=>e.kind===`stop`),c=s.filter(e=>t.edges.some(t=>t.from===o?.id&&t.to===e.id)),l=a?void 0:r.find(e=>n(e)?.kind===`stop`),u=a?i.outcome===`halt`?o:void 0:l?n(l):s.length===1?s[0]:c.length===1?c[0]:void 0,d=Qe(_t(i),t),f=u?`at ${u.name||u.id}`:a&&i.outcome===`halt`&&i.at.startsWith(`loop:`)?`in l${d.slice(1)}`:`after ${d}`,p;for(let n of r){let r=t.loops.find(t=>e.loops[t.id]?.lastStop?.note===n.id),i=r&&e.loops[r.id];if(r&&i?.lastStop?.fired){let e=i.lastStop.round??i.round;p=`${w_[i.lastStop.fired]} · ${r.name||r.id}${e==null?``:`, round ${e}`}`;break}}return{note:(l??i).id,where:f,...u?{node:u.id}:{},...p?{stop:p}:{}}}function D_(e,t){let n;for(let r of t.loops)r.members.some(t=>e.nodes[t]?.state===`running`)&&(!n||r.members.length<n.members.length)&&(n=r);return n}function O_({bundle:e,origin:t,back:n={href:`#/`,label:`All graphs`},hooks:r}){let i=(0,K.useMemo)(()=>vt(e),[e]),{summary:a}=i,o=(0,K.useMemo)(()=>r?ce(a,r):a,[a,r]),s=r?Object.values(r).reduce((e,t)=>e+t.running,0):0,c=e.working,[l,u]=(0,K.useState)(`timeline`),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(null),[_,v]=(0,K.useState)(!1),y=t.kind===`live`,b=y&&t.polling&&!t.error,x=bt(a,y),S=d?e.notes.find(e=>e.id===d):void 0,C=(0,K.useMemo)(()=>S?void 0:D_(o,c),[S,o,c]),w=(0,K.useMemo)(()=>S?$e(_t(S),c):C?{nodes:[],edges:C.back,loop:C.id}:void 0,[S,C,c]),T=(0,K.useMemo)(()=>E_(a,c),[a,c]),E=(0,K.useCallback)(e=>{u(`timeline`),f(e),requestAnimationFrame(()=>document.querySelector(`[data-note-id="${e}"]`)?.scrollIntoView({block:`nearest`}))},[]),D=t=>{let n=[...e.notes].reverse().find(e=>e.at===`node:${t}`);n&&E(n.id)},O=a.state===`ended`?`Ended${a.outcome?` · ${a.outcome}`:``}`:a.state===`halted`?`Halted`:`Running`,k=a.state===`running`?`run-status-running`:a.state===`halted`?`status-warning`:a.outcome===`pass`?`status-ok`:a.outcome===`fail`?`status-error`:`run-status-ended`,A=c.loops.map((e,t)=>({loop:e,i:t,run:a.loops[e.id]})),j=Object.entries(a.cost).map(([e,t])=>`${t} ${e}`),M=ct(a.started,a.ended),N=[M?`${M} start to end`:void 0,j.length>0?`cost noted: ${j.join(`, `)}`:void 0,`${e.notes.length} note${e.notes.length===1?``:`s`}`].filter(Boolean),P=[{id:`timeline`,label:`Timeline`,count:e.notes.length},{id:`changes`,label:`Changes`,count:i.diff.changes.length},{id:`proposals`,label:`Proposals`,count:a.proposals.length},...e.progress?[{id:`log`,label:`Log`}]:[]],F=async()=>{let{record:t,replaced:n}=await it(e);m({key:t.key,replaced:n})};return(0,q.jsxs)(`div`,{className:`run-view${_?` is-tall`:``}`,children:[(0,q.jsxs)(`header`,{className:`topbar`,children:[(0,q.jsx)(`a`,{className:`icon-btn`,href:n.href,"aria-label":n.label,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M15 5 8 12l7 7`})})}),(0,q.jsxs)(`div`,{className:`title-btn run-title`,children:[(0,q.jsx)(`span`,{className:`title-name`,children:c.name||c.id}),(0,q.jsxs)(`span`,{className:`title-sub${b?` is-live`:``}`,children:[(0,q.jsxs)(`span`,{children:[`Run `,(0,q.jsx)(`span`,{className:`mono`,children:e.run})]}),(0,q.jsx)(`span`,{children:` · `}),(0,q.jsx)(`span`,{className:`run-from`,children:t.kind===`link`?`from a link`:t.kind===`live`?`live`:`on this device`})]})]}),(0,q.jsxs)(`span`,{className:`status run-status ${k}`,role:`img`,"aria-label":`Run state: ${O}`,"data-run-state":a.state,children:[(0,q.jsx)(Mh,{state:a.state===`ended`?a.outcome===`fail`?`failed`:`passed`:a.state}),O]})]}),(0,q.jsxs)(`main`,{className:`stage run-stage${C?` is-glowing`:``}`,children:[T?.node?(0,q.jsx)(`style`,{children:`.run-stage .react-flow__node[data-id="${CSS.escape(T.node)}"] .gnode::before{content:"${a.state} here"}`}):null,(0,q.jsx)(u_,{doc:c,variant:`full`,issues:i.issues,run:o,notes:e.notes,...w?{highlight:w}:{},onNodeTap:D}),(0,q.jsx)(Wh,{}),A.length>0?(0,q.jsx)(`nav`,{className:`loop-legend`,"aria-label":`Loops`,children:A.map(({loop:t,i:n,run:r})=>{let i=w?.loop===t.id,a=r?.lastStop?.fired?w_[r.lastStop.fired]:void 0;return(0,q.jsxs)(`button`,{type:`button`,className:`loop-pill loop-c${n%4}${i?` is-on`:``}`,"data-loop-id":t.id,onClick:()=>{let n=r?.lastStop?.note??[...e.notes].reverse().find(e=>e.at===`loop:${t.id}`)?.id;n&&E(n)},children:[(0,q.jsx)(`span`,{className:`loop-dot loop-c${n%4}`,"aria-hidden":`true`}),t.name||t.id,(0,q.jsx)(`span`,{className:`loop-round`,children:r?.round===null||r===void 0?`not entered`:`round ${r.round}`}),a?(0,q.jsxs)(`span`,{className:`loop-stop`,children:[`· `,a]}):null,t===C?(0,q.jsx)(`span`,{className:`loop-stop`,children:`· running`}):null]},t.id)})}):null,(0,q.jsxs)(`button`,{type:`button`,className:`canvas-size`,"aria-pressed":_,onClick:()=>v(e=>!e),children:[(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:_?(0,q.jsx)(`path`,{d:`M12 21v-7M8 17l4-4 4 4M12 3v7M8 7l4 4 4-4`}):(0,q.jsx)(`path`,{d:`M12 14v7M8 18l4 4 4-4M12 10V3M8 6l4-4 4 4`})}),_?`Smaller graph`:`Bigger graph`]})]}),(0,q.jsxs)(`section`,{className:`run-panel`,"aria-label":`Run details`,children:[(0,q.jsxs)(`div`,{className:`run-facts`,children:[T?(0,q.jsxs)(`button`,{type:`button`,className:`run-end run-end-${a.state}`,onClick:()=>E(T.note),children:[(0,q.jsx)(Mh,{state:a.state===`halted`?`halted`:a.outcome===`fail`?`failed`:`passed`}),(0,q.jsxs)(`span`,{children:[(0,q.jsxs)(`strong`,{children:[a.state===`halted`?`Halted`:`Ended`,` `,T.where]}),(0,q.jsx)(`br`,{}),T.stop?`Last loop stop: ${T.stop}`:c.loops.length>0?`No loop stop on record.`:`The graph has no loops.`]})]}):null,(0,q.jsx)(`p`,{className:`run-line`,children:N.join(` · `)}),t.kind===`live`?(0,q.jsxs)(`p`,{className:`run-origin${t.error?` is-problem`:``}`,role:`status`,children:[(0,q.jsx)(`span`,{className:`live-dot${t.polling&&!t.error?` is-on`:``}`,"aria-hidden":`true`}),t.error?`${t.error} Showing what it last sent, from ${T_(t.updatedAt)}; still trying.`:t.polling?`Live from grooph watch · updated ${T_(t.updatedAt)}${r?` · the hook sees ${s} subagent${s===1?``:`s`} running`:``}`:`The run ended; grooph watch sent its last state ${T_(t.updatedAt)}.`]}):null,t.kind===`stored`?(0,q.jsx)(`div`,{className:`run-origin`,children:h===`done`?(0,q.jsx)(`span`,{role:`status`,children:`Removed from this device. The graph and its versions stay.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`span`,{children:[`Kept on this device since `,new Date(t.savedAt).toLocaleDateString(),`.`]}),h===`ask`?(0,q.jsx)(`button`,{type:`button`,className:`btn btn-small btn-danger`,onClick:async()=>{await ht(t.key),g(`done`)},children:`Remove for good`}):(0,q.jsx)(`button`,{type:`button`,className:`btn btn-small btn-quiet`,onClick:()=>g(`ask`),children:`Remove`})]})}):p?(0,q.jsxs)(`p`,{className:`run-origin`,role:`status`,children:[p.replaced?`Updated the copy of this run on this device.`:`Saved this run to this device; your graphs list it under its graph.`,` `,(0,q.jsx)(`a`,{href:tt(p.key),children:`Open the saved run`})]}):(0,q.jsxs)(`div`,{className:`run-origin`,children:[(0,q.jsx)(`span`,{children:`Not stored on this device until you save it.`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:()=>void F(),children:t.kind===`live`?`Save a copy`:`Save run`})]})]}),(0,q.jsx)(`div`,{className:`run-tabs`,role:`tablist`,"aria-label":`Run`,children:P.map(e=>(0,q.jsxs)(`button`,{type:`button`,role:`tab`,id:`run-tab-${e.id}`,"aria-selected":l===e.id,"aria-controls":`run-panel-${e.id}`,className:`run-tab${l===e.id?` is-on`:``}`,onClick:()=>u(e.id),children:[e.label,e.count===void 0?null:(0,q.jsx)(`span`,{className:`run-tab-count`,children:e.count})]},e.id))}),(0,q.jsx)(`div`,{className:`run-body`,role:`tabpanel`,id:`run-panel-${l}`,"aria-labelledby":`run-tab-${l}`,children:l===`timeline`?(0,q.jsx)(S_,{bundle:e,notes:x,newestFirst:x!==a.timeline,selected:d,onSelect:e=>f(t=>t===e?null:e),onShow:e=>u(e)}):l===`changes`?(0,q.jsx)(__,{model:i,onNote:E}):l===`proposals`?(0,q.jsx)(y_,{bundle:e,proposals:a.proposals,onNote:E},Ze(e)):(0,q.jsx)(`pre`,{className:`run-log`,children:e.progress})},l)]})]})}var k_=2e3,A_=()=>new URL(`api/run.json`,document.baseURI).href;async function j_(e){try{let t=await fetch(P_(),{cache:`no-store`});if(!t.ok||!(t.headers.get(`content-type`)??``).includes(`application/json`))return;let n=F_(await t.text());if(!n)return;let r=e.notes.map(e=>e.started??e.ended).find(e=>e!==void 0&&!Number.isNaN(Date.parse(e))),i=le(n.sessions,e.working,r?new Date(r).toISOString():void 0);return Object.keys(i).length>0?i:void 0}catch{return}}function M_(){let[e,t]=(0,K.useState)({updatedAt:Date.now(),polling:!0});return(0,K.useEffect)(()=>{let e=!1,n,r=async()=>{let i=!1;try{let e=await fetch(A_(),{cache:`no-store`}),n=await e.text();if(!(e.headers.get(`content-type`)??``).includes(`application/json`))t(e=>({...e,error:`There is no grooph watch here. A live run opens from the address grooph watch prints on your computer.`}));else if(e.ok){let e=T(n);if(!e.bundle)t(e=>({...e,error:`grooph watch sent something that is not a run; it may be a different version of grooph.`}));else{i=_(e.bundle.notes,e.bundle.working).state===`ended`;let n=i?void 0:await j_(e.bundle);t({bundle:e.bundle,updatedAt:Date.now(),polling:!i,...n?{hooks:n}:{}})}}else{let r=`grooph watch answered ${e.status}.`;try{r=`${String(JSON.parse(n).error??r)}.`}catch{}t(e=>({...e,error:r.replace(/\.\.$/,`.`)}))}}catch{t(e=>({...e,error:`grooph watch is not answering. Is it still running?`}))}!e&&!i&&(n=setTimeout(()=>void r(),k_))};return r(),()=>{e=!0,clearTimeout(n)}},[]),e.bundle?(0,q.jsx)(O_,{bundle:e.bundle,origin:{kind:`live`,updatedAt:e.updatedAt,polling:e.polling,...e.error?{error:e.error}:{}},...e.hooks?{hooks:e.hooks}:{}}):(0,q.jsxs)(`main`,{className:`link-problem`,"aria-live":`polite`,children:[(0,q.jsx)(`h1`,{children:e.error?`No run to show yet`:`Waiting for grooph watch`}),(0,q.jsx)(`p`,{children:e.error??`Asking the server this page came from for the run.`}),e.error?(0,q.jsx)(`p`,{className:`muted`,children:`Still asking every two seconds.`}):null,(0,q.jsx)(`a`,{className:`btn btn-large`,href:`#/`,children:`Back to your graphs`})]})}function N_({runKey:e}){let[t,n]=(0,K.useState)(void 0);return(0,K.useEffect)(()=>{pt(e).then(e=>n(e??null))},[e]),t===void 0?(0,q.jsx)(`div`,{className:`loading`,children:`Loading…`}):t===null?(0,q.jsxs)(`main`,{className:`link-problem`,children:[(0,q.jsx)(`h1`,{children:`That run is not on this device`}),(0,q.jsx)(`p`,{children:`It may have been removed. Runs are kept per browser; import its .grooph-run.json file to see it here.`}),(0,q.jsx)(`a`,{className:`btn btn-primary btn-large`,href:`#/`,children:`Back to your graphs`})]}):(0,q.jsx)(O_,{bundle:t.bundle,origin:{kind:`stored`,key:t.key,savedAt:t.savedAt}})}var P_=()=>new URL(`api/live.json`,document.baseURI).href;function F_(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t||t.groophLive!==0||!Array.isArray(t.sessions)||typeof t.at!=`string`)return;let{map:n,...r}=t,i=n===void 0?void 0:m(n).map;return i?{...r,map:i}:r}catch{return}}var I_=`There is no grooph watch here that serves sessions.`;async function L_(){if(location.protocol!==`https:`)return!0;try{return((await fetch(document.baseURI,{method:`HEAD`,cache:`no-store`})).headers.get(`referrer-policy`)??``).split(`,`).some(e=>e.trim()===`no-referrer`)}catch{return!0}}function R_(e=!0){let[t,n]=(0,K.useState)({fetchedAt:Date.now()});return(0,K.useEffect)(()=>{if(!e)return;let t=!1,r,i=async()=>{try{let e=await fetch(P_(),{cache:`no-store`}),t=(e.headers.get(`content-type`)??``).includes(`application/json`)&&e.ok?F_(await e.text()):void 0;n(t?{view:t,fetchedAt:Date.now()}:e=>({...e,error:I_}))}catch{n(e=>({...e,error:`grooph watch is not answering. Is it still running?`}))}t||(r=setTimeout(()=>void i(),k_))};return L_().then(e=>{t||(e?i():n(e=>({...e,error:I_,off:!0})))}),()=>{t=!0,clearTimeout(r)}},[e]),t}var z_=`grooph watch --sessions`;function B_({live:e}){let[t,n]=(0,K.useState)(``);return(0,q.jsxs)(`div`,{className:`live-none`,children:[(0,q.jsx)(`h2`,{children:`Your sessions, as they work`}),(0,q.jsx)(`p`,{children:`This screen shows each session the event hook has recorded on your computer, and its subagents as they start and stop.`}),(0,q.jsxs)(`p`,{role:`status`,children:[e.error,` Run this in your project and open the address it prints:`]}),(0,q.jsxs)(`div`,{className:`copy-line`,children:[(0,q.jsx)(`code`,{className:`copy-line-text`,children:z_}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-small`,"aria-label":`Copy the command`,onClick:async()=>n(await Dt(z_)?`Copied.`:`Could not copy. Select the line and copy it.`),children:`Copy`}),(0,q.jsx)(`span`,{className:`copy-line-said muted`,role:`status`,children:t})]}),(0,q.jsxs)(`p`,{className:`muted`,children:[(0,q.jsx)(`span`,{className:`mono`,children:`grooph hooks install`}),` starts the recording. `,e.off?``:`Still asking every two seconds.`]})]})}var V_={"claude-code":`Claude Code`,codex:`Codex`},H_={working:`Working`,waiting:`Waiting`,ended:`Ended`},U_=e=>e.length>10?e.slice(-8):e,W_=e=>e?.split(`/`).filter(Boolean).pop();function G_(e){let t=e.indexOf(`--`);return t>0?{name:e.slice(t+2),of:e.slice(0,t)}:{name:e}}function K_({agent:e,now:t,depth:n,quiet:r}){let i=e.state===`running`&&!r,{name:a,of:o}=G_(e.type),s=[e.state===`running`?r?`not seen to finish, started ${ae(Me(e.started,t))} ago`:`running ${ae(Me(e.started,t))}`:`done in ${ae(Me(e.started,e.ended??e.lastAt))}`,e.stops>1?`resumed ${e.stops-1}×`:void 0,e.tools>0?`${e.tools} tool call${e.tools===1?``:`s`}${e.lastTool?`, last ${e.lastTool}`:``}`:void 0,e.model].filter(Boolean);return(0,q.jsxs)(`li`,{className:`live-agent${i?` is-running`:``}`,"data-agent-id":e.id,"data-agent-state":e.state,style:{marginLeft:n*18},children:[(0,q.jsx)(`span`,{className:`live-mark`,role:`img`,"aria-label":i?`running`:e.state===`running`?`not seen to finish`:`done`,children:i||e.state===`running`?null:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`m5 12.5 4.5 4.5L19 7.5`})})}),(0,q.jsxs)(`span`,{className:`live-agent-text`,children:[(0,q.jsxs)(`span`,{className:`live-agent-name`,children:[a,o?(0,q.jsx)(`span`,{className:`badge badge-quiet`,children:o}):null,(0,q.jsx)(`span`,{className:`live-id mono`,children:U_(e.id)})]}),(0,q.jsx)(`span`,{className:`live-agent-facts`,children:s.join(` · `)})]})]})}function q_({plan:e,quiet:t}){return(0,q.jsxs)(`div`,{className:`live-plan`,"data-plan":!0,children:[(0,q.jsxs)(`p`,{className:`live-plan-head`,children:[(0,q.jsx)(`span`,{className:`badge badge-quiet`,children:`plan`}),` `,e.title??`Declared subagents`,(0,q.jsx)(`span`,{className:`live-plan-sum`,children:z(e,t)})]}),(0,q.jsx)(`ul`,{className:`live-plan-list`,children:e.agents.map((e,n)=>{let r=e.count??1,i=e.running>0?`running`:e.started>=r?`started`:e.started>0?`partly`:`waiting`;return(0,q.jsxs)(`li`,{"data-plan-state":i,children:[(0,q.jsxs)(`span`,{className:`live-plan-type`,children:[r>1?`${r} × `:``,G_(e.type).name]}),(0,q.jsx)(`span`,{className:`live-plan-state`,children:i===`running`?`${e.running} ${t?`not seen to finish`:`running`}`:i===`started`?`started`:i===`partly`?`${e.started} of ${r} started`:`not started`}),e.purpose?(0,q.jsx)(`span`,{className:`live-plan-purpose`,children:e.purpose}):null]},`${e.type}-${n}`)})}),e.unplanned.length>0?(0,q.jsxs)(`p`,{className:`live-plan-extra`,children:[`Started without being in the plan: `,e.unplanned.map(e=>G_(e).name).join(`, `)]}):null]})}function J_({session:e,now:t}){let n=Se(e,t),r=new Set(e.agents.map(e=>e.id)),i=[],a=(t,n)=>{for(let o of e.agents){let e=o.parent===void 0||!r.has(o.parent);(t===void 0?!e:o.parent!==t)||(i.push({agent:o,depth:n}),a(o.id,n+1))}};a(void 0,0);let o=e.agents.filter(e=>e.state===`running`).length,s=[W_(e.cwd),e.model,`session ${U_(e.id)}`].filter(Boolean).join(` · `),c=Me(e.lastAt,t);return(0,q.jsxs)(`section`,{className:`live-session live-${n?`quiet`:e.state}`,"data-session-id":e.id,"data-session-state":e.state,"data-quiet":n||void 0,"aria-label":`${V_[e.harness]??e.harness} session ${U_(e.id)}`,children:[(0,q.jsxs)(`header`,{className:`live-session-head`,children:[(0,q.jsxs)(`div`,{className:`live-session-title`,children:[(0,q.jsx)(`span`,{className:`live-harness live-harness-${e.harness===`codex`?`codex`:`claude`}`,children:V_[e.harness]??e.harness}),(0,q.jsx)(`span`,{className:`status live-state live-state-${n?`quiet`:e.state}`,children:n?`Last seen ${ae(c)} ago`:H_[e.state]})]}),(0,q.jsx)(`p`,{className:`live-session-sub`,children:s}),(0,q.jsxs)(`p`,{className:`live-session-facts`,children:[e.agents.length===0?`No subagents yet`:n&&o>0?`${o} not seen to finish · ${e.agents.length-o} done`:`${o} running · ${e.agents.length-o} done`,e.tools>0?` · ${e.tools} tool call${e.tools===1?``:`s`} of its own`:``,e.state===`ended`?` · ran ${ae(Me(e.started,e.ended??e.lastAt))}`:n?` · ${e.state} then`:` · last seen ${c<5?`just now`:`${ae(c)} ago`}`]})]}),e.plans&&e.plans.length>0?(0,q.jsx)(q_,{plan:e.plans[e.plans.length-1],quiet:n}):null,i.length>0?(0,q.jsx)(`ul`,{className:`live-agents`,"aria-label":`Subagents`,children:i.map(({agent:e,depth:r})=>(0,q.jsx)(K_,{agent:e,now:t,depth:r,quiet:n},e.id))}):null,e.notes&&e.notes.length>0?(0,q.jsx)(`ul`,{className:`live-notes`,"aria-label":`Notes from the lead`,children:e.notes.slice(-3).map(e=>(0,q.jsx)(`li`,{children:e.text},e.t))}):null]})}function Y_({map:e,view:t}){let n=(0,K.useMemo)(()=>Ae(e,{live:_e(t.sessions,e,t.at),at:t.at}),[e,t]);return(0,q.jsx)(`section`,{className:`live-map`,"aria-label":`Operation map: ${e.name}`,children:(0,q.jsx)(`div`,{className:`map-picture`,dangerouslySetInnerHTML:{__html:n}})})}function X_(){let e=R_(),[t,n]=(0,K.useState)(0);(0,K.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]);let r=(0,K.useMemo)(()=>e.view?new Date(Date.parse(e.view.at)+(Date.now()-e.fetchedAt)).toISOString():new Date().toISOString(),[e,t]),i=e.view?.sessions??[],a=e=>Se(e,r)?`quiet`:e.state,o={working:0,waiting:1,quiet:2,ended:3},s=[...i].sort((e,t)=>o[a(e)]-o[a(t)]||(e.lastAt<t.lastAt?1:-1)),c=new Map;for(let e of s)c.set(e.source??``,[...c.get(e.source??``)??[],e]);let l={working:0,waiting:0,quiet:0,ended:0};for(let e of i)l[a(e)]+=1;let u=l.working,d=i.reduce((e,t)=>e+(a(t)===`quiet`?0:t.agents.filter(e=>e.state===`running`).length),0);return(0,q.jsxs)(`div`,{className:`live-view`,children:[(0,q.jsxs)(`header`,{className:`topbar`,children:[(0,q.jsx)(`a`,{className:`icon-btn`,href:`#/`,"aria-label":`All graphs`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M15 5 8 12l7 7`})})}),(0,q.jsxs)(`div`,{className:`title-btn run-title`,children:[(0,q.jsx)(`span`,{className:`title-name`,children:`Sessions`}),(0,q.jsx)(`span`,{className:`title-sub`,children:`what the event hook has seen · live`})]}),(0,q.jsx)(`span`,{className:`status ${u>0?`run-status-running`:`run-status-ended`}`,role:`status`,"aria-label":`${u} working, ${d} subagents running`,children:u>0?`${d} running`:e.view?`Quiet`:`Not connected`})]}),(0,q.jsxs)(`main`,{className:`live-main`,children:[e.error&&e.view?(0,q.jsxs)(`p`,{className:`run-origin is-problem`,role:`status`,children:[e.error,` Showing what it last sent; still asking.`]}):null,e.view?null:e.error?(0,q.jsx)(B_,{live:e}):(0,q.jsx)(`p`,{className:`muted live-empty`,children:`Asking the server this page came from for its sessions.`}),(0,q.jsxs)(`div`,{className:`live-body${e.view?.map?` has-map`:``}`,children:[e.view?.map?(0,q.jsx)(Y_,{map:e.view.map,view:e.view}):null,(0,q.jsxs)(`div`,{className:`live-list`,children:[i.length>1?(0,q.jsx)(`p`,{className:`live-sum`,"aria-label":`Sessions by state`,children:Object.keys(l).map(e=>l[e]>0?(0,q.jsxs)(`span`,{className:`live-state-${e}`,children:[l[e],` `,e===`quiet`?`gone quiet`:e]},e):null)}):null,e.view&&i.length===0?(0,q.jsxs)(`div`,{className:`live-empty`,children:[(0,q.jsx)(`p`,{children:`No sessions recorded yet.`}),(0,q.jsxs)(`p`,{className:`muted`,children:[`A hook writes one line when a session or a subagent starts or stops. Install it in the project with `,(0,q.jsx)(`span`,{className:`mono`,children:`grooph hooks install`}),`, start a session, and it appears here.`]})]}):null,[...c.entries()].map(([e,t])=>(0,q.jsxs)(`div`,{className:`live-group`,children:[e===``?null:(0,q.jsx)(`h2`,{className:`live-source`,children:e}),t.map(e=>(0,q.jsx)(J_,{session:e,now:r},`${e.harness}/${e.id}`))]},e)),e.view?.issues&&e.view.issues.length>0?(0,q.jsxs)(`p`,{className:`field-hint`,children:[e.view.issues.length,` line`,e.view.issues.length===1?``:`s`,` of the events could not be read (the first: `,e.view.issues[0].source,`, line `,e.view.issues[0].line,`).`]}):null,e.view?(0,q.jsx)(`p`,{className:`field-hint live-foot`,children:`This shows that something ran, when and for how long. What an agent said is not recorded, except a plan or a note its lead chose to leave.`}):null]})]})]})]})}var Z_={"gauntlet-decomposed":[{name:`Matt Shumer's Gauntlet Loop and the Claude of Duty repository`,url:`https://github.com/mshumer/Claude-of-Duty`,note:`decompose, then builder plus fresh critic per piece against a real reference, blind side by side; here bounded, and pieces run in sequence because the repository's own note says fan-out lost on coupled work`}],"merge-queue":[{name:`Steve Yegge's Gas Town Refinery`,url:`https://github.com/gastownhall/gastown`,note:`a merge queue that integrates a batch, bisects on failure and lands by a human's word`},{name:`Bors`,url:`https://github.com/bors-ng/bors-ng`,note:`batch then bisect`}],"ownership-not-swarm":[{name:`Claude of Duty process note (Matt Shumer)`,url:`https://github.com/mshumer/Claude-of-Duty`,note:`sequential ownership beat parallel fan-out on coupled systems in the repository's own write-up`}],"patrol-pulse":[{name:`u/croovies's "Lloyd" heartbeat orchestrator, as written up by explainx.ai (2026-08-14; a secondary source)`,url:`https://www.explainx.ai/blog/claude-code-loop-orchestrator-heartbeat-ticket-memory-august-2026`,note:`a standing checklist per pulse, a read-only investigator, findings to a durable ticket store, humans prioritize`},{name:`Steve Yegge's Gas Town patrols`,url:`https://github.com/gastownhall/gastown`,note:`patrol agents that loop by design; here one pulse is one run`}],"ralph-loop":[{name:`Geoffrey Huntley's ralph loop`,url:`https://ghuntley.com/ralph/`,note:`one prompt piped into a fresh session per pass; one item of work per pass from a plan file; state on disk; the human as the brake, here replaced by stops`}],"spec-then-loop":[{name:`Answer-key-first Gauntlet, a community modification of Matt Pocock's Wayfinder`,url:`https://github.com/mattpocock/skills/blob/main/docs/engineering/wayfinder.md`,note:`write the spec and a pass/fail answer key before the loop; the modification is known from a secondary write-up, not a primary source`}],"taste-polish":[{name:`Matt Shumer's Gauntlet Loop (Claude of Duty)`,url:`https://github.com/mshumer/Claude-of-Duty`,note:`the bounded form of the Gauntlet: one owner, an isolated critic against a named reference, real stops`}]};function Q_({credits:e,className:t=`credits`}){return!e||e.length===0?null:(0,q.jsx)(`ul`,{className:t,"aria-label":`Credits`,children:e.map(e=>(0,q.jsxs)(`li`,{children:[`Inspired by`,` `,(0,q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,children:e.name}),`: `,e.note]},e.url+e.name))})}function $_({profile:e,className:t=`ccard-profile`}){return(0,q.jsx)(`ul`,{className:t,"aria-label":`Profile`,children:[`cost`,`speed`,`rigor`].map(t=>(0,q.jsxs)(`li`,{className:`pchip`,children:[(0,q.jsxs)(`span`,{className:`meter`,"aria-hidden":`true`,"data-level":Ke[t][e[t]],children:[(0,q.jsx)(`i`,{}),(0,q.jsx)(`i`,{}),(0,q.jsx)(`i`,{})]}),We[t][e[t]]]},t))})}var ev=(e,t)=>`I pick "${t.label}" (${t.id}) from ${e.id}.`;function tv({set:e,setIssues:t,payload:n}){let r=(0,K.useMemo)(()=>e.candidates.map(t=>{let n=t.graph,r=e.recommendation?.candidate===t.id;return{c:t,graph:n,issues:et(n),recommended:r,...r?{why:e.recommendation.why}:{}}}),[e]),i=t.filter(e=>e.code!==`E_CANDIDATE_INVALID`),a=(0,K.useRef)(null),o=Math.max(0,r.findIndex(e=>e.recommended)),[s,c]=(0,K.useState)(o),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(null),[p,m]=(0,K.useState)(null),{saved:h,busy:g,save:_}=p_();(0,K.useEffect)(()=>{let e=a.current;if(!e)return;let t=0,n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>{let t=e.scrollLeft+e.clientWidth/2,n=0,r=1/0;[...e.children].forEach((e,i)=>{let a=e,o=Math.abs(a.offsetLeft+a.offsetWidth/2-t);o<r&&([n,r]=[i,o])}),c(n)})};return e.addEventListener(`scroll`,n,{passive:!0}),()=>{e.removeEventListener(`scroll`,n),cancelAnimationFrame(t)}},[]),(0,K.useLayoutEffect)(()=>{let e=a.current,t=e?.children[o];e&&t&&o!==0&&(e.scrollLeft=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2)},[]);let v=(0,K.useCallback)(e=>{let t=a.current,n=t?.children[e];t&&n&&t.scrollTo({left:n.offsetLeft-(t.clientWidth-n.offsetWidth)/2,behavior:matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})},[]),y=async t=>{let n=ev(e,t);f({id:t.id,ok:await Dt(n),line:n})},b=async()=>{for(let e of r)h[e.c.id]||await _(e.c.id,e.graph);m(r.length)},x=r[Math.min(s,r.length-1)],S=e.brief.length>240;return(0,q.jsxs)(`div`,{className:`compare`,children:[(0,q.jsxs)(`header`,{className:`compare-top`,children:[(0,q.jsx)(`a`,{className:`icon-btn`,href:`#/`,"aria-label":`All graphs`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M15 5 8 12l7 7`})})}),(0,q.jsxs)(`div`,{className:`compare-heading`,children:[(0,q.jsxs)(`span`,{className:`overline`,children:[r.length===1?`One proposal`:`${r.length} proposals`,` · `,(0,q.jsx)(`span`,{className:`mono`,children:e.id})]}),(0,q.jsx)(`h1`,{children:e.title})]}),r.length>1?(0,q.jsx)(`button`,{type:`button`,className:`btn btn-small`,disabled:g!==null,onClick:()=>void b(),children:`Save all`}):null]}),(0,q.jsxs)(`section`,{className:`compare-brief`,"aria-label":`Brief`,children:[(0,q.jsx)(`p`,{className:S&&!l?`is-clamped`:void 0,children:e.brief}),S?(0,q.jsx)(`button`,{type:`button`,className:`link`,"aria-expanded":l,onClick:()=>u(e=>!e),children:l?`Less`:`More`}):null,p===null?null:(0,q.jsxs)(`p`,{className:`compare-saved`,role:`status`,children:[p,` graphs are on this device. `,(0,q.jsx)(`a`,{href:`#/`,children:`Open the library`})]}),i.length>0?(0,q.jsxs)(`div`,{className:`warnings`,children:[(0,q.jsx)(`p`,{children:`Notes on the set itself`}),(0,q.jsx)(`pre`,{className:`issue-lines`,children:i.map(oe).join(`
|
|
15
|
-
`)})]}):null]}),(0,q.jsx)(`div`,{className:`cards`,ref:a,style:{"--cards":r.length},"aria-label":`Candidates`,children:r.map((e,t)=>(0,q.jsx)(nv,{row:e,index:t,total:r.length,fullHref:`#/open?d=${n}&c=${encodeURIComponent(e.c.id)}`,onChoose:()=>void y(e.c),copied:d?.id===e.c.id?d:null,onSave:()=>void _(e.c.id,e.graph),saved:h[e.c.id]?.key,busy:g===e.c.id},e.c.id))}),(0,q.jsxs)(`footer`,{className:`compare-bar`,children:[r.length>1?(0,q.jsxs)(`div`,{className:`pager`,role:`group`,"aria-label":`Candidates`,children:[r.map((e,t)=>(0,q.jsx)(`button`,{type:`button`,className:`pager-dot`,"aria-label":`Show ${e.c.label}`,"aria-current":t===s?`true`:void 0,onClick:()=>v(t)},e.c.id)),(0,q.jsxs)(`span`,{className:`pager-count`,"aria-live":`polite`,children:[x.c.label,` · `,s+1,` of `,r.length]})]}):null,(0,q.jsx)(rv,{label:x.c.label,onChoose:()=>void y(x.c),onSave:()=>void _(x.c.id,x.graph),saved:h[x.c.id]?.key,busy:g===x.c.id,copied:d?.id===x.c.id?d:null})]})]})}function nv(e){let{c:t,graph:n,issues:r,recommended:i}=e.row,a=t.shape??Ce(n),{errors:o,warnings:s}=Fm(r),c=o>0?`status-error`:s>0?`status-warning`:`status-ok`,l=o>0?`${o} error${o===1?``:`s`}`:s>0?`${s} warning${s===1?``:`s`}`:`Valid`,u=`cand-${t.id}`;return(0,q.jsxs)(`article`,{className:`ccard${i?` is-recommended`:``}`,"aria-labelledby":u,"data-candidate":t.id,children:[(0,q.jsxs)(`div`,{className:`ccard-head`,children:[(0,q.jsxs)(`div`,{className:`ccard-title`,children:[(0,q.jsx)(`h2`,{id:u,children:t.label}),i?(0,q.jsx)(`span`,{className:`badge`,children:`Recommended`}):null,(0,q.jsxs)(`span`,{className:`ccard-index muted`,children:[e.index+1,`/`,e.total]})]}),e.row.why?(0,q.jsx)(`p`,{className:`ccard-why`,children:e.row.why}):null,t.basedOn?(0,q.jsxs)(`span`,{className:`ccard-based muted`,children:[`from the `,t.basedOn,` template`]}):null,t.basedOn&&Object.prototype.hasOwnProperty.call(Z_,t.basedOn)?(0,q.jsx)(Q_,{credits:Z_[t.basedOn]}):null]}),(0,q.jsx)($_,{profile:t.profile}),(0,q.jsxs)(`div`,{className:`ccard-shape`,children:[(0,q.jsx)(`p`,{className:`shape-line`,children:I(a)}),a.agents>0?(0,q.jsx)(`p`,{className:`tier-line muted`,children:R(a)}):null]}),(0,q.jsx)(`p`,{className:`ccard-rationale`,children:t.rationale}),(0,q.jsxs)(`div`,{className:`ccard-status`,children:[(0,q.jsx)(`span`,{className:`status ${c}`,children:l}),r.length>0?(0,q.jsx)(`ul`,{className:`ccard-issues`,children:r.map((e,t)=>(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mono`,children:e.code}),` `,e.message]},t))}):(0,q.jsx)(`span`,{className:`muted`,children:` Ready to export.`})]}),(0,q.jsxs)(`section`,{className:`ccard-list`,"aria-label":`Pros`,children:[(0,q.jsx)(`h3`,{children:`Pros`}),t.pros.length>0?(0,q.jsx)(`ul`,{className:`pros`,children:t.pros.map((e,t)=>(0,q.jsx)(`li`,{children:e},t))}):(0,q.jsx)(`p`,{className:`muted`,children:`None given.`})]}),(0,q.jsxs)(`section`,{className:`ccard-list`,"aria-label":`Cons`,children:[(0,q.jsx)(`h3`,{children:`Cons`}),t.cons.length>0?(0,q.jsx)(`ul`,{className:`cons`,children:t.cons.map((e,t)=>(0,q.jsx)(`li`,{children:e},t))}):(0,q.jsx)(`p`,{className:`muted`,children:`None given.`})]}),(0,q.jsxs)(`div`,{className:`ccard-canvas`,children:[(0,q.jsx)(Mt,{doc:n,className:`ccard-glyph`,decorative:!0}),(0,q.jsx)(`a`,{className:`btn btn-small`,href:e.fullHref,children:`Open full graph`})]}),(0,q.jsx)(`div`,{className:`ccard-actions`,children:(0,q.jsx)(rv,{label:t.label,onChoose:e.onChoose,onSave:e.onSave,saved:e.saved,busy:e.busy,copied:e.copied})})]})}function rv(e){return(0,q.jsxs)(`div`,{className:`actions`,children:[(0,q.jsxs)(`div`,{className:`actions-row`,children:[e.saved?(0,q.jsx)(`a`,{className:`btn`,href:m_(e.saved),children:`Open saved copy`}):(0,q.jsx)(`button`,{type:`button`,className:`btn`,disabled:e.busy,onClick:e.onSave,children:`Save to this device`}),(0,q.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:e.onChoose,"aria-label":`Choose ${e.label}`,children:[`Choose `,e.label]})]}),e.copied?e.copied.ok?(0,q.jsxs)(`p`,{className:`actions-note`,role:`status`,children:[`Copied. Paste it into the chat: `,(0,q.jsx)(`span`,{className:`mono`,children:e.copied.line})]}):(0,q.jsxs)(`p`,{className:`actions-note`,role:`status`,children:[`Copy this into the chat: `,(0,q.jsx)(`span`,{className:`mono selectable`,children:e.copied.line})]}):e.saved?(0,q.jsx)(`p`,{className:`actions-note`,role:`status`,children:`Saved to this device. It is editable from the library.`}):null]})}function iv({rows:e}){let t=e.filter(([,e])=>e!=null&&e!==``&&!(Array.isArray(e)&&e.length===0));return(0,q.jsx)(`dl`,{className:`readonly`,children:t.map(([e,t])=>(0,q.jsxs)(`div`,{className:`readonly-row`,children:[(0,q.jsx)(`dt`,{children:e}),(0,q.jsx)(`dd`,{children:t})]},e))})}var av=e=>e&&e.length>0?(0,q.jsx)(`ul`,{className:`plain-list`,children:e.map((e,t)=>(0,q.jsx)(`li`,{children:e},t))}):void 0,ov=e=>e?(0,q.jsx)(`p`,{className:`prose`,children:e}):void 0;function sv({node:e}){let t=[[`Name`,e.name],[`Id`,(0,q.jsx)(`span`,{className:`mono`,children:e.id})],[`About`,ov(e.description)],[`Coupled`,e.coupled?`yes`:void 0]];switch(e.kind){case`agent`:{let n=e.by!==`person`;return(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(iv,{rows:[...t,[`Done by`,n?void 0:`a person`],[`Role`,typeof e.role==`string`?e.role:`${e.role.custom} (custom)`],[`Model`,n?e.model?[e.model.tier,...Object.entries(e.model.pin??{}).map(([e,t])=>`${e}: ${t}`)].join(` · `):`session default`:void 0],[`Effort`,n?e.effort:void 0],[`Brief`,ov(e.brief)],[`Inputs`,av(e.inputs)],[`Outputs`,av(e.outputs)],[`Allowed`,n?av(e.allow):void 0],[`Denied`,n?av(e.deny):void 0],[`Owns`,av(e.owns)],[`Irreversible`,av(e.irreversible)]]})})}case`human-gate`:return(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(iv,{rows:[...t,[`Asks`,ov(e.prompt)],[`Options`,av(e.options)]]})});case`check`:return(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(iv,{rows:[...t,[`Check`,e.check.kind],[`Runs`,e.check.run?(0,q.jsx)(`span`,{className:`mono`,children:e.check.run}):void 0],[`Passes when`,e.check.pass],[`Threshold`,e.check.threshold===void 0?void 0:String(e.check.threshold)]]})});case`merge`:return(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(iv,{rows:[...t,[`Merges`,av(e.merges)],[`Strategy`,e.strategy]]})});case`stop`:return(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(iv,{rows:[...t,[`Outcome`,e.outcome??`ends the run`]]})})}}function cv({doc:e,loop:t}){let n=t=>e.nodes.find(e=>e.id===t)?.name??t;return(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(iv,{rows:[[`Name`,t.name],[`Mode`,D(xe(e),t)],[`Members`,av(t.members.map(n))],[`Back edges`,av(t.back.map(t=>{let r=e.edges.find(e=>e.id===t);return r?`${n(r.from)} → ${n(r.to)}${r.when&&r.when!==`always`?` (${typeof r.when==`string`?r.when:r.when.verdict})`:``}`:t}))],[`Bar`,t.bar?t.bar.name:`none`],[`Inspects`,av(t.bar?.inspects.map(e=>`${e.kind}: ${e.ref}`))],[`Good enough`,ov(t.bar?.acceptance)],[`Aiming for`,ov(t.bar?.aspiration)],[`Stops, in order`,av(t.stops.map(e=>`${g(e)}${e.then?` → ${n(e.then)}`:``}`))]]})})}function lv({doc:e}){return(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(iv,{rows:[[`Name`,e.name],[`Id`,(0,q.jsx)(`span`,{className:`mono`,children:e.id})],[`Goal`,ov(e.goal)],[`About`,ov(e.description)],[`Budget`,e.constraints?.budget],[`Time`,e.constraints?.time],[`Other limits`,e.constraints?.other],[`Target`,e.target?.harness],[`Adaptation`,e.adaptation??`adaptive (default)`],[`Started from`,e.lineage?.from??e.lineage?.pattern],[`Version`,String(e.version)]]})})}function uv({issues:e,needs:t,whole:n=!0}){return e.length===0?(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)(`p`,{className:`all-clear`,children:t||!n?`No issues. The graph validates.`:`No issues. The graph validates for export.`}),t]}):(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)(`ul`,{className:`issues`,children:e.map((e,t)=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`div`,{className:`issue issue-${e.severity}`,children:[(0,q.jsxs)(`span`,{className:`issue-head`,children:[(0,q.jsx)(`span`,{className:`issue-severity`,children:e.severity}),(0,q.jsx)(`span`,{className:`issue-code mono`,children:e.code})]}),(0,q.jsx)(`span`,{className:`issue-message`,children:e.message})]})},`${e.code}-${t}`))}),t]})}function dv({doc:e,back:t,context:n,issues:r,about:i,bar:a}){let o=(0,K.useMemo)(()=>r??et(e),[e,r]),{errors:s,warnings:c}=Fm(o),[l,u]=(0,K.useState)(i?{type:`about`}:null),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(!1),{saved:h,busy:g,save:_}=p_(),v=h.graph,y=s>0?`status-error`:c>0?`status-warning`:`status-ok`,b=s>0?`${s} error${s===1?``:`s`}`:c>0?`${c} warning${c===1?``:`s`}`:`Valid`,x=e=>u(t=>t&&t.type===e.type&&(!(`id`in t)||t.id===e.id)?null:e),S=p||l?.type===`outline`,C=()=>{S?(m(!1),l?.type===`outline`&&(f(!1),u(null))):vh()?m(!0):(f(!0),u({type:`outline`}))},w=(()=>{if(!l||l.type===`outline`)return null;if(l.type===`node`){let t=e.nodes.find(e=>e.id===l.id);return t?{title:ym(t),subtitle:t.id,body:(0,q.jsx)(sv,{node:t})}:null}if(l.type===`loop`){let t=e.loops.find(e=>e.id===l.id);return t?{title:`Loop`,subtitle:t.id,body:(0,q.jsx)(cv,{doc:e,loop:t})}:null}return l.type===`about`?i??null:l.type===`graph`?{title:`Graph`,subtitle:e.id,body:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(lv,{doc:e}),(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(gg,{doc:e})})]})}:{title:`Validation`,subtitle:`the graph's own findings`,body:(0,q.jsx)(uv,{issues:o,whole:e.template===void 0,needs:e.template===void 0&&ft(e).length>0?(0,q.jsx)(Gg,{doc:e}):void 0})}})();return(0,q.jsxs)(`div`,{className:`editor viewer${w||S?` has-sheet`:``}${d&&(w||l?.type===`outline`)?` sheet-expanded`:``}${S?` has-rail`:``}${w?` has-side`:``}`,children:[(0,q.jsxs)(`header`,{className:`topbar`,children:[(0,q.jsx)(`a`,{className:`icon-btn`,href:t.href,"aria-label":t.label,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M15 5 8 12l7 7`})})}),(0,q.jsxs)(`button`,{type:`button`,className:`title-btn`,onClick:()=>x(i?{type:`about`}:{type:`graph`}),children:[(0,q.jsx)(`span`,{className:`title-name`,children:e.name||e.id}),(0,q.jsxs)(`span`,{className:`title-sub`,children:[n??`from a link`,` · read-only`]})]}),(0,q.jsx)(Ug,{on:S,onClick:C}),(0,q.jsx)(`button`,{type:`button`,className:`status ${y}`,"aria-label":`Validation: ${b}`,onClick:()=>x({type:`issues`}),children:b})]}),S?(0,q.jsx)(qg,{rail:!0,title:`Outline`,subtitle:`the whole graph, to read`,expanded:d,onToggle:()=>f(e=>!e),onClose:C,children:(0,q.jsx)(Hg,{doc:e,current:l&&`id`in l?l.id:void 0})}):null,(0,q.jsxs)(`main`,{className:`stage`,children:[(0,q.jsx)(u_,{doc:e,variant:`full`,issues:o,selected:l?.type===`node`?l.id:void 0,onNodeTap:e=>x({type:`node`,id:e})}),(0,q.jsx)(Wh,{}),e.loops.length>0?(0,q.jsx)(`nav`,{className:`loop-legend`,"aria-label":`Loops`,children:e.loops.map((e,t)=>(0,q.jsxs)(`button`,{type:`button`,className:`loop-pill loop-c${t%4}${l?.type===`loop`&&l.id===e.id?` is-on`:``}`,onClick:()=>x({type:`loop`,id:e.id}),children:[(0,q.jsx)(`span`,{className:`loop-dot loop-c${t%4}`,"aria-hidden":`true`}),e.name||e.id]},e.id))}):null,a??(0,q.jsx)(`div`,{className:`viewer-bar`,role:`region`,"aria-label":`Save`,children:v?(0,q.jsxs)(`p`,{className:`viewer-saved`,role:`status`,children:[v.existed?`Already on this device.`:v.persistent?`Saved to this device.`:`Saved for this visit only; this browser is not keeping data.`,` `,(0,q.jsx)(`a`,{href:m_(v.key),children:`Open it to edit`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`viewer-note`,children:`Read-only. Nothing is stored until you save it.`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:g!==null,onClick:()=>void _(`graph`,e),children:`Save to this device`})]})})]}),w?(0,q.jsx)(qg,{title:w.title,subtitle:w.subtitle,expanded:d,onToggle:()=>f(e=>!e),onClose:()=>u(null),children:w.body}):null]})}var fv={"claude-code":`Claude Code`,codex:`Codex`},pv=`(min-width: 1100px)`,mv=600,hv;function gv(){let[e,t]=(0,K.useState)(()=>matchMedia(pv).matches);return(0,K.useEffect)(()=>{let e=matchMedia(pv),n=()=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var _v=e=>[`handoff`,`plate`,`number`].map(t=>`[data-${t}="${CSS.escape(e)}"]`).join(`,`),vv=e=>`var(--${{gate:`kind-human-gate`,check:`kind-check`,merge:`kind-merge`}[e]??e})`;function yv({rows:e}){return(0,q.jsx)(`dl`,{className:`readonly`,children:e.filter(([,e])=>e!=null&&e!==``).map(([e,t])=>(0,q.jsxs)(`div`,{className:`readonly-row`,children:[(0,q.jsx)(`dt`,{children:e}),(0,q.jsx)(`dd`,{children:t})]},e))})}function bv(e){let t=M(e).byHand;if(t.length!==0)return(0,q.jsx)(`ul`,{className:`map-by-hand`,"data-testid":`map-by-hand`,children:t.map(e=>(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`mono`,children:e.from}),` → `,(0,q.jsx)(`span`,{className:`mono`,children:e.to}),`: moves only when `,e.who===``?`a person`:e.who,` `,e.starts?`does`:`carries`,` it`]},e.handoff))})}function xv({pointer:e}){if(!/^https?:\/\//i.test(e))return(0,q.jsx)(`span`,{className:`mono`,children:e});let t=e.startsWith(`${location.origin}${location.pathname}#`);return(0,q.jsx)(`a`,{className:`mono map-graph-link`,href:e,"data-testid":`map-graph-link`,...t?{}:{target:`_blank`,rel:`noreferrer`},children:`Open its graph`})}function Sv({map:e,issues:t,back:n={href:`#/`,label:`All graphs`}}){let i=gv(),[o,s]=(0,K.useState)(hv);(0,K.useEffect)(()=>{o||r(`views`,()=>a(()=>import(`./views-DCEDX6Qx.js`),__vite__mapDeps([11,1]))).then(e=>s(hv=e),()=>s(null))},[]);let[c,l]=(0,K.useState)(),u=(0,K.useRef)(null),d=!!c?.sequence,f=(0,K.useMemo)(()=>c?.svg??(i&&o!==null?``:Ae(e,i?{width:mv}:{})),[e,i,o,c]),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(!1),_=(0,K.useRef)(null),v=t.filter(e=>e.severity===`error`).length,y=t.length-v,b=v>0?`status-error`:y>0?`status-warning`:`status-ok`,x=v>0?`${v} error${v===1?``:`s`}`:y>0?`${y} warning${y===1?``:`s`}`:`Valid`,S=t=>ze(e,t),C=t=>e.handoffs.findIndex(e=>e.id===t)+1,w=t=>m({type:(e.people??[]).some(e=>e.id===t)?`person`:`session`,id:t}),T=e=>m(t=>t&&t.type===e.type&&(!(`id`in t)||t.id===e.id)?null:e);(0,K.useEffect)(()=>{let t=_.current;if(t){for(let e of t.querySelectorAll(`[data-session]`))e.setAttribute(`tabindex`,`0`),e.setAttribute(`role`,`button`),e.setAttribute(`aria-label`,`Session ${S(e.dataset.session)}`);for(let e of t.querySelectorAll(`[data-person]`))e.setAttribute(`tabindex`,`0`),e.setAttribute(`role`,`button`),e.setAttribute(`aria-label`,`Person ${S(e.dataset.person)}`);for(let n of t.querySelectorAll(`[data-handoff], [data-handoff-row]`)){let t=n.dataset.handoff??n.dataset.handoffRow,r=e.handoffs.find(e=>e.id===t);(d||n.dataset.handoffRow&&!i)&&n.setAttribute(`tabindex`,`0`),n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,r?`Handoff ${C(t)}: ${S(r.from)} to ${S(r.to)}`:`Handoff ${t}`)}}},[f]),(0,K.useLayoutEffect)(()=>{let e=_.current;if(!e)return;let t=i&&!d?e.querySelector(`[data-handoff-row] > rect`):null;e.style.aspectRatio=t?`${e.querySelector(`svg`).viewBox.baseVal.width} / ${t.y.baseVal.value-22}`:``},[f]),(0,K.useEffect)(()=>{let e=_.current;if(!e)return;for(let t of e.querySelectorAll(`.is-on, .is-hot`))t.classList.remove(`is-on`,`is-hot`);if(!p||!(`id`in p))return;let t=CSS.escape(p.id),n=e.querySelectorAll(p.type===`handoff`?`${_v(p.id)}, [data-handoff-row="${t}"]`:`[data-${p.type}="${t}"]`);for(let e of n)e.classList.add(`is-on`);i&&((p.type===`handoff`&&e.querySelector(`[data-number="${t}"]`)||n[0])?.scrollIntoView({block:`nearest`}),document.activeElement===document.body&&document.querySelector(`.map-list [aria-current]`)?.focus({preventScroll:!0}))},[p,f]);let E=e=>{for(let e of _.current?.querySelectorAll(`.is-hot`)??[])e.classList.remove(`is-hot`);if(e)for(let t of _.current?.querySelectorAll(_v(e))??[])t.classList.add(`is-hot`)},D=e=>{if(!(e instanceof Element))return!1;let t=e.closest(`[data-session]`);if(t)return T({type:`session`,id:t.dataset.session}),!0;let n=e.closest(`[data-person]`);if(n)return T({type:`person`,id:n.dataset.person}),!0;let r=e.closest(`[data-handoff], [data-handoff-row], [data-plate], [data-number]`);return r?(T({type:`handoff`,id:r.dataset.handoff??r.dataset.handoffRow??r.dataset.plate??r.dataset.number}),!0):!1},k=t=>(0,q.jsx)(`ul`,{className:`map-handoffs map-list`,onMouseLeave:()=>E(null),onBlur:()=>E(null),children:e.handoffs.map(n=>(0,q.jsx)(Cv,{map:e,handoff:n,current:n.id===t,onOpen:e=>m({type:`handoff`,id:e}),onPoint:E},n.id))}),A=(()=>{if(!p)return null;if(p.type===`session`){let t=e.sessions.find(e=>e.id===p.id);return t?{title:`Session`,subtitle:t.id,body:(0,q.jsx)(Tv,{map:e,session:t,onHandoff:e=>m({type:`handoff`,id:e})})}:null}if(p.type===`person`){let t=(e.people??[]).find(e=>e.id===p.id);return t?{title:`Person`,subtitle:t.id,body:(0,q.jsx)(wv,{map:e,person:t,onHandoff:e=>m({type:`handoff`,id:e})})}:null}if(p.type===`handoff`){let t=e.handoffs.find(e=>e.id===p.id);if(!t)return null;let n=i?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{className:`files-title`,children:`All handoffs`}),k(t.id)]}):null;return{title:`Handoff ${C(t.id)}`,subtitle:t.id,body:(0,q.jsx)(Ev,{map:e,handoff:t,onSession:w,after:n})}}return p.type===`issues`?{title:`Validation`,subtitle:`the map's own rules`,body:t.length===0?(0,q.jsx)(`div`,{className:`inspector`,children:(0,q.jsx)(`p`,{className:`all-clear`,children:`No issues. Every handoff names its carrier.`})}):(0,q.jsx)(uv,{issues:t})}:{title:`Operation map`,subtitle:e.id,body:(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)(yv,{rows:[[`Name`,e.name],[`As of`,e.asOf],[`Shape`,F(M(e))],[`By hand`,bv(e)],[`About`,e.description?(0,q.jsx)(`p`,{className:`prose`,children:e.description}):void 0]]}),(0,q.jsx)(`p`,{className:`field-hint`,children:`A map shows sessions and what passes between them. It is drawn and checked, never run.`}),(0,q.jsx)(`div`,{className:`export-actions`,children:(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>xt(`${e.id}.grooph-map.json`,O(e),`application/json`),children:`Download map (.grooph-map.json)`})}),(0,q.jsx)(gg,{doc:e})]})}})(),j=i&&!A&&e.handoffs.length>0;return(0,q.jsxs)(`div`,{className:`editor viewer map-view${A?` has-sheet`:``}${h&&A?` sheet-expanded`:``}${i?` is-wide`:``}${j?` has-side`:``}`,children:[(0,q.jsxs)(`header`,{className:`topbar`,children:[(0,q.jsx)(`a`,{className:`icon-btn`,href:n.href,"aria-label":n.label,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M15 5 8 12l7 7`})})}),(0,q.jsxs)(`button`,{type:`button`,className:`title-btn`,onClick:()=>T({type:`about`}),children:[(0,q.jsx)(`span`,{className:`title-name`,children:e.name||e.id}),(0,q.jsxs)(`span`,{className:`title-sub`,children:[`operation map · read-only`,e.asOf?` · as of ${e.asOf}`:``]})]}),(0,q.jsx)(`button`,{type:`button`,className:`status ${b}`,"aria-label":`Validation: ${x}`,onClick:()=>T({type:`issues`}),children:x})]}),(0,q.jsxs)(`main`,{ref:u,className:`stage map-stage`,children:[(0,q.jsx)(`div`,{style:{minHeight:68},children:o?(0,q.jsx)(o.Views,{map:e,kit:he,wide:i,stage:u,onDrawn:l}):null}),(0,q.jsx)(`div`,{ref:_,className:`map-picture${d?` is-sequence`:``}`,hidden:f===``,style:c?.style,onClick:e=>{D(e.target)||m(null)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&D(e.target)&&e.preventDefault()},dangerouslySetInnerHTML:{__html:f}})]}),A?(0,q.jsx)(qg,{title:A.title,subtitle:A.subtitle,expanded:h,onToggle:()=>g(e=>!e),onClose:()=>m(null),children:A.body}):j?(0,q.jsxs)(`aside`,{className:`map-side`,"aria-label":`Handoffs`,children:[(0,q.jsxs)(`div`,{className:`map-side-head`,children:[(0,q.jsx)(`h2`,{children:`Handoffs`}),(0,q.jsxs)(`p`,{children:[e.handoffs.length,` on this map, numbered as on the picture. Pick one, or a session, for what the map says about it.`]})]}),k()]}):null]})}function Cv({map:e,handoff:t,onOpen:n,onPoint:r,current:i}){let a=t=>ze(e,t),o=e.handoffs.findIndex(e=>e.id===t.id)+1,s=re[t.carrier?.kind??`none`],l=r&&(()=>r(t.id));return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,className:`map-handoff-line`,"aria-current":i||void 0,onClick:()=>n(t.id),onMouseEnter:l,onFocus:l,children:[(0,q.jsx)(`span`,{className:`map-handoff-n`,style:{borderColor:vv(s.color)},children:o}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`strong`,{children:t.from===t.to?`${a(t.from)} → itself`:`${a(t.from)} → ${a(t.to)}`}),(0,q.jsx)(`br`,{}),(0,q.jsx)(`svg`,{className:`map-carrier`,viewBox:`0 0 22 8`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M2 4h18`,strokeWidth:s.width,strokeDasharray:s.dash,style:{stroke:vv(s.color)}})}),c(e,t)||`no carrier named`]})]})})}function wv({map:e,person:t,onHandoff:n}){let{out:r,in:i}=N(e,t.id);return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)(yv,{rows:[[`Name`,t.name],[`Role`,t.role?(0,q.jsx)(`p`,{className:`prose`,children:t.role}):void 0],[`About`,t.description?(0,q.jsx)(`p`,{className:`prose`,children:t.description}):void 0]]}),(0,q.jsx)(`p`,{className:`field-hint`,children:`A person is not a session: on no machine, under no account, never run. What starts with them moves only when they do it.`}),(0,q.jsx)(`h3`,{className:`files-title`,children:`Hands work to`}),r.length===0?(0,q.jsx)(`p`,{className:`field-hint`,children:`Nothing starts with this person on the map.`}):null,(0,q.jsx)(`ul`,{className:`map-handoffs`,children:r.map(t=>(0,q.jsx)(Cv,{map:e,handoff:t,onOpen:n},t.id))}),(0,q.jsx)(`h3`,{className:`files-title`,children:`Is handed work by`}),i.length===0?(0,q.jsx)(`p`,{className:`field-hint`,children:`Nothing on the map reaches this person.`}):null,(0,q.jsx)(`ul`,{className:`map-handoffs`,children:i.map(t=>(0,q.jsx)(Cv,{map:e,handoff:t,onOpen:n},t.id))})]})}function Tv({map:e,session:t,onHandoff:n}){let r=e.lanes.find(e=>e.id===t.lane),i=y(e,t.id),{out:a,in:o}=N(e,t.id);return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)(yv,{rows:[[`Name`,t.name],[`Role`,(0,q.jsx)(`p`,{className:`prose`,children:t.role})],[`Harness`,fv[t.harness]??t.harness],[`Model`,t.model],[`How many`,t.count&&t.count>1?`${t.count} like sessions, drawn as one`:void 0],[`Lifetime`,t.lifetime===`per-task`?`per task`:t.lifetime],[`Wakes itself`,i===void 0?void 0:i===``?`on a schedule`:i],[`Lane`,r?`${r.name} (${r.machine}, ${r.account})`:(0,q.jsx)(`span`,{className:`mono`,children:t.lane})],[`Repository`,t.repo],[`Its graph`,t.graph?(0,q.jsx)(xv,{pointer:t.graph}):void 0],[`About`,t.description?(0,q.jsx)(`p`,{className:`prose`,children:t.description}):void 0]]}),(0,q.jsx)(`h3`,{className:`files-title`,children:`Hands work to`}),a.length===0?(0,q.jsx)(`p`,{className:`field-hint`,children:`Nothing leaves this session by a named carrier.`}):null,(0,q.jsx)(`ul`,{className:`map-handoffs`,children:a.map(t=>(0,q.jsx)(Cv,{map:e,handoff:t,onOpen:n},t.id))}),(0,q.jsx)(`h3`,{className:`files-title`,children:`Is handed work by`}),o.length===0?(0,q.jsx)(`p`,{className:`field-hint`,children:`Nothing reaches this session by a named carrier.`}):null,(0,q.jsx)(`ul`,{className:`map-handoffs`,children:o.map(t=>(0,q.jsx)(Cv,{map:e,handoff:t,onOpen:n},t.id))})]})}function Ev({map:e,handoff:t,onSession:n,after:r}){let i=t=>{let r=e.sessions.find(e=>e.id===t)??(e.people??[]).find(e=>e.id===t);return r?(0,q.jsx)(`button`,{type:`button`,className:`chip chip-small`,onClick:()=>n(t),children:r.name||r.id}):(0,q.jsxs)(`span`,{className:`mono`,children:[t,` (unknown)`]})},a=t.carrier;return(0,q.jsxs)(`div`,{className:`inspector`,children:[(0,q.jsx)(yv,{rows:[[`From`,i(t.from)],[`To`,i(t.to)],[`Carried by`,a?c(e,t)||`${b[a.kind]} (not named)`:`no carrier named`],[`Carrier kind`,a?b[a.kind]:void 0],[`What`,t.what?(0,q.jsx)(`p`,{className:`prose`,children:t.what}):void 0],[`Label`,t.label]]}),r]})}function Dv({payload:e,candidate:t}){let n=(0,K.useMemo)(()=>De(e),[e]);if(!n.ok)return(0,q.jsx)(Ov,{message:n.message,details:n.details});let{envelope:r}=n;if(r.kind===`graph`)return(0,q.jsx)(dv,{doc:r.doc,back:{href:`#/`,label:`All graphs`}});if(r.kind===`run`)return(0,q.jsx)(O_,{bundle:r.doc,origin:{kind:`link`}});if(r.kind===`map`)return(0,q.jsx)(Sv,{map:r.doc,issues:n.issues});let i=r.doc;if(t!==void 0){let n=i.candidates.find(e=>e.id===t);if(n&&`grooph`in n.graph)return(0,q.jsx)(dv,{doc:n.graph,back:{href:`#/open?d=${e}`,label:`Back to the comparison`},context:`${n.label} · from ${i.title}`},n.id)}return(0,q.jsx)(tv,{set:i,setIssues:n.issues,payload:e})}function Ov({message:e,details:t}){return(0,q.jsxs)(`main`,{className:`link-problem`,role:`alert`,children:[(0,q.jsx)(`h1`,{children:`This link could not be opened`}),(0,q.jsx)(`p`,{children:e}),t.length>0?(0,q.jsxs)(`details`,{className:`more`,children:[(0,q.jsx)(`summary`,{children:`What is wrong with it`}),(0,q.jsx)(`pre`,{className:`issue-lines`,children:t.join(`
|
|
16
|
-
`)})]}):null,(0,q.jsx)(`p`,{className:`muted`,children:`Nothing from it was stored on this device.`}),(0,q.jsx)(`a`,{className:`btn btn-primary btn-large`,href:`#/`,children:`Back to your graphs`})]})}function kv(e,t){let[n,r]=(0,K.useState)(()=>e===`built-in`?Ve(t)??null:void 0);return(0,K.useEffect)(()=>{if(e===`built-in`)return;let n=!0;return e===`plan`?Xe().then(e=>n&&r(e.find(e=>e.id===t)??null),()=>n&&r(`unfetched`)):wt(t).then(e=>n&&r(e??null)),()=>{n=!1}},[e,t]),n}function Av({unfetched:e}){return(0,q.jsxs)(`div`,{className:`notfound`,children:[(0,q.jsx)(`p`,{children:e?`The plans could not be fetched. They need a connection the first time.`:`This template is not on this device.`}),(0,q.jsx)(`a`,{className:`btn btn-primary`,href:`#/templates`,children:`Back to templates`})]})}function jv({source:e,id:t}){let n=kv(e,t);return n===void 0?(0,q.jsx)(`div`,{className:`loading`,children:`Opening…`}):n===null||n===`unfetched`?(0,q.jsx)(Av,{unfetched:n===`unfetched`}):(0,q.jsx)(Mv,{source:e,doc:n},`${e}/${t}`)}function Mv({source:e,doc:t}){let n=t.template,r=(0,K.useMemo)(()=>ke(t),[t]),i=n.kind===`fragment`,a=(0,q.jsx)(`div`,{className:`viewer-bar`,role:`region`,"aria-label":`Use`,children:i?(0,q.jsx)(`span`,{className:`viewer-note`,children:`A fragment: open a graph, then Add → Insert a template.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`viewer-note`,children:`Read-only. Use it to make a graph of your own.`}),(0,q.jsx)(`a`,{className:`btn btn-primary`,href:St(e,t.id,!0),children:`Use`})]})});return(0,q.jsx)(dv,{doc:t,back:{href:`#/templates`,label:`All templates`},context:e===`plan`?`plan template`:`${e===`yours`?`your`:`built-in`} ${i?`fragment`:`template`}`,issues:r,about:{title:n.title,subtitle:`${t.id}@${t.version}`,body:(0,q.jsx)(Nv,{source:e,doc:t})},bar:a})}function Nv({source:e,doc:t}){let n=t.template,r=Ue(t),[i,a]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`inspector template-details`,children:[(0,q.jsx)(Pv,{doc:t}),e===`plan`?(0,q.jsx)(`p`,{className:`field-hint`,children:Ye}):null,(0,q.jsx)(`p`,{className:`prose`,children:n.summary}),n.kind===`graph`?(0,q.jsx)(`a`,{className:`btn btn-primary template-use`,href:St(e,t.id,!0),children:`Use this template`}):(0,q.jsx)(`p`,{className:`field-hint`,children:`A fragment: open a graph, then Add → Insert a template.`}),e===`plan`?null:(0,q.jsx)($_,{profile:n.profile}),(0,q.jsx)(Q_,{credits:n.credits}),(0,q.jsxs)(`dl`,{className:`readonly`,children:[(0,q.jsxs)(`div`,{className:`readonly-row`,children:[(0,q.jsx)(`dt`,{children:`Use when`}),(0,q.jsx)(`dd`,{children:n.whenToUse})]}),n.notFor?(0,q.jsxs)(`div`,{className:`readonly-row`,children:[(0,q.jsx)(`dt`,{children:`Not for`}),(0,q.jsx)(`dd`,{children:n.notFor})]}):null,n.tags&&n.tags.length>0?(0,q.jsxs)(`div`,{className:`readonly-row`,children:[(0,q.jsx)(`dt`,{children:`Tags`}),(0,q.jsx)(`dd`,{children:n.tags.join(`, `)})]}):null]}),(0,q.jsx)(`h3`,{className:`files-title`,children:r.length===0?`No slots`:`${r.length} slot${r.length===1?``:`s`}`}),r.length>0?(0,q.jsx)(`ul`,{className:`slot-list`,"aria-label":`Slots`,children:r.map(e=>(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`span`,{className:`slot-ask`,children:e.ask}),(0,q.jsx)(`span`,{className:`mono slot-key`,children:`{{${e.key}}}`}),e.example?(0,q.jsxs)(`span`,{className:`slot-example`,children:[`e.g. `,e.example]}):null]},e.key))}):(0,q.jsx)(`p`,{className:`field-hint`,children:`It asks nothing: use it as it is.`}),e===`yours`?(0,q.jsxs)(`div`,{className:`export-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>xt(Tt(t),Et(t),`application/json`),children:`Download template (.grooph.json)`}),i?(0,q.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:async()=>{await Pt(t.id),location.hash=`#/templates`},children:`Delete for good`}):(0,q.jsx)(`button`,{type:`button`,className:`btn btn-danger-text`,onClick:()=>a(!0),children:`Delete template`}),(0,q.jsxs)(`p`,{className:`field-hint`,children:[`The same file a registry holds: put it in `,(0,q.jsx)(`span`,{className:`mono`,children:`.grooph/templates/`}),`, or host it and run`,` `,(0,q.jsx)(`span`,{className:`mono`,children:`grooph template add <url>`}),`.`]})]}):null]})}function Pv({doc:e}){let[t,n]=(0,K.useState)(null);return(0,q.jsxs)(`div`,{className:`glyph-card`,children:[(0,q.jsx)(Mt,{doc:e,className:`glyph-large`}),(0,q.jsxs)(`div`,{className:`glyph-actions`,children:[(0,q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:()=>xt(`${e.id}.svg`,`${ee(e)}\n`,`image/svg+xml`),children:`Save glyph`}),(0,q.jsx)(`button`,{type:`button`,className:`btn btn-small`,onClick:async()=>n(await Dt(Le(e))?`Mermaid copied. It is a one-way picture: edit the document, not the text.`:`Could not copy; the Mermaid text is what grooph mermaid prints.`),children:`Copy Mermaid`})]}),t?(0,q.jsx)(`p`,{className:`field-hint glyph-note`,role:`status`,children:t}):null]})}function Fv({source:e,id:t}){let n=kv(e,t);return n===`unfetched`?(0,q.jsx)(Av,{unfetched:!0}):n===void 0?(0,q.jsx)(`div`,{className:`loading`,children:`Opening…`}):n===null?(0,q.jsx)(Av,{}):(0,q.jsx)(Iv,{source:e,template:n})}function Iv({source:e,template:t}){let n=t.template,r=Ue(t),[i,a]=(0,K.useState)(n.title),[o,s]=(0,K.useState)({}),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(!1),f=r.filter(e=>(o[e.key]??``).trim()===``).length,p=async()=>{d(!0);try{let e=i.trim()||n.title,r=new Set((await st()).map(e=>e.doc.id)),a=U(t,{name:e,values:Je(o),id:He(e,t,r)}),s=await gt(a);location.hash=`#/g/${encodeURIComponent(s.key)}`}catch(e){l(e instanceof ye?e.message:`Could not create the graph: ${e instanceof Error?e.message:String(e)}`),d(!1)}};return(0,q.jsxs)(`div`,{className:`library use-template`,children:[(0,q.jsxs)(`header`,{className:`screen-head`,children:[(0,q.jsx)(`a`,{className:`icon-btn`,href:St(e,t.id),"aria-label":`Back to ${n.title}`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,q.jsx)(`path`,{d:`M15 5 8 12l7 7`})})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`overline`,children:`Use a template`}),(0,q.jsx)(`h1`,{children:n.title})]})]}),(0,q.jsxs)(`form`,{className:`use-form`,onSubmit:e=>{e.preventDefault(),u||p()},children:[(0,q.jsx)($,{label:`Graph name`,value:i,onChange:a,hint:`The graph's id follows it.`}),r.length>0?(0,q.jsxs)(`fieldset`,{className:`slots`,children:[(0,q.jsx)(`legend`,{className:`list-title`,children:`What it needs to know`}),(0,q.jsx)(`p`,{className:`field-hint`,children:`Any of these can wait: an empty one stays marked in the graph, and a package waits until it is filled.`}),r.map(e=>(0,q.jsx)(tg,{label:e.ask,value:o[e.key]??``,rows:2,placeholder:e.example,hint:(0,q.jsx)(`span`,{className:`mono`,children:`{{${e.key}}}`}),onChange:t=>s(n=>({...n,[e.key]:t}))},e.key))]}):(0,q.jsx)(`p`,{className:`field-hint`,children:`This template asks nothing more.`}),c?(0,q.jsx)(`p`,{className:`refusal`,role:`alert`,children:c}):null,(0,q.jsxs)(`div`,{className:`use-actions`,children:[(0,q.jsx)(`button`,{type:`submit`,className:`btn btn-primary btn-large`,disabled:u,children:`Create graph`}),(0,q.jsx)(`p`,{className:`field-hint`,role:`status`,children:f===0?`Every slot is filled.`:`${f} slot${f===1?``:`s`} left empty, to fill in the editor.`})]})]})]})}export{e_ as EditorScreen,M_ as LiveRun,X_ as LiveSessions,Dv as OpenScreen,N_ as StoredRun,jv as TemplateView,Fv as UseTemplate};
|