agent-dag 1.30.8 → 1.30.9

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 Q0;function ZT(){if(Q0)return $c;Q0=1;var e=Fo(),n=QT();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 $c.useSyncExternalStoreWithSelector=function(h,p,m,y,x){var N=u(null);if(N.current===null){var _={hasValue:!1,value:null};N.current=_}else _=N.current;N=c(function(){function b(P){if(!k){if(k=!0,E=P,P=y(P),x!==void 0&&_.hasValue){var I=_.value;if(x(I,P))return C=I}return C=P}if(I=C,s(E,P))return I;var M=y(P);return x!==void 0&&x(I,M)?(E=P,I):(E=P,C=M)}var k=!1,E,C,A=m===void 0?null:m;return[function(){return b(p())},A===null?void 0:function(){return b(A())}]},[p,m,y,x]);var S=o(h,N[0],N[1]);return l(function(){_.hasValue=!0,_.value=S},[S]),d(S),S},$c}var Z0;function JT(){return Z0||(Z0=1,Lc.exports=ZT()),Lc.exports}var eR=JT();const tR=Dg(eR),nR={},J0=e=>{let n;const i=new Set,s=(p,m)=>{const y=typeof p=="function"?p(n):p;if(!Object.is(y,n)){const x=n;n=m??(typeof y!="object"||y===null)?y:Object.assign({},n,y),i.forEach(N=>N(n,x))}},o=()=>n,d={setState:s,getState:o,getInitialState:()=>h,subscribe:p=>(i.add(p),()=>i.delete(p)),destroy:()=>{(nR?"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},rR=e=>e?J0(e):J0,{useDebugValue:iR}=oe,{useSyncExternalStoreWithSelector:sR}=tR,oR=e=>e;function Rk(e,n=oR,i){const s=sR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,i);return iR(s),s}const ew=(e,n)=>{const i=rR(e),s=(o,u=n)=>Rk(i,o,u);return Object.assign(s,i),s},aR=(e,n)=>e?ew(e,n):ew;function Et(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 uR={value:()=>{}};function ju(){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 pu(i)}function pu(e){this._=e}function lR(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}})}pu.prototype=ju.prototype={constructor:pu,on:function(e,n){var i=this._,s=lR(e+"",i),o,u=-1,l=s.length;if(arguments.length<2){for(;++u<l;)if((o=(e=s[u]).type)&&(o=cR(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]=tw(i[o],e.name,n);else if(n==null)for(o in i)i[o]=tw(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 pu(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 cR(e,n){for(var i=0,s=e.length,o;i<s;++i)if((o=e[i]).name===n)return o.value}function tw(e,n,i){for(var s=0,o=e.length;s<o;++s)if(e[s].name===n){e[s]=uR,e=e.slice(0,s).concat(e.slice(s+1));break}return i!=null&&e.push({name:n,value:i}),e}var vg="http://www.w3.org/1999/xhtml";const nw={svg:"http://www.w3.org/2000/svg",xhtml:vg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Au(e){var n=e+="",i=n.indexOf(":");return i>=0&&(n=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),nw.hasOwnProperty(n)?{space:nw[n],local:e}:e}function fR(e){return function(){var n=this.ownerDocument,i=this.namespaceURI;return i===vg&&n.documentElement.namespaceURI===vg?n.createElement(e):n.createElementNS(i,e)}}function dR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function jk(e){var n=Au(e);return(n.local?dR:fR)(n)}function hR(){}function Fg(e){return e==null?hR:function(){return this.querySelector(e)}}function pR(e){typeof e!="function"&&(e=Fg(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 mn(s,this._parents)}function mR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function gR(){return[]}function Ak(e){return e==null?gR:function(){return this.querySelectorAll(e)}}function vR(e){return function(){return mR(e.apply(this,arguments))}}function yR(e){typeof e=="function"?e=vR(e):e=Ak(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 mn(s,o)}function Ik(e){return function(){return this.matches(e)}}function Mk(e){return function(n){return n.matches(e)}}var wR=Array.prototype.find;function xR(e){return function(){return wR.call(this.children,e)}}function _R(){return this.firstElementChild}function SR(e){return this.select(e==null?_R:xR(typeof e=="function"?e:Mk(e)))}var bR=Array.prototype.filter;function kR(){return Array.from(this.children)}function ER(e){return function(){return bR.call(this.children,e)}}function NR(e){return this.selectAll(e==null?kR:ER(typeof e=="function"?e:Mk(e)))}function CR(e){typeof e!="function"&&(e=Ik(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 mn(s,this._parents)}function Pk(e){return new Array(e.length)}function TR(){return new mn(this._enter||this._groups.map(Pk),this._parents)}function yu(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}yu.prototype={constructor:yu,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 RR(e){return function(){return e}}function jR(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 yu(e,u[l]);for(;l<d;++l)(c=n[l])&&(o[l]=c)}function AR(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 yu(e,u[c]);for(c=0;c<p;++c)(d=n[c])&&h.get(y[c])===d&&(o[c]=d)}function IR(e){return e.__data__}function MR(e,n){if(!arguments.length)return Array.from(this,IR);var i=n?AR:jR,s=this._parents,o=this._groups;typeof e!="function"&&(e=RR(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=PR(e.call(p,p&&p.__data__,h,s)),N=x.length,_=c[h]=new Array(N),S=l[h]=new Array(N),b=d[h]=new Array(y);i(p,m,_,S,b,x,n);for(var k=0,E=0,C,A;k<N;++k)if(C=_[k]){for(k>=E&&(E=k+1);!(A=S[E])&&++E<N;);C._next=A||null}}return l=new mn(l,s),l._enter=c,l._exit=d,l}function PR(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function OR(){return new mn(this._exit||this._groups.map(Pk),this._parents)}function qR(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 LR(e){for(var n=e.selection?e.selection():e,i=this._groups,s=n._groups,o=i.length,u=s.length,l=Math.min(o,u),c=new Array(o),d=0;d<l;++d)for(var h=i[d],p=s[d],m=h.length,y=c[d]=new Array(m),x,N=0;N<m;++N)(x=h[N]||p[N])&&(y[N]=x);for(;d<o;++d)c[d]=i[d];return new mn(c,this._parents)}function $R(){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 DR(e){e||(e=FR);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 mn(o,this._parents).order()}function FR(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function zR(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function BR(){return Array.from(this)}function UR(){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 HR(){let e=0;for(const n of this)++e;return e}function VR(){return!this.node()}function WR(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 GR(e){return function(){this.removeAttribute(e)}}function YR(e){return function(){this.removeAttributeNS(e.space,e.local)}}function KR(e,n){return function(){this.setAttribute(e,n)}}function XR(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function QR(e,n){return function(){var i=n.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function ZR(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 JR(e,n){var i=Au(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?YR:GR:typeof n=="function"?i.local?ZR:QR:i.local?XR:KR)(i,n))}function Ok(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function e2(e){return function(){this.style.removeProperty(e)}}function t2(e,n,i){return function(){this.style.setProperty(e,n,i)}}function n2(e,n,i){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,i)}}function r2(e,n,i){return arguments.length>1?this.each((n==null?e2:typeof n=="function"?n2:t2)(e,n,i??"")):Is(this.node(),e)}function Is(e,n){return e.style.getPropertyValue(n)||Ok(e).getComputedStyle(e,null).getPropertyValue(n)}function i2(e){return function(){delete this[e]}}function s2(e,n){return function(){this[e]=n}}function o2(e,n){return function(){var i=n.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function a2(e,n){return arguments.length>1?this.each((n==null?i2:typeof n=="function"?o2:s2)(e,n)):this.node()[e]}function qk(e){return e.trim().split(/^|\s+/)}function zg(e){return e.classList||new Lk(e)}function Lk(e){this._node=e,this._names=qk(e.getAttribute("class")||"")}Lk.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 $k(e,n){for(var i=zg(e),s=-1,o=n.length;++s<o;)i.add(n[s])}function Dk(e,n){for(var i=zg(e),s=-1,o=n.length;++s<o;)i.remove(n[s])}function u2(e){return function(){$k(this,e)}}function l2(e){return function(){Dk(this,e)}}function c2(e,n){return function(){(n.apply(this,arguments)?$k:Dk)(this,e)}}function f2(e,n){var i=qk(e+"");if(arguments.length<2){for(var s=zg(this.node()),o=-1,u=i.length;++o<u;)if(!s.contains(i[o]))return!1;return!0}return this.each((typeof n=="function"?c2:n?u2:l2)(i,n))}function d2(){this.textContent=""}function h2(e){return function(){this.textContent=e}}function p2(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function m2(e){return arguments.length?this.each(e==null?d2:(typeof e=="function"?p2:h2)(e)):this.node().textContent}function g2(){this.innerHTML=""}function v2(e){return function(){this.innerHTML=e}}function y2(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function w2(e){return arguments.length?this.each(e==null?g2:(typeof e=="function"?y2:v2)(e)):this.node().innerHTML}function x2(){this.nextSibling&&this.parentNode.appendChild(this)}function _2(){return this.each(x2)}function S2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function b2(){return this.each(S2)}function k2(e){var n=typeof e=="function"?e:jk(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function E2(){return null}function N2(e,n){var i=typeof e=="function"?e:jk(e),s=n==null?E2:typeof n=="function"?n:Fg(n);return this.select(function(){return this.insertBefore(i.apply(this,arguments),s.apply(this,arguments)||null)})}function C2(){var e=this.parentNode;e&&e.removeChild(this)}function T2(){return this.each(C2)}function R2(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function j2(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function A2(e){return this.select(e?j2:R2)}function I2(e){return arguments.length?this.property("__data__",e):this.node().__data__}function M2(e){return function(n){e.call(this,n,this.__data__)}}function P2(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 O2(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 q2(e,n,i){return function(){var s=this.__on,o,u=M2(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 L2(e,n,i){var s=P2(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?q2:O2,o=0;o<u;++o)this.each(c(s[o],n,i));return this}function Fk(e,n,i){var s=Ok(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 $2(e,n){return function(){return Fk(this,e,n)}}function D2(e,n){return function(){return Fk(this,e,n.apply(this,arguments))}}function F2(e,n){return this.each((typeof n=="function"?D2:$2)(e,n))}function*z2(){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 zk=[null];function mn(e,n){this._groups=e,this._parents=n}function zo(){return new mn([[document.documentElement]],zk)}function B2(){return this}mn.prototype=zo.prototype={constructor:mn,select:pR,selectAll:yR,selectChild:SR,selectChildren:NR,filter:CR,data:MR,enter:TR,exit:OR,join:qR,merge:LR,selection:B2,order:$R,sort:DR,call:zR,nodes:BR,node:UR,size:HR,empty:VR,each:WR,attr:JR,style:r2,property:a2,classed:f2,text:m2,html:w2,raise:_2,lower:b2,append:k2,insert:N2,remove:T2,clone:A2,datum:I2,on:L2,dispatch:F2,[Symbol.iterator]:z2};function Tn(e){return typeof e=="string"?new mn([[document.querySelector(e)]],[document.documentElement]):new mn([[e]],zk)}function U2(e){let n;for(;n=e.sourceEvent;)e=n;return e}function zn(e,n){if(e=U2(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 H2={passive:!1},Io={capture:!0,passive:!1};function zc(e){e.stopImmediatePropagation()}function Cs(e){e.preventDefault(),e.stopImmediatePropagation()}function Bk(e){var n=e.document.documentElement,i=Tn(e).on("dragstart.drag",Cs,Io);"onselectstart"in n?i.on("selectstart.drag",Cs,Io):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Uk(e,n){var i=e.document.documentElement,s=Tn(e).on("dragstart.drag",null);n&&(s.on("click.drag",Cs,Io),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 eu=e=>()=>e;function yg(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}})}yg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function V2(e){return!e.ctrlKey&&!e.button}function W2(){return this.parentNode}function G2(e,n){return n??{x:e.x,y:e.y}}function Y2(){return navigator.maxTouchPoints||"ontouchstart"in this}function K2(){var e=V2,n=W2,i=G2,s=Y2,o={},u=ju("start","drag","end"),l=0,c,d,h,p,m=0;function y(C){C.on("mousedown.drag",x).filter(s).on("touchstart.drag",S).on("touchmove.drag",b,H2).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(C,A){if(!(p||!e.call(this,C,A))){var P=E(this,n.call(this,C,A),C,A,"mouse");P&&(Tn(C.view).on("mousemove.drag",N,Io).on("mouseup.drag",_,Io),Bk(C.view),zc(C),h=!1,c=C.clientX,d=C.clientY,P("start",C))}}function N(C){if(Cs(C),!h){var A=C.clientX-c,P=C.clientY-d;h=A*A+P*P>m}o.mouse("drag",C)}function _(C){Tn(C.view).on("mousemove.drag mouseup.drag",null),Uk(C.view,h),Cs(C),o.mouse("end",C)}function S(C,A){if(e.call(this,C,A)){var P=C.changedTouches,I=n.call(this,C,A),M=P.length,R,L;for(R=0;R<M;++R)(L=E(this,I,C,A,P[R].identifier,P[R]))&&(zc(C),L("start",C,P[R]))}}function b(C){var A=C.changedTouches,P=A.length,I,M;for(I=0;I<P;++I)(M=o[A[I].identifier])&&(Cs(C),M("drag",C,A[I]))}function k(C){var A=C.changedTouches,P=A.length,I,M;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),I=0;I<P;++I)(M=o[A[I].identifier])&&(zc(C),M("end",C,A[I]))}function E(C,A,P,I,M,R){var L=u.copy(),F=zn(R||P,A),J,X,j;if((j=i.call(C,new yg("beforestart",{sourceEvent:P,target:y,identifier:M,active:l,x:F[0],y:F[1],dx:0,dy:0,dispatch:L}),I))!=null)return J=j.x-F[0]||0,X=j.y-F[1]||0,function G(U,ne,K){var $=F,W;switch(U){case"start":o[M]=G,W=l++;break;case"end":delete o[M],--l;case"drag":F=zn(K||ne,A),W=l;break}L.call(U,C,new yg(U,{sourceEvent:ne,subject:j,target:y,identifier:M,active:W,x:F[0]+J,y:F[1]+X,dx:F[0]-$[0],dy:F[1]-$[1],dispatch:L}),I)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:eu(!!C),y):e},y.container=function(C){return arguments.length?(n=typeof C=="function"?C:eu(C),y):n},y.subject=function(C){return arguments.length?(i=typeof C=="function"?C:eu(C),y):i},y.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:eu(!!C),y):s},y.on=function(){var C=u.on.apply(u,arguments);return C===u?y:C},y.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,y):Math.sqrt(m)},y}function Bg(e,n,i){e.prototype=n.prototype=i,i.constructor=e}function Hk(e,n){var i=Object.create(e.prototype);for(var s in n)i[s]=n[s];return i}function Bo(){}var Mo=.7,wu=1/Mo,Ts="\\s*([+-]?\\d+)\\s*",Po="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ir="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",X2=/^#([0-9a-f]{3,8})$/,Q2=new RegExp(`^rgb\\(${Ts},${Ts},${Ts}\\)$`),Z2=new RegExp(`^rgb\\(${ir},${ir},${ir}\\)$`),J2=new RegExp(`^rgba\\(${Ts},${Ts},${Ts},${Po}\\)$`),ej=new RegExp(`^rgba\\(${ir},${ir},${ir},${Po}\\)$`),tj=new RegExp(`^hsl\\(${Po},${ir},${ir}\\)$`),nj=new RegExp(`^hsla\\(${Po},${ir},${ir},${Po}\\)$`),rw={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};Bg(Bo,Oo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:iw,formatHex:iw,formatHex8:rj,formatHsl:ij,formatRgb:sw,toString:sw});function iw(){return this.rgb().formatHex()}function rj(){return this.rgb().formatHex8()}function ij(){return Vk(this).formatHsl()}function sw(){return this.rgb().formatRgb()}function Oo(e){var n,i;return e=(e+"").trim().toLowerCase(),(n=X2.exec(e))?(i=n[1].length,n=parseInt(n[1],16),i===6?ow(n):i===3?new on(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):i===8?tu(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):i===4?tu(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=Q2.exec(e))?new on(n[1],n[2],n[3],1):(n=Z2.exec(e))?new on(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=J2.exec(e))?tu(n[1],n[2],n[3],n[4]):(n=ej.exec(e))?tu(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=tj.exec(e))?lw(n[1],n[2]/100,n[3]/100,1):(n=nj.exec(e))?lw(n[1],n[2]/100,n[3]/100,n[4]):rw.hasOwnProperty(e)?ow(rw[e]):e==="transparent"?new on(NaN,NaN,NaN,0):null}function ow(e){return new on(e>>16&255,e>>8&255,e&255,1)}function tu(e,n,i,s){return s<=0&&(e=n=i=NaN),new on(e,n,i,s)}function sj(e){return e instanceof Bo||(e=Oo(e)),e?(e=e.rgb(),new on(e.r,e.g,e.b,e.opacity)):new on}function wg(e,n,i,s){return arguments.length===1?sj(e):new on(e,n,i,s??1)}function on(e,n,i,s){this.r=+e,this.g=+n,this.b=+i,this.opacity=+s}Bg(on,wg,Hk(Bo,{brighter(e){return e=e==null?wu:Math.pow(wu,e),new on(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Mo:Math.pow(Mo,e),new on(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new on(qi(this.r),qi(this.g),qi(this.b),xu(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:aw,formatHex:aw,formatHex8:oj,formatRgb:uw,toString:uw}));function aw(){return`#${Pi(this.r)}${Pi(this.g)}${Pi(this.b)}`}function oj(){return`#${Pi(this.r)}${Pi(this.g)}${Pi(this.b)}${Pi((isNaN(this.opacity)?1:this.opacity)*255)}`}function uw(){const e=xu(this.opacity);return`${e===1?"rgb(":"rgba("}${qi(this.r)}, ${qi(this.g)}, ${qi(this.b)}${e===1?")":`, ${e})`}`}function xu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function qi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Pi(e){return e=qi(e),(e<16?"0":"")+e.toString(16)}function lw(e,n,i,s){return s<=0?e=n=i=NaN:i<=0||i>=1?e=n=NaN:n<=0&&(e=NaN),new Bn(e,n,i,s)}function Vk(e){if(e instanceof Bn)return new Bn(e.h,e.s,e.l,e.opacity);if(e instanceof Bo||(e=Oo(e)),!e)return new Bn;if(e instanceof Bn)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 Bn(l,c,d,e.opacity)}function aj(e,n,i,s){return arguments.length===1?Vk(e):new Bn(e,n,i,s??1)}function Bn(e,n,i,s){this.h=+e,this.s=+n,this.l=+i,this.opacity=+s}Bg(Bn,aj,Hk(Bo,{brighter(e){return e=e==null?wu:Math.pow(wu,e),new Bn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Mo:Math.pow(Mo,e),new Bn(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 on(Bc(e>=240?e-240:e+120,o,s),Bc(e,o,s),Bc(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new Bn(cw(this.h),nu(this.s),nu(this.l),xu(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=xu(this.opacity);return`${e===1?"hsl(":"hsla("}${cw(this.h)}, ${nu(this.s)*100}%, ${nu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function cw(e){return e=(e||0)%360,e<0?e+360:e}function nu(e){return Math.max(0,Math.min(1,e||0))}function Bc(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 Wk=e=>()=>e;function uj(e,n){return function(i){return e+i*n}}function lj(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 cj(e){return(e=+e)==1?Gk:function(n,i){return i-n?lj(n,i,e):Wk(isNaN(n)?i:n)}}function Gk(e,n){var i=n-e;return i?uj(e,i):Wk(isNaN(e)?n:e)}const fw=(function e(n){var i=cj(n);function s(o,u){var l=i((o=wg(o)).r,(u=wg(u)).r),c=i(o.g,u.g),d=i(o.b,u.b),h=Gk(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 ei(e,n){return e=+e,n=+n,function(i){return e*(1-i)+n*i}}var xg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Uc=new RegExp(xg.source,"g");function fj(e){return function(){return e}}function dj(e){return function(n){return e(n)+""}}function hj(e,n){var i=xg.lastIndex=Uc.lastIndex=0,s,o,u,l=-1,c=[],d=[];for(e=e+"",n=n+"";(s=xg.exec(e))&&(o=Uc.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:ei(s,o)})),i=Uc.lastIndex;return i<n.length&&(u=n.slice(i),c[l]?c[l]+=u:c[++l]=u),c.length<2?d[0]?dj(d[0].x):fj(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 dw=180/Math.PI,_g={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yk(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)*dw,skewX:Math.atan(d)*dw,scaleX:l,scaleY:c}}var ru;function pj(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?_g:Yk(n.a,n.b,n.c,n.d,n.e,n.f)}function mj(e){return e==null||(ru||(ru=document.createElementNS("http://www.w3.org/2000/svg","g")),ru.setAttribute("transform",e),!(e=ru.transform.baseVal.consolidate()))?_g:(e=e.matrix,Yk(e.a,e.b,e.c,e.d,e.e,e.f))}function Kk(e,n,i,s){function o(h){return h.length?h.pop()+" ":""}function u(h,p,m,y,x,N){if(h!==m||p!==y){var _=x.push("translate(",null,n,null,i);N.push({i:_-4,x:ei(h,m)},{i:_-2,x:ei(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:ei(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:ei(h,p)}):p&&m.push(o(m)+"skewX("+p+s)}function d(h,p,m,y,x,N){if(h!==m||p!==y){var _=x.push(o(x)+"scale(",null,",",null,")");N.push({i:_-4,x:ei(h,m)},{i:_-2,x:ei(p,y)})}else(m!==1||y!==1)&&x.push(o(x)+"scale("+m+","+y+")")}return function(h,p){var m=[],y=[];return h=e(h),p=e(p),u(h.translateX,h.translateY,p.translateX,p.translateY,m,y),l(h.rotate,p.rotate,m,y),c(h.skewX,p.skewX,m,y),d(h.scaleX,h.scaleY,p.scaleX,p.scaleY,m,y),h=p=null,function(x){for(var N=-1,_=y.length,S;++N<_;)m[(S=y[N]).i]=S.x(x);return m.join("")}}}var gj=Kk(pj,"px, ","px)","deg)"),vj=Kk(mj,", ",")",")"),yj=1e-12;function hw(e){return((e=Math.exp(e))+1/e)/2}function wj(e){return((e=Math.exp(e))-1/e)/2}function xj(e){return((e=Math.exp(2*e))-1)/(e+1)}const _j=(function e(n,i,s){function o(u,l){var c=u[0],d=u[1],h=u[2],p=l[0],m=l[1],y=l[2],x=p-c,N=m-d,_=x*x+N*N,S,b;if(_<yj)b=Math.log(y/h)/n,S=function(I){return[c+I*x,d+I*N,h*Math.exp(n*I*b)]};else{var k=Math.sqrt(_),E=(y*y-h*h+s*_)/(2*h*i*k),C=(y*y-h*h-s*_)/(2*y*i*k),A=Math.log(Math.sqrt(E*E+1)-E),P=Math.log(Math.sqrt(C*C+1)-C);b=(P-A)/n,S=function(I){var M=I*b,R=hw(A),L=h/(i*k)*(R*xj(n*M+A)-wj(A));return[c+L*x,d+L*N,h*R/hw(n*M+A)]}}return S.duration=b*1e3*n/Math.SQRT2,S}return o.rho=function(u){var l=Math.max(.001,+u),c=l*l,d=c*c;return e(l,c,d)},o})(Math.SQRT2,2,4);var Ms=0,Eo=0,xo=0,Xk=1e3,_u,No,Su=0,Di=0,Iu=0,qo=typeof performance=="object"&&performance.now?performance:Date,Qk=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ug(){return Di||(Qk(Sj),Di=qo.now()+Iu)}function Sj(){Di=0}function bu(){this._call=this._time=this._next=null}bu.prototype=Zk.prototype={constructor:bu,restart:function(e,n,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?Ug():+i)+(n==null?0:+n),!this._next&&No!==this&&(No?No._next=this:_u=this,No=this),this._call=e,this._time=i,Sg()},stop:function(){this._call&&(this._call=null,this._time=1/0,Sg())}};function Zk(e,n,i){var s=new bu;return s.restart(e,n,i),s}function bj(){Ug(),++Ms;for(var e=_u,n;e;)(n=Di-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Ms}function pw(){Di=(Su=qo.now())+Iu,Ms=Eo=0;try{bj()}finally{Ms=0,Ej(),Di=0}}function kj(){var e=qo.now(),n=e-Su;n>Xk&&(Iu-=n,Su=e)}function Ej(){for(var e,n=_u,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:_u=i);No=e,Sg(s)}function Sg(e){if(!Ms){Eo&&(Eo=clearTimeout(Eo));var n=e-Di;n>24?(e<1/0&&(Eo=setTimeout(pw,e-qo.now()-Iu)),xo&&(xo=clearInterval(xo))):(xo||(Su=qo.now(),xo=setInterval(kj,Xk)),Ms=1,Qk(pw))}}function mw(e,n,i){var s=new bu;return n=n==null?0:+n,s.restart(o=>{s.stop(),e(o+n)},n,i),s}var Nj=ju("start","end","cancel","interrupt"),Cj=[],Jk=0,gw=1,bg=2,mu=3,vw=4,kg=5,gu=6;function Mu(e,n,i,s,o,u){var l=e.__transition;if(!l)e.__transition={};else if(i in l)return;Tj(e,i,{name:n,index:s,group:o,on:Nj,tween:Cj,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Jk})}function Hg(e,n){var i=Vn(e,n);if(i.state>Jk)throw new Error("too late; already scheduled");return i}function sr(e,n){var i=Vn(e,n);if(i.state>mu)throw new Error("too late; already running");return i}function Vn(e,n){var i=e.__transition;if(!i||!(i=i[n]))throw new Error("transition not found");return i}function Tj(e,n,i){var s=e.__transition,o;s[n]=i,i.timer=Zk(u,0,i.time);function u(h){i.state=gw,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!==gw)return d();for(p in s)if(x=s[p],x.name===i.name){if(x.state===mu)return mw(l);x.state===vw?(x.state=gu,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[p]):+p<n&&(x.state=gu,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete s[p])}if(mw(function(){i.state===mu&&(i.state=vw,i.timer.restart(c,i.delay,i.time),c(h))}),i.state=bg,i.on.call("start",e,e.__data__,i.index,i.group),i.state===bg){for(i.state=mu,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=kg,1),m=-1,y=o.length;++m<y;)o[m].call(e,p);i.state===kg&&(i.on.call("end",e,e.__data__,i.index,i.group),d())}function d(){i.state=gu,i.timer.stop(),delete s[n];for(var h in s)return;delete e.__transition}}function vu(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>bg&&s.state<kg,s.state=gu,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete i[l]}u&&delete e.__transition}}function Rj(e){return this.each(function(){vu(this,e)})}function jj(e,n){var i,s;return function(){var o=sr(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 Aj(e,n,i){var s,o;if(typeof i!="function")throw new Error;return function(){var u=sr(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 Ij(e,n){var i=this._id;if(e+="",arguments.length<2){for(var s=Vn(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?jj:Aj)(i,e,n))}function Vg(e,n,i){var s=e._id;return e.each(function(){var o=sr(this,s);(o.value||(o.value={}))[n]=i.apply(this,arguments)}),function(o){return Vn(o,s).value[n]}}function eE(e,n){var i;return(typeof n=="number"?ei:n instanceof Oo?fw:(i=Oo(n))?(n=i,fw):hj)(e,n)}function Mj(e){return function(){this.removeAttribute(e)}}function Pj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Oj(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 qj(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 Lj(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 $j(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 Dj(e,n){var i=Au(e),s=i==="transform"?vj:eE;return this.attrTween(e,typeof n=="function"?(i.local?$j:Lj)(i,s,Vg(this,"attr."+e,n)):n==null?(i.local?Pj:Mj)(i):(i.local?qj:Oj)(i,s,n))}function Fj(e,n){return function(i){this.setAttribute(e,n.call(this,i))}}function zj(e,n){return function(i){this.setAttributeNS(e.space,e.local,n.call(this,i))}}function Bj(e,n){var i,s;function o(){var u=n.apply(this,arguments);return u!==s&&(i=(s=u)&&zj(e,u)),i}return o._value=n,o}function Uj(e,n){var i,s;function o(){var u=n.apply(this,arguments);return u!==s&&(i=(s=u)&&Fj(e,u)),i}return o._value=n,o}function Hj(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=Au(e);return this.tween(i,(s.local?Bj:Uj)(s,n))}function Vj(e,n){return function(){Hg(this,e).delay=+n.apply(this,arguments)}}function Wj(e,n){return n=+n,function(){Hg(this,e).delay=n}}function Gj(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Vj:Wj)(n,e)):Vn(this.node(),n).delay}function Yj(e,n){return function(){sr(this,e).duration=+n.apply(this,arguments)}}function Kj(e,n){return n=+n,function(){sr(this,e).duration=n}}function Xj(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Yj:Kj)(n,e)):Vn(this.node(),n).duration}function Qj(e,n){if(typeof n!="function")throw new Error;return function(){sr(this,e).ease=n}}function Zj(e){var n=this._id;return arguments.length?this.each(Qj(n,e)):Vn(this.node(),n).ease}function Jj(e,n){return function(){var i=n.apply(this,arguments);if(typeof i!="function")throw new Error;sr(this,e).ease=i}}function eA(e){if(typeof e!="function")throw new Error;return this.each(Jj(this._id,e))}function tA(e){typeof e!="function"&&(e=Ik(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 kr(s,this._parents,this._name,this._id)}function nA(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 kr(l,this._parents,this._name,this._id)}function rA(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 iA(e,n,i){var s,o,u=rA(n)?Hg:sr;return function(){var l=u(this,e),c=l.on;c!==s&&(o=(s=c).copy()).on(n,i),l.on=o}}function sA(e,n){var i=this._id;return arguments.length<2?Vn(this.node(),i).on.on(e):this.each(iA(i,e,n))}function oA(e){return function(){var n=this.parentNode;for(var i in this.__transition)if(+i!==e)return;n&&n.removeChild(this)}}function aA(){return this.on("end.remove",oA(this._id))}function uA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Fg(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,Mu(h[y],n,i,y,h,Vn(p,i)));return new kr(u,this._parents,n,i)}function lA(e){var n=this._name,i=this._id;typeof e!="function"&&(e=Ak(e));for(var s=this._groups,o=s.length,u=[],l=[],c=0;c<o;++c)for(var d=s[c],h=d.length,p,m=0;m<h;++m)if(p=d[m]){for(var y=e.call(p,p.__data__,m,d),x,N=Vn(p,i),_=0,S=y.length;_<S;++_)(x=y[_])&&Mu(x,n,i,_,y,N);u.push(y),l.push(p)}return new kr(u,l,n,i)}var cA=zo.prototype.constructor;function fA(){return new cA(this._groups,this._parents)}function dA(e,n){var i,s,o;return function(){var u=Is(this,e),l=(this.style.removeProperty(e),Is(this,e));return u===l?null:u===i&&l===s?o:o=n(i=u,s=l)}}function tE(e){return function(){this.style.removeProperty(e)}}function hA(e,n,i){var s,o=i+"",u;return function(){var l=Is(this,e);return l===o?null:l===s?u:u=n(s=l,i)}}function pA(e,n,i){var s,o,u;return function(){var l=Is(this,e),c=i(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),Is(this,e))),l===d?null:l===s&&d===o?u:(o=d,u=n(s=l,c))}}function mA(e,n){var i,s,o,u="style."+n,l="end."+u,c;return function(){var d=sr(this,e),h=d.on,p=d.value[u]==null?c||(c=tE(n)):void 0;(h!==i||o!==p)&&(s=(i=h).copy()).on(l,o=p),d.on=s}}function gA(e,n,i){var s=(e+="")=="transform"?gj:eE;return n==null?this.styleTween(e,dA(e,s)).on("end.style."+e,tE(e)):typeof n=="function"?this.styleTween(e,pA(e,s,Vg(this,"style."+e,n))).each(mA(this._id,e)):this.styleTween(e,hA(e,s,n),i).on("end.style."+e,null)}function vA(e,n,i){return function(s){this.style.setProperty(e,n.call(this,s),i)}}function yA(e,n,i){var s,o;function u(){var l=n.apply(this,arguments);return l!==o&&(s=(o=l)&&vA(e,l,i)),s}return u._value=n,u}function wA(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,yA(e,n,i??""))}function xA(e){return function(){this.textContent=e}}function _A(e){return function(){var n=e(this);this.textContent=n??""}}function SA(e){return this.tween("text",typeof e=="function"?_A(Vg(this,"text",e)):xA(e==null?"":e+""))}function bA(e){return function(n){this.textContent=e.call(this,n)}}function kA(e){var n,i;function s(){var o=e.apply(this,arguments);return o!==i&&(n=(i=o)&&bA(o)),n}return s._value=e,s}function EA(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,kA(e))}function NA(){for(var e=this._name,n=this._id,i=nE(),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=Vn(d,n);Mu(d,e,i,h,l,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new kr(s,this._parents,e,i)}function CA(){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=sr(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 TA=0;function kr(e,n,i,s){this._groups=e,this._parents=n,this._name=i,this._id=s}function nE(){return++TA}var xr=zo.prototype;kr.prototype={constructor:kr,select:uA,selectAll:lA,selectChild:xr.selectChild,selectChildren:xr.selectChildren,filter:tA,merge:nA,selection:fA,transition:NA,call:xr.call,nodes:xr.nodes,node:xr.node,size:xr.size,empty:xr.empty,each:xr.each,on:sA,attr:Dj,attrTween:Hj,style:gA,styleTween:wA,text:SA,textTween:EA,remove:aA,tween:Ij,delay:Gj,duration:Xj,ease:Zj,easeVarying:eA,end:CA,[Symbol.iterator]:xr[Symbol.iterator]};function RA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jA={time:null,delay:0,duration:250,ease:RA};function AA(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 IA(e){var n,i;e instanceof kr?(n=e._id,e=e._name):(n=nE(),(i=jA).time=Ug(),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])&&Mu(d,e,n,h,l,i||AA(d,n));return new kr(s,this._parents,e,n)}zo.prototype.interrupt=Rj;zo.prototype.transition=IA;const iu=e=>()=>e;function MA(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 Sr(e,n,i){this.k=e,this.x=n,this.y=i}Sr.prototype={constructor:Sr,scale:function(e){return e===1?this:new Sr(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Sr(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 br=new Sr(1,0,0);Sr.prototype;function Hc(e){e.stopImmediatePropagation()}function _o(e){e.preventDefault(),e.stopImmediatePropagation()}function PA(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function OA(){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 yw(){return this.__zoom||br}function qA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function LA(){return navigator.maxTouchPoints||"ontouchstart"in this}function $A(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 rE(){var e=PA,n=OA,i=$A,s=qA,o=LA,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=_j,h=ju("start","zoom","end"),p,m,y,x=500,N=150,_=0,S=10;function b(j){j.property("__zoom",yw).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",L).filter(o).on("touchstart.zoom",F).on("touchmove.zoom",J).on("touchend.zoom touchcancel.zoom",X).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(j,G,U,ne){var K=j.selection?j.selection():j;K.property("__zoom",yw),j!==K?A(j,G,U,ne):K.interrupt().each(function(){P(this,arguments).event(ne).start().zoom(null,typeof G=="function"?G.apply(this,arguments):G).end()})},b.scaleBy=function(j,G,U,ne){b.scaleTo(j,function(){var K=this.__zoom.k,$=typeof G=="function"?G.apply(this,arguments):G;return K*$},U,ne)},b.scaleTo=function(j,G,U,ne){b.transform(j,function(){var K=n.apply(this,arguments),$=this.__zoom,W=U==null?C(K):typeof U=="function"?U.apply(this,arguments):U,O=$.invert(W),B=typeof G=="function"?G.apply(this,arguments):G;return i(E(k($,B),W,O),K,l)},U,ne)},b.translateBy=function(j,G,U,ne){b.transform(j,function(){return i(this.__zoom.translate(typeof G=="function"?G.apply(this,arguments):G,typeof U=="function"?U.apply(this,arguments):U),n.apply(this,arguments),l)},null,ne)},b.translateTo=function(j,G,U,ne,K){b.transform(j,function(){var $=n.apply(this,arguments),W=this.__zoom,O=ne==null?C($):typeof ne=="function"?ne.apply(this,arguments):ne;return i(br.translate(O[0],O[1]).scale(W.k).translate(typeof G=="function"?-G.apply(this,arguments):-G,typeof U=="function"?-U.apply(this,arguments):-U),$,l)},ne,K)};function k(j,G){return G=Math.max(u[0],Math.min(u[1],G)),G===j.k?j:new Sr(G,j.x,j.y)}function E(j,G,U){var ne=G[0]-U[0]*j.k,K=G[1]-U[1]*j.k;return ne===j.x&&K===j.y?j:new Sr(j.k,ne,K)}function C(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function A(j,G,U,ne){j.on("start.zoom",function(){P(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(ne).end()}).tween("zoom",function(){var K=this,$=arguments,W=P(K,$).event(ne),O=n.apply(K,$),B=U==null?C(O):typeof U=="function"?U.apply(K,$):U,ae=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),z=K.__zoom,H=typeof G=="function"?G.apply(K,$):G,ee=d(z.invert(B).concat(ae/z.k),H.invert(B).concat(ae/H.k));return function(se){if(se===1)se=H;else{var ce=ee(se),me=ae/ce[2];se=new Sr(me,B[0]-ce[0]*me,B[1]-ce[1]*me)}W.zoom(null,se)}})}function P(j,G,U){return!U&&j.__zooming||new I(j,G)}function I(j,G){this.that=j,this.args=G,this.active=0,this.sourceEvent=null,this.extent=n.apply(j,G),this.taps=0}I.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,G){return this.mouse&&j!=="mouse"&&(this.mouse[1]=G.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=G.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=G.invert(this.touch1[0])),this.that.__zoom=G,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var G=Tn(this.that).datum();h.call(j,this.that,new MA(j,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),G)}};function M(j,...G){if(!e.apply(this,arguments))return;var U=P(this,G).event(j),ne=this.__zoom,K=Math.max(u[0],Math.min(u[1],ne.k*Math.pow(2,s.apply(this,arguments)))),$=zn(j);if(U.wheel)(U.mouse[0][0]!==$[0]||U.mouse[0][1]!==$[1])&&(U.mouse[1]=ne.invert(U.mouse[0]=$)),clearTimeout(U.wheel);else{if(ne.k===K)return;U.mouse=[$,ne.invert($)],vu(this),U.start()}_o(j),U.wheel=setTimeout(W,N),U.zoom("mouse",i(E(k(ne,K),U.mouse[0],U.mouse[1]),U.extent,l));function W(){U.wheel=null,U.end()}}function R(j,...G){if(y||!e.apply(this,arguments))return;var U=j.currentTarget,ne=P(this,G,!0).event(j),K=Tn(j.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",ae,!0),$=zn(j,U),W=j.clientX,O=j.clientY;Bk(j.view),Hc(j),ne.mouse=[$,this.__zoom.invert($)],vu(this),ne.start();function B(z){if(_o(z),!ne.moved){var H=z.clientX-W,ee=z.clientY-O;ne.moved=H*H+ee*ee>_}ne.event(z).zoom("mouse",i(E(ne.that.__zoom,ne.mouse[0]=zn(z,U),ne.mouse[1]),ne.extent,l))}function ae(z){K.on("mousemove.zoom mouseup.zoom",null),Uk(z.view,ne.moved),_o(z),ne.event(z).end()}}function L(j,...G){if(e.apply(this,arguments)){var U=this.__zoom,ne=zn(j.changedTouches?j.changedTouches[0]:j,this),K=U.invert(ne),$=U.k*(j.shiftKey?.5:2),W=i(E(k(U,$),ne,K),n.apply(this,G),l);_o(j),c>0?Tn(this).transition().duration(c).call(A,W,ne,j):Tn(this).call(b.transform,W,ne,j)}}function F(j,...G){if(e.apply(this,arguments)){var U=j.touches,ne=U.length,K=P(this,G,j.changedTouches.length===ne).event(j),$,W,O,B;for(Hc(j),W=0;W<ne;++W)O=U[W],B=zn(O,this),B=[B,this.__zoom.invert(B),O.identifier],K.touch0?!K.touch1&&K.touch0[2]!==B[2]&&(K.touch1=B,K.taps=0):(K.touch0=B,$=!0,K.taps=1+!!p);p&&(p=clearTimeout(p)),$&&(K.taps<2&&(m=B[0],p=setTimeout(function(){p=null},x)),vu(this),K.start())}}function J(j,...G){if(this.__zooming){var U=P(this,G).event(j),ne=j.changedTouches,K=ne.length,$,W,O,B;for(_o(j),$=0;$<K;++$)W=ne[$],O=zn(W,this),U.touch0&&U.touch0[2]===W.identifier?U.touch0[0]=O:U.touch1&&U.touch1[2]===W.identifier&&(U.touch1[0]=O);if(W=U.that.__zoom,U.touch1){var ae=U.touch0[0],z=U.touch0[1],H=U.touch1[0],ee=U.touch1[1],se=(se=H[0]-ae[0])*se+(se=H[1]-ae[1])*se,ce=(ce=ee[0]-z[0])*ce+(ce=ee[1]-z[1])*ce;W=k(W,Math.sqrt(se/ce)),O=[(ae[0]+H[0])/2,(ae[1]+H[1])/2],B=[(z[0]+ee[0])/2,(z[1]+ee[1])/2]}else if(U.touch0)O=U.touch0[0],B=U.touch0[1];else return;U.zoom("touch",i(E(W,O,B),U.extent,l))}}function X(j,...G){if(this.__zooming){var U=P(this,G).event(j),ne=j.changedTouches,K=ne.length,$,W;for(Hc(j),y&&clearTimeout(y),y=setTimeout(function(){y=null},x),$=0;$<K;++$)W=ne[$],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=zn(W,this),Math.hypot(m[0]-W[0],m[1]-W[1])<S)){var O=Tn(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return b.wheelDelta=function(j){return arguments.length?(s=typeof j=="function"?j:iu(+j),b):s},b.filter=function(j){return arguments.length?(e=typeof j=="function"?j:iu(!!j),b):e},b.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:iu(!!j),b):o},b.extent=function(j){return arguments.length?(n=typeof j=="function"?j:iu([[+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}Tk();const Pu=q.createContext(null),DA=Pu.Provider,Er={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.`},iE=Er.error001();function Qe(e,n){const i=q.useContext(Pu);if(i===null)throw new Error(iE);return Rk(i,e,n)}const Nt=()=>{const e=q.useContext(Pu);if(e===null)throw new Error(iE);return q.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},FA=e=>e.userSelectionActive?"none":"all";function Wg({position:e,children:n,className:i,style:s,...o}){const u=Qe(FA),l=`${e}`.split("-");return oe.createElement("div",{className:Ot(["react-flow__panel",i,...l]),style:{...s,pointerEvents:u},...o},n)}function zA({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:oe.createElement(Wg,{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 BA=({x:e,y:n,label:i,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:u={},labelBgPadding:l=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...p})=>{const m=q.useRef(null),[y,x]=q.useState({x:0,y:0,width:0,height:0}),N=Ot(["react-flow__edge-textwrapper",h]);return q.useEffect(()=>{if(m.current){const _=m.current.getBBox();x({x:_.x,y:_.y,width:_.width,height:_.height})}},[i]),typeof i>"u"||!i?null:oe.createElement("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:N,visibility:y.width?"visible":"hidden",...p},o&&oe.createElement("rect",{width:y.width+2*l[0],x:-l[0],y:-l[1],height:y.height+2*l[1],className:"react-flow__edge-textbg",style:u,rx:c,ry:c}),oe.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:s},i),d)};var UA=q.memo(BA);const Gg=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ps=(e,n=0,i=1)=>Math.min(Math.max(e,n),i),Yg=(e={x:0,y:0},n)=>({x:Ps(e.x,n[0][0],n[1][0]),y:Ps(e.y,n[0][1],n[1][1])}),ww=(e,n,i)=>e<n?Ps(Math.abs(e-n),1,50)/50:e>i?-Ps(Math.abs(e-i),1,50)/50:0,sE=(e,n)=>{const i=ww(e.x,35,n.width-35)*20,s=ww(e.y,35,n.height-35)*20;return[i,s]},oE=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},aE=(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)}),Lo=({x:e,y:n,width:i,height:s})=>({x:e,y:n,x2:e+i,y2:n+s}),uE=({x:e,y:n,x2:i,y2:s})=>({x:e,y:n,width:i-e,height:s-n}),xw=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),HA=(e,n)=>uE(aE(Lo(e),Lo(n))),Eg=(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)},VA=e=>Rn(e.width)&&Rn(e.height)&&Rn(e.x)&&Rn(e.y),Rn=e=>!isNaN(e)&&isFinite(e),mt=Symbol.for("internals"),lE=["Enter"," ","Escape"],WA=(e,n)=>{},GA=e=>"nativeEvent"in e;function Ng(e){var o,u;const n=GA(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 cE=e=>"clientX"in e,ri=(e,n)=>{var u,l;const i=cE(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)}},ku=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Uo=({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&&Rn(i)&&Rn(s)?oe.createElement(UA,{x:i,y:s,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);Uo.displayName="BaseEdge";function So(e,n,i){return i===void 0?i:s=>{const o=n().edges.find(u=>u.id===e);o&&i(s,{...o})}}function fE({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 dE({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 Fi;(function(e){e.Strict="strict",e.Loose="loose"})(Fi||(Fi={}));var Oi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Oi||(Oi={}));var $o;(function(e){e.Partial="partial",e.Full="full"})($o||($o={}));var ni;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ni||(ni={}));var Eu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Eu||(Eu={}));var Ce;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ce||(Ce={}));function _w({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 hE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:u=Ce.Top}){const[l,c]=_w({pos:i,x1:e,y1:n,x2:s,y2:o}),[d,h]=_w({pos:u,x1:s,y1:o,x2:e,y2:n}),[p,m,y,x]=dE({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 Kg=q.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:u=Ce.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:_})=>{const[S,b,k]=hE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:u});return oe.createElement(Uo,{path:S,labelX:b,labelY:k,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:_})});Kg.displayName="SimpleBezierEdge";const Sw={[Ce.Left]:{x:-1,y:0},[Ce.Right]:{x:1,y:0},[Ce.Top]:{x:0,y:-1},[Ce.Bottom]:{x:0,y:1}},YA=({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},bw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function KA({source:e,sourcePosition:n=Ce.Bottom,target:i,targetPosition:s=Ce.Top,center:o,offset:u}){const l=Sw[n],c=Sw[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=YA({source:d,sourcePosition:n,target:h}),m=p.x!==0?"x":"y",y=p[m];let x=[],N,_;const S={x:0,y:0},b={x:0,y:0},[k,E,C,A]=fE({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(l[m]*c[m]===-1){N=o.x??k,_=o.y??E;const I=[{x:N,y:d.y},{x:N,y:h.y}],M=[{x:d.x,y:_},{x:h.x,y:_}];l[m]===y?x=m==="x"?I:M:x=m==="x"?M:I}else{const I=[{x:d.x,y:h.y}],M=[{x:h.x,y:d.y}];if(m==="x"?x=l.x===y?M:I:x=l.y===y?I:M,n===s){const X=Math.abs(e[m]-i[m]);if(X<=u){const j=Math.min(u-1,u-X);l[m]===y?S[m]=(d[m]>e[m]?-1:1)*j:b[m]=(h[m]>i[m]?-1:1)*j}}if(n!==s){const X=m==="x"?"y":"x",j=l[m]===c[X],G=d[X]>h[X],U=d[X]<h[X];(l[m]===1&&(!j&&G||j&&U)||l[m]!==1&&(!j&&U||j&&G))&&(x=m==="x"?I:M)}const R={x:d.x+S.x,y:d.y+S.y},L={x:h.x+b.x,y:h.y+b.y},F=Math.max(Math.abs(R.x-x[0].x),Math.abs(L.x-x[0].x)),J=Math.max(Math.abs(R.y-x[0].y),Math.abs(L.y-x[0].y));F>=J?(N=(R.x+L.x)/2,_=x[0].y):(N=x[0].x,_=(R.y+L.y)/2)}return[[e,{x:d.x+S.x,y:d.y+S.y},...x,{x:h.x+b.x,y:h.y+b.y},i],N,_,C,A]}function XA(e,n,i,s){const o=Math.min(bw(e,n)/2,bw(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 Cg({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:u=Ce.Top,borderRadius:l=5,centerX:c,centerY:d,offset:h=20}){const[p,m,y,x,N]=KA({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=XA(p[k-1],b,p[k+1],l):E=`${k===0?"M":"L"}${b.x} ${b.y}`,S+=E,S},""),m,y,x,N]}const Ou=q.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,sourcePosition:m=Ce.Bottom,targetPosition:y=Ce.Top,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:S})=>{const[b,k,E]=Cg({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(Uo,{path:b,labelX:k,labelY:E,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,markerEnd:x,markerStart:N,interactionWidth:S})});Ou.displayName="SmoothStepEdge";const Xg=q.memo(e=>{var n;return oe.createElement(Ou,{...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])})});Xg.displayName="StepEdge";function QA({sourceX:e,sourceY:n,targetX:i,targetY:s}){const[o,u,l,c]=fE({sourceX:e,sourceY:n,targetX:i,targetY:s});return[`M ${e},${n}L ${i},${s}`,o,u,l,c]}const Qg=q.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:x})=>{const[N,_,S]=QA({sourceX:e,sourceY:n,targetX:i,targetY:s});return oe.createElement(Uo,{path:N,labelX:_,labelY:S,label:o,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:p,markerEnd:m,markerStart:y,interactionWidth:x})});Qg.displayName="StraightEdge";function su(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function kw({pos:e,x1:n,y1:i,x2:s,y2:o,c:u}){switch(e){case Ce.Left:return[n-su(n-s,u),i];case Ce.Right:return[n+su(s-n,u),i];case Ce.Top:return[n,i-su(i-o,u)];case Ce.Bottom:return[n,i+su(o-i,u)]}}function pE({sourceX:e,sourceY:n,sourcePosition:i=Ce.Bottom,targetX:s,targetY:o,targetPosition:u=Ce.Top,curvature:l=.25}){const[c,d]=kw({pos:i,x1:e,y1:n,x2:s,y2:o,c:l}),[h,p]=kw({pos:u,x1:s,y1:o,x2:e,y2:n,c:l}),[m,y,x,N]=dE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:p});return[`M${e},${n} C${c},${d} ${h},${p} ${s},${o}`,m,y,x,N]}const Nu=q.memo(({sourceX:e,sourceY:n,targetX:i,targetY:s,sourcePosition:o=Ce.Bottom,targetPosition:u=Ce.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:S})=>{const[b,k,E]=pE({sourceX:e,sourceY:n,sourcePosition:o,targetX:i,targetY:s,targetPosition:u,curvature:_==null?void 0:_.curvature});return oe.createElement(Uo,{path:b,labelX:k,labelY:E,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:S})});Nu.displayName="BezierEdge";const Zg=q.createContext(null),ZA=Zg.Provider;Zg.Consumer;const JA=()=>q.useContext(Zg),eI=e=>"id"in e&&"source"in e&&"target"in e,tI=({source:e,sourceHandle:n,target:i,targetHandle:s})=>`reactflow__edge-${e}${n||""}-${i}${s||""}`,Tg=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,nI=(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)),rI=(e,n)=>{if(!e.source||!e.target)return n;let i;return eI(e)?i={...e}:i={...e,id:tI(e)},nI(i,n)?n:n.concat(i)},Rg=({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},mE=({x:e,y:n},[i,s,o])=>({x:e*o+i,y:n*o+s}),Li=(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}},qu=(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}=Li(o,n).positionAbsolute;return aE(s,Lo({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 uE(i)},gE=(e,n,[i,s,o]=[0,0,1],u=!1,l=!1,c=[0,0])=>{const d={x:(n.x-i)/o,y:(n.y-s)/o,width:n.width/o,height:n.height/o},h=[];return e.forEach(p=>{const{width:m,height:y,selectable:x=!0,hidden:N=!1}=p;if(l&&!x||N)return!1;const{positionAbsolute:_}=Li(p,c),S={x:_.x,y:_.y,width:m||0,height:y||0},b=Eg(d,S),k=typeof m>"u"||typeof y>"u"||m===null||y===null,E=u&&b>0,C=(m||0)*(y||0);(k||E||b>=C||p.dragging)&&h.push(p)}),h},vE=(e,n)=>{const i=e.map(s=>s.id);return n.filter(s=>i.includes(s.source)||i.includes(s.target))},yE=(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=Ps(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}},Mi=(e,n=0)=>e.transition().duration(n);function Ew(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 iI(e,n,i,s,o,u){const{x:l,y:c}=ri(e),h=n.elementsFromPoint(l,c).find(N=>N.classList.contains("react-flow__handle"));if(h){const N=h.getAttribute("data-nodeid");if(N){const _=Jg(void 0,h),S=h.getAttribute("data-handleid"),b=u({nodeId:N,id:S,type:_});if(b){const k=o.find(E=>E.nodeId===N&&E.type===_&&E.id===S);return{handle:{id:S,type:_,nodeId:N,x:(k==null?void 0:k.x)||i.x,y:(k==null?void 0:k.y)||i.y},validHandleResult:b}}}}let p=[],m=1/0;if(o.forEach(N=>{const _=Math.sqrt((N.x-i.x)**2+(N.y-i.y)**2);if(_<=s){const S=u(N);_<=m&&(_<m?p=[{handle:N,validHandleResult:S}]:_===m&&p.push({handle:N,validHandleResult:S}),m=_)}}),!p.length)return{handle:null,validHandleResult:wE()};if(p.length===1)return p[0];const y=p.some(({validHandleResult:N})=>N.isValid),x=p.some(({handle:N})=>N.type==="target");return p.find(({handle:N,validHandleResult:_})=>x?N.type==="target":y?_.isValid:!0)||p[0]}const sI={source:null,target:null,sourceHandle:null,targetHandle:null},wE=()=>({handleDomNode:null,isValid:!1,connection:sI,endHandle:null});function xE(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={...wE(),handleDomNode:d};if(d){const p=Jg(void 0,d),m=d.getAttribute("data-nodeid"),y=d.getAttribute("data-handleid"),x=d.classList.contains("connectable"),N=d.classList.contains("connectableend"),_={source:c?m:i,sourceHandle:c?y:s,target:c?i:m,targetHandle:c?s:y};h.connection=_,x&&N&&(n===Fi.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 oI({nodes:e,nodeId:n,handleId:i,handleType:s}){return e.reduce((o,u)=>{if(u[mt]){const{handleBounds:l}=u[mt];let c=[],d=[];l&&(c=Ew(u,l,"source",`${n}-${i}-${s}`),d=Ew(u,l,"target",`${n}-${i}-${s}`)),o.push(...c,...d)}return o},[])}function Jg(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Vc(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function aI(e,n){let i=null;return n?i="valid":e&&!n&&(i="invalid"),i}function _E({event:e,handleId:n,nodeId:i,onConnect:s,isTarget:o,getState:u,setState:l,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const p=oE(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:x,connectionRadius:N,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:k}=u();let E=0,C;const{x:A,y:P}=ri(e),I=p==null?void 0:p.elementFromPoint(A,P),M=Jg(d,I),R=y==null?void 0:y.getBoundingClientRect();if(!R||!M)return;let L,F=ri(e,R),J=!1,X=null,j=!1,G=null;const U=oI({nodes:b(),nodeId:i,handleId:n,handleType:M}),ne=()=>{if(!x)return;const[W,O]=sE(F,R);S({x:W,y:O}),E=requestAnimationFrame(ne)};l({connectionPosition:F,connectionStatus:null,connectionNodeId:i,connectionHandleId:n,connectionHandleType:M,connectionStartHandle:{nodeId:i,handleId:n,type:M},connectionEndHandle:null}),_==null||_(e,{nodeId:i,handleId:n,handleType:M});function K(W){const{transform:O}=u();F=ri(W,R);const{handle:B,validHandleResult:ae}=iI(W,p,Rg(F,O,!1,[1,1]),N,U,z=>xE(z,m,i,n,o?"target":"source",c,p));if(C=B,J||(ne(),J=!0),G=ae.handleDomNode,X=ae.connection,j=ae.isValid,l({connectionPosition:C&&j?mE({x:C.x,y:C.y},O):F,connectionStatus:aI(!!C,j),connectionEndHandle:ae.endHandle}),!C&&!j&&!G)return Vc(L);X.source!==X.target&&G&&(Vc(L),L=G,G.classList.add("connecting","react-flow__handle-connecting"),G.classList.toggle("valid",j),G.classList.toggle("react-flow__handle-valid",j))}function $(W){var O,B;(C||G)&&X&&j&&(s==null||s(X)),(B=(O=u()).onConnectEnd)==null||B.call(O,W),d&&(h==null||h(W)),Vc(L),k(),cancelAnimationFrame(E),J=!1,j=!1,X=null,G=null,p.removeEventListener("mousemove",K),p.removeEventListener("mouseup",$),p.removeEventListener("touchmove",K),p.removeEventListener("touchend",$)}p.addEventListener("mousemove",K),p.addEventListener("mouseup",$),p.addEventListener("touchmove",K),p.addEventListener("touchend",$)}const Nw=()=>!0,uI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),lI=(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}},SE=q.forwardRef(({type:e="source",position:n=Ce.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:u=!0,id:l,onConnect:c,children:d,className:h,onMouseDown:p,onTouchStart:m,...y},x)=>{var R,L;const N=l||null,_=e==="target",S=Nt(),b=JA(),{connectOnClick:k,noPanClassName:E}=Qe(uI,Et),{connecting:C,clickConnecting:A}=Qe(lI(b,N,e),Et);b||(L=(R=S.getState()).onError)==null||L.call(R,"010",Er.error010());const P=F=>{const{defaultEdgeOptions:J,onConnect:X,hasDefaultEdges:j}=S.getState(),G={...J,...F};if(j){const{edges:U,setEdges:ne}=S.getState();ne(rI(G,U))}X==null||X(G),c==null||c(G)},I=F=>{if(!b)return;const J=cE(F);o&&(J&&F.button===0||!J)&&_E({event:F,handleId:N,nodeId:b,onConnect:P,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:i||S.getState().isValidConnection||Nw}),J?p==null||p(F):m==null||m(F)},M=F=>{const{onClickConnectStart:J,onClickConnectEnd:X,connectionClickStartHandle:j,connectionMode:G,isValidConnection:U}=S.getState();if(!b||!j&&!o)return;if(!j){J==null||J(F,{nodeId:b,handleId:N,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:N}});return}const ne=oE(F.target),K=i||U||Nw,{connection:$,isValid:W}=xE({nodeId:b,id:N,type:e},G,j.nodeId,j.handleId||null,j.type,K,ne);W&&P($),X==null||X(F),S.setState({connectionClickStartHandle:null})};return oe.createElement("div",{"data-handleid":N,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${N}-${e}`,className:Ot(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",E,h,{source:!_,target:_,connectable:s,connectablestart:o,connectableend:u,connecting:A,connectionindicator:s&&(o&&!C||u&&C)}]),onMouseDown:I,onTouchStart:I,onClick:k?M:void 0,ref:x,...y},d)});SE.displayName="Handle";var Os=q.memo(SE);const bE=({data:e,isConnectable:n,targetPosition:i=Ce.Top,sourcePosition:s=Ce.Bottom})=>oe.createElement(oe.Fragment,null,oe.createElement(Os,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label,oe.createElement(Os,{type:"source",position:s,isConnectable:n}));bE.displayName="DefaultNode";var jg=q.memo(bE);const kE=({data:e,isConnectable:n,sourcePosition:i=Ce.Bottom})=>oe.createElement(oe.Fragment,null,e==null?void 0:e.label,oe.createElement(Os,{type:"source",position:i,isConnectable:n}));kE.displayName="InputNode";var EE=q.memo(kE);const NE=({data:e,isConnectable:n,targetPosition:i=Ce.Top})=>oe.createElement(oe.Fragment,null,oe.createElement(Os,{type:"target",position:i,isConnectable:n}),e==null?void 0:e.label);NE.displayName="OutputNode";var CE=q.memo(NE);const ev=()=>null;ev.displayName="GroupNode";const cI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),ou=e=>e.id;function fI(e,n){return Et(e.selectedNodes.map(ou),n.selectedNodes.map(ou))&&Et(e.selectedEdges.map(ou),n.selectedEdges.map(ou))}const TE=q.memo(({onSelectionChange:e})=>{const n=Nt(),{selectedNodes:i,selectedEdges:s}=Qe(cI,fI);return q.useEffect(()=>{const o={nodes:i,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(u=>u(o))},[i,s,e]),null});TE.displayName="SelectionListener";const dI=e=>!!e.onSelectionChange;function hI({onSelectionChange:e}){const n=Qe(dI);return e||n?oe.createElement(TE,{onSelectionChange:e}):null}const pI=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 xs(e,n){q.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function $e(e,n,i){q.useEffect(()=>{typeof n<"u"&&i({[e]:n})},[n])}const mI=({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:o,onConnectStart:u,onConnectEnd:l,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:p,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:x,elevateNodesOnSelect:N,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:k,onEdgesChange:E,elementsSelectable:C,connectionMode:A,snapGrid:P,snapToGrid:I,translateExtent:M,connectOnClick:R,defaultEdgeOptions:L,fitView:F,fitViewOptions:J,onNodesDelete:X,onEdgesDelete:j,onNodeDrag:G,onNodeDragStart:U,onNodeDragStop:ne,onSelectionDrag:K,onSelectionDragStart:$,onSelectionDragStop:W,noPanClassName:O,nodeOrigin:B,rfId:ae,autoPanOnConnect:z,autoPanOnNodeDrag:H,onError:ee,connectionRadius:se,isValidConnection:ce,nodeDragThreshold:me})=>{const{setNodes:ve,setEdges:Ae,setDefaultNodesAndEdges:Ue,setMinZoom:Me,setMaxZoom:Pe,setTranslateExtent:be,setNodeExtent:Fe,reset:we}=Qe(pI,Et),xe=Nt();return q.useEffect(()=>{const De=s==null?void 0:s.map(Xe=>({...Xe,...L}));return Ue(i,De),()=>{we()}},[]),$e("defaultEdgeOptions",L,xe.setState),$e("connectionMode",A,xe.setState),$e("onConnect",o,xe.setState),$e("onConnectStart",u,xe.setState),$e("onConnectEnd",l,xe.setState),$e("onClickConnectStart",c,xe.setState),$e("onClickConnectEnd",d,xe.setState),$e("nodesDraggable",h,xe.setState),$e("nodesConnectable",p,xe.setState),$e("nodesFocusable",m,xe.setState),$e("edgesFocusable",y,xe.setState),$e("edgesUpdatable",x,xe.setState),$e("elementsSelectable",C,xe.setState),$e("elevateNodesOnSelect",N,xe.setState),$e("snapToGrid",I,xe.setState),$e("snapGrid",P,xe.setState),$e("onNodesChange",k,xe.setState),$e("onEdgesChange",E,xe.setState),$e("connectOnClick",R,xe.setState),$e("fitViewOnInit",F,xe.setState),$e("fitViewOnInitOptions",J,xe.setState),$e("onNodesDelete",X,xe.setState),$e("onEdgesDelete",j,xe.setState),$e("onNodeDrag",G,xe.setState),$e("onNodeDragStart",U,xe.setState),$e("onNodeDragStop",ne,xe.setState),$e("onSelectionDrag",K,xe.setState),$e("onSelectionDragStart",$,xe.setState),$e("onSelectionDragStop",W,xe.setState),$e("noPanClassName",O,xe.setState),$e("nodeOrigin",B,xe.setState),$e("rfId",ae,xe.setState),$e("autoPanOnConnect",z,xe.setState),$e("autoPanOnNodeDrag",H,xe.setState),$e("onError",ee,xe.setState),$e("connectionRadius",se,xe.setState),$e("isValidConnection",ce,xe.setState),$e("nodeDragThreshold",me,xe.setState),xs(e,ve),xs(n,Ae),xs(_,Me),xs(S,Pe),xs(M,be),xs(b,Fe),null},Cw={display:"none"},gI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},RE="react-flow__node-desc",jE="react-flow__edge-desc",vI="react-flow__aria-live",yI=e=>e.ariaLiveMessage;function wI({rfId:e}){const n=Qe(yI);return oe.createElement("div",{id:`${vI}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:gI},n)}function xI({rfId:e,disableKeyboardA11y:n}){return oe.createElement(oe.Fragment,null,oe.createElement("div",{id:`${RE}-${e}`,style:Cw},"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:`${jE}-${e}`,style:Cw},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&oe.createElement(wI,{rfId:e}))}var Do=(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)&&Ng(x))return!1;const _=Rw(x.code,c);u.current.add(x[_]),Tw(l,u.current,!1)&&(x.preventDefault(),s(!0))},m=x=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&Ng(x))return!1;const _=Rw(x.code,c);Tw(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 Tw(e,n,i){return e.filter(s=>i||s.length===n.size).some(s=>s.every(o=>n.has(o)))}function Rw(e,n){return n.includes(e)?"code":"key"}function AE(e,n,i,s){var c,d;const o=e.parentNode||e.parentId;if(!o)return i;const u=n.get(o),l=Li(u,s);return AE(u,n,{x:(i.x??0)+l.x,y:(i.y??0)+l.y,z:(((c=u[mt])==null?void 0:c.z)??0)>(i.z??0)?((d=u[mt])==null?void 0:d.z)??0:i.z??0},s)}function IE(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}=AE(s,e,{...s.position,z:((u=s[mt])==null?void 0:u.z)??0},n);s.positionAbsolute={x:l,y:c},s[mt].z=d,i!=null&&i[s.id]&&(s[mt].isParent=!0)}})}function Wc(e,n,i,s){const o=new Map,u={},l=s?1e3:0;return e.forEach(c=>{var x;const d=(Rn(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,mt,{enumerable:!1,value:{handleBounds:y||(x=h==null?void 0:h[mt])==null?void 0:x.handleBounds,z:d}}),o.set(c.id,p)}),IE(o,i,u),o}function ME(e,n={}){const{getNodes:i,width:s,height:o,minZoom:u,maxZoom:l,d3Zoom:c,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:p,nodeOrigin:m}=e(),y=n.initial&&!h&&p;if(c&&d&&(y||!n.initial)){const N=i().filter(S=>{var k;const b=n.includeHiddenNodes?S.width&&S.height:!S.hidden;return(k=n.nodes)!=null&&k.length?b&&n.nodes.some(E=>E.id===S.id):b}),_=N.every(S=>S.width&&S.height);if(N.length>0&&_){const S=qu(N,m),{x:b,y:k,zoom:E}=yE(S,s,o,n.minZoom??u,n.maxZoom??l,n.padding??.1),C=br.translate(b,k).scale(E);return typeof n.duration=="number"&&n.duration>0?c.transform(Mi(d,n.duration),C):c.transform(d,C),!0}}return!1}function _I(e,n){return e.forEach(i=>{const s=n.get(i.id);s&&n.set(s.id,{...s,[mt]:s[mt],selected:i.selected})}),new Map(n)}function SI(e,n){return n.map(i=>{const s=e.find(o=>o.id===i.id);return s&&(i.selected=s.selected),i})}function au({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:_I(e,o)}),l==null||l(e)),n!=null&&n.length&&(h&&s({edges:SI(n,u)}),c==null||c(n))}const _s=()=>{},bI={zoomIn:_s,zoomOut:_s,zoomTo:_s,getZoom:()=>1,setViewport:_s,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:_s,fitBounds:_s,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},kI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),EI=()=>{const e=Nt(),{d3Zoom:n,d3Selection:i}=Qe(kI,Et);return q.useMemo(()=>i&&n?{zoomIn:o=>n.scaleBy(Mi(i,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(Mi(i,o==null?void 0:o.duration),1/1.2),zoomTo:(o,u)=>n.scaleTo(Mi(i,u==null?void 0:u.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,u)=>{const[l,c,d]=e.getState().transform,h=br.translate(o.x??l,o.y??c).scale(o.zoom??d);n.transform(Mi(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=>ME(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=br.translate(m,y).scale(p);n.transform(Mi(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}=yE(o,l,c,d,h,(u==null?void 0:u.padding)??.1),x=br.translate(p,m).scale(y);n.transform(Mi(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"),Rg(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 Rg(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=mE(o,u);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:bI,[n,i])};function Ho(){const e=EI(),n=Nt(),i=q.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),s=q.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=q.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(S=>({...S}))},[]),u=q.useCallback(_=>{const{edges:S=[]}=n.getState();return S.find(b=>b.id===_)},[]),l=q.useCallback(_=>{const{getNodes:S,setNodes:b,hasDefaultNodes:k,onNodesChange:E}=n.getState(),C=S(),A=typeof _=="function"?_(C):_;if(k)b(A);else if(E){const P=A.length===0?C.map(I=>({type:"remove",id:I.id})):A.map(I=>({item:I,type:"reset"}));E(P)}},[]),c=q.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:k,onEdgesChange:E}=n.getState(),C=typeof _=="function"?_(S):_;if(k)b(C);else if(E){const A=C.length===0?S.map(P=>({type:"remove",id:P.id})):C.map(P=>({item:P,type:"reset"}));E(A)}},[]),d=q.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:k,hasDefaultNodes:E,onNodesChange:C}=n.getState();if(E){const P=[...b(),...S];k(P)}else if(C){const A=S.map(P=>({item:P,type:"add"}));C(A)}},[]),h=q.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:k,hasDefaultEdges:E,onEdgesChange:C}=n.getState();if(E)k([...b,...S]);else if(C){const A=S.map(P=>({item:P,type:"add"}));C(A)}},[]),p=q.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[k,E,C]=b;return{nodes:_().map(A=>({...A})),edges:S.map(A=>({...A})),viewport:{x:k,y:E,zoom:C}}},[]),m=q.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:k,edges:E,hasDefaultNodes:C,hasDefaultEdges:A,onNodesDelete:P,onEdgesDelete:I,onNodesChange:M,onEdgesChange:R}=n.getState(),L=(_||[]).map(G=>G.id),F=(S||[]).map(G=>G.id),J=k().reduce((G,U)=>{const ne=U.parentNode||U.parentId,K=!L.includes(U.id)&&ne&&G.find(W=>W.id===ne);return(typeof U.deletable=="boolean"?U.deletable:!0)&&(L.includes(U.id)||K)&&G.push(U),G},[]),X=E.filter(G=>typeof G.deletable=="boolean"?G.deletable:!0),j=X.filter(G=>F.includes(G.id));if(J||j){const G=vE(J,X),U=[...j,...G],ne=U.reduce((K,$)=>(K.includes($.id)||K.push($.id),K),[]);if((A||C)&&(A&&n.setState({edges:E.filter(K=>!ne.includes(K.id))}),C&&(J.forEach(K=>{b.delete(K.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(I==null||I(U),R&&R(ne.map(K=>({id:K,type:"remove"})))),J.length>0&&(P==null||P(J),M)){const K=J.map($=>({id:$.id,type:"remove"}));M(K)}}},[]),y=q.useCallback(_=>{const S=VA(_),b=S?null:n.getState().nodeInternals.get(_.id);return!S&&!b?[null,null,S]:[S?_:xw(b),b,S]},[]),x=q.useCallback((_,S=!0,b)=>{const[k,E,C]=y(_);return k?(b||n.getState().getNodes()).filter(A=>{if(!C&&(A.id===E.id||!A.positionAbsolute))return!1;const P=xw(A),I=Eg(P,k);return S&&I>0||I>=k.width*k.height}):[]},[]),N=q.useCallback((_,S,b=!0)=>{const[k]=y(_);if(!k)return!1;const E=Eg(k,S);return b&&E>0||E>=k.width*k.height},[]);return q.useMemo(()=>({...e,getNodes:i,getNode:s,getEdges:o,getEdge:u,setNodes:l,setEdges:c,addNodes:d,addEdges:h,toObject:p,deleteElements:m,getIntersectingNodes:x,isNodeIntersecting:N}),[e,i,s,o,u,l,c,d,h,p,m,x,N])}const NI={actInsideInputWithModifier:!1};var CI=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const i=Nt(),{deleteElements:s}=Ho(),o=Do(e,NI),u=Do(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 TI(e){const n=Nt();q.useEffect(()=>{let i;const s=()=>{var u,l;if(!e.current)return;const o=Gg(e.current);(o.height===0||o.width===0)&&((l=(u=n.getState()).onError)==null||l.call(u,"004",Er.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 tv={position:"absolute",width:"100%",height:"100%",top:0,left:0},RI=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,uu=e=>({x:e.x,y:e.y,zoom:e.k}),Ss=(e,n)=>e.target.closest(`.${n}`),jw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Aw=e=>{const n=e.ctrlKey&&ku()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},jI=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),AI=({onMove:e,onMoveStart:n,onMoveEnd:i,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:u=!0,panOnScroll:l=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Oi.Free,zoomOnDoubleClick:h=!0,elementsSelectable:p,panOnDrag:m=!0,defaultViewport:y,translateExtent:x,minZoom:N,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:k,noWheelClassName:E,noPanClassName:C})=>{const A=q.useRef(),P=Nt(),I=q.useRef(!1),M=q.useRef(!1),R=q.useRef(null),L=q.useRef({x:0,y:0,zoom:0}),{d3Zoom:F,d3Selection:J,d3ZoomHandler:X,userSelectionActive:j}=Qe(jI,Et),G=Do(S),U=q.useRef(0),ne=q.useRef(!1),K=q.useRef();return TI(R),q.useEffect(()=>{if(R.current){const $=R.current.getBoundingClientRect(),W=rE().scaleExtent([N,_]).translateExtent(x),O=Tn(R.current).call(W),B=br.translate(y.x,y.y).scale(Ps(y.zoom,N,_)),ae=[[0,0],[$.width,$.height]],z=W.constrain()(B,ae,x);W.transform(O,z),W.wheelDelta(Aw),P.setState({d3Zoom:W,d3Selection:O,d3ZoomHandler:O.on("wheel.zoom"),transform:[z.x,z.y,z.k],domNode:R.current.closest(".react-flow")})}},[]),q.useEffect(()=>{J&&F&&(l&&!G&&!j?J.on("wheel.zoom",$=>{if(Ss($,E))return!1;$.preventDefault(),$.stopImmediatePropagation();const W=J.property("__zoom").k||1;if($.ctrlKey&&u){const ce=zn($),me=Aw($),ve=W*Math.pow(2,me);F.scaleTo(J,ve,ce,$);return}const O=$.deltaMode===1?20:1;let B=d===Oi.Vertical?0:$.deltaX*O,ae=d===Oi.Horizontal?0:$.deltaY*O;!ku()&&$.shiftKey&&d!==Oi.Vertical&&(B=$.deltaY*O,ae=0),F.translateBy(J,-(B/W)*c,-(ae/W)*c,{internal:!0});const z=uu(J.property("__zoom")),{onViewportChangeStart:H,onViewportChange:ee,onViewportChangeEnd:se}=P.getState();clearTimeout(K.current),ne.current||(ne.current=!0,n==null||n($,z),H==null||H(z)),ne.current&&(e==null||e($,z),ee==null||ee(z),K.current=setTimeout(()=>{i==null||i($,z),se==null||se(z),ne.current=!1},150))},{passive:!1}):typeof X<"u"&&J.on("wheel.zoom",function($,W){if(!b&&$.type==="wheel"&&!$.ctrlKey||Ss($,E))return null;$.preventDefault(),X.call(this,$,W)},{passive:!1}))},[j,l,d,J,F,X,G,u,b,E,n,e,i]),q.useEffect(()=>{F&&F.on("start",$=>{var B,ae;if(!$.sourceEvent||$.sourceEvent.internal)return null;U.current=(B=$.sourceEvent)==null?void 0:B.button;const{onViewportChangeStart:W}=P.getState(),O=uu($.transform);I.current=!0,L.current=O,((ae=$.sourceEvent)==null?void 0:ae.type)==="mousedown"&&P.setState({paneDragging:!0}),W==null||W(O),n==null||n($.sourceEvent,O)})},[F,n]),q.useEffect(()=>{F&&(j&&!I.current?F.on("zoom",null):j||F.on("zoom",$=>{var O;const{onViewportChange:W}=P.getState();if(P.setState({transform:[$.transform.x,$.transform.y,$.transform.k]}),M.current=!!(s&&jw(m,U.current??0)),(e||W)&&!((O=$.sourceEvent)!=null&&O.internal)){const B=uu($.transform);W==null||W(B),e==null||e($.sourceEvent,B)}}))},[j,F,e,m,s]),q.useEffect(()=>{F&&F.on("end",$=>{if(!$.sourceEvent||$.sourceEvent.internal)return null;const{onViewportChangeEnd:W}=P.getState();if(I.current=!1,P.setState({paneDragging:!1}),s&&jw(m,U.current??0)&&!M.current&&s($.sourceEvent),M.current=!1,(i||W)&&RI(L.current,$.transform)){const O=uu($.transform);L.current=O,clearTimeout(A.current),A.current=setTimeout(()=>{W==null||W(O),i==null||i($.sourceEvent,O)},l?150:0)}})},[F,l,m,i,s]),q.useEffect(()=>{F&&F.filter($=>{const W=G||o,O=u&&$.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&$.button===1&&$.type==="mousedown"&&(Ss($,"react-flow__node")||Ss($,"react-flow__edge")))return!0;if(!m&&!W&&!l&&!h&&!u||j||!h&&$.type==="dblclick"||Ss($,E)&&$.type==="wheel"||Ss($,C)&&($.type!=="wheel"||l&&$.type==="wheel"&&!G)||!u&&$.ctrlKey&&$.type==="wheel"||!W&&!l&&!O&&$.type==="wheel"||!m&&($.type==="mousedown"||$.type==="touchstart")||Array.isArray(m)&&!m.includes($.button)&&$.type==="mousedown")return!1;const B=Array.isArray(m)&&m.includes($.button)||!$.button||$.button<=1;return(!$.ctrlKey||$.type==="wheel")&&B})},[j,F,o,u,l,h,m,p,G]),oe.createElement("div",{className:"react-flow__renderer",ref:R,style:tv},k)},II=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function MI(){const{userSelectionActive:e,userSelectionRect:n}=Qe(II,Et);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 Iw(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 PI(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&&Iw(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&&Iw(s,l);break}case"remove":return s}return s.push(l),s},i)}function OI(e,n){return PI(e,n)}const ti=(e,n)=>({id:e,type:"select",selected:n});function Es(e,n){return e.reduce((i,s)=>{const o=n.includes(s.id);return!s.selected&&o?(s.selected=!0,i.push(ti(s.id,!0))):s.selected&&!o&&(s.selected=!1,i.push(ti(s.id,!1))),i},[])}const Gc=(e,n)=>i=>{i.target===n.current&&(e==null||e(i))},qI=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),PE=q.memo(({isSelecting:e,selectionMode:n=$o.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=Nt(),N=q.useRef(0),_=q.useRef(0),S=q.useRef(),{userSelectionActive:b,elementsSelectable:k,dragging:E}=Qe(qI,Et),C=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,_.current=0},A=X=>{u==null||u(X),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},P=X=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){X.preventDefault();return}l==null||l(X)},I=c?X=>c(X):void 0,M=X=>{const{resetSelectedElements:j,domNode:G}=x.getState();if(S.current=G==null?void 0:G.getBoundingClientRect(),!k||!e||X.button!==0||X.target!==y.current||!S.current)return;const{x:U,y:ne}=ri(X,S.current);j(),x.setState({userSelectionRect:{width:0,height:0,startX:U,startY:ne,x:U,y:ne}}),s==null||s(X)},R=X=>{const{userSelectionRect:j,nodeInternals:G,edges:U,transform:ne,onNodesChange:K,onEdgesChange:$,nodeOrigin:W,getNodes:O}=x.getState();if(!e||!S.current||!j)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const B=ri(X,S.current),ae=j.startX??0,z=j.startY??0,H={...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)},ee=O(),se=gE(G,H,ne,n===$o.Partial,!0,W),ce=vE(se,U).map(ve=>ve.id),me=se.map(ve=>ve.id);if(N.current!==me.length){N.current=me.length;const ve=Es(ee,me);ve.length&&(K==null||K(ve))}if(_.current!==ce.length){_.current=ce.length;const ve=Es(U,ce);ve.length&&($==null||$(ve))}x.setState({userSelectionRect:H})},L=X=>{if(X.button!==0)return;const{userSelectionRect:j}=x.getState();!b&&j&&X.target===y.current&&(A==null||A(X)),x.setState({nodesSelectionActive:N.current>0}),C(),o==null||o(X)},F=X=>{b&&(x.setState({nodesSelectionActive:N.current>0}),o==null||o(X)),C()},J=k&&(e||b);return oe.createElement("div",{className:Ot(["react-flow__pane",{dragging:E,selection:e}]),onClick:J?void 0:Gc(A,y),onContextMenu:Gc(P,y),onWheel:Gc(I,y),onMouseEnter:J?void 0:d,onMouseDown:J?M:void 0,onMouseMove:J?R:h,onMouseUp:J?L:void 0,onMouseLeave:J?F:p,ref:y,style:tv},m,oe.createElement(MI,null))});PE.displayName="Pane";function OE(e,n){const i=e.parentNode||e.parentId;if(!i)return!1;const s=n.get(i);return s?s.selected?!0:OE(s,n):!1}function Mw(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 LI(e,n,i,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!OE(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 $I(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function qE(e,n,i,s,o=[0,0],u){const l=$I(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}=Li(m,o).positionAbsolute;c=m&&Rn(y)&&Rn(x)&&Rn(m.width)&&Rn(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",Er.error005()),c=l;else if(e.extent&&d&&e.extent!=="parent"){const m=i.get(d),{x:y,y:x}=Li(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=Li(m,o).positionAbsolute}const p=c&&c!=="parent"?Yg(n,c):n;return{position:{x:p.x-h.x,y:p.y-h.y},positionAbsolute:p}}function Yc({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 Pw=(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,...Gg(d)}})};function bo(e,n,i){return i===void 0?i:s=>{const o=n().nodeInternals.get(e);o&&i(s,{...o})}}function Ag({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",Er.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 DI(){const e=Nt();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 Kc(e){return(n,i,s)=>e==null?void 0:e(n,s)}function LE({nodeRef:e,disabled:n=!1,noDragClassName:i,handleSelector:s,nodeId:o,isSelectable:u,selectNodesOnDrag:l}){const c=Nt(),[d,h]=q.useState(!1),p=q.useRef([]),m=q.useRef({x:null,y:null}),y=q.useRef(0),x=q.useRef(null),N=q.useRef({x:0,y:0}),_=q.useRef(null),S=q.useRef(!1),b=q.useRef(!1),k=q.useRef(!1),E=DI();return q.useEffect(()=>{if(e!=null&&e.current){const C=Tn(e.current),A=({x:M,y:R})=>{const{nodeInternals:L,onNodeDrag:F,onSelectionDrag:J,updateNodePositions:X,nodeExtent:j,snapGrid:G,snapToGrid:U,nodeOrigin:ne,onError:K}=c.getState();m.current={x:M,y:R};let $=!1,W={x:0,y:0,x2:0,y2:0};if(p.current.length>1&&j){const B=qu(p.current,ne);W=Lo(B)}if(p.current=p.current.map(B=>{const ae={x:M-B.distance.x,y:R-B.distance.y};U&&(ae.x=G[0]*Math.round(ae.x/G[0]),ae.y=G[1]*Math.round(ae.y/G[1]));const z=[[j[0][0],j[0][1]],[j[1][0],j[1][1]]];p.current.length>1&&j&&!B.extent&&(z[0][0]=B.positionAbsolute.x-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 H=qE(B,ae,L,z,ne,K);return $=$||B.position.x!==H.position.x||B.position.y!==H.position.y,B.position=H.position,B.positionAbsolute=H.positionAbsolute,B}),!$)return;X(p.current,!0,!0),h(!0);const O=o?F:Kc(J);if(O&&_.current){const[B,ae]=Yc({nodeId:o,dragItems:p.current,nodeInternals:L});O(_.current,B,ae)}},P=()=>{if(!x.current)return;const[M,R]=sE(N.current,x.current);if(M!==0||R!==0){const{transform:L,panBy:F}=c.getState();m.current.x=(m.current.x??0)-M/L[2],m.current.y=(m.current.y??0)-R/L[2],F({x:M,y:R})&&A(m.current)}y.current=requestAnimationFrame(P)},I=M=>{var ne;const{nodeInternals:R,multiSelectionActive:L,nodesDraggable:F,unselectNodesAndEdges:J,onNodeDragStart:X,onSelectionDragStart:j}=c.getState();b.current=!0;const G=o?X:Kc(j);(!l||!u)&&!L&&o&&((ne=R.get(o))!=null&&ne.selected||J()),o&&u&&l&&Ag({id:o,store:c,nodeRef:e});const U=E(M);if(m.current=U,p.current=LI(R,F,U,o),G&&p.current){const[K,$]=Yc({nodeId:o,dragItems:p.current,nodeInternals:R});G(M.sourceEvent,K,$)}};if(n)C.on(".drag",null);else{const M=K2().on("start",R=>{const{domNode:L,nodeDragThreshold:F}=c.getState();F===0&&I(R),k.current=!1;const J=E(R);m.current=J,x.current=(L==null?void 0:L.getBoundingClientRect())||null,N.current=ri(R.sourceEvent,x.current)}).on("drag",R=>{var X,j;const L=E(R),{autoPanOnNodeDrag:F,nodeDragThreshold:J}=c.getState();if(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!S.current&&b.current&&F&&(S.current=!0,P()),!b.current){const G=L.xSnapped-(((X=m==null?void 0:m.current)==null?void 0:X.x)??0),U=L.ySnapped-(((j=m==null?void 0:m.current)==null?void 0:j.y)??0);Math.sqrt(G*G+U*U)>J&&I(R)}(m.current.x!==L.xSnapped||m.current.y!==L.ySnapped)&&p.current&&b.current&&(_.current=R.sourceEvent,N.current=ri(R.sourceEvent,x.current),A(L))}}).on("end",R=>{if(!(!b.current||k.current)&&(h(!1),S.current=!1,b.current=!1,cancelAnimationFrame(y.current),p.current)){const{updateNodePositions:L,nodeInternals:F,onNodeDragStop:J,onSelectionDragStop:X}=c.getState(),j=o?J:Kc(X);if(L(p.current,!1,!1),j){const[G,U]=Yc({nodeId:o,dragItems:p.current,nodeInternals:F});j(R.sourceEvent,G,U)}}}).filter(R=>{const L=R.target;return!R.button&&(!i||!Mw(L,`.${i}`,e))&&(!s||Mw(L,s,e))});return C.call(M),()=>{C.on(".drag",null)}}}},[e,n,i,s,u,c,o,l,E]),d}function $E(){const e=Nt();return q.useCallback(i=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:u,getNodes:l,snapToGrid:c,snapGrid:d,onError:h,nodesDraggable:p}=e.getState(),m=l().filter(k=>k.selected&&(k.draggable||p&&typeof k.draggable>"u")),y=c?d[0]:5,x=c?d[1]:5,N=i.isShiftPressed?4:1,_=i.x*y*N,S=i.y*x*N,b=m.map(k=>{if(k.positionAbsolute){const E={x:k.positionAbsolute.x+_,y:k.positionAbsolute.y+S};c&&(E.x=d[0]*Math.round(E.x/d[0]),E.y=d[1]*Math.round(E.y/d[1]));const{positionAbsolute:C,position:A}=qE(k,E,s,o,void 0,h);k.position=A,k.positionAbsolute=C}return k});u(b,!0,!1)},[])}const Rs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var ko=e=>{const n=({id:i,type:s,data:o,xPos:u,yPos:l,xPosOrigin:c,yPosOrigin:d,selected:h,onClick:p,onMouseEnter:m,onMouseMove:y,onMouseLeave:x,onContextMenu:N,onDoubleClick:_,style:S,className:b,isDraggable:k,isSelectable:E,isConnectable:C,isFocusable:A,selectNodesOnDrag:P,sourcePosition:I,targetPosition:M,hidden:R,resizeObserver:L,dragHandle:F,zIndex:J,isParent:X,noDragClassName:j,noPanClassName:G,initialized:U,disableKeyboardA11y:ne,ariaLabel:K,rfId:$,hasHandleBounds:W})=>{const O=Nt(),B=q.useRef(null),ae=q.useRef(null),z=q.useRef(I),H=q.useRef(M),ee=q.useRef(s),se=E||k||p||m||y||x,ce=$E(),me=bo(i,O.getState,m),ve=bo(i,O.getState,y),Ae=bo(i,O.getState,x),Ue=bo(i,O.getState,N),Me=bo(i,O.getState,_),Pe=we=>{const{nodeDragThreshold:xe}=O.getState();if(E&&(!P||!k||xe>0)&&Ag({id:i,store:O,nodeRef:B}),p){const De=O.getState().nodeInternals.get(i);De&&p(we,{...De})}},be=we=>{if(!Ng(we)&&!ne)if(lE.includes(we.key)&&E){const xe=we.key==="Escape";Ag({id:i,store:O,unselect:xe,nodeRef:B})}else k&&h&&Object.prototype.hasOwnProperty.call(Rs,we.key)&&(O.setState({ariaLiveMessage:`Moved selected node ${we.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~u}, y: ${~~l}`}),ce({x:Rs[we.key].x,y:Rs[we.key].y,isShiftPressed:we.shiftKey}))};q.useEffect(()=>()=>{ae.current&&(L==null||L.unobserve(ae.current),ae.current=null)},[]),q.useEffect(()=>{if(B.current&&!R){const we=B.current;(!U||!W||ae.current!==we)&&(ae.current&&(L==null||L.unobserve(ae.current)),L==null||L.observe(we),ae.current=we)}},[R,U,W]),q.useEffect(()=>{const we=ee.current!==s,xe=z.current!==I,De=H.current!==M;B.current&&(we||xe||De)&&(we&&(ee.current=s),xe&&(z.current=I),De&&(H.current=M),O.getState().updateNodeDimensions([{id:i,nodeElement:B.current,forceUpdate:!0}]))},[i,s,I,M]);const Fe=LE({nodeRef:B,disabled:R||!k,noDragClassName:j,handleSelector:F,nodeId:i,isSelectable:E,selectNodesOnDrag:P});return R?null:oe.createElement("div",{className:Ot(["react-flow__node",`react-flow__node-${s}`,{[G]:k},b,{selected:h,selectable:E,parent:X,dragging:Fe}]),ref:B,style:{zIndex:J,transform:`translate(${c}px,${d}px)`,pointerEvents:se?"all":"none",visibility:U?"visible":"hidden",...S},"data-id":i,"data-testid":`rf__node-${i}`,onMouseEnter:me,onMouseMove:ve,onMouseLeave:Ae,onContextMenu:Ue,onClick:Pe,onDoubleClick:Me,onKeyDown:A?be:void 0,tabIndex:A?0:void 0,role:A?"button":void 0,"aria-describedby":ne?void 0:`${RE}-${$}`,"aria-label":K},oe.createElement(ZA,{value:i},oe.createElement(e,{id:i,data:o,type:s,xPos:u,yPos:l,selected:h,isConnectable:C,sourcePosition:I,targetPosition:M,dragging:Fe,dragHandle:F,zIndex:J})))};return n.displayName="NodeWrapper",q.memo(n)};const FI=e=>{const n=e.getNodes().filter(i=>i.selected);return{...qu(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function zI({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:i}){const s=Nt(),{width:o,height:u,x:l,y:c,transformString:d,userSelectionActive:h}=Qe(FI,Et),p=$E(),m=q.useRef(null);if(q.useEffect(()=>{var N;i||(N=m.current)==null||N.focus({preventScroll:!0})},[i]),LE({nodeRef:m}),h||!o||!u)return null;const y=e?N=>{const _=s.getState().getNodes().filter(S=>S.selected);e(N,_)}:void 0,x=N=>{Object.prototype.hasOwnProperty.call(Rs,N.key)&&p({x:Rs[N.key].x,y:Rs[N.key].y,isShiftPressed:N.shiftKey})};return oe.createElement("div",{className:Ot(["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 BI=q.memo(zI);const UI=e=>e.nodesSelectionActive,DE=({children:e,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:u,onPaneScroll:l,deleteKeyCode:c,onMove:d,onMoveStart:h,onMoveEnd:p,selectionKeyCode:m,selectionOnDrag:y,selectionMode:x,onSelectionStart:N,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:A,panOnScroll:P,panOnScrollSpeed:I,panOnScrollMode:M,zoomOnDoubleClick:R,panOnDrag:L,defaultViewport:F,translateExtent:J,minZoom:X,maxZoom:j,preventScrolling:G,onSelectionContextMenu:U,noWheelClassName:ne,noPanClassName:K,disableKeyboardA11y:$})=>{const W=Qe(UI),O=Do(m),B=Do(b),ae=B||L,z=B||P,H=O||y&&ae!==!0;return CI({deleteKeyCode:c,multiSelectionKeyCode:S}),oe.createElement(AI,{onMove:d,onMoveStart:h,onMoveEnd:p,onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:A,panOnScroll:z,panOnScrollSpeed:I,panOnScrollMode:M,zoomOnDoubleClick:R,panOnDrag:!O&&ae,defaultViewport:F,translateExtent:J,minZoom:X,maxZoom:j,zoomActivationKeyCode:k,preventScrolling:G,noWheelClassName:ne,noPanClassName:K},oe.createElement(PE,{onSelectionStart:N,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:u,onPaneScroll:l,panOnDrag:ae,isSelecting:!!H,selectionMode:x},e,W&&oe.createElement(BI,{onSelectionContextMenu:U,noPanClassName:K,disableKeyboardA11y:$})))};DE.displayName="FlowRenderer";var HI=q.memo(DE);function VI(e){return Qe(q.useCallback(i=>e?gE(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[e]))}function WI(e){const n={input:ko(e.input||EE),default:ko(e.default||jg),output:ko(e.output||CE),group:ko(e.group||ev)},i={},s=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,u)=>(o[u]=ko(e[u]||jg),o),i);return{...n,...s}}const GI=({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]},YI=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),FE=e=>{const{nodesDraggable:n,nodesConnectable:i,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:u,onError:l}=Qe(YI,Et),c=VI(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:tv},c.map(p=>{var A,P,I;let m=p.type||"default";e.nodeTypes[m]||(l==null||l("003",Er.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,x=!!(p.draggable||n&&typeof p.draggable>"u"),N=!!(p.selectable||o&&typeof p.selectable>"u"),_=!!(p.connectable||i&&typeof p.connectable>"u"),S=!!(p.focusable||s&&typeof p.focusable>"u"),b=e.nodeExtent?Yg(p.positionAbsolute,e.nodeExtent):p.positionAbsolute,k=(b==null?void 0:b.x)??0,E=(b==null?void 0:b.y)??0,C=GI({x:k,y:E,width:p.width??0,height:p.height??0,origin:e.nodeOrigin});return oe.createElement(y,{key:p.id,id:p.id,className:p.className,style:p.style,type:m,data:p.data,sourcePosition:p.sourcePosition||Ce.Bottom,targetPosition:p.targetPosition||Ce.Top,hidden:p.hidden,xPos:k,yPos:E,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!p.selected,isDraggable:x,isSelectable:N,isConnectable:_,isFocusable:S,resizeObserver:h,dragHandle:p.dragHandle,zIndex:((A=p[mt])==null?void 0:A.z)??0,isParent:!!((P=p[mt])!=null&&P.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!p.width&&!!p.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:p.ariaLabel,hasHandleBounds:!!((I=p[mt])!=null&&I.handleBounds)})}))};FE.displayName="NodeRenderer";var KI=q.memo(FE);const XI=(e,n,i)=>i===Ce.Left?e-n:i===Ce.Right?e+n:e,QI=(e,n,i)=>i===Ce.Top?e-n:i===Ce.Bottom?e+n:e,Ow="react-flow__edgeupdater",qw=({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:Ot([Ow,`${Ow}-${c}`]),cx:XI(n,s,e),cy:QI(i,s,e),r:s,stroke:"transparent",fill:"transparent"}),ZI=()=>!0;var bs=e=>{const n=({id:i,className:s,type:o,data:u,onClick:l,onEdgeDoubleClick:c,selected:d,animated:h,label:p,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,style:S,source:b,target:k,sourceX:E,sourceY:C,targetX:A,targetY:P,sourcePosition:I,targetPosition:M,elementsSelectable:R,hidden:L,sourceHandleId:F,targetHandleId:J,onContextMenu:X,onMouseEnter:j,onMouseMove:G,onMouseLeave:U,reconnectRadius:ne,onReconnect:K,onReconnectStart:$,onReconnectEnd:W,markerEnd:O,markerStart:B,rfId:ae,ariaLabel:z,isFocusable:H,isReconnectable:ee,pathOptions:se,interactionWidth:ce,disableKeyboardA11y:me})=>{const ve=q.useRef(null),[Ae,Ue]=q.useState(!1),[Me,Pe]=q.useState(!1),be=Nt(),Fe=q.useMemo(()=>`url('#${Tg(B,ae)}')`,[B,ae]),we=q.useMemo(()=>`url('#${Tg(O,ae)}')`,[O,ae]);if(L)return null;const xe=tt=>{var Dt;const{edges:_t,addSelectedEdges:gt,unselectNodesAndEdges:ot,multiSelectionActive:gn}=be.getState(),$t=_t.find(vn=>vn.id===i);$t&&(R&&(be.setState({nodesSelectionActive:!1}),$t.selected&&gn?(ot({nodes:[],edges:[$t]}),(Dt=ve.current)==null||Dt.blur()):gt([i])),l&&l(tt,$t))},De=So(i,be.getState,c),Xe=So(i,be.getState,X),Ke=So(i,be.getState,j),et=So(i,be.getState,G),ze=So(i,be.getState,U),qe=(tt,_t)=>{if(tt.button!==0)return;const{edges:gt,isValidConnection:ot}=be.getState(),gn=_t?k:b,$t=(_t?J:F)||null,Dt=_t?"target":"source",vn=ot||ZI,Gn=_t,ct=gt.find(yn=>yn.id===i);Pe(!0),$==null||$(tt,ct,Dt);const Xt=yn=>{Pe(!1),W==null||W(yn,ct,Dt)};_E({event:tt,handleId:$t,nodeId:gn,onConnect:yn=>K==null?void 0:K(ct,yn),isTarget:Gn,getState:be.getState,setState:be.setState,isValidConnection:vn,edgeUpdaterType:Dt,onReconnectEnd:Xt})},qt=tt=>qe(tt,!0),Lt=tt=>qe(tt,!1),Ze=()=>Ue(!0),lt=()=>Ue(!1),At=!R&&!l,ht=tt=>{var _t;if(!me&&lE.includes(tt.key)&&R){const{unselectNodesAndEdges:gt,addSelectedEdges:ot,edges:gn}=be.getState();tt.key==="Escape"?((_t=ve.current)==null||_t.blur(),gt({edges:[gn.find(Dt=>Dt.id===i)]})):ot([i])}};return oe.createElement("g",{className:Ot(["react-flow__edge",`react-flow__edge-${o}`,s,{selected:d,animated:h,inactive:At,updating:Ae}]),onClick:xe,onDoubleClick:De,onContextMenu:Xe,onMouseEnter:Ke,onMouseMove:et,onMouseLeave:ze,onKeyDown:H?ht:void 0,tabIndex:H?0:void 0,role:H?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":z===null?void 0:z||`Edge from ${b} to ${k}`,"aria-describedby":H?`${jE}-${ae}`:void 0,ref:ve},!Me&&oe.createElement(e,{id:i,source:b,target:k,selected:d,animated:h,label:p,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,data:u,style:S,sourceX:E,sourceY:C,targetX:A,targetY:P,sourcePosition:I,targetPosition:M,sourceHandleId:F,targetHandleId:J,markerStart:Fe,markerEnd:we,pathOptions:se,interactionWidth:ce}),ee&&oe.createElement(oe.Fragment,null,(ee==="source"||ee===!0)&&oe.createElement(qw,{position:I,centerX:E,centerY:C,radius:ne,onMouseDown:qt,onMouseEnter:Ze,onMouseOut:lt,type:"source"}),(ee==="target"||ee===!0)&&oe.createElement(qw,{position:M,centerX:A,centerY:P,radius:ne,onMouseDown:Lt,onMouseEnter:Ze,onMouseOut:lt,type:"target"})))};return n.displayName="EdgeWrapper",q.memo(n)};function JI(e){const n={default:bs(e.default||Nu),straight:bs(e.bezier||Qg),step:bs(e.step||Xg),smoothstep:bs(e.step||Ou),simplebezier:bs(e.simplebezier||Kg)},i={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,u)=>(o[u]=bs(e[u]||Nu),o),i);return{...n,...s}}function Lw(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 $w(e,n){return e?e.length===1||!n?e[0]:n&&e.find(i=>i.id===n)||null:null}const eM=(e,n,i,s,o,u)=>{const l=Lw(i,e,n),c=Lw(u,s,o);return{sourceX:l.x,sourceY:l.y,targetX:c.x,targetY:c.y}};function tM({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=Lo({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 Dw(e){var s,o,u,l,c;const n=((s=e==null?void 0:e[mt])==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 nM=[{level:0,isMaxLevel:!0,edges:[]}];function rM(e,n,i=!1){let s=-1;const o=e.reduce((l,c)=>{var p,m;const d=Rn(c.zIndex);let h=d?c.zIndex:0;if(i){const y=n.get(c.target),x=n.get(c.source),N=c.selected||(y==null?void 0:y.selected)||(x==null?void 0:x.selected),_=Math.max(((p=x==null?void 0:x[mt])==null?void 0:p.z)||0,((m=y==null?void 0:y[mt])==null?void 0:m.z)||0,1e3);h=(d?c.zIndex:0)+(N?_:0)}return l[h]?l[h].push(c):l[h]=[c],s=h>s?h:s,l},{}),u=Object.entries(o).map(([l,c])=>{const d=+l;return{edges:c,level:d,isMaxLevel:d===s}});return u.length===0?nM:u}function iM(e,n,i){const s=Qe(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)&&tM({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 rM(s,n,i)}const sM=({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"}),oM=({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"}),Fw={[Eu.Arrow]:sM,[Eu.ArrowClosed]:oM};function aM(e){const n=Nt();return q.useMemo(()=>{var o,u;return Object.prototype.hasOwnProperty.call(Fw,e)?Fw[e]:((u=(o=n.getState()).onError)==null||u.call(o,"009",Er.error009(e)),null)},[e])}const uM=({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=aM(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},lM=({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=Tg(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))},zE=({defaultColor:e,rfId:n})=>{const i=Qe(q.useCallback(lM({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(uM,{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})))};zE.displayName="MarkerDefinitions";var cM=q.memo(zE);const fM=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}),BE=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:i,rfId:s,edgeTypes:o,noPanClassName:u,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:k,edgesUpdatable:E,elementsSelectable:C,width:A,height:P,connectionMode:I,nodeInternals:M,onError:R}=Qe(fM,Et),L=iM(n,M,i);return A?oe.createElement(oe.Fragment,null,L.map(({level:F,edges:J,isMaxLevel:X})=>oe.createElement("svg",{key:F,style:{zIndex:F},width:A,height:P,className:"react-flow__edges react-flow__container"},X&&oe.createElement(cM,{defaultColor:e,rfId:s}),oe.createElement("g",null,J.map(j=>{const[G,U,ne]=Dw(M.get(j.source)),[K,$,W]=Dw(M.get(j.target));if(!ne||!W)return null;let O=j.type||"default";o[O]||(R==null||R("011",Er.error011(O)),O="default");const B=o[O]||o.default,ae=I===Fi.Strict?$.target:($.target??[]).concat($.source??[]),z=$w(U.source,j.sourceHandle),H=$w(ae,j.targetHandle),ee=(z==null?void 0:z.position)||Ce.Bottom,se=(H==null?void 0:H.position)||Ce.Top,ce=!!(j.focusable||k&&typeof j.focusable>"u"),me=j.reconnectable||j.updatable,ve=typeof y<"u"&&(me||E&&typeof me>"u");if(!z||!H)return R==null||R("008",Er.error008(z,j)),null;const{sourceX:Ae,sourceY:Ue,targetX:Me,targetY:Pe}=eM(G,z,ee,K,H,se);return oe.createElement(B,{key:j.id,id:j.id,className:Ot([j.className,u]),type:O,data:j.data,selected:!!j.selected,animated:!!j.animated,hidden:!!j.hidden,label:j.label,labelStyle:j.labelStyle,labelShowBg:j.labelShowBg,labelBgStyle:j.labelBgStyle,labelBgPadding:j.labelBgPadding,labelBgBorderRadius:j.labelBgBorderRadius,style:j.style,source:j.source,target:j.target,sourceHandleId:j.sourceHandle,targetHandleId:j.targetHandle,markerEnd:j.markerEnd,markerStart:j.markerStart,sourceX:Ae,sourceY:Ue,targetX:Me,targetY:Pe,sourcePosition:ee,targetPosition:se,elementsSelectable:C,onContextMenu:l,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:p,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,rfId:s,ariaLabel:j.ariaLabel,isFocusable:ce,isReconnectable:ve,pathOptions:"pathOptions"in j?j.pathOptions:void 0,interactionWidth:j.interactionWidth,disableKeyboardA11y:b})})))),S):null};BE.displayName="EdgeRenderer";var dM=q.memo(BE);const hM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function pM({children:e}){const n=Qe(hM);return oe.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function mM(e){const n=Ho(),i=q.useRef(!1);q.useEffect(()=>{!i.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),i.current=!0)},[e,n.viewportInitialized])}const gM={[Ce.Left]:Ce.Right,[Ce.Right]:Ce.Left,[Ce.Top]:Ce.Bottom,[Ce.Bottom]:Ce.Top},UE=({nodeId:e,handleType:n,style:i,type:s=ni.Bezier,CustomComponent:o,connectionStatus:u})=>{var P,I,M;const{fromNode:l,handleId:c,toX:d,toY:h,connectionMode:p}=Qe(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]),Et),m=(P=l==null?void 0:l[mt])==null?void 0:P.handleBounds;let y=m==null?void 0:m[n];if(p===Fi.Loose&&(y=y||(m==null?void 0:m[n==="source"?"target":"source"])),!l||!y)return null;const x=c?y.find(R=>R.id===c):y[0],N=x?x.x+x.width/2:(l.width??0)/2,_=x?x.y+x.height/2:l.height??0,S=(((I=l.positionAbsolute)==null?void 0:I.x)??0)+N,b=(((M=l.positionAbsolute)==null?void 0:M.y)??0)+_,k=x==null?void 0:x.position,E=k?gM[k]:null;if(!k||!E)return null;if(o)return oe.createElement(o,{connectionLineType:s,connectionLineStyle:i,fromNode:l,fromHandle:x,fromX:S,fromY:b,toX:d,toY:h,fromPosition:k,toPosition:E,connectionStatus:u});let C="";const A={sourceX:S,sourceY:b,sourcePosition:k,targetX:d,targetY:h,targetPosition:E};return s===ni.Bezier?[C]=pE(A):s===ni.Step?[C]=Cg({...A,borderRadius:0}):s===ni.SmoothStep?[C]=Cg(A):s===ni.SimpleBezier?[C]=hE(A):C=`M${S},${b} ${d},${h}`,oe.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:i})};UE.displayName="ConnectionLine";const vM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function yM({containerStyle:e,style:n,type:i,component:s}){const{nodeId:o,handleType:u,nodesConnectable:l,width:c,height:d,connectionStatus:h}=Qe(vM,Et);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:Ot(["react-flow__connection",h])},oe.createElement(UE,{nodeId:o,handleType:u,style:n,type:i,CustomComponent:s,connectionStatus:h})))}function zw(e,n){return q.useRef(null),Nt(),q.useMemo(()=>n(e),[e])}const HE=({nodeTypes:e,edgeTypes:n,onMove:i,onMoveStart:s,onMoveEnd:o,onInit:u,onNodeClick:l,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:p,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:N,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:k,connectionLineComponent:E,connectionLineContainerStyle:C,selectionKeyCode:A,selectionOnDrag:P,selectionMode:I,multiSelectionKeyCode:M,panActivationKeyCode:R,zoomActivationKeyCode:L,deleteKeyCode:F,onlyRenderVisibleElements:J,elementsSelectable:X,selectNodesOnDrag:j,defaultViewport:G,translateExtent:U,minZoom:ne,maxZoom:K,preventScrolling:$,defaultMarkerColor:W,zoomOnScroll:O,zoomOnPinch:B,panOnScroll:ae,panOnScrollSpeed:z,panOnScrollMode:H,zoomOnDoubleClick:ee,panOnDrag:se,onPaneClick:ce,onPaneMouseEnter:me,onPaneMouseMove:ve,onPaneMouseLeave:Ae,onPaneScroll:Ue,onPaneContextMenu:Me,onEdgeContextMenu:Pe,onEdgeMouseEnter:be,onEdgeMouseMove:Fe,onEdgeMouseLeave:we,onReconnect:xe,onReconnectStart:De,onReconnectEnd:Xe,reconnectRadius:Ke,noDragClassName:et,noWheelClassName:ze,noPanClassName:qe,elevateEdgesOnSelect:qt,disableKeyboardA11y:Lt,nodeOrigin:Ze,nodeExtent:lt,rfId:At})=>{const ht=zw(e,WI),tt=zw(n,JI);return mM(u),oe.createElement(HI,{onPaneClick:ce,onPaneMouseEnter:me,onPaneMouseMove:ve,onPaneMouseLeave:Ae,onPaneContextMenu:Me,onPaneScroll:Ue,deleteKeyCode:F,selectionKeyCode:A,selectionOnDrag:P,selectionMode:I,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:M,panActivationKeyCode:R,zoomActivationKeyCode:L,elementsSelectable:X,onMove:i,onMoveStart:s,onMoveEnd:o,zoomOnScroll:O,zoomOnPinch:B,zoomOnDoubleClick:ee,panOnScroll:ae,panOnScrollSpeed:z,panOnScrollMode:H,panOnDrag:se,defaultViewport:G,translateExtent:U,minZoom:ne,maxZoom:K,onSelectionContextMenu:N,preventScrolling:$,noDragClassName:et,noWheelClassName:ze,noPanClassName:qe,disableKeyboardA11y:Lt},oe.createElement(pM,null,oe.createElement(dM,{edgeTypes:tt,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:J,onEdgeContextMenu:Pe,onEdgeMouseEnter:be,onEdgeMouseMove:Fe,onEdgeMouseLeave:we,onReconnect:xe,onReconnectStart:De,onReconnectEnd:Xe,reconnectRadius:Ke,defaultMarkerColor:W,noPanClassName:qe,elevateEdgesOnSelect:!!qt,disableKeyboardA11y:Lt,rfId:At},oe.createElement(yM,{style:k,type:b,component:E,containerStyle:C})),oe.createElement("div",{className:"react-flow__edgelabel-renderer"}),oe.createElement(KI,{nodeTypes:ht,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:p,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,selectNodesOnDrag:j,onlyRenderVisibleElements:J,noPanClassName:qe,noDragClassName:et,disableKeyboardA11y:Lt,nodeOrigin:Ze,nodeExtent:lt,rfId:At})))};HE.displayName="GraphView";var wM=q.memo(HE);const Ig=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Jr={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:Ig,nodeExtent:Ig,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Fi.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:WA,isValidConnection:void 0},xM=()=>aR((e,n)=>({...Jr,setNodes:i=>{const{nodeInternals:s,nodeOrigin:o,elevateNodesOnSelect:u}=n();e({nodeInternals:Wc(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?Wc(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,[mt]:{...b[mt],handleBounds:void 0}});else if(b){const k=Gg(S.nodeElement);!!(k.width&&k.height&&(b.width!==k.width||b.height!==k.height||S.forceUpdate))&&(o.set(b.id,{...b,[mt]:{...b[mt],handleBounds:{source:Pw(".source",S.nodeElement,y,h),target:Pw(".target",S.nodeElement,y,h)}},...k}),_.push({id:b.id,type:"dimensions",dimensions:k}))}return _},[]);IE(o,h);const N=l||u&&!l&&ME(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:N}),(x==null?void 0:x.length)>0&&(s==null||s(x))},updateNodePositions:(i,s=!0,o=!1)=>{const{triggerNodeChanges:u}=n(),l=i.map(c=>{const d={id:c.id,type:"position",dragging:o};return s&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});u(l)},triggerNodeChanges:i=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:u,nodeOrigin:l,getNodes:c,elevateNodesOnSelect:d}=n();if(i!=null&&i.length){if(u){const h=OI(i,c()),p=Wc(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=>ti(d,!0)):(l=Es(u(),i),c=Es(o,[])),au({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=>ti(d,!0)):(l=Es(o,i),c=Es(u(),[])),au({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,ti(p.id,!1))),h=c.map(p=>ti(p.id,!1));au({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=>ti(c.id,!1)),l=i.filter(c=>c.selected).map(c=>ti(c.id,!1));au({changedNodes:u,changedEdges:l,get:n,set:e})},setNodeExtent:i=>{const{nodeInternals:s}=n();s.forEach(o=>{o.positionAbsolute=Yg(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=br.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:Jr.connectionNodeId,connectionHandleId:Jr.connectionHandleId,connectionHandleType:Jr.connectionHandleType,connectionStatus:Jr.connectionStatus,connectionStartHandle:Jr.connectionStartHandle,connectionEndHandle:Jr.connectionEndHandle}),reset:()=>e({...Jr})}),Object.is),nv=({children:e})=>{const n=q.useRef(null);return n.current||(n.current=xM()),oe.createElement(DA,{value:n.current},e)};nv.displayName="ReactFlowProvider";const VE=({children:e})=>q.useContext(Pu)?oe.createElement(oe.Fragment,null,e):oe.createElement(nv,null,e);VE.displayName="ReactFlowWrapper";const _M={input:EE,default:jg,output:CE,group:ev},SM={default:Nu,straight:Qg,step:Xg,smoothstep:Ou,simplebezier:Kg},bM=[0,0],kM=[15,15],EM={x:0,y:0,zoom:1},NM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},WE=q.forwardRef(({nodes:e,edges:n,defaultNodes:i,defaultEdges:s,className:o,nodeTypes:u=_M,edgeTypes:l=SM,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:A,onNodeDoubleClick:P,onNodeDragStart:I,onNodeDrag:M,onNodeDragStop:R,onNodesDelete:L,onEdgesDelete:F,onSelectionChange:J,onSelectionDragStart:X,onSelectionDrag:j,onSelectionDragStop:G,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:K,connectionMode:$=Fi.Strict,connectionLineType:W=ni.Bezier,connectionLineStyle:O,connectionLineComponent:B,connectionLineContainerStyle:ae,deleteKeyCode:z="Backspace",selectionKeyCode:H="Shift",selectionOnDrag:ee=!1,selectionMode:se=$o.Full,panActivationKeyCode:ce="Space",multiSelectionKeyCode:me=ku()?"Meta":"Control",zoomActivationKeyCode:ve=ku()?"Meta":"Control",snapToGrid:Ae=!1,snapGrid:Ue=kM,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Pe=!0,nodesDraggable:be,nodesConnectable:Fe,nodesFocusable:we,nodeOrigin:xe=bM,edgesFocusable:De,edgesUpdatable:Xe,elementsSelectable:Ke,defaultViewport:et=EM,minZoom:ze=.5,maxZoom:qe=2,translateExtent:qt=Ig,preventScrolling:Lt=!0,nodeExtent:Ze,defaultMarkerColor:lt="#b1b1b7",zoomOnScroll:At=!0,zoomOnPinch:ht=!0,panOnScroll:tt=!1,panOnScrollSpeed:_t=.5,panOnScrollMode:gt=Oi.Free,zoomOnDoubleClick:ot=!0,panOnDrag:gn=!0,onPaneClick:$t,onPaneMouseEnter:Dt,onPaneMouseMove:vn,onPaneMouseLeave:Gn,onPaneScroll:ct,onPaneContextMenu:Xt,children:Ft,onEdgeContextMenu:yn,onEdgeDoubleClick:Vt,onEdgeMouseEnter:Tr,onEdgeMouseMove:Rr,onEdgeMouseLeave:oi,onEdgeUpdate:Yn,onEdgeUpdateStart:jr,onEdgeUpdateEnd:Wt,onReconnect:Ar,onReconnectStart:Kn,onReconnectEnd:Vi,reconnectRadius:ar=10,edgeUpdaterRadius:Xn=10,onNodesChange:ln,onEdgesChange:Ir,noDragClassName:zs="nodrag",noWheelClassName:Wi="nowheel",noPanClassName:ai="nopan",fitView:In=!1,fitViewOptions:It,connectOnClick:Mr=!0,attributionPosition:Qn,proOptions:Zn,defaultEdgeOptions:Pr,elevateNodesOnSelect:Or=!0,elevateEdgesOnSelect:ui=!1,disableKeyboardA11y:ur=!1,autoPanOnConnect:Gi=!0,autoPanOnNodeDrag:rt=!0,connectionRadius:Yi=20,isValidConnection:li,onError:Ki,style:Jn,id:cn,nodeDragThreshold:qr,...lr},Qt)=>{const ci=cn||"1";return oe.createElement("div",{...lr,style:{...Jn,...NM},ref:Qt,className:Ot(["react-flow",o]),"data-testid":"rf__wrapper",id:cn},oe.createElement(VE,null,oe.createElement(wM,{onInit:h,onMove:p,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:A,onNodeDoubleClick:P,nodeTypes:u,edgeTypes:l,connectionLineType:W,connectionLineStyle:O,connectionLineComponent:B,connectionLineContainerStyle:ae,selectionKeyCode:H,selectionOnDrag:ee,selectionMode:se,deleteKeyCode:z,multiSelectionKeyCode:me,panActivationKeyCode:ce,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,selectNodesOnDrag:Pe,defaultViewport:et,translateExtent:qt,minZoom:ze,maxZoom:qe,preventScrolling:Lt,zoomOnScroll:At,zoomOnPinch:ht,zoomOnDoubleClick:ot,panOnScroll:tt,panOnScrollSpeed:_t,panOnScrollMode:gt,panOnDrag:gn,onPaneClick:$t,onPaneMouseEnter:Dt,onPaneMouseMove:vn,onPaneMouseLeave:Gn,onPaneScroll:ct,onPaneContextMenu:Xt,onSelectionContextMenu:U,onSelectionStart:ne,onSelectionEnd:K,onEdgeContextMenu:yn,onEdgeDoubleClick:Vt,onEdgeMouseEnter:Tr,onEdgeMouseMove:Rr,onEdgeMouseLeave:oi,onReconnect:Ar??Yn,onReconnectStart:Kn??jr,onReconnectEnd:Vi??Wt,reconnectRadius:ar??Xn,defaultMarkerColor:lt,noDragClassName:zs,noWheelClassName:Wi,noPanClassName:ai,elevateEdgesOnSelect:ui,rfId:ci,disableKeyboardA11y:ur,nodeOrigin:xe,nodeExtent:Ze}),oe.createElement(mI,{nodes:e,edges:n,defaultNodes:i,defaultEdges:s,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,nodesDraggable:be,nodesConnectable:Fe,nodesFocusable:we,edgesFocusable:De,edgesUpdatable:Xe,elementsSelectable:Ke,elevateNodesOnSelect:Or,minZoom:ze,maxZoom:qe,nodeExtent:Ze,onNodesChange:ln,onEdgesChange:Ir,snapToGrid:Ae,snapGrid:Ue,connectionMode:$,translateExtent:qt,connectOnClick:Mr,defaultEdgeOptions:Pr,fitView:In,fitViewOptions:It,onNodesDelete:L,onEdgesDelete:F,onNodeDragStart:I,onNodeDrag:M,onNodeDragStop:R,onSelectionDrag:j,onSelectionDragStart:X,onSelectionDragStop:G,noPanClassName:ai,nodeOrigin:xe,rfId:ci,autoPanOnConnect:Gi,autoPanOnNodeDrag:rt,onError:Ki,connectionRadius:Yi,isValidConnection:li,nodeDragThreshold:qr}),oe.createElement(hI,{onSelectionChange:J}),Ft,oe.createElement(zA,{proOptions:Zn,position:Qn}),oe.createElement(xI,{rfId:ci,disableKeyboardA11y:ur})))});WE.displayName="ReactFlow";const CM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function GE(){return Qe(CM,Et)}const YE=({id:e,x:n,y:i,width:s,height:o,style:u,color:l,strokeColor:c,strokeWidth:d,className:h,borderRadius:p,shapeRendering:m,onClick:y,selected:x})=>{const{background:N,backgroundColor:_}=u||{},S=l||N||_;return oe.createElement("rect",{className:Ot(["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})};YE.displayName="MiniMapNode";var TM=q.memo(YE);const RM=e=>e.nodeOrigin,jM=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),Xc=e=>e instanceof Function?e:()=>e;function AM({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:u=TM,onClick:l}){const c=Qe(jM,Et),d=Qe(RM),h=Xc(n),p=Xc(e),m=Xc(i),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return oe.createElement(oe.Fragment,null,c.map(x=>{const{x:N,y:_}=Li(x,d).positionAbsolute;return oe.createElement(u,{key:x.id,x:N,y:_,width:x.width,height:x.height,style:x.style,selected:x.selected,className:m(x),color:h(x),borderRadius:s,strokeColor:p(x),strokeWidth:o,shapeRendering:y,onClick:l,id:x.id})}))}var IM=q.memo(AM);const MM=200,PM=150,OM=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?HA(qu(n,e.nodeOrigin),i):i,rfId:e.rfId}},qM="react-flow__minimap-desc";function KE({style:e,className:n,nodeStrokeColor:i="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:u=5,nodeStrokeWidth:l=2,nodeComponent:c,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:p=1,position:m="bottom-right",onClick:y,onNodeClick:x,pannable:N=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:k=10,offsetScale:E=5}){const C=Nt(),A=q.useRef(null),{boundingRect:P,viewBB:I,rfId:M}=Qe(OM,Et),R=(e==null?void 0:e.width)??MM,L=(e==null?void 0:e.height)??PM,F=P.width/R,J=P.height/L,X=Math.max(F,J),j=X*R,G=X*L,U=E*X,ne=P.x-(j-P.width)/2-U,K=P.y-(G-P.height)/2-U,$=j+U*2,W=G+U*2,O=`${qM}-${M}`,B=q.useRef(0);B.current=X,q.useEffect(()=>{if(A.current){const H=Tn(A.current),ee=me=>{const{transform:ve,d3Selection:Ae,d3Zoom:Ue}=C.getState();if(me.sourceEvent.type!=="wheel"||!Ae||!Ue)return;const Me=-me.sourceEvent.deltaY*(me.sourceEvent.deltaMode===1?.05:me.sourceEvent.deltaMode?1:.002)*k,Pe=ve[2]*Math.pow(2,Me);Ue.scaleTo(Ae,Pe)},se=me=>{const{transform:ve,d3Selection:Ae,d3Zoom:Ue,translateExtent:Me,width:Pe,height:be}=C.getState();if(me.sourceEvent.type!=="mousemove"||!Ae||!Ue)return;const Fe=B.current*Math.max(1,ve[2])*(b?-1:1),we={x:ve[0]-me.sourceEvent.movementX*Fe,y:ve[1]-me.sourceEvent.movementY*Fe},xe=[[0,0],[Pe,be]],De=br.translate(we.x,we.y).scale(ve[2]),Xe=Ue.constrain()(De,xe,Me);Ue.transform(Ae,Xe)},ce=rE().on("zoom",N?se:null).on("zoom.wheel",_?ee:null);return H.call(ce),()=>{H.on("zoom",null)}}},[N,_,b,k]);const ae=y?H=>{const ee=zn(H);y(H,{x:ee[0],y:ee[1]})}:void 0,z=x?(H,ee)=>{const se=C.getState().nodeInternals.get(ee);x(H,se)}:void 0;return oe.createElement(Wg,{position:m,style:e,className:Ot(["react-flow__minimap",n]),"data-testid":"rf__minimap"},oe.createElement("svg",{width:R,height:L,viewBox:`${ne} ${K} ${$} ${W}`,role:"img","aria-labelledby":O,ref:A,onClick:ae},S&&oe.createElement("title",{id:O},S),oe.createElement(IM,{onClick:z,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:u,nodeClassName:o,nodeStrokeWidth:l,nodeComponent:c}),oe.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-U},${K-U}h${$+U*2}v${W+U*2}h${-$-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"})))}KE.displayName="MiniMap";var LM=q.memo(KE);function $M(){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 DM(){return oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},oe.createElement("path",{d:"M0 0h32v4.2H0z"}))}function FM(){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 zM(){return oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},oe.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 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 BM(){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 Ns=({children:e,className:n,...i})=>oe.createElement("button",{type:"button",className:Ot(["react-flow__controls-button",n]),...i},e);Ns.displayName="ControlButton";const UM=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),XE=({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=Nt(),[x,N]=q.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Qe(UM,Et),{zoomIn:k,zoomOut:E,fitView:C}=Ho();if(q.useEffect(()=>{N(!0)},[]),!x)return null;const A=()=>{k(),u==null||u()},P=()=>{E(),l==null||l()},I=()=>{C(o),c==null||c()},M=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),d==null||d(!_)};return oe.createElement(Wg,{className:Ot(["react-flow__controls",h]),position:m,style:e,"data-testid":"rf__controls"},n&&oe.createElement(oe.Fragment,null,oe.createElement(Ns,{onClick:A,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},oe.createElement($M,null)),oe.createElement(Ns,{onClick:P,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},oe.createElement(DM,null))),i&&oe.createElement(Ns,{className:"react-flow__controls-fitview",onClick:I,title:"fit view","aria-label":"fit view"},oe.createElement(FM,null)),s&&oe.createElement(Ns,{className:"react-flow__controls-interactive",onClick:M,title:"toggle interactivity","aria-label":"toggle interactivity"},_?oe.createElement(BM,null):oe.createElement(zM,null)),p)};XE.displayName="Controls";var HM=q.memo(XE),Un;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Un||(Un={}));function VM({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 WM({color:e,radius:n}){return oe.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const GM={[Un.Dots]:"#91919a",[Un.Lines]:"#eee",[Un.Cross]:"#e2e2e2"},YM={[Un.Dots]:1,[Un.Lines]:1,[Un.Cross]:6},KM=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function QE({id:e,variant:n=Un.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}=Qe(KM,Et),y=l||GM[n],x=s||YM[n],N=n===Un.Dots,_=n===Un.Cross,S=Array.isArray(i)?i:[i,i],b=[S[0]*p[2]||1,S[1]*p[2]||1],k=x*p[2],E=_?[k,k]:b,C=N?[k/u,k/u]:[E[0]/u,E[1]/u];return oe.createElement("svg",{className:Ot(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},oe.createElement("pattern",{id:m+e,x:p[0]%b[0],y:p[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},N?oe.createElement(WM,{color:y,radius:k/u}):oe.createElement(VM,{dimensions:E,color:y,lineWidth:o})),oe.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}QE.displayName="Background";var XM=q.memo(QE);function ZE(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function JE(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=JE(s,n+1);if(o)return o}return null}function QM(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens}const ZM=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function eN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const i=e;if(typeof i.model=="string"&&ZM.test(i.model))return i.model;for(const s of Object.values(i)){const o=eN(s,n+1);if(o)return o}return null}function Mg(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,totalEvents:0}}function ii(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function rv(e,n){return`${e}::${n}`}function Cu(e){return e.agent_type??e.subagent_type??"subagent"}function Pg(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Ao(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:ZE()},e.agents.set(o,u),u)}function tN(e,n,i,s){const o=rv(n,i),u=e.agents.get(o);if(!u)return null;!u.cwd&&s.cwd&&(u.cwd=s.cwd,u.cwdBasename=ii(s.cwd));const l=Cu(s);return l&&(u.label==="subagent"||!u.label)&&(u.label=l),u}function Bw(e,n,i){const s=n.session_id??"unknown",o=Pg(n);if(o){const d=tN(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(rv(s,l));if(d)return!d.cwd&&n.cwd&&(d.cwd=n.cwd,d.cwdBasename=ii(n.cwd)),d}const c=Ao(e,s,i,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=i),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=ii(n.cwd)),c.label==="session"&&n.cwd&&(c.label=ii(n.cwd)??"session"),c}function JM(e,n,i,s,o){const u=rv(n,i),l=Ao(e,n,o,!0);let c=e.agents.get(u);if(c){!c.cwd&&s.cwd&&(c.cwd=s.cwd,c.cwdBasename=ii(s.cwd));const d=Cu(s);return d&&(c.label==="subagent"||!c.label)&&(c.label=d),c}return c={id:u,sessionId:n,label:Cu(s),kind:"subagent",parentId:l.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:ii(s.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:ZE()},e.agents.set(u,c),l.childCount+=1,c}function eP(e,n,i){const s=e.activeSubagentStack.get(n)??[];s.push(i),e.activeSubagentStack.set(n,s)}function tP(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 Qc(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 Co(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 nP(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 rP(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 iP(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&&Co(o)}return s}function Uw(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{...Mg(),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=Bw(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=eN(i);switch(c&&(l.model=c),o){case"SessionStart":{const d=Ao(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=ii(i.cwd)),d.label==="session"&&i.cwd&&(d.label=ii(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=Ao(e,u,s,!1);d.state="active",d.endedAt=void 0,d.exitAt=void 0;const h=Bw(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=Qc(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:Qc(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),Co(l);break}case"PostToolUse":case"PostToolUseFailure":{const d=i.tool_use_id;if(!d)break;let h=e.toolIndex.get(d),p=!1;if(!h)for(const x of e.agents.values()){const N=x.tools.find(_=>_.id===d);if(N){h=N,p=!0;break}}if(!h)break;h.endedAt=s,h.ok=o==="PostToolUse",h.response=i.tool_response,o==="PostToolUseFailure"?h.errorPreview=Qc(i.tool_response):p&&(h.errorPreview=void 0);const m=JE(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&&QM(x.usage,m),Co(x))}break}case"SubagentStart":{const d=Pg(i);if(!d)break;const h=JM(e,u,d,i,s);h.state="active",h.startedAt=h.startedAt||s,h.exitAt=void 0,h.endedAt=void 0;const p=Cu(i);p&&(h.label=p),eP(e,u,d);break}case"SubagentStop":{const d=Pg(i);if(!d)break;const h=tN(e,u,d,i);if(!h)break;h.state="done",h.endedAt=s,Co(h),tP(e,u,d);break}case"Stop":case"SessionEnd":{const d=Ao(e,u,s,!1);d.state="done",d.endedAt=s,Co(d);break}}return e}function iv(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 sP=Date.UTC(2026,8,1);function oP(){return Date.now()<sP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75}}const aP=[{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:oP()},{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 uP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function sv(e){if(!e)return null;for(const n of aP)if(n.match.test(e))return n.rates;return null}const lP=272e3,cP=/^gpt[-_]5[-_.](?:6(?![-_]cyber)|5|4)/i;function fP(e,n){return!e||n<=lP?{input:1,output:1}:cP.test(e)?{input:2,output:1.5}:{input:1,output:1}}function an(e,n){const i=sv(n);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const s=uP(n),o=s?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens,u=s?fP(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 Hw=2e5,dP=1e6,hP=[/\[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],pP=[{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 nN(e){if(!e)return Hw;for(const n of hP)if(n.test(e))return dP;for(const n of pP)if(n.match.test(e))return n.window;return Hw}function We(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 Tu(e,n){if(e<=0||n<10)return null;const i=e/n,s=i*60;return s>=.01?`${We(s)}/min`:`${We(i*3600)}/hr`}function Cn(e){return e.toLocaleString()}function mP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function gP({agent:e,onClose:n}){var h;const i=e.context,s=e.usage,o=(i==null?void 0:i.currentContextTokens)??0,u=nN(e.model),l=Math.min(100,o/u*100),c=an(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:[Cn(o)," / ",Cn(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(Fn,{label:"input tokens",val:Cn(s.inputTokens)}),v.jsx(Fn,{label:"output tokens",val:Cn(s.outputTokens)}),v.jsx(Fn,{label:"cache reads",val:Cn(s.cacheReadTokens)}),v.jsx(Fn,{label:"cache writes",val:Cn(s.cacheCreateTokens)}),v.jsx(Fn,{label:"cumulative total",val:Cn(d)}),v.jsx(Fn,{label:"estimated cost",val:We(c.total),accent:!0})]}),v.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),v.jsxs("div",{className:"ctx-grid",children:[v.jsx(Fn,{label:"user messages",val:Cn((i==null?void 0:i.msgsUser)??0)}),v.jsx(Fn,{label:"assistant messages",val:Cn((i==null?void 0:i.msgsAssistant)??0)}),v.jsx(Fn,{label:"tool uses",val:Cn((i==null?void 0:i.toolUses)??0)}),v.jsx(Fn,{label:"tool results",val:Cn((i==null?void 0:i.toolResults)??0)}),v.jsx(Fn,{label:"system-reminders",val:Cn((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:mP(p.bytes)})]},p.path))})]})})}function Fn({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 vP({currentContextTokens:e,modelId:n,size:i=26,onClick:s,title:o}){const u=nN(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 yP(e,n){const i=sv(n);if(!i)return"no rates for this model";const s=l=>l.toLocaleString(),o=l=>`$${l}/MTok`,u=an(e,n);return[`model: ${n}`,`input ${s(e.inputTokens).padStart(14)} × ${o(i.input).padEnd(11)} = ${We(u.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(i.output).padEnd(11)} = ${We(u.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(i.cacheRead).padEnd(11)} = ${We(u.cacheRead)}`,`cache w ${s(e.cacheCreateTokens).padStart(14)} × ${o(i.cacheWrite).padEnd(11)} = ${We(u.cacheWrite)}`,"─────────────────────────────────────────",`total = ${We(u.total)}`].join(`
58
58
  `)}function wP(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 xP({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(${iv(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(Os,{type:"target",position:Ce.Left,style:{background:"transparent",border:"none"}}),v.jsxs("div",{className:"head",children:[v.jsxs("div",{className:"title",children:[v.jsx(_P,{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(vP,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),v.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:wP(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:Vo(e.model)})]}),e.tools.length>0&&v.jsx(bP,{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:SP(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&sv(e.model)&&(()=>{const p=an(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"?Tu(p.total,m):null,x=yP(e.usage,e.model)+(y?`
59
- burn: ${y}`:"");return v.jsxs("span",{className:"cost-meta",title:x,children:[v.jsx("b",{children:We(p.total)}),y&&v.jsx("span",{className:"cost-rate",children:y})]})})()]}),v.jsx(Os,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function _P({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return v.jsx("span",{className:`state-pill state-${e}`,children:n})}function SP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function bP({tools:e,now:n}){const u=new Array(24).fill(0);let l=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(u[N]+=1,l+=1)}const c=Math.max(1,...u),d=132,h=14,p=d/24,m=c/(2500/1e3);return v.jsxs("div",{className:"tool-spark-row",title:`${l} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[v.jsx("svg",{className:"tool-spark",width:d,height:h,viewBox:`0 0 ${d} ${h}`,"aria-hidden":!0,children:u.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return v.jsx("rect",{x:x*p+.4,y:h-N,width:Math.max(.5,p-1),height:N,rx:.8,className:b},x)})}),v.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Vo(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 Vw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function kP(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 EP({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:kP(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:Vw(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…)":Vw(e.response??e.errorPreview)})]})]})]})})}const lu=18,Ww=26,NP=12;function CP(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=Gw(u)??p.label)):n.set(u.sessionId,{minX:l,minY:c,maxX:d,maxY:h,label:Gw(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} · ${TP(o)}`:u.label;s.push({sessionId:o,label:c,x:u.minX-lu,y:u.minY-lu-Ww,w:u.maxX-u.minX+lu*2,h:u.maxY-u.minY+lu*2+Ww})}return s}function TP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Gw(e){if(e.kind==="root")return e.label}function RP(){const{x:e,y:n,zoom:i}=GE(),s=Ho(),o=Qe(CP,jP);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=iv(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-NP)*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 jP(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 AP({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 rN=600,IP=36,Og=16,MP=60,PP=6,Yw=220,Kw=96,OP=28,qP={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 LP(e){return e.startsWith("mcp__")?"mcp":qP[e]??"other"}const $P={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 Xw(e){return e.startsWith("mcp__")?"🔌":$P[e]??"✨"}const DP={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 iN(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 iN(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 FP(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 zP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),BP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function UP(e,n){return BP.has(e)?Math.max(Kw,34+n.length*7.5):Kw}function HP(e,n){if(!zP.has(e))return null;const i=FP(n);if(!i)return null;const s=iN(i);return s?{emoji:DP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const VP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Qw={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:"🗄️"},Zw={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 WP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function GP(e){const n=e.toLowerCase();if(Zw[n])return Zw[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(Qw[s])return Qw[s]}return"📄"}function YP(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 KP(e,n){if(!VP.has(e))return null;const i=YP(e,n);if(!i)return null;const s=WP(i);return s?{emoji:e==="LS"?"📂":GP(s),label:s,category:"file",detail:i}:null}const sN={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 oN(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 XP(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 QP(e,n){const i=oN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const u=sN[s.toLowerCase()];return{emoji:(u==null?void 0:u.emoji)??"🔌",label:o,category:"mcp",detail:u?`${u.name} · ${o}`:`${s} · ${o}`}}function ZP(e,n){return HP(e,n)??KP(e,n)??QP(e)}const JP={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function e3(e){const n=oN(e);if(n){const s=sN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:XP(n.server)}}const i=JP[e];return i?{emoji:Xw(e),label:i}:{emoji:Xw(e),label:e}}function t3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function n3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/rN)}function r3(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>rN)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)??Yw,Yw),x=(m==null?void 0:m.height)??130,N=d.x,_=d.y,S=N+y,b=_+x/2;h.forEach((k,E)=>{const C=E*IP,A=N+y+MP,P=_+PP+C,I=n3(k,u,p),M=k.inputPreview??"",R=t3(k),L=I<.999,F=e3(k.name);l.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:F.label,emoji:F.emoji,status:R,category:LP(k.name),mcpHue:F.hue,inputPreview:M,fade:I,fading:L,worldX:A,worldY:P,anchorX:S,anchorY:b,spawnDx:S-A,spawnDy:b-(P+Og)});const J=ZP(k.name,k.input);if(J){const X=UP(k.name,F.label),j=A+X+OP,G=P,U=A+X,ne=P+Og;l.push({id:`sub:${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:J.label,emoji:J.emoji,isSub:!0,status:R,category:J.category,inputPreview:J.detail??M,fade:I,fading:L,worldX:j,worldY:G,anchorX:U,anchorY:ne,spawnDx:U-j,spawnDy:0})}})}return l}function i3({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}=GE(),x=r3(e,n,i,s,o,d),N=c&&c.size>0?x.filter(_=>!c.has(_.category)):x;return v.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[v.jsx("svg",{className:"tool-bursts-svg",children:N.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,k=(_.worldX+6)*y+p,E=(_.worldY+Og)*y+m,C=S+(k-S)*.55,A=u!=null&&!u.has(_.agentId),P=l!=null&&!l.has(_.agentId),I=_.fade*(A||P?.14:1);return v.jsx("path",{d:`M ${S} ${b} Q ${C} ${b}, ${k} ${E}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:I},`l:${_.id}`)})}),N.map(_=>{const S=_.worldX*y+p,b=_.worldY*y+m,k={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},E=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${E} · ${_.inputPreview}`:E,A=h!=null,P=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},I=u!=null&&!u.has(_.agentId),M=l!=null&&!l.has(_.agentId),R=I||M?" dim":"";return v.jsx("div",{className:"tool-burst-wrap",style:k,children:v.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${A?" clickable":""}${_.isSub?" sub":""}${R}`,style:P,title:C,role:A?"button":void 0,tabIndex:A?0:void 0,"aria-label":A?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:A?()=>h(_.toolId):void 0,onKeyDown:A?L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),h(_.toolId))}:void 0,children:[v.jsx("span",{className:"tb-emoji",children:_.emoji}),v.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&v.jsx("span",{className:"tb-spin"}),_.status==="done"&&v.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&v.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function s3({state:e,sessionId:n,onClose:i}){const s=q.useMemo(()=>a3(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:We(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:Vo(o)},o))})]}),v.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&v.jsxs(v.Fragment,{children:[v.jsx(o3,{cost:s.cost}),v.jsxs("div",{className:"ss-cost-legend",children:[v.jsxs("span",{className:"ssl ssl-in",children:["input ",v.jsx("b",{children:We(s.cost.input)})]}),v.jsxs("span",{className:"ssl ssl-out",children:["output ",v.jsx("b",{children:We(s.cost.output)})]}),v.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",v.jsx("b",{children:We(s.cost.cacheRead)})]}),v.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",v.jsx("b",{children:We(s.cost.cacheWrite)})]})]})]})})]}),v.jsxs("section",{className:"ss-stats",children:[v.jsx(ks,{label:"agents",value:s.agentCount}),v.jsx(ks,{label:"subagents",value:s.subagentCount}),v.jsx(ks,{label:"tool calls",value:s.toolCount}),v.jsx(ks,{label:"prompts",value:s.promptCount}),v.jsx(ks,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&v.jsx(ks,{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 ks({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 o3({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}: ${We(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 a3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const E of e.agents.values())E.sessionId===n&&s.push(E);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},u=new Set,l=new Map;let c=0,d=0,h=0,p=0,m=0,y,x=1/0,N=0;for(const E of s){const C=an(E.usage,E.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,E.model&&u.add(E.model),E.kind==="subagent"&&m++,d+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),h+=E.usage.inputTokens+E.usage.outputTokens,c+=E.tools.length,x=Math.min(x,E.startedAt),N=Math.max(N,E.endedAt??Date.now());for(const A of E.tools)l.set(A.name,(l.get(A.name)??0)+1),A.ok===!1&&p++}const _=Math.max(0,N-x),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,k=Array.from(l.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(u),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:d,tokensSum:h,errCount:p,topTools:k,firstPrompt:y}}function u3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,u=an(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+=an(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 l3(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 c3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const u=q.useMemo(()=>u3(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:Vo(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:We(c.cost)})}),v.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:l3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function Jw(e,n){if(!e)return null;const i=n-Math.floor(e/1e3);return i<10?"just now":i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:`${Math.floor(i/3600)}h ago`}function f3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function _r(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function d3({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}: ${We(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 h3(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 p3(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 ji({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?h3(s,l):null,x=s&&o?p3(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 m3=6e4;function g3(){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),m3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>u(!0)}}function v3(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 aN=6e4;function y3(){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),aN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>u(!0)}}function w3(){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,aN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function x3({state:e,now:n,onClose:i}){var I,M;const{quota:s,loading:o,refresh:u}=g3(),{data:l,loading:c,refresh:d}=y3(),{data:h}=w3(),[p,m]=q.useState(()=>Math.floor(Date.now()/1e3));q.useEffect(()=>{const R=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(R)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=q.useMemo(()=>{const R=new Map,L={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let F=0,J=0,X=0,j=0;for(const $ of e.agents.values()){const W=$.model??"__unknown__",O=an($.usage,$.model),B=R.get(W);B?(B.inputTokens+=$.usage.inputTokens,B.outputTokens+=$.usage.outputTokens,B.cacheReadTokens+=$.usage.cacheReadTokens,B.cacheCreateTokens+=$.usage.cacheCreateTokens,B.cost.total+=O.total,B.cost.input+=O.input,B.cost.output+=O.output,B.cost.cacheRead+=O.cacheRead,B.cost.cacheWrite+=O.cacheWrite,B.agentCount++):R.set(W,{model:W,inputTokens:$.usage.inputTokens,outputTokens:$.usage.outputTokens,cacheReadTokens:$.usage.cacheReadTokens,cacheCreateTokens:$.usage.cacheCreateTokens,cost:{...O},agentCount:1}),L.total+=O.total,L.input+=O.input,L.output+=O.output,L.cacheRead+=O.cacheRead,L.cacheWrite+=O.cacheWrite,F+=$.usage.inputTokens,J+=$.usage.outputTokens,X+=$.usage.cacheReadTokens,j+=$.usage.cacheCreateTokens}const G=Array.from(R.values()).sort(($,W)=>W.cost.total-$.cost.total);let U=0,ne=0;for(const $ of e.agents.values()){if($.state!=="active")continue;const W=an($.usage,$.model);U+=W.total,ne=Math.max(ne,(($.endedAt??n)-$.startedAt)/1e3)}const K=ne>0?Tu(U,ne):null;return{byModel:G,totalCost:L,totalTokens:{in:F,out:J,cacheR:X,cacheC:j},burnRate:K}},[e,e.lastSeq,n]),S=q.useMemo(()=>{const R=[];for(const L of e.agents.values()){if(L.kind!=="root")continue;let F=an(L.usage,L.model).total,J=L.usage.inputTokens,X=L.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==L.sessionId||j.kind==="root"||(F+=an(j.usage,j.model).total,J+=j.usage.inputTokens,X+=j.usage.outputTokens);R.push({sessionId:L.sessionId,label:L.label||L.cwdBasename||"session",state:L.state,cost:F,inputTokens:J,outputTokens:X})}return R.sort((L,F)=>F.cost-L.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=N.in+N.out,E=o||c,C=Jw(s==null?void 0:s.fetchedAt,p),A=Jw(l==null?void 0:l.fetchedAt,p),P=()=>{u(),d()};return v.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[v.jsxs("div",{className:"up-header",children:[v.jsx("h3",{children:"Usage"}),_&&v.jsx("span",{className:"up-rate",children:_}),v.jsxs("div",{className:"up-header-right",children:[v.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:P,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),v.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),v.jsxs("section",{className:"up-section up-quota-section",children:[v.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&v.jsx("span",{className:"up-section-age",title:f3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?v.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&v.jsx(ji,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:p}),s.week7dPct!=null&&v.jsx(ji,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:p}),s.weekSonnetPct!=null&&v.jsx(ji,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:p}),s.weekOpusPct!=null&&v.jsx(ji,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:p})]}):(s==null?void 0:s.ok)===!1?v.jsxs("div",{className:"up-quota-na",children:[v.jsx("span",{children:"Quota unavailable."}),v.jsxs("span",{className:"up-quota-hint",children:["Run ",v.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):v.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),v.jsxs("section",{className:"up-section up-quota-section",children:[v.jsxs("h4",{className:"up-section-title",children:["Codex quota",(l==null?void 0:l.ok)&&l.planLabel&&v.jsx("span",{className:"up-plan-badge",children:l.planLabel}),A&&!c&&v.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:A})]}),l!=null&&l.ok?v.jsxs("div",{className:"up-quota-bars",children:[(I=l.windows)==null?void 0:I.map(R=>v.jsx(ji,{label:R.label,pct:R.pct,reset:R.reset??void 0,resetAt:R.resetAt??void 0,windowSec:R.windowSec??void 0,limitReached:l.limitReached&&R.pct>=100,nowSec:p},R.id)),(M=l.extraWindows)==null?void 0:M.map(R=>v.jsx(ji,{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(ji,{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:[_r(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:v3(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:We(x.total)}),v.jsx("span",{className:"up-total-label",children:"total spend"})]}),v.jsx(d3,{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"}),_r(N.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),_r(N.out)]}),N.cacheR>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache r"}),_r(N.cacheR)]}),N.cacheC>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache c"}),_r(N.cacheC)]})]}),y.filter(R=>R.cost.total>0).length>0&&v.jsxs("section",{className:"up-section",children:[v.jsx("h4",{className:"up-section-title",children:"By model"}),v.jsxs("table",{className:"up-table",children:[v.jsx("thead",{children:v.jsxs("tr",{children:[v.jsx("th",{children:"Model"}),v.jsx("th",{children:"Tokens"}),v.jsx("th",{children:"Cost"})]})}),v.jsx("tbody",{children:y.filter(R=>R.cost.total>0).map(R=>v.jsxs("tr",{children:[v.jsx("td",{className:"up-model-name",title:R.model,children:Vo(R.model)}),v.jsx("td",{className:"up-num",children:_r(R.inputTokens+R.outputTokens)}),v.jsx("td",{className:"up-num up-cost-val",children:We(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:_r(R.inputTokens+R.outputTokens)}),v.jsx("span",{className:"up-session-cost",children:We(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"}),_r(N.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),_r(N.out)]})]}),v.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):v.jsxs("div",{className:"up-empty",children:["No usage data yet.",v.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const _3=15e3,S3=[70,80,85,90,95];function b3(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 ex(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 k3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?" · due":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function E3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function N3({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?b3(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 C3({onClose:e}){var A,P,I;const[n,i]=q.useState(null),[s,o]=q.useState(null),[u,l]=q.useState(null),[c,d]=q.useState(null),[h,p]=q.useState(null),[m,y]=q.useState(()=>Math.floor(Date.now()/1e3)),x=q.useRef(null),N=q.useCallback(async(M=!1)=>{try{const[R,L]=await Promise.all([fetch(`/api/claude-accounts${M?"?refresh=1":""}`),fetch("/api/cswap-auto")]);R.ok&&i(await R.json()),L.ok&&o(await L.json())}catch{}},[]),_=q.useCallback(async(M,R)=>{l(R),p(null);try{const F=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)})).json().catch(()=>null);return F!=null&&F.ok||p((F==null?void 0:F.detail)||(F==null?void 0:F.reason)||"command failed"),F}catch{return p("server unreachable"),null}finally{l(null)}},[]);q.useEffect(()=>(N(!0),x.current=window.setInterval(()=>N(!1),_3),()=>{x.current!=null&&window.clearInterval(x.current)}),[N]),q.useEffect(()=>{const M=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(M)},[]);const S=((A=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:A.value)??"90",b=(P=n==null?void 0:n.accounts)==null?void 0:P.find(M=>M.active),k=b!=null&&b.lanes.length?Math.max(...b.lanes.map(M=>M.pct)):null,E=k!=null&&k>=Number(S)-15,C=async M=>{d(M),p(null);try{const L=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:M})})).json().catch(()=>null);L!=null&&L.ok||p((L==null?void 0:L.output)||(L==null?void 0:L.reason)||"switch failed"),await N(!0)}catch{p("server unreachable")}finally{d(null)}};return v.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[v.jsxs("div",{className:"ap-header",children:[v.jsx("h3",{children:"Accounts"}),v.jsxs("div",{className:"ap-header-right",children:[v.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>N(!0),title:"Reload from claude-swap",children:"↻"}),v.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?v.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?v.jsxs(v.Fragment,{children:[(I=n.accounts)==null?void 0:I.map(M=>v.jsxs("div",{className:`ap-account${M.active?" active":""}${M.disabled?" disabled":""}`,children:[v.jsxs("div",{className:"ap-account-head",children:[v.jsx("span",{className:"ap-num",children:M.num}),M.alias&&v.jsx("span",{className:"ap-alias",children:M.alias}),v.jsx("span",{className:"ap-email",title:M.org??void 0,children:M.email}),M.active?v.jsx("span",{className:"ap-badge-active",children:"● active"}):v.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||M.disabled,onClick:()=>C(M.num),title:M.disabled?"Held out of rotation":`Switch to ${M.alias??M.email}`,children:c===M.num?"…":"switch"})]}),M.lanes.length>0?M.lanes.map(R=>v.jsx(N3,{lane:R,nowSec:m},R.id)):v.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),v.jsxs("div",{className:"ap-meta",children:[M.error&&v.jsx("span",{className:"ap-err",children:E3(M.error)}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!M.active&&v.jsx("button",{type:"button",className:"ap-rotate",disabled:u!=null,onClick:()=>_({action:"account",account:M.num,enabled:M.disabled},`rot-${M.num}`).then(()=>N(!0)),title:M.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:M.disabled?"held out":"in rotation"}),M.fetchedAt?v.jsxs("span",{className:`ap-age${M.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",ex(M.fetchedAt,m),k3(M.nextAt,m)]}):v.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]})]},M.num)),(s==null?void 0:s.ok)&&v.jsxs("div",{className:"ap-auto",children:[v.jsxs("div",{className:"ap-auto-head",children:[v.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),v.jsxs("span",{className:"ap-auto-ctl",children:[k!=null&&v.jsxs("span",{className:`ap-auto-now${E?" near":""}`,children:[Math.round(k),"%"]}),v.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:v.jsx("select",{"aria-label":"Switch threshold",value:S,disabled:u!=null,onChange:M=>_({action:"setting",key:"autoswitch.threshold",value:M.target.value},"threshold").then(()=>N(!0)),children:S3.map(M=>v.jsxs("option",{value:M,children:[M,"%"]},M))})}),v.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:u!=null,onClick:()=>_({action:"enable",enabled:!s.enabled},"enable").then(()=>N(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[v.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&v.jsxs("p",{className:"ap-auto-note",children:[v.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",v.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&v.jsx("div",{className:"ap-auto-foot",children:v.jsxs("span",{className:"ap-auto-result",children:["checked ",ex(s.lastTick.at,m)]})})]}),h&&v.jsx("div",{className:"ap-failure",children:h}),v.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):v.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"claude-swap isn't installed."}),v.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&v.jsx("code",{className:"ap-cmd",children:n.hint}),v.jsxs("span",{className:"ap-hint",children:["Then add your accounts with ",v.jsx("code",{children:"cswap add"})," and reload."]})]}):n.reason==="no_accounts"?v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"No accounts added yet."}),v.jsx("span",{className:"ap-hint",children:"claude-swap is installed but has nothing in its store."}),v.jsx("code",{className:"ap-cmd",children:"cswap add"})]}):v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"Couldn't read the account store."}),v.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})})]})}function Ai(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 tx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function cu(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 T3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const R3=[7,14,30,90];function j3(e){const[n,i]=q.useState(null),[s,o]=q.useState(!1),u=(l=!1)=>{o(!0);const d=`/api/ccusage?since=${T3(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 A3({onClose:e}){var b,k;const[n,i]=q.useState(30),[s,o]=q.useState(null),{data:u,loading:l,reload:c}=j3(n);q.useEffect(()=>{const E=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const d=u!=null&&u.ok?u.days??[]:[],h=q.useMemo(()=>d.reduce((E,C)=>Math.max(E,C.totalCost),0),[d]),{totalCost:p,totalTok:m,inOut:y,cacheRead:x,modelCosts:N}=q.useMemo(()=>{let E=0,C=0,A=0,P=0;const I=new Map;for(const M of d){E+=M.totalCost,C+=M.totalTokens,A+=M.inputTokens+M.outputTokens,P+=M.cacheReadTokens;for(const R of M.modelBreakdowns)I.set(R.modelName,(I.get(R.modelName)??0)+R.cost)}return{totalCost:E,totalTok:C,inOut:A,cacheRead:P,modelCosts:I}},[d]),_=q.useMemo(()=>Array.from(N.entries()).sort((E,C)=>C[1]-E[1]),[N]),S=s?d.find(E=>E.period===s)??null:null;return v.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:v.jsxs("div",{className:"uh-modal",onClick:E=>E.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[v.jsxs("header",{className:"uh-head",children:[v.jsxs("div",{className:"uh-titlewrap",children:[v.jsx("div",{className:"uh-title",children:"Usage history"}),v.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),v.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:R3.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(fu,{label:"total cost",val:We(p),accent:!0}),v.jsx(fu,{label:"tokens",val:Ai(m)}),v.jsx(fu,{label:"input+output",val:Ai(y)}),v.jsx(fu,{label:"cache reads",val:Ai(x)})]}),v.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:d.map(E=>{const C=h>0?E.totalCost/h*100:0,A=E.period===s;return v.jsxs("button",{className:`uh-bar-col${A?" sel":""}`,onClick:()=>o(A?null:E.period),title:`${E.period} · ${We(E.totalCost)}`,style:{flexBasis:`${100/d.length}%`},children:[v.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,E.totalCost>0?2:0)}%`},children:E.modelBreakdowns.slice().sort((P,I)=>I.cost-P.cost).map(P=>{const I=E.totalCost>0?P.cost/E.totalCost*100:0;return v.jsx("div",{className:"uh-bar-seg",style:{height:`${I}%`,background:cu(P.modelName)}},P.modelName)})}),v.jsx("span",{className:"uh-bar-label",children:E.period.slice(5)})]},E.period)})}),v.jsx("div",{className:"uh-legend",children:_.map(([E,C])=>v.jsxs("span",{className:"uh-legend-item",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:cu(E)}}),tx(E)," ",v.jsx("span",{className:"uh-legend-cost",children:We(C)})]},E))}),S&&v.jsxs("div",{className:"uh-detail",children:[v.jsxs("div",{className:"uh-detail-head",children:[v.jsx("span",{className:"uh-detail-date",children:S.period}),v.jsx("span",{className:"uh-detail-cost",children:We(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(du,{label:"input",val:Ai(S.inputTokens)}),v.jsx(du,{label:"output",val:Ai(S.outputTokens)}),v.jsx(du,{label:"cache write",val:Ai(S.cacheCreationTokens)}),v.jsx(du,{label:"cache read",val:Ai(S.cacheReadTokens)})]}),v.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((E,C)=>C.cost-E.cost).map(E=>{const C=S.totalCost>0?E.cost/S.totalCost*100:0;return v.jsxs("div",{className:"uh-model-row",children:[v.jsxs("span",{className:"uh-model-name",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:cu(E.modelName)}}),tx(E.modelName)]}),v.jsx("span",{className:"uh-model-bar",children:v.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:cu(E.modelName)}})}),v.jsx("span",{className:"uh-model-cost",children:We(E.cost)})]},E.modelName)})})]})]})]})})}function fu({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 du({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 ov(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 Zc,nx;function I3(){if(nx)return Zc;nx=1;function e(){this.__data__=[],this.size=0}return Zc=e,Zc}var Jc,rx;function qs(){if(rx)return Jc;rx=1;function e(n,i){return n===i||n!==n&&i!==i}return Jc=e,Jc}var ef,ix;function Lu(){if(ix)return ef;ix=1;var e=qs();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return ef=n,ef}var tf,sx;function M3(){if(sx)return tf;sx=1;var e=Lu(),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 tf=s,tf}var nf,ox;function P3(){if(ox)return nf;ox=1;var e=Lu();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return nf=n,nf}var rf,ax;function O3(){if(ax)return rf;ax=1;var e=Lu();function n(i){return e(this.__data__,i)>-1}return rf=n,rf}var sf,ux;function q3(){if(ux)return sf;ux=1;var e=Lu();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 sf=n,sf}var of,lx;function $u(){if(lx)return of;lx=1;var e=I3(),n=M3(),i=P3(),s=O3(),o=q3();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,of=u,of}var af,cx;function L3(){if(cx)return af;cx=1;var e=$u();function n(){this.__data__=new e,this.size=0}return af=n,af}var uf,fx;function $3(){if(fx)return uf;fx=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return uf=e,uf}var lf,dx;function D3(){if(dx)return lf;dx=1;function e(n){return this.__data__.get(n)}return lf=e,lf}var cf,hx;function F3(){if(hx)return cf;hx=1;function e(n){return this.__data__.has(n)}return cf=e,cf}var ff,px;function uN(){if(px)return ff;px=1;var e=typeof Za=="object"&&Za&&Za.Object===Object&&Za;return ff=e,ff}var df,mx;function Wn(){if(mx)return df;mx=1;var e=uN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return df=i,df}var hf,gx;function Ls(){if(gx)return hf;gx=1;var e=Wn(),n=e.Symbol;return hf=n,hf}var pf,vx;function z3(){if(vx)return pf;vx=1;var e=Ls(),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 pf=u,pf}var mf,yx;function B3(){if(yx)return mf;yx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return mf=i,mf}var gf,wx;function zi(){if(wx)return gf;wx=1;var e=Ls(),n=z3(),i=B3(),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 gf=l,gf}var vf,xx;function jn(){if(xx)return vf;xx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return vf=e,vf}var yf,_x;function Wo(){if(_x)return yf;_x=1;var e=zi(),n=jn(),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 yf=l,yf}var wf,Sx;function U3(){if(Sx)return wf;Sx=1;var e=Wn(),n=e["__core-js_shared__"];return wf=n,wf}var xf,bx;function H3(){if(bx)return xf;bx=1;var e=U3(),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 xf=i,xf}var _f,kx;function lN(){if(kx)return _f;kx=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 _f=i,_f}var Sf,Ex;function V3(){if(Ex)return Sf;Ex=1;var e=Wo(),n=H3(),i=jn(),s=lN(),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 Sf=m,Sf}var bf,Nx;function W3(){if(Nx)return bf;Nx=1;function e(n,i){return n==null?void 0:n[i]}return bf=e,bf}var kf,Cx;function Bi(){if(Cx)return kf;Cx=1;var e=V3(),n=W3();function i(s,o){var u=n(s,o);return e(u)?u:void 0}return kf=i,kf}var Ef,Tx;function av(){if(Tx)return Ef;Tx=1;var e=Bi(),n=Wn(),i=e(n,"Map");return Ef=i,Ef}var Nf,Rx;function Du(){if(Rx)return Nf;Rx=1;var e=Bi(),n=e(Object,"create");return Nf=n,Nf}var Cf,jx;function G3(){if(jx)return Cf;jx=1;var e=Du();function n(){this.__data__=e?e(null):{},this.size=0}return Cf=n,Cf}var Tf,Ax;function Y3(){if(Ax)return Tf;Ax=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return Tf=e,Tf}var Rf,Ix;function K3(){if(Ix)return Rf;Ix=1;var e=Du(),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 Rf=o,Rf}var jf,Mx;function X3(){if(Mx)return jf;Mx=1;var e=Du(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var u=this.__data__;return e?u[o]!==void 0:i.call(u,o)}return jf=s,jf}var Af,Px;function Q3(){if(Px)return Af;Px=1;var e=Du(),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 Af=i,Af}var If,Ox;function Z3(){if(Ox)return If;Ox=1;var e=G3(),n=Y3(),i=K3(),s=X3(),o=Q3();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,If=u,If}var Mf,qx;function J3(){if(qx)return Mf;qx=1;var e=Z3(),n=$u(),i=av();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return Mf=s,Mf}var Pf,Lx;function eO(){if(Lx)return Pf;Lx=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Pf=e,Pf}var Of,$x;function Fu(){if($x)return Of;$x=1;var e=eO();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Of=n,Of}var qf,Dx;function tO(){if(Dx)return qf;Dx=1;var e=Fu();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return qf=n,qf}var Lf,Fx;function nO(){if(Fx)return Lf;Fx=1;var e=Fu();function n(i){return e(this,i).get(i)}return Lf=n,Lf}var $f,zx;function rO(){if(zx)return $f;zx=1;var e=Fu();function n(i){return e(this,i).has(i)}return $f=n,$f}var Df,Bx;function iO(){if(Bx)return Df;Bx=1;var e=Fu();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 Df=n,Df}var Ff,Ux;function uv(){if(Ux)return Ff;Ux=1;var e=J3(),n=tO(),i=nO(),s=rO(),o=iO();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,Ff=u,Ff}var zf,Hx;function sO(){if(Hx)return zf;Hx=1;var e=$u(),n=av(),i=uv(),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 zf=o,zf}var Bf,Vx;function zu(){if(Vx)return Bf;Vx=1;var e=$u(),n=L3(),i=$3(),s=D3(),o=F3(),u=sO();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,Bf=l,Bf}var Uf,Wx;function lv(){if(Wx)return Uf;Wx=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 Uf=e,Uf}var Hf,Gx;function cN(){if(Gx)return Hf;Gx=1;var e=Bi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Hf=n,Hf}var Vf,Yx;function Bu(){if(Yx)return Vf;Yx=1;var e=cN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Vf=n,Vf}var Wf,Kx;function Uu(){if(Kx)return Wf;Kx=1;var e=Bu(),n=qs(),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 Wf=o,Wf}var Gf,Xx;function Go(){if(Xx)return Gf;Xx=1;var e=Uu(),n=Bu();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 Gf=i,Gf}var Yf,Qx;function oO(){if(Qx)return Yf;Qx=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return Yf=e,Yf}var Kf,Zx;function or(){if(Zx)return Kf;Zx=1;function e(n){return n!=null&&typeof n=="object"}return Kf=e,Kf}var Xf,Jx;function aO(){if(Jx)return Xf;Jx=1;var e=zi(),n=or(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return Xf=s,Xf}var Qf,e1;function Yo(){if(e1)return Qf;e1=1;var e=aO(),n=or(),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 Qf=u,Qf}var Zf,t1;function xt(){if(t1)return Zf;t1=1;var e=Array.isArray;return Zf=e,Zf}var To={exports:{}},Jf,n1;function uO(){if(n1)return Jf;n1=1;function e(){return!1}return Jf=e,Jf}To.exports;var r1;function $s(){return r1||(r1=1,(function(e,n){var i=Wn(),s=uO(),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})(To,To.exports)),To.exports}var ed,i1;function Hu(){if(i1)return ed;i1=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 ed=i,ed}var td,s1;function cv(){if(s1)return td;s1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return td=n,td}var nd,o1;function lO(){if(o1)return nd;o1=1;var e=zi(),n=cv(),i=or(),s="[object Arguments]",o="[object Array]",u="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",p="[object Number]",m="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",P="[object Int32Array]",I="[object Uint8Array]",M="[object Uint8ClampedArray]",R="[object Uint16Array]",L="[object Uint32Array]",F={};F[k]=F[E]=F[C]=F[A]=F[P]=F[I]=F[M]=F[R]=F[L]=!0,F[s]=F[o]=F[S]=F[u]=F[b]=F[l]=F[c]=F[d]=F[h]=F[p]=F[m]=F[y]=F[x]=F[N]=F[_]=!1;function J(X){return i(X)&&n(X.length)&&!!F[e(X)]}return nd=J,nd}var rd,a1;function Vu(){if(a1)return rd;a1=1;function e(n){return function(i){return n(i)}}return rd=e,rd}var Ro={exports:{}};Ro.exports;var u1;function fv(){return u1||(u1=1,(function(e,n){var i=uN(),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})(Ro,Ro.exports)),Ro.exports}var id,l1;function Ko(){if(l1)return id;l1=1;var e=lO(),n=Vu(),i=fv(),s=i&&i.isTypedArray,o=s?n(s):e;return id=o,id}var sd,c1;function fN(){if(c1)return sd;c1=1;var e=oO(),n=Yo(),i=xt(),s=$s(),o=Hu(),u=Ko(),l=Object.prototype,c=l.hasOwnProperty;function d(h,p){var m=i(h),y=!m&&n(h),x=!m&&!y&&s(h),N=!m&&!y&&!x&&u(h),_=m||y||x||N,S=_?e(h.length,String):[],b=S.length;for(var k in h)(p||c.call(h,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return sd=d,sd}var od,f1;function Wu(){if(f1)return od;f1=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return od=n,od}var ad,d1;function dN(){if(d1)return ad;d1=1;function e(n,i){return function(s){return n(i(s))}}return ad=e,ad}var ud,h1;function cO(){if(h1)return ud;h1=1;var e=dN(),n=e(Object.keys,Object);return ud=n,ud}var ld,p1;function dv(){if(p1)return ld;p1=1;var e=Wu(),n=cO(),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 ld=o,ld}var cd,m1;function Nr(){if(m1)return cd;m1=1;var e=Wo(),n=cv();function i(s){return s!=null&&n(s.length)&&!e(s)}return cd=i,cd}var fd,g1;function si(){if(g1)return fd;g1=1;var e=fN(),n=dv(),i=Nr();function s(o){return i(o)?e(o):n(o)}return fd=s,fd}var dd,v1;function fO(){if(v1)return dd;v1=1;var e=Go(),n=si();function i(s,o){return s&&e(o,n(o),s)}return dd=i,dd}var hd,y1;function dO(){if(y1)return hd;y1=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return hd=e,hd}var pd,w1;function hO(){if(w1)return pd;w1=1;var e=jn(),n=Wu(),i=dO(),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 pd=u,pd}var md,x1;function Ui(){if(x1)return md;x1=1;var e=fN(),n=hO(),i=Nr();function s(o){return i(o)?e(o,!0):n(o)}return md=s,md}var gd,_1;function pO(){if(_1)return gd;_1=1;var e=Go(),n=Ui();function i(s,o){return s&&e(o,n(o),s)}return gd=i,gd}var jo={exports:{}};jo.exports;var S1;function hN(){return S1||(S1=1,(function(e,n){var i=Wn(),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})(jo,jo.exports)),jo.exports}var vd,b1;function pN(){if(b1)return vd;b1=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 vd=e,vd}var yd,k1;function mN(){if(k1)return yd;k1=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 yd=e,yd}var wd,E1;function gN(){if(E1)return wd;E1=1;function e(){return[]}return wd=e,wd}var xd,N1;function hv(){if(N1)return xd;N1=1;var e=mN(),n=gN(),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 xd=u,xd}var _d,C1;function mO(){if(C1)return _d;C1=1;var e=Go(),n=hv();function i(s,o){return e(s,n(s),o)}return _d=i,_d}var Sd,T1;function pv(){if(T1)return Sd;T1=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 Sd=e,Sd}var bd,R1;function Gu(){if(R1)return bd;R1=1;var e=dN(),n=e(Object.getPrototypeOf,Object);return bd=n,bd}var kd,j1;function vN(){if(j1)return kd;j1=1;var e=pv(),n=Gu(),i=hv(),s=gN(),o=Object.getOwnPropertySymbols,u=o?function(l){for(var c=[];l;)e(c,i(l)),l=n(l);return c}:s;return kd=u,kd}var Ed,A1;function gO(){if(A1)return Ed;A1=1;var e=Go(),n=vN();function i(s,o){return e(s,n(s),o)}return Ed=i,Ed}var Nd,I1;function yN(){if(I1)return Nd;I1=1;var e=pv(),n=xt();function i(s,o,u){var l=o(s);return n(s)?l:e(l,u(s))}return Nd=i,Nd}var Cd,M1;function wN(){if(M1)return Cd;M1=1;var e=yN(),n=hv(),i=si();function s(o){return e(o,i,n)}return Cd=s,Cd}var Td,P1;function vO(){if(P1)return Td;P1=1;var e=yN(),n=vN(),i=Ui();function s(o){return e(o,i,n)}return Td=s,Td}var Rd,O1;function yO(){if(O1)return Rd;O1=1;var e=Bi(),n=Wn(),i=e(n,"DataView");return Rd=i,Rd}var jd,q1;function wO(){if(q1)return jd;q1=1;var e=Bi(),n=Wn(),i=e(n,"Promise");return jd=i,jd}var Ad,L1;function xN(){if(L1)return Ad;L1=1;var e=Bi(),n=Wn(),i=e(n,"Set");return Ad=i,Ad}var Id,$1;function xO(){if($1)return Id;$1=1;var e=Bi(),n=Wn(),i=e(n,"WeakMap");return Id=i,Id}var Md,D1;function Ds(){if(D1)return Md;D1=1;var e=yO(),n=av(),i=wO(),s=xN(),o=xO(),u=zi(),l=lN(),c="[object Map]",d="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",x=l(e),N=l(n),_=l(i),S=l(s),b=l(o),k=u;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||i&&k(i.resolve())!=h||s&&k(new s)!=p||o&&k(new o)!=m)&&(k=function(E){var C=u(E),A=C==d?E.constructor:void 0,P=A?l(A):"";if(P)switch(P){case x:return y;case N:return c;case _:return h;case S:return p;case b:return m}return C}),Md=k,Md}var Pd,F1;function _O(){if(F1)return Pd;F1=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 Pd=i,Pd}var Od,z1;function _N(){if(z1)return Od;z1=1;var e=Wn(),n=e.Uint8Array;return Od=n,Od}var qd,B1;function mv(){if(B1)return qd;B1=1;var e=_N();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return qd=n,qd}var Ld,U1;function SO(){if(U1)return Ld;U1=1;var e=mv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Ld=n,Ld}var $d,H1;function bO(){if(H1)return $d;H1=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return $d=n,$d}var Dd,V1;function kO(){if(V1)return Dd;V1=1;var e=Ls(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Dd=s,Dd}var Fd,W1;function SN(){if(W1)return Fd;W1=1;var e=mv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Fd=n,Fd}var zd,G1;function EO(){if(G1)return zd;G1=1;var e=mv(),n=SO(),i=bO(),s=kO(),o=SN(),u="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",A="[object Uint8ClampedArray]",P="[object Uint16Array]",I="[object Uint32Array]";function M(R,L,F){var J=R.constructor;switch(L){case x:return e(R);case u:case l:return new J(+R);case N:return n(R,F);case _:case S:case b:case k:case E:case C:case A:case P:case I:return o(R,F);case c:return new J;case d:case m:return new J(R);case h:return i(R);case p:return new J;case y:return s(R)}}return zd=M,zd}var Bd,Y1;function bN(){if(Y1)return Bd;Y1=1;var e=jn(),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 Bd=i,Bd}var Ud,K1;function kN(){if(K1)return Ud;K1=1;var e=bN(),n=Gu(),i=Wu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Ud=s,Ud}var Hd,X1;function NO(){if(X1)return Hd;X1=1;var e=Ds(),n=or(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Hd=s,Hd}var Vd,Q1;function CO(){if(Q1)return Vd;Q1=1;var e=NO(),n=Vu(),i=fv(),s=i&&i.isMap,o=s?n(s):e;return Vd=o,Vd}var Wd,Z1;function TO(){if(Z1)return Wd;Z1=1;var e=Ds(),n=or(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Wd=s,Wd}var Gd,J1;function RO(){if(J1)return Gd;J1=1;var e=TO(),n=Vu(),i=fv(),s=i&&i.isSet,o=s?n(s):e;return Gd=o,Gd}var Yd,e_;function EN(){if(e_)return Yd;e_=1;var e=zu(),n=lv(),i=Uu(),s=fO(),o=pO(),u=hN(),l=pN(),c=mO(),d=gO(),h=wN(),p=vO(),m=Ds(),y=_O(),x=EO(),N=kN(),_=xt(),S=$s(),b=CO(),k=jn(),E=RO(),C=si(),A=Ui(),P=1,I=2,M=4,R="[object Arguments]",L="[object Array]",F="[object Boolean]",J="[object Date]",X="[object Error]",j="[object Function]",G="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",K="[object Object]",$="[object RegExp]",W="[object Set]",O="[object String]",B="[object Symbol]",ae="[object WeakMap]",z="[object ArrayBuffer]",H="[object DataView]",ee="[object Float32Array]",se="[object Float64Array]",ce="[object Int8Array]",me="[object Int16Array]",ve="[object Int32Array]",Ae="[object Uint8Array]",Ue="[object Uint8ClampedArray]",Me="[object Uint16Array]",Pe="[object Uint32Array]",be={};be[R]=be[L]=be[z]=be[H]=be[F]=be[J]=be[ee]=be[se]=be[ce]=be[me]=be[ve]=be[U]=be[ne]=be[K]=be[$]=be[W]=be[O]=be[B]=be[Ae]=be[Ue]=be[Me]=be[Pe]=!0,be[X]=be[j]=be[ae]=!1;function Fe(we,xe,De,Xe,Ke,et){var ze,qe=xe&P,qt=xe&I,Lt=xe&M;if(De&&(ze=Ke?De(we,Xe,Ke,et):De(we)),ze!==void 0)return ze;if(!k(we))return we;var Ze=_(we);if(Ze){if(ze=y(we),!qe)return l(we,ze)}else{var lt=m(we),At=lt==j||lt==G;if(S(we))return u(we,qe);if(lt==K||lt==R||At&&!Ke){if(ze=qt||At?{}:N(we),!qe)return qt?d(we,o(ze,we)):c(we,s(ze,we))}else{if(!be[lt])return Ke?we:{};ze=x(we,lt,qe)}}et||(et=new e);var ht=et.get(we);if(ht)return ht;et.set(we,ze),E(we)?we.forEach(function(gt){ze.add(Fe(gt,xe,De,gt,we,et))}):b(we)&&we.forEach(function(gt,ot){ze.set(ot,Fe(gt,xe,De,ot,we,et))});var tt=Lt?qt?p:h:qt?A:C,_t=Ze?void 0:tt(we);return n(_t||we,function(gt,ot){_t&&(ot=gt,gt=we[ot]),i(ze,ot,Fe(gt,xe,De,ot,we,et))}),ze}return Yd=Fe,Yd}var Kd,t_;function jO(){if(t_)return Kd;t_=1;var e=EN(),n=4;function i(s){return e(s,n)}return Kd=i,Kd}var Xd,n_;function gv(){if(n_)return Xd;n_=1;function e(n){return function(){return n}}return Xd=e,Xd}var Qd,r_;function AO(){if(r_)return Qd;r_=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 Qd=e,Qd}var Zd,i_;function vv(){if(i_)return Zd;i_=1;var e=AO(),n=e();return Zd=n,Zd}var Jd,s_;function yv(){if(s_)return Jd;s_=1;var e=vv(),n=si();function i(s,o){return s&&e(s,o,n)}return Jd=i,Jd}var eh,o_;function IO(){if(o_)return eh;o_=1;var e=Nr();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 eh=n,eh}var th,a_;function Yu(){if(a_)return th;a_=1;var e=yv(),n=IO(),i=n(e);return th=i,th}var nh,u_;function Hi(){if(u_)return nh;u_=1;function e(n){return n}return nh=e,nh}var rh,l_;function NN(){if(l_)return rh;l_=1;var e=Hi();function n(i){return typeof i=="function"?i:e}return rh=n,rh}var ih,c_;function CN(){if(c_)return ih;c_=1;var e=lv(),n=Yu(),i=NN(),s=xt();function o(u,l){var c=s(u)?e:n;return c(u,i(l))}return ih=o,ih}var sh,f_;function TN(){return f_||(f_=1,sh=CN()),sh}var oh,d_;function MO(){if(d_)return oh;d_=1;var e=Yu();function n(i,s){var o=[];return e(i,function(u,l,c){s(u,l,c)&&o.push(u)}),o}return oh=n,oh}var ah,h_;function PO(){if(h_)return ah;h_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return ah=n,ah}var uh,p_;function OO(){if(p_)return uh;p_=1;function e(n){return this.__data__.has(n)}return uh=e,uh}var lh,m_;function RN(){if(m_)return lh;m_=1;var e=uv(),n=PO(),i=OO();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,lh=s,lh}var ch,g_;function qO(){if(g_)return ch;g_=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 ch=e,ch}var fh,v_;function jN(){if(v_)return fh;v_=1;function e(n,i){return n.has(i)}return fh=e,fh}var dh,y_;function AN(){if(y_)return dh;y_=1;var e=RN(),n=qO(),i=jN(),s=1,o=2;function u(l,c,d,h,p,m){var y=d&s,x=l.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=m.get(l),S=m.get(c);if(_&&S)return _==c&&S==l;var b=-1,k=!0,E=d&o?new e:void 0;for(m.set(l,c),m.set(c,l);++b<x;){var C=l[b],A=c[b];if(h)var P=y?h(A,C,b,c,l,m):h(C,A,b,l,c,m);if(P!==void 0){if(P)continue;k=!1;break}if(E){if(!n(c,function(I,M){if(!i(E,M)&&(C===I||p(C,I,d,h,m)))return E.push(M)})){k=!1;break}}else if(!(C===A||p(C,A,d,h,m))){k=!1;break}}return m.delete(l),m.delete(c),k}return dh=u,dh}var hh,w_;function LO(){if(w_)return hh;w_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,u){s[++i]=[u,o]}),s}return hh=e,hh}var ph,x_;function wv(){if(x_)return ph;x_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return ph=e,ph}var mh,__;function $O(){if(__)return mh;__=1;var e=Ls(),n=_N(),i=qs(),s=AN(),o=LO(),u=wv(),l=1,c=2,d="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function A(P,I,M,R,L,F,J){switch(M){case k:if(P.byteLength!=I.byteLength||P.byteOffset!=I.byteOffset)return!1;P=P.buffer,I=I.buffer;case b:return!(P.byteLength!=I.byteLength||!F(new n(P),new n(I)));case d:case h:case y:return i(+P,+I);case p:return P.name==I.name&&P.message==I.message;case x:case _:return P==I+"";case m:var X=o;case N:var j=R&l;if(X||(X=u),P.size!=I.size&&!j)return!1;var G=J.get(P);if(G)return G==I;R|=c,J.set(P,I);var U=s(X(P),X(I),R,L,F,J);return J.delete(P),U;case S:if(C)return C.call(P)==C.call(I)}return!1}return mh=A,mh}var gh,S_;function DO(){if(S_)return gh;S_=1;var e=wN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(u,l,c,d,h,p){var m=c&n,y=e(u),x=y.length,N=e(l),_=N.length;if(x!=_&&!m)return!1;for(var S=x;S--;){var b=y[S];if(!(m?b in l:s.call(l,b)))return!1}var k=p.get(u),E=p.get(l);if(k&&E)return k==l&&E==u;var C=!0;p.set(u,l),p.set(l,u);for(var A=m;++S<x;){b=y[S];var P=u[b],I=l[b];if(d)var M=m?d(I,P,b,l,u,p):d(P,I,b,u,l,p);if(!(M===void 0?P===I||h(P,I,c,d,p):M)){C=!1;break}A||(A=b=="constructor")}if(C&&!A){var R=u.constructor,L=l.constructor;R!=L&&"constructor"in u&&"constructor"in l&&!(typeof R=="function"&&R instanceof R&&typeof L=="function"&&L instanceof L)&&(C=!1)}return p.delete(u),p.delete(l),C}return gh=o,gh}var vh,b_;function FO(){if(b_)return vh;b_=1;var e=zu(),n=AN(),i=$O(),s=DO(),o=Ds(),u=xt(),l=$s(),c=Ko(),d=1,h="[object Arguments]",p="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,k,E,C){var A=u(_),P=u(S),I=A?p:o(_),M=P?p:o(S);I=I==h?m:I,M=M==h?m:M;var R=I==m,L=M==m,F=I==M;if(F&&l(_)){if(!l(S))return!1;A=!0,R=!1}if(F&&!R)return C||(C=new e),A||c(_)?n(_,S,b,k,E,C):i(_,S,I,b,k,E,C);if(!(b&d)){var J=R&&x.call(_,"__wrapped__"),X=L&&x.call(S,"__wrapped__");if(J||X){var j=J?_.value():_,G=X?S.value():S;return C||(C=new e),E(j,G,b,k,C)}}return F?(C||(C=new e),s(_,S,b,k,E,C)):!1}return vh=N,vh}var yh,k_;function IN(){if(k_)return yh;k_=1;var e=FO(),n=or();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 yh=i,yh}var wh,E_;function zO(){if(E_)return wh;E_=1;var e=zu(),n=IN(),i=1,s=2;function o(u,l,c,d){var h=c.length,p=h,m=!d;if(u==null)return!p;for(u=Object(u);h--;){var y=c[h];if(m&&y[2]?y[1]!==u[y[0]]:!(y[0]in u))return!1}for(;++h<p;){y=c[h];var x=y[0],N=u[x],_=y[1];if(m&&y[2]){if(N===void 0&&!(x in u))return!1}else{var S=new e;if(d)var b=d(N,_,x,u,l,S);if(!(b===void 0?n(_,N,i|s,d,S):b))return!1}}return!0}return wh=o,wh}var xh,N_;function MN(){if(N_)return xh;N_=1;var e=jn();function n(i){return i===i&&!e(i)}return xh=n,xh}var _h,C_;function BO(){if(C_)return _h;C_=1;var e=MN(),n=si();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 _h=i,_h}var Sh,T_;function PN(){if(T_)return Sh;T_=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return Sh=e,Sh}var bh,R_;function UO(){if(R_)return bh;R_=1;var e=zO(),n=BO(),i=PN();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 bh=s,bh}var kh,j_;function Fs(){if(j_)return kh;j_=1;var e=zi(),n=or(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return kh=s,kh}var Eh,A_;function xv(){if(A_)return Eh;A_=1;var e=xt(),n=Fs(),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 Eh=o,Eh}var Nh,I_;function HO(){if(I_)return Nh;I_=1;var e=uv(),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,Nh=i,Nh}var Ch,M_;function VO(){if(M_)return Ch;M_=1;var e=HO(),n=500;function i(s){var o=e(s,function(l){return u.size===n&&u.clear(),l}),u=o.cache;return o}return Ch=i,Ch}var Th,P_;function WO(){if(P_)return Th;P_=1;var e=VO(),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 Th=s,Th}var Rh,O_;function Ku(){if(O_)return Rh;O_=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 Rh=e,Rh}var jh,q_;function GO(){if(q_)return jh;q_=1;var e=Ls(),n=Ku(),i=xt(),s=Fs(),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 jh=l,jh}var Ah,L_;function ON(){if(L_)return Ah;L_=1;var e=GO();function n(i){return i==null?"":e(i)}return Ah=n,Ah}var Ih,$_;function Xu(){if($_)return Ih;$_=1;var e=xt(),n=xv(),i=WO(),s=ON();function o(u,l){return e(u)?u:n(u,l)?[u]:i(s(u))}return Ih=o,Ih}var Mh,D_;function Xo(){if(D_)return Mh;D_=1;var e=Fs();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Mh=n,Mh}var Ph,F_;function Qu(){if(F_)return Ph;F_=1;var e=Xu(),n=Xo();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 Ph=i,Ph}var Oh,z_;function YO(){if(z_)return Oh;z_=1;var e=Qu();function n(i,s,o){var u=i==null?void 0:e(i,s);return u===void 0?o:u}return Oh=n,Oh}var qh,B_;function KO(){if(B_)return qh;B_=1;function e(n,i){return n!=null&&i in Object(n)}return qh=e,qh}var Lh,U_;function qN(){if(U_)return Lh;U_=1;var e=Xu(),n=Yo(),i=xt(),s=Hu(),o=cv(),u=Xo();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 Lh=l,Lh}var $h,H_;function LN(){if(H_)return $h;H_=1;var e=KO(),n=qN();function i(s,o){return s!=null&&n(s,o,e)}return $h=i,$h}var Dh,V_;function XO(){if(V_)return Dh;V_=1;var e=IN(),n=YO(),i=LN(),s=xv(),o=MN(),u=PN(),l=Xo(),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 Dh=h,Dh}var Fh,W_;function $N(){if(W_)return Fh;W_=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Fh=e,Fh}var zh,G_;function QO(){if(G_)return zh;G_=1;var e=Qu();function n(i){return function(s){return e(s,i)}}return zh=n,zh}var Bh,Y_;function ZO(){if(Y_)return Bh;Y_=1;var e=$N(),n=QO(),i=xv(),s=Xo();function o(u){return i(u)?e(s(u)):n(u)}return Bh=o,Bh}var Uh,K_;function Cr(){if(K_)return Uh;K_=1;var e=UO(),n=XO(),i=Hi(),s=xt(),o=ZO();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 Uh=u,Uh}var Hh,X_;function DN(){if(X_)return Hh;X_=1;var e=mN(),n=MO(),i=Cr(),s=xt();function o(u,l){var c=s(u)?e:n;return c(u,i(l,3))}return Hh=o,Hh}var Vh,Q_;function JO(){if(Q_)return Vh;Q_=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return Vh=i,Vh}var Wh,Z_;function FN(){if(Z_)return Wh;Z_=1;var e=JO(),n=qN();function i(s,o){return s!=null&&n(s,o,e)}return Wh=i,Wh}var Gh,J_;function eq(){if(J_)return Gh;J_=1;var e=dv(),n=Ds(),i=Yo(),s=xt(),o=Nr(),u=$s(),l=Wu(),c=Ko(),d="[object Map]",h="[object Set]",p=Object.prototype,m=p.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||u(x)||c(x)||i(x)))return!x.length;var N=n(x);if(N==d||N==h)return!x.size;if(l(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return Gh=y,Gh}var Yh,eS;function zN(){if(eS)return Yh;eS=1;function e(n){return n===void 0}return Yh=e,Yh}var Kh,tS;function BN(){if(tS)return Kh;tS=1;var e=Yu(),n=Nr();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 Kh=i,Kh}var Xh,nS;function UN(){if(nS)return Xh;nS=1;var e=Ku(),n=Cr(),i=BN(),s=xt();function o(u,l){var c=s(u)?e:i;return c(u,n(l,3))}return Xh=o,Xh}var Qh,rS;function tq(){if(rS)return Qh;rS=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 Qh=e,Qh}var Zh,iS;function nq(){if(iS)return Zh;iS=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 Zh=e,Zh}var Jh,sS;function HN(){if(sS)return Jh;sS=1;var e=tq(),n=Yu(),i=Cr(),s=nq(),o=xt();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 Jh=u,Jh}var ep,oS;function rq(){if(oS)return ep;oS=1;var e=zi(),n=xt(),i=or(),s="[object String]";function o(u){return typeof u=="string"||!n(u)&&i(u)&&e(u)==s}return ep=o,ep}var tp,aS;function iq(){if(aS)return tp;aS=1;var e=$N(),n=e("length");return tp=n,tp}var np,uS;function sq(){if(uS)return np;uS=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 np=d,np}var rp,lS;function oq(){if(lS)return rp;lS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,u="\\ufe0e\\ufe0f",l="["+e+"]",c="["+o+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",p="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+u+"]?",S="(?:"+x+"(?:"+[p,m,y].join("|")+")"+_+N+")*",b=_+N+S,k="(?:"+[p+c+"?",c,m,y,l].join("|")+")",E=RegExp(d+"(?="+d+")|"+k+b,"g");function C(A){for(var P=E.lastIndex=0;E.test(A);)++P;return P}return rp=C,rp}var ip,cS;function aq(){if(cS)return ip;cS=1;var e=iq(),n=sq(),i=oq();function s(o){return n(o)?i(o):e(o)}return ip=s,ip}var sp,fS;function uq(){if(fS)return sp;fS=1;var e=dv(),n=Ds(),i=Nr(),s=rq(),o=aq(),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 sp=c,sp}var op,dS;function lq(){if(dS)return op;dS=1;var e=lv(),n=bN(),i=yv(),s=Cr(),o=Gu(),u=xt(),l=$s(),c=Wo(),d=jn(),h=Ko();function p(m,y,x){var N=u(m),_=N||l(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=N?new S:[]:d(m)?x=c(S)?n(o(m)):{}:x={}}return(_?e:i)(m,function(b,k,E){return y(x,b,k,E)}),x}return op=p,op}var ap,hS;function cq(){if(hS)return ap;hS=1;var e=Ls(),n=Yo(),i=xt(),s=e?e.isConcatSpreadable:void 0;function o(u){return i(u)||n(u)||!!(s&&u&&u[s])}return ap=o,ap}var up,pS;function _v(){if(pS)return up;pS=1;var e=pv(),n=cq();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 up=i,up}var lp,mS;function fq(){if(mS)return lp;mS=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 lp=e,lp}var cp,gS;function VN(){if(gS)return cp;gS=1;var e=fq(),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 cp=i,cp}var fp,vS;function dq(){if(vS)return fp;vS=1;var e=gv(),n=cN(),i=Hi(),s=n?function(o,u){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(u),writable:!0})}:i;return fp=s,fp}var dp,yS;function hq(){if(yS)return dp;yS=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 dp=s,dp}var hp,wS;function WN(){if(wS)return hp;wS=1;var e=dq(),n=hq(),i=n(e);return hp=i,hp}var pp,xS;function Zu(){if(xS)return pp;xS=1;var e=Hi(),n=VN(),i=WN();function s(o,u){return i(n(o,u,e),o+"")}return pp=s,pp}var mp,_S;function GN(){if(_S)return mp;_S=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 mp=e,mp}var gp,SS;function pq(){if(SS)return gp;SS=1;function e(n){return n!==n}return gp=e,gp}var vp,bS;function mq(){if(bS)return vp;bS=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 vp=e,vp}var yp,kS;function gq(){if(kS)return yp;kS=1;var e=GN(),n=pq(),i=mq();function s(o,u,l){return u===u?i(o,u,l):e(o,n,l)}return yp=s,yp}var wp,ES;function vq(){if(ES)return wp;ES=1;var e=gq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return wp=n,wp}var xp,NS;function yq(){if(NS)return xp;NS=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 xp=e,xp}var _p,CS;function wq(){if(CS)return _p;CS=1;function e(){}return _p=e,_p}var Sp,TS;function xq(){if(TS)return Sp;TS=1;var e=xN(),n=wq(),i=wv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(u){return new e(u)}:n;return Sp=o,Sp}var bp,RS;function _q(){if(RS)return bp;RS=1;var e=RN(),n=vq(),i=yq(),s=jN(),o=xq(),u=wv(),l=200;function c(d,h,p){var m=-1,y=n,x=d.length,N=!0,_=[],S=_;if(p)N=!1,y=i;else if(x>=l){var b=h?null:o(d);if(b)return u(b);N=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<x;){var k=d[m],E=h?h(k):k;if(k=p||k!==0?k:0,N&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;h&&S.push(E),_.push(k)}else y(S,E,p)||(S!==_&&S.push(E),_.push(k))}return _}return bp=c,bp}var kp,jS;function YN(){if(jS)return kp;jS=1;var e=Nr(),n=or();function i(s){return n(s)&&e(s)}return kp=i,kp}var Ep,AS;function Sq(){if(AS)return Ep;AS=1;var e=_v(),n=Zu(),i=_q(),s=YN(),o=n(function(u){return i(e(u,1,s,!0))});return Ep=o,Ep}var Np,IS;function bq(){if(IS)return Np;IS=1;var e=Ku();function n(i,s){return e(s,function(o){return i[o]})}return Np=n,Np}var Cp,MS;function KN(){if(MS)return Cp;MS=1;var e=bq(),n=si();function i(s){return s==null?[]:e(s,n(s))}return Cp=i,Cp}var Tp,PS;function An(){if(PS)return Tp;PS=1;var e;if(typeof ov=="function")try{e={clone:jO(),constant:gv(),each:TN(),filter:DN(),has:FN(),isArray:xt(),isEmpty:eq(),isFunction:Wo(),isUndefined:zN(),keys:si(),map:UN(),reduce:HN(),size:uq(),transform:lq(),union:Sq(),values:KN()}}catch{}return e||(e=window._),Tp=e,Tp}var Rp,OS;function Sv(){if(OS)return Rp;OS=1;var e=An();Rp=o;var n="\0",i="\0",s="";function o(p){this._isDirected=e.has(p,"directed")?p.directed:!0,this._isMultigraph=e.has(p,"multigraph")?p.multigraph:!1,this._isCompound=e.has(p,"compound")?p.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(p){return this._label=p,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultNodeLabelFn=p,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._in[m])})},o.prototype.sinks=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._out[m])})},o.prototype.setNodes=function(p,m){var y=arguments,x=this;return e.each(p,function(N){y.length>1?x.setNode(N,m):x.setNode(N)}),this},o.prototype.setNode=function(p,m){return e.has(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=m),this):(this._nodes[p]=arguments.length>1?m:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=i,this._children[p]={},this._children[i][p]=!0),this._in[p]={},this._preds[p]={},this._out[p]={},this._sucs[p]={},++this._nodeCount,this)},o.prototype.node=function(p){return this._nodes[p]},o.prototype.hasNode=function(p){return e.has(this._nodes,p)},o.prototype.removeNode=function(p){var m=this;if(e.has(this._nodes,p)){var y=function(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[p],this._isCompound&&(this._removeFromParentsChildList(p),delete this._parent[p],e.each(this.children(p),function(x){m.setParent(x)}),delete this._children[p]),e.each(e.keys(this._in[p]),y),delete this._in[p],delete this._preds[p],e.each(e.keys(this._out[p]),y),delete this._out[p],delete this._sucs[p],--this._nodeCount}return this},o.prototype.setParent=function(p,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=i;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===p)throw new Error("Setting "+m+" as parent of "+p+" would create a cycle");this.setNode(m)}return this.setNode(p),this._removeFromParentsChildList(p),this._parent[p]=m,this._children[m][p]=!0,this},o.prototype._removeFromParentsChildList=function(p){delete this._children[this._parent[p]][p]},o.prototype.parent=function(p){if(this._isCompound){var m=this._parent[p];if(m!==i)return m}},o.prototype.children=function(p){if(e.isUndefined(p)&&(p=i),this._isCompound){var m=this._children[p];if(m)return e.keys(m)}else{if(p===i)return this.nodes();if(this.hasNode(p))return[]}},o.prototype.predecessors=function(p){var m=this._preds[p];if(m)return e.keys(m)},o.prototype.successors=function(p){var m=this._sucs[p];if(m)return e.keys(m)},o.prototype.neighbors=function(p){var m=this.predecessors(p);if(m)return e.union(m,this.successors(p))},o.prototype.isLeaf=function(p){var m;return this.isDirected()?m=this.successors(p):m=this.neighbors(p),m.length===0},o.prototype.filterNodes=function(p){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){p(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var x={};function N(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),m},o.prototype.setDefaultEdgeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultEdgeLabelFn=p,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(p,m){var y=this,x=arguments;return e.reduce(p,function(N,_){return x.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var p,m,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),p=""+p,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,p,m,y);if(e.has(this._edgeLabels,S))return N&&(this._edgeLabels[S]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(p),this.setNode(m),this._edgeLabels[S]=N?x:this._defaultEdgeLabelFn(p,m,y);var b=d(this._isDirected,p,m,y);return p=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,u(this._preds[m],p),u(this._sucs[p],m),this._in[m][S]=b,this._out[p][S]=b,this._edgeCount++,this},o.prototype.edge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y),N=this._edgeObjs[x];return N&&(p=N.v,m=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],l(this._preds[m],p),l(this._sucs[p],m),delete this._in[m][x],delete this._out[p][x],this._edgeCount--),this},o.prototype.inEdges=function(p,m){var y=this._in[p];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.v===m}):x}},o.prototype.outEdges=function(p,m){var y=this._out[p];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.w===m}):x}},o.prototype.nodeEdges=function(p,m){var y=this.inEdges(p,m);if(y)return y.concat(this.outEdges(p,m))};function u(p,m){p[m]?p[m]++:p[m]=1}function l(p,m){--p[m]||delete p[m]}function c(p,m,y,x){var N=""+m,_=""+y;if(!p&&N>_){var S=N;N=_,_=S}return N+s+_+s+(e.isUndefined(x)?n:x)}function d(p,m,y,x){var N=""+m,_=""+y;if(!p&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function h(p,m){return c(p,m.v,m.w,m.name)}return Rp}var jp,qS;function kq(){return qS||(qS=1,jp="2.1.8"),jp}var Ap,LS;function Eq(){return LS||(LS=1,Ap={Graph:Sv(),version:kq()}),Ap}var Ip,$S;function Nq(){if($S)return Ip;$S=1;var e=An(),n=Sv();Ip={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 Ip}var Mp,DS;function Cq(){if(DS)return Mp;DS=1;var e=An();Mp=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 Mp}var Pp,FS;function XN(){if(FS)return Pp;FS=1;var e=An();Pp=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},Pp}var Op,zS;function QN(){if(zS)return Op;zS=1;var e=An(),n=XN();Op=s;var i=e.constant(1);function s(u,l,c,d){return o(u,String(l),c||i,d||function(h){return u.outEdges(h)})}function o(u,l,c,d){var h={},p=new n,m,y,x=function(N){var _=N.v!==m?N.v:N.w,S=h[_],b=c(N),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=m,p.decrease(_,k))};for(u.nodes().forEach(function(N){var _=N===l?0:Number.POSITIVE_INFINITY;h[N]={distance:_},p.add(N,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)d(m).forEach(x);return h}return Op}var qp,BS;function Tq(){if(BS)return qp;BS=1;var e=QN(),n=An();qp=i;function i(s,o,u){return n.transform(s.nodes(),function(l,c){l[c]=e(s,c,o,u)},{})}return qp}var Lp,US;function ZN(){if(US)return Lp;US=1;var e=An();Lp=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 Lp}var $p,HS;function Rq(){if(HS)return $p;HS=1;var e=An(),n=ZN();$p=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 $p}var Dp,VS;function jq(){if(VS)return Dp;VS=1;var e=An();Dp=i;var n=e.constant(1);function i(o,u,l){return s(o,u||n,l||function(c){return o.outEdges(c)})}function s(o,u,l){var c={},d=o.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(p){h!==p&&(c[h][p]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(p){var m=p.v===h?p.w:p.v,y=u(p);c[h][m]={distance:y,predecessor:h}})}),d.forEach(function(h){var p=c[h];d.forEach(function(m){var y=c[m];d.forEach(function(x){var N=y[h],_=p[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Dp}var Fp,WS;function JN(){if(WS)return Fp;WS=1;var e=An();Fp=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,Fp}var zp,GS;function Aq(){if(GS)return zp;GS=1;var e=JN();zp=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return zp}var Bp,YS;function eC(){if(YS)return Bp;YS=1;var e=An();Bp=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 Bp}var Up,KS;function Iq(){if(KS)return Up;KS=1;var e=eC();Up=n;function n(i,s){return e(i,s,"post")}return Up}var Hp,XS;function Mq(){if(XS)return Hp;XS=1;var e=eC();Hp=n;function n(i,s){return e(i,s,"pre")}return Hp}var Vp,QS;function Pq(){if(QS)return Vp;QS=1;var e=An(),n=Sv(),i=XN();Vp=s;function s(o,u){var l=new n,c={},d=new i,h;function p(y){var x=y.v===h?y.w:y.v,N=d.priority(x);if(N!==void 0){var _=u(y);_<N&&(c[x]=h,d.decrease(x,_))}}if(o.nodeCount()===0)return l;e.each(o.nodes(),function(y){d.add(y,Number.POSITIVE_INFINITY),l.setNode(y)}),d.decrease(o.nodes()[0],0);for(var m=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))l.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(p)}return l}return Vp}var Wp,ZS;function Oq(){return ZS||(ZS=1,Wp={components:Cq(),dijkstra:QN(),dijkstraAll:Tq(),findCycles:Rq(),floydWarshall:jq(),isAcyclic:Aq(),postorder:Iq(),preorder:Mq(),prim:Pq(),tarjan:ZN(),topsort:JN()}),Wp}var Gp,JS;function qq(){if(JS)return Gp;JS=1;var e=Eq();return Gp={Graph:e.Graph,json:Nq(),alg:Oq(),version:e.version},Gp}var Yp,eb;function Hn(){if(eb)return Yp;eb=1;var e;if(typeof ov=="function")try{e=qq()}catch{}return e||(e=window.graphlib),Yp=e,Yp}var Kp,tb;function Lq(){if(tb)return Kp;tb=1;var e=EN(),n=1,i=4;function s(o){return e(o,n|i)}return Kp=s,Kp}var Xp,nb;function Ju(){if(nb)return Xp;nb=1;var e=qs(),n=Nr(),i=Hu(),s=jn();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 Xp=o,Xp}var Qp,rb;function $q(){if(rb)return Qp;rb=1;var e=Zu(),n=qs(),i=Ju(),s=Ui(),o=Object.prototype,u=o.hasOwnProperty,l=e(function(c,d){c=Object(c);var h=-1,p=d.length,m=p>2?d[2]:void 0;for(m&&i(d[0],d[1],m)&&(p=1);++h<p;)for(var y=d[h],x=s(y),N=-1,_=x.length;++N<_;){var S=x[N],b=c[S];(b===void 0||n(b,o[S])&&!u.call(c,S))&&(c[S]=y[S])}return c});return Qp=l,Qp}var Zp,ib;function Dq(){if(ib)return Zp;ib=1;var e=Cr(),n=Nr(),i=si();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 Zp=s,Zp}var Jp,sb;function Fq(){if(sb)return Jp;sb=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return Jp=n,Jp}var em,ob;function zq(){if(ob)return em;ob=1;var e=Fq(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return em=i,em}var tm,ab;function Bq(){if(ab)return tm;ab=1;var e=zq(),n=jn(),i=Fs(),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 tm=d,tm}var nm,ub;function tC(){if(ub)return nm;ub=1;var e=Bq(),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 nm=s,nm}var rm,lb;function Uq(){if(lb)return rm;lb=1;var e=tC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return rm=n,rm}var im,cb;function Hq(){if(cb)return im;cb=1;var e=GN(),n=Cr(),i=Uq(),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 im=o,im}var sm,fb;function Vq(){if(fb)return sm;fb=1;var e=Dq(),n=Hq(),i=e(n);return sm=i,sm}var om,db;function nC(){if(db)return om;db=1;var e=_v();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return om=n,om}var am,hb;function Wq(){if(hb)return am;hb=1;var e=vv(),n=NN(),i=Ui();function s(o,u){return o==null?o:e(o,n(u),i)}return am=s,am}var um,pb;function Gq(){if(pb)return um;pb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return um=e,um}var lm,mb;function Yq(){if(mb)return lm;mb=1;var e=Bu(),n=yv(),i=Cr();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 lm=s,lm}var cm,gb;function bv(){if(gb)return cm;gb=1;var e=Fs();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 cm=n,cm}var fm,vb;function Kq(){if(vb)return fm;vb=1;function e(n,i){return n>i}return fm=e,fm}var dm,yb;function Xq(){if(yb)return dm;yb=1;var e=bv(),n=Kq(),i=Hi();function s(o){return o&&o.length?e(o,i,n):void 0}return dm=s,dm}var hm,wb;function rC(){if(wb)return hm;wb=1;var e=Bu(),n=qs();function i(s,o,u){(u!==void 0&&!n(s[o],u)||u===void 0&&!(o in s))&&e(s,o,u)}return hm=i,hm}var pm,xb;function Qq(){if(xb)return pm;xb=1;var e=zi(),n=Gu(),i=or(),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 pm=h,pm}var mm,_b;function iC(){if(_b)return mm;_b=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return mm=e,mm}var gm,Sb;function Zq(){if(Sb)return gm;Sb=1;var e=Go(),n=Ui();function i(s){return e(s,n(s))}return gm=i,gm}var vm,bb;function Jq(){if(bb)return vm;bb=1;var e=rC(),n=hN(),i=SN(),s=pN(),o=kN(),u=Yo(),l=xt(),c=YN(),d=$s(),h=Wo(),p=jn(),m=Qq(),y=Ko(),x=iC(),N=Zq();function _(S,b,k,E,C,A,P){var I=x(S,k),M=x(b,k),R=P.get(M);if(R){e(S,k,R);return}var L=A?A(I,M,k+"",S,b,P):void 0,F=L===void 0;if(F){var J=l(M),X=!J&&d(M),j=!J&&!X&&y(M);L=M,J||X||j?l(I)?L=I:c(I)?L=s(I):X?(F=!1,L=n(M,!0)):j?(F=!1,L=i(M,!0)):L=[]:m(M)||u(M)?(L=I,u(I)?L=N(I):(!p(I)||h(I))&&(L=o(M))):F=!1}F&&(P.set(M,L),C(L,M,E,A,P),P.delete(M)),e(S,k,L)}return vm=_,vm}var ym,kb;function eL(){if(kb)return ym;kb=1;var e=zu(),n=rC(),i=vv(),s=Jq(),o=jn(),u=Ui(),l=iC();function c(d,h,p,m,y){d!==h&&i(h,function(x,N){if(y||(y=new e),o(x))s(d,h,N,p,c,m,y);else{var _=m?m(l(d,N),x,N+"",d,h,y):void 0;_===void 0&&(_=x),n(d,N,_)}},u)}return ym=c,ym}var wm,Eb;function tL(){if(Eb)return wm;Eb=1;var e=Zu(),n=Ju();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 wm=i,wm}var xm,Nb;function nL(){if(Nb)return xm;Nb=1;var e=eL(),n=tL(),i=n(function(s,o,u){e(s,o,u)});return xm=i,xm}var _m,Cb;function sC(){if(Cb)return _m;Cb=1;function e(n,i){return n<i}return _m=e,_m}var Sm,Tb;function rL(){if(Tb)return Sm;Tb=1;var e=bv(),n=sC(),i=Hi();function s(o){return o&&o.length?e(o,i,n):void 0}return Sm=s,Sm}var bm,Rb;function iL(){if(Rb)return bm;Rb=1;var e=bv(),n=Cr(),i=sC();function s(o,u){return o&&o.length?e(o,n(u,2),i):void 0}return bm=s,bm}var km,jb;function sL(){if(jb)return km;jb=1;var e=Wn(),n=function(){return e.Date.now()};return km=n,km}var Em,Ab;function oL(){if(Ab)return Em;Ab=1;var e=Uu(),n=Xu(),i=Hu(),s=jn(),o=Xo();function u(l,c,d,h){if(!s(l))return l;c=n(c,l);for(var p=-1,m=c.length,y=m-1,x=l;x!=null&&++p<m;){var N=o(c[p]),_=d;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(p!=y){var S=x[N];_=h?h(S,N,x):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(x,N,_),x=x[N]}return l}return Em=u,Em}var Nm,Ib;function aL(){if(Ib)return Nm;Ib=1;var e=Qu(),n=oL(),i=Xu();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 Nm=s,Nm}var Cm,Mb;function uL(){if(Mb)return Cm;Mb=1;var e=aL(),n=LN();function i(s,o){return e(s,o,function(u,l){return n(s,l)})}return Cm=i,Cm}var Tm,Pb;function lL(){if(Pb)return Tm;Pb=1;var e=nC(),n=VN(),i=WN();function s(o){return i(n(o,void 0,e),o+"")}return Tm=s,Tm}var Rm,Ob;function cL(){if(Ob)return Rm;Ob=1;var e=uL(),n=lL(),i=n(function(s,o){return s==null?{}:e(s,o)});return Rm=i,Rm}var jm,qb;function fL(){if(qb)return jm;qb=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 jm=i,jm}var Am,Lb;function dL(){if(Lb)return Am;Lb=1;var e=fL(),n=Ju(),i=tC();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 Am=s,Am}var Im,$b;function hL(){if($b)return Im;$b=1;var e=dL(),n=e();return Im=n,Im}var Mm,Db;function pL(){if(Db)return Mm;Db=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Mm=e,Mm}var Pm,Fb;function mL(){if(Fb)return Pm;Fb=1;var e=Fs();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 Pm=n,Pm}var Om,zb;function gL(){if(zb)return Om;zb=1;var e=mL();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 Om=n,Om}var qm,Bb;function vL(){if(Bb)return qm;Bb=1;var e=Ku(),n=Qu(),i=Cr(),s=BN(),o=pL(),u=Vu(),l=gL(),c=Hi(),d=xt();function h(p,m,y){m.length?m=e(m,function(_){return d(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,u(i));var N=s(p,function(_,S,b){var k=e(m,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,S){return l(_,S,y)})}return qm=h,qm}var Lm,Ub;function yL(){if(Ub)return Lm;Ub=1;var e=_v(),n=vL(),i=Zu(),s=Ju(),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 Lm=o,Lm}var $m,Hb;function wL(){if(Hb)return $m;Hb=1;var e=ON(),n=0;function i(s){var o=++n;return e(s)+o}return $m=i,$m}var Dm,Vb;function xL(){if(Vb)return Dm;Vb=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 Dm=e,Dm}var Fm,Wb;function _L(){if(Wb)return Fm;Wb=1;var e=Uu(),n=xL();function i(s,o){return n(s||[],o||[],e)}return Fm=i,Fm}var zm,Gb;function ut(){if(Gb)return zm;Gb=1;var e;if(typeof ov=="function")try{e={cloneDeep:Lq(),constant:gv(),defaults:$q(),each:TN(),filter:DN(),find:Vq(),flatten:nC(),forEach:CN(),forIn:Wq(),has:FN(),isUndefined:zN(),last:Gq(),map:UN(),mapValues:Yq(),max:Xq(),merge:nL(),min:rL(),minBy:iL(),now:sL(),pick:cL(),range:hL(),reduce:HN(),sortBy:yL(),uniqueId:wL(),values:KN(),zipObject:_L()}}catch{}return e||(e=window._),zm=e,zm}var Bm,Yb;function SL(){if(Yb)return Bm;Yb=1,Bm=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 Bm}var Um,Kb;function bL(){if(Kb)return Um;Kb=1;var e=ut(),n=Hn().Graph,i=SL();Um=o;var s=e.constant(1);function o(h,p){if(h.nodeCount()<=1)return[];var m=c(h,p||s),y=u(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function u(h,p,m){for(var y=[],x=p[p.length-1],N=p[0],_;h.nodeCount();){for(;_=N.dequeue();)l(h,p,m,_);for(;_=x.dequeue();)l(h,p,m,_);if(h.nodeCount()){for(var S=p.length-2;S>0;--S)if(_=p[S].dequeue(),_){y=y.concat(l(h,p,m,_,!0));break}}}return y}function l(h,p,m,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,d(p,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,k=h.node(b);k.in-=S,d(p,m,k)}),h.removeNode(y.v),N}function c(h,p){var m=new n,y=0,x=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,k=p(S),E=b+k;m.setEdge(S.v,S.w,E),x=Math.max(x,m.node(S.v).out+=k),y=Math.max(y,m.node(S.w).in+=k)});var N=e.range(x+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){d(N,_,m.node(S))}),{graph:m,buckets:N,zeroIdx:_}}function d(h,p,m){m.out?m.in?h[m.out-m.in+p].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Um}var Hm,Xb;function kL(){if(Xb)return Hm;Xb=1;var e=ut(),n=bL();Hm={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 Hm}var Vm,Qb;function un(){if(Qb)return Vm;Qb=1;var e=ut(),n=Hn().Graph;Vm={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:u,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:p,addBorderNode:m,maxRank:y,partition:x,time:N,notime:_};function i(S,b,k,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return k.dummy=b,S.setNode(C,k),C}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var E=b.edge(k.v,k.w)||{weight:0,minlen:1},C=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function u(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function l(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,C=b.x-k,A=b.y-E,P=S.width/2,I=S.height/2;if(!C&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var M,R;return Math.abs(A)*P>Math.abs(C)*I?(A<0&&(I=-I),M=I*C/A,R=I):(C<0&&(P=-P),M=P,R=P*A/C),{x:k+M,y:E+R}}function d(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var E=S.node(k),C=E.rank;e.isUndefined(C)||(b[C][E.order]=k)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var E=S.node(k);e.has(E,"rank")&&(E.rank-=b)})}function p(S){var b=e.min(e.map(S.nodes(),function(A){return S.node(A).rank})),k=[];e.forEach(S.nodes(),function(A){var P=S.node(A).rank-b;k[P]||(k[P]=[]),k[P].push(A)});var E=0,C=S.graph().nodeRankFactor;e.forEach(k,function(A,P){e.isUndefined(A)&&P%C!==0?--E:E&&e.forEach(A,function(I){S.node(I).rank+=E})})}function m(S,b,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),i(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return Vm}var Wm,Zb;function EL(){if(Zb)return Wm;Zb=1;var e=ut(),n=un();Wm={run:i,undo:o};function i(u){u.graph().dummyChains=[],e.forEach(u.edges(),function(l){s(u,l)})}function s(u,l){var c=l.v,d=u.node(c).rank,h=l.w,p=u.node(h).rank,m=l.name,y=u.edge(l),x=y.labelRank;if(p!==d+1){u.removeEdge(l);var N,_,S;for(S=0,++d;d<p;++S,++d)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:l,rank:d},N=n.addDummyNode(u,"edge",_,"_d"),d===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),u.setEdge(c,N,{weight:y.weight},m),S===0&&u.graph().dummyChains.push(N),c=N;u.setEdge(c,h,{weight:y.weight},m)}}function o(u){e.forEach(u.graph().dummyChains,function(l){var c=u.node(l),d=c.edgeLabel,h;for(u.setEdge(c.edgeObj,d);c.dummy;)h=u.successors(l)[0],u.removeNode(l),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),l=h,c=u.node(l)})}return Wm}var Gm,Jb;function Ru(){if(Jb)return Gm;Jb=1;var e=ut();Gm={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 Gm}var Ym,ek;function oC(){if(ek)return Ym;ek=1;var e=ut(),n=Hn().Graph,i=Ru().slack;Ym=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 Ym}var Km,tk;function NL(){if(tk)return Km;tk=1;var e=ut(),n=oC(),i=Ru().slack,s=Ru().longestPath,o=Hn().alg.preorder,u=Hn().alg.postorder,l=un().simplify;Km=c,c.initLowLimValues=m,c.initCutValues=d,c.calcCutValue=p,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=l(E),s(E);var C=n(E);m(C),d(C,E);for(var A,P;A=x(C);)P=N(C,E,A),_(C,E,A,P)}function d(E,C){var A=u(E,E.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(P){h(E,C,P)})}function h(E,C,A){var P=E.node(A),I=P.parent;E.edge(A,I).cutvalue=p(E,C,A)}function p(E,C,A){var P=E.node(A),I=P.parent,M=!0,R=C.edge(A,I),L=0;return R||(M=!1,R=C.edge(I,A)),L=R.weight,e.forEach(C.nodeEdges(A),function(F){var J=F.v===A,X=J?F.w:F.v;if(X!==I){var j=J===M,G=C.edge(F).weight;if(L+=j?G:-G,b(E,A,X)){var U=E.edge(A,X).cutvalue;L+=j?-U:U}}}),L}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,A,P,I){var M=A,R=E.node(P);return C[P]=!0,e.forEach(E.neighbors(P),function(L){e.has(C,L)||(A=y(E,C,A,L,P))}),R.low=M,R.lim=A++,I?R.parent=I:delete R.parent,A}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,A){var P=A.v,I=A.w;C.hasEdge(P,I)||(P=A.w,I=A.v);var M=E.node(P),R=E.node(I),L=M,F=!1;M.lim>R.lim&&(L=R,F=!0);var J=e.filter(C.edges(),function(X){return F===k(E,E.node(X.v),L)&&F!==k(E,E.node(X.w),L)});return e.minBy(J,function(X){return i(C,X)})}function _(E,C,A,P){var I=A.v,M=A.w;E.removeEdge(I,M),E.setEdge(P.v,P.w,{}),m(E),d(E,C),S(E,C)}function S(E,C){var A=e.find(E.nodes(),function(I){return!C.node(I).parent}),P=o(E,A);P=P.slice(1),e.forEach(P,function(I){var M=E.node(I).parent,R=C.edge(I,M),L=!1;R||(R=C.edge(M,I),L=!0),C.node(I).rank=C.node(M).rank+(L?R.minlen:-R.minlen)})}function b(E,C,A){return E.hasEdge(C,A)}function k(E,C,A){return A.low<=C.lim&&C.lim<=A.lim}return Km}var Xm,nk;function CL(){if(nk)return Xm;nk=1;var e=Ru(),n=e.longestPath,i=oC(),s=NL();Xm=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 Xm}var Qm,rk;function TL(){if(rk)return Qm;rk=1;var e=ut();Qm=n;function n(o){var u=s(o);e.forEach(o.graph().dummyChains,function(l){for(var c=o.node(l),d=c.edgeObj,h=i(o,u,d.v,d.w),p=h.path,m=h.lca,y=0,x=p[y],N=!0;l!==d.w;){if(c=o.node(l),N){for(;(x=p[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(N=!1)}if(!N){for(;y<p.length-1&&o.node(x=p[y+1]).minRank<=c.rank;)y++;x=p[y]}o.setParent(l,x),l=o.successors(l)[0]}})}function i(o,u,l,c){var d=[],h=[],p=Math.min(u[l].low,u[c].low),m=Math.max(u[l].lim,u[c].lim),y,x;y=l;do y=o.parent(y),d.push(y);while(y&&(u[y].low>p||m>u[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:d.concat(h.reverse()),lca:x}}function s(o){var u={},l=0;function c(d){var h=l;e.forEach(o.children(d),c),u[d]={low:h,lim:l++}}return e.forEach(o.children(),c),u}return Qm}var Zm,ik;function RL(){if(ik)return Zm;ik=1;var e=ut(),n=un();Zm={run:i,cleanup:l};function i(c){var d=n.addDummyNode(c,"root",{},"_root"),h=o(c),p=e.max(e.values(h))-1,m=2*p+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=u(c)+1;e.forEach(c.children(),function(x){s(c,d,m,y,p,h,x)}),c.graph().nodeRankFactor=m}function s(c,d,h,p,m,y,x){var N=c.children(x);if(!N.length){x!==d&&c.setEdge(d,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(N,function(k){s(c,d,h,p,m,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,A=E.borderBottom?E.borderBottom:k,P=E.borderTop?p:2*p,I=C!==A?1:m-y[x]+1;c.setEdge(_,C,{weight:P,minlen:I,nestingEdge:!0}),c.setEdge(A,S,{weight:P,minlen:I,nestingEdge:!0})}),c.parent(x)||c.setEdge(d,_,{weight:0,minlen:m+y[x]})}function o(c){var d={};function h(p,m){var y=c.children(p);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),d[p]=m}return e.forEach(c.children(),function(p){h(p,1)}),d}function u(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var p=c.edge(h);p.nestingEdge&&c.removeEdge(h)})}return Zm}var Jm,sk;function jL(){if(sk)return Jm;sk=1;var e=ut(),n=un();Jm=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 Jm}var eg,ok;function AL(){if(ok)return eg;ok=1;var e=ut();eg={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 eg}var tg,ak;function IL(){if(ak)return tg;ak=1;var e=ut();tg=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 tg}var ng,uk;function ML(){if(uk)return ng;uk=1;var e=ut();ng=n;function n(s,o){for(var u=0,l=1;l<o.length;++l)u+=i(s,o[l-1],o[l]);return u}function i(s,o,u){for(var l=e.zipObject(u,e.map(u,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:l[x.w],weight:s.edge(x).weight}}),"pos")}),!0),d=1;d<u.length;)d<<=1;var h=2*d-1;d-=1;var p=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+d;p[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=p[x+1]),x=x-1>>1,p[x]+=y.weight;m+=y.weight*N})),m}return ng}var rg,lk;function PL(){if(lk)return rg;lk=1;var e=ut();rg=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 rg}var ig,ck;function OL(){if(ck)return ig;ck=1;var e=ut();ig=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 ig}var sg,fk;function qL(){if(fk)return sg;fk=1;var e=ut(),n=un();sg=i;function i(u,l){var c=n.partition(u,function(_){return e.has(_,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),p=[],m=0,y=0,x=0;d.sort(o(!!l)),x=s(p,h,x),e.forEach(d,function(_){x+=_.vs.length,p.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(p,h,x)});var N={vs:e.flatten(p,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function s(u,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),u.push(d.vs),c++;return c}function o(u){return function(l,c){return l.barycenter<c.barycenter?-1:l.barycenter>c.barycenter?1:u?c.i-l.i:l.i-c.i}}return sg}var og,dk;function LL(){if(dk)return og;dk=1;var e=ut(),n=PL(),i=OL(),s=qL();og=o;function o(c,d,h,p){var m=c.children(d),y=c.node(d),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(A){return A!==x&&A!==N}));var S=n(c,m);e.forEach(S,function(A){if(c.children(A.v).length){var P=o(c,A.v,h,p);_[A.v]=P,e.has(P,"barycenter")&&l(A,P)}});var b=i(S,h);u(b,_);var k=s(b,p);if(x&&(k.vs=e.flatten([x,k.vs,N],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+C.order)/(k.weight+2),k.weight+=2}return k}function u(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(p){return d[p]?d[p].vs:p}),!0)})}function l(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return og}var ag,hk;function $L(){if(hk)return ag;hk=1;var e=ut(),n=Hn().Graph;ag=i;function i(o,u,l){var c=s(o),d=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var p=o.node(h),m=o.parent(h);(p.rank===u||p.minRank<=u&&u<=p.maxRank)&&(d.setNode(h),d.setParent(h,m||c),e.forEach(o[l](h),function(y){var x=y.v===h?y.w:y.v,N=d.edge(x,h),_=e.isUndefined(N)?0:N.weight;d.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(p,"minRank")&&d.setNode(h,{borderLeft:p.borderLeft[u],borderRight:p.borderRight[u]}))}),d}function s(o){for(var u;o.hasNode(u=e.uniqueId("_root")););return u}return ag}var ug,pk;function DL(){if(pk)return ug;pk=1;var e=ut();ug=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 ug}var lg,mk;function FL(){if(mk)return lg;mk=1;var e=ut(),n=IL(),i=ML(),s=LL(),o=$L(),u=DL(),l=Hn().Graph,c=un();lg=d;function d(y){var x=c.maxRank(y),N=h(y,e.range(1,x+1),"inEdges"),_=h(y,e.range(x-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){p(E%2?N:_,E%4>=2),S=c.buildLayerMatrix(y);var A=i(y,S);A<b&&(C=0,k=e.cloneDeep(S),b=A)}m(y,k)}function h(y,x,N){return e.map(x,function(_){return o(y,_,N)})}function p(y,x){var N=new l;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,N,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),u(_,N,b.vs)})}function m(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return lg}var cg,gk;function zL(){if(gk)return cg;gk=1;var e=ut(),n=Hn().Graph,i=un();cg={positionX:N,findType1Conflicts:s,findType2Conflicts:o,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(b,k){var E={};function C(A,P){var I=0,M=0,R=A.length,L=e.last(P);return e.forEach(P,function(F,J){var X=u(b,F),j=X?b.node(X).order:R;(X||F===L)&&(e.forEach(P.slice(M,J+1),function(G){e.forEach(b.predecessors(G),function(U){var ne=b.node(U),K=ne.order;(K<I||j<K)&&!(ne.dummy&&b.node(G).dummy)&&l(E,U,G)})}),M=J+1,I=j)}),P}return e.reduce(k,C),E}function o(b,k){var E={};function C(P,I,M,R,L){var F;e.forEach(e.range(I,M),function(J){F=P[J],b.node(F).dummy&&e.forEach(b.predecessors(F),function(X){var j=b.node(X);j.dummy&&(j.order<R||j.order>L)&&l(E,X,F)})})}function A(P,I){var M=-1,R,L=0;return e.forEach(I,function(F,J){if(b.node(F).dummy==="border"){var X=b.predecessors(F);X.length&&(R=b.node(X[0]).order,C(I,L,J,M,R),L=J,M=R)}C(I,L,I.length,R,P.length)}),I}return e.reduce(k,A),E}function u(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(E){return b.node(E).dummy})}function l(b,k,E){if(k>E){var C=k;k=E,E=C}var A=b[k];A||(b[k]=A={}),A[E]=!0}function c(b,k,E){if(k>E){var C=k;k=E,E=C}return e.has(b[k],E)}function d(b,k,E,C){var A={},P={},I={};return e.forEach(k,function(M){e.forEach(M,function(R,L){A[R]=R,P[R]=R,I[R]=L})}),e.forEach(k,function(M){var R=-1;e.forEach(M,function(L){var F=C(L);if(F.length){F=e.sortBy(F,function(U){return I[U]});for(var J=(F.length-1)/2,X=Math.floor(J),j=Math.ceil(J);X<=j;++X){var G=F[X];P[L]===L&&R<I[G]&&!c(E,L,G)&&(P[G]=L,P[L]=A[L]=A[G],R=I[G])}}})}),{root:A,align:P}}function h(b,k,E,C,A){var P={},I=p(b,k,E,A),M=A?"borderLeft":"borderRight";function R(J,X){for(var j=I.nodes(),G=j.pop(),U={};G;)U[G]?J(G):(U[G]=!0,j.push(G),j=j.concat(X(G))),G=j.pop()}function L(J){P[J]=I.inEdges(J).reduce(function(X,j){return Math.max(X,P[j.v]+I.edge(j))},0)}function F(J){var X=I.outEdges(J).reduce(function(G,U){return Math.min(G,P[U.w]-I.edge(U))},Number.POSITIVE_INFINITY),j=b.node(J);X!==Number.POSITIVE_INFINITY&&j.borderType!==M&&(P[J]=Math.max(P[J],X))}return R(L,I.predecessors.bind(I)),R(F,I.successors.bind(I)),e.forEach(C,function(J){P[J]=P[E[J]]}),P}function p(b,k,E,C){var A=new n,P=b.graph(),I=_(P.nodesep,P.edgesep,C);return e.forEach(k,function(M){var R;e.forEach(M,function(L){var F=E[L];if(A.setNode(F),R){var J=E[R],X=A.edge(J,F);A.setEdge(J,F,Math.max(I(b,L,R),X||0))}R=L})}),A}function m(b,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(E,function(P,I){var M=S(b,I)/2;C=Math.max(P+M,C),A=Math.min(P-M,A)}),C-A})}function y(b,k){var E=e.values(k),C=e.min(E),A=e.max(E);e.forEach(["u","d"],function(P){e.forEach(["l","r"],function(I){var M=P+I,R=b[M],L;if(R!==k){var F=e.values(R);L=I==="l"?C-e.min(F):A-e.max(F),L&&(b[M]=e.mapValues(R,function(J){return J+L}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,C){if(k)return b[k.toLowerCase()][C];var A=e.sortBy(e.map(b,C));return(A[1]+A[2])/2})}function N(b){var k=i.buildLayerMatrix(b),E=e.merge(s(b,k),o(b,k)),C={},A;e.forEach(["u","d"],function(I){A=I==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(M){M==="r"&&(A=e.map(A,function(J){return e.values(J).reverse()}));var R=(I==="u"?b.predecessors:b.successors).bind(b),L=d(b,A,E,R),F=h(b,A,L.root,L.align,M==="r");M==="r"&&(F=e.mapValues(F,function(J){return-J})),C[I+M]=F})});var P=m(b,C);return y(C,P),x(C,b.graph().align)}function _(b,k,E){return function(C,A,P){var I=C.node(A),M=C.node(P),R=0,L;if(R+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":L=-I.width/2;break;case"r":L=I.width/2;break}if(L&&(R+=E?L:-L),L=0,R+=(I.dummy?k:b)/2,R+=(M.dummy?k:b)/2,R+=M.width/2,e.has(M,"labelpos"))switch(M.labelpos.toLowerCase()){case"l":L=M.width/2;break;case"r":L=-M.width/2;break}return L&&(R+=E?L:-L),L=0,R}}function S(b,k){return b.node(k).width}return cg}var fg,vk;function BL(){if(vk)return fg;vk=1;var e=ut(),n=un(),i=zL().positionX;fg=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 fg}var dg,yk;function UL(){if(yk)return dg;yk=1;var e=ut(),n=kL(),i=EL(),s=CL(),o=un().normalizeRanks,u=TL(),l=un().removeEmptyRanks,c=RL(),d=jL(),h=AL(),p=FL(),m=BL(),y=un(),x=Hn().Graph;dg=N;function N(z,H){var ee=H&&H.debugTiming?y.time:y.notime;ee("layout",function(){var se=ee(" buildLayoutGraph",function(){return R(z)});ee(" runLayout",function(){_(se,ee)}),ee(" updateInputGraph",function(){S(z,se)})})}function _(z,H){H(" makeSpaceForEdgeLabels",function(){L(z)}),H(" removeSelfEdges",function(){$(z)}),H(" acyclic",function(){n.run(z)}),H(" nestingGraph.run",function(){c.run(z)}),H(" rank",function(){s(y.asNonCompoundGraph(z))}),H(" injectEdgeLabelProxies",function(){F(z)}),H(" removeEmptyRanks",function(){l(z)}),H(" nestingGraph.cleanup",function(){c.cleanup(z)}),H(" normalizeRanks",function(){o(z)}),H(" assignRankMinMax",function(){J(z)}),H(" removeEdgeLabelProxies",function(){X(z)}),H(" normalize.run",function(){i.run(z)}),H(" parentDummyChains",function(){u(z)}),H(" addBorderSegments",function(){d(z)}),H(" order",function(){p(z)}),H(" insertSelfEdges",function(){W(z)}),H(" adjustCoordinateSystem",function(){h.adjust(z)}),H(" position",function(){m(z)}),H(" positionSelfEdges",function(){O(z)}),H(" removeBorderNodes",function(){K(z)}),H(" normalize.undo",function(){i.undo(z)}),H(" fixupEdgeLabelCoords",function(){U(z)}),H(" undoCoordinateSystem",function(){h.undo(z)}),H(" translateGraph",function(){j(z)}),H(" assignNodeIntersects",function(){G(z)}),H(" reversePoints",function(){ne(z)}),H(" acyclic.undo",function(){n.undo(z)})}function S(z,H){e.forEach(z.nodes(),function(ee){var se=z.node(ee),ce=H.node(ee);se&&(se.x=ce.x,se.y=ce.y,H.children(ee).length&&(se.width=ce.width,se.height=ce.height))}),e.forEach(z.edges(),function(ee){var se=z.edge(ee),ce=H.edge(ee);se.points=ce.points,e.has(ce,"x")&&(se.x=ce.x,se.y=ce.y)}),z.graph().width=H.graph().width,z.graph().height=H.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],A={width:0,height:0},P=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},M=["labelpos"];function R(z){var H=new x({multigraph:!0,compound:!0}),ee=ae(z.graph());return H.setGraph(e.merge({},k,B(ee,b),e.pick(ee,E))),e.forEach(z.nodes(),function(se){var ce=ae(z.node(se));H.setNode(se,e.defaults(B(ce,C),A)),H.setParent(se,z.parent(se))}),e.forEach(z.edges(),function(se){var ce=ae(z.edge(se));H.setEdge(se,e.merge({},I,B(ce,P),e.pick(ce,M)))}),H}function L(z){var H=z.graph();H.ranksep/=2,e.forEach(z.edges(),function(ee){var se=z.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(H.rankdir==="TB"||H.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function F(z){e.forEach(z.edges(),function(H){var ee=z.edge(H);if(ee.width&&ee.height){var se=z.node(H.v),ce=z.node(H.w),me={rank:(ce.rank-se.rank)/2+se.rank,e:H};y.addDummyNode(z,"edge-proxy",me,"_ep")}})}function J(z){var H=0;e.forEach(z.nodes(),function(ee){var se=z.node(ee);se.borderTop&&(se.minRank=z.node(se.borderTop).rank,se.maxRank=z.node(se.borderBottom).rank,H=e.max(H,se.maxRank))}),z.graph().maxRank=H}function X(z){e.forEach(z.nodes(),function(H){var ee=z.node(H);ee.dummy==="edge-proxy"&&(z.edge(ee.e).labelRank=ee.rank,z.removeNode(H))})}function j(z){var H=Number.POSITIVE_INFINITY,ee=0,se=Number.POSITIVE_INFINITY,ce=0,me=z.graph(),ve=me.marginx||0,Ae=me.marginy||0;function Ue(Me){var Pe=Me.x,be=Me.y,Fe=Me.width,we=Me.height;H=Math.min(H,Pe-Fe/2),ee=Math.max(ee,Pe+Fe/2),se=Math.min(se,be-we/2),ce=Math.max(ce,be+we/2)}e.forEach(z.nodes(),function(Me){Ue(z.node(Me))}),e.forEach(z.edges(),function(Me){var Pe=z.edge(Me);e.has(Pe,"x")&&Ue(Pe)}),H-=ve,se-=Ae,e.forEach(z.nodes(),function(Me){var Pe=z.node(Me);Pe.x-=H,Pe.y-=se}),e.forEach(z.edges(),function(Me){var Pe=z.edge(Me);e.forEach(Pe.points,function(be){be.x-=H,be.y-=se}),e.has(Pe,"x")&&(Pe.x-=H),e.has(Pe,"y")&&(Pe.y-=se)}),me.width=ee-H+ve,me.height=ce-se+Ae}function G(z){e.forEach(z.edges(),function(H){var ee=z.edge(H),se=z.node(H.v),ce=z.node(H.w),me,ve;ee.points?(me=ee.points[0],ve=ee.points[ee.points.length-1]):(ee.points=[],me=ce,ve=se),ee.points.unshift(y.intersectRect(se,me)),ee.points.push(y.intersectRect(ce,ve))})}function U(z){e.forEach(z.edges(),function(H){var ee=z.edge(H);if(e.has(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function ne(z){e.forEach(z.edges(),function(H){var ee=z.edge(H);ee.reversed&&ee.points.reverse()})}function K(z){e.forEach(z.nodes(),function(H){if(z.children(H).length){var ee=z.node(H),se=z.node(ee.borderTop),ce=z.node(ee.borderBottom),me=z.node(e.last(ee.borderLeft)),ve=z.node(e.last(ee.borderRight));ee.width=Math.abs(ve.x-me.x),ee.height=Math.abs(ce.y-se.y),ee.x=me.x+ee.width/2,ee.y=se.y+ee.height/2}}),e.forEach(z.nodes(),function(H){z.node(H).dummy==="border"&&z.removeNode(H)})}function $(z){e.forEach(z.edges(),function(H){if(H.v===H.w){var ee=z.node(H.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:H,label:z.edge(H)}),z.removeEdge(H)}})}function W(z){var H=y.buildLayerMatrix(z);e.forEach(H,function(ee){var se=0;e.forEach(ee,function(ce,me){var ve=z.node(ce);ve.order=me+se,e.forEach(ve.selfEdges,function(Ae){y.addDummyNode(z,"selfedge",{width:Ae.label.width,height:Ae.label.height,rank:ve.rank,order:me+ ++se,e:Ae.e,label:Ae.label},"_se")}),delete ve.selfEdges})})}function O(z){e.forEach(z.nodes(),function(H){var ee=z.node(H);if(ee.dummy==="selfedge"){var se=z.node(ee.e.v),ce=se.x+se.width/2,me=se.y,ve=ee.x-ce,Ae=se.height/2;z.setEdge(ee.e,ee.label),z.removeNode(H),ee.label.points=[{x:ce+2*ve/3,y:me-Ae},{x:ce+5*ve/6,y:me-Ae},{x:ce+ve,y:me},{x:ce+5*ve/6,y:me+Ae},{x:ce+2*ve/3,y:me+Ae}],ee.label.x=ee.x,ee.label.y=ee.y}})}function B(z,H){return e.mapValues(e.pick(z,H),Number)}function ae(z){var H={};return e.forEach(z,function(ee,se){H[se.toLowerCase()]=ee}),H}return dg}var hg,wk;function HL(){if(wk)return hg;wk=1;var e=ut(),n=un(),i=Hn().Graph;hg={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 hg}var pg,xk;function VL(){return xk||(xk=1,pg="0.8.5"),pg}var mg,_k;function WL(){return _k||(_k=1,mg={graphlib:Hn(),layout:UL(),debug:HL(),util:{time:un().time,notime:un().notime},version:VL()}),mg}var GL=WL();const Sk=Dg(GL),$i=240,js=130,As=74,el=72,bk=As+el;function YL(e){let n=$i;for(const i of e.values())n=Math.max(n,i.width);return n}const KL=420,XL=2;function tl(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function QL(e,n,i,s,o){const u=new Sk.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)??$i,height:(S==null?void 0:S.height)??js})}for(const _ of n)c.has(_.source)&&c.has(_.target)&&u.setEdge(_.source,_.target);Sk.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)??$i,E=(b==null?void 0:b.height)??js,C=S.x-k/2,A=S.y-E/2;d.set(_,{x:C,y:A}),C<h&&(h=C),A<p&&(p=A),C+k>m&&(m=C+k),A+E>y&&(y=A+E)}if(Number.isFinite(h)&&Number.isFinite(p))for(const[_,S]of d)d.set(_,{x:S.x-h,y:S.y-p});let x=Number.isFinite(m)?m-h:0,N=Number.isFinite(y)?y-p:0;for(const _ of e){const S=o.get(_);if(!S)continue;const b=s.get(_);x=Math.max(x,S.x+((b==null?void 0:b.width)??$i)),N=Math.max(N,S.y+((b==null?void 0:b.height)??js))}return{positions:d,width:x,height:N}}function ZL(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=tl(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,...QL(l.get(S),n,s,u,o)})),h=YL(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+bk;return b},y=S=>S.reduce((b,k)=>Math.max(b,k.width),0)+KL;let x=m(i.availableWidth?XL:1);x.length>1&&x.reduce((b,k)=>b+y(k),0)+h*(x.length-1)>(i.availableWidth??0)&&(x=m(1));const N=new Map;let _=0;for(const S of x){let b=0;for(const{positions:k,height:E}of S){for(const[C,A]of k)N.set(C,{x:A.x+_,y:A.y+b});b+=E+bk}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const k=N.get(S.id);return k?{...S,position:k}:S})}function JL(e,n,i,s){const u=As+el,l=60,c=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??$i,h:(x==null?void 0:x.height)??js}},d=new Map(e.map(y=>[y.id,tl(y)])),h=[],p=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,x)=>y.pos.y-x.pos.y||y.pos.x-x.pos.x||y.id.localeCompare(x.id)),m=[];for(const{id:y,pos:x}of p){const{w:N,h:_}=c(y),S=d.get(y)??"_default";if(i.has(y)){h.push({x:x.x,y:x.y,w:N,h:_,sid:S});continue}let b=x.y;for(let k=0;k<h.length+1;k++){const E=h.find(C=>{const A=C.sid===S?24:l,P=C.sid===S?24:u;return x.x<C.x+C.w+A&&C.x<x.x+N+A&&b<C.y+C.h+P&&C.y<b+_+P});if(!E)break;b=E.y+E.h+(E.sid===S?24:u)}b!==x.y&&(n.set(y,{x:x.x,y:b}),m.push(y)),h.push({x:x.x,y:b,w:N,h:_,sid:S})}return m}function e$(e,n,i,s,o){const u=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??$i,h:(x==null?void 0:x.height)??js}},l=y=>i.get(y)??n.get(y),c=new Map,d=[];for(const y of e){const x=l(y.id);if(!x)continue;const{w:N,h:_}=u(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=tl(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else d.push({x:x.x,y:x.y,w:N,h:_})}if(c.size===0)return[];const h=As+el,p=(y,x,N,_)=>d.some(S=>y<S.x+S.w+As&&S.x<y+N+As&&x<S.y+S.h+h&&S.y<x+_+h),m=[];for(const y of[...c.keys()].sort()){const x=c.get(y);let N=1/0,_=1/0,S=-1/0,b=-1/0;for(const M of x){const R=l(M.id),{w:L,h:F}=u(M.id);N=Math.min(N,R.x),_=Math.min(_,R.y),S=Math.max(S,R.x+L),b=Math.max(b,R.y+F)}const k=S-N,E=b-_,C=[...new Set(d.map(M=>Math.round(M.x)))].sort((M,R)=>M-R),A=C.length?C:[N],P=[0,...d.map(M=>M.y+M.h+h)].sort((M,R)=>M-R);let I=null;e:for(const M of A)for(const R of P){if(R>=_)break;if(!p(M,R,k,E)){I={x:M,y:R};break e}}if(I){const M=I.x-N,R=I.y-_;for(const L of x){const F=l(L.id);n.set(L.id,{x:F.x+M,y:F.y+R})}m.push(y)}for(const M of x){const R=l(M.id),{w:L,h:F}=u(M.id);d.push({x:R.x,y:R.y,w:L,h:F})}}return m}function t$(e,n,i,s,o,u=!1){const d=As+el+1,h=8,p=1.75,m=200,y=.7,x=.01,N=I=>{const M=s.get(I);return{w:(M==null?void 0:M.width)??$i,h:(M==null?void 0:M.height)??js}},_=I=>i.get(I)??n.get(I),S=new Map;for(const I of e){if(!_(I.id))continue;const M=tl(I),R=S.get(M);R?R.push(I):S.set(M,[I])}const b=[],k=new Set,E=new Set;for(const I of[...S.keys()].sort()){const M=S.get(I);let R=1/0,L=1/0,F=-1/0,J=-1/0,X=!1;for(const ne of M){const K=_(ne.id),{w:$,h:W}=N(ne.id);R=Math.min(R,K.x),L=Math.min(L,K.y),F=Math.max(F,K.x+$),J=Math.max(J,K.y+W),i.has(ne.id)&&(X=!0)}const j=F-R,G=J-L;E.add(I);const U=o.get(I);U&&(j>U.w+h||G>U.h+h)&&k.add(I),o.set(I,{w:j,h:G}),b.push({sid:I,members:M.map(ne=>ne.id),x:R,y:L,w:j,h:G,anchored:X,mass:1})}for(const I of[...o.keys()])E.has(I)||o.delete(I);if(u||k.size===0)return[];for(const I of b)k.has(I.sid)&&(I.mass=8);const C=new Map(b.map(I=>[I.sid,I.x])),A=new Map(b.map(I=>[I.sid,I.y]));for(let I=0;I<m;I++){const M=new Map,R=new Map;let L=0;for(let F=0;F<b.length;F++)for(let J=F+1;J<b.length;J++){const X=b[F],j=b[J];if(X.anchored&&j.anchored)continue;const G=X.x+X.w/2,U=X.y+X.h/2,ne=j.x+j.w/2,K=j.y+j.h/2,$=(X.w+j.w)/2+61-Math.abs(G-ne),W=(X.h+j.h)/2+d-Math.abs(U-K);if($<=0||W<=0)continue;const O=(Xe,Ke)=>!Xe.anchored&&!(Ke<0&&Xe.x<=0),B=(Xe,Ke)=>!Xe.anchored&&!(Ke<0&&Xe.y<=0),ae=(Xe,Ke,et)=>{const ze=Xe===Ke,qe=ze?X.sid<j.sid?-1:1:Math.sign(Xe-Ke);return et(X,qe)||et(j,-qe)?qe:ze&&(et(X,-qe)||et(j,qe))?-qe:0},z=ae(G,ne,O),H=ae(U,K,B),ee=z!==0,se=H!==0;if(!ee&&!se)continue;const ce=ee&&(!se||$*p<W),[me,ve,Ae,Ue]=ce?[z,$,M,O]:[H,W,R,B],Me=Ue(X,me),Pe=Ue(j,-me),be=X.mass,Fe=j.mass,we=Me?Pe?Fe/(be+Fe):1:0,xe=Pe?Me?be/(be+Fe):1:0,De=ve*y;Ae.set(X.sid,(Ae.get(X.sid)??0)+me*De*we),Ae.set(j.sid,(Ae.get(j.sid)??0)-me*De*xe),L+=De}for(const F of b)F.anchored||(F.x=Math.max(0,F.x+(M.get(F.sid)??0)),F.y=Math.max(0,F.y+(R.get(F.sid)??0)));if(L<x)break}const P=[];for(const I of b){const M=I.x-C.get(I.sid),R=I.y-A.get(I.sid);if(!(Math.abs(M)<1&&Math.abs(R)<1)){for(const L of I.members){if(i.has(L))continue;const F=n.get(L);F&&n.set(L,{x:F.x+M,y:F.y+R})}P.push(I.sid)}}return P}const n$=600;function qg(e,n){return!(e.exitAt!=null&&n-e.exitAt>n$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function r$(e,n){const i=new Set;for(const s of e.agents.values())qg(s,n)&&i.add(s.id);return i}function Ii(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function i$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const s$={agent:xP,sessionGroup:AP},o$=420,hu=18,a$=9e4,u$=200,l$=5*6e4,c$=6,f$=2*6e4,kv="agent-dag.layout",Ev="agent-dag.viewport",aC="agent-dag.summariesDismissed",uC="agent-dag.sessionListOpen",lC="agent-dag.detailOpen",cC="agent-dag.usagePanelOpen",kk="agent-dag.accountsPanelOpen",Ek="agent-dag.versionNoticeDismissed";function d$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(uC)==="1"}catch{return!1}}function h$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(uC,e?"1":"0")}catch{}}function p$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(lC)==="1"}catch{return!1}}function m$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(lC,e?"1":"0")}catch{}}function g$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(cC);try{return e===null?!0:e==="1"}catch{return!0}}function v$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(cC,e?"1":"0")}catch{}}function y$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(aC);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 Nk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(aC,JSON.stringify(i))}catch{}}function w$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(kv);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 gg(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(kv,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function x$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ev);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 _$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ev,JSON.stringify(e))}catch{}}function Ck(){if(!(typeof window>"u")){try{window.localStorage.removeItem(kv)}catch{}try{window.localStorage.removeItem(Ev)}catch{}}}function S$(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 Lg={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},$g={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},b$={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 fC(e){return e.startsWith("mcp__")?"mcp":b$[e]??"other"}function dC(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 k$(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 E$(e,n,i,s,o,u,l,c,d,h,p,m,y,x,N,_,S,b){const k=[],E=[],C=new Set;if(u)for(const R of e.agents.values())dC(R,u)&&C.add(R.id);for(const R of e.agents.values()){if(!S.has(R.id))continue;const L=u?!C.has(R.id):!1,F=R.exitAt!=null,J=_!=null&&!_.has(R.id),X=[L?"rf-dim":"",F?"rf-exiting":"",J?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,j=l.get(R.id);if(k.push({id:R.id,type:"agent",position:{x:0,y:0},data:{...R,now:n,dim:L,onOpenContext:b},className:X,...j?{width:j.width,height:j.height}:null}),R.parentId&&S.has(R.parentId)){const G=iv(R.sessionId),U=R.state==="active"?`hsl(${G} 80% 72%)`:`hsl(${G} 50% 55%)`,ne=u&&!C.has(R.id)&&!C.has(R.parentId),K=F,$=N.size>0&&(N.has(R.id)||N.has(R.parentId)),W=_!=null&&!_.has(R.id)&&!_.has(R.parentId),O=R.state==="active"?2:1.5,B=$?O+1.5:O,ae=ne||K?.2:W?.12:1,z=[K?"rf-edge-exiting":"",$?"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"||$)&&!ne&&!K,type:"smoothstep",style:{stroke:U,strokeWidth:B,opacity:ae,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:z})}}const A=k.filter(R=>!o.has(R.id)&&!m.has(R.id));if(A.length>0||y!==x.current){if(A.length>0){const R=ZL(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);e$(k,m,o,l,new Set(A.map(L=>L.id)))}JL(k,m,o,l),x.current=y}const P=t$(k,m,o,l,c,!h||p);P.length>0&&d(P);for(const R of Array.from(m.keys()))e.agents.has(R)||m.delete(R);if(e.agents.size>0)for(const R of Array.from(o.keys()))e.agents.has(R)||o.delete(R);const I=[];let M=!1;for(const R of k){let L=o.get(R.id)??m.get(R.id);L||(L={x:0,y:0},m.set(R.id,L),M=!0),I.push({...R,position:L})}return M&&(x.current=""),{nodes:I,edges:E}}function N$(){return v.jsx(nv,{children:v.jsx(C$,{})})}function C$(){const e=Ho(),n=q.useRef(Mg()),[,i]=q.useState(0),s=q.useCallback(()=>i(Q=>Q+1),[]),[o,u]=q.useState(()=>new Set),[l,c]=q.useState(null),[d,h]=q.useState(null),p=q.useCallback((Q,Z)=>{u(ue=>{if(!Z)return new Set([Q]);const de=new Set(ue);return de.has(Q)?de.delete(Q):de.add(Q),de}),c(ue=>Z&&ue===Q?ue:Q)},[]),m=q.useCallback(()=>{u(new Set),c(null)},[]),[y,x]=q.useState(null),[N,_]=q.useState(null),S=q.useCallback(Q=>_(Q),[]),b=q.useRef(y$()),[k,E]=q.useState(d$);q.useEffect(()=>{h$(k)},[k]);const[C,A]=q.useState(p$);q.useEffect(()=>{m$(C)},[C]);const[P,I]=q.useState(g$);q.useEffect(()=>{v$(P)},[P]);const[M,R]=q.useState(()=>{try{const Q=window.localStorage.getItem(kk);return Q===null?!0:Q==="1"}catch{return!0}});q.useEffect(()=>{try{window.localStorage.setItem(kk,M?"1":"0")}catch{}},[M]);const[L,F]=q.useState(null),[J,X]=q.useState(!1),[j,G]=q.useState(0),[U,ne]=q.useState(0);q.useEffect(()=>{fetch("/api/sound-hook").then(Q=>Q.ok?Q.json():null).then(Q=>{Q!=null&&Q.ok&&(F(Q.enabled===!0),G((Q.foreign??[]).filter(Z=>Z.worksHere).length),ne(typeof Q.parked=="number"?Q.parked:0))}).catch(()=>{})},[]);const K=q.useCallback(async()=>{X(!0);try{const Z=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!L})})).json().catch(()=>null);Z!=null&&Z.ok&&F(Z.enabled===!0),fetch("/api/sound-hook").then(ue=>ue.ok?ue.json():null).then(ue=>{ue!=null&&ue.ok&&(G((ue.foreign??[]).filter(de=>de.worksHere).length),ne(typeof ue.parked=="number"?ue.parked:0))}).catch(()=>{})}catch{}finally{X(!1)}},[L]),[$,W]=q.useState(null),[O,B]=q.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Ek)??""}catch{return""}}),[ae,z]=q.useState(!1);q.useEffect(()=>{let Q=!0;const Z=()=>{fetch("/api/version").then(ge=>ge.ok?ge.json():null).then(ge=>{Q&&ge&&W(ge)}).catch(()=>{})};Z();const ue=window.setInterval(Z,5*6e4),de=()=>{document.visibilityState==="visible"&&Z()};return document.addEventListener("visibilitychange",de),()=>{Q=!1,window.clearInterval(ue),document.removeEventListener("visibilitychange",de)}},[]);const H=($==null?void 0:$.notice)??null,ee=H?`${H.kind}:${H.to}`:"",se=H!=null&&O!==ee,ce=q.useCallback(()=>{if(!H)return;const Q=O===ee?"":ee;B(Q);try{window.localStorage.setItem(Ek,Q)}catch{}},[H,ee,O]),me=q.useCallback(async()=>{var ue;const Q=$==null?void 0:$.command;if(!Q)return;let Z=!1;try{Z=await Promise.race([((ue=navigator.clipboard)==null?void 0:ue.writeText(Q).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{Z=!1}if(!Z)try{const de=document.createElement("textarea");de.value=Q,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),Z=document.execCommand("copy"),de.remove()}catch{Z=!1}Z&&(z(!0),window.setTimeout(()=>z(!1),1600))},[$==null?void 0:$.command]),ve=q.useCallback(()=>{E(Q=>(Q||R(!1),!Q))},[]),Ae=q.useCallback(()=>{R(Q=>(Q||E(!1),!Q))},[]),[Ue,Me]=q.useState(!1),[Pe,be]=q.useState(0),Fe=q.useRef(null),[we,xe]=q.useState(0),[De,Xe]=q.useState(!1),[Ke,et]=q.useState(!1),ze=q.useRef([]),[qe,qt]=q.useState(Date.now()),Lt=q.useRef(w$()).current;q.useRef(!1);const Ze=q.useRef(new Map(Lt.positions.filter(([Q])=>Lt.pins.includes(Q)))),lt=q.useRef(null),At=q.useState(()=>x$())[0],[ht,tt]=q.useState(""),[_t,gt]=q.useState(()=>new Set),[ot,gn]=q.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[$t,Dt]=q.useState(!1),vn=q.useRef(null);q.useEffect(()=>{document.documentElement.dataset.theme=ot;try{window.localStorage.setItem("agent-dag.theme",ot)}catch{}},[ot]),q.useEffect(()=>{if(!At)return;const Q=window.setTimeout(()=>{try{e.setViewport(At,{duration:0})}catch{}},60);return()=>window.clearTimeout(Q)},[e,At]);const Gn=q.useRef(!0),ct=q.useRef(null);q.useEffect(()=>{const Q=new EventSource("/events");return Q.addEventListener("open",()=>{Xe(!0),Dt(!0)}),Q.addEventListener("error",()=>Xe(!1)),Q.addEventListener("replay-end",()=>{Gn.current=!1,ct.current!=null&&(window.clearTimeout(ct.current),ct.current=null),s()}),Q.addEventListener("hook",Z=>{try{const ue=JSON.parse(Z.data);if(Ke){ze.current.push(ue);return}n.current=Uw(n.current,ue),ue.replay===!0||Gn.current||Date.now()-ue.receivedAt>3e4?(ct.current!=null&&window.clearTimeout(ct.current),ct.current=window.setTimeout(()=>{ct.current=null,s()},120)):(ct.current!=null&&(window.clearTimeout(ct.current),ct.current=null),s())}catch{}}),()=>{Q.close(),ct.current!=null&&(window.clearTimeout(ct.current),ct.current=null)}},[Ke,s]),q.useEffect(()=>{if(!Ke&&ze.current.length!==0){for(const Q of ze.current)n.current=Uw(n.current,Q);ze.current.length=0,s()}},[Ke,s]),q.useEffect(()=>{const Q=setInterval(()=>{const Z=Date.now();qt(Z);let ue=iP(n.current,Z,a$);nP(n.current,Z,u$,l$)&&(ue=!0),rP(n.current,Z,c$,f$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(Q)},[s]);const Xt=q.useRef(null),Ft=q.useRef(0),yn=420,Vt=q.useCallback((Q=500)=>{try{const _e=document.querySelector(".canvas-wrap"),Ie=Array.from(document.querySelectorAll(".react-flow__node")).filter(yt=>yt.offsetWidth>0);if(!_e||Ie.length===0)return;const Oe=_e.getBoundingClientRect(),Be=e.getViewport();if(!Number.isFinite(Be.zoom)||Be.zoom<=0)return;const Ge=yt=>(yt-Oe.left-Be.x)/Be.zoom,Je=yt=>(yt-Oe.top-Be.y)/Be.zoom,St=Ie.map(yt=>yt.getBoundingClientRect()),vi=Math.min(...St.map(yt=>Ge(yt.left))),Qi=Math.max(...St.map(yt=>Ge(yt.right))),Mn=Math.min(...St.map(yt=>Je(yt.top))),Us=Math.max(...St.map(yt=>Je(yt.bottom))),Hs=Qi-vi,fr=Us-Mn;if(!(Hs>0&&fr>0))return;const xn=Math.max(.2,Math.min(1,(Oe.width-160)/(Hs+yn)*.86,(Oe.height-160)/fr*.86));e.setViewport({x:80-vi*xn,y:Math.max(80,(Oe.height-fr*xn)/2)-Mn*xn,zoom:xn},{duration:Q}),Ft.current=Date.now(),window.setTimeout(()=>{try{const yt={x:80-vi*xn,y:Math.max(80,(Oe.height-fr*xn)/2)-Mn*xn,zoom:xn},Lr=e.getViewport();(Math.abs(Lr.zoom-xn)>.01||Math.abs(Lr.x-yt.x)>2)&&e.setViewport(yt,{duration:0})}catch{}},Q+60)}catch{}},[e]),Tr=q.useRef(""),Rr=q.useRef(null),oi=q.useRef(0),Yn=q.useCallback(()=>{oi.current=Date.now()},[]),jr="agent-dag.autoFitDisabled",Wt=q.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(jr)==="1"}catch{return!1}})()),[Ar,Kn]=q.useState(Wt.current),Vi=q.useCallback(()=>{if(!Wt.current){Wt.current=!0,Kn(!0);try{window.localStorage.setItem(jr,"1")}catch{}}},[]),ar=q.useCallback(()=>{Wt.current=!1,Kn(!1);try{window.localStorage.removeItem(jr)}catch{}Vt(400)},[e,Vt]);q.useEffect(()=>{const Q=setInterval(()=>{if(Wt.current||Date.now()-oi.current<800)return;const Z=n.current,ue=Date.now(),de=[];for(const Ge of Z.agents.values())qg(Ge,ue)&&de.push({id:Ge.id});if(de.length===0)return;const ge=e.getViewport(),_e=window.innerWidth-360,Ie=window.innerHeight-52;let Oe=!1,Be=!1;for(const{id:Ge}of de){const Je=ln.current.get(Ge),St=Ze.current.get(Ge)??It.current.get(Ge);if(!Je||!St)continue;Be=!0;const vi=St.x*ge.zoom+ge.x,Qi=St.y*ge.zoom+ge.y,Mn=(St.x+Je.width)*ge.zoom+ge.x,Us=(St.y+Je.height)*ge.zoom+ge.y;if(Mn>0&&vi<_e&&Us>0&&Qi<Ie){Oe=!0;break}}Be&&!Oe&&Vt(600)},1500);return()=>clearInterval(Q)},[e]);const Xn=q.useRef(!1),ln=q.useRef(new Map),Ir=q.useRef(0),zs=q.useCallback(Q=>{const Z=ln.current;let ue=!1;for(const de of Q.nodeInternals.values()){const ge=de.width,_e=de.height;if(ge==null||_e==null)continue;const Ie=Z.get(de.id);Ie?(Math.abs(Ie.height-_e)>4||Math.abs(Ie.width-ge)>4)&&(Z.set(de.id,{width:ge,height:_e}),ue=!0):(Z.set(de.id,{width:ge,height:_e}),ue=!0)}return ue&&(Ir.current+=1),Ir.current},[]),Wi=Qe(zs),[ai,In]=q.useState(0);q.useEffect(()=>{let Q=0;const Z=()=>{const de=ln.current;let ge=!1;for(const _e of document.querySelectorAll(".react-flow__node[data-id]")){const Ie=_e.getAttribute("data-id");if(!Ie)continue;const Oe=_e.offsetWidth,Be=_e.offsetHeight;if(!Oe||!Be)continue;const Ge=de.get(Ie);(!Ge||Math.abs(Ge.width-Oe)>4||Math.abs(Ge.height-Be)>4)&&(de.set(Ie,{width:Oe,height:Be}),ge=!0)}ge&&In(_e=>_e+1)};if(Xn.current)return;let ue=0;return document.visibilityState==="hidden"?ue=window.setTimeout(Z,32):Q=requestAnimationFrame(Z),()=>{cancelAnimationFrame(Q),window.clearTimeout(ue)}});const It=q.useRef(new Map(Lt.positions)),Mr=q.useRef(""),Qn=q.useMemo(()=>{const Q=[];for(const Z of n.current.agents.values())qg(Z,qe)&&Q.push(Z.id+(Z.parentId?`>${Z.parentId}`:""));return Q.sort(),`${Q.join("|")}#sv${Wi}.${ai}`},[n.current,n.current.lastSeq,qe,Wi,ai]),Zn=q.useRef(null);q.useEffect(()=>(Zn.current!=null&&window.clearTimeout(Zn.current),Zn.current=window.setTimeout(()=>{gg(It.current,Ze.current)},1500),()=>{Zn.current!=null&&window.clearTimeout(Zn.current)}),[Qn]),q.useEffect(()=>{if(Tr.current===Qn)return;const Q=Tr.current;if(Tr.current=Qn,!Q||Wt.current)return;Date.now()-Ft.current>1200&&Vt(400),Xt.current&&window.clearTimeout(Xt.current),Xt.current=window.setTimeout(()=>{Wt.current||Vt(500)},280)},[Qn,e,Vt]);const Pr=q.useMemo(()=>{if(o.size===0)return null;const Q=new Set;for(const Z of o){const ue=k$(n.current,Z);if(ue)for(const de of ue)Q.add(de)}return Q.size>0?Q:null},[n.current,n.current.lastSeq,o]),Or=q.useMemo(()=>r$(n.current,qe),[n.current,n.current.lastSeq,qe]),ui=q.useRef(null),[ur,Gi]=q.useState({w:0,h:0});q.useEffect(()=>{const Q=ui.current;if(!Q||typeof ResizeObserver>"u")return;const Z=new ResizeObserver(ue=>{var ge;const de=(ge=ue[0])==null?void 0:ge.contentRect;de&&Gi(_e=>Math.abs(_e.w-de.width)>40||Math.abs(_e.h-de.height)>40?{w:de.width,h:de.height}:_e)});return Z.observe(Q),Gi({w:Q.clientWidth,h:Q.clientHeight}),()=>Z.disconnect()},[]);const rt=q.useRef(new Map),[Yi,li]=q.useState(!1);q.useEffect(()=>{const Q=window.setTimeout(()=>li(!0),2500);return()=>window.clearTimeout(Q)},[]);const[Ki,Jn]=q.useState(!1),cn=q.useRef(null),[qr,lr]=q.useState(!1),Qt=q.useCallback(()=>{cn.current&&(window.clearTimeout(cn.current),cn.current=null),Jn(!1)},[]),ci=q.useCallback(Q=>{Q.length!==0&&queueMicrotask(()=>{Jn(!0),cn.current&&window.clearTimeout(cn.current),cn.current=window.setTimeout(()=>Jn(!1),o$+80)})},[]);q.useEffect(()=>()=>{cn.current&&window.clearTimeout(cn.current)},[]);const Zt=ur.w>0?ur.w*.92:0,Qo=ur.h>0?ur.h:0,{nodes:wn,edges:nl}=q.useMemo(()=>E$(n.current,qe,Zt,Qo,Ze.current,ht,ln.current,rt.current,ci,Yi,qr,It.current,Qn,Mr,o,Pr,Or,S),[n.current,n.current.lastSeq,qe,Zt,Qo,Yi,qr,ht,Qn,o,Pr,Or,S,Pe]),fi=q.useMemo(()=>{const Q=new Map;for(const ue of wn){const de=ue.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const ge=ue.width,_e=ue.height;if(ge==null||_e==null)continue;const Ie=ue.position.x,Oe=ue.position.y,Be=Ie+ge,Ge=Oe+_e,Je=Q.get(de.sessionId);Je?(Je.minX=Math.min(Je.minX,Ie),Je.minY=Math.min(Je.minY,Oe),Je.maxX=Math.max(Je.maxX,Be),Je.maxY=Math.max(Je.maxY,Ge)):Q.set(de.sessionId,{minX:Ie,minY:Oe,maxX:Be,maxY:Ge})}const Z=[];for(const[ue,de]of Q){const ge=de.maxX-de.minX+hu*2,_e=de.maxY-de.minY+hu*2;Z.push({id:`group:${ue}`,type:"sessionGroup",position:{x:de.minX-hu,y:de.minY-hu},data:{sessionId:ue,w:ge,h:_e},width:ge,height:_e,style:{width:ge,height:_e},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Z},[wn,qe]),Xi=q.useMemo(()=>{const Q=[...fi,...wn],Z=Fe.current;return!Z||Z.size===0?Q:Q.map(ue=>{const de=Z.get(ue.id);return de?{...ue,position:de}:ue})},[fi,wn,we]),di=q.useMemo(()=>{if(!ht)return null;const Q=new Set;for(const Z of n.current.agents.values())dC(Z,ht)&&Q.add(Z.id);return Q},[n.current,n.current.lastSeq,ht]),hi=q.useMemo(()=>{const Q=new Set;for(const Z of n.current.agents.values())for(const ue of Z.tools)Q.add(fC(ue.name));return Object.keys(Lg).filter(Z=>Q.has(Z))},[n.current,n.current.lastSeq]),pi=q.useMemo(()=>{const Q=new Map;for(const ue of n.current.agents.values())for(const de of ue.tools){if(!de.name.startsWith("mcp__"))continue;const ge=de.name.slice(5),_e=ge.indexOf("__"),Ie=_e>0?ge.slice(0,_e):ge;Q.set(Ie,(Q.get(Ie)??0)+1)}const Z=[];for(const[ue,de]of Q){let ge=5381;for(let _e=0;_e<ue.length;_e++)ge=(ge<<5)+ge^ue.charCodeAt(_e);Z.push({server:ue,count:de,hue:Math.abs(ge)%360})}return Z.sort((ue,de)=>de.count-ue.count),Z},[n.current,n.current.lastSeq]),rl=q.useCallback(Q=>{gt(Z=>{const ue=new Set(Z);return ue.has(Q)?ue.delete(Q):ue.add(Q),ue})},[]),Ct=l?n.current.agents.get(l):null,Bs=d?Array.from(n.current.agents.values()).flatMap(Q=>Q.tools).find(Q=>Q.id===d)??null:null,mi=q.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Mg(),Ze.current.clear(),ln.current.clear(),It.current.clear(),Mr.current="",Ck(),m(),s()},[s,m]),cr=q.useCallback(()=>{Ze.current.clear(),It.current.clear(),Mr.current="",Ck(),s(),window.setTimeout(()=>Vt(500),80)},[s,e,Vt]),Zo=q.useCallback(()=>Vt(500),[Vt]),gi=q.useCallback(Q=>{if(wn.length===0)return;const Z=wn.slice().sort((_e,Ie)=>_e.position.y-Ie.position.y||_e.position.x-Ie.position.x),ue=l?Z.findIndex(_e=>_e.id===l):-1;let de;ue===-1?de=Q===1?0:Z.length-1:de=(ue+Q+Z.length)%Z.length;const ge=Z[de];ge&&(p(ge.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[ge]})}catch{}Ft.current=Date.now()},30))},[wn,l,p,e]);q.useEffect(()=>{const Q=Z=>{var de,ge;const ue=((de=Z.target)==null?void 0:de.tagName)==="INPUT";if(Z.key==="Escape"){ue?Z.target.blur():m();return}if(!ue){if(Z.key==="/"){Z.preventDefault(),(ge=vn.current)==null||ge.focus();return}Z.key===" "&&(Z.preventDefault(),et(_e=>!_e)),(Z.key==="c"||Z.key==="C")&&mi(),(Z.key==="r"||Z.key==="R")&&cr(),(Z.key==="f"||Z.key==="F")&&Zo(),(Z.key==="l"||Z.key==="L")&&ve(),(Z.key==="h"||Z.key==="H")&&Me(_e=>!_e),(Z.key==="u"||Z.key==="U")&&I(_e=>!_e),(Z.key==="a"||Z.key==="A")&&Ae(),(Z.key==="j"||Z.key==="J")&&gi(1),(Z.key==="k"||Z.key==="K")&&gi(-1),(Z.key==="t"||Z.key==="T")&&gn(_e=>_e==="dark"?"light":"dark")}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[mi,cr,Zo,m,gi]);const He=n.current.agents.size,Jo=new Set(Array.from(n.current.agents.values()).map(Q=>Q.sessionId)).size,Gt=q.useMemo(()=>{let Q=0,Z=0,ue=0,de=0,ge=0,_e=0,Ie=0,Oe=0,Be=0;for(const Ge of n.current.agents.values()){Q+=Ge.usage.inputTokens,Z+=Ge.usage.outputTokens,ue+=Ge.usage.cacheReadTokens,de+=Ge.usage.cacheCreateTokens;const Je=an(Ge.usage,Ge.model);ge+=Je.total,_e+=Je.input,Ie+=Je.output,Oe+=Je.cacheRead,Be+=Je.cacheWrite}return{inT:Q,outT:Z,cacheR:ue,cacheC:de,sum:Q+Z,cost:{total:ge,input:_e,output:Ie,cacheRead:Oe,cacheWrite:Be}}},[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",H?v.jsxs("button",{type:"button",className:"v stale",onClick:ce,title:H.kind==="restart"?`Running v${H.from}; v${H.to} is installed on disk. Restart to pick it up.`:`Running v${H.from}; v${H.to} is on npm.`,children:["v",H.from,v.jsx("span",{className:"v-dot","aria-hidden":!0})]}):v.jsxs("span",{className:"v",children:["v",($==null?void 0:$.running)??"1.30.8"]})]}),Ct&&(()=>{const Q=an(Ct.usage,Ct.model),Z=Math.max(0,((Ct.endedAt??qe)-Ct.startedAt)/1e3),ue=Ct.state==="active"?Tu(Q.total,Z):null,de=o.size-1;return v.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Ct.label}`,onClick:()=>{try{const ge=wn.find(_e=>_e.id===Ct.id);ge&&e.fitView({padding:.35,duration:500,nodes:[ge]}),Ft.current=Date.now()}catch{}},children:[v.jsx("span",{className:`state-pill state-${Ct.state}`,children:Ct.state==="active"?"live":Ct.state}),v.jsx("span",{className:"selected-label",children:Ct.label}),Q.total>0&&v.jsxs("span",{className:"selected-cost",children:[We(Q.total),ue?v.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),de>0&&v.jsxs("span",{className:"selected-extra",children:["+",de]}),v.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:ge=>{ge.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:vn,type:"text",placeholder:"Search agents, cwd, tools…",value:ht,onChange:Q=>tt(Q.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),ht?v.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>tt(""),children:"×"}):v.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),v.jsxs("span",{className:"status",role:"status",children:[v.jsx("span",{className:`pill ${De?"live":"dead"}`,title:De?"Receiving events":"SSE disconnected",children:De?"live":"offline"}),v.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[v.jsx("span",{className:"count",children:Jo}),v.jsx("span",{className:"lbl",children:"sessions"})]}),v.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[v.jsx("span",{className:"count",children:He}),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"})]}),Gt.sum>0&&v.jsxs("span",{className:"stat",title:`in:${Gt.inT.toLocaleString()} out:${Gt.outT.toLocaleString()} cache-r:${Gt.cacheR.toLocaleString()} cache-c:${Gt.cacheC.toLocaleString()}`,children:[v.jsx("span",{className:"count",children:i$(Gt.sum)}),v.jsx("span",{className:"lbl",children:"tokens"})]}),pi.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:We(p.total)}),y&&v.jsx("span",{className:"cost-rate",children:y})]})})()]}),v.jsx(Os,{type:"source",position:Ce.Right,style:{background:"transparent",border:"none"}})]})}function _P({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return v.jsx("span",{className:`state-pill state-${e}`,children:n})}function SP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function bP({tools:e,now:n}){const u=new Array(24).fill(0);let l=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(u[N]+=1,l+=1)}const c=Math.max(1,...u),d=132,h=14,p=d/24,m=c/(2500/1e3);return v.jsxs("div",{className:"tool-spark-row",title:`${l} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[v.jsx("svg",{className:"tool-spark",width:d,height:h,viewBox:`0 0 ${d} ${h}`,"aria-hidden":!0,children:u.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return v.jsx("rect",{x:x*p+.4,y:h-N,width:Math.max(.5,p-1),height:N,rx:.8,className:b},x)})}),v.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Vo(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 Vw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function kP(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 EP({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:kP(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:Vw(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…)":Vw(e.response??e.errorPreview)})]})]})]})})}const lu=18,Ww=26,NP=12;function CP(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=Gw(u)??p.label)):n.set(u.sessionId,{minX:l,minY:c,maxX:d,maxY:h,label:Gw(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} · ${TP(o)}`:u.label;s.push({sessionId:o,label:c,x:u.minX-lu,y:u.minY-lu-Ww,w:u.maxX-u.minX+lu*2,h:u.maxY-u.minY+lu*2+Ww})}return s}function TP(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Gw(e){if(e.kind==="root")return e.label}function RP(){const{x:e,y:n,zoom:i}=GE(),s=Ho(),o=Qe(CP,jP);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=iv(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-NP)*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 jP(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 AP({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 rN=600,IP=36,Og=16,MP=60,PP=6,Yw=220,Kw=96,OP=28,qP={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 LP(e){return e.startsWith("mcp__")?"mcp":qP[e]??"other"}const $P={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 Xw(e){return e.startsWith("mcp__")?"🔌":$P[e]??"✨"}const DP={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 iN(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 iN(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 FP(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 zP=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),BP=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function UP(e,n){return BP.has(e)?Math.max(Kw,34+n.length*7.5):Kw}function HP(e,n){if(!zP.has(e))return null;const i=FP(n);if(!i)return null;const s=iN(i);return s?{emoji:DP[s]??"⚙️",label:s,category:"shell",detail:i}:null}const VP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Qw={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:"🗄️"},Zw={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 WP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),s=i.lastIndexOf("/");return s>=0?i.slice(s+1):i}function GP(e){const n=e.toLowerCase();if(Zw[n])return Zw[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(Qw[s])return Qw[s]}return"📄"}function YP(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 KP(e,n){if(!VP.has(e))return null;const i=YP(e,n);if(!i)return null;const s=WP(i);return s?{emoji:e==="LS"?"📂":GP(s),label:s,category:"file",detail:i}:null}const sN={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 oN(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 XP(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 QP(e,n){const i=oN(e);if(!i)return null;const{server:s,method:o}=i;if(!o)return null;const u=sN[s.toLowerCase()];return{emoji:(u==null?void 0:u.emoji)??"🔌",label:o,category:"mcp",detail:u?`${u.name} · ${o}`:`${s} · ${o}`}}function ZP(e,n){return HP(e,n)??KP(e,n)??QP(e)}const JP={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function e3(e){const n=oN(e);if(n){const s=sN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:XP(n.server)}}const i=JP[e];return i?{emoji:Xw(e),label:i}:{emoji:Xw(e),label:e}}function t3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function n3(e,n,i){if(i==null)return 1;const s=n-i;return s<0?1:Math.max(0,1-s/rN)}function r3(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>rN)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)??Yw,Yw),x=(m==null?void 0:m.height)??130,N=d.x,_=d.y,S=N+y,b=_+x/2;h.forEach((k,E)=>{const C=E*IP,A=N+y+MP,P=_+PP+C,I=n3(k,u,p),M=k.inputPreview??"",R=t3(k),L=I<.999,F=e3(k.name);l.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:F.label,emoji:F.emoji,status:R,category:LP(k.name),mcpHue:F.hue,inputPreview:M,fade:I,fading:L,worldX:A,worldY:P,anchorX:S,anchorY:b,spawnDx:S-A,spawnDy:b-(P+Og)});const J=ZP(k.name,k.input);if(J){const X=UP(k.name,F.label),j=A+X+OP,G=P,U=A+X,ne=P+Og;l.push({id:`sub:${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:J.label,emoji:J.emoji,isSub:!0,status:R,category:J.category,inputPreview:J.detail??M,fade:I,fading:L,worldX:j,worldY:G,anchorX:U,anchorY:ne,spawnDx:U-j,spawnDy:0})}})}return l}function i3({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}=GE(),x=r3(e,n,i,s,o,d),N=c&&c.size>0?x.filter(_=>!c.has(_.category)):x;return v.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[v.jsx("svg",{className:"tool-bursts-svg",children:N.map(_=>{const S=_.anchorX*y+p,b=_.anchorY*y+m,k=(_.worldX+6)*y+p,E=(_.worldY+Og)*y+m,C=S+(k-S)*.55,A=u!=null&&!u.has(_.agentId),P=l!=null&&!l.has(_.agentId),I=_.fade*(A||P?.14:1);return v.jsx("path",{d:`M ${S} ${b} Q ${C} ${b}, ${k} ${E}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:I},`l:${_.id}`)})}),N.map(_=>{const S=_.worldX*y+p,b=_.worldY*y+m,k={left:`${S}px`,top:`${b}px`,transform:`scale(${y})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},E=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${E} · ${_.inputPreview}`:E,A=h!=null,P=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},I=u!=null&&!u.has(_.agentId),M=l!=null&&!l.has(_.agentId),R=I||M?" dim":"";return v.jsx("div",{className:"tool-burst-wrap",style:k,children:v.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${A?" clickable":""}${_.isSub?" sub":""}${R}`,style:P,title:C,role:A?"button":void 0,tabIndex:A?0:void 0,"aria-label":A?`Open ${_.toolName} ${_.status==="inflight"?"in flight":_.status} — click for details`:void 0,onClick:A?()=>h(_.toolId):void 0,onKeyDown:A?L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),h(_.toolId))}:void 0,children:[v.jsx("span",{className:"tb-emoji",children:_.emoji}),v.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&v.jsx("span",{className:"tb-spin"}),_.status==="done"&&v.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&v.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function s3({state:e,sessionId:n,onClose:i}){const s=q.useMemo(()=>a3(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:We(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:Vo(o)},o))})]}),v.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&v.jsxs(v.Fragment,{children:[v.jsx(o3,{cost:s.cost}),v.jsxs("div",{className:"ss-cost-legend",children:[v.jsxs("span",{className:"ssl ssl-in",children:["input ",v.jsx("b",{children:We(s.cost.input)})]}),v.jsxs("span",{className:"ssl ssl-out",children:["output ",v.jsx("b",{children:We(s.cost.output)})]}),v.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",v.jsx("b",{children:We(s.cost.cacheRead)})]}),v.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",v.jsx("b",{children:We(s.cost.cacheWrite)})]})]})]})})]}),v.jsxs("section",{className:"ss-stats",children:[v.jsx(ks,{label:"agents",value:s.agentCount}),v.jsx(ks,{label:"subagents",value:s.subagentCount}),v.jsx(ks,{label:"tool calls",value:s.toolCount}),v.jsx(ks,{label:"prompts",value:s.promptCount}),v.jsx(ks,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&v.jsx(ks,{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 ks({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 o3({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}: ${We(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 a3(e,n){const i=e.agents.get(n);if(!i)return null;const s=[];for(const E of e.agents.values())E.sessionId===n&&s.push(E);if(s.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},u=new Set,l=new Map;let c=0,d=0,h=0,p=0,m=0,y,x=1/0,N=0;for(const E of s){const C=an(E.usage,E.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,E.model&&u.add(E.model),E.kind==="subagent"&&m++,d+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),h+=E.usage.inputTokens+E.usage.outputTokens,c+=E.tools.length,x=Math.min(x,E.startedAt),N=Math.max(N,E.endedAt??Date.now());for(const A of E.tools)l.set(A.name,(l.get(A.name)??0)+1),A.ok===!1&&p++}const _=Math.max(0,N-x),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,k=Array.from(l.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:n,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:b,cost:o,modelChips:Array.from(u),agentCount:s.length,subagentCount:m,toolCount:c,promptCount:d,tokensSum:h,errCount:p,topTools:k,firstPrompt:y}}function u3(e,n){const i=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.tools.length,u=an(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+=an(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 l3(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 c3({state:e,now:n,selectedIds:i,onSelect:s,onClose:o}){const u=q.useMemo(()=>u3(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:Vo(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:We(c.cost)})}),v.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:l3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function Jw(e,n){if(!e)return null;const i=n-Math.floor(e/1e3);return i<10?"just now":i<60?`${i}s ago`:i<3600?`${Math.floor(i/60)}m ago`:`${Math.floor(i/3600)}h ago`}function f3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function _r(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function d3({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}: ${We(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 h3(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 p3(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 ji({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?h3(s,l):null,x=s&&o?p3(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 m3=6e4;function g3(){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),m3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:i,refresh:()=>u(!0)}}function v3(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 aN=6e4;function y3(){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),aN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:i,refresh:()=>u(!0)}}function w3(){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,aN),()=>{i.current!=null&&window.clearInterval(i.current)}),[]),{data:e}}function x3({state:e,now:n,onClose:i}){var I,M;const{quota:s,loading:o,refresh:u}=g3(),{data:l,loading:c,refresh:d}=y3(),{data:h}=w3(),[p,m]=q.useState(()=>Math.floor(Date.now()/1e3));q.useEffect(()=>{const R=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(R)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=q.useMemo(()=>{const R=new Map,L={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let F=0,J=0,X=0,j=0;for(const $ of e.agents.values()){const W=$.model??"__unknown__",O=an($.usage,$.model),B=R.get(W);B?(B.inputTokens+=$.usage.inputTokens,B.outputTokens+=$.usage.outputTokens,B.cacheReadTokens+=$.usage.cacheReadTokens,B.cacheCreateTokens+=$.usage.cacheCreateTokens,B.cost.total+=O.total,B.cost.input+=O.input,B.cost.output+=O.output,B.cost.cacheRead+=O.cacheRead,B.cost.cacheWrite+=O.cacheWrite,B.agentCount++):R.set(W,{model:W,inputTokens:$.usage.inputTokens,outputTokens:$.usage.outputTokens,cacheReadTokens:$.usage.cacheReadTokens,cacheCreateTokens:$.usage.cacheCreateTokens,cost:{...O},agentCount:1}),L.total+=O.total,L.input+=O.input,L.output+=O.output,L.cacheRead+=O.cacheRead,L.cacheWrite+=O.cacheWrite,F+=$.usage.inputTokens,J+=$.usage.outputTokens,X+=$.usage.cacheReadTokens,j+=$.usage.cacheCreateTokens}const G=Array.from(R.values()).sort(($,W)=>W.cost.total-$.cost.total);let U=0,ne=0;for(const $ of e.agents.values()){if($.state!=="active")continue;const W=an($.usage,$.model);U+=W.total,ne=Math.max(ne,(($.endedAt??n)-$.startedAt)/1e3)}const K=ne>0?Tu(U,ne):null;return{byModel:G,totalCost:L,totalTokens:{in:F,out:J,cacheR:X,cacheC:j},burnRate:K}},[e,e.lastSeq,n]),S=q.useMemo(()=>{const R=[];for(const L of e.agents.values()){if(L.kind!=="root")continue;let F=an(L.usage,L.model).total,J=L.usage.inputTokens,X=L.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==L.sessionId||j.kind==="root"||(F+=an(j.usage,j.model).total,J+=j.usage.inputTokens,X+=j.usage.outputTokens);R.push({sessionId:L.sessionId,label:L.label||L.cwdBasename||"session",state:L.state,cost:F,inputTokens:J,outputTokens:X})}return R.sort((L,F)=>F.cost-L.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=N.in+N.out,E=o||c,C=Jw(s==null?void 0:s.fetchedAt,p),A=Jw(l==null?void 0:l.fetchedAt,p),P=()=>{u(),d()};return v.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[v.jsxs("div",{className:"up-header",children:[v.jsx("h3",{children:"Usage"}),_&&v.jsx("span",{className:"up-rate",children:_}),v.jsxs("div",{className:"up-header-right",children:[v.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:P,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),v.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),v.jsxs("section",{className:"up-section up-quota-section",children:[v.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&v.jsx("span",{className:"up-section-age",title:f3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?v.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&v.jsx(ji,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:p}),s.week7dPct!=null&&v.jsx(ji,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:p}),s.weekSonnetPct!=null&&v.jsx(ji,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:p}),s.weekOpusPct!=null&&v.jsx(ji,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:p})]}):(s==null?void 0:s.ok)===!1?v.jsxs("div",{className:"up-quota-na",children:[v.jsx("span",{children:"Quota unavailable."}),v.jsxs("span",{className:"up-quota-hint",children:["Run ",v.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):v.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),v.jsxs("section",{className:"up-section up-quota-section",children:[v.jsxs("h4",{className:"up-section-title",children:["Codex quota",(l==null?void 0:l.ok)&&l.planLabel&&v.jsx("span",{className:"up-plan-badge",children:l.planLabel}),A&&!c&&v.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:A})]}),l!=null&&l.ok?v.jsxs("div",{className:"up-quota-bars",children:[(I=l.windows)==null?void 0:I.map(R=>v.jsx(ji,{label:R.label,pct:R.pct,reset:R.reset??void 0,resetAt:R.resetAt??void 0,windowSec:R.windowSec??void 0,limitReached:l.limitReached&&R.pct>=100,nowSec:p},R.id)),(M=l.extraWindows)==null?void 0:M.map(R=>v.jsx(ji,{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(ji,{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:[_r(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:v3(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:We(x.total)}),v.jsx("span",{className:"up-total-label",children:"total spend"})]}),v.jsx(d3,{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"}),_r(N.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),_r(N.out)]}),N.cacheR>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache r"}),_r(N.cacheR)]}),N.cacheC>0&&v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"cache c"}),_r(N.cacheC)]})]}),y.filter(R=>R.cost.total>0).length>0&&v.jsxs("section",{className:"up-section",children:[v.jsx("h4",{className:"up-section-title",children:"By model"}),v.jsxs("table",{className:"up-table",children:[v.jsx("thead",{children:v.jsxs("tr",{children:[v.jsx("th",{children:"Model"}),v.jsx("th",{children:"Tokens"}),v.jsx("th",{children:"Cost"})]})}),v.jsx("tbody",{children:y.filter(R=>R.cost.total>0).map(R=>v.jsxs("tr",{children:[v.jsx("td",{className:"up-model-name",title:R.model,children:Vo(R.model)}),v.jsx("td",{className:"up-num",children:_r(R.inputTokens+R.outputTokens)}),v.jsx("td",{className:"up-num up-cost-val",children:We(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:_r(R.inputTokens+R.outputTokens)}),v.jsx("span",{className:"up-session-cost",children:We(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"}),_r(N.in)]}),v.jsxs("span",{className:"up-tok",children:[v.jsx("span",{className:"up-k",children:"out"}),_r(N.out)]})]}),v.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):v.jsxs("div",{className:"up-empty",children:["No usage data yet.",v.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const _3=15e3,S3=[70,80,85,90,95];function b3(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 ex(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 k3(e,n){if(!e)return"";const i=Math.floor(e/1e3)-n;return i<=0?" · due":i<60?` · next in ${i}s`:` · next in ${Math.round(i/60)}m`}function E3(e){return e==="http-429"?"rate limited":e==="http-401"?"re-login needed":e==="timeout"?"timed out":e==="network"?"unreachable":e}function N3({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?b3(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 C3({onClose:e}){var A,P,I;const[n,i]=q.useState(null),[s,o]=q.useState(null),[u,l]=q.useState(null),[c,d]=q.useState(null),[h,p]=q.useState(null),[m,y]=q.useState(()=>Math.floor(Date.now()/1e3)),x=q.useRef(null),N=q.useCallback(async(M=!1)=>{try{const[R,L]=await Promise.all([fetch(`/api/claude-accounts${M?"?refresh=1":""}`),fetch("/api/cswap-auto")]);R.ok&&i(await R.json()),L.ok&&o(await L.json())}catch{}},[]),_=q.useCallback(async(M,R)=>{l(R),p(null);try{const F=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)})).json().catch(()=>null);return F!=null&&F.ok||p((F==null?void 0:F.detail)||(F==null?void 0:F.reason)||"command failed"),F}catch{return p("server unreachable"),null}finally{l(null)}},[]);q.useEffect(()=>(N(!0),x.current=window.setInterval(()=>N(!1),_3),()=>{x.current!=null&&window.clearInterval(x.current)}),[N]),q.useEffect(()=>{const M=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(M)},[]);const S=((A=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:A.value)??"90",b=(P=n==null?void 0:n.accounts)==null?void 0:P.find(M=>M.active),k=b!=null&&b.lanes.length?Math.max(...b.lanes.map(M=>M.pct)):null,E=k!=null&&k>=Number(S)-15,C=async M=>{d(M),p(null);try{const L=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:M})})).json().catch(()=>null);L!=null&&L.ok||p((L==null?void 0:L.output)||(L==null?void 0:L.reason)||"switch failed"),await N(!0)}catch{p("server unreachable")}finally{d(null)}};return v.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[v.jsxs("div",{className:"ap-header",children:[v.jsx("h3",{children:"Accounts"}),v.jsxs("div",{className:"ap-header-right",children:[v.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>N(!0),title:"Reload from claude-swap",children:"↻"}),v.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?v.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?v.jsxs(v.Fragment,{children:[(I=n.accounts)==null?void 0:I.map(M=>v.jsxs("div",{className:`ap-account${M.active?" active":""}${M.disabled?" disabled":""}`,children:[v.jsxs("div",{className:"ap-account-head",children:[v.jsx("span",{className:"ap-num",children:M.num}),M.alias&&v.jsx("span",{className:"ap-alias",children:M.alias}),v.jsx("span",{className:"ap-email",title:M.org??void 0,children:M.email}),M.active?v.jsx("span",{className:"ap-badge-active",children:"● active"}):v.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||M.disabled,onClick:()=>C(M.num),title:M.disabled?"Held out of rotation":`Switch to ${M.alias??M.email}`,children:c===M.num?"…":"switch"})]}),M.lanes.length>0?M.lanes.map(R=>v.jsx(N3,{lane:R,nowSec:m},R.id)):v.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),v.jsxs("div",{className:"ap-meta",children:[M.error&&v.jsx("span",{className:"ap-err",children:E3(M.error)}),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!M.active&&v.jsx("button",{type:"button",className:"ap-rotate",disabled:u!=null,onClick:()=>_({action:"account",account:M.num,enabled:M.disabled},`rot-${M.num}`).then(()=>N(!0)),title:M.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:M.disabled?"held out":"in rotation"}),M.fetchedAt?v.jsxs("span",{className:`ap-age${M.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",ex(M.fetchedAt,m),k3(M.nextAt,m)]}):v.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]})]},M.num)),(s==null?void 0:s.ok)&&v.jsxs("div",{className:"ap-auto",children:[v.jsxs("div",{className:"ap-auto-head",children:[v.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),v.jsxs("span",{className:"ap-auto-ctl",children:[k!=null&&v.jsxs("span",{className:`ap-auto-now${E?" near":""}`,children:[Math.round(k),"%"]}),v.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:v.jsx("select",{"aria-label":"Switch threshold",value:S,disabled:u!=null,onChange:M=>_({action:"setting",key:"autoswitch.threshold",value:M.target.value},"threshold").then(()=>N(!0)),children:S3.map(M=>v.jsxs("option",{value:M,children:[M,"%"]},M))})}),v.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:u!=null,onClick:()=>_({action:"enable",enabled:!s.enabled},"enable").then(()=>N(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[v.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.external&&v.jsxs("p",{className:"ap-auto-note",children:[v.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",v.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&v.jsx("div",{className:"ap-auto-foot",children:v.jsxs("span",{className:"ap-auto-result",children:["checked ",ex(s.lastTick.at,m)]})})]}),h&&v.jsx("div",{className:"ap-failure",children:h}),v.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):v.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"claude-swap isn't installed."}),v.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&v.jsx("code",{className:"ap-cmd",children:n.hint}),v.jsxs("span",{className:"ap-hint",children:["Then add your accounts with ",v.jsx("code",{children:"cswap add"})," and reload."]})]}):n.reason==="no_accounts"?v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"No accounts added yet."}),v.jsx("span",{className:"ap-hint",children:"claude-swap is installed but has nothing in its store."}),v.jsx("code",{className:"ap-cmd",children:"cswap add"})]}):v.jsxs(v.Fragment,{children:[v.jsx("span",{children:"Couldn't read the account store."}),v.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})})]})}function Ai(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 tx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function cu(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 T3(e){return new Date(Date.now()-(e-1)*864e5).toISOString().slice(0,10).replace(/-/g,"")}const R3=[7,14,30,90];function j3(e){const[n,i]=q.useState(null),[s,o]=q.useState(!1),u=(l=!1)=>{o(!0);const d=`/api/ccusage?since=${T3(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 A3({onClose:e}){var b,k;const[n,i]=q.useState(30),[s,o]=q.useState(null),{data:u,loading:l,reload:c}=j3(n);q.useEffect(()=>{const E=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[e]);const d=u!=null&&u.ok?u.days??[]:[],h=q.useMemo(()=>d.reduce((E,C)=>Math.max(E,C.totalCost),0),[d]),{totalCost:p,totalTok:m,inOut:y,cacheRead:x,modelCosts:N}=q.useMemo(()=>{let E=0,C=0,A=0,P=0;const I=new Map;for(const M of d){E+=M.totalCost,C+=M.totalTokens,A+=M.inputTokens+M.outputTokens,P+=M.cacheReadTokens;for(const R of M.modelBreakdowns)I.set(R.modelName,(I.get(R.modelName)??0)+R.cost)}return{totalCost:E,totalTok:C,inOut:A,cacheRead:P,modelCosts:I}},[d]),_=q.useMemo(()=>Array.from(N.entries()).sort((E,C)=>C[1]-E[1]),[N]),S=s?d.find(E=>E.period===s)??null:null;return v.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:v.jsxs("div",{className:"uh-modal",onClick:E=>E.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[v.jsxs("header",{className:"uh-head",children:[v.jsxs("div",{className:"uh-titlewrap",children:[v.jsx("div",{className:"uh-title",children:"Usage history"}),v.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),v.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:R3.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(fu,{label:"total cost",val:We(p),accent:!0}),v.jsx(fu,{label:"tokens",val:Ai(m)}),v.jsx(fu,{label:"input+output",val:Ai(y)}),v.jsx(fu,{label:"cache reads",val:Ai(x)})]}),v.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:d.map(E=>{const C=h>0?E.totalCost/h*100:0,A=E.period===s;return v.jsxs("button",{className:`uh-bar-col${A?" sel":""}`,onClick:()=>o(A?null:E.period),title:`${E.period} · ${We(E.totalCost)}`,style:{flexBasis:`${100/d.length}%`},children:[v.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,E.totalCost>0?2:0)}%`},children:E.modelBreakdowns.slice().sort((P,I)=>I.cost-P.cost).map(P=>{const I=E.totalCost>0?P.cost/E.totalCost*100:0;return v.jsx("div",{className:"uh-bar-seg",style:{height:`${I}%`,background:cu(P.modelName)}},P.modelName)})}),v.jsx("span",{className:"uh-bar-label",children:E.period.slice(5)})]},E.period)})}),v.jsx("div",{className:"uh-legend",children:_.map(([E,C])=>v.jsxs("span",{className:"uh-legend-item",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:cu(E)}}),tx(E)," ",v.jsx("span",{className:"uh-legend-cost",children:We(C)})]},E))}),S&&v.jsxs("div",{className:"uh-detail",children:[v.jsxs("div",{className:"uh-detail-head",children:[v.jsx("span",{className:"uh-detail-date",children:S.period}),v.jsx("span",{className:"uh-detail-cost",children:We(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(du,{label:"input",val:Ai(S.inputTokens)}),v.jsx(du,{label:"output",val:Ai(S.outputTokens)}),v.jsx(du,{label:"cache write",val:Ai(S.cacheCreationTokens)}),v.jsx(du,{label:"cache read",val:Ai(S.cacheReadTokens)})]}),v.jsx("div",{className:"uh-detail-models",children:S.modelBreakdowns.slice().sort((E,C)=>C.cost-E.cost).map(E=>{const C=S.totalCost>0?E.cost/S.totalCost*100:0;return v.jsxs("div",{className:"uh-model-row",children:[v.jsxs("span",{className:"uh-model-name",children:[v.jsx("span",{className:"uh-legend-dot",style:{background:cu(E.modelName)}}),tx(E.modelName)]}),v.jsx("span",{className:"uh-model-bar",children:v.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:cu(E.modelName)}})}),v.jsx("span",{className:"uh-model-cost",children:We(E.cost)})]},E.modelName)})})]})]})]})})}function fu({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 du({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 ov(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 Zc,nx;function I3(){if(nx)return Zc;nx=1;function e(){this.__data__=[],this.size=0}return Zc=e,Zc}var Jc,rx;function qs(){if(rx)return Jc;rx=1;function e(n,i){return n===i||n!==n&&i!==i}return Jc=e,Jc}var ef,ix;function Lu(){if(ix)return ef;ix=1;var e=qs();function n(i,s){for(var o=i.length;o--;)if(e(i[o][0],s))return o;return-1}return ef=n,ef}var tf,sx;function M3(){if(sx)return tf;sx=1;var e=Lu(),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 tf=s,tf}var nf,ox;function P3(){if(ox)return nf;ox=1;var e=Lu();function n(i){var s=this.__data__,o=e(s,i);return o<0?void 0:s[o][1]}return nf=n,nf}var rf,ax;function O3(){if(ax)return rf;ax=1;var e=Lu();function n(i){return e(this.__data__,i)>-1}return rf=n,rf}var sf,ux;function q3(){if(ux)return sf;ux=1;var e=Lu();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 sf=n,sf}var of,lx;function $u(){if(lx)return of;lx=1;var e=I3(),n=M3(),i=P3(),s=O3(),o=q3();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,of=u,of}var af,cx;function L3(){if(cx)return af;cx=1;var e=$u();function n(){this.__data__=new e,this.size=0}return af=n,af}var uf,fx;function $3(){if(fx)return uf;fx=1;function e(n){var i=this.__data__,s=i.delete(n);return this.size=i.size,s}return uf=e,uf}var lf,dx;function D3(){if(dx)return lf;dx=1;function e(n){return this.__data__.get(n)}return lf=e,lf}var cf,hx;function F3(){if(hx)return cf;hx=1;function e(n){return this.__data__.has(n)}return cf=e,cf}var ff,px;function uN(){if(px)return ff;px=1;var e=typeof Za=="object"&&Za&&Za.Object===Object&&Za;return ff=e,ff}var df,mx;function Wn(){if(mx)return df;mx=1;var e=uN(),n=typeof self=="object"&&self&&self.Object===Object&&self,i=e||n||Function("return this")();return df=i,df}var hf,gx;function Ls(){if(gx)return hf;gx=1;var e=Wn(),n=e.Symbol;return hf=n,hf}var pf,vx;function z3(){if(vx)return pf;vx=1;var e=Ls(),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 pf=u,pf}var mf,yx;function B3(){if(yx)return mf;yx=1;var e=Object.prototype,n=e.toString;function i(s){return n.call(s)}return mf=i,mf}var gf,wx;function zi(){if(wx)return gf;wx=1;var e=Ls(),n=z3(),i=B3(),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 gf=l,gf}var vf,xx;function jn(){if(xx)return vf;xx=1;function e(n){var i=typeof n;return n!=null&&(i=="object"||i=="function")}return vf=e,vf}var yf,_x;function Wo(){if(_x)return yf;_x=1;var e=zi(),n=jn(),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 yf=l,yf}var wf,Sx;function U3(){if(Sx)return wf;Sx=1;var e=Wn(),n=e["__core-js_shared__"];return wf=n,wf}var xf,bx;function H3(){if(bx)return xf;bx=1;var e=U3(),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 xf=i,xf}var _f,kx;function lN(){if(kx)return _f;kx=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 _f=i,_f}var Sf,Ex;function V3(){if(Ex)return Sf;Ex=1;var e=Wo(),n=H3(),i=jn(),s=lN(),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 Sf=m,Sf}var bf,Nx;function W3(){if(Nx)return bf;Nx=1;function e(n,i){return n==null?void 0:n[i]}return bf=e,bf}var kf,Cx;function Bi(){if(Cx)return kf;Cx=1;var e=V3(),n=W3();function i(s,o){var u=n(s,o);return e(u)?u:void 0}return kf=i,kf}var Ef,Tx;function av(){if(Tx)return Ef;Tx=1;var e=Bi(),n=Wn(),i=e(n,"Map");return Ef=i,Ef}var Nf,Rx;function Du(){if(Rx)return Nf;Rx=1;var e=Bi(),n=e(Object,"create");return Nf=n,Nf}var Cf,jx;function G3(){if(jx)return Cf;jx=1;var e=Du();function n(){this.__data__=e?e(null):{},this.size=0}return Cf=n,Cf}var Tf,Ax;function Y3(){if(Ax)return Tf;Ax=1;function e(n){var i=this.has(n)&&delete this.__data__[n];return this.size-=i?1:0,i}return Tf=e,Tf}var Rf,Ix;function K3(){if(Ix)return Rf;Ix=1;var e=Du(),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 Rf=o,Rf}var jf,Mx;function X3(){if(Mx)return jf;Mx=1;var e=Du(),n=Object.prototype,i=n.hasOwnProperty;function s(o){var u=this.__data__;return e?u[o]!==void 0:i.call(u,o)}return jf=s,jf}var Af,Px;function Q3(){if(Px)return Af;Px=1;var e=Du(),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 Af=i,Af}var If,Ox;function Z3(){if(Ox)return If;Ox=1;var e=G3(),n=Y3(),i=K3(),s=X3(),o=Q3();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,If=u,If}var Mf,qx;function J3(){if(qx)return Mf;qx=1;var e=Z3(),n=$u(),i=av();function s(){this.size=0,this.__data__={hash:new e,map:new(i||n),string:new e}}return Mf=s,Mf}var Pf,Lx;function eO(){if(Lx)return Pf;Lx=1;function e(n){var i=typeof n;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?n!=="__proto__":n===null}return Pf=e,Pf}var Of,$x;function Fu(){if($x)return Of;$x=1;var e=eO();function n(i,s){var o=i.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return Of=n,Of}var qf,Dx;function tO(){if(Dx)return qf;Dx=1;var e=Fu();function n(i){var s=e(this,i).delete(i);return this.size-=s?1:0,s}return qf=n,qf}var Lf,Fx;function nO(){if(Fx)return Lf;Fx=1;var e=Fu();function n(i){return e(this,i).get(i)}return Lf=n,Lf}var $f,zx;function rO(){if(zx)return $f;zx=1;var e=Fu();function n(i){return e(this,i).has(i)}return $f=n,$f}var Df,Bx;function iO(){if(Bx)return Df;Bx=1;var e=Fu();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 Df=n,Df}var Ff,Ux;function uv(){if(Ux)return Ff;Ux=1;var e=J3(),n=tO(),i=nO(),s=rO(),o=iO();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,Ff=u,Ff}var zf,Hx;function sO(){if(Hx)return zf;Hx=1;var e=$u(),n=av(),i=uv(),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 zf=o,zf}var Bf,Vx;function zu(){if(Vx)return Bf;Vx=1;var e=$u(),n=L3(),i=$3(),s=D3(),o=F3(),u=sO();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,Bf=l,Bf}var Uf,Wx;function lv(){if(Wx)return Uf;Wx=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 Uf=e,Uf}var Hf,Gx;function cN(){if(Gx)return Hf;Gx=1;var e=Bi(),n=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return Hf=n,Hf}var Vf,Yx;function Bu(){if(Yx)return Vf;Yx=1;var e=cN();function n(i,s,o){s=="__proto__"&&e?e(i,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[s]=o}return Vf=n,Vf}var Wf,Kx;function Uu(){if(Kx)return Wf;Kx=1;var e=Bu(),n=qs(),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 Wf=o,Wf}var Gf,Xx;function Go(){if(Xx)return Gf;Xx=1;var e=Uu(),n=Bu();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 Gf=i,Gf}var Yf,Qx;function oO(){if(Qx)return Yf;Qx=1;function e(n,i){for(var s=-1,o=Array(n);++s<n;)o[s]=i(s);return o}return Yf=e,Yf}var Kf,Zx;function or(){if(Zx)return Kf;Zx=1;function e(n){return n!=null&&typeof n=="object"}return Kf=e,Kf}var Xf,Jx;function aO(){if(Jx)return Xf;Jx=1;var e=zi(),n=or(),i="[object Arguments]";function s(o){return n(o)&&e(o)==i}return Xf=s,Xf}var Qf,e1;function Yo(){if(e1)return Qf;e1=1;var e=aO(),n=or(),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 Qf=u,Qf}var Zf,t1;function xt(){if(t1)return Zf;t1=1;var e=Array.isArray;return Zf=e,Zf}var To={exports:{}},Jf,n1;function uO(){if(n1)return Jf;n1=1;function e(){return!1}return Jf=e,Jf}To.exports;var r1;function $s(){return r1||(r1=1,(function(e,n){var i=Wn(),s=uO(),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})(To,To.exports)),To.exports}var ed,i1;function Hu(){if(i1)return ed;i1=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 ed=i,ed}var td,s1;function cv(){if(s1)return td;s1=1;var e=9007199254740991;function n(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return td=n,td}var nd,o1;function lO(){if(o1)return nd;o1=1;var e=zi(),n=cv(),i=or(),s="[object Arguments]",o="[object Array]",u="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",p="[object Number]",m="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",P="[object Int32Array]",I="[object Uint8Array]",M="[object Uint8ClampedArray]",R="[object Uint16Array]",L="[object Uint32Array]",F={};F[k]=F[E]=F[C]=F[A]=F[P]=F[I]=F[M]=F[R]=F[L]=!0,F[s]=F[o]=F[S]=F[u]=F[b]=F[l]=F[c]=F[d]=F[h]=F[p]=F[m]=F[y]=F[x]=F[N]=F[_]=!1;function J(X){return i(X)&&n(X.length)&&!!F[e(X)]}return nd=J,nd}var rd,a1;function Vu(){if(a1)return rd;a1=1;function e(n){return function(i){return n(i)}}return rd=e,rd}var Ro={exports:{}};Ro.exports;var u1;function fv(){return u1||(u1=1,(function(e,n){var i=uN(),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})(Ro,Ro.exports)),Ro.exports}var id,l1;function Ko(){if(l1)return id;l1=1;var e=lO(),n=Vu(),i=fv(),s=i&&i.isTypedArray,o=s?n(s):e;return id=o,id}var sd,c1;function fN(){if(c1)return sd;c1=1;var e=oO(),n=Yo(),i=xt(),s=$s(),o=Hu(),u=Ko(),l=Object.prototype,c=l.hasOwnProperty;function d(h,p){var m=i(h),y=!m&&n(h),x=!m&&!y&&s(h),N=!m&&!y&&!x&&u(h),_=m||y||x||N,S=_?e(h.length,String):[],b=S.length;for(var k in h)(p||c.call(h,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return sd=d,sd}var od,f1;function Wu(){if(f1)return od;f1=1;var e=Object.prototype;function n(i){var s=i&&i.constructor,o=typeof s=="function"&&s.prototype||e;return i===o}return od=n,od}var ad,d1;function dN(){if(d1)return ad;d1=1;function e(n,i){return function(s){return n(i(s))}}return ad=e,ad}var ud,h1;function cO(){if(h1)return ud;h1=1;var e=dN(),n=e(Object.keys,Object);return ud=n,ud}var ld,p1;function dv(){if(p1)return ld;p1=1;var e=Wu(),n=cO(),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 ld=o,ld}var cd,m1;function Nr(){if(m1)return cd;m1=1;var e=Wo(),n=cv();function i(s){return s!=null&&n(s.length)&&!e(s)}return cd=i,cd}var fd,g1;function si(){if(g1)return fd;g1=1;var e=fN(),n=dv(),i=Nr();function s(o){return i(o)?e(o):n(o)}return fd=s,fd}var dd,v1;function fO(){if(v1)return dd;v1=1;var e=Go(),n=si();function i(s,o){return s&&e(o,n(o),s)}return dd=i,dd}var hd,y1;function dO(){if(y1)return hd;y1=1;function e(n){var i=[];if(n!=null)for(var s in Object(n))i.push(s);return i}return hd=e,hd}var pd,w1;function hO(){if(w1)return pd;w1=1;var e=jn(),n=Wu(),i=dO(),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 pd=u,pd}var md,x1;function Ui(){if(x1)return md;x1=1;var e=fN(),n=hO(),i=Nr();function s(o){return i(o)?e(o,!0):n(o)}return md=s,md}var gd,_1;function pO(){if(_1)return gd;_1=1;var e=Go(),n=Ui();function i(s,o){return s&&e(o,n(o),s)}return gd=i,gd}var jo={exports:{}};jo.exports;var S1;function hN(){return S1||(S1=1,(function(e,n){var i=Wn(),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})(jo,jo.exports)),jo.exports}var vd,b1;function pN(){if(b1)return vd;b1=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 vd=e,vd}var yd,k1;function mN(){if(k1)return yd;k1=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 yd=e,yd}var wd,E1;function gN(){if(E1)return wd;E1=1;function e(){return[]}return wd=e,wd}var xd,N1;function hv(){if(N1)return xd;N1=1;var e=mN(),n=gN(),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 xd=u,xd}var _d,C1;function mO(){if(C1)return _d;C1=1;var e=Go(),n=hv();function i(s,o){return e(s,n(s),o)}return _d=i,_d}var Sd,T1;function pv(){if(T1)return Sd;T1=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 Sd=e,Sd}var bd,R1;function Gu(){if(R1)return bd;R1=1;var e=dN(),n=e(Object.getPrototypeOf,Object);return bd=n,bd}var kd,j1;function vN(){if(j1)return kd;j1=1;var e=pv(),n=Gu(),i=hv(),s=gN(),o=Object.getOwnPropertySymbols,u=o?function(l){for(var c=[];l;)e(c,i(l)),l=n(l);return c}:s;return kd=u,kd}var Ed,A1;function gO(){if(A1)return Ed;A1=1;var e=Go(),n=vN();function i(s,o){return e(s,n(s),o)}return Ed=i,Ed}var Nd,I1;function yN(){if(I1)return Nd;I1=1;var e=pv(),n=xt();function i(s,o,u){var l=o(s);return n(s)?l:e(l,u(s))}return Nd=i,Nd}var Cd,M1;function wN(){if(M1)return Cd;M1=1;var e=yN(),n=hv(),i=si();function s(o){return e(o,i,n)}return Cd=s,Cd}var Td,P1;function vO(){if(P1)return Td;P1=1;var e=yN(),n=vN(),i=Ui();function s(o){return e(o,i,n)}return Td=s,Td}var Rd,O1;function yO(){if(O1)return Rd;O1=1;var e=Bi(),n=Wn(),i=e(n,"DataView");return Rd=i,Rd}var jd,q1;function wO(){if(q1)return jd;q1=1;var e=Bi(),n=Wn(),i=e(n,"Promise");return jd=i,jd}var Ad,L1;function xN(){if(L1)return Ad;L1=1;var e=Bi(),n=Wn(),i=e(n,"Set");return Ad=i,Ad}var Id,$1;function xO(){if($1)return Id;$1=1;var e=Bi(),n=Wn(),i=e(n,"WeakMap");return Id=i,Id}var Md,D1;function Ds(){if(D1)return Md;D1=1;var e=yO(),n=av(),i=wO(),s=xN(),o=xO(),u=zi(),l=lN(),c="[object Map]",d="[object Object]",h="[object Promise]",p="[object Set]",m="[object WeakMap]",y="[object DataView]",x=l(e),N=l(n),_=l(i),S=l(s),b=l(o),k=u;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||i&&k(i.resolve())!=h||s&&k(new s)!=p||o&&k(new o)!=m)&&(k=function(E){var C=u(E),A=C==d?E.constructor:void 0,P=A?l(A):"";if(P)switch(P){case x:return y;case N:return c;case _:return h;case S:return p;case b:return m}return C}),Md=k,Md}var Pd,F1;function _O(){if(F1)return Pd;F1=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 Pd=i,Pd}var Od,z1;function _N(){if(z1)return Od;z1=1;var e=Wn(),n=e.Uint8Array;return Od=n,Od}var qd,B1;function mv(){if(B1)return qd;B1=1;var e=_N();function n(i){var s=new i.constructor(i.byteLength);return new e(s).set(new e(i)),s}return qd=n,qd}var Ld,U1;function SO(){if(U1)return Ld;U1=1;var e=mv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.byteLength)}return Ld=n,Ld}var $d,H1;function bO(){if(H1)return $d;H1=1;var e=/\w*$/;function n(i){var s=new i.constructor(i.source,e.exec(i));return s.lastIndex=i.lastIndex,s}return $d=n,$d}var Dd,V1;function kO(){if(V1)return Dd;V1=1;var e=Ls(),n=e?e.prototype:void 0,i=n?n.valueOf:void 0;function s(o){return i?Object(i.call(o)):{}}return Dd=s,Dd}var Fd,W1;function SN(){if(W1)return Fd;W1=1;var e=mv();function n(i,s){var o=s?e(i.buffer):i.buffer;return new i.constructor(o,i.byteOffset,i.length)}return Fd=n,Fd}var zd,G1;function EO(){if(G1)return zd;G1=1;var e=mv(),n=SO(),i=bO(),s=kO(),o=SN(),u="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",p="[object Set]",m="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",A="[object Uint8ClampedArray]",P="[object Uint16Array]",I="[object Uint32Array]";function M(R,L,F){var J=R.constructor;switch(L){case x:return e(R);case u:case l:return new J(+R);case N:return n(R,F);case _:case S:case b:case k:case E:case C:case A:case P:case I:return o(R,F);case c:return new J;case d:case m:return new J(R);case h:return i(R);case p:return new J;case y:return s(R)}}return zd=M,zd}var Bd,Y1;function bN(){if(Y1)return Bd;Y1=1;var e=jn(),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 Bd=i,Bd}var Ud,K1;function kN(){if(K1)return Ud;K1=1;var e=bN(),n=Gu(),i=Wu();function s(o){return typeof o.constructor=="function"&&!i(o)?e(n(o)):{}}return Ud=s,Ud}var Hd,X1;function NO(){if(X1)return Hd;X1=1;var e=Ds(),n=or(),i="[object Map]";function s(o){return n(o)&&e(o)==i}return Hd=s,Hd}var Vd,Q1;function CO(){if(Q1)return Vd;Q1=1;var e=NO(),n=Vu(),i=fv(),s=i&&i.isMap,o=s?n(s):e;return Vd=o,Vd}var Wd,Z1;function TO(){if(Z1)return Wd;Z1=1;var e=Ds(),n=or(),i="[object Set]";function s(o){return n(o)&&e(o)==i}return Wd=s,Wd}var Gd,J1;function RO(){if(J1)return Gd;J1=1;var e=TO(),n=Vu(),i=fv(),s=i&&i.isSet,o=s?n(s):e;return Gd=o,Gd}var Yd,e_;function EN(){if(e_)return Yd;e_=1;var e=zu(),n=lv(),i=Uu(),s=fO(),o=pO(),u=hN(),l=pN(),c=mO(),d=gO(),h=wN(),p=vO(),m=Ds(),y=_O(),x=EO(),N=kN(),_=xt(),S=$s(),b=CO(),k=jn(),E=RO(),C=si(),A=Ui(),P=1,I=2,M=4,R="[object Arguments]",L="[object Array]",F="[object Boolean]",J="[object Date]",X="[object Error]",j="[object Function]",G="[object GeneratorFunction]",U="[object Map]",ne="[object Number]",K="[object Object]",$="[object RegExp]",W="[object Set]",O="[object String]",B="[object Symbol]",ae="[object WeakMap]",z="[object ArrayBuffer]",H="[object DataView]",ee="[object Float32Array]",se="[object Float64Array]",ce="[object Int8Array]",me="[object Int16Array]",ve="[object Int32Array]",Ae="[object Uint8Array]",Ue="[object Uint8ClampedArray]",Me="[object Uint16Array]",Pe="[object Uint32Array]",be={};be[R]=be[L]=be[z]=be[H]=be[F]=be[J]=be[ee]=be[se]=be[ce]=be[me]=be[ve]=be[U]=be[ne]=be[K]=be[$]=be[W]=be[O]=be[B]=be[Ae]=be[Ue]=be[Me]=be[Pe]=!0,be[X]=be[j]=be[ae]=!1;function Fe(we,xe,De,Xe,Ke,et){var ze,qe=xe&P,qt=xe&I,Lt=xe&M;if(De&&(ze=Ke?De(we,Xe,Ke,et):De(we)),ze!==void 0)return ze;if(!k(we))return we;var Ze=_(we);if(Ze){if(ze=y(we),!qe)return l(we,ze)}else{var lt=m(we),At=lt==j||lt==G;if(S(we))return u(we,qe);if(lt==K||lt==R||At&&!Ke){if(ze=qt||At?{}:N(we),!qe)return qt?d(we,o(ze,we)):c(we,s(ze,we))}else{if(!be[lt])return Ke?we:{};ze=x(we,lt,qe)}}et||(et=new e);var ht=et.get(we);if(ht)return ht;et.set(we,ze),E(we)?we.forEach(function(gt){ze.add(Fe(gt,xe,De,gt,we,et))}):b(we)&&we.forEach(function(gt,ot){ze.set(ot,Fe(gt,xe,De,ot,we,et))});var tt=Lt?qt?p:h:qt?A:C,_t=Ze?void 0:tt(we);return n(_t||we,function(gt,ot){_t&&(ot=gt,gt=we[ot]),i(ze,ot,Fe(gt,xe,De,ot,we,et))}),ze}return Yd=Fe,Yd}var Kd,t_;function jO(){if(t_)return Kd;t_=1;var e=EN(),n=4;function i(s){return e(s,n)}return Kd=i,Kd}var Xd,n_;function gv(){if(n_)return Xd;n_=1;function e(n){return function(){return n}}return Xd=e,Xd}var Qd,r_;function AO(){if(r_)return Qd;r_=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 Qd=e,Qd}var Zd,i_;function vv(){if(i_)return Zd;i_=1;var e=AO(),n=e();return Zd=n,Zd}var Jd,s_;function yv(){if(s_)return Jd;s_=1;var e=vv(),n=si();function i(s,o){return s&&e(s,o,n)}return Jd=i,Jd}var eh,o_;function IO(){if(o_)return eh;o_=1;var e=Nr();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 eh=n,eh}var th,a_;function Yu(){if(a_)return th;a_=1;var e=yv(),n=IO(),i=n(e);return th=i,th}var nh,u_;function Hi(){if(u_)return nh;u_=1;function e(n){return n}return nh=e,nh}var rh,l_;function NN(){if(l_)return rh;l_=1;var e=Hi();function n(i){return typeof i=="function"?i:e}return rh=n,rh}var ih,c_;function CN(){if(c_)return ih;c_=1;var e=lv(),n=Yu(),i=NN(),s=xt();function o(u,l){var c=s(u)?e:n;return c(u,i(l))}return ih=o,ih}var sh,f_;function TN(){return f_||(f_=1,sh=CN()),sh}var oh,d_;function MO(){if(d_)return oh;d_=1;var e=Yu();function n(i,s){var o=[];return e(i,function(u,l,c){s(u,l,c)&&o.push(u)}),o}return oh=n,oh}var ah,h_;function PO(){if(h_)return ah;h_=1;var e="__lodash_hash_undefined__";function n(i){return this.__data__.set(i,e),this}return ah=n,ah}var uh,p_;function OO(){if(p_)return uh;p_=1;function e(n){return this.__data__.has(n)}return uh=e,uh}var lh,m_;function RN(){if(m_)return lh;m_=1;var e=uv(),n=PO(),i=OO();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,lh=s,lh}var ch,g_;function qO(){if(g_)return ch;g_=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 ch=e,ch}var fh,v_;function jN(){if(v_)return fh;v_=1;function e(n,i){return n.has(i)}return fh=e,fh}var dh,y_;function AN(){if(y_)return dh;y_=1;var e=RN(),n=qO(),i=jN(),s=1,o=2;function u(l,c,d,h,p,m){var y=d&s,x=l.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=m.get(l),S=m.get(c);if(_&&S)return _==c&&S==l;var b=-1,k=!0,E=d&o?new e:void 0;for(m.set(l,c),m.set(c,l);++b<x;){var C=l[b],A=c[b];if(h)var P=y?h(A,C,b,c,l,m):h(C,A,b,l,c,m);if(P!==void 0){if(P)continue;k=!1;break}if(E){if(!n(c,function(I,M){if(!i(E,M)&&(C===I||p(C,I,d,h,m)))return E.push(M)})){k=!1;break}}else if(!(C===A||p(C,A,d,h,m))){k=!1;break}}return m.delete(l),m.delete(c),k}return dh=u,dh}var hh,w_;function LO(){if(w_)return hh;w_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o,u){s[++i]=[u,o]}),s}return hh=e,hh}var ph,x_;function wv(){if(x_)return ph;x_=1;function e(n){var i=-1,s=Array(n.size);return n.forEach(function(o){s[++i]=o}),s}return ph=e,ph}var mh,__;function $O(){if(__)return mh;__=1;var e=Ls(),n=_N(),i=qs(),s=AN(),o=LO(),u=wv(),l=1,c=2,d="[object Boolean]",h="[object Date]",p="[object Error]",m="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function A(P,I,M,R,L,F,J){switch(M){case k:if(P.byteLength!=I.byteLength||P.byteOffset!=I.byteOffset)return!1;P=P.buffer,I=I.buffer;case b:return!(P.byteLength!=I.byteLength||!F(new n(P),new n(I)));case d:case h:case y:return i(+P,+I);case p:return P.name==I.name&&P.message==I.message;case x:case _:return P==I+"";case m:var X=o;case N:var j=R&l;if(X||(X=u),P.size!=I.size&&!j)return!1;var G=J.get(P);if(G)return G==I;R|=c,J.set(P,I);var U=s(X(P),X(I),R,L,F,J);return J.delete(P),U;case S:if(C)return C.call(P)==C.call(I)}return!1}return mh=A,mh}var gh,S_;function DO(){if(S_)return gh;S_=1;var e=wN(),n=1,i=Object.prototype,s=i.hasOwnProperty;function o(u,l,c,d,h,p){var m=c&n,y=e(u),x=y.length,N=e(l),_=N.length;if(x!=_&&!m)return!1;for(var S=x;S--;){var b=y[S];if(!(m?b in l:s.call(l,b)))return!1}var k=p.get(u),E=p.get(l);if(k&&E)return k==l&&E==u;var C=!0;p.set(u,l),p.set(l,u);for(var A=m;++S<x;){b=y[S];var P=u[b],I=l[b];if(d)var M=m?d(I,P,b,l,u,p):d(P,I,b,u,l,p);if(!(M===void 0?P===I||h(P,I,c,d,p):M)){C=!1;break}A||(A=b=="constructor")}if(C&&!A){var R=u.constructor,L=l.constructor;R!=L&&"constructor"in u&&"constructor"in l&&!(typeof R=="function"&&R instanceof R&&typeof L=="function"&&L instanceof L)&&(C=!1)}return p.delete(u),p.delete(l),C}return gh=o,gh}var vh,b_;function FO(){if(b_)return vh;b_=1;var e=zu(),n=AN(),i=$O(),s=DO(),o=Ds(),u=xt(),l=$s(),c=Ko(),d=1,h="[object Arguments]",p="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,k,E,C){var A=u(_),P=u(S),I=A?p:o(_),M=P?p:o(S);I=I==h?m:I,M=M==h?m:M;var R=I==m,L=M==m,F=I==M;if(F&&l(_)){if(!l(S))return!1;A=!0,R=!1}if(F&&!R)return C||(C=new e),A||c(_)?n(_,S,b,k,E,C):i(_,S,I,b,k,E,C);if(!(b&d)){var J=R&&x.call(_,"__wrapped__"),X=L&&x.call(S,"__wrapped__");if(J||X){var j=J?_.value():_,G=X?S.value():S;return C||(C=new e),E(j,G,b,k,C)}}return F?(C||(C=new e),s(_,S,b,k,E,C)):!1}return vh=N,vh}var yh,k_;function IN(){if(k_)return yh;k_=1;var e=FO(),n=or();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 yh=i,yh}var wh,E_;function zO(){if(E_)return wh;E_=1;var e=zu(),n=IN(),i=1,s=2;function o(u,l,c,d){var h=c.length,p=h,m=!d;if(u==null)return!p;for(u=Object(u);h--;){var y=c[h];if(m&&y[2]?y[1]!==u[y[0]]:!(y[0]in u))return!1}for(;++h<p;){y=c[h];var x=y[0],N=u[x],_=y[1];if(m&&y[2]){if(N===void 0&&!(x in u))return!1}else{var S=new e;if(d)var b=d(N,_,x,u,l,S);if(!(b===void 0?n(_,N,i|s,d,S):b))return!1}}return!0}return wh=o,wh}var xh,N_;function MN(){if(N_)return xh;N_=1;var e=jn();function n(i){return i===i&&!e(i)}return xh=n,xh}var _h,C_;function BO(){if(C_)return _h;C_=1;var e=MN(),n=si();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 _h=i,_h}var Sh,T_;function PN(){if(T_)return Sh;T_=1;function e(n,i){return function(s){return s==null?!1:s[n]===i&&(i!==void 0||n in Object(s))}}return Sh=e,Sh}var bh,R_;function UO(){if(R_)return bh;R_=1;var e=zO(),n=BO(),i=PN();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 bh=s,bh}var kh,j_;function Fs(){if(j_)return kh;j_=1;var e=zi(),n=or(),i="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==i}return kh=s,kh}var Eh,A_;function xv(){if(A_)return Eh;A_=1;var e=xt(),n=Fs(),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 Eh=o,Eh}var Nh,I_;function HO(){if(I_)return Nh;I_=1;var e=uv(),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,Nh=i,Nh}var Ch,M_;function VO(){if(M_)return Ch;M_=1;var e=HO(),n=500;function i(s){var o=e(s,function(l){return u.size===n&&u.clear(),l}),u=o.cache;return o}return Ch=i,Ch}var Th,P_;function WO(){if(P_)return Th;P_=1;var e=VO(),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 Th=s,Th}var Rh,O_;function Ku(){if(O_)return Rh;O_=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 Rh=e,Rh}var jh,q_;function GO(){if(q_)return jh;q_=1;var e=Ls(),n=Ku(),i=xt(),s=Fs(),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 jh=l,jh}var Ah,L_;function ON(){if(L_)return Ah;L_=1;var e=GO();function n(i){return i==null?"":e(i)}return Ah=n,Ah}var Ih,$_;function Xu(){if($_)return Ih;$_=1;var e=xt(),n=xv(),i=WO(),s=ON();function o(u,l){return e(u)?u:n(u,l)?[u]:i(s(u))}return Ih=o,Ih}var Mh,D_;function Xo(){if(D_)return Mh;D_=1;var e=Fs();function n(i){if(typeof i=="string"||e(i))return i;var s=i+"";return s=="0"&&1/i==-1/0?"-0":s}return Mh=n,Mh}var Ph,F_;function Qu(){if(F_)return Ph;F_=1;var e=Xu(),n=Xo();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 Ph=i,Ph}var Oh,z_;function YO(){if(z_)return Oh;z_=1;var e=Qu();function n(i,s,o){var u=i==null?void 0:e(i,s);return u===void 0?o:u}return Oh=n,Oh}var qh,B_;function KO(){if(B_)return qh;B_=1;function e(n,i){return n!=null&&i in Object(n)}return qh=e,qh}var Lh,U_;function qN(){if(U_)return Lh;U_=1;var e=Xu(),n=Yo(),i=xt(),s=Hu(),o=cv(),u=Xo();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 Lh=l,Lh}var $h,H_;function LN(){if(H_)return $h;H_=1;var e=KO(),n=qN();function i(s,o){return s!=null&&n(s,o,e)}return $h=i,$h}var Dh,V_;function XO(){if(V_)return Dh;V_=1;var e=IN(),n=YO(),i=LN(),s=xv(),o=MN(),u=PN(),l=Xo(),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 Dh=h,Dh}var Fh,W_;function $N(){if(W_)return Fh;W_=1;function e(n){return function(i){return i==null?void 0:i[n]}}return Fh=e,Fh}var zh,G_;function QO(){if(G_)return zh;G_=1;var e=Qu();function n(i){return function(s){return e(s,i)}}return zh=n,zh}var Bh,Y_;function ZO(){if(Y_)return Bh;Y_=1;var e=$N(),n=QO(),i=xv(),s=Xo();function o(u){return i(u)?e(s(u)):n(u)}return Bh=o,Bh}var Uh,K_;function Cr(){if(K_)return Uh;K_=1;var e=UO(),n=XO(),i=Hi(),s=xt(),o=ZO();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 Uh=u,Uh}var Hh,X_;function DN(){if(X_)return Hh;X_=1;var e=mN(),n=MO(),i=Cr(),s=xt();function o(u,l){var c=s(u)?e:n;return c(u,i(l,3))}return Hh=o,Hh}var Vh,Q_;function JO(){if(Q_)return Vh;Q_=1;var e=Object.prototype,n=e.hasOwnProperty;function i(s,o){return s!=null&&n.call(s,o)}return Vh=i,Vh}var Wh,Z_;function FN(){if(Z_)return Wh;Z_=1;var e=JO(),n=qN();function i(s,o){return s!=null&&n(s,o,e)}return Wh=i,Wh}var Gh,J_;function eq(){if(J_)return Gh;J_=1;var e=dv(),n=Ds(),i=Yo(),s=xt(),o=Nr(),u=$s(),l=Wu(),c=Ko(),d="[object Map]",h="[object Set]",p=Object.prototype,m=p.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||u(x)||c(x)||i(x)))return!x.length;var N=n(x);if(N==d||N==h)return!x.size;if(l(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return Gh=y,Gh}var Yh,eS;function zN(){if(eS)return Yh;eS=1;function e(n){return n===void 0}return Yh=e,Yh}var Kh,tS;function BN(){if(tS)return Kh;tS=1;var e=Yu(),n=Nr();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 Kh=i,Kh}var Xh,nS;function UN(){if(nS)return Xh;nS=1;var e=Ku(),n=Cr(),i=BN(),s=xt();function o(u,l){var c=s(u)?e:i;return c(u,n(l,3))}return Xh=o,Xh}var Qh,rS;function tq(){if(rS)return Qh;rS=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 Qh=e,Qh}var Zh,iS;function nq(){if(iS)return Zh;iS=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 Zh=e,Zh}var Jh,sS;function HN(){if(sS)return Jh;sS=1;var e=tq(),n=Yu(),i=Cr(),s=nq(),o=xt();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 Jh=u,Jh}var ep,oS;function rq(){if(oS)return ep;oS=1;var e=zi(),n=xt(),i=or(),s="[object String]";function o(u){return typeof u=="string"||!n(u)&&i(u)&&e(u)==s}return ep=o,ep}var tp,aS;function iq(){if(aS)return tp;aS=1;var e=$N(),n=e("length");return tp=n,tp}var np,uS;function sq(){if(uS)return np;uS=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 np=d,np}var rp,lS;function oq(){if(lS)return rp;lS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+i+s,u="\\ufe0e\\ufe0f",l="["+e+"]",c="["+o+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",p="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+u+"]?",S="(?:"+x+"(?:"+[p,m,y].join("|")+")"+_+N+")*",b=_+N+S,k="(?:"+[p+c+"?",c,m,y,l].join("|")+")",E=RegExp(d+"(?="+d+")|"+k+b,"g");function C(A){for(var P=E.lastIndex=0;E.test(A);)++P;return P}return rp=C,rp}var ip,cS;function aq(){if(cS)return ip;cS=1;var e=iq(),n=sq(),i=oq();function s(o){return n(o)?i(o):e(o)}return ip=s,ip}var sp,fS;function uq(){if(fS)return sp;fS=1;var e=dv(),n=Ds(),i=Nr(),s=rq(),o=aq(),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 sp=c,sp}var op,dS;function lq(){if(dS)return op;dS=1;var e=lv(),n=bN(),i=yv(),s=Cr(),o=Gu(),u=xt(),l=$s(),c=Wo(),d=jn(),h=Ko();function p(m,y,x){var N=u(m),_=N||l(m)||h(m);if(y=s(y,4),x==null){var S=m&&m.constructor;_?x=N?new S:[]:d(m)?x=c(S)?n(o(m)):{}:x={}}return(_?e:i)(m,function(b,k,E){return y(x,b,k,E)}),x}return op=p,op}var ap,hS;function cq(){if(hS)return ap;hS=1;var e=Ls(),n=Yo(),i=xt(),s=e?e.isConcatSpreadable:void 0;function o(u){return i(u)||n(u)||!!(s&&u&&u[s])}return ap=o,ap}var up,pS;function _v(){if(pS)return up;pS=1;var e=pv(),n=cq();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 up=i,up}var lp,mS;function fq(){if(mS)return lp;mS=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 lp=e,lp}var cp,gS;function VN(){if(gS)return cp;gS=1;var e=fq(),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 cp=i,cp}var fp,vS;function dq(){if(vS)return fp;vS=1;var e=gv(),n=cN(),i=Hi(),s=n?function(o,u){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(u),writable:!0})}:i;return fp=s,fp}var dp,yS;function hq(){if(yS)return dp;yS=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 dp=s,dp}var hp,wS;function WN(){if(wS)return hp;wS=1;var e=dq(),n=hq(),i=n(e);return hp=i,hp}var pp,xS;function Zu(){if(xS)return pp;xS=1;var e=Hi(),n=VN(),i=WN();function s(o,u){return i(n(o,u,e),o+"")}return pp=s,pp}var mp,_S;function GN(){if(_S)return mp;_S=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 mp=e,mp}var gp,SS;function pq(){if(SS)return gp;SS=1;function e(n){return n!==n}return gp=e,gp}var vp,bS;function mq(){if(bS)return vp;bS=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 vp=e,vp}var yp,kS;function gq(){if(kS)return yp;kS=1;var e=GN(),n=pq(),i=mq();function s(o,u,l){return u===u?i(o,u,l):e(o,n,l)}return yp=s,yp}var wp,ES;function vq(){if(ES)return wp;ES=1;var e=gq();function n(i,s){var o=i==null?0:i.length;return!!o&&e(i,s,0)>-1}return wp=n,wp}var xp,NS;function yq(){if(NS)return xp;NS=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 xp=e,xp}var _p,CS;function wq(){if(CS)return _p;CS=1;function e(){}return _p=e,_p}var Sp,TS;function xq(){if(TS)return Sp;TS=1;var e=xN(),n=wq(),i=wv(),s=1/0,o=e&&1/i(new e([,-0]))[1]==s?function(u){return new e(u)}:n;return Sp=o,Sp}var bp,RS;function _q(){if(RS)return bp;RS=1;var e=RN(),n=vq(),i=yq(),s=jN(),o=xq(),u=wv(),l=200;function c(d,h,p){var m=-1,y=n,x=d.length,N=!0,_=[],S=_;if(p)N=!1,y=i;else if(x>=l){var b=h?null:o(d);if(b)return u(b);N=!1,y=s,S=new e}else S=h?[]:_;e:for(;++m<x;){var k=d[m],E=h?h(k):k;if(k=p||k!==0?k:0,N&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;h&&S.push(E),_.push(k)}else y(S,E,p)||(S!==_&&S.push(E),_.push(k))}return _}return bp=c,bp}var kp,jS;function YN(){if(jS)return kp;jS=1;var e=Nr(),n=or();function i(s){return n(s)&&e(s)}return kp=i,kp}var Ep,AS;function Sq(){if(AS)return Ep;AS=1;var e=_v(),n=Zu(),i=_q(),s=YN(),o=n(function(u){return i(e(u,1,s,!0))});return Ep=o,Ep}var Np,IS;function bq(){if(IS)return Np;IS=1;var e=Ku();function n(i,s){return e(s,function(o){return i[o]})}return Np=n,Np}var Cp,MS;function KN(){if(MS)return Cp;MS=1;var e=bq(),n=si();function i(s){return s==null?[]:e(s,n(s))}return Cp=i,Cp}var Tp,PS;function An(){if(PS)return Tp;PS=1;var e;if(typeof ov=="function")try{e={clone:jO(),constant:gv(),each:TN(),filter:DN(),has:FN(),isArray:xt(),isEmpty:eq(),isFunction:Wo(),isUndefined:zN(),keys:si(),map:UN(),reduce:HN(),size:uq(),transform:lq(),union:Sq(),values:KN()}}catch{}return e||(e=window._),Tp=e,Tp}var Rp,OS;function Sv(){if(OS)return Rp;OS=1;var e=An();Rp=o;var n="\0",i="\0",s="";function o(p){this._isDirected=e.has(p,"directed")?p.directed:!0,this._isMultigraph=e.has(p,"multigraph")?p.multigraph:!1,this._isCompound=e.has(p,"compound")?p.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(p){return this._label=p,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultNodeLabelFn=p,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._in[m])})},o.prototype.sinks=function(){var p=this;return e.filter(this.nodes(),function(m){return e.isEmpty(p._out[m])})},o.prototype.setNodes=function(p,m){var y=arguments,x=this;return e.each(p,function(N){y.length>1?x.setNode(N,m):x.setNode(N)}),this},o.prototype.setNode=function(p,m){return e.has(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=m),this):(this._nodes[p]=arguments.length>1?m:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=i,this._children[p]={},this._children[i][p]=!0),this._in[p]={},this._preds[p]={},this._out[p]={},this._sucs[p]={},++this._nodeCount,this)},o.prototype.node=function(p){return this._nodes[p]},o.prototype.hasNode=function(p){return e.has(this._nodes,p)},o.prototype.removeNode=function(p){var m=this;if(e.has(this._nodes,p)){var y=function(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[p],this._isCompound&&(this._removeFromParentsChildList(p),delete this._parent[p],e.each(this.children(p),function(x){m.setParent(x)}),delete this._children[p]),e.each(e.keys(this._in[p]),y),delete this._in[p],delete this._preds[p],e.each(e.keys(this._out[p]),y),delete this._out[p],delete this._sucs[p],--this._nodeCount}return this},o.prototype.setParent=function(p,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=i;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===p)throw new Error("Setting "+m+" as parent of "+p+" would create a cycle");this.setNode(m)}return this.setNode(p),this._removeFromParentsChildList(p),this._parent[p]=m,this._children[m][p]=!0,this},o.prototype._removeFromParentsChildList=function(p){delete this._children[this._parent[p]][p]},o.prototype.parent=function(p){if(this._isCompound){var m=this._parent[p];if(m!==i)return m}},o.prototype.children=function(p){if(e.isUndefined(p)&&(p=i),this._isCompound){var m=this._children[p];if(m)return e.keys(m)}else{if(p===i)return this.nodes();if(this.hasNode(p))return[]}},o.prototype.predecessors=function(p){var m=this._preds[p];if(m)return e.keys(m)},o.prototype.successors=function(p){var m=this._sucs[p];if(m)return e.keys(m)},o.prototype.neighbors=function(p){var m=this.predecessors(p);if(m)return e.union(m,this.successors(p))},o.prototype.isLeaf=function(p){var m;return this.isDirected()?m=this.successors(p):m=this.neighbors(p),m.length===0},o.prototype.filterNodes=function(p){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){p(S)&&m.setNode(S,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var x={};function N(_){var S=y.parent(_);return S===void 0||m.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),m},o.prototype.setDefaultEdgeLabel=function(p){return e.isFunction(p)||(p=e.constant(p)),this._defaultEdgeLabelFn=p,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(p,m){var y=this,x=arguments;return e.reduce(p,function(N,_){return x.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var p,m,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(p=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(p=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),p=""+p,m=""+m,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,p,m,y);if(e.has(this._edgeLabels,S))return N&&(this._edgeLabels[S]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(p),this.setNode(m),this._edgeLabels[S]=N?x:this._defaultEdgeLabelFn(p,m,y);var b=d(this._isDirected,p,m,y);return p=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,u(this._preds[m],p),u(this._sucs[p],m),this._in[m][S]=b,this._out[p][S]=b,this._edgeCount++,this},o.prototype.edge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(p,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,p,m,y),N=this._edgeObjs[x];return N&&(p=N.v,m=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],l(this._preds[m],p),l(this._sucs[p],m),delete this._in[m][x],delete this._out[p][x],this._edgeCount--),this},o.prototype.inEdges=function(p,m){var y=this._in[p];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.v===m}):x}},o.prototype.outEdges=function(p,m){var y=this._out[p];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.w===m}):x}},o.prototype.nodeEdges=function(p,m){var y=this.inEdges(p,m);if(y)return y.concat(this.outEdges(p,m))};function u(p,m){p[m]?p[m]++:p[m]=1}function l(p,m){--p[m]||delete p[m]}function c(p,m,y,x){var N=""+m,_=""+y;if(!p&&N>_){var S=N;N=_,_=S}return N+s+_+s+(e.isUndefined(x)?n:x)}function d(p,m,y,x){var N=""+m,_=""+y;if(!p&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function h(p,m){return c(p,m.v,m.w,m.name)}return Rp}var jp,qS;function kq(){return qS||(qS=1,jp="2.1.8"),jp}var Ap,LS;function Eq(){return LS||(LS=1,Ap={Graph:Sv(),version:kq()}),Ap}var Ip,$S;function Nq(){if($S)return Ip;$S=1;var e=An(),n=Sv();Ip={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 Ip}var Mp,DS;function Cq(){if(DS)return Mp;DS=1;var e=An();Mp=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 Mp}var Pp,FS;function XN(){if(FS)return Pp;FS=1;var e=An();Pp=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},Pp}var Op,zS;function QN(){if(zS)return Op;zS=1;var e=An(),n=XN();Op=s;var i=e.constant(1);function s(u,l,c,d){return o(u,String(l),c||i,d||function(h){return u.outEdges(h)})}function o(u,l,c,d){var h={},p=new n,m,y,x=function(N){var _=N.v!==m?N.v:N.w,S=h[_],b=c(N),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=m,p.decrease(_,k))};for(u.nodes().forEach(function(N){var _=N===l?0:Number.POSITIVE_INFINITY;h[N]={distance:_},p.add(N,_)});p.size()>0&&(m=p.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)d(m).forEach(x);return h}return Op}var qp,BS;function Tq(){if(BS)return qp;BS=1;var e=QN(),n=An();qp=i;function i(s,o,u){return n.transform(s.nodes(),function(l,c){l[c]=e(s,c,o,u)},{})}return qp}var Lp,US;function ZN(){if(US)return Lp;US=1;var e=An();Lp=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 Lp}var $p,HS;function Rq(){if(HS)return $p;HS=1;var e=An(),n=ZN();$p=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 $p}var Dp,VS;function jq(){if(VS)return Dp;VS=1;var e=An();Dp=i;var n=e.constant(1);function i(o,u,l){return s(o,u||n,l||function(c){return o.outEdges(c)})}function s(o,u,l){var c={},d=o.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(p){h!==p&&(c[h][p]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(p){var m=p.v===h?p.w:p.v,y=u(p);c[h][m]={distance:y,predecessor:h}})}),d.forEach(function(h){var p=c[h];d.forEach(function(m){var y=c[m];d.forEach(function(x){var N=y[h],_=p[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return Dp}var Fp,WS;function JN(){if(WS)return Fp;WS=1;var e=An();Fp=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,Fp}var zp,GS;function Aq(){if(GS)return zp;GS=1;var e=JN();zp=n;function n(i){try{e(i)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return zp}var Bp,YS;function eC(){if(YS)return Bp;YS=1;var e=An();Bp=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 Bp}var Up,KS;function Iq(){if(KS)return Up;KS=1;var e=eC();Up=n;function n(i,s){return e(i,s,"post")}return Up}var Hp,XS;function Mq(){if(XS)return Hp;XS=1;var e=eC();Hp=n;function n(i,s){return e(i,s,"pre")}return Hp}var Vp,QS;function Pq(){if(QS)return Vp;QS=1;var e=An(),n=Sv(),i=XN();Vp=s;function s(o,u){var l=new n,c={},d=new i,h;function p(y){var x=y.v===h?y.w:y.v,N=d.priority(x);if(N!==void 0){var _=u(y);_<N&&(c[x]=h,d.decrease(x,_))}}if(o.nodeCount()===0)return l;e.each(o.nodes(),function(y){d.add(y,Number.POSITIVE_INFINITY),l.setNode(y)}),d.decrease(o.nodes()[0],0);for(var m=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))l.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(p)}return l}return Vp}var Wp,ZS;function Oq(){return ZS||(ZS=1,Wp={components:Cq(),dijkstra:QN(),dijkstraAll:Tq(),findCycles:Rq(),floydWarshall:jq(),isAcyclic:Aq(),postorder:Iq(),preorder:Mq(),prim:Pq(),tarjan:ZN(),topsort:JN()}),Wp}var Gp,JS;function qq(){if(JS)return Gp;JS=1;var e=Eq();return Gp={Graph:e.Graph,json:Nq(),alg:Oq(),version:e.version},Gp}var Yp,eb;function Hn(){if(eb)return Yp;eb=1;var e;if(typeof ov=="function")try{e=qq()}catch{}return e||(e=window.graphlib),Yp=e,Yp}var Kp,tb;function Lq(){if(tb)return Kp;tb=1;var e=EN(),n=1,i=4;function s(o){return e(o,n|i)}return Kp=s,Kp}var Xp,nb;function Ju(){if(nb)return Xp;nb=1;var e=qs(),n=Nr(),i=Hu(),s=jn();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 Xp=o,Xp}var Qp,rb;function $q(){if(rb)return Qp;rb=1;var e=Zu(),n=qs(),i=Ju(),s=Ui(),o=Object.prototype,u=o.hasOwnProperty,l=e(function(c,d){c=Object(c);var h=-1,p=d.length,m=p>2?d[2]:void 0;for(m&&i(d[0],d[1],m)&&(p=1);++h<p;)for(var y=d[h],x=s(y),N=-1,_=x.length;++N<_;){var S=x[N],b=c[S];(b===void 0||n(b,o[S])&&!u.call(c,S))&&(c[S]=y[S])}return c});return Qp=l,Qp}var Zp,ib;function Dq(){if(ib)return Zp;ib=1;var e=Cr(),n=Nr(),i=si();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 Zp=s,Zp}var Jp,sb;function Fq(){if(sb)return Jp;sb=1;var e=/\s/;function n(i){for(var s=i.length;s--&&e.test(i.charAt(s)););return s}return Jp=n,Jp}var em,ob;function zq(){if(ob)return em;ob=1;var e=Fq(),n=/^\s+/;function i(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return em=i,em}var tm,ab;function Bq(){if(ab)return tm;ab=1;var e=zq(),n=jn(),i=Fs(),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 tm=d,tm}var nm,ub;function tC(){if(ub)return nm;ub=1;var e=Bq(),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 nm=s,nm}var rm,lb;function Uq(){if(lb)return rm;lb=1;var e=tC();function n(i){var s=e(i),o=s%1;return s===s?o?s-o:s:0}return rm=n,rm}var im,cb;function Hq(){if(cb)return im;cb=1;var e=GN(),n=Cr(),i=Uq(),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 im=o,im}var sm,fb;function Vq(){if(fb)return sm;fb=1;var e=Dq(),n=Hq(),i=e(n);return sm=i,sm}var om,db;function nC(){if(db)return om;db=1;var e=_v();function n(i){var s=i==null?0:i.length;return s?e(i,1):[]}return om=n,om}var am,hb;function Wq(){if(hb)return am;hb=1;var e=vv(),n=NN(),i=Ui();function s(o,u){return o==null?o:e(o,n(u),i)}return am=s,am}var um,pb;function Gq(){if(pb)return um;pb=1;function e(n){var i=n==null?0:n.length;return i?n[i-1]:void 0}return um=e,um}var lm,mb;function Yq(){if(mb)return lm;mb=1;var e=Bu(),n=yv(),i=Cr();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 lm=s,lm}var cm,gb;function bv(){if(gb)return cm;gb=1;var e=Fs();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 cm=n,cm}var fm,vb;function Kq(){if(vb)return fm;vb=1;function e(n,i){return n>i}return fm=e,fm}var dm,yb;function Xq(){if(yb)return dm;yb=1;var e=bv(),n=Kq(),i=Hi();function s(o){return o&&o.length?e(o,i,n):void 0}return dm=s,dm}var hm,wb;function rC(){if(wb)return hm;wb=1;var e=Bu(),n=qs();function i(s,o,u){(u!==void 0&&!n(s[o],u)||u===void 0&&!(o in s))&&e(s,o,u)}return hm=i,hm}var pm,xb;function Qq(){if(xb)return pm;xb=1;var e=zi(),n=Gu(),i=or(),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 pm=h,pm}var mm,_b;function iC(){if(_b)return mm;_b=1;function e(n,i){if(!(i==="constructor"&&typeof n[i]=="function")&&i!="__proto__")return n[i]}return mm=e,mm}var gm,Sb;function Zq(){if(Sb)return gm;Sb=1;var e=Go(),n=Ui();function i(s){return e(s,n(s))}return gm=i,gm}var vm,bb;function Jq(){if(bb)return vm;bb=1;var e=rC(),n=hN(),i=SN(),s=pN(),o=kN(),u=Yo(),l=xt(),c=YN(),d=$s(),h=Wo(),p=jn(),m=Qq(),y=Ko(),x=iC(),N=Zq();function _(S,b,k,E,C,A,P){var I=x(S,k),M=x(b,k),R=P.get(M);if(R){e(S,k,R);return}var L=A?A(I,M,k+"",S,b,P):void 0,F=L===void 0;if(F){var J=l(M),X=!J&&d(M),j=!J&&!X&&y(M);L=M,J||X||j?l(I)?L=I:c(I)?L=s(I):X?(F=!1,L=n(M,!0)):j?(F=!1,L=i(M,!0)):L=[]:m(M)||u(M)?(L=I,u(I)?L=N(I):(!p(I)||h(I))&&(L=o(M))):F=!1}F&&(P.set(M,L),C(L,M,E,A,P),P.delete(M)),e(S,k,L)}return vm=_,vm}var ym,kb;function eL(){if(kb)return ym;kb=1;var e=zu(),n=rC(),i=vv(),s=Jq(),o=jn(),u=Ui(),l=iC();function c(d,h,p,m,y){d!==h&&i(h,function(x,N){if(y||(y=new e),o(x))s(d,h,N,p,c,m,y);else{var _=m?m(l(d,N),x,N+"",d,h,y):void 0;_===void 0&&(_=x),n(d,N,_)}},u)}return ym=c,ym}var wm,Eb;function tL(){if(Eb)return wm;Eb=1;var e=Zu(),n=Ju();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 wm=i,wm}var xm,Nb;function nL(){if(Nb)return xm;Nb=1;var e=eL(),n=tL(),i=n(function(s,o,u){e(s,o,u)});return xm=i,xm}var _m,Cb;function sC(){if(Cb)return _m;Cb=1;function e(n,i){return n<i}return _m=e,_m}var Sm,Tb;function rL(){if(Tb)return Sm;Tb=1;var e=bv(),n=sC(),i=Hi();function s(o){return o&&o.length?e(o,i,n):void 0}return Sm=s,Sm}var bm,Rb;function iL(){if(Rb)return bm;Rb=1;var e=bv(),n=Cr(),i=sC();function s(o,u){return o&&o.length?e(o,n(u,2),i):void 0}return bm=s,bm}var km,jb;function sL(){if(jb)return km;jb=1;var e=Wn(),n=function(){return e.Date.now()};return km=n,km}var Em,Ab;function oL(){if(Ab)return Em;Ab=1;var e=Uu(),n=Xu(),i=Hu(),s=jn(),o=Xo();function u(l,c,d,h){if(!s(l))return l;c=n(c,l);for(var p=-1,m=c.length,y=m-1,x=l;x!=null&&++p<m;){var N=o(c[p]),_=d;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(p!=y){var S=x[N];_=h?h(S,N,x):void 0,_===void 0&&(_=s(S)?S:i(c[p+1])?[]:{})}e(x,N,_),x=x[N]}return l}return Em=u,Em}var Nm,Ib;function aL(){if(Ib)return Nm;Ib=1;var e=Qu(),n=oL(),i=Xu();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 Nm=s,Nm}var Cm,Mb;function uL(){if(Mb)return Cm;Mb=1;var e=aL(),n=LN();function i(s,o){return e(s,o,function(u,l){return n(s,l)})}return Cm=i,Cm}var Tm,Pb;function lL(){if(Pb)return Tm;Pb=1;var e=nC(),n=VN(),i=WN();function s(o){return i(n(o,void 0,e),o+"")}return Tm=s,Tm}var Rm,Ob;function cL(){if(Ob)return Rm;Ob=1;var e=uL(),n=lL(),i=n(function(s,o){return s==null?{}:e(s,o)});return Rm=i,Rm}var jm,qb;function fL(){if(qb)return jm;qb=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 jm=i,jm}var Am,Lb;function dL(){if(Lb)return Am;Lb=1;var e=fL(),n=Ju(),i=tC();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 Am=s,Am}var Im,$b;function hL(){if($b)return Im;$b=1;var e=dL(),n=e();return Im=n,Im}var Mm,Db;function pL(){if(Db)return Mm;Db=1;function e(n,i){var s=n.length;for(n.sort(i);s--;)n[s]=n[s].value;return n}return Mm=e,Mm}var Pm,Fb;function mL(){if(Fb)return Pm;Fb=1;var e=Fs();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 Pm=n,Pm}var Om,zb;function gL(){if(zb)return Om;zb=1;var e=mL();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 Om=n,Om}var qm,Bb;function vL(){if(Bb)return qm;Bb=1;var e=Ku(),n=Qu(),i=Cr(),s=BN(),o=pL(),u=Vu(),l=gL(),c=Hi(),d=xt();function h(p,m,y){m.length?m=e(m,function(_){return d(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,u(i));var N=s(p,function(_,S,b){var k=e(m,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,S){return l(_,S,y)})}return qm=h,qm}var Lm,Ub;function yL(){if(Ub)return Lm;Ub=1;var e=_v(),n=vL(),i=Zu(),s=Ju(),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 Lm=o,Lm}var $m,Hb;function wL(){if(Hb)return $m;Hb=1;var e=ON(),n=0;function i(s){var o=++n;return e(s)+o}return $m=i,$m}var Dm,Vb;function xL(){if(Vb)return Dm;Vb=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 Dm=e,Dm}var Fm,Wb;function _L(){if(Wb)return Fm;Wb=1;var e=Uu(),n=xL();function i(s,o){return n(s||[],o||[],e)}return Fm=i,Fm}var zm,Gb;function ut(){if(Gb)return zm;Gb=1;var e;if(typeof ov=="function")try{e={cloneDeep:Lq(),constant:gv(),defaults:$q(),each:TN(),filter:DN(),find:Vq(),flatten:nC(),forEach:CN(),forIn:Wq(),has:FN(),isUndefined:zN(),last:Gq(),map:UN(),mapValues:Yq(),max:Xq(),merge:nL(),min:rL(),minBy:iL(),now:sL(),pick:cL(),range:hL(),reduce:HN(),sortBy:yL(),uniqueId:wL(),values:KN(),zipObject:_L()}}catch{}return e||(e=window._),zm=e,zm}var Bm,Yb;function SL(){if(Yb)return Bm;Yb=1,Bm=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 Bm}var Um,Kb;function bL(){if(Kb)return Um;Kb=1;var e=ut(),n=Hn().Graph,i=SL();Um=o;var s=e.constant(1);function o(h,p){if(h.nodeCount()<=1)return[];var m=c(h,p||s),y=u(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function u(h,p,m){for(var y=[],x=p[p.length-1],N=p[0],_;h.nodeCount();){for(;_=N.dequeue();)l(h,p,m,_);for(;_=x.dequeue();)l(h,p,m,_);if(h.nodeCount()){for(var S=p.length-2;S>0;--S)if(_=p[S].dequeue(),_){y=y.concat(l(h,p,m,_,!0));break}}}return y}function l(h,p,m,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,d(p,m,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,k=h.node(b);k.in-=S,d(p,m,k)}),h.removeNode(y.v),N}function c(h,p){var m=new n,y=0,x=0;e.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=m.edge(S.v,S.w)||0,k=p(S),E=b+k;m.setEdge(S.v,S.w,E),x=Math.max(x,m.node(S.v).out+=k),y=Math.max(y,m.node(S.w).in+=k)});var N=e.range(x+y+3).map(function(){return new i}),_=y+1;return e.forEach(m.nodes(),function(S){d(N,_,m.node(S))}),{graph:m,buckets:N,zeroIdx:_}}function d(h,p,m){m.out?m.in?h[m.out-m.in+p].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return Um}var Hm,Xb;function kL(){if(Xb)return Hm;Xb=1;var e=ut(),n=bL();Hm={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 Hm}var Vm,Qb;function un(){if(Qb)return Vm;Qb=1;var e=ut(),n=Hn().Graph;Vm={addDummyNode:i,simplify:s,asNonCompoundGraph:o,successorWeights:u,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:p,addBorderNode:m,maxRank:y,partition:x,time:N,notime:_};function i(S,b,k,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return k.dummy=b,S.setNode(C,k),C}function s(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var E=b.edge(k.v,k.w)||{weight:0,minlen:1},C=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function u(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function l(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,C=b.x-k,A=b.y-E,P=S.width/2,I=S.height/2;if(!C&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var M,R;return Math.abs(A)*P>Math.abs(C)*I?(A<0&&(I=-I),M=I*C/A,R=I):(C<0&&(P=-P),M=P,R=P*A/C),{x:k+M,y:E+R}}function d(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var E=S.node(k),C=E.rank;e.isUndefined(C)||(b[C][E.order]=k)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var E=S.node(k);e.has(E,"rank")&&(E.rank-=b)})}function p(S){var b=e.min(e.map(S.nodes(),function(A){return S.node(A).rank})),k=[];e.forEach(S.nodes(),function(A){var P=S.node(A).rank-b;k[P]||(k[P]=[]),k[P].push(A)});var E=0,C=S.graph().nodeRankFactor;e.forEach(k,function(A,P){e.isUndefined(A)&&P%C!==0?--E:E&&e.forEach(A,function(I){S.node(I).rank+=E})})}function m(S,b,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),i(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return Vm}var Wm,Zb;function EL(){if(Zb)return Wm;Zb=1;var e=ut(),n=un();Wm={run:i,undo:o};function i(u){u.graph().dummyChains=[],e.forEach(u.edges(),function(l){s(u,l)})}function s(u,l){var c=l.v,d=u.node(c).rank,h=l.w,p=u.node(h).rank,m=l.name,y=u.edge(l),x=y.labelRank;if(p!==d+1){u.removeEdge(l);var N,_,S;for(S=0,++d;d<p;++S,++d)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:l,rank:d},N=n.addDummyNode(u,"edge",_,"_d"),d===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),u.setEdge(c,N,{weight:y.weight},m),S===0&&u.graph().dummyChains.push(N),c=N;u.setEdge(c,h,{weight:y.weight},m)}}function o(u){e.forEach(u.graph().dummyChains,function(l){var c=u.node(l),d=c.edgeLabel,h;for(u.setEdge(c.edgeObj,d);c.dummy;)h=u.successors(l)[0],u.removeNode(l),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),l=h,c=u.node(l)})}return Wm}var Gm,Jb;function Ru(){if(Jb)return Gm;Jb=1;var e=ut();Gm={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 Gm}var Ym,ek;function oC(){if(ek)return Ym;ek=1;var e=ut(),n=Hn().Graph,i=Ru().slack;Ym=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 Ym}var Km,tk;function NL(){if(tk)return Km;tk=1;var e=ut(),n=oC(),i=Ru().slack,s=Ru().longestPath,o=Hn().alg.preorder,u=Hn().alg.postorder,l=un().simplify;Km=c,c.initLowLimValues=m,c.initCutValues=d,c.calcCutValue=p,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=l(E),s(E);var C=n(E);m(C),d(C,E);for(var A,P;A=x(C);)P=N(C,E,A),_(C,E,A,P)}function d(E,C){var A=u(E,E.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(P){h(E,C,P)})}function h(E,C,A){var P=E.node(A),I=P.parent;E.edge(A,I).cutvalue=p(E,C,A)}function p(E,C,A){var P=E.node(A),I=P.parent,M=!0,R=C.edge(A,I),L=0;return R||(M=!1,R=C.edge(I,A)),L=R.weight,e.forEach(C.nodeEdges(A),function(F){var J=F.v===A,X=J?F.w:F.v;if(X!==I){var j=J===M,G=C.edge(F).weight;if(L+=j?G:-G,b(E,A,X)){var U=E.edge(A,X).cutvalue;L+=j?-U:U}}}),L}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,A,P,I){var M=A,R=E.node(P);return C[P]=!0,e.forEach(E.neighbors(P),function(L){e.has(C,L)||(A=y(E,C,A,L,P))}),R.low=M,R.lim=A++,I?R.parent=I:delete R.parent,A}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,A){var P=A.v,I=A.w;C.hasEdge(P,I)||(P=A.w,I=A.v);var M=E.node(P),R=E.node(I),L=M,F=!1;M.lim>R.lim&&(L=R,F=!0);var J=e.filter(C.edges(),function(X){return F===k(E,E.node(X.v),L)&&F!==k(E,E.node(X.w),L)});return e.minBy(J,function(X){return i(C,X)})}function _(E,C,A,P){var I=A.v,M=A.w;E.removeEdge(I,M),E.setEdge(P.v,P.w,{}),m(E),d(E,C),S(E,C)}function S(E,C){var A=e.find(E.nodes(),function(I){return!C.node(I).parent}),P=o(E,A);P=P.slice(1),e.forEach(P,function(I){var M=E.node(I).parent,R=C.edge(I,M),L=!1;R||(R=C.edge(M,I),L=!0),C.node(I).rank=C.node(M).rank+(L?R.minlen:-R.minlen)})}function b(E,C,A){return E.hasEdge(C,A)}function k(E,C,A){return A.low<=C.lim&&C.lim<=A.lim}return Km}var Xm,nk;function CL(){if(nk)return Xm;nk=1;var e=Ru(),n=e.longestPath,i=oC(),s=NL();Xm=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 Xm}var Qm,rk;function TL(){if(rk)return Qm;rk=1;var e=ut();Qm=n;function n(o){var u=s(o);e.forEach(o.graph().dummyChains,function(l){for(var c=o.node(l),d=c.edgeObj,h=i(o,u,d.v,d.w),p=h.path,m=h.lca,y=0,x=p[y],N=!0;l!==d.w;){if(c=o.node(l),N){for(;(x=p[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(N=!1)}if(!N){for(;y<p.length-1&&o.node(x=p[y+1]).minRank<=c.rank;)y++;x=p[y]}o.setParent(l,x),l=o.successors(l)[0]}})}function i(o,u,l,c){var d=[],h=[],p=Math.min(u[l].low,u[c].low),m=Math.max(u[l].lim,u[c].lim),y,x;y=l;do y=o.parent(y),d.push(y);while(y&&(u[y].low>p||m>u[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:d.concat(h.reverse()),lca:x}}function s(o){var u={},l=0;function c(d){var h=l;e.forEach(o.children(d),c),u[d]={low:h,lim:l++}}return e.forEach(o.children(),c),u}return Qm}var Zm,ik;function RL(){if(ik)return Zm;ik=1;var e=ut(),n=un();Zm={run:i,cleanup:l};function i(c){var d=n.addDummyNode(c,"root",{},"_root"),h=o(c),p=e.max(e.values(h))-1,m=2*p+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=u(c)+1;e.forEach(c.children(),function(x){s(c,d,m,y,p,h,x)}),c.graph().nodeRankFactor=m}function s(c,d,h,p,m,y,x){var N=c.children(x);if(!N.length){x!==d&&c.setEdge(d,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(N,function(k){s(c,d,h,p,m,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,A=E.borderBottom?E.borderBottom:k,P=E.borderTop?p:2*p,I=C!==A?1:m-y[x]+1;c.setEdge(_,C,{weight:P,minlen:I,nestingEdge:!0}),c.setEdge(A,S,{weight:P,minlen:I,nestingEdge:!0})}),c.parent(x)||c.setEdge(d,_,{weight:0,minlen:m+y[x]})}function o(c){var d={};function h(p,m){var y=c.children(p);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),d[p]=m}return e.forEach(c.children(),function(p){h(p,1)}),d}function u(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var p=c.edge(h);p.nestingEdge&&c.removeEdge(h)})}return Zm}var Jm,sk;function jL(){if(sk)return Jm;sk=1;var e=ut(),n=un();Jm=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 Jm}var eg,ok;function AL(){if(ok)return eg;ok=1;var e=ut();eg={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 eg}var tg,ak;function IL(){if(ak)return tg;ak=1;var e=ut();tg=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 tg}var ng,uk;function ML(){if(uk)return ng;uk=1;var e=ut();ng=n;function n(s,o){for(var u=0,l=1;l<o.length;++l)u+=i(s,o[l-1],o[l]);return u}function i(s,o,u){for(var l=e.zipObject(u,e.map(u,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:l[x.w],weight:s.edge(x).weight}}),"pos")}),!0),d=1;d<u.length;)d<<=1;var h=2*d-1;d-=1;var p=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+d;p[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=p[x+1]),x=x-1>>1,p[x]+=y.weight;m+=y.weight*N})),m}return ng}var rg,lk;function PL(){if(lk)return rg;lk=1;var e=ut();rg=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 rg}var ig,ck;function OL(){if(ck)return ig;ck=1;var e=ut();ig=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 ig}var sg,fk;function qL(){if(fk)return sg;fk=1;var e=ut(),n=un();sg=i;function i(u,l){var c=n.partition(u,function(_){return e.has(_,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),p=[],m=0,y=0,x=0;d.sort(o(!!l)),x=s(p,h,x),e.forEach(d,function(_){x+=_.vs.length,p.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(p,h,x)});var N={vs:e.flatten(p,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function s(u,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),u.push(d.vs),c++;return c}function o(u){return function(l,c){return l.barycenter<c.barycenter?-1:l.barycenter>c.barycenter?1:u?c.i-l.i:l.i-c.i}}return sg}var og,dk;function LL(){if(dk)return og;dk=1;var e=ut(),n=PL(),i=OL(),s=qL();og=o;function o(c,d,h,p){var m=c.children(d),y=c.node(d),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(A){return A!==x&&A!==N}));var S=n(c,m);e.forEach(S,function(A){if(c.children(A.v).length){var P=o(c,A.v,h,p);_[A.v]=P,e.has(P,"barycenter")&&l(A,P)}});var b=i(S,h);u(b,_);var k=s(b,p);if(x&&(k.vs=e.flatten([x,k.vs,N],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+C.order)/(k.weight+2),k.weight+=2}return k}function u(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(p){return d[p]?d[p].vs:p}),!0)})}function l(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return og}var ag,hk;function $L(){if(hk)return ag;hk=1;var e=ut(),n=Hn().Graph;ag=i;function i(o,u,l){var c=s(o),d=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var p=o.node(h),m=o.parent(h);(p.rank===u||p.minRank<=u&&u<=p.maxRank)&&(d.setNode(h),d.setParent(h,m||c),e.forEach(o[l](h),function(y){var x=y.v===h?y.w:y.v,N=d.edge(x,h),_=e.isUndefined(N)?0:N.weight;d.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(p,"minRank")&&d.setNode(h,{borderLeft:p.borderLeft[u],borderRight:p.borderRight[u]}))}),d}function s(o){for(var u;o.hasNode(u=e.uniqueId("_root")););return u}return ag}var ug,pk;function DL(){if(pk)return ug;pk=1;var e=ut();ug=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 ug}var lg,mk;function FL(){if(mk)return lg;mk=1;var e=ut(),n=IL(),i=ML(),s=LL(),o=$L(),u=DL(),l=Hn().Graph,c=un();lg=d;function d(y){var x=c.maxRank(y),N=h(y,e.range(1,x+1),"inEdges"),_=h(y,e.range(x-1,-1,-1),"outEdges"),S=n(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){p(E%2?N:_,E%4>=2),S=c.buildLayerMatrix(y);var A=i(y,S);A<b&&(C=0,k=e.cloneDeep(S),b=A)}m(y,k)}function h(y,x,N){return e.map(x,function(_){return o(y,_,N)})}function p(y,x){var N=new l;e.forEach(y,function(_){var S=_.graph().root,b=s(_,S,N,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),u(_,N,b.vs)})}function m(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return lg}var cg,gk;function zL(){if(gk)return cg;gk=1;var e=ut(),n=Hn().Graph,i=un();cg={positionX:N,findType1Conflicts:s,findType2Conflicts:o,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(b,k){var E={};function C(A,P){var I=0,M=0,R=A.length,L=e.last(P);return e.forEach(P,function(F,J){var X=u(b,F),j=X?b.node(X).order:R;(X||F===L)&&(e.forEach(P.slice(M,J+1),function(G){e.forEach(b.predecessors(G),function(U){var ne=b.node(U),K=ne.order;(K<I||j<K)&&!(ne.dummy&&b.node(G).dummy)&&l(E,U,G)})}),M=J+1,I=j)}),P}return e.reduce(k,C),E}function o(b,k){var E={};function C(P,I,M,R,L){var F;e.forEach(e.range(I,M),function(J){F=P[J],b.node(F).dummy&&e.forEach(b.predecessors(F),function(X){var j=b.node(X);j.dummy&&(j.order<R||j.order>L)&&l(E,X,F)})})}function A(P,I){var M=-1,R,L=0;return e.forEach(I,function(F,J){if(b.node(F).dummy==="border"){var X=b.predecessors(F);X.length&&(R=b.node(X[0]).order,C(I,L,J,M,R),L=J,M=R)}C(I,L,I.length,R,P.length)}),I}return e.reduce(k,A),E}function u(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(E){return b.node(E).dummy})}function l(b,k,E){if(k>E){var C=k;k=E,E=C}var A=b[k];A||(b[k]=A={}),A[E]=!0}function c(b,k,E){if(k>E){var C=k;k=E,E=C}return e.has(b[k],E)}function d(b,k,E,C){var A={},P={},I={};return e.forEach(k,function(M){e.forEach(M,function(R,L){A[R]=R,P[R]=R,I[R]=L})}),e.forEach(k,function(M){var R=-1;e.forEach(M,function(L){var F=C(L);if(F.length){F=e.sortBy(F,function(U){return I[U]});for(var J=(F.length-1)/2,X=Math.floor(J),j=Math.ceil(J);X<=j;++X){var G=F[X];P[L]===L&&R<I[G]&&!c(E,L,G)&&(P[G]=L,P[L]=A[L]=A[G],R=I[G])}}})}),{root:A,align:P}}function h(b,k,E,C,A){var P={},I=p(b,k,E,A),M=A?"borderLeft":"borderRight";function R(J,X){for(var j=I.nodes(),G=j.pop(),U={};G;)U[G]?J(G):(U[G]=!0,j.push(G),j=j.concat(X(G))),G=j.pop()}function L(J){P[J]=I.inEdges(J).reduce(function(X,j){return Math.max(X,P[j.v]+I.edge(j))},0)}function F(J){var X=I.outEdges(J).reduce(function(G,U){return Math.min(G,P[U.w]-I.edge(U))},Number.POSITIVE_INFINITY),j=b.node(J);X!==Number.POSITIVE_INFINITY&&j.borderType!==M&&(P[J]=Math.max(P[J],X))}return R(L,I.predecessors.bind(I)),R(F,I.successors.bind(I)),e.forEach(C,function(J){P[J]=P[E[J]]}),P}function p(b,k,E,C){var A=new n,P=b.graph(),I=_(P.nodesep,P.edgesep,C);return e.forEach(k,function(M){var R;e.forEach(M,function(L){var F=E[L];if(A.setNode(F),R){var J=E[R],X=A.edge(J,F);A.setEdge(J,F,Math.max(I(b,L,R),X||0))}R=L})}),A}function m(b,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(E,function(P,I){var M=S(b,I)/2;C=Math.max(P+M,C),A=Math.min(P-M,A)}),C-A})}function y(b,k){var E=e.values(k),C=e.min(E),A=e.max(E);e.forEach(["u","d"],function(P){e.forEach(["l","r"],function(I){var M=P+I,R=b[M],L;if(R!==k){var F=e.values(R);L=I==="l"?C-e.min(F):A-e.max(F),L&&(b[M]=e.mapValues(R,function(J){return J+L}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,C){if(k)return b[k.toLowerCase()][C];var A=e.sortBy(e.map(b,C));return(A[1]+A[2])/2})}function N(b){var k=i.buildLayerMatrix(b),E=e.merge(s(b,k),o(b,k)),C={},A;e.forEach(["u","d"],function(I){A=I==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(M){M==="r"&&(A=e.map(A,function(J){return e.values(J).reverse()}));var R=(I==="u"?b.predecessors:b.successors).bind(b),L=d(b,A,E,R),F=h(b,A,L.root,L.align,M==="r");M==="r"&&(F=e.mapValues(F,function(J){return-J})),C[I+M]=F})});var P=m(b,C);return y(C,P),x(C,b.graph().align)}function _(b,k,E){return function(C,A,P){var I=C.node(A),M=C.node(P),R=0,L;if(R+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":L=-I.width/2;break;case"r":L=I.width/2;break}if(L&&(R+=E?L:-L),L=0,R+=(I.dummy?k:b)/2,R+=(M.dummy?k:b)/2,R+=M.width/2,e.has(M,"labelpos"))switch(M.labelpos.toLowerCase()){case"l":L=M.width/2;break;case"r":L=-M.width/2;break}return L&&(R+=E?L:-L),L=0,R}}function S(b,k){return b.node(k).width}return cg}var fg,vk;function BL(){if(vk)return fg;vk=1;var e=ut(),n=un(),i=zL().positionX;fg=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 fg}var dg,yk;function UL(){if(yk)return dg;yk=1;var e=ut(),n=kL(),i=EL(),s=CL(),o=un().normalizeRanks,u=TL(),l=un().removeEmptyRanks,c=RL(),d=jL(),h=AL(),p=FL(),m=BL(),y=un(),x=Hn().Graph;dg=N;function N(z,H){var ee=H&&H.debugTiming?y.time:y.notime;ee("layout",function(){var se=ee(" buildLayoutGraph",function(){return R(z)});ee(" runLayout",function(){_(se,ee)}),ee(" updateInputGraph",function(){S(z,se)})})}function _(z,H){H(" makeSpaceForEdgeLabels",function(){L(z)}),H(" removeSelfEdges",function(){$(z)}),H(" acyclic",function(){n.run(z)}),H(" nestingGraph.run",function(){c.run(z)}),H(" rank",function(){s(y.asNonCompoundGraph(z))}),H(" injectEdgeLabelProxies",function(){F(z)}),H(" removeEmptyRanks",function(){l(z)}),H(" nestingGraph.cleanup",function(){c.cleanup(z)}),H(" normalizeRanks",function(){o(z)}),H(" assignRankMinMax",function(){J(z)}),H(" removeEdgeLabelProxies",function(){X(z)}),H(" normalize.run",function(){i.run(z)}),H(" parentDummyChains",function(){u(z)}),H(" addBorderSegments",function(){d(z)}),H(" order",function(){p(z)}),H(" insertSelfEdges",function(){W(z)}),H(" adjustCoordinateSystem",function(){h.adjust(z)}),H(" position",function(){m(z)}),H(" positionSelfEdges",function(){O(z)}),H(" removeBorderNodes",function(){K(z)}),H(" normalize.undo",function(){i.undo(z)}),H(" fixupEdgeLabelCoords",function(){U(z)}),H(" undoCoordinateSystem",function(){h.undo(z)}),H(" translateGraph",function(){j(z)}),H(" assignNodeIntersects",function(){G(z)}),H(" reversePoints",function(){ne(z)}),H(" acyclic.undo",function(){n.undo(z)})}function S(z,H){e.forEach(z.nodes(),function(ee){var se=z.node(ee),ce=H.node(ee);se&&(se.x=ce.x,se.y=ce.y,H.children(ee).length&&(se.width=ce.width,se.height=ce.height))}),e.forEach(z.edges(),function(ee){var se=z.edge(ee),ce=H.edge(ee);se.points=ce.points,e.has(ce,"x")&&(se.x=ce.x,se.y=ce.y)}),z.graph().width=H.graph().width,z.graph().height=H.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],A={width:0,height:0},P=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},M=["labelpos"];function R(z){var H=new x({multigraph:!0,compound:!0}),ee=ae(z.graph());return H.setGraph(e.merge({},k,B(ee,b),e.pick(ee,E))),e.forEach(z.nodes(),function(se){var ce=ae(z.node(se));H.setNode(se,e.defaults(B(ce,C),A)),H.setParent(se,z.parent(se))}),e.forEach(z.edges(),function(se){var ce=ae(z.edge(se));H.setEdge(se,e.merge({},I,B(ce,P),e.pick(ce,M)))}),H}function L(z){var H=z.graph();H.ranksep/=2,e.forEach(z.edges(),function(ee){var se=z.edge(ee);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(H.rankdir==="TB"||H.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function F(z){e.forEach(z.edges(),function(H){var ee=z.edge(H);if(ee.width&&ee.height){var se=z.node(H.v),ce=z.node(H.w),me={rank:(ce.rank-se.rank)/2+se.rank,e:H};y.addDummyNode(z,"edge-proxy",me,"_ep")}})}function J(z){var H=0;e.forEach(z.nodes(),function(ee){var se=z.node(ee);se.borderTop&&(se.minRank=z.node(se.borderTop).rank,se.maxRank=z.node(se.borderBottom).rank,H=e.max(H,se.maxRank))}),z.graph().maxRank=H}function X(z){e.forEach(z.nodes(),function(H){var ee=z.node(H);ee.dummy==="edge-proxy"&&(z.edge(ee.e).labelRank=ee.rank,z.removeNode(H))})}function j(z){var H=Number.POSITIVE_INFINITY,ee=0,se=Number.POSITIVE_INFINITY,ce=0,me=z.graph(),ve=me.marginx||0,Ae=me.marginy||0;function Ue(Me){var Pe=Me.x,be=Me.y,Fe=Me.width,we=Me.height;H=Math.min(H,Pe-Fe/2),ee=Math.max(ee,Pe+Fe/2),se=Math.min(se,be-we/2),ce=Math.max(ce,be+we/2)}e.forEach(z.nodes(),function(Me){Ue(z.node(Me))}),e.forEach(z.edges(),function(Me){var Pe=z.edge(Me);e.has(Pe,"x")&&Ue(Pe)}),H-=ve,se-=Ae,e.forEach(z.nodes(),function(Me){var Pe=z.node(Me);Pe.x-=H,Pe.y-=se}),e.forEach(z.edges(),function(Me){var Pe=z.edge(Me);e.forEach(Pe.points,function(be){be.x-=H,be.y-=se}),e.has(Pe,"x")&&(Pe.x-=H),e.has(Pe,"y")&&(Pe.y-=se)}),me.width=ee-H+ve,me.height=ce-se+Ae}function G(z){e.forEach(z.edges(),function(H){var ee=z.edge(H),se=z.node(H.v),ce=z.node(H.w),me,ve;ee.points?(me=ee.points[0],ve=ee.points[ee.points.length-1]):(ee.points=[],me=ce,ve=se),ee.points.unshift(y.intersectRect(se,me)),ee.points.push(y.intersectRect(ce,ve))})}function U(z){e.forEach(z.edges(),function(H){var ee=z.edge(H);if(e.has(ee,"x"))switch((ee.labelpos==="l"||ee.labelpos==="r")&&(ee.width-=ee.labeloffset),ee.labelpos){case"l":ee.x-=ee.width/2+ee.labeloffset;break;case"r":ee.x+=ee.width/2+ee.labeloffset;break}})}function ne(z){e.forEach(z.edges(),function(H){var ee=z.edge(H);ee.reversed&&ee.points.reverse()})}function K(z){e.forEach(z.nodes(),function(H){if(z.children(H).length){var ee=z.node(H),se=z.node(ee.borderTop),ce=z.node(ee.borderBottom),me=z.node(e.last(ee.borderLeft)),ve=z.node(e.last(ee.borderRight));ee.width=Math.abs(ve.x-me.x),ee.height=Math.abs(ce.y-se.y),ee.x=me.x+ee.width/2,ee.y=se.y+ee.height/2}}),e.forEach(z.nodes(),function(H){z.node(H).dummy==="border"&&z.removeNode(H)})}function $(z){e.forEach(z.edges(),function(H){if(H.v===H.w){var ee=z.node(H.v);ee.selfEdges||(ee.selfEdges=[]),ee.selfEdges.push({e:H,label:z.edge(H)}),z.removeEdge(H)}})}function W(z){var H=y.buildLayerMatrix(z);e.forEach(H,function(ee){var se=0;e.forEach(ee,function(ce,me){var ve=z.node(ce);ve.order=me+se,e.forEach(ve.selfEdges,function(Ae){y.addDummyNode(z,"selfedge",{width:Ae.label.width,height:Ae.label.height,rank:ve.rank,order:me+ ++se,e:Ae.e,label:Ae.label},"_se")}),delete ve.selfEdges})})}function O(z){e.forEach(z.nodes(),function(H){var ee=z.node(H);if(ee.dummy==="selfedge"){var se=z.node(ee.e.v),ce=se.x+se.width/2,me=se.y,ve=ee.x-ce,Ae=se.height/2;z.setEdge(ee.e,ee.label),z.removeNode(H),ee.label.points=[{x:ce+2*ve/3,y:me-Ae},{x:ce+5*ve/6,y:me-Ae},{x:ce+ve,y:me},{x:ce+5*ve/6,y:me+Ae},{x:ce+2*ve/3,y:me+Ae}],ee.label.x=ee.x,ee.label.y=ee.y}})}function B(z,H){return e.mapValues(e.pick(z,H),Number)}function ae(z){var H={};return e.forEach(z,function(ee,se){H[se.toLowerCase()]=ee}),H}return dg}var hg,wk;function HL(){if(wk)return hg;wk=1;var e=ut(),n=un(),i=Hn().Graph;hg={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 hg}var pg,xk;function VL(){return xk||(xk=1,pg="0.8.5"),pg}var mg,_k;function WL(){return _k||(_k=1,mg={graphlib:Hn(),layout:UL(),debug:HL(),util:{time:un().time,notime:un().notime},version:VL()}),mg}var GL=WL();const Sk=Dg(GL),$i=240,js=130,As=74,el=72,bk=As+el;function YL(e){let n=$i;for(const i of e.values())n=Math.max(n,i.width);return n}const KL=420,XL=2;function tl(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function QL(e,n,i,s,o){const u=new Sk.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)??$i,height:(S==null?void 0:S.height)??js})}for(const _ of n)c.has(_.source)&&c.has(_.target)&&u.setEdge(_.source,_.target);Sk.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)??$i,E=(b==null?void 0:b.height)??js,C=S.x-k/2,A=S.y-E/2;d.set(_,{x:C,y:A}),C<h&&(h=C),A<p&&(p=A),C+k>m&&(m=C+k),A+E>y&&(y=A+E)}if(Number.isFinite(h)&&Number.isFinite(p))for(const[_,S]of d)d.set(_,{x:S.x-h,y:S.y-p});let x=Number.isFinite(m)?m-h:0,N=Number.isFinite(y)?y-p:0;for(const _ of e){const S=o.get(_);if(!S)continue;const b=s.get(_);x=Math.max(x,S.x+((b==null?void 0:b.width)??$i)),N=Math.max(N,S.y+((b==null?void 0:b.height)??js))}return{positions:d,width:x,height:N}}function ZL(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=tl(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,...QL(l.get(S),n,s,u,o)})),h=YL(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+bk;return b},y=S=>S.reduce((b,k)=>Math.max(b,k.width),0)+KL;let x=m(i.availableWidth?XL:1);x.length>1&&x.reduce((b,k)=>b+y(k),0)+h*(x.length-1)>(i.availableWidth??0)&&(x=m(1));const N=new Map;let _=0;for(const S of x){let b=0;for(const{positions:k,height:E}of S){for(const[C,A]of k)N.set(C,{x:A.x+_,y:A.y+b});b+=E+bk}_+=y(S)+h}return e.map(S=>{const b=o.get(S.id);if(b)return{...S,position:b};const k=N.get(S.id);return k?{...S,position:k}:S})}function JL(e,n,i,s){const u=As+el,l=60,c=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??$i,h:(x==null?void 0:x.height)??js}},d=new Map(e.map(y=>[y.id,tl(y)])),h=[],p=e.map(y=>({id:y.id,pos:i.get(y.id)??n.get(y.id)})).filter(y=>y.pos!=null).sort((y,x)=>y.pos.y-x.pos.y||y.pos.x-x.pos.x||y.id.localeCompare(x.id)),m=[];for(const{id:y,pos:x}of p){const{w:N,h:_}=c(y),S=d.get(y)??"_default";if(i.has(y)){h.push({x:x.x,y:x.y,w:N,h:_,sid:S});continue}let b=x.y;for(let k=0;k<h.length+1;k++){const E=h.find(C=>{const A=C.sid===S?24:l,P=C.sid===S?24:u;return x.x<C.x+C.w+A&&C.x<x.x+N+A&&b<C.y+C.h+P&&C.y<b+_+P});if(!E)break;b=E.y+E.h+(E.sid===S?24:u)}b!==x.y&&(n.set(y,{x:x.x,y:b}),m.push(y)),h.push({x:x.x,y:b,w:N,h:_,sid:S})}return m}function e$(e,n,i,s,o){const u=y=>{const x=s.get(y);return{w:(x==null?void 0:x.width)??$i,h:(x==null?void 0:x.height)??js}},l=y=>i.get(y)??n.get(y),c=new Map,d=[];for(const y of e){const x=l(y.id);if(!x)continue;const{w:N,h:_}=u(y.id);if(o.has(y.id)&&!i.has(y.id)){const S=tl(y);(c.get(S)??c.set(S,[]).get(S)).push(y)}else d.push({x:x.x,y:x.y,w:N,h:_})}if(c.size===0)return[];const h=As+el,p=(y,x,N,_)=>d.some(S=>y<S.x+S.w+As&&S.x<y+N+As&&x<S.y+S.h+h&&S.y<x+_+h),m=[];for(const y of[...c.keys()].sort()){const x=c.get(y);let N=1/0,_=1/0,S=-1/0,b=-1/0;for(const M of x){const R=l(M.id),{w:L,h:F}=u(M.id);N=Math.min(N,R.x),_=Math.min(_,R.y),S=Math.max(S,R.x+L),b=Math.max(b,R.y+F)}const k=S-N,E=b-_,C=[...new Set(d.map(M=>Math.round(M.x)))].sort((M,R)=>M-R),A=C.length?C:[N],P=[0,...d.map(M=>M.y+M.h+h)].sort((M,R)=>M-R);let I=null;e:for(const M of A)for(const R of P){if(R>=_)break;if(!p(M,R,k,E)){I={x:M,y:R};break e}}if(I){const M=I.x-N,R=I.y-_;for(const L of x){const F=l(L.id);n.set(L.id,{x:F.x+M,y:F.y+R})}m.push(y)}for(const M of x){const R=l(M.id),{w:L,h:F}=u(M.id);d.push({x:R.x,y:R.y,w:L,h:F})}}return m}function t$(e,n,i,s,o,u=!1){const d=As+el+1,h=8,p=1.75,m=200,y=.7,x=.01,N=I=>{const M=s.get(I);return{w:(M==null?void 0:M.width)??$i,h:(M==null?void 0:M.height)??js}},_=I=>i.get(I)??n.get(I),S=new Map;for(const I of e){if(!_(I.id))continue;const M=tl(I),R=S.get(M);R?R.push(I):S.set(M,[I])}const b=[],k=new Set,E=new Set;for(const I of[...S.keys()].sort()){const M=S.get(I);let R=1/0,L=1/0,F=-1/0,J=-1/0,X=!1;for(const ne of M){const K=_(ne.id),{w:$,h:W}=N(ne.id);R=Math.min(R,K.x),L=Math.min(L,K.y),F=Math.max(F,K.x+$),J=Math.max(J,K.y+W),i.has(ne.id)&&(X=!0)}const j=F-R,G=J-L;E.add(I);const U=o.get(I);U&&(j>U.w+h||G>U.h+h)&&k.add(I),o.set(I,{w:j,h:G}),b.push({sid:I,members:M.map(ne=>ne.id),x:R,y:L,w:j,h:G,anchored:X,mass:1})}for(const I of[...o.keys()])E.has(I)||o.delete(I);if(u||k.size===0)return[];for(const I of b)k.has(I.sid)&&(I.mass=8);const C=new Map(b.map(I=>[I.sid,I.x])),A=new Map(b.map(I=>[I.sid,I.y]));for(let I=0;I<m;I++){const M=new Map,R=new Map;let L=0;for(let F=0;F<b.length;F++)for(let J=F+1;J<b.length;J++){const X=b[F],j=b[J];if(X.anchored&&j.anchored)continue;const G=X.x+X.w/2,U=X.y+X.h/2,ne=j.x+j.w/2,K=j.y+j.h/2,$=(X.w+j.w)/2+61-Math.abs(G-ne),W=(X.h+j.h)/2+d-Math.abs(U-K);if($<=0||W<=0)continue;const O=(Xe,Ke)=>!Xe.anchored&&!(Ke<0&&Xe.x<=0),B=(Xe,Ke)=>!Xe.anchored&&!(Ke<0&&Xe.y<=0),ae=(Xe,Ke,et)=>{const ze=Xe===Ke,qe=ze?X.sid<j.sid?-1:1:Math.sign(Xe-Ke);return et(X,qe)||et(j,-qe)?qe:ze&&(et(X,-qe)||et(j,qe))?-qe:0},z=ae(G,ne,O),H=ae(U,K,B),ee=z!==0,se=H!==0;if(!ee&&!se)continue;const ce=ee&&(!se||$*p<W),[me,ve,Ae,Ue]=ce?[z,$,M,O]:[H,W,R,B],Me=Ue(X,me),Pe=Ue(j,-me),be=X.mass,Fe=j.mass,we=Me?Pe?Fe/(be+Fe):1:0,xe=Pe?Me?be/(be+Fe):1:0,De=ve*y;Ae.set(X.sid,(Ae.get(X.sid)??0)+me*De*we),Ae.set(j.sid,(Ae.get(j.sid)??0)-me*De*xe),L+=De}for(const F of b)F.anchored||(F.x=Math.max(0,F.x+(M.get(F.sid)??0)),F.y=Math.max(0,F.y+(R.get(F.sid)??0)));if(L<x)break}const P=[];for(const I of b){const M=I.x-C.get(I.sid),R=I.y-A.get(I.sid);if(!(Math.abs(M)<1&&Math.abs(R)<1)){for(const L of I.members){if(i.has(L))continue;const F=n.get(L);F&&n.set(L,{x:F.x+M,y:F.y+R})}P.push(I.sid)}}return P}const n$=600;function qg(e,n){return!(e.exitAt!=null&&n-e.exitAt>n$||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function r$(e,n){const i=new Set;for(const s of e.agents.values())qg(s,n)&&i.add(s.id);return i}function Ii(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function i$(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const s$={agent:xP,sessionGroup:AP},o$=420,hu=18,a$=9e4,u$=200,l$=5*6e4,c$=6,f$=2*6e4,kv="agent-dag.layout",Ev="agent-dag.viewport",aC="agent-dag.summariesDismissed",uC="agent-dag.sessionListOpen",lC="agent-dag.detailOpen",cC="agent-dag.usagePanelOpen",kk="agent-dag.accountsPanelOpen",Ek="agent-dag.versionNoticeDismissed";function d$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(uC)==="1"}catch{return!1}}function h$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(uC,e?"1":"0")}catch{}}function p$(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(lC)==="1"}catch{return!1}}function m$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(lC,e?"1":"0")}catch{}}function g$(){if(typeof window>"u")return!0;const e=window.localStorage.getItem(cC);try{return e===null?!0:e==="1"}catch{return!0}}function v$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(cC,e?"1":"0")}catch{}}function y$(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(aC);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 Nk(e){if(!(typeof window>"u"))try{const n=Array.from(e),i=n.length>200?n.slice(-200):n;window.localStorage.setItem(aC,JSON.stringify(i))}catch{}}function w$(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(kv);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 gg(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(kv,JSON.stringify({v:2,positions:i,pins:Array.from(n.keys())}))}catch{}}function x$(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ev);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 _$(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ev,JSON.stringify(e))}catch{}}function Ck(){if(!(typeof window>"u")){try{window.localStorage.removeItem(kv)}catch{}try{window.localStorage.removeItem(Ev)}catch{}}}function S$(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 Lg={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},$g={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},b$={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 fC(e){return e.startsWith("mcp__")?"mcp":b$[e]??"other"}function dC(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 k$(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 E$(e,n,i,s,o,u,l,c,d,h,p,m,y,x,N,_,S,b){const k=[],E=[],C=new Set;if(u)for(const R of e.agents.values())dC(R,u)&&C.add(R.id);for(const R of e.agents.values()){if(!S.has(R.id))continue;const L=u?!C.has(R.id):!1,F=R.exitAt!=null,J=_!=null&&!_.has(R.id),X=[L?"rf-dim":"",F?"rf-exiting":"",J?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,j=l.get(R.id);if(k.push({id:R.id,type:"agent",position:{x:0,y:0},data:{...R,now:n,dim:L,onOpenContext:b},className:X,...j?{width:j.width,height:j.height}:null}),R.parentId&&S.has(R.parentId)){const G=iv(R.sessionId),U=R.state==="active"?`hsl(${G} 80% 72%)`:`hsl(${G} 50% 55%)`,ne=u&&!C.has(R.id)&&!C.has(R.parentId),K=F,$=N.size>0&&(N.has(R.id)||N.has(R.parentId)),W=_!=null&&!_.has(R.id)&&!_.has(R.parentId),O=R.state==="active"?2:1.5,B=$?O+1.5:O,ae=ne||K?.2:W?.12:1,z=[K?"rf-edge-exiting":"",$?"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"||$)&&!ne&&!K,type:"smoothstep",style:{stroke:U,strokeWidth:B,opacity:ae,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:z})}}const A=k.filter(R=>!o.has(R.id)&&!m.has(R.id));if(A.length>0||y!==x.current){if(A.length>0){const R=ZL(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);e$(k,m,o,l,new Set(A.map(L=>L.id)))}JL(k,m,o,l),x.current=y}const P=t$(k,m,o,l,c,!h||p);P.length>0&&d(P);for(const R of Array.from(m.keys()))e.agents.has(R)||m.delete(R);if(e.agents.size>0)for(const R of Array.from(o.keys()))e.agents.has(R)||o.delete(R);const I=[];let M=!1;for(const R of k){let L=o.get(R.id)??m.get(R.id);L||(L={x:0,y:0},m.set(R.id,L),M=!0),I.push({...R,position:L})}return M&&(x.current=""),{nodes:I,edges:E}}function N$(){return v.jsx(nv,{children:v.jsx(C$,{})})}function C$(){const e=Ho(),n=q.useRef(Mg()),[,i]=q.useState(0),s=q.useCallback(()=>i(Q=>Q+1),[]),[o,u]=q.useState(()=>new Set),[l,c]=q.useState(null),[d,h]=q.useState(null),p=q.useCallback((Q,Z)=>{u(ue=>{if(!Z)return new Set([Q]);const de=new Set(ue);return de.has(Q)?de.delete(Q):de.add(Q),de}),c(ue=>Z&&ue===Q?ue:Q)},[]),m=q.useCallback(()=>{u(new Set),c(null)},[]),[y,x]=q.useState(null),[N,_]=q.useState(null),S=q.useCallback(Q=>_(Q),[]),b=q.useRef(y$()),[k,E]=q.useState(d$);q.useEffect(()=>{h$(k)},[k]);const[C,A]=q.useState(p$);q.useEffect(()=>{m$(C)},[C]);const[P,I]=q.useState(g$);q.useEffect(()=>{v$(P)},[P]);const[M,R]=q.useState(()=>{try{const Q=window.localStorage.getItem(kk);return Q===null?!0:Q==="1"}catch{return!0}});q.useEffect(()=>{try{window.localStorage.setItem(kk,M?"1":"0")}catch{}},[M]);const[L,F]=q.useState(null),[J,X]=q.useState(!1),[j,G]=q.useState(0),[U,ne]=q.useState(0);q.useEffect(()=>{fetch("/api/sound-hook").then(Q=>Q.ok?Q.json():null).then(Q=>{Q!=null&&Q.ok&&(F(Q.enabled===!0),G((Q.foreign??[]).filter(Z=>Z.worksHere).length),ne(typeof Q.parked=="number"?Q.parked:0))}).catch(()=>{})},[]);const K=q.useCallback(async()=>{X(!0);try{const Z=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!L})})).json().catch(()=>null);Z!=null&&Z.ok&&F(Z.enabled===!0),fetch("/api/sound-hook").then(ue=>ue.ok?ue.json():null).then(ue=>{ue!=null&&ue.ok&&(G((ue.foreign??[]).filter(de=>de.worksHere).length),ne(typeof ue.parked=="number"?ue.parked:0))}).catch(()=>{})}catch{}finally{X(!1)}},[L]),[$,W]=q.useState(null),[O,B]=q.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Ek)??""}catch{return""}}),[ae,z]=q.useState(!1);q.useEffect(()=>{let Q=!0;const Z=()=>{fetch("/api/version").then(ge=>ge.ok?ge.json():null).then(ge=>{Q&&ge&&W(ge)}).catch(()=>{})};Z();const ue=window.setInterval(Z,5*6e4),de=()=>{document.visibilityState==="visible"&&Z()};return document.addEventListener("visibilitychange",de),()=>{Q=!1,window.clearInterval(ue),document.removeEventListener("visibilitychange",de)}},[]);const H=($==null?void 0:$.notice)??null,ee=H?`${H.kind}:${H.to}`:"",se=H!=null&&O!==ee,ce=q.useCallback(()=>{if(!H)return;const Q=O===ee?"":ee;B(Q);try{window.localStorage.setItem(Ek,Q)}catch{}},[H,ee,O]),me=q.useCallback(async()=>{var ue;const Q=$==null?void 0:$.command;if(!Q)return;let Z=!1;try{Z=await Promise.race([((ue=navigator.clipboard)==null?void 0:ue.writeText(Q).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{Z=!1}if(!Z)try{const de=document.createElement("textarea");de.value=Q,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),Z=document.execCommand("copy"),de.remove()}catch{Z=!1}Z&&(z(!0),window.setTimeout(()=>z(!1),1600))},[$==null?void 0:$.command]),ve=q.useCallback(()=>{E(Q=>(Q||R(!1),!Q))},[]),Ae=q.useCallback(()=>{R(Q=>(Q||E(!1),!Q))},[]),[Ue,Me]=q.useState(!1),[Pe,be]=q.useState(0),Fe=q.useRef(null),[we,xe]=q.useState(0),[De,Xe]=q.useState(!1),[Ke,et]=q.useState(!1),ze=q.useRef([]),[qe,qt]=q.useState(Date.now()),Lt=q.useRef(w$()).current;q.useRef(!1);const Ze=q.useRef(new Map(Lt.positions.filter(([Q])=>Lt.pins.includes(Q)))),lt=q.useRef(null),At=q.useState(()=>x$())[0],[ht,tt]=q.useState(""),[_t,gt]=q.useState(()=>new Set),[ot,gn]=q.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[$t,Dt]=q.useState(!1),vn=q.useRef(null);q.useEffect(()=>{document.documentElement.dataset.theme=ot;try{window.localStorage.setItem("agent-dag.theme",ot)}catch{}},[ot]),q.useEffect(()=>{if(!At)return;const Q=window.setTimeout(()=>{try{e.setViewport(At,{duration:0})}catch{}},60);return()=>window.clearTimeout(Q)},[e,At]);const Gn=q.useRef(!0),ct=q.useRef(null);q.useEffect(()=>{const Q=new EventSource("/events");return Q.addEventListener("open",()=>{Xe(!0),Dt(!0)}),Q.addEventListener("error",()=>Xe(!1)),Q.addEventListener("replay-end",()=>{Gn.current=!1,ct.current!=null&&(window.clearTimeout(ct.current),ct.current=null),s()}),Q.addEventListener("hook",Z=>{try{const ue=JSON.parse(Z.data);if(Ke){ze.current.push(ue);return}n.current=Uw(n.current,ue),ue.replay===!0||Gn.current||Date.now()-ue.receivedAt>3e4?(ct.current!=null&&window.clearTimeout(ct.current),ct.current=window.setTimeout(()=>{ct.current=null,s()},120)):(ct.current!=null&&(window.clearTimeout(ct.current),ct.current=null),s())}catch{}}),()=>{Q.close(),ct.current!=null&&(window.clearTimeout(ct.current),ct.current=null)}},[Ke,s]),q.useEffect(()=>{if(!Ke&&ze.current.length!==0){for(const Q of ze.current)n.current=Uw(n.current,Q);ze.current.length=0,s()}},[Ke,s]),q.useEffect(()=>{const Q=setInterval(()=>{const Z=Date.now();qt(Z);let ue=iP(n.current,Z,a$);nP(n.current,Z,u$,l$)&&(ue=!0),rP(n.current,Z,c$,f$)&&(ue=!0),ue&&s()},250);return()=>clearInterval(Q)},[s]);const Xt=q.useRef(null),Ft=q.useRef(0),yn=420,Vt=q.useCallback((Q=500)=>{try{const _e=document.querySelector(".canvas-wrap"),Ie=Array.from(document.querySelectorAll(".react-flow__node")).filter(yt=>yt.offsetWidth>0);if(!_e||Ie.length===0)return;const Oe=_e.getBoundingClientRect(),Be=e.getViewport();if(!Number.isFinite(Be.zoom)||Be.zoom<=0)return;const Ge=yt=>(yt-Oe.left-Be.x)/Be.zoom,Je=yt=>(yt-Oe.top-Be.y)/Be.zoom,St=Ie.map(yt=>yt.getBoundingClientRect()),vi=Math.min(...St.map(yt=>Ge(yt.left))),Qi=Math.max(...St.map(yt=>Ge(yt.right))),Mn=Math.min(...St.map(yt=>Je(yt.top))),Us=Math.max(...St.map(yt=>Je(yt.bottom))),Hs=Qi-vi,fr=Us-Mn;if(!(Hs>0&&fr>0))return;const xn=Math.max(.2,Math.min(1,(Oe.width-160)/(Hs+yn)*.86,(Oe.height-160)/fr*.86));e.setViewport({x:80-vi*xn,y:Math.max(80,(Oe.height-fr*xn)/2)-Mn*xn,zoom:xn},{duration:Q}),Ft.current=Date.now(),window.setTimeout(()=>{try{const yt={x:80-vi*xn,y:Math.max(80,(Oe.height-fr*xn)/2)-Mn*xn,zoom:xn},Lr=e.getViewport();(Math.abs(Lr.zoom-xn)>.01||Math.abs(Lr.x-yt.x)>2)&&e.setViewport(yt,{duration:0})}catch{}},Q+60)}catch{}},[e]),Tr=q.useRef(""),Rr=q.useRef(null),oi=q.useRef(0),Yn=q.useCallback(()=>{oi.current=Date.now()},[]),jr="agent-dag.autoFitDisabled",Wt=q.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(jr)==="1"}catch{return!1}})()),[Ar,Kn]=q.useState(Wt.current),Vi=q.useCallback(()=>{if(!Wt.current){Wt.current=!0,Kn(!0);try{window.localStorage.setItem(jr,"1")}catch{}}},[]),ar=q.useCallback(()=>{Wt.current=!1,Kn(!1);try{window.localStorage.removeItem(jr)}catch{}Vt(400)},[e,Vt]);q.useEffect(()=>{const Q=setInterval(()=>{if(Wt.current||Date.now()-oi.current<800)return;const Z=n.current,ue=Date.now(),de=[];for(const Ge of Z.agents.values())qg(Ge,ue)&&de.push({id:Ge.id});if(de.length===0)return;const ge=e.getViewport(),_e=window.innerWidth-360,Ie=window.innerHeight-52;let Oe=!1,Be=!1;for(const{id:Ge}of de){const Je=ln.current.get(Ge),St=Ze.current.get(Ge)??It.current.get(Ge);if(!Je||!St)continue;Be=!0;const vi=St.x*ge.zoom+ge.x,Qi=St.y*ge.zoom+ge.y,Mn=(St.x+Je.width)*ge.zoom+ge.x,Us=(St.y+Je.height)*ge.zoom+ge.y;if(Mn>0&&vi<_e&&Us>0&&Qi<Ie){Oe=!0;break}}Be&&!Oe&&Vt(600)},1500);return()=>clearInterval(Q)},[e]);const Xn=q.useRef(!1),ln=q.useRef(new Map),Ir=q.useRef(0),zs=q.useCallback(Q=>{const Z=ln.current;let ue=!1;for(const de of Q.nodeInternals.values()){const ge=de.width,_e=de.height;if(ge==null||_e==null)continue;const Ie=Z.get(de.id);Ie?(Math.abs(Ie.height-_e)>4||Math.abs(Ie.width-ge)>4)&&(Z.set(de.id,{width:ge,height:_e}),ue=!0):(Z.set(de.id,{width:ge,height:_e}),ue=!0)}return ue&&(Ir.current+=1),Ir.current},[]),Wi=Qe(zs),[ai,In]=q.useState(0);q.useEffect(()=>{let Q=0;const Z=()=>{const de=ln.current;let ge=!1;for(const _e of document.querySelectorAll(".react-flow__node[data-id]")){const Ie=_e.getAttribute("data-id");if(!Ie)continue;const Oe=_e.offsetWidth,Be=_e.offsetHeight;if(!Oe||!Be)continue;const Ge=de.get(Ie);(!Ge||Math.abs(Ge.width-Oe)>4||Math.abs(Ge.height-Be)>4)&&(de.set(Ie,{width:Oe,height:Be}),ge=!0)}ge&&In(_e=>_e+1)};if(Xn.current)return;let ue=0;return document.visibilityState==="hidden"?ue=window.setTimeout(Z,32):Q=requestAnimationFrame(Z),()=>{cancelAnimationFrame(Q),window.clearTimeout(ue)}});const It=q.useRef(new Map(Lt.positions)),Mr=q.useRef(""),Qn=q.useMemo(()=>{const Q=[];for(const Z of n.current.agents.values())qg(Z,qe)&&Q.push(Z.id+(Z.parentId?`>${Z.parentId}`:""));return Q.sort(),`${Q.join("|")}#sv${Wi}.${ai}`},[n.current,n.current.lastSeq,qe,Wi,ai]),Zn=q.useRef(null);q.useEffect(()=>(Zn.current!=null&&window.clearTimeout(Zn.current),Zn.current=window.setTimeout(()=>{gg(It.current,Ze.current)},1500),()=>{Zn.current!=null&&window.clearTimeout(Zn.current)}),[Qn]),q.useEffect(()=>{if(Tr.current===Qn)return;const Q=Tr.current;if(Tr.current=Qn,!Q||Wt.current)return;Date.now()-Ft.current>1200&&Vt(400),Xt.current&&window.clearTimeout(Xt.current),Xt.current=window.setTimeout(()=>{Wt.current||Vt(500)},280)},[Qn,e,Vt]);const Pr=q.useMemo(()=>{if(o.size===0)return null;const Q=new Set;for(const Z of o){const ue=k$(n.current,Z);if(ue)for(const de of ue)Q.add(de)}return Q.size>0?Q:null},[n.current,n.current.lastSeq,o]),Or=q.useMemo(()=>r$(n.current,qe),[n.current,n.current.lastSeq,qe]),ui=q.useRef(null),[ur,Gi]=q.useState({w:0,h:0});q.useEffect(()=>{const Q=ui.current;if(!Q||typeof ResizeObserver>"u")return;const Z=new ResizeObserver(ue=>{var ge;const de=(ge=ue[0])==null?void 0:ge.contentRect;de&&Gi(_e=>Math.abs(_e.w-de.width)>40||Math.abs(_e.h-de.height)>40?{w:de.width,h:de.height}:_e)});return Z.observe(Q),Gi({w:Q.clientWidth,h:Q.clientHeight}),()=>Z.disconnect()},[]);const rt=q.useRef(new Map),[Yi,li]=q.useState(!1);q.useEffect(()=>{const Q=window.setTimeout(()=>li(!0),2500);return()=>window.clearTimeout(Q)},[]);const[Ki,Jn]=q.useState(!1),cn=q.useRef(null),[qr,lr]=q.useState(!1),Qt=q.useCallback(()=>{cn.current&&(window.clearTimeout(cn.current),cn.current=null),Jn(!1)},[]),ci=q.useCallback(Q=>{Q.length!==0&&queueMicrotask(()=>{Jn(!0),cn.current&&window.clearTimeout(cn.current),cn.current=window.setTimeout(()=>Jn(!1),o$+80)})},[]);q.useEffect(()=>()=>{cn.current&&window.clearTimeout(cn.current)},[]);const Zt=ur.w>0?ur.w*.92:0,Qo=ur.h>0?ur.h:0,{nodes:wn,edges:nl}=q.useMemo(()=>E$(n.current,qe,Zt,Qo,Ze.current,ht,ln.current,rt.current,ci,Yi,qr,It.current,Qn,Mr,o,Pr,Or,S),[n.current,n.current.lastSeq,qe,Zt,Qo,Yi,qr,ht,Qn,o,Pr,Or,S,Pe]),fi=q.useMemo(()=>{const Q=new Map;for(const ue of wn){const de=ue.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const ge=ue.width,_e=ue.height;if(ge==null||_e==null)continue;const Ie=ue.position.x,Oe=ue.position.y,Be=Ie+ge,Ge=Oe+_e,Je=Q.get(de.sessionId);Je?(Je.minX=Math.min(Je.minX,Ie),Je.minY=Math.min(Je.minY,Oe),Je.maxX=Math.max(Je.maxX,Be),Je.maxY=Math.max(Je.maxY,Ge)):Q.set(de.sessionId,{minX:Ie,minY:Oe,maxX:Be,maxY:Ge})}const Z=[];for(const[ue,de]of Q){const ge=de.maxX-de.minX+hu*2,_e=de.maxY-de.minY+hu*2;Z.push({id:`group:${ue}`,type:"sessionGroup",position:{x:de.minX-hu,y:de.minY-hu},data:{sessionId:ue,w:ge,h:_e},width:ge,height:_e,style:{width:ge,height:_e},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Z},[wn,qe]),Xi=q.useMemo(()=>{const Q=[...fi,...wn],Z=Fe.current;return!Z||Z.size===0?Q:Q.map(ue=>{const de=Z.get(ue.id);return de?{...ue,position:de}:ue})},[fi,wn,we]),di=q.useMemo(()=>{if(!ht)return null;const Q=new Set;for(const Z of n.current.agents.values())dC(Z,ht)&&Q.add(Z.id);return Q},[n.current,n.current.lastSeq,ht]),hi=q.useMemo(()=>{const Q=new Set;for(const Z of n.current.agents.values())for(const ue of Z.tools)Q.add(fC(ue.name));return Object.keys(Lg).filter(Z=>Q.has(Z))},[n.current,n.current.lastSeq]),pi=q.useMemo(()=>{const Q=new Map;for(const ue of n.current.agents.values())for(const de of ue.tools){if(!de.name.startsWith("mcp__"))continue;const ge=de.name.slice(5),_e=ge.indexOf("__"),Ie=_e>0?ge.slice(0,_e):ge;Q.set(Ie,(Q.get(Ie)??0)+1)}const Z=[];for(const[ue,de]of Q){let ge=5381;for(let _e=0;_e<ue.length;_e++)ge=(ge<<5)+ge^ue.charCodeAt(_e);Z.push({server:ue,count:de,hue:Math.abs(ge)%360})}return Z.sort((ue,de)=>de.count-ue.count),Z},[n.current,n.current.lastSeq]),rl=q.useCallback(Q=>{gt(Z=>{const ue=new Set(Z);return ue.has(Q)?ue.delete(Q):ue.add(Q),ue})},[]),Ct=l?n.current.agents.get(l):null,Bs=d?Array.from(n.current.agents.values()).flatMap(Q=>Q.tools).find(Q=>Q.id===d)??null:null,mi=q.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Mg(),Ze.current.clear(),ln.current.clear(),It.current.clear(),Mr.current="",Ck(),m(),s()},[s,m]),cr=q.useCallback(()=>{Ze.current.clear(),It.current.clear(),Mr.current="",Ck(),s(),window.setTimeout(()=>Vt(500),80)},[s,e,Vt]),Zo=q.useCallback(()=>Vt(500),[Vt]),gi=q.useCallback(Q=>{if(wn.length===0)return;const Z=wn.slice().sort((_e,Ie)=>_e.position.y-Ie.position.y||_e.position.x-Ie.position.x),ue=l?Z.findIndex(_e=>_e.id===l):-1;let de;ue===-1?de=Q===1?0:Z.length-1:de=(ue+Q+Z.length)%Z.length;const ge=Z[de];ge&&(p(ge.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[ge]})}catch{}Ft.current=Date.now()},30))},[wn,l,p,e]);q.useEffect(()=>{const Q=Z=>{var de,ge;const ue=((de=Z.target)==null?void 0:de.tagName)==="INPUT";if(Z.key==="Escape"){ue?Z.target.blur():m();return}if(!ue){if(Z.key==="/"){Z.preventDefault(),(ge=vn.current)==null||ge.focus();return}Z.key===" "&&(Z.preventDefault(),et(_e=>!_e)),(Z.key==="c"||Z.key==="C")&&mi(),(Z.key==="r"||Z.key==="R")&&cr(),(Z.key==="f"||Z.key==="F")&&Zo(),(Z.key==="l"||Z.key==="L")&&ve(),(Z.key==="h"||Z.key==="H")&&Me(_e=>!_e),(Z.key==="u"||Z.key==="U")&&I(_e=>!_e),(Z.key==="a"||Z.key==="A")&&Ae(),(Z.key==="j"||Z.key==="J")&&gi(1),(Z.key==="k"||Z.key==="K")&&gi(-1),(Z.key==="t"||Z.key==="T")&&gn(_e=>_e==="dark"?"light":"dark")}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[mi,cr,Zo,m,gi]);const He=n.current.agents.size,Jo=new Set(Array.from(n.current.agents.values()).map(Q=>Q.sessionId)).size,Gt=q.useMemo(()=>{let Q=0,Z=0,ue=0,de=0,ge=0,_e=0,Ie=0,Oe=0,Be=0;for(const Ge of n.current.agents.values()){Q+=Ge.usage.inputTokens,Z+=Ge.usage.outputTokens,ue+=Ge.usage.cacheReadTokens,de+=Ge.usage.cacheCreateTokens;const Je=an(Ge.usage,Ge.model);ge+=Je.total,_e+=Je.input,Ie+=Je.output,Oe+=Je.cacheRead,Be+=Je.cacheWrite}return{inT:Q,outT:Z,cacheR:ue,cacheC:de,sum:Q+Z,cost:{total:ge,input:_e,output:Ie,cacheRead:Oe,cacheWrite:Be}}},[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",H?v.jsxs("button",{type:"button",className:"v stale",onClick:ce,title:H.kind==="restart"?`Running v${H.from}; v${H.to} is installed on disk. Restart to pick it up.`:`Running v${H.from}; v${H.to} is on npm.`,children:["v",H.from,v.jsx("span",{className:"v-dot","aria-hidden":!0})]}):v.jsxs("span",{className:"v",children:["v",($==null?void 0:$.running)??"1.30.9"]})]}),Ct&&(()=>{const Q=an(Ct.usage,Ct.model),Z=Math.max(0,((Ct.endedAt??qe)-Ct.startedAt)/1e3),ue=Ct.state==="active"?Tu(Q.total,Z):null,de=o.size-1;return v.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Ct.label}`,onClick:()=>{try{const ge=wn.find(_e=>_e.id===Ct.id);ge&&e.fitView({padding:.35,duration:500,nodes:[ge]}),Ft.current=Date.now()}catch{}},children:[v.jsx("span",{className:`state-pill state-${Ct.state}`,children:Ct.state==="active"?"live":Ct.state}),v.jsx("span",{className:"selected-label",children:Ct.label}),Q.total>0&&v.jsxs("span",{className:"selected-cost",children:[We(Q.total),ue?v.jsxs("span",{className:"selected-rate",children:[" · ",ue]}):null]}),de>0&&v.jsxs("span",{className:"selected-extra",children:["+",de]}),v.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:ge=>{ge.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:vn,type:"text",placeholder:"Search agents, cwd, tools…",value:ht,onChange:Q=>tt(Q.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),ht?v.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>tt(""),children:"×"}):v.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),v.jsxs("span",{className:"status",role:"status",children:[v.jsx("span",{className:`pill ${De?"live":"dead"}`,title:De?"Receiving events":"SSE disconnected",children:De?"live":"offline"}),v.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[v.jsx("span",{className:"count",children:Jo}),v.jsx("span",{className:"lbl",children:"sessions"})]}),v.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[v.jsx("span",{className:"count",children:He}),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"})]}),Gt.sum>0&&v.jsxs("span",{className:"stat",title:`in:${Gt.inT.toLocaleString()} out:${Gt.outT.toLocaleString()} cache-r:${Gt.cacheR.toLocaleString()} cache-c:${Gt.cacheC.toLocaleString()}`,children:[v.jsx("span",{className:"count",children:i$(Gt.sum)}),v.jsx("span",{className:"lbl",children:"tokens"})]}),pi.length>0&&v.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
60
60
  ${pi.map(Q=>` ${Q.server}: ${Q.count} call${Q.count===1?"":"s"}`).join(`
61
61
  `)}`,children:[pi.slice(0,6).map(Q=>v.jsx("span",{className:"mcp-dot",style:{background:`hsl(${Q.hue} 65% 65%)`}},Q.server)),pi.length>6&&v.jsxs("span",{className:"mcp-more",children:["+",pi.length-6]}),v.jsx("span",{className:"lbl",children:"mcp"})]}),Gt.cost.total>0&&(()=>{let Q=0,Z=0;for(const ge of n.current.agents.values()){if(ge.state!=="active")continue;const _e=an(ge.usage,ge.model);Q+=_e.total,Z=Math.max(Z,((ge.endedAt??qe)-ge.startedAt)/1e3)}const ue=Z>0?Tu(Q,Z):null,de=`input ${We(Gt.cost.input)} + output ${We(Gt.cost.output)} + cache r ${We(Gt.cost.cacheRead)} + cache w ${We(Gt.cost.cacheWrite)}${ue?`
62
62
  active burn: ${ue}`:""}`;return v.jsxs("span",{className:"stat",title:de,children:[v.jsx("span",{className:"count",children:We(Gt.cost.total)}),v.jsxs("span",{className:"lbl",children:["cost",ue?` · ${ue}`:""]})]})})()]}),v.jsx("button",{className:`btn ${Ke?"warn":""}`,onClick:()=>et(Q=>!Q),title:"Pause/resume live updates (Space)",children:Ke?`Resume${ze.current.length?` · ${ze.current.length}`:""}`:"Pause"}),v.jsx("button",{className:`btn icon-btn ${P?"primary":""}`,onClick:()=>I(Q=>!Q),title:`${P?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel",children:"$"}),L!==null&&v.jsx("button",{className:`btn icon-btn ${L?"primary":""}`,onClick:Q=>{if(Q.shiftKey&&U>0){X(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(Z=>Z.ok?Z.json():null).then(Z=>{Z!=null&&Z.ok&&(F(Z.enabled===!0),ne(Z.parked??0))}).catch(()=>{}).finally(()=>X(!1));return}K()},disabled:J,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?`