spexcode 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/package.json +1 -1
  2. package/spec-cli/src/cli.ts +68 -47
  3. package/spec-cli/src/client.ts +1 -1
  4. package/spec-cli/src/codex-runtime-generations.ts +97 -7
  5. package/spec-cli/src/commit-surgery.ts +2 -1
  6. package/spec-cli/src/contract-filter.ts +58 -42
  7. package/spec-cli/src/doctor.ts +2 -1
  8. package/spec-cli/src/file-write.ts +22 -0
  9. package/spec-cli/src/git.ts +30 -8
  10. package/spec-cli/src/graphStream.ts +79 -11
  11. package/spec-cli/src/harness.ts +11 -9
  12. package/spec-cli/src/help.ts +8 -13
  13. package/spec-cli/src/index.ts +8 -1
  14. package/spec-cli/src/init.ts +8 -17
  15. package/spec-cli/src/layout.ts +35 -7
  16. package/spec-cli/src/materialize.ts +150 -107
  17. package/spec-cli/src/plugin-harness.ts +19 -8
  18. package/spec-cli/src/process-identity.ts +13 -0
  19. package/spec-cli/src/reviews.ts +55 -11
  20. package/spec-cli/src/sessions.ts +166 -9
  21. package/spec-cli/src/uninstall.ts +2 -1
  22. package/spec-cli/templates/hooks/post-checkout +3 -0
  23. package/spec-cli/templates/hooks/post-merge +1 -0
  24. package/spec-cli/templates/spec/project/.plugins/commands/supervisor/spec.md +1 -1
  25. package/spec-cli/templates/spec/project/.plugins/core/stop-gate/spec.md +1 -1
  26. package/spec-cli/templates/spec/project/.plugins/core/stop-gate/stop-gate.sh +2 -2
  27. package/spec-dashboard/dist/assets/{App-b8Nh0sgk.js → App-F9uaAVcH.js} +2 -2
  28. package/spec-dashboard/dist/assets/{Dashboard-CvAjfRC2.js → Dashboard-Ba_jhxp1.js} +3 -3
  29. package/spec-dashboard/dist/assets/{EvalsPage-Bz-nMKoS.js → EvalsPage-FixoOg_n.js} +2 -2
  30. package/spec-dashboard/dist/assets/{IssuesPage-CAP64YWE.js → IssuesPage-CuKLFhH3.js} +1 -1
  31. package/spec-dashboard/dist/assets/{MobileApp-D9L1Va8Z.js → MobileApp-CHgEHORJ.js} +2 -2
  32. package/spec-dashboard/dist/assets/{Modal-Drscez-d.js → Modal-CQgYymmr.js} +1 -1
  33. package/spec-dashboard/dist/assets/{PageScroll-qW6uOJL8.js → PageScroll-hT7UTLvD.js} +1 -1
  34. package/spec-dashboard/dist/assets/{ProjectsPage-CjybFBmR.js → ProjectsPage-CtXxakF9.js} +1 -1
  35. package/spec-dashboard/dist/assets/{SessionInterface-Dl9v0JFM.js → SessionInterface-Bpie-9fs.js} +12 -12
  36. package/spec-dashboard/dist/assets/{SessionWindow-iOk0yHoU.js → SessionWindow-CixDi4PI.js} +1 -1
  37. package/spec-dashboard/dist/assets/{Settings-BZ1lGRJs.js → Settings-C2MsucfE.js} +1 -1
  38. package/spec-dashboard/dist/assets/Thread-C6Go8HRh.js +13 -0
  39. package/spec-dashboard/dist/assets/{data-Bwd3kAVL.js → data-B-RQmit6.js} +1 -1
  40. package/spec-dashboard/dist/assets/{index-DAbQBBK_.css → index-CsI8DElI.css} +1 -1
  41. package/spec-dashboard/dist/assets/{index-paP-z_Vd.js → index-DrVao0Ep.js} +2 -2
  42. package/spec-dashboard/dist/assets/{launch-B-bYdWmh.js → launch-BBH02b1v.js} +1 -1
  43. package/spec-dashboard/dist/index.html +2 -2
  44. package/spec-dashboard/src/reviewFilters.js +5 -0
  45. package/spec-dashboard/src/session.js +5 -1
  46. package/spec-eval/src/cli.ts +7 -8
  47. package/spec-eval/src/evaltab.ts +25 -5
  48. package/spec-eval/src/freshness.ts +52 -8
  49. package/spec-eval/src/scenariofresh.ts +58 -8
  50. package/spec-eval/src/scenarios.ts +60 -12
  51. package/spec-eval/src/sessioneval.ts +122 -30
  52. package/spec-dashboard/dist/assets/Thread-D_kcDnfd.js +0 -13
  53. package/spec-eval/src/matrix.ts +0 -693
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionInterface-Dl9v0JFM.js","assets/index-paP-z_Vd.js","assets/index-DAbQBBK_.css","assets/data-Bwd3kAVL.js","assets/terminalFont-C6oGNKrf.js","assets/launch-B-bYdWmh.js","assets/Thread-D_kcDnfd.js","assets/PageScroll-qW6uOJL8.js","assets/launch-Cp579UoJ.css","assets/SessionWindow-iOk0yHoU.js","assets/Modal-Drscez-d.js","assets/bindings-BC9vqpYU.js","assets/SessionInterface-6GBZ9nXN.css","assets/EvalsPage-Bz-nMKoS.js","assets/IssuesPage-CAP64YWE.js","assets/Settings-BZ1lGRJs.js"])))=>i.map(i=>d[i]);
2
- import{r as _,l as Xa,R as Ka,j as m,u as Ze,m as qa,I as Ga,d as Ua,f as Za,n as ke,o as Qa,T as Ja,S as ec,_ as Rn}from"./index-paP-z_Vd.js";import{b as st,G as _s,l as xr,A as tc,c as nc,L as rc}from"./SessionWindow-iOk0yHoU.js";import{Y as oc,Z as sc,s as Tr,_ as ic,X as wr,n as co,$ as ac,a0 as cc,a1 as lc,E as uc,v as lo,a2 as dc,J as fc,w as hc,a3 as gc,a4 as pc,H as mc,a5 as yc}from"./Thread-D_kcDnfd.js";import{M as xc}from"./Modal-Drscez-d.js";import{A as wc,k as Es,a as vr,f as fe}from"./bindings-BC9vqpYU.js";import{k as vc,X as bc,Y as _c}from"./data-Bwd3kAVL.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 Ec={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 bn(n)}function bn(e){this._=e}function Nc(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}})}bn.prototype=Ln.prototype={constructor:bn,on:function(e,t){var n=this._,r=Nc(e+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(e=r[s]).type)&&(o=Sc(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]=uo(n[o],e.name,t);else if(t==null)for(o in n)n[o]=uo(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 bn(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 Sc(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function uo(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=Ec,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var br="http://www.w3.org/1999/xhtml";const fo={svg:"http://www.w3.org/2000/svg",xhtml:br,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)),fo.hasOwnProperty(t)?{space:fo[t],local:e}:e}function Mc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===br&&t.documentElement.namespaceURI===br?t.createElement(e):t.createElementNS(n,e)}}function kc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ns(e){var t=zn(e);return(t.local?kc:Mc)(t)}function Cc(){}function Rr(e){return e==null?Cc:function(){return this.querySelector(e)}}function Ac(e){typeof e!="function"&&(e=Rr(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 Me(r,this._parents)}function $c(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ic(){return[]}function Ss(e){return e==null?Ic:function(){return this.querySelectorAll(e)}}function Pc(e){return function(){return $c(e.apply(this,arguments))}}function jc(e){typeof e=="function"?e=Pc(e):e=Ss(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 Me(r,o)}function Ms(e){return function(){return this.matches(e)}}function ks(e){return function(t){return t.matches(e)}}var Dc=Array.prototype.find;function Tc(e){return function(){return Dc.call(this.children,e)}}function Rc(){return this.firstElementChild}function Lc(e){return this.select(e==null?Rc:Tc(typeof e=="function"?e:ks(e)))}var zc=Array.prototype.filter;function Hc(){return Array.from(this.children)}function Oc(e){return function(){return zc.call(this.children,e)}}function Vc(e){return this.selectAll(e==null?Hc:Oc(typeof e=="function"?e:ks(e)))}function Bc(e){typeof e!="function"&&(e=Ms(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 Me(r,this._parents)}function Cs(e){return new Array(e.length)}function Fc(){return new Me(this._enter||this._groups.map(Cs),this._parents)}function Mn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Mn.prototype={constructor:Mn,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 Wc(e){return function(){return e}}function Yc(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 Mn(e,s[i]);for(;i<c;++i)(a=t[i])&&(o[i]=a)}function Xc(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 Mn(e,s[a]);for(a=0;a<d;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function Kc(e){return e.__data__}function qc(e,t){if(!arguments.length)return Array.from(this,Kc);var n=t?Xc:Yc,r=this._parents,o=this._groups;typeof e!="function"&&(e=Wc(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=Gc(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,p=0,v,M;E<g;++E)if(v=w[E]){for(E>=p&&(p=E+1);!(M=x[p])&&++p<g;);v._next=M||null}}return i=new Me(i,r),i._enter=a,i._exit=c,i}function Gc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Uc(){return new Me(this._exit||this._groups.map(Cs),this._parents)}function Zc(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 Qc(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 Me(a,this._parents)}function Jc(){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 el(e){e||(e=tl);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 Me(o,this._parents).order()}function tl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function nl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function rl(){return Array.from(this)}function ol(){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 sl(){let e=0;for(const t of this)++e;return e}function il(){return!this.node()}function al(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 cl(e){return function(){this.removeAttribute(e)}}function ll(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ul(e,t){return function(){this.setAttribute(e,t)}}function dl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function fl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function hl(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 gl(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?ll:cl:typeof t=="function"?n.local?hl:fl:n.local?dl:ul)(n,t))}function As(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function pl(e){return function(){this.style.removeProperty(e)}}function ml(e,t,n){return function(){this.style.setProperty(e,t,n)}}function yl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function xl(e,t,n){return arguments.length>1?this.each((t==null?pl:typeof t=="function"?yl:ml)(e,t,n??"")):vt(this.node(),e)}function vt(e,t){return e.style.getPropertyValue(t)||As(e).getComputedStyle(e,null).getPropertyValue(t)}function wl(e){return function(){delete this[e]}}function vl(e,t){return function(){this[e]=t}}function bl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function _l(e,t){return arguments.length>1?this.each((t==null?wl:typeof t=="function"?bl:vl)(e,t)):this.node()[e]}function $s(e){return e.trim().split(/^|\s+/)}function Lr(e){return e.classList||new Is(e)}function Is(e){this._node=e,this._names=$s(e.getAttribute("class")||"")}Is.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 Ps(e,t){for(var n=Lr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function js(e,t){for(var n=Lr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function El(e){return function(){Ps(this,e)}}function Nl(e){return function(){js(this,e)}}function Sl(e,t){return function(){(t.apply(this,arguments)?Ps:js)(this,e)}}function Ml(e,t){var n=$s(e+"");if(arguments.length<2){for(var r=Lr(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?Sl:t?El:Nl)(n,t))}function kl(){this.textContent=""}function Cl(e){return function(){this.textContent=e}}function Al(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function $l(e){return arguments.length?this.each(e==null?kl:(typeof e=="function"?Al:Cl)(e)):this.node().textContent}function Il(){this.innerHTML=""}function Pl(e){return function(){this.innerHTML=e}}function jl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Dl(e){return arguments.length?this.each(e==null?Il:(typeof e=="function"?jl:Pl)(e)):this.node().innerHTML}function Tl(){this.nextSibling&&this.parentNode.appendChild(this)}function Rl(){return this.each(Tl)}function Ll(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function zl(){return this.each(Ll)}function Hl(e){var t=typeof e=="function"?e:Ns(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ol(){return null}function Vl(e,t){var n=typeof e=="function"?e:Ns(e),r=t==null?Ol:typeof t=="function"?t:Rr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Bl(){var e=this.parentNode;e&&e.removeChild(this)}function Fl(){return this.each(Bl)}function Wl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xl(e){return this.select(e?Yl:Wl)}function Kl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ql(e){return function(t){e.call(this,t,this.__data__)}}function Gl(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 Ul(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 Zl(e,t,n){return function(){var r=this.__on,o,s=ql(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 Ql(e,t,n){var r=Gl(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?Zl:Ul,o=0;o<s;++o)this.each(a(r[o],t,n));return this}function Ds(e,t,n){var r=As(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 Jl(e,t){return function(){return Ds(this,e,t)}}function eu(e,t){return function(){return Ds(this,e,t.apply(this,arguments))}}function tu(e,t){return this.each((typeof t=="function"?eu:Jl)(e,t))}function*nu(){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 Ts=[null];function Me(e,t){this._groups=e,this._parents=t}function Ut(){return new Me([[document.documentElement]],Ts)}function ru(){return this}Me.prototype=Ut.prototype={constructor:Me,select:Ac,selectAll:jc,selectChild:Lc,selectChildren:Vc,filter:Bc,data:qc,enter:Fc,exit:Uc,join:Zc,merge:Qc,selection:ru,order:Jc,sort:el,call:nl,nodes:rl,node:ol,size:sl,empty:il,each:al,attr:gl,style:xl,property:_l,classed:Ml,text:$l,html:Dl,raise:Rl,lower:zl,append:Hl,insert:Vl,remove:Fl,clone:Xl,datum:Kl,on:Ql,dispatch:tu,[Symbol.iterator]:nu};function Se(e){return typeof e=="string"?new Me([[document.querySelector(e)]],[document.documentElement]):new Me([[e]],Ts)}function ou(e){let t;for(;t=e.sourceEvent;)e=t;return e}function $e(e,t){if(e=ou(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 su={passive:!1},Ot={capture:!0,passive:!1};function or(e){e.stopImmediatePropagation()}function xt(e){e.preventDefault(),e.stopImmediatePropagation()}function Rs(e){var t=e.document.documentElement,n=Se(e).on("dragstart.drag",xt,Ot);"onselectstart"in t?n.on("selectstart.drag",xt,Ot):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ls(e,t){var n=e.document.documentElement,r=Se(e).on("dragstart.drag",null);t&&(r.on("click.drag",xt,Ot),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 un=e=>()=>e;function _r(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}})}_r.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function iu(e){return!e.ctrlKey&&!e.button}function au(){return this.parentNode}function cu(e,t){return t??{x:e.x,y:e.y}}function lu(){return navigator.maxTouchPoints||"ontouchstart"in this}function zs(){var e=iu,t=au,n=cu,r=lu,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,su).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,M){if(!(d||!e.call(this,v,M))){var k=p(this,t.call(this,v,M),v,M,"mouse");k&&(Se(v.view).on("mousemove.drag",g,Ot).on("mouseup.drag",w,Ot),Rs(v.view),or(v),l=!1,a=v.clientX,c=v.clientY,k("start",v))}}function g(v){if(xt(v),!l){var M=v.clientX-a,k=v.clientY-c;l=M*M+k*k>u}o.mouse("drag",v)}function w(v){Se(v.view).on("mousemove.drag mouseup.drag",null),Ls(v.view,l),xt(v),o.mouse("end",v)}function x(v,M){if(e.call(this,v,M)){var k=v.changedTouches,I=t.call(this,v,M),$=k.length,T,F;for(T=0;T<$;++T)(F=p(this,I,v,M,k[T].identifier,k[T]))&&(or(v),F("start",v,k[T]))}}function y(v){var M=v.changedTouches,k=M.length,I,$;for(I=0;I<k;++I)($=o[M[I].identifier])&&(xt(v),$("drag",v,M[I]))}function E(v){var M=v.changedTouches,k=M.length,I,$;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),I=0;I<k;++I)($=o[M[I].identifier])&&(or(v),$("end",v,M[I]))}function p(v,M,k,I,$,T){var F=s.copy(),C=$e(T||k,M),S,z,b;if((b=n.call(v,new _r("beforestart",{sourceEvent:k,target:f,identifier:$,active:i,x:C[0],y:C[1],dx:0,dy:0,dispatch:F}),I))!=null)return S=b.x-C[0]||0,z=b.y-C[1]||0,function P(N,D,R){var A=C,B;switch(N){case"start":o[$]=P,B=i++;break;case"end":delete o[$],--i;case"drag":C=$e(R||D,M),B=i;break}F.call(N,v,new _r(N,{sourceEvent:D,subject:b,target:f,identifier:$,active:B,x:C[0]+S,y:C[1]+z,dx:C[0]-A[0],dy:C[1]-A[1],dispatch:F}),I)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:un(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:un(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:un(v),f):n},f.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:un(!!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 zr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Hs(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Zt(){}var Vt=.7,kn=1/Vt,wt="\\s*([+-]?\\d+)\\s*",Bt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ze="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",uu=/^#([0-9a-f]{3,8})$/,du=new RegExp(`^rgb\\(${wt},${wt},${wt}\\)$`),fu=new RegExp(`^rgb\\(${ze},${ze},${ze}\\)$`),hu=new RegExp(`^rgba\\(${wt},${wt},${wt},${Bt}\\)$`),gu=new RegExp(`^rgba\\(${ze},${ze},${ze},${Bt}\\)$`),pu=new RegExp(`^hsl\\(${Bt},${ze},${ze}\\)$`),mu=new RegExp(`^hsla\\(${Bt},${ze},${ze},${Bt}\\)$`),ho={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};zr(Zt,it,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:go,formatHex:go,formatHex8:yu,formatHsl:xu,formatRgb:po,toString:po});function go(){return this.rgb().formatHex()}function yu(){return this.rgb().formatHex8()}function xu(){return Os(this).formatHsl()}function po(){return this.rgb().formatRgb()}function it(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=uu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?mo(t):n===3?new ve(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?dn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?dn(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=du.exec(e))?new ve(t[1],t[2],t[3],1):(t=fu.exec(e))?new ve(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=hu.exec(e))?dn(t[1],t[2],t[3],t[4]):(t=gu.exec(e))?dn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=pu.exec(e))?wo(t[1],t[2]/100,t[3]/100,1):(t=mu.exec(e))?wo(t[1],t[2]/100,t[3]/100,t[4]):ho.hasOwnProperty(e)?mo(ho[e]):e==="transparent"?new ve(NaN,NaN,NaN,0):null}function mo(e){return new ve(e>>16&255,e>>8&255,e&255,1)}function dn(e,t,n,r){return r<=0&&(e=t=n=NaN),new ve(e,t,n,r)}function wu(e){return e instanceof Zt||(e=it(e)),e?(e=e.rgb(),new ve(e.r,e.g,e.b,e.opacity)):new ve}function Er(e,t,n,r){return arguments.length===1?wu(e):new ve(e,t,n,r??1)}function ve(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}zr(ve,Er,Hs(Zt,{brighter(e){return e=e==null?kn:Math.pow(kn,e),new ve(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Vt:Math.pow(Vt,e),new ve(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ve(rt(this.r),rt(this.g),rt(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:yo,formatHex:yo,formatHex8:vu,formatRgb:xo,toString:xo}));function yo(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}`}function vu(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}${nt((isNaN(this.opacity)?1:this.opacity)*255)}`}function xo(){const e=Cn(this.opacity);return`${e===1?"rgb(":"rgba("}${rt(this.r)}, ${rt(this.g)}, ${rt(this.b)}${e===1?")":`, ${e})`}`}function Cn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function rt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function nt(e){return e=rt(e),(e<16?"0":"")+e.toString(16)}function wo(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ie(e,t,n,r)}function Os(e){if(e instanceof Ie)return new Ie(e.h,e.s,e.l,e.opacity);if(e instanceof Zt||(e=it(e)),!e)return new Ie;if(e instanceof Ie)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 Ie(i,a,c,e.opacity)}function bu(e,t,n,r){return arguments.length===1?Os(e):new Ie(e,t,n,r??1)}function Ie(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}zr(Ie,bu,Hs(Zt,{brighter(e){return e=e==null?kn:Math.pow(kn,e),new Ie(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Vt:Math.pow(Vt,e),new Ie(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 ve(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 Ie(vo(this.h),fn(this.s),fn(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("}${vo(this.h)}, ${fn(this.s)*100}%, ${fn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function vo(e){return e=(e||0)%360,e<0?e+360:e}function fn(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 Hr=e=>()=>e;function _u(e,t){return function(n){return e+n*t}}function Eu(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 Nu(e){return(e=+e)==1?Vs:function(t,n){return n-t?Eu(t,n,e):Hr(isNaN(t)?n:t)}}function Vs(e,t){var n=t-e;return n?_u(e,n):Hr(isNaN(e)?t:e)}const An=function e(t){var n=Nu(t);function r(o,s){var i=n((o=Er(o)).r,(s=Er(s)).r),a=n(o.g,s.g),c=n(o.b,s.b),l=Vs(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 Su(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 Mu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ku(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]=zt(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 Cu(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Le(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Au(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]=zt(e[o],t[o]):r[o]=t[o];return function(s){for(o in n)r[o]=n[o](s);return r}}var Nr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ir=new RegExp(Nr.source,"g");function $u(e){return function(){return e}}function Iu(e){return function(t){return e(t)+""}}function Bs(e,t){var n=Nr.lastIndex=ir.lastIndex=0,r,o,s,i=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Nr.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:Le(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]?Iu(c[0].x):$u(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 zt(e,t){var n=typeof t,r;return t==null||n==="boolean"?Hr(t):(n==="number"?Le:n==="string"?(r=it(t))?(t=r,An):Bs:t instanceof it?An:t instanceof Date?Cu:Mu(t)?Su:Array.isArray(t)?ku:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Au:Le)(e,t)}var bo=180/Math.PI,Sr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fs(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)*bo,skewX:Math.atan(c)*bo,scaleX:i,scaleY:a}}var hn;function Pu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Sr:Fs(t.a,t.b,t.c,t.d,t.e,t.f)}function ju(e){return e==null||(hn||(hn=document.createElementNS("http://www.w3.org/2000/svg","g")),hn.setAttribute("transform",e),!(e=hn.transform.baseVal.consolidate()))?Sr:(e=e.matrix,Fs(e.a,e.b,e.c,e.d,e.e,e.f))}function Ws(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:Le(l,u)},{i:w-2,x:Le(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:Le(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:Le(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:Le(l,u)},{i:w-2,x:Le(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 Du=Ws(Pu,"px, ","px)","deg)"),Tu=Ws(ju,", ",")",")"),Ru=1e-12;function _o(e){return((e=Math.exp(e))+1/e)/2}function Lu(e){return((e=Math.exp(e))-1/e)/2}function zu(e){return((e=Math.exp(2*e))-1)/(e+1)}const _n=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<Ru)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),p=(f*f-l*l+r*w)/(2*l*n*E),v=(f*f-l*l-r*w)/(2*f*n*E),M=Math.log(Math.sqrt(p*p+1)-p),k=Math.log(Math.sqrt(v*v+1)-v);y=(k-M)/t,x=function(I){var $=I*y,T=_o(M),F=l/(n*E)*(T*zu(t*$+M)-Lu(M));return[a+F*h,c+F*g,l*T/_o(t*$+M)]}}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 bt=0,Tt=0,It=0,Ys=1e3,$n,Rt,In=0,at=0,Hn=0,Ft=typeof performance=="object"&&performance.now?performance:Date,Xs=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Or(){return at||(Xs(Hu),at=Ft.now()+Hn)}function Hu(){at=0}function Pn(){this._call=this._time=this._next=null}Pn.prototype=Ks.prototype={constructor:Pn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Or():+n)+(t==null?0:+t),!this._next&&Rt!==this&&(Rt?Rt._next=this:$n=this,Rt=this),this._call=e,this._time=n,Mr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Mr())}};function Ks(e,t,n){var r=new Pn;return r.restart(e,t,n),r}function Ou(){Or(),++bt;for(var e=$n,t;e;)(t=at-e._time)>=0&&e._call.call(void 0,t),e=e._next;--bt}function Eo(){at=(In=Ft.now())+Hn,bt=Tt=0;try{Ou()}finally{bt=0,Bu(),at=0}}function Vu(){var e=Ft.now(),t=e-In;t>Ys&&(Hn-=t,In=e)}function Bu(){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);Rt=e,Mr(r)}function Mr(e){if(!bt){Tt&&(Tt=clearTimeout(Tt));var t=e-at;t>24?(e<1/0&&(Tt=setTimeout(Eo,e-Ft.now()-Hn)),It&&(It=clearInterval(It))):(It||(In=Ft.now(),It=setInterval(Vu,Ys)),bt=1,Xs(Eo))}}function No(e,t,n){var r=new Pn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Fu=Ln("start","end","cancel","interrupt"),Wu=[],qs=0,So=1,kr=2,En=3,Mo=4,Cr=5,Nn=6;function On(e,t,n,r,o,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Yu(e,n,{name:t,index:r,group:o,on:Fu,tween:Wu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:qs})}function Vr(e,t){var n=Te(e,t);if(n.state>qs)throw new Error("too late; already scheduled");return n}function He(e,t){var n=Te(e,t);if(n.state>En)throw new Error("too late; already running");return n}function Te(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Yu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Ks(s,0,n.time);function s(l){n.state=So,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!==So)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===En)return No(i);h.state===Mo?(h.state=Nn,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=Nn,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(No(function(){n.state===En&&(n.state=Mo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=kr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===kr){for(n.state=En,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=Cr,1),u=-1,f=o.length;++u<f;)o[u].call(e,d);n.state===Cr&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Nn,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Sn(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>kr&&r.state<Cr,r.state=Nn,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}s&&delete e.__transition}}function Xu(e){return this.each(function(){Sn(this,e)})}function Ku(e,t){var n,r;return function(){var o=He(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 qu(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=He(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 Gu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Te(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?Ku:qu)(n,e,t))}function Br(e,t,n){var r=e._id;return e.each(function(){var o=He(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Te(o,r).value[t]}}function Gs(e,t){var n;return(typeof t=="number"?Le:t instanceof it?An:(n=it(t))?(t=n,An):Bs)(e,t)}function Uu(e){return function(){this.removeAttribute(e)}}function Zu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qu(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 Ju(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 ed(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 td(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 nd(e,t){var n=zn(e),r=n==="transform"?Tu:Gs;return this.attrTween(e,typeof t=="function"?(n.local?td:ed)(n,r,Br(this,"attr."+e,t)):t==null?(n.local?Zu:Uu)(n):(n.local?Ju:Qu)(n,r,t))}function rd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function od(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function sd(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&od(e,s)),n}return o._value=t,o}function id(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&rd(e,s)),n}return o._value=t,o}function ad(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?sd:id)(r,t))}function cd(e,t){return function(){Vr(this,e).delay=+t.apply(this,arguments)}}function ld(e,t){return t=+t,function(){Vr(this,e).delay=t}}function ud(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?cd:ld)(t,e)):Te(this.node(),t).delay}function dd(e,t){return function(){He(this,e).duration=+t.apply(this,arguments)}}function fd(e,t){return t=+t,function(){He(this,e).duration=t}}function hd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dd:fd)(t,e)):Te(this.node(),t).duration}function gd(e,t){if(typeof t!="function")throw new Error;return function(){He(this,e).ease=t}}function pd(e){var t=this._id;return arguments.length?this.each(gd(t,e)):Te(this.node(),t).ease}function md(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;He(this,e).ease=n}}function yd(e){if(typeof e!="function")throw new Error;return this.each(md(this._id,e))}function xd(e){typeof e!="function"&&(e=Ms(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 We(r,this._parents,this._name,this._id)}function wd(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 We(i,this._parents,this._name,this._id)}function vd(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 bd(e,t,n){var r,o,s=vd(t)?Vr:He;return function(){var i=s(this,e),a=i.on;a!==r&&(o=(r=a).copy()).on(t,n),i.on=o}}function _d(e,t){var n=this._id;return arguments.length<2?Te(this.node(),n).on.on(e):this.each(bd(n,e,t))}function Ed(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Nd(){return this.on("end.remove",Ed(this._id))}function Sd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Rr(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,Te(d,n)));return new We(s,this._parents,t,n)}function Md(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ss(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=Te(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 We(s,i,t,n)}var kd=Ut.prototype.constructor;function Cd(){return new kd(this._groups,this._parents)}function Ad(e,t){var n,r,o;return function(){var s=vt(this,e),i=(this.style.removeProperty(e),vt(this,e));return s===i?null:s===n&&i===r?o:o=t(n=s,r=i)}}function Us(e){return function(){this.style.removeProperty(e)}}function $d(e,t,n){var r,o=n+"",s;return function(){var i=vt(this,e);return i===o?null:i===r?s:s=t(r=i,n)}}function Id(e,t,n){var r,o,s;return function(){var i=vt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),vt(this,e))),i===c?null:i===r&&c===o?s:(o=c,s=t(r=i,a))}}function Pd(e,t){var n,r,o,s="style."+t,i="end."+s,a;return function(){var c=He(this,e),l=c.on,d=c.value[s]==null?a||(a=Us(t)):void 0;(l!==n||o!==d)&&(r=(n=l).copy()).on(i,o=d),c.on=r}}function jd(e,t,n){var r=(e+="")=="transform"?Du:Gs;return t==null?this.styleTween(e,Ad(e,r)).on("end.style."+e,Us(e)):typeof t=="function"?this.styleTween(e,Id(e,r,Br(this,"style."+e,t))).each(Pd(this._id,e)):this.styleTween(e,$d(e,r,t),n).on("end.style."+e,null)}function Dd(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Td(e,t,n){var r,o;function s(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&Dd(e,i,n)),r}return s._value=t,s}function Rd(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,Td(e,t,n??""))}function Ld(e){return function(){this.textContent=e}}function zd(e){return function(){var t=e(this);this.textContent=t??""}}function Hd(e){return this.tween("text",typeof e=="function"?zd(Br(this,"text",e)):Ld(e==null?"":e+""))}function Od(e){return function(t){this.textContent=e.call(this,t)}}function Vd(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Od(o)),t}return r._value=e,r}function Bd(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,Vd(e))}function Fd(){for(var e=this._name,t=this._id,n=Zs(),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=Te(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 We(r,this._parents,e,n)}function Wd(){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=He(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 Yd=0;function We(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Zs(){return++Yd}var Be=Ut.prototype;We.prototype={constructor:We,select:Sd,selectAll:Md,selectChild:Be.selectChild,selectChildren:Be.selectChildren,filter:xd,merge:wd,selection:Cd,transition:Fd,call:Be.call,nodes:Be.nodes,node:Be.node,size:Be.size,empty:Be.empty,each:Be.each,on:_d,attr:nd,attrTween:ad,style:jd,styleTween:Rd,text:Hd,textTween:Bd,remove:Nd,tween:Gu,delay:ud,duration:hd,ease:pd,easeVarying:yd,end:Wd,[Symbol.iterator]:Be[Symbol.iterator]};function Xd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Kd={time:null,delay:0,duration:250,ease:Xd};function qd(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 Gd(e){var t,n;e instanceof We?(t=e._id,e=e._name):(t=Zs(),(n=Kd).time=Or(),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||qd(c,t));return new We(r,this._parents,e,t)}Ut.prototype.interrupt=Xu;Ut.prototype.transition=Gd;const gn=e=>()=>e;function Ud(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 Fe(e,t,n){this.k=e,this.x=t,this.y=n}Fe.prototype={constructor:Fe,scale:function(e){return e===1?this:new Fe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Fe(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 Fe(1,0,0);Qs.prototype=Fe.prototype;function Qs(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Vn;return e.__zoom}function ar(e){e.stopImmediatePropagation()}function Pt(e){e.preventDefault(),e.stopImmediatePropagation()}function Zd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Qd(){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 ko(){return this.__zoom||Vn}function Jd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ef(){return navigator.maxTouchPoints||"ontouchstart"in this}function tf(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 Js(){var e=Zd,t=Qd,n=tf,r=Jd,o=ef,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=_n,l=Ln("start","zoom","end"),d,u,f,h=500,g=150,w=0,x=10;function y(b){b.property("__zoom",ko).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",F).filter(o).on("touchstart.zoom",C).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(b,P,N,D){var R=b.selection?b.selection():b;R.property("__zoom",ko),b!==R?M(b,P,N,D):R.interrupt().each(function(){k(this,arguments).event(D).start().zoom(null,typeof P=="function"?P.apply(this,arguments):P).end()})},y.scaleBy=function(b,P,N,D){y.scaleTo(b,function(){var R=this.__zoom.k,A=typeof P=="function"?P.apply(this,arguments):P;return R*A},N,D)},y.scaleTo=function(b,P,N,D){y.transform(b,function(){var R=t.apply(this,arguments),A=this.__zoom,B=N==null?v(R):typeof N=="function"?N.apply(this,arguments):N,O=A.invert(B),V=typeof P=="function"?P.apply(this,arguments):P;return n(p(E(A,V),B,O),R,i)},N,D)},y.translateBy=function(b,P,N,D){y.transform(b,function(){return n(this.__zoom.translate(typeof P=="function"?P.apply(this,arguments):P,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),i)},null,D)},y.translateTo=function(b,P,N,D,R){y.transform(b,function(){var A=t.apply(this,arguments),B=this.__zoom,O=D==null?v(A):typeof D=="function"?D.apply(this,arguments):D;return n(Vn.translate(O[0],O[1]).scale(B.k).translate(typeof P=="function"?-P.apply(this,arguments):-P,typeof N=="function"?-N.apply(this,arguments):-N),A,i)},D,R)};function E(b,P){return P=Math.max(s[0],Math.min(s[1],P)),P===b.k?b:new Fe(P,b.x,b.y)}function p(b,P,N){var D=P[0]-N[0]*b.k,R=P[1]-N[1]*b.k;return D===b.x&&R===b.y?b:new Fe(b.k,D,R)}function v(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function M(b,P,N,D){b.on("start.zoom",function(){k(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(D).end()}).tween("zoom",function(){var R=this,A=arguments,B=k(R,A).event(D),O=t.apply(R,A),V=N==null?v(O):typeof N=="function"?N.apply(R,A):N,X=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),K=R.__zoom,te=typeof P=="function"?P.apply(R,A):P,ne=c(K.invert(V).concat(X/K.k),te.invert(V).concat(X/te.k));return function(J){if(J===1)J=te;else{var H=ne(J),Y=X/H[2];J=new Fe(Y,V[0]-H[0]*Y,V[1]-H[1]*Y)}B.zoom(null,J)}})}function k(b,P,N){return!N&&b.__zooming||new I(b,P)}function I(b,P){this.that=b,this.args=P,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,P),this.taps=0}I.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,P){return this.mouse&&b!=="mouse"&&(this.mouse[1]=P.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=P.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=P.invert(this.touch1[0])),this.that.__zoom=P,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var P=Se(this.that).datum();l.call(b,this.that,new Ud(b,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),P)}};function $(b,...P){if(!e.apply(this,arguments))return;var N=k(this,P).event(b),D=this.__zoom,R=Math.max(s[0],Math.min(s[1],D.k*Math.pow(2,r.apply(this,arguments)))),A=$e(b);if(N.wheel)(N.mouse[0][0]!==A[0]||N.mouse[0][1]!==A[1])&&(N.mouse[1]=D.invert(N.mouse[0]=A)),clearTimeout(N.wheel);else{if(D.k===R)return;N.mouse=[A,D.invert(A)],Sn(this),N.start()}Pt(b),N.wheel=setTimeout(B,g),N.zoom("mouse",n(p(E(D,R),N.mouse[0],N.mouse[1]),N.extent,i));function B(){N.wheel=null,N.end()}}function T(b,...P){if(f||!e.apply(this,arguments))return;var N=b.currentTarget,D=k(this,P,!0).event(b),R=Se(b.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",X,!0),A=$e(b,N),B=b.clientX,O=b.clientY;Rs(b.view),ar(b),D.mouse=[A,this.__zoom.invert(A)],Sn(this),D.start();function V(K){if(Pt(K),!D.moved){var te=K.clientX-B,ne=K.clientY-O;D.moved=te*te+ne*ne>w}D.event(K).zoom("mouse",n(p(D.that.__zoom,D.mouse[0]=$e(K,N),D.mouse[1]),D.extent,i))}function X(K){R.on("mousemove.zoom mouseup.zoom",null),Ls(K.view,D.moved),Pt(K),D.event(K).end()}}function F(b,...P){if(e.apply(this,arguments)){var N=this.__zoom,D=$e(b.changedTouches?b.changedTouches[0]:b,this),R=N.invert(D),A=N.k*(b.shiftKey?.5:2),B=n(p(E(N,A),D,R),t.apply(this,P),i);Pt(b),a>0?Se(this).transition().duration(a).call(M,B,D,b):Se(this).call(y.transform,B,D,b)}}function C(b,...P){if(e.apply(this,arguments)){var N=b.touches,D=N.length,R=k(this,P,b.changedTouches.length===D).event(b),A,B,O,V;for(ar(b),B=0;B<D;++B)O=N[B],V=$e(O,this),V=[V,this.__zoom.invert(V),O.identifier],R.touch0?!R.touch1&&R.touch0[2]!==V[2]&&(R.touch1=V,R.taps=0):(R.touch0=V,A=!0,R.taps=1+!!d);d&&(d=clearTimeout(d)),A&&(R.taps<2&&(u=V[0],d=setTimeout(function(){d=null},h)),Sn(this),R.start())}}function S(b,...P){if(this.__zooming){var N=k(this,P).event(b),D=b.changedTouches,R=D.length,A,B,O,V;for(Pt(b),A=0;A<R;++A)B=D[A],O=$e(B,this),N.touch0&&N.touch0[2]===B.identifier?N.touch0[0]=O:N.touch1&&N.touch1[2]===B.identifier&&(N.touch1[0]=O);if(B=N.that.__zoom,N.touch1){var X=N.touch0[0],K=N.touch0[1],te=N.touch1[0],ne=N.touch1[1],J=(J=te[0]-X[0])*J+(J=te[1]-X[1])*J,H=(H=ne[0]-K[0])*H+(H=ne[1]-K[1])*H;B=E(B,Math.sqrt(J/H)),O=[(X[0]+te[0])/2,(X[1]+te[1])/2],V=[(K[0]+ne[0])/2,(K[1]+ne[1])/2]}else if(N.touch0)O=N.touch0[0],V=N.touch0[1];else return;N.zoom("touch",n(p(B,O,V),N.extent,i))}}function z(b,...P){if(this.__zooming){var N=k(this,P).event(b),D=b.changedTouches,R=D.length,A,B;for(ar(b),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),A=0;A<R;++A)B=D[A],N.touch0&&N.touch0[2]===B.identifier?delete N.touch0:N.touch1&&N.touch1[2]===B.identifier&&delete N.touch1;if(N.touch1&&!N.touch0&&(N.touch0=N.touch1,delete N.touch1),N.touch0)N.touch0[1]=this.__zoom.invert(N.touch0[0]);else if(N.end(),N.taps===2&&(B=$e(B,this),Math.hypot(u[0]-B[0],u[1]-B[1])<x)){var O=Se(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return y.wheelDelta=function(b){return arguments.length?(r=typeof b=="function"?b:gn(+b),y):r},y.filter=function(b){return arguments.length?(e=typeof b=="function"?b:gn(!!b),y):e},y.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:gn(!!b),y):o},y.extent=function(b){return arguments.length?(t=typeof b=="function"?b:gn([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),y):t},y.scaleExtent=function(b){return arguments.length?(s[0]=+b[0],s[1]=+b[1],y):[s[0],s[1]]},y.translateExtent=function(b){return arguments.length?(i[0][0]=+b[0][0],i[1][0]=+b[1][0],i[0][1]=+b[0][1],i[1][1]=+b[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(b){return arguments.length?(n=b,y):n},y.duration=function(b){return arguments.length?(a=+b,y):a},y.interpolate=function(b){return arguments.length?(c=b,y):c},y.on=function(){var b=l.on.apply(l,arguments);return b===l?y:b},y.clickDistance=function(b){return arguments.length?(w=(b=+b)*b,y):Math.sqrt(w)},y.tapDistance=function(b){return arguments.length?(x=+b,y):x},y}const De={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.`},Wt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ei=["Enter"," ","Escape"],ti={"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 _t;(function(e){e.Strict="strict",e.Loose="loose"})(_t||(_t={}));var ot;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ot||(ot={}));var Yt;(function(e){e.Partial="partial",e.Full="full"})(Yt||(Yt={}));const ni={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ge;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ge||(Ge={}));var Xt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Xt||(Xt={}));var Q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Q||(Q={}));const Co={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function ri(e){return e===null?null:e?"valid":"invalid"}const oi=e=>"id"in e&&"source"in e&&"target"in e,nf=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Fr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Qt=(e,t=[0,0])=>{const{width:n,height:r}=Ye(e),o=e.origin??t,s=n*o[0],i=r*o[1];return{x:e.position.x-s,y:e.position.y-i}},rf=(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):Fr(o)?o:t.nodeLookup.get(o.id));const a=i?jn(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)},Jt=(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,jn(o)),r=!0)}),r?Fn(n):{x:0,y:0,width:0,height:0}},Wr=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1)=>{const a={...At(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=Kt(a,Nt(l)),x=(h??0)*(g??0),y=s&&w>0;(!l.internals.handleBounds||y||w>=x||l.dragging)&&c.push(l)}return c},of=(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 sf(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 af({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:s},i){if(e.size===0)return!0;const a=sf(e,i),c=Jt(a),l=Xr(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 si({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",De.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[c,l],[c+h,l+g]])}else a&&lt(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=lt(u)?ct(t,u,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&(s==null||s("015",De.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 cf({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=of(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 Et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ct=(e={x:0,y:0},t,n)=>({x:Et(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Et(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ii(e,t,n){const{width:r,height:o}=Ye(n),{x:s,y:i}=n.internals.positionAbsolute;return ct(e,[[s,i],[s+r,i+o]],t)}const Ao=(e,t,n)=>e<t?Et(Math.abs(e-t),1,t)/t:e>n?-Et(Math.abs(e-n),1,t)/t:0,Yr=(e,t,n=15,r=40)=>{const o=Ao(e.x,r,t.width-r)*n,s=Ao(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)}),Ar=({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}),Nt=(e,t=[0,0])=>{var o,s;const{x:n,y:r}=Fr(e)?e.internals.positionAbsolute:Qt(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}},jn=(e,t=[0,0])=>{var o,s;const{x:n,y:r}=Fr(e)?e.internals.positionAbsolute:Qt(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)}},ai=(e,t)=>Fn(Bn(Ar(e),Ar(t))),Kt=(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)},$o=e=>Pe(e.width)&&Pe(e.height)&&Pe(e.x)&&Pe(e.y),Pe=e=>!isNaN(e)&&isFinite(e),ci=(e,t)=>(n,r)=>{},en=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),At=({x:e,y:t},[n,r,o],s=!1,i=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return s?en(a,i):a},St=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function pt(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 lf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=pt(e,n),o=pt(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=pt(e.top??e.y??0,n),o=pt(e.bottom??e.y??0,n),s=pt(e.left??e.x??0,t),i=pt(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 uf(e,t,n,r,o,s){const{x:i,y:a}=St(e,[t,n,r]),{x:c,y:l}=St({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 Xr=(e,t,n,r,o,s)=>{const i=lf(s,t,n),a=(t-i.x)/e.width,c=(n-i.y)/e.height,l=Math.min(a,c),d=Et(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=uf(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}},qt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function lt(e){return e!=null&&e!=="parent"}function Ye(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 li(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 ui(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 Io(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function df(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function ff(e){return{...ti,...e||{}}}function Ht(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:s,y:i}=je(e),a=At({x:s-((o==null?void 0:o.left)??0),y:i-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?en(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Kr=e=>({width:e.offsetWidth,height:e.offsetHeight}),di=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},hf=["INPUT","SELECT","TEXTAREA"];function fi(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:hf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const hi=e=>"clientX"in e,je=(e,t)=>{var s,i;const n=hi(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)}},Po=(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,...Kr(i)}})};function gi({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 pn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function jo({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case Q.Left:return[t-pn(t-r,s),n];case Q.Right:return[t+pn(r-t,s),n];case Q.Top:return[t,n-pn(n-o,s)];case Q.Bottom:return[t,n+pn(o-n,s)]}}function pi({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:o,targetPosition:s=Q.Top,curvature:i=.25}){const[a,c]=jo({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[l,d]=jo({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[u,f,h,g]=gi({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 mi({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 gf({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 pf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const s=Bn(jn(e),jn(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 Kt(i,Fn(s))>0}const mf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,yf=(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)),xf=(e,t,n={})=>{var s;if(!e.source||!e.target)return(s=n.onError)==null||s.call(n,"006",De.error006()),t;const r=n.getEdgeId||mf;let o;return oi(e)?o={...e}:o={...e,id:r(e)},yf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function yi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,a]=mi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,a]}const Do={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},wf=({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},To=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function vf({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:o,offset:s,stepPosition:i}){const a=Do[t],c=Do[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=wf({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},[,,p,v]=mi({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 $=[{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"?$:T:g=f==="x"?T:$}else{const $=[{x:l.x,y:d.y}],T=[{x:d.x,y:l.y}];if(f==="x"?g=a.x===h?T:$:g=a.y===h?$:T,t===r){const b=Math.abs(e[f]-n[f]);if(b<=s){const P=Math.min(s-1,s-b);a[f]===h?y[f]=(l[f]>e[f]?-1:1)*P:E[f]=(d[f]>n[f]?-1:1)*P}}if(t!==r){const b=f==="x"?"y":"x",P=a[f]===c[b],N=l[b]>d[b],D=l[b]<d[b];(a[f]===1&&(!P&&N||P&&D)||a[f]!==1&&(!P&&D||P&&N))&&(g=f==="x"?$:T)}const F={x:l.x+y.x,y:l.y+y.y},C={x:d.x+E.x,y:d.y+E.y},S=Math.max(Math.abs(F.x-g[0].x),Math.abs(C.x-g[0].x)),z=Math.max(Math.abs(F.y-g[0].y),Math.abs(C.y-g[0].y));S>=z?(w=(F.x+C.x)/2,x=g[0].y):(w=g[0].x,x=(F.y+C.y)/2)}const M={x:l.x+y.x,y:l.y+y.y},k={x:d.x+E.x,y:d.y+E.y};return[[e,...M.x!==g[0].x||M.y!==g[0].y?[M]:[],...g,...k.x!==g[g.length-1].x||k.y!==g[g.length-1].y?[k]:[],n],w,x,p,v]}function bf(e,t,n,r){const o=Math.min(To(e,t)/2,To(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 $r({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]=vf({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+=bf(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 Ro(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function _f(e){var u;const{sourceNode:t,targetNode:n}=e;if(!Ro(t)||!Ro(n))return null;const r=t.internals.handleBounds||Lo(t.handles),o=n.internals.handleBounds||Lo(n.handles),s=zo((r==null?void 0:r.source)??[],e.sourceHandle),i=zo(e.connectionMode===_t.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",De.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=ut(t,s,a),d=ut(n,i,c);return{sourceX:l.x,sourceY:l.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:c}}function Lo(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 ut(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??Ye(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 zo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ir(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Ef(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=Ir(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 xi=1e3,Nf=10,qr={nodeOrigin:[0,0],nodeExtent:Wt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Sf={...qr,checkEquality:!0};function Gr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Mf(e,t,n){const r=Gr(qr,n);for(const o of e.values())if(o.parentId)Zr(o,e,t,r);else{const s=Qt(o,r.nodeOrigin),i=lt(o.extent)?o.extent:r.nodeExtent,a=ct(s,i,Ye(o));o.internals.positionAbsolute=a}}function kf(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 Ur(e){return e==="manual"}function Pr(e,t,n,r={}){var d,u;const o=Gr(Sf,r),s={i:0},i=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!Ur(o.zIndexMode)?xi: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=Qt(f,o.nodeOrigin),w=lt(f.extent)?f.extent:o.nodeExtent,x=ct(g,w,Ye(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:kf(f,h),z:wi(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&&Zr(h,t,n,r,s),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function Cf(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 Zr(e,t,n,r,o){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:a,zIndexMode:c}=Gr(qr,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}Cf(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*Nf),o&&d.internals.rootParentIndex!==void 0&&(o.i=d.internals.rootParentIndex);const u=s&&!Ur(c)?xi:0,{x:f,y:h,z:g}=Af(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 wi(e,t,n){const r=Pe(e.zIndex)?e.zIndex:0;return Ur(n)?r:r+(e.selected?t:0)}function Af(e,t,n,r,o,s){const{x:i,y:a}=t.internals.positionAbsolute,c=Ye(e),l=Qt(e,n),d=lt(e.extent)?ct(l,e.extent,c):l;let u=ct({x:i+d.x,y:a+d.y},r,c);e.extent==="parent"&&(u=ii(u,c,t));const f=wi(e,o,s),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function Qr(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)??Nt(c),d=ai(l,a.rect);s.set(a.parentId,{expandedRect:d,parent:c})}return s.size>0&&s.forEach(({expandedRect:a,parent:c},l)=>{var p;const d=c.internals.positionAbsolute,u=Ye(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}}),(p=n.get(l))==null||p.forEach(v=>{e.some(M=>M.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 $f(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=Kr(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(),p=lt(g.extent)?g.extent:s;let{positionAbsolute:v}=g.internals;g.parentId&&g.extent==="parent"?v=ii(v,w,t.get(g.parentId)):p&&(v=ct(v,p,w));const M={...g,measured:w,internals:{...g.internals,positionAbsolute:v,handleBounds:{source:Po("source",h.nodeElement,E,u,g.id),target:Po("target",h.nodeElement,E,u,g.id)}}};t.set(g.id,M),g.parentId&&Zr(M,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:Nt(M,o)}))}}if(f.length>0){const h=Qr(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function If({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 Ho(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 vi(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}`;Ho("source",c,d,e,o,i),Ho("target",c,l,e,s,a),t.set(r.id,r)}}function bi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:bi(n,t):!1}function Oo(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 Pf(e,t,n,r){const o=new Map;for(const[s,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!bi(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 jf({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=en(s,t);return{x:i.x-s.x,y:i.y-s.y}}function Df({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:p,domNode:v,isSelectable:M,nodeId:k,nodeClickDistance:I=0}){f=Se(v);function $({x:S,y:z}){const{nodeLookup:b,nodeExtent:P,snapGrid:N,snapToGrid:D,nodeOrigin:R,onNodeDrag:A,onSelectionDrag:B,onError:O,updateNodePositions:V}=t();s={x:S,y:z};let X=!1;const K=a.size>1,te=K&&P?Ar(Jt(a)):null,ne=K&&D?jf({dragItems:a,snapGrid:N,x:S,y:z}):null;for(const[J,H]of a){if(!b.has(J))continue;let Y={x:S-H.distance.x,y:z-H.distance.y};D&&(Y=ne?{x:Math.round(Y.x+ne.x),y:Math.round(Y.y+ne.y)}:en(Y,N));let U=null;if(K&&P&&!H.extent&&te){const{positionAbsolute:Z}=H.internals,re=Z.x-te.x+P[0][0],ie=Z.x+H.measured.width-te.x2+P[1][0],se=Z.y-te.y+P[0][1],ce=Z.y+H.measured.height-te.y2+P[1][1];U=[[re,se],[ie,ce]]}const{position:ee,positionAbsolute:W}=si({nodeId:J,nextPosition:Y,nodeLookup:b,nodeExtent:U||P,nodeOrigin:R,onError:O});X=X||H.position.x!==ee.x||H.position.y!==ee.y,H.position=ee,H.internals.positionAbsolute=W}if(g=g||X,!!X&&(V(a,!0),w&&(r||A||!k&&B))){const[J,H]=cr({nodeId:k,dragItems:a,nodeLookup:b});r==null||r(w,a,J,H),A==null||A(w,J,H),k||B==null||B(w,H)}}async function T(){if(!d)return;const{transform:S,panBy:z,autoPanSpeed:b,autoPanOnNodeDrag:P}=t();if(!P){c=!1,cancelAnimationFrame(i);return}const[N,D]=Yr(l,d,b);(N!==0||D!==0)&&(s.x=(s.x??0)-N/S[2],s.y=(s.y??0)-D/S[2],await z({x:N,y:D})&&$(s)),i=requestAnimationFrame(T)}function F(S){var K;const{nodeLookup:z,multiSelectionActive:b,nodesDraggable:P,transform:N,snapGrid:D,snapToGrid:R,selectNodesOnDrag:A,onNodeDragStart:B,onSelectionDragStart:O,unselectNodesAndEdges:V}=t();u=!0,(!A||!M)&&!b&&k&&((K=z.get(k))!=null&&K.selected||V()),M&&A&&k&&(e==null||e(k));const X=Ht(S.sourceEvent,{transform:N,snapGrid:D,snapToGrid:R,containerBounds:d});if(s=X,a=Pf(z,P,X,k),a.size>0&&(n||B||!k&&O)){const[te,ne]=cr({nodeId:k,dragItems:a,nodeLookup:z});n==null||n(S.sourceEvent,a,te,ne),B==null||B(S.sourceEvent,te,ne),k||O==null||O(S.sourceEvent,ne)}}const C=zs().clickDistance(I).on("start",S=>{const{domNode:z,nodeDragThreshold:b,transform:P,snapGrid:N,snapToGrid:D}=t();d=(z==null?void 0:z.getBoundingClientRect())||null,h=!1,g=!1,w=S.sourceEvent,b===0&&F(S),s=Ht(S.sourceEvent,{transform:P,snapGrid:N,snapToGrid:D,containerBounds:d}),l=je(S.sourceEvent,d)}).on("drag",S=>{const{autoPanOnNodeDrag:z,transform:b,snapGrid:P,snapToGrid:N,nodeDragThreshold:D,nodeLookup:R}=t(),A=Ht(S.sourceEvent,{transform:b,snapGrid:P,snapToGrid:N,containerBounds:d});if(w=S.sourceEvent,(S.sourceEvent.type==="touchmove"&&S.sourceEvent.touches.length>1||k&&!R.has(k))&&(h=!0),!h){if(!c&&z&&u&&(c=!0,T()),!u){const B=je(S.sourceEvent,d),O=B.x-l.x,V=B.y-l.y;Math.sqrt(O*O+V*V)>D&&F(S)}(s.x!==A.xSnapped||s.y!==A.ySnapped)&&a&&u&&(l=je(S.sourceEvent,d),$(A))}}).on("end",S=>{if(!u||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,u=!1,cancelAnimationFrame(i),a.size>0){const{nodeLookup:z,updateNodePositions:b,onNodeDragStop:P,onSelectionDragStop:N}=t();if(g&&(b(a,!1),g=!1),o||P||!k&&N){const[D,R]=cr({nodeId:k,dragItems:a,nodeLookup:z,dragging:!1});o==null||o(S.sourceEvent,a,D,R),P==null||P(S.sourceEvent,D,R),k||N==null||N(S.sourceEvent,R)}}}).filter(S=>{const z=S.target;return!S.button&&(!E||!Oo(z,`.${E}`,v))&&(!p||Oo(z,p,v))});f.call(C)}function y(){f==null||f.on(".drag",null)}return{update:x,destroy:y}}function Tf(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())Kt(o,Nt(s))>0&&r.push(s);return r}const Rf=250;function Lf(e,t,n,r){var a,c;let o=[],s=1/0;const i=Tf(e,n,t+Rf);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}=ut(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 _i(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,...ut(i,c,c.position,!0)}:c}function Ei(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function zf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ni=()=>!0;function Hf(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=Ni,onReconnectEnd:E,updateConnection:p,getTransform:v,getFromHandle:M,autoPanSpeed:k,dragThreshold:I=1,handleDomNode:$}){const T=di(e.target);let F=0,C;const{x:S,y:z}=je(e),b=Ei(s,$),P=a==null?void 0:a.getBoundingClientRect();let N=!1;if(!P||!b)return;const D=_i(o,b,r,c,t);if(!D)return;let R=je(e,P),A=!1,B=null,O=!1,V=null;function X(){if(!d||!P)return;const[ee,W]=Yr(R,P,k);f({x:ee,y:W}),F=requestAnimationFrame(X)}const K={...D,nodeId:o,type:b,position:D.position},te=c.get(o);let J={inProgress:!0,isValid:null,from:ut(te,K,Q.Left,!0),fromHandle:K,fromPosition:K.position,fromNode:te,to:R,toHandle:null,toPosition:Co[K.position],toNode:null,pointer:R};function H(){N=!0,p(J),g==null||g(e,{nodeId:o,handleId:r,handleType:b})}I===0&&H();function Y(ee){if(!N){const{x:ce,y:xe}=je(ee),be=ce-S,ge=xe-z;if(!(be*be+ge*ge>I*I))return;H()}if(!M()||!K){U(ee);return}const W=v();R=je(ee,P),C=Lf(At(R,W,!1,[1,1]),n,c,K),A||(X(),A=!0);const Z=Si(ee,{handle:C,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:i?"target":"source",isValidConnection:y,doc:T,lib:l,flowId:u,nodeLookup:c});V=Z.handleDomNode,B=Z.connection,O=zf(!!C,Z.isValid);const re=c.get(o),ie=re?ut(re,K,Q.Left,!0):J.from,se={...J,from:ie,isValid:O,to:Z.toHandle&&O?St({x:Z.toHandle.x,y:Z.toHandle.y},W):R,toHandle:Z.toHandle,toPosition:O&&Z.toHandle?Z.toHandle.position:Co[K.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:R};p(se),J=se}function U(ee){if(!("touches"in ee&&ee.touches.length>0)){if(N){(C||V)&&B&&O&&(w==null||w(B));const{inProgress:W,...Z}=J,re={...Z,toPosition:J.toHandle?J.toPosition:null};x==null||x(ee,re),s&&(E==null||E(ee,re))}h(),cancelAnimationFrame(F),A=!1,O=!1,B=null,V=null,T.removeEventListener("mousemove",Y),T.removeEventListener("mouseup",U),T.removeEventListener("touchmove",Y),T.removeEventListener("touchend",U)}}T.addEventListener("mousemove",Y),T.addEventListener("mouseup",U),T.addEventListener("touchmove",Y),T.addEventListener("touchend",U)}function Si(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:s,doc:i,lib:a,flowId:c,isValidConnection:l=Ni,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}=je(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=Ei(void 0,x),p=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),M=x.classList.contains("connectable"),k=x.classList.contains("connectableend");if(!p||!E)return y;const I={source:u?p:r,sourceHandle:u?v:o,target:u?r:p,targetHandle:u?o:v};y.connection=I;const T=M&&k&&(n===_t.Strict?u&&E==="source"||!u&&E==="target":p!==r||v!==o);y.isValid=T&&l(I),y.toHandle=_i(p,E,v,d,n,!0)}return y}const jr={onPointerDown:Hf,isValid:Si};function Of({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Se(e);function s({translateExtent:a,width:c,height:l,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const v=n(),M=p.sourceEvent.ctrlKey&&qt()?10:1,k=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,I=v[2]*Math.pow(2,k*M);t.scaleTo(I)};let w=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(w=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},y=p=>{const v=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const M=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],k=[M[0]-w[0],M[1]-w[1]];w=M;const I=r()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),$={x:v[0]-k[0]*I,y:v[1]-k[1]*I},T=[[0,0],[c,l]];t.setViewportConstrained({x:$.x,y:$.y,zoom:v[2]},T,a)},E=Js().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:$e}}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),mt=(e,t)=>e.target.closest(`.${t}`),Mi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Vf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ur=(e,t=0,n=Vf,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},ki=e=>{const t=e.ctrlKey&&qt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Bf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return d=>{if(mt(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=$e(d),y=ki(d),E=u*Math.pow(2,y);r.scaleTo(n,E,x,d);return}const f=d.deltaMode===1?20:1;let h=o===ot.Vertical?0:d.deltaX*f,g=o===ot.Horizontal?0:d.deltaY*f;!qt()&&d.shiftKey&&o!==ot.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 Ff({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const s=r.type==="wheel",i=!t&&s&&!r.ctrlKey,a=mt(r,e);if(r.ctrlKey&&s&&a&&r.preventDefault(),i||a)return null;r.preventDefault(),n.call(this,r,o)}}function Wf({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 Yf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return s=>{var i,a;e.usedRightMouseButton=!!(n&&Mi(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 Xf({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&&Mi(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 Kf({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"&&(mt(u,`${l}-flow__node`)||mt(u,`${l}-flow__edge`)))return!0;if(!r&&!f&&!o&&!s&&!n||i||d&&!g||mt(u,a)&&g||mt(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 qf({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=Js().scaleExtent([t,n]).translateExtent(r),f=Se(e).call(u);E({x:o.x,y:o.y,zoom:Et(o.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(ki);async function w(C,S){return f?new Promise(z=>{u==null||u.interpolate((S==null?void 0:S.interpolate)==="linear"?zt:_n).transform(ur(f,S==null?void 0:S.duration,S==null?void 0:S.ease,()=>z(!0)),C)}):!1}function x({noWheelClassName:C,noPanClassName:S,onPaneContextMenu:z,userSelectionActive:b,panOnScroll:P,panOnDrag:N,panOnScrollMode:D,panOnScrollSpeed:R,preventScrolling:A,zoomOnPinch:B,zoomOnScroll:O,zoomOnDoubleClick:V,zoomActivationKeyPressed:X,lib:K,onTransformChange:te,connectionInProgress:ne,paneClickDistance:J,selectionOnDrag:H}){b&&!l.isZoomingOrPanning&&y();const Y=P&&!X&&!b;u.clickDistance(H?1/0:!Pe(J)||J<0?0:J);const U=Y?Bf({zoomPanValues:l,noWheelClassName:C,d3Selection:f,d3Zoom:u,panOnScrollMode:D,panOnScrollSpeed:R,zoomOnPinch:B,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:a}):Ff({noWheelClassName:C,preventScrolling:A,d3ZoomHandler:h});f.on("wheel.zoom",U,{passive:!1});const ee=Wf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:i});u.on("start",ee);const W=Yf({zoomPanValues:l,panOnDrag:N,onPaneContextMenu:!!z,onPanZoom:s,onTransformChange:te});u.on("zoom",W);const Z=Xf({zoomPanValues:l,panOnDrag:N,panOnScroll:P,onPaneContextMenu:z,onPanZoomEnd:a,onDraggingChange:c});u.on("end",Z);const re=Kf({zoomActivationKeyPressed:X,panOnDrag:N,zoomOnScroll:O,panOnScroll:P,zoomOnDoubleClick:V,zoomOnPinch:B,userSelectionActive:b,noPanClassName:S,noWheelClassName:C,lib:K,connectionInProgress:ne});u.filter(re),V?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function y(){u.on("zoom",null)}async function E(C,S,z){const b=lr(C),P=u==null?void 0:u.constrain()(b,S,z);return P&&await w(P),P}async function p(C,S){const z=lr(C);return await w(z,S),z}function v(C){if(f){const S=lr(C),z=f.property("__zoom");(z.k!==C.zoom||z.x!==C.x||z.y!==C.y)&&(u==null||u.transform(f,S,null,{sync:!0}))}}function M(){const C=f?Qs(f.node()):{x:0,y:0,k:1};return{x:C.x,y:C.y,zoom:C.k}}async function k(C,S){return f?new Promise(z=>{u==null||u.interpolate((S==null?void 0:S.interpolate)==="linear"?zt:_n).scaleTo(ur(f,S==null?void 0:S.duration,S==null?void 0:S.ease,()=>z(!0)),C)}):!1}async function I(C,S){return f?new Promise(z=>{u==null||u.interpolate((S==null?void 0:S.interpolate)==="linear"?zt:_n).scaleBy(ur(f,S==null?void 0:S.duration,S==null?void 0:S.ease,()=>z(!0)),C)}):!1}function $(C){u==null||u.scaleExtent(C)}function T(C){u==null||u.translateExtent(C)}function F(C){const S=!Pe(C)||C<0?0:C;u==null||u.clickDistance(S)}return{update:x,destroy:y,setViewport:p,setViewportConstrained:E,getViewport:M,scaleTo:k,scaleBy:I,setScaleExtent:$,setTranslateExtent:T,syncViewport:v,setClickDistance:F}}var Mt;(function(e){e.Line="line",e.Handle="handle"})(Mt||(Mt={}));function Gf({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 Vo(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 Ke(e,t){return Math.max(0,t-e)}function qe(e,t){return Math.max(0,e-t)}function mn(e,t,n){return Math.max(0,t-e,e-n)}function Bo(e,t){return e?!t:t}function Uf(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:p,y:v,width:M,height:k,aspectRatio:I}=e;let $=Math.floor(d?h-e.pointerX:0),T=Math.floor(u?g-e.pointerY:0);const F=M+(c?-$:$),C=k+(l?-T:T),S=-s[0]*M,z=-s[1]*k;let b=mn(F,w,x),P=mn(C,y,E);if(i){let R=0,A=0;c&&$<0?R=Ke(p+$+S,i[0][0]):!c&&$>0&&(R=qe(p+F+S,i[1][0])),l&&T<0?A=Ke(v+T+z,i[0][1]):!l&&T>0&&(A=qe(v+C+z,i[1][1])),b=Math.max(b,R),P=Math.max(P,A)}if(a){let R=0,A=0;c&&$>0?R=qe(p+$,a[0][0]):!c&&$<0&&(R=Ke(p+F,a[1][0])),l&&T>0?A=qe(v+T,a[0][1]):!l&&T<0&&(A=Ke(v+C,a[1][1])),b=Math.max(b,R),P=Math.max(P,A)}if(o){if(d){const R=mn(F/I,y,E)*I;if(b=Math.max(b,R),i){let A=0;!c&&!l||c&&!l&&f?A=qe(v+z+F/I,i[1][1])*I:A=Ke(v+z+(c?$:-$)/I,i[0][1])*I,b=Math.max(b,A)}if(a){let A=0;!c&&!l||c&&!l&&f?A=Ke(v+F/I,a[1][1])*I:A=qe(v+(c?$:-$)/I,a[0][1])*I,b=Math.max(b,A)}}if(u){const R=mn(C*I,w,x)/I;if(P=Math.max(P,R),i){let A=0;!c&&!l||l&&!c&&f?A=qe(p+C*I+S,i[1][0])/I:A=Ke(p+(l?T:-T)*I+S,i[0][0])/I,P=Math.max(P,A)}if(a){let A=0;!c&&!l||l&&!c&&f?A=Ke(p+C*I,a[1][0])/I:A=qe(p+(l?T:-T)*I,a[0][0])/I,P=Math.max(P,A)}}}T=T+(T<0?P:-P),$=$+($<0?b:-b),o&&(f?F>C*I?T=(Bo(c,l)?-$:$)/I:$=(Bo(c,l)?-T:T)*I:d?(T=$/I,l=c):($=T*I,c=l));const N=c?p+$:p,D=l?v+T:v;return{width:M+(c?-$:$),height:k+(l?-T:T),x:s[0]*$*(c?-1:1)+N,y:s[1]*T*(l?-1:1)+D}}const Ci={width:0,height:0,x:0,y:0},Zf={...Ci,pointerX:0,pointerY:0,aspectRatio:1};function Qf(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 Jf({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const s=Se(e);let i={controlDirection:Vo("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={...Ci},E={...Zf};i={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Vo(l)};let p,v=null,M=[],k,I,$,T=!1;const F=zs().on("start",C=>{const{nodeLookup:S,transform:z,snapGrid:b,snapToGrid:P,nodeOrigin:N,paneDomNode:D}=n();if(p=S.get(t),!p)return;v=(D==null?void 0:D.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:A}=Ht(C.sourceEvent,{transform:z,snapGrid:b,snapToGrid:P,containerBounds:v});y={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},E={...y,pointerX:R,pointerY:A,aspectRatio:y.width/y.height},k=void 0,I=lt(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(k=S.get(p.parentId)),k&&p.extent==="parent"&&(I=[[0,0],[k.measured.width,k.measured.height]]),M=[],$=void 0;for(const[B,O]of S)if(O.parentId===t&&(M.push({id:B,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const V=Qf(O,p,O.origin??N);$?$=[[Math.min(V[0][0],$[0][0]),Math.min(V[0][1],$[0][1])],[Math.max(V[1][0],$[1][0]),Math.max(V[1][1],$[1][1])]]:$=V}h==null||h(C,{...y})}).on("drag",C=>{const{transform:S,snapGrid:z,snapToGrid:b,nodeOrigin:P}=n(),N=Ht(C.sourceEvent,{transform:S,snapGrid:z,snapToGrid:b,containerBounds:v}),D=[];if(!p)return;const{x:R,y:A,width:B,height:O}=y,V={},X=p.origin??P,{width:K,height:te,x:ne,y:J}=Uf(E,i.controlDirection,N,i.boundaries,i.keepAspectRatio,X,I,$),H=K!==B,Y=te!==O,U=ne!==R&&H,ee=J!==A&&Y;if(!U&&!ee&&!H&&!Y)return;if((U||ee||X[0]===1||X[1]===1)&&(V.x=U?ne:y.x,V.y=ee?J:y.y,y.x=V.x,y.y=V.y,M.length>0)){const ie=ne-R,se=J-A;for(const ce of M)ce.position={x:ce.position.x-ie+X[0]*(K-B),y:ce.position.y-se+X[1]*(te-O)},D.push(ce)}if((H||Y)&&(V.width=H&&(!i.resizeDirection||i.resizeDirection==="horizontal")?K:y.width,V.height=Y&&(!i.resizeDirection||i.resizeDirection==="vertical")?te:y.height,y.width=V.width,y.height=V.height),k&&p.expandParent){const ie=X[0]*(V.width??0);V.x&&V.x<ie&&(y.x=ie,E.x=E.x-(V.x-ie));const se=X[1]*(V.height??0);V.y&&V.y<se&&(y.y=se,E.y=E.y-(V.y-se))}const W=Gf({width:y.width,prevWidth:B,height:y.height,prevHeight:O,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),Z={...y,direction:W};(x==null?void 0:x(C,Z))!==!1&&(T=!0,g==null||g(C,Z),r(V,D))}).on("end",C=>{T&&(w==null||w(C,{...y}),o==null||o({...y}),T=!1)});s.call(F)}function c(){s.on(".drag",null)}return{update:a,destroy:c}}var Ai={exports:{}},$i={},Ii={exports:{}},Pi={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionInterface-Bpie-9fs.js","assets/index-DrVao0Ep.js","assets/index-CsI8DElI.css","assets/data-B-RQmit6.js","assets/terminalFont-C6oGNKrf.js","assets/launch-BBH02b1v.js","assets/Thread-C6Go8HRh.js","assets/PageScroll-hT7UTLvD.js","assets/launch-Cp579UoJ.css","assets/SessionWindow-CixDi4PI.js","assets/Modal-CQgYymmr.js","assets/bindings-BC9vqpYU.js","assets/SessionInterface-6GBZ9nXN.css","assets/EvalsPage-FixoOg_n.js","assets/IssuesPage-CuKLFhH3.js","assets/Settings-C2MsucfE.js"])))=>i.map(i=>d[i]);
2
+ import{r as _,l as Xa,R as Ka,j as m,u as Ze,m as qa,I as Ga,d as Ua,f as Za,n as ke,o as Qa,T as Ja,S as ec,_ as Rn}from"./index-DrVao0Ep.js";import{b as st,G as _s,l as xr,A as tc,c as nc,L as rc}from"./SessionWindow-CixDi4PI.js";import{Y as oc,Z as sc,s as Tr,_ as ic,X as wr,n as co,$ as ac,a0 as cc,a1 as lc,E as uc,v as lo,a2 as dc,J as fc,w as hc,a3 as gc,a4 as pc,H as mc,a5 as yc}from"./Thread-C6Go8HRh.js";import{M as xc}from"./Modal-CQgYymmr.js";import{A as wc,k as Es,a as vr,f as fe}from"./bindings-BC9vqpYU.js";import{k as vc,X as bc,Y as _c}from"./data-B-RQmit6.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 Ec={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 bn(n)}function bn(e){this._=e}function Nc(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}})}bn.prototype=Ln.prototype={constructor:bn,on:function(e,t){var n=this._,r=Nc(e+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(e=r[s]).type)&&(o=Sc(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]=uo(n[o],e.name,t);else if(t==null)for(o in n)n[o]=uo(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 bn(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 Sc(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function uo(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=Ec,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var br="http://www.w3.org/1999/xhtml";const fo={svg:"http://www.w3.org/2000/svg",xhtml:br,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)),fo.hasOwnProperty(t)?{space:fo[t],local:e}:e}function Mc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===br&&t.documentElement.namespaceURI===br?t.createElement(e):t.createElementNS(n,e)}}function kc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ns(e){var t=zn(e);return(t.local?kc:Mc)(t)}function Cc(){}function Rr(e){return e==null?Cc:function(){return this.querySelector(e)}}function Ac(e){typeof e!="function"&&(e=Rr(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 Me(r,this._parents)}function $c(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ic(){return[]}function Ss(e){return e==null?Ic:function(){return this.querySelectorAll(e)}}function Pc(e){return function(){return $c(e.apply(this,arguments))}}function jc(e){typeof e=="function"?e=Pc(e):e=Ss(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 Me(r,o)}function Ms(e){return function(){return this.matches(e)}}function ks(e){return function(t){return t.matches(e)}}var Dc=Array.prototype.find;function Tc(e){return function(){return Dc.call(this.children,e)}}function Rc(){return this.firstElementChild}function Lc(e){return this.select(e==null?Rc:Tc(typeof e=="function"?e:ks(e)))}var zc=Array.prototype.filter;function Hc(){return Array.from(this.children)}function Oc(e){return function(){return zc.call(this.children,e)}}function Vc(e){return this.selectAll(e==null?Hc:Oc(typeof e=="function"?e:ks(e)))}function Bc(e){typeof e!="function"&&(e=Ms(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 Me(r,this._parents)}function Cs(e){return new Array(e.length)}function Fc(){return new Me(this._enter||this._groups.map(Cs),this._parents)}function Mn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Mn.prototype={constructor:Mn,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 Wc(e){return function(){return e}}function Yc(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 Mn(e,s[i]);for(;i<c;++i)(a=t[i])&&(o[i]=a)}function Xc(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 Mn(e,s[a]);for(a=0;a<d;++a)(c=t[a])&&l.get(f[a])===c&&(o[a]=c)}function Kc(e){return e.__data__}function qc(e,t){if(!arguments.length)return Array.from(this,Kc);var n=t?Xc:Yc,r=this._parents,o=this._groups;typeof e!="function"&&(e=Wc(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=Gc(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,p=0,v,M;E<g;++E)if(v=w[E]){for(E>=p&&(p=E+1);!(M=x[p])&&++p<g;);v._next=M||null}}return i=new Me(i,r),i._enter=a,i._exit=c,i}function Gc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Uc(){return new Me(this._exit||this._groups.map(Cs),this._parents)}function Zc(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 Qc(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 Me(a,this._parents)}function Jc(){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 el(e){e||(e=tl);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 Me(o,this._parents).order()}function tl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function nl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function rl(){return Array.from(this)}function ol(){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 sl(){let e=0;for(const t of this)++e;return e}function il(){return!this.node()}function al(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 cl(e){return function(){this.removeAttribute(e)}}function ll(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ul(e,t){return function(){this.setAttribute(e,t)}}function dl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function fl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function hl(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 gl(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?ll:cl:typeof t=="function"?n.local?hl:fl:n.local?dl:ul)(n,t))}function As(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function pl(e){return function(){this.style.removeProperty(e)}}function ml(e,t,n){return function(){this.style.setProperty(e,t,n)}}function yl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function xl(e,t,n){return arguments.length>1?this.each((t==null?pl:typeof t=="function"?yl:ml)(e,t,n??"")):vt(this.node(),e)}function vt(e,t){return e.style.getPropertyValue(t)||As(e).getComputedStyle(e,null).getPropertyValue(t)}function wl(e){return function(){delete this[e]}}function vl(e,t){return function(){this[e]=t}}function bl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function _l(e,t){return arguments.length>1?this.each((t==null?wl:typeof t=="function"?bl:vl)(e,t)):this.node()[e]}function $s(e){return e.trim().split(/^|\s+/)}function Lr(e){return e.classList||new Is(e)}function Is(e){this._node=e,this._names=$s(e.getAttribute("class")||"")}Is.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 Ps(e,t){for(var n=Lr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function js(e,t){for(var n=Lr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function El(e){return function(){Ps(this,e)}}function Nl(e){return function(){js(this,e)}}function Sl(e,t){return function(){(t.apply(this,arguments)?Ps:js)(this,e)}}function Ml(e,t){var n=$s(e+"");if(arguments.length<2){for(var r=Lr(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?Sl:t?El:Nl)(n,t))}function kl(){this.textContent=""}function Cl(e){return function(){this.textContent=e}}function Al(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function $l(e){return arguments.length?this.each(e==null?kl:(typeof e=="function"?Al:Cl)(e)):this.node().textContent}function Il(){this.innerHTML=""}function Pl(e){return function(){this.innerHTML=e}}function jl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Dl(e){return arguments.length?this.each(e==null?Il:(typeof e=="function"?jl:Pl)(e)):this.node().innerHTML}function Tl(){this.nextSibling&&this.parentNode.appendChild(this)}function Rl(){return this.each(Tl)}function Ll(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function zl(){return this.each(Ll)}function Hl(e){var t=typeof e=="function"?e:Ns(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ol(){return null}function Vl(e,t){var n=typeof e=="function"?e:Ns(e),r=t==null?Ol:typeof t=="function"?t:Rr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Bl(){var e=this.parentNode;e&&e.removeChild(this)}function Fl(){return this.each(Bl)}function Wl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xl(e){return this.select(e?Yl:Wl)}function Kl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ql(e){return function(t){e.call(this,t,this.__data__)}}function Gl(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 Ul(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 Zl(e,t,n){return function(){var r=this.__on,o,s=ql(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 Ql(e,t,n){var r=Gl(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?Zl:Ul,o=0;o<s;++o)this.each(a(r[o],t,n));return this}function Ds(e,t,n){var r=As(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 Jl(e,t){return function(){return Ds(this,e,t)}}function eu(e,t){return function(){return Ds(this,e,t.apply(this,arguments))}}function tu(e,t){return this.each((typeof t=="function"?eu:Jl)(e,t))}function*nu(){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 Ts=[null];function Me(e,t){this._groups=e,this._parents=t}function Ut(){return new Me([[document.documentElement]],Ts)}function ru(){return this}Me.prototype=Ut.prototype={constructor:Me,select:Ac,selectAll:jc,selectChild:Lc,selectChildren:Vc,filter:Bc,data:qc,enter:Fc,exit:Uc,join:Zc,merge:Qc,selection:ru,order:Jc,sort:el,call:nl,nodes:rl,node:ol,size:sl,empty:il,each:al,attr:gl,style:xl,property:_l,classed:Ml,text:$l,html:Dl,raise:Rl,lower:zl,append:Hl,insert:Vl,remove:Fl,clone:Xl,datum:Kl,on:Ql,dispatch:tu,[Symbol.iterator]:nu};function Se(e){return typeof e=="string"?new Me([[document.querySelector(e)]],[document.documentElement]):new Me([[e]],Ts)}function ou(e){let t;for(;t=e.sourceEvent;)e=t;return e}function $e(e,t){if(e=ou(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 su={passive:!1},Ot={capture:!0,passive:!1};function or(e){e.stopImmediatePropagation()}function xt(e){e.preventDefault(),e.stopImmediatePropagation()}function Rs(e){var t=e.document.documentElement,n=Se(e).on("dragstart.drag",xt,Ot);"onselectstart"in t?n.on("selectstart.drag",xt,Ot):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ls(e,t){var n=e.document.documentElement,r=Se(e).on("dragstart.drag",null);t&&(r.on("click.drag",xt,Ot),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 un=e=>()=>e;function _r(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}})}_r.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function iu(e){return!e.ctrlKey&&!e.button}function au(){return this.parentNode}function cu(e,t){return t??{x:e.x,y:e.y}}function lu(){return navigator.maxTouchPoints||"ontouchstart"in this}function zs(){var e=iu,t=au,n=cu,r=lu,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,su).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,M){if(!(d||!e.call(this,v,M))){var k=p(this,t.call(this,v,M),v,M,"mouse");k&&(Se(v.view).on("mousemove.drag",g,Ot).on("mouseup.drag",w,Ot),Rs(v.view),or(v),l=!1,a=v.clientX,c=v.clientY,k("start",v))}}function g(v){if(xt(v),!l){var M=v.clientX-a,k=v.clientY-c;l=M*M+k*k>u}o.mouse("drag",v)}function w(v){Se(v.view).on("mousemove.drag mouseup.drag",null),Ls(v.view,l),xt(v),o.mouse("end",v)}function x(v,M){if(e.call(this,v,M)){var k=v.changedTouches,I=t.call(this,v,M),$=k.length,T,F;for(T=0;T<$;++T)(F=p(this,I,v,M,k[T].identifier,k[T]))&&(or(v),F("start",v,k[T]))}}function y(v){var M=v.changedTouches,k=M.length,I,$;for(I=0;I<k;++I)($=o[M[I].identifier])&&(xt(v),$("drag",v,M[I]))}function E(v){var M=v.changedTouches,k=M.length,I,$;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),I=0;I<k;++I)($=o[M[I].identifier])&&(or(v),$("end",v,M[I]))}function p(v,M,k,I,$,T){var F=s.copy(),C=$e(T||k,M),S,z,b;if((b=n.call(v,new _r("beforestart",{sourceEvent:k,target:f,identifier:$,active:i,x:C[0],y:C[1],dx:0,dy:0,dispatch:F}),I))!=null)return S=b.x-C[0]||0,z=b.y-C[1]||0,function P(N,D,R){var A=C,B;switch(N){case"start":o[$]=P,B=i++;break;case"end":delete o[$],--i;case"drag":C=$e(R||D,M),B=i;break}F.call(N,v,new _r(N,{sourceEvent:D,subject:b,target:f,identifier:$,active:B,x:C[0]+S,y:C[1]+z,dx:C[0]-A[0],dy:C[1]-A[1],dispatch:F}),I)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:un(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:un(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:un(v),f):n},f.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:un(!!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 zr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Hs(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Zt(){}var Vt=.7,kn=1/Vt,wt="\\s*([+-]?\\d+)\\s*",Bt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ze="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",uu=/^#([0-9a-f]{3,8})$/,du=new RegExp(`^rgb\\(${wt},${wt},${wt}\\)$`),fu=new RegExp(`^rgb\\(${ze},${ze},${ze}\\)$`),hu=new RegExp(`^rgba\\(${wt},${wt},${wt},${Bt}\\)$`),gu=new RegExp(`^rgba\\(${ze},${ze},${ze},${Bt}\\)$`),pu=new RegExp(`^hsl\\(${Bt},${ze},${ze}\\)$`),mu=new RegExp(`^hsla\\(${Bt},${ze},${ze},${Bt}\\)$`),ho={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};zr(Zt,it,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:go,formatHex:go,formatHex8:yu,formatHsl:xu,formatRgb:po,toString:po});function go(){return this.rgb().formatHex()}function yu(){return this.rgb().formatHex8()}function xu(){return Os(this).formatHsl()}function po(){return this.rgb().formatRgb()}function it(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=uu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?mo(t):n===3?new ve(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?dn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?dn(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=du.exec(e))?new ve(t[1],t[2],t[3],1):(t=fu.exec(e))?new ve(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=hu.exec(e))?dn(t[1],t[2],t[3],t[4]):(t=gu.exec(e))?dn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=pu.exec(e))?wo(t[1],t[2]/100,t[3]/100,1):(t=mu.exec(e))?wo(t[1],t[2]/100,t[3]/100,t[4]):ho.hasOwnProperty(e)?mo(ho[e]):e==="transparent"?new ve(NaN,NaN,NaN,0):null}function mo(e){return new ve(e>>16&255,e>>8&255,e&255,1)}function dn(e,t,n,r){return r<=0&&(e=t=n=NaN),new ve(e,t,n,r)}function wu(e){return e instanceof Zt||(e=it(e)),e?(e=e.rgb(),new ve(e.r,e.g,e.b,e.opacity)):new ve}function Er(e,t,n,r){return arguments.length===1?wu(e):new ve(e,t,n,r??1)}function ve(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}zr(ve,Er,Hs(Zt,{brighter(e){return e=e==null?kn:Math.pow(kn,e),new ve(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Vt:Math.pow(Vt,e),new ve(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ve(rt(this.r),rt(this.g),rt(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:yo,formatHex:yo,formatHex8:vu,formatRgb:xo,toString:xo}));function yo(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}`}function vu(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}${nt((isNaN(this.opacity)?1:this.opacity)*255)}`}function xo(){const e=Cn(this.opacity);return`${e===1?"rgb(":"rgba("}${rt(this.r)}, ${rt(this.g)}, ${rt(this.b)}${e===1?")":`, ${e})`}`}function Cn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function rt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function nt(e){return e=rt(e),(e<16?"0":"")+e.toString(16)}function wo(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ie(e,t,n,r)}function Os(e){if(e instanceof Ie)return new Ie(e.h,e.s,e.l,e.opacity);if(e instanceof Zt||(e=it(e)),!e)return new Ie;if(e instanceof Ie)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 Ie(i,a,c,e.opacity)}function bu(e,t,n,r){return arguments.length===1?Os(e):new Ie(e,t,n,r??1)}function Ie(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}zr(Ie,bu,Hs(Zt,{brighter(e){return e=e==null?kn:Math.pow(kn,e),new Ie(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Vt:Math.pow(Vt,e),new Ie(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 ve(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 Ie(vo(this.h),fn(this.s),fn(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("}${vo(this.h)}, ${fn(this.s)*100}%, ${fn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function vo(e){return e=(e||0)%360,e<0?e+360:e}function fn(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 Hr=e=>()=>e;function _u(e,t){return function(n){return e+n*t}}function Eu(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 Nu(e){return(e=+e)==1?Vs:function(t,n){return n-t?Eu(t,n,e):Hr(isNaN(t)?n:t)}}function Vs(e,t){var n=t-e;return n?_u(e,n):Hr(isNaN(e)?t:e)}const An=function e(t){var n=Nu(t);function r(o,s){var i=n((o=Er(o)).r,(s=Er(s)).r),a=n(o.g,s.g),c=n(o.b,s.b),l=Vs(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 Su(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 Mu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ku(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]=zt(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 Cu(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Le(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Au(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]=zt(e[o],t[o]):r[o]=t[o];return function(s){for(o in n)r[o]=n[o](s);return r}}var Nr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ir=new RegExp(Nr.source,"g");function $u(e){return function(){return e}}function Iu(e){return function(t){return e(t)+""}}function Bs(e,t){var n=Nr.lastIndex=ir.lastIndex=0,r,o,s,i=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Nr.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:Le(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]?Iu(c[0].x):$u(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 zt(e,t){var n=typeof t,r;return t==null||n==="boolean"?Hr(t):(n==="number"?Le:n==="string"?(r=it(t))?(t=r,An):Bs:t instanceof it?An:t instanceof Date?Cu:Mu(t)?Su:Array.isArray(t)?ku:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Au:Le)(e,t)}var bo=180/Math.PI,Sr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fs(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)*bo,skewX:Math.atan(c)*bo,scaleX:i,scaleY:a}}var hn;function Pu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Sr:Fs(t.a,t.b,t.c,t.d,t.e,t.f)}function ju(e){return e==null||(hn||(hn=document.createElementNS("http://www.w3.org/2000/svg","g")),hn.setAttribute("transform",e),!(e=hn.transform.baseVal.consolidate()))?Sr:(e=e.matrix,Fs(e.a,e.b,e.c,e.d,e.e,e.f))}function Ws(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:Le(l,u)},{i:w-2,x:Le(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:Le(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:Le(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:Le(l,u)},{i:w-2,x:Le(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 Du=Ws(Pu,"px, ","px)","deg)"),Tu=Ws(ju,", ",")",")"),Ru=1e-12;function _o(e){return((e=Math.exp(e))+1/e)/2}function Lu(e){return((e=Math.exp(e))-1/e)/2}function zu(e){return((e=Math.exp(2*e))-1)/(e+1)}const _n=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<Ru)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),p=(f*f-l*l+r*w)/(2*l*n*E),v=(f*f-l*l-r*w)/(2*f*n*E),M=Math.log(Math.sqrt(p*p+1)-p),k=Math.log(Math.sqrt(v*v+1)-v);y=(k-M)/t,x=function(I){var $=I*y,T=_o(M),F=l/(n*E)*(T*zu(t*$+M)-Lu(M));return[a+F*h,c+F*g,l*T/_o(t*$+M)]}}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 bt=0,Tt=0,It=0,Ys=1e3,$n,Rt,In=0,at=0,Hn=0,Ft=typeof performance=="object"&&performance.now?performance:Date,Xs=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Or(){return at||(Xs(Hu),at=Ft.now()+Hn)}function Hu(){at=0}function Pn(){this._call=this._time=this._next=null}Pn.prototype=Ks.prototype={constructor:Pn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Or():+n)+(t==null?0:+t),!this._next&&Rt!==this&&(Rt?Rt._next=this:$n=this,Rt=this),this._call=e,this._time=n,Mr()},stop:function(){this._call&&(this._call=null,this._time=1/0,Mr())}};function Ks(e,t,n){var r=new Pn;return r.restart(e,t,n),r}function Ou(){Or(),++bt;for(var e=$n,t;e;)(t=at-e._time)>=0&&e._call.call(void 0,t),e=e._next;--bt}function Eo(){at=(In=Ft.now())+Hn,bt=Tt=0;try{Ou()}finally{bt=0,Bu(),at=0}}function Vu(){var e=Ft.now(),t=e-In;t>Ys&&(Hn-=t,In=e)}function Bu(){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);Rt=e,Mr(r)}function Mr(e){if(!bt){Tt&&(Tt=clearTimeout(Tt));var t=e-at;t>24?(e<1/0&&(Tt=setTimeout(Eo,e-Ft.now()-Hn)),It&&(It=clearInterval(It))):(It||(In=Ft.now(),It=setInterval(Vu,Ys)),bt=1,Xs(Eo))}}function No(e,t,n){var r=new Pn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Fu=Ln("start","end","cancel","interrupt"),Wu=[],qs=0,So=1,kr=2,En=3,Mo=4,Cr=5,Nn=6;function On(e,t,n,r,o,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Yu(e,n,{name:t,index:r,group:o,on:Fu,tween:Wu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:qs})}function Vr(e,t){var n=Te(e,t);if(n.state>qs)throw new Error("too late; already scheduled");return n}function He(e,t){var n=Te(e,t);if(n.state>En)throw new Error("too late; already running");return n}function Te(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Yu(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=Ks(s,0,n.time);function s(l){n.state=So,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!==So)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===En)return No(i);h.state===Mo?(h.state=Nn,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=Nn,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(No(function(){n.state===En&&(n.state=Mo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=kr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===kr){for(n.state=En,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=Cr,1),u=-1,f=o.length;++u<f;)o[u].call(e,d);n.state===Cr&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Nn,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Sn(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>kr&&r.state<Cr,r.state=Nn,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}s&&delete e.__transition}}function Xu(e){return this.each(function(){Sn(this,e)})}function Ku(e,t){var n,r;return function(){var o=He(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 qu(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=He(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 Gu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Te(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?Ku:qu)(n,e,t))}function Br(e,t,n){var r=e._id;return e.each(function(){var o=He(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Te(o,r).value[t]}}function Gs(e,t){var n;return(typeof t=="number"?Le:t instanceof it?An:(n=it(t))?(t=n,An):Bs)(e,t)}function Uu(e){return function(){this.removeAttribute(e)}}function Zu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qu(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 Ju(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 ed(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 td(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 nd(e,t){var n=zn(e),r=n==="transform"?Tu:Gs;return this.attrTween(e,typeof t=="function"?(n.local?td:ed)(n,r,Br(this,"attr."+e,t)):t==null?(n.local?Zu:Uu)(n):(n.local?Ju:Qu)(n,r,t))}function rd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function od(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function sd(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&od(e,s)),n}return o._value=t,o}function id(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&rd(e,s)),n}return o._value=t,o}function ad(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?sd:id)(r,t))}function cd(e,t){return function(){Vr(this,e).delay=+t.apply(this,arguments)}}function ld(e,t){return t=+t,function(){Vr(this,e).delay=t}}function ud(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?cd:ld)(t,e)):Te(this.node(),t).delay}function dd(e,t){return function(){He(this,e).duration=+t.apply(this,arguments)}}function fd(e,t){return t=+t,function(){He(this,e).duration=t}}function hd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dd:fd)(t,e)):Te(this.node(),t).duration}function gd(e,t){if(typeof t!="function")throw new Error;return function(){He(this,e).ease=t}}function pd(e){var t=this._id;return arguments.length?this.each(gd(t,e)):Te(this.node(),t).ease}function md(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;He(this,e).ease=n}}function yd(e){if(typeof e!="function")throw new Error;return this.each(md(this._id,e))}function xd(e){typeof e!="function"&&(e=Ms(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 We(r,this._parents,this._name,this._id)}function wd(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 We(i,this._parents,this._name,this._id)}function vd(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 bd(e,t,n){var r,o,s=vd(t)?Vr:He;return function(){var i=s(this,e),a=i.on;a!==r&&(o=(r=a).copy()).on(t,n),i.on=o}}function _d(e,t){var n=this._id;return arguments.length<2?Te(this.node(),n).on.on(e):this.each(bd(n,e,t))}function Ed(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Nd(){return this.on("end.remove",Ed(this._id))}function Sd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Rr(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,Te(d,n)));return new We(s,this._parents,t,n)}function Md(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ss(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=Te(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 We(s,i,t,n)}var kd=Ut.prototype.constructor;function Cd(){return new kd(this._groups,this._parents)}function Ad(e,t){var n,r,o;return function(){var s=vt(this,e),i=(this.style.removeProperty(e),vt(this,e));return s===i?null:s===n&&i===r?o:o=t(n=s,r=i)}}function Us(e){return function(){this.style.removeProperty(e)}}function $d(e,t,n){var r,o=n+"",s;return function(){var i=vt(this,e);return i===o?null:i===r?s:s=t(r=i,n)}}function Id(e,t,n){var r,o,s;return function(){var i=vt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),vt(this,e))),i===c?null:i===r&&c===o?s:(o=c,s=t(r=i,a))}}function Pd(e,t){var n,r,o,s="style."+t,i="end."+s,a;return function(){var c=He(this,e),l=c.on,d=c.value[s]==null?a||(a=Us(t)):void 0;(l!==n||o!==d)&&(r=(n=l).copy()).on(i,o=d),c.on=r}}function jd(e,t,n){var r=(e+="")=="transform"?Du:Gs;return t==null?this.styleTween(e,Ad(e,r)).on("end.style."+e,Us(e)):typeof t=="function"?this.styleTween(e,Id(e,r,Br(this,"style."+e,t))).each(Pd(this._id,e)):this.styleTween(e,$d(e,r,t),n).on("end.style."+e,null)}function Dd(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Td(e,t,n){var r,o;function s(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&Dd(e,i,n)),r}return s._value=t,s}function Rd(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,Td(e,t,n??""))}function Ld(e){return function(){this.textContent=e}}function zd(e){return function(){var t=e(this);this.textContent=t??""}}function Hd(e){return this.tween("text",typeof e=="function"?zd(Br(this,"text",e)):Ld(e==null?"":e+""))}function Od(e){return function(t){this.textContent=e.call(this,t)}}function Vd(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Od(o)),t}return r._value=e,r}function Bd(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,Vd(e))}function Fd(){for(var e=this._name,t=this._id,n=Zs(),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=Te(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 We(r,this._parents,e,n)}function Wd(){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=He(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 Yd=0;function We(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Zs(){return++Yd}var Be=Ut.prototype;We.prototype={constructor:We,select:Sd,selectAll:Md,selectChild:Be.selectChild,selectChildren:Be.selectChildren,filter:xd,merge:wd,selection:Cd,transition:Fd,call:Be.call,nodes:Be.nodes,node:Be.node,size:Be.size,empty:Be.empty,each:Be.each,on:_d,attr:nd,attrTween:ad,style:jd,styleTween:Rd,text:Hd,textTween:Bd,remove:Nd,tween:Gu,delay:ud,duration:hd,ease:pd,easeVarying:yd,end:Wd,[Symbol.iterator]:Be[Symbol.iterator]};function Xd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Kd={time:null,delay:0,duration:250,ease:Xd};function qd(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 Gd(e){var t,n;e instanceof We?(t=e._id,e=e._name):(t=Zs(),(n=Kd).time=Or(),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||qd(c,t));return new We(r,this._parents,e,t)}Ut.prototype.interrupt=Xu;Ut.prototype.transition=Gd;const gn=e=>()=>e;function Ud(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 Fe(e,t,n){this.k=e,this.x=t,this.y=n}Fe.prototype={constructor:Fe,scale:function(e){return e===1?this:new Fe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Fe(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 Fe(1,0,0);Qs.prototype=Fe.prototype;function Qs(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Vn;return e.__zoom}function ar(e){e.stopImmediatePropagation()}function Pt(e){e.preventDefault(),e.stopImmediatePropagation()}function Zd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Qd(){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 ko(){return this.__zoom||Vn}function Jd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ef(){return navigator.maxTouchPoints||"ontouchstart"in this}function tf(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 Js(){var e=Zd,t=Qd,n=tf,r=Jd,o=ef,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=_n,l=Ln("start","zoom","end"),d,u,f,h=500,g=150,w=0,x=10;function y(b){b.property("__zoom",ko).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",F).filter(o).on("touchstart.zoom",C).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(b,P,N,D){var R=b.selection?b.selection():b;R.property("__zoom",ko),b!==R?M(b,P,N,D):R.interrupt().each(function(){k(this,arguments).event(D).start().zoom(null,typeof P=="function"?P.apply(this,arguments):P).end()})},y.scaleBy=function(b,P,N,D){y.scaleTo(b,function(){var R=this.__zoom.k,A=typeof P=="function"?P.apply(this,arguments):P;return R*A},N,D)},y.scaleTo=function(b,P,N,D){y.transform(b,function(){var R=t.apply(this,arguments),A=this.__zoom,B=N==null?v(R):typeof N=="function"?N.apply(this,arguments):N,O=A.invert(B),V=typeof P=="function"?P.apply(this,arguments):P;return n(p(E(A,V),B,O),R,i)},N,D)},y.translateBy=function(b,P,N,D){y.transform(b,function(){return n(this.__zoom.translate(typeof P=="function"?P.apply(this,arguments):P,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),i)},null,D)},y.translateTo=function(b,P,N,D,R){y.transform(b,function(){var A=t.apply(this,arguments),B=this.__zoom,O=D==null?v(A):typeof D=="function"?D.apply(this,arguments):D;return n(Vn.translate(O[0],O[1]).scale(B.k).translate(typeof P=="function"?-P.apply(this,arguments):-P,typeof N=="function"?-N.apply(this,arguments):-N),A,i)},D,R)};function E(b,P){return P=Math.max(s[0],Math.min(s[1],P)),P===b.k?b:new Fe(P,b.x,b.y)}function p(b,P,N){var D=P[0]-N[0]*b.k,R=P[1]-N[1]*b.k;return D===b.x&&R===b.y?b:new Fe(b.k,D,R)}function v(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function M(b,P,N,D){b.on("start.zoom",function(){k(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(D).end()}).tween("zoom",function(){var R=this,A=arguments,B=k(R,A).event(D),O=t.apply(R,A),V=N==null?v(O):typeof N=="function"?N.apply(R,A):N,X=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),K=R.__zoom,te=typeof P=="function"?P.apply(R,A):P,ne=c(K.invert(V).concat(X/K.k),te.invert(V).concat(X/te.k));return function(J){if(J===1)J=te;else{var H=ne(J),Y=X/H[2];J=new Fe(Y,V[0]-H[0]*Y,V[1]-H[1]*Y)}B.zoom(null,J)}})}function k(b,P,N){return!N&&b.__zooming||new I(b,P)}function I(b,P){this.that=b,this.args=P,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,P),this.taps=0}I.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,P){return this.mouse&&b!=="mouse"&&(this.mouse[1]=P.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=P.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=P.invert(this.touch1[0])),this.that.__zoom=P,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var P=Se(this.that).datum();l.call(b,this.that,new Ud(b,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),P)}};function $(b,...P){if(!e.apply(this,arguments))return;var N=k(this,P).event(b),D=this.__zoom,R=Math.max(s[0],Math.min(s[1],D.k*Math.pow(2,r.apply(this,arguments)))),A=$e(b);if(N.wheel)(N.mouse[0][0]!==A[0]||N.mouse[0][1]!==A[1])&&(N.mouse[1]=D.invert(N.mouse[0]=A)),clearTimeout(N.wheel);else{if(D.k===R)return;N.mouse=[A,D.invert(A)],Sn(this),N.start()}Pt(b),N.wheel=setTimeout(B,g),N.zoom("mouse",n(p(E(D,R),N.mouse[0],N.mouse[1]),N.extent,i));function B(){N.wheel=null,N.end()}}function T(b,...P){if(f||!e.apply(this,arguments))return;var N=b.currentTarget,D=k(this,P,!0).event(b),R=Se(b.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",X,!0),A=$e(b,N),B=b.clientX,O=b.clientY;Rs(b.view),ar(b),D.mouse=[A,this.__zoom.invert(A)],Sn(this),D.start();function V(K){if(Pt(K),!D.moved){var te=K.clientX-B,ne=K.clientY-O;D.moved=te*te+ne*ne>w}D.event(K).zoom("mouse",n(p(D.that.__zoom,D.mouse[0]=$e(K,N),D.mouse[1]),D.extent,i))}function X(K){R.on("mousemove.zoom mouseup.zoom",null),Ls(K.view,D.moved),Pt(K),D.event(K).end()}}function F(b,...P){if(e.apply(this,arguments)){var N=this.__zoom,D=$e(b.changedTouches?b.changedTouches[0]:b,this),R=N.invert(D),A=N.k*(b.shiftKey?.5:2),B=n(p(E(N,A),D,R),t.apply(this,P),i);Pt(b),a>0?Se(this).transition().duration(a).call(M,B,D,b):Se(this).call(y.transform,B,D,b)}}function C(b,...P){if(e.apply(this,arguments)){var N=b.touches,D=N.length,R=k(this,P,b.changedTouches.length===D).event(b),A,B,O,V;for(ar(b),B=0;B<D;++B)O=N[B],V=$e(O,this),V=[V,this.__zoom.invert(V),O.identifier],R.touch0?!R.touch1&&R.touch0[2]!==V[2]&&(R.touch1=V,R.taps=0):(R.touch0=V,A=!0,R.taps=1+!!d);d&&(d=clearTimeout(d)),A&&(R.taps<2&&(u=V[0],d=setTimeout(function(){d=null},h)),Sn(this),R.start())}}function S(b,...P){if(this.__zooming){var N=k(this,P).event(b),D=b.changedTouches,R=D.length,A,B,O,V;for(Pt(b),A=0;A<R;++A)B=D[A],O=$e(B,this),N.touch0&&N.touch0[2]===B.identifier?N.touch0[0]=O:N.touch1&&N.touch1[2]===B.identifier&&(N.touch1[0]=O);if(B=N.that.__zoom,N.touch1){var X=N.touch0[0],K=N.touch0[1],te=N.touch1[0],ne=N.touch1[1],J=(J=te[0]-X[0])*J+(J=te[1]-X[1])*J,H=(H=ne[0]-K[0])*H+(H=ne[1]-K[1])*H;B=E(B,Math.sqrt(J/H)),O=[(X[0]+te[0])/2,(X[1]+te[1])/2],V=[(K[0]+ne[0])/2,(K[1]+ne[1])/2]}else if(N.touch0)O=N.touch0[0],V=N.touch0[1];else return;N.zoom("touch",n(p(B,O,V),N.extent,i))}}function z(b,...P){if(this.__zooming){var N=k(this,P).event(b),D=b.changedTouches,R=D.length,A,B;for(ar(b),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),A=0;A<R;++A)B=D[A],N.touch0&&N.touch0[2]===B.identifier?delete N.touch0:N.touch1&&N.touch1[2]===B.identifier&&delete N.touch1;if(N.touch1&&!N.touch0&&(N.touch0=N.touch1,delete N.touch1),N.touch0)N.touch0[1]=this.__zoom.invert(N.touch0[0]);else if(N.end(),N.taps===2&&(B=$e(B,this),Math.hypot(u[0]-B[0],u[1]-B[1])<x)){var O=Se(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return y.wheelDelta=function(b){return arguments.length?(r=typeof b=="function"?b:gn(+b),y):r},y.filter=function(b){return arguments.length?(e=typeof b=="function"?b:gn(!!b),y):e},y.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:gn(!!b),y):o},y.extent=function(b){return arguments.length?(t=typeof b=="function"?b:gn([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),y):t},y.scaleExtent=function(b){return arguments.length?(s[0]=+b[0],s[1]=+b[1],y):[s[0],s[1]]},y.translateExtent=function(b){return arguments.length?(i[0][0]=+b[0][0],i[1][0]=+b[1][0],i[0][1]=+b[0][1],i[1][1]=+b[1][1],y):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},y.constrain=function(b){return arguments.length?(n=b,y):n},y.duration=function(b){return arguments.length?(a=+b,y):a},y.interpolate=function(b){return arguments.length?(c=b,y):c},y.on=function(){var b=l.on.apply(l,arguments);return b===l?y:b},y.clickDistance=function(b){return arguments.length?(w=(b=+b)*b,y):Math.sqrt(w)},y.tapDistance=function(b){return arguments.length?(x=+b,y):x},y}const De={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.`},Wt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ei=["Enter"," ","Escape"],ti={"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 _t;(function(e){e.Strict="strict",e.Loose="loose"})(_t||(_t={}));var ot;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ot||(ot={}));var Yt;(function(e){e.Partial="partial",e.Full="full"})(Yt||(Yt={}));const ni={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ge;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ge||(Ge={}));var Xt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Xt||(Xt={}));var Q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Q||(Q={}));const Co={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function ri(e){return e===null?null:e?"valid":"invalid"}const oi=e=>"id"in e&&"source"in e&&"target"in e,nf=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Fr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Qt=(e,t=[0,0])=>{const{width:n,height:r}=Ye(e),o=e.origin??t,s=n*o[0],i=r*o[1];return{x:e.position.x-s,y:e.position.y-i}},rf=(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):Fr(o)?o:t.nodeLookup.get(o.id));const a=i?jn(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)},Jt=(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,jn(o)),r=!0)}),r?Fn(n):{x:0,y:0,width:0,height:0}},Wr=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1)=>{const a={...At(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=Kt(a,Nt(l)),x=(h??0)*(g??0),y=s&&w>0;(!l.internals.handleBounds||y||w>=x||l.dragging)&&c.push(l)}return c},of=(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 sf(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 af({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:s},i){if(e.size===0)return!0;const a=sf(e,i),c=Jt(a),l=Xr(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 si({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",De.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[c,l],[c+h,l+g]])}else a&&lt(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=lt(u)?ct(t,u,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&(s==null||s("015",De.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 cf({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=of(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 Et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ct=(e={x:0,y:0},t,n)=>({x:Et(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Et(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ii(e,t,n){const{width:r,height:o}=Ye(n),{x:s,y:i}=n.internals.positionAbsolute;return ct(e,[[s,i],[s+r,i+o]],t)}const Ao=(e,t,n)=>e<t?Et(Math.abs(e-t),1,t)/t:e>n?-Et(Math.abs(e-n),1,t)/t:0,Yr=(e,t,n=15,r=40)=>{const o=Ao(e.x,r,t.width-r)*n,s=Ao(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)}),Ar=({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}),Nt=(e,t=[0,0])=>{var o,s;const{x:n,y:r}=Fr(e)?e.internals.positionAbsolute:Qt(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}},jn=(e,t=[0,0])=>{var o,s;const{x:n,y:r}=Fr(e)?e.internals.positionAbsolute:Qt(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)}},ai=(e,t)=>Fn(Bn(Ar(e),Ar(t))),Kt=(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)},$o=e=>Pe(e.width)&&Pe(e.height)&&Pe(e.x)&&Pe(e.y),Pe=e=>!isNaN(e)&&isFinite(e),ci=(e,t)=>(n,r)=>{},en=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),At=({x:e,y:t},[n,r,o],s=!1,i=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return s?en(a,i):a},St=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function pt(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 lf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=pt(e,n),o=pt(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=pt(e.top??e.y??0,n),o=pt(e.bottom??e.y??0,n),s=pt(e.left??e.x??0,t),i=pt(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 uf(e,t,n,r,o,s){const{x:i,y:a}=St(e,[t,n,r]),{x:c,y:l}=St({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 Xr=(e,t,n,r,o,s)=>{const i=lf(s,t,n),a=(t-i.x)/e.width,c=(n-i.y)/e.height,l=Math.min(a,c),d=Et(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=uf(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}},qt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function lt(e){return e!=null&&e!=="parent"}function Ye(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 li(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 ui(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 Io(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function df(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function ff(e){return{...ti,...e||{}}}function Ht(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:s,y:i}=je(e),a=At({x:s-((o==null?void 0:o.left)??0),y:i-((o==null?void 0:o.top)??0)},r),{x:c,y:l}=n?en(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Kr=e=>({width:e.offsetWidth,height:e.offsetHeight}),di=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},hf=["INPUT","SELECT","TEXTAREA"];function fi(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:hf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const hi=e=>"clientX"in e,je=(e,t)=>{var s,i;const n=hi(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)}},Po=(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,...Kr(i)}})};function gi({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 pn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function jo({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case Q.Left:return[t-pn(t-r,s),n];case Q.Right:return[t+pn(r-t,s),n];case Q.Top:return[t,n-pn(n-o,s)];case Q.Bottom:return[t,n+pn(o-n,s)]}}function pi({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:o,targetPosition:s=Q.Top,curvature:i=.25}){const[a,c]=jo({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[l,d]=jo({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[u,f,h,g]=gi({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 mi({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 gf({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 pf({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const s=Bn(jn(e),jn(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 Kt(i,Fn(s))>0}const mf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,yf=(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)),xf=(e,t,n={})=>{var s;if(!e.source||!e.target)return(s=n.onError)==null||s.call(n,"006",De.error006()),t;const r=n.getEdgeId||mf;let o;return oi(e)?o={...e}:o={...e,id:r(e)},yf(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function yi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,a]=mi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,a]}const Do={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},wf=({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},To=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function vf({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:o,offset:s,stepPosition:i}){const a=Do[t],c=Do[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=wf({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},[,,p,v]=mi({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 $=[{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"?$:T:g=f==="x"?T:$}else{const $=[{x:l.x,y:d.y}],T=[{x:d.x,y:l.y}];if(f==="x"?g=a.x===h?T:$:g=a.y===h?$:T,t===r){const b=Math.abs(e[f]-n[f]);if(b<=s){const P=Math.min(s-1,s-b);a[f]===h?y[f]=(l[f]>e[f]?-1:1)*P:E[f]=(d[f]>n[f]?-1:1)*P}}if(t!==r){const b=f==="x"?"y":"x",P=a[f]===c[b],N=l[b]>d[b],D=l[b]<d[b];(a[f]===1&&(!P&&N||P&&D)||a[f]!==1&&(!P&&D||P&&N))&&(g=f==="x"?$:T)}const F={x:l.x+y.x,y:l.y+y.y},C={x:d.x+E.x,y:d.y+E.y},S=Math.max(Math.abs(F.x-g[0].x),Math.abs(C.x-g[0].x)),z=Math.max(Math.abs(F.y-g[0].y),Math.abs(C.y-g[0].y));S>=z?(w=(F.x+C.x)/2,x=g[0].y):(w=g[0].x,x=(F.y+C.y)/2)}const M={x:l.x+y.x,y:l.y+y.y},k={x:d.x+E.x,y:d.y+E.y};return[[e,...M.x!==g[0].x||M.y!==g[0].y?[M]:[],...g,...k.x!==g[g.length-1].x||k.y!==g[g.length-1].y?[k]:[],n],w,x,p,v]}function bf(e,t,n,r){const o=Math.min(To(e,t)/2,To(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 $r({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]=vf({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+=bf(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 Ro(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function _f(e){var u;const{sourceNode:t,targetNode:n}=e;if(!Ro(t)||!Ro(n))return null;const r=t.internals.handleBounds||Lo(t.handles),o=n.internals.handleBounds||Lo(n.handles),s=zo((r==null?void 0:r.source)??[],e.sourceHandle),i=zo(e.connectionMode===_t.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",De.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=ut(t,s,a),d=ut(n,i,c);return{sourceX:l.x,sourceY:l.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:c}}function Lo(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 ut(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??Ye(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 zo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ir(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Ef(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=Ir(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 xi=1e3,Nf=10,qr={nodeOrigin:[0,0],nodeExtent:Wt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Sf={...qr,checkEquality:!0};function Gr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Mf(e,t,n){const r=Gr(qr,n);for(const o of e.values())if(o.parentId)Zr(o,e,t,r);else{const s=Qt(o,r.nodeOrigin),i=lt(o.extent)?o.extent:r.nodeExtent,a=ct(s,i,Ye(o));o.internals.positionAbsolute=a}}function kf(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 Ur(e){return e==="manual"}function Pr(e,t,n,r={}){var d,u;const o=Gr(Sf,r),s={i:0},i=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!Ur(o.zIndexMode)?xi: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=Qt(f,o.nodeOrigin),w=lt(f.extent)?f.extent:o.nodeExtent,x=ct(g,w,Ye(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:kf(f,h),z:wi(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&&Zr(h,t,n,r,s),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function Cf(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 Zr(e,t,n,r,o){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:a,zIndexMode:c}=Gr(qr,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}Cf(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*Nf),o&&d.internals.rootParentIndex!==void 0&&(o.i=d.internals.rootParentIndex);const u=s&&!Ur(c)?xi:0,{x:f,y:h,z:g}=Af(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 wi(e,t,n){const r=Pe(e.zIndex)?e.zIndex:0;return Ur(n)?r:r+(e.selected?t:0)}function Af(e,t,n,r,o,s){const{x:i,y:a}=t.internals.positionAbsolute,c=Ye(e),l=Qt(e,n),d=lt(e.extent)?ct(l,e.extent,c):l;let u=ct({x:i+d.x,y:a+d.y},r,c);e.extent==="parent"&&(u=ii(u,c,t));const f=wi(e,o,s),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function Qr(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)??Nt(c),d=ai(l,a.rect);s.set(a.parentId,{expandedRect:d,parent:c})}return s.size>0&&s.forEach(({expandedRect:a,parent:c},l)=>{var p;const d=c.internals.positionAbsolute,u=Ye(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}}),(p=n.get(l))==null||p.forEach(v=>{e.some(M=>M.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 $f(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=Kr(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(),p=lt(g.extent)?g.extent:s;let{positionAbsolute:v}=g.internals;g.parentId&&g.extent==="parent"?v=ii(v,w,t.get(g.parentId)):p&&(v=ct(v,p,w));const M={...g,measured:w,internals:{...g.internals,positionAbsolute:v,handleBounds:{source:Po("source",h.nodeElement,E,u,g.id),target:Po("target",h.nodeElement,E,u,g.id)}}};t.set(g.id,M),g.parentId&&Zr(M,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:Nt(M,o)}))}}if(f.length>0){const h=Qr(f,t,n,o);l.push(...h)}return{changes:l,updatedInternals:c}}async function If({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 Ho(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 vi(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}`;Ho("source",c,d,e,o,i),Ho("target",c,l,e,s,a),t.set(r.id,r)}}function bi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:bi(n,t):!1}function Oo(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 Pf(e,t,n,r){const o=new Map;for(const[s,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!bi(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 jf({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=en(s,t);return{x:i.x-s.x,y:i.y-s.y}}function Df({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:p,domNode:v,isSelectable:M,nodeId:k,nodeClickDistance:I=0}){f=Se(v);function $({x:S,y:z}){const{nodeLookup:b,nodeExtent:P,snapGrid:N,snapToGrid:D,nodeOrigin:R,onNodeDrag:A,onSelectionDrag:B,onError:O,updateNodePositions:V}=t();s={x:S,y:z};let X=!1;const K=a.size>1,te=K&&P?Ar(Jt(a)):null,ne=K&&D?jf({dragItems:a,snapGrid:N,x:S,y:z}):null;for(const[J,H]of a){if(!b.has(J))continue;let Y={x:S-H.distance.x,y:z-H.distance.y};D&&(Y=ne?{x:Math.round(Y.x+ne.x),y:Math.round(Y.y+ne.y)}:en(Y,N));let U=null;if(K&&P&&!H.extent&&te){const{positionAbsolute:Z}=H.internals,re=Z.x-te.x+P[0][0],ie=Z.x+H.measured.width-te.x2+P[1][0],se=Z.y-te.y+P[0][1],ce=Z.y+H.measured.height-te.y2+P[1][1];U=[[re,se],[ie,ce]]}const{position:ee,positionAbsolute:W}=si({nodeId:J,nextPosition:Y,nodeLookup:b,nodeExtent:U||P,nodeOrigin:R,onError:O});X=X||H.position.x!==ee.x||H.position.y!==ee.y,H.position=ee,H.internals.positionAbsolute=W}if(g=g||X,!!X&&(V(a,!0),w&&(r||A||!k&&B))){const[J,H]=cr({nodeId:k,dragItems:a,nodeLookup:b});r==null||r(w,a,J,H),A==null||A(w,J,H),k||B==null||B(w,H)}}async function T(){if(!d)return;const{transform:S,panBy:z,autoPanSpeed:b,autoPanOnNodeDrag:P}=t();if(!P){c=!1,cancelAnimationFrame(i);return}const[N,D]=Yr(l,d,b);(N!==0||D!==0)&&(s.x=(s.x??0)-N/S[2],s.y=(s.y??0)-D/S[2],await z({x:N,y:D})&&$(s)),i=requestAnimationFrame(T)}function F(S){var K;const{nodeLookup:z,multiSelectionActive:b,nodesDraggable:P,transform:N,snapGrid:D,snapToGrid:R,selectNodesOnDrag:A,onNodeDragStart:B,onSelectionDragStart:O,unselectNodesAndEdges:V}=t();u=!0,(!A||!M)&&!b&&k&&((K=z.get(k))!=null&&K.selected||V()),M&&A&&k&&(e==null||e(k));const X=Ht(S.sourceEvent,{transform:N,snapGrid:D,snapToGrid:R,containerBounds:d});if(s=X,a=Pf(z,P,X,k),a.size>0&&(n||B||!k&&O)){const[te,ne]=cr({nodeId:k,dragItems:a,nodeLookup:z});n==null||n(S.sourceEvent,a,te,ne),B==null||B(S.sourceEvent,te,ne),k||O==null||O(S.sourceEvent,ne)}}const C=zs().clickDistance(I).on("start",S=>{const{domNode:z,nodeDragThreshold:b,transform:P,snapGrid:N,snapToGrid:D}=t();d=(z==null?void 0:z.getBoundingClientRect())||null,h=!1,g=!1,w=S.sourceEvent,b===0&&F(S),s=Ht(S.sourceEvent,{transform:P,snapGrid:N,snapToGrid:D,containerBounds:d}),l=je(S.sourceEvent,d)}).on("drag",S=>{const{autoPanOnNodeDrag:z,transform:b,snapGrid:P,snapToGrid:N,nodeDragThreshold:D,nodeLookup:R}=t(),A=Ht(S.sourceEvent,{transform:b,snapGrid:P,snapToGrid:N,containerBounds:d});if(w=S.sourceEvent,(S.sourceEvent.type==="touchmove"&&S.sourceEvent.touches.length>1||k&&!R.has(k))&&(h=!0),!h){if(!c&&z&&u&&(c=!0,T()),!u){const B=je(S.sourceEvent,d),O=B.x-l.x,V=B.y-l.y;Math.sqrt(O*O+V*V)>D&&F(S)}(s.x!==A.xSnapped||s.y!==A.ySnapped)&&a&&u&&(l=je(S.sourceEvent,d),$(A))}}).on("end",S=>{if(!u||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,u=!1,cancelAnimationFrame(i),a.size>0){const{nodeLookup:z,updateNodePositions:b,onNodeDragStop:P,onSelectionDragStop:N}=t();if(g&&(b(a,!1),g=!1),o||P||!k&&N){const[D,R]=cr({nodeId:k,dragItems:a,nodeLookup:z,dragging:!1});o==null||o(S.sourceEvent,a,D,R),P==null||P(S.sourceEvent,D,R),k||N==null||N(S.sourceEvent,R)}}}).filter(S=>{const z=S.target;return!S.button&&(!E||!Oo(z,`.${E}`,v))&&(!p||Oo(z,p,v))});f.call(C)}function y(){f==null||f.on(".drag",null)}return{update:x,destroy:y}}function Tf(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())Kt(o,Nt(s))>0&&r.push(s);return r}const Rf=250;function Lf(e,t,n,r){var a,c;let o=[],s=1/0;const i=Tf(e,n,t+Rf);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}=ut(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 _i(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,...ut(i,c,c.position,!0)}:c}function Ei(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function zf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ni=()=>!0;function Hf(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=Ni,onReconnectEnd:E,updateConnection:p,getTransform:v,getFromHandle:M,autoPanSpeed:k,dragThreshold:I=1,handleDomNode:$}){const T=di(e.target);let F=0,C;const{x:S,y:z}=je(e),b=Ei(s,$),P=a==null?void 0:a.getBoundingClientRect();let N=!1;if(!P||!b)return;const D=_i(o,b,r,c,t);if(!D)return;let R=je(e,P),A=!1,B=null,O=!1,V=null;function X(){if(!d||!P)return;const[ee,W]=Yr(R,P,k);f({x:ee,y:W}),F=requestAnimationFrame(X)}const K={...D,nodeId:o,type:b,position:D.position},te=c.get(o);let J={inProgress:!0,isValid:null,from:ut(te,K,Q.Left,!0),fromHandle:K,fromPosition:K.position,fromNode:te,to:R,toHandle:null,toPosition:Co[K.position],toNode:null,pointer:R};function H(){N=!0,p(J),g==null||g(e,{nodeId:o,handleId:r,handleType:b})}I===0&&H();function Y(ee){if(!N){const{x:ce,y:xe}=je(ee),be=ce-S,ge=xe-z;if(!(be*be+ge*ge>I*I))return;H()}if(!M()||!K){U(ee);return}const W=v();R=je(ee,P),C=Lf(At(R,W,!1,[1,1]),n,c,K),A||(X(),A=!0);const Z=Si(ee,{handle:C,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:i?"target":"source",isValidConnection:y,doc:T,lib:l,flowId:u,nodeLookup:c});V=Z.handleDomNode,B=Z.connection,O=zf(!!C,Z.isValid);const re=c.get(o),ie=re?ut(re,K,Q.Left,!0):J.from,se={...J,from:ie,isValid:O,to:Z.toHandle&&O?St({x:Z.toHandle.x,y:Z.toHandle.y},W):R,toHandle:Z.toHandle,toPosition:O&&Z.toHandle?Z.toHandle.position:Co[K.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:R};p(se),J=se}function U(ee){if(!("touches"in ee&&ee.touches.length>0)){if(N){(C||V)&&B&&O&&(w==null||w(B));const{inProgress:W,...Z}=J,re={...Z,toPosition:J.toHandle?J.toPosition:null};x==null||x(ee,re),s&&(E==null||E(ee,re))}h(),cancelAnimationFrame(F),A=!1,O=!1,B=null,V=null,T.removeEventListener("mousemove",Y),T.removeEventListener("mouseup",U),T.removeEventListener("touchmove",Y),T.removeEventListener("touchend",U)}}T.addEventListener("mousemove",Y),T.addEventListener("mouseup",U),T.addEventListener("touchmove",Y),T.addEventListener("touchend",U)}function Si(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:s,doc:i,lib:a,flowId:c,isValidConnection:l=Ni,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}=je(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=Ei(void 0,x),p=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),M=x.classList.contains("connectable"),k=x.classList.contains("connectableend");if(!p||!E)return y;const I={source:u?p:r,sourceHandle:u?v:o,target:u?r:p,targetHandle:u?o:v};y.connection=I;const T=M&&k&&(n===_t.Strict?u&&E==="source"||!u&&E==="target":p!==r||v!==o);y.isValid=T&&l(I),y.toHandle=_i(p,E,v,d,n,!0)}return y}const jr={onPointerDown:Hf,isValid:Si};function Of({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Se(e);function s({translateExtent:a,width:c,height:l,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const v=n(),M=p.sourceEvent.ctrlKey&&qt()?10:1,k=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,I=v[2]*Math.pow(2,k*M);t.scaleTo(I)};let w=[0,0];const x=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(w=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},y=p=>{const v=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const M=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],k=[M[0]-w[0],M[1]-w[1]];w=M;const I=r()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),$={x:v[0]-k[0]*I,y:v[1]-k[1]*I},T=[[0,0],[c,l]];t.setViewportConstrained({x:$.x,y:$.y,zoom:v[2]},T,a)},E=Js().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:$e}}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),mt=(e,t)=>e.target.closest(`.${t}`),Mi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Vf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ur=(e,t=0,n=Vf,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},ki=e=>{const t=e.ctrlKey&&qt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Bf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return d=>{if(mt(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=$e(d),y=ki(d),E=u*Math.pow(2,y);r.scaleTo(n,E,x,d);return}const f=d.deltaMode===1?20:1;let h=o===ot.Vertical?0:d.deltaX*f,g=o===ot.Horizontal?0:d.deltaY*f;!qt()&&d.shiftKey&&o!==ot.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 Ff({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const s=r.type==="wheel",i=!t&&s&&!r.ctrlKey,a=mt(r,e);if(r.ctrlKey&&s&&a&&r.preventDefault(),i||a)return null;r.preventDefault(),n.call(this,r,o)}}function Wf({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 Yf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return s=>{var i,a;e.usedRightMouseButton=!!(n&&Mi(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 Xf({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&&Mi(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 Kf({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"&&(mt(u,`${l}-flow__node`)||mt(u,`${l}-flow__edge`)))return!0;if(!r&&!f&&!o&&!s&&!n||i||d&&!g||mt(u,a)&&g||mt(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 qf({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=Js().scaleExtent([t,n]).translateExtent(r),f=Se(e).call(u);E({x:o.x,y:o.y,zoom:Et(o.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(ki);async function w(C,S){return f?new Promise(z=>{u==null||u.interpolate((S==null?void 0:S.interpolate)==="linear"?zt:_n).transform(ur(f,S==null?void 0:S.duration,S==null?void 0:S.ease,()=>z(!0)),C)}):!1}function x({noWheelClassName:C,noPanClassName:S,onPaneContextMenu:z,userSelectionActive:b,panOnScroll:P,panOnDrag:N,panOnScrollMode:D,panOnScrollSpeed:R,preventScrolling:A,zoomOnPinch:B,zoomOnScroll:O,zoomOnDoubleClick:V,zoomActivationKeyPressed:X,lib:K,onTransformChange:te,connectionInProgress:ne,paneClickDistance:J,selectionOnDrag:H}){b&&!l.isZoomingOrPanning&&y();const Y=P&&!X&&!b;u.clickDistance(H?1/0:!Pe(J)||J<0?0:J);const U=Y?Bf({zoomPanValues:l,noWheelClassName:C,d3Selection:f,d3Zoom:u,panOnScrollMode:D,panOnScrollSpeed:R,zoomOnPinch:B,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:a}):Ff({noWheelClassName:C,preventScrolling:A,d3ZoomHandler:h});f.on("wheel.zoom",U,{passive:!1});const ee=Wf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:i});u.on("start",ee);const W=Yf({zoomPanValues:l,panOnDrag:N,onPaneContextMenu:!!z,onPanZoom:s,onTransformChange:te});u.on("zoom",W);const Z=Xf({zoomPanValues:l,panOnDrag:N,panOnScroll:P,onPaneContextMenu:z,onPanZoomEnd:a,onDraggingChange:c});u.on("end",Z);const re=Kf({zoomActivationKeyPressed:X,panOnDrag:N,zoomOnScroll:O,panOnScroll:P,zoomOnDoubleClick:V,zoomOnPinch:B,userSelectionActive:b,noPanClassName:S,noWheelClassName:C,lib:K,connectionInProgress:ne});u.filter(re),V?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function y(){u.on("zoom",null)}async function E(C,S,z){const b=lr(C),P=u==null?void 0:u.constrain()(b,S,z);return P&&await w(P),P}async function p(C,S){const z=lr(C);return await w(z,S),z}function v(C){if(f){const S=lr(C),z=f.property("__zoom");(z.k!==C.zoom||z.x!==C.x||z.y!==C.y)&&(u==null||u.transform(f,S,null,{sync:!0}))}}function M(){const C=f?Qs(f.node()):{x:0,y:0,k:1};return{x:C.x,y:C.y,zoom:C.k}}async function k(C,S){return f?new Promise(z=>{u==null||u.interpolate((S==null?void 0:S.interpolate)==="linear"?zt:_n).scaleTo(ur(f,S==null?void 0:S.duration,S==null?void 0:S.ease,()=>z(!0)),C)}):!1}async function I(C,S){return f?new Promise(z=>{u==null||u.interpolate((S==null?void 0:S.interpolate)==="linear"?zt:_n).scaleBy(ur(f,S==null?void 0:S.duration,S==null?void 0:S.ease,()=>z(!0)),C)}):!1}function $(C){u==null||u.scaleExtent(C)}function T(C){u==null||u.translateExtent(C)}function F(C){const S=!Pe(C)||C<0?0:C;u==null||u.clickDistance(S)}return{update:x,destroy:y,setViewport:p,setViewportConstrained:E,getViewport:M,scaleTo:k,scaleBy:I,setScaleExtent:$,setTranslateExtent:T,syncViewport:v,setClickDistance:F}}var Mt;(function(e){e.Line="line",e.Handle="handle"})(Mt||(Mt={}));function Gf({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 Vo(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 Ke(e,t){return Math.max(0,t-e)}function qe(e,t){return Math.max(0,e-t)}function mn(e,t,n){return Math.max(0,t-e,e-n)}function Bo(e,t){return e?!t:t}function Uf(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:p,y:v,width:M,height:k,aspectRatio:I}=e;let $=Math.floor(d?h-e.pointerX:0),T=Math.floor(u?g-e.pointerY:0);const F=M+(c?-$:$),C=k+(l?-T:T),S=-s[0]*M,z=-s[1]*k;let b=mn(F,w,x),P=mn(C,y,E);if(i){let R=0,A=0;c&&$<0?R=Ke(p+$+S,i[0][0]):!c&&$>0&&(R=qe(p+F+S,i[1][0])),l&&T<0?A=Ke(v+T+z,i[0][1]):!l&&T>0&&(A=qe(v+C+z,i[1][1])),b=Math.max(b,R),P=Math.max(P,A)}if(a){let R=0,A=0;c&&$>0?R=qe(p+$,a[0][0]):!c&&$<0&&(R=Ke(p+F,a[1][0])),l&&T>0?A=qe(v+T,a[0][1]):!l&&T<0&&(A=Ke(v+C,a[1][1])),b=Math.max(b,R),P=Math.max(P,A)}if(o){if(d){const R=mn(F/I,y,E)*I;if(b=Math.max(b,R),i){let A=0;!c&&!l||c&&!l&&f?A=qe(v+z+F/I,i[1][1])*I:A=Ke(v+z+(c?$:-$)/I,i[0][1])*I,b=Math.max(b,A)}if(a){let A=0;!c&&!l||c&&!l&&f?A=Ke(v+F/I,a[1][1])*I:A=qe(v+(c?$:-$)/I,a[0][1])*I,b=Math.max(b,A)}}if(u){const R=mn(C*I,w,x)/I;if(P=Math.max(P,R),i){let A=0;!c&&!l||l&&!c&&f?A=qe(p+C*I+S,i[1][0])/I:A=Ke(p+(l?T:-T)*I+S,i[0][0])/I,P=Math.max(P,A)}if(a){let A=0;!c&&!l||l&&!c&&f?A=Ke(p+C*I,a[1][0])/I:A=qe(p+(l?T:-T)*I,a[0][0])/I,P=Math.max(P,A)}}}T=T+(T<0?P:-P),$=$+($<0?b:-b),o&&(f?F>C*I?T=(Bo(c,l)?-$:$)/I:$=(Bo(c,l)?-T:T)*I:d?(T=$/I,l=c):($=T*I,c=l));const N=c?p+$:p,D=l?v+T:v;return{width:M+(c?-$:$),height:k+(l?-T:T),x:s[0]*$*(c?-1:1)+N,y:s[1]*T*(l?-1:1)+D}}const Ci={width:0,height:0,x:0,y:0},Zf={...Ci,pointerX:0,pointerY:0,aspectRatio:1};function Qf(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 Jf({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const s=Se(e);let i={controlDirection:Vo("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={...Ci},E={...Zf};i={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Vo(l)};let p,v=null,M=[],k,I,$,T=!1;const F=zs().on("start",C=>{const{nodeLookup:S,transform:z,snapGrid:b,snapToGrid:P,nodeOrigin:N,paneDomNode:D}=n();if(p=S.get(t),!p)return;v=(D==null?void 0:D.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:A}=Ht(C.sourceEvent,{transform:z,snapGrid:b,snapToGrid:P,containerBounds:v});y={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},E={...y,pointerX:R,pointerY:A,aspectRatio:y.width/y.height},k=void 0,I=lt(p.extent)?p.extent:void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(k=S.get(p.parentId)),k&&p.extent==="parent"&&(I=[[0,0],[k.measured.width,k.measured.height]]),M=[],$=void 0;for(const[B,O]of S)if(O.parentId===t&&(M.push({id:B,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const V=Qf(O,p,O.origin??N);$?$=[[Math.min(V[0][0],$[0][0]),Math.min(V[0][1],$[0][1])],[Math.max(V[1][0],$[1][0]),Math.max(V[1][1],$[1][1])]]:$=V}h==null||h(C,{...y})}).on("drag",C=>{const{transform:S,snapGrid:z,snapToGrid:b,nodeOrigin:P}=n(),N=Ht(C.sourceEvent,{transform:S,snapGrid:z,snapToGrid:b,containerBounds:v}),D=[];if(!p)return;const{x:R,y:A,width:B,height:O}=y,V={},X=p.origin??P,{width:K,height:te,x:ne,y:J}=Uf(E,i.controlDirection,N,i.boundaries,i.keepAspectRatio,X,I,$),H=K!==B,Y=te!==O,U=ne!==R&&H,ee=J!==A&&Y;if(!U&&!ee&&!H&&!Y)return;if((U||ee||X[0]===1||X[1]===1)&&(V.x=U?ne:y.x,V.y=ee?J:y.y,y.x=V.x,y.y=V.y,M.length>0)){const ie=ne-R,se=J-A;for(const ce of M)ce.position={x:ce.position.x-ie+X[0]*(K-B),y:ce.position.y-se+X[1]*(te-O)},D.push(ce)}if((H||Y)&&(V.width=H&&(!i.resizeDirection||i.resizeDirection==="horizontal")?K:y.width,V.height=Y&&(!i.resizeDirection||i.resizeDirection==="vertical")?te:y.height,y.width=V.width,y.height=V.height),k&&p.expandParent){const ie=X[0]*(V.width??0);V.x&&V.x<ie&&(y.x=ie,E.x=E.x-(V.x-ie));const se=X[1]*(V.height??0);V.y&&V.y<se&&(y.y=se,E.y=E.y-(V.y-se))}const W=Gf({width:y.width,prevWidth:B,height:y.height,prevHeight:O,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),Z={...y,direction:W};(x==null?void 0:x(C,Z))!==!1&&(T=!0,g==null||g(C,Z),r(V,D))}).on("end",C=>{T&&(w==null||w(C,{...y}),o==null||o({...y}),T=!1)});s.call(F)}function c(){s.on(".drag",null)}return{update:a,destroy:c}}var Ai={exports:{}},$i={},Ii={exports:{}},Pi={};/**
3
3
  * @license React
4
4
  * use-sync-external-store-shim.production.js
5
5
  *
@@ -24,4 +24,4 @@ import{r as _,l as Xa,R as Ka,j as m,u as Ze,m as qa,I as Ga,d as Ua,f as Za,n a
24
24
  M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}fa.displayName="MiniMap";_.memo(fa);const Hp=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Op={[Mt.Line]:"right",[Mt.Handle]:"bottom-right"};function Vp({nodeId:e,position:t,variant:n=Mt.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=Fi(),p=typeof e=="string"?e:E,v=ue(),M=_.useRef(null),k=n===Mt.Handle,I=ae(_.useCallback(Hp(k&&h),[k,h]),le),$=_.useRef(null),T=t??Op[n];_.useEffect(()=>{if(!(!M.current||!p))return $.current||($.current=Jf({domNode:M.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:C,transform:S,snapGrid:z,snapToGrid:b,nodeOrigin:P,domNode:N}=v.getState();return{nodeLookup:C,transform:S,snapGrid:z,snapToGrid:b,nodeOrigin:P,paneDomNode:N}},onChange:(C,S)=>{const{triggerNodeChanges:z,nodeLookup:b,parentLookup:P,nodeOrigin:N}=v.getState(),D=[],R={x:C.x,y:C.y},A=b.get(p);if(A&&A.expandParent&&A.parentId){const B=A.origin??N,O=C.width??A.measured.width??0,V=C.height??A.measured.height??0,X={id:A.id,parentId:A.parentId,rect:{width:O,height:V,...ui({x:C.x??A.position.x,y:C.y??A.position.y},{width:O,height:V},A.parentId,b,B)}},K=Qr([X],b,P,N);D.push(...K),R.x=C.x?Math.max(B[0]*O,C.x):void 0,R.y=C.y?Math.max(B[1]*V,C.y):void 0}if(R.x!==void 0&&R.y!==void 0){const B={id:p,type:"position",position:{...R}};D.push(B)}if(C.width!==void 0&&C.height!==void 0){const O={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:C.width,height:C.height}};D.push(O)}for(const B of S){const O={...B,type:"position"};D.push(O)}z(D)},onEnd:({width:C,height:S})=>{const z={id:p,type:"dimensions",resizing:!1,dimensions:{width:C,height:S}};v.getState().triggerNodeChanges([z])}})),$.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 C;(C=$.current)==null||C.destroy()}},[T,a,c,l,d,u,w,x,y,g]);const F=T.split("-");return m.jsx("div",{className:he(["react-flow__resize-control","nodrag",...F,n,r]),ref:M,style:{...o,scale:I,...i&&{[k?"backgroundColor":"borderColor"]:i}},children:s})}_.memo(Vp);function Bp(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 Fp=4,hs={isConnectable:!1,isConnectableStart:!1,isConnectableEnd:!1,style:{pointerEvents:"none"},"aria-hidden":!0};function Wp({data:e}){const t=Ze(),n=[...new Map((e.editors||[]).map(s=>[s.id,s])).values()];if(n.length===0)return null;const r=n.slice(0,Fp),o=n.length-r.length;return m.jsxs("span",{className:"node-editors","data-tip":t("specNode.liveEditors",{n:n.length}),children:[r.map(s=>m.jsx(tc,{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&&m.jsxs("span",{className:"av-more","data-tip":t("specNode.more",{n:o}),children:["+",o]})]})}function Yp({summary:e,t}){return e!=null&&e.open?m.jsxs("span",{className:"issue-badge","data-tip":t("specNode.openIssues",{n:e.open}),children:["◆",e.open]}):null}function Xp({data:e,selected:t}){var u,f;const n=Ze(),r=st[e.status]||st.pending,o=Bp(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 m.jsxs("div",{className:d,style:i?{"--ov":xr(i.seed)}:void 0,children:[m.jsx(Ct,{type:"target",position:Q.Left,...hs}),m.jsxs("div",{className:"node-row1",children:[m.jsx("span",{className:"node-dot",style:{background:r.color},children:e.status==="active"&&m.jsx("span",{className:"pulse",style:{background:r.color}})}),m.jsx("span",{className:"node-title",children:e.title}),l.length>0?m.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=>m.jsx("span",{className:`ov-mark ov-${h}`,children:_s[h]},h))}):o?m.jsx("span",{className:"node-ago",children:o}):null]}),m.jsxs("div",{className:"node-row2",children:[m.jsx("span",{className:"node-ver",children:e.version?`v${e.version}`:""}),e.drift>0&&m.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]}),m.jsx(Yp,{summary:(u=e.reviewSummary)==null?void 0:u.issues,t:n}),m.jsx(oc,{summary:(f=e.reviewSummary)==null?void 0:f.evals}),m.jsx(Wp,{data:e})]}),e.collapsed&&m.jsxs("span",{className:"node-expand","data-tip":n("specNode.expandable",{n:e.childCount}),children:["▸",e.childCount]}),m.jsx(Ct,{type:"source",position:Q.Right,...hs})]})}const wn=8;function Kp({x:e,y:t,anchorKey:n,label:r,children:o}){const s=_.useRef(null),[i,a]=_.useState({left:e,top:t,visibility:"hidden"});return _.useLayoutEffect(()=>{var l;const c=(l=s.current)==null?void 0:l.getBoundingClientRect();c&&a({left:Math.max(wn,Math.min(e,window.innerWidth-c.width-wn)),top:Math.max(wn,Math.min(t,window.innerHeight-c.height-wn)),visibility:"visible"})},[e,t,n]),m.jsx("div",{ref:s,className:"sess-menu",role:"menu","aria-label":r,style:i,onClick:c=>c.stopPropagation(),onMouseDownCapture:qa,children:o})}function gr({children:e}){return m.jsx("div",{className:"sess-menu-group",role:"group",children:e})}function gs(){return m.jsx("div",{className:"sess-menu-sep",role:"separator"})}function jt({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 m.jsxs("button",{type:"button",role:"menuitem",className:i,...s,children:[m.jsx("span",{className:"sess-menu-icon",children:t??m.jsx(Ga,{name:e,size:14,className:"sess-menu-svg"})}),m.jsx("span",{className:"sess-menu-label",children:o})]})}function qp({menu:e,onClose:t,onInfo:n,onFresh:r,onNewChild:o,onDelete:s,sessions:i=[],onOpenSession:a}){const c=Ze();if(_.useEffect(()=>{if(e)return window.addEventListener("click",t),window.addEventListener("contextmenu",t,!0),()=>{window.removeEventListener("click",t),window.removeEventListener("contextmenu",t,!0)}},[e,t]),sc(!!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 m.jsxs(Kp,{x:e.x,y:e.y,anchorKey:e.id,label:c("nodeMenu.menuLabel"),children:[m.jsxs(gr,{children:[m.jsx(jt,{icon:"info",onClick:l(n),children:c("nodeMenu.info")}),m.jsx(jt,{icon:"sessions",onClick:l(r),children:c("nodeMenu.newSession")}),m.jsx(jt,{icon:"plus",onClick:l(o),children:c("nodeMenu.newChild")})]}),m.jsx(gs,{}),m.jsx(gr,{children:m.jsx(jt,{icon:"trash",danger:!0,onClick:l(s),children:c("nodeMenu.del")})}),i.length>0&&m.jsxs(m.Fragment,{children:[m.jsx(gs,{}),m.jsx(gr,{children:i.map(u=>m.jsx(jt,{className:"sess-menu-sess",leading:m.jsx("span",{className:"sess-glyph",style:{color:wr[u.status]},"aria-hidden":"true",children:ic[u.status]}),onClick:d(u.id),children:Tr(u)},u.id))})]})]})}const Gp=new Set(["=","_","I","H","J","K","L"]),Up=(()=>{const e=[];for(const t of wc){const n=Es(t.id).filter(o=>!Gp.has(o)).map(vr),r=e[e.length-1];r&&r.desc===t.desc?r.keys.push(...n):e.push({desc:t.desc,keys:n})}return e})(),Zp=[[["←","→","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"]],Qp=["merged","active","drift","pending"],Jp=["added","edited","deleted","moved"];function em({t:e}){return m.jsxs("section",{className:"legend-sec",children:[m.jsx("div",{className:"legend-h",children:e("legend.secBoard")}),Up.map(t=>m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:"keymap-keys",children:t.keys.map((n,r)=>m.jsx("kbd",{children:n},r))}),m.jsx("span",{className:"legend-desc",children:e(t.desc)})]},t.desc))]})}function tm({title:e,rows:t,t:n}){return m.jsxs("section",{className:"legend-sec",children:[m.jsx("div",{className:"legend-h",children:e}),t.map(([r,o])=>m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:"keymap-keys",children:r.map((s,i)=>m.jsx("kbd",{children:s},i))}),m.jsx("span",{className:"legend-desc",children:n(o)})]},o))]})}function nm({onClose:e}){const t=Ze();return m.jsxs(xc,{title:t("legend.title"),closeLabel:t("legend.close"),onClose:e,children:[m.jsx(em,{t}),m.jsx(tm,{title:t("legend.secPopup"),rows:Zp,t}),m.jsxs("section",{className:"legend-sec",children:[m.jsx("div",{className:"legend-h",children:t("legend.secStatus")}),Qp.map(n=>m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:"node-dot",style:{background:st[n].color},children:n==="active"&&m.jsx("span",{className:"pulse",style:{background:st[n].color}})}),m.jsx("span",{className:"legend-name",children:t(`status.${n}`)}),m.jsx("span",{className:"legend-desc",children:t(`legend.statusRows.${n}`)})]},n))]}),m.jsxs("section",{className:"legend-sec",children:[m.jsxs("div",{className:"legend-h",children:[t("legend.secOp")," ",m.jsx("span",{className:"legend-sub",children:t("legend.secOpSub")})]}),Jp.map(n=>m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:`ov-mark ov-${n}`,children:_s[n]}),m.jsx("span",{className:"legend-desc",children:t(`legend.opRows.${n}`)})]},n))]}),m.jsxs("section",{className:"legend-sec",children:[m.jsx("div",{className:"legend-h",children:t("legend.secBadges")}),m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:"drift-badge",children:"⚠N"}),m.jsx("span",{className:"legend-desc",children:t("legend.badgeDrift")})]}),m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:"legend-glyph legend-ver",children:"vN"}),m.jsx("span",{className:"legend-desc",children:t("legend.badgeVer")})]})]}),m.jsxs("section",{className:"legend-sec",children:[m.jsx("div",{className:"legend-h",children:t("legend.secRing")}),m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:"legend-ring ring-dashed"}),m.jsx("span",{className:"legend-desc",children:t("legend.ringDashed")})]}),m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:"legend-ring ring-solid"}),m.jsx("span",{className:"legend-desc",children:t("legend.ringSolid")})]}),m.jsxs("div",{className:"legend-row",children:[m.jsx("span",{className:"legend-ring ring-ghost"}),m.jsx("span",{className:"legend-desc",children:t("legend.ringGhost")})]})]})]})}const ha=8,rm=5,om=2.2,sm=1,im=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"]),ga="\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\u3040-\\u30ff",am=new RegExp(`[a-z0-9]+|[${ga}]`,"g"),cm=new RegExp(`[${ga}]`);function pa(e){return cm.test(e)}function ma(e){return e.toLowerCase().match(am)??[]}function lm(e){const t=new Set;for(const n of ma(e))(pa(n)||n.length>1&&!im.has(n))&&t.add(n);return[...t]}function pr(e){return ma(e)}function eo(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 um(e,t){return t.startsWith(eo(e))}function Tn(e,t){return t.startsWith(eo(e))||t.length>=3&&e.startsWith(t)}const dm=.5;function fm(e,t){const n=eo(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(dm,r):0}const ps=1.2,ms=.4;function ys(e,t,n){return e<=0?0:e*(ps+1)/(e+ps*(1-ms+ms*t/(n||1)))}function hm(e,t,n,r){const o=fm(e,t);if(o>0)return ha*o;if(t.name.includes(e))return rm;if(t.descWords.some(i=>Tn(e,i)))return om*ys(1,t.descWords.length,r);const s=t.bodyWords.reduce((i,a)=>i+(Tn(e,a)?1:0),0);return sm*ys(s,t.bodyWords.length,n)}function gm(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=pa(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 pm(e,t,n={}){const r=n.limit??10,o=lm(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=>um(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(hm(h,u,a,c)*l[h],ha);f<=0||d.push({ref:u.ref,score:Math.round(f*100)/100,snippet:gm(u.snippetText,u.desc,o)})}return d.sort((u,f)=>f.score-u.score),d.slice(0,r)}let mr=null;function mm(e=!0){const[t,n]=_.useState(mr),r=_.useRef(!1);return _.useEffect(()=>{!e||r.current||(r.current=!0,fetch(Ua("/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 ym={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$/,""),xs=["spec","session","issue","scenario"],xm=e=>e?[e,...xs.filter(t=>t!==e)]:xs,wm=new Set(["issue","scenario"]);function vm(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:cc(d.id),color:(st[d.status]||st.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:lc(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===uc.RESULT;i.push({kind:"scenario",key:`scenario:${d.node}:${d.scenario}`,target:d.scenario,nodeId:d.node,address:f?lo(d.node,d.scenario):lo(d.node),color:ym[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 dc(t)){const u=Tr(d),f=fc(d),h=d.status||d.promptPreview||d.note||"";i.push({kind:"session",key:`session:${d.id}`,target:d.id,address:hc(d.id),color:wr[d.status]||wr.offline,title:u,sub:h,name:u||"",desc:d.status||"",body:`${d.promptPreview||d.note||""} ${f}`.trim()})}return i}function bm(e,t,n){const r=Object.fromEntries(n.map((a,c)=>[a,c])),o=(a,c)=>r[a.kind]-r[c.kind];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]=wm.has(a)?c.slice(0,15):pm(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 _m({specs:e,sessions:t,onPick:n,onClose:r,boost:o=null}){var F,C;const s=Ze(),i=mm(),[a,c]=_.useState(""),[l,d]=_.useState("");_.useEffect(()=>{if(!a.trim()){d(a);return}const S=setTimeout(()=>d(a),120);return()=>clearTimeout(S)},[a]);const[u,f]=_.useState(0),h=_.useRef(null),g=_.useRef(null),w=_.useMemo(()=>xm(o),[o]),x=`is:issue${l.trim()?` ${l.trim()}`:""}`,y=`is:eval${l.trim()?` ${l.trim()}`:""}`,E=co("issues",x,1,{pollMs:0}),p=co("evals",y,1,{pollMs:0}),v=((F=E.data)==null?void 0:F.items)||[],M=((C=p.data)==null?void 0:C.items)||[],k=_.useMemo(()=>vm(e,t,i,v,M),[e,t,i,E.data,p.data]),I=_.useMemo(()=>bm(k,l,w),[k,l,w]);_.useEffect(()=>{var S;(S=h.current)==null||S.focus()},[]),_.useEffect(()=>{f(0)},[a]),_.useEffect(()=>{var S,z;(z=(S=g.current)==null?void 0:S.querySelector(".search-item.on"))==null||z.scrollIntoView({block:"nearest"})},[u,I]);const $=S=>{S&&(n(S),r())},T=S=>{S.key==="ArrowDown"?(S.preventDefault(),f(z=>Math.min(I.length-1,z+1))):S.key==="ArrowUp"?(S.preventDefault(),f(z=>Math.max(0,z-1))):S.key==="Enter"?(S.preventDefault(),$(I[u])):S.key==="Escape"&&(S.preventDefault(),r())};return m.jsx("div",{className:"search-backdrop","data-focus-overlay":!0,onClick:r,children:m.jsxs("div",{className:"search-panel",role:"dialog","aria-modal":"true","aria-label":s("search.title"),onClick:S=>S.stopPropagation(),children:[m.jsxs("div",{className:"search-bar",children:[m.jsx("span",{className:"search-icon",children:"⌕"}),m.jsx("input",{ref:h,className:"search-input",value:a,placeholder:s("search.placeholder"),onChange:S=>c(S.target.value),onKeyDown:T})]}),m.jsxs("ul",{className:"search-results",ref:g,children:[I.length===0&&m.jsx("li",{className:"search-empty",children:s("search.empty")}),I.map((S,z)=>m.jsxs("li",{className:`search-item${z===u?" on":""}`,"data-kind":S.kind,"data-target":S.target,onMouseEnter:()=>f(z),onClick:()=>$(S),children:[m.jsx("span",{className:"node-dot",style:{background:S.color}}),m.jsx("span",{className:`search-kind k-${S.kind}`,children:s(`search.kind.${S.kind}`)}),m.jsx("span",{className:"search-title",children:S.title||S.target}),m.jsx(ac,{tags:S.tags}),m.jsx("span",{className:"search-path",children:S.sub})]},S.key))]}),m.jsx("div",{className:"search-foot",children:s("search.hint")})]})})}function ya(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 Em=["merged","active","drift","pending"],Nm=[{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 Sm(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 vn({count:e,ids:t,focusId:n,onJump:r,title:o,cls:s="",children:i}){const a=t.length>0;return m.jsxs("button",{type:"button",className:`bstat ${s}`.trim(),disabled:!a,"data-tip":o,"aria-label":o,onClick:a?()=>r(ya(t,n)):void 0,children:[i,e]})}function Mm({specs:e,focusId:t,onJump:n}){const r=Ze(),o=_.useMemo(()=>Sm(e),[e]),s=i=>i&&(n==null?void 0:n(i));return m.jsxs("div",{className:"graph-stats",role:"group","aria-label":r("stats.aria"),children:[m.jsx("span",{className:"bstat-total","data-tip":r("stats.totalTitle",{n:o.total}),children:o.total}),Em.map(i=>m.jsx(vn,{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:m.jsx("span",{className:"bstat-dot",style:{background:st[i].color}})},i)),m.jsx("span",{className:"bstat-sep"}),m.jsx(vn,{count:o.driftIds.length,ids:o.driftIds,focusId:t,onJump:s,cls:"bstat-drift",title:r("stats.driftTitle",{n:o.driftIds.length}),children:"⚠"}),m.jsx(vn,{count:o.issueCount,ids:o.issueIds,focusId:t,onJump:s,cls:"bstat-issue",title:r("stats.issueTitle",{n:o.issueCount}),children:"◆"}),m.jsx("span",{className:"bstat-sep"}),Nm.map(({state:i,always:a,titleKey:c})=>{const l=o.scoreCount[i],d=o.scoreNodes[i];return!l&&!a?null:m.jsx(vn,{count:l,ids:d,focusId:t,onJump:s,title:r(`stats.${c}`,{n:l}),children:m.jsx(gc,{state:i})},i)})]})}function ws(){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 km(e){return e>1}function Cm(e){return{next:vr((e("graph.cycle")||[])[0]||"o"),prev:vr((e("graph.cycleRev")||[])[0]||"O")}}const Am=_.lazy(()=>Rn(()=>import("./SessionInterface-Dl9v0JFM.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),$m=_.lazy(()=>Rn(()=>import("./EvalsPage-Bz-nMKoS.js"),__vite__mapDeps([13,1,2,6,7,3]))),Im=_.lazy(()=>Rn(()=>import("./IssuesPage-CAP64YWE.js"),__vite__mapDeps([14,1,2,3,6,7]))),Pm=_.lazy(()=>Rn(()=>import("./Settings-BZ1lGRJs.js"),__vite__mapDeps([15,1,2,11,7,4]))),jm={spec:Xp},Dm=[.5,.5],vs={width:176,height:50},Tm=[{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}],bs=e=>Math.max(.4,Math.min(1.6,e)),Lt={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: `},xa=Object.keys(Lt),Rm=new Set(xa.map(e=>e[0]));function Dt({active:e,warm:t=!1,className:n,children:r}){const o=Ze();return!t&&!e?null:m.jsx("div",{className:n?`page-pane ${n}`:"page-pane",style:e?void 0:{display:"none"},children:m.jsx(_.Suspense,{fallback:m.jsx("div",{className:"loading",children:o("hud.loading")}),children:r})})}function Lm({specs:e,sessions:t,issuesStamp:n,reload:r,identity:o,catalog:s,boardLive:i}){const a=(o==null?void 0:o.title)||"",{page:c,param:l}=Za(),[d,u]=_.useState(()=>c==="sessions");_.useEffect(()=>{c==="sessions"&&u(!0)},[c]);const[f,h]=_.useState(()=>{var q;let L=null;try{L=sessionStorage.getItem("spex.focus")}catch{}return(L&&e.some(G=>G.id===L)?L:null)||((q=e.find(G=>!G.parent))==null?void 0:q.id)});_.useEffect(()=>{try{f&&sessionStorage.setItem("spex.focus",f)}catch{}},[f]);const[g,w]=_.useState(!1),[x,y]=_.useState("spec"),[E,p]=_.useState(!1),[v,M]=_.useState(null),[k,I]=_.useState("new"),[$,T]=_.useState(null),[F,C]=_.useState(null),[S,z]=_.useState(null),{getViewport:b,setViewport:P}=qn(),N=Ze(),D=_.useRef(null),R=_.useRef(0),A=_.useRef({buf:"",timer:0}),[B,O]=_.useState(!1),V=_.useRef(!1);V.current=B;const X=_.useRef({x:-1,y:-1}),K=_.useMemo(()=>ws(),[]),te=_.useMemo(()=>ws(),[]),ne=_.useMemo(()=>Object.fromEntries(e.map(L=>[L.id,L])),[e]),J=ne[f]||e.find(L=>!L.parent)||e[0],H=_.useMemo(()=>{const L=new Set;for(let q=J;q;q=q.parent?ne[q.parent]:null)L.add(q.id);return L},[J,ne]),Y=_.useMemo(()=>vc(e,H),[e,H]),U=_.useMemo(()=>e.filter(L=>Y[L.id]).map(L=>({...L,...Y[L.id]})),[e,Y]),ee=_.useMemo(()=>Object.fromEntries(U.map(L=>[L.id,L])),[U]),W=ee[J.id],Z=_.useMemo(()=>{const L={};return e.forEach(q=>{q.parent&&(L[q.parent]=(L[q.parent]||0)+1)}),L},[e]),re=_.useMemo(()=>e.filter(L=>{var q;return(q=L.overlays)==null?void 0:q.length}),[e]),ie=_.useMemo(()=>$?t.find(L=>L.source===$):null,[t,$]),se=_.useMemo(()=>$?e.filter(L=>(L.overlays||[]).some(q=>q.source===$)):[],[e,$]),ce=_.useMemo(()=>$?se:re,[$,se,re]),xe=Cm(Es),be=_.useCallback(L=>L?t.filter(q=>{var G;return(G=q.ops)==null?void 0:G.some(oe=>oe.nodeId===L.id)}):[],[t]),ge=_.useCallback(L=>{I(L),ke("sessions",L)},[]),me=_.useCallback(L=>{I("new"),C(L),ke("sessions","new")},[]),Xe=_.useCallback(L=>{pc(L,{onFocusNode:h,onOpenSession:ge})},[ge]),Oe=_.useMemo(()=>{var G;if(!S)return[];const L=e.find(oe=>oe.id===S.id);return(G=L==null?void 0:L.overlays)!=null&&G.length?[...new Set(L.overlays.map(oe=>oe.source))].map(oe=>t.find(de=>de.source===oe)).filter(Boolean):[]},[S,e,t]),Ve=_.useCallback(L=>{Xe(L.address)},[Xe]);_.useLayoutEffect(()=>{if(c!=="sessions"||!l)return;const L=l.split("/")[0];L&&L!==k&&I(L)},[c,l]),_.useEffect(()=>{c==="sessions"&&ke("sessions",k,{replace:!0})},[c,k]),_.useEffect(()=>{c!=="graph"&&(w(!1),p(!1),M(null),z(null))},[c]);const we=_.useMemo(()=>U.filter(L=>L.parent===W.id),[U,W]),_e=W.parent?ee[W.parent]:null,Ee=_.useMemo(()=>we.length?we.reduce((L,q)=>Math.abs(q.y-W.y)<Math.abs(L.y-W.y)?q:L):null,[we,W]),Ce=_.useMemo(()=>{if(Ee)return Ee;let L=null,q=1/0;for(const G of U){const oe=G.x-W.x;if(oe<=0)continue;const de=G.y-W.y,j=(oe/bc)**2+(de/_c)**2;j<q&&(q=j,L=G)}return L},[Ee,U,W]),dt=_.useCallback(L=>{let q=null;for(const G of U){if(G.id===W.id||G.x!==W.x)continue;const oe=G.y-W.y;(L==="down"?oe<=0:oe>=0)||(!q||Math.abs(oe)<Math.abs(q.y-W.y))&&(q=G)}return q},[U,W]),Qe=_.useMemo(()=>dt("down"),[dt]),$t=_.useMemo(()=>dt("up"),[dt]),Zn=_.useMemo(()=>U.map(L=>{const q=L.id===f||L.id===W.parent||L.parent===f||L.parent===W.parent;let G;$&&se.length?G=(L.overlays||[]).some(pe=>pe.source===$)?"ov-hot":"ov-dim":G=q?void 0:"is-far";const de=be(L).map(pe=>({id:pe.id,status:pe.status,node:pe.node})),j=Z[L.id]||0,ye={editors:de,collapsed:j>0&&!H.has(L.id),childCount:j};return{id:L.id,type:"spec",position:{x:L.x,y:L.y},data:{...L,...ye},initialWidth:vs.width,initialHeight:vs.height,handles:Tm,draggable:!1,selected:L.id===f,className:G}}),[f,W.parent,$,se,U,be,Z,H]),Qn=_.useMemo(()=>{const L=U.filter(G=>G.parent).map(G=>{const oe=G.id===f||G.parent===f;return{id:`${G.parent}-${G.id}`,source:G.parent,target:G.id,type:"smoothstep",style:{stroke:oe?"var(--blue)":"var(--line)",strokeWidth:oe?2:1},zIndex:oe?1:0}}),q=[];for(const G of U){const oe=(G.overlays||[]).find(j=>j.op==="moved"&&j.toParent&&ee[j.toParent]);if(!oe)continue;const de=xr(oe.seed);q.push({id:`move-${G.id}-${oe.toParent}`,source:G.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:Xt.ArrowClosed,color:de,width:14,height:14}})}return[...L,...q]},[f,U,ee]),tn=_.useCallback((L,q)=>{const G=b(),oe=performance.now();cancelAnimationFrame(R.current);const de=j=>{const ye=q?Math.min(1,(j-oe)/q):1,pe=1-Math.pow(1-ye,3);P({x:G.x+(L.x-G.x)*pe,y:G.y+(L.y-G.y)*pe,zoom:G.zoom+(L.zoom-G.zoom)*pe}),ye<1&&(R.current=requestAnimationFrame(de))};R.current=requestAnimationFrame(de)},[b,P]),Re=_.useCallback((L,q,G=300)=>{const oe=D.current;if(!oe)return;const de=q??b().zoom;tn({x:oe.clientWidth/2-L.x*de,y:oe.clientHeight/2-L.y*de,zoom:de},G)},[tn,b]),nn=_.useRef(!1);_.useEffect(()=>{if(nn.current||c!=="graph")return;const L=requestAnimationFrame(()=>{nn.current=!0,Re(W,void 0,0)});return()=>cancelAnimationFrame(L)},[Re,W,c]);const Je=_.useRef(W);Je.current=W;const rn=_.useRef(Re);rn.current=Re;const on=_.useRef(!1),et=_.useRef(!1),ft=_.useRef(null);_.useEffect(()=>{if(c==="graph"){if(!on.current){on.current=!0,ft.current=f;return}if(et.current){et.current=!1,ft.current=f;return}ft.current!==f&&(ft.current=f,rn.current(Je.current))}},[f,c]);const ht=g||E||!!v,sn=_.useRef(ht);_.useEffect(()=>{sn.current&&!ht&&Qa(),sn.current=ht},[ht]),_.useEffect(()=>{const L=mc(W).map(j=>j.key),q=j=>y(ye=>{const pe=L.indexOf(ye);return L[((pe<0?0:pe)+j+L.length)%L.length]}),G=(j,ye)=>{j&&(ye.preventDefault(),ye.stopPropagation(),O(!0),h(j.id))},oe=j=>K(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 ye,pe,gt,cn;if(j.altKey&&!j.metaKey&&!j.ctrlKey){const Ae={Digit1:"graph",Digit2:"sessions",Digit3:"evals",Digit4:"issues",Digit5:"settings"}[j.code];if(Ae){j.preventDefault(),j.stopPropagation(),M(null),ke(Ae);return}if(j.code==="KeyN"){j.preventDefault(),j.stopPropagation(),M(null),I("new"),ke("sessions","new");return}if(j.code==="KeyF"){j.preventDefault(),j.stopPropagation(),M(null),ke("evals");return}}if(v){j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),M(null));return}if(j.altKey&&!j.metaKey&&!j.ctrlKey&&j.code==="Slash"){j.preventDefault(),j.stopPropagation(),M("sessions");return}if(!(j.metaKey||j.ctrlKey||j.altKey)&&!((j.key==="Enter"||j.key===" ")&&((pe=(ye=j.target)==null?void 0:ye.closest)!=null&&pe.call(ye,"button, a[href], input, select, textarea, summary")))&&c!=="sessions"&&!(c==="evals"||c==="issues")){if(c==="settings"){fe("graph.settings",j.key)&&(j.preventDefault(),j.stopPropagation(),ke("graph"));return}if(g){const Ne=j.key==="Escape"?null:(cn=(gt=j.target)==null?void 0:gt.closest)==null?void 0:cn.call(gt,'input, textarea, select, [role="menu"], [role="menuitemradio"], [aria-haspopup="menu"]');if(Ne!=null&&Ne.closest("[data-focus-overlay]"))return;if(j.key==="Escape"){j.preventDefault(),w(!1);return}if(j.shiftKey){if(fe("nav.up",j.key))return G($t,j);if(fe("nav.down",j.key))return G(Qe,j);if(fe("nav.parent",j.key))return G(_e,j);if(fe("nav.child",j.key))return G(Ce,j)}if(j.key==="Tab"){j.preventDefault(),j.stopPropagation(),q(j.shiftKey?-1:1);return}if(j.key==="ArrowLeft"||j.key==="h"){j.preventDefault(),j.stopPropagation(),q(-1);return}if(j.key==="ArrowRight"||j.key==="l"){j.preventDefault(),j.stopPropagation(),q(1);return}if(/^[1-9]$/.test(j.key)&&+j.key<=L.length){j.preventDefault(),j.stopPropagation(),y(L[+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(E){if(j.key==="Escape"||j.key==="?"){j.preventDefault(),p(!1);return}if(j.key==="j"||j.key==="k"||j.key==="ArrowDown"||j.key==="ArrowUp"){j.preventDefault(),j.stopPropagation(),te(document.querySelector(".legend"),j.key==="j"||j.key==="ArrowDown"?120:-120);return}return}if(fe("graph.help",j.key)){j.preventDefault(),p(!0);return}if(j.key==="Escape"&&$){j.preventDefault(),j.stopPropagation(),T(null);return}if(fe("graph.settings",j.key)){j.preventDefault(),ke("settings");return}if(fe("graph.search",j.key)){j.preventDefault(),j.stopPropagation(),M("nodes");return}if(!j.metaKey&&!j.ctrlKey&&!j.altKey&&/^[a-zA-Z]$/.test(j.key)){const Ne=A.current;if(Ne.buf||Rm.has(j.key)){clearTimeout(Ne.timer);const Ae=Ne.buf+j.key;if(Lt[Ae]){j.preventDefault(),j.stopPropagation(),A.current={buf:"",timer:0},me(Lt[Ae](W.id));return}if(xa.some(nr=>nr.startsWith(Ae))){j.preventDefault(),j.stopPropagation(),A.current={buf:Ae,timer:setTimeout(()=>{A.current={buf:"",timer:0}},700)};return}A.current={buf:"",timer:0}}}if(fe("nav.up",j.key))return G($t,j);if(fe("nav.down",j.key))return G(Qe,j);if(fe("nav.parent",j.key))return G(_e,j);if(fe("nav.child",j.key))return G(Ce,j);if(fe("graph.zoomIn",j.key))j.preventDefault(),O(!0),Re(W,bs(b().zoom*1.2),160);else if(fe("graph.zoomOut",j.key))j.preventDefault(),O(!0),Re(W,bs(b().zoom/1.2),160);else if(fe("graph.zoomReset",j.key))j.preventDefault(),O(!0),Re(W,.85,200);else if(fe("graph.info",j.key))j.preventDefault(),w(!0);else if(fe("graph.cycle",j.key)||fe("graph.cycleRev",j.key)){if(j.preventDefault(),!ce.length)return;O(!0);const Ne=ya(ce,W.id,fe("graph.cycleRev",j.key)?-1:1,Ae=>Ae.id);Ne&&h(Ne.id)}else fe("graph.fresh",j.key)?(j.preventDefault(),me(`[[${W.id}]] `)):fe("graph.evals",j.key)&&(j.preventDefault(),ke("evals"))}};return window.addEventListener("keydown",de,!0),()=>window.removeEventListener("keydown",de,!0)},[g,c,E,v,$,W,ce,$t,Qe,Ce,_e,Re,b,ge,me,K,te]),_.useEffect(()=>{const L=q=>{const G=X.current,oe=q.clientX!==G.x||q.clientY!==G.y;G.x=q.clientX,G.y=q.clientY,oe&&V.current&&O(!1)};return window.addEventListener("mousemove",L,!0),()=>window.removeEventListener("mousemove",L,!0)},[]);const Jn=_.useCallback((L,q)=>{q.id!==Je.current.id&&(et.current=!0),h(q.id)},[]),er=_.useCallback((L,q)=>{q.id!==Je.current.id&&(et.current=!0),h(q.id),w(!0)},[]),tr=_.useCallback((L,q)=>{L.preventDefault(),q.id!==Je.current.id&&(et.current=!0),h(q.id),z({x:L.clientX,y:L.clientY,id:q.id})},[]),an=_.useCallback((L,q=!0)=>{const G=q&&$===L.source;if(T(G?null:L.source),G)return;const oe=new Set((L.ops||[]).map(j=>j.nodeId)),de=e.find(j=>oe.has(j.id));de&&h(de.id)},[$,e]);return m.jsxs("div",{className:B?"app kbd-mode":"app",children:[m.jsx(Ja,{}),m.jsx(ec,{page:c,identity:o,catalog:s}),m.jsxs("div",{className:"app-main",children:[m.jsx(Dt,{active:c==="graph",warm:!0,className:"page-graph",children:m.jsxs("div",{className:"graph",ref:D,children:[m.jsx(mp,{nodes:Zn,edges:Qn,nodeTypes:jm,onNodeClick:Jn,onNodeDoubleClick:er,onNodeContextMenu:tr,nodeOrigin:Dm,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesFocusable:!1,disableKeyboardA11y:!0,defaultViewport:{x:0,y:0,zoom:.85},minZoom:.4,maxZoom:1.6,proOptions:{hideAttribution:!0}}),m.jsxs("div",{className:"hud",children:[m.jsxs("span",{className:"brand",children:["$ ",a||"spec-dashboard"]}),m.jsx("button",{className:"hud-help",onClick:()=>p(L=>!L),"data-tip":N("hud.helpTitle"),children:"?"})]}),m.jsx(nc,{sessions:t,activeId:$,onPick:an,onOpenSession:ge}),m.jsx(Mm,{specs:e,focusId:f,onJump:h}),m.jsx(qp,{menu:S,onClose:()=>z(null),onInfo:()=>w(!0),onFresh:L=>me(`[[${L}]] `),onNewChild:L=>me(Lt.nn(L)),onDelete:L=>me(Lt.dd(L)),sessions:Oe,onOpenSession:ge}),ie&&m.jsxs("div",{className:"lock-hint",style:{"--ov":xr(ie.id)},children:[m.jsxs("span",{className:"lock-hint-lead",children:[m.jsx(rc,{})," ",Tr(ie)]}),se.length?m.jsx("span",{className:"lock-hint-body",children:km(se.length)?m.jsxs(m.Fragment,{children:[N("lockHint.cycleBefore"),m.jsx("kbd",{children:xe.next}),N("lockHint.cycleNext"),m.jsx("span",{className:"lock-hint-sep",children:" / "}),m.jsx("kbd",{children:xe.prev}),N("lockHint.cyclePrev"),N("lockHint.cycleAfter",{n:se.length})]}):N("lockHint.singleChanged")}):m.jsx("span",{className:"lock-hint-body",children:N("lockHint.empty")}),m.jsx("button",{className:"lock-hint-release",onClick:()=>T(null),"data-tip":N("lockHint.releaseTitle"),children:N("lockHint.release")})]}),E&&m.jsx(nm,{onClose:()=>p(!1)})]})}),g&&m.jsx(yc,{node:W,pane:x,setPane:y,sessions:t,onClose:()=>w(!1)},W.id),m.jsx(Dt,{active:c==="sessions",warm:d,className:"page-sessions",children:m.jsx(Am,{sessions:t,specs:e,focusNode:W,open:c==="sessions",searchOpen:!!v,sel:k,setSel:I,seed:F,onSeedConsumed:()=>C(null),onClose:()=>ke("graph"),onPickSession:an,onOpenSearch:()=>M("sessions"),boardLive:i,reload:r})}),m.jsx(Dt,{active:c==="evals",className:"page-evals",children:m.jsx($m,{specs:e,sessions:t,issuesStamp:n,reloadBoard:r,onOpenSession:ge,onFocusNode:L=>{h(L),ke("graph")}})}),m.jsx(Dt,{active:c==="issues",className:"page-issues",children:m.jsx(Im,{specs:e,sessions:t,issuesStamp:n,onOpenSession:ge,onFocusNode:L=>{h(L),ke("graph")}})}),m.jsx(Dt,{active:c==="settings",className:"page-settings",children:m.jsx(Pm,{})}),v&&m.jsx(_m,{specs:e,sessions:t,onPick:Ve,onClose:()=>M(null),boost:v==="sessions"?"session":null})]})]})}function zm(e){return m.jsx(la,{children:m.jsx(Lm,{...e})})}const Ym=Object.freeze(Object.defineProperty({__proto__:null,default:zm},Symbol.toStringTag,{value:"Module"}));export{Kp as C,Ym as D,gr as a,jt as b,gs 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=>um(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(hm(h,u,a,c)*l[h],ha);f<=0||d.push({ref:u.ref,score:Math.round(f*100)/100,snippet:gm(u.snippetText,u.desc,o)})}return d.sort((u,f)=>f.score-u.score),d.slice(0,r)}let mr=null;function mm(e=!0){const[t,n]=_.useState(mr),r=_.useRef(!1);return _.useEffect(()=>{!e||r.current||(r.current=!0,fetch(Ua("/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 ym={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$/,""),xs=["spec","session","issue","scenario"],xm=e=>e?[e,...xs.filter(t=>t!==e)]:xs,wm=new Set(["issue","scenario"]);function vm(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:cc(d.id),color:(st[d.status]||st.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:lc(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===uc.RESULT;i.push({kind:"scenario",key:`scenario:${d.node}:${d.scenario}`,target:d.scenario,nodeId:d.node,address:f?lo(d.node,d.scenario):lo(d.node),color:ym[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 dc(t)){const u=Tr(d),f=fc(d),h=d.status||d.promptPreview||d.note||"";i.push({kind:"session",key:`session:${d.id}`,target:d.id,address:hc(d.id),color:wr[d.status]||wr.offline,title:u,sub:h,name:u||"",desc:d.status||"",body:`${d.promptPreview||d.note||""} ${f}`.trim()})}return i}function bm(e,t,n){const r=Object.fromEntries(n.map((a,c)=>[a,c])),o=(a,c)=>r[a.kind]-r[c.kind];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]=wm.has(a)?c.slice(0,15):pm(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 _m({specs:e,sessions:t,onPick:n,onClose:r,boost:o=null}){var F,C;const s=Ze(),i=mm(),[a,c]=_.useState(""),[l,d]=_.useState("");_.useEffect(()=>{if(!a.trim()){d(a);return}const S=setTimeout(()=>d(a),120);return()=>clearTimeout(S)},[a]);const[u,f]=_.useState(0),h=_.useRef(null),g=_.useRef(null),w=_.useMemo(()=>xm(o),[o]),x=`is:issue${l.trim()?` ${l.trim()}`:""}`,y=`is:eval${l.trim()?` ${l.trim()}`:""}`,E=co("issues",x,1,{pollMs:0}),p=co("evals",y,1,{pollMs:0}),v=((F=E.data)==null?void 0:F.items)||[],M=((C=p.data)==null?void 0:C.items)||[],k=_.useMemo(()=>vm(e,t,i,v,M),[e,t,i,E.data,p.data]),I=_.useMemo(()=>bm(k,l,w),[k,l,w]);_.useEffect(()=>{var S;(S=h.current)==null||S.focus()},[]),_.useEffect(()=>{f(0)},[a]),_.useEffect(()=>{var S,z;(z=(S=g.current)==null?void 0:S.querySelector(".search-item.on"))==null||z.scrollIntoView({block:"nearest"})},[u,I]);const $=S=>{S&&(n(S),r())},T=S=>{S.key==="ArrowDown"?(S.preventDefault(),f(z=>Math.min(I.length-1,z+1))):S.key==="ArrowUp"?(S.preventDefault(),f(z=>Math.max(0,z-1))):S.key==="Enter"?(S.preventDefault(),$(I[u])):S.key==="Escape"&&(S.preventDefault(),r())};return m.jsx("div",{className:"search-backdrop","data-focus-overlay":!0,onClick:r,children:m.jsxs("div",{className:"search-panel",role:"dialog","aria-modal":"true","aria-label":s("search.title"),onClick:S=>S.stopPropagation(),children:[m.jsxs("div",{className:"search-bar",children:[m.jsx("span",{className:"search-icon",children:"⌕"}),m.jsx("input",{ref:h,className:"search-input",value:a,placeholder:s("search.placeholder"),onChange:S=>c(S.target.value),onKeyDown:T})]}),m.jsxs("ul",{className:"search-results",ref:g,children:[I.length===0&&m.jsx("li",{className:"search-empty",children:s("search.empty")}),I.map((S,z)=>m.jsxs("li",{className:`search-item${z===u?" on":""}`,"data-kind":S.kind,"data-target":S.target,onMouseEnter:()=>f(z),onClick:()=>$(S),children:[m.jsx("span",{className:"node-dot",style:{background:S.color}}),m.jsx("span",{className:`search-kind k-${S.kind}`,children:s(`search.kind.${S.kind}`)}),m.jsx("span",{className:"search-title",children:S.title||S.target}),m.jsx(ac,{tags:S.tags}),m.jsx("span",{className:"search-path",children:S.sub})]},S.key))]}),m.jsx("div",{className:"search-foot",children:s("search.hint")})]})})}function ya(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 Em=["merged","active","drift","pending"],Nm=[{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 Sm(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 vn({count:e,ids:t,focusId:n,onJump:r,title:o,cls:s="",children:i}){const a=t.length>0;return m.jsxs("button",{type:"button",className:`bstat ${s}`.trim(),disabled:!a,"data-tip":o,"aria-label":o,onClick:a?()=>r(ya(t,n)):void 0,children:[i,e]})}function Mm({specs:e,focusId:t,onJump:n}){const r=Ze(),o=_.useMemo(()=>Sm(e),[e]),s=i=>i&&(n==null?void 0:n(i));return m.jsxs("div",{className:"graph-stats",role:"group","aria-label":r("stats.aria"),children:[m.jsx("span",{className:"bstat-total","data-tip":r("stats.totalTitle",{n:o.total}),children:o.total}),Em.map(i=>m.jsx(vn,{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:m.jsx("span",{className:"bstat-dot",style:{background:st[i].color}})},i)),m.jsx("span",{className:"bstat-sep"}),m.jsx(vn,{count:o.driftIds.length,ids:o.driftIds,focusId:t,onJump:s,cls:"bstat-drift",title:r("stats.driftTitle",{n:o.driftIds.length}),children:"⚠"}),m.jsx(vn,{count:o.issueCount,ids:o.issueIds,focusId:t,onJump:s,cls:"bstat-issue",title:r("stats.issueTitle",{n:o.issueCount}),children:"◆"}),m.jsx("span",{className:"bstat-sep"}),Nm.map(({state:i,always:a,titleKey:c})=>{const l=o.scoreCount[i],d=o.scoreNodes[i];return!l&&!a?null:m.jsx(vn,{count:l,ids:d,focusId:t,onJump:s,title:r(`stats.${c}`,{n:l}),children:m.jsx(gc,{state:i})},i)})]})}function ws(){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 km(e){return e>1}function Cm(e){return{next:vr((e("graph.cycle")||[])[0]||"o"),prev:vr((e("graph.cycleRev")||[])[0]||"O")}}const Am=_.lazy(()=>Rn(()=>import("./SessionInterface-Bpie-9fs.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),$m=_.lazy(()=>Rn(()=>import("./EvalsPage-FixoOg_n.js"),__vite__mapDeps([13,1,2,6,7,3]))),Im=_.lazy(()=>Rn(()=>import("./IssuesPage-CuKLFhH3.js"),__vite__mapDeps([14,1,2,3,6,7]))),Pm=_.lazy(()=>Rn(()=>import("./Settings-C2MsucfE.js"),__vite__mapDeps([15,1,2,11,7,4]))),jm={spec:Xp},Dm=[.5,.5],vs={width:176,height:50},Tm=[{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}],bs=e=>Math.max(.4,Math.min(1.6,e)),Lt={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: `},xa=Object.keys(Lt),Rm=new Set(xa.map(e=>e[0]));function Dt({active:e,warm:t=!1,className:n,children:r}){const o=Ze();return!t&&!e?null:m.jsx("div",{className:n?`page-pane ${n}`:"page-pane",style:e?void 0:{display:"none"},children:m.jsx(_.Suspense,{fallback:m.jsx("div",{className:"loading",children:o("hud.loading")}),children:r})})}function Lm({specs:e,sessions:t,issuesStamp:n,reload:r,identity:o,catalog:s,boardLive:i}){const a=(o==null?void 0:o.title)||"",{page:c,param:l}=Za(),[d,u]=_.useState(()=>c==="sessions");_.useEffect(()=>{c==="sessions"&&u(!0)},[c]);const[f,h]=_.useState(()=>{var q;let L=null;try{L=sessionStorage.getItem("spex.focus")}catch{}return(L&&e.some(G=>G.id===L)?L:null)||((q=e.find(G=>!G.parent))==null?void 0:q.id)});_.useEffect(()=>{try{f&&sessionStorage.setItem("spex.focus",f)}catch{}},[f]);const[g,w]=_.useState(!1),[x,y]=_.useState("spec"),[E,p]=_.useState(!1),[v,M]=_.useState(null),[k,I]=_.useState("new"),[$,T]=_.useState(null),[F,C]=_.useState(null),[S,z]=_.useState(null),{getViewport:b,setViewport:P}=qn(),N=Ze(),D=_.useRef(null),R=_.useRef(0),A=_.useRef({buf:"",timer:0}),[B,O]=_.useState(!1),V=_.useRef(!1);V.current=B;const X=_.useRef({x:-1,y:-1}),K=_.useMemo(()=>ws(),[]),te=_.useMemo(()=>ws(),[]),ne=_.useMemo(()=>Object.fromEntries(e.map(L=>[L.id,L])),[e]),J=ne[f]||e.find(L=>!L.parent)||e[0],H=_.useMemo(()=>{const L=new Set;for(let q=J;q;q=q.parent?ne[q.parent]:null)L.add(q.id);return L},[J,ne]),Y=_.useMemo(()=>vc(e,H),[e,H]),U=_.useMemo(()=>e.filter(L=>Y[L.id]).map(L=>({...L,...Y[L.id]})),[e,Y]),ee=_.useMemo(()=>Object.fromEntries(U.map(L=>[L.id,L])),[U]),W=ee[J.id],Z=_.useMemo(()=>{const L={};return e.forEach(q=>{q.parent&&(L[q.parent]=(L[q.parent]||0)+1)}),L},[e]),re=_.useMemo(()=>e.filter(L=>{var q;return(q=L.overlays)==null?void 0:q.length}),[e]),ie=_.useMemo(()=>$?t.find(L=>L.source===$):null,[t,$]),se=_.useMemo(()=>$?e.filter(L=>(L.overlays||[]).some(q=>q.source===$)):[],[e,$]),ce=_.useMemo(()=>$?se:re,[$,se,re]),xe=Cm(Es),be=_.useCallback(L=>L?t.filter(q=>{var G;return(G=q.ops)==null?void 0:G.some(oe=>oe.nodeId===L.id)}):[],[t]),ge=_.useCallback(L=>{I(L),ke("sessions",L)},[]),me=_.useCallback(L=>{I("new"),C(L),ke("sessions","new")},[]),Xe=_.useCallback(L=>{pc(L,{onFocusNode:h,onOpenSession:ge})},[ge]),Oe=_.useMemo(()=>{var G;if(!S)return[];const L=e.find(oe=>oe.id===S.id);return(G=L==null?void 0:L.overlays)!=null&&G.length?[...new Set(L.overlays.map(oe=>oe.source))].map(oe=>t.find(de=>de.source===oe)).filter(Boolean):[]},[S,e,t]),Ve=_.useCallback(L=>{Xe(L.address)},[Xe]);_.useLayoutEffect(()=>{if(c!=="sessions"||!l)return;const L=l.split("/")[0];L&&L!==k&&I(L)},[c,l]),_.useEffect(()=>{c==="sessions"&&ke("sessions",k,{replace:!0})},[c,k]),_.useEffect(()=>{c!=="graph"&&(w(!1),p(!1),M(null),z(null))},[c]);const we=_.useMemo(()=>U.filter(L=>L.parent===W.id),[U,W]),_e=W.parent?ee[W.parent]:null,Ee=_.useMemo(()=>we.length?we.reduce((L,q)=>Math.abs(q.y-W.y)<Math.abs(L.y-W.y)?q:L):null,[we,W]),Ce=_.useMemo(()=>{if(Ee)return Ee;let L=null,q=1/0;for(const G of U){const oe=G.x-W.x;if(oe<=0)continue;const de=G.y-W.y,j=(oe/bc)**2+(de/_c)**2;j<q&&(q=j,L=G)}return L},[Ee,U,W]),dt=_.useCallback(L=>{let q=null;for(const G of U){if(G.id===W.id||G.x!==W.x)continue;const oe=G.y-W.y;(L==="down"?oe<=0:oe>=0)||(!q||Math.abs(oe)<Math.abs(q.y-W.y))&&(q=G)}return q},[U,W]),Qe=_.useMemo(()=>dt("down"),[dt]),$t=_.useMemo(()=>dt("up"),[dt]),Zn=_.useMemo(()=>U.map(L=>{const q=L.id===f||L.id===W.parent||L.parent===f||L.parent===W.parent;let G;$&&se.length?G=(L.overlays||[]).some(pe=>pe.source===$)?"ov-hot":"ov-dim":G=q?void 0:"is-far";const de=be(L).map(pe=>({id:pe.id,status:pe.status,node:pe.node})),j=Z[L.id]||0,ye={editors:de,collapsed:j>0&&!H.has(L.id),childCount:j};return{id:L.id,type:"spec",position:{x:L.x,y:L.y},data:{...L,...ye},initialWidth:vs.width,initialHeight:vs.height,handles:Tm,draggable:!1,selected:L.id===f,className:G}}),[f,W.parent,$,se,U,be,Z,H]),Qn=_.useMemo(()=>{const L=U.filter(G=>G.parent).map(G=>{const oe=G.id===f||G.parent===f;return{id:`${G.parent}-${G.id}`,source:G.parent,target:G.id,type:"smoothstep",style:{stroke:oe?"var(--blue)":"var(--line)",strokeWidth:oe?2:1},zIndex:oe?1:0}}),q=[];for(const G of U){const oe=(G.overlays||[]).find(j=>j.op==="moved"&&j.toParent&&ee[j.toParent]);if(!oe)continue;const de=xr(oe.seed);q.push({id:`move-${G.id}-${oe.toParent}`,source:G.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:Xt.ArrowClosed,color:de,width:14,height:14}})}return[...L,...q]},[f,U,ee]),tn=_.useCallback((L,q)=>{const G=b(),oe=performance.now();cancelAnimationFrame(R.current);const de=j=>{const ye=q?Math.min(1,(j-oe)/q):1,pe=1-Math.pow(1-ye,3);P({x:G.x+(L.x-G.x)*pe,y:G.y+(L.y-G.y)*pe,zoom:G.zoom+(L.zoom-G.zoom)*pe}),ye<1&&(R.current=requestAnimationFrame(de))};R.current=requestAnimationFrame(de)},[b,P]),Re=_.useCallback((L,q,G=300)=>{const oe=D.current;if(!oe)return;const de=q??b().zoom;tn({x:oe.clientWidth/2-L.x*de,y:oe.clientHeight/2-L.y*de,zoom:de},G)},[tn,b]),nn=_.useRef(!1);_.useEffect(()=>{if(nn.current||c!=="graph")return;const L=requestAnimationFrame(()=>{nn.current=!0,Re(W,void 0,0)});return()=>cancelAnimationFrame(L)},[Re,W,c]);const Je=_.useRef(W);Je.current=W;const rn=_.useRef(Re);rn.current=Re;const on=_.useRef(!1),et=_.useRef(!1),ft=_.useRef(null);_.useEffect(()=>{if(c==="graph"){if(!on.current){on.current=!0,ft.current=f;return}if(et.current){et.current=!1,ft.current=f;return}ft.current!==f&&(ft.current=f,rn.current(Je.current))}},[f,c]);const ht=g||E||!!v,sn=_.useRef(ht);_.useEffect(()=>{sn.current&&!ht&&Qa(),sn.current=ht},[ht]),_.useEffect(()=>{const L=mc(W).map(j=>j.key),q=j=>y(ye=>{const pe=L.indexOf(ye);return L[((pe<0?0:pe)+j+L.length)%L.length]}),G=(j,ye)=>{j&&(ye.preventDefault(),ye.stopPropagation(),O(!0),h(j.id))},oe=j=>K(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 ye,pe,gt,cn;if(j.altKey&&!j.metaKey&&!j.ctrlKey){const Ae={Digit1:"graph",Digit2:"sessions",Digit3:"evals",Digit4:"issues",Digit5:"settings"}[j.code];if(Ae){j.preventDefault(),j.stopPropagation(),M(null),ke(Ae);return}if(j.code==="KeyN"){j.preventDefault(),j.stopPropagation(),M(null),I("new"),ke("sessions","new");return}if(j.code==="KeyF"){j.preventDefault(),j.stopPropagation(),M(null),ke("evals");return}}if(v){j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),M(null));return}if(j.altKey&&!j.metaKey&&!j.ctrlKey&&j.code==="Slash"){j.preventDefault(),j.stopPropagation(),M("sessions");return}if(!(j.metaKey||j.ctrlKey||j.altKey)&&!((j.key==="Enter"||j.key===" ")&&((pe=(ye=j.target)==null?void 0:ye.closest)!=null&&pe.call(ye,"button, a[href], input, select, textarea, summary")))&&c!=="sessions"&&!(c==="evals"||c==="issues")){if(c==="settings"){fe("graph.settings",j.key)&&(j.preventDefault(),j.stopPropagation(),ke("graph"));return}if(g){const Ne=j.key==="Escape"?null:(cn=(gt=j.target)==null?void 0:gt.closest)==null?void 0:cn.call(gt,'input, textarea, select, [role="menu"], [role="menuitemradio"], [aria-haspopup="menu"]');if(Ne!=null&&Ne.closest("[data-focus-overlay]"))return;if(j.key==="Escape"){j.preventDefault(),w(!1);return}if(j.shiftKey){if(fe("nav.up",j.key))return G($t,j);if(fe("nav.down",j.key))return G(Qe,j);if(fe("nav.parent",j.key))return G(_e,j);if(fe("nav.child",j.key))return G(Ce,j)}if(j.key==="Tab"){j.preventDefault(),j.stopPropagation(),q(j.shiftKey?-1:1);return}if(j.key==="ArrowLeft"||j.key==="h"){j.preventDefault(),j.stopPropagation(),q(-1);return}if(j.key==="ArrowRight"||j.key==="l"){j.preventDefault(),j.stopPropagation(),q(1);return}if(/^[1-9]$/.test(j.key)&&+j.key<=L.length){j.preventDefault(),j.stopPropagation(),y(L[+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(E){if(j.key==="Escape"||j.key==="?"){j.preventDefault(),p(!1);return}if(j.key==="j"||j.key==="k"||j.key==="ArrowDown"||j.key==="ArrowUp"){j.preventDefault(),j.stopPropagation(),te(document.querySelector(".legend"),j.key==="j"||j.key==="ArrowDown"?120:-120);return}return}if(fe("graph.help",j.key)){j.preventDefault(),p(!0);return}if(j.key==="Escape"&&$){j.preventDefault(),j.stopPropagation(),T(null);return}if(fe("graph.settings",j.key)){j.preventDefault(),ke("settings");return}if(fe("graph.search",j.key)){j.preventDefault(),j.stopPropagation(),M("nodes");return}if(!j.metaKey&&!j.ctrlKey&&!j.altKey&&/^[a-zA-Z]$/.test(j.key)){const Ne=A.current;if(Ne.buf||Rm.has(j.key)){clearTimeout(Ne.timer);const Ae=Ne.buf+j.key;if(Lt[Ae]){j.preventDefault(),j.stopPropagation(),A.current={buf:"",timer:0},me(Lt[Ae](W.id));return}if(xa.some(nr=>nr.startsWith(Ae))){j.preventDefault(),j.stopPropagation(),A.current={buf:Ae,timer:setTimeout(()=>{A.current={buf:"",timer:0}},700)};return}A.current={buf:"",timer:0}}}if(fe("nav.up",j.key))return G($t,j);if(fe("nav.down",j.key))return G(Qe,j);if(fe("nav.parent",j.key))return G(_e,j);if(fe("nav.child",j.key))return G(Ce,j);if(fe("graph.zoomIn",j.key))j.preventDefault(),O(!0),Re(W,bs(b().zoom*1.2),160);else if(fe("graph.zoomOut",j.key))j.preventDefault(),O(!0),Re(W,bs(b().zoom/1.2),160);else if(fe("graph.zoomReset",j.key))j.preventDefault(),O(!0),Re(W,.85,200);else if(fe("graph.info",j.key))j.preventDefault(),w(!0);else if(fe("graph.cycle",j.key)||fe("graph.cycleRev",j.key)){if(j.preventDefault(),!ce.length)return;O(!0);const Ne=ya(ce,W.id,fe("graph.cycleRev",j.key)?-1:1,Ae=>Ae.id);Ne&&h(Ne.id)}else fe("graph.fresh",j.key)?(j.preventDefault(),me(`[[${W.id}]] `)):fe("graph.evals",j.key)&&(j.preventDefault(),ke("evals"))}};return window.addEventListener("keydown",de,!0),()=>window.removeEventListener("keydown",de,!0)},[g,c,E,v,$,W,ce,$t,Qe,Ce,_e,Re,b,ge,me,K,te]),_.useEffect(()=>{const L=q=>{const G=X.current,oe=q.clientX!==G.x||q.clientY!==G.y;G.x=q.clientX,G.y=q.clientY,oe&&V.current&&O(!1)};return window.addEventListener("mousemove",L,!0),()=>window.removeEventListener("mousemove",L,!0)},[]);const Jn=_.useCallback((L,q)=>{q.id!==Je.current.id&&(et.current=!0),h(q.id)},[]),er=_.useCallback((L,q)=>{q.id!==Je.current.id&&(et.current=!0),h(q.id),w(!0)},[]),tr=_.useCallback((L,q)=>{L.preventDefault(),q.id!==Je.current.id&&(et.current=!0),h(q.id),z({x:L.clientX,y:L.clientY,id:q.id})},[]),an=_.useCallback((L,q=!0)=>{const G=q&&$===L.source;if(T(G?null:L.source),G)return;const oe=new Set((L.ops||[]).map(j=>j.nodeId)),de=e.find(j=>oe.has(j.id));de&&h(de.id)},[$,e]);return m.jsxs("div",{className:B?"app kbd-mode":"app",children:[m.jsx(Ja,{}),m.jsx(ec,{page:c,identity:o,catalog:s}),m.jsxs("div",{className:"app-main",children:[m.jsx(Dt,{active:c==="graph",warm:!0,className:"page-graph",children:m.jsxs("div",{className:"graph",ref:D,children:[m.jsx(mp,{nodes:Zn,edges:Qn,nodeTypes:jm,onNodeClick:Jn,onNodeDoubleClick:er,onNodeContextMenu:tr,nodeOrigin:Dm,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesFocusable:!1,disableKeyboardA11y:!0,defaultViewport:{x:0,y:0,zoom:.85},minZoom:.4,maxZoom:1.6,proOptions:{hideAttribution:!0}}),m.jsxs("div",{className:"hud",children:[m.jsxs("span",{className:"brand",children:["$ ",a||"spec-dashboard"]}),m.jsx("button",{className:"hud-help",onClick:()=>p(L=>!L),"data-tip":N("hud.helpTitle"),children:"?"})]}),m.jsx(nc,{sessions:t,activeId:$,onPick:an,onOpenSession:ge}),m.jsx(Mm,{specs:e,focusId:f,onJump:h}),m.jsx(qp,{menu:S,onClose:()=>z(null),onInfo:()=>w(!0),onFresh:L=>me(`[[${L}]] `),onNewChild:L=>me(Lt.nn(L)),onDelete:L=>me(Lt.dd(L)),sessions:Oe,onOpenSession:ge}),ie&&m.jsxs("div",{className:"lock-hint",style:{"--ov":xr(ie.id)},children:[m.jsxs("span",{className:"lock-hint-lead",children:[m.jsx(rc,{})," ",Tr(ie)]}),se.length?m.jsx("span",{className:"lock-hint-body",children:km(se.length)?m.jsxs(m.Fragment,{children:[N("lockHint.cycleBefore"),m.jsx("kbd",{children:xe.next}),N("lockHint.cycleNext"),m.jsx("span",{className:"lock-hint-sep",children:" / "}),m.jsx("kbd",{children:xe.prev}),N("lockHint.cyclePrev"),N("lockHint.cycleAfter",{n:se.length})]}):N("lockHint.singleChanged")}):m.jsx("span",{className:"lock-hint-body",children:N("lockHint.empty")}),m.jsx("button",{className:"lock-hint-release",onClick:()=>T(null),"data-tip":N("lockHint.releaseTitle"),children:N("lockHint.release")})]}),E&&m.jsx(nm,{onClose:()=>p(!1)})]})}),g&&m.jsx(yc,{node:W,pane:x,setPane:y,sessions:t,onClose:()=>w(!1)},W.id),m.jsx(Dt,{active:c==="sessions",warm:d,className:"page-sessions",children:m.jsx(Am,{sessions:t,specs:e,focusNode:W,open:c==="sessions",searchOpen:!!v,sel:k,setSel:I,seed:F,onSeedConsumed:()=>C(null),onClose:()=>ke("graph"),onPickSession:an,onOpenSearch:()=>M("sessions"),boardLive:i,reload:r})}),m.jsx(Dt,{active:c==="evals",className:"page-evals",children:m.jsx($m,{specs:e,sessions:t,issuesStamp:n,reloadBoard:r,onOpenSession:ge,onFocusNode:L=>{h(L),ke("graph")}})}),m.jsx(Dt,{active:c==="issues",className:"page-issues",children:m.jsx(Im,{specs:e,sessions:t,issuesStamp:n,onOpenSession:ge,onFocusNode:L=>{h(L),ke("graph")}})}),m.jsx(Dt,{active:c==="settings",className:"page-settings",children:m.jsx(Pm,{})}),v&&m.jsx(_m,{specs:e,sessions:t,onPick:Ve,onClose:()=>M(null),boost:v==="sessions"?"session":null})]})]})}function zm(e){return m.jsx(la,{children:m.jsx(Lm,{...e})})}const Ym=Object.freeze(Object.defineProperty({__proto__:null,default:zm},Symbol.toStringTag,{value:"Module"}));export{Kp as C,Ym as D,gr as a,jt as b,gs as c};