agent-dag 1.15.4 → 1.15.5

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.
@@ -54,9 +54,9 @@ Error generating stack: `+y.message+`
54
54
  * This source code is licensed under the MIT license found in the
55
55
  * LICENSE file in the root directory of this source tree.
56
56
  */var A0;function O2(){if(A0)return ac;A0=1;var e=Qo(),r=q2();function i(p,h){return p===h&&(p!==0||1/p===1/h)||p!==p&&h!==h}var o=typeof Object.is=="function"?Object.is:i,s=r.useSyncExternalStore,u=e.useRef,l=e.useEffect,c=e.useMemo,d=e.useDebugValue;return ac.useSyncExternalStoreWithSelector=function(p,h,v,g,w){var N=u(null);if(N.current===null){var _={hasValue:!1,value:null};N.current=_}else _=N.current;N=c(function(){function x(j){if(!k){if(k=!0,T=j,j=g(j),w!==void 0&&_.hasValue){var M=_.value;if(w(M,j))return C=M}return C=j}if(M=C,o(T,j))return M;var z=g(j);return w!==void 0&&w(M,z)?(T=j,M):(T=j,C=z)}var k=!1,T,C,A=v===void 0?null:v;return[function(){return x(h())},A===null?void 0:function(){return x(A())}]},[h,v,g,w]);var E=s(p,N[0],N[1]);return l(function(){_.hasValue=!0,_.value=E},[E]),d(E),E},ac}var I0;function L2(){return I0||(I0=1,sc.exports=O2()),sc.exports}var $2=L2();const D2=lv($2),F2={},j0=e=>{let r;const i=new Set,o=(h,v)=>{const g=typeof h=="function"?h(r):h;if(!Object.is(g,r)){const w=r;r=v??(typeof g!="object"||g===null)?g:Object.assign({},r,g),i.forEach(N=>N(r,w))}},s=()=>r,d={setState:o,getState:s,getInitialState:()=>p,subscribe:h=>(i.add(h),()=>i.delete(h)),destroy:()=>{(F2?"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()}},p=r=e(o,s,d);return d},z2=e=>e?j0(e):j0,{useDebugValue:B2}=ie,{useSyncExternalStoreWithSelector:U2}=D2,H2=e=>e;function ok(e,r=H2,i){const o=U2(e.subscribe,e.getState,e.getServerState||e.getInitialState,r,i);return B2(o),o}const M0=(e,r)=>{const i=z2(e),o=(s,u=r)=>ok(i,s,u);return Object.assign(o,i),o},V2=(e,r)=>e?M0(e,r):M0;function wt(e,r){if(Object.is(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(const[o,s]of e)if(!Object.is(s,r.get(o)))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(const o of e)if(!r.has(o))return!1;return!0}const i=Object.keys(e);if(i.length!==Object.keys(r).length)return!1;for(const o of i)if(!Object.prototype.hasOwnProperty.call(r,o)||!Object.is(e[o],r[o]))return!1;return!0}var W2={value:()=>{}};function Ka(){for(var e=0,r=arguments.length,i={},o;e<r;++e){if(!(o=arguments[e]+"")||o in i||/[\s.]/.test(o))throw new Error("illegal type: "+o);i[o]=[]}return new Ma(i)}function Ma(e){this._=e}function G2(e,r){return e.trim().split(/^|\s+/).map(function(i){var o="",s=i.indexOf(".");if(s>=0&&(o=i.slice(s+1),i=i.slice(0,s)),i&&!r.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:o}})}Ma.prototype=Ka.prototype={constructor:Ma,on:function(e,r){var i=this._,o=G2(e+"",i),s,u=-1,l=o.length;if(arguments.length<2){for(;++u<l;)if((s=(e=o[u]).type)&&(s=K2(i[s],e.name)))return s;return}if(r!=null&&typeof r!="function")throw new Error("invalid callback: "+r);for(;++u<l;)if(s=(e=o[u]).type)i[s]=P0(i[s],e.name,r);else if(r==null)for(s in i)i[s]=P0(i[s],e.name,null);return this},copy:function(){var e={},r=this._;for(var i in r)e[i]=r[i].slice();return new Ma(e)},call:function(e,r){if((s=arguments.length-2)>0)for(var i=new Array(s),o=0,s,u;o<s;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(u=this._[e],o=0,s=u.length;o<s;++o)u[o].value.apply(r,i)},apply:function(e,r,i){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],s=0,u=o.length;s<u;++s)o[s].value.apply(r,i)}};function K2(e,r){for(var i=0,o=e.length,s;i<o;++i)if((s=e[i]).name===r)return s.value}function P0(e,r,i){for(var o=0,s=e.length;o<s;++o)if(e[o].name===r){e[o]=W2,e=e.slice(0,o).concat(e.slice(o+1));break}return i!=null&&e.push({name:r,value:i}),e}var Fm="http://www.w3.org/1999/xhtml";const q0={svg:"http://www.w3.org/2000/svg",xhtml:Fm,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ya(e){var r=e+="",i=r.indexOf(":");return i>=0&&(r=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),q0.hasOwnProperty(r)?{space:q0[r],local:e}:e}function Y2(e){return function(){var r=this.ownerDocument,i=this.namespaceURI;return i===Fm&&r.documentElement.namespaceURI===Fm?r.createElement(e):r.createElementNS(i,e)}}function X2(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function sk(e){var r=Ya(e);return(r.local?X2:Y2)(r)}function Q2(){}function cv(e){return e==null?Q2:function(){return this.querySelector(e)}}function Z2(e){typeof e!="function"&&(e=cv(e));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var u=r[s],l=u.length,c=o[s]=new Array(l),d,p,h=0;h<l;++h)(d=u[h])&&(p=e.call(d,d.__data__,h,u))&&("__data__"in d&&(p.__data__=d.__data__),c[h]=p);return new rn(o,this._parents)}function J2(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function eT(){return[]}function ak(e){return e==null?eT:function(){return this.querySelectorAll(e)}}function tT(e){return function(){return J2(e.apply(this,arguments))}}function nT(e){typeof e=="function"?e=tT(e):e=ak(e);for(var r=this._groups,i=r.length,o=[],s=[],u=0;u<i;++u)for(var l=r[u],c=l.length,d,p=0;p<c;++p)(d=l[p])&&(o.push(e.call(d,d.__data__,p,l)),s.push(d));return new rn(o,s)}function uk(e){return function(){return this.matches(e)}}function lk(e){return function(r){return r.matches(e)}}var rT=Array.prototype.find;function iT(e){return function(){return rT.call(this.children,e)}}function oT(){return this.firstElementChild}function sT(e){return this.select(e==null?oT:iT(typeof e=="function"?e:lk(e)))}var aT=Array.prototype.filter;function uT(){return Array.from(this.children)}function lT(e){return function(){return aT.call(this.children,e)}}function cT(e){return this.selectAll(e==null?uT:lT(typeof e=="function"?e:lk(e)))}function fT(e){typeof e!="function"&&(e=uk(e));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var u=r[s],l=u.length,c=o[s]=[],d,p=0;p<l;++p)(d=u[p])&&e.call(d,d.__data__,p,u)&&c.push(d);return new rn(o,this._parents)}function ck(e){return new Array(e.length)}function dT(){return new rn(this._enter||this._groups.map(ck),this._parents)}function La(e,r){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=r}La.prototype={constructor:La,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,r){return this._parent.insertBefore(e,r)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function hT(e){return function(){return e}}function pT(e,r,i,o,s,u){for(var l=0,c,d=r.length,p=u.length;l<p;++l)(c=r[l])?(c.__data__=u[l],o[l]=c):i[l]=new La(e,u[l]);for(;l<d;++l)(c=r[l])&&(s[l]=c)}function mT(e,r,i,o,s,u,l){var c,d,p=new Map,h=r.length,v=u.length,g=new Array(h),w;for(c=0;c<h;++c)(d=r[c])&&(g[c]=w=l.call(d,d.__data__,c,r)+"",p.has(w)?s[c]=d:p.set(w,d));for(c=0;c<v;++c)w=l.call(e,u[c],c,u)+"",(d=p.get(w))?(o[c]=d,d.__data__=u[c],p.delete(w)):i[c]=new La(e,u[c]);for(c=0;c<h;++c)(d=r[c])&&p.get(g[c])===d&&(s[c]=d)}function vT(e){return e.__data__}function gT(e,r){if(!arguments.length)return Array.from(this,vT);var i=r?mT:pT,o=this._parents,s=this._groups;typeof e!="function"&&(e=hT(e));for(var u=s.length,l=new Array(u),c=new Array(u),d=new Array(u),p=0;p<u;++p){var h=o[p],v=s[p],g=v.length,w=yT(e.call(h,h&&h.__data__,p,o)),N=w.length,_=c[p]=new Array(N),E=l[p]=new Array(N),x=d[p]=new Array(g);i(h,v,_,E,x,w,r);for(var k=0,T=0,C,A;k<N;++k)if(C=_[k]){for(k>=T&&(T=k+1);!(A=E[T])&&++T<N;);C._next=A||null}}return l=new rn(l,o),l._enter=c,l._exit=d,l}function yT(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function wT(){return new rn(this._exit||this._groups.map(ck),this._parents)}function _T(e,r,i){var o=this.enter(),s=this,u=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),r!=null&&(s=r(s),s&&(s=s.selection())),i==null?u.remove():i(u),o&&s?o.merge(s).order():s}function xT(e){for(var r=e.selection?e.selection():e,i=this._groups,o=r._groups,s=i.length,u=o.length,l=Math.min(s,u),c=new Array(s),d=0;d<l;++d)for(var p=i[d],h=o[d],v=p.length,g=c[d]=new Array(v),w,N=0;N<v;++N)(w=p[N]||h[N])&&(g[N]=w);for(;d<s;++d)c[d]=i[d];return new rn(c,this._parents)}function ST(){for(var e=this._groups,r=-1,i=e.length;++r<i;)for(var o=e[r],s=o.length-1,u=o[s],l;--s>=0;)(l=o[s])&&(u&&l.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(l,u),u=l);return this}function ET(e){e||(e=kT);function r(v,g){return v&&g?e(v.__data__,g.__data__):!v-!g}for(var i=this._groups,o=i.length,s=new Array(o),u=0;u<o;++u){for(var l=i[u],c=l.length,d=s[u]=new Array(c),p,h=0;h<c;++h)(p=l[h])&&(d[h]=p);d.sort(r)}return new rn(s,this._parents).order()}function kT(e,r){return e<r?-1:e>r?1:e>=r?0:NaN}function bT(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function NT(){return Array.from(this)}function CT(){for(var e=this._groups,r=0,i=e.length;r<i;++r)for(var o=e[r],s=0,u=o.length;s<u;++s){var l=o[s];if(l)return l}return null}function TT(){let e=0;for(const r of this)++e;return e}function RT(){return!this.node()}function AT(e){for(var r=this._groups,i=0,o=r.length;i<o;++i)for(var s=r[i],u=0,l=s.length,c;u<l;++u)(c=s[u])&&e.call(c,c.__data__,u,s);return this}function IT(e){return function(){this.removeAttribute(e)}}function jT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function MT(e,r){return function(){this.setAttribute(e,r)}}function PT(e,r){return function(){this.setAttributeNS(e.space,e.local,r)}}function qT(e,r){return function(){var i=r.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function OT(e,r){return function(){var i=r.apply(this,arguments);i==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,i)}}function LT(e,r){var i=Ya(e);if(arguments.length<2){var o=this.node();return i.local?o.getAttributeNS(i.space,i.local):o.getAttribute(i)}return this.each((r==null?i.local?jT:IT:typeof r=="function"?i.local?OT:qT:i.local?PT:MT)(i,r))}function fk(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function $T(e){return function(){this.style.removeProperty(e)}}function DT(e,r,i){return function(){this.style.setProperty(e,r,i)}}function FT(e,r,i){return function(){var o=r.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,i)}}function zT(e,r,i){return arguments.length>1?this.each((r==null?$T:typeof r=="function"?FT:DT)(e,r,i??"")):Li(this.node(),e)}function Li(e,r){return e.style.getPropertyValue(r)||fk(e).getComputedStyle(e,null).getPropertyValue(r)}function BT(e){return function(){delete this[e]}}function UT(e,r){return function(){this[e]=r}}function HT(e,r){return function(){var i=r.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function VT(e,r){return arguments.length>1?this.each((r==null?BT:typeof r=="function"?HT:UT)(e,r)):this.node()[e]}function dk(e){return e.trim().split(/^|\s+/)}function fv(e){return e.classList||new hk(e)}function hk(e){this._node=e,this._names=dk(e.getAttribute("class")||"")}hk.prototype={add:function(e){var r=this._names.indexOf(e);r<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var r=this._names.indexOf(e);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function pk(e,r){for(var i=fv(e),o=-1,s=r.length;++o<s;)i.add(r[o])}function mk(e,r){for(var i=fv(e),o=-1,s=r.length;++o<s;)i.remove(r[o])}function WT(e){return function(){pk(this,e)}}function GT(e){return function(){mk(this,e)}}function KT(e,r){return function(){(r.apply(this,arguments)?pk:mk)(this,e)}}function YT(e,r){var i=dk(e+"");if(arguments.length<2){for(var o=fv(this.node()),s=-1,u=i.length;++s<u;)if(!o.contains(i[s]))return!1;return!0}return this.each((typeof r=="function"?KT:r?WT:GT)(i,r))}function XT(){this.textContent=""}function QT(e){return function(){this.textContent=e}}function ZT(e){return function(){var r=e.apply(this,arguments);this.textContent=r??""}}function JT(e){return arguments.length?this.each(e==null?XT:(typeof e=="function"?ZT:QT)(e)):this.node().textContent}function eR(){this.innerHTML=""}function tR(e){return function(){this.innerHTML=e}}function nR(e){return function(){var r=e.apply(this,arguments);this.innerHTML=r??""}}function rR(e){return arguments.length?this.each(e==null?eR:(typeof e=="function"?nR:tR)(e)):this.node().innerHTML}function iR(){this.nextSibling&&this.parentNode.appendChild(this)}function oR(){return this.each(iR)}function sR(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function aR(){return this.each(sR)}function uR(e){var r=typeof e=="function"?e:sk(e);return this.select(function(){return this.appendChild(r.apply(this,arguments))})}function lR(){return null}function cR(e,r){var i=typeof e=="function"?e:sk(e),o=r==null?lR:typeof r=="function"?r:cv(r);return this.select(function(){return this.insertBefore(i.apply(this,arguments),o.apply(this,arguments)||null)})}function fR(){var e=this.parentNode;e&&e.removeChild(this)}function dR(){return this.each(fR)}function hR(){var e=this.cloneNode(!1),r=this.parentNode;return r?r.insertBefore(e,this.nextSibling):e}function pR(){var e=this.cloneNode(!0),r=this.parentNode;return r?r.insertBefore(e,this.nextSibling):e}function mR(e){return this.select(e?pR:hR)}function vR(e){return arguments.length?this.property("__data__",e):this.node().__data__}function gR(e){return function(r){e.call(this,r,this.__data__)}}function yR(e){return e.trim().split(/^|\s+/).map(function(r){var i="",o=r.indexOf(".");return o>=0&&(i=r.slice(o+1),r=r.slice(0,o)),{type:r,name:i}})}function wR(e){return function(){var r=this.__on;if(r){for(var i=0,o=-1,s=r.length,u;i<s;++i)u=r[i],(!e.type||u.type===e.type)&&u.name===e.name?this.removeEventListener(u.type,u.listener,u.options):r[++o]=u;++o?r.length=o:delete this.__on}}}function _R(e,r,i){return function(){var o=this.__on,s,u=gR(r);if(o){for(var l=0,c=o.length;l<c;++l)if((s=o[l]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=u,s.options=i),s.value=r;return}}this.addEventListener(e.type,u,i),s={type:e.type,name:e.name,value:r,listener:u,options:i},o?o.push(s):this.__on=[s]}}function xR(e,r,i){var o=yR(e+""),s,u=o.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var d=0,p=c.length,h;d<p;++d)for(s=0,h=c[d];s<u;++s)if((l=o[s]).type===h.type&&l.name===h.name)return h.value}return}for(c=r?_R:wR,s=0;s<u;++s)this.each(c(o[s],r,i));return this}function vk(e,r,i){var o=fk(e),s=o.CustomEvent;typeof s=="function"?s=new s(r,i):(s=o.document.createEvent("Event"),i?(s.initEvent(r,i.bubbles,i.cancelable),s.detail=i.detail):s.initEvent(r,!1,!1)),e.dispatchEvent(s)}function SR(e,r){return function(){return vk(this,e,r)}}function ER(e,r){return function(){return vk(this,e,r.apply(this,arguments))}}function kR(e,r){return this.each((typeof r=="function"?ER:SR)(e,r))}function*bR(){for(var e=this._groups,r=0,i=e.length;r<i;++r)for(var o=e[r],s=0,u=o.length,l;s<u;++s)(l=o[s])&&(yield l)}var gk=[null];function rn(e,r){this._groups=e,this._parents=r}function Zo(){return new rn([[document.documentElement]],gk)}function NR(){return this}rn.prototype=Zo.prototype={constructor:rn,select:Z2,selectAll:nT,selectChild:sT,selectChildren:cT,filter:fT,data:gT,enter:dT,exit:wT,join:_T,merge:xT,selection:NR,order:ST,sort:ET,call:bT,nodes:NT,node:CT,size:TT,empty:RT,each:AT,attr:LT,style:zT,property:VT,classed:YT,text:JT,html:rR,raise:oR,lower:aR,append:uR,insert:cR,remove:dR,clone:mR,datum:vR,on:xR,dispatch:kR,[Symbol.iterator]:bR};function pn(e){return typeof e=="string"?new rn([[document.querySelector(e)]],[document.documentElement]):new rn([[e]],gk)}function CR(e){let r;for(;r=e.sourceEvent;)e=r;return e}function Tn(e,r){if(e=CR(e),r===void 0&&(r=e.currentTarget),r){var i=r.ownerSVGElement||r;if(i.createSVGPoint){var o=i.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(r.getScreenCTM().inverse()),[o.x,o.y]}if(r.getBoundingClientRect){var s=r.getBoundingClientRect();return[e.clientX-s.left-r.clientLeft,e.clientY-s.top-r.clientTop]}}return[e.pageX,e.pageY]}const TR={passive:!1},Uo={capture:!0,passive:!1};function cc(e){e.stopImmediatePropagation()}function Pi(e){e.preventDefault(),e.stopImmediatePropagation()}function yk(e){var r=e.document.documentElement,i=pn(e).on("dragstart.drag",Pi,Uo);"onselectstart"in r?i.on("selectstart.drag",Pi,Uo):(r.__noselect=r.style.MozUserSelect,r.style.MozUserSelect="none")}function wk(e,r){var i=e.document.documentElement,o=pn(e).on("dragstart.drag",null);r&&(o.on("click.drag",Pi,Uo),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in i?o.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const Ea=e=>()=>e;function zm(e,{sourceEvent:r,subject:i,target:o,identifier:s,active:u,x:l,y:c,dx:d,dy:p,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:s,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:p,enumerable:!0,configurable:!0},_:{value:h}})}zm.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function RR(e){return!e.ctrlKey&&!e.button}function AR(){return this.parentNode}function IR(e,r){return r??{x:e.x,y:e.y}}function jR(){return navigator.maxTouchPoints||"ontouchstart"in this}function MR(){var e=RR,r=AR,i=IR,o=jR,s={},u=Ka("start","drag","end"),l=0,c,d,p,h,v=0;function g(C){C.on("mousedown.drag",w).filter(o).on("touchstart.drag",E).on("touchmove.drag",x,TR).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(C,A){if(!(h||!e.call(this,C,A))){var j=T(this,r.call(this,C,A),C,A,"mouse");j&&(pn(C.view).on("mousemove.drag",N,Uo).on("mouseup.drag",_,Uo),yk(C.view),cc(C),p=!1,c=C.clientX,d=C.clientY,j("start",C))}}function N(C){if(Pi(C),!p){var A=C.clientX-c,j=C.clientY-d;p=A*A+j*j>v}s.mouse("drag",C)}function _(C){pn(C.view).on("mousemove.drag mouseup.drag",null),wk(C.view,p),Pi(C),s.mouse("end",C)}function E(C,A){if(e.call(this,C,A)){var j=C.changedTouches,M=r.call(this,C,A),z=j.length,O,B;for(O=0;O<z;++O)(B=T(this,M,C,A,j[O].identifier,j[O]))&&(cc(C),B("start",C,j[O]))}}function x(C){var A=C.changedTouches,j=A.length,M,z;for(M=0;M<j;++M)(z=s[A[M].identifier])&&(Pi(C),z("drag",C,A[M]))}function k(C){var A=C.changedTouches,j=A.length,M,z;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),M=0;M<j;++M)(z=s[A[M].identifier])&&(cc(C),z("end",C,A[M]))}function T(C,A,j,M,z,O){var B=u.copy(),U=Tn(O||j,A),ee,X,R;if((R=i.call(C,new zm("beforestart",{sourceEvent:j,target:g,identifier:z,active:l,x:U[0],y:U[1],dx:0,dy:0,dispatch:B}),M))!=null)return ee=R.x-U[0]||0,X=R.y-U[1]||0,function G(H,ne,Y){var L=U,K;switch(H){case"start":s[z]=G,K=l++;break;case"end":delete s[z],--l;case"drag":U=Tn(Y||ne,A),K=l;break}B.call(H,C,new zm(H,{sourceEvent:ne,subject:R,target:g,identifier:z,active:K,x:U[0]+ee,y:U[1]+X,dx:U[0]-L[0],dy:U[1]-L[1],dispatch:B}),M)}}return g.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Ea(!!C),g):e},g.container=function(C){return arguments.length?(r=typeof C=="function"?C:Ea(C),g):r},g.subject=function(C){return arguments.length?(i=typeof C=="function"?C:Ea(C),g):i},g.touchable=function(C){return arguments.length?(o=typeof C=="function"?C:Ea(!!C),g):o},g.on=function(){var C=u.on.apply(u,arguments);return C===u?g:C},g.clickDistance=function(C){return arguments.length?(v=(C=+C)*C,g):Math.sqrt(v)},g}function dv(e,r,i){e.prototype=r.prototype=i,i.constructor=e}function _k(e,r){var i=Object.create(e.prototype);for(var o in r)i[o]=r[o];return i}function Jo(){}var Ho=.7,$a=1/Ho,qi="\\s*([+-]?\\d+)\\s*",Vo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",PR=/^#([0-9a-f]{3,8})$/,qR=new RegExp(`^rgb\\(${qi},${qi},${qi}\\)$`),OR=new RegExp(`^rgb\\(${Fn},${Fn},${Fn}\\)$`),LR=new RegExp(`^rgba\\(${qi},${qi},${qi},${Vo}\\)$`),$R=new RegExp(`^rgba\\(${Fn},${Fn},${Fn},${Vo}\\)$`),DR=new RegExp(`^hsl\\(${Vo},${Fn},${Fn}\\)$`),FR=new RegExp(`^hsla\\(${Vo},${Fn},${Fn},${Vo}\\)$`),O0={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};dv(Jo,Wo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:L0,formatHex:L0,formatHex8:zR,formatHsl:BR,formatRgb:$0,toString:$0});function L0(){return this.rgb().formatHex()}function zR(){return this.rgb().formatHex8()}function BR(){return xk(this).formatHsl()}function $0(){return this.rgb().formatRgb()}function Wo(e){var r,i;return e=(e+"").trim().toLowerCase(),(r=PR.exec(e))?(i=r[1].length,r=parseInt(r[1],16),i===6?D0(r):i===3?new Kt(r>>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):i===8?ka(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):i===4?ka(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=qR.exec(e))?new Kt(r[1],r[2],r[3],1):(r=OR.exec(e))?new Kt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=LR.exec(e))?ka(r[1],r[2],r[3],r[4]):(r=$R.exec(e))?ka(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=DR.exec(e))?B0(r[1],r[2]/100,r[3]/100,1):(r=FR.exec(e))?B0(r[1],r[2]/100,r[3]/100,r[4]):O0.hasOwnProperty(e)?D0(O0[e]):e==="transparent"?new Kt(NaN,NaN,NaN,0):null}function D0(e){return new Kt(e>>16&255,e>>8&255,e&255,1)}function ka(e,r,i,o){return o<=0&&(e=r=i=NaN),new Kt(e,r,i,o)}function UR(e){return e instanceof Jo||(e=Wo(e)),e?(e=e.rgb(),new Kt(e.r,e.g,e.b,e.opacity)):new Kt}function Bm(e,r,i,o){return arguments.length===1?UR(e):new Kt(e,r,i,o??1)}function Kt(e,r,i,o){this.r=+e,this.g=+r,this.b=+i,this.opacity=+o}dv(Kt,Bm,_k(Jo,{brighter(e){return e=e==null?$a:Math.pow($a,e),new Kt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ho:Math.pow(Ho,e),new Kt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Kt(Yr(this.r),Yr(this.g),Yr(this.b),Da(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:F0,formatHex:F0,formatHex8:HR,formatRgb:z0,toString:z0}));function F0(){return`#${Gr(this.r)}${Gr(this.g)}${Gr(this.b)}`}function HR(){return`#${Gr(this.r)}${Gr(this.g)}${Gr(this.b)}${Gr((isNaN(this.opacity)?1:this.opacity)*255)}`}function z0(){const e=Da(this.opacity);return`${e===1?"rgb(":"rgba("}${Yr(this.r)}, ${Yr(this.g)}, ${Yr(this.b)}${e===1?")":`, ${e})`}`}function Da(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Yr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Gr(e){return e=Yr(e),(e<16?"0":"")+e.toString(16)}function B0(e,r,i,o){return o<=0?e=r=i=NaN:i<=0||i>=1?e=r=NaN:r<=0&&(e=NaN),new Rn(e,r,i,o)}function xk(e){if(e instanceof Rn)return new Rn(e.h,e.s,e.l,e.opacity);if(e instanceof Jo||(e=Wo(e)),!e)return new Rn;if(e instanceof Rn)return e;e=e.rgb();var r=e.r/255,i=e.g/255,o=e.b/255,s=Math.min(r,i,o),u=Math.max(r,i,o),l=NaN,c=u-s,d=(u+s)/2;return c?(r===u?l=(i-o)/c+(i<o)*6:i===u?l=(o-r)/c+2:l=(r-i)/c+4,c/=d<.5?u+s:2-u-s,l*=60):c=d>0&&d<1?0:l,new Rn(l,c,d,e.opacity)}function VR(e,r,i,o){return arguments.length===1?xk(e):new Rn(e,r,i,o??1)}function Rn(e,r,i,o){this.h=+e,this.s=+r,this.l=+i,this.opacity=+o}dv(Rn,VR,_k(Jo,{brighter(e){return e=e==null?$a:Math.pow($a,e),new Rn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ho:Math.pow(Ho,e),new Rn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,r=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,o=i+(i<.5?i:1-i)*r,s=2*i-o;return new Kt(fc(e>=240?e-240:e+120,s,o),fc(e,s,o),fc(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Rn(U0(this.h),ba(this.s),ba(this.l),Da(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=Da(this.opacity);return`${e===1?"hsl(":"hsla("}${U0(this.h)}, ${ba(this.s)*100}%, ${ba(this.l)*100}%${e===1?")":`, ${e})`}`}}));function U0(e){return e=(e||0)%360,e<0?e+360:e}function ba(e){return Math.max(0,Math.min(1,e||0))}function fc(e,r,i){return(e<60?r+(i-r)*e/60:e<180?i:e<240?r+(i-r)*(240-e)/60:r)*255}const Sk=e=>()=>e;function WR(e,r){return function(i){return e+i*r}}function GR(e,r,i){return e=Math.pow(e,i),r=Math.pow(r,i)-e,i=1/i,function(o){return Math.pow(e+o*r,i)}}function KR(e){return(e=+e)==1?Ek:function(r,i){return i-r?GR(r,i,e):Sk(isNaN(r)?i:r)}}function Ek(e,r){var i=r-e;return i?WR(e,i):Sk(isNaN(e)?r:e)}const H0=(function e(r){var i=KR(r);function o(s,u){var l=i((s=Bm(s)).r,(u=Bm(u)).r),c=i(s.g,u.g),d=i(s.b,u.b),p=Ek(s.opacity,u.opacity);return function(h){return s.r=l(h),s.g=c(h),s.b=d(h),s.opacity=p(h),s+""}}return o.gamma=e,o})(1);function Nr(e,r){return e=+e,r=+r,function(i){return e*(1-i)+r*i}}var Um=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,dc=new RegExp(Um.source,"g");function YR(e){return function(){return e}}function XR(e){return function(r){return e(r)+""}}function QR(e,r){var i=Um.lastIndex=dc.lastIndex=0,o,s,u,l=-1,c=[],d=[];for(e=e+"",r=r+"";(o=Um.exec(e))&&(s=dc.exec(r));)(u=s.index)>i&&(u=r.slice(i,u),c[l]?c[l]+=u:c[++l]=u),(o=o[0])===(s=s[0])?c[l]?c[l]+=s:c[++l]=s:(c[++l]=null,d.push({i:l,x:Nr(o,s)})),i=dc.lastIndex;return i<r.length&&(u=r.slice(i),c[l]?c[l]+=u:c[++l]=u),c.length<2?d[0]?XR(d[0].x):YR(r):(r=d.length,function(p){for(var h=0,v;h<r;++h)c[(v=d[h]).i]=v.x(p);return c.join("")})}var V0=180/Math.PI,Hm={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function kk(e,r,i,o,s,u){var l,c,d;return(l=Math.sqrt(e*e+r*r))&&(e/=l,r/=l),(d=e*i+r*o)&&(i-=e*d,o-=r*d),(c=Math.sqrt(i*i+o*o))&&(i/=c,o/=c,d/=c),e*o<r*i&&(e=-e,r=-r,d=-d,l=-l),{translateX:s,translateY:u,rotate:Math.atan2(r,e)*V0,skewX:Math.atan(d)*V0,scaleX:l,scaleY:c}}var Na;function ZR(e){const r=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return r.isIdentity?Hm:kk(r.a,r.b,r.c,r.d,r.e,r.f)}function JR(e){return e==null||(Na||(Na=document.createElementNS("http://www.w3.org/2000/svg","g")),Na.setAttribute("transform",e),!(e=Na.transform.baseVal.consolidate()))?Hm:(e=e.matrix,kk(e.a,e.b,e.c,e.d,e.e,e.f))}function bk(e,r,i,o){function s(p){return p.length?p.pop()+" ":""}function u(p,h,v,g,w,N){if(p!==v||h!==g){var _=w.push("translate(",null,r,null,i);N.push({i:_-4,x:Nr(p,v)},{i:_-2,x:Nr(h,g)})}else(v||g)&&w.push("translate("+v+r+g+i)}function l(p,h,v,g){p!==h?(p-h>180?h+=360:h-p>180&&(p+=360),g.push({i:v.push(s(v)+"rotate(",null,o)-2,x:Nr(p,h)})):h&&v.push(s(v)+"rotate("+h+o)}function c(p,h,v,g){p!==h?g.push({i:v.push(s(v)+"skewX(",null,o)-2,x:Nr(p,h)}):h&&v.push(s(v)+"skewX("+h+o)}function d(p,h,v,g,w,N){if(p!==v||h!==g){var _=w.push(s(w)+"scale(",null,",",null,")");N.push({i:_-4,x:Nr(p,v)},{i:_-2,x:Nr(h,g)})}else(v!==1||g!==1)&&w.push(s(w)+"scale("+v+","+g+")")}return function(p,h){var v=[],g=[];return p=e(p),h=e(h),u(p.translateX,p.translateY,h.translateX,h.translateY,v,g),l(p.rotate,h.rotate,v,g),c(p.skewX,h.skewX,v,g),d(p.scaleX,p.scaleY,h.scaleX,h.scaleY,v,g),p=h=null,function(w){for(var N=-1,_=g.length,E;++N<_;)v[(E=g[N]).i]=E.x(w);return v.join("")}}}var eA=bk(ZR,"px, ","px)","deg)"),tA=bk(JR,", ",")",")"),nA=1e-12;function W0(e){return((e=Math.exp(e))+1/e)/2}function rA(e){return((e=Math.exp(e))-1/e)/2}function iA(e){return((e=Math.exp(2*e))-1)/(e+1)}const oA=(function e(r,i,o){function s(u,l){var c=u[0],d=u[1],p=u[2],h=l[0],v=l[1],g=l[2],w=h-c,N=v-d,_=w*w+N*N,E,x;if(_<nA)x=Math.log(g/p)/r,E=function(M){return[c+M*w,d+M*N,p*Math.exp(r*M*x)]};else{var k=Math.sqrt(_),T=(g*g-p*p+o*_)/(2*p*i*k),C=(g*g-p*p-o*_)/(2*g*i*k),A=Math.log(Math.sqrt(T*T+1)-T),j=Math.log(Math.sqrt(C*C+1)-C);x=(j-A)/r,E=function(M){var z=M*x,O=W0(A),B=p/(i*k)*(O*iA(r*z+A)-rA(A));return[c+B*w,d+B*N,p*O/W0(r*z+A)]}}return E.duration=x*1e3*r/Math.SQRT2,E}return s.rho=function(u){var l=Math.max(.001,+u),c=l*l,d=c*c;return e(l,c,d)},s})(Math.SQRT2,2,4);var $i=0,Oo=0,Io=0,Nk=1e3,Fa,Lo,za=0,Qr=0,Xa=0,Go=typeof performance=="object"&&performance.now?performance:Date,Ck=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function hv(){return Qr||(Ck(sA),Qr=Go.now()+Xa)}function sA(){Qr=0}function Ba(){this._call=this._time=this._next=null}Ba.prototype=Tk.prototype={constructor:Ba,restart:function(e,r,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?hv():+i)+(r==null?0:+r),!this._next&&Lo!==this&&(Lo?Lo._next=this:Fa=this,Lo=this),this._call=e,this._time=i,Vm()},stop:function(){this._call&&(this._call=null,this._time=1/0,Vm())}};function Tk(e,r,i){var o=new Ba;return o.restart(e,r,i),o}function aA(){hv(),++$i;for(var e=Fa,r;e;)(r=Qr-e._time)>=0&&e._call.call(void 0,r),e=e._next;--$i}function G0(){Qr=(za=Go.now())+Xa,$i=Oo=0;try{aA()}finally{$i=0,lA(),Qr=0}}function uA(){var e=Go.now(),r=e-za;r>Nk&&(Xa-=r,za=e)}function lA(){for(var e,r=Fa,i,o=1/0;r;)r._call?(o>r._time&&(o=r._time),e=r,r=r._next):(i=r._next,r._next=null,r=e?e._next=i:Fa=i);Lo=e,Vm(o)}function Vm(e){if(!$i){Oo&&(Oo=clearTimeout(Oo));var r=e-Qr;r>24?(e<1/0&&(Oo=setTimeout(G0,e-Go.now()-Xa)),Io&&(Io=clearInterval(Io))):(Io||(za=Go.now(),Io=setInterval(uA,Nk)),$i=1,Ck(G0))}}function K0(e,r,i){var o=new Ba;return r=r==null?0:+r,o.restart(s=>{o.stop(),e(s+r)},r,i),o}var cA=Ka("start","end","cancel","interrupt"),fA=[],Rk=0,Y0=1,Wm=2,Pa=3,X0=4,Gm=5,qa=6;function Qa(e,r,i,o,s,u){var l=e.__transition;if(!l)e.__transition={};else if(i in l)return;dA(e,i,{name:r,index:o,group:s,on:cA,tween:fA,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Rk})}function pv(e,r){var i=Mn(e,r);if(i.state>Rk)throw new Error("too late; already scheduled");return i}function zn(e,r){var i=Mn(e,r);if(i.state>Pa)throw new Error("too late; already running");return i}function Mn(e,r){var i=e.__transition;if(!i||!(i=i[r]))throw new Error("transition not found");return i}function dA(e,r,i){var o=e.__transition,s;o[r]=i,i.timer=Tk(u,0,i.time);function u(p){i.state=Y0,i.timer.restart(l,i.delay,i.time),i.delay<=p&&l(p-i.delay)}function l(p){var h,v,g,w;if(i.state!==Y0)return d();for(h in o)if(w=o[h],w.name===i.name){if(w.state===Pa)return K0(l);w.state===X0?(w.state=qa,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete o[h]):+h<r&&(w.state=qa,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete o[h])}if(K0(function(){i.state===Pa&&(i.state=X0,i.timer.restart(c,i.delay,i.time),c(p))}),i.state=Wm,i.on.call("start",e,e.__data__,i.index,i.group),i.state===Wm){for(i.state=Pa,s=new Array(g=i.tween.length),h=0,v=-1;h<g;++h)(w=i.tween[h].value.call(e,e.__data__,i.index,i.group))&&(s[++v]=w);s.length=v+1}}function c(p){for(var h=p<i.duration?i.ease.call(null,p/i.duration):(i.timer.restart(d),i.state=Gm,1),v=-1,g=s.length;++v<g;)s[v].call(e,h);i.state===Gm&&(i.on.call("end",e,e.__data__,i.index,i.group),d())}function d(){i.state=qa,i.timer.stop(),delete o[r];for(var p in o)return;delete e.__transition}}function Oa(e,r){var i=e.__transition,o,s,u=!0,l;if(i){r=r==null?null:r+"";for(l in i){if((o=i[l]).name!==r){u=!1;continue}s=o.state>Wm&&o.state<Gm,o.state=qa,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete i[l]}u&&delete e.__transition}}function hA(e){return this.each(function(){Oa(this,e)})}function pA(e,r){var i,o;return function(){var s=zn(this,e),u=s.tween;if(u!==i){o=i=u;for(var l=0,c=o.length;l<c;++l)if(o[l].name===r){o=o.slice(),o.splice(l,1);break}}s.tween=o}}function mA(e,r,i){var o,s;if(typeof i!="function")throw new Error;return function(){var u=zn(this,e),l=u.tween;if(l!==o){s=(o=l).slice();for(var c={name:r,value:i},d=0,p=s.length;d<p;++d)if(s[d].name===r){s[d]=c;break}d===p&&s.push(c)}u.tween=s}}function vA(e,r){var i=this._id;if(e+="",arguments.length<2){for(var o=Mn(this.node(),i).tween,s=0,u=o.length,l;s<u;++s)if((l=o[s]).name===e)return l.value;return null}return this.each((r==null?pA:mA)(i,e,r))}function mv(e,r,i){var o=e._id;return e.each(function(){var s=zn(this,o);(s.value||(s.value={}))[r]=i.apply(this,arguments)}),function(s){return Mn(s,o).value[r]}}function Ak(e,r){var i;return(typeof r=="number"?Nr:r instanceof Wo?H0:(i=Wo(r))?(r=i,H0):QR)(e,r)}function gA(e){return function(){this.removeAttribute(e)}}function yA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wA(e,r,i){var o,s=i+"",u;return function(){var l=this.getAttribute(e);return l===s?null:l===o?u:u=r(o=l,i)}}function _A(e,r,i){var o,s=i+"",u;return function(){var l=this.getAttributeNS(e.space,e.local);return l===s?null:l===o?u:u=r(o=l,i)}}function xA(e,r,i){var o,s,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===o&&d===s?u:(s=d,u=r(o=l,c)))}}function SA(e,r,i){var o,s,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===o&&d===s?u:(s=d,u=r(o=l,c)))}}function EA(e,r){var i=Ya(e),o=i==="transform"?tA:Ak;return this.attrTween(e,typeof r=="function"?(i.local?SA:xA)(i,o,mv(this,"attr."+e,r)):r==null?(i.local?yA:gA)(i):(i.local?_A:wA)(i,o,r))}function kA(e,r){return function(i){this.setAttribute(e,r.call(this,i))}}function bA(e,r){return function(i){this.setAttributeNS(e.space,e.local,r.call(this,i))}}function NA(e,r){var i,o;function s(){var u=r.apply(this,arguments);return u!==o&&(i=(o=u)&&bA(e,u)),i}return s._value=r,s}function CA(e,r){var i,o;function s(){var u=r.apply(this,arguments);return u!==o&&(i=(o=u)&&kA(e,u)),i}return s._value=r,s}function TA(e,r){var i="attr."+e;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(r==null)return this.tween(i,null);if(typeof r!="function")throw new Error;var o=Ya(e);return this.tween(i,(o.local?NA:CA)(o,r))}function RA(e,r){return function(){pv(this,e).delay=+r.apply(this,arguments)}}function AA(e,r){return r=+r,function(){pv(this,e).delay=r}}function IA(e){var r=this._id;return arguments.length?this.each((typeof e=="function"?RA:AA)(r,e)):Mn(this.node(),r).delay}function jA(e,r){return function(){zn(this,e).duration=+r.apply(this,arguments)}}function MA(e,r){return r=+r,function(){zn(this,e).duration=r}}function PA(e){var r=this._id;return arguments.length?this.each((typeof e=="function"?jA:MA)(r,e)):Mn(this.node(),r).duration}function qA(e,r){if(typeof r!="function")throw new Error;return function(){zn(this,e).ease=r}}function OA(e){var r=this._id;return arguments.length?this.each(qA(r,e)):Mn(this.node(),r).ease}function LA(e,r){return function(){var i=r.apply(this,arguments);if(typeof i!="function")throw new Error;zn(this,e).ease=i}}function $A(e){if(typeof e!="function")throw new Error;return this.each(LA(this._id,e))}function DA(e){typeof e!="function"&&(e=uk(e));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var u=r[s],l=u.length,c=o[s]=[],d,p=0;p<l;++p)(d=u[p])&&e.call(d,d.__data__,p,u)&&c.push(d);return new tr(o,this._parents,this._name,this._id)}function FA(e){if(e._id!==this._id)throw new Error;for(var r=this._groups,i=e._groups,o=r.length,s=i.length,u=Math.min(o,s),l=new Array(o),c=0;c<u;++c)for(var d=r[c],p=i[c],h=d.length,v=l[c]=new Array(h),g,w=0;w<h;++w)(g=d[w]||p[w])&&(v[w]=g);for(;c<o;++c)l[c]=r[c];return new tr(l,this._parents,this._name,this._id)}function zA(e){return(e+"").trim().split(/^|\s+/).every(function(r){var i=r.indexOf(".");return i>=0&&(r=r.slice(0,i)),!r||r==="start"})}function BA(e,r,i){var o,s,u=zA(r)?pv:zn;return function(){var l=u(this,e),c=l.on;c!==o&&(s=(o=c).copy()).on(r,i),l.on=s}}function UA(e,r){var i=this._id;return arguments.length<2?Mn(this.node(),i).on.on(e):this.each(BA(i,e,r))}function HA(e){return function(){var r=this.parentNode;for(var i in this.__transition)if(+i!==e)return;r&&r.removeChild(this)}}function VA(){return this.on("end.remove",HA(this._id))}function WA(e){var r=this._name,i=this._id;typeof e!="function"&&(e=cv(e));for(var o=this._groups,s=o.length,u=new Array(s),l=0;l<s;++l)for(var c=o[l],d=c.length,p=u[l]=new Array(d),h,v,g=0;g<d;++g)(h=c[g])&&(v=e.call(h,h.__data__,g,c))&&("__data__"in h&&(v.__data__=h.__data__),p[g]=v,Qa(p[g],r,i,g,p,Mn(h,i)));return new tr(u,this._parents,r,i)}function GA(e){var r=this._name,i=this._id;typeof e!="function"&&(e=ak(e));for(var o=this._groups,s=o.length,u=[],l=[],c=0;c<s;++c)for(var d=o[c],p=d.length,h,v=0;v<p;++v)if(h=d[v]){for(var g=e.call(h,h.__data__,v,d),w,N=Mn(h,i),_=0,E=g.length;_<E;++_)(w=g[_])&&Qa(w,r,i,_,g,N);u.push(g),l.push(h)}return new tr(u,l,r,i)}var KA=Zo.prototype.constructor;function YA(){return new KA(this._groups,this._parents)}function XA(e,r){var i,o,s;return function(){var u=Li(this,e),l=(this.style.removeProperty(e),Li(this,e));return u===l?null:u===i&&l===o?s:s=r(i=u,o=l)}}function Ik(e){return function(){this.style.removeProperty(e)}}function QA(e,r,i){var o,s=i+"",u;return function(){var l=Li(this,e);return l===s?null:l===o?u:u=r(o=l,i)}}function ZA(e,r,i){var o,s,u;return function(){var l=Li(this,e),c=i(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),Li(this,e))),l===d?null:l===o&&d===s?u:(s=d,u=r(o=l,c))}}function JA(e,r){var i,o,s,u="style."+r,l="end."+u,c;return function(){var d=zn(this,e),p=d.on,h=d.value[u]==null?c||(c=Ik(r)):void 0;(p!==i||s!==h)&&(o=(i=p).copy()).on(l,s=h),d.on=o}}function eI(e,r,i){var o=(e+="")=="transform"?eA:Ak;return r==null?this.styleTween(e,XA(e,o)).on("end.style."+e,Ik(e)):typeof r=="function"?this.styleTween(e,ZA(e,o,mv(this,"style."+e,r))).each(JA(this._id,e)):this.styleTween(e,QA(e,o,r),i).on("end.style."+e,null)}function tI(e,r,i){return function(o){this.style.setProperty(e,r.call(this,o),i)}}function nI(e,r,i){var o,s;function u(){var l=r.apply(this,arguments);return l!==s&&(o=(s=l)&&tI(e,l,i)),o}return u._value=r,u}function rI(e,r,i){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(r==null)return this.tween(o,null);if(typeof r!="function")throw new Error;return this.tween(o,nI(e,r,i??""))}function iI(e){return function(){this.textContent=e}}function oI(e){return function(){var r=e(this);this.textContent=r??""}}function sI(e){return this.tween("text",typeof e=="function"?oI(mv(this,"text",e)):iI(e==null?"":e+""))}function aI(e){return function(r){this.textContent=e.call(this,r)}}function uI(e){var r,i;function o(){var s=e.apply(this,arguments);return s!==i&&(r=(i=s)&&aI(s)),r}return o._value=e,o}function lI(e){var r="text";if(arguments.length<1)return(r=this.tween(r))&&r._value;if(e==null)return this.tween(r,null);if(typeof e!="function")throw new Error;return this.tween(r,uI(e))}function cI(){for(var e=this._name,r=this._id,i=jk(),o=this._groups,s=o.length,u=0;u<s;++u)for(var l=o[u],c=l.length,d,p=0;p<c;++p)if(d=l[p]){var h=Mn(d,r);Qa(d,e,i,p,l,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new tr(o,this._parents,e,i)}function fI(){var e,r,i=this,o=i._id,s=i.size();return new Promise(function(u,l){var c={value:l},d={value:function(){--s===0&&u()}};i.each(function(){var p=zn(this,o),h=p.on;h!==e&&(r=(e=h).copy(),r._.cancel.push(c),r._.interrupt.push(c),r._.end.push(d)),p.on=r}),s===0&&u()})}var dI=0;function tr(e,r,i,o){this._groups=e,this._parents=r,this._name=i,this._id=o}function jk(){return++dI}var Zn=Zo.prototype;tr.prototype={constructor:tr,select:WA,selectAll:GA,selectChild:Zn.selectChild,selectChildren:Zn.selectChildren,filter:DA,merge:FA,selection:YA,transition:cI,call:Zn.call,nodes:Zn.nodes,node:Zn.node,size:Zn.size,empty:Zn.empty,each:Zn.each,on:UA,attr:EA,attrTween:TA,style:eI,styleTween:rI,text:sI,textTween:lI,remove:VA,tween:vA,delay:IA,duration:PA,ease:OA,easeVarying:$A,end:fI,[Symbol.iterator]:Zn[Symbol.iterator]};function hI(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var pI={time:null,delay:0,duration:250,ease:hI};function mI(e,r){for(var i;!(i=e.__transition)||!(i=i[r]);)if(!(e=e.parentNode))throw new Error(`transition ${r} not found`);return i}function vI(e){var r,i;e instanceof tr?(r=e._id,e=e._name):(r=jk(),(i=pI).time=hv(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,u=0;u<s;++u)for(var l=o[u],c=l.length,d,p=0;p<c;++p)(d=l[p])&&Qa(d,e,r,p,l,i||mI(d,r));return new tr(o,this._parents,e,r)}Zo.prototype.interrupt=hA;Zo.prototype.transition=vI;const Ca=e=>()=>e;function gI(e,{sourceEvent:r,target:i,transform:o,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:s}})}function Jn(e,r,i){this.k=e,this.x=r,this.y=i}Jn.prototype={constructor:Jn,scale:function(e){return e===1?this:new Jn(this.k*e,this.x,this.y)},translate:function(e,r){return e===0&r===0?this:new Jn(this.k,this.x+this.k*e,this.y+this.k*r)},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 er=new Jn(1,0,0);Jn.prototype;function hc(e){e.stopImmediatePropagation()}function jo(e){e.preventDefault(),e.stopImmediatePropagation()}function yI(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function wI(){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 Q0(){return this.__zoom||er}function _I(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function xI(){return navigator.maxTouchPoints||"ontouchstart"in this}function SI(e,r,i){var o=e.invertX(r[0][0])-i[0][0],s=e.invertX(r[1][0])-i[1][0],u=e.invertY(r[0][1])-i[0][1],l=e.invertY(r[1][1])-i[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),l>u?(u+l)/2:Math.min(0,u)||Math.max(0,l))}function Mk(){var e=yI,r=wI,i=SI,o=_I,s=xI,u=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=oA,p=Ka("start","zoom","end"),h,v,g,w=500,N=150,_=0,E=10;function x(R){R.property("__zoom",Q0).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",B).filter(s).on("touchstart.zoom",U).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",X).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(R,G,H,ne){var Y=R.selection?R.selection():R;Y.property("__zoom",Q0),R!==Y?A(R,G,H,ne):Y.interrupt().each(function(){j(this,arguments).event(ne).start().zoom(null,typeof G=="function"?G.apply(this,arguments):G).end()})},x.scaleBy=function(R,G,H,ne){x.scaleTo(R,function(){var Y=this.__zoom.k,L=typeof G=="function"?G.apply(this,arguments):G;return Y*L},H,ne)},x.scaleTo=function(R,G,H,ne){x.transform(R,function(){var Y=r.apply(this,arguments),L=this.__zoom,K=H==null?C(Y):typeof H=="function"?H.apply(this,arguments):H,I=L.invert(K),F=typeof G=="function"?G.apply(this,arguments):G;return i(T(k(L,F),K,I),Y,l)},H,ne)},x.translateBy=function(R,G,H,ne){x.transform(R,function(){return i(this.__zoom.translate(typeof G=="function"?G.apply(this,arguments):G,typeof H=="function"?H.apply(this,arguments):H),r.apply(this,arguments),l)},null,ne)},x.translateTo=function(R,G,H,ne,Y){x.transform(R,function(){var L=r.apply(this,arguments),K=this.__zoom,I=ne==null?C(L):typeof ne=="function"?ne.apply(this,arguments):ne;return i(er.translate(I[0],I[1]).scale(K.k).translate(typeof G=="function"?-G.apply(this,arguments):-G,typeof H=="function"?-H.apply(this,arguments):-H),L,l)},ne,Y)};function k(R,G){return G=Math.max(u[0],Math.min(u[1],G)),G===R.k?R:new Jn(G,R.x,R.y)}function T(R,G,H){var ne=G[0]-H[0]*R.k,Y=G[1]-H[1]*R.k;return ne===R.x&&Y===R.y?R:new Jn(R.k,ne,Y)}function C(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function A(R,G,H,ne){R.on("start.zoom",function(){j(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(ne).end()}).tween("zoom",function(){var Y=this,L=arguments,K=j(Y,L).event(ne),I=r.apply(Y,L),F=H==null?C(I):typeof H=="function"?H.apply(Y,L):H,ae=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),q=Y.__zoom,V=typeof G=="function"?G.apply(Y,L):G,Q=d(q.invert(F).concat(ae/q.k),V.invert(F).concat(ae/V.k));return function(re){if(re===1)re=V;else{var ce=Q(re),he=ae/ce[2];re=new Jn(he,F[0]-ce[0]*he,F[1]-ce[1]*he)}K.zoom(null,re)}})}function j(R,G,H){return!H&&R.__zooming||new M(R,G)}function M(R,G){this.that=R,this.args=G,this.active=0,this.sourceEvent=null,this.extent=r.apply(R,G),this.taps=0}M.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,G){return this.mouse&&R!=="mouse"&&(this.mouse[1]=G.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=G.invert(this.touch0[0])),this.touch1&&R!=="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(R){var G=pn(this.that).datum();p.call(R,this.that,new gI(R,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:p}),G)}};function z(R,...G){if(!e.apply(this,arguments))return;var H=j(this,G).event(R),ne=this.__zoom,Y=Math.max(u[0],Math.min(u[1],ne.k*Math.pow(2,o.apply(this,arguments)))),L=Tn(R);if(H.wheel)(H.mouse[0][0]!==L[0]||H.mouse[0][1]!==L[1])&&(H.mouse[1]=ne.invert(H.mouse[0]=L)),clearTimeout(H.wheel);else{if(ne.k===Y)return;H.mouse=[L,ne.invert(L)],Oa(this),H.start()}jo(R),H.wheel=setTimeout(K,N),H.zoom("mouse",i(T(k(ne,Y),H.mouse[0],H.mouse[1]),H.extent,l));function K(){H.wheel=null,H.end()}}function O(R,...G){if(g||!e.apply(this,arguments))return;var H=R.currentTarget,ne=j(this,G,!0).event(R),Y=pn(R.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",ae,!0),L=Tn(R,H),K=R.clientX,I=R.clientY;yk(R.view),hc(R),ne.mouse=[L,this.__zoom.invert(L)],Oa(this),ne.start();function F(q){if(jo(q),!ne.moved){var V=q.clientX-K,Q=q.clientY-I;ne.moved=V*V+Q*Q>_}ne.event(q).zoom("mouse",i(T(ne.that.__zoom,ne.mouse[0]=Tn(q,H),ne.mouse[1]),ne.extent,l))}function ae(q){Y.on("mousemove.zoom mouseup.zoom",null),wk(q.view,ne.moved),jo(q),ne.event(q).end()}}function B(R,...G){if(e.apply(this,arguments)){var H=this.__zoom,ne=Tn(R.changedTouches?R.changedTouches[0]:R,this),Y=H.invert(ne),L=H.k*(R.shiftKey?.5:2),K=i(T(k(H,L),ne,Y),r.apply(this,G),l);jo(R),c>0?pn(this).transition().duration(c).call(A,K,ne,R):pn(this).call(x.transform,K,ne,R)}}function U(R,...G){if(e.apply(this,arguments)){var H=R.touches,ne=H.length,Y=j(this,G,R.changedTouches.length===ne).event(R),L,K,I,F;for(hc(R),K=0;K<ne;++K)I=H[K],F=Tn(I,this),F=[F,this.__zoom.invert(F),I.identifier],Y.touch0?!Y.touch1&&Y.touch0[2]!==F[2]&&(Y.touch1=F,Y.taps=0):(Y.touch0=F,L=!0,Y.taps=1+!!h);h&&(h=clearTimeout(h)),L&&(Y.taps<2&&(v=F[0],h=setTimeout(function(){h=null},w)),Oa(this),Y.start())}}function ee(R,...G){if(this.__zooming){var H=j(this,G).event(R),ne=R.changedTouches,Y=ne.length,L,K,I,F;for(jo(R),L=0;L<Y;++L)K=ne[L],I=Tn(K,this),H.touch0&&H.touch0[2]===K.identifier?H.touch0[0]=I:H.touch1&&H.touch1[2]===K.identifier&&(H.touch1[0]=I);if(K=H.that.__zoom,H.touch1){var ae=H.touch0[0],q=H.touch0[1],V=H.touch1[0],Q=H.touch1[1],re=(re=V[0]-ae[0])*re+(re=V[1]-ae[1])*re,ce=(ce=Q[0]-q[0])*ce+(ce=Q[1]-q[1])*ce;K=k(K,Math.sqrt(re/ce)),I=[(ae[0]+V[0])/2,(ae[1]+V[1])/2],F=[(q[0]+Q[0])/2,(q[1]+Q[1])/2]}else if(H.touch0)I=H.touch0[0],F=H.touch0[1];else return;H.zoom("touch",i(T(K,I,F),H.extent,l))}}function X(R,...G){if(this.__zooming){var H=j(this,G).event(R),ne=R.changedTouches,Y=ne.length,L,K;for(hc(R),g&&clearTimeout(g),g=setTimeout(function(){g=null},w),L=0;L<Y;++L)K=ne[L],H.touch0&&H.touch0[2]===K.identifier?delete H.touch0:H.touch1&&H.touch1[2]===K.identifier&&delete H.touch1;if(H.touch1&&!H.touch0&&(H.touch0=H.touch1,delete H.touch1),H.touch0)H.touch0[1]=this.__zoom.invert(H.touch0[0]);else if(H.end(),H.taps===2&&(K=Tn(K,this),Math.hypot(v[0]-K[0],v[1]-K[1])<E)){var I=pn(this).on("dblclick.zoom");I&&I.apply(this,arguments)}}}return x.wheelDelta=function(R){return arguments.length?(o=typeof R=="function"?R:Ca(+R),x):o},x.filter=function(R){return arguments.length?(e=typeof R=="function"?R:Ca(!!R),x):e},x.touchable=function(R){return arguments.length?(s=typeof R=="function"?R:Ca(!!R),x):s},x.extent=function(R){return arguments.length?(r=typeof R=="function"?R:Ca([[+R[0][0],+R[0][1]],[+R[1][0],+R[1][1]]]),x):r},x.scaleExtent=function(R){return arguments.length?(u[0]=+R[0],u[1]=+R[1],x):[u[0],u[1]]},x.translateExtent=function(R){return arguments.length?(l[0][0]=+R[0][0],l[1][0]=+R[1][0],l[0][1]=+R[0][1],l[1][1]=+R[1][1],x):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},x.constrain=function(R){return arguments.length?(i=R,x):i},x.duration=function(R){return arguments.length?(c=+R,x):c},x.interpolate=function(R){return arguments.length?(d=R,x):d},x.on=function(){var R=p.on.apply(p,arguments);return R===p?x:R},x.clickDistance=function(R){return arguments.length?(_=(R=+R)*R,x):Math.sqrt(_)},x.tapDistance=function(R){return arguments.length?(E=+R,x):E},x}ik();const Za=D.createContext(null),EI=Za.Provider,nr={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,r)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?r.targetHandle:r.sourceHandle}", edge id: ${r.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.`},Pk=nr.error001();function Fe(e,r){const i=D.useContext(Za);if(i===null)throw new Error(Pk);return ok(i,e,r)}const _t=()=>{const e=D.useContext(Za);if(e===null)throw new Error(Pk);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},kI=e=>e.userSelectionActive?"none":"all";function vv({position:e,children:r,className:i,style:o,...s}){const u=Fe(kI),l=`${e}`.split("-");return ie.createElement("div",{className:jt(["react-flow__panel",i,...l]),style:{...o,pointerEvents:u},...s},r)}function bI({proOptions:e,position:r="bottom-right"}){return e!=null&&e.hideAttribution?null:ie.createElement(vv,{position:r,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},ie.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const NI=({x:e,y:r,label:i,labelStyle:o={},labelShowBg:s=!0,labelBgStyle:u={},labelBgPadding:l=[2,4],labelBgBorderRadius:c=2,children:d,className:p,...h})=>{const v=D.useRef(null),[g,w]=D.useState({x:0,y:0,width:0,height:0}),N=jt(["react-flow__edge-textwrapper",p]);return D.useEffect(()=>{if(v.current){const _=v.current.getBBox();w({x:_.x,y:_.y,width:_.width,height:_.height})}},[i]),typeof i>"u"||!i?null:ie.createElement("g",{transform:`translate(${e-g.width/2} ${r-g.height/2})`,className:N,visibility:g.width?"visible":"hidden",...h},s&&ie.createElement("rect",{width:g.width+2*l[0],x:-l[0],y:-l[1],height:g.height+2*l[1],className:"react-flow__edge-textbg",style:u,rx:c,ry:c}),ie.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:v,style:o},i),d)};var CI=D.memo(NI);const gv=e=>({width:e.offsetWidth,height:e.offsetHeight}),Di=(e,r=0,i=1)=>Math.min(Math.max(e,r),i),yv=(e={x:0,y:0},r)=>({x:Di(e.x,r[0][0],r[1][0]),y:Di(e.y,r[0][1],r[1][1])}),Z0=(e,r,i)=>e<r?Di(Math.abs(e-r),1,50)/50:e>i?-Di(Math.abs(e-i),1,50)/50:0,qk=(e,r)=>{const i=Z0(e.x,35,r.width-35)*20,o=Z0(e.y,35,r.height-35)*20;return[i,o]},Ok=e=>{var r;return((r=e.getRootNode)==null?void 0:r.call(e))||(window==null?void 0:window.document)},Lk=(e,r)=>({x:Math.min(e.x,r.x),y:Math.min(e.y,r.y),x2:Math.max(e.x2,r.x2),y2:Math.max(e.y2,r.y2)}),Ko=({x:e,y:r,width:i,height:o})=>({x:e,y:r,x2:e+i,y2:r+o}),$k=({x:e,y:r,x2:i,y2:o})=>({x:e,y:r,width:i-e,height:o-r}),J0=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),TI=(e,r)=>$k(Lk(Ko(e),Ko(r))),Km=(e,r)=>{const i=Math.max(0,Math.min(e.x+e.width,r.x+r.width)-Math.max(e.x,r.x)),o=Math.max(0,Math.min(e.y+e.height,r.y+r.height)-Math.max(e.y,r.y));return Math.ceil(i*o)},RI=e=>mn(e.width)&&mn(e.height)&&mn(e.x)&&mn(e.y),mn=e=>!isNaN(e)&&isFinite(e),ut=Symbol.for("internals"),Dk=["Enter"," ","Escape"],AI=(e,r)=>{},II=e=>"nativeEvent"in e;function Ym(e){var s,u;const r=II(e)?e.nativeEvent:e,i=((u=(s=r.composedPath)==null?void 0:s.call(r))==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 Fk=e=>"clientX"in e,Rr=(e,r)=>{var u,l;const i=Fk(e),o=i?e.clientX:(u=e.touches)==null?void 0:u[0].clientX,s=i?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:o-((r==null?void 0:r.left)??0),y:s-((r==null?void 0:r.top)??0)}},Ua=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},es=({id:e,path:r,labelX:i,labelY:o,label:s,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:p,style:h,markerEnd:v,markerStart:g,interactionWidth:w=20})=>ie.createElement(ie.Fragment,null,ie.createElement("path",{id:e,style:h,d:r,fill:"none",className:"react-flow__edge-path",markerEnd:v,markerStart:g}),w&&ie.createElement("path",{d:r,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),s&&mn(i)&&mn(o)?ie.createElement(CI,{x:i,y:o,label:s,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:p}):null);es.displayName="BaseEdge";function Mo(e,r,i){return i===void 0?i:o=>{const s=r().edges.find(u=>u.id===e);s&&i(o,{...s})}}function zk({sourceX:e,sourceY:r,targetX:i,targetY:o}){const s=Math.abs(i-e)/2,u=i<e?i+s:i-s,l=Math.abs(o-r)/2,c=o<r?o+l:o-l;return[u,c,s,l]}function Bk({sourceX:e,sourceY:r,targetX:i,targetY:o,sourceControlX:s,sourceControlY:u,targetControlX:l,targetControlY:c}){const d=e*.125+s*.375+l*.375+i*.125,p=r*.125+u*.375+c*.375+o*.125,h=Math.abs(d-e),v=Math.abs(p-r);return[d,p,h,v]}var Zr;(function(e){e.Strict="strict",e.Loose="loose"})(Zr||(Zr={}));var Kr;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Kr||(Kr={}));var Yo;(function(e){e.Partial="partial",e.Full="full"})(Yo||(Yo={}));var Tr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Tr||(Tr={}));var Ha;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ha||(Ha={}));var ke;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ke||(ke={}));function ew({pos:e,x1:r,y1:i,x2:o,y2:s}){return e===ke.Left||e===ke.Right?[.5*(r+o),i]:[r,.5*(i+s)]}function Uk({sourceX:e,sourceY:r,sourcePosition:i=ke.Bottom,targetX:o,targetY:s,targetPosition:u=ke.Top}){const[l,c]=ew({pos:i,x1:e,y1:r,x2:o,y2:s}),[d,p]=ew({pos:u,x1:o,y1:s,x2:e,y2:r}),[h,v,g,w]=Bk({sourceX:e,sourceY:r,targetX:o,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:p});return[`M${e},${r} C${l},${c} ${d},${p} ${o},${s}`,h,v,g,w]}const wv=D.memo(({sourceX:e,sourceY:r,targetX:i,targetY:o,sourcePosition:s=ke.Bottom,targetPosition:u=ke.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:v,style:g,markerEnd:w,markerStart:N,interactionWidth:_})=>{const[E,x,k]=Uk({sourceX:e,sourceY:r,sourcePosition:s,targetX:i,targetY:o,targetPosition:u});return ie.createElement(es,{path:E,labelX:x,labelY:k,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:v,style:g,markerEnd:w,markerStart:N,interactionWidth:_})});wv.displayName="SimpleBezierEdge";const tw={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},jI=({source:e,sourcePosition:r=ke.Bottom,target:i})=>r===ke.Left||r===ke.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},nw=(e,r)=>Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2));function MI({source:e,sourcePosition:r=ke.Bottom,target:i,targetPosition:o=ke.Top,center:s,offset:u}){const l=tw[r],c=tw[o],d={x:e.x+l.x*u,y:e.y+l.y*u},p={x:i.x+c.x*u,y:i.y+c.y*u},h=jI({source:d,sourcePosition:r,target:p}),v=h.x!==0?"x":"y",g=h[v];let w=[],N,_;const E={x:0,y:0},x={x:0,y:0},[k,T,C,A]=zk({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(l[v]*c[v]===-1){N=s.x??k,_=s.y??T;const M=[{x:N,y:d.y},{x:N,y:p.y}],z=[{x:d.x,y:_},{x:p.x,y:_}];l[v]===g?w=v==="x"?M:z:w=v==="x"?z:M}else{const M=[{x:d.x,y:p.y}],z=[{x:p.x,y:d.y}];if(v==="x"?w=l.x===g?z:M:w=l.y===g?M:z,r===o){const X=Math.abs(e[v]-i[v]);if(X<=u){const R=Math.min(u-1,u-X);l[v]===g?E[v]=(d[v]>e[v]?-1:1)*R:x[v]=(p[v]>i[v]?-1:1)*R}}if(r!==o){const X=v==="x"?"y":"x",R=l[v]===c[X],G=d[X]>p[X],H=d[X]<p[X];(l[v]===1&&(!R&&G||R&&H)||l[v]!==1&&(!R&&H||R&&G))&&(w=v==="x"?M:z)}const O={x:d.x+E.x,y:d.y+E.y},B={x:p.x+x.x,y:p.y+x.y},U=Math.max(Math.abs(O.x-w[0].x),Math.abs(B.x-w[0].x)),ee=Math.max(Math.abs(O.y-w[0].y),Math.abs(B.y-w[0].y));U>=ee?(N=(O.x+B.x)/2,_=w[0].y):(N=w[0].x,_=(O.y+B.y)/2)}return[[e,{x:d.x+E.x,y:d.y+E.y},...w,{x:p.x+x.x,y:p.y+x.y},i],N,_,C,A]}function PI(e,r,i,o){const s=Math.min(nw(e,r)/2,nw(r,i)/2,o),{x:u,y:l}=r;if(e.x===u&&u===i.x||e.y===l&&l===i.y)return`L${u} ${l}`;if(e.y===l){const p=e.x<i.x?-1:1,h=e.y<i.y?1:-1;return`L ${u+s*p},${l}Q ${u},${l} ${u},${l+s*h}`}const c=e.x<i.x?1:-1,d=e.y<i.y?-1:1;return`L ${u},${l+s*d}Q ${u},${l} ${u+s*c},${l}`}function Xm({sourceX:e,sourceY:r,sourcePosition:i=ke.Bottom,targetX:o,targetY:s,targetPosition:u=ke.Top,borderRadius:l=5,centerX:c,centerY:d,offset:p=20}){const[h,v,g,w,N]=MI({source:{x:e,y:r},sourcePosition:i,target:{x:o,y:s},targetPosition:u,center:{x:c,y:d},offset:p});return[h.reduce((E,x,k)=>{let T="";return k>0&&k<h.length-1?T=PI(h[k-1],x,h[k+1],l):T=`${k===0?"M":"L"}${x.x} ${x.y}`,E+=T,E},""),v,g,w,N]}const Ja=D.memo(({sourceX:e,sourceY:r,targetX:i,targetY:o,label:s,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:p,style:h,sourcePosition:v=ke.Bottom,targetPosition:g=ke.Top,markerEnd:w,markerStart:N,pathOptions:_,interactionWidth:E})=>{const[x,k,T]=Xm({sourceX:e,sourceY:r,sourcePosition:v,targetX:i,targetY:o,targetPosition:g,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return ie.createElement(es,{path:x,labelX:k,labelY:T,label:s,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:p,style:h,markerEnd:w,markerStart:N,interactionWidth:E})});Ja.displayName="SmoothStepEdge";const _v=D.memo(e=>{var r;return ie.createElement(Ja,{...e,pathOptions:D.useMemo(()=>{var i;return{borderRadius:0,offset:(i=e.pathOptions)==null?void 0:i.offset}},[(r=e.pathOptions)==null?void 0:r.offset])})});_v.displayName="StepEdge";function qI({sourceX:e,sourceY:r,targetX:i,targetY:o}){const[s,u,l,c]=zk({sourceX:e,sourceY:r,targetX:i,targetY:o});return[`M ${e},${r}L ${i},${o}`,s,u,l,c]}const xv=D.memo(({sourceX:e,sourceY:r,targetX:i,targetY:o,label:s,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:p,style:h,markerEnd:v,markerStart:g,interactionWidth:w})=>{const[N,_,E]=qI({sourceX:e,sourceY:r,targetX:i,targetY:o});return ie.createElement(es,{path:N,labelX:_,labelY:E,label:s,labelStyle:u,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:p,style:h,markerEnd:v,markerStart:g,interactionWidth:w})});xv.displayName="StraightEdge";function Ta(e,r){return e>=0?.5*e:r*25*Math.sqrt(-e)}function rw({pos:e,x1:r,y1:i,x2:o,y2:s,c:u}){switch(e){case ke.Left:return[r-Ta(r-o,u),i];case ke.Right:return[r+Ta(o-r,u),i];case ke.Top:return[r,i-Ta(i-s,u)];case ke.Bottom:return[r,i+Ta(s-i,u)]}}function Hk({sourceX:e,sourceY:r,sourcePosition:i=ke.Bottom,targetX:o,targetY:s,targetPosition:u=ke.Top,curvature:l=.25}){const[c,d]=rw({pos:i,x1:e,y1:r,x2:o,y2:s,c:l}),[p,h]=rw({pos:u,x1:o,y1:s,x2:e,y2:r,c:l}),[v,g,w,N]=Bk({sourceX:e,sourceY:r,targetX:o,targetY:s,sourceControlX:c,sourceControlY:d,targetControlX:p,targetControlY:h});return[`M${e},${r} C${c},${d} ${p},${h} ${o},${s}`,v,g,w,N]}const Va=D.memo(({sourceX:e,sourceY:r,targetX:i,targetY:o,sourcePosition:s=ke.Bottom,targetPosition:u=ke.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:v,style:g,markerEnd:w,markerStart:N,pathOptions:_,interactionWidth:E})=>{const[x,k,T]=Hk({sourceX:e,sourceY:r,sourcePosition:s,targetX:i,targetY:o,targetPosition:u,curvature:_==null?void 0:_.curvature});return ie.createElement(es,{path:x,labelX:k,labelY:T,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:v,style:g,markerEnd:w,markerStart:N,interactionWidth:E})});Va.displayName="BezierEdge";const Sv=D.createContext(null),OI=Sv.Provider;Sv.Consumer;const LI=()=>D.useContext(Sv),$I=e=>"id"in e&&"source"in e&&"target"in e,DI=({source:e,sourceHandle:r,target:i,targetHandle:o})=>`reactflow__edge-${e}${r||""}-${i}${o||""}`,Qm=(e,r)=>typeof e>"u"?"":typeof e=="string"?e:`${r?`${r}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`,FI=(e,r)=>r.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)),zI=(e,r)=>{if(!e.source||!e.target)return r;let i;return $I(e)?i={...e}:i={...e,id:DI(e)},FI(i,r)?r:r.concat(i)},Zm=({x:e,y:r},[i,o,s],u,[l,c])=>{const d={x:(e-i)/s,y:(r-o)/s};return u?{x:l*Math.round(d.x/l),y:c*Math.round(d.y/c)}:d},Vk=({x:e,y:r},[i,o,s])=>({x:e*s+i,y:r*s+o}),Xr=(e,r=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const i=(e.width??0)*r[0],o=(e.height??0)*r[1],s={x:e.position.x-i,y:e.position.y-o};return{...s,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-i,y:e.positionAbsolute.y-o}:s}},eu=(e,r=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const i=e.reduce((o,s)=>{const{x:u,y:l}=Xr(s,r).positionAbsolute;return Lk(o,Ko({x:u,y:l,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return $k(i)},Wk=(e,r,[i,o,s]=[0,0,1],u=!1,l=!1,c=[0,0])=>{const d={x:(r.x-i)/s,y:(r.y-o)/s,width:r.width/s,height:r.height/s},p=[];return e.forEach(h=>{const{width:v,height:g,selectable:w=!0,hidden:N=!1}=h;if(l&&!w||N)return!1;const{positionAbsolute:_}=Xr(h,c),E={x:_.x,y:_.y,width:v||0,height:g||0},x=Km(d,E),k=typeof v>"u"||typeof g>"u"||v===null||g===null,T=u&&x>0,C=(v||0)*(g||0);(k||T||x>=C||h.dragging)&&p.push(h)}),p},Gk=(e,r)=>{const i=e.map(o=>o.id);return r.filter(o=>i.includes(o.source)||i.includes(o.target))},Kk=(e,r,i,o,s,u=.1)=>{const l=r/(e.width*(1+u)),c=i/(e.height*(1+u)),d=Math.min(l,c),p=Di(d,o,s),h=e.x+e.width/2,v=e.y+e.height/2,g=r/2-h*p,w=i/2-v*p;return{x:g,y:w,zoom:p}},Wr=(e,r=0)=>e.transition().duration(r);function iw(e,r,i,o){return(r[i]||[]).reduce((s,u)=>{var l,c;return`${e.id}-${u.id}-${i}`!==o&&s.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}),s},[])}function BI(e,r,i,o,s,u){const{x:l,y:c}=Rr(e),p=r.elementsFromPoint(l,c).find(N=>N.classList.contains("react-flow__handle"));if(p){const N=p.getAttribute("data-nodeid");if(N){const _=Ev(void 0,p),E=p.getAttribute("data-handleid"),x=u({nodeId:N,id:E,type:_});if(x){const k=s.find(T=>T.nodeId===N&&T.type===_&&T.id===E);return{handle:{id:E,type:_,nodeId:N,x:(k==null?void 0:k.x)||i.x,y:(k==null?void 0:k.y)||i.y},validHandleResult:x}}}}let h=[],v=1/0;if(s.forEach(N=>{const _=Math.sqrt((N.x-i.x)**2+(N.y-i.y)**2);if(_<=o){const E=u(N);_<=v&&(_<v?h=[{handle:N,validHandleResult:E}]:_===v&&h.push({handle:N,validHandleResult:E}),v=_)}}),!h.length)return{handle:null,validHandleResult:Yk()};if(h.length===1)return h[0];const g=h.some(({validHandleResult:N})=>N.isValid),w=h.some(({handle:N})=>N.type==="target");return h.find(({handle:N,validHandleResult:_})=>w?N.type==="target":g?_.isValid:!0)||h[0]}const UI={source:null,target:null,sourceHandle:null,targetHandle:null},Yk=()=>({handleDomNode:null,isValid:!1,connection:UI,endHandle:null});function Xk(e,r,i,o,s,u,l){const c=s==="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}"]`),p={...Yk(),handleDomNode:d};if(d){const h=Ev(void 0,d),v=d.getAttribute("data-nodeid"),g=d.getAttribute("data-handleid"),w=d.classList.contains("connectable"),N=d.classList.contains("connectableend"),_={source:c?v:i,sourceHandle:c?g:o,target:c?i:v,targetHandle:c?o:g};p.connection=_,w&&N&&(r===Zr.Strict?c&&h==="source"||!c&&h==="target":v!==i||g!==o)&&(p.endHandle={nodeId:v,handleId:g,type:h},p.isValid=u(_))}return p}function HI({nodes:e,nodeId:r,handleId:i,handleType:o}){return e.reduce((s,u)=>{if(u[ut]){const{handleBounds:l}=u[ut];let c=[],d=[];l&&(c=iw(u,l,"source",`${r}-${i}-${o}`),d=iw(u,l,"target",`${r}-${i}-${o}`)),s.push(...c,...d)}return s},[])}function Ev(e,r){return e||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function pc(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function VI(e,r){let i=null;return r?i="valid":e&&!r&&(i="invalid"),i}function Qk({event:e,handleId:r,nodeId:i,onConnect:o,isTarget:s,getState:u,setState:l,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:p}){const h=Ok(e.target),{connectionMode:v,domNode:g,autoPanOnConnect:w,connectionRadius:N,onConnectStart:_,panBy:E,getNodes:x,cancelConnection:k}=u();let T=0,C;const{x:A,y:j}=Rr(e),M=h==null?void 0:h.elementFromPoint(A,j),z=Ev(d,M),O=g==null?void 0:g.getBoundingClientRect();if(!O||!z)return;let B,U=Rr(e,O),ee=!1,X=null,R=!1,G=null;const H=HI({nodes:x(),nodeId:i,handleId:r,handleType:z}),ne=()=>{if(!w)return;const[K,I]=qk(U,O);E({x:K,y:I}),T=requestAnimationFrame(ne)};l({connectionPosition:U,connectionStatus:null,connectionNodeId:i,connectionHandleId:r,connectionHandleType:z,connectionStartHandle:{nodeId:i,handleId:r,type:z},connectionEndHandle:null}),_==null||_(e,{nodeId:i,handleId:r,handleType:z});function Y(K){const{transform:I}=u();U=Rr(K,O);const{handle:F,validHandleResult:ae}=BI(K,h,Zm(U,I,!1,[1,1]),N,H,q=>Xk(q,v,i,r,s?"target":"source",c,h));if(C=F,ee||(ne(),ee=!0),G=ae.handleDomNode,X=ae.connection,R=ae.isValid,l({connectionPosition:C&&R?Vk({x:C.x,y:C.y},I):U,connectionStatus:VI(!!C,R),connectionEndHandle:ae.endHandle}),!C&&!R&&!G)return pc(B);X.source!==X.target&&G&&(pc(B),B=G,G.classList.add("connecting","react-flow__handle-connecting"),G.classList.toggle("valid",R),G.classList.toggle("react-flow__handle-valid",R))}function L(K){var I,F;(C||G)&&X&&R&&(o==null||o(X)),(F=(I=u()).onConnectEnd)==null||F.call(I,K),d&&(p==null||p(K)),pc(B),k(),cancelAnimationFrame(T),ee=!1,R=!1,X=null,G=null,h.removeEventListener("mousemove",Y),h.removeEventListener("mouseup",L),h.removeEventListener("touchmove",Y),h.removeEventListener("touchend",L)}h.addEventListener("mousemove",Y),h.addEventListener("mouseup",L),h.addEventListener("touchmove",Y),h.addEventListener("touchend",L)}const ow=()=>!0,WI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),GI=(e,r,i)=>o=>{const{connectionStartHandle:s,connectionEndHandle:u,connectionClickStartHandle:l}=o;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===r&&(s==null?void 0:s.type)===i||(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===r&&(u==null?void 0:u.type)===i,clickConnecting:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===r&&(l==null?void 0:l.type)===i}},Zk=D.forwardRef(({type:e="source",position:r=ke.Top,isValidConnection:i,isConnectable:o=!0,isConnectableStart:s=!0,isConnectableEnd:u=!0,id:l,onConnect:c,children:d,className:p,onMouseDown:h,onTouchStart:v,...g},w)=>{var O,B;const N=l||null,_=e==="target",E=_t(),x=LI(),{connectOnClick:k,noPanClassName:T}=Fe(WI,wt),{connecting:C,clickConnecting:A}=Fe(GI(x,N,e),wt);x||(B=(O=E.getState()).onError)==null||B.call(O,"010",nr.error010());const j=U=>{const{defaultEdgeOptions:ee,onConnect:X,hasDefaultEdges:R}=E.getState(),G={...ee,...U};if(R){const{edges:H,setEdges:ne}=E.getState();ne(zI(G,H))}X==null||X(G),c==null||c(G)},M=U=>{if(!x)return;const ee=Fk(U);s&&(ee&&U.button===0||!ee)&&Qk({event:U,handleId:N,nodeId:x,onConnect:j,isTarget:_,getState:E.getState,setState:E.setState,isValidConnection:i||E.getState().isValidConnection||ow}),ee?h==null||h(U):v==null||v(U)},z=U=>{const{onClickConnectStart:ee,onClickConnectEnd:X,connectionClickStartHandle:R,connectionMode:G,isValidConnection:H}=E.getState();if(!x||!R&&!s)return;if(!R){ee==null||ee(U,{nodeId:x,handleId:N,handleType:e}),E.setState({connectionClickStartHandle:{nodeId:x,type:e,handleId:N}});return}const ne=Ok(U.target),Y=i||H||ow,{connection:L,isValid:K}=Xk({nodeId:x,id:N,type:e},G,R.nodeId,R.handleId||null,R.type,Y,ne);K&&j(L),X==null||X(U),E.setState({connectionClickStartHandle:null})};return ie.createElement("div",{"data-handleid":N,"data-nodeid":x,"data-handlepos":r,"data-id":`${x}-${N}-${e}`,className:jt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",T,p,{source:!_,target:_,connectable:o,connectablestart:s,connectableend:u,connecting:A,connectionindicator:o&&(s&&!C||u&&C)}]),onMouseDown:M,onTouchStart:M,onClick:k?z:void 0,ref:w,...g},d)});Zk.displayName="Handle";var Fi=D.memo(Zk);const Jk=({data:e,isConnectable:r,targetPosition:i=ke.Top,sourcePosition:o=ke.Bottom})=>ie.createElement(ie.Fragment,null,ie.createElement(Fi,{type:"target",position:i,isConnectable:r}),e==null?void 0:e.label,ie.createElement(Fi,{type:"source",position:o,isConnectable:r}));Jk.displayName="DefaultNode";var Jm=D.memo(Jk);const eb=({data:e,isConnectable:r,sourcePosition:i=ke.Bottom})=>ie.createElement(ie.Fragment,null,e==null?void 0:e.label,ie.createElement(Fi,{type:"source",position:i,isConnectable:r}));eb.displayName="InputNode";var tb=D.memo(eb);const nb=({data:e,isConnectable:r,targetPosition:i=ke.Top})=>ie.createElement(ie.Fragment,null,ie.createElement(Fi,{type:"target",position:i,isConnectable:r}),e==null?void 0:e.label);nb.displayName="OutputNode";var rb=D.memo(nb);const kv=()=>null;kv.displayName="GroupNode";const KI=e=>({selectedNodes:e.getNodes().filter(r=>r.selected),selectedEdges:e.edges.filter(r=>r.selected).map(r=>({...r}))}),Ra=e=>e.id;function YI(e,r){return wt(e.selectedNodes.map(Ra),r.selectedNodes.map(Ra))&&wt(e.selectedEdges.map(Ra),r.selectedEdges.map(Ra))}const ib=D.memo(({onSelectionChange:e})=>{const r=_t(),{selectedNodes:i,selectedEdges:o}=Fe(KI,YI);return D.useEffect(()=>{const s={nodes:i,edges:o};e==null||e(s),r.getState().onSelectionChange.forEach(u=>u(s))},[i,o,e]),null});ib.displayName="SelectionListener";const XI=e=>!!e.onSelectionChange;function QI({onSelectionChange:e}){const r=Fe(XI);return e||r?ie.createElement(ib,{onSelectionChange:e}):null}const ZI=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 Ci(e,r){D.useEffect(()=>{typeof e<"u"&&r(e)},[e])}function qe(e,r,i){D.useEffect(()=>{typeof r<"u"&&i({[e]:r})},[r])}const JI=({nodes:e,edges:r,defaultNodes:i,defaultEdges:o,onConnect:s,onConnectStart:u,onConnectEnd:l,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:p,nodesConnectable:h,nodesFocusable:v,edgesFocusable:g,edgesUpdatable:w,elevateNodesOnSelect:N,minZoom:_,maxZoom:E,nodeExtent:x,onNodesChange:k,onEdgesChange:T,elementsSelectable:C,connectionMode:A,snapGrid:j,snapToGrid:M,translateExtent:z,connectOnClick:O,defaultEdgeOptions:B,fitView:U,fitViewOptions:ee,onNodesDelete:X,onEdgesDelete:R,onNodeDrag:G,onNodeDragStart:H,onNodeDragStop:ne,onSelectionDrag:Y,onSelectionDragStart:L,onSelectionDragStop:K,noPanClassName:I,nodeOrigin:F,rfId:ae,autoPanOnConnect:q,autoPanOnNodeDrag:V,onError:Q,connectionRadius:re,isValidConnection:ce,nodeDragThreshold:he})=>{const{setNodes:pe,setEdges:je,setDefaultNodesAndEdges:$e,setMinZoom:Me,setMaxZoom:Ae,setTranslateExtent:we,setNodeExtent:Be,reset:ve}=Fe(ZI,wt),ge=_t();return D.useEffect(()=>{const ze=o==null?void 0:o.map(et=>({...et,...B}));return $e(i,ze),()=>{ve()}},[]),qe("defaultEdgeOptions",B,ge.setState),qe("connectionMode",A,ge.setState),qe("onConnect",s,ge.setState),qe("onConnectStart",u,ge.setState),qe("onConnectEnd",l,ge.setState),qe("onClickConnectStart",c,ge.setState),qe("onClickConnectEnd",d,ge.setState),qe("nodesDraggable",p,ge.setState),qe("nodesConnectable",h,ge.setState),qe("nodesFocusable",v,ge.setState),qe("edgesFocusable",g,ge.setState),qe("edgesUpdatable",w,ge.setState),qe("elementsSelectable",C,ge.setState),qe("elevateNodesOnSelect",N,ge.setState),qe("snapToGrid",M,ge.setState),qe("snapGrid",j,ge.setState),qe("onNodesChange",k,ge.setState),qe("onEdgesChange",T,ge.setState),qe("connectOnClick",O,ge.setState),qe("fitViewOnInit",U,ge.setState),qe("fitViewOnInitOptions",ee,ge.setState),qe("onNodesDelete",X,ge.setState),qe("onEdgesDelete",R,ge.setState),qe("onNodeDrag",G,ge.setState),qe("onNodeDragStart",H,ge.setState),qe("onNodeDragStop",ne,ge.setState),qe("onSelectionDrag",Y,ge.setState),qe("onSelectionDragStart",L,ge.setState),qe("onSelectionDragStop",K,ge.setState),qe("noPanClassName",I,ge.setState),qe("nodeOrigin",F,ge.setState),qe("rfId",ae,ge.setState),qe("autoPanOnConnect",q,ge.setState),qe("autoPanOnNodeDrag",V,ge.setState),qe("onError",Q,ge.setState),qe("connectionRadius",re,ge.setState),qe("isValidConnection",ce,ge.setState),qe("nodeDragThreshold",he,ge.setState),Ci(e,pe),Ci(r,je),Ci(_,Me),Ci(E,Ae),Ci(z,we),Ci(x,Be),null},sw={display:"none"},ej={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ob="react-flow__node-desc",sb="react-flow__edge-desc",tj="react-flow__aria-live",nj=e=>e.ariaLiveMessage;function rj({rfId:e}){const r=Fe(nj);return ie.createElement("div",{id:`${tj}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ej},r)}function ij({rfId:e,disableKeyboardA11y:r}){return ie.createElement(ie.Fragment,null,ie.createElement("div",{id:`${ob}-${e}`,style:sw},"Press enter or space to select a node.",!r&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),ie.createElement("div",{id:`${sb}-${e}`,style:sw},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!r&&ie.createElement(rj,{rfId:e}))}var Xo=(e=null,r={actInsideInputWithModifier:!0})=>{const[i,o]=D.useState(!1),s=D.useRef(!1),u=D.useRef(new Set([])),[l,c]=D.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(v=>typeof v=="string").map(v=>v.split("+")),h=p.reduce((v,g)=>v.concat(...g),[]);return[p,h]}return[[],[]]},[e]);return D.useEffect(()=>{const d=typeof document<"u"?document:null,p=(r==null?void 0:r.target)||d;if(e!==null){const h=w=>{if(s.current=w.ctrlKey||w.metaKey||w.shiftKey,(!s.current||s.current&&!r.actInsideInputWithModifier)&&Ym(w))return!1;const _=uw(w.code,c);u.current.add(w[_]),aw(l,u.current,!1)&&(w.preventDefault(),o(!0))},v=w=>{if((!s.current||s.current&&!r.actInsideInputWithModifier)&&Ym(w))return!1;const _=uw(w.code,c);aw(l,u.current,!0)?(o(!1),u.current.clear()):u.current.delete(w[_]),w.key==="Meta"&&u.current.clear(),s.current=!1},g=()=>{u.current.clear(),o(!1)};return p==null||p.addEventListener("keydown",h),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",g),()=>{p==null||p.removeEventListener("keydown",h),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",g)}}},[e,o]),i};function aw(e,r,i){return e.filter(o=>i||o.length===r.size).some(o=>o.every(s=>r.has(s)))}function uw(e,r){return r.includes(e)?"code":"key"}function ab(e,r,i,o){var c,d;const s=e.parentNode||e.parentId;if(!s)return i;const u=r.get(s),l=Xr(u,o);return ab(u,r,{x:(i.x??0)+l.x,y:(i.y??0)+l.y,z:(((c=u[ut])==null?void 0:c.z)??0)>(i.z??0)?((d=u[ut])==null?void 0:d.z)??0:i.z??0},o)}function ub(e,r,i){e.forEach(o=>{var u;const s=o.parentNode||o.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||i!=null&&i[o.id]){const{x:l,y:c,z:d}=ab(o,e,{...o.position,z:((u=o[ut])==null?void 0:u.z)??0},r);o.positionAbsolute={x:l,y:c},o[ut].z=d,i!=null&&i[o.id]&&(o[ut].isParent=!0)}})}function mc(e,r,i,o){const s=new Map,u={},l=o?1e3:0;return e.forEach(c=>{var w;const d=(mn(c.zIndex)?c.zIndex:0)+(c.selected?l:0),p=r.get(c.id),h={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},v=c.parentNode||c.parentId;v&&(u[v]=!0);const g=(p==null?void 0:p.type)&&(p==null?void 0:p.type)!==c.type;Object.defineProperty(h,ut,{enumerable:!1,value:{handleBounds:g||(w=p==null?void 0:p[ut])==null?void 0:w.handleBounds,z:d}}),s.set(c.id,h)}),ub(s,i,u),s}function lb(e,r={}){const{getNodes:i,width:o,height:s,minZoom:u,maxZoom:l,d3Zoom:c,d3Selection:d,fitViewOnInitDone:p,fitViewOnInit:h,nodeOrigin:v}=e(),g=r.initial&&!p&&h;if(c&&d&&(g||!r.initial)){const N=i().filter(E=>{var k;const x=r.includeHiddenNodes?E.width&&E.height:!E.hidden;return(k=r.nodes)!=null&&k.length?x&&r.nodes.some(T=>T.id===E.id):x}),_=N.every(E=>E.width&&E.height);if(N.length>0&&_){const E=eu(N,v),{x,y:k,zoom:T}=Kk(E,o,s,r.minZoom??u,r.maxZoom??l,r.padding??.1),C=er.translate(x,k).scale(T);return typeof r.duration=="number"&&r.duration>0?c.transform(Wr(d,r.duration),C):c.transform(d,C),!0}}return!1}function oj(e,r){return e.forEach(i=>{const o=r.get(i.id);o&&r.set(o.id,{...o,[ut]:o[ut],selected:i.selected})}),new Map(r)}function sj(e,r){return r.map(i=>{const o=e.find(s=>s.id===i.id);return o&&(i.selected=o.selected),i})}function Aa({changedNodes:e,changedEdges:r,get:i,set:o}){const{nodeInternals:s,edges:u,onNodesChange:l,onEdgesChange:c,hasDefaultNodes:d,hasDefaultEdges:p}=i();e!=null&&e.length&&(d&&o({nodeInternals:oj(e,s)}),l==null||l(e)),r!=null&&r.length&&(p&&o({edges:sj(r,u)}),c==null||c(r))}const Ti=()=>{},aj={zoomIn:Ti,zoomOut:Ti,zoomTo:Ti,getZoom:()=>1,setViewport:Ti,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ti,fitBounds:Ti,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},uj=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),lj=()=>{const e=_t(),{d3Zoom:r,d3Selection:i}=Fe(uj,wt);return D.useMemo(()=>i&&r?{zoomIn:s=>r.scaleBy(Wr(i,s==null?void 0:s.duration),1.2),zoomOut:s=>r.scaleBy(Wr(i,s==null?void 0:s.duration),1/1.2),zoomTo:(s,u)=>r.scaleTo(Wr(i,u==null?void 0:u.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,u)=>{const[l,c,d]=e.getState().transform,p=er.translate(s.x??l,s.y??c).scale(s.zoom??d);r.transform(Wr(i,u==null?void 0:u.duration),p)},getViewport:()=>{const[s,u,l]=e.getState().transform;return{x:s,y:u,zoom:l}},fitView:s=>lb(e.getState,s),setCenter:(s,u,l)=>{const{width:c,height:d,maxZoom:p}=e.getState(),h=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:p,v=c/2-s*h,g=d/2-u*h,w=er.translate(v,g).scale(h);r.transform(Wr(i,l==null?void 0:l.duration),w)},fitBounds:(s,u)=>{const{width:l,height:c,minZoom:d,maxZoom:p}=e.getState(),{x:h,y:v,zoom:g}=Kk(s,l,c,d,p,(u==null?void 0:u.padding)??.1),w=er.translate(h,v).scale(g);r.transform(Wr(i,u==null?void 0:u.duration),w)},project:s=>{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"),Zm(s,u,l,c)},screenToFlowPosition:s=>{const{transform:u,snapToGrid:l,snapGrid:c,domNode:d}=e.getState();if(!d)return s;const{x:p,y:h}=d.getBoundingClientRect(),v={x:s.x-p,y:s.y-h};return Zm(v,u,l,c)},flowToScreenPosition:s=>{const{transform:u,domNode:l}=e.getState();if(!l)return s;const{x:c,y:d}=l.getBoundingClientRect(),p=Vk(s,u);return{x:p.x+c,y:p.y+d}},viewportInitialized:!0}:aj,[r,i])};function ts(){const e=lj(),r=_t(),i=D.useCallback(()=>r.getState().getNodes().map(_=>({..._})),[]),o=D.useCallback(_=>r.getState().nodeInternals.get(_),[]),s=D.useCallback(()=>{const{edges:_=[]}=r.getState();return _.map(E=>({...E}))},[]),u=D.useCallback(_=>{const{edges:E=[]}=r.getState();return E.find(x=>x.id===_)},[]),l=D.useCallback(_=>{const{getNodes:E,setNodes:x,hasDefaultNodes:k,onNodesChange:T}=r.getState(),C=E(),A=typeof _=="function"?_(C):_;if(k)x(A);else if(T){const j=A.length===0?C.map(M=>({type:"remove",id:M.id})):A.map(M=>({item:M,type:"reset"}));T(j)}},[]),c=D.useCallback(_=>{const{edges:E=[],setEdges:x,hasDefaultEdges:k,onEdgesChange:T}=r.getState(),C=typeof _=="function"?_(E):_;if(k)x(C);else if(T){const A=C.length===0?E.map(j=>({type:"remove",id:j.id})):C.map(j=>({item:j,type:"reset"}));T(A)}},[]),d=D.useCallback(_=>{const E=Array.isArray(_)?_:[_],{getNodes:x,setNodes:k,hasDefaultNodes:T,onNodesChange:C}=r.getState();if(T){const j=[...x(),...E];k(j)}else if(C){const A=E.map(j=>({item:j,type:"add"}));C(A)}},[]),p=D.useCallback(_=>{const E=Array.isArray(_)?_:[_],{edges:x=[],setEdges:k,hasDefaultEdges:T,onEdgesChange:C}=r.getState();if(T)k([...x,...E]);else if(C){const A=E.map(j=>({item:j,type:"add"}));C(A)}},[]),h=D.useCallback(()=>{const{getNodes:_,edges:E=[],transform:x}=r.getState(),[k,T,C]=x;return{nodes:_().map(A=>({...A})),edges:E.map(A=>({...A})),viewport:{x:k,y:T,zoom:C}}},[]),v=D.useCallback(({nodes:_,edges:E})=>{const{nodeInternals:x,getNodes:k,edges:T,hasDefaultNodes:C,hasDefaultEdges:A,onNodesDelete:j,onEdgesDelete:M,onNodesChange:z,onEdgesChange:O}=r.getState(),B=(_||[]).map(G=>G.id),U=(E||[]).map(G=>G.id),ee=k().reduce((G,H)=>{const ne=H.parentNode||H.parentId,Y=!B.includes(H.id)&&ne&&G.find(K=>K.id===ne);return(typeof H.deletable=="boolean"?H.deletable:!0)&&(B.includes(H.id)||Y)&&G.push(H),G},[]),X=T.filter(G=>typeof G.deletable=="boolean"?G.deletable:!0),R=X.filter(G=>U.includes(G.id));if(ee||R){const G=Gk(ee,X),H=[...R,...G],ne=H.reduce((Y,L)=>(Y.includes(L.id)||Y.push(L.id),Y),[]);if((A||C)&&(A&&r.setState({edges:T.filter(Y=>!ne.includes(Y.id))}),C&&(ee.forEach(Y=>{x.delete(Y.id)}),r.setState({nodeInternals:new Map(x)}))),ne.length>0&&(M==null||M(H),O&&O(ne.map(Y=>({id:Y,type:"remove"})))),ee.length>0&&(j==null||j(ee),z)){const Y=ee.map(L=>({id:L.id,type:"remove"}));z(Y)}}},[]),g=D.useCallback(_=>{const E=RI(_),x=E?null:r.getState().nodeInternals.get(_.id);return!E&&!x?[null,null,E]:[E?_:J0(x),x,E]},[]),w=D.useCallback((_,E=!0,x)=>{const[k,T,C]=g(_);return k?(x||r.getState().getNodes()).filter(A=>{if(!C&&(A.id===T.id||!A.positionAbsolute))return!1;const j=J0(A),M=Km(j,k);return E&&M>0||M>=k.width*k.height}):[]},[]),N=D.useCallback((_,E,x=!0)=>{const[k]=g(_);if(!k)return!1;const T=Km(k,E);return x&&T>0||T>=k.width*k.height},[]);return D.useMemo(()=>({...e,getNodes:i,getNode:o,getEdges:s,getEdge:u,setNodes:l,setEdges:c,addNodes:d,addEdges:p,toObject:h,deleteElements:v,getIntersectingNodes:w,isNodeIntersecting:N}),[e,i,o,s,u,l,c,d,p,h,v,w,N])}const cj={actInsideInputWithModifier:!1};var fj=({deleteKeyCode:e,multiSelectionKeyCode:r})=>{const i=_t(),{deleteElements:o}=ts(),s=Xo(e,cj),u=Xo(r);D.useEffect(()=>{if(s){const{edges:l,getNodes:c}=i.getState(),d=c().filter(h=>h.selected),p=l.filter(h=>h.selected);o({nodes:d,edges:p}),i.setState({nodesSelectionActive:!1})}},[s]),D.useEffect(()=>{i.setState({multiSelectionActive:u})},[u])};function dj(e){const r=_t();D.useEffect(()=>{let i;const o=()=>{var u,l;if(!e.current)return;const s=gv(e.current);(s.height===0||s.width===0)&&((l=(u=r.getState()).onError)==null||l.call(u,"004",nr.error004())),r.setState({width:s.width||500,height:s.height||500})};return o(),window.addEventListener("resize",o),e.current&&(i=new ResizeObserver(()=>o()),i.observe(e.current)),()=>{window.removeEventListener("resize",o),i&&e.current&&i.unobserve(e.current)}},[])}const bv={position:"absolute",width:"100%",height:"100%",top:0,left:0},hj=(e,r)=>e.x!==r.x||e.y!==r.y||e.zoom!==r.k,Ia=e=>({x:e.x,y:e.y,zoom:e.k}),Ri=(e,r)=>e.target.closest(`.${r}`),lw=(e,r)=>r===2&&Array.isArray(e)&&e.includes(2),cw=e=>{const r=e.ctrlKey&&Ua()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*r},pj=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),mj=({onMove:e,onMoveStart:r,onMoveEnd:i,onPaneContextMenu:o,zoomOnScroll:s=!0,zoomOnPinch:u=!0,panOnScroll:l=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Kr.Free,zoomOnDoubleClick:p=!0,elementsSelectable:h,panOnDrag:v=!0,defaultViewport:g,translateExtent:w,minZoom:N,maxZoom:_,zoomActivationKeyCode:E,preventScrolling:x=!0,children:k,noWheelClassName:T,noPanClassName:C})=>{const A=D.useRef(),j=_t(),M=D.useRef(!1),z=D.useRef(!1),O=D.useRef(null),B=D.useRef({x:0,y:0,zoom:0}),{d3Zoom:U,d3Selection:ee,d3ZoomHandler:X,userSelectionActive:R}=Fe(pj,wt),G=Xo(E),H=D.useRef(0),ne=D.useRef(!1),Y=D.useRef();return dj(O),D.useEffect(()=>{if(O.current){const L=O.current.getBoundingClientRect(),K=Mk().scaleExtent([N,_]).translateExtent(w),I=pn(O.current).call(K),F=er.translate(g.x,g.y).scale(Di(g.zoom,N,_)),ae=[[0,0],[L.width,L.height]],q=K.constrain()(F,ae,w);K.transform(I,q),K.wheelDelta(cw),j.setState({d3Zoom:K,d3Selection:I,d3ZoomHandler:I.on("wheel.zoom"),transform:[q.x,q.y,q.k],domNode:O.current.closest(".react-flow")})}},[]),D.useEffect(()=>{ee&&U&&(l&&!G&&!R?ee.on("wheel.zoom",L=>{if(Ri(L,T))return!1;L.preventDefault(),L.stopImmediatePropagation();const K=ee.property("__zoom").k||1;if(L.ctrlKey&&u){const ce=Tn(L),he=cw(L),pe=K*Math.pow(2,he);U.scaleTo(ee,pe,ce,L);return}const I=L.deltaMode===1?20:1;let F=d===Kr.Vertical?0:L.deltaX*I,ae=d===Kr.Horizontal?0:L.deltaY*I;!Ua()&&L.shiftKey&&d!==Kr.Vertical&&(F=L.deltaY*I,ae=0),U.translateBy(ee,-(F/K)*c,-(ae/K)*c,{internal:!0});const q=Ia(ee.property("__zoom")),{onViewportChangeStart:V,onViewportChange:Q,onViewportChangeEnd:re}=j.getState();clearTimeout(Y.current),ne.current||(ne.current=!0,r==null||r(L,q),V==null||V(q)),ne.current&&(e==null||e(L,q),Q==null||Q(q),Y.current=setTimeout(()=>{i==null||i(L,q),re==null||re(q),ne.current=!1},150))},{passive:!1}):typeof X<"u"&&ee.on("wheel.zoom",function(L,K){if(!x&&L.type==="wheel"&&!L.ctrlKey||Ri(L,T))return null;L.preventDefault(),X.call(this,L,K)},{passive:!1}))},[R,l,d,ee,U,X,G,u,x,T,r,e,i]),D.useEffect(()=>{U&&U.on("start",L=>{var F,ae;if(!L.sourceEvent||L.sourceEvent.internal)return null;H.current=(F=L.sourceEvent)==null?void 0:F.button;const{onViewportChangeStart:K}=j.getState(),I=Ia(L.transform);M.current=!0,B.current=I,((ae=L.sourceEvent)==null?void 0:ae.type)==="mousedown"&&j.setState({paneDragging:!0}),K==null||K(I),r==null||r(L.sourceEvent,I)})},[U,r]),D.useEffect(()=>{U&&(R&&!M.current?U.on("zoom",null):R||U.on("zoom",L=>{var I;const{onViewportChange:K}=j.getState();if(j.setState({transform:[L.transform.x,L.transform.y,L.transform.k]}),z.current=!!(o&&lw(v,H.current??0)),(e||K)&&!((I=L.sourceEvent)!=null&&I.internal)){const F=Ia(L.transform);K==null||K(F),e==null||e(L.sourceEvent,F)}}))},[R,U,e,v,o]),D.useEffect(()=>{U&&U.on("end",L=>{if(!L.sourceEvent||L.sourceEvent.internal)return null;const{onViewportChangeEnd:K}=j.getState();if(M.current=!1,j.setState({paneDragging:!1}),o&&lw(v,H.current??0)&&!z.current&&o(L.sourceEvent),z.current=!1,(i||K)&&hj(B.current,L.transform)){const I=Ia(L.transform);B.current=I,clearTimeout(A.current),A.current=setTimeout(()=>{K==null||K(I),i==null||i(L.sourceEvent,I)},l?150:0)}})},[U,l,v,i,o]),D.useEffect(()=>{U&&U.filter(L=>{const K=G||s,I=u&&L.ctrlKey;if((v===!0||Array.isArray(v)&&v.includes(1))&&L.button===1&&L.type==="mousedown"&&(Ri(L,"react-flow__node")||Ri(L,"react-flow__edge")))return!0;if(!v&&!K&&!l&&!p&&!u||R||!p&&L.type==="dblclick"||Ri(L,T)&&L.type==="wheel"||Ri(L,C)&&(L.type!=="wheel"||l&&L.type==="wheel"&&!G)||!u&&L.ctrlKey&&L.type==="wheel"||!K&&!l&&!I&&L.type==="wheel"||!v&&(L.type==="mousedown"||L.type==="touchstart")||Array.isArray(v)&&!v.includes(L.button)&&L.type==="mousedown")return!1;const F=Array.isArray(v)&&v.includes(L.button)||!L.button||L.button<=1;return(!L.ctrlKey||L.type==="wheel")&&F})},[R,U,s,u,l,p,v,h,G]),ie.createElement("div",{className:"react-flow__renderer",ref:O,style:bv},k)},vj=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function gj(){const{userSelectionActive:e,userSelectionRect:r}=Fe(vj,wt);return e&&r?ie.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}function fw(e,r){const i=r.parentNode||r.parentId,o=e.find(s=>s.id===i);if(o){const s=r.position.x+r.width-o.width,u=r.position.y+r.height-o.height;if(s>0||u>0||r.position.x<0||r.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,s>0&&(o.style.width+=s),u>0&&(o.style.height+=u),r.position.x<0){const l=Math.abs(r.position.x);o.position.x=o.position.x-l,o.style.width+=l,r.position.x=0}if(r.position.y<0){const l=Math.abs(r.position.y);o.position.y=o.position.y-l,o.style.height+=l,r.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function yj(e,r){if(e.some(o=>o.type==="reset"))return e.filter(o=>o.type==="reset").map(o=>o.item);const i=e.filter(o=>o.type==="add").map(o=>o.item);return r.reduce((o,s)=>{const u=e.filter(c=>c.id===s.id);if(u.length===0)return o.push(s),o;const l={...s};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&&fw(o,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&&fw(o,l);break}case"remove":return o}return o.push(l),o},i)}function wj(e,r){return yj(e,r)}const Cr=(e,r)=>({id:e,type:"select",selected:r});function ji(e,r){return e.reduce((i,o)=>{const s=r.includes(o.id);return!o.selected&&s?(o.selected=!0,i.push(Cr(o.id,!0))):o.selected&&!s&&(o.selected=!1,i.push(Cr(o.id,!1))),i},[])}const vc=(e,r)=>i=>{i.target===r.current&&(e==null||e(i))},_j=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),cb=D.memo(({isSelecting:e,selectionMode:r=Yo.Full,panOnDrag:i,onSelectionStart:o,onSelectionEnd:s,onPaneClick:u,onPaneContextMenu:l,onPaneScroll:c,onPaneMouseEnter:d,onPaneMouseMove:p,onPaneMouseLeave:h,children:v})=>{const g=D.useRef(null),w=_t(),N=D.useRef(0),_=D.useRef(0),E=D.useRef(),{userSelectionActive:x,elementsSelectable:k,dragging:T}=Fe(_j,wt),C=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,_.current=0},A=X=>{u==null||u(X),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},j=X=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){X.preventDefault();return}l==null||l(X)},M=c?X=>c(X):void 0,z=X=>{const{resetSelectedElements:R,domNode:G}=w.getState();if(E.current=G==null?void 0:G.getBoundingClientRect(),!k||!e||X.button!==0||X.target!==g.current||!E.current)return;const{x:H,y:ne}=Rr(X,E.current);R(),w.setState({userSelectionRect:{width:0,height:0,startX:H,startY:ne,x:H,y:ne}}),o==null||o(X)},O=X=>{const{userSelectionRect:R,nodeInternals:G,edges:H,transform:ne,onNodesChange:Y,onEdgesChange:L,nodeOrigin:K,getNodes:I}=w.getState();if(!e||!E.current||!R)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const F=Rr(X,E.current),ae=R.startX??0,q=R.startY??0,V={...R,x:F.x<ae?F.x:ae,y:F.y<q?F.y:q,width:Math.abs(F.x-ae),height:Math.abs(F.y-q)},Q=I(),re=Wk(G,V,ne,r===Yo.Partial,!0,K),ce=Gk(re,H).map(pe=>pe.id),he=re.map(pe=>pe.id);if(N.current!==he.length){N.current=he.length;const pe=ji(Q,he);pe.length&&(Y==null||Y(pe))}if(_.current!==ce.length){_.current=ce.length;const pe=ji(H,ce);pe.length&&(L==null||L(pe))}w.setState({userSelectionRect:V})},B=X=>{if(X.button!==0)return;const{userSelectionRect:R}=w.getState();!x&&R&&X.target===g.current&&(A==null||A(X)),w.setState({nodesSelectionActive:N.current>0}),C(),s==null||s(X)},U=X=>{x&&(w.setState({nodesSelectionActive:N.current>0}),s==null||s(X)),C()},ee=k&&(e||x);return ie.createElement("div",{className:jt(["react-flow__pane",{dragging:T,selection:e}]),onClick:ee?void 0:vc(A,g),onContextMenu:vc(j,g),onWheel:vc(M,g),onMouseEnter:ee?void 0:d,onMouseDown:ee?z:void 0,onMouseMove:ee?O:p,onMouseUp:ee?B:void 0,onMouseLeave:ee?U:h,ref:g,style:bv},v,ie.createElement(gj,null))});cb.displayName="Pane";function fb(e,r){const i=e.parentNode||e.parentId;if(!i)return!1;const o=r.get(i);return o?o.selected?!0:fb(o,r):!1}function dw(e,r,i){let o=e;do{if(o!=null&&o.matches(r))return!0;if(o===i.current)return!1;o=o.parentElement}while(o);return!1}function xj(e,r,i,o){return Array.from(e.values()).filter(s=>(s.selected||s.id===o)&&(!s.parentNode||s.parentId||!fb(s,e))&&(s.draggable||r&&typeof s.draggable>"u")).map(s=>{var u,l;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:i.x-(((u=s.positionAbsolute)==null?void 0:u.x)??0),y:i.y-(((l=s.positionAbsolute)==null?void 0:l.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function Sj(e,r){return!r||r==="parent"?r:[r[0],[r[1][0]-(e.width||0),r[1][1]-(e.height||0)]]}function db(e,r,i,o,s=[0,0],u){const l=Sj(e,e.extent||o);let c=l;const d=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(d&&e.width&&e.height){const v=i.get(d),{x:g,y:w}=Xr(v,s).positionAbsolute;c=v&&mn(g)&&mn(w)&&mn(v.width)&&mn(v.height)?[[g+e.width*s[0],w+e.height*s[1]],[g+v.width-e.width+e.width*s[0],w+v.height-e.height+e.height*s[1]]]:c}else u==null||u("005",nr.error005()),c=l;else if(e.extent&&d&&e.extent!=="parent"){const v=i.get(d),{x:g,y:w}=Xr(v,s).positionAbsolute;c=[[e.extent[0][0]+g,e.extent[0][1]+w],[e.extent[1][0]+g,e.extent[1][1]+w]]}let p={x:0,y:0};if(d){const v=i.get(d);p=Xr(v,s).positionAbsolute}const h=c&&c!=="parent"?yv(r,c):r;return{position:{x:h.x-p.x,y:h.y-p.y},positionAbsolute:h}}function gc({nodeId:e,dragItems:r,nodeInternals:i}){const o=r.map(s=>({...i.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[e?o.find(s=>s.id===e):o[0],o]}const hw=(e,r,i,o)=>{const s=r.querySelectorAll(e);if(!s||!s.length)return null;const u=Array.from(s),l=r.getBoundingClientRect(),c={x:l.width*o[0],y:l.height*o[1]};return u.map(d=>{const p=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(p.left-l.left-c.x)/i,y:(p.top-l.top-c.y)/i,...gv(d)}})};function Po(e,r,i){return i===void 0?i:o=>{const s=r().nodeInternals.get(e);s&&i(o,{...s})}}function ev({id:e,store:r,unselect:i=!1,nodeRef:o}){const{addSelectedNodes:s,unselectNodesAndEdges:u,multiSelectionActive:l,nodeInternals:c,onError:d}=r.getState(),p=c.get(e);if(!p){d==null||d("012",nr.error012(e));return}r.setState({nodesSelectionActive:!1}),p.selected?(i||p.selected&&l)&&(u({nodes:[p],edges:[]}),requestAnimationFrame(()=>{var h;return(h=o==null?void 0:o.current)==null?void 0:h.blur()})):s([e])}function Ej(){const e=_t();return D.useCallback(({sourceEvent:i})=>{const{transform:o,snapGrid:s,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-o[0])/o[2],y:(c-o[1])/o[2]};return{xSnapped:u?s[0]*Math.round(d.x/s[0]):d.x,ySnapped:u?s[1]*Math.round(d.y/s[1]):d.y,...d}},[])}function yc(e){return(r,i,o)=>e==null?void 0:e(r,o)}function hb({nodeRef:e,disabled:r=!1,noDragClassName:i,handleSelector:o,nodeId:s,isSelectable:u,selectNodesOnDrag:l}){const c=_t(),[d,p]=D.useState(!1),h=D.useRef([]),v=D.useRef({x:null,y:null}),g=D.useRef(0),w=D.useRef(null),N=D.useRef({x:0,y:0}),_=D.useRef(null),E=D.useRef(!1),x=D.useRef(!1),k=D.useRef(!1),T=Ej();return D.useEffect(()=>{if(e!=null&&e.current){const C=pn(e.current),A=({x:z,y:O})=>{const{nodeInternals:B,onNodeDrag:U,onSelectionDrag:ee,updateNodePositions:X,nodeExtent:R,snapGrid:G,snapToGrid:H,nodeOrigin:ne,onError:Y}=c.getState();v.current={x:z,y:O};let L=!1,K={x:0,y:0,x2:0,y2:0};if(h.current.length>1&&R){const F=eu(h.current,ne);K=Ko(F)}if(h.current=h.current.map(F=>{const ae={x:z-F.distance.x,y:O-F.distance.y};H&&(ae.x=G[0]*Math.round(ae.x/G[0]),ae.y=G[1]*Math.round(ae.y/G[1]));const q=[[R[0][0],R[0][1]],[R[1][0],R[1][1]]];h.current.length>1&&R&&!F.extent&&(q[0][0]=F.positionAbsolute.x-K.x+R[0][0],q[1][0]=F.positionAbsolute.x+(F.width??0)-K.x2+R[1][0],q[0][1]=F.positionAbsolute.y-K.y+R[0][1],q[1][1]=F.positionAbsolute.y+(F.height??0)-K.y2+R[1][1]);const V=db(F,ae,B,q,ne,Y);return L=L||F.position.x!==V.position.x||F.position.y!==V.position.y,F.position=V.position,F.positionAbsolute=V.positionAbsolute,F}),!L)return;X(h.current,!0,!0),p(!0);const I=s?U:yc(ee);if(I&&_.current){const[F,ae]=gc({nodeId:s,dragItems:h.current,nodeInternals:B});I(_.current,F,ae)}},j=()=>{if(!w.current)return;const[z,O]=qk(N.current,w.current);if(z!==0||O!==0){const{transform:B,panBy:U}=c.getState();v.current.x=(v.current.x??0)-z/B[2],v.current.y=(v.current.y??0)-O/B[2],U({x:z,y:O})&&A(v.current)}g.current=requestAnimationFrame(j)},M=z=>{var ne;const{nodeInternals:O,multiSelectionActive:B,nodesDraggable:U,unselectNodesAndEdges:ee,onNodeDragStart:X,onSelectionDragStart:R}=c.getState();x.current=!0;const G=s?X:yc(R);(!l||!u)&&!B&&s&&((ne=O.get(s))!=null&&ne.selected||ee()),s&&u&&l&&ev({id:s,store:c,nodeRef:e});const H=T(z);if(v.current=H,h.current=xj(O,U,H,s),G&&h.current){const[Y,L]=gc({nodeId:s,dragItems:h.current,nodeInternals:O});G(z.sourceEvent,Y,L)}};if(r)C.on(".drag",null);else{const z=MR().on("start",O=>{const{domNode:B,nodeDragThreshold:U}=c.getState();U===0&&M(O),k.current=!1;const ee=T(O);v.current=ee,w.current=(B==null?void 0:B.getBoundingClientRect())||null,N.current=Rr(O.sourceEvent,w.current)}).on("drag",O=>{var X,R;const B=T(O),{autoPanOnNodeDrag:U,nodeDragThreshold:ee}=c.getState();if(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!E.current&&x.current&&U&&(E.current=!0,j()),!x.current){const G=B.xSnapped-(((X=v==null?void 0:v.current)==null?void 0:X.x)??0),H=B.ySnapped-(((R=v==null?void 0:v.current)==null?void 0:R.y)??0);Math.sqrt(G*G+H*H)>ee&&M(O)}(v.current.x!==B.xSnapped||v.current.y!==B.ySnapped)&&h.current&&x.current&&(_.current=O.sourceEvent,N.current=Rr(O.sourceEvent,w.current),A(B))}}).on("end",O=>{if(!(!x.current||k.current)&&(p(!1),E.current=!1,x.current=!1,cancelAnimationFrame(g.current),h.current)){const{updateNodePositions:B,nodeInternals:U,onNodeDragStop:ee,onSelectionDragStop:X}=c.getState(),R=s?ee:yc(X);if(B(h.current,!1,!1),R){const[G,H]=gc({nodeId:s,dragItems:h.current,nodeInternals:U});R(O.sourceEvent,G,H)}}}).filter(O=>{const B=O.target;return!O.button&&(!i||!dw(B,`.${i}`,e))&&(!o||dw(B,o,e))});return C.call(z),()=>{C.on(".drag",null)}}}},[e,r,i,o,u,c,s,l,T]),d}function pb(){const e=_t();return D.useCallback(i=>{const{nodeInternals:o,nodeExtent:s,updateNodePositions:u,getNodes:l,snapToGrid:c,snapGrid:d,onError:p,nodesDraggable:h}=e.getState(),v=l().filter(k=>k.selected&&(k.draggable||h&&typeof k.draggable>"u")),g=c?d[0]:5,w=c?d[1]:5,N=i.isShiftPressed?4:1,_=i.x*g*N,E=i.y*w*N,x=v.map(k=>{if(k.positionAbsolute){const T={x:k.positionAbsolute.x+_,y:k.positionAbsolute.y+E};c&&(T.x=d[0]*Math.round(T.x/d[0]),T.y=d[1]*Math.round(T.y/d[1]));const{positionAbsolute:C,position:A}=db(k,T,o,s,void 0,p);k.position=A,k.positionAbsolute=C}return k});u(x,!0,!1)},[])}const Oi={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var qo=e=>{const r=({id:i,type:o,data:s,xPos:u,yPos:l,xPosOrigin:c,yPosOrigin:d,selected:p,onClick:h,onMouseEnter:v,onMouseMove:g,onMouseLeave:w,onContextMenu:N,onDoubleClick:_,style:E,className:x,isDraggable:k,isSelectable:T,isConnectable:C,isFocusable:A,selectNodesOnDrag:j,sourcePosition:M,targetPosition:z,hidden:O,resizeObserver:B,dragHandle:U,zIndex:ee,isParent:X,noDragClassName:R,noPanClassName:G,initialized:H,disableKeyboardA11y:ne,ariaLabel:Y,rfId:L,hasHandleBounds:K})=>{const I=_t(),F=D.useRef(null),ae=D.useRef(null),q=D.useRef(M),V=D.useRef(z),Q=D.useRef(o),re=T||k||h||v||g||w,ce=pb(),he=Po(i,I.getState,v),pe=Po(i,I.getState,g),je=Po(i,I.getState,w),$e=Po(i,I.getState,N),Me=Po(i,I.getState,_),Ae=ve=>{const{nodeDragThreshold:ge}=I.getState();if(T&&(!j||!k||ge>0)&&ev({id:i,store:I,nodeRef:F}),h){const ze=I.getState().nodeInternals.get(i);ze&&h(ve,{...ze})}},we=ve=>{if(!Ym(ve)&&!ne)if(Dk.includes(ve.key)&&T){const ge=ve.key==="Escape";ev({id:i,store:I,unselect:ge,nodeRef:F})}else k&&p&&Object.prototype.hasOwnProperty.call(Oi,ve.key)&&(I.setState({ariaLiveMessage:`Moved selected node ${ve.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~u}, y: ${~~l}`}),ce({x:Oi[ve.key].x,y:Oi[ve.key].y,isShiftPressed:ve.shiftKey}))};D.useEffect(()=>()=>{ae.current&&(B==null||B.unobserve(ae.current),ae.current=null)},[]),D.useEffect(()=>{if(F.current&&!O){const ve=F.current;(!H||!K||ae.current!==ve)&&(ae.current&&(B==null||B.unobserve(ae.current)),B==null||B.observe(ve),ae.current=ve)}},[O,H,K]),D.useEffect(()=>{const ve=Q.current!==o,ge=q.current!==M,ze=V.current!==z;F.current&&(ve||ge||ze)&&(ve&&(Q.current=o),ge&&(q.current=M),ze&&(V.current=z),I.getState().updateNodeDimensions([{id:i,nodeElement:F.current,forceUpdate:!0}]))},[i,o,M,z]);const Be=hb({nodeRef:F,disabled:O||!k,noDragClassName:R,handleSelector:U,nodeId:i,isSelectable:T,selectNodesOnDrag:j});return O?null:ie.createElement("div",{className:jt(["react-flow__node",`react-flow__node-${o}`,{[G]:k},x,{selected:p,selectable:T,parent:X,dragging:Be}]),ref:F,style:{zIndex:ee,transform:`translate(${c}px,${d}px)`,pointerEvents:re?"all":"none",visibility:H?"visible":"hidden",...E},"data-id":i,"data-testid":`rf__node-${i}`,onMouseEnter:he,onMouseMove:pe,onMouseLeave:je,onContextMenu:$e,onClick:Ae,onDoubleClick:Me,onKeyDown:A?we:void 0,tabIndex:A?0:void 0,role:A?"button":void 0,"aria-describedby":ne?void 0:`${ob}-${L}`,"aria-label":Y},ie.createElement(OI,{value:i},ie.createElement(e,{id:i,data:s,type:o,xPos:u,yPos:l,selected:p,isConnectable:C,sourcePosition:M,targetPosition:z,dragging:Be,dragHandle:U,zIndex:ee})))};return r.displayName="NodeWrapper",D.memo(r)};const kj=e=>{const r=e.getNodes().filter(i=>i.selected);return{...eu(r,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function bj({onSelectionContextMenu:e,noPanClassName:r,disableKeyboardA11y:i}){const o=_t(),{width:s,height:u,x:l,y:c,transformString:d,userSelectionActive:p}=Fe(kj,wt),h=pb(),v=D.useRef(null);if(D.useEffect(()=>{var N;i||(N=v.current)==null||N.focus({preventScroll:!0})},[i]),hb({nodeRef:v}),p||!s||!u)return null;const g=e?N=>{const _=o.getState().getNodes().filter(E=>E.selected);e(N,_)}:void 0,w=N=>{Object.prototype.hasOwnProperty.call(Oi,N.key)&&h({x:Oi[N.key].x,y:Oi[N.key].y,isShiftPressed:N.shiftKey})};return ie.createElement("div",{className:jt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d}},ie.createElement("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:i?void 0:-1,onKeyDown:i?void 0:w,style:{width:s,height:u,top:c,left:l}}))}var Nj=D.memo(bj);const Cj=e=>e.nodesSelectionActive,mb=({children:e,onPaneClick:r,onPaneMouseEnter:i,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:u,onPaneScroll:l,deleteKeyCode:c,onMove:d,onMoveStart:p,onMoveEnd:h,selectionKeyCode:v,selectionOnDrag:g,selectionMode:w,onSelectionStart:N,onSelectionEnd:_,multiSelectionKeyCode:E,panActivationKeyCode:x,zoomActivationKeyCode:k,elementsSelectable:T,zoomOnScroll:C,zoomOnPinch:A,panOnScroll:j,panOnScrollSpeed:M,panOnScrollMode:z,zoomOnDoubleClick:O,panOnDrag:B,defaultViewport:U,translateExtent:ee,minZoom:X,maxZoom:R,preventScrolling:G,onSelectionContextMenu:H,noWheelClassName:ne,noPanClassName:Y,disableKeyboardA11y:L})=>{const K=Fe(Cj),I=Xo(v),F=Xo(x),ae=F||B,q=F||j,V=I||g&&ae!==!0;return fj({deleteKeyCode:c,multiSelectionKeyCode:E}),ie.createElement(mj,{onMove:d,onMoveStart:p,onMoveEnd:h,onPaneContextMenu:u,elementsSelectable:T,zoomOnScroll:C,zoomOnPinch:A,panOnScroll:q,panOnScrollSpeed:M,panOnScrollMode:z,zoomOnDoubleClick:O,panOnDrag:!I&&ae,defaultViewport:U,translateExtent:ee,minZoom:X,maxZoom:R,zoomActivationKeyCode:k,preventScrolling:G,noWheelClassName:ne,noPanClassName:Y},ie.createElement(cb,{onSelectionStart:N,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:i,onPaneMouseMove:o,onPaneMouseLeave:s,onPaneContextMenu:u,onPaneScroll:l,panOnDrag:ae,isSelecting:!!V,selectionMode:w},e,K&&ie.createElement(Nj,{onSelectionContextMenu:H,noPanClassName:Y,disableKeyboardA11y:L})))};mb.displayName="FlowRenderer";var Tj=D.memo(mb);function Rj(e){return Fe(D.useCallback(i=>e?Wk(i.nodeInternals,{x:0,y:0,width:i.width,height:i.height},i.transform,!0):i.getNodes(),[e]))}function Aj(e){const r={input:qo(e.input||tb),default:qo(e.default||Jm),output:qo(e.output||rb),group:qo(e.group||kv)},i={},o=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,u)=>(s[u]=qo(e[u]||Jm),s),i);return{...r,...o}}const Ij=({x:e,y:r,width:i,height:o,origin:s})=>!i||!o?{x:e,y:r}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:e,y:r}:{x:e-i*s[0],y:r-o*s[1]},jj=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),vb=e=>{const{nodesDraggable:r,nodesConnectable:i,nodesFocusable:o,elementsSelectable:s,updateNodeDimensions:u,onError:l}=Fe(jj,wt),c=Rj(e.onlyRenderVisibleElements),d=D.useRef(),p=D.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const h=new ResizeObserver(v=>{const g=v.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));u(g)});return d.current=h,h},[]);return D.useEffect(()=>()=>{var h;(h=d==null?void 0:d.current)==null||h.disconnect()},[]),ie.createElement("div",{className:"react-flow__nodes",style:bv},c.map(h=>{var A,j,M;let v=h.type||"default";e.nodeTypes[v]||(l==null||l("003",nr.error003(v)),v="default");const g=e.nodeTypes[v]||e.nodeTypes.default,w=!!(h.draggable||r&&typeof h.draggable>"u"),N=!!(h.selectable||s&&typeof h.selectable>"u"),_=!!(h.connectable||i&&typeof h.connectable>"u"),E=!!(h.focusable||o&&typeof h.focusable>"u"),x=e.nodeExtent?yv(h.positionAbsolute,e.nodeExtent):h.positionAbsolute,k=(x==null?void 0:x.x)??0,T=(x==null?void 0:x.y)??0,C=Ij({x:k,y:T,width:h.width??0,height:h.height??0,origin:e.nodeOrigin});return ie.createElement(g,{key:h.id,id:h.id,className:h.className,style:h.style,type:v,data:h.data,sourcePosition:h.sourcePosition||ke.Bottom,targetPosition:h.targetPosition||ke.Top,hidden:h.hidden,xPos:k,yPos:T,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:!!h.selected,isDraggable:w,isSelectable:N,isConnectable:_,isFocusable:E,resizeObserver:p,dragHandle:h.dragHandle,zIndex:((A=h[ut])==null?void 0:A.z)??0,isParent:!!((j=h[ut])!=null&&j.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!h.width&&!!h.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:h.ariaLabel,hasHandleBounds:!!((M=h[ut])!=null&&M.handleBounds)})}))};vb.displayName="NodeRenderer";var Mj=D.memo(vb);const Pj=(e,r,i)=>i===ke.Left?e-r:i===ke.Right?e+r:e,qj=(e,r,i)=>i===ke.Top?e-r:i===ke.Bottom?e+r:e,pw="react-flow__edgeupdater",mw=({position:e,centerX:r,centerY:i,radius:o=10,onMouseDown:s,onMouseEnter:u,onMouseOut:l,type:c})=>ie.createElement("circle",{onMouseDown:s,onMouseEnter:u,onMouseOut:l,className:jt([pw,`${pw}-${c}`]),cx:Pj(r,o,e),cy:qj(i,o,e),r:o,stroke:"transparent",fill:"transparent"}),Oj=()=>!0;var Ai=e=>{const r=({id:i,className:o,type:s,data:u,onClick:l,onEdgeDoubleClick:c,selected:d,animated:p,label:h,labelStyle:v,labelShowBg:g,labelBgStyle:w,labelBgPadding:N,labelBgBorderRadius:_,style:E,source:x,target:k,sourceX:T,sourceY:C,targetX:A,targetY:j,sourcePosition:M,targetPosition:z,elementsSelectable:O,hidden:B,sourceHandleId:U,targetHandleId:ee,onContextMenu:X,onMouseEnter:R,onMouseMove:G,onMouseLeave:H,reconnectRadius:ne,onReconnect:Y,onReconnectStart:L,onReconnectEnd:K,markerEnd:I,markerStart:F,rfId:ae,ariaLabel:q,isFocusable:V,isReconnectable:Q,pathOptions:re,interactionWidth:ce,disableKeyboardA11y:he})=>{const pe=D.useRef(null),[je,$e]=D.useState(!1),[Me,Ae]=D.useState(!1),we=_t(),Be=D.useMemo(()=>`url('#${Qm(F,ae)}')`,[F,ae]),ve=D.useMemo(()=>`url('#${Qm(I,ae)}')`,[I,ae]);if(B)return null;const ge=He=>{var kt;const{edges:vt,addSelectedEdges:Ke,unselectNodesAndEdges:dt,multiSelectionActive:Qe}=we.getState(),Pt=vt.find(Xt=>Xt.id===i);Pt&&(O&&(we.setState({nodesSelectionActive:!1}),Pt.selected&&Qe?(dt({nodes:[],edges:[Pt]}),(kt=pe.current)==null||kt.blur()):Ke([i])),l&&l(He,Pt))},ze=Mo(i,we.getState,c),et=Mo(i,we.getState,X),ft=Mo(i,we.getState,R),lt=Mo(i,we.getState,G),Ue=Mo(i,we.getState,H),Ge=(He,vt)=>{if(He.button!==0)return;const{edges:Ke,isValidConnection:dt}=we.getState(),Qe=vt?k:x,Pt=(vt?ee:U)||null,kt=vt?"target":"source",Xt=dt||Oj,qn=vt,Qt=Ke.find(nt=>nt.id===i);Ae(!0),L==null||L(He,Qt,kt);const Dt=nt=>{Ae(!1),K==null||K(nt,Qt,kt)};Qk({event:He,handleId:Pt,nodeId:Qe,onConnect:nt=>Y==null?void 0:Y(Qt,nt),isTarget:qn,getState:we.getState,setState:we.setState,isValidConnection:Xt,edgeUpdaterType:kt,onReconnectEnd:Dt})},xt=He=>Ge(He,!0),St=He=>Ge(He,!1),Et=()=>$e(!0),tt=()=>$e(!1),mt=!O&&!l,Mt=He=>{var vt;if(!he&&Dk.includes(He.key)&&O){const{unselectNodesAndEdges:Ke,addSelectedEdges:dt,edges:Qe}=we.getState();He.key==="Escape"?((vt=pe.current)==null||vt.blur(),Ke({edges:[Qe.find(kt=>kt.id===i)]})):dt([i])}};return ie.createElement("g",{className:jt(["react-flow__edge",`react-flow__edge-${s}`,o,{selected:d,animated:p,inactive:mt,updating:je}]),onClick:ge,onDoubleClick:ze,onContextMenu:et,onMouseEnter:ft,onMouseMove:lt,onMouseLeave:Ue,onKeyDown:V?Mt:void 0,tabIndex:V?0:void 0,role:V?"button":"img","data-testid":`rf__edge-${i}`,"aria-label":q===null?void 0:q||`Edge from ${x} to ${k}`,"aria-describedby":V?`${sb}-${ae}`:void 0,ref:pe},!Me&&ie.createElement(e,{id:i,source:x,target:k,selected:d,animated:p,label:h,labelStyle:v,labelShowBg:g,labelBgStyle:w,labelBgPadding:N,labelBgBorderRadius:_,data:u,style:E,sourceX:T,sourceY:C,targetX:A,targetY:j,sourcePosition:M,targetPosition:z,sourceHandleId:U,targetHandleId:ee,markerStart:Be,markerEnd:ve,pathOptions:re,interactionWidth:ce}),Q&&ie.createElement(ie.Fragment,null,(Q==="source"||Q===!0)&&ie.createElement(mw,{position:M,centerX:T,centerY:C,radius:ne,onMouseDown:xt,onMouseEnter:Et,onMouseOut:tt,type:"source"}),(Q==="target"||Q===!0)&&ie.createElement(mw,{position:z,centerX:A,centerY:j,radius:ne,onMouseDown:St,onMouseEnter:Et,onMouseOut:tt,type:"target"})))};return r.displayName="EdgeWrapper",D.memo(r)};function Lj(e){const r={default:Ai(e.default||Va),straight:Ai(e.bezier||xv),step:Ai(e.step||_v),smoothstep:Ai(e.step||Ja),simplebezier:Ai(e.simplebezier||wv)},i={},o=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,u)=>(s[u]=Ai(e[u]||Va),s),i);return{...r,...o}}function vw(e,r,i=null){const o=((i==null?void 0:i.x)||0)+r.x,s=((i==null?void 0:i.y)||0)+r.y,u=(i==null?void 0:i.width)||r.width,l=(i==null?void 0:i.height)||r.height;switch(e){case ke.Top:return{x:o+u/2,y:s};case ke.Right:return{x:o+u,y:s+l/2};case ke.Bottom:return{x:o+u/2,y:s+l};case ke.Left:return{x:o,y:s+l/2}}}function gw(e,r){return e?e.length===1||!r?e[0]:r&&e.find(i=>i.id===r)||null:null}const $j=(e,r,i,o,s,u)=>{const l=vw(i,e,r),c=vw(u,o,s);return{sourceX:l.x,sourceY:l.y,targetX:c.x,targetY:c.y}};function Dj({sourcePos:e,targetPos:r,sourceWidth:i,sourceHeight:o,targetWidth:s,targetHeight:u,width:l,height:c,transform:d}){const p={x:Math.min(e.x,r.x),y:Math.min(e.y,r.y),x2:Math.max(e.x+i,r.x+s),y2:Math.max(e.y+o,r.y+u)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const h=Ko({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:l/d[2],height:c/d[2]}),v=Math.max(0,Math.min(h.x2,p.x2)-Math.max(h.x,p.x)),g=Math.max(0,Math.min(h.y2,p.y2)-Math.max(h.y,p.y));return Math.ceil(v*g)>0}function yw(e){var o,s,u,l,c;const r=((o=e==null?void 0:e[ut])==null?void 0:o.handleBounds)||null,i=r&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.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},r,!!i]}const Fj=[{level:0,isMaxLevel:!0,edges:[]}];function zj(e,r,i=!1){let o=-1;const s=e.reduce((l,c)=>{var h,v;const d=mn(c.zIndex);let p=d?c.zIndex:0;if(i){const g=r.get(c.target),w=r.get(c.source),N=c.selected||(g==null?void 0:g.selected)||(w==null?void 0:w.selected),_=Math.max(((h=w==null?void 0:w[ut])==null?void 0:h.z)||0,((v=g==null?void 0:g[ut])==null?void 0:v.z)||0,1e3);p=(d?c.zIndex:0)+(N?_:0)}return l[p]?l[p].push(c):l[p]=[c],o=p>o?p:o,l},{}),u=Object.entries(s).map(([l,c])=>{const d=+l;return{edges:c,level:d,isMaxLevel:d===o}});return u.length===0?Fj:u}function Bj(e,r,i){const o=Fe(D.useCallback(s=>e?s.edges.filter(u=>{const l=r.get(u.source),c=r.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)&&Dj({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:s.width,height:s.height,transform:s.transform})}):s.edges,[e,r]));return zj(o,r,i)}const Uj=({color:e="none",strokeWidth:r=1})=>ie.createElement("polyline",{style:{stroke:e,strokeWidth:r},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Hj=({color:e="none",strokeWidth:r=1})=>ie.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:r},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),ww={[Ha.Arrow]:Uj,[Ha.ArrowClosed]:Hj};function Vj(e){const r=_t();return D.useMemo(()=>{var s,u;return Object.prototype.hasOwnProperty.call(ww,e)?ww[e]:((u=(s=r.getState()).onError)==null||u.call(s,"009",nr.error009(e)),null)},[e])}const Wj=({id:e,type:r,color:i,width:o=12.5,height:s=12.5,markerUnits:u="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const d=Vj(r);return d?ie.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:c,refX:"0",refY:"0"},ie.createElement(d,{color:i,strokeWidth:l})):null},Gj=({defaultColor:e,rfId:r})=>i=>{const o=[];return i.edges.reduce((s,u)=>([u.markerStart,u.markerEnd].forEach(l=>{if(l&&typeof l=="object"){const c=Qm(l,r);o.includes(c)||(s.push({id:c,color:l.color||e,...l}),o.push(c))}}),s),[]).sort((s,u)=>s.id.localeCompare(u.id))},gb=({defaultColor:e,rfId:r})=>{const i=Fe(D.useCallback(Gj({defaultColor:e,rfId:r}),[e,r]),(o,s)=>!(o.length!==s.length||o.some((u,l)=>u.id!==s[l].id)));return ie.createElement("defs",null,i.map(o=>ie.createElement(Wj,{id:o.id,key:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient})))};gb.displayName="MarkerDefinitions";var Kj=D.memo(gb);const Yj=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}),yb=({defaultMarkerColor:e,onlyRenderVisibleElements:r,elevateEdgesOnSelect:i,rfId:o,edgeTypes:s,noPanClassName:u,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:p,onEdgeClick:h,onEdgeDoubleClick:v,onReconnect:g,onReconnectStart:w,onReconnectEnd:N,reconnectRadius:_,children:E,disableKeyboardA11y:x})=>{const{edgesFocusable:k,edgesUpdatable:T,elementsSelectable:C,width:A,height:j,connectionMode:M,nodeInternals:z,onError:O}=Fe(Yj,wt),B=Bj(r,z,i);return A?ie.createElement(ie.Fragment,null,B.map(({level:U,edges:ee,isMaxLevel:X})=>ie.createElement("svg",{key:U,style:{zIndex:U},width:A,height:j,className:"react-flow__edges react-flow__container"},X&&ie.createElement(Kj,{defaultColor:e,rfId:o}),ie.createElement("g",null,ee.map(R=>{const[G,H,ne]=yw(z.get(R.source)),[Y,L,K]=yw(z.get(R.target));if(!ne||!K)return null;let I=R.type||"default";s[I]||(O==null||O("011",nr.error011(I)),I="default");const F=s[I]||s.default,ae=M===Zr.Strict?L.target:(L.target??[]).concat(L.source??[]),q=gw(H.source,R.sourceHandle),V=gw(ae,R.targetHandle),Q=(q==null?void 0:q.position)||ke.Bottom,re=(V==null?void 0:V.position)||ke.Top,ce=!!(R.focusable||k&&typeof R.focusable>"u"),he=R.reconnectable||R.updatable,pe=typeof g<"u"&&(he||T&&typeof he>"u");if(!q||!V)return O==null||O("008",nr.error008(q,R)),null;const{sourceX:je,sourceY:$e,targetX:Me,targetY:Ae}=$j(G,q,Q,Y,V,re);return ie.createElement(F,{key:R.id,id:R.id,className:jt([R.className,u]),type:I,data:R.data,selected:!!R.selected,animated:!!R.animated,hidden:!!R.hidden,label:R.label,labelStyle:R.labelStyle,labelShowBg:R.labelShowBg,labelBgStyle:R.labelBgStyle,labelBgPadding:R.labelBgPadding,labelBgBorderRadius:R.labelBgBorderRadius,style:R.style,source:R.source,target:R.target,sourceHandleId:R.sourceHandle,targetHandleId:R.targetHandle,markerEnd:R.markerEnd,markerStart:R.markerStart,sourceX:je,sourceY:$e,targetX:Me,targetY:Ae,sourcePosition:Q,targetPosition:re,elementsSelectable:C,onContextMenu:l,onMouseEnter:c,onMouseMove:d,onMouseLeave:p,onClick:h,onEdgeDoubleClick:v,onReconnect:g,onReconnectStart:w,onReconnectEnd:N,reconnectRadius:_,rfId:o,ariaLabel:R.ariaLabel,isFocusable:ce,isReconnectable:pe,pathOptions:"pathOptions"in R?R.pathOptions:void 0,interactionWidth:R.interactionWidth,disableKeyboardA11y:x})})))),E):null};yb.displayName="EdgeRenderer";var Xj=D.memo(yb);const Qj=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Zj({children:e}){const r=Fe(Qj);return ie.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:r}},e)}function Jj(e){const r=ts(),i=D.useRef(!1);D.useEffect(()=>{!i.current&&r.viewportInitialized&&e&&(setTimeout(()=>e(r),1),i.current=!0)},[e,r.viewportInitialized])}const eM={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top},wb=({nodeId:e,handleType:r,style:i,type:o=Tr.Bezier,CustomComponent:s,connectionStatus:u})=>{var j,M,z;const{fromNode:l,handleId:c,toX:d,toY:p,connectionMode:h}=Fe(D.useCallback(O=>({fromNode:O.nodeInternals.get(e),handleId:O.connectionHandleId,toX:(O.connectionPosition.x-O.transform[0])/O.transform[2],toY:(O.connectionPosition.y-O.transform[1])/O.transform[2],connectionMode:O.connectionMode}),[e]),wt),v=(j=l==null?void 0:l[ut])==null?void 0:j.handleBounds;let g=v==null?void 0:v[r];if(h===Zr.Loose&&(g=g||(v==null?void 0:v[r==="source"?"target":"source"])),!l||!g)return null;const w=c?g.find(O=>O.id===c):g[0],N=w?w.x+w.width/2:(l.width??0)/2,_=w?w.y+w.height/2:l.height??0,E=(((M=l.positionAbsolute)==null?void 0:M.x)??0)+N,x=(((z=l.positionAbsolute)==null?void 0:z.y)??0)+_,k=w==null?void 0:w.position,T=k?eM[k]:null;if(!k||!T)return null;if(s)return ie.createElement(s,{connectionLineType:o,connectionLineStyle:i,fromNode:l,fromHandle:w,fromX:E,fromY:x,toX:d,toY:p,fromPosition:k,toPosition:T,connectionStatus:u});let C="";const A={sourceX:E,sourceY:x,sourcePosition:k,targetX:d,targetY:p,targetPosition:T};return o===Tr.Bezier?[C]=Hk(A):o===Tr.Step?[C]=Xm({...A,borderRadius:0}):o===Tr.SmoothStep?[C]=Xm(A):o===Tr.SimpleBezier?[C]=Uk(A):C=`M${E},${x} ${d},${p}`,ie.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:i})};wb.displayName="ConnectionLine";const tM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function nM({containerStyle:e,style:r,type:i,component:o}){const{nodeId:s,handleType:u,nodesConnectable:l,width:c,height:d,connectionStatus:p}=Fe(tM,wt);return!(s&&u&&c&&l)?null:ie.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},ie.createElement("g",{className:jt(["react-flow__connection",p])},ie.createElement(wb,{nodeId:s,handleType:u,style:r,type:i,CustomComponent:o,connectionStatus:p})))}function _w(e,r){return D.useRef(null),_t(),D.useMemo(()=>r(e),[e])}const _b=({nodeTypes:e,edgeTypes:r,onMove:i,onMoveStart:o,onMoveEnd:s,onInit:u,onNodeClick:l,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:p,onNodeMouseEnter:h,onNodeMouseMove:v,onNodeMouseLeave:g,onNodeContextMenu:w,onSelectionContextMenu:N,onSelectionStart:_,onSelectionEnd:E,connectionLineType:x,connectionLineStyle:k,connectionLineComponent:T,connectionLineContainerStyle:C,selectionKeyCode:A,selectionOnDrag:j,selectionMode:M,multiSelectionKeyCode:z,panActivationKeyCode:O,zoomActivationKeyCode:B,deleteKeyCode:U,onlyRenderVisibleElements:ee,elementsSelectable:X,selectNodesOnDrag:R,defaultViewport:G,translateExtent:H,minZoom:ne,maxZoom:Y,preventScrolling:L,defaultMarkerColor:K,zoomOnScroll:I,zoomOnPinch:F,panOnScroll:ae,panOnScrollSpeed:q,panOnScrollMode:V,zoomOnDoubleClick:Q,panOnDrag:re,onPaneClick:ce,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:je,onPaneScroll:$e,onPaneContextMenu:Me,onEdgeContextMenu:Ae,onEdgeMouseEnter:we,onEdgeMouseMove:Be,onEdgeMouseLeave:ve,onReconnect:ge,onReconnectStart:ze,onReconnectEnd:et,reconnectRadius:ft,noDragClassName:lt,noWheelClassName:Ue,noPanClassName:Ge,elevateEdgesOnSelect:xt,disableKeyboardA11y:St,nodeOrigin:Et,nodeExtent:tt,rfId:mt})=>{const Mt=_w(e,Aj),He=_w(r,Lj);return Jj(u),ie.createElement(Tj,{onPaneClick:ce,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:je,onPaneContextMenu:Me,onPaneScroll:$e,deleteKeyCode:U,selectionKeyCode:A,selectionOnDrag:j,selectionMode:M,onSelectionStart:_,onSelectionEnd:E,multiSelectionKeyCode:z,panActivationKeyCode:O,zoomActivationKeyCode:B,elementsSelectable:X,onMove:i,onMoveStart:o,onMoveEnd:s,zoomOnScroll:I,zoomOnPinch:F,zoomOnDoubleClick:Q,panOnScroll:ae,panOnScrollSpeed:q,panOnScrollMode:V,panOnDrag:re,defaultViewport:G,translateExtent:H,minZoom:ne,maxZoom:Y,onSelectionContextMenu:N,preventScrolling:L,noDragClassName:lt,noWheelClassName:Ue,noPanClassName:Ge,disableKeyboardA11y:St},ie.createElement(Zj,null,ie.createElement(Xj,{edgeTypes:He,onEdgeClick:c,onEdgeDoubleClick:p,onlyRenderVisibleElements:ee,onEdgeContextMenu:Ae,onEdgeMouseEnter:we,onEdgeMouseMove:Be,onEdgeMouseLeave:ve,onReconnect:ge,onReconnectStart:ze,onReconnectEnd:et,reconnectRadius:ft,defaultMarkerColor:K,noPanClassName:Ge,elevateEdgesOnSelect:!!xt,disableKeyboardA11y:St,rfId:mt},ie.createElement(nM,{style:k,type:x,component:T,containerStyle:C})),ie.createElement("div",{className:"react-flow__edgelabel-renderer"}),ie.createElement(Mj,{nodeTypes:Mt,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:v,onNodeMouseLeave:g,onNodeContextMenu:w,selectNodesOnDrag:R,onlyRenderVisibleElements:ee,noPanClassName:Ge,noDragClassName:lt,disableKeyboardA11y:St,nodeOrigin:Et,nodeExtent:tt,rfId:mt})))};_b.displayName="GraphView";var rM=D.memo(_b);const tv=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],br={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:tv,nodeExtent:tv,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Zr.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:AI,isValidConnection:void 0},iM=()=>V2((e,r)=>({...br,setNodes:i=>{const{nodeInternals:o,nodeOrigin:s,elevateNodesOnSelect:u}=r();e({nodeInternals:mc(i,o,s,u)})},getNodes:()=>Array.from(r().nodeInternals.values()),setEdges:i=>{const{defaultEdgeOptions:o={}}=r();e({edges:i.map(s=>({...o,...s}))})},setDefaultNodesAndEdges:(i,o)=>{const s=typeof i<"u",u=typeof o<"u",l=s?mc(i,new Map,r().nodeOrigin,r().elevateNodesOnSelect):new Map;e({nodeInternals:l,edges:u?o:[],hasDefaultNodes:s,hasDefaultEdges:u})},updateNodeDimensions:i=>{const{onNodesChange:o,nodeInternals:s,fitViewOnInit:u,fitViewOnInitDone:l,fitViewOnInitOptions:c,domNode:d,nodeOrigin:p}=r(),h=d==null?void 0:d.querySelector(".react-flow__viewport");if(!h)return;const v=window.getComputedStyle(h),{m22:g}=new window.DOMMatrixReadOnly(v.transform),w=i.reduce((_,E)=>{const x=s.get(E.id);if(x!=null&&x.hidden)s.set(x.id,{...x,[ut]:{...x[ut],handleBounds:void 0}});else if(x){const k=gv(E.nodeElement);!!(k.width&&k.height&&(x.width!==k.width||x.height!==k.height||E.forceUpdate))&&(s.set(x.id,{...x,[ut]:{...x[ut],handleBounds:{source:hw(".source",E.nodeElement,g,p),target:hw(".target",E.nodeElement,g,p)}},...k}),_.push({id:x.id,type:"dimensions",dimensions:k}))}return _},[]);ub(s,p);const N=l||u&&!l&&lb(r,{initial:!0,...c});e({nodeInternals:new Map(s),fitViewOnInitDone:N}),(w==null?void 0:w.length)>0&&(o==null||o(w))},updateNodePositions:(i,o=!0,s=!1)=>{const{triggerNodeChanges:u}=r(),l=i.map(c=>{const d={id:c.id,type:"position",dragging:s};return o&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});u(l)},triggerNodeChanges:i=>{const{onNodesChange:o,nodeInternals:s,hasDefaultNodes:u,nodeOrigin:l,getNodes:c,elevateNodesOnSelect:d}=r();if(i!=null&&i.length){if(u){const p=wj(i,c()),h=mc(p,s,l,d);e({nodeInternals:h})}o==null||o(i)}},addSelectedNodes:i=>{const{multiSelectionActive:o,edges:s,getNodes:u}=r();let l,c=null;o?l=i.map(d=>Cr(d,!0)):(l=ji(u(),i),c=ji(s,[])),Aa({changedNodes:l,changedEdges:c,get:r,set:e})},addSelectedEdges:i=>{const{multiSelectionActive:o,edges:s,getNodes:u}=r();let l,c=null;o?l=i.map(d=>Cr(d,!0)):(l=ji(s,i),c=ji(u(),[])),Aa({changedNodes:c,changedEdges:l,get:r,set:e})},unselectNodesAndEdges:({nodes:i,edges:o}={})=>{const{edges:s,getNodes:u}=r(),l=i||u(),c=o||s,d=l.map(h=>(h.selected=!1,Cr(h.id,!1))),p=c.map(h=>Cr(h.id,!1));Aa({changedNodes:d,changedEdges:p,get:r,set:e})},setMinZoom:i=>{const{d3Zoom:o,maxZoom:s}=r();o==null||o.scaleExtent([i,s]),e({minZoom:i})},setMaxZoom:i=>{const{d3Zoom:o,minZoom:s}=r();o==null||o.scaleExtent([s,i]),e({maxZoom:i})},setTranslateExtent:i=>{var o;(o=r().d3Zoom)==null||o.translateExtent(i),e({translateExtent:i})},resetSelectedElements:()=>{const{edges:i,getNodes:o}=r(),u=o().filter(c=>c.selected).map(c=>Cr(c.id,!1)),l=i.filter(c=>c.selected).map(c=>Cr(c.id,!1));Aa({changedNodes:u,changedEdges:l,get:r,set:e})},setNodeExtent:i=>{const{nodeInternals:o}=r();o.forEach(s=>{s.positionAbsolute=yv(s.position,i)}),e({nodeExtent:i,nodeInternals:new Map(o)})},panBy:i=>{const{transform:o,width:s,height:u,d3Zoom:l,d3Selection:c,translateExtent:d}=r();if(!l||!c||!i.x&&!i.y)return!1;const p=er.translate(o[0]+i.x,o[1]+i.y).scale(o[2]),h=[[0,0],[s,u]],v=l==null?void 0:l.constrain()(p,h,d);return l.transform(c,v),o[0]!==v.x||o[1]!==v.y||o[2]!==v.k},cancelConnection:()=>e({connectionNodeId:br.connectionNodeId,connectionHandleId:br.connectionHandleId,connectionHandleType:br.connectionHandleType,connectionStatus:br.connectionStatus,connectionStartHandle:br.connectionStartHandle,connectionEndHandle:br.connectionEndHandle}),reset:()=>e({...br})}),Object.is),Nv=({children:e})=>{const r=D.useRef(null);return r.current||(r.current=iM()),ie.createElement(EI,{value:r.current},e)};Nv.displayName="ReactFlowProvider";const xb=({children:e})=>D.useContext(Za)?ie.createElement(ie.Fragment,null,e):ie.createElement(Nv,null,e);xb.displayName="ReactFlowWrapper";const oM={input:tb,default:Jm,output:rb,group:kv},sM={default:Va,straight:xv,step:_v,smoothstep:Ja,simplebezier:wv},aM=[0,0],uM=[15,15],lM={x:0,y:0,zoom:1},cM={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Sb=D.forwardRef(({nodes:e,edges:r,defaultNodes:i,defaultEdges:o,className:s,nodeTypes:u=oM,edgeTypes:l=sM,onNodeClick:c,onEdgeClick:d,onInit:p,onMove:h,onMoveStart:v,onMoveEnd:g,onConnect:w,onConnectStart:N,onConnectEnd:_,onClickConnectStart:E,onClickConnectEnd:x,onNodeMouseEnter:k,onNodeMouseMove:T,onNodeMouseLeave:C,onNodeContextMenu:A,onNodeDoubleClick:j,onNodeDragStart:M,onNodeDrag:z,onNodeDragStop:O,onNodesDelete:B,onEdgesDelete:U,onSelectionChange:ee,onSelectionDragStart:X,onSelectionDrag:R,onSelectionDragStop:G,onSelectionContextMenu:H,onSelectionStart:ne,onSelectionEnd:Y,connectionMode:L=Zr.Strict,connectionLineType:K=Tr.Bezier,connectionLineStyle:I,connectionLineComponent:F,connectionLineContainerStyle:ae,deleteKeyCode:q="Backspace",selectionKeyCode:V="Shift",selectionOnDrag:Q=!1,selectionMode:re=Yo.Full,panActivationKeyCode:ce="Space",multiSelectionKeyCode:he=Ua()?"Meta":"Control",zoomActivationKeyCode:pe=Ua()?"Meta":"Control",snapToGrid:je=!1,snapGrid:$e=uM,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Ae=!0,nodesDraggable:we,nodesConnectable:Be,nodesFocusable:ve,nodeOrigin:ge=aM,edgesFocusable:ze,edgesUpdatable:et,elementsSelectable:ft,defaultViewport:lt=lM,minZoom:Ue=.5,maxZoom:Ge=2,translateExtent:xt=tv,preventScrolling:St=!0,nodeExtent:Et,defaultMarkerColor:tt="#b1b1b7",zoomOnScroll:mt=!0,zoomOnPinch:Mt=!0,panOnScroll:He=!1,panOnScrollSpeed:vt=.5,panOnScrollMode:Ke=Kr.Free,zoomOnDoubleClick:dt=!0,panOnDrag:Qe=!0,onPaneClick:Pt,onPaneMouseEnter:kt,onPaneMouseMove:Xt,onPaneMouseLeave:qn,onPaneScroll:Qt,onPaneContextMenu:Dt,children:yn,onEdgeContextMenu:nt,onEdgeDoubleClick:oe,onEdgeMouseEnter:se,onEdgeMouseMove:Se,onEdgeMouseLeave:Te,onEdgeUpdate:be,onEdgeUpdateStart:Ie,onEdgeUpdateEnd:st,onReconnect:wn,onReconnectStart:Zt,onReconnectEnd:Tt,reconnectRadius:Rt=10,edgeUpdaterRadius:on=10,onNodesChange:or,onEdgesChange:jr,noDragClassName:Wi="nodrag",noWheelClassName:Gi="nowheel",noPanClassName:as="nopan",fitView:Un=!1,fitViewOptions:us,connectOnClick:ls=!0,attributionPosition:wu,proOptions:cs,defaultEdgeOptions:fs,elevateNodesOnSelect:ds=!0,elevateEdgesOnSelect:hs=!1,disableKeyboardA11y:ps=!1,autoPanOnConnect:_u=!0,autoPanOnNodeDrag:rt=!0,connectionRadius:xu=20,isValidConnection:Ki,onError:ms,style:ri,id:vs,nodeDragThreshold:gs,...ii},sn)=>{const Yi=vs||"1";return ie.createElement("div",{...ii,style:{...ri,...cM},ref:sn,className:jt(["react-flow",s]),"data-testid":"rf__wrapper",id:vs},ie.createElement(xb,null,ie.createElement(rM,{onInit:p,onMove:h,onMoveStart:v,onMoveEnd:g,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:k,onNodeMouseMove:T,onNodeMouseLeave:C,onNodeContextMenu:A,onNodeDoubleClick:j,nodeTypes:u,edgeTypes:l,connectionLineType:K,connectionLineStyle:I,connectionLineComponent:F,connectionLineContainerStyle:ae,selectionKeyCode:V,selectionOnDrag:Q,selectionMode:re,deleteKeyCode:q,multiSelectionKeyCode:he,panActivationKeyCode:ce,zoomActivationKeyCode:pe,onlyRenderVisibleElements:Me,selectNodesOnDrag:Ae,defaultViewport:lt,translateExtent:xt,minZoom:Ue,maxZoom:Ge,preventScrolling:St,zoomOnScroll:mt,zoomOnPinch:Mt,zoomOnDoubleClick:dt,panOnScroll:He,panOnScrollSpeed:vt,panOnScrollMode:Ke,panOnDrag:Qe,onPaneClick:Pt,onPaneMouseEnter:kt,onPaneMouseMove:Xt,onPaneMouseLeave:qn,onPaneScroll:Qt,onPaneContextMenu:Dt,onSelectionContextMenu:H,onSelectionStart:ne,onSelectionEnd:Y,onEdgeContextMenu:nt,onEdgeDoubleClick:oe,onEdgeMouseEnter:se,onEdgeMouseMove:Se,onEdgeMouseLeave:Te,onReconnect:wn??be,onReconnectStart:Zt??Ie,onReconnectEnd:Tt??st,reconnectRadius:Rt??on,defaultMarkerColor:tt,noDragClassName:Wi,noWheelClassName:Gi,noPanClassName:as,elevateEdgesOnSelect:hs,rfId:Yi,disableKeyboardA11y:ps,nodeOrigin:ge,nodeExtent:Et}),ie.createElement(JI,{nodes:e,edges:r,defaultNodes:i,defaultEdges:o,onConnect:w,onConnectStart:N,onConnectEnd:_,onClickConnectStart:E,onClickConnectEnd:x,nodesDraggable:we,nodesConnectable:Be,nodesFocusable:ve,edgesFocusable:ze,edgesUpdatable:et,elementsSelectable:ft,elevateNodesOnSelect:ds,minZoom:Ue,maxZoom:Ge,nodeExtent:Et,onNodesChange:or,onEdgesChange:jr,snapToGrid:je,snapGrid:$e,connectionMode:L,translateExtent:xt,connectOnClick:ls,defaultEdgeOptions:fs,fitView:Un,fitViewOptions:us,onNodesDelete:B,onEdgesDelete:U,onNodeDragStart:M,onNodeDrag:z,onNodeDragStop:O,onSelectionDrag:R,onSelectionDragStart:X,onSelectionDragStop:G,noPanClassName:as,nodeOrigin:ge,rfId:Yi,autoPanOnConnect:_u,autoPanOnNodeDrag:rt,onError:ms,connectionRadius:xu,isValidConnection:Ki,nodeDragThreshold:gs}),ie.createElement(QI,{onSelectionChange:ee}),yn,ie.createElement(bI,{proOptions:cs,position:wu}),ie.createElement(ij,{rfId:Yi,disableKeyboardA11y:ps})))});Sb.displayName="ReactFlow";const fM=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function Eb(){return Fe(fM,wt)}const kb=({id:e,x:r,y:i,width:o,height:s,style:u,color:l,strokeColor:c,strokeWidth:d,className:p,borderRadius:h,shapeRendering:v,onClick:g,selected:w})=>{const{background:N,backgroundColor:_}=u||{},E=l||N||_;return ie.createElement("rect",{className:jt(["react-flow__minimap-node",{selected:w},p]),x:r,y:i,rx:h,ry:h,width:o,height:s,fill:E,stroke:c,strokeWidth:d,shapeRendering:v,onClick:g?x=>g(x,e):void 0})};kb.displayName="MiniMapNode";var dM=D.memo(kb);const hM=e=>e.nodeOrigin,pM=e=>e.getNodes().filter(r=>!r.hidden&&r.width&&r.height),wc=e=>e instanceof Function?e:()=>e;function mM({nodeStrokeColor:e="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:s=2,nodeComponent:u=dM,onClick:l}){const c=Fe(pM,wt),d=Fe(hM),p=wc(r),h=wc(e),v=wc(i),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ie.createElement(ie.Fragment,null,c.map(w=>{const{x:N,y:_}=Xr(w,d).positionAbsolute;return ie.createElement(u,{key:w.id,x:N,y:_,width:w.width,height:w.height,style:w.style,selected:w.selected,className:v(w),color:p(w),borderRadius:o,strokeColor:h(w),strokeWidth:s,shapeRendering:g,onClick:l,id:w.id})}))}var vM=D.memo(mM);const gM=200,yM=150,wM=e=>{const r=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:r.length>0?TI(eu(r,e.nodeOrigin),i):i,rfId:e.rfId}},_M="react-flow__minimap-desc";function bb({style:e,className:r,nodeStrokeColor:i="transparent",nodeColor:o="#e2e2e2",nodeClassName:s="",nodeBorderRadius:u=5,nodeStrokeWidth:l=2,nodeComponent:c,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:p="none",maskStrokeWidth:h=1,position:v="bottom-right",onClick:g,onNodeClick:w,pannable:N=!1,zoomable:_=!1,ariaLabel:E="React Flow mini map",inversePan:x=!1,zoomStep:k=10,offsetScale:T=5}){const C=_t(),A=D.useRef(null),{boundingRect:j,viewBB:M,rfId:z}=Fe(wM,wt),O=(e==null?void 0:e.width)??gM,B=(e==null?void 0:e.height)??yM,U=j.width/O,ee=j.height/B,X=Math.max(U,ee),R=X*O,G=X*B,H=T*X,ne=j.x-(R-j.width)/2-H,Y=j.y-(G-j.height)/2-H,L=R+H*2,K=G+H*2,I=`${_M}-${z}`,F=D.useRef(0);F.current=X,D.useEffect(()=>{if(A.current){const V=pn(A.current),Q=he=>{const{transform:pe,d3Selection:je,d3Zoom:$e}=C.getState();if(he.sourceEvent.type!=="wheel"||!je||!$e)return;const Me=-he.sourceEvent.deltaY*(he.sourceEvent.deltaMode===1?.05:he.sourceEvent.deltaMode?1:.002)*k,Ae=pe[2]*Math.pow(2,Me);$e.scaleTo(je,Ae)},re=he=>{const{transform:pe,d3Selection:je,d3Zoom:$e,translateExtent:Me,width:Ae,height:we}=C.getState();if(he.sourceEvent.type!=="mousemove"||!je||!$e)return;const Be=F.current*Math.max(1,pe[2])*(x?-1:1),ve={x:pe[0]-he.sourceEvent.movementX*Be,y:pe[1]-he.sourceEvent.movementY*Be},ge=[[0,0],[Ae,we]],ze=er.translate(ve.x,ve.y).scale(pe[2]),et=$e.constrain()(ze,ge,Me);$e.transform(je,et)},ce=Mk().on("zoom",N?re:null).on("zoom.wheel",_?Q:null);return V.call(ce),()=>{V.on("zoom",null)}}},[N,_,x,k]);const ae=g?V=>{const Q=Tn(V);g(V,{x:Q[0],y:Q[1]})}:void 0,q=w?(V,Q)=>{const re=C.getState().nodeInternals.get(Q);w(V,re)}:void 0;return ie.createElement(vv,{position:v,style:e,className:jt(["react-flow__minimap",r]),"data-testid":"rf__minimap"},ie.createElement("svg",{width:O,height:B,viewBox:`${ne} ${Y} ${L} ${K}`,role:"img","aria-labelledby":I,ref:A,onClick:ae},E&&ie.createElement("title",{id:I},E),ie.createElement(vM,{onClick:q,nodeColor:o,nodeStrokeColor:i,nodeBorderRadius:u,nodeClassName:s,nodeStrokeWidth:l,nodeComponent:c}),ie.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-H},${Y-H}h${L+H*2}v${K+H*2}h${-L-H*2}z
57
- M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fill:d,fillRule:"evenodd",stroke:p,strokeWidth:h,pointerEvents:"none"})))}bb.displayName="MiniMap";var xM=D.memo(bb);function SM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ie.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function EM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ie.createElement("path",{d:"M0 0h32v4.2H0z"}))}function kM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ie.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 bM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ie.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 NM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ie.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 Mi=({children:e,className:r,...i})=>ie.createElement("button",{type:"button",className:jt(["react-flow__controls-button",r]),...i},e);Mi.displayName="ControlButton";const CM=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Nb=({style:e,showZoom:r=!0,showFitView:i=!0,showInteractive:o=!0,fitViewOptions:s,onZoomIn:u,onZoomOut:l,onFitView:c,onInteractiveChange:d,className:p,children:h,position:v="bottom-left"})=>{const g=_t(),[w,N]=D.useState(!1),{isInteractive:_,minZoomReached:E,maxZoomReached:x}=Fe(CM,wt),{zoomIn:k,zoomOut:T,fitView:C}=ts();if(D.useEffect(()=>{N(!0)},[]),!w)return null;const A=()=>{k(),u==null||u()},j=()=>{T(),l==null||l()},M=()=>{C(s),c==null||c()},z=()=>{g.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),d==null||d(!_)};return ie.createElement(vv,{className:jt(["react-flow__controls",p]),position:v,style:e,"data-testid":"rf__controls"},r&&ie.createElement(ie.Fragment,null,ie.createElement(Mi,{onClick:A,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x},ie.createElement(SM,null)),ie.createElement(Mi,{onClick:j,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:E},ie.createElement(EM,null))),i&&ie.createElement(Mi,{className:"react-flow__controls-fitview",onClick:M,title:"fit view","aria-label":"fit view"},ie.createElement(kM,null)),o&&ie.createElement(Mi,{className:"react-flow__controls-interactive",onClick:z,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ie.createElement(NM,null):ie.createElement(bM,null)),h)};Nb.displayName="Controls";var TM=D.memo(Nb),In;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(In||(In={}));function RM({color:e,dimensions:r,lineWidth:i}){return ie.createElement("path",{stroke:e,strokeWidth:i,d:`M${r[0]/2} 0 V${r[1]} M0 ${r[1]/2} H${r[0]}`})}function AM({color:e,radius:r}){return ie.createElement("circle",{cx:r,cy:r,r,fill:e})}const IM={[In.Dots]:"#91919a",[In.Lines]:"#eee",[In.Cross]:"#e2e2e2"},jM={[In.Dots]:1,[In.Lines]:1,[In.Cross]:6},MM=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Cb({id:e,variant:r=In.Dots,gap:i=20,size:o,lineWidth:s=1,offset:u=2,color:l,style:c,className:d}){const p=D.useRef(null),{transform:h,patternId:v}=Fe(MM,wt),g=l||IM[r],w=o||jM[r],N=r===In.Dots,_=r===In.Cross,E=Array.isArray(i)?i:[i,i],x=[E[0]*h[2]||1,E[1]*h[2]||1],k=w*h[2],T=_?[k,k]:x,C=N?[k/u,k/u]:[T[0]/u,T[1]/u];return ie.createElement("svg",{className:jt(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},ie.createElement("pattern",{id:v+e,x:h[0]%x[0],y:h[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},N?ie.createElement(AM,{color:g,radius:k/u}):ie.createElement(RM,{dimensions:T,color:g,lineWidth:s})),ie.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${v+e})`}))}Cb.displayName="Background";var PM=D.memo(Cb);function Tb(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function Rb(e,r=0){if(!e||typeof e!="object"||r>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 o of Object.values(i)){const s=Rb(o,r+1);if(s)return s}return null}function qM(e,r){e.inputTokens+=r.inputTokens,e.outputTokens+=r.outputTokens,e.cacheReadTokens+=r.cacheReadTokens,e.cacheCreateTokens+=r.cacheCreateTokens}function Ab(e,r=0){if(!e||typeof e!="object"||r>6)return null;const i=e;if(typeof i.model=="string"&&/^claude[-_]/i.test(i.model))return i.model;for(const o of Object.values(i)){const s=Ab(o,r+1);if(s)return s}return null}function nv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,totalEvents:0}}function Ar(e){if(!e)return;const r=e.replace(/\\/g,"/").split("/").filter(Boolean);return r[r.length-1]}function Cv(e,r){return`${e}::${r}`}function Wa(e){return e.agent_type??e.subagent_type??"subagent"}function rv(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Bo(e,r,i,o){const s=r;let u=e.agents.get(s);return u||(u={id:s,sessionId:r,label:"session",kind:"root",state:"active",startedAt:i,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:o,inFlightTool:null,usage:Tb()},e.agents.set(s,u),u)}function Ib(e,r,i,o){const s=Cv(r,i),u=e.agents.get(s);if(!u)return null;!u.cwd&&o.cwd&&(u.cwd=o.cwd,u.cwdBasename=Ar(o.cwd));const l=Wa(o);return l&&(u.label==="subagent"||!u.label)&&(u.label=l),u}function xw(e,r,i){const o=r.session_id??"unknown",s=rv(r);if(s){const d=Ib(e,o,s,r);if(d)return d}const u=e.activeSubagentStack.get(o),l=u&&u.length>0?u[u.length-1]:null;if(l){const d=e.agents.get(Cv(o,l));if(d)return!d.cwd&&r.cwd&&(d.cwd=r.cwd,d.cwdBasename=Ar(r.cwd)),d}const c=Bo(e,o,i,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=i),!c.cwd&&r.cwd&&(c.cwd=r.cwd,c.cwdBasename=Ar(r.cwd)),c.label==="session"&&r.cwd&&(c.label=Ar(r.cwd)??"session"),c}function OM(e,r,i,o,s){const u=Cv(r,i),l=Bo(e,r,s,!0);let c=e.agents.get(u);if(c){!c.cwd&&o.cwd&&(c.cwd=o.cwd,c.cwdBasename=Ar(o.cwd));const d=Wa(o);return d&&(c.label==="subagent"||!c.label)&&(c.label=d),c}return c={id:u,sessionId:r,label:Wa(o),kind:"subagent",parentId:l.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:o.cwd,cwdBasename:Ar(o.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:Tb()},e.agents.set(u,c),l.childCount+=1,c}function LM(e,r,i){const o=e.activeSubagentStack.get(r)??[];o.push(i),e.activeSubagentStack.set(r,o)}function $M(e,r,i){const o=e.activeSubagentStack.get(r);if(o){for(let s=o.length-1;s>=0;s--)if(o[s]===i){o.splice(s,1);break}o.length===0&&e.activeSubagentStack.delete(r)}}function _c(e,r=80){if(e==null)return"";if(typeof e=="string")return e.length>r?e.slice(0,r-1)+"…":e;try{const i=JSON.stringify(e);return i.length>r?i.slice(0,r-1)+"…":i}catch{return String(e)}}function $o(e){let r=null;for(let i=e.tools.length-1;i>=0;i--){const o=e.tools[i];if(o.endedAt==null){r=o;break}}e.inFlightTool=r}function DM(e,r,i,o){if(e.agents.size<=i)return!1;const s=[];for(const[l,c]of e.agents)c.state==="done"&&c.endedAt!=null&&r-c.endedAt>o&&s.push({id:l,endedAt:c.endedAt});if(s.length===0)return!1;s.sort((l,c)=>l.endedAt-c.endedAt);let u=0;for(const l of s){if(e.agents.size<=i)break;e.agents.delete(l.id),u++}return u>0}function FM(e,r,i){let o=!1;for(const s of e.agents.values()){let u=!1;for(const l of s.tools)l.endedAt==null&&r-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,o=!0);u&&$o(s)}return o}function Sw(e,r){if(r.seq<=e.lastSeq)return e;const i=r.payload??{},o=r.receivedAt,s=i.hook_event_name??"Unknown";if(s==="__clear")return{...nv(),lastSeq:r.seq};e.totalEvents+=1,e.lastSeq=r.seq;const u=i.session_id??"unknown";if(s==="ModelObserved"){const d=typeof i.model=="string"?i.model:null;if(d){const h=e.agents.get(u);h&&(h.model=d)}const p=i.subagentModels;if(p&&typeof p=="object")for(const[h,v]of Object.entries(p)){if(typeof v!="string")continue;const g=`${u}::${h}`,w=e.agents.get(g);w&&(w.model=v)}return e}if(s==="ContextObserved"){const d=i.context??null;if(d){const p=e.agents.get(u);p&&(p.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(s==="UsageObserved"){const d=i.usage??null;if(d){const p=e.agents.get(u);p&&(p.usage.inputTokens=Number(d.input_tokens??0),p.usage.outputTokens=Number(d.output_tokens??0),p.usage.cacheReadTokens=Number(d.cache_read_input_tokens??0),p.usage.cacheCreateTokens=Number(d.cache_creation_input_tokens??0))}return e}const l=xw(e,i,o),c=Ab(i);switch(c&&(l.model=c),s){case"SessionStart":{const d=Bo(e,u,o,!1);d.synthetic=!1,d.state="active",d.startedAt=d.startedAt||o,!d.cwd&&i.cwd&&(d.cwd=i.cwd,d.cwdBasename=Ar(i.cwd)),d.label==="session"&&i.cwd&&(d.label=Ar(i.cwd)??"session");break}case"UserPromptSubmit":{const d=Bo(e,u,o,!1);d.state="active",d.endedAt=void 0,d.exitAt=void 0;const p=xw(e,i,o);p.state="active",p.exitAt=void 0,p.endedAt=void 0;const h=(typeof i.prompt=="string"?i.prompt:typeof i.message=="string"?i.message:"")??"";h&&(p.prompts.push({at:o,text:h}),p.firstPrompt||(p.firstPrompt=_c(h,120)));break}case"PreToolUse":{const d=i.tool_use_id??`${l.id}:${l.toolCount}`,p={id:d,name:i.tool_name??"?",input:i.tool_input,inputPreview:_c(i.tool_input),agentId:l.id,startedAt:o};l.tools.push(p),l.toolCount+=1,l.state="active",e.toolIndex.set(d,p),e.toolOwner.set(d,l.id),$o(l);break}case"PostToolUse":case"PostToolUseFailure":{const d=i.tool_use_id;if(!d)break;let p=e.toolIndex.get(d),h=!1;if(!p)for(const w of e.agents.values()){const N=w.tools.find(_=>_.id===d);if(N){p=N,h=!0;break}}if(!p)break;p.endedAt=o,p.ok=s==="PostToolUse",p.response=i.tool_response,s==="PostToolUseFailure"?p.errorPreview=_c(i.tool_response):h&&(p.errorPreview=void 0);const v=Rb(i.tool_response);v&&(p.usage=v),e.toolIndex.delete(d);const g=e.toolOwner.get(d)??p.agentId;if(e.toolOwner.delete(d),g){const w=e.agents.get(g);w&&(v&&qM(w.usage,v),$o(w))}break}case"SubagentStart":{const d=rv(i);if(!d)break;const p=OM(e,u,d,i,o);p.state="active",p.startedAt=p.startedAt||o,p.exitAt=void 0,p.endedAt=void 0;const h=Wa(i);h&&(p.label=h),LM(e,u,d);break}case"SubagentStop":{const d=rv(i);if(!d)break;const p=Ib(e,u,d,i);if(!p)break;p.state="done",p.endedAt=o,$o(p),$M(e,u,d);break}case"Stop":case"SessionEnd":{const d=Bo(e,u,o,!1);d.state="done",d.endedAt=o,$o(d);break}}return e}function Tv(e){let r=5381;for(let i=0;i<e.length;i++)r=(r<<5)+r^e.charCodeAt(i);return Math.abs(r)%360}const zM=[{match:/^claude[-_](fable|mythos)[-_]5\b/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5}},{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}}];function Rv(e){if(!e)return null;for(const r of zM)if(r.match.test(e))return r.rates;return null}function An(e,r){const i=Rv(r);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=e.inputTokens*i.input/1e6,s=e.outputTokens*i.output/1e6,u=e.cacheReadTokens*i.cacheRead/1e6,l=e.cacheCreateTokens*i.cacheWrite/1e6;return{input:o,output:s,cacheRead:u,cacheWrite:l,total:o+s+u+l}}const Ew=2e5,BM=1e6,UM=[/\[1m\]/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i];function jb(e){if(!e)return Ew;for(const r of UM)if(r.test(e))return BM;return Ew}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 iv(e,r){if(e<=0||r<10)return null;const i=e/r,o=i*60;return o>=.01?`${We(o)}/min`:`${We(i*3600)}/hr`}function hn(e){return e.toLocaleString()}function HM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function VM({agent:e,onClose:r}){var p;const i=e.context,o=e.usage,s=(i==null?void 0:i.currentContextTokens)??0,u=jb(e.model),l=Math.min(100,s/u*100),c=An(o,e.model),d=o.inputTokens+o.cacheReadTokens+o.cacheCreateTokens;return S.jsx("div",{className:"ctx-modal-backdrop",onClick:r,role:"presentation",children:S.jsxs("div",{className:"ctx-modal",onClick:h=>h.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[S.jsxs("header",{className:"ctx-modal-head",children:[S.jsxs("div",{children:[S.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),S.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),S.jsx("button",{className:"ctx-modal-close",onClick:r,"aria-label":"Close",children:"×"})]}),S.jsxs("section",{className:"ctx-window-row",children:[S.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(l),children:S.jsx("div",{className:"ctx-window-fill",style:{width:`${l}%`}})}),S.jsxs("div",{className:"ctx-window-meta",children:[S.jsxs("span",{className:"ctx-window-pct",children:[l.toFixed(1),"%"]}),S.jsxs("span",{className:"ctx-window-num",children:[hn(s)," / ",hn(u)," tok (current turn)"]})]})]}),S.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),S.jsxs("div",{className:"ctx-grid",children:[S.jsx(Cn,{label:"input tokens",val:hn(o.inputTokens)}),S.jsx(Cn,{label:"output tokens",val:hn(o.outputTokens)}),S.jsx(Cn,{label:"cache reads",val:hn(o.cacheReadTokens)}),S.jsx(Cn,{label:"cache writes",val:hn(o.cacheCreateTokens)}),S.jsx(Cn,{label:"cumulative total",val:hn(d)}),S.jsx(Cn,{label:"estimated cost",val:We(c.total),accent:!0})]}),S.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),S.jsxs("div",{className:"ctx-grid",children:[S.jsx(Cn,{label:"user messages",val:hn((i==null?void 0:i.msgsUser)??0)}),S.jsx(Cn,{label:"assistant messages",val:hn((i==null?void 0:i.msgsAssistant)??0)}),S.jsx(Cn,{label:"tool uses",val:hn((i==null?void 0:i.toolUses)??0)}),S.jsx(Cn,{label:"tool results",val:hn((i==null?void 0:i.toolResults)??0)}),S.jsx(Cn,{label:"system-reminders",val:hn((i==null?void 0:i.systemReminders)??0)})]}),S.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((p=i==null?void 0:i.claudeMdFiles)==null?void 0:p.length)??0)===0?S.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):S.jsx("ul",{className:"ctx-md-list",children:i.claudeMdFiles.map(h=>S.jsxs("li",{children:[S.jsx("span",{className:"ctx-md-path",title:h.path,children:h.path}),S.jsx("span",{className:"ctx-md-size",children:HM(h.bytes)})]},h.path))})]})})}function Cn({label:e,val:r,accent:i}){return S.jsxs("div",{className:`ctx-row${i?" accent":""}`,children:[S.jsx("span",{className:"ctx-row-label",children:e}),S.jsx("span",{className:"ctx-row-val",children:r})]})}function WM({currentContextTokens:e,modelId:r,size:i=26,onClick:o,title:s}){const u=jb(r),l=Math.min(1,e/u),c=i/2-3,d=i/2,p=2*Math.PI*c,h=p*l,v=l>.9?"var(--err)":l>.7?"var(--inflight)":"var(--accent)";return S.jsx("button",{type:"button",className:"ctx-donut",onClick:o,title:s??`context: ${e.toLocaleString()} / ${u.toLocaleString()} (${(l*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:S.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[S.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),S.jsx("circle",{cx:d,cy:d,r:c,stroke:v,strokeWidth:"2.5",fill:"none",strokeDasharray:`${h} ${p-h}`,strokeDashoffset:p/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),S.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(l*100)})]})})}function GM(e,r){const i=Rv(r);if(!i)return"no rates for this model";const o=l=>l.toLocaleString(),s=l=>`$${l}/MTok`,u=An(e,r);return[`model: ${r}`,`input ${o(e.inputTokens).padStart(14)} × ${s(i.input).padEnd(11)} = ${We(u.input)}`,`output ${o(e.outputTokens).padStart(14)} × ${s(i.output).padEnd(11)} = ${We(u.output)}`,`cache r ${o(e.cacheReadTokens).padStart(14)} × ${s(i.cacheRead).padEnd(11)} = ${We(u.cacheRead)}`,`cache w ${o(e.cacheCreateTokens).padStart(14)} × ${s(i.cacheWrite).padEnd(11)} = ${We(u.cacheWrite)}`,"─────────────────────────────────────────",`total = ${We(u.total)}`].join(`
57
+ M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fill:d,fillRule:"evenodd",stroke:p,strokeWidth:h,pointerEvents:"none"})))}bb.displayName="MiniMap";var xM=D.memo(bb);function SM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ie.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function EM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ie.createElement("path",{d:"M0 0h32v4.2H0z"}))}function kM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ie.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 bM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ie.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 NM(){return ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ie.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 Mi=({children:e,className:r,...i})=>ie.createElement("button",{type:"button",className:jt(["react-flow__controls-button",r]),...i},e);Mi.displayName="ControlButton";const CM=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Nb=({style:e,showZoom:r=!0,showFitView:i=!0,showInteractive:o=!0,fitViewOptions:s,onZoomIn:u,onZoomOut:l,onFitView:c,onInteractiveChange:d,className:p,children:h,position:v="bottom-left"})=>{const g=_t(),[w,N]=D.useState(!1),{isInteractive:_,minZoomReached:E,maxZoomReached:x}=Fe(CM,wt),{zoomIn:k,zoomOut:T,fitView:C}=ts();if(D.useEffect(()=>{N(!0)},[]),!w)return null;const A=()=>{k(),u==null||u()},j=()=>{T(),l==null||l()},M=()=>{C(s),c==null||c()},z=()=>{g.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),d==null||d(!_)};return ie.createElement(vv,{className:jt(["react-flow__controls",p]),position:v,style:e,"data-testid":"rf__controls"},r&&ie.createElement(ie.Fragment,null,ie.createElement(Mi,{onClick:A,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x},ie.createElement(SM,null)),ie.createElement(Mi,{onClick:j,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:E},ie.createElement(EM,null))),i&&ie.createElement(Mi,{className:"react-flow__controls-fitview",onClick:M,title:"fit view","aria-label":"fit view"},ie.createElement(kM,null)),o&&ie.createElement(Mi,{className:"react-flow__controls-interactive",onClick:z,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ie.createElement(NM,null):ie.createElement(bM,null)),h)};Nb.displayName="Controls";var TM=D.memo(Nb),In;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(In||(In={}));function RM({color:e,dimensions:r,lineWidth:i}){return ie.createElement("path",{stroke:e,strokeWidth:i,d:`M${r[0]/2} 0 V${r[1]} M0 ${r[1]/2} H${r[0]}`})}function AM({color:e,radius:r}){return ie.createElement("circle",{cx:r,cy:r,r,fill:e})}const IM={[In.Dots]:"#91919a",[In.Lines]:"#eee",[In.Cross]:"#e2e2e2"},jM={[In.Dots]:1,[In.Lines]:1,[In.Cross]:6},MM=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Cb({id:e,variant:r=In.Dots,gap:i=20,size:o,lineWidth:s=1,offset:u=2,color:l,style:c,className:d}){const p=D.useRef(null),{transform:h,patternId:v}=Fe(MM,wt),g=l||IM[r],w=o||jM[r],N=r===In.Dots,_=r===In.Cross,E=Array.isArray(i)?i:[i,i],x=[E[0]*h[2]||1,E[1]*h[2]||1],k=w*h[2],T=_?[k,k]:x,C=N?[k/u,k/u]:[T[0]/u,T[1]/u];return ie.createElement("svg",{className:jt(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},ie.createElement("pattern",{id:v+e,x:h[0]%x[0],y:h[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},N?ie.createElement(AM,{color:g,radius:k/u}):ie.createElement(RM,{dimensions:T,color:g,lineWidth:s})),ie.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${v+e})`}))}Cb.displayName="Background";var PM=D.memo(Cb);function Tb(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function Rb(e,r=0){if(!e||typeof e!="object"||r>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 o of Object.values(i)){const s=Rb(o,r+1);if(s)return s}return null}function qM(e,r){e.inputTokens+=r.inputTokens,e.outputTokens+=r.outputTokens,e.cacheReadTokens+=r.cacheReadTokens,e.cacheCreateTokens+=r.cacheCreateTokens}function Ab(e,r=0){if(!e||typeof e!="object"||r>6)return null;const i=e;if(typeof i.model=="string"&&/^claude[-_]/i.test(i.model))return i.model;for(const o of Object.values(i)){const s=Ab(o,r+1);if(s)return s}return null}function nv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,totalEvents:0}}function Ar(e){if(!e)return;const r=e.replace(/\\/g,"/").split("/").filter(Boolean);return r[r.length-1]}function Cv(e,r){return`${e}::${r}`}function Wa(e){return e.agent_type??e.subagent_type??"subagent"}function rv(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Bo(e,r,i,o){const s=r;let u=e.agents.get(s);return u||(u={id:s,sessionId:r,label:"session",kind:"root",state:"active",startedAt:i,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:o,inFlightTool:null,usage:Tb()},e.agents.set(s,u),u)}function Ib(e,r,i,o){const s=Cv(r,i),u=e.agents.get(s);if(!u)return null;!u.cwd&&o.cwd&&(u.cwd=o.cwd,u.cwdBasename=Ar(o.cwd));const l=Wa(o);return l&&(u.label==="subagent"||!u.label)&&(u.label=l),u}function xw(e,r,i){const o=r.session_id??"unknown",s=rv(r);if(s){const d=Ib(e,o,s,r);if(d)return d}const u=e.activeSubagentStack.get(o),l=u&&u.length>0?u[u.length-1]:null;if(l){const d=e.agents.get(Cv(o,l));if(d)return!d.cwd&&r.cwd&&(d.cwd=r.cwd,d.cwdBasename=Ar(r.cwd)),d}const c=Bo(e,o,i,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=i),!c.cwd&&r.cwd&&(c.cwd=r.cwd,c.cwdBasename=Ar(r.cwd)),c.label==="session"&&r.cwd&&(c.label=Ar(r.cwd)??"session"),c}function OM(e,r,i,o,s){const u=Cv(r,i),l=Bo(e,r,s,!0);let c=e.agents.get(u);if(c){!c.cwd&&o.cwd&&(c.cwd=o.cwd,c.cwdBasename=Ar(o.cwd));const d=Wa(o);return d&&(c.label==="subagent"||!c.label)&&(c.label=d),c}return c={id:u,sessionId:r,label:Wa(o),kind:"subagent",parentId:l.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:o.cwd,cwdBasename:Ar(o.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:Tb()},e.agents.set(u,c),l.childCount+=1,c}function LM(e,r,i){const o=e.activeSubagentStack.get(r)??[];o.push(i),e.activeSubagentStack.set(r,o)}function $M(e,r,i){const o=e.activeSubagentStack.get(r);if(o){for(let s=o.length-1;s>=0;s--)if(o[s]===i){o.splice(s,1);break}o.length===0&&e.activeSubagentStack.delete(r)}}function _c(e,r=80){if(e==null)return"";if(typeof e=="string")return e.length>r?e.slice(0,r-1)+"…":e;try{const i=JSON.stringify(e);return i.length>r?i.slice(0,r-1)+"…":i}catch{return String(e)}}function $o(e){let r=null;for(let i=e.tools.length-1;i>=0;i--){const o=e.tools[i];if(o.endedAt==null){r=o;break}}e.inFlightTool=r}function DM(e,r,i,o){if(e.agents.size<=i)return!1;const s=[];for(const[l,c]of e.agents)c.state==="done"&&c.endedAt!=null&&r-c.endedAt>o&&s.push({id:l,endedAt:c.endedAt});if(s.length===0)return!1;s.sort((l,c)=>l.endedAt-c.endedAt);let u=0;for(const l of s){if(e.agents.size<=i)break;e.agents.delete(l.id),u++}return u>0}function FM(e,r,i){let o=!1;for(const s of e.agents.values()){let u=!1;for(const l of s.tools)l.endedAt==null&&r-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,o=!0);u&&$o(s)}return o}function Sw(e,r){if(r.seq<=e.lastSeq)return e;const i=r.payload??{},o=r.receivedAt,s=i.hook_event_name??"Unknown";if(s==="__clear")return{...nv(),lastSeq:r.seq};e.totalEvents+=1,e.lastSeq=r.seq;const u=i.session_id??"unknown";if(s==="ModelObserved"){const d=typeof i.model=="string"?i.model:null;if(d){const h=e.agents.get(u);h&&(h.model=d)}const p=i.subagentModels;if(p&&typeof p=="object")for(const[h,v]of Object.entries(p)){if(typeof v!="string")continue;const g=`${u}::${h}`,w=e.agents.get(g);w&&(w.model=v)}return e}if(s==="ContextObserved"){const d=i.context??null;if(d){const p=e.agents.get(u);p&&(p.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(s==="UsageObserved"){const d=i.usage??null;if(d){const p=e.agents.get(u);p&&(p.usage.inputTokens=Number(d.input_tokens??0),p.usage.outputTokens=Number(d.output_tokens??0),p.usage.cacheReadTokens=Number(d.cache_read_input_tokens??0),p.usage.cacheCreateTokens=Number(d.cache_creation_input_tokens??0))}return e}const l=xw(e,i,o),c=Ab(i);switch(c&&(l.model=c),s){case"SessionStart":{const d=Bo(e,u,o,!1);d.synthetic=!1,d.state="active",d.startedAt=d.startedAt||o,!d.cwd&&i.cwd&&(d.cwd=i.cwd,d.cwdBasename=Ar(i.cwd)),d.label==="session"&&i.cwd&&(d.label=Ar(i.cwd)??"session");break}case"UserPromptSubmit":{for(const v of e.agents.values())v.sessionId===u&&v.kind==="subagent"&&v.state==="done"&&v.exitAt==null&&v.endedAt!=null&&v.endedAt<o&&(v.exitAt=o);const d=Bo(e,u,o,!1);d.state="active",d.endedAt=void 0,d.exitAt=void 0;const p=xw(e,i,o);p.state="active",p.exitAt=void 0,p.endedAt=void 0;const h=(typeof i.prompt=="string"?i.prompt:typeof i.message=="string"?i.message:"")??"";h&&(p.prompts.push({at:o,text:h}),p.firstPrompt||(p.firstPrompt=_c(h,120)));break}case"PreToolUse":{const d=i.tool_use_id??`${l.id}:${l.toolCount}`,p={id:d,name:i.tool_name??"?",input:i.tool_input,inputPreview:_c(i.tool_input),agentId:l.id,startedAt:o};l.tools.push(p),l.toolCount+=1,l.state="active",e.toolIndex.set(d,p),e.toolOwner.set(d,l.id),$o(l);break}case"PostToolUse":case"PostToolUseFailure":{const d=i.tool_use_id;if(!d)break;let p=e.toolIndex.get(d),h=!1;if(!p)for(const w of e.agents.values()){const N=w.tools.find(_=>_.id===d);if(N){p=N,h=!0;break}}if(!p)break;p.endedAt=o,p.ok=s==="PostToolUse",p.response=i.tool_response,s==="PostToolUseFailure"?p.errorPreview=_c(i.tool_response):h&&(p.errorPreview=void 0);const v=Rb(i.tool_response);v&&(p.usage=v),e.toolIndex.delete(d);const g=e.toolOwner.get(d)??p.agentId;if(e.toolOwner.delete(d),g){const w=e.agents.get(g);w&&(v&&qM(w.usage,v),$o(w))}break}case"SubagentStart":{const d=rv(i);if(!d)break;const p=OM(e,u,d,i,o);p.state="active",p.startedAt=p.startedAt||o,p.exitAt=void 0,p.endedAt=void 0;const h=Wa(i);h&&(p.label=h),LM(e,u,d);break}case"SubagentStop":{const d=rv(i);if(!d)break;const p=Ib(e,u,d,i);if(!p)break;p.state="done",p.endedAt=o,$o(p),$M(e,u,d);break}case"Stop":case"SessionEnd":{const d=Bo(e,u,o,!1);d.state="done",d.endedAt=o,$o(d);break}}return e}function Tv(e){let r=5381;for(let i=0;i<e.length;i++)r=(r<<5)+r^e.charCodeAt(i);return Math.abs(r)%360}const zM=[{match:/^claude[-_](fable|mythos)[-_]5\b/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5}},{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}}];function Rv(e){if(!e)return null;for(const r of zM)if(r.match.test(e))return r.rates;return null}function An(e,r){const i=Rv(r);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=e.inputTokens*i.input/1e6,s=e.outputTokens*i.output/1e6,u=e.cacheReadTokens*i.cacheRead/1e6,l=e.cacheCreateTokens*i.cacheWrite/1e6;return{input:o,output:s,cacheRead:u,cacheWrite:l,total:o+s+u+l}}const Ew=2e5,BM=1e6,UM=[/\[1m\]/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i];function jb(e){if(!e)return Ew;for(const r of UM)if(r.test(e))return BM;return Ew}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 iv(e,r){if(e<=0||r<10)return null;const i=e/r,o=i*60;return o>=.01?`${We(o)}/min`:`${We(i*3600)}/hr`}function hn(e){return e.toLocaleString()}function HM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function VM({agent:e,onClose:r}){var p;const i=e.context,o=e.usage,s=(i==null?void 0:i.currentContextTokens)??0,u=jb(e.model),l=Math.min(100,s/u*100),c=An(o,e.model),d=o.inputTokens+o.cacheReadTokens+o.cacheCreateTokens;return S.jsx("div",{className:"ctx-modal-backdrop",onClick:r,role:"presentation",children:S.jsxs("div",{className:"ctx-modal",onClick:h=>h.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[S.jsxs("header",{className:"ctx-modal-head",children:[S.jsxs("div",{children:[S.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),S.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),S.jsx("button",{className:"ctx-modal-close",onClick:r,"aria-label":"Close",children:"×"})]}),S.jsxs("section",{className:"ctx-window-row",children:[S.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(l),children:S.jsx("div",{className:"ctx-window-fill",style:{width:`${l}%`}})}),S.jsxs("div",{className:"ctx-window-meta",children:[S.jsxs("span",{className:"ctx-window-pct",children:[l.toFixed(1),"%"]}),S.jsxs("span",{className:"ctx-window-num",children:[hn(s)," / ",hn(u)," tok (current turn)"]})]})]}),S.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),S.jsxs("div",{className:"ctx-grid",children:[S.jsx(Cn,{label:"input tokens",val:hn(o.inputTokens)}),S.jsx(Cn,{label:"output tokens",val:hn(o.outputTokens)}),S.jsx(Cn,{label:"cache reads",val:hn(o.cacheReadTokens)}),S.jsx(Cn,{label:"cache writes",val:hn(o.cacheCreateTokens)}),S.jsx(Cn,{label:"cumulative total",val:hn(d)}),S.jsx(Cn,{label:"estimated cost",val:We(c.total),accent:!0})]}),S.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),S.jsxs("div",{className:"ctx-grid",children:[S.jsx(Cn,{label:"user messages",val:hn((i==null?void 0:i.msgsUser)??0)}),S.jsx(Cn,{label:"assistant messages",val:hn((i==null?void 0:i.msgsAssistant)??0)}),S.jsx(Cn,{label:"tool uses",val:hn((i==null?void 0:i.toolUses)??0)}),S.jsx(Cn,{label:"tool results",val:hn((i==null?void 0:i.toolResults)??0)}),S.jsx(Cn,{label:"system-reminders",val:hn((i==null?void 0:i.systemReminders)??0)})]}),S.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((p=i==null?void 0:i.claudeMdFiles)==null?void 0:p.length)??0)===0?S.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):S.jsx("ul",{className:"ctx-md-list",children:i.claudeMdFiles.map(h=>S.jsxs("li",{children:[S.jsx("span",{className:"ctx-md-path",title:h.path,children:h.path}),S.jsx("span",{className:"ctx-md-size",children:HM(h.bytes)})]},h.path))})]})})}function Cn({label:e,val:r,accent:i}){return S.jsxs("div",{className:`ctx-row${i?" accent":""}`,children:[S.jsx("span",{className:"ctx-row-label",children:e}),S.jsx("span",{className:"ctx-row-val",children:r})]})}function WM({currentContextTokens:e,modelId:r,size:i=26,onClick:o,title:s}){const u=jb(r),l=Math.min(1,e/u),c=i/2-3,d=i/2,p=2*Math.PI*c,h=p*l,v=l>.9?"var(--err)":l>.7?"var(--inflight)":"var(--accent)";return S.jsx("button",{type:"button",className:"ctx-donut",onClick:o,title:s??`context: ${e.toLocaleString()} / ${u.toLocaleString()} (${(l*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:S.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[S.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),S.jsx("circle",{cx:d,cy:d,r:c,stroke:v,strokeWidth:"2.5",fill:"none",strokeDasharray:`${h} ${p-h}`,strokeDashoffset:p/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),S.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(l*100)})]})})}function GM(e,r){const i=Rv(r);if(!i)return"no rates for this model";const o=l=>l.toLocaleString(),s=l=>`$${l}/MTok`,u=An(e,r);return[`model: ${r}`,`input ${o(e.inputTokens).padStart(14)} × ${s(i.input).padEnd(11)} = ${We(u.input)}`,`output ${o(e.outputTokens).padStart(14)} × ${s(i.output).padEnd(11)} = ${We(u.output)}`,`cache r ${o(e.cacheReadTokens).padStart(14)} × ${s(i.cacheRead).padEnd(11)} = ${We(u.cacheRead)}`,`cache w ${o(e.cacheCreateTokens).padStart(14)} × ${s(i.cacheWrite).padEnd(11)} = ${We(u.cacheWrite)}`,"─────────────────────────────────────────",`total = ${We(u.total)}`].join(`
58
58
  `)}function KM(e,r,i){const o=(r??i)-e;if(o<1e3)return`${Math.max(0,o)}ms`;const s=Math.floor(o/1e3);if(s<60)return`${s}s`;const u=Math.floor(s/60),l=s%60;return`${u}m ${String(l).padStart(2,"0")}s`}function YM({data:e,selected:r}){var p;const i=e.now??Date.now(),o=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",r?"selected":""].filter(Boolean).join(" "),s=e.tools.filter(h=>!h.endedAt).length,l=`hsl(${Tv(e.sessionId)} 70% 60%)`,c=((p=e.context)==null?void 0:p.currentContextTokens)??0,d=e.kind==="root"&&c>0;return S.jsxs("div",{className:o,style:{"--accent":l},children:[S.jsx("span",{className:"accent-stripe"}),S.jsx(Fi,{type:"target",position:ke.Left,style:{background:"transparent",border:"none"}}),S.jsxs("div",{className:"head",children:[S.jsxs("div",{className:"title",children:[S.jsx(XM,{state:e.state}),S.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&S.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),S.jsxs("div",{className:"head-right",children:[d&&e.onOpenContext&&S.jsx(WM,{currentContextTokens:c,modelId:e.model,onClick:()=>e.onOpenContext(e.sessionId)}),S.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:KM(e.startedAt,e.endedAt,i)})]})]}),S.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&S.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&S.jsx("span",{className:"model-chip",title:e.model,children:tu(e.model)})]}),e.tools.length>0&&S.jsx(ZM,{tools:e.tools,now:i}),S.jsxs("div",{className:"meta",children:[S.jsxs("span",{children:[S.jsx("b",{children:e.toolCount})," tools"]}),s>0&&S.jsxs("span",{className:"inflight-meta",children:[S.jsx("b",{children:s})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&S.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}`,children:[S.jsx("b",{children:QM(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&Rv(e.model)&&(()=>{const h=An(e.usage,e.model);if(h.total<=0)return null;const v=Math.max(0,((e.endedAt??i)-e.startedAt)/1e3),g=e.state==="active"?iv(h.total,v):null,w=GM(e.usage,e.model)+(g?`
59
- burn: ${g}`:"");return S.jsxs("span",{className:"cost-meta",title:w,children:[S.jsx("b",{children:We(h.total)}),g&&S.jsx("span",{className:"cost-rate",children:g})]})})()]}),S.jsx(Fi,{type:"source",position:ke.Right,style:{background:"transparent",border:"none"}})]})}function XM({state:e}){const r=e==="active"?"live":e==="done"?"done":"err";return S.jsx("span",{className:`state-pill state-${e}`,children:r})}function QM(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function ZM({tools:e,now:r}){const u=new Array(24).fill(0);let l=0;for(const g of e){const w=r-g.startedAt;if(w<0||w>=6e4)continue;const N=23-Math.floor(w/2500);N>=0&&N<24&&(u[N]+=1,l+=1)}const c=Math.max(1,...u),d=132,p=14,h=d/24,v=c/(2500/1e3);return S.jsxs("div",{className:"tool-spark-row",title:`${l} tool calls in last 60s · peak ${v.toFixed(1)}/s`,children:[S.jsx("svg",{className:"tool-spark",width:d,height:p,viewBox:`0 0 ${d} ${p}`,"aria-hidden":!0,children:u.map((g,w)=>{const N=g===0?1.5:Math.max(1.5,g/c*p),_=w===23&&g>0,x=`tool-spark-bar${g>0?" active":""}${_?" latest":""}`;return S.jsx("rect",{x:w*h+.4,y:p-N,width:Math.max(.5,h-1),height:N,rx:.8,className:x},w)})}),S.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function tu(e){const r=e.match(/^claude[-_](opus|sonnet|haiku|fable)[-_](\d+(?:[-_.]\d+)*)/i);if(!r)return e;const i=r[1][0].toUpperCase()+r[1].slice(1).toLowerCase(),o=r[2].replace(/[-_]/g,".");return`${i} ${o}`}function kw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function JM(e){if(e.endedAt==null)return"in-flight…";const r=e.endedAt-e.startedAt;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`}function eP({tool:e,onClose:r}){D.useEffect(()=>{const o=s=>{s.key==="Escape"&&r()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[r]);const i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return S.jsx("div",{className:"modal-backdrop",onClick:r,role:"dialog","aria-modal":"true",children:S.jsxs("div",{className:"modal",onClick:o=>o.stopPropagation(),children:[S.jsxs("header",{className:"modal-head",children:[S.jsxs("div",{className:"modal-title",children:[S.jsx("span",{className:`status-dot ${i}`}),S.jsx("span",{className:"modal-tool-name",children:e.name}),S.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),S.jsxs("div",{className:"modal-actions",children:[S.jsx("span",{className:"modal-dur",children:JM(e)}),S.jsx("button",{className:"btn icon-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),S.jsxs("section",{className:"modal-body",children:[S.jsxs("div",{className:"modal-section",children:[S.jsx("h4",{children:"Input"}),S.jsx("pre",{children:kw(e.input??e.inputPreview)})]}),S.jsxs("div",{className:"modal-section",children:[S.jsxs("h4",{children:["Response ",i==="err"&&S.jsx("span",{className:"err-tag",children:"error"})]}),S.jsx("pre",{children:e.endedAt==null?"(waiting…)":kw(e.response??e.errorPreview)})]})]})]})})}const ja=18,bw=26,tP=12;function nP(e){const r=new Map;for(const s of e.nodeInternals.values()){const u=s.data;if(!(u!=null&&u.sessionId)||u.exitAt!=null||s.width==null||s.height==null)continue;const l=s.position.x,c=s.position.y,d=l+s.width,p=c+s.height,h=r.get(u.sessionId);h?(h.minX=Math.min(h.minX,l),h.minY=Math.min(h.minY,c),h.maxX=Math.max(h.maxX,d),h.maxY=Math.max(h.maxY,p),u.kind==="root"&&(h.label=Nw(u)??h.label)):r.set(u.sessionId,{minX:l,minY:c,maxX:d,maxY:p,label:Nw(u)??u.sessionId})}const i=new Map;for(const s of r.values())i.set(s.label,(i.get(s.label)??0)+1);const o=[];for(const[s,u]of r){const c=(i.get(u.label)??0)>1?`${u.label} · ${rP(s)}`:u.label;o.push({sessionId:s,label:c,x:u.minX-ja,y:u.minY-ja-bw,w:u.maxX-u.minX+ja*2,h:u.maxY-u.minY+ja*2+bw})}return o}function rP(e){const r=e.match(/[a-zA-Z0-9]{4}/);return r?r[0]:e.slice(0,4)}function Nw(e){if(e.kind==="root")return e.label}function iP(){const{x:e,y:r,zoom:i}=Eb(),o=ts(),s=Fe(nP,oP);if(s.length<=1)return null;const u=l=>{try{const c=o.getNodes().filter(d=>{const p=d.data;return(p==null?void 0:p.sessionId)===l});if(c.length===0)return;o.fitView({padding:.3,duration:500,nodes:c})}catch{}};return S.jsx("div",{className:"session-clusters",children:s.map(l=>{const c=Tv(l.sessionId),d={position:"absolute",left:l.x*i+e,top:l.y*i+r,width:l.w*i,height:l.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},p={position:"absolute",left:l.x*i+e+16*i,top:(l.y-tP)*i+r,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return S.jsxs(ie.Fragment,{children:[S.jsx("div",{className:"cluster-card",style:d,"aria-hidden":!0}),S.jsx("button",{type:"button",className:"cluster-label",style:p,title:`Fit view to ${l.label}`,onClick:()=>u(l.sessionId),children:l.label})]},l.sessionId)})})}function oP(e,r){if(e.length!==r.length)return!1;for(let i=0;i<e.length;i++){const o=e[i],s=r[i];if(o.sessionId!==s.sessionId||o.label!==s.label||o.x!==s.x||o.y!==s.y||o.w!==s.w||o.h!==s.h)return!1}return!0}const Mb=600,sP=36,ov=16,aP=60,uP=6,Cw=220,Tw=96,lP=28,cP={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",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 fP(e){return e.startsWith("mcp__")?"mcp":cP[e]??"other"}const dP={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",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 hP(e){return e.startsWith("mcp__")?"🔌":dP[e]??"✨"}const pP={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 Pb(e){if(!e)return null;let r=e.trim();if(!r)return null;const i=r.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(i)return Pb(i[1]);for(;;){const u=r.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!u)break;r=r.slice(u[0].length)}r=r.replace(/^sudo(?:\s+-\S+)*\s+/,""),r=r.replace(/^(?:time|nohup|xargs)\s+/,"");const o=r.match(/^([^\s|;&<>(]+)/);if(!o)return null;let s=o[1];return s=s.replace(/^.*[/\\]/,""),s=s.replace(/\.(exe|cmd|bat|ps1)$/i,""),s||null}function mP(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const r=e;return typeof r.command=="string"?r.command:typeof r.cmd=="string"?r.cmd:typeof r.script=="string"?r.script:null}function vP(e,r){if(e!=="Bash"&&e!=="PowerShell")return null;const i=mP(r);if(!i)return null;const o=Pb(i);return o?{emoji:pP[o]??"⚙️",label:o,category:"shell",detail:i}:null}const gP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob"]),Rw={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:"🗄️"},Aw={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 yP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),o=i.lastIndexOf("/");return o>=0?i.slice(o+1):i}function wP(e){const r=e.toLowerCase();if(Aw[r])return Aw[r];if(r.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(r))return"🧪";const i=r.lastIndexOf(".");if(i>0&&i<r.length-1){const o=r.slice(i+1);if(Rw[o])return Rw[o]}return"📄"}function _P(e,r){if(!r||typeof r!="object")return null;const i=r;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 xP(e,r){if(!gP.has(e))return null;const i=_P(e,r);if(!i)return null;const o=yP(i);return o?{emoji:e==="LS"?"📂":wP(o),label:o,category:"file",detail:i}:null}const qb={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 Ob(e){if(!e.startsWith("mcp__"))return null;const r=e.slice(5),i=r.indexOf("__");return i<=0?{server:r,method:""}:{server:r.slice(0,i),method:r.slice(i+2)}}function SP(e){let r=5381;for(let i=0;i<e.length;i++)r=(r<<5)+r^e.charCodeAt(i);return Math.abs(r)%360}function EP(e,r){const i=Ob(e);if(!i)return null;const{server:o,method:s}=i;if(!s)return null;const u=qb[o.toLowerCase()];return{emoji:(u==null?void 0:u.emoji)??"🔌",label:s,category:"mcp",detail:u?`${u.name} · ${s}`:`${o} · ${s}`}}function kP(e,r){return vP(e,r)??xP(e,r)??EP(e)}function bP(e){const r=Ob(e);if(r){const i=qb[r.server.toLowerCase()];return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:r.server,hue:SP(r.server)}}return{emoji:hP(e),label:e}}function NP(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function CP(e,r,i){if(i==null)return 1;const o=r-i;return o<0?1:Math.max(0,1-o/Mb)}function TP(e,r,i,o,s,u){const l=[];for(const c of e.values()){if(!r.has(c.id)||c.exitAt!=null&&u-c.exitAt>Mb)continue;const d=o.get(c.id)??i.get(c.id);if(!d)continue;const p=c.tools.slice(-4);if(p.length===0)continue;const h=c.exitAt??null,v=s.get(c.id),g=Math.max((v==null?void 0:v.width)??Cw,Cw),w=(v==null?void 0:v.height)??130,N=d.x,_=d.y,E=N+g,x=_+w/2;p.forEach((k,T)=>{const C=T*sP,A=N+g+aP,j=_+uP+C,M=CP(k,u,h),z=k.inputPreview??"",O=NP(k),B=M<.999,U=bP(k.name);l.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:U.label,emoji:U.emoji,status:O,category:fP(k.name),mcpHue:U.hue,inputPreview:z,fade:M,fading:B,worldX:A,worldY:j,anchorX:E,anchorY:x,spawnDx:E-A,spawnDy:x-(j+ov)});const ee=kP(k.name,k.input);if(ee){const X=A+Tw+lP,R=j,G=A+Tw,H=j+ov;l.push({id:`sub:${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:ee.label,emoji:ee.emoji,isSub:!0,status:O,category:ee.category,inputPreview:ee.detail??z,fade:M,fading:B,worldX:X,worldY:R,anchorX:G,anchorY:H,spawnDx:G-X,spawnDy:0})}})}return l}function RP({agents:e,visibleAgentIds:r,positions:i,pinned:o,measured:s,dimUnmatched:u,spotlight:l,hiddenCategories:c,now:d,onOpenTool:p}){const{x:h,y:v,zoom:g}=Eb(),w=TP(e,r,i,o,s,d),N=c&&c.size>0?w.filter(_=>!c.has(_.category)):w;return S.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[S.jsx("svg",{className:"tool-bursts-svg",children:N.map(_=>{const E=_.anchorX*g+h,x=_.anchorY*g+v,k=(_.worldX+6)*g+h,T=(_.worldY+ov)*g+v,C=E+(k-E)*.55,A=u!=null&&!u.has(_.agentId),j=l!=null&&!l.has(_.agentId),M=_.fade*(A||j?.14:1);return S.jsx("path",{d:`M ${E} ${x} Q ${C} ${x}, ${k} ${T}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:M},`l:${_.id}`)})}),N.map(_=>{const E=_.worldX*g+h,x=_.worldY*g+v,k={left:`${E}px`,top:`${x}px`,transform:`scale(${g})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},T=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${T} · ${_.inputPreview}`:T,A=p!=null,j=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},M=u!=null&&!u.has(_.agentId),z=l!=null&&!l.has(_.agentId),O=M||z?" dim":"";return S.jsx("div",{className:"tool-burst-wrap",style:k,children:S.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${A?" clickable":""}${_.isSub?" sub":""}${O}`,style:j,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?()=>p(_.toolId):void 0,onKeyDown:A?B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),p(_.toolId))}:void 0,children:[S.jsx("span",{className:"tb-emoji",children:_.emoji}),S.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&S.jsx("span",{className:"tb-spin"}),_.status==="done"&&S.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&S.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function AP({state:e,sessionId:r,onClose:i}){const o=D.useMemo(()=>jP(e,r),[e,r]);return o?S.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:S.jsxs("div",{className:"modal session-summary",onClick:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[S.jsxs("div",{className:"modal-head",children:[S.jsxs("div",{className:"modal-title",children:[S.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),S.jsx("span",{id:"ss-title",className:"modal-tool-name",title:o.cwd??o.sessionId,children:o.label}),S.jsxs("span",{className:"modal-tool-id",children:["· ",o.sessionId.slice(0,8)]})]}),S.jsxs("div",{className:"modal-actions",children:[S.jsx("span",{className:"modal-dur",title:"Total wall time",children:o.durationLabel}),S.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),S.jsxs("div",{className:"modal-body",children:[S.jsxs("section",{className:"ss-hero",children:[S.jsxs("div",{className:"ss-hero-left",children:[S.jsx("div",{className:"ss-cost-label",children:"total spend"}),S.jsx("div",{className:"ss-cost",children:We(o.cost.total)}),o.modelChips.length>0&&S.jsx("div",{className:"ss-models",children:o.modelChips.map(s=>S.jsx("span",{className:"model-chip",title:s,children:tu(s)},s))})]}),S.jsx("div",{className:"ss-hero-right",children:o.cost.total>0&&S.jsxs(S.Fragment,{children:[S.jsx(IP,{cost:o.cost}),S.jsxs("div",{className:"ss-cost-legend",children:[S.jsxs("span",{className:"ssl ssl-in",children:["input ",S.jsx("b",{children:We(o.cost.input)})]}),S.jsxs("span",{className:"ssl ssl-out",children:["output ",S.jsx("b",{children:We(o.cost.output)})]}),S.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",S.jsx("b",{children:We(o.cost.cacheRead)})]}),S.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",S.jsx("b",{children:We(o.cost.cacheWrite)})]})]})]})})]}),S.jsxs("section",{className:"ss-stats",children:[S.jsx(Ii,{label:"agents",value:o.agentCount}),S.jsx(Ii,{label:"subagents",value:o.subagentCount}),S.jsx(Ii,{label:"tool calls",value:o.toolCount}),S.jsx(Ii,{label:"prompts",value:o.promptCount}),S.jsx(Ii,{label:"tokens",value:o.tokensSum.toLocaleString()}),o.errCount>0&&S.jsx(Ii,{label:"errors",value:o.errCount,tone:"err"})]}),o.topTools.length>0&&S.jsxs("section",{className:"modal-section",children:[S.jsx("h4",{children:"Most-used tools"}),S.jsx("div",{className:"ss-top-tools",children:o.topTools.map(([s,u])=>S.jsxs("div",{className:"ss-tt",children:[S.jsx("span",{className:"ss-tt-name",children:s}),S.jsx("span",{className:"ss-tt-bar",children:S.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/o.topTools[0][1]*100}%`}})}),S.jsx("span",{className:"ss-tt-count",children:u})]},s))})]}),o.firstPrompt&&S.jsxs("section",{className:"modal-section",children:[S.jsx("h4",{children:"Opening prompt"}),S.jsx("div",{className:"ss-prompt",children:o.firstPrompt})]})]})]})}):null}function Ii({label:e,value:r,tone:i}){return S.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[S.jsx("div",{className:"ss-stat-value",children:r}),S.jsx("div",{className:"ss-stat-label",children:e})]})}function IP({cost:e}){const r=e.total;if(r<=0)return null;const i=(o,s,u)=>{if(o<=0)return null;const l=o/r*100;return S.jsx("span",{className:`cb-seg ${s}`,style:{width:`${l}%`},title:`${u}: ${We(o)} (${l.toFixed(0)}%)`},s)};return S.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 jP(e,r){const i=e.agents.get(r);if(!i)return null;const o=[];for(const T of e.agents.values())T.sessionId===r&&o.push(T);if(o.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},u=new Set,l=new Map;let c=0,d=0,p=0,h=0,v=0,g,w=1/0,N=0;for(const T of o){const C=An(T.usage,T.model);s.input+=C.input,s.output+=C.output,s.cacheRead+=C.cacheRead,s.cacheWrite+=C.cacheWrite,s.total+=C.total,T.model&&u.add(T.model),T.kind==="subagent"&&v++,d+=T.prompts.length,!g&&T.prompts.length>0&&(g=T.prompts[0].text),p+=T.usage.inputTokens+T.usage.outputTokens,c+=T.tools.length,w=Math.min(w,T.startedAt),N=Math.max(N,T.endedAt??Date.now());for(const A of T.tools)l.set(A.name,(l.get(A.name)??0)+1),A.ok===!1&&h++}const _=Math.max(0,N-w),E=Math.floor(_/1e3),x=E<60?`${E}s`:E<3600?`${Math.floor(E/60)}m ${String(E%60).padStart(2,"0")}s`:`${Math.floor(E/3600)}h ${Math.floor(E%3600/60)}m`,k=Array.from(l.entries()).sort((T,C)=>C[1]-T[1]).slice(0,5);return{sessionId:r,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:x,cost:s,modelChips:Array.from(u),agentCount:o.length,subagentCount:v,toolCount:c,promptCount:d,tokensSum:p,errCount:h,topTools:k,firstPrompt:g}}function MP(e,r){const i=[];for(const o of e.agents.values()){if(o.kind!=="root")continue;let s=o.tools.length,u=An(o.usage,o.model).total,l=o.endedAt??o.startedAt;for(const c of e.agents.values()){if(c.sessionId!==o.sessionId||c.kind==="root")continue;s+=c.tools.length,u+=An(c.usage,c.model).total;const d=c.endedAt??c.startedAt;d>l&&(l=d)}i.push({sessionId:o.sessionId,label:o.label||o.cwdBasename||"session",cwdBasename:o.cwdBasename,state:o.state,modelId:o.model,toolCount:s,cost:u,startedAt:o.startedAt,lastActivity:l})}return i.sort((o,s)=>{if(o.state!==s.state){if(o.state==="active")return-1;if(s.state==="active")return 1}return s.lastActivity-o.lastActivity}),i}function PP(e,r,i){const o=(r??i)-e;if(o<1e3)return"<1s";const s=Math.floor(o/1e3);if(s<60)return`${s}s`;const u=Math.floor(s/60);return u<60?`${u}m`:`${Math.floor(u/60)}h ${u%60}m`}function qP({state:e,now:r,selectedIds:i,onSelect:o,onClose:s}){const u=D.useMemo(()=>MP(e),[e,e.lastSeq,r]),l=u.filter(c=>c.state==="active").length;return S.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[S.jsxs("div",{className:"sl-header",children:[S.jsxs("h3",{children:["Sessions ",S.jsx("span",{className:"sl-count",children:u.length})]}),l>0&&S.jsxs("span",{className:"sl-live-count",children:[l," live"]}),S.jsx("button",{className:"btn icon-btn sl-close",onClick:s,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),S.jsxs("div",{className:"sl-rows",children:[u.length===0&&S.jsx("div",{className:"sl-empty",children:"No sessions yet."}),u.map(c=>{const d=i.has(c.sessionId);return S.jsxs("button",{type:"button",className:`sl-row state-${c.state}${d?" selected":""}`,onClick:()=>o(c.sessionId),title:`Focus ${c.label}`,children:[S.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),S.jsxs("div",{className:"sl-row-body",children:[S.jsxs("div",{className:"sl-row-head",children:[S.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&S.jsx("span",{className:"model-chip",title:c.modelId,children:tu(c.modelId)})]}),S.jsxs("div",{className:"sl-row-meta",children:[S.jsxs("span",{title:"tool calls",children:[S.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&S.jsx("span",{className:"sl-cost",title:"total spend",children:S.jsx("b",{children:We(c.cost)})}),S.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:PP(c.startedAt,c.state==="active"?void 0:c.lastActivity,r)})]})]})]},c.sessionId)})]})]})}const xc=12e4,Iw=400,Lb="agent-dag.timelineMode";function OP(){if(typeof window>"u")return"tools";try{return window.localStorage.getItem(Lb)==="cost"?"cost":"tools"}catch{return"tools"}}function LP(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Lb,e)}catch{}}const $P={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",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 DP(e){return e.startsWith("mcp__")?"mcp":$P[e]??"other"}function FP(e,r,i){const o=[];for(const s of e.values())if(r.has(s.id))for(const u of s.tools)u.startedAt<i||o.push({agentId:s.id,toolId:u.id,name:u.name,category:DP(u.name),startedAt:u.startedAt,endedAt:u.endedAt,inflight:u.endedAt==null,errored:u.ok===!1});return o.sort((s,u)=>s.startedAt-u.startedAt),o.length>Iw?o.slice(o.length-Iw):o}function zP({agents:e,visibleAgentIds:r,now:i,costSamples:o,onSelect:s,onOpenTool:u,onClose:l}){const[c,d]=D.useState(OP);D.useEffect(()=>{LP(c)},[c]);const p=i-xc,h=D.useMemo(()=>FP(e,r,p),[e,r,p]),v=D.useMemo(()=>{const x=new Map;for(const k of h)x.set(k.category,(x.get(k.category)??0)+1);return x},[h]),g=D.useMemo(()=>o.filter(x=>x.t>=p),[o,p]),w=D.useMemo(()=>g.reduce((x,k)=>Math.max(x,k.cost),0),[g]),N=g.length>0?g[g.length-1].cost:0,_=g.length>0?g[0].cost:0,E=N-_;return S.jsxs("div",{className:"timeline-strip",role:"region","aria-label":c==="cost"?"Spend over time":"Recent tool activity",children:[S.jsxs("div",{className:"ts-header",children:[S.jsxs("div",{className:"ts-mode-toggle",role:"tablist","aria-label":"Timeline mode",children:[S.jsx("button",{role:"tab",className:`ts-mode${c==="tools"?" on":""}`,onClick:()=>d("tools"),"aria-selected":c==="tools",title:"Show recent tool calls",children:"tools"}),S.jsx("button",{role:"tab",className:`ts-mode${c==="cost"?" on":""}`,onClick:()=>d("cost"),"aria-selected":c==="cost",title:"Show cumulative spend",children:"$"})]}),S.jsx("span",{className:"ts-title",children:"Last 2 min"}),c==="tools"?S.jsxs(S.Fragment,{children:[S.jsxs("span",{className:"ts-total",children:[h.length," tool call",h.length===1?"":"s"]}),S.jsx("div",{className:"ts-legend",children:Array.from(v.entries()).sort((x,k)=>k[1]-x[1]).map(([x,k])=>S.jsxs("span",{className:`ts-legend-item cat-${x}`,title:`${k} ${x}`,children:[S.jsx("span",{className:"ts-legend-dot"}),k]},x))})]}):S.jsxs(S.Fragment,{children:[S.jsxs("span",{className:"ts-total",children:[We(N),E>0&&S.jsxs("span",{className:"ts-delta",children:[" · +",We(E)]})]}),S.jsx("div",{className:"ts-legend"})]}),S.jsx("button",{className:"btn icon-btn ts-close",onClick:l,title:"Hide timeline","aria-label":"Hide timeline",children:"×"})]}),S.jsxs("div",{className:"ts-track","aria-hidden":!0,children:[[2,1.5,1,.5,0].map(x=>S.jsx("span",{className:"ts-tick",style:{left:`${(2-x)/2*100}%`},children:x===0?"now":`${x}m`},x)),S.jsx("span",{className:"ts-now-line"}),c==="tools"?h.map(x=>{const k=(x.startedAt-p)/xc*100,T=x.inflight?"inflight":x.errored?"err":"done";return S.jsx("button",{className:`ts-dot cat-${x.category} status-${T}`,style:{left:`${k}%`},onClick:()=>{s(x.agentId),u(x.toolId)},title:`${x.name} · ${new Date(x.startedAt).toLocaleTimeString()}${x.endedAt?` (${Math.max(0,x.endedAt-x.startedAt)}ms)`:" — running"}`,"aria-label":`${x.name} ${T}`},x.toolId)}):S.jsx(BP,{series:g,earliest:p,windowMs:xc,costMax:w})]})]})}function BP({series:e,earliest:r,windowMs:i,costMax:o}){if(e.length<2||o<=0)return S.jsx("div",{className:"ts-chart-empty",children:"collecting samples…"});const s=h=>Math.max(0,Math.min(100,(h-r)/i*100)),u=h=>100-h/o*92-4,l=e.map(h=>({x:s(h.t),y:u(h.cost)}));let c=`M ${l[0].x.toFixed(2)} ${l[0].y.toFixed(2)}`;for(let h=1;h<l.length;h++){const v=l[h-1],g=l[h],w=(v.x+g.x)/2;c+=` C ${w.toFixed(2)} ${v.y.toFixed(2)}, ${w.toFixed(2)} ${g.y.toFixed(2)}, ${g.x.toFixed(2)} ${g.y.toFixed(2)}`}const d=l[l.length-1],p=`${c} L ${d.x.toFixed(2)} 100 L ${l[0].x.toFixed(2)} 100 Z`;return S.jsxs("svg",{className:"ts-chart",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":!0,children:[S.jsx("defs",{children:S.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[S.jsx("stop",{offset:"0%",stopColor:"hsl(150 60% 60%)",stopOpacity:"0.55"}),S.jsx("stop",{offset:"100%",stopColor:"hsl(150 60% 60%)",stopOpacity:"0.02"})]})}),S.jsx("path",{d:p,fill:"url(#ts-fill)"}),S.jsx("path",{d:c,fill:"none",stroke:"hsl(150 70% 65%)",strokeWidth:"0.6",vectorEffect:"non-scaling-stroke"}),S.jsx("circle",{cx:d.x,cy:d.y,r:"1.4",fill:"hsl(150 80% 70%)",vectorEffect:"non-scaling-stroke"})]})}function Av(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 Sc,jw;function UP(){if(jw)return Sc;jw=1;function e(){this.__data__=[],this.size=0}return Sc=e,Sc}var Ec,Mw;function zi(){if(Mw)return Ec;Mw=1;function e(r,i){return r===i||r!==r&&i!==i}return Ec=e,Ec}var kc,Pw;function nu(){if(Pw)return kc;Pw=1;var e=zi();function r(i,o){for(var s=i.length;s--;)if(e(i[s][0],o))return s;return-1}return kc=r,kc}var bc,qw;function HP(){if(qw)return bc;qw=1;var e=nu(),r=Array.prototype,i=r.splice;function o(s){var u=this.__data__,l=e(u,s);if(l<0)return!1;var c=u.length-1;return l==c?u.pop():i.call(u,l,1),--this.size,!0}return bc=o,bc}var Nc,Ow;function VP(){if(Ow)return Nc;Ow=1;var e=nu();function r(i){var o=this.__data__,s=e(o,i);return s<0?void 0:o[s][1]}return Nc=r,Nc}var Cc,Lw;function WP(){if(Lw)return Cc;Lw=1;var e=nu();function r(i){return e(this.__data__,i)>-1}return Cc=r,Cc}var Tc,$w;function GP(){if($w)return Tc;$w=1;var e=nu();function r(i,o){var s=this.__data__,u=e(s,i);return u<0?(++this.size,s.push([i,o])):s[u][1]=o,this}return Tc=r,Tc}var Rc,Dw;function ru(){if(Dw)return Rc;Dw=1;var e=UP(),r=HP(),i=VP(),o=WP(),s=GP();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var p=l[c];this.set(p[0],p[1])}}return u.prototype.clear=e,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=s,Rc=u,Rc}var Ac,Fw;function KP(){if(Fw)return Ac;Fw=1;var e=ru();function r(){this.__data__=new e,this.size=0}return Ac=r,Ac}var Ic,zw;function YP(){if(zw)return Ic;zw=1;function e(r){var i=this.__data__,o=i.delete(r);return this.size=i.size,o}return Ic=e,Ic}var jc,Bw;function XP(){if(Bw)return jc;Bw=1;function e(r){return this.__data__.get(r)}return jc=e,jc}var Mc,Uw;function QP(){if(Uw)return Mc;Uw=1;function e(r){return this.__data__.has(r)}return Mc=e,Mc}var Pc,Hw;function $b(){if(Hw)return Pc;Hw=1;var e=typeof xa=="object"&&xa&&xa.Object===Object&&xa;return Pc=e,Pc}var qc,Vw;function Pn(){if(Vw)return qc;Vw=1;var e=$b(),r=typeof self=="object"&&self&&self.Object===Object&&self,i=e||r||Function("return this")();return qc=i,qc}var Oc,Ww;function Bi(){if(Ww)return Oc;Ww=1;var e=Pn(),r=e.Symbol;return Oc=r,Oc}var Lc,Gw;function ZP(){if(Gw)return Lc;Gw=1;var e=Bi(),r=Object.prototype,i=r.hasOwnProperty,o=r.toString,s=e?e.toStringTag:void 0;function u(l){var c=i.call(l,s),d=l[s];try{l[s]=void 0;var p=!0}catch{}var h=o.call(l);return p&&(c?l[s]=d:delete l[s]),h}return Lc=u,Lc}var $c,Kw;function JP(){if(Kw)return $c;Kw=1;var e=Object.prototype,r=e.toString;function i(o){return r.call(o)}return $c=i,$c}var Dc,Yw;function Jr(){if(Yw)return Dc;Yw=1;var e=Bi(),r=ZP(),i=JP(),o="[object Null]",s="[object Undefined]",u=e?e.toStringTag:void 0;function l(c){return c==null?c===void 0?s:o:u&&u in Object(c)?r(c):i(c)}return Dc=l,Dc}var Fc,Xw;function vn(){if(Xw)return Fc;Xw=1;function e(r){var i=typeof r;return r!=null&&(i=="object"||i=="function")}return Fc=e,Fc}var zc,Qw;function ns(){if(Qw)return zc;Qw=1;var e=Jr(),r=vn(),i="[object AsyncFunction]",o="[object Function]",s="[object GeneratorFunction]",u="[object Proxy]";function l(c){if(!r(c))return!1;var d=e(c);return d==o||d==s||d==i||d==u}return zc=l,zc}var Bc,Zw;function e3(){if(Zw)return Bc;Zw=1;var e=Pn(),r=e["__core-js_shared__"];return Bc=r,Bc}var Uc,Jw;function t3(){if(Jw)return Uc;Jw=1;var e=e3(),r=(function(){var o=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""})();function i(o){return!!r&&r in o}return Uc=i,Uc}var Hc,e1;function Db(){if(e1)return Hc;e1=1;var e=Function.prototype,r=e.toString;function i(o){if(o!=null){try{return r.call(o)}catch{}try{return o+""}catch{}}return""}return Hc=i,Hc}var Vc,t1;function n3(){if(t1)return Vc;t1=1;var e=ns(),r=t3(),i=vn(),o=Db(),s=/[\\^$.*+?()[\]{}|]/g,u=/^\[object .+?Constructor\]$/,l=Function.prototype,c=Object.prototype,d=l.toString,p=c.hasOwnProperty,h=RegExp("^"+d.call(p).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function v(g){if(!i(g)||r(g))return!1;var w=e(g)?h:u;return w.test(o(g))}return Vc=v,Vc}var Wc,n1;function r3(){if(n1)return Wc;n1=1;function e(r,i){return r==null?void 0:r[i]}return Wc=e,Wc}var Gc,r1;function ei(){if(r1)return Gc;r1=1;var e=n3(),r=r3();function i(o,s){var u=r(o,s);return e(u)?u:void 0}return Gc=i,Gc}var Kc,i1;function Iv(){if(i1)return Kc;i1=1;var e=ei(),r=Pn(),i=e(r,"Map");return Kc=i,Kc}var Yc,o1;function iu(){if(o1)return Yc;o1=1;var e=ei(),r=e(Object,"create");return Yc=r,Yc}var Xc,s1;function i3(){if(s1)return Xc;s1=1;var e=iu();function r(){this.__data__=e?e(null):{},this.size=0}return Xc=r,Xc}var Qc,a1;function o3(){if(a1)return Qc;a1=1;function e(r){var i=this.has(r)&&delete this.__data__[r];return this.size-=i?1:0,i}return Qc=e,Qc}var Zc,u1;function s3(){if(u1)return Zc;u1=1;var e=iu(),r="__lodash_hash_undefined__",i=Object.prototype,o=i.hasOwnProperty;function s(u){var l=this.__data__;if(e){var c=l[u];return c===r?void 0:c}return o.call(l,u)?l[u]:void 0}return Zc=s,Zc}var Jc,l1;function a3(){if(l1)return Jc;l1=1;var e=iu(),r=Object.prototype,i=r.hasOwnProperty;function o(s){var u=this.__data__;return e?u[s]!==void 0:i.call(u,s)}return Jc=o,Jc}var ef,c1;function u3(){if(c1)return ef;c1=1;var e=iu(),r="__lodash_hash_undefined__";function i(o,s){var u=this.__data__;return this.size+=this.has(o)?0:1,u[o]=e&&s===void 0?r:s,this}return ef=i,ef}var tf,f1;function l3(){if(f1)return tf;f1=1;var e=i3(),r=o3(),i=s3(),o=a3(),s=u3();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var p=l[c];this.set(p[0],p[1])}}return u.prototype.clear=e,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=s,tf=u,tf}var nf,d1;function c3(){if(d1)return nf;d1=1;var e=l3(),r=ru(),i=Iv();function o(){this.size=0,this.__data__={hash:new e,map:new(i||r),string:new e}}return nf=o,nf}var rf,h1;function f3(){if(h1)return rf;h1=1;function e(r){var i=typeof r;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?r!=="__proto__":r===null}return rf=e,rf}var of,p1;function ou(){if(p1)return of;p1=1;var e=f3();function r(i,o){var s=i.__data__;return e(o)?s[typeof o=="string"?"string":"hash"]:s.map}return of=r,of}var sf,m1;function d3(){if(m1)return sf;m1=1;var e=ou();function r(i){var o=e(this,i).delete(i);return this.size-=o?1:0,o}return sf=r,sf}var af,v1;function h3(){if(v1)return af;v1=1;var e=ou();function r(i){return e(this,i).get(i)}return af=r,af}var uf,g1;function p3(){if(g1)return uf;g1=1;var e=ou();function r(i){return e(this,i).has(i)}return uf=r,uf}var lf,y1;function m3(){if(y1)return lf;y1=1;var e=ou();function r(i,o){var s=e(this,i),u=s.size;return s.set(i,o),this.size+=s.size==u?0:1,this}return lf=r,lf}var cf,w1;function jv(){if(w1)return cf;w1=1;var e=c3(),r=d3(),i=h3(),o=p3(),s=m3();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var p=l[c];this.set(p[0],p[1])}}return u.prototype.clear=e,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=s,cf=u,cf}var ff,_1;function v3(){if(_1)return ff;_1=1;var e=ru(),r=Iv(),i=jv(),o=200;function s(u,l){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!r||d.length<o-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 ff=s,ff}var df,x1;function su(){if(x1)return df;x1=1;var e=ru(),r=KP(),i=YP(),o=XP(),s=QP(),u=v3();function l(c){var d=this.__data__=new e(c);this.size=d.size}return l.prototype.clear=r,l.prototype.delete=i,l.prototype.get=o,l.prototype.has=s,l.prototype.set=u,df=l,df}var hf,S1;function Mv(){if(S1)return hf;S1=1;function e(r,i){for(var o=-1,s=r==null?0:r.length;++o<s&&i(r[o],o,r)!==!1;);return r}return hf=e,hf}var pf,E1;function Fb(){if(E1)return pf;E1=1;var e=ei(),r=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return pf=r,pf}var mf,k1;function au(){if(k1)return mf;k1=1;var e=Fb();function r(i,o,s){o=="__proto__"&&e?e(i,o,{configurable:!0,enumerable:!0,value:s,writable:!0}):i[o]=s}return mf=r,mf}var vf,b1;function uu(){if(b1)return vf;b1=1;var e=au(),r=zi(),i=Object.prototype,o=i.hasOwnProperty;function s(u,l,c){var d=u[l];(!(o.call(u,l)&&r(d,c))||c===void 0&&!(l in u))&&e(u,l,c)}return vf=s,vf}var gf,N1;function rs(){if(N1)return gf;N1=1;var e=uu(),r=au();function i(o,s,u,l){var c=!u;u||(u={});for(var d=-1,p=s.length;++d<p;){var h=s[d],v=l?l(u[h],o[h],h,u,o):void 0;v===void 0&&(v=o[h]),c?r(u,h,v):e(u,h,v)}return u}return gf=i,gf}var yf,C1;function g3(){if(C1)return yf;C1=1;function e(r,i){for(var o=-1,s=Array(r);++o<r;)s[o]=i(o);return s}return yf=e,yf}var wf,T1;function Bn(){if(T1)return wf;T1=1;function e(r){return r!=null&&typeof r=="object"}return wf=e,wf}var _f,R1;function y3(){if(R1)return _f;R1=1;var e=Jr(),r=Bn(),i="[object Arguments]";function o(s){return r(s)&&e(s)==i}return _f=o,_f}var xf,A1;function is(){if(A1)return xf;A1=1;var e=y3(),r=Bn(),i=Object.prototype,o=i.hasOwnProperty,s=i.propertyIsEnumerable,u=e((function(){return arguments})())?e:function(l){return r(l)&&o.call(l,"callee")&&!s.call(l,"callee")};return xf=u,xf}var Sf,I1;function pt(){if(I1)return Sf;I1=1;var e=Array.isArray;return Sf=e,Sf}var Do={exports:{}},Ef,j1;function w3(){if(j1)return Ef;j1=1;function e(){return!1}return Ef=e,Ef}Do.exports;var M1;function Ui(){return M1||(M1=1,(function(e,r){var i=Pn(),o=w3(),s=r&&!r.nodeType&&r,u=s&&!0&&e&&!e.nodeType&&e,l=u&&u.exports===s,c=l?i.Buffer:void 0,d=c?c.isBuffer:void 0,p=d||o;e.exports=p})(Do,Do.exports)),Do.exports}var kf,P1;function lu(){if(P1)return kf;P1=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function i(o,s){var u=typeof o;return s=s??e,!!s&&(u=="number"||u!="symbol"&&r.test(o))&&o>-1&&o%1==0&&o<s}return kf=i,kf}var bf,q1;function Pv(){if(q1)return bf;q1=1;var e=9007199254740991;function r(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return bf=r,bf}var Nf,O1;function _3(){if(O1)return Nf;O1=1;var e=Jr(),r=Pv(),i=Bn(),o="[object Arguments]",s="[object Array]",u="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",p="[object Map]",h="[object Number]",v="[object Object]",g="[object RegExp]",w="[object Set]",N="[object String]",_="[object WeakMap]",E="[object ArrayBuffer]",x="[object DataView]",k="[object Float32Array]",T="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",j="[object Int32Array]",M="[object Uint8Array]",z="[object Uint8ClampedArray]",O="[object Uint16Array]",B="[object Uint32Array]",U={};U[k]=U[T]=U[C]=U[A]=U[j]=U[M]=U[z]=U[O]=U[B]=!0,U[o]=U[s]=U[E]=U[u]=U[x]=U[l]=U[c]=U[d]=U[p]=U[h]=U[v]=U[g]=U[w]=U[N]=U[_]=!1;function ee(X){return i(X)&&r(X.length)&&!!U[e(X)]}return Nf=ee,Nf}var Cf,L1;function cu(){if(L1)return Cf;L1=1;function e(r){return function(i){return r(i)}}return Cf=e,Cf}var Fo={exports:{}};Fo.exports;var $1;function qv(){return $1||($1=1,(function(e,r){var i=$b(),o=r&&!r.nodeType&&r,s=o&&!0&&e&&!e.nodeType&&e,u=s&&s.exports===o,l=u&&i.process,c=(function(){try{var d=s&&s.require&&s.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}})();e.exports=c})(Fo,Fo.exports)),Fo.exports}var Tf,D1;function os(){if(D1)return Tf;D1=1;var e=_3(),r=cu(),i=qv(),o=i&&i.isTypedArray,s=o?r(o):e;return Tf=s,Tf}var Rf,F1;function zb(){if(F1)return Rf;F1=1;var e=g3(),r=is(),i=pt(),o=Ui(),s=lu(),u=os(),l=Object.prototype,c=l.hasOwnProperty;function d(p,h){var v=i(p),g=!v&&r(p),w=!v&&!g&&o(p),N=!v&&!g&&!w&&u(p),_=v||g||w||N,E=_?e(p.length,String):[],x=E.length;for(var k in p)(h||c.call(p,k))&&!(_&&(k=="length"||w&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||s(k,x)))&&E.push(k);return E}return Rf=d,Rf}var Af,z1;function fu(){if(z1)return Af;z1=1;var e=Object.prototype;function r(i){var o=i&&i.constructor,s=typeof o=="function"&&o.prototype||e;return i===s}return Af=r,Af}var If,B1;function Bb(){if(B1)return If;B1=1;function e(r,i){return function(o){return r(i(o))}}return If=e,If}var jf,U1;function x3(){if(U1)return jf;U1=1;var e=Bb(),r=e(Object.keys,Object);return jf=r,jf}var Mf,H1;function Ov(){if(H1)return Mf;H1=1;var e=fu(),r=x3(),i=Object.prototype,o=i.hasOwnProperty;function s(u){if(!e(u))return r(u);var l=[];for(var c in Object(u))o.call(u,c)&&c!="constructor"&&l.push(c);return l}return Mf=s,Mf}var Pf,V1;function rr(){if(V1)return Pf;V1=1;var e=ns(),r=Pv();function i(o){return o!=null&&r(o.length)&&!e(o)}return Pf=i,Pf}var qf,W1;function Ir(){if(W1)return qf;W1=1;var e=zb(),r=Ov(),i=rr();function o(s){return i(s)?e(s):r(s)}return qf=o,qf}var Of,G1;function S3(){if(G1)return Of;G1=1;var e=rs(),r=Ir();function i(o,s){return o&&e(s,r(s),o)}return Of=i,Of}var Lf,K1;function E3(){if(K1)return Lf;K1=1;function e(r){var i=[];if(r!=null)for(var o in Object(r))i.push(o);return i}return Lf=e,Lf}var $f,Y1;function k3(){if(Y1)return $f;Y1=1;var e=vn(),r=fu(),i=E3(),o=Object.prototype,s=o.hasOwnProperty;function u(l){if(!e(l))return i(l);var c=r(l),d=[];for(var p in l)p=="constructor"&&(c||!s.call(l,p))||d.push(p);return d}return $f=u,$f}var Df,X1;function ti(){if(X1)return Df;X1=1;var e=zb(),r=k3(),i=rr();function o(s){return i(s)?e(s,!0):r(s)}return Df=o,Df}var Ff,Q1;function b3(){if(Q1)return Ff;Q1=1;var e=rs(),r=ti();function i(o,s){return o&&e(s,r(s),o)}return Ff=i,Ff}var zo={exports:{}};zo.exports;var Z1;function Ub(){return Z1||(Z1=1,(function(e,r){var i=Pn(),o=r&&!r.nodeType&&r,s=o&&!0&&e&&!e.nodeType&&e,u=s&&s.exports===o,l=u?i.Buffer:void 0,c=l?l.allocUnsafe:void 0;function d(p,h){if(h)return p.slice();var v=p.length,g=c?c(v):new p.constructor(v);return p.copy(g),g}e.exports=d})(zo,zo.exports)),zo.exports}var zf,J1;function Hb(){if(J1)return zf;J1=1;function e(r,i){var o=-1,s=r.length;for(i||(i=Array(s));++o<s;)i[o]=r[o];return i}return zf=e,zf}var Bf,e_;function Vb(){if(e_)return Bf;e_=1;function e(r,i){for(var o=-1,s=r==null?0:r.length,u=0,l=[];++o<s;){var c=r[o];i(c,o,r)&&(l[u++]=c)}return l}return Bf=e,Bf}var Uf,t_;function Wb(){if(t_)return Uf;t_=1;function e(){return[]}return Uf=e,Uf}var Hf,n_;function Lv(){if(n_)return Hf;n_=1;var e=Vb(),r=Wb(),i=Object.prototype,o=i.propertyIsEnumerable,s=Object.getOwnPropertySymbols,u=s?function(l){return l==null?[]:(l=Object(l),e(s(l),function(c){return o.call(l,c)}))}:r;return Hf=u,Hf}var Vf,r_;function N3(){if(r_)return Vf;r_=1;var e=rs(),r=Lv();function i(o,s){return e(o,r(o),s)}return Vf=i,Vf}var Wf,i_;function $v(){if(i_)return Wf;i_=1;function e(r,i){for(var o=-1,s=i.length,u=r.length;++o<s;)r[u+o]=i[o];return r}return Wf=e,Wf}var Gf,o_;function du(){if(o_)return Gf;o_=1;var e=Bb(),r=e(Object.getPrototypeOf,Object);return Gf=r,Gf}var Kf,s_;function Gb(){if(s_)return Kf;s_=1;var e=$v(),r=du(),i=Lv(),o=Wb(),s=Object.getOwnPropertySymbols,u=s?function(l){for(var c=[];l;)e(c,i(l)),l=r(l);return c}:o;return Kf=u,Kf}var Yf,a_;function C3(){if(a_)return Yf;a_=1;var e=rs(),r=Gb();function i(o,s){return e(o,r(o),s)}return Yf=i,Yf}var Xf,u_;function Kb(){if(u_)return Xf;u_=1;var e=$v(),r=pt();function i(o,s,u){var l=s(o);return r(o)?l:e(l,u(o))}return Xf=i,Xf}var Qf,l_;function Yb(){if(l_)return Qf;l_=1;var e=Kb(),r=Lv(),i=Ir();function o(s){return e(s,i,r)}return Qf=o,Qf}var Zf,c_;function T3(){if(c_)return Zf;c_=1;var e=Kb(),r=Gb(),i=ti();function o(s){return e(s,i,r)}return Zf=o,Zf}var Jf,f_;function R3(){if(f_)return Jf;f_=1;var e=ei(),r=Pn(),i=e(r,"DataView");return Jf=i,Jf}var ed,d_;function A3(){if(d_)return ed;d_=1;var e=ei(),r=Pn(),i=e(r,"Promise");return ed=i,ed}var td,h_;function Xb(){if(h_)return td;h_=1;var e=ei(),r=Pn(),i=e(r,"Set");return td=i,td}var nd,p_;function I3(){if(p_)return nd;p_=1;var e=ei(),r=Pn(),i=e(r,"WeakMap");return nd=i,nd}var rd,m_;function Hi(){if(m_)return rd;m_=1;var e=R3(),r=Iv(),i=A3(),o=Xb(),s=I3(),u=Jr(),l=Db(),c="[object Map]",d="[object Object]",p="[object Promise]",h="[object Set]",v="[object WeakMap]",g="[object DataView]",w=l(e),N=l(r),_=l(i),E=l(o),x=l(s),k=u;return(e&&k(new e(new ArrayBuffer(1)))!=g||r&&k(new r)!=c||i&&k(i.resolve())!=p||o&&k(new o)!=h||s&&k(new s)!=v)&&(k=function(T){var C=u(T),A=C==d?T.constructor:void 0,j=A?l(A):"";if(j)switch(j){case w:return g;case N:return c;case _:return p;case E:return h;case x:return v}return C}),rd=k,rd}var id,v_;function j3(){if(v_)return id;v_=1;var e=Object.prototype,r=e.hasOwnProperty;function i(o){var s=o.length,u=new o.constructor(s);return s&&typeof o[0]=="string"&&r.call(o,"index")&&(u.index=o.index,u.input=o.input),u}return id=i,id}var od,g_;function Qb(){if(g_)return od;g_=1;var e=Pn(),r=e.Uint8Array;return od=r,od}var sd,y_;function Dv(){if(y_)return sd;y_=1;var e=Qb();function r(i){var o=new i.constructor(i.byteLength);return new e(o).set(new e(i)),o}return sd=r,sd}var ad,w_;function M3(){if(w_)return ad;w_=1;var e=Dv();function r(i,o){var s=o?e(i.buffer):i.buffer;return new i.constructor(s,i.byteOffset,i.byteLength)}return ad=r,ad}var ud,__;function P3(){if(__)return ud;__=1;var e=/\w*$/;function r(i){var o=new i.constructor(i.source,e.exec(i));return o.lastIndex=i.lastIndex,o}return ud=r,ud}var ld,x_;function q3(){if(x_)return ld;x_=1;var e=Bi(),r=e?e.prototype:void 0,i=r?r.valueOf:void 0;function o(s){return i?Object(i.call(s)):{}}return ld=o,ld}var cd,S_;function Zb(){if(S_)return cd;S_=1;var e=Dv();function r(i,o){var s=o?e(i.buffer):i.buffer;return new i.constructor(s,i.byteOffset,i.length)}return cd=r,cd}var fd,E_;function O3(){if(E_)return fd;E_=1;var e=Dv(),r=M3(),i=P3(),o=q3(),s=Zb(),u="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",p="[object RegExp]",h="[object Set]",v="[object String]",g="[object Symbol]",w="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",E="[object Float64Array]",x="[object Int8Array]",k="[object Int16Array]",T="[object Int32Array]",C="[object Uint8Array]",A="[object Uint8ClampedArray]",j="[object Uint16Array]",M="[object Uint32Array]";function z(O,B,U){var ee=O.constructor;switch(B){case w:return e(O);case u:case l:return new ee(+O);case N:return r(O,U);case _:case E:case x:case k:case T:case C:case A:case j:case M:return s(O,U);case c:return new ee;case d:case v:return new ee(O);case p:return i(O);case h:return new ee;case g:return o(O)}}return fd=z,fd}var dd,k_;function Jb(){if(k_)return dd;k_=1;var e=vn(),r=Object.create,i=(function(){function o(){}return function(s){if(!e(s))return{};if(r)return r(s);o.prototype=s;var u=new o;return o.prototype=void 0,u}})();return dd=i,dd}var hd,b_;function eN(){if(b_)return hd;b_=1;var e=Jb(),r=du(),i=fu();function o(s){return typeof s.constructor=="function"&&!i(s)?e(r(s)):{}}return hd=o,hd}var pd,N_;function L3(){if(N_)return pd;N_=1;var e=Hi(),r=Bn(),i="[object Map]";function o(s){return r(s)&&e(s)==i}return pd=o,pd}var md,C_;function $3(){if(C_)return md;C_=1;var e=L3(),r=cu(),i=qv(),o=i&&i.isMap,s=o?r(o):e;return md=s,md}var vd,T_;function D3(){if(T_)return vd;T_=1;var e=Hi(),r=Bn(),i="[object Set]";function o(s){return r(s)&&e(s)==i}return vd=o,vd}var gd,R_;function F3(){if(R_)return gd;R_=1;var e=D3(),r=cu(),i=qv(),o=i&&i.isSet,s=o?r(o):e;return gd=s,gd}var yd,A_;function tN(){if(A_)return yd;A_=1;var e=su(),r=Mv(),i=uu(),o=S3(),s=b3(),u=Ub(),l=Hb(),c=N3(),d=C3(),p=Yb(),h=T3(),v=Hi(),g=j3(),w=O3(),N=eN(),_=pt(),E=Ui(),x=$3(),k=vn(),T=F3(),C=Ir(),A=ti(),j=1,M=2,z=4,O="[object Arguments]",B="[object Array]",U="[object Boolean]",ee="[object Date]",X="[object Error]",R="[object Function]",G="[object GeneratorFunction]",H="[object Map]",ne="[object Number]",Y="[object Object]",L="[object RegExp]",K="[object Set]",I="[object String]",F="[object Symbol]",ae="[object WeakMap]",q="[object ArrayBuffer]",V="[object DataView]",Q="[object Float32Array]",re="[object Float64Array]",ce="[object Int8Array]",he="[object Int16Array]",pe="[object Int32Array]",je="[object Uint8Array]",$e="[object Uint8ClampedArray]",Me="[object Uint16Array]",Ae="[object Uint32Array]",we={};we[O]=we[B]=we[q]=we[V]=we[U]=we[ee]=we[Q]=we[re]=we[ce]=we[he]=we[pe]=we[H]=we[ne]=we[Y]=we[L]=we[K]=we[I]=we[F]=we[je]=we[$e]=we[Me]=we[Ae]=!0,we[X]=we[R]=we[ae]=!1;function Be(ve,ge,ze,et,ft,lt){var Ue,Ge=ge&j,xt=ge&M,St=ge&z;if(ze&&(Ue=ft?ze(ve,et,ft,lt):ze(ve)),Ue!==void 0)return Ue;if(!k(ve))return ve;var Et=_(ve);if(Et){if(Ue=g(ve),!Ge)return l(ve,Ue)}else{var tt=v(ve),mt=tt==R||tt==G;if(E(ve))return u(ve,Ge);if(tt==Y||tt==O||mt&&!ft){if(Ue=xt||mt?{}:N(ve),!Ge)return xt?d(ve,s(Ue,ve)):c(ve,o(Ue,ve))}else{if(!we[tt])return ft?ve:{};Ue=w(ve,tt,Ge)}}lt||(lt=new e);var Mt=lt.get(ve);if(Mt)return Mt;lt.set(ve,Ue),T(ve)?ve.forEach(function(Ke){Ue.add(Be(Ke,ge,ze,Ke,ve,lt))}):x(ve)&&ve.forEach(function(Ke,dt){Ue.set(dt,Be(Ke,ge,ze,dt,ve,lt))});var He=St?xt?h:p:xt?A:C,vt=Et?void 0:He(ve);return r(vt||ve,function(Ke,dt){vt&&(dt=Ke,Ke=ve[dt]),i(Ue,dt,Be(Ke,ge,ze,dt,ve,lt))}),Ue}return yd=Be,yd}var wd,I_;function z3(){if(I_)return wd;I_=1;var e=tN(),r=4;function i(o){return e(o,r)}return wd=i,wd}var _d,j_;function Fv(){if(j_)return _d;j_=1;function e(r){return function(){return r}}return _d=e,_d}var xd,M_;function B3(){if(M_)return xd;M_=1;function e(r){return function(i,o,s){for(var u=-1,l=Object(i),c=s(i),d=c.length;d--;){var p=c[r?d:++u];if(o(l[p],p,l)===!1)break}return i}}return xd=e,xd}var Sd,P_;function zv(){if(P_)return Sd;P_=1;var e=B3(),r=e();return Sd=r,Sd}var Ed,q_;function Bv(){if(q_)return Ed;q_=1;var e=zv(),r=Ir();function i(o,s){return o&&e(o,s,r)}return Ed=i,Ed}var kd,O_;function U3(){if(O_)return kd;O_=1;var e=rr();function r(i,o){return function(s,u){if(s==null)return s;if(!e(s))return i(s,u);for(var l=s.length,c=o?l:-1,d=Object(s);(o?c--:++c<l)&&u(d[c],c,d)!==!1;);return s}}return kd=r,kd}var bd,L_;function hu(){if(L_)return bd;L_=1;var e=Bv(),r=U3(),i=r(e);return bd=i,bd}var Nd,$_;function ni(){if($_)return Nd;$_=1;function e(r){return r}return Nd=e,Nd}var Cd,D_;function nN(){if(D_)return Cd;D_=1;var e=ni();function r(i){return typeof i=="function"?i:e}return Cd=r,Cd}var Td,F_;function rN(){if(F_)return Td;F_=1;var e=Mv(),r=hu(),i=nN(),o=pt();function s(u,l){var c=o(u)?e:r;return c(u,i(l))}return Td=s,Td}var Rd,z_;function iN(){return z_||(z_=1,Rd=rN()),Rd}var Ad,B_;function H3(){if(B_)return Ad;B_=1;var e=hu();function r(i,o){var s=[];return e(i,function(u,l,c){o(u,l,c)&&s.push(u)}),s}return Ad=r,Ad}var Id,U_;function V3(){if(U_)return Id;U_=1;var e="__lodash_hash_undefined__";function r(i){return this.__data__.set(i,e),this}return Id=r,Id}var jd,H_;function W3(){if(H_)return jd;H_=1;function e(r){return this.__data__.has(r)}return jd=e,jd}var Md,V_;function oN(){if(V_)return Md;V_=1;var e=jv(),r=V3(),i=W3();function o(s){var u=-1,l=s==null?0:s.length;for(this.__data__=new e;++u<l;)this.add(s[u])}return o.prototype.add=o.prototype.push=r,o.prototype.has=i,Md=o,Md}var Pd,W_;function G3(){if(W_)return Pd;W_=1;function e(r,i){for(var o=-1,s=r==null?0:r.length;++o<s;)if(i(r[o],o,r))return!0;return!1}return Pd=e,Pd}var qd,G_;function sN(){if(G_)return qd;G_=1;function e(r,i){return r.has(i)}return qd=e,qd}var Od,K_;function aN(){if(K_)return Od;K_=1;var e=oN(),r=G3(),i=sN(),o=1,s=2;function u(l,c,d,p,h,v){var g=d&o,w=l.length,N=c.length;if(w!=N&&!(g&&N>w))return!1;var _=v.get(l),E=v.get(c);if(_&&E)return _==c&&E==l;var x=-1,k=!0,T=d&s?new e:void 0;for(v.set(l,c),v.set(c,l);++x<w;){var C=l[x],A=c[x];if(p)var j=g?p(A,C,x,c,l,v):p(C,A,x,l,c,v);if(j!==void 0){if(j)continue;k=!1;break}if(T){if(!r(c,function(M,z){if(!i(T,z)&&(C===M||h(C,M,d,p,v)))return T.push(z)})){k=!1;break}}else if(!(C===A||h(C,A,d,p,v))){k=!1;break}}return v.delete(l),v.delete(c),k}return Od=u,Od}var Ld,Y_;function K3(){if(Y_)return Ld;Y_=1;function e(r){var i=-1,o=Array(r.size);return r.forEach(function(s,u){o[++i]=[u,s]}),o}return Ld=e,Ld}var $d,X_;function Uv(){if(X_)return $d;X_=1;function e(r){var i=-1,o=Array(r.size);return r.forEach(function(s){o[++i]=s}),o}return $d=e,$d}var Dd,Q_;function Y3(){if(Q_)return Dd;Q_=1;var e=Bi(),r=Qb(),i=zi(),o=aN(),s=K3(),u=Uv(),l=1,c=2,d="[object Boolean]",p="[object Date]",h="[object Error]",v="[object Map]",g="[object Number]",w="[object RegExp]",N="[object Set]",_="[object String]",E="[object Symbol]",x="[object ArrayBuffer]",k="[object DataView]",T=e?e.prototype:void 0,C=T?T.valueOf:void 0;function A(j,M,z,O,B,U,ee){switch(z){case k:if(j.byteLength!=M.byteLength||j.byteOffset!=M.byteOffset)return!1;j=j.buffer,M=M.buffer;case x:return!(j.byteLength!=M.byteLength||!U(new r(j),new r(M)));case d:case p:case g:return i(+j,+M);case h:return j.name==M.name&&j.message==M.message;case w:case _:return j==M+"";case v:var X=s;case N:var R=O&l;if(X||(X=u),j.size!=M.size&&!R)return!1;var G=ee.get(j);if(G)return G==M;O|=c,ee.set(j,M);var H=o(X(j),X(M),O,B,U,ee);return ee.delete(j),H;case E:if(C)return C.call(j)==C.call(M)}return!1}return Dd=A,Dd}var Fd,Z_;function X3(){if(Z_)return Fd;Z_=1;var e=Yb(),r=1,i=Object.prototype,o=i.hasOwnProperty;function s(u,l,c,d,p,h){var v=c&r,g=e(u),w=g.length,N=e(l),_=N.length;if(w!=_&&!v)return!1;for(var E=w;E--;){var x=g[E];if(!(v?x in l:o.call(l,x)))return!1}var k=h.get(u),T=h.get(l);if(k&&T)return k==l&&T==u;var C=!0;h.set(u,l),h.set(l,u);for(var A=v;++E<w;){x=g[E];var j=u[x],M=l[x];if(d)var z=v?d(M,j,x,l,u,h):d(j,M,x,u,l,h);if(!(z===void 0?j===M||p(j,M,c,d,h):z)){C=!1;break}A||(A=x=="constructor")}if(C&&!A){var O=u.constructor,B=l.constructor;O!=B&&"constructor"in u&&"constructor"in l&&!(typeof O=="function"&&O instanceof O&&typeof B=="function"&&B instanceof B)&&(C=!1)}return h.delete(u),h.delete(l),C}return Fd=s,Fd}var zd,J_;function Q3(){if(J_)return zd;J_=1;var e=su(),r=aN(),i=Y3(),o=X3(),s=Hi(),u=pt(),l=Ui(),c=os(),d=1,p="[object Arguments]",h="[object Array]",v="[object Object]",g=Object.prototype,w=g.hasOwnProperty;function N(_,E,x,k,T,C){var A=u(_),j=u(E),M=A?h:s(_),z=j?h:s(E);M=M==p?v:M,z=z==p?v:z;var O=M==v,B=z==v,U=M==z;if(U&&l(_)){if(!l(E))return!1;A=!0,O=!1}if(U&&!O)return C||(C=new e),A||c(_)?r(_,E,x,k,T,C):i(_,E,M,x,k,T,C);if(!(x&d)){var ee=O&&w.call(_,"__wrapped__"),X=B&&w.call(E,"__wrapped__");if(ee||X){var R=ee?_.value():_,G=X?E.value():E;return C||(C=new e),T(R,G,x,k,C)}}return U?(C||(C=new e),o(_,E,x,k,T,C)):!1}return zd=N,zd}var Bd,ex;function uN(){if(ex)return Bd;ex=1;var e=Q3(),r=Bn();function i(o,s,u,l,c){return o===s?!0:o==null||s==null||!r(o)&&!r(s)?o!==o&&s!==s:e(o,s,u,l,i,c)}return Bd=i,Bd}var Ud,tx;function Z3(){if(tx)return Ud;tx=1;var e=su(),r=uN(),i=1,o=2;function s(u,l,c,d){var p=c.length,h=p,v=!d;if(u==null)return!h;for(u=Object(u);p--;){var g=c[p];if(v&&g[2]?g[1]!==u[g[0]]:!(g[0]in u))return!1}for(;++p<h;){g=c[p];var w=g[0],N=u[w],_=g[1];if(v&&g[2]){if(N===void 0&&!(w in u))return!1}else{var E=new e;if(d)var x=d(N,_,w,u,l,E);if(!(x===void 0?r(_,N,i|o,d,E):x))return!1}}return!0}return Ud=s,Ud}var Hd,nx;function lN(){if(nx)return Hd;nx=1;var e=vn();function r(i){return i===i&&!e(i)}return Hd=r,Hd}var Vd,rx;function J3(){if(rx)return Vd;rx=1;var e=lN(),r=Ir();function i(o){for(var s=r(o),u=s.length;u--;){var l=s[u],c=o[l];s[u]=[l,c,e(c)]}return s}return Vd=i,Vd}var Wd,ix;function cN(){if(ix)return Wd;ix=1;function e(r,i){return function(o){return o==null?!1:o[r]===i&&(i!==void 0||r in Object(o))}}return Wd=e,Wd}var Gd,ox;function eq(){if(ox)return Gd;ox=1;var e=Z3(),r=J3(),i=cN();function o(s){var u=r(s);return u.length==1&&u[0][2]?i(u[0][0],u[0][1]):function(l){return l===s||e(l,s,u)}}return Gd=o,Gd}var Kd,sx;function Vi(){if(sx)return Kd;sx=1;var e=Jr(),r=Bn(),i="[object Symbol]";function o(s){return typeof s=="symbol"||r(s)&&e(s)==i}return Kd=o,Kd}var Yd,ax;function Hv(){if(ax)return Yd;ax=1;var e=pt(),r=Vi(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,o=/^\w*$/;function s(u,l){if(e(u))return!1;var c=typeof u;return c=="number"||c=="symbol"||c=="boolean"||u==null||r(u)?!0:o.test(u)||!i.test(u)||l!=null&&u in Object(l)}return Yd=s,Yd}var Xd,ux;function tq(){if(ux)return Xd;ux=1;var e=jv(),r="Expected a function";function i(o,s){if(typeof o!="function"||s!=null&&typeof s!="function")throw new TypeError(r);var u=function(){var l=arguments,c=s?s.apply(this,l):l[0],d=u.cache;if(d.has(c))return d.get(c);var p=o.apply(this,l);return u.cache=d.set(c,p)||d,p};return u.cache=new(i.Cache||e),u}return i.Cache=e,Xd=i,Xd}var Qd,lx;function nq(){if(lx)return Qd;lx=1;var e=tq(),r=500;function i(o){var s=e(o,function(l){return u.size===r&&u.clear(),l}),u=s.cache;return s}return Qd=i,Qd}var Zd,cx;function rq(){if(cx)return Zd;cx=1;var e=nq(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,o=e(function(s){var u=[];return s.charCodeAt(0)===46&&u.push(""),s.replace(r,function(l,c,d,p){u.push(d?p.replace(i,"$1"):c||l)}),u});return Zd=o,Zd}var Jd,fx;function pu(){if(fx)return Jd;fx=1;function e(r,i){for(var o=-1,s=r==null?0:r.length,u=Array(s);++o<s;)u[o]=i(r[o],o,r);return u}return Jd=e,Jd}var eh,dx;function iq(){if(dx)return eh;dx=1;var e=Bi(),r=pu(),i=pt(),o=Vi(),s=e?e.prototype:void 0,u=s?s.toString:void 0;function l(c){if(typeof c=="string")return c;if(i(c))return r(c,l)+"";if(o(c))return u?u.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return eh=l,eh}var th,hx;function fN(){if(hx)return th;hx=1;var e=iq();function r(i){return i==null?"":e(i)}return th=r,th}var nh,px;function mu(){if(px)return nh;px=1;var e=pt(),r=Hv(),i=rq(),o=fN();function s(u,l){return e(u)?u:r(u,l)?[u]:i(o(u))}return nh=s,nh}var rh,mx;function ss(){if(mx)return rh;mx=1;var e=Vi();function r(i){if(typeof i=="string"||e(i))return i;var o=i+"";return o=="0"&&1/i==-1/0?"-0":o}return rh=r,rh}var ih,vx;function vu(){if(vx)return ih;vx=1;var e=mu(),r=ss();function i(o,s){s=e(s,o);for(var u=0,l=s.length;o!=null&&u<l;)o=o[r(s[u++])];return u&&u==l?o:void 0}return ih=i,ih}var oh,gx;function oq(){if(gx)return oh;gx=1;var e=vu();function r(i,o,s){var u=i==null?void 0:e(i,o);return u===void 0?s:u}return oh=r,oh}var sh,yx;function sq(){if(yx)return sh;yx=1;function e(r,i){return r!=null&&i in Object(r)}return sh=e,sh}var ah,wx;function dN(){if(wx)return ah;wx=1;var e=mu(),r=is(),i=pt(),o=lu(),s=Pv(),u=ss();function l(c,d,p){d=e(d,c);for(var h=-1,v=d.length,g=!1;++h<v;){var w=u(d[h]);if(!(g=c!=null&&p(c,w)))break;c=c[w]}return g||++h!=v?g:(v=c==null?0:c.length,!!v&&s(v)&&o(w,v)&&(i(c)||r(c)))}return ah=l,ah}var uh,_x;function hN(){if(_x)return uh;_x=1;var e=sq(),r=dN();function i(o,s){return o!=null&&r(o,s,e)}return uh=i,uh}var lh,xx;function aq(){if(xx)return lh;xx=1;var e=uN(),r=oq(),i=hN(),o=Hv(),s=lN(),u=cN(),l=ss(),c=1,d=2;function p(h,v){return o(h)&&s(v)?u(l(h),v):function(g){var w=r(g,h);return w===void 0&&w===v?i(g,h):e(v,w,c|d)}}return lh=p,lh}var ch,Sx;function pN(){if(Sx)return ch;Sx=1;function e(r){return function(i){return i==null?void 0:i[r]}}return ch=e,ch}var fh,Ex;function uq(){if(Ex)return fh;Ex=1;var e=vu();function r(i){return function(o){return e(o,i)}}return fh=r,fh}var dh,kx;function lq(){if(kx)return dh;kx=1;var e=pN(),r=uq(),i=Hv(),o=ss();function s(u){return i(u)?e(o(u)):r(u)}return dh=s,dh}var hh,bx;function ir(){if(bx)return hh;bx=1;var e=eq(),r=aq(),i=ni(),o=pt(),s=lq();function u(l){return typeof l=="function"?l:l==null?i:typeof l=="object"?o(l)?r(l[0],l[1]):e(l):s(l)}return hh=u,hh}var ph,Nx;function mN(){if(Nx)return ph;Nx=1;var e=Vb(),r=H3(),i=ir(),o=pt();function s(u,l){var c=o(u)?e:r;return c(u,i(l,3))}return ph=s,ph}var mh,Cx;function cq(){if(Cx)return mh;Cx=1;var e=Object.prototype,r=e.hasOwnProperty;function i(o,s){return o!=null&&r.call(o,s)}return mh=i,mh}var vh,Tx;function vN(){if(Tx)return vh;Tx=1;var e=cq(),r=dN();function i(o,s){return o!=null&&r(o,s,e)}return vh=i,vh}var gh,Rx;function fq(){if(Rx)return gh;Rx=1;var e=Ov(),r=Hi(),i=is(),o=pt(),s=rr(),u=Ui(),l=fu(),c=os(),d="[object Map]",p="[object Set]",h=Object.prototype,v=h.hasOwnProperty;function g(w){if(w==null)return!0;if(s(w)&&(o(w)||typeof w=="string"||typeof w.splice=="function"||u(w)||c(w)||i(w)))return!w.length;var N=r(w);if(N==d||N==p)return!w.size;if(l(w))return!e(w).length;for(var _ in w)if(v.call(w,_))return!1;return!0}return gh=g,gh}var yh,Ax;function gN(){if(Ax)return yh;Ax=1;function e(r){return r===void 0}return yh=e,yh}var wh,Ix;function yN(){if(Ix)return wh;Ix=1;var e=hu(),r=rr();function i(o,s){var u=-1,l=r(o)?Array(o.length):[];return e(o,function(c,d,p){l[++u]=s(c,d,p)}),l}return wh=i,wh}var _h,jx;function wN(){if(jx)return _h;jx=1;var e=pu(),r=ir(),i=yN(),o=pt();function s(u,l){var c=o(u)?e:i;return c(u,r(l,3))}return _h=s,_h}var xh,Mx;function dq(){if(Mx)return xh;Mx=1;function e(r,i,o,s){var u=-1,l=r==null?0:r.length;for(s&&l&&(o=r[++u]);++u<l;)o=i(o,r[u],u,r);return o}return xh=e,xh}var Sh,Px;function hq(){if(Px)return Sh;Px=1;function e(r,i,o,s,u){return u(r,function(l,c,d){o=s?(s=!1,l):i(o,l,c,d)}),o}return Sh=e,Sh}var Eh,qx;function _N(){if(qx)return Eh;qx=1;var e=dq(),r=hu(),i=ir(),o=hq(),s=pt();function u(l,c,d){var p=s(l)?e:o,h=arguments.length<3;return p(l,i(c,4),d,h,r)}return Eh=u,Eh}var kh,Ox;function pq(){if(Ox)return kh;Ox=1;var e=Jr(),r=pt(),i=Bn(),o="[object String]";function s(u){return typeof u=="string"||!r(u)&&i(u)&&e(u)==o}return kh=s,kh}var bh,Lx;function mq(){if(Lx)return bh;Lx=1;var e=pN(),r=e("length");return bh=r,bh}var Nh,$x;function vq(){if($x)return Nh;$x=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",o="\\u20d0-\\u20ff",s=r+i+o,u="\\ufe0e\\ufe0f",l="\\u200d",c=RegExp("["+l+e+s+u+"]");function d(p){return c.test(p)}return Nh=d,Nh}var Ch,Dx;function gq(){if(Dx)return Ch;Dx=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",o="\\u20d0-\\u20ff",s=r+i+o,u="\\ufe0e\\ufe0f",l="["+e+"]",c="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+d+")",h="[^"+e+"]",v="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",N=p+"?",_="["+u+"]?",E="(?:"+w+"(?:"+[h,v,g].join("|")+")"+_+N+")*",x=_+N+E,k="(?:"+[h+c+"?",c,v,g,l].join("|")+")",T=RegExp(d+"(?="+d+")|"+k+x,"g");function C(A){for(var j=T.lastIndex=0;T.test(A);)++j;return j}return Ch=C,Ch}var Th,Fx;function yq(){if(Fx)return Th;Fx=1;var e=mq(),r=vq(),i=gq();function o(s){return r(s)?i(s):e(s)}return Th=o,Th}var Rh,zx;function wq(){if(zx)return Rh;zx=1;var e=Ov(),r=Hi(),i=rr(),o=pq(),s=yq(),u="[object Map]",l="[object Set]";function c(d){if(d==null)return 0;if(i(d))return o(d)?s(d):d.length;var p=r(d);return p==u||p==l?d.size:e(d).length}return Rh=c,Rh}var Ah,Bx;function _q(){if(Bx)return Ah;Bx=1;var e=Mv(),r=Jb(),i=Bv(),o=ir(),s=du(),u=pt(),l=Ui(),c=ns(),d=vn(),p=os();function h(v,g,w){var N=u(v),_=N||l(v)||p(v);if(g=o(g,4),w==null){var E=v&&v.constructor;_?w=N?new E:[]:d(v)?w=c(E)?r(s(v)):{}:w={}}return(_?e:i)(v,function(x,k,T){return g(w,x,k,T)}),w}return Ah=h,Ah}var Ih,Ux;function xq(){if(Ux)return Ih;Ux=1;var e=Bi(),r=is(),i=pt(),o=e?e.isConcatSpreadable:void 0;function s(u){return i(u)||r(u)||!!(o&&u&&u[o])}return Ih=s,Ih}var jh,Hx;function Vv(){if(Hx)return jh;Hx=1;var e=$v(),r=xq();function i(o,s,u,l,c){var d=-1,p=o.length;for(u||(u=r),c||(c=[]);++d<p;){var h=o[d];s>0&&u(h)?s>1?i(h,s-1,u,l,c):e(c,h):l||(c[c.length]=h)}return c}return jh=i,jh}var Mh,Vx;function Sq(){if(Vx)return Mh;Vx=1;function e(r,i,o){switch(o.length){case 0:return r.call(i);case 1:return r.call(i,o[0]);case 2:return r.call(i,o[0],o[1]);case 3:return r.call(i,o[0],o[1],o[2])}return r.apply(i,o)}return Mh=e,Mh}var Ph,Wx;function xN(){if(Wx)return Ph;Wx=1;var e=Sq(),r=Math.max;function i(o,s,u){return s=r(s===void 0?o.length-1:s,0),function(){for(var l=arguments,c=-1,d=r(l.length-s,0),p=Array(d);++c<d;)p[c]=l[s+c];c=-1;for(var h=Array(s+1);++c<s;)h[c]=l[c];return h[s]=u(p),e(o,this,h)}}return Ph=i,Ph}var qh,Gx;function Eq(){if(Gx)return qh;Gx=1;var e=Fv(),r=Fb(),i=ni(),o=r?function(s,u){return r(s,"toString",{configurable:!0,enumerable:!1,value:e(u),writable:!0})}:i;return qh=o,qh}var Oh,Kx;function kq(){if(Kx)return Oh;Kx=1;var e=800,r=16,i=Date.now;function o(s){var u=0,l=0;return function(){var c=i(),d=r-(c-l);if(l=c,d>0){if(++u>=e)return arguments[0]}else u=0;return s.apply(void 0,arguments)}}return Oh=o,Oh}var Lh,Yx;function SN(){if(Yx)return Lh;Yx=1;var e=Eq(),r=kq(),i=r(e);return Lh=i,Lh}var $h,Xx;function gu(){if(Xx)return $h;Xx=1;var e=ni(),r=xN(),i=SN();function o(s,u){return i(r(s,u,e),s+"")}return $h=o,$h}var Dh,Qx;function EN(){if(Qx)return Dh;Qx=1;function e(r,i,o,s){for(var u=r.length,l=o+(s?1:-1);s?l--:++l<u;)if(i(r[l],l,r))return l;return-1}return Dh=e,Dh}var Fh,Zx;function bq(){if(Zx)return Fh;Zx=1;function e(r){return r!==r}return Fh=e,Fh}var zh,Jx;function Nq(){if(Jx)return zh;Jx=1;function e(r,i,o){for(var s=o-1,u=r.length;++s<u;)if(r[s]===i)return s;return-1}return zh=e,zh}var Bh,eS;function Cq(){if(eS)return Bh;eS=1;var e=EN(),r=bq(),i=Nq();function o(s,u,l){return u===u?i(s,u,l):e(s,r,l)}return Bh=o,Bh}var Uh,tS;function Tq(){if(tS)return Uh;tS=1;var e=Cq();function r(i,o){var s=i==null?0:i.length;return!!s&&e(i,o,0)>-1}return Uh=r,Uh}var Hh,nS;function Rq(){if(nS)return Hh;nS=1;function e(r,i,o){for(var s=-1,u=r==null?0:r.length;++s<u;)if(o(i,r[s]))return!0;return!1}return Hh=e,Hh}var Vh,rS;function Aq(){if(rS)return Vh;rS=1;function e(){}return Vh=e,Vh}var Wh,iS;function Iq(){if(iS)return Wh;iS=1;var e=Xb(),r=Aq(),i=Uv(),o=1/0,s=e&&1/i(new e([,-0]))[1]==o?function(u){return new e(u)}:r;return Wh=s,Wh}var Gh,oS;function jq(){if(oS)return Gh;oS=1;var e=oN(),r=Tq(),i=Rq(),o=sN(),s=Iq(),u=Uv(),l=200;function c(d,p,h){var v=-1,g=r,w=d.length,N=!0,_=[],E=_;if(h)N=!1,g=i;else if(w>=l){var x=p?null:s(d);if(x)return u(x);N=!1,g=o,E=new e}else E=p?[]:_;e:for(;++v<w;){var k=d[v],T=p?p(k):k;if(k=h||k!==0?k:0,N&&T===T){for(var C=E.length;C--;)if(E[C]===T)continue e;p&&E.push(T),_.push(k)}else g(E,T,h)||(E!==_&&E.push(T),_.push(k))}return _}return Gh=c,Gh}var Kh,sS;function kN(){if(sS)return Kh;sS=1;var e=rr(),r=Bn();function i(o){return r(o)&&e(o)}return Kh=i,Kh}var Yh,aS;function Mq(){if(aS)return Yh;aS=1;var e=Vv(),r=gu(),i=jq(),o=kN(),s=r(function(u){return i(e(u,1,o,!0))});return Yh=s,Yh}var Xh,uS;function Pq(){if(uS)return Xh;uS=1;var e=pu();function r(i,o){return e(o,function(s){return i[s]})}return Xh=r,Xh}var Qh,lS;function bN(){if(lS)return Qh;lS=1;var e=Pq(),r=Ir();function i(o){return o==null?[]:e(o,r(o))}return Qh=i,Qh}var Zh,cS;function gn(){if(cS)return Zh;cS=1;var e;if(typeof Av=="function")try{e={clone:z3(),constant:Fv(),each:iN(),filter:mN(),has:vN(),isArray:pt(),isEmpty:fq(),isFunction:ns(),isUndefined:gN(),keys:Ir(),map:wN(),reduce:_N(),size:wq(),transform:_q(),union:Mq(),values:bN()}}catch{}return e||(e=window._),Zh=e,Zh}var Jh,fS;function Wv(){if(fS)return Jh;fS=1;var e=gn();Jh=s;var r="\0",i="\0",o="";function s(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.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={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(h){return this._label=h,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(v){return e.isEmpty(h._in[v])})},s.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(v){return e.isEmpty(h._out[v])})},s.prototype.setNodes=function(h,v){var g=arguments,w=this;return e.each(h,function(N){g.length>1?w.setNode(N,v):w.setNode(N)}),this},s.prototype.setNode=function(h,v){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=v),this):(this._nodes[h]=arguments.length>1?v:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=i,this._children[h]={},this._children[i][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},s.prototype.node=function(h){return this._nodes[h]},s.prototype.hasNode=function(h){return e.has(this._nodes,h)},s.prototype.removeNode=function(h){var v=this;if(e.has(this._nodes,h)){var g=function(w){v.removeEdge(v._edgeObjs[w])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(w){v.setParent(w)}),delete this._children[h]),e.each(e.keys(this._in[h]),g),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),g),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},s.prototype.setParent=function(h,v){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(v))v=i;else{v+="";for(var g=v;!e.isUndefined(g);g=this.parent(g))if(g===h)throw new Error("Setting "+v+" as parent of "+h+" would create a cycle");this.setNode(v)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=v,this._children[v][h]=!0,this},s.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},s.prototype.parent=function(h){if(this._isCompound){var v=this._parent[h];if(v!==i)return v}},s.prototype.children=function(h){if(e.isUndefined(h)&&(h=i),this._isCompound){var v=this._children[h];if(v)return e.keys(v)}else{if(h===i)return this.nodes();if(this.hasNode(h))return[]}},s.prototype.predecessors=function(h){var v=this._preds[h];if(v)return e.keys(v)},s.prototype.successors=function(h){var v=this._sucs[h];if(v)return e.keys(v)},s.prototype.neighbors=function(h){var v=this.predecessors(h);if(v)return e.union(v,this.successors(h))},s.prototype.isLeaf=function(h){var v;return this.isDirected()?v=this.successors(h):v=this.neighbors(h),v.length===0},s.prototype.filterNodes=function(h){var v=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});v.setGraph(this.graph());var g=this;e.each(this._nodes,function(_,E){h(E)&&v.setNode(E,_)}),e.each(this._edgeObjs,function(_){v.hasNode(_.v)&&v.hasNode(_.w)&&v.setEdge(_,g.edge(_))});var w={};function N(_){var E=g.parent(_);return E===void 0||v.hasNode(E)?(w[_]=E,E):E in w?w[E]:N(E)}return this._isCompound&&e.each(v.nodes(),function(_){v.setParent(_,N(_))}),v},s.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(h,v){var g=this,w=arguments;return e.reduce(h,function(N,_){return w.length>1?g.setEdge(N,_,v):g.setEdge(N,_),_}),this},s.prototype.setEdge=function(){var h,v,g,w,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(h=_.v,v=_.w,g=_.name,arguments.length===2&&(w=arguments[1],N=!0)):(h=_,v=arguments[1],g=arguments[3],arguments.length>2&&(w=arguments[2],N=!0)),h=""+h,v=""+v,e.isUndefined(g)||(g=""+g);var E=c(this._isDirected,h,v,g);if(e.has(this._edgeLabels,E))return N&&(this._edgeLabels[E]=w),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(v),this._edgeLabels[E]=N?w:this._defaultEdgeLabelFn(h,v,g);var x=d(this._isDirected,h,v,g);return h=x.v,v=x.w,Object.freeze(x),this._edgeObjs[E]=x,u(this._preds[v],h),u(this._sucs[h],v),this._in[v][E]=x,this._out[h][E]=x,this._edgeCount++,this},s.prototype.edge=function(h,v,g){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,v,g);return this._edgeLabels[w]},s.prototype.hasEdge=function(h,v,g){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,v,g);return e.has(this._edgeLabels,w)},s.prototype.removeEdge=function(h,v,g){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,v,g),N=this._edgeObjs[w];return N&&(h=N.v,v=N.w,delete this._edgeLabels[w],delete this._edgeObjs[w],l(this._preds[v],h),l(this._sucs[h],v),delete this._in[v][w],delete this._out[h][w],this._edgeCount--),this},s.prototype.inEdges=function(h,v){var g=this._in[h];if(g){var w=e.values(g);return v?e.filter(w,function(N){return N.v===v}):w}},s.prototype.outEdges=function(h,v){var g=this._out[h];if(g){var w=e.values(g);return v?e.filter(w,function(N){return N.w===v}):w}},s.prototype.nodeEdges=function(h,v){var g=this.inEdges(h,v);if(g)return g.concat(this.outEdges(h,v))};function u(h,v){h[v]?h[v]++:h[v]=1}function l(h,v){--h[v]||delete h[v]}function c(h,v,g,w){var N=""+v,_=""+g;if(!h&&N>_){var E=N;N=_,_=E}return N+o+_+o+(e.isUndefined(w)?r:w)}function d(h,v,g,w){var N=""+v,_=""+g;if(!h&&N>_){var E=N;N=_,_=E}var x={v:N,w:_};return w&&(x.name=w),x}function p(h,v){return c(h,v.v,v.w,v.name)}return Jh}var ep,dS;function qq(){return dS||(dS=1,ep="2.1.8"),ep}var tp,hS;function Oq(){return hS||(hS=1,tp={Graph:Wv(),version:qq()}),tp}var np,pS;function Lq(){if(pS)return np;pS=1;var e=gn(),r=Wv();np={write:i,read:u};function i(l){var c={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:o(l),edges:s(l)};return e.isUndefined(l.graph())||(c.value=e.clone(l.graph())),c}function o(l){return e.map(l.nodes(),function(c){var d=l.node(c),p=l.parent(c),h={v:c};return e.isUndefined(d)||(h.value=d),e.isUndefined(p)||(h.parent=p),h})}function s(l){return e.map(l.edges(),function(c){var d=l.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(d)||(p.value=d),p})}function u(l){var c=new r(l.options).setGraph(l.value);return e.each(l.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(l.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return np}var rp,mS;function $q(){if(mS)return rp;mS=1;var e=gn();rp=r;function r(i){var o={},s=[],u;function l(c){e.has(o,c)||(o[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&&s.push(u)}),s}return rp}var ip,vS;function NN(){if(vS)return ip;vS=1;var e=gn();ip=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(i){return i.key})},r.prototype.has=function(i){return e.has(this._keyIndices,i)},r.prototype.priority=function(i){var o=this._keyIndices[i];if(o!==void 0)return this._arr[o].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(i,o){var s=this._keyIndices;if(i=String(i),!e.has(s,i)){var u=this._arr,l=u.length;return s[i]=l,u.push({key:i,priority:o}),this._decrease(l),!0}return!1},r.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},r.prototype.decrease=function(i,o){var s=this._keyIndices[i];if(o>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+i+" Old: "+this._arr[s].priority+" New: "+o);this._arr[s].priority=o,this._decrease(s)},r.prototype._heapify=function(i){var o=this._arr,s=2*i,u=s+1,l=i;s<o.length&&(l=o[s].priority<o[l].priority?s:l,u<o.length&&(l=o[u].priority<o[l].priority?u:l),l!==i&&(this._swap(i,l),this._heapify(l)))},r.prototype._decrease=function(i){for(var o=this._arr,s=o[i].priority,u;i!==0&&(u=i>>1,!(o[u].priority<s));)this._swap(i,u),i=u},r.prototype._swap=function(i,o){var s=this._arr,u=this._keyIndices,l=s[i],c=s[o];s[i]=c,s[o]=l,u[c.key]=i,u[l.key]=o},ip}var op,gS;function CN(){if(gS)return op;gS=1;var e=gn(),r=NN();op=o;var i=e.constant(1);function o(u,l,c,d){return s(u,String(l),c||i,d||function(p){return u.outEdges(p)})}function s(u,l,c,d){var p={},h=new r,v,g,w=function(N){var _=N.v!==v?N.v:N.w,E=p[_],x=c(N),k=g.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+x);k<E.distance&&(E.distance=k,E.predecessor=v,h.decrease(_,k))};for(u.nodes().forEach(function(N){var _=N===l?0:Number.POSITIVE_INFINITY;p[N]={distance:_},h.add(N,_)});h.size()>0&&(v=h.removeMin(),g=p[v],g.distance!==Number.POSITIVE_INFINITY);)d(v).forEach(w);return p}return op}var sp,yS;function Dq(){if(yS)return sp;yS=1;var e=CN(),r=gn();sp=i;function i(o,s,u){return r.transform(o.nodes(),function(l,c){l[c]=e(o,c,s,u)},{})}return sp}var ap,wS;function TN(){if(wS)return ap;wS=1;var e=gn();ap=r;function r(i){var o=0,s=[],u={},l=[];function c(d){var p=u[d]={onStack:!0,lowlink:o,index:o++};if(s.push(d),i.successors(d).forEach(function(g){e.has(u,g)?u[g].onStack&&(p.lowlink=Math.min(p.lowlink,u[g].index)):(c(g),p.lowlink=Math.min(p.lowlink,u[g].lowlink))}),p.lowlink===p.index){var h=[],v;do v=s.pop(),u[v].onStack=!1,h.push(v);while(d!==v);l.push(h)}}return i.nodes().forEach(function(d){e.has(u,d)||c(d)}),l}return ap}var up,_S;function Fq(){if(_S)return up;_S=1;var e=gn(),r=TN();up=i;function i(o){return e.filter(r(o),function(s){return s.length>1||s.length===1&&o.hasEdge(s[0],s[0])})}return up}var lp,xS;function zq(){if(xS)return lp;xS=1;var e=gn();lp=i;var r=e.constant(1);function i(s,u,l){return o(s,u||r,l||function(c){return s.outEdges(c)})}function o(s,u,l){var c={},d=s.nodes();return d.forEach(function(p){c[p]={},c[p][p]={distance:0},d.forEach(function(h){p!==h&&(c[p][h]={distance:Number.POSITIVE_INFINITY})}),l(p).forEach(function(h){var v=h.v===p?h.w:h.v,g=u(h);c[p][v]={distance:g,predecessor:p}})}),d.forEach(function(p){var h=c[p];d.forEach(function(v){var g=c[v];d.forEach(function(w){var N=g[p],_=h[w],E=g[w],x=N.distance+_.distance;x<E.distance&&(E.distance=x,E.predecessor=_.predecessor)})})}),c}return lp}var cp,SS;function RN(){if(SS)return cp;SS=1;var e=gn();cp=r,r.CycleException=i;function r(o){var s={},u={},l=[];function c(d){if(e.has(u,d))throw new i;e.has(s,d)||(u[d]=!0,s[d]=!0,e.each(o.predecessors(d),c),delete u[d],l.push(d))}if(e.each(o.sinks(),c),e.size(s)!==o.nodeCount())throw new i;return l}function i(){}return i.prototype=new Error,cp}var fp,ES;function Bq(){if(ES)return fp;ES=1;var e=RN();fp=r;function r(i){try{e(i)}catch(o){if(o instanceof e.CycleException)return!1;throw o}return!0}return fp}var dp,kS;function AN(){if(kS)return dp;kS=1;var e=gn();dp=r;function r(o,s,u){e.isArray(s)||(s=[s]);var l=(o.isDirected()?o.successors:o.neighbors).bind(o),c=[],d={};return e.each(s,function(p){if(!o.hasNode(p))throw new Error("Graph does not have node: "+p);i(o,p,u==="post",d,l,c)}),c}function i(o,s,u,l,c,d){e.has(l,s)||(l[s]=!0,u||d.push(s),e.each(c(s),function(p){i(o,p,u,l,c,d)}),u&&d.push(s))}return dp}var hp,bS;function Uq(){if(bS)return hp;bS=1;var e=AN();hp=r;function r(i,o){return e(i,o,"post")}return hp}var pp,NS;function Hq(){if(NS)return pp;NS=1;var e=AN();pp=r;function r(i,o){return e(i,o,"pre")}return pp}var mp,CS;function Vq(){if(CS)return mp;CS=1;var e=gn(),r=Wv(),i=NN();mp=o;function o(s,u){var l=new r,c={},d=new i,p;function h(g){var w=g.v===p?g.w:g.v,N=d.priority(w);if(N!==void 0){var _=u(g);_<N&&(c[w]=p,d.decrease(w,_))}}if(s.nodeCount()===0)return l;e.each(s.nodes(),function(g){d.add(g,Number.POSITIVE_INFINITY),l.setNode(g)}),d.decrease(s.nodes()[0],0);for(var v=!1;d.size()>0;){if(p=d.removeMin(),e.has(c,p))l.setEdge(p,c[p]);else{if(v)throw new Error("Input graph is not connected: "+s);v=!0}s.nodeEdges(p).forEach(h)}return l}return mp}var vp,TS;function Wq(){return TS||(TS=1,vp={components:$q(),dijkstra:CN(),dijkstraAll:Dq(),findCycles:Fq(),floydWarshall:zq(),isAcyclic:Bq(),postorder:Uq(),preorder:Hq(),prim:Vq(),tarjan:TN(),topsort:RN()}),vp}var gp,RS;function Gq(){if(RS)return gp;RS=1;var e=Oq();return gp={Graph:e.Graph,json:Lq(),alg:Wq(),version:e.version},gp}var yp,AS;function jn(){if(AS)return yp;AS=1;var e;if(typeof Av=="function")try{e=Gq()}catch{}return e||(e=window.graphlib),yp=e,yp}var wp,IS;function Kq(){if(IS)return wp;IS=1;var e=tN(),r=1,i=4;function o(s){return e(s,r|i)}return wp=o,wp}var _p,jS;function yu(){if(jS)return _p;jS=1;var e=zi(),r=rr(),i=lu(),o=vn();function s(u,l,c){if(!o(c))return!1;var d=typeof l;return(d=="number"?r(c)&&i(l,c.length):d=="string"&&l in c)?e(c[l],u):!1}return _p=s,_p}var xp,MS;function Yq(){if(MS)return xp;MS=1;var e=gu(),r=zi(),i=yu(),o=ti(),s=Object.prototype,u=s.hasOwnProperty,l=e(function(c,d){c=Object(c);var p=-1,h=d.length,v=h>2?d[2]:void 0;for(v&&i(d[0],d[1],v)&&(h=1);++p<h;)for(var g=d[p],w=o(g),N=-1,_=w.length;++N<_;){var E=w[N],x=c[E];(x===void 0||r(x,s[E])&&!u.call(c,E))&&(c[E]=g[E])}return c});return xp=l,xp}var Sp,PS;function Xq(){if(PS)return Sp;PS=1;var e=ir(),r=rr(),i=Ir();function o(s){return function(u,l,c){var d=Object(u);if(!r(u)){var p=e(l,3);u=i(u),l=function(v){return p(d[v],v,d)}}var h=s(u,l,c);return h>-1?d[p?u[h]:h]:void 0}}return Sp=o,Sp}var Ep,qS;function Qq(){if(qS)return Ep;qS=1;var e=/\s/;function r(i){for(var o=i.length;o--&&e.test(i.charAt(o)););return o}return Ep=r,Ep}var kp,OS;function Zq(){if(OS)return kp;OS=1;var e=Qq(),r=/^\s+/;function i(o){return o&&o.slice(0,e(o)+1).replace(r,"")}return kp=i,kp}var bp,LS;function Jq(){if(LS)return bp;LS=1;var e=Zq(),r=vn(),i=Vi(),o=NaN,s=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;function d(p){if(typeof p=="number")return p;if(i(p))return o;if(r(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=r(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var v=u.test(p);return v||l.test(p)?c(p.slice(2),v?2:8):s.test(p)?o:+p}return bp=d,bp}var Np,$S;function IN(){if($S)return Np;$S=1;var e=Jq(),r=1/0,i=17976931348623157e292;function o(s){if(!s)return s===0?s:0;if(s=e(s),s===r||s===-r){var u=s<0?-1:1;return u*i}return s===s?s:0}return Np=o,Np}var Cp,DS;function eO(){if(DS)return Cp;DS=1;var e=IN();function r(i){var o=e(i),s=o%1;return o===o?s?o-s:o:0}return Cp=r,Cp}var Tp,FS;function tO(){if(FS)return Tp;FS=1;var e=EN(),r=ir(),i=eO(),o=Math.max;function s(u,l,c){var d=u==null?0:u.length;if(!d)return-1;var p=c==null?0:i(c);return p<0&&(p=o(d+p,0)),e(u,r(l,3),p)}return Tp=s,Tp}var Rp,zS;function nO(){if(zS)return Rp;zS=1;var e=Xq(),r=tO(),i=e(r);return Rp=i,Rp}var Ap,BS;function jN(){if(BS)return Ap;BS=1;var e=Vv();function r(i){var o=i==null?0:i.length;return o?e(i,1):[]}return Ap=r,Ap}var Ip,US;function rO(){if(US)return Ip;US=1;var e=zv(),r=nN(),i=ti();function o(s,u){return s==null?s:e(s,r(u),i)}return Ip=o,Ip}var jp,HS;function iO(){if(HS)return jp;HS=1;function e(r){var i=r==null?0:r.length;return i?r[i-1]:void 0}return jp=e,jp}var Mp,VS;function oO(){if(VS)return Mp;VS=1;var e=au(),r=Bv(),i=ir();function o(s,u){var l={};return u=i(u,3),r(s,function(c,d,p){e(l,d,u(c,d,p))}),l}return Mp=o,Mp}var Pp,WS;function Gv(){if(WS)return Pp;WS=1;var e=Vi();function r(i,o,s){for(var u=-1,l=i.length;++u<l;){var c=i[u],d=o(c);if(d!=null&&(p===void 0?d===d&&!e(d):s(d,p)))var p=d,h=c}return h}return Pp=r,Pp}var qp,GS;function sO(){if(GS)return qp;GS=1;function e(r,i){return r>i}return qp=e,qp}var Op,KS;function aO(){if(KS)return Op;KS=1;var e=Gv(),r=sO(),i=ni();function o(s){return s&&s.length?e(s,i,r):void 0}return Op=o,Op}var Lp,YS;function MN(){if(YS)return Lp;YS=1;var e=au(),r=zi();function i(o,s,u){(u!==void 0&&!r(o[s],u)||u===void 0&&!(s in o))&&e(o,s,u)}return Lp=i,Lp}var $p,XS;function uO(){if(XS)return $p;XS=1;var e=Jr(),r=du(),i=Bn(),o="[object Object]",s=Function.prototype,u=Object.prototype,l=s.toString,c=u.hasOwnProperty,d=l.call(Object);function p(h){if(!i(h)||e(h)!=o)return!1;var v=r(h);if(v===null)return!0;var g=c.call(v,"constructor")&&v.constructor;return typeof g=="function"&&g instanceof g&&l.call(g)==d}return $p=p,$p}var Dp,QS;function PN(){if(QS)return Dp;QS=1;function e(r,i){if(!(i==="constructor"&&typeof r[i]=="function")&&i!="__proto__")return r[i]}return Dp=e,Dp}var Fp,ZS;function lO(){if(ZS)return Fp;ZS=1;var e=rs(),r=ti();function i(o){return e(o,r(o))}return Fp=i,Fp}var zp,JS;function cO(){if(JS)return zp;JS=1;var e=MN(),r=Ub(),i=Zb(),o=Hb(),s=eN(),u=is(),l=pt(),c=kN(),d=Ui(),p=ns(),h=vn(),v=uO(),g=os(),w=PN(),N=lO();function _(E,x,k,T,C,A,j){var M=w(E,k),z=w(x,k),O=j.get(z);if(O){e(E,k,O);return}var B=A?A(M,z,k+"",E,x,j):void 0,U=B===void 0;if(U){var ee=l(z),X=!ee&&d(z),R=!ee&&!X&&g(z);B=z,ee||X||R?l(M)?B=M:c(M)?B=o(M):X?(U=!1,B=r(z,!0)):R?(U=!1,B=i(z,!0)):B=[]:v(z)||u(z)?(B=M,u(M)?B=N(M):(!h(M)||p(M))&&(B=s(z))):U=!1}U&&(j.set(z,B),C(B,z,T,A,j),j.delete(z)),e(E,k,B)}return zp=_,zp}var Bp,eE;function fO(){if(eE)return Bp;eE=1;var e=su(),r=MN(),i=zv(),o=cO(),s=vn(),u=ti(),l=PN();function c(d,p,h,v,g){d!==p&&i(p,function(w,N){if(g||(g=new e),s(w))o(d,p,N,h,c,v,g);else{var _=v?v(l(d,N),w,N+"",d,p,g):void 0;_===void 0&&(_=w),r(d,N,_)}},u)}return Bp=c,Bp}var Up,tE;function dO(){if(tE)return Up;tE=1;var e=gu(),r=yu();function i(o){return e(function(s,u){var l=-1,c=u.length,d=c>1?u[c-1]:void 0,p=c>2?u[2]:void 0;for(d=o.length>3&&typeof d=="function"?(c--,d):void 0,p&&r(u[0],u[1],p)&&(d=c<3?void 0:d,c=1),s=Object(s);++l<c;){var h=u[l];h&&o(s,h,l,d)}return s})}return Up=i,Up}var Hp,nE;function hO(){if(nE)return Hp;nE=1;var e=fO(),r=dO(),i=r(function(o,s,u){e(o,s,u)});return Hp=i,Hp}var Vp,rE;function qN(){if(rE)return Vp;rE=1;function e(r,i){return r<i}return Vp=e,Vp}var Wp,iE;function pO(){if(iE)return Wp;iE=1;var e=Gv(),r=qN(),i=ni();function o(s){return s&&s.length?e(s,i,r):void 0}return Wp=o,Wp}var Gp,oE;function mO(){if(oE)return Gp;oE=1;var e=Gv(),r=ir(),i=qN();function o(s,u){return s&&s.length?e(s,r(u,2),i):void 0}return Gp=o,Gp}var Kp,sE;function vO(){if(sE)return Kp;sE=1;var e=Pn(),r=function(){return e.Date.now()};return Kp=r,Kp}var Yp,aE;function gO(){if(aE)return Yp;aE=1;var e=uu(),r=mu(),i=lu(),o=vn(),s=ss();function u(l,c,d,p){if(!o(l))return l;c=r(c,l);for(var h=-1,v=c.length,g=v-1,w=l;w!=null&&++h<v;){var N=s(c[h]),_=d;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(h!=g){var E=w[N];_=p?p(E,N,w):void 0,_===void 0&&(_=o(E)?E:i(c[h+1])?[]:{})}e(w,N,_),w=w[N]}return l}return Yp=u,Yp}var Xp,uE;function yO(){if(uE)return Xp;uE=1;var e=vu(),r=gO(),i=mu();function o(s,u,l){for(var c=-1,d=u.length,p={};++c<d;){var h=u[c],v=e(s,h);l(v,h)&&r(p,i(h,s),v)}return p}return Xp=o,Xp}var Qp,lE;function wO(){if(lE)return Qp;lE=1;var e=yO(),r=hN();function i(o,s){return e(o,s,function(u,l){return r(o,l)})}return Qp=i,Qp}var Zp,cE;function _O(){if(cE)return Zp;cE=1;var e=jN(),r=xN(),i=SN();function o(s){return i(r(s,void 0,e),s+"")}return Zp=o,Zp}var Jp,fE;function xO(){if(fE)return Jp;fE=1;var e=wO(),r=_O(),i=r(function(o,s){return o==null?{}:e(o,s)});return Jp=i,Jp}var em,dE;function SO(){if(dE)return em;dE=1;var e=Math.ceil,r=Math.max;function i(o,s,u,l){for(var c=-1,d=r(e((s-o)/(u||1)),0),p=Array(d);d--;)p[l?d:++c]=o,o+=u;return p}return em=i,em}var tm,hE;function EO(){if(hE)return tm;hE=1;var e=SO(),r=yu(),i=IN();function o(s){return function(u,l,c){return c&&typeof c!="number"&&r(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,s)}}return tm=o,tm}var nm,pE;function kO(){if(pE)return nm;pE=1;var e=EO(),r=e();return nm=r,nm}var rm,mE;function bO(){if(mE)return rm;mE=1;function e(r,i){var o=r.length;for(r.sort(i);o--;)r[o]=r[o].value;return r}return rm=e,rm}var im,vE;function NO(){if(vE)return im;vE=1;var e=Vi();function r(i,o){if(i!==o){var s=i!==void 0,u=i===null,l=i===i,c=e(i),d=o!==void 0,p=o===null,h=o===o,v=e(o);if(!p&&!v&&!c&&i>o||c&&d&&h&&!p&&!v||u&&d&&h||!s&&h||!l)return 1;if(!u&&!c&&!v&&i<o||v&&s&&l&&!u&&!c||p&&s&&l||!d&&l||!h)return-1}return 0}return im=r,im}var om,gE;function CO(){if(gE)return om;gE=1;var e=NO();function r(i,o,s){for(var u=-1,l=i.criteria,c=o.criteria,d=l.length,p=s.length;++u<d;){var h=e(l[u],c[u]);if(h){if(u>=p)return h;var v=s[u];return h*(v=="desc"?-1:1)}}return i.index-o.index}return om=r,om}var sm,yE;function TO(){if(yE)return sm;yE=1;var e=pu(),r=vu(),i=ir(),o=yN(),s=bO(),u=cu(),l=CO(),c=ni(),d=pt();function p(h,v,g){v.length?v=e(v,function(_){return d(_)?function(E){return r(E,_.length===1?_[0]:_)}:_}):v=[c];var w=-1;v=e(v,u(i));var N=o(h,function(_,E,x){var k=e(v,function(T){return T(_)});return{criteria:k,index:++w,value:_}});return s(N,function(_,E){return l(_,E,g)})}return sm=p,sm}var am,wE;function RO(){if(wE)return am;wE=1;var e=Vv(),r=TO(),i=gu(),o=yu(),s=i(function(u,l){if(u==null)return[];var c=l.length;return c>1&&o(u,l[0],l[1])?l=[]:c>2&&o(l[0],l[1],l[2])&&(l=[l[0]]),r(u,e(l,1),[])});return am=s,am}var um,_E;function AO(){if(_E)return um;_E=1;var e=fN(),r=0;function i(o){var s=++r;return e(o)+s}return um=i,um}var lm,xE;function IO(){if(xE)return lm;xE=1;function e(r,i,o){for(var s=-1,u=r.length,l=i.length,c={};++s<u;){var d=s<l?i[s]:void 0;o(c,r[s],d)}return c}return lm=e,lm}var cm,SE;function jO(){if(SE)return cm;SE=1;var e=uu(),r=IO();function i(o,s){return r(o||[],s||[],e)}return cm=i,cm}var fm,EE;function Je(){if(EE)return fm;EE=1;var e;if(typeof Av=="function")try{e={cloneDeep:Kq(),constant:Fv(),defaults:Yq(),each:iN(),filter:mN(),find:nO(),flatten:jN(),forEach:rN(),forIn:rO(),has:vN(),isUndefined:gN(),last:iO(),map:wN(),mapValues:oO(),max:aO(),merge:hO(),min:pO(),minBy:mO(),now:vO(),pick:xO(),range:kO(),reduce:_N(),sortBy:RO(),uniqueId:AO(),values:bN(),zipObject:jO()}}catch{}return e||(e=window._),fm=e,fm}var dm,kE;function MO(){if(kE)return dm;kE=1,dm=e;function e(){var o={};o._next=o._prev=o,this._sentinel=o}e.prototype.dequeue=function(){var o=this._sentinel,s=o._prev;if(s!==o)return r(s),s},e.prototype.enqueue=function(o){var s=this._sentinel;o._prev&&o._next&&r(o),o._next=s._next,s._next._prev=o,s._next=o,o._prev=s},e.prototype.toString=function(){for(var o=[],s=this._sentinel,u=s._prev;u!==s;)o.push(JSON.stringify(u,i)),u=u._prev;return"["+o.join(", ")+"]"};function r(o){o._prev._next=o._next,o._next._prev=o._prev,delete o._next,delete o._prev}function i(o,s){if(o!=="_next"&&o!=="_prev")return s}return dm}var hm,bE;function PO(){if(bE)return hm;bE=1;var e=Je(),r=jn().Graph,i=MO();hm=s;var o=e.constant(1);function s(p,h){if(p.nodeCount()<=1)return[];var v=c(p,h||o),g=u(v.graph,v.buckets,v.zeroIdx);return e.flatten(e.map(g,function(w){return p.outEdges(w.v,w.w)}),!0)}function u(p,h,v){for(var g=[],w=h[h.length-1],N=h[0],_;p.nodeCount();){for(;_=N.dequeue();)l(p,h,v,_);for(;_=w.dequeue();)l(p,h,v,_);if(p.nodeCount()){for(var E=h.length-2;E>0;--E)if(_=h[E].dequeue(),_){g=g.concat(l(p,h,v,_,!0));break}}}return g}function l(p,h,v,g,w){var N=w?[]:void 0;return e.forEach(p.inEdges(g.v),function(_){var E=p.edge(_),x=p.node(_.v);w&&N.push({v:_.v,w:_.w}),x.out-=E,d(h,v,x)}),e.forEach(p.outEdges(g.v),function(_){var E=p.edge(_),x=_.w,k=p.node(x);k.in-=E,d(h,v,k)}),p.removeNode(g.v),N}function c(p,h){var v=new r,g=0,w=0;e.forEach(p.nodes(),function(E){v.setNode(E,{v:E,in:0,out:0})}),e.forEach(p.edges(),function(E){var x=v.edge(E.v,E.w)||0,k=h(E),T=x+k;v.setEdge(E.v,E.w,T),w=Math.max(w,v.node(E.v).out+=k),g=Math.max(g,v.node(E.w).in+=k)});var N=e.range(w+g+3).map(function(){return new i}),_=g+1;return e.forEach(v.nodes(),function(E){d(N,_,v.node(E))}),{graph:v,buckets:N,zeroIdx:_}}function d(p,h,v){v.out?v.in?p[v.out-v.in+h].enqueue(v):p[p.length-1].enqueue(v):p[0].enqueue(v)}return hm}var pm,NE;function qO(){if(NE)return pm;NE=1;var e=Je(),r=PO();pm={run:i,undo:s};function i(u){var l=u.graph().acyclicer==="greedy"?r(u,c(u)):o(u);e.forEach(l,function(d){var p=u.edge(d);u.removeEdge(d),p.forwardName=d.name,p.reversed=!0,u.setEdge(d.w,d.v,p,e.uniqueId("rev"))});function c(d){return function(p){return d.edge(p).weight}}}function o(u){var l=[],c={},d={};function p(h){e.has(d,h)||(d[h]=!0,c[h]=!0,e.forEach(u.outEdges(h),function(v){e.has(c,v.w)?l.push(v):p(v.w)}),delete c[h])}return e.forEach(u.nodes(),p),l}function s(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 pm}var mm,CE;function Yt(){if(CE)return mm;CE=1;var e=Je(),r=jn().Graph;mm={addDummyNode:i,simplify:o,asNonCompoundGraph:s,successorWeights:u,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:v,maxRank:g,partition:w,time:N,notime:_};function i(E,x,k,T){var C;do C=e.uniqueId(T);while(E.hasNode(C));return k.dummy=x,E.setNode(C,k),C}function o(E){var x=new r().setGraph(E.graph());return e.forEach(E.nodes(),function(k){x.setNode(k,E.node(k))}),e.forEach(E.edges(),function(k){var T=x.edge(k.v,k.w)||{weight:0,minlen:1},C=E.edge(k);x.setEdge(k.v,k.w,{weight:T.weight+C.weight,minlen:Math.max(T.minlen,C.minlen)})}),x}function s(E){var x=new r({multigraph:E.isMultigraph()}).setGraph(E.graph());return e.forEach(E.nodes(),function(k){E.children(k).length||x.setNode(k,E.node(k))}),e.forEach(E.edges(),function(k){x.setEdge(k,E.edge(k))}),x}function u(E){var x=e.map(E.nodes(),function(k){var T={};return e.forEach(E.outEdges(k),function(C){T[C.w]=(T[C.w]||0)+E.edge(C).weight}),T});return e.zipObject(E.nodes(),x)}function l(E){var x=e.map(E.nodes(),function(k){var T={};return e.forEach(E.inEdges(k),function(C){T[C.v]=(T[C.v]||0)+E.edge(C).weight}),T});return e.zipObject(E.nodes(),x)}function c(E,x){var k=E.x,T=E.y,C=x.x-k,A=x.y-T,j=E.width/2,M=E.height/2;if(!C&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var z,O;return Math.abs(A)*j>Math.abs(C)*M?(A<0&&(M=-M),z=M*C/A,O=M):(C<0&&(j=-j),z=j,O=j*A/C),{x:k+z,y:T+O}}function d(E){var x=e.map(e.range(g(E)+1),function(){return[]});return e.forEach(E.nodes(),function(k){var T=E.node(k),C=T.rank;e.isUndefined(C)||(x[C][T.order]=k)}),x}function p(E){var x=e.min(e.map(E.nodes(),function(k){return E.node(k).rank}));e.forEach(E.nodes(),function(k){var T=E.node(k);e.has(T,"rank")&&(T.rank-=x)})}function h(E){var x=e.min(e.map(E.nodes(),function(A){return E.node(A).rank})),k=[];e.forEach(E.nodes(),function(A){var j=E.node(A).rank-x;k[j]||(k[j]=[]),k[j].push(A)});var T=0,C=E.graph().nodeRankFactor;e.forEach(k,function(A,j){e.isUndefined(A)&&j%C!==0?--T:T&&e.forEach(A,function(M){E.node(M).rank+=T})})}function v(E,x,k,T){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=T),i(E,"border",C,x)}function g(E){return e.max(e.map(E.nodes(),function(x){var k=E.node(x).rank;if(!e.isUndefined(k))return k}))}function w(E,x){var k={lhs:[],rhs:[]};return e.forEach(E,function(T){x(T)?k.lhs.push(T):k.rhs.push(T)}),k}function N(E,x){var k=e.now();try{return x()}finally{console.log(E+" time: "+(e.now()-k)+"ms")}}function _(E,x){return x()}return mm}var vm,TE;function OO(){if(TE)return vm;TE=1;var e=Je(),r=Yt();vm={run:i,undo:s};function i(u){u.graph().dummyChains=[],e.forEach(u.edges(),function(l){o(u,l)})}function o(u,l){var c=l.v,d=u.node(c).rank,p=l.w,h=u.node(p).rank,v=l.name,g=u.edge(l),w=g.labelRank;if(h!==d+1){u.removeEdge(l);var N,_,E;for(E=0,++d;d<h;++E,++d)g.points=[],_={width:0,height:0,edgeLabel:g,edgeObj:l,rank:d},N=r.addDummyNode(u,"edge",_,"_d"),d===w&&(_.width=g.width,_.height=g.height,_.dummy="edge-label",_.labelpos=g.labelpos),u.setEdge(c,N,{weight:g.weight},v),E===0&&u.graph().dummyChains.push(N),c=N;u.setEdge(c,p,{weight:g.weight},v)}}function s(u){e.forEach(u.graph().dummyChains,function(l){var c=u.node(l),d=c.edgeLabel,p;for(u.setEdge(c.edgeObj,d);c.dummy;)p=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=p,c=u.node(l)})}return vm}var gm,RE;function Ga(){if(RE)return gm;RE=1;var e=Je();gm={longestPath:r,slack:i};function r(o){var s={};function u(l){var c=o.node(l);if(e.has(s,l))return c.rank;s[l]=!0;var d=e.min(e.map(o.outEdges(l),function(p){return u(p.w)-o.edge(p).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(o.sources(),u)}function i(o,s){return o.node(s.w).rank-o.node(s.v).rank-o.edge(s).minlen}return gm}var ym,AE;function ON(){if(AE)return ym;AE=1;var e=Je(),r=jn().Graph,i=Ga().slack;ym=o;function o(c){var d=new r({directed:!1}),p=c.nodes()[0],h=c.nodeCount();d.setNode(p,{});for(var v,g;s(d,c)<h;)v=u(d,c),g=d.hasNode(v.v)?i(c,v):-i(c,v),l(d,c,g);return d}function s(c,d){function p(h){e.forEach(d.nodeEdges(h),function(v){var g=v.v,w=h===g?v.w:g;!c.hasNode(w)&&!i(d,v)&&(c.setNode(w,{}),c.setEdge(h,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function u(c,d){return e.minBy(d.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return i(d,p)})}function l(c,d,p){e.forEach(c.nodes(),function(h){d.node(h).rank+=p})}return ym}var wm,IE;function LO(){if(IE)return wm;IE=1;var e=Je(),r=ON(),i=Ga().slack,o=Ga().longestPath,s=jn().alg.preorder,u=jn().alg.postorder,l=Yt().simplify;wm=c,c.initLowLimValues=v,c.initCutValues=d,c.calcCutValue=h,c.leaveEdge=w,c.enterEdge=N,c.exchangeEdges=_;function c(T){T=l(T),o(T);var C=r(T);v(C),d(C,T);for(var A,j;A=w(C);)j=N(C,T,A),_(C,T,A,j)}function d(T,C){var A=u(T,T.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(j){p(T,C,j)})}function p(T,C,A){var j=T.node(A),M=j.parent;T.edge(A,M).cutvalue=h(T,C,A)}function h(T,C,A){var j=T.node(A),M=j.parent,z=!0,O=C.edge(A,M),B=0;return O||(z=!1,O=C.edge(M,A)),B=O.weight,e.forEach(C.nodeEdges(A),function(U){var ee=U.v===A,X=ee?U.w:U.v;if(X!==M){var R=ee===z,G=C.edge(U).weight;if(B+=R?G:-G,x(T,A,X)){var H=T.edge(A,X).cutvalue;B+=R?-H:H}}}),B}function v(T,C){arguments.length<2&&(C=T.nodes()[0]),g(T,{},1,C)}function g(T,C,A,j,M){var z=A,O=T.node(j);return C[j]=!0,e.forEach(T.neighbors(j),function(B){e.has(C,B)||(A=g(T,C,A,B,j))}),O.low=z,O.lim=A++,M?O.parent=M:delete O.parent,A}function w(T){return e.find(T.edges(),function(C){return T.edge(C).cutvalue<0})}function N(T,C,A){var j=A.v,M=A.w;C.hasEdge(j,M)||(j=A.w,M=A.v);var z=T.node(j),O=T.node(M),B=z,U=!1;z.lim>O.lim&&(B=O,U=!0);var ee=e.filter(C.edges(),function(X){return U===k(T,T.node(X.v),B)&&U!==k(T,T.node(X.w),B)});return e.minBy(ee,function(X){return i(C,X)})}function _(T,C,A,j){var M=A.v,z=A.w;T.removeEdge(M,z),T.setEdge(j.v,j.w,{}),v(T),d(T,C),E(T,C)}function E(T,C){var A=e.find(T.nodes(),function(M){return!C.node(M).parent}),j=s(T,A);j=j.slice(1),e.forEach(j,function(M){var z=T.node(M).parent,O=C.edge(M,z),B=!1;O||(O=C.edge(z,M),B=!0),C.node(M).rank=C.node(z).rank+(B?O.minlen:-O.minlen)})}function x(T,C,A){return T.hasEdge(C,A)}function k(T,C,A){return A.low<=C.lim&&C.lim<=A.lim}return wm}var _m,jE;function $O(){if(jE)return _m;jE=1;var e=Ga(),r=e.longestPath,i=ON(),o=LO();_m=s;function s(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=r;function l(d){r(d),i(d)}function c(d){o(d)}return _m}var xm,ME;function DO(){if(ME)return xm;ME=1;var e=Je();xm=r;function r(s){var u=o(s);e.forEach(s.graph().dummyChains,function(l){for(var c=s.node(l),d=c.edgeObj,p=i(s,u,d.v,d.w),h=p.path,v=p.lca,g=0,w=h[g],N=!0;l!==d.w;){if(c=s.node(l),N){for(;(w=h[g])!==v&&s.node(w).maxRank<c.rank;)g++;w===v&&(N=!1)}if(!N){for(;g<h.length-1&&s.node(w=h[g+1]).minRank<=c.rank;)g++;w=h[g]}s.setParent(l,w),l=s.successors(l)[0]}})}function i(s,u,l,c){var d=[],p=[],h=Math.min(u[l].low,u[c].low),v=Math.max(u[l].lim,u[c].lim),g,w;g=l;do g=s.parent(g),d.push(g);while(g&&(u[g].low>h||v>u[g].lim));for(w=g,g=c;(g=s.parent(g))!==w;)p.push(g);return{path:d.concat(p.reverse()),lca:w}}function o(s){var u={},l=0;function c(d){var p=l;e.forEach(s.children(d),c),u[d]={low:p,lim:l++}}return e.forEach(s.children(),c),u}return xm}var Sm,PE;function FO(){if(PE)return Sm;PE=1;var e=Je(),r=Yt();Sm={run:i,cleanup:l};function i(c){var d=r.addDummyNode(c,"root",{},"_root"),p=s(c),h=e.max(e.values(p))-1,v=2*h+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(w){c.edge(w).minlen*=v});var g=u(c)+1;e.forEach(c.children(),function(w){o(c,d,v,g,h,p,w)}),c.graph().nodeRankFactor=v}function o(c,d,p,h,v,g,w){var N=c.children(w);if(!N.length){w!==d&&c.setEdge(d,w,{weight:0,minlen:p});return}var _=r.addBorderNode(c,"_bt"),E=r.addBorderNode(c,"_bb"),x=c.node(w);c.setParent(_,w),x.borderTop=_,c.setParent(E,w),x.borderBottom=E,e.forEach(N,function(k){o(c,d,p,h,v,g,k);var T=c.node(k),C=T.borderTop?T.borderTop:k,A=T.borderBottom?T.borderBottom:k,j=T.borderTop?h:2*h,M=C!==A?1:v-g[w]+1;c.setEdge(_,C,{weight:j,minlen:M,nestingEdge:!0}),c.setEdge(A,E,{weight:j,minlen:M,nestingEdge:!0})}),c.parent(w)||c.setEdge(d,_,{weight:0,minlen:v+g[w]})}function s(c){var d={};function p(h,v){var g=c.children(h);g&&g.length&&e.forEach(g,function(w){p(w,v+1)}),d[h]=v}return e.forEach(c.children(),function(h){p(h,1)}),d}function u(c){return e.reduce(c.edges(),function(d,p){return d+c.edge(p).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(p){var h=c.edge(p);h.nestingEdge&&c.removeEdge(p)})}return Sm}var Em,qE;function zO(){if(qE)return Em;qE=1;var e=Je(),r=Yt();Em=i;function i(s){function u(l){var c=s.children(l),d=s.node(l);if(c.length&&e.forEach(c,u),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var p=d.minRank,h=d.maxRank+1;p<h;++p)o(s,"borderLeft","_bl",l,d,p),o(s,"borderRight","_br",l,d,p)}}e.forEach(s.children(),u)}function o(s,u,l,c,d,p){var h={width:0,height:0,rank:p,borderType:u},v=d[u][p-1],g=r.addDummyNode(s,"border",h,l);d[u][p]=g,s.setParent(g,c),v&&s.setEdge(v,g,{weight:1})}return Em}var km,OE;function BO(){if(OE)return km;OE=1;var e=Je();km={adjust:r,undo:i};function r(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&o(p)}function i(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&u(p),(h==="lr"||h==="rl")&&(c(p),o(p))}function o(p){e.forEach(p.nodes(),function(h){s(p.node(h))}),e.forEach(p.edges(),function(h){s(p.edge(h))})}function s(p){var h=p.width;p.width=p.height,p.height=h}function u(p){e.forEach(p.nodes(),function(h){l(p.node(h))}),e.forEach(p.edges(),function(h){var v=p.edge(h);e.forEach(v.points,l),e.has(v,"y")&&l(v)})}function l(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(h){d(p.node(h))}),e.forEach(p.edges(),function(h){var v=p.edge(h);e.forEach(v.points,d),e.has(v,"x")&&d(v)})}function d(p){var h=p.x;p.x=p.y,p.y=h}return km}var bm,LE;function UO(){if(LE)return bm;LE=1;var e=Je();bm=r;function r(i){var o={},s=e.filter(i.nodes(),function(p){return!i.children(p).length}),u=e.max(e.map(s,function(p){return i.node(p).rank})),l=e.map(e.range(u+1),function(){return[]});function c(p){if(!e.has(o,p)){o[p]=!0;var h=i.node(p);l[h.rank].push(p),e.forEach(i.successors(p),c)}}var d=e.sortBy(s,function(p){return i.node(p).rank});return e.forEach(d,c),l}return bm}var Nm,$E;function HO(){if($E)return Nm;$E=1;var e=Je();Nm=r;function r(o,s){for(var u=0,l=1;l<s.length;++l)u+=i(o,s[l-1],s[l]);return u}function i(o,s,u){for(var l=e.zipObject(u,e.map(u,function(g,w){return w})),c=e.flatten(e.map(s,function(g){return e.sortBy(e.map(o.outEdges(g),function(w){return{pos:l[w.w],weight:o.edge(w).weight}}),"pos")}),!0),d=1;d<u.length;)d<<=1;var p=2*d-1;d-=1;var h=e.map(new Array(p),function(){return 0}),v=0;return e.forEach(c.forEach(function(g){var w=g.pos+d;h[w]+=g.weight;for(var N=0;w>0;)w%2&&(N+=h[w+1]),w=w-1>>1,h[w]+=g.weight;v+=g.weight*N})),v}return Nm}var Cm,DE;function VO(){if(DE)return Cm;DE=1;var e=Je();Cm=r;function r(i,o){return e.map(o,function(s){var u=i.inEdges(s);if(u.length){var l=e.reduce(u,function(c,d){var p=i.edge(d),h=i.node(d.v);return{sum:c.sum+p.weight*h.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:s,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:s}})}return Cm}var Tm,FE;function WO(){if(FE)return Tm;FE=1;var e=Je();Tm=r;function r(s,u){var l={};e.forEach(s,function(d,p){var h=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:p};e.isUndefined(d.barycenter)||(h.barycenter=d.barycenter,h.weight=d.weight)}),e.forEach(u.edges(),function(d){var p=l[d.v],h=l[d.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(l[d.w]))});var c=e.filter(l,function(d){return!d.indegree});return i(c)}function i(s){var u=[];function l(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&o(p,h)}}function c(p){return function(h){h.in.push(p),--h.indegree===0&&s.push(h)}}for(;s.length;){var d=s.pop();u.push(d),e.forEach(d.in.reverse(),l(d)),e.forEach(d.out,c(d))}return e.map(e.filter(u,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function o(s,u){var l=0,c=0;s.weight&&(l+=s.barycenter*s.weight,c+=s.weight),u.weight&&(l+=u.barycenter*u.weight,c+=u.weight),s.vs=u.vs.concat(s.vs),s.barycenter=l/c,s.weight=c,s.i=Math.min(u.i,s.i),u.merged=!0}return Tm}var Rm,zE;function GO(){if(zE)return Rm;zE=1;var e=Je(),r=Yt();Rm=i;function i(u,l){var c=r.partition(u,function(_){return e.has(_,"barycenter")}),d=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),h=[],v=0,g=0,w=0;d.sort(s(!!l)),w=o(h,p,w),e.forEach(d,function(_){w+=_.vs.length,h.push(_.vs),v+=_.barycenter*_.weight,g+=_.weight,w=o(h,p,w)});var N={vs:e.flatten(h,!0)};return g&&(N.barycenter=v/g,N.weight=g),N}function o(u,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),u.push(d.vs),c++;return c}function s(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 Rm}var Am,BE;function KO(){if(BE)return Am;BE=1;var e=Je(),r=VO(),i=WO(),o=GO();Am=s;function s(c,d,p,h){var v=c.children(d),g=c.node(d),w=g?g.borderLeft:void 0,N=g?g.borderRight:void 0,_={};w&&(v=e.filter(v,function(A){return A!==w&&A!==N}));var E=r(c,v);e.forEach(E,function(A){if(c.children(A.v).length){var j=s(c,A.v,p,h);_[A.v]=j,e.has(j,"barycenter")&&l(A,j)}});var x=i(E,p);u(x,_);var k=o(x,h);if(w&&(k.vs=e.flatten([w,k.vs,N],!0),c.predecessors(w).length)){var T=c.node(c.predecessors(w)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+T.order+C.order)/(k.weight+2),k.weight+=2}return k}function u(c,d){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(h){return d[h]?d[h].vs:h}),!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 Am}var Im,UE;function YO(){if(UE)return Im;UE=1;var e=Je(),r=jn().Graph;Im=i;function i(s,u,l){var c=o(s),d=new r({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return s.node(p)});return e.forEach(s.nodes(),function(p){var h=s.node(p),v=s.parent(p);(h.rank===u||h.minRank<=u&&u<=h.maxRank)&&(d.setNode(p),d.setParent(p,v||c),e.forEach(s[l](p),function(g){var w=g.v===p?g.w:g.v,N=d.edge(w,p),_=e.isUndefined(N)?0:N.weight;d.setEdge(w,p,{weight:s.edge(g).weight+_})}),e.has(h,"minRank")&&d.setNode(p,{borderLeft:h.borderLeft[u],borderRight:h.borderRight[u]}))}),d}function o(s){for(var u;s.hasNode(u=e.uniqueId("_root")););return u}return Im}var jm,HE;function XO(){if(HE)return jm;HE=1;var e=Je();jm=r;function r(i,o,s){var u={},l;e.forEach(s,function(c){for(var d=i.parent(c),p,h;d;){if(p=i.parent(d),p?(h=u[p],u[p]=d):(h=l,l=d),h&&h!==d){o.setEdge(h,d);return}d=p}})}return jm}var Mm,VE;function QO(){if(VE)return Mm;VE=1;var e=Je(),r=UO(),i=HO(),o=KO(),s=YO(),u=XO(),l=jn().Graph,c=Yt();Mm=d;function d(g){var w=c.maxRank(g),N=p(g,e.range(1,w+1),"inEdges"),_=p(g,e.range(w-1,-1,-1),"outEdges"),E=r(g);v(g,E);for(var x=Number.POSITIVE_INFINITY,k,T=0,C=0;C<4;++T,++C){h(T%2?N:_,T%4>=2),E=c.buildLayerMatrix(g);var A=i(g,E);A<x&&(C=0,k=e.cloneDeep(E),x=A)}v(g,k)}function p(g,w,N){return e.map(w,function(_){return s(g,_,N)})}function h(g,w){var N=new l;e.forEach(g,function(_){var E=_.graph().root,x=o(_,E,N,w);e.forEach(x.vs,function(k,T){_.node(k).order=T}),u(_,N,x.vs)})}function v(g,w){e.forEach(w,function(N){e.forEach(N,function(_,E){g.node(_).order=E})})}return Mm}var Pm,WE;function ZO(){if(WE)return Pm;WE=1;var e=Je(),r=jn().Graph,i=Yt();Pm={positionX:N,findType1Conflicts:o,findType2Conflicts:s,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:p,alignCoordinates:g,findSmallestWidthAlignment:v,balance:w};function o(x,k){var T={};function C(A,j){var M=0,z=0,O=A.length,B=e.last(j);return e.forEach(j,function(U,ee){var X=u(x,U),R=X?x.node(X).order:O;(X||U===B)&&(e.forEach(j.slice(z,ee+1),function(G){e.forEach(x.predecessors(G),function(H){var ne=x.node(H),Y=ne.order;(Y<M||R<Y)&&!(ne.dummy&&x.node(G).dummy)&&l(T,H,G)})}),z=ee+1,M=R)}),j}return e.reduce(k,C),T}function s(x,k){var T={};function C(j,M,z,O,B){var U;e.forEach(e.range(M,z),function(ee){U=j[ee],x.node(U).dummy&&e.forEach(x.predecessors(U),function(X){var R=x.node(X);R.dummy&&(R.order<O||R.order>B)&&l(T,X,U)})})}function A(j,M){var z=-1,O,B=0;return e.forEach(M,function(U,ee){if(x.node(U).dummy==="border"){var X=x.predecessors(U);X.length&&(O=x.node(X[0]).order,C(M,B,ee,z,O),B=ee,z=O)}C(M,B,M.length,O,j.length)}),M}return e.reduce(k,A),T}function u(x,k){if(x.node(k).dummy)return e.find(x.predecessors(k),function(T){return x.node(T).dummy})}function l(x,k,T){if(k>T){var C=k;k=T,T=C}var A=x[k];A||(x[k]=A={}),A[T]=!0}function c(x,k,T){if(k>T){var C=k;k=T,T=C}return e.has(x[k],T)}function d(x,k,T,C){var A={},j={},M={};return e.forEach(k,function(z){e.forEach(z,function(O,B){A[O]=O,j[O]=O,M[O]=B})}),e.forEach(k,function(z){var O=-1;e.forEach(z,function(B){var U=C(B);if(U.length){U=e.sortBy(U,function(H){return M[H]});for(var ee=(U.length-1)/2,X=Math.floor(ee),R=Math.ceil(ee);X<=R;++X){var G=U[X];j[B]===B&&O<M[G]&&!c(T,B,G)&&(j[G]=B,j[B]=A[B]=A[G],O=M[G])}}})}),{root:A,align:j}}function p(x,k,T,C,A){var j={},M=h(x,k,T,A),z=A?"borderLeft":"borderRight";function O(ee,X){for(var R=M.nodes(),G=R.pop(),H={};G;)H[G]?ee(G):(H[G]=!0,R.push(G),R=R.concat(X(G))),G=R.pop()}function B(ee){j[ee]=M.inEdges(ee).reduce(function(X,R){return Math.max(X,j[R.v]+M.edge(R))},0)}function U(ee){var X=M.outEdges(ee).reduce(function(G,H){return Math.min(G,j[H.w]-M.edge(H))},Number.POSITIVE_INFINITY),R=x.node(ee);X!==Number.POSITIVE_INFINITY&&R.borderType!==z&&(j[ee]=Math.max(j[ee],X))}return O(B,M.predecessors.bind(M)),O(U,M.successors.bind(M)),e.forEach(C,function(ee){j[ee]=j[T[ee]]}),j}function h(x,k,T,C){var A=new r,j=x.graph(),M=_(j.nodesep,j.edgesep,C);return e.forEach(k,function(z){var O;e.forEach(z,function(B){var U=T[B];if(A.setNode(U),O){var ee=T[O],X=A.edge(ee,U);A.setEdge(ee,U,Math.max(M(x,B,O),X||0))}O=B})}),A}function v(x,k){return e.minBy(e.values(k),function(T){var C=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(T,function(j,M){var z=E(x,M)/2;C=Math.max(j+z,C),A=Math.min(j-z,A)}),C-A})}function g(x,k){var T=e.values(k),C=e.min(T),A=e.max(T);e.forEach(["u","d"],function(j){e.forEach(["l","r"],function(M){var z=j+M,O=x[z],B;if(O!==k){var U=e.values(O);B=M==="l"?C-e.min(U):A-e.max(U),B&&(x[z]=e.mapValues(O,function(ee){return ee+B}))}})})}function w(x,k){return e.mapValues(x.ul,function(T,C){if(k)return x[k.toLowerCase()][C];var A=e.sortBy(e.map(x,C));return(A[1]+A[2])/2})}function N(x){var k=i.buildLayerMatrix(x),T=e.merge(o(x,k),s(x,k)),C={},A;e.forEach(["u","d"],function(M){A=M==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(z){z==="r"&&(A=e.map(A,function(ee){return e.values(ee).reverse()}));var O=(M==="u"?x.predecessors:x.successors).bind(x),B=d(x,A,T,O),U=p(x,A,B.root,B.align,z==="r");z==="r"&&(U=e.mapValues(U,function(ee){return-ee})),C[M+z]=U})});var j=v(x,C);return g(C,j),w(C,x.graph().align)}function _(x,k,T){return function(C,A,j){var M=C.node(A),z=C.node(j),O=0,B;if(O+=M.width/2,e.has(M,"labelpos"))switch(M.labelpos.toLowerCase()){case"l":B=-M.width/2;break;case"r":B=M.width/2;break}if(B&&(O+=T?B:-B),B=0,O+=(M.dummy?k:x)/2,O+=(z.dummy?k:x)/2,O+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":B=z.width/2;break;case"r":B=-z.width/2;break}return B&&(O+=T?B:-B),B=0,O}}function E(x,k){return x.node(k).width}return Pm}var qm,GE;function JO(){if(GE)return qm;GE=1;var e=Je(),r=Yt(),i=ZO().positionX;qm=o;function o(u){u=r.asNonCompoundGraph(u),s(u),e.forEach(i(u),function(l,c){u.node(c).x=l})}function s(u){var l=r.buildLayerMatrix(u),c=u.graph().ranksep,d=0;e.forEach(l,function(p){var h=e.max(e.map(p,function(v){return u.node(v).height}));e.forEach(p,function(v){u.node(v).y=d+h/2}),d+=h+c})}return qm}var Om,KE;function eL(){if(KE)return Om;KE=1;var e=Je(),r=qO(),i=OO(),o=$O(),s=Yt().normalizeRanks,u=DO(),l=Yt().removeEmptyRanks,c=FO(),d=zO(),p=BO(),h=QO(),v=JO(),g=Yt(),w=jn().Graph;Om=N;function N(q,V){var Q=V&&V.debugTiming?g.time:g.notime;Q("layout",function(){var re=Q(" buildLayoutGraph",function(){return O(q)});Q(" runLayout",function(){_(re,Q)}),Q(" updateInputGraph",function(){E(q,re)})})}function _(q,V){V(" makeSpaceForEdgeLabels",function(){B(q)}),V(" removeSelfEdges",function(){L(q)}),V(" acyclic",function(){r.run(q)}),V(" nestingGraph.run",function(){c.run(q)}),V(" rank",function(){o(g.asNonCompoundGraph(q))}),V(" injectEdgeLabelProxies",function(){U(q)}),V(" removeEmptyRanks",function(){l(q)}),V(" nestingGraph.cleanup",function(){c.cleanup(q)}),V(" normalizeRanks",function(){s(q)}),V(" assignRankMinMax",function(){ee(q)}),V(" removeEdgeLabelProxies",function(){X(q)}),V(" normalize.run",function(){i.run(q)}),V(" parentDummyChains",function(){u(q)}),V(" addBorderSegments",function(){d(q)}),V(" order",function(){h(q)}),V(" insertSelfEdges",function(){K(q)}),V(" adjustCoordinateSystem",function(){p.adjust(q)}),V(" position",function(){v(q)}),V(" positionSelfEdges",function(){I(q)}),V(" removeBorderNodes",function(){Y(q)}),V(" normalize.undo",function(){i.undo(q)}),V(" fixupEdgeLabelCoords",function(){H(q)}),V(" undoCoordinateSystem",function(){p.undo(q)}),V(" translateGraph",function(){R(q)}),V(" assignNodeIntersects",function(){G(q)}),V(" reversePoints",function(){ne(q)}),V(" acyclic.undo",function(){r.undo(q)})}function E(q,V){e.forEach(q.nodes(),function(Q){var re=q.node(Q),ce=V.node(Q);re&&(re.x=ce.x,re.y=ce.y,V.children(Q).length&&(re.width=ce.width,re.height=ce.height))}),e.forEach(q.edges(),function(Q){var re=q.edge(Q),ce=V.edge(Q);re.points=ce.points,e.has(ce,"x")&&(re.x=ce.x,re.y=ce.y)}),q.graph().width=V.graph().width,q.graph().height=V.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},T=["acyclicer","ranker","rankdir","align"],C=["width","height"],A={width:0,height:0},j=["minlen","weight","width","height","labeloffset"],M={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function O(q){var V=new w({multigraph:!0,compound:!0}),Q=ae(q.graph());return V.setGraph(e.merge({},k,F(Q,x),e.pick(Q,T))),e.forEach(q.nodes(),function(re){var ce=ae(q.node(re));V.setNode(re,e.defaults(F(ce,C),A)),V.setParent(re,q.parent(re))}),e.forEach(q.edges(),function(re){var ce=ae(q.edge(re));V.setEdge(re,e.merge({},M,F(ce,j),e.pick(ce,z)))}),V}function B(q){var V=q.graph();V.ranksep/=2,e.forEach(q.edges(),function(Q){var re=q.edge(Q);re.minlen*=2,re.labelpos.toLowerCase()!=="c"&&(V.rankdir==="TB"||V.rankdir==="BT"?re.width+=re.labeloffset:re.height+=re.labeloffset)})}function U(q){e.forEach(q.edges(),function(V){var Q=q.edge(V);if(Q.width&&Q.height){var re=q.node(V.v),ce=q.node(V.w),he={rank:(ce.rank-re.rank)/2+re.rank,e:V};g.addDummyNode(q,"edge-proxy",he,"_ep")}})}function ee(q){var V=0;e.forEach(q.nodes(),function(Q){var re=q.node(Q);re.borderTop&&(re.minRank=q.node(re.borderTop).rank,re.maxRank=q.node(re.borderBottom).rank,V=e.max(V,re.maxRank))}),q.graph().maxRank=V}function X(q){e.forEach(q.nodes(),function(V){var Q=q.node(V);Q.dummy==="edge-proxy"&&(q.edge(Q.e).labelRank=Q.rank,q.removeNode(V))})}function R(q){var V=Number.POSITIVE_INFINITY,Q=0,re=Number.POSITIVE_INFINITY,ce=0,he=q.graph(),pe=he.marginx||0,je=he.marginy||0;function $e(Me){var Ae=Me.x,we=Me.y,Be=Me.width,ve=Me.height;V=Math.min(V,Ae-Be/2),Q=Math.max(Q,Ae+Be/2),re=Math.min(re,we-ve/2),ce=Math.max(ce,we+ve/2)}e.forEach(q.nodes(),function(Me){$e(q.node(Me))}),e.forEach(q.edges(),function(Me){var Ae=q.edge(Me);e.has(Ae,"x")&&$e(Ae)}),V-=pe,re-=je,e.forEach(q.nodes(),function(Me){var Ae=q.node(Me);Ae.x-=V,Ae.y-=re}),e.forEach(q.edges(),function(Me){var Ae=q.edge(Me);e.forEach(Ae.points,function(we){we.x-=V,we.y-=re}),e.has(Ae,"x")&&(Ae.x-=V),e.has(Ae,"y")&&(Ae.y-=re)}),he.width=Q-V+pe,he.height=ce-re+je}function G(q){e.forEach(q.edges(),function(V){var Q=q.edge(V),re=q.node(V.v),ce=q.node(V.w),he,pe;Q.points?(he=Q.points[0],pe=Q.points[Q.points.length-1]):(Q.points=[],he=ce,pe=re),Q.points.unshift(g.intersectRect(re,he)),Q.points.push(g.intersectRect(ce,pe))})}function H(q){e.forEach(q.edges(),function(V){var Q=q.edge(V);if(e.has(Q,"x"))switch((Q.labelpos==="l"||Q.labelpos==="r")&&(Q.width-=Q.labeloffset),Q.labelpos){case"l":Q.x-=Q.width/2+Q.labeloffset;break;case"r":Q.x+=Q.width/2+Q.labeloffset;break}})}function ne(q){e.forEach(q.edges(),function(V){var Q=q.edge(V);Q.reversed&&Q.points.reverse()})}function Y(q){e.forEach(q.nodes(),function(V){if(q.children(V).length){var Q=q.node(V),re=q.node(Q.borderTop),ce=q.node(Q.borderBottom),he=q.node(e.last(Q.borderLeft)),pe=q.node(e.last(Q.borderRight));Q.width=Math.abs(pe.x-he.x),Q.height=Math.abs(ce.y-re.y),Q.x=he.x+Q.width/2,Q.y=re.y+Q.height/2}}),e.forEach(q.nodes(),function(V){q.node(V).dummy==="border"&&q.removeNode(V)})}function L(q){e.forEach(q.edges(),function(V){if(V.v===V.w){var Q=q.node(V.v);Q.selfEdges||(Q.selfEdges=[]),Q.selfEdges.push({e:V,label:q.edge(V)}),q.removeEdge(V)}})}function K(q){var V=g.buildLayerMatrix(q);e.forEach(V,function(Q){var re=0;e.forEach(Q,function(ce,he){var pe=q.node(ce);pe.order=he+re,e.forEach(pe.selfEdges,function(je){g.addDummyNode(q,"selfedge",{width:je.label.width,height:je.label.height,rank:pe.rank,order:he+ ++re,e:je.e,label:je.label},"_se")}),delete pe.selfEdges})})}function I(q){e.forEach(q.nodes(),function(V){var Q=q.node(V);if(Q.dummy==="selfedge"){var re=q.node(Q.e.v),ce=re.x+re.width/2,he=re.y,pe=Q.x-ce,je=re.height/2;q.setEdge(Q.e,Q.label),q.removeNode(V),Q.label.points=[{x:ce+2*pe/3,y:he-je},{x:ce+5*pe/6,y:he-je},{x:ce+pe,y:he},{x:ce+5*pe/6,y:he+je},{x:ce+2*pe/3,y:he+je}],Q.label.x=Q.x,Q.label.y=Q.y}})}function F(q,V){return e.mapValues(e.pick(q,V),Number)}function ae(q){var V={};return e.forEach(q,function(Q,re){V[re.toLowerCase()]=Q}),V}return Om}var Lm,YE;function tL(){if(YE)return Lm;YE=1;var e=Je(),r=Yt(),i=jn().Graph;Lm={debugOrdering:o};function o(s){var u=r.buildLayerMatrix(s),l=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(c){l.setNode(c,{label:c}),l.setParent(c,"layer"+s.node(c).rank)}),e.forEach(s.edges(),function(c){l.setEdge(c.v,c.w,{},c.name)}),e.forEach(u,function(c,d){var p="layer"+d;l.setNode(p,{rank:"same"}),e.reduce(c,function(h,v){return l.setEdge(h,v,{style:"invis"}),v})}),l}return Lm}var $m,XE;function nL(){return XE||(XE=1,$m="0.8.5"),$m}var Dm,QE;function rL(){return QE||(QE=1,Dm={graphlib:jn(),layout:eL(),debug:tL(),util:{time:Yt().time,notime:Yt().notime},version:nL()}),Dm}var iL=rL();const ZE=lv(iL),JE=240,ek=130,oL=110;function sL(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function aL(e,r,i,o){const s=new ZE.graphlib.Graph;s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=new Set(e);for(const w of e){const N=o.get(w);s.setNode(w,{width:(N==null?void 0:N.width)??JE,height:(N==null?void 0:N.height)??ek})}for(const w of r)u.has(w.source)&&u.has(w.target)&&s.setEdge(w.source,w.target);ZE.layout(s);const l=new Map;let c=1/0,d=1/0,p=-1/0,h=-1/0;for(const w of e){const N=s.node(w);if(!N)continue;const _=o.get(w),E=(_==null?void 0:_.width)??JE,x=(_==null?void 0:_.height)??ek,k=N.x-E/2,T=N.y-x/2;l.set(w,{x:k,y:T}),k<c&&(c=k),T<d&&(d=T),k+E>p&&(p=k+E),T+x>h&&(h=T+x)}if(Number.isFinite(c)&&Number.isFinite(d))for(const[w,N]of l)l.set(w,{x:N.x-c,y:N.y-d});const v=Number.isFinite(p)?p-c:0,g=Number.isFinite(h)?h-d:0;return{positions:l,width:v,height:g}}function tk(e,r,i={}){const o=i.direction??"LR",s=i.pinned??new Map,u=i.measured??new Map,l=new Map;for(const h of e){const v=sL(h),g=l.get(v);g?g.push(h.id):l.set(v,[h.id])}const c=Array.from(l.keys()).sort(),d=new Map;let p=0;for(const h of c){const v=l.get(h),{positions:g,height:w}=aL(v,r,o,u);for(const[N,_]of g)d.set(N,{x:_.x,y:_.y+p});p+=w+oL}return e.map(h=>{const v=s.get(h.id);if(v)return{...h,position:v};const g=d.get(h.id);return g?{...h,position:g}:h})}const uL=600;function sv(e,r){return!(e.exitAt!=null&&r-e.exitAt>uL||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function lL(e,r){const i=new Set;for(const o of e.agents.values())sv(o,r)&&i.add(o.id);return i}function Vr(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function cL(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const fL={agent:YM},dL=9e4,hL=200,pL=5*6e4,Kv="agent-dag.layout",Yv="agent-dag.viewport",LN="agent-dag.summariesDismissed",$N="agent-dag.sessionListOpen",DN="agent-dag.timelineOpen";function mL(){if(typeof window>"u")return!0;try{return window.localStorage.getItem($N)!=="0"}catch{return!0}}function vL(e){if(!(typeof window>"u"))try{window.localStorage.setItem($N,e?"1":"0")}catch{}}function gL(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(DN)!=="0"}catch{return!0}}function yL(e){if(!(typeof window>"u"))try{window.localStorage.setItem(DN,e?"1":"0")}catch{}}function wL(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(LN);if(!e)return new Set;const r=JSON.parse(e);return new Set(Array.isArray(r)?r.filter(i=>typeof i=="string"):[])}catch{return new Set}}function nk(e){if(!(typeof window>"u"))try{const r=Array.from(e),i=r.length>200?r.slice(-200):r;window.localStorage.setItem(LN,JSON.stringify(i))}catch{}}function _L(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Kv);if(!e)return[];const r=JSON.parse(e);return Object.entries(r).filter(([,i])=>i&&typeof i.x=="number"&&typeof i.y=="number")}catch{return[]}}function xL(e){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;window.localStorage.setItem(Kv,JSON.stringify(r))}catch{}}function SL(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Yv);if(!e)return null;const r=JSON.parse(e);return typeof(r==null?void 0:r.x)!="number"||typeof(r==null?void 0:r.y)!="number"||typeof(r==null?void 0:r.zoom)!="number"?null:r}catch{return null}}function EL(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Yv,JSON.stringify(e))}catch{}}function rk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Kv)}catch{}try{window.localStorage.removeItem(Yv)}catch{}}}function kL(e,r){const i=e.agents.get(r);if(!i)return;const o=[];for(const h of e.agents.values())h.sessionId===r&&o.push(h);const s={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:r,label:i.label,cwd:i.cwd,startedAt:i.startedAt,endedAt:i.endedAt,model:i.model,agents:o.map(h=>({id:h.id,kind:h.kind,label:h.label,parentId:h.parentId,state:h.state,startedAt:h.startedAt,endedAt:h.endedAt,model:h.model,cwd:h.cwd,usage:h.usage,prompts:h.prompts,tools:h.tools.map(v=>({id:v.id,name:v.name,inputPreview:v.inputPreview,startedAt:v.startedAt,endedAt:v.endedAt,ok:v.ok,errorPreview:v.errorPreview,usage:v.usage}))}))},u=JSON.stringify(s,null,2),l=new Blob([u],{type:"application/json"}),c=URL.createObjectURL(l),d=document.createElement("a"),p=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");d.href=c,d.download=`agent-dag-${p}-${r.slice(0,8)}.json`,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const av={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},uv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},bL={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",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 FN(e){return e.startsWith("mcp__")?"mcp":bL[e]??"other"}function zN(e,r){var o,s,u;if(!r)return!0;const i=r.toLowerCase();if(e.label.toLowerCase().includes(i)||(o=e.cwd)!=null&&o.toLowerCase().includes(i)||(s=e.cwdBasename)!=null&&s.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 NL(e,r){if(!r)return null;const i=new Set([r]);let o=r;for(;o;){const u=e.agents.get(o);if(!(u!=null&&u.parentId)||i.has(u.parentId))break;i.add(u.parentId),o=u.parentId}let s=!0;for(;s;){s=!1;for(const u of e.agents.values())u.parentId&&i.has(u.parentId)&&!i.has(u.id)&&(i.add(u.id),s=!0)}return i}function CL(e,r,i,o,s,u,l,c,d,p,h,v){const g=[],w=[],N=new Set;if(o)for(const x of e.agents.values())zN(x,o)&&N.add(x.id);for(const x of e.agents.values()){if(!h.has(x.id))continue;const k=o?!N.has(x.id):!1,T=x.exitAt!=null,C=p!=null&&!p.has(x.id),A=[k?"rf-dim":"",T?"rf-exiting":"",C?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,j=s.get(x.id);if(g.push({id:x.id,type:"agent",position:{x:0,y:0},data:{...x,now:r,dim:k,onOpenContext:v},className:A,...j?{width:j.width,height:j.height}:null}),x.parentId&&h.has(x.parentId)){const M=Tv(x.sessionId),z=x.state==="active"?`hsl(${M} 80% 72%)`:`hsl(${M} 50% 55%)`,O=o&&!N.has(x.id)&&!N.has(x.parentId),B=T,U=d.size>0&&(d.has(x.id)||d.has(x.parentId)),ee=p!=null&&!p.has(x.id)&&!p.has(x.parentId),X=x.state==="active"?2:1.5,R=U?X+1.5:X,G=O||B?.2:ee?.12:1,H=[B?"rf-edge-exiting":"",U?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;w.push({id:`e:${x.parentId}->${x.id}`,source:x.parentId,target:x.id,animated:(x.state==="active"||U)&&!O&&!B,type:"smoothstep",style:{stroke:z,strokeWidth:R,opacity:G,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:H})}}if(l!==c.current){const x=tk(g,w,{direction:"LR",pinned:i,measured:s});for(const k of x)u.set(k.id,k.position);c.current=l}else if(g.filter(k=>!i.has(k.id)&&!u.has(k.id)).length>0){const k=tk(g,w,{direction:"LR",pinned:i,measured:s});for(const T of k)u.has(T.id)||u.set(T.id,T.position)}for(const x of Array.from(u.keys()))e.agents.has(x)||u.delete(x);const _=[];let E=!1;for(const x of g){let k=i.get(x.id)??u.get(x.id);k||(k={x:0,y:0},u.set(x.id,k),E=!0),_.push({...x,position:k})}return E&&(c.current=""),{nodes:_,edges:w}}function TL(){return S.jsx(Nv,{children:S.jsx(RL,{})})}function RL(){const e=ts(),r=D.useRef(nv()),[,i]=D.useState(0),o=D.useCallback(()=>i(oe=>oe+1),[]),[s,u]=D.useState(()=>new Set),[l,c]=D.useState(null),[d,p]=D.useState(null),h=D.useCallback((oe,se)=>{u(Se=>{if(!se)return new Set([oe]);const Te=new Set(Se);return Te.has(oe)?Te.delete(oe):Te.add(oe),Te}),c(Se=>se&&Se===oe?Se:oe)},[]),v=D.useCallback(()=>{u(new Set),c(null)},[]),[g,w]=D.useState(null),[N,_]=D.useState(null),E=D.useCallback(oe=>_(oe),[]),x=D.useRef(wL()),[k,T]=D.useState(mL);D.useEffect(()=>{vL(k)},[k]);const[C,A]=D.useState(gL);D.useEffect(()=>{yL(C)},[C]);const[j,M]=D.useState(!1),[z,O]=D.useState(!1),B=D.useRef([]),[U,ee]=D.useState(Date.now()),X=D.useRef(new Map(_L())),R=D.useState(()=>SL())[0],[G,H]=D.useState(""),[ne,Y]=D.useState(()=>new Set),[L,K]=D.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[I,F]=D.useState(!1),ae=D.useRef(null);D.useEffect(()=>{document.documentElement.dataset.theme=L;try{window.localStorage.setItem("agent-dag.theme",L)}catch{}},[L]),D.useEffect(()=>{if(!R)return;const oe=window.setTimeout(()=>{try{e.setViewport(R,{duration:0})}catch{}},60);return()=>window.clearTimeout(oe)},[e,R]);const q=D.useRef(!0),V=D.useRef(null);D.useEffect(()=>{const oe=new EventSource("/events");return oe.addEventListener("open",()=>{M(!0),F(!0)}),oe.addEventListener("error",()=>M(!1)),oe.addEventListener("replay-end",()=>{q.current=!1,V.current!=null&&(window.clearTimeout(V.current),V.current=null),o()}),oe.addEventListener("hook",se=>{try{const Se=JSON.parse(se.data);if(z){B.current.push(Se);return}r.current=Sw(r.current,Se),Se.replay===!0||q.current||Date.now()-Se.receivedAt>3e4?(V.current!=null&&window.clearTimeout(V.current),V.current=window.setTimeout(()=>{V.current=null,o()},120)):(V.current!=null&&(window.clearTimeout(V.current),V.current=null),o())}catch{}}),()=>{oe.close(),V.current!=null&&(window.clearTimeout(V.current),V.current=null)}},[z,o]),D.useEffect(()=>{if(!z&&B.current.length!==0){for(const oe of B.current)r.current=Sw(r.current,oe);B.current.length=0,o()}},[z,o]),D.useEffect(()=>{const oe=setInterval(()=>{const se=Date.now();ee(se);let Se=FM(r.current,se,dL);if(DM(r.current,se,hL,pL)&&(Se=!0),se-je.current>=1e3){je.current=se;let Te=0;for(const Ie of r.current.agents.values())Te+=An(Ie.usage,Ie.model).total;const be=pe.current;be.push({t:se,cost:Te}),be.length>240&&be.shift()}Se&&o()},250);return()=>clearInterval(oe)},[o]);const Q=D.useRef(null),re=D.useRef(0),ce=D.useRef(""),he=D.useRef(null),pe=D.useRef([]),je=D.useRef(0),$e=D.useRef(0),Me=D.useCallback(()=>{$e.current=Date.now()},[]),Ae="agent-dag.autoFitDisabled",we=D.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ae)==="1"}catch{return!1}})()),[Be,ve]=D.useState(we.current),ge=D.useCallback(()=>{if(!we.current){we.current=!0,ve(!0);try{window.localStorage.setItem(Ae,"1")}catch{}}},[]),ze=D.useCallback(()=>{we.current=!1,ve(!1);try{window.localStorage.removeItem(Ae)}catch{}try{e.fitView({padding:.25,duration:400})}catch{}},[e]);D.useEffect(()=>{const oe=setInterval(()=>{if(we.current||Date.now()-$e.current<800)return;const se=r.current,Se=Date.now(),Te=[];for(const Tt of se.agents.values())sv(Tt,Se)&&Te.push({id:Tt.id});if(Te.length===0)return;const be=e.getViewport(),Ie=window.innerWidth-360,st=window.innerHeight-52;let wn=!1,Zt=!1;for(const{id:Tt}of Te){const Rt=et.current.get(Tt),on=X.current.get(Tt)??Ge.current.get(Tt);if(!Rt||!on)continue;Zt=!0;const or=on.x*be.zoom+be.x,jr=on.y*be.zoom+be.y,Wi=(on.x+Rt.width)*be.zoom+be.x,Gi=(on.y+Rt.height)*be.zoom+be.y;if(Wi>0&&or<Ie&&Gi>0&&jr<st){wn=!0;break}}if(Zt&&!wn)try{e.fitView({padding:.25,duration:600})}catch{}},1500);return()=>clearInterval(oe)},[e]);const et=D.useRef(new Map),ft=D.useRef(0),lt=D.useCallback(oe=>{const se=et.current;let Se=!1;for(const Te of oe.nodeInternals.values()){const be=Te.width,Ie=Te.height;if(be==null||Ie==null)continue;const st=se.get(Te.id);st?(Math.abs(st.height-Ie)>4||Math.abs(st.width-be)>4)&&(se.set(Te.id,{width:be,height:Ie}),Se=!0):(se.set(Te.id,{width:be,height:Ie}),Se=!0)}return Se&&(ft.current+=1),ft.current},[]),Ue=Fe(lt),Ge=D.useRef(new Map),xt=D.useRef(""),St=D.useMemo(()=>{const oe=[];for(const se of r.current.agents.values())sv(se,U)&&oe.push(se.id+(se.parentId?`>${se.parentId}`:""));return oe.sort(),`${oe.join("|")}#sv${Ue}`},[r.current,r.current.lastSeq,U,Ue]);D.useEffect(()=>{if(ce.current===St)return;const oe=ce.current;if(ce.current=St,!oe||we.current)return;const se=Date.now();if(se-re.current>1200){try{e.fitView({padding:.25,duration:400})}catch{}re.current=se}Q.current&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{if(!we.current){try{e.fitView({padding:.25,duration:500})}catch{}re.current=Date.now()}},280)},[St,e]);const Et=D.useMemo(()=>{if(s.size===0)return null;const oe=new Set;for(const se of s){const Se=NL(r.current,se);if(Se)for(const Te of Se)oe.add(Te)}return oe.size>0?oe:null},[r.current,r.current.lastSeq,s]),tt=D.useMemo(()=>lL(r.current,U),[r.current,r.current.lastSeq,U]),{nodes:mt,edges:Mt}=D.useMemo(()=>CL(r.current,U,X.current,G,et.current,Ge.current,St,xt,s,Et,tt,E),[r.current,r.current.lastSeq,U,G,St,s,Et,tt,E]),He=D.useMemo(()=>{if(!G)return null;const oe=new Set;for(const se of r.current.agents.values())zN(se,G)&&oe.add(se.id);return oe},[r.current,r.current.lastSeq,G]),vt=D.useMemo(()=>{const oe=new Set;for(const se of r.current.agents.values())for(const Se of se.tools)oe.add(FN(Se.name));return Object.keys(av).filter(se=>oe.has(se))},[r.current,r.current.lastSeq]),Ke=D.useMemo(()=>{const oe=new Map;for(const Se of r.current.agents.values())for(const Te of Se.tools){if(!Te.name.startsWith("mcp__"))continue;const be=Te.name.slice(5),Ie=be.indexOf("__"),st=Ie>0?be.slice(0,Ie):be;oe.set(st,(oe.get(st)??0)+1)}const se=[];for(const[Se,Te]of oe){let be=5381;for(let Ie=0;Ie<Se.length;Ie++)be=(be<<5)+be^Se.charCodeAt(Ie);se.push({server:Se,count:Te,hue:Math.abs(be)%360})}return se.sort((Se,Te)=>Te.count-Se.count),se},[r.current,r.current.lastSeq]),dt=D.useCallback(oe=>{Y(se=>{const Se=new Set(se);return Se.has(oe)?Se.delete(oe):Se.add(oe),Se})},[]),Qe=l?r.current.agents.get(l):null,Pt=d?Array.from(r.current.agents.values()).flatMap(oe=>oe.tools).find(oe=>oe.id===d)??null:null,kt=D.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}r.current=nv(),X.current.clear(),et.current.clear(),Ge.current.clear(),xt.current="",rk(),v(),o()},[o,v]),Xt=D.useCallback(()=>{X.current.clear(),Ge.current.clear(),xt.current="",rk(),o(),window.setTimeout(()=>{try{e.fitView({padding:.25,duration:500})}catch{}re.current=Date.now()},80)},[o,e]),qn=D.useCallback(()=>{try{e.fitView({padding:.25,duration:500})}catch{}re.current=Date.now()},[e]),Qt=D.useCallback(oe=>{if(mt.length===0)return;const se=mt.slice().sort((Ie,st)=>Ie.position.y-st.position.y||Ie.position.x-st.position.x),Se=l?se.findIndex(Ie=>Ie.id===l):-1;let Te;Se===-1?Te=oe===1?0:se.length-1:Te=(Se+oe+se.length)%se.length;const be=se[Te];be&&(h(be.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[be]})}catch{}re.current=Date.now()},30))},[mt,l,h,e]);D.useEffect(()=>{const oe=se=>{var Te,be;const Se=((Te=se.target)==null?void 0:Te.tagName)==="INPUT";if(se.key==="Escape"){Se?se.target.blur():v();return}if(!Se){if(se.key==="/"){se.preventDefault(),(be=ae.current)==null||be.focus();return}se.key===" "&&(se.preventDefault(),O(Ie=>!Ie)),(se.key==="c"||se.key==="C")&&kt(),(se.key==="r"||se.key==="R")&&Xt(),(se.key==="f"||se.key==="F")&&qn(),(se.key==="l"||se.key==="L")&&T(Ie=>!Ie),(se.key==="h"||se.key==="H")&&A(Ie=>!Ie),(se.key==="j"||se.key==="J")&&Qt(1),(se.key==="k"||se.key==="K")&&Qt(-1),(se.key==="t"||se.key==="T")&&K(Ie=>Ie==="dark"?"light":"dark")}};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[kt,Xt,qn,v,Qt]);const Dt=r.current.agents.size,yn=new Set(Array.from(r.current.agents.values()).map(oe=>oe.sessionId)).size,nt=D.useMemo(()=>{let oe=0,se=0,Se=0,Te=0,be=0,Ie=0,st=0,wn=0,Zt=0;for(const Tt of r.current.agents.values()){oe+=Tt.usage.inputTokens,se+=Tt.usage.outputTokens,Se+=Tt.usage.cacheReadTokens,Te+=Tt.usage.cacheCreateTokens;const Rt=An(Tt.usage,Tt.model);be+=Rt.total,Ie+=Rt.input,st+=Rt.output,wn+=Rt.cacheRead,Zt+=Rt.cacheWrite}return{inT:oe,outT:se,cacheR:Se,cacheC:Te,sum:oe+se,cost:{total:be,input:Ie,output:st,cacheRead:wn,cacheWrite:Zt}}},[r.current,r.current.lastSeq]);return S.jsxs("div",{className:"app",children:[S.jsxs("header",{className:"topbar",children:[S.jsxs("div",{className:"brand",children:[S.jsx("span",{className:"logo"}),"agent-dag ",S.jsxs("span",{className:"v",children:["v","1.15.4"]})]}),Qe&&(()=>{const oe=An(Qe.usage,Qe.model),se=Math.max(0,((Qe.endedAt??U)-Qe.startedAt)/1e3),Se=Qe.state==="active"?iv(oe.total,se):null,Te=s.size-1;return S.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Qe.label}`,onClick:()=>{try{const be=mt.find(Ie=>Ie.id===Qe.id);be&&e.fitView({padding:.35,duration:500,nodes:[be]}),re.current=Date.now()}catch{}},children:[S.jsx("span",{className:`state-pill state-${Qe.state}`,children:Qe.state==="active"?"live":Qe.state}),S.jsx("span",{className:"selected-label",children:Qe.label}),oe.total>0&&S.jsxs("span",{className:"selected-cost",children:[We(oe.total),Se?S.jsxs("span",{className:"selected-rate",children:[" · ",Se]}):null]}),Te>0&&S.jsxs("span",{className:"selected-extra",children:["+",Te]}),S.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:be=>{be.stopPropagation(),v()},children:"×"})]})})(),S.jsxs("div",{className:"actions",children:[S.jsxs("div",{className:"search",children:[S.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),S.jsx("input",{ref:ae,type:"text",placeholder:"Search agents, cwd, tools…",value:G,onChange:oe=>H(oe.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),G?S.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>H(""),children:"×"}):S.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),S.jsxs("span",{className:"status",role:"status",children:[S.jsx("span",{className:`pill ${j?"live":"dead"}`,title:j?"Receiving events":"SSE disconnected",children:j?"live":"offline"}),S.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[S.jsx("span",{className:"count",children:yn}),S.jsx("span",{className:"lbl",children:"sessions"})]}),S.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[S.jsx("span",{className:"count",children:Dt}),S.jsx("span",{className:"lbl",children:"agents"})]}),S.jsxs("span",{className:"stat",title:"Total hook events received",children:[S.jsx("span",{className:"count",children:r.current.totalEvents}),S.jsx("span",{className:"lbl",children:"events"})]}),nt.sum>0&&S.jsxs("span",{className:"stat",title:`in:${nt.inT.toLocaleString()} out:${nt.outT.toLocaleString()} cache-r:${nt.cacheR.toLocaleString()} cache-c:${nt.cacheC.toLocaleString()}`,children:[S.jsx("span",{className:"count",children:cL(nt.sum)}),S.jsx("span",{className:"lbl",children:"tokens"})]}),Ke.length>0&&S.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
59
+ burn: ${g}`:"");return S.jsxs("span",{className:"cost-meta",title:w,children:[S.jsx("b",{children:We(h.total)}),g&&S.jsx("span",{className:"cost-rate",children:g})]})})()]}),S.jsx(Fi,{type:"source",position:ke.Right,style:{background:"transparent",border:"none"}})]})}function XM({state:e}){const r=e==="active"?"live":e==="done"?"done":"err";return S.jsx("span",{className:`state-pill state-${e}`,children:r})}function QM(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function ZM({tools:e,now:r}){const u=new Array(24).fill(0);let l=0;for(const g of e){const w=r-g.startedAt;if(w<0||w>=6e4)continue;const N=23-Math.floor(w/2500);N>=0&&N<24&&(u[N]+=1,l+=1)}const c=Math.max(1,...u),d=132,p=14,h=d/24,v=c/(2500/1e3);return S.jsxs("div",{className:"tool-spark-row",title:`${l} tool calls in last 60s · peak ${v.toFixed(1)}/s`,children:[S.jsx("svg",{className:"tool-spark",width:d,height:p,viewBox:`0 0 ${d} ${p}`,"aria-hidden":!0,children:u.map((g,w)=>{const N=g===0?1.5:Math.max(1.5,g/c*p),_=w===23&&g>0,x=`tool-spark-bar${g>0?" active":""}${_?" latest":""}`;return S.jsx("rect",{x:w*h+.4,y:p-N,width:Math.max(.5,h-1),height:N,rx:.8,className:x},w)})}),S.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function tu(e){const r=e.match(/^claude[-_](opus|sonnet|haiku|fable)[-_](\d+(?:[-_.]\d+)*)/i);if(!r)return e;const i=r[1][0].toUpperCase()+r[1].slice(1).toLowerCase(),o=r[2].replace(/[-_]/g,".");return`${i} ${o}`}function kw(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function JM(e){if(e.endedAt==null)return"in-flight…";const r=e.endedAt-e.startedAt;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`}function eP({tool:e,onClose:r}){D.useEffect(()=>{const o=s=>{s.key==="Escape"&&r()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[r]);const i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return S.jsx("div",{className:"modal-backdrop",onClick:r,role:"dialog","aria-modal":"true",children:S.jsxs("div",{className:"modal",onClick:o=>o.stopPropagation(),children:[S.jsxs("header",{className:"modal-head",children:[S.jsxs("div",{className:"modal-title",children:[S.jsx("span",{className:`status-dot ${i}`}),S.jsx("span",{className:"modal-tool-name",children:e.name}),S.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),S.jsxs("div",{className:"modal-actions",children:[S.jsx("span",{className:"modal-dur",children:JM(e)}),S.jsx("button",{className:"btn icon-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),S.jsxs("section",{className:"modal-body",children:[S.jsxs("div",{className:"modal-section",children:[S.jsx("h4",{children:"Input"}),S.jsx("pre",{children:kw(e.input??e.inputPreview)})]}),S.jsxs("div",{className:"modal-section",children:[S.jsxs("h4",{children:["Response ",i==="err"&&S.jsx("span",{className:"err-tag",children:"error"})]}),S.jsx("pre",{children:e.endedAt==null?"(waiting…)":kw(e.response??e.errorPreview)})]})]})]})})}const ja=18,bw=26,tP=12;function nP(e){const r=new Map;for(const s of e.nodeInternals.values()){const u=s.data;if(!(u!=null&&u.sessionId)||u.exitAt!=null||s.width==null||s.height==null)continue;const l=s.position.x,c=s.position.y,d=l+s.width,p=c+s.height,h=r.get(u.sessionId);h?(h.minX=Math.min(h.minX,l),h.minY=Math.min(h.minY,c),h.maxX=Math.max(h.maxX,d),h.maxY=Math.max(h.maxY,p),u.kind==="root"&&(h.label=Nw(u)??h.label)):r.set(u.sessionId,{minX:l,minY:c,maxX:d,maxY:p,label:Nw(u)??u.sessionId})}const i=new Map;for(const s of r.values())i.set(s.label,(i.get(s.label)??0)+1);const o=[];for(const[s,u]of r){const c=(i.get(u.label)??0)>1?`${u.label} · ${rP(s)}`:u.label;o.push({sessionId:s,label:c,x:u.minX-ja,y:u.minY-ja-bw,w:u.maxX-u.minX+ja*2,h:u.maxY-u.minY+ja*2+bw})}return o}function rP(e){const r=e.match(/[a-zA-Z0-9]{4}/);return r?r[0]:e.slice(0,4)}function Nw(e){if(e.kind==="root")return e.label}function iP(){const{x:e,y:r,zoom:i}=Eb(),o=ts(),s=Fe(nP,oP);if(s.length<=1)return null;const u=l=>{try{const c=o.getNodes().filter(d=>{const p=d.data;return(p==null?void 0:p.sessionId)===l});if(c.length===0)return;o.fitView({padding:.3,duration:500,nodes:c})}catch{}};return S.jsx("div",{className:"session-clusters",children:s.map(l=>{const c=Tv(l.sessionId),d={position:"absolute",left:l.x*i+e,top:l.y*i+r,width:l.w*i,height:l.h*i,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},p={position:"absolute",left:l.x*i+e+16*i,top:(l.y-tP)*i+r,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,i)})`,transformOrigin:"left top"};return S.jsxs(ie.Fragment,{children:[S.jsx("div",{className:"cluster-card",style:d,"aria-hidden":!0}),S.jsx("button",{type:"button",className:"cluster-label",style:p,title:`Fit view to ${l.label}`,onClick:()=>u(l.sessionId),children:l.label})]},l.sessionId)})})}function oP(e,r){if(e.length!==r.length)return!1;for(let i=0;i<e.length;i++){const o=e[i],s=r[i];if(o.sessionId!==s.sessionId||o.label!==s.label||o.x!==s.x||o.y!==s.y||o.w!==s.w||o.h!==s.h)return!1}return!0}const Mb=600,sP=36,ov=16,aP=60,uP=6,Cw=220,Tw=96,lP=28,cP={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",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 fP(e){return e.startsWith("mcp__")?"mcp":cP[e]??"other"}const dP={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",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 hP(e){return e.startsWith("mcp__")?"🔌":dP[e]??"✨"}const pP={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 Pb(e){if(!e)return null;let r=e.trim();if(!r)return null;const i=r.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(i)return Pb(i[1]);for(;;){const u=r.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!u)break;r=r.slice(u[0].length)}r=r.replace(/^sudo(?:\s+-\S+)*\s+/,""),r=r.replace(/^(?:time|nohup|xargs)\s+/,"");const o=r.match(/^([^\s|;&<>(]+)/);if(!o)return null;let s=o[1];return s=s.replace(/^.*[/\\]/,""),s=s.replace(/\.(exe|cmd|bat|ps1)$/i,""),s||null}function mP(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const r=e;return typeof r.command=="string"?r.command:typeof r.cmd=="string"?r.cmd:typeof r.script=="string"?r.script:null}function vP(e,r){if(e!=="Bash"&&e!=="PowerShell")return null;const i=mP(r);if(!i)return null;const o=Pb(i);return o?{emoji:pP[o]??"⚙️",label:o,category:"shell",detail:i}:null}const gP=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob"]),Rw={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:"🗄️"},Aw={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 yP(e){const i=e.replace(/\\/g,"/").replace(/\/+$/,""),o=i.lastIndexOf("/");return o>=0?i.slice(o+1):i}function wP(e){const r=e.toLowerCase();if(Aw[r])return Aw[r];if(r.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(r))return"🧪";const i=r.lastIndexOf(".");if(i>0&&i<r.length-1){const o=r.slice(i+1);if(Rw[o])return Rw[o]}return"📄"}function _P(e,r){if(!r||typeof r!="object")return null;const i=r;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 xP(e,r){if(!gP.has(e))return null;const i=_P(e,r);if(!i)return null;const o=yP(i);return o?{emoji:e==="LS"?"📂":wP(o),label:o,category:"file",detail:i}:null}const qb={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 Ob(e){if(!e.startsWith("mcp__"))return null;const r=e.slice(5),i=r.indexOf("__");return i<=0?{server:r,method:""}:{server:r.slice(0,i),method:r.slice(i+2)}}function SP(e){let r=5381;for(let i=0;i<e.length;i++)r=(r<<5)+r^e.charCodeAt(i);return Math.abs(r)%360}function EP(e,r){const i=Ob(e);if(!i)return null;const{server:o,method:s}=i;if(!s)return null;const u=qb[o.toLowerCase()];return{emoji:(u==null?void 0:u.emoji)??"🔌",label:s,category:"mcp",detail:u?`${u.name} · ${s}`:`${o} · ${s}`}}function kP(e,r){return vP(e,r)??xP(e,r)??EP(e)}function bP(e){const r=Ob(e);if(r){const i=qb[r.server.toLowerCase()];return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:r.server,hue:SP(r.server)}}return{emoji:hP(e),label:e}}function NP(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function CP(e,r,i){if(i==null)return 1;const o=r-i;return o<0?1:Math.max(0,1-o/Mb)}function TP(e,r,i,o,s,u){const l=[];for(const c of e.values()){if(!r.has(c.id)||c.exitAt!=null&&u-c.exitAt>Mb)continue;const d=o.get(c.id)??i.get(c.id);if(!d)continue;const p=c.tools.slice(-4);if(p.length===0)continue;const h=c.exitAt??null,v=s.get(c.id),g=Math.max((v==null?void 0:v.width)??Cw,Cw),w=(v==null?void 0:v.height)??130,N=d.x,_=d.y,E=N+g,x=_+w/2;p.forEach((k,T)=>{const C=T*sP,A=N+g+aP,j=_+uP+C,M=CP(k,u,h),z=k.inputPreview??"",O=NP(k),B=M<.999,U=bP(k.name);l.push({id:k.id,toolId:k.id,agentId:c.id,toolName:k.name,name:U.label,emoji:U.emoji,status:O,category:fP(k.name),mcpHue:U.hue,inputPreview:z,fade:M,fading:B,worldX:A,worldY:j,anchorX:E,anchorY:x,spawnDx:E-A,spawnDy:x-(j+ov)});const ee=kP(k.name,k.input);if(ee){const X=A+Tw+lP,R=j,G=A+Tw,H=j+ov;l.push({id:`sub:${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:ee.label,emoji:ee.emoji,isSub:!0,status:O,category:ee.category,inputPreview:ee.detail??z,fade:M,fading:B,worldX:X,worldY:R,anchorX:G,anchorY:H,spawnDx:G-X,spawnDy:0})}})}return l}function RP({agents:e,visibleAgentIds:r,positions:i,pinned:o,measured:s,dimUnmatched:u,spotlight:l,hiddenCategories:c,now:d,onOpenTool:p}){const{x:h,y:v,zoom:g}=Eb(),w=TP(e,r,i,o,s,d),N=c&&c.size>0?w.filter(_=>!c.has(_.category)):w;return S.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[S.jsx("svg",{className:"tool-bursts-svg",children:N.map(_=>{const E=_.anchorX*g+h,x=_.anchorY*g+v,k=(_.worldX+6)*g+h,T=(_.worldY+ov)*g+v,C=E+(k-E)*.55,A=u!=null&&!u.has(_.agentId),j=l!=null&&!l.has(_.agentId),M=_.fade*(A||j?.14:1);return S.jsx("path",{d:`M ${E} ${x} Q ${C} ${x}, ${k} ${T}`,className:`tool-conn status-${_.status}${_.fading?" fading":""}`,opacity:M},`l:${_.id}`)})}),N.map(_=>{const E=_.worldX*g+h,x=_.worldY*g+v,k={left:`${E}px`,top:`${x}px`,transform:`scale(${g})`,transformOrigin:"left top","--spawn-dx":`${_.spawnDx}px`,"--spawn-dy":`${_.spawnDy}px`},T=_.isSub?`${_.toolName} · ${_.name}`:_.toolName,C=_.inputPreview?`${T} · ${_.inputPreview}`:T,A=p!=null,j=_.mcpHue!=null?{"--cat-accent":`hsl(${_.mcpHue} 65% 65%)`}:{},M=u!=null&&!u.has(_.agentId),z=l!=null&&!l.has(_.agentId),O=M||z?" dim":"";return S.jsx("div",{className:"tool-burst-wrap",style:k,children:S.jsxs("div",{className:`tool-burst cat-${_.category} status-${_.status}${_.fading?" fading":""}${A?" clickable":""}${_.isSub?" sub":""}${O}`,style:j,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?()=>p(_.toolId):void 0,onKeyDown:A?B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),p(_.toolId))}:void 0,children:[S.jsx("span",{className:"tb-emoji",children:_.emoji}),S.jsx("span",{className:"tb-name",children:_.name}),_.status==="inflight"&&S.jsx("span",{className:"tb-spin"}),_.status==="done"&&S.jsx("span",{className:"tb-mark done",children:"✓"}),_.status==="err"&&S.jsx("span",{className:"tb-mark err",children:"×"})]})},_.id)})]})}function AP({state:e,sessionId:r,onClose:i}){const o=D.useMemo(()=>jP(e,r),[e,r]);return o?S.jsx("div",{className:"modal-backdrop",onClick:i,role:"presentation",children:S.jsxs("div",{className:"modal session-summary",onClick:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[S.jsxs("div",{className:"modal-head",children:[S.jsxs("div",{className:"modal-title",children:[S.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),S.jsx("span",{id:"ss-title",className:"modal-tool-name",title:o.cwd??o.sessionId,children:o.label}),S.jsxs("span",{className:"modal-tool-id",children:["· ",o.sessionId.slice(0,8)]})]}),S.jsxs("div",{className:"modal-actions",children:[S.jsx("span",{className:"modal-dur",title:"Total wall time",children:o.durationLabel}),S.jsx("button",{className:"btn",onClick:i,"aria-label":"Close",children:"×"})]})]}),S.jsxs("div",{className:"modal-body",children:[S.jsxs("section",{className:"ss-hero",children:[S.jsxs("div",{className:"ss-hero-left",children:[S.jsx("div",{className:"ss-cost-label",children:"total spend"}),S.jsx("div",{className:"ss-cost",children:We(o.cost.total)}),o.modelChips.length>0&&S.jsx("div",{className:"ss-models",children:o.modelChips.map(s=>S.jsx("span",{className:"model-chip",title:s,children:tu(s)},s))})]}),S.jsx("div",{className:"ss-hero-right",children:o.cost.total>0&&S.jsxs(S.Fragment,{children:[S.jsx(IP,{cost:o.cost}),S.jsxs("div",{className:"ss-cost-legend",children:[S.jsxs("span",{className:"ssl ssl-in",children:["input ",S.jsx("b",{children:We(o.cost.input)})]}),S.jsxs("span",{className:"ssl ssl-out",children:["output ",S.jsx("b",{children:We(o.cost.output)})]}),S.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",S.jsx("b",{children:We(o.cost.cacheRead)})]}),S.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",S.jsx("b",{children:We(o.cost.cacheWrite)})]})]})]})})]}),S.jsxs("section",{className:"ss-stats",children:[S.jsx(Ii,{label:"agents",value:o.agentCount}),S.jsx(Ii,{label:"subagents",value:o.subagentCount}),S.jsx(Ii,{label:"tool calls",value:o.toolCount}),S.jsx(Ii,{label:"prompts",value:o.promptCount}),S.jsx(Ii,{label:"tokens",value:o.tokensSum.toLocaleString()}),o.errCount>0&&S.jsx(Ii,{label:"errors",value:o.errCount,tone:"err"})]}),o.topTools.length>0&&S.jsxs("section",{className:"modal-section",children:[S.jsx("h4",{children:"Most-used tools"}),S.jsx("div",{className:"ss-top-tools",children:o.topTools.map(([s,u])=>S.jsxs("div",{className:"ss-tt",children:[S.jsx("span",{className:"ss-tt-name",children:s}),S.jsx("span",{className:"ss-tt-bar",children:S.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/o.topTools[0][1]*100}%`}})}),S.jsx("span",{className:"ss-tt-count",children:u})]},s))})]}),o.firstPrompt&&S.jsxs("section",{className:"modal-section",children:[S.jsx("h4",{children:"Opening prompt"}),S.jsx("div",{className:"ss-prompt",children:o.firstPrompt})]})]})]})}):null}function Ii({label:e,value:r,tone:i}){return S.jsxs("div",{className:`ss-stat${i?` tone-${i}`:""}`,children:[S.jsx("div",{className:"ss-stat-value",children:r}),S.jsx("div",{className:"ss-stat-label",children:e})]})}function IP({cost:e}){const r=e.total;if(r<=0)return null;const i=(o,s,u)=>{if(o<=0)return null;const l=o/r*100;return S.jsx("span",{className:`cb-seg ${s}`,style:{width:`${l}%`},title:`${u}: ${We(o)} (${l.toFixed(0)}%)`},s)};return S.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 jP(e,r){const i=e.agents.get(r);if(!i)return null;const o=[];for(const T of e.agents.values())T.sessionId===r&&o.push(T);if(o.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},u=new Set,l=new Map;let c=0,d=0,p=0,h=0,v=0,g,w=1/0,N=0;for(const T of o){const C=An(T.usage,T.model);s.input+=C.input,s.output+=C.output,s.cacheRead+=C.cacheRead,s.cacheWrite+=C.cacheWrite,s.total+=C.total,T.model&&u.add(T.model),T.kind==="subagent"&&v++,d+=T.prompts.length,!g&&T.prompts.length>0&&(g=T.prompts[0].text),p+=T.usage.inputTokens+T.usage.outputTokens,c+=T.tools.length,w=Math.min(w,T.startedAt),N=Math.max(N,T.endedAt??Date.now());for(const A of T.tools)l.set(A.name,(l.get(A.name)??0)+1),A.ok===!1&&h++}const _=Math.max(0,N-w),E=Math.floor(_/1e3),x=E<60?`${E}s`:E<3600?`${Math.floor(E/60)}m ${String(E%60).padStart(2,"0")}s`:`${Math.floor(E/3600)}h ${Math.floor(E%3600/60)}m`,k=Array.from(l.entries()).sort((T,C)=>C[1]-T[1]).slice(0,5);return{sessionId:r,label:i.label||i.cwdBasename||"session",cwd:i.cwd,durationLabel:x,cost:s,modelChips:Array.from(u),agentCount:o.length,subagentCount:v,toolCount:c,promptCount:d,tokensSum:p,errCount:h,topTools:k,firstPrompt:g}}function MP(e,r){const i=[];for(const o of e.agents.values()){if(o.kind!=="root")continue;let s=o.tools.length,u=An(o.usage,o.model).total,l=o.endedAt??o.startedAt;for(const c of e.agents.values()){if(c.sessionId!==o.sessionId||c.kind==="root")continue;s+=c.tools.length,u+=An(c.usage,c.model).total;const d=c.endedAt??c.startedAt;d>l&&(l=d)}i.push({sessionId:o.sessionId,label:o.label||o.cwdBasename||"session",cwdBasename:o.cwdBasename,state:o.state,modelId:o.model,toolCount:s,cost:u,startedAt:o.startedAt,lastActivity:l})}return i.sort((o,s)=>{if(o.state!==s.state){if(o.state==="active")return-1;if(s.state==="active")return 1}return s.lastActivity-o.lastActivity}),i}function PP(e,r,i){const o=(r??i)-e;if(o<1e3)return"<1s";const s=Math.floor(o/1e3);if(s<60)return`${s}s`;const u=Math.floor(s/60);return u<60?`${u}m`:`${Math.floor(u/60)}h ${u%60}m`}function qP({state:e,now:r,selectedIds:i,onSelect:o,onClose:s}){const u=D.useMemo(()=>MP(e),[e,e.lastSeq,r]),l=u.filter(c=>c.state==="active").length;return S.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[S.jsxs("div",{className:"sl-header",children:[S.jsxs("h3",{children:["Sessions ",S.jsx("span",{className:"sl-count",children:u.length})]}),l>0&&S.jsxs("span",{className:"sl-live-count",children:[l," live"]}),S.jsx("button",{className:"btn icon-btn sl-close",onClick:s,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),S.jsxs("div",{className:"sl-rows",children:[u.length===0&&S.jsx("div",{className:"sl-empty",children:"No sessions yet."}),u.map(c=>{const d=i.has(c.sessionId);return S.jsxs("button",{type:"button",className:`sl-row state-${c.state}${d?" selected":""}`,onClick:()=>o(c.sessionId),title:`Focus ${c.label}`,children:[S.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),S.jsxs("div",{className:"sl-row-body",children:[S.jsxs("div",{className:"sl-row-head",children:[S.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&S.jsx("span",{className:"model-chip",title:c.modelId,children:tu(c.modelId)})]}),S.jsxs("div",{className:"sl-row-meta",children:[S.jsxs("span",{title:"tool calls",children:[S.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&S.jsx("span",{className:"sl-cost",title:"total spend",children:S.jsx("b",{children:We(c.cost)})}),S.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:PP(c.startedAt,c.state==="active"?void 0:c.lastActivity,r)})]})]})]},c.sessionId)})]})]})}const xc=12e4,Iw=400,Lb="agent-dag.timelineMode";function OP(){if(typeof window>"u")return"tools";try{return window.localStorage.getItem(Lb)==="cost"?"cost":"tools"}catch{return"tools"}}function LP(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Lb,e)}catch{}}const $P={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",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 DP(e){return e.startsWith("mcp__")?"mcp":$P[e]??"other"}function FP(e,r,i){const o=[];for(const s of e.values())if(r.has(s.id))for(const u of s.tools)u.startedAt<i||o.push({agentId:s.id,toolId:u.id,name:u.name,category:DP(u.name),startedAt:u.startedAt,endedAt:u.endedAt,inflight:u.endedAt==null,errored:u.ok===!1});return o.sort((s,u)=>s.startedAt-u.startedAt),o.length>Iw?o.slice(o.length-Iw):o}function zP({agents:e,visibleAgentIds:r,now:i,costSamples:o,onSelect:s,onOpenTool:u,onClose:l}){const[c,d]=D.useState(OP);D.useEffect(()=>{LP(c)},[c]);const p=i-xc,h=D.useMemo(()=>FP(e,r,p),[e,r,p]),v=D.useMemo(()=>{const x=new Map;for(const k of h)x.set(k.category,(x.get(k.category)??0)+1);return x},[h]),g=D.useMemo(()=>o.filter(x=>x.t>=p),[o,p]),w=D.useMemo(()=>g.reduce((x,k)=>Math.max(x,k.cost),0),[g]),N=g.length>0?g[g.length-1].cost:0,_=g.length>0?g[0].cost:0,E=N-_;return S.jsxs("div",{className:"timeline-strip",role:"region","aria-label":c==="cost"?"Spend over time":"Recent tool activity",children:[S.jsxs("div",{className:"ts-header",children:[S.jsxs("div",{className:"ts-mode-toggle",role:"tablist","aria-label":"Timeline mode",children:[S.jsx("button",{role:"tab",className:`ts-mode${c==="tools"?" on":""}`,onClick:()=>d("tools"),"aria-selected":c==="tools",title:"Show recent tool calls",children:"tools"}),S.jsx("button",{role:"tab",className:`ts-mode${c==="cost"?" on":""}`,onClick:()=>d("cost"),"aria-selected":c==="cost",title:"Show cumulative spend",children:"$"})]}),S.jsx("span",{className:"ts-title",children:"Last 2 min"}),c==="tools"?S.jsxs(S.Fragment,{children:[S.jsxs("span",{className:"ts-total",children:[h.length," tool call",h.length===1?"":"s"]}),S.jsx("div",{className:"ts-legend",children:Array.from(v.entries()).sort((x,k)=>k[1]-x[1]).map(([x,k])=>S.jsxs("span",{className:`ts-legend-item cat-${x}`,title:`${k} ${x}`,children:[S.jsx("span",{className:"ts-legend-dot"}),k]},x))})]}):S.jsxs(S.Fragment,{children:[S.jsxs("span",{className:"ts-total",children:[We(N),E>0&&S.jsxs("span",{className:"ts-delta",children:[" · +",We(E)]})]}),S.jsx("div",{className:"ts-legend"})]}),S.jsx("button",{className:"btn icon-btn ts-close",onClick:l,title:"Hide timeline","aria-label":"Hide timeline",children:"×"})]}),S.jsxs("div",{className:"ts-track","aria-hidden":!0,children:[[2,1.5,1,.5,0].map(x=>S.jsx("span",{className:"ts-tick",style:{left:`${(2-x)/2*100}%`},children:x===0?"now":`${x}m`},x)),S.jsx("span",{className:"ts-now-line"}),c==="tools"?h.map(x=>{const k=(x.startedAt-p)/xc*100,T=x.inflight?"inflight":x.errored?"err":"done";return S.jsx("button",{className:`ts-dot cat-${x.category} status-${T}`,style:{left:`${k}%`},onClick:()=>{s(x.agentId),u(x.toolId)},title:`${x.name} · ${new Date(x.startedAt).toLocaleTimeString()}${x.endedAt?` (${Math.max(0,x.endedAt-x.startedAt)}ms)`:" — running"}`,"aria-label":`${x.name} ${T}`},x.toolId)}):S.jsx(BP,{series:g,earliest:p,windowMs:xc,costMax:w})]})]})}function BP({series:e,earliest:r,windowMs:i,costMax:o}){if(e.length<2||o<=0)return S.jsx("div",{className:"ts-chart-empty",children:"collecting samples…"});const s=h=>Math.max(0,Math.min(100,(h-r)/i*100)),u=h=>100-h/o*92-4,l=e.map(h=>({x:s(h.t),y:u(h.cost)}));let c=`M ${l[0].x.toFixed(2)} ${l[0].y.toFixed(2)}`;for(let h=1;h<l.length;h++){const v=l[h-1],g=l[h],w=(v.x+g.x)/2;c+=` C ${w.toFixed(2)} ${v.y.toFixed(2)}, ${w.toFixed(2)} ${g.y.toFixed(2)}, ${g.x.toFixed(2)} ${g.y.toFixed(2)}`}const d=l[l.length-1],p=`${c} L ${d.x.toFixed(2)} 100 L ${l[0].x.toFixed(2)} 100 Z`;return S.jsxs("svg",{className:"ts-chart",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":!0,children:[S.jsx("defs",{children:S.jsxs("linearGradient",{id:"ts-fill",x1:"0",y1:"0",x2:"0",y2:"1",children:[S.jsx("stop",{offset:"0%",stopColor:"hsl(150 60% 60%)",stopOpacity:"0.55"}),S.jsx("stop",{offset:"100%",stopColor:"hsl(150 60% 60%)",stopOpacity:"0.02"})]})}),S.jsx("path",{d:p,fill:"url(#ts-fill)"}),S.jsx("path",{d:c,fill:"none",stroke:"hsl(150 70% 65%)",strokeWidth:"0.6",vectorEffect:"non-scaling-stroke"}),S.jsx("circle",{cx:d.x,cy:d.y,r:"1.4",fill:"hsl(150 80% 70%)",vectorEffect:"non-scaling-stroke"})]})}function Av(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 Sc,jw;function UP(){if(jw)return Sc;jw=1;function e(){this.__data__=[],this.size=0}return Sc=e,Sc}var Ec,Mw;function zi(){if(Mw)return Ec;Mw=1;function e(r,i){return r===i||r!==r&&i!==i}return Ec=e,Ec}var kc,Pw;function nu(){if(Pw)return kc;Pw=1;var e=zi();function r(i,o){for(var s=i.length;s--;)if(e(i[s][0],o))return s;return-1}return kc=r,kc}var bc,qw;function HP(){if(qw)return bc;qw=1;var e=nu(),r=Array.prototype,i=r.splice;function o(s){var u=this.__data__,l=e(u,s);if(l<0)return!1;var c=u.length-1;return l==c?u.pop():i.call(u,l,1),--this.size,!0}return bc=o,bc}var Nc,Ow;function VP(){if(Ow)return Nc;Ow=1;var e=nu();function r(i){var o=this.__data__,s=e(o,i);return s<0?void 0:o[s][1]}return Nc=r,Nc}var Cc,Lw;function WP(){if(Lw)return Cc;Lw=1;var e=nu();function r(i){return e(this.__data__,i)>-1}return Cc=r,Cc}var Tc,$w;function GP(){if($w)return Tc;$w=1;var e=nu();function r(i,o){var s=this.__data__,u=e(s,i);return u<0?(++this.size,s.push([i,o])):s[u][1]=o,this}return Tc=r,Tc}var Rc,Dw;function ru(){if(Dw)return Rc;Dw=1;var e=UP(),r=HP(),i=VP(),o=WP(),s=GP();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var p=l[c];this.set(p[0],p[1])}}return u.prototype.clear=e,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=s,Rc=u,Rc}var Ac,Fw;function KP(){if(Fw)return Ac;Fw=1;var e=ru();function r(){this.__data__=new e,this.size=0}return Ac=r,Ac}var Ic,zw;function YP(){if(zw)return Ic;zw=1;function e(r){var i=this.__data__,o=i.delete(r);return this.size=i.size,o}return Ic=e,Ic}var jc,Bw;function XP(){if(Bw)return jc;Bw=1;function e(r){return this.__data__.get(r)}return jc=e,jc}var Mc,Uw;function QP(){if(Uw)return Mc;Uw=1;function e(r){return this.__data__.has(r)}return Mc=e,Mc}var Pc,Hw;function $b(){if(Hw)return Pc;Hw=1;var e=typeof xa=="object"&&xa&&xa.Object===Object&&xa;return Pc=e,Pc}var qc,Vw;function Pn(){if(Vw)return qc;Vw=1;var e=$b(),r=typeof self=="object"&&self&&self.Object===Object&&self,i=e||r||Function("return this")();return qc=i,qc}var Oc,Ww;function Bi(){if(Ww)return Oc;Ww=1;var e=Pn(),r=e.Symbol;return Oc=r,Oc}var Lc,Gw;function ZP(){if(Gw)return Lc;Gw=1;var e=Bi(),r=Object.prototype,i=r.hasOwnProperty,o=r.toString,s=e?e.toStringTag:void 0;function u(l){var c=i.call(l,s),d=l[s];try{l[s]=void 0;var p=!0}catch{}var h=o.call(l);return p&&(c?l[s]=d:delete l[s]),h}return Lc=u,Lc}var $c,Kw;function JP(){if(Kw)return $c;Kw=1;var e=Object.prototype,r=e.toString;function i(o){return r.call(o)}return $c=i,$c}var Dc,Yw;function Jr(){if(Yw)return Dc;Yw=1;var e=Bi(),r=ZP(),i=JP(),o="[object Null]",s="[object Undefined]",u=e?e.toStringTag:void 0;function l(c){return c==null?c===void 0?s:o:u&&u in Object(c)?r(c):i(c)}return Dc=l,Dc}var Fc,Xw;function vn(){if(Xw)return Fc;Xw=1;function e(r){var i=typeof r;return r!=null&&(i=="object"||i=="function")}return Fc=e,Fc}var zc,Qw;function ns(){if(Qw)return zc;Qw=1;var e=Jr(),r=vn(),i="[object AsyncFunction]",o="[object Function]",s="[object GeneratorFunction]",u="[object Proxy]";function l(c){if(!r(c))return!1;var d=e(c);return d==o||d==s||d==i||d==u}return zc=l,zc}var Bc,Zw;function e3(){if(Zw)return Bc;Zw=1;var e=Pn(),r=e["__core-js_shared__"];return Bc=r,Bc}var Uc,Jw;function t3(){if(Jw)return Uc;Jw=1;var e=e3(),r=(function(){var o=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""})();function i(o){return!!r&&r in o}return Uc=i,Uc}var Hc,e1;function Db(){if(e1)return Hc;e1=1;var e=Function.prototype,r=e.toString;function i(o){if(o!=null){try{return r.call(o)}catch{}try{return o+""}catch{}}return""}return Hc=i,Hc}var Vc,t1;function n3(){if(t1)return Vc;t1=1;var e=ns(),r=t3(),i=vn(),o=Db(),s=/[\\^$.*+?()[\]{}|]/g,u=/^\[object .+?Constructor\]$/,l=Function.prototype,c=Object.prototype,d=l.toString,p=c.hasOwnProperty,h=RegExp("^"+d.call(p).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function v(g){if(!i(g)||r(g))return!1;var w=e(g)?h:u;return w.test(o(g))}return Vc=v,Vc}var Wc,n1;function r3(){if(n1)return Wc;n1=1;function e(r,i){return r==null?void 0:r[i]}return Wc=e,Wc}var Gc,r1;function ei(){if(r1)return Gc;r1=1;var e=n3(),r=r3();function i(o,s){var u=r(o,s);return e(u)?u:void 0}return Gc=i,Gc}var Kc,i1;function Iv(){if(i1)return Kc;i1=1;var e=ei(),r=Pn(),i=e(r,"Map");return Kc=i,Kc}var Yc,o1;function iu(){if(o1)return Yc;o1=1;var e=ei(),r=e(Object,"create");return Yc=r,Yc}var Xc,s1;function i3(){if(s1)return Xc;s1=1;var e=iu();function r(){this.__data__=e?e(null):{},this.size=0}return Xc=r,Xc}var Qc,a1;function o3(){if(a1)return Qc;a1=1;function e(r){var i=this.has(r)&&delete this.__data__[r];return this.size-=i?1:0,i}return Qc=e,Qc}var Zc,u1;function s3(){if(u1)return Zc;u1=1;var e=iu(),r="__lodash_hash_undefined__",i=Object.prototype,o=i.hasOwnProperty;function s(u){var l=this.__data__;if(e){var c=l[u];return c===r?void 0:c}return o.call(l,u)?l[u]:void 0}return Zc=s,Zc}var Jc,l1;function a3(){if(l1)return Jc;l1=1;var e=iu(),r=Object.prototype,i=r.hasOwnProperty;function o(s){var u=this.__data__;return e?u[s]!==void 0:i.call(u,s)}return Jc=o,Jc}var ef,c1;function u3(){if(c1)return ef;c1=1;var e=iu(),r="__lodash_hash_undefined__";function i(o,s){var u=this.__data__;return this.size+=this.has(o)?0:1,u[o]=e&&s===void 0?r:s,this}return ef=i,ef}var tf,f1;function l3(){if(f1)return tf;f1=1;var e=i3(),r=o3(),i=s3(),o=a3(),s=u3();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var p=l[c];this.set(p[0],p[1])}}return u.prototype.clear=e,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=s,tf=u,tf}var nf,d1;function c3(){if(d1)return nf;d1=1;var e=l3(),r=ru(),i=Iv();function o(){this.size=0,this.__data__={hash:new e,map:new(i||r),string:new e}}return nf=o,nf}var rf,h1;function f3(){if(h1)return rf;h1=1;function e(r){var i=typeof r;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?r!=="__proto__":r===null}return rf=e,rf}var of,p1;function ou(){if(p1)return of;p1=1;var e=f3();function r(i,o){var s=i.__data__;return e(o)?s[typeof o=="string"?"string":"hash"]:s.map}return of=r,of}var sf,m1;function d3(){if(m1)return sf;m1=1;var e=ou();function r(i){var o=e(this,i).delete(i);return this.size-=o?1:0,o}return sf=r,sf}var af,v1;function h3(){if(v1)return af;v1=1;var e=ou();function r(i){return e(this,i).get(i)}return af=r,af}var uf,g1;function p3(){if(g1)return uf;g1=1;var e=ou();function r(i){return e(this,i).has(i)}return uf=r,uf}var lf,y1;function m3(){if(y1)return lf;y1=1;var e=ou();function r(i,o){var s=e(this,i),u=s.size;return s.set(i,o),this.size+=s.size==u?0:1,this}return lf=r,lf}var cf,w1;function jv(){if(w1)return cf;w1=1;var e=c3(),r=d3(),i=h3(),o=p3(),s=m3();function u(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var p=l[c];this.set(p[0],p[1])}}return u.prototype.clear=e,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=s,cf=u,cf}var ff,_1;function v3(){if(_1)return ff;_1=1;var e=ru(),r=Iv(),i=jv(),o=200;function s(u,l){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!r||d.length<o-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 ff=s,ff}var df,x1;function su(){if(x1)return df;x1=1;var e=ru(),r=KP(),i=YP(),o=XP(),s=QP(),u=v3();function l(c){var d=this.__data__=new e(c);this.size=d.size}return l.prototype.clear=r,l.prototype.delete=i,l.prototype.get=o,l.prototype.has=s,l.prototype.set=u,df=l,df}var hf,S1;function Mv(){if(S1)return hf;S1=1;function e(r,i){for(var o=-1,s=r==null?0:r.length;++o<s&&i(r[o],o,r)!==!1;);return r}return hf=e,hf}var pf,E1;function Fb(){if(E1)return pf;E1=1;var e=ei(),r=(function(){try{var i=e(Object,"defineProperty");return i({},"",{}),i}catch{}})();return pf=r,pf}var mf,k1;function au(){if(k1)return mf;k1=1;var e=Fb();function r(i,o,s){o=="__proto__"&&e?e(i,o,{configurable:!0,enumerable:!0,value:s,writable:!0}):i[o]=s}return mf=r,mf}var vf,b1;function uu(){if(b1)return vf;b1=1;var e=au(),r=zi(),i=Object.prototype,o=i.hasOwnProperty;function s(u,l,c){var d=u[l];(!(o.call(u,l)&&r(d,c))||c===void 0&&!(l in u))&&e(u,l,c)}return vf=s,vf}var gf,N1;function rs(){if(N1)return gf;N1=1;var e=uu(),r=au();function i(o,s,u,l){var c=!u;u||(u={});for(var d=-1,p=s.length;++d<p;){var h=s[d],v=l?l(u[h],o[h],h,u,o):void 0;v===void 0&&(v=o[h]),c?r(u,h,v):e(u,h,v)}return u}return gf=i,gf}var yf,C1;function g3(){if(C1)return yf;C1=1;function e(r,i){for(var o=-1,s=Array(r);++o<r;)s[o]=i(o);return s}return yf=e,yf}var wf,T1;function Bn(){if(T1)return wf;T1=1;function e(r){return r!=null&&typeof r=="object"}return wf=e,wf}var _f,R1;function y3(){if(R1)return _f;R1=1;var e=Jr(),r=Bn(),i="[object Arguments]";function o(s){return r(s)&&e(s)==i}return _f=o,_f}var xf,A1;function is(){if(A1)return xf;A1=1;var e=y3(),r=Bn(),i=Object.prototype,o=i.hasOwnProperty,s=i.propertyIsEnumerable,u=e((function(){return arguments})())?e:function(l){return r(l)&&o.call(l,"callee")&&!s.call(l,"callee")};return xf=u,xf}var Sf,I1;function pt(){if(I1)return Sf;I1=1;var e=Array.isArray;return Sf=e,Sf}var Do={exports:{}},Ef,j1;function w3(){if(j1)return Ef;j1=1;function e(){return!1}return Ef=e,Ef}Do.exports;var M1;function Ui(){return M1||(M1=1,(function(e,r){var i=Pn(),o=w3(),s=r&&!r.nodeType&&r,u=s&&!0&&e&&!e.nodeType&&e,l=u&&u.exports===s,c=l?i.Buffer:void 0,d=c?c.isBuffer:void 0,p=d||o;e.exports=p})(Do,Do.exports)),Do.exports}var kf,P1;function lu(){if(P1)return kf;P1=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function i(o,s){var u=typeof o;return s=s??e,!!s&&(u=="number"||u!="symbol"&&r.test(o))&&o>-1&&o%1==0&&o<s}return kf=i,kf}var bf,q1;function Pv(){if(q1)return bf;q1=1;var e=9007199254740991;function r(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=e}return bf=r,bf}var Nf,O1;function _3(){if(O1)return Nf;O1=1;var e=Jr(),r=Pv(),i=Bn(),o="[object Arguments]",s="[object Array]",u="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",p="[object Map]",h="[object Number]",v="[object Object]",g="[object RegExp]",w="[object Set]",N="[object String]",_="[object WeakMap]",E="[object ArrayBuffer]",x="[object DataView]",k="[object Float32Array]",T="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",j="[object Int32Array]",M="[object Uint8Array]",z="[object Uint8ClampedArray]",O="[object Uint16Array]",B="[object Uint32Array]",U={};U[k]=U[T]=U[C]=U[A]=U[j]=U[M]=U[z]=U[O]=U[B]=!0,U[o]=U[s]=U[E]=U[u]=U[x]=U[l]=U[c]=U[d]=U[p]=U[h]=U[v]=U[g]=U[w]=U[N]=U[_]=!1;function ee(X){return i(X)&&r(X.length)&&!!U[e(X)]}return Nf=ee,Nf}var Cf,L1;function cu(){if(L1)return Cf;L1=1;function e(r){return function(i){return r(i)}}return Cf=e,Cf}var Fo={exports:{}};Fo.exports;var $1;function qv(){return $1||($1=1,(function(e,r){var i=$b(),o=r&&!r.nodeType&&r,s=o&&!0&&e&&!e.nodeType&&e,u=s&&s.exports===o,l=u&&i.process,c=(function(){try{var d=s&&s.require&&s.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}})();e.exports=c})(Fo,Fo.exports)),Fo.exports}var Tf,D1;function os(){if(D1)return Tf;D1=1;var e=_3(),r=cu(),i=qv(),o=i&&i.isTypedArray,s=o?r(o):e;return Tf=s,Tf}var Rf,F1;function zb(){if(F1)return Rf;F1=1;var e=g3(),r=is(),i=pt(),o=Ui(),s=lu(),u=os(),l=Object.prototype,c=l.hasOwnProperty;function d(p,h){var v=i(p),g=!v&&r(p),w=!v&&!g&&o(p),N=!v&&!g&&!w&&u(p),_=v||g||w||N,E=_?e(p.length,String):[],x=E.length;for(var k in p)(h||c.call(p,k))&&!(_&&(k=="length"||w&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||s(k,x)))&&E.push(k);return E}return Rf=d,Rf}var Af,z1;function fu(){if(z1)return Af;z1=1;var e=Object.prototype;function r(i){var o=i&&i.constructor,s=typeof o=="function"&&o.prototype||e;return i===s}return Af=r,Af}var If,B1;function Bb(){if(B1)return If;B1=1;function e(r,i){return function(o){return r(i(o))}}return If=e,If}var jf,U1;function x3(){if(U1)return jf;U1=1;var e=Bb(),r=e(Object.keys,Object);return jf=r,jf}var Mf,H1;function Ov(){if(H1)return Mf;H1=1;var e=fu(),r=x3(),i=Object.prototype,o=i.hasOwnProperty;function s(u){if(!e(u))return r(u);var l=[];for(var c in Object(u))o.call(u,c)&&c!="constructor"&&l.push(c);return l}return Mf=s,Mf}var Pf,V1;function rr(){if(V1)return Pf;V1=1;var e=ns(),r=Pv();function i(o){return o!=null&&r(o.length)&&!e(o)}return Pf=i,Pf}var qf,W1;function Ir(){if(W1)return qf;W1=1;var e=zb(),r=Ov(),i=rr();function o(s){return i(s)?e(s):r(s)}return qf=o,qf}var Of,G1;function S3(){if(G1)return Of;G1=1;var e=rs(),r=Ir();function i(o,s){return o&&e(s,r(s),o)}return Of=i,Of}var Lf,K1;function E3(){if(K1)return Lf;K1=1;function e(r){var i=[];if(r!=null)for(var o in Object(r))i.push(o);return i}return Lf=e,Lf}var $f,Y1;function k3(){if(Y1)return $f;Y1=1;var e=vn(),r=fu(),i=E3(),o=Object.prototype,s=o.hasOwnProperty;function u(l){if(!e(l))return i(l);var c=r(l),d=[];for(var p in l)p=="constructor"&&(c||!s.call(l,p))||d.push(p);return d}return $f=u,$f}var Df,X1;function ti(){if(X1)return Df;X1=1;var e=zb(),r=k3(),i=rr();function o(s){return i(s)?e(s,!0):r(s)}return Df=o,Df}var Ff,Q1;function b3(){if(Q1)return Ff;Q1=1;var e=rs(),r=ti();function i(o,s){return o&&e(s,r(s),o)}return Ff=i,Ff}var zo={exports:{}};zo.exports;var Z1;function Ub(){return Z1||(Z1=1,(function(e,r){var i=Pn(),o=r&&!r.nodeType&&r,s=o&&!0&&e&&!e.nodeType&&e,u=s&&s.exports===o,l=u?i.Buffer:void 0,c=l?l.allocUnsafe:void 0;function d(p,h){if(h)return p.slice();var v=p.length,g=c?c(v):new p.constructor(v);return p.copy(g),g}e.exports=d})(zo,zo.exports)),zo.exports}var zf,J1;function Hb(){if(J1)return zf;J1=1;function e(r,i){var o=-1,s=r.length;for(i||(i=Array(s));++o<s;)i[o]=r[o];return i}return zf=e,zf}var Bf,e_;function Vb(){if(e_)return Bf;e_=1;function e(r,i){for(var o=-1,s=r==null?0:r.length,u=0,l=[];++o<s;){var c=r[o];i(c,o,r)&&(l[u++]=c)}return l}return Bf=e,Bf}var Uf,t_;function Wb(){if(t_)return Uf;t_=1;function e(){return[]}return Uf=e,Uf}var Hf,n_;function Lv(){if(n_)return Hf;n_=1;var e=Vb(),r=Wb(),i=Object.prototype,o=i.propertyIsEnumerable,s=Object.getOwnPropertySymbols,u=s?function(l){return l==null?[]:(l=Object(l),e(s(l),function(c){return o.call(l,c)}))}:r;return Hf=u,Hf}var Vf,r_;function N3(){if(r_)return Vf;r_=1;var e=rs(),r=Lv();function i(o,s){return e(o,r(o),s)}return Vf=i,Vf}var Wf,i_;function $v(){if(i_)return Wf;i_=1;function e(r,i){for(var o=-1,s=i.length,u=r.length;++o<s;)r[u+o]=i[o];return r}return Wf=e,Wf}var Gf,o_;function du(){if(o_)return Gf;o_=1;var e=Bb(),r=e(Object.getPrototypeOf,Object);return Gf=r,Gf}var Kf,s_;function Gb(){if(s_)return Kf;s_=1;var e=$v(),r=du(),i=Lv(),o=Wb(),s=Object.getOwnPropertySymbols,u=s?function(l){for(var c=[];l;)e(c,i(l)),l=r(l);return c}:o;return Kf=u,Kf}var Yf,a_;function C3(){if(a_)return Yf;a_=1;var e=rs(),r=Gb();function i(o,s){return e(o,r(o),s)}return Yf=i,Yf}var Xf,u_;function Kb(){if(u_)return Xf;u_=1;var e=$v(),r=pt();function i(o,s,u){var l=s(o);return r(o)?l:e(l,u(o))}return Xf=i,Xf}var Qf,l_;function Yb(){if(l_)return Qf;l_=1;var e=Kb(),r=Lv(),i=Ir();function o(s){return e(s,i,r)}return Qf=o,Qf}var Zf,c_;function T3(){if(c_)return Zf;c_=1;var e=Kb(),r=Gb(),i=ti();function o(s){return e(s,i,r)}return Zf=o,Zf}var Jf,f_;function R3(){if(f_)return Jf;f_=1;var e=ei(),r=Pn(),i=e(r,"DataView");return Jf=i,Jf}var ed,d_;function A3(){if(d_)return ed;d_=1;var e=ei(),r=Pn(),i=e(r,"Promise");return ed=i,ed}var td,h_;function Xb(){if(h_)return td;h_=1;var e=ei(),r=Pn(),i=e(r,"Set");return td=i,td}var nd,p_;function I3(){if(p_)return nd;p_=1;var e=ei(),r=Pn(),i=e(r,"WeakMap");return nd=i,nd}var rd,m_;function Hi(){if(m_)return rd;m_=1;var e=R3(),r=Iv(),i=A3(),o=Xb(),s=I3(),u=Jr(),l=Db(),c="[object Map]",d="[object Object]",p="[object Promise]",h="[object Set]",v="[object WeakMap]",g="[object DataView]",w=l(e),N=l(r),_=l(i),E=l(o),x=l(s),k=u;return(e&&k(new e(new ArrayBuffer(1)))!=g||r&&k(new r)!=c||i&&k(i.resolve())!=p||o&&k(new o)!=h||s&&k(new s)!=v)&&(k=function(T){var C=u(T),A=C==d?T.constructor:void 0,j=A?l(A):"";if(j)switch(j){case w:return g;case N:return c;case _:return p;case E:return h;case x:return v}return C}),rd=k,rd}var id,v_;function j3(){if(v_)return id;v_=1;var e=Object.prototype,r=e.hasOwnProperty;function i(o){var s=o.length,u=new o.constructor(s);return s&&typeof o[0]=="string"&&r.call(o,"index")&&(u.index=o.index,u.input=o.input),u}return id=i,id}var od,g_;function Qb(){if(g_)return od;g_=1;var e=Pn(),r=e.Uint8Array;return od=r,od}var sd,y_;function Dv(){if(y_)return sd;y_=1;var e=Qb();function r(i){var o=new i.constructor(i.byteLength);return new e(o).set(new e(i)),o}return sd=r,sd}var ad,w_;function M3(){if(w_)return ad;w_=1;var e=Dv();function r(i,o){var s=o?e(i.buffer):i.buffer;return new i.constructor(s,i.byteOffset,i.byteLength)}return ad=r,ad}var ud,__;function P3(){if(__)return ud;__=1;var e=/\w*$/;function r(i){var o=new i.constructor(i.source,e.exec(i));return o.lastIndex=i.lastIndex,o}return ud=r,ud}var ld,x_;function q3(){if(x_)return ld;x_=1;var e=Bi(),r=e?e.prototype:void 0,i=r?r.valueOf:void 0;function o(s){return i?Object(i.call(s)):{}}return ld=o,ld}var cd,S_;function Zb(){if(S_)return cd;S_=1;var e=Dv();function r(i,o){var s=o?e(i.buffer):i.buffer;return new i.constructor(s,i.byteOffset,i.length)}return cd=r,cd}var fd,E_;function O3(){if(E_)return fd;E_=1;var e=Dv(),r=M3(),i=P3(),o=q3(),s=Zb(),u="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",p="[object RegExp]",h="[object Set]",v="[object String]",g="[object Symbol]",w="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",E="[object Float64Array]",x="[object Int8Array]",k="[object Int16Array]",T="[object Int32Array]",C="[object Uint8Array]",A="[object Uint8ClampedArray]",j="[object Uint16Array]",M="[object Uint32Array]";function z(O,B,U){var ee=O.constructor;switch(B){case w:return e(O);case u:case l:return new ee(+O);case N:return r(O,U);case _:case E:case x:case k:case T:case C:case A:case j:case M:return s(O,U);case c:return new ee;case d:case v:return new ee(O);case p:return i(O);case h:return new ee;case g:return o(O)}}return fd=z,fd}var dd,k_;function Jb(){if(k_)return dd;k_=1;var e=vn(),r=Object.create,i=(function(){function o(){}return function(s){if(!e(s))return{};if(r)return r(s);o.prototype=s;var u=new o;return o.prototype=void 0,u}})();return dd=i,dd}var hd,b_;function eN(){if(b_)return hd;b_=1;var e=Jb(),r=du(),i=fu();function o(s){return typeof s.constructor=="function"&&!i(s)?e(r(s)):{}}return hd=o,hd}var pd,N_;function L3(){if(N_)return pd;N_=1;var e=Hi(),r=Bn(),i="[object Map]";function o(s){return r(s)&&e(s)==i}return pd=o,pd}var md,C_;function $3(){if(C_)return md;C_=1;var e=L3(),r=cu(),i=qv(),o=i&&i.isMap,s=o?r(o):e;return md=s,md}var vd,T_;function D3(){if(T_)return vd;T_=1;var e=Hi(),r=Bn(),i="[object Set]";function o(s){return r(s)&&e(s)==i}return vd=o,vd}var gd,R_;function F3(){if(R_)return gd;R_=1;var e=D3(),r=cu(),i=qv(),o=i&&i.isSet,s=o?r(o):e;return gd=s,gd}var yd,A_;function tN(){if(A_)return yd;A_=1;var e=su(),r=Mv(),i=uu(),o=S3(),s=b3(),u=Ub(),l=Hb(),c=N3(),d=C3(),p=Yb(),h=T3(),v=Hi(),g=j3(),w=O3(),N=eN(),_=pt(),E=Ui(),x=$3(),k=vn(),T=F3(),C=Ir(),A=ti(),j=1,M=2,z=4,O="[object Arguments]",B="[object Array]",U="[object Boolean]",ee="[object Date]",X="[object Error]",R="[object Function]",G="[object GeneratorFunction]",H="[object Map]",ne="[object Number]",Y="[object Object]",L="[object RegExp]",K="[object Set]",I="[object String]",F="[object Symbol]",ae="[object WeakMap]",q="[object ArrayBuffer]",V="[object DataView]",Q="[object Float32Array]",re="[object Float64Array]",ce="[object Int8Array]",he="[object Int16Array]",pe="[object Int32Array]",je="[object Uint8Array]",$e="[object Uint8ClampedArray]",Me="[object Uint16Array]",Ae="[object Uint32Array]",we={};we[O]=we[B]=we[q]=we[V]=we[U]=we[ee]=we[Q]=we[re]=we[ce]=we[he]=we[pe]=we[H]=we[ne]=we[Y]=we[L]=we[K]=we[I]=we[F]=we[je]=we[$e]=we[Me]=we[Ae]=!0,we[X]=we[R]=we[ae]=!1;function Be(ve,ge,ze,et,ft,lt){var Ue,Ge=ge&j,xt=ge&M,St=ge&z;if(ze&&(Ue=ft?ze(ve,et,ft,lt):ze(ve)),Ue!==void 0)return Ue;if(!k(ve))return ve;var Et=_(ve);if(Et){if(Ue=g(ve),!Ge)return l(ve,Ue)}else{var tt=v(ve),mt=tt==R||tt==G;if(E(ve))return u(ve,Ge);if(tt==Y||tt==O||mt&&!ft){if(Ue=xt||mt?{}:N(ve),!Ge)return xt?d(ve,s(Ue,ve)):c(ve,o(Ue,ve))}else{if(!we[tt])return ft?ve:{};Ue=w(ve,tt,Ge)}}lt||(lt=new e);var Mt=lt.get(ve);if(Mt)return Mt;lt.set(ve,Ue),T(ve)?ve.forEach(function(Ke){Ue.add(Be(Ke,ge,ze,Ke,ve,lt))}):x(ve)&&ve.forEach(function(Ke,dt){Ue.set(dt,Be(Ke,ge,ze,dt,ve,lt))});var He=St?xt?h:p:xt?A:C,vt=Et?void 0:He(ve);return r(vt||ve,function(Ke,dt){vt&&(dt=Ke,Ke=ve[dt]),i(Ue,dt,Be(Ke,ge,ze,dt,ve,lt))}),Ue}return yd=Be,yd}var wd,I_;function z3(){if(I_)return wd;I_=1;var e=tN(),r=4;function i(o){return e(o,r)}return wd=i,wd}var _d,j_;function Fv(){if(j_)return _d;j_=1;function e(r){return function(){return r}}return _d=e,_d}var xd,M_;function B3(){if(M_)return xd;M_=1;function e(r){return function(i,o,s){for(var u=-1,l=Object(i),c=s(i),d=c.length;d--;){var p=c[r?d:++u];if(o(l[p],p,l)===!1)break}return i}}return xd=e,xd}var Sd,P_;function zv(){if(P_)return Sd;P_=1;var e=B3(),r=e();return Sd=r,Sd}var Ed,q_;function Bv(){if(q_)return Ed;q_=1;var e=zv(),r=Ir();function i(o,s){return o&&e(o,s,r)}return Ed=i,Ed}var kd,O_;function U3(){if(O_)return kd;O_=1;var e=rr();function r(i,o){return function(s,u){if(s==null)return s;if(!e(s))return i(s,u);for(var l=s.length,c=o?l:-1,d=Object(s);(o?c--:++c<l)&&u(d[c],c,d)!==!1;);return s}}return kd=r,kd}var bd,L_;function hu(){if(L_)return bd;L_=1;var e=Bv(),r=U3(),i=r(e);return bd=i,bd}var Nd,$_;function ni(){if($_)return Nd;$_=1;function e(r){return r}return Nd=e,Nd}var Cd,D_;function nN(){if(D_)return Cd;D_=1;var e=ni();function r(i){return typeof i=="function"?i:e}return Cd=r,Cd}var Td,F_;function rN(){if(F_)return Td;F_=1;var e=Mv(),r=hu(),i=nN(),o=pt();function s(u,l){var c=o(u)?e:r;return c(u,i(l))}return Td=s,Td}var Rd,z_;function iN(){return z_||(z_=1,Rd=rN()),Rd}var Ad,B_;function H3(){if(B_)return Ad;B_=1;var e=hu();function r(i,o){var s=[];return e(i,function(u,l,c){o(u,l,c)&&s.push(u)}),s}return Ad=r,Ad}var Id,U_;function V3(){if(U_)return Id;U_=1;var e="__lodash_hash_undefined__";function r(i){return this.__data__.set(i,e),this}return Id=r,Id}var jd,H_;function W3(){if(H_)return jd;H_=1;function e(r){return this.__data__.has(r)}return jd=e,jd}var Md,V_;function oN(){if(V_)return Md;V_=1;var e=jv(),r=V3(),i=W3();function o(s){var u=-1,l=s==null?0:s.length;for(this.__data__=new e;++u<l;)this.add(s[u])}return o.prototype.add=o.prototype.push=r,o.prototype.has=i,Md=o,Md}var Pd,W_;function G3(){if(W_)return Pd;W_=1;function e(r,i){for(var o=-1,s=r==null?0:r.length;++o<s;)if(i(r[o],o,r))return!0;return!1}return Pd=e,Pd}var qd,G_;function sN(){if(G_)return qd;G_=1;function e(r,i){return r.has(i)}return qd=e,qd}var Od,K_;function aN(){if(K_)return Od;K_=1;var e=oN(),r=G3(),i=sN(),o=1,s=2;function u(l,c,d,p,h,v){var g=d&o,w=l.length,N=c.length;if(w!=N&&!(g&&N>w))return!1;var _=v.get(l),E=v.get(c);if(_&&E)return _==c&&E==l;var x=-1,k=!0,T=d&s?new e:void 0;for(v.set(l,c),v.set(c,l);++x<w;){var C=l[x],A=c[x];if(p)var j=g?p(A,C,x,c,l,v):p(C,A,x,l,c,v);if(j!==void 0){if(j)continue;k=!1;break}if(T){if(!r(c,function(M,z){if(!i(T,z)&&(C===M||h(C,M,d,p,v)))return T.push(z)})){k=!1;break}}else if(!(C===A||h(C,A,d,p,v))){k=!1;break}}return v.delete(l),v.delete(c),k}return Od=u,Od}var Ld,Y_;function K3(){if(Y_)return Ld;Y_=1;function e(r){var i=-1,o=Array(r.size);return r.forEach(function(s,u){o[++i]=[u,s]}),o}return Ld=e,Ld}var $d,X_;function Uv(){if(X_)return $d;X_=1;function e(r){var i=-1,o=Array(r.size);return r.forEach(function(s){o[++i]=s}),o}return $d=e,$d}var Dd,Q_;function Y3(){if(Q_)return Dd;Q_=1;var e=Bi(),r=Qb(),i=zi(),o=aN(),s=K3(),u=Uv(),l=1,c=2,d="[object Boolean]",p="[object Date]",h="[object Error]",v="[object Map]",g="[object Number]",w="[object RegExp]",N="[object Set]",_="[object String]",E="[object Symbol]",x="[object ArrayBuffer]",k="[object DataView]",T=e?e.prototype:void 0,C=T?T.valueOf:void 0;function A(j,M,z,O,B,U,ee){switch(z){case k:if(j.byteLength!=M.byteLength||j.byteOffset!=M.byteOffset)return!1;j=j.buffer,M=M.buffer;case x:return!(j.byteLength!=M.byteLength||!U(new r(j),new r(M)));case d:case p:case g:return i(+j,+M);case h:return j.name==M.name&&j.message==M.message;case w:case _:return j==M+"";case v:var X=s;case N:var R=O&l;if(X||(X=u),j.size!=M.size&&!R)return!1;var G=ee.get(j);if(G)return G==M;O|=c,ee.set(j,M);var H=o(X(j),X(M),O,B,U,ee);return ee.delete(j),H;case E:if(C)return C.call(j)==C.call(M)}return!1}return Dd=A,Dd}var Fd,Z_;function X3(){if(Z_)return Fd;Z_=1;var e=Yb(),r=1,i=Object.prototype,o=i.hasOwnProperty;function s(u,l,c,d,p,h){var v=c&r,g=e(u),w=g.length,N=e(l),_=N.length;if(w!=_&&!v)return!1;for(var E=w;E--;){var x=g[E];if(!(v?x in l:o.call(l,x)))return!1}var k=h.get(u),T=h.get(l);if(k&&T)return k==l&&T==u;var C=!0;h.set(u,l),h.set(l,u);for(var A=v;++E<w;){x=g[E];var j=u[x],M=l[x];if(d)var z=v?d(M,j,x,l,u,h):d(j,M,x,u,l,h);if(!(z===void 0?j===M||p(j,M,c,d,h):z)){C=!1;break}A||(A=x=="constructor")}if(C&&!A){var O=u.constructor,B=l.constructor;O!=B&&"constructor"in u&&"constructor"in l&&!(typeof O=="function"&&O instanceof O&&typeof B=="function"&&B instanceof B)&&(C=!1)}return h.delete(u),h.delete(l),C}return Fd=s,Fd}var zd,J_;function Q3(){if(J_)return zd;J_=1;var e=su(),r=aN(),i=Y3(),o=X3(),s=Hi(),u=pt(),l=Ui(),c=os(),d=1,p="[object Arguments]",h="[object Array]",v="[object Object]",g=Object.prototype,w=g.hasOwnProperty;function N(_,E,x,k,T,C){var A=u(_),j=u(E),M=A?h:s(_),z=j?h:s(E);M=M==p?v:M,z=z==p?v:z;var O=M==v,B=z==v,U=M==z;if(U&&l(_)){if(!l(E))return!1;A=!0,O=!1}if(U&&!O)return C||(C=new e),A||c(_)?r(_,E,x,k,T,C):i(_,E,M,x,k,T,C);if(!(x&d)){var ee=O&&w.call(_,"__wrapped__"),X=B&&w.call(E,"__wrapped__");if(ee||X){var R=ee?_.value():_,G=X?E.value():E;return C||(C=new e),T(R,G,x,k,C)}}return U?(C||(C=new e),o(_,E,x,k,T,C)):!1}return zd=N,zd}var Bd,ex;function uN(){if(ex)return Bd;ex=1;var e=Q3(),r=Bn();function i(o,s,u,l,c){return o===s?!0:o==null||s==null||!r(o)&&!r(s)?o!==o&&s!==s:e(o,s,u,l,i,c)}return Bd=i,Bd}var Ud,tx;function Z3(){if(tx)return Ud;tx=1;var e=su(),r=uN(),i=1,o=2;function s(u,l,c,d){var p=c.length,h=p,v=!d;if(u==null)return!h;for(u=Object(u);p--;){var g=c[p];if(v&&g[2]?g[1]!==u[g[0]]:!(g[0]in u))return!1}for(;++p<h;){g=c[p];var w=g[0],N=u[w],_=g[1];if(v&&g[2]){if(N===void 0&&!(w in u))return!1}else{var E=new e;if(d)var x=d(N,_,w,u,l,E);if(!(x===void 0?r(_,N,i|o,d,E):x))return!1}}return!0}return Ud=s,Ud}var Hd,nx;function lN(){if(nx)return Hd;nx=1;var e=vn();function r(i){return i===i&&!e(i)}return Hd=r,Hd}var Vd,rx;function J3(){if(rx)return Vd;rx=1;var e=lN(),r=Ir();function i(o){for(var s=r(o),u=s.length;u--;){var l=s[u],c=o[l];s[u]=[l,c,e(c)]}return s}return Vd=i,Vd}var Wd,ix;function cN(){if(ix)return Wd;ix=1;function e(r,i){return function(o){return o==null?!1:o[r]===i&&(i!==void 0||r in Object(o))}}return Wd=e,Wd}var Gd,ox;function eq(){if(ox)return Gd;ox=1;var e=Z3(),r=J3(),i=cN();function o(s){var u=r(s);return u.length==1&&u[0][2]?i(u[0][0],u[0][1]):function(l){return l===s||e(l,s,u)}}return Gd=o,Gd}var Kd,sx;function Vi(){if(sx)return Kd;sx=1;var e=Jr(),r=Bn(),i="[object Symbol]";function o(s){return typeof s=="symbol"||r(s)&&e(s)==i}return Kd=o,Kd}var Yd,ax;function Hv(){if(ax)return Yd;ax=1;var e=pt(),r=Vi(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,o=/^\w*$/;function s(u,l){if(e(u))return!1;var c=typeof u;return c=="number"||c=="symbol"||c=="boolean"||u==null||r(u)?!0:o.test(u)||!i.test(u)||l!=null&&u in Object(l)}return Yd=s,Yd}var Xd,ux;function tq(){if(ux)return Xd;ux=1;var e=jv(),r="Expected a function";function i(o,s){if(typeof o!="function"||s!=null&&typeof s!="function")throw new TypeError(r);var u=function(){var l=arguments,c=s?s.apply(this,l):l[0],d=u.cache;if(d.has(c))return d.get(c);var p=o.apply(this,l);return u.cache=d.set(c,p)||d,p};return u.cache=new(i.Cache||e),u}return i.Cache=e,Xd=i,Xd}var Qd,lx;function nq(){if(lx)return Qd;lx=1;var e=tq(),r=500;function i(o){var s=e(o,function(l){return u.size===r&&u.clear(),l}),u=s.cache;return s}return Qd=i,Qd}var Zd,cx;function rq(){if(cx)return Zd;cx=1;var e=nq(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,o=e(function(s){var u=[];return s.charCodeAt(0)===46&&u.push(""),s.replace(r,function(l,c,d,p){u.push(d?p.replace(i,"$1"):c||l)}),u});return Zd=o,Zd}var Jd,fx;function pu(){if(fx)return Jd;fx=1;function e(r,i){for(var o=-1,s=r==null?0:r.length,u=Array(s);++o<s;)u[o]=i(r[o],o,r);return u}return Jd=e,Jd}var eh,dx;function iq(){if(dx)return eh;dx=1;var e=Bi(),r=pu(),i=pt(),o=Vi(),s=e?e.prototype:void 0,u=s?s.toString:void 0;function l(c){if(typeof c=="string")return c;if(i(c))return r(c,l)+"";if(o(c))return u?u.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return eh=l,eh}var th,hx;function fN(){if(hx)return th;hx=1;var e=iq();function r(i){return i==null?"":e(i)}return th=r,th}var nh,px;function mu(){if(px)return nh;px=1;var e=pt(),r=Hv(),i=rq(),o=fN();function s(u,l){return e(u)?u:r(u,l)?[u]:i(o(u))}return nh=s,nh}var rh,mx;function ss(){if(mx)return rh;mx=1;var e=Vi();function r(i){if(typeof i=="string"||e(i))return i;var o=i+"";return o=="0"&&1/i==-1/0?"-0":o}return rh=r,rh}var ih,vx;function vu(){if(vx)return ih;vx=1;var e=mu(),r=ss();function i(o,s){s=e(s,o);for(var u=0,l=s.length;o!=null&&u<l;)o=o[r(s[u++])];return u&&u==l?o:void 0}return ih=i,ih}var oh,gx;function oq(){if(gx)return oh;gx=1;var e=vu();function r(i,o,s){var u=i==null?void 0:e(i,o);return u===void 0?s:u}return oh=r,oh}var sh,yx;function sq(){if(yx)return sh;yx=1;function e(r,i){return r!=null&&i in Object(r)}return sh=e,sh}var ah,wx;function dN(){if(wx)return ah;wx=1;var e=mu(),r=is(),i=pt(),o=lu(),s=Pv(),u=ss();function l(c,d,p){d=e(d,c);for(var h=-1,v=d.length,g=!1;++h<v;){var w=u(d[h]);if(!(g=c!=null&&p(c,w)))break;c=c[w]}return g||++h!=v?g:(v=c==null?0:c.length,!!v&&s(v)&&o(w,v)&&(i(c)||r(c)))}return ah=l,ah}var uh,_x;function hN(){if(_x)return uh;_x=1;var e=sq(),r=dN();function i(o,s){return o!=null&&r(o,s,e)}return uh=i,uh}var lh,xx;function aq(){if(xx)return lh;xx=1;var e=uN(),r=oq(),i=hN(),o=Hv(),s=lN(),u=cN(),l=ss(),c=1,d=2;function p(h,v){return o(h)&&s(v)?u(l(h),v):function(g){var w=r(g,h);return w===void 0&&w===v?i(g,h):e(v,w,c|d)}}return lh=p,lh}var ch,Sx;function pN(){if(Sx)return ch;Sx=1;function e(r){return function(i){return i==null?void 0:i[r]}}return ch=e,ch}var fh,Ex;function uq(){if(Ex)return fh;Ex=1;var e=vu();function r(i){return function(o){return e(o,i)}}return fh=r,fh}var dh,kx;function lq(){if(kx)return dh;kx=1;var e=pN(),r=uq(),i=Hv(),o=ss();function s(u){return i(u)?e(o(u)):r(u)}return dh=s,dh}var hh,bx;function ir(){if(bx)return hh;bx=1;var e=eq(),r=aq(),i=ni(),o=pt(),s=lq();function u(l){return typeof l=="function"?l:l==null?i:typeof l=="object"?o(l)?r(l[0],l[1]):e(l):s(l)}return hh=u,hh}var ph,Nx;function mN(){if(Nx)return ph;Nx=1;var e=Vb(),r=H3(),i=ir(),o=pt();function s(u,l){var c=o(u)?e:r;return c(u,i(l,3))}return ph=s,ph}var mh,Cx;function cq(){if(Cx)return mh;Cx=1;var e=Object.prototype,r=e.hasOwnProperty;function i(o,s){return o!=null&&r.call(o,s)}return mh=i,mh}var vh,Tx;function vN(){if(Tx)return vh;Tx=1;var e=cq(),r=dN();function i(o,s){return o!=null&&r(o,s,e)}return vh=i,vh}var gh,Rx;function fq(){if(Rx)return gh;Rx=1;var e=Ov(),r=Hi(),i=is(),o=pt(),s=rr(),u=Ui(),l=fu(),c=os(),d="[object Map]",p="[object Set]",h=Object.prototype,v=h.hasOwnProperty;function g(w){if(w==null)return!0;if(s(w)&&(o(w)||typeof w=="string"||typeof w.splice=="function"||u(w)||c(w)||i(w)))return!w.length;var N=r(w);if(N==d||N==p)return!w.size;if(l(w))return!e(w).length;for(var _ in w)if(v.call(w,_))return!1;return!0}return gh=g,gh}var yh,Ax;function gN(){if(Ax)return yh;Ax=1;function e(r){return r===void 0}return yh=e,yh}var wh,Ix;function yN(){if(Ix)return wh;Ix=1;var e=hu(),r=rr();function i(o,s){var u=-1,l=r(o)?Array(o.length):[];return e(o,function(c,d,p){l[++u]=s(c,d,p)}),l}return wh=i,wh}var _h,jx;function wN(){if(jx)return _h;jx=1;var e=pu(),r=ir(),i=yN(),o=pt();function s(u,l){var c=o(u)?e:i;return c(u,r(l,3))}return _h=s,_h}var xh,Mx;function dq(){if(Mx)return xh;Mx=1;function e(r,i,o,s){var u=-1,l=r==null?0:r.length;for(s&&l&&(o=r[++u]);++u<l;)o=i(o,r[u],u,r);return o}return xh=e,xh}var Sh,Px;function hq(){if(Px)return Sh;Px=1;function e(r,i,o,s,u){return u(r,function(l,c,d){o=s?(s=!1,l):i(o,l,c,d)}),o}return Sh=e,Sh}var Eh,qx;function _N(){if(qx)return Eh;qx=1;var e=dq(),r=hu(),i=ir(),o=hq(),s=pt();function u(l,c,d){var p=s(l)?e:o,h=arguments.length<3;return p(l,i(c,4),d,h,r)}return Eh=u,Eh}var kh,Ox;function pq(){if(Ox)return kh;Ox=1;var e=Jr(),r=pt(),i=Bn(),o="[object String]";function s(u){return typeof u=="string"||!r(u)&&i(u)&&e(u)==o}return kh=s,kh}var bh,Lx;function mq(){if(Lx)return bh;Lx=1;var e=pN(),r=e("length");return bh=r,bh}var Nh,$x;function vq(){if($x)return Nh;$x=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",o="\\u20d0-\\u20ff",s=r+i+o,u="\\ufe0e\\ufe0f",l="\\u200d",c=RegExp("["+l+e+s+u+"]");function d(p){return c.test(p)}return Nh=d,Nh}var Ch,Dx;function gq(){if(Dx)return Ch;Dx=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",i="\\ufe20-\\ufe2f",o="\\u20d0-\\u20ff",s=r+i+o,u="\\ufe0e\\ufe0f",l="["+e+"]",c="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+d+")",h="[^"+e+"]",v="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",N=p+"?",_="["+u+"]?",E="(?:"+w+"(?:"+[h,v,g].join("|")+")"+_+N+")*",x=_+N+E,k="(?:"+[h+c+"?",c,v,g,l].join("|")+")",T=RegExp(d+"(?="+d+")|"+k+x,"g");function C(A){for(var j=T.lastIndex=0;T.test(A);)++j;return j}return Ch=C,Ch}var Th,Fx;function yq(){if(Fx)return Th;Fx=1;var e=mq(),r=vq(),i=gq();function o(s){return r(s)?i(s):e(s)}return Th=o,Th}var Rh,zx;function wq(){if(zx)return Rh;zx=1;var e=Ov(),r=Hi(),i=rr(),o=pq(),s=yq(),u="[object Map]",l="[object Set]";function c(d){if(d==null)return 0;if(i(d))return o(d)?s(d):d.length;var p=r(d);return p==u||p==l?d.size:e(d).length}return Rh=c,Rh}var Ah,Bx;function _q(){if(Bx)return Ah;Bx=1;var e=Mv(),r=Jb(),i=Bv(),o=ir(),s=du(),u=pt(),l=Ui(),c=ns(),d=vn(),p=os();function h(v,g,w){var N=u(v),_=N||l(v)||p(v);if(g=o(g,4),w==null){var E=v&&v.constructor;_?w=N?new E:[]:d(v)?w=c(E)?r(s(v)):{}:w={}}return(_?e:i)(v,function(x,k,T){return g(w,x,k,T)}),w}return Ah=h,Ah}var Ih,Ux;function xq(){if(Ux)return Ih;Ux=1;var e=Bi(),r=is(),i=pt(),o=e?e.isConcatSpreadable:void 0;function s(u){return i(u)||r(u)||!!(o&&u&&u[o])}return Ih=s,Ih}var jh,Hx;function Vv(){if(Hx)return jh;Hx=1;var e=$v(),r=xq();function i(o,s,u,l,c){var d=-1,p=o.length;for(u||(u=r),c||(c=[]);++d<p;){var h=o[d];s>0&&u(h)?s>1?i(h,s-1,u,l,c):e(c,h):l||(c[c.length]=h)}return c}return jh=i,jh}var Mh,Vx;function Sq(){if(Vx)return Mh;Vx=1;function e(r,i,o){switch(o.length){case 0:return r.call(i);case 1:return r.call(i,o[0]);case 2:return r.call(i,o[0],o[1]);case 3:return r.call(i,o[0],o[1],o[2])}return r.apply(i,o)}return Mh=e,Mh}var Ph,Wx;function xN(){if(Wx)return Ph;Wx=1;var e=Sq(),r=Math.max;function i(o,s,u){return s=r(s===void 0?o.length-1:s,0),function(){for(var l=arguments,c=-1,d=r(l.length-s,0),p=Array(d);++c<d;)p[c]=l[s+c];c=-1;for(var h=Array(s+1);++c<s;)h[c]=l[c];return h[s]=u(p),e(o,this,h)}}return Ph=i,Ph}var qh,Gx;function Eq(){if(Gx)return qh;Gx=1;var e=Fv(),r=Fb(),i=ni(),o=r?function(s,u){return r(s,"toString",{configurable:!0,enumerable:!1,value:e(u),writable:!0})}:i;return qh=o,qh}var Oh,Kx;function kq(){if(Kx)return Oh;Kx=1;var e=800,r=16,i=Date.now;function o(s){var u=0,l=0;return function(){var c=i(),d=r-(c-l);if(l=c,d>0){if(++u>=e)return arguments[0]}else u=0;return s.apply(void 0,arguments)}}return Oh=o,Oh}var Lh,Yx;function SN(){if(Yx)return Lh;Yx=1;var e=Eq(),r=kq(),i=r(e);return Lh=i,Lh}var $h,Xx;function gu(){if(Xx)return $h;Xx=1;var e=ni(),r=xN(),i=SN();function o(s,u){return i(r(s,u,e),s+"")}return $h=o,$h}var Dh,Qx;function EN(){if(Qx)return Dh;Qx=1;function e(r,i,o,s){for(var u=r.length,l=o+(s?1:-1);s?l--:++l<u;)if(i(r[l],l,r))return l;return-1}return Dh=e,Dh}var Fh,Zx;function bq(){if(Zx)return Fh;Zx=1;function e(r){return r!==r}return Fh=e,Fh}var zh,Jx;function Nq(){if(Jx)return zh;Jx=1;function e(r,i,o){for(var s=o-1,u=r.length;++s<u;)if(r[s]===i)return s;return-1}return zh=e,zh}var Bh,eS;function Cq(){if(eS)return Bh;eS=1;var e=EN(),r=bq(),i=Nq();function o(s,u,l){return u===u?i(s,u,l):e(s,r,l)}return Bh=o,Bh}var Uh,tS;function Tq(){if(tS)return Uh;tS=1;var e=Cq();function r(i,o){var s=i==null?0:i.length;return!!s&&e(i,o,0)>-1}return Uh=r,Uh}var Hh,nS;function Rq(){if(nS)return Hh;nS=1;function e(r,i,o){for(var s=-1,u=r==null?0:r.length;++s<u;)if(o(i,r[s]))return!0;return!1}return Hh=e,Hh}var Vh,rS;function Aq(){if(rS)return Vh;rS=1;function e(){}return Vh=e,Vh}var Wh,iS;function Iq(){if(iS)return Wh;iS=1;var e=Xb(),r=Aq(),i=Uv(),o=1/0,s=e&&1/i(new e([,-0]))[1]==o?function(u){return new e(u)}:r;return Wh=s,Wh}var Gh,oS;function jq(){if(oS)return Gh;oS=1;var e=oN(),r=Tq(),i=Rq(),o=sN(),s=Iq(),u=Uv(),l=200;function c(d,p,h){var v=-1,g=r,w=d.length,N=!0,_=[],E=_;if(h)N=!1,g=i;else if(w>=l){var x=p?null:s(d);if(x)return u(x);N=!1,g=o,E=new e}else E=p?[]:_;e:for(;++v<w;){var k=d[v],T=p?p(k):k;if(k=h||k!==0?k:0,N&&T===T){for(var C=E.length;C--;)if(E[C]===T)continue e;p&&E.push(T),_.push(k)}else g(E,T,h)||(E!==_&&E.push(T),_.push(k))}return _}return Gh=c,Gh}var Kh,sS;function kN(){if(sS)return Kh;sS=1;var e=rr(),r=Bn();function i(o){return r(o)&&e(o)}return Kh=i,Kh}var Yh,aS;function Mq(){if(aS)return Yh;aS=1;var e=Vv(),r=gu(),i=jq(),o=kN(),s=r(function(u){return i(e(u,1,o,!0))});return Yh=s,Yh}var Xh,uS;function Pq(){if(uS)return Xh;uS=1;var e=pu();function r(i,o){return e(o,function(s){return i[s]})}return Xh=r,Xh}var Qh,lS;function bN(){if(lS)return Qh;lS=1;var e=Pq(),r=Ir();function i(o){return o==null?[]:e(o,r(o))}return Qh=i,Qh}var Zh,cS;function gn(){if(cS)return Zh;cS=1;var e;if(typeof Av=="function")try{e={clone:z3(),constant:Fv(),each:iN(),filter:mN(),has:vN(),isArray:pt(),isEmpty:fq(),isFunction:ns(),isUndefined:gN(),keys:Ir(),map:wN(),reduce:_N(),size:wq(),transform:_q(),union:Mq(),values:bN()}}catch{}return e||(e=window._),Zh=e,Zh}var Jh,fS;function Wv(){if(fS)return Jh;fS=1;var e=gn();Jh=s;var r="\0",i="\0",o="";function s(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.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={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(h){return this._label=h,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(v){return e.isEmpty(h._in[v])})},s.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(v){return e.isEmpty(h._out[v])})},s.prototype.setNodes=function(h,v){var g=arguments,w=this;return e.each(h,function(N){g.length>1?w.setNode(N,v):w.setNode(N)}),this},s.prototype.setNode=function(h,v){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=v),this):(this._nodes[h]=arguments.length>1?v:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=i,this._children[h]={},this._children[i][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},s.prototype.node=function(h){return this._nodes[h]},s.prototype.hasNode=function(h){return e.has(this._nodes,h)},s.prototype.removeNode=function(h){var v=this;if(e.has(this._nodes,h)){var g=function(w){v.removeEdge(v._edgeObjs[w])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(w){v.setParent(w)}),delete this._children[h]),e.each(e.keys(this._in[h]),g),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),g),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},s.prototype.setParent=function(h,v){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(v))v=i;else{v+="";for(var g=v;!e.isUndefined(g);g=this.parent(g))if(g===h)throw new Error("Setting "+v+" as parent of "+h+" would create a cycle");this.setNode(v)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=v,this._children[v][h]=!0,this},s.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},s.prototype.parent=function(h){if(this._isCompound){var v=this._parent[h];if(v!==i)return v}},s.prototype.children=function(h){if(e.isUndefined(h)&&(h=i),this._isCompound){var v=this._children[h];if(v)return e.keys(v)}else{if(h===i)return this.nodes();if(this.hasNode(h))return[]}},s.prototype.predecessors=function(h){var v=this._preds[h];if(v)return e.keys(v)},s.prototype.successors=function(h){var v=this._sucs[h];if(v)return e.keys(v)},s.prototype.neighbors=function(h){var v=this.predecessors(h);if(v)return e.union(v,this.successors(h))},s.prototype.isLeaf=function(h){var v;return this.isDirected()?v=this.successors(h):v=this.neighbors(h),v.length===0},s.prototype.filterNodes=function(h){var v=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});v.setGraph(this.graph());var g=this;e.each(this._nodes,function(_,E){h(E)&&v.setNode(E,_)}),e.each(this._edgeObjs,function(_){v.hasNode(_.v)&&v.hasNode(_.w)&&v.setEdge(_,g.edge(_))});var w={};function N(_){var E=g.parent(_);return E===void 0||v.hasNode(E)?(w[_]=E,E):E in w?w[E]:N(E)}return this._isCompound&&e.each(v.nodes(),function(_){v.setParent(_,N(_))}),v},s.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(h,v){var g=this,w=arguments;return e.reduce(h,function(N,_){return w.length>1?g.setEdge(N,_,v):g.setEdge(N,_),_}),this},s.prototype.setEdge=function(){var h,v,g,w,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(h=_.v,v=_.w,g=_.name,arguments.length===2&&(w=arguments[1],N=!0)):(h=_,v=arguments[1],g=arguments[3],arguments.length>2&&(w=arguments[2],N=!0)),h=""+h,v=""+v,e.isUndefined(g)||(g=""+g);var E=c(this._isDirected,h,v,g);if(e.has(this._edgeLabels,E))return N&&(this._edgeLabels[E]=w),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(v),this._edgeLabels[E]=N?w:this._defaultEdgeLabelFn(h,v,g);var x=d(this._isDirected,h,v,g);return h=x.v,v=x.w,Object.freeze(x),this._edgeObjs[E]=x,u(this._preds[v],h),u(this._sucs[h],v),this._in[v][E]=x,this._out[h][E]=x,this._edgeCount++,this},s.prototype.edge=function(h,v,g){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,v,g);return this._edgeLabels[w]},s.prototype.hasEdge=function(h,v,g){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,v,g);return e.has(this._edgeLabels,w)},s.prototype.removeEdge=function(h,v,g){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,h,v,g),N=this._edgeObjs[w];return N&&(h=N.v,v=N.w,delete this._edgeLabels[w],delete this._edgeObjs[w],l(this._preds[v],h),l(this._sucs[h],v),delete this._in[v][w],delete this._out[h][w],this._edgeCount--),this},s.prototype.inEdges=function(h,v){var g=this._in[h];if(g){var w=e.values(g);return v?e.filter(w,function(N){return N.v===v}):w}},s.prototype.outEdges=function(h,v){var g=this._out[h];if(g){var w=e.values(g);return v?e.filter(w,function(N){return N.w===v}):w}},s.prototype.nodeEdges=function(h,v){var g=this.inEdges(h,v);if(g)return g.concat(this.outEdges(h,v))};function u(h,v){h[v]?h[v]++:h[v]=1}function l(h,v){--h[v]||delete h[v]}function c(h,v,g,w){var N=""+v,_=""+g;if(!h&&N>_){var E=N;N=_,_=E}return N+o+_+o+(e.isUndefined(w)?r:w)}function d(h,v,g,w){var N=""+v,_=""+g;if(!h&&N>_){var E=N;N=_,_=E}var x={v:N,w:_};return w&&(x.name=w),x}function p(h,v){return c(h,v.v,v.w,v.name)}return Jh}var ep,dS;function qq(){return dS||(dS=1,ep="2.1.8"),ep}var tp,hS;function Oq(){return hS||(hS=1,tp={Graph:Wv(),version:qq()}),tp}var np,pS;function Lq(){if(pS)return np;pS=1;var e=gn(),r=Wv();np={write:i,read:u};function i(l){var c={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:o(l),edges:s(l)};return e.isUndefined(l.graph())||(c.value=e.clone(l.graph())),c}function o(l){return e.map(l.nodes(),function(c){var d=l.node(c),p=l.parent(c),h={v:c};return e.isUndefined(d)||(h.value=d),e.isUndefined(p)||(h.parent=p),h})}function s(l){return e.map(l.edges(),function(c){var d=l.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(d)||(p.value=d),p})}function u(l){var c=new r(l.options).setGraph(l.value);return e.each(l.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(l.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return np}var rp,mS;function $q(){if(mS)return rp;mS=1;var e=gn();rp=r;function r(i){var o={},s=[],u;function l(c){e.has(o,c)||(o[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&&s.push(u)}),s}return rp}var ip,vS;function NN(){if(vS)return ip;vS=1;var e=gn();ip=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(i){return i.key})},r.prototype.has=function(i){return e.has(this._keyIndices,i)},r.prototype.priority=function(i){var o=this._keyIndices[i];if(o!==void 0)return this._arr[o].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(i,o){var s=this._keyIndices;if(i=String(i),!e.has(s,i)){var u=this._arr,l=u.length;return s[i]=l,u.push({key:i,priority:o}),this._decrease(l),!0}return!1},r.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},r.prototype.decrease=function(i,o){var s=this._keyIndices[i];if(o>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+i+" Old: "+this._arr[s].priority+" New: "+o);this._arr[s].priority=o,this._decrease(s)},r.prototype._heapify=function(i){var o=this._arr,s=2*i,u=s+1,l=i;s<o.length&&(l=o[s].priority<o[l].priority?s:l,u<o.length&&(l=o[u].priority<o[l].priority?u:l),l!==i&&(this._swap(i,l),this._heapify(l)))},r.prototype._decrease=function(i){for(var o=this._arr,s=o[i].priority,u;i!==0&&(u=i>>1,!(o[u].priority<s));)this._swap(i,u),i=u},r.prototype._swap=function(i,o){var s=this._arr,u=this._keyIndices,l=s[i],c=s[o];s[i]=c,s[o]=l,u[c.key]=i,u[l.key]=o},ip}var op,gS;function CN(){if(gS)return op;gS=1;var e=gn(),r=NN();op=o;var i=e.constant(1);function o(u,l,c,d){return s(u,String(l),c||i,d||function(p){return u.outEdges(p)})}function s(u,l,c,d){var p={},h=new r,v,g,w=function(N){var _=N.v!==v?N.v:N.w,E=p[_],x=c(N),k=g.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+x);k<E.distance&&(E.distance=k,E.predecessor=v,h.decrease(_,k))};for(u.nodes().forEach(function(N){var _=N===l?0:Number.POSITIVE_INFINITY;p[N]={distance:_},h.add(N,_)});h.size()>0&&(v=h.removeMin(),g=p[v],g.distance!==Number.POSITIVE_INFINITY);)d(v).forEach(w);return p}return op}var sp,yS;function Dq(){if(yS)return sp;yS=1;var e=CN(),r=gn();sp=i;function i(o,s,u){return r.transform(o.nodes(),function(l,c){l[c]=e(o,c,s,u)},{})}return sp}var ap,wS;function TN(){if(wS)return ap;wS=1;var e=gn();ap=r;function r(i){var o=0,s=[],u={},l=[];function c(d){var p=u[d]={onStack:!0,lowlink:o,index:o++};if(s.push(d),i.successors(d).forEach(function(g){e.has(u,g)?u[g].onStack&&(p.lowlink=Math.min(p.lowlink,u[g].index)):(c(g),p.lowlink=Math.min(p.lowlink,u[g].lowlink))}),p.lowlink===p.index){var h=[],v;do v=s.pop(),u[v].onStack=!1,h.push(v);while(d!==v);l.push(h)}}return i.nodes().forEach(function(d){e.has(u,d)||c(d)}),l}return ap}var up,_S;function Fq(){if(_S)return up;_S=1;var e=gn(),r=TN();up=i;function i(o){return e.filter(r(o),function(s){return s.length>1||s.length===1&&o.hasEdge(s[0],s[0])})}return up}var lp,xS;function zq(){if(xS)return lp;xS=1;var e=gn();lp=i;var r=e.constant(1);function i(s,u,l){return o(s,u||r,l||function(c){return s.outEdges(c)})}function o(s,u,l){var c={},d=s.nodes();return d.forEach(function(p){c[p]={},c[p][p]={distance:0},d.forEach(function(h){p!==h&&(c[p][h]={distance:Number.POSITIVE_INFINITY})}),l(p).forEach(function(h){var v=h.v===p?h.w:h.v,g=u(h);c[p][v]={distance:g,predecessor:p}})}),d.forEach(function(p){var h=c[p];d.forEach(function(v){var g=c[v];d.forEach(function(w){var N=g[p],_=h[w],E=g[w],x=N.distance+_.distance;x<E.distance&&(E.distance=x,E.predecessor=_.predecessor)})})}),c}return lp}var cp,SS;function RN(){if(SS)return cp;SS=1;var e=gn();cp=r,r.CycleException=i;function r(o){var s={},u={},l=[];function c(d){if(e.has(u,d))throw new i;e.has(s,d)||(u[d]=!0,s[d]=!0,e.each(o.predecessors(d),c),delete u[d],l.push(d))}if(e.each(o.sinks(),c),e.size(s)!==o.nodeCount())throw new i;return l}function i(){}return i.prototype=new Error,cp}var fp,ES;function Bq(){if(ES)return fp;ES=1;var e=RN();fp=r;function r(i){try{e(i)}catch(o){if(o instanceof e.CycleException)return!1;throw o}return!0}return fp}var dp,kS;function AN(){if(kS)return dp;kS=1;var e=gn();dp=r;function r(o,s,u){e.isArray(s)||(s=[s]);var l=(o.isDirected()?o.successors:o.neighbors).bind(o),c=[],d={};return e.each(s,function(p){if(!o.hasNode(p))throw new Error("Graph does not have node: "+p);i(o,p,u==="post",d,l,c)}),c}function i(o,s,u,l,c,d){e.has(l,s)||(l[s]=!0,u||d.push(s),e.each(c(s),function(p){i(o,p,u,l,c,d)}),u&&d.push(s))}return dp}var hp,bS;function Uq(){if(bS)return hp;bS=1;var e=AN();hp=r;function r(i,o){return e(i,o,"post")}return hp}var pp,NS;function Hq(){if(NS)return pp;NS=1;var e=AN();pp=r;function r(i,o){return e(i,o,"pre")}return pp}var mp,CS;function Vq(){if(CS)return mp;CS=1;var e=gn(),r=Wv(),i=NN();mp=o;function o(s,u){var l=new r,c={},d=new i,p;function h(g){var w=g.v===p?g.w:g.v,N=d.priority(w);if(N!==void 0){var _=u(g);_<N&&(c[w]=p,d.decrease(w,_))}}if(s.nodeCount()===0)return l;e.each(s.nodes(),function(g){d.add(g,Number.POSITIVE_INFINITY),l.setNode(g)}),d.decrease(s.nodes()[0],0);for(var v=!1;d.size()>0;){if(p=d.removeMin(),e.has(c,p))l.setEdge(p,c[p]);else{if(v)throw new Error("Input graph is not connected: "+s);v=!0}s.nodeEdges(p).forEach(h)}return l}return mp}var vp,TS;function Wq(){return TS||(TS=1,vp={components:$q(),dijkstra:CN(),dijkstraAll:Dq(),findCycles:Fq(),floydWarshall:zq(),isAcyclic:Bq(),postorder:Uq(),preorder:Hq(),prim:Vq(),tarjan:TN(),topsort:RN()}),vp}var gp,RS;function Gq(){if(RS)return gp;RS=1;var e=Oq();return gp={Graph:e.Graph,json:Lq(),alg:Wq(),version:e.version},gp}var yp,AS;function jn(){if(AS)return yp;AS=1;var e;if(typeof Av=="function")try{e=Gq()}catch{}return e||(e=window.graphlib),yp=e,yp}var wp,IS;function Kq(){if(IS)return wp;IS=1;var e=tN(),r=1,i=4;function o(s){return e(s,r|i)}return wp=o,wp}var _p,jS;function yu(){if(jS)return _p;jS=1;var e=zi(),r=rr(),i=lu(),o=vn();function s(u,l,c){if(!o(c))return!1;var d=typeof l;return(d=="number"?r(c)&&i(l,c.length):d=="string"&&l in c)?e(c[l],u):!1}return _p=s,_p}var xp,MS;function Yq(){if(MS)return xp;MS=1;var e=gu(),r=zi(),i=yu(),o=ti(),s=Object.prototype,u=s.hasOwnProperty,l=e(function(c,d){c=Object(c);var p=-1,h=d.length,v=h>2?d[2]:void 0;for(v&&i(d[0],d[1],v)&&(h=1);++p<h;)for(var g=d[p],w=o(g),N=-1,_=w.length;++N<_;){var E=w[N],x=c[E];(x===void 0||r(x,s[E])&&!u.call(c,E))&&(c[E]=g[E])}return c});return xp=l,xp}var Sp,PS;function Xq(){if(PS)return Sp;PS=1;var e=ir(),r=rr(),i=Ir();function o(s){return function(u,l,c){var d=Object(u);if(!r(u)){var p=e(l,3);u=i(u),l=function(v){return p(d[v],v,d)}}var h=s(u,l,c);return h>-1?d[p?u[h]:h]:void 0}}return Sp=o,Sp}var Ep,qS;function Qq(){if(qS)return Ep;qS=1;var e=/\s/;function r(i){for(var o=i.length;o--&&e.test(i.charAt(o)););return o}return Ep=r,Ep}var kp,OS;function Zq(){if(OS)return kp;OS=1;var e=Qq(),r=/^\s+/;function i(o){return o&&o.slice(0,e(o)+1).replace(r,"")}return kp=i,kp}var bp,LS;function Jq(){if(LS)return bp;LS=1;var e=Zq(),r=vn(),i=Vi(),o=NaN,s=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;function d(p){if(typeof p=="number")return p;if(i(p))return o;if(r(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=r(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var v=u.test(p);return v||l.test(p)?c(p.slice(2),v?2:8):s.test(p)?o:+p}return bp=d,bp}var Np,$S;function IN(){if($S)return Np;$S=1;var e=Jq(),r=1/0,i=17976931348623157e292;function o(s){if(!s)return s===0?s:0;if(s=e(s),s===r||s===-r){var u=s<0?-1:1;return u*i}return s===s?s:0}return Np=o,Np}var Cp,DS;function eO(){if(DS)return Cp;DS=1;var e=IN();function r(i){var o=e(i),s=o%1;return o===o?s?o-s:o:0}return Cp=r,Cp}var Tp,FS;function tO(){if(FS)return Tp;FS=1;var e=EN(),r=ir(),i=eO(),o=Math.max;function s(u,l,c){var d=u==null?0:u.length;if(!d)return-1;var p=c==null?0:i(c);return p<0&&(p=o(d+p,0)),e(u,r(l,3),p)}return Tp=s,Tp}var Rp,zS;function nO(){if(zS)return Rp;zS=1;var e=Xq(),r=tO(),i=e(r);return Rp=i,Rp}var Ap,BS;function jN(){if(BS)return Ap;BS=1;var e=Vv();function r(i){var o=i==null?0:i.length;return o?e(i,1):[]}return Ap=r,Ap}var Ip,US;function rO(){if(US)return Ip;US=1;var e=zv(),r=nN(),i=ti();function o(s,u){return s==null?s:e(s,r(u),i)}return Ip=o,Ip}var jp,HS;function iO(){if(HS)return jp;HS=1;function e(r){var i=r==null?0:r.length;return i?r[i-1]:void 0}return jp=e,jp}var Mp,VS;function oO(){if(VS)return Mp;VS=1;var e=au(),r=Bv(),i=ir();function o(s,u){var l={};return u=i(u,3),r(s,function(c,d,p){e(l,d,u(c,d,p))}),l}return Mp=o,Mp}var Pp,WS;function Gv(){if(WS)return Pp;WS=1;var e=Vi();function r(i,o,s){for(var u=-1,l=i.length;++u<l;){var c=i[u],d=o(c);if(d!=null&&(p===void 0?d===d&&!e(d):s(d,p)))var p=d,h=c}return h}return Pp=r,Pp}var qp,GS;function sO(){if(GS)return qp;GS=1;function e(r,i){return r>i}return qp=e,qp}var Op,KS;function aO(){if(KS)return Op;KS=1;var e=Gv(),r=sO(),i=ni();function o(s){return s&&s.length?e(s,i,r):void 0}return Op=o,Op}var Lp,YS;function MN(){if(YS)return Lp;YS=1;var e=au(),r=zi();function i(o,s,u){(u!==void 0&&!r(o[s],u)||u===void 0&&!(s in o))&&e(o,s,u)}return Lp=i,Lp}var $p,XS;function uO(){if(XS)return $p;XS=1;var e=Jr(),r=du(),i=Bn(),o="[object Object]",s=Function.prototype,u=Object.prototype,l=s.toString,c=u.hasOwnProperty,d=l.call(Object);function p(h){if(!i(h)||e(h)!=o)return!1;var v=r(h);if(v===null)return!0;var g=c.call(v,"constructor")&&v.constructor;return typeof g=="function"&&g instanceof g&&l.call(g)==d}return $p=p,$p}var Dp,QS;function PN(){if(QS)return Dp;QS=1;function e(r,i){if(!(i==="constructor"&&typeof r[i]=="function")&&i!="__proto__")return r[i]}return Dp=e,Dp}var Fp,ZS;function lO(){if(ZS)return Fp;ZS=1;var e=rs(),r=ti();function i(o){return e(o,r(o))}return Fp=i,Fp}var zp,JS;function cO(){if(JS)return zp;JS=1;var e=MN(),r=Ub(),i=Zb(),o=Hb(),s=eN(),u=is(),l=pt(),c=kN(),d=Ui(),p=ns(),h=vn(),v=uO(),g=os(),w=PN(),N=lO();function _(E,x,k,T,C,A,j){var M=w(E,k),z=w(x,k),O=j.get(z);if(O){e(E,k,O);return}var B=A?A(M,z,k+"",E,x,j):void 0,U=B===void 0;if(U){var ee=l(z),X=!ee&&d(z),R=!ee&&!X&&g(z);B=z,ee||X||R?l(M)?B=M:c(M)?B=o(M):X?(U=!1,B=r(z,!0)):R?(U=!1,B=i(z,!0)):B=[]:v(z)||u(z)?(B=M,u(M)?B=N(M):(!h(M)||p(M))&&(B=s(z))):U=!1}U&&(j.set(z,B),C(B,z,T,A,j),j.delete(z)),e(E,k,B)}return zp=_,zp}var Bp,eE;function fO(){if(eE)return Bp;eE=1;var e=su(),r=MN(),i=zv(),o=cO(),s=vn(),u=ti(),l=PN();function c(d,p,h,v,g){d!==p&&i(p,function(w,N){if(g||(g=new e),s(w))o(d,p,N,h,c,v,g);else{var _=v?v(l(d,N),w,N+"",d,p,g):void 0;_===void 0&&(_=w),r(d,N,_)}},u)}return Bp=c,Bp}var Up,tE;function dO(){if(tE)return Up;tE=1;var e=gu(),r=yu();function i(o){return e(function(s,u){var l=-1,c=u.length,d=c>1?u[c-1]:void 0,p=c>2?u[2]:void 0;for(d=o.length>3&&typeof d=="function"?(c--,d):void 0,p&&r(u[0],u[1],p)&&(d=c<3?void 0:d,c=1),s=Object(s);++l<c;){var h=u[l];h&&o(s,h,l,d)}return s})}return Up=i,Up}var Hp,nE;function hO(){if(nE)return Hp;nE=1;var e=fO(),r=dO(),i=r(function(o,s,u){e(o,s,u)});return Hp=i,Hp}var Vp,rE;function qN(){if(rE)return Vp;rE=1;function e(r,i){return r<i}return Vp=e,Vp}var Wp,iE;function pO(){if(iE)return Wp;iE=1;var e=Gv(),r=qN(),i=ni();function o(s){return s&&s.length?e(s,i,r):void 0}return Wp=o,Wp}var Gp,oE;function mO(){if(oE)return Gp;oE=1;var e=Gv(),r=ir(),i=qN();function o(s,u){return s&&s.length?e(s,r(u,2),i):void 0}return Gp=o,Gp}var Kp,sE;function vO(){if(sE)return Kp;sE=1;var e=Pn(),r=function(){return e.Date.now()};return Kp=r,Kp}var Yp,aE;function gO(){if(aE)return Yp;aE=1;var e=uu(),r=mu(),i=lu(),o=vn(),s=ss();function u(l,c,d,p){if(!o(l))return l;c=r(c,l);for(var h=-1,v=c.length,g=v-1,w=l;w!=null&&++h<v;){var N=s(c[h]),_=d;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(h!=g){var E=w[N];_=p?p(E,N,w):void 0,_===void 0&&(_=o(E)?E:i(c[h+1])?[]:{})}e(w,N,_),w=w[N]}return l}return Yp=u,Yp}var Xp,uE;function yO(){if(uE)return Xp;uE=1;var e=vu(),r=gO(),i=mu();function o(s,u,l){for(var c=-1,d=u.length,p={};++c<d;){var h=u[c],v=e(s,h);l(v,h)&&r(p,i(h,s),v)}return p}return Xp=o,Xp}var Qp,lE;function wO(){if(lE)return Qp;lE=1;var e=yO(),r=hN();function i(o,s){return e(o,s,function(u,l){return r(o,l)})}return Qp=i,Qp}var Zp,cE;function _O(){if(cE)return Zp;cE=1;var e=jN(),r=xN(),i=SN();function o(s){return i(r(s,void 0,e),s+"")}return Zp=o,Zp}var Jp,fE;function xO(){if(fE)return Jp;fE=1;var e=wO(),r=_O(),i=r(function(o,s){return o==null?{}:e(o,s)});return Jp=i,Jp}var em,dE;function SO(){if(dE)return em;dE=1;var e=Math.ceil,r=Math.max;function i(o,s,u,l){for(var c=-1,d=r(e((s-o)/(u||1)),0),p=Array(d);d--;)p[l?d:++c]=o,o+=u;return p}return em=i,em}var tm,hE;function EO(){if(hE)return tm;hE=1;var e=SO(),r=yu(),i=IN();function o(s){return function(u,l,c){return c&&typeof c!="number"&&r(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,s)}}return tm=o,tm}var nm,pE;function kO(){if(pE)return nm;pE=1;var e=EO(),r=e();return nm=r,nm}var rm,mE;function bO(){if(mE)return rm;mE=1;function e(r,i){var o=r.length;for(r.sort(i);o--;)r[o]=r[o].value;return r}return rm=e,rm}var im,vE;function NO(){if(vE)return im;vE=1;var e=Vi();function r(i,o){if(i!==o){var s=i!==void 0,u=i===null,l=i===i,c=e(i),d=o!==void 0,p=o===null,h=o===o,v=e(o);if(!p&&!v&&!c&&i>o||c&&d&&h&&!p&&!v||u&&d&&h||!s&&h||!l)return 1;if(!u&&!c&&!v&&i<o||v&&s&&l&&!u&&!c||p&&s&&l||!d&&l||!h)return-1}return 0}return im=r,im}var om,gE;function CO(){if(gE)return om;gE=1;var e=NO();function r(i,o,s){for(var u=-1,l=i.criteria,c=o.criteria,d=l.length,p=s.length;++u<d;){var h=e(l[u],c[u]);if(h){if(u>=p)return h;var v=s[u];return h*(v=="desc"?-1:1)}}return i.index-o.index}return om=r,om}var sm,yE;function TO(){if(yE)return sm;yE=1;var e=pu(),r=vu(),i=ir(),o=yN(),s=bO(),u=cu(),l=CO(),c=ni(),d=pt();function p(h,v,g){v.length?v=e(v,function(_){return d(_)?function(E){return r(E,_.length===1?_[0]:_)}:_}):v=[c];var w=-1;v=e(v,u(i));var N=o(h,function(_,E,x){var k=e(v,function(T){return T(_)});return{criteria:k,index:++w,value:_}});return s(N,function(_,E){return l(_,E,g)})}return sm=p,sm}var am,wE;function RO(){if(wE)return am;wE=1;var e=Vv(),r=TO(),i=gu(),o=yu(),s=i(function(u,l){if(u==null)return[];var c=l.length;return c>1&&o(u,l[0],l[1])?l=[]:c>2&&o(l[0],l[1],l[2])&&(l=[l[0]]),r(u,e(l,1),[])});return am=s,am}var um,_E;function AO(){if(_E)return um;_E=1;var e=fN(),r=0;function i(o){var s=++r;return e(o)+s}return um=i,um}var lm,xE;function IO(){if(xE)return lm;xE=1;function e(r,i,o){for(var s=-1,u=r.length,l=i.length,c={};++s<u;){var d=s<l?i[s]:void 0;o(c,r[s],d)}return c}return lm=e,lm}var cm,SE;function jO(){if(SE)return cm;SE=1;var e=uu(),r=IO();function i(o,s){return r(o||[],s||[],e)}return cm=i,cm}var fm,EE;function Je(){if(EE)return fm;EE=1;var e;if(typeof Av=="function")try{e={cloneDeep:Kq(),constant:Fv(),defaults:Yq(),each:iN(),filter:mN(),find:nO(),flatten:jN(),forEach:rN(),forIn:rO(),has:vN(),isUndefined:gN(),last:iO(),map:wN(),mapValues:oO(),max:aO(),merge:hO(),min:pO(),minBy:mO(),now:vO(),pick:xO(),range:kO(),reduce:_N(),sortBy:RO(),uniqueId:AO(),values:bN(),zipObject:jO()}}catch{}return e||(e=window._),fm=e,fm}var dm,kE;function MO(){if(kE)return dm;kE=1,dm=e;function e(){var o={};o._next=o._prev=o,this._sentinel=o}e.prototype.dequeue=function(){var o=this._sentinel,s=o._prev;if(s!==o)return r(s),s},e.prototype.enqueue=function(o){var s=this._sentinel;o._prev&&o._next&&r(o),o._next=s._next,s._next._prev=o,s._next=o,o._prev=s},e.prototype.toString=function(){for(var o=[],s=this._sentinel,u=s._prev;u!==s;)o.push(JSON.stringify(u,i)),u=u._prev;return"["+o.join(", ")+"]"};function r(o){o._prev._next=o._next,o._next._prev=o._prev,delete o._next,delete o._prev}function i(o,s){if(o!=="_next"&&o!=="_prev")return s}return dm}var hm,bE;function PO(){if(bE)return hm;bE=1;var e=Je(),r=jn().Graph,i=MO();hm=s;var o=e.constant(1);function s(p,h){if(p.nodeCount()<=1)return[];var v=c(p,h||o),g=u(v.graph,v.buckets,v.zeroIdx);return e.flatten(e.map(g,function(w){return p.outEdges(w.v,w.w)}),!0)}function u(p,h,v){for(var g=[],w=h[h.length-1],N=h[0],_;p.nodeCount();){for(;_=N.dequeue();)l(p,h,v,_);for(;_=w.dequeue();)l(p,h,v,_);if(p.nodeCount()){for(var E=h.length-2;E>0;--E)if(_=h[E].dequeue(),_){g=g.concat(l(p,h,v,_,!0));break}}}return g}function l(p,h,v,g,w){var N=w?[]:void 0;return e.forEach(p.inEdges(g.v),function(_){var E=p.edge(_),x=p.node(_.v);w&&N.push({v:_.v,w:_.w}),x.out-=E,d(h,v,x)}),e.forEach(p.outEdges(g.v),function(_){var E=p.edge(_),x=_.w,k=p.node(x);k.in-=E,d(h,v,k)}),p.removeNode(g.v),N}function c(p,h){var v=new r,g=0,w=0;e.forEach(p.nodes(),function(E){v.setNode(E,{v:E,in:0,out:0})}),e.forEach(p.edges(),function(E){var x=v.edge(E.v,E.w)||0,k=h(E),T=x+k;v.setEdge(E.v,E.w,T),w=Math.max(w,v.node(E.v).out+=k),g=Math.max(g,v.node(E.w).in+=k)});var N=e.range(w+g+3).map(function(){return new i}),_=g+1;return e.forEach(v.nodes(),function(E){d(N,_,v.node(E))}),{graph:v,buckets:N,zeroIdx:_}}function d(p,h,v){v.out?v.in?p[v.out-v.in+h].enqueue(v):p[p.length-1].enqueue(v):p[0].enqueue(v)}return hm}var pm,NE;function qO(){if(NE)return pm;NE=1;var e=Je(),r=PO();pm={run:i,undo:s};function i(u){var l=u.graph().acyclicer==="greedy"?r(u,c(u)):o(u);e.forEach(l,function(d){var p=u.edge(d);u.removeEdge(d),p.forwardName=d.name,p.reversed=!0,u.setEdge(d.w,d.v,p,e.uniqueId("rev"))});function c(d){return function(p){return d.edge(p).weight}}}function o(u){var l=[],c={},d={};function p(h){e.has(d,h)||(d[h]=!0,c[h]=!0,e.forEach(u.outEdges(h),function(v){e.has(c,v.w)?l.push(v):p(v.w)}),delete c[h])}return e.forEach(u.nodes(),p),l}function s(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 pm}var mm,CE;function Yt(){if(CE)return mm;CE=1;var e=Je(),r=jn().Graph;mm={addDummyNode:i,simplify:o,asNonCompoundGraph:s,successorWeights:u,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:v,maxRank:g,partition:w,time:N,notime:_};function i(E,x,k,T){var C;do C=e.uniqueId(T);while(E.hasNode(C));return k.dummy=x,E.setNode(C,k),C}function o(E){var x=new r().setGraph(E.graph());return e.forEach(E.nodes(),function(k){x.setNode(k,E.node(k))}),e.forEach(E.edges(),function(k){var T=x.edge(k.v,k.w)||{weight:0,minlen:1},C=E.edge(k);x.setEdge(k.v,k.w,{weight:T.weight+C.weight,minlen:Math.max(T.minlen,C.minlen)})}),x}function s(E){var x=new r({multigraph:E.isMultigraph()}).setGraph(E.graph());return e.forEach(E.nodes(),function(k){E.children(k).length||x.setNode(k,E.node(k))}),e.forEach(E.edges(),function(k){x.setEdge(k,E.edge(k))}),x}function u(E){var x=e.map(E.nodes(),function(k){var T={};return e.forEach(E.outEdges(k),function(C){T[C.w]=(T[C.w]||0)+E.edge(C).weight}),T});return e.zipObject(E.nodes(),x)}function l(E){var x=e.map(E.nodes(),function(k){var T={};return e.forEach(E.inEdges(k),function(C){T[C.v]=(T[C.v]||0)+E.edge(C).weight}),T});return e.zipObject(E.nodes(),x)}function c(E,x){var k=E.x,T=E.y,C=x.x-k,A=x.y-T,j=E.width/2,M=E.height/2;if(!C&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var z,O;return Math.abs(A)*j>Math.abs(C)*M?(A<0&&(M=-M),z=M*C/A,O=M):(C<0&&(j=-j),z=j,O=j*A/C),{x:k+z,y:T+O}}function d(E){var x=e.map(e.range(g(E)+1),function(){return[]});return e.forEach(E.nodes(),function(k){var T=E.node(k),C=T.rank;e.isUndefined(C)||(x[C][T.order]=k)}),x}function p(E){var x=e.min(e.map(E.nodes(),function(k){return E.node(k).rank}));e.forEach(E.nodes(),function(k){var T=E.node(k);e.has(T,"rank")&&(T.rank-=x)})}function h(E){var x=e.min(e.map(E.nodes(),function(A){return E.node(A).rank})),k=[];e.forEach(E.nodes(),function(A){var j=E.node(A).rank-x;k[j]||(k[j]=[]),k[j].push(A)});var T=0,C=E.graph().nodeRankFactor;e.forEach(k,function(A,j){e.isUndefined(A)&&j%C!==0?--T:T&&e.forEach(A,function(M){E.node(M).rank+=T})})}function v(E,x,k,T){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=T),i(E,"border",C,x)}function g(E){return e.max(e.map(E.nodes(),function(x){var k=E.node(x).rank;if(!e.isUndefined(k))return k}))}function w(E,x){var k={lhs:[],rhs:[]};return e.forEach(E,function(T){x(T)?k.lhs.push(T):k.rhs.push(T)}),k}function N(E,x){var k=e.now();try{return x()}finally{console.log(E+" time: "+(e.now()-k)+"ms")}}function _(E,x){return x()}return mm}var vm,TE;function OO(){if(TE)return vm;TE=1;var e=Je(),r=Yt();vm={run:i,undo:s};function i(u){u.graph().dummyChains=[],e.forEach(u.edges(),function(l){o(u,l)})}function o(u,l){var c=l.v,d=u.node(c).rank,p=l.w,h=u.node(p).rank,v=l.name,g=u.edge(l),w=g.labelRank;if(h!==d+1){u.removeEdge(l);var N,_,E;for(E=0,++d;d<h;++E,++d)g.points=[],_={width:0,height:0,edgeLabel:g,edgeObj:l,rank:d},N=r.addDummyNode(u,"edge",_,"_d"),d===w&&(_.width=g.width,_.height=g.height,_.dummy="edge-label",_.labelpos=g.labelpos),u.setEdge(c,N,{weight:g.weight},v),E===0&&u.graph().dummyChains.push(N),c=N;u.setEdge(c,p,{weight:g.weight},v)}}function s(u){e.forEach(u.graph().dummyChains,function(l){var c=u.node(l),d=c.edgeLabel,p;for(u.setEdge(c.edgeObj,d);c.dummy;)p=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=p,c=u.node(l)})}return vm}var gm,RE;function Ga(){if(RE)return gm;RE=1;var e=Je();gm={longestPath:r,slack:i};function r(o){var s={};function u(l){var c=o.node(l);if(e.has(s,l))return c.rank;s[l]=!0;var d=e.min(e.map(o.outEdges(l),function(p){return u(p.w)-o.edge(p).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(o.sources(),u)}function i(o,s){return o.node(s.w).rank-o.node(s.v).rank-o.edge(s).minlen}return gm}var ym,AE;function ON(){if(AE)return ym;AE=1;var e=Je(),r=jn().Graph,i=Ga().slack;ym=o;function o(c){var d=new r({directed:!1}),p=c.nodes()[0],h=c.nodeCount();d.setNode(p,{});for(var v,g;s(d,c)<h;)v=u(d,c),g=d.hasNode(v.v)?i(c,v):-i(c,v),l(d,c,g);return d}function s(c,d){function p(h){e.forEach(d.nodeEdges(h),function(v){var g=v.v,w=h===g?v.w:g;!c.hasNode(w)&&!i(d,v)&&(c.setNode(w,{}),c.setEdge(h,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function u(c,d){return e.minBy(d.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return i(d,p)})}function l(c,d,p){e.forEach(c.nodes(),function(h){d.node(h).rank+=p})}return ym}var wm,IE;function LO(){if(IE)return wm;IE=1;var e=Je(),r=ON(),i=Ga().slack,o=Ga().longestPath,s=jn().alg.preorder,u=jn().alg.postorder,l=Yt().simplify;wm=c,c.initLowLimValues=v,c.initCutValues=d,c.calcCutValue=h,c.leaveEdge=w,c.enterEdge=N,c.exchangeEdges=_;function c(T){T=l(T),o(T);var C=r(T);v(C),d(C,T);for(var A,j;A=w(C);)j=N(C,T,A),_(C,T,A,j)}function d(T,C){var A=u(T,T.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(j){p(T,C,j)})}function p(T,C,A){var j=T.node(A),M=j.parent;T.edge(A,M).cutvalue=h(T,C,A)}function h(T,C,A){var j=T.node(A),M=j.parent,z=!0,O=C.edge(A,M),B=0;return O||(z=!1,O=C.edge(M,A)),B=O.weight,e.forEach(C.nodeEdges(A),function(U){var ee=U.v===A,X=ee?U.w:U.v;if(X!==M){var R=ee===z,G=C.edge(U).weight;if(B+=R?G:-G,x(T,A,X)){var H=T.edge(A,X).cutvalue;B+=R?-H:H}}}),B}function v(T,C){arguments.length<2&&(C=T.nodes()[0]),g(T,{},1,C)}function g(T,C,A,j,M){var z=A,O=T.node(j);return C[j]=!0,e.forEach(T.neighbors(j),function(B){e.has(C,B)||(A=g(T,C,A,B,j))}),O.low=z,O.lim=A++,M?O.parent=M:delete O.parent,A}function w(T){return e.find(T.edges(),function(C){return T.edge(C).cutvalue<0})}function N(T,C,A){var j=A.v,M=A.w;C.hasEdge(j,M)||(j=A.w,M=A.v);var z=T.node(j),O=T.node(M),B=z,U=!1;z.lim>O.lim&&(B=O,U=!0);var ee=e.filter(C.edges(),function(X){return U===k(T,T.node(X.v),B)&&U!==k(T,T.node(X.w),B)});return e.minBy(ee,function(X){return i(C,X)})}function _(T,C,A,j){var M=A.v,z=A.w;T.removeEdge(M,z),T.setEdge(j.v,j.w,{}),v(T),d(T,C),E(T,C)}function E(T,C){var A=e.find(T.nodes(),function(M){return!C.node(M).parent}),j=s(T,A);j=j.slice(1),e.forEach(j,function(M){var z=T.node(M).parent,O=C.edge(M,z),B=!1;O||(O=C.edge(z,M),B=!0),C.node(M).rank=C.node(z).rank+(B?O.minlen:-O.minlen)})}function x(T,C,A){return T.hasEdge(C,A)}function k(T,C,A){return A.low<=C.lim&&C.lim<=A.lim}return wm}var _m,jE;function $O(){if(jE)return _m;jE=1;var e=Ga(),r=e.longestPath,i=ON(),o=LO();_m=s;function s(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=r;function l(d){r(d),i(d)}function c(d){o(d)}return _m}var xm,ME;function DO(){if(ME)return xm;ME=1;var e=Je();xm=r;function r(s){var u=o(s);e.forEach(s.graph().dummyChains,function(l){for(var c=s.node(l),d=c.edgeObj,p=i(s,u,d.v,d.w),h=p.path,v=p.lca,g=0,w=h[g],N=!0;l!==d.w;){if(c=s.node(l),N){for(;(w=h[g])!==v&&s.node(w).maxRank<c.rank;)g++;w===v&&(N=!1)}if(!N){for(;g<h.length-1&&s.node(w=h[g+1]).minRank<=c.rank;)g++;w=h[g]}s.setParent(l,w),l=s.successors(l)[0]}})}function i(s,u,l,c){var d=[],p=[],h=Math.min(u[l].low,u[c].low),v=Math.max(u[l].lim,u[c].lim),g,w;g=l;do g=s.parent(g),d.push(g);while(g&&(u[g].low>h||v>u[g].lim));for(w=g,g=c;(g=s.parent(g))!==w;)p.push(g);return{path:d.concat(p.reverse()),lca:w}}function o(s){var u={},l=0;function c(d){var p=l;e.forEach(s.children(d),c),u[d]={low:p,lim:l++}}return e.forEach(s.children(),c),u}return xm}var Sm,PE;function FO(){if(PE)return Sm;PE=1;var e=Je(),r=Yt();Sm={run:i,cleanup:l};function i(c){var d=r.addDummyNode(c,"root",{},"_root"),p=s(c),h=e.max(e.values(p))-1,v=2*h+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(w){c.edge(w).minlen*=v});var g=u(c)+1;e.forEach(c.children(),function(w){o(c,d,v,g,h,p,w)}),c.graph().nodeRankFactor=v}function o(c,d,p,h,v,g,w){var N=c.children(w);if(!N.length){w!==d&&c.setEdge(d,w,{weight:0,minlen:p});return}var _=r.addBorderNode(c,"_bt"),E=r.addBorderNode(c,"_bb"),x=c.node(w);c.setParent(_,w),x.borderTop=_,c.setParent(E,w),x.borderBottom=E,e.forEach(N,function(k){o(c,d,p,h,v,g,k);var T=c.node(k),C=T.borderTop?T.borderTop:k,A=T.borderBottom?T.borderBottom:k,j=T.borderTop?h:2*h,M=C!==A?1:v-g[w]+1;c.setEdge(_,C,{weight:j,minlen:M,nestingEdge:!0}),c.setEdge(A,E,{weight:j,minlen:M,nestingEdge:!0})}),c.parent(w)||c.setEdge(d,_,{weight:0,minlen:v+g[w]})}function s(c){var d={};function p(h,v){var g=c.children(h);g&&g.length&&e.forEach(g,function(w){p(w,v+1)}),d[h]=v}return e.forEach(c.children(),function(h){p(h,1)}),d}function u(c){return e.reduce(c.edges(),function(d,p){return d+c.edge(p).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(p){var h=c.edge(p);h.nestingEdge&&c.removeEdge(p)})}return Sm}var Em,qE;function zO(){if(qE)return Em;qE=1;var e=Je(),r=Yt();Em=i;function i(s){function u(l){var c=s.children(l),d=s.node(l);if(c.length&&e.forEach(c,u),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var p=d.minRank,h=d.maxRank+1;p<h;++p)o(s,"borderLeft","_bl",l,d,p),o(s,"borderRight","_br",l,d,p)}}e.forEach(s.children(),u)}function o(s,u,l,c,d,p){var h={width:0,height:0,rank:p,borderType:u},v=d[u][p-1],g=r.addDummyNode(s,"border",h,l);d[u][p]=g,s.setParent(g,c),v&&s.setEdge(v,g,{weight:1})}return Em}var km,OE;function BO(){if(OE)return km;OE=1;var e=Je();km={adjust:r,undo:i};function r(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&o(p)}function i(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&u(p),(h==="lr"||h==="rl")&&(c(p),o(p))}function o(p){e.forEach(p.nodes(),function(h){s(p.node(h))}),e.forEach(p.edges(),function(h){s(p.edge(h))})}function s(p){var h=p.width;p.width=p.height,p.height=h}function u(p){e.forEach(p.nodes(),function(h){l(p.node(h))}),e.forEach(p.edges(),function(h){var v=p.edge(h);e.forEach(v.points,l),e.has(v,"y")&&l(v)})}function l(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(h){d(p.node(h))}),e.forEach(p.edges(),function(h){var v=p.edge(h);e.forEach(v.points,d),e.has(v,"x")&&d(v)})}function d(p){var h=p.x;p.x=p.y,p.y=h}return km}var bm,LE;function UO(){if(LE)return bm;LE=1;var e=Je();bm=r;function r(i){var o={},s=e.filter(i.nodes(),function(p){return!i.children(p).length}),u=e.max(e.map(s,function(p){return i.node(p).rank})),l=e.map(e.range(u+1),function(){return[]});function c(p){if(!e.has(o,p)){o[p]=!0;var h=i.node(p);l[h.rank].push(p),e.forEach(i.successors(p),c)}}var d=e.sortBy(s,function(p){return i.node(p).rank});return e.forEach(d,c),l}return bm}var Nm,$E;function HO(){if($E)return Nm;$E=1;var e=Je();Nm=r;function r(o,s){for(var u=0,l=1;l<s.length;++l)u+=i(o,s[l-1],s[l]);return u}function i(o,s,u){for(var l=e.zipObject(u,e.map(u,function(g,w){return w})),c=e.flatten(e.map(s,function(g){return e.sortBy(e.map(o.outEdges(g),function(w){return{pos:l[w.w],weight:o.edge(w).weight}}),"pos")}),!0),d=1;d<u.length;)d<<=1;var p=2*d-1;d-=1;var h=e.map(new Array(p),function(){return 0}),v=0;return e.forEach(c.forEach(function(g){var w=g.pos+d;h[w]+=g.weight;for(var N=0;w>0;)w%2&&(N+=h[w+1]),w=w-1>>1,h[w]+=g.weight;v+=g.weight*N})),v}return Nm}var Cm,DE;function VO(){if(DE)return Cm;DE=1;var e=Je();Cm=r;function r(i,o){return e.map(o,function(s){var u=i.inEdges(s);if(u.length){var l=e.reduce(u,function(c,d){var p=i.edge(d),h=i.node(d.v);return{sum:c.sum+p.weight*h.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:s,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:s}})}return Cm}var Tm,FE;function WO(){if(FE)return Tm;FE=1;var e=Je();Tm=r;function r(s,u){var l={};e.forEach(s,function(d,p){var h=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:p};e.isUndefined(d.barycenter)||(h.barycenter=d.barycenter,h.weight=d.weight)}),e.forEach(u.edges(),function(d){var p=l[d.v],h=l[d.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(l[d.w]))});var c=e.filter(l,function(d){return!d.indegree});return i(c)}function i(s){var u=[];function l(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&o(p,h)}}function c(p){return function(h){h.in.push(p),--h.indegree===0&&s.push(h)}}for(;s.length;){var d=s.pop();u.push(d),e.forEach(d.in.reverse(),l(d)),e.forEach(d.out,c(d))}return e.map(e.filter(u,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function o(s,u){var l=0,c=0;s.weight&&(l+=s.barycenter*s.weight,c+=s.weight),u.weight&&(l+=u.barycenter*u.weight,c+=u.weight),s.vs=u.vs.concat(s.vs),s.barycenter=l/c,s.weight=c,s.i=Math.min(u.i,s.i),u.merged=!0}return Tm}var Rm,zE;function GO(){if(zE)return Rm;zE=1;var e=Je(),r=Yt();Rm=i;function i(u,l){var c=r.partition(u,function(_){return e.has(_,"barycenter")}),d=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),h=[],v=0,g=0,w=0;d.sort(s(!!l)),w=o(h,p,w),e.forEach(d,function(_){w+=_.vs.length,h.push(_.vs),v+=_.barycenter*_.weight,g+=_.weight,w=o(h,p,w)});var N={vs:e.flatten(h,!0)};return g&&(N.barycenter=v/g,N.weight=g),N}function o(u,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),u.push(d.vs),c++;return c}function s(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 Rm}var Am,BE;function KO(){if(BE)return Am;BE=1;var e=Je(),r=VO(),i=WO(),o=GO();Am=s;function s(c,d,p,h){var v=c.children(d),g=c.node(d),w=g?g.borderLeft:void 0,N=g?g.borderRight:void 0,_={};w&&(v=e.filter(v,function(A){return A!==w&&A!==N}));var E=r(c,v);e.forEach(E,function(A){if(c.children(A.v).length){var j=s(c,A.v,p,h);_[A.v]=j,e.has(j,"barycenter")&&l(A,j)}});var x=i(E,p);u(x,_);var k=o(x,h);if(w&&(k.vs=e.flatten([w,k.vs,N],!0),c.predecessors(w).length)){var T=c.node(c.predecessors(w)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+T.order+C.order)/(k.weight+2),k.weight+=2}return k}function u(c,d){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(h){return d[h]?d[h].vs:h}),!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 Am}var Im,UE;function YO(){if(UE)return Im;UE=1;var e=Je(),r=jn().Graph;Im=i;function i(s,u,l){var c=o(s),d=new r({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return s.node(p)});return e.forEach(s.nodes(),function(p){var h=s.node(p),v=s.parent(p);(h.rank===u||h.minRank<=u&&u<=h.maxRank)&&(d.setNode(p),d.setParent(p,v||c),e.forEach(s[l](p),function(g){var w=g.v===p?g.w:g.v,N=d.edge(w,p),_=e.isUndefined(N)?0:N.weight;d.setEdge(w,p,{weight:s.edge(g).weight+_})}),e.has(h,"minRank")&&d.setNode(p,{borderLeft:h.borderLeft[u],borderRight:h.borderRight[u]}))}),d}function o(s){for(var u;s.hasNode(u=e.uniqueId("_root")););return u}return Im}var jm,HE;function XO(){if(HE)return jm;HE=1;var e=Je();jm=r;function r(i,o,s){var u={},l;e.forEach(s,function(c){for(var d=i.parent(c),p,h;d;){if(p=i.parent(d),p?(h=u[p],u[p]=d):(h=l,l=d),h&&h!==d){o.setEdge(h,d);return}d=p}})}return jm}var Mm,VE;function QO(){if(VE)return Mm;VE=1;var e=Je(),r=UO(),i=HO(),o=KO(),s=YO(),u=XO(),l=jn().Graph,c=Yt();Mm=d;function d(g){var w=c.maxRank(g),N=p(g,e.range(1,w+1),"inEdges"),_=p(g,e.range(w-1,-1,-1),"outEdges"),E=r(g);v(g,E);for(var x=Number.POSITIVE_INFINITY,k,T=0,C=0;C<4;++T,++C){h(T%2?N:_,T%4>=2),E=c.buildLayerMatrix(g);var A=i(g,E);A<x&&(C=0,k=e.cloneDeep(E),x=A)}v(g,k)}function p(g,w,N){return e.map(w,function(_){return s(g,_,N)})}function h(g,w){var N=new l;e.forEach(g,function(_){var E=_.graph().root,x=o(_,E,N,w);e.forEach(x.vs,function(k,T){_.node(k).order=T}),u(_,N,x.vs)})}function v(g,w){e.forEach(w,function(N){e.forEach(N,function(_,E){g.node(_).order=E})})}return Mm}var Pm,WE;function ZO(){if(WE)return Pm;WE=1;var e=Je(),r=jn().Graph,i=Yt();Pm={positionX:N,findType1Conflicts:o,findType2Conflicts:s,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:p,alignCoordinates:g,findSmallestWidthAlignment:v,balance:w};function o(x,k){var T={};function C(A,j){var M=0,z=0,O=A.length,B=e.last(j);return e.forEach(j,function(U,ee){var X=u(x,U),R=X?x.node(X).order:O;(X||U===B)&&(e.forEach(j.slice(z,ee+1),function(G){e.forEach(x.predecessors(G),function(H){var ne=x.node(H),Y=ne.order;(Y<M||R<Y)&&!(ne.dummy&&x.node(G).dummy)&&l(T,H,G)})}),z=ee+1,M=R)}),j}return e.reduce(k,C),T}function s(x,k){var T={};function C(j,M,z,O,B){var U;e.forEach(e.range(M,z),function(ee){U=j[ee],x.node(U).dummy&&e.forEach(x.predecessors(U),function(X){var R=x.node(X);R.dummy&&(R.order<O||R.order>B)&&l(T,X,U)})})}function A(j,M){var z=-1,O,B=0;return e.forEach(M,function(U,ee){if(x.node(U).dummy==="border"){var X=x.predecessors(U);X.length&&(O=x.node(X[0]).order,C(M,B,ee,z,O),B=ee,z=O)}C(M,B,M.length,O,j.length)}),M}return e.reduce(k,A),T}function u(x,k){if(x.node(k).dummy)return e.find(x.predecessors(k),function(T){return x.node(T).dummy})}function l(x,k,T){if(k>T){var C=k;k=T,T=C}var A=x[k];A||(x[k]=A={}),A[T]=!0}function c(x,k,T){if(k>T){var C=k;k=T,T=C}return e.has(x[k],T)}function d(x,k,T,C){var A={},j={},M={};return e.forEach(k,function(z){e.forEach(z,function(O,B){A[O]=O,j[O]=O,M[O]=B})}),e.forEach(k,function(z){var O=-1;e.forEach(z,function(B){var U=C(B);if(U.length){U=e.sortBy(U,function(H){return M[H]});for(var ee=(U.length-1)/2,X=Math.floor(ee),R=Math.ceil(ee);X<=R;++X){var G=U[X];j[B]===B&&O<M[G]&&!c(T,B,G)&&(j[G]=B,j[B]=A[B]=A[G],O=M[G])}}})}),{root:A,align:j}}function p(x,k,T,C,A){var j={},M=h(x,k,T,A),z=A?"borderLeft":"borderRight";function O(ee,X){for(var R=M.nodes(),G=R.pop(),H={};G;)H[G]?ee(G):(H[G]=!0,R.push(G),R=R.concat(X(G))),G=R.pop()}function B(ee){j[ee]=M.inEdges(ee).reduce(function(X,R){return Math.max(X,j[R.v]+M.edge(R))},0)}function U(ee){var X=M.outEdges(ee).reduce(function(G,H){return Math.min(G,j[H.w]-M.edge(H))},Number.POSITIVE_INFINITY),R=x.node(ee);X!==Number.POSITIVE_INFINITY&&R.borderType!==z&&(j[ee]=Math.max(j[ee],X))}return O(B,M.predecessors.bind(M)),O(U,M.successors.bind(M)),e.forEach(C,function(ee){j[ee]=j[T[ee]]}),j}function h(x,k,T,C){var A=new r,j=x.graph(),M=_(j.nodesep,j.edgesep,C);return e.forEach(k,function(z){var O;e.forEach(z,function(B){var U=T[B];if(A.setNode(U),O){var ee=T[O],X=A.edge(ee,U);A.setEdge(ee,U,Math.max(M(x,B,O),X||0))}O=B})}),A}function v(x,k){return e.minBy(e.values(k),function(T){var C=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(T,function(j,M){var z=E(x,M)/2;C=Math.max(j+z,C),A=Math.min(j-z,A)}),C-A})}function g(x,k){var T=e.values(k),C=e.min(T),A=e.max(T);e.forEach(["u","d"],function(j){e.forEach(["l","r"],function(M){var z=j+M,O=x[z],B;if(O!==k){var U=e.values(O);B=M==="l"?C-e.min(U):A-e.max(U),B&&(x[z]=e.mapValues(O,function(ee){return ee+B}))}})})}function w(x,k){return e.mapValues(x.ul,function(T,C){if(k)return x[k.toLowerCase()][C];var A=e.sortBy(e.map(x,C));return(A[1]+A[2])/2})}function N(x){var k=i.buildLayerMatrix(x),T=e.merge(o(x,k),s(x,k)),C={},A;e.forEach(["u","d"],function(M){A=M==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(z){z==="r"&&(A=e.map(A,function(ee){return e.values(ee).reverse()}));var O=(M==="u"?x.predecessors:x.successors).bind(x),B=d(x,A,T,O),U=p(x,A,B.root,B.align,z==="r");z==="r"&&(U=e.mapValues(U,function(ee){return-ee})),C[M+z]=U})});var j=v(x,C);return g(C,j),w(C,x.graph().align)}function _(x,k,T){return function(C,A,j){var M=C.node(A),z=C.node(j),O=0,B;if(O+=M.width/2,e.has(M,"labelpos"))switch(M.labelpos.toLowerCase()){case"l":B=-M.width/2;break;case"r":B=M.width/2;break}if(B&&(O+=T?B:-B),B=0,O+=(M.dummy?k:x)/2,O+=(z.dummy?k:x)/2,O+=z.width/2,e.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":B=z.width/2;break;case"r":B=-z.width/2;break}return B&&(O+=T?B:-B),B=0,O}}function E(x,k){return x.node(k).width}return Pm}var qm,GE;function JO(){if(GE)return qm;GE=1;var e=Je(),r=Yt(),i=ZO().positionX;qm=o;function o(u){u=r.asNonCompoundGraph(u),s(u),e.forEach(i(u),function(l,c){u.node(c).x=l})}function s(u){var l=r.buildLayerMatrix(u),c=u.graph().ranksep,d=0;e.forEach(l,function(p){var h=e.max(e.map(p,function(v){return u.node(v).height}));e.forEach(p,function(v){u.node(v).y=d+h/2}),d+=h+c})}return qm}var Om,KE;function eL(){if(KE)return Om;KE=1;var e=Je(),r=qO(),i=OO(),o=$O(),s=Yt().normalizeRanks,u=DO(),l=Yt().removeEmptyRanks,c=FO(),d=zO(),p=BO(),h=QO(),v=JO(),g=Yt(),w=jn().Graph;Om=N;function N(q,V){var Q=V&&V.debugTiming?g.time:g.notime;Q("layout",function(){var re=Q(" buildLayoutGraph",function(){return O(q)});Q(" runLayout",function(){_(re,Q)}),Q(" updateInputGraph",function(){E(q,re)})})}function _(q,V){V(" makeSpaceForEdgeLabels",function(){B(q)}),V(" removeSelfEdges",function(){L(q)}),V(" acyclic",function(){r.run(q)}),V(" nestingGraph.run",function(){c.run(q)}),V(" rank",function(){o(g.asNonCompoundGraph(q))}),V(" injectEdgeLabelProxies",function(){U(q)}),V(" removeEmptyRanks",function(){l(q)}),V(" nestingGraph.cleanup",function(){c.cleanup(q)}),V(" normalizeRanks",function(){s(q)}),V(" assignRankMinMax",function(){ee(q)}),V(" removeEdgeLabelProxies",function(){X(q)}),V(" normalize.run",function(){i.run(q)}),V(" parentDummyChains",function(){u(q)}),V(" addBorderSegments",function(){d(q)}),V(" order",function(){h(q)}),V(" insertSelfEdges",function(){K(q)}),V(" adjustCoordinateSystem",function(){p.adjust(q)}),V(" position",function(){v(q)}),V(" positionSelfEdges",function(){I(q)}),V(" removeBorderNodes",function(){Y(q)}),V(" normalize.undo",function(){i.undo(q)}),V(" fixupEdgeLabelCoords",function(){H(q)}),V(" undoCoordinateSystem",function(){p.undo(q)}),V(" translateGraph",function(){R(q)}),V(" assignNodeIntersects",function(){G(q)}),V(" reversePoints",function(){ne(q)}),V(" acyclic.undo",function(){r.undo(q)})}function E(q,V){e.forEach(q.nodes(),function(Q){var re=q.node(Q),ce=V.node(Q);re&&(re.x=ce.x,re.y=ce.y,V.children(Q).length&&(re.width=ce.width,re.height=ce.height))}),e.forEach(q.edges(),function(Q){var re=q.edge(Q),ce=V.edge(Q);re.points=ce.points,e.has(ce,"x")&&(re.x=ce.x,re.y=ce.y)}),q.graph().width=V.graph().width,q.graph().height=V.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},T=["acyclicer","ranker","rankdir","align"],C=["width","height"],A={width:0,height:0},j=["minlen","weight","width","height","labeloffset"],M={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function O(q){var V=new w({multigraph:!0,compound:!0}),Q=ae(q.graph());return V.setGraph(e.merge({},k,F(Q,x),e.pick(Q,T))),e.forEach(q.nodes(),function(re){var ce=ae(q.node(re));V.setNode(re,e.defaults(F(ce,C),A)),V.setParent(re,q.parent(re))}),e.forEach(q.edges(),function(re){var ce=ae(q.edge(re));V.setEdge(re,e.merge({},M,F(ce,j),e.pick(ce,z)))}),V}function B(q){var V=q.graph();V.ranksep/=2,e.forEach(q.edges(),function(Q){var re=q.edge(Q);re.minlen*=2,re.labelpos.toLowerCase()!=="c"&&(V.rankdir==="TB"||V.rankdir==="BT"?re.width+=re.labeloffset:re.height+=re.labeloffset)})}function U(q){e.forEach(q.edges(),function(V){var Q=q.edge(V);if(Q.width&&Q.height){var re=q.node(V.v),ce=q.node(V.w),he={rank:(ce.rank-re.rank)/2+re.rank,e:V};g.addDummyNode(q,"edge-proxy",he,"_ep")}})}function ee(q){var V=0;e.forEach(q.nodes(),function(Q){var re=q.node(Q);re.borderTop&&(re.minRank=q.node(re.borderTop).rank,re.maxRank=q.node(re.borderBottom).rank,V=e.max(V,re.maxRank))}),q.graph().maxRank=V}function X(q){e.forEach(q.nodes(),function(V){var Q=q.node(V);Q.dummy==="edge-proxy"&&(q.edge(Q.e).labelRank=Q.rank,q.removeNode(V))})}function R(q){var V=Number.POSITIVE_INFINITY,Q=0,re=Number.POSITIVE_INFINITY,ce=0,he=q.graph(),pe=he.marginx||0,je=he.marginy||0;function $e(Me){var Ae=Me.x,we=Me.y,Be=Me.width,ve=Me.height;V=Math.min(V,Ae-Be/2),Q=Math.max(Q,Ae+Be/2),re=Math.min(re,we-ve/2),ce=Math.max(ce,we+ve/2)}e.forEach(q.nodes(),function(Me){$e(q.node(Me))}),e.forEach(q.edges(),function(Me){var Ae=q.edge(Me);e.has(Ae,"x")&&$e(Ae)}),V-=pe,re-=je,e.forEach(q.nodes(),function(Me){var Ae=q.node(Me);Ae.x-=V,Ae.y-=re}),e.forEach(q.edges(),function(Me){var Ae=q.edge(Me);e.forEach(Ae.points,function(we){we.x-=V,we.y-=re}),e.has(Ae,"x")&&(Ae.x-=V),e.has(Ae,"y")&&(Ae.y-=re)}),he.width=Q-V+pe,he.height=ce-re+je}function G(q){e.forEach(q.edges(),function(V){var Q=q.edge(V),re=q.node(V.v),ce=q.node(V.w),he,pe;Q.points?(he=Q.points[0],pe=Q.points[Q.points.length-1]):(Q.points=[],he=ce,pe=re),Q.points.unshift(g.intersectRect(re,he)),Q.points.push(g.intersectRect(ce,pe))})}function H(q){e.forEach(q.edges(),function(V){var Q=q.edge(V);if(e.has(Q,"x"))switch((Q.labelpos==="l"||Q.labelpos==="r")&&(Q.width-=Q.labeloffset),Q.labelpos){case"l":Q.x-=Q.width/2+Q.labeloffset;break;case"r":Q.x+=Q.width/2+Q.labeloffset;break}})}function ne(q){e.forEach(q.edges(),function(V){var Q=q.edge(V);Q.reversed&&Q.points.reverse()})}function Y(q){e.forEach(q.nodes(),function(V){if(q.children(V).length){var Q=q.node(V),re=q.node(Q.borderTop),ce=q.node(Q.borderBottom),he=q.node(e.last(Q.borderLeft)),pe=q.node(e.last(Q.borderRight));Q.width=Math.abs(pe.x-he.x),Q.height=Math.abs(ce.y-re.y),Q.x=he.x+Q.width/2,Q.y=re.y+Q.height/2}}),e.forEach(q.nodes(),function(V){q.node(V).dummy==="border"&&q.removeNode(V)})}function L(q){e.forEach(q.edges(),function(V){if(V.v===V.w){var Q=q.node(V.v);Q.selfEdges||(Q.selfEdges=[]),Q.selfEdges.push({e:V,label:q.edge(V)}),q.removeEdge(V)}})}function K(q){var V=g.buildLayerMatrix(q);e.forEach(V,function(Q){var re=0;e.forEach(Q,function(ce,he){var pe=q.node(ce);pe.order=he+re,e.forEach(pe.selfEdges,function(je){g.addDummyNode(q,"selfedge",{width:je.label.width,height:je.label.height,rank:pe.rank,order:he+ ++re,e:je.e,label:je.label},"_se")}),delete pe.selfEdges})})}function I(q){e.forEach(q.nodes(),function(V){var Q=q.node(V);if(Q.dummy==="selfedge"){var re=q.node(Q.e.v),ce=re.x+re.width/2,he=re.y,pe=Q.x-ce,je=re.height/2;q.setEdge(Q.e,Q.label),q.removeNode(V),Q.label.points=[{x:ce+2*pe/3,y:he-je},{x:ce+5*pe/6,y:he-je},{x:ce+pe,y:he},{x:ce+5*pe/6,y:he+je},{x:ce+2*pe/3,y:he+je}],Q.label.x=Q.x,Q.label.y=Q.y}})}function F(q,V){return e.mapValues(e.pick(q,V),Number)}function ae(q){var V={};return e.forEach(q,function(Q,re){V[re.toLowerCase()]=Q}),V}return Om}var Lm,YE;function tL(){if(YE)return Lm;YE=1;var e=Je(),r=Yt(),i=jn().Graph;Lm={debugOrdering:o};function o(s){var u=r.buildLayerMatrix(s),l=new i({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(c){l.setNode(c,{label:c}),l.setParent(c,"layer"+s.node(c).rank)}),e.forEach(s.edges(),function(c){l.setEdge(c.v,c.w,{},c.name)}),e.forEach(u,function(c,d){var p="layer"+d;l.setNode(p,{rank:"same"}),e.reduce(c,function(h,v){return l.setEdge(h,v,{style:"invis"}),v})}),l}return Lm}var $m,XE;function nL(){return XE||(XE=1,$m="0.8.5"),$m}var Dm,QE;function rL(){return QE||(QE=1,Dm={graphlib:jn(),layout:eL(),debug:tL(),util:{time:Yt().time,notime:Yt().notime},version:nL()}),Dm}var iL=rL();const ZE=lv(iL),JE=240,ek=130,oL=110;function sL(e){var i;return((i=e.data)==null?void 0:i.sessionId)??"_default"}function aL(e,r,i,o){const s=new ZE.graphlib.Graph;s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:i,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=new Set(e);for(const w of e){const N=o.get(w);s.setNode(w,{width:(N==null?void 0:N.width)??JE,height:(N==null?void 0:N.height)??ek})}for(const w of r)u.has(w.source)&&u.has(w.target)&&s.setEdge(w.source,w.target);ZE.layout(s);const l=new Map;let c=1/0,d=1/0,p=-1/0,h=-1/0;for(const w of e){const N=s.node(w);if(!N)continue;const _=o.get(w),E=(_==null?void 0:_.width)??JE,x=(_==null?void 0:_.height)??ek,k=N.x-E/2,T=N.y-x/2;l.set(w,{x:k,y:T}),k<c&&(c=k),T<d&&(d=T),k+E>p&&(p=k+E),T+x>h&&(h=T+x)}if(Number.isFinite(c)&&Number.isFinite(d))for(const[w,N]of l)l.set(w,{x:N.x-c,y:N.y-d});const v=Number.isFinite(p)?p-c:0,g=Number.isFinite(h)?h-d:0;return{positions:l,width:v,height:g}}function tk(e,r,i={}){const o=i.direction??"LR",s=i.pinned??new Map,u=i.measured??new Map,l=new Map;for(const h of e){const v=sL(h),g=l.get(v);g?g.push(h.id):l.set(v,[h.id])}const c=Array.from(l.keys()).sort(),d=new Map;let p=0;for(const h of c){const v=l.get(h),{positions:g,height:w}=aL(v,r,o,u);for(const[N,_]of g)d.set(N,{x:_.x,y:_.y+p});p+=w+oL}return e.map(h=>{const v=s.get(h.id);if(v)return{...h,position:v};const g=d.get(h.id);return g?{...h,position:g}:h})}const uL=600;function sv(e,r){return!(e.exitAt!=null&&r-e.exitAt>uL||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function lL(e,r){const i=new Set;for(const o of e.agents.values())sv(o,r)&&i.add(o.id);return i}function Vr(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function cL(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const fL={agent:YM},dL=9e4,hL=200,pL=5*6e4,Kv="agent-dag.layout",Yv="agent-dag.viewport",LN="agent-dag.summariesDismissed",$N="agent-dag.sessionListOpen",DN="agent-dag.timelineOpen";function mL(){if(typeof window>"u")return!0;try{return window.localStorage.getItem($N)!=="0"}catch{return!0}}function vL(e){if(!(typeof window>"u"))try{window.localStorage.setItem($N,e?"1":"0")}catch{}}function gL(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(DN)!=="0"}catch{return!0}}function yL(e){if(!(typeof window>"u"))try{window.localStorage.setItem(DN,e?"1":"0")}catch{}}function wL(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(LN);if(!e)return new Set;const r=JSON.parse(e);return new Set(Array.isArray(r)?r.filter(i=>typeof i=="string"):[])}catch{return new Set}}function nk(e){if(!(typeof window>"u"))try{const r=Array.from(e),i=r.length>200?r.slice(-200):r;window.localStorage.setItem(LN,JSON.stringify(i))}catch{}}function _L(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Kv);if(!e)return[];const r=JSON.parse(e);return Object.entries(r).filter(([,i])=>i&&typeof i.x=="number"&&typeof i.y=="number")}catch{return[]}}function xL(e){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;window.localStorage.setItem(Kv,JSON.stringify(r))}catch{}}function SL(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Yv);if(!e)return null;const r=JSON.parse(e);return typeof(r==null?void 0:r.x)!="number"||typeof(r==null?void 0:r.y)!="number"||typeof(r==null?void 0:r.zoom)!="number"?null:r}catch{return null}}function EL(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Yv,JSON.stringify(e))}catch{}}function rk(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Kv)}catch{}try{window.localStorage.removeItem(Yv)}catch{}}}function kL(e,r){const i=e.agents.get(r);if(!i)return;const o=[];for(const h of e.agents.values())h.sessionId===r&&o.push(h);const s={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:r,label:i.label,cwd:i.cwd,startedAt:i.startedAt,endedAt:i.endedAt,model:i.model,agents:o.map(h=>({id:h.id,kind:h.kind,label:h.label,parentId:h.parentId,state:h.state,startedAt:h.startedAt,endedAt:h.endedAt,model:h.model,cwd:h.cwd,usage:h.usage,prompts:h.prompts,tools:h.tools.map(v=>({id:v.id,name:v.name,inputPreview:v.inputPreview,startedAt:v.startedAt,endedAt:v.endedAt,ok:v.ok,errorPreview:v.errorPreview,usage:v.usage}))}))},u=JSON.stringify(s,null,2),l=new Blob([u],{type:"application/json"}),c=URL.createObjectURL(l),d=document.createElement("a"),p=(i.label||"session").replace(/[^a-z0-9._-]/gi,"_");d.href=c,d.download=`agent-dag-${p}-${r.slice(0,8)}.json`,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const av={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},uv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},bL={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",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 FN(e){return e.startsWith("mcp__")?"mcp":bL[e]??"other"}function zN(e,r){var o,s,u;if(!r)return!0;const i=r.toLowerCase();if(e.label.toLowerCase().includes(i)||(o=e.cwd)!=null&&o.toLowerCase().includes(i)||(s=e.cwdBasename)!=null&&s.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 NL(e,r){if(!r)return null;const i=new Set([r]);let o=r;for(;o;){const u=e.agents.get(o);if(!(u!=null&&u.parentId)||i.has(u.parentId))break;i.add(u.parentId),o=u.parentId}let s=!0;for(;s;){s=!1;for(const u of e.agents.values())u.parentId&&i.has(u.parentId)&&!i.has(u.id)&&(i.add(u.id),s=!0)}return i}function CL(e,r,i,o,s,u,l,c,d,p,h,v){const g=[],w=[],N=new Set;if(o)for(const x of e.agents.values())zN(x,o)&&N.add(x.id);for(const x of e.agents.values()){if(!h.has(x.id))continue;const k=o?!N.has(x.id):!1,T=x.exitAt!=null,C=p!=null&&!p.has(x.id),A=[k?"rf-dim":"",T?"rf-exiting":"",C?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,j=s.get(x.id);if(g.push({id:x.id,type:"agent",position:{x:0,y:0},data:{...x,now:r,dim:k,onOpenContext:v},className:A,...j?{width:j.width,height:j.height}:null}),x.parentId&&h.has(x.parentId)){const M=Tv(x.sessionId),z=x.state==="active"?`hsl(${M} 80% 72%)`:`hsl(${M} 50% 55%)`,O=o&&!N.has(x.id)&&!N.has(x.parentId),B=T,U=d.size>0&&(d.has(x.id)||d.has(x.parentId)),ee=p!=null&&!p.has(x.id)&&!p.has(x.parentId),X=x.state==="active"?2:1.5,R=U?X+1.5:X,G=O||B?.2:ee?.12:1,H=[B?"rf-edge-exiting":"",U?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;w.push({id:`e:${x.parentId}->${x.id}`,source:x.parentId,target:x.id,animated:(x.state==="active"||U)&&!O&&!B,type:"smoothstep",style:{stroke:z,strokeWidth:R,opacity:G,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:H})}}if(l!==c.current){const x=tk(g,w,{direction:"LR",pinned:i,measured:s});for(const k of x)u.set(k.id,k.position);c.current=l}else if(g.filter(k=>!i.has(k.id)&&!u.has(k.id)).length>0){const k=tk(g,w,{direction:"LR",pinned:i,measured:s});for(const T of k)u.has(T.id)||u.set(T.id,T.position)}for(const x of Array.from(u.keys()))e.agents.has(x)||u.delete(x);const _=[];let E=!1;for(const x of g){let k=i.get(x.id)??u.get(x.id);k||(k={x:0,y:0},u.set(x.id,k),E=!0),_.push({...x,position:k})}return E&&(c.current=""),{nodes:_,edges:w}}function TL(){return S.jsx(Nv,{children:S.jsx(RL,{})})}function RL(){const e=ts(),r=D.useRef(nv()),[,i]=D.useState(0),o=D.useCallback(()=>i(oe=>oe+1),[]),[s,u]=D.useState(()=>new Set),[l,c]=D.useState(null),[d,p]=D.useState(null),h=D.useCallback((oe,se)=>{u(Se=>{if(!se)return new Set([oe]);const Te=new Set(Se);return Te.has(oe)?Te.delete(oe):Te.add(oe),Te}),c(Se=>se&&Se===oe?Se:oe)},[]),v=D.useCallback(()=>{u(new Set),c(null)},[]),[g,w]=D.useState(null),[N,_]=D.useState(null),E=D.useCallback(oe=>_(oe),[]),x=D.useRef(wL()),[k,T]=D.useState(mL);D.useEffect(()=>{vL(k)},[k]);const[C,A]=D.useState(gL);D.useEffect(()=>{yL(C)},[C]);const[j,M]=D.useState(!1),[z,O]=D.useState(!1),B=D.useRef([]),[U,ee]=D.useState(Date.now()),X=D.useRef(new Map(_L())),R=D.useState(()=>SL())[0],[G,H]=D.useState(""),[ne,Y]=D.useState(()=>new Set),[L,K]=D.useState(()=>typeof window>"u"?"dark":window.localStorage.getItem("agent-dag.theme")??"dark"),[I,F]=D.useState(!1),ae=D.useRef(null);D.useEffect(()=>{document.documentElement.dataset.theme=L;try{window.localStorage.setItem("agent-dag.theme",L)}catch{}},[L]),D.useEffect(()=>{if(!R)return;const oe=window.setTimeout(()=>{try{e.setViewport(R,{duration:0})}catch{}},60);return()=>window.clearTimeout(oe)},[e,R]);const q=D.useRef(!0),V=D.useRef(null);D.useEffect(()=>{const oe=new EventSource("/events");return oe.addEventListener("open",()=>{M(!0),F(!0)}),oe.addEventListener("error",()=>M(!1)),oe.addEventListener("replay-end",()=>{q.current=!1,V.current!=null&&(window.clearTimeout(V.current),V.current=null),o()}),oe.addEventListener("hook",se=>{try{const Se=JSON.parse(se.data);if(z){B.current.push(Se);return}r.current=Sw(r.current,Se),Se.replay===!0||q.current||Date.now()-Se.receivedAt>3e4?(V.current!=null&&window.clearTimeout(V.current),V.current=window.setTimeout(()=>{V.current=null,o()},120)):(V.current!=null&&(window.clearTimeout(V.current),V.current=null),o())}catch{}}),()=>{oe.close(),V.current!=null&&(window.clearTimeout(V.current),V.current=null)}},[z,o]),D.useEffect(()=>{if(!z&&B.current.length!==0){for(const oe of B.current)r.current=Sw(r.current,oe);B.current.length=0,o()}},[z,o]),D.useEffect(()=>{const oe=setInterval(()=>{const se=Date.now();ee(se);let Se=FM(r.current,se,dL);if(DM(r.current,se,hL,pL)&&(Se=!0),se-je.current>=1e3){je.current=se;let Te=0;for(const Ie of r.current.agents.values())Te+=An(Ie.usage,Ie.model).total;const be=pe.current;be.push({t:se,cost:Te}),be.length>240&&be.shift()}Se&&o()},250);return()=>clearInterval(oe)},[o]);const Q=D.useRef(null),re=D.useRef(0),ce=D.useRef(""),he=D.useRef(null),pe=D.useRef([]),je=D.useRef(0),$e=D.useRef(0),Me=D.useCallback(()=>{$e.current=Date.now()},[]),Ae="agent-dag.autoFitDisabled",we=D.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ae)==="1"}catch{return!1}})()),[Be,ve]=D.useState(we.current),ge=D.useCallback(()=>{if(!we.current){we.current=!0,ve(!0);try{window.localStorage.setItem(Ae,"1")}catch{}}},[]),ze=D.useCallback(()=>{we.current=!1,ve(!1);try{window.localStorage.removeItem(Ae)}catch{}try{e.fitView({padding:.25,duration:400})}catch{}},[e]);D.useEffect(()=>{const oe=setInterval(()=>{if(we.current||Date.now()-$e.current<800)return;const se=r.current,Se=Date.now(),Te=[];for(const Tt of se.agents.values())sv(Tt,Se)&&Te.push({id:Tt.id});if(Te.length===0)return;const be=e.getViewport(),Ie=window.innerWidth-360,st=window.innerHeight-52;let wn=!1,Zt=!1;for(const{id:Tt}of Te){const Rt=et.current.get(Tt),on=X.current.get(Tt)??Ge.current.get(Tt);if(!Rt||!on)continue;Zt=!0;const or=on.x*be.zoom+be.x,jr=on.y*be.zoom+be.y,Wi=(on.x+Rt.width)*be.zoom+be.x,Gi=(on.y+Rt.height)*be.zoom+be.y;if(Wi>0&&or<Ie&&Gi>0&&jr<st){wn=!0;break}}if(Zt&&!wn)try{e.fitView({padding:.25,duration:600})}catch{}},1500);return()=>clearInterval(oe)},[e]);const et=D.useRef(new Map),ft=D.useRef(0),lt=D.useCallback(oe=>{const se=et.current;let Se=!1;for(const Te of oe.nodeInternals.values()){const be=Te.width,Ie=Te.height;if(be==null||Ie==null)continue;const st=se.get(Te.id);st?(Math.abs(st.height-Ie)>4||Math.abs(st.width-be)>4)&&(se.set(Te.id,{width:be,height:Ie}),Se=!0):(se.set(Te.id,{width:be,height:Ie}),Se=!0)}return Se&&(ft.current+=1),ft.current},[]),Ue=Fe(lt),Ge=D.useRef(new Map),xt=D.useRef(""),St=D.useMemo(()=>{const oe=[];for(const se of r.current.agents.values())sv(se,U)&&oe.push(se.id+(se.parentId?`>${se.parentId}`:""));return oe.sort(),`${oe.join("|")}#sv${Ue}`},[r.current,r.current.lastSeq,U,Ue]);D.useEffect(()=>{if(ce.current===St)return;const oe=ce.current;if(ce.current=St,!oe||we.current)return;const se=Date.now();if(se-re.current>1200){try{e.fitView({padding:.25,duration:400})}catch{}re.current=se}Q.current&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{if(!we.current){try{e.fitView({padding:.25,duration:500})}catch{}re.current=Date.now()}},280)},[St,e]);const Et=D.useMemo(()=>{if(s.size===0)return null;const oe=new Set;for(const se of s){const Se=NL(r.current,se);if(Se)for(const Te of Se)oe.add(Te)}return oe.size>0?oe:null},[r.current,r.current.lastSeq,s]),tt=D.useMemo(()=>lL(r.current,U),[r.current,r.current.lastSeq,U]),{nodes:mt,edges:Mt}=D.useMemo(()=>CL(r.current,U,X.current,G,et.current,Ge.current,St,xt,s,Et,tt,E),[r.current,r.current.lastSeq,U,G,St,s,Et,tt,E]),He=D.useMemo(()=>{if(!G)return null;const oe=new Set;for(const se of r.current.agents.values())zN(se,G)&&oe.add(se.id);return oe},[r.current,r.current.lastSeq,G]),vt=D.useMemo(()=>{const oe=new Set;for(const se of r.current.agents.values())for(const Se of se.tools)oe.add(FN(Se.name));return Object.keys(av).filter(se=>oe.has(se))},[r.current,r.current.lastSeq]),Ke=D.useMemo(()=>{const oe=new Map;for(const Se of r.current.agents.values())for(const Te of Se.tools){if(!Te.name.startsWith("mcp__"))continue;const be=Te.name.slice(5),Ie=be.indexOf("__"),st=Ie>0?be.slice(0,Ie):be;oe.set(st,(oe.get(st)??0)+1)}const se=[];for(const[Se,Te]of oe){let be=5381;for(let Ie=0;Ie<Se.length;Ie++)be=(be<<5)+be^Se.charCodeAt(Ie);se.push({server:Se,count:Te,hue:Math.abs(be)%360})}return se.sort((Se,Te)=>Te.count-Se.count),se},[r.current,r.current.lastSeq]),dt=D.useCallback(oe=>{Y(se=>{const Se=new Set(se);return Se.has(oe)?Se.delete(oe):Se.add(oe),Se})},[]),Qe=l?r.current.agents.get(l):null,Pt=d?Array.from(r.current.agents.values()).flatMap(oe=>oe.tools).find(oe=>oe.id===d)??null:null,kt=D.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}r.current=nv(),X.current.clear(),et.current.clear(),Ge.current.clear(),xt.current="",rk(),v(),o()},[o,v]),Xt=D.useCallback(()=>{X.current.clear(),Ge.current.clear(),xt.current="",rk(),o(),window.setTimeout(()=>{try{e.fitView({padding:.25,duration:500})}catch{}re.current=Date.now()},80)},[o,e]),qn=D.useCallback(()=>{try{e.fitView({padding:.25,duration:500})}catch{}re.current=Date.now()},[e]),Qt=D.useCallback(oe=>{if(mt.length===0)return;const se=mt.slice().sort((Ie,st)=>Ie.position.y-st.position.y||Ie.position.x-st.position.x),Se=l?se.findIndex(Ie=>Ie.id===l):-1;let Te;Se===-1?Te=oe===1?0:se.length-1:Te=(Se+oe+se.length)%se.length;const be=se[Te];be&&(h(be.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[be]})}catch{}re.current=Date.now()},30))},[mt,l,h,e]);D.useEffect(()=>{const oe=se=>{var Te,be;const Se=((Te=se.target)==null?void 0:Te.tagName)==="INPUT";if(se.key==="Escape"){Se?se.target.blur():v();return}if(!Se){if(se.key==="/"){se.preventDefault(),(be=ae.current)==null||be.focus();return}se.key===" "&&(se.preventDefault(),O(Ie=>!Ie)),(se.key==="c"||se.key==="C")&&kt(),(se.key==="r"||se.key==="R")&&Xt(),(se.key==="f"||se.key==="F")&&qn(),(se.key==="l"||se.key==="L")&&T(Ie=>!Ie),(se.key==="h"||se.key==="H")&&A(Ie=>!Ie),(se.key==="j"||se.key==="J")&&Qt(1),(se.key==="k"||se.key==="K")&&Qt(-1),(se.key==="t"||se.key==="T")&&K(Ie=>Ie==="dark"?"light":"dark")}};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[kt,Xt,qn,v,Qt]);const Dt=r.current.agents.size,yn=new Set(Array.from(r.current.agents.values()).map(oe=>oe.sessionId)).size,nt=D.useMemo(()=>{let oe=0,se=0,Se=0,Te=0,be=0,Ie=0,st=0,wn=0,Zt=0;for(const Tt of r.current.agents.values()){oe+=Tt.usage.inputTokens,se+=Tt.usage.outputTokens,Se+=Tt.usage.cacheReadTokens,Te+=Tt.usage.cacheCreateTokens;const Rt=An(Tt.usage,Tt.model);be+=Rt.total,Ie+=Rt.input,st+=Rt.output,wn+=Rt.cacheRead,Zt+=Rt.cacheWrite}return{inT:oe,outT:se,cacheR:Se,cacheC:Te,sum:oe+se,cost:{total:be,input:Ie,output:st,cacheRead:wn,cacheWrite:Zt}}},[r.current,r.current.lastSeq]);return S.jsxs("div",{className:"app",children:[S.jsxs("header",{className:"topbar",children:[S.jsxs("div",{className:"brand",children:[S.jsx("span",{className:"logo"}),"agent-dag ",S.jsxs("span",{className:"v",children:["v","1.15.5"]})]}),Qe&&(()=>{const oe=An(Qe.usage,Qe.model),se=Math.max(0,((Qe.endedAt??U)-Qe.startedAt)/1e3),Se=Qe.state==="active"?iv(oe.total,se):null,Te=s.size-1;return S.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Qe.label}`,onClick:()=>{try{const be=mt.find(Ie=>Ie.id===Qe.id);be&&e.fitView({padding:.35,duration:500,nodes:[be]}),re.current=Date.now()}catch{}},children:[S.jsx("span",{className:`state-pill state-${Qe.state}`,children:Qe.state==="active"?"live":Qe.state}),S.jsx("span",{className:"selected-label",children:Qe.label}),oe.total>0&&S.jsxs("span",{className:"selected-cost",children:[We(oe.total),Se?S.jsxs("span",{className:"selected-rate",children:[" · ",Se]}):null]}),Te>0&&S.jsxs("span",{className:"selected-extra",children:["+",Te]}),S.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:be=>{be.stopPropagation(),v()},children:"×"})]})})(),S.jsxs("div",{className:"actions",children:[S.jsxs("div",{className:"search",children:[S.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),S.jsx("input",{ref:ae,type:"text",placeholder:"Search agents, cwd, tools…",value:G,onChange:oe=>H(oe.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),G?S.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>H(""),children:"×"}):S.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),S.jsxs("span",{className:"status",role:"status",children:[S.jsx("span",{className:`pill ${j?"live":"dead"}`,title:j?"Receiving events":"SSE disconnected",children:j?"live":"offline"}),S.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[S.jsx("span",{className:"count",children:yn}),S.jsx("span",{className:"lbl",children:"sessions"})]}),S.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[S.jsx("span",{className:"count",children:Dt}),S.jsx("span",{className:"lbl",children:"agents"})]}),S.jsxs("span",{className:"stat",title:"Total hook events received",children:[S.jsx("span",{className:"count",children:r.current.totalEvents}),S.jsx("span",{className:"lbl",children:"events"})]}),nt.sum>0&&S.jsxs("span",{className:"stat",title:`in:${nt.inT.toLocaleString()} out:${nt.outT.toLocaleString()} cache-r:${nt.cacheR.toLocaleString()} cache-c:${nt.cacheC.toLocaleString()}`,children:[S.jsx("span",{className:"count",children:cL(nt.sum)}),S.jsx("span",{className:"lbl",children:"tokens"})]}),Ke.length>0&&S.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
60
60
  ${Ke.map(oe=>` ${oe.server}: ${oe.count} call${oe.count===1?"":"s"}`).join(`
61
61
  `)}`,children:[Ke.slice(0,6).map(oe=>S.jsx("span",{className:"mcp-dot",style:{background:`hsl(${oe.hue} 65% 65%)`}},oe.server)),Ke.length>6&&S.jsxs("span",{className:"mcp-more",children:["+",Ke.length-6]}),S.jsx("span",{className:"lbl",children:"mcp"})]}),nt.cost.total>0&&(()=>{let oe=0,se=0;for(const be of r.current.agents.values()){if(be.state!=="active")continue;const Ie=An(be.usage,be.model);oe+=Ie.total,se=Math.max(se,((be.endedAt??U)-be.startedAt)/1e3)}const Se=se>0?iv(oe,se):null,Te=`input ${We(nt.cost.input)} + output ${We(nt.cost.output)} + cache r ${We(nt.cost.cacheRead)} + cache w ${We(nt.cost.cacheWrite)}${Se?`
62
62
  active burn: ${Se}`:""}`;return S.jsxs("span",{className:"stat",title:Te,children:[S.jsx("span",{className:"count",children:We(nt.cost.total)}),S.jsxs("span",{className:"lbl",children:["cost",Se?` · ${Se}`:""]})]})})()]}),S.jsx("button",{className:`btn ${z?"warn":""}`,onClick:()=>O(oe=>!oe),title:"Pause/resume live updates (Space)",children:z?`Resume${B.current.length?` · ${B.current.length}`:""}`:"Pause"}),S.jsx("button",{className:`btn icon-btn ${k?"primary":""}`,onClick:()=>T(oe=>!oe),title:`${k?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list",children:"☰"}),S.jsx("button",{className:`btn icon-btn ${C?"primary":""}`,onClick:()=>A(oe=>!oe),title:`${C?"Hide":"Show"} activity timeline (H)`,"aria-label":"Toggle activity timeline",children:"⏱"}),S.jsx("button",{className:"btn",onClick:Xt,title:"Auto-arrange — clear pins (R)",children:"Re-layout"}),S.jsx("button",{className:"btn",onClick:kt,title:"Clear canvas (C)",children:"Clear"}),S.jsx("button",{className:"btn icon-btn",onClick:()=>K(oe=>oe==="dark"?"light":"dark"),title:`Switch to ${L==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:L==="dark"?"☀":"☾"})]})]}),I&&!j&&S.jsxs("div",{className:"conn-banner",role:"alert",children:[S.jsx("span",{className:"conn-dot"}),"Lost connection to agent-dag server. Reconnecting…"]}),k&&S.jsx(qP,{state:r.current,now:U,selectedIds:s,onSelect:oe=>{h(oe,!1),window.setTimeout(()=>{try{const se=mt.find(Se=>Se.id===oe);se&&e.fitView({padding:.3,duration:500,nodes:[se]}),re.current=Date.now()}catch{}},60)},onClose:()=>T(!1)}),S.jsxs("div",{className:"canvas-wrap",children:[Dt===0&&S.jsx(AL,{live:j,everConnected:I}),vt.length>1&&S.jsx("div",{className:"cat-filter-bar",role:"toolbar","aria-label":"Filter tools by category",children:vt.map(oe=>{const se=ne.has(oe);return S.jsxs("button",{type:"button",className:`cat-filter${se?" off":""}`,onClick:()=>dt(oe),title:`${se?"Show":"Hide"} ${uv[oe]} tools`,children:[S.jsx("span",{className:"cat-emoji",children:av[oe]}),S.jsx("span",{className:"cat-name",children:uv[oe]})]},oe)})}),S.jsxs(Sb,{nodes:mt,edges:Mt,nodeTypes:fL,fitView:!R,fitViewOptions:{padding:.25,duration:400},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,onNodeClick:(oe,se)=>h(se.id,oe.shiftKey),onPaneClick:()=>v(),onMoveStart:()=>{ge()},onMove:(oe,se)=>{Me(),he.current&&window.clearTimeout(he.current),he.current=window.setTimeout(()=>EL(se),250)},onNodeDragStart:(oe,se)=>{Me(),ge(),X.current.set(se.id,{x:se.position.x,y:se.position.y})},onNodeDrag:(oe,se)=>{Me(),X.current.set(se.id,{x:se.position.x,y:se.position.y}),Ge.current.set(se.id,{x:se.position.x,y:se.position.y})},onNodeDragStop:(oe,se)=>{Me(),X.current.set(se.id,{x:se.position.x,y:se.position.y}),Ge.current.set(se.id,{x:se.position.x,y:se.position.y}),xL(X.current)},children:[S.jsx(PM,{gap:28,size:1,color:Vr("--grid-line")}),S.jsx(iP,{}),S.jsx(RP,{agents:r.current.agents,visibleAgentIds:tt,positions:Ge.current,pinned:X.current,measured:et.current,dimUnmatched:He,spotlight:Et,hiddenCategories:ne,now:U,onOpenTool:p}),S.jsx(TM,{showInteractive:!1,children:S.jsx(Mi,{onClick:ze,title:Be?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:Be?{color:"var(--accent)"}:void 0,children:S.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[S.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),S.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})})}),S.jsx(xM,{zoomable:!0,pannable:!0,nodeColor:oe=>{const se=oe.data;return se.state==="err"?Vr("--err"):se.state==="active"?Vr("--inflight"):Vr("--ok")},nodeStrokeWidth:2,maskColor:Vr("--minimap-mask"),style:{background:Vr("--panel"),border:`1px solid ${Vr("--line")}`,borderRadius:8}})]}),C&&Dt>0&&S.jsx(zP,{agents:r.current.agents,visibleAgentIds:tt,now:U,costSamples:pe.current,onSelect:oe=>h(oe,!1),onOpenTool:p,onClose:()=>A(!1)})]}),S.jsx("aside",{className:"detail",children:Qe?S.jsx(ML,{agent:Qe,now:U,onOpenTool:p,onShowSummary:oe=>{x.current.has(oe)&&(x.current.delete(oe),nk(x.current)),w(oe)},onExportSession:oe=>kL(r.current,oe)}):S.jsx(jL,{count:Dt})}),Pt&&S.jsx(eP,{tool:Pt,onClose:()=>p(null)}),N&&(()=>{const oe=r.current.agents.get(N);return oe?S.jsx(VM,{agent:oe,onClose:()=>_(null)}):null})(),g&&S.jsx(AP,{state:r.current,sessionId:g,onClose:()=>{x.current.add(g),nk(x.current),w(null)}})]})}function AL({live:e,everConnected:r}){const i=!e;return S.jsxs("div",{className:"empty-hero",children:[S.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[S.jsx("div",{className:"core"}),S.jsxs("div",{className:"orbit r1",children:[S.jsx("span",{className:"dot"}),S.jsx("span",{className:"dot b"})]}),S.jsxs("div",{className:"orbit r2",children:[S.jsx("span",{className:"dot"}),S.jsx("span",{className:"dot b"})]}),S.jsxs("div",{className:"orbit r3",children:[S.jsx("span",{className:"dot"}),S.jsx("span",{className:"dot b"})]})]}),i?S.jsxs(S.Fragment,{children:[S.jsx("h2",{children:r?"Disconnected from server":"Server unreachable"}),S.jsxs("p",{children:["The browser cannot reach ",S.jsx("code",{children:"/events"}),". Check that",S.jsx("code",{children:"agent-dag"})," is still running in your terminal, then this page will resume automatically."]})]}):IL()]})}function IL(){return S.jsxs(S.Fragment,{children:[S.jsx("h2",{children:"Waiting for Claude Code"}),S.jsxs("p",{children:["Run ",S.jsx("code",{children:"claude"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),S.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",S.jsx("code",{children:"agent-dag"})," is running and that the hook is installed in ",S.jsx("code",{children:"~/.claude/settings.json"}),"."]})]})}function jL({count:e}){return S.jsxs(S.Fragment,{children:[S.jsx("h3",{children:"Detail"}),e===0?S.jsxs("div",{className:"hint",children:["No data yet. Start a Claude Code session anywhere on this machine — agent-dag is in ",S.jsx("code",{children:"--all"})," mode and listens to every workspace."]}):S.jsx("div",{className:"empty",children:"Click an agent to see its tools."}),S.jsx("h3",{style:{marginTop:4},children:"Shortcuts"}),S.jsxs("div",{className:"shortcuts",children:[S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"drag"}),S.jsx("span",{children:"move a node"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"/"}),S.jsx("span",{children:"focus search"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"space"}),S.jsx("span",{children:"pause / resume"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"J"}),S.jsx("span",{children:"next agent"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"K"}),S.jsx("span",{children:"previous agent"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"R"}),S.jsx("span",{children:"re-arrange"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"F"}),S.jsx("span",{children:"fit view"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"L"}),S.jsx("span",{children:"session list"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"H"}),S.jsx("span",{children:"activity timeline"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"C"}),S.jsx("span",{children:"clear canvas"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"T"}),S.jsx("span",{children:"toggle theme"})]}),S.jsxs("div",{className:"sc",children:[S.jsx("kbd",{children:"Esc"}),S.jsx("span",{children:"deselect"})]})]})]})}function ML({agent:e,now:r,onOpenTool:i,onShowSummary:o,onExportSession:s}){const u=(e.endedAt??r)-e.startedAt,l=Math.max(0,Math.floor(u/1e3)),c=l<60?`${l}s`:`${Math.floor(l/60)}m ${String(l%60).padStart(2,"0")}s`,d=An(e.usage,e.model),p=d.total>0,h=e.usage.inputTokens+e.usage.outputTokens,v=new Map;for(const _ of e.tools){const E=FN(_.name);v.set(E,(v.get(E)??0)+1)}const g=e.tools.filter(_=>_.ok===!1).length,w=e.tools.filter(_=>!_.endedAt).length,N=Array.from(v.entries()).sort((_,E)=>E[1]-_[1]);return S.jsxs(S.Fragment,{children:[S.jsxs("header",{className:"detail-hero",children:[S.jsxs("div",{className:"hero-line",children:[S.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),S.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),S.jsxs("div",{className:"hero-meta",children:[S.jsx("span",{className:"hero-meta-item",children:e.kind}),S.jsx("span",{className:"hero-sep",children:"·"}),S.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:c}),e.model&&S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"hero-sep",children:"·"}),S.jsx("span",{className:"model-chip",title:e.model,children:tu(e.model)})]})]}),p&&S.jsxs("div",{className:"hero-cost",children:[S.jsxs("div",{className:"hero-cost-headline",children:[S.jsx("span",{className:"hero-cost-value",children:We(d.total)}),S.jsx("span",{className:"hero-cost-label",children:"spend"})]}),S.jsx(PL,{cost:d})]}),S.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&o&&S.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>o(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),s&&S.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&S.jsxs("section",{className:"detail-section",children:[S.jsx("h3",{children:"Activity"}),S.jsxs("div",{className:"activity-row",children:[S.jsxs("div",{className:"activity-counters",children:[S.jsxs("span",{className:"ac-item",children:[S.jsx("b",{children:e.toolCount})," calls"]}),w>0&&S.jsxs("span",{className:"ac-item ac-live",children:[S.jsx("b",{children:w})," live"]}),g>0&&S.jsxs("span",{className:"ac-item ac-err",children:[S.jsx("b",{children:g})," err"]})]}),S.jsx("div",{className:"cat-strip",children:N.map(([_,E])=>S.jsxs("span",{className:`cat-chip cat-${_}`,title:`${E} ${uv[_]} call${E===1?"":"s"}`,children:[S.jsx("span",{className:"cat-emoji",children:av[_]}),S.jsx("span",{className:"cat-count",children:E})]},_))})]})]}),h>0&&S.jsxs("section",{className:"detail-section",children:[S.jsx("h3",{children:"Tokens"}),S.jsxs("div",{className:"tokens-grid",children:[S.jsxs("div",{children:[S.jsx("span",{className:"k",children:"in"}),S.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),S.jsxs("div",{children:[S.jsx("span",{className:"k",children:"out"}),S.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),S.jsxs("div",{children:[S.jsx("span",{className:"k",children:"cache r"}),S.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),S.jsxs("div",{children:[S.jsx("span",{className:"k",children:"cache c"}),S.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),S.jsxs("section",{className:"detail-section",children:[S.jsx("h3",{children:"Identity"}),S.jsxs("div",{children:[e.cwd&&S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"cwd"}),S.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"session"}),S.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&S.jsxs("div",{className:"row",children:[S.jsx("span",{className:"k",children:"parent"}),S.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&S.jsxs("section",{className:"detail-section",children:[S.jsxs("h3",{children:["Prompts ",S.jsx("span",{className:"section-count",children:e.prompts.length})]}),S.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((_,E)=>S.jsxs("div",{className:"prompt-entry",children:[S.jsx("div",{className:"prompt-time",children:new Date(_.at).toLocaleTimeString()}),S.jsx("div",{className:"prompt-text",children:_.text})]},E))})]}),S.jsxs("section",{className:"detail-section",children:[S.jsxs("h3",{children:["Tool calls ",S.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&S.jsx("div",{className:"empty",children:"No tool calls yet."}),S.jsx("div",{children:e.tools.slice().reverse().map(_=>S.jsx(qL,{t:_,now:r,onClick:()=>i(_.id)},_.id))})]})]})}function PL({cost:e}){const r=e.total;if(r<=0)return null;const i=(o,s,u)=>{if(o<=0)return null;const l=o/r*100;return S.jsx("span",{className:`cb-seg ${s}`,style:{width:`${l}%`},title:`${u}: ${We(o)} (${l.toFixed(0)}%)`},s)};return S.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 qL({t:e,now:r,onClick:i}){const o=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=(e.endedAt??r)-e.startedAt,u=e.endedAt==null?"…":s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`;return S.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:i,children:[S.jsxs("span",{className:"name",children:[S.jsx("span",{className:`status-dot ${o}`}),e.name]}),S.jsx("span",{style:{color:"var(--muted)"},children:u})]})}const OL=M2.createRoot(document.getElementById("root"));OL.render(S.jsx(TL,{}));