agent-dag 1.30.0 → 1.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -56,7 +56,7 @@ Error generating stack: `+w.message+`
|
|
|
56
56
|
*/var Y0;function XT(){if(Y0)return Ic;Y0=1;var e=Lo(),n=KT();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 C=u(null);if(C.current===null){var _={hasValue:!1,value:null};C.current=_}else _=C.current;C=c(function(){function b(M){if(!k){if(k=!0,E=M,M=y(M),x!==void 0&&_.hasValue){var I=_.value;if(x(I,M))return N=I}return N=M}if(I=N,s(E,M))return I;var $=y(M);return x!==void 0&&x(I,$)?(E=M,I):(E=M,N=$)}var k=!1,E,N,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,C[0],C[1]);return l(function(){_.hasValue=!0,_.value=S},[S]),d(S),S},Ic}var K0;function QT(){return K0||(K0=1,Ac.exports=XT()),Ac.exports}var ZT=QT();const JT=Mg(ZT),eR={},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(C=>C(n,x))}},o=()=>n,d={setState:s,getState:o,getInitialState:()=>h,subscribe:p=>(i.add(p),()=>i.delete(p)),destroy:()=>{(eR?"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},tR=e=>e?X0(e):X0,{useDebugValue:nR}=oe,{useSyncExternalStoreWithSelector:rR}=JT,iR=e=>e;function kk(e,n=iR,i){const s=rR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,i);return nR(s),s}const Q0=(e,n)=>{const i=tR(e),s=(o,u=n)=>kk(i,o,u);return Object.assign(s,i),s},sR=(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 oR={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 aR(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=aR(e+"",i),o,u=-1,l=s.length;if(arguments.length<2){for(;++u<l;)if((o=(e=s[u]).type)&&(o=uR(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 uR(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]=oR,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 lR(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 cR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ek(e){var n=Cu(e);return(n.local?cR:lR)(n)}function fR(){}function Pg(e){return e==null?fR:function(){return this.querySelector(e)}}function dR(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 hR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function pR(){return[]}function Nk(e){return e==null?pR:function(){return this.querySelectorAll(e)}}function mR(e){return function(){return hR(e.apply(this,arguments))}}function gR(e){typeof e=="function"?e=mR(e):e=Nk(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 Ck(e){return function(){return this.matches(e)}}function Tk(e){return function(n){return n.matches(e)}}var vR=Array.prototype.find;function yR(e){return function(){return vR.call(this.children,e)}}function wR(){return this.firstElementChild}function xR(e){return this.select(e==null?wR:yR(typeof e=="function"?e:Tk(e)))}var _R=Array.prototype.filter;function SR(){return Array.from(this.children)}function bR(e){return function(){return _R.call(this.children,e)}}function kR(e){return this.selectAll(e==null?SR:bR(typeof e=="function"?e:Tk(e)))}function ER(e){typeof e!="function"&&(e=Ck(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 Rk(e){return new Array(e.length)}function NR(){return new gn(this._enter||this._groups.map(Rk),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 CR(e){return function(){return e}}function TR(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 RR(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 jR(e){return e.__data__}function AR(e,n){if(!arguments.length)return Array.from(this,jR);var i=n?RR:TR,s=this._parents,o=this._groups;typeof e!="function"&&(e=CR(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=IR(e.call(p,p&&p.__data__,h,s)),C=x.length,_=c[h]=new Array(C),S=l[h]=new Array(C),b=d[h]=new Array(y);i(p,m,_,S,b,x,n);for(var k=0,E=0,N,A;k<C;++k)if(N=_[k]){for(k>=E&&(E=k+1);!(A=S[E])&&++E<C;);N._next=A||null}}return l=new gn(l,s),l._enter=c,l._exit=d,l}function IR(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function MR(){return new gn(this._exit||this._groups.map(Rk),this._parents)}function PR(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 OR(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,C=0;C<m;++C)(x=h[C]||p[C])&&(y[C]=x);for(;d<o;++d)c[d]=i[d];return new gn(c,this._parents)}function qR(){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 LR(e){e||(e=$R);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 $R(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function DR(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function FR(){return Array.from(this)}function zR(){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 BR(){let e=0;for(const n of this)++e;return e}function UR(){return!this.node()}function HR(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 VR(e){return function(){this.removeAttribute(e)}}function WR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function GR(e,n){return function(){this.setAttribute(e,n)}}function YR(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function KR(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function XR(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 QR(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?WR:VR:typeof n=="function"?i.local?XR:KR:i.local?YR:GR)(i,n))}function jk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ZR(e){return function(){this.style.removeProperty(e)}}function JR(e,n,i){return function(){this.style.setProperty(e,n,i)}}function e2(e,n,i){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,i)}}function t2(e,n,i){return arguments.length>1?this.each((n==null?ZR:typeof n=="function"?e2:JR)(e,n,i??"")):Ts(this.node(),e)}function Ts(e,n){return e.style.getPropertyValue(n)||jk(e).getComputedStyle(e,null).getPropertyValue(n)}function n2(e){return function(){delete this[e]}}function r2(e,n){return function(){this[e]=n}}function i2(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function s2(e,n){return arguments.length>1?this.each((n==null?n2:typeof n=="function"?i2:r2)(e,n)):this.node()[e]}function Ak(e){return e.trim().split(/^|\s+/)}function Og(e){return e.classList||new Ik(e)}function Ik(e){this._node=e,this._names=Ak(e.getAttribute("class")||"")}Ik.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 Mk(e,n){for(var i=Og(e),s=-1,o=n.length;++s<o;)i.add(n[s])}function Pk(e,n){for(var i=Og(e),s=-1,o=n.length;++s<o;)i.remove(n[s])}function o2(e){return function(){Mk(this,e)}}function a2(e){return function(){Pk(this,e)}}function u2(e,n){return function(){(n.apply(this,arguments)?Mk:Pk)(this,e)}}function l2(e,n){var i=Ak(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"?u2:n?o2:a2)(i,n))}function c2(){this.textContent=""}function f2(e){return function(){this.textContent=e}}function d2(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function h2(e){return arguments.length?this.each(e==null?c2:(typeof e=="function"?d2:f2)(e)):this.node().textContent}function p2(){this.innerHTML=""}function m2(e){return function(){this.innerHTML=e}}function g2(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function v2(e){return arguments.length?this.each(e==null?p2:(typeof e=="function"?g2:m2)(e)):this.node().innerHTML}function y2(){this.nextSibling&&this.parentNode.appendChild(this)}function w2(){return this.each(y2)}function x2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function _2(){return this.each(x2)}function S2(e){var n=typeof e=="function"?e:Ek(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function b2(){return null}function k2(e,n){var i=typeof e=="function"?e:Ek(e),s=n==null?b2:typeof n=="function"?n:Pg(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),s.apply(this,arguments)||null)})}function E2(){var e=this.parentNode;e&&e.removeChild(this)}function N2(){return this.each(E2)}function C2(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function T2(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function R2(e){return this.select(e?T2:C2)}function j2(e){return arguments.length?this.property("__data__",e):this.node().__data__}function A2(e){return function(n){e.call(this,n,this.__data__)}}function I2(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 M2(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 P2(e,n,i){return function(){var s=this.__on,o,u=A2(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 O2(e,n,i){var s=I2(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?P2:M2,o=0;o<u;++o)this.each(c(s[o],n,i));return this}function Ok(e,n,i){var s=jk(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 q2(e,n){return function(){return Ok(this,e,n)}}function L2(e,n){return function(){return Ok(this,e,n.apply(this,arguments))}}function $2(e,n){return this.each((typeof n=="function"?L2:q2)(e,n))}function*D2(){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 qk=[null];function gn(e,n){this._groups=e,this._parents=n}function $o(){return new gn([[document.documentElement]],qk)}function F2(){return this}gn.prototype=$o.prototype={constructor:gn,select:dR,selectAll:gR,selectChild:xR,selectChildren:kR,filter:ER,data:AR,enter:NR,exit:MR,join:PR,merge:OR,selection:F2,order:qR,sort:LR,call:DR,nodes:FR,node:zR,size:BR,empty:UR,each:HR,attr:QR,style:t2,property:s2,classed:l2,text:h2,html:v2,raise:w2,lower:_2,append:S2,insert:k2,remove:N2,clone:R2,datum:j2,on:O2,dispatch:$2,[Symbol.iterator]:D2};function Rn(e){return typeof e=="string"?new gn([[document.querySelector(e)]],[document.documentElement]):new gn([[e]],qk)}function z2(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Bn(e,n){if(e=z2(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 B2={passive:!1},Ro={capture:!0,passive:!1};function Oc(e){e.stopImmediatePropagation()}function bs(e){e.preventDefault(),e.stopImmediatePropagation()}function Lk(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 $k(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 U2(e){return!e.ctrlKey&&!e.button}function H2(){return this.parentNode}function V2(e,n){return n??{x:e.x,y:e.y}}function W2(){return navigator.maxTouchPoints||"ontouchstart"in this}function G2(){var e=U2,n=H2,i=V2,s=W2,o={},u=Nu("start","drag","end"),l=0,c,d,h,p,m=0;function y(N){N.on("mousedown.drag",x).filter(s).on("touchstart.drag",S).on("touchmove.drag",b,B2).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(N,A){if(!(p||!e.call(this,N,A))){var M=E(this,n.call(this,N,A),N,A,"mouse");M&&(Rn(N.view).on("mousemove.drag",C,Ro).on("mouseup.drag",_,Ro),Lk(N.view),Oc(N),h=!1,c=N.clientX,d=N.clientY,M("start",N))}}function C(N){if(bs(N),!h){var A=N.clientX-c,M=N.clientY-d;h=A*A+M*M>m}o.mouse("drag",N)}function _(N){Rn(N.view).on("mousemove.drag mouseup.drag",null),$k(N.view,h),bs(N),o.mouse("end",N)}function S(N,A){if(e.call(this,N,A)){var M=N.changedTouches,I=n.call(this,N,A),$=M.length,R,L;for(R=0;R<$;++R)(L=E(this,I,N,A,M[R].identifier,M[R]))&&(Oc(N),L("start",N,M[R]))}}function b(N){var A=N.changedTouches,M=A.length,I,$;for(I=0;I<M;++I)($=o[A[I].identifier])&&(bs(N),$("drag",N,A[I]))}function k(N){var A=N.changedTouches,M=A.length,I,$;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),I=0;I<M;++I)($=o[A[I].identifier])&&(Oc(N),$("end",N,A[I]))}function E(N,A,M,I,$,R){var L=u.copy(),O=Bn(R||M,A),Q,V,j;if((j=i.call(N,new dg("beforestart",{sourceEvent:M,target:y,identifier:$,active:l,x:O[0],y:O[1],dx:0,dy:0,dispatch:L}),I))!=null)return Q=j.x-O[0]||0,V=j.y-O[1]||0,function Y(U,ne,X){var F=O,W;switch(U){case"start":o[$]=Y,W=l++;break;case"end":delete o[$],--l;case"drag":O=Bn(X||ne,A),W=l;break}L.call(U,N,new dg(U,{sourceEvent:ne,subject:j,target:y,identifier:$,active:W,x:O[0]+Q,y:O[1]+V,dx:O[0]-F[0],dy:O[1]-F[1],dispatch:L}),I)}}return y.filter=function(N){return arguments.length?(e=typeof N=="function"?N:Xa(!!N),y):e},y.container=function(N){return arguments.length?(n=typeof N=="function"?N:Xa(N),y):n},y.subject=function(N){return arguments.length?(i=typeof N=="function"?N:Xa(N),y):i},y.touchable=function(N){return arguments.length?(s=typeof N=="function"?N:Xa(!!N),y):s},y.on=function(){var N=u.on.apply(u,arguments);return N===u?y:N},y.clickDistance=function(N){return arguments.length?(m=(N=+N)*N,y):Math.sqrt(m)},y}function qg(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function Dk(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*",Y2=/^#([0-9a-f]{3,8})$/,K2=new RegExp(`^rgb\\(${ks},${ks},${ks}\\)$`),X2=new RegExp(`^rgb\\(${tr},${tr},${tr}\\)$`),Q2=new RegExp(`^rgba\\(${ks},${ks},${ks},${Ao}\\)$`),Z2=new RegExp(`^rgba\\(${tr},${tr},${tr},${Ao}\\)$`),J2=new RegExp(`^hsl\\(${Ao},${tr},${tr}\\)$`),ej=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:tj,formatHsl:nj,formatRgb:nw,toString:nw});function tw(){return this.rgb().formatHex()}function tj(){return this.rgb().formatHex8()}function nj(){return Fk(this).formatHsl()}function nw(){return this.rgb().formatRgb()}function Io(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=Y2.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=K2.exec(e))?new nn(n[1],n[2],n[3],1):(n=X2.exec(e))?new nn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=Q2.exec(e))?Qa(n[1],n[2],n[3],n[4]):(n=Z2.exec(e))?Qa(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=J2.exec(e))?ow(n[1],n[2]/100,n[3]/100,1):(n=ej.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 rj(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?rj(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,Dk(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:ij,formatRgb:sw,toString:sw}));function iw(){return`#${Ci(this.r)}${Ci(this.g)}${Ci(this.b)}`}function ij(){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 Fk(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 sj(e,n,i,s){return arguments.length===1?Fk(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,sj,Dk(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 zk=e=>()=>e;function oj(e,n){return function(i){return e+i*n}}function aj(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 uj(e){return(e=+e)==1?Bk:function(n,i){return i-n?aj(n,i,e):zk(isNaN(n)?i:n)}}function Bk(e,n){var i=n-e;return i?oj(e,i):zk(isNaN(e)?n:e)}const uw=(function e(n){var i=uj(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=Bk(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 lj(e){return function(){return e}}function cj(e){return function(n){return e(n)+""}}function fj(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]?cj(d[0].x):lj(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 Uk(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 dj(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?mg:Uk(n.a,n.b,n.c,n.d,n.e,n.f)}function hj(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,Uk(e.a,e.b,e.c,e.d,e.e,e.f))}function Hk(e,n,i,s){function o(h){return h.length?h.pop()+" ":""}function u(h,p,m,y,x,C){if(h!==m||p!==y){var _=x.push("translate(",null,n,null,i);C.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,C){if(h!==m||p!==y){var _=x.push(o(x)+"scale(",null,",",null,")");C.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 C=-1,_=y.length,S;++C<_;)m[(S=y[C]).i]=S.x(x);return m.join("")}}}var pj=Hk(dj,"px, ","px)","deg)"),mj=Hk(hj,", ",")",")"),gj=1e-12;function cw(e){return((e=Math.exp(e))+1/e)/2}function vj(e){return((e=Math.exp(e))-1/e)/2}function yj(e){return((e=Math.exp(2*e))-1)/(e+1)}const wj=(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,C=m-d,_=x*x+C*C,S,b;if(_<gj)b=Math.log(y/h)/n,S=function(I){return[c+I*x,d+I*C,h*Math.exp(n*I*b)]};else{var k=Math.sqrt(_),E=(y*y-h*h+s*_)/(2*h*i*k),N=(y*y-h*h-s*_)/(2*y*i*k),A=Math.log(Math.sqrt(E*E+1)-E),M=Math.log(Math.sqrt(N*N+1)-N);b=(M-A)/n,S=function(I){var $=I*b,R=cw(A),L=h/(i*k)*(R*yj(n*$+A)-vj(A));return[c+L*x,d+L*C,h*R/cw(n*$+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,Vk=1e3,vu,bo,yu=0,Ii=0,Tu=0,Mo=typeof performance=="object"&&performance.now?performance:Date,Wk=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lg(){return Ii||(Wk(xj),Ii=Mo.now()+Tu)}function xj(){Ii=0}function wu(){this._call=this._time=this._next=null}wu.prototype=Gk.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 Gk(e,n,i){var s=new wu;return s.restart(e,n,i),s}function _j(){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{_j()}finally{Rs=0,bj(),Ii=0}}function Sj(){var e=Mo.now(),n=e-yu;n>Vk&&(Tu-=n,yu=e)}function bj(){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(Sj,Vk)),Rs=1,Wk(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 kj=Nu("start","end","cancel","interrupt"),Ej=[],Yk=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;Nj(e,i,{name:n,index:s,group:o,on:kj,tween:Ej,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Yk})}function $g(e,n){var i=Wn(e,n);if(i.state>Yk)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 Nj(e,n,i){var s=e.__transition,o;s[n]=i,i.timer=Gk(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 Cj(e){return this.each(function(){hu(this,e)})}function Tj(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 Rj(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 jj(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?Tj:Rj)(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 Kk(e,n){var i;return(typeof n=="number"?Kr:n instanceof Io?uw:(i=Io(n))?(n=i,uw):fj)(e,n)}function Aj(e){return function(){this.removeAttribute(e)}}function Ij(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mj(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 Pj(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 Oj(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 qj(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 Lj(e,n){var i=Cu(e),s=i==="transform"?mj:Kk;return this.attrTween(e,typeof n=="function"?(i.local?qj:Oj)(i,s,Dg(this,"attr."+e,n)):n==null?(i.local?Ij:Aj)(i):(i.local?Pj:Mj)(i,s,n))}function $j(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function Dj(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function Fj(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 zj(e,n){var i,s;function o(){var u=n.apply(this,arguments);return u!==s&&(i=(s=u)&&$j(e,u)),i}return o._value=n,o}function Bj(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?Fj:zj)(s,n))}function Uj(e,n){return function(){$g(this,e).delay=+n.apply(this,arguments)}}function Hj(e,n){return n=+n,function(){$g(this,e).delay=n}}function Vj(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Uj:Hj)(n,e)):Wn(this.node(),n).delay}function Wj(e,n){return function(){nr(this,e).duration=+n.apply(this,arguments)}}function Gj(e,n){return n=+n,function(){nr(this,e).duration=n}}function Yj(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Wj:Gj)(n,e)):Wn(this.node(),n).duration}function Kj(e,n){if(typeof n!="function")throw new Error;return function(){nr(this,e).ease=n}}function Xj(e){var n=this._id;return arguments.length?this.each(Kj(n,e)):Wn(this.node(),n).ease}function Qj(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;nr(this,e).ease=i}}function Zj(e){if(typeof e!="function")throw new Error;return this.each(Qj(this._id,e))}function Jj(e){typeof e!="function"&&(e=Ck(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 eA(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 tA(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 nA(e,n,i){var s,o,u=tA(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 rA(e,n){var i=this._id;return arguments.length<2?Wn(this.node(),i).on.on(e):this.each(nA(i,e,n))}function iA(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function sA(){return this.on("end.remove",iA(this._id))}function oA(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 aA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Nk(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,C=Wn(p,i),_=0,S=y.length;_<S;++_)(x=y[_])&&Ru(x,n,i,_,y,C);u.push(y),l.push(p)}return new vr(u,l,n,i)}var uA=$o.prototype.constructor;function lA(){return new uA(this._groups,this._parents)}function cA(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 Xk(e){return function(){this.style.removeProperty(e)}}function fA(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 dA(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 hA(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=Xk(n)):void 0;(h!==i||o!==p)&&(s=(i=h).copy()).on(l,o=p),d.on=s}}function pA(e,n,i){var s=(e+="")=="transform"?pj:Kk;return n==null?this.styleTween(e,cA(e,s)).on("end.style."+e,Xk(e)):typeof n=="function"?this.styleTween(e,dA(e,s,Dg(this,"style."+e,n))).each(hA(this._id,e)):this.styleTween(e,fA(e,s,n),i).on("end.style."+e,null)}function mA(e,n,i){return function(s){this.style.setProperty(e,n.call(this,s),i)}}function gA(e,n,i){var s,o;function u(){var l=n.apply(this,arguments);return l!==o&&(s=(o=l)&&mA(e,l,i)),s}return u._value=n,u}function vA(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,gA(e,n,i??""))}function yA(e){return function(){this.textContent=e}}function wA(e){return function(){var n=e(this);this.textContent=n??""}}function xA(e){return this.tween("text",typeof e=="function"?wA(Dg(this,"text",e)):yA(e==null?"":e+""))}function _A(e){return function(n){this.textContent=e.call(this,n)}}function SA(e){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&_A(o)),n}return s._value=e,s}function bA(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,SA(e))}function kA(){for(var e=this._name,n=this._id,i=Qk(),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 EA(){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 NA=0;function vr(e,n,i,s){this._groups=e,this._parents=n,this._name=i,this._id=s}function Qk(){return++NA}var hr=$o.prototype;vr.prototype={constructor:vr,select:oA,selectAll:aA,selectChild:hr.selectChild,selectChildren:hr.selectChildren,filter:Jj,merge:eA,selection:lA,transition:kA,call:hr.call,nodes:hr.nodes,node:hr.node,size:hr.size,empty:hr.empty,each:hr.each,on:rA,attr:Lj,attrTween:Bj,style:pA,styleTween:vA,text:xA,textTween:bA,remove:sA,tween:jj,delay:Vj,duration:Yj,ease:Xj,easeVarying:Zj,end:EA,[Symbol.iterator]:hr[Symbol.iterator]};function CA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var TA={time:null,delay:0,duration:250,ease:CA};function RA(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 jA(e){var n,i;e instanceof vr?(n=e._id,e=e._name):(n=Qk(),(i=TA).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||RA(d,n));return new vr(s,this._parents,e,n)}$o.prototype.interrupt=Cj;$o.prototype.transition=jA;const eu=e=>()=>e;function AA(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 IA(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function MA(){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 PA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function OA(){return navigator.maxTouchPoints||"ontouchstart"in this}function qA(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 Zk(){var e=IA,n=MA,i=qA,s=PA,o=OA,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=wj,h=Nu("start","zoom","end"),p,m,y,x=500,C=150,_=0,S=10;function b(j){j.property("__zoom",mw).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",L).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",Q).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(j,Y,U,ne){var X=j.selection?j.selection():j;X.property("__zoom",mw),j!==X?A(j,Y,U,ne):X.interrupt().each(function(){M(this,arguments).event(ne).start().zoom(null,typeof Y=="function"?Y.apply(this,arguments):Y).end()})},b.scaleBy=function(j,Y,U,ne){b.scaleTo(j,function(){var X=this.__zoom.k,F=typeof Y=="function"?Y.apply(this,arguments):Y;return X*F},U,ne)},b.scaleTo=function(j,Y,U,ne){b.transform(j,function(){var X=n.apply(this,arguments),F=this.__zoom,W=U==null?N(X):typeof U=="function"?U.apply(this,arguments):U,P=F.invert(W),B=typeof Y=="function"?Y.apply(this,arguments):Y;return i(E(k(F,B),W,P),X,l)},U,ne)},b.translateBy=function(j,Y,U,ne){b.transform(j,function(){return i(this.__zoom.translate(typeof Y=="function"?Y.apply(this,arguments):Y,typeof U=="function"?U.apply(this,arguments):U),n.apply(this,arguments),l)},null,ne)},b.translateTo=function(j,Y,U,ne,X){b.transform(j,function(){var F=n.apply(this,arguments),W=this.__zoom,P=ne==null?N(F):typeof ne=="function"?ne.apply(this,arguments):ne;return i(gr.translate(P[0],P[1]).scale(W.k).translate(typeof Y=="function"?-Y.apply(this,arguments):-Y,typeof U=="function"?-U.apply(this,arguments):-U),F,l)},ne,X)};function k(j,Y){return Y=Math.max(u[0],Math.min(u[1],Y)),Y===j.k?j:new mr(Y,j.x,j.y)}function E(j,Y,U){var ne=Y[0]-U[0]*j.k,X=Y[1]-U[1]*j.k;return ne===j.x&&X===j.y?j:new mr(j.k,ne,X)}function N(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function A(j,Y,U,ne){j.on("start.zoom",function(){M(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(ne).end()}).tween("zoom",function(){var X=this,F=arguments,W=M(X,F).event(ne),P=n.apply(X,F),B=U==null?N(P):typeof U=="function"?U.apply(X,F):U,ae=Math.max(P[1][0]-P[0][0],P[1][1]-P[0][1]),z=X.__zoom,G=typeof Y=="function"?Y.apply(X,F):Y,J=d(z.invert(B).concat(ae/z.k),G.invert(B).concat(ae/G.k));return function(se){if(se===1)se=G;else{var ue=J(se),he=ae/ue[2];se=new mr(he,B[0]-ue[0]*he,B[1]-ue[1]*he)}W.zoom(null,se)}})}function M(j,Y,U){return!U&&j.__zooming||new I(j,Y)}function I(j,Y){this.that=j,this.args=Y,this.active=0,this.sourceEvent=null,this.extent=n.apply(j,Y),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,Y){return this.mouse&&j!=="mouse"&&(this.mouse[1]=Y.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=Y.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=Y.invert(this.touch1[0])),this.that.__zoom=Y,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var Y=Rn(this.that).datum();h.call(j,this.that,new AA(j,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),Y)}};function $(j,...Y){if(!e.apply(this,arguments))return;var U=M(this,Y).event(j),ne=this.__zoom,X=Math.max(u[0],Math.min(u[1],ne.k*Math.pow(2,s.apply(this,arguments)))),F=Bn(j);if(U.wheel)(U.mouse[0][0]!==F[0]||U.mouse[0][1]!==F[1])&&(U.mouse[1]=ne.invert(U.mouse[0]=F)),clearTimeout(U.wheel);else{if(ne.k===X)return;U.mouse=[F,ne.invert(F)],hu(this),U.start()}yo(j),U.wheel=setTimeout(W,C),U.zoom("mouse",i(E(k(ne,X),U.mouse[0],U.mouse[1]),U.extent,l));function W(){U.wheel=null,U.end()}}function R(j,...Y){if(y||!e.apply(this,arguments))return;var U=j.currentTarget,ne=M(this,Y,!0).event(j),X=Rn(j.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",ae,!0),F=Bn(j,U),W=j.clientX,P=j.clientY;Lk(j.view),$c(j),ne.mouse=[F,this.__zoom.invert(F)],hu(this),ne.start();function B(z){if(yo(z),!ne.moved){var G=z.clientX-W,J=z.clientY-P;ne.moved=G*G+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){X.on("mousemove.zoom mouseup.zoom",null),$k(z.view,ne.moved),yo(z),ne.event(z).end()}}function L(j,...Y){if(e.apply(this,arguments)){var U=this.__zoom,ne=Bn(j.changedTouches?j.changedTouches[0]:j,this),X=U.invert(ne),F=U.k*(j.shiftKey?.5:2),W=i(E(k(U,F),ne,X),n.apply(this,Y),l);yo(j),c>0?Rn(this).transition().duration(c).call(A,W,ne,j):Rn(this).call(b.transform,W,ne,j)}}function O(j,...Y){if(e.apply(this,arguments)){var U=j.touches,ne=U.length,X=M(this,Y,j.changedTouches.length===ne).event(j),F,W,P,B;for($c(j),W=0;W<ne;++W)P=U[W],B=Bn(P,this),B=[B,this.__zoom.invert(B),P.identifier],X.touch0?!X.touch1&&X.touch0[2]!==B[2]&&(X.touch1=B,X.taps=0):(X.touch0=B,F=!0,X.taps=1+!!p);p&&(p=clearTimeout(p)),F&&(X.taps<2&&(m=B[0],p=setTimeout(function(){p=null},x)),hu(this),X.start())}}function Q(j,...Y){if(this.__zooming){var U=M(this,Y).event(j),ne=j.changedTouches,X=ne.length,F,W,P,B;for(yo(j),F=0;F<X;++F)W=ne[F],P=Bn(W,this),U.touch0&&U.touch0[2]===W.identifier?U.touch0[0]=P:U.touch1&&U.touch1[2]===W.identifier&&(U.touch1[0]=P);if(W=U.that.__zoom,U.touch1){var ae=U.touch0[0],z=U.touch0[1],G=U.touch1[0],J=U.touch1[1],se=(se=G[0]-ae[0])*se+(se=G[1]-ae[1])*se,ue=(ue=J[0]-z[0])*ue+(ue=J[1]-z[1])*ue;W=k(W,Math.sqrt(se/ue)),P=[(ae[0]+G[0])/2,(ae[1]+G[1])/2],B=[(z[0]+J[0])/2,(z[1]+J[1])/2]}else if(U.touch0)P=U.touch0[0],B=U.touch0[1];else return;U.zoom("touch",i(E(W,P,B),U.extent,l))}}function V(j,...Y){if(this.__zooming){var U=M(this,Y).event(j),ne=j.changedTouches,X=ne.length,F,W;for($c(j),y&&clearTimeout(y),y=setTimeout(function(){y=null},x),F=0;F<X;++F)W=ne[F],U.touch0&&U.touch0[2]===W.identifier?delete U.touch0:U.touch1&&U.touch1[2]===W.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&&(W=Bn(W,this),Math.hypot(m[0]-W[0],m[1]-W[1])<S)){var P=Rn(this).on("dblclick.zoom");P&&P.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}bk();const ju=q.createContext(null),LA=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.`},Jk=yr.error001();function Xe(e,n){const i=q.useContext(ju);if(i===null)throw new Error(Jk);return kk(i,e,n)}const bt=()=>{const e=q.useContext(ju);if(e===null)throw new Error(Jk);return q.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},$A=e=>e.userSelectionActive?"none":"all";function Fg({position:e,children:n,className:i,style:s,...o}){const u=Xe($A),l=`${e}`.split("-");return oe.createElement("div",{className:qt(["react-flow__panel",i,...l]),style:{...s,pointerEvents:u},...o},n)}function DA({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 FA=({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}),C=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:C,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 zA=q.memo(FA);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,eE=(e,n)=>{const i=gw(e.x,35,n.width-35)*20,s=gw(e.y,35,n.height-35)*20;return[i,s]},tE=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},nE=(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}),rE=({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}),BA=(e,n)=>rE(nE(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)},UA=e=>jn(e.width)&&jn(e.height)&&jn(e.x)&&jn(e.y),jn=e=>!isNaN(e)&&isFinite(e),ht=Symbol.for("internals"),iE=["Enter"," ","Escape"],HA=(e,n)=>{},VA=e=>"nativeEvent"in e;function xg(e){var o,u;const n=VA(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 sE=e=>"clientX"in e,Zr=(e,n)=>{var u,l;const i=sE(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(zA,{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 oE({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 aE({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 uE({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]=aE({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:C,interactionWidth:_})=>{const[S,b,k]=uE({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:C,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}},WA=({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 GA({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=WA({source:d,sourcePosition:n,target:h}),m=p.x!==0?"x":"y",y=p[m];let x=[],C,_;const S={x:0,y:0},b={x:0,y:0},[k,E,N,A]=oE({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(l[m]*c[m]===-1){C=o.x??k,_=o.y??E;const I=[{x:C,y:d.y},{x:C,y:h.y}],$=[{x:d.x,y:_},{x:h.x,y:_}];l[m]===y?x=m==="x"?I:$:x=m==="x"?$:I}else{const I=[{x:d.x,y:h.y}],$=[{x:h.x,y:d.y}];if(m==="x"?x=l.x===y?$:I:x=l.y===y?I:$,n===s){const V=Math.abs(e[m]-i[m]);if(V<=u){const j=Math.min(u-1,u-V);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 V=m==="x"?"y":"x",j=l[m]===c[V],Y=d[V]>h[V],U=d[V]<h[V];(l[m]===1&&(!j&&Y||j&&U)||l[m]!==1&&(!j&&U||j&&Y))&&(x=m==="x"?I:$)}const R={x:d.x+S.x,y:d.y+S.y},L={x:h.x+b.x,y:h.y+b.y},O=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));O>=Q?(C=(R.x+L.x)/2,_=x[0].y):(C=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],C,_,N,A]}function YA(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,C]=GA({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=YA(p[k-1],b,p[k+1],l):E=`${k===0?"M":"L"}${b.x} ${b.y}`,S+=E,S},""),m,y,x,C]}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:C,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:C,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 KA({sourceX:e,sourceY:n,targetX:i,targetY:s}){const[o,u,l,c]=oE({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[C,_,S]=KA({sourceX:e,sourceY:n,targetX:i,targetY:s});return oe.createElement(Fo,{path:C,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 lE({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,C]=aE({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,C]}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:C,pathOptions:_,interactionWidth:S})=>{const[b,k,E]=lE({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:C,interactionWidth:S})});Su.displayName="BezierEdge";const Wg=q.createContext(null),XA=Wg.Provider;Wg.Consumer;const QA=()=>q.useContext(Wg),ZA=e=>"id"in e&&"source"in e&&"target"in e,JA=({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("&")}`,eI=(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)),tI=(e,n)=>{if(!e.source||!e.target)return n;let i;return ZA(e)?i={...e}:i={...e,id:JA(e)},eI(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},cE=({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 nE(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 rE(i)},fE=(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:C=!1}=p;if(l&&!x||C)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,N=(m||0)*(y||0);(k||E||b>=N||p.dragging)&&h.push(p)}),h},dE=(e,n)=>{const i=e.map(s=>s.id);return n.filter(s=>i.includes(s.source)||i.includes(s.target))},hE=(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 nI(e,n,i,s,o,u){const{x:l,y:c}=Zr(e),h=n.elementsFromPoint(l,c).find(C=>C.classList.contains("react-flow__handle"));if(h){const C=h.getAttribute("data-nodeid");if(C){const _=Gg(void 0,h),S=h.getAttribute("data-handleid"),b=u({nodeId:C,id:S,type:_});if(b){const k=o.find(E=>E.nodeId===C&&E.type===_&&E.id===S);return{handle:{id:S,type:_,nodeId:C,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(C=>{const _=Math.sqrt((C.x-i.x)**2+(C.y-i.y)**2);if(_<=s){const S=u(C);_<=m&&(_<m?p=[{handle:C,validHandleResult:S}]:_===m&&p.push({handle:C,validHandleResult:S}),m=_)}}),!p.length)return{handle:null,validHandleResult:pE()};if(p.length===1)return p[0];const y=p.some(({validHandleResult:C})=>C.isValid),x=p.some(({handle:C})=>C.type==="target");return p.find(({handle:C,validHandleResult:_})=>x?C.type==="target":y?_.isValid:!0)||p[0]}const rI={source:null,target:null,sourceHandle:null,targetHandle:null},pE=()=>({handleDomNode:null,isValid:!1,connection:rI,endHandle:null});function mE(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={...pE(),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"),C=d.classList.contains("connectableend"),_={source:c?m:i,sourceHandle:c?y:s,target:c?i:m,targetHandle:c?s:y};h.connection=_,x&&C&&(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 iI({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 sI(e,n){let i=null;return n?i="valid":e&&!n&&(i="invalid"),i}function gE({event:e,handleId:n,nodeId:i,onConnect:s,isTarget:o,getState:u,setState:l,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const p=tE(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:x,connectionRadius:C,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:k}=u();let E=0,N;const{x:A,y:M}=Zr(e),I=p==null?void 0:p.elementFromPoint(A,M),$=Gg(d,I),R=y==null?void 0:y.getBoundingClientRect();if(!R||!$)return;let L,O=Zr(e,R),Q=!1,V=null,j=!1,Y=null;const U=iI({nodes:b(),nodeId:i,handleId:n,handleType:$}),ne=()=>{if(!x)return;const[W,P]=eE(O,R);S({x:W,y:P}),E=requestAnimationFrame(ne)};l({connectionPosition:O,connectionStatus:null,connectionNodeId:i,connectionHandleId:n,connectionHandleType:$,connectionStartHandle:{nodeId:i,handleId:n,type:$},connectionEndHandle:null}),_==null||_(e,{nodeId:i,handleId:n,handleType:$});function X(W){const{transform:P}=u();O=Zr(W,R);const{handle:B,validHandleResult:ae}=nI(W,p,bg(O,P,!1,[1,1]),C,U,z=>mE(z,m,i,n,o?"target":"source",c,p));if(N=B,Q||(ne(),Q=!0),Y=ae.handleDomNode,V=ae.connection,j=ae.isValid,l({connectionPosition:N&&j?cE({x:N.x,y:N.y},P):O,connectionStatus:sI(!!N,j),connectionEndHandle:ae.endHandle}),!N&&!j&&!Y)return Dc(L);V.source!==V.target&&Y&&(Dc(L),L=Y,Y.classList.add("connecting","react-flow__handle-connecting"),Y.classList.toggle("valid",j),Y.classList.toggle("react-flow__handle-valid",j))}function F(W){var P,B;(N||Y)&&V&&j&&(s==null||s(V)),(B=(P=u()).onConnectEnd)==null||B.call(P,W),d&&(h==null||h(W)),Dc(L),k(),cancelAnimationFrame(E),Q=!1,j=!1,V=null,Y=null,p.removeEventListener("mousemove",X),p.removeEventListener("mouseup",F),p.removeEventListener("touchmove",X),p.removeEventListener("touchend",F)}p.addEventListener("mousemove",X),p.addEventListener("mouseup",F),p.addEventListener("touchmove",X),p.addEventListener("touchend",F)}const bw=()=>!0,oI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),aI=(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}},vE=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 C=l||null,_=e==="target",S=bt(),b=QA(),{connectOnClick:k,noPanClassName:E}=Xe(oI,St),{connecting:N,clickConnecting:A}=Xe(aI(b,C,e),St);b||(L=(R=S.getState()).onError)==null||L.call(R,"010",yr.error010());const M=O=>{const{defaultEdgeOptions:Q,onConnect:V,hasDefaultEdges:j}=S.getState(),Y={...Q,...O};if(j){const{edges:U,setEdges:ne}=S.getState();ne(tI(Y,U))}V==null||V(Y),c==null||c(Y)},I=O=>{if(!b)return;const Q=sE(O);o&&(Q&&O.button===0||!Q)&&gE({event:O,handleId:C,nodeId:b,onConnect:M,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:i||S.getState().isValidConnection||bw}),Q?p==null||p(O):m==null||m(O)},$=O=>{const{onClickConnectStart:Q,onClickConnectEnd:V,connectionClickStartHandle:j,connectionMode:Y,isValidConnection:U}=S.getState();if(!b||!j&&!o)return;if(!j){Q==null||Q(O,{nodeId:b,handleId:C,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:C}});return}const ne=tE(O.target),X=i||U||bw,{connection:F,isValid:W}=mE({nodeId:b,id:C,type:e},Y,j.nodeId,j.handleId||null,j.type,X,ne);W&&M(F),V==null||V(O),S.setState({connectionClickStartHandle:null})};return oe.createElement("div",{"data-handleid":C,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${C}-${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&&!N||u&&N)}]),onMouseDown:I,onTouchStart:I,onClick:k?$:void 0,ref:x,...y},d)});vE.displayName="Handle";var As=q.memo(vE);const yE=({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}));yE.displayName="DefaultNode";var kg=q.memo(yE);const wE=({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}));wE.displayName="InputNode";var xE=q.memo(wE);const _E=({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);_E.displayName="OutputNode";var SE=q.memo(_E);const Yg=()=>null;Yg.displayName="GroupNode";const uI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),nu=e=>e.id;function lI(e,n){return St(e.selectedNodes.map(nu),n.selectedNodes.map(nu))&&St(e.selectedEdges.map(nu),n.selectedEdges.map(nu))}const bE=q.memo(({onSelectionChange:e})=>{const n=bt(),{selectedNodes:i,selectedEdges:s}=Xe(uI,lI);return q.useEffect(()=>{const o={nodes:i,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(u=>u(o))},[i,s,e]),null});bE.displayName="SelectionListener";const cI=e=>!!e.onSelectionChange;function fI({onSelectionChange:e}){const n=Xe(cI);return e||n?oe.createElement(bE,{onSelectionChange:e}):null}const dI=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 hI=({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:C,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:k,onEdgesChange:E,elementsSelectable:N,connectionMode:A,snapGrid:M,snapToGrid:I,translateExtent:$,connectOnClick:R,defaultEdgeOptions:L,fitView:O,fitViewOptions:Q,onNodesDelete:V,onEdgesDelete:j,onNodeDrag:Y,onNodeDragStart:U,onNodeDragStop:ne,onSelectionDrag:X,onSelectionDragStart:F,onSelectionDragStop:W,noPanClassName:P,nodeOrigin:B,rfId:ae,autoPanOnConnect:z,autoPanOnNodeDrag:G,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(dI,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",N,ye.setState),De("elevateNodesOnSelect",C,ye.setState),De("snapToGrid",I,ye.setState),De("snapGrid",M,ye.setState),De("onNodesChange",k,ye.setState),De("onEdgesChange",E,ye.setState),De("connectOnClick",R,ye.setState),De("fitViewOnInit",O,ye.setState),De("fitViewOnInitOptions",Q,ye.setState),De("onNodesDelete",V,ye.setState),De("onEdgesDelete",j,ye.setState),De("onNodeDrag",Y,ye.setState),De("onNodeDragStart",U,ye.setState),De("onNodeDragStop",ne,ye.setState),De("onSelectionDrag",X,ye.setState),De("onSelectionDragStart",F,ye.setState),De("onSelectionDragStop",W,ye.setState),De("noPanClassName",P,ye.setState),De("nodeOrigin",B,ye.setState),De("rfId",ae,ye.setState),De("autoPanOnConnect",z,ye.setState),De("autoPanOnNodeDrag",G,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($,be),gs(b,Oe),null},kw={display:"none"},pI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},kE="react-flow__node-desc",EE="react-flow__edge-desc",mI="react-flow__aria-live",gI=e=>e.ariaLiveMessage;function vI({rfId:e}){const n=Xe(gI);return oe.createElement("div",{id:`${mI}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:pI},n)}function yI({rfId:e,disableKeyboardA11y:n}){return oe.createElement(oe.Fragment,null,oe.createElement("div",{id:`${kE}-${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:`${EE}-${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(vI,{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 NE(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 NE(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 CE(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}=NE(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)}),CE(o,i,u),o}function TE(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 C=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}),_=C.every(S=>S.width&&S.height);if(C.length>0&&_){const S=Iu(C,m),{x:b,y:k,zoom:E}=hE(S,s,o,n.minZoom??u,n.maxZoom??l,n.padding??.1),N=gr.translate(b,k).scale(E);return typeof n.duration=="number"&&n.duration>0?c.transform(Ni(d,n.duration),N):c.transform(d,N),!0}}return!1}function wI(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 xI(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:wI(e,o)}),l==null||l(e)),n!=null&&n.length&&(h&&s({edges:xI(n,u)}),c==null||c(n))}const vs=()=>{},_I={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},SI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),bI=()=>{const e=bt(),{d3Zoom:n,d3Selection:i}=Xe(SI,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=>TE(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}=hE(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=cE(o,u);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:_I,[n,i])};function zo(){const e=bI(),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(),N=S(),A=typeof _=="function"?_(N):_;if(k)b(A);else if(E){const M=A.length===0?N.map(I=>({type:"remove",id:I.id})):A.map(I=>({item:I,type:"reset"}));E(M)}},[]),c=q.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:k,onEdgesChange:E}=n.getState(),N=typeof _=="function"?_(S):_;if(k)b(N);else if(E){const A=N.length===0?S.map(M=>({type:"remove",id:M.id})):N.map(M=>({item:M,type:"reset"}));E(A)}},[]),d=q.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:k,hasDefaultNodes:E,onNodesChange:N}=n.getState();if(E){const M=[...b(),...S];k(M)}else if(N){const A=S.map(M=>({item:M,type:"add"}));N(A)}},[]),h=q.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:k,hasDefaultEdges:E,onEdgesChange:N}=n.getState();if(E)k([...b,...S]);else if(N){const A=S.map(M=>({item:M,type:"add"}));N(A)}},[]),p=q.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[k,E,N]=b;return{nodes:_().map(A=>({...A})),edges:S.map(A=>({...A})),viewport:{x:k,y:E,zoom:N}}},[]),m=q.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:k,edges:E,hasDefaultNodes:N,hasDefaultEdges:A,onNodesDelete:M,onEdgesDelete:I,onNodesChange:$,onEdgesChange:R}=n.getState(),L=(_||[]).map(Y=>Y.id),O=(S||[]).map(Y=>Y.id),Q=k().reduce((Y,U)=>{const ne=U.parentNode||U.parentId,X=!L.includes(U.id)&&ne&&Y.find(W=>W.id===ne);return(typeof U.deletable=="boolean"?U.deletable:!0)&&(L.includes(U.id)||X)&&Y.push(U),Y},[]),V=E.filter(Y=>typeof Y.deletable=="boolean"?Y.deletable:!0),j=V.filter(Y=>O.includes(Y.id));if(Q||j){const Y=dE(Q,V),U=[...j,...Y],ne=U.reduce((X,F)=>(X.includes(F.id)||X.push(F.id),X),[]);if((A||N)&&(A&&n.setState({edges:E.filter(X=>!ne.includes(X.id))}),N&&(Q.forEach(X=>{b.delete(X.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(I==null||I(U),R&&R(ne.map(X=>({id:X,type:"remove"})))),Q.length>0&&(M==null||M(Q),$)){const X=Q.map(F=>({id:F.id,type:"remove"}));$(X)}}},[]),y=q.useCallback(_=>{const S=UA(_),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,N]=y(_);return k?(b||n.getState().getNodes()).filter(A=>{if(!N&&(A.id===E.id||!A.positionAbsolute))return!1;const M=vw(A),I=wg(M,k);return S&&I>0||I>=k.width*k.height}):[]},[]),C=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:C}),[e,i,s,o,u,l,c,d,h,p,m,x,C])}const kI={actInsideInputWithModifier:!1};var EI=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const i=bt(),{deleteElements:s}=zo(),o=qo(e,kI),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 NI(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},CI=(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},TI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),RI=({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:C,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:k,noWheelClassName:E,noPanClassName:N})=>{const A=q.useRef(),M=bt(),I=q.useRef(!1),$=q.useRef(!1),R=q.useRef(null),L=q.useRef({x:0,y:0,zoom:0}),{d3Zoom:O,d3Selection:Q,d3ZoomHandler:V,userSelectionActive:j}=Xe(TI,St),Y=qo(S),U=q.useRef(0),ne=q.useRef(!1),X=q.useRef();return NI(R),q.useEffect(()=>{if(R.current){const F=R.current.getBoundingClientRect(),W=Zk().scaleExtent([C,_]).translateExtent(x),P=Rn(R.current).call(W),B=gr.translate(y.x,y.y).scale(js(y.zoom,C,_)),ae=[[0,0],[F.width,F.height]],z=W.constrain()(B,ae,x);W.transform(P,z),W.wheelDelta(Tw),M.setState({d3Zoom:W,d3Selection:P,d3ZoomHandler:P.on("wheel.zoom"),transform:[z.x,z.y,z.k],domNode:R.current.closest(".react-flow")})}},[]),q.useEffect(()=>{Q&&O&&(l&&!Y&&!j?Q.on("wheel.zoom",F=>{if(ys(F,E))return!1;F.preventDefault(),F.stopImmediatePropagation();const W=Q.property("__zoom").k||1;if(F.ctrlKey&&u){const ue=Bn(F),he=Tw(F),ge=W*Math.pow(2,he);O.scaleTo(Q,ge,ue,F);return}const P=F.deltaMode===1?20:1;let B=d===Ti.Vertical?0:F.deltaX*P,ae=d===Ti.Horizontal?0:F.deltaY*P;!xu()&&F.shiftKey&&d!==Ti.Vertical&&(B=F.deltaY*P,ae=0),O.translateBy(Q,-(B/W)*c,-(ae/W)*c,{internal:!0});const z=iu(Q.property("__zoom")),{onViewportChangeStart:G,onViewportChange:J,onViewportChangeEnd:se}=M.getState();clearTimeout(X.current),ne.current||(ne.current=!0,n==null||n(F,z),G==null||G(z)),ne.current&&(e==null||e(F,z),J==null||J(z),X.current=setTimeout(()=>{i==null||i(F,z),se==null||se(z),ne.current=!1},150))},{passive:!1}):typeof V<"u"&&Q.on("wheel.zoom",function(F,W){if(!b&&F.type==="wheel"&&!F.ctrlKey||ys(F,E))return null;F.preventDefault(),V.call(this,F,W)},{passive:!1}))},[j,l,d,Q,O,V,Y,u,b,E,n,e,i]),q.useEffect(()=>{O&&O.on("start",F=>{var B,ae;if(!F.sourceEvent||F.sourceEvent.internal)return null;U.current=(B=F.sourceEvent)==null?void 0:B.button;const{onViewportChangeStart:W}=M.getState(),P=iu(F.transform);I.current=!0,L.current=P,((ae=F.sourceEvent)==null?void 0:ae.type)==="mousedown"&&M.setState({paneDragging:!0}),W==null||W(P),n==null||n(F.sourceEvent,P)})},[O,n]),q.useEffect(()=>{O&&(j&&!I.current?O.on("zoom",null):j||O.on("zoom",F=>{var P;const{onViewportChange:W}=M.getState();if(M.setState({transform:[F.transform.x,F.transform.y,F.transform.k]}),$.current=!!(s&&Cw(m,U.current??0)),(e||W)&&!((P=F.sourceEvent)!=null&&P.internal)){const B=iu(F.transform);W==null||W(B),e==null||e(F.sourceEvent,B)}}))},[j,O,e,m,s]),q.useEffect(()=>{O&&O.on("end",F=>{if(!F.sourceEvent||F.sourceEvent.internal)return null;const{onViewportChangeEnd:W}=M.getState();if(I.current=!1,M.setState({paneDragging:!1}),s&&Cw(m,U.current??0)&&!$.current&&s(F.sourceEvent),$.current=!1,(i||W)&&CI(L.current,F.transform)){const P=iu(F.transform);L.current=P,clearTimeout(A.current),A.current=setTimeout(()=>{W==null||W(P),i==null||i(F.sourceEvent,P)},l?150:0)}})},[O,l,m,i,s]),q.useEffect(()=>{O&&O.filter(F=>{const W=Y||o,P=u&&F.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&F.button===1&&F.type==="mousedown"&&(ys(F,"react-flow__node")||ys(F,"react-flow__edge")))return!0;if(!m&&!W&&!l&&!h&&!u||j||!h&&F.type==="dblclick"||ys(F,E)&&F.type==="wheel"||ys(F,N)&&(F.type!=="wheel"||l&&F.type==="wheel"&&!Y)||!u&&F.ctrlKey&&F.type==="wheel"||!W&&!l&&!P&&F.type==="wheel"||!m&&(F.type==="mousedown"||F.type==="touchstart")||Array.isArray(m)&&!m.includes(F.button)&&F.type==="mousedown")return!1;const B=Array.isArray(m)&&m.includes(F.button)||!F.button||F.button<=1;return(!F.ctrlKey||F.type==="wheel")&&B})},[j,O,o,u,l,h,m,p,Y]),oe.createElement("div",{className:"react-flow__renderer",ref:R,style:Kg},k)},jI=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function AI(){const{userSelectionActive:e,userSelectionRect:n}=Xe(jI,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 II(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 MI(e,n){return II(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))},PI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),RE=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(),C=q.useRef(0),_=q.useRef(0),S=q.useRef(),{userSelectionActive:b,elementsSelectable:k,dragging:E}=Xe(PI,St),N=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),C.current=0,_.current=0},A=V=>{u==null||u(V),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},M=V=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){V.preventDefault();return}l==null||l(V)},I=c?V=>c(V):void 0,$=V=>{const{resetSelectedElements:j,domNode:Y}=x.getState();if(S.current=Y==null?void 0:Y.getBoundingClientRect(),!k||!e||V.button!==0||V.target!==y.current||!S.current)return;const{x:U,y:ne}=Zr(V,S.current);j(),x.setState({userSelectionRect:{width:0,height:0,startX:U,startY:ne,x:U,y:ne}}),s==null||s(V)},R=V=>{const{userSelectionRect:j,nodeInternals:Y,edges:U,transform:ne,onNodesChange:X,onEdgesChange:F,nodeOrigin:W,getNodes:P}=x.getState();if(!e||!S.current||!j)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const B=Zr(V,S.current),ae=j.startX??0,z=j.startY??0,G={...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=P(),se=fE(Y,G,ne,n===Oo.Partial,!0,W),ue=dE(se,U).map(ge=>ge.id),he=se.map(ge=>ge.id);if(C.current!==he.length){C.current=he.length;const ge=_s(J,he);ge.length&&(X==null||X(ge))}if(_.current!==ue.length){_.current=ue.length;const ge=_s(U,ue);ge.length&&(F==null||F(ge))}x.setState({userSelectionRect:G})},L=V=>{if(V.button!==0)return;const{userSelectionRect:j}=x.getState();!b&&j&&V.target===y.current&&(A==null||A(V)),x.setState({nodesSelectionActive:C.current>0}),N(),o==null||o(V)},O=V=>{b&&(x.setState({nodesSelectionActive:C.current>0}),o==null||o(V)),N()},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(M,y),onWheel:zc(I,y),onMouseEnter:Q?void 0:d,onMouseDown:Q?$:void 0,onMouseMove:Q?R:h,onMouseUp:Q?L:void 0,onMouseLeave:Q?O:p,ref:y,style:Kg},m,oe.createElement(AI,null))});RE.displayName="Pane";function jE(e,n){const i=e.parentNode||e.parentId;if(!i)return!1;const s=n.get(i);return s?s.selected?!0:jE(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 OI(e,n,i,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!jE(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 qI(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function AE(e,n,i,s,o=[0,0],u){const l=qI(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 LI(){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 IE({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),C=q.useRef({x:0,y:0}),_=q.useRef(null),S=q.useRef(!1),b=q.useRef(!1),k=q.useRef(!1),E=LI();return q.useEffect(()=>{if(e!=null&&e.current){const N=Rn(e.current),A=({x:$,y:R})=>{const{nodeInternals:L,onNodeDrag:O,onSelectionDrag:Q,updateNodePositions:V,nodeExtent:j,snapGrid:Y,snapToGrid:U,nodeOrigin:ne,onError:X}=c.getState();m.current={x:$,y:R};let F=!1,W={x:0,y:0,x2:0,y2:0};if(p.current.length>1&&j){const B=Iu(p.current,ne);W=Po(B)}if(p.current=p.current.map(B=>{const ae={x:$-B.distance.x,y:R-B.distance.y};U&&(ae.x=Y[0]*Math.round(ae.x/Y[0]),ae.y=Y[1]*Math.round(ae.y/Y[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-W.x+j[0][0],z[1][0]=B.positionAbsolute.x+(B.width??0)-W.x2+j[1][0],z[0][1]=B.positionAbsolute.y-W.y+j[0][1],z[1][1]=B.positionAbsolute.y+(B.height??0)-W.y2+j[1][1]);const G=AE(B,ae,L,z,ne,X);return F=F||B.position.x!==G.position.x||B.position.y!==G.position.y,B.position=G.position,B.positionAbsolute=G.positionAbsolute,B}),!F)return;V(p.current,!0,!0),h(!0);const P=o?O:Uc(Q);if(P&&_.current){const[B,ae]=Bc({nodeId:o,dragItems:p.current,nodeInternals:L});P(_.current,B,ae)}},M=()=>{if(!x.current)return;const[$,R]=eE(C.current,x.current);if($!==0||R!==0){const{transform:L,panBy:O}=c.getState();m.current.x=(m.current.x??0)-$/L[2],m.current.y=(m.current.y??0)-R/L[2],O({x:$,y:R})&&A(m.current)}y.current=requestAnimationFrame(M)},I=$=>{var ne;const{nodeInternals:R,multiSelectionActive:L,nodesDraggable:O,unselectNodesAndEdges:Q,onNodeDragStart:V,onSelectionDragStart:j}=c.getState();b.current=!0;const Y=o?V: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($);if(m.current=U,p.current=OI(R,O,U,o),Y&&p.current){const[X,F]=Bc({nodeId:o,dragItems:p.current,nodeInternals:R});Y($.sourceEvent,X,F)}};if(n)N.on(".drag",null);else{const $=G2().on("start",R=>{const{domNode:L,nodeDragThreshold:O}=c.getState();O===0&&I(R),k.current=!1;const Q=E(R);m.current=Q,x.current=(L==null?void 0:L.getBoundingClientRect())||null,C.current=Zr(R.sourceEvent,x.current)}).on("drag",R=>{var V,j;const L=E(R),{autoPanOnNodeDrag:O,nodeDragThreshold:Q}=c.getState();if(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!S.current&&b.current&&O&&(S.current=!0,M()),!b.current){const Y=L.xSnapped-(((V=m==null?void 0:m.current)==null?void 0:V.x)??0),U=L.ySnapped-(((j=m==null?void 0:m.current)==null?void 0:j.y)??0);Math.sqrt(Y*Y+U*U)>Q&&I(R)}(m.current.x!==L.xSnapped||m.current.y!==L.ySnapped)&&p.current&&b.current&&(_.current=R.sourceEvent,C.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:O,onNodeDragStop:Q,onSelectionDragStop:V}=c.getState(),j=o?Q:Uc(V);if(L(p.current,!1,!1),j){const[Y,U]=Bc({nodeId:o,dragItems:p.current,nodeInternals:O});j(R.sourceEvent,Y,U)}}}).filter(R=>{const L=R.target;return!R.button&&(!i||!jw(L,`.${i}`,e))&&(!s||jw(L,s,e))});return N.call($),()=>{N.on(".drag",null)}}}},[e,n,i,s,u,c,o,l,E]),d}function ME(){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,C=i.isShiftPressed?4:1,_=i.x*y*C,S=i.y*x*C,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:N,position:A}=AE(k,E,s,o,void 0,h);k.position=A,k.positionAbsolute=N}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:C,onDoubleClick:_,style:S,className:b,isDraggable:k,isSelectable:E,isConnectable:N,isFocusable:A,selectNodesOnDrag:M,sourcePosition:I,targetPosition:$,hidden:R,resizeObserver:L,dragHandle:O,zIndex:Q,isParent:V,noDragClassName:j,noPanClassName:Y,initialized:U,disableKeyboardA11y:ne,ariaLabel:X,rfId:F,hasHandleBounds:W})=>{const P=bt(),B=q.useRef(null),ae=q.useRef(null),z=q.useRef(I),G=q.useRef($),J=q.useRef(s),se=E||k||p||m||y||x,ue=ME(),he=xo(i,P.getState,m),ge=xo(i,P.getState,y),Me=xo(i,P.getState,x),Fe=xo(i,P.getState,C),Re=xo(i,P.getState,_),Pe=ve=>{const{nodeDragThreshold:ye}=P.getState();if(E&&(!M||!k||ye>0)&&Eg({id:i,store:P,nodeRef:B}),p){const qe=P.getState().nodeInternals.get(i);qe&&p(ve,{...qe})}},be=ve=>{if(!xg(ve)&&!ne)if(iE.includes(ve.key)&&E){const ye=ve.key==="Escape";Eg({id:i,store:P,unselect:ye,nodeRef:B})}else k&&h&&Object.prototype.hasOwnProperty.call(Es,ve.key)&&(P.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||!W||ae.current!==ve)&&(ae.current&&(L==null||L.unobserve(ae.current)),L==null||L.observe(ve),ae.current=ve)}},[R,U,W]),q.useEffect(()=>{const ve=J.current!==s,ye=z.current!==I,qe=G.current!==$;B.current&&(ve||ye||qe)&&(ve&&(J.current=s),ye&&(z.current=I),qe&&(G.current=$),P.getState().updateNodeDimensions([{id:i,nodeElement:B.current,forceUpdate:!0}]))},[i,s,I,$]);const Oe=IE({nodeRef:B,disabled:R||!k,noDragClassName:j,handleSelector:O,nodeId:i,isSelectable:E,selectNodesOnDrag:M});return R?null:oe.createElement("div",{className:qt(["react-flow__node",`react-flow__node-${s}`,{[Y]:k},b,{selected:h,selectable:E,parent:V,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:`${kE}-${F}`,"aria-label":X},oe.createElement(XA,{value:i},oe.createElement(e,{id:i,data:o,type:s,xPos:u,yPos:l,selected:h,isConnectable:N,sourcePosition:I,targetPosition:$,dragging:Oe,dragHandle:O,zIndex:Q})))};return n.displayName="NodeWrapper",q.memo(n)};const $I=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 DI({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:i}){const s=bt(),{width:o,height:u,x:l,y:c,transformString:d,userSelectionActive:h}=Xe($I,St),p=ME(),m=q.useRef(null);if(q.useEffect(()=>{var C;i||(C=m.current)==null||C.focus({preventScroll:!0})},[i]),IE({nodeRef:m}),h||!o||!u)return null;const y=e?C=>{const _=s.getState().getNodes().filter(S=>S.selected);e(C,_)}:void 0,x=C=>{Object.prototype.hasOwnProperty.call(Es,C.key)&&p({x:Es[C.key].x,y:Es[C.key].y,isShiftPressed:C.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 FI=q.memo(DI);const zI=e=>e.nodesSelectionActive,PE=({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:C,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:A,panOnScroll:M,panOnScrollSpeed:I,panOnScrollMode:$,zoomOnDoubleClick:R,panOnDrag:L,defaultViewport:O,translateExtent:Q,minZoom:V,maxZoom:j,preventScrolling:Y,onSelectionContextMenu:U,noWheelClassName:ne,noPanClassName:X,disableKeyboardA11y:F})=>{const W=Xe(zI),P=qo(m),B=qo(b),ae=B||L,z=B||M,G=P||y&&ae!==!0;return EI({deleteKeyCode:c,multiSelectionKeyCode:S}),oe.createElement(RI,{onMove:d,onMoveStart:h,onMoveEnd:p,onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:A,panOnScroll:z,panOnScrollSpeed:I,panOnScrollMode:$,zoomOnDoubleClick:R,panOnDrag:!P&&ae,defaultViewport:O,translateExtent:Q,minZoom:V,maxZoom:j,zoomActivationKeyCode:k,preventScrolling:Y,noWheelClassName:ne,noPanClassName:X},oe.createElement(RE,{onSelectionStart:C,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:u,onPaneScroll:l,panOnDrag:ae,isSelecting:!!G,selectionMode:x},e,W&&oe.createElement(FI,{onSelectionContextMenu:U,noPanClassName:X,disableKeyboardA11y:F})))};PE.displayName="FlowRenderer";var BI=q.memo(PE);function UI(e){return Xe(q.useCallback(i=>e?fE(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[e]))}function HI(e){const n={input:_o(e.input||xE),default:_o(e.default||kg),output:_o(e.output||SE),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 VI=({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]},WI=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),OE=e=>{const{nodesDraggable:n,nodesConnectable:i,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:u,onError:l}=Xe(WI,St),c=UI(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,M,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"),C=!!(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,N=VI({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:N.x,yPosOrigin:N.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:C,isConnectable:_,isFocusable:S,resizeObserver:h,dragHandle:p.dragHandle,zIndex:((A=p[ht])==null?void 0:A.z)??0,isParent:!!((M=p[ht])!=null&&M.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)})}))};OE.displayName="NodeRenderer";var GI=q.memo(OE);const YI=(e,n,i)=>i===Ce.Left?e-n:i===Ce.Right?e+n:e,KI=(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:YI(n,s,e),cy:KI(i,s,e),r:s,stroke:"transparent",fill:"transparent"}),XI=()=>!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:C,labelBgBorderRadius:_,style:S,source:b,target:k,sourceX:E,sourceY:N,targetX:A,targetY:M,sourcePosition:I,targetPosition:$,elementsSelectable:R,hidden:L,sourceHandleId:O,targetHandleId:Q,onContextMenu:V,onMouseEnter:j,onMouseMove:Y,onMouseLeave:U,reconnectRadius:ne,onReconnect:X,onReconnectStart:F,onReconnectEnd:W,markerEnd:P,markerStart:B,rfId:ae,ariaLabel:z,isFocusable:G,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(P,ae)}')`,[P,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,V),Qe=wo(i,be.getState,j),et=wo(i,be.getState,Y),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:O)||null,wt=Et?"target":"source",an=ft||XI,Bt=Et,vn=Ge.find(wn=>wn.id===i);Pe(!0),F==null||F(We,vn,wt);const un=wn=>{Pe(!1),W==null||W(wn,vn,wt)};gE({event:We,handleId:Lt,nodeId:on,onConnect:wn=>X==null?void 0:X(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&&iE.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:G?kt:void 0,tabIndex:G?0:void 0,role:G?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":z===null?void 0:z||`Edge from ${b} to ${k}`,"aria-describedby":G?`${EE}-${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:C,labelBgBorderRadius:_,data:u,style:S,sourceX:E,sourceY:N,targetX:A,targetY:M,sourcePosition:I,targetPosition:$,sourceHandleId:O,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:N,radius:ne,onMouseDown:At,onMouseEnter:It,onMouseOut:pt,type:"source"}),(J==="target"||J===!0)&&oe.createElement(Mw,{position:$,centerX:A,centerY:M,radius:ne,onMouseDown:Vt,onMouseEnter:It,onMouseOut:pt,type:"target"})))};return n.displayName="EdgeWrapper",q.memo(n)};function QI(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 ZI=(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 JI({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 eM=[{level:0,isMaxLevel:!0,edges:[]}];function tM(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),C=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)+(C?_: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?eM:u}function nM(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)&&JI({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 tM(s,n,i)}const rM=({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"}),iM=({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]:rM,[_u.ArrowClosed]:iM};function sM(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 oM=({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=sM(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},aM=({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))},qE=({defaultColor:e,rfId:n})=>{const i=Xe(q.useCallback(aM({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(oM,{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})))};qE.displayName="MarkerDefinitions";var uM=q.memo(qE);const lM=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}),LE=({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:C,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:k,edgesUpdatable:E,elementsSelectable:N,width:A,height:M,connectionMode:I,nodeInternals:$,onError:R}=Xe(lM,St),L=nM(n,$,i);return A?oe.createElement(oe.Fragment,null,L.map(({level:O,edges:Q,isMaxLevel:V})=>oe.createElement("svg",{key:O,style:{zIndex:O},width:A,height:M,className:"react-flow__edges react-flow__container"},V&&oe.createElement(uM,{defaultColor:e,rfId:s}),oe.createElement("g",null,Q.map(j=>{const[Y,U,ne]=qw($.get(j.source)),[X,F,W]=qw($.get(j.target));if(!ne||!W)return null;let P=j.type||"default";o[P]||(R==null||R("011",yr.error011(P)),P="default");const B=o[P]||o.default,ae=I===Mi.Strict?F.target:(F.target??[]).concat(F.source??[]),z=Ow(U.source,j.sourceHandle),G=Ow(ae,j.targetHandle),J=(z==null?void 0:z.position)||Ce.Bottom,se=(G==null?void 0:G.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||!G)return R==null||R("008",yr.error008(z,j)),null;const{sourceX:Me,sourceY:Fe,targetX:Re,targetY:Pe}=ZI(Y,z,J,X,G,se);return oe.createElement(B,{key:j.id,id:j.id,className:qt([j.className,u]),type:P,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:N,onContextMenu:l,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:C,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};LE.displayName="EdgeRenderer";var cM=q.memo(LE);const fM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function dM({children:e}){const n=Xe(fM);return oe.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function hM(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 pM={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},$E=({nodeId:e,handleType:n,style:i,type:s=Qr.Bezier,CustomComponent:o,connectionStatus:u})=>{var M,I,$;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=(M=l==null?void 0:l[ht])==null?void 0:M.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],C=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)+C,b=((($=l.positionAbsolute)==null?void 0:$.y)??0)+_,k=x==null?void 0:x.position,E=k?pM[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 N="";const A={sourceX:S,sourceY:b,sourcePosition:k,targetX:d,targetY:h,targetPosition:E};return s===Qr.Bezier?[N]=lE(A):s===Qr.Step?[N]=_g({...A,borderRadius:0}):s===Qr.SmoothStep?[N]=_g(A):s===Qr.SimpleBezier?[N]=uE(A):N=`M${S},${b} ${d},${h}`,oe.createElement("path",{d:N,fill:"none",className:"react-flow__connection-path",style:i})};$E.displayName="ConnectionLine";const mM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function gM({containerStyle:e,style:n,type:i,component:s}){const{nodeId:o,handleType:u,nodesConnectable:l,width:c,height:d,connectionStatus:h}=Xe(mM,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($E,{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 DE=({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:C,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:k,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:A,selectionOnDrag:M,selectionMode:I,multiSelectionKeyCode:$,panActivationKeyCode:R,zoomActivationKeyCode:L,deleteKeyCode:O,onlyRenderVisibleElements:Q,elementsSelectable:V,selectNodesOnDrag:j,defaultViewport:Y,translateExtent:U,minZoom:ne,maxZoom:X,preventScrolling:F,defaultMarkerColor:W,zoomOnScroll:P,zoomOnPinch:B,panOnScroll:ae,panOnScrollSpeed:z,panOnScrollMode:G,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,HI),We=$w(n,QI);return hM(u),oe.createElement(BI,{onPaneClick:ue,onPaneMouseEnter:he,onPaneMouseMove:ge,onPaneMouseLeave:Me,onPaneContextMenu:Re,onPaneScroll:Fe,deleteKeyCode:O,selectionKeyCode:A,selectionOnDrag:M,selectionMode:I,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:$,panActivationKeyCode:R,zoomActivationKeyCode:L,elementsSelectable:V,onMove:i,onMoveStart:s,onMoveEnd:o,zoomOnScroll:P,zoomOnPinch:B,zoomOnDoubleClick:J,panOnScroll:ae,panOnScrollSpeed:z,panOnScrollMode:G,panOnDrag:se,defaultViewport:Y,translateExtent:U,minZoom:ne,maxZoom:X,onSelectionContextMenu:C,preventScrolling:F,noDragClassName:et,noWheelClassName:Be,noPanClassName:Ze,disableKeyboardA11y:Vt},oe.createElement(dM,null,oe.createElement(cM,{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:W,noPanClassName:Ze,elevateEdgesOnSelect:!!At,disableKeyboardA11y:Vt,rfId:tt},oe.createElement(gM,{style:k,type:b,component:E,containerStyle:N})),oe.createElement("div",{className:"react-flow__edgelabel-renderer"}),oe.createElement(GI,{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})))};DE.displayName="GraphView";var vM=q.memo(DE);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:HA,isValidConnection:void 0},yM=()=>sR((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 _},[]);CE(o,h);const C=l||u&&!l&&TE(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:C}),(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=MI(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=yM()),oe.createElement(LA,{value:n.current},e)};Xg.displayName="ReactFlowProvider";const FE=({children:e})=>q.useContext(ju)?oe.createElement(oe.Fragment,null,e):oe.createElement(Xg,null,e);FE.displayName="ReactFlowWrapper";const wM={input:xE,default:kg,output:SE,group:Yg},xM={default:Su,straight:Vg,step:Hg,smoothstep:Au,simplebezier:Ug},_M=[0,0],SM=[15,15],bM={x:0,y:0,zoom:1},kM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},zE=q.forwardRef(({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,className:o,nodeTypes:u=wM,edgeTypes:l=xM,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onConnect:x,onConnectStart:C,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:M,onNodeDragStart:I,onNodeDrag:$,onNodeDragStop:R,onNodesDelete:L,onEdgesDelete:O,onSelectionChange:Q,onSelectionDragStart:V,onSelectionDrag:j,onSelectionDragStop:Y,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:X,connectionMode:F=Mi.Strict,connectionLineType:W=Qr.Bezier,connectionLineStyle:P,connectionLineComponent:B,connectionLineContainerStyle:ae,deleteKeyCode:z="Backspace",selectionKeyCode:G="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=SM,onlyRenderVisibleElements:Re=!1,selectNodesOnDrag:Pe=!0,nodesDraggable:be,nodesConnectable:Oe,nodesFocusable:ve,nodeOrigin:ye=_M,edgesFocusable:qe,edgesUpdatable:Ye,elementsSelectable:Qe,defaultViewport:et=bM,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,...kM},ref:Gt,className:qt(["react-flow",o]),"data-testid":"rf__wrapper",id:Wi},oe.createElement(FE,null,oe.createElement(vM,{onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:M,nodeTypes:u,edgeTypes:l,connectionLineType:W,connectionLineStyle:P,connectionLineComponent:B,connectionLineContainerStyle:ae,selectionKeyCode:G,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:X,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(hI,{nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:x,onConnectStart:C,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:F,translateExtent:At,connectOnClick:Bi,defaultEdgeOptions:Er,fitView:xn,fitViewOptions:zi,onNodesDelete:L,onEdgesDelete:O,onNodeDragStart:I,onNodeDrag:$,onNodeDragStop:R,onSelectionDrag:j,onSelectionDragStart:V,onSelectionDragStop:Y,noPanClassName:Fi,nodeOrigin:ye,rfId:gt,autoPanOnConnect:Vi,autoPanOnNodeDrag:nt,onError:oi,connectionRadius:Wt,isValidConnection:si,nodeDragThreshold:ai}),oe.createElement(fI,{onSelectionChange:Q}),yn,oe.createElement(DA,{proOptions:cn,position:ri}),oe.createElement(yI,{rfId:gt,disableKeyboardA11y:Hi})))});zE.displayName="ReactFlow";const EM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function BE(){return Xe(EM,St)}const UE=({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:C,backgroundColor:_}=u||{},S=l||C||_;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})};UE.displayName="MiniMapNode";var NM=q.memo(UE);const CM=e=>e.nodeOrigin,TM=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),Hc=e=>e instanceof Function?e:()=>e;function RM({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:u=NM,onClick:l}){const c=Xe(TM,St),d=Xe(CM),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:C,y:_}=ji(x,d).positionAbsolute;return oe.createElement(u,{key:x.id,x:C,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 jM=q.memo(RM);const AM=200,IM=150,MM=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?BA(Iu(n,e.nodeOrigin),i):i,rfId:e.rfId}},PM="react-flow__minimap-desc";function HE({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:C=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:k=10,offsetScale:E=5}){const N=bt(),A=q.useRef(null),{boundingRect:M,viewBB:I,rfId:$}=Xe(MM,St),R=(e==null?void 0:e.width)??AM,L=(e==null?void 0:e.height)??IM,O=M.width/R,Q=M.height/L,V=Math.max(O,Q),j=V*R,Y=V*L,U=E*V,ne=M.x-(j-M.width)/2-U,X=M.y-(Y-M.height)/2-U,F=j+U*2,W=Y+U*2,P=`${PM}-${$}`,B=q.useRef(0);B.current=V,q.useEffect(()=>{if(A.current){const G=Rn(A.current),J=he=>{const{transform:ge,d3Selection:Me,d3Zoom:Fe}=N.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}=N.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=Zk().on("zoom",C?se:null).on("zoom.wheel",_?J:null);return G.call(ue),()=>{G.on("zoom",null)}}},[C,_,b,k]);const ae=y?G=>{const J=Bn(G);y(G,{x:J[0],y:J[1]})}:void 0,z=x?(G,J)=>{const se=N.getState().nodeInternals.get(J);x(G,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} ${X} ${F} ${W}`,role:"img","aria-labelledby":P,ref:A,onClick:ae},S&&oe.createElement("title",{id:P},S),oe.createElement(jM,{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},${X-U}h${F+U*2}v${W+U*2}h${-F-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"})))}HE.displayName="MiniMap";var OM=q.memo(HE);function qM(){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 LM(){return oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},oe.createElement("path",{d:"M0 0h32v4.2H0z"}))}function $M(){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 DM(){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 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 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 zM=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),VE=({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,C]=q.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Xe(zM,St),{zoomIn:k,zoomOut:E,fitView:N}=zo();if(q.useEffect(()=>{C(!0)},[]),!x)return null;const A=()=>{k(),u==null||u()},M=()=>{E(),l==null||l()},I=()=>{N(o),c==null||c()},$=()=>{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(qM,null)),oe.createElement(Ss,{onClick:M,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},oe.createElement(LM,null))),i&&oe.createElement(Ss,{className:"react-flow__controls-fitview",onClick:I,title:"fit view","aria-label":"fit view"},oe.createElement($M,null)),s&&oe.createElement(Ss,{className:"react-flow__controls-interactive",onClick:$,title:"toggle interactivity","aria-label":"toggle interactivity"},_?oe.createElement(FM,null):oe.createElement(DM,null)),p)};VE.displayName="Controls";var BM=q.memo(VE),Hn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Hn||(Hn={}));function UM({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 HM({color:e,radius:n}){return oe.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const VM={[Hn.Dots]:"#91919a",[Hn.Lines]:"#eee",[Hn.Cross]:"#e2e2e2"},WM={[Hn.Dots]:1,[Hn.Lines]:1,[Hn.Cross]:6},GM=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function WE({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(GM,St),y=l||VM[n],x=s||WM[n],C=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,N=C?[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(-${N[0]},-${N[1]})`},C?oe.createElement(HM,{color:y,radius:k/u}):oe.createElement(UM,{dimensions:E,color:y,lineWidth:o})),oe.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}WE.displayName="Background";var YM=q.memo(WE);function GE(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function YE(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=YE(s,n+1);if(o)return o}return null}function KM(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens}const XM=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function KE(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.model=="string"&&XM.test(i.model))return i.model;for(const s of Object.values(i)){const o=KE(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:GE()},e.agents.set(o,u),u)}function XE(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=XE(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 QM(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:GE()},e.agents.set(u,c),l.childCount+=1,c}function ZM(e,n,i){const s=e.activeSubagentStack.get(n)??[];s.push(i),e.activeSubagentStack.set(n,s)}function JM(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 eP(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 tP(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 nP(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=KE(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 C=x.tools.find(_=>_.id===d);if(C){h=C,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=YE(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&&KM(x.usage,m),ko(x))}break}case"SubagentStart":{const d=Tg(i);if(!d)break;const h=QM(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),ZM(e,u,d);break}case"SubagentStop":{const d=Tg(i);if(!d)break;const h=XE(e,u,d,i);if(!h)break;h.state="done",h.endedAt=s,ko(h),JM(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 rP=Date.UTC(2026,8,1);function iP(){return Date.now()<rP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}}const sP=[{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:iP()},{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 oP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Jg(e){if(!e)return null;for(const n of sP)if(n.match.test(e))return n.rates;return null}const aP=272e3,uP=/^gpt[-_]5[-_.](?:6(?![-_]cyber)|5|4)/i;function lP(e,n){return!e||n<=aP?{input:1,output:1}:uP.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=oP(n),o=s?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens,u=s?lP(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,cP=1e6,fP=[/\[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],dP=[{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 QE(e){if(!e)return zw;for(const n of fP)if(n.test(e))return cP;for(const n of dP)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 hP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function pP({agent:e,onClose:n}){var h;const i=e.context,s=e.usage,o=(i==null?void 0:i.currentContextTokens)??0,u=QE(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:hP(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 mP({currentContextTokens:e,modelId:n,size:i=26,onClick:s,title:o}){const u=QE(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 gP(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 vP(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 yP({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(wP,{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(mP,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),v.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:vP(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(_P,{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:xP(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=gP(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 wP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return v.jsx("span",{className:`state-pill state-${e}`,children:n})}function xP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function _P({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 C=23-Math.floor(x/2500);C>=0&&C<24&&(u[C]+=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 C=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-C,width:Math.max(.5,p-1),height:C,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 SP(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 bP({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:SP(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,kP=12;function EP(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} · ${NP(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 NP(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 CP(){const{x:e,y:n,zoom:i}=BE(),s=zo(),o=Xe(EP,TP);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-kP)*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 TP(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 RP({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 ZE=600,jP=36,Rg=16,AP=60,IP=6,Vw=220,Ww=96,MP=28,PP={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 OP(e){return e.startsWith("mcp__")?"mcp":PP[e]??"other"}const qP={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__")?"🔌":qP[e]??"✨"}const LP={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 JE(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 JE(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 $P(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 DP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),FP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function zP(e,n){return FP.has(e)?Math.max(Ww,34+n.length*7.5):Ww}function BP(e,n){if(!DP.has(e))return null;const i=$P(n);if(!i)return null;const s=JE(i);return s?{emoji:LP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const UP=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 HP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function VP(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 WP(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 GP(e,n){if(!UP.has(e))return null;const i=WP(e,n);if(!i)return null;const s=HP(i);return s?{emoji:e==="LS"?"📂":VP(s),label:s,category:"file",detail:i}:null}const eN={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 tN(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 YP(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 KP(e,n){const i=tN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const u=eN[s.toLowerCase()];return{emoji:(u==null?void 0:u.emoji)??"🔌",label:o,category:"mcp",detail:u?`${u.name} · ${o}`:`${s} · ${o}`}}function XP(e,n){return BP(e,n)??GP(e,n)??KP(e)}const QP={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function ZP(e){const n=tN(e);if(n){const s=eN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:YP(n.server)}}const i=QP[e];return i?{emoji:Gw(e),label:i}:{emoji:Gw(e),label:e}}function JP(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function e3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/ZE)}function t3(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>ZE)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,C=d.x,_=d.y,S=C+y,b=_+x/2;h.forEach((k,E)=>{const N=E*jP,A=C+y+AP,M=_+IP+N,I=e3(k,u,p),$=k.inputPreview??"",R=JP(k),L=I<.999,O=ZP(k.name);l.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:O.label,emoji:O.emoji,status:R,category:OP(k.name),mcpHue:O.hue,inputPreview:$,fade:I,fading:L,worldX:A,worldY:M,anchorX:S,anchorY:b,spawnDx:S-A,spawnDy:b-(M+Rg)});const Q=XP(k.name,k.input);if(Q){const V=zP(k.name,O.label),j=A+V+MP,Y=M,U=A+V,ne=M+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??$,fade:I,fading:L,worldX:j,worldY:Y,anchorX:U,anchorY:ne,spawnDx:U-j,spawnDy:0})}})}return l}function n3({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}=BE(),x=t3(e,n,i,s,o,d),C=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:C.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,k=(_.worldX+6)*y+p,E=(_.worldY+Rg)*y+m,N=S+(k-S)*.55,A=u!=null&&!u.has(_.agentId),M=l!=null&&!l.has(_.agentId),I=_.fade*(A||M?.14:1);return v.jsx("path",{d:`M ${S} ${b} Q ${N} ${b}, ${k} ${E}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:I},`l:${_.id}`)})}),C.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,N=_.inputPreview?`${E} · ${_.inputPreview}`:E,A=h!=null,M=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},I=u!=null&&!u.has(_.agentId),$=l!=null&&!l.has(_.agentId),R=I||$?" 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:M,title:N,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 r3({state:e,sessionId:n,onClose:i}){const s=q.useMemo(()=>s3(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(i3,{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 i3({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 s3(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,C=0;for(const E of s){const N=rn(E.usage,E.model);o.input+=N.input,o.output+=N.output,o.cacheRead+=N.cacheRead,o.cacheWrite+=N.cacheWrite,o.total+=N.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),C=Math.max(C,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,C-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,N)=>N[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 o3(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 a3(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 u3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const u=q.useMemo(()=>o3(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:a3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function pr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function l3({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 c3(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 f3(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?c3(s,l):null,x=s&&o?f3(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 d3=6e4;function h3(){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),d3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>u(!0)}}function p3(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 nN=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/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),nN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>u(!0)}}function g3(){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,nN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function v3({state:e,now:n,onClose:i}){var I,$;const{quota:s,loading:o,refresh:u}=h3(),{data:l,loading:c,refresh:d}=m3(),{data:h}=g3(),[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:C,burnRate:_}=q.useMemo(()=>{const R=new Map,L={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let O=0,Q=0,V=0,j=0;for(const F of e.agents.values()){const W=F.model??"__unknown__",P=rn(F.usage,F.model),B=R.get(W);B?(B.inputTokens+=F.usage.inputTokens,B.outputTokens+=F.usage.outputTokens,B.cacheReadTokens+=F.usage.cacheReadTokens,B.cacheCreateTokens+=F.usage.cacheCreateTokens,B.cost.total+=P.total,B.cost.input+=P.input,B.cost.output+=P.output,B.cost.cacheRead+=P.cacheRead,B.cost.cacheWrite+=P.cacheWrite,B.agentCount++):R.set(W,{model:W,inputTokens:F.usage.inputTokens,outputTokens:F.usage.outputTokens,cacheReadTokens:F.usage.cacheReadTokens,cacheCreateTokens:F.usage.cacheCreateTokens,cost:{...P},agentCount:1}),L.total+=P.total,L.input+=P.input,L.output+=P.output,L.cacheRead+=P.cacheRead,L.cacheWrite+=P.cacheWrite,O+=F.usage.inputTokens,Q+=F.usage.outputTokens,V+=F.usage.cacheReadTokens,j+=F.usage.cacheCreateTokens}const Y=Array.from(R.values()).sort((F,W)=>W.cost.total-F.cost.total);let U=0,ne=0;for(const F of e.agents.values()){if(F.state!=="active")continue;const W=rn(F.usage,F.model);U+=W.total,ne=Math.max(ne,((F.endedAt??n)-F.startedAt)/1e3)}const X=ne>0?ku(U,ne):null;return{byModel:Y,totalCost:L,totalTokens:{in:O,out:Q,cacheR:V,cacheC:j},burnRate:X}},[e,e.lastSeq,n]),S=q.useMemo(()=>{const R=[];for(const L of e.agents.values()){if(L.kind!=="root")continue;let O=rn(L.usage,L.model).total,Q=L.usage.inputTokens,V=L.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==L.sessionId||j.kind==="root"||(O+=rn(j.usage,j.model).total,Q+=j.usage.inputTokens,V+=j.usage.outputTokens);R.push({sessionId:L.sessionId,label:L.label||L.cwdBasename||"session",state:L.state,cost:O,inputTokens:Q,outputTokens:V})}return R.sort((L,O)=>O.cost-L.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=C.in+C.out,E=o||c,N=Math.max((s==null?void 0:s.fetchedAt)??0,(l==null?void 0:l.fetchedAt)??0),A=N>0?(()=>{const R=p-Math.floor(N/1e3);return R<10?"just now":R<60?`${R}s ago`:R<3600?`${Math.floor(R/60)}m ago`:`${Math.floor(R/3600)}h ago`})():null,M=()=>{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:[A&&!E&&v.jsx("span",{className:"up-last-updated",children:A}),v.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:M,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.jsx("h4",{className:"up-section-title",children:"Claude quota"}),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})]}),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)),($=l.extraWindows)==null?void 0:$.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:p3(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(l3,{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(C.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),pr(C.out)]}),C.cacheR>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache r"}),pr(C.cacheR)]}),C.cacheC>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache c"}),pr(C.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(C.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),pr(C.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 y3=15e3,w3=[70,80,85,90,95];function x3(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 Xw(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 _3(e){if(e.event==="switch")return`would switch — ${e.detail??"another account"}`;const i={"below-threshold":"under threshold","no-qualifying-candidate":"no better account","all-exhausted":"every account spent",cooldown:"cooling down","external-engine":"handled elsewhere"}[e.reason??""]??e.reason??"nothing to do";return e.detail?`stays put · ${i}, ${e.detail}`:`stays put · ${i}`}function S3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function b3({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?x3(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 k3({onClose:e}){var I,$,R,L;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(null),[x,C]=q.useState(()=>Math.floor(Date.now()/1e3)),_=q.useRef(null),S=q.useCallback(async(O=!1)=>{try{const[Q,V]=await Promise.all([fetch(`/api/claude-accounts${O?"?refresh=1":""}`),fetch("/api/cswap-auto")]);Q.ok&&i(await Q.json()),V.ok&&o(await V.json())}catch{}},[]),b=q.useCallback(async(O,Q)=>{d(Q),y(null);try{const j=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).json().catch(()=>null);return j!=null&&j.ok||y((j==null?void 0:j.detail)||(j==null?void 0:j.reason)||"command failed"),j}catch{return y("server unreachable"),null}finally{d(null)}},[]);q.useEffect(()=>(S(!0),_.current=window.setInterval(()=>S(!1),y3),()=>{_.current!=null&&window.clearInterval(_.current)}),[S]),q.useEffect(()=>{const O=window.setInterval(()=>C(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(O)},[]);const k=((I=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:I.value)??"90",E=($=n==null?void 0:n.accounts)==null?void 0:$.find(O=>O.active),N=E!=null&&E.lanes.length?Math.max(...E.lanes.map(O=>O.pct)):null,A=N!=null&&N>=Number(k)-15,M=async O=>{p(O),y(null);try{const V=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:O})})).json().catch(()=>null);V!=null&&V.ok||y((V==null?void 0:V.output)||(V==null?void 0:V.reason)||"switch failed"),await S(!0)}catch{y("server unreachable")}finally{p(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:()=>S(!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:[(R=n.accounts)==null?void 0:R.map(O=>v.jsxs("div",{className:`ap-account${O.active?" active":""}${O.disabled?" disabled":""}`,children:[v.jsxs("div",{className:"ap-account-head",children:[v.jsx("span",{className:"ap-num",children:O.num}),O.alias&&v.jsx("span",{className:"ap-alias",children:O.alias}),v.jsx("span",{className:"ap-email",title:O.org??void 0,children:O.email}),O.active?v.jsx("span",{className:"ap-badge-active",children:"● active"}):v.jsx("button",{type:"button",className:"btn ap-switch",disabled:h!=null||O.disabled,onClick:()=>M(O.num),title:O.disabled?"Held out of rotation":`Switch to ${O.alias??O.email}`,children:h===O.num?"…":"switch"})]}),O.lanes.length>0?O.lanes.map(Q=>v.jsx(b3,{lane:Q,nowSec:x},Q.id)):v.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),v.jsxs("div",{className:"ap-meta",children:[O.error&&v.jsx("span",{className:"ap-err",children:S3(O.error)}),O.fetchedAt?v.jsx("span",{className:O.stale?"ap-stale":void 0,children:Xw(O.fetchedAt,x)}):v.jsx("span",{className:"ap-stale",children:"never fetched"}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!O.active&&v.jsx("button",{type:"button",className:"ap-rotate",disabled:c!=null,onClick:()=>b({action:"account",account:O.num,enabled:O.disabled},`rot-${O.num}`).then(()=>S(!0)),title:O.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:O.disabled?"held out":"in rotation"})]})]},O.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("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:c!=null,onClick:()=>b({action:"enable",enabled:!s.enabled},"enable").then(()=>S(!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.":"."]}),v.jsxs("div",{className:"ap-auto-row",children:[v.jsx("span",{className:"ap-auto-key",children:"switch when"}),N!=null&&v.jsxs("span",{className:`ap-auto-now${A?" near":""}`,children:["now ",Math.round(N),"%"]}),v.jsx("span",{className:"ap-field",children:v.jsx("select",{"aria-label":"Switch threshold",value:k,disabled:c!=null,onChange:O=>b({action:"setting",key:"autoswitch.threshold",value:O.target.value},"threshold").then(()=>S(!0)),children:w3.map(O=>v.jsxs("option",{value:O,children:[O,"%"]},O))})})]}),v.jsxs("div",{className:"ap-auto-row",children:[v.jsx("span",{className:"ap-auto-key",children:"switch to"}),v.jsx("span",{className:"ap-field",children:v.jsxs("select",{"aria-label":"Target account strategy",value:((L=s.settings["autoswitch.strategy"])==null?void 0:L.value)??"best",disabled:c!=null,onChange:O=>b({action:"setting",key:"autoswitch.strategy",value:O.target.value},"strategy").then(()=>S(!0)),children:[v.jsx("option",{value:"best",children:"most quota left"}),v.jsx("option",{value:"consume-first",children:"soonest reset"})]})})]}),v.jsxs("div",{className:"ap-auto-foot",children:[v.jsx("button",{type:"button",className:"ap-auto-dry",disabled:c!=null,onClick:async()=>l(await b({action:"preview"},"preview")),title:"Evaluate a switch without performing one",children:c==="preview"?"checking…":"dry run"}),u!=null&&u.ok?v.jsx("span",{className:`ap-auto-result${u.event==="switch"?" would":""}`,children:_3(u)}):s.lastTick?v.jsxs("span",{className:"ap-auto-result",children:["checked ",Xw(s.lastTick.at,x)]}):null]})]}),m&&v.jsx("div",{className:"ap-failure",children:m}),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 Qw(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 E3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const N3=[7,14,30,90];function C3(e){const[n,i]=q.useState(null),[s,o]=q.useState(!1),u=(l=!1)=>{o(!0);const d=`/api/ccusage?since=${E3(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 T3({onClose:e}){var b,k;const[n,i]=q.useState(30),[s,o]=q.useState(null),{data:u,loading:l,reload:c}=C3(n);q.useEffect(()=>{const E=N=>{N.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,N)=>Math.max(E,N.totalCost),0),[d]),{totalCost:p,totalTok:m,inOut:y,cacheRead:x,modelCosts:C}=q.useMemo(()=>{let E=0,N=0,A=0,M=0;const I=new Map;for(const $ of d){E+=$.totalCost,N+=$.totalTokens,A+=$.inputTokens+$.outputTokens,M+=$.cacheReadTokens;for(const R of $.modelBreakdowns)I.set(R.modelName,(I.get(R.modelName)??0)+R.cost)}return{totalCost:E,totalTok:N,inOut:A,cacheRead:M,modelCosts:I}},[d]),_=q.useMemo(()=>Array.from(C.entries()).sort((E,N)=>N[1]-E[1]),[C]),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:N3.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 N=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(N,E.totalCost>0?2:0)}%`},children:E.modelBreakdowns.slice().sort((M,I)=>I.cost-M.cost).map(M=>{const I=E.totalCost>0?M.cost/E.totalCost*100:0;return v.jsx("div",{className:"uh-bar-seg",style:{height:`${I}%`,background:ou(M.modelName)}},M.modelName)})}),v.jsx("span",{className:"uh-bar-label",children:E.period.slice(5)})]},E.period)})}),v.jsx("div",{className:"uh-legend",children:_.map(([E,N])=>v.jsxs("span",{className:"uh-legend-item",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:ou(E)}}),Qw(E)," ",v.jsx("span",{className:"uh-legend-cost",children:He(N)})]},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,N)=>N.cost-E.cost).map(E=>{const N=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)}}),Qw(E.modelName)]}),v.jsx("span",{className:"uh-model-bar",children:v.jsx("span",{className:"uh-model-bar-fill",style:{width:`${N}%`,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,Zw;function R3(){if(Zw)return Wc;Zw=1;function e(){this.__data__=[],this.size=0}return Wc=e,Wc}var Gc,Jw;function Is(){if(Jw)return Gc;Jw=1;function e(n,i){return n===i||n!==n&&i!==i}return Gc=e,Gc}var Yc,ex;function Mu(){if(ex)return Yc;ex=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,tx;function j3(){if(tx)return Kc;tx=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,nx;function A3(){if(nx)return Xc;nx=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,rx;function I3(){if(rx)return Qc;rx=1;var e=Mu();function n(i){return e(this.__data__,i)>-1}return Qc=n,Qc}var Zc,ix;function M3(){if(ix)return Zc;ix=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,sx;function Pu(){if(sx)return Jc;sx=1;var e=R3(),n=j3(),i=A3(),s=I3(),o=M3();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,ox;function P3(){if(ox)return ef;ox=1;var e=Pu();function n(){this.__data__=new e,this.size=0}return ef=n,ef}var tf,ax;function O3(){if(ax)return tf;ax=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return tf=e,tf}var nf,ux;function q3(){if(ux)return nf;ux=1;function e(n){return this.__data__.get(n)}return nf=e,nf}var rf,lx;function L3(){if(lx)return rf;lx=1;function e(n){return this.__data__.has(n)}return rf=e,rf}var sf,cx;function rN(){if(cx)return sf;cx=1;var e=typeof Ya=="object"&&Ya&&Ya.Object===Object&&Ya;return sf=e,sf}var of,fx;function Gn(){if(fx)return of;fx=1;var e=rN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return of=i,of}var af,dx;function Ms(){if(dx)return af;dx=1;var e=Gn(),n=e.Symbol;return af=n,af}var uf,hx;function $3(){if(hx)return uf;hx=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,px;function D3(){if(px)return lf;px=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return lf=i,lf}var cf,mx;function Pi(){if(mx)return cf;mx=1;var e=Ms(),n=$3(),i=D3(),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,gx;function An(){if(gx)return ff;gx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return ff=e,ff}var df,vx;function Uo(){if(vx)return df;vx=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,yx;function F3(){if(yx)return hf;yx=1;var e=Gn(),n=e["__core-js_shared__"];return hf=n,hf}var pf,wx;function z3(){if(wx)return pf;wx=1;var e=F3(),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,xx;function iN(){if(xx)return mf;xx=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,_x;function B3(){if(_x)return gf;_x=1;var e=Uo(),n=z3(),i=An(),s=iN(),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,Sx;function U3(){if(Sx)return vf;Sx=1;function e(n,i){return n==null?void 0:n[i]}return vf=e,vf}var yf,bx;function Oi(){if(bx)return yf;bx=1;var e=B3(),n=U3();function i(s,o){var u=n(s,o);return e(u)?u:void 0}return yf=i,yf}var wf,kx;function tv(){if(kx)return wf;kx=1;var e=Oi(),n=Gn(),i=e(n,"Map");return wf=i,wf}var xf,Ex;function Ou(){if(Ex)return xf;Ex=1;var e=Oi(),n=e(Object,"create");return xf=n,xf}var _f,Nx;function H3(){if(Nx)return _f;Nx=1;var e=Ou();function n(){this.__data__=e?e(null):{},this.size=0}return _f=n,_f}var Sf,Cx;function V3(){if(Cx)return Sf;Cx=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,Tx;function W3(){if(Tx)return bf;Tx=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,Rx;function G3(){if(Rx)return kf;Rx=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,jx;function Y3(){if(jx)return Ef;jx=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,Ax;function K3(){if(Ax)return Nf;Ax=1;var e=H3(),n=V3(),i=W3(),s=G3(),o=Y3();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,Ix;function X3(){if(Ix)return Cf;Ix=1;var e=K3(),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,Mx;function Q3(){if(Mx)return Tf;Mx=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,Px;function qu(){if(Px)return Rf;Px=1;var e=Q3();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,Ox;function Z3(){if(Ox)return jf;Ox=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,qx;function J3(){if(qx)return Af;qx=1;var e=qu();function n(i){return e(this,i).get(i)}return Af=n,Af}var If,Lx;function eO(){if(Lx)return If;Lx=1;var e=qu();function n(i){return e(this,i).has(i)}return If=n,If}var Mf,$x;function tO(){if($x)return Mf;$x=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,Dx;function nv(){if(Dx)return Pf;Dx=1;var e=X3(),n=Z3(),i=J3(),s=eO(),o=tO();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,Fx;function nO(){if(Fx)return Of;Fx=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,zx;function Lu(){if(zx)return qf;zx=1;var e=Pu(),n=P3(),i=O3(),s=q3(),o=L3(),u=nO();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,Bx;function rv(){if(Bx)return Lf;Bx=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,Ux;function sN(){if(Ux)return $f;Ux=1;var e=Oi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return $f=n,$f}var Df,Hx;function $u(){if(Hx)return Df;Hx=1;var e=sN();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,Vx;function Du(){if(Vx)return Ff;Vx=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,Wx;function Ho(){if(Wx)return zf;Wx=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,Gx;function rO(){if(Gx)return Bf;Gx=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,Yx;function rr(){if(Yx)return Uf;Yx=1;function e(n){return n!=null&&typeof n=="object"}return Uf=e,Uf}var Hf,Kx;function iO(){if(Kx)return Hf;Kx=1;var e=Pi(),n=rr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return Hf=s,Hf}var Vf,Xx;function Vo(){if(Xx)return Vf;Xx=1;var e=iO(),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,Qx;function yt(){if(Qx)return Wf;Qx=1;var e=Array.isArray;return Wf=e,Wf}var Eo={exports:{}},Gf,Zx;function sO(){if(Zx)return Gf;Zx=1;function e(){return!1}return Gf=e,Gf}Eo.exports;var Jx;function Ps(){return Jx||(Jx=1,(function(e,n){var i=Gn(),s=sO(),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,e1;function Fu(){if(e1)return Yf;e1=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,t1;function iv(){if(t1)return Kf;t1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return Kf=n,Kf}var Xf,n1;function oO(){if(n1)return Xf;n1=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]",C="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",N="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",I="[object Uint8Array]",$="[object Uint8ClampedArray]",R="[object Uint16Array]",L="[object Uint32Array]",O={};O[k]=O[E]=O[N]=O[A]=O[M]=O[I]=O[$]=O[R]=O[L]=!0,O[s]=O[o]=O[S]=O[u]=O[b]=O[l]=O[c]=O[d]=O[h]=O[p]=O[m]=O[y]=O[x]=O[C]=O[_]=!1;function Q(V){return i(V)&&n(V.length)&&!!O[e(V)]}return Xf=Q,Xf}var Qf,r1;function zu(){if(r1)return Qf;r1=1;function e(n){return function(i){return n(i)}}return Qf=e,Qf}var No={exports:{}};No.exports;var i1;function sv(){return i1||(i1=1,(function(e,n){var i=rN(),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,s1;function Wo(){if(s1)return Zf;s1=1;var e=oO(),n=zu(),i=sv(),s=i&&i.isTypedArray,o=s?n(s):e;return Zf=o,Zf}var Jf,o1;function oN(){if(o1)return Jf;o1=1;var e=rO(),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),C=!m&&!y&&!x&&u(h),_=m||y||x||C,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")||C&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return Jf=d,Jf}var ed,a1;function Bu(){if(a1)return ed;a1=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,u1;function aN(){if(u1)return td;u1=1;function e(n,i){return function(s){return n(i(s))}}return td=e,td}var nd,l1;function aO(){if(l1)return nd;l1=1;var e=aN(),n=e(Object.keys,Object);return nd=n,nd}var rd,c1;function ov(){if(c1)return rd;c1=1;var e=Bu(),n=aO(),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,f1;function wr(){if(f1)return id;f1=1;var e=Uo(),n=iv();function i(s){return s!=null&&n(s.length)&&!e(s)}return id=i,id}var sd,d1;function ei(){if(d1)return sd;d1=1;var e=oN(),n=ov(),i=wr();function s(o){return i(o)?e(o):n(o)}return sd=s,sd}var od,h1;function uO(){if(h1)return od;h1=1;var e=Ho(),n=ei();function i(s,o){return s&&e(o,n(o),s)}return od=i,od}var ad,p1;function lO(){if(p1)return ad;p1=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,m1;function cO(){if(m1)return ud;m1=1;var e=An(),n=Bu(),i=lO(),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,g1;function qi(){if(g1)return ld;g1=1;var e=oN(),n=cO(),i=wr();function s(o){return i(o)?e(o,!0):n(o)}return ld=s,ld}var cd,v1;function fO(){if(v1)return cd;v1=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 y1;function uN(){return y1||(y1=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,w1;function lN(){if(w1)return fd;w1=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,x1;function cN(){if(x1)return dd;x1=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,_1;function fN(){if(_1)return hd;_1=1;function e(){return[]}return hd=e,hd}var pd,S1;function av(){if(S1)return pd;S1=1;var e=cN(),n=fN(),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,b1;function dO(){if(b1)return md;b1=1;var e=Ho(),n=av();function i(s,o){return e(s,n(s),o)}return md=i,md}var gd,k1;function uv(){if(k1)return gd;k1=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,E1;function Uu(){if(E1)return vd;E1=1;var e=aN(),n=e(Object.getPrototypeOf,Object);return vd=n,vd}var yd,N1;function dN(){if(N1)return yd;N1=1;var e=uv(),n=Uu(),i=av(),s=fN(),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,C1;function hO(){if(C1)return wd;C1=1;var e=Ho(),n=dN();function i(s,o){return e(s,n(s),o)}return wd=i,wd}var xd,T1;function hN(){if(T1)return xd;T1=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,R1;function pN(){if(R1)return _d;R1=1;var e=hN(),n=av(),i=ei();function s(o){return e(o,i,n)}return _d=s,_d}var Sd,j1;function pO(){if(j1)return Sd;j1=1;var e=hN(),n=dN(),i=qi();function s(o){return e(o,i,n)}return Sd=s,Sd}var bd,A1;function mO(){if(A1)return bd;A1=1;var e=Oi(),n=Gn(),i=e(n,"DataView");return bd=i,bd}var kd,I1;function gO(){if(I1)return kd;I1=1;var e=Oi(),n=Gn(),i=e(n,"Promise");return kd=i,kd}var Ed,M1;function mN(){if(M1)return Ed;M1=1;var e=Oi(),n=Gn(),i=e(n,"Set");return Ed=i,Ed}var Nd,P1;function vO(){if(P1)return Nd;P1=1;var e=Oi(),n=Gn(),i=e(n,"WeakMap");return Nd=i,Nd}var Cd,O1;function Os(){if(O1)return Cd;O1=1;var e=mO(),n=tv(),i=gO(),s=mN(),o=vO(),u=Pi(),l=iN(),c="[object Map]",d="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",x=l(e),C=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 N=u(E),A=N==d?E.constructor:void 0,M=A?l(A):"";if(M)switch(M){case x:return y;case C:return c;case _:return h;case S:return p;case b:return m}return N}),Cd=k,Cd}var Td,q1;function yO(){if(q1)return Td;q1=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,L1;function gN(){if(L1)return Rd;L1=1;var e=Gn(),n=e.Uint8Array;return Rd=n,Rd}var jd,$1;function lv(){if($1)return jd;$1=1;var e=gN();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,D1;function wO(){if(D1)return Ad;D1=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,F1;function xO(){if(F1)return Id;F1=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,z1;function _O(){if(z1)return Md;z1=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,B1;function vN(){if(B1)return Pd;B1=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,U1;function SO(){if(U1)return Od;U1=1;var e=lv(),n=wO(),i=xO(),s=_O(),o=vN(),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]",C="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",N="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",I="[object Uint32Array]";function $(R,L,O){var Q=R.constructor;switch(L){case x:return e(R);case u:case l:return new Q(+R);case C:return n(R,O);case _:case S:case b:case k:case E:case N:case A:case M:case I:return o(R,O);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=$,Od}var qd,H1;function yN(){if(H1)return qd;H1=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,V1;function wN(){if(V1)return Ld;V1=1;var e=yN(),n=Uu(),i=Bu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Ld=s,Ld}var $d,W1;function bO(){if(W1)return $d;W1=1;var e=Os(),n=rr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return $d=s,$d}var Dd,G1;function kO(){if(G1)return Dd;G1=1;var e=bO(),n=zu(),i=sv(),s=i&&i.isMap,o=s?n(s):e;return Dd=o,Dd}var Fd,Y1;function EO(){if(Y1)return Fd;Y1=1;var e=Os(),n=rr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Fd=s,Fd}var zd,K1;function NO(){if(K1)return zd;K1=1;var e=EO(),n=zu(),i=sv(),s=i&&i.isSet,o=s?n(s):e;return zd=o,zd}var Bd,X1;function xN(){if(X1)return Bd;X1=1;var e=Lu(),n=rv(),i=Du(),s=uO(),o=fO(),u=uN(),l=lN(),c=dO(),d=hO(),h=pN(),p=pO(),m=Os(),y=yO(),x=SO(),C=wN(),_=yt(),S=Ps(),b=kO(),k=An(),E=NO(),N=ei(),A=qi(),M=1,I=2,$=4,R="[object Arguments]",L="[object Array]",O="[object Boolean]",Q="[object Date]",V="[object Error]",j="[object Function]",Y="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",X="[object Object]",F="[object RegExp]",W="[object Set]",P="[object String]",B="[object Symbol]",ae="[object WeakMap]",z="[object ArrayBuffer]",G="[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[G]=be[O]=be[Q]=be[J]=be[se]=be[ue]=be[he]=be[ge]=be[U]=be[ne]=be[X]=be[F]=be[W]=be[P]=be[B]=be[Me]=be[Fe]=be[Re]=be[Pe]=!0,be[V]=be[j]=be[ae]=!1;function Oe(ve,ye,qe,Ye,Qe,et){var Be,Ze=ye&M,At=ye&I,Vt=ye&$;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==Y;if(S(ve))return u(ve,Ze);if(pt==X||pt==R||tt&&!Qe){if(Be=At||tt?{}:C(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:N,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,Q1;function CO(){if(Q1)return Ud;Q1=1;var e=xN(),n=4;function i(s){return e(s,n)}return Ud=i,Ud}var Hd,Z1;function cv(){if(Z1)return Hd;Z1=1;function e(n){return function(){return n}}return Hd=e,Hd}var Vd,J1;function TO(){if(J1)return Vd;J1=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,e_;function fv(){if(e_)return Wd;e_=1;var e=TO(),n=e();return Wd=n,Wd}var Gd,t_;function dv(){if(t_)return Gd;t_=1;var e=fv(),n=ei();function i(s,o){return s&&e(s,o,n)}return Gd=i,Gd}var Yd,n_;function RO(){if(n_)return Yd;n_=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,r_;function Hu(){if(r_)return Kd;r_=1;var e=dv(),n=RO(),i=n(e);return Kd=i,Kd}var Xd,i_;function Li(){if(i_)return Xd;i_=1;function e(n){return n}return Xd=e,Xd}var Qd,s_;function _N(){if(s_)return Qd;s_=1;var e=Li();function n(i){return typeof i=="function"?i:e}return Qd=n,Qd}var Zd,o_;function SN(){if(o_)return Zd;o_=1;var e=rv(),n=Hu(),i=_N(),s=yt();function o(u,l){var c=s(u)?e:n;return c(u,i(l))}return Zd=o,Zd}var Jd,a_;function bN(){return a_||(a_=1,Jd=SN()),Jd}var eh,u_;function jO(){if(u_)return eh;u_=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,l_;function AO(){if(l_)return th;l_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return th=n,th}var nh,c_;function IO(){if(c_)return nh;c_=1;function e(n){return this.__data__.has(n)}return nh=e,nh}var rh,f_;function kN(){if(f_)return rh;f_=1;var e=nv(),n=AO(),i=IO();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,d_;function MO(){if(d_)return ih;d_=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,h_;function EN(){if(h_)return sh;h_=1;function e(n,i){return n.has(i)}return sh=e,sh}var oh,p_;function NN(){if(p_)return oh;p_=1;var e=kN(),n=MO(),i=EN(),s=1,o=2;function u(l,c,d,h,p,m){var y=d&s,x=l.length,C=c.length;if(x!=C&&!(y&&C>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 N=l[b],A=c[b];if(h)var M=y?h(A,N,b,c,l,m):h(N,A,b,l,c,m);if(M!==void 0){if(M)continue;k=!1;break}if(E){if(!n(c,function(I,$){if(!i(E,$)&&(N===I||p(N,I,d,h,m)))return E.push($)})){k=!1;break}}else if(!(N===A||p(N,A,d,h,m))){k=!1;break}}return m.delete(l),m.delete(c),k}return oh=u,oh}var ah,m_;function PO(){if(m_)return ah;m_=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,g_;function hv(){if(g_)return uh;g_=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,v_;function OO(){if(v_)return lh;v_=1;var e=Ms(),n=gN(),i=Is(),s=NN(),o=PO(),u=hv(),l=1,c=2,d="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",C="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,N=E?E.valueOf:void 0;function A(M,I,$,R,L,O,Q){switch($){case k:if(M.byteLength!=I.byteLength||M.byteOffset!=I.byteOffset)return!1;M=M.buffer,I=I.buffer;case b:return!(M.byteLength!=I.byteLength||!O(new n(M),new n(I)));case d:case h:case y:return i(+M,+I);case p:return M.name==I.name&&M.message==I.message;case x:case _:return M==I+"";case m:var V=o;case C:var j=R&l;if(V||(V=u),M.size!=I.size&&!j)return!1;var Y=Q.get(M);if(Y)return Y==I;R|=c,Q.set(M,I);var U=s(V(M),V(I),R,L,O,Q);return Q.delete(M),U;case S:if(N)return N.call(M)==N.call(I)}return!1}return lh=A,lh}var ch,y_;function qO(){if(y_)return ch;y_=1;var e=pN(),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,C=e(l),_=C.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 N=!0;p.set(u,l),p.set(l,u);for(var A=m;++S<x;){b=y[S];var M=u[b],I=l[b];if(d)var $=m?d(I,M,b,l,u,p):d(M,I,b,u,l,p);if(!($===void 0?M===I||h(M,I,c,d,p):$)){N=!1;break}A||(A=b=="constructor")}if(N&&!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)&&(N=!1)}return p.delete(u),p.delete(l),N}return ch=o,ch}var fh,w_;function LO(){if(w_)return fh;w_=1;var e=Lu(),n=NN(),i=OO(),s=qO(),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 C(_,S,b,k,E,N){var A=u(_),M=u(S),I=A?p:o(_),$=M?p:o(S);I=I==h?m:I,$=$==h?m:$;var R=I==m,L=$==m,O=I==$;if(O&&l(_)){if(!l(S))return!1;A=!0,R=!1}if(O&&!R)return N||(N=new e),A||c(_)?n(_,S,b,k,E,N):i(_,S,I,b,k,E,N);if(!(b&d)){var Q=R&&x.call(_,"__wrapped__"),V=L&&x.call(S,"__wrapped__");if(Q||V){var j=Q?_.value():_,Y=V?S.value():S;return N||(N=new e),E(j,Y,b,k,N)}}return O?(N||(N=new e),s(_,S,b,k,E,N)):!1}return fh=C,fh}var dh,x_;function CN(){if(x_)return dh;x_=1;var e=LO(),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,__;function $O(){if(__)return hh;__=1;var e=Lu(),n=CN(),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],C=u[x],_=y[1];if(m&&y[2]){if(C===void 0&&!(x in u))return!1}else{var S=new e;if(d)var b=d(C,_,x,u,l,S);if(!(b===void 0?n(_,C,i|s,d,S):b))return!1}}return!0}return hh=o,hh}var ph,S_;function TN(){if(S_)return ph;S_=1;var e=An();function n(i){return i===i&&!e(i)}return ph=n,ph}var mh,b_;function DO(){if(b_)return mh;b_=1;var e=TN(),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,k_;function RN(){if(k_)return gh;k_=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,E_;function FO(){if(E_)return vh;E_=1;var e=$O(),n=DO(),i=RN();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,N_;function qs(){if(N_)return yh;N_=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,C_;function pv(){if(C_)return wh;C_=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,T_;function zO(){if(T_)return xh;T_=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,R_;function BO(){if(R_)return _h;R_=1;var e=zO(),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,j_;function UO(){if(j_)return Sh;j_=1;var e=BO(),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,A_;function Vu(){if(A_)return bh;A_=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,I_;function HO(){if(I_)return kh;I_=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,M_;function jN(){if(M_)return Eh;M_=1;var e=HO();function n(i){return i==null?"":e(i)}return Eh=n,Eh}var Nh,P_;function Wu(){if(P_)return Nh;P_=1;var e=yt(),n=pv(),i=UO(),s=jN();function o(u,l){return e(u)?u:n(u,l)?[u]:i(s(u))}return Nh=o,Nh}var Ch,O_;function Go(){if(O_)return Ch;O_=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,q_;function Gu(){if(q_)return Th;q_=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,L_;function VO(){if(L_)return Rh;L_=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,$_;function WO(){if($_)return jh;$_=1;function e(n,i){return n!=null&&i in Object(n)}return jh=e,jh}var Ah,D_;function AN(){if(D_)return Ah;D_=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,F_;function IN(){if(F_)return Ih;F_=1;var e=WO(),n=AN();function i(s,o){return s!=null&&n(s,o,e)}return Ih=i,Ih}var Mh,z_;function GO(){if(z_)return Mh;z_=1;var e=CN(),n=VO(),i=IN(),s=pv(),o=TN(),u=RN(),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,B_;function MN(){if(B_)return Ph;B_=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Ph=e,Ph}var Oh,U_;function YO(){if(U_)return Oh;U_=1;var e=Gu();function n(i){return function(s){return e(s,i)}}return Oh=n,Oh}var qh,H_;function KO(){if(H_)return qh;H_=1;var e=MN(),n=YO(),i=pv(),s=Go();function o(u){return i(u)?e(s(u)):n(u)}return qh=o,qh}var Lh,V_;function xr(){if(V_)return Lh;V_=1;var e=FO(),n=GO(),i=Li(),s=yt(),o=KO();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,W_;function PN(){if(W_)return $h;W_=1;var e=cN(),n=jO(),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,G_;function XO(){if(G_)return Dh;G_=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,Y_;function ON(){if(Y_)return Fh;Y_=1;var e=XO(),n=AN();function i(s,o){return s!=null&&n(s,o,e)}return Fh=i,Fh}var zh,K_;function QO(){if(K_)return zh;K_=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 C=n(x);if(C==d||C==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,X_;function qN(){if(X_)return Bh;X_=1;function e(n){return n===void 0}return Bh=e,Bh}var Uh,Q_;function LN(){if(Q_)return Uh;Q_=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,Z_;function $N(){if(Z_)return Hh;Z_=1;var e=Vu(),n=xr(),i=LN(),s=yt();function o(u,l){var c=s(u)?e:i;return c(u,n(l,3))}return Hh=o,Hh}var Vh,J_;function ZO(){if(J_)return Vh;J_=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,eS;function JO(){if(eS)return Wh;eS=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,tS;function DN(){if(tS)return Gh;tS=1;var e=ZO(),n=Hu(),i=xr(),s=JO(),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,nS;function eq(){if(nS)return Yh;nS=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,rS;function tq(){if(rS)return Kh;rS=1;var e=MN(),n=e("length");return Kh=n,Kh}var Xh,iS;function nq(){if(iS)return Xh;iS=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,sS;function rq(){if(sS)return Qh;sS=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",C=h+"?",_="["+u+"]?",S="(?:"+x+"(?:"+[p,m,y].join("|")+")"+_+C+")*",b=_+C+S,k="(?:"+[p+c+"?",c,m,y,l].join("|")+")",E=RegExp(d+"(?="+d+")|"+k+b,"g");function N(A){for(var M=E.lastIndex=0;E.test(A);)++M;return M}return Qh=N,Qh}var Zh,oS;function iq(){if(oS)return Zh;oS=1;var e=tq(),n=nq(),i=rq();function s(o){return n(o)?i(o):e(o)}return Zh=s,Zh}var Jh,aS;function sq(){if(aS)return Jh;aS=1;var e=ov(),n=Os(),i=wr(),s=eq(),o=iq(),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,uS;function oq(){if(uS)return ep;uS=1;var e=rv(),n=yN(),i=dv(),s=xr(),o=Uu(),u=yt(),l=Ps(),c=Uo(),d=An(),h=Wo();function p(m,y,x){var C=u(m),_=C||l(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=C?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,lS;function aq(){if(lS)return tp;lS=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,cS;function mv(){if(cS)return np;cS=1;var e=uv(),n=aq();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,fS;function uq(){if(fS)return rp;fS=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,dS;function FN(){if(dS)return ip;dS=1;var e=uq(),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,hS;function lq(){if(hS)return sp;hS=1;var e=cv(),n=sN(),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,pS;function cq(){if(pS)return op;pS=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,mS;function zN(){if(mS)return ap;mS=1;var e=lq(),n=cq(),i=n(e);return ap=i,ap}var up,gS;function Yu(){if(gS)return up;gS=1;var e=Li(),n=FN(),i=zN();function s(o,u){return i(n(o,u,e),o+"")}return up=s,up}var lp,vS;function BN(){if(vS)return lp;vS=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,yS;function fq(){if(yS)return cp;yS=1;function e(n){return n!==n}return cp=e,cp}var fp,wS;function dq(){if(wS)return fp;wS=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,xS;function hq(){if(xS)return dp;xS=1;var e=BN(),n=fq(),i=dq();function s(o,u,l){return u===u?i(o,u,l):e(o,n,l)}return dp=s,dp}var hp,_S;function pq(){if(_S)return hp;_S=1;var e=hq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return hp=n,hp}var pp,SS;function mq(){if(SS)return pp;SS=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,bS;function gq(){if(bS)return mp;bS=1;function e(){}return mp=e,mp}var gp,kS;function vq(){if(kS)return gp;kS=1;var e=mN(),n=gq(),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,ES;function yq(){if(ES)return vp;ES=1;var e=kN(),n=pq(),i=mq(),s=EN(),o=vq(),u=hv(),l=200;function c(d,h,p){var m=-1,y=n,x=d.length,C=!0,_=[],S=_;if(p)C=!1,y=i;else if(x>=l){var b=h?null:o(d);if(b)return u(b);C=!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,C&&E===E){for(var N=S.length;N--;)if(S[N]===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,NS;function UN(){if(NS)return yp;NS=1;var e=wr(),n=rr();function i(s){return n(s)&&e(s)}return yp=i,yp}var wp,CS;function wq(){if(CS)return wp;CS=1;var e=mv(),n=Yu(),i=yq(),s=UN(),o=n(function(u){return i(e(u,1,s,!0))});return wp=o,wp}var xp,TS;function xq(){if(TS)return xp;TS=1;var e=Vu();function n(i,s){return e(s,function(o){return i[o]})}return xp=n,xp}var _p,RS;function HN(){if(RS)return _p;RS=1;var e=xq(),n=ei();function i(s){return s==null?[]:e(s,n(s))}return _p=i,_p}var Sp,jS;function In(){if(jS)return Sp;jS=1;var e;if(typeof ev=="function")try{e={clone:CO(),constant:cv(),each:bN(),filter:PN(),has:ON(),isArray:yt(),isEmpty:QO(),isFunction:Uo(),isUndefined:qN(),keys:ei(),map:$N(),reduce:DN(),size:sq(),transform:oq(),union:wq(),values:HN()}}catch{}return e||(e=window._),Sp=e,Sp}var bp,AS;function gv(){if(AS)return bp;AS=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(C){y.length>1?x.setNode(C,m):x.setNode(C)}),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 C(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:C(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,C(_))}),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(C,_){return x.length>1?y.setEdge(C,_,m):y.setEdge(C,_),_}),this},o.prototype.setEdge=function(){var p,m,y,x,C=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],C=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],C=!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 C&&(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]=C?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),C=this._edgeObjs[x];return C&&(p=C.v,m=C.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(C){return C.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(C){return C.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 C=""+m,_=""+y;if(!p&&C>_){var S=C;C=_,_=S}return C+s+_+s+(e.isUndefined(x)?n:x)}function d(p,m,y,x){var C=""+m,_=""+y;if(!p&&C>_){var S=C;C=_,_=S}var b={v:C,w:_};return x&&(b.name=x),b}function h(p,m){return c(p,m.v,m.w,m.name)}return bp}var kp,IS;function _q(){return IS||(IS=1,kp="2.1.8"),kp}var Ep,MS;function Sq(){return MS||(MS=1,Ep={Graph:gv(),version:_q()}),Ep}var Np,PS;function bq(){if(PS)return Np;PS=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,OS;function kq(){if(OS)return Cp;OS=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,qS;function VN(){if(qS)return Tp;qS=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,LS;function WN(){if(LS)return Rp;LS=1;var e=In(),n=VN();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(C){var _=C.v!==m?C.v:C.w,S=h[_],b=c(C),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+C+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=m,p.decrease(_,k))};for(u.nodes().forEach(function(C){var _=C===l?0:Number.POSITIVE_INFINITY;h[C]={distance:_},p.add(C,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)d(m).forEach(x);return h}return Rp}var jp,$S;function Eq(){if($S)return jp;$S=1;var e=WN(),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,DS;function GN(){if(DS)return Ap;DS=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,FS;function Nq(){if(FS)return Ip;FS=1;var e=In(),n=GN();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,zS;function Cq(){if(zS)return Mp;zS=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 C=y[h],_=p[x],S=y[x],b=C.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Mp}var Pp,BS;function YN(){if(BS)return Pp;BS=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,US;function Tq(){if(US)return Op;US=1;var e=YN();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,HS;function KN(){if(HS)return qp;HS=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,VS;function Rq(){if(VS)return Lp;VS=1;var e=KN();Lp=n;function n(i,s){return e(i,s,"post")}return Lp}var $p,WS;function jq(){if(WS)return $p;WS=1;var e=KN();$p=n;function n(i,s){return e(i,s,"pre")}return $p}var Dp,GS;function Aq(){if(GS)return Dp;GS=1;var e=In(),n=gv(),i=VN();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,C=d.priority(x);if(C!==void 0){var _=u(y);_<C&&(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,YS;function Iq(){return YS||(YS=1,Fp={components:kq(),dijkstra:WN(),dijkstraAll:Eq(),findCycles:Nq(),floydWarshall:Cq(),isAcyclic:Tq(),postorder:Rq(),preorder:jq(),prim:Aq(),tarjan:GN(),topsort:YN()}),Fp}var zp,KS;function Mq(){if(KS)return zp;KS=1;var e=Sq();return zp={Graph:e.Graph,json:bq(),alg:Iq(),version:e.version},zp}var Bp,XS;function Vn(){if(XS)return Bp;XS=1;var e;if(typeof ev=="function")try{e=Mq()}catch{}return e||(e=window.graphlib),Bp=e,Bp}var Up,QS;function Pq(){if(QS)return Up;QS=1;var e=xN(),n=1,i=4;function s(o){return e(o,n|i)}return Up=s,Up}var Hp,ZS;function Ku(){if(ZS)return Hp;ZS=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,JS;function Oq(){if(JS)return Vp;JS=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),C=-1,_=x.length;++C<_;){var S=x[C],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,eb;function qq(){if(eb)return Wp;eb=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,tb;function Lq(){if(tb)return Gp;tb=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,nb;function $q(){if(nb)return Yp;nb=1;var e=Lq(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return Yp=i,Yp}var Kp,rb;function Dq(){if(rb)return Kp;rb=1;var e=$q(),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,ib;function XN(){if(ib)return Xp;ib=1;var e=Dq(),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,sb;function Fq(){if(sb)return Qp;sb=1;var e=XN();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return Qp=n,Qp}var Zp,ob;function zq(){if(ob)return Zp;ob=1;var e=BN(),n=xr(),i=Fq(),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,ab;function Bq(){if(ab)return Jp;ab=1;var e=qq(),n=zq(),i=e(n);return Jp=i,Jp}var em,ub;function QN(){if(ub)return em;ub=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,lb;function Uq(){if(lb)return tm;lb=1;var e=fv(),n=_N(),i=qi();function s(o,u){return o==null?o:e(o,n(u),i)}return tm=s,tm}var nm,cb;function Hq(){if(cb)return nm;cb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return nm=e,nm}var rm,fb;function Vq(){if(fb)return rm;fb=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,db;function vv(){if(db)return im;db=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,hb;function Wq(){if(hb)return sm;hb=1;function e(n,i){return n>i}return sm=e,sm}var om,pb;function Gq(){if(pb)return om;pb=1;var e=vv(),n=Wq(),i=Li();function s(o){return o&&o.length?e(o,i,n):void 0}return om=s,om}var am,mb;function ZN(){if(mb)return am;mb=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,gb;function Yq(){if(gb)return um;gb=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,vb;function JN(){if(vb)return lm;vb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return lm=e,lm}var cm,yb;function Kq(){if(yb)return cm;yb=1;var e=Ho(),n=qi();function i(s){return e(s,n(s))}return cm=i,cm}var fm,wb;function Xq(){if(wb)return fm;wb=1;var e=ZN(),n=uN(),i=vN(),s=lN(),o=wN(),u=Vo(),l=yt(),c=UN(),d=Ps(),h=Uo(),p=An(),m=Yq(),y=Wo(),x=JN(),C=Kq();function _(S,b,k,E,N,A,M){var I=x(S,k),$=x(b,k),R=M.get($);if(R){e(S,k,R);return}var L=A?A(I,$,k+"",S,b,M):void 0,O=L===void 0;if(O){var Q=l($),V=!Q&&d($),j=!Q&&!V&&y($);L=$,Q||V||j?l(I)?L=I:c(I)?L=s(I):V?(O=!1,L=n($,!0)):j?(O=!1,L=i($,!0)):L=[]:m($)||u($)?(L=I,u(I)?L=C(I):(!p(I)||h(I))&&(L=o($))):O=!1}O&&(M.set($,L),N(L,$,E,A,M),M.delete($)),e(S,k,L)}return fm=_,fm}var dm,xb;function Qq(){if(xb)return dm;xb=1;var e=Lu(),n=ZN(),i=fv(),s=Xq(),o=An(),u=qi(),l=JN();function c(d,h,p,m,y){d!==h&&i(h,function(x,C){if(y||(y=new e),o(x))s(d,h,C,p,c,m,y);else{var _=m?m(l(d,C),x,C+"",d,h,y):void 0;_===void 0&&(_=x),n(d,C,_)}},u)}return dm=c,dm}var hm,_b;function Zq(){if(_b)return hm;_b=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,Sb;function Jq(){if(Sb)return pm;Sb=1;var e=Qq(),n=Zq(),i=n(function(s,o,u){e(s,o,u)});return pm=i,pm}var mm,bb;function eC(){if(bb)return mm;bb=1;function e(n,i){return n<i}return mm=e,mm}var gm,kb;function eL(){if(kb)return gm;kb=1;var e=vv(),n=eC(),i=Li();function s(o){return o&&o.length?e(o,i,n):void 0}return gm=s,gm}var vm,Eb;function tL(){if(Eb)return vm;Eb=1;var e=vv(),n=xr(),i=eC();function s(o,u){return o&&o.length?e(o,n(u,2),i):void 0}return vm=s,vm}var ym,Nb;function nL(){if(Nb)return ym;Nb=1;var e=Gn(),n=function(){return e.Date.now()};return ym=n,ym}var wm,Cb;function rL(){if(Cb)return wm;Cb=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 C=o(c[p]),_=d;if(C==="__proto__"||C==="constructor"||C==="prototype")return l;if(p!=y){var S=x[C];_=h?h(S,C,x):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(x,C,_),x=x[C]}return l}return wm=u,wm}var xm,Tb;function iL(){if(Tb)return xm;Tb=1;var e=Gu(),n=rL(),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,Rb;function sL(){if(Rb)return _m;Rb=1;var e=iL(),n=IN();function i(s,o){return e(s,o,function(u,l){return n(s,l)})}return _m=i,_m}var Sm,jb;function oL(){if(jb)return Sm;jb=1;var e=QN(),n=FN(),i=zN();function s(o){return i(n(o,void 0,e),o+"")}return Sm=s,Sm}var bm,Ab;function aL(){if(Ab)return bm;Ab=1;var e=sL(),n=oL(),i=n(function(s,o){return s==null?{}:e(s,o)});return bm=i,bm}var km,Ib;function uL(){if(Ib)return km;Ib=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,Mb;function lL(){if(Mb)return Em;Mb=1;var e=uL(),n=Ku(),i=XN();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,Pb;function cL(){if(Pb)return Nm;Pb=1;var e=lL(),n=e();return Nm=n,Nm}var Cm,Ob;function fL(){if(Ob)return Cm;Ob=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,qb;function dL(){if(qb)return Tm;qb=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,Lb;function hL(){if(Lb)return Rm;Lb=1;var e=dL();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,$b;function pL(){if($b)return jm;$b=1;var e=Vu(),n=Gu(),i=xr(),s=LN(),o=fL(),u=zu(),l=hL(),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 C=s(p,function(_,S,b){var k=e(m,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(C,function(_,S){return l(_,S,y)})}return jm=h,jm}var Am,Db;function mL(){if(Db)return Am;Db=1;var e=mv(),n=pL(),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,Fb;function gL(){if(Fb)return Im;Fb=1;var e=jN(),n=0;function i(s){var o=++n;return e(s)+o}return Im=i,Im}var Mm,zb;function vL(){if(zb)return Mm;zb=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,Bb;function yL(){if(Bb)return Pm;Bb=1;var e=Du(),n=vL();function i(s,o){return n(s||[],o||[],e)}return Pm=i,Pm}var Om,Ub;function ut(){if(Ub)return Om;Ub=1;var e;if(typeof ev=="function")try{e={cloneDeep:Pq(),constant:cv(),defaults:Oq(),each:bN(),filter:PN(),find:Bq(),flatten:QN(),forEach:SN(),forIn:Uq(),has:ON(),isUndefined:qN(),last:Hq(),map:$N(),mapValues:Vq(),max:Gq(),merge:Jq(),min:eL(),minBy:tL(),now:nL(),pick:aL(),range:cL(),reduce:DN(),sortBy:mL(),uniqueId:gL(),values:HN(),zipObject:yL()}}catch{}return e||(e=window._),Om=e,Om}var qm,Hb;function wL(){if(Hb)return qm;Hb=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,Vb;function xL(){if(Vb)return Lm;Vb=1;var e=ut(),n=Vn().Graph,i=wL();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],C=p[0],_;h.nodeCount();){for(;_=C.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 C=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&C.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),C}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 C=e.range(x+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){d(C,_,m.node(S))}),{graph:m,buckets:C,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,Wb;function _L(){if(Wb)return $m;Wb=1;var e=ut(),n=xL();$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,Gb;function sn(){if(Gb)return Dm;Gb=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:C,notime:_};function i(S,b,k,E){var N;do N=e.uniqueId(E);while(S.hasNode(N));return k.dummy=b,S.setNode(N,k),N}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},N=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+N.weight,minlen:Math.max(E.minlen,N.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(N){E[N.w]=(E[N.w]||0)+S.edge(N).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(N){E[N.v]=(E[N.v]||0)+S.edge(N).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,N=b.x-k,A=b.y-E,M=S.width/2,I=S.height/2;if(!N&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var $,R;return Math.abs(A)*M>Math.abs(N)*I?(A<0&&(I=-I),$=I*N/A,R=I):(N<0&&(M=-M),$=M,R=M*A/N),{x:k+$,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),N=E.rank;e.isUndefined(N)||(b[N][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 M=S.node(A).rank-b;k[M]||(k[M]=[]),k[M].push(A)});var E=0,N=S.graph().nodeRankFactor;e.forEach(k,function(A,M){e.isUndefined(A)&&M%N!==0?--E:E&&e.forEach(A,function(I){S.node(I).rank+=E})})}function m(S,b,k,E){var N={width:0,height:0};return arguments.length>=4&&(N.rank=k,N.order=E),i(S,"border",N,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 C(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,Yb;function SL(){if(Yb)return Fm;Yb=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 C,_,S;for(S=0,++d;d<p;++S,++d)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:l,rank:d},C=n.addDummyNode(u,"edge",_,"_d"),d===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),u.setEdge(c,C,{weight:y.weight},m),S===0&&u.graph().dummyChains.push(C),c=C;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,Kb;function Eu(){if(Kb)return zm;Kb=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,Xb;function tC(){if(Xb)return Bm;Xb=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,Qb;function bL(){if(Qb)return Um;Qb=1;var e=ut(),n=tC(),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=C,c.exchangeEdges=_;function c(E){E=l(E),s(E);var N=n(E);m(N),d(N,E);for(var A,M;A=x(N);)M=C(N,E,A),_(N,E,A,M)}function d(E,N){var A=u(E,E.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(M){h(E,N,M)})}function h(E,N,A){var M=E.node(A),I=M.parent;E.edge(A,I).cutvalue=p(E,N,A)}function p(E,N,A){var M=E.node(A),I=M.parent,$=!0,R=N.edge(A,I),L=0;return R||($=!1,R=N.edge(I,A)),L=R.weight,e.forEach(N.nodeEdges(A),function(O){var Q=O.v===A,V=Q?O.w:O.v;if(V!==I){var j=Q===$,Y=N.edge(O).weight;if(L+=j?Y:-Y,b(E,A,V)){var U=E.edge(A,V).cutvalue;L+=j?-U:U}}}),L}function m(E,N){arguments.length<2&&(N=E.nodes()[0]),y(E,{},1,N)}function y(E,N,A,M,I){var $=A,R=E.node(M);return N[M]=!0,e.forEach(E.neighbors(M),function(L){e.has(N,L)||(A=y(E,N,A,L,M))}),R.low=$,R.lim=A++,I?R.parent=I:delete R.parent,A}function x(E){return e.find(E.edges(),function(N){return E.edge(N).cutvalue<0})}function C(E,N,A){var M=A.v,I=A.w;N.hasEdge(M,I)||(M=A.w,I=A.v);var $=E.node(M),R=E.node(I),L=$,O=!1;$.lim>R.lim&&(L=R,O=!0);var Q=e.filter(N.edges(),function(V){return O===k(E,E.node(V.v),L)&&O!==k(E,E.node(V.w),L)});return e.minBy(Q,function(V){return i(N,V)})}function _(E,N,A,M){var I=A.v,$=A.w;E.removeEdge(I,$),E.setEdge(M.v,M.w,{}),m(E),d(E,N),S(E,N)}function S(E,N){var A=e.find(E.nodes(),function(I){return!N.node(I).parent}),M=o(E,A);M=M.slice(1),e.forEach(M,function(I){var $=E.node(I).parent,R=N.edge(I,$),L=!1;R||(R=N.edge($,I),L=!0),N.node(I).rank=N.node($).rank+(L?R.minlen:-R.minlen)})}function b(E,N,A){return E.hasEdge(N,A)}function k(E,N,A){return A.low<=N.lim&&N.lim<=A.lim}return Um}var Hm,Zb;function kL(){if(Zb)return Hm;Zb=1;var e=Eu(),n=e.longestPath,i=tC(),s=bL();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,Jb;function EL(){if(Jb)return Vm;Jb=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],C=!0;l!==d.w;){if(c=o.node(l),C){for(;(x=p[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(C=!1)}if(!C){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,ek;function NL(){if(ek)return Wm;ek=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 C=c.children(x);if(!C.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(C,function(k){s(c,d,h,p,m,y,k);var E=c.node(k),N=E.borderTop?E.borderTop:k,A=E.borderBottom?E.borderBottom:k,M=E.borderTop?p:2*p,I=N!==A?1:m-y[x]+1;c.setEdge(_,N,{weight:M,minlen:I,nestingEdge:!0}),c.setEdge(A,S,{weight:M,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,tk;function CL(){if(tk)return Gm;tk=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,nk;function TL(){if(nk)return Ym;nk=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,rk;function RL(){if(rk)return Km;rk=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,ik;function jL(){if(ik)return Xm;ik=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 C=0;x>0;)x%2&&(C+=p[x+1]),x=x-1>>1,p[x]+=y.weight;m+=y.weight*C})),m}return Xm}var Qm,sk;function AL(){if(sk)return Qm;sk=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,ok;function IL(){if(ok)return Zm;ok=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,ak;function ML(){if(ak)return Jm;ak=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 C={vs:e.flatten(p,!0)};return y&&(C.barycenter=m/y,C.weight=y),C}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,uk;function PL(){if(uk)return eg;uk=1;var e=ut(),n=AL(),i=IL(),s=ML();eg=o;function o(c,d,h,p){var m=c.children(d),y=c.node(d),x=y?y.borderLeft:void 0,C=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(A){return A!==x&&A!==C}));var S=n(c,m);e.forEach(S,function(A){if(c.children(A.v).length){var M=o(c,A.v,h,p);_[A.v]=M,e.has(M,"barycenter")&&l(A,M)}});var b=i(S,h);u(b,_);var k=s(b,p);if(x&&(k.vs=e.flatten([x,k.vs,C],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[0]),N=c.node(c.predecessors(C)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+N.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,lk;function OL(){if(lk)return tg;lk=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,C=d.edge(x,h),_=e.isUndefined(C)?0:C.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,ck;function qL(){if(ck)return ng;ck=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,fk;function LL(){if(fk)return rg;fk=1;var e=ut(),n=RL(),i=jL(),s=PL(),o=OL(),u=qL(),l=Vn().Graph,c=sn();rg=d;function d(y){var x=c.maxRank(y),C=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,N=0;N<4;++E,++N){p(E%2?C:_,E%4>=2),S=c.buildLayerMatrix(y);var A=i(y,S);A<b&&(N=0,k=e.cloneDeep(S),b=A)}m(y,k)}function h(y,x,C){return e.map(x,function(_){return o(y,_,C)})}function p(y,x){var C=new l;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,C,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),u(_,C,b.vs)})}function m(y,x){e.forEach(x,function(C){e.forEach(C,function(_,S){y.node(_).order=S})})}return rg}var ig,dk;function $L(){if(dk)return ig;dk=1;var e=ut(),n=Vn().Graph,i=sn();ig={positionX:C,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 N(A,M){var I=0,$=0,R=A.length,L=e.last(M);return e.forEach(M,function(O,Q){var V=u(b,O),j=V?b.node(V).order:R;(V||O===L)&&(e.forEach(M.slice($,Q+1),function(Y){e.forEach(b.predecessors(Y),function(U){var ne=b.node(U),X=ne.order;(X<I||j<X)&&!(ne.dummy&&b.node(Y).dummy)&&l(E,U,Y)})}),$=Q+1,I=j)}),M}return e.reduce(k,N),E}function o(b,k){var E={};function N(M,I,$,R,L){var O;e.forEach(e.range(I,$),function(Q){O=M[Q],b.node(O).dummy&&e.forEach(b.predecessors(O),function(V){var j=b.node(V);j.dummy&&(j.order<R||j.order>L)&&l(E,V,O)})})}function A(M,I){var $=-1,R,L=0;return e.forEach(I,function(O,Q){if(b.node(O).dummy==="border"){var V=b.predecessors(O);V.length&&(R=b.node(V[0]).order,N(I,L,Q,$,R),L=Q,$=R)}N(I,L,I.length,R,M.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 N=k;k=E,E=N}var A=b[k];A||(b[k]=A={}),A[E]=!0}function c(b,k,E){if(k>E){var N=k;k=E,E=N}return e.has(b[k],E)}function d(b,k,E,N){var A={},M={},I={};return e.forEach(k,function($){e.forEach($,function(R,L){A[R]=R,M[R]=R,I[R]=L})}),e.forEach(k,function($){var R=-1;e.forEach($,function(L){var O=N(L);if(O.length){O=e.sortBy(O,function(U){return I[U]});for(var Q=(O.length-1)/2,V=Math.floor(Q),j=Math.ceil(Q);V<=j;++V){var Y=O[V];M[L]===L&&R<I[Y]&&!c(E,L,Y)&&(M[Y]=L,M[L]=A[L]=A[Y],R=I[Y])}}})}),{root:A,align:M}}function h(b,k,E,N,A){var M={},I=p(b,k,E,A),$=A?"borderLeft":"borderRight";function R(Q,V){for(var j=I.nodes(),Y=j.pop(),U={};Y;)U[Y]?Q(Y):(U[Y]=!0,j.push(Y),j=j.concat(V(Y))),Y=j.pop()}function L(Q){M[Q]=I.inEdges(Q).reduce(function(V,j){return Math.max(V,M[j.v]+I.edge(j))},0)}function O(Q){var V=I.outEdges(Q).reduce(function(Y,U){return Math.min(Y,M[U.w]-I.edge(U))},Number.POSITIVE_INFINITY),j=b.node(Q);V!==Number.POSITIVE_INFINITY&&j.borderType!==$&&(M[Q]=Math.max(M[Q],V))}return R(L,I.predecessors.bind(I)),R(O,I.successors.bind(I)),e.forEach(N,function(Q){M[Q]=M[E[Q]]}),M}function p(b,k,E,N){var A=new n,M=b.graph(),I=_(M.nodesep,M.edgesep,N);return e.forEach(k,function($){var R;e.forEach($,function(L){var O=E[L];if(A.setNode(O),R){var Q=E[R],V=A.edge(Q,O);A.setEdge(Q,O,Math.max(I(b,L,R),V||0))}R=L})}),A}function m(b,k){return e.minBy(e.values(k),function(E){var N=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(E,function(M,I){var $=S(b,I)/2;N=Math.max(M+$,N),A=Math.min(M-$,A)}),N-A})}function y(b,k){var E=e.values(k),N=e.min(E),A=e.max(E);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(I){var $=M+I,R=b[$],L;if(R!==k){var O=e.values(R);L=I==="l"?N-e.min(O):A-e.max(O),L&&(b[$]=e.mapValues(R,function(Q){return Q+L}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,N){if(k)return b[k.toLowerCase()][N];var A=e.sortBy(e.map(b,N));return(A[1]+A[2])/2})}function C(b){var k=i.buildLayerMatrix(b),E=e.merge(s(b,k),o(b,k)),N={},A;e.forEach(["u","d"],function(I){A=I==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function($){$==="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),O=h(b,A,L.root,L.align,$==="r");$==="r"&&(O=e.mapValues(O,function(Q){return-Q})),N[I+$]=O})});var M=m(b,N);return y(N,M),x(N,b.graph().align)}function _(b,k,E){return function(N,A,M){var I=N.node(A),$=N.node(M),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+=($.dummy?k:b)/2,R+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":L=$.width/2;break;case"r":L=-$.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,hk;function DL(){if(hk)return sg;hk=1;var e=ut(),n=sn(),i=$L().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,pk;function FL(){if(pk)return og;pk=1;var e=ut(),n=_L(),i=SL(),s=kL(),o=sn().normalizeRanks,u=EL(),l=sn().removeEmptyRanks,c=NL(),d=CL(),h=TL(),p=LL(),m=DL(),y=sn(),x=Vn().Graph;og=C;function C(z,G){var J=G&&G.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,G){G(" makeSpaceForEdgeLabels",function(){L(z)}),G(" removeSelfEdges",function(){F(z)}),G(" acyclic",function(){n.run(z)}),G(" nestingGraph.run",function(){c.run(z)}),G(" rank",function(){s(y.asNonCompoundGraph(z))}),G(" injectEdgeLabelProxies",function(){O(z)}),G(" removeEmptyRanks",function(){l(z)}),G(" nestingGraph.cleanup",function(){c.cleanup(z)}),G(" normalizeRanks",function(){o(z)}),G(" assignRankMinMax",function(){Q(z)}),G(" removeEdgeLabelProxies",function(){V(z)}),G(" normalize.run",function(){i.run(z)}),G(" parentDummyChains",function(){u(z)}),G(" addBorderSegments",function(){d(z)}),G(" order",function(){p(z)}),G(" insertSelfEdges",function(){W(z)}),G(" adjustCoordinateSystem",function(){h.adjust(z)}),G(" position",function(){m(z)}),G(" positionSelfEdges",function(){P(z)}),G(" removeBorderNodes",function(){X(z)}),G(" normalize.undo",function(){i.undo(z)}),G(" fixupEdgeLabelCoords",function(){U(z)}),G(" undoCoordinateSystem",function(){h.undo(z)}),G(" translateGraph",function(){j(z)}),G(" assignNodeIntersects",function(){Y(z)}),G(" reversePoints",function(){ne(z)}),G(" acyclic.undo",function(){n.undo(z)})}function S(z,G){e.forEach(z.nodes(),function(J){var se=z.node(J),ue=G.node(J);se&&(se.x=ue.x,se.y=ue.y,G.children(J).length&&(se.width=ue.width,se.height=ue.height))}),e.forEach(z.edges(),function(J){var se=z.edge(J),ue=G.edge(J);se.points=ue.points,e.has(ue,"x")&&(se.x=ue.x,se.y=ue.y)}),z.graph().width=G.graph().width,z.graph().height=G.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],N=["width","height"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},$=["labelpos"];function R(z){var G=new x({multigraph:!0,compound:!0}),J=ae(z.graph());return G.setGraph(e.merge({},k,B(J,b),e.pick(J,E))),e.forEach(z.nodes(),function(se){var ue=ae(z.node(se));G.setNode(se,e.defaults(B(ue,N),A)),G.setParent(se,z.parent(se))}),e.forEach(z.edges(),function(se){var ue=ae(z.edge(se));G.setEdge(se,e.merge({},I,B(ue,M),e.pick(ue,$)))}),G}function L(z){var G=z.graph();G.ranksep/=2,e.forEach(z.edges(),function(J){var se=z.edge(J);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(G.rankdir==="TB"||G.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function O(z){e.forEach(z.edges(),function(G){var J=z.edge(G);if(J.width&&J.height){var se=z.node(G.v),ue=z.node(G.w),he={rank:(ue.rank-se.rank)/2+se.rank,e:G};y.addDummyNode(z,"edge-proxy",he,"_ep")}})}function Q(z){var G=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,G=e.max(G,se.maxRank))}),z.graph().maxRank=G}function V(z){e.forEach(z.nodes(),function(G){var J=z.node(G);J.dummy==="edge-proxy"&&(z.edge(J.e).labelRank=J.rank,z.removeNode(G))})}function j(z){var G=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;G=Math.min(G,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)}),G-=ge,se-=Me,e.forEach(z.nodes(),function(Re){var Pe=z.node(Re);Pe.x-=G,Pe.y-=se}),e.forEach(z.edges(),function(Re){var Pe=z.edge(Re);e.forEach(Pe.points,function(be){be.x-=G,be.y-=se}),e.has(Pe,"x")&&(Pe.x-=G),e.has(Pe,"y")&&(Pe.y-=se)}),he.width=J-G+ge,he.height=ue-se+Me}function Y(z){e.forEach(z.edges(),function(G){var J=z.edge(G),se=z.node(G.v),ue=z.node(G.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(G){var J=z.edge(G);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(G){var J=z.edge(G);J.reversed&&J.points.reverse()})}function X(z){e.forEach(z.nodes(),function(G){if(z.children(G).length){var J=z.node(G),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(G){z.node(G).dummy==="border"&&z.removeNode(G)})}function F(z){e.forEach(z.edges(),function(G){if(G.v===G.w){var J=z.node(G.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:G,label:z.edge(G)}),z.removeEdge(G)}})}function W(z){var G=y.buildLayerMatrix(z);e.forEach(G,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 P(z){e.forEach(z.nodes(),function(G){var J=z.node(G);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(G),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,G){return e.mapValues(e.pick(z,G),Number)}function ae(z){var G={};return e.forEach(z,function(J,se){G[se.toLowerCase()]=J}),G}return og}var ag,mk;function zL(){if(mk)return ag;mk=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,gk;function BL(){return gk||(gk=1,ug="0.8.5"),ug}var lg,vk;function UL(){return vk||(vk=1,lg={graphlib:Vn(),layout:FL(),debug:zL(),util:{time:sn().time,notime:sn().notime},version:BL()}),lg}var HL=UL();const yk=Mg(HL),Ai=240,Ns=130,Cs=74,Xu=72,wk=Cs+Xu;function VL(e){let n=Ai;for(const i of e.values())n=Math.max(n,i.width);return n}const WL=420,GL=2;function Qu(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function YL(e,n,i,s,o){const u=new yk.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);yk.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,N=S.x-k/2,A=S.y-E/2;d.set(_,{x:N,y:A}),N<h&&(h=N),A<p&&(p=A),N+k>m&&(m=N+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,C=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)),C=Math.max(C,S.y+((b==null?void 0:b.height)??Ns))}return{positions:d,width:x,height:C}}function KL(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,...YL(l.get(S),n,s,u,o)})),h=VL(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+wk;return b},y=S=>S.reduce((b,k)=>Math.max(b,k.width),0)+WL;let x=m(i.availableWidth?GL:1);x.length>1&&x.reduce((b,k)=>b+y(k),0)+h*(x.length-1)>(i.availableWidth??0)&&(x=m(1));const C=new Map;let _=0;for(const S of x){let b=0;for(const{positions:k,height:E}of S){for(const[N,A]of k)C.set(N,{x:A.x+_,y:A.y+b});b+=E+wk}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const k=C.get(S.id);return k?{...S,position:k}:S})}function XL(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:C,h:_}=c(y),S=d.get(y)??"_default";if(i.has(y)){h.push({x:x.x,y:x.y,w:C,h:_,sid:S});continue}let b=x.y;for(let k=0;k<h.length+1;k++){const E=h.find(N=>{const A=N.sid===S?24:l,M=N.sid===S?24:u;return x.x<N.x+N.w+A&&N.x<x.x+C+A&&b<N.y+N.h+M&&N.y<b+_+M});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:C,h:_,sid:S})}return m}function QL(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:C,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:C,h:_})}if(c.size===0)return[];const h=Cs+Xu,p=(y,x,C,_)=>d.some(S=>y<S.x+S.w+Cs&&S.x<y+C+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 C=1/0,_=1/0,S=-1/0,b=-1/0;for(const $ of x){const R=l($.id),{w:L,h:O}=u($.id);C=Math.min(C,R.x),_=Math.min(_,R.y),S=Math.max(S,R.x+L),b=Math.max(b,R.y+O)}const k=S-C,E=b-_,N=[...new Set(d.map($=>Math.round($.x)))].sort(($,R)=>$-R),A=N.length?N:[C],M=[0,...d.map($=>$.y+$.h+h)].sort(($,R)=>$-R);let I=null;e:for(const $ of A)for(const R of M){if(R>=_)break;if(!p($,R,k,E)){I={x:$,y:R};break e}}if(I){const $=I.x-C,R=I.y-_;for(const L of x){const O=l(L.id);n.set(L.id,{x:O.x+$,y:O.y+R})}m.push(y)}for(const $ of x){const R=l($.id),{w:L,h:O}=u($.id);d.push({x:R.x,y:R.y,w:L,h:O})}}return m}function ZL(e,n,i,s,o,u=!1){const d=Cs+Xu+1,h=8,p=1.75,m=200,y=.7,x=.01,C=I=>{const $=s.get(I);return{w:($==null?void 0:$.width)??Ai,h:($==null?void 0:$.height)??Ns}},_=I=>i.get(I)??n.get(I),S=new Map;for(const I of e){if(!_(I.id))continue;const $=Qu(I),R=S.get($);R?R.push(I):S.set($,[I])}const b=[],k=new Set,E=new Set;for(const I of[...S.keys()].sort()){const $=S.get(I);let R=1/0,L=1/0,O=-1/0,Q=-1/0,V=!1;for(const ne of $){const X=_(ne.id),{w:F,h:W}=C(ne.id);R=Math.min(R,X.x),L=Math.min(L,X.y),O=Math.max(O,X.x+F),Q=Math.max(Q,X.y+W),i.has(ne.id)&&(V=!0)}const j=O-R,Y=Q-L;E.add(I);const U=o.get(I);U&&(j>U.w+h||Y>U.h+h)&&k.add(I),o.set(I,{w:j,h:Y}),b.push({sid:I,members:$.map(ne=>ne.id),x:R,y:L,w:j,h:Y,anchored:V,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 N=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 $=new Map,R=new Map;let L=0;for(let O=0;O<b.length;O++)for(let Q=O+1;Q<b.length;Q++){const V=b[O],j=b[Q];if(V.anchored&&j.anchored)continue;const Y=V.x+V.w/2,U=V.y+V.h/2,ne=j.x+j.w/2,X=j.y+j.h/2,F=(V.w+j.w)/2+61-Math.abs(Y-ne),W=(V.h+j.h)/2+d-Math.abs(U-X);if(F<=0||W<=0)continue;const P=(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?V.sid<j.sid?-1:1:Math.sign(Ye-Qe);return et(V,Ze)||et(j,-Ze)?Ze:Be&&(et(V,-Ze)||et(j,Ze))?-Ze:0},z=ae(Y,ne,P),G=ae(U,X,B),J=z!==0,se=G!==0;if(!J&&!se)continue;const ue=J&&(!se||F*p<W),[he,ge,Me,Fe]=ue?[z,F,$,P]:[G,W,R,B],Re=Fe(V,he),Pe=Fe(j,-he),be=V.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(V.sid,(Me.get(V.sid)??0)+he*qe*ve),Me.set(j.sid,(Me.get(j.sid)??0)-he*qe*ye),L+=qe}for(const O of b)O.anchored||(O.x=Math.max(0,O.x+($.get(O.sid)??0)),O.y=Math.max(0,O.y+(R.get(O.sid)??0)));if(L<x)break}const M=[];for(const I of b){const $=I.x-N.get(I.sid),R=I.y-A.get(I.sid);if(!(Math.abs($)<1&&Math.abs(R)<1)){for(const L of I.members){if(i.has(L))continue;const O=n.get(L);O&&n.set(L,{x:O.x+$,y:O.y+R})}M.push(I.sid)}}return M}const JL=600;function jg(e,n){return!(e.exitAt!=null&&n-e.exitAt>JL||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function e$(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 t$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const n$={agent:yP,sessionGroup:RP},r$=420,lu=18,i$=9e4,s$=200,o$=5*6e4,a$=6,u$=2*6e4,yv="agent-dag.layout",wv="agent-dag.viewport",nC="agent-dag.summariesDismissed",rC="agent-dag.sessionListOpen",iC="agent-dag.detailOpen",sC="agent-dag.usagePanelOpen",xk="agent-dag.accountsPanelOpen";function l$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(rC)==="1"}catch{return!1}}function c$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(rC,e?"1":"0")}catch{}}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!0;const e=window.localStorage.getItem(sC);try{return e===null?!0:e==="1"}catch{return!0}}function p$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(sC,e?"1":"0")}catch{}}function m$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(nC);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 _k(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(nC,JSON.stringify(i))}catch{}}function g$(){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 v$(){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 y$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(wv,JSON.stringify(e))}catch{}}function Sk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(yv)}catch{}try{window.localStorage.removeItem(wv)}catch{}}}function w$(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"},x$={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 oC(e){return e.startsWith("mcp__")?"mcp":x$[e]??"other"}function aC(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 _$(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 S$(e,n,i,s,o,u,l,c,d,h,p,m,y,x,C,_,S,b){const k=[],E=[],N=new Set;if(u)for(const R of e.agents.values())aC(R,u)&&N.add(R.id);for(const R of e.agents.values()){if(!S.has(R.id))continue;const L=u?!N.has(R.id):!1,O=R.exitAt!=null,Q=_!=null&&!_.has(R.id),V=[L?"rf-dim":"",O?"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:V,...j?{width:j.width,height:j.height}:null}),R.parentId&&S.has(R.parentId)){const Y=Zg(R.sessionId),U=R.state==="active"?`hsl(${Y} 80% 72%)`:`hsl(${Y} 50% 55%)`,ne=u&&!N.has(R.id)&&!N.has(R.parentId),X=O,F=C.size>0&&(C.has(R.id)||C.has(R.parentId)),W=_!=null&&!_.has(R.id)&&!_.has(R.parentId),P=R.state==="active"?2:1.5,B=F?P+1.5:P,ae=ne||X?.2:W?.12:1,z=[X?"rf-edge-exiting":"",F?"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"||F)&&!ne&&!X,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=KL(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);QL(k,m,o,l,new Set(A.map(L=>L.id)))}XL(k,m,o,l),x.current=y}const M=ZL(k,m,o,l,c,!h||p);M.length>0&&d(M);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 $=!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),$=!0),I.push({...R,position:L})}return $&&(x.current=""),{nodes:I,edges:E}}function b$(){return v.jsx(Xg,{children:v.jsx(k$,{})})}function k$(){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),[C,_]=q.useState(null),S=q.useCallback(Z=>_(Z),[]),b=q.useRef(m$()),[k,E]=q.useState(l$);q.useEffect(()=>{c$(k)},[k]);const[N,A]=q.useState(f$);q.useEffect(()=>{d$(N)},[N]);const[M,I]=q.useState(h$);q.useEffect(()=>{p$(M)},[M]);const[$,R]=q.useState(()=>{try{const Z=window.localStorage.getItem(xk);return Z===null?!0:Z==="1"}catch{return!0}});q.useEffect(()=>{try{window.localStorage.setItem(xk,$?"1":"0")}catch{}},[$]);const[L,O]=q.useState(null),[Q,V]=q.useState(!1),[j,Y]=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&&(O(Z.enabled===!0),Y((Z.foreign??[]).filter(te=>te.worksHere).length),ne(typeof Z.parked=="number"?Z.parked:0))}).catch(()=>{})},[]);const X=q.useCallback(async()=>{V(!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&&O(te.enabled===!0),fetch("/api/sound-hook").then(ce=>ce.ok?ce.json():null).then(ce=>{ce!=null&&ce.ok&&(Y((ce.foreign??[]).filter(me=>me.worksHere).length),ne(typeof ce.parked=="number"?ce.parked:0))}).catch(()=>{})}catch{}finally{V(!1)}},[L]),F=q.useCallback(()=>{E(Z=>(Z||R(!1),!Z))},[]),W=q.useCallback(()=>{R(Z=>(Z||E(!1),!Z))},[]),[P,B]=q.useState(!1),[ae,z]=q.useState(0),G=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(g$()).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(()=>v$())[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=nP(n.current,te,i$);eP(n.current,te,s$,o$)&&(ce=!0),tP(n.current,te,a$,u$)&&(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=_$(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(()=>e$(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),r$+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(()=>S$(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=G.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())aC(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(oC(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="",Sk(),m(),s()},[s,m]),$s=q.useCallback(()=>{Oe.current.clear(),Nt.current.clear(),Pn.current="",Sk(),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")&&F(),(te.key==="h"||te.key==="H")&&B(we=>!we),(te.key==="u"||te.key==="U")&&I(we=>!we),(te.key==="a"||te.key==="A")&&W(),(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.0"]})]}),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:t$(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 wP({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return v.jsx("span",{className:`state-pill state-${e}`,children:n})}function xP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function _P({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 C=23-Math.floor(x/2500);C>=0&&C<24&&(u[C]+=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 C=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-C,width:Math.max(.5,p-1),height:C,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 SP(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 bP({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:SP(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,kP=12;function EP(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} · ${NP(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 NP(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 CP(){const{x:e,y:n,zoom:i}=BE(),s=zo(),o=Xe(EP,TP);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-kP)*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 TP(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 RP({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 ZE=600,jP=36,Rg=16,AP=60,IP=6,Vw=220,Ww=96,MP=28,PP={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 OP(e){return e.startsWith("mcp__")?"mcp":PP[e]??"other"}const qP={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__")?"🔌":qP[e]??"✨"}const LP={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 JE(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 JE(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 $P(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 DP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),FP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function zP(e,n){return FP.has(e)?Math.max(Ww,34+n.length*7.5):Ww}function BP(e,n){if(!DP.has(e))return null;const i=$P(n);if(!i)return null;const s=JE(i);return s?{emoji:LP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const UP=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 HP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function VP(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 WP(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 GP(e,n){if(!UP.has(e))return null;const i=WP(e,n);if(!i)return null;const s=HP(i);return s?{emoji:e==="LS"?"📂":VP(s),label:s,category:"file",detail:i}:null}const eN={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 tN(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 YP(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 KP(e,n){const i=tN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const u=eN[s.toLowerCase()];return{emoji:(u==null?void 0:u.emoji)??"🔌",label:o,category:"mcp",detail:u?`${u.name} · ${o}`:`${s} · ${o}`}}function XP(e,n){return BP(e,n)??GP(e,n)??KP(e)}const QP={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function ZP(e){const n=tN(e);if(n){const s=eN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:YP(n.server)}}const i=QP[e];return i?{emoji:Gw(e),label:i}:{emoji:Gw(e),label:e}}function JP(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function e3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/ZE)}function t3(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>ZE)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,C=d.x,_=d.y,S=C+y,b=_+x/2;h.forEach((k,E)=>{const N=E*jP,A=C+y+AP,M=_+IP+N,I=e3(k,u,p),$=k.inputPreview??"",R=JP(k),L=I<.999,O=ZP(k.name);l.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:O.label,emoji:O.emoji,status:R,category:OP(k.name),mcpHue:O.hue,inputPreview:$,fade:I,fading:L,worldX:A,worldY:M,anchorX:S,anchorY:b,spawnDx:S-A,spawnDy:b-(M+Rg)});const Q=XP(k.name,k.input);if(Q){const V=zP(k.name,O.label),j=A+V+MP,Y=M,U=A+V,ne=M+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??$,fade:I,fading:L,worldX:j,worldY:Y,anchorX:U,anchorY:ne,spawnDx:U-j,spawnDy:0})}})}return l}function n3({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}=BE(),x=t3(e,n,i,s,o,d),C=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:C.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,k=(_.worldX+6)*y+p,E=(_.worldY+Rg)*y+m,N=S+(k-S)*.55,A=u!=null&&!u.has(_.agentId),M=l!=null&&!l.has(_.agentId),I=_.fade*(A||M?.14:1);return v.jsx("path",{d:`M ${S} ${b} Q ${N} ${b}, ${k} ${E}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:I},`l:${_.id}`)})}),C.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,N=_.inputPreview?`${E} · ${_.inputPreview}`:E,A=h!=null,M=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},I=u!=null&&!u.has(_.agentId),$=l!=null&&!l.has(_.agentId),R=I||$?" 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:M,title:N,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 r3({state:e,sessionId:n,onClose:i}){const s=q.useMemo(()=>s3(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(i3,{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 i3({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 s3(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,C=0;for(const E of s){const N=rn(E.usage,E.model);o.input+=N.input,o.output+=N.output,o.cacheRead+=N.cacheRead,o.cacheWrite+=N.cacheWrite,o.total+=N.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),C=Math.max(C,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,C-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,N)=>N[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 o3(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 a3(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 u3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const u=q.useMemo(()=>o3(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:a3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function pr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function l3({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 c3(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 f3(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?c3(s,l):null,x=s&&o?f3(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 d3=6e4;function h3(){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),d3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>u(!0)}}function p3(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 nN=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/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),nN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>u(!0)}}function g3(){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,nN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function v3({state:e,now:n,onClose:i}){var I,$;const{quota:s,loading:o,refresh:u}=h3(),{data:l,loading:c,refresh:d}=m3(),{data:h}=g3(),[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:C,burnRate:_}=q.useMemo(()=>{const R=new Map,L={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let O=0,Q=0,V=0,j=0;for(const F of e.agents.values()){const W=F.model??"__unknown__",P=rn(F.usage,F.model),B=R.get(W);B?(B.inputTokens+=F.usage.inputTokens,B.outputTokens+=F.usage.outputTokens,B.cacheReadTokens+=F.usage.cacheReadTokens,B.cacheCreateTokens+=F.usage.cacheCreateTokens,B.cost.total+=P.total,B.cost.input+=P.input,B.cost.output+=P.output,B.cost.cacheRead+=P.cacheRead,B.cost.cacheWrite+=P.cacheWrite,B.agentCount++):R.set(W,{model:W,inputTokens:F.usage.inputTokens,outputTokens:F.usage.outputTokens,cacheReadTokens:F.usage.cacheReadTokens,cacheCreateTokens:F.usage.cacheCreateTokens,cost:{...P},agentCount:1}),L.total+=P.total,L.input+=P.input,L.output+=P.output,L.cacheRead+=P.cacheRead,L.cacheWrite+=P.cacheWrite,O+=F.usage.inputTokens,Q+=F.usage.outputTokens,V+=F.usage.cacheReadTokens,j+=F.usage.cacheCreateTokens}const Y=Array.from(R.values()).sort((F,W)=>W.cost.total-F.cost.total);let U=0,ne=0;for(const F of e.agents.values()){if(F.state!=="active")continue;const W=rn(F.usage,F.model);U+=W.total,ne=Math.max(ne,((F.endedAt??n)-F.startedAt)/1e3)}const X=ne>0?ku(U,ne):null;return{byModel:Y,totalCost:L,totalTokens:{in:O,out:Q,cacheR:V,cacheC:j},burnRate:X}},[e,e.lastSeq,n]),S=q.useMemo(()=>{const R=[];for(const L of e.agents.values()){if(L.kind!=="root")continue;let O=rn(L.usage,L.model).total,Q=L.usage.inputTokens,V=L.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==L.sessionId||j.kind==="root"||(O+=rn(j.usage,j.model).total,Q+=j.usage.inputTokens,V+=j.usage.outputTokens);R.push({sessionId:L.sessionId,label:L.label||L.cwdBasename||"session",state:L.state,cost:O,inputTokens:Q,outputTokens:V})}return R.sort((L,O)=>O.cost-L.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=C.in+C.out,E=o||c,N=Math.max((s==null?void 0:s.fetchedAt)??0,(l==null?void 0:l.fetchedAt)??0),A=N>0?(()=>{const R=p-Math.floor(N/1e3);return R<10?"just now":R<60?`${R}s ago`:R<3600?`${Math.floor(R/60)}m ago`:`${Math.floor(R/3600)}h ago`})():null,M=()=>{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:[A&&!E&&v.jsx("span",{className:"up-last-updated",children:A}),v.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:M,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.jsx("h4",{className:"up-section-title",children:"Claude quota"}),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})]}),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)),($=l.extraWindows)==null?void 0:$.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:p3(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(l3,{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(C.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),pr(C.out)]}),C.cacheR>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache r"}),pr(C.cacheR)]}),C.cacheC>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache c"}),pr(C.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(C.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),pr(C.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 y3=15e3,w3=[70,80,85,90,95];function x3(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 Xw(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 _3(e){if(e.event==="switch")return`would switch — ${e.detail??"another account"}`;const i={"below-threshold":"under threshold","no-qualifying-candidate":"no better account","all-exhausted":"every account spent",cooldown:"cooling down","external-engine":"handled elsewhere"}[e.reason??""]??e.reason??"nothing to do";return e.detail?`stays put · ${i}, ${e.detail}`:`stays put · ${i}`}function S3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function b3({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?x3(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 k3({onClose:e}){var I,$,R,L;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(null),[x,C]=q.useState(()=>Math.floor(Date.now()/1e3)),_=q.useRef(null),S=q.useCallback(async(O=!1)=>{try{const[Q,V]=await Promise.all([fetch(`/api/claude-accounts${O?"?refresh=1":""}`),fetch("/api/cswap-auto")]);Q.ok&&i(await Q.json()),V.ok&&o(await V.json())}catch{}},[]),b=q.useCallback(async(O,Q)=>{d(Q),y(null);try{const j=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).json().catch(()=>null);return j!=null&&j.ok||y((j==null?void 0:j.detail)||(j==null?void 0:j.reason)||"command failed"),j}catch{return y("server unreachable"),null}finally{d(null)}},[]);q.useEffect(()=>(S(!0),_.current=window.setInterval(()=>S(!1),y3),()=>{_.current!=null&&window.clearInterval(_.current)}),[S]),q.useEffect(()=>{const O=window.setInterval(()=>C(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(O)},[]);const k=((I=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:I.value)??"90",E=($=n==null?void 0:n.accounts)==null?void 0:$.find(O=>O.active),N=E!=null&&E.lanes.length?Math.max(...E.lanes.map(O=>O.pct)):null,A=N!=null&&N>=Number(k)-15,M=async O=>{p(O),y(null);try{const V=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:O})})).json().catch(()=>null);V!=null&&V.ok||y((V==null?void 0:V.output)||(V==null?void 0:V.reason)||"switch failed"),await S(!0)}catch{y("server unreachable")}finally{p(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:()=>S(!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:[(R=n.accounts)==null?void 0:R.map(O=>v.jsxs("div",{className:`ap-account${O.active?" active":""}${O.disabled?" disabled":""}`,children:[v.jsxs("div",{className:"ap-account-head",children:[v.jsx("span",{className:"ap-num",children:O.num}),O.alias&&v.jsx("span",{className:"ap-alias",children:O.alias}),v.jsx("span",{className:"ap-email",title:O.org??void 0,children:O.email}),O.active?v.jsx("span",{className:"ap-badge-active",children:"● active"}):v.jsx("button",{type:"button",className:"btn ap-switch",disabled:h!=null||O.disabled,onClick:()=>M(O.num),title:O.disabled?"Held out of rotation":`Switch to ${O.alias??O.email}`,children:h===O.num?"…":"switch"})]}),O.lanes.length>0?O.lanes.map(Q=>v.jsx(b3,{lane:Q,nowSec:x},Q.id)):v.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),v.jsxs("div",{className:"ap-meta",children:[O.error&&v.jsx("span",{className:"ap-err",children:S3(O.error)}),O.fetchedAt?v.jsx("span",{className:O.stale?"ap-stale":void 0,children:Xw(O.fetchedAt,x)}):v.jsx("span",{className:"ap-stale",children:"never fetched"}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!O.active&&v.jsx("button",{type:"button",className:"ap-rotate",disabled:c!=null,onClick:()=>b({action:"account",account:O.num,enabled:O.disabled},`rot-${O.num}`).then(()=>S(!0)),title:O.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:O.disabled?"held out":"in rotation"})]})]},O.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("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:c!=null,onClick:()=>b({action:"enable",enabled:!s.enabled},"enable").then(()=>S(!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.":"."]}),v.jsxs("div",{className:"ap-auto-row",children:[v.jsx("span",{className:"ap-auto-key",children:"switch when"}),N!=null&&v.jsxs("span",{className:`ap-auto-now${A?" near":""}`,children:["now ",Math.round(N),"%"]}),v.jsx("span",{className:"ap-field",children:v.jsx("select",{"aria-label":"Switch threshold",value:k,disabled:c!=null,onChange:O=>b({action:"setting",key:"autoswitch.threshold",value:O.target.value},"threshold").then(()=>S(!0)),children:w3.map(O=>v.jsxs("option",{value:O,children:[O,"%"]},O))})})]}),v.jsxs("div",{className:"ap-auto-row",children:[v.jsx("span",{className:"ap-auto-key",children:"switch to"}),v.jsx("span",{className:"ap-field",children:v.jsxs("select",{"aria-label":"Target account strategy",value:((L=s.settings["autoswitch.strategy"])==null?void 0:L.value)??"best",disabled:c!=null,onChange:O=>b({action:"setting",key:"autoswitch.strategy",value:O.target.value},"strategy").then(()=>S(!0)),children:[v.jsx("option",{value:"best",children:"most quota left"}),v.jsx("option",{value:"consume-first",children:"soonest reset"})]})})]}),v.jsxs("div",{className:"ap-auto-foot",children:[v.jsx("button",{type:"button",className:"ap-auto-dry",disabled:c!=null,onClick:async()=>l(await b({action:"preview"},"preview")),title:"Evaluate a switch without performing one",children:c==="preview"?"checking…":"dry run"}),u!=null&&u.ok?v.jsx("span",{className:`ap-auto-result${u.event==="switch"?" would":""}`,children:_3(u)}):s.lastTick?v.jsxs("span",{className:"ap-auto-result",children:["checked ",Xw(s.lastTick.at,x)]}):null]})]}),m&&v.jsx("div",{className:"ap-failure",children:m}),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 Qw(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 E3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const N3=[7,14,30,90];function C3(e){const[n,i]=q.useState(null),[s,o]=q.useState(!1),u=(l=!1)=>{o(!0);const d=`/api/ccusage?since=${E3(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 T3({onClose:e}){var b,k;const[n,i]=q.useState(30),[s,o]=q.useState(null),{data:u,loading:l,reload:c}=C3(n);q.useEffect(()=>{const E=N=>{N.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,N)=>Math.max(E,N.totalCost),0),[d]),{totalCost:p,totalTok:m,inOut:y,cacheRead:x,modelCosts:C}=q.useMemo(()=>{let E=0,N=0,A=0,M=0;const I=new Map;for(const $ of d){E+=$.totalCost,N+=$.totalTokens,A+=$.inputTokens+$.outputTokens,M+=$.cacheReadTokens;for(const R of $.modelBreakdowns)I.set(R.modelName,(I.get(R.modelName)??0)+R.cost)}return{totalCost:E,totalTok:N,inOut:A,cacheRead:M,modelCosts:I}},[d]),_=q.useMemo(()=>Array.from(C.entries()).sort((E,N)=>N[1]-E[1]),[C]),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:N3.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 N=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(N,E.totalCost>0?2:0)}%`},children:E.modelBreakdowns.slice().sort((M,I)=>I.cost-M.cost).map(M=>{const I=E.totalCost>0?M.cost/E.totalCost*100:0;return v.jsx("div",{className:"uh-bar-seg",style:{height:`${I}%`,background:ou(M.modelName)}},M.modelName)})}),v.jsx("span",{className:"uh-bar-label",children:E.period.slice(5)})]},E.period)})}),v.jsx("div",{className:"uh-legend",children:_.map(([E,N])=>v.jsxs("span",{className:"uh-legend-item",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:ou(E)}}),Qw(E)," ",v.jsx("span",{className:"uh-legend-cost",children:He(N)})]},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,N)=>N.cost-E.cost).map(E=>{const N=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)}}),Qw(E.modelName)]}),v.jsx("span",{className:"uh-model-bar",children:v.jsx("span",{className:"uh-model-bar-fill",style:{width:`${N}%`,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,Zw;function R3(){if(Zw)return Wc;Zw=1;function e(){this.__data__=[],this.size=0}return Wc=e,Wc}var Gc,Jw;function Is(){if(Jw)return Gc;Jw=1;function e(n,i){return n===i||n!==n&&i!==i}return Gc=e,Gc}var Yc,ex;function Mu(){if(ex)return Yc;ex=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,tx;function j3(){if(tx)return Kc;tx=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,nx;function A3(){if(nx)return Xc;nx=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,rx;function I3(){if(rx)return Qc;rx=1;var e=Mu();function n(i){return e(this.__data__,i)>-1}return Qc=n,Qc}var Zc,ix;function M3(){if(ix)return Zc;ix=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,sx;function Pu(){if(sx)return Jc;sx=1;var e=R3(),n=j3(),i=A3(),s=I3(),o=M3();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,ox;function P3(){if(ox)return ef;ox=1;var e=Pu();function n(){this.__data__=new e,this.size=0}return ef=n,ef}var tf,ax;function O3(){if(ax)return tf;ax=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return tf=e,tf}var nf,ux;function q3(){if(ux)return nf;ux=1;function e(n){return this.__data__.get(n)}return nf=e,nf}var rf,lx;function L3(){if(lx)return rf;lx=1;function e(n){return this.__data__.has(n)}return rf=e,rf}var sf,cx;function rN(){if(cx)return sf;cx=1;var e=typeof Ya=="object"&&Ya&&Ya.Object===Object&&Ya;return sf=e,sf}var of,fx;function Gn(){if(fx)return of;fx=1;var e=rN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return of=i,of}var af,dx;function Ms(){if(dx)return af;dx=1;var e=Gn(),n=e.Symbol;return af=n,af}var uf,hx;function $3(){if(hx)return uf;hx=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,px;function D3(){if(px)return lf;px=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return lf=i,lf}var cf,mx;function Pi(){if(mx)return cf;mx=1;var e=Ms(),n=$3(),i=D3(),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,gx;function An(){if(gx)return ff;gx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return ff=e,ff}var df,vx;function Uo(){if(vx)return df;vx=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,yx;function F3(){if(yx)return hf;yx=1;var e=Gn(),n=e["__core-js_shared__"];return hf=n,hf}var pf,wx;function z3(){if(wx)return pf;wx=1;var e=F3(),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,xx;function iN(){if(xx)return mf;xx=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,_x;function B3(){if(_x)return gf;_x=1;var e=Uo(),n=z3(),i=An(),s=iN(),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,Sx;function U3(){if(Sx)return vf;Sx=1;function e(n,i){return n==null?void 0:n[i]}return vf=e,vf}var yf,bx;function Oi(){if(bx)return yf;bx=1;var e=B3(),n=U3();function i(s,o){var u=n(s,o);return e(u)?u:void 0}return yf=i,yf}var wf,kx;function tv(){if(kx)return wf;kx=1;var e=Oi(),n=Gn(),i=e(n,"Map");return wf=i,wf}var xf,Ex;function Ou(){if(Ex)return xf;Ex=1;var e=Oi(),n=e(Object,"create");return xf=n,xf}var _f,Nx;function H3(){if(Nx)return _f;Nx=1;var e=Ou();function n(){this.__data__=e?e(null):{},this.size=0}return _f=n,_f}var Sf,Cx;function V3(){if(Cx)return Sf;Cx=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,Tx;function W3(){if(Tx)return bf;Tx=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,Rx;function G3(){if(Rx)return kf;Rx=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,jx;function Y3(){if(jx)return Ef;jx=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,Ax;function K3(){if(Ax)return Nf;Ax=1;var e=H3(),n=V3(),i=W3(),s=G3(),o=Y3();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,Ix;function X3(){if(Ix)return Cf;Ix=1;var e=K3(),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,Mx;function Q3(){if(Mx)return Tf;Mx=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,Px;function qu(){if(Px)return Rf;Px=1;var e=Q3();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,Ox;function Z3(){if(Ox)return jf;Ox=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,qx;function J3(){if(qx)return Af;qx=1;var e=qu();function n(i){return e(this,i).get(i)}return Af=n,Af}var If,Lx;function eO(){if(Lx)return If;Lx=1;var e=qu();function n(i){return e(this,i).has(i)}return If=n,If}var Mf,$x;function tO(){if($x)return Mf;$x=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,Dx;function nv(){if(Dx)return Pf;Dx=1;var e=X3(),n=Z3(),i=J3(),s=eO(),o=tO();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,Fx;function nO(){if(Fx)return Of;Fx=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,zx;function Lu(){if(zx)return qf;zx=1;var e=Pu(),n=P3(),i=O3(),s=q3(),o=L3(),u=nO();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,Bx;function rv(){if(Bx)return Lf;Bx=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,Ux;function sN(){if(Ux)return $f;Ux=1;var e=Oi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return $f=n,$f}var Df,Hx;function $u(){if(Hx)return Df;Hx=1;var e=sN();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,Vx;function Du(){if(Vx)return Ff;Vx=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,Wx;function Ho(){if(Wx)return zf;Wx=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,Gx;function rO(){if(Gx)return Bf;Gx=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,Yx;function rr(){if(Yx)return Uf;Yx=1;function e(n){return n!=null&&typeof n=="object"}return Uf=e,Uf}var Hf,Kx;function iO(){if(Kx)return Hf;Kx=1;var e=Pi(),n=rr(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return Hf=s,Hf}var Vf,Xx;function Vo(){if(Xx)return Vf;Xx=1;var e=iO(),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,Qx;function yt(){if(Qx)return Wf;Qx=1;var e=Array.isArray;return Wf=e,Wf}var Eo={exports:{}},Gf,Zx;function sO(){if(Zx)return Gf;Zx=1;function e(){return!1}return Gf=e,Gf}Eo.exports;var Jx;function Ps(){return Jx||(Jx=1,(function(e,n){var i=Gn(),s=sO(),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,e1;function Fu(){if(e1)return Yf;e1=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,t1;function iv(){if(t1)return Kf;t1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return Kf=n,Kf}var Xf,n1;function oO(){if(n1)return Xf;n1=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]",C="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",N="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",I="[object Uint8Array]",$="[object Uint8ClampedArray]",R="[object Uint16Array]",L="[object Uint32Array]",O={};O[k]=O[E]=O[N]=O[A]=O[M]=O[I]=O[$]=O[R]=O[L]=!0,O[s]=O[o]=O[S]=O[u]=O[b]=O[l]=O[c]=O[d]=O[h]=O[p]=O[m]=O[y]=O[x]=O[C]=O[_]=!1;function Q(V){return i(V)&&n(V.length)&&!!O[e(V)]}return Xf=Q,Xf}var Qf,r1;function zu(){if(r1)return Qf;r1=1;function e(n){return function(i){return n(i)}}return Qf=e,Qf}var No={exports:{}};No.exports;var i1;function sv(){return i1||(i1=1,(function(e,n){var i=rN(),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,s1;function Wo(){if(s1)return Zf;s1=1;var e=oO(),n=zu(),i=sv(),s=i&&i.isTypedArray,o=s?n(s):e;return Zf=o,Zf}var Jf,o1;function oN(){if(o1)return Jf;o1=1;var e=rO(),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),C=!m&&!y&&!x&&u(h),_=m||y||x||C,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")||C&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return Jf=d,Jf}var ed,a1;function Bu(){if(a1)return ed;a1=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,u1;function aN(){if(u1)return td;u1=1;function e(n,i){return function(s){return n(i(s))}}return td=e,td}var nd,l1;function aO(){if(l1)return nd;l1=1;var e=aN(),n=e(Object.keys,Object);return nd=n,nd}var rd,c1;function ov(){if(c1)return rd;c1=1;var e=Bu(),n=aO(),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,f1;function wr(){if(f1)return id;f1=1;var e=Uo(),n=iv();function i(s){return s!=null&&n(s.length)&&!e(s)}return id=i,id}var sd,d1;function ei(){if(d1)return sd;d1=1;var e=oN(),n=ov(),i=wr();function s(o){return i(o)?e(o):n(o)}return sd=s,sd}var od,h1;function uO(){if(h1)return od;h1=1;var e=Ho(),n=ei();function i(s,o){return s&&e(o,n(o),s)}return od=i,od}var ad,p1;function lO(){if(p1)return ad;p1=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,m1;function cO(){if(m1)return ud;m1=1;var e=An(),n=Bu(),i=lO(),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,g1;function qi(){if(g1)return ld;g1=1;var e=oN(),n=cO(),i=wr();function s(o){return i(o)?e(o,!0):n(o)}return ld=s,ld}var cd,v1;function fO(){if(v1)return cd;v1=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 y1;function uN(){return y1||(y1=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,w1;function lN(){if(w1)return fd;w1=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,x1;function cN(){if(x1)return dd;x1=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,_1;function fN(){if(_1)return hd;_1=1;function e(){return[]}return hd=e,hd}var pd,S1;function av(){if(S1)return pd;S1=1;var e=cN(),n=fN(),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,b1;function dO(){if(b1)return md;b1=1;var e=Ho(),n=av();function i(s,o){return e(s,n(s),o)}return md=i,md}var gd,k1;function uv(){if(k1)return gd;k1=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,E1;function Uu(){if(E1)return vd;E1=1;var e=aN(),n=e(Object.getPrototypeOf,Object);return vd=n,vd}var yd,N1;function dN(){if(N1)return yd;N1=1;var e=uv(),n=Uu(),i=av(),s=fN(),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,C1;function hO(){if(C1)return wd;C1=1;var e=Ho(),n=dN();function i(s,o){return e(s,n(s),o)}return wd=i,wd}var xd,T1;function hN(){if(T1)return xd;T1=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,R1;function pN(){if(R1)return _d;R1=1;var e=hN(),n=av(),i=ei();function s(o){return e(o,i,n)}return _d=s,_d}var Sd,j1;function pO(){if(j1)return Sd;j1=1;var e=hN(),n=dN(),i=qi();function s(o){return e(o,i,n)}return Sd=s,Sd}var bd,A1;function mO(){if(A1)return bd;A1=1;var e=Oi(),n=Gn(),i=e(n,"DataView");return bd=i,bd}var kd,I1;function gO(){if(I1)return kd;I1=1;var e=Oi(),n=Gn(),i=e(n,"Promise");return kd=i,kd}var Ed,M1;function mN(){if(M1)return Ed;M1=1;var e=Oi(),n=Gn(),i=e(n,"Set");return Ed=i,Ed}var Nd,P1;function vO(){if(P1)return Nd;P1=1;var e=Oi(),n=Gn(),i=e(n,"WeakMap");return Nd=i,Nd}var Cd,O1;function Os(){if(O1)return Cd;O1=1;var e=mO(),n=tv(),i=gO(),s=mN(),o=vO(),u=Pi(),l=iN(),c="[object Map]",d="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",x=l(e),C=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 N=u(E),A=N==d?E.constructor:void 0,M=A?l(A):"";if(M)switch(M){case x:return y;case C:return c;case _:return h;case S:return p;case b:return m}return N}),Cd=k,Cd}var Td,q1;function yO(){if(q1)return Td;q1=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,L1;function gN(){if(L1)return Rd;L1=1;var e=Gn(),n=e.Uint8Array;return Rd=n,Rd}var jd,$1;function lv(){if($1)return jd;$1=1;var e=gN();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,D1;function wO(){if(D1)return Ad;D1=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,F1;function xO(){if(F1)return Id;F1=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,z1;function _O(){if(z1)return Md;z1=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,B1;function vN(){if(B1)return Pd;B1=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,U1;function SO(){if(U1)return Od;U1=1;var e=lv(),n=wO(),i=xO(),s=_O(),o=vN(),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]",C="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",N="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",I="[object Uint32Array]";function $(R,L,O){var Q=R.constructor;switch(L){case x:return e(R);case u:case l:return new Q(+R);case C:return n(R,O);case _:case S:case b:case k:case E:case N:case A:case M:case I:return o(R,O);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=$,Od}var qd,H1;function yN(){if(H1)return qd;H1=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,V1;function wN(){if(V1)return Ld;V1=1;var e=yN(),n=Uu(),i=Bu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Ld=s,Ld}var $d,W1;function bO(){if(W1)return $d;W1=1;var e=Os(),n=rr(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return $d=s,$d}var Dd,G1;function kO(){if(G1)return Dd;G1=1;var e=bO(),n=zu(),i=sv(),s=i&&i.isMap,o=s?n(s):e;return Dd=o,Dd}var Fd,Y1;function EO(){if(Y1)return Fd;Y1=1;var e=Os(),n=rr(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Fd=s,Fd}var zd,K1;function NO(){if(K1)return zd;K1=1;var e=EO(),n=zu(),i=sv(),s=i&&i.isSet,o=s?n(s):e;return zd=o,zd}var Bd,X1;function xN(){if(X1)return Bd;X1=1;var e=Lu(),n=rv(),i=Du(),s=uO(),o=fO(),u=uN(),l=lN(),c=dO(),d=hO(),h=pN(),p=pO(),m=Os(),y=yO(),x=SO(),C=wN(),_=yt(),S=Ps(),b=kO(),k=An(),E=NO(),N=ei(),A=qi(),M=1,I=2,$=4,R="[object Arguments]",L="[object Array]",O="[object Boolean]",Q="[object Date]",V="[object Error]",j="[object Function]",Y="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",X="[object Object]",F="[object RegExp]",W="[object Set]",P="[object String]",B="[object Symbol]",ae="[object WeakMap]",z="[object ArrayBuffer]",G="[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[G]=be[O]=be[Q]=be[J]=be[se]=be[ue]=be[he]=be[ge]=be[U]=be[ne]=be[X]=be[F]=be[W]=be[P]=be[B]=be[Me]=be[Fe]=be[Re]=be[Pe]=!0,be[V]=be[j]=be[ae]=!1;function Oe(ve,ye,qe,Ye,Qe,et){var Be,Ze=ye&M,At=ye&I,Vt=ye&$;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==Y;if(S(ve))return u(ve,Ze);if(pt==X||pt==R||tt&&!Qe){if(Be=At||tt?{}:C(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:N,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,Q1;function CO(){if(Q1)return Ud;Q1=1;var e=xN(),n=4;function i(s){return e(s,n)}return Ud=i,Ud}var Hd,Z1;function cv(){if(Z1)return Hd;Z1=1;function e(n){return function(){return n}}return Hd=e,Hd}var Vd,J1;function TO(){if(J1)return Vd;J1=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,e_;function fv(){if(e_)return Wd;e_=1;var e=TO(),n=e();return Wd=n,Wd}var Gd,t_;function dv(){if(t_)return Gd;t_=1;var e=fv(),n=ei();function i(s,o){return s&&e(s,o,n)}return Gd=i,Gd}var Yd,n_;function RO(){if(n_)return Yd;n_=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,r_;function Hu(){if(r_)return Kd;r_=1;var e=dv(),n=RO(),i=n(e);return Kd=i,Kd}var Xd,i_;function Li(){if(i_)return Xd;i_=1;function e(n){return n}return Xd=e,Xd}var Qd,s_;function _N(){if(s_)return Qd;s_=1;var e=Li();function n(i){return typeof i=="function"?i:e}return Qd=n,Qd}var Zd,o_;function SN(){if(o_)return Zd;o_=1;var e=rv(),n=Hu(),i=_N(),s=yt();function o(u,l){var c=s(u)?e:n;return c(u,i(l))}return Zd=o,Zd}var Jd,a_;function bN(){return a_||(a_=1,Jd=SN()),Jd}var eh,u_;function jO(){if(u_)return eh;u_=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,l_;function AO(){if(l_)return th;l_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return th=n,th}var nh,c_;function IO(){if(c_)return nh;c_=1;function e(n){return this.__data__.has(n)}return nh=e,nh}var rh,f_;function kN(){if(f_)return rh;f_=1;var e=nv(),n=AO(),i=IO();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,d_;function MO(){if(d_)return ih;d_=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,h_;function EN(){if(h_)return sh;h_=1;function e(n,i){return n.has(i)}return sh=e,sh}var oh,p_;function NN(){if(p_)return oh;p_=1;var e=kN(),n=MO(),i=EN(),s=1,o=2;function u(l,c,d,h,p,m){var y=d&s,x=l.length,C=c.length;if(x!=C&&!(y&&C>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 N=l[b],A=c[b];if(h)var M=y?h(A,N,b,c,l,m):h(N,A,b,l,c,m);if(M!==void 0){if(M)continue;k=!1;break}if(E){if(!n(c,function(I,$){if(!i(E,$)&&(N===I||p(N,I,d,h,m)))return E.push($)})){k=!1;break}}else if(!(N===A||p(N,A,d,h,m))){k=!1;break}}return m.delete(l),m.delete(c),k}return oh=u,oh}var ah,m_;function PO(){if(m_)return ah;m_=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,g_;function hv(){if(g_)return uh;g_=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,v_;function OO(){if(v_)return lh;v_=1;var e=Ms(),n=gN(),i=Is(),s=NN(),o=PO(),u=hv(),l=1,c=2,d="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",C="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,N=E?E.valueOf:void 0;function A(M,I,$,R,L,O,Q){switch($){case k:if(M.byteLength!=I.byteLength||M.byteOffset!=I.byteOffset)return!1;M=M.buffer,I=I.buffer;case b:return!(M.byteLength!=I.byteLength||!O(new n(M),new n(I)));case d:case h:case y:return i(+M,+I);case p:return M.name==I.name&&M.message==I.message;case x:case _:return M==I+"";case m:var V=o;case C:var j=R&l;if(V||(V=u),M.size!=I.size&&!j)return!1;var Y=Q.get(M);if(Y)return Y==I;R|=c,Q.set(M,I);var U=s(V(M),V(I),R,L,O,Q);return Q.delete(M),U;case S:if(N)return N.call(M)==N.call(I)}return!1}return lh=A,lh}var ch,y_;function qO(){if(y_)return ch;y_=1;var e=pN(),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,C=e(l),_=C.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 N=!0;p.set(u,l),p.set(l,u);for(var A=m;++S<x;){b=y[S];var M=u[b],I=l[b];if(d)var $=m?d(I,M,b,l,u,p):d(M,I,b,u,l,p);if(!($===void 0?M===I||h(M,I,c,d,p):$)){N=!1;break}A||(A=b=="constructor")}if(N&&!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)&&(N=!1)}return p.delete(u),p.delete(l),N}return ch=o,ch}var fh,w_;function LO(){if(w_)return fh;w_=1;var e=Lu(),n=NN(),i=OO(),s=qO(),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 C(_,S,b,k,E,N){var A=u(_),M=u(S),I=A?p:o(_),$=M?p:o(S);I=I==h?m:I,$=$==h?m:$;var R=I==m,L=$==m,O=I==$;if(O&&l(_)){if(!l(S))return!1;A=!0,R=!1}if(O&&!R)return N||(N=new e),A||c(_)?n(_,S,b,k,E,N):i(_,S,I,b,k,E,N);if(!(b&d)){var Q=R&&x.call(_,"__wrapped__"),V=L&&x.call(S,"__wrapped__");if(Q||V){var j=Q?_.value():_,Y=V?S.value():S;return N||(N=new e),E(j,Y,b,k,N)}}return O?(N||(N=new e),s(_,S,b,k,E,N)):!1}return fh=C,fh}var dh,x_;function CN(){if(x_)return dh;x_=1;var e=LO(),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,__;function $O(){if(__)return hh;__=1;var e=Lu(),n=CN(),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],C=u[x],_=y[1];if(m&&y[2]){if(C===void 0&&!(x in u))return!1}else{var S=new e;if(d)var b=d(C,_,x,u,l,S);if(!(b===void 0?n(_,C,i|s,d,S):b))return!1}}return!0}return hh=o,hh}var ph,S_;function TN(){if(S_)return ph;S_=1;var e=An();function n(i){return i===i&&!e(i)}return ph=n,ph}var mh,b_;function DO(){if(b_)return mh;b_=1;var e=TN(),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,k_;function RN(){if(k_)return gh;k_=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,E_;function FO(){if(E_)return vh;E_=1;var e=$O(),n=DO(),i=RN();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,N_;function qs(){if(N_)return yh;N_=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,C_;function pv(){if(C_)return wh;C_=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,T_;function zO(){if(T_)return xh;T_=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,R_;function BO(){if(R_)return _h;R_=1;var e=zO(),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,j_;function UO(){if(j_)return Sh;j_=1;var e=BO(),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,A_;function Vu(){if(A_)return bh;A_=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,I_;function HO(){if(I_)return kh;I_=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,M_;function jN(){if(M_)return Eh;M_=1;var e=HO();function n(i){return i==null?"":e(i)}return Eh=n,Eh}var Nh,P_;function Wu(){if(P_)return Nh;P_=1;var e=yt(),n=pv(),i=UO(),s=jN();function o(u,l){return e(u)?u:n(u,l)?[u]:i(s(u))}return Nh=o,Nh}var Ch,O_;function Go(){if(O_)return Ch;O_=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,q_;function Gu(){if(q_)return Th;q_=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,L_;function VO(){if(L_)return Rh;L_=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,$_;function WO(){if($_)return jh;$_=1;function e(n,i){return n!=null&&i in Object(n)}return jh=e,jh}var Ah,D_;function AN(){if(D_)return Ah;D_=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,F_;function IN(){if(F_)return Ih;F_=1;var e=WO(),n=AN();function i(s,o){return s!=null&&n(s,o,e)}return Ih=i,Ih}var Mh,z_;function GO(){if(z_)return Mh;z_=1;var e=CN(),n=VO(),i=IN(),s=pv(),o=TN(),u=RN(),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,B_;function MN(){if(B_)return Ph;B_=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Ph=e,Ph}var Oh,U_;function YO(){if(U_)return Oh;U_=1;var e=Gu();function n(i){return function(s){return e(s,i)}}return Oh=n,Oh}var qh,H_;function KO(){if(H_)return qh;H_=1;var e=MN(),n=YO(),i=pv(),s=Go();function o(u){return i(u)?e(s(u)):n(u)}return qh=o,qh}var Lh,V_;function xr(){if(V_)return Lh;V_=1;var e=FO(),n=GO(),i=Li(),s=yt(),o=KO();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,W_;function PN(){if(W_)return $h;W_=1;var e=cN(),n=jO(),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,G_;function XO(){if(G_)return Dh;G_=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,Y_;function ON(){if(Y_)return Fh;Y_=1;var e=XO(),n=AN();function i(s,o){return s!=null&&n(s,o,e)}return Fh=i,Fh}var zh,K_;function QO(){if(K_)return zh;K_=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 C=n(x);if(C==d||C==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,X_;function qN(){if(X_)return Bh;X_=1;function e(n){return n===void 0}return Bh=e,Bh}var Uh,Q_;function LN(){if(Q_)return Uh;Q_=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,Z_;function $N(){if(Z_)return Hh;Z_=1;var e=Vu(),n=xr(),i=LN(),s=yt();function o(u,l){var c=s(u)?e:i;return c(u,n(l,3))}return Hh=o,Hh}var Vh,J_;function ZO(){if(J_)return Vh;J_=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,eS;function JO(){if(eS)return Wh;eS=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,tS;function DN(){if(tS)return Gh;tS=1;var e=ZO(),n=Hu(),i=xr(),s=JO(),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,nS;function eq(){if(nS)return Yh;nS=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,rS;function tq(){if(rS)return Kh;rS=1;var e=MN(),n=e("length");return Kh=n,Kh}var Xh,iS;function nq(){if(iS)return Xh;iS=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,sS;function rq(){if(sS)return Qh;sS=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",C=h+"?",_="["+u+"]?",S="(?:"+x+"(?:"+[p,m,y].join("|")+")"+_+C+")*",b=_+C+S,k="(?:"+[p+c+"?",c,m,y,l].join("|")+")",E=RegExp(d+"(?="+d+")|"+k+b,"g");function N(A){for(var M=E.lastIndex=0;E.test(A);)++M;return M}return Qh=N,Qh}var Zh,oS;function iq(){if(oS)return Zh;oS=1;var e=tq(),n=nq(),i=rq();function s(o){return n(o)?i(o):e(o)}return Zh=s,Zh}var Jh,aS;function sq(){if(aS)return Jh;aS=1;var e=ov(),n=Os(),i=wr(),s=eq(),o=iq(),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,uS;function oq(){if(uS)return ep;uS=1;var e=rv(),n=yN(),i=dv(),s=xr(),o=Uu(),u=yt(),l=Ps(),c=Uo(),d=An(),h=Wo();function p(m,y,x){var C=u(m),_=C||l(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=C?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,lS;function aq(){if(lS)return tp;lS=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,cS;function mv(){if(cS)return np;cS=1;var e=uv(),n=aq();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,fS;function uq(){if(fS)return rp;fS=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,dS;function FN(){if(dS)return ip;dS=1;var e=uq(),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,hS;function lq(){if(hS)return sp;hS=1;var e=cv(),n=sN(),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,pS;function cq(){if(pS)return op;pS=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,mS;function zN(){if(mS)return ap;mS=1;var e=lq(),n=cq(),i=n(e);return ap=i,ap}var up,gS;function Yu(){if(gS)return up;gS=1;var e=Li(),n=FN(),i=zN();function s(o,u){return i(n(o,u,e),o+"")}return up=s,up}var lp,vS;function BN(){if(vS)return lp;vS=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,yS;function fq(){if(yS)return cp;yS=1;function e(n){return n!==n}return cp=e,cp}var fp,wS;function dq(){if(wS)return fp;wS=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,xS;function hq(){if(xS)return dp;xS=1;var e=BN(),n=fq(),i=dq();function s(o,u,l){return u===u?i(o,u,l):e(o,n,l)}return dp=s,dp}var hp,_S;function pq(){if(_S)return hp;_S=1;var e=hq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return hp=n,hp}var pp,SS;function mq(){if(SS)return pp;SS=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,bS;function gq(){if(bS)return mp;bS=1;function e(){}return mp=e,mp}var gp,kS;function vq(){if(kS)return gp;kS=1;var e=mN(),n=gq(),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,ES;function yq(){if(ES)return vp;ES=1;var e=kN(),n=pq(),i=mq(),s=EN(),o=vq(),u=hv(),l=200;function c(d,h,p){var m=-1,y=n,x=d.length,C=!0,_=[],S=_;if(p)C=!1,y=i;else if(x>=l){var b=h?null:o(d);if(b)return u(b);C=!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,C&&E===E){for(var N=S.length;N--;)if(S[N]===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,NS;function UN(){if(NS)return yp;NS=1;var e=wr(),n=rr();function i(s){return n(s)&&e(s)}return yp=i,yp}var wp,CS;function wq(){if(CS)return wp;CS=1;var e=mv(),n=Yu(),i=yq(),s=UN(),o=n(function(u){return i(e(u,1,s,!0))});return wp=o,wp}var xp,TS;function xq(){if(TS)return xp;TS=1;var e=Vu();function n(i,s){return e(s,function(o){return i[o]})}return xp=n,xp}var _p,RS;function HN(){if(RS)return _p;RS=1;var e=xq(),n=ei();function i(s){return s==null?[]:e(s,n(s))}return _p=i,_p}var Sp,jS;function In(){if(jS)return Sp;jS=1;var e;if(typeof ev=="function")try{e={clone:CO(),constant:cv(),each:bN(),filter:PN(),has:ON(),isArray:yt(),isEmpty:QO(),isFunction:Uo(),isUndefined:qN(),keys:ei(),map:$N(),reduce:DN(),size:sq(),transform:oq(),union:wq(),values:HN()}}catch{}return e||(e=window._),Sp=e,Sp}var bp,AS;function gv(){if(AS)return bp;AS=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(C){y.length>1?x.setNode(C,m):x.setNode(C)}),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 C(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:C(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,C(_))}),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(C,_){return x.length>1?y.setEdge(C,_,m):y.setEdge(C,_),_}),this},o.prototype.setEdge=function(){var p,m,y,x,C=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],C=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],C=!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 C&&(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]=C?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),C=this._edgeObjs[x];return C&&(p=C.v,m=C.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(C){return C.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(C){return C.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 C=""+m,_=""+y;if(!p&&C>_){var S=C;C=_,_=S}return C+s+_+s+(e.isUndefined(x)?n:x)}function d(p,m,y,x){var C=""+m,_=""+y;if(!p&&C>_){var S=C;C=_,_=S}var b={v:C,w:_};return x&&(b.name=x),b}function h(p,m){return c(p,m.v,m.w,m.name)}return bp}var kp,IS;function _q(){return IS||(IS=1,kp="2.1.8"),kp}var Ep,MS;function Sq(){return MS||(MS=1,Ep={Graph:gv(),version:_q()}),Ep}var Np,PS;function bq(){if(PS)return Np;PS=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,OS;function kq(){if(OS)return Cp;OS=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,qS;function VN(){if(qS)return Tp;qS=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,LS;function WN(){if(LS)return Rp;LS=1;var e=In(),n=VN();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(C){var _=C.v!==m?C.v:C.w,S=h[_],b=c(C),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+C+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=m,p.decrease(_,k))};for(u.nodes().forEach(function(C){var _=C===l?0:Number.POSITIVE_INFINITY;h[C]={distance:_},p.add(C,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)d(m).forEach(x);return h}return Rp}var jp,$S;function Eq(){if($S)return jp;$S=1;var e=WN(),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,DS;function GN(){if(DS)return Ap;DS=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,FS;function Nq(){if(FS)return Ip;FS=1;var e=In(),n=GN();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,zS;function Cq(){if(zS)return Mp;zS=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 C=y[h],_=p[x],S=y[x],b=C.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Mp}var Pp,BS;function YN(){if(BS)return Pp;BS=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,US;function Tq(){if(US)return Op;US=1;var e=YN();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,HS;function KN(){if(HS)return qp;HS=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,VS;function Rq(){if(VS)return Lp;VS=1;var e=KN();Lp=n;function n(i,s){return e(i,s,"post")}return Lp}var $p,WS;function jq(){if(WS)return $p;WS=1;var e=KN();$p=n;function n(i,s){return e(i,s,"pre")}return $p}var Dp,GS;function Aq(){if(GS)return Dp;GS=1;var e=In(),n=gv(),i=VN();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,C=d.priority(x);if(C!==void 0){var _=u(y);_<C&&(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,YS;function Iq(){return YS||(YS=1,Fp={components:kq(),dijkstra:WN(),dijkstraAll:Eq(),findCycles:Nq(),floydWarshall:Cq(),isAcyclic:Tq(),postorder:Rq(),preorder:jq(),prim:Aq(),tarjan:GN(),topsort:YN()}),Fp}var zp,KS;function Mq(){if(KS)return zp;KS=1;var e=Sq();return zp={Graph:e.Graph,json:bq(),alg:Iq(),version:e.version},zp}var Bp,XS;function Vn(){if(XS)return Bp;XS=1;var e;if(typeof ev=="function")try{e=Mq()}catch{}return e||(e=window.graphlib),Bp=e,Bp}var Up,QS;function Pq(){if(QS)return Up;QS=1;var e=xN(),n=1,i=4;function s(o){return e(o,n|i)}return Up=s,Up}var Hp,ZS;function Ku(){if(ZS)return Hp;ZS=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,JS;function Oq(){if(JS)return Vp;JS=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),C=-1,_=x.length;++C<_;){var S=x[C],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,eb;function qq(){if(eb)return Wp;eb=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,tb;function Lq(){if(tb)return Gp;tb=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,nb;function $q(){if(nb)return Yp;nb=1;var e=Lq(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return Yp=i,Yp}var Kp,rb;function Dq(){if(rb)return Kp;rb=1;var e=$q(),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,ib;function XN(){if(ib)return Xp;ib=1;var e=Dq(),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,sb;function Fq(){if(sb)return Qp;sb=1;var e=XN();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return Qp=n,Qp}var Zp,ob;function zq(){if(ob)return Zp;ob=1;var e=BN(),n=xr(),i=Fq(),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,ab;function Bq(){if(ab)return Jp;ab=1;var e=qq(),n=zq(),i=e(n);return Jp=i,Jp}var em,ub;function QN(){if(ub)return em;ub=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,lb;function Uq(){if(lb)return tm;lb=1;var e=fv(),n=_N(),i=qi();function s(o,u){return o==null?o:e(o,n(u),i)}return tm=s,tm}var nm,cb;function Hq(){if(cb)return nm;cb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return nm=e,nm}var rm,fb;function Vq(){if(fb)return rm;fb=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,db;function vv(){if(db)return im;db=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,hb;function Wq(){if(hb)return sm;hb=1;function e(n,i){return n>i}return sm=e,sm}var om,pb;function Gq(){if(pb)return om;pb=1;var e=vv(),n=Wq(),i=Li();function s(o){return o&&o.length?e(o,i,n):void 0}return om=s,om}var am,mb;function ZN(){if(mb)return am;mb=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,gb;function Yq(){if(gb)return um;gb=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,vb;function JN(){if(vb)return lm;vb=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return lm=e,lm}var cm,yb;function Kq(){if(yb)return cm;yb=1;var e=Ho(),n=qi();function i(s){return e(s,n(s))}return cm=i,cm}var fm,wb;function Xq(){if(wb)return fm;wb=1;var e=ZN(),n=uN(),i=vN(),s=lN(),o=wN(),u=Vo(),l=yt(),c=UN(),d=Ps(),h=Uo(),p=An(),m=Yq(),y=Wo(),x=JN(),C=Kq();function _(S,b,k,E,N,A,M){var I=x(S,k),$=x(b,k),R=M.get($);if(R){e(S,k,R);return}var L=A?A(I,$,k+"",S,b,M):void 0,O=L===void 0;if(O){var Q=l($),V=!Q&&d($),j=!Q&&!V&&y($);L=$,Q||V||j?l(I)?L=I:c(I)?L=s(I):V?(O=!1,L=n($,!0)):j?(O=!1,L=i($,!0)):L=[]:m($)||u($)?(L=I,u(I)?L=C(I):(!p(I)||h(I))&&(L=o($))):O=!1}O&&(M.set($,L),N(L,$,E,A,M),M.delete($)),e(S,k,L)}return fm=_,fm}var dm,xb;function Qq(){if(xb)return dm;xb=1;var e=Lu(),n=ZN(),i=fv(),s=Xq(),o=An(),u=qi(),l=JN();function c(d,h,p,m,y){d!==h&&i(h,function(x,C){if(y||(y=new e),o(x))s(d,h,C,p,c,m,y);else{var _=m?m(l(d,C),x,C+"",d,h,y):void 0;_===void 0&&(_=x),n(d,C,_)}},u)}return dm=c,dm}var hm,_b;function Zq(){if(_b)return hm;_b=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,Sb;function Jq(){if(Sb)return pm;Sb=1;var e=Qq(),n=Zq(),i=n(function(s,o,u){e(s,o,u)});return pm=i,pm}var mm,bb;function eC(){if(bb)return mm;bb=1;function e(n,i){return n<i}return mm=e,mm}var gm,kb;function eL(){if(kb)return gm;kb=1;var e=vv(),n=eC(),i=Li();function s(o){return o&&o.length?e(o,i,n):void 0}return gm=s,gm}var vm,Eb;function tL(){if(Eb)return vm;Eb=1;var e=vv(),n=xr(),i=eC();function s(o,u){return o&&o.length?e(o,n(u,2),i):void 0}return vm=s,vm}var ym,Nb;function nL(){if(Nb)return ym;Nb=1;var e=Gn(),n=function(){return e.Date.now()};return ym=n,ym}var wm,Cb;function rL(){if(Cb)return wm;Cb=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 C=o(c[p]),_=d;if(C==="__proto__"||C==="constructor"||C==="prototype")return l;if(p!=y){var S=x[C];_=h?h(S,C,x):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(x,C,_),x=x[C]}return l}return wm=u,wm}var xm,Tb;function iL(){if(Tb)return xm;Tb=1;var e=Gu(),n=rL(),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,Rb;function sL(){if(Rb)return _m;Rb=1;var e=iL(),n=IN();function i(s,o){return e(s,o,function(u,l){return n(s,l)})}return _m=i,_m}var Sm,jb;function oL(){if(jb)return Sm;jb=1;var e=QN(),n=FN(),i=zN();function s(o){return i(n(o,void 0,e),o+"")}return Sm=s,Sm}var bm,Ab;function aL(){if(Ab)return bm;Ab=1;var e=sL(),n=oL(),i=n(function(s,o){return s==null?{}:e(s,o)});return bm=i,bm}var km,Ib;function uL(){if(Ib)return km;Ib=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,Mb;function lL(){if(Mb)return Em;Mb=1;var e=uL(),n=Ku(),i=XN();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,Pb;function cL(){if(Pb)return Nm;Pb=1;var e=lL(),n=e();return Nm=n,Nm}var Cm,Ob;function fL(){if(Ob)return Cm;Ob=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,qb;function dL(){if(qb)return Tm;qb=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,Lb;function hL(){if(Lb)return Rm;Lb=1;var e=dL();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,$b;function pL(){if($b)return jm;$b=1;var e=Vu(),n=Gu(),i=xr(),s=LN(),o=fL(),u=zu(),l=hL(),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 C=s(p,function(_,S,b){var k=e(m,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(C,function(_,S){return l(_,S,y)})}return jm=h,jm}var Am,Db;function mL(){if(Db)return Am;Db=1;var e=mv(),n=pL(),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,Fb;function gL(){if(Fb)return Im;Fb=1;var e=jN(),n=0;function i(s){var o=++n;return e(s)+o}return Im=i,Im}var Mm,zb;function vL(){if(zb)return Mm;zb=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,Bb;function yL(){if(Bb)return Pm;Bb=1;var e=Du(),n=vL();function i(s,o){return n(s||[],o||[],e)}return Pm=i,Pm}var Om,Ub;function ut(){if(Ub)return Om;Ub=1;var e;if(typeof ev=="function")try{e={cloneDeep:Pq(),constant:cv(),defaults:Oq(),each:bN(),filter:PN(),find:Bq(),flatten:QN(),forEach:SN(),forIn:Uq(),has:ON(),isUndefined:qN(),last:Hq(),map:$N(),mapValues:Vq(),max:Gq(),merge:Jq(),min:eL(),minBy:tL(),now:nL(),pick:aL(),range:cL(),reduce:DN(),sortBy:mL(),uniqueId:gL(),values:HN(),zipObject:yL()}}catch{}return e||(e=window._),Om=e,Om}var qm,Hb;function wL(){if(Hb)return qm;Hb=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,Vb;function xL(){if(Vb)return Lm;Vb=1;var e=ut(),n=Vn().Graph,i=wL();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],C=p[0],_;h.nodeCount();){for(;_=C.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 C=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&C.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),C}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 C=e.range(x+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){d(C,_,m.node(S))}),{graph:m,buckets:C,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,Wb;function _L(){if(Wb)return $m;Wb=1;var e=ut(),n=xL();$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,Gb;function sn(){if(Gb)return Dm;Gb=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:C,notime:_};function i(S,b,k,E){var N;do N=e.uniqueId(E);while(S.hasNode(N));return k.dummy=b,S.setNode(N,k),N}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},N=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+N.weight,minlen:Math.max(E.minlen,N.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(N){E[N.w]=(E[N.w]||0)+S.edge(N).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(N){E[N.v]=(E[N.v]||0)+S.edge(N).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,N=b.x-k,A=b.y-E,M=S.width/2,I=S.height/2;if(!N&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var $,R;return Math.abs(A)*M>Math.abs(N)*I?(A<0&&(I=-I),$=I*N/A,R=I):(N<0&&(M=-M),$=M,R=M*A/N),{x:k+$,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),N=E.rank;e.isUndefined(N)||(b[N][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 M=S.node(A).rank-b;k[M]||(k[M]=[]),k[M].push(A)});var E=0,N=S.graph().nodeRankFactor;e.forEach(k,function(A,M){e.isUndefined(A)&&M%N!==0?--E:E&&e.forEach(A,function(I){S.node(I).rank+=E})})}function m(S,b,k,E){var N={width:0,height:0};return arguments.length>=4&&(N.rank=k,N.order=E),i(S,"border",N,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 C(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,Yb;function SL(){if(Yb)return Fm;Yb=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 C,_,S;for(S=0,++d;d<p;++S,++d)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:l,rank:d},C=n.addDummyNode(u,"edge",_,"_d"),d===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),u.setEdge(c,C,{weight:y.weight},m),S===0&&u.graph().dummyChains.push(C),c=C;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,Kb;function Eu(){if(Kb)return zm;Kb=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,Xb;function tC(){if(Xb)return Bm;Xb=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,Qb;function bL(){if(Qb)return Um;Qb=1;var e=ut(),n=tC(),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=C,c.exchangeEdges=_;function c(E){E=l(E),s(E);var N=n(E);m(N),d(N,E);for(var A,M;A=x(N);)M=C(N,E,A),_(N,E,A,M)}function d(E,N){var A=u(E,E.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(M){h(E,N,M)})}function h(E,N,A){var M=E.node(A),I=M.parent;E.edge(A,I).cutvalue=p(E,N,A)}function p(E,N,A){var M=E.node(A),I=M.parent,$=!0,R=N.edge(A,I),L=0;return R||($=!1,R=N.edge(I,A)),L=R.weight,e.forEach(N.nodeEdges(A),function(O){var Q=O.v===A,V=Q?O.w:O.v;if(V!==I){var j=Q===$,Y=N.edge(O).weight;if(L+=j?Y:-Y,b(E,A,V)){var U=E.edge(A,V).cutvalue;L+=j?-U:U}}}),L}function m(E,N){arguments.length<2&&(N=E.nodes()[0]),y(E,{},1,N)}function y(E,N,A,M,I){var $=A,R=E.node(M);return N[M]=!0,e.forEach(E.neighbors(M),function(L){e.has(N,L)||(A=y(E,N,A,L,M))}),R.low=$,R.lim=A++,I?R.parent=I:delete R.parent,A}function x(E){return e.find(E.edges(),function(N){return E.edge(N).cutvalue<0})}function C(E,N,A){var M=A.v,I=A.w;N.hasEdge(M,I)||(M=A.w,I=A.v);var $=E.node(M),R=E.node(I),L=$,O=!1;$.lim>R.lim&&(L=R,O=!0);var Q=e.filter(N.edges(),function(V){return O===k(E,E.node(V.v),L)&&O!==k(E,E.node(V.w),L)});return e.minBy(Q,function(V){return i(N,V)})}function _(E,N,A,M){var I=A.v,$=A.w;E.removeEdge(I,$),E.setEdge(M.v,M.w,{}),m(E),d(E,N),S(E,N)}function S(E,N){var A=e.find(E.nodes(),function(I){return!N.node(I).parent}),M=o(E,A);M=M.slice(1),e.forEach(M,function(I){var $=E.node(I).parent,R=N.edge(I,$),L=!1;R||(R=N.edge($,I),L=!0),N.node(I).rank=N.node($).rank+(L?R.minlen:-R.minlen)})}function b(E,N,A){return E.hasEdge(N,A)}function k(E,N,A){return A.low<=N.lim&&N.lim<=A.lim}return Um}var Hm,Zb;function kL(){if(Zb)return Hm;Zb=1;var e=Eu(),n=e.longestPath,i=tC(),s=bL();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,Jb;function EL(){if(Jb)return Vm;Jb=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],C=!0;l!==d.w;){if(c=o.node(l),C){for(;(x=p[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(C=!1)}if(!C){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,ek;function NL(){if(ek)return Wm;ek=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 C=c.children(x);if(!C.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(C,function(k){s(c,d,h,p,m,y,k);var E=c.node(k),N=E.borderTop?E.borderTop:k,A=E.borderBottom?E.borderBottom:k,M=E.borderTop?p:2*p,I=N!==A?1:m-y[x]+1;c.setEdge(_,N,{weight:M,minlen:I,nestingEdge:!0}),c.setEdge(A,S,{weight:M,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,tk;function CL(){if(tk)return Gm;tk=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,nk;function TL(){if(nk)return Ym;nk=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,rk;function RL(){if(rk)return Km;rk=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,ik;function jL(){if(ik)return Xm;ik=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 C=0;x>0;)x%2&&(C+=p[x+1]),x=x-1>>1,p[x]+=y.weight;m+=y.weight*C})),m}return Xm}var Qm,sk;function AL(){if(sk)return Qm;sk=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,ok;function IL(){if(ok)return Zm;ok=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,ak;function ML(){if(ak)return Jm;ak=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 C={vs:e.flatten(p,!0)};return y&&(C.barycenter=m/y,C.weight=y),C}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,uk;function PL(){if(uk)return eg;uk=1;var e=ut(),n=AL(),i=IL(),s=ML();eg=o;function o(c,d,h,p){var m=c.children(d),y=c.node(d),x=y?y.borderLeft:void 0,C=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(A){return A!==x&&A!==C}));var S=n(c,m);e.forEach(S,function(A){if(c.children(A.v).length){var M=o(c,A.v,h,p);_[A.v]=M,e.has(M,"barycenter")&&l(A,M)}});var b=i(S,h);u(b,_);var k=s(b,p);if(x&&(k.vs=e.flatten([x,k.vs,C],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[0]),N=c.node(c.predecessors(C)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+N.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,lk;function OL(){if(lk)return tg;lk=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,C=d.edge(x,h),_=e.isUndefined(C)?0:C.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,ck;function qL(){if(ck)return ng;ck=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,fk;function LL(){if(fk)return rg;fk=1;var e=ut(),n=RL(),i=jL(),s=PL(),o=OL(),u=qL(),l=Vn().Graph,c=sn();rg=d;function d(y){var x=c.maxRank(y),C=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,N=0;N<4;++E,++N){p(E%2?C:_,E%4>=2),S=c.buildLayerMatrix(y);var A=i(y,S);A<b&&(N=0,k=e.cloneDeep(S),b=A)}m(y,k)}function h(y,x,C){return e.map(x,function(_){return o(y,_,C)})}function p(y,x){var C=new l;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,C,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),u(_,C,b.vs)})}function m(y,x){e.forEach(x,function(C){e.forEach(C,function(_,S){y.node(_).order=S})})}return rg}var ig,dk;function $L(){if(dk)return ig;dk=1;var e=ut(),n=Vn().Graph,i=sn();ig={positionX:C,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 N(A,M){var I=0,$=0,R=A.length,L=e.last(M);return e.forEach(M,function(O,Q){var V=u(b,O),j=V?b.node(V).order:R;(V||O===L)&&(e.forEach(M.slice($,Q+1),function(Y){e.forEach(b.predecessors(Y),function(U){var ne=b.node(U),X=ne.order;(X<I||j<X)&&!(ne.dummy&&b.node(Y).dummy)&&l(E,U,Y)})}),$=Q+1,I=j)}),M}return e.reduce(k,N),E}function o(b,k){var E={};function N(M,I,$,R,L){var O;e.forEach(e.range(I,$),function(Q){O=M[Q],b.node(O).dummy&&e.forEach(b.predecessors(O),function(V){var j=b.node(V);j.dummy&&(j.order<R||j.order>L)&&l(E,V,O)})})}function A(M,I){var $=-1,R,L=0;return e.forEach(I,function(O,Q){if(b.node(O).dummy==="border"){var V=b.predecessors(O);V.length&&(R=b.node(V[0]).order,N(I,L,Q,$,R),L=Q,$=R)}N(I,L,I.length,R,M.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 N=k;k=E,E=N}var A=b[k];A||(b[k]=A={}),A[E]=!0}function c(b,k,E){if(k>E){var N=k;k=E,E=N}return e.has(b[k],E)}function d(b,k,E,N){var A={},M={},I={};return e.forEach(k,function($){e.forEach($,function(R,L){A[R]=R,M[R]=R,I[R]=L})}),e.forEach(k,function($){var R=-1;e.forEach($,function(L){var O=N(L);if(O.length){O=e.sortBy(O,function(U){return I[U]});for(var Q=(O.length-1)/2,V=Math.floor(Q),j=Math.ceil(Q);V<=j;++V){var Y=O[V];M[L]===L&&R<I[Y]&&!c(E,L,Y)&&(M[Y]=L,M[L]=A[L]=A[Y],R=I[Y])}}})}),{root:A,align:M}}function h(b,k,E,N,A){var M={},I=p(b,k,E,A),$=A?"borderLeft":"borderRight";function R(Q,V){for(var j=I.nodes(),Y=j.pop(),U={};Y;)U[Y]?Q(Y):(U[Y]=!0,j.push(Y),j=j.concat(V(Y))),Y=j.pop()}function L(Q){M[Q]=I.inEdges(Q).reduce(function(V,j){return Math.max(V,M[j.v]+I.edge(j))},0)}function O(Q){var V=I.outEdges(Q).reduce(function(Y,U){return Math.min(Y,M[U.w]-I.edge(U))},Number.POSITIVE_INFINITY),j=b.node(Q);V!==Number.POSITIVE_INFINITY&&j.borderType!==$&&(M[Q]=Math.max(M[Q],V))}return R(L,I.predecessors.bind(I)),R(O,I.successors.bind(I)),e.forEach(N,function(Q){M[Q]=M[E[Q]]}),M}function p(b,k,E,N){var A=new n,M=b.graph(),I=_(M.nodesep,M.edgesep,N);return e.forEach(k,function($){var R;e.forEach($,function(L){var O=E[L];if(A.setNode(O),R){var Q=E[R],V=A.edge(Q,O);A.setEdge(Q,O,Math.max(I(b,L,R),V||0))}R=L})}),A}function m(b,k){return e.minBy(e.values(k),function(E){var N=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(E,function(M,I){var $=S(b,I)/2;N=Math.max(M+$,N),A=Math.min(M-$,A)}),N-A})}function y(b,k){var E=e.values(k),N=e.min(E),A=e.max(E);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(I){var $=M+I,R=b[$],L;if(R!==k){var O=e.values(R);L=I==="l"?N-e.min(O):A-e.max(O),L&&(b[$]=e.mapValues(R,function(Q){return Q+L}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,N){if(k)return b[k.toLowerCase()][N];var A=e.sortBy(e.map(b,N));return(A[1]+A[2])/2})}function C(b){var k=i.buildLayerMatrix(b),E=e.merge(s(b,k),o(b,k)),N={},A;e.forEach(["u","d"],function(I){A=I==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function($){$==="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),O=h(b,A,L.root,L.align,$==="r");$==="r"&&(O=e.mapValues(O,function(Q){return-Q})),N[I+$]=O})});var M=m(b,N);return y(N,M),x(N,b.graph().align)}function _(b,k,E){return function(N,A,M){var I=N.node(A),$=N.node(M),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+=($.dummy?k:b)/2,R+=$.width/2,e.has($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":L=$.width/2;break;case"r":L=-$.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,hk;function DL(){if(hk)return sg;hk=1;var e=ut(),n=sn(),i=$L().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,pk;function FL(){if(pk)return og;pk=1;var e=ut(),n=_L(),i=SL(),s=kL(),o=sn().normalizeRanks,u=EL(),l=sn().removeEmptyRanks,c=NL(),d=CL(),h=TL(),p=LL(),m=DL(),y=sn(),x=Vn().Graph;og=C;function C(z,G){var J=G&&G.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,G){G(" makeSpaceForEdgeLabels",function(){L(z)}),G(" removeSelfEdges",function(){F(z)}),G(" acyclic",function(){n.run(z)}),G(" nestingGraph.run",function(){c.run(z)}),G(" rank",function(){s(y.asNonCompoundGraph(z))}),G(" injectEdgeLabelProxies",function(){O(z)}),G(" removeEmptyRanks",function(){l(z)}),G(" nestingGraph.cleanup",function(){c.cleanup(z)}),G(" normalizeRanks",function(){o(z)}),G(" assignRankMinMax",function(){Q(z)}),G(" removeEdgeLabelProxies",function(){V(z)}),G(" normalize.run",function(){i.run(z)}),G(" parentDummyChains",function(){u(z)}),G(" addBorderSegments",function(){d(z)}),G(" order",function(){p(z)}),G(" insertSelfEdges",function(){W(z)}),G(" adjustCoordinateSystem",function(){h.adjust(z)}),G(" position",function(){m(z)}),G(" positionSelfEdges",function(){P(z)}),G(" removeBorderNodes",function(){X(z)}),G(" normalize.undo",function(){i.undo(z)}),G(" fixupEdgeLabelCoords",function(){U(z)}),G(" undoCoordinateSystem",function(){h.undo(z)}),G(" translateGraph",function(){j(z)}),G(" assignNodeIntersects",function(){Y(z)}),G(" reversePoints",function(){ne(z)}),G(" acyclic.undo",function(){n.undo(z)})}function S(z,G){e.forEach(z.nodes(),function(J){var se=z.node(J),ue=G.node(J);se&&(se.x=ue.x,se.y=ue.y,G.children(J).length&&(se.width=ue.width,se.height=ue.height))}),e.forEach(z.edges(),function(J){var se=z.edge(J),ue=G.edge(J);se.points=ue.points,e.has(ue,"x")&&(se.x=ue.x,se.y=ue.y)}),z.graph().width=G.graph().width,z.graph().height=G.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],N=["width","height"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},$=["labelpos"];function R(z){var G=new x({multigraph:!0,compound:!0}),J=ae(z.graph());return G.setGraph(e.merge({},k,B(J,b),e.pick(J,E))),e.forEach(z.nodes(),function(se){var ue=ae(z.node(se));G.setNode(se,e.defaults(B(ue,N),A)),G.setParent(se,z.parent(se))}),e.forEach(z.edges(),function(se){var ue=ae(z.edge(se));G.setEdge(se,e.merge({},I,B(ue,M),e.pick(ue,$)))}),G}function L(z){var G=z.graph();G.ranksep/=2,e.forEach(z.edges(),function(J){var se=z.edge(J);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(G.rankdir==="TB"||G.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function O(z){e.forEach(z.edges(),function(G){var J=z.edge(G);if(J.width&&J.height){var se=z.node(G.v),ue=z.node(G.w),he={rank:(ue.rank-se.rank)/2+se.rank,e:G};y.addDummyNode(z,"edge-proxy",he,"_ep")}})}function Q(z){var G=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,G=e.max(G,se.maxRank))}),z.graph().maxRank=G}function V(z){e.forEach(z.nodes(),function(G){var J=z.node(G);J.dummy==="edge-proxy"&&(z.edge(J.e).labelRank=J.rank,z.removeNode(G))})}function j(z){var G=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;G=Math.min(G,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)}),G-=ge,se-=Me,e.forEach(z.nodes(),function(Re){var Pe=z.node(Re);Pe.x-=G,Pe.y-=se}),e.forEach(z.edges(),function(Re){var Pe=z.edge(Re);e.forEach(Pe.points,function(be){be.x-=G,be.y-=se}),e.has(Pe,"x")&&(Pe.x-=G),e.has(Pe,"y")&&(Pe.y-=se)}),he.width=J-G+ge,he.height=ue-se+Me}function Y(z){e.forEach(z.edges(),function(G){var J=z.edge(G),se=z.node(G.v),ue=z.node(G.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(G){var J=z.edge(G);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(G){var J=z.edge(G);J.reversed&&J.points.reverse()})}function X(z){e.forEach(z.nodes(),function(G){if(z.children(G).length){var J=z.node(G),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(G){z.node(G).dummy==="border"&&z.removeNode(G)})}function F(z){e.forEach(z.edges(),function(G){if(G.v===G.w){var J=z.node(G.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:G,label:z.edge(G)}),z.removeEdge(G)}})}function W(z){var G=y.buildLayerMatrix(z);e.forEach(G,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 P(z){e.forEach(z.nodes(),function(G){var J=z.node(G);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(G),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,G){return e.mapValues(e.pick(z,G),Number)}function ae(z){var G={};return e.forEach(z,function(J,se){G[se.toLowerCase()]=J}),G}return og}var ag,mk;function zL(){if(mk)return ag;mk=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,gk;function BL(){return gk||(gk=1,ug="0.8.5"),ug}var lg,vk;function UL(){return vk||(vk=1,lg={graphlib:Vn(),layout:FL(),debug:zL(),util:{time:sn().time,notime:sn().notime},version:BL()}),lg}var HL=UL();const yk=Mg(HL),Ai=240,Ns=130,Cs=74,Xu=72,wk=Cs+Xu;function VL(e){let n=Ai;for(const i of e.values())n=Math.max(n,i.width);return n}const WL=420,GL=2;function Qu(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function YL(e,n,i,s,o){const u=new yk.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);yk.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,N=S.x-k/2,A=S.y-E/2;d.set(_,{x:N,y:A}),N<h&&(h=N),A<p&&(p=A),N+k>m&&(m=N+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,C=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)),C=Math.max(C,S.y+((b==null?void 0:b.height)??Ns))}return{positions:d,width:x,height:C}}function KL(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,...YL(l.get(S),n,s,u,o)})),h=VL(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+wk;return b},y=S=>S.reduce((b,k)=>Math.max(b,k.width),0)+WL;let x=m(i.availableWidth?GL:1);x.length>1&&x.reduce((b,k)=>b+y(k),0)+h*(x.length-1)>(i.availableWidth??0)&&(x=m(1));const C=new Map;let _=0;for(const S of x){let b=0;for(const{positions:k,height:E}of S){for(const[N,A]of k)C.set(N,{x:A.x+_,y:A.y+b});b+=E+wk}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const k=C.get(S.id);return k?{...S,position:k}:S})}function XL(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:C,h:_}=c(y),S=d.get(y)??"_default";if(i.has(y)){h.push({x:x.x,y:x.y,w:C,h:_,sid:S});continue}let b=x.y;for(let k=0;k<h.length+1;k++){const E=h.find(N=>{const A=N.sid===S?24:l,M=N.sid===S?24:u;return x.x<N.x+N.w+A&&N.x<x.x+C+A&&b<N.y+N.h+M&&N.y<b+_+M});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:C,h:_,sid:S})}return m}function QL(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:C,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:C,h:_})}if(c.size===0)return[];const h=Cs+Xu,p=(y,x,C,_)=>d.some(S=>y<S.x+S.w+Cs&&S.x<y+C+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 C=1/0,_=1/0,S=-1/0,b=-1/0;for(const $ of x){const R=l($.id),{w:L,h:O}=u($.id);C=Math.min(C,R.x),_=Math.min(_,R.y),S=Math.max(S,R.x+L),b=Math.max(b,R.y+O)}const k=S-C,E=b-_,N=[...new Set(d.map($=>Math.round($.x)))].sort(($,R)=>$-R),A=N.length?N:[C],M=[0,...d.map($=>$.y+$.h+h)].sort(($,R)=>$-R);let I=null;e:for(const $ of A)for(const R of M){if(R>=_)break;if(!p($,R,k,E)){I={x:$,y:R};break e}}if(I){const $=I.x-C,R=I.y-_;for(const L of x){const O=l(L.id);n.set(L.id,{x:O.x+$,y:O.y+R})}m.push(y)}for(const $ of x){const R=l($.id),{w:L,h:O}=u($.id);d.push({x:R.x,y:R.y,w:L,h:O})}}return m}function ZL(e,n,i,s,o,u=!1){const d=Cs+Xu+1,h=8,p=1.75,m=200,y=.7,x=.01,C=I=>{const $=s.get(I);return{w:($==null?void 0:$.width)??Ai,h:($==null?void 0:$.height)??Ns}},_=I=>i.get(I)??n.get(I),S=new Map;for(const I of e){if(!_(I.id))continue;const $=Qu(I),R=S.get($);R?R.push(I):S.set($,[I])}const b=[],k=new Set,E=new Set;for(const I of[...S.keys()].sort()){const $=S.get(I);let R=1/0,L=1/0,O=-1/0,Q=-1/0,V=!1;for(const ne of $){const X=_(ne.id),{w:F,h:W}=C(ne.id);R=Math.min(R,X.x),L=Math.min(L,X.y),O=Math.max(O,X.x+F),Q=Math.max(Q,X.y+W),i.has(ne.id)&&(V=!0)}const j=O-R,Y=Q-L;E.add(I);const U=o.get(I);U&&(j>U.w+h||Y>U.h+h)&&k.add(I),o.set(I,{w:j,h:Y}),b.push({sid:I,members:$.map(ne=>ne.id),x:R,y:L,w:j,h:Y,anchored:V,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 N=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 $=new Map,R=new Map;let L=0;for(let O=0;O<b.length;O++)for(let Q=O+1;Q<b.length;Q++){const V=b[O],j=b[Q];if(V.anchored&&j.anchored)continue;const Y=V.x+V.w/2,U=V.y+V.h/2,ne=j.x+j.w/2,X=j.y+j.h/2,F=(V.w+j.w)/2+61-Math.abs(Y-ne),W=(V.h+j.h)/2+d-Math.abs(U-X);if(F<=0||W<=0)continue;const P=(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?V.sid<j.sid?-1:1:Math.sign(Ye-Qe);return et(V,Ze)||et(j,-Ze)?Ze:Be&&(et(V,-Ze)||et(j,Ze))?-Ze:0},z=ae(Y,ne,P),G=ae(U,X,B),J=z!==0,se=G!==0;if(!J&&!se)continue;const ue=J&&(!se||F*p<W),[he,ge,Me,Fe]=ue?[z,F,$,P]:[G,W,R,B],Re=Fe(V,he),Pe=Fe(j,-he),be=V.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(V.sid,(Me.get(V.sid)??0)+he*qe*ve),Me.set(j.sid,(Me.get(j.sid)??0)-he*qe*ye),L+=qe}for(const O of b)O.anchored||(O.x=Math.max(0,O.x+($.get(O.sid)??0)),O.y=Math.max(0,O.y+(R.get(O.sid)??0)));if(L<x)break}const M=[];for(const I of b){const $=I.x-N.get(I.sid),R=I.y-A.get(I.sid);if(!(Math.abs($)<1&&Math.abs(R)<1)){for(const L of I.members){if(i.has(L))continue;const O=n.get(L);O&&n.set(L,{x:O.x+$,y:O.y+R})}M.push(I.sid)}}return M}const JL=600;function jg(e,n){return!(e.exitAt!=null&&n-e.exitAt>JL||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function e$(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 t$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const n$={agent:yP,sessionGroup:RP},r$=420,lu=18,i$=9e4,s$=200,o$=5*6e4,a$=6,u$=2*6e4,yv="agent-dag.layout",wv="agent-dag.viewport",nC="agent-dag.summariesDismissed",rC="agent-dag.sessionListOpen",iC="agent-dag.detailOpen",sC="agent-dag.usagePanelOpen",xk="agent-dag.accountsPanelOpen";function l$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(rC)==="1"}catch{return!1}}function c$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(rC,e?"1":"0")}catch{}}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!0;const e=window.localStorage.getItem(sC);try{return e===null?!0:e==="1"}catch{return!0}}function p$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(sC,e?"1":"0")}catch{}}function m$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(nC);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 _k(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(nC,JSON.stringify(i))}catch{}}function g$(){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 v$(){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 y$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(wv,JSON.stringify(e))}catch{}}function Sk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(yv)}catch{}try{window.localStorage.removeItem(wv)}catch{}}}function w$(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"},x$={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 oC(e){return e.startsWith("mcp__")?"mcp":x$[e]??"other"}function aC(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 _$(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 S$(e,n,i,s,o,u,l,c,d,h,p,m,y,x,C,_,S,b){const k=[],E=[],N=new Set;if(u)for(const R of e.agents.values())aC(R,u)&&N.add(R.id);for(const R of e.agents.values()){if(!S.has(R.id))continue;const L=u?!N.has(R.id):!1,O=R.exitAt!=null,Q=_!=null&&!_.has(R.id),V=[L?"rf-dim":"",O?"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:V,...j?{width:j.width,height:j.height}:null}),R.parentId&&S.has(R.parentId)){const Y=Zg(R.sessionId),U=R.state==="active"?`hsl(${Y} 80% 72%)`:`hsl(${Y} 50% 55%)`,ne=u&&!N.has(R.id)&&!N.has(R.parentId),X=O,F=C.size>0&&(C.has(R.id)||C.has(R.parentId)),W=_!=null&&!_.has(R.id)&&!_.has(R.parentId),P=R.state==="active"?2:1.5,B=F?P+1.5:P,ae=ne||X?.2:W?.12:1,z=[X?"rf-edge-exiting":"",F?"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"||F)&&!ne&&!X,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=KL(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);QL(k,m,o,l,new Set(A.map(L=>L.id)))}XL(k,m,o,l),x.current=y}const M=ZL(k,m,o,l,c,!h||p);M.length>0&&d(M);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 $=!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),$=!0),I.push({...R,position:L})}return $&&(x.current=""),{nodes:I,edges:E}}function b$(){return v.jsx(Xg,{children:v.jsx(k$,{})})}function k$(){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),[C,_]=q.useState(null),S=q.useCallback(Z=>_(Z),[]),b=q.useRef(m$()),[k,E]=q.useState(l$);q.useEffect(()=>{c$(k)},[k]);const[N,A]=q.useState(f$);q.useEffect(()=>{d$(N)},[N]);const[M,I]=q.useState(h$);q.useEffect(()=>{p$(M)},[M]);const[$,R]=q.useState(()=>{try{const Z=window.localStorage.getItem(xk);return Z===null?!0:Z==="1"}catch{return!0}});q.useEffect(()=>{try{window.localStorage.setItem(xk,$?"1":"0")}catch{}},[$]);const[L,O]=q.useState(null),[Q,V]=q.useState(!1),[j,Y]=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&&(O(Z.enabled===!0),Y((Z.foreign??[]).filter(te=>te.worksHere).length),ne(typeof Z.parked=="number"?Z.parked:0))}).catch(()=>{})},[]);const X=q.useCallback(async()=>{V(!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&&O(te.enabled===!0),fetch("/api/sound-hook").then(ce=>ce.ok?ce.json():null).then(ce=>{ce!=null&&ce.ok&&(Y((ce.foreign??[]).filter(me=>me.worksHere).length),ne(typeof ce.parked=="number"?ce.parked:0))}).catch(()=>{})}catch{}finally{V(!1)}},[L]),F=q.useCallback(()=>{E(Z=>(Z||R(!1),!Z))},[]),W=q.useCallback(()=>{R(Z=>(Z||E(!1),!Z))},[]),[P,B]=q.useState(!1),[ae,z]=q.useState(0),G=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(g$()).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(()=>v$())[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=nP(n.current,te,i$);eP(n.current,te,s$,o$)&&(ce=!0),tP(n.current,te,a$,u$)&&(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=_$(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(()=>e$(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),r$+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(()=>S$(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=G.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())aC(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(oC(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="",Sk(),m(),s()},[s,m]),$s=q.useCallback(()=>{Oe.current.clear(),Nt.current.clear(),Pn.current="",Sk(),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")&&F(),(te.key==="h"||te.key==="H")&&B(we=>!we),(te.key==="u"||te.key==="U")&&I(we=>!we),(te.key==="a"||te.key==="A")&&W(),(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.2"]})]}),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:t$(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 ${M?"primary":""}`,onClick:()=>I(Z=>!Z),title:`${M?"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){V(!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&&(O(te.enabled===!0),ne(te.parked??0))}).catch(()=>{}).finally(()=>V(!1));return}X()},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?`
|