agent-dag 1.30.6 → 1.30.7

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: `+w.message+`
56
56
  */var Y0;function QT(){if(Y0)return Ic;Y0=1;var e=Lo(),n=XT();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,u=e.useRef,l=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Ic.useSyncExternalStoreWithSelector=function(h,p,m,y,x){var N=u(null);if(N.current===null){var _={hasValue:!1,value:null};N.current=_}else _=N.current;N=c(function(){function b(P){if(!k){if(k=!0,E=P,P=y(P),x!==void 0&&_.hasValue){var I=_.value;if(x(I,P))return C=I}return C=P}if(I=C,s(E,P))return I;var M=y(P);return x!==void 0&&x(I,M)?(E=P,I):(E=P,C=M)}var k=!1,E,C,A=m===void 0?null:m;return[function(){return b(p())},A===null?void 0:function(){return b(A())}]},[p,m,y,x]);var S=o(h,N[0],N[1]);return l(function(){_.hasValue=!0,_.value=S},[S]),d(S),S},Ic}var K0;function ZT(){return K0||(K0=1,Ac.exports=QT()),Ac.exports}var JT=ZT();const eR=Mg(JT),tR={},X0=e=>{let n;const i=new Set,s=(p,m)=>{const y=typeof p=="function"?p(n):p;if(!Object.is(y,n)){const x=n;n=m??(typeof y!="object"||y===null)?y:Object.assign({},n,y),i.forEach(N=>N(n,x))}},o=()=>n,d={setState:s,getState:o,getInitialState:()=>h,subscribe:p=>(i.add(p),()=>i.delete(p)),destroy:()=>{(tR?"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,d);return d},nR=e=>e?X0(e):X0,{useDebugValue:rR}=oe,{useSyncExternalStoreWithSelector:iR}=eR,sR=e=>e;function Ek(e,n=sR,i){const s=iR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,i);return rR(s),s}const Q0=(e,n)=>{const i=nR(e),s=(o,u=n)=>Ek(i,o,u);return Object.assign(s,i),s},oR=(e,n)=>e?Q0(e,n):Q0;function St(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 aR={value:()=>{}};function Nu(){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 cu(i)}function cu(e){this._=e}function uR(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}})}cu.prototype=Nu.prototype={constructor:cu,on:function(e,n){var i=this._,s=uR(e+"",i),o,u=-1,l=s.length;if(arguments.length<2){for(;++u<l;)if((o=(e=s[u]).type)&&(o=lR(i[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++u<l;)if(o=(e=s[u]).type)i[o]=Z0(i[o],e.name,n);else if(n==null)for(o in i)i[o]=Z0(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 cu(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var i=new Array(o),s=0,o,u;s<o;++s)i[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(u=this._[e],s=0,o=u.length;s<o;++s)u[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,u=s.length;o<u;++o)s[o].value.apply(n,i)}};function lR(e,n){for(var i=0,s=e.length,o;i<s;++i)if((o=e[i]).name===n)return o.value}function Z0(e,n,i){for(var s=0,o=e.length;s<o;++s)if(e[s].name===n){e[s]=aR,e=e.slice(0,s).concat(e.slice(s+1));break}return i!=null&&e.push({name:n,value:i}),e}var fg="http://www.w3.org/1999/xhtml";const J0={svg:"http://www.w3.org/2000/svg",xhtml:fg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Cu(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),J0.hasOwnProperty(n)?{space:J0[n],local:e}:e}function cR(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===fg&&n.documentElement.namespaceURI===fg?n.createElement(e):n.createElementNS(i,e)}}function fR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Nk(e){var n=Cu(e);return(n.local?fR:cR)(n)}function dR(){}function Pg(e){return e==null?dR:function(){return this.querySelector(e)}}function hR(e){typeof e!="function"&&(e=Pg(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var u=n[o],l=u.length,c=s[o]=new Array(l),d,h,p=0;p<l;++p)(d=u[p])&&(h=e.call(d,d.__data__,p,u))&&("__data__"in d&&(h.__data__=d.__data__),c[p]=h);return new gn(s,this._parents)}function pR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function mR(){return[]}function Ck(e){return e==null?mR:function(){return this.querySelectorAll(e)}}function gR(e){return function(){return pR(e.apply(this,arguments))}}function vR(e){typeof e=="function"?e=gR(e):e=Ck(e);for(var n=this._groups,i=n.length,s=[],o=[],u=0;u<i;++u)for(var l=n[u],c=l.length,d,h=0;h<c;++h)(d=l[h])&&(s.push(e.call(d,d.__data__,h,l)),o.push(d));return new gn(s,o)}function Tk(e){return function(){return this.matches(e)}}function Rk(e){return function(n){return n.matches(e)}}var yR=Array.prototype.find;function wR(e){return function(){return yR.call(this.children,e)}}function xR(){return this.firstElementChild}function _R(e){return this.select(e==null?xR:wR(typeof e=="function"?e:Rk(e)))}var SR=Array.prototype.filter;function bR(){return Array.from(this.children)}function kR(e){return function(){return SR.call(this.children,e)}}function ER(e){return this.selectAll(e==null?bR:kR(typeof e=="function"?e:Rk(e)))}function NR(e){typeof e!="function"&&(e=Tk(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var u=n[o],l=u.length,c=s[o]=[],d,h=0;h<l;++h)(d=u[h])&&e.call(d,d.__data__,h,u)&&c.push(d);return new gn(s,this._parents)}function jk(e){return new Array(e.length)}function CR(){return new gn(this._enter||this._groups.map(jk),this._parents)}function pu(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}pu.prototype={constructor:pu,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 TR(e){return function(){return e}}function RR(e,n,i,s,o,u){for(var l=0,c,d=n.length,h=u.length;l<h;++l)(c=n[l])?(c.__data__=u[l],s[l]=c):i[l]=new pu(e,u[l]);for(;l<d;++l)(c=n[l])&&(o[l]=c)}function jR(e,n,i,s,o,u,l){var c,d,h=new Map,p=n.length,m=u.length,y=new Array(p),x;for(c=0;c<p;++c)(d=n[c])&&(y[c]=x=l.call(d,d.__data__,c,n)+"",h.has(x)?o[c]=d:h.set(x,d));for(c=0;c<m;++c)x=l.call(e,u[c],c,u)+"",(d=h.get(x))?(s[c]=d,d.__data__=u[c],h.delete(x)):i[c]=new pu(e,u[c]);for(c=0;c<p;++c)(d=n[c])&&h.get(y[c])===d&&(o[c]=d)}function AR(e){return e.__data__}function IR(e,n){if(!arguments.length)return Array.from(this,AR);var i=n?jR:RR,s=this._parents,o=this._groups;typeof e!="function"&&(e=TR(e));for(var u=o.length,l=new Array(u),c=new Array(u),d=new Array(u),h=0;h<u;++h){var p=s[h],m=o[h],y=m.length,x=MR(e.call(p,p&&p.__data__,h,s)),N=x.length,_=c[h]=new Array(N),S=l[h]=new Array(N),b=d[h]=new Array(y);i(p,m,_,S,b,x,n);for(var k=0,E=0,C,A;k<N;++k)if(C=_[k]){for(k>=E&&(E=k+1);!(A=S[E])&&++E<N;);C._next=A||null}}return l=new gn(l,s),l._enter=c,l._exit=d,l}function MR(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function PR(){return new gn(this._exit||this._groups.map(jk),this._parents)}function OR(e,n,i){var s=this.enter(),o=this,u=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?u.remove():i(u),s&&o?s.merge(o).order():o}function qR(e){for(var n=e.selection?e.selection():e,i=this._groups,s=n._groups,o=i.length,u=s.length,l=Math.min(o,u),c=new Array(o),d=0;d<l;++d)for(var h=i[d],p=s[d],m=h.length,y=c[d]=new Array(m),x,N=0;N<m;++N)(x=h[N]||p[N])&&(y[N]=x);for(;d<o;++d)c[d]=i[d];return new gn(c,this._parents)}function LR(){for(var e=this._groups,n=-1,i=e.length;++n<i;)for(var s=e[n],o=s.length-1,u=s[o],l;--o>=0;)(l=s[o])&&(u&&l.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(l,u),u=l);return this}function $R(e){e||(e=DR);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),u=0;u<s;++u){for(var l=i[u],c=l.length,d=o[u]=new Array(c),h,p=0;p<c;++p)(h=l[p])&&(d[p]=h);d.sort(n)}return new gn(o,this._parents).order()}function DR(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function FR(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function zR(){return Array.from(this)}function BR(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var s=e[n],o=0,u=s.length;o<u;++o){var l=s[o];if(l)return l}return null}function UR(){let e=0;for(const n of this)++e;return e}function HR(){return!this.node()}function VR(e){for(var n=this._groups,i=0,s=n.length;i<s;++i)for(var o=n[i],u=0,l=o.length,c;u<l;++u)(c=o[u])&&e.call(c,c.__data__,u,o);return this}function WR(e){return function(){this.removeAttribute(e)}}function GR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function YR(e,n){return function(){this.setAttribute(e,n)}}function KR(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function XR(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function QR(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 ZR(e,n){var i=Cu(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?GR:WR:typeof n=="function"?i.local?QR:XR:i.local?KR:YR)(i,n))}function Ak(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function JR(e){return function(){this.style.removeProperty(e)}}function e2(e,n,i){return function(){this.style.setProperty(e,n,i)}}function t2(e,n,i){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,i)}}function n2(e,n,i){return arguments.length>1?this.each((n==null?JR:typeof n=="function"?t2:e2)(e,n,i??"")):Ts(this.node(),e)}function Ts(e,n){return e.style.getPropertyValue(n)||Ak(e).getComputedStyle(e,null).getPropertyValue(n)}function r2(e){return function(){delete this[e]}}function i2(e,n){return function(){this[e]=n}}function s2(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function o2(e,n){return arguments.length>1?this.each((n==null?r2:typeof n=="function"?s2:i2)(e,n)):this.node()[e]}function Ik(e){return e.trim().split(/^|\s+/)}function Og(e){return e.classList||new Mk(e)}function Mk(e){this._node=e,this._names=Ik(e.getAttribute("class")||"")}Mk.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 Pk(e,n){for(var i=Og(e),s=-1,o=n.length;++s<o;)i.add(n[s])}function Ok(e,n){for(var i=Og(e),s=-1,o=n.length;++s<o;)i.remove(n[s])}function a2(e){return function(){Pk(this,e)}}function u2(e){return function(){Ok(this,e)}}function l2(e,n){return function(){(n.apply(this,arguments)?Pk:Ok)(this,e)}}function c2(e,n){var i=Ik(e+"");if(arguments.length<2){for(var s=Og(this.node()),o=-1,u=i.length;++o<u;)if(!s.contains(i[o]))return!1;return!0}return this.each((typeof n=="function"?l2:n?a2:u2)(i,n))}function f2(){this.textContent=""}function d2(e){return function(){this.textContent=e}}function h2(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function p2(e){return arguments.length?this.each(e==null?f2:(typeof e=="function"?h2:d2)(e)):this.node().textContent}function m2(){this.innerHTML=""}function g2(e){return function(){this.innerHTML=e}}function v2(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function y2(e){return arguments.length?this.each(e==null?m2:(typeof e=="function"?v2:g2)(e)):this.node().innerHTML}function w2(){this.nextSibling&&this.parentNode.appendChild(this)}function x2(){return this.each(w2)}function _2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function S2(){return this.each(_2)}function b2(e){var n=typeof e=="function"?e:Nk(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function k2(){return null}function E2(e,n){var i=typeof e=="function"?e:Nk(e),s=n==null?k2:typeof n=="function"?n:Pg(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),s.apply(this,arguments)||null)})}function N2(){var e=this.parentNode;e&&e.removeChild(this)}function C2(){return this.each(N2)}function T2(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function R2(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function j2(e){return this.select(e?R2:T2)}function A2(e){return arguments.length?this.property("__data__",e):this.node().__data__}function I2(e){return function(n){e.call(this,n,this.__data__)}}function M2(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 P2(e){return function(){var n=this.__on;if(n){for(var i=0,s=-1,o=n.length,u;i<o;++i)u=n[i],(!e.type||u.type===e.type)&&u.name===e.name?this.removeEventListener(u.type,u.listener,u.options):n[++s]=u;++s?n.length=s:delete this.__on}}}function O2(e,n,i){return function(){var s=this.__on,o,u=I2(n);if(s){for(var l=0,c=s.length;l<c;++l)if((o=s[l]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=u,o.options=i),o.value=n;return}}this.addEventListener(e.type,u,i),o={type:e.type,name:e.name,value:n,listener:u,options:i},s?s.push(o):this.__on=[o]}}function q2(e,n,i){var s=M2(e+""),o,u=s.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var d=0,h=c.length,p;d<h;++d)for(o=0,p=c[d];o<u;++o)if((l=s[o]).type===p.type&&l.name===p.name)return p.value}return}for(c=n?O2:P2,o=0;o<u;++o)this.each(c(s[o],n,i));return this}function qk(e,n,i){var s=Ak(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 L2(e,n){return function(){return qk(this,e,n)}}function $2(e,n){return function(){return qk(this,e,n.apply(this,arguments))}}function D2(e,n){return this.each((typeof n=="function"?$2:L2)(e,n))}function*F2(){for(var e=this._groups,n=0,i=e.length;n<i;++n)for(var s=e[n],o=0,u=s.length,l;o<u;++o)(l=s[o])&&(yield l)}var Lk=[null];function gn(e,n){this._groups=e,this._parents=n}function $o(){return new gn([[document.documentElement]],Lk)}function z2(){return this}gn.prototype=$o.prototype={constructor:gn,select:hR,selectAll:vR,selectChild:_R,selectChildren:ER,filter:NR,data:IR,enter:CR,exit:PR,join:OR,merge:qR,selection:z2,order:LR,sort:$R,call:FR,nodes:zR,node:BR,size:UR,empty:HR,each:VR,attr:ZR,style:n2,property:o2,classed:c2,text:p2,html:y2,raise:x2,lower:S2,append:b2,insert:E2,remove:C2,clone:j2,datum:A2,on:q2,dispatch:D2,[Symbol.iterator]:F2};function Rn(e){return typeof e=="string"?new gn([[document.querySelector(e)]],[document.documentElement]):new gn([[e]],Lk)}function B2(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Bn(e,n){if(e=B2(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 U2={passive:!1},Ro={capture:!0,passive:!1};function Oc(e){e.stopImmediatePropagation()}function bs(e){e.preventDefault(),e.stopImmediatePropagation()}function $k(e){var n=e.document.documentElement,i=Rn(e).on("dragstart.drag",bs,Ro);"onselectstart"in n?i.on("selectstart.drag",bs,Ro):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Dk(e,n){var i=e.document.documentElement,s=Rn(e).on("dragstart.drag",null);n&&(s.on("click.drag",bs,Ro),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 Xa=e=>()=>e;function dg(e,{sourceEvent:n,subject:i,target:s,identifier:o,active:u,x:l,y:c,dx:d,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:u,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:p}})}dg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function H2(e){return!e.ctrlKey&&!e.button}function V2(){return this.parentNode}function W2(e,n){return n??{x:e.x,y:e.y}}function G2(){return navigator.maxTouchPoints||"ontouchstart"in this}function Y2(){var e=H2,n=V2,i=W2,s=G2,o={},u=Nu("start","drag","end"),l=0,c,d,h,p,m=0;function y(C){C.on("mousedown.drag",x).filter(s).on("touchstart.drag",S).on("touchmove.drag",b,U2).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(C,A){if(!(p||!e.call(this,C,A))){var P=E(this,n.call(this,C,A),C,A,"mouse");P&&(Rn(C.view).on("mousemove.drag",N,Ro).on("mouseup.drag",_,Ro),$k(C.view),Oc(C),h=!1,c=C.clientX,d=C.clientY,P("start",C))}}function N(C){if(bs(C),!h){var A=C.clientX-c,P=C.clientY-d;h=A*A+P*P>m}o.mouse("drag",C)}function _(C){Rn(C.view).on("mousemove.drag mouseup.drag",null),Dk(C.view,h),bs(C),o.mouse("end",C)}function S(C,A){if(e.call(this,C,A)){var P=C.changedTouches,I=n.call(this,C,A),M=P.length,R,L;for(R=0;R<M;++R)(L=E(this,I,C,A,P[R].identifier,P[R]))&&(Oc(C),L("start",C,P[R]))}}function b(C){var A=C.changedTouches,P=A.length,I,M;for(I=0;I<P;++I)(M=o[A[I].identifier])&&(bs(C),M("drag",C,A[I]))}function k(C){var A=C.changedTouches,P=A.length,I,M;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),I=0;I<P;++I)(M=o[A[I].identifier])&&(Oc(C),M("end",C,A[I]))}function E(C,A,P,I,M,R){var L=u.copy(),F=Bn(R||P,A),Q,X,j;if((j=i.call(C,new dg("beforestart",{sourceEvent:P,target:y,identifier:M,active:l,x:F[0],y:F[1],dx:0,dy:0,dispatch:L}),I))!=null)return Q=j.x-F[0]||0,X=j.y-F[1]||0,function G(U,ne,K){var D=F,V;switch(U){case"start":o[M]=G,V=l++;break;case"end":delete o[M],--l;case"drag":F=Bn(K||ne,A),V=l;break}L.call(U,C,new dg(U,{sourceEvent:ne,subject:j,target:y,identifier:M,active:V,x:F[0]+Q,y:F[1]+X,dx:F[0]-D[0],dy:F[1]-D[1],dispatch:L}),I)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Xa(!!C),y):e},y.container=function(C){return arguments.length?(n=typeof C=="function"?C:Xa(C),y):n},y.subject=function(C){return arguments.length?(i=typeof C=="function"?C:Xa(C),y):i},y.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:Xa(!!C),y):s},y.on=function(){var C=u.on.apply(u,arguments);return C===u?y:C},y.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,y):Math.sqrt(m)},y}function qg(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function Fk(e,n){var i=Object.create(e.prototype);for(var s in n)i[s]=n[s];return i}function Do(){}var jo=.7,mu=1/jo,ks="\\s*([+-]?\\d+)\\s*",Ao="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",tr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",K2=/^#([0-9a-f]{3,8})$/,X2=new RegExp(`^rgb\\(${ks},${ks},${ks}\\)$`),Q2=new RegExp(`^rgb\\(${tr},${tr},${tr}\\)$`),Z2=new RegExp(`^rgba\\(${ks},${ks},${ks},${Ao}\\)$`),J2=new RegExp(`^rgba\\(${tr},${tr},${tr},${Ao}\\)$`),ej=new RegExp(`^hsl\\(${Ao},${tr},${tr}\\)$`),tj=new RegExp(`^hsla\\(${Ao},${tr},${tr},${Ao}\\)$`),ew={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};qg(Do,Io,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:tw,formatHex:tw,formatHex8:nj,formatHsl:rj,formatRgb:nw,toString:nw});function tw(){return this.rgb().formatHex()}function nj(){return this.rgb().formatHex8()}function rj(){return zk(this).formatHsl()}function nw(){return this.rgb().formatRgb()}function Io(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=K2.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?rw(n):i===3?new nn(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?Qa(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?Qa(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=X2.exec(e))?new nn(n[1],n[2],n[3],1):(n=Q2.exec(e))?new nn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=Z2.exec(e))?Qa(n[1],n[2],n[3],n[4]):(n=J2.exec(e))?Qa(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=ej.exec(e))?ow(n[1],n[2]/100,n[3]/100,1):(n=tj.exec(e))?ow(n[1],n[2]/100,n[3]/100,n[4]):ew.hasOwnProperty(e)?rw(ew[e]):e==="transparent"?new nn(NaN,NaN,NaN,0):null}function rw(e){return new nn(e>>16&255,e>>8&255,e&255,1)}function Qa(e,n,i,s){return s<=0&&(e=n=i=NaN),new nn(e,n,i,s)}function ij(e){return e instanceof Do||(e=Io(e)),e?(e=e.rgb(),new nn(e.r,e.g,e.b,e.opacity)):new nn}function hg(e,n,i,s){return arguments.length===1?ij(e):new nn(e,n,i,s??1)}function nn(e,n,i,s){this.r=+e,this.g=+n,this.b=+i,this.opacity=+s}qg(nn,hg,Fk(Do,{brighter(e){return e=e==null?mu:Math.pow(mu,e),new nn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?jo:Math.pow(jo,e),new nn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new nn(Ri(this.r),Ri(this.g),Ri(this.b),gu(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:iw,formatHex:iw,formatHex8:sj,formatRgb:sw,toString:sw}));function iw(){return`#${Ci(this.r)}${Ci(this.g)}${Ci(this.b)}`}function sj(){return`#${Ci(this.r)}${Ci(this.g)}${Ci(this.b)}${Ci((isNaN(this.opacity)?1:this.opacity)*255)}`}function sw(){const e=gu(this.opacity);return`${e===1?"rgb(":"rgba("}${Ri(this.r)}, ${Ri(this.g)}, ${Ri(this.b)}${e===1?")":`, ${e})`}`}function gu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ri(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ci(e){return e=Ri(e),(e<16?"0":"")+e.toString(16)}function ow(e,n,i,s){return s<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Un(e,n,i,s)}function zk(e){if(e instanceof Un)return new Un(e.h,e.s,e.l,e.opacity);if(e instanceof Do||(e=Io(e)),!e)return new Un;if(e instanceof Un)return e;e=e.rgb();var n=e.r/255,i=e.g/255,s=e.b/255,o=Math.min(n,i,s),u=Math.max(n,i,s),l=NaN,c=u-o,d=(u+o)/2;return c?(n===u?l=(i-s)/c+(i<s)*6:i===u?l=(s-n)/c+2:l=(n-i)/c+4,c/=d<.5?u+o:2-u-o,l*=60):c=d>0&&d<1?0:l,new Un(l,c,d,e.opacity)}function oj(e,n,i,s){return arguments.length===1?zk(e):new Un(e,n,i,s??1)}function Un(e,n,i,s){this.h=+e,this.s=+n,this.l=+i,this.opacity=+s}qg(Un,oj,Fk(Do,{brighter(e){return e=e==null?mu:Math.pow(mu,e),new Un(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?jo:Math.pow(jo,e),new Un(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 nn(qc(e>=240?e-240:e+120,o,s),qc(e,o,s),qc(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new Un(aw(this.h),Za(this.s),Za(this.l),gu(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=gu(this.opacity);return`${e===1?"hsl(":"hsla("}${aw(this.h)}, ${Za(this.s)*100}%, ${Za(this.l)*100}%${e===1?")":`, ${e})`}`}}));function aw(e){return e=(e||0)%360,e<0?e+360:e}function Za(e){return Math.max(0,Math.min(1,e||0))}function qc(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 Bk=e=>()=>e;function aj(e,n){return function(i){return e+i*n}}function uj(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 lj(e){return(e=+e)==1?Uk:function(n,i){return i-n?uj(n,i,e):Bk(isNaN(n)?i:n)}}function Uk(e,n){var i=n-e;return i?aj(e,i):Bk(isNaN(e)?n:e)}const uw=(function e(n){var i=lj(n);function s(o,u){var l=i((o=hg(o)).r,(u=hg(u)).r),c=i(o.g,u.g),d=i(o.b,u.b),h=Uk(o.opacity,u.opacity);return function(p){return o.r=l(p),o.g=c(p),o.b=d(p),o.opacity=h(p),o+""}}return s.gamma=e,s})(1);function Kr(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}var pg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Lc=new RegExp(pg.source,"g");function cj(e){return function(){return e}}function fj(e){return function(n){return e(n)+""}}function dj(e,n){var i=pg.lastIndex=Lc.lastIndex=0,s,o,u,l=-1,c=[],d=[];for(e=e+"",n=n+"";(s=pg.exec(e))&&(o=Lc.exec(n));)(u=o.index)>i&&(u=n.slice(i,u),c[l]?c[l]+=u:c[++l]=u),(s=s[0])===(o=o[0])?c[l]?c[l]+=o:c[++l]=o:(c[++l]=null,d.push({i:l,x:Kr(s,o)})),i=Lc.lastIndex;return i<n.length&&(u=n.slice(i),c[l]?c[l]+=u:c[++l]=u),c.length<2?d[0]?fj(d[0].x):cj(n):(n=d.length,function(h){for(var p=0,m;p<n;++p)c[(m=d[p]).i]=m.x(h);return c.join("")})}var lw=180/Math.PI,mg={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Hk(e,n,i,s,o,u){var l,c,d;return(l=Math.sqrt(e*e+n*n))&&(e/=l,n/=l),(d=e*i+n*s)&&(i-=e*d,s-=n*d),(c=Math.sqrt(i*i+s*s))&&(i/=c,s/=c,d/=c),e*s<n*i&&(e=-e,n=-n,d=-d,l=-l),{translateX:o,translateY:u,rotate:Math.atan2(n,e)*lw,skewX:Math.atan(d)*lw,scaleX:l,scaleY:c}}var Ja;function hj(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?mg:Hk(n.a,n.b,n.c,n.d,n.e,n.f)}function pj(e){return e==null||(Ja||(Ja=document.createElementNS("http://www.w3.org/2000/svg","g")),Ja.setAttribute("transform",e),!(e=Ja.transform.baseVal.consolidate()))?mg:(e=e.matrix,Hk(e.a,e.b,e.c,e.d,e.e,e.f))}function Vk(e,n,i,s){function o(h){return h.length?h.pop()+" ":""}function u(h,p,m,y,x,N){if(h!==m||p!==y){var _=x.push("translate(",null,n,null,i);N.push({i:_-4,x:Kr(h,m)},{i:_-2,x:Kr(p,y)})}else(m||y)&&x.push("translate("+m+n+y+i)}function l(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:Kr(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:Kr(h,p)}):p&&m.push(o(m)+"skewX("+p+s)}function d(h,p,m,y,x,N){if(h!==m||p!==y){var _=x.push(o(x)+"scale(",null,",",null,")");N.push({i:_-4,x:Kr(h,m)},{i:_-2,x:Kr(p,y)})}else(m!==1||y!==1)&&x.push(o(x)+"scale("+m+","+y+")")}return function(h,p){var m=[],y=[];return h=e(h),p=e(p),u(h.translateX,h.translateY,p.translateX,p.translateY,m,y),l(h.rotate,p.rotate,m,y),c(h.skewX,p.skewX,m,y),d(h.scaleX,h.scaleY,p.scaleX,p.scaleY,m,y),h=p=null,function(x){for(var N=-1,_=y.length,S;++N<_;)m[(S=y[N]).i]=S.x(x);return m.join("")}}}var mj=Vk(hj,"px, ","px)","deg)"),gj=Vk(pj,", ",")",")"),vj=1e-12;function cw(e){return((e=Math.exp(e))+1/e)/2}function yj(e){return((e=Math.exp(e))-1/e)/2}function wj(e){return((e=Math.exp(2*e))-1)/(e+1)}const xj=(function e(n,i,s){function o(u,l){var c=u[0],d=u[1],h=u[2],p=l[0],m=l[1],y=l[2],x=p-c,N=m-d,_=x*x+N*N,S,b;if(_<vj)b=Math.log(y/h)/n,S=function(I){return[c+I*x,d+I*N,h*Math.exp(n*I*b)]};else{var k=Math.sqrt(_),E=(y*y-h*h+s*_)/(2*h*i*k),C=(y*y-h*h-s*_)/(2*y*i*k),A=Math.log(Math.sqrt(E*E+1)-E),P=Math.log(Math.sqrt(C*C+1)-C);b=(P-A)/n,S=function(I){var M=I*b,R=cw(A),L=h/(i*k)*(R*wj(n*M+A)-yj(A));return[c+L*x,d+L*N,h*R/cw(n*M+A)]}}return S.duration=b*1e3*n/Math.SQRT2,S}return o.rho=function(u){var l=Math.max(.001,+u),c=l*l,d=c*c;return e(l,c,d)},o})(Math.SQRT2,2,4);var Rs=0,So=0,vo=0,Wk=1e3,vu,bo,yu=0,Ii=0,Tu=0,Mo=typeof performance=="object"&&performance.now?performance:Date,Gk=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lg(){return Ii||(Gk(_j),Ii=Mo.now()+Tu)}function _j(){Ii=0}function wu(){this._call=this._time=this._next=null}wu.prototype=Yk.prototype={constructor:wu,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Lg():+i)+(n==null?0:+n),!this._next&&bo!==this&&(bo?bo._next=this:vu=this,bo=this),this._call=e,this._time=i,gg()},stop:function(){this._call&&(this._call=null,this._time=1/0,gg())}};function Yk(e,n,i){var s=new wu;return s.restart(e,n,i),s}function Sj(){Lg(),++Rs;for(var e=vu,n;e;)(n=Ii-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Rs}function fw(){Ii=(yu=Mo.now())+Tu,Rs=So=0;try{Sj()}finally{Rs=0,kj(),Ii=0}}function bj(){var e=Mo.now(),n=e-yu;n>Wk&&(Tu-=n,yu=e)}function kj(){for(var e,n=vu,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:vu=i);bo=e,gg(s)}function gg(e){if(!Rs){So&&(So=clearTimeout(So));var n=e-Ii;n>24?(e<1/0&&(So=setTimeout(fw,e-Mo.now()-Tu)),vo&&(vo=clearInterval(vo))):(vo||(yu=Mo.now(),vo=setInterval(bj,Wk)),Rs=1,Gk(fw))}}function dw(e,n,i){var s=new wu;return n=n==null?0:+n,s.restart(o=>{s.stop(),e(o+n)},n,i),s}var Ej=Nu("start","end","cancel","interrupt"),Nj=[],Kk=0,hw=1,vg=2,fu=3,pw=4,yg=5,du=6;function Ru(e,n,i,s,o,u){var l=e.__transition;if(!l)e.__transition={};else if(i in l)return;Cj(e,i,{name:n,index:s,group:o,on:Ej,tween:Nj,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Kk})}function $g(e,n){var i=Wn(e,n);if(i.state>Kk)throw new Error("too late; already scheduled");return i}function nr(e,n){var i=Wn(e,n);if(i.state>fu)throw new Error("too late; already running");return i}function Wn(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function Cj(e,n,i){var s=e.__transition,o;s[n]=i,i.timer=Yk(u,0,i.time);function u(h){i.state=hw,i.timer.restart(l,i.delay,i.time),i.delay<=h&&l(h-i.delay)}function l(h){var p,m,y,x;if(i.state!==hw)return d();for(p in s)if(x=s[p],x.name===i.name){if(x.state===fu)return dw(l);x.state===pw?(x.state=du,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[p]):+p<n&&(x.state=du,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete s[p])}if(dw(function(){i.state===fu&&(i.state=pw,i.timer.restart(c,i.delay,i.time),c(h))}),i.state=vg,i.on.call("start",e,e.__data__,i.index,i.group),i.state===vg){for(i.state=fu,o=new Array(y=i.tween.length),p=0,m=-1;p<y;++p)(x=i.tween[p].value.call(e,e.__data__,i.index,i.group))&&(o[++m]=x);o.length=m+1}}function c(h){for(var p=h<i.duration?i.ease.call(null,h/i.duration):(i.timer.restart(d),i.state=yg,1),m=-1,y=o.length;++m<y;)o[m].call(e,p);i.state===yg&&(i.on.call("end",e,e.__data__,i.index,i.group),d())}function d(){i.state=du,i.timer.stop(),delete s[n];for(var h in s)return;delete e.__transition}}function hu(e,n){var i=e.__transition,s,o,u=!0,l;if(i){n=n==null?null:n+"";for(l in i){if((s=i[l]).name!==n){u=!1;continue}o=s.state>vg&&s.state<yg,s.state=du,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete i[l]}u&&delete e.__transition}}function Tj(e){return this.each(function(){hu(this,e)})}function Rj(e,n){var i,s;return function(){var o=nr(this,e),u=o.tween;if(u!==i){s=i=u;for(var l=0,c=s.length;l<c;++l)if(s[l].name===n){s=s.slice(),s.splice(l,1);break}}o.tween=s}}function jj(e,n,i){var s,o;if(typeof i!="function")throw new Error;return function(){var u=nr(this,e),l=u.tween;if(l!==s){o=(s=l).slice();for(var c={name:n,value:i},d=0,h=o.length;d<h;++d)if(o[d].name===n){o[d]=c;break}d===h&&o.push(c)}u.tween=o}}function Aj(e,n){var i=this._id;if(e+="",arguments.length<2){for(var s=Wn(this.node(),i).tween,o=0,u=s.length,l;o<u;++o)if((l=s[o]).name===e)return l.value;return null}return this.each((n==null?Rj:jj)(i,e,n))}function Dg(e,n,i){var s=e._id;return e.each(function(){var o=nr(this,s);(o.value||(o.value={}))[n]=i.apply(this,arguments)}),function(o){return Wn(o,s).value[n]}}function Xk(e,n){var i;return(typeof n=="number"?Kr:n instanceof Io?uw:(i=Io(n))?(n=i,uw):dj)(e,n)}function Ij(e){return function(){this.removeAttribute(e)}}function Mj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pj(e,n,i){var s,o=i+"",u;return function(){var l=this.getAttribute(e);return l===o?null:l===s?u:u=n(s=l,i)}}function Oj(e,n,i){var s,o=i+"",u;return function(){var l=this.getAttributeNS(e.space,e.local);return l===o?null:l===s?u:u=n(s=l,i)}}function qj(e,n,i){var s,o,u;return function(){var l,c=i(this),d;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),d=c+"",l===d?null:l===s&&d===o?u:(o=d,u=n(s=l,c)))}}function Lj(e,n,i){var s,o,u;return function(){var l,c=i(this),d;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),d=c+"",l===d?null:l===s&&d===o?u:(o=d,u=n(s=l,c)))}}function $j(e,n){var i=Cu(e),s=i==="transform"?gj:Xk;return this.attrTween(e,typeof n=="function"?(i.local?Lj:qj)(i,s,Dg(this,"attr."+e,n)):n==null?(i.local?Mj:Ij)(i):(i.local?Oj:Pj)(i,s,n))}function Dj(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function Fj(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function zj(e,n){var i,s;function o(){var u=n.apply(this,arguments);return u!==s&&(i=(s=u)&&Fj(e,u)),i}return o._value=n,o}function Bj(e,n){var i,s;function o(){var u=n.apply(this,arguments);return u!==s&&(i=(s=u)&&Dj(e,u)),i}return o._value=n,o}function Uj(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=Cu(e);return this.tween(i,(s.local?zj:Bj)(s,n))}function Hj(e,n){return function(){$g(this,e).delay=+n.apply(this,arguments)}}function Vj(e,n){return n=+n,function(){$g(this,e).delay=n}}function Wj(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Hj:Vj)(n,e)):Wn(this.node(),n).delay}function Gj(e,n){return function(){nr(this,e).duration=+n.apply(this,arguments)}}function Yj(e,n){return n=+n,function(){nr(this,e).duration=n}}function Kj(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Gj:Yj)(n,e)):Wn(this.node(),n).duration}function Xj(e,n){if(typeof n!="function")throw new Error;return function(){nr(this,e).ease=n}}function Qj(e){var n=this._id;return arguments.length?this.each(Xj(n,e)):Wn(this.node(),n).ease}function Zj(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;nr(this,e).ease=i}}function Jj(e){if(typeof e!="function")throw new Error;return this.each(Zj(this._id,e))}function eA(e){typeof e!="function"&&(e=Tk(e));for(var n=this._groups,i=n.length,s=new Array(i),o=0;o<i;++o)for(var u=n[o],l=u.length,c=s[o]=[],d,h=0;h<l;++h)(d=u[h])&&e.call(d,d.__data__,h,u)&&c.push(d);return new vr(s,this._parents,this._name,this._id)}function tA(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,i=e._groups,s=n.length,o=i.length,u=Math.min(s,o),l=new Array(s),c=0;c<u;++c)for(var d=n[c],h=i[c],p=d.length,m=l[c]=new Array(p),y,x=0;x<p;++x)(y=d[x]||h[x])&&(m[x]=y);for(;c<s;++c)l[c]=n[c];return new vr(l,this._parents,this._name,this._id)}function nA(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 rA(e,n,i){var s,o,u=nA(n)?$g:nr;return function(){var l=u(this,e),c=l.on;c!==s&&(o=(s=c).copy()).on(n,i),l.on=o}}function iA(e,n){var i=this._id;return arguments.length<2?Wn(this.node(),i).on.on(e):this.each(rA(i,e,n))}function sA(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function oA(){return this.on("end.remove",sA(this._id))}function aA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Pg(e));for(var s=this._groups,o=s.length,u=new Array(o),l=0;l<o;++l)for(var c=s[l],d=c.length,h=u[l]=new Array(d),p,m,y=0;y<d;++y)(p=c[y])&&(m=e.call(p,p.__data__,y,c))&&("__data__"in p&&(m.__data__=p.__data__),h[y]=m,Ru(h[y],n,i,y,h,Wn(p,i)));return new vr(u,this._parents,n,i)}function uA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Ck(e));for(var s=this._groups,o=s.length,u=[],l=[],c=0;c<o;++c)for(var d=s[c],h=d.length,p,m=0;m<h;++m)if(p=d[m]){for(var y=e.call(p,p.__data__,m,d),x,N=Wn(p,i),_=0,S=y.length;_<S;++_)(x=y[_])&&Ru(x,n,i,_,y,N);u.push(y),l.push(p)}return new vr(u,l,n,i)}var lA=$o.prototype.constructor;function cA(){return new lA(this._groups,this._parents)}function fA(e,n){var i,s,o;return function(){var u=Ts(this,e),l=(this.style.removeProperty(e),Ts(this,e));return u===l?null:u===i&&l===s?o:o=n(i=u,s=l)}}function Qk(e){return function(){this.style.removeProperty(e)}}function dA(e,n,i){var s,o=i+"",u;return function(){var l=Ts(this,e);return l===o?null:l===s?u:u=n(s=l,i)}}function hA(e,n,i){var s,o,u;return function(){var l=Ts(this,e),c=i(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),Ts(this,e))),l===d?null:l===s&&d===o?u:(o=d,u=n(s=l,c))}}function pA(e,n){var i,s,o,u="style."+n,l="end."+u,c;return function(){var d=nr(this,e),h=d.on,p=d.value[u]==null?c||(c=Qk(n)):void 0;(h!==i||o!==p)&&(s=(i=h).copy()).on(l,o=p),d.on=s}}function mA(e,n,i){var s=(e+="")=="transform"?mj:Xk;return n==null?this.styleTween(e,fA(e,s)).on("end.style."+e,Qk(e)):typeof n=="function"?this.styleTween(e,hA(e,s,Dg(this,"style."+e,n))).each(pA(this._id,e)):this.styleTween(e,dA(e,s,n),i).on("end.style."+e,null)}function gA(e,n,i){return function(s){this.style.setProperty(e,n.call(this,s),i)}}function vA(e,n,i){var s,o;function u(){var l=n.apply(this,arguments);return l!==o&&(s=(o=l)&&gA(e,l,i)),s}return u._value=n,u}function yA(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,vA(e,n,i??""))}function wA(e){return function(){this.textContent=e}}function xA(e){return function(){var n=e(this);this.textContent=n??""}}function _A(e){return this.tween("text",typeof e=="function"?xA(Dg(this,"text",e)):wA(e==null?"":e+""))}function SA(e){return function(n){this.textContent=e.call(this,n)}}function bA(e){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&SA(o)),n}return s._value=e,s}function kA(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,bA(e))}function EA(){for(var e=this._name,n=this._id,i=Zk(),s=this._groups,o=s.length,u=0;u<o;++u)for(var l=s[u],c=l.length,d,h=0;h<c;++h)if(d=l[h]){var p=Wn(d,n);Ru(d,e,i,h,l,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new vr(s,this._parents,e,i)}function NA(){var e,n,i=this,s=i._id,o=i.size();return new Promise(function(u,l){var c={value:l},d={value:function(){--o===0&&u()}};i.each(function(){var h=nr(this,s),p=h.on;p!==e&&(n=(e=p).copy(),n._.cancel.push(c),n._.interrupt.push(c),n._.end.push(d)),h.on=n}),o===0&&u()})}var CA=0;function vr(e,n,i,s){this._groups=e,this._parents=n,this._name=i,this._id=s}function Zk(){return++CA}var hr=$o.prototype;vr.prototype={constructor:vr,select:aA,selectAll:uA,selectChild:hr.selectChild,selectChildren:hr.selectChildren,filter:eA,merge:tA,selection:cA,transition:EA,call:hr.call,nodes:hr.nodes,node:hr.node,size:hr.size,empty:hr.empty,each:hr.each,on:iA,attr:$j,attrTween:Uj,style:mA,styleTween:yA,text:_A,textTween:kA,remove:oA,tween:Aj,delay:Wj,duration:Kj,ease:Qj,easeVarying:Jj,end:NA,[Symbol.iterator]:hr[Symbol.iterator]};function TA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var RA={time:null,delay:0,duration:250,ease:TA};function jA(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 AA(e){var n,i;e instanceof vr?(n=e._id,e=e._name):(n=Zk(),(i=RA).time=Lg(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,u=0;u<o;++u)for(var l=s[u],c=l.length,d,h=0;h<c;++h)(d=l[h])&&Ru(d,e,n,h,l,i||jA(d,n));return new vr(s,this._parents,e,n)}$o.prototype.interrupt=Tj;$o.prototype.transition=AA;const eu=e=>()=>e;function IA(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 mr(e,n,i){this.k=e,this.x=n,this.y=i}mr.prototype={constructor:mr,scale:function(e){return e===1?this:new mr(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new mr(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 gr=new mr(1,0,0);mr.prototype;function $c(e){e.stopImmediatePropagation()}function yo(e){e.preventDefault(),e.stopImmediatePropagation()}function MA(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function PA(){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 mw(){return this.__zoom||gr}function OA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function qA(){return navigator.maxTouchPoints||"ontouchstart"in this}function LA(e,n,i){var s=e.invertX(n[0][0])-i[0][0],o=e.invertX(n[1][0])-i[1][0],u=e.invertY(n[0][1])-i[0][1],l=e.invertY(n[1][1])-i[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),l>u?(u+l)/2:Math.min(0,u)||Math.max(0,l))}function Jk(){var e=MA,n=PA,i=LA,s=OA,o=qA,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=xj,h=Nu("start","zoom","end"),p,m,y,x=500,N=150,_=0,S=10;function b(j){j.property("__zoom",mw).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",L).filter(o).on("touchstart.zoom",F).on("touchmove.zoom",Q).on("touchend.zoom touchcancel.zoom",X).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(j,G,U,ne){var K=j.selection?j.selection():j;K.property("__zoom",mw),j!==K?A(j,G,U,ne):K.interrupt().each(function(){P(this,arguments).event(ne).start().zoom(null,typeof G=="function"?G.apply(this,arguments):G).end()})},b.scaleBy=function(j,G,U,ne){b.scaleTo(j,function(){var K=this.__zoom.k,D=typeof G=="function"?G.apply(this,arguments):G;return K*D},U,ne)},b.scaleTo=function(j,G,U,ne){b.transform(j,function(){var K=n.apply(this,arguments),D=this.__zoom,V=U==null?C(K):typeof U=="function"?U.apply(this,arguments):U,O=D.invert(V),B=typeof G=="function"?G.apply(this,arguments):G;return i(E(k(D,B),V,O),K,l)},U,ne)},b.translateBy=function(j,G,U,ne){b.transform(j,function(){return i(this.__zoom.translate(typeof G=="function"?G.apply(this,arguments):G,typeof U=="function"?U.apply(this,arguments):U),n.apply(this,arguments),l)},null,ne)},b.translateTo=function(j,G,U,ne,K){b.transform(j,function(){var D=n.apply(this,arguments),V=this.__zoom,O=ne==null?C(D):typeof ne=="function"?ne.apply(this,arguments):ne;return i(gr.translate(O[0],O[1]).scale(V.k).translate(typeof G=="function"?-G.apply(this,arguments):-G,typeof U=="function"?-U.apply(this,arguments):-U),D,l)},ne,K)};function k(j,G){return G=Math.max(u[0],Math.min(u[1],G)),G===j.k?j:new mr(G,j.x,j.y)}function E(j,G,U){var ne=G[0]-U[0]*j.k,K=G[1]-U[1]*j.k;return ne===j.x&&K===j.y?j:new mr(j.k,ne,K)}function C(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function A(j,G,U,ne){j.on("start.zoom",function(){P(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(ne).end()}).tween("zoom",function(){var K=this,D=arguments,V=P(K,D).event(ne),O=n.apply(K,D),B=U==null?C(O):typeof U=="function"?U.apply(K,D):U,ae=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),z=K.__zoom,W=typeof G=="function"?G.apply(K,D):G,J=d(z.invert(B).concat(ae/z.k),W.invert(B).concat(ae/W.k));return function(se){if(se===1)se=W;else{var ue=J(se),he=ae/ue[2];se=new mr(he,B[0]-ue[0]*he,B[1]-ue[1]*he)}V.zoom(null,se)}})}function P(j,G,U){return!U&&j.__zooming||new I(j,G)}function I(j,G){this.that=j,this.args=G,this.active=0,this.sourceEvent=null,this.extent=n.apply(j,G),this.taps=0}I.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,G){return this.mouse&&j!=="mouse"&&(this.mouse[1]=G.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=G.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=G.invert(this.touch1[0])),this.that.__zoom=G,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var G=Rn(this.that).datum();h.call(j,this.that,new IA(j,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),G)}};function M(j,...G){if(!e.apply(this,arguments))return;var U=P(this,G).event(j),ne=this.__zoom,K=Math.max(u[0],Math.min(u[1],ne.k*Math.pow(2,s.apply(this,arguments)))),D=Bn(j);if(U.wheel)(U.mouse[0][0]!==D[0]||U.mouse[0][1]!==D[1])&&(U.mouse[1]=ne.invert(U.mouse[0]=D)),clearTimeout(U.wheel);else{if(ne.k===K)return;U.mouse=[D,ne.invert(D)],hu(this),U.start()}yo(j),U.wheel=setTimeout(V,N),U.zoom("mouse",i(E(k(ne,K),U.mouse[0],U.mouse[1]),U.extent,l));function V(){U.wheel=null,U.end()}}function R(j,...G){if(y||!e.apply(this,arguments))return;var U=j.currentTarget,ne=P(this,G,!0).event(j),K=Rn(j.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",ae,!0),D=Bn(j,U),V=j.clientX,O=j.clientY;$k(j.view),$c(j),ne.mouse=[D,this.__zoom.invert(D)],hu(this),ne.start();function B(z){if(yo(z),!ne.moved){var W=z.clientX-V,J=z.clientY-O;ne.moved=W*W+J*J>_}ne.event(z).zoom("mouse",i(E(ne.that.__zoom,ne.mouse[0]=Bn(z,U),ne.mouse[1]),ne.extent,l))}function ae(z){K.on("mousemove.zoom mouseup.zoom",null),Dk(z.view,ne.moved),yo(z),ne.event(z).end()}}function L(j,...G){if(e.apply(this,arguments)){var U=this.__zoom,ne=Bn(j.changedTouches?j.changedTouches[0]:j,this),K=U.invert(ne),D=U.k*(j.shiftKey?.5:2),V=i(E(k(U,D),ne,K),n.apply(this,G),l);yo(j),c>0?Rn(this).transition().duration(c).call(A,V,ne,j):Rn(this).call(b.transform,V,ne,j)}}function F(j,...G){if(e.apply(this,arguments)){var U=j.touches,ne=U.length,K=P(this,G,j.changedTouches.length===ne).event(j),D,V,O,B;for($c(j),V=0;V<ne;++V)O=U[V],B=Bn(O,this),B=[B,this.__zoom.invert(B),O.identifier],K.touch0?!K.touch1&&K.touch0[2]!==B[2]&&(K.touch1=B,K.taps=0):(K.touch0=B,D=!0,K.taps=1+!!p);p&&(p=clearTimeout(p)),D&&(K.taps<2&&(m=B[0],p=setTimeout(function(){p=null},x)),hu(this),K.start())}}function Q(j,...G){if(this.__zooming){var U=P(this,G).event(j),ne=j.changedTouches,K=ne.length,D,V,O,B;for(yo(j),D=0;D<K;++D)V=ne[D],O=Bn(V,this),U.touch0&&U.touch0[2]===V.identifier?U.touch0[0]=O:U.touch1&&U.touch1[2]===V.identifier&&(U.touch1[0]=O);if(V=U.that.__zoom,U.touch1){var ae=U.touch0[0],z=U.touch0[1],W=U.touch1[0],J=U.touch1[1],se=(se=W[0]-ae[0])*se+(se=W[1]-ae[1])*se,ue=(ue=J[0]-z[0])*ue+(ue=J[1]-z[1])*ue;V=k(V,Math.sqrt(se/ue)),O=[(ae[0]+W[0])/2,(ae[1]+W[1])/2],B=[(z[0]+J[0])/2,(z[1]+J[1])/2]}else if(U.touch0)O=U.touch0[0],B=U.touch0[1];else return;U.zoom("touch",i(E(V,O,B),U.extent,l))}}function X(j,...G){if(this.__zooming){var U=P(this,G).event(j),ne=j.changedTouches,K=ne.length,D,V;for($c(j),y&&clearTimeout(y),y=setTimeout(function(){y=null},x),D=0;D<K;++D)V=ne[D],U.touch0&&U.touch0[2]===V.identifier?delete U.touch0:U.touch1&&U.touch1[2]===V.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&&(V=Bn(V,this),Math.hypot(m[0]-V[0],m[1]-V[1])<S)){var O=Rn(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return b.wheelDelta=function(j){return arguments.length?(s=typeof j=="function"?j:eu(+j),b):s},b.filter=function(j){return arguments.length?(e=typeof j=="function"?j:eu(!!j),b):e},b.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:eu(!!j),b):o},b.extent=function(j){return arguments.length?(n=typeof j=="function"?j:eu([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),b):n},b.scaleExtent=function(j){return arguments.length?(u[0]=+j[0],u[1]=+j[1],b):[u[0],u[1]]},b.translateExtent=function(j){return arguments.length?(l[0][0]=+j[0][0],l[1][0]=+j[1][0],l[0][1]=+j[0][1],l[1][1]=+j[1][1],b):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},b.constrain=function(j){return arguments.length?(i=j,b):i},b.duration=function(j){return arguments.length?(c=+j,b):c},b.interpolate=function(j){return arguments.length?(d=j,b):d},b.on=function(){var j=h.on.apply(h,arguments);return j===h?b:j},b.clickDistance=function(j){return arguments.length?(_=(j=+j)*j,b):Math.sqrt(_)},b.tapDistance=function(j){return arguments.length?(S=+j,b):S},b}kk();const ju=q.createContext(null),$A=ju.Provider,yr={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.`},eE=yr.error001();function Xe(e,n){const i=q.useContext(ju);if(i===null)throw new Error(eE);return Ek(i,e,n)}const bt=()=>{const e=q.useContext(ju);if(e===null)throw new Error(eE);return q.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},DA=e=>e.userSelectionActive?"none":"all";function Fg({position:e,children:n,className:i,style:s,...o}){const u=Xe(DA),l=`${e}`.split("-");return oe.createElement("div",{className:qt(["react-flow__panel",i,...l]),style:{...s,pointerEvents:u},...o},n)}function FA({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:oe.createElement(Fg,{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"},oe.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const zA=({x:e,y:n,label:i,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:u={},labelBgPadding:l=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...p})=>{const m=q.useRef(null),[y,x]=q.useState({x:0,y:0,width:0,height:0}),N=qt(["react-flow__edge-textwrapper",h]);return q.useEffect(()=>{if(m.current){const _=m.current.getBBox();x({x:_.x,y:_.y,width:_.width,height:_.height})}},[i]),typeof i>"u"||!i?null:oe.createElement("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:N,visibility:y.width?"visible":"hidden",...p},o&&oe.createElement("rect",{width:y.width+2*l[0],x:-l[0],y:-l[1],height:y.height+2*l[1],className:"react-flow__edge-textbg",style:u,rx:c,ry:c}),oe.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:s},i),d)};var BA=q.memo(zA);const zg=e=>({width:e.offsetWidth,height:e.offsetHeight}),js=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),Bg=(e={x:0,y:0},n)=>({x:js(e.x,n[0][0],n[1][0]),y:js(e.y,n[0][1],n[1][1])}),gw=(e,n,i)=>e<n?js(Math.abs(e-n),1,50)/50:e>i?-js(Math.abs(e-i),1,50)/50:0,tE=(e,n)=>{const i=gw(e.x,35,n.width-35)*20,s=gw(e.y,35,n.height-35)*20;return[i,s]},nE=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},rE=(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)}),Po=({x:e,y:n,width:i,height:s})=>({x:e,y:n,x2:e+i,y2:n+s}),iE=({x:e,y:n,x2:i,y2:s})=>({x:e,y:n,width:i-e,height:s-n}),vw=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),UA=(e,n)=>iE(rE(Po(e),Po(n))),wg=(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)},HA=e=>jn(e.width)&&jn(e.height)&&jn(e.x)&&jn(e.y),jn=e=>!isNaN(e)&&isFinite(e),ht=Symbol.for("internals"),sE=["Enter"," ","Escape"],VA=(e,n)=>{},WA=e=>"nativeEvent"in e;function xg(e){var o,u;const n=WA(e)?e.nativeEvent:e,i=((u=(o=n.composedPath)==null?void 0:o.call(n))==null?void 0:u[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 oE=e=>"clientX"in e,Zr=(e,n)=>{var u,l;const i=oE(e),s=i?e.clientX:(u=e.touches)==null?void 0:u[0].clientX,o=i?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:s-((n==null?void 0:n.left)??0),y:o-((n==null?void 0:n.top)??0)}},xu=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Fo=({id:e,path:n,labelX:i,labelY:s,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:x=20})=>oe.createElement(oe.Fragment,null,oe.createElement("path",{id:e,style:p,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),x&&oe.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}),o&&jn(i)&&jn(s)?oe.createElement(BA,{x:i,y:s,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);Fo.displayName="BaseEdge";function wo(e,n,i){return i===void 0?i:s=>{const o=n().edges.find(u=>u.id===e);o&&i(s,{...o})}}function aE({sourceX:e,sourceY:n,targetX:i,targetY:s}){const o=Math.abs(i-e)/2,u=i<e?i+o:i-o,l=Math.abs(s-n)/2,c=s<n?s+l:s-l;return[u,c,o,l]}function uE({sourceX:e,sourceY:n,targetX:i,targetY:s,sourceControlX:o,sourceControlY:u,targetControlX:l,targetControlY:c}){const d=e*.125+o*.375+l*.375+i*.125,h=n*.125+u*.375+c*.375+s*.125,p=Math.abs(d-e),m=Math.abs(h-n);return[d,h,p,m]}var Mi;(function(e){e.Strict="strict",e.Loose="loose"})(Mi||(Mi={}));var Ti;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ti||(Ti={}));var Oo;(function(e){e.Partial="partial",e.Full="full"})(Oo||(Oo={}));var Qr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Qr||(Qr={}));var _u;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(_u||(_u={}));var Ce;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ce||(Ce={}));function yw({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 lE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:u=Ce.Top}){const[l,c]=yw({pos:i,x1:e,y1:n,x2:s,y2:o}),[d,h]=yw({pos:u,x1:s,y1:o,x2:e,y2:n}),[p,m,y,x]=uE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${n} C${l},${c} ${d},${h} ${s},${o}`,p,m,y,x]}const Ug=q.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:u=Ce.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:_})=>{const[S,b,k]=lE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:u});return oe.createElement(Fo,{path:S,labelX:b,labelY:k,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:_})});Ug.displayName="SimpleBezierEdge";const ww={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},GA=({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},xw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function YA({source:e,sourcePosition:n=Ce.Bottom,target:i,targetPosition:s=Ce.Top,center:o,offset:u}){const l=ww[n],c=ww[s],d={x:e.x+l.x*u,y:e.y+l.y*u},h={x:i.x+c.x*u,y:i.y+c.y*u},p=GA({source:d,sourcePosition:n,target:h}),m=p.x!==0?"x":"y",y=p[m];let x=[],N,_;const S={x:0,y:0},b={x:0,y:0},[k,E,C,A]=aE({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(l[m]*c[m]===-1){N=o.x??k,_=o.y??E;const I=[{x:N,y:d.y},{x:N,y:h.y}],M=[{x:d.x,y:_},{x:h.x,y:_}];l[m]===y?x=m==="x"?I:M:x=m==="x"?M:I}else{const I=[{x:d.x,y:h.y}],M=[{x:h.x,y:d.y}];if(m==="x"?x=l.x===y?M:I:x=l.y===y?I:M,n===s){const X=Math.abs(e[m]-i[m]);if(X<=u){const j=Math.min(u-1,u-X);l[m]===y?S[m]=(d[m]>e[m]?-1:1)*j:b[m]=(h[m]>i[m]?-1:1)*j}}if(n!==s){const X=m==="x"?"y":"x",j=l[m]===c[X],G=d[X]>h[X],U=d[X]<h[X];(l[m]===1&&(!j&&G||j&&U)||l[m]!==1&&(!j&&U||j&&G))&&(x=m==="x"?I:M)}const R={x:d.x+S.x,y:d.y+S.y},L={x:h.x+b.x,y:h.y+b.y},F=Math.max(Math.abs(R.x-x[0].x),Math.abs(L.x-x[0].x)),Q=Math.max(Math.abs(R.y-x[0].y),Math.abs(L.y-x[0].y));F>=Q?(N=(R.x+L.x)/2,_=x[0].y):(N=x[0].x,_=(R.y+L.y)/2)}return[[e,{x:d.x+S.x,y:d.y+S.y},...x,{x:h.x+b.x,y:h.y+b.y},i],N,_,C,A]}function KA(e,n,i,s){const o=Math.min(xw(e,n)/2,xw(n,i)/2,s),{x:u,y:l}=n;if(e.x===u&&u===i.x||e.y===l&&l===i.y)return`L${u} ${l}`;if(e.y===l){const h=e.x<i.x?-1:1,p=e.y<i.y?1:-1;return`L ${u+o*h},${l}Q ${u},${l} ${u},${l+o*p}`}const c=e.x<i.x?1:-1,d=e.y<i.y?-1:1;return`L ${u},${l+o*d}Q ${u},${l} ${u+o*c},${l}`}function _g({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:u=Ce.Top,borderRadius:l=5,centerX:c,centerY:d,offset:h=20}){const[p,m,y,x,N]=YA({source:{x:e,y:n},sourcePosition:i,target:{x:s,y:o},targetPosition:u,center:{x:c,y:d},offset:h});return[p.reduce((S,b,k)=>{let E="";return k>0&&k<p.length-1?E=KA(p[k-1],b,p[k+1],l):E=`${k===0?"M":"L"}${b.x} ${b.y}`,S+=E,S},""),m,y,x,N]}const Au=q.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,sourcePosition:m=Ce.Bottom,targetPosition:y=Ce.Top,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:S})=>{const[b,k,E]=_g({sourceX:e,sourceY:n,sourcePosition:m,targetX:i,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return oe.createElement(Fo,{path:b,labelX:k,labelY:E,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,markerEnd:x,markerStart:N,interactionWidth:S})});Au.displayName="SmoothStepEdge";const Hg=q.memo(e=>{var n;return oe.createElement(Au,{...e,pathOptions:q.useMemo(()=>{var i;return{borderRadius:0,offset:(i=e.pathOptions)==null?void 0:i.offset}},[(n=e.pathOptions)==null?void 0:n.offset])})});Hg.displayName="StepEdge";function XA({sourceX:e,sourceY:n,targetX:i,targetY:s}){const[o,u,l,c]=aE({sourceX:e,sourceY:n,targetX:i,targetY:s});return[`M ${e},${n}L ${i},${s}`,o,u,l,c]}const Vg=q.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:x})=>{const[N,_,S]=XA({sourceX:e,sourceY:n,targetX:i,targetY:s});return oe.createElement(Fo,{path:N,labelX:_,labelY:S,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:x})});Vg.displayName="StraightEdge";function tu(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function _w({pos:e,x1:n,y1:i,x2:s,y2:o,c:u}){switch(e){case Ce.Left:return[n-tu(n-s,u),i];case Ce.Right:return[n+tu(s-n,u),i];case Ce.Top:return[n,i-tu(i-o,u)];case Ce.Bottom:return[n,i+tu(o-i,u)]}}function cE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:u=Ce.Top,curvature:l=.25}){const[c,d]=_w({pos:i,x1:e,y1:n,x2:s,y2:o,c:l}),[h,p]=_w({pos:u,x1:s,y1:o,x2:e,y2:n,c:l}),[m,y,x,N]=uE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:p});return[`M${e},${n} C${c},${d} ${h},${p} ${s},${o}`,m,y,x,N]}const Su=q.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:u=Ce.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:S})=>{const[b,k,E]=cE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:u,curvature:_==null?void 0:_.curvature});return oe.createElement(Fo,{path:b,labelX:k,labelY:E,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:S})});Su.displayName="BezierEdge";const Wg=q.createContext(null),QA=Wg.Provider;Wg.Consumer;const ZA=()=>q.useContext(Wg),JA=e=>"id"in e&&"source"in e&&"target"in e,eI=({source:e,sourceHandle:n,target:i,targetHandle:s})=>`reactflow__edge-${e}${n||""}-${i}${s||""}`,Sg=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,tI=(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)),nI=(e,n)=>{if(!e.source||!e.target)return n;let i;return JA(e)?i={...e}:i={...e,id:eI(e)},tI(i,n)?n:n.concat(i)},bg=({x:e,y:n},[i,s,o],u,[l,c])=>{const d={x:(e-i)/o,y:(n-s)/o};return u?{x:l*Math.round(d.x/l),y:c*Math.round(d.y/c)}:d},fE=({x:e,y:n},[i,s,o])=>({x:e*o+i,y:n*o+s}),ji=(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}},Iu=(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:u,y:l}=ji(o,n).positionAbsolute;return rE(s,Po({x:u,y:l,width:o.width||0,height:o.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return iE(i)},dE=(e,n,[i,s,o]=[0,0,1],u=!1,l=!1,c=[0,0])=>{const d={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:x=!0,hidden:N=!1}=p;if(l&&!x||N)return!1;const{positionAbsolute:_}=ji(p,c),S={x:_.x,y:_.y,width:m||0,height:y||0},b=wg(d,S),k=typeof m>"u"||typeof y>"u"||m===null||y===null,E=u&&b>0,C=(m||0)*(y||0);(k||E||b>=C||p.dragging)&&h.push(p)}),h},hE=(e,n)=>{const i=e.map(s=>s.id);return n.filter(s=>i.includes(s.source)||i.includes(s.target))},pE=(e,n,i,s,o,u=.1)=>{const l=n/(e.width*(1+u)),c=i/(e.height*(1+u)),d=Math.min(l,c),h=js(d,s,o),p=e.x+e.width/2,m=e.y+e.height/2,y=n/2-p*h,x=i/2-m*h;return{x:y,y:x,zoom:h}},Ni=(e,n=0)=>e.transition().duration(n);function Sw(e,n,i,s){return(n[i]||[]).reduce((o,u)=>{var l,c;return`${e.id}-${u.id}-${i}`!==s&&o.push({id:u.id||null,type:i,nodeId:e.id,x:(((l=e.positionAbsolute)==null?void 0:l.x)??0)+u.x+u.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+u.y+u.height/2}),o},[])}function rI(e,n,i,s,o,u){const{x:l,y:c}=Zr(e),h=n.elementsFromPoint(l,c).find(N=>N.classList.contains("react-flow__handle"));if(h){const N=h.getAttribute("data-nodeid");if(N){const _=Gg(void 0,h),S=h.getAttribute("data-handleid"),b=u({nodeId:N,id:S,type:_});if(b){const k=o.find(E=>E.nodeId===N&&E.type===_&&E.id===S);return{handle:{id:S,type:_,nodeId:N,x:(k==null?void 0:k.x)||i.x,y:(k==null?void 0:k.y)||i.y},validHandleResult:b}}}}let p=[],m=1/0;if(o.forEach(N=>{const _=Math.sqrt((N.x-i.x)**2+(N.y-i.y)**2);if(_<=s){const S=u(N);_<=m&&(_<m?p=[{handle:N,validHandleResult:S}]:_===m&&p.push({handle:N,validHandleResult:S}),m=_)}}),!p.length)return{handle:null,validHandleResult:mE()};if(p.length===1)return p[0];const y=p.some(({validHandleResult:N})=>N.isValid),x=p.some(({handle:N})=>N.type==="target");return p.find(({handle:N,validHandleResult:_})=>x?N.type==="target":y?_.isValid:!0)||p[0]}const iI={source:null,target:null,sourceHandle:null,targetHandle:null},mE=()=>({handleDomNode:null,isValid:!1,connection:iI,endHandle:null});function gE(e,n,i,s,o,u,l){const c=o==="target",d=l.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={...mE(),handleDomNode:d};if(d){const p=Gg(void 0,d),m=d.getAttribute("data-nodeid"),y=d.getAttribute("data-handleid"),x=d.classList.contains("connectable"),N=d.classList.contains("connectableend"),_={source:c?m:i,sourceHandle:c?y:s,target:c?i:m,targetHandle:c?s:y};h.connection=_,x&&N&&(n===Mi.Strict?c&&p==="source"||!c&&p==="target":m!==i||y!==s)&&(h.endHandle={nodeId:m,handleId:y,type:p},h.isValid=u(_))}return h}function sI({nodes:e,nodeId:n,handleId:i,handleType:s}){return e.reduce((o,u)=>{if(u[ht]){const{handleBounds:l}=u[ht];let c=[],d=[];l&&(c=Sw(u,l,"source",`${n}-${i}-${s}`),d=Sw(u,l,"target",`${n}-${i}-${s}`)),o.push(...c,...d)}return o},[])}function Gg(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Dc(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function oI(e,n){let i=null;return n?i="valid":e&&!n&&(i="invalid"),i}function vE({event:e,handleId:n,nodeId:i,onConnect:s,isTarget:o,getState:u,setState:l,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const p=nE(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:x,connectionRadius:N,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:k}=u();let E=0,C;const{x:A,y:P}=Zr(e),I=p==null?void 0:p.elementFromPoint(A,P),M=Gg(d,I),R=y==null?void 0:y.getBoundingClientRect();if(!R||!M)return;let L,F=Zr(e,R),Q=!1,X=null,j=!1,G=null;const U=sI({nodes:b(),nodeId:i,handleId:n,handleType:M}),ne=()=>{if(!x)return;const[V,O]=tE(F,R);S({x:V,y:O}),E=requestAnimationFrame(ne)};l({connectionPosition:F,connectionStatus:null,connectionNodeId:i,connectionHandleId:n,connectionHandleType:M,connectionStartHandle:{nodeId:i,handleId:n,type:M},connectionEndHandle:null}),_==null||_(e,{nodeId:i,handleId:n,handleType:M});function K(V){const{transform:O}=u();F=Zr(V,R);const{handle:B,validHandleResult:ae}=rI(V,p,bg(F,O,!1,[1,1]),N,U,z=>gE(z,m,i,n,o?"target":"source",c,p));if(C=B,Q||(ne(),Q=!0),G=ae.handleDomNode,X=ae.connection,j=ae.isValid,l({connectionPosition:C&&j?fE({x:C.x,y:C.y},O):F,connectionStatus:oI(!!C,j),connectionEndHandle:ae.endHandle}),!C&&!j&&!G)return Dc(L);X.source!==X.target&&G&&(Dc(L),L=G,G.classList.add("connecting","react-flow__handle-connecting"),G.classList.toggle("valid",j),G.classList.toggle("react-flow__handle-valid",j))}function D(V){var O,B;(C||G)&&X&&j&&(s==null||s(X)),(B=(O=u()).onConnectEnd)==null||B.call(O,V),d&&(h==null||h(V)),Dc(L),k(),cancelAnimationFrame(E),Q=!1,j=!1,X=null,G=null,p.removeEventListener("mousemove",K),p.removeEventListener("mouseup",D),p.removeEventListener("touchmove",K),p.removeEventListener("touchend",D)}p.addEventListener("mousemove",K),p.addEventListener("mouseup",D),p.addEventListener("touchmove",K),p.addEventListener("touchend",D)}const bw=()=>!0,aI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),uI=(e,n,i)=>s=>{const{connectionStartHandle:o,connectionEndHandle:u,connectionClickStartHandle:l}=s;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===n&&(o==null?void 0:o.type)===i||(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===n&&(u==null?void 0:u.type)===i,clickConnecting:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===n&&(l==null?void 0:l.type)===i}},yE=q.forwardRef(({type:e="source",position:n=Ce.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:u=!0,id:l,onConnect:c,children:d,className:h,onMouseDown:p,onTouchStart:m,...y},x)=>{var R,L;const N=l||null,_=e==="target",S=bt(),b=ZA(),{connectOnClick:k,noPanClassName:E}=Xe(aI,St),{connecting:C,clickConnecting:A}=Xe(uI(b,N,e),St);b||(L=(R=S.getState()).onError)==null||L.call(R,"010",yr.error010());const P=F=>{const{defaultEdgeOptions:Q,onConnect:X,hasDefaultEdges:j}=S.getState(),G={...Q,...F};if(j){const{edges:U,setEdges:ne}=S.getState();ne(nI(G,U))}X==null||X(G),c==null||c(G)},I=F=>{if(!b)return;const Q=oE(F);o&&(Q&&F.button===0||!Q)&&vE({event:F,handleId:N,nodeId:b,onConnect:P,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:i||S.getState().isValidConnection||bw}),Q?p==null||p(F):m==null||m(F)},M=F=>{const{onClickConnectStart:Q,onClickConnectEnd:X,connectionClickStartHandle:j,connectionMode:G,isValidConnection:U}=S.getState();if(!b||!j&&!o)return;if(!j){Q==null||Q(F,{nodeId:b,handleId:N,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:N}});return}const ne=nE(F.target),K=i||U||bw,{connection:D,isValid:V}=gE({nodeId:b,id:N,type:e},G,j.nodeId,j.handleId||null,j.type,K,ne);V&&P(D),X==null||X(F),S.setState({connectionClickStartHandle:null})};return oe.createElement("div",{"data-handleid":N,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${N}-${e}`,className:qt(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",E,h,{source:!_,target:_,connectable:s,connectablestart:o,connectableend:u,connecting:A,connectionindicator:s&&(o&&!C||u&&C)}]),onMouseDown:I,onTouchStart:I,onClick:k?M:void 0,ref:x,...y},d)});yE.displayName="Handle";var As=q.memo(yE);const wE=({data:e,isConnectable:n,targetPosition:i=Ce.Top,sourcePosition:s=Ce.Bottom})=>oe.createElement(oe.Fragment,null,oe.createElement(As,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label,oe.createElement(As,{type:"source",position:s,isConnectable:n}));wE.displayName="DefaultNode";var kg=q.memo(wE);const xE=({data:e,isConnectable:n,sourcePosition:i=Ce.Bottom})=>oe.createElement(oe.Fragment,null,e==null?void 0:e.label,oe.createElement(As,{type:"source",position:i,isConnectable:n}));xE.displayName="InputNode";var _E=q.memo(xE);const SE=({data:e,isConnectable:n,targetPosition:i=Ce.Top})=>oe.createElement(oe.Fragment,null,oe.createElement(As,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label);SE.displayName="OutputNode";var bE=q.memo(SE);const Yg=()=>null;Yg.displayName="GroupNode";const lI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),nu=e=>e.id;function cI(e,n){return St(e.selectedNodes.map(nu),n.selectedNodes.map(nu))&&St(e.selectedEdges.map(nu),n.selectedEdges.map(nu))}const kE=q.memo(({onSelectionChange:e})=>{const n=bt(),{selectedNodes:i,selectedEdges:s}=Xe(lI,cI);return q.useEffect(()=>{const o={nodes:i,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(u=>u(o))},[i,s,e]),null});kE.displayName="SelectionListener";const fI=e=>!!e.onSelectionChange;function dI({onSelectionChange:e}){const n=Xe(fI);return e||n?oe.createElement(kE,{onSelectionChange:e}):null}const hI=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 gs(e,n){q.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function De(e,n,i){q.useEffect(()=>{typeof n<"u"&&i({[e]:n})},[n])}const pI=({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:o,onConnectStart:u,onConnectEnd:l,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:p,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:x,elevateNodesOnSelect:N,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:k,onEdgesChange:E,elementsSelectable:C,connectionMode:A,snapGrid:P,snapToGrid:I,translateExtent:M,connectOnClick:R,defaultEdgeOptions:L,fitView:F,fitViewOptions:Q,onNodesDelete:X,onEdgesDelete:j,onNodeDrag:G,onNodeDragStart:U,onNodeDragStop:ne,onSelectionDrag:K,onSelectionDragStart:D,onSelectionDragStop:V,noPanClassName:O,nodeOrigin:B,rfId:ae,autoPanOnConnect:z,autoPanOnNodeDrag:W,onError:J,connectionRadius:se,isValidConnection:ue,nodeDragThreshold:he})=>{const{setNodes:ge,setEdges:Me,setDefaultNodesAndEdges:Fe,setMinZoom:Re,setMaxZoom:Pe,setTranslateExtent:be,setNodeExtent:Oe,reset:ve}=Xe(hI,St),ye=bt();return q.useEffect(()=>{const qe=s==null?void 0:s.map(Ye=>({...Ye,...L}));return Fe(i,qe),()=>{ve()}},[]),De("defaultEdgeOptions",L,ye.setState),De("connectionMode",A,ye.setState),De("onConnect",o,ye.setState),De("onConnectStart",u,ye.setState),De("onConnectEnd",l,ye.setState),De("onClickConnectStart",c,ye.setState),De("onClickConnectEnd",d,ye.setState),De("nodesDraggable",h,ye.setState),De("nodesConnectable",p,ye.setState),De("nodesFocusable",m,ye.setState),De("edgesFocusable",y,ye.setState),De("edgesUpdatable",x,ye.setState),De("elementsSelectable",C,ye.setState),De("elevateNodesOnSelect",N,ye.setState),De("snapToGrid",I,ye.setState),De("snapGrid",P,ye.setState),De("onNodesChange",k,ye.setState),De("onEdgesChange",E,ye.setState),De("connectOnClick",R,ye.setState),De("fitViewOnInit",F,ye.setState),De("fitViewOnInitOptions",Q,ye.setState),De("onNodesDelete",X,ye.setState),De("onEdgesDelete",j,ye.setState),De("onNodeDrag",G,ye.setState),De("onNodeDragStart",U,ye.setState),De("onNodeDragStop",ne,ye.setState),De("onSelectionDrag",K,ye.setState),De("onSelectionDragStart",D,ye.setState),De("onSelectionDragStop",V,ye.setState),De("noPanClassName",O,ye.setState),De("nodeOrigin",B,ye.setState),De("rfId",ae,ye.setState),De("autoPanOnConnect",z,ye.setState),De("autoPanOnNodeDrag",W,ye.setState),De("onError",J,ye.setState),De("connectionRadius",se,ye.setState),De("isValidConnection",ue,ye.setState),De("nodeDragThreshold",he,ye.setState),gs(e,ge),gs(n,Me),gs(_,Re),gs(S,Pe),gs(M,be),gs(b,Oe),null},kw={display:"none"},mI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},EE="react-flow__node-desc",NE="react-flow__edge-desc",gI="react-flow__aria-live",vI=e=>e.ariaLiveMessage;function yI({rfId:e}){const n=Xe(vI);return oe.createElement("div",{id:`${gI}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mI},n)}function wI({rfId:e,disableKeyboardA11y:n}){return oe.createElement(oe.Fragment,null,oe.createElement("div",{id:`${EE}-${e}`,style:kw},"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."," "),oe.createElement("div",{id:`${NE}-${e}`,style:kw},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&oe.createElement(yI,{rfId:e}))}var qo=(e=null,n={actInsideInputWithModifier:!0})=>{const[i,s]=q.useState(!1),o=q.useRef(!1),u=q.useRef(new Set([])),[l,c]=q.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 q.useEffect(()=>{const d=typeof document<"u"?document:null,h=(n==null?void 0:n.target)||d;if(e!==null){const p=x=>{if(o.current=x.ctrlKey||x.metaKey||x.shiftKey,(!o.current||o.current&&!n.actInsideInputWithModifier)&&xg(x))return!1;const _=Nw(x.code,c);u.current.add(x[_]),Ew(l,u.current,!1)&&(x.preventDefault(),s(!0))},m=x=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&xg(x))return!1;const _=Nw(x.code,c);Ew(l,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(x[_]),x.key==="Meta"&&u.current.clear(),o.current=!1},y=()=>{u.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 Ew(e,n,i){return e.filter(s=>i||s.length===n.size).some(s=>s.every(o=>n.has(o)))}function Nw(e,n){return n.includes(e)?"code":"key"}function CE(e,n,i,s){var c,d;const o=e.parentNode||e.parentId;if(!o)return i;const u=n.get(o),l=ji(u,s);return CE(u,n,{x:(i.x??0)+l.x,y:(i.y??0)+l.y,z:(((c=u[ht])==null?void 0:c.z)??0)>(i.z??0)?((d=u[ht])==null?void 0:d.z)??0:i.z??0},s)}function TE(e,n,i){e.forEach(s=>{var u;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:l,y:c,z:d}=CE(s,e,{...s.position,z:((u=s[ht])==null?void 0:u.z)??0},n);s.positionAbsolute={x:l,y:c},s[ht].z=d,i!=null&&i[s.id]&&(s[ht].isParent=!0)}})}function Fc(e,n,i,s){const o=new Map,u={},l=s?1e3:0;return e.forEach(c=>{var x;const d=(jn(c.zIndex)?c.zIndex:0)+(c.selected?l:0),h=n.get(c.id),p={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},m=c.parentNode||c.parentId;m&&(u[m]=!0);const y=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(p,ht,{enumerable:!1,value:{handleBounds:y||(x=h==null?void 0:h[ht])==null?void 0:x.handleBounds,z:d}}),o.set(c.id,p)}),TE(o,i,u),o}function RE(e,n={}){const{getNodes:i,width:s,height:o,minZoom:u,maxZoom:l,d3Zoom:c,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:p,nodeOrigin:m}=e(),y=n.initial&&!h&&p;if(c&&d&&(y||!n.initial)){const N=i().filter(S=>{var k;const b=n.includeHiddenNodes?S.width&&S.height:!S.hidden;return(k=n.nodes)!=null&&k.length?b&&n.nodes.some(E=>E.id===S.id):b}),_=N.every(S=>S.width&&S.height);if(N.length>0&&_){const S=Iu(N,m),{x:b,y:k,zoom:E}=pE(S,s,o,n.minZoom??u,n.maxZoom??l,n.padding??.1),C=gr.translate(b,k).scale(E);return typeof n.duration=="number"&&n.duration>0?c.transform(Ni(d,n.duration),C):c.transform(d,C),!0}}return!1}function xI(e,n){return e.forEach(i=>{const s=n.get(i.id);s&&n.set(s.id,{...s,[ht]:s[ht],selected:i.selected})}),new Map(n)}function _I(e,n){return n.map(i=>{const s=e.find(o=>o.id===i.id);return s&&(i.selected=s.selected),i})}function ru({changedNodes:e,changedEdges:n,get:i,set:s}){const{nodeInternals:o,edges:u,onNodesChange:l,onEdgesChange:c,hasDefaultNodes:d,hasDefaultEdges:h}=i();e!=null&&e.length&&(d&&s({nodeInternals:xI(e,o)}),l==null||l(e)),n!=null&&n.length&&(h&&s({edges:_I(n,u)}),c==null||c(n))}const vs=()=>{},SI={zoomIn:vs,zoomOut:vs,zoomTo:vs,getZoom:()=>1,setViewport:vs,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:vs,fitBounds:vs,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},bI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),kI=()=>{const e=bt(),{d3Zoom:n,d3Selection:i}=Xe(bI,St);return q.useMemo(()=>i&&n?{zoomIn:o=>n.scaleBy(Ni(i,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(Ni(i,o==null?void 0:o.duration),1/1.2),zoomTo:(o,u)=>n.scaleTo(Ni(i,u==null?void 0:u.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,u)=>{const[l,c,d]=e.getState().transform,h=gr.translate(o.x??l,o.y??c).scale(o.zoom??d);n.transform(Ni(i,u==null?void 0:u.duration),h)},getViewport:()=>{const[o,u,l]=e.getState().transform;return{x:o,y:u,zoom:l}},fitView:o=>RE(e.getState,o),setCenter:(o,u,l)=>{const{width:c,height:d,maxZoom:h}=e.getState(),p=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:h,m=c/2-o*p,y=d/2-u*p,x=gr.translate(m,y).scale(p);n.transform(Ni(i,l==null?void 0:l.duration),x)},fitBounds:(o,u)=>{const{width:l,height:c,minZoom:d,maxZoom:h}=e.getState(),{x:p,y:m,zoom:y}=pE(o,l,c,d,h,(u==null?void 0:u.padding)??.1),x=gr.translate(p,m).scale(y);n.transform(Ni(i,u==null?void 0:u.duration),x)},project:o=>{const{transform:u,snapToGrid:l,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"),bg(o,u,l,c)},screenToFlowPosition:o=>{const{transform:u,snapToGrid:l,snapGrid:c,domNode:d}=e.getState();if(!d)return o;const{x:h,y:p}=d.getBoundingClientRect(),m={x:o.x-h,y:o.y-p};return bg(m,u,l,c)},flowToScreenPosition:o=>{const{transform:u,domNode:l}=e.getState();if(!l)return o;const{x:c,y:d}=l.getBoundingClientRect(),h=fE(o,u);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:SI,[n,i])};function zo(){const e=kI(),n=bt(),i=q.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),s=q.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=q.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(S=>({...S}))},[]),u=q.useCallback(_=>{const{edges:S=[]}=n.getState();return S.find(b=>b.id===_)},[]),l=q.useCallback(_=>{const{getNodes:S,setNodes:b,hasDefaultNodes:k,onNodesChange:E}=n.getState(),C=S(),A=typeof _=="function"?_(C):_;if(k)b(A);else if(E){const P=A.length===0?C.map(I=>({type:"remove",id:I.id})):A.map(I=>({item:I,type:"reset"}));E(P)}},[]),c=q.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:k,onEdgesChange:E}=n.getState(),C=typeof _=="function"?_(S):_;if(k)b(C);else if(E){const A=C.length===0?S.map(P=>({type:"remove",id:P.id})):C.map(P=>({item:P,type:"reset"}));E(A)}},[]),d=q.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:k,hasDefaultNodes:E,onNodesChange:C}=n.getState();if(E){const P=[...b(),...S];k(P)}else if(C){const A=S.map(P=>({item:P,type:"add"}));C(A)}},[]),h=q.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:k,hasDefaultEdges:E,onEdgesChange:C}=n.getState();if(E)k([...b,...S]);else if(C){const A=S.map(P=>({item:P,type:"add"}));C(A)}},[]),p=q.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[k,E,C]=b;return{nodes:_().map(A=>({...A})),edges:S.map(A=>({...A})),viewport:{x:k,y:E,zoom:C}}},[]),m=q.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:k,edges:E,hasDefaultNodes:C,hasDefaultEdges:A,onNodesDelete:P,onEdgesDelete:I,onNodesChange:M,onEdgesChange:R}=n.getState(),L=(_||[]).map(G=>G.id),F=(S||[]).map(G=>G.id),Q=k().reduce((G,U)=>{const ne=U.parentNode||U.parentId,K=!L.includes(U.id)&&ne&&G.find(V=>V.id===ne);return(typeof U.deletable=="boolean"?U.deletable:!0)&&(L.includes(U.id)||K)&&G.push(U),G},[]),X=E.filter(G=>typeof G.deletable=="boolean"?G.deletable:!0),j=X.filter(G=>F.includes(G.id));if(Q||j){const G=hE(Q,X),U=[...j,...G],ne=U.reduce((K,D)=>(K.includes(D.id)||K.push(D.id),K),[]);if((A||C)&&(A&&n.setState({edges:E.filter(K=>!ne.includes(K.id))}),C&&(Q.forEach(K=>{b.delete(K.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(I==null||I(U),R&&R(ne.map(K=>({id:K,type:"remove"})))),Q.length>0&&(P==null||P(Q),M)){const K=Q.map(D=>({id:D.id,type:"remove"}));M(K)}}},[]),y=q.useCallback(_=>{const S=HA(_),b=S?null:n.getState().nodeInternals.get(_.id);return!S&&!b?[null,null,S]:[S?_:vw(b),b,S]},[]),x=q.useCallback((_,S=!0,b)=>{const[k,E,C]=y(_);return k?(b||n.getState().getNodes()).filter(A=>{if(!C&&(A.id===E.id||!A.positionAbsolute))return!1;const P=vw(A),I=wg(P,k);return S&&I>0||I>=k.width*k.height}):[]},[]),N=q.useCallback((_,S,b=!0)=>{const[k]=y(_);if(!k)return!1;const E=wg(k,S);return b&&E>0||E>=k.width*k.height},[]);return q.useMemo(()=>({...e,getNodes:i,getNode:s,getEdges:o,getEdge:u,setNodes:l,setEdges:c,addNodes:d,addEdges:h,toObject:p,deleteElements:m,getIntersectingNodes:x,isNodeIntersecting:N}),[e,i,s,o,u,l,c,d,h,p,m,x,N])}const EI={actInsideInputWithModifier:!1};var NI=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const i=bt(),{deleteElements:s}=zo(),o=qo(e,EI),u=qo(n);q.useEffect(()=>{if(o){const{edges:l,getNodes:c}=i.getState(),d=c().filter(p=>p.selected),h=l.filter(p=>p.selected);s({nodes:d,edges:h}),i.setState({nodesSelectionActive:!1})}},[o]),q.useEffect(()=>{i.setState({multiSelectionActive:u})},[u])};function CI(e){const n=bt();q.useEffect(()=>{let i;const s=()=>{var u,l;if(!e.current)return;const o=zg(e.current);(o.height===0||o.width===0)&&((l=(u=n.getState()).onError)==null||l.call(u,"004",yr.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 Kg={position:"absolute",width:"100%",height:"100%",top:0,left:0},TI=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,iu=e=>({x:e.x,y:e.y,zoom:e.k}),ys=(e,n)=>e.target.closest(`.${n}`),Cw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Tw=e=>{const n=e.ctrlKey&&xu()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},RI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),jI=({onMove:e,onMoveStart:n,onMoveEnd:i,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:u=!0,panOnScroll:l=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Ti.Free,zoomOnDoubleClick:h=!0,elementsSelectable:p,panOnDrag:m=!0,defaultViewport:y,translateExtent:x,minZoom:N,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:k,noWheelClassName:E,noPanClassName:C})=>{const A=q.useRef(),P=bt(),I=q.useRef(!1),M=q.useRef(!1),R=q.useRef(null),L=q.useRef({x:0,y:0,zoom:0}),{d3Zoom:F,d3Selection:Q,d3ZoomHandler:X,userSelectionActive:j}=Xe(RI,St),G=qo(S),U=q.useRef(0),ne=q.useRef(!1),K=q.useRef();return CI(R),q.useEffect(()=>{if(R.current){const D=R.current.getBoundingClientRect(),V=Jk().scaleExtent([N,_]).translateExtent(x),O=Rn(R.current).call(V),B=gr.translate(y.x,y.y).scale(js(y.zoom,N,_)),ae=[[0,0],[D.width,D.height]],z=V.constrain()(B,ae,x);V.transform(O,z),V.wheelDelta(Tw),P.setState({d3Zoom:V,d3Selection:O,d3ZoomHandler:O.on("wheel.zoom"),transform:[z.x,z.y,z.k],domNode:R.current.closest(".react-flow")})}},[]),q.useEffect(()=>{Q&&F&&(l&&!G&&!j?Q.on("wheel.zoom",D=>{if(ys(D,E))return!1;D.preventDefault(),D.stopImmediatePropagation();const V=Q.property("__zoom").k||1;if(D.ctrlKey&&u){const ue=Bn(D),he=Tw(D),ge=V*Math.pow(2,he);F.scaleTo(Q,ge,ue,D);return}const O=D.deltaMode===1?20:1;let B=d===Ti.Vertical?0:D.deltaX*O,ae=d===Ti.Horizontal?0:D.deltaY*O;!xu()&&D.shiftKey&&d!==Ti.Vertical&&(B=D.deltaY*O,ae=0),F.translateBy(Q,-(B/V)*c,-(ae/V)*c,{internal:!0});const z=iu(Q.property("__zoom")),{onViewportChangeStart:W,onViewportChange:J,onViewportChangeEnd:se}=P.getState();clearTimeout(K.current),ne.current||(ne.current=!0,n==null||n(D,z),W==null||W(z)),ne.current&&(e==null||e(D,z),J==null||J(z),K.current=setTimeout(()=>{i==null||i(D,z),se==null||se(z),ne.current=!1},150))},{passive:!1}):typeof X<"u"&&Q.on("wheel.zoom",function(D,V){if(!b&&D.type==="wheel"&&!D.ctrlKey||ys(D,E))return null;D.preventDefault(),X.call(this,D,V)},{passive:!1}))},[j,l,d,Q,F,X,G,u,b,E,n,e,i]),q.useEffect(()=>{F&&F.on("start",D=>{var B,ae;if(!D.sourceEvent||D.sourceEvent.internal)return null;U.current=(B=D.sourceEvent)==null?void 0:B.button;const{onViewportChangeStart:V}=P.getState(),O=iu(D.transform);I.current=!0,L.current=O,((ae=D.sourceEvent)==null?void 0:ae.type)==="mousedown"&&P.setState({paneDragging:!0}),V==null||V(O),n==null||n(D.sourceEvent,O)})},[F,n]),q.useEffect(()=>{F&&(j&&!I.current?F.on("zoom",null):j||F.on("zoom",D=>{var O;const{onViewportChange:V}=P.getState();if(P.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),M.current=!!(s&&Cw(m,U.current??0)),(e||V)&&!((O=D.sourceEvent)!=null&&O.internal)){const B=iu(D.transform);V==null||V(B),e==null||e(D.sourceEvent,B)}}))},[j,F,e,m,s]),q.useEffect(()=>{F&&F.on("end",D=>{if(!D.sourceEvent||D.sourceEvent.internal)return null;const{onViewportChangeEnd:V}=P.getState();if(I.current=!1,P.setState({paneDragging:!1}),s&&Cw(m,U.current??0)&&!M.current&&s(D.sourceEvent),M.current=!1,(i||V)&&TI(L.current,D.transform)){const O=iu(D.transform);L.current=O,clearTimeout(A.current),A.current=setTimeout(()=>{V==null||V(O),i==null||i(D.sourceEvent,O)},l?150:0)}})},[F,l,m,i,s]),q.useEffect(()=>{F&&F.filter(D=>{const V=G||o,O=u&&D.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&D.button===1&&D.type==="mousedown"&&(ys(D,"react-flow__node")||ys(D,"react-flow__edge")))return!0;if(!m&&!V&&!l&&!h&&!u||j||!h&&D.type==="dblclick"||ys(D,E)&&D.type==="wheel"||ys(D,C)&&(D.type!=="wheel"||l&&D.type==="wheel"&&!G)||!u&&D.ctrlKey&&D.type==="wheel"||!V&&!l&&!O&&D.type==="wheel"||!m&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(m)&&!m.includes(D.button)&&D.type==="mousedown")return!1;const B=Array.isArray(m)&&m.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&B})},[j,F,o,u,l,h,m,p,G]),oe.createElement("div",{className:"react-flow__renderer",ref:R,style:Kg},k)},AI=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function II(){const{userSelectionActive:e,userSelectionRect:n}=Xe(AI,St);return e&&n?oe.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 Rw(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,u=n.position.y+n.height-s.height;if(o>0||u>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),u>0&&(s.style.height+=u),n.position.x<0){const l=Math.abs(n.position.x);s.position.x=s.position.x-l,s.style.width+=l,n.position.x=0}if(n.position.y<0){const l=Math.abs(n.position.y);s.position.y=s.position.y-l,s.style.height+=l,n.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function MI(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 u=e.filter(c=>c.id===o.id);if(u.length===0)return s.push(o),s;const l={...o};for(const c of u)if(c)switch(c.type){case"select":{l.selected=c.selected;break}case"position":{typeof c.position<"u"&&(l.position=c.position),typeof c.positionAbsolute<"u"&&(l.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(l.dragging=c.dragging),l.expandParent&&Rw(s,l);break}case"dimensions":{typeof c.dimensions<"u"&&(l.width=c.dimensions.width,l.height=c.dimensions.height),typeof c.updateStyle<"u"&&(l.style={...l.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(l.resizing=c.resizing),l.expandParent&&Rw(s,l);break}case"remove":return s}return s.push(l),s},i)}function PI(e,n){return MI(e,n)}const Xr=(e,n)=>({id:e,type:"select",selected:n});function _s(e,n){return e.reduce((i,s)=>{const o=n.includes(s.id);return!s.selected&&o?(s.selected=!0,i.push(Xr(s.id,!0))):s.selected&&!o&&(s.selected=!1,i.push(Xr(s.id,!1))),i},[])}const zc=(e,n)=>i=>{i.target===n.current&&(e==null||e(i))},OI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),jE=q.memo(({isSelecting:e,selectionMode:n=Oo.Full,panOnDrag:i,onSelectionStart:s,onSelectionEnd:o,onPaneClick:u,onPaneContextMenu:l,onPaneScroll:c,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:p,children:m})=>{const y=q.useRef(null),x=bt(),N=q.useRef(0),_=q.useRef(0),S=q.useRef(),{userSelectionActive:b,elementsSelectable:k,dragging:E}=Xe(OI,St),C=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,_.current=0},A=X=>{u==null||u(X),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},P=X=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){X.preventDefault();return}l==null||l(X)},I=c?X=>c(X):void 0,M=X=>{const{resetSelectedElements:j,domNode:G}=x.getState();if(S.current=G==null?void 0:G.getBoundingClientRect(),!k||!e||X.button!==0||X.target!==y.current||!S.current)return;const{x:U,y:ne}=Zr(X,S.current);j(),x.setState({userSelectionRect:{width:0,height:0,startX:U,startY:ne,x:U,y:ne}}),s==null||s(X)},R=X=>{const{userSelectionRect:j,nodeInternals:G,edges:U,transform:ne,onNodesChange:K,onEdgesChange:D,nodeOrigin:V,getNodes:O}=x.getState();if(!e||!S.current||!j)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const B=Zr(X,S.current),ae=j.startX??0,z=j.startY??0,W={...j,x:B.x<ae?B.x:ae,y:B.y<z?B.y:z,width:Math.abs(B.x-ae),height:Math.abs(B.y-z)},J=O(),se=dE(G,W,ne,n===Oo.Partial,!0,V),ue=hE(se,U).map(ge=>ge.id),he=se.map(ge=>ge.id);if(N.current!==he.length){N.current=he.length;const ge=_s(J,he);ge.length&&(K==null||K(ge))}if(_.current!==ue.length){_.current=ue.length;const ge=_s(U,ue);ge.length&&(D==null||D(ge))}x.setState({userSelectionRect:W})},L=X=>{if(X.button!==0)return;const{userSelectionRect:j}=x.getState();!b&&j&&X.target===y.current&&(A==null||A(X)),x.setState({nodesSelectionActive:N.current>0}),C(),o==null||o(X)},F=X=>{b&&(x.setState({nodesSelectionActive:N.current>0}),o==null||o(X)),C()},Q=k&&(e||b);return oe.createElement("div",{className:qt(["react-flow__pane",{dragging:E,selection:e}]),onClick:Q?void 0:zc(A,y),onContextMenu:zc(P,y),onWheel:zc(I,y),onMouseEnter:Q?void 0:d,onMouseDown:Q?M:void 0,onMouseMove:Q?R:h,onMouseUp:Q?L:void 0,onMouseLeave:Q?F:p,ref:y,style:Kg},m,oe.createElement(II,null))});jE.displayName="Pane";function AE(e,n){const i=e.parentNode||e.parentId;if(!i)return!1;const s=n.get(i);return s?s.selected?!0:AE(s,n):!1}function jw(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 qI(e,n,i,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!AE(o,e))&&(o.draggable||n&&typeof o.draggable>"u")).map(o=>{var u,l;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:i.x-(((u=o.positionAbsolute)==null?void 0:u.x)??0),y:i.y-(((l=o.positionAbsolute)==null?void 0:l.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 LI(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function IE(e,n,i,s,o=[0,0],u){const l=LI(e,e.extent||s);let c=l;const d=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(d&&e.width&&e.height){const m=i.get(d),{x:y,y:x}=ji(m,o).positionAbsolute;c=m&&jn(y)&&jn(x)&&jn(m.width)&&jn(m.height)?[[y+e.width*o[0],x+e.height*o[1]],[y+m.width-e.width+e.width*o[0],x+m.height-e.height+e.height*o[1]]]:c}else u==null||u("005",yr.error005()),c=l;else if(e.extent&&d&&e.extent!=="parent"){const m=i.get(d),{x:y,y:x}=ji(m,o).positionAbsolute;c=[[e.extent[0][0]+y,e.extent[0][1]+x],[e.extent[1][0]+y,e.extent[1][1]+x]]}let h={x:0,y:0};if(d){const m=i.get(d);h=ji(m,o).positionAbsolute}const p=c&&c!=="parent"?Bg(n,c):n;return{position:{x:p.x-h.x,y:p.y-h.y},positionAbsolute:p}}function Bc({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 Aw=(e,n,i,s)=>{const o=n.querySelectorAll(e);if(!o||!o.length)return null;const u=Array.from(o),l=n.getBoundingClientRect(),c={x:l.width*s[0],y:l.height*s[1]};return u.map(d=>{const h=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(h.left-l.left-c.x)/i,y:(h.top-l.top-c.y)/i,...zg(d)}})};function xo(e,n,i){return i===void 0?i:s=>{const o=n().nodeInternals.get(e);o&&i(s,{...o})}}function Eg({id:e,store:n,unselect:i=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:u,multiSelectionActive:l,nodeInternals:c,onError:d}=n.getState(),h=c.get(e);if(!h){d==null||d("012",yr.error012(e));return}n.setState({nodesSelectionActive:!1}),h.selected?(i||h.selected&&l)&&(u({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var p;return(p=s==null?void 0:s.current)==null?void 0:p.blur()})):o([e])}function $I(){const e=bt();return q.useCallback(({sourceEvent:i})=>{const{transform:s,snapGrid:o,snapToGrid:u}=e.getState(),l=i.touches?i.touches[0].clientX:i.clientX,c=i.touches?i.touches[0].clientY:i.clientY,d={x:(l-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:u?o[0]*Math.round(d.x/o[0]):d.x,ySnapped:u?o[1]*Math.round(d.y/o[1]):d.y,...d}},[])}function Uc(e){return(n,i,s)=>e==null?void 0:e(n,s)}function ME({nodeRef:e,disabled:n=!1,noDragClassName:i,handleSelector:s,nodeId:o,isSelectable:u,selectNodesOnDrag:l}){const c=bt(),[d,h]=q.useState(!1),p=q.useRef([]),m=q.useRef({x:null,y:null}),y=q.useRef(0),x=q.useRef(null),N=q.useRef({x:0,y:0}),_=q.useRef(null),S=q.useRef(!1),b=q.useRef(!1),k=q.useRef(!1),E=$I();return q.useEffect(()=>{if(e!=null&&e.current){const C=Rn(e.current),A=({x:M,y:R})=>{const{nodeInternals:L,onNodeDrag:F,onSelectionDrag:Q,updateNodePositions:X,nodeExtent:j,snapGrid:G,snapToGrid:U,nodeOrigin:ne,onError:K}=c.getState();m.current={x:M,y:R};let D=!1,V={x:0,y:0,x2:0,y2:0};if(p.current.length>1&&j){const B=Iu(p.current,ne);V=Po(B)}if(p.current=p.current.map(B=>{const ae={x:M-B.distance.x,y:R-B.distance.y};U&&(ae.x=G[0]*Math.round(ae.x/G[0]),ae.y=G[1]*Math.round(ae.y/G[1]));const z=[[j[0][0],j[0][1]],[j[1][0],j[1][1]]];p.current.length>1&&j&&!B.extent&&(z[0][0]=B.positionAbsolute.x-V.x+j[0][0],z[1][0]=B.positionAbsolute.x+(B.width??0)-V.x2+j[1][0],z[0][1]=B.positionAbsolute.y-V.y+j[0][1],z[1][1]=B.positionAbsolute.y+(B.height??0)-V.y2+j[1][1]);const W=IE(B,ae,L,z,ne,K);return D=D||B.position.x!==W.position.x||B.position.y!==W.position.y,B.position=W.position,B.positionAbsolute=W.positionAbsolute,B}),!D)return;X(p.current,!0,!0),h(!0);const O=o?F:Uc(Q);if(O&&_.current){const[B,ae]=Bc({nodeId:o,dragItems:p.current,nodeInternals:L});O(_.current,B,ae)}},P=()=>{if(!x.current)return;const[M,R]=tE(N.current,x.current);if(M!==0||R!==0){const{transform:L,panBy:F}=c.getState();m.current.x=(m.current.x??0)-M/L[2],m.current.y=(m.current.y??0)-R/L[2],F({x:M,y:R})&&A(m.current)}y.current=requestAnimationFrame(P)},I=M=>{var ne;const{nodeInternals:R,multiSelectionActive:L,nodesDraggable:F,unselectNodesAndEdges:Q,onNodeDragStart:X,onSelectionDragStart:j}=c.getState();b.current=!0;const G=o?X:Uc(j);(!l||!u)&&!L&&o&&((ne=R.get(o))!=null&&ne.selected||Q()),o&&u&&l&&Eg({id:o,store:c,nodeRef:e});const U=E(M);if(m.current=U,p.current=qI(R,F,U,o),G&&p.current){const[K,D]=Bc({nodeId:o,dragItems:p.current,nodeInternals:R});G(M.sourceEvent,K,D)}};if(n)C.on(".drag",null);else{const M=Y2().on("start",R=>{const{domNode:L,nodeDragThreshold:F}=c.getState();F===0&&I(R),k.current=!1;const Q=E(R);m.current=Q,x.current=(L==null?void 0:L.getBoundingClientRect())||null,N.current=Zr(R.sourceEvent,x.current)}).on("drag",R=>{var X,j;const L=E(R),{autoPanOnNodeDrag:F,nodeDragThreshold:Q}=c.getState();if(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!S.current&&b.current&&F&&(S.current=!0,P()),!b.current){const G=L.xSnapped-(((X=m==null?void 0:m.current)==null?void 0:X.x)??0),U=L.ySnapped-(((j=m==null?void 0:m.current)==null?void 0:j.y)??0);Math.sqrt(G*G+U*U)>Q&&I(R)}(m.current.x!==L.xSnapped||m.current.y!==L.ySnapped)&&p.current&&b.current&&(_.current=R.sourceEvent,N.current=Zr(R.sourceEvent,x.current),A(L))}}).on("end",R=>{if(!(!b.current||k.current)&&(h(!1),S.current=!1,b.current=!1,cancelAnimationFrame(y.current),p.current)){const{updateNodePositions:L,nodeInternals:F,onNodeDragStop:Q,onSelectionDragStop:X}=c.getState(),j=o?Q:Uc(X);if(L(p.current,!1,!1),j){const[G,U]=Bc({nodeId:o,dragItems:p.current,nodeInternals:F});j(R.sourceEvent,G,U)}}}).filter(R=>{const L=R.target;return!R.button&&(!i||!jw(L,`.${i}`,e))&&(!s||jw(L,s,e))});return C.call(M),()=>{C.on(".drag",null)}}}},[e,n,i,s,u,c,o,l,E]),d}function PE(){const e=bt();return q.useCallback(i=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:u,getNodes:l,snapToGrid:c,snapGrid:d,onError:h,nodesDraggable:p}=e.getState(),m=l().filter(k=>k.selected&&(k.draggable||p&&typeof k.draggable>"u")),y=c?d[0]:5,x=c?d[1]:5,N=i.isShiftPressed?4:1,_=i.x*y*N,S=i.y*x*N,b=m.map(k=>{if(k.positionAbsolute){const E={x:k.positionAbsolute.x+_,y:k.positionAbsolute.y+S};c&&(E.x=d[0]*Math.round(E.x/d[0]),E.y=d[1]*Math.round(E.y/d[1]));const{positionAbsolute:C,position:A}=IE(k,E,s,o,void 0,h);k.position=A,k.positionAbsolute=C}return k});u(b,!0,!1)},[])}const Es={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var _o=e=>{const n=({id:i,type:s,data:o,xPos:u,yPos:l,xPosOrigin:c,yPosOrigin:d,selected:h,onClick:p,onMouseEnter:m,onMouseMove:y,onMouseLeave:x,onContextMenu:N,onDoubleClick:_,style:S,className:b,isDraggable:k,isSelectable:E,isConnectable:C,isFocusable:A,selectNodesOnDrag:P,sourcePosition:I,targetPosition:M,hidden:R,resizeObserver:L,dragHandle:F,zIndex:Q,isParent:X,noDragClassName:j,noPanClassName:G,initialized:U,disableKeyboardA11y:ne,ariaLabel:K,rfId:D,hasHandleBounds:V})=>{const O=bt(),B=q.useRef(null),ae=q.useRef(null),z=q.useRef(I),W=q.useRef(M),J=q.useRef(s),se=E||k||p||m||y||x,ue=PE(),he=xo(i,O.getState,m),ge=xo(i,O.getState,y),Me=xo(i,O.getState,x),Fe=xo(i,O.getState,N),Re=xo(i,O.getState,_),Pe=ve=>{const{nodeDragThreshold:ye}=O.getState();if(E&&(!P||!k||ye>0)&&Eg({id:i,store:O,nodeRef:B}),p){const qe=O.getState().nodeInternals.get(i);qe&&p(ve,{...qe})}},be=ve=>{if(!xg(ve)&&!ne)if(sE.includes(ve.key)&&E){const ye=ve.key==="Escape";Eg({id:i,store:O,unselect:ye,nodeRef:B})}else k&&h&&Object.prototype.hasOwnProperty.call(Es,ve.key)&&(O.setState({ariaLiveMessage:`Moved selected node ${ve.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~u}, y: ${~~l}`}),ue({x:Es[ve.key].x,y:Es[ve.key].y,isShiftPressed:ve.shiftKey}))};q.useEffect(()=>()=>{ae.current&&(L==null||L.unobserve(ae.current),ae.current=null)},[]),q.useEffect(()=>{if(B.current&&!R){const ve=B.current;(!U||!V||ae.current!==ve)&&(ae.current&&(L==null||L.unobserve(ae.current)),L==null||L.observe(ve),ae.current=ve)}},[R,U,V]),q.useEffect(()=>{const ve=J.current!==s,ye=z.current!==I,qe=W.current!==M;B.current&&(ve||ye||qe)&&(ve&&(J.current=s),ye&&(z.current=I),qe&&(W.current=M),O.getState().updateNodeDimensions([{id:i,nodeElement:B.current,forceUpdate:!0}]))},[i,s,I,M]);const Oe=ME({nodeRef:B,disabled:R||!k,noDragClassName:j,handleSelector:F,nodeId:i,isSelectable:E,selectNodesOnDrag:P});return R?null:oe.createElement("div",{className:qt(["react-flow__node",`react-flow__node-${s}`,{[G]:k},b,{selected:h,selectable:E,parent:X,dragging:Oe}]),ref:B,style:{zIndex:Q,transform:`translate(${c}px,${d}px)`,pointerEvents:se?"all":"none",visibility:U?"visible":"hidden",...S},"data-id":i,"data-testid":`rf__node-${i}`,onMouseEnter:he,onMouseMove:ge,onMouseLeave:Me,onContextMenu:Fe,onClick:Pe,onDoubleClick:Re,onKeyDown:A?be:void 0,tabIndex:A?0:void 0,role:A?"button":void 0,"aria-describedby":ne?void 0:`${EE}-${D}`,"aria-label":K},oe.createElement(QA,{value:i},oe.createElement(e,{id:i,data:o,type:s,xPos:u,yPos:l,selected:h,isConnectable:C,sourcePosition:I,targetPosition:M,dragging:Oe,dragHandle:F,zIndex:Q})))};return n.displayName="NodeWrapper",q.memo(n)};const DI=e=>{const n=e.getNodes().filter(i=>i.selected);return{...Iu(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function FI({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:i}){const s=bt(),{width:o,height:u,x:l,y:c,transformString:d,userSelectionActive:h}=Xe(DI,St),p=PE(),m=q.useRef(null);if(q.useEffect(()=>{var N;i||(N=m.current)==null||N.focus({preventScroll:!0})},[i]),ME({nodeRef:m}),h||!o||!u)return null;const y=e?N=>{const _=s.getState().getNodes().filter(S=>S.selected);e(N,_)}:void 0,x=N=>{Object.prototype.hasOwnProperty.call(Es,N.key)&&p({x:Es[N.key].x,y:Es[N.key].y,isShiftPressed:N.shiftKey})};return oe.createElement("div",{className:qt(["react-flow__nodesselection","react-flow__container",n]),style:{transform:d}},oe.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:i?void 0:-1,onKeyDown:i?void 0:x,style:{width:o,height:u,top:c,left:l}}))}var zI=q.memo(FI);const BI=e=>e.nodesSelectionActive,OE=({children:e,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:u,onPaneScroll:l,deleteKeyCode:c,onMove:d,onMoveStart:h,onMoveEnd:p,selectionKeyCode:m,selectionOnDrag:y,selectionMode:x,onSelectionStart:N,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:A,panOnScroll:P,panOnScrollSpeed:I,panOnScrollMode:M,zoomOnDoubleClick:R,panOnDrag:L,defaultViewport:F,translateExtent:Q,minZoom:X,maxZoom:j,preventScrolling:G,onSelectionContextMenu:U,noWheelClassName:ne,noPanClassName:K,disableKeyboardA11y:D})=>{const V=Xe(BI),O=qo(m),B=qo(b),ae=B||L,z=B||P,W=O||y&&ae!==!0;return NI({deleteKeyCode:c,multiSelectionKeyCode:S}),oe.createElement(jI,{onMove:d,onMoveStart:h,onMoveEnd:p,onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:A,panOnScroll:z,panOnScrollSpeed:I,panOnScrollMode:M,zoomOnDoubleClick:R,panOnDrag:!O&&ae,defaultViewport:F,translateExtent:Q,minZoom:X,maxZoom:j,zoomActivationKeyCode:k,preventScrolling:G,noWheelClassName:ne,noPanClassName:K},oe.createElement(jE,{onSelectionStart:N,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:u,onPaneScroll:l,panOnDrag:ae,isSelecting:!!W,selectionMode:x},e,V&&oe.createElement(zI,{onSelectionContextMenu:U,noPanClassName:K,disableKeyboardA11y:D})))};OE.displayName="FlowRenderer";var UI=q.memo(OE);function HI(e){return Xe(q.useCallback(i=>e?dE(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[e]))}function VI(e){const n={input:_o(e.input||_E),default:_o(e.default||kg),output:_o(e.output||bE),group:_o(e.group||Yg)},i={},s=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,u)=>(o[u]=_o(e[u]||kg),o),i);return{...n,...s}}const WI=({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]},GI=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),qE=e=>{const{nodesDraggable:n,nodesConnectable:i,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:u,onError:l}=Xe(GI,St),c=HI(e.onlyRenderVisibleElements),d=q.useRef(),h=q.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const p=new ResizeObserver(m=>{const y=m.map(x=>({id:x.target.getAttribute("data-id"),nodeElement:x.target,forceUpdate:!0}));u(y)});return d.current=p,p},[]);return q.useEffect(()=>()=>{var p;(p=d==null?void 0:d.current)==null||p.disconnect()},[]),oe.createElement("div",{className:"react-flow__nodes",style:Kg},c.map(p=>{var A,P,I;let m=p.type||"default";e.nodeTypes[m]||(l==null||l("003",yr.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,x=!!(p.draggable||n&&typeof p.draggable>"u"),N=!!(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?Bg(p.positionAbsolute,e.nodeExtent):p.positionAbsolute,k=(b==null?void 0:b.x)??0,E=(b==null?void 0:b.y)??0,C=WI({x:k,y:E,width:p.width??0,height:p.height??0,origin:e.nodeOrigin});return oe.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:k,yPos:E,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:x,isSelectable:N,isConnectable:_,isFocusable:S,resizeObserver:h,dragHandle:p.dragHandle,zIndex:((A=p[ht])==null?void 0:A.z)??0,isParent:!!((P=p[ht])!=null&&P.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!p.width&&!!p.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:p.ariaLabel,hasHandleBounds:!!((I=p[ht])!=null&&I.handleBounds)})}))};qE.displayName="NodeRenderer";var YI=q.memo(qE);const KI=(e,n,i)=>i===Ce.Left?e-n:i===Ce.Right?e+n:e,XI=(e,n,i)=>i===Ce.Top?e-n:i===Ce.Bottom?e+n:e,Iw="react-flow__edgeupdater",Mw=({position:e,centerX:n,centerY:i,radius:s=10,onMouseDown:o,onMouseEnter:u,onMouseOut:l,type:c})=>oe.createElement("circle",{onMouseDown:o,onMouseEnter:u,onMouseOut:l,className:qt([Iw,`${Iw}-${c}`]),cx:KI(n,s,e),cy:XI(i,s,e),r:s,stroke:"transparent",fill:"transparent"}),QI=()=>!0;var ws=e=>{const n=({id:i,className:s,type:o,data:u,onClick:l,onEdgeDoubleClick:c,selected:d,animated:h,label:p,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,style:S,source:b,target:k,sourceX:E,sourceY:C,targetX:A,targetY:P,sourcePosition:I,targetPosition:M,elementsSelectable:R,hidden:L,sourceHandleId:F,targetHandleId:Q,onContextMenu:X,onMouseEnter:j,onMouseMove:G,onMouseLeave:U,reconnectRadius:ne,onReconnect:K,onReconnectStart:D,onReconnectEnd:V,markerEnd:O,markerStart:B,rfId:ae,ariaLabel:z,isFocusable:W,isReconnectable:J,pathOptions:se,interactionWidth:ue,disableKeyboardA11y:he})=>{const ge=q.useRef(null),[Me,Fe]=q.useState(!1),[Re,Pe]=q.useState(!1),be=bt(),Oe=q.useMemo(()=>`url('#${Sg(B,ae)}')`,[B,ae]),ve=q.useMemo(()=>`url('#${Sg(O,ae)}')`,[O,ae]);if(L)return null;const ye=We=>{var wt;const{edges:Et,addSelectedEdges:Ge,unselectNodesAndEdges:ft,multiSelectionActive:on}=be.getState(),Lt=Et.find(an=>an.id===i);Lt&&(R&&(be.setState({nodesSelectionActive:!1}),Lt.selected&&on?(ft({nodes:[],edges:[Lt]}),(wt=ge.current)==null||wt.blur()):Ge([i])),l&&l(We,Lt))},qe=wo(i,be.getState,c),Ye=wo(i,be.getState,X),Qe=wo(i,be.getState,j),et=wo(i,be.getState,G),Be=wo(i,be.getState,U),Ze=(We,Et)=>{if(We.button!==0)return;const{edges:Ge,isValidConnection:ft}=be.getState(),on=Et?k:b,Lt=(Et?Q:F)||null,wt=Et?"target":"source",an=ft||QI,Bt=Et,vn=Ge.find(wn=>wn.id===i);Pe(!0),D==null||D(We,vn,wt);const un=wn=>{Pe(!1),V==null||V(wn,vn,wt)};vE({event:We,handleId:Lt,nodeId:on,onConnect:wn=>K==null?void 0:K(vn,wn),isTarget:Bt,getState:be.getState,setState:be.setState,isValidConnection:an,edgeUpdaterType:wt,onReconnectEnd:un})},At=We=>Ze(We,!0),Vt=We=>Ze(We,!1),It=()=>Fe(!0),pt=()=>Fe(!1),tt=!R&&!l,kt=We=>{var Et;if(!he&&sE.includes(We.key)&&R){const{unselectNodesAndEdges:Ge,addSelectedEdges:ft,edges:on}=be.getState();We.key==="Escape"?((Et=ge.current)==null||Et.blur(),Ge({edges:[on.find(wt=>wt.id===i)]})):ft([i])}};return oe.createElement("g",{className:qt(["react-flow__edge",`react-flow__edge-${o}`,s,{selected:d,animated:h,inactive:tt,updating:Me}]),onClick:ye,onDoubleClick:qe,onContextMenu:Ye,onMouseEnter:Qe,onMouseMove:et,onMouseLeave:Be,onKeyDown:W?kt:void 0,tabIndex:W?0:void 0,role:W?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":z===null?void 0:z||`Edge from ${b} to ${k}`,"aria-describedby":W?`${NE}-${ae}`:void 0,ref:ge},!Re&&oe.createElement(e,{id:i,source:b,target:k,selected:d,animated:h,label:p,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,data:u,style:S,sourceX:E,sourceY:C,targetX:A,targetY:P,sourcePosition:I,targetPosition:M,sourceHandleId:F,targetHandleId:Q,markerStart:Oe,markerEnd:ve,pathOptions:se,interactionWidth:ue}),J&&oe.createElement(oe.Fragment,null,(J==="source"||J===!0)&&oe.createElement(Mw,{position:I,centerX:E,centerY:C,radius:ne,onMouseDown:At,onMouseEnter:It,onMouseOut:pt,type:"source"}),(J==="target"||J===!0)&&oe.createElement(Mw,{position:M,centerX:A,centerY:P,radius:ne,onMouseDown:Vt,onMouseEnter:It,onMouseOut:pt,type:"target"})))};return n.displayName="EdgeWrapper",q.memo(n)};function ZI(e){const n={default:ws(e.default||Su),straight:ws(e.bezier||Vg),step:ws(e.step||Hg),smoothstep:ws(e.step||Au),simplebezier:ws(e.simplebezier||Ug)},i={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,u)=>(o[u]=ws(e[u]||Su),o),i);return{...n,...s}}function Pw(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,u=(i==null?void 0:i.width)||n.width,l=(i==null?void 0:i.height)||n.height;switch(e){case Ce.Top:return{x:s+u/2,y:o};case Ce.Right:return{x:s+u,y:o+l/2};case Ce.Bottom:return{x:s+u/2,y:o+l};case Ce.Left:return{x:s,y:o+l/2}}}function Ow(e,n){return e?e.length===1||!n?e[0]:n&&e.find(i=>i.id===n)||null:null}const JI=(e,n,i,s,o,u)=>{const l=Pw(i,e,n),c=Pw(u,s,o);return{sourceX:l.x,sourceY:l.y,targetX:c.x,targetY:c.y}};function eM({sourcePos:e,targetPos:n,sourceWidth:i,sourceHeight:s,targetWidth:o,targetHeight:u,width:l,height:c,transform:d}){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+u)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const p=Po({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:l/d[2],height:c/d[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 qw(e){var s,o,u,l,c;const n=((s=e==null?void 0:e[ht])==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((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.y)<"u";return[{x:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.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 tM=[{level:0,isMaxLevel:!0,edges:[]}];function nM(e,n,i=!1){let s=-1;const o=e.reduce((l,c)=>{var p,m;const d=jn(c.zIndex);let h=d?c.zIndex:0;if(i){const y=n.get(c.target),x=n.get(c.source),N=c.selected||(y==null?void 0:y.selected)||(x==null?void 0:x.selected),_=Math.max(((p=x==null?void 0:x[ht])==null?void 0:p.z)||0,((m=y==null?void 0:y[ht])==null?void 0:m.z)||0,1e3);h=(d?c.zIndex:0)+(N?_:0)}return l[h]?l[h].push(c):l[h]=[c],s=h>s?h:s,l},{}),u=Object.entries(o).map(([l,c])=>{const d=+l;return{edges:c,level:d,isMaxLevel:d===s}});return u.length===0?tM:u}function rM(e,n,i){const s=Xe(q.useCallback(o=>e?o.edges.filter(u=>{const l=n.get(u.source),c=n.get(u.target);return(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&eM({sourcePos:l.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:l.width,sourceHeight:l.height,targetWidth:c.width,targetHeight:c.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[e,n]));return nM(s,n,i)}const iM=({color:e="none",strokeWidth:n=1})=>oe.createElement("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),sM=({color:e="none",strokeWidth:n=1})=>oe.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Lw={[_u.Arrow]:iM,[_u.ArrowClosed]:sM};function oM(e){const n=bt();return q.useMemo(()=>{var o,u;return Object.prototype.hasOwnProperty.call(Lw,e)?Lw[e]:((u=(o=n.getState()).onError)==null||u.call(o,"009",yr.error009(e)),null)},[e])}const aM=({id:e,type:n,color:i,width:s=12.5,height:o=12.5,markerUnits:u="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const d=oM(n);return d?oe.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:c,refX:"0",refY:"0"},oe.createElement(d,{color:i,strokeWidth:l})):null},uM=({defaultColor:e,rfId:n})=>i=>{const s=[];return i.edges.reduce((o,u)=>([u.markerStart,u.markerEnd].forEach(l=>{if(l&&typeof l=="object"){const c=Sg(l,n);s.includes(c)||(o.push({id:c,color:l.color||e,...l}),s.push(c))}}),o),[]).sort((o,u)=>o.id.localeCompare(u.id))},LE=({defaultColor:e,rfId:n})=>{const i=Xe(q.useCallback(uM({defaultColor:e,rfId:n}),[e,n]),(s,o)=>!(s.length!==o.length||s.some((u,l)=>u.id!==o[l].id)));return oe.createElement("defs",null,i.map(s=>oe.createElement(aM,{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})))};LE.displayName="MarkerDefinitions";var lM=q.memo(LE);const cM=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}),$E=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:i,rfId:s,edgeTypes:o,noPanClassName:u,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:k,edgesUpdatable:E,elementsSelectable:C,width:A,height:P,connectionMode:I,nodeInternals:M,onError:R}=Xe(cM,St),L=rM(n,M,i);return A?oe.createElement(oe.Fragment,null,L.map(({level:F,edges:Q,isMaxLevel:X})=>oe.createElement("svg",{key:F,style:{zIndex:F},width:A,height:P,className:"react-flow__edges react-flow__container"},X&&oe.createElement(lM,{defaultColor:e,rfId:s}),oe.createElement("g",null,Q.map(j=>{const[G,U,ne]=qw(M.get(j.source)),[K,D,V]=qw(M.get(j.target));if(!ne||!V)return null;let O=j.type||"default";o[O]||(R==null||R("011",yr.error011(O)),O="default");const B=o[O]||o.default,ae=I===Mi.Strict?D.target:(D.target??[]).concat(D.source??[]),z=Ow(U.source,j.sourceHandle),W=Ow(ae,j.targetHandle),J=(z==null?void 0:z.position)||Ce.Bottom,se=(W==null?void 0:W.position)||Ce.Top,ue=!!(j.focusable||k&&typeof j.focusable>"u"),he=j.reconnectable||j.updatable,ge=typeof y<"u"&&(he||E&&typeof he>"u");if(!z||!W)return R==null||R("008",yr.error008(z,j)),null;const{sourceX:Me,sourceY:Fe,targetX:Re,targetY:Pe}=JI(G,z,J,K,W,se);return oe.createElement(B,{key:j.id,id:j.id,className:qt([j.className,u]),type:O,data:j.data,selected:!!j.selected,animated:!!j.animated,hidden:!!j.hidden,label:j.label,labelStyle:j.labelStyle,labelShowBg:j.labelShowBg,labelBgStyle:j.labelBgStyle,labelBgPadding:j.labelBgPadding,labelBgBorderRadius:j.labelBgBorderRadius,style:j.style,source:j.source,target:j.target,sourceHandleId:j.sourceHandle,targetHandleId:j.targetHandle,markerEnd:j.markerEnd,markerStart:j.markerStart,sourceX:Me,sourceY:Fe,targetX:Re,targetY:Pe,sourcePosition:J,targetPosition:se,elementsSelectable:C,onContextMenu:l,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,rfId:s,ariaLabel:j.ariaLabel,isFocusable:ue,isReconnectable:ge,pathOptions:"pathOptions"in j?j.pathOptions:void 0,interactionWidth:j.interactionWidth,disableKeyboardA11y:b})})))),S):null};$E.displayName="EdgeRenderer";var fM=q.memo($E);const dM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function hM({children:e}){const n=Xe(dM);return oe.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function pM(e){const n=zo(),i=q.useRef(!1);q.useEffect(()=>{!i.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),i.current=!0)},[e,n.viewportInitialized])}const mM={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},DE=({nodeId:e,handleType:n,style:i,type:s=Qr.Bezier,CustomComponent:o,connectionStatus:u})=>{var P,I,M;const{fromNode:l,handleId:c,toX:d,toY:h,connectionMode:p}=Xe(q.useCallback(R=>({fromNode:R.nodeInternals.get(e),handleId:R.connectionHandleId,toX:(R.connectionPosition.x-R.transform[0])/R.transform[2],toY:(R.connectionPosition.y-R.transform[1])/R.transform[2],connectionMode:R.connectionMode}),[e]),St),m=(P=l==null?void 0:l[ht])==null?void 0:P.handleBounds;let y=m==null?void 0:m[n];if(p===Mi.Loose&&(y=y||(m==null?void 0:m[n==="source"?"target":"source"])),!l||!y)return null;const x=c?y.find(R=>R.id===c):y[0],N=x?x.x+x.width/2:(l.width??0)/2,_=x?x.y+x.height/2:l.height??0,S=(((I=l.positionAbsolute)==null?void 0:I.x)??0)+N,b=(((M=l.positionAbsolute)==null?void 0:M.y)??0)+_,k=x==null?void 0:x.position,E=k?mM[k]:null;if(!k||!E)return null;if(o)return oe.createElement(o,{connectionLineType:s,connectionLineStyle:i,fromNode:l,fromHandle:x,fromX:S,fromY:b,toX:d,toY:h,fromPosition:k,toPosition:E,connectionStatus:u});let C="";const A={sourceX:S,sourceY:b,sourcePosition:k,targetX:d,targetY:h,targetPosition:E};return s===Qr.Bezier?[C]=cE(A):s===Qr.Step?[C]=_g({...A,borderRadius:0}):s===Qr.SmoothStep?[C]=_g(A):s===Qr.SimpleBezier?[C]=lE(A):C=`M${S},${b} ${d},${h}`,oe.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:i})};DE.displayName="ConnectionLine";const gM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function vM({containerStyle:e,style:n,type:i,component:s}){const{nodeId:o,handleType:u,nodesConnectable:l,width:c,height:d,connectionStatus:h}=Xe(gM,St);return!(o&&u&&c&&l)?null:oe.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},oe.createElement("g",{className:qt(["react-flow__connection",h])},oe.createElement(DE,{nodeId:o,handleType:u,style:n,type:i,CustomComponent:s,connectionStatus:h})))}function $w(e,n){return q.useRef(null),bt(),q.useMemo(()=>n(e),[e])}const FE=({nodeTypes:e,edgeTypes:n,onMove:i,onMoveStart:s,onMoveEnd:o,onInit:u,onNodeClick:l,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:p,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:N,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:k,connectionLineComponent:E,connectionLineContainerStyle:C,selectionKeyCode:A,selectionOnDrag:P,selectionMode:I,multiSelectionKeyCode:M,panActivationKeyCode:R,zoomActivationKeyCode:L,deleteKeyCode:F,onlyRenderVisibleElements:Q,elementsSelectable:X,selectNodesOnDrag:j,defaultViewport:G,translateExtent:U,minZoom:ne,maxZoom:K,preventScrolling:D,defaultMarkerColor:V,zoomOnScroll:O,zoomOnPinch:B,panOnScroll:ae,panOnScrollSpeed:z,panOnScrollMode:W,zoomOnDoubleClick:J,panOnDrag:se,onPaneClick:ue,onPaneMouseEnter:he,onPaneMouseMove:ge,onPaneMouseLeave:Me,onPaneScroll:Fe,onPaneContextMenu:Re,onEdgeContextMenu:Pe,onEdgeMouseEnter:be,onEdgeMouseMove:Oe,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:qe,onReconnectEnd:Ye,reconnectRadius:Qe,noDragClassName:et,noWheelClassName:Be,noPanClassName:Ze,elevateEdgesOnSelect:At,disableKeyboardA11y:Vt,nodeOrigin:It,nodeExtent:pt,rfId:tt})=>{const kt=$w(e,VI),We=$w(n,ZI);return pM(u),oe.createElement(UI,{onPaneClick:ue,onPaneMouseEnter:he,onPaneMouseMove:ge,onPaneMouseLeave:Me,onPaneContextMenu:Re,onPaneScroll:Fe,deleteKeyCode:F,selectionKeyCode:A,selectionOnDrag:P,selectionMode:I,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:M,panActivationKeyCode:R,zoomActivationKeyCode:L,elementsSelectable:X,onMove:i,onMoveStart:s,onMoveEnd:o,zoomOnScroll:O,zoomOnPinch:B,zoomOnDoubleClick:J,panOnScroll:ae,panOnScrollSpeed:z,panOnScrollMode:W,panOnDrag:se,defaultViewport:G,translateExtent:U,minZoom:ne,maxZoom:K,onSelectionContextMenu:N,preventScrolling:D,noDragClassName:et,noWheelClassName:Be,noPanClassName:Ze,disableKeyboardA11y:Vt},oe.createElement(hM,null,oe.createElement(fM,{edgeTypes:We,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:Q,onEdgeContextMenu:Pe,onEdgeMouseEnter:be,onEdgeMouseMove:Oe,onEdgeMouseLeave:ve,onReconnect:ye,onReconnectStart:qe,onReconnectEnd:Ye,reconnectRadius:Qe,defaultMarkerColor:V,noPanClassName:Ze,elevateEdgesOnSelect:!!At,disableKeyboardA11y:Vt,rfId:tt},oe.createElement(vM,{style:k,type:b,component:E,containerStyle:C})),oe.createElement("div",{className:"react-flow__edgelabel-renderer"}),oe.createElement(YI,{nodeTypes:kt,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:p,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,selectNodesOnDrag:j,onlyRenderVisibleElements:Q,noPanClassName:Ze,noDragClassName:et,disableKeyboardA11y:Vt,nodeOrigin:It,nodeExtent:pt,rfId:tt})))};FE.displayName="GraphView";var yM=q.memo(FE);const Ng=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Yr={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:Ng,nodeExtent:Ng,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Mi.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:VA,isValidConnection:void 0},wM=()=>oR((e,n)=>({...Yr,setNodes:i=>{const{nodeInternals:s,nodeOrigin:o,elevateNodesOnSelect:u}=n();e({nodeInternals:Fc(i,s,o,u)})},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",u=typeof s<"u",l=o?Fc(i,new Map,n().nodeOrigin,n().elevateNodesOnSelect):new Map;e({nodeInternals:l,edges:u?s:[],hasDefaultNodes:o,hasDefaultEdges:u})},updateNodeDimensions:i=>{const{onNodesChange:s,nodeInternals:o,fitViewOnInit:u,fitViewOnInitDone:l,fitViewOnInitOptions:c,domNode:d,nodeOrigin:h}=n(),p=d==null?void 0:d.querySelector(".react-flow__viewport");if(!p)return;const m=window.getComputedStyle(p),{m22:y}=new window.DOMMatrixReadOnly(m.transform),x=i.reduce((_,S)=>{const b=o.get(S.id);if(b!=null&&b.hidden)o.set(b.id,{...b,[ht]:{...b[ht],handleBounds:void 0}});else if(b){const k=zg(S.nodeElement);!!(k.width&&k.height&&(b.width!==k.width||b.height!==k.height||S.forceUpdate))&&(o.set(b.id,{...b,[ht]:{...b[ht],handleBounds:{source:Aw(".source",S.nodeElement,y,h),target:Aw(".target",S.nodeElement,y,h)}},...k}),_.push({id:b.id,type:"dimensions",dimensions:k}))}return _},[]);TE(o,h);const N=l||u&&!l&&RE(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:N}),(x==null?void 0:x.length)>0&&(s==null||s(x))},updateNodePositions:(i,s=!0,o=!1)=>{const{triggerNodeChanges:u}=n(),l=i.map(c=>{const d={id:c.id,type:"position",dragging:o};return s&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});u(l)},triggerNodeChanges:i=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:u,nodeOrigin:l,getNodes:c,elevateNodesOnSelect:d}=n();if(i!=null&&i.length){if(u){const h=PI(i,c()),p=Fc(h,o,l,d);e({nodeInternals:p})}s==null||s(i)}},addSelectedNodes:i=>{const{multiSelectionActive:s,edges:o,getNodes:u}=n();let l,c=null;s?l=i.map(d=>Xr(d,!0)):(l=_s(u(),i),c=_s(o,[])),ru({changedNodes:l,changedEdges:c,get:n,set:e})},addSelectedEdges:i=>{const{multiSelectionActive:s,edges:o,getNodes:u}=n();let l,c=null;s?l=i.map(d=>Xr(d,!0)):(l=_s(o,i),c=_s(u(),[])),ru({changedNodes:c,changedEdges:l,get:n,set:e})},unselectNodesAndEdges:({nodes:i,edges:s}={})=>{const{edges:o,getNodes:u}=n(),l=i||u(),c=s||o,d=l.map(p=>(p.selected=!1,Xr(p.id,!1))),h=c.map(p=>Xr(p.id,!1));ru({changedNodes:d,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(),u=s().filter(c=>c.selected).map(c=>Xr(c.id,!1)),l=i.filter(c=>c.selected).map(c=>Xr(c.id,!1));ru({changedNodes:u,changedEdges:l,get:n,set:e})},setNodeExtent:i=>{const{nodeInternals:s}=n();s.forEach(o=>{o.positionAbsolute=Bg(o.position,i)}),e({nodeExtent:i,nodeInternals:new Map(s)})},panBy:i=>{const{transform:s,width:o,height:u,d3Zoom:l,d3Selection:c,translateExtent:d}=n();if(!l||!c||!i.x&&!i.y)return!1;const h=gr.translate(s[0]+i.x,s[1]+i.y).scale(s[2]),p=[[0,0],[o,u]],m=l==null?void 0:l.constrain()(h,p,d);return l.transform(c,m),s[0]!==m.x||s[1]!==m.y||s[2]!==m.k},cancelConnection:()=>e({connectionNodeId:Yr.connectionNodeId,connectionHandleId:Yr.connectionHandleId,connectionHandleType:Yr.connectionHandleType,connectionStatus:Yr.connectionStatus,connectionStartHandle:Yr.connectionStartHandle,connectionEndHandle:Yr.connectionEndHandle}),reset:()=>e({...Yr})}),Object.is),Xg=({children:e})=>{const n=q.useRef(null);return n.current||(n.current=wM()),oe.createElement($A,{value:n.current},e)};Xg.displayName="ReactFlowProvider";const zE=({children:e})=>q.useContext(ju)?oe.createElement(oe.Fragment,null,e):oe.createElement(Xg,null,e);zE.displayName="ReactFlowWrapper";const xM={input:_E,default:kg,output:bE,group:Yg},_M={default:Su,straight:Vg,step:Hg,smoothstep:Au,simplebezier:Ug},SM=[0,0],bM=[15,15],kM={x:0,y:0,zoom:1},EM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},BE=q.forwardRef(({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,className:o,nodeTypes:u=xM,edgeTypes:l=_M,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:A,onNodeDoubleClick:P,onNodeDragStart:I,onNodeDrag:M,onNodeDragStop:R,onNodesDelete:L,onEdgesDelete:F,onSelectionChange:Q,onSelectionDragStart:X,onSelectionDrag:j,onSelectionDragStop:G,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:K,connectionMode:D=Mi.Strict,connectionLineType:V=Qr.Bezier,connectionLineStyle:O,connectionLineComponent:B,connectionLineContainerStyle:ae,deleteKeyCode:z="Backspace",selectionKeyCode:W="Shift",selectionOnDrag:J=!1,selectionMode:se=Oo.Full,panActivationKeyCode:ue="Space",multiSelectionKeyCode:he=xu()?"Meta":"Control",zoomActivationKeyCode:ge=xu()?"Meta":"Control",snapToGrid:Me=!1,snapGrid:Fe=bM,onlyRenderVisibleElements:Re=!1,selectNodesOnDrag:Pe=!0,nodesDraggable:be,nodesConnectable:Oe,nodesFocusable:ve,nodeOrigin:ye=SM,edgesFocusable:qe,edgesUpdatable:Ye,elementsSelectable:Qe,defaultViewport:et=kM,minZoom:Be=.5,maxZoom:Ze=2,translateExtent:At=Ng,preventScrolling:Vt=!0,nodeExtent:It,defaultMarkerColor:pt="#b1b1b7",zoomOnScroll:tt=!0,zoomOnPinch:kt=!0,panOnScroll:We=!1,panOnScrollSpeed:Et=.5,panOnScrollMode:Ge=Ti.Free,zoomOnDoubleClick:ft=!0,panOnDrag:on=!0,onPaneClick:Lt,onPaneMouseEnter:wt,onPaneMouseMove:an,onPaneMouseLeave:Bt,onPaneScroll:vn,onPaneContextMenu:un,children:yn,onEdgeContextMenu:wn,onEdgeDoubleClick:_r,onEdgeMouseEnter:Mn,onEdgeMouseMove:ti,onEdgeMouseLeave:$i,onEdgeUpdate:Sr,onEdgeUpdateStart:ni,onEdgeUpdateEnd:ir,onReconnect:Nt,onReconnectStart:Pn,onReconnectEnd:Yn,reconnectRadius:ln=10,edgeUpdaterRadius:Kn=10,onNodesChange:Xn,onEdgesChange:br,noDragClassName:kr="nodrag",noWheelClassName:Di="nowheel",noPanClassName:Fi="nopan",fitView:xn=!1,fitViewOptions:zi,connectOnClick:Bi=!0,attributionPosition:ri,proOptions:cn,defaultEdgeOptions:Er,elevateNodesOnSelect:ii=!0,elevateEdgesOnSelect:Ui=!1,disableKeyboardA11y:Hi=!1,autoPanOnConnect:Vi=!0,autoPanOnNodeDrag:nt=!0,connectionRadius:Wt=20,isValidConnection:si,onError:oi,style:Nr,id:Wi,nodeDragThreshold:ai,..._n},Gt)=>{const gt=Wi||"1";return oe.createElement("div",{..._n,style:{...Nr,...EM},ref:Gt,className:qt(["react-flow",o]),"data-testid":"rf__wrapper",id:Wi},oe.createElement(zE,null,oe.createElement(yM,{onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:A,onNodeDoubleClick:P,nodeTypes:u,edgeTypes:l,connectionLineType:V,connectionLineStyle:O,connectionLineComponent:B,connectionLineContainerStyle:ae,selectionKeyCode:W,selectionOnDrag:J,selectionMode:se,deleteKeyCode:z,multiSelectionKeyCode:he,panActivationKeyCode:ue,zoomActivationKeyCode:ge,onlyRenderVisibleElements:Re,selectNodesOnDrag:Pe,defaultViewport:et,translateExtent:At,minZoom:Be,maxZoom:Ze,preventScrolling:Vt,zoomOnScroll:tt,zoomOnPinch:kt,zoomOnDoubleClick:ft,panOnScroll:We,panOnScrollSpeed:Et,panOnScrollMode:Ge,panOnDrag:on,onPaneClick:Lt,onPaneMouseEnter:wt,onPaneMouseMove:an,onPaneMouseLeave:Bt,onPaneScroll:vn,onPaneContextMenu:un,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:K,onEdgeContextMenu:wn,onEdgeDoubleClick:_r,onEdgeMouseEnter:Mn,onEdgeMouseMove:ti,onEdgeMouseLeave:$i,onReconnect:Nt??Sr,onReconnectStart:Pn??ni,onReconnectEnd:Yn??ir,reconnectRadius:ln??Kn,defaultMarkerColor:pt,noDragClassName:kr,noWheelClassName:Di,noPanClassName:Fi,elevateEdgesOnSelect:Ui,rfId:gt,disableKeyboardA11y:Hi,nodeOrigin:ye,nodeExtent:It}),oe.createElement(pI,{nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,nodesDraggable:be,nodesConnectable:Oe,nodesFocusable:ve,edgesFocusable:qe,edgesUpdatable:Ye,elementsSelectable:Qe,elevateNodesOnSelect:ii,minZoom:Be,maxZoom:Ze,nodeExtent:It,onNodesChange:Xn,onEdgesChange:br,snapToGrid:Me,snapGrid:Fe,connectionMode:D,translateExtent:At,connectOnClick:Bi,defaultEdgeOptions:Er,fitView:xn,fitViewOptions:zi,onNodesDelete:L,onEdgesDelete:F,onNodeDragStart:I,onNodeDrag:M,onNodeDragStop:R,onSelectionDrag:j,onSelectionDragStart:X,onSelectionDragStop:G,noPanClassName:Fi,nodeOrigin:ye,rfId:gt,autoPanOnConnect:Vi,autoPanOnNodeDrag:nt,onError:oi,connectionRadius:Wt,isValidConnection:si,nodeDragThreshold:ai}),oe.createElement(dI,{onSelectionChange:Q}),yn,oe.createElement(FA,{proOptions:cn,position:ri}),oe.createElement(wI,{rfId:gt,disableKeyboardA11y:Hi})))});BE.displayName="ReactFlow";const NM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function UE(){return Xe(NM,St)}const HE=({id:e,x:n,y:i,width:s,height:o,style:u,color:l,strokeColor:c,strokeWidth:d,className:h,borderRadius:p,shapeRendering:m,onClick:y,selected:x})=>{const{background:N,backgroundColor:_}=u||{},S=l||N||_;return oe.createElement("rect",{className:qt(["react-flow__minimap-node",{selected:x},h]),x:n,y:i,rx:p,ry:p,width:s,height:o,fill:S,stroke:c,strokeWidth:d,shapeRendering:m,onClick:y?b=>y(b,e):void 0})};HE.displayName="MiniMapNode";var CM=q.memo(HE);const TM=e=>e.nodeOrigin,RM=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),Hc=e=>e instanceof Function?e:()=>e;function jM({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:u=CM,onClick:l}){const c=Xe(RM,St),d=Xe(TM),h=Hc(n),p=Hc(e),m=Hc(i),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return oe.createElement(oe.Fragment,null,c.map(x=>{const{x:N,y:_}=ji(x,d).positionAbsolute;return oe.createElement(u,{key:x.id,x:N,y:_,width:x.width,height:x.height,style:x.style,selected:x.selected,className:m(x),color:h(x),borderRadius:s,strokeColor:p(x),strokeWidth:o,shapeRendering:y,onClick:l,id:x.id})}))}var AM=q.memo(jM);const IM=200,MM=150,PM=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?UA(Iu(n,e.nodeOrigin),i):i,rfId:e.rfId}},OM="react-flow__minimap-desc";function VE({style:e,className:n,nodeStrokeColor:i="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:u=5,nodeStrokeWidth:l=2,nodeComponent:c,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:p=1,position:m="bottom-right",onClick:y,onNodeClick:x,pannable:N=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:k=10,offsetScale:E=5}){const C=bt(),A=q.useRef(null),{boundingRect:P,viewBB:I,rfId:M}=Xe(PM,St),R=(e==null?void 0:e.width)??IM,L=(e==null?void 0:e.height)??MM,F=P.width/R,Q=P.height/L,X=Math.max(F,Q),j=X*R,G=X*L,U=E*X,ne=P.x-(j-P.width)/2-U,K=P.y-(G-P.height)/2-U,D=j+U*2,V=G+U*2,O=`${OM}-${M}`,B=q.useRef(0);B.current=X,q.useEffect(()=>{if(A.current){const W=Rn(A.current),J=he=>{const{transform:ge,d3Selection:Me,d3Zoom:Fe}=C.getState();if(he.sourceEvent.type!=="wheel"||!Me||!Fe)return;const Re=-he.sourceEvent.deltaY*(he.sourceEvent.deltaMode===1?.05:he.sourceEvent.deltaMode?1:.002)*k,Pe=ge[2]*Math.pow(2,Re);Fe.scaleTo(Me,Pe)},se=he=>{const{transform:ge,d3Selection:Me,d3Zoom:Fe,translateExtent:Re,width:Pe,height:be}=C.getState();if(he.sourceEvent.type!=="mousemove"||!Me||!Fe)return;const Oe=B.current*Math.max(1,ge[2])*(b?-1:1),ve={x:ge[0]-he.sourceEvent.movementX*Oe,y:ge[1]-he.sourceEvent.movementY*Oe},ye=[[0,0],[Pe,be]],qe=gr.translate(ve.x,ve.y).scale(ge[2]),Ye=Fe.constrain()(qe,ye,Re);Fe.transform(Me,Ye)},ue=Jk().on("zoom",N?se:null).on("zoom.wheel",_?J:null);return W.call(ue),()=>{W.on("zoom",null)}}},[N,_,b,k]);const ae=y?W=>{const J=Bn(W);y(W,{x:J[0],y:J[1]})}:void 0,z=x?(W,J)=>{const se=C.getState().nodeInternals.get(J);x(W,se)}:void 0;return oe.createElement(Fg,{position:m,style:e,className:qt(["react-flow__minimap",n]),"data-testid":"rf__minimap"},oe.createElement("svg",{width:R,height:L,viewBox:`${ne} ${K} ${D} ${V}`,role:"img","aria-labelledby":O,ref:A,onClick:ae},S&&oe.createElement("title",{id:O},S),oe.createElement(AM,{onClick:z,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:u,nodeClassName:o,nodeStrokeWidth:l,nodeComponent:c}),oe.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-U},${K-U}h${D+U*2}v${V+U*2}h${-D-U*2}z
57
57
  M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fill:d,fillRule:"evenodd",stroke:h,strokeWidth:p,pointerEvents:"none"})))}VE.displayName="MiniMap";var qM=q.memo(VE);function LM(){return oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},oe.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function $M(){return oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},oe.createElement("path",{d:"M0 0h32v4.2H0z"}))}function DM(){return oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},oe.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 FM(){return oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},oe.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 zM(){return oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},oe.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 Ss=({children:e,className:n,...i})=>oe.createElement("button",{type:"button",className:qt(["react-flow__controls-button",n]),...i},e);Ss.displayName="ControlButton";const BM=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),WE=({style:e,showZoom:n=!0,showFitView:i=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:u,onZoomOut:l,onFitView:c,onInteractiveChange:d,className:h,children:p,position:m="bottom-left"})=>{const y=bt(),[x,N]=q.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Xe(BM,St),{zoomIn:k,zoomOut:E,fitView:C}=zo();if(q.useEffect(()=>{N(!0)},[]),!x)return null;const A=()=>{k(),u==null||u()},P=()=>{E(),l==null||l()},I=()=>{C(o),c==null||c()},M=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),d==null||d(!_)};return oe.createElement(Fg,{className:qt(["react-flow__controls",h]),position:m,style:e,"data-testid":"rf__controls"},n&&oe.createElement(oe.Fragment,null,oe.createElement(Ss,{onClick:A,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},oe.createElement(LM,null)),oe.createElement(Ss,{onClick:P,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},oe.createElement($M,null))),i&&oe.createElement(Ss,{className:"react-flow__controls-fitview",onClick:I,title:"fit view","aria-label":"fit view"},oe.createElement(DM,null)),s&&oe.createElement(Ss,{className:"react-flow__controls-interactive",onClick:M,title:"toggle interactivity","aria-label":"toggle interactivity"},_?oe.createElement(zM,null):oe.createElement(FM,null)),p)};WE.displayName="Controls";var UM=q.memo(WE),Hn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Hn||(Hn={}));function HM({color:e,dimensions:n,lineWidth:i}){return oe.createElement("path",{stroke:e,strokeWidth:i,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function VM({color:e,radius:n}){return oe.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const WM={[Hn.Dots]:"#91919a",[Hn.Lines]:"#eee",[Hn.Cross]:"#e2e2e2"},GM={[Hn.Dots]:1,[Hn.Lines]:1,[Hn.Cross]:6},YM=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function GE({id:e,variant:n=Hn.Dots,gap:i=20,size:s,lineWidth:o=1,offset:u=2,color:l,style:c,className:d}){const h=q.useRef(null),{transform:p,patternId:m}=Xe(YM,St),y=l||WM[n],x=s||GM[n],N=n===Hn.Dots,_=n===Hn.Cross,S=Array.isArray(i)?i:[i,i],b=[S[0]*p[2]||1,S[1]*p[2]||1],k=x*p[2],E=_?[k,k]:b,C=N?[k/u,k/u]:[E[0]/u,E[1]/u];return oe.createElement("svg",{className:qt(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},oe.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]})`},N?oe.createElement(VM,{color:y,radius:k/u}):oe.createElement(HM,{dimensions:E,color:y,lineWidth:o})),oe.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}GE.displayName="Background";var KM=q.memo(GE);function YE(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function KE(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=KE(s,n+1);if(o)return o}return null}function XM(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens}const QM=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function XE(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.model=="string"&&QM.test(i.model))return i.model;for(const s of Object.values(i)){const o=XE(s,n+1);if(o)return o}return null}function Cg(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,totalEvents:0}}function Jr(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function Qg(e,n){return`${e}::${n}`}function bu(e){return e.agent_type??e.subagent_type??"subagent"}function Tg(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function To(e,n,i,s){const o=n;let u=e.agents.get(o);return u||(u={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:i,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,inFlightTool:null,usage:YE()},e.agents.set(o,u),u)}function QE(e,n,i,s){const o=Qg(n,i),u=e.agents.get(o);if(!u)return null;!u.cwd&&s.cwd&&(u.cwd=s.cwd,u.cwdBasename=Jr(s.cwd));const l=bu(s);return l&&(u.label==="subagent"||!u.label)&&(u.label=l),u}function Dw(e,n,i){const s=n.session_id??"unknown",o=Tg(n);if(o){const d=QE(e,s,o,n);if(d)return d}const u=e.activeSubagentStack.get(s),l=u&&u.length>0?u[u.length-1]:null;if(l){const d=e.agents.get(Qg(s,l));if(d)return!d.cwd&&n.cwd&&(d.cwd=n.cwd,d.cwdBasename=Jr(n.cwd)),d}const c=To(e,s,i,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=i),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=Jr(n.cwd)),c.label==="session"&&n.cwd&&(c.label=Jr(n.cwd)??"session"),c}function ZM(e,n,i,s,o){const u=Qg(n,i),l=To(e,n,o,!0);let c=e.agents.get(u);if(c){!c.cwd&&s.cwd&&(c.cwd=s.cwd,c.cwdBasename=Jr(s.cwd));const d=bu(s);return d&&(c.label==="subagent"||!c.label)&&(c.label=d),c}return c={id:u,sessionId:n,label:bu(s),kind:"subagent",parentId:l.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:Jr(s.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:YE()},e.agents.set(u,c),l.childCount+=1,c}function JM(e,n,i){const s=e.activeSubagentStack.get(n)??[];s.push(i),e.activeSubagentStack.set(n,s)}function eP(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 Vc(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 ko(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 tP(e,n,i,s){if(e.agents.size<=i)return!1;const o=[];for(const[l,c]of e.agents)c.state==="done"&&c.endedAt!=null&&n-c.endedAt>s&&o.push({id:l,endedAt:c.endedAt});if(o.length===0)return!1;o.sort((l,c)=>l.endedAt-c.endedAt);let u=0;for(const l of o){if(e.agents.size<=i)break;e.agents.delete(l.id),u++}return u>0}function nP(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 u=[...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 d=!1;for(const h of u){if(c<=0)break;for(const p of h.ids)e.agents.delete(p);c--,d=!0}return d}function rP(e,n,i){let s=!1;for(const o of e.agents.values()){let u=!1;for(const l of o.tools)l.endedAt==null&&n-l.startedAt>i&&(l.endedAt=l.startedAt+i,l.ok=!1,l.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(l.id),e.toolOwner.delete(l.id),u=!0,s=!0);u&&ko(o)}return s}function Fw(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{...Cg(),lastSeq:n.seq};e.totalEvents+=1,e.lastSeq=n.seq;const u=i.session_id??"unknown";if(o==="ModelObserved"){const d=typeof i.model=="string"?i.model:null;if(d){const p=e.agents.get(u);p&&(p.model=d)}const h=i.subagentModels;if(h&&typeof h=="object")for(const[p,m]of Object.entries(h)){if(typeof m!="string")continue;const y=`${u}::${p}`,x=e.agents.get(y);x&&(x.model=m)}return e}if(o==="ContextObserved"){const d=i.context??null;if(d){const h=e.agents.get(u);h&&(h.context={msgsUser:Number(d.msgsUser??0),msgsAssistant:Number(d.msgsAssistant??0),toolUses:Number(d.toolUses??0),toolResults:Number(d.toolResults??0),systemReminders:Number(d.systemReminders??0),currentContextTokens:Number(d.currentContextTokens??0),claudeMdFiles:Array.isArray(d.claudeMdFiles)?d.claudeMdFiles:[]})}return e}if(o==="UsageObserved"){const d=i.usage??null;if(d){const h=e.agents.get(u);h&&(h.usage.inputTokens=Number(d.input_tokens??0),h.usage.outputTokens=Number(d.output_tokens??0),h.usage.cacheReadTokens=Number(d.cache_read_input_tokens??d.cached_input_tokens??0),h.usage.cacheCreateTokens=Number(d.cache_creation_input_tokens??0),typeof d.reasoning_output_tokens=="number"&&(h.usage.reasoningOutputTokens=Number(d.reasoning_output_tokens)))}return e}const l=Dw(e,i,s);l.provider||(l.provider=i.provider==="codex"?"codex":"claude"),typeof i.model_context_window=="number"&&i.model_context_window>0&&(l.contextWindow=i.model_context_window);const c=XE(i);switch(c&&(l.model=c),o){case"SessionStart":{const d=To(e,u,s,!1);d.synthetic=!1,d.state="active",d.startedAt=d.startedAt||s,!d.cwd&&i.cwd&&(d.cwd=i.cwd,d.cwdBasename=Jr(i.cwd)),d.label==="session"&&i.cwd&&(d.label=Jr(i.cwd)??"session");break}case"UserPromptSubmit":{for(const m of e.agents.values())m.sessionId===u&&m.kind==="subagent"&&m.state==="done"&&m.exitAt==null&&m.endedAt!=null&&m.endedAt<s&&(m.exitAt=s);const d=To(e,u,s,!1);d.state="active",d.endedAt=void 0,d.exitAt=void 0;const h=Dw(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=Vc(p,120)));break}case"PreToolUse":{const d=i.tool_use_id??`${l.id}:${l.toolCount}`,h={id:d,name:i.tool_name??"?",input:i.tool_input,inputPreview:Vc(i.tool_input),agentId:l.id,startedAt:s};l.tools.push(h),l.toolCount+=1,l.state="active",e.toolIndex.set(d,h),e.toolOwner.set(d,l.id),ko(l);break}case"PostToolUse":case"PostToolUseFailure":{const d=i.tool_use_id;if(!d)break;let h=e.toolIndex.get(d),p=!1;if(!h)for(const x of e.agents.values()){const N=x.tools.find(_=>_.id===d);if(N){h=N,p=!0;break}}if(!h)break;h.endedAt=s,h.ok=o==="PostToolUse",h.response=i.tool_response,o==="PostToolUseFailure"?h.errorPreview=Vc(i.tool_response):p&&(h.errorPreview=void 0);const m=KE(i.tool_response);m&&(h.usage=m),e.toolIndex.delete(d);const y=e.toolOwner.get(d)??h.agentId;if(e.toolOwner.delete(d),y){const x=e.agents.get(y);x&&(m&&XM(x.usage,m),ko(x))}break}case"SubagentStart":{const d=Tg(i);if(!d)break;const h=ZM(e,u,d,i,s);h.state="active",h.startedAt=h.startedAt||s,h.exitAt=void 0,h.endedAt=void 0;const p=bu(i);p&&(h.label=p),JM(e,u,d);break}case"SubagentStop":{const d=Tg(i);if(!d)break;const h=QE(e,u,d,i);if(!h)break;h.state="done",h.endedAt=s,ko(h),eP(e,u,d);break}case"Stop":case"SessionEnd":{const d=To(e,u,s,!1);d.state="done",d.endedAt=s,ko(d);break}}return e}function Zg(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 iP=Date.UTC(2026,8,1);function sP(){return Date.now()<iP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}}const oP=[{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:sP()},{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 aP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Jg(e){if(!e)return null;for(const n of oP)if(n.match.test(e))return n.rates;return null}const uP=272e3,lP=/^gpt[-_]5[-_.](?:6(?![-_]cyber)|5|4)/i;function cP(e,n){return!e||n<=uP?{input:1,output:1}:lP.test(e)?{input:2,output:1.5}:{input:1,output:1}}function rn(e,n){const i=Jg(n);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const s=aP(n),o=s?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens,u=s?cP(n,e.inputTokens):{input:1,output:1},l=o*i.input*u.input/1e6,c=e.outputTokens*i.output*u.output/1e6,d=e.cacheReadTokens*i.cacheRead*u.input/1e6,h=e.cacheCreateTokens*i.cacheWrite*u.input/1e6;return{input:l,output:c,cacheRead:d,cacheWrite:h,total:l+c+d+h}}const zw=2e5,fP=1e6,dP=[/\[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],hP=[{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 ZE(e){if(!e)return zw;for(const n of dP)if(n.test(e))return fP;for(const n of hP)if(n.match.test(e))return n.window;return zw}function He(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 ku(e,n){if(e<=0||n<10)return null;const i=e/n,s=i*60;return s>=.01?`${He(s)}/min`:`${He(i*3600)}/hr`}function Tn(e){return e.toLocaleString()}function pP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function mP({agent:e,onClose:n}){var h;const i=e.context,s=e.usage,o=(i==null?void 0:i.currentContextTokens)??0,u=ZE(e.model),l=Math.min(100,o/u*100),c=rn(s,e.model),d=s.inputTokens+s.cacheReadTokens+s.cacheCreateTokens;return v.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:v.jsxs("div",{className:"ctx-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[v.jsxs("header",{className:"ctx-modal-head",children:[v.jsxs("div",{children:[v.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),v.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),v.jsx("button",{className:"ctx-modal-close",onClick:n,"aria-label":"Close",children:"×"})]}),v.jsxs("section",{className:"ctx-window-row",children:[v.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(l),children:v.jsx("div",{className:"ctx-window-fill",style:{width:`${l}%`}})}),v.jsxs("div",{className:"ctx-window-meta",children:[v.jsxs("span",{className:"ctx-window-pct",children:[l.toFixed(1),"%"]}),v.jsxs("span",{className:"ctx-window-num",children:[Tn(o)," / ",Tn(u)," tok (current turn)"]})]})]}),v.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),v.jsxs("div",{className:"ctx-grid",children:[v.jsx(zn,{label:"input tokens",val:Tn(s.inputTokens)}),v.jsx(zn,{label:"output tokens",val:Tn(s.outputTokens)}),v.jsx(zn,{label:"cache reads",val:Tn(s.cacheReadTokens)}),v.jsx(zn,{label:"cache writes",val:Tn(s.cacheCreateTokens)}),v.jsx(zn,{label:"cumulative total",val:Tn(d)}),v.jsx(zn,{label:"estimated cost",val:He(c.total),accent:!0})]}),v.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),v.jsxs("div",{className:"ctx-grid",children:[v.jsx(zn,{label:"user messages",val:Tn((i==null?void 0:i.msgsUser)??0)}),v.jsx(zn,{label:"assistant messages",val:Tn((i==null?void 0:i.msgsAssistant)??0)}),v.jsx(zn,{label:"tool uses",val:Tn((i==null?void 0:i.toolUses)??0)}),v.jsx(zn,{label:"tool results",val:Tn((i==null?void 0:i.toolResults)??0)}),v.jsx(zn,{label:"system-reminders",val:Tn((i==null?void 0:i.systemReminders)??0)})]}),v.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?v.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):v.jsx("ul",{className:"ctx-md-list",children:i.claudeMdFiles.map(p=>v.jsxs("li",{children:[v.jsx("span",{className:"ctx-md-path",title:p.path,children:p.path}),v.jsx("span",{className:"ctx-md-size",children:pP(p.bytes)})]},p.path))})]})})}function zn({label:e,val:n,accent:i}){return v.jsxs("div",{className:`ctx-row${i?" accent":""}`,children:[v.jsx("span",{className:"ctx-row-label",children:e}),v.jsx("span",{className:"ctx-row-val",children:n})]})}function gP({currentContextTokens:e,modelId:n,size:i=26,onClick:s,title:o}){const u=ZE(n),l=Math.min(1,e/u),c=i/2-3,d=i/2,h=2*Math.PI*c,p=h*l,m=l>.9?"var(--err)":l>.7?"var(--inflight)":"var(--accent)";return v.jsx("button",{type:"button",className:"ctx-donut",onClick:s,title:o??`context: ${e.toLocaleString()} / ${u.toLocaleString()} (${(l*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:v.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[v.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),v.jsx("circle",{cx:d,cy:d,r:c,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${p} ${h-p}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),v.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(l*100)})]})})}function vP(e,n){const i=Jg(n);if(!i)return"no rates for this model";const s=l=>l.toLocaleString(),o=l=>`$${l}/MTok`,u=rn(e,n);return[`model: ${n}`,`input ${s(e.inputTokens).padStart(14)} × ${o(i.input).padEnd(11)} = ${He(u.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(i.output).padEnd(11)} = ${He(u.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(i.cacheRead).padEnd(11)} = ${He(u.cacheRead)}`,`cache w ${s(e.cacheCreateTokens).padStart(14)} × ${o(i.cacheWrite).padEnd(11)} = ${He(u.cacheWrite)}`,"─────────────────────────────────────────",`total = ${He(u.total)}`].join(`
58
58
  `)}function yP(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 u=Math.floor(o/60),l=o%60;return`${u}m ${String(l).padStart(2,"0")}s`}function wP({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,l=`hsl(${Zg(e.sessionId)} 70% 60%)`,c=((h=e.context)==null?void 0:h.currentContextTokens)??0,d=e.kind==="root"&&c>0;return v.jsxs("div",{className:s,style:{"--accent":l},children:[v.jsx("span",{className:"accent-stripe"}),v.jsx(As,{type:"target",position:Ce.Left,style:{background:"transparent",border:"none"}}),v.jsxs("div",{className:"head",children:[v.jsxs("div",{className:"title",children:[v.jsx(xP,{state:e.state}),v.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&v.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),v.jsxs("div",{className:"head-right",children:[d&&e.onOpenContext&&v.jsx(gP,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),v.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:yP(e.startedAt,e.endedAt,i)})]})]}),v.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&v.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&v.jsx("span",{className:"model-chip",title:e.model,children:Bo(e.model)})]}),e.tools.length>0&&v.jsx(SP,{tools:e.tools,now:i}),v.jsxs("div",{className:"meta",children:[v.jsxs("span",{children:[v.jsx("b",{children:e.toolCount})," tools"]}),o>0&&v.jsxs("span",{className:"inflight-meta",children:[v.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&v.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:[v.jsx("b",{children:_P(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&Jg(e.model)&&(()=>{const p=rn(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"?ku(p.total,m):null,x=vP(e.usage,e.model)+(y?`
59
- burn: ${y}`:"");return v.jsxs("span",{className:"cost-meta",title:x,children:[v.jsx("b",{children:He(p.total)}),y&&v.jsx("span",{className:"cost-rate",children:y})]})})()]}),v.jsx(As,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function xP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return v.jsx("span",{className:`state-pill state-${e}`,children:n})}function _P(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function SP({tools:e,now:n}){const u=new Array(24).fill(0);let l=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(u[N]+=1,l+=1)}const c=Math.max(1,...u),d=132,h=14,p=d/24,m=c/(2500/1e3);return v.jsxs("div",{className:"tool-spark-row",title:`${l} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[v.jsx("svg",{className:"tool-spark",width:d,height:h,viewBox:`0 0 ${d} ${h}`,"aria-hidden":!0,children:u.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return v.jsx("rect",{x:x*p+.4,y:h-N,width:Math.max(.5,p-1),height:N,rx:.8,className:b},x)})}),v.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Bo(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(),u=n[2].replace(/[-_]/g,".");return`${o} ${u}`}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 Bw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function bP(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 kP({tool:e,onClose:n}){q.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 v.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:v.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[v.jsxs("header",{className:"modal-head",children:[v.jsxs("div",{className:"modal-title",children:[v.jsx("span",{className:`status-dot ${i}`}),v.jsx("span",{className:"modal-tool-name",children:e.name}),v.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),v.jsxs("div",{className:"modal-actions",children:[v.jsx("span",{className:"modal-dur",children:bP(e)}),v.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),v.jsxs("section",{className:"modal-body",children:[v.jsxs("div",{className:"modal-section",children:[v.jsx("h4",{children:"Input"}),v.jsx("pre",{children:Bw(e.input??e.inputPreview)})]}),v.jsxs("div",{className:"modal-section",children:[v.jsxs("h4",{children:["Response ",i==="err"&&v.jsx("span",{className:"err-tag",children:"error"})]}),v.jsx("pre",{children:e.endedAt==null?"(waiting…)":Bw(e.response??e.errorPreview)})]})]})]})})}const su=18,Uw=26,EP=12;function NP(e){const n=new Map;for(const o of e.nodeInternals.values()){const u=o.data;if(!(u!=null&&u.sessionId)||u.exitAt!=null||o.width==null||o.height==null)continue;const l=o.position.x,c=o.position.y,d=l+o.width,h=c+o.height,p=n.get(u.sessionId);p?(p.minX=Math.min(p.minX,l),p.minY=Math.min(p.minY,c),p.maxX=Math.max(p.maxX,d),p.maxY=Math.max(p.maxY,h),u.kind==="root"&&(p.label=Hw(u)??p.label)):n.set(u.sessionId,{minX:l,minY:c,maxX:d,maxY:h,label:Hw(u)??u.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,u]of n){const c=(i.get(u.label)??0)>1?`${u.label} · ${CP(o)}`:u.label;s.push({sessionId:o,label:c,x:u.minX-su,y:u.minY-su-Uw,w:u.maxX-u.minX+su*2,h:u.maxY-u.minY+su*2+Uw})}return s}function CP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Hw(e){if(e.kind==="root")return e.label}function TP(){const{x:e,y:n,zoom:i}=UE(),s=zo(),o=Xe(NP,RP);if(o.length<=1)return null;const u=l=>{try{const c=s.getNodes().filter(d=>{const h=d.data;return(h==null?void 0:h.sessionId)===l});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return v.jsx("div",{className:"session-clusters",children:o.map(l=>{const c=Zg(l.sessionId),d={position:"absolute",left:l.x*i+e,top:l.y*i+n,width:l.w*i,height:l.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:l.x*i+e+16*i,top:(l.y-EP)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return v.jsxs(oe.Fragment,{children:[v.jsx("div",{className:"cluster-card",style:d,"aria-hidden":!0}),v.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${l.label} · drag the wrapper to move the whole session`,onClick:()=>u(l.sessionId),children:l.label})]},l.sessionId)})})}function RP(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 jP({data:e}){return v.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const JE=600,AP=36,Rg=16,IP=60,MP=6,Vw=220,Ww=96,PP=28,OP={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 qP(e){return e.startsWith("mcp__")?"mcp":OP[e]??"other"}const LP={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 Gw(e){return e.startsWith("mcp__")?"🔌":LP[e]??"✨"}const $P={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 eN(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 eN(i[1]);for(;;){const u=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!u)break;n=n.slice(u[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 DP(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 FP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),zP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function BP(e,n){return zP.has(e)?Math.max(Ww,34+n.length*7.5):Ww}function UP(e,n){if(!FP.has(e))return null;const i=DP(n);if(!i)return null;const s=eN(i);return s?{emoji:$P[s]??"⚙️",label:s,category:"shell",detail:i}:null}const HP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Yw={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:"🗄️"},Kw={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 VP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function WP(e){const n=e.toLowerCase();if(Kw[n])return Kw[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(Yw[s])return Yw[s]}return"📄"}function GP(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 YP(e,n){if(!HP.has(e))return null;const i=GP(e,n);if(!i)return null;const s=VP(i);return s?{emoji:e==="LS"?"📂":WP(s),label:s,category:"file",detail:i}:null}const tN={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 nN(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 KP(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 XP(e,n){const i=nN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const u=tN[s.toLowerCase()];return{emoji:(u==null?void 0:u.emoji)??"🔌",label:o,category:"mcp",detail:u?`${u.name} · ${o}`:`${s} · ${o}`}}function QP(e,n){return UP(e,n)??YP(e,n)??XP(e)}const ZP={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function JP(e){const n=nN(e);if(n){const s=tN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:KP(n.server)}}const i=ZP[e];return i?{emoji:Gw(e),label:i}:{emoji:Gw(e),label:e}}function e3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function t3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/JE)}function n3(e,n,i,s,o,u){const l=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&u-c.exitAt>JE)continue;const d=s.get(c.id)??i.get(c.id);if(!d)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)??Vw,Vw),x=(m==null?void 0:m.height)??130,N=d.x,_=d.y,S=N+y,b=_+x/2;h.forEach((k,E)=>{const C=E*AP,A=N+y+IP,P=_+MP+C,I=t3(k,u,p),M=k.inputPreview??"",R=e3(k),L=I<.999,F=JP(k.name);l.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:F.label,emoji:F.emoji,status:R,category:qP(k.name),mcpHue:F.hue,inputPreview:M,fade:I,fading:L,worldX:A,worldY:P,anchorX:S,anchorY:b,spawnDx:S-A,spawnDy:b-(P+Rg)});const Q=QP(k.name,k.input);if(Q){const X=BP(k.name,F.label),j=A+X+PP,G=P,U=A+X,ne=P+Rg;l.push({id:`sub:${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:Q.label,emoji:Q.emoji,isSub:!0,status:R,category:Q.category,inputPreview:Q.detail??M,fade:I,fading:L,worldX:j,worldY:G,anchorX:U,anchorY:ne,spawnDx:U-j,spawnDy:0})}})}return l}function r3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:u,spotlight:l,hiddenCategories:c,now:d,onOpenTool:h}){const{x:p,y:m,zoom:y}=UE(),x=n3(e,n,i,s,o,d),N=c&&c.size>0?x.filter(_=>!c.has(_.category)):x;return v.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[v.jsx("svg",{className:"tool-bursts-svg",children:N.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,k=(_.worldX+6)*y+p,E=(_.worldY+Rg)*y+m,C=S+(k-S)*.55,A=u!=null&&!u.has(_.agentId),P=l!=null&&!l.has(_.agentId),I=_.fade*(A||P?.14:1);return v.jsx("path",{d:`M ${S} ${b} Q ${C} ${b}, ${k} ${E}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:I},`l:${_.id}`)})}),N.map(_=>{const S=_.worldX*y+p,b=_.worldY*y+m,k={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},E=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${E} · ${_.inputPreview}`:E,A=h!=null,P=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},I=u!=null&&!u.has(_.agentId),M=l!=null&&!l.has(_.agentId),R=I||M?" dim":"";return v.jsx("div",{className:"tool-burst-wrap",style:k,children:v.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${A?" clickable":""}${_.isSub?" sub":""}${R}`,style:P,title:C,role:A?"button":void 0,tabIndex:A?0:void 0,"aria-label":A?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:A?()=>h(_.toolId):void 0,onKeyDown:A?L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),h(_.toolId))}:void 0,children:[v.jsx("span",{className:"tb-emoji",children:_.emoji}),v.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&v.jsx("span",{className:"tb-spin"}),_.status==="done"&&v.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&v.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function i3({state:e,sessionId:n,onClose:i}){const s=q.useMemo(()=>o3(e,n),[e,n]);return s?v.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:v.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[v.jsxs("div",{className:"modal-head",children:[v.jsxs("div",{className:"modal-title",children:[v.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),v.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),v.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),v.jsxs("div",{className:"modal-actions",children:[v.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),v.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),v.jsxs("div",{className:"modal-body",children:[v.jsxs("section",{className:"ss-hero",children:[v.jsxs("div",{className:"ss-hero-left",children:[v.jsx("div",{className:"ss-cost-label",children:"total spend"}),v.jsx("div",{className:"ss-cost",children:He(s.cost.total)}),s.modelChips.length>0&&v.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>v.jsx("span",{className:"model-chip",title:o,children:Bo(o)},o))})]}),v.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&v.jsxs(v.Fragment,{children:[v.jsx(s3,{cost:s.cost}),v.jsxs("div",{className:"ss-cost-legend",children:[v.jsxs("span",{className:"ssl ssl-in",children:["input ",v.jsx("b",{children:He(s.cost.input)})]}),v.jsxs("span",{className:"ssl ssl-out",children:["output ",v.jsx("b",{children:He(s.cost.output)})]}),v.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",v.jsx("b",{children:He(s.cost.cacheRead)})]}),v.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",v.jsx("b",{children:He(s.cost.cacheWrite)})]})]})]})})]}),v.jsxs("section",{className:"ss-stats",children:[v.jsx(xs,{label:"agents",value:s.agentCount}),v.jsx(xs,{label:"subagents",value:s.subagentCount}),v.jsx(xs,{label:"tool calls",value:s.toolCount}),v.jsx(xs,{label:"prompts",value:s.promptCount}),v.jsx(xs,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&v.jsx(xs,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&v.jsxs("section",{className:"modal-section",children:[v.jsx("h4",{children:"Most-used tools"}),v.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,u])=>v.jsxs("div",{className:"ss-tt",children:[v.jsx("span",{className:"ss-tt-name",children:o}),v.jsx("span",{className:"ss-tt-bar",children:v.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/s.topTools[0][1]*100}%`}})}),v.jsx("span",{className:"ss-tt-count",children:u})]},o))})]}),s.firstPrompt&&v.jsxs("section",{className:"modal-section",children:[v.jsx("h4",{children:"Opening prompt"}),v.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function xs({label:e,value:n,tone:i}){return v.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[v.jsx("div",{className:"ss-stat-value",children:n}),v.jsx("div",{className:"ss-stat-label",children:e})]})}function s3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,u)=>{if(s<=0)return null;const l=s/n*100;return v.jsx("span",{className:`cb-seg ${o}`,style:{width:`${l}%`},title:`${u}: ${He(s)} (${l.toFixed(0)}%)`},o)};return v.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 o3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const E of e.agents.values())E.sessionId===n&&s.push(E);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},u=new Set,l=new Map;let c=0,d=0,h=0,p=0,m=0,y,x=1/0,N=0;for(const E of s){const C=rn(E.usage,E.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,E.model&&u.add(E.model),E.kind==="subagent"&&m++,d+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),h+=E.usage.inputTokens+E.usage.outputTokens,c+=E.tools.length,x=Math.min(x,E.startedAt),N=Math.max(N,E.endedAt??Date.now());for(const A of E.tools)l.set(A.name,(l.get(A.name)??0)+1),A.ok===!1&&p++}const _=Math.max(0,N-x),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`,k=Array.from(l.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(u),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:d,tokensSum:h,errCount:p,topTools:k,firstPrompt:y}}function a3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,u=rn(s.usage,s.model).total,l=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.tools.length,u+=rn(c.usage,c.model).total;const d=c.endedAt??c.startedAt;d>l&&(l=d)}i.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:u,startedAt:s.startedAt,lastActivity:l})}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 u3(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 u=Math.floor(o/60);return u<60?`${u}m`:`${Math.floor(u/60)}h ${u%60}m`}function l3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const u=q.useMemo(()=>a3(e),[e,e.lastSeq,n]),l=u.filter(c=>c.state==="active").length;return v.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[v.jsxs("div",{className:"sl-header",children:[v.jsxs("h3",{children:["Sessions ",v.jsx("span",{className:"sl-count",children:u.length})]}),l>0&&v.jsxs("span",{className:"sl-live-count",children:[l," live"]}),v.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),v.jsxs("div",{className:"sl-rows",children:[u.length===0&&v.jsx("div",{className:"sl-empty",children:"No sessions yet."}),u.map(c=>{const d=i.has(c.sessionId);return v.jsxs("button",{type:"button",className:`sl-row state-${c.state}${d?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[v.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),v.jsxs("div",{className:"sl-row-body",children:[v.jsxs("div",{className:"sl-row-head",children:[v.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&v.jsx("span",{className:"model-chip",title:c.modelId,children:Bo(c.modelId)})]}),v.jsxs("div",{className:"sl-row-meta",children:[v.jsxs("span",{title:"tool calls",children:[v.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&v.jsx("span",{className:"sl-cost",title:"total spend",children:v.jsx("b",{children:He(c.cost)})}),v.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:u3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function Xw(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 c3(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 pr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function f3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,u)=>{if(s<=0)return null;const l=s/n*100;return v.jsx("span",{className:`cb-seg ${o}`,style:{width:`${l}%`},title:`${u}: ${He(s)} (${l.toFixed(0)}%)`},o)};return v.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 d3(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 u=Math.floor(i/86400),l=Math.floor(i%86400/3600);return`${u}d ${l}h`}return s>0?`${s}h ${o}m`:`${o}m`}function h3(e,n,i,s){const o=Math.max(0,n-s),u=Math.max(0,i-o);if(u<120)return null;const l=Math.min(100,u/i*100),c=e-l;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:l,isDeficit:!1};if(c>0){const d=100-e,h=u>0?e/u:0,p=h>0?d/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:l,isDeficit:!0};if(p<o&&p<86400){const y=Math.floor(p/3600),x=Math.floor(p%3600/60);m.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:l,isDeficit:!1}}function bi({pct:e,label:n,reset:i,resetAt:s,windowSec:o,limitReached:u,nowSec:l}){const c=Math.min(100,Math.max(0,e)),h=u||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",p=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?d3(s,l):null,x=s&&o?h3(c,s,o,l):null;return v.jsxs("div",{className:"qb-row",children:[v.jsxs("div",{className:"qb-meta",children:[v.jsxs("span",{className:"qb-label",children:[n,u&&v.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),v.jsx("span",{className:"qb-pct",style:{color:h},children:p})]}),v.jsxs("div",{className:"qb-track",children:[v.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),x&&v.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.expectedPct)}% by now`})]}),v.jsxs("div",{className:"qb-reset-row",children:[y?v.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?v.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,x&&v.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const p3=6e4;function m3(){const[e,n]=q.useState(null),[i,s]=q.useState(!1),o=q.useRef(null),u=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 q.useEffect(()=>(u(!0),o.current=window.setInterval(()=>u(!1),p3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>u(!0)}}function g3(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 rN=6e4;function v3(){const[e,n]=q.useState(null),[i,s]=q.useState(!1),o=q.useRef(null),u=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 q.useEffect(()=>(u(!0),o.current=window.setInterval(()=>u(!1),rN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>u(!0)}}function y3(){const[e,n]=q.useState(null),i=q.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return q.useEffect(()=>(s(),i.current=window.setInterval(s,rN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function w3({state:e,now:n,onClose:i}){var I,M;const{quota:s,loading:o,refresh:u}=m3(),{data:l,loading:c,refresh:d}=v3(),{data:h}=y3(),[p,m]=q.useState(()=>Math.floor(Date.now()/1e3));q.useEffect(()=>{const R=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(R)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=q.useMemo(()=>{const R=new Map,L={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let F=0,Q=0,X=0,j=0;for(const D of e.agents.values()){const V=D.model??"__unknown__",O=rn(D.usage,D.model),B=R.get(V);B?(B.inputTokens+=D.usage.inputTokens,B.outputTokens+=D.usage.outputTokens,B.cacheReadTokens+=D.usage.cacheReadTokens,B.cacheCreateTokens+=D.usage.cacheCreateTokens,B.cost.total+=O.total,B.cost.input+=O.input,B.cost.output+=O.output,B.cost.cacheRead+=O.cacheRead,B.cost.cacheWrite+=O.cacheWrite,B.agentCount++):R.set(V,{model:V,inputTokens:D.usage.inputTokens,outputTokens:D.usage.outputTokens,cacheReadTokens:D.usage.cacheReadTokens,cacheCreateTokens:D.usage.cacheCreateTokens,cost:{...O},agentCount:1}),L.total+=O.total,L.input+=O.input,L.output+=O.output,L.cacheRead+=O.cacheRead,L.cacheWrite+=O.cacheWrite,F+=D.usage.inputTokens,Q+=D.usage.outputTokens,X+=D.usage.cacheReadTokens,j+=D.usage.cacheCreateTokens}const G=Array.from(R.values()).sort((D,V)=>V.cost.total-D.cost.total);let U=0,ne=0;for(const D of e.agents.values()){if(D.state!=="active")continue;const V=rn(D.usage,D.model);U+=V.total,ne=Math.max(ne,((D.endedAt??n)-D.startedAt)/1e3)}const K=ne>0?ku(U,ne):null;return{byModel:G,totalCost:L,totalTokens:{in:F,out:Q,cacheR:X,cacheC:j},burnRate:K}},[e,e.lastSeq,n]),S=q.useMemo(()=>{const R=[];for(const L of e.agents.values()){if(L.kind!=="root")continue;let F=rn(L.usage,L.model).total,Q=L.usage.inputTokens,X=L.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==L.sessionId||j.kind==="root"||(F+=rn(j.usage,j.model).total,Q+=j.usage.inputTokens,X+=j.usage.outputTokens);R.push({sessionId:L.sessionId,label:L.label||L.cwdBasename||"session",state:L.state,cost:F,inputTokens:Q,outputTokens:X})}return R.sort((L,F)=>F.cost-L.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=N.in+N.out,E=o||c,C=Xw(s==null?void 0:s.fetchedAt,p),A=Xw(l==null?void 0:l.fetchedAt,p),P=()=>{u(),d()};return v.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[v.jsxs("div",{className:"up-header",children:[v.jsx("h3",{children:"Usage"}),_&&v.jsx("span",{className:"up-rate",children:_}),v.jsxs("div",{className:"up-header-right",children:[v.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:P,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),v.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),v.jsxs("section",{className:"up-section up-quota-section",children:[v.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&v.jsx("span",{className:"up-section-age",title:c3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?v.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&v.jsx(bi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:p}),s.week7dPct!=null&&v.jsx(bi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:p}),s.weekSonnetPct!=null&&v.jsx(bi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:p}),s.weekOpusPct!=null&&v.jsx(bi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:p})]}):(s==null?void 0:s.ok)===!1?v.jsxs("div",{className:"up-quota-na",children:[v.jsx("span",{children:"Quota unavailable."}),v.jsxs("span",{className:"up-quota-hint",children:["Run ",v.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):v.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),v.jsxs("section",{className:"up-section up-quota-section",children:[v.jsxs("h4",{className:"up-section-title",children:["Codex quota",(l==null?void 0:l.ok)&&l.planLabel&&v.jsx("span",{className:"up-plan-badge",children:l.planLabel}),A&&!c&&v.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:A})]}),l!=null&&l.ok?v.jsxs("div",{className:"up-quota-bars",children:[(I=l.windows)==null?void 0:I.map(R=>v.jsx(bi,{label:R.label,pct:R.pct,reset:R.reset??void 0,resetAt:R.resetAt??void 0,windowSec:R.windowSec??void 0,limitReached:l.limitReached&&R.pct>=100,nowSec:p},R.id)),(M=l.extraWindows)==null?void 0:M.map(R=>v.jsx(bi,{label:R.label,pct:R.pct,reset:R.reset??void 0,resetAt:R.resetAt??void 0,windowSec:R.windowSec??void 0,nowSec:p},R.id)),l.creditLimit&&v.jsx(bi,{label:`spend cap · $${Math.round(l.creditLimit.used)} of $${Math.round(l.creditLimit.limit)}`,pct:l.creditLimit.usedPct,reset:l.creditLimit.reset??void 0,resetAt:l.creditLimit.resetAt??void 0,limitReached:l.spendControlReached,nowSec:p}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&v.jsxs("div",{className:"up-quota-sub",children:[pr(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),l.creditsBalance&&!l.creditsUnlimited&&v.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",l.creditsBalance,l.overageReached&&" · overage limit reached"]}),l.creditsUnlimited&&v.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),l.resetCredits&&l.resetCredits.availableCount>0&&v.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[l.resetCredits.availableCount," rate-limit reset",l.resetCredits.availableCount!==1?"s":""," available",l.resetCredits.nextExpiryAt&&` · expires ${new Date(l.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),l.promo&&v.jsx("div",{className:"up-quota-sub",children:l.promo}),l.partial&&v.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(l==null?void 0:l.ok)===!1?v.jsxs("div",{className:"up-quota-na",children:[v.jsx("span",{children:"Quota unavailable."}),v.jsx("span",{className:"up-quota-hint",children:g3(l.reason)})]}):v.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"up-total",children:[v.jsx("span",{className:"up-total-value",children:He(x.total)}),v.jsx("span",{className:"up-total-label",children:"total spend"})]}),v.jsx(f3,{cost:x}),k>0&&v.jsxs("div",{className:"up-tokens-row",children:[v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"in"}),pr(N.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),pr(N.out)]}),N.cacheR>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache r"}),pr(N.cacheR)]}),N.cacheC>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache c"}),pr(N.cacheC)]})]}),y.filter(R=>R.cost.total>0).length>0&&v.jsxs("section",{className:"up-section",children:[v.jsx("h4",{className:"up-section-title",children:"By model"}),v.jsxs("table",{className:"up-table",children:[v.jsx("thead",{children:v.jsxs("tr",{children:[v.jsx("th",{children:"Model"}),v.jsx("th",{children:"Tokens"}),v.jsx("th",{children:"Cost"})]})}),v.jsx("tbody",{children:y.filter(R=>R.cost.total>0).map(R=>v.jsxs("tr",{children:[v.jsx("td",{className:"up-model-name",title:R.model,children:Bo(R.model)}),v.jsx("td",{className:"up-num",children:pr(R.inputTokens+R.outputTokens)}),v.jsx("td",{className:"up-num up-cost-val",children:He(R.cost.total)})]},R.model))})]})]}),S.filter(R=>R.cost>0).length>0&&v.jsxs("section",{className:"up-section",children:[v.jsx("h4",{className:"up-section-title",children:"By session"}),v.jsx("div",{className:"up-sessions",children:S.filter(R=>R.cost>0).map(R=>v.jsxs("div",{className:"up-session-row",children:[v.jsx("span",{className:`sl-dot state-${R.state}`,"aria-hidden":!0}),v.jsx("span",{className:"up-session-label",children:R.label}),v.jsx("span",{className:"up-session-tokens",children:pr(R.inputTokens+R.outputTokens)}),v.jsx("span",{className:"up-session-cost",children:He(R.cost)})]},R.sessionId))})]})]}):k>0?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"up-tokens-row",children:[v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"in"}),pr(N.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),pr(N.out)]})]}),v.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):v.jsxs("div",{className:"up-empty",children:["No usage data yet.",v.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const x3=15e3,_3=[70,80,85,90,95];function S3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/86400),o=Math.floor(i%86400/3600),u=Math.floor(i%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${u}m`:`${u}m`}function Qw(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 b3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?"":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function k3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function E3({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?S3(e.resetAt,n):null;return v.jsxs("div",{className:"ap-lane",children:[v.jsx("span",{className:"ap-lane-label",children:e.label}),v.jsx("div",{className:"ap-lane-track",children:v.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),v.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),v.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function N3({onClose:e}){var A,P,I;const[n,i]=q.useState(null),[s,o]=q.useState(null),[u,l]=q.useState(null),[c,d]=q.useState(null),[h,p]=q.useState(null),[m,y]=q.useState(()=>Math.floor(Date.now()/1e3)),x=q.useRef(null),N=q.useCallback(async(M=!1)=>{try{const[R,L]=await Promise.all([fetch(`/api/claude-accounts${M?"?refresh=1":""}`),fetch("/api/cswap-auto")]);R.ok&&i(await R.json()),L.ok&&o(await L.json())}catch{}},[]),_=q.useCallback(async(M,R)=>{l(R),p(null);try{const F=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)})).json().catch(()=>null);return F!=null&&F.ok||p((F==null?void 0:F.detail)||(F==null?void 0:F.reason)||"command failed"),F}catch{return p("server unreachable"),null}finally{l(null)}},[]);q.useEffect(()=>(N(!0),x.current=window.setInterval(()=>N(!1),x3),()=>{x.current!=null&&window.clearInterval(x.current)}),[N]),q.useEffect(()=>{const M=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(M)},[]);const S=((A=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:A.value)??"90",b=(P=n==null?void 0:n.accounts)==null?void 0:P.find(M=>M.active),k=b!=null&&b.lanes.length?Math.max(...b.lanes.map(M=>M.pct)):null,E=k!=null&&k>=Number(S)-15,C=async M=>{d(M),p(null);try{const L=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:M})})).json().catch(()=>null);L!=null&&L.ok||p((L==null?void 0:L.output)||(L==null?void 0:L.reason)||"switch failed"),await N(!0)}catch{p("server unreachable")}finally{d(null)}};return v.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[v.jsxs("div",{className:"ap-header",children:[v.jsx("h3",{children:"Accounts"}),v.jsxs("div",{className:"ap-header-right",children:[v.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>N(!0),title:"Reload from claude-swap",children:"↻"}),v.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?v.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?v.jsxs(v.Fragment,{children:[(I=n.accounts)==null?void 0:I.map(M=>v.jsxs("div",{className:`ap-account${M.active?" active":""}${M.disabled?" disabled":""}`,children:[v.jsxs("div",{className:"ap-account-head",children:[v.jsx("span",{className:"ap-num",children:M.num}),M.alias&&v.jsx("span",{className:"ap-alias",children:M.alias}),v.jsx("span",{className:"ap-email",title:M.org??void 0,children:M.email}),M.active?v.jsx("span",{className:"ap-badge-active",children:"● active"}):v.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||M.disabled,onClick:()=>C(M.num),title:M.disabled?"Held out of rotation":`Switch to ${M.alias??M.email}`,children:c===M.num?"…":"switch"})]}),M.lanes.length>0?M.lanes.map(R=>v.jsx(E3,{lane:R,nowSec:m},R.id)):v.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),v.jsxs("div",{className:"ap-meta",children:[M.error&&v.jsx("span",{className:"ap-err",children:k3(M.error)}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!M.active&&v.jsx("button",{type:"button",className:"ap-rotate",disabled:u!=null,onClick:()=>_({action:"account",account:M.num,enabled:M.disabled},`rot-${M.num}`).then(()=>N(!0)),title:M.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:M.disabled?"held out":"in rotation"}),M.fetchedAt?v.jsxs("span",{className:`ap-age${M.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 ",Qw(M.fetchedAt,m),b3(M.nextAt,m)]}):v.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]})]},M.num)),(s==null?void 0:s.ok)&&v.jsxs("div",{className:"ap-auto",children:[v.jsxs("div",{className:"ap-auto-head",children:[v.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),v.jsxs("span",{className:"ap-auto-ctl",children:[k!=null&&v.jsxs("span",{className:`ap-auto-now${E?" near":""}`,children:[Math.round(k),"%"]}),v.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:v.jsx("select",{"aria-label":"Switch threshold",value:S,disabled:u!=null,onChange:M=>_({action:"setting",key:"autoswitch.threshold",value:M.target.value},"threshold").then(()=>N(!0)),children:_3.map(M=>v.jsxs("option",{value:M,children:[M,"%"]},M))})}),v.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:u!=null,onClick:()=>_({action:"enable",enabled:!s.enabled},"enable").then(()=>N(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[v.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&v.jsxs("p",{className:"ap-auto-note",children:[v.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",v.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&&v.jsx("div",{className:"ap-auto-foot",children:v.jsxs("span",{className:"ap-auto-result",children:["checked ",Qw(s.lastTick.at,m)]})})]}),h&&v.jsx("div",{className:"ap-failure",children:h}),v.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 reads what claude-swap already collected.",children:"Read from claude-swap, not polled."})]}):v.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"claude-swap isn't installed."}),v.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&&v.jsx("code",{className:"ap-cmd",children:n.hint}),v.jsxs("span",{className:"ap-hint",children:["Then add your accounts with ",v.jsx("code",{children:"cswap add"})," and reload."]})]}):n.reason==="no_accounts"?v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"No accounts added yet."}),v.jsx("span",{className:"ap-hint",children:"claude-swap is installed but has nothing in its store."}),v.jsx("code",{className:"ap-cmd",children:"cswap add"})]}):v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"Couldn't read the account store."}),v.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})})]})}function ki(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 Zw(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function ou(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 C3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const T3=[7,14,30,90];function R3(e){const[n,i]=q.useState(null),[s,o]=q.useState(!1),u=(l=!1)=>{o(!0);const d=`/api/ccusage?since=${C3(e)}${l?"&refresh=1":""}`;fetch(d).then(h=>h.json()).then(i).catch(()=>i({ok:!1,error:"request failed"})).finally(()=>o(!1))};return q.useEffect(()=>{u(!1)},[e]),{data:n,loading:s,reload:()=>u(!0)}}function j3({onClose:e}){var b,k;const[n,i]=q.useState(30),[s,o]=q.useState(null),{data:u,loading:l,reload:c}=R3(n);q.useEffect(()=>{const E=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const d=u!=null&&u.ok?u.days??[]:[],h=q.useMemo(()=>d.reduce((E,C)=>Math.max(E,C.totalCost),0),[d]),{totalCost:p,totalTok:m,inOut:y,cacheRead:x,modelCosts:N}=q.useMemo(()=>{let E=0,C=0,A=0,P=0;const I=new Map;for(const M of d){E+=M.totalCost,C+=M.totalTokens,A+=M.inputTokens+M.outputTokens,P+=M.cacheReadTokens;for(const R of M.modelBreakdowns)I.set(R.modelName,(I.get(R.modelName)??0)+R.cost)}return{totalCost:E,totalTok:C,inOut:A,cacheRead:P,modelCosts:I}},[d]),_=q.useMemo(()=>Array.from(N.entries()).sort((E,C)=>C[1]-E[1]),[N]),S=s?d.find(E=>E.period===s)??null:null;return v.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:v.jsxs("div",{className:"uh-modal",onClick:E=>E.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[v.jsxs("header",{className:"uh-head",children:[v.jsxs("div",{className:"uh-titlewrap",children:[v.jsx("div",{className:"uh-title",children:"Usage history"}),v.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),v.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:T3.map(E=>v.jsxs("button",{role:"tab","aria-selected":n===E,className:`uh-range-btn${n===E?" on":""}`,onClick:()=>{i(E),o(null)},children:[E,"d"]},E))}),v.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),v.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),l&&d.length===0?v.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):u&&!u.ok?v.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",u.error]}):d.length===0?v.jsx("div",{className:"uh-status",children:"no usage in this range"}):v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"uh-totals",children:[v.jsx(au,{label:"total cost",val:He(p),accent:!0}),v.jsx(au,{label:"tokens",val:ki(m)}),v.jsx(au,{label:"input+output",val:ki(y)}),v.jsx(au,{label:"cache reads",val:ki(x)})]}),v.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:d.map(E=>{const C=h>0?E.totalCost/h*100:0,A=E.period===s;return v.jsxs("button",{className:`uh-bar-col${A?" sel":""}`,onClick:()=>o(A?null:E.period),title:`${E.period} · ${He(E.totalCost)}`,style:{flexBasis:`${100/d.length}%`},children:[v.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,E.totalCost>0?2:0)}%`},children:E.modelBreakdowns.slice().sort((P,I)=>I.cost-P.cost).map(P=>{const I=E.totalCost>0?P.cost/E.totalCost*100:0;return v.jsx("div",{className:"uh-bar-seg",style:{height:`${I}%`,background:ou(P.modelName)}},P.modelName)})}),v.jsx("span",{className:"uh-bar-label",children:E.period.slice(5)})]},E.period)})}),v.jsx("div",{className:"uh-legend",children:_.map(([E,C])=>v.jsxs("span",{className:"uh-legend-item",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:ou(E)}}),Zw(E)," ",v.jsx("span",{className:"uh-legend-cost",children:He(C)})]},E))}),S&&v.jsxs("div",{className:"uh-detail",children:[v.jsxs("div",{className:"uh-detail-head",children:[v.jsx("span",{className:"uh-detail-date",children:S.period}),v.jsx("span",{className:"uh-detail-cost",children:He(S.totalCost)}),(k=(b=S.metadata)==null?void 0:b.agents)!=null&&k.length?v.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),v.jsxs("div",{className:"uh-detail-mini",children:[v.jsx(uu,{label:"input",val:ki(S.inputTokens)}),v.jsx(uu,{label:"output",val:ki(S.outputTokens)}),v.jsx(uu,{label:"cache write",val:ki(S.cacheCreationTokens)}),v.jsx(uu,{label:"cache read",val:ki(S.cacheReadTokens)})]}),v.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((E,C)=>C.cost-E.cost).map(E=>{const C=S.totalCost>0?E.cost/S.totalCost*100:0;return v.jsxs("div",{className:"uh-model-row",children:[v.jsxs("span",{className:"uh-model-name",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:ou(E.modelName)}}),Zw(E.modelName)]}),v.jsx("span",{className:"uh-model-bar",children:v.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:ou(E.modelName)}})}),v.jsx("span",{className:"uh-model-cost",children:He(E.cost)})]},E.modelName)})})]})]})]})})}function au({label:e,val:n,accent:i}){return v.jsxs("div",{className:"uh-stat",children:[v.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),v.jsx("span",{className:"uh-stat-label",children:e})]})}function uu({label:e,val:n}){return v.jsxs("div",{className:"uh-ministat",children:[v.jsx("span",{className:"uh-ministat-val",children:n}),v.jsx("span",{className:"uh-ministat-label",children:e})]})}function ev(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 Wc,Jw;function A3(){if(Jw)return Wc;Jw=1;function e(){this.__data__=[],this.size=0}return Wc=e,Wc}var Gc,ex;function Is(){if(ex)return Gc;ex=1;function e(n,i){return n===i||n!==n&&i!==i}return Gc=e,Gc}var Yc,tx;function Mu(){if(tx)return Yc;tx=1;var e=Is();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return Yc=n,Yc}var Kc,nx;function I3(){if(nx)return Kc;nx=1;var e=Mu(),n=Array.prototype,i=n.splice;function s(o){var u=this.__data__,l=e(u,o);if(l<0)return!1;var c=u.length-1;return l==c?u.pop():i.call(u,l,1),--this.size,!0}return Kc=s,Kc}var Xc,rx;function M3(){if(rx)return Xc;rx=1;var e=Mu();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return Xc=n,Xc}var Qc,ix;function P3(){if(ix)return Qc;ix=1;var e=Mu();function n(i){return e(this.__data__,i)>-1}return Qc=n,Qc}var Zc,sx;function O3(){if(sx)return Zc;sx=1;var e=Mu();function n(i,s){var o=this.__data__,u=e(o,i);return u<0?(++this.size,o.push([i,s])):o[u][1]=s,this}return Zc=n,Zc}var Jc,ox;function Pu(){if(ox)return Jc;ox=1;var e=A3(),n=I3(),i=M3(),s=P3(),o=O3();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return u.prototype.clear=e,u.prototype.delete=n,u.prototype.get=i,u.prototype.has=s,u.prototype.set=o,Jc=u,Jc}var ef,ax;function q3(){if(ax)return ef;ax=1;var e=Pu();function n(){this.__data__=new e,this.size=0}return ef=n,ef}var tf,ux;function L3(){if(ux)return tf;ux=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return tf=e,tf}var nf,lx;function $3(){if(lx)return nf;lx=1;function e(n){return this.__data__.get(n)}return nf=e,nf}var rf,cx;function D3(){if(cx)return rf;cx=1;function e(n){return this.__data__.has(n)}return rf=e,rf}var sf,fx;function iN(){if(fx)return sf;fx=1;var e=typeof Ya=="object"&&Ya&&Ya.Object===Object&&Ya;return sf=e,sf}var of,dx;function Gn(){if(dx)return of;dx=1;var e=iN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return of=i,of}var af,hx;function Ms(){if(hx)return af;hx=1;var e=Gn(),n=e.Symbol;return af=n,af}var uf,px;function F3(){if(px)return uf;px=1;var e=Ms(),n=Object.prototype,i=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function u(l){var c=i.call(l,o),d=l[o];try{l[o]=void 0;var h=!0}catch{}var p=s.call(l);return h&&(c?l[o]=d:delete l[o]),p}return uf=u,uf}var lf,mx;function z3(){if(mx)return lf;mx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return lf=i,lf}var cf,gx;function Pi(){if(gx)return cf;gx=1;var e=Ms(),n=F3(),i=z3(),s="[object Null]",o="[object Undefined]",u=e?e.toStringTag:void 0;function l(c){return c==null?c===void 0?o:s:u&&u in Object(c)?n(c):i(c)}return cf=l,cf}var ff,vx;function An(){if(vx)return ff;vx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return ff=e,ff}var df,yx;function Uo(){if(yx)return df;yx=1;var e=Pi(),n=An(),i="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",u="[object Proxy]";function l(c){if(!n(c))return!1;var d=e(c);return d==s||d==o||d==i||d==u}return df=l,df}var hf,wx;function B3(){if(wx)return hf;wx=1;var e=Gn(),n=e["__core-js_shared__"];return hf=n,hf}var pf,xx;function U3(){if(xx)return pf;xx=1;var e=B3(),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 pf=i,pf}var mf,_x;function sN(){if(_x)return mf;_x=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 mf=i,mf}var gf,Sx;function H3(){if(Sx)return gf;Sx=1;var e=Uo(),n=U3(),i=An(),s=sN(),o=/[\\^$.*+?()[\]{}|]/g,u=/^\[object .+?Constructor\]$/,l=Function.prototype,c=Object.prototype,d=l.toString,h=c.hasOwnProperty,p=RegExp("^"+d.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!i(y)||n(y))return!1;var x=e(y)?p:u;return x.test(s(y))}return gf=m,gf}var vf,bx;function V3(){if(bx)return vf;bx=1;function e(n,i){return n==null?void 0:n[i]}return vf=e,vf}var yf,kx;function Oi(){if(kx)return yf;kx=1;var e=H3(),n=V3();function i(s,o){var u=n(s,o);return e(u)?u:void 0}return yf=i,yf}var wf,Ex;function tv(){if(Ex)return wf;Ex=1;var e=Oi(),n=Gn(),i=e(n,"Map");return wf=i,wf}var xf,Nx;function Ou(){if(Nx)return xf;Nx=1;var e=Oi(),n=e(Object,"create");return xf=n,xf}var _f,Cx;function W3(){if(Cx)return _f;Cx=1;var e=Ou();function n(){this.__data__=e?e(null):{},this.size=0}return _f=n,_f}var Sf,Tx;function G3(){if(Tx)return Sf;Tx=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return Sf=e,Sf}var bf,Rx;function Y3(){if(Rx)return bf;Rx=1;var e=Ou(),n="__lodash_hash_undefined__",i=Object.prototype,s=i.hasOwnProperty;function o(u){var l=this.__data__;if(e){var c=l[u];return c===n?void 0:c}return s.call(l,u)?l[u]:void 0}return bf=o,bf}var kf,jx;function K3(){if(jx)return kf;jx=1;var e=Ou(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var u=this.__data__;return e?u[o]!==void 0:i.call(u,o)}return kf=s,kf}var Ef,Ax;function X3(){if(Ax)return Ef;Ax=1;var e=Ou(),n="__lodash_hash_undefined__";function i(s,o){var u=this.__data__;return this.size+=this.has(s)?0:1,u[s]=e&&o===void 0?n:o,this}return Ef=i,Ef}var Nf,Ix;function Q3(){if(Ix)return Nf;Ix=1;var e=W3(),n=G3(),i=Y3(),s=K3(),o=X3();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return u.prototype.clear=e,u.prototype.delete=n,u.prototype.get=i,u.prototype.has=s,u.prototype.set=o,Nf=u,Nf}var Cf,Mx;function Z3(){if(Mx)return Cf;Mx=1;var e=Q3(),n=Pu(),i=tv();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return Cf=s,Cf}var Tf,Px;function J3(){if(Px)return Tf;Px=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Tf=e,Tf}var Rf,Ox;function qu(){if(Ox)return Rf;Ox=1;var e=J3();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Rf=n,Rf}var jf,qx;function eO(){if(qx)return jf;qx=1;var e=qu();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return jf=n,jf}var Af,Lx;function tO(){if(Lx)return Af;Lx=1;var e=qu();function n(i){return e(this,i).get(i)}return Af=n,Af}var If,$x;function nO(){if($x)return If;$x=1;var e=qu();function n(i){return e(this,i).has(i)}return If=n,If}var Mf,Dx;function rO(){if(Dx)return Mf;Dx=1;var e=qu();function n(i,s){var o=e(this,i),u=o.size;return o.set(i,s),this.size+=o.size==u?0:1,this}return Mf=n,Mf}var Pf,Fx;function nv(){if(Fx)return Pf;Fx=1;var e=Z3(),n=eO(),i=tO(),s=nO(),o=rO();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return u.prototype.clear=e,u.prototype.delete=n,u.prototype.get=i,u.prototype.has=s,u.prototype.set=o,Pf=u,Pf}var Of,zx;function iO(){if(zx)return Of;zx=1;var e=Pu(),n=tv(),i=nv(),s=200;function o(u,l){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!n||d.length<s-1)return d.push([u,l]),this.size=++c.size,this;c=this.__data__=new i(d)}return c.set(u,l),this.size=c.size,this}return Of=o,Of}var qf,Bx;function Lu(){if(Bx)return qf;Bx=1;var e=Pu(),n=q3(),i=L3(),s=$3(),o=D3(),u=iO();function l(c){var d=this.__data__=new e(c);this.size=d.size}return l.prototype.clear=n,l.prototype.delete=i,l.prototype.get=s,l.prototype.has=o,l.prototype.set=u,qf=l,qf}var Lf,Ux;function rv(){if(Ux)return Lf;Ux=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 Lf=e,Lf}var $f,Hx;function oN(){if(Hx)return $f;Hx=1;var e=Oi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return $f=n,$f}var Df,Vx;function $u(){if(Vx)return Df;Vx=1;var e=oN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Df=n,Df}var Ff,Wx;function Du(){if(Wx)return Ff;Wx=1;var e=$u(),n=Is(),i=Object.prototype,s=i.hasOwnProperty;function o(u,l,c){var d=u[l];(!(s.call(u,l)&&n(d,c))||c===void 0&&!(l in u))&&e(u,l,c)}return Ff=o,Ff}var zf,Gx;function Ho(){if(Gx)return zf;Gx=1;var e=Du(),n=$u();function i(s,o,u,l){var c=!u;u||(u={});for(var d=-1,h=o.length;++d<h;){var p=o[d],m=l?l(u[p],s[p],p,u,s):void 0;m===void 0&&(m=s[p]),c?n(u,p,m):e(u,p,m)}return u}return zf=i,zf}var Bf,Yx;function sO(){if(Yx)return Bf;Yx=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return Bf=e,Bf}var Uf,Kx;function rr(){if(Kx)return Uf;Kx=1;function e(n){return n!=null&&typeof n=="object"}return Uf=e,Uf}var Hf,Xx;function oO(){if(Xx)return Hf;Xx=1;var e=Pi(),n=rr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return Hf=s,Hf}var Vf,Qx;function Vo(){if(Qx)return Vf;Qx=1;var e=oO(),n=rr(),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,u=e((function(){return arguments})())?e:function(l){return n(l)&&s.call(l,"callee")&&!o.call(l,"callee")};return Vf=u,Vf}var Wf,Zx;function yt(){if(Zx)return Wf;Zx=1;var e=Array.isArray;return Wf=e,Wf}var Eo={exports:{}},Gf,Jx;function aO(){if(Jx)return Gf;Jx=1;function e(){return!1}return Gf=e,Gf}Eo.exports;var e1;function Ps(){return e1||(e1=1,(function(e,n){var i=Gn(),s=aO(),o=n&&!n.nodeType&&n,u=o&&!0&&e&&!e.nodeType&&e,l=u&&u.exports===o,c=l?i.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||s;e.exports=h})(Eo,Eo.exports)),Eo.exports}var Yf,t1;function Fu(){if(t1)return Yf;t1=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function i(s,o){var u=typeof s;return o=o??e,!!o&&(u=="number"||u!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return Yf=i,Yf}var Kf,n1;function iv(){if(n1)return Kf;n1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return Kf=n,Kf}var Xf,r1;function uO(){if(r1)return Xf;r1=1;var e=Pi(),n=iv(),i=rr(),s="[object Arguments]",o="[object Array]",u="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",p="[object Number]",m="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",P="[object Int32Array]",I="[object Uint8Array]",M="[object Uint8ClampedArray]",R="[object Uint16Array]",L="[object Uint32Array]",F={};F[k]=F[E]=F[C]=F[A]=F[P]=F[I]=F[M]=F[R]=F[L]=!0,F[s]=F[o]=F[S]=F[u]=F[b]=F[l]=F[c]=F[d]=F[h]=F[p]=F[m]=F[y]=F[x]=F[N]=F[_]=!1;function Q(X){return i(X)&&n(X.length)&&!!F[e(X)]}return Xf=Q,Xf}var Qf,i1;function zu(){if(i1)return Qf;i1=1;function e(n){return function(i){return n(i)}}return Qf=e,Qf}var No={exports:{}};No.exports;var s1;function sv(){return s1||(s1=1,(function(e,n){var i=iN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,u=o&&o.exports===s,l=u&&i.process,c=(function(){try{var d=o&&o.require&&o.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}})();e.exports=c})(No,No.exports)),No.exports}var Zf,o1;function Wo(){if(o1)return Zf;o1=1;var e=uO(),n=zu(),i=sv(),s=i&&i.isTypedArray,o=s?n(s):e;return Zf=o,Zf}var Jf,a1;function aN(){if(a1)return Jf;a1=1;var e=sO(),n=Vo(),i=yt(),s=Ps(),o=Fu(),u=Wo(),l=Object.prototype,c=l.hasOwnProperty;function d(h,p){var m=i(h),y=!m&&n(h),x=!m&&!y&&s(h),N=!m&&!y&&!x&&u(h),_=m||y||x||N,S=_?e(h.length,String):[],b=S.length;for(var k in h)(p||c.call(h,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return Jf=d,Jf}var ed,u1;function Bu(){if(u1)return ed;u1=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return ed=n,ed}var td,l1;function uN(){if(l1)return td;l1=1;function e(n,i){return function(s){return n(i(s))}}return td=e,td}var nd,c1;function lO(){if(c1)return nd;c1=1;var e=uN(),n=e(Object.keys,Object);return nd=n,nd}var rd,f1;function ov(){if(f1)return rd;f1=1;var e=Bu(),n=lO(),i=Object.prototype,s=i.hasOwnProperty;function o(u){if(!e(u))return n(u);var l=[];for(var c in Object(u))s.call(u,c)&&c!="constructor"&&l.push(c);return l}return rd=o,rd}var id,d1;function wr(){if(d1)return id;d1=1;var e=Uo(),n=iv();function i(s){return s!=null&&n(s.length)&&!e(s)}return id=i,id}var sd,h1;function ei(){if(h1)return sd;h1=1;var e=aN(),n=ov(),i=wr();function s(o){return i(o)?e(o):n(o)}return sd=s,sd}var od,p1;function cO(){if(p1)return od;p1=1;var e=Ho(),n=ei();function i(s,o){return s&&e(o,n(o),s)}return od=i,od}var ad,m1;function fO(){if(m1)return ad;m1=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return ad=e,ad}var ud,g1;function dO(){if(g1)return ud;g1=1;var e=An(),n=Bu(),i=fO(),s=Object.prototype,o=s.hasOwnProperty;function u(l){if(!e(l))return i(l);var c=n(l),d=[];for(var h in l)h=="constructor"&&(c||!o.call(l,h))||d.push(h);return d}return ud=u,ud}var ld,v1;function qi(){if(v1)return ld;v1=1;var e=aN(),n=dO(),i=wr();function s(o){return i(o)?e(o,!0):n(o)}return ld=s,ld}var cd,y1;function hO(){if(y1)return cd;y1=1;var e=Ho(),n=qi();function i(s,o){return s&&e(o,n(o),s)}return cd=i,cd}var Co={exports:{}};Co.exports;var w1;function lN(){return w1||(w1=1,(function(e,n){var i=Gn(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,u=o&&o.exports===s,l=u?i.Buffer:void 0,c=l?l.allocUnsafe:void 0;function d(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=d})(Co,Co.exports)),Co.exports}var fd,x1;function cN(){if(x1)return fd;x1=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 fd=e,fd}var dd,_1;function fN(){if(_1)return dd;_1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,u=0,l=[];++s<o;){var c=n[s];i(c,s,n)&&(l[u++]=c)}return l}return dd=e,dd}var hd,S1;function dN(){if(S1)return hd;S1=1;function e(){return[]}return hd=e,hd}var pd,b1;function av(){if(b1)return pd;b1=1;var e=fN(),n=dN(),i=Object.prototype,s=i.propertyIsEnumerable,o=Object.getOwnPropertySymbols,u=o?function(l){return l==null?[]:(l=Object(l),e(o(l),function(c){return s.call(l,c)}))}:n;return pd=u,pd}var md,k1;function pO(){if(k1)return md;k1=1;var e=Ho(),n=av();function i(s,o){return e(s,n(s),o)}return md=i,md}var gd,E1;function uv(){if(E1)return gd;E1=1;function e(n,i){for(var s=-1,o=i.length,u=n.length;++s<o;)n[u+s]=i[s];return n}return gd=e,gd}var vd,N1;function Uu(){if(N1)return vd;N1=1;var e=uN(),n=e(Object.getPrototypeOf,Object);return vd=n,vd}var yd,C1;function hN(){if(C1)return yd;C1=1;var e=uv(),n=Uu(),i=av(),s=dN(),o=Object.getOwnPropertySymbols,u=o?function(l){for(var c=[];l;)e(c,i(l)),l=n(l);return c}:s;return yd=u,yd}var wd,T1;function mO(){if(T1)return wd;T1=1;var e=Ho(),n=hN();function i(s,o){return e(s,n(s),o)}return wd=i,wd}var xd,R1;function pN(){if(R1)return xd;R1=1;var e=uv(),n=yt();function i(s,o,u){var l=o(s);return n(s)?l:e(l,u(s))}return xd=i,xd}var _d,j1;function mN(){if(j1)return _d;j1=1;var e=pN(),n=av(),i=ei();function s(o){return e(o,i,n)}return _d=s,_d}var Sd,A1;function gO(){if(A1)return Sd;A1=1;var e=pN(),n=hN(),i=qi();function s(o){return e(o,i,n)}return Sd=s,Sd}var bd,I1;function vO(){if(I1)return bd;I1=1;var e=Oi(),n=Gn(),i=e(n,"DataView");return bd=i,bd}var kd,M1;function yO(){if(M1)return kd;M1=1;var e=Oi(),n=Gn(),i=e(n,"Promise");return kd=i,kd}var Ed,P1;function gN(){if(P1)return Ed;P1=1;var e=Oi(),n=Gn(),i=e(n,"Set");return Ed=i,Ed}var Nd,O1;function wO(){if(O1)return Nd;O1=1;var e=Oi(),n=Gn(),i=e(n,"WeakMap");return Nd=i,Nd}var Cd,q1;function Os(){if(q1)return Cd;q1=1;var e=vO(),n=tv(),i=yO(),s=gN(),o=wO(),u=Pi(),l=sN(),c="[object Map]",d="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",x=l(e),N=l(n),_=l(i),S=l(s),b=l(o),k=u;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||i&&k(i.resolve())!=h||s&&k(new s)!=p||o&&k(new o)!=m)&&(k=function(E){var C=u(E),A=C==d?E.constructor:void 0,P=A?l(A):"";if(P)switch(P){case x:return y;case N:return c;case _:return h;case S:return p;case b:return m}return C}),Cd=k,Cd}var Td,L1;function xO(){if(L1)return Td;L1=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s){var o=s.length,u=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(u.index=s.index,u.input=s.input),u}return Td=i,Td}var Rd,$1;function vN(){if($1)return Rd;$1=1;var e=Gn(),n=e.Uint8Array;return Rd=n,Rd}var jd,D1;function lv(){if(D1)return jd;D1=1;var e=vN();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return jd=n,jd}var Ad,F1;function _O(){if(F1)return Ad;F1=1;var e=lv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Ad=n,Ad}var Id,z1;function SO(){if(z1)return Id;z1=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return Id=n,Id}var Md,B1;function bO(){if(B1)return Md;B1=1;var e=Ms(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Md=s,Md}var Pd,U1;function yN(){if(U1)return Pd;U1=1;var e=lv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Pd=n,Pd}var Od,H1;function kO(){if(H1)return Od;H1=1;var e=lv(),n=_O(),i=SO(),s=bO(),o=yN(),u="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",A="[object Uint8ClampedArray]",P="[object Uint16Array]",I="[object Uint32Array]";function M(R,L,F){var Q=R.constructor;switch(L){case x:return e(R);case u:case l:return new Q(+R);case N:return n(R,F);case _:case S:case b:case k:case E:case C:case A:case P:case I:return o(R,F);case c:return new Q;case d:case m:return new Q(R);case h:return i(R);case p:return new Q;case y:return s(R)}}return Od=M,Od}var qd,V1;function wN(){if(V1)return qd;V1=1;var e=An(),n=Object.create,i=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var u=new s;return s.prototype=void 0,u}})();return qd=i,qd}var Ld,W1;function xN(){if(W1)return Ld;W1=1;var e=wN(),n=Uu(),i=Bu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Ld=s,Ld}var $d,G1;function EO(){if(G1)return $d;G1=1;var e=Os(),n=rr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return $d=s,$d}var Dd,Y1;function NO(){if(Y1)return Dd;Y1=1;var e=EO(),n=zu(),i=sv(),s=i&&i.isMap,o=s?n(s):e;return Dd=o,Dd}var Fd,K1;function CO(){if(K1)return Fd;K1=1;var e=Os(),n=rr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Fd=s,Fd}var zd,X1;function TO(){if(X1)return zd;X1=1;var e=CO(),n=zu(),i=sv(),s=i&&i.isSet,o=s?n(s):e;return zd=o,zd}var Bd,Q1;function _N(){if(Q1)return Bd;Q1=1;var e=Lu(),n=rv(),i=Du(),s=cO(),o=hO(),u=lN(),l=cN(),c=pO(),d=mO(),h=mN(),p=gO(),m=Os(),y=xO(),x=kO(),N=xN(),_=yt(),S=Ps(),b=NO(),k=An(),E=TO(),C=ei(),A=qi(),P=1,I=2,M=4,R="[object Arguments]",L="[object Array]",F="[object Boolean]",Q="[object Date]",X="[object Error]",j="[object Function]",G="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",K="[object Object]",D="[object RegExp]",V="[object Set]",O="[object String]",B="[object Symbol]",ae="[object WeakMap]",z="[object ArrayBuffer]",W="[object DataView]",J="[object Float32Array]",se="[object Float64Array]",ue="[object Int8Array]",he="[object Int16Array]",ge="[object Int32Array]",Me="[object Uint8Array]",Fe="[object Uint8ClampedArray]",Re="[object Uint16Array]",Pe="[object Uint32Array]",be={};be[R]=be[L]=be[z]=be[W]=be[F]=be[Q]=be[J]=be[se]=be[ue]=be[he]=be[ge]=be[U]=be[ne]=be[K]=be[D]=be[V]=be[O]=be[B]=be[Me]=be[Fe]=be[Re]=be[Pe]=!0,be[X]=be[j]=be[ae]=!1;function Oe(ve,ye,qe,Ye,Qe,et){var Be,Ze=ye&P,At=ye&I,Vt=ye&M;if(qe&&(Be=Qe?qe(ve,Ye,Qe,et):qe(ve)),Be!==void 0)return Be;if(!k(ve))return ve;var It=_(ve);if(It){if(Be=y(ve),!Ze)return l(ve,Be)}else{var pt=m(ve),tt=pt==j||pt==G;if(S(ve))return u(ve,Ze);if(pt==K||pt==R||tt&&!Qe){if(Be=At||tt?{}:N(ve),!Ze)return At?d(ve,o(Be,ve)):c(ve,s(Be,ve))}else{if(!be[pt])return Qe?ve:{};Be=x(ve,pt,Ze)}}et||(et=new e);var kt=et.get(ve);if(kt)return kt;et.set(ve,Be),E(ve)?ve.forEach(function(Ge){Be.add(Oe(Ge,ye,qe,Ge,ve,et))}):b(ve)&&ve.forEach(function(Ge,ft){Be.set(ft,Oe(Ge,ye,qe,ft,ve,et))});var We=Vt?At?p:h:At?A:C,Et=It?void 0:We(ve);return n(Et||ve,function(Ge,ft){Et&&(ft=Ge,Ge=ve[ft]),i(Be,ft,Oe(Ge,ye,qe,ft,ve,et))}),Be}return Bd=Oe,Bd}var Ud,Z1;function RO(){if(Z1)return Ud;Z1=1;var e=_N(),n=4;function i(s){return e(s,n)}return Ud=i,Ud}var Hd,J1;function cv(){if(J1)return Hd;J1=1;function e(n){return function(){return n}}return Hd=e,Hd}var Vd,e_;function jO(){if(e_)return Vd;e_=1;function e(n){return function(i,s,o){for(var u=-1,l=Object(i),c=o(i),d=c.length;d--;){var h=c[n?d:++u];if(s(l[h],h,l)===!1)break}return i}}return Vd=e,Vd}var Wd,t_;function fv(){if(t_)return Wd;t_=1;var e=jO(),n=e();return Wd=n,Wd}var Gd,n_;function dv(){if(n_)return Gd;n_=1;var e=fv(),n=ei();function i(s,o){return s&&e(s,o,n)}return Gd=i,Gd}var Yd,r_;function AO(){if(r_)return Yd;r_=1;var e=wr();function n(i,s){return function(o,u){if(o==null)return o;if(!e(o))return i(o,u);for(var l=o.length,c=s?l:-1,d=Object(o);(s?c--:++c<l)&&u(d[c],c,d)!==!1;);return o}}return Yd=n,Yd}var Kd,i_;function Hu(){if(i_)return Kd;i_=1;var e=dv(),n=AO(),i=n(e);return Kd=i,Kd}var Xd,s_;function Li(){if(s_)return Xd;s_=1;function e(n){return n}return Xd=e,Xd}var Qd,o_;function SN(){if(o_)return Qd;o_=1;var e=Li();function n(i){return typeof i=="function"?i:e}return Qd=n,Qd}var Zd,a_;function bN(){if(a_)return Zd;a_=1;var e=rv(),n=Hu(),i=SN(),s=yt();function o(u,l){var c=s(u)?e:n;return c(u,i(l))}return Zd=o,Zd}var Jd,u_;function kN(){return u_||(u_=1,Jd=bN()),Jd}var eh,l_;function IO(){if(l_)return eh;l_=1;var e=Hu();function n(i,s){var o=[];return e(i,function(u,l,c){s(u,l,c)&&o.push(u)}),o}return eh=n,eh}var th,c_;function MO(){if(c_)return th;c_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return th=n,th}var nh,f_;function PO(){if(f_)return nh;f_=1;function e(n){return this.__data__.has(n)}return nh=e,nh}var rh,d_;function EN(){if(d_)return rh;d_=1;var e=nv(),n=MO(),i=PO();function s(o){var u=-1,l=o==null?0:o.length;for(this.__data__=new e;++u<l;)this.add(o[u])}return s.prototype.add=s.prototype.push=n,s.prototype.has=i,rh=s,rh}var ih,h_;function OO(){if(h_)return ih;h_=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 ih=e,ih}var sh,p_;function NN(){if(p_)return sh;p_=1;function e(n,i){return n.has(i)}return sh=e,sh}var oh,m_;function CN(){if(m_)return oh;m_=1;var e=EN(),n=OO(),i=NN(),s=1,o=2;function u(l,c,d,h,p,m){var y=d&s,x=l.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=m.get(l),S=m.get(c);if(_&&S)return _==c&&S==l;var b=-1,k=!0,E=d&o?new e:void 0;for(m.set(l,c),m.set(c,l);++b<x;){var C=l[b],A=c[b];if(h)var P=y?h(A,C,b,c,l,m):h(C,A,b,l,c,m);if(P!==void 0){if(P)continue;k=!1;break}if(E){if(!n(c,function(I,M){if(!i(E,M)&&(C===I||p(C,I,d,h,m)))return E.push(M)})){k=!1;break}}else if(!(C===A||p(C,A,d,h,m))){k=!1;break}}return m.delete(l),m.delete(c),k}return oh=u,oh}var ah,g_;function qO(){if(g_)return ah;g_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,u){s[++i]=[u,o]}),s}return ah=e,ah}var uh,v_;function hv(){if(v_)return uh;v_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return uh=e,uh}var lh,y_;function LO(){if(y_)return lh;y_=1;var e=Ms(),n=vN(),i=Is(),s=CN(),o=qO(),u=hv(),l=1,c=2,d="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function A(P,I,M,R,L,F,Q){switch(M){case k:if(P.byteLength!=I.byteLength||P.byteOffset!=I.byteOffset)return!1;P=P.buffer,I=I.buffer;case b:return!(P.byteLength!=I.byteLength||!F(new n(P),new n(I)));case d:case h:case y:return i(+P,+I);case p:return P.name==I.name&&P.message==I.message;case x:case _:return P==I+"";case m:var X=o;case N:var j=R&l;if(X||(X=u),P.size!=I.size&&!j)return!1;var G=Q.get(P);if(G)return G==I;R|=c,Q.set(P,I);var U=s(X(P),X(I),R,L,F,Q);return Q.delete(P),U;case S:if(C)return C.call(P)==C.call(I)}return!1}return lh=A,lh}var ch,w_;function $O(){if(w_)return ch;w_=1;var e=mN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(u,l,c,d,h,p){var m=c&n,y=e(u),x=y.length,N=e(l),_=N.length;if(x!=_&&!m)return!1;for(var S=x;S--;){var b=y[S];if(!(m?b in l:s.call(l,b)))return!1}var k=p.get(u),E=p.get(l);if(k&&E)return k==l&&E==u;var C=!0;p.set(u,l),p.set(l,u);for(var A=m;++S<x;){b=y[S];var P=u[b],I=l[b];if(d)var M=m?d(I,P,b,l,u,p):d(P,I,b,u,l,p);if(!(M===void 0?P===I||h(P,I,c,d,p):M)){C=!1;break}A||(A=b=="constructor")}if(C&&!A){var R=u.constructor,L=l.constructor;R!=L&&"constructor"in u&&"constructor"in l&&!(typeof R=="function"&&R instanceof R&&typeof L=="function"&&L instanceof L)&&(C=!1)}return p.delete(u),p.delete(l),C}return ch=o,ch}var fh,x_;function DO(){if(x_)return fh;x_=1;var e=Lu(),n=CN(),i=LO(),s=$O(),o=Os(),u=yt(),l=Ps(),c=Wo(),d=1,h="[object Arguments]",p="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,k,E,C){var A=u(_),P=u(S),I=A?p:o(_),M=P?p:o(S);I=I==h?m:I,M=M==h?m:M;var R=I==m,L=M==m,F=I==M;if(F&&l(_)){if(!l(S))return!1;A=!0,R=!1}if(F&&!R)return C||(C=new e),A||c(_)?n(_,S,b,k,E,C):i(_,S,I,b,k,E,C);if(!(b&d)){var Q=R&&x.call(_,"__wrapped__"),X=L&&x.call(S,"__wrapped__");if(Q||X){var j=Q?_.value():_,G=X?S.value():S;return C||(C=new e),E(j,G,b,k,C)}}return F?(C||(C=new e),s(_,S,b,k,E,C)):!1}return fh=N,fh}var dh,__;function TN(){if(__)return dh;__=1;var e=DO(),n=rr();function i(s,o,u,l,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,u,l,i,c)}return dh=i,dh}var hh,S_;function FO(){if(S_)return hh;S_=1;var e=Lu(),n=TN(),i=1,s=2;function o(u,l,c,d){var h=c.length,p=h,m=!d;if(u==null)return!p;for(u=Object(u);h--;){var y=c[h];if(m&&y[2]?y[1]!==u[y[0]]:!(y[0]in u))return!1}for(;++h<p;){y=c[h];var x=y[0],N=u[x],_=y[1];if(m&&y[2]){if(N===void 0&&!(x in u))return!1}else{var S=new e;if(d)var b=d(N,_,x,u,l,S);if(!(b===void 0?n(_,N,i|s,d,S):b))return!1}}return!0}return hh=o,hh}var ph,b_;function RN(){if(b_)return ph;b_=1;var e=An();function n(i){return i===i&&!e(i)}return ph=n,ph}var mh,k_;function zO(){if(k_)return mh;k_=1;var e=RN(),n=ei();function i(s){for(var o=n(s),u=o.length;u--;){var l=o[u],c=s[l];o[u]=[l,c,e(c)]}return o}return mh=i,mh}var gh,E_;function jN(){if(E_)return gh;E_=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return gh=e,gh}var vh,N_;function BO(){if(N_)return vh;N_=1;var e=FO(),n=zO(),i=jN();function s(o){var u=n(o);return u.length==1&&u[0][2]?i(u[0][0],u[0][1]):function(l){return l===o||e(l,o,u)}}return vh=s,vh}var yh,C_;function qs(){if(C_)return yh;C_=1;var e=Pi(),n=rr(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return yh=s,yh}var wh,T_;function pv(){if(T_)return wh;T_=1;var e=yt(),n=qs(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(u,l){if(e(u))return!1;var c=typeof u;return c=="number"||c=="symbol"||c=="boolean"||u==null||n(u)?!0:s.test(u)||!i.test(u)||l!=null&&u in Object(l)}return wh=o,wh}var xh,R_;function UO(){if(R_)return xh;R_=1;var e=nv(),n="Expected a function";function i(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var u=function(){var l=arguments,c=o?o.apply(this,l):l[0],d=u.cache;if(d.has(c))return d.get(c);var h=s.apply(this,l);return u.cache=d.set(c,h)||d,h};return u.cache=new(i.Cache||e),u}return i.Cache=e,xh=i,xh}var _h,j_;function HO(){if(j_)return _h;j_=1;var e=UO(),n=500;function i(s){var o=e(s,function(l){return u.size===n&&u.clear(),l}),u=o.cache;return o}return _h=i,_h}var Sh,A_;function VO(){if(A_)return Sh;A_=1;var e=HO(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=e(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(n,function(l,c,d,h){u.push(d?h.replace(i,"$1"):c||l)}),u});return Sh=s,Sh}var bh,I_;function Vu(){if(I_)return bh;I_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,u=Array(o);++s<o;)u[s]=i(n[s],s,n);return u}return bh=e,bh}var kh,M_;function WO(){if(M_)return kh;M_=1;var e=Ms(),n=Vu(),i=yt(),s=qs(),o=e?e.prototype:void 0,u=o?o.toString:void 0;function l(c){if(typeof c=="string")return c;if(i(c))return n(c,l)+"";if(s(c))return u?u.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return kh=l,kh}var Eh,P_;function AN(){if(P_)return Eh;P_=1;var e=WO();function n(i){return i==null?"":e(i)}return Eh=n,Eh}var Nh,O_;function Wu(){if(O_)return Nh;O_=1;var e=yt(),n=pv(),i=VO(),s=AN();function o(u,l){return e(u)?u:n(u,l)?[u]:i(s(u))}return Nh=o,Nh}var Ch,q_;function Go(){if(q_)return Ch;q_=1;var e=qs();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Ch=n,Ch}var Th,L_;function Gu(){if(L_)return Th;L_=1;var e=Wu(),n=Go();function i(s,o){o=e(o,s);for(var u=0,l=o.length;s!=null&&u<l;)s=s[n(o[u++])];return u&&u==l?s:void 0}return Th=i,Th}var Rh,$_;function GO(){if($_)return Rh;$_=1;var e=Gu();function n(i,s,o){var u=i==null?void 0:e(i,s);return u===void 0?o:u}return Rh=n,Rh}var jh,D_;function YO(){if(D_)return jh;D_=1;function e(n,i){return n!=null&&i in Object(n)}return jh=e,jh}var Ah,F_;function IN(){if(F_)return Ah;F_=1;var e=Wu(),n=Vo(),i=yt(),s=Fu(),o=iv(),u=Go();function l(c,d,h){d=e(d,c);for(var p=-1,m=d.length,y=!1;++p<m;){var x=u(d[p]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++p!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(x,m)&&(i(c)||n(c)))}return Ah=l,Ah}var Ih,z_;function MN(){if(z_)return Ih;z_=1;var e=YO(),n=IN();function i(s,o){return s!=null&&n(s,o,e)}return Ih=i,Ih}var Mh,B_;function KO(){if(B_)return Mh;B_=1;var e=TN(),n=GO(),i=MN(),s=pv(),o=RN(),u=jN(),l=Go(),c=1,d=2;function h(p,m){return s(p)&&o(m)?u(l(p),m):function(y){var x=n(y,p);return x===void 0&&x===m?i(y,p):e(m,x,c|d)}}return Mh=h,Mh}var Ph,U_;function PN(){if(U_)return Ph;U_=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Ph=e,Ph}var Oh,H_;function XO(){if(H_)return Oh;H_=1;var e=Gu();function n(i){return function(s){return e(s,i)}}return Oh=n,Oh}var qh,V_;function QO(){if(V_)return qh;V_=1;var e=PN(),n=XO(),i=pv(),s=Go();function o(u){return i(u)?e(s(u)):n(u)}return qh=o,qh}var Lh,W_;function xr(){if(W_)return Lh;W_=1;var e=BO(),n=KO(),i=Li(),s=yt(),o=QO();function u(l){return typeof l=="function"?l:l==null?i:typeof l=="object"?s(l)?n(l[0],l[1]):e(l):o(l)}return Lh=u,Lh}var $h,G_;function ON(){if(G_)return $h;G_=1;var e=fN(),n=IO(),i=xr(),s=yt();function o(u,l){var c=s(u)?e:n;return c(u,i(l,3))}return $h=o,$h}var Dh,Y_;function ZO(){if(Y_)return Dh;Y_=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return Dh=i,Dh}var Fh,K_;function qN(){if(K_)return Fh;K_=1;var e=ZO(),n=IN();function i(s,o){return s!=null&&n(s,o,e)}return Fh=i,Fh}var zh,X_;function JO(){if(X_)return zh;X_=1;var e=ov(),n=Os(),i=Vo(),s=yt(),o=wr(),u=Ps(),l=Bu(),c=Wo(),d="[object Map]",h="[object Set]",p=Object.prototype,m=p.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||u(x)||c(x)||i(x)))return!x.length;var N=n(x);if(N==d||N==h)return!x.size;if(l(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return zh=y,zh}var Bh,Q_;function LN(){if(Q_)return Bh;Q_=1;function e(n){return n===void 0}return Bh=e,Bh}var Uh,Z_;function $N(){if(Z_)return Uh;Z_=1;var e=Hu(),n=wr();function i(s,o){var u=-1,l=n(s)?Array(s.length):[];return e(s,function(c,d,h){l[++u]=o(c,d,h)}),l}return Uh=i,Uh}var Hh,J_;function DN(){if(J_)return Hh;J_=1;var e=Vu(),n=xr(),i=$N(),s=yt();function o(u,l){var c=s(u)?e:i;return c(u,n(l,3))}return Hh=o,Hh}var Vh,eS;function eq(){if(eS)return Vh;eS=1;function e(n,i,s,o){var u=-1,l=n==null?0:n.length;for(o&&l&&(s=n[++u]);++u<l;)s=i(s,n[u],u,n);return s}return Vh=e,Vh}var Wh,tS;function tq(){if(tS)return Wh;tS=1;function e(n,i,s,o,u){return u(n,function(l,c,d){s=o?(o=!1,l):i(s,l,c,d)}),s}return Wh=e,Wh}var Gh,nS;function FN(){if(nS)return Gh;nS=1;var e=eq(),n=Hu(),i=xr(),s=tq(),o=yt();function u(l,c,d){var h=o(l)?e:s,p=arguments.length<3;return h(l,i(c,4),d,p,n)}return Gh=u,Gh}var Yh,rS;function nq(){if(rS)return Yh;rS=1;var e=Pi(),n=yt(),i=rr(),s="[object String]";function o(u){return typeof u=="string"||!n(u)&&i(u)&&e(u)==s}return Yh=o,Yh}var Kh,iS;function rq(){if(iS)return Kh;iS=1;var e=PN(),n=e("length");return Kh=n,Kh}var Xh,sS;function iq(){if(sS)return Xh;sS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,u="\\ufe0e\\ufe0f",l="\\u200d",c=RegExp("["+l+e+o+u+"]");function d(h){return c.test(h)}return Xh=d,Xh}var Qh,oS;function sq(){if(oS)return Qh;oS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,u="\\ufe0e\\ufe0f",l="["+e+"]",c="["+o+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",p="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+u+"]?",S="(?:"+x+"(?:"+[p,m,y].join("|")+")"+_+N+")*",b=_+N+S,k="(?:"+[p+c+"?",c,m,y,l].join("|")+")",E=RegExp(d+"(?="+d+")|"+k+b,"g");function C(A){for(var P=E.lastIndex=0;E.test(A);)++P;return P}return Qh=C,Qh}var Zh,aS;function oq(){if(aS)return Zh;aS=1;var e=rq(),n=iq(),i=sq();function s(o){return n(o)?i(o):e(o)}return Zh=s,Zh}var Jh,uS;function aq(){if(uS)return Jh;uS=1;var e=ov(),n=Os(),i=wr(),s=nq(),o=oq(),u="[object Map]",l="[object Set]";function c(d){if(d==null)return 0;if(i(d))return s(d)?o(d):d.length;var h=n(d);return h==u||h==l?d.size:e(d).length}return Jh=c,Jh}var ep,lS;function uq(){if(lS)return ep;lS=1;var e=rv(),n=wN(),i=dv(),s=xr(),o=Uu(),u=yt(),l=Ps(),c=Uo(),d=An(),h=Wo();function p(m,y,x){var N=u(m),_=N||l(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=N?new S:[]:d(m)?x=c(S)?n(o(m)):{}:x={}}return(_?e:i)(m,function(b,k,E){return y(x,b,k,E)}),x}return ep=p,ep}var tp,cS;function lq(){if(cS)return tp;cS=1;var e=Ms(),n=Vo(),i=yt(),s=e?e.isConcatSpreadable:void 0;function o(u){return i(u)||n(u)||!!(s&&u&&u[s])}return tp=o,tp}var np,fS;function mv(){if(fS)return np;fS=1;var e=uv(),n=lq();function i(s,o,u,l,c){var d=-1,h=s.length;for(u||(u=n),c||(c=[]);++d<h;){var p=s[d];o>0&&u(p)?o>1?i(p,o-1,u,l,c):e(c,p):l||(c[c.length]=p)}return c}return np=i,np}var rp,dS;function cq(){if(dS)return rp;dS=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 rp=e,rp}var ip,hS;function zN(){if(hS)return ip;hS=1;var e=cq(),n=Math.max;function i(s,o,u){return o=n(o===void 0?s.length-1:o,0),function(){for(var l=arguments,c=-1,d=n(l.length-o,0),h=Array(d);++c<d;)h[c]=l[o+c];c=-1;for(var p=Array(o+1);++c<o;)p[c]=l[c];return p[o]=u(h),e(s,this,p)}}return ip=i,ip}var sp,pS;function fq(){if(pS)return sp;pS=1;var e=cv(),n=oN(),i=Li(),s=n?function(o,u){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(u),writable:!0})}:i;return sp=s,sp}var op,mS;function dq(){if(mS)return op;mS=1;var e=800,n=16,i=Date.now;function s(o){var u=0,l=0;return function(){var c=i(),d=n-(c-l);if(l=c,d>0){if(++u>=e)return arguments[0]}else u=0;return o.apply(void 0,arguments)}}return op=s,op}var ap,gS;function BN(){if(gS)return ap;gS=1;var e=fq(),n=dq(),i=n(e);return ap=i,ap}var up,vS;function Yu(){if(vS)return up;vS=1;var e=Li(),n=zN(),i=BN();function s(o,u){return i(n(o,u,e),o+"")}return up=s,up}var lp,yS;function UN(){if(yS)return lp;yS=1;function e(n,i,s,o){for(var u=n.length,l=s+(o?1:-1);o?l--:++l<u;)if(i(n[l],l,n))return l;return-1}return lp=e,lp}var cp,wS;function hq(){if(wS)return cp;wS=1;function e(n){return n!==n}return cp=e,cp}var fp,xS;function pq(){if(xS)return fp;xS=1;function e(n,i,s){for(var o=s-1,u=n.length;++o<u;)if(n[o]===i)return o;return-1}return fp=e,fp}var dp,_S;function mq(){if(_S)return dp;_S=1;var e=UN(),n=hq(),i=pq();function s(o,u,l){return u===u?i(o,u,l):e(o,n,l)}return dp=s,dp}var hp,SS;function gq(){if(SS)return hp;SS=1;var e=mq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return hp=n,hp}var pp,bS;function vq(){if(bS)return pp;bS=1;function e(n,i,s){for(var o=-1,u=n==null?0:n.length;++o<u;)if(s(i,n[o]))return!0;return!1}return pp=e,pp}var mp,kS;function yq(){if(kS)return mp;kS=1;function e(){}return mp=e,mp}var gp,ES;function wq(){if(ES)return gp;ES=1;var e=gN(),n=yq(),i=hv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(u){return new e(u)}:n;return gp=o,gp}var vp,NS;function xq(){if(NS)return vp;NS=1;var e=EN(),n=gq(),i=vq(),s=NN(),o=wq(),u=hv(),l=200;function c(d,h,p){var m=-1,y=n,x=d.length,N=!0,_=[],S=_;if(p)N=!1,y=i;else if(x>=l){var b=h?null:o(d);if(b)return u(b);N=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<x;){var k=d[m],E=h?h(k):k;if(k=p||k!==0?k:0,N&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;h&&S.push(E),_.push(k)}else y(S,E,p)||(S!==_&&S.push(E),_.push(k))}return _}return vp=c,vp}var yp,CS;function HN(){if(CS)return yp;CS=1;var e=wr(),n=rr();function i(s){return n(s)&&e(s)}return yp=i,yp}var wp,TS;function _q(){if(TS)return wp;TS=1;var e=mv(),n=Yu(),i=xq(),s=HN(),o=n(function(u){return i(e(u,1,s,!0))});return wp=o,wp}var xp,RS;function Sq(){if(RS)return xp;RS=1;var e=Vu();function n(i,s){return e(s,function(o){return i[o]})}return xp=n,xp}var _p,jS;function VN(){if(jS)return _p;jS=1;var e=Sq(),n=ei();function i(s){return s==null?[]:e(s,n(s))}return _p=i,_p}var Sp,AS;function In(){if(AS)return Sp;AS=1;var e;if(typeof ev=="function")try{e={clone:RO(),constant:cv(),each:kN(),filter:ON(),has:qN(),isArray:yt(),isEmpty:JO(),isFunction:Uo(),isUndefined:LN(),keys:ei(),map:DN(),reduce:FN(),size:aq(),transform:uq(),union:_q(),values:VN()}}catch{}return e||(e=window._),Sp=e,Sp}var bp,IS;function gv(){if(IS)return bp;IS=1;var e=In();bp=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,x=this;return e.each(p,function(N){y.length>1?x.setNode(N,m):x.setNode(N)}),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(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[p],this._isCompound&&(this._removeFromParentsChildList(p),delete this._parent[p],e.each(this.children(p),function(x){m.setParent(x)}),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 x={};function N(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),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,x=arguments;return e.reduce(p,function(N,_){return x.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var p,m,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!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 N&&(this._edgeLabels[S]=x),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]=N?x:this._defaultEdgeLabelFn(p,m,y);var b=d(this._isDirected,p,m,y);return p=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,u(this._preds[m],p),u(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 x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y),N=this._edgeObjs[x];return N&&(p=N.v,m=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],l(this._preds[m],p),l(this._sucs[p],m),delete this._in[m][x],delete this._out[p][x],this._edgeCount--),this},o.prototype.inEdges=function(p,m){var y=this._in[p];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.v===m}):x}},o.prototype.outEdges=function(p,m){var y=this._out[p];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.w===m}):x}},o.prototype.nodeEdges=function(p,m){var y=this.inEdges(p,m);if(y)return y.concat(this.outEdges(p,m))};function u(p,m){p[m]?p[m]++:p[m]=1}function l(p,m){--p[m]||delete p[m]}function c(p,m,y,x){var N=""+m,_=""+y;if(!p&&N>_){var S=N;N=_,_=S}return N+s+_+s+(e.isUndefined(x)?n:x)}function d(p,m,y,x){var N=""+m,_=""+y;if(!p&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function h(p,m){return c(p,m.v,m.w,m.name)}return bp}var kp,MS;function bq(){return MS||(MS=1,kp="2.1.8"),kp}var Ep,PS;function kq(){return PS||(PS=1,Ep={Graph:gv(),version:bq()}),Ep}var Np,OS;function Eq(){if(OS)return Np;OS=1;var e=In(),n=gv();Np={write:i,read:u};function i(l){var c={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:s(l),edges:o(l)};return e.isUndefined(l.graph())||(c.value=e.clone(l.graph())),c}function s(l){return e.map(l.nodes(),function(c){var d=l.node(c),h=l.parent(c),p={v:c};return e.isUndefined(d)||(p.value=d),e.isUndefined(h)||(p.parent=h),p})}function o(l){return e.map(l.edges(),function(c){var d=l.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(d)||(h.value=d),h})}function u(l){var c=new n(l.options).setGraph(l.value);return e.each(l.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(l.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return Np}var Cp,qS;function Nq(){if(qS)return Cp;qS=1;var e=In();Cp=n;function n(i){var s={},o=[],u;function l(c){e.has(s,c)||(s[c]=!0,u.push(c),e.each(i.successors(c),l),e.each(i.predecessors(c),l))}return e.each(i.nodes(),function(c){u=[],l(c),u.length&&o.push(u)}),o}return Cp}var Tp,LS;function WN(){if(LS)return Tp;LS=1;var e=In();Tp=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 u=this._arr,l=u.length;return o[i]=l,u.push({key:i,priority:s}),this._decrease(l),!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,u=o+1,l=i;o<s.length&&(l=s[o].priority<s[l].priority?o:l,u<s.length&&(l=s[u].priority<s[l].priority?u:l),l!==i&&(this._swap(i,l),this._heapify(l)))},n.prototype._decrease=function(i){for(var s=this._arr,o=s[i].priority,u;i!==0&&(u=i>>1,!(s[u].priority<o));)this._swap(i,u),i=u},n.prototype._swap=function(i,s){var o=this._arr,u=this._keyIndices,l=o[i],c=o[s];o[i]=c,o[s]=l,u[c.key]=i,u[l.key]=s},Tp}var Rp,$S;function GN(){if($S)return Rp;$S=1;var e=In(),n=WN();Rp=s;var i=e.constant(1);function s(u,l,c,d){return o(u,String(l),c||i,d||function(h){return u.outEdges(h)})}function o(u,l,c,d){var h={},p=new n,m,y,x=function(N){var _=N.v!==m?N.v:N.w,S=h[_],b=c(N),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=m,p.decrease(_,k))};for(u.nodes().forEach(function(N){var _=N===l?0:Number.POSITIVE_INFINITY;h[N]={distance:_},p.add(N,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)d(m).forEach(x);return h}return Rp}var jp,DS;function Cq(){if(DS)return jp;DS=1;var e=GN(),n=In();jp=i;function i(s,o,u){return n.transform(s.nodes(),function(l,c){l[c]=e(s,c,o,u)},{})}return jp}var Ap,FS;function YN(){if(FS)return Ap;FS=1;var e=In();Ap=n;function n(i){var s=0,o=[],u={},l=[];function c(d){var h=u[d]={onStack:!0,lowlink:s,index:s++};if(o.push(d),i.successors(d).forEach(function(y){e.has(u,y)?u[y].onStack&&(h.lowlink=Math.min(h.lowlink,u[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,u[y].lowlink))}),h.lowlink===h.index){var p=[],m;do m=o.pop(),u[m].onStack=!1,p.push(m);while(d!==m);l.push(p)}}return i.nodes().forEach(function(d){e.has(u,d)||c(d)}),l}return Ap}var Ip,zS;function Tq(){if(zS)return Ip;zS=1;var e=In(),n=YN();Ip=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 Ip}var Mp,BS;function Rq(){if(BS)return Mp;BS=1;var e=In();Mp=i;var n=e.constant(1);function i(o,u,l){return s(o,u||n,l||function(c){return o.outEdges(c)})}function s(o,u,l){var c={},d=o.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(p){h!==p&&(c[h][p]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(p){var m=p.v===h?p.w:p.v,y=u(p);c[h][m]={distance:y,predecessor:h}})}),d.forEach(function(h){var p=c[h];d.forEach(function(m){var y=c[m];d.forEach(function(x){var N=y[h],_=p[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Mp}var Pp,US;function KN(){if(US)return Pp;US=1;var e=In();Pp=n,n.CycleException=i;function n(s){var o={},u={},l=[];function c(d){if(e.has(u,d))throw new i;e.has(o,d)||(u[d]=!0,o[d]=!0,e.each(s.predecessors(d),c),delete u[d],l.push(d))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new i;return l}function i(){}return i.prototype=new Error,Pp}var Op,HS;function jq(){if(HS)return Op;HS=1;var e=KN();Op=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Op}var qp,VS;function XN(){if(VS)return qp;VS=1;var e=In();qp=n;function n(s,o,u){e.isArray(o)||(o=[o]);var l=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],d={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);i(s,h,u==="post",d,l,c)}),c}function i(s,o,u,l,c,d){e.has(l,o)||(l[o]=!0,u||d.push(o),e.each(c(o),function(h){i(s,h,u,l,c,d)}),u&&d.push(o))}return qp}var Lp,WS;function Aq(){if(WS)return Lp;WS=1;var e=XN();Lp=n;function n(i,s){return e(i,s,"post")}return Lp}var $p,GS;function Iq(){if(GS)return $p;GS=1;var e=XN();$p=n;function n(i,s){return e(i,s,"pre")}return $p}var Dp,YS;function Mq(){if(YS)return Dp;YS=1;var e=In(),n=gv(),i=WN();Dp=s;function s(o,u){var l=new n,c={},d=new i,h;function p(y){var x=y.v===h?y.w:y.v,N=d.priority(x);if(N!==void 0){var _=u(y);_<N&&(c[x]=h,d.decrease(x,_))}}if(o.nodeCount()===0)return l;e.each(o.nodes(),function(y){d.add(y,Number.POSITIVE_INFINITY),l.setNode(y)}),d.decrease(o.nodes()[0],0);for(var m=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))l.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(p)}return l}return Dp}var Fp,KS;function Pq(){return KS||(KS=1,Fp={components:Nq(),dijkstra:GN(),dijkstraAll:Cq(),findCycles:Tq(),floydWarshall:Rq(),isAcyclic:jq(),postorder:Aq(),preorder:Iq(),prim:Mq(),tarjan:YN(),topsort:KN()}),Fp}var zp,XS;function Oq(){if(XS)return zp;XS=1;var e=kq();return zp={Graph:e.Graph,json:Eq(),alg:Pq(),version:e.version},zp}var Bp,QS;function Vn(){if(QS)return Bp;QS=1;var e;if(typeof ev=="function")try{e=Oq()}catch{}return e||(e=window.graphlib),Bp=e,Bp}var Up,ZS;function qq(){if(ZS)return Up;ZS=1;var e=_N(),n=1,i=4;function s(o){return e(o,n|i)}return Up=s,Up}var Hp,JS;function Ku(){if(JS)return Hp;JS=1;var e=Is(),n=wr(),i=Fu(),s=An();function o(u,l,c){if(!s(c))return!1;var d=typeof l;return(d=="number"?n(c)&&i(l,c.length):d=="string"&&l in c)?e(c[l],u):!1}return Hp=o,Hp}var Vp,eb;function Lq(){if(eb)return Vp;eb=1;var e=Yu(),n=Is(),i=Ku(),s=qi(),o=Object.prototype,u=o.hasOwnProperty,l=e(function(c,d){c=Object(c);var h=-1,p=d.length,m=p>2?d[2]:void 0;for(m&&i(d[0],d[1],m)&&(p=1);++h<p;)for(var y=d[h],x=s(y),N=-1,_=x.length;++N<_;){var S=x[N],b=c[S];(b===void 0||n(b,o[S])&&!u.call(c,S))&&(c[S]=y[S])}return c});return Vp=l,Vp}var Wp,tb;function $q(){if(tb)return Wp;tb=1;var e=xr(),n=wr(),i=ei();function s(o){return function(u,l,c){var d=Object(u);if(!n(u)){var h=e(l,3);u=i(u),l=function(m){return h(d[m],m,d)}}var p=o(u,l,c);return p>-1?d[h?u[p]:p]:void 0}}return Wp=s,Wp}var Gp,nb;function Dq(){if(nb)return Gp;nb=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return Gp=n,Gp}var Yp,rb;function Fq(){if(rb)return Yp;rb=1;var e=Dq(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return Yp=i,Yp}var Kp,ib;function zq(){if(ib)return Kp;ib=1;var e=Fq(),n=An(),i=qs(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;function d(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=u.test(h);return m||l.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return Kp=d,Kp}var Xp,sb;function QN(){if(sb)return Xp;sb=1;var e=zq(),n=1/0,i=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var u=o<0?-1:1;return u*i}return o===o?o:0}return Xp=s,Xp}var Qp,ob;function Bq(){if(ob)return Qp;ob=1;var e=QN();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return Qp=n,Qp}var Zp,ab;function Uq(){if(ab)return Zp;ab=1;var e=UN(),n=xr(),i=Bq(),s=Math.max;function o(u,l,c){var d=u==null?0:u.length;if(!d)return-1;var h=c==null?0:i(c);return h<0&&(h=s(d+h,0)),e(u,n(l,3),h)}return Zp=o,Zp}var Jp,ub;function Hq(){if(ub)return Jp;ub=1;var e=$q(),n=Uq(),i=e(n);return Jp=i,Jp}var em,lb;function ZN(){if(lb)return em;lb=1;var e=mv();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return em=n,em}var tm,cb;function Vq(){if(cb)return tm;cb=1;var e=fv(),n=SN(),i=qi();function s(o,u){return o==null?o:e(o,n(u),i)}return tm=s,tm}var nm,fb;function Wq(){if(fb)return nm;fb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return nm=e,nm}var rm,db;function Gq(){if(db)return rm;db=1;var e=$u(),n=dv(),i=xr();function s(o,u){var l={};return u=i(u,3),n(o,function(c,d,h){e(l,d,u(c,d,h))}),l}return rm=s,rm}var im,hb;function vv(){if(hb)return im;hb=1;var e=qs();function n(i,s,o){for(var u=-1,l=i.length;++u<l;){var c=i[u],d=s(c);if(d!=null&&(h===void 0?d===d&&!e(d):o(d,h)))var h=d,p=c}return p}return im=n,im}var sm,pb;function Yq(){if(pb)return sm;pb=1;function e(n,i){return n>i}return sm=e,sm}var om,mb;function Kq(){if(mb)return om;mb=1;var e=vv(),n=Yq(),i=Li();function s(o){return o&&o.length?e(o,i,n):void 0}return om=s,om}var am,gb;function JN(){if(gb)return am;gb=1;var e=$u(),n=Is();function i(s,o,u){(u!==void 0&&!n(s[o],u)||u===void 0&&!(o in s))&&e(s,o,u)}return am=i,am}var um,vb;function Xq(){if(vb)return um;vb=1;var e=Pi(),n=Uu(),i=rr(),s="[object Object]",o=Function.prototype,u=Object.prototype,l=o.toString,c=u.hasOwnProperty,d=l.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&&l.call(y)==d}return um=h,um}var lm,yb;function eC(){if(yb)return lm;yb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return lm=e,lm}var cm,wb;function Qq(){if(wb)return cm;wb=1;var e=Ho(),n=qi();function i(s){return e(s,n(s))}return cm=i,cm}var fm,xb;function Zq(){if(xb)return fm;xb=1;var e=JN(),n=lN(),i=yN(),s=cN(),o=xN(),u=Vo(),l=yt(),c=HN(),d=Ps(),h=Uo(),p=An(),m=Xq(),y=Wo(),x=eC(),N=Qq();function _(S,b,k,E,C,A,P){var I=x(S,k),M=x(b,k),R=P.get(M);if(R){e(S,k,R);return}var L=A?A(I,M,k+"",S,b,P):void 0,F=L===void 0;if(F){var Q=l(M),X=!Q&&d(M),j=!Q&&!X&&y(M);L=M,Q||X||j?l(I)?L=I:c(I)?L=s(I):X?(F=!1,L=n(M,!0)):j?(F=!1,L=i(M,!0)):L=[]:m(M)||u(M)?(L=I,u(I)?L=N(I):(!p(I)||h(I))&&(L=o(M))):F=!1}F&&(P.set(M,L),C(L,M,E,A,P),P.delete(M)),e(S,k,L)}return fm=_,fm}var dm,_b;function Jq(){if(_b)return dm;_b=1;var e=Lu(),n=JN(),i=fv(),s=Zq(),o=An(),u=qi(),l=eC();function c(d,h,p,m,y){d!==h&&i(h,function(x,N){if(y||(y=new e),o(x))s(d,h,N,p,c,m,y);else{var _=m?m(l(d,N),x,N+"",d,h,y):void 0;_===void 0&&(_=x),n(d,N,_)}},u)}return dm=c,dm}var hm,Sb;function eL(){if(Sb)return hm;Sb=1;var e=Yu(),n=Ku();function i(s){return e(function(o,u){var l=-1,c=u.length,d=c>1?u[c-1]:void 0,h=c>2?u[2]:void 0;for(d=s.length>3&&typeof d=="function"?(c--,d):void 0,h&&n(u[0],u[1],h)&&(d=c<3?void 0:d,c=1),o=Object(o);++l<c;){var p=u[l];p&&s(o,p,l,d)}return o})}return hm=i,hm}var pm,bb;function tL(){if(bb)return pm;bb=1;var e=Jq(),n=eL(),i=n(function(s,o,u){e(s,o,u)});return pm=i,pm}var mm,kb;function tC(){if(kb)return mm;kb=1;function e(n,i){return n<i}return mm=e,mm}var gm,Eb;function nL(){if(Eb)return gm;Eb=1;var e=vv(),n=tC(),i=Li();function s(o){return o&&o.length?e(o,i,n):void 0}return gm=s,gm}var vm,Nb;function rL(){if(Nb)return vm;Nb=1;var e=vv(),n=xr(),i=tC();function s(o,u){return o&&o.length?e(o,n(u,2),i):void 0}return vm=s,vm}var ym,Cb;function iL(){if(Cb)return ym;Cb=1;var e=Gn(),n=function(){return e.Date.now()};return ym=n,ym}var wm,Tb;function sL(){if(Tb)return wm;Tb=1;var e=Du(),n=Wu(),i=Fu(),s=An(),o=Go();function u(l,c,d,h){if(!s(l))return l;c=n(c,l);for(var p=-1,m=c.length,y=m-1,x=l;x!=null&&++p<m;){var N=o(c[p]),_=d;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(p!=y){var S=x[N];_=h?h(S,N,x):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(x,N,_),x=x[N]}return l}return wm=u,wm}var xm,Rb;function oL(){if(Rb)return xm;Rb=1;var e=Gu(),n=sL(),i=Wu();function s(o,u,l){for(var c=-1,d=u.length,h={};++c<d;){var p=u[c],m=e(o,p);l(m,p)&&n(h,i(p,o),m)}return h}return xm=s,xm}var _m,jb;function aL(){if(jb)return _m;jb=1;var e=oL(),n=MN();function i(s,o){return e(s,o,function(u,l){return n(s,l)})}return _m=i,_m}var Sm,Ab;function uL(){if(Ab)return Sm;Ab=1;var e=ZN(),n=zN(),i=BN();function s(o){return i(n(o,void 0,e),o+"")}return Sm=s,Sm}var bm,Ib;function lL(){if(Ib)return bm;Ib=1;var e=aL(),n=uL(),i=n(function(s,o){return s==null?{}:e(s,o)});return bm=i,bm}var km,Mb;function cL(){if(Mb)return km;Mb=1;var e=Math.ceil,n=Math.max;function i(s,o,u,l){for(var c=-1,d=n(e((o-s)/(u||1)),0),h=Array(d);d--;)h[l?d:++c]=s,s+=u;return h}return km=i,km}var Em,Pb;function fL(){if(Pb)return Em;Pb=1;var e=cL(),n=Ku(),i=QN();function s(o){return function(u,l,c){return c&&typeof c!="number"&&n(u,l,c)&&(l=c=void 0),u=i(u),l===void 0?(l=u,u=0):l=i(l),c=c===void 0?u<l?1:-1:i(c),e(u,l,c,o)}}return Em=s,Em}var Nm,Ob;function dL(){if(Ob)return Nm;Ob=1;var e=fL(),n=e();return Nm=n,Nm}var Cm,qb;function hL(){if(qb)return Cm;qb=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Cm=e,Cm}var Tm,Lb;function pL(){if(Lb)return Tm;Lb=1;var e=qs();function n(i,s){if(i!==s){var o=i!==void 0,u=i===null,l=i===i,c=e(i),d=s!==void 0,h=s===null,p=s===s,m=e(s);if(!h&&!m&&!c&&i>s||c&&d&&p&&!h&&!m||u&&d&&p||!o&&p||!l)return 1;if(!u&&!c&&!m&&i<s||m&&o&&l&&!u&&!c||h&&o&&l||!d&&l||!p)return-1}return 0}return Tm=n,Tm}var Rm,$b;function mL(){if($b)return Rm;$b=1;var e=pL();function n(i,s,o){for(var u=-1,l=i.criteria,c=s.criteria,d=l.length,h=o.length;++u<d;){var p=e(l[u],c[u]);if(p){if(u>=h)return p;var m=o[u];return p*(m=="desc"?-1:1)}}return i.index-s.index}return Rm=n,Rm}var jm,Db;function gL(){if(Db)return jm;Db=1;var e=Vu(),n=Gu(),i=xr(),s=$N(),o=hL(),u=zu(),l=mL(),c=Li(),d=yt();function h(p,m,y){m.length?m=e(m,function(_){return d(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,u(i));var N=s(p,function(_,S,b){var k=e(m,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,S){return l(_,S,y)})}return jm=h,jm}var Am,Fb;function vL(){if(Fb)return Am;Fb=1;var e=mv(),n=gL(),i=Yu(),s=Ku(),o=i(function(u,l){if(u==null)return[];var c=l.length;return c>1&&s(u,l[0],l[1])?l=[]:c>2&&s(l[0],l[1],l[2])&&(l=[l[0]]),n(u,e(l,1),[])});return Am=o,Am}var Im,zb;function yL(){if(zb)return Im;zb=1;var e=AN(),n=0;function i(s){var o=++n;return e(s)+o}return Im=i,Im}var Mm,Bb;function wL(){if(Bb)return Mm;Bb=1;function e(n,i,s){for(var o=-1,u=n.length,l=i.length,c={};++o<u;){var d=o<l?i[o]:void 0;s(c,n[o],d)}return c}return Mm=e,Mm}var Pm,Ub;function xL(){if(Ub)return Pm;Ub=1;var e=Du(),n=wL();function i(s,o){return n(s||[],o||[],e)}return Pm=i,Pm}var Om,Hb;function ut(){if(Hb)return Om;Hb=1;var e;if(typeof ev=="function")try{e={cloneDeep:qq(),constant:cv(),defaults:Lq(),each:kN(),filter:ON(),find:Hq(),flatten:ZN(),forEach:bN(),forIn:Vq(),has:qN(),isUndefined:LN(),last:Wq(),map:DN(),mapValues:Gq(),max:Kq(),merge:tL(),min:nL(),minBy:rL(),now:iL(),pick:lL(),range:dL(),reduce:FN(),sortBy:vL(),uniqueId:yL(),values:VN(),zipObject:xL()}}catch{}return e||(e=window._),Om=e,Om}var qm,Vb;function _L(){if(Vb)return qm;Vb=1,qm=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,u=o._prev;u!==o;)s.push(JSON.stringify(u,i)),u=u._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 qm}var Lm,Wb;function SL(){if(Wb)return Lm;Wb=1;var e=ut(),n=Vn().Graph,i=_L();Lm=o;var s=e.constant(1);function o(h,p){if(h.nodeCount()<=1)return[];var m=c(h,p||s),y=u(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function u(h,p,m){for(var y=[],x=p[p.length-1],N=p[0],_;h.nodeCount();){for(;_=N.dequeue();)l(h,p,m,_);for(;_=x.dequeue();)l(h,p,m,_);if(h.nodeCount()){for(var S=p.length-2;S>0;--S)if(_=p[S].dequeue(),_){y=y.concat(l(h,p,m,_,!0));break}}}return y}function l(h,p,m,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,d(p,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,k=h.node(b);k.in-=S,d(p,m,k)}),h.removeNode(y.v),N}function c(h,p){var m=new n,y=0,x=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,k=p(S),E=b+k;m.setEdge(S.v,S.w,E),x=Math.max(x,m.node(S.v).out+=k),y=Math.max(y,m.node(S.w).in+=k)});var N=e.range(x+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){d(N,_,m.node(S))}),{graph:m,buckets:N,zeroIdx:_}}function d(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 Lm}var $m,Gb;function bL(){if(Gb)return $m;Gb=1;var e=ut(),n=SL();$m={run:i,undo:o};function i(u){var l=u.graph().acyclicer==="greedy"?n(u,c(u)):s(u);e.forEach(l,function(d){var h=u.edge(d);u.removeEdge(d),h.forwardName=d.name,h.reversed=!0,u.setEdge(d.w,d.v,h,e.uniqueId("rev"))});function c(d){return function(h){return d.edge(h).weight}}}function s(u){var l=[],c={},d={};function h(p){e.has(d,p)||(d[p]=!0,c[p]=!0,e.forEach(u.outEdges(p),function(m){e.has(c,m.w)?l.push(m):h(m.w)}),delete c[p])}return e.forEach(u.nodes(),h),l}function o(u){e.forEach(u.edges(),function(l){var c=u.edge(l);if(c.reversed){u.removeEdge(l);var d=c.forwardName;delete c.reversed,delete c.forwardName,u.setEdge(l.w,l.v,c,d)}})}return $m}var Dm,Yb;function sn(){if(Yb)return Dm;Yb=1;var e=ut(),n=Vn().Graph;Dm={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:u,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:p,addBorderNode:m,maxRank:y,partition:x,time:N,notime:_};function i(S,b,k,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return k.dummy=b,S.setNode(C,k),C}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var E=b.edge(k.v,k.w)||{weight:0,minlen:1},C=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function u(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function l(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,C=b.x-k,A=b.y-E,P=S.width/2,I=S.height/2;if(!C&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var M,R;return Math.abs(A)*P>Math.abs(C)*I?(A<0&&(I=-I),M=I*C/A,R=I):(C<0&&(P=-P),M=P,R=P*A/C),{x:k+M,y:E+R}}function d(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var E=S.node(k),C=E.rank;e.isUndefined(C)||(b[C][E.order]=k)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var E=S.node(k);e.has(E,"rank")&&(E.rank-=b)})}function p(S){var b=e.min(e.map(S.nodes(),function(A){return S.node(A).rank})),k=[];e.forEach(S.nodes(),function(A){var P=S.node(A).rank-b;k[P]||(k[P]=[]),k[P].push(A)});var E=0,C=S.graph().nodeRankFactor;e.forEach(k,function(A,P){e.isUndefined(A)&&P%C!==0?--E:E&&e.forEach(A,function(I){S.node(I).rank+=E})})}function m(S,b,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),i(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return Dm}var Fm,Kb;function kL(){if(Kb)return Fm;Kb=1;var e=ut(),n=sn();Fm={run:i,undo:o};function i(u){u.graph().dummyChains=[],e.forEach(u.edges(),function(l){s(u,l)})}function s(u,l){var c=l.v,d=u.node(c).rank,h=l.w,p=u.node(h).rank,m=l.name,y=u.edge(l),x=y.labelRank;if(p!==d+1){u.removeEdge(l);var N,_,S;for(S=0,++d;d<p;++S,++d)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:l,rank:d},N=n.addDummyNode(u,"edge",_,"_d"),d===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),u.setEdge(c,N,{weight:y.weight},m),S===0&&u.graph().dummyChains.push(N),c=N;u.setEdge(c,h,{weight:y.weight},m)}}function o(u){e.forEach(u.graph().dummyChains,function(l){var c=u.node(l),d=c.edgeLabel,h;for(u.setEdge(c.edgeObj,d);c.dummy;)h=u.successors(l)[0],u.removeNode(l),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),l=h,c=u.node(l)})}return Fm}var zm,Xb;function Eu(){if(Xb)return zm;Xb=1;var e=ut();zm={longestPath:n,slack:i};function n(s){var o={};function u(l){var c=s.node(l);if(e.has(o,l))return c.rank;o[l]=!0;var d=e.min(e.map(s.outEdges(l),function(h){return u(h.w)-s.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(s.sources(),u)}function i(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return zm}var Bm,Qb;function nC(){if(Qb)return Bm;Qb=1;var e=ut(),n=Vn().Graph,i=Eu().slack;Bm=s;function s(c){var d=new n({directed:!1}),h=c.nodes()[0],p=c.nodeCount();d.setNode(h,{});for(var m,y;o(d,c)<p;)m=u(d,c),y=d.hasNode(m.v)?i(c,m):-i(c,m),l(d,c,y);return d}function o(c,d){function h(p){e.forEach(d.nodeEdges(p),function(m){var y=m.v,x=p===y?m.w:y;!c.hasNode(x)&&!i(d,m)&&(c.setNode(x,{}),c.setEdge(p,x,{}),h(x))})}return e.forEach(c.nodes(),h),c.nodeCount()}function u(c,d){return e.minBy(d.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return i(d,h)})}function l(c,d,h){e.forEach(c.nodes(),function(p){d.node(p).rank+=h})}return Bm}var Um,Zb;function EL(){if(Zb)return Um;Zb=1;var e=ut(),n=nC(),i=Eu().slack,s=Eu().longestPath,o=Vn().alg.preorder,u=Vn().alg.postorder,l=sn().simplify;Um=c,c.initLowLimValues=m,c.initCutValues=d,c.calcCutValue=p,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=l(E),s(E);var C=n(E);m(C),d(C,E);for(var A,P;A=x(C);)P=N(C,E,A),_(C,E,A,P)}function d(E,C){var A=u(E,E.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(P){h(E,C,P)})}function h(E,C,A){var P=E.node(A),I=P.parent;E.edge(A,I).cutvalue=p(E,C,A)}function p(E,C,A){var P=E.node(A),I=P.parent,M=!0,R=C.edge(A,I),L=0;return R||(M=!1,R=C.edge(I,A)),L=R.weight,e.forEach(C.nodeEdges(A),function(F){var Q=F.v===A,X=Q?F.w:F.v;if(X!==I){var j=Q===M,G=C.edge(F).weight;if(L+=j?G:-G,b(E,A,X)){var U=E.edge(A,X).cutvalue;L+=j?-U:U}}}),L}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,A,P,I){var M=A,R=E.node(P);return C[P]=!0,e.forEach(E.neighbors(P),function(L){e.has(C,L)||(A=y(E,C,A,L,P))}),R.low=M,R.lim=A++,I?R.parent=I:delete R.parent,A}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,A){var P=A.v,I=A.w;C.hasEdge(P,I)||(P=A.w,I=A.v);var M=E.node(P),R=E.node(I),L=M,F=!1;M.lim>R.lim&&(L=R,F=!0);var Q=e.filter(C.edges(),function(X){return F===k(E,E.node(X.v),L)&&F!==k(E,E.node(X.w),L)});return e.minBy(Q,function(X){return i(C,X)})}function _(E,C,A,P){var I=A.v,M=A.w;E.removeEdge(I,M),E.setEdge(P.v,P.w,{}),m(E),d(E,C),S(E,C)}function S(E,C){var A=e.find(E.nodes(),function(I){return!C.node(I).parent}),P=o(E,A);P=P.slice(1),e.forEach(P,function(I){var M=E.node(I).parent,R=C.edge(I,M),L=!1;R||(R=C.edge(M,I),L=!0),C.node(I).rank=C.node(M).rank+(L?R.minlen:-R.minlen)})}function b(E,C,A){return E.hasEdge(C,A)}function k(E,C,A){return A.low<=C.lim&&C.lim<=A.lim}return Um}var Hm,Jb;function NL(){if(Jb)return Hm;Jb=1;var e=Eu(),n=e.longestPath,i=nC(),s=EL();Hm=o;function o(d){switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":l(d);break;case"longest-path":u(d);break;default:c(d)}}var u=n;function l(d){n(d),i(d)}function c(d){s(d)}return Hm}var Vm,ek;function CL(){if(ek)return Vm;ek=1;var e=ut();Vm=n;function n(o){var u=s(o);e.forEach(o.graph().dummyChains,function(l){for(var c=o.node(l),d=c.edgeObj,h=i(o,u,d.v,d.w),p=h.path,m=h.lca,y=0,x=p[y],N=!0;l!==d.w;){if(c=o.node(l),N){for(;(x=p[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(N=!1)}if(!N){for(;y<p.length-1&&o.node(x=p[y+1]).minRank<=c.rank;)y++;x=p[y]}o.setParent(l,x),l=o.successors(l)[0]}})}function i(o,u,l,c){var d=[],h=[],p=Math.min(u[l].low,u[c].low),m=Math.max(u[l].lim,u[c].lim),y,x;y=l;do y=o.parent(y),d.push(y);while(y&&(u[y].low>p||m>u[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:d.concat(h.reverse()),lca:x}}function s(o){var u={},l=0;function c(d){var h=l;e.forEach(o.children(d),c),u[d]={low:h,lim:l++}}return e.forEach(o.children(),c),u}return Vm}var Wm,tk;function TL(){if(tk)return Wm;tk=1;var e=ut(),n=sn();Wm={run:i,cleanup:l};function i(c){var d=n.addDummyNode(c,"root",{},"_root"),h=o(c),p=e.max(e.values(h))-1,m=2*p+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=u(c)+1;e.forEach(c.children(),function(x){s(c,d,m,y,p,h,x)}),c.graph().nodeRankFactor=m}function s(c,d,h,p,m,y,x){var N=c.children(x);if(!N.length){x!==d&&c.setEdge(d,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(N,function(k){s(c,d,h,p,m,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,A=E.borderBottom?E.borderBottom:k,P=E.borderTop?p:2*p,I=C!==A?1:m-y[x]+1;c.setEdge(_,C,{weight:P,minlen:I,nestingEdge:!0}),c.setEdge(A,S,{weight:P,minlen:I,nestingEdge:!0})}),c.parent(x)||c.setEdge(d,_,{weight:0,minlen:m+y[x]})}function o(c){var d={};function h(p,m){var y=c.children(p);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),d[p]=m}return e.forEach(c.children(),function(p){h(p,1)}),d}function u(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var p=c.edge(h);p.nestingEdge&&c.removeEdge(h)})}return Wm}var Gm,nk;function RL(){if(nk)return Gm;nk=1;var e=ut(),n=sn();Gm=i;function i(o){function u(l){var c=o.children(l),d=o.node(l);if(c.length&&e.forEach(c,u),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var h=d.minRank,p=d.maxRank+1;h<p;++h)s(o,"borderLeft","_bl",l,d,h),s(o,"borderRight","_br",l,d,h)}}e.forEach(o.children(),u)}function s(o,u,l,c,d,h){var p={width:0,height:0,rank:h,borderType:u},m=d[u][h-1],y=n.addDummyNode(o,"border",p,l);d[u][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return Gm}var Ym,rk;function jL(){if(rk)return Ym;rk=1;var e=ut();Ym={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")&&u(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 u(h){e.forEach(h.nodes(),function(p){l(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,l),e.has(m,"y")&&l(m)})}function l(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(p){d(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,d),e.has(m,"x")&&d(m)})}function d(h){var p=h.x;h.x=h.y,h.y=p}return Ym}var Km,ik;function AL(){if(ik)return Km;ik=1;var e=ut();Km=n;function n(i){var s={},o=e.filter(i.nodes(),function(h){return!i.children(h).length}),u=e.max(e.map(o,function(h){return i.node(h).rank})),l=e.map(e.range(u+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var p=i.node(h);l[p.rank].push(h),e.forEach(i.successors(h),c)}}var d=e.sortBy(o,function(h){return i.node(h).rank});return e.forEach(d,c),l}return Km}var Xm,sk;function IL(){if(sk)return Xm;sk=1;var e=ut();Xm=n;function n(s,o){for(var u=0,l=1;l<o.length;++l)u+=i(s,o[l-1],o[l]);return u}function i(s,o,u){for(var l=e.zipObject(u,e.map(u,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:l[x.w],weight:s.edge(x).weight}}),"pos")}),!0),d=1;d<u.length;)d<<=1;var h=2*d-1;d-=1;var p=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+d;p[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=p[x+1]),x=x-1>>1,p[x]+=y.weight;m+=y.weight*N})),m}return Xm}var Qm,ok;function ML(){if(ok)return Qm;ok=1;var e=ut();Qm=n;function n(i,s){return e.map(s,function(o){var u=i.inEdges(o);if(u.length){var l=e.reduce(u,function(c,d){var h=i.edge(d),p=i.node(d.v);return{sum:c.sum+h.weight*p.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:o}})}return Qm}var Zm,ak;function PL(){if(ak)return Zm;ak=1;var e=ut();Zm=n;function n(o,u){var l={};e.forEach(o,function(d,h){var p=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};e.isUndefined(d.barycenter)||(p.barycenter=d.barycenter,p.weight=d.weight)}),e.forEach(u.edges(),function(d){var h=l[d.v],p=l[d.w];!e.isUndefined(h)&&!e.isUndefined(p)&&(p.indegree++,h.out.push(l[d.w]))});var c=e.filter(l,function(d){return!d.indegree});return i(c)}function i(o){var u=[];function l(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 d=o.pop();u.push(d),e.forEach(d.in.reverse(),l(d)),e.forEach(d.out,c(d))}return e.map(e.filter(u,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(o,u){var l=0,c=0;o.weight&&(l+=o.barycenter*o.weight,c+=o.weight),u.weight&&(l+=u.barycenter*u.weight,c+=u.weight),o.vs=u.vs.concat(o.vs),o.barycenter=l/c,o.weight=c,o.i=Math.min(u.i,o.i),u.merged=!0}return Zm}var Jm,uk;function OL(){if(uk)return Jm;uk=1;var e=ut(),n=sn();Jm=i;function i(u,l){var c=n.partition(u,function(_){return e.has(_,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),p=[],m=0,y=0,x=0;d.sort(o(!!l)),x=s(p,h,x),e.forEach(d,function(_){x+=_.vs.length,p.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(p,h,x)});var N={vs:e.flatten(p,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function s(u,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),u.push(d.vs),c++;return c}function o(u){return function(l,c){return l.barycenter<c.barycenter?-1:l.barycenter>c.barycenter?1:u?c.i-l.i:l.i-c.i}}return Jm}var eg,lk;function qL(){if(lk)return eg;lk=1;var e=ut(),n=ML(),i=PL(),s=OL();eg=o;function o(c,d,h,p){var m=c.children(d),y=c.node(d),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(A){return A!==x&&A!==N}));var S=n(c,m);e.forEach(S,function(A){if(c.children(A.v).length){var P=o(c,A.v,h,p);_[A.v]=P,e.has(P,"barycenter")&&l(A,P)}});var b=i(S,h);u(b,_);var k=s(b,p);if(x&&(k.vs=e.flatten([x,k.vs,N],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+C.order)/(k.weight+2),k.weight+=2}return k}function u(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(p){return d[p]?d[p].vs:p}),!0)})}function l(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return eg}var tg,ck;function LL(){if(ck)return tg;ck=1;var e=ut(),n=Vn().Graph;tg=i;function i(o,u,l){var c=s(o),d=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===u||p.minRank<=u&&u<=p.maxRank)&&(d.setNode(h),d.setParent(h,m||c),e.forEach(o[l](h),function(y){var x=y.v===h?y.w:y.v,N=d.edge(x,h),_=e.isUndefined(N)?0:N.weight;d.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(p,"minRank")&&d.setNode(h,{borderLeft:p.borderLeft[u],borderRight:p.borderRight[u]}))}),d}function s(o){for(var u;o.hasNode(u=e.uniqueId("_root")););return u}return tg}var ng,fk;function $L(){if(fk)return ng;fk=1;var e=ut();ng=n;function n(i,s,o){var u={},l;e.forEach(o,function(c){for(var d=i.parent(c),h,p;d;){if(h=i.parent(d),h?(p=u[h],u[h]=d):(p=l,l=d),p&&p!==d){s.setEdge(p,d);return}d=h}})}return ng}var rg,dk;function DL(){if(dk)return rg;dk=1;var e=ut(),n=AL(),i=IL(),s=qL(),o=LL(),u=$L(),l=Vn().Graph,c=sn();rg=d;function d(y){var x=c.maxRank(y),N=h(y,e.range(1,x+1),"inEdges"),_=h(y,e.range(x-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){p(E%2?N:_,E%4>=2),S=c.buildLayerMatrix(y);var A=i(y,S);A<b&&(C=0,k=e.cloneDeep(S),b=A)}m(y,k)}function h(y,x,N){return e.map(x,function(_){return o(y,_,N)})}function p(y,x){var N=new l;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,N,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),u(_,N,b.vs)})}function m(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return rg}var ig,hk;function FL(){if(hk)return ig;hk=1;var e=ut(),n=Vn().Graph,i=sn();ig={positionX:N,findType1Conflicts:s,findType2Conflicts:o,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(b,k){var E={};function C(A,P){var I=0,M=0,R=A.length,L=e.last(P);return e.forEach(P,function(F,Q){var X=u(b,F),j=X?b.node(X).order:R;(X||F===L)&&(e.forEach(P.slice(M,Q+1),function(G){e.forEach(b.predecessors(G),function(U){var ne=b.node(U),K=ne.order;(K<I||j<K)&&!(ne.dummy&&b.node(G).dummy)&&l(E,U,G)})}),M=Q+1,I=j)}),P}return e.reduce(k,C),E}function o(b,k){var E={};function C(P,I,M,R,L){var F;e.forEach(e.range(I,M),function(Q){F=P[Q],b.node(F).dummy&&e.forEach(b.predecessors(F),function(X){var j=b.node(X);j.dummy&&(j.order<R||j.order>L)&&l(E,X,F)})})}function A(P,I){var M=-1,R,L=0;return e.forEach(I,function(F,Q){if(b.node(F).dummy==="border"){var X=b.predecessors(F);X.length&&(R=b.node(X[0]).order,C(I,L,Q,M,R),L=Q,M=R)}C(I,L,I.length,R,P.length)}),I}return e.reduce(k,A),E}function u(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(E){return b.node(E).dummy})}function l(b,k,E){if(k>E){var C=k;k=E,E=C}var A=b[k];A||(b[k]=A={}),A[E]=!0}function c(b,k,E){if(k>E){var C=k;k=E,E=C}return e.has(b[k],E)}function d(b,k,E,C){var A={},P={},I={};return e.forEach(k,function(M){e.forEach(M,function(R,L){A[R]=R,P[R]=R,I[R]=L})}),e.forEach(k,function(M){var R=-1;e.forEach(M,function(L){var F=C(L);if(F.length){F=e.sortBy(F,function(U){return I[U]});for(var Q=(F.length-1)/2,X=Math.floor(Q),j=Math.ceil(Q);X<=j;++X){var G=F[X];P[L]===L&&R<I[G]&&!c(E,L,G)&&(P[G]=L,P[L]=A[L]=A[G],R=I[G])}}})}),{root:A,align:P}}function h(b,k,E,C,A){var P={},I=p(b,k,E,A),M=A?"borderLeft":"borderRight";function R(Q,X){for(var j=I.nodes(),G=j.pop(),U={};G;)U[G]?Q(G):(U[G]=!0,j.push(G),j=j.concat(X(G))),G=j.pop()}function L(Q){P[Q]=I.inEdges(Q).reduce(function(X,j){return Math.max(X,P[j.v]+I.edge(j))},0)}function F(Q){var X=I.outEdges(Q).reduce(function(G,U){return Math.min(G,P[U.w]-I.edge(U))},Number.POSITIVE_INFINITY),j=b.node(Q);X!==Number.POSITIVE_INFINITY&&j.borderType!==M&&(P[Q]=Math.max(P[Q],X))}return R(L,I.predecessors.bind(I)),R(F,I.successors.bind(I)),e.forEach(C,function(Q){P[Q]=P[E[Q]]}),P}function p(b,k,E,C){var A=new n,P=b.graph(),I=_(P.nodesep,P.edgesep,C);return e.forEach(k,function(M){var R;e.forEach(M,function(L){var F=E[L];if(A.setNode(F),R){var Q=E[R],X=A.edge(Q,F);A.setEdge(Q,F,Math.max(I(b,L,R),X||0))}R=L})}),A}function m(b,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(E,function(P,I){var M=S(b,I)/2;C=Math.max(P+M,C),A=Math.min(P-M,A)}),C-A})}function y(b,k){var E=e.values(k),C=e.min(E),A=e.max(E);e.forEach(["u","d"],function(P){e.forEach(["l","r"],function(I){var M=P+I,R=b[M],L;if(R!==k){var F=e.values(R);L=I==="l"?C-e.min(F):A-e.max(F),L&&(b[M]=e.mapValues(R,function(Q){return Q+L}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,C){if(k)return b[k.toLowerCase()][C];var A=e.sortBy(e.map(b,C));return(A[1]+A[2])/2})}function N(b){var k=i.buildLayerMatrix(b),E=e.merge(s(b,k),o(b,k)),C={},A;e.forEach(["u","d"],function(I){A=I==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(M){M==="r"&&(A=e.map(A,function(Q){return e.values(Q).reverse()}));var R=(I==="u"?b.predecessors:b.successors).bind(b),L=d(b,A,E,R),F=h(b,A,L.root,L.align,M==="r");M==="r"&&(F=e.mapValues(F,function(Q){return-Q})),C[I+M]=F})});var P=m(b,C);return y(C,P),x(C,b.graph().align)}function _(b,k,E){return function(C,A,P){var I=C.node(A),M=C.node(P),R=0,L;if(R+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":L=-I.width/2;break;case"r":L=I.width/2;break}if(L&&(R+=E?L:-L),L=0,R+=(I.dummy?k:b)/2,R+=(M.dummy?k:b)/2,R+=M.width/2,e.has(M,"labelpos"))switch(M.labelpos.toLowerCase()){case"l":L=M.width/2;break;case"r":L=-M.width/2;break}return L&&(R+=E?L:-L),L=0,R}}function S(b,k){return b.node(k).width}return ig}var sg,pk;function zL(){if(pk)return sg;pk=1;var e=ut(),n=sn(),i=FL().positionX;sg=s;function s(u){u=n.asNonCompoundGraph(u),o(u),e.forEach(i(u),function(l,c){u.node(c).x=l})}function o(u){var l=n.buildLayerMatrix(u),c=u.graph().ranksep,d=0;e.forEach(l,function(h){var p=e.max(e.map(h,function(m){return u.node(m).height}));e.forEach(h,function(m){u.node(m).y=d+p/2}),d+=p+c})}return sg}var og,mk;function BL(){if(mk)return og;mk=1;var e=ut(),n=bL(),i=kL(),s=NL(),o=sn().normalizeRanks,u=CL(),l=sn().removeEmptyRanks,c=TL(),d=RL(),h=jL(),p=DL(),m=zL(),y=sn(),x=Vn().Graph;og=N;function N(z,W){var J=W&&W.debugTiming?y.time:y.notime;J("layout",function(){var se=J(" buildLayoutGraph",function(){return R(z)});J(" runLayout",function(){_(se,J)}),J(" updateInputGraph",function(){S(z,se)})})}function _(z,W){W(" makeSpaceForEdgeLabels",function(){L(z)}),W(" removeSelfEdges",function(){D(z)}),W(" acyclic",function(){n.run(z)}),W(" nestingGraph.run",function(){c.run(z)}),W(" rank",function(){s(y.asNonCompoundGraph(z))}),W(" injectEdgeLabelProxies",function(){F(z)}),W(" removeEmptyRanks",function(){l(z)}),W(" nestingGraph.cleanup",function(){c.cleanup(z)}),W(" normalizeRanks",function(){o(z)}),W(" assignRankMinMax",function(){Q(z)}),W(" removeEdgeLabelProxies",function(){X(z)}),W(" normalize.run",function(){i.run(z)}),W(" parentDummyChains",function(){u(z)}),W(" addBorderSegments",function(){d(z)}),W(" order",function(){p(z)}),W(" insertSelfEdges",function(){V(z)}),W(" adjustCoordinateSystem",function(){h.adjust(z)}),W(" position",function(){m(z)}),W(" positionSelfEdges",function(){O(z)}),W(" removeBorderNodes",function(){K(z)}),W(" normalize.undo",function(){i.undo(z)}),W(" fixupEdgeLabelCoords",function(){U(z)}),W(" undoCoordinateSystem",function(){h.undo(z)}),W(" translateGraph",function(){j(z)}),W(" assignNodeIntersects",function(){G(z)}),W(" reversePoints",function(){ne(z)}),W(" acyclic.undo",function(){n.undo(z)})}function S(z,W){e.forEach(z.nodes(),function(J){var se=z.node(J),ue=W.node(J);se&&(se.x=ue.x,se.y=ue.y,W.children(J).length&&(se.width=ue.width,se.height=ue.height))}),e.forEach(z.edges(),function(J){var se=z.edge(J),ue=W.edge(J);se.points=ue.points,e.has(ue,"x")&&(se.x=ue.x,se.y=ue.y)}),z.graph().width=W.graph().width,z.graph().height=W.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],A={width:0,height:0},P=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},M=["labelpos"];function R(z){var W=new x({multigraph:!0,compound:!0}),J=ae(z.graph());return W.setGraph(e.merge({},k,B(J,b),e.pick(J,E))),e.forEach(z.nodes(),function(se){var ue=ae(z.node(se));W.setNode(se,e.defaults(B(ue,C),A)),W.setParent(se,z.parent(se))}),e.forEach(z.edges(),function(se){var ue=ae(z.edge(se));W.setEdge(se,e.merge({},I,B(ue,P),e.pick(ue,M)))}),W}function L(z){var W=z.graph();W.ranksep/=2,e.forEach(z.edges(),function(J){var se=z.edge(J);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(W.rankdir==="TB"||W.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function F(z){e.forEach(z.edges(),function(W){var J=z.edge(W);if(J.width&&J.height){var se=z.node(W.v),ue=z.node(W.w),he={rank:(ue.rank-se.rank)/2+se.rank,e:W};y.addDummyNode(z,"edge-proxy",he,"_ep")}})}function Q(z){var W=0;e.forEach(z.nodes(),function(J){var se=z.node(J);se.borderTop&&(se.minRank=z.node(se.borderTop).rank,se.maxRank=z.node(se.borderBottom).rank,W=e.max(W,se.maxRank))}),z.graph().maxRank=W}function X(z){e.forEach(z.nodes(),function(W){var J=z.node(W);J.dummy==="edge-proxy"&&(z.edge(J.e).labelRank=J.rank,z.removeNode(W))})}function j(z){var W=Number.POSITIVE_INFINITY,J=0,se=Number.POSITIVE_INFINITY,ue=0,he=z.graph(),ge=he.marginx||0,Me=he.marginy||0;function Fe(Re){var Pe=Re.x,be=Re.y,Oe=Re.width,ve=Re.height;W=Math.min(W,Pe-Oe/2),J=Math.max(J,Pe+Oe/2),se=Math.min(se,be-ve/2),ue=Math.max(ue,be+ve/2)}e.forEach(z.nodes(),function(Re){Fe(z.node(Re))}),e.forEach(z.edges(),function(Re){var Pe=z.edge(Re);e.has(Pe,"x")&&Fe(Pe)}),W-=ge,se-=Me,e.forEach(z.nodes(),function(Re){var Pe=z.node(Re);Pe.x-=W,Pe.y-=se}),e.forEach(z.edges(),function(Re){var Pe=z.edge(Re);e.forEach(Pe.points,function(be){be.x-=W,be.y-=se}),e.has(Pe,"x")&&(Pe.x-=W),e.has(Pe,"y")&&(Pe.y-=se)}),he.width=J-W+ge,he.height=ue-se+Me}function G(z){e.forEach(z.edges(),function(W){var J=z.edge(W),se=z.node(W.v),ue=z.node(W.w),he,ge;J.points?(he=J.points[0],ge=J.points[J.points.length-1]):(J.points=[],he=ue,ge=se),J.points.unshift(y.intersectRect(se,he)),J.points.push(y.intersectRect(ue,ge))})}function U(z){e.forEach(z.edges(),function(W){var J=z.edge(W);if(e.has(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function ne(z){e.forEach(z.edges(),function(W){var J=z.edge(W);J.reversed&&J.points.reverse()})}function K(z){e.forEach(z.nodes(),function(W){if(z.children(W).length){var J=z.node(W),se=z.node(J.borderTop),ue=z.node(J.borderBottom),he=z.node(e.last(J.borderLeft)),ge=z.node(e.last(J.borderRight));J.width=Math.abs(ge.x-he.x),J.height=Math.abs(ue.y-se.y),J.x=he.x+J.width/2,J.y=se.y+J.height/2}}),e.forEach(z.nodes(),function(W){z.node(W).dummy==="border"&&z.removeNode(W)})}function D(z){e.forEach(z.edges(),function(W){if(W.v===W.w){var J=z.node(W.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:W,label:z.edge(W)}),z.removeEdge(W)}})}function V(z){var W=y.buildLayerMatrix(z);e.forEach(W,function(J){var se=0;e.forEach(J,function(ue,he){var ge=z.node(ue);ge.order=he+se,e.forEach(ge.selfEdges,function(Me){y.addDummyNode(z,"selfedge",{width:Me.label.width,height:Me.label.height,rank:ge.rank,order:he+ ++se,e:Me.e,label:Me.label},"_se")}),delete ge.selfEdges})})}function O(z){e.forEach(z.nodes(),function(W){var J=z.node(W);if(J.dummy==="selfedge"){var se=z.node(J.e.v),ue=se.x+se.width/2,he=se.y,ge=J.x-ue,Me=se.height/2;z.setEdge(J.e,J.label),z.removeNode(W),J.label.points=[{x:ue+2*ge/3,y:he-Me},{x:ue+5*ge/6,y:he-Me},{x:ue+ge,y:he},{x:ue+5*ge/6,y:he+Me},{x:ue+2*ge/3,y:he+Me}],J.label.x=J.x,J.label.y=J.y}})}function B(z,W){return e.mapValues(e.pick(z,W),Number)}function ae(z){var W={};return e.forEach(z,function(J,se){W[se.toLowerCase()]=J}),W}return og}var ag,gk;function UL(){if(gk)return ag;gk=1;var e=ut(),n=sn(),i=Vn().Graph;ag={debugOrdering:s};function s(o){var u=n.buildLayerMatrix(o),l=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){l.setNode(c,{label:c}),l.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){l.setEdge(c.v,c.w,{},c.name)}),e.forEach(u,function(c,d){var h="layer"+d;l.setNode(h,{rank:"same"}),e.reduce(c,function(p,m){return l.setEdge(p,m,{style:"invis"}),m})}),l}return ag}var ug,vk;function HL(){return vk||(vk=1,ug="0.8.5"),ug}var lg,yk;function VL(){return yk||(yk=1,lg={graphlib:Vn(),layout:BL(),debug:UL(),util:{time:sn().time,notime:sn().notime},version:HL()}),lg}var WL=VL();const wk=Mg(WL),Ai=240,Ns=130,Cs=74,Xu=72,xk=Cs+Xu;function GL(e){let n=Ai;for(const i of e.values())n=Math.max(n,i.width);return n}const YL=420,KL=2;function Qu(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function XL(e,n,i,s,o){const u=new wk.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const l=e.filter(_=>!o.has(_)),c=new Set(l);for(const _ of l){const S=s.get(_);u.setNode(_,{width:(S==null?void 0:S.width)??Ai,height:(S==null?void 0:S.height)??Ns})}for(const _ of n)c.has(_.source)&&c.has(_.target)&&u.setEdge(_.source,_.target);wk.layout(u);const d=new Map;let h=1/0,p=1/0,m=-1/0,y=-1/0;for(const _ of l){const S=u.node(_);if(!S)continue;const b=s.get(_),k=(b==null?void 0:b.width)??Ai,E=(b==null?void 0:b.height)??Ns,C=S.x-k/2,A=S.y-E/2;d.set(_,{x:C,y:A}),C<h&&(h=C),A<p&&(p=A),C+k>m&&(m=C+k),A+E>y&&(y=A+E)}if(Number.isFinite(h)&&Number.isFinite(p))for(const[_,S]of d)d.set(_,{x:S.x-h,y:S.y-p});let x=Number.isFinite(m)?m-h:0,N=Number.isFinite(y)?y-p:0;for(const _ of e){const S=o.get(_);if(!S)continue;const b=s.get(_);x=Math.max(x,S.x+((b==null?void 0:b.width)??Ai)),N=Math.max(N,S.y+((b==null?void 0:b.height)??Ns))}return{positions:d,width:x,height:N}}function QL(e,n,i={}){const s=i.direction??"LR",o=i.pinned??new Map,u=i.measured??new Map,l=new Map;for(const S of e){const b=Qu(S),k=l.get(b);k?k.push(S.id):l.set(b,[S.id])}const d=Array.from(l.keys()).sort().map(S=>({sid:S,...XL(l.get(S),n,s,u,o)})),h=GL(u),p=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,m=S=>{const b=[[]];let k=0;for(const E of d)b.length<S&&k>0&&k+E.height>p&&(b.push([]),k=0),b[b.length-1].push(E),k+=E.height+xk;return b},y=S=>S.reduce((b,k)=>Math.max(b,k.width),0)+YL;let x=m(i.availableWidth?KL:1);x.length>1&&x.reduce((b,k)=>b+y(k),0)+h*(x.length-1)>(i.availableWidth??0)&&(x=m(1));const N=new Map;let _=0;for(const S of x){let b=0;for(const{positions:k,height:E}of S){for(const[C,A]of k)N.set(C,{x:A.x+_,y:A.y+b});b+=E+xk}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const k=N.get(S.id);return k?{...S,position:k}:S})}function ZL(e,n,i,s){const u=Cs+Xu,l=60,c=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??Ai,h:(x==null?void 0:x.height)??Ns}},d=new Map(e.map(y=>[y.id,Qu(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,x)=>y.pos.y-x.pos.y||y.pos.x-x.pos.x||y.id.localeCompare(x.id)),m=[];for(const{id:y,pos:x}of p){const{w:N,h:_}=c(y),S=d.get(y)??"_default";if(i.has(y)){h.push({x:x.x,y:x.y,w:N,h:_,sid:S});continue}let b=x.y;for(let k=0;k<h.length+1;k++){const E=h.find(C=>{const A=C.sid===S?24:l,P=C.sid===S?24:u;return x.x<C.x+C.w+A&&C.x<x.x+N+A&&b<C.y+C.h+P&&C.y<b+_+P});if(!E)break;b=E.y+E.h+(E.sid===S?24:u)}b!==x.y&&(n.set(y,{x:x.x,y:b}),m.push(y)),h.push({x:x.x,y:b,w:N,h:_,sid:S})}return m}function JL(e,n,i,s,o){const u=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??Ai,h:(x==null?void 0:x.height)??Ns}},l=y=>i.get(y)??n.get(y),c=new Map,d=[];for(const y of e){const x=l(y.id);if(!x)continue;const{w:N,h:_}=u(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=Qu(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else d.push({x:x.x,y:x.y,w:N,h:_})}if(c.size===0)return[];const h=Cs+Xu,p=(y,x,N,_)=>d.some(S=>y<S.x+S.w+Cs&&S.x<y+N+Cs&&x<S.y+S.h+h&&S.y<x+_+h),m=[];for(const y of[...c.keys()].sort()){const x=c.get(y);let N=1/0,_=1/0,S=-1/0,b=-1/0;for(const M of x){const R=l(M.id),{w:L,h:F}=u(M.id);N=Math.min(N,R.x),_=Math.min(_,R.y),S=Math.max(S,R.x+L),b=Math.max(b,R.y+F)}const k=S-N,E=b-_,C=[...new Set(d.map(M=>Math.round(M.x)))].sort((M,R)=>M-R),A=C.length?C:[N],P=[0,...d.map(M=>M.y+M.h+h)].sort((M,R)=>M-R);let I=null;e:for(const M of A)for(const R of P){if(R>=_)break;if(!p(M,R,k,E)){I={x:M,y:R};break e}}if(I){const M=I.x-N,R=I.y-_;for(const L of x){const F=l(L.id);n.set(L.id,{x:F.x+M,y:F.y+R})}m.push(y)}for(const M of x){const R=l(M.id),{w:L,h:F}=u(M.id);d.push({x:R.x,y:R.y,w:L,h:F})}}return m}function e$(e,n,i,s,o,u=!1){const d=Cs+Xu+1,h=8,p=1.75,m=200,y=.7,x=.01,N=I=>{const M=s.get(I);return{w:(M==null?void 0:M.width)??Ai,h:(M==null?void 0:M.height)??Ns}},_=I=>i.get(I)??n.get(I),S=new Map;for(const I of e){if(!_(I.id))continue;const M=Qu(I),R=S.get(M);R?R.push(I):S.set(M,[I])}const b=[],k=new Set,E=new Set;for(const I of[...S.keys()].sort()){const M=S.get(I);let R=1/0,L=1/0,F=-1/0,Q=-1/0,X=!1;for(const ne of M){const K=_(ne.id),{w:D,h:V}=N(ne.id);R=Math.min(R,K.x),L=Math.min(L,K.y),F=Math.max(F,K.x+D),Q=Math.max(Q,K.y+V),i.has(ne.id)&&(X=!0)}const j=F-R,G=Q-L;E.add(I);const U=o.get(I);U&&(j>U.w+h||G>U.h+h)&&k.add(I),o.set(I,{w:j,h:G}),b.push({sid:I,members:M.map(ne=>ne.id),x:R,y:L,w:j,h:G,anchored:X,mass:1})}for(const I of[...o.keys()])E.has(I)||o.delete(I);if(u||k.size===0)return[];for(const I of b)k.has(I.sid)&&(I.mass=8);const C=new Map(b.map(I=>[I.sid,I.x])),A=new Map(b.map(I=>[I.sid,I.y]));for(let I=0;I<m;I++){const M=new Map,R=new Map;let L=0;for(let F=0;F<b.length;F++)for(let Q=F+1;Q<b.length;Q++){const X=b[F],j=b[Q];if(X.anchored&&j.anchored)continue;const G=X.x+X.w/2,U=X.y+X.h/2,ne=j.x+j.w/2,K=j.y+j.h/2,D=(X.w+j.w)/2+61-Math.abs(G-ne),V=(X.h+j.h)/2+d-Math.abs(U-K);if(D<=0||V<=0)continue;const O=(Ye,Qe)=>!Ye.anchored&&!(Qe<0&&Ye.x<=0),B=(Ye,Qe)=>!Ye.anchored&&!(Qe<0&&Ye.y<=0),ae=(Ye,Qe,et)=>{const Be=Ye===Qe,Ze=Be?X.sid<j.sid?-1:1:Math.sign(Ye-Qe);return et(X,Ze)||et(j,-Ze)?Ze:Be&&(et(X,-Ze)||et(j,Ze))?-Ze:0},z=ae(G,ne,O),W=ae(U,K,B),J=z!==0,se=W!==0;if(!J&&!se)continue;const ue=J&&(!se||D*p<V),[he,ge,Me,Fe]=ue?[z,D,M,O]:[W,V,R,B],Re=Fe(X,he),Pe=Fe(j,-he),be=X.mass,Oe=j.mass,ve=Re?Pe?Oe/(be+Oe):1:0,ye=Pe?Re?be/(be+Oe):1:0,qe=ge*y;Me.set(X.sid,(Me.get(X.sid)??0)+he*qe*ve),Me.set(j.sid,(Me.get(j.sid)??0)-he*qe*ye),L+=qe}for(const F of b)F.anchored||(F.x=Math.max(0,F.x+(M.get(F.sid)??0)),F.y=Math.max(0,F.y+(R.get(F.sid)??0)));if(L<x)break}const P=[];for(const I of b){const M=I.x-C.get(I.sid),R=I.y-A.get(I.sid);if(!(Math.abs(M)<1&&Math.abs(R)<1)){for(const L of I.members){if(i.has(L))continue;const F=n.get(L);F&&n.set(L,{x:F.x+M,y:F.y+R})}P.push(I.sid)}}return P}const t$=600;function jg(e,n){return!(e.exitAt!=null&&n-e.exitAt>t$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function n$(e,n){const i=new Set;for(const s of e.agents.values())jg(s,n)&&i.add(s.id);return i}function Ei(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function r$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const i$={agent:wP,sessionGroup:jP},s$=420,lu=18,o$=9e4,a$=200,u$=5*6e4,l$=6,c$=2*6e4,yv="agent-dag.layout",wv="agent-dag.viewport",rC="agent-dag.summariesDismissed",iC="agent-dag.sessionListOpen",sC="agent-dag.detailOpen",oC="agent-dag.usagePanelOpen",_k="agent-dag.accountsPanelOpen";function f$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(iC)==="1"}catch{return!1}}function d$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(iC,e?"1":"0")}catch{}}function h$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(sC)==="1"}catch{return!1}}function p$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(sC,e?"1":"0")}catch{}}function m$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(oC);try{return e===null?!0:e==="1"}catch{return!0}}function g$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(oC,e?"1":"0")}catch{}}function v$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(rC);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 Sk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(rC,JSON.stringify(i))}catch{}}function y$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(yv);if(!n)return e;const i=JSON.parse(n);if(!("v"in i)){const o=Object.entries(i).filter(([,u])=>u&&typeof u.x=="number"&&typeof u.y=="number");return{positions:o,pins:o.map(([u])=>u)}}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 cg(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(yv,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function w$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(wv);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 x$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(wv,JSON.stringify(e))}catch{}}function bk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(yv)}catch{}try{window.localStorage.removeItem(wv)}catch{}}}function _$(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}))}))},u=JSON.stringify(o,null,2),l=new Blob([u],{type:"application/json"}),c=URL.createObjectURL(l),d=document.createElement("a"),h=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");d.href=c,d.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Ag={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Ig={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},S$={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 aC(e){return e.startsWith("mcp__")?"mcp":S$[e]??"other"}function uC(e,n){var s,o,u;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)||(u=e.firstPrompt)!=null&&u.toLowerCase().includes(i))return!0;for(const l of e.tools)if(l.name.toLowerCase().includes(i))return!0;return!1}function b$(e,n){if(!n)return null;const i=new Set([n]);let s=n;for(;s;){const u=e.agents.get(s);if(!(u!=null&&u.parentId)||i.has(u.parentId))break;i.add(u.parentId),s=u.parentId}let o=!0;for(;o;){o=!1;for(const u of e.agents.values())u.parentId&&i.has(u.parentId)&&!i.has(u.id)&&(i.add(u.id),o=!0)}return i}function k$(e,n,i,s,o,u,l,c,d,h,p,m,y,x,N,_,S,b){const k=[],E=[],C=new Set;if(u)for(const R of e.agents.values())uC(R,u)&&C.add(R.id);for(const R of e.agents.values()){if(!S.has(R.id))continue;const L=u?!C.has(R.id):!1,F=R.exitAt!=null,Q=_!=null&&!_.has(R.id),X=[L?"rf-dim":"",F?"rf-exiting":"",Q?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,j=l.get(R.id);if(k.push({id:R.id,type:"agent",position:{x:0,y:0},data:{...R,now:n,dim:L,onOpenContext:b},className:X,...j?{width:j.width,height:j.height}:null}),R.parentId&&S.has(R.parentId)){const G=Zg(R.sessionId),U=R.state==="active"?`hsl(${G} 80% 72%)`:`hsl(${G} 50% 55%)`,ne=u&&!C.has(R.id)&&!C.has(R.parentId),K=F,D=N.size>0&&(N.has(R.id)||N.has(R.parentId)),V=_!=null&&!_.has(R.id)&&!_.has(R.parentId),O=R.state==="active"?2:1.5,B=D?O+1.5:O,ae=ne||K?.2:V?.12:1,z=[K?"rf-edge-exiting":"",D?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;E.push({id:`e:${R.parentId}->${R.id}`,source:R.parentId,target:R.id,animated:(R.state==="active"||D)&&!ne&&!K,type:"smoothstep",style:{stroke:U,strokeWidth:B,opacity:ae,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:z})}}const A=k.filter(R=>!o.has(R.id)&&!m.has(R.id));if(A.length>0||y!==x.current){if(A.length>0){const R=QL(k,E,{direction:"LR",pinned:o,measured:l,availableWidth:i,availableHeight:s});for(const L of R)m.has(L.id)||m.set(L.id,L.position);JL(k,m,o,l,new Set(A.map(L=>L.id)))}ZL(k,m,o,l),x.current=y}const P=e$(k,m,o,l,c,!h||p);P.length>0&&d(P);for(const R of Array.from(m.keys()))e.agents.has(R)||m.delete(R);if(e.agents.size>0)for(const R of Array.from(o.keys()))e.agents.has(R)||o.delete(R);const I=[];let M=!1;for(const R of k){let L=o.get(R.id)??m.get(R.id);L||(L={x:0,y:0},m.set(R.id,L),M=!0),I.push({...R,position:L})}return M&&(x.current=""),{nodes:I,edges:E}}function E$(){return v.jsx(Xg,{children:v.jsx(N$,{})})}function N$(){const e=zo(),n=q.useRef(Cg()),[,i]=q.useState(0),s=q.useCallback(()=>i(Z=>Z+1),[]),[o,u]=q.useState(()=>new Set),[l,c]=q.useState(null),[d,h]=q.useState(null),p=q.useCallback((Z,te)=>{u(ce=>{if(!te)return new Set([Z]);const me=new Set(ce);return me.has(Z)?me.delete(Z):me.add(Z),me}),c(ce=>te&&ce===Z?ce:Z)},[]),m=q.useCallback(()=>{u(new Set),c(null)},[]),[y,x]=q.useState(null),[N,_]=q.useState(null),S=q.useCallback(Z=>_(Z),[]),b=q.useRef(v$()),[k,E]=q.useState(f$);q.useEffect(()=>{d$(k)},[k]);const[C,A]=q.useState(h$);q.useEffect(()=>{p$(C)},[C]);const[P,I]=q.useState(m$);q.useEffect(()=>{g$(P)},[P]);const[M,R]=q.useState(()=>{try{const Z=window.localStorage.getItem(_k);return Z===null?!0:Z==="1"}catch{return!0}});q.useEffect(()=>{try{window.localStorage.setItem(_k,M?"1":"0")}catch{}},[M]);const[L,F]=q.useState(null),[Q,X]=q.useState(!1),[j,G]=q.useState(0),[U,ne]=q.useState(0);q.useEffect(()=>{fetch("/api/sound-hook").then(Z=>Z.ok?Z.json():null).then(Z=>{Z!=null&&Z.ok&&(F(Z.enabled===!0),G((Z.foreign??[]).filter(te=>te.worksHere).length),ne(typeof Z.parked=="number"?Z.parked:0))}).catch(()=>{})},[]);const K=q.useCallback(async()=>{X(!0);try{const te=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!L})})).json().catch(()=>null);te!=null&&te.ok&&F(te.enabled===!0),fetch("/api/sound-hook").then(ce=>ce.ok?ce.json():null).then(ce=>{ce!=null&&ce.ok&&(G((ce.foreign??[]).filter(me=>me.worksHere).length),ne(typeof ce.parked=="number"?ce.parked:0))}).catch(()=>{})}catch{}finally{X(!1)}},[L]),D=q.useCallback(()=>{E(Z=>(Z||R(!1),!Z))},[]),V=q.useCallback(()=>{R(Z=>(Z||E(!1),!Z))},[]),[O,B]=q.useState(!1),[ae,z]=q.useState(0),W=q.useRef(null),[J,se]=q.useState(0),[ue,he]=q.useState(!1),[ge,Me]=q.useState(!1),Fe=q.useRef([]),[Re,Pe]=q.useState(Date.now()),be=q.useRef(y$()).current;q.useRef(!1);const Oe=q.useRef(new Map(be.positions.filter(([Z])=>be.pins.includes(Z)))),ve=q.useRef(null),ye=q.useState(()=>w$())[0],[qe,Ye]=q.useState(""),[Qe,et]=q.useState(()=>new Set),[Be,Ze]=q.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[At,Vt]=q.useState(!1),It=q.useRef(null);q.useEffect(()=>{document.documentElement.dataset.theme=Be;try{window.localStorage.setItem("agent-dag.theme",Be)}catch{}},[Be]),q.useEffect(()=>{if(!ye)return;const Z=window.setTimeout(()=>{try{e.setViewport(ye,{duration:0})}catch{}},60);return()=>window.clearTimeout(Z)},[e,ye]);const pt=q.useRef(!0),tt=q.useRef(null);q.useEffect(()=>{const Z=new EventSource("/events");return Z.addEventListener("open",()=>{he(!0),Vt(!0)}),Z.addEventListener("error",()=>he(!1)),Z.addEventListener("replay-end",()=>{pt.current=!1,tt.current!=null&&(window.clearTimeout(tt.current),tt.current=null),s()}),Z.addEventListener("hook",te=>{try{const ce=JSON.parse(te.data);if(ge){Fe.current.push(ce);return}n.current=Fw(n.current,ce),ce.replay===!0||pt.current||Date.now()-ce.receivedAt>3e4?(tt.current!=null&&window.clearTimeout(tt.current),tt.current=window.setTimeout(()=>{tt.current=null,s()},120)):(tt.current!=null&&(window.clearTimeout(tt.current),tt.current=null),s())}catch{}}),()=>{Z.close(),tt.current!=null&&(window.clearTimeout(tt.current),tt.current=null)}},[ge,s]),q.useEffect(()=>{if(!ge&&Fe.current.length!==0){for(const Z of Fe.current)n.current=Fw(n.current,Z);Fe.current.length=0,s()}},[ge,s]),q.useEffect(()=>{const Z=setInterval(()=>{const te=Date.now();Pe(te);let ce=rP(n.current,te,o$);tP(n.current,te,a$,u$)&&(ce=!0),nP(n.current,te,l$,c$)&&(ce=!0),ce&&s()},250);return()=>clearInterval(Z)},[s]);const kt=q.useRef(null),We=q.useRef(0),Et=420,Ge=q.useCallback((Z=500)=>{try{const we=document.querySelector(".canvas-wrap"),Le=Array.from(document.querySelectorAll(".react-flow__node")).filter(Je=>Je.offsetWidth>0);if(!we||Le.length===0)return;const ze=we.getBoundingClientRect(),Te=e.getViewport();if(!Number.isFinite(Te.zoom)||Te.zoom<=0)return;const Ke=Je=>(Je-ze.left-Te.x)/Te.zoom,it=Je=>(Je-ze.top-Te.y)/Te.zoom,Kt=Le.map(Je=>Je.getBoundingClientRect()),Rr=Math.min(...Kt.map(Je=>Ke(Je.left))),Gi=Math.max(...Kt.map(Je=>Ke(Je.right))),jr=Math.min(...Kt.map(Je=>it(Je.top))),li=Math.max(...Kt.map(Je=>it(Je.bottom))),ci=Gi-Rr,fn=li-jr;if(!(ci>0&&fn>0))return;const Ct=Math.max(.2,Math.min(1,(ze.width-160)/(ci+Et)*.86,(ze.height-160)/fn*.86));e.setViewport({x:80-Rr*Ct,y:Math.max(80,(ze.height-fn*Ct)/2)-jr*Ct,zoom:Ct},{duration:Z}),We.current=Date.now(),window.setTimeout(()=>{try{const Je={x:80-Rr*Ct,y:Math.max(80,(ze.height-fn*Ct)/2)-jr*Ct,zoom:Ct},Ar=e.getViewport();(Math.abs(Ar.zoom-Ct)>.01||Math.abs(Ar.x-Je.x)>2)&&e.setViewport(Je,{duration:0})}catch{}},Z+60)}catch{}},[e]),ft=q.useRef(""),on=q.useRef(null),Lt=q.useRef(0),wt=q.useCallback(()=>{Lt.current=Date.now()},[]),an="agent-dag.autoFitDisabled",Bt=q.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(an)==="1"}catch{return!1}})()),[vn,un]=q.useState(Bt.current),yn=q.useCallback(()=>{if(!Bt.current){Bt.current=!0,un(!0);try{window.localStorage.setItem(an,"1")}catch{}}},[]),wn=q.useCallback(()=>{Bt.current=!1,un(!1);try{window.localStorage.removeItem(an)}catch{}Ge(400)},[e,Ge]);q.useEffect(()=>{const Z=setInterval(()=>{if(Bt.current||Date.now()-Lt.current<800)return;const te=n.current,ce=Date.now(),me=[];for(const Ke of te.agents.values())jg(Ke,ce)&&me.push({id:Ke.id});if(me.length===0)return;const _e=e.getViewport(),we=window.innerWidth-360,Le=window.innerHeight-52;let ze=!1,Te=!1;for(const{id:Ke}of me){const it=Mn.current.get(Ke),Kt=Oe.current.get(Ke)??Nt.current.get(Ke);if(!it||!Kt)continue;Te=!0;const Rr=Kt.x*_e.zoom+_e.x,Gi=Kt.y*_e.zoom+_e.y,jr=(Kt.x+it.width)*_e.zoom+_e.x,li=(Kt.y+it.height)*_e.zoom+_e.y;if(jr>0&&Rr<we&&li>0&&Gi<Le){ze=!0;break}}Te&&!ze&&Ge(600)},1500);return()=>clearInterval(Z)},[e]);const _r=q.useRef(!1),Mn=q.useRef(new Map),ti=q.useRef(0),$i=q.useCallback(Z=>{const te=Mn.current;let ce=!1;for(const me of Z.nodeInternals.values()){const _e=me.width,we=me.height;if(_e==null||we==null)continue;const Le=te.get(me.id);Le?(Math.abs(Le.height-we)>4||Math.abs(Le.width-_e)>4)&&(te.set(me.id,{width:_e,height:we}),ce=!0):(te.set(me.id,{width:_e,height:we}),ce=!0)}return ce&&(ti.current+=1),ti.current},[]),Sr=Xe($i),[ni,ir]=q.useState(0);q.useEffect(()=>{let Z=0;const te=()=>{const me=Mn.current;let _e=!1;for(const we of document.querySelectorAll(".react-flow__node[data-id]")){const Le=we.getAttribute("data-id");if(!Le)continue;const ze=we.offsetWidth,Te=we.offsetHeight;if(!ze||!Te)continue;const Ke=me.get(Le);(!Ke||Math.abs(Ke.width-ze)>4||Math.abs(Ke.height-Te)>4)&&(me.set(Le,{width:ze,height:Te}),_e=!0)}_e&&ir(we=>we+1)};if(_r.current)return;let ce=0;return document.visibilityState==="hidden"?ce=window.setTimeout(te,32):Z=requestAnimationFrame(te),()=>{cancelAnimationFrame(Z),window.clearTimeout(ce)}});const Nt=q.useRef(new Map(be.positions)),Pn=q.useRef(""),Yn=q.useMemo(()=>{const Z=[];for(const te of n.current.agents.values())jg(te,Re)&&Z.push(te.id+(te.parentId?`>${te.parentId}`:""));return Z.sort(),`${Z.join("|")}#sv${Sr}.${ni}`},[n.current,n.current.lastSeq,Re,Sr,ni]),ln=q.useRef(null);q.useEffect(()=>(ln.current!=null&&window.clearTimeout(ln.current),ln.current=window.setTimeout(()=>{cg(Nt.current,Oe.current)},1500),()=>{ln.current!=null&&window.clearTimeout(ln.current)}),[Yn]),q.useEffect(()=>{if(ft.current===Yn)return;const Z=ft.current;if(ft.current=Yn,!Z||Bt.current)return;Date.now()-We.current>1200&&Ge(400),kt.current&&window.clearTimeout(kt.current),kt.current=window.setTimeout(()=>{Bt.current||Ge(500)},280)},[Yn,e,Ge]);const Kn=q.useMemo(()=>{if(o.size===0)return null;const Z=new Set;for(const te of o){const ce=b$(n.current,te);if(ce)for(const me of ce)Z.add(me)}return Z.size>0?Z:null},[n.current,n.current.lastSeq,o]),Xn=q.useMemo(()=>n$(n.current,Re),[n.current,n.current.lastSeq,Re]),br=q.useRef(null),[kr,Di]=q.useState({w:0,h:0});q.useEffect(()=>{const Z=br.current;if(!Z||typeof ResizeObserver>"u")return;const te=new ResizeObserver(ce=>{var _e;const me=(_e=ce[0])==null?void 0:_e.contentRect;me&&Di(we=>Math.abs(we.w-me.width)>40||Math.abs(we.h-me.height)>40?{w:me.width,h:me.height}:we)});return te.observe(Z),Di({w:Z.clientWidth,h:Z.clientHeight}),()=>te.disconnect()},[]);const Fi=q.useRef(new Map),[xn,zi]=q.useState(!1);q.useEffect(()=>{const Z=window.setTimeout(()=>zi(!0),2500);return()=>window.clearTimeout(Z)},[]);const[Bi,ri]=q.useState(!1),cn=q.useRef(null),[Er,ii]=q.useState(!1),Ui=q.useCallback(()=>{cn.current&&(window.clearTimeout(cn.current),cn.current=null),ri(!1)},[]),Hi=q.useCallback(Z=>{Z.length!==0&&queueMicrotask(()=>{ri(!0),cn.current&&window.clearTimeout(cn.current),cn.current=window.setTimeout(()=>ri(!1),s$+80)})},[]);q.useEffect(()=>()=>{cn.current&&window.clearTimeout(cn.current)},[]);const Vi=kr.w>0?kr.w*.92:0,nt=kr.h>0?kr.h:0,{nodes:Wt,edges:si}=q.useMemo(()=>k$(n.current,Re,Vi,nt,Oe.current,qe,Mn.current,Fi.current,Hi,xn,Er,Nt.current,Yn,Pn,o,Kn,Xn,S),[n.current,n.current.lastSeq,Re,Vi,nt,xn,Er,qe,Yn,o,Kn,Xn,S,ae]),oi=q.useMemo(()=>{const Z=new Map;for(const ce of Wt){const me=ce.data;if(!(me!=null&&me.sessionId)||me.exitAt!=null)continue;const _e=ce.width,we=ce.height;if(_e==null||we==null)continue;const Le=ce.position.x,ze=ce.position.y,Te=Le+_e,Ke=ze+we,it=Z.get(me.sessionId);it?(it.minX=Math.min(it.minX,Le),it.minY=Math.min(it.minY,ze),it.maxX=Math.max(it.maxX,Te),it.maxY=Math.max(it.maxY,Ke)):Z.set(me.sessionId,{minX:Le,minY:ze,maxX:Te,maxY:Ke})}const te=[];for(const[ce,me]of Z){const _e=me.maxX-me.minX+lu*2,we=me.maxY-me.minY+lu*2;te.push({id:`group:${ce}`,type:"sessionGroup",position:{x:me.minX-lu,y:me.minY-lu},data:{sessionId:ce,w:_e,h:we},width:_e,height:we,style:{width:_e,height:we},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return te},[Wt,Re]),Nr=q.useMemo(()=>{const Z=[...oi,...Wt],te=W.current;return!te||te.size===0?Z:Z.map(ce=>{const me=te.get(ce.id);return me?{...ce,position:me}:ce})},[oi,Wt,J]),Wi=q.useMemo(()=>{if(!qe)return null;const Z=new Set;for(const te of n.current.agents.values())uC(te,qe)&&Z.add(te.id);return Z},[n.current,n.current.lastSeq,qe]),ai=q.useMemo(()=>{const Z=new Set;for(const te of n.current.agents.values())for(const ce of te.tools)Z.add(aC(ce.name));return Object.keys(Ag).filter(te=>Z.has(te))},[n.current,n.current.lastSeq]),_n=q.useMemo(()=>{const Z=new Map;for(const ce of n.current.agents.values())for(const me of ce.tools){if(!me.name.startsWith("mcp__"))continue;const _e=me.name.slice(5),we=_e.indexOf("__"),Le=we>0?_e.slice(0,we):_e;Z.set(Le,(Z.get(Le)??0)+1)}const te=[];for(const[ce,me]of Z){let _e=5381;for(let we=0;we<ce.length;we++)_e=(_e<<5)+_e^ce.charCodeAt(we);te.push({server:ce,count:me,hue:Math.abs(_e)%360})}return te.sort((ce,me)=>me.count-ce.count),te},[n.current,n.current.lastSeq]),Gt=q.useCallback(Z=>{et(te=>{const ce=new Set(te);return ce.has(Z)?ce.delete(Z):ce.add(Z),ce})},[]),gt=l?n.current.agents.get(l):null,Yt=d?Array.from(n.current.agents.values()).flatMap(Z=>Z.tools).find(Z=>Z.id===d)??null:null,Ls=q.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Cg(),Oe.current.clear(),Mn.current.clear(),Nt.current.clear(),Pn.current="",bk(),m(),s()},[s,m]),$s=q.useCallback(()=>{Oe.current.clear(),Nt.current.clear(),Pn.current="",bk(),s(),window.setTimeout(()=>Ge(500),80)},[s,e,Ge]),Yo=q.useCallback(()=>Ge(500),[Ge]),Cr=q.useCallback(Z=>{if(Wt.length===0)return;const te=Wt.slice().sort((we,Le)=>we.position.y-Le.position.y||we.position.x-Le.position.x),ce=l?te.findIndex(we=>we.id===l):-1;let me;ce===-1?me=Z===1?0:te.length-1:me=(ce+Z+te.length)%te.length;const _e=te[me];_e&&(p(_e.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[_e]})}catch{}We.current=Date.now()},30))},[Wt,l,p,e]);q.useEffect(()=>{const Z=te=>{var me,_e;const ce=((me=te.target)==null?void 0:me.tagName)==="INPUT";if(te.key==="Escape"){ce?te.target.blur():m();return}if(!ce){if(te.key==="/"){te.preventDefault(),(_e=It.current)==null||_e.focus();return}te.key===" "&&(te.preventDefault(),Me(we=>!we)),(te.key==="c"||te.key==="C")&&Ls(),(te.key==="r"||te.key==="R")&&$s(),(te.key==="f"||te.key==="F")&&Yo(),(te.key==="l"||te.key==="L")&&D(),(te.key==="h"||te.key==="H")&&B(we=>!we),(te.key==="u"||te.key==="U")&&I(we=>!we),(te.key==="a"||te.key==="A")&&V(),(te.key==="j"||te.key==="J")&&Cr(1),(te.key==="k"||te.key==="K")&&Cr(-1),(te.key==="t"||te.key==="T")&&Ze(we=>we==="dark"?"light":"dark")}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[Ls,$s,Yo,m,Cr]);const Tr=n.current.agents.size,ui=new Set(Array.from(n.current.agents.values()).map(Z=>Z.sessionId)).size,Mt=q.useMemo(()=>{let Z=0,te=0,ce=0,me=0,_e=0,we=0,Le=0,ze=0,Te=0;for(const Ke of n.current.agents.values()){Z+=Ke.usage.inputTokens,te+=Ke.usage.outputTokens,ce+=Ke.usage.cacheReadTokens,me+=Ke.usage.cacheCreateTokens;const it=rn(Ke.usage,Ke.model);_e+=it.total,we+=it.input,Le+=it.output,ze+=it.cacheRead,Te+=it.cacheWrite}return{inT:Z,outT:te,cacheR:ce,cacheC:me,sum:Z+te,cost:{total:_e,input:we,output:Le,cacheRead:ze,cacheWrite:Te}}},[n.current,n.current.lastSeq]);return v.jsxs("div",{className:"app",children:[v.jsxs("header",{className:"topbar",children:[v.jsxs("div",{className:"brand",children:[v.jsx("span",{className:"logo"}),"agents-deck ",v.jsxs("span",{className:"v",children:["v","1.30.6"]})]}),gt&&(()=>{const Z=rn(gt.usage,gt.model),te=Math.max(0,((gt.endedAt??Re)-gt.startedAt)/1e3),ce=gt.state==="active"?ku(Z.total,te):null,me=o.size-1;return v.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${gt.label}`,onClick:()=>{try{const _e=Wt.find(we=>we.id===gt.id);_e&&e.fitView({padding:.35,duration:500,nodes:[_e]}),We.current=Date.now()}catch{}},children:[v.jsx("span",{className:`state-pill state-${gt.state}`,children:gt.state==="active"?"live":gt.state}),v.jsx("span",{className:"selected-label",children:gt.label}),Z.total>0&&v.jsxs("span",{className:"selected-cost",children:[He(Z.total),ce?v.jsxs("span",{className:"selected-rate",children:[" · ",ce]}):null]}),me>0&&v.jsxs("span",{className:"selected-extra",children:["+",me]}),v.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:_e=>{_e.stopPropagation(),m()},children:"×"})]})})(),v.jsxs("div",{className:"actions",children:[v.jsxs("div",{className:"search",children:[v.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),v.jsx("input",{ref:It,type:"text",placeholder:"Search agents, cwd, tools…",value:qe,onChange:Z=>Ye(Z.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),qe?v.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Ye(""),children:"×"}):v.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),v.jsxs("span",{className:"status",role:"status",children:[v.jsx("span",{className:`pill ${ue?"live":"dead"}`,title:ue?"Receiving events":"SSE disconnected",children:ue?"live":"offline"}),v.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[v.jsx("span",{className:"count",children:ui}),v.jsx("span",{className:"lbl",children:"sessions"})]}),v.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[v.jsx("span",{className:"count",children:Tr}),v.jsx("span",{className:"lbl",children:"agents"})]}),v.jsxs("span",{className:"stat",title:"Total hook events received",children:[v.jsx("span",{className:"count",children:n.current.totalEvents}),v.jsx("span",{className:"lbl",children:"events"})]}),Mt.sum>0&&v.jsxs("span",{className:"stat",title:`in:${Mt.inT.toLocaleString()} out:${Mt.outT.toLocaleString()} cache-r:${Mt.cacheR.toLocaleString()} cache-c:${Mt.cacheC.toLocaleString()}`,children:[v.jsx("span",{className:"count",children:r$(Mt.sum)}),v.jsx("span",{className:"lbl",children:"tokens"})]}),_n.length>0&&v.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
59
+ burn: ${y}`:"");return v.jsxs("span",{className:"cost-meta",title:x,children:[v.jsx("b",{children:He(p.total)}),y&&v.jsx("span",{className:"cost-rate",children:y})]})})()]}),v.jsx(As,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function xP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return v.jsx("span",{className:`state-pill state-${e}`,children:n})}function _P(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function SP({tools:e,now:n}){const u=new Array(24).fill(0);let l=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(u[N]+=1,l+=1)}const c=Math.max(1,...u),d=132,h=14,p=d/24,m=c/(2500/1e3);return v.jsxs("div",{className:"tool-spark-row",title:`${l} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[v.jsx("svg",{className:"tool-spark",width:d,height:h,viewBox:`0 0 ${d} ${h}`,"aria-hidden":!0,children:u.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return v.jsx("rect",{x:x*p+.4,y:h-N,width:Math.max(.5,p-1),height:N,rx:.8,className:b},x)})}),v.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Bo(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(),u=n[2].replace(/[-_]/g,".");return`${o} ${u}`}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 Bw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function bP(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 kP({tool:e,onClose:n}){q.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 v.jsx("div",{className:"modal-backdrop",onClick:n,role:"dialog","aria-modal":"true",children:v.jsxs("div",{className:"modal",onClick:s=>s.stopPropagation(),children:[v.jsxs("header",{className:"modal-head",children:[v.jsxs("div",{className:"modal-title",children:[v.jsx("span",{className:`status-dot ${i}`}),v.jsx("span",{className:"modal-tool-name",children:e.name}),v.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),v.jsxs("div",{className:"modal-actions",children:[v.jsx("span",{className:"modal-dur",children:bP(e)}),v.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),v.jsxs("section",{className:"modal-body",children:[v.jsxs("div",{className:"modal-section",children:[v.jsx("h4",{children:"Input"}),v.jsx("pre",{children:Bw(e.input??e.inputPreview)})]}),v.jsxs("div",{className:"modal-section",children:[v.jsxs("h4",{children:["Response ",i==="err"&&v.jsx("span",{className:"err-tag",children:"error"})]}),v.jsx("pre",{children:e.endedAt==null?"(waiting…)":Bw(e.response??e.errorPreview)})]})]})]})})}const su=18,Uw=26,EP=12;function NP(e){const n=new Map;for(const o of e.nodeInternals.values()){const u=o.data;if(!(u!=null&&u.sessionId)||u.exitAt!=null||o.width==null||o.height==null)continue;const l=o.position.x,c=o.position.y,d=l+o.width,h=c+o.height,p=n.get(u.sessionId);p?(p.minX=Math.min(p.minX,l),p.minY=Math.min(p.minY,c),p.maxX=Math.max(p.maxX,d),p.maxY=Math.max(p.maxY,h),u.kind==="root"&&(p.label=Hw(u)??p.label)):n.set(u.sessionId,{minX:l,minY:c,maxX:d,maxY:h,label:Hw(u)??u.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,u]of n){const c=(i.get(u.label)??0)>1?`${u.label} · ${CP(o)}`:u.label;s.push({sessionId:o,label:c,x:u.minX-su,y:u.minY-su-Uw,w:u.maxX-u.minX+su*2,h:u.maxY-u.minY+su*2+Uw})}return s}function CP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Hw(e){if(e.kind==="root")return e.label}function TP(){const{x:e,y:n,zoom:i}=UE(),s=zo(),o=Xe(NP,RP);if(o.length<=1)return null;const u=l=>{try{const c=s.getNodes().filter(d=>{const h=d.data;return(h==null?void 0:h.sessionId)===l});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return v.jsx("div",{className:"session-clusters",children:o.map(l=>{const c=Zg(l.sessionId),d={position:"absolute",left:l.x*i+e,top:l.y*i+n,width:l.w*i,height:l.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:l.x*i+e+16*i,top:(l.y-EP)*i+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return v.jsxs(oe.Fragment,{children:[v.jsx("div",{className:"cluster-card",style:d,"aria-hidden":!0}),v.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${l.label} · drag the wrapper to move the whole session`,onClick:()=>u(l.sessionId),children:l.label})]},l.sessionId)})})}function RP(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 jP({data:e}){return v.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const JE=600,AP=36,Rg=16,IP=60,MP=6,Vw=220,Ww=96,PP=28,OP={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 qP(e){return e.startsWith("mcp__")?"mcp":OP[e]??"other"}const LP={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 Gw(e){return e.startsWith("mcp__")?"🔌":LP[e]??"✨"}const $P={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 eN(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 eN(i[1]);for(;;){const u=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!u)break;n=n.slice(u[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 DP(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 FP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),zP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function BP(e,n){return zP.has(e)?Math.max(Ww,34+n.length*7.5):Ww}function UP(e,n){if(!FP.has(e))return null;const i=DP(n);if(!i)return null;const s=eN(i);return s?{emoji:$P[s]??"⚙️",label:s,category:"shell",detail:i}:null}const HP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Yw={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:"🗄️"},Kw={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 VP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function WP(e){const n=e.toLowerCase();if(Kw[n])return Kw[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(Yw[s])return Yw[s]}return"📄"}function GP(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 YP(e,n){if(!HP.has(e))return null;const i=GP(e,n);if(!i)return null;const s=VP(i);return s?{emoji:e==="LS"?"📂":WP(s),label:s,category:"file",detail:i}:null}const tN={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 nN(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 KP(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 XP(e,n){const i=nN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const u=tN[s.toLowerCase()];return{emoji:(u==null?void 0:u.emoji)??"🔌",label:o,category:"mcp",detail:u?`${u.name} · ${o}`:`${s} · ${o}`}}function QP(e,n){return UP(e,n)??YP(e,n)??XP(e)}const ZP={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function JP(e){const n=nN(e);if(n){const s=tN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:KP(n.server)}}const i=ZP[e];return i?{emoji:Gw(e),label:i}:{emoji:Gw(e),label:e}}function e3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function t3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/JE)}function n3(e,n,i,s,o,u){const l=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&u-c.exitAt>JE)continue;const d=s.get(c.id)??i.get(c.id);if(!d)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)??Vw,Vw),x=(m==null?void 0:m.height)??130,N=d.x,_=d.y,S=N+y,b=_+x/2;h.forEach((k,E)=>{const C=E*AP,A=N+y+IP,P=_+MP+C,I=t3(k,u,p),M=k.inputPreview??"",R=e3(k),L=I<.999,F=JP(k.name);l.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:F.label,emoji:F.emoji,status:R,category:qP(k.name),mcpHue:F.hue,inputPreview:M,fade:I,fading:L,worldX:A,worldY:P,anchorX:S,anchorY:b,spawnDx:S-A,spawnDy:b-(P+Rg)});const Q=QP(k.name,k.input);if(Q){const X=BP(k.name,F.label),j=A+X+PP,G=P,U=A+X,ne=P+Rg;l.push({id:`sub:${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:Q.label,emoji:Q.emoji,isSub:!0,status:R,category:Q.category,inputPreview:Q.detail??M,fade:I,fading:L,worldX:j,worldY:G,anchorX:U,anchorY:ne,spawnDx:U-j,spawnDy:0})}})}return l}function r3({agents:e,visibleAgentIds:n,positions:i,pinned:s,measured:o,dimUnmatched:u,spotlight:l,hiddenCategories:c,now:d,onOpenTool:h}){const{x:p,y:m,zoom:y}=UE(),x=n3(e,n,i,s,o,d),N=c&&c.size>0?x.filter(_=>!c.has(_.category)):x;return v.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[v.jsx("svg",{className:"tool-bursts-svg",children:N.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,k=(_.worldX+6)*y+p,E=(_.worldY+Rg)*y+m,C=S+(k-S)*.55,A=u!=null&&!u.has(_.agentId),P=l!=null&&!l.has(_.agentId),I=_.fade*(A||P?.14:1);return v.jsx("path",{d:`M ${S} ${b} Q ${C} ${b}, ${k} ${E}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:I},`l:${_.id}`)})}),N.map(_=>{const S=_.worldX*y+p,b=_.worldY*y+m,k={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},E=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${E} · ${_.inputPreview}`:E,A=h!=null,P=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},I=u!=null&&!u.has(_.agentId),M=l!=null&&!l.has(_.agentId),R=I||M?" dim":"";return v.jsx("div",{className:"tool-burst-wrap",style:k,children:v.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${A?" clickable":""}${_.isSub?" sub":""}${R}`,style:P,title:C,role:A?"button":void 0,tabIndex:A?0:void 0,"aria-label":A?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:A?()=>h(_.toolId):void 0,onKeyDown:A?L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),h(_.toolId))}:void 0,children:[v.jsx("span",{className:"tb-emoji",children:_.emoji}),v.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&v.jsx("span",{className:"tb-spin"}),_.status==="done"&&v.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&v.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function i3({state:e,sessionId:n,onClose:i}){const s=q.useMemo(()=>o3(e,n),[e,n]);return s?v.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:v.jsxs("div",{className:"modal session-summary",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[v.jsxs("div",{className:"modal-head",children:[v.jsxs("div",{className:"modal-title",children:[v.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),v.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),v.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),v.jsxs("div",{className:"modal-actions",children:[v.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),v.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),v.jsxs("div",{className:"modal-body",children:[v.jsxs("section",{className:"ss-hero",children:[v.jsxs("div",{className:"ss-hero-left",children:[v.jsx("div",{className:"ss-cost-label",children:"total spend"}),v.jsx("div",{className:"ss-cost",children:He(s.cost.total)}),s.modelChips.length>0&&v.jsx("div",{className:"ss-models",children:s.modelChips.map(o=>v.jsx("span",{className:"model-chip",title:o,children:Bo(o)},o))})]}),v.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&v.jsxs(v.Fragment,{children:[v.jsx(s3,{cost:s.cost}),v.jsxs("div",{className:"ss-cost-legend",children:[v.jsxs("span",{className:"ssl ssl-in",children:["input ",v.jsx("b",{children:He(s.cost.input)})]}),v.jsxs("span",{className:"ssl ssl-out",children:["output ",v.jsx("b",{children:He(s.cost.output)})]}),v.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",v.jsx("b",{children:He(s.cost.cacheRead)})]}),v.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",v.jsx("b",{children:He(s.cost.cacheWrite)})]})]})]})})]}),v.jsxs("section",{className:"ss-stats",children:[v.jsx(xs,{label:"agents",value:s.agentCount}),v.jsx(xs,{label:"subagents",value:s.subagentCount}),v.jsx(xs,{label:"tool calls",value:s.toolCount}),v.jsx(xs,{label:"prompts",value:s.promptCount}),v.jsx(xs,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&v.jsx(xs,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&v.jsxs("section",{className:"modal-section",children:[v.jsx("h4",{children:"Most-used tools"}),v.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([o,u])=>v.jsxs("div",{className:"ss-tt",children:[v.jsx("span",{className:"ss-tt-name",children:o}),v.jsx("span",{className:"ss-tt-bar",children:v.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/s.topTools[0][1]*100}%`}})}),v.jsx("span",{className:"ss-tt-count",children:u})]},o))})]}),s.firstPrompt&&v.jsxs("section",{className:"modal-section",children:[v.jsx("h4",{children:"Opening prompt"}),v.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function xs({label:e,value:n,tone:i}){return v.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[v.jsx("div",{className:"ss-stat-value",children:n}),v.jsx("div",{className:"ss-stat-label",children:e})]})}function s3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,u)=>{if(s<=0)return null;const l=s/n*100;return v.jsx("span",{className:`cb-seg ${o}`,style:{width:`${l}%`},title:`${u}: ${He(s)} (${l.toFixed(0)}%)`},o)};return v.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 o3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const E of e.agents.values())E.sessionId===n&&s.push(E);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},u=new Set,l=new Map;let c=0,d=0,h=0,p=0,m=0,y,x=1/0,N=0;for(const E of s){const C=rn(E.usage,E.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,E.model&&u.add(E.model),E.kind==="subagent"&&m++,d+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),h+=E.usage.inputTokens+E.usage.outputTokens,c+=E.tools.length,x=Math.min(x,E.startedAt),N=Math.max(N,E.endedAt??Date.now());for(const A of E.tools)l.set(A.name,(l.get(A.name)??0)+1),A.ok===!1&&p++}const _=Math.max(0,N-x),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`,k=Array.from(l.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(u),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:d,tokensSum:h,errCount:p,topTools:k,firstPrompt:y}}function a3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,u=rn(s.usage,s.model).total,l=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.tools.length,u+=rn(c.usage,c.model).total;const d=c.endedAt??c.startedAt;d>l&&(l=d)}i.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:u,startedAt:s.startedAt,lastActivity:l})}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 u3(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 u=Math.floor(o/60);return u<60?`${u}m`:`${Math.floor(u/60)}h ${u%60}m`}function l3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const u=q.useMemo(()=>a3(e),[e,e.lastSeq,n]),l=u.filter(c=>c.state==="active").length;return v.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[v.jsxs("div",{className:"sl-header",children:[v.jsxs("h3",{children:["Sessions ",v.jsx("span",{className:"sl-count",children:u.length})]}),l>0&&v.jsxs("span",{className:"sl-live-count",children:[l," live"]}),v.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),v.jsxs("div",{className:"sl-rows",children:[u.length===0&&v.jsx("div",{className:"sl-empty",children:"No sessions yet."}),u.map(c=>{const d=i.has(c.sessionId);return v.jsxs("button",{type:"button",className:`sl-row state-${c.state}${d?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[v.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),v.jsxs("div",{className:"sl-row-body",children:[v.jsxs("div",{className:"sl-row-head",children:[v.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&v.jsx("span",{className:"model-chip",title:c.modelId,children:Bo(c.modelId)})]}),v.jsxs("div",{className:"sl-row-meta",children:[v.jsxs("span",{title:"tool calls",children:[v.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&v.jsx("span",{className:"sl-cost",title:"total spend",children:v.jsx("b",{children:He(c.cost)})}),v.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:u3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function Xw(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 c3(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 pr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function f3({cost:e}){const n=e.total;if(n<=0)return null;const i=(s,o,u)=>{if(s<=0)return null;const l=s/n*100;return v.jsx("span",{className:`cb-seg ${o}`,style:{width:`${l}%`},title:`${u}: ${He(s)} (${l.toFixed(0)}%)`},o)};return v.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 d3(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 u=Math.floor(i/86400),l=Math.floor(i%86400/3600);return`${u}d ${l}h`}return s>0?`${s}h ${o}m`:`${o}m`}function h3(e,n,i,s){const o=Math.max(0,n-s),u=Math.max(0,i-o);if(u<120)return null;const l=Math.min(100,u/i*100),c=e-l;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:l,isDeficit:!1};if(c>0){const d=100-e,h=u>0?e/u:0,p=h>0?d/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:l,isDeficit:!0};if(p<o&&p<86400){const y=Math.floor(p/3600),x=Math.floor(p%3600/60);m.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:l,isDeficit:!1}}function bi({pct:e,label:n,reset:i,resetAt:s,windowSec:o,limitReached:u,nowSec:l}){const c=Math.min(100,Math.max(0,e)),h=u||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",p=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?d3(s,l):null,x=s&&o?h3(c,s,o,l):null;return v.jsxs("div",{className:"qb-row",children:[v.jsxs("div",{className:"qb-meta",children:[v.jsxs("span",{className:"qb-label",children:[n,u&&v.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),v.jsx("span",{className:"qb-pct",style:{color:h},children:p})]}),v.jsxs("div",{className:"qb-track",children:[v.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),x&&v.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.expectedPct)}% by now`})]}),v.jsxs("div",{className:"qb-reset-row",children:[y?v.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):i?v.jsxs("span",{className:"qb-reset",children:["resets ",i]}):null,x&&v.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const p3=6e4;function m3(){const[e,n]=q.useState(null),[i,s]=q.useState(!1),o=q.useRef(null),u=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 q.useEffect(()=>(u(!0),o.current=window.setInterval(()=>u(!1),p3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>u(!0)}}function g3(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 rN=6e4;function v3(){const[e,n]=q.useState(null),[i,s]=q.useState(!1),o=q.useRef(null),u=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 q.useEffect(()=>(u(!0),o.current=window.setInterval(()=>u(!1),rN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>u(!0)}}function y3(){const[e,n]=q.useState(null),i=q.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return q.useEffect(()=>(s(),i.current=window.setInterval(s,rN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function w3({state:e,now:n,onClose:i}){var I,M;const{quota:s,loading:o,refresh:u}=m3(),{data:l,loading:c,refresh:d}=v3(),{data:h}=y3(),[p,m]=q.useState(()=>Math.floor(Date.now()/1e3));q.useEffect(()=>{const R=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(R)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=q.useMemo(()=>{const R=new Map,L={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let F=0,Q=0,X=0,j=0;for(const D of e.agents.values()){const V=D.model??"__unknown__",O=rn(D.usage,D.model),B=R.get(V);B?(B.inputTokens+=D.usage.inputTokens,B.outputTokens+=D.usage.outputTokens,B.cacheReadTokens+=D.usage.cacheReadTokens,B.cacheCreateTokens+=D.usage.cacheCreateTokens,B.cost.total+=O.total,B.cost.input+=O.input,B.cost.output+=O.output,B.cost.cacheRead+=O.cacheRead,B.cost.cacheWrite+=O.cacheWrite,B.agentCount++):R.set(V,{model:V,inputTokens:D.usage.inputTokens,outputTokens:D.usage.outputTokens,cacheReadTokens:D.usage.cacheReadTokens,cacheCreateTokens:D.usage.cacheCreateTokens,cost:{...O},agentCount:1}),L.total+=O.total,L.input+=O.input,L.output+=O.output,L.cacheRead+=O.cacheRead,L.cacheWrite+=O.cacheWrite,F+=D.usage.inputTokens,Q+=D.usage.outputTokens,X+=D.usage.cacheReadTokens,j+=D.usage.cacheCreateTokens}const G=Array.from(R.values()).sort((D,V)=>V.cost.total-D.cost.total);let U=0,ne=0;for(const D of e.agents.values()){if(D.state!=="active")continue;const V=rn(D.usage,D.model);U+=V.total,ne=Math.max(ne,((D.endedAt??n)-D.startedAt)/1e3)}const K=ne>0?ku(U,ne):null;return{byModel:G,totalCost:L,totalTokens:{in:F,out:Q,cacheR:X,cacheC:j},burnRate:K}},[e,e.lastSeq,n]),S=q.useMemo(()=>{const R=[];for(const L of e.agents.values()){if(L.kind!=="root")continue;let F=rn(L.usage,L.model).total,Q=L.usage.inputTokens,X=L.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==L.sessionId||j.kind==="root"||(F+=rn(j.usage,j.model).total,Q+=j.usage.inputTokens,X+=j.usage.outputTokens);R.push({sessionId:L.sessionId,label:L.label||L.cwdBasename||"session",state:L.state,cost:F,inputTokens:Q,outputTokens:X})}return R.sort((L,F)=>F.cost-L.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=N.in+N.out,E=o||c,C=Xw(s==null?void 0:s.fetchedAt,p),A=Xw(l==null?void 0:l.fetchedAt,p),P=()=>{u(),d()};return v.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[v.jsxs("div",{className:"up-header",children:[v.jsx("h3",{children:"Usage"}),_&&v.jsx("span",{className:"up-rate",children:_}),v.jsxs("div",{className:"up-header-right",children:[v.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:P,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),v.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),v.jsxs("section",{className:"up-section up-quota-section",children:[v.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&v.jsx("span",{className:"up-section-age",title:c3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?v.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&v.jsx(bi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:p}),s.week7dPct!=null&&v.jsx(bi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:p}),s.weekSonnetPct!=null&&v.jsx(bi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:p}),s.weekOpusPct!=null&&v.jsx(bi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:p})]}):(s==null?void 0:s.ok)===!1?v.jsxs("div",{className:"up-quota-na",children:[v.jsx("span",{children:"Quota unavailable."}),v.jsxs("span",{className:"up-quota-hint",children:["Run ",v.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):v.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),v.jsxs("section",{className:"up-section up-quota-section",children:[v.jsxs("h4",{className:"up-section-title",children:["Codex quota",(l==null?void 0:l.ok)&&l.planLabel&&v.jsx("span",{className:"up-plan-badge",children:l.planLabel}),A&&!c&&v.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:A})]}),l!=null&&l.ok?v.jsxs("div",{className:"up-quota-bars",children:[(I=l.windows)==null?void 0:I.map(R=>v.jsx(bi,{label:R.label,pct:R.pct,reset:R.reset??void 0,resetAt:R.resetAt??void 0,windowSec:R.windowSec??void 0,limitReached:l.limitReached&&R.pct>=100,nowSec:p},R.id)),(M=l.extraWindows)==null?void 0:M.map(R=>v.jsx(bi,{label:R.label,pct:R.pct,reset:R.reset??void 0,resetAt:R.resetAt??void 0,windowSec:R.windowSec??void 0,nowSec:p},R.id)),l.creditLimit&&v.jsx(bi,{label:`spend cap · $${Math.round(l.creditLimit.used)} of $${Math.round(l.creditLimit.limit)}`,pct:l.creditLimit.usedPct,reset:l.creditLimit.reset??void 0,resetAt:l.creditLimit.resetAt??void 0,limitReached:l.spendControlReached,nowSec:p}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&v.jsxs("div",{className:"up-quota-sub",children:[pr(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),l.creditsBalance&&!l.creditsUnlimited&&v.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",l.creditsBalance,l.overageReached&&" · overage limit reached"]}),l.creditsUnlimited&&v.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),l.resetCredits&&l.resetCredits.availableCount>0&&v.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[l.resetCredits.availableCount," rate-limit reset",l.resetCredits.availableCount!==1?"s":""," available",l.resetCredits.nextExpiryAt&&` · expires ${new Date(l.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),l.promo&&v.jsx("div",{className:"up-quota-sub",children:l.promo}),l.partial&&v.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(l==null?void 0:l.ok)===!1?v.jsxs("div",{className:"up-quota-na",children:[v.jsx("span",{children:"Quota unavailable."}),v.jsx("span",{className:"up-quota-hint",children:g3(l.reason)})]}):v.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"up-total",children:[v.jsx("span",{className:"up-total-value",children:He(x.total)}),v.jsx("span",{className:"up-total-label",children:"total spend"})]}),v.jsx(f3,{cost:x}),k>0&&v.jsxs("div",{className:"up-tokens-row",children:[v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"in"}),pr(N.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),pr(N.out)]}),N.cacheR>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache r"}),pr(N.cacheR)]}),N.cacheC>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache c"}),pr(N.cacheC)]})]}),y.filter(R=>R.cost.total>0).length>0&&v.jsxs("section",{className:"up-section",children:[v.jsx("h4",{className:"up-section-title",children:"By model"}),v.jsxs("table",{className:"up-table",children:[v.jsx("thead",{children:v.jsxs("tr",{children:[v.jsx("th",{children:"Model"}),v.jsx("th",{children:"Tokens"}),v.jsx("th",{children:"Cost"})]})}),v.jsx("tbody",{children:y.filter(R=>R.cost.total>0).map(R=>v.jsxs("tr",{children:[v.jsx("td",{className:"up-model-name",title:R.model,children:Bo(R.model)}),v.jsx("td",{className:"up-num",children:pr(R.inputTokens+R.outputTokens)}),v.jsx("td",{className:"up-num up-cost-val",children:He(R.cost.total)})]},R.model))})]})]}),S.filter(R=>R.cost>0).length>0&&v.jsxs("section",{className:"up-section",children:[v.jsx("h4",{className:"up-section-title",children:"By session"}),v.jsx("div",{className:"up-sessions",children:S.filter(R=>R.cost>0).map(R=>v.jsxs("div",{className:"up-session-row",children:[v.jsx("span",{className:`sl-dot state-${R.state}`,"aria-hidden":!0}),v.jsx("span",{className:"up-session-label",children:R.label}),v.jsx("span",{className:"up-session-tokens",children:pr(R.inputTokens+R.outputTokens)}),v.jsx("span",{className:"up-session-cost",children:He(R.cost)})]},R.sessionId))})]})]}):k>0?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"up-tokens-row",children:[v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"in"}),pr(N.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),pr(N.out)]})]}),v.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):v.jsxs("div",{className:"up-empty",children:["No usage data yet.",v.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const x3=15e3,_3=[70,80,85,90,95];function S3(e,n){const i=e-n;if(i<=0)return null;const s=Math.floor(i/86400),o=Math.floor(i%86400/3600),u=Math.floor(i%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${u}m`:`${u}m`}function Qw(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 b3(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 k3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function E3({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?S3(e.resetAt,n):null;return v.jsxs("div",{className:"ap-lane",children:[v.jsx("span",{className:"ap-lane-label",children:e.label}),v.jsx("div",{className:"ap-lane-track",children:v.jsx("div",{className:"ap-lane-fill",style:{width:`${i===0?1.5:i}%`,background:s,opacity:i===0?.4:1}})}),v.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[i,"%"]}),v.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function N3({onClose:e}){var A,P,I;const[n,i]=q.useState(null),[s,o]=q.useState(null),[u,l]=q.useState(null),[c,d]=q.useState(null),[h,p]=q.useState(null),[m,y]=q.useState(()=>Math.floor(Date.now()/1e3)),x=q.useRef(null),N=q.useCallback(async(M=!1)=>{try{const[R,L]=await Promise.all([fetch(`/api/claude-accounts${M?"?refresh=1":""}`),fetch("/api/cswap-auto")]);R.ok&&i(await R.json()),L.ok&&o(await L.json())}catch{}},[]),_=q.useCallback(async(M,R)=>{l(R),p(null);try{const F=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)})).json().catch(()=>null);return F!=null&&F.ok||p((F==null?void 0:F.detail)||(F==null?void 0:F.reason)||"command failed"),F}catch{return p("server unreachable"),null}finally{l(null)}},[]);q.useEffect(()=>(N(!0),x.current=window.setInterval(()=>N(!1),x3),()=>{x.current!=null&&window.clearInterval(x.current)}),[N]),q.useEffect(()=>{const M=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(M)},[]);const S=((A=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:A.value)??"90",b=(P=n==null?void 0:n.accounts)==null?void 0:P.find(M=>M.active),k=b!=null&&b.lanes.length?Math.max(...b.lanes.map(M=>M.pct)):null,E=k!=null&&k>=Number(S)-15,C=async M=>{d(M),p(null);try{const L=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:M})})).json().catch(()=>null);L!=null&&L.ok||p((L==null?void 0:L.output)||(L==null?void 0:L.reason)||"switch failed"),await N(!0)}catch{p("server unreachable")}finally{d(null)}};return v.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[v.jsxs("div",{className:"ap-header",children:[v.jsx("h3",{children:"Accounts"}),v.jsxs("div",{className:"ap-header-right",children:[v.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>N(!0),title:"Reload from claude-swap",children:"↻"}),v.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?v.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?v.jsxs(v.Fragment,{children:[(I=n.accounts)==null?void 0:I.map(M=>v.jsxs("div",{className:`ap-account${M.active?" active":""}${M.disabled?" disabled":""}`,children:[v.jsxs("div",{className:"ap-account-head",children:[v.jsx("span",{className:"ap-num",children:M.num}),M.alias&&v.jsx("span",{className:"ap-alias",children:M.alias}),v.jsx("span",{className:"ap-email",title:M.org??void 0,children:M.email}),M.active?v.jsx("span",{className:"ap-badge-active",children:"● active"}):v.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||M.disabled,onClick:()=>C(M.num),title:M.disabled?"Held out of rotation":`Switch to ${M.alias??M.email}`,children:c===M.num?"…":"switch"})]}),M.lanes.length>0?M.lanes.map(R=>v.jsx(E3,{lane:R,nowSec:m},R.id)):v.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),v.jsxs("div",{className:"ap-meta",children:[M.error&&v.jsx("span",{className:"ap-err",children:k3(M.error)}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!M.active&&v.jsx("button",{type:"button",className:"ap-rotate",disabled:u!=null,onClick:()=>_({action:"account",account:M.num,enabled:M.disabled},`rot-${M.num}`).then(()=>N(!0)),title:M.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:M.disabled?"held out":"in rotation"}),M.fetchedAt?v.jsxs("span",{className:`ap-age${M.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 ",Qw(M.fetchedAt,m),b3(M.nextAt,m)]}):v.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]})]},M.num)),(s==null?void 0:s.ok)&&v.jsxs("div",{className:"ap-auto",children:[v.jsxs("div",{className:"ap-auto-head",children:[v.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),v.jsxs("span",{className:"ap-auto-ctl",children:[k!=null&&v.jsxs("span",{className:`ap-auto-now${E?" near":""}`,children:[Math.round(k),"%"]}),v.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:v.jsx("select",{"aria-label":"Switch threshold",value:S,disabled:u!=null,onChange:M=>_({action:"setting",key:"autoswitch.threshold",value:M.target.value},"threshold").then(()=>N(!0)),children:_3.map(M=>v.jsxs("option",{value:M,children:[M,"%"]},M))})}),v.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:u!=null,onClick:()=>_({action:"enable",enabled:!s.enabled},"enable").then(()=>N(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[v.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&v.jsxs("p",{className:"ap-auto-note",children:[v.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",v.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&&v.jsx("div",{className:"ap-auto-foot",children:v.jsxs("span",{className:"ap-auto-result",children:["checked ",Qw(s.lastTick.at,m)]})})]}),h&&v.jsx("div",{className:"ap-failure",children:h}),v.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."})]}):v.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"claude-swap isn't installed."}),v.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&&v.jsx("code",{className:"ap-cmd",children:n.hint}),v.jsxs("span",{className:"ap-hint",children:["Then add your accounts with ",v.jsx("code",{children:"cswap add"})," and reload."]})]}):n.reason==="no_accounts"?v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"No accounts added yet."}),v.jsx("span",{className:"ap-hint",children:"claude-swap is installed but has nothing in its store."}),v.jsx("code",{className:"ap-cmd",children:"cswap add"})]}):v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"Couldn't read the account store."}),v.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})})]})}function ki(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 Zw(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function ou(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 C3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const T3=[7,14,30,90];function R3(e){const[n,i]=q.useState(null),[s,o]=q.useState(!1),u=(l=!1)=>{o(!0);const d=`/api/ccusage?since=${C3(e)}${l?"&refresh=1":""}`;fetch(d).then(h=>h.json()).then(i).catch(()=>i({ok:!1,error:"request failed"})).finally(()=>o(!1))};return q.useEffect(()=>{u(!1)},[e]),{data:n,loading:s,reload:()=>u(!0)}}function j3({onClose:e}){var b,k;const[n,i]=q.useState(30),[s,o]=q.useState(null),{data:u,loading:l,reload:c}=R3(n);q.useEffect(()=>{const E=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const d=u!=null&&u.ok?u.days??[]:[],h=q.useMemo(()=>d.reduce((E,C)=>Math.max(E,C.totalCost),0),[d]),{totalCost:p,totalTok:m,inOut:y,cacheRead:x,modelCosts:N}=q.useMemo(()=>{let E=0,C=0,A=0,P=0;const I=new Map;for(const M of d){E+=M.totalCost,C+=M.totalTokens,A+=M.inputTokens+M.outputTokens,P+=M.cacheReadTokens;for(const R of M.modelBreakdowns)I.set(R.modelName,(I.get(R.modelName)??0)+R.cost)}return{totalCost:E,totalTok:C,inOut:A,cacheRead:P,modelCosts:I}},[d]),_=q.useMemo(()=>Array.from(N.entries()).sort((E,C)=>C[1]-E[1]),[N]),S=s?d.find(E=>E.period===s)??null:null;return v.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:v.jsxs("div",{className:"uh-modal",onClick:E=>E.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[v.jsxs("header",{className:"uh-head",children:[v.jsxs("div",{className:"uh-titlewrap",children:[v.jsx("div",{className:"uh-title",children:"Usage history"}),v.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),v.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:T3.map(E=>v.jsxs("button",{role:"tab","aria-selected":n===E,className:`uh-range-btn${n===E?" on":""}`,onClick:()=>{i(E),o(null)},children:[E,"d"]},E))}),v.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),v.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),l&&d.length===0?v.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):u&&!u.ok?v.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",u.error]}):d.length===0?v.jsx("div",{className:"uh-status",children:"no usage in this range"}):v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"uh-totals",children:[v.jsx(au,{label:"total cost",val:He(p),accent:!0}),v.jsx(au,{label:"tokens",val:ki(m)}),v.jsx(au,{label:"input+output",val:ki(y)}),v.jsx(au,{label:"cache reads",val:ki(x)})]}),v.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:d.map(E=>{const C=h>0?E.totalCost/h*100:0,A=E.period===s;return v.jsxs("button",{className:`uh-bar-col${A?" sel":""}`,onClick:()=>o(A?null:E.period),title:`${E.period} · ${He(E.totalCost)}`,style:{flexBasis:`${100/d.length}%`},children:[v.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,E.totalCost>0?2:0)}%`},children:E.modelBreakdowns.slice().sort((P,I)=>I.cost-P.cost).map(P=>{const I=E.totalCost>0?P.cost/E.totalCost*100:0;return v.jsx("div",{className:"uh-bar-seg",style:{height:`${I}%`,background:ou(P.modelName)}},P.modelName)})}),v.jsx("span",{className:"uh-bar-label",children:E.period.slice(5)})]},E.period)})}),v.jsx("div",{className:"uh-legend",children:_.map(([E,C])=>v.jsxs("span",{className:"uh-legend-item",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:ou(E)}}),Zw(E)," ",v.jsx("span",{className:"uh-legend-cost",children:He(C)})]},E))}),S&&v.jsxs("div",{className:"uh-detail",children:[v.jsxs("div",{className:"uh-detail-head",children:[v.jsx("span",{className:"uh-detail-date",children:S.period}),v.jsx("span",{className:"uh-detail-cost",children:He(S.totalCost)}),(k=(b=S.metadata)==null?void 0:b.agents)!=null&&k.length?v.jsx("span",{className:"uh-detail-agents",children:S.metadata.agents.join(" · ")}):null]}),v.jsxs("div",{className:"uh-detail-mini",children:[v.jsx(uu,{label:"input",val:ki(S.inputTokens)}),v.jsx(uu,{label:"output",val:ki(S.outputTokens)}),v.jsx(uu,{label:"cache write",val:ki(S.cacheCreationTokens)}),v.jsx(uu,{label:"cache read",val:ki(S.cacheReadTokens)})]}),v.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((E,C)=>C.cost-E.cost).map(E=>{const C=S.totalCost>0?E.cost/S.totalCost*100:0;return v.jsxs("div",{className:"uh-model-row",children:[v.jsxs("span",{className:"uh-model-name",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:ou(E.modelName)}}),Zw(E.modelName)]}),v.jsx("span",{className:"uh-model-bar",children:v.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:ou(E.modelName)}})}),v.jsx("span",{className:"uh-model-cost",children:He(E.cost)})]},E.modelName)})})]})]})]})})}function au({label:e,val:n,accent:i}){return v.jsxs("div",{className:"uh-stat",children:[v.jsx("span",{className:`uh-stat-val${i?" accent":""}`,children:n}),v.jsx("span",{className:"uh-stat-label",children:e})]})}function uu({label:e,val:n}){return v.jsxs("div",{className:"uh-ministat",children:[v.jsx("span",{className:"uh-ministat-val",children:n}),v.jsx("span",{className:"uh-ministat-label",children:e})]})}function ev(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 Wc,Jw;function A3(){if(Jw)return Wc;Jw=1;function e(){this.__data__=[],this.size=0}return Wc=e,Wc}var Gc,ex;function Is(){if(ex)return Gc;ex=1;function e(n,i){return n===i||n!==n&&i!==i}return Gc=e,Gc}var Yc,tx;function Mu(){if(tx)return Yc;tx=1;var e=Is();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return Yc=n,Yc}var Kc,nx;function I3(){if(nx)return Kc;nx=1;var e=Mu(),n=Array.prototype,i=n.splice;function s(o){var u=this.__data__,l=e(u,o);if(l<0)return!1;var c=u.length-1;return l==c?u.pop():i.call(u,l,1),--this.size,!0}return Kc=s,Kc}var Xc,rx;function M3(){if(rx)return Xc;rx=1;var e=Mu();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return Xc=n,Xc}var Qc,ix;function P3(){if(ix)return Qc;ix=1;var e=Mu();function n(i){return e(this.__data__,i)>-1}return Qc=n,Qc}var Zc,sx;function O3(){if(sx)return Zc;sx=1;var e=Mu();function n(i,s){var o=this.__data__,u=e(o,i);return u<0?(++this.size,o.push([i,s])):o[u][1]=s,this}return Zc=n,Zc}var Jc,ox;function Pu(){if(ox)return Jc;ox=1;var e=A3(),n=I3(),i=M3(),s=P3(),o=O3();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return u.prototype.clear=e,u.prototype.delete=n,u.prototype.get=i,u.prototype.has=s,u.prototype.set=o,Jc=u,Jc}var ef,ax;function q3(){if(ax)return ef;ax=1;var e=Pu();function n(){this.__data__=new e,this.size=0}return ef=n,ef}var tf,ux;function L3(){if(ux)return tf;ux=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return tf=e,tf}var nf,lx;function $3(){if(lx)return nf;lx=1;function e(n){return this.__data__.get(n)}return nf=e,nf}var rf,cx;function D3(){if(cx)return rf;cx=1;function e(n){return this.__data__.has(n)}return rf=e,rf}var sf,fx;function iN(){if(fx)return sf;fx=1;var e=typeof Ya=="object"&&Ya&&Ya.Object===Object&&Ya;return sf=e,sf}var of,dx;function Gn(){if(dx)return of;dx=1;var e=iN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return of=i,of}var af,hx;function Ms(){if(hx)return af;hx=1;var e=Gn(),n=e.Symbol;return af=n,af}var uf,px;function F3(){if(px)return uf;px=1;var e=Ms(),n=Object.prototype,i=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function u(l){var c=i.call(l,o),d=l[o];try{l[o]=void 0;var h=!0}catch{}var p=s.call(l);return h&&(c?l[o]=d:delete l[o]),p}return uf=u,uf}var lf,mx;function z3(){if(mx)return lf;mx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return lf=i,lf}var cf,gx;function Pi(){if(gx)return cf;gx=1;var e=Ms(),n=F3(),i=z3(),s="[object Null]",o="[object Undefined]",u=e?e.toStringTag:void 0;function l(c){return c==null?c===void 0?o:s:u&&u in Object(c)?n(c):i(c)}return cf=l,cf}var ff,vx;function An(){if(vx)return ff;vx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return ff=e,ff}var df,yx;function Uo(){if(yx)return df;yx=1;var e=Pi(),n=An(),i="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",u="[object Proxy]";function l(c){if(!n(c))return!1;var d=e(c);return d==s||d==o||d==i||d==u}return df=l,df}var hf,wx;function B3(){if(wx)return hf;wx=1;var e=Gn(),n=e["__core-js_shared__"];return hf=n,hf}var pf,xx;function U3(){if(xx)return pf;xx=1;var e=B3(),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 pf=i,pf}var mf,_x;function sN(){if(_x)return mf;_x=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 mf=i,mf}var gf,Sx;function H3(){if(Sx)return gf;Sx=1;var e=Uo(),n=U3(),i=An(),s=sN(),o=/[\\^$.*+?()[\]{}|]/g,u=/^\[object .+?Constructor\]$/,l=Function.prototype,c=Object.prototype,d=l.toString,h=c.hasOwnProperty,p=RegExp("^"+d.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!i(y)||n(y))return!1;var x=e(y)?p:u;return x.test(s(y))}return gf=m,gf}var vf,bx;function V3(){if(bx)return vf;bx=1;function e(n,i){return n==null?void 0:n[i]}return vf=e,vf}var yf,kx;function Oi(){if(kx)return yf;kx=1;var e=H3(),n=V3();function i(s,o){var u=n(s,o);return e(u)?u:void 0}return yf=i,yf}var wf,Ex;function tv(){if(Ex)return wf;Ex=1;var e=Oi(),n=Gn(),i=e(n,"Map");return wf=i,wf}var xf,Nx;function Ou(){if(Nx)return xf;Nx=1;var e=Oi(),n=e(Object,"create");return xf=n,xf}var _f,Cx;function W3(){if(Cx)return _f;Cx=1;var e=Ou();function n(){this.__data__=e?e(null):{},this.size=0}return _f=n,_f}var Sf,Tx;function G3(){if(Tx)return Sf;Tx=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return Sf=e,Sf}var bf,Rx;function Y3(){if(Rx)return bf;Rx=1;var e=Ou(),n="__lodash_hash_undefined__",i=Object.prototype,s=i.hasOwnProperty;function o(u){var l=this.__data__;if(e){var c=l[u];return c===n?void 0:c}return s.call(l,u)?l[u]:void 0}return bf=o,bf}var kf,jx;function K3(){if(jx)return kf;jx=1;var e=Ou(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var u=this.__data__;return e?u[o]!==void 0:i.call(u,o)}return kf=s,kf}var Ef,Ax;function X3(){if(Ax)return Ef;Ax=1;var e=Ou(),n="__lodash_hash_undefined__";function i(s,o){var u=this.__data__;return this.size+=this.has(s)?0:1,u[s]=e&&o===void 0?n:o,this}return Ef=i,Ef}var Nf,Ix;function Q3(){if(Ix)return Nf;Ix=1;var e=W3(),n=G3(),i=Y3(),s=K3(),o=X3();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return u.prototype.clear=e,u.prototype.delete=n,u.prototype.get=i,u.prototype.has=s,u.prototype.set=o,Nf=u,Nf}var Cf,Mx;function Z3(){if(Mx)return Cf;Mx=1;var e=Q3(),n=Pu(),i=tv();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return Cf=s,Cf}var Tf,Px;function J3(){if(Px)return Tf;Px=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Tf=e,Tf}var Rf,Ox;function qu(){if(Ox)return Rf;Ox=1;var e=J3();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Rf=n,Rf}var jf,qx;function eO(){if(qx)return jf;qx=1;var e=qu();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return jf=n,jf}var Af,Lx;function tO(){if(Lx)return Af;Lx=1;var e=qu();function n(i){return e(this,i).get(i)}return Af=n,Af}var If,$x;function nO(){if($x)return If;$x=1;var e=qu();function n(i){return e(this,i).has(i)}return If=n,If}var Mf,Dx;function rO(){if(Dx)return Mf;Dx=1;var e=qu();function n(i,s){var o=e(this,i),u=o.size;return o.set(i,s),this.size+=o.size==u?0:1,this}return Mf=n,Mf}var Pf,Fx;function nv(){if(Fx)return Pf;Fx=1;var e=Z3(),n=eO(),i=tO(),s=nO(),o=rO();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return u.prototype.clear=e,u.prototype.delete=n,u.prototype.get=i,u.prototype.has=s,u.prototype.set=o,Pf=u,Pf}var Of,zx;function iO(){if(zx)return Of;zx=1;var e=Pu(),n=tv(),i=nv(),s=200;function o(u,l){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!n||d.length<s-1)return d.push([u,l]),this.size=++c.size,this;c=this.__data__=new i(d)}return c.set(u,l),this.size=c.size,this}return Of=o,Of}var qf,Bx;function Lu(){if(Bx)return qf;Bx=1;var e=Pu(),n=q3(),i=L3(),s=$3(),o=D3(),u=iO();function l(c){var d=this.__data__=new e(c);this.size=d.size}return l.prototype.clear=n,l.prototype.delete=i,l.prototype.get=s,l.prototype.has=o,l.prototype.set=u,qf=l,qf}var Lf,Ux;function rv(){if(Ux)return Lf;Ux=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 Lf=e,Lf}var $f,Hx;function oN(){if(Hx)return $f;Hx=1;var e=Oi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return $f=n,$f}var Df,Vx;function $u(){if(Vx)return Df;Vx=1;var e=oN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Df=n,Df}var Ff,Wx;function Du(){if(Wx)return Ff;Wx=1;var e=$u(),n=Is(),i=Object.prototype,s=i.hasOwnProperty;function o(u,l,c){var d=u[l];(!(s.call(u,l)&&n(d,c))||c===void 0&&!(l in u))&&e(u,l,c)}return Ff=o,Ff}var zf,Gx;function Ho(){if(Gx)return zf;Gx=1;var e=Du(),n=$u();function i(s,o,u,l){var c=!u;u||(u={});for(var d=-1,h=o.length;++d<h;){var p=o[d],m=l?l(u[p],s[p],p,u,s):void 0;m===void 0&&(m=s[p]),c?n(u,p,m):e(u,p,m)}return u}return zf=i,zf}var Bf,Yx;function sO(){if(Yx)return Bf;Yx=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return Bf=e,Bf}var Uf,Kx;function rr(){if(Kx)return Uf;Kx=1;function e(n){return n!=null&&typeof n=="object"}return Uf=e,Uf}var Hf,Xx;function oO(){if(Xx)return Hf;Xx=1;var e=Pi(),n=rr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return Hf=s,Hf}var Vf,Qx;function Vo(){if(Qx)return Vf;Qx=1;var e=oO(),n=rr(),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,u=e((function(){return arguments})())?e:function(l){return n(l)&&s.call(l,"callee")&&!o.call(l,"callee")};return Vf=u,Vf}var Wf,Zx;function yt(){if(Zx)return Wf;Zx=1;var e=Array.isArray;return Wf=e,Wf}var Eo={exports:{}},Gf,Jx;function aO(){if(Jx)return Gf;Jx=1;function e(){return!1}return Gf=e,Gf}Eo.exports;var e1;function Ps(){return e1||(e1=1,(function(e,n){var i=Gn(),s=aO(),o=n&&!n.nodeType&&n,u=o&&!0&&e&&!e.nodeType&&e,l=u&&u.exports===o,c=l?i.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||s;e.exports=h})(Eo,Eo.exports)),Eo.exports}var Yf,t1;function Fu(){if(t1)return Yf;t1=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function i(s,o){var u=typeof s;return o=o??e,!!o&&(u=="number"||u!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return Yf=i,Yf}var Kf,n1;function iv(){if(n1)return Kf;n1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return Kf=n,Kf}var Xf,r1;function uO(){if(r1)return Xf;r1=1;var e=Pi(),n=iv(),i=rr(),s="[object Arguments]",o="[object Array]",u="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",p="[object Number]",m="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",P="[object Int32Array]",I="[object Uint8Array]",M="[object Uint8ClampedArray]",R="[object Uint16Array]",L="[object Uint32Array]",F={};F[k]=F[E]=F[C]=F[A]=F[P]=F[I]=F[M]=F[R]=F[L]=!0,F[s]=F[o]=F[S]=F[u]=F[b]=F[l]=F[c]=F[d]=F[h]=F[p]=F[m]=F[y]=F[x]=F[N]=F[_]=!1;function Q(X){return i(X)&&n(X.length)&&!!F[e(X)]}return Xf=Q,Xf}var Qf,i1;function zu(){if(i1)return Qf;i1=1;function e(n){return function(i){return n(i)}}return Qf=e,Qf}var No={exports:{}};No.exports;var s1;function sv(){return s1||(s1=1,(function(e,n){var i=iN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,u=o&&o.exports===s,l=u&&i.process,c=(function(){try{var d=o&&o.require&&o.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}})();e.exports=c})(No,No.exports)),No.exports}var Zf,o1;function Wo(){if(o1)return Zf;o1=1;var e=uO(),n=zu(),i=sv(),s=i&&i.isTypedArray,o=s?n(s):e;return Zf=o,Zf}var Jf,a1;function aN(){if(a1)return Jf;a1=1;var e=sO(),n=Vo(),i=yt(),s=Ps(),o=Fu(),u=Wo(),l=Object.prototype,c=l.hasOwnProperty;function d(h,p){var m=i(h),y=!m&&n(h),x=!m&&!y&&s(h),N=!m&&!y&&!x&&u(h),_=m||y||x||N,S=_?e(h.length,String):[],b=S.length;for(var k in h)(p||c.call(h,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return Jf=d,Jf}var ed,u1;function Bu(){if(u1)return ed;u1=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return ed=n,ed}var td,l1;function uN(){if(l1)return td;l1=1;function e(n,i){return function(s){return n(i(s))}}return td=e,td}var nd,c1;function lO(){if(c1)return nd;c1=1;var e=uN(),n=e(Object.keys,Object);return nd=n,nd}var rd,f1;function ov(){if(f1)return rd;f1=1;var e=Bu(),n=lO(),i=Object.prototype,s=i.hasOwnProperty;function o(u){if(!e(u))return n(u);var l=[];for(var c in Object(u))s.call(u,c)&&c!="constructor"&&l.push(c);return l}return rd=o,rd}var id,d1;function wr(){if(d1)return id;d1=1;var e=Uo(),n=iv();function i(s){return s!=null&&n(s.length)&&!e(s)}return id=i,id}var sd,h1;function ei(){if(h1)return sd;h1=1;var e=aN(),n=ov(),i=wr();function s(o){return i(o)?e(o):n(o)}return sd=s,sd}var od,p1;function cO(){if(p1)return od;p1=1;var e=Ho(),n=ei();function i(s,o){return s&&e(o,n(o),s)}return od=i,od}var ad,m1;function fO(){if(m1)return ad;m1=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return ad=e,ad}var ud,g1;function dO(){if(g1)return ud;g1=1;var e=An(),n=Bu(),i=fO(),s=Object.prototype,o=s.hasOwnProperty;function u(l){if(!e(l))return i(l);var c=n(l),d=[];for(var h in l)h=="constructor"&&(c||!o.call(l,h))||d.push(h);return d}return ud=u,ud}var ld,v1;function qi(){if(v1)return ld;v1=1;var e=aN(),n=dO(),i=wr();function s(o){return i(o)?e(o,!0):n(o)}return ld=s,ld}var cd,y1;function hO(){if(y1)return cd;y1=1;var e=Ho(),n=qi();function i(s,o){return s&&e(o,n(o),s)}return cd=i,cd}var Co={exports:{}};Co.exports;var w1;function lN(){return w1||(w1=1,(function(e,n){var i=Gn(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,u=o&&o.exports===s,l=u?i.Buffer:void 0,c=l?l.allocUnsafe:void 0;function d(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=d})(Co,Co.exports)),Co.exports}var fd,x1;function cN(){if(x1)return fd;x1=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 fd=e,fd}var dd,_1;function fN(){if(_1)return dd;_1=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,u=0,l=[];++s<o;){var c=n[s];i(c,s,n)&&(l[u++]=c)}return l}return dd=e,dd}var hd,S1;function dN(){if(S1)return hd;S1=1;function e(){return[]}return hd=e,hd}var pd,b1;function av(){if(b1)return pd;b1=1;var e=fN(),n=dN(),i=Object.prototype,s=i.propertyIsEnumerable,o=Object.getOwnPropertySymbols,u=o?function(l){return l==null?[]:(l=Object(l),e(o(l),function(c){return s.call(l,c)}))}:n;return pd=u,pd}var md,k1;function pO(){if(k1)return md;k1=1;var e=Ho(),n=av();function i(s,o){return e(s,n(s),o)}return md=i,md}var gd,E1;function uv(){if(E1)return gd;E1=1;function e(n,i){for(var s=-1,o=i.length,u=n.length;++s<o;)n[u+s]=i[s];return n}return gd=e,gd}var vd,N1;function Uu(){if(N1)return vd;N1=1;var e=uN(),n=e(Object.getPrototypeOf,Object);return vd=n,vd}var yd,C1;function hN(){if(C1)return yd;C1=1;var e=uv(),n=Uu(),i=av(),s=dN(),o=Object.getOwnPropertySymbols,u=o?function(l){for(var c=[];l;)e(c,i(l)),l=n(l);return c}:s;return yd=u,yd}var wd,T1;function mO(){if(T1)return wd;T1=1;var e=Ho(),n=hN();function i(s,o){return e(s,n(s),o)}return wd=i,wd}var xd,R1;function pN(){if(R1)return xd;R1=1;var e=uv(),n=yt();function i(s,o,u){var l=o(s);return n(s)?l:e(l,u(s))}return xd=i,xd}var _d,j1;function mN(){if(j1)return _d;j1=1;var e=pN(),n=av(),i=ei();function s(o){return e(o,i,n)}return _d=s,_d}var Sd,A1;function gO(){if(A1)return Sd;A1=1;var e=pN(),n=hN(),i=qi();function s(o){return e(o,i,n)}return Sd=s,Sd}var bd,I1;function vO(){if(I1)return bd;I1=1;var e=Oi(),n=Gn(),i=e(n,"DataView");return bd=i,bd}var kd,M1;function yO(){if(M1)return kd;M1=1;var e=Oi(),n=Gn(),i=e(n,"Promise");return kd=i,kd}var Ed,P1;function gN(){if(P1)return Ed;P1=1;var e=Oi(),n=Gn(),i=e(n,"Set");return Ed=i,Ed}var Nd,O1;function wO(){if(O1)return Nd;O1=1;var e=Oi(),n=Gn(),i=e(n,"WeakMap");return Nd=i,Nd}var Cd,q1;function Os(){if(q1)return Cd;q1=1;var e=vO(),n=tv(),i=yO(),s=gN(),o=wO(),u=Pi(),l=sN(),c="[object Map]",d="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",x=l(e),N=l(n),_=l(i),S=l(s),b=l(o),k=u;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||i&&k(i.resolve())!=h||s&&k(new s)!=p||o&&k(new o)!=m)&&(k=function(E){var C=u(E),A=C==d?E.constructor:void 0,P=A?l(A):"";if(P)switch(P){case x:return y;case N:return c;case _:return h;case S:return p;case b:return m}return C}),Cd=k,Cd}var Td,L1;function xO(){if(L1)return Td;L1=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s){var o=s.length,u=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(u.index=s.index,u.input=s.input),u}return Td=i,Td}var Rd,$1;function vN(){if($1)return Rd;$1=1;var e=Gn(),n=e.Uint8Array;return Rd=n,Rd}var jd,D1;function lv(){if(D1)return jd;D1=1;var e=vN();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return jd=n,jd}var Ad,F1;function _O(){if(F1)return Ad;F1=1;var e=lv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Ad=n,Ad}var Id,z1;function SO(){if(z1)return Id;z1=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return Id=n,Id}var Md,B1;function bO(){if(B1)return Md;B1=1;var e=Ms(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Md=s,Md}var Pd,U1;function yN(){if(U1)return Pd;U1=1;var e=lv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Pd=n,Pd}var Od,H1;function kO(){if(H1)return Od;H1=1;var e=lv(),n=_O(),i=SO(),s=bO(),o=yN(),u="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",A="[object Uint8ClampedArray]",P="[object Uint16Array]",I="[object Uint32Array]";function M(R,L,F){var Q=R.constructor;switch(L){case x:return e(R);case u:case l:return new Q(+R);case N:return n(R,F);case _:case S:case b:case k:case E:case C:case A:case P:case I:return o(R,F);case c:return new Q;case d:case m:return new Q(R);case h:return i(R);case p:return new Q;case y:return s(R)}}return Od=M,Od}var qd,V1;function wN(){if(V1)return qd;V1=1;var e=An(),n=Object.create,i=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var u=new s;return s.prototype=void 0,u}})();return qd=i,qd}var Ld,W1;function xN(){if(W1)return Ld;W1=1;var e=wN(),n=Uu(),i=Bu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Ld=s,Ld}var $d,G1;function EO(){if(G1)return $d;G1=1;var e=Os(),n=rr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return $d=s,$d}var Dd,Y1;function NO(){if(Y1)return Dd;Y1=1;var e=EO(),n=zu(),i=sv(),s=i&&i.isMap,o=s?n(s):e;return Dd=o,Dd}var Fd,K1;function CO(){if(K1)return Fd;K1=1;var e=Os(),n=rr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Fd=s,Fd}var zd,X1;function TO(){if(X1)return zd;X1=1;var e=CO(),n=zu(),i=sv(),s=i&&i.isSet,o=s?n(s):e;return zd=o,zd}var Bd,Q1;function _N(){if(Q1)return Bd;Q1=1;var e=Lu(),n=rv(),i=Du(),s=cO(),o=hO(),u=lN(),l=cN(),c=pO(),d=mO(),h=mN(),p=gO(),m=Os(),y=xO(),x=kO(),N=xN(),_=yt(),S=Ps(),b=NO(),k=An(),E=TO(),C=ei(),A=qi(),P=1,I=2,M=4,R="[object Arguments]",L="[object Array]",F="[object Boolean]",Q="[object Date]",X="[object Error]",j="[object Function]",G="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",K="[object Object]",D="[object RegExp]",V="[object Set]",O="[object String]",B="[object Symbol]",ae="[object WeakMap]",z="[object ArrayBuffer]",W="[object DataView]",J="[object Float32Array]",se="[object Float64Array]",ue="[object Int8Array]",he="[object Int16Array]",ge="[object Int32Array]",Me="[object Uint8Array]",Fe="[object Uint8ClampedArray]",Re="[object Uint16Array]",Pe="[object Uint32Array]",be={};be[R]=be[L]=be[z]=be[W]=be[F]=be[Q]=be[J]=be[se]=be[ue]=be[he]=be[ge]=be[U]=be[ne]=be[K]=be[D]=be[V]=be[O]=be[B]=be[Me]=be[Fe]=be[Re]=be[Pe]=!0,be[X]=be[j]=be[ae]=!1;function Oe(ve,ye,qe,Ye,Qe,et){var Be,Ze=ye&P,At=ye&I,Vt=ye&M;if(qe&&(Be=Qe?qe(ve,Ye,Qe,et):qe(ve)),Be!==void 0)return Be;if(!k(ve))return ve;var It=_(ve);if(It){if(Be=y(ve),!Ze)return l(ve,Be)}else{var pt=m(ve),tt=pt==j||pt==G;if(S(ve))return u(ve,Ze);if(pt==K||pt==R||tt&&!Qe){if(Be=At||tt?{}:N(ve),!Ze)return At?d(ve,o(Be,ve)):c(ve,s(Be,ve))}else{if(!be[pt])return Qe?ve:{};Be=x(ve,pt,Ze)}}et||(et=new e);var kt=et.get(ve);if(kt)return kt;et.set(ve,Be),E(ve)?ve.forEach(function(Ge){Be.add(Oe(Ge,ye,qe,Ge,ve,et))}):b(ve)&&ve.forEach(function(Ge,ft){Be.set(ft,Oe(Ge,ye,qe,ft,ve,et))});var We=Vt?At?p:h:At?A:C,Et=It?void 0:We(ve);return n(Et||ve,function(Ge,ft){Et&&(ft=Ge,Ge=ve[ft]),i(Be,ft,Oe(Ge,ye,qe,ft,ve,et))}),Be}return Bd=Oe,Bd}var Ud,Z1;function RO(){if(Z1)return Ud;Z1=1;var e=_N(),n=4;function i(s){return e(s,n)}return Ud=i,Ud}var Hd,J1;function cv(){if(J1)return Hd;J1=1;function e(n){return function(){return n}}return Hd=e,Hd}var Vd,e_;function jO(){if(e_)return Vd;e_=1;function e(n){return function(i,s,o){for(var u=-1,l=Object(i),c=o(i),d=c.length;d--;){var h=c[n?d:++u];if(s(l[h],h,l)===!1)break}return i}}return Vd=e,Vd}var Wd,t_;function fv(){if(t_)return Wd;t_=1;var e=jO(),n=e();return Wd=n,Wd}var Gd,n_;function dv(){if(n_)return Gd;n_=1;var e=fv(),n=ei();function i(s,o){return s&&e(s,o,n)}return Gd=i,Gd}var Yd,r_;function AO(){if(r_)return Yd;r_=1;var e=wr();function n(i,s){return function(o,u){if(o==null)return o;if(!e(o))return i(o,u);for(var l=o.length,c=s?l:-1,d=Object(o);(s?c--:++c<l)&&u(d[c],c,d)!==!1;);return o}}return Yd=n,Yd}var Kd,i_;function Hu(){if(i_)return Kd;i_=1;var e=dv(),n=AO(),i=n(e);return Kd=i,Kd}var Xd,s_;function Li(){if(s_)return Xd;s_=1;function e(n){return n}return Xd=e,Xd}var Qd,o_;function SN(){if(o_)return Qd;o_=1;var e=Li();function n(i){return typeof i=="function"?i:e}return Qd=n,Qd}var Zd,a_;function bN(){if(a_)return Zd;a_=1;var e=rv(),n=Hu(),i=SN(),s=yt();function o(u,l){var c=s(u)?e:n;return c(u,i(l))}return Zd=o,Zd}var Jd,u_;function kN(){return u_||(u_=1,Jd=bN()),Jd}var eh,l_;function IO(){if(l_)return eh;l_=1;var e=Hu();function n(i,s){var o=[];return e(i,function(u,l,c){s(u,l,c)&&o.push(u)}),o}return eh=n,eh}var th,c_;function MO(){if(c_)return th;c_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return th=n,th}var nh,f_;function PO(){if(f_)return nh;f_=1;function e(n){return this.__data__.has(n)}return nh=e,nh}var rh,d_;function EN(){if(d_)return rh;d_=1;var e=nv(),n=MO(),i=PO();function s(o){var u=-1,l=o==null?0:o.length;for(this.__data__=new e;++u<l;)this.add(o[u])}return s.prototype.add=s.prototype.push=n,s.prototype.has=i,rh=s,rh}var ih,h_;function OO(){if(h_)return ih;h_=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 ih=e,ih}var sh,p_;function NN(){if(p_)return sh;p_=1;function e(n,i){return n.has(i)}return sh=e,sh}var oh,m_;function CN(){if(m_)return oh;m_=1;var e=EN(),n=OO(),i=NN(),s=1,o=2;function u(l,c,d,h,p,m){var y=d&s,x=l.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=m.get(l),S=m.get(c);if(_&&S)return _==c&&S==l;var b=-1,k=!0,E=d&o?new e:void 0;for(m.set(l,c),m.set(c,l);++b<x;){var C=l[b],A=c[b];if(h)var P=y?h(A,C,b,c,l,m):h(C,A,b,l,c,m);if(P!==void 0){if(P)continue;k=!1;break}if(E){if(!n(c,function(I,M){if(!i(E,M)&&(C===I||p(C,I,d,h,m)))return E.push(M)})){k=!1;break}}else if(!(C===A||p(C,A,d,h,m))){k=!1;break}}return m.delete(l),m.delete(c),k}return oh=u,oh}var ah,g_;function qO(){if(g_)return ah;g_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,u){s[++i]=[u,o]}),s}return ah=e,ah}var uh,v_;function hv(){if(v_)return uh;v_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return uh=e,uh}var lh,y_;function LO(){if(y_)return lh;y_=1;var e=Ms(),n=vN(),i=Is(),s=CN(),o=qO(),u=hv(),l=1,c=2,d="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function A(P,I,M,R,L,F,Q){switch(M){case k:if(P.byteLength!=I.byteLength||P.byteOffset!=I.byteOffset)return!1;P=P.buffer,I=I.buffer;case b:return!(P.byteLength!=I.byteLength||!F(new n(P),new n(I)));case d:case h:case y:return i(+P,+I);case p:return P.name==I.name&&P.message==I.message;case x:case _:return P==I+"";case m:var X=o;case N:var j=R&l;if(X||(X=u),P.size!=I.size&&!j)return!1;var G=Q.get(P);if(G)return G==I;R|=c,Q.set(P,I);var U=s(X(P),X(I),R,L,F,Q);return Q.delete(P),U;case S:if(C)return C.call(P)==C.call(I)}return!1}return lh=A,lh}var ch,w_;function $O(){if(w_)return ch;w_=1;var e=mN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(u,l,c,d,h,p){var m=c&n,y=e(u),x=y.length,N=e(l),_=N.length;if(x!=_&&!m)return!1;for(var S=x;S--;){var b=y[S];if(!(m?b in l:s.call(l,b)))return!1}var k=p.get(u),E=p.get(l);if(k&&E)return k==l&&E==u;var C=!0;p.set(u,l),p.set(l,u);for(var A=m;++S<x;){b=y[S];var P=u[b],I=l[b];if(d)var M=m?d(I,P,b,l,u,p):d(P,I,b,u,l,p);if(!(M===void 0?P===I||h(P,I,c,d,p):M)){C=!1;break}A||(A=b=="constructor")}if(C&&!A){var R=u.constructor,L=l.constructor;R!=L&&"constructor"in u&&"constructor"in l&&!(typeof R=="function"&&R instanceof R&&typeof L=="function"&&L instanceof L)&&(C=!1)}return p.delete(u),p.delete(l),C}return ch=o,ch}var fh,x_;function DO(){if(x_)return fh;x_=1;var e=Lu(),n=CN(),i=LO(),s=$O(),o=Os(),u=yt(),l=Ps(),c=Wo(),d=1,h="[object Arguments]",p="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,k,E,C){var A=u(_),P=u(S),I=A?p:o(_),M=P?p:o(S);I=I==h?m:I,M=M==h?m:M;var R=I==m,L=M==m,F=I==M;if(F&&l(_)){if(!l(S))return!1;A=!0,R=!1}if(F&&!R)return C||(C=new e),A||c(_)?n(_,S,b,k,E,C):i(_,S,I,b,k,E,C);if(!(b&d)){var Q=R&&x.call(_,"__wrapped__"),X=L&&x.call(S,"__wrapped__");if(Q||X){var j=Q?_.value():_,G=X?S.value():S;return C||(C=new e),E(j,G,b,k,C)}}return F?(C||(C=new e),s(_,S,b,k,E,C)):!1}return fh=N,fh}var dh,__;function TN(){if(__)return dh;__=1;var e=DO(),n=rr();function i(s,o,u,l,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,u,l,i,c)}return dh=i,dh}var hh,S_;function FO(){if(S_)return hh;S_=1;var e=Lu(),n=TN(),i=1,s=2;function o(u,l,c,d){var h=c.length,p=h,m=!d;if(u==null)return!p;for(u=Object(u);h--;){var y=c[h];if(m&&y[2]?y[1]!==u[y[0]]:!(y[0]in u))return!1}for(;++h<p;){y=c[h];var x=y[0],N=u[x],_=y[1];if(m&&y[2]){if(N===void 0&&!(x in u))return!1}else{var S=new e;if(d)var b=d(N,_,x,u,l,S);if(!(b===void 0?n(_,N,i|s,d,S):b))return!1}}return!0}return hh=o,hh}var ph,b_;function RN(){if(b_)return ph;b_=1;var e=An();function n(i){return i===i&&!e(i)}return ph=n,ph}var mh,k_;function zO(){if(k_)return mh;k_=1;var e=RN(),n=ei();function i(s){for(var o=n(s),u=o.length;u--;){var l=o[u],c=s[l];o[u]=[l,c,e(c)]}return o}return mh=i,mh}var gh,E_;function jN(){if(E_)return gh;E_=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return gh=e,gh}var vh,N_;function BO(){if(N_)return vh;N_=1;var e=FO(),n=zO(),i=jN();function s(o){var u=n(o);return u.length==1&&u[0][2]?i(u[0][0],u[0][1]):function(l){return l===o||e(l,o,u)}}return vh=s,vh}var yh,C_;function qs(){if(C_)return yh;C_=1;var e=Pi(),n=rr(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return yh=s,yh}var wh,T_;function pv(){if(T_)return wh;T_=1;var e=yt(),n=qs(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function o(u,l){if(e(u))return!1;var c=typeof u;return c=="number"||c=="symbol"||c=="boolean"||u==null||n(u)?!0:s.test(u)||!i.test(u)||l!=null&&u in Object(l)}return wh=o,wh}var xh,R_;function UO(){if(R_)return xh;R_=1;var e=nv(),n="Expected a function";function i(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var u=function(){var l=arguments,c=o?o.apply(this,l):l[0],d=u.cache;if(d.has(c))return d.get(c);var h=s.apply(this,l);return u.cache=d.set(c,h)||d,h};return u.cache=new(i.Cache||e),u}return i.Cache=e,xh=i,xh}var _h,j_;function HO(){if(j_)return _h;j_=1;var e=UO(),n=500;function i(s){var o=e(s,function(l){return u.size===n&&u.clear(),l}),u=o.cache;return o}return _h=i,_h}var Sh,A_;function VO(){if(A_)return Sh;A_=1;var e=HO(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=e(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(n,function(l,c,d,h){u.push(d?h.replace(i,"$1"):c||l)}),u});return Sh=s,Sh}var bh,I_;function Vu(){if(I_)return bh;I_=1;function e(n,i){for(var s=-1,o=n==null?0:n.length,u=Array(o);++s<o;)u[s]=i(n[s],s,n);return u}return bh=e,bh}var kh,M_;function WO(){if(M_)return kh;M_=1;var e=Ms(),n=Vu(),i=yt(),s=qs(),o=e?e.prototype:void 0,u=o?o.toString:void 0;function l(c){if(typeof c=="string")return c;if(i(c))return n(c,l)+"";if(s(c))return u?u.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return kh=l,kh}var Eh,P_;function AN(){if(P_)return Eh;P_=1;var e=WO();function n(i){return i==null?"":e(i)}return Eh=n,Eh}var Nh,O_;function Wu(){if(O_)return Nh;O_=1;var e=yt(),n=pv(),i=VO(),s=AN();function o(u,l){return e(u)?u:n(u,l)?[u]:i(s(u))}return Nh=o,Nh}var Ch,q_;function Go(){if(q_)return Ch;q_=1;var e=qs();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Ch=n,Ch}var Th,L_;function Gu(){if(L_)return Th;L_=1;var e=Wu(),n=Go();function i(s,o){o=e(o,s);for(var u=0,l=o.length;s!=null&&u<l;)s=s[n(o[u++])];return u&&u==l?s:void 0}return Th=i,Th}var Rh,$_;function GO(){if($_)return Rh;$_=1;var e=Gu();function n(i,s,o){var u=i==null?void 0:e(i,s);return u===void 0?o:u}return Rh=n,Rh}var jh,D_;function YO(){if(D_)return jh;D_=1;function e(n,i){return n!=null&&i in Object(n)}return jh=e,jh}var Ah,F_;function IN(){if(F_)return Ah;F_=1;var e=Wu(),n=Vo(),i=yt(),s=Fu(),o=iv(),u=Go();function l(c,d,h){d=e(d,c);for(var p=-1,m=d.length,y=!1;++p<m;){var x=u(d[p]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++p!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(x,m)&&(i(c)||n(c)))}return Ah=l,Ah}var Ih,z_;function MN(){if(z_)return Ih;z_=1;var e=YO(),n=IN();function i(s,o){return s!=null&&n(s,o,e)}return Ih=i,Ih}var Mh,B_;function KO(){if(B_)return Mh;B_=1;var e=TN(),n=GO(),i=MN(),s=pv(),o=RN(),u=jN(),l=Go(),c=1,d=2;function h(p,m){return s(p)&&o(m)?u(l(p),m):function(y){var x=n(y,p);return x===void 0&&x===m?i(y,p):e(m,x,c|d)}}return Mh=h,Mh}var Ph,U_;function PN(){if(U_)return Ph;U_=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Ph=e,Ph}var Oh,H_;function XO(){if(H_)return Oh;H_=1;var e=Gu();function n(i){return function(s){return e(s,i)}}return Oh=n,Oh}var qh,V_;function QO(){if(V_)return qh;V_=1;var e=PN(),n=XO(),i=pv(),s=Go();function o(u){return i(u)?e(s(u)):n(u)}return qh=o,qh}var Lh,W_;function xr(){if(W_)return Lh;W_=1;var e=BO(),n=KO(),i=Li(),s=yt(),o=QO();function u(l){return typeof l=="function"?l:l==null?i:typeof l=="object"?s(l)?n(l[0],l[1]):e(l):o(l)}return Lh=u,Lh}var $h,G_;function ON(){if(G_)return $h;G_=1;var e=fN(),n=IO(),i=xr(),s=yt();function o(u,l){var c=s(u)?e:n;return c(u,i(l,3))}return $h=o,$h}var Dh,Y_;function ZO(){if(Y_)return Dh;Y_=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return Dh=i,Dh}var Fh,K_;function qN(){if(K_)return Fh;K_=1;var e=ZO(),n=IN();function i(s,o){return s!=null&&n(s,o,e)}return Fh=i,Fh}var zh,X_;function JO(){if(X_)return zh;X_=1;var e=ov(),n=Os(),i=Vo(),s=yt(),o=wr(),u=Ps(),l=Bu(),c=Wo(),d="[object Map]",h="[object Set]",p=Object.prototype,m=p.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||u(x)||c(x)||i(x)))return!x.length;var N=n(x);if(N==d||N==h)return!x.size;if(l(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return zh=y,zh}var Bh,Q_;function LN(){if(Q_)return Bh;Q_=1;function e(n){return n===void 0}return Bh=e,Bh}var Uh,Z_;function $N(){if(Z_)return Uh;Z_=1;var e=Hu(),n=wr();function i(s,o){var u=-1,l=n(s)?Array(s.length):[];return e(s,function(c,d,h){l[++u]=o(c,d,h)}),l}return Uh=i,Uh}var Hh,J_;function DN(){if(J_)return Hh;J_=1;var e=Vu(),n=xr(),i=$N(),s=yt();function o(u,l){var c=s(u)?e:i;return c(u,n(l,3))}return Hh=o,Hh}var Vh,eS;function eq(){if(eS)return Vh;eS=1;function e(n,i,s,o){var u=-1,l=n==null?0:n.length;for(o&&l&&(s=n[++u]);++u<l;)s=i(s,n[u],u,n);return s}return Vh=e,Vh}var Wh,tS;function tq(){if(tS)return Wh;tS=1;function e(n,i,s,o,u){return u(n,function(l,c,d){s=o?(o=!1,l):i(s,l,c,d)}),s}return Wh=e,Wh}var Gh,nS;function FN(){if(nS)return Gh;nS=1;var e=eq(),n=Hu(),i=xr(),s=tq(),o=yt();function u(l,c,d){var h=o(l)?e:s,p=arguments.length<3;return h(l,i(c,4),d,p,n)}return Gh=u,Gh}var Yh,rS;function nq(){if(rS)return Yh;rS=1;var e=Pi(),n=yt(),i=rr(),s="[object String]";function o(u){return typeof u=="string"||!n(u)&&i(u)&&e(u)==s}return Yh=o,Yh}var Kh,iS;function rq(){if(iS)return Kh;iS=1;var e=PN(),n=e("length");return Kh=n,Kh}var Xh,sS;function iq(){if(sS)return Xh;sS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,u="\\ufe0e\\ufe0f",l="\\u200d",c=RegExp("["+l+e+o+u+"]");function d(h){return c.test(h)}return Xh=d,Xh}var Qh,oS;function sq(){if(oS)return Qh;oS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,u="\\ufe0e\\ufe0f",l="["+e+"]",c="["+o+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",p="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+u+"]?",S="(?:"+x+"(?:"+[p,m,y].join("|")+")"+_+N+")*",b=_+N+S,k="(?:"+[p+c+"?",c,m,y,l].join("|")+")",E=RegExp(d+"(?="+d+")|"+k+b,"g");function C(A){for(var P=E.lastIndex=0;E.test(A);)++P;return P}return Qh=C,Qh}var Zh,aS;function oq(){if(aS)return Zh;aS=1;var e=rq(),n=iq(),i=sq();function s(o){return n(o)?i(o):e(o)}return Zh=s,Zh}var Jh,uS;function aq(){if(uS)return Jh;uS=1;var e=ov(),n=Os(),i=wr(),s=nq(),o=oq(),u="[object Map]",l="[object Set]";function c(d){if(d==null)return 0;if(i(d))return s(d)?o(d):d.length;var h=n(d);return h==u||h==l?d.size:e(d).length}return Jh=c,Jh}var ep,lS;function uq(){if(lS)return ep;lS=1;var e=rv(),n=wN(),i=dv(),s=xr(),o=Uu(),u=yt(),l=Ps(),c=Uo(),d=An(),h=Wo();function p(m,y,x){var N=u(m),_=N||l(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=N?new S:[]:d(m)?x=c(S)?n(o(m)):{}:x={}}return(_?e:i)(m,function(b,k,E){return y(x,b,k,E)}),x}return ep=p,ep}var tp,cS;function lq(){if(cS)return tp;cS=1;var e=Ms(),n=Vo(),i=yt(),s=e?e.isConcatSpreadable:void 0;function o(u){return i(u)||n(u)||!!(s&&u&&u[s])}return tp=o,tp}var np,fS;function mv(){if(fS)return np;fS=1;var e=uv(),n=lq();function i(s,o,u,l,c){var d=-1,h=s.length;for(u||(u=n),c||(c=[]);++d<h;){var p=s[d];o>0&&u(p)?o>1?i(p,o-1,u,l,c):e(c,p):l||(c[c.length]=p)}return c}return np=i,np}var rp,dS;function cq(){if(dS)return rp;dS=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 rp=e,rp}var ip,hS;function zN(){if(hS)return ip;hS=1;var e=cq(),n=Math.max;function i(s,o,u){return o=n(o===void 0?s.length-1:o,0),function(){for(var l=arguments,c=-1,d=n(l.length-o,0),h=Array(d);++c<d;)h[c]=l[o+c];c=-1;for(var p=Array(o+1);++c<o;)p[c]=l[c];return p[o]=u(h),e(s,this,p)}}return ip=i,ip}var sp,pS;function fq(){if(pS)return sp;pS=1;var e=cv(),n=oN(),i=Li(),s=n?function(o,u){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(u),writable:!0})}:i;return sp=s,sp}var op,mS;function dq(){if(mS)return op;mS=1;var e=800,n=16,i=Date.now;function s(o){var u=0,l=0;return function(){var c=i(),d=n-(c-l);if(l=c,d>0){if(++u>=e)return arguments[0]}else u=0;return o.apply(void 0,arguments)}}return op=s,op}var ap,gS;function BN(){if(gS)return ap;gS=1;var e=fq(),n=dq(),i=n(e);return ap=i,ap}var up,vS;function Yu(){if(vS)return up;vS=1;var e=Li(),n=zN(),i=BN();function s(o,u){return i(n(o,u,e),o+"")}return up=s,up}var lp,yS;function UN(){if(yS)return lp;yS=1;function e(n,i,s,o){for(var u=n.length,l=s+(o?1:-1);o?l--:++l<u;)if(i(n[l],l,n))return l;return-1}return lp=e,lp}var cp,wS;function hq(){if(wS)return cp;wS=1;function e(n){return n!==n}return cp=e,cp}var fp,xS;function pq(){if(xS)return fp;xS=1;function e(n,i,s){for(var o=s-1,u=n.length;++o<u;)if(n[o]===i)return o;return-1}return fp=e,fp}var dp,_S;function mq(){if(_S)return dp;_S=1;var e=UN(),n=hq(),i=pq();function s(o,u,l){return u===u?i(o,u,l):e(o,n,l)}return dp=s,dp}var hp,SS;function gq(){if(SS)return hp;SS=1;var e=mq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return hp=n,hp}var pp,bS;function vq(){if(bS)return pp;bS=1;function e(n,i,s){for(var o=-1,u=n==null?0:n.length;++o<u;)if(s(i,n[o]))return!0;return!1}return pp=e,pp}var mp,kS;function yq(){if(kS)return mp;kS=1;function e(){}return mp=e,mp}var gp,ES;function wq(){if(ES)return gp;ES=1;var e=gN(),n=yq(),i=hv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(u){return new e(u)}:n;return gp=o,gp}var vp,NS;function xq(){if(NS)return vp;NS=1;var e=EN(),n=gq(),i=vq(),s=NN(),o=wq(),u=hv(),l=200;function c(d,h,p){var m=-1,y=n,x=d.length,N=!0,_=[],S=_;if(p)N=!1,y=i;else if(x>=l){var b=h?null:o(d);if(b)return u(b);N=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<x;){var k=d[m],E=h?h(k):k;if(k=p||k!==0?k:0,N&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;h&&S.push(E),_.push(k)}else y(S,E,p)||(S!==_&&S.push(E),_.push(k))}return _}return vp=c,vp}var yp,CS;function HN(){if(CS)return yp;CS=1;var e=wr(),n=rr();function i(s){return n(s)&&e(s)}return yp=i,yp}var wp,TS;function _q(){if(TS)return wp;TS=1;var e=mv(),n=Yu(),i=xq(),s=HN(),o=n(function(u){return i(e(u,1,s,!0))});return wp=o,wp}var xp,RS;function Sq(){if(RS)return xp;RS=1;var e=Vu();function n(i,s){return e(s,function(o){return i[o]})}return xp=n,xp}var _p,jS;function VN(){if(jS)return _p;jS=1;var e=Sq(),n=ei();function i(s){return s==null?[]:e(s,n(s))}return _p=i,_p}var Sp,AS;function In(){if(AS)return Sp;AS=1;var e;if(typeof ev=="function")try{e={clone:RO(),constant:cv(),each:kN(),filter:ON(),has:qN(),isArray:yt(),isEmpty:JO(),isFunction:Uo(),isUndefined:LN(),keys:ei(),map:DN(),reduce:FN(),size:aq(),transform:uq(),union:_q(),values:VN()}}catch{}return e||(e=window._),Sp=e,Sp}var bp,IS;function gv(){if(IS)return bp;IS=1;var e=In();bp=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,x=this;return e.each(p,function(N){y.length>1?x.setNode(N,m):x.setNode(N)}),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(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[p],this._isCompound&&(this._removeFromParentsChildList(p),delete this._parent[p],e.each(this.children(p),function(x){m.setParent(x)}),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 x={};function N(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),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,x=arguments;return e.reduce(p,function(N,_){return x.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var p,m,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!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 N&&(this._edgeLabels[S]=x),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]=N?x:this._defaultEdgeLabelFn(p,m,y);var b=d(this._isDirected,p,m,y);return p=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,u(this._preds[m],p),u(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 x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y),N=this._edgeObjs[x];return N&&(p=N.v,m=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],l(this._preds[m],p),l(this._sucs[p],m),delete this._in[m][x],delete this._out[p][x],this._edgeCount--),this},o.prototype.inEdges=function(p,m){var y=this._in[p];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.v===m}):x}},o.prototype.outEdges=function(p,m){var y=this._out[p];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.w===m}):x}},o.prototype.nodeEdges=function(p,m){var y=this.inEdges(p,m);if(y)return y.concat(this.outEdges(p,m))};function u(p,m){p[m]?p[m]++:p[m]=1}function l(p,m){--p[m]||delete p[m]}function c(p,m,y,x){var N=""+m,_=""+y;if(!p&&N>_){var S=N;N=_,_=S}return N+s+_+s+(e.isUndefined(x)?n:x)}function d(p,m,y,x){var N=""+m,_=""+y;if(!p&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function h(p,m){return c(p,m.v,m.w,m.name)}return bp}var kp,MS;function bq(){return MS||(MS=1,kp="2.1.8"),kp}var Ep,PS;function kq(){return PS||(PS=1,Ep={Graph:gv(),version:bq()}),Ep}var Np,OS;function Eq(){if(OS)return Np;OS=1;var e=In(),n=gv();Np={write:i,read:u};function i(l){var c={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:s(l),edges:o(l)};return e.isUndefined(l.graph())||(c.value=e.clone(l.graph())),c}function s(l){return e.map(l.nodes(),function(c){var d=l.node(c),h=l.parent(c),p={v:c};return e.isUndefined(d)||(p.value=d),e.isUndefined(h)||(p.parent=h),p})}function o(l){return e.map(l.edges(),function(c){var d=l.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(d)||(h.value=d),h})}function u(l){var c=new n(l.options).setGraph(l.value);return e.each(l.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(l.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return Np}var Cp,qS;function Nq(){if(qS)return Cp;qS=1;var e=In();Cp=n;function n(i){var s={},o=[],u;function l(c){e.has(s,c)||(s[c]=!0,u.push(c),e.each(i.successors(c),l),e.each(i.predecessors(c),l))}return e.each(i.nodes(),function(c){u=[],l(c),u.length&&o.push(u)}),o}return Cp}var Tp,LS;function WN(){if(LS)return Tp;LS=1;var e=In();Tp=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 u=this._arr,l=u.length;return o[i]=l,u.push({key:i,priority:s}),this._decrease(l),!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,u=o+1,l=i;o<s.length&&(l=s[o].priority<s[l].priority?o:l,u<s.length&&(l=s[u].priority<s[l].priority?u:l),l!==i&&(this._swap(i,l),this._heapify(l)))},n.prototype._decrease=function(i){for(var s=this._arr,o=s[i].priority,u;i!==0&&(u=i>>1,!(s[u].priority<o));)this._swap(i,u),i=u},n.prototype._swap=function(i,s){var o=this._arr,u=this._keyIndices,l=o[i],c=o[s];o[i]=c,o[s]=l,u[c.key]=i,u[l.key]=s},Tp}var Rp,$S;function GN(){if($S)return Rp;$S=1;var e=In(),n=WN();Rp=s;var i=e.constant(1);function s(u,l,c,d){return o(u,String(l),c||i,d||function(h){return u.outEdges(h)})}function o(u,l,c,d){var h={},p=new n,m,y,x=function(N){var _=N.v!==m?N.v:N.w,S=h[_],b=c(N),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=m,p.decrease(_,k))};for(u.nodes().forEach(function(N){var _=N===l?0:Number.POSITIVE_INFINITY;h[N]={distance:_},p.add(N,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)d(m).forEach(x);return h}return Rp}var jp,DS;function Cq(){if(DS)return jp;DS=1;var e=GN(),n=In();jp=i;function i(s,o,u){return n.transform(s.nodes(),function(l,c){l[c]=e(s,c,o,u)},{})}return jp}var Ap,FS;function YN(){if(FS)return Ap;FS=1;var e=In();Ap=n;function n(i){var s=0,o=[],u={},l=[];function c(d){var h=u[d]={onStack:!0,lowlink:s,index:s++};if(o.push(d),i.successors(d).forEach(function(y){e.has(u,y)?u[y].onStack&&(h.lowlink=Math.min(h.lowlink,u[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,u[y].lowlink))}),h.lowlink===h.index){var p=[],m;do m=o.pop(),u[m].onStack=!1,p.push(m);while(d!==m);l.push(p)}}return i.nodes().forEach(function(d){e.has(u,d)||c(d)}),l}return Ap}var Ip,zS;function Tq(){if(zS)return Ip;zS=1;var e=In(),n=YN();Ip=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 Ip}var Mp,BS;function Rq(){if(BS)return Mp;BS=1;var e=In();Mp=i;var n=e.constant(1);function i(o,u,l){return s(o,u||n,l||function(c){return o.outEdges(c)})}function s(o,u,l){var c={},d=o.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(p){h!==p&&(c[h][p]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(p){var m=p.v===h?p.w:p.v,y=u(p);c[h][m]={distance:y,predecessor:h}})}),d.forEach(function(h){var p=c[h];d.forEach(function(m){var y=c[m];d.forEach(function(x){var N=y[h],_=p[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Mp}var Pp,US;function KN(){if(US)return Pp;US=1;var e=In();Pp=n,n.CycleException=i;function n(s){var o={},u={},l=[];function c(d){if(e.has(u,d))throw new i;e.has(o,d)||(u[d]=!0,o[d]=!0,e.each(s.predecessors(d),c),delete u[d],l.push(d))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new i;return l}function i(){}return i.prototype=new Error,Pp}var Op,HS;function jq(){if(HS)return Op;HS=1;var e=KN();Op=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Op}var qp,VS;function XN(){if(VS)return qp;VS=1;var e=In();qp=n;function n(s,o,u){e.isArray(o)||(o=[o]);var l=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],d={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);i(s,h,u==="post",d,l,c)}),c}function i(s,o,u,l,c,d){e.has(l,o)||(l[o]=!0,u||d.push(o),e.each(c(o),function(h){i(s,h,u,l,c,d)}),u&&d.push(o))}return qp}var Lp,WS;function Aq(){if(WS)return Lp;WS=1;var e=XN();Lp=n;function n(i,s){return e(i,s,"post")}return Lp}var $p,GS;function Iq(){if(GS)return $p;GS=1;var e=XN();$p=n;function n(i,s){return e(i,s,"pre")}return $p}var Dp,YS;function Mq(){if(YS)return Dp;YS=1;var e=In(),n=gv(),i=WN();Dp=s;function s(o,u){var l=new n,c={},d=new i,h;function p(y){var x=y.v===h?y.w:y.v,N=d.priority(x);if(N!==void 0){var _=u(y);_<N&&(c[x]=h,d.decrease(x,_))}}if(o.nodeCount()===0)return l;e.each(o.nodes(),function(y){d.add(y,Number.POSITIVE_INFINITY),l.setNode(y)}),d.decrease(o.nodes()[0],0);for(var m=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))l.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(p)}return l}return Dp}var Fp,KS;function Pq(){return KS||(KS=1,Fp={components:Nq(),dijkstra:GN(),dijkstraAll:Cq(),findCycles:Tq(),floydWarshall:Rq(),isAcyclic:jq(),postorder:Aq(),preorder:Iq(),prim:Mq(),tarjan:YN(),topsort:KN()}),Fp}var zp,XS;function Oq(){if(XS)return zp;XS=1;var e=kq();return zp={Graph:e.Graph,json:Eq(),alg:Pq(),version:e.version},zp}var Bp,QS;function Vn(){if(QS)return Bp;QS=1;var e;if(typeof ev=="function")try{e=Oq()}catch{}return e||(e=window.graphlib),Bp=e,Bp}var Up,ZS;function qq(){if(ZS)return Up;ZS=1;var e=_N(),n=1,i=4;function s(o){return e(o,n|i)}return Up=s,Up}var Hp,JS;function Ku(){if(JS)return Hp;JS=1;var e=Is(),n=wr(),i=Fu(),s=An();function o(u,l,c){if(!s(c))return!1;var d=typeof l;return(d=="number"?n(c)&&i(l,c.length):d=="string"&&l in c)?e(c[l],u):!1}return Hp=o,Hp}var Vp,eb;function Lq(){if(eb)return Vp;eb=1;var e=Yu(),n=Is(),i=Ku(),s=qi(),o=Object.prototype,u=o.hasOwnProperty,l=e(function(c,d){c=Object(c);var h=-1,p=d.length,m=p>2?d[2]:void 0;for(m&&i(d[0],d[1],m)&&(p=1);++h<p;)for(var y=d[h],x=s(y),N=-1,_=x.length;++N<_;){var S=x[N],b=c[S];(b===void 0||n(b,o[S])&&!u.call(c,S))&&(c[S]=y[S])}return c});return Vp=l,Vp}var Wp,tb;function $q(){if(tb)return Wp;tb=1;var e=xr(),n=wr(),i=ei();function s(o){return function(u,l,c){var d=Object(u);if(!n(u)){var h=e(l,3);u=i(u),l=function(m){return h(d[m],m,d)}}var p=o(u,l,c);return p>-1?d[h?u[p]:p]:void 0}}return Wp=s,Wp}var Gp,nb;function Dq(){if(nb)return Gp;nb=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return Gp=n,Gp}var Yp,rb;function Fq(){if(rb)return Yp;rb=1;var e=Dq(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return Yp=i,Yp}var Kp,ib;function zq(){if(ib)return Kp;ib=1;var e=Fq(),n=An(),i=qs(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;function d(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=u.test(h);return m||l.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return Kp=d,Kp}var Xp,sb;function QN(){if(sb)return Xp;sb=1;var e=zq(),n=1/0,i=17976931348623157e292;function s(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var u=o<0?-1:1;return u*i}return o===o?o:0}return Xp=s,Xp}var Qp,ob;function Bq(){if(ob)return Qp;ob=1;var e=QN();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return Qp=n,Qp}var Zp,ab;function Uq(){if(ab)return Zp;ab=1;var e=UN(),n=xr(),i=Bq(),s=Math.max;function o(u,l,c){var d=u==null?0:u.length;if(!d)return-1;var h=c==null?0:i(c);return h<0&&(h=s(d+h,0)),e(u,n(l,3),h)}return Zp=o,Zp}var Jp,ub;function Hq(){if(ub)return Jp;ub=1;var e=$q(),n=Uq(),i=e(n);return Jp=i,Jp}var em,lb;function ZN(){if(lb)return em;lb=1;var e=mv();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return em=n,em}var tm,cb;function Vq(){if(cb)return tm;cb=1;var e=fv(),n=SN(),i=qi();function s(o,u){return o==null?o:e(o,n(u),i)}return tm=s,tm}var nm,fb;function Wq(){if(fb)return nm;fb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return nm=e,nm}var rm,db;function Gq(){if(db)return rm;db=1;var e=$u(),n=dv(),i=xr();function s(o,u){var l={};return u=i(u,3),n(o,function(c,d,h){e(l,d,u(c,d,h))}),l}return rm=s,rm}var im,hb;function vv(){if(hb)return im;hb=1;var e=qs();function n(i,s,o){for(var u=-1,l=i.length;++u<l;){var c=i[u],d=s(c);if(d!=null&&(h===void 0?d===d&&!e(d):o(d,h)))var h=d,p=c}return p}return im=n,im}var sm,pb;function Yq(){if(pb)return sm;pb=1;function e(n,i){return n>i}return sm=e,sm}var om,mb;function Kq(){if(mb)return om;mb=1;var e=vv(),n=Yq(),i=Li();function s(o){return o&&o.length?e(o,i,n):void 0}return om=s,om}var am,gb;function JN(){if(gb)return am;gb=1;var e=$u(),n=Is();function i(s,o,u){(u!==void 0&&!n(s[o],u)||u===void 0&&!(o in s))&&e(s,o,u)}return am=i,am}var um,vb;function Xq(){if(vb)return um;vb=1;var e=Pi(),n=Uu(),i=rr(),s="[object Object]",o=Function.prototype,u=Object.prototype,l=o.toString,c=u.hasOwnProperty,d=l.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&&l.call(y)==d}return um=h,um}var lm,yb;function eC(){if(yb)return lm;yb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return lm=e,lm}var cm,wb;function Qq(){if(wb)return cm;wb=1;var e=Ho(),n=qi();function i(s){return e(s,n(s))}return cm=i,cm}var fm,xb;function Zq(){if(xb)return fm;xb=1;var e=JN(),n=lN(),i=yN(),s=cN(),o=xN(),u=Vo(),l=yt(),c=HN(),d=Ps(),h=Uo(),p=An(),m=Xq(),y=Wo(),x=eC(),N=Qq();function _(S,b,k,E,C,A,P){var I=x(S,k),M=x(b,k),R=P.get(M);if(R){e(S,k,R);return}var L=A?A(I,M,k+"",S,b,P):void 0,F=L===void 0;if(F){var Q=l(M),X=!Q&&d(M),j=!Q&&!X&&y(M);L=M,Q||X||j?l(I)?L=I:c(I)?L=s(I):X?(F=!1,L=n(M,!0)):j?(F=!1,L=i(M,!0)):L=[]:m(M)||u(M)?(L=I,u(I)?L=N(I):(!p(I)||h(I))&&(L=o(M))):F=!1}F&&(P.set(M,L),C(L,M,E,A,P),P.delete(M)),e(S,k,L)}return fm=_,fm}var dm,_b;function Jq(){if(_b)return dm;_b=1;var e=Lu(),n=JN(),i=fv(),s=Zq(),o=An(),u=qi(),l=eC();function c(d,h,p,m,y){d!==h&&i(h,function(x,N){if(y||(y=new e),o(x))s(d,h,N,p,c,m,y);else{var _=m?m(l(d,N),x,N+"",d,h,y):void 0;_===void 0&&(_=x),n(d,N,_)}},u)}return dm=c,dm}var hm,Sb;function eL(){if(Sb)return hm;Sb=1;var e=Yu(),n=Ku();function i(s){return e(function(o,u){var l=-1,c=u.length,d=c>1?u[c-1]:void 0,h=c>2?u[2]:void 0;for(d=s.length>3&&typeof d=="function"?(c--,d):void 0,h&&n(u[0],u[1],h)&&(d=c<3?void 0:d,c=1),o=Object(o);++l<c;){var p=u[l];p&&s(o,p,l,d)}return o})}return hm=i,hm}var pm,bb;function tL(){if(bb)return pm;bb=1;var e=Jq(),n=eL(),i=n(function(s,o,u){e(s,o,u)});return pm=i,pm}var mm,kb;function tC(){if(kb)return mm;kb=1;function e(n,i){return n<i}return mm=e,mm}var gm,Eb;function nL(){if(Eb)return gm;Eb=1;var e=vv(),n=tC(),i=Li();function s(o){return o&&o.length?e(o,i,n):void 0}return gm=s,gm}var vm,Nb;function rL(){if(Nb)return vm;Nb=1;var e=vv(),n=xr(),i=tC();function s(o,u){return o&&o.length?e(o,n(u,2),i):void 0}return vm=s,vm}var ym,Cb;function iL(){if(Cb)return ym;Cb=1;var e=Gn(),n=function(){return e.Date.now()};return ym=n,ym}var wm,Tb;function sL(){if(Tb)return wm;Tb=1;var e=Du(),n=Wu(),i=Fu(),s=An(),o=Go();function u(l,c,d,h){if(!s(l))return l;c=n(c,l);for(var p=-1,m=c.length,y=m-1,x=l;x!=null&&++p<m;){var N=o(c[p]),_=d;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(p!=y){var S=x[N];_=h?h(S,N,x):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(x,N,_),x=x[N]}return l}return wm=u,wm}var xm,Rb;function oL(){if(Rb)return xm;Rb=1;var e=Gu(),n=sL(),i=Wu();function s(o,u,l){for(var c=-1,d=u.length,h={};++c<d;){var p=u[c],m=e(o,p);l(m,p)&&n(h,i(p,o),m)}return h}return xm=s,xm}var _m,jb;function aL(){if(jb)return _m;jb=1;var e=oL(),n=MN();function i(s,o){return e(s,o,function(u,l){return n(s,l)})}return _m=i,_m}var Sm,Ab;function uL(){if(Ab)return Sm;Ab=1;var e=ZN(),n=zN(),i=BN();function s(o){return i(n(o,void 0,e),o+"")}return Sm=s,Sm}var bm,Ib;function lL(){if(Ib)return bm;Ib=1;var e=aL(),n=uL(),i=n(function(s,o){return s==null?{}:e(s,o)});return bm=i,bm}var km,Mb;function cL(){if(Mb)return km;Mb=1;var e=Math.ceil,n=Math.max;function i(s,o,u,l){for(var c=-1,d=n(e((o-s)/(u||1)),0),h=Array(d);d--;)h[l?d:++c]=s,s+=u;return h}return km=i,km}var Em,Pb;function fL(){if(Pb)return Em;Pb=1;var e=cL(),n=Ku(),i=QN();function s(o){return function(u,l,c){return c&&typeof c!="number"&&n(u,l,c)&&(l=c=void 0),u=i(u),l===void 0?(l=u,u=0):l=i(l),c=c===void 0?u<l?1:-1:i(c),e(u,l,c,o)}}return Em=s,Em}var Nm,Ob;function dL(){if(Ob)return Nm;Ob=1;var e=fL(),n=e();return Nm=n,Nm}var Cm,qb;function hL(){if(qb)return Cm;qb=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Cm=e,Cm}var Tm,Lb;function pL(){if(Lb)return Tm;Lb=1;var e=qs();function n(i,s){if(i!==s){var o=i!==void 0,u=i===null,l=i===i,c=e(i),d=s!==void 0,h=s===null,p=s===s,m=e(s);if(!h&&!m&&!c&&i>s||c&&d&&p&&!h&&!m||u&&d&&p||!o&&p||!l)return 1;if(!u&&!c&&!m&&i<s||m&&o&&l&&!u&&!c||h&&o&&l||!d&&l||!p)return-1}return 0}return Tm=n,Tm}var Rm,$b;function mL(){if($b)return Rm;$b=1;var e=pL();function n(i,s,o){for(var u=-1,l=i.criteria,c=s.criteria,d=l.length,h=o.length;++u<d;){var p=e(l[u],c[u]);if(p){if(u>=h)return p;var m=o[u];return p*(m=="desc"?-1:1)}}return i.index-s.index}return Rm=n,Rm}var jm,Db;function gL(){if(Db)return jm;Db=1;var e=Vu(),n=Gu(),i=xr(),s=$N(),o=hL(),u=zu(),l=mL(),c=Li(),d=yt();function h(p,m,y){m.length?m=e(m,function(_){return d(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,u(i));var N=s(p,function(_,S,b){var k=e(m,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,S){return l(_,S,y)})}return jm=h,jm}var Am,Fb;function vL(){if(Fb)return Am;Fb=1;var e=mv(),n=gL(),i=Yu(),s=Ku(),o=i(function(u,l){if(u==null)return[];var c=l.length;return c>1&&s(u,l[0],l[1])?l=[]:c>2&&s(l[0],l[1],l[2])&&(l=[l[0]]),n(u,e(l,1),[])});return Am=o,Am}var Im,zb;function yL(){if(zb)return Im;zb=1;var e=AN(),n=0;function i(s){var o=++n;return e(s)+o}return Im=i,Im}var Mm,Bb;function wL(){if(Bb)return Mm;Bb=1;function e(n,i,s){for(var o=-1,u=n.length,l=i.length,c={};++o<u;){var d=o<l?i[o]:void 0;s(c,n[o],d)}return c}return Mm=e,Mm}var Pm,Ub;function xL(){if(Ub)return Pm;Ub=1;var e=Du(),n=wL();function i(s,o){return n(s||[],o||[],e)}return Pm=i,Pm}var Om,Hb;function ut(){if(Hb)return Om;Hb=1;var e;if(typeof ev=="function")try{e={cloneDeep:qq(),constant:cv(),defaults:Lq(),each:kN(),filter:ON(),find:Hq(),flatten:ZN(),forEach:bN(),forIn:Vq(),has:qN(),isUndefined:LN(),last:Wq(),map:DN(),mapValues:Gq(),max:Kq(),merge:tL(),min:nL(),minBy:rL(),now:iL(),pick:lL(),range:dL(),reduce:FN(),sortBy:vL(),uniqueId:yL(),values:VN(),zipObject:xL()}}catch{}return e||(e=window._),Om=e,Om}var qm,Vb;function _L(){if(Vb)return qm;Vb=1,qm=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,u=o._prev;u!==o;)s.push(JSON.stringify(u,i)),u=u._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 qm}var Lm,Wb;function SL(){if(Wb)return Lm;Wb=1;var e=ut(),n=Vn().Graph,i=_L();Lm=o;var s=e.constant(1);function o(h,p){if(h.nodeCount()<=1)return[];var m=c(h,p||s),y=u(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function u(h,p,m){for(var y=[],x=p[p.length-1],N=p[0],_;h.nodeCount();){for(;_=N.dequeue();)l(h,p,m,_);for(;_=x.dequeue();)l(h,p,m,_);if(h.nodeCount()){for(var S=p.length-2;S>0;--S)if(_=p[S].dequeue(),_){y=y.concat(l(h,p,m,_,!0));break}}}return y}function l(h,p,m,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,d(p,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,k=h.node(b);k.in-=S,d(p,m,k)}),h.removeNode(y.v),N}function c(h,p){var m=new n,y=0,x=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,k=p(S),E=b+k;m.setEdge(S.v,S.w,E),x=Math.max(x,m.node(S.v).out+=k),y=Math.max(y,m.node(S.w).in+=k)});var N=e.range(x+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){d(N,_,m.node(S))}),{graph:m,buckets:N,zeroIdx:_}}function d(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 Lm}var $m,Gb;function bL(){if(Gb)return $m;Gb=1;var e=ut(),n=SL();$m={run:i,undo:o};function i(u){var l=u.graph().acyclicer==="greedy"?n(u,c(u)):s(u);e.forEach(l,function(d){var h=u.edge(d);u.removeEdge(d),h.forwardName=d.name,h.reversed=!0,u.setEdge(d.w,d.v,h,e.uniqueId("rev"))});function c(d){return function(h){return d.edge(h).weight}}}function s(u){var l=[],c={},d={};function h(p){e.has(d,p)||(d[p]=!0,c[p]=!0,e.forEach(u.outEdges(p),function(m){e.has(c,m.w)?l.push(m):h(m.w)}),delete c[p])}return e.forEach(u.nodes(),h),l}function o(u){e.forEach(u.edges(),function(l){var c=u.edge(l);if(c.reversed){u.removeEdge(l);var d=c.forwardName;delete c.reversed,delete c.forwardName,u.setEdge(l.w,l.v,c,d)}})}return $m}var Dm,Yb;function sn(){if(Yb)return Dm;Yb=1;var e=ut(),n=Vn().Graph;Dm={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:u,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:p,addBorderNode:m,maxRank:y,partition:x,time:N,notime:_};function i(S,b,k,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return k.dummy=b,S.setNode(C,k),C}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var E=b.edge(k.v,k.w)||{weight:0,minlen:1},C=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function u(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function l(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,C=b.x-k,A=b.y-E,P=S.width/2,I=S.height/2;if(!C&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var M,R;return Math.abs(A)*P>Math.abs(C)*I?(A<0&&(I=-I),M=I*C/A,R=I):(C<0&&(P=-P),M=P,R=P*A/C),{x:k+M,y:E+R}}function d(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var E=S.node(k),C=E.rank;e.isUndefined(C)||(b[C][E.order]=k)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var E=S.node(k);e.has(E,"rank")&&(E.rank-=b)})}function p(S){var b=e.min(e.map(S.nodes(),function(A){return S.node(A).rank})),k=[];e.forEach(S.nodes(),function(A){var P=S.node(A).rank-b;k[P]||(k[P]=[]),k[P].push(A)});var E=0,C=S.graph().nodeRankFactor;e.forEach(k,function(A,P){e.isUndefined(A)&&P%C!==0?--E:E&&e.forEach(A,function(I){S.node(I).rank+=E})})}function m(S,b,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),i(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return Dm}var Fm,Kb;function kL(){if(Kb)return Fm;Kb=1;var e=ut(),n=sn();Fm={run:i,undo:o};function i(u){u.graph().dummyChains=[],e.forEach(u.edges(),function(l){s(u,l)})}function s(u,l){var c=l.v,d=u.node(c).rank,h=l.w,p=u.node(h).rank,m=l.name,y=u.edge(l),x=y.labelRank;if(p!==d+1){u.removeEdge(l);var N,_,S;for(S=0,++d;d<p;++S,++d)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:l,rank:d},N=n.addDummyNode(u,"edge",_,"_d"),d===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),u.setEdge(c,N,{weight:y.weight},m),S===0&&u.graph().dummyChains.push(N),c=N;u.setEdge(c,h,{weight:y.weight},m)}}function o(u){e.forEach(u.graph().dummyChains,function(l){var c=u.node(l),d=c.edgeLabel,h;for(u.setEdge(c.edgeObj,d);c.dummy;)h=u.successors(l)[0],u.removeNode(l),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),l=h,c=u.node(l)})}return Fm}var zm,Xb;function Eu(){if(Xb)return zm;Xb=1;var e=ut();zm={longestPath:n,slack:i};function n(s){var o={};function u(l){var c=s.node(l);if(e.has(o,l))return c.rank;o[l]=!0;var d=e.min(e.map(s.outEdges(l),function(h){return u(h.w)-s.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(s.sources(),u)}function i(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return zm}var Bm,Qb;function nC(){if(Qb)return Bm;Qb=1;var e=ut(),n=Vn().Graph,i=Eu().slack;Bm=s;function s(c){var d=new n({directed:!1}),h=c.nodes()[0],p=c.nodeCount();d.setNode(h,{});for(var m,y;o(d,c)<p;)m=u(d,c),y=d.hasNode(m.v)?i(c,m):-i(c,m),l(d,c,y);return d}function o(c,d){function h(p){e.forEach(d.nodeEdges(p),function(m){var y=m.v,x=p===y?m.w:y;!c.hasNode(x)&&!i(d,m)&&(c.setNode(x,{}),c.setEdge(p,x,{}),h(x))})}return e.forEach(c.nodes(),h),c.nodeCount()}function u(c,d){return e.minBy(d.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return i(d,h)})}function l(c,d,h){e.forEach(c.nodes(),function(p){d.node(p).rank+=h})}return Bm}var Um,Zb;function EL(){if(Zb)return Um;Zb=1;var e=ut(),n=nC(),i=Eu().slack,s=Eu().longestPath,o=Vn().alg.preorder,u=Vn().alg.postorder,l=sn().simplify;Um=c,c.initLowLimValues=m,c.initCutValues=d,c.calcCutValue=p,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=l(E),s(E);var C=n(E);m(C),d(C,E);for(var A,P;A=x(C);)P=N(C,E,A),_(C,E,A,P)}function d(E,C){var A=u(E,E.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(P){h(E,C,P)})}function h(E,C,A){var P=E.node(A),I=P.parent;E.edge(A,I).cutvalue=p(E,C,A)}function p(E,C,A){var P=E.node(A),I=P.parent,M=!0,R=C.edge(A,I),L=0;return R||(M=!1,R=C.edge(I,A)),L=R.weight,e.forEach(C.nodeEdges(A),function(F){var Q=F.v===A,X=Q?F.w:F.v;if(X!==I){var j=Q===M,G=C.edge(F).weight;if(L+=j?G:-G,b(E,A,X)){var U=E.edge(A,X).cutvalue;L+=j?-U:U}}}),L}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,A,P,I){var M=A,R=E.node(P);return C[P]=!0,e.forEach(E.neighbors(P),function(L){e.has(C,L)||(A=y(E,C,A,L,P))}),R.low=M,R.lim=A++,I?R.parent=I:delete R.parent,A}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,A){var P=A.v,I=A.w;C.hasEdge(P,I)||(P=A.w,I=A.v);var M=E.node(P),R=E.node(I),L=M,F=!1;M.lim>R.lim&&(L=R,F=!0);var Q=e.filter(C.edges(),function(X){return F===k(E,E.node(X.v),L)&&F!==k(E,E.node(X.w),L)});return e.minBy(Q,function(X){return i(C,X)})}function _(E,C,A,P){var I=A.v,M=A.w;E.removeEdge(I,M),E.setEdge(P.v,P.w,{}),m(E),d(E,C),S(E,C)}function S(E,C){var A=e.find(E.nodes(),function(I){return!C.node(I).parent}),P=o(E,A);P=P.slice(1),e.forEach(P,function(I){var M=E.node(I).parent,R=C.edge(I,M),L=!1;R||(R=C.edge(M,I),L=!0),C.node(I).rank=C.node(M).rank+(L?R.minlen:-R.minlen)})}function b(E,C,A){return E.hasEdge(C,A)}function k(E,C,A){return A.low<=C.lim&&C.lim<=A.lim}return Um}var Hm,Jb;function NL(){if(Jb)return Hm;Jb=1;var e=Eu(),n=e.longestPath,i=nC(),s=EL();Hm=o;function o(d){switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":l(d);break;case"longest-path":u(d);break;default:c(d)}}var u=n;function l(d){n(d),i(d)}function c(d){s(d)}return Hm}var Vm,ek;function CL(){if(ek)return Vm;ek=1;var e=ut();Vm=n;function n(o){var u=s(o);e.forEach(o.graph().dummyChains,function(l){for(var c=o.node(l),d=c.edgeObj,h=i(o,u,d.v,d.w),p=h.path,m=h.lca,y=0,x=p[y],N=!0;l!==d.w;){if(c=o.node(l),N){for(;(x=p[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(N=!1)}if(!N){for(;y<p.length-1&&o.node(x=p[y+1]).minRank<=c.rank;)y++;x=p[y]}o.setParent(l,x),l=o.successors(l)[0]}})}function i(o,u,l,c){var d=[],h=[],p=Math.min(u[l].low,u[c].low),m=Math.max(u[l].lim,u[c].lim),y,x;y=l;do y=o.parent(y),d.push(y);while(y&&(u[y].low>p||m>u[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:d.concat(h.reverse()),lca:x}}function s(o){var u={},l=0;function c(d){var h=l;e.forEach(o.children(d),c),u[d]={low:h,lim:l++}}return e.forEach(o.children(),c),u}return Vm}var Wm,tk;function TL(){if(tk)return Wm;tk=1;var e=ut(),n=sn();Wm={run:i,cleanup:l};function i(c){var d=n.addDummyNode(c,"root",{},"_root"),h=o(c),p=e.max(e.values(h))-1,m=2*p+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=u(c)+1;e.forEach(c.children(),function(x){s(c,d,m,y,p,h,x)}),c.graph().nodeRankFactor=m}function s(c,d,h,p,m,y,x){var N=c.children(x);if(!N.length){x!==d&&c.setEdge(d,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(N,function(k){s(c,d,h,p,m,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,A=E.borderBottom?E.borderBottom:k,P=E.borderTop?p:2*p,I=C!==A?1:m-y[x]+1;c.setEdge(_,C,{weight:P,minlen:I,nestingEdge:!0}),c.setEdge(A,S,{weight:P,minlen:I,nestingEdge:!0})}),c.parent(x)||c.setEdge(d,_,{weight:0,minlen:m+y[x]})}function o(c){var d={};function h(p,m){var y=c.children(p);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),d[p]=m}return e.forEach(c.children(),function(p){h(p,1)}),d}function u(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var p=c.edge(h);p.nestingEdge&&c.removeEdge(h)})}return Wm}var Gm,nk;function RL(){if(nk)return Gm;nk=1;var e=ut(),n=sn();Gm=i;function i(o){function u(l){var c=o.children(l),d=o.node(l);if(c.length&&e.forEach(c,u),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var h=d.minRank,p=d.maxRank+1;h<p;++h)s(o,"borderLeft","_bl",l,d,h),s(o,"borderRight","_br",l,d,h)}}e.forEach(o.children(),u)}function s(o,u,l,c,d,h){var p={width:0,height:0,rank:h,borderType:u},m=d[u][h-1],y=n.addDummyNode(o,"border",p,l);d[u][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return Gm}var Ym,rk;function jL(){if(rk)return Ym;rk=1;var e=ut();Ym={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")&&u(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 u(h){e.forEach(h.nodes(),function(p){l(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,l),e.has(m,"y")&&l(m)})}function l(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(p){d(h.node(p))}),e.forEach(h.edges(),function(p){var m=h.edge(p);e.forEach(m.points,d),e.has(m,"x")&&d(m)})}function d(h){var p=h.x;h.x=h.y,h.y=p}return Ym}var Km,ik;function AL(){if(ik)return Km;ik=1;var e=ut();Km=n;function n(i){var s={},o=e.filter(i.nodes(),function(h){return!i.children(h).length}),u=e.max(e.map(o,function(h){return i.node(h).rank})),l=e.map(e.range(u+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var p=i.node(h);l[p.rank].push(h),e.forEach(i.successors(h),c)}}var d=e.sortBy(o,function(h){return i.node(h).rank});return e.forEach(d,c),l}return Km}var Xm,sk;function IL(){if(sk)return Xm;sk=1;var e=ut();Xm=n;function n(s,o){for(var u=0,l=1;l<o.length;++l)u+=i(s,o[l-1],o[l]);return u}function i(s,o,u){for(var l=e.zipObject(u,e.map(u,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:l[x.w],weight:s.edge(x).weight}}),"pos")}),!0),d=1;d<u.length;)d<<=1;var h=2*d-1;d-=1;var p=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+d;p[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=p[x+1]),x=x-1>>1,p[x]+=y.weight;m+=y.weight*N})),m}return Xm}var Qm,ok;function ML(){if(ok)return Qm;ok=1;var e=ut();Qm=n;function n(i,s){return e.map(s,function(o){var u=i.inEdges(o);if(u.length){var l=e.reduce(u,function(c,d){var h=i.edge(d),p=i.node(d.v);return{sum:c.sum+h.weight*p.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:o}})}return Qm}var Zm,ak;function PL(){if(ak)return Zm;ak=1;var e=ut();Zm=n;function n(o,u){var l={};e.forEach(o,function(d,h){var p=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};e.isUndefined(d.barycenter)||(p.barycenter=d.barycenter,p.weight=d.weight)}),e.forEach(u.edges(),function(d){var h=l[d.v],p=l[d.w];!e.isUndefined(h)&&!e.isUndefined(p)&&(p.indegree++,h.out.push(l[d.w]))});var c=e.filter(l,function(d){return!d.indegree});return i(c)}function i(o){var u=[];function l(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 d=o.pop();u.push(d),e.forEach(d.in.reverse(),l(d)),e.forEach(d.out,c(d))}return e.map(e.filter(u,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(o,u){var l=0,c=0;o.weight&&(l+=o.barycenter*o.weight,c+=o.weight),u.weight&&(l+=u.barycenter*u.weight,c+=u.weight),o.vs=u.vs.concat(o.vs),o.barycenter=l/c,o.weight=c,o.i=Math.min(u.i,o.i),u.merged=!0}return Zm}var Jm,uk;function OL(){if(uk)return Jm;uk=1;var e=ut(),n=sn();Jm=i;function i(u,l){var c=n.partition(u,function(_){return e.has(_,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),p=[],m=0,y=0,x=0;d.sort(o(!!l)),x=s(p,h,x),e.forEach(d,function(_){x+=_.vs.length,p.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(p,h,x)});var N={vs:e.flatten(p,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function s(u,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),u.push(d.vs),c++;return c}function o(u){return function(l,c){return l.barycenter<c.barycenter?-1:l.barycenter>c.barycenter?1:u?c.i-l.i:l.i-c.i}}return Jm}var eg,lk;function qL(){if(lk)return eg;lk=1;var e=ut(),n=ML(),i=PL(),s=OL();eg=o;function o(c,d,h,p){var m=c.children(d),y=c.node(d),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(A){return A!==x&&A!==N}));var S=n(c,m);e.forEach(S,function(A){if(c.children(A.v).length){var P=o(c,A.v,h,p);_[A.v]=P,e.has(P,"barycenter")&&l(A,P)}});var b=i(S,h);u(b,_);var k=s(b,p);if(x&&(k.vs=e.flatten([x,k.vs,N],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+C.order)/(k.weight+2),k.weight+=2}return k}function u(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(p){return d[p]?d[p].vs:p}),!0)})}function l(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return eg}var tg,ck;function LL(){if(ck)return tg;ck=1;var e=ut(),n=Vn().Graph;tg=i;function i(o,u,l){var c=s(o),d=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===u||p.minRank<=u&&u<=p.maxRank)&&(d.setNode(h),d.setParent(h,m||c),e.forEach(o[l](h),function(y){var x=y.v===h?y.w:y.v,N=d.edge(x,h),_=e.isUndefined(N)?0:N.weight;d.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(p,"minRank")&&d.setNode(h,{borderLeft:p.borderLeft[u],borderRight:p.borderRight[u]}))}),d}function s(o){for(var u;o.hasNode(u=e.uniqueId("_root")););return u}return tg}var ng,fk;function $L(){if(fk)return ng;fk=1;var e=ut();ng=n;function n(i,s,o){var u={},l;e.forEach(o,function(c){for(var d=i.parent(c),h,p;d;){if(h=i.parent(d),h?(p=u[h],u[h]=d):(p=l,l=d),p&&p!==d){s.setEdge(p,d);return}d=h}})}return ng}var rg,dk;function DL(){if(dk)return rg;dk=1;var e=ut(),n=AL(),i=IL(),s=qL(),o=LL(),u=$L(),l=Vn().Graph,c=sn();rg=d;function d(y){var x=c.maxRank(y),N=h(y,e.range(1,x+1),"inEdges"),_=h(y,e.range(x-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){p(E%2?N:_,E%4>=2),S=c.buildLayerMatrix(y);var A=i(y,S);A<b&&(C=0,k=e.cloneDeep(S),b=A)}m(y,k)}function h(y,x,N){return e.map(x,function(_){return o(y,_,N)})}function p(y,x){var N=new l;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,N,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),u(_,N,b.vs)})}function m(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return rg}var ig,hk;function FL(){if(hk)return ig;hk=1;var e=ut(),n=Vn().Graph,i=sn();ig={positionX:N,findType1Conflicts:s,findType2Conflicts:o,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(b,k){var E={};function C(A,P){var I=0,M=0,R=A.length,L=e.last(P);return e.forEach(P,function(F,Q){var X=u(b,F),j=X?b.node(X).order:R;(X||F===L)&&(e.forEach(P.slice(M,Q+1),function(G){e.forEach(b.predecessors(G),function(U){var ne=b.node(U),K=ne.order;(K<I||j<K)&&!(ne.dummy&&b.node(G).dummy)&&l(E,U,G)})}),M=Q+1,I=j)}),P}return e.reduce(k,C),E}function o(b,k){var E={};function C(P,I,M,R,L){var F;e.forEach(e.range(I,M),function(Q){F=P[Q],b.node(F).dummy&&e.forEach(b.predecessors(F),function(X){var j=b.node(X);j.dummy&&(j.order<R||j.order>L)&&l(E,X,F)})})}function A(P,I){var M=-1,R,L=0;return e.forEach(I,function(F,Q){if(b.node(F).dummy==="border"){var X=b.predecessors(F);X.length&&(R=b.node(X[0]).order,C(I,L,Q,M,R),L=Q,M=R)}C(I,L,I.length,R,P.length)}),I}return e.reduce(k,A),E}function u(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(E){return b.node(E).dummy})}function l(b,k,E){if(k>E){var C=k;k=E,E=C}var A=b[k];A||(b[k]=A={}),A[E]=!0}function c(b,k,E){if(k>E){var C=k;k=E,E=C}return e.has(b[k],E)}function d(b,k,E,C){var A={},P={},I={};return e.forEach(k,function(M){e.forEach(M,function(R,L){A[R]=R,P[R]=R,I[R]=L})}),e.forEach(k,function(M){var R=-1;e.forEach(M,function(L){var F=C(L);if(F.length){F=e.sortBy(F,function(U){return I[U]});for(var Q=(F.length-1)/2,X=Math.floor(Q),j=Math.ceil(Q);X<=j;++X){var G=F[X];P[L]===L&&R<I[G]&&!c(E,L,G)&&(P[G]=L,P[L]=A[L]=A[G],R=I[G])}}})}),{root:A,align:P}}function h(b,k,E,C,A){var P={},I=p(b,k,E,A),M=A?"borderLeft":"borderRight";function R(Q,X){for(var j=I.nodes(),G=j.pop(),U={};G;)U[G]?Q(G):(U[G]=!0,j.push(G),j=j.concat(X(G))),G=j.pop()}function L(Q){P[Q]=I.inEdges(Q).reduce(function(X,j){return Math.max(X,P[j.v]+I.edge(j))},0)}function F(Q){var X=I.outEdges(Q).reduce(function(G,U){return Math.min(G,P[U.w]-I.edge(U))},Number.POSITIVE_INFINITY),j=b.node(Q);X!==Number.POSITIVE_INFINITY&&j.borderType!==M&&(P[Q]=Math.max(P[Q],X))}return R(L,I.predecessors.bind(I)),R(F,I.successors.bind(I)),e.forEach(C,function(Q){P[Q]=P[E[Q]]}),P}function p(b,k,E,C){var A=new n,P=b.graph(),I=_(P.nodesep,P.edgesep,C);return e.forEach(k,function(M){var R;e.forEach(M,function(L){var F=E[L];if(A.setNode(F),R){var Q=E[R],X=A.edge(Q,F);A.setEdge(Q,F,Math.max(I(b,L,R),X||0))}R=L})}),A}function m(b,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(E,function(P,I){var M=S(b,I)/2;C=Math.max(P+M,C),A=Math.min(P-M,A)}),C-A})}function y(b,k){var E=e.values(k),C=e.min(E),A=e.max(E);e.forEach(["u","d"],function(P){e.forEach(["l","r"],function(I){var M=P+I,R=b[M],L;if(R!==k){var F=e.values(R);L=I==="l"?C-e.min(F):A-e.max(F),L&&(b[M]=e.mapValues(R,function(Q){return Q+L}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,C){if(k)return b[k.toLowerCase()][C];var A=e.sortBy(e.map(b,C));return(A[1]+A[2])/2})}function N(b){var k=i.buildLayerMatrix(b),E=e.merge(s(b,k),o(b,k)),C={},A;e.forEach(["u","d"],function(I){A=I==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(M){M==="r"&&(A=e.map(A,function(Q){return e.values(Q).reverse()}));var R=(I==="u"?b.predecessors:b.successors).bind(b),L=d(b,A,E,R),F=h(b,A,L.root,L.align,M==="r");M==="r"&&(F=e.mapValues(F,function(Q){return-Q})),C[I+M]=F})});var P=m(b,C);return y(C,P),x(C,b.graph().align)}function _(b,k,E){return function(C,A,P){var I=C.node(A),M=C.node(P),R=0,L;if(R+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":L=-I.width/2;break;case"r":L=I.width/2;break}if(L&&(R+=E?L:-L),L=0,R+=(I.dummy?k:b)/2,R+=(M.dummy?k:b)/2,R+=M.width/2,e.has(M,"labelpos"))switch(M.labelpos.toLowerCase()){case"l":L=M.width/2;break;case"r":L=-M.width/2;break}return L&&(R+=E?L:-L),L=0,R}}function S(b,k){return b.node(k).width}return ig}var sg,pk;function zL(){if(pk)return sg;pk=1;var e=ut(),n=sn(),i=FL().positionX;sg=s;function s(u){u=n.asNonCompoundGraph(u),o(u),e.forEach(i(u),function(l,c){u.node(c).x=l})}function o(u){var l=n.buildLayerMatrix(u),c=u.graph().ranksep,d=0;e.forEach(l,function(h){var p=e.max(e.map(h,function(m){return u.node(m).height}));e.forEach(h,function(m){u.node(m).y=d+p/2}),d+=p+c})}return sg}var og,mk;function BL(){if(mk)return og;mk=1;var e=ut(),n=bL(),i=kL(),s=NL(),o=sn().normalizeRanks,u=CL(),l=sn().removeEmptyRanks,c=TL(),d=RL(),h=jL(),p=DL(),m=zL(),y=sn(),x=Vn().Graph;og=N;function N(z,W){var J=W&&W.debugTiming?y.time:y.notime;J("layout",function(){var se=J(" buildLayoutGraph",function(){return R(z)});J(" runLayout",function(){_(se,J)}),J(" updateInputGraph",function(){S(z,se)})})}function _(z,W){W(" makeSpaceForEdgeLabels",function(){L(z)}),W(" removeSelfEdges",function(){D(z)}),W(" acyclic",function(){n.run(z)}),W(" nestingGraph.run",function(){c.run(z)}),W(" rank",function(){s(y.asNonCompoundGraph(z))}),W(" injectEdgeLabelProxies",function(){F(z)}),W(" removeEmptyRanks",function(){l(z)}),W(" nestingGraph.cleanup",function(){c.cleanup(z)}),W(" normalizeRanks",function(){o(z)}),W(" assignRankMinMax",function(){Q(z)}),W(" removeEdgeLabelProxies",function(){X(z)}),W(" normalize.run",function(){i.run(z)}),W(" parentDummyChains",function(){u(z)}),W(" addBorderSegments",function(){d(z)}),W(" order",function(){p(z)}),W(" insertSelfEdges",function(){V(z)}),W(" adjustCoordinateSystem",function(){h.adjust(z)}),W(" position",function(){m(z)}),W(" positionSelfEdges",function(){O(z)}),W(" removeBorderNodes",function(){K(z)}),W(" normalize.undo",function(){i.undo(z)}),W(" fixupEdgeLabelCoords",function(){U(z)}),W(" undoCoordinateSystem",function(){h.undo(z)}),W(" translateGraph",function(){j(z)}),W(" assignNodeIntersects",function(){G(z)}),W(" reversePoints",function(){ne(z)}),W(" acyclic.undo",function(){n.undo(z)})}function S(z,W){e.forEach(z.nodes(),function(J){var se=z.node(J),ue=W.node(J);se&&(se.x=ue.x,se.y=ue.y,W.children(J).length&&(se.width=ue.width,se.height=ue.height))}),e.forEach(z.edges(),function(J){var se=z.edge(J),ue=W.edge(J);se.points=ue.points,e.has(ue,"x")&&(se.x=ue.x,se.y=ue.y)}),z.graph().width=W.graph().width,z.graph().height=W.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],A={width:0,height:0},P=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},M=["labelpos"];function R(z){var W=new x({multigraph:!0,compound:!0}),J=ae(z.graph());return W.setGraph(e.merge({},k,B(J,b),e.pick(J,E))),e.forEach(z.nodes(),function(se){var ue=ae(z.node(se));W.setNode(se,e.defaults(B(ue,C),A)),W.setParent(se,z.parent(se))}),e.forEach(z.edges(),function(se){var ue=ae(z.edge(se));W.setEdge(se,e.merge({},I,B(ue,P),e.pick(ue,M)))}),W}function L(z){var W=z.graph();W.ranksep/=2,e.forEach(z.edges(),function(J){var se=z.edge(J);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(W.rankdir==="TB"||W.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function F(z){e.forEach(z.edges(),function(W){var J=z.edge(W);if(J.width&&J.height){var se=z.node(W.v),ue=z.node(W.w),he={rank:(ue.rank-se.rank)/2+se.rank,e:W};y.addDummyNode(z,"edge-proxy",he,"_ep")}})}function Q(z){var W=0;e.forEach(z.nodes(),function(J){var se=z.node(J);se.borderTop&&(se.minRank=z.node(se.borderTop).rank,se.maxRank=z.node(se.borderBottom).rank,W=e.max(W,se.maxRank))}),z.graph().maxRank=W}function X(z){e.forEach(z.nodes(),function(W){var J=z.node(W);J.dummy==="edge-proxy"&&(z.edge(J.e).labelRank=J.rank,z.removeNode(W))})}function j(z){var W=Number.POSITIVE_INFINITY,J=0,se=Number.POSITIVE_INFINITY,ue=0,he=z.graph(),ge=he.marginx||0,Me=he.marginy||0;function Fe(Re){var Pe=Re.x,be=Re.y,Oe=Re.width,ve=Re.height;W=Math.min(W,Pe-Oe/2),J=Math.max(J,Pe+Oe/2),se=Math.min(se,be-ve/2),ue=Math.max(ue,be+ve/2)}e.forEach(z.nodes(),function(Re){Fe(z.node(Re))}),e.forEach(z.edges(),function(Re){var Pe=z.edge(Re);e.has(Pe,"x")&&Fe(Pe)}),W-=ge,se-=Me,e.forEach(z.nodes(),function(Re){var Pe=z.node(Re);Pe.x-=W,Pe.y-=se}),e.forEach(z.edges(),function(Re){var Pe=z.edge(Re);e.forEach(Pe.points,function(be){be.x-=W,be.y-=se}),e.has(Pe,"x")&&(Pe.x-=W),e.has(Pe,"y")&&(Pe.y-=se)}),he.width=J-W+ge,he.height=ue-se+Me}function G(z){e.forEach(z.edges(),function(W){var J=z.edge(W),se=z.node(W.v),ue=z.node(W.w),he,ge;J.points?(he=J.points[0],ge=J.points[J.points.length-1]):(J.points=[],he=ue,ge=se),J.points.unshift(y.intersectRect(se,he)),J.points.push(y.intersectRect(ue,ge))})}function U(z){e.forEach(z.edges(),function(W){var J=z.edge(W);if(e.has(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function ne(z){e.forEach(z.edges(),function(W){var J=z.edge(W);J.reversed&&J.points.reverse()})}function K(z){e.forEach(z.nodes(),function(W){if(z.children(W).length){var J=z.node(W),se=z.node(J.borderTop),ue=z.node(J.borderBottom),he=z.node(e.last(J.borderLeft)),ge=z.node(e.last(J.borderRight));J.width=Math.abs(ge.x-he.x),J.height=Math.abs(ue.y-se.y),J.x=he.x+J.width/2,J.y=se.y+J.height/2}}),e.forEach(z.nodes(),function(W){z.node(W).dummy==="border"&&z.removeNode(W)})}function D(z){e.forEach(z.edges(),function(W){if(W.v===W.w){var J=z.node(W.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:W,label:z.edge(W)}),z.removeEdge(W)}})}function V(z){var W=y.buildLayerMatrix(z);e.forEach(W,function(J){var se=0;e.forEach(J,function(ue,he){var ge=z.node(ue);ge.order=he+se,e.forEach(ge.selfEdges,function(Me){y.addDummyNode(z,"selfedge",{width:Me.label.width,height:Me.label.height,rank:ge.rank,order:he+ ++se,e:Me.e,label:Me.label},"_se")}),delete ge.selfEdges})})}function O(z){e.forEach(z.nodes(),function(W){var J=z.node(W);if(J.dummy==="selfedge"){var se=z.node(J.e.v),ue=se.x+se.width/2,he=se.y,ge=J.x-ue,Me=se.height/2;z.setEdge(J.e,J.label),z.removeNode(W),J.label.points=[{x:ue+2*ge/3,y:he-Me},{x:ue+5*ge/6,y:he-Me},{x:ue+ge,y:he},{x:ue+5*ge/6,y:he+Me},{x:ue+2*ge/3,y:he+Me}],J.label.x=J.x,J.label.y=J.y}})}function B(z,W){return e.mapValues(e.pick(z,W),Number)}function ae(z){var W={};return e.forEach(z,function(J,se){W[se.toLowerCase()]=J}),W}return og}var ag,gk;function UL(){if(gk)return ag;gk=1;var e=ut(),n=sn(),i=Vn().Graph;ag={debugOrdering:s};function s(o){var u=n.buildLayerMatrix(o),l=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){l.setNode(c,{label:c}),l.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){l.setEdge(c.v,c.w,{},c.name)}),e.forEach(u,function(c,d){var h="layer"+d;l.setNode(h,{rank:"same"}),e.reduce(c,function(p,m){return l.setEdge(p,m,{style:"invis"}),m})}),l}return ag}var ug,vk;function HL(){return vk||(vk=1,ug="0.8.5"),ug}var lg,yk;function VL(){return yk||(yk=1,lg={graphlib:Vn(),layout:BL(),debug:UL(),util:{time:sn().time,notime:sn().notime},version:HL()}),lg}var WL=VL();const wk=Mg(WL),Ai=240,Ns=130,Cs=74,Xu=72,xk=Cs+Xu;function GL(e){let n=Ai;for(const i of e.values())n=Math.max(n,i.width);return n}const YL=420,KL=2;function Qu(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function XL(e,n,i,s,o){const u=new wk.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const l=e.filter(_=>!o.has(_)),c=new Set(l);for(const _ of l){const S=s.get(_);u.setNode(_,{width:(S==null?void 0:S.width)??Ai,height:(S==null?void 0:S.height)??Ns})}for(const _ of n)c.has(_.source)&&c.has(_.target)&&u.setEdge(_.source,_.target);wk.layout(u);const d=new Map;let h=1/0,p=1/0,m=-1/0,y=-1/0;for(const _ of l){const S=u.node(_);if(!S)continue;const b=s.get(_),k=(b==null?void 0:b.width)??Ai,E=(b==null?void 0:b.height)??Ns,C=S.x-k/2,A=S.y-E/2;d.set(_,{x:C,y:A}),C<h&&(h=C),A<p&&(p=A),C+k>m&&(m=C+k),A+E>y&&(y=A+E)}if(Number.isFinite(h)&&Number.isFinite(p))for(const[_,S]of d)d.set(_,{x:S.x-h,y:S.y-p});let x=Number.isFinite(m)?m-h:0,N=Number.isFinite(y)?y-p:0;for(const _ of e){const S=o.get(_);if(!S)continue;const b=s.get(_);x=Math.max(x,S.x+((b==null?void 0:b.width)??Ai)),N=Math.max(N,S.y+((b==null?void 0:b.height)??Ns))}return{positions:d,width:x,height:N}}function QL(e,n,i={}){const s=i.direction??"LR",o=i.pinned??new Map,u=i.measured??new Map,l=new Map;for(const S of e){const b=Qu(S),k=l.get(b);k?k.push(S.id):l.set(b,[S.id])}const d=Array.from(l.keys()).sort().map(S=>({sid:S,...XL(l.get(S),n,s,u,o)})),h=GL(u),p=i.availableHeight&&i.availableHeight>0?i.availableHeight:Number.POSITIVE_INFINITY,m=S=>{const b=[[]];let k=0;for(const E of d)b.length<S&&k>0&&k+E.height>p&&(b.push([]),k=0),b[b.length-1].push(E),k+=E.height+xk;return b},y=S=>S.reduce((b,k)=>Math.max(b,k.width),0)+YL;let x=m(i.availableWidth?KL:1);x.length>1&&x.reduce((b,k)=>b+y(k),0)+h*(x.length-1)>(i.availableWidth??0)&&(x=m(1));const N=new Map;let _=0;for(const S of x){let b=0;for(const{positions:k,height:E}of S){for(const[C,A]of k)N.set(C,{x:A.x+_,y:A.y+b});b+=E+xk}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const k=N.get(S.id);return k?{...S,position:k}:S})}function ZL(e,n,i,s){const u=Cs+Xu,l=60,c=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??Ai,h:(x==null?void 0:x.height)??Ns}},d=new Map(e.map(y=>[y.id,Qu(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,x)=>y.pos.y-x.pos.y||y.pos.x-x.pos.x||y.id.localeCompare(x.id)),m=[];for(const{id:y,pos:x}of p){const{w:N,h:_}=c(y),S=d.get(y)??"_default";if(i.has(y)){h.push({x:x.x,y:x.y,w:N,h:_,sid:S});continue}let b=x.y;for(let k=0;k<h.length+1;k++){const E=h.find(C=>{const A=C.sid===S?24:l,P=C.sid===S?24:u;return x.x<C.x+C.w+A&&C.x<x.x+N+A&&b<C.y+C.h+P&&C.y<b+_+P});if(!E)break;b=E.y+E.h+(E.sid===S?24:u)}b!==x.y&&(n.set(y,{x:x.x,y:b}),m.push(y)),h.push({x:x.x,y:b,w:N,h:_,sid:S})}return m}function JL(e,n,i,s,o){const u=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??Ai,h:(x==null?void 0:x.height)??Ns}},l=y=>i.get(y)??n.get(y),c=new Map,d=[];for(const y of e){const x=l(y.id);if(!x)continue;const{w:N,h:_}=u(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=Qu(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else d.push({x:x.x,y:x.y,w:N,h:_})}if(c.size===0)return[];const h=Cs+Xu,p=(y,x,N,_)=>d.some(S=>y<S.x+S.w+Cs&&S.x<y+N+Cs&&x<S.y+S.h+h&&S.y<x+_+h),m=[];for(const y of[...c.keys()].sort()){const x=c.get(y);let N=1/0,_=1/0,S=-1/0,b=-1/0;for(const M of x){const R=l(M.id),{w:L,h:F}=u(M.id);N=Math.min(N,R.x),_=Math.min(_,R.y),S=Math.max(S,R.x+L),b=Math.max(b,R.y+F)}const k=S-N,E=b-_,C=[...new Set(d.map(M=>Math.round(M.x)))].sort((M,R)=>M-R),A=C.length?C:[N],P=[0,...d.map(M=>M.y+M.h+h)].sort((M,R)=>M-R);let I=null;e:for(const M of A)for(const R of P){if(R>=_)break;if(!p(M,R,k,E)){I={x:M,y:R};break e}}if(I){const M=I.x-N,R=I.y-_;for(const L of x){const F=l(L.id);n.set(L.id,{x:F.x+M,y:F.y+R})}m.push(y)}for(const M of x){const R=l(M.id),{w:L,h:F}=u(M.id);d.push({x:R.x,y:R.y,w:L,h:F})}}return m}function e$(e,n,i,s,o,u=!1){const d=Cs+Xu+1,h=8,p=1.75,m=200,y=.7,x=.01,N=I=>{const M=s.get(I);return{w:(M==null?void 0:M.width)??Ai,h:(M==null?void 0:M.height)??Ns}},_=I=>i.get(I)??n.get(I),S=new Map;for(const I of e){if(!_(I.id))continue;const M=Qu(I),R=S.get(M);R?R.push(I):S.set(M,[I])}const b=[],k=new Set,E=new Set;for(const I of[...S.keys()].sort()){const M=S.get(I);let R=1/0,L=1/0,F=-1/0,Q=-1/0,X=!1;for(const ne of M){const K=_(ne.id),{w:D,h:V}=N(ne.id);R=Math.min(R,K.x),L=Math.min(L,K.y),F=Math.max(F,K.x+D),Q=Math.max(Q,K.y+V),i.has(ne.id)&&(X=!0)}const j=F-R,G=Q-L;E.add(I);const U=o.get(I);U&&(j>U.w+h||G>U.h+h)&&k.add(I),o.set(I,{w:j,h:G}),b.push({sid:I,members:M.map(ne=>ne.id),x:R,y:L,w:j,h:G,anchored:X,mass:1})}for(const I of[...o.keys()])E.has(I)||o.delete(I);if(u||k.size===0)return[];for(const I of b)k.has(I.sid)&&(I.mass=8);const C=new Map(b.map(I=>[I.sid,I.x])),A=new Map(b.map(I=>[I.sid,I.y]));for(let I=0;I<m;I++){const M=new Map,R=new Map;let L=0;for(let F=0;F<b.length;F++)for(let Q=F+1;Q<b.length;Q++){const X=b[F],j=b[Q];if(X.anchored&&j.anchored)continue;const G=X.x+X.w/2,U=X.y+X.h/2,ne=j.x+j.w/2,K=j.y+j.h/2,D=(X.w+j.w)/2+61-Math.abs(G-ne),V=(X.h+j.h)/2+d-Math.abs(U-K);if(D<=0||V<=0)continue;const O=(Ye,Qe)=>!Ye.anchored&&!(Qe<0&&Ye.x<=0),B=(Ye,Qe)=>!Ye.anchored&&!(Qe<0&&Ye.y<=0),ae=(Ye,Qe,et)=>{const Be=Ye===Qe,Ze=Be?X.sid<j.sid?-1:1:Math.sign(Ye-Qe);return et(X,Ze)||et(j,-Ze)?Ze:Be&&(et(X,-Ze)||et(j,Ze))?-Ze:0},z=ae(G,ne,O),W=ae(U,K,B),J=z!==0,se=W!==0;if(!J&&!se)continue;const ue=J&&(!se||D*p<V),[he,ge,Me,Fe]=ue?[z,D,M,O]:[W,V,R,B],Re=Fe(X,he),Pe=Fe(j,-he),be=X.mass,Oe=j.mass,ve=Re?Pe?Oe/(be+Oe):1:0,ye=Pe?Re?be/(be+Oe):1:0,qe=ge*y;Me.set(X.sid,(Me.get(X.sid)??0)+he*qe*ve),Me.set(j.sid,(Me.get(j.sid)??0)-he*qe*ye),L+=qe}for(const F of b)F.anchored||(F.x=Math.max(0,F.x+(M.get(F.sid)??0)),F.y=Math.max(0,F.y+(R.get(F.sid)??0)));if(L<x)break}const P=[];for(const I of b){const M=I.x-C.get(I.sid),R=I.y-A.get(I.sid);if(!(Math.abs(M)<1&&Math.abs(R)<1)){for(const L of I.members){if(i.has(L))continue;const F=n.get(L);F&&n.set(L,{x:F.x+M,y:F.y+R})}P.push(I.sid)}}return P}const t$=600;function jg(e,n){return!(e.exitAt!=null&&n-e.exitAt>t$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function n$(e,n){const i=new Set;for(const s of e.agents.values())jg(s,n)&&i.add(s.id);return i}function Ei(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function r$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const i$={agent:wP,sessionGroup:jP},s$=420,lu=18,o$=9e4,a$=200,u$=5*6e4,l$=6,c$=2*6e4,yv="agent-dag.layout",wv="agent-dag.viewport",rC="agent-dag.summariesDismissed",iC="agent-dag.sessionListOpen",sC="agent-dag.detailOpen",oC="agent-dag.usagePanelOpen",_k="agent-dag.accountsPanelOpen";function f$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(iC)==="1"}catch{return!1}}function d$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(iC,e?"1":"0")}catch{}}function h$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(sC)==="1"}catch{return!1}}function p$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(sC,e?"1":"0")}catch{}}function m$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(oC);try{return e===null?!0:e==="1"}catch{return!0}}function g$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(oC,e?"1":"0")}catch{}}function v$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(rC);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 Sk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(rC,JSON.stringify(i))}catch{}}function y$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(yv);if(!n)return e;const i=JSON.parse(n);if(!("v"in i)){const o=Object.entries(i).filter(([,u])=>u&&typeof u.x=="number"&&typeof u.y=="number");return{positions:o,pins:o.map(([u])=>u)}}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 cg(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(yv,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function w$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(wv);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 x$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(wv,JSON.stringify(e))}catch{}}function bk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(yv)}catch{}try{window.localStorage.removeItem(wv)}catch{}}}function _$(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}))}))},u=JSON.stringify(o,null,2),l=new Blob([u],{type:"application/json"}),c=URL.createObjectURL(l),d=document.createElement("a"),h=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");d.href=c,d.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Ag={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Ig={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},S$={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 aC(e){return e.startsWith("mcp__")?"mcp":S$[e]??"other"}function uC(e,n){var s,o,u;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)||(u=e.firstPrompt)!=null&&u.toLowerCase().includes(i))return!0;for(const l of e.tools)if(l.name.toLowerCase().includes(i))return!0;return!1}function b$(e,n){if(!n)return null;const i=new Set([n]);let s=n;for(;s;){const u=e.agents.get(s);if(!(u!=null&&u.parentId)||i.has(u.parentId))break;i.add(u.parentId),s=u.parentId}let o=!0;for(;o;){o=!1;for(const u of e.agents.values())u.parentId&&i.has(u.parentId)&&!i.has(u.id)&&(i.add(u.id),o=!0)}return i}function k$(e,n,i,s,o,u,l,c,d,h,p,m,y,x,N,_,S,b){const k=[],E=[],C=new Set;if(u)for(const R of e.agents.values())uC(R,u)&&C.add(R.id);for(const R of e.agents.values()){if(!S.has(R.id))continue;const L=u?!C.has(R.id):!1,F=R.exitAt!=null,Q=_!=null&&!_.has(R.id),X=[L?"rf-dim":"",F?"rf-exiting":"",Q?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,j=l.get(R.id);if(k.push({id:R.id,type:"agent",position:{x:0,y:0},data:{...R,now:n,dim:L,onOpenContext:b},className:X,...j?{width:j.width,height:j.height}:null}),R.parentId&&S.has(R.parentId)){const G=Zg(R.sessionId),U=R.state==="active"?`hsl(${G} 80% 72%)`:`hsl(${G} 50% 55%)`,ne=u&&!C.has(R.id)&&!C.has(R.parentId),K=F,D=N.size>0&&(N.has(R.id)||N.has(R.parentId)),V=_!=null&&!_.has(R.id)&&!_.has(R.parentId),O=R.state==="active"?2:1.5,B=D?O+1.5:O,ae=ne||K?.2:V?.12:1,z=[K?"rf-edge-exiting":"",D?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;E.push({id:`e:${R.parentId}->${R.id}`,source:R.parentId,target:R.id,animated:(R.state==="active"||D)&&!ne&&!K,type:"smoothstep",style:{stroke:U,strokeWidth:B,opacity:ae,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:z})}}const A=k.filter(R=>!o.has(R.id)&&!m.has(R.id));if(A.length>0||y!==x.current){if(A.length>0){const R=QL(k,E,{direction:"LR",pinned:o,measured:l,availableWidth:i,availableHeight:s});for(const L of R)m.has(L.id)||m.set(L.id,L.position);JL(k,m,o,l,new Set(A.map(L=>L.id)))}ZL(k,m,o,l),x.current=y}const P=e$(k,m,o,l,c,!h||p);P.length>0&&d(P);for(const R of Array.from(m.keys()))e.agents.has(R)||m.delete(R);if(e.agents.size>0)for(const R of Array.from(o.keys()))e.agents.has(R)||o.delete(R);const I=[];let M=!1;for(const R of k){let L=o.get(R.id)??m.get(R.id);L||(L={x:0,y:0},m.set(R.id,L),M=!0),I.push({...R,position:L})}return M&&(x.current=""),{nodes:I,edges:E}}function E$(){return v.jsx(Xg,{children:v.jsx(N$,{})})}function N$(){const e=zo(),n=q.useRef(Cg()),[,i]=q.useState(0),s=q.useCallback(()=>i(Z=>Z+1),[]),[o,u]=q.useState(()=>new Set),[l,c]=q.useState(null),[d,h]=q.useState(null),p=q.useCallback((Z,te)=>{u(ce=>{if(!te)return new Set([Z]);const me=new Set(ce);return me.has(Z)?me.delete(Z):me.add(Z),me}),c(ce=>te&&ce===Z?ce:Z)},[]),m=q.useCallback(()=>{u(new Set),c(null)},[]),[y,x]=q.useState(null),[N,_]=q.useState(null),S=q.useCallback(Z=>_(Z),[]),b=q.useRef(v$()),[k,E]=q.useState(f$);q.useEffect(()=>{d$(k)},[k]);const[C,A]=q.useState(h$);q.useEffect(()=>{p$(C)},[C]);const[P,I]=q.useState(m$);q.useEffect(()=>{g$(P)},[P]);const[M,R]=q.useState(()=>{try{const Z=window.localStorage.getItem(_k);return Z===null?!0:Z==="1"}catch{return!0}});q.useEffect(()=>{try{window.localStorage.setItem(_k,M?"1":"0")}catch{}},[M]);const[L,F]=q.useState(null),[Q,X]=q.useState(!1),[j,G]=q.useState(0),[U,ne]=q.useState(0);q.useEffect(()=>{fetch("/api/sound-hook").then(Z=>Z.ok?Z.json():null).then(Z=>{Z!=null&&Z.ok&&(F(Z.enabled===!0),G((Z.foreign??[]).filter(te=>te.worksHere).length),ne(typeof Z.parked=="number"?Z.parked:0))}).catch(()=>{})},[]);const K=q.useCallback(async()=>{X(!0);try{const te=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!L})})).json().catch(()=>null);te!=null&&te.ok&&F(te.enabled===!0),fetch("/api/sound-hook").then(ce=>ce.ok?ce.json():null).then(ce=>{ce!=null&&ce.ok&&(G((ce.foreign??[]).filter(me=>me.worksHere).length),ne(typeof ce.parked=="number"?ce.parked:0))}).catch(()=>{})}catch{}finally{X(!1)}},[L]),D=q.useCallback(()=>{E(Z=>(Z||R(!1),!Z))},[]),V=q.useCallback(()=>{R(Z=>(Z||E(!1),!Z))},[]),[O,B]=q.useState(!1),[ae,z]=q.useState(0),W=q.useRef(null),[J,se]=q.useState(0),[ue,he]=q.useState(!1),[ge,Me]=q.useState(!1),Fe=q.useRef([]),[Re,Pe]=q.useState(Date.now()),be=q.useRef(y$()).current;q.useRef(!1);const Oe=q.useRef(new Map(be.positions.filter(([Z])=>be.pins.includes(Z)))),ve=q.useRef(null),ye=q.useState(()=>w$())[0],[qe,Ye]=q.useState(""),[Qe,et]=q.useState(()=>new Set),[Be,Ze]=q.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[At,Vt]=q.useState(!1),It=q.useRef(null);q.useEffect(()=>{document.documentElement.dataset.theme=Be;try{window.localStorage.setItem("agent-dag.theme",Be)}catch{}},[Be]),q.useEffect(()=>{if(!ye)return;const Z=window.setTimeout(()=>{try{e.setViewport(ye,{duration:0})}catch{}},60);return()=>window.clearTimeout(Z)},[e,ye]);const pt=q.useRef(!0),tt=q.useRef(null);q.useEffect(()=>{const Z=new EventSource("/events");return Z.addEventListener("open",()=>{he(!0),Vt(!0)}),Z.addEventListener("error",()=>he(!1)),Z.addEventListener("replay-end",()=>{pt.current=!1,tt.current!=null&&(window.clearTimeout(tt.current),tt.current=null),s()}),Z.addEventListener("hook",te=>{try{const ce=JSON.parse(te.data);if(ge){Fe.current.push(ce);return}n.current=Fw(n.current,ce),ce.replay===!0||pt.current||Date.now()-ce.receivedAt>3e4?(tt.current!=null&&window.clearTimeout(tt.current),tt.current=window.setTimeout(()=>{tt.current=null,s()},120)):(tt.current!=null&&(window.clearTimeout(tt.current),tt.current=null),s())}catch{}}),()=>{Z.close(),tt.current!=null&&(window.clearTimeout(tt.current),tt.current=null)}},[ge,s]),q.useEffect(()=>{if(!ge&&Fe.current.length!==0){for(const Z of Fe.current)n.current=Fw(n.current,Z);Fe.current.length=0,s()}},[ge,s]),q.useEffect(()=>{const Z=setInterval(()=>{const te=Date.now();Pe(te);let ce=rP(n.current,te,o$);tP(n.current,te,a$,u$)&&(ce=!0),nP(n.current,te,l$,c$)&&(ce=!0),ce&&s()},250);return()=>clearInterval(Z)},[s]);const kt=q.useRef(null),We=q.useRef(0),Et=420,Ge=q.useCallback((Z=500)=>{try{const we=document.querySelector(".canvas-wrap"),Le=Array.from(document.querySelectorAll(".react-flow__node")).filter(Je=>Je.offsetWidth>0);if(!we||Le.length===0)return;const ze=we.getBoundingClientRect(),Te=e.getViewport();if(!Number.isFinite(Te.zoom)||Te.zoom<=0)return;const Ke=Je=>(Je-ze.left-Te.x)/Te.zoom,it=Je=>(Je-ze.top-Te.y)/Te.zoom,Kt=Le.map(Je=>Je.getBoundingClientRect()),Rr=Math.min(...Kt.map(Je=>Ke(Je.left))),Gi=Math.max(...Kt.map(Je=>Ke(Je.right))),jr=Math.min(...Kt.map(Je=>it(Je.top))),li=Math.max(...Kt.map(Je=>it(Je.bottom))),ci=Gi-Rr,fn=li-jr;if(!(ci>0&&fn>0))return;const Ct=Math.max(.2,Math.min(1,(ze.width-160)/(ci+Et)*.86,(ze.height-160)/fn*.86));e.setViewport({x:80-Rr*Ct,y:Math.max(80,(ze.height-fn*Ct)/2)-jr*Ct,zoom:Ct},{duration:Z}),We.current=Date.now(),window.setTimeout(()=>{try{const Je={x:80-Rr*Ct,y:Math.max(80,(ze.height-fn*Ct)/2)-jr*Ct,zoom:Ct},Ar=e.getViewport();(Math.abs(Ar.zoom-Ct)>.01||Math.abs(Ar.x-Je.x)>2)&&e.setViewport(Je,{duration:0})}catch{}},Z+60)}catch{}},[e]),ft=q.useRef(""),on=q.useRef(null),Lt=q.useRef(0),wt=q.useCallback(()=>{Lt.current=Date.now()},[]),an="agent-dag.autoFitDisabled",Bt=q.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(an)==="1"}catch{return!1}})()),[vn,un]=q.useState(Bt.current),yn=q.useCallback(()=>{if(!Bt.current){Bt.current=!0,un(!0);try{window.localStorage.setItem(an,"1")}catch{}}},[]),wn=q.useCallback(()=>{Bt.current=!1,un(!1);try{window.localStorage.removeItem(an)}catch{}Ge(400)},[e,Ge]);q.useEffect(()=>{const Z=setInterval(()=>{if(Bt.current||Date.now()-Lt.current<800)return;const te=n.current,ce=Date.now(),me=[];for(const Ke of te.agents.values())jg(Ke,ce)&&me.push({id:Ke.id});if(me.length===0)return;const _e=e.getViewport(),we=window.innerWidth-360,Le=window.innerHeight-52;let ze=!1,Te=!1;for(const{id:Ke}of me){const it=Mn.current.get(Ke),Kt=Oe.current.get(Ke)??Nt.current.get(Ke);if(!it||!Kt)continue;Te=!0;const Rr=Kt.x*_e.zoom+_e.x,Gi=Kt.y*_e.zoom+_e.y,jr=(Kt.x+it.width)*_e.zoom+_e.x,li=(Kt.y+it.height)*_e.zoom+_e.y;if(jr>0&&Rr<we&&li>0&&Gi<Le){ze=!0;break}}Te&&!ze&&Ge(600)},1500);return()=>clearInterval(Z)},[e]);const _r=q.useRef(!1),Mn=q.useRef(new Map),ti=q.useRef(0),$i=q.useCallback(Z=>{const te=Mn.current;let ce=!1;for(const me of Z.nodeInternals.values()){const _e=me.width,we=me.height;if(_e==null||we==null)continue;const Le=te.get(me.id);Le?(Math.abs(Le.height-we)>4||Math.abs(Le.width-_e)>4)&&(te.set(me.id,{width:_e,height:we}),ce=!0):(te.set(me.id,{width:_e,height:we}),ce=!0)}return ce&&(ti.current+=1),ti.current},[]),Sr=Xe($i),[ni,ir]=q.useState(0);q.useEffect(()=>{let Z=0;const te=()=>{const me=Mn.current;let _e=!1;for(const we of document.querySelectorAll(".react-flow__node[data-id]")){const Le=we.getAttribute("data-id");if(!Le)continue;const ze=we.offsetWidth,Te=we.offsetHeight;if(!ze||!Te)continue;const Ke=me.get(Le);(!Ke||Math.abs(Ke.width-ze)>4||Math.abs(Ke.height-Te)>4)&&(me.set(Le,{width:ze,height:Te}),_e=!0)}_e&&ir(we=>we+1)};if(_r.current)return;let ce=0;return document.visibilityState==="hidden"?ce=window.setTimeout(te,32):Z=requestAnimationFrame(te),()=>{cancelAnimationFrame(Z),window.clearTimeout(ce)}});const Nt=q.useRef(new Map(be.positions)),Pn=q.useRef(""),Yn=q.useMemo(()=>{const Z=[];for(const te of n.current.agents.values())jg(te,Re)&&Z.push(te.id+(te.parentId?`>${te.parentId}`:""));return Z.sort(),`${Z.join("|")}#sv${Sr}.${ni}`},[n.current,n.current.lastSeq,Re,Sr,ni]),ln=q.useRef(null);q.useEffect(()=>(ln.current!=null&&window.clearTimeout(ln.current),ln.current=window.setTimeout(()=>{cg(Nt.current,Oe.current)},1500),()=>{ln.current!=null&&window.clearTimeout(ln.current)}),[Yn]),q.useEffect(()=>{if(ft.current===Yn)return;const Z=ft.current;if(ft.current=Yn,!Z||Bt.current)return;Date.now()-We.current>1200&&Ge(400),kt.current&&window.clearTimeout(kt.current),kt.current=window.setTimeout(()=>{Bt.current||Ge(500)},280)},[Yn,e,Ge]);const Kn=q.useMemo(()=>{if(o.size===0)return null;const Z=new Set;for(const te of o){const ce=b$(n.current,te);if(ce)for(const me of ce)Z.add(me)}return Z.size>0?Z:null},[n.current,n.current.lastSeq,o]),Xn=q.useMemo(()=>n$(n.current,Re),[n.current,n.current.lastSeq,Re]),br=q.useRef(null),[kr,Di]=q.useState({w:0,h:0});q.useEffect(()=>{const Z=br.current;if(!Z||typeof ResizeObserver>"u")return;const te=new ResizeObserver(ce=>{var _e;const me=(_e=ce[0])==null?void 0:_e.contentRect;me&&Di(we=>Math.abs(we.w-me.width)>40||Math.abs(we.h-me.height)>40?{w:me.width,h:me.height}:we)});return te.observe(Z),Di({w:Z.clientWidth,h:Z.clientHeight}),()=>te.disconnect()},[]);const Fi=q.useRef(new Map),[xn,zi]=q.useState(!1);q.useEffect(()=>{const Z=window.setTimeout(()=>zi(!0),2500);return()=>window.clearTimeout(Z)},[]);const[Bi,ri]=q.useState(!1),cn=q.useRef(null),[Er,ii]=q.useState(!1),Ui=q.useCallback(()=>{cn.current&&(window.clearTimeout(cn.current),cn.current=null),ri(!1)},[]),Hi=q.useCallback(Z=>{Z.length!==0&&queueMicrotask(()=>{ri(!0),cn.current&&window.clearTimeout(cn.current),cn.current=window.setTimeout(()=>ri(!1),s$+80)})},[]);q.useEffect(()=>()=>{cn.current&&window.clearTimeout(cn.current)},[]);const Vi=kr.w>0?kr.w*.92:0,nt=kr.h>0?kr.h:0,{nodes:Wt,edges:si}=q.useMemo(()=>k$(n.current,Re,Vi,nt,Oe.current,qe,Mn.current,Fi.current,Hi,xn,Er,Nt.current,Yn,Pn,o,Kn,Xn,S),[n.current,n.current.lastSeq,Re,Vi,nt,xn,Er,qe,Yn,o,Kn,Xn,S,ae]),oi=q.useMemo(()=>{const Z=new Map;for(const ce of Wt){const me=ce.data;if(!(me!=null&&me.sessionId)||me.exitAt!=null)continue;const _e=ce.width,we=ce.height;if(_e==null||we==null)continue;const Le=ce.position.x,ze=ce.position.y,Te=Le+_e,Ke=ze+we,it=Z.get(me.sessionId);it?(it.minX=Math.min(it.minX,Le),it.minY=Math.min(it.minY,ze),it.maxX=Math.max(it.maxX,Te),it.maxY=Math.max(it.maxY,Ke)):Z.set(me.sessionId,{minX:Le,minY:ze,maxX:Te,maxY:Ke})}const te=[];for(const[ce,me]of Z){const _e=me.maxX-me.minX+lu*2,we=me.maxY-me.minY+lu*2;te.push({id:`group:${ce}`,type:"sessionGroup",position:{x:me.minX-lu,y:me.minY-lu},data:{sessionId:ce,w:_e,h:we},width:_e,height:we,style:{width:_e,height:we},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return te},[Wt,Re]),Nr=q.useMemo(()=>{const Z=[...oi,...Wt],te=W.current;return!te||te.size===0?Z:Z.map(ce=>{const me=te.get(ce.id);return me?{...ce,position:me}:ce})},[oi,Wt,J]),Wi=q.useMemo(()=>{if(!qe)return null;const Z=new Set;for(const te of n.current.agents.values())uC(te,qe)&&Z.add(te.id);return Z},[n.current,n.current.lastSeq,qe]),ai=q.useMemo(()=>{const Z=new Set;for(const te of n.current.agents.values())for(const ce of te.tools)Z.add(aC(ce.name));return Object.keys(Ag).filter(te=>Z.has(te))},[n.current,n.current.lastSeq]),_n=q.useMemo(()=>{const Z=new Map;for(const ce of n.current.agents.values())for(const me of ce.tools){if(!me.name.startsWith("mcp__"))continue;const _e=me.name.slice(5),we=_e.indexOf("__"),Le=we>0?_e.slice(0,we):_e;Z.set(Le,(Z.get(Le)??0)+1)}const te=[];for(const[ce,me]of Z){let _e=5381;for(let we=0;we<ce.length;we++)_e=(_e<<5)+_e^ce.charCodeAt(we);te.push({server:ce,count:me,hue:Math.abs(_e)%360})}return te.sort((ce,me)=>me.count-ce.count),te},[n.current,n.current.lastSeq]),Gt=q.useCallback(Z=>{et(te=>{const ce=new Set(te);return ce.has(Z)?ce.delete(Z):ce.add(Z),ce})},[]),gt=l?n.current.agents.get(l):null,Yt=d?Array.from(n.current.agents.values()).flatMap(Z=>Z.tools).find(Z=>Z.id===d)??null:null,Ls=q.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Cg(),Oe.current.clear(),Mn.current.clear(),Nt.current.clear(),Pn.current="",bk(),m(),s()},[s,m]),$s=q.useCallback(()=>{Oe.current.clear(),Nt.current.clear(),Pn.current="",bk(),s(),window.setTimeout(()=>Ge(500),80)},[s,e,Ge]),Yo=q.useCallback(()=>Ge(500),[Ge]),Cr=q.useCallback(Z=>{if(Wt.length===0)return;const te=Wt.slice().sort((we,Le)=>we.position.y-Le.position.y||we.position.x-Le.position.x),ce=l?te.findIndex(we=>we.id===l):-1;let me;ce===-1?me=Z===1?0:te.length-1:me=(ce+Z+te.length)%te.length;const _e=te[me];_e&&(p(_e.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[_e]})}catch{}We.current=Date.now()},30))},[Wt,l,p,e]);q.useEffect(()=>{const Z=te=>{var me,_e;const ce=((me=te.target)==null?void 0:me.tagName)==="INPUT";if(te.key==="Escape"){ce?te.target.blur():m();return}if(!ce){if(te.key==="/"){te.preventDefault(),(_e=It.current)==null||_e.focus();return}te.key===" "&&(te.preventDefault(),Me(we=>!we)),(te.key==="c"||te.key==="C")&&Ls(),(te.key==="r"||te.key==="R")&&$s(),(te.key==="f"||te.key==="F")&&Yo(),(te.key==="l"||te.key==="L")&&D(),(te.key==="h"||te.key==="H")&&B(we=>!we),(te.key==="u"||te.key==="U")&&I(we=>!we),(te.key==="a"||te.key==="A")&&V(),(te.key==="j"||te.key==="J")&&Cr(1),(te.key==="k"||te.key==="K")&&Cr(-1),(te.key==="t"||te.key==="T")&&Ze(we=>we==="dark"?"light":"dark")}};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[Ls,$s,Yo,m,Cr]);const Tr=n.current.agents.size,ui=new Set(Array.from(n.current.agents.values()).map(Z=>Z.sessionId)).size,Mt=q.useMemo(()=>{let Z=0,te=0,ce=0,me=0,_e=0,we=0,Le=0,ze=0,Te=0;for(const Ke of n.current.agents.values()){Z+=Ke.usage.inputTokens,te+=Ke.usage.outputTokens,ce+=Ke.usage.cacheReadTokens,me+=Ke.usage.cacheCreateTokens;const it=rn(Ke.usage,Ke.model);_e+=it.total,we+=it.input,Le+=it.output,ze+=it.cacheRead,Te+=it.cacheWrite}return{inT:Z,outT:te,cacheR:ce,cacheC:me,sum:Z+te,cost:{total:_e,input:we,output:Le,cacheRead:ze,cacheWrite:Te}}},[n.current,n.current.lastSeq]);return v.jsxs("div",{className:"app",children:[v.jsxs("header",{className:"topbar",children:[v.jsxs("div",{className:"brand",children:[v.jsx("span",{className:"logo"}),"agents-deck ",v.jsxs("span",{className:"v",children:["v","1.30.7"]})]}),gt&&(()=>{const Z=rn(gt.usage,gt.model),te=Math.max(0,((gt.endedAt??Re)-gt.startedAt)/1e3),ce=gt.state==="active"?ku(Z.total,te):null,me=o.size-1;return v.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${gt.label}`,onClick:()=>{try{const _e=Wt.find(we=>we.id===gt.id);_e&&e.fitView({padding:.35,duration:500,nodes:[_e]}),We.current=Date.now()}catch{}},children:[v.jsx("span",{className:`state-pill state-${gt.state}`,children:gt.state==="active"?"live":gt.state}),v.jsx("span",{className:"selected-label",children:gt.label}),Z.total>0&&v.jsxs("span",{className:"selected-cost",children:[He(Z.total),ce?v.jsxs("span",{className:"selected-rate",children:[" · ",ce]}):null]}),me>0&&v.jsxs("span",{className:"selected-extra",children:["+",me]}),v.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:_e=>{_e.stopPropagation(),m()},children:"×"})]})})(),v.jsxs("div",{className:"actions",children:[v.jsxs("div",{className:"search",children:[v.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),v.jsx("input",{ref:It,type:"text",placeholder:"Search agents, cwd, tools…",value:qe,onChange:Z=>Ye(Z.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),qe?v.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Ye(""),children:"×"}):v.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),v.jsxs("span",{className:"status",role:"status",children:[v.jsx("span",{className:`pill ${ue?"live":"dead"}`,title:ue?"Receiving events":"SSE disconnected",children:ue?"live":"offline"}),v.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[v.jsx("span",{className:"count",children:ui}),v.jsx("span",{className:"lbl",children:"sessions"})]}),v.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[v.jsx("span",{className:"count",children:Tr}),v.jsx("span",{className:"lbl",children:"agents"})]}),v.jsxs("span",{className:"stat",title:"Total hook events received",children:[v.jsx("span",{className:"count",children:n.current.totalEvents}),v.jsx("span",{className:"lbl",children:"events"})]}),Mt.sum>0&&v.jsxs("span",{className:"stat",title:`in:${Mt.inT.toLocaleString()} out:${Mt.outT.toLocaleString()} cache-r:${Mt.cacheR.toLocaleString()} cache-c:${Mt.cacheC.toLocaleString()}`,children:[v.jsx("span",{className:"count",children:r$(Mt.sum)}),v.jsx("span",{className:"lbl",children:"tokens"})]}),_n.length>0&&v.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
60
60
  ${_n.map(Z=>` ${Z.server}: ${Z.count} call${Z.count===1?"":"s"}`).join(`
61
61
  `)}`,children:[_n.slice(0,6).map(Z=>v.jsx("span",{className:"mcp-dot",style:{background:`hsl(${Z.hue} 65% 65%)`}},Z.server)),_n.length>6&&v.jsxs("span",{className:"mcp-more",children:["+",_n.length-6]}),v.jsx("span",{className:"lbl",children:"mcp"})]}),Mt.cost.total>0&&(()=>{let Z=0,te=0;for(const _e of n.current.agents.values()){if(_e.state!=="active")continue;const we=rn(_e.usage,_e.model);Z+=we.total,te=Math.max(te,((_e.endedAt??Re)-_e.startedAt)/1e3)}const ce=te>0?ku(Z,te):null,me=`input ${He(Mt.cost.input)} + output ${He(Mt.cost.output)} + cache r ${He(Mt.cost.cacheRead)} + cache w ${He(Mt.cost.cacheWrite)}${ce?`
62
62
  active burn: ${ce}`:""}`;return v.jsxs("span",{className:"stat",title:me,children:[v.jsx("span",{className:"count",children:He(Mt.cost.total)}),v.jsxs("span",{className:"lbl",children:["cost",ce?` · ${ce}`:""]})]})})()]}),v.jsx("button",{className:`btn ${ge?"warn":""}`,onClick:()=>Me(Z=>!Z),title:"Pause/resume live updates (Space)",children:ge?`Resume${Fe.current.length?` · ${Fe.current.length}`:""}`:"Pause"}),v.jsx("button",{className:`btn icon-btn ${P?"primary":""}`,onClick:()=>I(Z=>!Z),title:`${P?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel",children:"$"}),L!==null&&v.jsx("button",{className:`btn icon-btn ${L?"primary":""}`,onClick:Z=>{if(Z.shiftKey&&U>0){X(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(te=>te.ok?te.json():null).then(te=>{te!=null&&te.ok&&(F(te.enabled===!0),ne(te.parked??0))}).catch(()=>{}).finally(()=>X(!1));return}K()},disabled:Q,title:(L?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook")+(j>0?`