spexcode 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/spec-cli/src/claude-headless.ts +105 -16
- package/spec-cli/src/cli.ts +13 -2
- package/spec-cli/src/harness.ts +21 -1
- package/spec-cli/src/host.ts +1 -0
- package/spec-cli/src/opencode-headless.ts +119 -5
- package/spec-cli/src/opencode.ts +8 -4
- package/spec-cli/src/pi-headless.ts +1 -0
- package/spec-cli/src/pty-bridge.ts +31 -4
- package/spec-cli/src/pty-helper.mjs +16 -6
- package/spec-cli/src/pty-native-helper.mjs +22 -0
- package/spec-cli/src/session-timeline.ts +23 -17
- package/spec-cli/src/sessions.ts +25 -4
- package/spec-dashboard/dist/assets/{Dashboard-C_w_wdk5.js → Dashboard-CTAuTyZ3.js} +3 -3
- package/spec-dashboard/dist/assets/{EvalsPage-5_nfIYll.js → EvalsPage-KbMMownG.js} +2 -2
- package/spec-dashboard/dist/assets/{IssuesPage-By-u--95.js → IssuesPage-DmyLb9Rj.js} +1 -1
- package/spec-dashboard/dist/assets/{MobileApp-CVEwjHr9.js → MobileApp-D2RZGt4Z.js} +2 -2
- package/spec-dashboard/dist/assets/{Modal-BqgvzMJD.js → Modal-3brXUhM0.js} +1 -1
- package/spec-dashboard/dist/assets/{PageScroll-B_dKCuXx.js → PageScroll-CadAKuSy.js} +1 -1
- package/spec-dashboard/dist/assets/ProjectsPage-DU3x4Y8l.js +1 -0
- package/spec-dashboard/dist/assets/{SessionInterface-Bh3vq8SU.js → SessionInterface-BtrzlOPs.js} +1 -1
- package/spec-dashboard/dist/assets/{SessionWindow-BuJ5mzjC.js → SessionWindow-BWH5O0jh.js} +1 -1
- package/spec-dashboard/dist/assets/{Settings-B8KFocsz.js → Settings-COgdKTJB.js} +1 -1
- package/spec-dashboard/dist/assets/{TimelineChat-K0wdlweB.js → TimelineChat-DQ21GSJK.js} +1 -1
- package/spec-dashboard/dist/assets/{index-BKaTHjmU.js → index-D6HBvKkJ.js} +2 -2
- package/spec-dashboard/dist/assets/{index-DcnCaBAC.css → index-DFdlYy4H.css} +1 -1
- package/spec-dashboard/dist/index.html +2 -2
- package/spec-dashboard/dist/assets/ProjectsPage-RVP8AqK4.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionInterface-
|
|
2
|
-
import{r as b,g as Ja,R as ec,j as p,u as Xe,I as Sn,a as tc,P as wn,b as rr,p as nc,h as rc,c as oc,l as sc,_ as Rn,X as ic,Y as ac}from"./index-BKaTHjmU.js";import{S as ot,G as Ss,a as cc,l as vr,A as lc,u as uc,s as Lr,b as dc,c as br,d as uo,T as fc,g as hc,i as gc,E as pc,e as fo,f as mc,h as yc,j as xc,P as wc,r as vc,k as bc,n as ke,m as _c,p as Ec,o as Nc,L as Sc,N as kc}from"./SessionWindow-BuJ5mzjC.js";import{i as ks,M as Mc,r as Cc}from"./Modal-BqgvzMJD.js";import{A as Ac,k as Ms,a as _r,f as fe}from"./bindings-BC9vqpYU.js";function he(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=he(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var $c={value:()=>{}};function Ln(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new vn(n)}function vn(e){this._=e}function Ic(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}vn.prototype=Ln.prototype={constructor:vn,on:function(e,t){var n=this._,r=Ic(e+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(e=r[s]).type)&&(o=jc(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<i;)if(o=(e=r[s]).type)n[o]=ho(n[o],e.name,t);else if(t==null)for(o in n)n[o]=ho(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new vn(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,s;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,o=s.length;r<o;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,s=r.length;o<s;++o)r[o].value.apply(t,n)}};function jc(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function ho(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=$c,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Er="http://www.w3.org/1999/xhtml";const go={svg:"http://www.w3.org/2000/svg",xhtml:Er,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function zn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),go.hasOwnProperty(t)?{space:go[t],local:e}:e}function Pc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Er&&t.documentElement.namespaceURI===Er?t.createElement(e):t.createElementNS(n,e)}}function Dc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Cs(e){var t=zn(e);return(t.local?Dc:Pc)(t)}function Tc(){}function zr(e){return e==null?Tc:function(){return this.querySelector(e)}}function Rc(e){typeof e!="function"&&(e=zr(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=new Array(i),c,l,d=0;d<i;++d)(c=s[d])&&(l=e.call(c,c.__data__,d,s))&&("__data__"in c&&(l.__data__=c.__data__),a[d]=l);return new Ne(r,this._parents)}function Lc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function zc(){return[]}function As(e){return e==null?zc:function(){return this.querySelectorAll(e)}}function Hc(e){return function(){return Lc(e.apply(this,arguments))}}function Oc(e){typeof e=="function"?e=Hc(e):e=As(e);for(var t=this._groups,n=t.length,r=[],o=[],s=0;s<n;++s)for(var i=t[s],a=i.length,c,l=0;l<a;++l)(c=i[l])&&(r.push(e.call(c,c.__data__,l,i)),o.push(c));return new Ne(r,o)}function $s(e){return function(){return this.matches(e)}}function Is(e){return function(t){return t.matches(e)}}var Vc=Array.prototype.find;function Bc(e){return function(){return Vc.call(this.children,e)}}function Fc(){return this.firstElementChild}function Wc(e){return this.select(e==null?Fc:Bc(typeof e=="function"?e:Is(e)))}var Yc=Array.prototype.filter;function Xc(){return Array.from(this.children)}function Kc(e){return function(){return Yc.call(this.children,e)}}function qc(e){return this.selectAll(e==null?Xc:Kc(typeof e=="function"?e:Is(e)))}function Gc(e){typeof e!="function"&&(e=$s(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=[],c,l=0;l<i;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new Ne(r,this._parents)}function js(e){return new Array(e.length)}function Uc(){return new Ne(this._enter||this._groups.map(js),this._parents)}function kn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}kn.prototype={constructor:kn,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 Zc(e){return function(){return e}}function Qc(e,t,n,r,o,s){for(var i=0,a,c=t.length,l=s.length;i<l;++i)(a=t[i])?(a.__data__=s[i],r[i]=a):n[i]=new kn(e,s[i]);for(;i<c;++i)(a=t[i])&&(o[i]=a)}function Jc(e,t,n,r,o,s,i){var a,c,l=new Map,d=t.length,u=s.length,f=new Array(d),h;for(a=0;a<d;++a)(c=t[a])&&(f[a]=h=i.call(c,c.__data__,a,t)+"",l.has(h)?o[a]=c:l.set(h,c));for(a=0;a<u;++a)h=i.call(e,s[a],a,s)+"",(c=l.get(h))?(r[a]=c,c.__data__=s[a],l.delete(h)):n[a]=new kn(e,s[a]);for(a=0;a<d;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function el(e){return e.__data__}function tl(e,t){if(!arguments.length)return Array.from(this,el);var n=t?Jc:Qc,r=this._parents,o=this._groups;typeof e!="function"&&(e=Zc(e));for(var s=o.length,i=new Array(s),a=new Array(s),c=new Array(s),l=0;l<s;++l){var d=r[l],u=o[l],f=u.length,h=nl(e.call(d,d&&d.__data__,l,r)),g=h.length,w=a[l]=new Array(g),x=i[l]=new Array(g),y=c[l]=new Array(f);n(d,u,w,x,y,h,t);for(var E=0,m=0,v,N;E<g;++E)if(v=w[E]){for(E>=m&&(m=E+1);!(N=x[m])&&++m<g;);v._next=N||null}}return i=new Ne(i,r),i._enter=a,i._exit=c,i}function nl(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rl(){return new Ne(this._exit||this._groups.map(js),this._parents)}function ol(e,t,n){var r=this.enter(),o=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?s.remove():n(s),r&&o?r.merge(o).order():o}function sl(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,s=r.length,i=Math.min(o,s),a=new Array(o),c=0;c<i;++c)for(var l=n[c],d=r[c],u=l.length,f=a[c]=new Array(u),h,g=0;g<u;++g)(h=l[g]||d[g])&&(f[g]=h);for(;c<o;++c)a[c]=n[c];return new Ne(a,this._parents)}function il(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,s=r[o],i;--o>=0;)(i=r[o])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function al(e){e||(e=cl);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,r=n.length,o=new Array(r),s=0;s<r;++s){for(var i=n[s],a=i.length,c=o[s]=new Array(a),l,d=0;d<a;++d)(l=i[d])&&(c[d]=l);c.sort(t)}return new Ne(o,this._parents).order()}function cl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ll(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ul(){return Array.from(this)}function dl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length;o<s;++o){var i=r[o];if(i)return i}return null}function fl(){let e=0;for(const t of this)++e;return e}function hl(){return!this.node()}function gl(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],s=0,i=o.length,a;s<i;++s)(a=o[s])&&e.call(a,a.__data__,s,o);return this}function pl(e){return function(){this.removeAttribute(e)}}function ml(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yl(e,t){return function(){this.setAttribute(e,t)}}function xl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function wl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function vl(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 bl(e,t){var n=zn(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?ml:pl:typeof t=="function"?n.local?vl:wl:n.local?xl:yl)(n,t))}function Ps(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function _l(e){return function(){this.style.removeProperty(e)}}function El(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Nl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Sl(e,t,n){return arguments.length>1?this.each((t==null?_l:typeof t=="function"?Nl:El)(e,t,n??"")):xt(this.node(),e)}function xt(e,t){return e.style.getPropertyValue(t)||Ps(e).getComputedStyle(e,null).getPropertyValue(t)}function kl(e){return function(){delete this[e]}}function Ml(e,t){return function(){this[e]=t}}function Cl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Al(e,t){return arguments.length>1?this.each((t==null?kl:typeof t=="function"?Cl:Ml)(e,t)):this.node()[e]}function Ds(e){return e.trim().split(/^|\s+/)}function Hr(e){return e.classList||new Ts(e)}function Ts(e){this._node=e,this._names=Ds(e.getAttribute("class")||"")}Ts.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Rs(e,t){for(var n=Hr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Ls(e,t){for(var n=Hr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function $l(e){return function(){Rs(this,e)}}function Il(e){return function(){Ls(this,e)}}function jl(e,t){return function(){(t.apply(this,arguments)?Rs:Ls)(this,e)}}function Pl(e,t){var n=Ds(e+"");if(arguments.length<2){for(var r=Hr(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?jl:t?$l:Il)(n,t))}function Dl(){this.textContent=""}function Tl(e){return function(){this.textContent=e}}function Rl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Ll(e){return arguments.length?this.each(e==null?Dl:(typeof e=="function"?Rl:Tl)(e)):this.node().textContent}function zl(){this.innerHTML=""}function Hl(e){return function(){this.innerHTML=e}}function Ol(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Vl(e){return arguments.length?this.each(e==null?zl:(typeof e=="function"?Ol:Hl)(e)):this.node().innerHTML}function Bl(){this.nextSibling&&this.parentNode.appendChild(this)}function Fl(){return this.each(Bl)}function Wl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Yl(){return this.each(Wl)}function Xl(e){var t=typeof e=="function"?e:Cs(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Kl(){return null}function ql(e,t){var n=typeof e=="function"?e:Cs(e),r=t==null?Kl:typeof t=="function"?t:zr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Gl(){var e=this.parentNode;e&&e.removeChild(this)}function Ul(){return this.each(Gl)}function Zl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ql(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Jl(e){return this.select(e?Ql:Zl)}function eu(e){return arguments.length?this.property("__data__",e):this.node().__data__}function tu(e){return function(t){e.call(this,t,this.__data__)}}function nu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function ru(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,s;n<o;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function ou(e,t,n){return function(){var r=this.__on,o,s=tu(t);if(r){for(var i=0,a=r.length;i<a;++i)if((o=r[i]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=s,o.options=n),o.value=t;return}}this.addEventListener(e.type,s,n),o={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(o):this.__on=[o]}}function su(e,t,n){var r=nu(e+""),o,s=r.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,d;c<l;++c)for(o=0,d=a[c];o<s;++o)if((i=r[o]).type===d.type&&i.name===d.name)return d.value}return}for(a=t?ou:ru,o=0;o<s;++o)this.each(a(r[o],t,n));return this}function zs(e,t,n){var r=Ps(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function iu(e,t){return function(){return zs(this,e,t)}}function au(e,t){return function(){return zs(this,e,t.apply(this,arguments))}}function cu(e,t){return this.each((typeof t=="function"?au:iu)(e,t))}function*lu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length,i;o<s;++o)(i=r[o])&&(yield i)}var Hs=[null];function Ne(e,t){this._groups=e,this._parents=t}function qt(){return new Ne([[document.documentElement]],Hs)}function uu(){return this}Ne.prototype=qt.prototype={constructor:Ne,select:Rc,selectAll:Oc,selectChild:Wc,selectChildren:qc,filter:Gc,data:tl,enter:Uc,exit:rl,join:ol,merge:sl,selection:uu,order:il,sort:al,call:ll,nodes:ul,node:dl,size:fl,empty:hl,each:gl,attr:bl,style:Sl,property:Al,classed:Pl,text:Ll,html:Vl,raise:Fl,lower:Yl,append:Xl,insert:ql,remove:Ul,clone:Jl,datum:eu,on:su,dispatch:cu,[Symbol.iterator]:lu};function Ee(e){return typeof e=="string"?new Ne([[document.querySelector(e)]],[document.documentElement]):new Ne([[e]],Hs)}function du(e){let t;for(;t=e.sourceEvent;)e=t;return e}function je(e,t){if(e=du(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 o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const fu={passive:!1},zt={capture:!0,passive:!1};function or(e){e.stopImmediatePropagation()}function mt(e){e.preventDefault(),e.stopImmediatePropagation()}function Os(e){var t=e.document.documentElement,n=Ee(e).on("dragstart.drag",mt,zt);"onselectstart"in t?n.on("selectstart.drag",mt,zt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Vs(e,t){var n=e.document.documentElement,r=Ee(e).on("dragstart.drag",null);t&&(r.on("click.drag",mt,zt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const cn=e=>()=>e;function Nr(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:s,x:i,y:a,dx:c,dy:l,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:d}})}Nr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function hu(e){return!e.ctrlKey&&!e.button}function gu(){return this.parentNode}function pu(e,t){return t??{x:e.x,y:e.y}}function mu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bs(){var e=hu,t=gu,n=pu,r=mu,o={},s=Ln("start","drag","end"),i=0,a,c,l,d,u=0;function f(v){v.on("mousedown.drag",h).filter(r).on("touchstart.drag",x).on("touchmove.drag",y,fu).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,N){if(!(d||!e.call(this,v,N))){var C=m(this,t.call(this,v,N),v,N,"mouse");C&&(Ee(v.view).on("mousemove.drag",g,zt).on("mouseup.drag",w,zt),Os(v.view),or(v),l=!1,a=v.clientX,c=v.clientY,C("start",v))}}function g(v){if(mt(v),!l){var N=v.clientX-a,C=v.clientY-c;l=N*N+C*C>u}o.mouse("drag",v)}function w(v){Ee(v.view).on("mousemove.drag mouseup.drag",null),Vs(v.view,l),mt(v),o.mouse("end",v)}function x(v,N){if(e.call(this,v,N)){var C=v.changedTouches,I=t.call(this,v,N),D=C.length,T,W;for(T=0;T<D;++T)(W=m(this,I,v,N,C[T].identifier,C[T]))&&(or(v),W("start",v,C[T]))}}function y(v){var N=v.changedTouches,C=N.length,I,D;for(I=0;I<C;++I)(D=o[N[I].identifier])&&(mt(v),D("drag",v,N[I]))}function E(v){var N=v.changedTouches,C=N.length,I,D;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),I=0;I<C;++I)(D=o[N[I].identifier])&&(or(v),D("end",v,N[I]))}function m(v,N,C,I,D,T){var W=s.copy(),M=je(T||C,N),k,L,_;if((_=n.call(v,new Nr("beforestart",{sourceEvent:C,target:f,identifier:D,active:i,x:M[0],y:M[1],dx:0,dy:0,dispatch:W}),I))!=null)return k=_.x-M[0]||0,L=_.y-M[1]||0,function $(S,P,R){var A=M,V;switch(S){case"start":o[D]=$,V=i++;break;case"end":delete o[D],--i;case"drag":M=je(R||P,N),V=i;break}W.call(S,v,new Nr(S,{sourceEvent:P,subject:_,target:f,identifier:D,active:V,x:M[0]+k,y:M[1]+L,dx:M[0]-A[0],dy:M[1]-A[1],dispatch:W}),I)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:cn(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:cn(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:cn(v),f):n},f.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:cn(!!v),f):r},f.on=function(){var v=s.on.apply(s,arguments);return v===s?f:v},f.clickDistance=function(v){return arguments.length?(u=(v=+v)*v,f):Math.sqrt(u)},f}function Or(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Fs(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Gt(){}var Ht=.7,Mn=1/Ht,yt="\\s*([+-]?\\d+)\\s*",Ot="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Oe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",yu=/^#([0-9a-f]{3,8})$/,xu=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),wu=new RegExp(`^rgb\\(${Oe},${Oe},${Oe}\\)$`),vu=new RegExp(`^rgba\\(${yt},${yt},${yt},${Ot}\\)$`),bu=new RegExp(`^rgba\\(${Oe},${Oe},${Oe},${Ot}\\)$`),_u=new RegExp(`^hsl\\(${Ot},${Oe},${Oe}\\)$`),Eu=new RegExp(`^hsla\\(${Ot},${Oe},${Oe},${Ot}\\)$`),po={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};Or(Gt,st,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:mo,formatHex:mo,formatHex8:Nu,formatHsl:Su,formatRgb:yo,toString:yo});function mo(){return this.rgb().formatHex()}function Nu(){return this.rgb().formatHex8()}function Su(){return Ws(this).formatHsl()}function yo(){return this.rgb().formatRgb()}function st(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=yu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?xo(t):n===3?new we(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ln(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ln(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=xu.exec(e))?new we(t[1],t[2],t[3],1):(t=wu.exec(e))?new we(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vu.exec(e))?ln(t[1],t[2],t[3],t[4]):(t=bu.exec(e))?ln(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=_u.exec(e))?bo(t[1],t[2]/100,t[3]/100,1):(t=Eu.exec(e))?bo(t[1],t[2]/100,t[3]/100,t[4]):po.hasOwnProperty(e)?xo(po[e]):e==="transparent"?new we(NaN,NaN,NaN,0):null}function xo(e){return new we(e>>16&255,e>>8&255,e&255,1)}function ln(e,t,n,r){return r<=0&&(e=t=n=NaN),new we(e,t,n,r)}function ku(e){return e instanceof Gt||(e=st(e)),e?(e=e.rgb(),new we(e.r,e.g,e.b,e.opacity)):new we}function Sr(e,t,n,r){return arguments.length===1?ku(e):new we(e,t,n,r??1)}function we(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Or(we,Sr,Fs(Gt,{brighter(e){return e=e==null?Mn:Math.pow(Mn,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new we(nt(this.r),nt(this.g),nt(this.b),Cn(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:wo,formatHex:wo,formatHex8:Mu,formatRgb:vo,toString:vo}));function wo(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}`}function Mu(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}${tt((isNaN(this.opacity)?1:this.opacity)*255)}`}function vo(){const e=Cn(this.opacity);return`${e===1?"rgb(":"rgba("}${nt(this.r)}, ${nt(this.g)}, ${nt(this.b)}${e===1?")":`, ${e})`}`}function Cn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function nt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function tt(e){return e=nt(e),(e<16?"0":"")+e.toString(16)}function bo(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Pe(e,t,n,r)}function Ws(e){if(e instanceof Pe)return new Pe(e.h,e.s,e.l,e.opacity);if(e instanceof Gt||(e=st(e)),!e)return new Pe;if(e instanceof Pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),s=Math.max(t,n,r),i=NaN,a=s-o,c=(s+o)/2;return a?(t===s?i=(n-r)/a+(n<r)*6:n===s?i=(r-t)/a+2:i=(t-n)/a+4,a/=c<.5?s+o:2-s-o,i*=60):a=c>0&&c<1?0:i,new Pe(i,a,c,e.opacity)}function Cu(e,t,n,r){return arguments.length===1?Ws(e):new Pe(e,t,n,r??1)}function Pe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Or(Pe,Cu,Fs(Gt,{brighter(e){return e=e==null?Mn:Math.pow(Mn,e),new Pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new Pe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new we(sr(e>=240?e-240:e+120,o,r),sr(e,o,r),sr(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new Pe(_o(this.h),un(this.s),un(this.l),Cn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Cn(this.opacity);return`${e===1?"hsl(":"hsla("}${_o(this.h)}, ${un(this.s)*100}%, ${un(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _o(e){return e=(e||0)%360,e<0?e+360:e}function un(e){return Math.max(0,Math.min(1,e||0))}function sr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Vr=e=>()=>e;function Au(e,t){return function(n){return e+n*t}}function $u(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Iu(e){return(e=+e)==1?Ys:function(t,n){return n-t?$u(t,n,e):Vr(isNaN(t)?n:t)}}function Ys(e,t){var n=t-e;return n?Au(e,n):Vr(isNaN(e)?t:e)}const An=function e(t){var n=Iu(t);function r(o,s){var i=n((o=Sr(o)).r,(s=Sr(s)).r),a=n(o.g,s.g),c=n(o.b,s.b),l=Ys(o.opacity,s.opacity);return function(d){return o.r=i(d),o.g=a(d),o.b=c(d),o.opacity=l(d),o+""}}return r.gamma=e,r}(1);function ju(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(s){for(o=0;o<n;++o)r[o]=e[o]*(1-s)+t[o]*s;return r}}function Pu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Du(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),s=new Array(n),i;for(i=0;i<r;++i)o[i]=Rt(e[i],t[i]);for(;i<n;++i)s[i]=t[i];return function(a){for(i=0;i<r;++i)s[i]=o[i](a);return s}}function Tu(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Ru(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=Rt(e[o],t[o]):r[o]=t[o];return function(s){for(o in n)r[o]=n[o](s);return r}}var kr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ir=new RegExp(kr.source,"g");function Lu(e){return function(){return e}}function zu(e){return function(t){return e(t)+""}}function Xs(e,t){var n=kr.lastIndex=ir.lastIndex=0,r,o,s,i=-1,a=[],c=[];for(e=e+"",t=t+"";(r=kr.exec(e))&&(o=ir.exec(t));)(s=o.index)>n&&(s=t.slice(n,s),a[i]?a[i]+=s:a[++i]=s),(r=r[0])===(o=o[0])?a[i]?a[i]+=o:a[++i]=o:(a[++i]=null,c.push({i,x:He(r,o)})),n=ir.lastIndex;return n<t.length&&(s=t.slice(n),a[i]?a[i]+=s:a[++i]=s),a.length<2?c[0]?zu(c[0].x):Lu(t):(t=c.length,function(l){for(var d=0,u;d<t;++d)a[(u=c[d]).i]=u.x(l);return a.join("")})}function Rt(e,t){var n=typeof t,r;return t==null||n==="boolean"?Vr(t):(n==="number"?He:n==="string"?(r=st(t))?(t=r,An):Xs:t instanceof st?An:t instanceof Date?Tu:Pu(t)?ju:Array.isArray(t)?Du:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Ru:He)(e,t)}var Eo=180/Math.PI,Mr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ks(e,t,n,r,o,s){var i,a,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:o,translateY:s,rotate:Math.atan2(t,e)*Eo,skewX:Math.atan(c)*Eo,scaleX:i,scaleY:a}}var dn;function Hu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Mr:Ks(t.a,t.b,t.c,t.d,t.e,t.f)}function Ou(e){return e==null||(dn||(dn=document.createElementNS("http://www.w3.org/2000/svg","g")),dn.setAttribute("transform",e),!(e=dn.transform.baseVal.consolidate()))?Mr:(e=e.matrix,Ks(e.a,e.b,e.c,e.d,e.e,e.f))}function qs(e,t,n,r){function o(l){return l.length?l.pop()+" ":""}function s(l,d,u,f,h,g){if(l!==u||d!==f){var w=h.push("translate(",null,t,null,n);g.push({i:w-4,x:He(l,u)},{i:w-2,x:He(d,f)})}else(u||f)&&h.push("translate("+u+t+f+n)}function i(l,d,u,f){l!==d?(l-d>180?d+=360:d-l>180&&(l+=360),f.push({i:u.push(o(u)+"rotate(",null,r)-2,x:He(l,d)})):d&&u.push(o(u)+"rotate("+d+r)}function a(l,d,u,f){l!==d?f.push({i:u.push(o(u)+"skewX(",null,r)-2,x:He(l,d)}):d&&u.push(o(u)+"skewX("+d+r)}function c(l,d,u,f,h,g){if(l!==u||d!==f){var w=h.push(o(h)+"scale(",null,",",null,")");g.push({i:w-4,x:He(l,u)},{i:w-2,x:He(d,f)})}else(u!==1||f!==1)&&h.push(o(h)+"scale("+u+","+f+")")}return function(l,d){var u=[],f=[];return l=e(l),d=e(d),s(l.translateX,l.translateY,d.translateX,d.translateY,u,f),i(l.rotate,d.rotate,u,f),a(l.skewX,d.skewX,u,f),c(l.scaleX,l.scaleY,d.scaleX,d.scaleY,u,f),l=d=null,function(h){for(var g=-1,w=f.length,x;++g<w;)u[(x=f[g]).i]=x.x(h);return u.join("")}}}var Vu=qs(Hu,"px, ","px)","deg)"),Bu=qs(Ou,", ",")",")"),Fu=1e-12;function No(e){return((e=Math.exp(e))+1/e)/2}function Wu(e){return((e=Math.exp(e))-1/e)/2}function Yu(e){return((e=Math.exp(2*e))-1)/(e+1)}const bn=function e(t,n,r){function o(s,i){var a=s[0],c=s[1],l=s[2],d=i[0],u=i[1],f=i[2],h=d-a,g=u-c,w=h*h+g*g,x,y;if(w<Fu)y=Math.log(f/l)/t,x=function(I){return[a+I*h,c+I*g,l*Math.exp(t*I*y)]};else{var E=Math.sqrt(w),m=(f*f-l*l+r*w)/(2*l*n*E),v=(f*f-l*l-r*w)/(2*f*n*E),N=Math.log(Math.sqrt(m*m+1)-m),C=Math.log(Math.sqrt(v*v+1)-v);y=(C-N)/t,x=function(I){var D=I*y,T=No(N),W=l/(n*E)*(T*Yu(t*D+N)-Wu(N));return[a+W*h,c+W*g,l*T/No(t*D+N)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return o.rho=function(s){var i=Math.max(.001,+s),a=i*i,c=a*a;return e(i,a,c)},o}(Math.SQRT2,2,4);var wt=0,Pt=0,At=0,Gs=1e3,$n,Dt,In=0,it=0,Hn=0,Vt=typeof performance=="object"&&performance.now?performance:Date,Us=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Br(){return it||(Us(Xu),it=Vt.now()+Hn)}function Xu(){it=0}function jn(){this._call=this._time=this._next=null}jn.prototype=Zs.prototype={constructor:jn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Br():+n)+(t==null?0:+t),!this._next&&Dt!==this&&(Dt?Dt._next=this:$n=this,Dt=this),this._call=e,this._time=n,Cr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Cr())}};function Zs(e,t,n){var r=new jn;return r.restart(e,t,n),r}function Ku(){Br(),++wt;for(var e=$n,t;e;)(t=it-e._time)>=0&&e._call.call(void 0,t),e=e._next;--wt}function So(){it=(In=Vt.now())+Hn,wt=Pt=0;try{Ku()}finally{wt=0,Gu(),it=0}}function qu(){var e=Vt.now(),t=e-In;t>Gs&&(Hn-=t,In=e)}function Gu(){for(var e,t=$n,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:$n=n);Dt=e,Cr(r)}function Cr(e){if(!wt){Pt&&(Pt=clearTimeout(Pt));var t=e-it;t>24?(e<1/0&&(Pt=setTimeout(So,e-Vt.now()-Hn)),At&&(At=clearInterval(At))):(At||(In=Vt.now(),At=setInterval(qu,Gs)),wt=1,Us(So))}}function ko(e,t,n){var r=new jn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Uu=Ln("start","end","cancel","interrupt"),Zu=[],Qs=0,Mo=1,Ar=2,_n=3,Co=4,$r=5,En=6;function On(e,t,n,r,o,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Qu(e,n,{name:t,index:r,group:o,on:Uu,tween:Zu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Qs})}function Fr(e,t){var n=Le(e,t);if(n.state>Qs)throw new Error("too late; already scheduled");return n}function Ve(e,t){var n=Le(e,t);if(n.state>_n)throw new Error("too late; already running");return n}function Le(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Qu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Zs(s,0,n.time);function s(l){n.state=Mo,n.timer.restart(i,n.delay,n.time),n.delay<=l&&i(l-n.delay)}function i(l){var d,u,f,h;if(n.state!==Mo)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===_n)return ko(i);h.state===Co?(h.state=En,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=En,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(ko(function(){n.state===_n&&(n.state=Co,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Ar,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ar){for(n.state=_n,o=new Array(f=n.tween.length),d=0,u=-1;d<f;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(o[++u]=h);o.length=u+1}}function a(l){for(var d=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=$r,1),u=-1,f=o.length;++u<f;)o[u].call(e,d);n.state===$r&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=En,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Nn(e,t){var n=e.__transition,r,o,s=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){s=!1;continue}o=r.state>Ar&&r.state<$r,r.state=En,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}s&&delete e.__transition}}function Ju(e){return this.each(function(){Nn(this,e)})}function ed(e,t){var n,r;return function(){var o=Ve(this,e),s=o.tween;if(s!==n){r=n=s;for(var i=0,a=r.length;i<a;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}o.tween=r}}function td(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=Ve(this,e),i=s.tween;if(i!==r){o=(r=i).slice();for(var a={name:t,value:n},c=0,l=o.length;c<l;++c)if(o[c].name===t){o[c]=a;break}c===l&&o.push(a)}s.tween=o}}function nd(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Le(this.node(),n).tween,o=0,s=r.length,i;o<s;++o)if((i=r[o]).name===e)return i.value;return null}return this.each((t==null?ed:td)(n,e,t))}function Wr(e,t,n){var r=e._id;return e.each(function(){var o=Ve(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Le(o,r).value[t]}}function Js(e,t){var n;return(typeof t=="number"?He:t instanceof st?An:(n=st(t))?(t=n,An):Xs)(e,t)}function rd(e){return function(){this.removeAttribute(e)}}function od(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sd(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttribute(e);return i===o?null:i===r?s:s=t(r=i,n)}}function id(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttributeNS(e.space,e.local);return i===o?null:i===r?s:s=t(r=i,n)}}function ad(e,t,n){var r,o,s;return function(){var i,a=n(this),c;return a==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=a+"",i===c?null:i===r&&c===o?s:(o=c,s=t(r=i,a)))}}function cd(e,t,n){var r,o,s;return function(){var i,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=a+"",i===c?null:i===r&&c===o?s:(o=c,s=t(r=i,a)))}}function ld(e,t){var n=zn(e),r=n==="transform"?Bu:Js;return this.attrTween(e,typeof t=="function"?(n.local?cd:ad)(n,r,Wr(this,"attr."+e,t)):t==null?(n.local?od:rd)(n):(n.local?id:sd)(n,r,t))}function ud(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function dd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function fd(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&dd(e,s)),n}return o._value=t,o}function hd(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&ud(e,s)),n}return o._value=t,o}function gd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=zn(e);return this.tween(n,(r.local?fd:hd)(r,t))}function pd(e,t){return function(){Fr(this,e).delay=+t.apply(this,arguments)}}function md(e,t){return t=+t,function(){Fr(this,e).delay=t}}function yd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pd:md)(t,e)):Le(this.node(),t).delay}function xd(e,t){return function(){Ve(this,e).duration=+t.apply(this,arguments)}}function wd(e,t){return t=+t,function(){Ve(this,e).duration=t}}function vd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xd:wd)(t,e)):Le(this.node(),t).duration}function bd(e,t){if(typeof t!="function")throw new Error;return function(){Ve(this,e).ease=t}}function _d(e){var t=this._id;return arguments.length?this.each(bd(t,e)):Le(this.node(),t).ease}function Ed(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ve(this,e).ease=n}}function Nd(e){if(typeof e!="function")throw new Error;return this.each(Ed(this._id,e))}function Sd(e){typeof e!="function"&&(e=$s(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=[],c,l=0;l<i;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new Ye(r,this._parents,this._name,this._id)}function kd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,s=Math.min(r,o),i=new Array(r),a=0;a<s;++a)for(var c=t[a],l=n[a],d=c.length,u=i[a]=new Array(d),f,h=0;h<d;++h)(f=c[h]||l[h])&&(u[h]=f);for(;a<r;++a)i[a]=t[a];return new Ye(i,this._parents,this._name,this._id)}function Md(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Cd(e,t,n){var r,o,s=Md(t)?Fr:Ve;return function(){var i=s(this,e),a=i.on;a!==r&&(o=(r=a).copy()).on(t,n),i.on=o}}function Ad(e,t){var n=this._id;return arguments.length<2?Le(this.node(),n).on.on(e):this.each(Cd(n,e,t))}function $d(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Id(){return this.on("end.remove",$d(this._id))}function jd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=zr(e));for(var r=this._groups,o=r.length,s=new Array(o),i=0;i<o;++i)for(var a=r[i],c=a.length,l=s[i]=new Array(c),d,u,f=0;f<c;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),l[f]=u,On(l[f],t,n,f,l,Le(d,n)));return new Ye(s,this._parents,t,n)}function Pd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=As(e));for(var r=this._groups,o=r.length,s=[],i=[],a=0;a<o;++a)for(var c=r[a],l=c.length,d,u=0;u<l;++u)if(d=c[u]){for(var f=e.call(d,d.__data__,u,c),h,g=Le(d,n),w=0,x=f.length;w<x;++w)(h=f[w])&&On(h,t,n,w,f,g);s.push(f),i.push(d)}return new Ye(s,i,t,n)}var Dd=qt.prototype.constructor;function Td(){return new Dd(this._groups,this._parents)}function Rd(e,t){var n,r,o;return function(){var s=xt(this,e),i=(this.style.removeProperty(e),xt(this,e));return s===i?null:s===n&&i===r?o:o=t(n=s,r=i)}}function ei(e){return function(){this.style.removeProperty(e)}}function Ld(e,t,n){var r,o=n+"",s;return function(){var i=xt(this,e);return i===o?null:i===r?s:s=t(r=i,n)}}function zd(e,t,n){var r,o,s;return function(){var i=xt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),xt(this,e))),i===c?null:i===r&&c===o?s:(o=c,s=t(r=i,a))}}function Hd(e,t){var n,r,o,s="style."+t,i="end."+s,a;return function(){var c=Ve(this,e),l=c.on,d=c.value[s]==null?a||(a=ei(t)):void 0;(l!==n||o!==d)&&(r=(n=l).copy()).on(i,o=d),c.on=r}}function Od(e,t,n){var r=(e+="")=="transform"?Vu:Js;return t==null?this.styleTween(e,Rd(e,r)).on("end.style."+e,ei(e)):typeof t=="function"?this.styleTween(e,zd(e,r,Wr(this,"style."+e,t))).each(Hd(this._id,e)):this.styleTween(e,Ld(e,r,t),n).on("end.style."+e,null)}function Vd(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Bd(e,t,n){var r,o;function s(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&Vd(e,i,n)),r}return s._value=t,s}function Fd(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 new Error;return this.tween(r,Bd(e,t,n??""))}function Wd(e){return function(){this.textContent=e}}function Yd(e){return function(){var t=e(this);this.textContent=t??""}}function Xd(e){return this.tween("text",typeof e=="function"?Yd(Wr(this,"text",e)):Wd(e==null?"":e+""))}function Kd(e){return function(t){this.textContent=e.call(this,t)}}function qd(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Kd(o)),t}return r._value=e,r}function Gd(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,qd(e))}function Ud(){for(var e=this._name,t=this._id,n=ti(),r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],a=i.length,c,l=0;l<a;++l)if(c=i[l]){var d=Le(c,t);On(c,e,n,l,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ye(r,this._parents,e,n)}function Zd(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(s,i){var a={value:i},c={value:function(){--o===0&&s()}};n.each(function(){var l=Ve(this,r),d=l.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),o===0&&s()})}var Qd=0;function Ye(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ti(){return++Qd}var Fe=qt.prototype;Ye.prototype={constructor:Ye,select:jd,selectAll:Pd,selectChild:Fe.selectChild,selectChildren:Fe.selectChildren,filter:Sd,merge:kd,selection:Td,transition:Ud,call:Fe.call,nodes:Fe.nodes,node:Fe.node,size:Fe.size,empty:Fe.empty,each:Fe.each,on:Ad,attr:ld,attrTween:gd,style:Od,styleTween:Fd,text:Xd,textTween:Gd,remove:Id,tween:nd,delay:yd,duration:vd,ease:_d,easeVarying:Nd,end:Zd,[Symbol.iterator]:Fe[Symbol.iterator]};function Jd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ef={time:null,delay:0,duration:250,ease:Jd};function tf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function nf(e){var t,n;e instanceof Ye?(t=e._id,e=e._name):(t=ti(),(n=ef).time=Br(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],a=i.length,c,l=0;l<a;++l)(c=i[l])&&On(c,e,t,l,i,n||tf(c,t));return new Ye(r,this._parents,e,t)}qt.prototype.interrupt=Ju;qt.prototype.transition=nf;const fn=e=>()=>e;function rf(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){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:o}})}function We(e,t,n){this.k=e,this.x=t,this.y=n}We.prototype={constructor:We,scale:function(e){return e===1?this:new We(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new We(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 Vn=new We(1,0,0);ni.prototype=We.prototype;function ni(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Vn;return e.__zoom}function ar(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function of(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function sf(){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 Ao(){return this.__zoom||Vn}function af(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function cf(){return navigator.maxTouchPoints||"ontouchstart"in this}function lf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function ri(){var e=of,t=sf,n=lf,r=af,o=cf,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=bn,l=Ln("start","zoom","end"),d,u,f,h=500,g=150,w=0,x=10;function y(_){_.property("__zoom",Ao).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",W).filter(o).on("touchstart.zoom",M).on("touchmove.zoom",k).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,$,S,P){var R=_.selection?_.selection():_;R.property("__zoom",Ao),_!==R?N(_,$,S,P):R.interrupt().each(function(){C(this,arguments).event(P).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},y.scaleBy=function(_,$,S,P){y.scaleTo(_,function(){var R=this.__zoom.k,A=typeof $=="function"?$.apply(this,arguments):$;return R*A},S,P)},y.scaleTo=function(_,$,S,P){y.transform(_,function(){var R=t.apply(this,arguments),A=this.__zoom,V=S==null?v(R):typeof S=="function"?S.apply(this,arguments):S,B=A.invert(V),O=typeof $=="function"?$.apply(this,arguments):$;return n(m(E(A,O),V,B),R,i)},S,P)},y.translateBy=function(_,$,S,P){y.transform(_,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),i)},null,P)},y.translateTo=function(_,$,S,P,R){y.transform(_,function(){var A=t.apply(this,arguments),V=this.__zoom,B=P==null?v(A):typeof P=="function"?P.apply(this,arguments):P;return n(Vn.translate(B[0],B[1]).scale(V.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof S=="function"?-S.apply(this,arguments):-S),A,i)},P,R)};function E(_,$){return $=Math.max(s[0],Math.min(s[1],$)),$===_.k?_:new We($,_.x,_.y)}function m(_,$,S){var P=$[0]-S[0]*_.k,R=$[1]-S[1]*_.k;return P===_.x&&R===_.y?_:new We(_.k,P,R)}function v(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function N(_,$,S,P){_.on("start.zoom",function(){C(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(P).end()}).tween("zoom",function(){var R=this,A=arguments,V=C(R,A).event(P),B=t.apply(R,A),O=S==null?v(B):typeof S=="function"?S.apply(R,A):S,Y=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),K=R.__zoom,J=typeof $=="function"?$.apply(R,A):$,ne=c(K.invert(O).concat(Y/K.k),J.invert(O).concat(Y/J.k));return function(X){if(X===1)X=J;else{var H=ne(X),F=Y/H[2];X=new We(F,O[0]-H[0]*F,O[1]-H[1]*F)}V.zoom(null,X)}})}function C(_,$,S){return!S&&_.__zooming||new I(_,$)}function I(_,$){this.that=_,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,$),this.taps=0}I.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,$){return this.mouse&&_!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var $=Ee(this.that).datum();l.call(_,this.that,new rf(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),$)}};function D(_,...$){if(!e.apply(this,arguments))return;var S=C(this,$).event(_),P=this.__zoom,R=Math.max(s[0],Math.min(s[1],P.k*Math.pow(2,r.apply(this,arguments)))),A=je(_);if(S.wheel)(S.mouse[0][0]!==A[0]||S.mouse[0][1]!==A[1])&&(S.mouse[1]=P.invert(S.mouse[0]=A)),clearTimeout(S.wheel);else{if(P.k===R)return;S.mouse=[A,P.invert(A)],Nn(this),S.start()}$t(_),S.wheel=setTimeout(V,g),S.zoom("mouse",n(m(E(P,R),S.mouse[0],S.mouse[1]),S.extent,i));function V(){S.wheel=null,S.end()}}function T(_,...$){if(f||!e.apply(this,arguments))return;var S=_.currentTarget,P=C(this,$,!0).event(_),R=Ee(_.view).on("mousemove.zoom",O,!0).on("mouseup.zoom",Y,!0),A=je(_,S),V=_.clientX,B=_.clientY;Os(_.view),ar(_),P.mouse=[A,this.__zoom.invert(A)],Nn(this),P.start();function O(K){if($t(K),!P.moved){var J=K.clientX-V,ne=K.clientY-B;P.moved=J*J+ne*ne>w}P.event(K).zoom("mouse",n(m(P.that.__zoom,P.mouse[0]=je(K,S),P.mouse[1]),P.extent,i))}function Y(K){R.on("mousemove.zoom mouseup.zoom",null),Vs(K.view,P.moved),$t(K),P.event(K).end()}}function W(_,...$){if(e.apply(this,arguments)){var S=this.__zoom,P=je(_.changedTouches?_.changedTouches[0]:_,this),R=S.invert(P),A=S.k*(_.shiftKey?.5:2),V=n(m(E(S,A),P,R),t.apply(this,$),i);$t(_),a>0?Ee(this).transition().duration(a).call(N,V,P,_):Ee(this).call(y.transform,V,P,_)}}function M(_,...$){if(e.apply(this,arguments)){var S=_.touches,P=S.length,R=C(this,$,_.changedTouches.length===P).event(_),A,V,B,O;for(ar(_),V=0;V<P;++V)B=S[V],O=je(B,this),O=[O,this.__zoom.invert(O),B.identifier],R.touch0?!R.touch1&&R.touch0[2]!==O[2]&&(R.touch1=O,R.taps=0):(R.touch0=O,A=!0,R.taps=1+!!d);d&&(d=clearTimeout(d)),A&&(R.taps<2&&(u=O[0],d=setTimeout(function(){d=null},h)),Nn(this),R.start())}}function k(_,...$){if(this.__zooming){var S=C(this,$).event(_),P=_.changedTouches,R=P.length,A,V,B,O;for($t(_),A=0;A<R;++A)V=P[A],B=je(V,this),S.touch0&&S.touch0[2]===V.identifier?S.touch0[0]=B:S.touch1&&S.touch1[2]===V.identifier&&(S.touch1[0]=B);if(V=S.that.__zoom,S.touch1){var Y=S.touch0[0],K=S.touch0[1],J=S.touch1[0],ne=S.touch1[1],X=(X=J[0]-Y[0])*X+(X=J[1]-Y[1])*X,H=(H=ne[0]-K[0])*H+(H=ne[1]-K[1])*H;V=E(V,Math.sqrt(X/H)),B=[(Y[0]+J[0])/2,(Y[1]+J[1])/2],O=[(K[0]+ne[0])/2,(K[1]+ne[1])/2]}else if(S.touch0)B=S.touch0[0],O=S.touch0[1];else return;S.zoom("touch",n(m(V,B,O),S.extent,i))}}function L(_,...$){if(this.__zooming){var S=C(this,$).event(_),P=_.changedTouches,R=P.length,A,V;for(ar(_),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),A=0;A<R;++A)V=P[A],S.touch0&&S.touch0[2]===V.identifier?delete S.touch0:S.touch1&&S.touch1[2]===V.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(V=je(V,this),Math.hypot(u[0]-V[0],u[1]-V[1])<x)){var B=Ee(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(r=typeof _=="function"?_:fn(+_),y):r},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:fn(!!_),y):e},y.touchable=function(_){return arguments.length?(o=typeof _=="function"?_:fn(!!_),y):o},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:fn([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),y):t},y.scaleExtent=function(_){return arguments.length?(s[0]=+_[0],s[1]=+_[1],y):[s[0],s[1]]},y.translateExtent=function(_){return arguments.length?(i[0][0]=+_[0][0],i[1][0]=+_[1][0],i[0][1]=+_[0][1],i[1][1]=+_[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(_){return arguments.length?(n=_,y):n},y.duration=function(_){return arguments.length?(a=+_,y):a},y.interpolate=function(_){return arguments.length?(c=_,y):c},y.on=function(){var _=l.on.apply(l,arguments);return _===l?y:_},y.clickDistance=function(_){return arguments.length?(w=(_=+_)*_,y):Math.sqrt(w)},y.tapDistance=function(_){return arguments.length?(x=+_,y):x},y}const Re={error001:(e="react")=>`Seems like you have not used zustand provider 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.`},Bt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],oi=["Enter"," ","Escape"],si={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var vt;(function(e){e.Strict="strict",e.Loose="loose"})(vt||(vt={}));var rt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(rt||(rt={}));var Ft;(function(e){e.Partial="partial",e.Full="full"})(Ft||(Ft={}));const ii={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ue;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ue||(Ue={}));var Wt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Wt||(Wt={}));var Q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Q||(Q={}));const $o={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function ai(e){return e===null?null:e?"valid":"invalid"}const ci=e=>"id"in e&&"source"in e&&"target"in e,uf=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Yr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ut=(e,t=[0,0])=>{const{width:n,height:r}=Ke(e),o=e.origin??t,s=n*o[0],i=r*o[1];return{x:e.position.x-s,y:e.position.y-i}},df=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const s=typeof o=="string";let i=!t.nodeLookup&&!s?o:void 0;t.nodeLookup&&(i=s?t.nodeLookup.get(o):Yr(o)?o:t.nodeLookup.get(o.id));const a=i?Pn(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Bn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Fn(n)},Zt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=Bn(n,Pn(o)),r=!0)}),r?Fn(n):{x:0,y:0,width:0,height:0}},Xr=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1)=>{const a={...Mt(t,[n,r,o]),width:t.width/o,height:t.height/o},c=[];for(const l of e.values()){const{measured:d,selectable:u=!0,hidden:f=!1}=l;if(i&&!u||f)continue;const h=d.width??l.width??l.initialWidth??null,g=d.height??l.height??l.initialHeight??null,w=Yt(a,_t(l)),x=(h??0)*(g??0),y=s&&w>0;(!l.internals.handleBounds||y||w>=x||l.dragging)&&c.push(l)}return c},ff=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function hf(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function gf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:s},i){if(e.size===0)return!0;const a=hf(e,i),c=Zt(a),l=qr(c,t,n,(i==null?void 0:i.minZoom)??o,(i==null?void 0:i.maxZoom)??s,(i==null?void 0:i.padding)??.1);return await r.setViewport(l,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),!0}function li({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:s}){const i=n.get(e),a=i.parentId?n.get(i.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},d=i.origin??r;let u=i.extent||o;if(i.extent==="parent"&&!i.expandParent)if(!a)s==null||s("005",Re.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[c,l],[c+h,l+g]])}else a&&ct(i.extent)&&(u=[[i.extent[0][0]+c,i.extent[0][1]+l],[i.extent[1][0]+c,i.extent[1][1]+l]]);const f=ct(u)?at(t,u,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&(s==null||s("015",Re.error015())),{position:{x:f.x-c+(i.measured.width??0)*d[0],y:f.y-l+(i.measured.height??0)*d[1]},positionAbsolute:f}}async function pf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const s=new Set(e.map(f=>f.id)),i=[];for(const f of n){if(f.deletable===!1)continue;const h=s.has(f.id),g=!h&&f.parentId&&i.find(w=>w.id===f.parentId);(h||g)&&i.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),d=ff(i,c);for(const f of c)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!o)return{edges:d,nodes:i};const u=await o({nodes:i,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:i}:{edges:[],nodes:[]}:u}const bt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),at=(e={x:0,y:0},t,n)=>({x:bt(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:bt(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ui(e,t,n){const{width:r,height:o}=Ke(n),{x:s,y:i}=n.internals.positionAbsolute;return at(e,[[s,i],[s+r,i+o]],t)}const Io=(e,t,n)=>e<t?bt(Math.abs(e-t),1,t)/t:e>n?-bt(Math.abs(e-n),1,t)/t:0,Kr=(e,t,n=15,r=40)=>{const o=Io(e.x,r,t.width-r)*n,s=Io(e.y,r,t.height-r)*n;return[o,s]},Bn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Ir=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Fn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),_t=(e,t=[0,0])=>{var o,s;const{x:n,y:r}=Yr(e)?e.internals.positionAbsolute:Ut(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}},Pn=(e,t=[0,0])=>{var o,s;const{x:n,y:r}=Yr(e)?e.internals.positionAbsolute:Ut(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0)}},di=(e,t)=>Fn(Bn(Ir(e),Ir(t))),Yt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},jo=e=>De(e.width)&&De(e.height)&&De(e.x)&&De(e.y),De=e=>!isNaN(e)&&isFinite(e),fi=(e,t)=>(n,r)=>{},Qt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Mt=({x:e,y:t},[n,r,o],s=!1,i=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return s?Qt(a,i):a},Et=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function ht(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function mf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ht(e,n),o=ht(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=ht(e.top??e.y??0,n),o=ht(e.bottom??e.y??0,n),s=ht(e.left??e.x??0,t),i=ht(e.right??e.x??0,t);return{top:r,right:i,bottom:o,left:s,x:s+i,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function yf(e,t,n,r,o,s){const{x:i,y:a}=Et(e,[t,n,r]),{x:c,y:l}=Et({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=o-c,u=s-l;return{left:Math.floor(i),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}const qr=(e,t,n,r,o,s)=>{const i=mf(s,t,n),a=(t-i.x)/e.width,c=(n-i.y)/e.height,l=Math.min(a,c),d=bt(l,r,o),u=e.x+e.width/2,f=e.y+e.height/2,h=t/2-u*d,g=n/2-f*d,w=yf(e,h,g,d,t,n),x={left:Math.min(w.left-i.left,0),top:Math.min(w.top-i.top,0),right:Math.min(w.right-i.right,0),bottom:Math.min(w.bottom-i.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:d}},Xt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function ct(e){return e!=null&&e!=="parent"}function Ke(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function hi(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function gi(e,t={width:0,height:0},n,r,o){const s={...e},i=r.get(n);if(i){const a=i.origin||o;s.x+=i.internals.positionAbsolute.x-(t.width??0)*a[0],s.y+=i.internals.positionAbsolute.y-(t.height??0)*a[1]}return s}function Po(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function xf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function wf(e){return{...si,...e||{}}}function Lt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:s,y:i}=Te(e),a=Mt({x:s-((o==null?void 0:o.left)??0),y:i-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?Qt(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Gr=e=>({width:e.offsetWidth,height:e.offsetHeight}),pi=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},vf=["INPUT","SELECT","TEXTAREA"];function mi(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:vf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const yi=e=>"clientX"in e,Te=(e,t)=>{var s,i;const n=yi(e),r=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,o=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},Do=(e,t,n,r,o)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(i=>{const a=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:o,position:i.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Gr(i)}})};function xi({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:a}){const c=e*.125+o*.375+i*.375+n*.125,l=t*.125+s*.375+a*.375+r*.125,d=Math.abs(c-e),u=Math.abs(l-t);return[c,l,d,u]}function hn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function To({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case Q.Left:return[t-hn(t-r,s),n];case Q.Right:return[t+hn(r-t,s),n];case Q.Top:return[t,n-hn(n-o,s)];case Q.Bottom:return[t,n+hn(o-n,s)]}}function wi({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:o,targetPosition:s=Q.Top,curvature:i=.25}){const[a,c]=To({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[l,d]=To({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[u,f,h,g]=xi({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${a},${c} ${l},${d} ${r},${o}`,u,f,h,g]}function vi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,s=n<e?n+o:n-o,i=Math.abs(r-t)/2,a=r<t?r+i:r-i;return[s,a,o,i]}function bf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:s="basic"}){if(s==="manual")return r;const i=o&&n?r+1e3:r,a=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return i+a}function _f({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const s=Bn(Pn(e),Pn(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const i={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return Yt(i,Fn(s))>0}const Ef=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Nf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Sf=(e,t,n={})=>{var s;if(!e.source||!e.target)return(s=n.onError)==null||s.call(n,"006",Re.error006()),t;const r=n.getEdgeId||Ef;let o;return ci(e)?o={...e}:o={...e,id:r(e)},Nf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function bi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,a]=vi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,a]}const Ro={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},kf=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Lo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Mf({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:o,offset:s,stepPosition:i}){const a=Ro[t],c=Ro[r],l={x:e.x+a.x*s,y:e.y+a.y*s},d={x:n.x+c.x*s,y:n.y+c.y*s},u=kf({source:l,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],w,x;const y={x:0,y:0},E={x:0,y:0},[,,m,v]=vi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(w=o.x??l.x+(d.x-l.x)*i,x=o.y??(l.y+d.y)/2):(w=o.x??(l.x+d.x)/2,x=o.y??l.y+(d.y-l.y)*i);const D=[{x:w,y:l.y},{x:w,y:d.y}],T=[{x:l.x,y:x},{x:d.x,y:x}];a[f]===h?g=f==="x"?D:T:g=f==="x"?T:D}else{const D=[{x:l.x,y:d.y}],T=[{x:d.x,y:l.y}];if(f==="x"?g=a.x===h?T:D:g=a.y===h?D:T,t===r){const _=Math.abs(e[f]-n[f]);if(_<=s){const $=Math.min(s-1,s-_);a[f]===h?y[f]=(l[f]>e[f]?-1:1)*$:E[f]=(d[f]>n[f]?-1:1)*$}}if(t!==r){const _=f==="x"?"y":"x",$=a[f]===c[_],S=l[_]>d[_],P=l[_]<d[_];(a[f]===1&&(!$&&S||$&&P)||a[f]!==1&&(!$&&P||$&&S))&&(g=f==="x"?D:T)}const W={x:l.x+y.x,y:l.y+y.y},M={x:d.x+E.x,y:d.y+E.y},k=Math.max(Math.abs(W.x-g[0].x),Math.abs(M.x-g[0].x)),L=Math.max(Math.abs(W.y-g[0].y),Math.abs(M.y-g[0].y));k>=L?(w=(W.x+M.x)/2,x=g[0].y):(w=g[0].x,x=(W.y+M.y)/2)}const N={x:l.x+y.x,y:l.y+y.y},C={x:d.x+E.x,y:d.y+E.y};return[[e,...N.x!==g[0].x||N.y!==g[0].y?[N]:[],...g,...C.x!==g[g.length-1].x||C.y!==g[g.length-1].y?[C]:[],n],w,x,m,v]}function Cf(e,t,n,r){const o=Math.min(Lo(e,t)/2,Lo(t,n)/2,r),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i){const l=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${s+o*l},${i}Q ${s},${i} ${s},${i+o*d}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${s},${i+o*c}Q ${s},${i} ${s+o*a},${i}`}function jr({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:o,targetPosition:s=Q.Top,borderRadius:i=5,centerX:a,centerY:c,offset:l=20,stepPosition:d=.5}){const[u,f,h,g,w]=Mf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:a,y:c},offset:l,stepPosition:d});let x=`M${u[0].x} ${u[0].y}`;for(let y=1;y<u.length-1;y++)x+=Cf(u[y-1],u[y],u[y+1],i);return x+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[x,f,h,g,w]}function zo(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Af(e){var u;const{sourceNode:t,targetNode:n}=e;if(!zo(t)||!zo(n))return null;const r=t.internals.handleBounds||Ho(t.handles),o=n.internals.handleBounds||Ho(n.handles),s=Oo((r==null?void 0:r.source)??[],e.sourceHandle),i=Oo(e.connectionMode===vt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!s||!i)return(u=e.onError)==null||u.call(e,"008",Re.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(s==null?void 0:s.position)||Q.Bottom,c=(i==null?void 0:i.position)||Q.Top,l=lt(t,s,a),d=lt(n,i,c);return{sourceX:l.x,sourceY:l.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:c}}function Ho(e){if(!e)return null;const t=[],n=[];for(const 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 lt(e,t,n=Q.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,s=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:i,height:a}=t??Ke(e);if(r)return{x:o+i/2,y:s+a/2};switch((t==null?void 0:t.position)??n){case Q.Top:return{x:o+i/2,y:s};case Q.Right:return{x:o+i,y:s+a/2};case Q.Bottom:return{x:o+i/2,y:s+a};case Q.Left:return{x:o,y:s+a/2}}}function Oo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Pr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function $f(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const s=new Set;return e.reduce((i,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const l=Pr(c,t);s.has(l)||(i.push({id:l,color:c.color||n,...c}),s.add(l))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))}const _i=1e3,If=10,Ur={nodeOrigin:[0,0],nodeExtent:Bt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},jf={...Ur,checkEquality:!0};function Zr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Pf(e,t,n){const r=Zr(Ur,n);for(const o of e.values())if(o.parentId)Jr(o,e,t,r);else{const s=Ut(o,r.nodeOrigin),i=ct(o.extent)?o.extent:r.nodeExtent,a=at(s,i,Ke(o));o.internals.positionAbsolute=a}}function Df(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const s={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(s):o.type==="target"&&r.push(s)}return{source:n,target:r}}function Qr(e){return e==="manual"}function Dr(e,t,n,r={}){var d,u;const o=Zr(jf,r),s={i:0},i=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!Qr(o.zIndexMode)?_i:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let h=i.get(f.id);if(o.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const g=Ut(f,o.nodeOrigin),w=ct(f.extent)?f.extent:o.nodeExtent,x=at(g,w,Ke(f));h={...o.defaults,...f,measured:{width:(d=f.measured)==null?void 0:d.width,height:(u=f.measured)==null?void 0:u.height},internals:{positionAbsolute:x,handleBounds:Df(f,h),z:Ei(f,a,o.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),f.parentId&&Jr(h,t,n,r,s),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function Tf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Jr(e,t,n,r,o){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:a,zIndexMode:c}=Zr(Ur,r),l=e.parentId,d=t.get(l);if(!d){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}Tf(e,n),o&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++o.i,d.internals.z=d.internals.z+o.i*If),o&&d.internals.rootParentIndex!==void 0&&(o.i=d.internals.rootParentIndex);const u=s&&!Qr(c)?_i:0,{x:f,y:h,z:g}=Rf(e,d,i,a,u,c),{positionAbsolute:w}=e.internals,x=f!==w.x||h!==w.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:w,z:g}})}function Ei(e,t,n){const r=De(e.zIndex)?e.zIndex:0;return Qr(n)?r:r+(e.selected?t:0)}function Rf(e,t,n,r,o,s){const{x:i,y:a}=t.internals.positionAbsolute,c=Ke(e),l=Ut(e,n),d=ct(e.extent)?at(l,e.extent,c):l;let u=at({x:i+d.x,y:a+d.y},r,c);e.extent==="parent"&&(u=ui(u,c,t));const f=Ei(e,o,s),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function eo(e,t,n,r=[0,0]){var i;const o=[],s=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((i=s.get(a.parentId))==null?void 0:i.expandedRect)??_t(c),d=di(l,a.rect);s.set(a.parentId,{expandedRect:d,parent:c})}return s.size>0&&s.forEach(({expandedRect:a,parent:c},l)=>{var m;const d=c.internals.positionAbsolute,u=Ke(c),f=c.origin??r,h=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,g=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,w=Math.max(u.width,Math.round(a.width)),x=Math.max(u.height,Math.round(a.height)),y=(w-u.width)*f[0],E=(x-u.height)*f[1];(h>0||g>0||y||E)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+y,y:c.position.y-g+E}}),(m=n.get(l))==null||m.forEach(v=>{e.some(N=>N.id===v.id)||o.push({id:v.id,type:"position",position:{x:v.position.x+h,y:v.position.y+g}})})),(u.width<a.width||u.height<a.height||h||g)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:w+(h?f[0]*h-y:0),height:x+(g?f[1]*g-E:0)}})}),o}function Lf(e,t,n,r,o,s,i){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],d=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const w=Gr(h.nodeElement),x=g.measured.width!==w.width||g.measured.height!==w.height;if(!!(w.width&&w.height&&(x||!g.internals.handleBounds||h.force))){const E=h.nodeElement.getBoundingClientRect(),m=ct(g.extent)?g.extent:s;let{positionAbsolute:v}=g.internals;g.parentId&&g.extent==="parent"?v=ui(v,w,t.get(g.parentId)):m&&(v=at(v,m,w));const N={...g,measured:w,internals:{...g.internals,positionAbsolute:v,handleBounds:{source:Do("source",h.nodeElement,E,u,g.id),target:Do("target",h.nodeElement,E,u,g.id)}}};t.set(g.id,N),g.parentId&&Jr(N,t,n,{nodeOrigin:o,zIndexMode:i}),c=!0,x&&(l.push({id:g.id,type:"dimensions",dimensions:w}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:_t(N,o)}))}}if(f.length>0){const h=eo(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function zf({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:s}){if(!t||!e.x&&!e.y)return!1;const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,s]],r);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function Vo(e,t,n,r,o,s){let i=o;const a=r.get(i)||new Map;r.set(i,a.set(n,t)),i=`${o}-${e}`;const c=r.get(i)||new Map;if(r.set(i,c.set(n,t)),s){i=`${o}-${e}-${s}`;const l=r.get(i)||new Map;r.set(i,l.set(n,t))}}function Ni(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:s,sourceHandle:i=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:s,sourceHandle:i,targetHandle:a},l=`${o}-${i}--${s}-${a}`,d=`${s}-${a}--${o}-${i}`;Vo("source",c,d,e,o,i),Vo("target",c,l,e,s,a),t.set(r.id,r)}}function Si(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Si(n,t):!1}function Bo(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Hf(e,t,n,r){const o=new Map;for(const[s,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!Si(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const a=e.get(s);a&&o.set(s,{id:s,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function cr({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var i,a,c;const o=[];for(const[l,d]of t){const u=(i=n.get(l))==null?void 0:i.internals.userNode;u&&o.push({...u,position:d.position,dragging:r})}if(!e)return[o[0],o];const s=(a=n.get(e))==null?void 0:a.internals.userNode;return[s?{...s,position:((c=t.get(e))==null?void 0:c.position)||s.position,dragging:r}:o[0],o]}function Of({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const s={x:n-o.distance.x,y:r-o.distance.y},i=Qt(s,t);return{x:i.x-s.x,y:i.y-s.y}}function Vf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let s={x:null,y:null},i=0,a=new Map,c=!1,l={x:0,y:0},d=null,u=!1,f=null,h=!1,g=!1,w=null;function x({noDragClassName:E,handleSelector:m,domNode:v,isSelectable:N,nodeId:C,nodeClickDistance:I=0}){f=Ee(v);function D({x:k,y:L}){const{nodeLookup:_,nodeExtent:$,snapGrid:S,snapToGrid:P,nodeOrigin:R,onNodeDrag:A,onSelectionDrag:V,onError:B,updateNodePositions:O}=t();s={x:k,y:L};let Y=!1;const K=a.size>1,J=K&&$?Ir(Zt(a)):null,ne=K&&P?Of({dragItems:a,snapGrid:S,x:k,y:L}):null;for(const[X,H]of a){if(!_.has(X))continue;let F={x:k-H.distance.x,y:L-H.distance.y};P&&(F=ne?{x:Math.round(F.x+ne.x),y:Math.round(F.y+ne.y)}:Qt(F,S));let te=null;if(K&&$&&!H.extent&&J){const{positionAbsolute:q}=H.internals,re=q.x-J.x+$[0][0],ie=q.x+H.measured.width-J.x2+$[1][0],ae=q.y-J.y+$[0][1],ce=q.y+H.measured.height-J.y2+$[1][1];te=[[re,ae],[ie,ce]]}const{position:ee,positionAbsolute:Z}=li({nodeId:X,nextPosition:F,nodeLookup:_,nodeExtent:te||$,nodeOrigin:R,onError:B});Y=Y||H.position.x!==ee.x||H.position.y!==ee.y,H.position=ee,H.internals.positionAbsolute=Z}if(g=g||Y,!!Y&&(O(a,!0),w&&(r||A||!C&&V))){const[X,H]=cr({nodeId:C,dragItems:a,nodeLookup:_});r==null||r(w,a,X,H),A==null||A(w,X,H),C||V==null||V(w,H)}}async function T(){if(!d)return;const{transform:k,panBy:L,autoPanSpeed:_,autoPanOnNodeDrag:$}=t();if(!$){c=!1,cancelAnimationFrame(i);return}const[S,P]=Kr(l,d,_);(S!==0||P!==0)&&(s.x=(s.x??0)-S/k[2],s.y=(s.y??0)-P/k[2],await L({x:S,y:P})&&D(s)),i=requestAnimationFrame(T)}function W(k){var K;const{nodeLookup:L,multiSelectionActive:_,nodesDraggable:$,transform:S,snapGrid:P,snapToGrid:R,selectNodesOnDrag:A,onNodeDragStart:V,onSelectionDragStart:B,unselectNodesAndEdges:O}=t();u=!0,(!A||!N)&&!_&&C&&((K=L.get(C))!=null&&K.selected||O()),N&&A&&C&&(e==null||e(C));const Y=Lt(k.sourceEvent,{transform:S,snapGrid:P,snapToGrid:R,containerBounds:d});if(s=Y,a=Hf(L,$,Y,C),a.size>0&&(n||V||!C&&B)){const[J,ne]=cr({nodeId:C,dragItems:a,nodeLookup:L});n==null||n(k.sourceEvent,a,J,ne),V==null||V(k.sourceEvent,J,ne),C||B==null||B(k.sourceEvent,ne)}}const M=Bs().clickDistance(I).on("start",k=>{const{domNode:L,nodeDragThreshold:_,transform:$,snapGrid:S,snapToGrid:P}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,h=!1,g=!1,w=k.sourceEvent,_===0&&W(k),s=Lt(k.sourceEvent,{transform:$,snapGrid:S,snapToGrid:P,containerBounds:d}),l=Te(k.sourceEvent,d)}).on("drag",k=>{const{autoPanOnNodeDrag:L,transform:_,snapGrid:$,snapToGrid:S,nodeDragThreshold:P,nodeLookup:R}=t(),A=Lt(k.sourceEvent,{transform:_,snapGrid:$,snapToGrid:S,containerBounds:d});if(w=k.sourceEvent,(k.sourceEvent.type==="touchmove"&&k.sourceEvent.touches.length>1||C&&!R.has(C))&&(h=!0),!h){if(!c&&L&&u&&(c=!0,T()),!u){const V=Te(k.sourceEvent,d),B=V.x-l.x,O=V.y-l.y;Math.sqrt(B*B+O*O)>P&&W(k)}(s.x!==A.xSnapped||s.y!==A.ySnapped)&&a&&u&&(l=Te(k.sourceEvent,d),D(A))}}).on("end",k=>{if(!u||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,u=!1,cancelAnimationFrame(i),a.size>0){const{nodeLookup:L,updateNodePositions:_,onNodeDragStop:$,onSelectionDragStop:S}=t();if(g&&(_(a,!1),g=!1),o||$||!C&&S){const[P,R]=cr({nodeId:C,dragItems:a,nodeLookup:L,dragging:!1});o==null||o(k.sourceEvent,a,P,R),$==null||$(k.sourceEvent,P,R),C||S==null||S(k.sourceEvent,R)}}}).filter(k=>{const L=k.target;return!k.button&&(!E||!Bo(L,`.${E}`,v))&&(!m||Bo(L,m,v))});f.call(M)}function y(){f==null||f.on(".drag",null)}return{update:x,destroy:y}}function Bf(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())Yt(o,_t(s))>0&&r.push(s);return r}const Ff=250;function Wf(e,t,n,r){var a,c;let o=[],s=1/0;const i=Bf(e,n,t+Ff);for(const l of i){const d=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of d){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:f,y:h}=lt(l,u,u.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g<s?(o=[{...u,x:f,y:h}],s=g):g===s&&o.push({...u,x:f,y:h}))}}if(!o.length)return null;if(o.length>1){const l=r.type==="source"?"target":"source";return o.find(d=>d.type===l)??o[0]}return o[0]}function ki(e,t,n,r,o,s=!1){var l,d,u;const i=r.get(e);if(!i)return null;const a=o==="strict"?(l=i.internals.handleBounds)==null?void 0:l[t]:[...((d=i.internals.handleBounds)==null?void 0:d.source)??[],...((u=i.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&s?{...c,...lt(i,c,c.position,!0)}:c}function Mi(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Yf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ci=()=>!0;function Xf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:s,isTarget:i,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:w,onConnectEnd:x,isValidConnection:y=Ci,onReconnectEnd:E,updateConnection:m,getTransform:v,getFromHandle:N,autoPanSpeed:C,dragThreshold:I=1,handleDomNode:D}){const T=pi(e.target);let W=0,M;const{x:k,y:L}=Te(e),_=Mi(s,D),$=a==null?void 0:a.getBoundingClientRect();let S=!1;if(!$||!_)return;const P=ki(o,_,r,c,t);if(!P)return;let R=Te(e,$),A=!1,V=null,B=!1,O=null;function Y(){if(!d||!$)return;const[ee,Z]=Kr(R,$,C);f({x:ee,y:Z}),W=requestAnimationFrame(Y)}const K={...P,nodeId:o,type:_,position:P.position},J=c.get(o);let X={inProgress:!0,isValid:null,from:lt(J,K,Q.Left,!0),fromHandle:K,fromPosition:K.position,fromNode:J,to:R,toHandle:null,toPosition:$o[K.position],toNode:null,pointer:R};function H(){S=!0,m(X),g==null||g(e,{nodeId:o,handleId:r,handleType:_})}I===0&&H();function F(ee){if(!S){const{x:ce,y:ge}=Te(ee),ve=ce-k,Se=ge-L;if(!(ve*ve+Se*Se>I*I))return;H()}if(!N()||!K){te(ee);return}const Z=v();R=Te(ee,$),M=Wf(Mt(R,Z,!1,[1,1]),n,c,K),A||(Y(),A=!0);const q=Ai(ee,{handle:M,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:i?"target":"source",isValidConnection:y,doc:T,lib:l,flowId:u,nodeLookup:c});O=q.handleDomNode,V=q.connection,B=Yf(!!M,q.isValid);const re=c.get(o),ie=re?lt(re,K,Q.Left,!0):X.from,ae={...X,from:ie,isValid:B,to:q.toHandle&&B?Et({x:q.toHandle.x,y:q.toHandle.y},Z):R,toHandle:q.toHandle,toPosition:B&&q.toHandle?q.toHandle.position:$o[K.position],toNode:q.toHandle?c.get(q.toHandle.nodeId):null,pointer:R};m(ae),X=ae}function te(ee){if(!("touches"in ee&&ee.touches.length>0)){if(S){(M||O)&&V&&B&&(w==null||w(V));const{inProgress:Z,...q}=X,re={...q,toPosition:X.toHandle?X.toPosition:null};x==null||x(ee,re),s&&(E==null||E(ee,re))}h(),cancelAnimationFrame(W),A=!1,B=!1,V=null,O=null,T.removeEventListener("mousemove",F),T.removeEventListener("mouseup",te),T.removeEventListener("touchmove",F),T.removeEventListener("touchend",te)}}T.addEventListener("mousemove",F),T.addEventListener("mouseup",te),T.addEventListener("touchmove",F),T.addEventListener("touchend",te)}function Ai(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:s,doc:i,lib:a,flowId:c,isValidConnection:l=Ci,nodeLookup:d}){const u=s==="target",f=t?i.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=Te(e),w=i.elementFromPoint(h,g),x=w!=null&&w.classList.contains(`${a}-flow__handle`)?w:f,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const E=Mi(void 0,x),m=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),N=x.classList.contains("connectable"),C=x.classList.contains("connectableend");if(!m||!E)return y;const I={source:u?m:r,sourceHandle:u?v:o,target:u?r:m,targetHandle:u?o:v};y.connection=I;const T=N&&C&&(n===vt.Strict?u&&E==="source"||!u&&E==="target":m!==r||v!==o);y.isValid=T&&l(I),y.toHandle=ki(m,E,v,d,n,!0)}return y}const Tr={onPointerDown:Xf,isValid:Ai};function Kf({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Ee(e);function s({translateExtent:a,width:c,height:l,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=m=>{if(m.sourceEvent.type!=="wheel"||!t)return;const v=n(),N=m.sourceEvent.ctrlKey&&Xt()?10:1,C=-m.sourceEvent.deltaY*(m.sourceEvent.deltaMode===1?.05:m.sourceEvent.deltaMode?1:.002)*d,I=v[2]*Math.pow(2,C*N);t.scaleTo(I)};let w=[0,0];const x=m=>{(m.sourceEvent.type==="mousedown"||m.sourceEvent.type==="touchstart")&&(w=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY])},y=m=>{const v=n();if(m.sourceEvent.type!=="mousemove"&&m.sourceEvent.type!=="touchmove"||!t)return;const N=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY],C=[N[0]-w[0],N[1]-w[1]];w=N;const I=r()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),D={x:v[0]-C[0]*I,y:v[1]-C[1]*I},T=[[0,0],[c,l]];t.setViewportConstrained({x:D.x,y:D.y,zoom:v[2]},T,a)},E=ri().on("start",x).on("zoom",u?y:null).on("zoom.wheel",f?g:null);o.call(E,{})}function i(){o.on("zoom",null)}return{update:s,destroy:i,pointer:je}}const Wn=e=>({x:e.x,y:e.y,zoom:e.k}),lr=({x:e,y:t,zoom:n})=>Vn.translate(e,t).scale(n),gt=(e,t)=>e.target.closest(`.${t}`),$i=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),qf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ur=(e,t=0,n=qf,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},Ii=e=>{const t=e.ctrlKey&&Xt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Gf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return d=>{if(gt(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(d.ctrlKey&&i){const x=je(d),y=Ii(d),E=u*Math.pow(2,y);r.scaleTo(n,E,x,d);return}const f=d.deltaMode===1?20:1;let h=o===rt.Vertical?0:d.deltaX*f,g=o===rt.Horizontal?0:d.deltaY*f;!Xt()&&d.shiftKey&&o!==rt.Vertical&&(h=d.deltaY*f,g=0),r.translateBy(n,-(h/u)*s,-(g/u)*s,{internal:!0});const w=Wn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,w),e.panScrollTimeout=setTimeout(()=>{l==null||l(d,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(d,w))}}function Uf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const s=r.type==="wheel",i=!t&&s&&!r.ctrlKey,a=gt(r,e);if(r.ctrlKey&&s&&a&&r.preventDefault(),i||a)return null;r.preventDefault(),n.call(this,r,o)}}function Zf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var s,i,a;if((s=r.sourceEvent)!=null&&s.internal)return;const o=Wn(r.transform);e.mouseButton=((i=r.sourceEvent)==null?void 0:i.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Qf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return s=>{var i,a;e.usedRightMouseButton=!!(n&&$i(t,e.mouseButton??0)),(i=s.sourceEvent)!=null&&i.sync||r([s.transform.x,s.transform.y,s.transform.k]),o&&!((a=s.sourceEvent)!=null&&a.internal)&&(o==null||o(s.sourceEvent,Wn(s.transform)))}}function Jf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:s}){return i=>{var a;if(!((a=i.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,s&&$i(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&s(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=Wn(i.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(i.sourceEvent,c)},n?150:0)}}}function eh({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:s,userSelectionActive:i,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:d}){return u=>{var x;const f=e||t,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(gt(u,`${l}-flow__node`)||gt(u,`${l}-flow__edge`)))return!0;if(!r&&!f&&!o&&!s&&!n||i||d&&!g||gt(u,a)&&g||gt(u,c)&&(!g||o&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&((x=u.touches)==null?void 0:x.length)>1)return u.preventDefault(),!1;if(!f&&!o&&!h&&g||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&w}}function th({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:s,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=ri().scaleExtent([t,n]).translateExtent(r),f=Ee(e).call(u);E({x:o.x,y:o.y,zoom:bt(o.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(Ii);async function w(M,k){return f?new Promise(L=>{u==null||u.interpolate((k==null?void 0:k.interpolate)==="linear"?Rt:bn).transform(ur(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>L(!0)),M)}):!1}function x({noWheelClassName:M,noPanClassName:k,onPaneContextMenu:L,userSelectionActive:_,panOnScroll:$,panOnDrag:S,panOnScrollMode:P,panOnScrollSpeed:R,preventScrolling:A,zoomOnPinch:V,zoomOnScroll:B,zoomOnDoubleClick:O,zoomActivationKeyPressed:Y,lib:K,onTransformChange:J,connectionInProgress:ne,paneClickDistance:X,selectionOnDrag:H}){_&&!l.isZoomingOrPanning&&y();const F=$&&!Y&&!_;u.clickDistance(H?1/0:!De(X)||X<0?0:X);const te=F?Gf({zoomPanValues:l,noWheelClassName:M,d3Selection:f,d3Zoom:u,panOnScrollMode:P,panOnScrollSpeed:R,zoomOnPinch:V,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:a}):Uf({noWheelClassName:M,preventScrolling:A,d3ZoomHandler:h});f.on("wheel.zoom",te,{passive:!1});const ee=Zf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:i});u.on("start",ee);const Z=Qf({zoomPanValues:l,panOnDrag:S,onPaneContextMenu:!!L,onPanZoom:s,onTransformChange:J});u.on("zoom",Z);const q=Jf({zoomPanValues:l,panOnDrag:S,panOnScroll:$,onPaneContextMenu:L,onPanZoomEnd:a,onDraggingChange:c});u.on("end",q);const re=eh({zoomActivationKeyPressed:Y,panOnDrag:S,zoomOnScroll:B,panOnScroll:$,zoomOnDoubleClick:O,zoomOnPinch:V,userSelectionActive:_,noPanClassName:k,noWheelClassName:M,lib:K,connectionInProgress:ne});u.filter(re),O?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function y(){u.on("zoom",null)}async function E(M,k,L){const _=lr(M),$=u==null?void 0:u.constrain()(_,k,L);return $&&await w($),$}async function m(M,k){const L=lr(M);return await w(L,k),L}function v(M){if(f){const k=lr(M),L=f.property("__zoom");(L.k!==M.zoom||L.x!==M.x||L.y!==M.y)&&(u==null||u.transform(f,k,null,{sync:!0}))}}function N(){const M=f?ni(f.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function C(M,k){return f?new Promise(L=>{u==null||u.interpolate((k==null?void 0:k.interpolate)==="linear"?Rt:bn).scaleTo(ur(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>L(!0)),M)}):!1}async function I(M,k){return f?new Promise(L=>{u==null||u.interpolate((k==null?void 0:k.interpolate)==="linear"?Rt:bn).scaleBy(ur(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>L(!0)),M)}):!1}function D(M){u==null||u.scaleExtent(M)}function T(M){u==null||u.translateExtent(M)}function W(M){const k=!De(M)||M<0?0:M;u==null||u.clickDistance(k)}return{update:x,destroy:y,setViewport:m,setViewportConstrained:E,getViewport:N,scaleTo:C,scaleBy:I,setScaleExtent:D,setTranslateExtent:T,syncViewport:v,setClickDistance:W}}var Nt;(function(e){e.Line="line",e.Handle="handle"})(Nt||(Nt={}));function nh({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:s}){const i=e-t,a=n-r,c=[i>0?1:i<0?-1:0,a>0?1:a<0?-1:0];return i&&o&&(c[0]=c[0]*-1),a&&s&&(c[1]=c[1]*-1),c}function Fo(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function qe(e,t){return Math.max(0,t-e)}function Ge(e,t){return Math.max(0,e-t)}function gn(e,t,n){return Math.max(0,t-e,e-n)}function Wo(e,t){return e?!t:t}function rh(e,t,n,r,o,s,i,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:d,isVertical:u}=t,f=d&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:w,maxWidth:x,minHeight:y,maxHeight:E}=r,{x:m,y:v,width:N,height:C,aspectRatio:I}=e;let D=Math.floor(d?h-e.pointerX:0),T=Math.floor(u?g-e.pointerY:0);const W=N+(c?-D:D),M=C+(l?-T:T),k=-s[0]*N,L=-s[1]*C;let _=gn(W,w,x),$=gn(M,y,E);if(i){let R=0,A=0;c&&D<0?R=qe(m+D+k,i[0][0]):!c&&D>0&&(R=Ge(m+W+k,i[1][0])),l&&T<0?A=qe(v+T+L,i[0][1]):!l&&T>0&&(A=Ge(v+M+L,i[1][1])),_=Math.max(_,R),$=Math.max($,A)}if(a){let R=0,A=0;c&&D>0?R=Ge(m+D,a[0][0]):!c&&D<0&&(R=qe(m+W,a[1][0])),l&&T>0?A=Ge(v+T,a[0][1]):!l&&T<0&&(A=qe(v+M,a[1][1])),_=Math.max(_,R),$=Math.max($,A)}if(o){if(d){const R=gn(W/I,y,E)*I;if(_=Math.max(_,R),i){let A=0;!c&&!l||c&&!l&&f?A=Ge(v+L+W/I,i[1][1])*I:A=qe(v+L+(c?D:-D)/I,i[0][1])*I,_=Math.max(_,A)}if(a){let A=0;!c&&!l||c&&!l&&f?A=qe(v+W/I,a[1][1])*I:A=Ge(v+(c?D:-D)/I,a[0][1])*I,_=Math.max(_,A)}}if(u){const R=gn(M*I,w,x)/I;if($=Math.max($,R),i){let A=0;!c&&!l||l&&!c&&f?A=Ge(m+M*I+k,i[1][0])/I:A=qe(m+(l?T:-T)*I+k,i[0][0])/I,$=Math.max($,A)}if(a){let A=0;!c&&!l||l&&!c&&f?A=qe(m+M*I,a[1][0])/I:A=Ge(m+(l?T:-T)*I,a[0][0])/I,$=Math.max($,A)}}}T=T+(T<0?$:-$),D=D+(D<0?_:-_),o&&(f?W>M*I?T=(Wo(c,l)?-D:D)/I:D=(Wo(c,l)?-T:T)*I:d?(T=D/I,l=c):(D=T*I,c=l));const S=c?m+D:m,P=l?v+T:v;return{width:N+(c?-D:D),height:C+(l?-T:T),x:s[0]*D*(c?-1:1)+S,y:s[1]*T*(l?-1:1)+P}}const ji={width:0,height:0,x:0,y:0},oh={...ji,pointerX:0,pointerY:0,aspectRatio:1};function sh(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,s=e.measured.width??0,i=e.measured.height??0,a=n[0]*s,c=n[1]*i;return[[r-a,o-c],[r+s-a,o+i-c]]}function ih({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const s=Ee(e);let i={controlDirection:Fo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:w,shouldResize:x}){let y={...ji},E={...oh};i={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Fo(l)};let m,v=null,N=[],C,I,D,T=!1;const W=Bs().on("start",M=>{const{nodeLookup:k,transform:L,snapGrid:_,snapToGrid:$,nodeOrigin:S,paneDomNode:P}=n();if(m=k.get(t),!m)return;v=(P==null?void 0:P.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:A}=Lt(M.sourceEvent,{transform:L,snapGrid:_,snapToGrid:$,containerBounds:v});y={width:m.measured.width??0,height:m.measured.height??0,x:m.position.x??0,y:m.position.y??0},E={...y,pointerX:R,pointerY:A,aspectRatio:y.width/y.height},C=void 0,I=ct(m.extent)?m.extent:void 0,m.parentId&&(m.extent==="parent"||m.expandParent)&&(C=k.get(m.parentId)),C&&m.extent==="parent"&&(I=[[0,0],[C.measured.width,C.measured.height]]),N=[],D=void 0;for(const[V,B]of k)if(B.parentId===t&&(N.push({id:V,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const O=sh(B,m,B.origin??S);D?D=[[Math.min(O[0][0],D[0][0]),Math.min(O[0][1],D[0][1])],[Math.max(O[1][0],D[1][0]),Math.max(O[1][1],D[1][1])]]:D=O}h==null||h(M,{...y})}).on("drag",M=>{const{transform:k,snapGrid:L,snapToGrid:_,nodeOrigin:$}=n(),S=Lt(M.sourceEvent,{transform:k,snapGrid:L,snapToGrid:_,containerBounds:v}),P=[];if(!m)return;const{x:R,y:A,width:V,height:B}=y,O={},Y=m.origin??$,{width:K,height:J,x:ne,y:X}=rh(E,i.controlDirection,S,i.boundaries,i.keepAspectRatio,Y,I,D),H=K!==V,F=J!==B,te=ne!==R&&H,ee=X!==A&&F;if(!te&&!ee&&!H&&!F)return;if((te||ee||Y[0]===1||Y[1]===1)&&(O.x=te?ne:y.x,O.y=ee?X:y.y,y.x=O.x,y.y=O.y,N.length>0)){const ie=ne-R,ae=X-A;for(const ce of N)ce.position={x:ce.position.x-ie+Y[0]*(K-V),y:ce.position.y-ae+Y[1]*(J-B)},P.push(ce)}if((H||F)&&(O.width=H&&(!i.resizeDirection||i.resizeDirection==="horizontal")?K:y.width,O.height=F&&(!i.resizeDirection||i.resizeDirection==="vertical")?J:y.height,y.width=O.width,y.height=O.height),C&&m.expandParent){const ie=Y[0]*(O.width??0);O.x&&O.x<ie&&(y.x=ie,E.x=E.x-(O.x-ie));const ae=Y[1]*(O.height??0);O.y&&O.y<ae&&(y.y=ae,E.y=E.y-(O.y-ae))}const Z=nh({width:y.width,prevWidth:V,height:y.height,prevHeight:B,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),q={...y,direction:Z};(x==null?void 0:x(M,q))!==!1&&(T=!0,g==null||g(M,q),r(O,P))}).on("end",M=>{T&&(w==null||w(M,{...y}),o==null||o({...y}),T=!1)});s.call(W)}function c(){s.on(".drag",null)}return{update:a,destroy:c}}var Pi={exports:{}},Di={},Ti={exports:{}},Ri={};/**
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionInterface-BtrzlOPs.js","assets/index-D6HBvKkJ.js","assets/index-DFdlYy4H.css","assets/terminalFont-DmTPNdbU.js","assets/TimelineChat-DQ21GSJK.js","assets/SessionWindow-BWH5O0jh.js","assets/PageScroll-CadAKuSy.js","assets/Modal-3brXUhM0.js","assets/bindings-BC9vqpYU.js","assets/SessionInterface-6GBZ9nXN.css","assets/EvalsPage-KbMMownG.js","assets/IssuesPage-DmyLb9Rj.js","assets/Settings-COgdKTJB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as b,g as Ja,R as ec,j as p,u as Xe,I as Sn,a as tc,P as wn,b as rr,p as nc,h as rc,c as oc,l as sc,_ as Rn,X as ic,Y as ac}from"./index-D6HBvKkJ.js";import{S as ot,G as Ss,a as cc,l as vr,A as lc,u as uc,s as Lr,b as dc,c as br,d as uo,T as fc,g as hc,i as gc,E as pc,e as fo,f as mc,h as yc,j as xc,P as wc,r as vc,k as bc,n as ke,m as _c,p as Ec,o as Nc,L as Sc,N as kc}from"./SessionWindow-BWH5O0jh.js";import{i as ks,M as Mc,r as Cc}from"./Modal-3brXUhM0.js";import{A as Ac,k as Ms,a as _r,f as fe}from"./bindings-BC9vqpYU.js";function he(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=he(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var $c={value:()=>{}};function Ln(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new vn(n)}function vn(e){this._=e}function Ic(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}vn.prototype=Ln.prototype={constructor:vn,on:function(e,t){var n=this._,r=Ic(e+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(e=r[s]).type)&&(o=jc(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<i;)if(o=(e=r[s]).type)n[o]=ho(n[o],e.name,t);else if(t==null)for(o in n)n[o]=ho(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new vn(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,s;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,o=s.length;r<o;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,s=r.length;o<s;++o)r[o].value.apply(t,n)}};function jc(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function ho(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=$c,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Er="http://www.w3.org/1999/xhtml";const go={svg:"http://www.w3.org/2000/svg",xhtml:Er,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function zn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),go.hasOwnProperty(t)?{space:go[t],local:e}:e}function Pc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Er&&t.documentElement.namespaceURI===Er?t.createElement(e):t.createElementNS(n,e)}}function Dc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Cs(e){var t=zn(e);return(t.local?Dc:Pc)(t)}function Tc(){}function zr(e){return e==null?Tc:function(){return this.querySelector(e)}}function Rc(e){typeof e!="function"&&(e=zr(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=new Array(i),c,l,d=0;d<i;++d)(c=s[d])&&(l=e.call(c,c.__data__,d,s))&&("__data__"in c&&(l.__data__=c.__data__),a[d]=l);return new Ne(r,this._parents)}function Lc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function zc(){return[]}function As(e){return e==null?zc:function(){return this.querySelectorAll(e)}}function Hc(e){return function(){return Lc(e.apply(this,arguments))}}function Oc(e){typeof e=="function"?e=Hc(e):e=As(e);for(var t=this._groups,n=t.length,r=[],o=[],s=0;s<n;++s)for(var i=t[s],a=i.length,c,l=0;l<a;++l)(c=i[l])&&(r.push(e.call(c,c.__data__,l,i)),o.push(c));return new Ne(r,o)}function $s(e){return function(){return this.matches(e)}}function Is(e){return function(t){return t.matches(e)}}var Vc=Array.prototype.find;function Bc(e){return function(){return Vc.call(this.children,e)}}function Fc(){return this.firstElementChild}function Wc(e){return this.select(e==null?Fc:Bc(typeof e=="function"?e:Is(e)))}var Yc=Array.prototype.filter;function Xc(){return Array.from(this.children)}function Kc(e){return function(){return Yc.call(this.children,e)}}function qc(e){return this.selectAll(e==null?Xc:Kc(typeof e=="function"?e:Is(e)))}function Gc(e){typeof e!="function"&&(e=$s(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=[],c,l=0;l<i;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new Ne(r,this._parents)}function js(e){return new Array(e.length)}function Uc(){return new Ne(this._enter||this._groups.map(js),this._parents)}function kn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}kn.prototype={constructor:kn,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 Zc(e){return function(){return e}}function Qc(e,t,n,r,o,s){for(var i=0,a,c=t.length,l=s.length;i<l;++i)(a=t[i])?(a.__data__=s[i],r[i]=a):n[i]=new kn(e,s[i]);for(;i<c;++i)(a=t[i])&&(o[i]=a)}function Jc(e,t,n,r,o,s,i){var a,c,l=new Map,d=t.length,u=s.length,f=new Array(d),h;for(a=0;a<d;++a)(c=t[a])&&(f[a]=h=i.call(c,c.__data__,a,t)+"",l.has(h)?o[a]=c:l.set(h,c));for(a=0;a<u;++a)h=i.call(e,s[a],a,s)+"",(c=l.get(h))?(r[a]=c,c.__data__=s[a],l.delete(h)):n[a]=new kn(e,s[a]);for(a=0;a<d;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function el(e){return e.__data__}function tl(e,t){if(!arguments.length)return Array.from(this,el);var n=t?Jc:Qc,r=this._parents,o=this._groups;typeof e!="function"&&(e=Zc(e));for(var s=o.length,i=new Array(s),a=new Array(s),c=new Array(s),l=0;l<s;++l){var d=r[l],u=o[l],f=u.length,h=nl(e.call(d,d&&d.__data__,l,r)),g=h.length,w=a[l]=new Array(g),x=i[l]=new Array(g),y=c[l]=new Array(f);n(d,u,w,x,y,h,t);for(var E=0,m=0,v,N;E<g;++E)if(v=w[E]){for(E>=m&&(m=E+1);!(N=x[m])&&++m<g;);v._next=N||null}}return i=new Ne(i,r),i._enter=a,i._exit=c,i}function nl(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function rl(){return new Ne(this._exit||this._groups.map(js),this._parents)}function ol(e,t,n){var r=this.enter(),o=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?s.remove():n(s),r&&o?r.merge(o).order():o}function sl(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,s=r.length,i=Math.min(o,s),a=new Array(o),c=0;c<i;++c)for(var l=n[c],d=r[c],u=l.length,f=a[c]=new Array(u),h,g=0;g<u;++g)(h=l[g]||d[g])&&(f[g]=h);for(;c<o;++c)a[c]=n[c];return new Ne(a,this._parents)}function il(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,s=r[o],i;--o>=0;)(i=r[o])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function al(e){e||(e=cl);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,r=n.length,o=new Array(r),s=0;s<r;++s){for(var i=n[s],a=i.length,c=o[s]=new Array(a),l,d=0;d<a;++d)(l=i[d])&&(c[d]=l);c.sort(t)}return new Ne(o,this._parents).order()}function cl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ll(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ul(){return Array.from(this)}function dl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length;o<s;++o){var i=r[o];if(i)return i}return null}function fl(){let e=0;for(const t of this)++e;return e}function hl(){return!this.node()}function gl(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],s=0,i=o.length,a;s<i;++s)(a=o[s])&&e.call(a,a.__data__,s,o);return this}function pl(e){return function(){this.removeAttribute(e)}}function ml(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yl(e,t){return function(){this.setAttribute(e,t)}}function xl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function wl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function vl(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 bl(e,t){var n=zn(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?ml:pl:typeof t=="function"?n.local?vl:wl:n.local?xl:yl)(n,t))}function Ps(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function _l(e){return function(){this.style.removeProperty(e)}}function El(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Nl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Sl(e,t,n){return arguments.length>1?this.each((t==null?_l:typeof t=="function"?Nl:El)(e,t,n??"")):xt(this.node(),e)}function xt(e,t){return e.style.getPropertyValue(t)||Ps(e).getComputedStyle(e,null).getPropertyValue(t)}function kl(e){return function(){delete this[e]}}function Ml(e,t){return function(){this[e]=t}}function Cl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Al(e,t){return arguments.length>1?this.each((t==null?kl:typeof t=="function"?Cl:Ml)(e,t)):this.node()[e]}function Ds(e){return e.trim().split(/^|\s+/)}function Hr(e){return e.classList||new Ts(e)}function Ts(e){this._node=e,this._names=Ds(e.getAttribute("class")||"")}Ts.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Rs(e,t){for(var n=Hr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Ls(e,t){for(var n=Hr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function $l(e){return function(){Rs(this,e)}}function Il(e){return function(){Ls(this,e)}}function jl(e,t){return function(){(t.apply(this,arguments)?Rs:Ls)(this,e)}}function Pl(e,t){var n=Ds(e+"");if(arguments.length<2){for(var r=Hr(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?jl:t?$l:Il)(n,t))}function Dl(){this.textContent=""}function Tl(e){return function(){this.textContent=e}}function Rl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Ll(e){return arguments.length?this.each(e==null?Dl:(typeof e=="function"?Rl:Tl)(e)):this.node().textContent}function zl(){this.innerHTML=""}function Hl(e){return function(){this.innerHTML=e}}function Ol(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Vl(e){return arguments.length?this.each(e==null?zl:(typeof e=="function"?Ol:Hl)(e)):this.node().innerHTML}function Bl(){this.nextSibling&&this.parentNode.appendChild(this)}function Fl(){return this.each(Bl)}function Wl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Yl(){return this.each(Wl)}function Xl(e){var t=typeof e=="function"?e:Cs(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Kl(){return null}function ql(e,t){var n=typeof e=="function"?e:Cs(e),r=t==null?Kl:typeof t=="function"?t:zr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Gl(){var e=this.parentNode;e&&e.removeChild(this)}function Ul(){return this.each(Gl)}function Zl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ql(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Jl(e){return this.select(e?Ql:Zl)}function eu(e){return arguments.length?this.property("__data__",e):this.node().__data__}function tu(e){return function(t){e.call(this,t,this.__data__)}}function nu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function ru(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,s;n<o;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function ou(e,t,n){return function(){var r=this.__on,o,s=tu(t);if(r){for(var i=0,a=r.length;i<a;++i)if((o=r[i]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=s,o.options=n),o.value=t;return}}this.addEventListener(e.type,s,n),o={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(o):this.__on=[o]}}function su(e,t,n){var r=nu(e+""),o,s=r.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,d;c<l;++c)for(o=0,d=a[c];o<s;++o)if((i=r[o]).type===d.type&&i.name===d.name)return d.value}return}for(a=t?ou:ru,o=0;o<s;++o)this.each(a(r[o],t,n));return this}function zs(e,t,n){var r=Ps(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function iu(e,t){return function(){return zs(this,e,t)}}function au(e,t){return function(){return zs(this,e,t.apply(this,arguments))}}function cu(e,t){return this.each((typeof t=="function"?au:iu)(e,t))}function*lu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length,i;o<s;++o)(i=r[o])&&(yield i)}var Hs=[null];function Ne(e,t){this._groups=e,this._parents=t}function qt(){return new Ne([[document.documentElement]],Hs)}function uu(){return this}Ne.prototype=qt.prototype={constructor:Ne,select:Rc,selectAll:Oc,selectChild:Wc,selectChildren:qc,filter:Gc,data:tl,enter:Uc,exit:rl,join:ol,merge:sl,selection:uu,order:il,sort:al,call:ll,nodes:ul,node:dl,size:fl,empty:hl,each:gl,attr:bl,style:Sl,property:Al,classed:Pl,text:Ll,html:Vl,raise:Fl,lower:Yl,append:Xl,insert:ql,remove:Ul,clone:Jl,datum:eu,on:su,dispatch:cu,[Symbol.iterator]:lu};function Ee(e){return typeof e=="string"?new Ne([[document.querySelector(e)]],[document.documentElement]):new Ne([[e]],Hs)}function du(e){let t;for(;t=e.sourceEvent;)e=t;return e}function je(e,t){if(e=du(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 o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const fu={passive:!1},zt={capture:!0,passive:!1};function or(e){e.stopImmediatePropagation()}function mt(e){e.preventDefault(),e.stopImmediatePropagation()}function Os(e){var t=e.document.documentElement,n=Ee(e).on("dragstart.drag",mt,zt);"onselectstart"in t?n.on("selectstart.drag",mt,zt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Vs(e,t){var n=e.document.documentElement,r=Ee(e).on("dragstart.drag",null);t&&(r.on("click.drag",mt,zt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const cn=e=>()=>e;function Nr(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:s,x:i,y:a,dx:c,dy:l,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:d}})}Nr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function hu(e){return!e.ctrlKey&&!e.button}function gu(){return this.parentNode}function pu(e,t){return t??{x:e.x,y:e.y}}function mu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bs(){var e=hu,t=gu,n=pu,r=mu,o={},s=Ln("start","drag","end"),i=0,a,c,l,d,u=0;function f(v){v.on("mousedown.drag",h).filter(r).on("touchstart.drag",x).on("touchmove.drag",y,fu).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,N){if(!(d||!e.call(this,v,N))){var C=m(this,t.call(this,v,N),v,N,"mouse");C&&(Ee(v.view).on("mousemove.drag",g,zt).on("mouseup.drag",w,zt),Os(v.view),or(v),l=!1,a=v.clientX,c=v.clientY,C("start",v))}}function g(v){if(mt(v),!l){var N=v.clientX-a,C=v.clientY-c;l=N*N+C*C>u}o.mouse("drag",v)}function w(v){Ee(v.view).on("mousemove.drag mouseup.drag",null),Vs(v.view,l),mt(v),o.mouse("end",v)}function x(v,N){if(e.call(this,v,N)){var C=v.changedTouches,I=t.call(this,v,N),D=C.length,T,W;for(T=0;T<D;++T)(W=m(this,I,v,N,C[T].identifier,C[T]))&&(or(v),W("start",v,C[T]))}}function y(v){var N=v.changedTouches,C=N.length,I,D;for(I=0;I<C;++I)(D=o[N[I].identifier])&&(mt(v),D("drag",v,N[I]))}function E(v){var N=v.changedTouches,C=N.length,I,D;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),I=0;I<C;++I)(D=o[N[I].identifier])&&(or(v),D("end",v,N[I]))}function m(v,N,C,I,D,T){var W=s.copy(),M=je(T||C,N),k,L,_;if((_=n.call(v,new Nr("beforestart",{sourceEvent:C,target:f,identifier:D,active:i,x:M[0],y:M[1],dx:0,dy:0,dispatch:W}),I))!=null)return k=_.x-M[0]||0,L=_.y-M[1]||0,function $(S,P,R){var A=M,V;switch(S){case"start":o[D]=$,V=i++;break;case"end":delete o[D],--i;case"drag":M=je(R||P,N),V=i;break}W.call(S,v,new Nr(S,{sourceEvent:P,subject:_,target:f,identifier:D,active:V,x:M[0]+k,y:M[1]+L,dx:M[0]-A[0],dy:M[1]-A[1],dispatch:W}),I)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:cn(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:cn(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:cn(v),f):n},f.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:cn(!!v),f):r},f.on=function(){var v=s.on.apply(s,arguments);return v===s?f:v},f.clickDistance=function(v){return arguments.length?(u=(v=+v)*v,f):Math.sqrt(u)},f}function Or(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Fs(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Gt(){}var Ht=.7,Mn=1/Ht,yt="\\s*([+-]?\\d+)\\s*",Ot="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Oe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",yu=/^#([0-9a-f]{3,8})$/,xu=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),wu=new RegExp(`^rgb\\(${Oe},${Oe},${Oe}\\)$`),vu=new RegExp(`^rgba\\(${yt},${yt},${yt},${Ot}\\)$`),bu=new RegExp(`^rgba\\(${Oe},${Oe},${Oe},${Ot}\\)$`),_u=new RegExp(`^hsl\\(${Ot},${Oe},${Oe}\\)$`),Eu=new RegExp(`^hsla\\(${Ot},${Oe},${Oe},${Ot}\\)$`),po={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};Or(Gt,st,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:mo,formatHex:mo,formatHex8:Nu,formatHsl:Su,formatRgb:yo,toString:yo});function mo(){return this.rgb().formatHex()}function Nu(){return this.rgb().formatHex8()}function Su(){return Ws(this).formatHsl()}function yo(){return this.rgb().formatRgb()}function st(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=yu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?xo(t):n===3?new we(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ln(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ln(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=xu.exec(e))?new we(t[1],t[2],t[3],1):(t=wu.exec(e))?new we(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vu.exec(e))?ln(t[1],t[2],t[3],t[4]):(t=bu.exec(e))?ln(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=_u.exec(e))?bo(t[1],t[2]/100,t[3]/100,1):(t=Eu.exec(e))?bo(t[1],t[2]/100,t[3]/100,t[4]):po.hasOwnProperty(e)?xo(po[e]):e==="transparent"?new we(NaN,NaN,NaN,0):null}function xo(e){return new we(e>>16&255,e>>8&255,e&255,1)}function ln(e,t,n,r){return r<=0&&(e=t=n=NaN),new we(e,t,n,r)}function ku(e){return e instanceof Gt||(e=st(e)),e?(e=e.rgb(),new we(e.r,e.g,e.b,e.opacity)):new we}function Sr(e,t,n,r){return arguments.length===1?ku(e):new we(e,t,n,r??1)}function we(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Or(we,Sr,Fs(Gt,{brighter(e){return e=e==null?Mn:Math.pow(Mn,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new we(nt(this.r),nt(this.g),nt(this.b),Cn(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:wo,formatHex:wo,formatHex8:Mu,formatRgb:vo,toString:vo}));function wo(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}`}function Mu(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}${tt((isNaN(this.opacity)?1:this.opacity)*255)}`}function vo(){const e=Cn(this.opacity);return`${e===1?"rgb(":"rgba("}${nt(this.r)}, ${nt(this.g)}, ${nt(this.b)}${e===1?")":`, ${e})`}`}function Cn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function nt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function tt(e){return e=nt(e),(e<16?"0":"")+e.toString(16)}function bo(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Pe(e,t,n,r)}function Ws(e){if(e instanceof Pe)return new Pe(e.h,e.s,e.l,e.opacity);if(e instanceof Gt||(e=st(e)),!e)return new Pe;if(e instanceof Pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),s=Math.max(t,n,r),i=NaN,a=s-o,c=(s+o)/2;return a?(t===s?i=(n-r)/a+(n<r)*6:n===s?i=(r-t)/a+2:i=(t-n)/a+4,a/=c<.5?s+o:2-s-o,i*=60):a=c>0&&c<1?0:i,new Pe(i,a,c,e.opacity)}function Cu(e,t,n,r){return arguments.length===1?Ws(e):new Pe(e,t,n,r??1)}function Pe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Or(Pe,Cu,Fs(Gt,{brighter(e){return e=e==null?Mn:Math.pow(Mn,e),new Pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new Pe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new we(sr(e>=240?e-240:e+120,o,r),sr(e,o,r),sr(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new Pe(_o(this.h),un(this.s),un(this.l),Cn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Cn(this.opacity);return`${e===1?"hsl(":"hsla("}${_o(this.h)}, ${un(this.s)*100}%, ${un(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _o(e){return e=(e||0)%360,e<0?e+360:e}function un(e){return Math.max(0,Math.min(1,e||0))}function sr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Vr=e=>()=>e;function Au(e,t){return function(n){return e+n*t}}function $u(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Iu(e){return(e=+e)==1?Ys:function(t,n){return n-t?$u(t,n,e):Vr(isNaN(t)?n:t)}}function Ys(e,t){var n=t-e;return n?Au(e,n):Vr(isNaN(e)?t:e)}const An=function e(t){var n=Iu(t);function r(o,s){var i=n((o=Sr(o)).r,(s=Sr(s)).r),a=n(o.g,s.g),c=n(o.b,s.b),l=Ys(o.opacity,s.opacity);return function(d){return o.r=i(d),o.g=a(d),o.b=c(d),o.opacity=l(d),o+""}}return r.gamma=e,r}(1);function ju(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(s){for(o=0;o<n;++o)r[o]=e[o]*(1-s)+t[o]*s;return r}}function Pu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Du(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),s=new Array(n),i;for(i=0;i<r;++i)o[i]=Rt(e[i],t[i]);for(;i<n;++i)s[i]=t[i];return function(a){for(i=0;i<r;++i)s[i]=o[i](a);return s}}function Tu(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Ru(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=Rt(e[o],t[o]):r[o]=t[o];return function(s){for(o in n)r[o]=n[o](s);return r}}var kr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ir=new RegExp(kr.source,"g");function Lu(e){return function(){return e}}function zu(e){return function(t){return e(t)+""}}function Xs(e,t){var n=kr.lastIndex=ir.lastIndex=0,r,o,s,i=-1,a=[],c=[];for(e=e+"",t=t+"";(r=kr.exec(e))&&(o=ir.exec(t));)(s=o.index)>n&&(s=t.slice(n,s),a[i]?a[i]+=s:a[++i]=s),(r=r[0])===(o=o[0])?a[i]?a[i]+=o:a[++i]=o:(a[++i]=null,c.push({i,x:He(r,o)})),n=ir.lastIndex;return n<t.length&&(s=t.slice(n),a[i]?a[i]+=s:a[++i]=s),a.length<2?c[0]?zu(c[0].x):Lu(t):(t=c.length,function(l){for(var d=0,u;d<t;++d)a[(u=c[d]).i]=u.x(l);return a.join("")})}function Rt(e,t){var n=typeof t,r;return t==null||n==="boolean"?Vr(t):(n==="number"?He:n==="string"?(r=st(t))?(t=r,An):Xs:t instanceof st?An:t instanceof Date?Tu:Pu(t)?ju:Array.isArray(t)?Du:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Ru:He)(e,t)}var Eo=180/Math.PI,Mr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ks(e,t,n,r,o,s){var i,a,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:o,translateY:s,rotate:Math.atan2(t,e)*Eo,skewX:Math.atan(c)*Eo,scaleX:i,scaleY:a}}var dn;function Hu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Mr:Ks(t.a,t.b,t.c,t.d,t.e,t.f)}function Ou(e){return e==null||(dn||(dn=document.createElementNS("http://www.w3.org/2000/svg","g")),dn.setAttribute("transform",e),!(e=dn.transform.baseVal.consolidate()))?Mr:(e=e.matrix,Ks(e.a,e.b,e.c,e.d,e.e,e.f))}function qs(e,t,n,r){function o(l){return l.length?l.pop()+" ":""}function s(l,d,u,f,h,g){if(l!==u||d!==f){var w=h.push("translate(",null,t,null,n);g.push({i:w-4,x:He(l,u)},{i:w-2,x:He(d,f)})}else(u||f)&&h.push("translate("+u+t+f+n)}function i(l,d,u,f){l!==d?(l-d>180?d+=360:d-l>180&&(l+=360),f.push({i:u.push(o(u)+"rotate(",null,r)-2,x:He(l,d)})):d&&u.push(o(u)+"rotate("+d+r)}function a(l,d,u,f){l!==d?f.push({i:u.push(o(u)+"skewX(",null,r)-2,x:He(l,d)}):d&&u.push(o(u)+"skewX("+d+r)}function c(l,d,u,f,h,g){if(l!==u||d!==f){var w=h.push(o(h)+"scale(",null,",",null,")");g.push({i:w-4,x:He(l,u)},{i:w-2,x:He(d,f)})}else(u!==1||f!==1)&&h.push(o(h)+"scale("+u+","+f+")")}return function(l,d){var u=[],f=[];return l=e(l),d=e(d),s(l.translateX,l.translateY,d.translateX,d.translateY,u,f),i(l.rotate,d.rotate,u,f),a(l.skewX,d.skewX,u,f),c(l.scaleX,l.scaleY,d.scaleX,d.scaleY,u,f),l=d=null,function(h){for(var g=-1,w=f.length,x;++g<w;)u[(x=f[g]).i]=x.x(h);return u.join("")}}}var Vu=qs(Hu,"px, ","px)","deg)"),Bu=qs(Ou,", ",")",")"),Fu=1e-12;function No(e){return((e=Math.exp(e))+1/e)/2}function Wu(e){return((e=Math.exp(e))-1/e)/2}function Yu(e){return((e=Math.exp(2*e))-1)/(e+1)}const bn=function e(t,n,r){function o(s,i){var a=s[0],c=s[1],l=s[2],d=i[0],u=i[1],f=i[2],h=d-a,g=u-c,w=h*h+g*g,x,y;if(w<Fu)y=Math.log(f/l)/t,x=function(I){return[a+I*h,c+I*g,l*Math.exp(t*I*y)]};else{var E=Math.sqrt(w),m=(f*f-l*l+r*w)/(2*l*n*E),v=(f*f-l*l-r*w)/(2*f*n*E),N=Math.log(Math.sqrt(m*m+1)-m),C=Math.log(Math.sqrt(v*v+1)-v);y=(C-N)/t,x=function(I){var D=I*y,T=No(N),W=l/(n*E)*(T*Yu(t*D+N)-Wu(N));return[a+W*h,c+W*g,l*T/No(t*D+N)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return o.rho=function(s){var i=Math.max(.001,+s),a=i*i,c=a*a;return e(i,a,c)},o}(Math.SQRT2,2,4);var wt=0,Pt=0,At=0,Gs=1e3,$n,Dt,In=0,it=0,Hn=0,Vt=typeof performance=="object"&&performance.now?performance:Date,Us=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Br(){return it||(Us(Xu),it=Vt.now()+Hn)}function Xu(){it=0}function jn(){this._call=this._time=this._next=null}jn.prototype=Zs.prototype={constructor:jn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Br():+n)+(t==null?0:+t),!this._next&&Dt!==this&&(Dt?Dt._next=this:$n=this,Dt=this),this._call=e,this._time=n,Cr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Cr())}};function Zs(e,t,n){var r=new jn;return r.restart(e,t,n),r}function Ku(){Br(),++wt;for(var e=$n,t;e;)(t=it-e._time)>=0&&e._call.call(void 0,t),e=e._next;--wt}function So(){it=(In=Vt.now())+Hn,wt=Pt=0;try{Ku()}finally{wt=0,Gu(),it=0}}function qu(){var e=Vt.now(),t=e-In;t>Gs&&(Hn-=t,In=e)}function Gu(){for(var e,t=$n,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:$n=n);Dt=e,Cr(r)}function Cr(e){if(!wt){Pt&&(Pt=clearTimeout(Pt));var t=e-it;t>24?(e<1/0&&(Pt=setTimeout(So,e-Vt.now()-Hn)),At&&(At=clearInterval(At))):(At||(In=Vt.now(),At=setInterval(qu,Gs)),wt=1,Us(So))}}function ko(e,t,n){var r=new jn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Uu=Ln("start","end","cancel","interrupt"),Zu=[],Qs=0,Mo=1,Ar=2,_n=3,Co=4,$r=5,En=6;function On(e,t,n,r,o,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Qu(e,n,{name:t,index:r,group:o,on:Uu,tween:Zu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Qs})}function Fr(e,t){var n=Le(e,t);if(n.state>Qs)throw new Error("too late; already scheduled");return n}function Ve(e,t){var n=Le(e,t);if(n.state>_n)throw new Error("too late; already running");return n}function Le(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Qu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Zs(s,0,n.time);function s(l){n.state=Mo,n.timer.restart(i,n.delay,n.time),n.delay<=l&&i(l-n.delay)}function i(l){var d,u,f,h;if(n.state!==Mo)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===_n)return ko(i);h.state===Co?(h.state=En,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=En,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(ko(function(){n.state===_n&&(n.state=Co,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Ar,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ar){for(n.state=_n,o=new Array(f=n.tween.length),d=0,u=-1;d<f;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(o[++u]=h);o.length=u+1}}function a(l){for(var d=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=$r,1),u=-1,f=o.length;++u<f;)o[u].call(e,d);n.state===$r&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=En,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Nn(e,t){var n=e.__transition,r,o,s=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){s=!1;continue}o=r.state>Ar&&r.state<$r,r.state=En,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}s&&delete e.__transition}}function Ju(e){return this.each(function(){Nn(this,e)})}function ed(e,t){var n,r;return function(){var o=Ve(this,e),s=o.tween;if(s!==n){r=n=s;for(var i=0,a=r.length;i<a;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}o.tween=r}}function td(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=Ve(this,e),i=s.tween;if(i!==r){o=(r=i).slice();for(var a={name:t,value:n},c=0,l=o.length;c<l;++c)if(o[c].name===t){o[c]=a;break}c===l&&o.push(a)}s.tween=o}}function nd(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Le(this.node(),n).tween,o=0,s=r.length,i;o<s;++o)if((i=r[o]).name===e)return i.value;return null}return this.each((t==null?ed:td)(n,e,t))}function Wr(e,t,n){var r=e._id;return e.each(function(){var o=Ve(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Le(o,r).value[t]}}function Js(e,t){var n;return(typeof t=="number"?He:t instanceof st?An:(n=st(t))?(t=n,An):Xs)(e,t)}function rd(e){return function(){this.removeAttribute(e)}}function od(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sd(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttribute(e);return i===o?null:i===r?s:s=t(r=i,n)}}function id(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttributeNS(e.space,e.local);return i===o?null:i===r?s:s=t(r=i,n)}}function ad(e,t,n){var r,o,s;return function(){var i,a=n(this),c;return a==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=a+"",i===c?null:i===r&&c===o?s:(o=c,s=t(r=i,a)))}}function cd(e,t,n){var r,o,s;return function(){var i,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=a+"",i===c?null:i===r&&c===o?s:(o=c,s=t(r=i,a)))}}function ld(e,t){var n=zn(e),r=n==="transform"?Bu:Js;return this.attrTween(e,typeof t=="function"?(n.local?cd:ad)(n,r,Wr(this,"attr."+e,t)):t==null?(n.local?od:rd)(n):(n.local?id:sd)(n,r,t))}function ud(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function dd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function fd(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&dd(e,s)),n}return o._value=t,o}function hd(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&ud(e,s)),n}return o._value=t,o}function gd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=zn(e);return this.tween(n,(r.local?fd:hd)(r,t))}function pd(e,t){return function(){Fr(this,e).delay=+t.apply(this,arguments)}}function md(e,t){return t=+t,function(){Fr(this,e).delay=t}}function yd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pd:md)(t,e)):Le(this.node(),t).delay}function xd(e,t){return function(){Ve(this,e).duration=+t.apply(this,arguments)}}function wd(e,t){return t=+t,function(){Ve(this,e).duration=t}}function vd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?xd:wd)(t,e)):Le(this.node(),t).duration}function bd(e,t){if(typeof t!="function")throw new Error;return function(){Ve(this,e).ease=t}}function _d(e){var t=this._id;return arguments.length?this.each(bd(t,e)):Le(this.node(),t).ease}function Ed(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ve(this,e).ease=n}}function Nd(e){if(typeof e!="function")throw new Error;return this.each(Ed(this._id,e))}function Sd(e){typeof e!="function"&&(e=$s(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=[],c,l=0;l<i;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new Ye(r,this._parents,this._name,this._id)}function kd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,s=Math.min(r,o),i=new Array(r),a=0;a<s;++a)for(var c=t[a],l=n[a],d=c.length,u=i[a]=new Array(d),f,h=0;h<d;++h)(f=c[h]||l[h])&&(u[h]=f);for(;a<r;++a)i[a]=t[a];return new Ye(i,this._parents,this._name,this._id)}function Md(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Cd(e,t,n){var r,o,s=Md(t)?Fr:Ve;return function(){var i=s(this,e),a=i.on;a!==r&&(o=(r=a).copy()).on(t,n),i.on=o}}function Ad(e,t){var n=this._id;return arguments.length<2?Le(this.node(),n).on.on(e):this.each(Cd(n,e,t))}function $d(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Id(){return this.on("end.remove",$d(this._id))}function jd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=zr(e));for(var r=this._groups,o=r.length,s=new Array(o),i=0;i<o;++i)for(var a=r[i],c=a.length,l=s[i]=new Array(c),d,u,f=0;f<c;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),l[f]=u,On(l[f],t,n,f,l,Le(d,n)));return new Ye(s,this._parents,t,n)}function Pd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=As(e));for(var r=this._groups,o=r.length,s=[],i=[],a=0;a<o;++a)for(var c=r[a],l=c.length,d,u=0;u<l;++u)if(d=c[u]){for(var f=e.call(d,d.__data__,u,c),h,g=Le(d,n),w=0,x=f.length;w<x;++w)(h=f[w])&&On(h,t,n,w,f,g);s.push(f),i.push(d)}return new Ye(s,i,t,n)}var Dd=qt.prototype.constructor;function Td(){return new Dd(this._groups,this._parents)}function Rd(e,t){var n,r,o;return function(){var s=xt(this,e),i=(this.style.removeProperty(e),xt(this,e));return s===i?null:s===n&&i===r?o:o=t(n=s,r=i)}}function ei(e){return function(){this.style.removeProperty(e)}}function Ld(e,t,n){var r,o=n+"",s;return function(){var i=xt(this,e);return i===o?null:i===r?s:s=t(r=i,n)}}function zd(e,t,n){var r,o,s;return function(){var i=xt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),xt(this,e))),i===c?null:i===r&&c===o?s:(o=c,s=t(r=i,a))}}function Hd(e,t){var n,r,o,s="style."+t,i="end."+s,a;return function(){var c=Ve(this,e),l=c.on,d=c.value[s]==null?a||(a=ei(t)):void 0;(l!==n||o!==d)&&(r=(n=l).copy()).on(i,o=d),c.on=r}}function Od(e,t,n){var r=(e+="")=="transform"?Vu:Js;return t==null?this.styleTween(e,Rd(e,r)).on("end.style."+e,ei(e)):typeof t=="function"?this.styleTween(e,zd(e,r,Wr(this,"style."+e,t))).each(Hd(this._id,e)):this.styleTween(e,Ld(e,r,t),n).on("end.style."+e,null)}function Vd(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Bd(e,t,n){var r,o;function s(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&Vd(e,i,n)),r}return s._value=t,s}function Fd(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 new Error;return this.tween(r,Bd(e,t,n??""))}function Wd(e){return function(){this.textContent=e}}function Yd(e){return function(){var t=e(this);this.textContent=t??""}}function Xd(e){return this.tween("text",typeof e=="function"?Yd(Wr(this,"text",e)):Wd(e==null?"":e+""))}function Kd(e){return function(t){this.textContent=e.call(this,t)}}function qd(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Kd(o)),t}return r._value=e,r}function Gd(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,qd(e))}function Ud(){for(var e=this._name,t=this._id,n=ti(),r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],a=i.length,c,l=0;l<a;++l)if(c=i[l]){var d=Le(c,t);On(c,e,n,l,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ye(r,this._parents,e,n)}function Zd(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(s,i){var a={value:i},c={value:function(){--o===0&&s()}};n.each(function(){var l=Ve(this,r),d=l.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),o===0&&s()})}var Qd=0;function Ye(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ti(){return++Qd}var Fe=qt.prototype;Ye.prototype={constructor:Ye,select:jd,selectAll:Pd,selectChild:Fe.selectChild,selectChildren:Fe.selectChildren,filter:Sd,merge:kd,selection:Td,transition:Ud,call:Fe.call,nodes:Fe.nodes,node:Fe.node,size:Fe.size,empty:Fe.empty,each:Fe.each,on:Ad,attr:ld,attrTween:gd,style:Od,styleTween:Fd,text:Xd,textTween:Gd,remove:Id,tween:nd,delay:yd,duration:vd,ease:_d,easeVarying:Nd,end:Zd,[Symbol.iterator]:Fe[Symbol.iterator]};function Jd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ef={time:null,delay:0,duration:250,ease:Jd};function tf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function nf(e){var t,n;e instanceof Ye?(t=e._id,e=e._name):(t=ti(),(n=ef).time=Br(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],a=i.length,c,l=0;l<a;++l)(c=i[l])&&On(c,e,t,l,i,n||tf(c,t));return new Ye(r,this._parents,e,t)}qt.prototype.interrupt=Ju;qt.prototype.transition=nf;const fn=e=>()=>e;function rf(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){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:o}})}function We(e,t,n){this.k=e,this.x=t,this.y=n}We.prototype={constructor:We,scale:function(e){return e===1?this:new We(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new We(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 Vn=new We(1,0,0);ni.prototype=We.prototype;function ni(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Vn;return e.__zoom}function ar(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function of(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function sf(){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 Ao(){return this.__zoom||Vn}function af(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function cf(){return navigator.maxTouchPoints||"ontouchstart"in this}function lf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function ri(){var e=of,t=sf,n=lf,r=af,o=cf,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=bn,l=Ln("start","zoom","end"),d,u,f,h=500,g=150,w=0,x=10;function y(_){_.property("__zoom",Ao).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",W).filter(o).on("touchstart.zoom",M).on("touchmove.zoom",k).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,$,S,P){var R=_.selection?_.selection():_;R.property("__zoom",Ao),_!==R?N(_,$,S,P):R.interrupt().each(function(){C(this,arguments).event(P).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},y.scaleBy=function(_,$,S,P){y.scaleTo(_,function(){var R=this.__zoom.k,A=typeof $=="function"?$.apply(this,arguments):$;return R*A},S,P)},y.scaleTo=function(_,$,S,P){y.transform(_,function(){var R=t.apply(this,arguments),A=this.__zoom,V=S==null?v(R):typeof S=="function"?S.apply(this,arguments):S,B=A.invert(V),O=typeof $=="function"?$.apply(this,arguments):$;return n(m(E(A,O),V,B),R,i)},S,P)},y.translateBy=function(_,$,S,P){y.transform(_,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),i)},null,P)},y.translateTo=function(_,$,S,P,R){y.transform(_,function(){var A=t.apply(this,arguments),V=this.__zoom,B=P==null?v(A):typeof P=="function"?P.apply(this,arguments):P;return n(Vn.translate(B[0],B[1]).scale(V.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof S=="function"?-S.apply(this,arguments):-S),A,i)},P,R)};function E(_,$){return $=Math.max(s[0],Math.min(s[1],$)),$===_.k?_:new We($,_.x,_.y)}function m(_,$,S){var P=$[0]-S[0]*_.k,R=$[1]-S[1]*_.k;return P===_.x&&R===_.y?_:new We(_.k,P,R)}function v(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function N(_,$,S,P){_.on("start.zoom",function(){C(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(P).end()}).tween("zoom",function(){var R=this,A=arguments,V=C(R,A).event(P),B=t.apply(R,A),O=S==null?v(B):typeof S=="function"?S.apply(R,A):S,Y=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),K=R.__zoom,J=typeof $=="function"?$.apply(R,A):$,ne=c(K.invert(O).concat(Y/K.k),J.invert(O).concat(Y/J.k));return function(X){if(X===1)X=J;else{var H=ne(X),F=Y/H[2];X=new We(F,O[0]-H[0]*F,O[1]-H[1]*F)}V.zoom(null,X)}})}function C(_,$,S){return!S&&_.__zooming||new I(_,$)}function I(_,$){this.that=_,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,$),this.taps=0}I.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,$){return this.mouse&&_!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var $=Ee(this.that).datum();l.call(_,this.that,new rf(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),$)}};function D(_,...$){if(!e.apply(this,arguments))return;var S=C(this,$).event(_),P=this.__zoom,R=Math.max(s[0],Math.min(s[1],P.k*Math.pow(2,r.apply(this,arguments)))),A=je(_);if(S.wheel)(S.mouse[0][0]!==A[0]||S.mouse[0][1]!==A[1])&&(S.mouse[1]=P.invert(S.mouse[0]=A)),clearTimeout(S.wheel);else{if(P.k===R)return;S.mouse=[A,P.invert(A)],Nn(this),S.start()}$t(_),S.wheel=setTimeout(V,g),S.zoom("mouse",n(m(E(P,R),S.mouse[0],S.mouse[1]),S.extent,i));function V(){S.wheel=null,S.end()}}function T(_,...$){if(f||!e.apply(this,arguments))return;var S=_.currentTarget,P=C(this,$,!0).event(_),R=Ee(_.view).on("mousemove.zoom",O,!0).on("mouseup.zoom",Y,!0),A=je(_,S),V=_.clientX,B=_.clientY;Os(_.view),ar(_),P.mouse=[A,this.__zoom.invert(A)],Nn(this),P.start();function O(K){if($t(K),!P.moved){var J=K.clientX-V,ne=K.clientY-B;P.moved=J*J+ne*ne>w}P.event(K).zoom("mouse",n(m(P.that.__zoom,P.mouse[0]=je(K,S),P.mouse[1]),P.extent,i))}function Y(K){R.on("mousemove.zoom mouseup.zoom",null),Vs(K.view,P.moved),$t(K),P.event(K).end()}}function W(_,...$){if(e.apply(this,arguments)){var S=this.__zoom,P=je(_.changedTouches?_.changedTouches[0]:_,this),R=S.invert(P),A=S.k*(_.shiftKey?.5:2),V=n(m(E(S,A),P,R),t.apply(this,$),i);$t(_),a>0?Ee(this).transition().duration(a).call(N,V,P,_):Ee(this).call(y.transform,V,P,_)}}function M(_,...$){if(e.apply(this,arguments)){var S=_.touches,P=S.length,R=C(this,$,_.changedTouches.length===P).event(_),A,V,B,O;for(ar(_),V=0;V<P;++V)B=S[V],O=je(B,this),O=[O,this.__zoom.invert(O),B.identifier],R.touch0?!R.touch1&&R.touch0[2]!==O[2]&&(R.touch1=O,R.taps=0):(R.touch0=O,A=!0,R.taps=1+!!d);d&&(d=clearTimeout(d)),A&&(R.taps<2&&(u=O[0],d=setTimeout(function(){d=null},h)),Nn(this),R.start())}}function k(_,...$){if(this.__zooming){var S=C(this,$).event(_),P=_.changedTouches,R=P.length,A,V,B,O;for($t(_),A=0;A<R;++A)V=P[A],B=je(V,this),S.touch0&&S.touch0[2]===V.identifier?S.touch0[0]=B:S.touch1&&S.touch1[2]===V.identifier&&(S.touch1[0]=B);if(V=S.that.__zoom,S.touch1){var Y=S.touch0[0],K=S.touch0[1],J=S.touch1[0],ne=S.touch1[1],X=(X=J[0]-Y[0])*X+(X=J[1]-Y[1])*X,H=(H=ne[0]-K[0])*H+(H=ne[1]-K[1])*H;V=E(V,Math.sqrt(X/H)),B=[(Y[0]+J[0])/2,(Y[1]+J[1])/2],O=[(K[0]+ne[0])/2,(K[1]+ne[1])/2]}else if(S.touch0)B=S.touch0[0],O=S.touch0[1];else return;S.zoom("touch",n(m(V,B,O),S.extent,i))}}function L(_,...$){if(this.__zooming){var S=C(this,$).event(_),P=_.changedTouches,R=P.length,A,V;for(ar(_),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),A=0;A<R;++A)V=P[A],S.touch0&&S.touch0[2]===V.identifier?delete S.touch0:S.touch1&&S.touch1[2]===V.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(V=je(V,this),Math.hypot(u[0]-V[0],u[1]-V[1])<x)){var B=Ee(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(r=typeof _=="function"?_:fn(+_),y):r},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:fn(!!_),y):e},y.touchable=function(_){return arguments.length?(o=typeof _=="function"?_:fn(!!_),y):o},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:fn([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),y):t},y.scaleExtent=function(_){return arguments.length?(s[0]=+_[0],s[1]=+_[1],y):[s[0],s[1]]},y.translateExtent=function(_){return arguments.length?(i[0][0]=+_[0][0],i[1][0]=+_[1][0],i[0][1]=+_[0][1],i[1][1]=+_[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(_){return arguments.length?(n=_,y):n},y.duration=function(_){return arguments.length?(a=+_,y):a},y.interpolate=function(_){return arguments.length?(c=_,y):c},y.on=function(){var _=l.on.apply(l,arguments);return _===l?y:_},y.clickDistance=function(_){return arguments.length?(w=(_=+_)*_,y):Math.sqrt(w)},y.tapDistance=function(_){return arguments.length?(x=+_,y):x},y}const Re={error001:(e="react")=>`Seems like you have not used zustand provider 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.`},Bt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],oi=["Enter"," ","Escape"],si={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var vt;(function(e){e.Strict="strict",e.Loose="loose"})(vt||(vt={}));var rt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(rt||(rt={}));var Ft;(function(e){e.Partial="partial",e.Full="full"})(Ft||(Ft={}));const ii={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ue;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ue||(Ue={}));var Wt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Wt||(Wt={}));var Q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Q||(Q={}));const $o={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function ai(e){return e===null?null:e?"valid":"invalid"}const ci=e=>"id"in e&&"source"in e&&"target"in e,uf=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Yr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ut=(e,t=[0,0])=>{const{width:n,height:r}=Ke(e),o=e.origin??t,s=n*o[0],i=r*o[1];return{x:e.position.x-s,y:e.position.y-i}},df=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const s=typeof o=="string";let i=!t.nodeLookup&&!s?o:void 0;t.nodeLookup&&(i=s?t.nodeLookup.get(o):Yr(o)?o:t.nodeLookup.get(o.id));const a=i?Pn(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Bn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Fn(n)},Zt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=Bn(n,Pn(o)),r=!0)}),r?Fn(n):{x:0,y:0,width:0,height:0}},Xr=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1)=>{const a={...Mt(t,[n,r,o]),width:t.width/o,height:t.height/o},c=[];for(const l of e.values()){const{measured:d,selectable:u=!0,hidden:f=!1}=l;if(i&&!u||f)continue;const h=d.width??l.width??l.initialWidth??null,g=d.height??l.height??l.initialHeight??null,w=Yt(a,_t(l)),x=(h??0)*(g??0),y=s&&w>0;(!l.internals.handleBounds||y||w>=x||l.dragging)&&c.push(l)}return c},ff=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function hf(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function gf({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:s},i){if(e.size===0)return!0;const a=hf(e,i),c=Zt(a),l=qr(c,t,n,(i==null?void 0:i.minZoom)??o,(i==null?void 0:i.maxZoom)??s,(i==null?void 0:i.padding)??.1);return await r.setViewport(l,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),!0}function li({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:s}){const i=n.get(e),a=i.parentId?n.get(i.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},d=i.origin??r;let u=i.extent||o;if(i.extent==="parent"&&!i.expandParent)if(!a)s==null||s("005",Re.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[c,l],[c+h,l+g]])}else a&&ct(i.extent)&&(u=[[i.extent[0][0]+c,i.extent[0][1]+l],[i.extent[1][0]+c,i.extent[1][1]+l]]);const f=ct(u)?at(t,u,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&(s==null||s("015",Re.error015())),{position:{x:f.x-c+(i.measured.width??0)*d[0],y:f.y-l+(i.measured.height??0)*d[1]},positionAbsolute:f}}async function pf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const s=new Set(e.map(f=>f.id)),i=[];for(const f of n){if(f.deletable===!1)continue;const h=s.has(f.id),g=!h&&f.parentId&&i.find(w=>w.id===f.parentId);(h||g)&&i.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),d=ff(i,c);for(const f of c)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!o)return{edges:d,nodes:i};const u=await o({nodes:i,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:i}:{edges:[],nodes:[]}:u}const bt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),at=(e={x:0,y:0},t,n)=>({x:bt(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:bt(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ui(e,t,n){const{width:r,height:o}=Ke(n),{x:s,y:i}=n.internals.positionAbsolute;return at(e,[[s,i],[s+r,i+o]],t)}const Io=(e,t,n)=>e<t?bt(Math.abs(e-t),1,t)/t:e>n?-bt(Math.abs(e-n),1,t)/t:0,Kr=(e,t,n=15,r=40)=>{const o=Io(e.x,r,t.width-r)*n,s=Io(e.y,r,t.height-r)*n;return[o,s]},Bn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Ir=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Fn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),_t=(e,t=[0,0])=>{var o,s;const{x:n,y:r}=Yr(e)?e.internals.positionAbsolute:Ut(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}},Pn=(e,t=[0,0])=>{var o,s;const{x:n,y:r}=Yr(e)?e.internals.positionAbsolute:Ut(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0)}},di=(e,t)=>Fn(Bn(Ir(e),Ir(t))),Yt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},jo=e=>De(e.width)&&De(e.height)&&De(e.x)&&De(e.y),De=e=>!isNaN(e)&&isFinite(e),fi=(e,t)=>(n,r)=>{},Qt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Mt=({x:e,y:t},[n,r,o],s=!1,i=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return s?Qt(a,i):a},Et=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function ht(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function mf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ht(e,n),o=ht(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=ht(e.top??e.y??0,n),o=ht(e.bottom??e.y??0,n),s=ht(e.left??e.x??0,t),i=ht(e.right??e.x??0,t);return{top:r,right:i,bottom:o,left:s,x:s+i,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function yf(e,t,n,r,o,s){const{x:i,y:a}=Et(e,[t,n,r]),{x:c,y:l}=Et({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=o-c,u=s-l;return{left:Math.floor(i),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}const qr=(e,t,n,r,o,s)=>{const i=mf(s,t,n),a=(t-i.x)/e.width,c=(n-i.y)/e.height,l=Math.min(a,c),d=bt(l,r,o),u=e.x+e.width/2,f=e.y+e.height/2,h=t/2-u*d,g=n/2-f*d,w=yf(e,h,g,d,t,n),x={left:Math.min(w.left-i.left,0),top:Math.min(w.top-i.top,0),right:Math.min(w.right-i.right,0),bottom:Math.min(w.bottom-i.bottom,0)};return{x:h-x.left+x.right,y:g-x.top+x.bottom,zoom:d}},Xt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function ct(e){return e!=null&&e!=="parent"}function Ke(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function hi(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function gi(e,t={width:0,height:0},n,r,o){const s={...e},i=r.get(n);if(i){const a=i.origin||o;s.x+=i.internals.positionAbsolute.x-(t.width??0)*a[0],s.y+=i.internals.positionAbsolute.y-(t.height??0)*a[1]}return s}function Po(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function xf(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function wf(e){return{...si,...e||{}}}function Lt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:s,y:i}=Te(e),a=Mt({x:s-((o==null?void 0:o.left)??0),y:i-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?Qt(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Gr=e=>({width:e.offsetWidth,height:e.offsetHeight}),pi=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},vf=["INPUT","SELECT","TEXTAREA"];function mi(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:vf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const yi=e=>"clientX"in e,Te=(e,t)=>{var s,i;const n=yi(e),r=n?e.clientX:(s=e.touches)==null?void 0:s[0].clientX,o=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},Do=(e,t,n,r,o)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(i=>{const a=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:o,position:i.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Gr(i)}})};function xi({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:a}){const c=e*.125+o*.375+i*.375+n*.125,l=t*.125+s*.375+a*.375+r*.125,d=Math.abs(c-e),u=Math.abs(l-t);return[c,l,d,u]}function hn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function To({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case Q.Left:return[t-hn(t-r,s),n];case Q.Right:return[t+hn(r-t,s),n];case Q.Top:return[t,n-hn(n-o,s)];case Q.Bottom:return[t,n+hn(o-n,s)]}}function wi({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:o,targetPosition:s=Q.Top,curvature:i=.25}){const[a,c]=To({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[l,d]=To({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[u,f,h,g]=xi({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${a},${c} ${l},${d} ${r},${o}`,u,f,h,g]}function vi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,s=n<e?n+o:n-o,i=Math.abs(r-t)/2,a=r<t?r+i:r-i;return[s,a,o,i]}function bf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:s="basic"}){if(s==="manual")return r;const i=o&&n?r+1e3:r,a=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return i+a}function _f({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const s=Bn(Pn(e),Pn(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const i={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return Yt(i,Fn(s))>0}const Ef=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Nf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Sf=(e,t,n={})=>{var s;if(!e.source||!e.target)return(s=n.onError)==null||s.call(n,"006",Re.error006()),t;const r=n.getEdgeId||Ef;let o;return ci(e)?o={...e}:o={...e,id:r(e)},Nf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function bi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,a]=vi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,a]}const Ro={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},kf=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Lo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Mf({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:o,offset:s,stepPosition:i}){const a=Ro[t],c=Ro[r],l={x:e.x+a.x*s,y:e.y+a.y*s},d={x:n.x+c.x*s,y:n.y+c.y*s},u=kf({source:l,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],w,x;const y={x:0,y:0},E={x:0,y:0},[,,m,v]=vi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(w=o.x??l.x+(d.x-l.x)*i,x=o.y??(l.y+d.y)/2):(w=o.x??(l.x+d.x)/2,x=o.y??l.y+(d.y-l.y)*i);const D=[{x:w,y:l.y},{x:w,y:d.y}],T=[{x:l.x,y:x},{x:d.x,y:x}];a[f]===h?g=f==="x"?D:T:g=f==="x"?T:D}else{const D=[{x:l.x,y:d.y}],T=[{x:d.x,y:l.y}];if(f==="x"?g=a.x===h?T:D:g=a.y===h?D:T,t===r){const _=Math.abs(e[f]-n[f]);if(_<=s){const $=Math.min(s-1,s-_);a[f]===h?y[f]=(l[f]>e[f]?-1:1)*$:E[f]=(d[f]>n[f]?-1:1)*$}}if(t!==r){const _=f==="x"?"y":"x",$=a[f]===c[_],S=l[_]>d[_],P=l[_]<d[_];(a[f]===1&&(!$&&S||$&&P)||a[f]!==1&&(!$&&P||$&&S))&&(g=f==="x"?D:T)}const W={x:l.x+y.x,y:l.y+y.y},M={x:d.x+E.x,y:d.y+E.y},k=Math.max(Math.abs(W.x-g[0].x),Math.abs(M.x-g[0].x)),L=Math.max(Math.abs(W.y-g[0].y),Math.abs(M.y-g[0].y));k>=L?(w=(W.x+M.x)/2,x=g[0].y):(w=g[0].x,x=(W.y+M.y)/2)}const N={x:l.x+y.x,y:l.y+y.y},C={x:d.x+E.x,y:d.y+E.y};return[[e,...N.x!==g[0].x||N.y!==g[0].y?[N]:[],...g,...C.x!==g[g.length-1].x||C.y!==g[g.length-1].y?[C]:[],n],w,x,m,v]}function Cf(e,t,n,r){const o=Math.min(Lo(e,t)/2,Lo(t,n)/2,r),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i){const l=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${s+o*l},${i}Q ${s},${i} ${s},${i+o*d}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${s},${i+o*c}Q ${s},${i} ${s+o*a},${i}`}function jr({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:o,targetPosition:s=Q.Top,borderRadius:i=5,centerX:a,centerY:c,offset:l=20,stepPosition:d=.5}){const[u,f,h,g,w]=Mf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:a,y:c},offset:l,stepPosition:d});let x=`M${u[0].x} ${u[0].y}`;for(let y=1;y<u.length-1;y++)x+=Cf(u[y-1],u[y],u[y+1],i);return x+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[x,f,h,g,w]}function zo(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Af(e){var u;const{sourceNode:t,targetNode:n}=e;if(!zo(t)||!zo(n))return null;const r=t.internals.handleBounds||Ho(t.handles),o=n.internals.handleBounds||Ho(n.handles),s=Oo((r==null?void 0:r.source)??[],e.sourceHandle),i=Oo(e.connectionMode===vt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!s||!i)return(u=e.onError)==null||u.call(e,"008",Re.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(s==null?void 0:s.position)||Q.Bottom,c=(i==null?void 0:i.position)||Q.Top,l=lt(t,s,a),d=lt(n,i,c);return{sourceX:l.x,sourceY:l.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:c}}function Ho(e){if(!e)return null;const t=[],n=[];for(const 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 lt(e,t,n=Q.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,s=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:i,height:a}=t??Ke(e);if(r)return{x:o+i/2,y:s+a/2};switch((t==null?void 0:t.position)??n){case Q.Top:return{x:o+i/2,y:s};case Q.Right:return{x:o+i,y:s+a/2};case Q.Bottom:return{x:o+i/2,y:s+a};case Q.Left:return{x:o,y:s+a/2}}}function Oo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Pr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function $f(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const s=new Set;return e.reduce((i,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const l=Pr(c,t);s.has(l)||(i.push({id:l,color:c.color||n,...c}),s.add(l))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))}const _i=1e3,If=10,Ur={nodeOrigin:[0,0],nodeExtent:Bt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},jf={...Ur,checkEquality:!0};function Zr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Pf(e,t,n){const r=Zr(Ur,n);for(const o of e.values())if(o.parentId)Jr(o,e,t,r);else{const s=Ut(o,r.nodeOrigin),i=ct(o.extent)?o.extent:r.nodeExtent,a=at(s,i,Ke(o));o.internals.positionAbsolute=a}}function Df(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const s={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(s):o.type==="target"&&r.push(s)}return{source:n,target:r}}function Qr(e){return e==="manual"}function Dr(e,t,n,r={}){var d,u;const o=Zr(jf,r),s={i:0},i=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!Qr(o.zIndexMode)?_i:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let h=i.get(f.id);if(o.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const g=Ut(f,o.nodeOrigin),w=ct(f.extent)?f.extent:o.nodeExtent,x=at(g,w,Ke(f));h={...o.defaults,...f,measured:{width:(d=f.measured)==null?void 0:d.width,height:(u=f.measured)==null?void 0:u.height},internals:{positionAbsolute:x,handleBounds:Df(f,h),z:Ei(f,a,o.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),f.parentId&&Jr(h,t,n,r,s),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function Tf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Jr(e,t,n,r,o){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:a,zIndexMode:c}=Zr(Ur,r),l=e.parentId,d=t.get(l);if(!d){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}Tf(e,n),o&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++o.i,d.internals.z=d.internals.z+o.i*If),o&&d.internals.rootParentIndex!==void 0&&(o.i=d.internals.rootParentIndex);const u=s&&!Qr(c)?_i:0,{x:f,y:h,z:g}=Rf(e,d,i,a,u,c),{positionAbsolute:w}=e.internals,x=f!==w.x||h!==w.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:w,z:g}})}function Ei(e,t,n){const r=De(e.zIndex)?e.zIndex:0;return Qr(n)?r:r+(e.selected?t:0)}function Rf(e,t,n,r,o,s){const{x:i,y:a}=t.internals.positionAbsolute,c=Ke(e),l=Ut(e,n),d=ct(e.extent)?at(l,e.extent,c):l;let u=at({x:i+d.x,y:a+d.y},r,c);e.extent==="parent"&&(u=ui(u,c,t));const f=Ei(e,o,s),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function eo(e,t,n,r=[0,0]){var i;const o=[],s=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((i=s.get(a.parentId))==null?void 0:i.expandedRect)??_t(c),d=di(l,a.rect);s.set(a.parentId,{expandedRect:d,parent:c})}return s.size>0&&s.forEach(({expandedRect:a,parent:c},l)=>{var m;const d=c.internals.positionAbsolute,u=Ke(c),f=c.origin??r,h=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,g=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,w=Math.max(u.width,Math.round(a.width)),x=Math.max(u.height,Math.round(a.height)),y=(w-u.width)*f[0],E=(x-u.height)*f[1];(h>0||g>0||y||E)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+y,y:c.position.y-g+E}}),(m=n.get(l))==null||m.forEach(v=>{e.some(N=>N.id===v.id)||o.push({id:v.id,type:"position",position:{x:v.position.x+h,y:v.position.y+g}})})),(u.width<a.width||u.height<a.height||h||g)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:w+(h?f[0]*h-y:0),height:x+(g?f[1]*g-E:0)}})}),o}function Lf(e,t,n,r,o,s,i){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],d=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const w=Gr(h.nodeElement),x=g.measured.width!==w.width||g.measured.height!==w.height;if(!!(w.width&&w.height&&(x||!g.internals.handleBounds||h.force))){const E=h.nodeElement.getBoundingClientRect(),m=ct(g.extent)?g.extent:s;let{positionAbsolute:v}=g.internals;g.parentId&&g.extent==="parent"?v=ui(v,w,t.get(g.parentId)):m&&(v=at(v,m,w));const N={...g,measured:w,internals:{...g.internals,positionAbsolute:v,handleBounds:{source:Do("source",h.nodeElement,E,u,g.id),target:Do("target",h.nodeElement,E,u,g.id)}}};t.set(g.id,N),g.parentId&&Jr(N,t,n,{nodeOrigin:o,zIndexMode:i}),c=!0,x&&(l.push({id:g.id,type:"dimensions",dimensions:w}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:_t(N,o)}))}}if(f.length>0){const h=eo(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function zf({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:s}){if(!t||!e.x&&!e.y)return!1;const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,s]],r);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function Vo(e,t,n,r,o,s){let i=o;const a=r.get(i)||new Map;r.set(i,a.set(n,t)),i=`${o}-${e}`;const c=r.get(i)||new Map;if(r.set(i,c.set(n,t)),s){i=`${o}-${e}-${s}`;const l=r.get(i)||new Map;r.set(i,l.set(n,t))}}function Ni(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:s,sourceHandle:i=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:s,sourceHandle:i,targetHandle:a},l=`${o}-${i}--${s}-${a}`,d=`${s}-${a}--${o}-${i}`;Vo("source",c,d,e,o,i),Vo("target",c,l,e,s,a),t.set(r.id,r)}}function Si(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Si(n,t):!1}function Bo(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Hf(e,t,n,r){const o=new Map;for(const[s,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!Si(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const a=e.get(s);a&&o.set(s,{id:s,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function cr({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var i,a,c;const o=[];for(const[l,d]of t){const u=(i=n.get(l))==null?void 0:i.internals.userNode;u&&o.push({...u,position:d.position,dragging:r})}if(!e)return[o[0],o];const s=(a=n.get(e))==null?void 0:a.internals.userNode;return[s?{...s,position:((c=t.get(e))==null?void 0:c.position)||s.position,dragging:r}:o[0],o]}function Of({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const s={x:n-o.distance.x,y:r-o.distance.y},i=Qt(s,t);return{x:i.x-s.x,y:i.y-s.y}}function Vf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let s={x:null,y:null},i=0,a=new Map,c=!1,l={x:0,y:0},d=null,u=!1,f=null,h=!1,g=!1,w=null;function x({noDragClassName:E,handleSelector:m,domNode:v,isSelectable:N,nodeId:C,nodeClickDistance:I=0}){f=Ee(v);function D({x:k,y:L}){const{nodeLookup:_,nodeExtent:$,snapGrid:S,snapToGrid:P,nodeOrigin:R,onNodeDrag:A,onSelectionDrag:V,onError:B,updateNodePositions:O}=t();s={x:k,y:L};let Y=!1;const K=a.size>1,J=K&&$?Ir(Zt(a)):null,ne=K&&P?Of({dragItems:a,snapGrid:S,x:k,y:L}):null;for(const[X,H]of a){if(!_.has(X))continue;let F={x:k-H.distance.x,y:L-H.distance.y};P&&(F=ne?{x:Math.round(F.x+ne.x),y:Math.round(F.y+ne.y)}:Qt(F,S));let te=null;if(K&&$&&!H.extent&&J){const{positionAbsolute:q}=H.internals,re=q.x-J.x+$[0][0],ie=q.x+H.measured.width-J.x2+$[1][0],ae=q.y-J.y+$[0][1],ce=q.y+H.measured.height-J.y2+$[1][1];te=[[re,ae],[ie,ce]]}const{position:ee,positionAbsolute:Z}=li({nodeId:X,nextPosition:F,nodeLookup:_,nodeExtent:te||$,nodeOrigin:R,onError:B});Y=Y||H.position.x!==ee.x||H.position.y!==ee.y,H.position=ee,H.internals.positionAbsolute=Z}if(g=g||Y,!!Y&&(O(a,!0),w&&(r||A||!C&&V))){const[X,H]=cr({nodeId:C,dragItems:a,nodeLookup:_});r==null||r(w,a,X,H),A==null||A(w,X,H),C||V==null||V(w,H)}}async function T(){if(!d)return;const{transform:k,panBy:L,autoPanSpeed:_,autoPanOnNodeDrag:$}=t();if(!$){c=!1,cancelAnimationFrame(i);return}const[S,P]=Kr(l,d,_);(S!==0||P!==0)&&(s.x=(s.x??0)-S/k[2],s.y=(s.y??0)-P/k[2],await L({x:S,y:P})&&D(s)),i=requestAnimationFrame(T)}function W(k){var K;const{nodeLookup:L,multiSelectionActive:_,nodesDraggable:$,transform:S,snapGrid:P,snapToGrid:R,selectNodesOnDrag:A,onNodeDragStart:V,onSelectionDragStart:B,unselectNodesAndEdges:O}=t();u=!0,(!A||!N)&&!_&&C&&((K=L.get(C))!=null&&K.selected||O()),N&&A&&C&&(e==null||e(C));const Y=Lt(k.sourceEvent,{transform:S,snapGrid:P,snapToGrid:R,containerBounds:d});if(s=Y,a=Hf(L,$,Y,C),a.size>0&&(n||V||!C&&B)){const[J,ne]=cr({nodeId:C,dragItems:a,nodeLookup:L});n==null||n(k.sourceEvent,a,J,ne),V==null||V(k.sourceEvent,J,ne),C||B==null||B(k.sourceEvent,ne)}}const M=Bs().clickDistance(I).on("start",k=>{const{domNode:L,nodeDragThreshold:_,transform:$,snapGrid:S,snapToGrid:P}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,h=!1,g=!1,w=k.sourceEvent,_===0&&W(k),s=Lt(k.sourceEvent,{transform:$,snapGrid:S,snapToGrid:P,containerBounds:d}),l=Te(k.sourceEvent,d)}).on("drag",k=>{const{autoPanOnNodeDrag:L,transform:_,snapGrid:$,snapToGrid:S,nodeDragThreshold:P,nodeLookup:R}=t(),A=Lt(k.sourceEvent,{transform:_,snapGrid:$,snapToGrid:S,containerBounds:d});if(w=k.sourceEvent,(k.sourceEvent.type==="touchmove"&&k.sourceEvent.touches.length>1||C&&!R.has(C))&&(h=!0),!h){if(!c&&L&&u&&(c=!0,T()),!u){const V=Te(k.sourceEvent,d),B=V.x-l.x,O=V.y-l.y;Math.sqrt(B*B+O*O)>P&&W(k)}(s.x!==A.xSnapped||s.y!==A.ySnapped)&&a&&u&&(l=Te(k.sourceEvent,d),D(A))}}).on("end",k=>{if(!u||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,u=!1,cancelAnimationFrame(i),a.size>0){const{nodeLookup:L,updateNodePositions:_,onNodeDragStop:$,onSelectionDragStop:S}=t();if(g&&(_(a,!1),g=!1),o||$||!C&&S){const[P,R]=cr({nodeId:C,dragItems:a,nodeLookup:L,dragging:!1});o==null||o(k.sourceEvent,a,P,R),$==null||$(k.sourceEvent,P,R),C||S==null||S(k.sourceEvent,R)}}}).filter(k=>{const L=k.target;return!k.button&&(!E||!Bo(L,`.${E}`,v))&&(!m||Bo(L,m,v))});f.call(M)}function y(){f==null||f.on(".drag",null)}return{update:x,destroy:y}}function Bf(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())Yt(o,_t(s))>0&&r.push(s);return r}const Ff=250;function Wf(e,t,n,r){var a,c;let o=[],s=1/0;const i=Bf(e,n,t+Ff);for(const l of i){const d=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of d){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:f,y:h}=lt(l,u,u.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g<s?(o=[{...u,x:f,y:h}],s=g):g===s&&o.push({...u,x:f,y:h}))}}if(!o.length)return null;if(o.length>1){const l=r.type==="source"?"target":"source";return o.find(d=>d.type===l)??o[0]}return o[0]}function ki(e,t,n,r,o,s=!1){var l,d,u;const i=r.get(e);if(!i)return null;const a=o==="strict"?(l=i.internals.handleBounds)==null?void 0:l[t]:[...((d=i.internals.handleBounds)==null?void 0:d.source)??[],...((u=i.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&s?{...c,...lt(i,c,c.position,!0)}:c}function Mi(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Yf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ci=()=>!0;function Xf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:s,isTarget:i,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:w,onConnectEnd:x,isValidConnection:y=Ci,onReconnectEnd:E,updateConnection:m,getTransform:v,getFromHandle:N,autoPanSpeed:C,dragThreshold:I=1,handleDomNode:D}){const T=pi(e.target);let W=0,M;const{x:k,y:L}=Te(e),_=Mi(s,D),$=a==null?void 0:a.getBoundingClientRect();let S=!1;if(!$||!_)return;const P=ki(o,_,r,c,t);if(!P)return;let R=Te(e,$),A=!1,V=null,B=!1,O=null;function Y(){if(!d||!$)return;const[ee,Z]=Kr(R,$,C);f({x:ee,y:Z}),W=requestAnimationFrame(Y)}const K={...P,nodeId:o,type:_,position:P.position},J=c.get(o);let X={inProgress:!0,isValid:null,from:lt(J,K,Q.Left,!0),fromHandle:K,fromPosition:K.position,fromNode:J,to:R,toHandle:null,toPosition:$o[K.position],toNode:null,pointer:R};function H(){S=!0,m(X),g==null||g(e,{nodeId:o,handleId:r,handleType:_})}I===0&&H();function F(ee){if(!S){const{x:ce,y:ge}=Te(ee),ve=ce-k,Se=ge-L;if(!(ve*ve+Se*Se>I*I))return;H()}if(!N()||!K){te(ee);return}const Z=v();R=Te(ee,$),M=Wf(Mt(R,Z,!1,[1,1]),n,c,K),A||(Y(),A=!0);const q=Ai(ee,{handle:M,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:i?"target":"source",isValidConnection:y,doc:T,lib:l,flowId:u,nodeLookup:c});O=q.handleDomNode,V=q.connection,B=Yf(!!M,q.isValid);const re=c.get(o),ie=re?lt(re,K,Q.Left,!0):X.from,ae={...X,from:ie,isValid:B,to:q.toHandle&&B?Et({x:q.toHandle.x,y:q.toHandle.y},Z):R,toHandle:q.toHandle,toPosition:B&&q.toHandle?q.toHandle.position:$o[K.position],toNode:q.toHandle?c.get(q.toHandle.nodeId):null,pointer:R};m(ae),X=ae}function te(ee){if(!("touches"in ee&&ee.touches.length>0)){if(S){(M||O)&&V&&B&&(w==null||w(V));const{inProgress:Z,...q}=X,re={...q,toPosition:X.toHandle?X.toPosition:null};x==null||x(ee,re),s&&(E==null||E(ee,re))}h(),cancelAnimationFrame(W),A=!1,B=!1,V=null,O=null,T.removeEventListener("mousemove",F),T.removeEventListener("mouseup",te),T.removeEventListener("touchmove",F),T.removeEventListener("touchend",te)}}T.addEventListener("mousemove",F),T.addEventListener("mouseup",te),T.addEventListener("touchmove",F),T.addEventListener("touchend",te)}function Ai(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:s,doc:i,lib:a,flowId:c,isValidConnection:l=Ci,nodeLookup:d}){const u=s==="target",f=t?i.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=Te(e),w=i.elementFromPoint(h,g),x=w!=null&&w.classList.contains(`${a}-flow__handle`)?w:f,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const E=Mi(void 0,x),m=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),N=x.classList.contains("connectable"),C=x.classList.contains("connectableend");if(!m||!E)return y;const I={source:u?m:r,sourceHandle:u?v:o,target:u?r:m,targetHandle:u?o:v};y.connection=I;const T=N&&C&&(n===vt.Strict?u&&E==="source"||!u&&E==="target":m!==r||v!==o);y.isValid=T&&l(I),y.toHandle=ki(m,E,v,d,n,!0)}return y}const Tr={onPointerDown:Xf,isValid:Ai};function Kf({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Ee(e);function s({translateExtent:a,width:c,height:l,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=m=>{if(m.sourceEvent.type!=="wheel"||!t)return;const v=n(),N=m.sourceEvent.ctrlKey&&Xt()?10:1,C=-m.sourceEvent.deltaY*(m.sourceEvent.deltaMode===1?.05:m.sourceEvent.deltaMode?1:.002)*d,I=v[2]*Math.pow(2,C*N);t.scaleTo(I)};let w=[0,0];const x=m=>{(m.sourceEvent.type==="mousedown"||m.sourceEvent.type==="touchstart")&&(w=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY])},y=m=>{const v=n();if(m.sourceEvent.type!=="mousemove"&&m.sourceEvent.type!=="touchmove"||!t)return;const N=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY],C=[N[0]-w[0],N[1]-w[1]];w=N;const I=r()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),D={x:v[0]-C[0]*I,y:v[1]-C[1]*I},T=[[0,0],[c,l]];t.setViewportConstrained({x:D.x,y:D.y,zoom:v[2]},T,a)},E=ri().on("start",x).on("zoom",u?y:null).on("zoom.wheel",f?g:null);o.call(E,{})}function i(){o.on("zoom",null)}return{update:s,destroy:i,pointer:je}}const Wn=e=>({x:e.x,y:e.y,zoom:e.k}),lr=({x:e,y:t,zoom:n})=>Vn.translate(e,t).scale(n),gt=(e,t)=>e.target.closest(`.${t}`),$i=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),qf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ur=(e,t=0,n=qf,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},Ii=e=>{const t=e.ctrlKey&&Xt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Gf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return d=>{if(gt(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(d.ctrlKey&&i){const x=je(d),y=Ii(d),E=u*Math.pow(2,y);r.scaleTo(n,E,x,d);return}const f=d.deltaMode===1?20:1;let h=o===rt.Vertical?0:d.deltaX*f,g=o===rt.Horizontal?0:d.deltaY*f;!Xt()&&d.shiftKey&&o!==rt.Vertical&&(h=d.deltaY*f,g=0),r.translateBy(n,-(h/u)*s,-(g/u)*s,{internal:!0});const w=Wn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,w),e.panScrollTimeout=setTimeout(()=>{l==null||l(d,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(d,w))}}function Uf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const s=r.type==="wheel",i=!t&&s&&!r.ctrlKey,a=gt(r,e);if(r.ctrlKey&&s&&a&&r.preventDefault(),i||a)return null;r.preventDefault(),n.call(this,r,o)}}function Zf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var s,i,a;if((s=r.sourceEvent)!=null&&s.internal)return;const o=Wn(r.transform);e.mouseButton=((i=r.sourceEvent)==null?void 0:i.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Qf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return s=>{var i,a;e.usedRightMouseButton=!!(n&&$i(t,e.mouseButton??0)),(i=s.sourceEvent)!=null&&i.sync||r([s.transform.x,s.transform.y,s.transform.k]),o&&!((a=s.sourceEvent)!=null&&a.internal)&&(o==null||o(s.sourceEvent,Wn(s.transform)))}}function Jf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:s}){return i=>{var a;if(!((a=i.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,s&&$i(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&s(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=Wn(i.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(i.sourceEvent,c)},n?150:0)}}}function eh({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:s,userSelectionActive:i,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:d}){return u=>{var x;const f=e||t,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(gt(u,`${l}-flow__node`)||gt(u,`${l}-flow__edge`)))return!0;if(!r&&!f&&!o&&!s&&!n||i||d&&!g||gt(u,a)&&g||gt(u,c)&&(!g||o&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&((x=u.touches)==null?void 0:x.length)>1)return u.preventDefault(),!1;if(!f&&!o&&!h&&g||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&w}}function th({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:s,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=ri().scaleExtent([t,n]).translateExtent(r),f=Ee(e).call(u);E({x:o.x,y:o.y,zoom:bt(o.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(Ii);async function w(M,k){return f?new Promise(L=>{u==null||u.interpolate((k==null?void 0:k.interpolate)==="linear"?Rt:bn).transform(ur(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>L(!0)),M)}):!1}function x({noWheelClassName:M,noPanClassName:k,onPaneContextMenu:L,userSelectionActive:_,panOnScroll:$,panOnDrag:S,panOnScrollMode:P,panOnScrollSpeed:R,preventScrolling:A,zoomOnPinch:V,zoomOnScroll:B,zoomOnDoubleClick:O,zoomActivationKeyPressed:Y,lib:K,onTransformChange:J,connectionInProgress:ne,paneClickDistance:X,selectionOnDrag:H}){_&&!l.isZoomingOrPanning&&y();const F=$&&!Y&&!_;u.clickDistance(H?1/0:!De(X)||X<0?0:X);const te=F?Gf({zoomPanValues:l,noWheelClassName:M,d3Selection:f,d3Zoom:u,panOnScrollMode:P,panOnScrollSpeed:R,zoomOnPinch:V,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:a}):Uf({noWheelClassName:M,preventScrolling:A,d3ZoomHandler:h});f.on("wheel.zoom",te,{passive:!1});const ee=Zf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:i});u.on("start",ee);const Z=Qf({zoomPanValues:l,panOnDrag:S,onPaneContextMenu:!!L,onPanZoom:s,onTransformChange:J});u.on("zoom",Z);const q=Jf({zoomPanValues:l,panOnDrag:S,panOnScroll:$,onPaneContextMenu:L,onPanZoomEnd:a,onDraggingChange:c});u.on("end",q);const re=eh({zoomActivationKeyPressed:Y,panOnDrag:S,zoomOnScroll:B,panOnScroll:$,zoomOnDoubleClick:O,zoomOnPinch:V,userSelectionActive:_,noPanClassName:k,noWheelClassName:M,lib:K,connectionInProgress:ne});u.filter(re),O?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function y(){u.on("zoom",null)}async function E(M,k,L){const _=lr(M),$=u==null?void 0:u.constrain()(_,k,L);return $&&await w($),$}async function m(M,k){const L=lr(M);return await w(L,k),L}function v(M){if(f){const k=lr(M),L=f.property("__zoom");(L.k!==M.zoom||L.x!==M.x||L.y!==M.y)&&(u==null||u.transform(f,k,null,{sync:!0}))}}function N(){const M=f?ni(f.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function C(M,k){return f?new Promise(L=>{u==null||u.interpolate((k==null?void 0:k.interpolate)==="linear"?Rt:bn).scaleTo(ur(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>L(!0)),M)}):!1}async function I(M,k){return f?new Promise(L=>{u==null||u.interpolate((k==null?void 0:k.interpolate)==="linear"?Rt:bn).scaleBy(ur(f,k==null?void 0:k.duration,k==null?void 0:k.ease,()=>L(!0)),M)}):!1}function D(M){u==null||u.scaleExtent(M)}function T(M){u==null||u.translateExtent(M)}function W(M){const k=!De(M)||M<0?0:M;u==null||u.clickDistance(k)}return{update:x,destroy:y,setViewport:m,setViewportConstrained:E,getViewport:N,scaleTo:C,scaleBy:I,setScaleExtent:D,setTranslateExtent:T,syncViewport:v,setClickDistance:W}}var Nt;(function(e){e.Line="line",e.Handle="handle"})(Nt||(Nt={}));function nh({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:s}){const i=e-t,a=n-r,c=[i>0?1:i<0?-1:0,a>0?1:a<0?-1:0];return i&&o&&(c[0]=c[0]*-1),a&&s&&(c[1]=c[1]*-1),c}function Fo(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function qe(e,t){return Math.max(0,t-e)}function Ge(e,t){return Math.max(0,e-t)}function gn(e,t,n){return Math.max(0,t-e,e-n)}function Wo(e,t){return e?!t:t}function rh(e,t,n,r,o,s,i,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:d,isVertical:u}=t,f=d&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:w,maxWidth:x,minHeight:y,maxHeight:E}=r,{x:m,y:v,width:N,height:C,aspectRatio:I}=e;let D=Math.floor(d?h-e.pointerX:0),T=Math.floor(u?g-e.pointerY:0);const W=N+(c?-D:D),M=C+(l?-T:T),k=-s[0]*N,L=-s[1]*C;let _=gn(W,w,x),$=gn(M,y,E);if(i){let R=0,A=0;c&&D<0?R=qe(m+D+k,i[0][0]):!c&&D>0&&(R=Ge(m+W+k,i[1][0])),l&&T<0?A=qe(v+T+L,i[0][1]):!l&&T>0&&(A=Ge(v+M+L,i[1][1])),_=Math.max(_,R),$=Math.max($,A)}if(a){let R=0,A=0;c&&D>0?R=Ge(m+D,a[0][0]):!c&&D<0&&(R=qe(m+W,a[1][0])),l&&T>0?A=Ge(v+T,a[0][1]):!l&&T<0&&(A=qe(v+M,a[1][1])),_=Math.max(_,R),$=Math.max($,A)}if(o){if(d){const R=gn(W/I,y,E)*I;if(_=Math.max(_,R),i){let A=0;!c&&!l||c&&!l&&f?A=Ge(v+L+W/I,i[1][1])*I:A=qe(v+L+(c?D:-D)/I,i[0][1])*I,_=Math.max(_,A)}if(a){let A=0;!c&&!l||c&&!l&&f?A=qe(v+W/I,a[1][1])*I:A=Ge(v+(c?D:-D)/I,a[0][1])*I,_=Math.max(_,A)}}if(u){const R=gn(M*I,w,x)/I;if($=Math.max($,R),i){let A=0;!c&&!l||l&&!c&&f?A=Ge(m+M*I+k,i[1][0])/I:A=qe(m+(l?T:-T)*I+k,i[0][0])/I,$=Math.max($,A)}if(a){let A=0;!c&&!l||l&&!c&&f?A=qe(m+M*I,a[1][0])/I:A=Ge(m+(l?T:-T)*I,a[0][0])/I,$=Math.max($,A)}}}T=T+(T<0?$:-$),D=D+(D<0?_:-_),o&&(f?W>M*I?T=(Wo(c,l)?-D:D)/I:D=(Wo(c,l)?-T:T)*I:d?(T=D/I,l=c):(D=T*I,c=l));const S=c?m+D:m,P=l?v+T:v;return{width:N+(c?-D:D),height:C+(l?-T:T),x:s[0]*D*(c?-1:1)+S,y:s[1]*T*(l?-1:1)+P}}const ji={width:0,height:0,x:0,y:0},oh={...ji,pointerX:0,pointerY:0,aspectRatio:1};function sh(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,s=e.measured.width??0,i=e.measured.height??0,a=n[0]*s,c=n[1]*i;return[[r-a,o-c],[r+s-a,o+i-c]]}function ih({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const s=Ee(e);let i={controlDirection:Fo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:w,shouldResize:x}){let y={...ji},E={...oh};i={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Fo(l)};let m,v=null,N=[],C,I,D,T=!1;const W=Bs().on("start",M=>{const{nodeLookup:k,transform:L,snapGrid:_,snapToGrid:$,nodeOrigin:S,paneDomNode:P}=n();if(m=k.get(t),!m)return;v=(P==null?void 0:P.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:A}=Lt(M.sourceEvent,{transform:L,snapGrid:_,snapToGrid:$,containerBounds:v});y={width:m.measured.width??0,height:m.measured.height??0,x:m.position.x??0,y:m.position.y??0},E={...y,pointerX:R,pointerY:A,aspectRatio:y.width/y.height},C=void 0,I=ct(m.extent)?m.extent:void 0,m.parentId&&(m.extent==="parent"||m.expandParent)&&(C=k.get(m.parentId)),C&&m.extent==="parent"&&(I=[[0,0],[C.measured.width,C.measured.height]]),N=[],D=void 0;for(const[V,B]of k)if(B.parentId===t&&(N.push({id:V,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const O=sh(B,m,B.origin??S);D?D=[[Math.min(O[0][0],D[0][0]),Math.min(O[0][1],D[0][1])],[Math.max(O[1][0],D[1][0]),Math.max(O[1][1],D[1][1])]]:D=O}h==null||h(M,{...y})}).on("drag",M=>{const{transform:k,snapGrid:L,snapToGrid:_,nodeOrigin:$}=n(),S=Lt(M.sourceEvent,{transform:k,snapGrid:L,snapToGrid:_,containerBounds:v}),P=[];if(!m)return;const{x:R,y:A,width:V,height:B}=y,O={},Y=m.origin??$,{width:K,height:J,x:ne,y:X}=rh(E,i.controlDirection,S,i.boundaries,i.keepAspectRatio,Y,I,D),H=K!==V,F=J!==B,te=ne!==R&&H,ee=X!==A&&F;if(!te&&!ee&&!H&&!F)return;if((te||ee||Y[0]===1||Y[1]===1)&&(O.x=te?ne:y.x,O.y=ee?X:y.y,y.x=O.x,y.y=O.y,N.length>0)){const ie=ne-R,ae=X-A;for(const ce of N)ce.position={x:ce.position.x-ie+Y[0]*(K-V),y:ce.position.y-ae+Y[1]*(J-B)},P.push(ce)}if((H||F)&&(O.width=H&&(!i.resizeDirection||i.resizeDirection==="horizontal")?K:y.width,O.height=F&&(!i.resizeDirection||i.resizeDirection==="vertical")?J:y.height,y.width=O.width,y.height=O.height),C&&m.expandParent){const ie=Y[0]*(O.width??0);O.x&&O.x<ie&&(y.x=ie,E.x=E.x-(O.x-ie));const ae=Y[1]*(O.height??0);O.y&&O.y<ae&&(y.y=ae,E.y=E.y-(O.y-ae))}const Z=nh({width:y.width,prevWidth:V,height:y.height,prevHeight:B,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),q={...y,direction:Z};(x==null?void 0:x(M,q))!==!1&&(T=!0,g==null||g(M,q),r(O,P))}).on("end",M=>{T&&(w==null||w(M,{...y}),o==null||o({...y}),T=!1)});s.call(W)}function c(){s.on(".drag",null)}return{update:a,destroy:c}}var Pi={exports:{}},Di={},Ti={exports:{}},Ri={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* use-sync-external-store-shim.production.js
|
|
5
5
|
*
|
|
@@ -24,4 +24,4 @@ import{r as b,g as Ja,R as ec,j as p,u as Xe,I as Sn,a as tc,P as wn,b as rr,p a
|
|
|
24
24
|
M${D.x},${D.y}h${D.width}v${D.height}h${-D.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ma.displayName="MiniMap";b.memo(ma);const Xp=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Kp={[Nt.Line]:"right",[Nt.Handle]:"bottom-right"};function qp({nodeId:e,position:t,variant:n=Nt.Handle,className:r,style:o=void 0,children:s,color:i,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:w,onResize:x,onResizeEnd:y}){const E=Ki(),m=typeof e=="string"?e:E,v=ue(),N=b.useRef(null),C=n===Nt.Handle,I=se(b.useCallback(Xp(C&&h),[C,h]),le),D=b.useRef(null),T=t??Kp[n];b.useEffect(()=>{if(!(!N.current||!m))return D.current||(D.current=ih({domNode:N.current,nodeId:m,getStoreItems:()=>{const{nodeLookup:M,transform:k,snapGrid:L,snapToGrid:_,nodeOrigin:$,domNode:S}=v.getState();return{nodeLookup:M,transform:k,snapGrid:L,snapToGrid:_,nodeOrigin:$,paneDomNode:S}},onChange:(M,k)=>{const{triggerNodeChanges:L,nodeLookup:_,parentLookup:$,nodeOrigin:S}=v.getState(),P=[],R={x:M.x,y:M.y},A=_.get(m);if(A&&A.expandParent&&A.parentId){const V=A.origin??S,B=M.width??A.measured.width??0,O=M.height??A.measured.height??0,Y={id:A.id,parentId:A.parentId,rect:{width:B,height:O,...gi({x:M.x??A.position.x,y:M.y??A.position.y},{width:B,height:O},A.parentId,_,V)}},K=eo([Y],_,$,S);P.push(...K),R.x=M.x?Math.max(V[0]*B,M.x):void 0,R.y=M.y?Math.max(V[1]*O,M.y):void 0}if(R.x!==void 0&&R.y!==void 0){const V={id:m,type:"position",position:{...R}};P.push(V)}if(M.width!==void 0&&M.height!==void 0){const B={id:m,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};P.push(B)}for(const V of k){const B={...V,type:"position"};P.push(B)}L(P)},onEnd:({width:M,height:k})=>{const L={id:m,type:"dimensions",resizing:!1,dimensions:{width:M,height:k}};v.getState().triggerNodeChanges([L])}})),D.current.update({controlPosition:T,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:w,onResize:x,onResizeEnd:y,shouldResize:g}),()=>{var M;(M=D.current)==null||M.destroy()}},[T,a,c,l,d,u,w,x,y,g]);const W=T.split("-");return p.jsx("div",{className:he(["react-flow__resize-control","nodrag",...W,n,r]),ref:N,style:{...o,scale:I,...i&&{[C?"backgroundColor":"borderColor"]:i}},children:s})}b.memo(qp);function Gp(e,t){if(!e)return null;const n=Date.parse(e);if(Number.isNaN(n))return null;const r=Math.max(0,(Date.now()-n)/1e3);if(r<45)return t("time.justNow");const o=r/60,s=o/60,i=s/24;return o<45?t("time.minutes",{n:Math.round(o)}):s<22?t("time.hours",{n:Math.round(s)}):i<7?t("time.days",{n:Math.round(i)}):t("time.weeks",{n:Math.round(i/7)})}const Up=4,ps={isConnectable:!1,isConnectableStart:!1,isConnectableEnd:!1,style:{pointerEvents:"none"},"aria-hidden":!0};function Zp({data:e}){const t=Xe(),n=[...new Map((e.editors||[]).map(s=>[s.id,s])).values()];if(n.length===0)return null;const r=n.slice(0,Up),o=n.length-r.length;return p.jsxs("span",{className:"node-editors","data-tip":t("specNode.liveEditors",{n:n.length}),children:[r.map(s=>p.jsx(lc,{seed:s.id,status:s.status,title:t("specNode.editorTitle",{node:s.node||t("common.session"),status:t(`status.${s.status}`),id:s.id.slice(0,8)})},s.id)),o>0&&p.jsxs("span",{className:"av-more","data-tip":t("specNode.more",{n:o}),children:["+",o]})]})}function Qp({summary:e,t}){return e!=null&&e.open?p.jsxs("span",{className:"issue-badge","data-tip":t("specNode.openIssues",{n:e.open}),children:["◆",e.open]}):null}function Jp({data:e,selected:t}){var u,f;const n=Xe(),r=ot[e.status]||ot.pending,o=Gp(e.lastEdited,n),s=e.overlays||[],i=s[0],a=s.some(h=>h.op==="deleted"),c=i&&!i.committed,l=[...new Set(s.map(h=>h.op))],d=["spec-node",e.status,t?"focused":"",e.ghost?"ghost":"",a?"deleted":"",s.length?"has-overlay":"",c?"ov-dirty":""].filter(Boolean).join(" ");return p.jsxs("div",{className:d,style:i?{"--ov":vr(i.seed)}:void 0,children:[p.jsx(kt,{type:"target",position:Q.Left,...ps}),p.jsxs("div",{className:"node-row1",children:[p.jsx("span",{className:"node-dot",style:{background:r.color},children:e.status==="active"&&p.jsx("span",{className:"pulse",style:{background:r.color}})}),p.jsx("span",{className:"node-title",children:e.title}),l.length>0?p.jsx("span",{className:"ov-marks","data-tip":s.map(h=>n("specNode.opTitle",{op:n(`legend.opRows.${h.op}`),label:h.label,uncommitted:!h.committed})).join(`
|
|
25
25
|
`),children:l.map(h=>p.jsx("span",{className:`ov-mark ov-${h}`,children:Ss[h]},h))}):o?p.jsx("span",{className:"node-ago",children:o}):null]}),p.jsxs("div",{className:"node-row2",children:[p.jsx("span",{className:"node-ver",children:e.version?`v${e.version}`:""}),e.drift>0&&p.jsxs("span",{className:"drift-badge","data-tip":(e.driftFiles||[]).map(h=>`${h.file}: ${n("specNode.driftAhead",{n:h.behind})}`).join(`
|
|
26
26
|
`),children:["⚠",e.drift]}),p.jsx(Qp,{summary:(u=e.reviewSummary)==null?void 0:u.issues,t:n}),p.jsx(cc,{summary:(f=e.reviewSummary)==null?void 0:f.evals}),p.jsx(Zp,{data:e})]}),e.collapsed&&p.jsxs("span",{className:"node-expand","data-tip":n("specNode.expandable",{n:e.childCount}),children:["▸",e.childCount]}),p.jsx(kt,{type:"source",position:Q.Right,...ps})]})}const yn=8;function em({x:e,y:t,anchorKey:n,label:r,children:o}){const s=b.useRef(null),[i,a]=b.useState({left:e,top:t,visibility:"hidden"});return b.useLayoutEffect(()=>{var l;const c=(l=s.current)==null?void 0:l.getBoundingClientRect();c&&a({left:Math.max(yn,Math.min(e,window.innerWidth-c.width-yn)),top:Math.max(yn,Math.min(t,window.innerHeight-c.height-yn)),visibility:"visible"})},[e,t,n]),p.jsx("div",{ref:s,className:"sess-menu",role:"menu","aria-label":r,style:i,onClick:c=>c.stopPropagation(),onMouseDownCapture:ks,children:o})}function gr({children:e}){return p.jsx("div",{className:"sess-menu-group",role:"group",children:e})}function ms(){return p.jsx("div",{className:"sess-menu-sep",role:"separator"})}function It({icon:e,leading:t,danger:n=!1,className:r="",children:o,...s}){if(!e&&!t)throw new Error("context menu item requires an icon or leading glyph");const i=["sess-menu-item",n&&"danger",r].filter(Boolean).join(" ");return p.jsxs("button",{type:"button",role:"menuitem",className:i,...s,children:[p.jsx("span",{className:"sess-menu-icon",children:t??p.jsx(Sn,{name:e,size:14,className:"sess-menu-svg"})}),p.jsx("span",{className:"sess-menu-label",children:o})]})}function tm({menu:e,onClose:t,onInfo:n,onFresh:r,onNewChild:o,onDelete:s,sessions:i=[],onOpenSession:a}){const c=Xe();if(b.useEffect(()=>{if(e)return window.addEventListener("click",t),window.addEventListener("contextmenu",t,!0),()=>{window.removeEventListener("click",t),window.removeEventListener("contextmenu",t,!0)}},[e,t]),uc(!!e,t),!e)return null;const l=u=>f=>{f.stopPropagation(),t(),u(e.id)},d=u=>f=>{f.stopPropagation(),t(),a==null||a(u)};return p.jsxs(em,{x:e.x,y:e.y,anchorKey:e.id,label:c("nodeMenu.menuLabel"),children:[p.jsxs(gr,{children:[p.jsx(It,{icon:"info",onClick:l(n),children:c("nodeMenu.info")}),p.jsx(It,{icon:"sessions",onClick:l(r),children:c("nodeMenu.newSession")}),p.jsx(It,{icon:"plus",onClick:l(o),children:c("nodeMenu.newChild")})]}),p.jsx(ms,{}),p.jsx(gr,{children:p.jsx(It,{icon:"trash",danger:!0,onClick:l(s),children:c("nodeMenu.del")})}),i.length>0&&p.jsxs(p.Fragment,{children:[p.jsx(ms,{}),p.jsx(gr,{children:i.map(u=>p.jsx(It,{className:"sess-menu-sess",leading:p.jsx("span",{className:"sess-glyph",style:{color:br[u.status]},"aria-hidden":"true",children:dc[u.status]}),onClick:d(u.id),children:Lr(u)},u.id))})]})]})}const nm=new Set(["=","_","I","H","J","K","L"]),rm=(()=>{const e=[];for(const t of Ac){const n=Ms(t.id).filter(o=>!nm.has(o)).map(_r),r=e[e.length-1];r&&r.desc===t.desc?r.keys.push(...n):e.push({desc:t.desc,keys:n})}return e})(),om=[[["←","→","h","l","⇥","1","2"],"legend.popup.switch"],[["j","k","↑","↓"],"legend.popup.scroll"],[["⇧h","⇧j","⇧k","⇧l","⇧←↑↓→"],"legend.popup.lens"],[["⏎"],"legend.popup.enter"],[["esc"],"legend.popup.esc"]],sm=["merged","active","drift","pending"],im=["added","edited","deleted","moved"];function am({t:e}){return p.jsxs("section",{className:"legend-sec",children:[p.jsx("div",{className:"legend-h",children:e("legend.secBoard")}),rm.map(t=>p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:"keymap-keys",children:t.keys.map((n,r)=>p.jsx("kbd",{children:n},r))}),p.jsx("span",{className:"legend-desc",children:e(t.desc)})]},t.desc))]})}function cm({title:e,rows:t,t:n}){return p.jsxs("section",{className:"legend-sec",children:[p.jsx("div",{className:"legend-h",children:e}),t.map(([r,o])=>p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:"keymap-keys",children:r.map((s,i)=>p.jsx("kbd",{children:s},i))}),p.jsx("span",{className:"legend-desc",children:n(o)})]},o))]})}function lm({onClose:e}){const t=Xe();return p.jsxs(Mc,{title:t("legend.title"),closeLabel:t("legend.close"),onClose:e,children:[p.jsx(am,{t}),p.jsx(cm,{title:t("legend.secPopup"),rows:om,t}),p.jsxs("section",{className:"legend-sec",children:[p.jsx("div",{className:"legend-h",children:t("legend.secStatus")}),sm.map(n=>p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:"node-dot",style:{background:ot[n].color},children:n==="active"&&p.jsx("span",{className:"pulse",style:{background:ot[n].color}})}),p.jsx("span",{className:"legend-name",children:t(`status.${n}`)}),p.jsx("span",{className:"legend-desc",children:t(`legend.statusRows.${n}`)})]},n))]}),p.jsxs("section",{className:"legend-sec",children:[p.jsxs("div",{className:"legend-h",children:[t("legend.secOp")," ",p.jsx("span",{className:"legend-sub",children:t("legend.secOpSub")})]}),im.map(n=>p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:`ov-mark ov-${n}`,children:Ss[n]}),p.jsx("span",{className:"legend-desc",children:t(`legend.opRows.${n}`)})]},n))]}),p.jsxs("section",{className:"legend-sec",children:[p.jsx("div",{className:"legend-h",children:t("legend.secBadges")}),p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:"drift-badge",children:"⚠N"}),p.jsx("span",{className:"legend-desc",children:t("legend.badgeDrift")})]}),p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:"legend-glyph legend-ver",children:"vN"}),p.jsx("span",{className:"legend-desc",children:t("legend.badgeVer")})]})]}),p.jsxs("section",{className:"legend-sec",children:[p.jsx("div",{className:"legend-h",children:t("legend.secRing")}),p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:"legend-ring ring-dashed"}),p.jsx("span",{className:"legend-desc",children:t("legend.ringDashed")})]}),p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:"legend-ring ring-solid"}),p.jsx("span",{className:"legend-desc",children:t("legend.ringSolid")})]}),p.jsxs("div",{className:"legend-row",children:[p.jsx("span",{className:"legend-ring ring-ghost"}),p.jsx("span",{className:"legend-desc",children:t("legend.ringGhost")})]})]})]})}const ya=8,um=5,dm=2.2,fm=1,hm=new Set(["the","a","an","and","or","of","to","in","on","is","it","its","as","at","by","for","how","does","do","what","which","that","this","these","those","with","from","into","are","be","can","just","them","they","their","so","if","not","no","but","vs","us","we","you"]),xa="\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\u3040-\\u30ff",gm=new RegExp(`[a-z0-9]+|[${xa}]`,"g"),pm=new RegExp(`[${xa}]`);function wa(e){return pm.test(e)}function va(e){return e.toLowerCase().match(gm)??[]}function mm(e){const t=new Set;for(const n of va(e))(wa(n)||n.length>1&&!hm.has(n))&&t.add(n);return[...t]}function pr(e){return va(e)}function no(e){let t=e;return t.length>=4&&t.endsWith("s")&&!t.endsWith("ss")&&(t=t.slice(0,-1)),t.length>=5&&t.endsWith("e")&&(t=t.slice(0,-1)),t}function ym(e,t){return t.startsWith(no(e))}function Tn(e,t){return t.startsWith(no(e))||t.length>=3&&e.startsWith(t)}const xm=.5;function wm(e,t){const n=no(e);let r=0;for(const o of t.nameWords)if(o.startsWith(n)){const s=n.length/o.length;s>r&&(r=s)}return r>0?Math.max(xm,r):0}const ys=1.2,xs=.4;function ws(e,t,n){return e<=0?0:e*(ys+1)/(e+ys*(1-xs+xs*t/(n||1)))}function vm(e,t,n,r){const o=wm(e,t);if(o>0)return ya*o;if(t.name.includes(e))return um;if(t.descWords.some(i=>Tn(e,i)))return dm*ws(1,t.descWords.length,r);const s=t.bodyWords.reduce((i,a)=>i+(Tn(e,a)?1:0),0);return fm*ws(s,t.bodyWords.length,n)}function bm(e,t,n,r=140){const o=e.replace(/\s+/g," ").trim(),s=o.toLowerCase();let i=-1;for(const l of n){const d=wa(l)?s.indexOf(l):s.search(new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")));d>=0&&(i<0||d<i)&&(i=d)}if(i<0){const l=(t||o).replace(/\s+/g," ").trim();return l.length>r?l.slice(0,r).trimEnd()+"…":l}const a=Math.max(0,i-Math.floor(r/3));let c=o.slice(a,a+r).trim();return a>0&&(c="…"+c),a+r<o.length&&(c=c+"…"),c}function _m(e,t,n={}){const r=n.limit??10,o=mm(e);if(!o.length)return[];const s=t.map(u=>{const f=u.name.toLowerCase();return{ref:u.ref,name:f,nameWords:pr(f),desc:u.desc.toLowerCase(),descWords:pr(u.desc),bodyWords:pr(u.body),snippetText:`${u.desc}
|
|
27
|
-
${u.body}`}}),i=s.length,a=s.reduce((u,f)=>u+f.bodyWords.length,0)/(i||1),c=s.reduce((u,f)=>u+f.descWords.length,0)/(i||1),l={};for(const u of o){let f=0;for(const h of s)(h.nameWords.some(g=>ym(u,g))||h.descWords.some(g=>Tn(u,g))||h.bodyWords.some(g=>Tn(u,g)))&&f++;l[u]=f>0?Math.log(i/f):0}const d=[];for(const u of s){let f=0;for(const h of o)f+=Math.min(vm(h,u,a,c)*l[h],ya);f<=0||d.push({ref:u.ref,score:Math.round(f*100)/100,snippet:bm(u.snippetText,u.desc,o)})}return d.sort((u,f)=>f.score-u.score),d.slice(0,r)}let mr=null;function Em(e=!0){const[t,n]=b.useState(mr),r=b.useRef(!1);return b.useEffect(()=>{!e||r.current||(r.current=!0,fetch(tc("/api/specs/lite")).then(o=>o.ok?o.json():[]).then(o=>{mr={bodies:Object.fromEntries((o||[]).map(s=>[s.id,s.body||""]))},n(mr)}).catch(()=>{}))},[e]),t}const Nm={pass:"var(--green)",fail:"var(--red)",stalePass:"var(--muted)",staleFail:"var(--muted)",empty:"var(--muted)",missing:"var(--muted)"},yr=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,""),vs=["spec","session","issue","scenario"],Sm=e=>e?[e,...vs.filter(t=>t!==e)]:vs,km=new Set(["issue","scenario"]);function Mm(e,t,n,r=[],o=[]){var c,l;const s=n==null?void 0:n.bodies,i=[],a=Object.fromEntries(e.map(d=>[d.id,d]));for(const d of e){const u=yr(d.path);i.push({kind:"spec",key:`spec:${d.id}`,target:d.id,address:hc(d.id),color:(ot[d.status]||ot.pending).color,title:d.title||d.id,sub:u,name:`${d.title||d.id} ${d.id}`,desc:d.desc||"",body:(s==null?void 0:s[d.id])??d.body??""})}for(const d of r){const u=((c=d.nodes)==null?void 0:c[0])||null,f=yr((l=a[u])==null?void 0:l.path);i.push({kind:"issue",key:`issue:${d.id}`,target:d.id,nodeId:u,address:gc(d.id),color:d.status==="open"?"var(--green)":"var(--muted)",title:d.concern,sub:[d.id,f].filter(Boolean).join(" · "),name:d.concern||"",desc:d.id,body:""})}for(const d of o){const u=a[d.node],f=d.filterKind===pc.RESULT;i.push({kind:"scenario",key:`scenario:${d.node}:${d.scenario}`,target:d.scenario,nodeId:d.node,address:f?fo(d.node,d.scenario):fo(d.node),color:Nm[d.state||"missing"]||"var(--cyan)",title:d.scenario,sub:yr(u==null?void 0:u.path),tags:d.tags,name:d.scenario||"",desc:"",body:d.expected||""})}for(const d of t){const u=Lr(d),f=mc(d),h=d.status||d.promptPreview||d.note||"";i.push({kind:"session",key:`session:${d.id}`,target:d.id,address:yc(d.id),color:br[d.status]||br.offline,title:u,sub:h,name:u||"",desc:d.status||"",body:`${d.promptPreview||d.note||""} ${f}`.trim()})}return i}function Cm(e,t,n){const r=Object.fromEntries(n.map((a,c)=>[a,c])),o=(a,c)=>r[a.kind]-r[c.kind]||a.name.length-c.name.length||a.key.localeCompare(c.key);if(!t.trim())return e.slice().sort(o).slice(0,15);const s={};for(const a of n){const c=e.filter(l=>l.kind===a);s[a]=km.has(a)?c.slice(0,15):_m(t,c.sort((l,d)=>l.name.length-d.name.length||l.key.localeCompare(d.key)).map(l=>({ref:l,name:l.name,desc:l.desc,body:l.body})),{limit:15}).map(l=>l.ref)}const i=[];for(let a=0;i.length<15;a++){let c=!1;for(const l of n)s[l][a]&&i.length<15&&(i.push(s[l][a]),c=!0);if(!c)break}return i}function Am({specs:e,sessions:t,onPick:n,onClose:r,boost:o=null}){var W,M;const s=Xe(),i=Em(),[a,c]=b.useState(""),[l,d]=b.useState("");b.useEffect(()=>{if(!a.trim()){d(a);return}const k=setTimeout(()=>d(a),120);return()=>clearTimeout(k)},[a]);const[u,f]=b.useState(0),h=b.useRef(null),g=b.useRef(null),w=b.useMemo(()=>Sm(o),[o]),x=`is:issue${l.trim()?` ${l.trim()}`:""}`,y=`is:eval${l.trim()?` ${l.trim()}`:""}`,E=uo("issues",x,1,{pollMs:0}),m=uo("evals",y,1,{pollMs:0}),v=((W=E.data)==null?void 0:W.items)||[],N=((M=m.data)==null?void 0:M.items)||[],C=b.useMemo(()=>Mm(e,t,i,v,N),[e,t,i,E.data,m.data]),I=b.useMemo(()=>Cm(C,l,w),[C,l,w]);b.useEffect(()=>{var k;(k=h.current)==null||k.focus()},[]),b.useEffect(()=>{f(0)},[a]),b.useEffect(()=>{var k,L;(L=(k=g.current)==null?void 0:k.querySelector(".search-item.on"))==null||L.scrollIntoView({block:"nearest"})},[u,I]);const D=k=>{k&&(n(k),r())},T=k=>{k.key==="ArrowDown"?(k.preventDefault(),f(L=>Math.min(I.length-1,L+1))):k.key==="ArrowUp"?(k.preventDefault(),f(L=>Math.max(0,L-1))):k.key==="Enter"?(k.preventDefault(),D(I[u])):k.key==="Escape"&&(k.preventDefault(),r())};return p.jsx("div",{className:"search-backdrop","data-focus-overlay":!0,onClick:r,children:p.jsxs("div",{className:"search-panel",role:"dialog","aria-modal":"true","aria-label":s("search.title"),onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"search-bar",children:[p.jsx("span",{className:"search-icon",children:"⌕"}),p.jsx("input",{ref:h,className:"search-input",value:a,placeholder:s("search.placeholder"),onChange:k=>c(k.target.value),onKeyDown:T})]}),p.jsxs("ul",{className:"search-results",ref:g,children:[I.length===0&&p.jsx("li",{className:"search-empty",children:s("search.empty")}),I.map((k,L)=>p.jsxs("li",{className:`search-item${L===u?" on":""}`,onMouseEnter:()=>f(L),onClick:()=>D(k),children:[p.jsx("span",{className:"node-dot",style:{background:k.color}}),p.jsx("span",{className:`search-kind k-${k.kind}`,children:s(`search.kind.${k.kind}`)}),p.jsx("span",{className:"search-title",children:k.title||k.target}),p.jsx(fc,{tags:k.tags}),p.jsx("span",{className:"search-path",children:k.sub})]},k.key))]}),p.jsx("div",{className:"search-foot",children:s("search.hint")})]})})}function ba(e,t,n=1,r=o=>o){if(!e.length)return null;const o=e.findIndex(s=>r(s)===t);return o===-1?n>0?e[0]:e[e.length-1]:e[(o+n+e.length)%e.length]}const $m=["merged","active","drift","pending"],Im=[{state:"pass",always:!0,titleKey:"scorePass"},{state:"fail",always:!0,titleKey:"scoreFail"},{state:"stalePass",always:!1,titleKey:"scoreStalePass"},{state:"staleFail",always:!1,titleKey:"scoreStaleFail"},{state:"empty",always:!1,titleKey:"scoreEmpty"}];function jm(e){var a,c;const t={merged:[],active:[],drift:[],pending:[]},n=[],r=[],o=new Set,s={pass:0,fail:0,stalePass:0,staleFail:0,empty:0},i={pass:[],fail:[],stalePass:[],staleFail:[],empty:[]};for(const l of e){t[l.status]&&t[l.status].push(l.id),l.drift>0&&n.push(l.id);const d=(a=l.reviewSummary)==null?void 0:a.issues;if(d!=null&&d.open){r.push(l.id);for(const f of d.openIds||[])o.add(f)}const u=(c=l.reviewSummary)==null?void 0:c.evals;if(u)for(const f of Object.keys(s)){const h=u[f]||0;s[f]+=h,h>0&&i[f].push(l.id)}}return{total:e.length,status:t,driftIds:n,issueIds:r,issueCount:o.size,scoreCount:s,scoreNodes:i}}function xn({count:e,ids:t,focusId:n,onJump:r,title:o,cls:s="",children:i}){const a=t.length>0;return p.jsxs("button",{type:"button",className:`bstat ${s}`.trim(),disabled:!a,"data-tip":o,"aria-label":o,onClick:a?()=>r(ba(t,n)):void 0,children:[i,e]})}function Pm({specs:e,focusId:t,onJump:n}){const r=Xe(),o=b.useMemo(()=>jm(e),[e]),s=i=>i&&(n==null?void 0:n(i));return p.jsxs("div",{className:"graph-stats",role:"group","aria-label":r("stats.aria"),children:[p.jsx("span",{className:"bstat-total","data-tip":r("stats.totalTitle",{n:o.total}),children:o.total}),$m.map(i=>p.jsx(xn,{count:o.status[i].length,ids:o.status[i],focusId:t,onJump:s,title:r("stats.statusTitle",{n:o.status[i].length,status:r(`status.${i}`)}),children:p.jsx("span",{className:"bstat-dot",style:{background:ot[i].color}})},i)),p.jsx("span",{className:"bstat-sep"}),p.jsx(xn,{count:o.driftIds.length,ids:o.driftIds,focusId:t,onJump:s,cls:"bstat-drift",title:r("stats.driftTitle",{n:o.driftIds.length}),children:"⚠"}),p.jsx(xn,{count:o.issueCount,ids:o.issueIds,focusId:t,onJump:s,cls:"bstat-issue",title:r("stats.issueTitle",{n:o.issueCount}),children:"◆"}),p.jsx("span",{className:"bstat-sep"}),Im.map(({state:i,always:a,titleKey:c})=>{const l=o.scoreCount[i],d=o.scoreNodes[i];return!l&&!a?null:p.jsx(xn,{count:l,ids:d,focusId:t,onJump:s,title:r(`stats.${c}`,{n:l}),children:p.jsx(xc,{state:i})},i)})]})}const Dm=wc.filter(e=>e!=="settings");function bs({page:e,active:t,label:n}){return p.jsx("a",{className:t?"rail-btn on":"rail-btn","data-tip":n,"aria-label":n,"aria-current":t?"page":void 0,href:vc(e),children:p.jsx(Sn,{name:e,size:18})})}function Tm({identity:e,projects:t,gatewayIdentity:n,t:r}){const[o,s]=b.useState(!1),i=b.useRef(null);b.useEffect(()=>{if(!o)return;const c=d=>{var u;(u=i.current)!=null&&u.contains(d.target)||s(!1)},l=d=>{d.key==="Escape"&&(d.stopPropagation(),s(!1))};return document.addEventListener("mousedown",c,!0),window.addEventListener("keydown",l,!0),()=>{document.removeEventListener("mousedown",c,!0),window.removeEventListener("keydown",l,!0)}},[o]);const a=(e==null?void 0:e.title)||wn||"";return p.jsxs("div",{className:"proj-chip-wrap",ref:i,children:[p.jsx("button",{type:"button",className:o?"rail-btn proj-chip on":"rail-btn proj-chip","data-tip":r("nav.projectChip",{name:a}),"aria-label":r("nav.projectChip",{name:a}),"aria-haspopup":t?"menu":void 0,"aria-expanded":t?o:void 0,onClick:()=>{t&&s(c=>!c)},children:p.jsx(rr,{icon:e==null?void 0:e.icon,size:26})}),o&&t&&p.jsxs("div",{className:"proj-menu",role:"menu",children:[t.map(c=>p.jsxs("a",{role:"menuitem",className:c.id===wn?"proj-menu-item current":"proj-menu-item",href:nc(c.id),children:[p.jsx(rr,{icon:c.identity.icon,size:16,className:"proj-menu-mark"}),c.gated&&p.jsx(Sn,{name:"lock",size:11}),p.jsx("span",{className:"proj-menu-name",children:c.identity.title}),c.id===wn&&p.jsx(Sn,{name:"check",size:12})]},c.id)),p.jsxs("a",{role:"menuitem",className:"proj-menu-item all",href:rc(),children:[p.jsx(rr,{icon:n==null?void 0:n.icon,fallback:"gateway",size:16,className:"proj-menu-mark"}),p.jsx("span",{className:"proj-menu-name",children:r("nav.allProjects")})]})]})]})}function Rm({page:e,identity:t,catalog:n}){const r=Xe(),o=(n==null?void 0:n.state)==="ok";return p.jsxs("nav",{className:"side-rail","aria-label":r("nav.railLabel"),onMouseDownCapture:ks,children:[wn&&p.jsx(Tm,{identity:t,projects:o?n.projects:null,gatewayIdentity:o?n.gateway.identity:null,t:r}),Dm.map(s=>p.jsx(bs,{page:s,active:e===s,label:r(`nav.${s}`)},s)),p.jsx("div",{className:"rail-spacer"}),p.jsx(bs,{page:"settings",active:e==="settings",label:r("nav.settings")})]})}const Lm=400,zm=80,xr=7,wr=6;function Hm(){const[e,t]=b.useState(null),n=b.useRef(null),r=b.useRef(0),o=b.useRef(null),s=b.useRef(null),i=b.useRef(!1);return b.useEffect(()=>{const a=()=>{r.current&&(clearTimeout(r.current),r.current=0)},c=()=>{a(),o.current=null,s.current&&(s.current.getAttribute("aria-describedby")==="ui-tip"&&s.current.removeAttribute("aria-describedby"),s.current=null),t(x=>(x&&(i.current=!0,setTimeout(()=>{o.current||(i.current=!1)},300)),null))},l=x=>{const y=x.getAttribute("data-tip");!y||!x.isConnected||(o.current=x,x.getAttribute("aria-describedby")||(x.setAttribute("aria-describedby","ui-tip"),s.current=x),t({text:y,anchor:x}))},d=(x,y)=>{o.current!==x&&(a(),o.current=x,r.current=setTimeout(()=>{r.current=0,l(x)},y))},u=x=>{var E,m;const y=(m=(E=x.target).closest)==null?void 0:m.call(E,"[data-tip]");y&&d(y,i.current?zm:Lm)},f=x=>{var E,m;const y=(m=(E=x.target).closest)==null?void 0:m.call(E,"[data-tip]");!y||y!==o.current||y.contains(x.relatedTarget)||c()},h=x=>{var m,v;const y=(v=(m=x.target).closest)==null?void 0:v.call(m,"[data-tip]");if(!y)return;let E=!0;try{E=y.matches(":focus-visible")}catch{}E&&(a(),l(y))},g=x=>{var E,m;const y=(m=(E=x.target).closest)==null?void 0:m.call(E,"[data-tip]");y&&y===o.current&&c()},w=x=>{x.key==="Escape"&&c()};return document.addEventListener("pointerover",u,!0),document.addEventListener("pointerout",f,!0),document.addEventListener("focusin",h,!0),document.addEventListener("focusout",g,!0),document.addEventListener("keydown",w,!0),document.addEventListener("pointerdown",c,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{a(),document.removeEventListener("pointerover",u,!0),document.removeEventListener("pointerout",f,!0),document.removeEventListener("focusin",h,!0),document.removeEventListener("focusout",g,!0),document.removeEventListener("keydown",w,!0),document.removeEventListener("pointerdown",c,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[]),b.useEffect(()=>{const a=n.current;if(!e||!a)return;if(!e.anchor.isConnected){t(null);return}const c=e.anchor.getBoundingClientRect(),l=a.getBoundingClientRect(),d=c.top-l.height-xr>=wr?"top":"bottom",u=d==="top"?c.top-l.height-xr:c.bottom+xr,f=Math.min(Math.max(c.left+c.width/2-l.width/2,wr),window.innerWidth-l.width-wr);a.dataset.place=d,a.style.top=`${Math.round(u)}px`,a.style.left=`${Math.round(f)}px`;const h=a.querySelector(".ui-tip-arrow");h&&(h.style.left=`${Math.round(Math.min(Math.max(c.left+c.width/2-f,10),l.width-10))-4}px`);const g=requestAnimationFrame(()=>a.classList.add("show"));return()=>cancelAnimationFrame(g)},[e]),e?oc.createPortal(p.jsxs("div",{id:"ui-tip",role:"tooltip",ref:n,className:"ui-tip",children:[e.text,p.jsx("span",{className:"ui-tip-arrow","aria-hidden":"true"})]}),document.body):null}function _s(){let e=0,t=null,n=null,r=null;return function(s,i){if(!s)return;const a=r!=null&&Math.abs(s.scrollTop-r)>1;(s!==n||a)&&(n=s,t=null,r=null);const c=s.scrollHeight-s.clientHeight,l=t??s.scrollTop;t=Math.max(0,Math.min(c,l+i)),cancelAnimationFrame(e);const d=()=>{if(r!=null&&Math.abs(s.scrollTop-r)>1){cancelAnimationFrame(e),t=null,r=null;return}const u=t-s.scrollTop;if(Math.abs(u)<.5){s.scrollTop=t,r=s.scrollTop;return}s.scrollTop+=u*.2,r=s.scrollTop,e=requestAnimationFrame(d)};e=requestAnimationFrame(d)}}function Om(e){return e>1}function Vm(e){return{next:_r((e("graph.cycle")||[])[0]||"o"),prev:_r((e("graph.cycleRev")||[])[0]||"O")}}const Bm=b.lazy(()=>Rn(()=>import("./SessionInterface-Bh3vq8SU.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Fm=b.lazy(()=>Rn(()=>import("./EvalsPage-5_nfIYll.js"),__vite__mapDeps([10,1,2,5,6]))),Wm=b.lazy(()=>Rn(()=>import("./IssuesPage-By-u--95.js"),__vite__mapDeps([11,1,2,5,6,7]))),Ym=b.lazy(()=>Rn(()=>import("./Settings-B8KFocsz.js"),__vite__mapDeps([12,1,2,8,6,3]))),Xm={spec:Jp},Km=[.5,.5],Es={width:176,height:50},qm=[{type:"target",position:Q.Left,x:-1.5,y:22.5,width:5,height:5},{type:"source",position:Q.Right,x:172.5,y:22.5,width:5,height:5}],Ns=e=>Math.max(.4,Math.min(1.6,e)),Tt={nn:e=>`Create a new spec node under [[${e}]] — choose a kebab-case id, write its spec.md at contract altitude with a code: list, implement it, then propose merge. What it should be: `,dd:e=>`Delete the [[${e}]] spec node — remove its dir, repoint or fold its governed code, fix any [[…]] refs, recover its intent from git history, then propose merge. Why: `},_a=Object.keys(Tt),Gm=new Set(_a.map(e=>e[0]));function jt({active:e,warm:t=!1,className:n,children:r}){const o=Xe();return!t&&!e?null:p.jsx("div",{className:n?`page-pane ${n}`:"page-pane",style:e?void 0:{display:"none"},children:p.jsx(b.Suspense,{fallback:p.jsx("div",{className:"loading",children:o("hud.loading")}),children:r})})}function Um({specs:e,sessions:t,reload:n,identity:r,catalog:o,boardLive:s}){const i=(r==null?void 0:r.title)||"",{page:a,param:c}=bc(),[l,d]=b.useState(()=>{var G;let z=null;try{z=sessionStorage.getItem("spex.focus")}catch{}return(z&&e.some(U=>U.id===z)?z:null)||((G=e.find(U=>!U.parent))==null?void 0:G.id)});b.useEffect(()=>{try{l&&sessionStorage.setItem("spex.focus",l)}catch{}},[l]);const[u,f]=b.useState(!1),[h,g]=b.useState("spec"),[w,x]=b.useState(!1),[y,E]=b.useState(null),[m,v]=b.useState("new"),[N,C]=b.useState(null),[I,D]=b.useState(null),[T,W]=b.useState(null),{getViewport:M,setViewport:k}=qn(),L=Xe(),_=b.useRef(null),$=b.useRef(0),S=b.useRef({buf:"",timer:0}),[P,R]=b.useState(!1),A=b.useRef(!1);A.current=P;const V=b.useRef({x:-1,y:-1}),B=b.useMemo(()=>_s(),[]),O=b.useMemo(()=>_s(),[]),Y=b.useMemo(()=>Object.fromEntries(e.map(z=>[z.id,z])),[e]),K=Y[l]||e.find(z=>!z.parent)||e[0],J=b.useMemo(()=>{const z=new Set;for(let G=K;G;G=G.parent?Y[G.parent]:null)z.add(G.id);return z},[K,Y]),ne=b.useMemo(()=>sc(e,J),[e,J]),X=b.useMemo(()=>e.filter(z=>ne[z.id]).map(z=>({...z,...ne[z.id]})),[e,ne]),H=b.useMemo(()=>Object.fromEntries(X.map(z=>[z.id,z])),[X]),F=H[K.id],te=b.useMemo(()=>{const z={};return e.forEach(G=>{G.parent&&(z[G.parent]=(z[G.parent]||0)+1)}),z},[e]),ee=b.useMemo(()=>e.filter(z=>{var G;return(G=z.overlays)==null?void 0:G.length}),[e]),Z=b.useMemo(()=>N?t.find(z=>z.source===N):null,[t,N]),q=b.useMemo(()=>N?e.filter(z=>(z.overlays||[]).some(G=>G.source===N)):[],[e,N]),re=b.useMemo(()=>N?q:ee,[N,q,ee]),ie=Vm(Ms),ae=b.useCallback(z=>z?t.filter(G=>{var U;return(U=G.ops)==null?void 0:U.some(oe=>oe.nodeId===z.id)}):[],[t]),ce=b.useCallback(z=>{v(z),ke("sessions",z)},[]),ge=b.useCallback(z=>{v("new"),D(z),ke("sessions","new")},[]),ve=b.useCallback(z=>{_c(z,{onFocusNode:d,onOpenSession:ce})},[ce]),Se=b.useMemo(()=>{var U;if(!T)return[];const z=e.find(oe=>oe.id===T.id);return(U=z==null?void 0:z.overlays)!=null&&U.length?[...new Set(z.overlays.map(oe=>oe.source))].map(oe=>t.find(de=>de.source===oe)).filter(Boolean):[]},[T,e,t]),Me=b.useCallback(z=>{ve(z.address)},[ve]);b.useLayoutEffect(()=>{if(a!=="sessions"||!c)return;const z=c.split("/")[0];z&&z!==m&&v(z)},[a,c]),b.useEffect(()=>{a==="sessions"&&ke("sessions",m,{replace:!0})},[a,m]),b.useEffect(()=>{a!=="graph"&&(f(!1),x(!1),E(null),W(null))},[a]);const Be=b.useMemo(()=>X.filter(z=>z.parent===F.id),[X,F]),Ce=F.parent?H[F.parent]:null,Ae=b.useMemo(()=>Be.length?Be.reduce((z,G)=>Math.abs(G.y-F.y)<Math.abs(z.y-F.y)?G:z):null,[Be,F]),ye=b.useMemo(()=>{if(Ae)return Ae;let z=null,G=1/0;for(const U of X){const oe=U.x-F.x;if(oe<=0)continue;const de=U.y-F.y,j=(oe/ic)**2+(de/ac)**2;j<G&&(G=j,z=U)}return z},[Ae,X,F]),xe=b.useCallback(z=>{let G=null;for(const U of X){if(U.id===F.id||U.x!==F.x)continue;const oe=U.y-F.y;(z==="down"?oe<=0:oe>=0)||(!G||Math.abs(oe)<Math.abs(G.y-F.y))&&(G=U)}return G},[X,F]),be=b.useMemo(()=>xe("down"),[xe]),$e=b.useMemo(()=>xe("up"),[xe]),Zn=b.useMemo(()=>X.map(z=>{const G=z.id===l||z.id===F.parent||z.parent===l||z.parent===F.parent;let U;N&&q.length?U=(z.overlays||[]).some(pe=>pe.source===N)?"ov-hot":"ov-dim":U=G?void 0:"is-far";const de=ae(z).map(pe=>({id:pe.id,status:pe.status,node:pe.node})),j=te[z.id]||0,me={editors:de,collapsed:j>0&&!J.has(z.id),childCount:j};return{id:z.id,type:"spec",position:{x:z.x,y:z.y},data:{...z,...me},initialWidth:Es.width,initialHeight:Es.height,handles:qm,draggable:!1,selected:z.id===l,className:U}}),[l,F.parent,N,q,X,ae,te,J]),Ct=b.useMemo(()=>{const z=X.filter(U=>U.parent).map(U=>{const oe=U.id===l||U.parent===l;return{id:`${U.parent}-${U.id}`,source:U.parent,target:U.id,type:"smoothstep",style:{stroke:oe?"var(--blue)":"var(--line)",strokeWidth:oe?2:1},zIndex:oe?1:0}}),G=[];for(const U of X){const oe=(U.overlays||[]).find(j=>j.op==="moved"&&j.toParent&&H[j.toParent]);if(!oe)continue;const de=vr(oe.seed);G.push({id:`move-${U.id}-${oe.toParent}`,source:U.id,target:oe.toParent,type:"smoothstep",animated:!0,zIndex:2,className:"move-edge",style:{stroke:de,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6},markerEnd:{type:Wt.ArrowClosed,color:de,width:14,height:14}})}return[...z,...G]},[l,X,H]),Jt=b.useCallback((z,G)=>{const U=M(),oe=performance.now();cancelAnimationFrame($.current);const de=j=>{const me=G?Math.min(1,(j-oe)/G):1,pe=1-Math.pow(1-me,3);k({x:U.x+(z.x-U.x)*pe,y:U.y+(z.y-U.y)*pe,zoom:U.zoom+(z.zoom-U.zoom)*pe}),me<1&&($.current=requestAnimationFrame(de))};$.current=requestAnimationFrame(de)},[M,k]),ze=b.useCallback((z,G,U=300)=>{const oe=_.current;if(!oe)return;const de=G??M().zoom;Jt({x:oe.clientWidth/2-z.x*de,y:oe.clientHeight/2-z.y*de,zoom:de},U)},[Jt,M]),en=b.useRef(!1);b.useEffect(()=>{if(en.current||a!=="graph")return;const z=requestAnimationFrame(()=>{en.current=!0,ze(F,void 0,0)});return()=>cancelAnimationFrame(z)},[ze,F,a]);const Qe=b.useRef(F);Qe.current=F;const tn=b.useRef(ze);tn.current=ze;const nn=b.useRef(!1),Je=b.useRef(!1),ut=b.useRef(null);b.useEffect(()=>{if(a==="graph"){if(!nn.current){nn.current=!0,ut.current=l;return}if(Je.current){Je.current=!1,ut.current=l;return}ut.current!==l&&(ut.current=l,tn.current(Qe.current))}},[l,a]);const dt=u||w||!!y,rn=b.useRef(dt);b.useEffect(()=>{rn.current&&!dt&&Cc(),rn.current=dt},[dt]),b.useEffect(()=>{const z=Ec(F).map(j=>j.key),G=j=>g(me=>{const pe=z.indexOf(me);return z[((pe<0?0:pe)+j+z.length)%z.length]}),U=(j,me)=>{j&&(me.preventDefault(),me.stopPropagation(),R(!0),d(j.id))},oe=j=>B(document.querySelector(".ov-body .pane-doc, .ov-body .pane-hist, .ov-body .pane-issues, .ov-body .pane-eval, .ov-body .pane-edit"),j),de=j=>{var me,pe,ft,sn;if(j.altKey&&!j.metaKey&&!j.ctrlKey){const Ie={Digit1:"graph",Digit2:"sessions",Digit3:"evals",Digit4:"issues",Digit5:"settings"}[j.code];if(Ie){j.preventDefault(),j.stopPropagation(),E(null),ke(Ie);return}if(j.code==="KeyN"){j.preventDefault(),j.stopPropagation(),E(null),v("new"),ke("sessions","new");return}if(j.code==="KeyF"){j.preventDefault(),j.stopPropagation(),E(null),ke("evals");return}}if(y){j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),E(null));return}if((j.metaKey||j.ctrlKey)&&j.key==="/"){j.preventDefault(),j.stopPropagation(),E("sessions");return}if(!(j.metaKey||j.ctrlKey||j.altKey)&&!((j.key==="Enter"||j.key===" ")&&((pe=(me=j.target)==null?void 0:me.closest)!=null&&pe.call(me,"button, a[href], input, select, textarea, summary")))&&a!=="sessions"&&!(a==="evals"||a==="issues")){if(a==="settings"){fe("graph.settings",j.key)&&(j.preventDefault(),j.stopPropagation(),ke("graph"));return}if(u){const _e=j.key==="Escape"?null:(sn=(ft=j.target)==null?void 0:ft.closest)==null?void 0:sn.call(ft,'input, textarea, select, [role="menu"], [role="menuitemradio"], [aria-haspopup="menu"]');if(_e!=null&&_e.closest("[data-focus-overlay]"))return;if(j.key==="Escape"){j.preventDefault(),f(!1);return}if(j.shiftKey){if(fe("nav.up",j.key))return U($e,j);if(fe("nav.down",j.key))return U(be,j);if(fe("nav.parent",j.key))return U(Ce,j);if(fe("nav.child",j.key))return U(ye,j)}if(j.key==="Tab"){j.preventDefault(),j.stopPropagation(),G(j.shiftKey?-1:1);return}if(j.key==="ArrowLeft"||j.key==="h"){j.preventDefault(),j.stopPropagation(),G(-1);return}if(j.key==="ArrowRight"||j.key==="l"){j.preventDefault(),j.stopPropagation(),G(1);return}if(/^[1-9]$/.test(j.key)&&+j.key<=z.length){j.preventDefault(),j.stopPropagation(),g(z[+j.key-1]);return}if(j.key==="j"||j.key==="k"||j.key==="ArrowDown"||j.key==="ArrowUp"){j.preventDefault(),j.stopPropagation(),oe(j.key==="j"||j.key==="ArrowDown"?120:-120);return}return}if(w){if(j.key==="Escape"||j.key==="?"){j.preventDefault(),x(!1);return}if(j.key==="j"||j.key==="k"||j.key==="ArrowDown"||j.key==="ArrowUp"){j.preventDefault(),j.stopPropagation(),O(document.querySelector(".legend"),j.key==="j"||j.key==="ArrowDown"?120:-120);return}return}if(fe("graph.help",j.key)){j.preventDefault(),x(!0);return}if(j.key==="Escape"&&N){j.preventDefault(),j.stopPropagation(),C(null);return}if(fe("graph.settings",j.key)){j.preventDefault(),ke("settings");return}if(fe("graph.search",j.key)){j.preventDefault(),j.stopPropagation(),E("nodes");return}if(!j.metaKey&&!j.ctrlKey&&!j.altKey&&/^[a-zA-Z]$/.test(j.key)){const _e=S.current;if(_e.buf||Gm.has(j.key)){clearTimeout(_e.timer);const Ie=_e.buf+j.key;if(Tt[Ie]){j.preventDefault(),j.stopPropagation(),S.current={buf:"",timer:0},ge(Tt[Ie](F.id));return}if(_a.some(tr=>tr.startsWith(Ie))){j.preventDefault(),j.stopPropagation(),S.current={buf:Ie,timer:setTimeout(()=>{S.current={buf:"",timer:0}},700)};return}S.current={buf:"",timer:0}}}if(fe("nav.up",j.key))return U($e,j);if(fe("nav.down",j.key))return U(be,j);if(fe("nav.parent",j.key))return U(Ce,j);if(fe("nav.child",j.key))return U(ye,j);if(fe("graph.zoomIn",j.key))j.preventDefault(),R(!0),ze(F,Ns(M().zoom*1.2),160);else if(fe("graph.zoomOut",j.key))j.preventDefault(),R(!0),ze(F,Ns(M().zoom/1.2),160);else if(fe("graph.zoomReset",j.key))j.preventDefault(),R(!0),ze(F,.85,200);else if(fe("graph.info",j.key))j.preventDefault(),f(!0);else if(fe("graph.cycle",j.key)||fe("graph.cycleRev",j.key)){if(j.preventDefault(),!re.length)return;R(!0);const _e=ba(re,F.id,fe("graph.cycleRev",j.key)?-1:1,Ie=>Ie.id);_e&&d(_e.id)}else fe("graph.fresh",j.key)?(j.preventDefault(),ge(`[[${F.id}]] `)):fe("graph.evals",j.key)&&(j.preventDefault(),ke("evals"))}};return window.addEventListener("keydown",de,!0),()=>window.removeEventListener("keydown",de,!0)},[u,a,w,y,N,F,re,$e,be,ye,Ce,ze,M,ce,ge,B,O]),b.useEffect(()=>{const z=G=>{const U=V.current,oe=G.clientX!==U.x||G.clientY!==U.y;U.x=G.clientX,U.y=G.clientY,oe&&A.current&&R(!1)};return window.addEventListener("mousemove",z,!0),()=>window.removeEventListener("mousemove",z,!0)},[]);const Qn=b.useCallback((z,G)=>{G.id!==Qe.current.id&&(Je.current=!0),d(G.id)},[]),Jn=b.useCallback((z,G)=>{G.id!==Qe.current.id&&(Je.current=!0),d(G.id),f(!0)},[]),er=b.useCallback((z,G)=>{z.preventDefault(),G.id!==Qe.current.id&&(Je.current=!0),d(G.id),W({x:z.clientX,y:z.clientY,id:G.id})},[]),on=b.useCallback((z,G=!0)=>{const U=G&&N===z.source;if(C(U?null:z.source),U)return;const oe=new Set((z.ops||[]).map(j=>j.nodeId)),de=e.find(j=>oe.has(j.id));de&&d(de.id)},[N,e]);return p.jsxs("div",{className:P?"app kbd-mode":"app",children:[p.jsx(Hm,{}),p.jsx(Rm,{page:a,identity:r,catalog:o}),p.jsxs("div",{className:"app-main",children:[p.jsx(jt,{active:a==="graph",warm:!0,className:"page-graph",children:p.jsxs("div",{className:"graph",ref:_,children:[p.jsx(Ep,{nodes:Zn,edges:Ct,nodeTypes:Xm,onNodeClick:Qn,onNodeDoubleClick:Jn,onNodeContextMenu:er,nodeOrigin:Km,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesFocusable:!1,disableKeyboardA11y:!0,defaultViewport:{x:0,y:0,zoom:.85},minZoom:.4,maxZoom:1.6,proOptions:{hideAttribution:!0}}),p.jsxs("div",{className:"hud",children:[p.jsxs("span",{className:"brand",children:["$ ",i||"spec-dashboard"]}),p.jsx("button",{className:"hud-help",onClick:()=>x(z=>!z),"data-tip":L("hud.helpTitle"),children:"?"})]}),p.jsx(Nc,{sessions:t,activeId:N,onPick:on,onOpenSession:ce}),p.jsx(Pm,{specs:e,focusId:l,onJump:d}),p.jsx(tm,{menu:T,onClose:()=>W(null),onInfo:()=>f(!0),onFresh:z=>ge(`[[${z}]] `),onNewChild:z=>ge(Tt.nn(z)),onDelete:z=>ge(Tt.dd(z)),sessions:Se,onOpenSession:ce}),Z&&p.jsxs("div",{className:"lock-hint",style:{"--ov":vr(Z.id)},children:[p.jsxs("span",{className:"lock-hint-lead",children:[p.jsx(Sc,{})," ",Lr(Z)]}),q.length?p.jsx("span",{className:"lock-hint-body",children:Om(q.length)?p.jsxs(p.Fragment,{children:[L("lockHint.cycleBefore"),p.jsx("kbd",{children:ie.next}),L("lockHint.cycleNext"),p.jsx("span",{className:"lock-hint-sep",children:" / "}),p.jsx("kbd",{children:ie.prev}),L("lockHint.cyclePrev"),L("lockHint.cycleAfter",{n:q.length})]}):L("lockHint.singleChanged")}):p.jsx("span",{className:"lock-hint-body",children:L("lockHint.empty")}),p.jsx("button",{className:"lock-hint-release",onClick:()=>C(null),"data-tip":L("lockHint.releaseTitle"),children:L("lockHint.release")})]}),w&&p.jsx(lm,{onClose:()=>x(!1)})]})}),u&&p.jsx(kc,{node:F,pane:h,setPane:g,sessions:t,onClose:()=>f(!1)},F.id),p.jsx(jt,{active:a==="sessions",warm:!0,className:"page-sessions",children:p.jsx(Bm,{sessions:t,specs:e,focusNode:F,open:a==="sessions",searchOpen:!!y,sel:m,setSel:v,seed:I,onSeedConsumed:()=>D(null),onClose:()=>ke("graph"),onPickSession:on,onOpenSearch:()=>E("sessions"),boardLive:s,reload:n})}),p.jsx(jt,{active:a==="evals",className:"page-evals",children:p.jsx(Fm,{specs:e,sessions:t,reloadBoard:n,onOpenSession:ce,onFocusNode:z=>{d(z),ke("graph")}})}),p.jsx(jt,{active:a==="issues",className:"page-issues",children:p.jsx(Wm,{specs:e,sessions:t,onOpenSession:ce,onFocusNode:z=>{d(z),ke("graph")}})}),p.jsx(jt,{active:a==="settings",className:"page-settings",children:p.jsx(Ym,{})}),y&&p.jsx(Am,{specs:e,sessions:t,onPick:Me,onClose:()=>E(null),boost:y==="sessions"?"session":null})]})]})}function Zm(e){return p.jsx(ha,{children:p.jsx(Um,{...e})})}const n0=Object.freeze(Object.defineProperty({__proto__:null,default:Zm},Symbol.toStringTag,{value:"Module"}));export{em as C,n0 as D,gr as a,It as b,ms as c};
|
|
27
|
+
${u.body}`}}),i=s.length,a=s.reduce((u,f)=>u+f.bodyWords.length,0)/(i||1),c=s.reduce((u,f)=>u+f.descWords.length,0)/(i||1),l={};for(const u of o){let f=0;for(const h of s)(h.nameWords.some(g=>ym(u,g))||h.descWords.some(g=>Tn(u,g))||h.bodyWords.some(g=>Tn(u,g)))&&f++;l[u]=f>0?Math.log(i/f):0}const d=[];for(const u of s){let f=0;for(const h of o)f+=Math.min(vm(h,u,a,c)*l[h],ya);f<=0||d.push({ref:u.ref,score:Math.round(f*100)/100,snippet:bm(u.snippetText,u.desc,o)})}return d.sort((u,f)=>f.score-u.score),d.slice(0,r)}let mr=null;function Em(e=!0){const[t,n]=b.useState(mr),r=b.useRef(!1);return b.useEffect(()=>{!e||r.current||(r.current=!0,fetch(tc("/api/specs/lite")).then(o=>o.ok?o.json():[]).then(o=>{mr={bodies:Object.fromEntries((o||[]).map(s=>[s.id,s.body||""]))},n(mr)}).catch(()=>{}))},[e]),t}const Nm={pass:"var(--green)",fail:"var(--red)",stalePass:"var(--muted)",staleFail:"var(--muted)",empty:"var(--muted)",missing:"var(--muted)"},yr=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,""),vs=["spec","session","issue","scenario"],Sm=e=>e?[e,...vs.filter(t=>t!==e)]:vs,km=new Set(["issue","scenario"]);function Mm(e,t,n,r=[],o=[]){var c,l;const s=n==null?void 0:n.bodies,i=[],a=Object.fromEntries(e.map(d=>[d.id,d]));for(const d of e){const u=yr(d.path);i.push({kind:"spec",key:`spec:${d.id}`,target:d.id,address:hc(d.id),color:(ot[d.status]||ot.pending).color,title:d.title||d.id,sub:u,name:`${d.title||d.id} ${d.id}`,desc:d.desc||"",body:(s==null?void 0:s[d.id])??d.body??""})}for(const d of r){const u=((c=d.nodes)==null?void 0:c[0])||null,f=yr((l=a[u])==null?void 0:l.path);i.push({kind:"issue",key:`issue:${d.id}`,target:d.id,nodeId:u,address:gc(d.id),color:d.status==="open"?"var(--green)":"var(--muted)",title:d.concern,sub:[d.id,f].filter(Boolean).join(" · "),name:d.concern||"",desc:d.id,body:""})}for(const d of o){const u=a[d.node],f=d.filterKind===pc.RESULT;i.push({kind:"scenario",key:`scenario:${d.node}:${d.scenario}`,target:d.scenario,nodeId:d.node,address:f?fo(d.node,d.scenario):fo(d.node),color:Nm[d.state||"missing"]||"var(--cyan)",title:d.scenario,sub:yr(u==null?void 0:u.path),tags:d.tags,name:d.scenario||"",desc:"",body:d.expected||""})}for(const d of t){const u=Lr(d),f=mc(d),h=d.status||d.promptPreview||d.note||"";i.push({kind:"session",key:`session:${d.id}`,target:d.id,address:yc(d.id),color:br[d.status]||br.offline,title:u,sub:h,name:u||"",desc:d.status||"",body:`${d.promptPreview||d.note||""} ${f}`.trim()})}return i}function Cm(e,t,n){const r=Object.fromEntries(n.map((a,c)=>[a,c])),o=(a,c)=>r[a.kind]-r[c.kind]||a.name.length-c.name.length||a.key.localeCompare(c.key);if(!t.trim())return e.slice().sort(o).slice(0,15);const s={};for(const a of n){const c=e.filter(l=>l.kind===a);s[a]=km.has(a)?c.slice(0,15):_m(t,c.sort((l,d)=>l.name.length-d.name.length||l.key.localeCompare(d.key)).map(l=>({ref:l,name:l.name,desc:l.desc,body:l.body})),{limit:15}).map(l=>l.ref)}const i=[];for(let a=0;i.length<15;a++){let c=!1;for(const l of n)s[l][a]&&i.length<15&&(i.push(s[l][a]),c=!0);if(!c)break}return i}function Am({specs:e,sessions:t,onPick:n,onClose:r,boost:o=null}){var W,M;const s=Xe(),i=Em(),[a,c]=b.useState(""),[l,d]=b.useState("");b.useEffect(()=>{if(!a.trim()){d(a);return}const k=setTimeout(()=>d(a),120);return()=>clearTimeout(k)},[a]);const[u,f]=b.useState(0),h=b.useRef(null),g=b.useRef(null),w=b.useMemo(()=>Sm(o),[o]),x=`is:issue${l.trim()?` ${l.trim()}`:""}`,y=`is:eval${l.trim()?` ${l.trim()}`:""}`,E=uo("issues",x,1,{pollMs:0}),m=uo("evals",y,1,{pollMs:0}),v=((W=E.data)==null?void 0:W.items)||[],N=((M=m.data)==null?void 0:M.items)||[],C=b.useMemo(()=>Mm(e,t,i,v,N),[e,t,i,E.data,m.data]),I=b.useMemo(()=>Cm(C,l,w),[C,l,w]);b.useEffect(()=>{var k;(k=h.current)==null||k.focus()},[]),b.useEffect(()=>{f(0)},[a]),b.useEffect(()=>{var k,L;(L=(k=g.current)==null?void 0:k.querySelector(".search-item.on"))==null||L.scrollIntoView({block:"nearest"})},[u,I]);const D=k=>{k&&(n(k),r())},T=k=>{k.key==="ArrowDown"?(k.preventDefault(),f(L=>Math.min(I.length-1,L+1))):k.key==="ArrowUp"?(k.preventDefault(),f(L=>Math.max(0,L-1))):k.key==="Enter"?(k.preventDefault(),D(I[u])):k.key==="Escape"&&(k.preventDefault(),r())};return p.jsx("div",{className:"search-backdrop","data-focus-overlay":!0,onClick:r,children:p.jsxs("div",{className:"search-panel",role:"dialog","aria-modal":"true","aria-label":s("search.title"),onClick:k=>k.stopPropagation(),children:[p.jsxs("div",{className:"search-bar",children:[p.jsx("span",{className:"search-icon",children:"⌕"}),p.jsx("input",{ref:h,className:"search-input",value:a,placeholder:s("search.placeholder"),onChange:k=>c(k.target.value),onKeyDown:T})]}),p.jsxs("ul",{className:"search-results",ref:g,children:[I.length===0&&p.jsx("li",{className:"search-empty",children:s("search.empty")}),I.map((k,L)=>p.jsxs("li",{className:`search-item${L===u?" on":""}`,onMouseEnter:()=>f(L),onClick:()=>D(k),children:[p.jsx("span",{className:"node-dot",style:{background:k.color}}),p.jsx("span",{className:`search-kind k-${k.kind}`,children:s(`search.kind.${k.kind}`)}),p.jsx("span",{className:"search-title",children:k.title||k.target}),p.jsx(fc,{tags:k.tags}),p.jsx("span",{className:"search-path",children:k.sub})]},k.key))]}),p.jsx("div",{className:"search-foot",children:s("search.hint")})]})})}function ba(e,t,n=1,r=o=>o){if(!e.length)return null;const o=e.findIndex(s=>r(s)===t);return o===-1?n>0?e[0]:e[e.length-1]:e[(o+n+e.length)%e.length]}const $m=["merged","active","drift","pending"],Im=[{state:"pass",always:!0,titleKey:"scorePass"},{state:"fail",always:!0,titleKey:"scoreFail"},{state:"stalePass",always:!1,titleKey:"scoreStalePass"},{state:"staleFail",always:!1,titleKey:"scoreStaleFail"},{state:"empty",always:!1,titleKey:"scoreEmpty"}];function jm(e){var a,c;const t={merged:[],active:[],drift:[],pending:[]},n=[],r=[],o=new Set,s={pass:0,fail:0,stalePass:0,staleFail:0,empty:0},i={pass:[],fail:[],stalePass:[],staleFail:[],empty:[]};for(const l of e){t[l.status]&&t[l.status].push(l.id),l.drift>0&&n.push(l.id);const d=(a=l.reviewSummary)==null?void 0:a.issues;if(d!=null&&d.open){r.push(l.id);for(const f of d.openIds||[])o.add(f)}const u=(c=l.reviewSummary)==null?void 0:c.evals;if(u)for(const f of Object.keys(s)){const h=u[f]||0;s[f]+=h,h>0&&i[f].push(l.id)}}return{total:e.length,status:t,driftIds:n,issueIds:r,issueCount:o.size,scoreCount:s,scoreNodes:i}}function xn({count:e,ids:t,focusId:n,onJump:r,title:o,cls:s="",children:i}){const a=t.length>0;return p.jsxs("button",{type:"button",className:`bstat ${s}`.trim(),disabled:!a,"data-tip":o,"aria-label":o,onClick:a?()=>r(ba(t,n)):void 0,children:[i,e]})}function Pm({specs:e,focusId:t,onJump:n}){const r=Xe(),o=b.useMemo(()=>jm(e),[e]),s=i=>i&&(n==null?void 0:n(i));return p.jsxs("div",{className:"graph-stats",role:"group","aria-label":r("stats.aria"),children:[p.jsx("span",{className:"bstat-total","data-tip":r("stats.totalTitle",{n:o.total}),children:o.total}),$m.map(i=>p.jsx(xn,{count:o.status[i].length,ids:o.status[i],focusId:t,onJump:s,title:r("stats.statusTitle",{n:o.status[i].length,status:r(`status.${i}`)}),children:p.jsx("span",{className:"bstat-dot",style:{background:ot[i].color}})},i)),p.jsx("span",{className:"bstat-sep"}),p.jsx(xn,{count:o.driftIds.length,ids:o.driftIds,focusId:t,onJump:s,cls:"bstat-drift",title:r("stats.driftTitle",{n:o.driftIds.length}),children:"⚠"}),p.jsx(xn,{count:o.issueCount,ids:o.issueIds,focusId:t,onJump:s,cls:"bstat-issue",title:r("stats.issueTitle",{n:o.issueCount}),children:"◆"}),p.jsx("span",{className:"bstat-sep"}),Im.map(({state:i,always:a,titleKey:c})=>{const l=o.scoreCount[i],d=o.scoreNodes[i];return!l&&!a?null:p.jsx(xn,{count:l,ids:d,focusId:t,onJump:s,title:r(`stats.${c}`,{n:l}),children:p.jsx(xc,{state:i})},i)})]})}const Dm=wc.filter(e=>e!=="settings");function bs({page:e,active:t,label:n}){return p.jsx("a",{className:t?"rail-btn on":"rail-btn","data-tip":n,"aria-label":n,"aria-current":t?"page":void 0,href:vc(e),children:p.jsx(Sn,{name:e,size:18})})}function Tm({identity:e,projects:t,gatewayIdentity:n,t:r}){const[o,s]=b.useState(!1),i=b.useRef(null);b.useEffect(()=>{if(!o)return;const c=d=>{var u;(u=i.current)!=null&&u.contains(d.target)||s(!1)},l=d=>{d.key==="Escape"&&(d.stopPropagation(),s(!1))};return document.addEventListener("mousedown",c,!0),window.addEventListener("keydown",l,!0),()=>{document.removeEventListener("mousedown",c,!0),window.removeEventListener("keydown",l,!0)}},[o]);const a=(e==null?void 0:e.title)||wn||"";return p.jsxs("div",{className:"proj-chip-wrap",ref:i,children:[p.jsx("button",{type:"button",className:o?"rail-btn proj-chip on":"rail-btn proj-chip","data-tip":r("nav.projectChip",{name:a}),"aria-label":r("nav.projectChip",{name:a}),"aria-haspopup":t?"menu":void 0,"aria-expanded":t?o:void 0,onClick:()=>{t&&s(c=>!c)},children:p.jsx(rr,{icon:e==null?void 0:e.icon,size:26})}),o&&t&&p.jsxs("div",{className:"proj-menu",role:"menu",children:[t.map(c=>p.jsxs("a",{role:"menuitem",className:c.id===wn?"proj-menu-item current":"proj-menu-item",href:nc(c.id),children:[p.jsx(rr,{icon:c.identity.icon,size:16,className:"proj-menu-mark"}),c.gated&&p.jsx(Sn,{name:"lock",size:11}),p.jsx("span",{className:"proj-menu-name",children:c.identity.title}),c.id===wn&&p.jsx(Sn,{name:"check",size:12})]},c.id)),p.jsxs("a",{role:"menuitem",className:"proj-menu-item all",href:rc(),children:[p.jsx(rr,{icon:n==null?void 0:n.icon,fallback:"gateway",size:16,className:"proj-menu-mark"}),p.jsx("span",{className:"proj-menu-name",children:r("nav.allProjects")})]})]})]})}function Rm({page:e,identity:t,catalog:n}){const r=Xe(),o=(n==null?void 0:n.state)==="ok";return p.jsxs("nav",{className:"side-rail","aria-label":r("nav.railLabel"),onMouseDownCapture:ks,children:[wn&&p.jsx(Tm,{identity:t,projects:o?n.projects:null,gatewayIdentity:o?n.gateway.identity:null,t:r}),Dm.map(s=>p.jsx(bs,{page:s,active:e===s,label:r(`nav.${s}`)},s)),p.jsx("div",{className:"rail-spacer"}),p.jsx(bs,{page:"settings",active:e==="settings",label:r("nav.settings")})]})}const Lm=400,zm=80,xr=7,wr=6;function Hm(){const[e,t]=b.useState(null),n=b.useRef(null),r=b.useRef(0),o=b.useRef(null),s=b.useRef(null),i=b.useRef(!1);return b.useEffect(()=>{const a=()=>{r.current&&(clearTimeout(r.current),r.current=0)},c=()=>{a(),o.current=null,s.current&&(s.current.getAttribute("aria-describedby")==="ui-tip"&&s.current.removeAttribute("aria-describedby"),s.current=null),t(x=>(x&&(i.current=!0,setTimeout(()=>{o.current||(i.current=!1)},300)),null))},l=x=>{const y=x.getAttribute("data-tip");!y||!x.isConnected||(o.current=x,x.getAttribute("aria-describedby")||(x.setAttribute("aria-describedby","ui-tip"),s.current=x),t({text:y,anchor:x}))},d=(x,y)=>{o.current!==x&&(a(),o.current=x,r.current=setTimeout(()=>{r.current=0,l(x)},y))},u=x=>{var E,m;const y=(m=(E=x.target).closest)==null?void 0:m.call(E,"[data-tip]");y&&d(y,i.current?zm:Lm)},f=x=>{var E,m;const y=(m=(E=x.target).closest)==null?void 0:m.call(E,"[data-tip]");!y||y!==o.current||y.contains(x.relatedTarget)||c()},h=x=>{var m,v;const y=(v=(m=x.target).closest)==null?void 0:v.call(m,"[data-tip]");if(!y)return;let E=!0;try{E=y.matches(":focus-visible")}catch{}E&&(a(),l(y))},g=x=>{var E,m;const y=(m=(E=x.target).closest)==null?void 0:m.call(E,"[data-tip]");y&&y===o.current&&c()},w=x=>{x.key==="Escape"&&c()};return document.addEventListener("pointerover",u,!0),document.addEventListener("pointerout",f,!0),document.addEventListener("focusin",h,!0),document.addEventListener("focusout",g,!0),document.addEventListener("keydown",w,!0),document.addEventListener("pointerdown",c,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{a(),document.removeEventListener("pointerover",u,!0),document.removeEventListener("pointerout",f,!0),document.removeEventListener("focusin",h,!0),document.removeEventListener("focusout",g,!0),document.removeEventListener("keydown",w,!0),document.removeEventListener("pointerdown",c,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[]),b.useEffect(()=>{const a=n.current;if(!e||!a)return;if(!e.anchor.isConnected){t(null);return}const c=e.anchor.getBoundingClientRect(),l=a.getBoundingClientRect(),d=c.top-l.height-xr>=wr?"top":"bottom",u=d==="top"?c.top-l.height-xr:c.bottom+xr,f=Math.min(Math.max(c.left+c.width/2-l.width/2,wr),window.innerWidth-l.width-wr);a.dataset.place=d,a.style.top=`${Math.round(u)}px`,a.style.left=`${Math.round(f)}px`;const h=a.querySelector(".ui-tip-arrow");h&&(h.style.left=`${Math.round(Math.min(Math.max(c.left+c.width/2-f,10),l.width-10))-4}px`);const g=requestAnimationFrame(()=>a.classList.add("show"));return()=>cancelAnimationFrame(g)},[e]),e?oc.createPortal(p.jsxs("div",{id:"ui-tip",role:"tooltip",ref:n,className:"ui-tip",children:[e.text,p.jsx("span",{className:"ui-tip-arrow","aria-hidden":"true"})]}),document.body):null}function _s(){let e=0,t=null,n=null,r=null;return function(s,i){if(!s)return;const a=r!=null&&Math.abs(s.scrollTop-r)>1;(s!==n||a)&&(n=s,t=null,r=null);const c=s.scrollHeight-s.clientHeight,l=t??s.scrollTop;t=Math.max(0,Math.min(c,l+i)),cancelAnimationFrame(e);const d=()=>{if(r!=null&&Math.abs(s.scrollTop-r)>1){cancelAnimationFrame(e),t=null,r=null;return}const u=t-s.scrollTop;if(Math.abs(u)<.5){s.scrollTop=t,r=s.scrollTop;return}s.scrollTop+=u*.2,r=s.scrollTop,e=requestAnimationFrame(d)};e=requestAnimationFrame(d)}}function Om(e){return e>1}function Vm(e){return{next:_r((e("graph.cycle")||[])[0]||"o"),prev:_r((e("graph.cycleRev")||[])[0]||"O")}}const Bm=b.lazy(()=>Rn(()=>import("./SessionInterface-BtrzlOPs.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Fm=b.lazy(()=>Rn(()=>import("./EvalsPage-KbMMownG.js"),__vite__mapDeps([10,1,2,5,6]))),Wm=b.lazy(()=>Rn(()=>import("./IssuesPage-DmyLb9Rj.js"),__vite__mapDeps([11,1,2,5,6,7]))),Ym=b.lazy(()=>Rn(()=>import("./Settings-COgdKTJB.js"),__vite__mapDeps([12,1,2,8,6,3]))),Xm={spec:Jp},Km=[.5,.5],Es={width:176,height:50},qm=[{type:"target",position:Q.Left,x:-1.5,y:22.5,width:5,height:5},{type:"source",position:Q.Right,x:172.5,y:22.5,width:5,height:5}],Ns=e=>Math.max(.4,Math.min(1.6,e)),Tt={nn:e=>`Create a new spec node under [[${e}]] — choose a kebab-case id, write its spec.md at contract altitude with a code: list, implement it, then propose merge. What it should be: `,dd:e=>`Delete the [[${e}]] spec node — remove its dir, repoint or fold its governed code, fix any [[…]] refs, recover its intent from git history, then propose merge. Why: `},_a=Object.keys(Tt),Gm=new Set(_a.map(e=>e[0]));function jt({active:e,warm:t=!1,className:n,children:r}){const o=Xe();return!t&&!e?null:p.jsx("div",{className:n?`page-pane ${n}`:"page-pane",style:e?void 0:{display:"none"},children:p.jsx(b.Suspense,{fallback:p.jsx("div",{className:"loading",children:o("hud.loading")}),children:r})})}function Um({specs:e,sessions:t,reload:n,identity:r,catalog:o,boardLive:s}){const i=(r==null?void 0:r.title)||"",{page:a,param:c}=bc(),[l,d]=b.useState(()=>{var G;let z=null;try{z=sessionStorage.getItem("spex.focus")}catch{}return(z&&e.some(U=>U.id===z)?z:null)||((G=e.find(U=>!U.parent))==null?void 0:G.id)});b.useEffect(()=>{try{l&&sessionStorage.setItem("spex.focus",l)}catch{}},[l]);const[u,f]=b.useState(!1),[h,g]=b.useState("spec"),[w,x]=b.useState(!1),[y,E]=b.useState(null),[m,v]=b.useState("new"),[N,C]=b.useState(null),[I,D]=b.useState(null),[T,W]=b.useState(null),{getViewport:M,setViewport:k}=qn(),L=Xe(),_=b.useRef(null),$=b.useRef(0),S=b.useRef({buf:"",timer:0}),[P,R]=b.useState(!1),A=b.useRef(!1);A.current=P;const V=b.useRef({x:-1,y:-1}),B=b.useMemo(()=>_s(),[]),O=b.useMemo(()=>_s(),[]),Y=b.useMemo(()=>Object.fromEntries(e.map(z=>[z.id,z])),[e]),K=Y[l]||e.find(z=>!z.parent)||e[0],J=b.useMemo(()=>{const z=new Set;for(let G=K;G;G=G.parent?Y[G.parent]:null)z.add(G.id);return z},[K,Y]),ne=b.useMemo(()=>sc(e,J),[e,J]),X=b.useMemo(()=>e.filter(z=>ne[z.id]).map(z=>({...z,...ne[z.id]})),[e,ne]),H=b.useMemo(()=>Object.fromEntries(X.map(z=>[z.id,z])),[X]),F=H[K.id],te=b.useMemo(()=>{const z={};return e.forEach(G=>{G.parent&&(z[G.parent]=(z[G.parent]||0)+1)}),z},[e]),ee=b.useMemo(()=>e.filter(z=>{var G;return(G=z.overlays)==null?void 0:G.length}),[e]),Z=b.useMemo(()=>N?t.find(z=>z.source===N):null,[t,N]),q=b.useMemo(()=>N?e.filter(z=>(z.overlays||[]).some(G=>G.source===N)):[],[e,N]),re=b.useMemo(()=>N?q:ee,[N,q,ee]),ie=Vm(Ms),ae=b.useCallback(z=>z?t.filter(G=>{var U;return(U=G.ops)==null?void 0:U.some(oe=>oe.nodeId===z.id)}):[],[t]),ce=b.useCallback(z=>{v(z),ke("sessions",z)},[]),ge=b.useCallback(z=>{v("new"),D(z),ke("sessions","new")},[]),ve=b.useCallback(z=>{_c(z,{onFocusNode:d,onOpenSession:ce})},[ce]),Se=b.useMemo(()=>{var U;if(!T)return[];const z=e.find(oe=>oe.id===T.id);return(U=z==null?void 0:z.overlays)!=null&&U.length?[...new Set(z.overlays.map(oe=>oe.source))].map(oe=>t.find(de=>de.source===oe)).filter(Boolean):[]},[T,e,t]),Me=b.useCallback(z=>{ve(z.address)},[ve]);b.useLayoutEffect(()=>{if(a!=="sessions"||!c)return;const z=c.split("/")[0];z&&z!==m&&v(z)},[a,c]),b.useEffect(()=>{a==="sessions"&&ke("sessions",m,{replace:!0})},[a,m]),b.useEffect(()=>{a!=="graph"&&(f(!1),x(!1),E(null),W(null))},[a]);const Be=b.useMemo(()=>X.filter(z=>z.parent===F.id),[X,F]),Ce=F.parent?H[F.parent]:null,Ae=b.useMemo(()=>Be.length?Be.reduce((z,G)=>Math.abs(G.y-F.y)<Math.abs(z.y-F.y)?G:z):null,[Be,F]),ye=b.useMemo(()=>{if(Ae)return Ae;let z=null,G=1/0;for(const U of X){const oe=U.x-F.x;if(oe<=0)continue;const de=U.y-F.y,j=(oe/ic)**2+(de/ac)**2;j<G&&(G=j,z=U)}return z},[Ae,X,F]),xe=b.useCallback(z=>{let G=null;for(const U of X){if(U.id===F.id||U.x!==F.x)continue;const oe=U.y-F.y;(z==="down"?oe<=0:oe>=0)||(!G||Math.abs(oe)<Math.abs(G.y-F.y))&&(G=U)}return G},[X,F]),be=b.useMemo(()=>xe("down"),[xe]),$e=b.useMemo(()=>xe("up"),[xe]),Zn=b.useMemo(()=>X.map(z=>{const G=z.id===l||z.id===F.parent||z.parent===l||z.parent===F.parent;let U;N&&q.length?U=(z.overlays||[]).some(pe=>pe.source===N)?"ov-hot":"ov-dim":U=G?void 0:"is-far";const de=ae(z).map(pe=>({id:pe.id,status:pe.status,node:pe.node})),j=te[z.id]||0,me={editors:de,collapsed:j>0&&!J.has(z.id),childCount:j};return{id:z.id,type:"spec",position:{x:z.x,y:z.y},data:{...z,...me},initialWidth:Es.width,initialHeight:Es.height,handles:qm,draggable:!1,selected:z.id===l,className:U}}),[l,F.parent,N,q,X,ae,te,J]),Ct=b.useMemo(()=>{const z=X.filter(U=>U.parent).map(U=>{const oe=U.id===l||U.parent===l;return{id:`${U.parent}-${U.id}`,source:U.parent,target:U.id,type:"smoothstep",style:{stroke:oe?"var(--blue)":"var(--line)",strokeWidth:oe?2:1},zIndex:oe?1:0}}),G=[];for(const U of X){const oe=(U.overlays||[]).find(j=>j.op==="moved"&&j.toParent&&H[j.toParent]);if(!oe)continue;const de=vr(oe.seed);G.push({id:`move-${U.id}-${oe.toParent}`,source:U.id,target:oe.toParent,type:"smoothstep",animated:!0,zIndex:2,className:"move-edge",style:{stroke:de,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6},markerEnd:{type:Wt.ArrowClosed,color:de,width:14,height:14}})}return[...z,...G]},[l,X,H]),Jt=b.useCallback((z,G)=>{const U=M(),oe=performance.now();cancelAnimationFrame($.current);const de=j=>{const me=G?Math.min(1,(j-oe)/G):1,pe=1-Math.pow(1-me,3);k({x:U.x+(z.x-U.x)*pe,y:U.y+(z.y-U.y)*pe,zoom:U.zoom+(z.zoom-U.zoom)*pe}),me<1&&($.current=requestAnimationFrame(de))};$.current=requestAnimationFrame(de)},[M,k]),ze=b.useCallback((z,G,U=300)=>{const oe=_.current;if(!oe)return;const de=G??M().zoom;Jt({x:oe.clientWidth/2-z.x*de,y:oe.clientHeight/2-z.y*de,zoom:de},U)},[Jt,M]),en=b.useRef(!1);b.useEffect(()=>{if(en.current||a!=="graph")return;const z=requestAnimationFrame(()=>{en.current=!0,ze(F,void 0,0)});return()=>cancelAnimationFrame(z)},[ze,F,a]);const Qe=b.useRef(F);Qe.current=F;const tn=b.useRef(ze);tn.current=ze;const nn=b.useRef(!1),Je=b.useRef(!1),ut=b.useRef(null);b.useEffect(()=>{if(a==="graph"){if(!nn.current){nn.current=!0,ut.current=l;return}if(Je.current){Je.current=!1,ut.current=l;return}ut.current!==l&&(ut.current=l,tn.current(Qe.current))}},[l,a]);const dt=u||w||!!y,rn=b.useRef(dt);b.useEffect(()=>{rn.current&&!dt&&Cc(),rn.current=dt},[dt]),b.useEffect(()=>{const z=Ec(F).map(j=>j.key),G=j=>g(me=>{const pe=z.indexOf(me);return z[((pe<0?0:pe)+j+z.length)%z.length]}),U=(j,me)=>{j&&(me.preventDefault(),me.stopPropagation(),R(!0),d(j.id))},oe=j=>B(document.querySelector(".ov-body .pane-doc, .ov-body .pane-hist, .ov-body .pane-issues, .ov-body .pane-eval, .ov-body .pane-edit"),j),de=j=>{var me,pe,ft,sn;if(j.altKey&&!j.metaKey&&!j.ctrlKey){const Ie={Digit1:"graph",Digit2:"sessions",Digit3:"evals",Digit4:"issues",Digit5:"settings"}[j.code];if(Ie){j.preventDefault(),j.stopPropagation(),E(null),ke(Ie);return}if(j.code==="KeyN"){j.preventDefault(),j.stopPropagation(),E(null),v("new"),ke("sessions","new");return}if(j.code==="KeyF"){j.preventDefault(),j.stopPropagation(),E(null),ke("evals");return}}if(y){j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),E(null));return}if((j.metaKey||j.ctrlKey)&&j.key==="/"){j.preventDefault(),j.stopPropagation(),E("sessions");return}if(!(j.metaKey||j.ctrlKey||j.altKey)&&!((j.key==="Enter"||j.key===" ")&&((pe=(me=j.target)==null?void 0:me.closest)!=null&&pe.call(me,"button, a[href], input, select, textarea, summary")))&&a!=="sessions"&&!(a==="evals"||a==="issues")){if(a==="settings"){fe("graph.settings",j.key)&&(j.preventDefault(),j.stopPropagation(),ke("graph"));return}if(u){const _e=j.key==="Escape"?null:(sn=(ft=j.target)==null?void 0:ft.closest)==null?void 0:sn.call(ft,'input, textarea, select, [role="menu"], [role="menuitemradio"], [aria-haspopup="menu"]');if(_e!=null&&_e.closest("[data-focus-overlay]"))return;if(j.key==="Escape"){j.preventDefault(),f(!1);return}if(j.shiftKey){if(fe("nav.up",j.key))return U($e,j);if(fe("nav.down",j.key))return U(be,j);if(fe("nav.parent",j.key))return U(Ce,j);if(fe("nav.child",j.key))return U(ye,j)}if(j.key==="Tab"){j.preventDefault(),j.stopPropagation(),G(j.shiftKey?-1:1);return}if(j.key==="ArrowLeft"||j.key==="h"){j.preventDefault(),j.stopPropagation(),G(-1);return}if(j.key==="ArrowRight"||j.key==="l"){j.preventDefault(),j.stopPropagation(),G(1);return}if(/^[1-9]$/.test(j.key)&&+j.key<=z.length){j.preventDefault(),j.stopPropagation(),g(z[+j.key-1]);return}if(j.key==="j"||j.key==="k"||j.key==="ArrowDown"||j.key==="ArrowUp"){j.preventDefault(),j.stopPropagation(),oe(j.key==="j"||j.key==="ArrowDown"?120:-120);return}return}if(w){if(j.key==="Escape"||j.key==="?"){j.preventDefault(),x(!1);return}if(j.key==="j"||j.key==="k"||j.key==="ArrowDown"||j.key==="ArrowUp"){j.preventDefault(),j.stopPropagation(),O(document.querySelector(".legend"),j.key==="j"||j.key==="ArrowDown"?120:-120);return}return}if(fe("graph.help",j.key)){j.preventDefault(),x(!0);return}if(j.key==="Escape"&&N){j.preventDefault(),j.stopPropagation(),C(null);return}if(fe("graph.settings",j.key)){j.preventDefault(),ke("settings");return}if(fe("graph.search",j.key)){j.preventDefault(),j.stopPropagation(),E("nodes");return}if(!j.metaKey&&!j.ctrlKey&&!j.altKey&&/^[a-zA-Z]$/.test(j.key)){const _e=S.current;if(_e.buf||Gm.has(j.key)){clearTimeout(_e.timer);const Ie=_e.buf+j.key;if(Tt[Ie]){j.preventDefault(),j.stopPropagation(),S.current={buf:"",timer:0},ge(Tt[Ie](F.id));return}if(_a.some(tr=>tr.startsWith(Ie))){j.preventDefault(),j.stopPropagation(),S.current={buf:Ie,timer:setTimeout(()=>{S.current={buf:"",timer:0}},700)};return}S.current={buf:"",timer:0}}}if(fe("nav.up",j.key))return U($e,j);if(fe("nav.down",j.key))return U(be,j);if(fe("nav.parent",j.key))return U(Ce,j);if(fe("nav.child",j.key))return U(ye,j);if(fe("graph.zoomIn",j.key))j.preventDefault(),R(!0),ze(F,Ns(M().zoom*1.2),160);else if(fe("graph.zoomOut",j.key))j.preventDefault(),R(!0),ze(F,Ns(M().zoom/1.2),160);else if(fe("graph.zoomReset",j.key))j.preventDefault(),R(!0),ze(F,.85,200);else if(fe("graph.info",j.key))j.preventDefault(),f(!0);else if(fe("graph.cycle",j.key)||fe("graph.cycleRev",j.key)){if(j.preventDefault(),!re.length)return;R(!0);const _e=ba(re,F.id,fe("graph.cycleRev",j.key)?-1:1,Ie=>Ie.id);_e&&d(_e.id)}else fe("graph.fresh",j.key)?(j.preventDefault(),ge(`[[${F.id}]] `)):fe("graph.evals",j.key)&&(j.preventDefault(),ke("evals"))}};return window.addEventListener("keydown",de,!0),()=>window.removeEventListener("keydown",de,!0)},[u,a,w,y,N,F,re,$e,be,ye,Ce,ze,M,ce,ge,B,O]),b.useEffect(()=>{const z=G=>{const U=V.current,oe=G.clientX!==U.x||G.clientY!==U.y;U.x=G.clientX,U.y=G.clientY,oe&&A.current&&R(!1)};return window.addEventListener("mousemove",z,!0),()=>window.removeEventListener("mousemove",z,!0)},[]);const Qn=b.useCallback((z,G)=>{G.id!==Qe.current.id&&(Je.current=!0),d(G.id)},[]),Jn=b.useCallback((z,G)=>{G.id!==Qe.current.id&&(Je.current=!0),d(G.id),f(!0)},[]),er=b.useCallback((z,G)=>{z.preventDefault(),G.id!==Qe.current.id&&(Je.current=!0),d(G.id),W({x:z.clientX,y:z.clientY,id:G.id})},[]),on=b.useCallback((z,G=!0)=>{const U=G&&N===z.source;if(C(U?null:z.source),U)return;const oe=new Set((z.ops||[]).map(j=>j.nodeId)),de=e.find(j=>oe.has(j.id));de&&d(de.id)},[N,e]);return p.jsxs("div",{className:P?"app kbd-mode":"app",children:[p.jsx(Hm,{}),p.jsx(Rm,{page:a,identity:r,catalog:o}),p.jsxs("div",{className:"app-main",children:[p.jsx(jt,{active:a==="graph",warm:!0,className:"page-graph",children:p.jsxs("div",{className:"graph",ref:_,children:[p.jsx(Ep,{nodes:Zn,edges:Ct,nodeTypes:Xm,onNodeClick:Qn,onNodeDoubleClick:Jn,onNodeContextMenu:er,nodeOrigin:Km,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesFocusable:!1,disableKeyboardA11y:!0,defaultViewport:{x:0,y:0,zoom:.85},minZoom:.4,maxZoom:1.6,proOptions:{hideAttribution:!0}}),p.jsxs("div",{className:"hud",children:[p.jsxs("span",{className:"brand",children:["$ ",i||"spec-dashboard"]}),p.jsx("button",{className:"hud-help",onClick:()=>x(z=>!z),"data-tip":L("hud.helpTitle"),children:"?"})]}),p.jsx(Nc,{sessions:t,activeId:N,onPick:on,onOpenSession:ce}),p.jsx(Pm,{specs:e,focusId:l,onJump:d}),p.jsx(tm,{menu:T,onClose:()=>W(null),onInfo:()=>f(!0),onFresh:z=>ge(`[[${z}]] `),onNewChild:z=>ge(Tt.nn(z)),onDelete:z=>ge(Tt.dd(z)),sessions:Se,onOpenSession:ce}),Z&&p.jsxs("div",{className:"lock-hint",style:{"--ov":vr(Z.id)},children:[p.jsxs("span",{className:"lock-hint-lead",children:[p.jsx(Sc,{})," ",Lr(Z)]}),q.length?p.jsx("span",{className:"lock-hint-body",children:Om(q.length)?p.jsxs(p.Fragment,{children:[L("lockHint.cycleBefore"),p.jsx("kbd",{children:ie.next}),L("lockHint.cycleNext"),p.jsx("span",{className:"lock-hint-sep",children:" / "}),p.jsx("kbd",{children:ie.prev}),L("lockHint.cyclePrev"),L("lockHint.cycleAfter",{n:q.length})]}):L("lockHint.singleChanged")}):p.jsx("span",{className:"lock-hint-body",children:L("lockHint.empty")}),p.jsx("button",{className:"lock-hint-release",onClick:()=>C(null),"data-tip":L("lockHint.releaseTitle"),children:L("lockHint.release")})]}),w&&p.jsx(lm,{onClose:()=>x(!1)})]})}),u&&p.jsx(kc,{node:F,pane:h,setPane:g,sessions:t,onClose:()=>f(!1)},F.id),p.jsx(jt,{active:a==="sessions",warm:!0,className:"page-sessions",children:p.jsx(Bm,{sessions:t,specs:e,focusNode:F,open:a==="sessions",searchOpen:!!y,sel:m,setSel:v,seed:I,onSeedConsumed:()=>D(null),onClose:()=>ke("graph"),onPickSession:on,onOpenSearch:()=>E("sessions"),boardLive:s,reload:n})}),p.jsx(jt,{active:a==="evals",className:"page-evals",children:p.jsx(Fm,{specs:e,sessions:t,reloadBoard:n,onOpenSession:ce,onFocusNode:z=>{d(z),ke("graph")}})}),p.jsx(jt,{active:a==="issues",className:"page-issues",children:p.jsx(Wm,{specs:e,sessions:t,onOpenSession:ce,onFocusNode:z=>{d(z),ke("graph")}})}),p.jsx(jt,{active:a==="settings",className:"page-settings",children:p.jsx(Ym,{})}),y&&p.jsx(Am,{specs:e,sessions:t,onPick:Me,onClose:()=>E(null),boost:y==="sessions"?"session":null})]})]})}function Zm(e){return p.jsx(ha,{children:p.jsx(Um,{...e})})}const n0=Object.freeze(Object.defineProperty({__proto__:null,default:Zm},Symbol.toStringTag,{value:"Module"}));export{em as C,n0 as D,gr as a,It as b,ms as c};
|