agent-dag 1.33.2 → 1.33.4
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.
|
@@ -56,7 +56,7 @@ Error generating stack: `+x.message+`
|
|
|
56
56
|
*/var tw;function iR(){if(tw)return Hc;tw=1;var e=Qo(),n=rR();function i(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var s=typeof Object.is=="function"?Object.is:i,o=n.useSyncExternalStore,l=e.useRef,u=e.useEffect,c=e.useMemo,f=e.useDebugValue;return Hc.useSyncExternalStoreWithSelector=function(h,p,m,y,w){var j=l(null);if(j.current===null){var _={hasValue:!1,value:null};j.current=_}else _=j.current;j=c(function(){function b(O){if(!E){if(E=!0,N=O,O=y(O),w!==void 0&&_.hasValue){var P=_.value;if(w(P,O))return C=P}return C=O}if(P=C,s(N,O))return P;var z=y(O);return w!==void 0&&w(P,z)?(N=O,P):(N=O,C=z)}var E=!1,N,C,I=m===void 0?null:m;return[function(){return b(p())},I===null?void 0:function(){return b(I())}]},[p,m,y,w]);var S=o(h,j[0],j[1]);return u(function(){_.hasValue=!0,_.value=S},[S]),f(S),S},Hc}var nw;function sR(){return nw||(nw=1,Uc.exports=iR()),Uc.exports}var oR=sR();const aR=Wg(oR),lR={},rw=e=>{let n;const i=new Set,s=(p,m)=>{const y=typeof p=="function"?p(n):p;if(!Object.is(y,n)){const w=n;n=m??(typeof y!="object"||y===null)?y:Object.assign({},n,y),i.forEach(j=>j(n,w))}},o=()=>n,f={setState:s,getState:o,getInitialState:()=>h,subscribe:p=>(i.add(p),()=>i.delete(p)),destroy:()=>{(lR?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},h=n=e(s,o,f);return f},uR=e=>e?rw(e):rw,{useDebugValue:cR}=le,{useSyncExternalStoreWithSelector:dR}=aR,fR=e=>e;function Lk(e,n=fR,i){const s=dR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,i);return cR(s),s}const iw=(e,n)=>{const i=uR(e),s=(o,l=n)=>Lk(i,o,l);return Object.assign(s,i),s},hR=(e,n)=>e?iw(e,n):iw;function Tt(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[s,o]of e)if(!Object.is(o,n.get(s)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}const i=Object.keys(e);if(i.length!==Object.keys(n).length)return!1;for(const s of i)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(e[s],n[s]))return!1;return!0}var pR={value:()=>{}};function Fl(){for(var e=0,n=arguments.length,i={},s;e<n;++e){if(!(s=arguments[e]+"")||s in i||/[\s.]/.test(s))throw new Error("illegal type: "+s);i[s]=[]}return new kl(i)}function kl(e){this._=e}function mR(e,n){return e.trim().split(/^|\s+/).map(function(i){var s="",o=i.indexOf(".");if(o>=0&&(s=i.slice(o+1),i=i.slice(0,o)),i&&!n.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:s}})}kl.prototype=Fl.prototype={constructor:kl,on:function(e,n){var i=this._,s=mR(e+"",i),o,l=-1,u=s.length;if(arguments.length<2){for(;++l<u;)if((o=(e=s[l]).type)&&(o=gR(i[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++l<u;)if(o=(e=s[l]).type)i[o]=sw(i[o],e.name,n);else if(n==null)for(o in i)i[o]=sw(i[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var i in n)e[i]=n[i].slice();return new kl(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var i=new Array(o),s=0,o,l;s<o;++s)i[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,o=l.length;s<o;++s)l[s].value.apply(n,i)},apply:function(e,n,i){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,l=s.length;o<l;++o)s[o].value.apply(n,i)}};function gR(e,n){for(var i=0,s=e.length,o;i<s;++i)if((o=e[i]).name===n)return o.value}function sw(e,n,i){for(var s=0,o=e.length;s<o;++s)if(e[s].name===n){e[s]=pR,e=e.slice(0,s).concat(e.slice(s+1));break}return i!=null&&e.push({name:n,value:i}),e}var kg="http://www.w3.org/1999/xhtml";const ow={svg:"http://www.w3.org/2000/svg",xhtml:kg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function zl(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),ow.hasOwnProperty(n)?{space:ow[n],local:e}:e}function vR(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===kg&&n.documentElement.namespaceURI===kg?n.createElement(e):n.createElementNS(i,e)}}function yR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function $k(e){var n=zl(e);return(n.local?yR:vR)(n)}function wR(){}function Gg(e){return e==null?wR:function(){return this.querySelector(e)}}function xR(e){typeof e!="function"&&(e=Gg(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=new Array(u),f,h,p=0;p<u;++p)(f=l[p])&&(h=e.call(f,f.__data__,p,l))&&("__data__"in f&&(h.__data__=f.__data__),c[p]=h);return new gn(s,this._parents)}function _R(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function SR(){return[]}function Dk(e){return e==null?SR:function(){return this.querySelectorAll(e)}}function bR(e){return function(){return _R(e.apply(this,arguments))}}function kR(e){typeof e=="function"?e=bR(e):e=Dk(e);for(var n=this._groups,i=n.length,s=[],o=[],l=0;l<i;++l)for(var u=n[l],c=u.length,f,h=0;h<c;++h)(f=u[h])&&(s.push(e.call(f,f.__data__,h,u)),o.push(f));return new gn(s,o)}function Fk(e){return function(){return this.matches(e)}}function zk(e){return function(n){return n.matches(e)}}var ER=Array.prototype.find;function NR(e){return function(){return ER.call(this.children,e)}}function CR(){return this.firstElementChild}function jR(e){return this.select(e==null?CR:NR(typeof e=="function"?e:zk(e)))}var RR=Array.prototype.filter;function TR(){return Array.from(this.children)}function AR(e){return function(){return RR.call(this.children,e)}}function IR(e){return this.selectAll(e==null?TR:AR(typeof e=="function"?e:zk(e)))}function MR(e){typeof e!="function"&&(e=Fk(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=[],f,h=0;h<u;++h)(f=l[h])&&e.call(f,f.__data__,h,l)&&c.push(f);return new gn(s,this._parents)}function Bk(e){return new Array(e.length)}function PR(){return new gn(this._enter||this._groups.map(Bk),this._parents)}function jl(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}jl.prototype={constructor:jl,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function OR(e){return function(){return e}}function qR(e,n,i,s,o,l){for(var u=0,c,f=n.length,h=l.length;u<h;++u)(c=n[u])?(c.__data__=l[u],s[u]=c):i[u]=new jl(e,l[u]);for(;u<f;++u)(c=n[u])&&(o[u]=c)}function LR(e,n,i,s,o,l,u){var c,f,h=new Map,p=n.length,m=l.length,y=new Array(p),w;for(c=0;c<p;++c)(f=n[c])&&(y[c]=w=u.call(f,f.__data__,c,n)+"",h.has(w)?o[c]=f:h.set(w,f));for(c=0;c<m;++c)w=u.call(e,l[c],c,l)+"",(f=h.get(w))?(s[c]=f,f.__data__=l[c],h.delete(w)):i[c]=new jl(e,l[c]);for(c=0;c<p;++c)(f=n[c])&&h.get(y[c])===f&&(o[c]=f)}function $R(e){return e.__data__}function DR(e,n){if(!arguments.length)return Array.from(this,$R);var i=n?LR:qR,s=this._parents,o=this._groups;typeof e!="function"&&(e=OR(e));for(var l=o.length,u=new Array(l),c=new Array(l),f=new Array(l),h=0;h<l;++h){var p=s[h],m=o[h],y=m.length,w=FR(e.call(p,p&&p.__data__,h,s)),j=w.length,_=c[h]=new Array(j),S=u[h]=new Array(j),b=f[h]=new Array(y);i(p,m,_,S,b,w,n);for(var E=0,N=0,C,I;E<j;++E)if(C=_[E]){for(E>=N&&(N=E+1);!(I=S[N])&&++N<j;);C._next=I||null}}return u=new gn(u,s),u._enter=c,u._exit=f,u}function FR(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function zR(){return new gn(this._exit||this._groups.map(Bk),this._parents)}function BR(e,n,i){var s=this.enter(),o=this,l=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),i==null?l.remove():i(l),s&&o?s.merge(o).order():o}function UR(e){for(var n=e.selection?e.selection():e,i=this._groups,s=n._groups,o=i.length,l=s.length,u=Math.min(o,l),c=new Array(o),f=0;f<u;++f)for(var h=i[f],p=s[f],m=h.length,y=c[f]=new Array(m),w,j=0;j<m;++j)(w=h[j]||p[j])&&(y[j]=w);for(;f<o;++f)c[f]=i[f];return new gn(c,this._parents)}function HR(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var s=e[n],o=s.length-1,l=s[o],u;--o>=0;)(u=s[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function VR(e){e||(e=WR);function n(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var i=this._groups,s=i.length,o=new Array(s),l=0;l<s;++l){for(var u=i[l],c=u.length,f=o[l]=new Array(c),h,p=0;p<c;++p)(h=u[p])&&(f[p]=h);f.sort(n)}return new gn(o,this._parents).order()}function WR(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function GR(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function YR(){return Array.from(this)}function KR(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var s=e[n],o=0,l=s.length;o<l;++o){var u=s[o];if(u)return u}return null}function XR(){let e=0;for(const n of this)++e;return e}function QR(){return!this.node()}function ZR(e){for(var n=this._groups,i=0,s=n.length;i<s;++i)for(var o=n[i],l=0,u=o.length,c;l<u;++l)(c=o[l])&&e.call(c,c.__data__,l,o);return this}function JR(e){return function(){this.removeAttribute(e)}}function eT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function tT(e,n){return function(){this.setAttribute(e,n)}}function nT(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function rT(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function iT(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,i)}}function sT(e,n){var i=zl(e);if(arguments.length<2){var s=this.node();return i.local?s.getAttributeNS(i.space,i.local):s.getAttribute(i)}return this.each((n==null?i.local?eT:JR:typeof n=="function"?i.local?iT:rT:i.local?nT:tT)(i,n))}function Uk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function oT(e){return function(){this.style.removeProperty(e)}}function aT(e,n,i){return function(){this.style.setProperty(e,n,i)}}function lT(e,n,i){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,i)}}function uT(e,n,i){return arguments.length>1?this.each((n==null?oT:typeof n=="function"?lT:aT)(e,n,i??"")):zs(this.node(),e)}function zs(e,n){return e.style.getPropertyValue(n)||Uk(e).getComputedStyle(e,null).getPropertyValue(n)}function cT(e){return function(){delete this[e]}}function dT(e,n){return function(){this[e]=n}}function fT(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function hT(e,n){return arguments.length>1?this.each((n==null?cT:typeof n=="function"?fT:dT)(e,n)):this.node()[e]}function Hk(e){return e.trim().split(/^|\s+/)}function Yg(e){return e.classList||new Vk(e)}function Vk(e){this._node=e,this._names=Hk(e.getAttribute("class")||"")}Vk.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Wk(e,n){for(var i=Yg(e),s=-1,o=n.length;++s<o;)i.add(n[s])}function Gk(e,n){for(var i=Yg(e),s=-1,o=n.length;++s<o;)i.remove(n[s])}function pT(e){return function(){Wk(this,e)}}function mT(e){return function(){Gk(this,e)}}function gT(e,n){return function(){(n.apply(this,arguments)?Wk:Gk)(this,e)}}function vT(e,n){var i=Hk(e+"");if(arguments.length<2){for(var s=Yg(this.node()),o=-1,l=i.length;++o<l;)if(!s.contains(i[o]))return!1;return!0}return this.each((typeof n=="function"?gT:n?pT:mT)(i,n))}function yT(){this.textContent=""}function wT(e){return function(){this.textContent=e}}function xT(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function _T(e){return arguments.length?this.each(e==null?yT:(typeof e=="function"?xT:wT)(e)):this.node().textContent}function ST(){this.innerHTML=""}function bT(e){return function(){this.innerHTML=e}}function kT(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function ET(e){return arguments.length?this.each(e==null?ST:(typeof e=="function"?kT:bT)(e)):this.node().innerHTML}function NT(){this.nextSibling&&this.parentNode.appendChild(this)}function CT(){return this.each(NT)}function jT(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function RT(){return this.each(jT)}function TT(e){var n=typeof e=="function"?e:$k(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function AT(){return null}function IT(e,n){var i=typeof e=="function"?e:$k(e),s=n==null?AT:typeof n=="function"?n:Gg(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),s.apply(this,arguments)||null)})}function MT(){var e=this.parentNode;e&&e.removeChild(this)}function PT(){return this.each(MT)}function OT(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function qT(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function LT(e){return this.select(e?qT:OT)}function $T(e){return arguments.length?this.property("__data__",e):this.node().__data__}function DT(e){return function(n){e.call(this,n,this.__data__)}}function FT(e){return e.trim().split(/^|\s+/).map(function(n){var i="",s=n.indexOf(".");return s>=0&&(i=n.slice(s+1),n=n.slice(0,s)),{type:n,name:i}})}function zT(e){return function(){var n=this.__on;if(n){for(var i=0,s=-1,o=n.length,l;i<o;++i)l=n[i],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):n[++s]=l;++s?n.length=s:delete this.__on}}}function BT(e,n,i){return function(){var s=this.__on,o,l=DT(n);if(s){for(var u=0,c=s.length;u<c;++u)if((o=s[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=l,o.options=i),o.value=n;return}}this.addEventListener(e.type,l,i),o={type:e.type,name:e.name,value:n,listener:l,options:i},s?s.push(o):this.__on=[o]}}function UT(e,n,i){var s=FT(e+""),o,l=s.length,u;if(arguments.length<2){var c=this.node().__on;if(c){for(var f=0,h=c.length,p;f<h;++f)for(o=0,p=c[f];o<l;++o)if((u=s[o]).type===p.type&&u.name===p.name)return p.value}return}for(c=n?BT:zT,o=0;o<l;++o)this.each(c(s[o],n,i));return this}function Yk(e,n,i){var s=Uk(e),o=s.CustomEvent;typeof o=="function"?o=new o(n,i):(o=s.document.createEvent("Event"),i?(o.initEvent(n,i.bubbles,i.cancelable),o.detail=i.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function HT(e,n){return function(){return Yk(this,e,n)}}function VT(e,n){return function(){return Yk(this,e,n.apply(this,arguments))}}function WT(e,n){return this.each((typeof n=="function"?VT:HT)(e,n))}function*GT(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var s=e[n],o=0,l=s.length,u;o<l;++o)(u=s[o])&&(yield u)}var Kk=[null];function gn(e,n){this._groups=e,this._parents=n}function Zo(){return new gn([[document.documentElement]],Kk)}function YT(){return this}gn.prototype=Zo.prototype={constructor:gn,select:xR,selectAll:kR,selectChild:jR,selectChildren:IR,filter:MR,data:DR,enter:PR,exit:zR,join:BR,merge:UR,selection:YT,order:HR,sort:VR,call:GR,nodes:YR,node:KR,size:XR,empty:QR,each:ZR,attr:sT,style:uT,property:hT,classed:vT,text:_T,html:ET,raise:CT,lower:RT,append:TT,insert:IT,remove:PT,clone:LT,datum:$T,on:UT,dispatch:WT,[Symbol.iterator]:GT};function In(e){return typeof e=="string"?new gn([[document.querySelector(e)]],[document.documentElement]):new gn([[e]],Kk)}function KT(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Wn(e,n){if(e=KT(e),n===void 0&&(n=e.currentTarget),n){var i=n.ownerSVGElement||n;if(i.createSVGPoint){var s=i.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(n.getScreenCTM().inverse()),[s.x,s.y]}if(n.getBoundingClientRect){var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}}return[e.pageX,e.pageY]}const XT={passive:!1},Uo={capture:!0,passive:!1};function Gc(e){e.stopImmediatePropagation()}function Ls(e){e.preventDefault(),e.stopImmediatePropagation()}function Xk(e){var n=e.document.documentElement,i=In(e).on("dragstart.drag",Ls,Uo);"onselectstart"in n?i.on("selectstart.drag",Ls,Uo):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Qk(e,n){var i=e.document.documentElement,s=In(e).on("dragstart.drag",null);n&&(s.on("click.drag",Ls,Uo),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in i?s.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const ul=e=>()=>e;function Eg(e,{sourceEvent:n,subject:i,target:s,identifier:o,active:l,x:u,y:c,dx:f,dy:h,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:p}})}Eg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function QT(e){return!e.ctrlKey&&!e.button}function ZT(){return this.parentNode}function JT(e,n){return n??{x:e.x,y:e.y}}function e2(){return navigator.maxTouchPoints||"ontouchstart"in this}function t2(){var e=QT,n=ZT,i=JT,s=e2,o={},l=Fl("start","drag","end"),u=0,c,f,h,p,m=0;function y(C){C.on("mousedown.drag",w).filter(s).on("touchstart.drag",S).on("touchmove.drag",b,XT).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(C,I){if(!(p||!e.call(this,C,I))){var O=N(this,n.call(this,C,I),C,I,"mouse");O&&(In(C.view).on("mousemove.drag",j,Uo).on("mouseup.drag",_,Uo),Xk(C.view),Gc(C),h=!1,c=C.clientX,f=C.clientY,O("start",C))}}function j(C){if(Ls(C),!h){var I=C.clientX-c,O=C.clientY-f;h=I*I+O*O>m}o.mouse("drag",C)}function _(C){In(C.view).on("mousemove.drag mouseup.drag",null),Qk(C.view,h),Ls(C),o.mouse("end",C)}function S(C,I){if(e.call(this,C,I)){var O=C.changedTouches,P=n.call(this,C,I),z=O.length,T,q;for(T=0;T<z;++T)(q=N(this,P,C,I,O[T].identifier,O[T]))&&(Gc(C),q("start",C,O[T]))}}function b(C){var I=C.changedTouches,O=I.length,P,z;for(P=0;P<O;++P)(z=o[I[P].identifier])&&(Ls(C),z("drag",C,I[P]))}function E(C){var I=C.changedTouches,O=I.length,P,z;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),P=0;P<O;++P)(z=o[I[P].identifier])&&(Gc(C),z("end",C,I[P]))}function N(C,I,O,P,z,T){var q=l.copy(),B=Wn(T||O,I),J,Q,A;if((A=i.call(C,new Eg("beforestart",{sourceEvent:O,target:y,identifier:z,active:u,x:B[0],y:B[1],dx:0,dy:0,dispatch:q}),P))!=null)return J=A.x-B[0]||0,Q=A.y-B[1]||0,function H(U,ne,Y){var L=B,G;switch(U){case"start":o[z]=H,G=u++;break;case"end":delete o[z],--u;case"drag":B=Wn(Y||ne,I),G=u;break}q.call(U,C,new Eg(U,{sourceEvent:ne,subject:A,target:y,identifier:z,active:G,x:B[0]+J,y:B[1]+Q,dx:B[0]-L[0],dy:B[1]-L[1],dispatch:q}),P)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:ul(!!C),y):e},y.container=function(C){return arguments.length?(n=typeof C=="function"?C:ul(C),y):n},y.subject=function(C){return arguments.length?(i=typeof C=="function"?C:ul(C),y):i},y.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:ul(!!C),y):s},y.on=function(){var C=l.on.apply(l,arguments);return C===l?y:C},y.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,y):Math.sqrt(m)},y}function Kg(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function Zk(e,n){var i=Object.create(e.prototype);for(var s in n)i[s]=n[s];return i}function Jo(){}var Ho=.7,Rl=1/Ho,$s="\\s*([+-]?\\d+)\\s*",Vo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ar="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",n2=/^#([0-9a-f]{3,8})$/,r2=new RegExp(`^rgb\\(${$s},${$s},${$s}\\)$`),i2=new RegExp(`^rgb\\(${ar},${ar},${ar}\\)$`),s2=new RegExp(`^rgba\\(${$s},${$s},${$s},${Vo}\\)$`),o2=new RegExp(`^rgba\\(${ar},${ar},${ar},${Vo}\\)$`),a2=new RegExp(`^hsl\\(${Vo},${ar},${ar}\\)$`),l2=new RegExp(`^hsla\\(${Vo},${ar},${ar},${Vo}\\)$`),aw={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};Kg(Jo,Wo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:lw,formatHex:lw,formatHex8:u2,formatHsl:c2,formatRgb:uw,toString:uw});function lw(){return this.rgb().formatHex()}function u2(){return this.rgb().formatHex8()}function c2(){return Jk(this).formatHsl()}function uw(){return this.rgb().formatRgb()}function Wo(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=n2.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?cw(n):i===3?new ln(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?cl(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?cl(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=r2.exec(e))?new ln(n[1],n[2],n[3],1):(n=i2.exec(e))?new ln(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=s2.exec(e))?cl(n[1],n[2],n[3],n[4]):(n=o2.exec(e))?cl(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=a2.exec(e))?hw(n[1],n[2]/100,n[3]/100,1):(n=l2.exec(e))?hw(n[1],n[2]/100,n[3]/100,n[4]):aw.hasOwnProperty(e)?cw(aw[e]):e==="transparent"?new ln(NaN,NaN,NaN,0):null}function cw(e){return new ln(e>>16&255,e>>8&255,e&255,1)}function cl(e,n,i,s){return s<=0&&(e=n=i=NaN),new ln(e,n,i,s)}function d2(e){return e instanceof Jo||(e=Wo(e)),e?(e=e.rgb(),new ln(e.r,e.g,e.b,e.opacity)):new ln}function Ng(e,n,i,s){return arguments.length===1?d2(e):new ln(e,n,i,s??1)}function ln(e,n,i,s){this.r=+e,this.g=+n,this.b=+i,this.opacity=+s}Kg(ln,Ng,Zk(Jo,{brighter(e){return e=e==null?Rl:Math.pow(Rl,e),new ln(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ho:Math.pow(Ho,e),new ln(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ln(Bi(this.r),Bi(this.g),Bi(this.b),Tl(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:dw,formatHex:dw,formatHex8:f2,formatRgb:fw,toString:fw}));function dw(){return`#${Fi(this.r)}${Fi(this.g)}${Fi(this.b)}`}function f2(){return`#${Fi(this.r)}${Fi(this.g)}${Fi(this.b)}${Fi((isNaN(this.opacity)?1:this.opacity)*255)}`}function fw(){const e=Tl(this.opacity);return`${e===1?"rgb(":"rgba("}${Bi(this.r)}, ${Bi(this.g)}, ${Bi(this.b)}${e===1?")":`, ${e})`}`}function Tl(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Bi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fi(e){return e=Bi(e),(e<16?"0":"")+e.toString(16)}function hw(e,n,i,s){return s<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Gn(e,n,i,s)}function Jk(e){if(e instanceof Gn)return new Gn(e.h,e.s,e.l,e.opacity);if(e instanceof Jo||(e=Wo(e)),!e)return new Gn;if(e instanceof Gn)return e;e=e.rgb();var n=e.r/255,i=e.g/255,s=e.b/255,o=Math.min(n,i,s),l=Math.max(n,i,s),u=NaN,c=l-o,f=(l+o)/2;return c?(n===l?u=(i-s)/c+(i<s)*6:i===l?u=(s-n)/c+2:u=(n-i)/c+4,c/=f<.5?l+o:2-l-o,u*=60):c=f>0&&f<1?0:u,new Gn(u,c,f,e.opacity)}function h2(e,n,i,s){return arguments.length===1?Jk(e):new Gn(e,n,i,s??1)}function Gn(e,n,i,s){this.h=+e,this.s=+n,this.l=+i,this.opacity=+s}Kg(Gn,h2,Zk(Jo,{brighter(e){return e=e==null?Rl:Math.pow(Rl,e),new Gn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ho:Math.pow(Ho,e),new Gn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,s=i+(i<.5?i:1-i)*n,o=2*i-s;return new ln(Yc(e>=240?e-240:e+120,o,s),Yc(e,o,s),Yc(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new Gn(pw(this.h),dl(this.s),dl(this.l),Tl(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=Tl(this.opacity);return`${e===1?"hsl(":"hsla("}${pw(this.h)}, ${dl(this.s)*100}%, ${dl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function pw(e){return e=(e||0)%360,e<0?e+360:e}function dl(e){return Math.max(0,Math.min(1,e||0))}function Yc(e,n,i){return(e<60?n+(i-n)*e/60:e<180?i:e<240?n+(i-n)*(240-e)/60:n)*255}const eE=e=>()=>e;function p2(e,n){return function(i){return e+i*n}}function m2(e,n,i){return e=Math.pow(e,i),n=Math.pow(n,i)-e,i=1/i,function(s){return Math.pow(e+s*n,i)}}function g2(e){return(e=+e)==1?tE:function(n,i){return i-n?m2(n,i,e):eE(isNaN(n)?i:n)}}function tE(e,n){var i=n-e;return i?p2(e,i):eE(isNaN(e)?n:e)}const mw=(function e(n){var i=g2(n);function s(o,l){var u=i((o=Ng(o)).r,(l=Ng(l)).r),c=i(o.g,l.g),f=i(o.b,l.b),h=tE(o.opacity,l.opacity);return function(p){return o.r=u(p),o.g=c(p),o.b=f(p),o.opacity=h(p),o+""}}return s.gamma=e,s})(1);function ti(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}var Cg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Kc=new RegExp(Cg.source,"g");function v2(e){return function(){return e}}function y2(e){return function(n){return e(n)+""}}function w2(e,n){var i=Cg.lastIndex=Kc.lastIndex=0,s,o,l,u=-1,c=[],f=[];for(e=e+"",n=n+"";(s=Cg.exec(e))&&(o=Kc.exec(n));)(l=o.index)>i&&(l=n.slice(i,l),c[u]?c[u]+=l:c[++u]=l),(s=s[0])===(o=o[0])?c[u]?c[u]+=o:c[++u]=o:(c[++u]=null,f.push({i:u,x:ti(s,o)})),i=Kc.lastIndex;return i<n.length&&(l=n.slice(i),c[u]?c[u]+=l:c[++u]=l),c.length<2?f[0]?y2(f[0].x):v2(n):(n=f.length,function(h){for(var p=0,m;p<n;++p)c[(m=f[p]).i]=m.x(h);return c.join("")})}var gw=180/Math.PI,jg={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function nE(e,n,i,s,o,l){var u,c,f;return(u=Math.sqrt(e*e+n*n))&&(e/=u,n/=u),(f=e*i+n*s)&&(i-=e*f,s-=n*f),(c=Math.sqrt(i*i+s*s))&&(i/=c,s/=c,f/=c),e*s<n*i&&(e=-e,n=-n,f=-f,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(n,e)*gw,skewX:Math.atan(f)*gw,scaleX:u,scaleY:c}}var fl;function x2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?jg:nE(n.a,n.b,n.c,n.d,n.e,n.f)}function _2(e){return e==null||(fl||(fl=document.createElementNS("http://www.w3.org/2000/svg","g")),fl.setAttribute("transform",e),!(e=fl.transform.baseVal.consolidate()))?jg:(e=e.matrix,nE(e.a,e.b,e.c,e.d,e.e,e.f))}function rE(e,n,i,s){function o(h){return h.length?h.pop()+" ":""}function l(h,p,m,y,w,j){if(h!==m||p!==y){var _=w.push("translate(",null,n,null,i);j.push({i:_-4,x:ti(h,m)},{i:_-2,x:ti(p,y)})}else(m||y)&&w.push("translate("+m+n+y+i)}function u(h,p,m,y){h!==p?(h-p>180?p+=360:p-h>180&&(h+=360),y.push({i:m.push(o(m)+"rotate(",null,s)-2,x:ti(h,p)})):p&&m.push(o(m)+"rotate("+p+s)}function c(h,p,m,y){h!==p?y.push({i:m.push(o(m)+"skewX(",null,s)-2,x:ti(h,p)}):p&&m.push(o(m)+"skewX("+p+s)}function f(h,p,m,y,w,j){if(h!==m||p!==y){var _=w.push(o(w)+"scale(",null,",",null,")");j.push({i:_-4,x:ti(h,m)},{i:_-2,x:ti(p,y)})}else(m!==1||y!==1)&&w.push(o(w)+"scale("+m+","+y+")")}return function(h,p){var m=[],y=[];return h=e(h),p=e(p),l(h.translateX,h.translateY,p.translateX,p.translateY,m,y),u(h.rotate,p.rotate,m,y),c(h.skewX,p.skewX,m,y),f(h.scaleX,h.scaleY,p.scaleX,p.scaleY,m,y),h=p=null,function(w){for(var j=-1,_=y.length,S;++j<_;)m[(S=y[j]).i]=S.x(w);return m.join("")}}}var S2=rE(x2,"px, ","px)","deg)"),b2=rE(_2,", ",")",")"),k2=1e-12;function vw(e){return((e=Math.exp(e))+1/e)/2}function E2(e){return((e=Math.exp(e))-1/e)/2}function N2(e){return((e=Math.exp(2*e))-1)/(e+1)}const C2=(function e(n,i,s){function o(l,u){var c=l[0],f=l[1],h=l[2],p=u[0],m=u[1],y=u[2],w=p-c,j=m-f,_=w*w+j*j,S,b;if(_<k2)b=Math.log(y/h)/n,S=function(P){return[c+P*w,f+P*j,h*Math.exp(n*P*b)]};else{var E=Math.sqrt(_),N=(y*y-h*h+s*_)/(2*h*i*E),C=(y*y-h*h-s*_)/(2*y*i*E),I=Math.log(Math.sqrt(N*N+1)-N),O=Math.log(Math.sqrt(C*C+1)-C);b=(O-I)/n,S=function(P){var z=P*b,T=vw(I),q=h/(i*E)*(T*N2(n*z+I)-E2(I));return[c+q*w,f+q*j,h*T/vw(n*z+I)]}}return S.duration=b*1e3*n/Math.SQRT2,S}return o.rho=function(l){var u=Math.max(.001,+l),c=u*u,f=c*c;return e(u,c,f)},o})(Math.SQRT2,2,4);var Bs=0,qo=0,Ao=0,iE=1e3,Al,Lo,Il=0,Vi=0,Bl=0,Go=typeof performance=="object"&&performance.now?performance:Date,sE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Xg(){return Vi||(sE(j2),Vi=Go.now()+Bl)}function j2(){Vi=0}function Ml(){this._call=this._time=this._next=null}Ml.prototype=oE.prototype={constructor:Ml,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Xg():+i)+(n==null?0:+n),!this._next&&Lo!==this&&(Lo?Lo._next=this:Al=this,Lo=this),this._call=e,this._time=i,Rg()},stop:function(){this._call&&(this._call=null,this._time=1/0,Rg())}};function oE(e,n,i){var s=new Ml;return s.restart(e,n,i),s}function R2(){Xg(),++Bs;for(var e=Al,n;e;)(n=Vi-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Bs}function yw(){Vi=(Il=Go.now())+Bl,Bs=qo=0;try{R2()}finally{Bs=0,A2(),Vi=0}}function T2(){var e=Go.now(),n=e-Il;n>iE&&(Bl-=n,Il=e)}function A2(){for(var e,n=Al,i,s=1/0;n;)n._call?(s>n._time&&(s=n._time),e=n,n=n._next):(i=n._next,n._next=null,n=e?e._next=i:Al=i);Lo=e,Rg(s)}function Rg(e){if(!Bs){qo&&(qo=clearTimeout(qo));var n=e-Vi;n>24?(e<1/0&&(qo=setTimeout(yw,e-Go.now()-Bl)),Ao&&(Ao=clearInterval(Ao))):(Ao||(Il=Go.now(),Ao=setInterval(T2,iE)),Bs=1,sE(yw))}}function ww(e,n,i){var s=new Ml;return n=n==null?0:+n,s.restart(o=>{s.stop(),e(o+n)},n,i),s}var I2=Fl("start","end","cancel","interrupt"),M2=[],aE=0,xw=1,Tg=2,El=3,_w=4,Ag=5,Nl=6;function Ul(e,n,i,s,o,l){var u=e.__transition;if(!u)e.__transition={};else if(i in u)return;P2(e,i,{name:n,index:s,group:o,on:I2,tween:M2,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:aE})}function Qg(e,n){var i=Xn(e,n);if(i.state>aE)throw new Error("too late; already scheduled");return i}function lr(e,n){var i=Xn(e,n);if(i.state>El)throw new Error("too late; already running");return i}function Xn(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function P2(e,n,i){var s=e.__transition,o;s[n]=i,i.timer=oE(l,0,i.time);function l(h){i.state=xw,i.timer.restart(u,i.delay,i.time),i.delay<=h&&u(h-i.delay)}function u(h){var p,m,y,w;if(i.state!==xw)return f();for(p in s)if(w=s[p],w.name===i.name){if(w.state===El)return ww(u);w.state===_w?(w.state=Nl,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[p]):+p<n&&(w.state=Nl,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[p])}if(ww(function(){i.state===El&&(i.state=_w,i.timer.restart(c,i.delay,i.time),c(h))}),i.state=Tg,i.on.call("start",e,e.__data__,i.index,i.group),i.state===Tg){for(i.state=El,o=new Array(y=i.tween.length),p=0,m=-1;p<y;++p)(w=i.tween[p].value.call(e,e.__data__,i.index,i.group))&&(o[++m]=w);o.length=m+1}}function c(h){for(var p=h<i.duration?i.ease.call(null,h/i.duration):(i.timer.restart(f),i.state=Ag,1),m=-1,y=o.length;++m<y;)o[m].call(e,p);i.state===Ag&&(i.on.call("end",e,e.__data__,i.index,i.group),f())}function f(){i.state=Nl,i.timer.stop(),delete s[n];for(var h in s)return;delete e.__transition}}function Cl(e,n){var i=e.__transition,s,o,l=!0,u;if(i){n=n==null?null:n+"";for(u in i){if((s=i[u]).name!==n){l=!1;continue}o=s.state>Tg&&s.state<Ag,s.state=Nl,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete i[u]}l&&delete e.__transition}}function O2(e){return this.each(function(){Cl(this,e)})}function q2(e,n){var i,s;return function(){var o=lr(this,e),l=o.tween;if(l!==i){s=i=l;for(var u=0,c=s.length;u<c;++u)if(s[u].name===n){s=s.slice(),s.splice(u,1);break}}o.tween=s}}function L2(e,n,i){var s,o;if(typeof i!="function")throw new Error;return function(){var l=lr(this,e),u=l.tween;if(u!==s){o=(s=u).slice();for(var c={name:n,value:i},f=0,h=o.length;f<h;++f)if(o[f].name===n){o[f]=c;break}f===h&&o.push(c)}l.tween=o}}function $2(e,n){var i=this._id;if(e+="",arguments.length<2){for(var s=Xn(this.node(),i).tween,o=0,l=s.length,u;o<l;++o)if((u=s[o]).name===e)return u.value;return null}return this.each((n==null?q2:L2)(i,e,n))}function Zg(e,n,i){var s=e._id;return e.each(function(){var o=lr(this,s);(o.value||(o.value={}))[n]=i.apply(this,arguments)}),function(o){return Xn(o,s).value[n]}}function lE(e,n){var i;return(typeof n=="number"?ti:n instanceof Wo?mw:(i=Wo(n))?(n=i,mw):w2)(e,n)}function D2(e){return function(){this.removeAttribute(e)}}function F2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function z2(e,n,i){var s,o=i+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===s?l:l=n(s=u,i)}}function B2(e,n,i){var s,o=i+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===s?l:l=n(s=u,i)}}function U2(e,n,i){var s,o,l;return function(){var u,c=i(this),f;return c==null?void this.removeAttribute(e):(u=this.getAttribute(e),f=c+"",u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c)))}}function H2(e,n,i){var s,o,l;return function(){var u,c=i(this),f;return c==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),f=c+"",u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c)))}}function V2(e,n){var i=zl(e),s=i==="transform"?b2:lE;return this.attrTween(e,typeof n=="function"?(i.local?H2:U2)(i,s,Zg(this,"attr."+e,n)):n==null?(i.local?F2:D2)(i):(i.local?B2:z2)(i,s,n))}function W2(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function G2(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function Y2(e,n){var i,s;function o(){var l=n.apply(this,arguments);return l!==s&&(i=(s=l)&&G2(e,l)),i}return o._value=n,o}function K2(e,n){var i,s;function o(){var l=n.apply(this,arguments);return l!==s&&(i=(s=l)&&W2(e,l)),i}return o._value=n,o}function X2(e,n){var i="attr."+e;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;var s=zl(e);return this.tween(i,(s.local?Y2:K2)(s,n))}function Q2(e,n){return function(){Qg(this,e).delay=+n.apply(this,arguments)}}function Z2(e,n){return n=+n,function(){Qg(this,e).delay=n}}function J2(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Q2:Z2)(n,e)):Xn(this.node(),n).delay}function eA(e,n){return function(){lr(this,e).duration=+n.apply(this,arguments)}}function tA(e,n){return n=+n,function(){lr(this,e).duration=n}}function nA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?eA:tA)(n,e)):Xn(this.node(),n).duration}function rA(e,n){if(typeof n!="function")throw new Error;return function(){lr(this,e).ease=n}}function iA(e){var n=this._id;return arguments.length?this.each(rA(n,e)):Xn(this.node(),n).ease}function sA(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;lr(this,e).ease=i}}function oA(e){if(typeof e!="function")throw new Error;return this.each(sA(this._id,e))}function aA(e){typeof e!="function"&&(e=Fk(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var l=n[o],u=l.length,c=s[o]=[],f,h=0;h<u;++h)(f=l[h])&&e.call(f,f.__data__,h,l)&&c.push(f);return new Rr(s,this._parents,this._name,this._id)}function lA(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,s=n.length,o=i.length,l=Math.min(s,o),u=new Array(s),c=0;c<l;++c)for(var f=n[c],h=i[c],p=f.length,m=u[c]=new Array(p),y,w=0;w<p;++w)(y=f[w]||h[w])&&(m[w]=y);for(;c<s;++c)u[c]=n[c];return new Rr(u,this._parents,this._name,this._id)}function uA(e){return(e+"").trim().split(/^|\s+/).every(function(n){var i=n.indexOf(".");return i>=0&&(n=n.slice(0,i)),!n||n==="start"})}function cA(e,n,i){var s,o,l=uA(n)?Qg:lr;return function(){var u=l(this,e),c=u.on;c!==s&&(o=(s=c).copy()).on(n,i),u.on=o}}function dA(e,n){var i=this._id;return arguments.length<2?Xn(this.node(),i).on.on(e):this.each(cA(i,e,n))}function fA(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function hA(){return this.on("end.remove",fA(this._id))}function pA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Gg(e));for(var s=this._groups,o=s.length,l=new Array(o),u=0;u<o;++u)for(var c=s[u],f=c.length,h=l[u]=new Array(f),p,m,y=0;y<f;++y)(p=c[y])&&(m=e.call(p,p.__data__,y,c))&&("__data__"in p&&(m.__data__=p.__data__),h[y]=m,Ul(h[y],n,i,y,h,Xn(p,i)));return new Rr(l,this._parents,n,i)}function mA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Dk(e));for(var s=this._groups,o=s.length,l=[],u=[],c=0;c<o;++c)for(var f=s[c],h=f.length,p,m=0;m<h;++m)if(p=f[m]){for(var y=e.call(p,p.__data__,m,f),w,j=Xn(p,i),_=0,S=y.length;_<S;++_)(w=y[_])&&Ul(w,n,i,_,y,j);l.push(y),u.push(p)}return new Rr(l,u,n,i)}var gA=Zo.prototype.constructor;function vA(){return new gA(this._groups,this._parents)}function yA(e,n){var i,s,o;return function(){var l=zs(this,e),u=(this.style.removeProperty(e),zs(this,e));return l===u?null:l===i&&u===s?o:o=n(i=l,s=u)}}function uE(e){return function(){this.style.removeProperty(e)}}function wA(e,n,i){var s,o=i+"",l;return function(){var u=zs(this,e);return u===o?null:u===s?l:l=n(s=u,i)}}function xA(e,n,i){var s,o,l;return function(){var u=zs(this,e),c=i(this),f=c+"";return c==null&&(f=c=(this.style.removeProperty(e),zs(this,e))),u===f?null:u===s&&f===o?l:(o=f,l=n(s=u,c))}}function _A(e,n){var i,s,o,l="style."+n,u="end."+l,c;return function(){var f=lr(this,e),h=f.on,p=f.value[l]==null?c||(c=uE(n)):void 0;(h!==i||o!==p)&&(s=(i=h).copy()).on(u,o=p),f.on=s}}function SA(e,n,i){var s=(e+="")=="transform"?S2:lE;return n==null?this.styleTween(e,yA(e,s)).on("end.style."+e,uE(e)):typeof n=="function"?this.styleTween(e,xA(e,s,Zg(this,"style."+e,n))).each(_A(this._id,e)):this.styleTween(e,wA(e,s,n),i).on("end.style."+e,null)}function bA(e,n,i){return function(s){this.style.setProperty(e,n.call(this,s),i)}}function kA(e,n,i){var s,o;function l(){var u=n.apply(this,arguments);return u!==o&&(s=(o=u)&&bA(e,u,i)),s}return l._value=n,l}function EA(e,n,i){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;return this.tween(s,kA(e,n,i??""))}function NA(e){return function(){this.textContent=e}}function CA(e){return function(){var n=e(this);this.textContent=n??""}}function jA(e){return this.tween("text",typeof e=="function"?CA(Zg(this,"text",e)):NA(e==null?"":e+""))}function RA(e){return function(n){this.textContent=e.call(this,n)}}function TA(e){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&RA(o)),n}return s._value=e,s}function AA(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,TA(e))}function IA(){for(var e=this._name,n=this._id,i=cE(),s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,f,h=0;h<c;++h)if(f=u[h]){var p=Xn(f,n);Ul(f,e,i,h,u,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new Rr(s,this._parents,e,i)}function MA(){var e,n,i=this,s=i._id,o=i.size();return new Promise(function(l,u){var c={value:u},f={value:function(){--o===0&&l()}};i.each(function(){var h=lr(this,s),p=h.on;p!==e&&(n=(e=p).copy(),n._.cancel.push(c),n._.interrupt.push(c),n._.end.push(f)),h.on=n}),o===0&&l()})}var PA=0;function Rr(e,n,i,s){this._groups=e,this._parents=n,this._name=i,this._id=s}function cE(){return++PA}var Er=Zo.prototype;Rr.prototype={constructor:Rr,select:pA,selectAll:mA,selectChild:Er.selectChild,selectChildren:Er.selectChildren,filter:aA,merge:lA,selection:vA,transition:IA,call:Er.call,nodes:Er.nodes,node:Er.node,size:Er.size,empty:Er.empty,each:Er.each,on:dA,attr:V2,attrTween:X2,style:SA,styleTween:EA,text:jA,textTween:AA,remove:hA,tween:$2,delay:J2,duration:nA,ease:iA,easeVarying:oA,end:MA,[Symbol.iterator]:Er[Symbol.iterator]};function OA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var qA={time:null,delay:0,duration:250,ease:OA};function LA(e,n){for(var i;!(i=e.__transition)||!(i=i[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return i}function $A(e){var n,i;e instanceof Rr?(n=e._id,e=e._name):(n=cE(),(i=qA).time=Xg(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,f,h=0;h<c;++h)(f=u[h])&&Ul(f,e,n,h,u,i||LA(f,n));return new Rr(s,this._parents,e,n)}Zo.prototype.interrupt=O2;Zo.prototype.transition=$A;const hl=e=>()=>e;function DA(e,{sourceEvent:n,target:i,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function Cr(e,n,i){this.k=e,this.x=n,this.y=i}Cr.prototype={constructor:Cr,scale:function(e){return e===1?this:new Cr(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Cr(this.k,this.x+this.k*e,this.y+this.k*n)},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 jr=new Cr(1,0,0);Cr.prototype;function Xc(e){e.stopImmediatePropagation()}function Io(e){e.preventDefault(),e.stopImmediatePropagation()}function FA(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function zA(){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 Sw(){return this.__zoom||jr}function BA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function UA(){return navigator.maxTouchPoints||"ontouchstart"in this}function HA(e,n,i){var s=e.invertX(n[0][0])-i[0][0],o=e.invertX(n[1][0])-i[1][0],l=e.invertY(n[0][1])-i[0][1],u=e.invertY(n[1][1])-i[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function dE(){var e=FA,n=zA,i=HA,s=BA,o=UA,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,f=C2,h=Fl("start","zoom","end"),p,m,y,w=500,j=150,_=0,S=10;function b(A){A.property("__zoom",Sw).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",q).filter(o).on("touchstart.zoom",B).on("touchmove.zoom",J).on("touchend.zoom touchcancel.zoom",Q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(A,H,U,ne){var Y=A.selection?A.selection():A;Y.property("__zoom",Sw),A!==Y?I(A,H,U,ne):Y.interrupt().each(function(){O(this,arguments).event(ne).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},b.scaleBy=function(A,H,U,ne){b.scaleTo(A,function(){var Y=this.__zoom.k,L=typeof H=="function"?H.apply(this,arguments):H;return Y*L},U,ne)},b.scaleTo=function(A,H,U,ne){b.transform(A,function(){var Y=n.apply(this,arguments),L=this.__zoom,G=U==null?C(Y):typeof U=="function"?U.apply(this,arguments):U,k=L.invert(G),$=typeof H=="function"?H.apply(this,arguments):H;return i(N(E(L,$),G,k),Y,u)},U,ne)},b.translateBy=function(A,H,U,ne){b.transform(A,function(){return i(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof U=="function"?U.apply(this,arguments):U),n.apply(this,arguments),u)},null,ne)},b.translateTo=function(A,H,U,ne,Y){b.transform(A,function(){var L=n.apply(this,arguments),G=this.__zoom,k=ne==null?C(L):typeof ne=="function"?ne.apply(this,arguments):ne;return i(jr.translate(k[0],k[1]).scale(G.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof U=="function"?-U.apply(this,arguments):-U),L,u)},ne,Y)};function E(A,H){return H=Math.max(l[0],Math.min(l[1],H)),H===A.k?A:new Cr(H,A.x,A.y)}function N(A,H,U){var ne=H[0]-U[0]*A.k,Y=H[1]-U[1]*A.k;return ne===A.x&&Y===A.y?A:new Cr(A.k,ne,Y)}function C(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function I(A,H,U,ne){A.on("start.zoom",function(){O(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(ne).end()}).tween("zoom",function(){var Y=this,L=arguments,G=O(Y,L).event(ne),k=n.apply(Y,L),$=U==null?C(k):typeof U=="function"?U.apply(Y,L):U,oe=Math.max(k[1][0]-k[0][0],k[1][1]-k[0][1]),D=Y.__zoom,X=typeof H=="function"?H.apply(Y,L):H,ee=f(D.invert($).concat(oe/D.k),X.invert($).concat(oe/X.k));return function(se){if(se===1)se=X;else{var ae=ee(se),pe=oe/ae[2];se=new Cr(pe,$[0]-ae[0]*pe,$[1]-ae[1]*pe)}G.zoom(null,se)}})}function O(A,H,U){return!U&&A.__zooming||new P(A,H)}function P(A,H){this.that=A,this.args=H,this.active=0,this.sourceEvent=null,this.extent=n.apply(A,H),this.taps=0}P.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,H){return this.mouse&&A!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var H=In(this.that).datum();h.call(A,this.that,new DA(A,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),H)}};function z(A,...H){if(!e.apply(this,arguments))return;var U=O(this,H).event(A),ne=this.__zoom,Y=Math.max(l[0],Math.min(l[1],ne.k*Math.pow(2,s.apply(this,arguments)))),L=Wn(A);if(U.wheel)(U.mouse[0][0]!==L[0]||U.mouse[0][1]!==L[1])&&(U.mouse[1]=ne.invert(U.mouse[0]=L)),clearTimeout(U.wheel);else{if(ne.k===Y)return;U.mouse=[L,ne.invert(L)],Cl(this),U.start()}Io(A),U.wheel=setTimeout(G,j),U.zoom("mouse",i(N(E(ne,Y),U.mouse[0],U.mouse[1]),U.extent,u));function G(){U.wheel=null,U.end()}}function T(A,...H){if(y||!e.apply(this,arguments))return;var U=A.currentTarget,ne=O(this,H,!0).event(A),Y=In(A.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",oe,!0),L=Wn(A,U),G=A.clientX,k=A.clientY;Xk(A.view),Xc(A),ne.mouse=[L,this.__zoom.invert(L)],Cl(this),ne.start();function $(D){if(Io(D),!ne.moved){var X=D.clientX-G,ee=D.clientY-k;ne.moved=X*X+ee*ee>_}ne.event(D).zoom("mouse",i(N(ne.that.__zoom,ne.mouse[0]=Wn(D,U),ne.mouse[1]),ne.extent,u))}function oe(D){Y.on("mousemove.zoom mouseup.zoom",null),Qk(D.view,ne.moved),Io(D),ne.event(D).end()}}function q(A,...H){if(e.apply(this,arguments)){var U=this.__zoom,ne=Wn(A.changedTouches?A.changedTouches[0]:A,this),Y=U.invert(ne),L=U.k*(A.shiftKey?.5:2),G=i(N(E(U,L),ne,Y),n.apply(this,H),u);Io(A),c>0?In(this).transition().duration(c).call(I,G,ne,A):In(this).call(b.transform,G,ne,A)}}function B(A,...H){if(e.apply(this,arguments)){var U=A.touches,ne=U.length,Y=O(this,H,A.changedTouches.length===ne).event(A),L,G,k,$;for(Xc(A),G=0;G<ne;++G)k=U[G],$=Wn(k,this),$=[$,this.__zoom.invert($),k.identifier],Y.touch0?!Y.touch1&&Y.touch0[2]!==$[2]&&(Y.touch1=$,Y.taps=0):(Y.touch0=$,L=!0,Y.taps=1+!!p);p&&(p=clearTimeout(p)),L&&(Y.taps<2&&(m=$[0],p=setTimeout(function(){p=null},w)),Cl(this),Y.start())}}function J(A,...H){if(this.__zooming){var U=O(this,H).event(A),ne=A.changedTouches,Y=ne.length,L,G,k,$;for(Io(A),L=0;L<Y;++L)G=ne[L],k=Wn(G,this),U.touch0&&U.touch0[2]===G.identifier?U.touch0[0]=k:U.touch1&&U.touch1[2]===G.identifier&&(U.touch1[0]=k);if(G=U.that.__zoom,U.touch1){var oe=U.touch0[0],D=U.touch0[1],X=U.touch1[0],ee=U.touch1[1],se=(se=X[0]-oe[0])*se+(se=X[1]-oe[1])*se,ae=(ae=ee[0]-D[0])*ae+(ae=ee[1]-D[1])*ae;G=E(G,Math.sqrt(se/ae)),k=[(oe[0]+X[0])/2,(oe[1]+X[1])/2],$=[(D[0]+ee[0])/2,(D[1]+ee[1])/2]}else if(U.touch0)k=U.touch0[0],$=U.touch0[1];else return;U.zoom("touch",i(N(G,k,$),U.extent,u))}}function Q(A,...H){if(this.__zooming){var U=O(this,H).event(A),ne=A.changedTouches,Y=ne.length,L,G;for(Xc(A),y&&clearTimeout(y),y=setTimeout(function(){y=null},w),L=0;L<Y;++L)G=ne[L],U.touch0&&U.touch0[2]===G.identifier?delete U.touch0:U.touch1&&U.touch1[2]===G.identifier&&delete U.touch1;if(U.touch1&&!U.touch0&&(U.touch0=U.touch1,delete U.touch1),U.touch0)U.touch0[1]=this.__zoom.invert(U.touch0[0]);else if(U.end(),U.taps===2&&(G=Wn(G,this),Math.hypot(m[0]-G[0],m[1]-G[1])<S)){var k=In(this).on("dblclick.zoom");k&&k.apply(this,arguments)}}}return b.wheelDelta=function(A){return arguments.length?(s=typeof A=="function"?A:hl(+A),b):s},b.filter=function(A){return arguments.length?(e=typeof A=="function"?A:hl(!!A),b):e},b.touchable=function(A){return arguments.length?(o=typeof A=="function"?A:hl(!!A),b):o},b.extent=function(A){return arguments.length?(n=typeof A=="function"?A:hl([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),b):n},b.scaleExtent=function(A){return arguments.length?(l[0]=+A[0],l[1]=+A[1],b):[l[0],l[1]]},b.translateExtent=function(A){return arguments.length?(u[0][0]=+A[0][0],u[1][0]=+A[1][0],u[0][1]=+A[0][1],u[1][1]=+A[1][1],b):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},b.constrain=function(A){return arguments.length?(i=A,b):i},b.duration=function(A){return arguments.length?(c=+A,b):c},b.interpolate=function(A){return arguments.length?(f=A,b):f},b.on=function(){var A=h.on.apply(h,arguments);return A===h?b:A},b.clickDistance=function(A){return arguments.length?(_=(A=+A)*A,b):Math.sqrt(_)},b.tapDistance=function(A){return arguments.length?(S=+A,b):S},b}qk();const Hl=M.createContext(null),VA=Hl.Provider,Tr={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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,n)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?n.targetHandle:n.sourceHandle}", edge id: ${n.id}.`,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.`},fE=Tr.error001();function Ze(e,n){const i=M.useContext(Hl);if(i===null)throw new Error(fE);return Lk(i,e,n)}const At=()=>{const e=M.useContext(Hl);if(e===null)throw new Error(fE);return M.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},WA=e=>e.userSelectionActive?"none":"all";function Jg({position:e,children:n,className:i,style:s,...o}){const l=Ze(WA),u=`${e}`.split("-");return le.createElement("div",{className:zt(["react-flow__panel",i,...u]),style:{...s,pointerEvents:l},...o},n)}function GA({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:le.createElement(Jg,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},le.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const YA=({x:e,y:n,label:i,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:l={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:f,className:h,...p})=>{const m=M.useRef(null),[y,w]=M.useState({x:0,y:0,width:0,height:0}),j=zt(["react-flow__edge-textwrapper",h]);return M.useEffect(()=>{if(m.current){const _=m.current.getBBox();w({x:_.x,y:_.y,width:_.width,height:_.height})}},[i]),typeof i>"u"||!i?null:le.createElement("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:j,visibility:y.width?"visible":"hidden",...p},o&&le.createElement("rect",{width:y.width+2*u[0],x:-u[0],y:-u[1],height:y.height+2*u[1],className:"react-flow__edge-textbg",style:l,rx:c,ry:c}),le.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:s},i),f)};var KA=M.memo(YA);const ev=e=>({width:e.offsetWidth,height:e.offsetHeight}),Us=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),tv=(e={x:0,y:0},n)=>({x:Us(e.x,n[0][0],n[1][0]),y:Us(e.y,n[0][1],n[1][1])}),bw=(e,n,i)=>e<n?Us(Math.abs(e-n),1,50)/50:e>i?-Us(Math.abs(e-i),1,50)/50:0,hE=(e,n)=>{const i=bw(e.x,35,n.width-35)*20,s=bw(e.y,35,n.height-35)*20;return[i,s]},pE=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},mE=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),Yo=({x:e,y:n,width:i,height:s})=>({x:e,y:n,x2:e+i,y2:n+s}),gE=({x:e,y:n,x2:i,y2:s})=>({x:e,y:n,width:i-e,height:s-n}),kw=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),XA=(e,n)=>gE(mE(Yo(e),Yo(n))),Ig=(e,n)=>{const i=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),s=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(i*s)},QA=e=>Mn(e.width)&&Mn(e.height)&&Mn(e.x)&&Mn(e.y),Mn=e=>!isNaN(e)&&isFinite(e),yt=Symbol.for("internals"),vE=["Enter"," ","Escape"],ZA=(e,n)=>{},JA=e=>"nativeEvent"in e;function Mg(e){var o,l;const n=JA(e)?e.nativeEvent:e,i=((l=(o=n.composedPath)==null?void 0:o.call(n))==null?void 0:l[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(i==null?void 0:i.nodeName)||(i==null?void 0:i.hasAttribute("contenteditable"))||!!(i!=null&&i.closest(".nokey"))}const yE=e=>"clientX"in e,ii=(e,n)=>{var l,u;const i=yE(e),s=i?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,o=i?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:s-((n==null?void 0:n.left)??0),y:o-((n==null?void 0:n.top)??0)}},Pl=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},ea=({id:e,path:n,labelX:i,labelY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:w=20})=>le.createElement(le.Fragment,null,le.createElement("path",{id:e,style:p,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),w&&le.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),o&&Mn(i)&&Mn(s)?le.createElement(KA,{x:i,y:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h}):null);ea.displayName="BaseEdge";function Mo(e,n,i){return i===void 0?i:s=>{const o=n().edges.find(l=>l.id===e);o&&i(s,{...o})}}function wE({sourceX:e,sourceY:n,targetX:i,targetY:s}){const o=Math.abs(i-e)/2,l=i<e?i+o:i-o,u=Math.abs(s-n)/2,c=s<n?s+u:s-u;return[l,c,o,u]}function xE({sourceX:e,sourceY:n,targetX:i,targetY:s,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:c}){const f=e*.125+o*.375+u*.375+i*.125,h=n*.125+l*.375+c*.375+s*.125,p=Math.abs(f-e),m=Math.abs(h-n);return[f,h,p,m]}var Wi;(function(e){e.Strict="strict",e.Loose="loose"})(Wi||(Wi={}));var zi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(zi||(zi={}));var Ko;(function(e){e.Partial="partial",e.Full="full"})(Ko||(Ko={}));var ri;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ri||(ri={}));var Ol;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ol||(Ol={}));var Ce;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ce||(Ce={}));function Ew({pos:e,x1:n,y1:i,x2:s,y2:o}){return e===Ce.Left||e===Ce.Right?[.5*(n+s),i]:[n,.5*(i+o)]}function _E({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top}){const[u,c]=Ew({pos:i,x1:e,y1:n,x2:s,y2:o}),[f,h]=Ew({pos:l,x1:s,y1:o,x2:e,y2:n}),[p,m,y,w]=xE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:f,targetControlY:h});return[`M${e},${n} C${u},${c} ${f},${h} ${s},${o}`,p,m,y,w]}const nv=M.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:j,interactionWidth:_})=>{const[S,b,E]=_E({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:l});return le.createElement(ea,{path:S,labelX:b,labelY:E,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:j,interactionWidth:_})});nv.displayName="SimpleBezierEdge";const Nw={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},eI=({source:e,sourcePosition:n=Ce.Bottom,target:i})=>n===Ce.Left||n===Ce.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},Cw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function tI({source:e,sourcePosition:n=Ce.Bottom,target:i,targetPosition:s=Ce.Top,center:o,offset:l}){const u=Nw[n],c=Nw[s],f={x:e.x+u.x*l,y:e.y+u.y*l},h={x:i.x+c.x*l,y:i.y+c.y*l},p=eI({source:f,sourcePosition:n,target:h}),m=p.x!==0?"x":"y",y=p[m];let w=[],j,_;const S={x:0,y:0},b={x:0,y:0},[E,N,C,I]=wE({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(u[m]*c[m]===-1){j=o.x??E,_=o.y??N;const P=[{x:j,y:f.y},{x:j,y:h.y}],z=[{x:f.x,y:_},{x:h.x,y:_}];u[m]===y?w=m==="x"?P:z:w=m==="x"?z:P}else{const P=[{x:f.x,y:h.y}],z=[{x:h.x,y:f.y}];if(m==="x"?w=u.x===y?z:P:w=u.y===y?P:z,n===s){const Q=Math.abs(e[m]-i[m]);if(Q<=l){const A=Math.min(l-1,l-Q);u[m]===y?S[m]=(f[m]>e[m]?-1:1)*A:b[m]=(h[m]>i[m]?-1:1)*A}}if(n!==s){const Q=m==="x"?"y":"x",A=u[m]===c[Q],H=f[Q]>h[Q],U=f[Q]<h[Q];(u[m]===1&&(!A&&H||A&&U)||u[m]!==1&&(!A&&U||A&&H))&&(w=m==="x"?P:z)}const T={x:f.x+S.x,y:f.y+S.y},q={x:h.x+b.x,y:h.y+b.y},B=Math.max(Math.abs(T.x-w[0].x),Math.abs(q.x-w[0].x)),J=Math.max(Math.abs(T.y-w[0].y),Math.abs(q.y-w[0].y));B>=J?(j=(T.x+q.x)/2,_=w[0].y):(j=w[0].x,_=(T.y+q.y)/2)}return[[e,{x:f.x+S.x,y:f.y+S.y},...w,{x:h.x+b.x,y:h.y+b.y},i],j,_,C,I]}function nI(e,n,i,s){const o=Math.min(Cw(e,n)/2,Cw(n,i)/2,s),{x:l,y:u}=n;if(e.x===l&&l===i.x||e.y===u&&u===i.y)return`L${l} ${u}`;if(e.y===u){const h=e.x<i.x?-1:1,p=e.y<i.y?1:-1;return`L ${l+o*h},${u}Q ${l},${u} ${l},${u+o*p}`}const c=e.x<i.x?1:-1,f=e.y<i.y?-1:1;return`L ${l},${u+o*f}Q ${l},${u} ${l+o*c},${u}`}function Pg({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top,borderRadius:u=5,centerX:c,centerY:f,offset:h=20}){const[p,m,y,w,j]=tI({source:{x:e,y:n},sourcePosition:i,target:{x:s,y:o},targetPosition:l,center:{x:c,y:f},offset:h});return[p.reduce((S,b,E)=>{let N="";return E>0&&E<p.length-1?N=nI(p[E-1],b,p[E+1],u):N=`${E===0?"M":"L"}${b.x} ${b.y}`,S+=N,S},""),m,y,w,j]}const Vl=M.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,sourcePosition:m=Ce.Bottom,targetPosition:y=Ce.Top,markerEnd:w,markerStart:j,pathOptions:_,interactionWidth:S})=>{const[b,E,N]=Pg({sourceX:e,sourceY:n,sourcePosition:m,targetX:i,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return le.createElement(ea,{path:b,labelX:E,labelY:N,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:w,markerStart:j,interactionWidth:S})});Vl.displayName="SmoothStepEdge";const rv=M.memo(e=>{var n;return le.createElement(Vl,{...e,pathOptions:M.useMemo(()=>{var i;return{borderRadius:0,offset:(i=e.pathOptions)==null?void 0:i.offset}},[(n=e.pathOptions)==null?void 0:n.offset])})});rv.displayName="StepEdge";function rI({sourceX:e,sourceY:n,targetX:i,targetY:s}){const[o,l,u,c]=wE({sourceX:e,sourceY:n,targetX:i,targetY:s});return[`M ${e},${n}L ${i},${s}`,o,l,u,c]}const iv=M.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:w})=>{const[j,_,S]=rI({sourceX:e,sourceY:n,targetX:i,targetY:s});return le.createElement(ea,{path:j,labelX:_,labelY:S,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:w})});iv.displayName="StraightEdge";function pl(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function jw({pos:e,x1:n,y1:i,x2:s,y2:o,c:l}){switch(e){case Ce.Left:return[n-pl(n-s,l),i];case Ce.Right:return[n+pl(s-n,l),i];case Ce.Top:return[n,i-pl(i-o,l)];case Ce.Bottom:return[n,i+pl(o-i,l)]}}function SE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:l=Ce.Top,curvature:u=.25}){const[c,f]=jw({pos:i,x1:e,y1:n,x2:s,y2:o,c:u}),[h,p]=jw({pos:l,x1:s,y1:o,x2:e,y2:n,c:u}),[m,y,w,j]=xE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:c,sourceControlY:f,targetControlX:h,targetControlY:p});return[`M${e},${n} C${c},${f} ${h},${p} ${s},${o}`,m,y,w,j]}const ql=M.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:l=Ce.Top,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:j,pathOptions:_,interactionWidth:S})=>{const[b,E,N]=SE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:l,curvature:_==null?void 0:_.curvature});return le.createElement(ea,{path:b,labelX:E,labelY:N,label:u,labelStyle:c,labelShowBg:f,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:j,interactionWidth:S})});ql.displayName="BezierEdge";const sv=M.createContext(null),iI=sv.Provider;sv.Consumer;const sI=()=>M.useContext(sv),oI=e=>"id"in e&&"source"in e&&"target"in e,aI=({source:e,sourceHandle:n,target:i,targetHandle:s})=>`reactflow__edge-${e}${n||""}-${i}${s||""}`,Og=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,lI=(e,n)=>n.some(i=>i.source===e.source&&i.target===e.target&&(i.sourceHandle===e.sourceHandle||!i.sourceHandle&&!e.sourceHandle)&&(i.targetHandle===e.targetHandle||!i.targetHandle&&!e.targetHandle)),uI=(e,n)=>{if(!e.source||!e.target)return n;let i;return oI(e)?i={...e}:i={...e,id:aI(e)},lI(i,n)?n:n.concat(i)},qg=({x:e,y:n},[i,s,o],l,[u,c])=>{const f={x:(e-i)/o,y:(n-s)/o};return l?{x:u*Math.round(f.x/u),y:c*Math.round(f.y/c)}:f},bE=({x:e,y:n},[i,s,o])=>({x:e*o+i,y:n*o+s}),Ui=(e,n=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const i=(e.width??0)*n[0],s=(e.height??0)*n[1],o={x:e.position.x-i,y:e.position.y-s};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-i,y:e.positionAbsolute.y-s}:o}},Wl=(e,n=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const i=e.reduce((s,o)=>{const{x:l,y:u}=Ui(o,n).positionAbsolute;return mE(s,Yo({x:l,y:u,width:o.width||0,height:o.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return gE(i)},kE=(e,n,[i,s,o]=[0,0,1],l=!1,u=!1,c=[0,0])=>{const f={x:(n.x-i)/o,y:(n.y-s)/o,width:n.width/o,height:n.height/o},h=[];return e.forEach(p=>{const{width:m,height:y,selectable:w=!0,hidden:j=!1}=p;if(u&&!w||j)return!1;const{positionAbsolute:_}=Ui(p,c),S={x:_.x,y:_.y,width:m||0,height:y||0},b=Ig(f,S),E=typeof m>"u"||typeof y>"u"||m===null||y===null,N=l&&b>0,C=(m||0)*(y||0);(E||N||b>=C||p.dragging)&&h.push(p)}),h},EE=(e,n)=>{const i=e.map(s=>s.id);return n.filter(s=>i.includes(s.source)||i.includes(s.target))},NE=(e,n,i,s,o,l=.1)=>{const u=n/(e.width*(1+l)),c=i/(e.height*(1+l)),f=Math.min(u,c),h=Us(f,s,o),p=e.x+e.width/2,m=e.y+e.height/2,y=n/2-p*h,w=i/2-m*h;return{x:y,y:w,zoom:h}},Di=(e,n=0)=>e.transition().duration(n);function Rw(e,n,i,s){return(n[i]||[]).reduce((o,l)=>{var u,c;return`${e.id}-${l.id}-${i}`!==s&&o.push({id:l.id||null,type:i,nodeId:e.id,x:(((u=e.positionAbsolute)==null?void 0:u.x)??0)+l.x+l.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+l.y+l.height/2}),o},[])}function cI(e,n,i,s,o,l){const{x:u,y:c}=ii(e),h=n.elementsFromPoint(u,c).find(j=>j.classList.contains("react-flow__handle"));if(h){const j=h.getAttribute("data-nodeid");if(j){const _=ov(void 0,h),S=h.getAttribute("data-handleid"),b=l({nodeId:j,id:S,type:_});if(b){const E=o.find(N=>N.nodeId===j&&N.type===_&&N.id===S);return{handle:{id:S,type:_,nodeId:j,x:(E==null?void 0:E.x)||i.x,y:(E==null?void 0:E.y)||i.y},validHandleResult:b}}}}let p=[],m=1/0;if(o.forEach(j=>{const _=Math.sqrt((j.x-i.x)**2+(j.y-i.y)**2);if(_<=s){const S=l(j);_<=m&&(_<m?p=[{handle:j,validHandleResult:S}]:_===m&&p.push({handle:j,validHandleResult:S}),m=_)}}),!p.length)return{handle:null,validHandleResult:CE()};if(p.length===1)return p[0];const y=p.some(({validHandleResult:j})=>j.isValid),w=p.some(({handle:j})=>j.type==="target");return p.find(({handle:j,validHandleResult:_})=>w?j.type==="target":y?_.isValid:!0)||p[0]}const dI={source:null,target:null,sourceHandle:null,targetHandle:null},CE=()=>({handleDomNode:null,isValid:!1,connection:dI,endHandle:null});function jE(e,n,i,s,o,l,u){const c=o==="target",f=u.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),h={...CE(),handleDomNode:f};if(f){const p=ov(void 0,f),m=f.getAttribute("data-nodeid"),y=f.getAttribute("data-handleid"),w=f.classList.contains("connectable"),j=f.classList.contains("connectableend"),_={source:c?m:i,sourceHandle:c?y:s,target:c?i:m,targetHandle:c?s:y};h.connection=_,w&&j&&(n===Wi.Strict?c&&p==="source"||!c&&p==="target":m!==i||y!==s)&&(h.endHandle={nodeId:m,handleId:y,type:p},h.isValid=l(_))}return h}function fI({nodes:e,nodeId:n,handleId:i,handleType:s}){return e.reduce((o,l)=>{if(l[yt]){const{handleBounds:u}=l[yt];let c=[],f=[];u&&(c=Rw(l,u,"source",`${n}-${i}-${s}`),f=Rw(l,u,"target",`${n}-${i}-${s}`)),o.push(...c,...f)}return o},[])}function ov(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Qc(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function hI(e,n){let i=null;return n?i="valid":e&&!n&&(i="invalid"),i}function RE({event:e,handleId:n,nodeId:i,onConnect:s,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:f,onReconnectEnd:h}){const p=pE(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:w,connectionRadius:j,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:E}=l();let N=0,C;const{x:I,y:O}=ii(e),P=p==null?void 0:p.elementFromPoint(I,O),z=ov(f,P),T=y==null?void 0:y.getBoundingClientRect();if(!T||!z)return;let q,B=ii(e,T),J=!1,Q=null,A=!1,H=null;const U=fI({nodes:b(),nodeId:i,handleId:n,handleType:z}),ne=()=>{if(!w)return;const[G,k]=hE(B,T);S({x:G,y:k}),N=requestAnimationFrame(ne)};u({connectionPosition:B,connectionStatus:null,connectionNodeId:i,connectionHandleId:n,connectionHandleType:z,connectionStartHandle:{nodeId:i,handleId:n,type:z},connectionEndHandle:null}),_==null||_(e,{nodeId:i,handleId:n,handleType:z});function Y(G){const{transform:k}=l();B=ii(G,T);const{handle:$,validHandleResult:oe}=cI(G,p,qg(B,k,!1,[1,1]),j,U,D=>jE(D,m,i,n,o?"target":"source",c,p));if(C=$,J||(ne(),J=!0),H=oe.handleDomNode,Q=oe.connection,A=oe.isValid,u({connectionPosition:C&&A?bE({x:C.x,y:C.y},k):B,connectionStatus:hI(!!C,A),connectionEndHandle:oe.endHandle}),!C&&!A&&!H)return Qc(q);Q.source!==Q.target&&H&&(Qc(q),q=H,H.classList.add("connecting","react-flow__handle-connecting"),H.classList.toggle("valid",A),H.classList.toggle("react-flow__handle-valid",A))}function L(G){var k,$;(C||H)&&Q&&A&&(s==null||s(Q)),($=(k=l()).onConnectEnd)==null||$.call(k,G),f&&(h==null||h(G)),Qc(q),E(),cancelAnimationFrame(N),J=!1,A=!1,Q=null,H=null,p.removeEventListener("mousemove",Y),p.removeEventListener("mouseup",L),p.removeEventListener("touchmove",Y),p.removeEventListener("touchend",L)}p.addEventListener("mousemove",Y),p.addEventListener("mouseup",L),p.addEventListener("touchmove",Y),p.addEventListener("touchend",L)}const Tw=()=>!0,pI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),mI=(e,n,i)=>s=>{const{connectionStartHandle:o,connectionEndHandle:l,connectionClickStartHandle:u}=s;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===n&&(o==null?void 0:o.type)===i||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===n&&(l==null?void 0:l.type)===i,clickConnecting:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===n&&(u==null?void 0:u.type)===i}},TE=M.forwardRef(({type:e="source",position:n=Ce.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:u,onConnect:c,children:f,className:h,onMouseDown:p,onTouchStart:m,...y},w)=>{var T,q;const j=u||null,_=e==="target",S=At(),b=sI(),{connectOnClick:E,noPanClassName:N}=Ze(pI,Tt),{connecting:C,clickConnecting:I}=Ze(mI(b,j,e),Tt);b||(q=(T=S.getState()).onError)==null||q.call(T,"010",Tr.error010());const O=B=>{const{defaultEdgeOptions:J,onConnect:Q,hasDefaultEdges:A}=S.getState(),H={...J,...B};if(A){const{edges:U,setEdges:ne}=S.getState();ne(uI(H,U))}Q==null||Q(H),c==null||c(H)},P=B=>{if(!b)return;const J=yE(B);o&&(J&&B.button===0||!J)&&RE({event:B,handleId:j,nodeId:b,onConnect:O,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:i||S.getState().isValidConnection||Tw}),J?p==null||p(B):m==null||m(B)},z=B=>{const{onClickConnectStart:J,onClickConnectEnd:Q,connectionClickStartHandle:A,connectionMode:H,isValidConnection:U}=S.getState();if(!b||!A&&!o)return;if(!A){J==null||J(B,{nodeId:b,handleId:j,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:j}});return}const ne=pE(B.target),Y=i||U||Tw,{connection:L,isValid:G}=jE({nodeId:b,id:j,type:e},H,A.nodeId,A.handleId||null,A.type,Y,ne);G&&O(L),Q==null||Q(B),S.setState({connectionClickStartHandle:null})};return le.createElement("div",{"data-handleid":j,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${j}-${e}`,className:zt(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",N,h,{source:!_,target:_,connectable:s,connectablestart:o,connectableend:l,connecting:I,connectionindicator:s&&(o&&!C||l&&C)}]),onMouseDown:P,onTouchStart:P,onClick:E?z:void 0,ref:w,...y},f)});TE.displayName="Handle";var Hs=M.memo(TE);const AE=({data:e,isConnectable:n,targetPosition:i=Ce.Top,sourcePosition:s=Ce.Bottom})=>le.createElement(le.Fragment,null,le.createElement(Hs,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label,le.createElement(Hs,{type:"source",position:s,isConnectable:n}));AE.displayName="DefaultNode";var Lg=M.memo(AE);const IE=({data:e,isConnectable:n,sourcePosition:i=Ce.Bottom})=>le.createElement(le.Fragment,null,e==null?void 0:e.label,le.createElement(Hs,{type:"source",position:i,isConnectable:n}));IE.displayName="InputNode";var ME=M.memo(IE);const PE=({data:e,isConnectable:n,targetPosition:i=Ce.Top})=>le.createElement(le.Fragment,null,le.createElement(Hs,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label);PE.displayName="OutputNode";var OE=M.memo(PE);const av=()=>null;av.displayName="GroupNode";const gI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),ml=e=>e.id;function vI(e,n){return Tt(e.selectedNodes.map(ml),n.selectedNodes.map(ml))&&Tt(e.selectedEdges.map(ml),n.selectedEdges.map(ml))}const qE=M.memo(({onSelectionChange:e})=>{const n=At(),{selectedNodes:i,selectedEdges:s}=Ze(gI,vI);return M.useEffect(()=>{const o={nodes:i,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[i,s,e]),null});qE.displayName="SelectionListener";const yI=e=>!!e.onSelectionChange;function wI({onSelectionChange:e}){const n=Ze(yI);return e||n?le.createElement(qE,{onSelectionChange:e}):null}const xI=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Ts(e,n){M.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function Le(e,n,i){M.useEffect(()=>{typeof n<"u"&&i({[e]:n})},[n])}const _I=({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:o,onConnectStart:l,onConnectEnd:u,onClickConnectStart:c,onClickConnectEnd:f,nodesDraggable:h,nodesConnectable:p,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:w,elevateNodesOnSelect:j,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:E,onEdgesChange:N,elementsSelectable:C,connectionMode:I,snapGrid:O,snapToGrid:P,translateExtent:z,connectOnClick:T,defaultEdgeOptions:q,fitView:B,fitViewOptions:J,onNodesDelete:Q,onEdgesDelete:A,onNodeDrag:H,onNodeDragStart:U,onNodeDragStop:ne,onSelectionDrag:Y,onSelectionDragStart:L,onSelectionDragStop:G,noPanClassName:k,nodeOrigin:$,rfId:oe,autoPanOnConnect:D,autoPanOnNodeDrag:X,onError:ee,connectionRadius:se,isValidConnection:ae,nodeDragThreshold:pe})=>{const{setNodes:ge,setEdges:Ae,setDefaultNodesAndEdges:Pe,setMinZoom:Ie,setMaxZoom:Me,setTranslateExtent:ke,setNodeExtent:He,reset:ve}=Ze(xI,Tt),ye=At();return M.useEffect(()=>{const Ve=s==null?void 0:s.map(mt=>({...mt,...q}));return Pe(i,Ve),()=>{ve()}},[]),Le("defaultEdgeOptions",q,ye.setState),Le("connectionMode",I,ye.setState),Le("onConnect",o,ye.setState),Le("onConnectStart",l,ye.setState),Le("onConnectEnd",u,ye.setState),Le("onClickConnectStart",c,ye.setState),Le("onClickConnectEnd",f,ye.setState),Le("nodesDraggable",h,ye.setState),Le("nodesConnectable",p,ye.setState),Le("nodesFocusable",m,ye.setState),Le("edgesFocusable",y,ye.setState),Le("edgesUpdatable",w,ye.setState),Le("elementsSelectable",C,ye.setState),Le("elevateNodesOnSelect",j,ye.setState),Le("snapToGrid",P,ye.setState),Le("snapGrid",O,ye.setState),Le("onNodesChange",E,ye.setState),Le("onEdgesChange",N,ye.setState),Le("connectOnClick",T,ye.setState),Le("fitViewOnInit",B,ye.setState),Le("fitViewOnInitOptions",J,ye.setState),Le("onNodesDelete",Q,ye.setState),Le("onEdgesDelete",A,ye.setState),Le("onNodeDrag",H,ye.setState),Le("onNodeDragStart",U,ye.setState),Le("onNodeDragStop",ne,ye.setState),Le("onSelectionDrag",Y,ye.setState),Le("onSelectionDragStart",L,ye.setState),Le("onSelectionDragStop",G,ye.setState),Le("noPanClassName",k,ye.setState),Le("nodeOrigin",$,ye.setState),Le("rfId",oe,ye.setState),Le("autoPanOnConnect",D,ye.setState),Le("autoPanOnNodeDrag",X,ye.setState),Le("onError",ee,ye.setState),Le("connectionRadius",se,ye.setState),Le("isValidConnection",ae,ye.setState),Le("nodeDragThreshold",pe,ye.setState),Ts(e,ge),Ts(n,Ae),Ts(_,Ie),Ts(S,Me),Ts(z,ke),Ts(b,He),null},Aw={display:"none"},SI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},LE="react-flow__node-desc",$E="react-flow__edge-desc",bI="react-flow__aria-live",kI=e=>e.ariaLiveMessage;function EI({rfId:e}){const n=Ze(kI);return le.createElement("div",{id:`${bI}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:SI},n)}function NI({rfId:e,disableKeyboardA11y:n}){return le.createElement(le.Fragment,null,le.createElement("div",{id:`${LE}-${e}`,style:Aw},"Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),le.createElement("div",{id:`${$E}-${e}`,style:Aw},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&le.createElement(EI,{rfId:e}))}var Xo=(e=null,n={actInsideInputWithModifier:!0})=>{const[i,s]=M.useState(!1),o=M.useRef(!1),l=M.useRef(new Set([])),[u,c]=M.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),p=h.reduce((m,y)=>m.concat(...y),[]);return[h,p]}return[[],[]]},[e]);return M.useEffect(()=>{const f=typeof document<"u"?document:null,h=(n==null?void 0:n.target)||f;if(e!==null){const p=w=>{if(o.current=w.ctrlKey||w.metaKey||w.shiftKey,(!o.current||o.current&&!n.actInsideInputWithModifier)&&Mg(w))return!1;const _=Mw(w.code,c);l.current.add(w[_]),Iw(u,l.current,!1)&&(w.preventDefault(),s(!0))},m=w=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&Mg(w))return!1;const _=Mw(w.code,c);Iw(u,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(w[_]),w.key==="Meta"&&l.current.clear(),o.current=!1},y=()=>{l.current.clear(),s(!1)};return h==null||h.addEventListener("keydown",p),h==null||h.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{h==null||h.removeEventListener("keydown",p),h==null||h.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,s]),i};function Iw(e,n,i){return e.filter(s=>i||s.length===n.size).some(s=>s.every(o=>n.has(o)))}function Mw(e,n){return n.includes(e)?"code":"key"}function DE(e,n,i,s){var c,f;const o=e.parentNode||e.parentId;if(!o)return i;const l=n.get(o),u=Ui(l,s);return DE(l,n,{x:(i.x??0)+u.x,y:(i.y??0)+u.y,z:(((c=l[yt])==null?void 0:c.z)??0)>(i.z??0)?((f=l[yt])==null?void 0:f.z)??0:i.z??0},s)}function FE(e,n,i){e.forEach(s=>{var l;const o=s.parentNode||s.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||i!=null&&i[s.id]){const{x:u,y:c,z:f}=DE(s,e,{...s.position,z:((l=s[yt])==null?void 0:l.z)??0},n);s.positionAbsolute={x:u,y:c},s[yt].z=f,i!=null&&i[s.id]&&(s[yt].isParent=!0)}})}function Zc(e,n,i,s){const o=new Map,l={},u=s?1e3:0;return e.forEach(c=>{var w;const f=(Mn(c.zIndex)?c.zIndex:0)+(c.selected?u:0),h=n.get(c.id),p={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},m=c.parentNode||c.parentId;m&&(l[m]=!0);const y=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(p,yt,{enumerable:!1,value:{handleBounds:y||(w=h==null?void 0:h[yt])==null?void 0:w.handleBounds,z:f}}),o.set(c.id,p)}),FE(o,i,l),o}function zE(e,n={}){const{getNodes:i,width:s,height:o,minZoom:l,maxZoom:u,d3Zoom:c,d3Selection:f,fitViewOnInitDone:h,fitViewOnInit:p,nodeOrigin:m}=e(),y=n.initial&&!h&&p;if(c&&f&&(y||!n.initial)){const j=i().filter(S=>{var E;const b=n.includeHiddenNodes?S.width&&S.height:!S.hidden;return(E=n.nodes)!=null&&E.length?b&&n.nodes.some(N=>N.id===S.id):b}),_=j.every(S=>S.width&&S.height);if(j.length>0&&_){const S=Wl(j,m),{x:b,y:E,zoom:N}=NE(S,s,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),C=jr.translate(b,E).scale(N);return typeof n.duration=="number"&&n.duration>0?c.transform(Di(f,n.duration),C):c.transform(f,C),!0}}return!1}function CI(e,n){return e.forEach(i=>{const s=n.get(i.id);s&&n.set(s.id,{...s,[yt]:s[yt],selected:i.selected})}),new Map(n)}function jI(e,n){return n.map(i=>{const s=e.find(o=>o.id===i.id);return s&&(i.selected=s.selected),i})}function gl({changedNodes:e,changedEdges:n,get:i,set:s}){const{nodeInternals:o,edges:l,onNodesChange:u,onEdgesChange:c,hasDefaultNodes:f,hasDefaultEdges:h}=i();e!=null&&e.length&&(f&&s({nodeInternals:CI(e,o)}),u==null||u(e)),n!=null&&n.length&&(h&&s({edges:jI(n,l)}),c==null||c(n))}const As=()=>{},RI={zoomIn:As,zoomOut:As,zoomTo:As,getZoom:()=>1,setViewport:As,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:As,fitBounds:As,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},TI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),AI=()=>{const e=At(),{d3Zoom:n,d3Selection:i}=Ze(TI,Tt);return M.useMemo(()=>i&&n?{zoomIn:o=>n.scaleBy(Di(i,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(Di(i,o==null?void 0:o.duration),1/1.2),zoomTo:(o,l)=>n.scaleTo(Di(i,l==null?void 0:l.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,l)=>{const[u,c,f]=e.getState().transform,h=jr.translate(o.x??u,o.y??c).scale(o.zoom??f);n.transform(Di(i,l==null?void 0:l.duration),h)},getViewport:()=>{const[o,l,u]=e.getState().transform;return{x:o,y:l,zoom:u}},fitView:o=>zE(e.getState,o),setCenter:(o,l,u)=>{const{width:c,height:f,maxZoom:h}=e.getState(),p=typeof(u==null?void 0:u.zoom)<"u"?u.zoom:h,m=c/2-o*p,y=f/2-l*p,w=jr.translate(m,y).scale(p);n.transform(Di(i,u==null?void 0:u.duration),w)},fitBounds:(o,l)=>{const{width:u,height:c,minZoom:f,maxZoom:h}=e.getState(),{x:p,y:m,zoom:y}=NE(o,u,c,f,h,(l==null?void 0:l.padding)??.1),w=jr.translate(p,m).scale(y);n.transform(Di(i,l==null?void 0:l.duration),w)},project:o=>{const{transform:l,snapToGrid:u,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),qg(o,l,u,c)},screenToFlowPosition:o=>{const{transform:l,snapToGrid:u,snapGrid:c,domNode:f}=e.getState();if(!f)return o;const{x:h,y:p}=f.getBoundingClientRect(),m={x:o.x-h,y:o.y-p};return qg(m,l,u,c)},flowToScreenPosition:o=>{const{transform:l,domNode:u}=e.getState();if(!u)return o;const{x:c,y:f}=u.getBoundingClientRect(),h=bE(o,l);return{x:h.x+c,y:h.y+f}},viewportInitialized:!0}:RI,[n,i])};function ta(){const e=AI(),n=At(),i=M.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),s=M.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=M.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(S=>({...S}))},[]),l=M.useCallback(_=>{const{edges:S=[]}=n.getState();return S.find(b=>b.id===_)},[]),u=M.useCallback(_=>{const{getNodes:S,setNodes:b,hasDefaultNodes:E,onNodesChange:N}=n.getState(),C=S(),I=typeof _=="function"?_(C):_;if(E)b(I);else if(N){const O=I.length===0?C.map(P=>({type:"remove",id:P.id})):I.map(P=>({item:P,type:"reset"}));N(O)}},[]),c=M.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:E,onEdgesChange:N}=n.getState(),C=typeof _=="function"?_(S):_;if(E)b(C);else if(N){const I=C.length===0?S.map(O=>({type:"remove",id:O.id})):C.map(O=>({item:O,type:"reset"}));N(I)}},[]),f=M.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:E,hasDefaultNodes:N,onNodesChange:C}=n.getState();if(N){const O=[...b(),...S];E(O)}else if(C){const I=S.map(O=>({item:O,type:"add"}));C(I)}},[]),h=M.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:E,hasDefaultEdges:N,onEdgesChange:C}=n.getState();if(N)E([...b,...S]);else if(C){const I=S.map(O=>({item:O,type:"add"}));C(I)}},[]),p=M.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[E,N,C]=b;return{nodes:_().map(I=>({...I})),edges:S.map(I=>({...I})),viewport:{x:E,y:N,zoom:C}}},[]),m=M.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:E,edges:N,hasDefaultNodes:C,hasDefaultEdges:I,onNodesDelete:O,onEdgesDelete:P,onNodesChange:z,onEdgesChange:T}=n.getState(),q=(_||[]).map(H=>H.id),B=(S||[]).map(H=>H.id),J=E().reduce((H,U)=>{const ne=U.parentNode||U.parentId,Y=!q.includes(U.id)&&ne&&H.find(G=>G.id===ne);return(typeof U.deletable=="boolean"?U.deletable:!0)&&(q.includes(U.id)||Y)&&H.push(U),H},[]),Q=N.filter(H=>typeof H.deletable=="boolean"?H.deletable:!0),A=Q.filter(H=>B.includes(H.id));if(J||A){const H=EE(J,Q),U=[...A,...H],ne=U.reduce((Y,L)=>(Y.includes(L.id)||Y.push(L.id),Y),[]);if((I||C)&&(I&&n.setState({edges:N.filter(Y=>!ne.includes(Y.id))}),C&&(J.forEach(Y=>{b.delete(Y.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(P==null||P(U),T&&T(ne.map(Y=>({id:Y,type:"remove"})))),J.length>0&&(O==null||O(J),z)){const Y=J.map(L=>({id:L.id,type:"remove"}));z(Y)}}},[]),y=M.useCallback(_=>{const S=QA(_),b=S?null:n.getState().nodeInternals.get(_.id);return!S&&!b?[null,null,S]:[S?_:kw(b),b,S]},[]),w=M.useCallback((_,S=!0,b)=>{const[E,N,C]=y(_);return E?(b||n.getState().getNodes()).filter(I=>{if(!C&&(I.id===N.id||!I.positionAbsolute))return!1;const O=kw(I),P=Ig(O,E);return S&&P>0||P>=E.width*E.height}):[]},[]),j=M.useCallback((_,S,b=!0)=>{const[E]=y(_);if(!E)return!1;const N=Ig(E,S);return b&&N>0||N>=E.width*E.height},[]);return M.useMemo(()=>({...e,getNodes:i,getNode:s,getEdges:o,getEdge:l,setNodes:u,setEdges:c,addNodes:f,addEdges:h,toObject:p,deleteElements:m,getIntersectingNodes:w,isNodeIntersecting:j}),[e,i,s,o,l,u,c,f,h,p,m,w,j])}const II={actInsideInputWithModifier:!1};var MI=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const i=At(),{deleteElements:s}=ta(),o=Xo(e,II),l=Xo(n);M.useEffect(()=>{if(o){const{edges:u,getNodes:c}=i.getState(),f=c().filter(p=>p.selected),h=u.filter(p=>p.selected);s({nodes:f,edges:h}),i.setState({nodesSelectionActive:!1})}},[o]),M.useEffect(()=>{i.setState({multiSelectionActive:l})},[l])};function PI(e){const n=At();M.useEffect(()=>{let i;const s=()=>{var l,u;if(!e.current)return;const o=ev(e.current);(o.height===0||o.width===0)&&((u=(l=n.getState()).onError)==null||u.call(l,"004",Tr.error004())),n.setState({width:o.width||500,height:o.height||500})};return s(),window.addEventListener("resize",s),e.current&&(i=new ResizeObserver(()=>s()),i.observe(e.current)),()=>{window.removeEventListener("resize",s),i&&e.current&&i.unobserve(e.current)}},[])}const lv={position:"absolute",width:"100%",height:"100%",top:0,left:0},OI=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,vl=e=>({x:e.x,y:e.y,zoom:e.k}),Is=(e,n)=>e.target.closest(`.${n}`),Pw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Ow=e=>{const n=e.ctrlKey&&Pl()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},qI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),LI=({onMove:e,onMoveStart:n,onMoveEnd:i,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:f=zi.Free,zoomOnDoubleClick:h=!0,elementsSelectable:p,panOnDrag:m=!0,defaultViewport:y,translateExtent:w,minZoom:j,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:E,noWheelClassName:N,noPanClassName:C})=>{const I=M.useRef(),O=At(),P=M.useRef(!1),z=M.useRef(!1),T=M.useRef(null),q=M.useRef({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:J,d3ZoomHandler:Q,userSelectionActive:A}=Ze(qI,Tt),H=Xo(S),U=M.useRef(0),ne=M.useRef(!1),Y=M.useRef();return PI(T),M.useEffect(()=>{if(T.current){const L=T.current.getBoundingClientRect(),G=dE().scaleExtent([j,_]).translateExtent(w),k=In(T.current).call(G),$=jr.translate(y.x,y.y).scale(Us(y.zoom,j,_)),oe=[[0,0],[L.width,L.height]],D=G.constrain()($,oe,w);G.transform(k,D),G.wheelDelta(Ow),O.setState({d3Zoom:G,d3Selection:k,d3ZoomHandler:k.on("wheel.zoom"),transform:[D.x,D.y,D.k],domNode:T.current.closest(".react-flow")})}},[]),M.useEffect(()=>{J&&B&&(u&&!H&&!A?J.on("wheel.zoom",L=>{if(Is(L,N))return!1;L.preventDefault(),L.stopImmediatePropagation();const G=J.property("__zoom").k||1;if(L.ctrlKey&&l){const ae=Wn(L),pe=Ow(L),ge=G*Math.pow(2,pe);B.scaleTo(J,ge,ae,L);return}const k=L.deltaMode===1?20:1;let $=f===zi.Vertical?0:L.deltaX*k,oe=f===zi.Horizontal?0:L.deltaY*k;!Pl()&&L.shiftKey&&f!==zi.Vertical&&($=L.deltaY*k,oe=0),B.translateBy(J,-($/G)*c,-(oe/G)*c,{internal:!0});const D=vl(J.property("__zoom")),{onViewportChangeStart:X,onViewportChange:ee,onViewportChangeEnd:se}=O.getState();clearTimeout(Y.current),ne.current||(ne.current=!0,n==null||n(L,D),X==null||X(D)),ne.current&&(e==null||e(L,D),ee==null||ee(D),Y.current=setTimeout(()=>{i==null||i(L,D),se==null||se(D),ne.current=!1},150))},{passive:!1}):typeof Q<"u"&&J.on("wheel.zoom",function(L,G){if(!b&&L.type==="wheel"&&!L.ctrlKey||Is(L,N))return null;L.preventDefault(),Q.call(this,L,G)},{passive:!1}))},[A,u,f,J,B,Q,H,l,b,N,n,e,i]),M.useEffect(()=>{B&&B.on("start",L=>{var $,oe;if(!L.sourceEvent||L.sourceEvent.internal)return null;U.current=($=L.sourceEvent)==null?void 0:$.button;const{onViewportChangeStart:G}=O.getState(),k=vl(L.transform);P.current=!0,q.current=k,((oe=L.sourceEvent)==null?void 0:oe.type)==="mousedown"&&O.setState({paneDragging:!0}),G==null||G(k),n==null||n(L.sourceEvent,k)})},[B,n]),M.useEffect(()=>{B&&(A&&!P.current?B.on("zoom",null):A||B.on("zoom",L=>{var k;const{onViewportChange:G}=O.getState();if(O.setState({transform:[L.transform.x,L.transform.y,L.transform.k]}),z.current=!!(s&&Pw(m,U.current??0)),(e||G)&&!((k=L.sourceEvent)!=null&&k.internal)){const $=vl(L.transform);G==null||G($),e==null||e(L.sourceEvent,$)}}))},[A,B,e,m,s]),M.useEffect(()=>{B&&B.on("end",L=>{if(!L.sourceEvent||L.sourceEvent.internal)return null;const{onViewportChangeEnd:G}=O.getState();if(P.current=!1,O.setState({paneDragging:!1}),s&&Pw(m,U.current??0)&&!z.current&&s(L.sourceEvent),z.current=!1,(i||G)&&OI(q.current,L.transform)){const k=vl(L.transform);q.current=k,clearTimeout(I.current),I.current=setTimeout(()=>{G==null||G(k),i==null||i(L.sourceEvent,k)},u?150:0)}})},[B,u,m,i,s]),M.useEffect(()=>{B&&B.filter(L=>{const G=H||o,k=l&&L.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&L.button===1&&L.type==="mousedown"&&(Is(L,"react-flow__node")||Is(L,"react-flow__edge")))return!0;if(!m&&!G&&!u&&!h&&!l||A||!h&&L.type==="dblclick"||Is(L,N)&&L.type==="wheel"||Is(L,C)&&(L.type!=="wheel"||u&&L.type==="wheel"&&!H)||!l&&L.ctrlKey&&L.type==="wheel"||!G&&!u&&!k&&L.type==="wheel"||!m&&(L.type==="mousedown"||L.type==="touchstart")||Array.isArray(m)&&!m.includes(L.button)&&L.type==="mousedown")return!1;const $=Array.isArray(m)&&m.includes(L.button)||!L.button||L.button<=1;return(!L.ctrlKey||L.type==="wheel")&&$})},[A,B,o,l,u,h,m,p,H]),le.createElement("div",{className:"react-flow__renderer",ref:T,style:lv},E)},$I=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function DI(){const{userSelectionActive:e,userSelectionRect:n}=Ze($I,Tt);return e&&n?le.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}function qw(e,n){const i=n.parentNode||n.parentId,s=e.find(o=>o.id===i);if(s){const o=n.position.x+n.width-s.width,l=n.position.y+n.height-s.height;if(o>0||l>0||n.position.x<0||n.position.y<0){if(s.style={...s.style},s.style.width=s.style.width??s.width,s.style.height=s.style.height??s.height,o>0&&(s.style.width+=o),l>0&&(s.style.height+=l),n.position.x<0){const u=Math.abs(n.position.x);s.position.x=s.position.x-u,s.style.width+=u,n.position.x=0}if(n.position.y<0){const u=Math.abs(n.position.y);s.position.y=s.position.y-u,s.style.height+=u,n.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function FI(e,n){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const i=e.filter(s=>s.type==="add").map(s=>s.item);return n.reduce((s,o)=>{const l=e.filter(c=>c.id===o.id);if(l.length===0)return s.push(o),s;const u={...o};for(const c of l)if(c)switch(c.type){case"select":{u.selected=c.selected;break}case"position":{typeof c.position<"u"&&(u.position=c.position),typeof c.positionAbsolute<"u"&&(u.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(u.dragging=c.dragging),u.expandParent&&qw(s,u);break}case"dimensions":{typeof c.dimensions<"u"&&(u.width=c.dimensions.width,u.height=c.dimensions.height),typeof c.updateStyle<"u"&&(u.style={...u.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(u.resizing=c.resizing),u.expandParent&&qw(s,u);break}case"remove":return s}return s.push(u),s},i)}function zI(e,n){return FI(e,n)}const ni=(e,n)=>({id:e,type:"select",selected:n});function Os(e,n){return e.reduce((i,s)=>{const o=n.includes(s.id);return!s.selected&&o?(s.selected=!0,i.push(ni(s.id,!0))):s.selected&&!o&&(s.selected=!1,i.push(ni(s.id,!1))),i},[])}const Jc=(e,n)=>i=>{i.target===n.current&&(e==null||e(i))},BI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),BE=M.memo(({isSelecting:e,selectionMode:n=Ko.Full,panOnDrag:i,onSelectionStart:s,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:p,children:m})=>{const y=M.useRef(null),w=At(),j=M.useRef(0),_=M.useRef(0),S=M.useRef(),{userSelectionActive:b,elementsSelectable:E,dragging:N}=Ze(BI,Tt),C=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),j.current=0,_.current=0},I=Q=>{l==null||l(Q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},O=Q=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){Q.preventDefault();return}u==null||u(Q)},P=c?Q=>c(Q):void 0,z=Q=>{const{resetSelectedElements:A,domNode:H}=w.getState();if(S.current=H==null?void 0:H.getBoundingClientRect(),!E||!e||Q.button!==0||Q.target!==y.current||!S.current)return;const{x:U,y:ne}=ii(Q,S.current);A(),w.setState({userSelectionRect:{width:0,height:0,startX:U,startY:ne,x:U,y:ne}}),s==null||s(Q)},T=Q=>{const{userSelectionRect:A,nodeInternals:H,edges:U,transform:ne,onNodesChange:Y,onEdgesChange:L,nodeOrigin:G,getNodes:k}=w.getState();if(!e||!S.current||!A)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const $=ii(Q,S.current),oe=A.startX??0,D=A.startY??0,X={...A,x:$.x<oe?$.x:oe,y:$.y<D?$.y:D,width:Math.abs($.x-oe),height:Math.abs($.y-D)},ee=k(),se=kE(H,X,ne,n===Ko.Partial,!0,G),ae=EE(se,U).map(ge=>ge.id),pe=se.map(ge=>ge.id);if(j.current!==pe.length){j.current=pe.length;const ge=Os(ee,pe);ge.length&&(Y==null||Y(ge))}if(_.current!==ae.length){_.current=ae.length;const ge=Os(U,ae);ge.length&&(L==null||L(ge))}w.setState({userSelectionRect:X})},q=Q=>{if(Q.button!==0)return;const{userSelectionRect:A}=w.getState();!b&&A&&Q.target===y.current&&(I==null||I(Q)),w.setState({nodesSelectionActive:j.current>0}),C(),o==null||o(Q)},B=Q=>{b&&(w.setState({nodesSelectionActive:j.current>0}),o==null||o(Q)),C()},J=E&&(e||b);return le.createElement("div",{className:zt(["react-flow__pane",{dragging:N,selection:e}]),onClick:J?void 0:Jc(I,y),onContextMenu:Jc(O,y),onWheel:Jc(P,y),onMouseEnter:J?void 0:f,onMouseDown:J?z:void 0,onMouseMove:J?T:h,onMouseUp:J?q:void 0,onMouseLeave:J?B:p,ref:y,style:lv},m,le.createElement(DI,null))});BE.displayName="Pane";function UE(e,n){const i=e.parentNode||e.parentId;if(!i)return!1;const s=n.get(i);return s?s.selected?!0:UE(s,n):!1}function Lw(e,n,i){let s=e;do{if(s!=null&&s.matches(n))return!0;if(s===i.current)return!1;s=s.parentElement}while(s);return!1}function UI(e,n,i,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!UE(o,e))&&(o.draggable||n&&typeof o.draggable>"u")).map(o=>{var l,u;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:i.x-(((l=o.positionAbsolute)==null?void 0:l.x)??0),y:i.y-(((u=o.positionAbsolute)==null?void 0:u.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode||o.parentId,parentId:o.parentNode||o.parentId,width:o.width,height:o.height,expandParent:o.expandParent}})}function HI(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function HE(e,n,i,s,o=[0,0],l){const u=HI(e,e.extent||s);let c=u;const f=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(f&&e.width&&e.height){const m=i.get(f),{x:y,y:w}=Ui(m,o).positionAbsolute;c=m&&Mn(y)&&Mn(w)&&Mn(m.width)&&Mn(m.height)?[[y+e.width*o[0],w+e.height*o[1]],[y+m.width-e.width+e.width*o[0],w+m.height-e.height+e.height*o[1]]]:c}else l==null||l("005",Tr.error005()),c=u;else if(e.extent&&f&&e.extent!=="parent"){const m=i.get(f),{x:y,y:w}=Ui(m,o).positionAbsolute;c=[[e.extent[0][0]+y,e.extent[0][1]+w],[e.extent[1][0]+y,e.extent[1][1]+w]]}let h={x:0,y:0};if(f){const m=i.get(f);h=Ui(m,o).positionAbsolute}const p=c&&c!=="parent"?tv(n,c):n;return{position:{x:p.x-h.x,y:p.y-h.y},positionAbsolute:p}}function ed({nodeId:e,dragItems:n,nodeInternals:i}){const s=n.map(o=>({...i.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?s.find(o=>o.id===e):s[0],s]}const $w=(e,n,i,s)=>{const o=n.querySelectorAll(e);if(!o||!o.length)return null;const l=Array.from(o),u=n.getBoundingClientRect(),c={x:u.width*s[0],y:u.height*s[1]};return l.map(f=>{const h=f.getBoundingClientRect();return{id:f.getAttribute("data-handleid"),position:f.getAttribute("data-handlepos"),x:(h.left-u.left-c.x)/i,y:(h.top-u.top-c.y)/i,...ev(f)}})};function Po(e,n,i){return i===void 0?i:s=>{const o=n().nodeInternals.get(e);o&&i(s,{...o})}}function $g({id:e,store:n,unselect:i=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:l,multiSelectionActive:u,nodeInternals:c,onError:f}=n.getState(),h=c.get(e);if(!h){f==null||f("012",Tr.error012(e));return}n.setState({nodesSelectionActive:!1}),h.selected?(i||h.selected&&u)&&(l({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var p;return(p=s==null?void 0:s.current)==null?void 0:p.blur()})):o([e])}function VI(){const e=At();return M.useCallback(({sourceEvent:i})=>{const{transform:s,snapGrid:o,snapToGrid:l}=e.getState(),u=i.touches?i.touches[0].clientX:i.clientX,c=i.touches?i.touches[0].clientY:i.clientY,f={x:(u-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:l?o[0]*Math.round(f.x/o[0]):f.x,ySnapped:l?o[1]*Math.round(f.y/o[1]):f.y,...f}},[])}function td(e){return(n,i,s)=>e==null?void 0:e(n,s)}function VE({nodeRef:e,disabled:n=!1,noDragClassName:i,handleSelector:s,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=At(),[f,h]=M.useState(!1),p=M.useRef([]),m=M.useRef({x:null,y:null}),y=M.useRef(0),w=M.useRef(null),j=M.useRef({x:0,y:0}),_=M.useRef(null),S=M.useRef(!1),b=M.useRef(!1),E=M.useRef(!1),N=VI();return M.useEffect(()=>{if(e!=null&&e.current){const C=In(e.current),I=({x:z,y:T})=>{const{nodeInternals:q,onNodeDrag:B,onSelectionDrag:J,updateNodePositions:Q,nodeExtent:A,snapGrid:H,snapToGrid:U,nodeOrigin:ne,onError:Y}=c.getState();m.current={x:z,y:T};let L=!1,G={x:0,y:0,x2:0,y2:0};if(p.current.length>1&&A){const $=Wl(p.current,ne);G=Yo($)}if(p.current=p.current.map($=>{const oe={x:z-$.distance.x,y:T-$.distance.y};U&&(oe.x=H[0]*Math.round(oe.x/H[0]),oe.y=H[1]*Math.round(oe.y/H[1]));const D=[[A[0][0],A[0][1]],[A[1][0],A[1][1]]];p.current.length>1&&A&&!$.extent&&(D[0][0]=$.positionAbsolute.x-G.x+A[0][0],D[1][0]=$.positionAbsolute.x+($.width??0)-G.x2+A[1][0],D[0][1]=$.positionAbsolute.y-G.y+A[0][1],D[1][1]=$.positionAbsolute.y+($.height??0)-G.y2+A[1][1]);const X=HE($,oe,q,D,ne,Y);return L=L||$.position.x!==X.position.x||$.position.y!==X.position.y,$.position=X.position,$.positionAbsolute=X.positionAbsolute,$}),!L)return;Q(p.current,!0,!0),h(!0);const k=o?B:td(J);if(k&&_.current){const[$,oe]=ed({nodeId:o,dragItems:p.current,nodeInternals:q});k(_.current,$,oe)}},O=()=>{if(!w.current)return;const[z,T]=hE(j.current,w.current);if(z!==0||T!==0){const{transform:q,panBy:B}=c.getState();m.current.x=(m.current.x??0)-z/q[2],m.current.y=(m.current.y??0)-T/q[2],B({x:z,y:T})&&I(m.current)}y.current=requestAnimationFrame(O)},P=z=>{var ne;const{nodeInternals:T,multiSelectionActive:q,nodesDraggable:B,unselectNodesAndEdges:J,onNodeDragStart:Q,onSelectionDragStart:A}=c.getState();b.current=!0;const H=o?Q:td(A);(!u||!l)&&!q&&o&&((ne=T.get(o))!=null&&ne.selected||J()),o&&l&&u&&$g({id:o,store:c,nodeRef:e});const U=N(z);if(m.current=U,p.current=UI(T,B,U,o),H&&p.current){const[Y,L]=ed({nodeId:o,dragItems:p.current,nodeInternals:T});H(z.sourceEvent,Y,L)}};if(n)C.on(".drag",null);else{const z=t2().on("start",T=>{const{domNode:q,nodeDragThreshold:B}=c.getState();B===0&&P(T),E.current=!1;const J=N(T);m.current=J,w.current=(q==null?void 0:q.getBoundingClientRect())||null,j.current=ii(T.sourceEvent,w.current)}).on("drag",T=>{var Q,A;const q=N(T),{autoPanOnNodeDrag:B,nodeDragThreshold:J}=c.getState();if(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1&&(E.current=!0),!E.current){if(!S.current&&b.current&&B&&(S.current=!0,O()),!b.current){const H=q.xSnapped-(((Q=m==null?void 0:m.current)==null?void 0:Q.x)??0),U=q.ySnapped-(((A=m==null?void 0:m.current)==null?void 0:A.y)??0);Math.sqrt(H*H+U*U)>J&&P(T)}(m.current.x!==q.xSnapped||m.current.y!==q.ySnapped)&&p.current&&b.current&&(_.current=T.sourceEvent,j.current=ii(T.sourceEvent,w.current),I(q))}}).on("end",T=>{if(!(!b.current||E.current)&&(h(!1),S.current=!1,b.current=!1,cancelAnimationFrame(y.current),p.current)){const{updateNodePositions:q,nodeInternals:B,onNodeDragStop:J,onSelectionDragStop:Q}=c.getState(),A=o?J:td(Q);if(q(p.current,!1,!1),A){const[H,U]=ed({nodeId:o,dragItems:p.current,nodeInternals:B});A(T.sourceEvent,H,U)}}}).filter(T=>{const q=T.target;return!T.button&&(!i||!Lw(q,`.${i}`,e))&&(!s||Lw(q,s,e))});return C.call(z),()=>{C.on(".drag",null)}}}},[e,n,i,s,l,c,o,u,N]),f}function WE(){const e=At();return M.useCallback(i=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:l,getNodes:u,snapToGrid:c,snapGrid:f,onError:h,nodesDraggable:p}=e.getState(),m=u().filter(E=>E.selected&&(E.draggable||p&&typeof E.draggable>"u")),y=c?f[0]:5,w=c?f[1]:5,j=i.isShiftPressed?4:1,_=i.x*y*j,S=i.y*w*j,b=m.map(E=>{if(E.positionAbsolute){const N={x:E.positionAbsolute.x+_,y:E.positionAbsolute.y+S};c&&(N.x=f[0]*Math.round(N.x/f[0]),N.y=f[1]*Math.round(N.y/f[1]));const{positionAbsolute:C,position:I}=HE(E,N,s,o,void 0,h);E.position=I,E.positionAbsolute=C}return E});l(b,!0,!1)},[])}const Ds={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Oo=e=>{const n=({id:i,type:s,data:o,xPos:l,yPos:u,xPosOrigin:c,yPosOrigin:f,selected:h,onClick:p,onMouseEnter:m,onMouseMove:y,onMouseLeave:w,onContextMenu:j,onDoubleClick:_,style:S,className:b,isDraggable:E,isSelectable:N,isConnectable:C,isFocusable:I,selectNodesOnDrag:O,sourcePosition:P,targetPosition:z,hidden:T,resizeObserver:q,dragHandle:B,zIndex:J,isParent:Q,noDragClassName:A,noPanClassName:H,initialized:U,disableKeyboardA11y:ne,ariaLabel:Y,rfId:L,hasHandleBounds:G})=>{const k=At(),$=M.useRef(null),oe=M.useRef(null),D=M.useRef(P),X=M.useRef(z),ee=M.useRef(s),se=N||E||p||m||y||w,ae=WE(),pe=Po(i,k.getState,m),ge=Po(i,k.getState,y),Ae=Po(i,k.getState,w),Pe=Po(i,k.getState,j),Ie=Po(i,k.getState,_),Me=ve=>{const{nodeDragThreshold:ye}=k.getState();if(N&&(!O||!E||ye>0)&&$g({id:i,store:k,nodeRef:$}),p){const Ve=k.getState().nodeInternals.get(i);Ve&&p(ve,{...Ve})}},ke=ve=>{if(!Mg(ve)&&!ne)if(vE.includes(ve.key)&&N){const ye=ve.key==="Escape";$g({id:i,store:k,unselect:ye,nodeRef:$})}else E&&h&&Object.prototype.hasOwnProperty.call(Ds,ve.key)&&(k.setState({ariaLiveMessage:`Moved selected node ${ve.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~u}`}),ae({x:Ds[ve.key].x,y:Ds[ve.key].y,isShiftPressed:ve.shiftKey}))};M.useEffect(()=>()=>{oe.current&&(q==null||q.unobserve(oe.current),oe.current=null)},[]),M.useEffect(()=>{if($.current&&!T){const ve=$.current;(!U||!G||oe.current!==ve)&&(oe.current&&(q==null||q.unobserve(oe.current)),q==null||q.observe(ve),oe.current=ve)}},[T,U,G]),M.useEffect(()=>{const ve=ee.current!==s,ye=D.current!==P,Ve=X.current!==z;$.current&&(ve||ye||Ve)&&(ve&&(ee.current=s),ye&&(D.current=P),Ve&&(X.current=z),k.getState().updateNodeDimensions([{id:i,nodeElement:$.current,forceUpdate:!0}]))},[i,s,P,z]);const He=VE({nodeRef:$,disabled:T||!E,noDragClassName:A,handleSelector:B,nodeId:i,isSelectable:N,selectNodesOnDrag:O});return T?null:le.createElement("div",{className:zt(["react-flow__node",`react-flow__node-${s}`,{[H]:E},b,{selected:h,selectable:N,parent:Q,dragging:He}]),ref:$,style:{zIndex:J,transform:`translate(${c}px,${f}px)`,pointerEvents:se?"all":"none",visibility:U?"visible":"hidden",...S},"data-id":i,"data-testid":`rf__node-${i}`,onMouseEnter:pe,onMouseMove:ge,onMouseLeave:Ae,onContextMenu:Pe,onClick:Me,onDoubleClick:Ie,onKeyDown:I?ke:void 0,tabIndex:I?0:void 0,role:I?"button":void 0,"aria-describedby":ne?void 0:`${LE}-${L}`,"aria-label":Y},le.createElement(iI,{value:i},le.createElement(e,{id:i,data:o,type:s,xPos:l,yPos:u,selected:h,isConnectable:C,sourcePosition:P,targetPosition:z,dragging:He,dragHandle:B,zIndex:J})))};return n.displayName="NodeWrapper",M.memo(n)};const WI=e=>{const n=e.getNodes().filter(i=>i.selected);return{...Wl(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function GI({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:i}){const s=At(),{width:o,height:l,x:u,y:c,transformString:f,userSelectionActive:h}=Ze(WI,Tt),p=WE(),m=M.useRef(null);if(M.useEffect(()=>{var j;i||(j=m.current)==null||j.focus({preventScroll:!0})},[i]),VE({nodeRef:m}),h||!o||!l)return null;const y=e?j=>{const _=s.getState().getNodes().filter(S=>S.selected);e(j,_)}:void 0,w=j=>{Object.prototype.hasOwnProperty.call(Ds,j.key)&&p({x:Ds[j.key].x,y:Ds[j.key].y,isShiftPressed:j.shiftKey})};return le.createElement("div",{className:zt(["react-flow__nodesselection","react-flow__container",n]),style:{transform:f}},le.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:i?void 0:-1,onKeyDown:i?void 0:w,style:{width:o,height:l,top:c,left:u}}))}var YI=M.memo(GI);const KI=e=>e.nodesSelectionActive,GE=({children:e,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,deleteKeyCode:c,onMove:f,onMoveStart:h,onMoveEnd:p,selectionKeyCode:m,selectionOnDrag:y,selectionMode:w,onSelectionStart:j,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:C,zoomOnPinch:I,panOnScroll:O,panOnScrollSpeed:P,panOnScrollMode:z,zoomOnDoubleClick:T,panOnDrag:q,defaultViewport:B,translateExtent:J,minZoom:Q,maxZoom:A,preventScrolling:H,onSelectionContextMenu:U,noWheelClassName:ne,noPanClassName:Y,disableKeyboardA11y:L})=>{const G=Ze(KI),k=Xo(m),$=Xo(b),oe=$||q,D=$||O,X=k||y&&oe!==!0;return MI({deleteKeyCode:c,multiSelectionKeyCode:S}),le.createElement(LI,{onMove:f,onMoveStart:h,onMoveEnd:p,onPaneContextMenu:l,elementsSelectable:N,zoomOnScroll:C,zoomOnPinch:I,panOnScroll:D,panOnScrollSpeed:P,panOnScrollMode:z,zoomOnDoubleClick:T,panOnDrag:!k&&oe,defaultViewport:B,translateExtent:J,minZoom:Q,maxZoom:A,zoomActivationKeyCode:E,preventScrolling:H,noWheelClassName:ne,noPanClassName:Y},le.createElement(BE,{onSelectionStart:j,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:oe,isSelecting:!!X,selectionMode:w},e,G&&le.createElement(YI,{onSelectionContextMenu:U,noPanClassName:Y,disableKeyboardA11y:L})))};GE.displayName="FlowRenderer";var XI=M.memo(GE);function QI(e){return Ze(M.useCallback(i=>e?kE(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[e]))}function ZI(e){const n={input:Oo(e.input||ME),default:Oo(e.default||Lg),output:Oo(e.output||OE),group:Oo(e.group||av)},i={},s=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,l)=>(o[l]=Oo(e[l]||Lg),o),i);return{...n,...s}}const JI=({x:e,y:n,width:i,height:s,origin:o})=>!i||!s?{x:e,y:n}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:n}:{x:e-i*o[0],y:n-s*o[1]},eM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),YE=e=>{const{nodesDraggable:n,nodesConnectable:i,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Ze(eM,Tt),c=QI(e.onlyRenderVisibleElements),f=M.useRef(),h=M.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const p=new ResizeObserver(m=>{const y=m.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));l(y)});return f.current=p,p},[]);return M.useEffect(()=>()=>{var p;(p=f==null?void 0:f.current)==null||p.disconnect()},[]),le.createElement("div",{className:"react-flow__nodes",style:lv},c.map(p=>{var I,O,P;let m=p.type||"default";e.nodeTypes[m]||(u==null||u("003",Tr.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,w=!!(p.draggable||n&&typeof p.draggable>"u"),j=!!(p.selectable||o&&typeof p.selectable>"u"),_=!!(p.connectable||i&&typeof p.connectable>"u"),S=!!(p.focusable||s&&typeof p.focusable>"u"),b=e.nodeExtent?tv(p.positionAbsolute,e.nodeExtent):p.positionAbsolute,E=(b==null?void 0:b.x)??0,N=(b==null?void 0:b.y)??0,C=JI({x:E,y:N,width:p.width??0,height:p.height??0,origin:e.nodeOrigin});return le.createElement(y,{key:p.id,id:p.id,className:p.className,style:p.style,type:m,data:p.data,sourcePosition:p.sourcePosition||Ce.Bottom,targetPosition:p.targetPosition||Ce.Top,hidden:p.hidden,xPos:E,yPos:N,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!p.selected,isDraggable:w,isSelectable:j,isConnectable:_,isFocusable:S,resizeObserver:h,dragHandle:p.dragHandle,zIndex:((I=p[yt])==null?void 0:I.z)??0,isParent:!!((O=p[yt])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!p.width&&!!p.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:p.ariaLabel,hasHandleBounds:!!((P=p[yt])!=null&&P.handleBounds)})}))};YE.displayName="NodeRenderer";var tM=M.memo(YE);const nM=(e,n,i)=>i===Ce.Left?e-n:i===Ce.Right?e+n:e,rM=(e,n,i)=>i===Ce.Top?e-n:i===Ce.Bottom?e+n:e,Dw="react-flow__edgeupdater",Fw=({position:e,centerX:n,centerY:i,radius:s=10,onMouseDown:o,onMouseEnter:l,onMouseOut:u,type:c})=>le.createElement("circle",{onMouseDown:o,onMouseEnter:l,onMouseOut:u,className:zt([Dw,`${Dw}-${c}`]),cx:nM(n,s,e),cy:rM(i,s,e),r:s,stroke:"transparent",fill:"transparent"}),iM=()=>!0;var Ms=e=>{const n=({id:i,className:s,type:o,data:l,onClick:u,onEdgeDoubleClick:c,selected:f,animated:h,label:p,labelStyle:m,labelShowBg:y,labelBgStyle:w,labelBgPadding:j,labelBgBorderRadius:_,style:S,source:b,target:E,sourceX:N,sourceY:C,targetX:I,targetY:O,sourcePosition:P,targetPosition:z,elementsSelectable:T,hidden:q,sourceHandleId:B,targetHandleId:J,onContextMenu:Q,onMouseEnter:A,onMouseMove:H,onMouseLeave:U,reconnectRadius:ne,onReconnect:Y,onReconnectStart:L,onReconnectEnd:G,markerEnd:k,markerStart:$,rfId:oe,ariaLabel:D,isFocusable:X,isReconnectable:ee,pathOptions:se,interactionWidth:ae,disableKeyboardA11y:pe})=>{const ge=M.useRef(null),[Ae,Pe]=M.useState(!1),[Ie,Me]=M.useState(!1),ke=At(),He=M.useMemo(()=>`url('#${Og($,oe)}')`,[$,oe]),ve=M.useMemo(()=>`url('#${Og(k,oe)}')`,[k,oe]);if(q)return null;const ye=tt=>{var Lt;const{edges:gt,addSelectedEdges:ut,unselectNodesAndEdges:St,multiSelectionActive:qn}=ke.getState(),Ut=gt.find(Yt=>Yt.id===i);Ut&&(T&&(ke.setState({nodesSelectionActive:!1}),Ut.selected&&qn?(St({nodes:[],edges:[Ut]}),(Lt=ge.current)==null||Lt.blur()):ut([i])),u&&u(tt,Ut))},Ve=Mo(i,ke.getState,c),mt=Mo(i,ke.getState,Q),Je=Mo(i,ke.getState,A),We=Mo(i,ke.getState,H),$e=Mo(i,ke.getState,U),Qe=(tt,gt)=>{if(tt.button!==0)return;const{edges:ut,isValidConnection:St}=ke.getState(),qn=gt?E:b,Ut=(gt?J:B)||null,Lt=gt?"target":"source",Yt=St||iM,vn=gt,yn=ut.find(Kt=>Kt.id===i);Me(!0),L==null||L(tt,yn,Lt);const Jt=Kt=>{Me(!1),G==null||G(Kt,yn,Lt)};RE({event:tt,handleId:Ut,nodeId:qn,onConnect:Kt=>Y==null?void 0:Y(yn,Kt),isTarget:vn,getState:ke.getState,setState:ke.setState,isValidConnection:Yt,edgeUpdaterType:Lt,onReconnectEnd:Jt})},xt=tt=>Qe(tt,!0),et=tt=>Qe(tt,!1),Ge=()=>Pe(!0),_t=()=>Pe(!1),It=!T&&!u,Bt=tt=>{var gt;if(!pe&&vE.includes(tt.key)&&T){const{unselectNodesAndEdges:ut,addSelectedEdges:St,edges:qn}=ke.getState();tt.key==="Escape"?((gt=ge.current)==null||gt.blur(),ut({edges:[qn.find(Lt=>Lt.id===i)]})):St([i])}};return le.createElement("g",{className:zt(["react-flow__edge",`react-flow__edge-${o}`,s,{selected:f,animated:h,inactive:It,updating:Ae}]),onClick:ye,onDoubleClick:Ve,onContextMenu:mt,onMouseEnter:Je,onMouseMove:We,onMouseLeave:$e,onKeyDown:X?Bt:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":D===null?void 0:D||`Edge from ${b} to ${E}`,"aria-describedby":X?`${$E}-${oe}`:void 0,ref:ge},!Ie&&le.createElement(e,{id:i,source:b,target:E,selected:f,animated:h,label:p,labelStyle:m,labelShowBg:y,labelBgStyle:w,labelBgPadding:j,labelBgBorderRadius:_,data:l,style:S,sourceX:N,sourceY:C,targetX:I,targetY:O,sourcePosition:P,targetPosition:z,sourceHandleId:B,targetHandleId:J,markerStart:He,markerEnd:ve,pathOptions:se,interactionWidth:ae}),ee&&le.createElement(le.Fragment,null,(ee==="source"||ee===!0)&&le.createElement(Fw,{position:P,centerX:N,centerY:C,radius:ne,onMouseDown:xt,onMouseEnter:Ge,onMouseOut:_t,type:"source"}),(ee==="target"||ee===!0)&&le.createElement(Fw,{position:z,centerX:I,centerY:O,radius:ne,onMouseDown:et,onMouseEnter:Ge,onMouseOut:_t,type:"target"})))};return n.displayName="EdgeWrapper",M.memo(n)};function sM(e){const n={default:Ms(e.default||ql),straight:Ms(e.bezier||iv),step:Ms(e.step||rv),smoothstep:Ms(e.step||Vl),simplebezier:Ms(e.simplebezier||nv)},i={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=Ms(e[l]||ql),o),i);return{...n,...s}}function zw(e,n,i=null){const s=((i==null?void 0:i.x)||0)+n.x,o=((i==null?void 0:i.y)||0)+n.y,l=(i==null?void 0:i.width)||n.width,u=(i==null?void 0:i.height)||n.height;switch(e){case Ce.Top:return{x:s+l/2,y:o};case Ce.Right:return{x:s+l,y:o+u/2};case Ce.Bottom:return{x:s+l/2,y:o+u};case Ce.Left:return{x:s,y:o+u/2}}}function Bw(e,n){return e?e.length===1||!n?e[0]:n&&e.find(i=>i.id===n)||null:null}const oM=(e,n,i,s,o,l)=>{const u=zw(i,e,n),c=zw(l,s,o);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y}};function aM({sourcePos:e,targetPos:n,sourceWidth:i,sourceHeight:s,targetWidth:o,targetHeight:l,width:u,height:c,transform:f}){const h={x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x+i,n.x+o),y2:Math.max(e.y+s,n.y+l)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const p=Yo({x:(0-f[0])/f[2],y:(0-f[1])/f[2],width:u/f[2],height:c/f[2]}),m=Math.max(0,Math.min(p.x2,h.x2)-Math.max(p.x,h.x)),y=Math.max(0,Math.min(p.y2,h.y2)-Math.max(p.y,h.y));return Math.ceil(m*y)>0}function Uw(e){var s,o,l,u,c;const n=((s=e==null?void 0:e[yt])==null?void 0:s.handleBounds)||null,i=n&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},n,!!i]}const lM=[{level:0,isMaxLevel:!0,edges:[]}];function uM(e,n,i=!1){let s=-1;const o=e.reduce((u,c)=>{var p,m;const f=Mn(c.zIndex);let h=f?c.zIndex:0;if(i){const y=n.get(c.target),w=n.get(c.source),j=c.selected||(y==null?void 0:y.selected)||(w==null?void 0:w.selected),_=Math.max(((p=w==null?void 0:w[yt])==null?void 0:p.z)||0,((m=y==null?void 0:y[yt])==null?void 0:m.z)||0,1e3);h=(f?c.zIndex:0)+(j?_:0)}return u[h]?u[h].push(c):u[h]=[c],s=h>s?h:s,u},{}),l=Object.entries(o).map(([u,c])=>{const f=+u;return{edges:c,level:f,isMaxLevel:f===s}});return l.length===0?lM:l}function cM(e,n,i){const s=Ze(M.useCallback(o=>e?o.edges.filter(l=>{const u=n.get(l.source),c=n.get(l.target);return(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&aM({sourcePos:u.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:u.width,sourceHeight:u.height,targetWidth:c.width,targetHeight:c.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[e,n]));return uM(s,n,i)}const dM=({color:e="none",strokeWidth:n=1})=>le.createElement("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),fM=({color:e="none",strokeWidth:n=1})=>le.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Hw={[Ol.Arrow]:dM,[Ol.ArrowClosed]:fM};function hM(e){const n=At();return M.useMemo(()=>{var o,l;return Object.prototype.hasOwnProperty.call(Hw,e)?Hw[e]:((l=(o=n.getState()).onError)==null||l.call(o,"009",Tr.error009(e)),null)},[e])}const pM=({id:e,type:n,color:i,width:s=12.5,height:o=12.5,markerUnits:l="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const f=hM(n);return f?le.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:c,refX:"0",refY:"0"},le.createElement(f,{color:i,strokeWidth:u})):null},mM=({defaultColor:e,rfId:n})=>i=>{const s=[];return i.edges.reduce((o,l)=>([l.markerStart,l.markerEnd].forEach(u=>{if(u&&typeof u=="object"){const c=Og(u,n);s.includes(c)||(o.push({id:c,color:u.color||e,...u}),s.push(c))}}),o),[]).sort((o,l)=>o.id.localeCompare(l.id))},KE=({defaultColor:e,rfId:n})=>{const i=Ze(M.useCallback(mM({defaultColor:e,rfId:n}),[e,n]),(s,o)=>!(s.length!==o.length||s.some((l,u)=>l.id!==o[u].id)));return le.createElement("defs",null,i.map(s=>le.createElement(pM,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};KE.displayName="MarkerDefinitions";var gM=M.memo(KE);const vM=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),XE=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:i,rfId:s,edgeTypes:o,noPanClassName:l,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:f,onEdgeMouseLeave:h,onEdgeClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:w,onReconnectEnd:j,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:E,edgesUpdatable:N,elementsSelectable:C,width:I,height:O,connectionMode:P,nodeInternals:z,onError:T}=Ze(vM,Tt),q=cM(n,z,i);return I?le.createElement(le.Fragment,null,q.map(({level:B,edges:J,isMaxLevel:Q})=>le.createElement("svg",{key:B,style:{zIndex:B},width:I,height:O,className:"react-flow__edges react-flow__container"},Q&&le.createElement(gM,{defaultColor:e,rfId:s}),le.createElement("g",null,J.map(A=>{const[H,U,ne]=Uw(z.get(A.source)),[Y,L,G]=Uw(z.get(A.target));if(!ne||!G)return null;let k=A.type||"default";o[k]||(T==null||T("011",Tr.error011(k)),k="default");const $=o[k]||o.default,oe=P===Wi.Strict?L.target:(L.target??[]).concat(L.source??[]),D=Bw(U.source,A.sourceHandle),X=Bw(oe,A.targetHandle),ee=(D==null?void 0:D.position)||Ce.Bottom,se=(X==null?void 0:X.position)||Ce.Top,ae=!!(A.focusable||E&&typeof A.focusable>"u"),pe=A.reconnectable||A.updatable,ge=typeof y<"u"&&(pe||N&&typeof pe>"u");if(!D||!X)return T==null||T("008",Tr.error008(D,A)),null;const{sourceX:Ae,sourceY:Pe,targetX:Ie,targetY:Me}=oM(H,D,ee,Y,X,se);return le.createElement($,{key:A.id,id:A.id,className:zt([A.className,l]),type:k,data:A.data,selected:!!A.selected,animated:!!A.animated,hidden:!!A.hidden,label:A.label,labelStyle:A.labelStyle,labelShowBg:A.labelShowBg,labelBgStyle:A.labelBgStyle,labelBgPadding:A.labelBgPadding,labelBgBorderRadius:A.labelBgBorderRadius,style:A.style,source:A.source,target:A.target,sourceHandleId:A.sourceHandle,targetHandleId:A.targetHandle,markerEnd:A.markerEnd,markerStart:A.markerStart,sourceX:Ae,sourceY:Pe,targetX:Ie,targetY:Me,sourcePosition:ee,targetPosition:se,elementsSelectable:C,onContextMenu:u,onMouseEnter:c,onMouseMove:f,onMouseLeave:h,onClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:w,onReconnectEnd:j,reconnectRadius:_,rfId:s,ariaLabel:A.ariaLabel,isFocusable:ae,isReconnectable:ge,pathOptions:"pathOptions"in A?A.pathOptions:void 0,interactionWidth:A.interactionWidth,disableKeyboardA11y:b})})))),S):null};XE.displayName="EdgeRenderer";var yM=M.memo(XE);const wM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function xM({children:e}){const n=Ze(wM);return le.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function _M(e){const n=ta(),i=M.useRef(!1);M.useEffect(()=>{!i.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),i.current=!0)},[e,n.viewportInitialized])}const SM={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},QE=({nodeId:e,handleType:n,style:i,type:s=ri.Bezier,CustomComponent:o,connectionStatus:l})=>{var O,P,z;const{fromNode:u,handleId:c,toX:f,toY:h,connectionMode:p}=Ze(M.useCallback(T=>({fromNode:T.nodeInternals.get(e),handleId:T.connectionHandleId,toX:(T.connectionPosition.x-T.transform[0])/T.transform[2],toY:(T.connectionPosition.y-T.transform[1])/T.transform[2],connectionMode:T.connectionMode}),[e]),Tt),m=(O=u==null?void 0:u[yt])==null?void 0:O.handleBounds;let y=m==null?void 0:m[n];if(p===Wi.Loose&&(y=y||(m==null?void 0:m[n==="source"?"target":"source"])),!u||!y)return null;const w=c?y.find(T=>T.id===c):y[0],j=w?w.x+w.width/2:(u.width??0)/2,_=w?w.y+w.height/2:u.height??0,S=(((P=u.positionAbsolute)==null?void 0:P.x)??0)+j,b=(((z=u.positionAbsolute)==null?void 0:z.y)??0)+_,E=w==null?void 0:w.position,N=E?SM[E]:null;if(!E||!N)return null;if(o)return le.createElement(o,{connectionLineType:s,connectionLineStyle:i,fromNode:u,fromHandle:w,fromX:S,fromY:b,toX:f,toY:h,fromPosition:E,toPosition:N,connectionStatus:l});let C="";const I={sourceX:S,sourceY:b,sourcePosition:E,targetX:f,targetY:h,targetPosition:N};return s===ri.Bezier?[C]=SE(I):s===ri.Step?[C]=Pg({...I,borderRadius:0}):s===ri.SmoothStep?[C]=Pg(I):s===ri.SimpleBezier?[C]=_E(I):C=`M${S},${b} ${f},${h}`,le.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:i})};QE.displayName="ConnectionLine";const bM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function kM({containerStyle:e,style:n,type:i,component:s}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:f,connectionStatus:h}=Ze(bM,Tt);return!(o&&l&&c&&u)?null:le.createElement("svg",{style:e,width:c,height:f,className:"react-flow__edges react-flow__connectionline react-flow__container"},le.createElement("g",{className:zt(["react-flow__connection",h])},le.createElement(QE,{nodeId:o,handleType:l,style:n,type:i,CustomComponent:s,connectionStatus:h})))}function Vw(e,n){return M.useRef(null),At(),M.useMemo(()=>n(e),[e])}const ZE=({nodeTypes:e,edgeTypes:n,onMove:i,onMoveStart:s,onMoveEnd:o,onInit:l,onNodeClick:u,onEdgeClick:c,onNodeDoubleClick:f,onEdgeDoubleClick:h,onNodeMouseEnter:p,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:w,onSelectionContextMenu:j,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:E,connectionLineComponent:N,connectionLineContainerStyle:C,selectionKeyCode:I,selectionOnDrag:O,selectionMode:P,multiSelectionKeyCode:z,panActivationKeyCode:T,zoomActivationKeyCode:q,deleteKeyCode:B,onlyRenderVisibleElements:J,elementsSelectable:Q,selectNodesOnDrag:A,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:Y,preventScrolling:L,defaultMarkerColor:G,zoomOnScroll:k,zoomOnPinch:$,panOnScroll:oe,panOnScrollSpeed:D,panOnScrollMode:X,zoomOnDoubleClick:ee,panOnDrag:se,onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:ge,onPaneMouseLeave:Ae,onPaneScroll:Pe,onPaneContextMenu:Ie,onEdgeContextMenu:Me,onEdgeMouseEnter:ke,onEdgeMouseMove:He,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:Ve,onReconnectEnd:mt,reconnectRadius:Je,noDragClassName:We,noWheelClassName:$e,noPanClassName:Qe,elevateEdgesOnSelect:xt,disableKeyboardA11y:et,nodeOrigin:Ge,nodeExtent:_t,rfId:It})=>{const Bt=Vw(e,ZI),tt=Vw(n,sM);return _M(l),le.createElement(XI,{onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:ge,onPaneMouseLeave:Ae,onPaneContextMenu:Ie,onPaneScroll:Pe,deleteKeyCode:B,selectionKeyCode:I,selectionOnDrag:O,selectionMode:P,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:z,panActivationKeyCode:T,zoomActivationKeyCode:q,elementsSelectable:Q,onMove:i,onMoveStart:s,onMoveEnd:o,zoomOnScroll:k,zoomOnPinch:$,zoomOnDoubleClick:ee,panOnScroll:oe,panOnScrollSpeed:D,panOnScrollMode:X,panOnDrag:se,defaultViewport:H,translateExtent:U,minZoom:ne,maxZoom:Y,onSelectionContextMenu:j,preventScrolling:L,noDragClassName:We,noWheelClassName:$e,noPanClassName:Qe,disableKeyboardA11y:et},le.createElement(xM,null,le.createElement(yM,{edgeTypes:tt,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:J,onEdgeContextMenu:Me,onEdgeMouseEnter:ke,onEdgeMouseMove:He,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:Ve,onReconnectEnd:mt,reconnectRadius:Je,defaultMarkerColor:G,noPanClassName:Qe,elevateEdgesOnSelect:!!xt,disableKeyboardA11y:et,rfId:It},le.createElement(kM,{style:E,type:b,component:N,containerStyle:C})),le.createElement("div",{className:"react-flow__edgelabel-renderer"}),le.createElement(tM,{nodeTypes:Bt,onNodeClick:u,onNodeDoubleClick:f,onNodeMouseEnter:p,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:w,selectNodesOnDrag:A,onlyRenderVisibleElements:J,noPanClassName:Qe,noDragClassName:We,disableKeyboardA11y:et,nodeOrigin:Ge,nodeExtent:_t,rfId:It})))};ZE.displayName="GraphView";var EM=M.memo(ZE);const Dg=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ei={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Dg,nodeExtent:Dg,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Wi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:ZA,isValidConnection:void 0},NM=()=>hR((e,n)=>({...ei,setNodes:i=>{const{nodeInternals:s,nodeOrigin:o,elevateNodesOnSelect:l}=n();e({nodeInternals:Zc(i,s,o,l)})},getNodes:()=>Array.from(n().nodeInternals.values()),setEdges:i=>{const{defaultEdgeOptions:s={}}=n();e({edges:i.map(o=>({...s,...o}))})},setDefaultNodesAndEdges:(i,s)=>{const o=typeof i<"u",l=typeof s<"u",u=o?Zc(i,new Map,n().nodeOrigin,n().elevateNodesOnSelect):new Map;e({nodeInternals:u,edges:l?s:[],hasDefaultNodes:o,hasDefaultEdges:l})},updateNodeDimensions:i=>{const{onNodesChange:s,nodeInternals:o,fitViewOnInit:l,fitViewOnInitDone:u,fitViewOnInitOptions:c,domNode:f,nodeOrigin:h}=n(),p=f==null?void 0:f.querySelector(".react-flow__viewport");if(!p)return;const m=window.getComputedStyle(p),{m22:y}=new window.DOMMatrixReadOnly(m.transform),w=i.reduce((_,S)=>{const b=o.get(S.id);if(b!=null&&b.hidden)o.set(b.id,{...b,[yt]:{...b[yt],handleBounds:void 0}});else if(b){const E=ev(S.nodeElement);!!(E.width&&E.height&&(b.width!==E.width||b.height!==E.height||S.forceUpdate))&&(o.set(b.id,{...b,[yt]:{...b[yt],handleBounds:{source:$w(".source",S.nodeElement,y,h),target:$w(".target",S.nodeElement,y,h)}},...E}),_.push({id:b.id,type:"dimensions",dimensions:E}))}return _},[]);FE(o,h);const j=u||l&&!u&&zE(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:j}),(w==null?void 0:w.length)>0&&(s==null||s(w))},updateNodePositions:(i,s=!0,o=!1)=>{const{triggerNodeChanges:l}=n(),u=i.map(c=>{const f={id:c.id,type:"position",dragging:o};return s&&(f.positionAbsolute=c.positionAbsolute,f.position=c.position),f});l(u)},triggerNodeChanges:i=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:l,nodeOrigin:u,getNodes:c,elevateNodesOnSelect:f}=n();if(i!=null&&i.length){if(l){const h=zI(i,c()),p=Zc(h,o,u,f);e({nodeInternals:p})}s==null||s(i)}},addSelectedNodes:i=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=i.map(f=>ni(f,!0)):(u=Os(l(),i),c=Os(o,[])),gl({changedNodes:u,changedEdges:c,get:n,set:e})},addSelectedEdges:i=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=i.map(f=>ni(f,!0)):(u=Os(o,i),c=Os(l(),[])),gl({changedNodes:c,changedEdges:u,get:n,set:e})},unselectNodesAndEdges:({nodes:i,edges:s}={})=>{const{edges:o,getNodes:l}=n(),u=i||l(),c=s||o,f=u.map(p=>(p.selected=!1,ni(p.id,!1))),h=c.map(p=>ni(p.id,!1));gl({changedNodes:f,changedEdges:h,get:n,set:e})},setMinZoom:i=>{const{d3Zoom:s,maxZoom:o}=n();s==null||s.scaleExtent([i,o]),e({minZoom:i})},setMaxZoom:i=>{const{d3Zoom:s,minZoom:o}=n();s==null||s.scaleExtent([o,i]),e({maxZoom:i})},setTranslateExtent:i=>{var s;(s=n().d3Zoom)==null||s.translateExtent(i),e({translateExtent:i})},resetSelectedElements:()=>{const{edges:i,getNodes:s}=n(),l=s().filter(c=>c.selected).map(c=>ni(c.id,!1)),u=i.filter(c=>c.selected).map(c=>ni(c.id,!1));gl({changedNodes:l,changedEdges:u,get:n,set:e})},setNodeExtent:i=>{const{nodeInternals:s}=n();s.forEach(o=>{o.positionAbsolute=tv(o.position,i)}),e({nodeExtent:i,nodeInternals:new Map(s)})},panBy:i=>{const{transform:s,width:o,height:l,d3Zoom:u,d3Selection:c,translateExtent:f}=n();if(!u||!c||!i.x&&!i.y)return!1;const h=jr.translate(s[0]+i.x,s[1]+i.y).scale(s[2]),p=[[0,0],[o,l]],m=u==null?void 0:u.constrain()(h,p,f);return u.transform(c,m),s[0]!==m.x||s[1]!==m.y||s[2]!==m.k},cancelConnection:()=>e({connectionNodeId:ei.connectionNodeId,connectionHandleId:ei.connectionHandleId,connectionHandleType:ei.connectionHandleType,connectionStatus:ei.connectionStatus,connectionStartHandle:ei.connectionStartHandle,connectionEndHandle:ei.connectionEndHandle}),reset:()=>e({...ei})}),Object.is),uv=({children:e})=>{const n=M.useRef(null);return n.current||(n.current=NM()),le.createElement(VA,{value:n.current},e)};uv.displayName="ReactFlowProvider";const JE=({children:e})=>M.useContext(Hl)?le.createElement(le.Fragment,null,e):le.createElement(uv,null,e);JE.displayName="ReactFlowWrapper";const CM={input:ME,default:Lg,output:OE,group:av},jM={default:ql,straight:iv,step:rv,smoothstep:Vl,simplebezier:nv},RM=[0,0],TM=[15,15],AM={x:0,y:0,zoom:1},IM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},eN=M.forwardRef(({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,className:o,nodeTypes:l=CM,edgeTypes:u=jM,onNodeClick:c,onEdgeClick:f,onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onConnect:w,onConnectStart:j,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:C,onNodeContextMenu:I,onNodeDoubleClick:O,onNodeDragStart:P,onNodeDrag:z,onNodeDragStop:T,onNodesDelete:q,onEdgesDelete:B,onSelectionChange:J,onSelectionDragStart:Q,onSelectionDrag:A,onSelectionDragStop:H,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:Y,connectionMode:L=Wi.Strict,connectionLineType:G=ri.Bezier,connectionLineStyle:k,connectionLineComponent:$,connectionLineContainerStyle:oe,deleteKeyCode:D="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:ee=!1,selectionMode:se=Ko.Full,panActivationKeyCode:ae="Space",multiSelectionKeyCode:pe=Pl()?"Meta":"Control",zoomActivationKeyCode:ge=Pl()?"Meta":"Control",snapToGrid:Ae=!1,snapGrid:Pe=TM,onlyRenderVisibleElements:Ie=!1,selectNodesOnDrag:Me=!0,nodesDraggable:ke,nodesConnectable:He,nodesFocusable:ve,nodeOrigin:ye=RM,edgesFocusable:Ve,edgesUpdatable:mt,elementsSelectable:Je,defaultViewport:We=AM,minZoom:$e=.5,maxZoom:Qe=2,translateExtent:xt=Dg,preventScrolling:et=!0,nodeExtent:Ge,defaultMarkerColor:_t="#b1b1b7",zoomOnScroll:It=!0,zoomOnPinch:Bt=!0,panOnScroll:tt=!1,panOnScrollSpeed:gt=.5,panOnScrollMode:ut=zi.Free,zoomOnDoubleClick:St=!0,panOnDrag:qn=!0,onPaneClick:Ut,onPaneMouseEnter:Lt,onPaneMouseMove:Yt,onPaneMouseLeave:vn,onPaneScroll:yn,onPaneContextMenu:Jt,children:ct,onEdgeContextMenu:Kt,onEdgeDoubleClick:cr,onEdgeMouseEnter:wn,onEdgeMouseMove:li,onEdgeMouseLeave:ui,onEdgeUpdate:ci,onEdgeUpdateStart:Zn,onEdgeUpdateEnd:Jn,onReconnect:Mr,onReconnectStart:dr,onReconnectEnd:Qi,reconnectRadius:er=10,edgeUpdaterRadius:bt=10,onNodesChange:tr,onEdgesChange:xn,noDragClassName:Xs="nodrag",noWheelClassName:en="nowheel",noPanClassName:Pr="nopan",fitView:dn=!1,fitViewOptions:di,connectOnClick:fr=!0,attributionPosition:fi,proOptions:_n,defaultEdgeOptions:hi,elevateNodesOnSelect:pi=!0,elevateEdgesOnSelect:mi=!1,disableKeyboardA11y:Zi=!1,autoPanOnConnect:gi=!0,autoPanOnNodeDrag:Ye=!0,connectionRadius:Ji=20,isValidConnection:vi,onError:yi,style:hr,id:es,nodeDragThreshold:$t,...nr},Nt)=>{const Ln=es||"1";return le.createElement("div",{...nr,style:{...hr,...IM},ref:Nt,className:zt(["react-flow",o]),"data-testid":"rf__wrapper",id:es},le.createElement(JE,null,le.createElement(EM,{onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:f,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:C,onNodeContextMenu:I,onNodeDoubleClick:O,nodeTypes:l,edgeTypes:u,connectionLineType:G,connectionLineStyle:k,connectionLineComponent:$,connectionLineContainerStyle:oe,selectionKeyCode:X,selectionOnDrag:ee,selectionMode:se,deleteKeyCode:D,multiSelectionKeyCode:pe,panActivationKeyCode:ae,zoomActivationKeyCode:ge,onlyRenderVisibleElements:Ie,selectNodesOnDrag:Me,defaultViewport:We,translateExtent:xt,minZoom:$e,maxZoom:Qe,preventScrolling:et,zoomOnScroll:It,zoomOnPinch:Bt,zoomOnDoubleClick:St,panOnScroll:tt,panOnScrollSpeed:gt,panOnScrollMode:ut,panOnDrag:qn,onPaneClick:Ut,onPaneMouseEnter:Lt,onPaneMouseMove:Yt,onPaneMouseLeave:vn,onPaneScroll:yn,onPaneContextMenu:Jt,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:Y,onEdgeContextMenu:Kt,onEdgeDoubleClick:cr,onEdgeMouseEnter:wn,onEdgeMouseMove:li,onEdgeMouseLeave:ui,onReconnect:Mr??ci,onReconnectStart:dr??Zn,onReconnectEnd:Qi??Jn,reconnectRadius:er??bt,defaultMarkerColor:_t,noDragClassName:Xs,noWheelClassName:en,noPanClassName:Pr,elevateEdgesOnSelect:mi,rfId:Ln,disableKeyboardA11y:Zi,nodeOrigin:ye,nodeExtent:Ge}),le.createElement(_I,{nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:w,onConnectStart:j,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,nodesDraggable:ke,nodesConnectable:He,nodesFocusable:ve,edgesFocusable:Ve,edgesUpdatable:mt,elementsSelectable:Je,elevateNodesOnSelect:pi,minZoom:$e,maxZoom:Qe,nodeExtent:Ge,onNodesChange:tr,onEdgesChange:xn,snapToGrid:Ae,snapGrid:Pe,connectionMode:L,translateExtent:xt,connectOnClick:fr,defaultEdgeOptions:hi,fitView:dn,fitViewOptions:di,onNodesDelete:q,onEdgesDelete:B,onNodeDragStart:P,onNodeDrag:z,onNodeDragStop:T,onSelectionDrag:A,onSelectionDragStart:Q,onSelectionDragStop:H,noPanClassName:Pr,nodeOrigin:ye,rfId:Ln,autoPanOnConnect:gi,autoPanOnNodeDrag:Ye,onError:yi,connectionRadius:Ji,isValidConnection:vi,nodeDragThreshold:$t}),le.createElement(wI,{onSelectionChange:J}),ct,le.createElement(GA,{proOptions:_n,position:fi}),le.createElement(NI,{rfId:Ln,disableKeyboardA11y:Zi})))});eN.displayName="ReactFlow";const MM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function tN(){return Ze(MM,Tt)}const nN=({id:e,x:n,y:i,width:s,height:o,style:l,color:u,strokeColor:c,strokeWidth:f,className:h,borderRadius:p,shapeRendering:m,onClick:y,selected:w})=>{const{background:j,backgroundColor:_}=l||{},S=u||j||_;return le.createElement("rect",{className:zt(["react-flow__minimap-node",{selected:w},h]),x:n,y:i,rx:p,ry:p,width:s,height:o,fill:S,stroke:c,strokeWidth:f,shapeRendering:m,onClick:y?b=>y(b,e):void 0})};nN.displayName="MiniMapNode";var PM=M.memo(nN);const OM=e=>e.nodeOrigin,qM=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),nd=e=>e instanceof Function?e:()=>e;function LM({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:l=PM,onClick:u}){const c=Ze(qM,Tt),f=Ze(OM),h=nd(n),p=nd(e),m=nd(i),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return le.createElement(le.Fragment,null,c.map(w=>{const{x:j,y:_}=Ui(w,f).positionAbsolute;return le.createElement(l,{key:w.id,x:j,y:_,width:w.width,height:w.height,style:w.style,selected:w.selected,className:m(w),color:h(w),borderRadius:s,strokeColor:p(w),strokeWidth:o,shapeRendering:y,onClick:u,id:w.id})}))}var $M=M.memo(LM);const DM=200,FM=150,zM=e=>{const n=e.getNodes(),i={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:i,boundingRect:n.length>0?XA(Wl(n,e.nodeOrigin),i):i,rfId:e.rfId}},BM="react-flow__minimap-desc";function rN({style:e,className:n,nodeStrokeColor:i="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:u=2,nodeComponent:c,maskColor:f="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:p=1,position:m="bottom-right",onClick:y,onNodeClick:w,pannable:j=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:E=10,offsetScale:N=5}){const C=At(),I=M.useRef(null),{boundingRect:O,viewBB:P,rfId:z}=Ze(zM,Tt),T=(e==null?void 0:e.width)??DM,q=(e==null?void 0:e.height)??FM,B=O.width/T,J=O.height/q,Q=Math.max(B,J),A=Q*T,H=Q*q,U=N*Q,ne=O.x-(A-O.width)/2-U,Y=O.y-(H-O.height)/2-U,L=A+U*2,G=H+U*2,k=`${BM}-${z}`,$=M.useRef(0);$.current=Q,M.useEffect(()=>{if(I.current){const X=In(I.current),ee=pe=>{const{transform:ge,d3Selection:Ae,d3Zoom:Pe}=C.getState();if(pe.sourceEvent.type!=="wheel"||!Ae||!Pe)return;const Ie=-pe.sourceEvent.deltaY*(pe.sourceEvent.deltaMode===1?.05:pe.sourceEvent.deltaMode?1:.002)*E,Me=ge[2]*Math.pow(2,Ie);Pe.scaleTo(Ae,Me)},se=pe=>{const{transform:ge,d3Selection:Ae,d3Zoom:Pe,translateExtent:Ie,width:Me,height:ke}=C.getState();if(pe.sourceEvent.type!=="mousemove"||!Ae||!Pe)return;const He=$.current*Math.max(1,ge[2])*(b?-1:1),ve={x:ge[0]-pe.sourceEvent.movementX*He,y:ge[1]-pe.sourceEvent.movementY*He},ye=[[0,0],[Me,ke]],Ve=jr.translate(ve.x,ve.y).scale(ge[2]),mt=Pe.constrain()(Ve,ye,Ie);Pe.transform(Ae,mt)},ae=dE().on("zoom",j?se:null).on("zoom.wheel",_?ee:null);return X.call(ae),()=>{X.on("zoom",null)}}},[j,_,b,E]);const oe=y?X=>{const ee=Wn(X);y(X,{x:ee[0],y:ee[1]})}:void 0,D=w?(X,ee)=>{const se=C.getState().nodeInternals.get(ee);w(X,se)}:void 0;return le.createElement(Jg,{position:m,style:e,className:zt(["react-flow__minimap",n]),"data-testid":"rf__minimap"},le.createElement("svg",{width:T,height:q,viewBox:`${ne} ${Y} ${L} ${G}`,role:"img","aria-labelledby":k,ref:I,onClick:oe},S&&le.createElement("title",{id:k},S),le.createElement($M,{onClick:D,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:c}),le.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-U},${Y-U}h${L+U*2}v${G+U*2}h${-L-U*2}z
|
|
57
57
|
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fill:f,fillRule:"evenodd",stroke:h,strokeWidth:p,pointerEvents:"none"})))}rN.displayName="MiniMap";var UM=M.memo(rN);function HM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},le.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function VM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},le.createElement("path",{d:"M0 0h32v4.2H0z"}))}function WM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},le.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function GM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function YM(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const qs=({children:e,className:n,...i})=>le.createElement("button",{type:"button",className:zt(["react-flow__controls-button",n]),...i},e);qs.displayName="ControlButton";const KM=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),iN=({style:e,showZoom:n=!0,showFitView:i=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:f,className:h,children:p,position:m="bottom-left"})=>{const y=At(),[w,j]=M.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Ze(KM,Tt),{zoomIn:E,zoomOut:N,fitView:C}=ta();if(M.useEffect(()=>{j(!0)},[]),!w)return null;const I=()=>{E(),l==null||l()},O=()=>{N(),u==null||u()},P=()=>{C(o),c==null||c()},z=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),f==null||f(!_)};return le.createElement(Jg,{className:zt(["react-flow__controls",h]),position:m,style:e,"data-testid":"rf__controls"},n&&le.createElement(le.Fragment,null,le.createElement(qs,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},le.createElement(HM,null)),le.createElement(qs,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},le.createElement(VM,null))),i&&le.createElement(qs,{className:"react-flow__controls-fitview",onClick:P,title:"fit view","aria-label":"fit view"},le.createElement(WM,null)),s&&le.createElement(qs,{className:"react-flow__controls-interactive",onClick:z,title:"toggle interactivity","aria-label":"toggle interactivity"},_?le.createElement(YM,null):le.createElement(GM,null)),p)};iN.displayName="Controls";var XM=M.memo(iN),Yn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Yn||(Yn={}));function QM({color:e,dimensions:n,lineWidth:i}){return le.createElement("path",{stroke:e,strokeWidth:i,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function ZM({color:e,radius:n}){return le.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const JM={[Yn.Dots]:"#91919a",[Yn.Lines]:"#eee",[Yn.Cross]:"#e2e2e2"},eP={[Yn.Dots]:1,[Yn.Lines]:1,[Yn.Cross]:6},tP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function sN({id:e,variant:n=Yn.Dots,gap:i=20,size:s,lineWidth:o=1,offset:l=2,color:u,style:c,className:f}){const h=M.useRef(null),{transform:p,patternId:m}=Ze(tP,Tt),y=u||JM[n],w=s||eP[n],j=n===Yn.Dots,_=n===Yn.Cross,S=Array.isArray(i)?i:[i,i],b=[S[0]*p[2]||1,S[1]*p[2]||1],E=w*p[2],N=_?[E,E]:b,C=j?[E/l,E/l]:[N[0]/l,N[1]/l];return le.createElement("svg",{className:zt(["react-flow__background",f]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},le.createElement("pattern",{id:m+e,x:p[0]%b[0],y:p[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},j?le.createElement(ZM,{color:y,radius:E/l}):le.createElement(QM,{dimensions:N,color:y,lineWidth:o})),le.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}sN.displayName="Background";var nP=M.memo(sN);function oN(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function aN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.input_tokens=="number"||typeof i.output_tokens=="number"||typeof i.cache_read_input_tokens=="number"||typeof i.cache_creation_input_tokens=="number")return{inputTokens:Number(i.input_tokens??0),outputTokens:Number(i.output_tokens??0),cacheReadTokens:Number(i.cache_read_input_tokens??0),cacheCreateTokens:Number(i.cache_creation_input_tokens??0)};for(const s of Object.values(i)){const o=aN(s,n+1);if(o)return o}return null}function rP(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens}const iP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function lN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.model=="string"&&iP.test(i.model))return i.model;for(const s of Object.values(i)){const o=lN(s,n+1);if(o)return o}return null}function Fg(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,totalEvents:0}}function si(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function cv(e,n){return`${e}::${n}`}function Ll(e){return e.agent_type??e.subagent_type??"subagent"}function zg(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Bo(e,n,i,s){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:i,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,inFlightTool:null,usage:oN()},e.agents.set(o,l),l)}function uN(e,n,i,s){const o=cv(n,i),l=e.agents.get(o);if(!l)return null;!l.cwd&&s.cwd&&(l.cwd=s.cwd,l.cwdBasename=si(s.cwd));const u=Ll(s);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function Ww(e,n,i){const s=n.session_id??"unknown",o=zg(n);if(o){const f=uN(e,s,o,n);if(f)return f}const l=e.activeSubagentStack.get(s),u=l&&l.length>0?l[l.length-1]:null;if(u){const f=e.agents.get(cv(s,u));if(f)return!f.cwd&&n.cwd&&(f.cwd=n.cwd,f.cwdBasename=si(n.cwd)),f}const c=Bo(e,s,i,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=i),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=si(n.cwd)),c.label==="session"&&n.cwd&&(c.label=si(n.cwd)??"session"),c}function sP(e,n,i,s,o){const l=cv(n,i),u=Bo(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&s.cwd&&(c.cwd=s.cwd,c.cwdBasename=si(s.cwd));const f=Ll(s);return f&&(c.label==="subagent"||!c.label)&&(c.label=f),c}return c={id:l,sessionId:n,label:Ll(s),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:si(s.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:oN()},e.agents.set(l,c),u.childCount+=1,c}function oP(e,n,i){const s=e.activeSubagentStack.get(n)??[];s.push(i),e.activeSubagentStack.set(n,s)}function aP(e,n,i){const s=e.activeSubagentStack.get(n);if(s){for(let o=s.length-1;o>=0;o--)if(s[o]===i){s.splice(o,1);break}s.length===0&&e.activeSubagentStack.delete(n)}}function rd(e,n=80){if(e==null)return"";if(typeof e=="string")return e.length>n?e.slice(0,n-1)+"…":e;try{const i=JSON.stringify(e);return i.length>n?i.slice(0,n-1)+"…":i}catch{return String(e)}}function $o(e){let n=null;for(let i=e.tools.length-1;i>=0;i--){const s=e.tools[i];if(s.endedAt==null){n=s;break}}e.inFlightTool=n}function lP(e,n,i,s){if(e.agents.size<=i)return!1;const o=[];for(const[u,c]of e.agents)c.state==="done"&&c.endedAt!=null&&n-c.endedAt>s&&o.push({id:u,endedAt:c.endedAt});if(o.length===0)return!1;o.sort((u,c)=>u.endedAt-c.endedAt);let l=0;for(const u of o){if(e.agents.size<=i)break;e.agents.delete(u.id),l++}return l>0}function uP(e,n,i,s){const o=new Map;for(const[h,p]of e.agents){let m=o.get(p.sessionId);m||(m={ids:[],endedAt:0,live:!1},o.set(p.sessionId,m)),m.ids.push(h),p.state==="done"&&p.endedAt!=null?m.endedAt=Math.max(m.endedAt,p.endedAt):m.live=!0}const l=[...o.values()].filter(h=>!h.live&&h.endedAt>0&&n-h.endedAt>s).sort((h,p)=>h.endedAt-p.endedAt);let c=[...o.values()].filter(h=>!h.live).length-i;if(c<=0)return!1;let f=!1;for(const h of l){if(c<=0)break;for(const p of h.ids)e.agents.delete(p);c--,f=!0}return f}function cP(e,n,i){let s=!1;for(const o of e.agents.values()){let l=!1;for(const u of o.tools)u.endedAt==null&&n-u.startedAt>i&&(u.endedAt=u.startedAt+i,u.ok=!1,u.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(u.id),e.toolOwner.delete(u.id),l=!0,s=!0);l&&$o(o)}return s}function Gw(e,n){if(n.seq<=e.lastSeq)return e;const i=n.payload??{},s=n.receivedAt,o=i.hook_event_name??"Unknown";if(o==="__clear")return{...Fg(),lastSeq:n.seq};e.totalEvents+=1,e.lastSeq=n.seq;const l=i.session_id??"unknown";if(o==="ModelObserved"){const f=typeof i.model=="string"?i.model:null;if(f){const p=e.agents.get(l);p&&(p.model=f)}const h=i.subagentModels;if(h&&typeof h=="object")for(const[p,m]of Object.entries(h)){if(typeof m!="string")continue;const y=`${l}::${p}`,w=e.agents.get(y);w&&(w.model=m)}return e}if(o==="ContextObserved"){const f=i.context??null;if(f){const h=e.agents.get(l);h&&(h.context={msgsUser:Number(f.msgsUser??0),msgsAssistant:Number(f.msgsAssistant??0),toolUses:Number(f.toolUses??0),toolResults:Number(f.toolResults??0),systemReminders:Number(f.systemReminders??0),currentContextTokens:Number(f.currentContextTokens??0),claudeMdFiles:Array.isArray(f.claudeMdFiles)?f.claudeMdFiles:[]})}return e}if(o==="UsageObserved"){const f=i.usage??null;if(f){const h=e.agents.get(l);h&&(h.usage.inputTokens=Number(f.input_tokens??0),h.usage.outputTokens=Number(f.output_tokens??0),h.usage.cacheReadTokens=Number(f.cache_read_input_tokens??f.cached_input_tokens??0),h.usage.cacheCreateTokens=Number(f.cache_creation_input_tokens??0),typeof f.reasoning_output_tokens=="number"&&(h.usage.reasoningOutputTokens=Number(f.reasoning_output_tokens)))}return e}const u=Ww(e,i,s);u.provider||(u.provider=i.provider==="codex"?"codex":"claude"),typeof i.model_context_window=="number"&&i.model_context_window>0&&(u.contextWindow=i.model_context_window);const c=lN(i);switch(c&&(u.model=c),o){case"SessionStart":{const f=Bo(e,l,s,!1);f.synthetic=!1,f.state="active",f.startedAt=f.startedAt||s,!f.cwd&&i.cwd&&(f.cwd=i.cwd,f.cwdBasename=si(i.cwd)),f.label==="session"&&i.cwd&&(f.label=si(i.cwd)??"session");break}case"UserPromptSubmit":{for(const m of e.agents.values())m.sessionId===l&&m.kind==="subagent"&&m.state==="done"&&m.exitAt==null&&m.endedAt!=null&&m.endedAt<s&&(m.exitAt=s);const f=Bo(e,l,s,!1);f.state="active",f.endedAt=void 0,f.exitAt=void 0;const h=Ww(e,i,s);h.state="active",h.exitAt=void 0,h.endedAt=void 0;const p=(typeof i.prompt=="string"?i.prompt:typeof i.message=="string"?i.message:"")??"";p&&(h.prompts.push({at:s,text:p}),h.firstPrompt||(h.firstPrompt=rd(p,120)));break}case"PreToolUse":{const f=i.tool_use_id??`${u.id}:${u.toolCount}`,h={id:f,name:i.tool_name??"?",input:i.tool_input,inputPreview:rd(i.tool_input),agentId:u.id,startedAt:s};u.tools.push(h),u.toolCount+=1,u.state="active",e.toolIndex.set(f,h),e.toolOwner.set(f,u.id),$o(u);break}case"PostToolUse":case"PostToolUseFailure":{const f=i.tool_use_id;if(!f)break;let h=e.toolIndex.get(f),p=!1;if(!h)for(const w of e.agents.values()){const j=w.tools.find(_=>_.id===f);if(j){h=j,p=!0;break}}if(!h)break;h.endedAt=s,h.ok=o==="PostToolUse",h.response=i.tool_response,o==="PostToolUseFailure"?h.errorPreview=rd(i.tool_response):p&&(h.errorPreview=void 0);const m=aN(i.tool_response);m&&(h.usage=m),e.toolIndex.delete(f);const y=e.toolOwner.get(f)??h.agentId;if(e.toolOwner.delete(f),y){const w=e.agents.get(y);w&&(m&&rP(w.usage,m),$o(w))}break}case"SubagentStart":{const f=zg(i);if(!f)break;const h=sP(e,l,f,i,s);h.state="active",h.startedAt=h.startedAt||s,h.exitAt=void 0,h.endedAt=void 0;const p=Ll(i);p&&(h.label=p),oP(e,l,f);break}case"SubagentStop":{const f=zg(i);if(!f)break;const h=uN(e,l,f,i);if(!h)break;h.state="done",h.endedAt=s,$o(h),aP(e,l,f);break}case"Stop":case"SessionEnd":{const f=Bo(e,l,s,!1);f.state="done",f.endedAt=s,$o(f);break}}return e}function dv(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}const dP=Date.UTC(2026,8,1);function fP(){return Date.now()<dP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}}const hP=[{match:/^claude[-_](fable|mythos)[-_]5\b/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5}},{match:/^claude[-_]opus[-_]5\b/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25}},{match:/^claude[-_]sonnet[-_]5\b/i,rates:fP()},{match:/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25}},{match:/^claude[-_]opus[-_]4(?:[-_.]1)?\b/i,rates:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}},{match:/^claude[-_]sonnet[-_]4[-_.](?:5|6)\b/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}},{match:/^claude[-_]sonnet[-_]4\b/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}},{match:/^claude[-_]haiku[-_]4[-_.]5\b/i,rates:{input:1,output:5,cacheRead:.1,cacheWrite:1.25}},{match:/^claude[-_]haiku[-_]3[-_.]5\b/i,rates:{input:.8,output:4,cacheRead:.08,cacheWrite:1}},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]6[-_]luna/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra/i,rates:{input:2,output:12,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]5[-_.]6(?:[-_]sol)?\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:6.25}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]pro/i,rates:{input:30,output:180,cacheRead:3,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]mini/i,rates:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]nano/i,rates:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4\b/i,rates:{input:2.5,output:15,cacheRead:.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]3[-_]codex/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2[-_]pro/i,rates:{input:21,output:168,cacheRead:21,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2\b/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^codex[-_]mini/i,rates:{input:1.5,output:6,cacheRead:.375,cacheWrite:0}},{match:/^o1[-_]pro/i,rates:{input:150,output:600,cacheRead:150,cacheWrite:0}},{match:/^o1\b/i,rates:{input:15,output:60,cacheRead:7.5,cacheWrite:0}},{match:/^o3[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o3[-_]pro/i,rates:{input:20,output:80,cacheRead:20,cacheWrite:0}},{match:/^o4[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0}},{match:/^o3\b/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}}];function pP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function fv(e){if(!e)return null;for(const n of hP)if(n.match.test(e))return n.rates;return null}const mP=272e3,gP=/^gpt[-_]5[-_.](?:6(?![-_]cyber)|5|4)/i;function vP(e,n){return!e||n<=mP?{input:1,output:1}:gP.test(e)?{input:2,output:1.5}:{input:1,output:1}}function un(e,n){const i=fv(n);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const s=pP(n),o=s?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens,l=s?vP(n,e.inputTokens):{input:1,output:1},u=o*i.input*l.input/1e6,c=e.outputTokens*i.output*l.output/1e6,f=e.cacheReadTokens*i.cacheRead*l.input/1e6,h=e.cacheCreateTokens*i.cacheWrite*l.input/1e6;return{input:u,output:c,cacheRead:f,cacheWrite:h,total:u+c+f+h}}const Yw=2e5,yP=1e6,wP=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],xP=[{match:/^gpt[-_]5[-_.]6[-_]cyber/i,window:4e5},{match:/^gpt[-_]5[-_.]6/i,window:105e4},{match:/^gpt[-_]5[-_.]5/i,window:105e4},{match:/^gpt[-_]5[-_.]4[-_](?:mini|nano)/i,window:4e5},{match:/^gpt[-_]5[-_.]4/i,window:105e4},{match:/^gpt[-_]5[-_.]3[-_]codex[-_]spark/i,window:128e3},{match:/^gpt[-_]5[-_.]3[-_]codex/i,window:4e5},{match:/^gpt[-_]5[-_.]2/i,window:4e5},{match:/^gpt[-_]5/i,window:4e5},{match:/^codex[-_]mini/i,window:2e5},{match:/^o\d/i,window:2e5}];function cN(e){if(!e)return Yw;for(const n of wP)if(n.test(e))return yP;for(const n of xP)if(n.match.test(e))return n.window;return Yw}function ze(e){return e<=0?"—":e<.005?"<1¢":e<1?`${(e*100).toFixed(e<.1?1:0)}¢`:e<100?`$${e.toFixed(2)}`:e<1e4?`$${e.toFixed(0)}`:`$${(e/1e3).toFixed(1)}k`}function $l(e,n){if(e<=0||n<10)return null;const i=e/n,s=i*60;return s>=.01?`${ze(s)}/min`:`${ze(i*3600)}/hr`}function An(e){return e.toLocaleString()}function _P(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function SP({agent:e,onClose:n}){var h;const i=e.context,s=e.usage,o=(i==null?void 0:i.currentContextTokens)??0,l=cN(e.model),u=Math.min(100,o/l*100),c=un(s,e.model),f=s.inputTokens+s.cacheReadTokens+s.cacheCreateTokens;return g.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{className:"ctx-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[g.jsxs("header",{className:"ctx-modal-head",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),g.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),g.jsx("button",{className:"ctx-modal-close",onClick:n,"aria-label":"Close",children:"×"})]}),g.jsxs("section",{className:"ctx-window-row",children:[g.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u),children:g.jsx("div",{className:"ctx-window-fill",style:{width:`${u}%`}})}),g.jsxs("div",{className:"ctx-window-meta",children:[g.jsxs("span",{className:"ctx-window-pct",children:[u.toFixed(1),"%"]}),g.jsxs("span",{className:"ctx-window-num",children:[An(o)," / ",An(l)," tok (current turn)"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Vn,{label:"input tokens",val:An(s.inputTokens)}),g.jsx(Vn,{label:"output tokens",val:An(s.outputTokens)}),g.jsx(Vn,{label:"cache reads",val:An(s.cacheReadTokens)}),g.jsx(Vn,{label:"cache writes",val:An(s.cacheCreateTokens)}),g.jsx(Vn,{label:"cumulative total",val:An(f)}),g.jsx(Vn,{label:"estimated cost",val:ze(c.total),accent:!0})]}),g.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Vn,{label:"user messages",val:An((i==null?void 0:i.msgsUser)??0)}),g.jsx(Vn,{label:"assistant messages",val:An((i==null?void 0:i.msgsAssistant)??0)}),g.jsx(Vn,{label:"tool uses",val:An((i==null?void 0:i.toolUses)??0)}),g.jsx(Vn,{label:"tool results",val:An((i==null?void 0:i.toolResults)??0)}),g.jsx(Vn,{label:"system-reminders",val:An((i==null?void 0:i.systemReminders)??0)})]}),g.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((h=i==null?void 0:i.claudeMdFiles)==null?void 0:h.length)??0)===0?g.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):g.jsx("ul",{className:"ctx-md-list",children:i.claudeMdFiles.map(p=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:p.path,children:p.path}),g.jsx("span",{className:"ctx-md-size",children:_P(p.bytes)})]},p.path))})]})})}function Vn({label:e,val:n,accent:i}){return g.jsxs("div",{className:`ctx-row${i?" accent":""}`,children:[g.jsx("span",{className:"ctx-row-label",children:e}),g.jsx("span",{className:"ctx-row-val",children:n})]})}function bP({currentContextTokens:e,modelId:n,size:i=26,onClick:s,title:o}){const l=cN(n),u=Math.min(1,e/l),c=i/2-3,f=i/2,h=2*Math.PI*c,p=h*u,m=u>.9?"var(--err)":u>.7?"var(--inflight)":"var(--accent)";return g.jsx("button",{type:"button",className:"ctx-donut",onClick:s,title:o??`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(u*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:g.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[g.jsx("circle",{cx:f,cy:f,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),g.jsx("circle",{cx:f,cy:f,r:c,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${p} ${h-p}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),g.jsx("text",{x:f,y:f+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(u*100)})]})})}function kP(e,n){const i=fv(n);if(!i)return"no rates for this model";const s=u=>u.toLocaleString(),o=u=>`$${u}/MTok`,l=un(e,n);return[`model: ${n}`,`input ${s(e.inputTokens).padStart(14)} × ${o(i.input).padEnd(11)} = ${ze(l.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(i.output).padEnd(11)} = ${ze(l.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(i.cacheRead).padEnd(11)} = ${ze(l.cacheRead)}`,`cache w ${s(e.cacheCreateTokens).padStart(14)} × ${o(i.cacheWrite).padEnd(11)} = ${ze(l.cacheWrite)}`,"─────────────────────────────────────────",`total = ${ze(l.total)}`].join(`
|
|
58
58
|
`)}function EP(e,n,i){const s=(n??i)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60),u=o%60;return`${l}m ${String(u).padStart(2,"0")}s`}function NP({data:e,selected:n}){var h;const i=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(p=>!p.endedAt).length,u=`hsl(${dv(e.sessionId)} 70% 60%)`,c=((h=e.context)==null?void 0:h.currentContextTokens)??0,f=e.kind==="root"&&c>0;return g.jsxs("div",{className:s,style:{"--accent":u},children:[g.jsx("span",{className:"accent-stripe"}),g.jsx(Hs,{type:"target",position:Ce.Left,style:{background:"transparent",border:"none"}}),g.jsxs("div",{className:"head",children:[g.jsxs("div",{className:"title",children:[g.jsx(CP,{state:e.state}),g.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&g.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),g.jsxs("div",{className:"head-right",children:[f&&e.onOpenContext&&g.jsx(bP,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),g.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:EP(e.startedAt,e.endedAt,i)})]})]}),g.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&g.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&g.jsx("span",{className:"model-chip",title:e.model,children:na(e.model)})]}),e.tools.length>0&&g.jsx(RP,{tools:e.tools,now:i}),g.jsxs("div",{className:"meta",children:[g.jsxs("span",{children:[g.jsx("b",{children:e.toolCount})," tools"]}),o>0&&g.jsxs("span",{className:"inflight-meta",children:[g.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&g.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[g.jsx("b",{children:jP(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&fv(e.model)&&(()=>{const p=un(e.usage,e.model);if(p.total<=0)return null;const m=Math.max(0,((e.endedAt??i)-e.startedAt)/1e3),y=e.state==="active"?$l(p.total,m):null,w=kP(e.usage,e.model)+(y?`
|
|
59
|
-
burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:w,children:[g.jsx("b",{children:ze(p.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(Hs,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function CP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function jP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function RP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const j=23-Math.floor(w/2500);j>=0&&j<24&&(l[j]+=1,u+=1)}const c=Math.max(1,...l),f=132,h=14,p=f/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:f,height:h,viewBox:`0 0 ${f} ${h}`,"aria-hidden":!0,children:l.map((y,w)=>{const j=y===0?1.5:Math.max(1.5,y/c*h),_=w===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:w*p+.4,y:h-j,width:Math.max(.5,p-1),height:j,rx:.8,className:b},w)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function na(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const i=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function Kw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function TP(e){if(e.endedAt==null)return"in-flight…";const n=e.endedAt-e.startedAt;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(2)}s`}function AP({tool:e,onClose:n}){M.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:g.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`}),g.jsx("span",{className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:TP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Kw(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Kw(e.response??e.errorPreview)})]})]})]})})}const yl=18,Xw=26,IP=12;function MP(e){const n=new Map;for(const o of e.nodeInternals.values()){const l=o.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,f=u+o.width,h=c+o.height,p=n.get(l.sessionId);p?(p.minX=Math.min(p.minX,u),p.minY=Math.min(p.minY,c),p.maxX=Math.max(p.maxX,f),p.maxY=Math.max(p.maxY,h),l.kind==="root"&&(p.label=Qw(l)??p.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:f,maxY:h,label:Qw(l)??l.sessionId})}const i=new Map;for(const o of n.values())i.set(o.label,(i.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(i.get(l.label)??0)>1?`${l.label} · ${PP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-yl,y:l.minY-yl-Xw,w:l.maxX-l.minX+yl*2,h:l.maxY-l.minY+yl*2+Xw})}return s}function PP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Qw(e){if(e.kind==="root")return e.label}function OP(){const{x:e,y:n,zoom:i}=tN(),s=ta(),o=Ze(MP,qP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(f=>{const h=f.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=dv(u.sessionId),f={position:"absolute",left:u.x*i+e,top:u.y*i+n,width:u.w*i,height:u.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*i+e+16*i,top:(u.y-IP)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return g.jsxs(le.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:f,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function qP(e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++){const s=e[i],o=n[i];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function LP({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const dN=600,$P=36,Bg=16,DP=60,FP=6,Zw=220,Jw=96,zP=28,BP={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan",ScheduleWakeup:"other",CronCreate:"other",CronList:"other",CronDelete:"other",Monitor:"other",PushNotification:"other",RemoteTrigger:"other",ToolSearch:"other"};function UP(e){return e.startsWith("mcp__")?"mcp":BP[e]??"other"}const HP={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",shell:"⚡",exec_command:"⚡",shell_command:"⚡",write_stdin:"💻",wait:"⏳",apply_patch:"🩹",update_plan:"📋",LS:"📂",Task:"🤖",Agent:"🤖",TodoWrite:"📋",TaskCreate:"📋",TaskUpdate:"📝",TaskList:"🗂️",TaskGet:"🗂️",TaskOutput:"📤",TaskStop:"🛑",WebFetch:"🌐",WebSearch:"🔭",ToolSearch:"🧰",NotebookEdit:"📓",EnterPlanMode:"🧭",ExitPlanMode:"🏁",AskUserQuestion:"❓",ScheduleWakeup:"⏰",CronCreate:"⏰",CronList:"📅",CronDelete:"🗑️",Skill:"🎯",Workflow:"🎬",Monitor:"📡",PushNotification:"🔔",RemoteTrigger:"📡"};function ex(e){return e.startsWith("mcp__")?"🔌":HP[e]??"✨"}const VP={git:"🐙",gh:"🐙",glab:"🐙",npm:"📦",pnpm:"📦",yarn:"📦",bun:"📦",brew:"🍺",node:"🟢",deno:"🟢",python:"🐍",python3:"🐍",py:"🐍",pip:"🐍",pip3:"🐍",uv:"🐍",ruby:"💎",bundle:"💎",gem:"💎",cargo:"🦀",rustc:"🦀",rustup:"🦀",go:"🐹",docker:"🐳","docker-compose":"🐳",podman:"🐳",kubectl:"☸️",helm:"☸️",k9s:"☸️",grep:"🔎",rg:"🔎",ag:"🔎",ack:"🔎",find:"🔍",fd:"🔍",locate:"🔍",which:"🔍",ls:"📂",dir:"📂",tree:"📂",cat:"📄",head:"📄",tail:"📄",less:"📄",more:"📄",bat:"📄",cp:"📋",mv:"✂️",rm:"🗑️",rmdir:"🗑️",mkdir:"📁",touch:"📁",sed:"✏️",awk:"✏️",tr:"✏️",curl:"🌐",wget:"🌐",http:"🌐",httpie:"🌐",ssh:"🔐",scp:"🔐",rsync:"🔐",ping:"📡",make:"🔨",cmake:"🔨",ninja:"🔨",bazel:"🔨",just:"🔨",terraform:"🏗️",ansible:"📕",pulumi:"🏗️",ps:"📊",top:"📊",htop:"📊",btm:"📊",kill:"💀",pkill:"💀",systemctl:"⚙️",service:"⚙️",tar:"🗜️",zip:"🗜️",unzip:"🗜️",gzip:"🗜️","7z":"🗜️",vim:"📝",nvim:"📝",nano:"📝",emacs:"📝",code:"📝",jq:"🪺",yq:"🪺",echo:"💬",printf:"💬",ffmpeg:"🎞️",ffprobe:"🎞️",imagemagick:"🖼️",convert:"🖼️","Get-ChildItem":"📂","Get-Content":"📄","Set-Content":"💾","Out-File":"💾","Add-Content":"💾","Set-Location":"📍","Get-Location":"📍","Get-Process":"📊","Start-Process":"▶️","Stop-Process":"💀","Invoke-WebRequest":"🌐","Invoke-RestMethod":"🌐","New-Item":"📁","Remove-Item":"🗑️","Copy-Item":"📋","Move-Item":"✂️","Test-Path":"🔍","Where-Object":"🔎","ForEach-Object":"🔁","Select-Object":"🎯","Measure-Object":"📊","Get-Service":"⚙️","Restart-Service":"⚙️","ConvertTo-Json":"🪺","ConvertFrom-Json":"🪺"};function fN(e){if(!e)return null;let n=e.trim();if(!n)return null;const i=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(i)return fN(i[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function WP(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(i=>typeof i=="string")){const i=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(i[0]??"")){const s=i.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<i.length)return i[s+1]}return i.join(" ")}return typeof n.script=="string"?n.script:null}const GP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),YP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function KP(e,n){return YP.has(e)?Math.max(Jw,34+n.length*7.5):Jw}function XP(e,n){if(!GP.has(e))return null;const i=WP(n);if(!i)return null;const s=fN(i);return s?{emoji:VP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const QP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),tx={ts:"🟦",tsx:"🟦",d:"🟦",js:"🟨",jsx:"🟨",mjs:"🟨",cjs:"🟨",py:"🐍",pyi:"🐍",ipynb:"📓",rs:"🦀",go:"🐹",rb:"💎",erb:"💎",java:"☕",kt:"☕",scala:"☕",gradle:"☕",cs:"🔷",fs:"🔷",php:"🐘",swift:"🦅",c:"🇨",cpp:"🇨",cc:"🇨",h:"🇨",hpp:"🇨",md:"📝",mdx:"📝",rst:"📝",json:"🪺",json5:"🪺",jsonl:"🪺",yaml:"⚙️",yml:"⚙️",toml:"⚙️",ini:"⚙️",conf:"⚙️",cfg:"⚙️",xml:"📰",html:"🌐",htm:"🌐",vue:"🌐",svelte:"🌐",css:"🎨",scss:"🎨",sass:"🎨",less:"🎨",sh:"⚡",bash:"⚡",zsh:"⚡",fish:"⚡",ps1:"⚡",txt:"📄",log:"📄",out:"📄",csv:"📊",tsv:"📊",xlsx:"📊",xls:"📊",pdf:"📕",png:"🖼️",jpg:"🖼️",jpeg:"🖼️",gif:"🖼️",webp:"🖼️",svg:"🖼️",ico:"🖼️",mp4:"🎬",mov:"🎬",avi:"🎬",mkv:"🎬",webm:"🎬",mp3:"🎵",wav:"🎵",ogg:"🎵",flac:"🎵",zip:"🗜️",tar:"🗜️",gz:"🗜️",bz2:"🗜️","7z":"🗜️",xz:"🗜️",rar:"🗜️",env:"🔐",lock:"🔐",pem:"🔐",key:"🔐",crt:"🔐",sql:"🗄️",db:"🗄️",sqlite:"🗄️",parquet:"🗄️"},nx={dockerfile:"🐳",makefile:"🔨",rakefile:"💎","package.json":"📦","pnpm-lock.yaml":"📦","yarn.lock":"📦","cargo.toml":"🦀","cargo.lock":"🦀","go.mod":"🐹","go.sum":"🐹","pyproject.toml":"🐍","requirements.txt":"🐍","readme.md":"📖",readme:"📖",license:"📜",".gitignore":"🐙",".gitattributes":"🐙",".env":"🔐",".dockerignore":"🐳"};function ZP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function JP(e){const n=e.toLowerCase();if(nx[n])return nx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const i=n.lastIndexOf(".");if(i>0&&i<n.length-1){const s=n.slice(i+1);if(tx[s])return tx[s]}return"📄"}function e3(e,n){if(!n||typeof n!="object")return null;const i=n;if(e==="apply_patch"&&typeof i.patch=="string"){const s=i.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof i.file_path=="string"?i.file_path:typeof i.notebook_path=="string"?i.notebook_path:typeof i.path=="string"?i.path:e==="Glob"&&typeof i.pattern=="string"?i.pattern:null}function t3(e,n){if(!QP.has(e))return null;const i=e3(e,n);if(!i)return null;const s=ZP(i);return s?{emoji:e==="LS"?"📂":JP(s),label:s,category:"file",detail:i}:null}const hN={github:{emoji:"🐙",name:"GitHub"},git:{emoji:"🐙",name:"Git"},gitlab:{emoji:"🦊",name:"GitLab"},slack:{emoji:"💬",name:"Slack"},discord:{emoji:"💬",name:"Discord"},linear:{emoji:"📐",name:"Linear"},jira:{emoji:"🅹",name:"Jira"},atlassian:{emoji:"🅰️",name:"Atlassian"},notion:{emoji:"📓",name:"Notion"},asana:{emoji:"📋",name:"Asana"},intercom:{emoji:"💬",name:"Intercom"},figma:{emoji:"🎨",name:"Figma"},gmail:{emoji:"📧",name:"Gmail"},calendar:{emoji:"📅",name:"Calendar"},drive:{emoji:"☁️",name:"Drive"},zoom:{emoji:"📹",name:"Zoom"},spotify:{emoji:"🎵",name:"Spotify"},youtube:{emoji:"📺",name:"YouTube"},ccd_session:{emoji:"📡",name:"Session"},ccd_directory:{emoji:"📂",name:"Directory"},ccd_session_mgmt:{emoji:"📡",name:"Sessions"},mcp_registry:{emoji:"🧰",name:"Registry"},"computer-use":{emoji:"🖱️",name:"Computer"},"claude-in-chrome":{emoji:"🌐",name:"Chrome"},"claude-preview":{emoji:"👀",name:"Preview"},"scheduled-tasks":{emoji:"⏰",name:"Scheduler"},visualize:{emoji:"🎨",name:"Visualize"},"plugin-design-asana":{emoji:"📋",name:"Asana"},"plugin-design-atlassian":{emoji:"🅰️",name:"Atlassian"},"plugin-design-figma":{emoji:"🎨",name:"Figma"},"plugin-design-intercom":{emoji:"💬",name:"Intercom"},"plugin-design-linear":{emoji:"📐",name:"Linear"},"plugin-design-notion":{emoji:"📓",name:"Notion"},"plugin-design-slack":{emoji:"💬",name:"Slack"}};function pN(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),i=n.indexOf("__");return i<=0?{server:n,method:""}:{server:n.slice(0,i),method:n.slice(i+2)}}function n3(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}function r3(e,n){const i=pN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const l=hN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function i3(e,n){return XP(e,n)??t3(e,n)??r3(e)}const s3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function o3(e){const n=pN(e);if(n){const s=hN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:n3(n.server)}}const i=s3[e];return i?{emoji:ex(e),label:i}:{emoji:ex(e),label:e}}function a3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function l3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/dN)}function u3(e,n,i,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>dN)continue;const f=s.get(c.id)??i.get(c.id);if(!f)continue;const h=c.tools.slice(-4);if(h.length===0)continue;const p=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??Zw,Zw),w=(m==null?void 0:m.height)??130,j=f.x,_=f.y,S=j+y,b=_+w/2;h.forEach((E,N)=>{const C=N*$P,I=j+y+DP,O=_+FP+C,P=l3(E,l,p),z=E.inputPreview??"",T=a3(E),q=P<.999,B=o3(E.name);u.push({id:E.id,toolId:E.id,agentId:c.id,toolName:E.name,name:B.label,emoji:B.emoji,status:T,category:UP(E.name),mcpHue:B.hue,inputPreview:z,fade:P,fading:q,worldX:I,worldY:O,anchorX:S,anchorY:b,spawnDx:S-I,spawnDy:b-(O+Bg)});const J=i3(E.name,E.input);if(J){const Q=KP(E.name,B.label),A=I+Q+zP,H=O,U=I+Q,ne=O+Bg;u.push({id:`sub:${E.id}`,toolId:E.id,agentId:c.id,toolName:E.name,name:J.label,emoji:J.emoji,isSub:!0,status:T,category:J.category,inputPreview:J.detail??z,fade:P,fading:q,worldX:A,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-A,spawnDy:0})}})}return u}function c3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:f,onOpenTool:h}){const{x:p,y:m,zoom:y}=tN(),w=u3(e,n,i,s,o,f),j=c&&c.size>0?w.filter(_=>!c.has(_.category)):w;return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:j.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,E=(_.worldX+6)*y+p,N=(_.worldY+Bg)*y+m,C=S+(E-S)*.55,I=l!=null&&!l.has(_.agentId),O=u!=null&&!u.has(_.agentId),P=_.fade*(I||O?.14:1);return g.jsx("path",{d:`M ${S} ${b} Q ${C} ${b}, ${E} ${N}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:P},`l:${_.id}`)})}),j.map(_=>{const S=_.worldX*y+p,b=_.worldY*y+m,E={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},N=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${N} · ${_.inputPreview}`:N,I=h!=null,O=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},P=l!=null&&!l.has(_.agentId),z=u!=null&&!u.has(_.agentId),T=P||z?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:E,children:g.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${I?" clickable":""}${_.isSub?" sub":""}${T}`,style:O,title:C,role:I?"button":void 0,tabIndex:I?0:void 0,"aria-label":I?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:I?()=>h(_.toolId):void 0,onKeyDown:I?q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),h(_.toolId))}:void 0,children:[g.jsx("span",{className:"tb-emoji",children:_.emoji}),g.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),_.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function d3({state:e,sessionId:n,onClose:i}){const s=M.useMemo(()=>h3(e,n),[e,n]);return s?g.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),g.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:ze(s.cost.total)}),s.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>g.jsx("span",{className:"model-chip",title:o,children:na(o)},o))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(f3,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:ze(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:ze(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:ze(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:ze(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Ps,{label:"agents",value:s.agentCount}),g.jsx(Ps,{label:"subagents",value:s.subagentCount}),g.jsx(Ps,{label:"tool calls",value:s.toolCount}),g.jsx(Ps,{label:"prompts",value:s.promptCount}),g.jsx(Ps,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx(Ps,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Most-used tools"}),g.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,l])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:o}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${l/s.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:l})]},o))})]}),s.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Ps({label:e,value:n,tone:i}){return g.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function f3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function h3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const N of e.agents.values())N.sessionId===n&&s.push(N);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,f=0,h=0,p=0,m=0,y,w=1/0,j=0;for(const N of s){const C=un(N.usage,N.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,N.model&&l.add(N.model),N.kind==="subagent"&&m++,f+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),h+=N.usage.inputTokens+N.usage.outputTokens,c+=N.tools.length,w=Math.min(w,N.startedAt),j=Math.max(j,N.endedAt??Date.now());for(const I of N.tools)u.set(I.name,(u.get(I.name)??0)+1),I.ok===!1&&p++}const _=Math.max(0,j-w),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,E=Array.from(u.entries()).sort((N,C)=>C[1]-N[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:f,tokensSum:h,errCount:p,topTools:E,firstPrompt:y}}function p3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,l=un(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.tools.length,l+=un(c.usage,c.model).total;const f=c.endedAt??c.startedAt;f>u&&(u=f)}i.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return i.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),i}function m3(e,n,i){const s=(n??i)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function g3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const l=M.useMemo(()=>p3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return g.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[g.jsxs("div",{className:"sl-header",children:[g.jsxs("h3",{children:["Sessions ",g.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&g.jsxs("span",{className:"sl-live-count",children:[u," live"]}),g.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),g.jsxs("div",{className:"sl-rows",children:[l.length===0&&g.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const f=i.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${f?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[g.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&g.jsx("span",{className:"model-chip",title:c.modelId,children:na(c.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:ze(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:m3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function rx(e,n){if(!e)return null;const i=n-Math.floor(e/1e3);return i<10?"just now":i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:`${Math.floor(i/3600)}h ago`}function v3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function Nr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function y3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function w3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/3600),o=Math.floor(i%3600/60);if(s>23){const l=Math.floor(i/86400),u=Math.floor(i%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function x3(e,n,i,s){const o=Math.max(0,n-s),l=Math.max(0,i-o);if(l<120)return null;const u=Math.min(100,l/i*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const f=100-e,h=l>0?e/l:0,p=h>0?f/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(p<o&&p<86400){const y=Math.floor(p/3600),w=Math.floor(p%3600/60);m.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function qi({pct:e,label:n,reset:i,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",p=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?w3(s,u):null,w=s&&o?x3(c,s,o,u):null;return g.jsxs("div",{className:"qb-row",children:[g.jsxs("div",{className:"qb-meta",children:[g.jsxs("span",{className:"qb-label",children:[n,l&&g.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),g.jsx("span",{className:"qb-pct",style:{color:h},children:p})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),w&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?g.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,w&&g.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const _3=6e4;function S3(){const[e,n]=M.useState(null),[i,s]=M.useState(!1),o=M.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return M.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),_3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>l(!0)}}function b3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const mN=6e4;function k3(){const[e,n]=M.useState(null),[i,s]=M.useState(!1),o=M.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return M.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),mN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>l(!0)}}function E3(){const[e,n]=M.useState(null),i=M.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return M.useEffect(()=>(s(),i.current=window.setInterval(s,mN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function N3({state:e,now:n,onClose:i}){var P,z;const{quota:s,loading:o,refresh:l}=S3(),{data:u,loading:c,refresh:f}=k3(),{data:h}=E3(),[p,m]=M.useState(()=>Math.floor(Date.now()/1e3));M.useEffect(()=>{const T=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:w,totalTokens:j,burnRate:_}=M.useMemo(()=>{const T=new Map,q={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let B=0,J=0,Q=0,A=0;for(const L of e.agents.values()){const G=L.model??"__unknown__",k=un(L.usage,L.model),$=T.get(G);$?($.inputTokens+=L.usage.inputTokens,$.outputTokens+=L.usage.outputTokens,$.cacheReadTokens+=L.usage.cacheReadTokens,$.cacheCreateTokens+=L.usage.cacheCreateTokens,$.cost.total+=k.total,$.cost.input+=k.input,$.cost.output+=k.output,$.cost.cacheRead+=k.cacheRead,$.cost.cacheWrite+=k.cacheWrite,$.agentCount++):T.set(G,{model:G,inputTokens:L.usage.inputTokens,outputTokens:L.usage.outputTokens,cacheReadTokens:L.usage.cacheReadTokens,cacheCreateTokens:L.usage.cacheCreateTokens,cost:{...k},agentCount:1}),q.total+=k.total,q.input+=k.input,q.output+=k.output,q.cacheRead+=k.cacheRead,q.cacheWrite+=k.cacheWrite,B+=L.usage.inputTokens,J+=L.usage.outputTokens,Q+=L.usage.cacheReadTokens,A+=L.usage.cacheCreateTokens}const H=Array.from(T.values()).sort((L,G)=>G.cost.total-L.cost.total);let U=0,ne=0;for(const L of e.agents.values()){if(L.state!=="active")continue;const G=un(L.usage,L.model);U+=G.total,ne=Math.max(ne,((L.endedAt??n)-L.startedAt)/1e3)}const Y=ne>0?$l(U,ne):null;return{byModel:H,totalCost:q,totalTokens:{in:B,out:J,cacheR:Q,cacheC:A},burnRate:Y}},[e,e.lastSeq,n]),S=M.useMemo(()=>{const T=[];for(const q of e.agents.values()){if(q.kind!=="root")continue;let B=un(q.usage,q.model).total,J=q.usage.inputTokens,Q=q.usage.outputTokens;for(const A of e.agents.values())A.sessionId!==q.sessionId||A.kind==="root"||(B+=un(A.usage,A.model).total,J+=A.usage.inputTokens,Q+=A.usage.outputTokens);T.push({sessionId:q.sessionId,label:q.label||q.cwdBasename||"session",state:q.state,cost:B,inputTokens:J,outputTokens:Q})}return T.sort((q,B)=>B.cost-q.cost).slice(0,12)},[e,e.lastSeq]),b=w.total>0,E=j.in+j.out,N=o||c,C=rx(s==null?void 0:s.fetchedAt,p),I=rx(u==null?void 0:u.fetchedAt,p),O=()=>{l(),f()};return g.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),_&&g.jsx("span",{className:"up-rate",children:_}),g.jsxs("div",{className:"up-header-right",children:[g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:O,disabled:N,title:"Refresh Claude + Codex quota",children:N?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&g.jsx("span",{className:"up-section-age",title:v3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx(qi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:p}),s.week7dPct!=null&&g.jsx(qi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:p}),s.weekSonnetPct!=null&&g.jsx(qi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:p}),s.weekOpusPct!=null&&g.jsx(qi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:p})]}):(s==null?void 0:s.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),I&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:I})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(P=u.windows)==null?void 0:P.map(T=>g.jsx(qi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,limitReached:u.limitReached&&T.pct>=100,nowSec:p},T.id)),(z=u.extraWindows)==null?void 0:z.map(T=>g.jsx(qi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:p},T.id)),u.creditLimit&&g.jsx(qi,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:p}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[Nr(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&g.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:b3(u.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:ze(w.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(y3,{cost:w}),E>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Nr(j.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Nr(j.out)]}),j.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Nr(j.cacheR)]}),j.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Nr(j.cacheC)]})]}),y.filter(T=>T.cost.total>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:y.filter(T=>T.cost.total>0).map(T=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:T.model,children:na(T.model)}),g.jsx("td",{className:"up-num",children:Nr(T.inputTokens+T.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:ze(T.cost.total)})]},T.model))})]})]}),S.filter(T=>T.cost>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:S.filter(T=>T.cost>0).map(T=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${T.state}`,"aria-hidden":!0}),g.jsx("span",{className:"up-session-label",children:T.label}),g.jsx("span",{className:"up-session-tokens",children:Nr(T.inputTokens+T.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:ze(T.cost)})]},T.sessionId))})]})]}):E>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Nr(j.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Nr(j.out)]})]}),g.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const C3=1500;async function wl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const j3={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck1:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:"that share was made by a newer agents-deck",expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import"},id=(e,n)=>(e==null?void 0:e.detail)||(e!=null&&e.reason?j3[e.reason]??e.reason:null)||n;function R3({onClose:e,onChanged:n}){const[i,s]=M.useState("login"),[o,l]=M.useState(null),[u,c]=M.useState(""),[f,h]=M.useState(""),[p,m]=M.useState(!1),[y,w]=M.useState(null),[j,_]=M.useState(null),S=M.useRef(!1),b=M.useRef(null),E=M.useCallback(()=>{S.current&&wl({action:"login-cancel"}).catch(()=>{}),e()},[e]);M.useEffect(()=>{const P=z=>{z.key==="Escape"&&E()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[E]);const N=M.useCallback(async()=>{m(!0),w(null),S.current=!0;const P=await wl({action:"login"}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"could not start the sign-in"));return}l(P)},[]);M.useEffect(()=>{i!=="login"||S.current||N()},[i,N]),M.useEffect(()=>{if(!o||o.state==="done"||o.state==="failed")return;const P=window.setInterval(async()=>{try{const z=await fetch("/api/claude-accounts/login");z.ok&&l(await z.json())}catch{}},C3);return()=>window.clearInterval(P)},[o]),M.useEffect(()=>{var P;(o==null?void 0:o.state)==="awaiting_code"&&((P=b.current)==null||P.focus()),(o==null?void 0:o.state)==="done"&&n()},[o==null?void 0:o.state,n]);const C=M.useCallback(async()=>{var z;m(!0),w(null);const P=await wl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"the code was not accepted")),P!=null&&P.state&&l(P),(z=b.current)==null||z.select();return}c(""),l(P)},[u,o]),I=M.useCallback(async()=>{m(!0),w(null);const P=await wl({action:"import",blob:f}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"the import failed"));return}h(""),_({added:P.added===!0,num:P.num??null}),n()},[f,n]),O=(o==null?void 0:o.state)==="done"?o.account:null;return g.jsx("div",{className:"modal-backdrop",onClick:E,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":i==="login",className:`aa-tab${i==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":i==="paste",className:`aa-tab${i==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:E,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:i==="login"?O?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:O.added?`Added account ${O.num}`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[O.email,O.added?" is now in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:b,type:"text",value:u,onChange:P=>c(P.target.value),onKeyDown:P=>{P.key==="Enter"&&u.trim()&&!p&&C()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:p||!u.trim()||o.state==="registering",onClick:C,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):(o==null?void 0:o.state)==="failed"||y?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Sign-in failed"}),g.jsx("p",{className:"aa-err",children:y??(o==null?void 0:o.error)}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),w(null),N()},children:"Try again"})]}):g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{type:"text",value:f,onChange:P=>h(P.target.value),onKeyDown:P=>{P.key==="Enter"&&f.trim()&&!p&&I()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:p||!f.trim(),onClick:I,children:p?"importing…":"Import"})]}),j&&g.jsx("p",{className:"aa-note",children:j.added?`Added account ${j.num}.`:"That account was already here, so nothing changed."}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}const T3=15e3,A3=[70,80,85,90,95];function I3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/86400),o=Math.floor(i%86400/3600),l=Math.floor(i%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function ix(e,n){const i=n-Math.floor(e/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function M3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?" · due":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function P3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function O3({lane:e,nowSec:n}){const i=Math.min(100,Math.max(0,e.pct)),s=i>=90?"var(--err)":i>=70?"var(--warn)":"var(--accent)",o=e.resetAt?I3(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function q3(e){const n=e.map(s=>s.num),i=n.length?Math.max(...n):0;return[...new Set([...n,i+1])].sort((s,o)=>s-o)}function L3(e,n){const i=Math.round(e/1e3)-n;return i<=0?"expired":i<60?`expires in ${i}s`:`expires in ${Math.round(i/60)}m`}function $3({onClose:e}){var Y,L,G;const[n,i]=M.useState(null),[s,o]=M.useState(null),[l,u]=M.useState(null),[c,f]=M.useState(null),[h,p]=M.useState(null),[m,y]=M.useState(()=>Math.floor(Date.now()/1e3)),w=M.useRef(null),[j,_]=M.useState(null),[S,b]=M.useState(!1),[E,N]=M.useState(""),[C,I]=M.useState(null),[O,P]=M.useState(null),[z,T]=M.useState(!1),q=M.useCallback(async(k=!1)=>{try{const[$,oe]=await Promise.all([fetch(`/api/claude-accounts${k?"?refresh=1":""}`),fetch("/api/cswap-auto")]);$.ok&&i(await $.json()),oe.ok&&o(await oe.json())}catch{}},[]),B=M.useCallback(async(k,$)=>{u($),p(null);try{const D=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return D!=null&&D.ok||p((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return p("server unreachable"),null}finally{u(null)}},[]),J=M.useCallback(async(k,$)=>{u($),p(null);try{const D=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return D!=null&&D.ok||p((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return p("server unreachable"),null}finally{u(null)}},[]);M.useEffect(()=>(q(!0),w.current=window.setInterval(()=>q(!1),T3),()=>{w.current!=null&&window.clearInterval(w.current)}),[q]),M.useEffect(()=>{const k=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(k)},[]);const Q=((Y=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Y.value)??"90",A=(L=n==null?void 0:n.accounts)==null?void 0:L.find(k=>k.active),H=A!=null&&A.lanes.length?Math.max(...A.lanes.map(k=>k.pct)):null,U=H!=null&&H>=Number(Q)-15,ne=async k=>{f(k),p(null);try{const oe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:k})})).json().catch(()=>null);oe!=null&&oe.ok||p((oe==null?void 0:oe.output)||(oe==null?void 0:oe.reason)||"switch failed"),await q(!0)}catch{p("server unreachable")}finally{f(null)}};return g.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h3",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>b(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>q(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(k=>g.jsxs("div",{className:`ap-account${k.active?" active":""}${k.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:k.num}),k.alias&&g.jsx("span",{className:"ap-alias",children:k.alias}),g.jsx("span",{className:"ap-email",title:k.org??void 0,children:k.email}),g.jsx("button",{type:"button",className:`ap-more${j===k.num?" on":""}`,"aria-label":`Manage account ${k.num}`,"aria-expanded":j===k.num,title:"Share, rename, move, remove",onClick:()=>{_(j===k.num?null:k.num),N(k.alias??""),I(null),P(null),T(!1)},children:"⋯"}),k.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||k.disabled,onClick:()=>ne(k.num),title:k.disabled?"Held out of rotation":`Switch to ${k.alias??k.email}`,children:c===k.num?"…":"switch"})]}),k.lanes.length>0?k.lanes.map($=>g.jsx(O3,{lane:$,nowSec:m},$.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[k.error&&g.jsx("span",{className:"ap-err",children:P3(k.error)}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!k.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>B({action:"account",account:k.num,enabled:k.disabled},`rot-${k.num}`).then(()=>q(!0)),title:k.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:k.disabled?"held out":"in rotation"}),k.fetchedAt?g.jsxs("span",{className:`ap-age${k.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",ix(k.fetchedAt,m),M3(k.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),j===k.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:E,onChange:$=>N($.target.value),onKeyDown:$=>{$.key==="Enter"&&J({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>q(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${k.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||E.trim()===(k.alias??""),onClick:()=>J({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>q(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${k.num}`,value:String(k.num),disabled:l!=null,onChange:$=>J({action:"move",account:k.num,slot:Number($.target.value)},`move-${k.num}`).then(()=>q(!0)),children:q3(n.accounts??[]).map($=>g.jsx("option",{value:$,children:$},$))})}),g.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{T(!1);const $=await J({action:"share",account:k.num},`share-${k.num}`);$!=null&&$.ok&&P({num:k.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${C===k.num?" armed":""}`,disabled:l!=null,title:C===k.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(C!==k.num){I(k.num),window.setTimeout(()=>I($=>$===k.num?null:$),4e3);return}I(null),J({action:"remove",account:k.num},`rm-${k.num}`).then(()=>{_(null),q(!0)})},children:C===k.num?"confirm remove":"remove"})]}),(O==null?void 0:O.num)===k.num&&g.jsxs("div",{className:"ap-share",children:[g.jsx("code",{className:"ap-share-blob",children:O.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",onClick:async()=>{try{await navigator.clipboard.writeText(O.blob),T(!0)}catch{}},children:z?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",L3(O.expiresAt,m)]})]})]})]})]},k.num)),(s==null?void 0:s.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&g.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:Q,disabled:l!=null,onChange:k=>B({action:"setting",key:"autoswitch.threshold",value:k.target.value},"threshold").then(()=>q(!0)),children:A3.map(k=>g.jsxs("option",{value:k,children:[k,"%"]},k))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>B({action:"enable",enabled:!s.enabled},"enable").then(()=>q(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",ix(s.lastTick.at,m)]})})]}),h&&g.jsx("div",{className:"ap-failure",children:h}),g.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),S&&g.jsx(R3,{onClose:()=>b(!1),onChanged:()=>q(!0)})]})}const D3=3e4;function F3({bundle:e,running:n,lastTried:i}){return!n||e===n?!1:i!==n}function z3(e){const n=e.thresholdMs??D3;return!e.enabled||e.kind!=="restart"||!e.canRestart?{idleSince:null,restart:!1}:e.busy?{idleSince:null,restart:!1}:e.idleSince==null?{idleSince:e.now,restart:!1}:e.now<e.idleSince?{idleSince:e.now,restart:!1}:{idleSince:e.idleSince,restart:e.now-e.idleSince>=n}}function Li(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:e<1e9?`${(e/1e6).toFixed(2)}M`:`${(e/1e9).toFixed(2)}B`}function sx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function xl(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}function B3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const U3=[7,14,30,90];function H3(e){const[n,i]=M.useState(null),[s,o]=M.useState(!1),l=(u=!1)=>{o(!0);const f=`/api/ccusage?since=${B3(e)}${u?"&refresh=1":""}`;fetch(f).then(h=>h.json()).then(i).catch(()=>i({ok:!1,error:"request failed"})).finally(()=>o(!1))};return M.useEffect(()=>{l(!1)},[e]),{data:n,loading:s,reload:()=>l(!0)}}function V3({onClose:e}){var b,E;const[n,i]=M.useState(30),[s,o]=M.useState(null),{data:l,loading:u,reload:c}=H3(n);M.useEffect(()=>{const N=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const f=l!=null&&l.ok?l.days??[]:[],h=M.useMemo(()=>f.reduce((N,C)=>Math.max(N,C.totalCost),0),[f]),{totalCost:p,totalTok:m,inOut:y,cacheRead:w,modelCosts:j}=M.useMemo(()=>{let N=0,C=0,I=0,O=0;const P=new Map;for(const z of f){N+=z.totalCost,C+=z.totalTokens,I+=z.inputTokens+z.outputTokens,O+=z.cacheReadTokens;for(const T of z.modelBreakdowns)P.set(T.modelName,(P.get(T.modelName)??0)+T.cost)}return{totalCost:N,totalTok:C,inOut:I,cacheRead:O,modelCosts:P}},[f]),_=M.useMemo(()=>Array.from(j.entries()).sort((N,C)=>C[1]-N[1]),[j]),S=s?f.find(N=>N.period===s)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{className:"uh-modal",onClick:N=>N.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),g.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:U3.map(N=>g.jsxs("button",{role:"tab","aria-selected":n===N,className:`uh-range-btn${n===N?" on":""}`,onClick:()=>{i(N),o(null)},children:[N,"d"]},N))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),g.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&f.length===0?g.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?g.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):f.length===0?g.jsx("div",{className:"uh-status",children:"no usage in this range"}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(_l,{label:"total cost",val:ze(p),accent:!0}),g.jsx(_l,{label:"tokens",val:Li(m)}),g.jsx(_l,{label:"input+output",val:Li(y)}),g.jsx(_l,{label:"cache reads",val:Li(w)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:f.map(N=>{const C=h>0?N.totalCost/h*100:0,I=N.period===s;return g.jsxs("button",{className:`uh-bar-col${I?" sel":""}`,onClick:()=>o(I?null:N.period),title:`${N.period} · ${ze(N.totalCost)}`,style:{flexBasis:`${100/f.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,N.totalCost>0?2:0)}%`},children:N.modelBreakdowns.slice().sort((O,P)=>P.cost-O.cost).map(O=>{const P=N.totalCost>0?O.cost/N.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${P}%`,background:xl(O.modelName)}},O.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:N.period.slice(5)})]},N.period)})}),g.jsx("div",{className:"uh-legend",children:_.map(([N,C])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:xl(N)}}),sx(N)," ",g.jsx("span",{className:"uh-legend-cost",children:ze(C)})]},N))}),S&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:S.period}),g.jsx("span",{className:"uh-detail-cost",children:ze(S.totalCost)}),(E=(b=S.metadata)==null?void 0:b.agents)!=null&&E.length?g.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Sl,{label:"input",val:Li(S.inputTokens)}),g.jsx(Sl,{label:"output",val:Li(S.outputTokens)}),g.jsx(Sl,{label:"cache write",val:Li(S.cacheCreationTokens)}),g.jsx(Sl,{label:"cache read",val:Li(S.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((N,C)=>C.cost-N.cost).map(N=>{const C=S.totalCost>0?N.cost/S.totalCost*100:0;return g.jsxs("div",{className:"uh-model-row",children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:xl(N.modelName)}}),sx(N.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:xl(N.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:ze(N.cost)})]},N.modelName)})})]})]})]})})}function _l({label:e,val:n,accent:i}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function Sl({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function hv(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var sd,ox;function W3(){if(ox)return sd;ox=1;function e(){this.__data__=[],this.size=0}return sd=e,sd}var od,ax;function Vs(){if(ax)return od;ax=1;function e(n,i){return n===i||n!==n&&i!==i}return od=e,od}var ad,lx;function Gl(){if(lx)return ad;lx=1;var e=Vs();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return ad=n,ad}var ld,ux;function G3(){if(ux)return ld;ux=1;var e=Gl(),n=Array.prototype,i=n.splice;function s(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():i.call(l,u,1),--this.size,!0}return ld=s,ld}var ud,cx;function Y3(){if(cx)return ud;cx=1;var e=Gl();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return ud=n,ud}var cd,dx;function K3(){if(dx)return cd;dx=1;var e=Gl();function n(i){return e(this.__data__,i)>-1}return cd=n,cd}var dd,fx;function X3(){if(fx)return dd;fx=1;var e=Gl();function n(i,s){var o=this.__data__,l=e(o,i);return l<0?(++this.size,o.push([i,s])):o[l][1]=s,this}return dd=n,dd}var fd,hx;function Yl(){if(hx)return fd;hx=1;var e=W3(),n=G3(),i=Y3(),s=K3(),o=X3();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,fd=l,fd}var hd,px;function Q3(){if(px)return hd;px=1;var e=Yl();function n(){this.__data__=new e,this.size=0}return hd=n,hd}var pd,mx;function Z3(){if(mx)return pd;mx=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return pd=e,pd}var md,gx;function J3(){if(gx)return md;gx=1;function e(n){return this.__data__.get(n)}return md=e,md}var gd,vx;function eO(){if(vx)return gd;vx=1;function e(n){return this.__data__.has(n)}return gd=e,gd}var vd,yx;function gN(){if(yx)return vd;yx=1;var e=typeof al=="object"&&al&&al.Object===Object&&al;return vd=e,vd}var yd,wx;function Qn(){if(wx)return yd;wx=1;var e=gN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return yd=i,yd}var wd,xx;function Ws(){if(xx)return wd;xx=1;var e=Qn(),n=e.Symbol;return wd=n,wd}var xd,_x;function tO(){if(_x)return xd;_x=1;var e=Ws(),n=Object.prototype,i=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=i.call(u,o),f=u[o];try{u[o]=void 0;var h=!0}catch{}var p=s.call(u);return h&&(c?u[o]=f:delete u[o]),p}return xd=l,xd}var _d,Sx;function nO(){if(Sx)return _d;Sx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return _d=i,_d}var Sd,bx;function Gi(){if(bx)return Sd;bx=1;var e=Ws(),n=tO(),i=nO(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):i(c)}return Sd=u,Sd}var bd,kx;function Pn(){if(kx)return bd;kx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return bd=e,bd}var kd,Ex;function ra(){if(Ex)return kd;Ex=1;var e=Gi(),n=Pn(),i="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var f=e(c);return f==s||f==o||f==i||f==l}return kd=u,kd}var Ed,Nx;function rO(){if(Nx)return Ed;Nx=1;var e=Qn(),n=e["__core-js_shared__"];return Ed=n,Ed}var Nd,Cx;function iO(){if(Cx)return Nd;Cx=1;var e=rO(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function i(s){return!!n&&n in s}return Nd=i,Nd}var Cd,jx;function vN(){if(jx)return Cd;jx=1;var e=Function.prototype,n=e.toString;function i(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Cd=i,Cd}var jd,Rx;function sO(){if(Rx)return jd;Rx=1;var e=ra(),n=iO(),i=Pn(),s=vN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,f=u.toString,h=c.hasOwnProperty,p=RegExp("^"+f.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!i(y)||n(y))return!1;var w=e(y)?p:l;return w.test(s(y))}return jd=m,jd}var Rd,Tx;function oO(){if(Tx)return Rd;Tx=1;function e(n,i){return n==null?void 0:n[i]}return Rd=e,Rd}var Td,Ax;function Yi(){if(Ax)return Td;Ax=1;var e=sO(),n=oO();function i(s,o){var l=n(s,o);return e(l)?l:void 0}return Td=i,Td}var Ad,Ix;function pv(){if(Ix)return Ad;Ix=1;var e=Yi(),n=Qn(),i=e(n,"Map");return Ad=i,Ad}var Id,Mx;function Kl(){if(Mx)return Id;Mx=1;var e=Yi(),n=e(Object,"create");return Id=n,Id}var Md,Px;function aO(){if(Px)return Md;Px=1;var e=Kl();function n(){this.__data__=e?e(null):{},this.size=0}return Md=n,Md}var Pd,Ox;function lO(){if(Ox)return Pd;Ox=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return Pd=e,Pd}var Od,qx;function uO(){if(qx)return Od;qx=1;var e=Kl(),n="__lodash_hash_undefined__",i=Object.prototype,s=i.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return Od=o,Od}var qd,Lx;function cO(){if(Lx)return qd;Lx=1;var e=Kl(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:i.call(l,o)}return qd=s,qd}var Ld,$x;function dO(){if($x)return Ld;$x=1;var e=Kl(),n="__lodash_hash_undefined__";function i(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Ld=i,Ld}var $d,Dx;function fO(){if(Dx)return $d;Dx=1;var e=aO(),n=lO(),i=uO(),s=cO(),o=dO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,$d=l,$d}var Dd,Fx;function hO(){if(Fx)return Dd;Fx=1;var e=fO(),n=Yl(),i=pv();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return Dd=s,Dd}var Fd,zx;function pO(){if(zx)return Fd;zx=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Fd=e,Fd}var zd,Bx;function Xl(){if(Bx)return zd;Bx=1;var e=pO();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return zd=n,zd}var Bd,Ux;function mO(){if(Ux)return Bd;Ux=1;var e=Xl();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return Bd=n,Bd}var Ud,Hx;function gO(){if(Hx)return Ud;Hx=1;var e=Xl();function n(i){return e(this,i).get(i)}return Ud=n,Ud}var Hd,Vx;function vO(){if(Vx)return Hd;Vx=1;var e=Xl();function n(i){return e(this,i).has(i)}return Hd=n,Hd}var Vd,Wx;function yO(){if(Wx)return Vd;Wx=1;var e=Xl();function n(i,s){var o=e(this,i),l=o.size;return o.set(i,s),this.size+=o.size==l?0:1,this}return Vd=n,Vd}var Wd,Gx;function mv(){if(Gx)return Wd;Gx=1;var e=hO(),n=mO(),i=gO(),s=vO(),o=yO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,Wd=l,Wd}var Gd,Yx;function wO(){if(Yx)return Gd;Yx=1;var e=Yl(),n=pv(),i=mv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var f=c.__data__;if(!n||f.length<s-1)return f.push([l,u]),this.size=++c.size,this;c=this.__data__=new i(f)}return c.set(l,u),this.size=c.size,this}return Gd=o,Gd}var Yd,Kx;function Ql(){if(Kx)return Yd;Kx=1;var e=Yl(),n=Q3(),i=Z3(),s=J3(),o=eO(),l=wO();function u(c){var f=this.__data__=new e(c);this.size=f.size}return u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,Yd=u,Yd}var Kd,Xx;function gv(){if(Xx)return Kd;Xx=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o&&i(n[s],s,n)!==!1;);return n}return Kd=e,Kd}var Xd,Qx;function yN(){if(Qx)return Xd;Qx=1;var e=Yi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Xd=n,Xd}var Qd,Zx;function Zl(){if(Zx)return Qd;Zx=1;var e=yN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Qd=n,Qd}var Zd,Jx;function Jl(){if(Jx)return Zd;Jx=1;var e=Zl(),n=Vs(),i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c){var f=l[u];(!(s.call(l,u)&&n(f,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Zd=o,Zd}var Jd,e_;function ia(){if(e_)return Jd;e_=1;var e=Jl(),n=Zl();function i(s,o,l,u){var c=!l;l||(l={});for(var f=-1,h=o.length;++f<h;){var p=o[f],m=u?u(l[p],s[p],p,l,s):void 0;m===void 0&&(m=s[p]),c?n(l,p,m):e(l,p,m)}return l}return Jd=i,Jd}var ef,t_;function xO(){if(t_)return ef;t_=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return ef=e,ef}var tf,n_;function ur(){if(n_)return tf;n_=1;function e(n){return n!=null&&typeof n=="object"}return tf=e,tf}var nf,r_;function _O(){if(r_)return nf;r_=1;var e=Gi(),n=ur(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return nf=s,nf}var rf,i_;function sa(){if(i_)return rf;i_=1;var e=_O(),n=ur(),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return rf=l,rf}var sf,s_;function Et(){if(s_)return sf;s_=1;var e=Array.isArray;return sf=e,sf}var Do={exports:{}},of,o_;function SO(){if(o_)return of;o_=1;function e(){return!1}return of=e,of}Do.exports;var a_;function Gs(){return a_||(a_=1,(function(e,n){var i=Qn(),s=SO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?i.Buffer:void 0,f=c?c.isBuffer:void 0,h=f||s;e.exports=h})(Do,Do.exports)),Do.exports}var af,l_;function eu(){if(l_)return af;l_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function i(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return af=i,af}var lf,u_;function vv(){if(u_)return lf;u_=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return lf=n,lf}var uf,c_;function bO(){if(c_)return uf;c_=1;var e=Gi(),n=vv(),i=ur(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",h="[object Map]",p="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",j="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",E="[object Float32Array]",N="[object Float64Array]",C="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",P="[object Uint8Array]",z="[object Uint8ClampedArray]",T="[object Uint16Array]",q="[object Uint32Array]",B={};B[E]=B[N]=B[C]=B[I]=B[O]=B[P]=B[z]=B[T]=B[q]=!0,B[s]=B[o]=B[S]=B[l]=B[b]=B[u]=B[c]=B[f]=B[h]=B[p]=B[m]=B[y]=B[w]=B[j]=B[_]=!1;function J(Q){return i(Q)&&n(Q.length)&&!!B[e(Q)]}return uf=J,uf}var cf,d_;function tu(){if(d_)return cf;d_=1;function e(n){return function(i){return n(i)}}return cf=e,cf}var Fo={exports:{}};Fo.exports;var f_;function yv(){return f_||(f_=1,(function(e,n){var i=gN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&i.process,c=(function(){try{var f=o&&o.require&&o.require("util").types;return f||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(Fo,Fo.exports)),Fo.exports}var df,h_;function oa(){if(h_)return df;h_=1;var e=bO(),n=tu(),i=yv(),s=i&&i.isTypedArray,o=s?n(s):e;return df=o,df}var ff,p_;function wN(){if(p_)return ff;p_=1;var e=xO(),n=sa(),i=Et(),s=Gs(),o=eu(),l=oa(),u=Object.prototype,c=u.hasOwnProperty;function f(h,p){var m=i(h),y=!m&&n(h),w=!m&&!y&&s(h),j=!m&&!y&&!w&&l(h),_=m||y||w||j,S=_?e(h.length,String):[],b=S.length;for(var E in h)(p||c.call(h,E))&&!(_&&(E=="length"||w&&(E=="offset"||E=="parent")||j&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||o(E,b)))&&S.push(E);return S}return ff=f,ff}var hf,m_;function nu(){if(m_)return hf;m_=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return hf=n,hf}var pf,g_;function xN(){if(g_)return pf;g_=1;function e(n,i){return function(s){return n(i(s))}}return pf=e,pf}var mf,v_;function kO(){if(v_)return mf;v_=1;var e=xN(),n=e(Object.keys,Object);return mf=n,mf}var gf,y_;function wv(){if(y_)return gf;y_=1;var e=nu(),n=kO(),i=Object.prototype,s=i.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return gf=o,gf}var vf,w_;function Ar(){if(w_)return vf;w_=1;var e=ra(),n=vv();function i(s){return s!=null&&n(s.length)&&!e(s)}return vf=i,vf}var yf,x_;function ai(){if(x_)return yf;x_=1;var e=wN(),n=wv(),i=Ar();function s(o){return i(o)?e(o):n(o)}return yf=s,yf}var wf,__;function EO(){if(__)return wf;__=1;var e=ia(),n=ai();function i(s,o){return s&&e(o,n(o),s)}return wf=i,wf}var xf,S_;function NO(){if(S_)return xf;S_=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return xf=e,xf}var _f,b_;function CO(){if(b_)return _f;b_=1;var e=Pn(),n=nu(),i=NO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return i(u);var c=n(u),f=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||f.push(h);return f}return _f=l,_f}var Sf,k_;function Ki(){if(k_)return Sf;k_=1;var e=wN(),n=CO(),i=Ar();function s(o){return i(o)?e(o,!0):n(o)}return Sf=s,Sf}var bf,E_;function jO(){if(E_)return bf;E_=1;var e=ia(),n=Ki();function i(s,o){return s&&e(o,n(o),s)}return bf=i,bf}var zo={exports:{}};zo.exports;var N_;function _N(){return N_||(N_=1,(function(e,n){var i=Qn(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?i.Buffer:void 0,c=u?u.allocUnsafe:void 0;function f(h,p){if(p)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=f})(zo,zo.exports)),zo.exports}var kf,C_;function SN(){if(C_)return kf;C_=1;function e(n,i){var s=-1,o=n.length;for(i||(i=Array(o));++s<o;)i[s]=n[s];return i}return kf=e,kf}var Ef,j_;function bN(){if(j_)return Ef;j_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];i(c,s,n)&&(u[l++]=c)}return u}return Ef=e,Ef}var Nf,R_;function kN(){if(R_)return Nf;R_=1;function e(){return[]}return Nf=e,Nf}var Cf,T_;function xv(){if(T_)return Cf;T_=1;var e=bN(),n=kN(),i=Object.prototype,s=i.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Cf=l,Cf}var jf,A_;function RO(){if(A_)return jf;A_=1;var e=ia(),n=xv();function i(s,o){return e(s,n(s),o)}return jf=i,jf}var Rf,I_;function _v(){if(I_)return Rf;I_=1;function e(n,i){for(var s=-1,o=i.length,l=n.length;++s<o;)n[l+s]=i[s];return n}return Rf=e,Rf}var Tf,M_;function ru(){if(M_)return Tf;M_=1;var e=xN(),n=e(Object.getPrototypeOf,Object);return Tf=n,Tf}var Af,P_;function EN(){if(P_)return Af;P_=1;var e=_v(),n=ru(),i=xv(),s=kN(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,i(u)),u=n(u);return c}:s;return Af=l,Af}var If,O_;function TO(){if(O_)return If;O_=1;var e=ia(),n=EN();function i(s,o){return e(s,n(s),o)}return If=i,If}var Mf,q_;function NN(){if(q_)return Mf;q_=1;var e=_v(),n=Et();function i(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return Mf=i,Mf}var Pf,L_;function CN(){if(L_)return Pf;L_=1;var e=NN(),n=xv(),i=ai();function s(o){return e(o,i,n)}return Pf=s,Pf}var Of,$_;function AO(){if($_)return Of;$_=1;var e=NN(),n=EN(),i=Ki();function s(o){return e(o,i,n)}return Of=s,Of}var qf,D_;function IO(){if(D_)return qf;D_=1;var e=Yi(),n=Qn(),i=e(n,"DataView");return qf=i,qf}var Lf,F_;function MO(){if(F_)return Lf;F_=1;var e=Yi(),n=Qn(),i=e(n,"Promise");return Lf=i,Lf}var $f,z_;function jN(){if(z_)return $f;z_=1;var e=Yi(),n=Qn(),i=e(n,"Set");return $f=i,$f}var Df,B_;function PO(){if(B_)return Df;B_=1;var e=Yi(),n=Qn(),i=e(n,"WeakMap");return Df=i,Df}var Ff,U_;function Ys(){if(U_)return Ff;U_=1;var e=IO(),n=pv(),i=MO(),s=jN(),o=PO(),l=Gi(),u=vN(),c="[object Map]",f="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",w=u(e),j=u(n),_=u(i),S=u(s),b=u(o),E=l;return(e&&E(new e(new ArrayBuffer(1)))!=y||n&&E(new n)!=c||i&&E(i.resolve())!=h||s&&E(new s)!=p||o&&E(new o)!=m)&&(E=function(N){var C=l(N),I=C==f?N.constructor:void 0,O=I?u(I):"";if(O)switch(O){case w:return y;case j:return c;case _:return h;case S:return p;case b:return m}return C}),Ff=E,Ff}var zf,H_;function OO(){if(H_)return zf;H_=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return zf=i,zf}var Bf,V_;function RN(){if(V_)return Bf;V_=1;var e=Qn(),n=e.Uint8Array;return Bf=n,Bf}var Uf,W_;function Sv(){if(W_)return Uf;W_=1;var e=RN();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return Uf=n,Uf}var Hf,G_;function qO(){if(G_)return Hf;G_=1;var e=Sv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Hf=n,Hf}var Vf,Y_;function LO(){if(Y_)return Vf;Y_=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return Vf=n,Vf}var Wf,K_;function $O(){if(K_)return Wf;K_=1;var e=Ws(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Wf=s,Wf}var Gf,X_;function TN(){if(X_)return Gf;X_=1;var e=Sv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Gf=n,Gf}var Yf,Q_;function DO(){if(Q_)return Yf;Q_=1;var e=Sv(),n=qO(),i=LO(),s=$O(),o=TN(),l="[object Boolean]",u="[object Date]",c="[object Map]",f="[object Number]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",j="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",C="[object Uint8Array]",I="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]";function z(T,q,B){var J=T.constructor;switch(q){case w:return e(T);case l:case u:return new J(+T);case j:return n(T,B);case _:case S:case b:case E:case N:case C:case I:case O:case P:return o(T,B);case c:return new J;case f:case m:return new J(T);case h:return i(T);case p:return new J;case y:return s(T)}}return Yf=z,Yf}var Kf,Z_;function AN(){if(Z_)return Kf;Z_=1;var e=Pn(),n=Object.create,i=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return Kf=i,Kf}var Xf,J_;function IN(){if(J_)return Xf;J_=1;var e=AN(),n=ru(),i=nu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Xf=s,Xf}var Qf,e1;function FO(){if(e1)return Qf;e1=1;var e=Ys(),n=ur(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Qf=s,Qf}var Zf,t1;function zO(){if(t1)return Zf;t1=1;var e=FO(),n=tu(),i=yv(),s=i&&i.isMap,o=s?n(s):e;return Zf=o,Zf}var Jf,n1;function BO(){if(n1)return Jf;n1=1;var e=Ys(),n=ur(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Jf=s,Jf}var eh,r1;function UO(){if(r1)return eh;r1=1;var e=BO(),n=tu(),i=yv(),s=i&&i.isSet,o=s?n(s):e;return eh=o,eh}var th,i1;function MN(){if(i1)return th;i1=1;var e=Ql(),n=gv(),i=Jl(),s=EO(),o=jO(),l=_N(),u=SN(),c=RO(),f=TO(),h=CN(),p=AO(),m=Ys(),y=OO(),w=DO(),j=IN(),_=Et(),S=Gs(),b=zO(),E=Pn(),N=UO(),C=ai(),I=Ki(),O=1,P=2,z=4,T="[object Arguments]",q="[object Array]",B="[object Boolean]",J="[object Date]",Q="[object Error]",A="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",Y="[object Object]",L="[object RegExp]",G="[object Set]",k="[object String]",$="[object Symbol]",oe="[object WeakMap]",D="[object ArrayBuffer]",X="[object DataView]",ee="[object Float32Array]",se="[object Float64Array]",ae="[object Int8Array]",pe="[object Int16Array]",ge="[object Int32Array]",Ae="[object Uint8Array]",Pe="[object Uint8ClampedArray]",Ie="[object Uint16Array]",Me="[object Uint32Array]",ke={};ke[T]=ke[q]=ke[D]=ke[X]=ke[B]=ke[J]=ke[ee]=ke[se]=ke[ae]=ke[pe]=ke[ge]=ke[U]=ke[ne]=ke[Y]=ke[L]=ke[G]=ke[k]=ke[$]=ke[Ae]=ke[Pe]=ke[Ie]=ke[Me]=!0,ke[Q]=ke[A]=ke[oe]=!1;function He(ve,ye,Ve,mt,Je,We){var $e,Qe=ye&O,xt=ye&P,et=ye&z;if(Ve&&($e=Je?Ve(ve,mt,Je,We):Ve(ve)),$e!==void 0)return $e;if(!E(ve))return ve;var Ge=_(ve);if(Ge){if($e=y(ve),!Qe)return u(ve,$e)}else{var _t=m(ve),It=_t==A||_t==H;if(S(ve))return l(ve,Qe);if(_t==Y||_t==T||It&&!Je){if($e=xt||It?{}:j(ve),!Qe)return xt?f(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[_t])return Je?ve:{};$e=w(ve,_t,Qe)}}We||(We=new e);var Bt=We.get(ve);if(Bt)return Bt;We.set(ve,$e),N(ve)?ve.forEach(function(ut){$e.add(He(ut,ye,Ve,ut,ve,We))}):b(ve)&&ve.forEach(function(ut,St){$e.set(St,He(ut,ye,Ve,St,ve,We))});var tt=et?xt?p:h:xt?I:C,gt=Ge?void 0:tt(ve);return n(gt||ve,function(ut,St){gt&&(St=ut,ut=ve[St]),i($e,St,He(ut,ye,Ve,St,ve,We))}),$e}return th=He,th}var nh,s1;function HO(){if(s1)return nh;s1=1;var e=MN(),n=4;function i(s){return e(s,n)}return nh=i,nh}var rh,o1;function bv(){if(o1)return rh;o1=1;function e(n){return function(){return n}}return rh=e,rh}var ih,a1;function VO(){if(a1)return ih;a1=1;function e(n){return function(i,s,o){for(var l=-1,u=Object(i),c=o(i),f=c.length;f--;){var h=c[n?f:++l];if(s(u[h],h,u)===!1)break}return i}}return ih=e,ih}var sh,l1;function kv(){if(l1)return sh;l1=1;var e=VO(),n=e();return sh=n,sh}var oh,u1;function Ev(){if(u1)return oh;u1=1;var e=kv(),n=ai();function i(s,o){return s&&e(s,o,n)}return oh=i,oh}var ah,c1;function WO(){if(c1)return ah;c1=1;var e=Ar();function n(i,s){return function(o,l){if(o==null)return o;if(!e(o))return i(o,l);for(var u=o.length,c=s?u:-1,f=Object(o);(s?c--:++c<u)&&l(f[c],c,f)!==!1;);return o}}return ah=n,ah}var lh,d1;function iu(){if(d1)return lh;d1=1;var e=Ev(),n=WO(),i=n(e);return lh=i,lh}var uh,f1;function Xi(){if(f1)return uh;f1=1;function e(n){return n}return uh=e,uh}var ch,h1;function PN(){if(h1)return ch;h1=1;var e=Xi();function n(i){return typeof i=="function"?i:e}return ch=n,ch}var dh,p1;function ON(){if(p1)return dh;p1=1;var e=gv(),n=iu(),i=PN(),s=Et();function o(l,u){var c=s(l)?e:n;return c(l,i(u))}return dh=o,dh}var fh,m1;function qN(){return m1||(m1=1,fh=ON()),fh}var hh,g1;function GO(){if(g1)return hh;g1=1;var e=iu();function n(i,s){var o=[];return e(i,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return hh=n,hh}var ph,v1;function YO(){if(v1)return ph;v1=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return ph=n,ph}var mh,y1;function KO(){if(y1)return mh;y1=1;function e(n){return this.__data__.has(n)}return mh=e,mh}var gh,w1;function LN(){if(w1)return gh;w1=1;var e=mv(),n=YO(),i=KO();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=i,gh=s,gh}var vh,x1;function XO(){if(x1)return vh;x1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o;)if(i(n[s],s,n))return!0;return!1}return vh=e,vh}var yh,_1;function $N(){if(_1)return yh;_1=1;function e(n,i){return n.has(i)}return yh=e,yh}var wh,S1;function DN(){if(S1)return wh;S1=1;var e=LN(),n=XO(),i=$N(),s=1,o=2;function l(u,c,f,h,p,m){var y=f&s,w=u.length,j=c.length;if(w!=j&&!(y&&j>w))return!1;var _=m.get(u),S=m.get(c);if(_&&S)return _==c&&S==u;var b=-1,E=!0,N=f&o?new e:void 0;for(m.set(u,c),m.set(c,u);++b<w;){var C=u[b],I=c[b];if(h)var O=y?h(I,C,b,c,u,m):h(C,I,b,u,c,m);if(O!==void 0){if(O)continue;E=!1;break}if(N){if(!n(c,function(P,z){if(!i(N,z)&&(C===P||p(C,P,f,h,m)))return N.push(z)})){E=!1;break}}else if(!(C===I||p(C,I,f,h,m))){E=!1;break}}return m.delete(u),m.delete(c),E}return wh=l,wh}var xh,b1;function QO(){if(b1)return xh;b1=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,l){s[++i]=[l,o]}),s}return xh=e,xh}var _h,k1;function Nv(){if(k1)return _h;k1=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return _h=e,_h}var Sh,E1;function ZO(){if(E1)return Sh;E1=1;var e=Ws(),n=RN(),i=Vs(),s=DN(),o=QO(),l=Nv(),u=1,c=2,f="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",j="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",N=e?e.prototype:void 0,C=N?N.valueOf:void 0;function I(O,P,z,T,q,B,J){switch(z){case E:if(O.byteLength!=P.byteLength||O.byteOffset!=P.byteOffset)return!1;O=O.buffer,P=P.buffer;case b:return!(O.byteLength!=P.byteLength||!B(new n(O),new n(P)));case f:case h:case y:return i(+O,+P);case p:return O.name==P.name&&O.message==P.message;case w:case _:return O==P+"";case m:var Q=o;case j:var A=T&u;if(Q||(Q=l),O.size!=P.size&&!A)return!1;var H=J.get(O);if(H)return H==P;T|=c,J.set(O,P);var U=s(Q(O),Q(P),T,q,B,J);return J.delete(O),U;case S:if(C)return C.call(O)==C.call(P)}return!1}return Sh=I,Sh}var bh,N1;function JO(){if(N1)return bh;N1=1;var e=CN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c,f,h,p){var m=c&n,y=e(l),w=y.length,j=e(u),_=j.length;if(w!=_&&!m)return!1;for(var S=w;S--;){var b=y[S];if(!(m?b in u:s.call(u,b)))return!1}var E=p.get(l),N=p.get(u);if(E&&N)return E==u&&N==l;var C=!0;p.set(l,u),p.set(u,l);for(var I=m;++S<w;){b=y[S];var O=l[b],P=u[b];if(f)var z=m?f(P,O,b,u,l,p):f(O,P,b,l,u,p);if(!(z===void 0?O===P||h(O,P,c,f,p):z)){C=!1;break}I||(I=b=="constructor")}if(C&&!I){var T=l.constructor,q=u.constructor;T!=q&&"constructor"in l&&"constructor"in u&&!(typeof T=="function"&&T instanceof T&&typeof q=="function"&&q instanceof q)&&(C=!1)}return p.delete(l),p.delete(u),C}return bh=o,bh}var kh,C1;function eq(){if(C1)return kh;C1=1;var e=Ql(),n=DN(),i=ZO(),s=JO(),o=Ys(),l=Et(),u=Gs(),c=oa(),f=1,h="[object Arguments]",p="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function j(_,S,b,E,N,C){var I=l(_),O=l(S),P=I?p:o(_),z=O?p:o(S);P=P==h?m:P,z=z==h?m:z;var T=P==m,q=z==m,B=P==z;if(B&&u(_)){if(!u(S))return!1;I=!0,T=!1}if(B&&!T)return C||(C=new e),I||c(_)?n(_,S,b,E,N,C):i(_,S,P,b,E,N,C);if(!(b&f)){var J=T&&w.call(_,"__wrapped__"),Q=q&&w.call(S,"__wrapped__");if(J||Q){var A=J?_.value():_,H=Q?S.value():S;return C||(C=new e),N(A,H,b,E,C)}}return B?(C||(C=new e),s(_,S,b,E,N,C)):!1}return kh=j,kh}var Eh,j1;function FN(){if(j1)return Eh;j1=1;var e=eq(),n=ur();function i(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,i,c)}return Eh=i,Eh}var Nh,R1;function tq(){if(R1)return Nh;R1=1;var e=Ql(),n=FN(),i=1,s=2;function o(l,u,c,f){var h=c.length,p=h,m=!f;if(l==null)return!p;for(l=Object(l);h--;){var y=c[h];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++h<p;){y=c[h];var w=y[0],j=l[w],_=y[1];if(m&&y[2]){if(j===void 0&&!(w in l))return!1}else{var S=new e;if(f)var b=f(j,_,w,l,u,S);if(!(b===void 0?n(_,j,i|s,f,S):b))return!1}}return!0}return Nh=o,Nh}var Ch,T1;function zN(){if(T1)return Ch;T1=1;var e=Pn();function n(i){return i===i&&!e(i)}return Ch=n,Ch}var jh,A1;function nq(){if(A1)return jh;A1=1;var e=zN(),n=ai();function i(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return jh=i,jh}var Rh,I1;function BN(){if(I1)return Rh;I1=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return Rh=e,Rh}var Th,M1;function rq(){if(M1)return Th;M1=1;var e=tq(),n=nq(),i=BN();function s(o){var l=n(o);return l.length==1&&l[0][2]?i(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Th=s,Th}var Ah,P1;function Ks(){if(P1)return Ah;P1=1;var e=Gi(),n=ur(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return Ah=s,Ah}var Ih,O1;function Cv(){if(O1)return Ih;O1=1;var e=Et(),n=Ks(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:s.test(l)||!i.test(l)||u!=null&&l in Object(u)}return Ih=o,Ih}var Mh,q1;function iq(){if(q1)return Mh;q1=1;var e=mv(),n="Expected a function";function i(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],f=l.cache;if(f.has(c))return f.get(c);var h=s.apply(this,u);return l.cache=f.set(c,h)||f,h};return l.cache=new(i.Cache||e),l}return i.Cache=e,Mh=i,Mh}var Ph,L1;function sq(){if(L1)return Ph;L1=1;var e=iq(),n=500;function i(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Ph=i,Ph}var Oh,$1;function oq(){if($1)return Oh;$1=1;var e=sq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,f,h){l.push(f?h.replace(i,"$1"):c||u)}),l});return Oh=s,Oh}var qh,D1;function su(){if(D1)return qh;D1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=i(n[s],s,n);return l}return qh=e,qh}var Lh,F1;function aq(){if(F1)return Lh;F1=1;var e=Ws(),n=su(),i=Et(),s=Ks(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(i(c))return n(c,u)+"";if(s(c))return l?l.call(c):"";var f=c+"";return f=="0"&&1/c==-1/0?"-0":f}return Lh=u,Lh}var $h,z1;function UN(){if(z1)return $h;z1=1;var e=aq();function n(i){return i==null?"":e(i)}return $h=n,$h}var Dh,B1;function ou(){if(B1)return Dh;B1=1;var e=Et(),n=Cv(),i=oq(),s=UN();function o(l,u){return e(l)?l:n(l,u)?[l]:i(s(l))}return Dh=o,Dh}var Fh,U1;function aa(){if(U1)return Fh;U1=1;var e=Ks();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Fh=n,Fh}var zh,H1;function au(){if(H1)return zh;H1=1;var e=ou(),n=aa();function i(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return zh=i,zh}var Bh,V1;function lq(){if(V1)return Bh;V1=1;var e=au();function n(i,s,o){var l=i==null?void 0:e(i,s);return l===void 0?o:l}return Bh=n,Bh}var Uh,W1;function uq(){if(W1)return Uh;W1=1;function e(n,i){return n!=null&&i in Object(n)}return Uh=e,Uh}var Hh,G1;function HN(){if(G1)return Hh;G1=1;var e=ou(),n=sa(),i=Et(),s=eu(),o=vv(),l=aa();function u(c,f,h){f=e(f,c);for(var p=-1,m=f.length,y=!1;++p<m;){var w=l(f[p]);if(!(y=c!=null&&h(c,w)))break;c=c[w]}return y||++p!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(w,m)&&(i(c)||n(c)))}return Hh=u,Hh}var Vh,Y1;function VN(){if(Y1)return Vh;Y1=1;var e=uq(),n=HN();function i(s,o){return s!=null&&n(s,o,e)}return Vh=i,Vh}var Wh,K1;function cq(){if(K1)return Wh;K1=1;var e=FN(),n=lq(),i=VN(),s=Cv(),o=zN(),l=BN(),u=aa(),c=1,f=2;function h(p,m){return s(p)&&o(m)?l(u(p),m):function(y){var w=n(y,p);return w===void 0&&w===m?i(y,p):e(m,w,c|f)}}return Wh=h,Wh}var Gh,X1;function WN(){if(X1)return Gh;X1=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Gh=e,Gh}var Yh,Q1;function dq(){if(Q1)return Yh;Q1=1;var e=au();function n(i){return function(s){return e(s,i)}}return Yh=n,Yh}var Kh,Z1;function fq(){if(Z1)return Kh;Z1=1;var e=WN(),n=dq(),i=Cv(),s=aa();function o(l){return i(l)?e(s(l)):n(l)}return Kh=o,Kh}var Xh,J1;function Ir(){if(J1)return Xh;J1=1;var e=rq(),n=cq(),i=Xi(),s=Et(),o=fq();function l(u){return typeof u=="function"?u:u==null?i:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return Xh=l,Xh}var Qh,eS;function GN(){if(eS)return Qh;eS=1;var e=bN(),n=GO(),i=Ir(),s=Et();function o(l,u){var c=s(l)?e:n;return c(l,i(u,3))}return Qh=o,Qh}var Zh,tS;function hq(){if(tS)return Zh;tS=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return Zh=i,Zh}var Jh,nS;function YN(){if(nS)return Jh;nS=1;var e=hq(),n=HN();function i(s,o){return s!=null&&n(s,o,e)}return Jh=i,Jh}var ep,rS;function pq(){if(rS)return ep;rS=1;var e=wv(),n=Ys(),i=sa(),s=Et(),o=Ar(),l=Gs(),u=nu(),c=oa(),f="[object Map]",h="[object Set]",p=Object.prototype,m=p.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||i(w)))return!w.length;var j=n(w);if(j==f||j==h)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(m.call(w,_))return!1;return!0}return ep=y,ep}var tp,iS;function KN(){if(iS)return tp;iS=1;function e(n){return n===void 0}return tp=e,tp}var np,sS;function XN(){if(sS)return np;sS=1;var e=iu(),n=Ar();function i(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,f,h){u[++l]=o(c,f,h)}),u}return np=i,np}var rp,oS;function QN(){if(oS)return rp;oS=1;var e=su(),n=Ir(),i=XN(),s=Et();function o(l,u){var c=s(l)?e:i;return c(l,n(u,3))}return rp=o,rp}var ip,aS;function mq(){if(aS)return ip;aS=1;function e(n,i,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=i(s,n[l],l,n);return s}return ip=e,ip}var sp,lS;function gq(){if(lS)return sp;lS=1;function e(n,i,s,o,l){return l(n,function(u,c,f){s=o?(o=!1,u):i(s,u,c,f)}),s}return sp=e,sp}var op,uS;function ZN(){if(uS)return op;uS=1;var e=mq(),n=iu(),i=Ir(),s=gq(),o=Et();function l(u,c,f){var h=o(u)?e:s,p=arguments.length<3;return h(u,i(c,4),f,p,n)}return op=l,op}var ap,cS;function vq(){if(cS)return ap;cS=1;var e=Gi(),n=Et(),i=ur(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&i(l)&&e(l)==s}return ap=o,ap}var lp,dS;function yq(){if(dS)return lp;dS=1;var e=WN(),n=e("length");return lp=n,lp}var up,fS;function wq(){if(fS)return up;fS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function f(h){return c.test(h)}return up=f,up}var cp,hS;function xq(){if(hS)return cp;hS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",f="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+f+")",p="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",j=h+"?",_="["+l+"]?",S="(?:"+w+"(?:"+[p,m,y].join("|")+")"+_+j+")*",b=_+j+S,E="(?:"+[p+c+"?",c,m,y,u].join("|")+")",N=RegExp(f+"(?="+f+")|"+E+b,"g");function C(I){for(var O=N.lastIndex=0;N.test(I);)++O;return O}return cp=C,cp}var dp,pS;function _q(){if(pS)return dp;pS=1;var e=yq(),n=wq(),i=xq();function s(o){return n(o)?i(o):e(o)}return dp=s,dp}var fp,mS;function Sq(){if(mS)return fp;mS=1;var e=wv(),n=Ys(),i=Ar(),s=vq(),o=_q(),l="[object Map]",u="[object Set]";function c(f){if(f==null)return 0;if(i(f))return s(f)?o(f):f.length;var h=n(f);return h==l||h==u?f.size:e(f).length}return fp=c,fp}var hp,gS;function bq(){if(gS)return hp;gS=1;var e=gv(),n=AN(),i=Ev(),s=Ir(),o=ru(),l=Et(),u=Gs(),c=ra(),f=Pn(),h=oa();function p(m,y,w){var j=l(m),_=j||u(m)||h(m);if(y=s(y,4),w==null){var S=m&&m.constructor;_?w=j?new S:[]:f(m)?w=c(S)?n(o(m)):{}:w={}}return(_?e:i)(m,function(b,E,N){return y(w,b,E,N)}),w}return hp=p,hp}var pp,vS;function kq(){if(vS)return pp;vS=1;var e=Ws(),n=sa(),i=Et(),s=e?e.isConcatSpreadable:void 0;function o(l){return i(l)||n(l)||!!(s&&l&&l[s])}return pp=o,pp}var mp,yS;function jv(){if(yS)return mp;yS=1;var e=_v(),n=kq();function i(s,o,l,u,c){var f=-1,h=s.length;for(l||(l=n),c||(c=[]);++f<h;){var p=s[f];o>0&&l(p)?o>1?i(p,o-1,l,u,c):e(c,p):u||(c[c.length]=p)}return c}return mp=i,mp}var gp,wS;function Eq(){if(wS)return gp;wS=1;function e(n,i,s){switch(s.length){case 0:return n.call(i);case 1:return n.call(i,s[0]);case 2:return n.call(i,s[0],s[1]);case 3:return n.call(i,s[0],s[1],s[2])}return n.apply(i,s)}return gp=e,gp}var vp,xS;function JN(){if(xS)return vp;xS=1;var e=Eq(),n=Math.max;function i(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,f=n(u.length-o,0),h=Array(f);++c<f;)h[c]=u[o+c];c=-1;for(var p=Array(o+1);++c<o;)p[c]=u[c];return p[o]=l(h),e(s,this,p)}}return vp=i,vp}var yp,_S;function Nq(){if(_S)return yp;_S=1;var e=bv(),n=yN(),i=Xi(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:i;return yp=s,yp}var wp,SS;function Cq(){if(SS)return wp;SS=1;var e=800,n=16,i=Date.now;function s(o){var l=0,u=0;return function(){var c=i(),f=n-(c-u);if(u=c,f>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return wp=s,wp}var xp,bS;function eC(){if(bS)return xp;bS=1;var e=Nq(),n=Cq(),i=n(e);return xp=i,xp}var _p,kS;function lu(){if(kS)return _p;kS=1;var e=Xi(),n=JN(),i=eC();function s(o,l){return i(n(o,l,e),o+"")}return _p=s,_p}var Sp,ES;function tC(){if(ES)return Sp;ES=1;function e(n,i,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(i(n[u],u,n))return u;return-1}return Sp=e,Sp}var bp,NS;function jq(){if(NS)return bp;NS=1;function e(n){return n!==n}return bp=e,bp}var kp,CS;function Rq(){if(CS)return kp;CS=1;function e(n,i,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===i)return o;return-1}return kp=e,kp}var Ep,jS;function Tq(){if(jS)return Ep;jS=1;var e=tC(),n=jq(),i=Rq();function s(o,l,u){return l===l?i(o,l,u):e(o,n,u)}return Ep=s,Ep}var Np,RS;function Aq(){if(RS)return Np;RS=1;var e=Tq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return Np=n,Np}var Cp,TS;function Iq(){if(TS)return Cp;TS=1;function e(n,i,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(i,n[o]))return!0;return!1}return Cp=e,Cp}var jp,AS;function Mq(){if(AS)return jp;AS=1;function e(){}return jp=e,jp}var Rp,IS;function Pq(){if(IS)return Rp;IS=1;var e=jN(),n=Mq(),i=Nv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Rp=o,Rp}var Tp,MS;function Oq(){if(MS)return Tp;MS=1;var e=LN(),n=Aq(),i=Iq(),s=$N(),o=Pq(),l=Nv(),u=200;function c(f,h,p){var m=-1,y=n,w=f.length,j=!0,_=[],S=_;if(p)j=!1,y=i;else if(w>=u){var b=h?null:o(f);if(b)return l(b);j=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<w;){var E=f[m],N=h?h(E):E;if(E=p||E!==0?E:0,j&&N===N){for(var C=S.length;C--;)if(S[C]===N)continue e;h&&S.push(N),_.push(E)}else y(S,N,p)||(S!==_&&S.push(N),_.push(E))}return _}return Tp=c,Tp}var Ap,PS;function nC(){if(PS)return Ap;PS=1;var e=Ar(),n=ur();function i(s){return n(s)&&e(s)}return Ap=i,Ap}var Ip,OS;function qq(){if(OS)return Ip;OS=1;var e=jv(),n=lu(),i=Oq(),s=nC(),o=n(function(l){return i(e(l,1,s,!0))});return Ip=o,Ip}var Mp,qS;function Lq(){if(qS)return Mp;qS=1;var e=su();function n(i,s){return e(s,function(o){return i[o]})}return Mp=n,Mp}var Pp,LS;function rC(){if(LS)return Pp;LS=1;var e=Lq(),n=ai();function i(s){return s==null?[]:e(s,n(s))}return Pp=i,Pp}var Op,$S;function On(){if($S)return Op;$S=1;var e;if(typeof hv=="function")try{e={clone:HO(),constant:bv(),each:qN(),filter:GN(),has:YN(),isArray:Et(),isEmpty:pq(),isFunction:ra(),isUndefined:KN(),keys:ai(),map:QN(),reduce:ZN(),size:Sq(),transform:bq(),union:qq(),values:rC()}}catch{}return e||(e=window._),Op=e,Op}var qp,DS;function Rv(){if(DS)return qp;DS=1;var e=On();qp=o;var n="\0",i="\0",s="";function o(p){this._isDirected=e.has(p,"directed")?p.directed:!0,this._isMultigraph=e.has(p,"multigraph")?p.multigraph:!1,this._isCompound=e.has(p,"compound")?p.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(p){return this._label=p,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultNodeLabelFn=p,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._in[m])})},o.prototype.sinks=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._out[m])})},o.prototype.setNodes=function(p,m){var y=arguments,w=this;return e.each(p,function(j){y.length>1?w.setNode(j,m):w.setNode(j)}),this},o.prototype.setNode=function(p,m){return e.has(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=m),this):(this._nodes[p]=arguments.length>1?m:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=i,this._children[p]={},this._children[i][p]=!0),this._in[p]={},this._preds[p]={},this._out[p]={},this._sucs[p]={},++this._nodeCount,this)},o.prototype.node=function(p){return this._nodes[p]},o.prototype.hasNode=function(p){return e.has(this._nodes,p)},o.prototype.removeNode=function(p){var m=this;if(e.has(this._nodes,p)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[p],this._isCompound&&(this._removeFromParentsChildList(p),delete this._parent[p],e.each(this.children(p),function(w){m.setParent(w)}),delete this._children[p]),e.each(e.keys(this._in[p]),y),delete this._in[p],delete this._preds[p],e.each(e.keys(this._out[p]),y),delete this._out[p],delete this._sucs[p],--this._nodeCount}return this},o.prototype.setParent=function(p,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=i;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===p)throw new Error("Setting "+m+" as parent of "+p+" would create a cycle");this.setNode(m)}return this.setNode(p),this._removeFromParentsChildList(p),this._parent[p]=m,this._children[m][p]=!0,this},o.prototype._removeFromParentsChildList=function(p){delete this._children[this._parent[p]][p]},o.prototype.parent=function(p){if(this._isCompound){var m=this._parent[p];if(m!==i)return m}},o.prototype.children=function(p){if(e.isUndefined(p)&&(p=i),this._isCompound){var m=this._children[p];if(m)return e.keys(m)}else{if(p===i)return this.nodes();if(this.hasNode(p))return[]}},o.prototype.predecessors=function(p){var m=this._preds[p];if(m)return e.keys(m)},o.prototype.successors=function(p){var m=this._sucs[p];if(m)return e.keys(m)},o.prototype.neighbors=function(p){var m=this.predecessors(p);if(m)return e.union(m,this.successors(p))},o.prototype.isLeaf=function(p){var m;return this.isDirected()?m=this.successors(p):m=this.neighbors(p),m.length===0},o.prototype.filterNodes=function(p){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){p(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var w={};function j(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(w[_]=S,S):S in w?w[S]:j(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,j(_))}),m},o.prototype.setDefaultEdgeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultEdgeLabelFn=p,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(p,m){var y=this,w=arguments;return e.reduce(p,function(j,_){return w.length>1?y.setEdge(j,_,m):y.setEdge(j,_),_}),this},o.prototype.setEdge=function(){var p,m,y,w,j=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(w=arguments[1],j=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],j=!0)),p=""+p,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,p,m,y);if(e.has(this._edgeLabels,S))return j&&(this._edgeLabels[S]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(p),this.setNode(m),this._edgeLabels[S]=j?w:this._defaultEdgeLabelFn(p,m,y);var b=f(this._isDirected,p,m,y);return p=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],p),l(this._sucs[p],m),this._in[m][S]=b,this._out[p][S]=b,this._edgeCount++,this},o.prototype.edge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y),j=this._edgeObjs[w];return j&&(p=j.v,m=j.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[m],p),u(this._sucs[p],m),delete this._in[m][w],delete this._out[p][w],this._edgeCount--),this},o.prototype.inEdges=function(p,m){var y=this._in[p];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.v===m}):w}},o.prototype.outEdges=function(p,m){var y=this._out[p];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.w===m}):w}},o.prototype.nodeEdges=function(p,m){var y=this.inEdges(p,m);if(y)return y.concat(this.outEdges(p,m))};function l(p,m){p[m]?p[m]++:p[m]=1}function u(p,m){--p[m]||delete p[m]}function c(p,m,y,w){var j=""+m,_=""+y;if(!p&&j>_){var S=j;j=_,_=S}return j+s+_+s+(e.isUndefined(w)?n:w)}function f(p,m,y,w){var j=""+m,_=""+y;if(!p&&j>_){var S=j;j=_,_=S}var b={v:j,w:_};return w&&(b.name=w),b}function h(p,m){return c(p,m.v,m.w,m.name)}return qp}var Lp,FS;function $q(){return FS||(FS=1,Lp="2.1.8"),Lp}var $p,zS;function Dq(){return zS||(zS=1,$p={Graph:Rv(),version:$q()}),$p}var Dp,BS;function Fq(){if(BS)return Dp;BS=1;var e=On(),n=Rv();Dp={write:i,read:l};function i(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var f=u.node(c),h=u.parent(c),p={v:c};return e.isUndefined(f)||(p.value=f),e.isUndefined(h)||(p.parent=h),p})}function o(u){return e.map(u.edges(),function(c){var f=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(f)||(h.value=f),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(f){c.setNode(f.v,f.value),f.parent&&c.setParent(f.v,f.parent)}),e.each(u.edges,function(f){c.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),c}return Dp}var Fp,US;function zq(){if(US)return Fp;US=1;var e=On();Fp=n;function n(i){var s={},o=[],l;function u(c){e.has(s,c)||(s[c]=!0,l.push(c),e.each(i.successors(c),u),e.each(i.predecessors(c),u))}return e.each(i.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Fp}var zp,HS;function iC(){if(HS)return zp;HS=1;var e=On();zp=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(i){return i.key})},n.prototype.has=function(i){return e.has(this._keyIndices,i)},n.prototype.priority=function(i){var s=this._keyIndices[i];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(i,s){var o=this._keyIndices;if(i=String(i),!e.has(o,i)){var l=this._arr,u=l.length;return o[i]=u,l.push({key:i,priority:s}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var i=this._arr.pop();return delete this._keyIndices[i.key],this._heapify(0),i.key},n.prototype.decrease=function(i,s){var o=this._keyIndices[i];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+i+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(i){var s=this._arr,o=2*i,l=o+1,u=i;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==i&&(this._swap(i,u),this._heapify(u)))},n.prototype._decrease=function(i){for(var s=this._arr,o=s[i].priority,l;i!==0&&(l=i>>1,!(s[l].priority<o));)this._swap(i,l),i=l},n.prototype._swap=function(i,s){var o=this._arr,l=this._keyIndices,u=o[i],c=o[s];o[i]=c,o[s]=u,l[c.key]=i,l[u.key]=s},zp}var Bp,VS;function sC(){if(VS)return Bp;VS=1;var e=On(),n=iC();Bp=s;var i=e.constant(1);function s(l,u,c,f){return o(l,String(u),c||i,f||function(h){return l.outEdges(h)})}function o(l,u,c,f){var h={},p=new n,m,y,w=function(j){var _=j.v!==m?j.v:j.w,S=h[_],b=c(j),E=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+b);E<S.distance&&(S.distance=E,S.predecessor=m,p.decrease(_,E))};for(l.nodes().forEach(function(j){var _=j===u?0:Number.POSITIVE_INFINITY;h[j]={distance:_},p.add(j,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)f(m).forEach(w);return h}return Bp}var Up,WS;function Bq(){if(WS)return Up;WS=1;var e=sC(),n=On();Up=i;function i(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return Up}var Hp,GS;function oC(){if(GS)return Hp;GS=1;var e=On();Hp=n;function n(i){var s=0,o=[],l={},u=[];function c(f){var h=l[f]={onStack:!0,lowlink:s,index:s++};if(o.push(f),i.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(h.lowlink=Math.min(h.lowlink,l[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,l[y].lowlink))}),h.lowlink===h.index){var p=[],m;do m=o.pop(),l[m].onStack=!1,p.push(m);while(f!==m);u.push(p)}}return i.nodes().forEach(function(f){e.has(l,f)||c(f)}),u}return Hp}var Vp,YS;function Uq(){if(YS)return Vp;YS=1;var e=On(),n=oC();Vp=i;function i(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Vp}var Wp,KS;function Hq(){if(KS)return Wp;KS=1;var e=On();Wp=i;var n=e.constant(1);function i(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},f=o.nodes();return f.forEach(function(h){c[h]={},c[h][h]={distance:0},f.forEach(function(p){h!==p&&(c[h][p]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(p){var m=p.v===h?p.w:p.v,y=l(p);c[h][m]={distance:y,predecessor:h}})}),f.forEach(function(h){var p=c[h];f.forEach(function(m){var y=c[m];f.forEach(function(w){var j=y[h],_=p[w],S=y[w],b=j.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Wp}var Gp,XS;function aC(){if(XS)return Gp;XS=1;var e=On();Gp=n,n.CycleException=i;function n(s){var o={},l={},u=[];function c(f){if(e.has(l,f))throw new i;e.has(o,f)||(l[f]=!0,o[f]=!0,e.each(s.predecessors(f),c),delete l[f],u.push(f))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new i;return u}function i(){}return i.prototype=new Error,Gp}var Yp,QS;function Vq(){if(QS)return Yp;QS=1;var e=aC();Yp=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Yp}var Kp,ZS;function lC(){if(ZS)return Kp;ZS=1;var e=On();Kp=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],f={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);i(s,h,l==="post",f,u,c)}),c}function i(s,o,l,u,c,f){e.has(u,o)||(u[o]=!0,l||f.push(o),e.each(c(o),function(h){i(s,h,l,u,c,f)}),l&&f.push(o))}return Kp}var Xp,JS;function Wq(){if(JS)return Xp;JS=1;var e=lC();Xp=n;function n(i,s){return e(i,s,"post")}return Xp}var Qp,eb;function Gq(){if(eb)return Qp;eb=1;var e=lC();Qp=n;function n(i,s){return e(i,s,"pre")}return Qp}var Zp,tb;function Yq(){if(tb)return Zp;tb=1;var e=On(),n=Rv(),i=iC();Zp=s;function s(o,l){var u=new n,c={},f=new i,h;function p(y){var w=y.v===h?y.w:y.v,j=f.priority(w);if(j!==void 0){var _=l(y);_<j&&(c[w]=h,f.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),f.decrease(o.nodes()[0],0);for(var m=!1;f.size()>0;){if(h=f.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(p)}return u}return Zp}var Jp,nb;function Kq(){return nb||(nb=1,Jp={components:zq(),dijkstra:sC(),dijkstraAll:Bq(),findCycles:Uq(),floydWarshall:Hq(),isAcyclic:Vq(),postorder:Wq(),preorder:Gq(),prim:Yq(),tarjan:oC(),topsort:aC()}),Jp}var em,rb;function Xq(){if(rb)return em;rb=1;var e=Dq();return em={Graph:e.Graph,json:Fq(),alg:Kq(),version:e.version},em}var tm,ib;function Kn(){if(ib)return tm;ib=1;var e;if(typeof hv=="function")try{e=Xq()}catch{}return e||(e=window.graphlib),tm=e,tm}var nm,sb;function Qq(){if(sb)return nm;sb=1;var e=MN(),n=1,i=4;function s(o){return e(o,n|i)}return nm=s,nm}var rm,ob;function uu(){if(ob)return rm;ob=1;var e=Vs(),n=Ar(),i=eu(),s=Pn();function o(l,u,c){if(!s(c))return!1;var f=typeof u;return(f=="number"?n(c)&&i(u,c.length):f=="string"&&u in c)?e(c[u],l):!1}return rm=o,rm}var im,ab;function Zq(){if(ab)return im;ab=1;var e=lu(),n=Vs(),i=uu(),s=Ki(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,f){c=Object(c);var h=-1,p=f.length,m=p>2?f[2]:void 0;for(m&&i(f[0],f[1],m)&&(p=1);++h<p;)for(var y=f[h],w=s(y),j=-1,_=w.length;++j<_;){var S=w[j],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return im=u,im}var sm,lb;function Jq(){if(lb)return sm;lb=1;var e=Ir(),n=Ar(),i=ai();function s(o){return function(l,u,c){var f=Object(l);if(!n(l)){var h=e(u,3);l=i(l),u=function(m){return h(f[m],m,f)}}var p=o(l,u,c);return p>-1?f[h?l[p]:p]:void 0}}return sm=s,sm}var om,ub;function eL(){if(ub)return om;ub=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return om=n,om}var am,cb;function tL(){if(cb)return am;cb=1;var e=eL(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return am=i,am}var lm,db;function nL(){if(db)return lm;db=1;var e=tL(),n=Pn(),i=Ks(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function f(h){if(typeof h=="number")return h;if(i(h))return s;if(n(h)){var p=typeof h.valueOf=="function"?h.valueOf():h;h=n(p)?p+"":p}if(typeof h!="string")return h===0?h:+h;h=e(h);var m=l.test(h);return m||u.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return lm=f,lm}var um,fb;function uC(){if(fb)return um;fb=1;var e=nL(),n=1/0,i=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*i}return o===o?o:0}return um=s,um}var cm,hb;function rL(){if(hb)return cm;hb=1;var e=uC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return cm=n,cm}var dm,pb;function iL(){if(pb)return dm;pb=1;var e=tC(),n=Ir(),i=rL(),s=Math.max;function o(l,u,c){var f=l==null?0:l.length;if(!f)return-1;var h=c==null?0:i(c);return h<0&&(h=s(f+h,0)),e(l,n(u,3),h)}return dm=o,dm}var fm,mb;function sL(){if(mb)return fm;mb=1;var e=Jq(),n=iL(),i=e(n);return fm=i,fm}var hm,gb;function cC(){if(gb)return hm;gb=1;var e=jv();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return hm=n,hm}var pm,vb;function oL(){if(vb)return pm;vb=1;var e=kv(),n=PN(),i=Ki();function s(o,l){return o==null?o:e(o,n(l),i)}return pm=s,pm}var mm,yb;function aL(){if(yb)return mm;yb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return mm=e,mm}var gm,wb;function lL(){if(wb)return gm;wb=1;var e=Zl(),n=Ev(),i=Ir();function s(o,l){var u={};return l=i(l,3),n(o,function(c,f,h){e(u,f,l(c,f,h))}),u}return gm=s,gm}var vm,xb;function Tv(){if(xb)return vm;xb=1;var e=Ks();function n(i,s,o){for(var l=-1,u=i.length;++l<u;){var c=i[l],f=s(c);if(f!=null&&(h===void 0?f===f&&!e(f):o(f,h)))var h=f,p=c}return p}return vm=n,vm}var ym,_b;function uL(){if(_b)return ym;_b=1;function e(n,i){return n>i}return ym=e,ym}var wm,Sb;function cL(){if(Sb)return wm;Sb=1;var e=Tv(),n=uL(),i=Xi();function s(o){return o&&o.length?e(o,i,n):void 0}return wm=s,wm}var xm,bb;function dC(){if(bb)return xm;bb=1;var e=Zl(),n=Vs();function i(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return xm=i,xm}var _m,kb;function dL(){if(kb)return _m;kb=1;var e=Gi(),n=ru(),i=ur(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,f=u.call(Object);function h(p){if(!i(p)||e(p)!=s)return!1;var m=n(p);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==f}return _m=h,_m}var Sm,Eb;function fC(){if(Eb)return Sm;Eb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return Sm=e,Sm}var bm,Nb;function fL(){if(Nb)return bm;Nb=1;var e=ia(),n=Ki();function i(s){return e(s,n(s))}return bm=i,bm}var km,Cb;function hL(){if(Cb)return km;Cb=1;var e=dC(),n=_N(),i=TN(),s=SN(),o=IN(),l=sa(),u=Et(),c=nC(),f=Gs(),h=ra(),p=Pn(),m=dL(),y=oa(),w=fC(),j=fL();function _(S,b,E,N,C,I,O){var P=w(S,E),z=w(b,E),T=O.get(z);if(T){e(S,E,T);return}var q=I?I(P,z,E+"",S,b,O):void 0,B=q===void 0;if(B){var J=u(z),Q=!J&&f(z),A=!J&&!Q&&y(z);q=z,J||Q||A?u(P)?q=P:c(P)?q=s(P):Q?(B=!1,q=n(z,!0)):A?(B=!1,q=i(z,!0)):q=[]:m(z)||l(z)?(q=P,l(P)?q=j(P):(!p(P)||h(P))&&(q=o(z))):B=!1}B&&(O.set(z,q),C(q,z,N,I,O),O.delete(z)),e(S,E,q)}return km=_,km}var Em,jb;function pL(){if(jb)return Em;jb=1;var e=Ql(),n=dC(),i=kv(),s=hL(),o=Pn(),l=Ki(),u=fC();function c(f,h,p,m,y){f!==h&&i(h,function(w,j){if(y||(y=new e),o(w))s(f,h,j,p,c,m,y);else{var _=m?m(u(f,j),w,j+"",f,h,y):void 0;_===void 0&&(_=w),n(f,j,_)}},l)}return Em=c,Em}var Nm,Rb;function mL(){if(Rb)return Nm;Rb=1;var e=lu(),n=uu();function i(s){return e(function(o,l){var u=-1,c=l.length,f=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(f=s.length>3&&typeof f=="function"?(c--,f):void 0,h&&n(l[0],l[1],h)&&(f=c<3?void 0:f,c=1),o=Object(o);++u<c;){var p=l[u];p&&s(o,p,u,f)}return o})}return Nm=i,Nm}var Cm,Tb;function gL(){if(Tb)return Cm;Tb=1;var e=pL(),n=mL(),i=n(function(s,o,l){e(s,o,l)});return Cm=i,Cm}var jm,Ab;function hC(){if(Ab)return jm;Ab=1;function e(n,i){return n<i}return jm=e,jm}var Rm,Ib;function vL(){if(Ib)return Rm;Ib=1;var e=Tv(),n=hC(),i=Xi();function s(o){return o&&o.length?e(o,i,n):void 0}return Rm=s,Rm}var Tm,Mb;function yL(){if(Mb)return Tm;Mb=1;var e=Tv(),n=Ir(),i=hC();function s(o,l){return o&&o.length?e(o,n(l,2),i):void 0}return Tm=s,Tm}var Am,Pb;function wL(){if(Pb)return Am;Pb=1;var e=Qn(),n=function(){return e.Date.now()};return Am=n,Am}var Im,Ob;function xL(){if(Ob)return Im;Ob=1;var e=Jl(),n=ou(),i=eu(),s=Pn(),o=aa();function l(u,c,f,h){if(!s(u))return u;c=n(c,u);for(var p=-1,m=c.length,y=m-1,w=u;w!=null&&++p<m;){var j=o(c[p]),_=f;if(j==="__proto__"||j==="constructor"||j==="prototype")return u;if(p!=y){var S=w[j];_=h?h(S,j,w):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(w,j,_),w=w[j]}return u}return Im=l,Im}var Mm,qb;function _L(){if(qb)return Mm;qb=1;var e=au(),n=xL(),i=ou();function s(o,l,u){for(var c=-1,f=l.length,h={};++c<f;){var p=l[c],m=e(o,p);u(m,p)&&n(h,i(p,o),m)}return h}return Mm=s,Mm}var Pm,Lb;function SL(){if(Lb)return Pm;Lb=1;var e=_L(),n=VN();function i(s,o){return e(s,o,function(l,u){return n(s,u)})}return Pm=i,Pm}var Om,$b;function bL(){if($b)return Om;$b=1;var e=cC(),n=JN(),i=eC();function s(o){return i(n(o,void 0,e),o+"")}return Om=s,Om}var qm,Db;function kL(){if(Db)return qm;Db=1;var e=SL(),n=bL(),i=n(function(s,o){return s==null?{}:e(s,o)});return qm=i,qm}var Lm,Fb;function EL(){if(Fb)return Lm;Fb=1;var e=Math.ceil,n=Math.max;function i(s,o,l,u){for(var c=-1,f=n(e((o-s)/(l||1)),0),h=Array(f);f--;)h[u?f:++c]=s,s+=l;return h}return Lm=i,Lm}var $m,zb;function NL(){if(zb)return $m;zb=1;var e=EL(),n=uu(),i=uC();function s(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=i(l),u===void 0?(u=l,l=0):u=i(u),c=c===void 0?l<u?1:-1:i(c),e(l,u,c,o)}}return $m=s,$m}var Dm,Bb;function CL(){if(Bb)return Dm;Bb=1;var e=NL(),n=e();return Dm=n,Dm}var Fm,Ub;function jL(){if(Ub)return Fm;Ub=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Fm=e,Fm}var zm,Hb;function RL(){if(Hb)return zm;Hb=1;var e=Ks();function n(i,s){if(i!==s){var o=i!==void 0,l=i===null,u=i===i,c=e(i),f=s!==void 0,h=s===null,p=s===s,m=e(s);if(!h&&!m&&!c&&i>s||c&&f&&p&&!h&&!m||l&&f&&p||!o&&p||!u)return 1;if(!l&&!c&&!m&&i<s||m&&o&&u&&!l&&!c||h&&o&&u||!f&&u||!p)return-1}return 0}return zm=n,zm}var Bm,Vb;function TL(){if(Vb)return Bm;Vb=1;var e=RL();function n(i,s,o){for(var l=-1,u=i.criteria,c=s.criteria,f=u.length,h=o.length;++l<f;){var p=e(u[l],c[l]);if(p){if(l>=h)return p;var m=o[l];return p*(m=="desc"?-1:1)}}return i.index-s.index}return Bm=n,Bm}var Um,Wb;function AL(){if(Wb)return Um;Wb=1;var e=su(),n=au(),i=Ir(),s=XN(),o=jL(),l=tu(),u=TL(),c=Xi(),f=Et();function h(p,m,y){m.length?m=e(m,function(_){return f(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var w=-1;m=e(m,l(i));var j=s(p,function(_,S,b){var E=e(m,function(N){return N(_)});return{criteria:E,index:++w,value:_}});return o(j,function(_,S){return u(_,S,y)})}return Um=h,Um}var Hm,Gb;function IL(){if(Gb)return Hm;Gb=1;var e=jv(),n=AL(),i=lu(),s=uu(),o=i(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return Hm=o,Hm}var Vm,Yb;function ML(){if(Yb)return Vm;Yb=1;var e=UN(),n=0;function i(s){var o=++n;return e(s)+o}return Vm=i,Vm}var Wm,Kb;function PL(){if(Kb)return Wm;Kb=1;function e(n,i,s){for(var o=-1,l=n.length,u=i.length,c={};++o<l;){var f=o<u?i[o]:void 0;s(c,n[o],f)}return c}return Wm=e,Wm}var Gm,Xb;function OL(){if(Xb)return Gm;Xb=1;var e=Jl(),n=PL();function i(s,o){return n(s||[],o||[],e)}return Gm=i,Gm}var Ym,Qb;function lt(){if(Qb)return Ym;Qb=1;var e;if(typeof hv=="function")try{e={cloneDeep:Qq(),constant:bv(),defaults:Zq(),each:qN(),filter:GN(),find:sL(),flatten:cC(),forEach:ON(),forIn:oL(),has:YN(),isUndefined:KN(),last:aL(),map:QN(),mapValues:lL(),max:cL(),merge:gL(),min:vL(),minBy:yL(),now:wL(),pick:kL(),range:CL(),reduce:ZN(),sortBy:IL(),uniqueId:ML(),values:rC(),zipObject:OL()}}catch{}return e||(e=window._),Ym=e,Ym}var Km,Zb;function qL(){if(Zb)return Km;Zb=1,Km=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,i)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function i(s,o){if(s!=="_next"&&s!=="_prev")return o}return Km}var Xm,Jb;function LL(){if(Jb)return Xm;Jb=1;var e=lt(),n=Kn().Graph,i=qL();Xm=o;var s=e.constant(1);function o(h,p){if(h.nodeCount()<=1)return[];var m=c(h,p||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return h.outEdges(w.v,w.w)}),!0)}function l(h,p,m){for(var y=[],w=p[p.length-1],j=p[0],_;h.nodeCount();){for(;_=j.dequeue();)u(h,p,m,_);for(;_=w.dequeue();)u(h,p,m,_);if(h.nodeCount()){for(var S=p.length-2;S>0;--S)if(_=p[S].dequeue(),_){y=y.concat(u(h,p,m,_,!0));break}}}return y}function u(h,p,m,y,w){var j=w?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);w&&j.push({v:_.v,w:_.w}),b.out-=S,f(p,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,E=h.node(b);E.in-=S,f(p,m,E)}),h.removeNode(y.v),j}function c(h,p){var m=new n,y=0,w=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,E=p(S),N=b+E;m.setEdge(S.v,S.w,N),w=Math.max(w,m.node(S.v).out+=E),y=Math.max(y,m.node(S.w).in+=E)});var j=e.range(w+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){f(j,_,m.node(S))}),{graph:m,buckets:j,zeroIdx:_}}function f(h,p,m){m.out?m.in?h[m.out-m.in+p].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Xm}var Qm,ek;function $L(){if(ek)return Qm;ek=1;var e=lt(),n=LL();Qm={run:i,undo:o};function i(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(f){var h=l.edge(f);l.removeEdge(f),h.forwardName=f.name,h.reversed=!0,l.setEdge(f.w,f.v,h,e.uniqueId("rev"))});function c(f){return function(h){return f.edge(h).weight}}}function s(l){var u=[],c={},f={};function h(p){e.has(f,p)||(f[p]=!0,c[p]=!0,e.forEach(l.outEdges(p),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[p])}return e.forEach(l.nodes(),h),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var f=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,f)}})}return Qm}var Zm,tk;function cn(){if(tk)return Zm;tk=1;var e=lt(),n=Kn().Graph;Zm={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:f,normalizeRanks:h,removeEmptyRanks:p,addBorderNode:m,maxRank:y,partition:w,time:j,notime:_};function i(S,b,E,N){var C;do C=e.uniqueId(N);while(S.hasNode(C));return E.dummy=b,S.setNode(C,E),C}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(E){b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){var N=b.edge(E.v,E.w)||{weight:0,minlen:1},C=S.edge(E);b.setEdge(E.v,E.w,{weight:N.weight+C.weight,minlen:Math.max(N.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(E){S.children(E).length||b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){b.setEdge(E,S.edge(E))}),b}function l(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.outEdges(E),function(C){N[C.w]=(N[C.w]||0)+S.edge(C).weight}),N});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.inEdges(E),function(C){N[C.v]=(N[C.v]||0)+S.edge(C).weight}),N});return e.zipObject(S.nodes(),b)}function c(S,b){var E=S.x,N=S.y,C=b.x-E,I=b.y-N,O=S.width/2,P=S.height/2;if(!C&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var z,T;return Math.abs(I)*O>Math.abs(C)*P?(I<0&&(P=-P),z=P*C/I,T=P):(C<0&&(O=-O),z=O,T=O*I/C),{x:E+z,y:N+T}}function f(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(E){var N=S.node(E),C=N.rank;e.isUndefined(C)||(b[C][N.order]=E)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(E){return S.node(E).rank}));e.forEach(S.nodes(),function(E){var N=S.node(E);e.has(N,"rank")&&(N.rank-=b)})}function p(S){var b=e.min(e.map(S.nodes(),function(I){return S.node(I).rank})),E=[];e.forEach(S.nodes(),function(I){var O=S.node(I).rank-b;E[O]||(E[O]=[]),E[O].push(I)});var N=0,C=S.graph().nodeRankFactor;e.forEach(E,function(I,O){e.isUndefined(I)&&O%C!==0?--N:N&&e.forEach(I,function(P){S.node(P).rank+=N})})}function m(S,b,E,N){var C={width:0,height:0};return arguments.length>=4&&(C.rank=E,C.order=N),i(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var E=S.node(b).rank;if(!e.isUndefined(E))return E}))}function w(S,b){var E={lhs:[],rhs:[]};return e.forEach(S,function(N){b(N)?E.lhs.push(N):E.rhs.push(N)}),E}function j(S,b){var E=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-E)+"ms")}}function _(S,b){return b()}return Zm}var Jm,nk;function DL(){if(nk)return Jm;nk=1;var e=lt(),n=cn();Jm={run:i,undo:o};function i(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,f=l.node(c).rank,h=u.w,p=l.node(h).rank,m=u.name,y=l.edge(u),w=y.labelRank;if(p!==f+1){l.removeEdge(u);var j,_,S;for(S=0,++f;f<p;++S,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:f},j=n.addDummyNode(l,"edge",_,"_d"),f===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,j,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(j),c=j;l.setEdge(c,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),f=c.edgeLabel,h;for(l.setEdge(c.edgeObj,f);c.dummy;)h=l.successors(u)[0],l.removeNode(u),f.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(f.x=c.x,f.y=c.y,f.width=c.width,f.height=c.height),u=h,c=l.node(u)})}return Jm}var eg,rk;function Dl(){if(rk)return eg;rk=1;var e=lt();eg={longestPath:n,slack:i};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var f=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),c.rank=f}e.forEach(s.sources(),l)}function i(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return eg}var tg,ik;function pC(){if(ik)return tg;ik=1;var e=lt(),n=Kn().Graph,i=Dl().slack;tg=s;function s(c){var f=new n({directed:!1}),h=c.nodes()[0],p=c.nodeCount();f.setNode(h,{});for(var m,y;o(f,c)<p;)m=l(f,c),y=f.hasNode(m.v)?i(c,m):-i(c,m),u(f,c,y);return f}function o(c,f){function h(p){e.forEach(f.nodeEdges(p),function(m){var y=m.v,w=p===y?m.w:y;!c.hasNode(w)&&!i(f,m)&&(c.setNode(w,{}),c.setEdge(p,w,{}),h(w))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,f){return e.minBy(f.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return i(f,h)})}function u(c,f,h){e.forEach(c.nodes(),function(p){f.node(p).rank+=h})}return tg}var ng,sk;function FL(){if(sk)return ng;sk=1;var e=lt(),n=pC(),i=Dl().slack,s=Dl().longestPath,o=Kn().alg.preorder,l=Kn().alg.postorder,u=cn().simplify;ng=c,c.initLowLimValues=m,c.initCutValues=f,c.calcCutValue=p,c.leaveEdge=w,c.enterEdge=j,c.exchangeEdges=_;function c(N){N=u(N),s(N);var C=n(N);m(C),f(C,N);for(var I,O;I=w(C);)O=j(C,N,I),_(C,N,I,O)}function f(N,C){var I=l(N,N.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(O){h(N,C,O)})}function h(N,C,I){var O=N.node(I),P=O.parent;N.edge(I,P).cutvalue=p(N,C,I)}function p(N,C,I){var O=N.node(I),P=O.parent,z=!0,T=C.edge(I,P),q=0;return T||(z=!1,T=C.edge(P,I)),q=T.weight,e.forEach(C.nodeEdges(I),function(B){var J=B.v===I,Q=J?B.w:B.v;if(Q!==P){var A=J===z,H=C.edge(B).weight;if(q+=A?H:-H,b(N,I,Q)){var U=N.edge(I,Q).cutvalue;q+=A?-U:U}}}),q}function m(N,C){arguments.length<2&&(C=N.nodes()[0]),y(N,{},1,C)}function y(N,C,I,O,P){var z=I,T=N.node(O);return C[O]=!0,e.forEach(N.neighbors(O),function(q){e.has(C,q)||(I=y(N,C,I,q,O))}),T.low=z,T.lim=I++,P?T.parent=P:delete T.parent,I}function w(N){return e.find(N.edges(),function(C){return N.edge(C).cutvalue<0})}function j(N,C,I){var O=I.v,P=I.w;C.hasEdge(O,P)||(O=I.w,P=I.v);var z=N.node(O),T=N.node(P),q=z,B=!1;z.lim>T.lim&&(q=T,B=!0);var J=e.filter(C.edges(),function(Q){return B===E(N,N.node(Q.v),q)&&B!==E(N,N.node(Q.w),q)});return e.minBy(J,function(Q){return i(C,Q)})}function _(N,C,I,O){var P=I.v,z=I.w;N.removeEdge(P,z),N.setEdge(O.v,O.w,{}),m(N),f(N,C),S(N,C)}function S(N,C){var I=e.find(N.nodes(),function(P){return!C.node(P).parent}),O=o(N,I);O=O.slice(1),e.forEach(O,function(P){var z=N.node(P).parent,T=C.edge(P,z),q=!1;T||(T=C.edge(z,P),q=!0),C.node(P).rank=C.node(z).rank+(q?T.minlen:-T.minlen)})}function b(N,C,I){return N.hasEdge(C,I)}function E(N,C,I){return I.low<=C.lim&&C.lim<=I.lim}return ng}var rg,ok;function zL(){if(ok)return rg;ok=1;var e=Dl(),n=e.longestPath,i=pC(),s=FL();rg=o;function o(f){switch(f.graph().ranker){case"network-simplex":c(f);break;case"tight-tree":u(f);break;case"longest-path":l(f);break;default:c(f)}}var l=n;function u(f){n(f),i(f)}function c(f){s(f)}return rg}var ig,ak;function BL(){if(ak)return ig;ak=1;var e=lt();ig=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),f=c.edgeObj,h=i(o,l,f.v,f.w),p=h.path,m=h.lca,y=0,w=p[y],j=!0;u!==f.w;){if(c=o.node(u),j){for(;(w=p[y])!==m&&o.node(w).maxRank<c.rank;)y++;w===m&&(j=!1)}if(!j){for(;y<p.length-1&&o.node(w=p[y+1]).minRank<=c.rank;)y++;w=p[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function i(o,l,u,c){var f=[],h=[],p=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),f.push(y);while(y&&(l[y].low>p||m>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)h.push(y);return{path:f.concat(h.reverse()),lca:w}}function s(o){var l={},u=0;function c(f){var h=u;e.forEach(o.children(f),c),l[f]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return ig}var sg,lk;function UL(){if(lk)return sg;lk=1;var e=lt(),n=cn();sg={run:i,cleanup:u};function i(c){var f=n.addDummyNode(c,"root",{},"_root"),h=o(c),p=e.max(e.values(h))-1,m=2*p+1;c.graph().nestingRoot=f,e.forEach(c.edges(),function(w){c.edge(w).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(w){s(c,f,m,y,p,h,w)}),c.graph().nodeRankFactor=m}function s(c,f,h,p,m,y,w){var j=c.children(w);if(!j.length){w!==f&&c.setEdge(f,w,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(w);c.setParent(_,w),b.borderTop=_,c.setParent(S,w),b.borderBottom=S,e.forEach(j,function(E){s(c,f,h,p,m,y,E);var N=c.node(E),C=N.borderTop?N.borderTop:E,I=N.borderBottom?N.borderBottom:E,O=N.borderTop?p:2*p,P=C!==I?1:m-y[w]+1;c.setEdge(_,C,{weight:O,minlen:P,nestingEdge:!0}),c.setEdge(I,S,{weight:O,minlen:P,nestingEdge:!0})}),c.parent(w)||c.setEdge(f,_,{weight:0,minlen:m+y[w]})}function o(c){var f={};function h(p,m){var y=c.children(p);y&&y.length&&e.forEach(y,function(w){h(w,m+1)}),f[p]=m}return e.forEach(c.children(),function(p){h(p,1)}),f}function l(c){return e.reduce(c.edges(),function(f,h){return f+c.edge(h).weight},0)}function u(c){var f=c.graph();c.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(c.edges(),function(h){var p=c.edge(h);p.nestingEdge&&c.removeEdge(h)})}return sg}var og,uk;function HL(){if(uk)return og;uk=1;var e=lt(),n=cn();og=i;function i(o){function l(u){var c=o.children(u),f=o.node(u);if(c.length&&e.forEach(c,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var h=f.minRank,p=f.maxRank+1;h<p;++h)s(o,"borderLeft","_bl",u,f,h),s(o,"borderRight","_br",u,f,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,f,h){var p={width:0,height:0,rank:h,borderType:l},m=f[l][h-1],y=n.addDummyNode(o,"border",p,u);f[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return og}var ag,ck;function VL(){if(ck)return ag;ck=1;var e=lt();ag={adjust:n,undo:i};function n(h){var p=h.graph().rankdir.toLowerCase();(p==="lr"||p==="rl")&&s(h)}function i(h){var p=h.graph().rankdir.toLowerCase();(p==="bt"||p==="rl")&&l(h),(p==="lr"||p==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(p){o(h.node(p))}),e.forEach(h.edges(),function(p){o(h.edge(p))})}function o(h){var p=h.width;h.width=h.height,h.height=p}function l(h){e.forEach(h.nodes(),function(p){u(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(p){f(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,f),e.has(m,"x")&&f(m)})}function f(h){var p=h.x;h.x=h.y,h.y=p}return ag}var lg,dk;function WL(){if(dk)return lg;dk=1;var e=lt();lg=n;function n(i){var s={},o=e.filter(i.nodes(),function(h){return!i.children(h).length}),l=e.max(e.map(o,function(h){return i.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var p=i.node(h);u[p.rank].push(h),e.forEach(i.successors(h),c)}}var f=e.sortBy(o,function(h){return i.node(h).rank});return e.forEach(f,c),u}return lg}var ug,fk;function GL(){if(fk)return ug;fk=1;var e=lt();ug=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=i(s,o[u-1],o[u]);return l}function i(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(w){return{pos:u[w.w],weight:s.edge(w).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var h=2*f-1;f-=1;var p=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var w=y.pos+f;p[w]+=y.weight;for(var j=0;w>0;)w%2&&(j+=p[w+1]),w=w-1>>1,p[w]+=y.weight;m+=y.weight*j})),m}return ug}var cg,hk;function YL(){if(hk)return cg;hk=1;var e=lt();cg=n;function n(i,s){return e.map(s,function(o){var l=i.inEdges(o);if(l.length){var u=e.reduce(l,function(c,f){var h=i.edge(f),p=i.node(f.v);return{sum:c.sum+h.weight*p.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return cg}var dg,pk;function KL(){if(pk)return dg;pk=1;var e=lt();dg=n;function n(o,l){var u={};e.forEach(o,function(f,h){var p=u[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:h};e.isUndefined(f.barycenter)||(p.barycenter=f.barycenter,p.weight=f.weight)}),e.forEach(l.edges(),function(f){var h=u[f.v],p=u[f.w];!e.isUndefined(h)&&!e.isUndefined(p)&&(p.indegree++,h.out.push(u[f.w]))});var c=e.filter(u,function(f){return!f.indegree});return i(c)}function i(o){var l=[];function u(h){return function(p){p.merged||(e.isUndefined(p.barycenter)||e.isUndefined(h.barycenter)||p.barycenter>=h.barycenter)&&s(h,p)}}function c(h){return function(p){p.in.push(h),--p.indegree===0&&o.push(p)}}for(;o.length;){var f=o.pop();l.push(f),e.forEach(f.in.reverse(),u(f)),e.forEach(f.out,c(f))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return dg}var fg,mk;function XL(){if(mk)return fg;mk=1;var e=lt(),n=cn();fg=i;function i(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),f=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),p=[],m=0,y=0,w=0;f.sort(o(!!u)),w=s(p,h,w),e.forEach(f,function(_){w+=_.vs.length,p.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,w=s(p,h,w)});var j={vs:e.flatten(p,!0)};return y&&(j.barycenter=m/y,j.weight=y),j}function s(l,u,c){for(var f;u.length&&(f=e.last(u)).i<=c;)u.pop(),l.push(f.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return fg}var hg,gk;function QL(){if(gk)return hg;gk=1;var e=lt(),n=YL(),i=KL(),s=XL();hg=o;function o(c,f,h,p){var m=c.children(f),y=c.node(f),w=y?y.borderLeft:void 0,j=y?y.borderRight:void 0,_={};w&&(m=e.filter(m,function(I){return I!==w&&I!==j}));var S=n(c,m);e.forEach(S,function(I){if(c.children(I.v).length){var O=o(c,I.v,h,p);_[I.v]=O,e.has(O,"barycenter")&&u(I,O)}});var b=i(S,h);l(b,_);var E=s(b,p);if(w&&(E.vs=e.flatten([w,E.vs,j],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),C=c.node(c.predecessors(j)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+N.order+C.order)/(E.weight+2),E.weight+=2}return E}function l(c,f){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(p){return f[p]?f[p].vs:p}),!0)})}function u(c,f){e.isUndefined(c.barycenter)?(c.barycenter=f.barycenter,c.weight=f.weight):(c.barycenter=(c.barycenter*c.weight+f.barycenter*f.weight)/(c.weight+f.weight),c.weight+=f.weight)}return hg}var pg,vk;function ZL(){if(vk)return pg;vk=1;var e=lt(),n=Kn().Graph;pg=i;function i(o,l,u){var c=s(o),f=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var p=o.node(h),m=o.parent(h);(p.rank===l||p.minRank<=l&&l<=p.maxRank)&&(f.setNode(h),f.setParent(h,m||c),e.forEach(o[u](h),function(y){var w=y.v===h?y.w:y.v,j=f.edge(w,h),_=e.isUndefined(j)?0:j.weight;f.setEdge(w,h,{weight:o.edge(y).weight+_})}),e.has(p,"minRank")&&f.setNode(h,{borderLeft:p.borderLeft[l],borderRight:p.borderRight[l]}))}),f}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return pg}var mg,yk;function JL(){if(yk)return mg;yk=1;var e=lt();mg=n;function n(i,s,o){var l={},u;e.forEach(o,function(c){for(var f=i.parent(c),h,p;f;){if(h=i.parent(f),h?(p=l[h],l[h]=f):(p=u,u=f),p&&p!==f){s.setEdge(p,f);return}f=h}})}return mg}var gg,wk;function e$(){if(wk)return gg;wk=1;var e=lt(),n=WL(),i=GL(),s=QL(),o=ZL(),l=JL(),u=Kn().Graph,c=cn();gg=f;function f(y){var w=c.maxRank(y),j=h(y,e.range(1,w+1),"inEdges"),_=h(y,e.range(w-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,E,N=0,C=0;C<4;++N,++C){p(N%2?j:_,N%4>=2),S=c.buildLayerMatrix(y);var I=i(y,S);I<b&&(C=0,E=e.cloneDeep(S),b=I)}m(y,E)}function h(y,w,j){return e.map(w,function(_){return o(y,_,j)})}function p(y,w){var j=new u;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,j,w);e.forEach(b.vs,function(E,N){_.node(E).order=N}),l(_,j,b.vs)})}function m(y,w){e.forEach(w,function(j){e.forEach(j,function(_,S){y.node(_).order=S})})}return gg}var vg,xk;function t$(){if(xk)return vg;xk=1;var e=lt(),n=Kn().Graph,i=cn();vg={positionX:j,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:f,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function s(b,E){var N={};function C(I,O){var P=0,z=0,T=I.length,q=e.last(O);return e.forEach(O,function(B,J){var Q=l(b,B),A=Q?b.node(Q).order:T;(Q||B===q)&&(e.forEach(O.slice(z,J+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),Y=ne.order;(Y<P||A<Y)&&!(ne.dummy&&b.node(H).dummy)&&u(N,U,H)})}),z=J+1,P=A)}),O}return e.reduce(E,C),N}function o(b,E){var N={};function C(O,P,z,T,q){var B;e.forEach(e.range(P,z),function(J){B=O[J],b.node(B).dummy&&e.forEach(b.predecessors(B),function(Q){var A=b.node(Q);A.dummy&&(A.order<T||A.order>q)&&u(N,Q,B)})})}function I(O,P){var z=-1,T,q=0;return e.forEach(P,function(B,J){if(b.node(B).dummy==="border"){var Q=b.predecessors(B);Q.length&&(T=b.node(Q[0]).order,C(P,q,J,z,T),q=J,z=T)}C(P,q,P.length,T,O.length)}),P}return e.reduce(E,I),N}function l(b,E){if(b.node(E).dummy)return e.find(b.predecessors(E),function(N){return b.node(N).dummy})}function u(b,E,N){if(E>N){var C=E;E=N,N=C}var I=b[E];I||(b[E]=I={}),I[N]=!0}function c(b,E,N){if(E>N){var C=E;E=N,N=C}return e.has(b[E],N)}function f(b,E,N,C){var I={},O={},P={};return e.forEach(E,function(z){e.forEach(z,function(T,q){I[T]=T,O[T]=T,P[T]=q})}),e.forEach(E,function(z){var T=-1;e.forEach(z,function(q){var B=C(q);if(B.length){B=e.sortBy(B,function(U){return P[U]});for(var J=(B.length-1)/2,Q=Math.floor(J),A=Math.ceil(J);Q<=A;++Q){var H=B[Q];O[q]===q&&T<P[H]&&!c(N,q,H)&&(O[H]=q,O[q]=I[q]=I[H],T=P[H])}}})}),{root:I,align:O}}function h(b,E,N,C,I){var O={},P=p(b,E,N,I),z=I?"borderLeft":"borderRight";function T(J,Q){for(var A=P.nodes(),H=A.pop(),U={};H;)U[H]?J(H):(U[H]=!0,A.push(H),A=A.concat(Q(H))),H=A.pop()}function q(J){O[J]=P.inEdges(J).reduce(function(Q,A){return Math.max(Q,O[A.v]+P.edge(A))},0)}function B(J){var Q=P.outEdges(J).reduce(function(H,U){return Math.min(H,O[U.w]-P.edge(U))},Number.POSITIVE_INFINITY),A=b.node(J);Q!==Number.POSITIVE_INFINITY&&A.borderType!==z&&(O[J]=Math.max(O[J],Q))}return T(q,P.predecessors.bind(P)),T(B,P.successors.bind(P)),e.forEach(C,function(J){O[J]=O[N[J]]}),O}function p(b,E,N,C){var I=new n,O=b.graph(),P=_(O.nodesep,O.edgesep,C);return e.forEach(E,function(z){var T;e.forEach(z,function(q){var B=N[q];if(I.setNode(B),T){var J=N[T],Q=I.edge(J,B);I.setEdge(J,B,Math.max(P(b,q,T),Q||0))}T=q})}),I}function m(b,E){return e.minBy(e.values(E),function(N){var C=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY;return e.forIn(N,function(O,P){var z=S(b,P)/2;C=Math.max(O+z,C),I=Math.min(O-z,I)}),C-I})}function y(b,E){var N=e.values(E),C=e.min(N),I=e.max(N);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(P){var z=O+P,T=b[z],q;if(T!==E){var B=e.values(T);q=P==="l"?C-e.min(B):I-e.max(B),q&&(b[z]=e.mapValues(T,function(J){return J+q}))}})})}function w(b,E){return e.mapValues(b.ul,function(N,C){if(E)return b[E.toLowerCase()][C];var I=e.sortBy(e.map(b,C));return(I[1]+I[2])/2})}function j(b){var E=i.buildLayerMatrix(b),N=e.merge(s(b,E),o(b,E)),C={},I;e.forEach(["u","d"],function(P){I=P==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(z){z==="r"&&(I=e.map(I,function(J){return e.values(J).reverse()}));var T=(P==="u"?b.predecessors:b.successors).bind(b),q=f(b,I,N,T),B=h(b,I,q.root,q.align,z==="r");z==="r"&&(B=e.mapValues(B,function(J){return-J})),C[P+z]=B})});var O=m(b,C);return y(C,O),w(C,b.graph().align)}function _(b,E,N){return function(C,I,O){var P=C.node(I),z=C.node(O),T=0,q;if(T+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":q=-P.width/2;break;case"r":q=P.width/2;break}if(q&&(T+=N?q:-q),q=0,T+=(P.dummy?E:b)/2,T+=(z.dummy?E:b)/2,T+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":q=z.width/2;break;case"r":q=-z.width/2;break}return q&&(T+=N?q:-q),q=0,T}}function S(b,E){return b.node(E).width}return vg}var yg,_k;function n$(){if(_k)return yg;_k=1;var e=lt(),n=cn(),i=t$().positionX;yg=s;function s(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(i(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,f=0;e.forEach(u,function(h){var p=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=f+p/2}),f+=p+c})}return yg}var wg,Sk;function r$(){if(Sk)return wg;Sk=1;var e=lt(),n=$L(),i=DL(),s=zL(),o=cn().normalizeRanks,l=BL(),u=cn().removeEmptyRanks,c=UL(),f=HL(),h=VL(),p=e$(),m=n$(),y=cn(),w=Kn().Graph;wg=j;function j(D,X){var ee=X&&X.debugTiming?y.time:y.notime;ee("layout",function(){var se=ee(" buildLayoutGraph",function(){return T(D)});ee(" runLayout",function(){_(se,ee)}),ee(" updateInputGraph",function(){S(D,se)})})}function _(D,X){X(" makeSpaceForEdgeLabels",function(){q(D)}),X(" removeSelfEdges",function(){L(D)}),X(" acyclic",function(){n.run(D)}),X(" nestingGraph.run",function(){c.run(D)}),X(" rank",function(){s(y.asNonCompoundGraph(D))}),X(" injectEdgeLabelProxies",function(){B(D)}),X(" removeEmptyRanks",function(){u(D)}),X(" nestingGraph.cleanup",function(){c.cleanup(D)}),X(" normalizeRanks",function(){o(D)}),X(" assignRankMinMax",function(){J(D)}),X(" removeEdgeLabelProxies",function(){Q(D)}),X(" normalize.run",function(){i.run(D)}),X(" parentDummyChains",function(){l(D)}),X(" addBorderSegments",function(){f(D)}),X(" order",function(){p(D)}),X(" insertSelfEdges",function(){G(D)}),X(" adjustCoordinateSystem",function(){h.adjust(D)}),X(" position",function(){m(D)}),X(" positionSelfEdges",function(){k(D)}),X(" removeBorderNodes",function(){Y(D)}),X(" normalize.undo",function(){i.undo(D)}),X(" fixupEdgeLabelCoords",function(){U(D)}),X(" undoCoordinateSystem",function(){h.undo(D)}),X(" translateGraph",function(){A(D)}),X(" assignNodeIntersects",function(){H(D)}),X(" reversePoints",function(){ne(D)}),X(" acyclic.undo",function(){n.undo(D)})}function S(D,X){e.forEach(D.nodes(),function(ee){var se=D.node(ee),ae=X.node(ee);se&&(se.x=ae.x,se.y=ae.y,X.children(ee).length&&(se.width=ae.width,se.height=ae.height))}),e.forEach(D.edges(),function(ee){var se=D.edge(ee),ae=X.edge(ee);se.points=ae.points,e.has(ae,"x")&&(se.x=ae.x,se.y=ae.y)}),D.graph().width=X.graph().width,D.graph().height=X.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],C=["width","height"],I={width:0,height:0},O=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function T(D){var X=new w({multigraph:!0,compound:!0}),ee=oe(D.graph());return X.setGraph(e.merge({},E,$(ee,b),e.pick(ee,N))),e.forEach(D.nodes(),function(se){var ae=oe(D.node(se));X.setNode(se,e.defaults($(ae,C),I)),X.setParent(se,D.parent(se))}),e.forEach(D.edges(),function(se){var ae=oe(D.edge(se));X.setEdge(se,e.merge({},P,$(ae,O),e.pick(ae,z)))}),X}function q(D){var X=D.graph();X.ranksep/=2,e.forEach(D.edges(),function(ee){var se=D.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function B(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);if(ee.width&&ee.height){var se=D.node(X.v),ae=D.node(X.w),pe={rank:(ae.rank-se.rank)/2+se.rank,e:X};y.addDummyNode(D,"edge-proxy",pe,"_ep")}})}function J(D){var X=0;e.forEach(D.nodes(),function(ee){var se=D.node(ee);se.borderTop&&(se.minRank=D.node(se.borderTop).rank,se.maxRank=D.node(se.borderBottom).rank,X=e.max(X,se.maxRank))}),D.graph().maxRank=X}function Q(D){e.forEach(D.nodes(),function(X){var ee=D.node(X);ee.dummy==="edge-proxy"&&(D.edge(ee.e).labelRank=ee.rank,D.removeNode(X))})}function A(D){var X=Number.POSITIVE_INFINITY,ee=0,se=Number.POSITIVE_INFINITY,ae=0,pe=D.graph(),ge=pe.marginx||0,Ae=pe.marginy||0;function Pe(Ie){var Me=Ie.x,ke=Ie.y,He=Ie.width,ve=Ie.height;X=Math.min(X,Me-He/2),ee=Math.max(ee,Me+He/2),se=Math.min(se,ke-ve/2),ae=Math.max(ae,ke+ve/2)}e.forEach(D.nodes(),function(Ie){Pe(D.node(Ie))}),e.forEach(D.edges(),function(Ie){var Me=D.edge(Ie);e.has(Me,"x")&&Pe(Me)}),X-=ge,se-=Ae,e.forEach(D.nodes(),function(Ie){var Me=D.node(Ie);Me.x-=X,Me.y-=se}),e.forEach(D.edges(),function(Ie){var Me=D.edge(Ie);e.forEach(Me.points,function(ke){ke.x-=X,ke.y-=se}),e.has(Me,"x")&&(Me.x-=X),e.has(Me,"y")&&(Me.y-=se)}),pe.width=ee-X+ge,pe.height=ae-se+Ae}function H(D){e.forEach(D.edges(),function(X){var ee=D.edge(X),se=D.node(X.v),ae=D.node(X.w),pe,ge;ee.points?(pe=ee.points[0],ge=ee.points[ee.points.length-1]):(ee.points=[],pe=ae,ge=se),ee.points.unshift(y.intersectRect(se,pe)),ee.points.push(y.intersectRect(ae,ge))})}function U(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);if(e.has(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function ne(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);ee.reversed&&ee.points.reverse()})}function Y(D){e.forEach(D.nodes(),function(X){if(D.children(X).length){var ee=D.node(X),se=D.node(ee.borderTop),ae=D.node(ee.borderBottom),pe=D.node(e.last(ee.borderLeft)),ge=D.node(e.last(ee.borderRight));ee.width=Math.abs(ge.x-pe.x),ee.height=Math.abs(ae.y-se.y),ee.x=pe.x+ee.width/2,ee.y=se.y+ee.height/2}}),e.forEach(D.nodes(),function(X){D.node(X).dummy==="border"&&D.removeNode(X)})}function L(D){e.forEach(D.edges(),function(X){if(X.v===X.w){var ee=D.node(X.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:X,label:D.edge(X)}),D.removeEdge(X)}})}function G(D){var X=y.buildLayerMatrix(D);e.forEach(X,function(ee){var se=0;e.forEach(ee,function(ae,pe){var ge=D.node(ae);ge.order=pe+se,e.forEach(ge.selfEdges,function(Ae){y.addDummyNode(D,"selfedge",{width:Ae.label.width,height:Ae.label.height,rank:ge.rank,order:pe+ ++se,e:Ae.e,label:Ae.label},"_se")}),delete ge.selfEdges})})}function k(D){e.forEach(D.nodes(),function(X){var ee=D.node(X);if(ee.dummy==="selfedge"){var se=D.node(ee.e.v),ae=se.x+se.width/2,pe=se.y,ge=ee.x-ae,Ae=se.height/2;D.setEdge(ee.e,ee.label),D.removeNode(X),ee.label.points=[{x:ae+2*ge/3,y:pe-Ae},{x:ae+5*ge/6,y:pe-Ae},{x:ae+ge,y:pe},{x:ae+5*ge/6,y:pe+Ae},{x:ae+2*ge/3,y:pe+Ae}],ee.label.x=ee.x,ee.label.y=ee.y}})}function $(D,X){return e.mapValues(e.pick(D,X),Number)}function oe(D){var X={};return e.forEach(D,function(ee,se){X[se.toLowerCase()]=ee}),X}return wg}var xg,bk;function i$(){if(bk)return xg;bk=1;var e=lt(),n=cn(),i=Kn().Graph;xg={debugOrdering:s};function s(o){var l=n.buildLayerMatrix(o),u=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,f){var h="layer"+f;u.setNode(h,{rank:"same"}),e.reduce(c,function(p,m){return u.setEdge(p,m,{style:"invis"}),m})}),u}return xg}var _g,kk;function s$(){return kk||(kk=1,_g="0.8.5"),_g}var Sg,Ek;function o$(){return Ek||(Ek=1,Sg={graphlib:Kn(),layout:r$(),debug:i$(),util:{time:cn().time,notime:cn().notime},version:s$()}),Sg}var a$=o$();const Nk=Wg(a$),oi=240,Hi=130,Fs=74,cu=72,Ck=Fs+cu;function l$(e){let n=oi;for(const i of e.values())n=Math.max(n,i.width);return n}const u$=420,c$=2;function du(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function d$(e,n,i,s,o){const l=new Nk.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(_=>!o.has(_)),c=new Set(u);for(const _ of u){const S=s.get(_);l.setNode(_,{width:(S==null?void 0:S.width)??oi,height:(S==null?void 0:S.height)??Hi})}for(const _ of n)c.has(_.source)&&c.has(_.target)&&l.setEdge(_.source,_.target);Nk.layout(l);const f=new Map;let h=1/0,p=1/0,m=-1/0,y=-1/0;for(const _ of u){const S=l.node(_);if(!S)continue;const b=s.get(_),E=(b==null?void 0:b.width)??oi,N=(b==null?void 0:b.height)??Hi,C=S.x-E/2,I=S.y-N/2;f.set(_,{x:C,y:I}),C<h&&(h=C),I<p&&(p=I),C+E>m&&(m=C+E),I+N>y&&(y=I+N)}if(Number.isFinite(h)&&Number.isFinite(p))for(const[_,S]of f)f.set(_,{x:S.x-h,y:S.y-p});let w=Number.isFinite(m)?m-h:0,j=Number.isFinite(y)?y-p:0;for(const _ of e){const S=o.get(_);if(!S)continue;const b=s.get(_);w=Math.max(w,S.x+((b==null?void 0:b.width)??oi)),j=Math.max(j,S.y+((b==null?void 0:b.height)??Hi))}return{positions:f,width:w,height:j}}function f$(e,n,i={}){const s=i.direction??"LR",o=i.pinned??new Map,l=i.measured??new Map,u=new Map;for(const S of e){const b=du(S),E=u.get(b);E?E.push(S.id):u.set(b,[S.id])}const f=Array.from(u.keys()).sort().map(S=>({sid:S,...d$(u.get(S),n,s,l,o)})),h=l$(l),p=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,m=S=>{const b=[[]];let E=0;for(const N of f)b.length<S&&E>0&&E+N.height>p&&(b.push([]),E=0),b[b.length-1].push(N),E+=N.height+Ck;return b},y=S=>S.reduce((b,E)=>Math.max(b,E.width),0)+u$;let w=m(i.availableWidth?c$:1);w.length>1&&w.reduce((b,E)=>b+y(E),0)+h*(w.length-1)>(i.availableWidth??0)&&(w=m(1));const j=new Map;let _=0;for(const S of w){let b=0;for(const{positions:E,height:N}of S){for(const[C,I]of E)j.set(C,{x:I.x+_,y:I.y+b});b+=N+Ck}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const E=j.get(S.id);return E?{...S,position:E}:S})}function h$(e,n,i,s){const l=Fs+cu,u=60,c=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??oi,h:(w==null?void 0:w.height)??Hi}},f=new Map(e.map(y=>[y.id,du(y)])),h=[],p=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,w)=>y.pos.y-w.pos.y||y.pos.x-w.pos.x||y.id.localeCompare(w.id)),m=[];for(const{id:y,pos:w}of p){const{w:j,h:_}=c(y),S=f.get(y)??"_default";if(i.has(y)){h.push({x:w.x,y:w.y,w:j,h:_,sid:S});continue}let b=w.y;for(let E=0;E<h.length+1;E++){const N=h.find(C=>{const I=C.sid===S?24:u,O=C.sid===S?24:l;return w.x<C.x+C.w+I&&C.x<w.x+j+I&&b<C.y+C.h+O&&C.y<b+_+O});if(!N)break;b=N.y+N.h+(N.sid===S?24:l)}b!==w.y&&(n.set(y,{x:w.x,y:b}),m.push(y)),h.push({x:w.x,y:b,w:j,h:_,sid:S})}return m}function p$(e,n,i,s,o){const l=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??oi,h:(w==null?void 0:w.height)??Hi}},u=y=>i.get(y)??n.get(y),c=new Map,f=[];for(const y of e){const w=u(y.id);if(!w)continue;const{w:j,h:_}=l(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=du(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else f.push({x:w.x,y:w.y,w:j,h:_})}if(c.size===0)return[];const h=Fs+cu,p=(y,w,j,_)=>f.some(S=>y<S.x+S.w+Fs&&S.x<y+j+Fs&&w<S.y+S.h+h&&S.y<w+_+h),m=[];for(const y of[...c.keys()].sort()){const w=c.get(y);let j=1/0,_=1/0,S=-1/0,b=-1/0;for(const z of w){const T=u(z.id),{w:q,h:B}=l(z.id);j=Math.min(j,T.x),_=Math.min(_,T.y),S=Math.max(S,T.x+q),b=Math.max(b,T.y+B)}const E=S-j,N=b-_,C=[...new Set(f.map(z=>Math.round(z.x)))].sort((z,T)=>z-T),I=C.length?C:[j],O=[0,...f.map(z=>z.y+z.h+h)].sort((z,T)=>z-T);let P=null;e:for(const z of I)for(const T of O){if(T>=_)break;if(!p(z,T,E,N)){P={x:z,y:T};break e}}if(P){const z=P.x-j,T=P.y-_;for(const q of w){const B=u(q.id);n.set(q.id,{x:B.x+z,y:B.y+T})}m.push(y)}for(const z of w){const T=u(z.id),{w:q,h:B}=l(z.id);f.push({x:T.x,y:T.y,w:q,h:B})}}return m}function m$(e,n,i,s,o,l=!1){const f=Fs+cu+1,h=8,p=1.75,m=200,y=.7,w=.01,j=T=>{const q=s.get(T);return{w:(q==null?void 0:q.width)??oi,h:(q==null?void 0:q.height)??Hi}},_=T=>i.get(T)??n.get(T),S=new Map;for(const T of e){if(!_(T.id))continue;const q=du(T),B=S.get(q);B?B.push(T):S.set(q,[T])}const b=[],E=new Set,N=new Set,C=o.size===0;for(const T of[...S.keys()].sort()){const q=S.get(T);let B=1/0,J=1/0,Q=-1/0,A=-1/0,H=!1;for(const L of q){const G=_(L.id),{w:k,h:$}=j(L.id);B=Math.min(B,G.x),J=Math.min(J,G.y),Q=Math.max(Q,G.x+k),A=Math.max(A,G.y+$),i.has(L.id)&&(H=!0)}const U=Q-B,ne=A-J;N.add(T);const Y=o.get(T);Y&&(U>Y.w+h||ne>Y.h+h)&&E.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:q.map(L=>L.id),x:B,y:J,w:U,h:ne,anchored:H,mass:1})}for(const T of[...o.keys()])N.has(T)||o.delete(T);if(l||C)return[];let I=!1;for(let T=0;T<b.length&&!I;T++)for(let q=T+1;q<b.length;q++){const B=b[T],J=b[q];if(!(B.anchored&&J.anchored)&&Math.abs(B.x+B.w/2-(J.x+J.w/2))<(B.w+J.w)/2+61&&Math.abs(B.y+B.h/2-(J.y+J.h/2))<(B.h+J.h)/2+f){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const T of b)E.has(T.sid)&&(T.mass=8);else for(const T of b)T.mass=Math.max(1,T.w*T.h/(oi*Hi));const O=new Map(b.map(T=>[T.sid,T.x])),P=new Map(b.map(T=>[T.sid,T.y]));for(let T=0;T<m;T++){const q=new Map,B=new Map;let J=0;for(let Q=0;Q<b.length;Q++)for(let A=Q+1;A<b.length;A++){const H=b[Q],U=b[A];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,Y=H.y+H.h/2,L=U.x+U.w/2,G=U.y+U.h/2,k=(H.w+U.w)/2+61-Math.abs(ne-L),$=(H.h+U.h)/2+f-Math.abs(Y-G);if(k<=0||$<=0)continue;const oe=(We,$e)=>!We.anchored&&!($e<0&&We.x<=0),D=(We,$e)=>!We.anchored&&!($e<0&&We.y<=0),X=(We,$e,Qe)=>{const xt=We===$e,et=xt?H.sid<U.sid?-1:1:Math.sign(We-$e);return Qe(H,et)||Qe(U,-et)?et:xt&&(Qe(H,-et)||Qe(U,et))?-et:0},ee=X(ne,L,oe),se=X(Y,G,D),ae=ee!==0,pe=se!==0;if(!ae&&!pe)continue;const ge=ae&&(!pe||k*p<$),[Ae,Pe,Ie,Me]=ge?[ee,k,q,oe]:[se,$,B,D],ke=Me(H,Ae),He=Me(U,-Ae),ve=H.mass,ye=U.mass,Ve=ke?He?ye/(ve+ye):1:0,mt=He?ke?ve/(ve+ye):1:0,Je=Pe*y;Ie.set(H.sid,(Ie.get(H.sid)??0)+Ae*Je*Ve),Ie.set(U.sid,(Ie.get(U.sid)??0)-Ae*Je*mt),J+=Je}for(const Q of b)Q.anchored||(Q.x=Math.max(0,Q.x+(q.get(Q.sid)??0)),Q.y=Math.max(0,Q.y+(B.get(Q.sid)??0)));if(J<w)break}const z=[];for(const T of b){const q=T.x-O.get(T.sid),B=T.y-P.get(T.sid);if(!(Math.abs(q)<1&&Math.abs(B)<1)){for(const J of T.members){if(i.has(J))continue;const Q=n.get(J);Q&&n.set(J,{x:Q.x+q,y:Q.y+B})}z.push(T.sid)}}return z}const g$=600;function Ug(e,n){return!(e.exitAt!=null&&n-e.exitAt>g$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function v$(e,n){const i=new Set;for(const s of e.agents.values())Ug(s,n)&&i.add(s.id);return i}function $i(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function y$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const w$={agent:NP,sessionGroup:LP},x$=420,bl=18,_$=9e4,S$=200,b$=5*6e4,k$=6,E$=2*6e4,Av="agent-dag.layout",Iv="agent-dag.viewport",mC="agent-dag.summariesDismissed",gC="agent-dag.sessionListOpen",vC="agent-dag.detailOpen",yC="agent-dag.usagePanelOpen",jk="agent-dag.accountsPanelOpen",Rk="agent-dag.versionNoticeDismissed",Tk={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},Ak="agent-dag.autoRestart",Ik="agent-dag.bundleReloadedFor";function N$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(gC)==="1"}catch{return!1}}function C$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(gC,e?"1":"0")}catch{}}function j$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(vC)==="1"}catch{return!1}}function R$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(vC,e?"1":"0")}catch{}}function T$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(yC);try{return e===null?!0:e==="1"}catch{return!0}}function A$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(yC,e?"1":"0")}catch{}}function I$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(mC);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(i=>typeof i=="string"):[])}catch{return new Set}}function Mk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(mC,JSON.stringify(i))}catch{}}function M$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Av);if(!n)return e;const i=JSON.parse(n);if(!("v"in i)){const o=Object.entries(i).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(i.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(i.pins)?i.pins:[]}}catch{return e}}function bg(e,n){if(!(typeof window>"u"))try{const i={};for(const[s,o]of e)i[s]=o;for(const[s,o]of n)i[s]=o;window.localStorage.setItem(Av,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function P$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Iv);if(!e)return null;const n=JSON.parse(e);return typeof(n==null?void 0:n.x)!="number"||typeof(n==null?void 0:n.y)!="number"||typeof(n==null?void 0:n.zoom)!="number"?null:n}catch{return null}}function O$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Iv,JSON.stringify(e))}catch{}}function Pk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Av)}catch{}try{window.localStorage.removeItem(Iv)}catch{}}}function q$(e,n){const i=e.agents.get(n);if(!i)return;const s=[];for(const p of e.agents.values())p.sessionId===n&&s.push(p);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:i.label,cwd:i.cwd,startedAt:i.startedAt,endedAt:i.endedAt,model:i.model,agents:s.map(p=>({id:p.id,kind:p.kind,label:p.label,parentId:p.parentId,state:p.state,startedAt:p.startedAt,endedAt:p.endedAt,model:p.model,cwd:p.cwd,usage:p.usage,prompts:p.prompts,tools:p.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),f=document.createElement("a"),h=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=c,f.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Hg={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Vg={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},L$={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"};function wC(e){return e.startsWith("mcp__")?"mcp":L$[e]??"other"}function xC(e,n){var s,o,l;if(!n)return!0;const i=n.toLowerCase();if(e.label.toLowerCase().includes(i)||(s=e.cwd)!=null&&s.toLowerCase().includes(i)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(i)||e.sessionId.toLowerCase().includes(i)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(i))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(i))return!0;return!1}function $$(e,n){if(!n)return null;const i=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||i.has(l.parentId))break;i.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&i.has(l.parentId)&&!i.has(l.id)&&(i.add(l.id),o=!0)}return i}function D$(e,n,i,s,o,l,u,c,f,h,p,m,y,w,j,_,S,b){const E=[],N=[],C=new Set;if(l)for(const T of e.agents.values())xC(T,l)&&C.add(T.id);for(const T of e.agents.values()){if(!S.has(T.id))continue;const q=l?!C.has(T.id):!1,B=T.exitAt!=null,J=_!=null&&!_.has(T.id),Q=[q?"rf-dim":"",B?"rf-exiting":"",J?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,A=u.get(T.id);if(E.push({id:T.id,type:"agent",position:{x:0,y:0},data:{...T,now:n,dim:q,onOpenContext:b},className:Q,...A?{width:A.width,height:A.height}:null}),T.parentId&&S.has(T.parentId)){const H=dv(T.sessionId),U=T.state==="active"?`hsl(${H} 80% 72%)`:`hsl(${H} 50% 55%)`,ne=l&&!C.has(T.id)&&!C.has(T.parentId),Y=B,L=j.size>0&&(j.has(T.id)||j.has(T.parentId)),G=_!=null&&!_.has(T.id)&&!_.has(T.parentId),k=T.state==="active"?2:1.5,$=L?k+1.5:k,oe=ne||Y?.2:G?.12:1,D=[Y?"rf-edge-exiting":"",L?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;N.push({id:`e:${T.parentId}->${T.id}`,source:T.parentId,target:T.id,animated:(T.state==="active"||L)&&!ne&&!Y,type:"smoothstep",style:{stroke:U,strokeWidth:$,opacity:oe,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:D})}}const I=E.filter(T=>!o.has(T.id)&&!m.has(T.id));if(I.length>0||y!==w.current){if(I.length>0){const T=f$(E,N,{direction:"LR",pinned:o,measured:u,availableWidth:i,availableHeight:s});for(const q of T)m.has(q.id)||m.set(q.id,q.position);p$(E,m,o,u,new Set(I.map(q=>q.id)))}h$(E,m,o,u),w.current=y}const O=m$(E,m,o,u,c,!h||p);O.length>0&&f(O);for(const T of Array.from(m.keys()))e.agents.has(T)||m.delete(T);if(e.agents.size>0)for(const T of Array.from(o.keys()))e.agents.has(T)||o.delete(T);const P=[];let z=!1;for(const T of E){let q=o.get(T.id)??m.get(T.id);q||(q={x:0,y:0},m.set(T.id,q),z=!0),P.push({...T,position:q})}return z&&(w.current=""),{nodes:P,edges:N}}function F$(){return g.jsx(uv,{children:g.jsx(z$,{})})}function z$(){var ha,to,_i,no;const e=ta(),n=M.useRef(Fg()),[,i]=M.useState(0),s=M.useCallback(()=>i(W=>W+1),[]),[o,l]=M.useState(()=>new Set),[u,c]=M.useState(null),[f,h]=M.useState(null),p=M.useCallback((W,Z)=>{l(ue=>{if(!Z)return new Set([W]);const fe=new Set(ue);return fe.has(W)?fe.delete(W):fe.add(W),fe}),c(ue=>Z&&ue===W?ue:W)},[]),m=M.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=M.useState(null),[j,_]=M.useState(null),S=M.useCallback(W=>_(W),[]),b=M.useRef(I$()),[E,N]=M.useState(N$);M.useEffect(()=>{C$(E)},[E]);const[C,I]=M.useState(j$);M.useEffect(()=>{R$(C)},[C]);const[O,P]=M.useState(T$);M.useEffect(()=>{A$(O)},[O]);const[z,T]=M.useState(()=>{try{const W=window.localStorage.getItem(jk);return W===null?!0:W==="1"}catch{return!0}});M.useEffect(()=>{try{window.localStorage.setItem(jk,z?"1":"0")}catch{}},[z]);const[q,B]=M.useState(null),[J,Q]=M.useState(!1),[A,H]=M.useState(0),[U,ne]=M.useState(0);M.useEffect(()=>{fetch("/api/sound-hook").then(W=>W.ok?W.json():null).then(W=>{W!=null&&W.ok&&(B(W.enabled===!0),H((W.foreign??[]).filter(Z=>Z.worksHere).length),ne(typeof W.parked=="number"?W.parked:0))}).catch(()=>{})},[]);const Y=M.useCallback(async()=>{Q(!0);try{const Z=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!q})})).json().catch(()=>null);Z!=null&&Z.ok&&B(Z.enabled===!0),fetch("/api/sound-hook").then(ue=>ue.ok?ue.json():null).then(ue=>{ue!=null&&ue.ok&&(H((ue.foreign??[]).filter(fe=>fe.worksHere).length),ne(typeof ue.parked=="number"?ue.parked:0))}).catch(()=>{})}catch{}finally{Q(!1)}},[q]),[L,G]=M.useState(!1),[k,$]=M.useState(null),[oe,D]=M.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Rk)??""}catch{return""}}),[X,ee]=M.useState(!1),se=M.useCallback(()=>{fetch("/api/version").then(W=>W.ok?W.json():null).then(W=>{W&&$(W)}).catch(()=>{})},[]);M.useEffect(()=>{se();const W=window.setInterval(se,5*6e4),Z=()=>{document.visibilityState==="visible"&&se()};return document.addEventListener("visibilitychange",Z),()=>{window.clearInterval(W),document.removeEventListener("visibilitychange",Z)}},[se]),M.useEffect(()=>{L&&se()},[L,se]);const ae=(k==null?void 0:k.notice)??null,pe=ae?`${ae.kind}:${ae.to}`:"",ge=ae!=null&&oe!==pe,Ae=M.useCallback(()=>{if(!ae)return;const W=oe===pe?"":pe;D(W);try{window.localStorage.setItem(Rk,W)}catch{}},[ae,pe,oe]),Pe=((ha=k==null?void 0:k.upgrade)==null?void 0:ha.state)??"idle",Ie=M.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}se()},[se]);M.useEffect(()=>{if(Pe!=="running")return;const W=window.setInterval(se,3e3);return()=>window.clearInterval(W)},[Pe,se]);const Me=M.useCallback(async()=>{var ue;const W=k==null?void 0:k.command;if(!W)return;let Z=!1;try{Z=await Promise.race([((ue=navigator.clipboard)==null?void 0:ue.writeText(W).then(()=>!0))??Promise.resolve(!1),new Promise(fe=>window.setTimeout(()=>fe(!1),500))])}catch{Z=!1}if(!Z)try{const fe=document.createElement("textarea");fe.value=W,fe.setAttribute("readonly",""),fe.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(fe),fe.select(),Z=document.execCommand("copy"),fe.remove()}catch{Z=!1}Z&&(ee(!0),window.setTimeout(()=>ee(!1),1600))},[k==null?void 0:k.command]),ke=M.useCallback(()=>{N(W=>(W||T(!1),!W))},[]),He=M.useCallback(()=>{T(W=>(W||N(!1),!W))},[]),[ve,ye]=M.useState(!1),[Ve,mt]=M.useState(0),Je=M.useRef(null),[We,$e]=M.useState(0),[Qe,xt]=M.useState(!1),et=M.useRef([]),[Ge,_t]=M.useState(Date.now()),[It,Bt]=M.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Ak)!=="0"}catch{return!0}}),tt=M.useCallback(()=>{Bt(W=>{const Z=!W;try{window.localStorage.setItem(Ak,Z?"1":"0")}catch{}return Z})},[]),[gt,ut]=M.useState(!1),[St,qn]=M.useState("restart"),[Ut,Lt]=M.useState(null),Yt=M.useRef(!1),vn=M.useCallback(async W=>{if(Yt.current)return;const Z=(W==null?void 0:W.upgrade)===!0;Yt.current=!0,qn(Z?"npx":"restart"),ut(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ae==null?void 0:ae.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Z})})}catch{}window.setTimeout(()=>{if(Yt.current){Yt.current=!1,ut(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Z?18e4:3e4)},[ae==null?void 0:ae.to]),yn=M.useRef(null);M.useEffect(()=>{let W=!1;for(const ue of n.current.agents.values())if(ue.state==="active"){W=!0;break}const Z=z3({enabled:It,kind:ae==null?void 0:ae.kind,canRestart:(k==null?void 0:k.canRestart)===!0,busy:W,idleSince:yn.current,now:Ge});yn.current=Z.idleSince,Z.restart&&vn()},[It,ae==null?void 0:ae.kind,k==null?void 0:k.canRestart,Ge,vn]),M.useEffect(()=>{let W=null;try{W=window.sessionStorage.getItem(Ik)}catch{return}if(F3({bundle:"1.33.2",running:k==null?void 0:k.running,lastTried:W})){try{window.sessionStorage.setItem(Ik,(k==null?void 0:k.running)??"")}catch{return}window.location.reload()}},[k==null?void 0:k.running]),M.useEffect(()=>{const W=k==null?void 0:k.running;if(!W)return;let Z=null;try{Z=window.sessionStorage.getItem("agent-dag.restartPending")}catch{return}if(Z==null||Z&&Z!==W)return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Yt.current=!1,ut(!1),Lt(W);const ue=window.setTimeout(()=>Lt(null),6e3);return()=>window.clearTimeout(ue)},[k==null?void 0:k.running]);const Jt=M.useRef(M$()).current;M.useRef(!1);const ct=M.useRef(new Map(Jt.positions.filter(([W])=>Jt.pins.includes(W)))),Kt=M.useRef(null),cr=M.useState(()=>P$())[0],[wn,li]=M.useState(""),[ui,ci]=M.useState(()=>new Set),[Zn,Jn]=M.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[Mr,dr]=M.useState(!1),Qi=M.useRef(null);M.useEffect(()=>{document.documentElement.dataset.theme=Zn;try{window.localStorage.setItem("agent-dag.theme",Zn)}catch{}},[Zn]),M.useEffect(()=>{if(!cr)return;const W=window.setTimeout(()=>{try{e.setViewport(cr,{duration:0})}catch{}},60);return()=>window.clearTimeout(W)},[e,cr]);const er=M.useRef(!0),bt=M.useRef(null);M.useEffect(()=>{const W=new EventSource("/events");return W.addEventListener("open",()=>{G(!0),dr(!0)}),W.addEventListener("error",()=>G(!1)),W.addEventListener("replay-end",()=>{er.current=!1,bt.current!=null&&(window.clearTimeout(bt.current),bt.current=null),s()}),W.addEventListener("hook",Z=>{try{const ue=JSON.parse(Z.data);if(Qe){et.current.push(ue);return}n.current=Gw(n.current,ue),ue.replay===!0||er.current||Date.now()-ue.receivedAt>3e4?(bt.current!=null&&window.clearTimeout(bt.current),bt.current=window.setTimeout(()=>{bt.current=null,s()},120)):(bt.current!=null&&(window.clearTimeout(bt.current),bt.current=null),s())}catch{}}),()=>{W.close(),bt.current!=null&&(window.clearTimeout(bt.current),bt.current=null)}},[Qe,s]),M.useEffect(()=>{if(!Qe&&et.current.length!==0){for(const W of et.current)n.current=Gw(n.current,W);et.current.length=0,s()}},[Qe,s]),M.useEffect(()=>{const W=setInterval(()=>{const Z=Date.now();_t(Z);let ue=cP(n.current,Z,_$);lP(n.current,Z,S$,b$)&&(ue=!0),uP(n.current,Z,k$,E$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(W)},[s]);const tr=M.useRef(null),xn=M.useRef(0),Xs=420,en=M.useCallback((W=500)=>{try{const _e=document.querySelector(".canvas-wrap"),Oe=Array.from(document.querySelectorAll(".react-flow__node")).filter(it=>it.offsetWidth>0);if(!_e||Oe.length===0)return;const De=_e.getBoundingClientRect(),Ke=e.getViewport();if(!Number.isFinite(Ke.zoom)||Ke.zoom<=0)return;const Xe=it=>(it-De.left-Ke.x)/Ke.zoom,rt=it=>(it-De.top-Ke.y)/Ke.zoom,Ct=Oe.map(it=>it.getBoundingClientRect()),gr=Math.min(...Ct.map(it=>Xe(it.left))),Lr=Math.max(...Ct.map(it=>Xe(it.right))),$r=Math.min(...Ct.map(it=>rt(it.top))),Dr=Math.max(...Ct.map(it=>rt(it.bottom))),Si=Lr-gr,bi=Dr-$r;if(!(Si>0&&bi>0))return;const ft=Math.max(.2,Math.min(1,(De.width-160)/(Si+Xs)*.86,(De.height-160)/bi*.86));e.setViewport({x:80-gr*ft,y:Math.max(80,(De.height-bi*ft)/2)-$r*ft,zoom:ft},{duration:W}),xn.current=Date.now(),window.setTimeout(()=>{try{const it={x:80-gr*ft,y:Math.max(80,(De.height-bi*ft)/2)-$r*ft,zoom:ft},us=e.getViewport();(Math.abs(us.zoom-ft)>.01||Math.abs(us.x-it.x)>2)&&e.setViewport(it,{duration:0})}catch{}},W+60)}catch{}},[e]),Pr=M.useRef(""),dn=M.useRef(null),di=M.useRef(0),fr=M.useCallback(()=>{di.current=Date.now()},[]),fi="agent-dag.autoFitDisabled",_n=M.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(fi)==="1"}catch{return!1}})()),[hi,pi]=M.useState(_n.current),mi=M.useCallback(()=>{if(!_n.current){_n.current=!0,pi(!0);try{window.localStorage.setItem(fi,"1")}catch{}}},[]),Zi=M.useCallback(()=>{_n.current=!1,pi(!1);try{window.localStorage.removeItem(fi)}catch{}en(400)},[e,en]);M.useEffect(()=>{const W=setInterval(()=>{if(_n.current||Date.now()-di.current<800)return;const Z=n.current,ue=Date.now(),fe=[];for(const Xe of Z.agents.values())Ug(Xe,ue)&&fe.push({id:Xe.id});if(fe.length===0)return;const we=e.getViewport(),_e=window.innerWidth-360,Oe=window.innerHeight-52;let De=!1,Ke=!1;for(const{id:Xe}of fe){const rt=Ye.current.get(Xe),Ct=ct.current.get(Xe)??$t.current.get(Xe);if(!rt||!Ct)continue;Ke=!0;const gr=Ct.x*we.zoom+we.x,Lr=Ct.y*we.zoom+we.y,$r=(Ct.x+rt.width)*we.zoom+we.x,Dr=(Ct.y+rt.height)*we.zoom+we.y;if($r>0&&gr<_e&&Dr>0&&Lr<Oe){De=!0;break}}Ke&&!De&&en(600)},1500);return()=>clearInterval(W)},[e]);const gi=M.useRef(!1),Ye=M.useRef(new Map),Ji=M.useRef(0),vi=M.useCallback(W=>{const Z=Ye.current;let ue=!1;for(const fe of W.nodeInternals.values()){const we=fe.width,_e=fe.height;if(we==null||_e==null)continue;const Oe=Z.get(fe.id);Oe?(Math.abs(Oe.height-_e)>4||Math.abs(Oe.width-we)>4)&&(Z.set(fe.id,{width:we,height:_e}),ue=!0):(Z.set(fe.id,{width:we,height:_e}),ue=!0)}return ue&&(Ji.current+=1),Ji.current},[]),yi=Ze(vi),[hr,es]=M.useState(0);M.useEffect(()=>{let W=0;const Z=()=>{const fe=Ye.current;let we=!1;for(const _e of document.querySelectorAll(".react-flow__node[data-id]")){const Oe=_e.getAttribute("data-id");if(!Oe)continue;const De=_e.offsetWidth,Ke=_e.offsetHeight;if(!De||!Ke)continue;const Xe=fe.get(Oe);(!Xe||Math.abs(Xe.width-De)>4||Math.abs(Xe.height-Ke)>4)&&(fe.set(Oe,{width:De,height:Ke}),we=!0)}we&&es(_e=>_e+1)};if(gi.current)return;let ue=0;return document.visibilityState==="hidden"?ue=window.setTimeout(Z,32):W=requestAnimationFrame(Z),()=>{cancelAnimationFrame(W),window.clearTimeout(ue)}});const $t=M.useRef(new Map(Jt.positions)),nr=M.useRef(""),Nt=M.useMemo(()=>{const W=[];for(const Z of n.current.agents.values())Ug(Z,Ge)&&W.push(Z.id+(Z.parentId?`>${Z.parentId}`:""));return W.sort(),`${W.join("|")}#sv${yi}.${hr}`},[n.current,n.current.lastSeq,Ge,yi,hr]),Ln=M.useRef(null);M.useEffect(()=>(Ln.current!=null&&window.clearTimeout(Ln.current),Ln.current=window.setTimeout(()=>{bg($t.current,ct.current)},1500),()=>{Ln.current!=null&&window.clearTimeout(Ln.current)}),[Nt]),M.useEffect(()=>{if(Pr.current===Nt)return;const W=Pr.current;if(Pr.current=Nt,!W||_n.current)return;Date.now()-xn.current>1200&&en(400),tr.current&&window.clearTimeout(tr.current),tr.current=window.setTimeout(()=>{_n.current||en(500)},280)},[Nt,e,en]);const Xt=M.useMemo(()=>{if(o.size===0)return null;const W=new Set;for(const Z of o){const ue=$$(n.current,Z);if(ue)for(const fe of ue)W.add(fe)}return W.size>0?W:null},[n.current,n.current.lastSeq,o]),Qs=M.useMemo(()=>v$(n.current,Ge),[n.current,n.current.lastSeq,Ge]),la=M.useRef(null),[ts,wi]=M.useState({w:0,h:0});M.useEffect(()=>{const W=la.current;if(!W||typeof ResizeObserver>"u")return;const Z=new ResizeObserver(ue=>{var we;const fe=(we=ue[0])==null?void 0:we.contentRect;fe&&wi(_e=>Math.abs(_e.w-fe.width)>40||Math.abs(_e.h-fe.height)>40?{w:fe.width,h:fe.height}:_e)});return Z.observe(W),wi({w:W.clientWidth,h:W.clientHeight}),()=>Z.disconnect()},[]);const ns=M.useRef(new Map),[Or,rs]=M.useState(!1);M.useEffect(()=>{const W=window.setTimeout(()=>rs(!0),2500);return()=>window.clearTimeout(W)},[]);const[fu,Zs]=M.useState(!1),Sn=M.useRef(null),[is,ss]=M.useState(!1),xi=M.useCallback(()=>{Sn.current&&(window.clearTimeout(Sn.current),Sn.current=null),Zs(!1)},[]),hu=M.useCallback(W=>{W.length!==0&&queueMicrotask(()=>{Zs(!0),Sn.current&&window.clearTimeout(Sn.current),Sn.current=window.setTimeout(()=>Zs(!1),x$+80)})},[]);M.useEffect(()=>()=>{Sn.current&&window.clearTimeout(Sn.current)},[]);const os=ts.w>0?ts.w*.92:0,Be=ts.h>0?ts.h:0,{nodes:fn,edges:ua}=M.useMemo(()=>D$(n.current,Ge,os,Be,ct.current,wn,Ye.current,ns.current,hu,Or,is,$t.current,Nt,nr,o,Xt,Qs,S),[n.current,n.current.lastSeq,Ge,os,Be,Or,is,wn,Nt,o,Xt,Qs,S,Ve]),as=M.useMemo(()=>{const W=new Map;for(const ue of fn){const fe=ue.data;if(!(fe!=null&&fe.sessionId)||fe.exitAt!=null)continue;const we=ue.width,_e=ue.height;if(we==null||_e==null)continue;const Oe=ue.position.x,De=ue.position.y,Ke=Oe+we,Xe=De+_e,rt=W.get(fe.sessionId);rt?(rt.minX=Math.min(rt.minX,Oe),rt.minY=Math.min(rt.minY,De),rt.maxX=Math.max(rt.maxX,Ke),rt.maxY=Math.max(rt.maxY,Xe)):W.set(fe.sessionId,{minX:Oe,minY:De,maxX:Ke,maxY:Xe})}const Z=[];for(const[ue,fe]of W){const we=fe.maxX-fe.minX+bl*2,_e=fe.maxY-fe.minY+bl*2;Z.push({id:`group:${ue}`,type:"sessionGroup",position:{x:fe.minX-bl,y:fe.minY-bl},data:{sessionId:ue,w:we,h:_e},width:we,height:_e,style:{width:we,height:_e},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Z},[fn,Ge]),ca=M.useMemo(()=>{const W=[...as,...fn],Z=Je.current;return!Z||Z.size===0?W:W.map(ue=>{const fe=Z.get(ue.id);return fe?{...ue,position:fe}:ue})},[as,fn,We]),da=M.useMemo(()=>{if(!wn)return null;const W=new Set;for(const Z of n.current.agents.values())xC(Z,wn)&&W.add(Z.id);return W},[n.current,n.current.lastSeq,wn]),Js=M.useMemo(()=>{const W=new Set;for(const Z of n.current.agents.values())for(const ue of Z.tools)W.add(wC(ue.name));return Object.keys(Hg).filter(Z=>W.has(Z))},[n.current,n.current.lastSeq]),pr=M.useMemo(()=>{const W=new Map;for(const ue of n.current.agents.values())for(const fe of ue.tools){if(!fe.name.startsWith("mcp__"))continue;const we=fe.name.slice(5),_e=we.indexOf("__"),Oe=_e>0?we.slice(0,_e):we;W.set(Oe,(W.get(Oe)??0)+1)}const Z=[];for(const[ue,fe]of W){let we=5381;for(let _e=0;_e<ue.length;_e++)we=(we<<5)+we^ue.charCodeAt(_e);Z.push({server:ue,count:fe,hue:Math.abs(we)%360})}return Z.sort((ue,fe)=>fe.count-ue.count),Z},[n.current,n.current.lastSeq]),ls=M.useCallback(W=>{ci(Z=>{const ue=new Set(Z);return ue.has(W)?ue.delete(W):ue.add(W),ue})},[]),dt=u?n.current.agents.get(u):null,$n=f?Array.from(n.current.agents.values()).flatMap(W=>W.tools).find(W=>W.id===f)??null:null,bn=M.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Fg(),ct.current.clear(),Ye.current.clear(),$t.current.clear(),nr.current="",Pk(),m(),s()},[s,m]),mr=M.useCallback(()=>{ct.current.clear(),$t.current.clear(),nr.current="",Pk(),s(),window.setTimeout(()=>en(500),80)},[s,e,en]),qr=M.useCallback(()=>en(500),[en]),kn=M.useCallback(W=>{if(fn.length===0)return;const Z=fn.slice().sort((_e,Oe)=>_e.position.y-Oe.position.y||_e.position.x-Oe.position.x),ue=u?Z.findIndex(_e=>_e.id===u):-1;let fe;ue===-1?fe=W===1?0:Z.length-1:fe=(ue+W+Z.length)%Z.length;const we=Z[fe];we&&(p(we.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[we]})}catch{}xn.current=Date.now()},30))},[fn,u,p,e]);M.useEffect(()=>{const W=Z=>{var fe,we;const ue=((fe=Z.target)==null?void 0:fe.tagName)==="INPUT";if(Z.key==="Escape"){ue?Z.target.blur():m();return}if(!ue){if(Z.key==="/"){Z.preventDefault(),(we=Qi.current)==null||we.focus();return}Z.key===" "&&(Z.preventDefault(),xt(_e=>!_e)),(Z.key==="c"||Z.key==="C")&&bn(),(Z.key==="r"||Z.key==="R")&&mr(),(Z.key==="f"||Z.key==="F")&&qr(),(Z.key==="l"||Z.key==="L")&&ke(),(Z.key==="h"||Z.key==="H")&&ye(_e=>!_e),(Z.key==="u"||Z.key==="U")&&P(_e=>!_e),(Z.key==="a"||Z.key==="A")&&He(),(Z.key==="j"||Z.key==="J")&&kn(1),(Z.key==="k"||Z.key==="K")&&kn(-1),(Z.key==="t"||Z.key==="T")&&Jn(_e=>_e==="dark"?"light":"dark")}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[bn,mr,qr,m,kn]);const eo=n.current.agents.size,fa=new Set(Array.from(n.current.agents.values()).map(W=>W.sessionId)).size,Mt=M.useMemo(()=>{let W=0,Z=0,ue=0,fe=0,we=0,_e=0,Oe=0,De=0,Ke=0;for(const Xe of n.current.agents.values()){W+=Xe.usage.inputTokens,Z+=Xe.usage.outputTokens,ue+=Xe.usage.cacheReadTokens,fe+=Xe.usage.cacheCreateTokens;const rt=un(Xe.usage,Xe.model);we+=rt.total,_e+=rt.input,Oe+=rt.output,De+=rt.cacheRead,Ke+=rt.cacheWrite}return{inT:W,outT:Z,cacheR:ue,cacheC:fe,sum:W+Z,cost:{total:we,input:_e,output:Oe,cacheRead:De,cacheWrite:Ke}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),"agents-deck",ae?g.jsxs("button",{type:"button",className:"v stale",onClick:Ae,title:ae.kind==="restart"?`Running v${ae.from}; v${ae.to} is installed on disk. Restart to pick it up.`:`Running v${ae.from}; v${ae.to} is on npm.`,children:["v",ae.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):g.jsxs("span",{className:"v",children:["v",(k==null?void 0:k.running)??"1.33.2"]})]}),dt&&(()=>{const W=un(dt.usage,dt.model),Z=Math.max(0,((dt.endedAt??Ge)-dt.startedAt)/1e3),ue=dt.state==="active"?$l(W.total,Z):null,fe=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${dt.label}`,onClick:()=>{try{const we=fn.find(_e=>_e.id===dt.id);we&&e.fitView({padding:.35,duration:500,nodes:[we]}),xn.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${dt.state}`,children:dt.state==="active"?"live":dt.state}),g.jsx("span",{className:"selected-label",children:dt.label}),W.total>0&&g.jsxs("span",{className:"selected-cost",children:[ze(W.total),ue?g.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),fe>0&&g.jsxs("span",{className:"selected-extra",children:["+",fe]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:we=>{we.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:Qi,type:"text",placeholder:"Search agents, cwd, tools…",value:wn,onChange:W=>li(W.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),wn?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>li(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${L?"live":"dead"}`,title:L?"Receiving events":"SSE disconnected",children:L?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:fa}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:eo}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:"Total hook events received",children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),Mt.sum>0&&g.jsxs("span",{className:"stat",title:`in:${Mt.inT.toLocaleString()} out:${Mt.outT.toLocaleString()} cache-r:${Mt.cacheR.toLocaleString()} cache-c:${Mt.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:y$(Mt.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),pr.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
59
|
+
burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:w,children:[g.jsx("b",{children:ze(p.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(Hs,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function CP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function jP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function RP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const j=23-Math.floor(w/2500);j>=0&&j<24&&(l[j]+=1,u+=1)}const c=Math.max(1,...l),f=132,h=14,p=f/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:f,height:h,viewBox:`0 0 ${f} ${h}`,"aria-hidden":!0,children:l.map((y,w)=>{const j=y===0?1.5:Math.max(1.5,y/c*h),_=w===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:w*p+.4,y:h-j,width:Math.max(.5,p-1),height:j,rx:.8,className:b},w)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function na(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const i=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function Kw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function TP(e){if(e.endedAt==null)return"in-flight…";const n=e.endedAt-e.startedAt;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(2)}s`}function AP({tool:e,onClose:n}){M.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:g.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`}),g.jsx("span",{className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:TP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Kw(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Kw(e.response??e.errorPreview)})]})]})]})})}const yl=18,Xw=26,IP=12;function MP(e){const n=new Map;for(const o of e.nodeInternals.values()){const l=o.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,f=u+o.width,h=c+o.height,p=n.get(l.sessionId);p?(p.minX=Math.min(p.minX,u),p.minY=Math.min(p.minY,c),p.maxX=Math.max(p.maxX,f),p.maxY=Math.max(p.maxY,h),l.kind==="root"&&(p.label=Qw(l)??p.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:f,maxY:h,label:Qw(l)??l.sessionId})}const i=new Map;for(const o of n.values())i.set(o.label,(i.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(i.get(l.label)??0)>1?`${l.label} · ${PP(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-yl,y:l.minY-yl-Xw,w:l.maxX-l.minX+yl*2,h:l.maxY-l.minY+yl*2+Xw})}return s}function PP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Qw(e){if(e.kind==="root")return e.label}function OP(){const{x:e,y:n,zoom:i}=tN(),s=ta(),o=Ze(MP,qP);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(f=>{const h=f.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=dv(u.sessionId),f={position:"absolute",left:u.x*i+e,top:u.y*i+n,width:u.w*i,height:u.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*i+e+16*i,top:(u.y-IP)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return g.jsxs(le.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:f,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function qP(e,n){if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++){const s=e[i],o=n[i];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function LP({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const dN=600,$P=36,Bg=16,DP=60,FP=6,Zw=220,Jw=96,zP=28,BP={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan",ScheduleWakeup:"other",CronCreate:"other",CronList:"other",CronDelete:"other",Monitor:"other",PushNotification:"other",RemoteTrigger:"other",ToolSearch:"other"};function UP(e){return e.startsWith("mcp__")?"mcp":BP[e]??"other"}const HP={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",shell:"⚡",exec_command:"⚡",shell_command:"⚡",write_stdin:"💻",wait:"⏳",apply_patch:"🩹",update_plan:"📋",LS:"📂",Task:"🤖",Agent:"🤖",TodoWrite:"📋",TaskCreate:"📋",TaskUpdate:"📝",TaskList:"🗂️",TaskGet:"🗂️",TaskOutput:"📤",TaskStop:"🛑",WebFetch:"🌐",WebSearch:"🔭",ToolSearch:"🧰",NotebookEdit:"📓",EnterPlanMode:"🧭",ExitPlanMode:"🏁",AskUserQuestion:"❓",ScheduleWakeup:"⏰",CronCreate:"⏰",CronList:"📅",CronDelete:"🗑️",Skill:"🎯",Workflow:"🎬",Monitor:"📡",PushNotification:"🔔",RemoteTrigger:"📡"};function ex(e){return e.startsWith("mcp__")?"🔌":HP[e]??"✨"}const VP={git:"🐙",gh:"🐙",glab:"🐙",npm:"📦",pnpm:"📦",yarn:"📦",bun:"📦",brew:"🍺",node:"🟢",deno:"🟢",python:"🐍",python3:"🐍",py:"🐍",pip:"🐍",pip3:"🐍",uv:"🐍",ruby:"💎",bundle:"💎",gem:"💎",cargo:"🦀",rustc:"🦀",rustup:"🦀",go:"🐹",docker:"🐳","docker-compose":"🐳",podman:"🐳",kubectl:"☸️",helm:"☸️",k9s:"☸️",grep:"🔎",rg:"🔎",ag:"🔎",ack:"🔎",find:"🔍",fd:"🔍",locate:"🔍",which:"🔍",ls:"📂",dir:"📂",tree:"📂",cat:"📄",head:"📄",tail:"📄",less:"📄",more:"📄",bat:"📄",cp:"📋",mv:"✂️",rm:"🗑️",rmdir:"🗑️",mkdir:"📁",touch:"📁",sed:"✏️",awk:"✏️",tr:"✏️",curl:"🌐",wget:"🌐",http:"🌐",httpie:"🌐",ssh:"🔐",scp:"🔐",rsync:"🔐",ping:"📡",make:"🔨",cmake:"🔨",ninja:"🔨",bazel:"🔨",just:"🔨",terraform:"🏗️",ansible:"📕",pulumi:"🏗️",ps:"📊",top:"📊",htop:"📊",btm:"📊",kill:"💀",pkill:"💀",systemctl:"⚙️",service:"⚙️",tar:"🗜️",zip:"🗜️",unzip:"🗜️",gzip:"🗜️","7z":"🗜️",vim:"📝",nvim:"📝",nano:"📝",emacs:"📝",code:"📝",jq:"🪺",yq:"🪺",echo:"💬",printf:"💬",ffmpeg:"🎞️",ffprobe:"🎞️",imagemagick:"🖼️",convert:"🖼️","Get-ChildItem":"📂","Get-Content":"📄","Set-Content":"💾","Out-File":"💾","Add-Content":"💾","Set-Location":"📍","Get-Location":"📍","Get-Process":"📊","Start-Process":"▶️","Stop-Process":"💀","Invoke-WebRequest":"🌐","Invoke-RestMethod":"🌐","New-Item":"📁","Remove-Item":"🗑️","Copy-Item":"📋","Move-Item":"✂️","Test-Path":"🔍","Where-Object":"🔎","ForEach-Object":"🔁","Select-Object":"🎯","Measure-Object":"📊","Get-Service":"⚙️","Restart-Service":"⚙️","ConvertTo-Json":"🪺","ConvertFrom-Json":"🪺"};function fN(e){if(!e)return null;let n=e.trim();if(!n)return null;const i=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(i)return fN(i[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function WP(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(i=>typeof i=="string")){const i=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(i[0]??"")){const s=i.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<i.length)return i[s+1]}return i.join(" ")}return typeof n.script=="string"?n.script:null}const GP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),YP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function KP(e,n){return YP.has(e)?Math.max(Jw,34+n.length*7.5):Jw}function XP(e,n){if(!GP.has(e))return null;const i=WP(n);if(!i)return null;const s=fN(i);return s?{emoji:VP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const QP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),tx={ts:"🟦",tsx:"🟦",d:"🟦",js:"🟨",jsx:"🟨",mjs:"🟨",cjs:"🟨",py:"🐍",pyi:"🐍",ipynb:"📓",rs:"🦀",go:"🐹",rb:"💎",erb:"💎",java:"☕",kt:"☕",scala:"☕",gradle:"☕",cs:"🔷",fs:"🔷",php:"🐘",swift:"🦅",c:"🇨",cpp:"🇨",cc:"🇨",h:"🇨",hpp:"🇨",md:"📝",mdx:"📝",rst:"📝",json:"🪺",json5:"🪺",jsonl:"🪺",yaml:"⚙️",yml:"⚙️",toml:"⚙️",ini:"⚙️",conf:"⚙️",cfg:"⚙️",xml:"📰",html:"🌐",htm:"🌐",vue:"🌐",svelte:"🌐",css:"🎨",scss:"🎨",sass:"🎨",less:"🎨",sh:"⚡",bash:"⚡",zsh:"⚡",fish:"⚡",ps1:"⚡",txt:"📄",log:"📄",out:"📄",csv:"📊",tsv:"📊",xlsx:"📊",xls:"📊",pdf:"📕",png:"🖼️",jpg:"🖼️",jpeg:"🖼️",gif:"🖼️",webp:"🖼️",svg:"🖼️",ico:"🖼️",mp4:"🎬",mov:"🎬",avi:"🎬",mkv:"🎬",webm:"🎬",mp3:"🎵",wav:"🎵",ogg:"🎵",flac:"🎵",zip:"🗜️",tar:"🗜️",gz:"🗜️",bz2:"🗜️","7z":"🗜️",xz:"🗜️",rar:"🗜️",env:"🔐",lock:"🔐",pem:"🔐",key:"🔐",crt:"🔐",sql:"🗄️",db:"🗄️",sqlite:"🗄️",parquet:"🗄️"},nx={dockerfile:"🐳",makefile:"🔨",rakefile:"💎","package.json":"📦","pnpm-lock.yaml":"📦","yarn.lock":"📦","cargo.toml":"🦀","cargo.lock":"🦀","go.mod":"🐹","go.sum":"🐹","pyproject.toml":"🐍","requirements.txt":"🐍","readme.md":"📖",readme:"📖",license:"📜",".gitignore":"🐙",".gitattributes":"🐙",".env":"🔐",".dockerignore":"🐳"};function ZP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function JP(e){const n=e.toLowerCase();if(nx[n])return nx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const i=n.lastIndexOf(".");if(i>0&&i<n.length-1){const s=n.slice(i+1);if(tx[s])return tx[s]}return"📄"}function e3(e,n){if(!n||typeof n!="object")return null;const i=n;if(e==="apply_patch"&&typeof i.patch=="string"){const s=i.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[1].trim():null}return typeof i.file_path=="string"?i.file_path:typeof i.notebook_path=="string"?i.notebook_path:typeof i.path=="string"?i.path:e==="Glob"&&typeof i.pattern=="string"?i.pattern:null}function t3(e,n){if(!QP.has(e))return null;const i=e3(e,n);if(!i)return null;const s=ZP(i);return s?{emoji:e==="LS"?"📂":JP(s),label:s,category:"file",detail:i}:null}const hN={github:{emoji:"🐙",name:"GitHub"},git:{emoji:"🐙",name:"Git"},gitlab:{emoji:"🦊",name:"GitLab"},slack:{emoji:"💬",name:"Slack"},discord:{emoji:"💬",name:"Discord"},linear:{emoji:"📐",name:"Linear"},jira:{emoji:"🅹",name:"Jira"},atlassian:{emoji:"🅰️",name:"Atlassian"},notion:{emoji:"📓",name:"Notion"},asana:{emoji:"📋",name:"Asana"},intercom:{emoji:"💬",name:"Intercom"},figma:{emoji:"🎨",name:"Figma"},gmail:{emoji:"📧",name:"Gmail"},calendar:{emoji:"📅",name:"Calendar"},drive:{emoji:"☁️",name:"Drive"},zoom:{emoji:"📹",name:"Zoom"},spotify:{emoji:"🎵",name:"Spotify"},youtube:{emoji:"📺",name:"YouTube"},ccd_session:{emoji:"📡",name:"Session"},ccd_directory:{emoji:"📂",name:"Directory"},ccd_session_mgmt:{emoji:"📡",name:"Sessions"},mcp_registry:{emoji:"🧰",name:"Registry"},"computer-use":{emoji:"🖱️",name:"Computer"},"claude-in-chrome":{emoji:"🌐",name:"Chrome"},"claude-preview":{emoji:"👀",name:"Preview"},"scheduled-tasks":{emoji:"⏰",name:"Scheduler"},visualize:{emoji:"🎨",name:"Visualize"},"plugin-design-asana":{emoji:"📋",name:"Asana"},"plugin-design-atlassian":{emoji:"🅰️",name:"Atlassian"},"plugin-design-figma":{emoji:"🎨",name:"Figma"},"plugin-design-intercom":{emoji:"💬",name:"Intercom"},"plugin-design-linear":{emoji:"📐",name:"Linear"},"plugin-design-notion":{emoji:"📓",name:"Notion"},"plugin-design-slack":{emoji:"💬",name:"Slack"}};function pN(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),i=n.indexOf("__");return i<=0?{server:n,method:""}:{server:n.slice(0,i),method:n.slice(i+2)}}function n3(e){let n=5381;for(let i=0;i<e.length;i++)n=(n<<5)+n^e.charCodeAt(i);return Math.abs(n)%360}function r3(e,n){const i=pN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const l=hN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function i3(e,n){return XP(e,n)??t3(e,n)??r3(e)}const s3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function o3(e){const n=pN(e);if(n){const s=hN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:n3(n.server)}}const i=s3[e];return i?{emoji:ex(e),label:i}:{emoji:ex(e),label:e}}function a3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function l3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/dN)}function u3(e,n,i,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>dN)continue;const f=s.get(c.id)??i.get(c.id);if(!f)continue;const h=c.tools.slice(-4);if(h.length===0)continue;const p=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??Zw,Zw),w=(m==null?void 0:m.height)??130,j=f.x,_=f.y,S=j+y,b=_+w/2;h.forEach((E,N)=>{const C=N*$P,I=j+y+DP,O=_+FP+C,P=l3(E,l,p),z=E.inputPreview??"",T=a3(E),q=P<.999,B=o3(E.name);u.push({id:E.id,toolId:E.id,agentId:c.id,toolName:E.name,name:B.label,emoji:B.emoji,status:T,category:UP(E.name),mcpHue:B.hue,inputPreview:z,fade:P,fading:q,worldX:I,worldY:O,anchorX:S,anchorY:b,spawnDx:S-I,spawnDy:b-(O+Bg)});const J=i3(E.name,E.input);if(J){const Q=KP(E.name,B.label),A=I+Q+zP,H=O,U=I+Q,ne=O+Bg;u.push({id:`sub:${E.id}`,toolId:E.id,agentId:c.id,toolName:E.name,name:J.label,emoji:J.emoji,isSub:!0,status:T,category:J.category,inputPreview:J.detail??z,fade:P,fading:q,worldX:A,worldY:H,anchorX:U,anchorY:ne,spawnDx:U-A,spawnDy:0})}})}return u}function c3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:f,onOpenTool:h}){const{x:p,y:m,zoom:y}=tN(),w=u3(e,n,i,s,o,f),j=c&&c.size>0?w.filter(_=>!c.has(_.category)):w;return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:j.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,E=(_.worldX+6)*y+p,N=(_.worldY+Bg)*y+m,C=S+(E-S)*.55,I=l!=null&&!l.has(_.agentId),O=u!=null&&!u.has(_.agentId),P=_.fade*(I||O?.14:1);return g.jsx("path",{d:`M ${S} ${b} Q ${C} ${b}, ${E} ${N}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:P},`l:${_.id}`)})}),j.map(_=>{const S=_.worldX*y+p,b=_.worldY*y+m,E={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},N=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${N} · ${_.inputPreview}`:N,I=h!=null,O=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},P=l!=null&&!l.has(_.agentId),z=u!=null&&!u.has(_.agentId),T=P||z?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:E,children:g.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${I?" clickable":""}${_.isSub?" sub":""}${T}`,style:O,title:C,role:I?"button":void 0,tabIndex:I?0:void 0,"aria-label":I?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:I?()=>h(_.toolId):void 0,onKeyDown:I?q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),h(_.toolId))}:void 0,children:[g.jsx("span",{className:"tb-emoji",children:_.emoji}),g.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),_.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function d3({state:e,sessionId:n,onClose:i}){const s=M.useMemo(()=>h3(e,n),[e,n]);return s?g.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),g.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:ze(s.cost.total)}),s.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>g.jsx("span",{className:"model-chip",title:o,children:na(o)},o))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(f3,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:ze(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:ze(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:ze(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:ze(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Ps,{label:"agents",value:s.agentCount}),g.jsx(Ps,{label:"subagents",value:s.subagentCount}),g.jsx(Ps,{label:"tool calls",value:s.toolCount}),g.jsx(Ps,{label:"prompts",value:s.promptCount}),g.jsx(Ps,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx(Ps,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Most-used tools"}),g.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,l])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:o}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${l/s.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:l})]},o))})]}),s.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Ps({label:e,value:n,tone:i}){return g.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function f3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function h3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const N of e.agents.values())N.sessionId===n&&s.push(N);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,f=0,h=0,p=0,m=0,y,w=1/0,j=0;for(const N of s){const C=un(N.usage,N.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,N.model&&l.add(N.model),N.kind==="subagent"&&m++,f+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),h+=N.usage.inputTokens+N.usage.outputTokens,c+=N.tools.length,w=Math.min(w,N.startedAt),j=Math.max(j,N.endedAt??Date.now());for(const I of N.tools)u.set(I.name,(u.get(I.name)??0)+1),I.ok===!1&&p++}const _=Math.max(0,j-w),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,E=Array.from(u.entries()).sort((N,C)=>C[1]-N[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:f,tokensSum:h,errCount:p,topTools:E,firstPrompt:y}}function p3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,l=un(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.tools.length,l+=un(c.usage,c.model).total;const f=c.endedAt??c.startedAt;f>u&&(u=f)}i.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return i.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),i}function m3(e,n,i){const s=(n??i)-e;if(s<1e3)return"<1s";const o=Math.floor(s/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function g3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const l=M.useMemo(()=>p3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return g.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[g.jsxs("div",{className:"sl-header",children:[g.jsxs("h3",{children:["Sessions ",g.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&g.jsxs("span",{className:"sl-live-count",children:[u," live"]}),g.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),g.jsxs("div",{className:"sl-rows",children:[l.length===0&&g.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const f=i.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${f?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[g.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&g.jsx("span",{className:"model-chip",title:c.modelId,children:na(c.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:ze(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:m3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function rx(e,n){if(!e)return null;const i=n-Math.floor(e/1e3);return i<10?"just now":i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:`${Math.floor(i/3600)}h ago`}function v3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function Nr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function y3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(s)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function w3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/3600),o=Math.floor(i%3600/60);if(s>23){const l=Math.floor(i/86400),u=Math.floor(i%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function x3(e,n,i,s){const o=Math.max(0,n-s),l=Math.max(0,i-o);if(l<120)return null;const u=Math.min(100,l/i*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const f=100-e,h=l>0?e/l:0,p=h>0?f/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(p<o&&p<86400){const y=Math.floor(p/3600),w=Math.floor(p%3600/60);m.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function qi({pct:e,label:n,reset:i,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",p=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?w3(s,u):null,w=s&&o?x3(c,s,o,u):null;return g.jsxs("div",{className:"qb-row",children:[g.jsxs("div",{className:"qb-meta",children:[g.jsxs("span",{className:"qb-label",children:[n,l&&g.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),g.jsx("span",{className:"qb-pct",style:{color:h},children:p})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),w&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?g.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,w&&g.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const _3=6e4;function S3(){const[e,n]=M.useState(null),[i,s]=M.useState(!1),o=M.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return M.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),_3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>l(!0)}}function b3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const mN=6e4;function k3(){const[e,n]=M.useState(null),[i,s]=M.useState(!1),o=M.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return M.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),mN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>l(!0)}}function E3(){const[e,n]=M.useState(null),i=M.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return M.useEffect(()=>(s(),i.current=window.setInterval(s,mN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function N3({state:e,now:n,onClose:i}){var P,z;const{quota:s,loading:o,refresh:l}=S3(),{data:u,loading:c,refresh:f}=k3(),{data:h}=E3(),[p,m]=M.useState(()=>Math.floor(Date.now()/1e3));M.useEffect(()=>{const T=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(T)},[]);const{byModel:y,totalCost:w,totalTokens:j,burnRate:_}=M.useMemo(()=>{const T=new Map,q={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let B=0,J=0,Q=0,A=0;for(const L of e.agents.values()){const G=L.model??"__unknown__",k=un(L.usage,L.model),$=T.get(G);$?($.inputTokens+=L.usage.inputTokens,$.outputTokens+=L.usage.outputTokens,$.cacheReadTokens+=L.usage.cacheReadTokens,$.cacheCreateTokens+=L.usage.cacheCreateTokens,$.cost.total+=k.total,$.cost.input+=k.input,$.cost.output+=k.output,$.cost.cacheRead+=k.cacheRead,$.cost.cacheWrite+=k.cacheWrite,$.agentCount++):T.set(G,{model:G,inputTokens:L.usage.inputTokens,outputTokens:L.usage.outputTokens,cacheReadTokens:L.usage.cacheReadTokens,cacheCreateTokens:L.usage.cacheCreateTokens,cost:{...k},agentCount:1}),q.total+=k.total,q.input+=k.input,q.output+=k.output,q.cacheRead+=k.cacheRead,q.cacheWrite+=k.cacheWrite,B+=L.usage.inputTokens,J+=L.usage.outputTokens,Q+=L.usage.cacheReadTokens,A+=L.usage.cacheCreateTokens}const H=Array.from(T.values()).sort((L,G)=>G.cost.total-L.cost.total);let U=0,ne=0;for(const L of e.agents.values()){if(L.state!=="active")continue;const G=un(L.usage,L.model);U+=G.total,ne=Math.max(ne,((L.endedAt??n)-L.startedAt)/1e3)}const Y=ne>0?$l(U,ne):null;return{byModel:H,totalCost:q,totalTokens:{in:B,out:J,cacheR:Q,cacheC:A},burnRate:Y}},[e,e.lastSeq,n]),S=M.useMemo(()=>{const T=[];for(const q of e.agents.values()){if(q.kind!=="root")continue;let B=un(q.usage,q.model).total,J=q.usage.inputTokens,Q=q.usage.outputTokens;for(const A of e.agents.values())A.sessionId!==q.sessionId||A.kind==="root"||(B+=un(A.usage,A.model).total,J+=A.usage.inputTokens,Q+=A.usage.outputTokens);T.push({sessionId:q.sessionId,label:q.label||q.cwdBasename||"session",state:q.state,cost:B,inputTokens:J,outputTokens:Q})}return T.sort((q,B)=>B.cost-q.cost).slice(0,12)},[e,e.lastSeq]),b=w.total>0,E=j.in+j.out,N=o||c,C=rx(s==null?void 0:s.fetchedAt,p),I=rx(u==null?void 0:u.fetchedAt,p),O=()=>{l(),f()};return g.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),_&&g.jsx("span",{className:"up-rate",children:_}),g.jsxs("div",{className:"up-header-right",children:[g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:O,disabled:N,title:"Refresh Claude + Codex quota",children:N?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&g.jsx("span",{className:"up-section-age",title:v3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx(qi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:p}),s.week7dPct!=null&&g.jsx(qi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:p}),s.weekSonnetPct!=null&&g.jsx(qi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:p}),s.weekOpusPct!=null&&g.jsx(qi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:p})]}):(s==null?void 0:s.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),I&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:I})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(P=u.windows)==null?void 0:P.map(T=>g.jsx(qi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,limitReached:u.limitReached&&T.pct>=100,nowSec:p},T.id)),(z=u.extraWindows)==null?void 0:z.map(T=>g.jsx(qi,{label:T.label,pct:T.pct,reset:T.reset??void 0,resetAt:T.resetAt??void 0,windowSec:T.windowSec??void 0,nowSec:p},T.id)),u.creditLimit&&g.jsx(qi,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:p}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[Nr(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&g.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:b3(u.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:ze(w.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(y3,{cost:w}),E>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Nr(j.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Nr(j.out)]}),j.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Nr(j.cacheR)]}),j.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Nr(j.cacheC)]})]}),y.filter(T=>T.cost.total>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:y.filter(T=>T.cost.total>0).map(T=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:T.model,children:na(T.model)}),g.jsx("td",{className:"up-num",children:Nr(T.inputTokens+T.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:ze(T.cost.total)})]},T.model))})]})]}),S.filter(T=>T.cost>0).length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:S.filter(T=>T.cost>0).map(T=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${T.state}`,"aria-hidden":!0}),g.jsx("span",{className:"up-session-label",children:T.label}),g.jsx("span",{className:"up-session-tokens",children:Nr(T.inputTokens+T.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:ze(T.cost)})]},T.sessionId))})]})]}):E>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Nr(j.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Nr(j.out)]})]}),g.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const C3=1500;async function wl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const j3={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck1:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:"that share was made by a newer agents-deck",expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import"},id=(e,n)=>(e==null?void 0:e.detail)||(e!=null&&e.reason?j3[e.reason]??e.reason:null)||(e==null?void 0:e.error)||n;function R3({onClose:e,onChanged:n}){const[i,s]=M.useState("login"),[o,l]=M.useState(null),[u,c]=M.useState(""),[f,h]=M.useState(""),[p,m]=M.useState(!1),[y,w]=M.useState(null),[j,_]=M.useState(null),S=M.useRef(!1),b=M.useRef(null),E=M.useCallback(()=>{S.current&&wl({action:"login-cancel"}).catch(()=>{}),e()},[e]);M.useEffect(()=>{const P=z=>{z.key==="Escape"&&E()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[E]);const N=M.useCallback(async()=>{m(!0),w(null),S.current=!0;const P=await wl({action:"login"}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"could not start the sign-in"));return}l(P)},[]);M.useEffect(()=>{i!=="login"||S.current||N()},[i,N]),M.useEffect(()=>{if(!o||o.state==="done"||o.state==="failed")return;const P=window.setInterval(async()=>{try{const z=await fetch("/api/claude-accounts/login");z.ok&&l(await z.json())}catch{}},C3);return()=>window.clearInterval(P)},[o]),M.useEffect(()=>{var P;(o==null?void 0:o.state)==="awaiting_code"&&((P=b.current)==null||P.focus()),(o==null?void 0:o.state)==="done"&&n()},[o==null?void 0:o.state,n]);const C=M.useCallback(async()=>{var z;m(!0),w(null);const P=await wl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"the code was not accepted")),P!=null&&P.state&&l(P),(z=b.current)==null||z.select();return}c(""),l(P)},[u,o]),I=M.useCallback(async()=>{m(!0),w(null);const P=await wl({action:"import",blob:f}).catch(()=>null);if(m(!1),!(P!=null&&P.ok)){w(id(P,"the import failed"));return}h(""),_({added:P.added===!0,num:P.num??null}),n()},[f,n]),O=(o==null?void 0:o.state)==="done"?o.account:null;return g.jsx("div",{className:"modal-backdrop",onClick:E,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":i==="login",className:`aa-tab${i==="login"?" on":""}`,onClick:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":i==="paste",className:`aa-tab${i==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:E,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:i==="login"?O?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:O.added?`Added account ${O.num}`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[O.email,O.added?" is now in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:b,type:"text",value:u,onChange:P=>c(P.target.value),onKeyDown:P=>{P.key==="Enter"&&u.trim()&&!p&&C()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:p||!u.trim()||o.state==="registering",onClick:C,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):(o==null?void 0:o.state)==="failed"||y?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Sign-in failed"}),g.jsx("p",{className:"aa-err",children:y??(o==null?void 0:o.error)}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),w(null),N()},children:"Try again"})]}):g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{type:"text",value:f,onChange:P=>h(P.target.value),onKeyDown:P=>{P.key==="Enter"&&f.trim()&&!p&&I()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:p||!f.trim(),onClick:I,children:p?"importing…":"Import"})]}),j&&g.jsx("p",{className:"aa-note",children:j.added?`Added account ${j.num}.`:"That account was already here, so nothing changed."}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}const T3=15e3,A3=[70,80,85,90,95];function I3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/86400),o=Math.floor(i%86400/3600),l=Math.floor(i%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function ix(e,n){const i=n-Math.floor(e/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}function M3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?" · due":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function P3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function O3({lane:e,nowSec:n}){const i=Math.min(100,Math.max(0,e.pct)),s=i>=90?"var(--err)":i>=70?"var(--warn)":"var(--accent)",o=e.resetAt?I3(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function q3(e){const n=e.map(s=>s.num),i=n.length?Math.max(...n):0;return[...new Set([...n,i+1])].sort((s,o)=>s-o)}function L3(e,n){const i=Math.round(e/1e3)-n;return i<=0?"expired":i<60?`expires in ${i}s`:`expires in ${Math.round(i/60)}m`}function $3({onClose:e}){var Y,L,G;const[n,i]=M.useState(null),[s,o]=M.useState(null),[l,u]=M.useState(null),[c,f]=M.useState(null),[h,p]=M.useState(null),[m,y]=M.useState(()=>Math.floor(Date.now()/1e3)),w=M.useRef(null),[j,_]=M.useState(null),[S,b]=M.useState(!1),[E,N]=M.useState(""),[C,I]=M.useState(null),[O,P]=M.useState(null),[z,T]=M.useState(!1),q=M.useCallback(async(k=!1)=>{try{const[$,oe]=await Promise.all([fetch(`/api/claude-accounts${k?"?refresh=1":""}`),fetch("/api/cswap-auto")]);$.ok&&i(await $.json()),oe.ok&&o(await oe.json())}catch{}},[]),B=M.useCallback(async(k,$)=>{u($),p(null);try{const D=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return D!=null&&D.ok||p((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return p("server unreachable"),null}finally{u(null)}},[]),J=M.useCallback(async(k,$)=>{u($),p(null);try{const D=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)})).json().catch(()=>null);return D!=null&&D.ok||p((D==null?void 0:D.detail)||(D==null?void 0:D.reason)||"command failed"),D}catch{return p("server unreachable"),null}finally{u(null)}},[]);M.useEffect(()=>(q(!0),w.current=window.setInterval(()=>q(!1),T3),()=>{w.current!=null&&window.clearInterval(w.current)}),[q]),M.useEffect(()=>{const k=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(k)},[]);const Q=((Y=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Y.value)??"90",A=(L=n==null?void 0:n.accounts)==null?void 0:L.find(k=>k.active),H=A!=null&&A.lanes.length?Math.max(...A.lanes.map(k=>k.pct)):null,U=H!=null&&H>=Number(Q)-15,ne=async k=>{f(k),p(null);try{const oe=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:k})})).json().catch(()=>null);oe!=null&&oe.ok||p((oe==null?void 0:oe.output)||(oe==null?void 0:oe.reason)||"switch failed"),await q(!0)}catch{p("server unreachable")}finally{f(null)}};return g.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h3",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>b(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>q(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(G=n.accounts)==null?void 0:G.map(k=>g.jsxs("div",{className:`ap-account${k.active?" active":""}${k.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:k.num}),k.alias&&g.jsx("span",{className:"ap-alias",children:k.alias}),g.jsx("span",{className:"ap-email",title:k.org??void 0,children:k.email}),g.jsx("button",{type:"button",className:`ap-more${j===k.num?" on":""}`,"aria-label":`Manage account ${k.num}`,"aria-expanded":j===k.num,title:"Share, rename, move, remove",onClick:()=>{_(j===k.num?null:k.num),N(k.alias??""),I(null),P(null),T(!1)},children:"⋯"}),k.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||k.disabled,onClick:()=>ne(k.num),title:k.disabled?"Held out of rotation":`Switch to ${k.alias??k.email}`,children:c===k.num?"…":"switch"})]}),k.lanes.length>0?k.lanes.map($=>g.jsx(O3,{lane:$,nowSec:m},$.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[k.error&&g.jsx("span",{className:"ap-err",children:P3(k.error)}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!k.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>B({action:"account",account:k.num,enabled:k.disabled},`rot-${k.num}`).then(()=>q(!0)),title:k.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:k.disabled?"held out":"in rotation"}),k.fetchedAt?g.jsxs("span",{className:`ap-age${k.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",ix(k.fetchedAt,m),M3(k.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),j===k.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:E,onChange:$=>N($.target.value),onKeyDown:$=>{$.key==="Enter"&&J({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>q(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${k.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||E.trim()===(k.alias??""),onClick:()=>J({action:"alias",account:k.num,alias:E},`alias-${k.num}`).then(()=>q(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${k.num}`,value:String(k.num),disabled:l!=null,onChange:$=>J({action:"move",account:k.num,slot:Number($.target.value)},`move-${k.num}`).then(()=>q(!0)),children:q3(n.accounts??[]).map($=>g.jsx("option",{value:$,children:$},$))})}),g.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{T(!1);const $=await J({action:"share",account:k.num},`share-${k.num}`);$!=null&&$.ok&&P({num:k.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${C===k.num?" armed":""}`,disabled:l!=null,title:C===k.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(C!==k.num){I(k.num),window.setTimeout(()=>I($=>$===k.num?null:$),4e3);return}I(null),J({action:"remove",account:k.num},`rm-${k.num}`).then(()=>{_(null),q(!0)})},children:C===k.num?"confirm remove":"remove"})]}),(O==null?void 0:O.num)===k.num&&g.jsxs("div",{className:"ap-share",children:[g.jsx("code",{className:"ap-share-blob",children:O.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",onClick:async()=>{try{await navigator.clipboard.writeText(O.blob),T(!0)}catch{}},children:z?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",L3(O.expiresAt,m)]})]})]})]})]},k.num)),(s==null?void 0:s.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[H!=null&&g.jsxs("span",{className:`ap-auto-now${U?" near":""}`,children:[Math.round(H),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:Q,disabled:l!=null,onChange:k=>B({action:"setting",key:"autoswitch.threshold",value:k.target.value},"threshold").then(()=>q(!0)),children:A3.map(k=>g.jsxs("option",{value:k,children:[k,"%"]},k))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>B({action:"enable",enabled:!s.enabled},"enable").then(()=>q(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",ix(s.lastTick.at,m)]})})]}),h&&g.jsx("div",{className:"ap-failure",children:h}),g.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),S&&g.jsx(R3,{onClose:()=>b(!1),onChanged:()=>q(!0)})]})}const D3=3e4;function F3({bundle:e,running:n,lastTried:i}){return!n||e===n?!1:i!==n}function z3(e){const n=e.thresholdMs??D3;return!e.enabled||e.kind!=="restart"||!e.canRestart?{idleSince:null,restart:!1}:e.busy?{idleSince:null,restart:!1}:e.idleSince==null?{idleSince:e.now,restart:!1}:e.now<e.idleSince?{idleSince:e.now,restart:!1}:{idleSince:e.idleSince,restart:e.now-e.idleSince>=n}}function Li(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:e<1e9?`${(e/1e6).toFixed(2)}M`:`${(e/1e9).toFixed(2)}B`}function sx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function xl(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}function B3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const U3=[7,14,30,90];function H3(e){const[n,i]=M.useState(null),[s,o]=M.useState(!1),l=(u=!1)=>{o(!0);const f=`/api/ccusage?since=${B3(e)}${u?"&refresh=1":""}`;fetch(f).then(h=>h.json()).then(i).catch(()=>i({ok:!1,error:"request failed"})).finally(()=>o(!1))};return M.useEffect(()=>{l(!1)},[e]),{data:n,loading:s,reload:()=>l(!0)}}function V3({onClose:e}){var b,E;const[n,i]=M.useState(30),[s,o]=M.useState(null),{data:l,loading:u,reload:c}=H3(n);M.useEffect(()=>{const N=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const f=l!=null&&l.ok?l.days??[]:[],h=M.useMemo(()=>f.reduce((N,C)=>Math.max(N,C.totalCost),0),[f]),{totalCost:p,totalTok:m,inOut:y,cacheRead:w,modelCosts:j}=M.useMemo(()=>{let N=0,C=0,I=0,O=0;const P=new Map;for(const z of f){N+=z.totalCost,C+=z.totalTokens,I+=z.inputTokens+z.outputTokens,O+=z.cacheReadTokens;for(const T of z.modelBreakdowns)P.set(T.modelName,(P.get(T.modelName)??0)+T.cost)}return{totalCost:N,totalTok:C,inOut:I,cacheRead:O,modelCosts:P}},[f]),_=M.useMemo(()=>Array.from(j.entries()).sort((N,C)=>C[1]-N[1]),[j]),S=s?f.find(N=>N.period===s)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{className:"uh-modal",onClick:N=>N.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),g.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:U3.map(N=>g.jsxs("button",{role:"tab","aria-selected":n===N,className:`uh-range-btn${n===N?" on":""}`,onClick:()=>{i(N),o(null)},children:[N,"d"]},N))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),g.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&f.length===0?g.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?g.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):f.length===0?g.jsx("div",{className:"uh-status",children:"no usage in this range"}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(_l,{label:"total cost",val:ze(p),accent:!0}),g.jsx(_l,{label:"tokens",val:Li(m)}),g.jsx(_l,{label:"input+output",val:Li(y)}),g.jsx(_l,{label:"cache reads",val:Li(w)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:f.map(N=>{const C=h>0?N.totalCost/h*100:0,I=N.period===s;return g.jsxs("button",{className:`uh-bar-col${I?" sel":""}`,onClick:()=>o(I?null:N.period),title:`${N.period} · ${ze(N.totalCost)}`,style:{flexBasis:`${100/f.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,N.totalCost>0?2:0)}%`},children:N.modelBreakdowns.slice().sort((O,P)=>P.cost-O.cost).map(O=>{const P=N.totalCost>0?O.cost/N.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${P}%`,background:xl(O.modelName)}},O.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:N.period.slice(5)})]},N.period)})}),g.jsx("div",{className:"uh-legend",children:_.map(([N,C])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:xl(N)}}),sx(N)," ",g.jsx("span",{className:"uh-legend-cost",children:ze(C)})]},N))}),S&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:S.period}),g.jsx("span",{className:"uh-detail-cost",children:ze(S.totalCost)}),(E=(b=S.metadata)==null?void 0:b.agents)!=null&&E.length?g.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Sl,{label:"input",val:Li(S.inputTokens)}),g.jsx(Sl,{label:"output",val:Li(S.outputTokens)}),g.jsx(Sl,{label:"cache write",val:Li(S.cacheCreationTokens)}),g.jsx(Sl,{label:"cache read",val:Li(S.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((N,C)=>C.cost-N.cost).map(N=>{const C=S.totalCost>0?N.cost/S.totalCost*100:0;return g.jsxs("div",{className:"uh-model-row",children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:xl(N.modelName)}}),sx(N.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:xl(N.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:ze(N.cost)})]},N.modelName)})})]})]})]})})}function _l({label:e,val:n,accent:i}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function Sl({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function hv(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var sd,ox;function W3(){if(ox)return sd;ox=1;function e(){this.__data__=[],this.size=0}return sd=e,sd}var od,ax;function Vs(){if(ax)return od;ax=1;function e(n,i){return n===i||n!==n&&i!==i}return od=e,od}var ad,lx;function Gl(){if(lx)return ad;lx=1;var e=Vs();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return ad=n,ad}var ld,ux;function G3(){if(ux)return ld;ux=1;var e=Gl(),n=Array.prototype,i=n.splice;function s(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():i.call(l,u,1),--this.size,!0}return ld=s,ld}var ud,cx;function Y3(){if(cx)return ud;cx=1;var e=Gl();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return ud=n,ud}var cd,dx;function K3(){if(dx)return cd;dx=1;var e=Gl();function n(i){return e(this.__data__,i)>-1}return cd=n,cd}var dd,fx;function X3(){if(fx)return dd;fx=1;var e=Gl();function n(i,s){var o=this.__data__,l=e(o,i);return l<0?(++this.size,o.push([i,s])):o[l][1]=s,this}return dd=n,dd}var fd,hx;function Yl(){if(hx)return fd;hx=1;var e=W3(),n=G3(),i=Y3(),s=K3(),o=X3();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,fd=l,fd}var hd,px;function Q3(){if(px)return hd;px=1;var e=Yl();function n(){this.__data__=new e,this.size=0}return hd=n,hd}var pd,mx;function Z3(){if(mx)return pd;mx=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return pd=e,pd}var md,gx;function J3(){if(gx)return md;gx=1;function e(n){return this.__data__.get(n)}return md=e,md}var gd,vx;function eO(){if(vx)return gd;vx=1;function e(n){return this.__data__.has(n)}return gd=e,gd}var vd,yx;function gN(){if(yx)return vd;yx=1;var e=typeof al=="object"&&al&&al.Object===Object&&al;return vd=e,vd}var yd,wx;function Qn(){if(wx)return yd;wx=1;var e=gN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return yd=i,yd}var wd,xx;function Ws(){if(xx)return wd;xx=1;var e=Qn(),n=e.Symbol;return wd=n,wd}var xd,_x;function tO(){if(_x)return xd;_x=1;var e=Ws(),n=Object.prototype,i=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=i.call(u,o),f=u[o];try{u[o]=void 0;var h=!0}catch{}var p=s.call(u);return h&&(c?u[o]=f:delete u[o]),p}return xd=l,xd}var _d,Sx;function nO(){if(Sx)return _d;Sx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return _d=i,_d}var Sd,bx;function Gi(){if(bx)return Sd;bx=1;var e=Ws(),n=tO(),i=nO(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):i(c)}return Sd=u,Sd}var bd,kx;function Pn(){if(kx)return bd;kx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return bd=e,bd}var kd,Ex;function ra(){if(Ex)return kd;Ex=1;var e=Gi(),n=Pn(),i="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var f=e(c);return f==s||f==o||f==i||f==l}return kd=u,kd}var Ed,Nx;function rO(){if(Nx)return Ed;Nx=1;var e=Qn(),n=e["__core-js_shared__"];return Ed=n,Ed}var Nd,Cx;function iO(){if(Cx)return Nd;Cx=1;var e=rO(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function i(s){return!!n&&n in s}return Nd=i,Nd}var Cd,jx;function vN(){if(jx)return Cd;jx=1;var e=Function.prototype,n=e.toString;function i(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Cd=i,Cd}var jd,Rx;function sO(){if(Rx)return jd;Rx=1;var e=ra(),n=iO(),i=Pn(),s=vN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,f=u.toString,h=c.hasOwnProperty,p=RegExp("^"+f.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!i(y)||n(y))return!1;var w=e(y)?p:l;return w.test(s(y))}return jd=m,jd}var Rd,Tx;function oO(){if(Tx)return Rd;Tx=1;function e(n,i){return n==null?void 0:n[i]}return Rd=e,Rd}var Td,Ax;function Yi(){if(Ax)return Td;Ax=1;var e=sO(),n=oO();function i(s,o){var l=n(s,o);return e(l)?l:void 0}return Td=i,Td}var Ad,Ix;function pv(){if(Ix)return Ad;Ix=1;var e=Yi(),n=Qn(),i=e(n,"Map");return Ad=i,Ad}var Id,Mx;function Kl(){if(Mx)return Id;Mx=1;var e=Yi(),n=e(Object,"create");return Id=n,Id}var Md,Px;function aO(){if(Px)return Md;Px=1;var e=Kl();function n(){this.__data__=e?e(null):{},this.size=0}return Md=n,Md}var Pd,Ox;function lO(){if(Ox)return Pd;Ox=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return Pd=e,Pd}var Od,qx;function uO(){if(qx)return Od;qx=1;var e=Kl(),n="__lodash_hash_undefined__",i=Object.prototype,s=i.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return Od=o,Od}var qd,Lx;function cO(){if(Lx)return qd;Lx=1;var e=Kl(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:i.call(l,o)}return qd=s,qd}var Ld,$x;function dO(){if($x)return Ld;$x=1;var e=Kl(),n="__lodash_hash_undefined__";function i(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Ld=i,Ld}var $d,Dx;function fO(){if(Dx)return $d;Dx=1;var e=aO(),n=lO(),i=uO(),s=cO(),o=dO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,$d=l,$d}var Dd,Fx;function hO(){if(Fx)return Dd;Fx=1;var e=fO(),n=Yl(),i=pv();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return Dd=s,Dd}var Fd,zx;function pO(){if(zx)return Fd;zx=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Fd=e,Fd}var zd,Bx;function Xl(){if(Bx)return zd;Bx=1;var e=pO();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return zd=n,zd}var Bd,Ux;function mO(){if(Ux)return Bd;Ux=1;var e=Xl();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return Bd=n,Bd}var Ud,Hx;function gO(){if(Hx)return Ud;Hx=1;var e=Xl();function n(i){return e(this,i).get(i)}return Ud=n,Ud}var Hd,Vx;function vO(){if(Vx)return Hd;Vx=1;var e=Xl();function n(i){return e(this,i).has(i)}return Hd=n,Hd}var Vd,Wx;function yO(){if(Wx)return Vd;Wx=1;var e=Xl();function n(i,s){var o=e(this,i),l=o.size;return o.set(i,s),this.size+=o.size==l?0:1,this}return Vd=n,Vd}var Wd,Gx;function mv(){if(Gx)return Wd;Gx=1;var e=hO(),n=mO(),i=gO(),s=vO(),o=yO();function l(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=i,l.prototype.has=s,l.prototype.set=o,Wd=l,Wd}var Gd,Yx;function wO(){if(Yx)return Gd;Yx=1;var e=Yl(),n=pv(),i=mv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var f=c.__data__;if(!n||f.length<s-1)return f.push([l,u]),this.size=++c.size,this;c=this.__data__=new i(f)}return c.set(l,u),this.size=c.size,this}return Gd=o,Gd}var Yd,Kx;function Ql(){if(Kx)return Yd;Kx=1;var e=Yl(),n=Q3(),i=Z3(),s=J3(),o=eO(),l=wO();function u(c){var f=this.__data__=new e(c);this.size=f.size}return u.prototype.clear=n,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,Yd=u,Yd}var Kd,Xx;function gv(){if(Xx)return Kd;Xx=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o&&i(n[s],s,n)!==!1;);return n}return Kd=e,Kd}var Xd,Qx;function yN(){if(Qx)return Xd;Qx=1;var e=Yi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Xd=n,Xd}var Qd,Zx;function Zl(){if(Zx)return Qd;Zx=1;var e=yN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Qd=n,Qd}var Zd,Jx;function Jl(){if(Jx)return Zd;Jx=1;var e=Zl(),n=Vs(),i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c){var f=l[u];(!(s.call(l,u)&&n(f,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Zd=o,Zd}var Jd,e_;function ia(){if(e_)return Jd;e_=1;var e=Jl(),n=Zl();function i(s,o,l,u){var c=!l;l||(l={});for(var f=-1,h=o.length;++f<h;){var p=o[f],m=u?u(l[p],s[p],p,l,s):void 0;m===void 0&&(m=s[p]),c?n(l,p,m):e(l,p,m)}return l}return Jd=i,Jd}var ef,t_;function xO(){if(t_)return ef;t_=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return ef=e,ef}var tf,n_;function ur(){if(n_)return tf;n_=1;function e(n){return n!=null&&typeof n=="object"}return tf=e,tf}var nf,r_;function _O(){if(r_)return nf;r_=1;var e=Gi(),n=ur(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return nf=s,nf}var rf,i_;function sa(){if(i_)return rf;i_=1;var e=_O(),n=ur(),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return rf=l,rf}var sf,s_;function Et(){if(s_)return sf;s_=1;var e=Array.isArray;return sf=e,sf}var Do={exports:{}},of,o_;function SO(){if(o_)return of;o_=1;function e(){return!1}return of=e,of}Do.exports;var a_;function Gs(){return a_||(a_=1,(function(e,n){var i=Qn(),s=SO(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?i.Buffer:void 0,f=c?c.isBuffer:void 0,h=f||s;e.exports=h})(Do,Do.exports)),Do.exports}var af,l_;function eu(){if(l_)return af;l_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function i(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return af=i,af}var lf,u_;function vv(){if(u_)return lf;u_=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return lf=n,lf}var uf,c_;function bO(){if(c_)return uf;c_=1;var e=Gi(),n=vv(),i=ur(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",h="[object Map]",p="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",j="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",E="[object Float32Array]",N="[object Float64Array]",C="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",P="[object Uint8Array]",z="[object Uint8ClampedArray]",T="[object Uint16Array]",q="[object Uint32Array]",B={};B[E]=B[N]=B[C]=B[I]=B[O]=B[P]=B[z]=B[T]=B[q]=!0,B[s]=B[o]=B[S]=B[l]=B[b]=B[u]=B[c]=B[f]=B[h]=B[p]=B[m]=B[y]=B[w]=B[j]=B[_]=!1;function J(Q){return i(Q)&&n(Q.length)&&!!B[e(Q)]}return uf=J,uf}var cf,d_;function tu(){if(d_)return cf;d_=1;function e(n){return function(i){return n(i)}}return cf=e,cf}var Fo={exports:{}};Fo.exports;var f_;function yv(){return f_||(f_=1,(function(e,n){var i=gN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&i.process,c=(function(){try{var f=o&&o.require&&o.require("util").types;return f||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(Fo,Fo.exports)),Fo.exports}var df,h_;function oa(){if(h_)return df;h_=1;var e=bO(),n=tu(),i=yv(),s=i&&i.isTypedArray,o=s?n(s):e;return df=o,df}var ff,p_;function wN(){if(p_)return ff;p_=1;var e=xO(),n=sa(),i=Et(),s=Gs(),o=eu(),l=oa(),u=Object.prototype,c=u.hasOwnProperty;function f(h,p){var m=i(h),y=!m&&n(h),w=!m&&!y&&s(h),j=!m&&!y&&!w&&l(h),_=m||y||w||j,S=_?e(h.length,String):[],b=S.length;for(var E in h)(p||c.call(h,E))&&!(_&&(E=="length"||w&&(E=="offset"||E=="parent")||j&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||o(E,b)))&&S.push(E);return S}return ff=f,ff}var hf,m_;function nu(){if(m_)return hf;m_=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return hf=n,hf}var pf,g_;function xN(){if(g_)return pf;g_=1;function e(n,i){return function(s){return n(i(s))}}return pf=e,pf}var mf,v_;function kO(){if(v_)return mf;v_=1;var e=xN(),n=e(Object.keys,Object);return mf=n,mf}var gf,y_;function wv(){if(y_)return gf;y_=1;var e=nu(),n=kO(),i=Object.prototype,s=i.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return gf=o,gf}var vf,w_;function Ar(){if(w_)return vf;w_=1;var e=ra(),n=vv();function i(s){return s!=null&&n(s.length)&&!e(s)}return vf=i,vf}var yf,x_;function ai(){if(x_)return yf;x_=1;var e=wN(),n=wv(),i=Ar();function s(o){return i(o)?e(o):n(o)}return yf=s,yf}var wf,__;function EO(){if(__)return wf;__=1;var e=ia(),n=ai();function i(s,o){return s&&e(o,n(o),s)}return wf=i,wf}var xf,S_;function NO(){if(S_)return xf;S_=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return xf=e,xf}var _f,b_;function CO(){if(b_)return _f;b_=1;var e=Pn(),n=nu(),i=NO(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return i(u);var c=n(u),f=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||f.push(h);return f}return _f=l,_f}var Sf,k_;function Ki(){if(k_)return Sf;k_=1;var e=wN(),n=CO(),i=Ar();function s(o){return i(o)?e(o,!0):n(o)}return Sf=s,Sf}var bf,E_;function jO(){if(E_)return bf;E_=1;var e=ia(),n=Ki();function i(s,o){return s&&e(o,n(o),s)}return bf=i,bf}var zo={exports:{}};zo.exports;var N_;function _N(){return N_||(N_=1,(function(e,n){var i=Qn(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?i.Buffer:void 0,c=u?u.allocUnsafe:void 0;function f(h,p){if(p)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=f})(zo,zo.exports)),zo.exports}var kf,C_;function SN(){if(C_)return kf;C_=1;function e(n,i){var s=-1,o=n.length;for(i||(i=Array(o));++s<o;)i[s]=n[s];return i}return kf=e,kf}var Ef,j_;function bN(){if(j_)return Ef;j_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];i(c,s,n)&&(u[l++]=c)}return u}return Ef=e,Ef}var Nf,R_;function kN(){if(R_)return Nf;R_=1;function e(){return[]}return Nf=e,Nf}var Cf,T_;function xv(){if(T_)return Cf;T_=1;var e=bN(),n=kN(),i=Object.prototype,s=i.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Cf=l,Cf}var jf,A_;function RO(){if(A_)return jf;A_=1;var e=ia(),n=xv();function i(s,o){return e(s,n(s),o)}return jf=i,jf}var Rf,I_;function _v(){if(I_)return Rf;I_=1;function e(n,i){for(var s=-1,o=i.length,l=n.length;++s<o;)n[l+s]=i[s];return n}return Rf=e,Rf}var Tf,M_;function ru(){if(M_)return Tf;M_=1;var e=xN(),n=e(Object.getPrototypeOf,Object);return Tf=n,Tf}var Af,P_;function EN(){if(P_)return Af;P_=1;var e=_v(),n=ru(),i=xv(),s=kN(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,i(u)),u=n(u);return c}:s;return Af=l,Af}var If,O_;function TO(){if(O_)return If;O_=1;var e=ia(),n=EN();function i(s,o){return e(s,n(s),o)}return If=i,If}var Mf,q_;function NN(){if(q_)return Mf;q_=1;var e=_v(),n=Et();function i(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return Mf=i,Mf}var Pf,L_;function CN(){if(L_)return Pf;L_=1;var e=NN(),n=xv(),i=ai();function s(o){return e(o,i,n)}return Pf=s,Pf}var Of,$_;function AO(){if($_)return Of;$_=1;var e=NN(),n=EN(),i=Ki();function s(o){return e(o,i,n)}return Of=s,Of}var qf,D_;function IO(){if(D_)return qf;D_=1;var e=Yi(),n=Qn(),i=e(n,"DataView");return qf=i,qf}var Lf,F_;function MO(){if(F_)return Lf;F_=1;var e=Yi(),n=Qn(),i=e(n,"Promise");return Lf=i,Lf}var $f,z_;function jN(){if(z_)return $f;z_=1;var e=Yi(),n=Qn(),i=e(n,"Set");return $f=i,$f}var Df,B_;function PO(){if(B_)return Df;B_=1;var e=Yi(),n=Qn(),i=e(n,"WeakMap");return Df=i,Df}var Ff,U_;function Ys(){if(U_)return Ff;U_=1;var e=IO(),n=pv(),i=MO(),s=jN(),o=PO(),l=Gi(),u=vN(),c="[object Map]",f="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",w=u(e),j=u(n),_=u(i),S=u(s),b=u(o),E=l;return(e&&E(new e(new ArrayBuffer(1)))!=y||n&&E(new n)!=c||i&&E(i.resolve())!=h||s&&E(new s)!=p||o&&E(new o)!=m)&&(E=function(N){var C=l(N),I=C==f?N.constructor:void 0,O=I?u(I):"";if(O)switch(O){case w:return y;case j:return c;case _:return h;case S:return p;case b:return m}return C}),Ff=E,Ff}var zf,H_;function OO(){if(H_)return zf;H_=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return zf=i,zf}var Bf,V_;function RN(){if(V_)return Bf;V_=1;var e=Qn(),n=e.Uint8Array;return Bf=n,Bf}var Uf,W_;function Sv(){if(W_)return Uf;W_=1;var e=RN();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return Uf=n,Uf}var Hf,G_;function qO(){if(G_)return Hf;G_=1;var e=Sv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Hf=n,Hf}var Vf,Y_;function LO(){if(Y_)return Vf;Y_=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return Vf=n,Vf}var Wf,K_;function $O(){if(K_)return Wf;K_=1;var e=Ws(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Wf=s,Wf}var Gf,X_;function TN(){if(X_)return Gf;X_=1;var e=Sv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Gf=n,Gf}var Yf,Q_;function DO(){if(Q_)return Yf;Q_=1;var e=Sv(),n=qO(),i=LO(),s=$O(),o=TN(),l="[object Boolean]",u="[object Date]",c="[object Map]",f="[object Number]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",j="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",C="[object Uint8Array]",I="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]";function z(T,q,B){var J=T.constructor;switch(q){case w:return e(T);case l:case u:return new J(+T);case j:return n(T,B);case _:case S:case b:case E:case N:case C:case I:case O:case P:return o(T,B);case c:return new J;case f:case m:return new J(T);case h:return i(T);case p:return new J;case y:return s(T)}}return Yf=z,Yf}var Kf,Z_;function AN(){if(Z_)return Kf;Z_=1;var e=Pn(),n=Object.create,i=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return Kf=i,Kf}var Xf,J_;function IN(){if(J_)return Xf;J_=1;var e=AN(),n=ru(),i=nu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Xf=s,Xf}var Qf,e1;function FO(){if(e1)return Qf;e1=1;var e=Ys(),n=ur(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Qf=s,Qf}var Zf,t1;function zO(){if(t1)return Zf;t1=1;var e=FO(),n=tu(),i=yv(),s=i&&i.isMap,o=s?n(s):e;return Zf=o,Zf}var Jf,n1;function BO(){if(n1)return Jf;n1=1;var e=Ys(),n=ur(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Jf=s,Jf}var eh,r1;function UO(){if(r1)return eh;r1=1;var e=BO(),n=tu(),i=yv(),s=i&&i.isSet,o=s?n(s):e;return eh=o,eh}var th,i1;function MN(){if(i1)return th;i1=1;var e=Ql(),n=gv(),i=Jl(),s=EO(),o=jO(),l=_N(),u=SN(),c=RO(),f=TO(),h=CN(),p=AO(),m=Ys(),y=OO(),w=DO(),j=IN(),_=Et(),S=Gs(),b=zO(),E=Pn(),N=UO(),C=ai(),I=Ki(),O=1,P=2,z=4,T="[object Arguments]",q="[object Array]",B="[object Boolean]",J="[object Date]",Q="[object Error]",A="[object Function]",H="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",Y="[object Object]",L="[object RegExp]",G="[object Set]",k="[object String]",$="[object Symbol]",oe="[object WeakMap]",D="[object ArrayBuffer]",X="[object DataView]",ee="[object Float32Array]",se="[object Float64Array]",ae="[object Int8Array]",pe="[object Int16Array]",ge="[object Int32Array]",Ae="[object Uint8Array]",Pe="[object Uint8ClampedArray]",Ie="[object Uint16Array]",Me="[object Uint32Array]",ke={};ke[T]=ke[q]=ke[D]=ke[X]=ke[B]=ke[J]=ke[ee]=ke[se]=ke[ae]=ke[pe]=ke[ge]=ke[U]=ke[ne]=ke[Y]=ke[L]=ke[G]=ke[k]=ke[$]=ke[Ae]=ke[Pe]=ke[Ie]=ke[Me]=!0,ke[Q]=ke[A]=ke[oe]=!1;function He(ve,ye,Ve,mt,Je,We){var $e,Qe=ye&O,xt=ye&P,et=ye&z;if(Ve&&($e=Je?Ve(ve,mt,Je,We):Ve(ve)),$e!==void 0)return $e;if(!E(ve))return ve;var Ge=_(ve);if(Ge){if($e=y(ve),!Qe)return u(ve,$e)}else{var _t=m(ve),It=_t==A||_t==H;if(S(ve))return l(ve,Qe);if(_t==Y||_t==T||It&&!Je){if($e=xt||It?{}:j(ve),!Qe)return xt?f(ve,o($e,ve)):c(ve,s($e,ve))}else{if(!ke[_t])return Je?ve:{};$e=w(ve,_t,Qe)}}We||(We=new e);var Bt=We.get(ve);if(Bt)return Bt;We.set(ve,$e),N(ve)?ve.forEach(function(ut){$e.add(He(ut,ye,Ve,ut,ve,We))}):b(ve)&&ve.forEach(function(ut,St){$e.set(St,He(ut,ye,Ve,St,ve,We))});var tt=et?xt?p:h:xt?I:C,gt=Ge?void 0:tt(ve);return n(gt||ve,function(ut,St){gt&&(St=ut,ut=ve[St]),i($e,St,He(ut,ye,Ve,St,ve,We))}),$e}return th=He,th}var nh,s1;function HO(){if(s1)return nh;s1=1;var e=MN(),n=4;function i(s){return e(s,n)}return nh=i,nh}var rh,o1;function bv(){if(o1)return rh;o1=1;function e(n){return function(){return n}}return rh=e,rh}var ih,a1;function VO(){if(a1)return ih;a1=1;function e(n){return function(i,s,o){for(var l=-1,u=Object(i),c=o(i),f=c.length;f--;){var h=c[n?f:++l];if(s(u[h],h,u)===!1)break}return i}}return ih=e,ih}var sh,l1;function kv(){if(l1)return sh;l1=1;var e=VO(),n=e();return sh=n,sh}var oh,u1;function Ev(){if(u1)return oh;u1=1;var e=kv(),n=ai();function i(s,o){return s&&e(s,o,n)}return oh=i,oh}var ah,c1;function WO(){if(c1)return ah;c1=1;var e=Ar();function n(i,s){return function(o,l){if(o==null)return o;if(!e(o))return i(o,l);for(var u=o.length,c=s?u:-1,f=Object(o);(s?c--:++c<u)&&l(f[c],c,f)!==!1;);return o}}return ah=n,ah}var lh,d1;function iu(){if(d1)return lh;d1=1;var e=Ev(),n=WO(),i=n(e);return lh=i,lh}var uh,f1;function Xi(){if(f1)return uh;f1=1;function e(n){return n}return uh=e,uh}var ch,h1;function PN(){if(h1)return ch;h1=1;var e=Xi();function n(i){return typeof i=="function"?i:e}return ch=n,ch}var dh,p1;function ON(){if(p1)return dh;p1=1;var e=gv(),n=iu(),i=PN(),s=Et();function o(l,u){var c=s(l)?e:n;return c(l,i(u))}return dh=o,dh}var fh,m1;function qN(){return m1||(m1=1,fh=ON()),fh}var hh,g1;function GO(){if(g1)return hh;g1=1;var e=iu();function n(i,s){var o=[];return e(i,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return hh=n,hh}var ph,v1;function YO(){if(v1)return ph;v1=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return ph=n,ph}var mh,y1;function KO(){if(y1)return mh;y1=1;function e(n){return this.__data__.has(n)}return mh=e,mh}var gh,w1;function LN(){if(w1)return gh;w1=1;var e=mv(),n=YO(),i=KO();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=i,gh=s,gh}var vh,x1;function XO(){if(x1)return vh;x1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length;++s<o;)if(i(n[s],s,n))return!0;return!1}return vh=e,vh}var yh,_1;function $N(){if(_1)return yh;_1=1;function e(n,i){return n.has(i)}return yh=e,yh}var wh,S1;function DN(){if(S1)return wh;S1=1;var e=LN(),n=XO(),i=$N(),s=1,o=2;function l(u,c,f,h,p,m){var y=f&s,w=u.length,j=c.length;if(w!=j&&!(y&&j>w))return!1;var _=m.get(u),S=m.get(c);if(_&&S)return _==c&&S==u;var b=-1,E=!0,N=f&o?new e:void 0;for(m.set(u,c),m.set(c,u);++b<w;){var C=u[b],I=c[b];if(h)var O=y?h(I,C,b,c,u,m):h(C,I,b,u,c,m);if(O!==void 0){if(O)continue;E=!1;break}if(N){if(!n(c,function(P,z){if(!i(N,z)&&(C===P||p(C,P,f,h,m)))return N.push(z)})){E=!1;break}}else if(!(C===I||p(C,I,f,h,m))){E=!1;break}}return m.delete(u),m.delete(c),E}return wh=l,wh}var xh,b1;function QO(){if(b1)return xh;b1=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,l){s[++i]=[l,o]}),s}return xh=e,xh}var _h,k1;function Nv(){if(k1)return _h;k1=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return _h=e,_h}var Sh,E1;function ZO(){if(E1)return Sh;E1=1;var e=Ws(),n=RN(),i=Vs(),s=DN(),o=QO(),l=Nv(),u=1,c=2,f="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",j="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",E="[object DataView]",N=e?e.prototype:void 0,C=N?N.valueOf:void 0;function I(O,P,z,T,q,B,J){switch(z){case E:if(O.byteLength!=P.byteLength||O.byteOffset!=P.byteOffset)return!1;O=O.buffer,P=P.buffer;case b:return!(O.byteLength!=P.byteLength||!B(new n(O),new n(P)));case f:case h:case y:return i(+O,+P);case p:return O.name==P.name&&O.message==P.message;case w:case _:return O==P+"";case m:var Q=o;case j:var A=T&u;if(Q||(Q=l),O.size!=P.size&&!A)return!1;var H=J.get(O);if(H)return H==P;T|=c,J.set(O,P);var U=s(Q(O),Q(P),T,q,B,J);return J.delete(O),U;case S:if(C)return C.call(O)==C.call(P)}return!1}return Sh=I,Sh}var bh,N1;function JO(){if(N1)return bh;N1=1;var e=CN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(l,u,c,f,h,p){var m=c&n,y=e(l),w=y.length,j=e(u),_=j.length;if(w!=_&&!m)return!1;for(var S=w;S--;){var b=y[S];if(!(m?b in u:s.call(u,b)))return!1}var E=p.get(l),N=p.get(u);if(E&&N)return E==u&&N==l;var C=!0;p.set(l,u),p.set(u,l);for(var I=m;++S<w;){b=y[S];var O=l[b],P=u[b];if(f)var z=m?f(P,O,b,u,l,p):f(O,P,b,l,u,p);if(!(z===void 0?O===P||h(O,P,c,f,p):z)){C=!1;break}I||(I=b=="constructor")}if(C&&!I){var T=l.constructor,q=u.constructor;T!=q&&"constructor"in l&&"constructor"in u&&!(typeof T=="function"&&T instanceof T&&typeof q=="function"&&q instanceof q)&&(C=!1)}return p.delete(l),p.delete(u),C}return bh=o,bh}var kh,C1;function eq(){if(C1)return kh;C1=1;var e=Ql(),n=DN(),i=ZO(),s=JO(),o=Ys(),l=Et(),u=Gs(),c=oa(),f=1,h="[object Arguments]",p="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function j(_,S,b,E,N,C){var I=l(_),O=l(S),P=I?p:o(_),z=O?p:o(S);P=P==h?m:P,z=z==h?m:z;var T=P==m,q=z==m,B=P==z;if(B&&u(_)){if(!u(S))return!1;I=!0,T=!1}if(B&&!T)return C||(C=new e),I||c(_)?n(_,S,b,E,N,C):i(_,S,P,b,E,N,C);if(!(b&f)){var J=T&&w.call(_,"__wrapped__"),Q=q&&w.call(S,"__wrapped__");if(J||Q){var A=J?_.value():_,H=Q?S.value():S;return C||(C=new e),N(A,H,b,E,C)}}return B?(C||(C=new e),s(_,S,b,E,N,C)):!1}return kh=j,kh}var Eh,j1;function FN(){if(j1)return Eh;j1=1;var e=eq(),n=ur();function i(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,i,c)}return Eh=i,Eh}var Nh,R1;function tq(){if(R1)return Nh;R1=1;var e=Ql(),n=FN(),i=1,s=2;function o(l,u,c,f){var h=c.length,p=h,m=!f;if(l==null)return!p;for(l=Object(l);h--;){var y=c[h];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++h<p;){y=c[h];var w=y[0],j=l[w],_=y[1];if(m&&y[2]){if(j===void 0&&!(w in l))return!1}else{var S=new e;if(f)var b=f(j,_,w,l,u,S);if(!(b===void 0?n(_,j,i|s,f,S):b))return!1}}return!0}return Nh=o,Nh}var Ch,T1;function zN(){if(T1)return Ch;T1=1;var e=Pn();function n(i){return i===i&&!e(i)}return Ch=n,Ch}var jh,A1;function nq(){if(A1)return jh;A1=1;var e=zN(),n=ai();function i(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return jh=i,jh}var Rh,I1;function BN(){if(I1)return Rh;I1=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return Rh=e,Rh}var Th,M1;function rq(){if(M1)return Th;M1=1;var e=tq(),n=nq(),i=BN();function s(o){var l=n(o);return l.length==1&&l[0][2]?i(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Th=s,Th}var Ah,P1;function Ks(){if(P1)return Ah;P1=1;var e=Gi(),n=ur(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return Ah=s,Ah}var Ih,O1;function Cv(){if(O1)return Ih;O1=1;var e=Et(),n=Ks(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:s.test(l)||!i.test(l)||u!=null&&l in Object(u)}return Ih=o,Ih}var Mh,q1;function iq(){if(q1)return Mh;q1=1;var e=mv(),n="Expected a function";function i(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],f=l.cache;if(f.has(c))return f.get(c);var h=s.apply(this,u);return l.cache=f.set(c,h)||f,h};return l.cache=new(i.Cache||e),l}return i.Cache=e,Mh=i,Mh}var Ph,L1;function sq(){if(L1)return Ph;L1=1;var e=iq(),n=500;function i(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Ph=i,Ph}var Oh,$1;function oq(){if($1)return Oh;$1=1;var e=sq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,f,h){l.push(f?h.replace(i,"$1"):c||u)}),l});return Oh=s,Oh}var qh,D1;function su(){if(D1)return qh;D1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=i(n[s],s,n);return l}return qh=e,qh}var Lh,F1;function aq(){if(F1)return Lh;F1=1;var e=Ws(),n=su(),i=Et(),s=Ks(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(i(c))return n(c,u)+"";if(s(c))return l?l.call(c):"";var f=c+"";return f=="0"&&1/c==-1/0?"-0":f}return Lh=u,Lh}var $h,z1;function UN(){if(z1)return $h;z1=1;var e=aq();function n(i){return i==null?"":e(i)}return $h=n,$h}var Dh,B1;function ou(){if(B1)return Dh;B1=1;var e=Et(),n=Cv(),i=oq(),s=UN();function o(l,u){return e(l)?l:n(l,u)?[l]:i(s(l))}return Dh=o,Dh}var Fh,U1;function aa(){if(U1)return Fh;U1=1;var e=Ks();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Fh=n,Fh}var zh,H1;function au(){if(H1)return zh;H1=1;var e=ou(),n=aa();function i(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return zh=i,zh}var Bh,V1;function lq(){if(V1)return Bh;V1=1;var e=au();function n(i,s,o){var l=i==null?void 0:e(i,s);return l===void 0?o:l}return Bh=n,Bh}var Uh,W1;function uq(){if(W1)return Uh;W1=1;function e(n,i){return n!=null&&i in Object(n)}return Uh=e,Uh}var Hh,G1;function HN(){if(G1)return Hh;G1=1;var e=ou(),n=sa(),i=Et(),s=eu(),o=vv(),l=aa();function u(c,f,h){f=e(f,c);for(var p=-1,m=f.length,y=!1;++p<m;){var w=l(f[p]);if(!(y=c!=null&&h(c,w)))break;c=c[w]}return y||++p!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(w,m)&&(i(c)||n(c)))}return Hh=u,Hh}var Vh,Y1;function VN(){if(Y1)return Vh;Y1=1;var e=uq(),n=HN();function i(s,o){return s!=null&&n(s,o,e)}return Vh=i,Vh}var Wh,K1;function cq(){if(K1)return Wh;K1=1;var e=FN(),n=lq(),i=VN(),s=Cv(),o=zN(),l=BN(),u=aa(),c=1,f=2;function h(p,m){return s(p)&&o(m)?l(u(p),m):function(y){var w=n(y,p);return w===void 0&&w===m?i(y,p):e(m,w,c|f)}}return Wh=h,Wh}var Gh,X1;function WN(){if(X1)return Gh;X1=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Gh=e,Gh}var Yh,Q1;function dq(){if(Q1)return Yh;Q1=1;var e=au();function n(i){return function(s){return e(s,i)}}return Yh=n,Yh}var Kh,Z1;function fq(){if(Z1)return Kh;Z1=1;var e=WN(),n=dq(),i=Cv(),s=aa();function o(l){return i(l)?e(s(l)):n(l)}return Kh=o,Kh}var Xh,J1;function Ir(){if(J1)return Xh;J1=1;var e=rq(),n=cq(),i=Xi(),s=Et(),o=fq();function l(u){return typeof u=="function"?u:u==null?i:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return Xh=l,Xh}var Qh,eS;function GN(){if(eS)return Qh;eS=1;var e=bN(),n=GO(),i=Ir(),s=Et();function o(l,u){var c=s(l)?e:n;return c(l,i(u,3))}return Qh=o,Qh}var Zh,tS;function hq(){if(tS)return Zh;tS=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return Zh=i,Zh}var Jh,nS;function YN(){if(nS)return Jh;nS=1;var e=hq(),n=HN();function i(s,o){return s!=null&&n(s,o,e)}return Jh=i,Jh}var ep,rS;function pq(){if(rS)return ep;rS=1;var e=wv(),n=Ys(),i=sa(),s=Et(),o=Ar(),l=Gs(),u=nu(),c=oa(),f="[object Map]",h="[object Set]",p=Object.prototype,m=p.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||i(w)))return!w.length;var j=n(w);if(j==f||j==h)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(m.call(w,_))return!1;return!0}return ep=y,ep}var tp,iS;function KN(){if(iS)return tp;iS=1;function e(n){return n===void 0}return tp=e,tp}var np,sS;function XN(){if(sS)return np;sS=1;var e=iu(),n=Ar();function i(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,f,h){u[++l]=o(c,f,h)}),u}return np=i,np}var rp,oS;function QN(){if(oS)return rp;oS=1;var e=su(),n=Ir(),i=XN(),s=Et();function o(l,u){var c=s(l)?e:i;return c(l,n(u,3))}return rp=o,rp}var ip,aS;function mq(){if(aS)return ip;aS=1;function e(n,i,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=i(s,n[l],l,n);return s}return ip=e,ip}var sp,lS;function gq(){if(lS)return sp;lS=1;function e(n,i,s,o,l){return l(n,function(u,c,f){s=o?(o=!1,u):i(s,u,c,f)}),s}return sp=e,sp}var op,uS;function ZN(){if(uS)return op;uS=1;var e=mq(),n=iu(),i=Ir(),s=gq(),o=Et();function l(u,c,f){var h=o(u)?e:s,p=arguments.length<3;return h(u,i(c,4),f,p,n)}return op=l,op}var ap,cS;function vq(){if(cS)return ap;cS=1;var e=Gi(),n=Et(),i=ur(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&i(l)&&e(l)==s}return ap=o,ap}var lp,dS;function yq(){if(dS)return lp;dS=1;var e=WN(),n=e("length");return lp=n,lp}var up,fS;function wq(){if(fS)return up;fS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function f(h){return c.test(h)}return up=f,up}var cp,hS;function xq(){if(hS)return cp;hS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",f="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+f+")",p="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",j=h+"?",_="["+l+"]?",S="(?:"+w+"(?:"+[p,m,y].join("|")+")"+_+j+")*",b=_+j+S,E="(?:"+[p+c+"?",c,m,y,u].join("|")+")",N=RegExp(f+"(?="+f+")|"+E+b,"g");function C(I){for(var O=N.lastIndex=0;N.test(I);)++O;return O}return cp=C,cp}var dp,pS;function _q(){if(pS)return dp;pS=1;var e=yq(),n=wq(),i=xq();function s(o){return n(o)?i(o):e(o)}return dp=s,dp}var fp,mS;function Sq(){if(mS)return fp;mS=1;var e=wv(),n=Ys(),i=Ar(),s=vq(),o=_q(),l="[object Map]",u="[object Set]";function c(f){if(f==null)return 0;if(i(f))return s(f)?o(f):f.length;var h=n(f);return h==l||h==u?f.size:e(f).length}return fp=c,fp}var hp,gS;function bq(){if(gS)return hp;gS=1;var e=gv(),n=AN(),i=Ev(),s=Ir(),o=ru(),l=Et(),u=Gs(),c=ra(),f=Pn(),h=oa();function p(m,y,w){var j=l(m),_=j||u(m)||h(m);if(y=s(y,4),w==null){var S=m&&m.constructor;_?w=j?new S:[]:f(m)?w=c(S)?n(o(m)):{}:w={}}return(_?e:i)(m,function(b,E,N){return y(w,b,E,N)}),w}return hp=p,hp}var pp,vS;function kq(){if(vS)return pp;vS=1;var e=Ws(),n=sa(),i=Et(),s=e?e.isConcatSpreadable:void 0;function o(l){return i(l)||n(l)||!!(s&&l&&l[s])}return pp=o,pp}var mp,yS;function jv(){if(yS)return mp;yS=1;var e=_v(),n=kq();function i(s,o,l,u,c){var f=-1,h=s.length;for(l||(l=n),c||(c=[]);++f<h;){var p=s[f];o>0&&l(p)?o>1?i(p,o-1,l,u,c):e(c,p):u||(c[c.length]=p)}return c}return mp=i,mp}var gp,wS;function Eq(){if(wS)return gp;wS=1;function e(n,i,s){switch(s.length){case 0:return n.call(i);case 1:return n.call(i,s[0]);case 2:return n.call(i,s[0],s[1]);case 3:return n.call(i,s[0],s[1],s[2])}return n.apply(i,s)}return gp=e,gp}var vp,xS;function JN(){if(xS)return vp;xS=1;var e=Eq(),n=Math.max;function i(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,f=n(u.length-o,0),h=Array(f);++c<f;)h[c]=u[o+c];c=-1;for(var p=Array(o+1);++c<o;)p[c]=u[c];return p[o]=l(h),e(s,this,p)}}return vp=i,vp}var yp,_S;function Nq(){if(_S)return yp;_S=1;var e=bv(),n=yN(),i=Xi(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:i;return yp=s,yp}var wp,SS;function Cq(){if(SS)return wp;SS=1;var e=800,n=16,i=Date.now;function s(o){var l=0,u=0;return function(){var c=i(),f=n-(c-u);if(u=c,f>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return wp=s,wp}var xp,bS;function eC(){if(bS)return xp;bS=1;var e=Nq(),n=Cq(),i=n(e);return xp=i,xp}var _p,kS;function lu(){if(kS)return _p;kS=1;var e=Xi(),n=JN(),i=eC();function s(o,l){return i(n(o,l,e),o+"")}return _p=s,_p}var Sp,ES;function tC(){if(ES)return Sp;ES=1;function e(n,i,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(i(n[u],u,n))return u;return-1}return Sp=e,Sp}var bp,NS;function jq(){if(NS)return bp;NS=1;function e(n){return n!==n}return bp=e,bp}var kp,CS;function Rq(){if(CS)return kp;CS=1;function e(n,i,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===i)return o;return-1}return kp=e,kp}var Ep,jS;function Tq(){if(jS)return Ep;jS=1;var e=tC(),n=jq(),i=Rq();function s(o,l,u){return l===l?i(o,l,u):e(o,n,u)}return Ep=s,Ep}var Np,RS;function Aq(){if(RS)return Np;RS=1;var e=Tq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return Np=n,Np}var Cp,TS;function Iq(){if(TS)return Cp;TS=1;function e(n,i,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(i,n[o]))return!0;return!1}return Cp=e,Cp}var jp,AS;function Mq(){if(AS)return jp;AS=1;function e(){}return jp=e,jp}var Rp,IS;function Pq(){if(IS)return Rp;IS=1;var e=jN(),n=Mq(),i=Nv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Rp=o,Rp}var Tp,MS;function Oq(){if(MS)return Tp;MS=1;var e=LN(),n=Aq(),i=Iq(),s=$N(),o=Pq(),l=Nv(),u=200;function c(f,h,p){var m=-1,y=n,w=f.length,j=!0,_=[],S=_;if(p)j=!1,y=i;else if(w>=u){var b=h?null:o(f);if(b)return l(b);j=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<w;){var E=f[m],N=h?h(E):E;if(E=p||E!==0?E:0,j&&N===N){for(var C=S.length;C--;)if(S[C]===N)continue e;h&&S.push(N),_.push(E)}else y(S,N,p)||(S!==_&&S.push(N),_.push(E))}return _}return Tp=c,Tp}var Ap,PS;function nC(){if(PS)return Ap;PS=1;var e=Ar(),n=ur();function i(s){return n(s)&&e(s)}return Ap=i,Ap}var Ip,OS;function qq(){if(OS)return Ip;OS=1;var e=jv(),n=lu(),i=Oq(),s=nC(),o=n(function(l){return i(e(l,1,s,!0))});return Ip=o,Ip}var Mp,qS;function Lq(){if(qS)return Mp;qS=1;var e=su();function n(i,s){return e(s,function(o){return i[o]})}return Mp=n,Mp}var Pp,LS;function rC(){if(LS)return Pp;LS=1;var e=Lq(),n=ai();function i(s){return s==null?[]:e(s,n(s))}return Pp=i,Pp}var Op,$S;function On(){if($S)return Op;$S=1;var e;if(typeof hv=="function")try{e={clone:HO(),constant:bv(),each:qN(),filter:GN(),has:YN(),isArray:Et(),isEmpty:pq(),isFunction:ra(),isUndefined:KN(),keys:ai(),map:QN(),reduce:ZN(),size:Sq(),transform:bq(),union:qq(),values:rC()}}catch{}return e||(e=window._),Op=e,Op}var qp,DS;function Rv(){if(DS)return qp;DS=1;var e=On();qp=o;var n="\0",i="\0",s="";function o(p){this._isDirected=e.has(p,"directed")?p.directed:!0,this._isMultigraph=e.has(p,"multigraph")?p.multigraph:!1,this._isCompound=e.has(p,"compound")?p.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(p){return this._label=p,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultNodeLabelFn=p,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._in[m])})},o.prototype.sinks=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._out[m])})},o.prototype.setNodes=function(p,m){var y=arguments,w=this;return e.each(p,function(j){y.length>1?w.setNode(j,m):w.setNode(j)}),this},o.prototype.setNode=function(p,m){return e.has(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=m),this):(this._nodes[p]=arguments.length>1?m:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=i,this._children[p]={},this._children[i][p]=!0),this._in[p]={},this._preds[p]={},this._out[p]={},this._sucs[p]={},++this._nodeCount,this)},o.prototype.node=function(p){return this._nodes[p]},o.prototype.hasNode=function(p){return e.has(this._nodes,p)},o.prototype.removeNode=function(p){var m=this;if(e.has(this._nodes,p)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[p],this._isCompound&&(this._removeFromParentsChildList(p),delete this._parent[p],e.each(this.children(p),function(w){m.setParent(w)}),delete this._children[p]),e.each(e.keys(this._in[p]),y),delete this._in[p],delete this._preds[p],e.each(e.keys(this._out[p]),y),delete this._out[p],delete this._sucs[p],--this._nodeCount}return this},o.prototype.setParent=function(p,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=i;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===p)throw new Error("Setting "+m+" as parent of "+p+" would create a cycle");this.setNode(m)}return this.setNode(p),this._removeFromParentsChildList(p),this._parent[p]=m,this._children[m][p]=!0,this},o.prototype._removeFromParentsChildList=function(p){delete this._children[this._parent[p]][p]},o.prototype.parent=function(p){if(this._isCompound){var m=this._parent[p];if(m!==i)return m}},o.prototype.children=function(p){if(e.isUndefined(p)&&(p=i),this._isCompound){var m=this._children[p];if(m)return e.keys(m)}else{if(p===i)return this.nodes();if(this.hasNode(p))return[]}},o.prototype.predecessors=function(p){var m=this._preds[p];if(m)return e.keys(m)},o.prototype.successors=function(p){var m=this._sucs[p];if(m)return e.keys(m)},o.prototype.neighbors=function(p){var m=this.predecessors(p);if(m)return e.union(m,this.successors(p))},o.prototype.isLeaf=function(p){var m;return this.isDirected()?m=this.successors(p):m=this.neighbors(p),m.length===0},o.prototype.filterNodes=function(p){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){p(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var w={};function j(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(w[_]=S,S):S in w?w[S]:j(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,j(_))}),m},o.prototype.setDefaultEdgeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultEdgeLabelFn=p,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(p,m){var y=this,w=arguments;return e.reduce(p,function(j,_){return w.length>1?y.setEdge(j,_,m):y.setEdge(j,_),_}),this},o.prototype.setEdge=function(){var p,m,y,w,j=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(w=arguments[1],j=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],j=!0)),p=""+p,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,p,m,y);if(e.has(this._edgeLabels,S))return j&&(this._edgeLabels[S]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(p),this.setNode(m),this._edgeLabels[S]=j?w:this._defaultEdgeLabelFn(p,m,y);var b=f(this._isDirected,p,m,y);return p=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],p),l(this._sucs[p],m),this._in[m][S]=b,this._out[p][S]=b,this._edgeCount++,this},o.prototype.edge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(p,m,y){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y),j=this._edgeObjs[w];return j&&(p=j.v,m=j.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[m],p),u(this._sucs[p],m),delete this._in[m][w],delete this._out[p][w],this._edgeCount--),this},o.prototype.inEdges=function(p,m){var y=this._in[p];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.v===m}):w}},o.prototype.outEdges=function(p,m){var y=this._out[p];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.w===m}):w}},o.prototype.nodeEdges=function(p,m){var y=this.inEdges(p,m);if(y)return y.concat(this.outEdges(p,m))};function l(p,m){p[m]?p[m]++:p[m]=1}function u(p,m){--p[m]||delete p[m]}function c(p,m,y,w){var j=""+m,_=""+y;if(!p&&j>_){var S=j;j=_,_=S}return j+s+_+s+(e.isUndefined(w)?n:w)}function f(p,m,y,w){var j=""+m,_=""+y;if(!p&&j>_){var S=j;j=_,_=S}var b={v:j,w:_};return w&&(b.name=w),b}function h(p,m){return c(p,m.v,m.w,m.name)}return qp}var Lp,FS;function $q(){return FS||(FS=1,Lp="2.1.8"),Lp}var $p,zS;function Dq(){return zS||(zS=1,$p={Graph:Rv(),version:$q()}),$p}var Dp,BS;function Fq(){if(BS)return Dp;BS=1;var e=On(),n=Rv();Dp={write:i,read:l};function i(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var f=u.node(c),h=u.parent(c),p={v:c};return e.isUndefined(f)||(p.value=f),e.isUndefined(h)||(p.parent=h),p})}function o(u){return e.map(u.edges(),function(c){var f=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(f)||(h.value=f),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(f){c.setNode(f.v,f.value),f.parent&&c.setParent(f.v,f.parent)}),e.each(u.edges,function(f){c.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),c}return Dp}var Fp,US;function zq(){if(US)return Fp;US=1;var e=On();Fp=n;function n(i){var s={},o=[],l;function u(c){e.has(s,c)||(s[c]=!0,l.push(c),e.each(i.successors(c),u),e.each(i.predecessors(c),u))}return e.each(i.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Fp}var zp,HS;function iC(){if(HS)return zp;HS=1;var e=On();zp=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(i){return i.key})},n.prototype.has=function(i){return e.has(this._keyIndices,i)},n.prototype.priority=function(i){var s=this._keyIndices[i];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(i,s){var o=this._keyIndices;if(i=String(i),!e.has(o,i)){var l=this._arr,u=l.length;return o[i]=u,l.push({key:i,priority:s}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var i=this._arr.pop();return delete this._keyIndices[i.key],this._heapify(0),i.key},n.prototype.decrease=function(i,s){var o=this._keyIndices[i];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+i+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(i){var s=this._arr,o=2*i,l=o+1,u=i;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==i&&(this._swap(i,u),this._heapify(u)))},n.prototype._decrease=function(i){for(var s=this._arr,o=s[i].priority,l;i!==0&&(l=i>>1,!(s[l].priority<o));)this._swap(i,l),i=l},n.prototype._swap=function(i,s){var o=this._arr,l=this._keyIndices,u=o[i],c=o[s];o[i]=c,o[s]=u,l[c.key]=i,l[u.key]=s},zp}var Bp,VS;function sC(){if(VS)return Bp;VS=1;var e=On(),n=iC();Bp=s;var i=e.constant(1);function s(l,u,c,f){return o(l,String(u),c||i,f||function(h){return l.outEdges(h)})}function o(l,u,c,f){var h={},p=new n,m,y,w=function(j){var _=j.v!==m?j.v:j.w,S=h[_],b=c(j),E=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+b);E<S.distance&&(S.distance=E,S.predecessor=m,p.decrease(_,E))};for(l.nodes().forEach(function(j){var _=j===u?0:Number.POSITIVE_INFINITY;h[j]={distance:_},p.add(j,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)f(m).forEach(w);return h}return Bp}var Up,WS;function Bq(){if(WS)return Up;WS=1;var e=sC(),n=On();Up=i;function i(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return Up}var Hp,GS;function oC(){if(GS)return Hp;GS=1;var e=On();Hp=n;function n(i){var s=0,o=[],l={},u=[];function c(f){var h=l[f]={onStack:!0,lowlink:s,index:s++};if(o.push(f),i.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(h.lowlink=Math.min(h.lowlink,l[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,l[y].lowlink))}),h.lowlink===h.index){var p=[],m;do m=o.pop(),l[m].onStack=!1,p.push(m);while(f!==m);u.push(p)}}return i.nodes().forEach(function(f){e.has(l,f)||c(f)}),u}return Hp}var Vp,YS;function Uq(){if(YS)return Vp;YS=1;var e=On(),n=oC();Vp=i;function i(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return Vp}var Wp,KS;function Hq(){if(KS)return Wp;KS=1;var e=On();Wp=i;var n=e.constant(1);function i(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},f=o.nodes();return f.forEach(function(h){c[h]={},c[h][h]={distance:0},f.forEach(function(p){h!==p&&(c[h][p]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(p){var m=p.v===h?p.w:p.v,y=l(p);c[h][m]={distance:y,predecessor:h}})}),f.forEach(function(h){var p=c[h];f.forEach(function(m){var y=c[m];f.forEach(function(w){var j=y[h],_=p[w],S=y[w],b=j.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Wp}var Gp,XS;function aC(){if(XS)return Gp;XS=1;var e=On();Gp=n,n.CycleException=i;function n(s){var o={},l={},u=[];function c(f){if(e.has(l,f))throw new i;e.has(o,f)||(l[f]=!0,o[f]=!0,e.each(s.predecessors(f),c),delete l[f],u.push(f))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new i;return u}function i(){}return i.prototype=new Error,Gp}var Yp,QS;function Vq(){if(QS)return Yp;QS=1;var e=aC();Yp=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Yp}var Kp,ZS;function lC(){if(ZS)return Kp;ZS=1;var e=On();Kp=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],f={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);i(s,h,l==="post",f,u,c)}),c}function i(s,o,l,u,c,f){e.has(u,o)||(u[o]=!0,l||f.push(o),e.each(c(o),function(h){i(s,h,l,u,c,f)}),l&&f.push(o))}return Kp}var Xp,JS;function Wq(){if(JS)return Xp;JS=1;var e=lC();Xp=n;function n(i,s){return e(i,s,"post")}return Xp}var Qp,eb;function Gq(){if(eb)return Qp;eb=1;var e=lC();Qp=n;function n(i,s){return e(i,s,"pre")}return Qp}var Zp,tb;function Yq(){if(tb)return Zp;tb=1;var e=On(),n=Rv(),i=iC();Zp=s;function s(o,l){var u=new n,c={},f=new i,h;function p(y){var w=y.v===h?y.w:y.v,j=f.priority(w);if(j!==void 0){var _=l(y);_<j&&(c[w]=h,f.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),f.decrease(o.nodes()[0],0);for(var m=!1;f.size()>0;){if(h=f.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(p)}return u}return Zp}var Jp,nb;function Kq(){return nb||(nb=1,Jp={components:zq(),dijkstra:sC(),dijkstraAll:Bq(),findCycles:Uq(),floydWarshall:Hq(),isAcyclic:Vq(),postorder:Wq(),preorder:Gq(),prim:Yq(),tarjan:oC(),topsort:aC()}),Jp}var em,rb;function Xq(){if(rb)return em;rb=1;var e=Dq();return em={Graph:e.Graph,json:Fq(),alg:Kq(),version:e.version},em}var tm,ib;function Kn(){if(ib)return tm;ib=1;var e;if(typeof hv=="function")try{e=Xq()}catch{}return e||(e=window.graphlib),tm=e,tm}var nm,sb;function Qq(){if(sb)return nm;sb=1;var e=MN(),n=1,i=4;function s(o){return e(o,n|i)}return nm=s,nm}var rm,ob;function uu(){if(ob)return rm;ob=1;var e=Vs(),n=Ar(),i=eu(),s=Pn();function o(l,u,c){if(!s(c))return!1;var f=typeof u;return(f=="number"?n(c)&&i(u,c.length):f=="string"&&u in c)?e(c[u],l):!1}return rm=o,rm}var im,ab;function Zq(){if(ab)return im;ab=1;var e=lu(),n=Vs(),i=uu(),s=Ki(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,f){c=Object(c);var h=-1,p=f.length,m=p>2?f[2]:void 0;for(m&&i(f[0],f[1],m)&&(p=1);++h<p;)for(var y=f[h],w=s(y),j=-1,_=w.length;++j<_;){var S=w[j],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return im=u,im}var sm,lb;function Jq(){if(lb)return sm;lb=1;var e=Ir(),n=Ar(),i=ai();function s(o){return function(l,u,c){var f=Object(l);if(!n(l)){var h=e(u,3);l=i(l),u=function(m){return h(f[m],m,f)}}var p=o(l,u,c);return p>-1?f[h?l[p]:p]:void 0}}return sm=s,sm}var om,ub;function eL(){if(ub)return om;ub=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return om=n,om}var am,cb;function tL(){if(cb)return am;cb=1;var e=eL(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return am=i,am}var lm,db;function nL(){if(db)return lm;db=1;var e=tL(),n=Pn(),i=Ks(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function f(h){if(typeof h=="number")return h;if(i(h))return s;if(n(h)){var p=typeof h.valueOf=="function"?h.valueOf():h;h=n(p)?p+"":p}if(typeof h!="string")return h===0?h:+h;h=e(h);var m=l.test(h);return m||u.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return lm=f,lm}var um,fb;function uC(){if(fb)return um;fb=1;var e=nL(),n=1/0,i=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*i}return o===o?o:0}return um=s,um}var cm,hb;function rL(){if(hb)return cm;hb=1;var e=uC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return cm=n,cm}var dm,pb;function iL(){if(pb)return dm;pb=1;var e=tC(),n=Ir(),i=rL(),s=Math.max;function o(l,u,c){var f=l==null?0:l.length;if(!f)return-1;var h=c==null?0:i(c);return h<0&&(h=s(f+h,0)),e(l,n(u,3),h)}return dm=o,dm}var fm,mb;function sL(){if(mb)return fm;mb=1;var e=Jq(),n=iL(),i=e(n);return fm=i,fm}var hm,gb;function cC(){if(gb)return hm;gb=1;var e=jv();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return hm=n,hm}var pm,vb;function oL(){if(vb)return pm;vb=1;var e=kv(),n=PN(),i=Ki();function s(o,l){return o==null?o:e(o,n(l),i)}return pm=s,pm}var mm,yb;function aL(){if(yb)return mm;yb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return mm=e,mm}var gm,wb;function lL(){if(wb)return gm;wb=1;var e=Zl(),n=Ev(),i=Ir();function s(o,l){var u={};return l=i(l,3),n(o,function(c,f,h){e(u,f,l(c,f,h))}),u}return gm=s,gm}var vm,xb;function Tv(){if(xb)return vm;xb=1;var e=Ks();function n(i,s,o){for(var l=-1,u=i.length;++l<u;){var c=i[l],f=s(c);if(f!=null&&(h===void 0?f===f&&!e(f):o(f,h)))var h=f,p=c}return p}return vm=n,vm}var ym,_b;function uL(){if(_b)return ym;_b=1;function e(n,i){return n>i}return ym=e,ym}var wm,Sb;function cL(){if(Sb)return wm;Sb=1;var e=Tv(),n=uL(),i=Xi();function s(o){return o&&o.length?e(o,i,n):void 0}return wm=s,wm}var xm,bb;function dC(){if(bb)return xm;bb=1;var e=Zl(),n=Vs();function i(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return xm=i,xm}var _m,kb;function dL(){if(kb)return _m;kb=1;var e=Gi(),n=ru(),i=ur(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,f=u.call(Object);function h(p){if(!i(p)||e(p)!=s)return!1;var m=n(p);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==f}return _m=h,_m}var Sm,Eb;function fC(){if(Eb)return Sm;Eb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return Sm=e,Sm}var bm,Nb;function fL(){if(Nb)return bm;Nb=1;var e=ia(),n=Ki();function i(s){return e(s,n(s))}return bm=i,bm}var km,Cb;function hL(){if(Cb)return km;Cb=1;var e=dC(),n=_N(),i=TN(),s=SN(),o=IN(),l=sa(),u=Et(),c=nC(),f=Gs(),h=ra(),p=Pn(),m=dL(),y=oa(),w=fC(),j=fL();function _(S,b,E,N,C,I,O){var P=w(S,E),z=w(b,E),T=O.get(z);if(T){e(S,E,T);return}var q=I?I(P,z,E+"",S,b,O):void 0,B=q===void 0;if(B){var J=u(z),Q=!J&&f(z),A=!J&&!Q&&y(z);q=z,J||Q||A?u(P)?q=P:c(P)?q=s(P):Q?(B=!1,q=n(z,!0)):A?(B=!1,q=i(z,!0)):q=[]:m(z)||l(z)?(q=P,l(P)?q=j(P):(!p(P)||h(P))&&(q=o(z))):B=!1}B&&(O.set(z,q),C(q,z,N,I,O),O.delete(z)),e(S,E,q)}return km=_,km}var Em,jb;function pL(){if(jb)return Em;jb=1;var e=Ql(),n=dC(),i=kv(),s=hL(),o=Pn(),l=Ki(),u=fC();function c(f,h,p,m,y){f!==h&&i(h,function(w,j){if(y||(y=new e),o(w))s(f,h,j,p,c,m,y);else{var _=m?m(u(f,j),w,j+"",f,h,y):void 0;_===void 0&&(_=w),n(f,j,_)}},l)}return Em=c,Em}var Nm,Rb;function mL(){if(Rb)return Nm;Rb=1;var e=lu(),n=uu();function i(s){return e(function(o,l){var u=-1,c=l.length,f=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(f=s.length>3&&typeof f=="function"?(c--,f):void 0,h&&n(l[0],l[1],h)&&(f=c<3?void 0:f,c=1),o=Object(o);++u<c;){var p=l[u];p&&s(o,p,u,f)}return o})}return Nm=i,Nm}var Cm,Tb;function gL(){if(Tb)return Cm;Tb=1;var e=pL(),n=mL(),i=n(function(s,o,l){e(s,o,l)});return Cm=i,Cm}var jm,Ab;function hC(){if(Ab)return jm;Ab=1;function e(n,i){return n<i}return jm=e,jm}var Rm,Ib;function vL(){if(Ib)return Rm;Ib=1;var e=Tv(),n=hC(),i=Xi();function s(o){return o&&o.length?e(o,i,n):void 0}return Rm=s,Rm}var Tm,Mb;function yL(){if(Mb)return Tm;Mb=1;var e=Tv(),n=Ir(),i=hC();function s(o,l){return o&&o.length?e(o,n(l,2),i):void 0}return Tm=s,Tm}var Am,Pb;function wL(){if(Pb)return Am;Pb=1;var e=Qn(),n=function(){return e.Date.now()};return Am=n,Am}var Im,Ob;function xL(){if(Ob)return Im;Ob=1;var e=Jl(),n=ou(),i=eu(),s=Pn(),o=aa();function l(u,c,f,h){if(!s(u))return u;c=n(c,u);for(var p=-1,m=c.length,y=m-1,w=u;w!=null&&++p<m;){var j=o(c[p]),_=f;if(j==="__proto__"||j==="constructor"||j==="prototype")return u;if(p!=y){var S=w[j];_=h?h(S,j,w):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(w,j,_),w=w[j]}return u}return Im=l,Im}var Mm,qb;function _L(){if(qb)return Mm;qb=1;var e=au(),n=xL(),i=ou();function s(o,l,u){for(var c=-1,f=l.length,h={};++c<f;){var p=l[c],m=e(o,p);u(m,p)&&n(h,i(p,o),m)}return h}return Mm=s,Mm}var Pm,Lb;function SL(){if(Lb)return Pm;Lb=1;var e=_L(),n=VN();function i(s,o){return e(s,o,function(l,u){return n(s,u)})}return Pm=i,Pm}var Om,$b;function bL(){if($b)return Om;$b=1;var e=cC(),n=JN(),i=eC();function s(o){return i(n(o,void 0,e),o+"")}return Om=s,Om}var qm,Db;function kL(){if(Db)return qm;Db=1;var e=SL(),n=bL(),i=n(function(s,o){return s==null?{}:e(s,o)});return qm=i,qm}var Lm,Fb;function EL(){if(Fb)return Lm;Fb=1;var e=Math.ceil,n=Math.max;function i(s,o,l,u){for(var c=-1,f=n(e((o-s)/(l||1)),0),h=Array(f);f--;)h[u?f:++c]=s,s+=l;return h}return Lm=i,Lm}var $m,zb;function NL(){if(zb)return $m;zb=1;var e=EL(),n=uu(),i=uC();function s(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=i(l),u===void 0?(u=l,l=0):u=i(u),c=c===void 0?l<u?1:-1:i(c),e(l,u,c,o)}}return $m=s,$m}var Dm,Bb;function CL(){if(Bb)return Dm;Bb=1;var e=NL(),n=e();return Dm=n,Dm}var Fm,Ub;function jL(){if(Ub)return Fm;Ub=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Fm=e,Fm}var zm,Hb;function RL(){if(Hb)return zm;Hb=1;var e=Ks();function n(i,s){if(i!==s){var o=i!==void 0,l=i===null,u=i===i,c=e(i),f=s!==void 0,h=s===null,p=s===s,m=e(s);if(!h&&!m&&!c&&i>s||c&&f&&p&&!h&&!m||l&&f&&p||!o&&p||!u)return 1;if(!l&&!c&&!m&&i<s||m&&o&&u&&!l&&!c||h&&o&&u||!f&&u||!p)return-1}return 0}return zm=n,zm}var Bm,Vb;function TL(){if(Vb)return Bm;Vb=1;var e=RL();function n(i,s,o){for(var l=-1,u=i.criteria,c=s.criteria,f=u.length,h=o.length;++l<f;){var p=e(u[l],c[l]);if(p){if(l>=h)return p;var m=o[l];return p*(m=="desc"?-1:1)}}return i.index-s.index}return Bm=n,Bm}var Um,Wb;function AL(){if(Wb)return Um;Wb=1;var e=su(),n=au(),i=Ir(),s=XN(),o=jL(),l=tu(),u=TL(),c=Xi(),f=Et();function h(p,m,y){m.length?m=e(m,function(_){return f(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var w=-1;m=e(m,l(i));var j=s(p,function(_,S,b){var E=e(m,function(N){return N(_)});return{criteria:E,index:++w,value:_}});return o(j,function(_,S){return u(_,S,y)})}return Um=h,Um}var Hm,Gb;function IL(){if(Gb)return Hm;Gb=1;var e=jv(),n=AL(),i=lu(),s=uu(),o=i(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return Hm=o,Hm}var Vm,Yb;function ML(){if(Yb)return Vm;Yb=1;var e=UN(),n=0;function i(s){var o=++n;return e(s)+o}return Vm=i,Vm}var Wm,Kb;function PL(){if(Kb)return Wm;Kb=1;function e(n,i,s){for(var o=-1,l=n.length,u=i.length,c={};++o<l;){var f=o<u?i[o]:void 0;s(c,n[o],f)}return c}return Wm=e,Wm}var Gm,Xb;function OL(){if(Xb)return Gm;Xb=1;var e=Jl(),n=PL();function i(s,o){return n(s||[],o||[],e)}return Gm=i,Gm}var Ym,Qb;function lt(){if(Qb)return Ym;Qb=1;var e;if(typeof hv=="function")try{e={cloneDeep:Qq(),constant:bv(),defaults:Zq(),each:qN(),filter:GN(),find:sL(),flatten:cC(),forEach:ON(),forIn:oL(),has:YN(),isUndefined:KN(),last:aL(),map:QN(),mapValues:lL(),max:cL(),merge:gL(),min:vL(),minBy:yL(),now:wL(),pick:kL(),range:CL(),reduce:ZN(),sortBy:IL(),uniqueId:ML(),values:rC(),zipObject:OL()}}catch{}return e||(e=window._),Ym=e,Ym}var Km,Zb;function qL(){if(Zb)return Km;Zb=1,Km=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,i)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function i(s,o){if(s!=="_next"&&s!=="_prev")return o}return Km}var Xm,Jb;function LL(){if(Jb)return Xm;Jb=1;var e=lt(),n=Kn().Graph,i=qL();Xm=o;var s=e.constant(1);function o(h,p){if(h.nodeCount()<=1)return[];var m=c(h,p||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return h.outEdges(w.v,w.w)}),!0)}function l(h,p,m){for(var y=[],w=p[p.length-1],j=p[0],_;h.nodeCount();){for(;_=j.dequeue();)u(h,p,m,_);for(;_=w.dequeue();)u(h,p,m,_);if(h.nodeCount()){for(var S=p.length-2;S>0;--S)if(_=p[S].dequeue(),_){y=y.concat(u(h,p,m,_,!0));break}}}return y}function u(h,p,m,y,w){var j=w?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);w&&j.push({v:_.v,w:_.w}),b.out-=S,f(p,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,E=h.node(b);E.in-=S,f(p,m,E)}),h.removeNode(y.v),j}function c(h,p){var m=new n,y=0,w=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,E=p(S),N=b+E;m.setEdge(S.v,S.w,N),w=Math.max(w,m.node(S.v).out+=E),y=Math.max(y,m.node(S.w).in+=E)});var j=e.range(w+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){f(j,_,m.node(S))}),{graph:m,buckets:j,zeroIdx:_}}function f(h,p,m){m.out?m.in?h[m.out-m.in+p].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Xm}var Qm,ek;function $L(){if(ek)return Qm;ek=1;var e=lt(),n=LL();Qm={run:i,undo:o};function i(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(f){var h=l.edge(f);l.removeEdge(f),h.forwardName=f.name,h.reversed=!0,l.setEdge(f.w,f.v,h,e.uniqueId("rev"))});function c(f){return function(h){return f.edge(h).weight}}}function s(l){var u=[],c={},f={};function h(p){e.has(f,p)||(f[p]=!0,c[p]=!0,e.forEach(l.outEdges(p),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[p])}return e.forEach(l.nodes(),h),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var f=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,f)}})}return Qm}var Zm,tk;function cn(){if(tk)return Zm;tk=1;var e=lt(),n=Kn().Graph;Zm={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:f,normalizeRanks:h,removeEmptyRanks:p,addBorderNode:m,maxRank:y,partition:w,time:j,notime:_};function i(S,b,E,N){var C;do C=e.uniqueId(N);while(S.hasNode(C));return E.dummy=b,S.setNode(C,E),C}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(E){b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){var N=b.edge(E.v,E.w)||{weight:0,minlen:1},C=S.edge(E);b.setEdge(E.v,E.w,{weight:N.weight+C.weight,minlen:Math.max(N.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(E){S.children(E).length||b.setNode(E,S.node(E))}),e.forEach(S.edges(),function(E){b.setEdge(E,S.edge(E))}),b}function l(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.outEdges(E),function(C){N[C.w]=(N[C.w]||0)+S.edge(C).weight}),N});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(E){var N={};return e.forEach(S.inEdges(E),function(C){N[C.v]=(N[C.v]||0)+S.edge(C).weight}),N});return e.zipObject(S.nodes(),b)}function c(S,b){var E=S.x,N=S.y,C=b.x-E,I=b.y-N,O=S.width/2,P=S.height/2;if(!C&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var z,T;return Math.abs(I)*O>Math.abs(C)*P?(I<0&&(P=-P),z=P*C/I,T=P):(C<0&&(O=-O),z=O,T=O*I/C),{x:E+z,y:N+T}}function f(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(E){var N=S.node(E),C=N.rank;e.isUndefined(C)||(b[C][N.order]=E)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(E){return S.node(E).rank}));e.forEach(S.nodes(),function(E){var N=S.node(E);e.has(N,"rank")&&(N.rank-=b)})}function p(S){var b=e.min(e.map(S.nodes(),function(I){return S.node(I).rank})),E=[];e.forEach(S.nodes(),function(I){var O=S.node(I).rank-b;E[O]||(E[O]=[]),E[O].push(I)});var N=0,C=S.graph().nodeRankFactor;e.forEach(E,function(I,O){e.isUndefined(I)&&O%C!==0?--N:N&&e.forEach(I,function(P){S.node(P).rank+=N})})}function m(S,b,E,N){var C={width:0,height:0};return arguments.length>=4&&(C.rank=E,C.order=N),i(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var E=S.node(b).rank;if(!e.isUndefined(E))return E}))}function w(S,b){var E={lhs:[],rhs:[]};return e.forEach(S,function(N){b(N)?E.lhs.push(N):E.rhs.push(N)}),E}function j(S,b){var E=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-E)+"ms")}}function _(S,b){return b()}return Zm}var Jm,nk;function DL(){if(nk)return Jm;nk=1;var e=lt(),n=cn();Jm={run:i,undo:o};function i(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,f=l.node(c).rank,h=u.w,p=l.node(h).rank,m=u.name,y=l.edge(u),w=y.labelRank;if(p!==f+1){l.removeEdge(u);var j,_,S;for(S=0,++f;f<p;++S,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:f},j=n.addDummyNode(l,"edge",_,"_d"),f===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,j,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(j),c=j;l.setEdge(c,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),f=c.edgeLabel,h;for(l.setEdge(c.edgeObj,f);c.dummy;)h=l.successors(u)[0],l.removeNode(u),f.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(f.x=c.x,f.y=c.y,f.width=c.width,f.height=c.height),u=h,c=l.node(u)})}return Jm}var eg,rk;function Dl(){if(rk)return eg;rk=1;var e=lt();eg={longestPath:n,slack:i};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var f=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),c.rank=f}e.forEach(s.sources(),l)}function i(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return eg}var tg,ik;function pC(){if(ik)return tg;ik=1;var e=lt(),n=Kn().Graph,i=Dl().slack;tg=s;function s(c){var f=new n({directed:!1}),h=c.nodes()[0],p=c.nodeCount();f.setNode(h,{});for(var m,y;o(f,c)<p;)m=l(f,c),y=f.hasNode(m.v)?i(c,m):-i(c,m),u(f,c,y);return f}function o(c,f){function h(p){e.forEach(f.nodeEdges(p),function(m){var y=m.v,w=p===y?m.w:y;!c.hasNode(w)&&!i(f,m)&&(c.setNode(w,{}),c.setEdge(p,w,{}),h(w))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,f){return e.minBy(f.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return i(f,h)})}function u(c,f,h){e.forEach(c.nodes(),function(p){f.node(p).rank+=h})}return tg}var ng,sk;function FL(){if(sk)return ng;sk=1;var e=lt(),n=pC(),i=Dl().slack,s=Dl().longestPath,o=Kn().alg.preorder,l=Kn().alg.postorder,u=cn().simplify;ng=c,c.initLowLimValues=m,c.initCutValues=f,c.calcCutValue=p,c.leaveEdge=w,c.enterEdge=j,c.exchangeEdges=_;function c(N){N=u(N),s(N);var C=n(N);m(C),f(C,N);for(var I,O;I=w(C);)O=j(C,N,I),_(C,N,I,O)}function f(N,C){var I=l(N,N.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(O){h(N,C,O)})}function h(N,C,I){var O=N.node(I),P=O.parent;N.edge(I,P).cutvalue=p(N,C,I)}function p(N,C,I){var O=N.node(I),P=O.parent,z=!0,T=C.edge(I,P),q=0;return T||(z=!1,T=C.edge(P,I)),q=T.weight,e.forEach(C.nodeEdges(I),function(B){var J=B.v===I,Q=J?B.w:B.v;if(Q!==P){var A=J===z,H=C.edge(B).weight;if(q+=A?H:-H,b(N,I,Q)){var U=N.edge(I,Q).cutvalue;q+=A?-U:U}}}),q}function m(N,C){arguments.length<2&&(C=N.nodes()[0]),y(N,{},1,C)}function y(N,C,I,O,P){var z=I,T=N.node(O);return C[O]=!0,e.forEach(N.neighbors(O),function(q){e.has(C,q)||(I=y(N,C,I,q,O))}),T.low=z,T.lim=I++,P?T.parent=P:delete T.parent,I}function w(N){return e.find(N.edges(),function(C){return N.edge(C).cutvalue<0})}function j(N,C,I){var O=I.v,P=I.w;C.hasEdge(O,P)||(O=I.w,P=I.v);var z=N.node(O),T=N.node(P),q=z,B=!1;z.lim>T.lim&&(q=T,B=!0);var J=e.filter(C.edges(),function(Q){return B===E(N,N.node(Q.v),q)&&B!==E(N,N.node(Q.w),q)});return e.minBy(J,function(Q){return i(C,Q)})}function _(N,C,I,O){var P=I.v,z=I.w;N.removeEdge(P,z),N.setEdge(O.v,O.w,{}),m(N),f(N,C),S(N,C)}function S(N,C){var I=e.find(N.nodes(),function(P){return!C.node(P).parent}),O=o(N,I);O=O.slice(1),e.forEach(O,function(P){var z=N.node(P).parent,T=C.edge(P,z),q=!1;T||(T=C.edge(z,P),q=!0),C.node(P).rank=C.node(z).rank+(q?T.minlen:-T.minlen)})}function b(N,C,I){return N.hasEdge(C,I)}function E(N,C,I){return I.low<=C.lim&&C.lim<=I.lim}return ng}var rg,ok;function zL(){if(ok)return rg;ok=1;var e=Dl(),n=e.longestPath,i=pC(),s=FL();rg=o;function o(f){switch(f.graph().ranker){case"network-simplex":c(f);break;case"tight-tree":u(f);break;case"longest-path":l(f);break;default:c(f)}}var l=n;function u(f){n(f),i(f)}function c(f){s(f)}return rg}var ig,ak;function BL(){if(ak)return ig;ak=1;var e=lt();ig=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),f=c.edgeObj,h=i(o,l,f.v,f.w),p=h.path,m=h.lca,y=0,w=p[y],j=!0;u!==f.w;){if(c=o.node(u),j){for(;(w=p[y])!==m&&o.node(w).maxRank<c.rank;)y++;w===m&&(j=!1)}if(!j){for(;y<p.length-1&&o.node(w=p[y+1]).minRank<=c.rank;)y++;w=p[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function i(o,l,u,c){var f=[],h=[],p=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),f.push(y);while(y&&(l[y].low>p||m>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)h.push(y);return{path:f.concat(h.reverse()),lca:w}}function s(o){var l={},u=0;function c(f){var h=u;e.forEach(o.children(f),c),l[f]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return ig}var sg,lk;function UL(){if(lk)return sg;lk=1;var e=lt(),n=cn();sg={run:i,cleanup:u};function i(c){var f=n.addDummyNode(c,"root",{},"_root"),h=o(c),p=e.max(e.values(h))-1,m=2*p+1;c.graph().nestingRoot=f,e.forEach(c.edges(),function(w){c.edge(w).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(w){s(c,f,m,y,p,h,w)}),c.graph().nodeRankFactor=m}function s(c,f,h,p,m,y,w){var j=c.children(w);if(!j.length){w!==f&&c.setEdge(f,w,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(w);c.setParent(_,w),b.borderTop=_,c.setParent(S,w),b.borderBottom=S,e.forEach(j,function(E){s(c,f,h,p,m,y,E);var N=c.node(E),C=N.borderTop?N.borderTop:E,I=N.borderBottom?N.borderBottom:E,O=N.borderTop?p:2*p,P=C!==I?1:m-y[w]+1;c.setEdge(_,C,{weight:O,minlen:P,nestingEdge:!0}),c.setEdge(I,S,{weight:O,minlen:P,nestingEdge:!0})}),c.parent(w)||c.setEdge(f,_,{weight:0,minlen:m+y[w]})}function o(c){var f={};function h(p,m){var y=c.children(p);y&&y.length&&e.forEach(y,function(w){h(w,m+1)}),f[p]=m}return e.forEach(c.children(),function(p){h(p,1)}),f}function l(c){return e.reduce(c.edges(),function(f,h){return f+c.edge(h).weight},0)}function u(c){var f=c.graph();c.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(c.edges(),function(h){var p=c.edge(h);p.nestingEdge&&c.removeEdge(h)})}return sg}var og,uk;function HL(){if(uk)return og;uk=1;var e=lt(),n=cn();og=i;function i(o){function l(u){var c=o.children(u),f=o.node(u);if(c.length&&e.forEach(c,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var h=f.minRank,p=f.maxRank+1;h<p;++h)s(o,"borderLeft","_bl",u,f,h),s(o,"borderRight","_br",u,f,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,f,h){var p={width:0,height:0,rank:h,borderType:l},m=f[l][h-1],y=n.addDummyNode(o,"border",p,u);f[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return og}var ag,ck;function VL(){if(ck)return ag;ck=1;var e=lt();ag={adjust:n,undo:i};function n(h){var p=h.graph().rankdir.toLowerCase();(p==="lr"||p==="rl")&&s(h)}function i(h){var p=h.graph().rankdir.toLowerCase();(p==="bt"||p==="rl")&&l(h),(p==="lr"||p==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(p){o(h.node(p))}),e.forEach(h.edges(),function(p){o(h.edge(p))})}function o(h){var p=h.width;h.width=h.height,h.height=p}function l(h){e.forEach(h.nodes(),function(p){u(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(p){f(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,f),e.has(m,"x")&&f(m)})}function f(h){var p=h.x;h.x=h.y,h.y=p}return ag}var lg,dk;function WL(){if(dk)return lg;dk=1;var e=lt();lg=n;function n(i){var s={},o=e.filter(i.nodes(),function(h){return!i.children(h).length}),l=e.max(e.map(o,function(h){return i.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var p=i.node(h);u[p.rank].push(h),e.forEach(i.successors(h),c)}}var f=e.sortBy(o,function(h){return i.node(h).rank});return e.forEach(f,c),u}return lg}var ug,fk;function GL(){if(fk)return ug;fk=1;var e=lt();ug=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=i(s,o[u-1],o[u]);return l}function i(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(w){return{pos:u[w.w],weight:s.edge(w).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var h=2*f-1;f-=1;var p=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var w=y.pos+f;p[w]+=y.weight;for(var j=0;w>0;)w%2&&(j+=p[w+1]),w=w-1>>1,p[w]+=y.weight;m+=y.weight*j})),m}return ug}var cg,hk;function YL(){if(hk)return cg;hk=1;var e=lt();cg=n;function n(i,s){return e.map(s,function(o){var l=i.inEdges(o);if(l.length){var u=e.reduce(l,function(c,f){var h=i.edge(f),p=i.node(f.v);return{sum:c.sum+h.weight*p.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return cg}var dg,pk;function KL(){if(pk)return dg;pk=1;var e=lt();dg=n;function n(o,l){var u={};e.forEach(o,function(f,h){var p=u[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:h};e.isUndefined(f.barycenter)||(p.barycenter=f.barycenter,p.weight=f.weight)}),e.forEach(l.edges(),function(f){var h=u[f.v],p=u[f.w];!e.isUndefined(h)&&!e.isUndefined(p)&&(p.indegree++,h.out.push(u[f.w]))});var c=e.filter(u,function(f){return!f.indegree});return i(c)}function i(o){var l=[];function u(h){return function(p){p.merged||(e.isUndefined(p.barycenter)||e.isUndefined(h.barycenter)||p.barycenter>=h.barycenter)&&s(h,p)}}function c(h){return function(p){p.in.push(h),--p.indegree===0&&o.push(p)}}for(;o.length;){var f=o.pop();l.push(f),e.forEach(f.in.reverse(),u(f)),e.forEach(f.out,c(f))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return dg}var fg,mk;function XL(){if(mk)return fg;mk=1;var e=lt(),n=cn();fg=i;function i(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),f=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),p=[],m=0,y=0,w=0;f.sort(o(!!u)),w=s(p,h,w),e.forEach(f,function(_){w+=_.vs.length,p.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,w=s(p,h,w)});var j={vs:e.flatten(p,!0)};return y&&(j.barycenter=m/y,j.weight=y),j}function s(l,u,c){for(var f;u.length&&(f=e.last(u)).i<=c;)u.pop(),l.push(f.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return fg}var hg,gk;function QL(){if(gk)return hg;gk=1;var e=lt(),n=YL(),i=KL(),s=XL();hg=o;function o(c,f,h,p){var m=c.children(f),y=c.node(f),w=y?y.borderLeft:void 0,j=y?y.borderRight:void 0,_={};w&&(m=e.filter(m,function(I){return I!==w&&I!==j}));var S=n(c,m);e.forEach(S,function(I){if(c.children(I.v).length){var O=o(c,I.v,h,p);_[I.v]=O,e.has(O,"barycenter")&&u(I,O)}});var b=i(S,h);l(b,_);var E=s(b,p);if(w&&(E.vs=e.flatten([w,E.vs,j],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),C=c.node(c.predecessors(j)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+N.order+C.order)/(E.weight+2),E.weight+=2}return E}function l(c,f){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(p){return f[p]?f[p].vs:p}),!0)})}function u(c,f){e.isUndefined(c.barycenter)?(c.barycenter=f.barycenter,c.weight=f.weight):(c.barycenter=(c.barycenter*c.weight+f.barycenter*f.weight)/(c.weight+f.weight),c.weight+=f.weight)}return hg}var pg,vk;function ZL(){if(vk)return pg;vk=1;var e=lt(),n=Kn().Graph;pg=i;function i(o,l,u){var c=s(o),f=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var p=o.node(h),m=o.parent(h);(p.rank===l||p.minRank<=l&&l<=p.maxRank)&&(f.setNode(h),f.setParent(h,m||c),e.forEach(o[u](h),function(y){var w=y.v===h?y.w:y.v,j=f.edge(w,h),_=e.isUndefined(j)?0:j.weight;f.setEdge(w,h,{weight:o.edge(y).weight+_})}),e.has(p,"minRank")&&f.setNode(h,{borderLeft:p.borderLeft[l],borderRight:p.borderRight[l]}))}),f}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return pg}var mg,yk;function JL(){if(yk)return mg;yk=1;var e=lt();mg=n;function n(i,s,o){var l={},u;e.forEach(o,function(c){for(var f=i.parent(c),h,p;f;){if(h=i.parent(f),h?(p=l[h],l[h]=f):(p=u,u=f),p&&p!==f){s.setEdge(p,f);return}f=h}})}return mg}var gg,wk;function e$(){if(wk)return gg;wk=1;var e=lt(),n=WL(),i=GL(),s=QL(),o=ZL(),l=JL(),u=Kn().Graph,c=cn();gg=f;function f(y){var w=c.maxRank(y),j=h(y,e.range(1,w+1),"inEdges"),_=h(y,e.range(w-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,E,N=0,C=0;C<4;++N,++C){p(N%2?j:_,N%4>=2),S=c.buildLayerMatrix(y);var I=i(y,S);I<b&&(C=0,E=e.cloneDeep(S),b=I)}m(y,E)}function h(y,w,j){return e.map(w,function(_){return o(y,_,j)})}function p(y,w){var j=new u;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,j,w);e.forEach(b.vs,function(E,N){_.node(E).order=N}),l(_,j,b.vs)})}function m(y,w){e.forEach(w,function(j){e.forEach(j,function(_,S){y.node(_).order=S})})}return gg}var vg,xk;function t$(){if(xk)return vg;xk=1;var e=lt(),n=Kn().Graph,i=cn();vg={positionX:j,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:f,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function s(b,E){var N={};function C(I,O){var P=0,z=0,T=I.length,q=e.last(O);return e.forEach(O,function(B,J){var Q=l(b,B),A=Q?b.node(Q).order:T;(Q||B===q)&&(e.forEach(O.slice(z,J+1),function(H){e.forEach(b.predecessors(H),function(U){var ne=b.node(U),Y=ne.order;(Y<P||A<Y)&&!(ne.dummy&&b.node(H).dummy)&&u(N,U,H)})}),z=J+1,P=A)}),O}return e.reduce(E,C),N}function o(b,E){var N={};function C(O,P,z,T,q){var B;e.forEach(e.range(P,z),function(J){B=O[J],b.node(B).dummy&&e.forEach(b.predecessors(B),function(Q){var A=b.node(Q);A.dummy&&(A.order<T||A.order>q)&&u(N,Q,B)})})}function I(O,P){var z=-1,T,q=0;return e.forEach(P,function(B,J){if(b.node(B).dummy==="border"){var Q=b.predecessors(B);Q.length&&(T=b.node(Q[0]).order,C(P,q,J,z,T),q=J,z=T)}C(P,q,P.length,T,O.length)}),P}return e.reduce(E,I),N}function l(b,E){if(b.node(E).dummy)return e.find(b.predecessors(E),function(N){return b.node(N).dummy})}function u(b,E,N){if(E>N){var C=E;E=N,N=C}var I=b[E];I||(b[E]=I={}),I[N]=!0}function c(b,E,N){if(E>N){var C=E;E=N,N=C}return e.has(b[E],N)}function f(b,E,N,C){var I={},O={},P={};return e.forEach(E,function(z){e.forEach(z,function(T,q){I[T]=T,O[T]=T,P[T]=q})}),e.forEach(E,function(z){var T=-1;e.forEach(z,function(q){var B=C(q);if(B.length){B=e.sortBy(B,function(U){return P[U]});for(var J=(B.length-1)/2,Q=Math.floor(J),A=Math.ceil(J);Q<=A;++Q){var H=B[Q];O[q]===q&&T<P[H]&&!c(N,q,H)&&(O[H]=q,O[q]=I[q]=I[H],T=P[H])}}})}),{root:I,align:O}}function h(b,E,N,C,I){var O={},P=p(b,E,N,I),z=I?"borderLeft":"borderRight";function T(J,Q){for(var A=P.nodes(),H=A.pop(),U={};H;)U[H]?J(H):(U[H]=!0,A.push(H),A=A.concat(Q(H))),H=A.pop()}function q(J){O[J]=P.inEdges(J).reduce(function(Q,A){return Math.max(Q,O[A.v]+P.edge(A))},0)}function B(J){var Q=P.outEdges(J).reduce(function(H,U){return Math.min(H,O[U.w]-P.edge(U))},Number.POSITIVE_INFINITY),A=b.node(J);Q!==Number.POSITIVE_INFINITY&&A.borderType!==z&&(O[J]=Math.max(O[J],Q))}return T(q,P.predecessors.bind(P)),T(B,P.successors.bind(P)),e.forEach(C,function(J){O[J]=O[N[J]]}),O}function p(b,E,N,C){var I=new n,O=b.graph(),P=_(O.nodesep,O.edgesep,C);return e.forEach(E,function(z){var T;e.forEach(z,function(q){var B=N[q];if(I.setNode(B),T){var J=N[T],Q=I.edge(J,B);I.setEdge(J,B,Math.max(P(b,q,T),Q||0))}T=q})}),I}function m(b,E){return e.minBy(e.values(E),function(N){var C=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY;return e.forIn(N,function(O,P){var z=S(b,P)/2;C=Math.max(O+z,C),I=Math.min(O-z,I)}),C-I})}function y(b,E){var N=e.values(E),C=e.min(N),I=e.max(N);e.forEach(["u","d"],function(O){e.forEach(["l","r"],function(P){var z=O+P,T=b[z],q;if(T!==E){var B=e.values(T);q=P==="l"?C-e.min(B):I-e.max(B),q&&(b[z]=e.mapValues(T,function(J){return J+q}))}})})}function w(b,E){return e.mapValues(b.ul,function(N,C){if(E)return b[E.toLowerCase()][C];var I=e.sortBy(e.map(b,C));return(I[1]+I[2])/2})}function j(b){var E=i.buildLayerMatrix(b),N=e.merge(s(b,E),o(b,E)),C={},I;e.forEach(["u","d"],function(P){I=P==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(z){z==="r"&&(I=e.map(I,function(J){return e.values(J).reverse()}));var T=(P==="u"?b.predecessors:b.successors).bind(b),q=f(b,I,N,T),B=h(b,I,q.root,q.align,z==="r");z==="r"&&(B=e.mapValues(B,function(J){return-J})),C[P+z]=B})});var O=m(b,C);return y(C,O),w(C,b.graph().align)}function _(b,E,N){return function(C,I,O){var P=C.node(I),z=C.node(O),T=0,q;if(T+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":q=-P.width/2;break;case"r":q=P.width/2;break}if(q&&(T+=N?q:-q),q=0,T+=(P.dummy?E:b)/2,T+=(z.dummy?E:b)/2,T+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":q=z.width/2;break;case"r":q=-z.width/2;break}return q&&(T+=N?q:-q),q=0,T}}function S(b,E){return b.node(E).width}return vg}var yg,_k;function n$(){if(_k)return yg;_k=1;var e=lt(),n=cn(),i=t$().positionX;yg=s;function s(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(i(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,f=0;e.forEach(u,function(h){var p=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=f+p/2}),f+=p+c})}return yg}var wg,Sk;function r$(){if(Sk)return wg;Sk=1;var e=lt(),n=$L(),i=DL(),s=zL(),o=cn().normalizeRanks,l=BL(),u=cn().removeEmptyRanks,c=UL(),f=HL(),h=VL(),p=e$(),m=n$(),y=cn(),w=Kn().Graph;wg=j;function j(D,X){var ee=X&&X.debugTiming?y.time:y.notime;ee("layout",function(){var se=ee(" buildLayoutGraph",function(){return T(D)});ee(" runLayout",function(){_(se,ee)}),ee(" updateInputGraph",function(){S(D,se)})})}function _(D,X){X(" makeSpaceForEdgeLabels",function(){q(D)}),X(" removeSelfEdges",function(){L(D)}),X(" acyclic",function(){n.run(D)}),X(" nestingGraph.run",function(){c.run(D)}),X(" rank",function(){s(y.asNonCompoundGraph(D))}),X(" injectEdgeLabelProxies",function(){B(D)}),X(" removeEmptyRanks",function(){u(D)}),X(" nestingGraph.cleanup",function(){c.cleanup(D)}),X(" normalizeRanks",function(){o(D)}),X(" assignRankMinMax",function(){J(D)}),X(" removeEdgeLabelProxies",function(){Q(D)}),X(" normalize.run",function(){i.run(D)}),X(" parentDummyChains",function(){l(D)}),X(" addBorderSegments",function(){f(D)}),X(" order",function(){p(D)}),X(" insertSelfEdges",function(){G(D)}),X(" adjustCoordinateSystem",function(){h.adjust(D)}),X(" position",function(){m(D)}),X(" positionSelfEdges",function(){k(D)}),X(" removeBorderNodes",function(){Y(D)}),X(" normalize.undo",function(){i.undo(D)}),X(" fixupEdgeLabelCoords",function(){U(D)}),X(" undoCoordinateSystem",function(){h.undo(D)}),X(" translateGraph",function(){A(D)}),X(" assignNodeIntersects",function(){H(D)}),X(" reversePoints",function(){ne(D)}),X(" acyclic.undo",function(){n.undo(D)})}function S(D,X){e.forEach(D.nodes(),function(ee){var se=D.node(ee),ae=X.node(ee);se&&(se.x=ae.x,se.y=ae.y,X.children(ee).length&&(se.width=ae.width,se.height=ae.height))}),e.forEach(D.edges(),function(ee){var se=D.edge(ee),ae=X.edge(ee);se.points=ae.points,e.has(ae,"x")&&(se.x=ae.x,se.y=ae.y)}),D.graph().width=X.graph().width,D.graph().height=X.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],C=["width","height"],I={width:0,height:0},O=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function T(D){var X=new w({multigraph:!0,compound:!0}),ee=oe(D.graph());return X.setGraph(e.merge({},E,$(ee,b),e.pick(ee,N))),e.forEach(D.nodes(),function(se){var ae=oe(D.node(se));X.setNode(se,e.defaults($(ae,C),I)),X.setParent(se,D.parent(se))}),e.forEach(D.edges(),function(se){var ae=oe(D.edge(se));X.setEdge(se,e.merge({},P,$(ae,O),e.pick(ae,z)))}),X}function q(D){var X=D.graph();X.ranksep/=2,e.forEach(D.edges(),function(ee){var se=D.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function B(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);if(ee.width&&ee.height){var se=D.node(X.v),ae=D.node(X.w),pe={rank:(ae.rank-se.rank)/2+se.rank,e:X};y.addDummyNode(D,"edge-proxy",pe,"_ep")}})}function J(D){var X=0;e.forEach(D.nodes(),function(ee){var se=D.node(ee);se.borderTop&&(se.minRank=D.node(se.borderTop).rank,se.maxRank=D.node(se.borderBottom).rank,X=e.max(X,se.maxRank))}),D.graph().maxRank=X}function Q(D){e.forEach(D.nodes(),function(X){var ee=D.node(X);ee.dummy==="edge-proxy"&&(D.edge(ee.e).labelRank=ee.rank,D.removeNode(X))})}function A(D){var X=Number.POSITIVE_INFINITY,ee=0,se=Number.POSITIVE_INFINITY,ae=0,pe=D.graph(),ge=pe.marginx||0,Ae=pe.marginy||0;function Pe(Ie){var Me=Ie.x,ke=Ie.y,He=Ie.width,ve=Ie.height;X=Math.min(X,Me-He/2),ee=Math.max(ee,Me+He/2),se=Math.min(se,ke-ve/2),ae=Math.max(ae,ke+ve/2)}e.forEach(D.nodes(),function(Ie){Pe(D.node(Ie))}),e.forEach(D.edges(),function(Ie){var Me=D.edge(Ie);e.has(Me,"x")&&Pe(Me)}),X-=ge,se-=Ae,e.forEach(D.nodes(),function(Ie){var Me=D.node(Ie);Me.x-=X,Me.y-=se}),e.forEach(D.edges(),function(Ie){var Me=D.edge(Ie);e.forEach(Me.points,function(ke){ke.x-=X,ke.y-=se}),e.has(Me,"x")&&(Me.x-=X),e.has(Me,"y")&&(Me.y-=se)}),pe.width=ee-X+ge,pe.height=ae-se+Ae}function H(D){e.forEach(D.edges(),function(X){var ee=D.edge(X),se=D.node(X.v),ae=D.node(X.w),pe,ge;ee.points?(pe=ee.points[0],ge=ee.points[ee.points.length-1]):(ee.points=[],pe=ae,ge=se),ee.points.unshift(y.intersectRect(se,pe)),ee.points.push(y.intersectRect(ae,ge))})}function U(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);if(e.has(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function ne(D){e.forEach(D.edges(),function(X){var ee=D.edge(X);ee.reversed&&ee.points.reverse()})}function Y(D){e.forEach(D.nodes(),function(X){if(D.children(X).length){var ee=D.node(X),se=D.node(ee.borderTop),ae=D.node(ee.borderBottom),pe=D.node(e.last(ee.borderLeft)),ge=D.node(e.last(ee.borderRight));ee.width=Math.abs(ge.x-pe.x),ee.height=Math.abs(ae.y-se.y),ee.x=pe.x+ee.width/2,ee.y=se.y+ee.height/2}}),e.forEach(D.nodes(),function(X){D.node(X).dummy==="border"&&D.removeNode(X)})}function L(D){e.forEach(D.edges(),function(X){if(X.v===X.w){var ee=D.node(X.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:X,label:D.edge(X)}),D.removeEdge(X)}})}function G(D){var X=y.buildLayerMatrix(D);e.forEach(X,function(ee){var se=0;e.forEach(ee,function(ae,pe){var ge=D.node(ae);ge.order=pe+se,e.forEach(ge.selfEdges,function(Ae){y.addDummyNode(D,"selfedge",{width:Ae.label.width,height:Ae.label.height,rank:ge.rank,order:pe+ ++se,e:Ae.e,label:Ae.label},"_se")}),delete ge.selfEdges})})}function k(D){e.forEach(D.nodes(),function(X){var ee=D.node(X);if(ee.dummy==="selfedge"){var se=D.node(ee.e.v),ae=se.x+se.width/2,pe=se.y,ge=ee.x-ae,Ae=se.height/2;D.setEdge(ee.e,ee.label),D.removeNode(X),ee.label.points=[{x:ae+2*ge/3,y:pe-Ae},{x:ae+5*ge/6,y:pe-Ae},{x:ae+ge,y:pe},{x:ae+5*ge/6,y:pe+Ae},{x:ae+2*ge/3,y:pe+Ae}],ee.label.x=ee.x,ee.label.y=ee.y}})}function $(D,X){return e.mapValues(e.pick(D,X),Number)}function oe(D){var X={};return e.forEach(D,function(ee,se){X[se.toLowerCase()]=ee}),X}return wg}var xg,bk;function i$(){if(bk)return xg;bk=1;var e=lt(),n=cn(),i=Kn().Graph;xg={debugOrdering:s};function s(o){var l=n.buildLayerMatrix(o),u=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,f){var h="layer"+f;u.setNode(h,{rank:"same"}),e.reduce(c,function(p,m){return u.setEdge(p,m,{style:"invis"}),m})}),u}return xg}var _g,kk;function s$(){return kk||(kk=1,_g="0.8.5"),_g}var Sg,Ek;function o$(){return Ek||(Ek=1,Sg={graphlib:Kn(),layout:r$(),debug:i$(),util:{time:cn().time,notime:cn().notime},version:s$()}),Sg}var a$=o$();const Nk=Wg(a$),oi=240,Hi=130,Fs=74,cu=72,Ck=Fs+cu;function l$(e){let n=oi;for(const i of e.values())n=Math.max(n,i.width);return n}const u$=420,c$=2;function du(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function d$(e,n,i,s,o){const l=new Nk.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(_=>!o.has(_)),c=new Set(u);for(const _ of u){const S=s.get(_);l.setNode(_,{width:(S==null?void 0:S.width)??oi,height:(S==null?void 0:S.height)??Hi})}for(const _ of n)c.has(_.source)&&c.has(_.target)&&l.setEdge(_.source,_.target);Nk.layout(l);const f=new Map;let h=1/0,p=1/0,m=-1/0,y=-1/0;for(const _ of u){const S=l.node(_);if(!S)continue;const b=s.get(_),E=(b==null?void 0:b.width)??oi,N=(b==null?void 0:b.height)??Hi,C=S.x-E/2,I=S.y-N/2;f.set(_,{x:C,y:I}),C<h&&(h=C),I<p&&(p=I),C+E>m&&(m=C+E),I+N>y&&(y=I+N)}if(Number.isFinite(h)&&Number.isFinite(p))for(const[_,S]of f)f.set(_,{x:S.x-h,y:S.y-p});let w=Number.isFinite(m)?m-h:0,j=Number.isFinite(y)?y-p:0;for(const _ of e){const S=o.get(_);if(!S)continue;const b=s.get(_);w=Math.max(w,S.x+((b==null?void 0:b.width)??oi)),j=Math.max(j,S.y+((b==null?void 0:b.height)??Hi))}return{positions:f,width:w,height:j}}function f$(e,n,i={}){const s=i.direction??"LR",o=i.pinned??new Map,l=i.measured??new Map,u=new Map;for(const S of e){const b=du(S),E=u.get(b);E?E.push(S.id):u.set(b,[S.id])}const f=Array.from(u.keys()).sort().map(S=>({sid:S,...d$(u.get(S),n,s,l,o)})),h=l$(l),p=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,m=S=>{const b=[[]];let E=0;for(const N of f)b.length<S&&E>0&&E+N.height>p&&(b.push([]),E=0),b[b.length-1].push(N),E+=N.height+Ck;return b},y=S=>S.reduce((b,E)=>Math.max(b,E.width),0)+u$;let w=m(i.availableWidth?c$:1);w.length>1&&w.reduce((b,E)=>b+y(E),0)+h*(w.length-1)>(i.availableWidth??0)&&(w=m(1));const j=new Map;let _=0;for(const S of w){let b=0;for(const{positions:E,height:N}of S){for(const[C,I]of E)j.set(C,{x:I.x+_,y:I.y+b});b+=N+Ck}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const E=j.get(S.id);return E?{...S,position:E}:S})}function h$(e,n,i,s){const l=Fs+cu,u=60,c=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??oi,h:(w==null?void 0:w.height)??Hi}},f=new Map(e.map(y=>[y.id,du(y)])),h=[],p=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,w)=>y.pos.y-w.pos.y||y.pos.x-w.pos.x||y.id.localeCompare(w.id)),m=[];for(const{id:y,pos:w}of p){const{w:j,h:_}=c(y),S=f.get(y)??"_default";if(i.has(y)){h.push({x:w.x,y:w.y,w:j,h:_,sid:S});continue}let b=w.y;for(let E=0;E<h.length+1;E++){const N=h.find(C=>{const I=C.sid===S?24:u,O=C.sid===S?24:l;return w.x<C.x+C.w+I&&C.x<w.x+j+I&&b<C.y+C.h+O&&C.y<b+_+O});if(!N)break;b=N.y+N.h+(N.sid===S?24:l)}b!==w.y&&(n.set(y,{x:w.x,y:b}),m.push(y)),h.push({x:w.x,y:b,w:j,h:_,sid:S})}return m}function p$(e,n,i,s,o){const l=y=>{const w=s.get(y);return{w:(w==null?void 0:w.width)??oi,h:(w==null?void 0:w.height)??Hi}},u=y=>i.get(y)??n.get(y),c=new Map,f=[];for(const y of e){const w=u(y.id);if(!w)continue;const{w:j,h:_}=l(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=du(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else f.push({x:w.x,y:w.y,w:j,h:_})}if(c.size===0)return[];const h=Fs+cu,p=(y,w,j,_)=>f.some(S=>y<S.x+S.w+Fs&&S.x<y+j+Fs&&w<S.y+S.h+h&&S.y<w+_+h),m=[];for(const y of[...c.keys()].sort()){const w=c.get(y);let j=1/0,_=1/0,S=-1/0,b=-1/0;for(const z of w){const T=u(z.id),{w:q,h:B}=l(z.id);j=Math.min(j,T.x),_=Math.min(_,T.y),S=Math.max(S,T.x+q),b=Math.max(b,T.y+B)}const E=S-j,N=b-_,C=[...new Set(f.map(z=>Math.round(z.x)))].sort((z,T)=>z-T),I=C.length?C:[j],O=[0,...f.map(z=>z.y+z.h+h)].sort((z,T)=>z-T);let P=null;e:for(const z of I)for(const T of O){if(T>=_)break;if(!p(z,T,E,N)){P={x:z,y:T};break e}}if(P){const z=P.x-j,T=P.y-_;for(const q of w){const B=u(q.id);n.set(q.id,{x:B.x+z,y:B.y+T})}m.push(y)}for(const z of w){const T=u(z.id),{w:q,h:B}=l(z.id);f.push({x:T.x,y:T.y,w:q,h:B})}}return m}function m$(e,n,i,s,o,l=!1){const f=Fs+cu+1,h=8,p=1.75,m=200,y=.7,w=.01,j=T=>{const q=s.get(T);return{w:(q==null?void 0:q.width)??oi,h:(q==null?void 0:q.height)??Hi}},_=T=>i.get(T)??n.get(T),S=new Map;for(const T of e){if(!_(T.id))continue;const q=du(T),B=S.get(q);B?B.push(T):S.set(q,[T])}const b=[],E=new Set,N=new Set,C=o.size===0;for(const T of[...S.keys()].sort()){const q=S.get(T);let B=1/0,J=1/0,Q=-1/0,A=-1/0,H=!1;for(const L of q){const G=_(L.id),{w:k,h:$}=j(L.id);B=Math.min(B,G.x),J=Math.min(J,G.y),Q=Math.max(Q,G.x+k),A=Math.max(A,G.y+$),i.has(L.id)&&(H=!0)}const U=Q-B,ne=A-J;N.add(T);const Y=o.get(T);Y&&(U>Y.w+h||ne>Y.h+h)&&E.add(T),o.set(T,{w:U,h:ne}),b.push({sid:T,members:q.map(L=>L.id),x:B,y:J,w:U,h:ne,anchored:H,mass:1})}for(const T of[...o.keys()])N.has(T)||o.delete(T);if(l||C)return[];let I=!1;for(let T=0;T<b.length&&!I;T++)for(let q=T+1;q<b.length;q++){const B=b[T],J=b[q];if(!(B.anchored&&J.anchored)&&Math.abs(B.x+B.w/2-(J.x+J.w/2))<(B.w+J.w)/2+61&&Math.abs(B.y+B.h/2-(J.y+J.h/2))<(B.h+J.h)/2+f){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const T of b)E.has(T.sid)&&(T.mass=8);else for(const T of b)T.mass=Math.max(1,T.w*T.h/(oi*Hi));const O=new Map(b.map(T=>[T.sid,T.x])),P=new Map(b.map(T=>[T.sid,T.y]));for(let T=0;T<m;T++){const q=new Map,B=new Map;let J=0;for(let Q=0;Q<b.length;Q++)for(let A=Q+1;A<b.length;A++){const H=b[Q],U=b[A];if(H.anchored&&U.anchored)continue;const ne=H.x+H.w/2,Y=H.y+H.h/2,L=U.x+U.w/2,G=U.y+U.h/2,k=(H.w+U.w)/2+61-Math.abs(ne-L),$=(H.h+U.h)/2+f-Math.abs(Y-G);if(k<=0||$<=0)continue;const oe=(We,$e)=>!We.anchored&&!($e<0&&We.x<=0),D=(We,$e)=>!We.anchored&&!($e<0&&We.y<=0),X=(We,$e,Qe)=>{const xt=We===$e,et=xt?H.sid<U.sid?-1:1:Math.sign(We-$e);return Qe(H,et)||Qe(U,-et)?et:xt&&(Qe(H,-et)||Qe(U,et))?-et:0},ee=X(ne,L,oe),se=X(Y,G,D),ae=ee!==0,pe=se!==0;if(!ae&&!pe)continue;const ge=ae&&(!pe||k*p<$),[Ae,Pe,Ie,Me]=ge?[ee,k,q,oe]:[se,$,B,D],ke=Me(H,Ae),He=Me(U,-Ae),ve=H.mass,ye=U.mass,Ve=ke?He?ye/(ve+ye):1:0,mt=He?ke?ve/(ve+ye):1:0,Je=Pe*y;Ie.set(H.sid,(Ie.get(H.sid)??0)+Ae*Je*Ve),Ie.set(U.sid,(Ie.get(U.sid)??0)-Ae*Je*mt),J+=Je}for(const Q of b)Q.anchored||(Q.x=Math.max(0,Q.x+(q.get(Q.sid)??0)),Q.y=Math.max(0,Q.y+(B.get(Q.sid)??0)));if(J<w)break}const z=[];for(const T of b){const q=T.x-O.get(T.sid),B=T.y-P.get(T.sid);if(!(Math.abs(q)<1&&Math.abs(B)<1)){for(const J of T.members){if(i.has(J))continue;const Q=n.get(J);Q&&n.set(J,{x:Q.x+q,y:Q.y+B})}z.push(T.sid)}}return z}const g$=600;function Ug(e,n){return!(e.exitAt!=null&&n-e.exitAt>g$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function v$(e,n){const i=new Set;for(const s of e.agents.values())Ug(s,n)&&i.add(s.id);return i}function $i(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function y$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const w$={agent:NP,sessionGroup:LP},x$=420,bl=18,_$=9e4,S$=200,b$=5*6e4,k$=6,E$=2*6e4,Av="agent-dag.layout",Iv="agent-dag.viewport",mC="agent-dag.summariesDismissed",gC="agent-dag.sessionListOpen",vC="agent-dag.detailOpen",yC="agent-dag.usagePanelOpen",jk="agent-dag.accountsPanelOpen",Rk="agent-dag.versionNoticeDismissed",Tk={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},Ak="agent-dag.autoRestart",Ik="agent-dag.bundleReloadedFor";function N$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(gC)==="1"}catch{return!1}}function C$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(gC,e?"1":"0")}catch{}}function j$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(vC)==="1"}catch{return!1}}function R$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(vC,e?"1":"0")}catch{}}function T$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(yC);try{return e===null?!0:e==="1"}catch{return!0}}function A$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(yC,e?"1":"0")}catch{}}function I$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(mC);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(i=>typeof i=="string"):[])}catch{return new Set}}function Mk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(mC,JSON.stringify(i))}catch{}}function M$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Av);if(!n)return e;const i=JSON.parse(n);if(!("v"in i)){const o=Object.entries(i).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(i.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(i.pins)?i.pins:[]}}catch{return e}}function bg(e,n){if(!(typeof window>"u"))try{const i={};for(const[s,o]of e)i[s]=o;for(const[s,o]of n)i[s]=o;window.localStorage.setItem(Av,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function P$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Iv);if(!e)return null;const n=JSON.parse(e);return typeof(n==null?void 0:n.x)!="number"||typeof(n==null?void 0:n.y)!="number"||typeof(n==null?void 0:n.zoom)!="number"?null:n}catch{return null}}function O$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Iv,JSON.stringify(e))}catch{}}function Pk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Av)}catch{}try{window.localStorage.removeItem(Iv)}catch{}}}function q$(e,n){const i=e.agents.get(n);if(!i)return;const s=[];for(const p of e.agents.values())p.sessionId===n&&s.push(p);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:i.label,cwd:i.cwd,startedAt:i.startedAt,endedAt:i.endedAt,model:i.model,agents:s.map(p=>({id:p.id,kind:p.kind,label:p.label,parentId:p.parentId,state:p.state,startedAt:p.startedAt,endedAt:p.endedAt,model:p.model,cwd:p.cwd,usage:p.usage,prompts:p.prompts,tools:p.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),f=document.createElement("a"),h=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=c,f.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Hg={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Vg={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},L$={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"};function wC(e){return e.startsWith("mcp__")?"mcp":L$[e]??"other"}function xC(e,n){var s,o,l;if(!n)return!0;const i=n.toLowerCase();if(e.label.toLowerCase().includes(i)||(s=e.cwd)!=null&&s.toLowerCase().includes(i)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(i)||e.sessionId.toLowerCase().includes(i)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(i))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(i))return!0;return!1}function $$(e,n){if(!n)return null;const i=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||i.has(l.parentId))break;i.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&i.has(l.parentId)&&!i.has(l.id)&&(i.add(l.id),o=!0)}return i}function D$(e,n,i,s,o,l,u,c,f,h,p,m,y,w,j,_,S,b){const E=[],N=[],C=new Set;if(l)for(const T of e.agents.values())xC(T,l)&&C.add(T.id);for(const T of e.agents.values()){if(!S.has(T.id))continue;const q=l?!C.has(T.id):!1,B=T.exitAt!=null,J=_!=null&&!_.has(T.id),Q=[q?"rf-dim":"",B?"rf-exiting":"",J?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,A=u.get(T.id);if(E.push({id:T.id,type:"agent",position:{x:0,y:0},data:{...T,now:n,dim:q,onOpenContext:b},className:Q,...A?{width:A.width,height:A.height}:null}),T.parentId&&S.has(T.parentId)){const H=dv(T.sessionId),U=T.state==="active"?`hsl(${H} 80% 72%)`:`hsl(${H} 50% 55%)`,ne=l&&!C.has(T.id)&&!C.has(T.parentId),Y=B,L=j.size>0&&(j.has(T.id)||j.has(T.parentId)),G=_!=null&&!_.has(T.id)&&!_.has(T.parentId),k=T.state==="active"?2:1.5,$=L?k+1.5:k,oe=ne||Y?.2:G?.12:1,D=[Y?"rf-edge-exiting":"",L?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;N.push({id:`e:${T.parentId}->${T.id}`,source:T.parentId,target:T.id,animated:(T.state==="active"||L)&&!ne&&!Y,type:"smoothstep",style:{stroke:U,strokeWidth:$,opacity:oe,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:D})}}const I=E.filter(T=>!o.has(T.id)&&!m.has(T.id));if(I.length>0||y!==w.current){if(I.length>0){const T=f$(E,N,{direction:"LR",pinned:o,measured:u,availableWidth:i,availableHeight:s});for(const q of T)m.has(q.id)||m.set(q.id,q.position);p$(E,m,o,u,new Set(I.map(q=>q.id)))}h$(E,m,o,u),w.current=y}const O=m$(E,m,o,u,c,!h||p);O.length>0&&f(O);for(const T of Array.from(m.keys()))e.agents.has(T)||m.delete(T);if(e.agents.size>0)for(const T of Array.from(o.keys()))e.agents.has(T)||o.delete(T);const P=[];let z=!1;for(const T of E){let q=o.get(T.id)??m.get(T.id);q||(q={x:0,y:0},m.set(T.id,q),z=!0),P.push({...T,position:q})}return z&&(w.current=""),{nodes:P,edges:N}}function F$(){return g.jsx(uv,{children:g.jsx(z$,{})})}function z$(){var ha,to,_i,no;const e=ta(),n=M.useRef(Fg()),[,i]=M.useState(0),s=M.useCallback(()=>i(W=>W+1),[]),[o,l]=M.useState(()=>new Set),[u,c]=M.useState(null),[f,h]=M.useState(null),p=M.useCallback((W,Z)=>{l(ue=>{if(!Z)return new Set([W]);const fe=new Set(ue);return fe.has(W)?fe.delete(W):fe.add(W),fe}),c(ue=>Z&&ue===W?ue:W)},[]),m=M.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=M.useState(null),[j,_]=M.useState(null),S=M.useCallback(W=>_(W),[]),b=M.useRef(I$()),[E,N]=M.useState(N$);M.useEffect(()=>{C$(E)},[E]);const[C,I]=M.useState(j$);M.useEffect(()=>{R$(C)},[C]);const[O,P]=M.useState(T$);M.useEffect(()=>{A$(O)},[O]);const[z,T]=M.useState(()=>{try{const W=window.localStorage.getItem(jk);return W===null?!0:W==="1"}catch{return!0}});M.useEffect(()=>{try{window.localStorage.setItem(jk,z?"1":"0")}catch{}},[z]);const[q,B]=M.useState(null),[J,Q]=M.useState(!1),[A,H]=M.useState(0),[U,ne]=M.useState(0);M.useEffect(()=>{fetch("/api/sound-hook").then(W=>W.ok?W.json():null).then(W=>{W!=null&&W.ok&&(B(W.enabled===!0),H((W.foreign??[]).filter(Z=>Z.worksHere).length),ne(typeof W.parked=="number"?W.parked:0))}).catch(()=>{})},[]);const Y=M.useCallback(async()=>{Q(!0);try{const Z=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!q})})).json().catch(()=>null);Z!=null&&Z.ok&&B(Z.enabled===!0),fetch("/api/sound-hook").then(ue=>ue.ok?ue.json():null).then(ue=>{ue!=null&&ue.ok&&(H((ue.foreign??[]).filter(fe=>fe.worksHere).length),ne(typeof ue.parked=="number"?ue.parked:0))}).catch(()=>{})}catch{}finally{Q(!1)}},[q]),[L,G]=M.useState(!1),[k,$]=M.useState(null),[oe,D]=M.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Rk)??""}catch{return""}}),[X,ee]=M.useState(!1),se=M.useCallback(()=>{fetch("/api/version").then(W=>W.ok?W.json():null).then(W=>{W&&$(W)}).catch(()=>{})},[]);M.useEffect(()=>{se();const W=window.setInterval(se,5*6e4),Z=()=>{document.visibilityState==="visible"&&se()};return document.addEventListener("visibilitychange",Z),()=>{window.clearInterval(W),document.removeEventListener("visibilitychange",Z)}},[se]),M.useEffect(()=>{L&&se()},[L,se]);const ae=(k==null?void 0:k.notice)??null,pe=ae?`${ae.kind}:${ae.to}`:"",ge=ae!=null&&oe!==pe,Ae=M.useCallback(()=>{if(!ae)return;const W=oe===pe?"":pe;D(W);try{window.localStorage.setItem(Rk,W)}catch{}},[ae,pe,oe]),Pe=((ha=k==null?void 0:k.upgrade)==null?void 0:ha.state)??"idle",Ie=M.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}se()},[se]);M.useEffect(()=>{if(Pe!=="running")return;const W=window.setInterval(se,3e3);return()=>window.clearInterval(W)},[Pe,se]);const Me=M.useCallback(async()=>{var ue;const W=k==null?void 0:k.command;if(!W)return;let Z=!1;try{Z=await Promise.race([((ue=navigator.clipboard)==null?void 0:ue.writeText(W).then(()=>!0))??Promise.resolve(!1),new Promise(fe=>window.setTimeout(()=>fe(!1),500))])}catch{Z=!1}if(!Z)try{const fe=document.createElement("textarea");fe.value=W,fe.setAttribute("readonly",""),fe.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(fe),fe.select(),Z=document.execCommand("copy"),fe.remove()}catch{Z=!1}Z&&(ee(!0),window.setTimeout(()=>ee(!1),1600))},[k==null?void 0:k.command]),ke=M.useCallback(()=>{N(W=>(W||T(!1),!W))},[]),He=M.useCallback(()=>{T(W=>(W||N(!1),!W))},[]),[ve,ye]=M.useState(!1),[Ve,mt]=M.useState(0),Je=M.useRef(null),[We,$e]=M.useState(0),[Qe,xt]=M.useState(!1),et=M.useRef([]),[Ge,_t]=M.useState(Date.now()),[It,Bt]=M.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Ak)!=="0"}catch{return!0}}),tt=M.useCallback(()=>{Bt(W=>{const Z=!W;try{window.localStorage.setItem(Ak,Z?"1":"0")}catch{}return Z})},[]),[gt,ut]=M.useState(!1),[St,qn]=M.useState("restart"),[Ut,Lt]=M.useState(null),Yt=M.useRef(!1),vn=M.useCallback(async W=>{if(Yt.current)return;const Z=(W==null?void 0:W.upgrade)===!0;Yt.current=!0,qn(Z?"npx":"restart"),ut(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ae==null?void 0:ae.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Z})})}catch{}window.setTimeout(()=>{if(Yt.current){Yt.current=!1,ut(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Z?18e4:3e4)},[ae==null?void 0:ae.to]),yn=M.useRef(null);M.useEffect(()=>{let W=!1;for(const ue of n.current.agents.values())if(ue.state==="active"){W=!0;break}const Z=z3({enabled:It,kind:ae==null?void 0:ae.kind,canRestart:(k==null?void 0:k.canRestart)===!0,busy:W,idleSince:yn.current,now:Ge});yn.current=Z.idleSince,Z.restart&&vn()},[It,ae==null?void 0:ae.kind,k==null?void 0:k.canRestart,Ge,vn]),M.useEffect(()=>{let W=null;try{W=window.sessionStorage.getItem(Ik)}catch{return}if(F3({bundle:"1.33.4",running:k==null?void 0:k.running,lastTried:W})){try{window.sessionStorage.setItem(Ik,(k==null?void 0:k.running)??"")}catch{return}window.location.reload()}},[k==null?void 0:k.running]),M.useEffect(()=>{const W=k==null?void 0:k.running;if(!W)return;let Z=null;try{Z=window.sessionStorage.getItem("agent-dag.restartPending")}catch{return}if(Z==null||Z&&Z!==W)return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Yt.current=!1,ut(!1),Lt(W);const ue=window.setTimeout(()=>Lt(null),6e3);return()=>window.clearTimeout(ue)},[k==null?void 0:k.running]);const Jt=M.useRef(M$()).current;M.useRef(!1);const ct=M.useRef(new Map(Jt.positions.filter(([W])=>Jt.pins.includes(W)))),Kt=M.useRef(null),cr=M.useState(()=>P$())[0],[wn,li]=M.useState(""),[ui,ci]=M.useState(()=>new Set),[Zn,Jn]=M.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[Mr,dr]=M.useState(!1),Qi=M.useRef(null);M.useEffect(()=>{document.documentElement.dataset.theme=Zn;try{window.localStorage.setItem("agent-dag.theme",Zn)}catch{}},[Zn]),M.useEffect(()=>{if(!cr)return;const W=window.setTimeout(()=>{try{e.setViewport(cr,{duration:0})}catch{}},60);return()=>window.clearTimeout(W)},[e,cr]);const er=M.useRef(!0),bt=M.useRef(null);M.useEffect(()=>{const W=new EventSource("/events");return W.addEventListener("open",()=>{G(!0),dr(!0)}),W.addEventListener("error",()=>G(!1)),W.addEventListener("replay-end",()=>{er.current=!1,bt.current!=null&&(window.clearTimeout(bt.current),bt.current=null),s()}),W.addEventListener("hook",Z=>{try{const ue=JSON.parse(Z.data);if(Qe){et.current.push(ue);return}n.current=Gw(n.current,ue),ue.replay===!0||er.current||Date.now()-ue.receivedAt>3e4?(bt.current!=null&&window.clearTimeout(bt.current),bt.current=window.setTimeout(()=>{bt.current=null,s()},120)):(bt.current!=null&&(window.clearTimeout(bt.current),bt.current=null),s())}catch{}}),()=>{W.close(),bt.current!=null&&(window.clearTimeout(bt.current),bt.current=null)}},[Qe,s]),M.useEffect(()=>{if(!Qe&&et.current.length!==0){for(const W of et.current)n.current=Gw(n.current,W);et.current.length=0,s()}},[Qe,s]),M.useEffect(()=>{const W=setInterval(()=>{const Z=Date.now();_t(Z);let ue=cP(n.current,Z,_$);lP(n.current,Z,S$,b$)&&(ue=!0),uP(n.current,Z,k$,E$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(W)},[s]);const tr=M.useRef(null),xn=M.useRef(0),Xs=420,en=M.useCallback((W=500)=>{try{const _e=document.querySelector(".canvas-wrap"),Oe=Array.from(document.querySelectorAll(".react-flow__node")).filter(it=>it.offsetWidth>0);if(!_e||Oe.length===0)return;const De=_e.getBoundingClientRect(),Ke=e.getViewport();if(!Number.isFinite(Ke.zoom)||Ke.zoom<=0)return;const Xe=it=>(it-De.left-Ke.x)/Ke.zoom,rt=it=>(it-De.top-Ke.y)/Ke.zoom,Ct=Oe.map(it=>it.getBoundingClientRect()),gr=Math.min(...Ct.map(it=>Xe(it.left))),Lr=Math.max(...Ct.map(it=>Xe(it.right))),$r=Math.min(...Ct.map(it=>rt(it.top))),Dr=Math.max(...Ct.map(it=>rt(it.bottom))),Si=Lr-gr,bi=Dr-$r;if(!(Si>0&&bi>0))return;const ft=Math.max(.2,Math.min(1,(De.width-160)/(Si+Xs)*.86,(De.height-160)/bi*.86));e.setViewport({x:80-gr*ft,y:Math.max(80,(De.height-bi*ft)/2)-$r*ft,zoom:ft},{duration:W}),xn.current=Date.now(),window.setTimeout(()=>{try{const it={x:80-gr*ft,y:Math.max(80,(De.height-bi*ft)/2)-$r*ft,zoom:ft},us=e.getViewport();(Math.abs(us.zoom-ft)>.01||Math.abs(us.x-it.x)>2)&&e.setViewport(it,{duration:0})}catch{}},W+60)}catch{}},[e]),Pr=M.useRef(""),dn=M.useRef(null),di=M.useRef(0),fr=M.useCallback(()=>{di.current=Date.now()},[]),fi="agent-dag.autoFitDisabled",_n=M.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(fi)==="1"}catch{return!1}})()),[hi,pi]=M.useState(_n.current),mi=M.useCallback(()=>{if(!_n.current){_n.current=!0,pi(!0);try{window.localStorage.setItem(fi,"1")}catch{}}},[]),Zi=M.useCallback(()=>{_n.current=!1,pi(!1);try{window.localStorage.removeItem(fi)}catch{}en(400)},[e,en]);M.useEffect(()=>{const W=setInterval(()=>{if(_n.current||Date.now()-di.current<800)return;const Z=n.current,ue=Date.now(),fe=[];for(const Xe of Z.agents.values())Ug(Xe,ue)&&fe.push({id:Xe.id});if(fe.length===0)return;const we=e.getViewport(),_e=window.innerWidth-360,Oe=window.innerHeight-52;let De=!1,Ke=!1;for(const{id:Xe}of fe){const rt=Ye.current.get(Xe),Ct=ct.current.get(Xe)??$t.current.get(Xe);if(!rt||!Ct)continue;Ke=!0;const gr=Ct.x*we.zoom+we.x,Lr=Ct.y*we.zoom+we.y,$r=(Ct.x+rt.width)*we.zoom+we.x,Dr=(Ct.y+rt.height)*we.zoom+we.y;if($r>0&&gr<_e&&Dr>0&&Lr<Oe){De=!0;break}}Ke&&!De&&en(600)},1500);return()=>clearInterval(W)},[e]);const gi=M.useRef(!1),Ye=M.useRef(new Map),Ji=M.useRef(0),vi=M.useCallback(W=>{const Z=Ye.current;let ue=!1;for(const fe of W.nodeInternals.values()){const we=fe.width,_e=fe.height;if(we==null||_e==null)continue;const Oe=Z.get(fe.id);Oe?(Math.abs(Oe.height-_e)>4||Math.abs(Oe.width-we)>4)&&(Z.set(fe.id,{width:we,height:_e}),ue=!0):(Z.set(fe.id,{width:we,height:_e}),ue=!0)}return ue&&(Ji.current+=1),Ji.current},[]),yi=Ze(vi),[hr,es]=M.useState(0);M.useEffect(()=>{let W=0;const Z=()=>{const fe=Ye.current;let we=!1;for(const _e of document.querySelectorAll(".react-flow__node[data-id]")){const Oe=_e.getAttribute("data-id");if(!Oe)continue;const De=_e.offsetWidth,Ke=_e.offsetHeight;if(!De||!Ke)continue;const Xe=fe.get(Oe);(!Xe||Math.abs(Xe.width-De)>4||Math.abs(Xe.height-Ke)>4)&&(fe.set(Oe,{width:De,height:Ke}),we=!0)}we&&es(_e=>_e+1)};if(gi.current)return;let ue=0;return document.visibilityState==="hidden"?ue=window.setTimeout(Z,32):W=requestAnimationFrame(Z),()=>{cancelAnimationFrame(W),window.clearTimeout(ue)}});const $t=M.useRef(new Map(Jt.positions)),nr=M.useRef(""),Nt=M.useMemo(()=>{const W=[];for(const Z of n.current.agents.values())Ug(Z,Ge)&&W.push(Z.id+(Z.parentId?`>${Z.parentId}`:""));return W.sort(),`${W.join("|")}#sv${yi}.${hr}`},[n.current,n.current.lastSeq,Ge,yi,hr]),Ln=M.useRef(null);M.useEffect(()=>(Ln.current!=null&&window.clearTimeout(Ln.current),Ln.current=window.setTimeout(()=>{bg($t.current,ct.current)},1500),()=>{Ln.current!=null&&window.clearTimeout(Ln.current)}),[Nt]),M.useEffect(()=>{if(Pr.current===Nt)return;const W=Pr.current;if(Pr.current=Nt,!W||_n.current)return;Date.now()-xn.current>1200&&en(400),tr.current&&window.clearTimeout(tr.current),tr.current=window.setTimeout(()=>{_n.current||en(500)},280)},[Nt,e,en]);const Xt=M.useMemo(()=>{if(o.size===0)return null;const W=new Set;for(const Z of o){const ue=$$(n.current,Z);if(ue)for(const fe of ue)W.add(fe)}return W.size>0?W:null},[n.current,n.current.lastSeq,o]),Qs=M.useMemo(()=>v$(n.current,Ge),[n.current,n.current.lastSeq,Ge]),la=M.useRef(null),[ts,wi]=M.useState({w:0,h:0});M.useEffect(()=>{const W=la.current;if(!W||typeof ResizeObserver>"u")return;const Z=new ResizeObserver(ue=>{var we;const fe=(we=ue[0])==null?void 0:we.contentRect;fe&&wi(_e=>Math.abs(_e.w-fe.width)>40||Math.abs(_e.h-fe.height)>40?{w:fe.width,h:fe.height}:_e)});return Z.observe(W),wi({w:W.clientWidth,h:W.clientHeight}),()=>Z.disconnect()},[]);const ns=M.useRef(new Map),[Or,rs]=M.useState(!1);M.useEffect(()=>{const W=window.setTimeout(()=>rs(!0),2500);return()=>window.clearTimeout(W)},[]);const[fu,Zs]=M.useState(!1),Sn=M.useRef(null),[is,ss]=M.useState(!1),xi=M.useCallback(()=>{Sn.current&&(window.clearTimeout(Sn.current),Sn.current=null),Zs(!1)},[]),hu=M.useCallback(W=>{W.length!==0&&queueMicrotask(()=>{Zs(!0),Sn.current&&window.clearTimeout(Sn.current),Sn.current=window.setTimeout(()=>Zs(!1),x$+80)})},[]);M.useEffect(()=>()=>{Sn.current&&window.clearTimeout(Sn.current)},[]);const os=ts.w>0?ts.w*.92:0,Be=ts.h>0?ts.h:0,{nodes:fn,edges:ua}=M.useMemo(()=>D$(n.current,Ge,os,Be,ct.current,wn,Ye.current,ns.current,hu,Or,is,$t.current,Nt,nr,o,Xt,Qs,S),[n.current,n.current.lastSeq,Ge,os,Be,Or,is,wn,Nt,o,Xt,Qs,S,Ve]),as=M.useMemo(()=>{const W=new Map;for(const ue of fn){const fe=ue.data;if(!(fe!=null&&fe.sessionId)||fe.exitAt!=null)continue;const we=ue.width,_e=ue.height;if(we==null||_e==null)continue;const Oe=ue.position.x,De=ue.position.y,Ke=Oe+we,Xe=De+_e,rt=W.get(fe.sessionId);rt?(rt.minX=Math.min(rt.minX,Oe),rt.minY=Math.min(rt.minY,De),rt.maxX=Math.max(rt.maxX,Ke),rt.maxY=Math.max(rt.maxY,Xe)):W.set(fe.sessionId,{minX:Oe,minY:De,maxX:Ke,maxY:Xe})}const Z=[];for(const[ue,fe]of W){const we=fe.maxX-fe.minX+bl*2,_e=fe.maxY-fe.minY+bl*2;Z.push({id:`group:${ue}`,type:"sessionGroup",position:{x:fe.minX-bl,y:fe.minY-bl},data:{sessionId:ue,w:we,h:_e},width:we,height:_e,style:{width:we,height:_e},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Z},[fn,Ge]),ca=M.useMemo(()=>{const W=[...as,...fn],Z=Je.current;return!Z||Z.size===0?W:W.map(ue=>{const fe=Z.get(ue.id);return fe?{...ue,position:fe}:ue})},[as,fn,We]),da=M.useMemo(()=>{if(!wn)return null;const W=new Set;for(const Z of n.current.agents.values())xC(Z,wn)&&W.add(Z.id);return W},[n.current,n.current.lastSeq,wn]),Js=M.useMemo(()=>{const W=new Set;for(const Z of n.current.agents.values())for(const ue of Z.tools)W.add(wC(ue.name));return Object.keys(Hg).filter(Z=>W.has(Z))},[n.current,n.current.lastSeq]),pr=M.useMemo(()=>{const W=new Map;for(const ue of n.current.agents.values())for(const fe of ue.tools){if(!fe.name.startsWith("mcp__"))continue;const we=fe.name.slice(5),_e=we.indexOf("__"),Oe=_e>0?we.slice(0,_e):we;W.set(Oe,(W.get(Oe)??0)+1)}const Z=[];for(const[ue,fe]of W){let we=5381;for(let _e=0;_e<ue.length;_e++)we=(we<<5)+we^ue.charCodeAt(_e);Z.push({server:ue,count:fe,hue:Math.abs(we)%360})}return Z.sort((ue,fe)=>fe.count-ue.count),Z},[n.current,n.current.lastSeq]),ls=M.useCallback(W=>{ci(Z=>{const ue=new Set(Z);return ue.has(W)?ue.delete(W):ue.add(W),ue})},[]),dt=u?n.current.agents.get(u):null,$n=f?Array.from(n.current.agents.values()).flatMap(W=>W.tools).find(W=>W.id===f)??null:null,bn=M.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Fg(),ct.current.clear(),Ye.current.clear(),$t.current.clear(),nr.current="",Pk(),m(),s()},[s,m]),mr=M.useCallback(()=>{ct.current.clear(),$t.current.clear(),nr.current="",Pk(),s(),window.setTimeout(()=>en(500),80)},[s,e,en]),qr=M.useCallback(()=>en(500),[en]),kn=M.useCallback(W=>{if(fn.length===0)return;const Z=fn.slice().sort((_e,Oe)=>_e.position.y-Oe.position.y||_e.position.x-Oe.position.x),ue=u?Z.findIndex(_e=>_e.id===u):-1;let fe;ue===-1?fe=W===1?0:Z.length-1:fe=(ue+W+Z.length)%Z.length;const we=Z[fe];we&&(p(we.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[we]})}catch{}xn.current=Date.now()},30))},[fn,u,p,e]);M.useEffect(()=>{const W=Z=>{var fe,we;const ue=((fe=Z.target)==null?void 0:fe.tagName)==="INPUT";if(Z.key==="Escape"){ue?Z.target.blur():m();return}if(!ue){if(Z.key==="/"){Z.preventDefault(),(we=Qi.current)==null||we.focus();return}Z.key===" "&&(Z.preventDefault(),xt(_e=>!_e)),(Z.key==="c"||Z.key==="C")&&bn(),(Z.key==="r"||Z.key==="R")&&mr(),(Z.key==="f"||Z.key==="F")&&qr(),(Z.key==="l"||Z.key==="L")&&ke(),(Z.key==="h"||Z.key==="H")&&ye(_e=>!_e),(Z.key==="u"||Z.key==="U")&&P(_e=>!_e),(Z.key==="a"||Z.key==="A")&&He(),(Z.key==="j"||Z.key==="J")&&kn(1),(Z.key==="k"||Z.key==="K")&&kn(-1),(Z.key==="t"||Z.key==="T")&&Jn(_e=>_e==="dark"?"light":"dark")}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[bn,mr,qr,m,kn]);const eo=n.current.agents.size,fa=new Set(Array.from(n.current.agents.values()).map(W=>W.sessionId)).size,Mt=M.useMemo(()=>{let W=0,Z=0,ue=0,fe=0,we=0,_e=0,Oe=0,De=0,Ke=0;for(const Xe of n.current.agents.values()){W+=Xe.usage.inputTokens,Z+=Xe.usage.outputTokens,ue+=Xe.usage.cacheReadTokens,fe+=Xe.usage.cacheCreateTokens;const rt=un(Xe.usage,Xe.model);we+=rt.total,_e+=rt.input,Oe+=rt.output,De+=rt.cacheRead,Ke+=rt.cacheWrite}return{inT:W,outT:Z,cacheR:ue,cacheC:fe,sum:W+Z,cost:{total:we,input:_e,output:Oe,cacheRead:De,cacheWrite:Ke}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),"agents-deck",ae?g.jsxs("button",{type:"button",className:"v stale",onClick:Ae,title:ae.kind==="restart"?`Running v${ae.from}; v${ae.to} is installed on disk. Restart to pick it up.`:`Running v${ae.from}; v${ae.to} is on npm.`,children:["v",ae.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):g.jsxs("span",{className:"v",children:["v",(k==null?void 0:k.running)??"1.33.4"]})]}),dt&&(()=>{const W=un(dt.usage,dt.model),Z=Math.max(0,((dt.endedAt??Ge)-dt.startedAt)/1e3),ue=dt.state==="active"?$l(W.total,Z):null,fe=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${dt.label}`,onClick:()=>{try{const we=fn.find(_e=>_e.id===dt.id);we&&e.fitView({padding:.35,duration:500,nodes:[we]}),xn.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${dt.state}`,children:dt.state==="active"?"live":dt.state}),g.jsx("span",{className:"selected-label",children:dt.label}),W.total>0&&g.jsxs("span",{className:"selected-cost",children:[ze(W.total),ue?g.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),fe>0&&g.jsxs("span",{className:"selected-extra",children:["+",fe]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:we=>{we.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:Qi,type:"text",placeholder:"Search agents, cwd, tools…",value:wn,onChange:W=>li(W.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),wn?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>li(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${L?"live":"dead"}`,title:L?"Receiving events":"SSE disconnected",children:L?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:fa}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:eo}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:"Total hook events received",children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),Mt.sum>0&&g.jsxs("span",{className:"stat",title:`in:${Mt.inT.toLocaleString()} out:${Mt.outT.toLocaleString()} cache-r:${Mt.cacheR.toLocaleString()} cache-c:${Mt.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:y$(Mt.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),pr.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
60
60
|
${pr.map(W=>` ${W.server}: ${W.count} call${W.count===1?"":"s"}`).join(`
|
|
61
61
|
`)}`,children:[pr.slice(0,6).map(W=>g.jsx("span",{className:"mcp-dot",style:{background:`hsl(${W.hue} 65% 65%)`}},W.server)),pr.length>6&&g.jsxs("span",{className:"mcp-more",children:["+",pr.length-6]}),g.jsx("span",{className:"lbl",children:"mcp"})]}),Mt.cost.total>0&&(()=>{let W=0,Z=0;for(const we of n.current.agents.values()){if(we.state!=="active")continue;const _e=un(we.usage,we.model);W+=_e.total,Z=Math.max(Z,((we.endedAt??Ge)-we.startedAt)/1e3)}const ue=Z>0?$l(W,Z):null,fe=`input ${ze(Mt.cost.input)} + output ${ze(Mt.cost.output)} + cache r ${ze(Mt.cost.cacheRead)} + cache w ${ze(Mt.cost.cacheWrite)}${ue?`
|
|
62
62
|
active burn: ${ue}`:""}`;return g.jsxs("span",{className:"stat",title:fe,children:[g.jsx("span",{className:"count",children:ze(Mt.cost.total)}),g.jsxs("span",{className:"lbl",children:["cost",ue?` · ${ue}`:""]})]})})()]}),g.jsx("button",{className:`btn ${Qe?"warn":""}`,onClick:()=>xt(W=>!W),title:"Pause/resume live updates (Space)",children:Qe?`Resume${et.current.length?` · ${et.current.length}`:""}`:"Pause"}),g.jsx("button",{className:`btn icon-btn ${O?"primary":""}`,onClick:()=>P(W=>!W),title:`${O?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel",children:"$"}),q!==null&&g.jsx("button",{className:`btn icon-btn ${q?"primary":""}`,onClick:W=>{if(W.shiftKey&&U>0){Q(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(Z=>Z.ok?Z.json():null).then(Z=>{Z!=null&&Z.ok&&(B(Z.enabled===!0),ne(Z.parked??0))}).catch(()=>{}).finally(()=>Q(!1));return}Y()},disabled:J,title:(q?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook")+(A>0?`
|