@cotal-ai/web 0.182.0 → 0.182.1
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.
|
@@ -10,5 +10,5 @@ Error generating stack: `+e.message+`
|
|
|
10
10
|
`).replace(Qf,``)}function ep(e,t){return t=$f(t),$f(e)===t}function $(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||_n(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&_n(e,``+r);else return;break;case`className`:tn(e,`class`,r);break;case`tabIndex`:tn(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:tn(e,n,r);break;case`style`:bn(e,r,o);return;case`data`:if(t!==`object`){tn(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=wn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&$(e,t,`name`,a.name,a,null),$(e,t,`formEncType`,a.formEncType,a,null),$(e,t,`formMethod`,a.formMethod,a,null),$(e,t,`formTarget`,a.formTarget,a,null)):($(e,t,`encType`,a.encType,a,null),$(e,t,`method`,a.method,a,null),$(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=wn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Tn);return;case`onScroll`:r!=null&&Q(`scroll`,e);return;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=wn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Q(`beforetoggle`,e),Q(`toggle`,e),en(e,`popover`,r);break;case`xlinkActuate`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:nn(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:nn(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:nn(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:nn(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:en(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=Sn.get(n)||n,en(e,n,r);else return}j=!0}function tp(e,t,n,r,a,o){switch(n){case`style`:bn(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)_n(e,r);else if(typeof r==`number`||typeof r==`bigint`)_n(e,``+r);else return;break;case`onScroll`:r!=null&&Q(`scroll`,e);return;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=Tn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Kt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[At]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}j=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):en(e,n,r)}return}j=!0}function np(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Q(`error`,e),Q(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:$(e,t,o,s,n,null)}}a&&$(e,t,`srcSet`,n.srcSet,n,null),r&&$(e,t,`src`,n.src,n,null);return;case`input`:Q(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:$(e,t,r,d,n,null)}}fn(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Q(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:$(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&mn(e,!!r,n,!0):mn(e,!!r,t,!1);return;case`textarea`:for(s in Q(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:$(e,t,s,c,n,null)}gn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:$(e,t,l,r,n,null)}return;case`dialog`:Q(`beforetoggle`,e),Q(`toggle`,e),Q(`cancel`,e),Q(`close`,e);break;case`iframe`:case`object`:Q(`load`,e);break;case`video`:case`audio`:for(r=0;r<zf.length;r++)Q(zf[r],e);break;case`image`:Q(`error`,e),Q(`load`,e);break;case`details`:Q(`toggle`,e);break;case`embed`:case`source`:case`link`:Q(`error`,e),Q(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:$(e,t,u,r,n,null)}return;default:if(xn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&tp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&$(e,t,c,r,n,null))}var rp={};function ip(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||$(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(j=!0),o=m;break;case`name`:m!==f&&(j=!0),a=m;break;case`checked`:m!==f&&(j=!0),u=m;break;case`defaultChecked`:m!==f&&(j=!0),d=m;break;case`value`:m!==f&&(j=!0),s=m;break;case`defaultValue`:m!==f&&(j=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&$(e,t,p,m,r,f)}}dn(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||$(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(j=!0),p=o;break;case`defaultValue`:o!==l&&(j=!0),c=o;break;case`multiple`:o!==l&&(j=!0),s=o;default:o!==l&&$(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?mn(e,!!n,n?[]:``,!1):mn(e,!!n,t,!0)):mn(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:$(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(j=!0),p=a;break;case`defaultValue`:a!==o&&(j=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&$(e,t,s,a,r,o)}hn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:$(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(j=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:$(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&$(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:$(e,t,u,p,r,m)}return;default:if(xn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&tp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||tp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&$(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||$(e,t,f,p,r,m)}function ap(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function op(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&ap(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var sp=null,cp=null;function lp(e){return e.nodeType===9?e:e.ownerDocument}function up(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function dp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function fp(e,t,n,r){return n=lp(n).createElement(e),n[kt]=r,n[At]=t,np(n,e,t),Ut(n),n}function pp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var mp=null;function hp(){var e=window.event;return e&&e.type===`popstate`?e!==mp&&(mp=e,!0):(mp=null,!1)}var gp=typeof setTimeout==`function`?setTimeout:void 0,_p=typeof clearTimeout==`function`?clearTimeout:void 0,vp=typeof Promise==`function`?Promise:void 0,yp=typeof requestAnimationFrame==`function`?requestAnimationFrame:gp,bp=typeof queueMicrotask==`function`?queueMicrotask:vp===void 0?gp:function(e){return vp.resolve(null).then(e).catch(xp)};function xp(e){setTimeout(function(){throw e})}function Sp(e){return e===`head`}function Cp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Hh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_m(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_m(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[It]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_m(e.ownerDocument.body)}n=i}while(n);Hh(t)}function wp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Tp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Ep(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Dp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Op(e){return Dp(e.getBoundingClientRect(),getComputedStyle(e),e)}function kp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Dp(t,n,e)}function Ap(e){return e.documentElement.clientHeight}function jp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Mp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Ap(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Xm(f),u>$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Np(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Np.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Np.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Np.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Pp(e){return{name:e,group:new Np(`group`,e),imagePair:new Np(`image-pair`,e),old:new Np(`old`,e),new:new Np(`new`,e)}}function Fp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Fp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Bp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Rp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,Ip,e,s,r)}this._eventListeners=a}};function Ip(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Fp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Bp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Rp(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Lp,e,n,i),r.splice(t,1),a!==null&&a()}};function Lp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function Rp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function zp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Bp(e,t,n,r){if(e.length===0)return-1;r=zp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&zp(a.optionsOrUseCapture)===r)return i}return-1}Fp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Rp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Fp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,Vp,e,void 0,void 0)};function Vp(e,t){return e.tag!==6&&(e=_(e),pm(e,t))}Fp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,Hp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Vp(t[n],e);n--);};function Hp(e,t){return t.push(e),!1}Fp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=lp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,Up,e,void 0,void 0))};function Up(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Fp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,Wp,e,void 0,void 0)};function Wp(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Fp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,Gp,e,void 0,void 0);for(var n=t=0;n<Kp.length;n++){var r=Kp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Kp[t++]=r}Kp.length=t}};function Gp(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var Kp=[],qp=!1;function Jp(e,t,n){Kp.push({fragmentInstance:e,observer:t,instance:n}),qp||(qp=!0,mm(function(){qp=!1;var e=Kp;Kp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Fp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,Yp,e,void 0,void 0),e};function Yp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Fp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Fp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,Hp,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Xp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Xp(e,t,n,r,i){var a=zt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=ee(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=ee(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function Zp(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Fp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,Hp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),Zp(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),Zp(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function Qp(e,t){return e=_(e),$p(e,t),!1}function $p(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function em(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Kp.length;i++){var a=Kp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Kp[r++]=a)}Kp.length=r,n.observe(e)}),$p(e,t))}function tm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Rp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Jp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:nm(n),Rt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function rm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[It])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=lm(e.nextSibling),e===null)break}return null}function im(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=lm(e.nextSibling),e===null))return null;return e}function am(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=lm(e.nextSibling),e===null))return null;return e}function om(e){return e.data===`$?`||e.data===`$~`}function sm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function cm(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function lm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var um=null;function dm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return lm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function fm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function pm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function mm(e){yp(function(){yp(function(t){return e(t)})})}function hm(e,t,n){switch(t=lp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function gm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&$(e,t,r,null,rp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===Tn&&(e.onclick=null),Rt(e)}function _m(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Rt(e)}var vm=new Map,ym=new Set;function bm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var xm=O.d;O.d={f:Sm,r:Cm,D:Em,C:Dm,L:Om,m:km,X:jm,S:Am,M:Mm};function Sm(){var e=xm.f(),t=zd();return e||t}function Cm(e){var t=Bt(e);t!==null&&t.tag===5&&t.type===`form`?ac(t):xm.r(e)}var wm=typeof document>`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=un(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Ut(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+un(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+un(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+un(n.imageSizes)+`"]`)):i+=`[href="`+un(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Lt]=!0,o.onload=o.onerror=function(){Wt(o)}),Ut(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+un(r)+`"][href="`+un(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=w({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Ut(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Ht(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Ut(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Ht(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ut(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Ht(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ut(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=Ae.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Ht(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Ht(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Ht(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+un(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Lt]){r.loading=1;return}}else t=e.createElement(`link`),t[Lt]=!0,t.onload=t.onerror=Wt.bind(null,t),np(t,`link`,n),Ut(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+un(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+un(n.href)+`"]`);if(r)return t.instance=r,Ut(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ut(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Ut(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Ut(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Ut(a),a):(r=n,(a=vm.get(o))&&(r=w({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Ut(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Um(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wm=null;function Gm(e,t,n){if(Wm===null){var r=new Map,i=Wm=new Map;i.set(n,r)}else i=Wm,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[It]||a[kt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Km(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ut(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Ut(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&$m===0&&($m=62500*op());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ah(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=nh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sh={$$typeof:oe,Provider:null,Consumer:null,_currentValue:Ce,_currentValue2:Ce,_threadCount:0};function ch(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=yt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=yt(0),this.hiddenUpdates=yt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function lh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new ch(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Ii(3,null,null,t),e.current=a,a.stateNode=e,t=Fa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},vo(a),e}function uh(e){return e?(e=Pi,e):Pi}function dh(e,t,n,r,i,a){i=uh(i),r.context===null?r.context=i:r.pendingContext=i,r=bo(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=xo(e,r,t),n!==null&&(Pd(n,e,t),So(n,e,t))}function fh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ph(e,t){fh(e,t),(e=e.alternate)&&fh(e,t)}function mh(e){if(e.tag===13||e.tag===31){var t=ji(e,67108864);t!==null&&Pd(t,e,67108864),ph(e,67108864)}}function hh(e){if(e.tag===13||e.tag===31){var t=jd();t=Tt(t);var n=ji(e,t);n!==null&&Pd(n,e,t),ph(e,t)}}var gh=!0;function _h(e,t,n,r){var i=D.T;D.T=null;var a=O.p;try{O.p=2,yh(e,t,n,r)}finally{O.p=a,D.T=i}}function vh(e,t,n,r){var i=D.T;D.T=null;var a=O.p;try{O.p=8,yh(e,t,n,r)}finally{O.p=a,D.T=i}}function yh(e,t,n,r){if(gh){var i=bh(r);if(i===null)Kf(e,t,r,xh,n),Mh(e,r);else if(Ph(i,e,t,n,r))r.stopPropagation();else if(Mh(e,r),t&4&&-1<jh.indexOf(e)){for(;i!==null;){var a=Bt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=pt(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-ot(o);s.entanglements[1]|=c,o&=~c}Ef(a),!(W&6)&&(_d=Je()+500,Df(0,!1))}}break;case 31:case 13:s=ji(a,2),s!==null&&Pd(s,a,2),zd(),ph(a,2)}if(a=bh(r),a===null&&Kf(e,t,r,xh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Kf(e,t,r,null,n)}}function bh(e){return e=Dn(e),Sh(e)}var xh=null;function Sh(e){if(xh=null,e=zt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xh=e,null}function Ch(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Ye()){case Xe:return 2;case Ze:return 8;case Qe:case $e:return 32;case et:return 268435456;default:return 32}default:return 32}}var wh=!1,Th=null,Eh=null,Dh=null,Oh=new Map,kh=new Map,Ah=[],jh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Mh(e,t){switch(e){case`focusin`:case`focusout`:Th=null;break;case`dragenter`:case`dragleave`:Eh=null;break;case`mouseover`:case`mouseout`:Dh=null;break;case`pointerover`:case`pointerout`:Oh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kh.delete(t.pointerId)}}function Nh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Bt(t),t!==null&&mh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ph(e,t,n,r,i){switch(t){case`focusin`:return Th=Nh(Th,e,t,n,r,i),!0;case`dragenter`:return Eh=Nh(Eh,e,t,n,r,i),!0;case`mouseover`:return Dh=Nh(Dh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Oh.set(a,Nh(Oh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kh.set(a,Nh(kh.get(a)||null,e,t,n,r,i)),!0}return!1}function Fh(e){var t=zt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Dt(e.priority,function(){hh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Dt(e.priority,function(){hh(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ih(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);En=r,n.target.dispatchEvent(r),En=null}else return t=Bt(n),t!==null&&mh(t),e.blockedOn=n,!1;t.shift()}return!0}function Lh(e,t,n){Ih(e)&&n.delete(t)}function Rh(){wh=!1,Th!==null&&Ih(Th)&&(Th=null),Eh!==null&&Ih(Eh)&&(Eh=null),Dh!==null&&Ih(Dh)&&(Dh=null),Oh.forEach(Lh),kh.forEach(Lh)}function zh(e,n){e.blockedOn===n&&(e.blockedOn=null,wh||(wh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rh)))}var Bh=null;function Vh(e){Bh!==e&&(Bh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Bh===e&&(Bh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sh(r||n)===null)continue;break}var a=Bt(n);a!==null&&(e.splice(t,3),t-=3,rc(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hh(e){function t(t){return zh(t,e)}Th!==null&&zh(Th,e),Eh!==null&&zh(Eh,e),Dh!==null&&zh(Dh,e),Oh.forEach(t),kh.forEach(t);for(var n=0;n<Ah.length;n++){var r=Ah[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ah.length&&(n=Ah[0],n.blockedOn===null);)Fh(n),n.blockedOn===null&&Ah.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[At]||null;if(typeof a==`function`)o||Vh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[At]||null)s=o.formAction;else if(Sh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vh(n)}}}function Uh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Wh(e){this._internalRoot=e}Gh.prototype.render=Wh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dh(n,jd(),e,t,null,null)},Gh.prototype.unmount=Wh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dh(e.current,2,null,e,null,null),zd(),t[jt]=null}};function Gh(e){this._internalRoot=e}Gh.prototype.unstable_scheduleHydration=function(e){if(e){var t=Et();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ah.length&&t!==0&&t<Ah[n].priority;n++);Ah.splice(n,0,e),n===0&&Fh(e)}};var Kh=n.version;if(Kh!==`19.3.1`)throw Error(i(527,Kh,`19.3.1`));O.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var qh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:D,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jh.isDisabled&&Jh.supportsFiber)try{rt=Jh.inject(qh),it=Jh}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Ec,s=Dc,c=Oc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lh(e,1,!1,null,null,n,r,null,o,s,c,Uh),e[jt]=t.current,Wf(e),new Wh(t)}})),qn=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Kn()})),N=e(se(),1),Jn=qn();async function Yn(e=globalThis.fetch){try{let t={cache:`no-store`,signal:AbortSignal.timeout(3e3)};return await b(await e(`/api/meta`,t),`space`),!1}catch(e){return e instanceof He&&e.status===401&&e.reason===`unauthenticated`}}function Xn(e=(e,t)=>globalThis.fetch(e,t)){let t=async(t,n)=>b(await e(t),n),n=async(t,n)=>{let r=await e(t,{method:`POST`});if(r.status!==204)throw r.ok||await b(r,n),Error(`${n} refused with HTTP ${r.status}`)},r=e=>`/api/agents/${encodeURIComponent(e)}`;return{meta:()=>t(`/api/meta`,`space`),roster:()=>t(`/api/roster`,`peers`),channels:()=>t(`/api/channels`,`channels`),activity:e=>t(`/api/activity?limit=${e}`,`activity`),dms:e=>t(`/api/dms?limit=${e}`,`direct messages`),history:(e,n)=>t(`/api/channels/${encodeURIComponent(e)}/history?limit=${n}`,`#${e} history`),membership:()=>t(`/api/membership`,`membership`),agentEvents:(e,n)=>t(`${r(e)}/events?limit=${n}`,`${e} events`),watch:(e,t)=>n(`${r(e)}/watch?feed=${encodeURIComponent(t)}`,`watch ${e}`),unwatch:(e,t)=>n(`${r(e)}/unwatch?feed=${encodeURIComponent(t)}`,`unwatch ${e}`),deleteChannel:async t=>{let n=await e(`/api/channel/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({channel:t})});return b(n,`delete #${t}`)},send:async(t,n)=>{let r=await e(`/api/send`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...t,text:n})});if(!r.ok)throw await O(r);return b(r,`post`)}}}var Zn=`membership-read-failed`,Qn=2,$n=e=>new EventSource(e);function er(e,t=$n,n=Yn){let r=t(`/feed`),i=!1;r.onopen=()=>e.open(),r.onerror=()=>{if(!i){if(r.readyState!==Qn)return e.error();i=!0,e.closed(n())}};let a=(e,t)=>r.addEventListener(e,e=>t(JSON.parse(e.data)));return a(`roster`,t=>e.roster(t)),a(`presence-view`,t=>e.presenceView(t)),a(`membership`,t=>e.membership(t)),a(Zn,t=>e.membershipFailed(t.reason)),a(`message`,t=>e.message(t)),a(`hello`,t=>e.hello(t.feed)),a(`agent-frame`,t=>e.agentFrame(t)),()=>{r.onerror=null,r.close()}}var tr=`ag-ui.frame`,nr=` · `,rr=`» `,ir=`(thinking) `,ar=`⚙ `,or=` ↳ `,sr=e=>typeof e==`string`?e:void 0;function cr(e,t,n,r){let i=r.split(`
|
|
11
11
|
`);e.push(t+i[0]);for(let t=1;t<i.length;t+=1)e.push(n+i[t])}function lr(e,t,n,r,i,a){let o=t.get(n);o!==void 0&&o.length>0&&cr(e,r,i,o+(a||``)),t.delete(n)}function ur(e){let t=[],n=new Map,r=new Map,i=new Map,a=new Map;for(let o of e){let e=o,s=typeof e==`object`&&e?sr(e.type):void 0;switch(s){case`RUN_STARTED`:cr(t,`▸ `,nr,`run ${sr(e.runId)??`?`} started`);break;case`RUN_FINISHED`:{let n=sr(e.outcome?.type);cr(t,`◂ `,nr,`run ${sr(e.runId)??`?`} finished${n?` (${n})`:``}`);break}case`RUN_ERROR`:{let n=sr(e.code);cr(t,`✗ `,nr,`run error${n?` [${n}]`:``}: ${sr(e.message)??`(no message)`}`);break}case`TEXT_MESSAGE_START`:n.set(sr(e.messageId)??``,``);break;case`TEXT_MESSAGE_CONTENT`:{let t=sr(e.messageId)??``;n.set(t,(n.get(t)??``)+(sr(e.delta)??``));break}case`TEXT_MESSAGE_END`:lr(t,n,sr(e.messageId)??``,rr,rr);break;case`REASONING_MESSAGE_START`:r.set(sr(e.messageId)??``,``);break;case`REASONING_MESSAGE_CONTENT`:{let t=sr(e.messageId)??``;r.set(t,(r.get(t)??``)+(sr(e.delta)??``));break}case`REASONING_MESSAGE_END`:lr(t,r,sr(e.messageId)??``,ir,nr);break;case`TOOL_CALL_START`:{let t=sr(e.toolCallId)??``;i.set(t,sr(e.toolCallName)??`?`),a.set(t,``);break}case`TOOL_CALL_ARGS`:{let t=sr(e.toolCallId)??``;a.set(t,(a.get(t)??``)+(sr(e.delta)??``));break}case`TOOL_CALL_END`:{let n=sr(e.toolCallId)??``;cr(t,ar,nr,`${i.get(n)??`?`}(${a.get(n)??``})`),i.delete(n),a.delete(n);break}case`TOOL_CALL_RESULT`:cr(t,or,nr,sr(e.content)??`(no content)`);break;case`CUSTOM`:{let n=Re(e);n===void 0?cr(t,`• `,nr,`custom ${sr(e.name)??`(unnamed)`}`):cr(t,or,nr,n.isError?`failed`:`done`);break}default:cr(t,`• `,nr,`unrecognised event ${JSON.stringify(s===void 0?null:s)}`)}}for(let e of[...n.keys()])lr(t,n,e,rr,rr,` …`);for(let e of[...r.keys()])lr(t,r,e,ir,nr,` …`);for(let e of[...i.keys()])cr(t,ar,nr,`${i.get(e)??`?`}(${a.get(e)??``}) …`);return t}function dr(e){let t=e;if(typeof t!=`object`||!t||t.kind!==tr)return`[not an AG-UI frame]`;let n=t.events;if(!Array.isArray(n)||n.length===0)return`[AG-UI frame carrying no events]`;let r=ur(n);return r.length>0?r.join(`
|
|
12
12
|
`):`[AG-UI frame with ${n.length} event(s) and nothing to show]`}Mn(tr,dr);function fr(e=1e3,t){if(!Number.isFinite(e)||e<=0)throw Error(`createRate needs a positive number of ms, got ${e}`);if(t!==void 0&&!Number.isFinite(t))throw Error(`createRate needs a finite start time, got ${t}`);let n=n=>t===void 0?e:Math.min(e,Math.max(n-t,1e3)),r=[];return{hit(e){if(!Number.isFinite(e))return;let t=r.length>0&&e<r[r.length-1];r.push(e),t&&r.sort((e,t)=>e-t),r.length>1e4&&r.shift()},perSecond(t){let i=t-e,a=0;for(;a<r.length&&r[a]<=i;)a++;a>0&&(r=r.slice(a));let o=0;for(let e of r)e<=t&&o++;return o*1e3/n(t)}}}function pr(e){let t=g(e);return{hidden:!t,text:t,title:e.map(e=>`${e.name}: ${e.reason}`).join(`
|
|
13
|
-
`)}}var mr=e=>String(e).padStart(2,`0`),hr=e=>{let t=new Date(e);return`${mr(t.getHours())}:${mr(t.getMinutes())}`},gr=e=>`${hr(e)}:${mr(new Date(e).getSeconds())}`;function _r(e){let t=[],n=e.filter(e=>e.kind!==`partial`&&e.name!==`roster`);if(n.length){let e=n.map(e=>e.lastRead).filter(e=>typeof e==`number`&&Number.isFinite(e));t.push(e.length?`Showing what we last read at ${hr(Math.min(...e))}. Retrying.`:`Retrying.`)}let r=e.find(e=>e.kind!==`partial`&&e.name===`roster`);r?.since!==void 0&&Number.isFinite(r.since)&&t.push(`No presence updates since ${gr(r.since)}. Showing the last roster we heard.`);for(let n of e)n.kind===`partial`&&n.read!==void 0&&n.of!==void 0&&t.push(`${n.read} of ${n.of} sources answered`);return t}var vr={"direct messages":`Direct messages didn't load in time, so this page shows channel messages only.`,chat:`Channel messages didn't load in time, so this page shows direct messages only.`};function yr(e){let t=e.find(e=>e.kind===`partial`&&e.name===`activity`);if(!t)return;let n=t.missing??[];return{label:`partial: ${t.name}`,count:t.read!==void 0&&t.of!==void 0?`${t.read} of ${t.of} sources answered`:void 0,body:n.length===1&&Object.hasOwn(vr,n[0])?vr[n[0]]:void 0,title:t.reason}}function br(e){let t=e.filter(e=>e.type===`gap`),n=e.filter(e=>e.type===`boundary-hole`),r=e.filter(e=>e.type===`prefix-incomplete`),i=e.filter(e=>e.type===`backfill-failed`),a=[];if(t.length){let e=t.reduce((e,t)=>e+(t.missing||0),0);a.push(`${e} event frame${e===1?``:`s`} missing (${t.length} break${t.length===1?``:`s`} in the stream)`)}if(n.length&&a.push(`${n.length} possible ordering race${n.length===1?``:`s`} at start-up, unconfirmed`),r.length&&a.push(`${r.length} stream${r.length===1?``:`s`} joined after the start, earlier frames not retained`),i.length&&a.push(`history unavailable, so ordering is based on live frames only`),a.length)return{text:a.join(` · `),fault:t.length>0}}function xr(e){return e===null?`Cotal`:`Cotal · ${e}`}function Sr(e){return`${Math.round(e*10)/10} msg/s`}function Cr(e){return e.view===`channel`?e.channel:null}function wr(e,t){e?.open(t).catch(e=>console.error(`opening a channel failed:`,e))}var P=tt(),Tr=Object.defineProperty,Er=(e,t)=>Tr(e,`name`,{value:t,configurable:!0}),[Dr,Or]=pe(`AlertDialog`,[qt]),kr=qt(),Ar=Er(e=>{let{__scopeAlertDialog:t,...n}=e,r=kr(t);return(0,P.jsx)(Fn,{...r,...n,modal:!0})},`AlertDialog`),jr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(Te,{...i,...r,ref:t})},`AlertDialogTrigger`)),Mr=Er(e=>{let{__scopeAlertDialog:t,...n}=e,r=kr(t);return(0,P.jsx)(y,{...r,...n})},`AlertDialogPortal`),Nr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(Ve,{...i,...r,ref:t})},`AlertDialogOverlay`)),[Pr,Fr]=Dr(`AlertDialogContent`),Ir=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=kr(n),o=N.useRef(null),s=Me(t,o),c=N.useRef(null);return(0,P.jsx)(Pr,{scope:n,cancelRef:c,children:(0,P.jsx)(f,{role:`alertdialog`,...a,...i,ref:s,onOpenAutoFocus:Ze(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),Lr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(h,{...i,...r,ref:t})},`AlertDialogTitle`)),Rr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(jn,{...i,...r,ref:t})},`AlertDialogDescription`)),zr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(Le,{...i,...r,ref:t})},`AlertDialogAction`)),Br=`AlertDialogCancel`,Vr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=Fr(Br,n),a=kr(n),o=Me(t,i);return(0,P.jsx)(Le,{...a,...r,ref:o})},`AlertDialogCancel`)),Hr=Object.defineProperty,F=(e,t)=>Hr(e,`name`,{value:t,configurable:!0}),Ur=[`Enter`,` `],Wr=[`ArrowDown`,`PageUp`,`Home`],Gr=[`ArrowUp`,`PageDown`,`End`],Kr=[...Wr,...Gr];[...Ur],[...Ur];var qr=`Menu`,[Jr,Yr,Xr]=ne(qr),[Zr,Qr]=pe(qr,[Xr,mt,Mt]),$r=mt(),ei=Mt(),[ti,ni]=Zr(qr),[ri,ii]=Zr(qr),ai=F(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=$r(t),[c,l]=N.useState(null),d=N.useRef(!1),f=Hn(a),p=u(i);return N.useEffect(()=>{let e=F(()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=F(()=>d.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),N.useEffect(()=>{if(!n)return;let e=F(()=>f(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,f]),(0,P.jsx)(st,{...s,children:(0,P.jsx)(ti,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:l,children:(0,P.jsx)(ri,{scope:t,onClose:N.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:o,children:r})})})},`Menu`),oi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,...r}=e,i=$r(n);return(0,P.jsx)(On,{...i,...r,ref:t})},`MenuAnchor`)),si=`MenuPortal`,[ci,li]=Zr(si,{forceMount:void 0}),ui=F(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ni(si,t);return(0,P.jsx)(ci,{scope:t,forceMount:n,children:(0,P.jsx)(ie,{present:n||a.open,children:(0,P.jsx)(D,{asChild:!0,container:i,children:r})})})},`MenuPortal`),di=`MenuContent`,[fi,pi]=Zr(di),mi=N.forwardRef(F(function(e,t){let n=li(di,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ni(di,e.__scopeMenu),o=ii(di,e.__scopeMenu);return(0,P.jsx)(Jr.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(ie,{present:r||a.open,children:(0,P.jsx)(Jr.Slot,{scope:e.__scopeMenu,children:o.modal?(0,P.jsx)(hi,{...i,ref:t}):(0,P.jsx)(gi,{...i,ref:t})})})})},`MenuContent`)),hi=N.forwardRef(F(function(e,t){let n=ni(di,e.__scopeMenu),r=N.useRef(null),i=Me(t,r);return N.useEffect(()=>{let e=r.current;if(e)return o(e)},[]),(0,P.jsx)(vi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ze(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),gi=N.forwardRef(F(function(e,t){let n=ni(di,e.__scopeMenu);return(0,P.jsx)(vi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),_i=it(`MenuContent.ScrollLock`),vi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ni(di,n),_=ii(di,n),v=$r(n),y=ei(n),b=Yr(n),[x,S]=N.useState(null),C=N.useRef(null),[w,te]=N.useState(null);oe(w);let{nodes:ne,registry:T}=ge(),re=!!(i||m),ie=Me(t,C,g.onContentChange,te),E=N.useRef(0),ae=N.useRef(``),se=N.useRef(0),ce=N.useRef(null),le=N.useRef(`right`),ue=N.useRef(0),de=N.useMemo(()=>m?[C,...ne.map(e=>({current:e}))]:[],[C,ne,m]),fe=m?Ut:N.Fragment,pe=m?{as:_i,allowPinchZoom:!0,shards:de}:void 0,me=F(e=>{let t=ae.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Vi(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;function s(e){ae.current=e,window.clearTimeout(E.current),e!==``&&(E.current=window.setTimeout(()=>s(``),1e3))}F(s,`updateSearch`),s(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);N.useEffect(()=>()=>window.clearTimeout(E.current),[]),ye();let he=N.useCallback(e=>le.current===ce.current?.side&&Ui(e,ce.current?.area),[]);return(0,P.jsx)(fi,{scope:n,searchRef:ae,onItemEnter:N.useCallback(e=>{he(e)&&e.preventDefault()},[he]),onItemLeave:N.useCallback(e=>{he(e)||(C.current?.focus(),S(null))},[he]),onTriggerLeave:N.useCallback(e=>{he(e)&&e.preventDefault()},[he]),pointerGraceTimerRef:se,onPointerGraceIntentChange:N.useCallback(e=>{ce.current=e},[]),children:(0,P.jsx)(ee,{registry:re?T:null,children:(0,P.jsx)(fe,{...pe,children:(0,P.jsx)(Oe,{asChild:!0,trapped:i,branches:ne,onMountAutoFocus:Ze(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,P.jsx)(Pe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,P.jsx)($t,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:Ze(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,P.jsx)(Rn,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ii(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:ie,style:{outline:`none`,...h.style},onKeyDown:Ze(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&me(e.key));let i=C.current;if(e.target!==i||!Kr.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Gr.includes(e.key)&&a.reverse(),zi(a)}),onBlur:Ze(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),ae.current=``)}),onPointerMove:Ze(e.onPointerMove,Wi(e=>{let t=e.target,n=ue.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>ue.current?`right`:`left`;le.current=t,ue.current=e.clientX}}))})})})})})})})},`MenuContentImpl`)),yi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(fn.div,{role:`group`,...r,ref:t})},`MenuGroup`)),bi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(fn.div,{...r,ref:t})},`MenuLabel`)),xi=`MenuItem`,Si=`menu.itemSelect`,Ci=N.forwardRef(F(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=N.useRef(null),o=ii(xi,e.__scopeMenu),s=pi(xi,e.__scopeMenu),c=Me(t,a),l=N.useRef(!1),u=F(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Si,{bubbles:!0,cancelable:!0});e.addEventListener(Si,e=>r?.(e),{once:!0}),ue(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,P.jsx)(wi,{...i,ref:c,disabled:n,onClick:Ze(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Ze(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Ze(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&Ur.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),wi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=pi(xi,n),s=ei(n),c=N.useRef(null),l=Me(t,c),[u,d]=N.useState(!1),[f,p]=N.useState(``);return N.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,P.jsx)(Jr.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,P.jsx)(Ft,{asChild:!0,...s,focusable:!r,children:(0,P.jsx)(fn.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Ze(e.onPointerMove,Wi(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ze(e.onPointerLeave,Wi(e=>o.onItemLeave(e))),onFocus:Ze(e.onFocus,()=>d(!0)),onBlur:Ze(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Ti,Ei]=Zr(`MenuRadioGroup`,{value:void 0,onValueChange:F(()=>{},`onValueChange`)}),Di=N.forwardRef(F(function(e,t){let{value:n,onValueChange:r,...i}=e,a=Hn(r);return(0,P.jsx)(Ti,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,P.jsx)(yi,{...i,ref:t})})},`MenuRadioGroup`)),Oi=`MenuRadioItem`,ki=N.forwardRef(F(function(e,t){let{value:n,...r}=e,i=Ei(Oi,e.__scopeMenu),a=n===i.value;return(0,P.jsx)(ji,{scope:e.__scopeMenu,checked:a,children:(0,P.jsx)(Ci,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ri(a),onSelect:Ze(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),Ai=`MenuItemIndicator`,[ji,Mi]=Zr(Ai,{checked:!1}),Ni=N.forwardRef(F(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=Mi(Ai,n);return(0,P.jsx)(ie,{present:r||Li(a.checked)||a.checked===!0,children:(0,P.jsx)(fn.span,{...i,ref:t,"data-state":Ri(a.checked)})})},`MenuItemIndicator`)),[Pi,Fi]=Zr(`MenuSub`);function Ii(e){return e?`open`:`closed`}F(Ii,`getOpenState`);function Li(e){return e===`indeterminate`}F(Li,`isIndeterminate`);function Ri(e){return Li(e)?`indeterminate`:e?`checked`:`unchecked`}F(Ri,`getCheckedState`);function zi(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}F(zi,`focusFirst`);function Bi(e,t){return e.map((n,r)=>e[(t+r)%e.length])}F(Bi,`wrapArray`);function Vi(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Bi(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}F(Vi,`getNextMatch`);function Hi(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}F(Hi,`isPointInPolygon`);function Ui(e,t){return t?Hi({x:e.clientX,y:e.clientY},t):!1}F(Ui,`isPointerInGraceArea`);function Wi(e){return t=>t.pointerType===`mouse`?e(t):void 0}F(Wi,`whenMouse`);var Gi=Object.defineProperty,Ki=(e,t)=>Gi(e,`name`,{value:t,configurable:!0}),qi=`DropdownMenu`,[Ji,Yi]=pe(qi,[Qr]),Xi=Qr(),[Zi,Qi]=Ji(qi),$i=Ki(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Xi(t),l=N.useRef(null),[u,d]=Ge({prop:i,defaultProp:a??!1,onChange:o,caller:qi});return(0,P.jsx)(Zi,{scope:t,triggerId:Je(),triggerRef:l,contentId:Je(),open:u,onOpenChange:d,onOpenToggle:N.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,P.jsx)(ai,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),ea=`DropdownMenuTrigger`,ta=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Qi(ea,n),o=Xi(n),s=Me(t,a.triggerRef);return(0,P.jsx)(oi,{asChild:!0,...o,children:(0,P.jsx)(fn.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:Ze(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Ze(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),na=Ki(e=>{let{__scopeDropdownMenu:t,...n}=e,r=Xi(t);return(0,P.jsx)(ui,{...r,...n})},`DropdownMenuPortal`),ra=`DropdownMenuContent`,ia=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Qi(ra,n),a=Xi(n),o=N.useRef(!1);return(0,P.jsx)(mi,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Ze(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Ze(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),aa=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(yi,{...i,...r,ref:t})},`DropdownMenuGroup`)),oa=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(bi,{...i,...r,ref:t})},`DropdownMenuLabel`)),sa=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(Di,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),I=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(ki,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),L=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(Ni,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),ca=Object.defineProperty,la=(e,t)=>ca(e,`name`,{value:t,configurable:!0}),ua=`ToggleGroup`,da={Single:`single`,Multiple:`multiple`},[fa,pa]=pe(ua,[Mt]),ma=Mt(),ha=N.forwardRef(la(function(e,t){let{type:n,...r}=e;if(n===da.Single)return(0,P.jsx)(va,{role:`radiogroup`,...r,ref:t});if(n===da.Multiple)return(0,P.jsx)(ya,{role:`toolbar`,...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${ua}\``)},`ToggleGroup`)),[ga,_a]=fa(ua),va=N.forwardRef(la(function(e,t){let{value:n,defaultValue:r,onValueChange:i=la(()=>{},`onValueChange`),...a}=e,[o,s]=Ge({prop:n,defaultProp:r??``,onChange:i,caller:ua});return(0,P.jsx)(ga,{scope:e.__scopeToggleGroup,type:da.Single,value:N.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:N.useCallback(()=>s(``),[s]),children:(0,P.jsx)(Sa,{...a,ref:t})})},`ToggleGroupImplSingle`)),ya=N.forwardRef(la(function(e,t){let{value:n,defaultValue:r,onValueChange:i=la(()=>{},`onValueChange`),...a}=e,[o,s]=Ge({prop:n,defaultProp:r??[],onChange:i,caller:ua}),c=N.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=N.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,P.jsx)(ga,{scope:e.__scopeToggleGroup,type:da.Multiple,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,P.jsx)(Sa,{...a,ref:t})})},`ToggleGroupImplMultiple`)),[ba,xa]=fa(ua),Sa=N.forwardRef(la(function(e,t){let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=ma(n),d=u(o),f={dir:d,...c};return(0,P.jsx)(ba,{scope:n,rovingFocus:i,disabled:r,children:i?(0,P.jsx)($t,{asChild:!0,...l,orientation:a,dir:d,loop:s,children:(0,P.jsx)(fn.div,{...f,ref:t})}):(0,P.jsx)(fn.div,{...f,ref:t})})},`ToggleGroupImpl`)),Ca=`ToggleGroupItem`,wa=N.forwardRef(la(function(e,t){let n=_a(Ca,e.__scopeToggleGroup),r=xa(Ca,e.__scopeToggleGroup),i=ma(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=N.useRef(null);return r.rovingFocus?(0,P.jsx)(Ft,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,P.jsx)(Ta,{...s,ref:t})}):(0,P.jsx)(Ta,{...s,ref:t})},`ToggleGroupItem`)),Ta=N.forwardRef(la(function(e,t){let{__scopeToggleGroup:n,value:r,...i}=e,a=_a(Ca,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0},s=a.type===da.Single?o:void 0;return(0,P.jsx)(ln,{...s,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})},`ToggleGroupItemImpl`)),Ea=[[`path`,{d:`M13.9248 21H10.0752C5.44476 21 3.12955 21 2.27636 19.4939C1.42317 17.9879 2.60736 15.9914 4.97574 11.9985L6.90057 8.75333C9.17559 4.91778 10.3131 3 12 3C13.6869 3 14.8244 4.91777 17.0994 8.75332L19.0243 11.9985C21.3926 15.9914 22.5768 17.9879 21.7236 19.4939C20.8704 21 18.5552 21 13.9248 21Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12 9V13`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M12.125 16.75H12M12.25 16.75C12.25 16.8881 12.1381 17 12 17C11.8619 17 11.75 16.8881 11.75 16.75C11.75 16.6119 11.8619 16.5 12 16.5C12.1381 16.5 12.25 16.6119 12.25 16.75Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],Da=[[`path`,{d:`M18.8516 16.3743L19.5 6H4.5L5.14839 16.3743C5.315 19.0401 5.39831 20.373 6.26426 21.1865C7.13021 22 8.46571 22 11.1367 22H12.8633C15.5343 22 16.8698 22 17.7357 21.1865C18.6017 20.373 18.685 19.0401 18.8516 16.3743Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M16 6H21M16 6L15.3778 4.34082C15.0007 3.33524 14.8122 2.83245 14.4402 2.50292C14.3213 2.39765 14.1904 2.3069 14.0501 2.2326C13.6109 2 13.074 2 12 2C10.926 2 10.3891 2 9.9499 2.2326C9.8096 2.3069 9.67865 2.39765 9.55982 2.50292C9.18783 2.83245 8.99928 3.33524 8.62219 4.34082L8 6M16 6H8M3 6H8`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M9.5 11V17M14.5 11V17`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],Oa=[[`path`,{d:`M15.5 2V6M8.5 6V2`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M6.00446 7.61331C5.93719 6.74273 6.63957 6 7.53014 6H16.4699C17.3604 6 18.0628 6.74273 17.9955 7.61331L17.8117 9.99197C17.6796 11.7019 17.1011 13.3498 16.132 14.7773L15.5312 15.6622C14.9638 16.4979 14.0077 17 12.9838 17H11.0162C9.99228 17 9.03617 16.4979 8.46881 15.6622L7.86803 14.7773C6.89885 13.3498 6.32041 11.7019 6.18827 9.99197L6.00446 7.61331Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M12 17V22`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M11 9H13`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`3`}]],ka=[[`path`,{d:`M19 4H5C4.06812 4 3.60218 4 3.23463 4.15224C2.74458 4.35523 2.35523 4.74458 2.15224 5.23463C2 5.60218 2 6.06812 2 7C2 7.93188 2 8.39782 2.15224 8.76537C2.35523 9.25542 2.74458 9.64477 3.23463 9.84776C3.60218 10 4.06812 10 5 10H19C19.9319 10 20.3978 10 20.7654 9.84776C21.2554 9.64477 21.6448 9.25542 21.8478 8.76537C22 8.39782 22 7.93188 22 7C22 6.06812 22 5.60218 21.8478 5.23463C21.6448 4.74458 21.2554 4.35523 20.7654 4.15224C20.3978 4 19.9319 4 19 4Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M19 14H5C4.06812 14 3.60218 14 3.23463 14.1522C2.74458 14.3552 2.35523 14.7446 2.15224 15.2346C2 15.6022 2 16.0681 2 17C2 17.9319 2 18.3978 2.15224 18.7654C2.35523 19.2554 2.74458 19.6448 3.23463 19.8478C3.60218 20 4.06812 20 5 20H19C19.9319 20 20.3978 20 20.7654 19.8478C21.2554 19.6448 21.6448 19.2554 21.8478 18.7654C22 18.3978 22 17.9319 22 17C22 16.0681 22 15.6022 21.8478 15.2346C21.6448 14.7446 21.2554 14.3552 20.7654 14.1522C20.3978 14 19.9319 14 19 14Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M6.125 7H6M6.25 7C6.25 7.13807 6.13807 7.25 6 7.25C5.86193 7.25 5.75 7.13807 5.75 7C5.75 6.86193 5.86193 6.75 6 6.75C6.13807 6.75 6.25 6.86193 6.25 7Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M10.125 7H10M10.25 7C10.25 7.13807 10.1381 7.25 10 7.25C9.86193 7.25 9.75 7.13807 9.75 7C9.75 6.86193 9.86193 6.75 10 6.75C10.1381 6.75 10.25 6.86193 10.25 7Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`3`}],[`path`,{d:`M6.125 17H6M6.25 17C6.25 17.1381 6.13807 17.25 6 17.25C5.86193 17.25 5.75 17.1381 5.75 17C5.75 16.8619 5.86193 16.75 6 16.75C6.13807 16.75 6.25 16.8619 6.25 17Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`4`}],[`path`,{d:`M10.125 17H10M10.25 17C10.25 17.1381 10.1381 17.25 10 17.25C9.86193 17.25 9.75 17.1381 9.75 17C9.75 16.8619 9.86193 16.75 10 16.75C10.1381 16.75 10.25 16.8619 10.25 17Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`5`}]],Aa=[[`path`,{d:`M3.95631 10.5829L3.03254 9.07084C2.74505 8.60024 2.7389 8.00978 3.01652 7.5333L3.63533 6.47124C3.90953 6.00064 4.41721 5.71571 4.96162 5.7269L6.69131 5.76245C6.92616 5.76728 7.15379 5.68727 7.34333 5.54846C7.79531 5.21745 8.28334 4.93276 8.80042 4.70139C9.01191 4.60675 9.19222 4.45165 9.30469 4.24903L10.1203 2.77965C10.3847 2.30328 10.8865 2.00781 11.4312 2.00781H12.6937C13.2384 2.00781 13.7403 2.30329 14.0047 2.77966L14.8202 4.24902C14.9327 4.45165 15.113 4.60675 15.3245 4.70139C15.8416 4.93274 16.3296 5.2174 16.7815 5.54838C16.9711 5.68718 17.1987 5.76718 17.4336 5.76235L19.1634 5.72676C19.7078 5.71557 20.2155 6.00049 20.4897 6.47111L21.1085 7.53314C21.3862 8.00963 21.38 8.60009 21.0925 9.07068L20.1687 10.5828C20.0481 10.7803 20.002 11.0134 20.0235 11.2439C20.0707 11.7486 20.0707 12.267 20.0235 12.7717C20.002 13.0022 20.0481 13.2353 20.1687 13.4329L21.0924 14.9448C21.3799 15.4154 21.3861 16.0058 21.1084 16.4823L20.4896 17.5444C20.2154 18.015 19.7077 18.2999 19.1633 18.2887L17.4338 18.2531C17.1989 18.2483 16.9713 18.3283 16.7817 18.4671C16.3297 18.7982 15.8416 19.0829 15.3245 19.3142C15.113 19.4089 14.9327 19.564 14.8202 19.7666L14.0047 21.236C13.7403 21.7123 13.2384 22.0078 12.6937 22.0078H11.4312C10.8866 22.0078 10.3847 21.7123 10.1203 21.236L9.30468 19.7665C9.19222 19.5639 9.01191 19.4088 8.80042 19.3142C8.28329 19.0828 7.79519 18.798 7.34316 18.467C7.15362 18.3282 6.92597 18.2482 6.69111 18.253L4.96175 18.2886C4.41733 18.2998 3.90963 18.0148 3.63543 17.5442L3.01663 16.4822C2.739 16.0057 2.74515 15.4152 3.03264 14.9446L3.95631 13.4327C4.07699 13.2351 4.12309 13.002 4.10154 12.7715C4.05437 12.267 4.05438 11.7486 4.10154 11.244C4.12308 11.0135 4.07699 10.7805 3.95631 10.5829Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`0`}],[`circle`,{cx:`12.0625`,cy:`12.0078`,r:`3.5`,stroke:`currentColor`,strokeWidth:`1.5`,key:`1`}]];function ja({...e}){return(0,P.jsx)($i,{"data-slot":`dropdown-menu`,...e})}function Ma({...e}){return(0,P.jsx)(ta,{"data-slot":`dropdown-menu-trigger`,...e})}function Na({className:e,align:t=`start`,sideOffset:n=4,...i}){return(0,P.jsx)(na,{children:(0,P.jsx)(ia,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:r(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i})})}function Pa({...e}){return(0,P.jsx)(aa,{"data-slot":`dropdown-menu-group`,...e})}function Fa({...e}){return(0,P.jsx)(sa,{"data-slot":`dropdown-menu-radio-group`,...e})}function Ia({className:e,children:t,inset:n,...i}){return(0,P.jsxs)(I,{"data-slot":`dropdown-menu-radio-item`,"data-inset":n,className:r(`relative flex min-h-7 cursor-default items-center gap-2 rounded-xl py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...i,children:[(0,P.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,P.jsx)(L,{children:(0,P.jsx)(wn,{icon:at,strokeWidth:2})})}),t]})}function La({className:e,inset:t,...n}){return(0,P.jsx)(oa,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:r(`px-2 py-1 text-xs text-muted-foreground data-inset:pl-7`,e),...n})}var Ra={activity:(0,P.jsx)(`path`,{d:`M22 12h-4l-3 8L9 4l-3 8H2`}),hash:(0,P.jsx)(`path`,{d:`M4 9h16M4 15h16M10 3 8 21M16 3l-2 18`}),dm:(0,P.jsx)(`path`,{d:`M20 11.5a8 8 0 0 1-11.7 7.1L4 20l1.4-4.1A8 8 0 1 1 20 11.5z`}),agents:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,P.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,P.jsx)(`path`,{d:`M16 4.5a3.5 3.5 0 0 1 0 7M18 14a6 6 0 0 1 3.5 6`})]}),graph:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2.5`}),(0,P.jsx)(`circle`,{cx:`18`,cy:`8`,r:`2.5`}),(0,P.jsx)(`circle`,{cx:`10`,cy:`18`,r:`2.5`}),(0,P.jsx)(`path`,{d:`M8.4 6.4 15.5 7.6M6.9 8.4l2.3 7.2M16.6 10.1l-4.9 6`})]}),inbox:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`path`,{d:`M3 13h5l1.5 3h5L16 13h5`}),(0,P.jsx)(`path`,{d:`M5 5h14l2 8v6H3v-6z`})]}),search:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,P.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),chev:(0,P.jsx)(`path`,{d:`m7 10 5 5 5-5`}),gear:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,P.jsx)(`path`,{d:`M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M5.3 18.7l2.1-2.1M16.6 7.4l2.1-2.1`})]}),server:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`1.5`}),(0,P.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`1.5`}),(0,P.jsx)(`path`,{d:`M7 7.5h.01M7 16.5h.01`})]})};function za({name:e,size:t=18}){return(0,P.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:Ra[e]})}var Ba=[`system`,`light`,`dark`],Va=(0,N.createContext)({theme:`system`,setTheme:()=>null});function Ha({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`,...r}){let[i,a]=(0,N.useState)(()=>{try{return Ba.find(e=>e===localStorage.getItem(n))??t}catch{return t}});(0,N.useEffect)(()=>{let e=window.document.documentElement,t=()=>{if(e.classList.remove(`light`,`dark`),i===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t)}else e.classList.add(i)};if(t(),i!==`system`)return;let n=window.matchMedia(`(prefers-color-scheme: dark)`);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},[i]);let o={theme:i,setTheme:e=>{try{localStorage.setItem(n,e)}catch{}a(e)}};return(0,P.jsx)(Va.Provider,{...r,value:o,children:e})}var Ua=()=>{let e=(0,N.useContext)(Va);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},Wa=[{label:`Activity`,icon:`activity`,view:`activity`},{label:`Channels`,icon:`hash`,view:`channel`},{label:`Direct messages`,icon:`dm`,view:`dm`},{label:`Agents`,icon:`agents`,view:`agents`},{label:`Topology`,icon:`graph`,view:`topology`}],Ga={channel:`No channels yet. One appears with its first message.`,dm:`No direct messages yet.`};function Ka(e,t,n){if(t.view===e)return t;switch(e){case`channel`:return n.channel===null?null:{view:e,channel:n.channel};case`dm`:return n.dm===null?null:{view:e,...n.dm};case`agents`:return{view:e,group:`status`};case`activity`:case`topology`:case`needs`:return{view:e};case`agent`:return null}}var qa=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function Ja(){let e=(0,N.useId)(),{theme:t,setTheme:n}=Ua();return(0,P.jsxs)(ja,{children:[(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(Ma,{asChild:!0,children:(0,P.jsxs)(ce,{children:[(0,P.jsx)(za,{name:`gear`}),(0,P.jsx)(`span`,{children:`Settings`})]})})}),(0,P.jsx)(E,{side:`right`,children:`Settings`})]}),(0,P.jsx)(Na,{side:`right`,align:`end`,loop:!0,children:(0,P.jsxs)(Pa,{"aria-labelledby":e,children:[(0,P.jsx)(La,{id:e,children:`Theme`}),(0,P.jsx)(Fa,{value:t,onValueChange:e=>{let t=qa.find(t=>t.value===e);t&&n(t.value)},children:qa.map(e=>(0,P.jsx)(Ia,{value:e.value,children:e.label},e.value))})]})})]})}function Ya({route:e,places:t}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(xe,{children:(0,P.jsx)(`span`,{className:`ui-rail-mark self-center`,dangerouslySetInnerHTML:{__html:p(`currentColor`)}})}),(0,P.jsx)(_,{children:(0,P.jsx)(Yt,{children:(0,P.jsx)(c,{children:(0,P.jsx)(Ae,{children:Wa.map(({label:n,icon:r,view:i})=>{let a=Ka(i,e,t),o=e.view===i||i===`agents`&&e.view===`agent`,s=Ga[i];return(0,P.jsx)(_e,{children:a?(0,P.jsx)(ce,{asChild:!0,isActive:o,tooltip:{children:n,hidden:!1},children:(0,P.jsxs)(`a`,{href:It(a),"aria-current":o?`page`:void 0,children:[(0,P.jsx)(za,{name:r}),(0,P.jsx)(`span`,{children:n})]})}):(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(`span`,{className:`flex`,children:(0,P.jsxs)(ce,{type:`button`,"aria-disabled":!0,"aria-label":n,"aria-describedby":`rail-why-${i}`,children:[(0,P.jsx)(za,{name:r}),(0,P.jsx)(`span`,{children:n}),(0,P.jsx)(`span`,{id:`rail-why-${i}`,className:`ui-sr`,children:s})]})})}),(0,P.jsx)(E,{side:`right`,children:s})]})},i)})})})})}),(0,P.jsx)(De,{children:(0,P.jsx)(Ae,{children:(0,P.jsx)(_e,{children:(0,P.jsx)(Ja,{})})})})]})}var Xa=[{label:`Channels`,icon:`hash`,view:`channel`},{label:`DMs`,icon:`dm`,view:`dm`},{label:`Agents`,icon:`agents`,view:`agents`},{label:`Activity`,icon:`activity`,view:`activity`}];function Za({route:e,places:t,waiting:n,working:r}){return(0,P.jsx)(`nav`,{className:`v3-tabbar`,"aria-label":`Sections`,children:Xa.map(({label:i,icon:a,view:o})=>{let s=Ka(o,e,t),c=e.view===o||o===`agents`&&e.view===`needs`||o===`agents`&&e.view===`agent`,l=s?`a`:`button`,u=s?void 0:Ga[o],d=(0,P.jsxs)(l,{href:s?It(s):void 0,type:s?void 0:`button`,"aria-disabled":!s||void 0,"aria-current":c?`page`:void 0,"aria-label":u?i:void 0,"aria-describedby":u?`tab-why-${o}`:void 0,children:[(0,P.jsx)(za,{name:a,size:22}),i,u&&(0,P.jsx)(`span`,{id:`tab-why-${o}`,className:`ui-sr`,children:u}),o===`agents`&&n>0&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(gt,{children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:n}),(0,P.jsx)(`span`,{className:`ui-sr`,children:`${n} agent${n===1?``:`s`} waiting`})]})}),(0,P.jsx)(E,{children:`${n} agent${n===1?``:`s`} waiting`})]}),o===`agents`&&n===0&&r>0&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(`span`,{className:`ox-sbw ox-tabw`,children:[(0,P.jsx)(M,{icon:bn,size:16,className:`ui-ic ox-spin`}),(0,P.jsx)(`span`,{"aria-hidden":`true`,children:r}),(0,P.jsx)(`span`,{className:`ui-sr`,children:`${r} agent${r===1?``:`s`} working`})]})}),(0,P.jsx)(E,{children:`${r} agent${r===1?``:`s`} working`})]})]},o);return u?(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:d}),(0,P.jsx)(E,{side:`top`,children:u})]},o):d})})}var Qa={"--sidebar-width":`350px`};function $a(e){let{route:t,controller:n,paneOpen:i,phone:a}=e,o=Cr(t);(0,N.useEffect)(()=>{wr(n,o)},[n,o]);let s=ze(),c=e.stale?`stale`:void 0;return(0,P.jsxs)(Un,{className:r(`h-dvh`,a&&`ui-phone flex-col`),style:Qa,"data-view":t.view,"data-presence":c,children:[(0,P.jsxs)(x,{collapsible:`icon`,className:`overflow-hidden *:data-[sidebar=sidebar]:flex-row`,children:[(0,P.jsx)(x,{collapsible:`none`,role:`navigation`,"aria-label":`Views`,className:`hidden w-[calc(var(--sidebar-width-icon)+1px)]! border-r md:flex`,children:(0,P.jsx)(Ya,{route:t,places:e.places})}),(0,P.jsx)(x,{collapsible:`none`,role:`complementary`,"aria-label":`Space`,"data-presence":c,className:`min-w-0 flex-1 group-data-[collapsible=icon]:hidden`,children:e.sidebar})]}),(0,P.jsx)(Ce,{className:`min-h-0 min-w-0`,children:e.children}),a&&(0,P.jsx)(Za,{route:t,places:e.places,waiting:e.waiting,working:e.working}),e.panelSheet?(0,P.jsx)(pn,{open:i,onOpenChange:t=>!t&&e.onPanelClose(),children:(0,P.jsxs)(de,{side:`right`,showCloseButton:!1,"aria-describedby":void 0,"data-presence":c,...s,children:[(0,P.jsx)(nt,{className:`sr-only`,children:`Details`}),e.panel]})}):i&&(0,P.jsx)(`section`,{className:`ui-pane`,"aria-label":`Details`,children:e.panel})]})}var eo=Ot(`group/item flex w-full flex-wrap items-center rounded-2xl border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-3.5 px-4 py-3.5`,sm:`gap-3.5 px-3.5 py-3`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function to({className:e,variant:t=`default`,size:n=`default`,asChild:i=!1,...a}){let o=i?et:`div`;return(0,P.jsx)(o,{"data-slot":`item`,"data-variant":t,"data-size":n,className:r(eo({variant:t,size:n,className:e})),...a})}var no=Ot(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-xl group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 group-data-[size=xs]/item:rounded-lg [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function ro({className:e,variant:t=`default`,...n}){return(0,P.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:r(no({variant:t,className:e})),...n})}function io({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`item-content`,className:r(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0.5 [&+[data-slot=item-content]]:flex-none`,e),...t})}function ao({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`item-title`,className:r(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function oo({className:e,...t}){return(0,P.jsx)(`p`,{"data-slot":`item-description`,className:r(`line-clamp-2 text-left text-sm font-normal text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function so({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`item-actions`,className:r(`flex items-center gap-2`,e),...t})}var co=[{rows:2},{heading:`Channels`,rows:3},{heading:`Direct messages`,rows:1}];function lo({lines:e}){return(0,P.jsxs)(`div`,{className:`ui-skel-msg`,children:[(0,P.jsx)(T,{className:`size-8.5`}),(0,P.jsx)(`div`,{style:{display:`grid`,gap:8,paddingTop:4},children:e.map((e,t)=>(0,P.jsx)(T,{className:`h-2.5`,style:{width:e}},t))})]})}function uo(){return(0,P.jsx)(_,{role:`navigation`,"aria-label":`Places`,"aria-busy":`true`,children:co.map(({heading:e,rows:t})=>(0,P.jsxs)(Yt,{"aria-hidden":`true`,children:[e&&(0,P.jsx)(Gt,{children:e}),(0,P.jsx)(Ae,{children:Array.from({length:t},(e,t)=>(0,P.jsx)(_e,{children:(0,P.jsx)(Fe,{showIcon:!0})},t))})]},e??``))})}function fo(){return(0,P.jsxs)(`div`,{"aria-hidden":`true`,style:{display:`contents`},children:[(0,P.jsx)(`header`,{className:`ui-bar`,children:(0,P.jsx)(T,{className:`h-3 w-30`})}),(0,P.jsxs)(`div`,{className:`ui-col`,style:{width:`100%`},children:[(0,P.jsx)(lo,{lines:[`30%`,`85%`]}),(0,P.jsx)(lo,{lines:[`24%`,`70%`,`52%`]})]})]})}function po({store:e,inHeader:t=!1}){let n=A(e,e=>e.stale),r=pr(n);if(r.hidden)return null;let i=t?[]:_r(n);return(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(m,{role:`note`,id:t?void 0:`stale`,className:t?`w-auto`:`mx-2 my-1 w-auto`,children:[(0,P.jsx)(M,{icon:Ea}),(0,P.jsx)(Kt,{children:r.text}),i.length>0&&(0,P.jsx)(we,{children:i.map(e=>(0,P.jsx)(`div`,{children:e},e))}),r.title&&(0,P.jsx)(`div`,{className:`ui-sr`,children:r.title})]})}),r.title&&(0,P.jsx)(E,{className:`flex-col items-start`,children:r.title.split(`
|
|
14
|
-
`).map(e=>(0,P.jsx)(`span`,{children:e},e))})]})}var mo=1e3,ho=e=>e.startsWith(`run.`),go={connecting:{text:`Connecting`,title:`Connecting to cotal web`},reconnecting:{text:`Reconnecting`,title:`Reconnecting to cotal web`},closed:{text:`Disconnected`,title:`The live feed closed and will not retry. Reload the page, or open the link cotal web printed when it started.`},"session-invalid":{text:`Disconnected`,title:"Your session is no longer valid. Open a new private dashboard link. For a background service, find the private session file in the service logs, for example with `cotal service logs web --space main`."}},_o=e=>`${e.length} member${e.length===1?``:`s`} working: ${e.map(e=>e.name).join(`, `)}`;function vo({to:e,here:t,tip:n,badge:r,link:i,children:a}){let{isMobile:o}=d();return(0,P.jsxs)(_e,{children:[(0,P.jsx)(ce,{asChild:!0,isActive:t,className:r===void 0?void 0:`pr-8`,tooltip:n===void 0||o?void 0:{children:n,hidden:!1},children:(0,P.jsx)(`a`,{ref:i,href:It(e),"aria-current":t?`page`:void 0,children:a})}),r!==void 0&&(0,P.jsx)(w,{"aria-hidden":`true`,children:r})]})}function yo({connection:e}){let{text:t,title:n}=e===`connected`?{text:`Connected`,title:`Connected to cotal web`}:go[e];return(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(gt,{variant:e===`closed`||e===`session-invalid`?`destructive`:`outline`,children:[(0,P.jsx)(`i`,{className:e===`connected`?`ui-mdot ui-mdot-live`:`ui-mdot ui-mdot-down`}),t,(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${n}`})]})}),(0,P.jsx)(E,{children:n})]})}function bo({store:e,route:t,msgPerSecond:n}){let r=A(e,e=>e.space),i=A(e,e=>e.channels),a=A(e,e=>e.unread),o=A(e,e=>e.roster),c=A(e,e=>e.dms),l=A(e,e=>e.membership),u=A(e,e=>e.connection),f=A(e,e=>e.loading),p=A(e,e=>e.post),m=A(e,e=>e.operatorId),[,h]=(0,N.useState)(0);(0,N.useEffect)(()=>{let e=setInterval(()=>h(e=>e+1),mo);return()=>clearInterval(e)},[]);let{isMobile:g,setOpenMobile:v}=d(),y=(0,N.useRef)(null);(0,N.useLayoutEffect)(()=>{g&&y.current?.focus()},[g]);let b=It(t),x=(0,N.useRef)(b);(0,N.useEffect)(()=>{x.current!==b&&(x.current=b,v(!1))},[b,v]);let S=(0,N.useMemo)(()=>hn(o,{includeOffline:!0}),[o]),ee=(0,N.useMemo)(()=>Tn(o),[o]),C=(0,N.useMemo)(()=>new Map(S.map(e=>[e.id,e])),[S]),w=ae(),ne=(0,N.useMemo)(()=>{let e=i.map(e=>e.channel);return new Map(i.map(t=>[t.channel,$e(t.channel,l,e,[]).map(e=>C.get(e.id)).filter(e=>e?.status===`working`)]))},[i,l,C]),T=dt(S).length,re=`${T} agent${T===1?``:`s`} waiting`,ie=Sr(n()),oe=s(p,m!==null&&o.some(e=>e.card.id===m)),se=(0,N.useMemo)(()=>on(c),[c]),[le,ue]=(0,N.useState)(!1),de=t.view===`dm`&&t.with!==void 0?yt(t.peer,t.with):null,pe=(0,N.useMemo)(()=>le?se:se.filter((e,t)=>t<10||e.key===de),[se,le,de]);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(xe,{children:(0,P.jsx)(`span`,{className:`ui-space px-2 py-1.5`,children:r})}),(0,P.jsx)(po,{store:e}),f.roster||f.channels?(0,P.jsx)(uo,{}):(0,P.jsxs)(_,{role:`navigation`,"aria-label":`Places`,children:[(0,P.jsx)(Yt,{children:(0,P.jsxs)(Ae,{children:[(0,P.jsxs)(vo,{to:{view:`needs`},here:t.view===`needs`,tip:T>0?re:void 0,badge:T>0?T:void 0,link:y,children:[(0,P.jsx)(za,{name:`inbox`}),(0,P.jsx)(`span`,{className:`flex-1 truncate`,children:`Needs you`}),T>0&&(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${re}`})]}),(0,P.jsxs)(vo,{to:{view:`activity`},here:t.view===`activity`,badge:ie,children:[(0,P.jsx)(za,{name:`activity`}),(0,P.jsx)(`span`,{className:`flex-1 truncate`,children:`Activity`}),(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${ie}`})]})]})}),(0,P.jsxs)(Yt,{children:[(0,P.jsx)(Gt,{children:`Channels`}),i.length===0&&(0,P.jsx)(We,{className:`p-4`,children:(0,P.jsx)(fe,{children:(0,P.jsx)(te,{children:`No channels yet. One appears with its first message.`})})}),(0,P.jsx)(Ae,{children:i.map(e=>{let n=a[e.channel]??0,r=ho(e.channel)?`Events from run ${e.channel.slice(4)}`:void 0,i=ne.get(e.channel)??[];return(0,P.jsxs)(vo,{to:{view:`channel`,channel:e.channel},here:t.view===`channel`&&t.channel===e.channel,tip:r,badge:n>0?n:void 0,children:[r?(0,P.jsx)(M,{icon:Oa}):(0,P.jsx)(za,{name:`hash`}),(0,P.jsx)(`span`,{className:`flex-1 truncate`,children:e.channel}),i.length>0&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(`span`,{className:`ox-sbw`,children:[(0,P.jsx)(M,{icon:bn,className:`ox-spin`}),(0,P.jsx)(`span`,{"aria-hidden":`true`,children:i.length}),(0,P.jsx)(`span`,{className:`ui-sr`,children:_o(i)})]})}),(0,P.jsx)(E,{children:_o(i)})]}),n>0&&(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${n}`}),r&&(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${r}`})]},e.channel)})})]}),(0,P.jsxs)(Yt,{children:[(0,P.jsx)(Gt,{children:`Direct messages`}),(0,P.jsxs)(Ae,{children:[pe.map(({key:e,parts:t,opener:n,verified:r})=>{let i=t[0]===n?t[1]:t[0];return(0,P.jsxs)(vo,{to:{view:`dm`,peer:n,with:i},here:e===de,children:[(0,P.jsx)(`span`,{className:`ui-stack`,"aria-hidden":`true`,children:[n,i].map(e=>(0,P.jsx)(he,{vendor:C.get(e)?.harness,status:C.get(e)?.status??`offline`,size:18,dot:C.has(e),badge:C.has(e)?w(e):void 0},e))}),(0,P.jsx)(`span`,{className:`flex-1 truncate`,children:`${Zt(n,ee,m)}, ${Zt(i,ee,m)}`}),!r&&(0,P.jsx)(Ht,{})]},e)}),se.length>10&&(0,P.jsx)(_e,{children:(0,P.jsx)(ce,{type:`button`,"aria-expanded":le,onClick:()=>ue(e=>!e),children:(0,P.jsx)(`span`,{children:le?`Show fewer`:`Show all ${se.length}`})})})]})]})]}),(0,P.jsx)(De,{children:(0,P.jsxs)(to,{size:`xs`,children:[(0,P.jsx)(ro,{children:(0,P.jsx)(kn,{size:`sm`,children:(0,P.jsx)(Bn,{children:`OP`})})}),(0,P.jsxs)(io,{children:[(0,P.jsx)(ao,{children:`operator`}),oe&&(0,P.jsxs)(oo,{children:[(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(`span`,{tabIndex:0,"aria-describedby":`operator-line-why`,children:oe.text})}),(0,P.jsx)(E,{children:oe.title})]}),(0,P.jsx)(`span`,{id:`operator-line-why`,className:`ui-sr`,children:oe.title})]})]}),(0,P.jsx)(so,{children:(0,P.jsx)(yo,{connection:u})})]})})]})}var xo=N.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function So({className:e,variant:t,size:n,spacing:i=2,orientation:a=`horizontal`,children:o,...s}){return(0,P.jsx)(ha,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":i,"data-orientation":a,style:{"--gap":i},className:r(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-2xl data-vertical:flex-col data-vertical:items-stretch`,e),...s,children:(0,P.jsx)(xo.Provider,{value:{variant:t,size:n,spacing:i,orientation:a},children:o})})}function Co({className:e,children:t,variant:n=`default`,size:i=`default`,...a}){let o=N.useContext(xo);return(0,P.jsx)(wa,{"data-slot":`toggle-group-item`,"data-variant":o.variant||n,"data-size":o.size||i,"data-spacing":o.spacing,className:r(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-2xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-2xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-2xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-2xl data-[state=on]:bg-muted group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,v({variant:o.variant||n,size:o.size||i}),e),...a,children:t})}function wo(e,t){if(e){for(let{msg:n,senderId:r}of t)if(n.replyTo===e)return r===void 0?{id:n.from.id,verified:!1}:{id:r,verified:!0}}}function To({space:e}){return(0,P.jsxs)(We,{children:[(0,P.jsxs)(fe,{children:[(0,P.jsx)(dn,{"data-wave":`claude`,dangerouslySetInnerHTML:{__html:`<svg viewBox="0 0 150 150" width="150" height="150" overflow="visible" aria-hidden="true">${Nn(`claude`)}</svg>`}}),(0,P.jsx)(le,{children:e===null?`No agents here yet.`:`No agents on ${e} yet.`}),(0,P.jsx)(te,{children:`Start one from your terminal. It shows up here when it joins.`})]}),(0,P.jsxs)(Xe,{children:[(0,P.jsx)(ft,{command:`cotal spawn`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(ft,{command:`cotal personas`}),` lists the others.`]})]})]})}var Eo=e=>e.some(e=>e.card.kind===`agent`),Do=[{label:`All`,value:`all`},{label:`Channels`,value:`chat`},{label:`Direct`,value:`unicast`},{label:`Roles`,value:`anycast`}];function Oo(e,t){return e.mode===`chat`?typeof e.channel==`string`?`#${e.channel}`:null:e.mode===`anycast`?typeof e.msg.toService==`string`?`to role ${e.msg.toService}`:null:typeof e.msg.to==`string`?`to ${Zt(e.msg.to,t)}`:null}function ko({banner:e}){return(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(m,{role:`status`,children:[(0,P.jsx)(M,{icon:Ea}),(0,P.jsx)(Kt,{children:e.label}),(e.count||e.body)&&(0,P.jsxs)(we,{children:[e.count&&(0,P.jsx)(`div`,{children:e.count}),e.body&&(0,P.jsx)(`div`,{children:e.body})]}),(0,P.jsx)(`div`,{className:`ui-sr`,children:e.title})]})}),(0,P.jsx)(E,{children:e.title})]})}function Ao({store:e}){let t=A(e,e=>e.activity),n=A(e,e=>e.roster),r=A(e,e=>e.space),i=A(e,e=>e.operatorId),o=yr(A(e,e=>e.stale)),[s,c]=(0,N.useState)(`all`),l=(0,N.useMemo)(()=>Tn(n),[n]),u=(0,N.useMemo)(()=>hn(n,{includeOffline:!0}),[n]),d=(0,N.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]),f=(0,N.useMemo)(()=>{let e=t.map(e=>({msg:e.msg,senderId:e.senderId}));return t.map((t,n)=>({e:t,claim:t.mode===`anycast`?wo(t.msg.id,e.slice(n+1)):void 0})).reverse()},[t]),p=s===`all`?f:f.filter(({e})=>e.mode===s);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar ui-bar-activity`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(`h1`,{children:`Activity`}),!o&&(0,P.jsx)(po,{store:e,inHeader:!0}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsx)(So,{type:`single`,size:`sm`,"aria-label":`Show`,value:s,onValueChange:e=>{let t=Do.find(t=>t.value===e);t&&c(t.value)},children:Do.map(e=>(0,P.jsx)(Co,{value:e.value,children:e.label},e.value))})]}),(0,P.jsxs)(`div`,{className:`ui-scroll`,children:[!Eo(n)&&(0,P.jsx)(To,{space:r}),(0,P.jsxs)(`div`,{className:`ui-col flex flex-col gap-8`,children:[o&&(0,P.jsx)(ko,{banner:o}),p.map(({e,claim:t})=>{let n=e.senderId;return(0,P.jsx)(a,{msg:e.msg,senderId:n,mode:e.mode,idx:l,peers:d,own:n!==void 0&&n===i,mention:`operator`,claim:t,place:Oo(e,l)},`${e.msg.id}\u0001${n??``}`)})]})]})]})}function jo({className:e,size:t=`default`,...n}){return(0,P.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:r(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-[min(var(--radius-4xl),24px)] bg-card py-(--card-spacing) text-sm text-card-foreground shadow-sm ring-1 ring-foreground/5 [--card-spacing:--spacing(5)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] dark:ring-foreground/10 *:[img:first-child]:rounded-t-[min(var(--radius-4xl),24px)] *:[img:last-child]:rounded-b-[min(var(--radius-4xl),24px)]`,e),...n})}function Mo({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-header`,className:r(`group/card-header @container/card-header grid auto-rows-min items-start gap-1.5 rounded-t-[min(var(--radius-4xl),24px)] px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function No({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-title`,className:r(`text-base font-medium`,e),...t})}function Po({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-description`,className:r(`text-sm text-muted-foreground`,e),...t})}function Fo({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-action`,className:r(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function Io({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-footer`,className:r(`flex items-center rounded-b-[min(var(--radius-4xl),24px)] px-(--card-spacing) [.border-t]:pt-(--card-spacing)`,e),...t})}var Lo=`cotal.needs.dismissed`,Ro=`Dismiss until the status changes`,zo=e=>`${e.id} ${e.statusSince??``}`,Bo=new Set;function Vo(){let e=[];try{let t=JSON.parse(globalThis.localStorage?.getItem(Lo)??`[]`);Array.isArray(t)&&(e=t.filter(e=>typeof e==`string`))}catch{}return[...new Set([...e,...Bo])]}function Ho(e){try{globalThis.localStorage?.setItem(Lo,JSON.stringify(e.slice(-100)))}catch{}}function Uo(){let[e,t]=(0,N.useState)([]);return(0,N.useLayoutEffect)(()=>t(Vo()),[]),[new Set(e),n=>{Bo.add(n);let r=[...e.filter(e=>e!==n),n];t(r),Ho(r)}]}function Wo(e){let t=typeof e.statusSince==`number`&&Number.isFinite(e.statusSince)?`Reported ${In(new Date(e.statusSince))}`:void 0,n=[e.activity?.trim().replace(/\.$/,``),t].filter(e=>!!e);return n.length?`${n.join(`. `)}.`:``}function Go(e,t=Date.now()){return e.condition?Ln({condition:e.condition},t):``}function R({row:e,onViewAgent:t,onDismiss:n,post:r=null,selfId:i=null}){let a=ae(),o=Go(e);return(0,P.jsxs)(jo,{size:`sm`,children:[(0,P.jsxs)(Mo,{children:[(0,P.jsxs)(No,{className:`flex items-center gap-2`,children:[(0,P.jsx)(he,{vendor:e.harness,status:e.status,size:22,badge:a(e.id)}),`${e.name} is waiting`]}),(0,P.jsx)(Po,{className:`line-clamp-2`,children:Wo(e)}),o&&(0,P.jsx)(Po,{children:o}),(0,P.jsx)(Fo,{children:(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(St,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":Ro,onClick:n,children:(0,P.jsx)(M,{icon:an})})}),(0,P.jsx)(E,{children:Ro})]})})]}),(0,P.jsxs)(Io,{className:`flex-wrap gap-2`,children:[(0,P.jsx)(St,{type:`button`,variant:`outline`,disabled:!t,onClick:()=>t?.(e.id),children:`View agent`}),r?.mode===`off`?(0,P.jsxs)(St,{type:`button`,variant:`outline`,onClick:()=>sn(be({kind:`dm`,to:e.id})),children:[(0,P.jsx)(M,{icon:zt,"data-icon":`inline-start`}),`Copy command`]}):(0,P.jsx)(St,{asChild:!0,children:(0,P.jsx)(`a`,{href:It(Wt(e.id,i)),onClick:()=>Vt({kind:`dm`,to:e.id}),children:`Message ${e.name}`})})]})]})}function z({rows:e}){let t=ae(),n=d().isMobile;if(e.length===0)return null;let r=e.length-3;return(0,P.jsxs)(`div`,{className:`ox-typing`,role:`status`,"aria-live":`polite`,children:[e.slice(0,3).map(e=>(0,P.jsxs)(Pn,{className:`ox-wline`,children:[(0,P.jsx)(he,{vendor:e.harness,status:e.status,size:18,dot:!1,badge:t(e.id)}),(0,P.jsxs)(Ie,{className:`ox-wline-c`,children:[(0,P.jsx)(`b`,{children:e.name}),` is ${Bt(e)}`,e.activity&&(0,P.jsxs)(P.Fragment,{children:[` `,(0,P.jsx)(`span`,{className:`ox-shimmer`,children:e.activity})]})]}),(0,P.jsx)(`a`,{className:`ox-act`,href:It({view:`agent`,id:e.id,tab:`work`}),children:n?`View`:(0,P.jsxs)(P.Fragment,{children:[`View work`,(0,P.jsx)(M,{icon:vt,size:16})]})})]},e.id)),r>0&&(0,P.jsx)(`div`,{className:`ox-wmore`,children:`and ${r} more`})]})}var Ko=4,qo=[],Jo=e=>typeof e.toService==`string`?`anycast`:typeof e.to==`string`?`unicast`:`chat`,Yo={s:[`second`,`seconds`],m:[`minute`,`minutes`],h:[`hour`,`hours`],d:[`day`,`days`]};function Xo(e){let t=[];if(e?.deliveryClass===`durable`&&t.push({text:`durable`,title:`Kept for members who are offline`}),e?.replay===!0){let n=e.replayWindow;if(n===void 0)t.push({text:`replay`,title:`New members see every message the channel keeps`});else{let e=/^(\d+)(s|m|h|d)$/.exec(n.trim()),r=e?Number(e[1])===1?Yo[e[2]][0]:`${e[1]} ${Yo[e[2]][1]}`:n;t.push({text:`replay ${n}`,title:`New members see the last ${r}`})}}return t}function Zo(e,t){let n=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},r=n(t),i=n(e);if(i===r)return`Today`;if(i===n(r-432e5))return`Yesterday`;let a=new Date(e),o=a.getFullYear()===new Date(t).getFullYear();return a.toLocaleDateString(`en-GB`,o?{day:`numeric`,month:`long`}:{day:`numeric`,month:`long`,year:`numeric`})}var Qo=({msg:e,senderId:t})=>`${e.id}\u0001${t??``}`;function $o({messages:e,idx:t,peers:n,self:r}){let i=Date.now(),o=[],s=[],c=()=>{if(s.length===0)return;let i=s;s=[],o.push((0,P.jsx)(En,{messageId:Qo(e[i[0]]),children:(0,P.jsx)(Lt,{children:i.map((o,s)=>{let{msg:c,senderId:l}=e[o],u=Jo(c);return(0,P.jsx)(a,{msg:c,senderId:l,mode:u,idx:t,peers:n,run:i.length===1?`alone`:s===0?`first`:s===i.length-1?`last`:`middle`,own:l!==void 0&&l===r,mention:`operator`,claim:u===`anycast`?wo(c.id,e.slice(o+1)):void 0},Qo(e[o]))})})},Qo(e[i[0]])))},l;return e.forEach(({msg:t,senderId:n},r)=>{let a=Number.isFinite(t.ts)?Zo(t.ts,i):void 0,u=a!==void 0&&a!==l;(u||n===void 0||e[r-1]?.senderId!==n)&&c(),u&&o.push((0,P.jsx)(En,{children:(0,P.jsx)(Pn,{variant:`separator`,children:(0,P.jsx)(Ie,{children:a})})},`day\u0001${Qo(e[r])}`)),a!==void 0&&(l=a),s.push(r)}),c(),(0,P.jsx)(P.Fragment,{children:o})}function B(){return(0,P.jsx)(bt,{behavior:Dn()?`auto`:`smooth`})}function es({store:e,channel:t,onMembers:n,onViewAgent:r,panelOpen:a=!1,onTogglePanel:o}){let s=A(e,e=>e.open),c=A(e,e=>e.space),l=A(e,e=>e.channels),u=A(e,e=>e.roster),f=A(e,e=>e.membership),p=A(e,e=>e.post),m=A(e,e=>e.operatorId),h=s?.channel===t?s.messages:qo,g=(0,N.useMemo)(()=>({kind:`msg`,channel:t}),[t]),_=(0,N.useMemo)(()=>new Set(h.map(e=>e.msg.id)),[h]),v=(0,N.useMemo)(()=>Tn(u),[u]),y=(0,N.useMemo)(()=>hn(u,{includeOffline:!0}),[u]),b=(0,N.useMemo)(()=>new Map(y.map(e=>[e.id,e])),[y]),x=ae(),S=l.find(e=>e.channel===t),ee=(0,N.useMemo)(()=>$e(t,f,l.map(e=>e.channel),h),[t,f,l,h]),C=ee.map(e=>b.get(e.id)).filter(e=>e?.status===`working`),[w,te]=Uo(),ne=dt(y).find(e=>!w.has(zo(e))),T=ee.length,re=d().isMobile,ie=re?`Open agent panel`:`Toggle panel`,oe=`${T} member${T===1?``:`s`}`,se=`Working now: ${C.map(e=>e.name).join(`, `)}`;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(`h1`,{children:`# ${t}`}),S?.description&&(0,P.jsx)(`span`,{className:`ui-topic`,children:S.description}),(0,P.jsx)(`span`,{className:`ui-sp`}),!re&&Xo(S).map(e=>(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(gt,{variant:`outline`,children:[e.text,(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${e.title}`})]})}),(0,P.jsx)(E,{children:e.title})]},e.text)),C.length>0&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(`span`,{className:`ox-hchip`,children:[(0,P.jsx)(M,{icon:bn,size:16,className:`ui-ic ox-spin`}),re?C.length:`${C.length} working`,(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${se}`})]})}),(0,P.jsx)(E,{children:se})]}),(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(`span`,{className:`inline-flex`,tabIndex:n?void 0:0,children:(0,P.jsxs)(St,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":oe,disabled:!n,onClick:n,children:[(0,P.jsx)(`span`,{className:`ui-stack`,"aria-hidden":`true`,children:ee.slice(0,Ko).map(e=>{let t=b.get(e.id);return(0,P.jsx)(he,{vendor:t?.harness,status:t?.status??`offline`,badge:t?x(e.id):void 0,size:22},e.id)})}),T]})})}),(0,P.jsx)(E,{children:oe})]}),o&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(Be,{"aria-label":ie,pressed:a,onPressedChange:o,children:(0,P.jsx)(M,{icon:i})})}),(0,P.jsx)(E,{children:ie})]})]}),(0,P.jsx)(wt,{autoScroll:!0,children:(0,P.jsxs)(yn,{className:`flex-1`,children:[(0,P.jsx)(At,{children:(0,P.jsxs)(Qt,{className:`ui-col`,children:[s?.channel===t&&s.olderRetained&&(0,P.jsxs)(En,{className:`text-sm text-muted-foreground`,children:[(0,P.jsx)(`p`,{children:`Earlier messages are retained. To read further back, run:`}),(0,P.jsx)(`code`,{className:`[overflow-wrap:anywhere]`,children:`cotal history ${ke(`#${t}`)} --limit 2000${c===null?``:` --space ${ke(c)}`}`})]}),(0,P.jsx)($o,{messages:h,idx:v,peers:b,self:m}),(0,P.jsx)(gn,{store:e,target:g,shown:_}),C.length>0&&(0,P.jsx)(En,{children:(0,P.jsx)(z,{rows:C})})]})}),(0,P.jsx)(B,{})]})},t),(ne||p)&&(0,P.jsx)(`div`,{className:`ui-dock`,children:(0,P.jsxs)(`div`,{className:`ui-dock-in`,children:[ne&&(0,P.jsx)(R,{row:ne,onViewAgent:r,onDismiss:()=>te(zo(ne)),post:p,selfId:m}),(0,P.jsx)(rn,{store:e,target:g,where:`#${t}`,to:re?`to #${t}`:`to #${t} · ${T} member${T===1?``:`s`}`})]})})]})}function ts({store:e,peer:t,with:n}){let r=A(e,e=>e.dms),i=A(e,e=>e.roster),a=A(e,e=>e.post),o=A(e,e=>e.operatorId),s=(0,N.useMemo)(()=>Tn(i),[i]),c=(0,N.useMemo)(()=>hn(i,{includeOffline:!0}),[i]),l=(0,N.useMemo)(()=>new Map(c.map(e=>[e.id,e])),[c]),u=A(e,e=>e.dmsCut),d=n??o??void 0,f=(0,N.useMemo)(()=>{if(d===void 0)return;let e=yt(t,d);return on(r).find(t=>t.key===e)},[r,t,d]),p=l.get(t),m=ae(),h=Zt(t,s,o),g=[p?.role,p?.harness&&ve(p.harness)].filter(Boolean).join(` · `),_=(0,N.useMemo)(()=>Jt({view:`dm`,peer:t,with:n},o),[t,n,o]),v=(0,N.useMemo)(()=>new Set(r.map(e=>e.msg.id)),[r]),y=A(e,e=>_?e.drafts[Ee(_)]?.outgoing.length??0:0),b=_?.kind===`dm`?Zt(_.to,s,o):``,x=[...new Set([t,d])].map(e=>e===void 0?void 0:l.get(e)).filter(e=>e?.status===`working`);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(he,{vendor:p?.harness,status:p?.status??`offline`,size:22,badge:p?m(t):void 0}),(0,P.jsx)(`h1`,{children:h}),g&&(0,P.jsx)(`span`,{className:`ui-topic`,children:g}),f&&d!==void 0&&(0,P.jsx)(`span`,{className:`ui-topic`,children:`with ${Zt(d,s,o)}`}),f&&!f.verified&&(0,P.jsx)(Ht,{})]}),(0,P.jsx)(wt,{autoScroll:!0,children:(0,P.jsxs)(yn,{className:`flex-1`,children:[(0,P.jsx)(At,{children:(0,P.jsx)(Qt,{className:`ui-col`,children:f||y>0?(0,P.jsxs)(P.Fragment,{children:[f&&u&&(0,P.jsx)(En,{children:(0,P.jsx)(Pn,{children:(0,P.jsx)(Ie,{children:`Earlier messages aren't loaded`})})}),f&&(0,P.jsx)($o,{messages:f.messages,idx:s,peers:l,self:o}),_&&(0,P.jsx)(gn,{store:e,target:_,shown:v}),x.length>0&&(0,P.jsx)(En,{children:(0,P.jsx)(z,{rows:x})})]}):(0,P.jsx)(En,{children:(0,P.jsx)(We,{children:(0,P.jsx)(fe,{children:(0,P.jsx)(le,{children:`No direct messages with ${h} yet.`})})})})})}),(0,P.jsx)(B,{})]})},`${t}\u0001${d??``}`),a&&(_||n!==void 0)&&(0,P.jsx)(`div`,{className:`ui-dock`,children:(0,P.jsx)(`div`,{className:`ui-dock-in`,children:_?(0,P.jsx)(rn,{store:e,target:_,where:b,to:`to ${b}`}):(0,P.jsx)(Et,{peer:t,name:h,selfId:o})})})]})}var ns=`cotal.agents.group`,rs=1e3;function is(){try{let e=globalThis.localStorage?.getItem(ns);return e===`status`||e===`host`?e:void 0}catch{return}}function as(e){try{globalThis.localStorage?.setItem(ns,e)}catch{}}function os(e){let t=[...new Set(e.map(e=>e.status).filter(e=>!xn.includes(e)))].sort();return[...xn,...t].map(t=>({key:t,label:re(t),rows:e.filter(e=>e.status===t)})).filter(e=>e.rows.length>0)}function ss(e){let t=[...new Set(e.map(e=>e.host).filter(e=>e!==void 0))].sort((e,t)=>e.localeCompare(t)).map(t=>({key:`host:${t}`,label:t,rows:e.filter(e=>e.host===t)})),n=e.filter(e=>e.host===void 0);return n.length>0?[...t,{key:`host:`,label:`No host reported`,rows:n}]:t}var cs=e=>[e.role,e.harness===void 0?void 0:ve(e.harness)].filter(Boolean).join(` · `);function ls(e,t){return e.status===`offline`?`Last heartbeat ${In(new Date(e.ts))}`:e.status===`waiting`&&t===`status`?Wo(e)||`No current activity`:e.activity?.trim()||(e.status===`working`?re(Bt(e)):`No current activity`)}function us(e,t){let n=e.items.findLast(e=>e.kind===`turn`&&e.outcome===`open`&&!e.superseded),r=n?.steps.findLast(e=>e.kind!==`runError`);if(n===void 0||r?.kind!==`tools`)return;let i=r.calls.findLast(r=>ct(r,{turn:n,trailing:!0,status:t,toolStatus:e.toolStatus})===`running`);return i===void 0?void 0:{call:i,turn:n}}function ds({store:e,controller:t,row:n}){jt(n.events===`off`?null:t,n.id);let r=A(e,e=>e.sessions[n.id]?.frames),i=Pt(e,n.id),a=(0,N.useMemo)(()=>r===void 0?void 0:us(zn(r,i),n.status),[r,i,n.status]);return a===void 0?null:(0,P.jsx)(`span`,{className:`ox-now-w`,"aria-hidden":`true`,children:(0,P.jsx)(Dt,{call:a.call,state:`running`,className:`ox-now`})})}function fs({row:e,grouping:t,selected:n,onPick:r,live:i}){let a=e.attention===`dnd`||e.attention===`focus`?e.attention:void 0,o=e.status===`waiting`&&t===`status`,s=ae();return(0,P.jsxs)(`div`,{className:e.status===`working`?`ox-arow ox-arow-w`:`ox-arow`,children:[(0,P.jsxs)(`button`,{type:`button`,className:e.status===`offline`?`v3-arow v3-arow-off`:`v3-arow`,"data-agent":e.id,"aria-current":n?`true`:void 0,onClick:()=>r?.(e.id),children:[(0,P.jsx)(he,{vendor:e.harness,status:e.status,size:36,badge:s(e.id)}),(0,P.jsxs)(`span`,{children:[(0,P.jsxs)(`span`,{className:`v3-aname`,children:[(0,P.jsx)(`b`,{title:e.name,children:e.name}),(0,P.jsx)(`span`,{children:cs(e)})]}),(0,P.jsx)(`span`,{className:`v3-aact`,style:o?{color:`var(--gold-ink)`}:void 0,children:ls(e,t)}),i&&(0,P.jsx)(ds,{store:i.store,controller:i.controller,row:e})]}),a?(0,P.jsx)(ot,{attention:a}):(0,P.jsx)(`span`,{}),t===`host`?(0,P.jsx)(l,{row:e}):e.host!==void 0&&e.status!==`working`?(0,P.jsxs)(`span`,{className:`v3-meta ox-host`,children:[(0,P.jsx)(M,{icon:ka,size:16,className:`ui-ic`}),e.host]}):(0,P.jsx)(`span`,{})]}),e.status===`working`&&(0,P.jsxs)(`a`,{className:`ox-act`,href:It({view:`agent`,id:e.id,tab:`work`}),children:[`View work`,(0,P.jsx)(M,{icon:vt,size:16})]})]})}function ps({rows:e}){return(0,P.jsxs)(`div`,{className:`v3-epsec`,children:[(0,P.jsxs)(`div`,{className:`v3-ghead`,style:{paddingTop:12},children:[(0,P.jsx)(M,{icon:Oa,size:16,className:`ui-ic`}),(0,P.jsx)(`span`,{style:{color:`var(--dim)`},children:`Endpoints`}),(0,P.jsx)(`span`,{className:`v3-count`,children:e.length})]}),e.map(e=>(0,P.jsxs)(`div`,{className:`v3-eprow`,children:[(0,P.jsx)(`span`,{className:e.status===`offline`?`ui-av ui-av-ep ui-av-off`:`ui-av ui-av-ep`,children:(0,P.jsx)(M,{icon:Aa,size:16,className:`ui-ic ui-ic16`})}),(0,P.jsx)(`b`,{children:e.name}),(0,P.jsx)(`span`,{children:[e.role,e.host,e.status===`offline`?re(e.status):void 0].filter(Boolean).join(` · `)})]},e.id))]})}function ms({beat:e,clock:t}){let[,n]=(0,N.useReducer)(e=>e+1,0);return(0,N.useEffect)(()=>{let e=setInterval(n,rs);return()=>clearInterval(e)},[]),(0,P.jsxs)(`div`,{className:`v3-eprow`,style:{paddingLeft:66,fontSize:12.5},children:[`Oldest heartbeat among live agents: `,(0,P.jsx)(`span`,{className:`ui-num`,children:pt(t()-e)}),` ago`]})}function hs({store:e,controller:t=null,group:n,focusWaiting:r=!1,selected:i=null,onPick:a,clock:o=Date.now}){let s=A(e,e=>e.roster),c=A(e,e=>e.space),l=A(e,e=>e.stale),[u,d]=(0,N.useState)(n??`status`),f=(0,N.useRef)(null);(0,N.useLayoutEffect)(()=>d(n??is()??`status`),[n]);let{agents:p,endpoints:m}=(0,N.useMemo)(()=>{let e=e=>e.card.kind===`agent`;return{agents:hn(s.filter(e),{includeOffline:!0}),endpoints:hn(s.filter(t=>!e(t)),{includeOffline:!0})}},[s]),h=u===`status`?os(p):ss(p),g=p.length===0,_=h.some(e=>e.key===`waiting`)&&u===`status`,v=(0,N.useRef)(!1);(0,N.useLayoutEffect)(()=>{if(!r){v.current=!1;return}if(g||v.current)return;v.current=!0;let e=_?f.current:null;e?.focus({preventScroll:!0}),e?.scrollIntoView?.({block:`start`})},[r,g]);let y=e=>{d(e),as(e)},b=p.filter(e=>e.status!==`offline`).length,x=l.some(e=>e.name===`roster`),S=new Set(x?[]:h.flatMap(e=>e.rows).filter(e=>e.status===`working`).slice(0,12).map(e=>e.id)),ee=nn(p);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(`h1`,{children:`Agents`}),!g&&(0,P.jsx)(`span`,{className:`ui-topic`,children:x?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`ui-num`,children:b}),` last seen`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`ui-num`,children:b}),` live, `,(0,P.jsx)(`span`,{className:`ui-num`,children:p.length-b}),` offline`,c===null?``:` on ${c}`]})}),(0,P.jsx)(`span`,{className:`ui-sp`}),!g&&(0,P.jsxs)(So,{type:`single`,size:`sm`,"aria-label":`Group by`,value:u,onValueChange:e=>(e===`status`||e===`host`)&&y(e),children:[(0,P.jsx)(Co,{value:`status`,children:`Status`}),(0,P.jsx)(Co,{value:`host`,children:`Host`})]})]}),(0,P.jsx)(`div`,{className:`ui-scroll`,children:(0,P.jsxs)(`div`,{className:x?`ui-col s-lastseen`:`ui-col`,style:{maxWidth:900},children:[g&&(0,P.jsx)(To,{space:c}),!g&&(0,P.jsxs)(`div`,{className:u===`status`?`v3-by-status`:`v3-by-host`,children:[h.flatMap(n=>{let o=u===`status`?n.key:void 0,s=o!==void 0&&Object.hasOwn(Vn,o);return[(0,P.jsxs)(`div`,{className:s?`v3-ghead v3-s-${o}`:`v3-ghead`,role:`heading`,"aria-level":2,ref:o===`waiting`?f:void 0,tabIndex:o===`waiting`?-1:void 0,"data-focused":o===`waiting`&&r?`true`:void 0,children:[s&&(0,P.jsx)(M,{icon:Vn[o],size:16,className:qe(n.key,`ui-ic`)}),u===`host`&&(0,P.jsx)(M,{icon:ka,size:16,className:`ui-ic`}),(0,P.jsx)(`span`,{style:{color:o===`offline`?`var(--dim)`:`var(--ink)`},children:n.label}),(0,P.jsx)(`span`,{className:`v3-count`,children:n.rows.length})]},`head:${n.key}`),...n.rows.map(n=>(0,P.jsx)(fs,{row:n,grouping:u,selected:i===n.id,onPick:a,live:S.has(n.id)?{store:e,controller:t}:void 0},`row:${n.id}`))]}),u===`status`&&!x&&ee!==void 0&&Number.isFinite(ee)&&(0,P.jsx)(ms,{beat:ee,clock:o})]},u),m.length>0&&(0,P.jsx)(ps,{rows:m})]})})]})}var gs=[];function _s(e,t){let n=0,r=e.steps.length;for(;r>0&&n<t;){let t=e.steps[--r];t.kind!==`prompt`&&t.kind!==`reasoning`&&n++}return{...e,steps:e.steps.slice(r)}}function vs({turn:e,current:t,row:n}){let r=cn(t),{title:i,failed:a}=ht(e,n.status,r);return(0,P.jsxs)(`div`,{className:`ui-lt-head ox-now-head`,children:[(0,P.jsx)(`h5`,{children:t?`Now`:`Last turn`}),(0,P.jsxs)(`span`,{className:`ox-now-t`,children:[i,a!==void 0&&(0,P.jsxs)(P.Fragment,{children:[`, `,(0,P.jsxs)(`span`,{className:`ox-fail`,children:[(0,P.jsx)(M,{icon:ut,size:16}),a]})]})]})]})}function ys({store:e,id:t}){let n=A(e,e=>e.roster),r=A(e,e=>e.operatorId),i=A(e,e=>e.sessions[t]?.frames)??gs,a=A(e,e=>e.sessions[t]?.payloadRead),o=Pt(e,t),s=n.find(e=>e.card.id===t),c=(0,N.useMemo)(()=>s?hn([s],{includeOffline:!0})[0]:void 0,[s]),l=(0,N.useMemo)(()=>j(s),[s]),u=(0,N.useMemo)(()=>{let e=Tn(n);return t=>Zt(t,e,r)},[n,r]),d=(0,N.useMemo)(()=>zn(i,o),[i,o]);if(!c)return null;if(c.events===`off`)return(0,P.jsx)(_n,{children:`${c.name} publishes no work events.`});let f=d.items.filter(e=>e.kind===`turn`),p=f.findLast(e=>e.outcome===`open`&&!e.superseded),m=p!==void 0&&(c.status===`working`||c.status===`waiting`),h=m?p:f.at(-1);return h?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(vs,{turn:h,current:m,row:c}),(0,P.jsx)(Rt,{payloadRead:a,work:{items:[_s(h,3)],toolStatus:d.toolStatus},row:c,compact:!0,condition:l,nameOf:u})]}):null}function bs({store:e,controller:t=null,id:n,route:r}){let i=A(e,e=>e.roster),a=A(e,e=>e.operatorId),o=i.find(e=>e.card.id===n),s=(0,N.useMemo)(()=>o?hn([o],{includeOffline:!0})[0].events:void 0,[o]);jt(o&&s!==`off`?t:null,n);let c=ae();if(!o)return(0,P.jsx)(`p`,{className:`ui-nr`,children:`Not on the roster`});let u=hn([o],{includeOffline:!0})[0],d=[u.role,u.harness&&ve(u.harness)].filter(Boolean).join(` · `),f=typeof u.statusSince==`number`&&Number.isFinite(u.statusSince)?`Reported ${In(new Date(u.statusSince))}`:void 0;return(0,P.jsxs)(`div`,{className:`ox-peek`,children:[(0,P.jsxs)(`div`,{className:`ox-peek-who`,children:[(0,P.jsx)(he,{vendor:u.harness,status:u.status,size:44,badge:c(u.id)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`b`,{children:u.name}),d&&(0,P.jsx)(`div`,{className:`ui-sub`,children:d})]})]}),(0,P.jsxs)(`div`,{className:`ui-sline`,children:[(0,P.jsx)(l,{row:u}),(0,P.jsx)(`span`,{style:{color:`var(--ink)`},children:u.activity||`No current activity`}),f&&(0,P.jsx)(`small`,{children:f}),Ln(u,Date.now())&&(0,P.jsx)(`small`,{className:`ui-facts`,children:Ln(u,Date.now())})]}),(r?.view!==`agent`||r.id!==n)&&(0,P.jsx)(ys,{store:e,id:n}),(0,P.jsxs)(`div`,{className:`ui-actions`,children:[(0,P.jsx)(St,{asChild:!0,size:`sm`,children:(0,P.jsxs)(`a`,{href:It({view:`agent`,id:u.id,tab:`work`}),children:[(0,P.jsx)(M,{icon:vt,"data-icon":`inline-start`}),`Open ${u.name}'s page`]})}),(0,P.jsx)(St,{asChild:!0,variant:`outline`,size:`sm`,children:(0,P.jsxs)(`a`,{href:It(Wt(u.id,a)),onClick:()=>Vt({kind:`dm`,to:u.id}),children:[(0,P.jsx)(M,{icon:Tt,"data-icon":`inline-start`}),`Message`]})})]})]})}var xs={live:{word:`live`,cls:`ui-mdot-live`,title:`From broker membership, served by the delivery daemon`},stale:{word:`stale`,cls:`ui-mdot-stale`,title:`The daemon's last report is older than 45 seconds, or has no time on it`},"traffic-only":{word:`traffic-only`,cls:`ui-mdot-traffic`,title:`No delivery daemon on an open mesh, so members come from who has posted`},unreadable:{word:`unreadable`,cls:`ui-mdot-unread`}};function Ss({state:e,reason:t}){let n=xs[e],r=e===`unreadable`?t?`the read failed: ${t}`:`the read failed`:n.title;return(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(gt,{variant:e===`unreadable`?`destructive`:`outline`,children:[(0,P.jsx)(`i`,{className:`ui-mdot ${n.cls}`}),`Membership: `,n.word,(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${r}`})]})}),(0,P.jsx)(E,{children:r})]})}function Cs({...e}){return(0,P.jsx)(Ar,{"data-slot":`alert-dialog`,...e})}function ws({...e}){return(0,P.jsx)(jr,{"data-slot":`alert-dialog-trigger`,...e})}function Ts({...e}){return(0,P.jsx)(Mr,{"data-slot":`alert-dialog-portal`,...e})}function Es({className:e,...t}){return(0,P.jsx)(Nr,{"data-slot":`alert-dialog-overlay`,className:r(`fixed inset-0 z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Ds({className:e,size:t=`default`,...n}){return(0,P.jsxs)(Ts,{children:[(0,P.jsx)(Es,{}),(0,P.jsx)(Ir,{"data-slot":`alert-dialog-content`,"data-size":t,className:r(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-[min(var(--radius-4xl),24px)] bg-popover p-6 text-popover-foreground shadow-xl ring-1 ring-foreground/5 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-md dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function Os({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:r(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function ks({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:r(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function As({className:e,...t}){return(0,P.jsx)(Lr,{"data-slot":`alert-dialog-title`,className:r(`text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function js({className:e,...t}){return(0,P.jsx)(Rr,{"data-slot":`alert-dialog-description`,className:r(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Ms({className:e,variant:t=`default`,size:n=`default`,...i}){return(0,P.jsx)(St,{variant:t,size:n,asChild:!0,children:(0,P.jsx)(zr,{"data-slot":`alert-dialog-action`,className:r(e),...i})})}function Ns({className:e,variant:t=`outline`,size:n=`default`,...i}){return(0,P.jsx)(St,{variant:t,size:n,asChild:!0,children:(0,P.jsx)(Vr,{"data-slot":`alert-dialog-cancel`,className:r(e),...i})})}function Ps({className:e,type:t,...n}){return(0,P.jsx)(`input`,{type:t,"data-slot":`input`,className:r(`h-8 w-full min-w-0 rounded-2xl border border-transparent bg-input/50 px-2.5 py-1 text-base transition-[color,box-shadow] duration-200 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function Fs({channel:e,space:t,controller:n,children:r}){let[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(null),[u,d]=(0,N.useState)(!1),f=(0,N.useRef)(null),p=(0,N.useId)(),h=o===e,g=e=>{a(e),e&&(s(``),l(null),d(!1))},_=async()=>{if(h&&n!==null&&!u){d(!0),l(null);try{await n.deleteChannel(e),a(!1)}catch(e){l(e instanceof Error?e.message:String(e)),d(!1)}}};return(0,P.jsxs)(Cs,{open:i,onOpenChange:g,children:[(0,P.jsx)(ws,{asChild:!0,children:r}),(0,P.jsxs)(Ds,{onOpenAutoFocus:e=>{e.preventDefault(),f.current?.focus()},children:[(0,P.jsxs)(Os,{children:[(0,P.jsx)(As,{children:`Delete #${e}?`}),(0,P.jsx)(js,{children:`This deletes every message in #${e} for everyone${t?` on ${t}`:``}. You can't undo it. If anyone posts to #${e} again, it comes back empty.`})]}),(0,P.jsxs)(Nt,{children:[(0,P.jsx)(lt,{htmlFor:p,children:(0,P.jsxs)(`span`,{children:[`Type `,(0,P.jsx)(`b`,{children:e}),` to confirm`]})}),(0,P.jsx)(Ps,{ref:f,id:p,value:o,autoComplete:`off`,spellCheck:!1,onChange:e=>s(e.target.value)})]}),c!==null&&(0,P.jsx)(m,{variant:`destructive`,children:(0,P.jsx)(we,{children:c})}),(0,P.jsxs)(ks,{children:[(0,P.jsx)(Ns,{children:`Keep channel`}),(0,P.jsxs)(Ms,{variant:`destructive`,disabled:!h||u||n===null,onClick:e=>{e.preventDefault(),_()},children:[(0,P.jsx)(M,{icon:Da,"data-icon":`inline-start`}),`Delete #${e}`]})]})]})]})}var Is=[];function Ls(e){if(e?.deliveryClass===void 0)return;let t=[e.deliveryClass];return e.replay===!0&&t.push(e.replayWindow===void 0?`replay`:`replay ${e.replayWindow}`),t.join(`, `)}function Rs({store:e,controller:t,channel:r,now:i,onPick:a}){let o=A(e,e=>e.space),s=A(e,e=>e.roster),c=A(e,e=>e.channels),u=A(e,e=>e.membership),d=A(e,e=>e.channelDeleteSupported),f=A(e,e=>e.open),p=f?.channel===r?f.messages:Is,m=(0,N.useMemo)(()=>Tn(s),[s]),h=(0,N.useMemo)(()=>hn(s,{includeOffline:!0}),[s]),g=(0,N.useMemo)(()=>{let e=new Map(h.map((e,t)=>[e.id,t])),t=t=>e.get(t)??h.length;return $e(r,u,c.map(e=>e.channel),p).sort((e,n)=>t(e.id)-t(n.id))},[r,u,c,p,h]),_=ae(),v=(0,N.useMemo)(()=>new Map(h.map(e=>[e.id,e])),[h]),y=c.find(e=>e.channel===r),b=Ls(y),x=g.length;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`v3-mhead`,children:[(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`b`,{style:{color:`var(--ink)`,fontWeight:600},children:`#${r}`}),` · `,(0,P.jsx)(`span`,{className:`ui-num`,children:x}),x===1?` member`:` members`]}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsx)(Ss,{state:n(u,i),reason:u.unreadable})]}),g.map(e=>{let t=v.get(e.id);return(0,P.jsxs)(`button`,{type:`button`,className:`v3-mrow`,"data-member":e.id,"data-source":e.source,onClick:()=>a(e.id),children:[(0,P.jsx)(he,{vendor:t?.harness,status:t?.status??`offline`,size:28,dot:t!==void 0,badge:t?_(e.id):void 0}),(0,P.jsxs)(`span`,{className:`v3-mname`,children:[t?.name??Zt(e.id,m),t?.role&&(0,P.jsx)(`span`,{children:t.role})]}),t&&(0,P.jsx)(l,{row:t})]},e.id)}),(0,P.jsx)(`h5`,{style:{marginTop:14},children:`Channel`}),(0,P.jsxs)(`dl`,{className:`ui-kv`,style:{borderTop:0,paddingTop:0},children:[y?.description&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`dt`,{children:`Topic`}),(0,P.jsx)(`dd`,{children:y.description})]}),b&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`dt`,{children:`Delivery`}),(0,P.jsx)(`dd`,{children:b})]}),y&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`dt`,{children:`Messages`}),(0,P.jsx)(`dd`,{className:`ui-num`,children:y.messages})]})]}),d&&(0,P.jsx)(Fs,{channel:r,space:o,controller:t,children:(0,P.jsxs)(St,{type:`button`,variant:`destructive`,className:`mt-1`,children:[(0,P.jsx)(M,{icon:Da,"data-icon":`inline-start`}),`Delete channel`]})})]})}var zs={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Bs(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),zs.hasOwnProperty(t)?{space:zs[t],local:e}:e}function Vs(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Hs(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Us(e){var t=Bs(e);return(t.local?Hs:Vs)(t)}function Ws(){}function Gs(e){return e==null?Ws:function(){return this.querySelector(e)}}function Ks(e){typeof e!=`function`&&(e=Gs(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Nl(r,this._parents)}function qs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Js(){return[]}function Ys(e){return e==null?Js:function(){return this.querySelectorAll(e)}}function Xs(e){return function(){return qs(e.apply(this,arguments))}}function Zs(e){e=typeof e==`function`?Xs(e):Ys(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Nl(r,i)}function Qs(e){return function(){return this.matches(e)}}function $s(e){return function(t){return t.matches(e)}}var ec=Array.prototype.find;function tc(e){return function(){return ec.call(this.children,e)}}function nc(){return this.firstElementChild}function rc(e){return this.select(e==null?nc:tc(typeof e==`function`?e:$s(e)))}var ic=Array.prototype.filter;function ac(){return Array.from(this.children)}function oc(e){return function(){return ic.call(this.children,e)}}function sc(e){return this.selectAll(e==null?ac:oc(typeof e==`function`?e:$s(e)))}function cc(e){typeof e!=`function`&&(e=Qs(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Nl(r,this._parents)}function lc(e){return Array(e.length)}function uc(){return new Nl(this._enter||this._groups.map(lc),this._parents)}function dc(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}dc.prototype={constructor:dc,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function fc(e){return function(){return e}}function pc(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new dc(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function mc(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new dc(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function hc(e){return e.__data__}function gc(e,t){if(!arguments.length)return Array.from(this,hc);var n=t?mc:pc,r=this._parents,i=this._groups;typeof e!=`function`&&(e=fc(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=_c(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Nl(o,r),o._enter=s,o._exit=c,o}function _c(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function vc(){return new Nl(this._exit||this._groups.map(lc),this._parents)}function yc(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function bc(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Nl(s,this._parents)}function xc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Sc(e){e||=Cc;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Nl(i,this._parents).order()}function Cc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function wc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Tc(){return Array.from(this)}function Ec(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Dc(){let e=0;for(let t of this)++e;return e}function Oc(){return!this.node()}function kc(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function Ac(e){return function(){this.removeAttribute(e)}}function jc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mc(e,t){return function(){this.setAttribute(e,t)}}function Nc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Pc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Fc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ic(e,t){var n=Bs(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?jc:Ac:typeof t==`function`?n.local?Fc:Pc:n.local?Nc:Mc)(n,t))}function Lc(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Rc(e){return function(){this.style.removeProperty(e)}}function zc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Bc(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Vc(e,t,n){return arguments.length>1?this.each((t==null?Rc:typeof t==`function`?Bc:zc)(e,t,n??``)):Hc(this.node(),e)}function Hc(e,t){return e.style.getPropertyValue(t)||Lc(e).getComputedStyle(e,null).getPropertyValue(t)}function Uc(e){return function(){delete this[e]}}function Wc(e,t){return function(){this[e]=t}}function Gc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Kc(e,t){return arguments.length>1?this.each((t==null?Uc:typeof t==`function`?Gc:Wc)(e,t)):this.node()[e]}function qc(e){return e.trim().split(/^|\s+/)}function Jc(e){return e.classList||new Yc(e)}function Yc(e){this._node=e,this._names=qc(e.getAttribute(`class`)||``)}Yc.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Xc(e,t){for(var n=Jc(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Zc(e,t){for(var n=Jc(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Qc(e){return function(){Xc(this,e)}}function $c(e){return function(){Zc(this,e)}}function el(e,t){return function(){(t.apply(this,arguments)?Xc:Zc)(this,e)}}function tl(e,t){var n=qc(e+``);if(arguments.length<2){for(var r=Jc(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?el:t?Qc:$c)(n,t))}function nl(){this.textContent=``}function rl(e){return function(){this.textContent=e}}function il(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function al(e){return arguments.length?this.each(e==null?nl:(typeof e==`function`?il:rl)(e)):this.node().textContent}function ol(){this.innerHTML=``}function sl(e){return function(){this.innerHTML=e}}function cl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function ll(e){return arguments.length?this.each(e==null?ol:(typeof e==`function`?cl:sl)(e)):this.node().innerHTML}function ul(){this.nextSibling&&this.parentNode.appendChild(this)}function dl(){return this.each(ul)}function fl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function pl(){return this.each(fl)}function ml(e){var t=typeof e==`function`?e:Us(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function hl(){return null}function gl(e,t){var n=typeof e==`function`?e:Us(e),r=t==null?hl:typeof t==`function`?t:Gs(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function _l(){var e=this.parentNode;e&&e.removeChild(this)}function vl(){return this.each(_l)}function yl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function V(e){return this.select(e?bl:yl)}function xl(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Sl(e){return function(t){e.call(this,t,this.__data__)}}function Cl(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function wl(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Tl(e,t,n){return function(){var r=this.__on,i,a=Sl(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function El(e,t,n){var r=Cl(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}}else{for(s=t?Tl:wl,i=0;i<a;++i)this.each(s(r[i],t,n));return this}}function Dl(e,t,n){var r=Lc(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Ol(e,t){return function(){return Dl(this,e,t)}}function kl(e,t){return function(){return Dl(this,e,t.apply(this,arguments))}}function Al(e,t){return this.each((typeof t==`function`?kl:Ol)(e,t))}function*jl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Ml=[null];function Nl(e,t){this._groups=e,this._parents=t}function Pl(){return new Nl([[document.documentElement]],Ml)}function Fl(){return this}Nl.prototype=Pl.prototype={constructor:Nl,select:Ks,selectAll:Zs,selectChild:rc,selectChildren:sc,filter:cc,data:gc,enter:uc,exit:vc,join:yc,merge:bc,selection:Fl,order:xc,sort:Sc,call:wc,nodes:Tc,node:Ec,size:Dc,empty:Oc,each:kc,attr:Ic,style:Vc,property:Kc,classed:tl,text:al,html:ll,raise:dl,lower:pl,append:ml,insert:gl,remove:vl,clone:V,datum:xl,on:El,dispatch:Al,[Symbol.iterator]:jl};function Il(e){return typeof e==`string`?new Nl([[document.querySelector(e)]],[document.documentElement]):new Nl([[e]],Ml)}function Ll(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Rl(e,t){if(e=Ll(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var zl={value:()=>{}};function Bl(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Vl(n)}function Vl(e){this._=e}function Hl(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Vl.prototype=Bl.prototype={constructor:Vl,on:function(e,t){var n=this._,r=Hl(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Ul(n[i],e.name)))return i}else{if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Wl(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Wl(n[i],e.name,null);return this}},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Vl(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Ul(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Wl(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=zl,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Gl={capture:!0,passive:!1};function Kl(e){e.preventDefault(),e.stopImmediatePropagation()}function ql(e){var t=e.document.documentElement,n=Il(e).on(`dragstart.drag`,Kl,Gl);`onselectstart`in t?n.on(`selectstart.drag`,Kl,Gl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function Jl(e,t){var n=e.document.documentElement,r=Il(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,Kl,Gl),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Yl(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Xl(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Zl(){}var Ql=.7,$l=1/Ql,eu=`\\s*([+-]?\\d+)\\s*`,tu=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,nu=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,ru=/^#([0-9a-f]{3,8})$/,iu=RegExp(`^rgb\\(${eu},${eu},${eu}\\)$`),au=RegExp(`^rgb\\(${nu},${nu},${nu}\\)$`),ou=RegExp(`^rgba\\(${eu},${eu},${eu},${tu}\\)$`),su=RegExp(`^rgba\\(${nu},${nu},${nu},${tu}\\)$`),H=RegExp(`^hsl\\(${tu},${nu},${nu}\\)$`),cu=RegExp(`^hsla\\(${tu},${nu},${nu},${tu}\\)$`),lu={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};Yl(Zl,mu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:uu,formatHex:uu,formatHex8:du,formatHsl:fu,formatRgb:pu,toString:pu});function uu(){return this.rgb().formatHex()}function du(){return this.rgb().formatHex8()}function fu(){return Eu(this).formatHsl()}function pu(){return this.rgb().formatRgb()}function mu(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=ru.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?hu(t):n===3?new yu(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?gu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?gu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=iu.exec(e))?new yu(t[1],t[2],t[3],1):(t=au.exec(e))?new yu(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ou.exec(e))?gu(t[1],t[2],t[3],t[4]):(t=su.exec(e))?gu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=H.exec(e))?Tu(t[1],t[2]/100,t[3]/100,1):(t=cu.exec(e))?Tu(t[1],t[2]/100,t[3]/100,t[4]):lu.hasOwnProperty(e)?hu(lu[e]):e===`transparent`?new yu(NaN,NaN,NaN,0):null}function hu(e){return new yu(e>>16&255,e>>8&255,e&255,1)}function gu(e,t,n,r){return r<=0&&(e=t=n=NaN),new yu(e,t,n,r)}function _u(e){return e instanceof Zl||(e=mu(e)),e?(e=e.rgb(),new yu(e.r,e.g,e.b,e.opacity)):new yu}function vu(e,t,n,r){return arguments.length===1?_u(e):new yu(e,t,n,r??1)}function yu(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Yl(yu,vu,Xl(Zl,{brighter(e){return e=e==null?$l:$l**+e,new yu(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ql:Ql**+e,new yu(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new yu(Cu(this.r),Cu(this.g),Cu(this.b),U(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:bu,formatHex:bu,formatHex8:xu,formatRgb:Su,toString:Su}));function bu(){return`#${wu(this.r)}${wu(this.g)}${wu(this.b)}`}function xu(){return`#${wu(this.r)}${wu(this.g)}${wu(this.b)}${wu((isNaN(this.opacity)?1:this.opacity)*255)}`}function Su(){let e=U(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Cu(this.r)}, ${Cu(this.g)}, ${Cu(this.b)}${e===1?`)`:`, ${e})`}`}function U(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Cu(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function wu(e){return e=Cu(e),(e<16?`0`:``)+e.toString(16)}function Tu(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ou(e,t,n,r)}function Eu(e){if(e instanceof Ou)return new Ou(e.h,e.s,e.l,e.opacity);if(e instanceof Zl||(e=mu(e)),!e)return new Ou;if(e instanceof Ou)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Ou(o,s,c,e.opacity)}function Du(e,t,n,r){return arguments.length===1?Eu(e):new Ou(e,t,n,r??1)}function Ou(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Yl(Ou,Du,Xl(Zl,{brighter(e){return e=e==null?$l:$l**+e,new Ou(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ql:Ql**+e,new Ou(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new yu(ju(e>=240?e-240:e+120,i,r),ju(e,i,r),ju(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Ou(ku(this.h),Au(this.s),Au(this.l),U(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(){let e=U(this.opacity);return`${e===1?`hsl(`:`hsla(`}${ku(this.h)}, ${Au(this.s)*100}%, ${Au(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function ku(e){return e=(e||0)%360,e<0?e+360:e}function Au(e){return Math.max(0,Math.min(1,e||0))}function ju(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Mu=e=>()=>e;function Nu(e,t){return function(n){return e+n*t}}function Pu(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Fu(e){return(e=+e)==1?Iu:function(t,n){return n-t?Pu(t,n,e):Mu(isNaN(t)?n:t)}}function Iu(e,t){var n=t-e;return n?Nu(e,n):Mu(isNaN(e)?t:e)}var Lu=(function e(t){var n=Fu(t);function r(e,t){var r=n((e=vu(e)).r,(t=vu(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Iu(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Ru(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var zu=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Bu=new RegExp(zu.source,`g`);function Vu(e){return function(){return e}}function Hu(e){return function(t){return e(t)+``}}function Uu(e,t){var n=zu.lastIndex=Bu.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=zu.exec(e))&&(i=Bu.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Ru(r,i)})),n=Bu.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?Hu(c[0].x):Vu(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}var Wu=180/Math.PI,Gu={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ku(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*Wu,skewX:Math.atan(c)*Wu,scaleX:o,scaleY:s}}var qu;function Ju(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?Gu:Ku(t.a,t.b,t.c,t.d,t.e,t.f)}function Yu(e){return e==null||(qu||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),qu.setAttribute(`transform`,e),!(e=qu.transform.baseVal.consolidate()))?Gu:(e=e.matrix,Ku(e.a,e.b,e.c,e.d,e.e,e.f))}function Xu(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:Ru(e,i)},{i:c-2,x:Ru(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Ru(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Ru(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Ru(e,n)},{i:s-2,x:Ru(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Zu=Xu(Ju,`px, `,`px)`,`deg)`),Qu=Xu(Yu,`, `,`)`,`)`),$u=1e-12;function ed(e){return((e=Math.exp(e))+1/e)/2}function td(e){return((e=Math.exp(e))-1/e)/2}function W(e){return((e=Math.exp(2*e))-1)/(e+1)}var G=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<$u)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=ed(y),c=s/(n*g)*(i*W(t*r+y)-td(y));return[a+c*d,o+c*f,s*i/ed(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),K=0,q=0,J=0,nd=1e3,rd,id,ad=0,od=0,Y=0,sd=typeof performance==`object`&&performance.now?performance:Date,cd=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ld(){return od||=(cd(ud),sd.now()+Y)}function ud(){od=0}function dd(){this._call=this._time=this._next=null}dd.prototype=fd.prototype={constructor:dd,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?ld():+n)+(t==null?0:+t),!this._next&&id!==this&&(id?id._next=this:rd=this,id=this),this._call=e,this._time=n,_d()},stop:function(){this._call&&(this._call=null,this._time=1/0,_d())}};function fd(e,t,n){var r=new dd;return r.restart(e,t,n),r}function pd(){ld(),++K;for(var e=rd,t;e;)(t=od-e._time)>=0&&e._call.call(void 0,t),e=e._next;--K}function md(){od=(ad=sd.now())+Y,K=q=0;try{pd()}finally{K=0,gd(),od=0}}function hd(){var e=sd.now(),t=e-ad;t>nd&&(Y-=t,ad=e)}function gd(){for(var e,t=rd,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:rd=n);id=e,_d(r)}function _d(e){K||(q&&=clearTimeout(q),e-od>24?(e<1/0&&(q=setTimeout(md,e-sd.now()-Y)),J&&=clearInterval(J)):(J||=(ad=sd.now(),setInterval(hd,nd)),K=1,cd(md)))}function vd(e,t,n){var r=new dd;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var yd=Bl(`start`,`end`,`cancel`,`interrupt`),X=[];function bd(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;wd(e,n,{name:t,index:r,group:i,on:yd,tween:X,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function xd(e,t){var n=Cd(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Sd(e,t){var n=Cd(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Cd(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function wd(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=fd(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return vd(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(vd(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function Td(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n)(r=n[o]).name===t?(i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]):a=!1;a&&delete e.__transition}}function Ed(e){return this.each(function(){Td(this,e)})}function Dd(e,t){var n,r;return function(){var i=Sd(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Od(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=Sd(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function kd(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=Cd(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Dd:Od)(n,e,t))}function Ad(e,t,n){var r=e._id;return e.each(function(){var e=Sd(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return Cd(e,r).value[t]}}function jd(e,t){var n;return(typeof t==`number`?Ru:t instanceof mu?Lu:(n=mu(t))?(t=n,Lu):Uu)(e,t)}function Md(e){return function(){this.removeAttribute(e)}}function Nd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pd(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function Fd(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function Id(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Ld(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Rd(e,t){var n=Bs(e),r=n===`transform`?Qu:jd;return this.attrTween(e,typeof t==`function`?(n.local?Ld:Id)(n,r,Ad(this,`attr.`+e,t)):t==null?(n.local?Nd:Md)(n):(n.local?Fd:Pd)(n,r,t))}function zd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Bd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Vd(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Bd(e,i)),n}return i._value=t,i}function Hd(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&zd(e,i)),n}return i._value=t,i}function Ud(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=Bs(e);return this.tween(n,(r.local?Vd:Hd)(r,t))}function Wd(e,t){return function(){xd(this,e).delay=+t.apply(this,arguments)}}function Gd(e,t){return t=+t,function(){xd(this,e).delay=t}}function Kd(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Wd:Gd)(t,e)):Cd(this.node(),t).delay}function qd(e,t){return function(){Sd(this,e).duration=+t.apply(this,arguments)}}function Jd(e,t){return t=+t,function(){Sd(this,e).duration=t}}function Yd(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?qd:Jd)(t,e)):Cd(this.node(),t).duration}function Xd(e,t){if(typeof t!=`function`)throw Error();return function(){Sd(this,e).ease=t}}function Zd(e){var t=this._id;return arguments.length?this.each(Xd(t,e)):Cd(this.node(),t).ease}function Qd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();Sd(this,e).ease=n}}function $d(e){if(typeof e!=`function`)throw Error();return this.each(Qd(this._id,e))}function ef(e){typeof e!=`function`&&(e=Qs(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new kf(r,this._parents,this._name,this._id)}function tf(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new kf(o,this._parents,this._name,this._id)}function nf(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function rf(e,t,n){var r,i,a=nf(t)?xd:Sd;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function af(e,t){var n=this._id;return arguments.length<2?Cd(this.node(),n).on.on(e):this.each(rf(n,e,t))}function of(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function sf(){return this.on(`end.remove`,of(this._id))}function cf(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Gs(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,bd(l[f],t,n,f,l,Cd(u,n)));return new kf(a,this._parents,t,n)}function lf(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ys(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=Cd(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&bd(p,t,n,h,f,m);a.push(f),o.push(u)}return new kf(a,o,t,n)}var uf=Pl.prototype.constructor;function df(){return new uf(this._groups,this._parents)}function ff(e,t){var n,r,i;return function(){var a=Hc(this,e),o=(this.style.removeProperty(e),Hc(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function pf(e){return function(){this.style.removeProperty(e)}}function Z(e,t,n){var r,i=n+``,a;return function(){var o=Hc(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function mf(e,t,n){var r,i,a;return function(){var o=Hc(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),Hc(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function hf(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=Sd(this,e),l=c.on,u=c.value[a]==null?s||=pf(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function gf(e,t,n){var r=(e+=``)==`transform`?Zu:jd;return t==null?this.styleTween(e,ff(e,r)).on(`end.style.`+e,pf(e)):typeof t==`function`?this.styleTween(e,mf(e,r,Ad(this,`style.`+e,t))).each(hf(this._id,e)):this.styleTween(e,Z(e,r,t),n).on(`end.style.`+e,null)}function _f(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function vf(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&_f(e,a,n)),r}return a._value=t,a}function yf(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,vf(e,t,n??``))}function bf(e){return function(){this.textContent=e}}function xf(e){return function(){var t=e(this);this.textContent=t??``}}function Sf(e){return this.tween(`text`,typeof e==`function`?xf(Ad(this,`text`,e)):bf(e==null?``:e+``))}function Cf(e){return function(t){this.textContent=e.call(this,t)}}function wf(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Cf(r)),t}return r._value=e,r}function Tf(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,wf(e))}function Ef(){for(var e=this._name,t=this._id,n=Af(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=Cd(c,t);bd(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new kf(r,this._parents,e,n)}function Df(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=Sd(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Of=0;function kf(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Af(){return++Of}var jf=Pl.prototype;kf.prototype={constructor:kf,select:cf,selectAll:lf,selectChild:jf.selectChild,selectChildren:jf.selectChildren,filter:ef,merge:tf,selection:df,transition:Ef,call:jf.call,nodes:jf.nodes,node:jf.node,size:jf.size,empty:jf.empty,each:jf.each,on:af,attr:Rd,attrTween:Ud,style:gf,styleTween:yf,text:Sf,textTween:Tf,remove:sf,tween:kd,delay:Kd,duration:Yd,ease:Zd,easeVarying:$d,end:Df,[Symbol.iterator]:jf[Symbol.iterator]};function Mf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Nf={time:null,delay:0,duration:250,ease:Mf};function Pf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function Ff(e){var t,n;e instanceof kf?(t=e._id,e=e._name):(t=Af(),(n=Nf).time=ld(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&bd(c,e,t,l,o,n||Pf(c,t));return new kf(r,this._parents,e,t)}Pl.prototype.interrupt=Ed,Pl.prototype.transition=Ff;var If=e=>()=>e;function Lf(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Rf(e,t,n){this.k=e,this.x=t,this.y=n}Rf.prototype={constructor:Rf,scale:function(e){return e===1?this:new Rf(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Rf(this.k,this.x+this.k*e,this.y+this.k*t)},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 zf=new Rf(1,0,0);Bf.prototype=Rf.prototype;function Bf(e){for(;!e.__zoom;)if(!(e=e.parentNode))return zf;return e.__zoom}function Vf(e){e.stopImmediatePropagation()}function Q(e){e.preventDefault(),e.stopImmediatePropagation()}function Hf(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function Uf(){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 Wf(){return this.__zoom||zf}function Gf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Kf(){return navigator.maxTouchPoints||`ontouchstart`in this}function qf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function Jf(){var e=Hf,t=Uf,n=qf,r=Gf,i=Kf,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=G,l=Bl(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Wf).on(`wheel.zoom`,C,{passive:!1}).on(`mousedown.zoom`,w).on(`dblclick.zoom`,te).filter(i).on(`touchstart.zoom`,ne).on(`touchmove.zoom`,T).on(`touchend.zoom touchcancel.zoom`,re).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Wf),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(zf.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Rf(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Rf(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Rf(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new ee(e,t)}function ee(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}ee.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Il(this.that).datum();l.call(e,this.that,new Lf(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function C(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Rl(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Td(this),s.start();Q(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function w(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Il(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Rl(t,i),l=t.clientX,u=t.clientY;ql(t.view),Vf(t),a.mouse=[c,this.__zoom.invert(c)],Td(this),a.start();function d(e){if(Q(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Rl(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),Jl(e.view,a.moved),Q(e),a.event(e).end()}}function te(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Rl(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Q(r),s>0?Il(this).transition().duration(s).call(x,d,c,r):Il(this).call(_.transform,d,c,r)}}function ne(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(Vf(t),s=0;s<i;++s)c=r[s],l=Rl(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),Td(this),a.start())}}function T(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(Q(e),s=0;s<a;++s)c=i[s],l=Rl(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function re(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(Vf(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=Rl(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=Il(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:If(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:If(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:If(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:If([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}function Yf(e,t){var n,r=1;e??=0,t??=0;function i(){var i,a=n.length,o,s=0,c=0;for(i=0;i<a;++i)o=n[i],s+=o.x,c+=o.y;for(s=(s/a-e)*r,c=(c/a-t)*r,i=0;i<a;++i)o=n[i],o.x-=s,o.y-=c}return i.initialize=function(e){n=e},i.x=function(t){return arguments.length?(e=+t,i):e},i.y=function(e){return arguments.length?(t=+e,i):t},i.strength=function(e){return arguments.length?(r=+e,i):r},i}function Xf(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Zf(this.cover(t,n),t,n,e)}function Zf(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function Qf(e){var t,n,r=e.length,i,a,o=Array(r),s=Array(r),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(a=+this._y.call(null,t))||(o[n]=i,s[n]=a,i<c&&(c=i),i>u&&(u=i),a<l&&(l=a),a>d&&(d=a));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n<r;++n)Zf(this,o[n],s[n],e[n]);return this}function $f(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t<r)<<1|e<n,c=[,,,,],c[l]=s,s=c,o*=2,l){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function ep(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function $(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function tp(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function np(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new tp(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)<i||(l=m.y1)<a)){if(p.length){var g=(o+c)/2,_=(s+l)/2;f.push(new tp(p[3],g,_,c,l),new tp(p[2],o,_,g,l),new tp(p[1],g,s,c,_),new tp(p[0],o,s,g,_)),(h=(t>=_)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var v=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=v*v+y*y;if(b<n){var x=Math.sqrt(n=b);i=e-x,a=t-x,u=e+x,d=t+x,r=p.data}}}return r}function rp(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function ip(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function ap(){return this._root}function op(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function sp(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new tp(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new tp(i,l,u,s,c)),(i=r[2])&&t.push(new tp(i,a,u,l,c)),(i=r[1])&&t.push(new tp(i,l,o,s,u)),(i=r[0])&&t.push(new tp(i,a,o,l,u))}return this}function cp(e){var t=[],n=[],r;for(this._root&&t.push(new tp(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new tp(a,o,s,u,d)),(a=i[1])&&t.push(new tp(a,u,s,c,d)),(a=i[2])&&t.push(new tp(a,o,d,u,l)),(a=i[3])&&t.push(new tp(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function lp(e){return e[0]}function up(e){return arguments.length?(this._x=e,this):this._x}function dp(e){return e[1]}function fp(e){return arguments.length?(this._y=e,this):this._y}function pp(e,t,n){var r=new mp(t??lp,n??dp,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function mp(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function hp(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var gp=pp.prototype=mp.prototype;gp.copy=function(){var e=new mp(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=hp(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=hp(r));return e},gp.add=Xf,gp.addAll=Qf,gp.cover=$f,gp.data=ep,gp.extent=$,gp.find=np,gp.remove=rp,gp.removeAll=ip,gp.root=ap,gp.size=op,gp.visit=sp,gp.visitAfter=cp,gp.x=up,gp.y=fp;function _p(e){return function(){return e}}function vp(e){return(e()-.5)*1e-6}function yp(e){return e.x+e.vx}function bp(e){return e.y+e.vy}function xp(e){var t,n,r,i=1,a=1;typeof e!=`function`&&(e=_p(e==null?1:+e));function o(){for(var e,o=t.length,c,l,u,d,f,p,m=0;m<a;++m)for(c=pp(t,yp,bp).visitAfter(s),e=0;e<o;++e)l=t[e],f=n[l.index],p=f*f,u=l.x+l.vx,d=l.y+l.vy,c.visit(h);function h(e,t,n,a,o){var s=e.data,c=e.r,m=f+c;if(s){if(s.index>l.index){var h=u-s.x-s.vx,g=d-s.y-s.vy,_=h*h+g*g;_<m*m&&(h===0&&(h=vp(r),_+=h*h),g===0&&(g=vp(r),_+=g*g),_=(m-(_=Math.sqrt(_)))/_*i,l.vx+=(h*=_)*(m=(c*=c)/(p+c)),l.vy+=(g*=_)*m,s.vx-=h*(m=1-m),s.vy-=g*m)}}else return t>u+m||a<u-m||n>d+m||o<d-m}}function s(e){if(e.data)return e.r=n[e.data.index];for(var t=e.r=0;t<4;++t)e[t]&&e[t].r>e.r&&(e.r=e[t].r)}function c(){if(t){var r,i=t.length,a;for(n=Array(i),r=0;r<i;++r)a=t[r],n[a.index]=+e(a,r,t)}}return o.initialize=function(e,n){t=e,r=n,c()},o.iterations=function(e){return arguments.length?(a=+e,o):a},o.strength=function(e){return arguments.length?(i=+e,o):i},o.radius=function(t){return arguments.length?(e=typeof t==`function`?t:_p(+t),c(),o):e},o}function Sp(e){return e.index}function Cp(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function wp(e){var t=Sp,n=d,r,i=_p(30),a,o,s,c,l,u=1;e??=[];function d(e){return 1/Math.min(s[e.source.index],s[e.target.index])}function f(t){for(var n=0,i=e.length;n<u;++n)for(var o=0,s,d,f,p,m,h,g;o<i;++o)s=e[o],d=s.source,f=s.target,p=f.x+f.vx-d.x-d.vx||vp(l),m=f.y+f.vy-d.y-d.vy||vp(l),h=Math.sqrt(p*p+m*m),h=(h-a[o])/h*t*r[o],p*=h,m*=h,f.vx-=p*(g=c[o]),f.vy-=m*g,d.vx+=p*(g=1-g),d.vy+=m*g}function p(){if(o){var n,i=o.length,l=e.length,u=new Map(o.map((e,n)=>[t(e,n,o),e])),d;for(n=0,s=Array(i);n<l;++n)d=e[n],d.index=n,typeof d.source!=`object`&&(d.source=Cp(u,d.source)),typeof d.target!=`object`&&(d.target=Cp(u,d.target)),s[d.source.index]=(s[d.source.index]||0)+1,s[d.target.index]=(s[d.target.index]||0)+1;for(n=0,c=Array(l);n<l;++n)d=e[n],c[n]=s[d.source.index]/(s[d.source.index]+s[d.target.index]);r=Array(l),m(),a=Array(l),h()}}function m(){if(o)for(var t=0,i=e.length;t<i;++t)r[t]=+n(e[t],t,e)}function h(){if(o)for(var t=0,n=e.length;t<n;++t)a[t]=+i(e[t],t,e)}return f.initialize=function(e,t){o=e,l=t,p()},f.links=function(t){return arguments.length?(e=t,p(),f):e},f.id=function(e){return arguments.length?(t=e,f):t},f.iterations=function(e){return arguments.length?(u=+e,f):u},f.strength=function(e){return arguments.length?(n=typeof e==`function`?e:_p(+e),m(),f):n},f.distance=function(e){return arguments.length?(i=typeof e==`function`?e:_p(+e),h(),f):i},f}var Tp=1664525,Ep=1013904223,Dp=4294967296;function Op(){let e=1;return()=>(e=(Tp*e+Ep)%Dp)/Dp}function kp(e){return e.x}function Ap(e){return e.y}var jp=10,Mp=Math.PI*(3-Math.sqrt(5));function Np(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=fd(d),l=Bl(`tick`,`end`),u=Op();e??=[];function d(){f(),l.call(`tick`,t),n<r&&(c.stop(),l.call(`end`,t))}function f(r){var c,l=e.length,u;r===void 0&&(r=1);for(var d=0;d<r;++d)for(n+=(a-n)*i,s.forEach(function(e){e(n)}),c=0;c<l;++c)u=e[c],u.fx==null?u.x+=u.vx*=o:(u.x=u.fx,u.vx=0),u.fy==null?u.y+=u.vy*=o:(u.y=u.fy,u.vy=0);return t}function p(){for(var t=0,n=e.length,r;t<n;++t){if(r=e[t],r.index=t,r.fx!=null&&(r.x=r.fx),r.fy!=null&&(r.y=r.fy),isNaN(r.x)||isNaN(r.y)){var i=jp*Math.sqrt(.5+t),a=t*Mp;r.x=i*Math.cos(a),r.y=i*Math.sin(a)}(isNaN(r.vx)||isNaN(r.vy))&&(r.vx=r.vy=0)}}function m(t){return t.initialize&&t.initialize(e,u),t}return p(),t={tick:f,restart:function(){return c.restart(d),t},stop:function(){return c.stop(),t},nodes:function(n){return arguments.length?(e=n,p(),s.forEach(m),t):e},alpha:function(e){return arguments.length?(n=+e,t):n},alphaMin:function(e){return arguments.length?(r=+e,t):r},alphaDecay:function(e){return arguments.length?(i=+e,t):+i},alphaTarget:function(e){return arguments.length?(a=+e,t):a},velocityDecay:function(e){return arguments.length?(o=1-e,t):1-o},randomSource:function(e){return arguments.length?(u=e,s.forEach(m),t):u},force:function(e,n){return arguments.length>1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i<a;++i)l=e[i],o=t-l.x,s=n-l.y,c=o*o+s*s,c<r&&(u=l,r=c);return u},on:function(e,n){return arguments.length>1?(l.on(e,n),t):l.on(e)}}}function Pp(){var e,t,n,r,i=_p(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=pp(e,kp,Ap).visitAfter(d);for(r=n,i=0;i<a;++i)t=e[i],o.visit(f)}function u(){if(e){var t,n=e.length,r;for(a=Array(n),t=0;t<n;++t)r=e[t],a[r.index]=+i(r,t,e)}}function d(e){var t=0,n,r,i=0,o,s,c;if(e.length){for(o=s=c=0;c<4;++c)(n=e[c])&&(r=Math.abs(n.value))&&(t+=n.value,i+=r,o+=r*n.x,s+=r*n.y);e.x=o/i,e.y=s/i}else{n=e,n.x=n.data.x,n.y=n.data.y;do t+=a[n.data.index];while(n=n.next)}e.value=t}function f(e,i,l,u){if(!e.value)return!0;var d=e.x-t.x,f=e.y-t.y,p=u-i,m=d*d+f*f;if(p*p/c<m)return m<s&&(d===0&&(d=vp(n),m+=d*d),f===0&&(f=vp(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)),t.vx+=d*e.value*r/m,t.vy+=f*e.value*r/m),!0;if(!(e.length||m>=s)){(e.data!==t||e.next)&&(d===0&&(d=vp(n),m+=d*d),f===0&&(f=vp(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)));do e.data!==t&&(p=a[e.data.index]*r/m,t.vx+=d*p,t.vy+=f*p);while(e=e.next)}}return l.initialize=function(t,r){e=t,n=r,u()},l.strength=function(e){return arguments.length?(i=typeof e==`function`?e:_p(+e),u(),l):i},l.distanceMin=function(e){return arguments.length?(o=e*e,l):Math.sqrt(o)},l.distanceMax=function(e){return arguments.length?(s=e*e,l):Math.sqrt(s)},l.theta=function(e){return arguments.length?(c=e*e,l):Math.sqrt(c)},l}function Fp(e){var t=_p(.1),n,r,i;typeof e!=`function`&&(e=_p(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t<a;++t)o=n[t],o.vx+=(i[t]-o.x)*r[t]*e}function o(){if(n){var a,o=n.length;for(r=Array(o),i=Array(o),a=0;a<o;++a)r[a]=isNaN(i[a]=+e(n[a],a,n))?0:+t(n[a],a,n)}}return a.initialize=function(e){n=e,o()},a.strength=function(e){return arguments.length?(t=typeof e==`function`?e:_p(+e),o(),a):t},a.x=function(t){return arguments.length?(e=typeof t==`function`?t:_p(+t),o(),a):e},a}function Ip(e){var t=_p(.1),n,r,i;typeof e!=`function`&&(e=_p(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t<a;++t)o=n[t],o.vy+=(i[t]-o.y)*r[t]*e}function o(){if(n){var a,o=n.length;for(r=Array(o),i=Array(o),a=0;a<o;++a)r[a]=isNaN(i[a]=+e(n[a],a,n))?0:+t(n[a],a,n)}}return a.initialize=function(e){n=e,o()},a.strength=function(e){return arguments.length?(t=typeof e==`function`?e:_p(+e),o(),a):t},a.y=function(t){return arguments.length?(e=typeof t==`function`?t:_p(+t),o(),a):e},a}var Lp=e=>14+e.length*7,Rp=e=>e.kind===`channel`?Lp(e.label)/2+6:30;function zp(e){let t=e.nodes.map(e=>e.id).sort(),n=e.links.map(e=>`${e.source}\u0000${e.target}\u0000${e.kind}`).sort();return`${t.join(``)}\u0002${n.join(``)}`}var Bp=300,Vp=.5,Hp=20,Up=class{sim;links;bodies=new Map;key;size=``;width=0;height=0;constructor(e,t,n=1){this.links=wp([]).id(e=>e.id).strength(.4),this.sim=Np().force(`link`,this.links).force(`charge`,Pp()).force(`center`,Yf()).force(`x`,Fp()).force(`y`,Ip()).stop(),this.resize(e,t,n)}resize(e,t,n=1){let r=`${e}x${t}@${n}`;if(r===this.size)return!1;this.size=r,this.width=e,this.height=t;let i=Math.min(e,t)/n/420;return this.links.distance(90*i),this.sim.force(`charge`,Pp().strength(-280*i*i)).force(`center`,Yf(e/2,t/2)).force(`x`,Fp(e/2).strength(.04)).force(`y`,Ip(t/2).strength(.04)).force(`collide`,xp().radius(e=>e.r).iterations(n>1?3:1)),!0}sync(e){let t=zp(e);if(t===this.key)return!1;let n=new Map;for(let t of e.nodes)n.set(t.id,this.bodies.get(t.id)??{id:t.id,r:Rp(t)});return this.bodies=n,this.sim.nodes([...n.values()]),this.links.links(e.links.map(e=>({source:e.source,target:e.target}))),this.key=t,!0}warm(){this.sim.alpha(1);for(let e=0;e<Bp;e++)this.tick()}reheat(){this.sim.alpha(Math.max(this.sim.alpha(),Vp))}tick(){this.sim.tick();for(let e of this.bodies.values())e.x!==void 0&&(e.x=Math.min(Math.max(e.x,e.r),Math.max(e.r,this.width-e.r))),e.y!==void 0&&(e.y=Math.min(Math.max(e.y,e.r),this.height-e.r-Hp))}get settled(){return this.sim.alpha()<this.sim.alphaMin()}at(e){let t=this.bodies.get(e);return t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?{x:t.x,y:t.y}:void 0}},Wp={request:e=>globalThis.requestAnimationFrame(e),cancel:e=>globalThis.cancelAnimationFrame(e)};function Gp(e,t,n){return[`ui-tl`,`ui-tl-${e}`,n?`ui-tl-off`:``,t?`ui-tl-hot`:``].filter(Boolean).join(` `)}function Kp({status:e,x:t,y:n}){return(0,P.jsxs)(`g`,{className:`ui-tst ui-tst-${e}`,"aria-hidden":`true`,children:[e===`working`&&(0,P.jsx)(`circle`,{cx:t,cy:n,r:5}),e===`waiting`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:t,cy:n,r:5,className:`ui-tst-bg`}),(0,P.jsx)(`path`,{d:`M${t} ${n-4.2} A4.2 4.2 0 0 0 ${t} ${n+4.2} Z`}),(0,P.jsx)(`circle`,{cx:t,cy:n,r:4.2,className:`ui-tst-ring`})]}),(e===`idle`||e===`offline`)&&(0,P.jsx)(`circle`,{cx:t,cy:n,r:4.4})]})}function qp({r:e}){let t=2*Math.PI*e;return(0,P.jsxs)(`g`,{className:`ui-orbit-g`,"aria-hidden":`true`,children:[(0,P.jsx)(`circle`,{r:e,className:`ui-orbit-ring`}),(0,P.jsx)(`circle`,{r:e,className:`ui-orbit`,strokeDasharray:`${t/5} ${t*4/5}`})]})}function Jp({node:e,x:t,y:n,size:r,showName:i}){let a=e.status??`idle`,o=(0,N.useContext)(Se),s=ae()(e.id),c=r*.23,l=-r/2+c-3,u=r/2-c+2,d=s&&(0,P.jsxs)(`g`,{className:`ui-tidb`,"aria-hidden":`true`,children:[(0,P.jsx)(`circle`,{cx:l,cy:u,r:c,style:{fill:`var(--id-${a===`offline`?`off`:s.slot})`}}),(0,P.jsx)(`text`,{x:l,y:u+c*.42,textAnchor:`middle`,fontSize:[...s.letter].length>1?c*.95:c*1.2,children:s.letter})]});return(0,P.jsxs)(`g`,{className:a===`offline`?`ui-ta ui-ta-off`:`ui-ta`,"data-node":e.id,"data-pick":o?``:void 0,transform:`translate(${t} ${n})`,onClick:o?()=>o(e.id):void 0,children:[!i&&(0,P.jsx)(`title`,{children:e.label}),a===`working`&&(0,P.jsx)(qp,{r:r/2+7}),(0,P.jsxs)(`g`,{className:`ui-ta-art`,children:[(0,P.jsx)(`svg`,{x:-r/2,y:-r/2,width:r,height:r,viewBox:`-2 -4 112 112`,overflow:`visible`,dangerouslySetInnerHTML:{__html:Ne(e.vendor,a)}}),i&&(0,P.jsx)(`text`,{y:r/2+13,textAnchor:`middle`,className:`ui-ta-name`,children:e.label}),e.wide&&(0,P.jsxs)(`g`,{className:`ui-wide`,transform:`translate(0 ${r/2+26})`,children:[(0,P.jsx)(`rect`,{x:-70.4/2,y:-8,width:70.4,height:16,rx:6}),(0,P.jsx)(`text`,{y:3.5,textAnchor:`middle`,children:`all channels`})]})]}),d,(0,P.jsx)(Kp,{status:a,x:r/2-2,y:r/2-1})]})}function Yp({node:e,x:t,y:n,hot:r}){let i=Lp(e.label);return(0,P.jsxs)(`g`,{className:r?`ui-tn ui-tn-hot`:`ui-tn`,"data-node":e.id,transform:`translate(${t} ${n})`,children:[(0,P.jsx)(`rect`,{x:-i/2,y:-12,width:i,height:24,rx:8}),(0,P.jsxs)(`text`,{y:4,textAnchor:`middle`,children:[`#`,e.label]})]})}function Xp({model:e,width:t=400,height:n=420,drawingScale:r=1}){let i=t*r,a=n*r,o=(0,N.useRef)(null);o.current===null&&(o.current=new Up(i,a,r),o.current.sync(e),o.current.warm());let s=o.current,[,c]=(0,N.useReducer)(e=>e+1,0),l=(0,N.useRef)(0),u=()=>{if(l.current!==0||s.settled)return;let e=()=>{l.current=0,s.tick(),c(),s.settled||(l.current=Wp.request(e))};l.current=Wp.request(e)};(0,N.useEffect)(()=>{s.resize(i,a,r)&&s.reheat(),s.sync(e)&&s.reheat(),u()}),(0,N.useEffect)(()=>()=>{Wp.cancel(l.current),l.current=0},[]);let d=(0,N.useRef)(null),[f,p]=(0,N.useState)(zf);(0,N.useEffect)(()=>{let e=d.current;return Il(e).call(Jf().scaleExtent([.4,4]).on(`zoom`,e=>p(e.transform))),()=>void Il(e).on(`.zoom`,null)},[]);let m=e=>s.at(e)??{x:i/2,y:a/2},h=new Map(e.nodes.map(e=>[e.id,e])),g=new Set(e.links.filter(e=>e.hot).map(e=>e.target)),_=Math.min(40,t/10);return(0,P.jsx)(`svg`,{ref:d,className:`ui-topo-svg`,viewBox:`0 0 ${i} ${a}`,role:`img`,"aria-label":`Mesh topology`,children:(0,P.jsxs)(`g`,{transform:`translate(${f.x} ${f.y}) scale(${f.k})`,children:[e.links.map(e=>{let t=m(e.source),n=m(e.target);return(0,P.jsx)(`line`,{"data-link":`${e.source}>${e.target}`,className:Gp(e.kind,e.hot,h.get(e.source)?.status===`offline`),x1:t.x,y1:t.y,x2:n.x,y2:n.y},`${e.source}\u0000${e.target}`)}),e.nodes.filter(e=>e.kind===`channel`).map(e=>(0,P.jsx)(Yp,{node:e,...m(e.id),hot:g.has(e.id)},e.id)),e.nodes.filter(e=>e.kind===`agent`).map(e=>(0,P.jsx)(Jp,{node:e,...m(e.id),size:_,showName:r===1},e.id))]})})}var Zp=e=>`#${e}`;function Qp(e){let{roster:t,channels:n,membership:r,recent:i,hideOffline:a,hideEmpty:o,now:s}=e,c=Tn(t),l=new Map;for(let e of t){if(e.card.kind===`endpoint`||!e.card.id)continue;let t=e.card.meta?.connector;l.set(e.card.id,{id:e.card.id,kind:`agent`,label:e.card.name.trim()?e.card.name:e.card.id,...typeof t==`string`?{vendor:t}:{},status:e.status})}let u=new Set(n.map(e=>e.channel)),d=i.filter(e=>e.mode===`chat`&&e.channel).map(e=>({channel:e.channel,sender:e.senderId??e.msg.from.id,ts:e.ts}));for(let e of d)u.add(e.channel);let f=(r.unreadable===void 0?r.snapshot?.members??[]:[]).filter(e=>e.id);for(let e of f)for(let t of je(e.live??[],e.durable??[],[]).channels.keys())u.add(t);let p=new Set,m=new Map,h=(e,t)=>`${e}\u0000${t}`,g=[...u],_=n.filter(e=>e.deliveryClass===`durable`).map(e=>e.channel);for(let e of f){l.has(e.id)||l.set(e.id,{id:e.id,kind:`agent`,label:Zt(e.id,c),status:`offline`});let t=je(e.live??[],e.durable??[],g,_);t.wide&&p.add(e.id);for(let[n,r]of t.channels)m.set(h(e.id,n),{source:e.id,target:Zp(n),kind:r===`live`?`member`:`durable`,hot:!1})}for(let e of d){if(!e.sender)continue;l.has(e.sender)||l.set(e.sender,{id:e.sender,kind:`agent`,label:Zt(e.sender,c),status:`idle`});let t=h(e.sender,e.channel);m.has(t)||m.set(t,{source:e.sender,target:Zp(e.channel),kind:`traffic`,hot:!1})}for(let[e,t]of l)p.has(e)&&(t.wide=!0);for(let e of d)if(!(!e.sender||s-e.ts>=2e3))for(let t of m.values())t.target===Zp(e.channel)&&(t.hot=!0);let v=e=>l.get(e)?.status===`offline`,y=e=>a&&(e.kind===`durable`||v(e.source)),b=new Set;for(let e of m.values())e.kind!==`traffic`&&!y(e)&&b.add(e.target);let x=rt(r),S=e=>o&&x&&!b.has(Zp(e)),ee=[...l.values()].filter(e=>!(a&&e.status===`offline`));for(let e of u)S(e)||ee.push({id:Zp(e),kind:`channel`,label:e});let C=new Set(ee.map(e=>e.id));return{nodes:ee,links:[...m.values()].filter(e=>C.has(e.source)&&C.has(e.target)&&!(e.kind!==`traffic`&&y(e)))}}var $p=[{cls:`ui-lg-member`,label:`Member`},{cls:`ui-lg-durable`,label:`Durable member`},{cls:`ui-lg-offline`,label:`Offline agent`},{cls:`ui-lg-traffic`,label:`Posted here`},{cls:`ui-lg-hot`,label:`Active now`},{cls:`ui-lg-working`,label:`Working`}];function em(e,t,n){let r=A(e,e=>e.roster),i=A(e,e=>e.channels),a=A(e,e=>e.membership),o=A(e,e=>e.activity),[s,c]=(0,N.useState)(n),l=(0,N.useMemo)(()=>o.map(e=>({mode:e.mode,...`channel`in e&&e.channel!==void 0?{channel:e.channel}:{},...`senderId`in e&&e.senderId!==void 0?{senderId:e.senderId}:{},msg:e.msg,ts:e.arrivedAt??-1/0})),[o]),u=t(),d=Qp({roster:r,channels:i,membership:a,recent:l,hideOffline:s,hideEmpty:!0,now:u}),f=d.links.some(e=>e.hot),[,p]=(0,N.useReducer)(e=>e+1,0);return(0,N.useEffect)(()=>{let e=setInterval(p,f?500:5e3);return()=>clearInterval(e)},[f]),{model:d,membership:a,now:u,hideOffline:s,setHideOffline:c}}function tm({store:e,clock:t=Date.now,initialHideOffline:r=!0}){let{model:i,membership:a,now:o,hideOffline:s,setHideOffline:c}=em(e,t,r),l=Math.max(1,Math.sqrt(i.nodes.length/60));return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(`h1`,{children:`Topology`}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsx)(Ss,{state:n(a,o),reason:a.unreadable}),(0,P.jsx)(Be,{variant:`outline`,size:`sm`,pressed:s,onPressedChange:c,children:`Hide offline`})]}),(0,P.jsx)(`div`,{className:`ui-scroll`,children:(0,P.jsxs)(`div`,{className:`ui-col ui-col-wide`,children:[(0,P.jsx)(`div`,{className:`ui-topo`,children:(0,P.jsx)(Xp,{model:i,width:960,height:600,drawingScale:l})}),(0,P.jsxs)(`div`,{className:`ui-legend`,children:[$p.map(e=>(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`i`,{className:e.cls}),e.label]},e.cls)),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`b`,{className:`ui-wide-key`,children:`all channels`}),`Reads every channel`]})]})]})})]})}var nm={width:360,height:420};function rm({store:e,clock:t}){let{model:r,membership:i,now:a,hideOffline:o,setHideOffline:s}=em(e,t,!0);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginBottom:10},children:[(0,P.jsx)(Ss,{state:n(i,a),reason:i.unreadable}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsx)(Be,{variant:`outline`,size:`sm`,pressed:o,onPressedChange:s,children:`Hide offline`})]}),(0,P.jsx)(`div`,{className:`ui-topo`,children:(0,P.jsx)(Xp,{model:r,width:nm.width,height:nm.height})})]})}var im=`cotal.panel.open`;function am(){try{let e=globalThis.localStorage?.getItem(im);return e===`1`||e!==`0`&&void 0}catch{return}}function om(e){try{globalThis.localStorage?.setItem(im,e?`1`:`0`)}catch{}}var sm=e=>e.view===`agent`?`agent`:e.view===`channel`?`members`:`topology`;function cm(e,t=!1){let n=It(e),[r,i]=(0,N.useState)(!0),[a,o]=(0,N.useState)(!1),s=(0,N.useRef)(t);s.current=t,(0,N.useLayoutEffect)(()=>{let e=am();e!==void 0&&i(e)},[]);let[c,l]=(0,N.useState)(()=>({key:n,tab:sm(e),agent:e.view===`agent`?e.id:null})),u=c;c.key!==n&&(u={key:n,tab:sm(e),agent:e.view===`channel`?c.agent:null},e.view===`agent`&&(u={...u,agent:e.id}),l(u),o(!1));let d=(0,N.useMemo)(()=>{let e=e=>{if(s.current)return o(e);i(e),om(e)};return{setTab:e=>l(t=>({...t,tab:e})),selectAgent:t=>{l(e=>({...e,tab:`agent`,agent:t})),e(!0)},showMembers:()=>{l(e=>({...e,tab:`members`})),e(!0)},close:()=>e(!1),remember:e}},[]),f=t?a:r;return{open:f,tab:u.tab,agent:u.agent,setTab:d.setTab,selectAgent:d.selectAgent,showMembers:d.showMembers,close:d.close,toggle:()=>d.remember(!f)}}var lm=(e,t)=>e.open&&(t||e.agent!==null);function um({store:e,controller:t,channel:n,route:r,panel:i,clock:a}){let o=[{id:`members`,label:`Members`,off:n===null},{id:`agent`,label:`Agent`,off:i.agent===null},{id:`topology`,label:`Topology`,off:!1}];return(0,P.jsxs)(_t,{value:i.tab,onValueChange:e=>(e===`members`||e===`agent`||e===`topology`)&&i.setTab(e),className:`min-h-0 flex-1 gap-0`,children:[(0,P.jsxs)(`div`,{className:`ui-tabs`,children:[(0,P.jsx)(Cn,{"aria-label":`Details`,children:o.map(e=>(0,P.jsx)(xt,{value:e.id,disabled:e.off,children:e.label},e.id))}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(St,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close panel`,onClick:i.close,children:(0,P.jsx)(M,{icon:an})})}),(0,P.jsx)(E,{children:`Close panel`})]})]}),(0,P.jsx)(Xt,{value:`members`,className:`ui-pane-body`,children:n!==null&&(0,P.jsx)(Rs,{store:e,controller:t,channel:n,now:a(),onPick:i.selectAgent})}),(0,P.jsx)(Xt,{value:`agent`,className:`ui-pane-body`,children:i.agent!==null&&(0,P.jsx)(bs,{store:e,controller:t,id:i.agent,route:r})}),(0,P.jsx)(Xt,{value:`topology`,className:`ui-pane-body`,children:(0,P.jsx)(rm,{store:e,clock:a})})]})}var dm;function fm(){return Ue(()=>import(`./AgentPage-SDUlr64A.js`).then(e=>dm=e),__vite__mapDeps([0,1,2]))}var pm=(0,N.lazy)(()=>{let e=dm;return e?{then:t=>t({default:e.AgentPage})}:fm().then(e=>({default:e.AgentPage}))});function mm({store:e}){let t=br(A(e,e=>e.orderNotes));return(0,P.jsx)(`div`,{children:t&&(0,P.jsx)(`p`,{id:`order-notice`,role:t.fault?`alert`:`status`,children:t.text})})}function hm(e,t,n,r,i,a,o){switch(t.view){case`channel`:return(0,P.jsx)(es,{store:e,channel:t.channel,onMembers:r.showMembers,onViewAgent:r.selectAgent,panelOpen:i,onTogglePanel:r.toggle});case`activity`:return(0,P.jsx)(Ao,{store:e});case`dm`:return(0,P.jsx)(ts,{store:e,peer:t.peer,with:t.with});case`topology`:return(0,P.jsx)(tm,{store:e,clock:n});case`agents`:return(0,P.jsx)(hs,{store:e,controller:o.controller,group:t.group===`host`?`host`:void 0,selected:r.agent,onPick:a,clock:n});case`needs`:return(0,P.jsx)(hs,{store:e,controller:o.controller,group:`status`,focusWaiting:!0,selected:r.agent,onPick:a,clock:n});case`agent`:return(0,P.jsx)(N.Suspense,{fallback:(0,P.jsx)(fo,{}),children:(0,P.jsx)(pm,{store:e,controller:o.controller,id:t.id,tab:t.tab,at:t.at,back:o.back,phone:o.phone,panelOpen:o.panelOpen,onTogglePanel:o.toggle},t.id)})}}function gm({store:e,controller:t,route:n,paneOpen:r,msgPerSecond:i,clock:a=Date.now,phone:o=!1,panelSheet:s=o}){let c=A(e,e=>e.space),l=A(e,e=>e.channels),u=A(e,e=>e.roster),d=A(e,e=>e.dms),f=A(e,e=>e.loading),p=_m(n,l,d,u,A(e,e=>e.operatorId)),m=(0,N.useMemo)(()=>hn(u,{includeOffline:!0}),[u]),h=(0,N.useMemo)(()=>dt(m).length,[m]),g=(0,N.useMemo)(()=>u.filter(e=>e.card.kind===`agent`&&e.status===`working`).length,[u]),_=A(e,e=>e.stale.some(e=>e.name===`roster`)),v=(0,N.useMemo)(()=>S(m),[m]),y=cm(n,s),b=lm(y,r),x={...y,agent:b&&y.tab===`agent`?y.agent:null},ee=ym(n),C=(0,N.useContext)(mn),w=(0,N.useMemo)(()=>o?e=>C({view:`agent`,id:e,tab:`work`}):y.selectAgent,[o,C,y.selectAgent]),te={controller:t,phone:o,back:ee,panelOpen:b,toggle:y.toggle},ne=f.roster||f.channels?(0,P.jsx)(fo,{}):hm(e,n,a,x,b,w,te),T=(0,P.jsx)(um,{store:e,controller:t,channel:n.view===`channel`?n.channel:null,route:n,panel:y,clock:a});return(0,P.jsx)(Sn.Provider,{value:t,children:(0,P.jsx)(Se.Provider,{value:w,children:(0,P.jsx)(k.Provider,{value:v,children:(0,P.jsx)(Ke,{children:(0,P.jsxs)($a,{route:n,controller:t,paneOpen:b,panel:T,places:p,phone:o,panelSheet:s,waiting:h,working:g,stale:_,onPanelClose:y.close,sidebar:(0,P.jsx)(bo,{store:e,route:n,msgPerSecond:i}),children:[(0,P.jsx)(`title`,{children:xr(c)}),(0,P.jsx)(mm,{store:e}),(0,P.jsx)(`section`,{className:`ui-view`,"data-view":n.view,children:ne})]})})})})})}function _m(e,t,n,r,i){let[a,o]=(0,N.useState)({channel:null,dm:null}),s=a;e.view===`channel`&&a.channel!==e.channel&&(s={...a,channel:e.channel}),e.view===`dm`&&(a.dm?.peer!==e.peer||a.dm?.with!==e.with)&&(s={...s,dm:{peer:e.peer,with:e.with}}),s!==a&&o(s);let c=(0,N.useMemo)(()=>vn(n,r),[n,r]),l=s.channel!==null&&t.some(e=>e.channel===s.channel)?s.channel:t[0]?.channel??null,u=s.dm===null?null:s.dm.with??i,d=c[0]?.conversations[0];return{channel:l,dm:s.dm!==null&&u!==null&&c.some(e=>e.id===s.dm?.peer)?{peer:s.dm.peer,with:u}:c[0]&&d?{peer:c[0].id,with:d.with}:null}}function vm(e){switch(e.view){case`channel`:return`#${e.channel}`;case`activity`:return`Activity`;case`dm`:return`Direct messages`;case`topology`:return`Topology`;case`needs`:return`Needs you`;case`agents`:case`agent`:return`Agents`}}function ym(e){let[t,n]=(0,N.useState)(null);e.view!==`agent`&&(t===null||It(t)!==It(e))&&n(e);let r=e.view===`agent`?t:e;return r===null?{label:`Agents`,route:{view:`agents`,group:`status`}}:{label:vm(r),route:r}}var bm=5e3,xm=6e4,Sm={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)},Cm=e=>e.stale.some(e=>e.kind===`refused`&&e.name!==`roster`);function wm(e){let{store:t}=e,n=e.timer??Sm;t.set({loading:{roster:!0,channels:!0}});let r=tn(t,e.api),i=()=>{r.refresh().catch(e=>console.error(`dashboard refresh failed:`,e))},a=!1,o=e=>{a||t.set({connection:e?`session-invalid`:`closed`})},s={open(){t.set({connection:`connected`}),i()},error:()=>t.set(e=>e.connection===`closed`||e.connection===`session-invalid`?{}:{connection:e.connection===`connecting`?`connecting`:`reconnecting`}),closed(e){e?e.then(o):o(!1)},roster:r.onRoster,presenceView:r.onPresenceView,membership:r.onMembership,membershipFailed:r.onMembershipFailed,message(t){e.onArrival?.(),r.onMessage(t)},hello:r.onHello,agentFrame:r.onAgentFrame},{error:c,closed:l}=s;s.error=()=>{r.onFeedLost(),c()},s.closed=e=>{r.onFeedLost(),l(e)};let u=null,d=bm,f=t.subscribe(()=>{Cm(t.get())?u===null&&(u=n.set(()=>{u=null,d=Math.min(d*2,xm),i()},d)):(u!==null&&n.clear(u),u=null,d=bm)}),p=e.openFeed(s);return i(),{controller:r,stop(){a=!0,f(),u!==null&&n.clear(u),u=null,p()}}}function Tm(e){let t=e,n=new Set;return{get:()=>t,set(e){let r=typeof e==`function`?e(t):e;t={...t,...r};for(let e of n)e()},subscribe(e){return n.add(e),()=>n.delete(e)}}}var Em=Tm({space:null,connection:`connecting`,roster:[],presenceView:null,channels:[],unread:{},activity:[],dms:[],dmsCut:!1,open:null,stale:[],orderNotes:[],membership:{},loading:{roster:!1,channels:!1},post:null,channelDeleteSupported:!1,operatorId:null,drafts:{},sessions:{}}),Dm=1e4,Om=(e,t)=>{let n=wm({store:e,api:Xn(),openFeed:er,onArrival:t}),r=setInterval(()=>{let{connection:t,stale:r}=e.get();t===`connected`&&!r.some(e=>e.name===`channels`)&&n.controller.refreshChannels().catch(e=>console.error(`dashboard refresh failed:`,e))},5e3);return{controller:n.controller,stop:()=>{clearInterval(r),n.stop()}}};function km({host:e=window,start:t=Om,clock:n=Date.now}){let[r,i]=(0,N.useState)(null),[a]=(0,N.useState)(()=>fr(Dm,n()));(0,N.useLayoutEffect)(()=>{let e=t(Em,()=>a.hit(n()));return i(e.controller),e.stop},[t,a,n]);let[o,s]=(0,N.useState)(()=>Ct(e));(0,N.useEffect)(()=>en(e,s),[e]),(0,N.useEffect)(()=>un(e,o),[e,o]);let c=(0,N.useCallback)(t=>kt(e,t),[e]),l=me(),[u,d]=(0,N.useState)(!1);return(0,N.useLayoutEffect)(()=>{let e=window.matchMedia(`(width < 1200px)`),t=()=>d(e.matches);return e.addEventListener(`change`,t),t(),()=>e.removeEventListener(`change`,t)},[]),(0,P.jsx)(Ha,{defaultTheme:`system`,storageKey:`cotal.theme`,children:(0,P.jsx)(mn.Provider,{value:c,children:(0,P.jsx)(gm,{store:Em,controller:r,route:o,paneOpen:o.view===`channel`||o.view===`agent`,msgPerSecond:()=>a.perSecond(n()),phone:l,panelSheet:u})})})}var Am=document.getElementById(`root`);if(!Am)throw Error(`index.html has no #root element`);(0,Jn.createRoot)(Am).render((0,P.jsx)(N.StrictMode,{children:(0,P.jsx)(km,{})}));
|
|
13
|
+
`)}}var mr=e=>String(e).padStart(2,`0`),hr=e=>{let t=new Date(e);return`${mr(t.getHours())}:${mr(t.getMinutes())}`},gr=e=>`${hr(e)}:${mr(new Date(e).getSeconds())}`;function _r(e){let t=[],n=e.filter(e=>e.kind!==`partial`&&e.name!==`roster`);if(n.length){let e=n.map(e=>e.lastRead).filter(e=>typeof e==`number`&&Number.isFinite(e));t.push(e.length?`Showing what we last read at ${hr(Math.min(...e))}. Retrying.`:`Retrying.`)}let r=e.find(e=>e.kind!==`partial`&&e.name===`roster`);r?.since!==void 0&&Number.isFinite(r.since)&&t.push(`No presence updates since ${gr(r.since)}. Showing the last roster we heard.`);for(let n of e)n.kind===`partial`&&n.read!==void 0&&n.of!==void 0&&t.push(`${n.read} of ${n.of} sources answered`);return t}var vr={"direct messages":`Direct messages didn't load in time, so this page shows channel messages only.`,chat:`Channel messages didn't load in time, so this page shows direct messages only.`};function yr(e){let t=e.find(e=>e.kind===`partial`&&e.name===`activity`);if(!t)return;let n=t.missing??[];return{label:`partial: ${t.name}`,count:t.read!==void 0&&t.of!==void 0?`${t.read} of ${t.of} sources answered`:void 0,body:n.length===1&&Object.hasOwn(vr,n[0])?vr[n[0]]:void 0,title:t.reason}}function br(e){let t=e.filter(e=>e.type===`gap`),n=e.filter(e=>e.type===`boundary-hole`),r=e.filter(e=>e.type===`prefix-incomplete`),i=e.filter(e=>e.type===`backfill-failed`),a=[];if(t.length){let e=t.reduce((e,t)=>e+(t.missing||0),0);a.push(`${e} event frame${e===1?``:`s`} missing (${t.length} break${t.length===1?``:`s`} in the stream)`)}if(n.length&&a.push(`${n.length} possible ordering race${n.length===1?``:`s`} at start-up, unconfirmed`),r.length&&a.push(`${r.length} stream${r.length===1?``:`s`} joined after the start, earlier frames not retained`),i.length&&a.push(`history unavailable, so ordering is based on live frames only`),a.length)return{text:a.join(` · `),fault:t.length>0}}function xr(e){return e===null?`Cotal`:`Cotal · ${e}`}function Sr(e){return`${Math.round(e*10)/10} msg/s`}function Cr(e){return e.view===`channel`?e.channel:null}function wr(e,t){e?.open(t).catch(e=>console.error(`opening a channel failed:`,e))}var P=tt(),Tr=Object.defineProperty,Er=(e,t)=>Tr(e,`name`,{value:t,configurable:!0}),[Dr,Or]=pe(`AlertDialog`,[qt]),kr=qt(),Ar=Er(e=>{let{__scopeAlertDialog:t,...n}=e,r=kr(t);return(0,P.jsx)(Fn,{...r,...n,modal:!0})},`AlertDialog`),jr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(Te,{...i,...r,ref:t})},`AlertDialogTrigger`)),Mr=Er(e=>{let{__scopeAlertDialog:t,...n}=e,r=kr(t);return(0,P.jsx)(y,{...r,...n})},`AlertDialogPortal`),Nr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(Ve,{...i,...r,ref:t})},`AlertDialogOverlay`)),[Pr,Fr]=Dr(`AlertDialogContent`),Ir=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=kr(n),o=N.useRef(null),s=Me(t,o),c=N.useRef(null);return(0,P.jsx)(Pr,{scope:n,cancelRef:c,children:(0,P.jsx)(f,{role:`alertdialog`,...a,...i,ref:s,onOpenAutoFocus:Ze(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),Lr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(h,{...i,...r,ref:t})},`AlertDialogTitle`)),Rr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(jn,{...i,...r,ref:t})},`AlertDialogDescription`)),zr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=kr(n);return(0,P.jsx)(Le,{...i,...r,ref:t})},`AlertDialogAction`)),Br=`AlertDialogCancel`,Vr=N.forwardRef(Er(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=Fr(Br,n),a=kr(n),o=Me(t,i);return(0,P.jsx)(Le,{...a,...r,ref:o})},`AlertDialogCancel`)),Hr=Object.defineProperty,F=(e,t)=>Hr(e,`name`,{value:t,configurable:!0}),Ur=[`Enter`,` `],Wr=[`ArrowDown`,`PageUp`,`Home`],Gr=[`ArrowUp`,`PageDown`,`End`],Kr=[...Wr,...Gr];[...Ur],[...Ur];var qr=`Menu`,[Jr,Yr,Xr]=ne(qr),[Zr,Qr]=pe(qr,[Xr,mt,Mt]),$r=mt(),ei=Mt(),[ti,ni]=Zr(qr),[ri,ii]=Zr(qr),ai=F(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=$r(t),[c,l]=N.useState(null),d=N.useRef(!1),f=Hn(a),p=u(i);return N.useEffect(()=>{let e=F(()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=F(()=>d.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),N.useEffect(()=>{if(!n)return;let e=F(()=>f(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,f]),(0,P.jsx)(st,{...s,children:(0,P.jsx)(ti,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:l,children:(0,P.jsx)(ri,{scope:t,onClose:N.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:o,children:r})})})},`Menu`),oi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,...r}=e,i=$r(n);return(0,P.jsx)(On,{...i,...r,ref:t})},`MenuAnchor`)),si=`MenuPortal`,[ci,li]=Zr(si,{forceMount:void 0}),ui=F(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ni(si,t);return(0,P.jsx)(ci,{scope:t,forceMount:n,children:(0,P.jsx)(ie,{present:n||a.open,children:(0,P.jsx)(D,{asChild:!0,container:i,children:r})})})},`MenuPortal`),di=`MenuContent`,[fi,pi]=Zr(di),mi=N.forwardRef(F(function(e,t){let n=li(di,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ni(di,e.__scopeMenu),o=ii(di,e.__scopeMenu);return(0,P.jsx)(Jr.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(ie,{present:r||a.open,children:(0,P.jsx)(Jr.Slot,{scope:e.__scopeMenu,children:o.modal?(0,P.jsx)(hi,{...i,ref:t}):(0,P.jsx)(gi,{...i,ref:t})})})})},`MenuContent`)),hi=N.forwardRef(F(function(e,t){let n=ni(di,e.__scopeMenu),r=N.useRef(null),i=Me(t,r);return N.useEffect(()=>{let e=r.current;if(e)return o(e)},[]),(0,P.jsx)(vi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ze(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),gi=N.forwardRef(F(function(e,t){let n=ni(di,e.__scopeMenu);return(0,P.jsx)(vi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),_i=it(`MenuContent.ScrollLock`),vi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=ni(di,n),_=ii(di,n),v=$r(n),y=ei(n),b=Yr(n),[x,S]=N.useState(null),C=N.useRef(null),[w,te]=N.useState(null);oe(w);let{nodes:ne,registry:T}=ge(),re=!!(i||m),ie=Me(t,C,g.onContentChange,te),E=N.useRef(0),ae=N.useRef(``),se=N.useRef(0),ce=N.useRef(null),le=N.useRef(`right`),ue=N.useRef(0),de=N.useMemo(()=>m?[C,...ne.map(e=>({current:e}))]:[],[C,ne,m]),fe=m?Ut:N.Fragment,pe=m?{as:_i,allowPinchZoom:!0,shards:de}:void 0,me=F(e=>{let t=ae.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Vi(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;function s(e){ae.current=e,window.clearTimeout(E.current),e!==``&&(E.current=window.setTimeout(()=>s(``),1e3))}F(s,`updateSearch`),s(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);N.useEffect(()=>()=>window.clearTimeout(E.current),[]),ye();let he=N.useCallback(e=>le.current===ce.current?.side&&Ui(e,ce.current?.area),[]);return(0,P.jsx)(fi,{scope:n,searchRef:ae,onItemEnter:N.useCallback(e=>{he(e)&&e.preventDefault()},[he]),onItemLeave:N.useCallback(e=>{he(e)||(C.current?.focus(),S(null))},[he]),onTriggerLeave:N.useCallback(e=>{he(e)&&e.preventDefault()},[he]),pointerGraceTimerRef:se,onPointerGraceIntentChange:N.useCallback(e=>{ce.current=e},[]),children:(0,P.jsx)(ee,{registry:re?T:null,children:(0,P.jsx)(fe,{...pe,children:(0,P.jsx)(Oe,{asChild:!0,trapped:i,branches:ne,onMountAutoFocus:Ze(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,P.jsx)(Pe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,P.jsx)($t,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:Ze(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,P.jsx)(Rn,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ii(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:ie,style:{outline:`none`,...h.style},onKeyDown:Ze(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&me(e.key));let i=C.current;if(e.target!==i||!Kr.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Gr.includes(e.key)&&a.reverse(),zi(a)}),onBlur:Ze(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),ae.current=``)}),onPointerMove:Ze(e.onPointerMove,Wi(e=>{let t=e.target,n=ue.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>ue.current?`right`:`left`;le.current=t,ue.current=e.clientX}}))})})})})})})})},`MenuContentImpl`)),yi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(fn.div,{role:`group`,...r,ref:t})},`MenuGroup`)),bi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(fn.div,{...r,ref:t})},`MenuLabel`)),xi=`MenuItem`,Si=`menu.itemSelect`,Ci=N.forwardRef(F(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=N.useRef(null),o=ii(xi,e.__scopeMenu),s=pi(xi,e.__scopeMenu),c=Me(t,a),l=N.useRef(!1),u=F(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Si,{bubbles:!0,cancelable:!0});e.addEventListener(Si,e=>r?.(e),{once:!0}),ue(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,P.jsx)(wi,{...i,ref:c,disabled:n,onClick:Ze(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Ze(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Ze(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&Ur.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),wi=N.forwardRef(F(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=pi(xi,n),s=ei(n),c=N.useRef(null),l=Me(t,c),[u,d]=N.useState(!1),[f,p]=N.useState(``);return N.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,P.jsx)(Jr.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,P.jsx)(Ft,{asChild:!0,...s,focusable:!r,children:(0,P.jsx)(fn.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Ze(e.onPointerMove,Wi(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ze(e.onPointerLeave,Wi(e=>o.onItemLeave(e))),onFocus:Ze(e.onFocus,()=>d(!0)),onBlur:Ze(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Ti,Ei]=Zr(`MenuRadioGroup`,{value:void 0,onValueChange:F(()=>{},`onValueChange`)}),Di=N.forwardRef(F(function(e,t){let{value:n,onValueChange:r,...i}=e,a=Hn(r);return(0,P.jsx)(Ti,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,P.jsx)(yi,{...i,ref:t})})},`MenuRadioGroup`)),Oi=`MenuRadioItem`,ki=N.forwardRef(F(function(e,t){let{value:n,...r}=e,i=Ei(Oi,e.__scopeMenu),a=n===i.value;return(0,P.jsx)(ji,{scope:e.__scopeMenu,checked:a,children:(0,P.jsx)(Ci,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ri(a),onSelect:Ze(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),Ai=`MenuItemIndicator`,[ji,Mi]=Zr(Ai,{checked:!1}),Ni=N.forwardRef(F(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=Mi(Ai,n);return(0,P.jsx)(ie,{present:r||Li(a.checked)||a.checked===!0,children:(0,P.jsx)(fn.span,{...i,ref:t,"data-state":Ri(a.checked)})})},`MenuItemIndicator`)),[Pi,Fi]=Zr(`MenuSub`);function Ii(e){return e?`open`:`closed`}F(Ii,`getOpenState`);function Li(e){return e===`indeterminate`}F(Li,`isIndeterminate`);function Ri(e){return Li(e)?`indeterminate`:e?`checked`:`unchecked`}F(Ri,`getCheckedState`);function zi(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}F(zi,`focusFirst`);function Bi(e,t){return e.map((n,r)=>e[(t+r)%e.length])}F(Bi,`wrapArray`);function Vi(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Bi(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}F(Vi,`getNextMatch`);function Hi(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}F(Hi,`isPointInPolygon`);function Ui(e,t){return t?Hi({x:e.clientX,y:e.clientY},t):!1}F(Ui,`isPointerInGraceArea`);function Wi(e){return t=>t.pointerType===`mouse`?e(t):void 0}F(Wi,`whenMouse`);var Gi=Object.defineProperty,Ki=(e,t)=>Gi(e,`name`,{value:t,configurable:!0}),qi=`DropdownMenu`,[Ji,Yi]=pe(qi,[Qr]),Xi=Qr(),[Zi,Qi]=Ji(qi),$i=Ki(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Xi(t),l=N.useRef(null),[u,d]=Ge({prop:i,defaultProp:a??!1,onChange:o,caller:qi});return(0,P.jsx)(Zi,{scope:t,triggerId:Je(),triggerRef:l,contentId:Je(),open:u,onOpenChange:d,onOpenToggle:N.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,P.jsx)(ai,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),ea=`DropdownMenuTrigger`,ta=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Qi(ea,n),o=Xi(n),s=Me(t,a.triggerRef);return(0,P.jsx)(oi,{asChild:!0,...o,children:(0,P.jsx)(fn.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:Ze(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Ze(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),na=Ki(e=>{let{__scopeDropdownMenu:t,...n}=e,r=Xi(t);return(0,P.jsx)(ui,{...r,...n})},`DropdownMenuPortal`),ra=`DropdownMenuContent`,ia=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Qi(ra,n),a=Xi(n),o=N.useRef(!1);return(0,P.jsx)(mi,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Ze(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Ze(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),aa=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(yi,{...i,...r,ref:t})},`DropdownMenuGroup`)),oa=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(bi,{...i,...r,ref:t})},`DropdownMenuLabel`)),sa=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(Di,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),I=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(ki,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),L=N.forwardRef(Ki(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Xi(n);return(0,P.jsx)(Ni,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),ca=Object.defineProperty,la=(e,t)=>ca(e,`name`,{value:t,configurable:!0}),ua=`ToggleGroup`,da={Single:`single`,Multiple:`multiple`},[fa,pa]=pe(ua,[Mt]),ma=Mt(),ha=N.forwardRef(la(function(e,t){let{type:n,...r}=e;if(n===da.Single)return(0,P.jsx)(va,{role:`radiogroup`,...r,ref:t});if(n===da.Multiple)return(0,P.jsx)(ya,{role:`toolbar`,...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${ua}\``)},`ToggleGroup`)),[ga,_a]=fa(ua),va=N.forwardRef(la(function(e,t){let{value:n,defaultValue:r,onValueChange:i=la(()=>{},`onValueChange`),...a}=e,[o,s]=Ge({prop:n,defaultProp:r??``,onChange:i,caller:ua});return(0,P.jsx)(ga,{scope:e.__scopeToggleGroup,type:da.Single,value:N.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:N.useCallback(()=>s(``),[s]),children:(0,P.jsx)(Sa,{...a,ref:t})})},`ToggleGroupImplSingle`)),ya=N.forwardRef(la(function(e,t){let{value:n,defaultValue:r,onValueChange:i=la(()=>{},`onValueChange`),...a}=e,[o,s]=Ge({prop:n,defaultProp:r??[],onChange:i,caller:ua}),c=N.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=N.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,P.jsx)(ga,{scope:e.__scopeToggleGroup,type:da.Multiple,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,P.jsx)(Sa,{...a,ref:t})})},`ToggleGroupImplMultiple`)),[ba,xa]=fa(ua),Sa=N.forwardRef(la(function(e,t){let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=ma(n),d=u(o),f={dir:d,...c};return(0,P.jsx)(ba,{scope:n,rovingFocus:i,disabled:r,children:i?(0,P.jsx)($t,{asChild:!0,...l,orientation:a,dir:d,loop:s,children:(0,P.jsx)(fn.div,{...f,ref:t})}):(0,P.jsx)(fn.div,{...f,ref:t})})},`ToggleGroupImpl`)),Ca=`ToggleGroupItem`,wa=N.forwardRef(la(function(e,t){let n=_a(Ca,e.__scopeToggleGroup),r=xa(Ca,e.__scopeToggleGroup),i=ma(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=N.useRef(null);return r.rovingFocus?(0,P.jsx)(Ft,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,P.jsx)(Ta,{...s,ref:t})}):(0,P.jsx)(Ta,{...s,ref:t})},`ToggleGroupItem`)),Ta=N.forwardRef(la(function(e,t){let{__scopeToggleGroup:n,value:r,...i}=e,a=_a(Ca,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0},s=a.type===da.Single?o:void 0;return(0,P.jsx)(ln,{...s,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})},`ToggleGroupItemImpl`)),Ea=[[`path`,{d:`M13.9248 21H10.0752C5.44476 21 3.12955 21 2.27636 19.4939C1.42317 17.9879 2.60736 15.9914 4.97574 11.9985L6.90057 8.75333C9.17559 4.91778 10.3131 3 12 3C13.6869 3 14.8244 4.91777 17.0994 8.75332L19.0243 11.9985C21.3926 15.9914 22.5768 17.9879 21.7236 19.4939C20.8704 21 18.5552 21 13.9248 21Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M12 9V13`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M12.125 16.75H12M12.25 16.75C12.25 16.8881 12.1381 17 12 17C11.8619 17 11.75 16.8881 11.75 16.75C11.75 16.6119 11.8619 16.5 12 16.5C12.1381 16.5 12.25 16.6119 12.25 16.75Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],Da=[[`path`,{d:`M18.8516 16.3743L19.5 6H4.5L5.14839 16.3743C5.315 19.0401 5.39831 20.373 6.26426 21.1865C7.13021 22 8.46571 22 11.1367 22H12.8633C15.5343 22 16.8698 22 17.7357 21.1865C18.6017 20.373 18.685 19.0401 18.8516 16.3743Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M16 6H21M16 6L15.3778 4.34082C15.0007 3.33524 14.8122 2.83245 14.4402 2.50292C14.3213 2.39765 14.1904 2.3069 14.0501 2.2326C13.6109 2 13.074 2 12 2C10.926 2 10.3891 2 9.9499 2.2326C9.8096 2.3069 9.67865 2.39765 9.55982 2.50292C9.18783 2.83245 8.99928 3.33524 8.62219 4.34082L8 6M16 6H8M3 6H8`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M9.5 11V17M14.5 11V17`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}]],Oa=[[`path`,{d:`M15.5 2V6M8.5 6V2`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M6.00446 7.61331C5.93719 6.74273 6.63957 6 7.53014 6H16.4699C17.3604 6 18.0628 6.74273 17.9955 7.61331L17.8117 9.99197C17.6796 11.7019 17.1011 13.3498 16.132 14.7773L15.5312 15.6622C14.9638 16.4979 14.0077 17 12.9838 17H11.0162C9.99228 17 9.03617 16.4979 8.46881 15.6622L7.86803 14.7773C6.89885 13.3498 6.32041 11.7019 6.18827 9.99197L6.00446 7.61331Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M12 17V22`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M11 9H13`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`3`}]],ka=[[`path`,{d:`M19 4H5C4.06812 4 3.60218 4 3.23463 4.15224C2.74458 4.35523 2.35523 4.74458 2.15224 5.23463C2 5.60218 2 6.06812 2 7C2 7.93188 2 8.39782 2.15224 8.76537C2.35523 9.25542 2.74458 9.64477 3.23463 9.84776C3.60218 10 4.06812 10 5 10H19C19.9319 10 20.3978 10 20.7654 9.84776C21.2554 9.64477 21.6448 9.25542 21.8478 8.76537C22 8.39782 22 7.93188 22 7C22 6.06812 22 5.60218 21.8478 5.23463C21.6448 4.74458 21.2554 4.35523 20.7654 4.15224C20.3978 4 19.9319 4 19 4Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`0`}],[`path`,{d:`M19 14H5C4.06812 14 3.60218 14 3.23463 14.1522C2.74458 14.3552 2.35523 14.7446 2.15224 15.2346C2 15.6022 2 16.0681 2 17C2 17.9319 2 18.3978 2.15224 18.7654C2.35523 19.2554 2.74458 19.6448 3.23463 19.8478C3.60218 20 4.06812 20 5 20H19C19.9319 20 20.3978 20 20.7654 19.8478C21.2554 19.6448 21.6448 19.2554 21.8478 18.7654C22 18.3978 22 17.9319 22 17C22 16.0681 22 15.6022 21.8478 15.2346C21.6448 14.7446 21.2554 14.3552 20.7654 14.1522C20.3978 14 19.9319 14 19 14Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`1`}],[`path`,{d:`M6.125 7H6M6.25 7C6.25 7.13807 6.13807 7.25 6 7.25C5.86193 7.25 5.75 7.13807 5.75 7C5.75 6.86193 5.86193 6.75 6 6.75C6.13807 6.75 6.25 6.86193 6.25 7Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`2`}],[`path`,{d:`M10.125 7H10M10.25 7C10.25 7.13807 10.1381 7.25 10 7.25C9.86193 7.25 9.75 7.13807 9.75 7C9.75 6.86193 9.86193 6.75 10 6.75C10.1381 6.75 10.25 6.86193 10.25 7Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`3`}],[`path`,{d:`M6.125 17H6M6.25 17C6.25 17.1381 6.13807 17.25 6 17.25C5.86193 17.25 5.75 17.1381 5.75 17C5.75 16.8619 5.86193 16.75 6 16.75C6.13807 16.75 6.25 16.8619 6.25 17Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`4`}],[`path`,{d:`M10.125 17H10M10.25 17C10.25 17.1381 10.1381 17.25 10 17.25C9.86193 17.25 9.75 17.1381 9.75 17C9.75 16.8619 9.86193 16.75 10 16.75C10.1381 16.75 10.25 16.8619 10.25 17Z`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,key:`5`}]],Aa=[[`path`,{d:`M3.95631 10.5829L3.03254 9.07084C2.74505 8.60024 2.7389 8.00978 3.01652 7.5333L3.63533 6.47124C3.90953 6.00064 4.41721 5.71571 4.96162 5.7269L6.69131 5.76245C6.92616 5.76728 7.15379 5.68727 7.34333 5.54846C7.79531 5.21745 8.28334 4.93276 8.80042 4.70139C9.01191 4.60675 9.19222 4.45165 9.30469 4.24903L10.1203 2.77965C10.3847 2.30328 10.8865 2.00781 11.4312 2.00781H12.6937C13.2384 2.00781 13.7403 2.30329 14.0047 2.77966L14.8202 4.24902C14.9327 4.45165 15.113 4.60675 15.3245 4.70139C15.8416 4.93274 16.3296 5.2174 16.7815 5.54838C16.9711 5.68718 17.1987 5.76718 17.4336 5.76235L19.1634 5.72676C19.7078 5.71557 20.2155 6.00049 20.4897 6.47111L21.1085 7.53314C21.3862 8.00963 21.38 8.60009 21.0925 9.07068L20.1687 10.5828C20.0481 10.7803 20.002 11.0134 20.0235 11.2439C20.0707 11.7486 20.0707 12.267 20.0235 12.7717C20.002 13.0022 20.0481 13.2353 20.1687 13.4329L21.0924 14.9448C21.3799 15.4154 21.3861 16.0058 21.1084 16.4823L20.4896 17.5444C20.2154 18.015 19.7077 18.2999 19.1633 18.2887L17.4338 18.2531C17.1989 18.2483 16.9713 18.3283 16.7817 18.4671C16.3297 18.7982 15.8416 19.0829 15.3245 19.3142C15.113 19.4089 14.9327 19.564 14.8202 19.7666L14.0047 21.236C13.7403 21.7123 13.2384 22.0078 12.6937 22.0078H11.4312C10.8866 22.0078 10.3847 21.7123 10.1203 21.236L9.30468 19.7665C9.19222 19.5639 9.01191 19.4088 8.80042 19.3142C8.28329 19.0828 7.79519 18.798 7.34316 18.467C7.15362 18.3282 6.92597 18.2482 6.69111 18.253L4.96175 18.2886C4.41733 18.2998 3.90963 18.0148 3.63543 17.5442L3.01663 16.4822C2.739 16.0057 2.74515 15.4152 3.03264 14.9446L3.95631 13.4327C4.07699 13.2351 4.12309 13.002 4.10154 12.7715C4.05437 12.267 4.05438 11.7486 4.10154 11.244C4.12308 11.0135 4.07699 10.7805 3.95631 10.5829Z`,stroke:`currentColor`,strokeWidth:`1.5`,key:`0`}],[`circle`,{cx:`12.0625`,cy:`12.0078`,r:`3.5`,stroke:`currentColor`,strokeWidth:`1.5`,key:`1`}]];function ja({...e}){return(0,P.jsx)($i,{"data-slot":`dropdown-menu`,...e})}function Ma({...e}){return(0,P.jsx)(ta,{"data-slot":`dropdown-menu-trigger`,...e})}function Na({className:e,align:t=`start`,sideOffset:n=4,...i}){return(0,P.jsx)(na,{children:(0,P.jsx)(ia,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:r(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i})})}function Pa({...e}){return(0,P.jsx)(aa,{"data-slot":`dropdown-menu-group`,...e})}function Fa({...e}){return(0,P.jsx)(sa,{"data-slot":`dropdown-menu-radio-group`,...e})}function Ia({className:e,children:t,inset:n,...i}){return(0,P.jsxs)(I,{"data-slot":`dropdown-menu-radio-item`,"data-inset":n,className:r(`relative flex min-h-7 cursor-default items-center gap-2 rounded-xl py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...i,children:[(0,P.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,P.jsx)(L,{children:(0,P.jsx)(wn,{icon:at,strokeWidth:2})})}),t]})}function La({className:e,inset:t,...n}){return(0,P.jsx)(oa,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:r(`px-2 py-1 text-xs text-muted-foreground data-inset:pl-7`,e),...n})}var Ra={activity:(0,P.jsx)(`path`,{d:`M22 12h-4l-3 8L9 4l-3 8H2`}),hash:(0,P.jsx)(`path`,{d:`M4 9h16M4 15h16M10 3 8 21M16 3l-2 18`}),dm:(0,P.jsx)(`path`,{d:`M20 11.5a8 8 0 0 1-11.7 7.1L4 20l1.4-4.1A8 8 0 1 1 20 11.5z`}),agents:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.5`}),(0,P.jsx)(`path`,{d:`M2.5 20a6.5 6.5 0 0 1 13 0`}),(0,P.jsx)(`path`,{d:`M16 4.5a3.5 3.5 0 0 1 0 7M18 14a6 6 0 0 1 3.5 6`})]}),graph:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2.5`}),(0,P.jsx)(`circle`,{cx:`18`,cy:`8`,r:`2.5`}),(0,P.jsx)(`circle`,{cx:`10`,cy:`18`,r:`2.5`}),(0,P.jsx)(`path`,{d:`M8.4 6.4 15.5 7.6M6.9 8.4l2.3 7.2M16.6 10.1l-4.9 6`})]}),inbox:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`path`,{d:`M3 13h5l1.5 3h5L16 13h5`}),(0,P.jsx)(`path`,{d:`M5 5h14l2 8v6H3v-6z`})]}),search:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,P.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),chev:(0,P.jsx)(`path`,{d:`m7 10 5 5 5-5`}),gear:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,P.jsx)(`path`,{d:`M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M5.3 18.7l2.1-2.1M16.6 7.4l2.1-2.1`})]}),server:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`1.5`}),(0,P.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`1.5`}),(0,P.jsx)(`path`,{d:`M7 7.5h.01M7 16.5h.01`})]})};function za({name:e,size:t=18}){return(0,P.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:Ra[e]})}var Ba=[`system`,`light`,`dark`],Va=(0,N.createContext)({theme:`system`,setTheme:()=>null});function Ha({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`,...r}){let[i,a]=(0,N.useState)(()=>{try{return Ba.find(e=>e===localStorage.getItem(n))??t}catch{return t}});(0,N.useEffect)(()=>{let e=window.document.documentElement,t=()=>{if(e.classList.remove(`light`,`dark`),i===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t)}else e.classList.add(i)};if(t(),i!==`system`)return;let n=window.matchMedia(`(prefers-color-scheme: dark)`);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},[i]);let o={theme:i,setTheme:e=>{try{localStorage.setItem(n,e)}catch{}a(e)}};return(0,P.jsx)(Va.Provider,{...r,value:o,children:e})}var Ua=()=>{let e=(0,N.useContext)(Va);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},Wa=[{label:`Activity`,icon:`activity`,view:`activity`},{label:`Channels`,icon:`hash`,view:`channel`},{label:`Direct messages`,icon:`dm`,view:`dm`},{label:`Agents`,icon:`agents`,view:`agents`},{label:`Topology`,icon:`graph`,view:`topology`}],Ga={channel:`No channels yet. One appears with its first message.`,dm:`No direct messages yet.`};function Ka(e,t,n){if(t.view===e)return t;switch(e){case`channel`:return n.channel===null?null:{view:e,channel:n.channel};case`dm`:return n.dm===null?null:{view:e,...n.dm};case`agents`:return{view:e,group:`status`};case`activity`:case`topology`:case`needs`:return{view:e};case`agent`:return null}}var qa=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function Ja({side:e=`right`}){let t=(0,N.useId)(),{theme:n,setTheme:r}=Ua();return(0,P.jsxs)(ja,{children:[(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(Ma,{asChild:!0,children:(0,P.jsxs)(ce,{children:[(0,P.jsx)(za,{name:`gear`}),(0,P.jsx)(`span`,{children:`Settings`})]})})}),(0,P.jsx)(E,{side:`right`,children:`Settings`})]}),(0,P.jsx)(Na,{side:e,align:`end`,loop:!0,children:(0,P.jsxs)(Pa,{"aria-labelledby":t,children:[(0,P.jsx)(La,{id:t,children:`Theme`}),(0,P.jsx)(Fa,{value:n,onValueChange:e=>{let t=qa.find(t=>t.value===e);t&&r(t.value)},children:qa.map(e=>(0,P.jsx)(Ia,{value:e.value,children:e.label},e.value))})]})})]})}function Ya({route:e,places:t}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(xe,{children:(0,P.jsx)(`span`,{className:`ui-rail-mark self-center`,dangerouslySetInnerHTML:{__html:p(`currentColor`)}})}),(0,P.jsx)(_,{children:(0,P.jsx)(Yt,{children:(0,P.jsx)(c,{children:(0,P.jsx)(Ae,{children:Wa.map(({label:n,icon:r,view:i})=>{let a=Ka(i,e,t),o=e.view===i||i===`agents`&&e.view===`agent`,s=Ga[i];return(0,P.jsx)(_e,{children:a?(0,P.jsx)(ce,{asChild:!0,isActive:o,tooltip:{children:n,hidden:!1},children:(0,P.jsxs)(`a`,{href:It(a),"aria-current":o?`page`:void 0,children:[(0,P.jsx)(za,{name:r}),(0,P.jsx)(`span`,{children:n})]})}):(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(`span`,{className:`flex`,children:(0,P.jsxs)(ce,{type:`button`,"aria-disabled":!0,"aria-label":n,"aria-describedby":`rail-why-${i}`,children:[(0,P.jsx)(za,{name:r}),(0,P.jsx)(`span`,{children:n}),(0,P.jsx)(`span`,{id:`rail-why-${i}`,className:`ui-sr`,children:s})]})})}),(0,P.jsx)(E,{side:`right`,children:s})]})},i)})})})})}),(0,P.jsx)(De,{children:(0,P.jsx)(Ae,{children:(0,P.jsx)(_e,{children:(0,P.jsx)(Ja,{})})})})]})}var Xa=[{label:`Channels`,icon:`hash`,view:`channel`},{label:`DMs`,icon:`dm`,view:`dm`},{label:`Agents`,icon:`agents`,view:`agents`},{label:`Activity`,icon:`activity`,view:`activity`}];function Za({route:e,places:t,waiting:n,working:r}){return(0,P.jsx)(`nav`,{className:`v3-tabbar`,"aria-label":`Sections`,children:Xa.map(({label:i,icon:a,view:o})=>{let s=Ka(o,e,t),c=e.view===o||o===`agents`&&e.view===`needs`||o===`agents`&&e.view===`agent`,l=s?`a`:`button`,u=s?void 0:Ga[o],d=(0,P.jsxs)(l,{href:s?It(s):void 0,type:s?void 0:`button`,"aria-disabled":!s||void 0,"aria-current":c?`page`:void 0,"aria-label":u?i:void 0,"aria-describedby":u?`tab-why-${o}`:void 0,children:[(0,P.jsx)(za,{name:a,size:22}),i,u&&(0,P.jsx)(`span`,{id:`tab-why-${o}`,className:`ui-sr`,children:u}),o===`agents`&&n>0&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(gt,{children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:n}),(0,P.jsx)(`span`,{className:`ui-sr`,children:`${n} agent${n===1?``:`s`} waiting`})]})}),(0,P.jsx)(E,{children:`${n} agent${n===1?``:`s`} waiting`})]}),o===`agents`&&n===0&&r>0&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(`span`,{className:`ox-sbw ox-tabw`,children:[(0,P.jsx)(M,{icon:bn,size:16,className:`ui-ic ox-spin`}),(0,P.jsx)(`span`,{"aria-hidden":`true`,children:r}),(0,P.jsx)(`span`,{className:`ui-sr`,children:`${r} agent${r===1?``:`s`} working`})]})}),(0,P.jsx)(E,{children:`${r} agent${r===1?``:`s`} working`})]})]},o);return u?(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:d}),(0,P.jsx)(E,{side:`top`,children:u})]},o):d})})}var Qa={"--sidebar-width":`350px`};function $a(e){let{route:t,controller:n,paneOpen:i,phone:a}=e,o=Cr(t);(0,N.useEffect)(()=>{wr(n,o)},[n,o]);let s=ze(),c=e.stale?`stale`:void 0;return(0,P.jsxs)(Un,{className:r(`h-dvh`,a&&`ui-phone flex-col`),style:Qa,"data-view":t.view,"data-presence":c,children:[(0,P.jsxs)(x,{collapsible:`icon`,className:`overflow-hidden *:data-[sidebar=sidebar]:flex-row`,children:[(0,P.jsx)(x,{collapsible:`none`,role:`navigation`,"aria-label":`Views`,className:`hidden w-[calc(var(--sidebar-width-icon)+1px)]! border-r md:flex`,children:(0,P.jsx)(Ya,{route:t,places:e.places})}),(0,P.jsx)(x,{collapsible:`none`,role:`complementary`,"aria-label":`Space`,"data-presence":c,className:`min-w-0 flex-1 group-data-[collapsible=icon]:hidden`,children:e.sidebar})]}),(0,P.jsx)(Ce,{className:`min-h-0 min-w-0`,children:e.children}),a&&(0,P.jsx)(Za,{route:t,places:e.places,waiting:e.waiting,working:e.working}),e.panelSheet?(0,P.jsx)(pn,{open:i,onOpenChange:t=>!t&&e.onPanelClose(),children:(0,P.jsxs)(de,{side:`right`,showCloseButton:!1,"aria-describedby":void 0,"data-presence":c,...s,children:[(0,P.jsx)(nt,{className:`sr-only`,children:`Details`}),e.panel]})}):i&&(0,P.jsx)(`section`,{className:`ui-pane`,"aria-label":`Details`,children:e.panel})]})}var eo=Ot(`group/item flex w-full flex-wrap items-center rounded-2xl border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-3.5 px-4 py-3.5`,sm:`gap-3.5 px-3.5 py-3`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function to({className:e,variant:t=`default`,size:n=`default`,asChild:i=!1,...a}){let o=i?et:`div`;return(0,P.jsx)(o,{"data-slot":`item`,"data-variant":t,"data-size":n,className:r(eo({variant:t,size:n,className:e})),...a})}var no=Ot(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-xl group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 group-data-[size=xs]/item:rounded-lg [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function ro({className:e,variant:t=`default`,...n}){return(0,P.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:r(no({variant:t,className:e})),...n})}function io({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`item-content`,className:r(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0.5 [&+[data-slot=item-content]]:flex-none`,e),...t})}function ao({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`item-title`,className:r(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function oo({className:e,...t}){return(0,P.jsx)(`p`,{"data-slot":`item-description`,className:r(`line-clamp-2 text-left text-sm font-normal text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function so({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`item-actions`,className:r(`flex items-center gap-2`,e),...t})}var co=[{rows:2},{heading:`Channels`,rows:3},{heading:`Direct messages`,rows:1}];function lo({lines:e}){return(0,P.jsxs)(`div`,{className:`ui-skel-msg`,children:[(0,P.jsx)(T,{className:`size-8.5`}),(0,P.jsx)(`div`,{style:{display:`grid`,gap:8,paddingTop:4},children:e.map((e,t)=>(0,P.jsx)(T,{className:`h-2.5`,style:{width:e}},t))})]})}function uo(){return(0,P.jsx)(_,{role:`navigation`,"aria-label":`Places`,"aria-busy":`true`,children:co.map(({heading:e,rows:t})=>(0,P.jsxs)(Yt,{"aria-hidden":`true`,children:[e&&(0,P.jsx)(Gt,{children:e}),(0,P.jsx)(Ae,{children:Array.from({length:t},(e,t)=>(0,P.jsx)(_e,{children:(0,P.jsx)(Fe,{showIcon:!0})},t))})]},e??``))})}function fo(){return(0,P.jsxs)(`div`,{"aria-hidden":`true`,style:{display:`contents`},children:[(0,P.jsx)(`header`,{className:`ui-bar`,children:(0,P.jsx)(T,{className:`h-3 w-30`})}),(0,P.jsxs)(`div`,{className:`ui-col`,style:{width:`100%`},children:[(0,P.jsx)(lo,{lines:[`30%`,`85%`]}),(0,P.jsx)(lo,{lines:[`24%`,`70%`,`52%`]})]})]})}function po({store:e,inHeader:t=!1}){let n=A(e,e=>e.stale),r=pr(n);if(r.hidden)return null;let i=t?[]:_r(n);return(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(m,{role:`note`,id:t?void 0:`stale`,className:t?`w-auto`:`mx-2 my-1 w-auto`,children:[(0,P.jsx)(M,{icon:Ea}),(0,P.jsx)(Kt,{children:r.text}),i.length>0&&(0,P.jsx)(we,{children:i.map(e=>(0,P.jsx)(`div`,{children:e},e))}),r.title&&(0,P.jsx)(`div`,{className:`ui-sr`,children:r.title})]})}),r.title&&(0,P.jsx)(E,{className:`flex-col items-start`,children:r.title.split(`
|
|
14
|
+
`).map(e=>(0,P.jsx)(`span`,{children:e},e))})]})}var mo=1e3,ho=e=>e.startsWith(`run.`),go={connecting:{text:`Connecting`,title:`Connecting to cotal web`},reconnecting:{text:`Reconnecting`,title:`Reconnecting to cotal web`},closed:{text:`Disconnected`,title:`The live feed closed and will not retry. Reload the page, or open the link cotal web printed when it started.`},"session-invalid":{text:`Disconnected`,title:"Your session is no longer valid. Open a new private dashboard link. For a background service, find the private session file in the service logs, for example with `cotal service logs web --space main`."}},_o=e=>`${e.length} member${e.length===1?``:`s`} working: ${e.map(e=>e.name).join(`, `)}`;function vo({to:e,here:t,tip:n,badge:r,link:i,children:a}){let{isMobile:o}=d();return(0,P.jsxs)(_e,{children:[(0,P.jsx)(ce,{asChild:!0,isActive:t,className:r===void 0?void 0:`pr-8`,tooltip:n===void 0||o?void 0:{children:n,hidden:!1},children:(0,P.jsx)(`a`,{ref:i,href:It(e),"aria-current":t?`page`:void 0,children:a})}),r!==void 0&&(0,P.jsx)(w,{"aria-hidden":`true`,children:r})]})}function yo({connection:e}){let{text:t,title:n}=e===`connected`?{text:`Connected`,title:`Connected to cotal web`}:go[e];return(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(gt,{variant:e===`closed`||e===`session-invalid`?`destructive`:`outline`,children:[(0,P.jsx)(`i`,{className:e===`connected`?`ui-mdot ui-mdot-live`:`ui-mdot ui-mdot-down`}),t,(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${n}`})]})}),(0,P.jsx)(E,{children:n})]})}function bo({store:e,route:t,msgPerSecond:n}){let r=A(e,e=>e.space),i=A(e,e=>e.channels),a=A(e,e=>e.unread),o=A(e,e=>e.roster),c=A(e,e=>e.dms),l=A(e,e=>e.membership),u=A(e,e=>e.connection),f=A(e,e=>e.loading),p=A(e,e=>e.post),m=A(e,e=>e.operatorId),[,h]=(0,N.useState)(0);(0,N.useEffect)(()=>{let e=setInterval(()=>h(e=>e+1),mo);return()=>clearInterval(e)},[]);let{isMobile:g,setOpenMobile:v}=d(),y=(0,N.useRef)(null);(0,N.useLayoutEffect)(()=>{g&&y.current?.focus()},[g]);let b=It(t),x=(0,N.useRef)(b);(0,N.useEffect)(()=>{x.current!==b&&(x.current=b,v(!1))},[b,v]);let S=(0,N.useMemo)(()=>hn(o,{includeOffline:!0}),[o]),ee=(0,N.useMemo)(()=>Tn(o),[o]),C=(0,N.useMemo)(()=>new Map(S.map(e=>[e.id,e])),[S]),w=ae(),ne=(0,N.useMemo)(()=>{let e=i.map(e=>e.channel);return new Map(i.map(t=>[t.channel,$e(t.channel,l,e,[]).map(e=>C.get(e.id)).filter(e=>e?.status===`working`)]))},[i,l,C]),T=dt(S).length,re=`${T} agent${T===1?``:`s`} waiting`,ie=Sr(n()),oe=s(p,m!==null&&o.some(e=>e.card.id===m)),se=(0,N.useMemo)(()=>on(c),[c]),[le,ue]=(0,N.useState)(!1),de=t.view===`dm`&&t.with!==void 0?yt(t.peer,t.with):null,pe=(0,N.useMemo)(()=>le?se:se.filter((e,t)=>t<10||e.key===de),[se,le,de]);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(xe,{children:(0,P.jsx)(`span`,{className:`ui-space px-2 py-1.5`,children:r})}),(0,P.jsx)(po,{store:e}),f.roster||f.channels?(0,P.jsx)(uo,{}):(0,P.jsxs)(_,{role:`navigation`,"aria-label":`Places`,children:[(0,P.jsx)(Yt,{children:(0,P.jsxs)(Ae,{children:[(0,P.jsxs)(vo,{to:{view:`needs`},here:t.view===`needs`,tip:T>0?re:void 0,badge:T>0?T:void 0,link:y,children:[(0,P.jsx)(za,{name:`inbox`}),(0,P.jsx)(`span`,{className:`flex-1 truncate`,children:`Needs you`}),T>0&&(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${re}`})]}),(0,P.jsxs)(vo,{to:{view:`activity`},here:t.view===`activity`,badge:ie,children:[(0,P.jsx)(za,{name:`activity`}),(0,P.jsx)(`span`,{className:`flex-1 truncate`,children:`Activity`}),(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${ie}`})]})]})}),(0,P.jsxs)(Yt,{children:[(0,P.jsx)(Gt,{children:`Channels`}),i.length===0&&(0,P.jsx)(We,{className:`p-4`,children:(0,P.jsx)(fe,{children:(0,P.jsx)(te,{children:`No channels yet. One appears with its first message.`})})}),(0,P.jsx)(Ae,{children:i.map(e=>{let n=a[e.channel]??0,r=ho(e.channel)?`Events from run ${e.channel.slice(4)}`:void 0,i=ne.get(e.channel)??[];return(0,P.jsxs)(vo,{to:{view:`channel`,channel:e.channel},here:t.view===`channel`&&t.channel===e.channel,tip:r,badge:n>0?n:void 0,children:[r?(0,P.jsx)(M,{icon:Oa}):(0,P.jsx)(za,{name:`hash`}),(0,P.jsx)(`span`,{className:`flex-1 truncate`,children:e.channel}),i.length>0&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(`span`,{className:`ox-sbw`,children:[(0,P.jsx)(M,{icon:bn,className:`ox-spin`}),(0,P.jsx)(`span`,{"aria-hidden":`true`,children:i.length}),(0,P.jsx)(`span`,{className:`ui-sr`,children:_o(i)})]})}),(0,P.jsx)(E,{children:_o(i)})]}),n>0&&(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${n}`}),r&&(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${r}`})]},e.channel)})})]}),(0,P.jsxs)(Yt,{children:[(0,P.jsx)(Gt,{children:`Direct messages`}),(0,P.jsxs)(Ae,{children:[pe.map(({key:e,parts:t,opener:n,verified:r})=>{let i=t[0]===n?t[1]:t[0];return(0,P.jsxs)(vo,{to:{view:`dm`,peer:n,with:i},here:e===de,children:[(0,P.jsx)(`span`,{className:`ui-stack`,"aria-hidden":`true`,children:[n,i].map(e=>(0,P.jsx)(he,{vendor:C.get(e)?.harness,status:C.get(e)?.status??`offline`,size:18,dot:C.has(e),badge:C.has(e)?w(e):void 0},e))}),(0,P.jsx)(`span`,{className:`flex-1 truncate`,children:`${Zt(n,ee,m)}, ${Zt(i,ee,m)}`}),!r&&(0,P.jsx)(Ht,{})]},e)}),se.length>10&&(0,P.jsx)(_e,{children:(0,P.jsx)(ce,{type:`button`,"aria-expanded":le,onClick:()=>ue(e=>!e),children:(0,P.jsx)(`span`,{children:le?`Show fewer`:`Show all ${se.length}`})})})]})]})]}),(0,P.jsxs)(De,{children:[g&&(0,P.jsx)(Ae,{children:(0,P.jsx)(_e,{children:(0,P.jsx)(Ja,{side:`top`})})}),(0,P.jsxs)(to,{size:`xs`,children:[(0,P.jsx)(ro,{children:(0,P.jsx)(kn,{size:`sm`,children:(0,P.jsx)(Bn,{children:`OP`})})}),(0,P.jsxs)(io,{children:[(0,P.jsx)(ao,{children:`operator`}),oe&&(0,P.jsxs)(oo,{children:[(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(`span`,{tabIndex:0,"aria-describedby":`operator-line-why`,children:oe.text})}),(0,P.jsx)(E,{children:oe.title})]}),(0,P.jsx)(`span`,{id:`operator-line-why`,className:`ui-sr`,children:oe.title})]})]}),(0,P.jsx)(so,{children:(0,P.jsx)(yo,{connection:u})})]})]})]})}var xo=N.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function So({className:e,variant:t,size:n,spacing:i=2,orientation:a=`horizontal`,children:o,...s}){return(0,P.jsx)(ha,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":i,"data-orientation":a,style:{"--gap":i},className:r(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[spacing=0]:data-[variant=outline]:rounded-2xl data-vertical:flex-col data-vertical:items-stretch`,e),...s,children:(0,P.jsx)(xo.Provider,{value:{variant:t,size:n,spacing:i,orientation:a},children:o})})}function Co({className:e,children:t,variant:n=`default`,size:i=`default`,...a}){let o=N.useContext(xo);return(0,P.jsx)(wa,{"data-slot":`toggle-group-item`,"data-variant":o.variant||n,"data-size":o.size||i,"data-spacing":o.spacing,className:r(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-2xl group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-2xl group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-2xl group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-2xl data-[state=on]:bg-muted group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,v({variant:o.variant||n,size:o.size||i}),e),...a,children:t})}function wo(e,t){if(e){for(let{msg:n,senderId:r}of t)if(n.replyTo===e)return r===void 0?{id:n.from.id,verified:!1}:{id:r,verified:!0}}}function To({space:e}){return(0,P.jsxs)(We,{children:[(0,P.jsxs)(fe,{children:[(0,P.jsx)(dn,{"data-wave":`claude`,dangerouslySetInnerHTML:{__html:`<svg viewBox="0 0 150 150" width="150" height="150" overflow="visible" aria-hidden="true">${Nn(`claude`)}</svg>`}}),(0,P.jsx)(le,{children:e===null?`No agents here yet.`:`No agents on ${e} yet.`}),(0,P.jsx)(te,{children:`Start one from your terminal. It shows up here when it joins.`})]}),(0,P.jsxs)(Xe,{children:[(0,P.jsx)(ft,{command:`cotal spawn`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(ft,{command:`cotal personas`}),` lists the others.`]})]})]})}var Eo=e=>e.some(e=>e.card.kind===`agent`),Do=[{label:`All`,value:`all`},{label:`Channels`,value:`chat`},{label:`Direct`,value:`unicast`},{label:`Roles`,value:`anycast`}];function Oo(e,t){return e.mode===`chat`?typeof e.channel==`string`?`#${e.channel}`:null:e.mode===`anycast`?typeof e.msg.toService==`string`?`to role ${e.msg.toService}`:null:typeof e.msg.to==`string`?`to ${Zt(e.msg.to,t)}`:null}function ko({banner:e}){return(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(m,{role:`status`,children:[(0,P.jsx)(M,{icon:Ea}),(0,P.jsx)(Kt,{children:e.label}),(e.count||e.body)&&(0,P.jsxs)(we,{children:[e.count&&(0,P.jsx)(`div`,{children:e.count}),e.body&&(0,P.jsx)(`div`,{children:e.body})]}),(0,P.jsx)(`div`,{className:`ui-sr`,children:e.title})]})}),(0,P.jsx)(E,{children:e.title})]})}function Ao({store:e}){let t=A(e,e=>e.activity),n=A(e,e=>e.roster),r=A(e,e=>e.space),i=A(e,e=>e.operatorId),o=yr(A(e,e=>e.stale)),[s,c]=(0,N.useState)(`all`),l=(0,N.useMemo)(()=>Tn(n),[n]),u=(0,N.useMemo)(()=>hn(n,{includeOffline:!0}),[n]),d=(0,N.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]),f=(0,N.useMemo)(()=>{let e=t.map(e=>({msg:e.msg,senderId:e.senderId}));return t.map((t,n)=>({e:t,claim:t.mode===`anycast`?wo(t.msg.id,e.slice(n+1)):void 0})).reverse()},[t]),p=s===`all`?f:f.filter(({e})=>e.mode===s);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar ui-bar-activity`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(`h1`,{children:`Activity`}),!o&&(0,P.jsx)(po,{store:e,inHeader:!0}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsx)(So,{type:`single`,size:`sm`,"aria-label":`Show`,value:s,onValueChange:e=>{let t=Do.find(t=>t.value===e);t&&c(t.value)},children:Do.map(e=>(0,P.jsx)(Co,{value:e.value,children:e.label},e.value))})]}),(0,P.jsxs)(`div`,{className:`ui-scroll`,children:[!Eo(n)&&(0,P.jsx)(To,{space:r}),(0,P.jsxs)(`div`,{className:`ui-col flex flex-col gap-8`,children:[o&&(0,P.jsx)(ko,{banner:o}),p.map(({e,claim:t})=>{let n=e.senderId;return(0,P.jsx)(a,{msg:e.msg,senderId:n,mode:e.mode,idx:l,peers:d,own:n!==void 0&&n===i,mention:`operator`,claim:t,place:Oo(e,l)},`${e.msg.id}\u0001${n??``}`)})]})]})]})}function jo({className:e,size:t=`default`,...n}){return(0,P.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:r(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-[min(var(--radius-4xl),24px)] bg-card py-(--card-spacing) text-sm text-card-foreground shadow-sm ring-1 ring-foreground/5 [--card-spacing:--spacing(5)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] dark:ring-foreground/10 *:[img:first-child]:rounded-t-[min(var(--radius-4xl),24px)] *:[img:last-child]:rounded-b-[min(var(--radius-4xl),24px)]`,e),...n})}function Mo({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-header`,className:r(`group/card-header @container/card-header grid auto-rows-min items-start gap-1.5 rounded-t-[min(var(--radius-4xl),24px)] px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function No({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-title`,className:r(`text-base font-medium`,e),...t})}function Po({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-description`,className:r(`text-sm text-muted-foreground`,e),...t})}function Fo({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-action`,className:r(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function Io({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`card-footer`,className:r(`flex items-center rounded-b-[min(var(--radius-4xl),24px)] px-(--card-spacing) [.border-t]:pt-(--card-spacing)`,e),...t})}var Lo=`cotal.needs.dismissed`,Ro=`Dismiss until the status changes`,zo=e=>`${e.id} ${e.statusSince??``}`,Bo=new Set;function Vo(){let e=[];try{let t=JSON.parse(globalThis.localStorage?.getItem(Lo)??`[]`);Array.isArray(t)&&(e=t.filter(e=>typeof e==`string`))}catch{}return[...new Set([...e,...Bo])]}function Ho(e){try{globalThis.localStorage?.setItem(Lo,JSON.stringify(e.slice(-100)))}catch{}}function Uo(){let[e,t]=(0,N.useState)([]);return(0,N.useLayoutEffect)(()=>t(Vo()),[]),[new Set(e),n=>{Bo.add(n);let r=[...e.filter(e=>e!==n),n];t(r),Ho(r)}]}function Wo(e){let t=typeof e.statusSince==`number`&&Number.isFinite(e.statusSince)?`Reported ${In(new Date(e.statusSince))}`:void 0,n=[e.activity?.trim().replace(/\.$/,``),t].filter(e=>!!e);return n.length?`${n.join(`. `)}.`:``}function Go(e,t=Date.now()){return e.condition?Ln({condition:e.condition},t):``}function R({row:e,onViewAgent:t,onDismiss:n,post:r=null,selfId:i=null}){let a=ae(),o=Go(e);return(0,P.jsxs)(jo,{size:`sm`,children:[(0,P.jsxs)(Mo,{children:[(0,P.jsxs)(No,{className:`flex items-center gap-2`,children:[(0,P.jsx)(he,{vendor:e.harness,status:e.status,size:22,badge:a(e.id)}),`${e.name} is waiting`]}),(0,P.jsx)(Po,{className:`line-clamp-2`,children:Wo(e)}),o&&(0,P.jsx)(Po,{children:o}),(0,P.jsx)(Fo,{children:(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(St,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":Ro,onClick:n,children:(0,P.jsx)(M,{icon:an})})}),(0,P.jsx)(E,{children:Ro})]})})]}),(0,P.jsxs)(Io,{className:`flex-wrap gap-2`,children:[(0,P.jsx)(St,{type:`button`,variant:`outline`,disabled:!t,onClick:()=>t?.(e.id),children:`View agent`}),r?.mode===`off`?(0,P.jsxs)(St,{type:`button`,variant:`outline`,onClick:()=>sn(be({kind:`dm`,to:e.id})),children:[(0,P.jsx)(M,{icon:zt,"data-icon":`inline-start`}),`Copy command`]}):(0,P.jsx)(St,{asChild:!0,children:(0,P.jsx)(`a`,{href:It(Wt(e.id,i)),onClick:()=>Vt({kind:`dm`,to:e.id}),children:`Message ${e.name}`})})]})]})}function z({rows:e}){let t=ae(),n=d().isMobile;if(e.length===0)return null;let r=e.length-3;return(0,P.jsxs)(`div`,{className:`ox-typing`,role:`status`,"aria-live":`polite`,children:[e.slice(0,3).map(e=>(0,P.jsxs)(Pn,{className:`ox-wline`,children:[(0,P.jsx)(he,{vendor:e.harness,status:e.status,size:18,dot:!1,badge:t(e.id)}),(0,P.jsxs)(Ie,{className:`ox-wline-c`,children:[(0,P.jsx)(`b`,{children:e.name}),` is ${Bt(e)}`,e.activity&&(0,P.jsxs)(P.Fragment,{children:[` `,(0,P.jsx)(`span`,{className:`ox-shimmer`,children:e.activity})]})]}),(0,P.jsx)(`a`,{className:`ox-act`,href:It({view:`agent`,id:e.id,tab:`work`}),children:n?`View`:(0,P.jsxs)(P.Fragment,{children:[`View work`,(0,P.jsx)(M,{icon:vt,size:16})]})})]},e.id)),r>0&&(0,P.jsx)(`div`,{className:`ox-wmore`,children:`and ${r} more`})]})}var Ko=4,qo=[],Jo=e=>typeof e.toService==`string`?`anycast`:typeof e.to==`string`?`unicast`:`chat`,Yo={s:[`second`,`seconds`],m:[`minute`,`minutes`],h:[`hour`,`hours`],d:[`day`,`days`]};function Xo(e){let t=[];if(e?.deliveryClass===`durable`&&t.push({text:`durable`,title:`Kept for members who are offline`}),e?.replay===!0){let n=e.replayWindow;if(n===void 0)t.push({text:`replay`,title:`New members see every message the channel keeps`});else{let e=/^(\d+)(s|m|h|d)$/.exec(n.trim()),r=e?Number(e[1])===1?Yo[e[2]][0]:`${e[1]} ${Yo[e[2]][1]}`:n;t.push({text:`replay ${n}`,title:`New members see the last ${r}`})}}return t}function Zo(e,t){let n=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},r=n(t),i=n(e);if(i===r)return`Today`;if(i===n(r-432e5))return`Yesterday`;let a=new Date(e),o=a.getFullYear()===new Date(t).getFullYear();return a.toLocaleDateString(`en-GB`,o?{day:`numeric`,month:`long`}:{day:`numeric`,month:`long`,year:`numeric`})}var Qo=({msg:e,senderId:t})=>`${e.id}\u0001${t??``}`;function $o({messages:e,idx:t,peers:n,self:r}){let i=Date.now(),o=[],s=[],c=()=>{if(s.length===0)return;let i=s;s=[],o.push((0,P.jsx)(En,{messageId:Qo(e[i[0]]),children:(0,P.jsx)(Lt,{children:i.map((o,s)=>{let{msg:c,senderId:l}=e[o],u=Jo(c);return(0,P.jsx)(a,{msg:c,senderId:l,mode:u,idx:t,peers:n,run:i.length===1?`alone`:s===0?`first`:s===i.length-1?`last`:`middle`,own:l!==void 0&&l===r,mention:`operator`,claim:u===`anycast`?wo(c.id,e.slice(o+1)):void 0},Qo(e[o]))})})},Qo(e[i[0]])))},l;return e.forEach(({msg:t,senderId:n},r)=>{let a=Number.isFinite(t.ts)?Zo(t.ts,i):void 0,u=a!==void 0&&a!==l;(u||n===void 0||e[r-1]?.senderId!==n)&&c(),u&&o.push((0,P.jsx)(En,{children:(0,P.jsx)(Pn,{variant:`separator`,children:(0,P.jsx)(Ie,{children:a})})},`day\u0001${Qo(e[r])}`)),a!==void 0&&(l=a),s.push(r)}),c(),(0,P.jsx)(P.Fragment,{children:o})}function B(){return(0,P.jsx)(bt,{behavior:Dn()?`auto`:`smooth`})}function es({store:e,channel:t,onMembers:n,onViewAgent:r,panelOpen:a=!1,onTogglePanel:o}){let s=A(e,e=>e.open),c=A(e,e=>e.space),l=A(e,e=>e.channels),u=A(e,e=>e.roster),f=A(e,e=>e.membership),p=A(e,e=>e.post),m=A(e,e=>e.operatorId),h=s?.channel===t?s.messages:qo,g=(0,N.useMemo)(()=>({kind:`msg`,channel:t}),[t]),_=(0,N.useMemo)(()=>new Set(h.map(e=>e.msg.id)),[h]),v=(0,N.useMemo)(()=>Tn(u),[u]),y=(0,N.useMemo)(()=>hn(u,{includeOffline:!0}),[u]),b=(0,N.useMemo)(()=>new Map(y.map(e=>[e.id,e])),[y]),x=ae(),S=l.find(e=>e.channel===t),ee=(0,N.useMemo)(()=>$e(t,f,l.map(e=>e.channel),h),[t,f,l,h]),C=ee.map(e=>b.get(e.id)).filter(e=>e?.status===`working`),[w,te]=Uo(),ne=dt(y).find(e=>!w.has(zo(e))),T=ee.length,re=d().isMobile,ie=re?`Open agent panel`:`Toggle panel`,oe=`${T} member${T===1?``:`s`}`,se=`Working now: ${C.map(e=>e.name).join(`, `)}`;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(`h1`,{children:`# ${t}`}),S?.description&&(0,P.jsx)(`span`,{className:`ui-topic`,children:S.description}),(0,P.jsx)(`span`,{className:`ui-sp`}),!re&&Xo(S).map(e=>(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(gt,{variant:`outline`,children:[e.text,(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${e.title}`})]})}),(0,P.jsx)(E,{children:e.title})]},e.text)),C.length>0&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(`span`,{className:`ox-hchip`,children:[(0,P.jsx)(M,{icon:bn,size:16,className:`ui-ic ox-spin`}),re?C.length:`${C.length} working`,(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${se}`})]})}),(0,P.jsx)(E,{children:se})]}),(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(`span`,{className:`inline-flex`,tabIndex:n?void 0:0,children:(0,P.jsxs)(St,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":oe,disabled:!n,onClick:n,children:[(0,P.jsx)(`span`,{className:`ui-stack`,"aria-hidden":`true`,children:ee.slice(0,Ko).map(e=>{let t=b.get(e.id);return(0,P.jsx)(he,{vendor:t?.harness,status:t?.status??`offline`,badge:t?x(e.id):void 0,size:22},e.id)})}),T]})})}),(0,P.jsx)(E,{children:oe})]}),o&&(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(Be,{"aria-label":ie,pressed:a,onPressedChange:o,children:(0,P.jsx)(M,{icon:i})})}),(0,P.jsx)(E,{children:ie})]})]}),(0,P.jsx)(wt,{autoScroll:!0,children:(0,P.jsxs)(yn,{className:`flex-1`,children:[(0,P.jsx)(At,{children:(0,P.jsxs)(Qt,{className:`ui-col`,children:[s?.channel===t&&s.olderRetained&&(0,P.jsxs)(En,{className:`text-sm text-muted-foreground`,children:[(0,P.jsx)(`p`,{children:`Earlier messages are retained. To read further back, run:`}),(0,P.jsx)(`code`,{className:`[overflow-wrap:anywhere]`,children:`cotal history ${ke(`#${t}`)} --limit 2000${c===null?``:` --space ${ke(c)}`}`})]}),(0,P.jsx)($o,{messages:h,idx:v,peers:b,self:m}),(0,P.jsx)(gn,{store:e,target:g,shown:_}),C.length>0&&(0,P.jsx)(En,{children:(0,P.jsx)(z,{rows:C})})]})}),(0,P.jsx)(B,{})]})},t),(ne||p)&&(0,P.jsx)(`div`,{className:`ui-dock`,children:(0,P.jsxs)(`div`,{className:`ui-dock-in`,children:[ne&&(0,P.jsx)(R,{row:ne,onViewAgent:r,onDismiss:()=>te(zo(ne)),post:p,selfId:m}),(0,P.jsx)(rn,{store:e,target:g,where:`#${t}`,to:re?`to #${t}`:`to #${t} · ${T} member${T===1?``:`s`}`})]})})]})}function ts({store:e,peer:t,with:n}){let r=A(e,e=>e.dms),i=A(e,e=>e.roster),a=A(e,e=>e.post),o=A(e,e=>e.operatorId),s=(0,N.useMemo)(()=>Tn(i),[i]),c=(0,N.useMemo)(()=>hn(i,{includeOffline:!0}),[i]),l=(0,N.useMemo)(()=>new Map(c.map(e=>[e.id,e])),[c]),u=A(e,e=>e.dmsCut),d=n??o??void 0,f=(0,N.useMemo)(()=>{if(d===void 0)return;let e=yt(t,d);return on(r).find(t=>t.key===e)},[r,t,d]),p=l.get(t),m=ae(),h=Zt(t,s,o),g=[p?.role,p?.harness&&ve(p.harness)].filter(Boolean).join(` · `),_=(0,N.useMemo)(()=>Jt({view:`dm`,peer:t,with:n},o),[t,n,o]),v=(0,N.useMemo)(()=>new Set(r.map(e=>e.msg.id)),[r]),y=A(e,e=>_?e.drafts[Ee(_)]?.outgoing.length??0:0),b=_?.kind===`dm`?Zt(_.to,s,o):``,x=[...new Set([t,d])].map(e=>e===void 0?void 0:l.get(e)).filter(e=>e?.status===`working`);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(he,{vendor:p?.harness,status:p?.status??`offline`,size:22,badge:p?m(t):void 0}),(0,P.jsx)(`h1`,{children:h}),g&&(0,P.jsx)(`span`,{className:`ui-topic`,children:g}),f&&d!==void 0&&(0,P.jsx)(`span`,{className:`ui-topic`,children:`with ${Zt(d,s,o)}`}),f&&!f.verified&&(0,P.jsx)(Ht,{})]}),(0,P.jsx)(wt,{autoScroll:!0,children:(0,P.jsxs)(yn,{className:`flex-1`,children:[(0,P.jsx)(At,{children:(0,P.jsx)(Qt,{className:`ui-col`,children:f||y>0?(0,P.jsxs)(P.Fragment,{children:[f&&u&&(0,P.jsx)(En,{children:(0,P.jsx)(Pn,{children:(0,P.jsx)(Ie,{children:`Earlier messages aren't loaded`})})}),f&&(0,P.jsx)($o,{messages:f.messages,idx:s,peers:l,self:o}),_&&(0,P.jsx)(gn,{store:e,target:_,shown:v}),x.length>0&&(0,P.jsx)(En,{children:(0,P.jsx)(z,{rows:x})})]}):(0,P.jsx)(En,{children:(0,P.jsx)(We,{children:(0,P.jsx)(fe,{children:(0,P.jsx)(le,{children:`No direct messages with ${h} yet.`})})})})})}),(0,P.jsx)(B,{})]})},`${t}\u0001${d??``}`),a&&(_||n!==void 0)&&(0,P.jsx)(`div`,{className:`ui-dock`,children:(0,P.jsx)(`div`,{className:`ui-dock-in`,children:_?(0,P.jsx)(rn,{store:e,target:_,where:b,to:`to ${b}`}):(0,P.jsx)(Et,{peer:t,name:h,selfId:o})})})]})}var ns=`cotal.agents.group`,rs=1e3;function is(){try{let e=globalThis.localStorage?.getItem(ns);return e===`status`||e===`host`?e:void 0}catch{return}}function as(e){try{globalThis.localStorage?.setItem(ns,e)}catch{}}function os(e){let t=[...new Set(e.map(e=>e.status).filter(e=>!xn.includes(e)))].sort();return[...xn,...t].map(t=>({key:t,label:re(t),rows:e.filter(e=>e.status===t)})).filter(e=>e.rows.length>0)}function ss(e){let t=[...new Set(e.map(e=>e.host).filter(e=>e!==void 0))].sort((e,t)=>e.localeCompare(t)).map(t=>({key:`host:${t}`,label:t,rows:e.filter(e=>e.host===t)})),n=e.filter(e=>e.host===void 0);return n.length>0?[...t,{key:`host:`,label:`No host reported`,rows:n}]:t}var cs=e=>[e.role,e.harness===void 0?void 0:ve(e.harness)].filter(Boolean).join(` · `);function ls(e,t){return e.status===`offline`?`Last heartbeat ${In(new Date(e.ts))}`:e.status===`waiting`&&t===`status`?Wo(e)||`No current activity`:e.activity?.trim()||(e.status===`working`?re(Bt(e)):`No current activity`)}function us(e,t){let n=e.items.findLast(e=>e.kind===`turn`&&e.outcome===`open`&&!e.superseded),r=n?.steps.findLast(e=>e.kind!==`runError`);if(n===void 0||r?.kind!==`tools`)return;let i=r.calls.findLast(r=>ct(r,{turn:n,trailing:!0,status:t,toolStatus:e.toolStatus})===`running`);return i===void 0?void 0:{call:i,turn:n}}function ds({store:e,controller:t,row:n}){jt(n.events===`off`?null:t,n.id);let r=A(e,e=>e.sessions[n.id]?.frames),i=Pt(e,n.id),a=(0,N.useMemo)(()=>r===void 0?void 0:us(zn(r,i),n.status),[r,i,n.status]);return a===void 0?null:(0,P.jsx)(`span`,{className:`ox-now-w`,"aria-hidden":`true`,children:(0,P.jsx)(Dt,{call:a.call,state:`running`,className:`ox-now`})})}function fs({row:e,grouping:t,selected:n,onPick:r,live:i}){let a=e.attention===`dnd`||e.attention===`focus`?e.attention:void 0,o=e.status===`waiting`&&t===`status`,s=ae();return(0,P.jsxs)(`div`,{className:e.status===`working`?`ox-arow ox-arow-w`:`ox-arow`,children:[(0,P.jsxs)(`button`,{type:`button`,className:e.status===`offline`?`v3-arow v3-arow-off`:`v3-arow`,"data-agent":e.id,"aria-current":n?`true`:void 0,onClick:()=>r?.(e.id),children:[(0,P.jsx)(he,{vendor:e.harness,status:e.status,size:36,badge:s(e.id)}),(0,P.jsxs)(`span`,{children:[(0,P.jsxs)(`span`,{className:`v3-aname`,children:[(0,P.jsx)(`b`,{title:e.name,children:e.name}),(0,P.jsx)(`span`,{children:cs(e)})]}),(0,P.jsx)(`span`,{className:`v3-aact`,style:o?{color:`var(--gold-ink)`}:void 0,children:ls(e,t)}),i&&(0,P.jsx)(ds,{store:i.store,controller:i.controller,row:e})]}),a?(0,P.jsx)(ot,{attention:a}):(0,P.jsx)(`span`,{}),t===`host`?(0,P.jsx)(l,{row:e}):e.host!==void 0&&e.status!==`working`?(0,P.jsxs)(`span`,{className:`v3-meta ox-host`,children:[(0,P.jsx)(M,{icon:ka,size:16,className:`ui-ic`}),e.host]}):(0,P.jsx)(`span`,{})]}),e.status===`working`&&(0,P.jsxs)(`a`,{className:`ox-act`,href:It({view:`agent`,id:e.id,tab:`work`}),children:[`View work`,(0,P.jsx)(M,{icon:vt,size:16})]})]})}function ps({rows:e}){return(0,P.jsxs)(`div`,{className:`v3-epsec`,children:[(0,P.jsxs)(`div`,{className:`v3-ghead`,style:{paddingTop:12},children:[(0,P.jsx)(M,{icon:Oa,size:16,className:`ui-ic`}),(0,P.jsx)(`span`,{style:{color:`var(--dim)`},children:`Endpoints`}),(0,P.jsx)(`span`,{className:`v3-count`,children:e.length})]}),e.map(e=>(0,P.jsxs)(`div`,{className:`v3-eprow`,children:[(0,P.jsx)(`span`,{className:e.status===`offline`?`ui-av ui-av-ep ui-av-off`:`ui-av ui-av-ep`,children:(0,P.jsx)(M,{icon:Aa,size:16,className:`ui-ic ui-ic16`})}),(0,P.jsx)(`b`,{children:e.name}),(0,P.jsx)(`span`,{children:[e.role,e.host,e.status===`offline`?re(e.status):void 0].filter(Boolean).join(` · `)})]},e.id))]})}function ms({beat:e,clock:t}){let[,n]=(0,N.useReducer)(e=>e+1,0);return(0,N.useEffect)(()=>{let e=setInterval(n,rs);return()=>clearInterval(e)},[]),(0,P.jsxs)(`div`,{className:`v3-eprow`,style:{paddingLeft:66,fontSize:12.5},children:[`Oldest heartbeat among live agents: `,(0,P.jsx)(`span`,{className:`ui-num`,children:pt(t()-e)}),` ago`]})}function hs({store:e,controller:t=null,group:n,focusWaiting:r=!1,selected:i=null,onPick:a,clock:o=Date.now}){let s=A(e,e=>e.roster),c=A(e,e=>e.space),l=A(e,e=>e.stale),[u,d]=(0,N.useState)(n??`status`),f=(0,N.useRef)(null);(0,N.useLayoutEffect)(()=>d(n??is()??`status`),[n]);let{agents:p,endpoints:m}=(0,N.useMemo)(()=>{let e=e=>e.card.kind===`agent`;return{agents:hn(s.filter(e),{includeOffline:!0}),endpoints:hn(s.filter(t=>!e(t)),{includeOffline:!0})}},[s]),h=u===`status`?os(p):ss(p),g=p.length===0,_=h.some(e=>e.key===`waiting`)&&u===`status`,v=(0,N.useRef)(!1);(0,N.useLayoutEffect)(()=>{if(!r){v.current=!1;return}if(g||v.current)return;v.current=!0;let e=_?f.current:null;e?.focus({preventScroll:!0}),e?.scrollIntoView?.({block:`start`})},[r,g]);let y=e=>{d(e),as(e)},b=p.filter(e=>e.status!==`offline`).length,x=l.some(e=>e.name===`roster`),S=new Set(x?[]:h.flatMap(e=>e.rows).filter(e=>e.status===`working`).slice(0,12).map(e=>e.id)),ee=nn(p);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(`h1`,{children:`Agents`}),!g&&(0,P.jsx)(`span`,{className:`ui-topic`,children:x?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`ui-num`,children:b}),` last seen`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`ui-num`,children:b}),` live, `,(0,P.jsx)(`span`,{className:`ui-num`,children:p.length-b}),` offline`,c===null?``:` on ${c}`]})}),(0,P.jsx)(`span`,{className:`ui-sp`}),!g&&(0,P.jsxs)(So,{type:`single`,size:`sm`,"aria-label":`Group by`,value:u,onValueChange:e=>(e===`status`||e===`host`)&&y(e),children:[(0,P.jsx)(Co,{value:`status`,children:`Status`}),(0,P.jsx)(Co,{value:`host`,children:`Host`})]})]}),(0,P.jsx)(`div`,{className:`ui-scroll`,children:(0,P.jsxs)(`div`,{className:x?`ui-col s-lastseen`:`ui-col`,style:{maxWidth:900},children:[g&&(0,P.jsx)(To,{space:c}),!g&&(0,P.jsxs)(`div`,{className:u===`status`?`v3-by-status`:`v3-by-host`,children:[h.flatMap(n=>{let o=u===`status`?n.key:void 0,s=o!==void 0&&Object.hasOwn(Vn,o);return[(0,P.jsxs)(`div`,{className:s?`v3-ghead v3-s-${o}`:`v3-ghead`,role:`heading`,"aria-level":2,ref:o===`waiting`?f:void 0,tabIndex:o===`waiting`?-1:void 0,"data-focused":o===`waiting`&&r?`true`:void 0,children:[s&&(0,P.jsx)(M,{icon:Vn[o],size:16,className:qe(n.key,`ui-ic`)}),u===`host`&&(0,P.jsx)(M,{icon:ka,size:16,className:`ui-ic`}),(0,P.jsx)(`span`,{style:{color:o===`offline`?`var(--dim)`:`var(--ink)`},children:n.label}),(0,P.jsx)(`span`,{className:`v3-count`,children:n.rows.length})]},`head:${n.key}`),...n.rows.map(n=>(0,P.jsx)(fs,{row:n,grouping:u,selected:i===n.id,onPick:a,live:S.has(n.id)?{store:e,controller:t}:void 0},`row:${n.id}`))]}),u===`status`&&!x&&ee!==void 0&&Number.isFinite(ee)&&(0,P.jsx)(ms,{beat:ee,clock:o})]},u),m.length>0&&(0,P.jsx)(ps,{rows:m})]})})]})}var gs=[];function _s(e,t){let n=0,r=e.steps.length;for(;r>0&&n<t;){let t=e.steps[--r];t.kind!==`prompt`&&t.kind!==`reasoning`&&n++}return{...e,steps:e.steps.slice(r)}}function vs({turn:e,current:t,row:n}){let r=cn(t),{title:i,failed:a}=ht(e,n.status,r);return(0,P.jsxs)(`div`,{className:`ui-lt-head ox-now-head`,children:[(0,P.jsx)(`h5`,{children:t?`Now`:`Last turn`}),(0,P.jsxs)(`span`,{className:`ox-now-t`,children:[i,a!==void 0&&(0,P.jsxs)(P.Fragment,{children:[`, `,(0,P.jsxs)(`span`,{className:`ox-fail`,children:[(0,P.jsx)(M,{icon:ut,size:16}),a]})]})]})]})}function ys({store:e,id:t}){let n=A(e,e=>e.roster),r=A(e,e=>e.operatorId),i=A(e,e=>e.sessions[t]?.frames)??gs,a=A(e,e=>e.sessions[t]?.payloadRead),o=Pt(e,t),s=n.find(e=>e.card.id===t),c=(0,N.useMemo)(()=>s?hn([s],{includeOffline:!0})[0]:void 0,[s]),l=(0,N.useMemo)(()=>j(s),[s]),u=(0,N.useMemo)(()=>{let e=Tn(n);return t=>Zt(t,e,r)},[n,r]),d=(0,N.useMemo)(()=>zn(i,o),[i,o]);if(!c)return null;if(c.events===`off`)return(0,P.jsx)(_n,{children:`${c.name} publishes no work events.`});let f=d.items.filter(e=>e.kind===`turn`),p=f.findLast(e=>e.outcome===`open`&&!e.superseded),m=p!==void 0&&(c.status===`working`||c.status===`waiting`),h=m?p:f.at(-1);return h?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(vs,{turn:h,current:m,row:c}),(0,P.jsx)(Rt,{payloadRead:a,work:{items:[_s(h,3)],toolStatus:d.toolStatus},row:c,compact:!0,condition:l,nameOf:u})]}):null}function bs({store:e,controller:t=null,id:n,route:r}){let i=A(e,e=>e.roster),a=A(e,e=>e.operatorId),o=i.find(e=>e.card.id===n),s=(0,N.useMemo)(()=>o?hn([o],{includeOffline:!0})[0].events:void 0,[o]);jt(o&&s!==`off`?t:null,n);let c=ae();if(!o)return(0,P.jsx)(`p`,{className:`ui-nr`,children:`Not on the roster`});let u=hn([o],{includeOffline:!0})[0],d=[u.role,u.harness&&ve(u.harness)].filter(Boolean).join(` · `),f=typeof u.statusSince==`number`&&Number.isFinite(u.statusSince)?`Reported ${In(new Date(u.statusSince))}`:void 0;return(0,P.jsxs)(`div`,{className:`ox-peek`,children:[(0,P.jsxs)(`div`,{className:`ox-peek-who`,children:[(0,P.jsx)(he,{vendor:u.harness,status:u.status,size:44,badge:c(u.id)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`b`,{children:u.name}),d&&(0,P.jsx)(`div`,{className:`ui-sub`,children:d})]})]}),(0,P.jsxs)(`div`,{className:`ui-sline`,children:[(0,P.jsx)(l,{row:u}),(0,P.jsx)(`span`,{style:{color:`var(--ink)`},children:u.activity||`No current activity`}),f&&(0,P.jsx)(`small`,{children:f}),Ln(u,Date.now())&&(0,P.jsx)(`small`,{className:`ui-facts`,children:Ln(u,Date.now())})]}),(r?.view!==`agent`||r.id!==n)&&(0,P.jsx)(ys,{store:e,id:n}),(0,P.jsxs)(`div`,{className:`ui-actions`,children:[(0,P.jsx)(St,{asChild:!0,size:`sm`,children:(0,P.jsxs)(`a`,{href:It({view:`agent`,id:u.id,tab:`work`}),children:[(0,P.jsx)(M,{icon:vt,"data-icon":`inline-start`}),`Open ${u.name}'s page`]})}),(0,P.jsx)(St,{asChild:!0,variant:`outline`,size:`sm`,children:(0,P.jsxs)(`a`,{href:It(Wt(u.id,a)),onClick:()=>Vt({kind:`dm`,to:u.id}),children:[(0,P.jsx)(M,{icon:Tt,"data-icon":`inline-start`}),`Message`]})})]})]})}var xs={live:{word:`live`,cls:`ui-mdot-live`,title:`From broker membership, served by the delivery daemon`},stale:{word:`stale`,cls:`ui-mdot-stale`,title:`The daemon's last report is older than 45 seconds, or has no time on it`},"traffic-only":{word:`traffic-only`,cls:`ui-mdot-traffic`,title:`No delivery daemon on an open mesh, so members come from who has posted`},unreadable:{word:`unreadable`,cls:`ui-mdot-unread`}};function Ss({state:e,reason:t}){let n=xs[e],r=e===`unreadable`?t?`the read failed: ${t}`:`the read failed`:n.title;return(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsxs)(gt,{variant:e===`unreadable`?`destructive`:`outline`,children:[(0,P.jsx)(`i`,{className:`ui-mdot ${n.cls}`}),`Membership: `,n.word,(0,P.jsx)(`span`,{className:`ui-sr`,children:` ${r}`})]})}),(0,P.jsx)(E,{children:r})]})}function Cs({...e}){return(0,P.jsx)(Ar,{"data-slot":`alert-dialog`,...e})}function ws({...e}){return(0,P.jsx)(jr,{"data-slot":`alert-dialog-trigger`,...e})}function Ts({...e}){return(0,P.jsx)(Mr,{"data-slot":`alert-dialog-portal`,...e})}function Es({className:e,...t}){return(0,P.jsx)(Nr,{"data-slot":`alert-dialog-overlay`,className:r(`fixed inset-0 z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Ds({className:e,size:t=`default`,...n}){return(0,P.jsxs)(Ts,{children:[(0,P.jsx)(Es,{}),(0,P.jsx)(Ir,{"data-slot":`alert-dialog-content`,"data-size":t,className:r(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-[min(var(--radius-4xl),24px)] bg-popover p-6 text-popover-foreground shadow-xl ring-1 ring-foreground/5 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-md dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function Os({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:r(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function ks({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:r(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function As({className:e,...t}){return(0,P.jsx)(Lr,{"data-slot":`alert-dialog-title`,className:r(`text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function js({className:e,...t}){return(0,P.jsx)(Rr,{"data-slot":`alert-dialog-description`,className:r(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Ms({className:e,variant:t=`default`,size:n=`default`,...i}){return(0,P.jsx)(St,{variant:t,size:n,asChild:!0,children:(0,P.jsx)(zr,{"data-slot":`alert-dialog-action`,className:r(e),...i})})}function Ns({className:e,variant:t=`outline`,size:n=`default`,...i}){return(0,P.jsx)(St,{variant:t,size:n,asChild:!0,children:(0,P.jsx)(Vr,{"data-slot":`alert-dialog-cancel`,className:r(e),...i})})}function Ps({className:e,type:t,...n}){return(0,P.jsx)(`input`,{type:t,"data-slot":`input`,className:r(`h-8 w-full min-w-0 rounded-2xl border border-transparent bg-input/50 px-2.5 py-1 text-base transition-[color,box-shadow] duration-200 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function Fs({channel:e,space:t,controller:n,children:r}){let[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(null),[u,d]=(0,N.useState)(!1),f=(0,N.useRef)(null),p=(0,N.useId)(),h=o===e,g=e=>{a(e),e&&(s(``),l(null),d(!1))},_=async()=>{if(h&&n!==null&&!u){d(!0),l(null);try{await n.deleteChannel(e),a(!1)}catch(e){l(e instanceof Error?e.message:String(e)),d(!1)}}};return(0,P.jsxs)(Cs,{open:i,onOpenChange:g,children:[(0,P.jsx)(ws,{asChild:!0,children:r}),(0,P.jsxs)(Ds,{onOpenAutoFocus:e=>{e.preventDefault(),f.current?.focus()},children:[(0,P.jsxs)(Os,{children:[(0,P.jsx)(As,{children:`Delete #${e}?`}),(0,P.jsx)(js,{children:`This deletes every message in #${e} for everyone${t?` on ${t}`:``}. You can't undo it. If anyone posts to #${e} again, it comes back empty.`})]}),(0,P.jsxs)(Nt,{children:[(0,P.jsx)(lt,{htmlFor:p,children:(0,P.jsxs)(`span`,{children:[`Type `,(0,P.jsx)(`b`,{children:e}),` to confirm`]})}),(0,P.jsx)(Ps,{ref:f,id:p,value:o,autoComplete:`off`,spellCheck:!1,onChange:e=>s(e.target.value)})]}),c!==null&&(0,P.jsx)(m,{variant:`destructive`,children:(0,P.jsx)(we,{children:c})}),(0,P.jsxs)(ks,{children:[(0,P.jsx)(Ns,{children:`Keep channel`}),(0,P.jsxs)(Ms,{variant:`destructive`,disabled:!h||u||n===null,onClick:e=>{e.preventDefault(),_()},children:[(0,P.jsx)(M,{icon:Da,"data-icon":`inline-start`}),`Delete #${e}`]})]})]})]})}var Is=[];function Ls(e){if(e?.deliveryClass===void 0)return;let t=[e.deliveryClass];return e.replay===!0&&t.push(e.replayWindow===void 0?`replay`:`replay ${e.replayWindow}`),t.join(`, `)}function Rs({store:e,controller:t,channel:r,now:i,onPick:a}){let o=A(e,e=>e.space),s=A(e,e=>e.roster),c=A(e,e=>e.channels),u=A(e,e=>e.membership),d=A(e,e=>e.channelDeleteSupported),f=A(e,e=>e.open),p=f?.channel===r?f.messages:Is,m=(0,N.useMemo)(()=>Tn(s),[s]),h=(0,N.useMemo)(()=>hn(s,{includeOffline:!0}),[s]),g=(0,N.useMemo)(()=>{let e=new Map(h.map((e,t)=>[e.id,t])),t=t=>e.get(t)??h.length;return $e(r,u,c.map(e=>e.channel),p).sort((e,n)=>t(e.id)-t(n.id))},[r,u,c,p,h]),_=ae(),v=(0,N.useMemo)(()=>new Map(h.map(e=>[e.id,e])),[h]),y=c.find(e=>e.channel===r),b=Ls(y),x=g.length;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`v3-mhead`,children:[(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`b`,{style:{color:`var(--ink)`,fontWeight:600},children:`#${r}`}),` · `,(0,P.jsx)(`span`,{className:`ui-num`,children:x}),x===1?` member`:` members`]}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsx)(Ss,{state:n(u,i),reason:u.unreadable})]}),g.map(e=>{let t=v.get(e.id);return(0,P.jsxs)(`button`,{type:`button`,className:`v3-mrow`,"data-member":e.id,"data-source":e.source,onClick:()=>a(e.id),children:[(0,P.jsx)(he,{vendor:t?.harness,status:t?.status??`offline`,size:28,dot:t!==void 0,badge:t?_(e.id):void 0}),(0,P.jsxs)(`span`,{className:`v3-mname`,children:[t?.name??Zt(e.id,m),t?.role&&(0,P.jsx)(`span`,{children:t.role})]}),t&&(0,P.jsx)(l,{row:t})]},e.id)}),(0,P.jsx)(`h5`,{style:{marginTop:14},children:`Channel`}),(0,P.jsxs)(`dl`,{className:`ui-kv`,style:{borderTop:0,paddingTop:0},children:[y?.description&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`dt`,{children:`Topic`}),(0,P.jsx)(`dd`,{children:y.description})]}),b&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`dt`,{children:`Delivery`}),(0,P.jsx)(`dd`,{children:b})]}),y&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`dt`,{children:`Messages`}),(0,P.jsx)(`dd`,{className:`ui-num`,children:y.messages})]})]}),d&&(0,P.jsx)(Fs,{channel:r,space:o,controller:t,children:(0,P.jsxs)(St,{type:`button`,variant:`destructive`,className:`mt-1`,children:[(0,P.jsx)(M,{icon:Da,"data-icon":`inline-start`}),`Delete channel`]})})]})}var zs={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Bs(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),zs.hasOwnProperty(t)?{space:zs[t],local:e}:e}function Vs(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Hs(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Us(e){var t=Bs(e);return(t.local?Hs:Vs)(t)}function Ws(){}function Gs(e){return e==null?Ws:function(){return this.querySelector(e)}}function Ks(e){typeof e!=`function`&&(e=Gs(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new Nl(r,this._parents)}function qs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Js(){return[]}function Ys(e){return e==null?Js:function(){return this.querySelectorAll(e)}}function Xs(e){return function(){return qs(e.apply(this,arguments))}}function Zs(e){e=typeof e==`function`?Xs(e):Ys(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Nl(r,i)}function Qs(e){return function(){return this.matches(e)}}function $s(e){return function(t){return t.matches(e)}}var ec=Array.prototype.find;function tc(e){return function(){return ec.call(this.children,e)}}function nc(){return this.firstElementChild}function rc(e){return this.select(e==null?nc:tc(typeof e==`function`?e:$s(e)))}var ic=Array.prototype.filter;function ac(){return Array.from(this.children)}function oc(e){return function(){return ic.call(this.children,e)}}function sc(e){return this.selectAll(e==null?ac:oc(typeof e==`function`?e:$s(e)))}function cc(e){typeof e!=`function`&&(e=Qs(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Nl(r,this._parents)}function lc(e){return Array(e.length)}function uc(){return new Nl(this._enter||this._groups.map(lc),this._parents)}function dc(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}dc.prototype={constructor:dc,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function fc(e){return function(){return e}}function pc(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new dc(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function mc(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new dc(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function hc(e){return e.__data__}function gc(e,t){if(!arguments.length)return Array.from(this,hc);var n=t?mc:pc,r=this._parents,i=this._groups;typeof e!=`function`&&(e=fc(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=_c(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new Nl(o,r),o._enter=s,o._exit=c,o}function _c(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function vc(){return new Nl(this._exit||this._groups.map(lc),this._parents)}function yc(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function bc(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new Nl(s,this._parents)}function xc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function Sc(e){e||=Cc;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Nl(i,this._parents).order()}function Cc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function wc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Tc(){return Array.from(this)}function Ec(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function Dc(){let e=0;for(let t of this)++e;return e}function Oc(){return!this.node()}function kc(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function Ac(e){return function(){this.removeAttribute(e)}}function jc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mc(e,t){return function(){this.setAttribute(e,t)}}function Nc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Pc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Fc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Ic(e,t){var n=Bs(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?jc:Ac:typeof t==`function`?n.local?Fc:Pc:n.local?Nc:Mc)(n,t))}function Lc(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Rc(e){return function(){this.style.removeProperty(e)}}function zc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Bc(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Vc(e,t,n){return arguments.length>1?this.each((t==null?Rc:typeof t==`function`?Bc:zc)(e,t,n??``)):Hc(this.node(),e)}function Hc(e,t){return e.style.getPropertyValue(t)||Lc(e).getComputedStyle(e,null).getPropertyValue(t)}function Uc(e){return function(){delete this[e]}}function Wc(e,t){return function(){this[e]=t}}function Gc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Kc(e,t){return arguments.length>1?this.each((t==null?Uc:typeof t==`function`?Gc:Wc)(e,t)):this.node()[e]}function qc(e){return e.trim().split(/^|\s+/)}function Jc(e){return e.classList||new Yc(e)}function Yc(e){this._node=e,this._names=qc(e.getAttribute(`class`)||``)}Yc.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Xc(e,t){for(var n=Jc(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Zc(e,t){for(var n=Jc(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Qc(e){return function(){Xc(this,e)}}function $c(e){return function(){Zc(this,e)}}function el(e,t){return function(){(t.apply(this,arguments)?Xc:Zc)(this,e)}}function tl(e,t){var n=qc(e+``);if(arguments.length<2){for(var r=Jc(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?el:t?Qc:$c)(n,t))}function nl(){this.textContent=``}function rl(e){return function(){this.textContent=e}}function il(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function al(e){return arguments.length?this.each(e==null?nl:(typeof e==`function`?il:rl)(e)):this.node().textContent}function ol(){this.innerHTML=``}function sl(e){return function(){this.innerHTML=e}}function cl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function ll(e){return arguments.length?this.each(e==null?ol:(typeof e==`function`?cl:sl)(e)):this.node().innerHTML}function ul(){this.nextSibling&&this.parentNode.appendChild(this)}function dl(){return this.each(ul)}function fl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function pl(){return this.each(fl)}function ml(e){var t=typeof e==`function`?e:Us(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function hl(){return null}function gl(e,t){var n=typeof e==`function`?e:Us(e),r=t==null?hl:typeof t==`function`?t:Gs(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function _l(){var e=this.parentNode;e&&e.removeChild(this)}function vl(){return this.each(_l)}function yl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function V(e){return this.select(e?bl:yl)}function xl(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Sl(e){return function(t){e.call(this,t,this.__data__)}}function Cl(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function wl(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function Tl(e,t,n){return function(){var r=this.__on,i,a=Sl(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function El(e,t,n){var r=Cl(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}}else{for(s=t?Tl:wl,i=0;i<a;++i)this.each(s(r[i],t,n));return this}}function Dl(e,t,n){var r=Lc(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Ol(e,t){return function(){return Dl(this,e,t)}}function kl(e,t){return function(){return Dl(this,e,t.apply(this,arguments))}}function Al(e,t){return this.each((typeof t==`function`?kl:Ol)(e,t))}function*jl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Ml=[null];function Nl(e,t){this._groups=e,this._parents=t}function Pl(){return new Nl([[document.documentElement]],Ml)}function Fl(){return this}Nl.prototype=Pl.prototype={constructor:Nl,select:Ks,selectAll:Zs,selectChild:rc,selectChildren:sc,filter:cc,data:gc,enter:uc,exit:vc,join:yc,merge:bc,selection:Fl,order:xc,sort:Sc,call:wc,nodes:Tc,node:Ec,size:Dc,empty:Oc,each:kc,attr:Ic,style:Vc,property:Kc,classed:tl,text:al,html:ll,raise:dl,lower:pl,append:ml,insert:gl,remove:vl,clone:V,datum:xl,on:El,dispatch:Al,[Symbol.iterator]:jl};function Il(e){return typeof e==`string`?new Nl([[document.querySelector(e)]],[document.documentElement]):new Nl([[e]],Ml)}function Ll(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Rl(e,t){if(e=Ll(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var zl={value:()=>{}};function Bl(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Vl(n)}function Vl(e){this._=e}function Hl(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Vl.prototype=Bl.prototype={constructor:Vl,on:function(e,t){var n=this._,r=Hl(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Ul(n[i],e.name)))return i}else{if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Wl(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Wl(n[i],e.name,null);return this}},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Vl(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Ul(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Wl(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=zl,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Gl={capture:!0,passive:!1};function Kl(e){e.preventDefault(),e.stopImmediatePropagation()}function ql(e){var t=e.document.documentElement,n=Il(e).on(`dragstart.drag`,Kl,Gl);`onselectstart`in t?n.on(`selectstart.drag`,Kl,Gl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function Jl(e,t){var n=e.document.documentElement,r=Il(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,Kl,Gl),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Yl(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Xl(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Zl(){}var Ql=.7,$l=1/Ql,eu=`\\s*([+-]?\\d+)\\s*`,tu=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,nu=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,ru=/^#([0-9a-f]{3,8})$/,iu=RegExp(`^rgb\\(${eu},${eu},${eu}\\)$`),au=RegExp(`^rgb\\(${nu},${nu},${nu}\\)$`),ou=RegExp(`^rgba\\(${eu},${eu},${eu},${tu}\\)$`),su=RegExp(`^rgba\\(${nu},${nu},${nu},${tu}\\)$`),H=RegExp(`^hsl\\(${tu},${nu},${nu}\\)$`),cu=RegExp(`^hsla\\(${tu},${nu},${nu},${tu}\\)$`),lu={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};Yl(Zl,mu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:uu,formatHex:uu,formatHex8:du,formatHsl:fu,formatRgb:pu,toString:pu});function uu(){return this.rgb().formatHex()}function du(){return this.rgb().formatHex8()}function fu(){return Eu(this).formatHsl()}function pu(){return this.rgb().formatRgb()}function mu(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=ru.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?hu(t):n===3?new yu(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?gu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?gu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=iu.exec(e))?new yu(t[1],t[2],t[3],1):(t=au.exec(e))?new yu(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ou.exec(e))?gu(t[1],t[2],t[3],t[4]):(t=su.exec(e))?gu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=H.exec(e))?Tu(t[1],t[2]/100,t[3]/100,1):(t=cu.exec(e))?Tu(t[1],t[2]/100,t[3]/100,t[4]):lu.hasOwnProperty(e)?hu(lu[e]):e===`transparent`?new yu(NaN,NaN,NaN,0):null}function hu(e){return new yu(e>>16&255,e>>8&255,e&255,1)}function gu(e,t,n,r){return r<=0&&(e=t=n=NaN),new yu(e,t,n,r)}function _u(e){return e instanceof Zl||(e=mu(e)),e?(e=e.rgb(),new yu(e.r,e.g,e.b,e.opacity)):new yu}function vu(e,t,n,r){return arguments.length===1?_u(e):new yu(e,t,n,r??1)}function yu(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Yl(yu,vu,Xl(Zl,{brighter(e){return e=e==null?$l:$l**+e,new yu(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ql:Ql**+e,new yu(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new yu(Cu(this.r),Cu(this.g),Cu(this.b),U(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:bu,formatHex:bu,formatHex8:xu,formatRgb:Su,toString:Su}));function bu(){return`#${wu(this.r)}${wu(this.g)}${wu(this.b)}`}function xu(){return`#${wu(this.r)}${wu(this.g)}${wu(this.b)}${wu((isNaN(this.opacity)?1:this.opacity)*255)}`}function Su(){let e=U(this.opacity);return`${e===1?`rgb(`:`rgba(`}${Cu(this.r)}, ${Cu(this.g)}, ${Cu(this.b)}${e===1?`)`:`, ${e})`}`}function U(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Cu(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function wu(e){return e=Cu(e),(e<16?`0`:``)+e.toString(16)}function Tu(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ou(e,t,n,r)}function Eu(e){if(e instanceof Ou)return new Ou(e.h,e.s,e.l,e.opacity);if(e instanceof Zl||(e=mu(e)),!e)return new Ou;if(e instanceof Ou)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Ou(o,s,c,e.opacity)}function Du(e,t,n,r){return arguments.length===1?Eu(e):new Ou(e,t,n,r??1)}function Ou(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Yl(Ou,Du,Xl(Zl,{brighter(e){return e=e==null?$l:$l**+e,new Ou(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ql:Ql**+e,new Ou(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new yu(ju(e>=240?e-240:e+120,i,r),ju(e,i,r),ju(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Ou(ku(this.h),Au(this.s),Au(this.l),U(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(){let e=U(this.opacity);return`${e===1?`hsl(`:`hsla(`}${ku(this.h)}, ${Au(this.s)*100}%, ${Au(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function ku(e){return e=(e||0)%360,e<0?e+360:e}function Au(e){return Math.max(0,Math.min(1,e||0))}function ju(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Mu=e=>()=>e;function Nu(e,t){return function(n){return e+n*t}}function Pu(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Fu(e){return(e=+e)==1?Iu:function(t,n){return n-t?Pu(t,n,e):Mu(isNaN(t)?n:t)}}function Iu(e,t){var n=t-e;return n?Nu(e,n):Mu(isNaN(e)?t:e)}var Lu=(function e(t){var n=Fu(t);function r(e,t){var r=n((e=vu(e)).r,(t=vu(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Iu(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Ru(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var zu=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Bu=new RegExp(zu.source,`g`);function Vu(e){return function(){return e}}function Hu(e){return function(t){return e(t)+``}}function Uu(e,t){var n=zu.lastIndex=Bu.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=zu.exec(e))&&(i=Bu.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Ru(r,i)})),n=Bu.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?Hu(c[0].x):Vu(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}var Wu=180/Math.PI,Gu={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ku(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*Wu,skewX:Math.atan(c)*Wu,scaleX:o,scaleY:s}}var qu;function Ju(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?Gu:Ku(t.a,t.b,t.c,t.d,t.e,t.f)}function Yu(e){return e==null||(qu||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),qu.setAttribute(`transform`,e),!(e=qu.transform.baseVal.consolidate()))?Gu:(e=e.matrix,Ku(e.a,e.b,e.c,e.d,e.e,e.f))}function Xu(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:Ru(e,i)},{i:c-2,x:Ru(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Ru(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Ru(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Ru(e,n)},{i:s-2,x:Ru(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Zu=Xu(Ju,`px, `,`px)`,`deg)`),Qu=Xu(Yu,`, `,`)`,`)`),$u=1e-12;function ed(e){return((e=Math.exp(e))+1/e)/2}function td(e){return((e=Math.exp(e))-1/e)/2}function W(e){return((e=Math.exp(2*e))-1)/(e+1)}var G=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<$u)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=ed(y),c=s/(n*g)*(i*W(t*r+y)-td(y));return[a+c*d,o+c*f,s*i/ed(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),K=0,q=0,J=0,nd=1e3,rd,id,ad=0,od=0,Y=0,sd=typeof performance==`object`&&performance.now?performance:Date,cd=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ld(){return od||=(cd(ud),sd.now()+Y)}function ud(){od=0}function dd(){this._call=this._time=this._next=null}dd.prototype=fd.prototype={constructor:dd,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?ld():+n)+(t==null?0:+t),!this._next&&id!==this&&(id?id._next=this:rd=this,id=this),this._call=e,this._time=n,_d()},stop:function(){this._call&&(this._call=null,this._time=1/0,_d())}};function fd(e,t,n){var r=new dd;return r.restart(e,t,n),r}function pd(){ld(),++K;for(var e=rd,t;e;)(t=od-e._time)>=0&&e._call.call(void 0,t),e=e._next;--K}function md(){od=(ad=sd.now())+Y,K=q=0;try{pd()}finally{K=0,gd(),od=0}}function hd(){var e=sd.now(),t=e-ad;t>nd&&(Y-=t,ad=e)}function gd(){for(var e,t=rd,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:rd=n);id=e,_d(r)}function _d(e){K||(q&&=clearTimeout(q),e-od>24?(e<1/0&&(q=setTimeout(md,e-sd.now()-Y)),J&&=clearInterval(J)):(J||=(ad=sd.now(),setInterval(hd,nd)),K=1,cd(md)))}function vd(e,t,n){var r=new dd;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var yd=Bl(`start`,`end`,`cancel`,`interrupt`),X=[];function bd(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;wd(e,n,{name:t,index:r,group:i,on:yd,tween:X,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function xd(e,t){var n=Cd(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Sd(e,t){var n=Cd(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Cd(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function wd(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=fd(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return vd(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(vd(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function Td(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n)(r=n[o]).name===t?(i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]):a=!1;a&&delete e.__transition}}function Ed(e){return this.each(function(){Td(this,e)})}function Dd(e,t){var n,r;return function(){var i=Sd(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Od(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=Sd(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function kd(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=Cd(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Dd:Od)(n,e,t))}function Ad(e,t,n){var r=e._id;return e.each(function(){var e=Sd(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return Cd(e,r).value[t]}}function jd(e,t){var n;return(typeof t==`number`?Ru:t instanceof mu?Lu:(n=mu(t))?(t=n,Lu):Uu)(e,t)}function Md(e){return function(){this.removeAttribute(e)}}function Nd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pd(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function Fd(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function Id(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Ld(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Rd(e,t){var n=Bs(e),r=n===`transform`?Qu:jd;return this.attrTween(e,typeof t==`function`?(n.local?Ld:Id)(n,r,Ad(this,`attr.`+e,t)):t==null?(n.local?Nd:Md)(n):(n.local?Fd:Pd)(n,r,t))}function zd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Bd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Vd(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Bd(e,i)),n}return i._value=t,i}function Hd(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&zd(e,i)),n}return i._value=t,i}function Ud(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=Bs(e);return this.tween(n,(r.local?Vd:Hd)(r,t))}function Wd(e,t){return function(){xd(this,e).delay=+t.apply(this,arguments)}}function Gd(e,t){return t=+t,function(){xd(this,e).delay=t}}function Kd(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Wd:Gd)(t,e)):Cd(this.node(),t).delay}function qd(e,t){return function(){Sd(this,e).duration=+t.apply(this,arguments)}}function Jd(e,t){return t=+t,function(){Sd(this,e).duration=t}}function Yd(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?qd:Jd)(t,e)):Cd(this.node(),t).duration}function Xd(e,t){if(typeof t!=`function`)throw Error();return function(){Sd(this,e).ease=t}}function Zd(e){var t=this._id;return arguments.length?this.each(Xd(t,e)):Cd(this.node(),t).ease}function Qd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();Sd(this,e).ease=n}}function $d(e){if(typeof e!=`function`)throw Error();return this.each(Qd(this._id,e))}function ef(e){typeof e!=`function`&&(e=Qs(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new kf(r,this._parents,this._name,this._id)}function tf(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new kf(o,this._parents,this._name,this._id)}function nf(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function rf(e,t,n){var r,i,a=nf(t)?xd:Sd;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function af(e,t){var n=this._id;return arguments.length<2?Cd(this.node(),n).on.on(e):this.each(rf(n,e,t))}function of(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function sf(){return this.on(`end.remove`,of(this._id))}function cf(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Gs(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,bd(l[f],t,n,f,l,Cd(u,n)));return new kf(a,this._parents,t,n)}function lf(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ys(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=Cd(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&bd(p,t,n,h,f,m);a.push(f),o.push(u)}return new kf(a,o,t,n)}var uf=Pl.prototype.constructor;function df(){return new uf(this._groups,this._parents)}function ff(e,t){var n,r,i;return function(){var a=Hc(this,e),o=(this.style.removeProperty(e),Hc(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function pf(e){return function(){this.style.removeProperty(e)}}function Z(e,t,n){var r,i=n+``,a;return function(){var o=Hc(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function mf(e,t,n){var r,i,a;return function(){var o=Hc(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),Hc(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function hf(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=Sd(this,e),l=c.on,u=c.value[a]==null?s||=pf(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function gf(e,t,n){var r=(e+=``)==`transform`?Zu:jd;return t==null?this.styleTween(e,ff(e,r)).on(`end.style.`+e,pf(e)):typeof t==`function`?this.styleTween(e,mf(e,r,Ad(this,`style.`+e,t))).each(hf(this._id,e)):this.styleTween(e,Z(e,r,t),n).on(`end.style.`+e,null)}function _f(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function vf(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&_f(e,a,n)),r}return a._value=t,a}function yf(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,vf(e,t,n??``))}function bf(e){return function(){this.textContent=e}}function xf(e){return function(){var t=e(this);this.textContent=t??``}}function Sf(e){return this.tween(`text`,typeof e==`function`?xf(Ad(this,`text`,e)):bf(e==null?``:e+``))}function Cf(e){return function(t){this.textContent=e.call(this,t)}}function wf(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Cf(r)),t}return r._value=e,r}function Tf(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,wf(e))}function Ef(){for(var e=this._name,t=this._id,n=Af(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=Cd(c,t);bd(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new kf(r,this._parents,e,n)}function Df(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=Sd(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Of=0;function kf(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Af(){return++Of}var jf=Pl.prototype;kf.prototype={constructor:kf,select:cf,selectAll:lf,selectChild:jf.selectChild,selectChildren:jf.selectChildren,filter:ef,merge:tf,selection:df,transition:Ef,call:jf.call,nodes:jf.nodes,node:jf.node,size:jf.size,empty:jf.empty,each:jf.each,on:af,attr:Rd,attrTween:Ud,style:gf,styleTween:yf,text:Sf,textTween:Tf,remove:sf,tween:kd,delay:Kd,duration:Yd,ease:Zd,easeVarying:$d,end:Df,[Symbol.iterator]:jf[Symbol.iterator]};function Mf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Nf={time:null,delay:0,duration:250,ease:Mf};function Pf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function Ff(e){var t,n;e instanceof kf?(t=e._id,e=e._name):(t=Af(),(n=Nf).time=ld(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&bd(c,e,t,l,o,n||Pf(c,t));return new kf(r,this._parents,e,t)}Pl.prototype.interrupt=Ed,Pl.prototype.transition=Ff;var If=e=>()=>e;function Lf(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Rf(e,t,n){this.k=e,this.x=t,this.y=n}Rf.prototype={constructor:Rf,scale:function(e){return e===1?this:new Rf(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Rf(this.k,this.x+this.k*e,this.y+this.k*t)},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 zf=new Rf(1,0,0);Bf.prototype=Rf.prototype;function Bf(e){for(;!e.__zoom;)if(!(e=e.parentNode))return zf;return e.__zoom}function Vf(e){e.stopImmediatePropagation()}function Q(e){e.preventDefault(),e.stopImmediatePropagation()}function Hf(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function Uf(){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 Wf(){return this.__zoom||zf}function Gf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Kf(){return navigator.maxTouchPoints||`ontouchstart`in this}function qf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function Jf(){var e=Hf,t=Uf,n=qf,r=Gf,i=Kf,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=G,l=Bl(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Wf).on(`wheel.zoom`,C,{passive:!1}).on(`mousedown.zoom`,w).on(`dblclick.zoom`,te).filter(i).on(`touchstart.zoom`,ne).on(`touchmove.zoom`,T).on(`touchend.zoom touchcancel.zoom`,re).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Wf),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(zf.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Rf(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Rf(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Rf(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new ee(e,t)}function ee(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}ee.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Il(this.that).datum();l.call(e,this.that,new Lf(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function C(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Rl(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Td(this),s.start();Q(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function w(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Il(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Rl(t,i),l=t.clientX,u=t.clientY;ql(t.view),Vf(t),a.mouse=[c,this.__zoom.invert(c)],Td(this),a.start();function d(e){if(Q(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Rl(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),Jl(e.view,a.moved),Q(e),a.event(e).end()}}function te(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Rl(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Q(r),s>0?Il(this).transition().duration(s).call(x,d,c,r):Il(this).call(_.transform,d,c,r)}}function ne(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(Vf(t),s=0;s<i;++s)c=r[s],l=Rl(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),Td(this),a.start())}}function T(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(Q(e),s=0;s<a;++s)c=i[s],l=Rl(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function re(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(Vf(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=Rl(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=Il(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:If(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:If(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:If(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:If([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}function Yf(e,t){var n,r=1;e??=0,t??=0;function i(){var i,a=n.length,o,s=0,c=0;for(i=0;i<a;++i)o=n[i],s+=o.x,c+=o.y;for(s=(s/a-e)*r,c=(c/a-t)*r,i=0;i<a;++i)o=n[i],o.x-=s,o.y-=c}return i.initialize=function(e){n=e},i.x=function(t){return arguments.length?(e=+t,i):e},i.y=function(e){return arguments.length?(t=+e,i):t},i.strength=function(e){return arguments.length?(r=+e,i):r},i}function Xf(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Zf(this.cover(t,n),t,n,e)}function Zf(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function Qf(e){var t,n,r=e.length,i,a,o=Array(r),s=Array(r),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(a=+this._y.call(null,t))||(o[n]=i,s[n]=a,i<c&&(c=i),i>u&&(u=i),a<l&&(l=a),a>d&&(d=a));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n<r;++n)Zf(this,o[n],s[n],e[n]);return this}function $f(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t<r)<<1|e<n,c=[,,,,],c[l]=s,s=c,o*=2,l){case 0:i=n+o,a=r+o;break;case 1:n=i-o,a=r+o;break;case 2:i=n+o,r=a-o;break;case 3:n=i-o,r=a-o}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=a,this}function ep(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function $(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function tp(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function np(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new tp(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)<i||(l=m.y1)<a)){if(p.length){var g=(o+c)/2,_=(s+l)/2;f.push(new tp(p[3],g,_,c,l),new tp(p[2],o,_,g,l),new tp(p[1],g,s,c,_),new tp(p[0],o,s,g,_)),(h=(t>=_)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var v=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=v*v+y*y;if(b<n){var x=Math.sqrt(n=b);i=e-x,a=t-x,u=e+x,d=t+x,r=p.data}}}return r}function rp(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function ip(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function ap(){return this._root}function op(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function sp(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new tp(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new tp(i,l,u,s,c)),(i=r[2])&&t.push(new tp(i,a,u,l,c)),(i=r[1])&&t.push(new tp(i,l,o,s,u)),(i=r[0])&&t.push(new tp(i,a,o,l,u))}return this}function cp(e){var t=[],n=[],r;for(this._root&&t.push(new tp(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new tp(a,o,s,u,d)),(a=i[1])&&t.push(new tp(a,u,s,c,d)),(a=i[2])&&t.push(new tp(a,o,d,u,l)),(a=i[3])&&t.push(new tp(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function lp(e){return e[0]}function up(e){return arguments.length?(this._x=e,this):this._x}function dp(e){return e[1]}function fp(e){return arguments.length?(this._y=e,this):this._y}function pp(e,t,n){var r=new mp(t??lp,n??dp,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function mp(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function hp(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var gp=pp.prototype=mp.prototype;gp.copy=function(){var e=new mp(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=hp(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=hp(r));return e},gp.add=Xf,gp.addAll=Qf,gp.cover=$f,gp.data=ep,gp.extent=$,gp.find=np,gp.remove=rp,gp.removeAll=ip,gp.root=ap,gp.size=op,gp.visit=sp,gp.visitAfter=cp,gp.x=up,gp.y=fp;function _p(e){return function(){return e}}function vp(e){return(e()-.5)*1e-6}function yp(e){return e.x+e.vx}function bp(e){return e.y+e.vy}function xp(e){var t,n,r,i=1,a=1;typeof e!=`function`&&(e=_p(e==null?1:+e));function o(){for(var e,o=t.length,c,l,u,d,f,p,m=0;m<a;++m)for(c=pp(t,yp,bp).visitAfter(s),e=0;e<o;++e)l=t[e],f=n[l.index],p=f*f,u=l.x+l.vx,d=l.y+l.vy,c.visit(h);function h(e,t,n,a,o){var s=e.data,c=e.r,m=f+c;if(s){if(s.index>l.index){var h=u-s.x-s.vx,g=d-s.y-s.vy,_=h*h+g*g;_<m*m&&(h===0&&(h=vp(r),_+=h*h),g===0&&(g=vp(r),_+=g*g),_=(m-(_=Math.sqrt(_)))/_*i,l.vx+=(h*=_)*(m=(c*=c)/(p+c)),l.vy+=(g*=_)*m,s.vx-=h*(m=1-m),s.vy-=g*m)}}else return t>u+m||a<u-m||n>d+m||o<d-m}}function s(e){if(e.data)return e.r=n[e.data.index];for(var t=e.r=0;t<4;++t)e[t]&&e[t].r>e.r&&(e.r=e[t].r)}function c(){if(t){var r,i=t.length,a;for(n=Array(i),r=0;r<i;++r)a=t[r],n[a.index]=+e(a,r,t)}}return o.initialize=function(e,n){t=e,r=n,c()},o.iterations=function(e){return arguments.length?(a=+e,o):a},o.strength=function(e){return arguments.length?(i=+e,o):i},o.radius=function(t){return arguments.length?(e=typeof t==`function`?t:_p(+t),c(),o):e},o}function Sp(e){return e.index}function Cp(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function wp(e){var t=Sp,n=d,r,i=_p(30),a,o,s,c,l,u=1;e??=[];function d(e){return 1/Math.min(s[e.source.index],s[e.target.index])}function f(t){for(var n=0,i=e.length;n<u;++n)for(var o=0,s,d,f,p,m,h,g;o<i;++o)s=e[o],d=s.source,f=s.target,p=f.x+f.vx-d.x-d.vx||vp(l),m=f.y+f.vy-d.y-d.vy||vp(l),h=Math.sqrt(p*p+m*m),h=(h-a[o])/h*t*r[o],p*=h,m*=h,f.vx-=p*(g=c[o]),f.vy-=m*g,d.vx+=p*(g=1-g),d.vy+=m*g}function p(){if(o){var n,i=o.length,l=e.length,u=new Map(o.map((e,n)=>[t(e,n,o),e])),d;for(n=0,s=Array(i);n<l;++n)d=e[n],d.index=n,typeof d.source!=`object`&&(d.source=Cp(u,d.source)),typeof d.target!=`object`&&(d.target=Cp(u,d.target)),s[d.source.index]=(s[d.source.index]||0)+1,s[d.target.index]=(s[d.target.index]||0)+1;for(n=0,c=Array(l);n<l;++n)d=e[n],c[n]=s[d.source.index]/(s[d.source.index]+s[d.target.index]);r=Array(l),m(),a=Array(l),h()}}function m(){if(o)for(var t=0,i=e.length;t<i;++t)r[t]=+n(e[t],t,e)}function h(){if(o)for(var t=0,n=e.length;t<n;++t)a[t]=+i(e[t],t,e)}return f.initialize=function(e,t){o=e,l=t,p()},f.links=function(t){return arguments.length?(e=t,p(),f):e},f.id=function(e){return arguments.length?(t=e,f):t},f.iterations=function(e){return arguments.length?(u=+e,f):u},f.strength=function(e){return arguments.length?(n=typeof e==`function`?e:_p(+e),m(),f):n},f.distance=function(e){return arguments.length?(i=typeof e==`function`?e:_p(+e),h(),f):i},f}var Tp=1664525,Ep=1013904223,Dp=4294967296;function Op(){let e=1;return()=>(e=(Tp*e+Ep)%Dp)/Dp}function kp(e){return e.x}function Ap(e){return e.y}var jp=10,Mp=Math.PI*(3-Math.sqrt(5));function Np(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=fd(d),l=Bl(`tick`,`end`),u=Op();e??=[];function d(){f(),l.call(`tick`,t),n<r&&(c.stop(),l.call(`end`,t))}function f(r){var c,l=e.length,u;r===void 0&&(r=1);for(var d=0;d<r;++d)for(n+=(a-n)*i,s.forEach(function(e){e(n)}),c=0;c<l;++c)u=e[c],u.fx==null?u.x+=u.vx*=o:(u.x=u.fx,u.vx=0),u.fy==null?u.y+=u.vy*=o:(u.y=u.fy,u.vy=0);return t}function p(){for(var t=0,n=e.length,r;t<n;++t){if(r=e[t],r.index=t,r.fx!=null&&(r.x=r.fx),r.fy!=null&&(r.y=r.fy),isNaN(r.x)||isNaN(r.y)){var i=jp*Math.sqrt(.5+t),a=t*Mp;r.x=i*Math.cos(a),r.y=i*Math.sin(a)}(isNaN(r.vx)||isNaN(r.vy))&&(r.vx=r.vy=0)}}function m(t){return t.initialize&&t.initialize(e,u),t}return p(),t={tick:f,restart:function(){return c.restart(d),t},stop:function(){return c.stop(),t},nodes:function(n){return arguments.length?(e=n,p(),s.forEach(m),t):e},alpha:function(e){return arguments.length?(n=+e,t):n},alphaMin:function(e){return arguments.length?(r=+e,t):r},alphaDecay:function(e){return arguments.length?(i=+e,t):+i},alphaTarget:function(e){return arguments.length?(a=+e,t):a},velocityDecay:function(e){return arguments.length?(o=1-e,t):1-o},randomSource:function(e){return arguments.length?(u=e,s.forEach(m),t):u},force:function(e,n){return arguments.length>1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i<a;++i)l=e[i],o=t-l.x,s=n-l.y,c=o*o+s*s,c<r&&(u=l,r=c);return u},on:function(e,n){return arguments.length>1?(l.on(e,n),t):l.on(e)}}}function Pp(){var e,t,n,r,i=_p(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=pp(e,kp,Ap).visitAfter(d);for(r=n,i=0;i<a;++i)t=e[i],o.visit(f)}function u(){if(e){var t,n=e.length,r;for(a=Array(n),t=0;t<n;++t)r=e[t],a[r.index]=+i(r,t,e)}}function d(e){var t=0,n,r,i=0,o,s,c;if(e.length){for(o=s=c=0;c<4;++c)(n=e[c])&&(r=Math.abs(n.value))&&(t+=n.value,i+=r,o+=r*n.x,s+=r*n.y);e.x=o/i,e.y=s/i}else{n=e,n.x=n.data.x,n.y=n.data.y;do t+=a[n.data.index];while(n=n.next)}e.value=t}function f(e,i,l,u){if(!e.value)return!0;var d=e.x-t.x,f=e.y-t.y,p=u-i,m=d*d+f*f;if(p*p/c<m)return m<s&&(d===0&&(d=vp(n),m+=d*d),f===0&&(f=vp(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)),t.vx+=d*e.value*r/m,t.vy+=f*e.value*r/m),!0;if(!(e.length||m>=s)){(e.data!==t||e.next)&&(d===0&&(d=vp(n),m+=d*d),f===0&&(f=vp(n),m+=f*f),m<o&&(m=Math.sqrt(o*m)));do e.data!==t&&(p=a[e.data.index]*r/m,t.vx+=d*p,t.vy+=f*p);while(e=e.next)}}return l.initialize=function(t,r){e=t,n=r,u()},l.strength=function(e){return arguments.length?(i=typeof e==`function`?e:_p(+e),u(),l):i},l.distanceMin=function(e){return arguments.length?(o=e*e,l):Math.sqrt(o)},l.distanceMax=function(e){return arguments.length?(s=e*e,l):Math.sqrt(s)},l.theta=function(e){return arguments.length?(c=e*e,l):Math.sqrt(c)},l}function Fp(e){var t=_p(.1),n,r,i;typeof e!=`function`&&(e=_p(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t<a;++t)o=n[t],o.vx+=(i[t]-o.x)*r[t]*e}function o(){if(n){var a,o=n.length;for(r=Array(o),i=Array(o),a=0;a<o;++a)r[a]=isNaN(i[a]=+e(n[a],a,n))?0:+t(n[a],a,n)}}return a.initialize=function(e){n=e,o()},a.strength=function(e){return arguments.length?(t=typeof e==`function`?e:_p(+e),o(),a):t},a.x=function(t){return arguments.length?(e=typeof t==`function`?t:_p(+t),o(),a):e},a}function Ip(e){var t=_p(.1),n,r,i;typeof e!=`function`&&(e=_p(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t<a;++t)o=n[t],o.vy+=(i[t]-o.y)*r[t]*e}function o(){if(n){var a,o=n.length;for(r=Array(o),i=Array(o),a=0;a<o;++a)r[a]=isNaN(i[a]=+e(n[a],a,n))?0:+t(n[a],a,n)}}return a.initialize=function(e){n=e,o()},a.strength=function(e){return arguments.length?(t=typeof e==`function`?e:_p(+e),o(),a):t},a.y=function(t){return arguments.length?(e=typeof t==`function`?t:_p(+t),o(),a):e},a}var Lp=e=>14+e.length*7,Rp=e=>e.kind===`channel`?Lp(e.label)/2+6:30;function zp(e){let t=e.nodes.map(e=>e.id).sort(),n=e.links.map(e=>`${e.source}\u0000${e.target}\u0000${e.kind}`).sort();return`${t.join(``)}\u0002${n.join(``)}`}var Bp=300,Vp=.5,Hp=20,Up=class{sim;links;bodies=new Map;key;size=``;width=0;height=0;constructor(e,t,n=1){this.links=wp([]).id(e=>e.id).strength(.4),this.sim=Np().force(`link`,this.links).force(`charge`,Pp()).force(`center`,Yf()).force(`x`,Fp()).force(`y`,Ip()).stop(),this.resize(e,t,n)}resize(e,t,n=1){let r=`${e}x${t}@${n}`;if(r===this.size)return!1;this.size=r,this.width=e,this.height=t;let i=Math.min(e,t)/n/420;return this.links.distance(90*i),this.sim.force(`charge`,Pp().strength(-280*i*i)).force(`center`,Yf(e/2,t/2)).force(`x`,Fp(e/2).strength(.04)).force(`y`,Ip(t/2).strength(.04)).force(`collide`,xp().radius(e=>e.r).iterations(n>1?3:1)),!0}sync(e){let t=zp(e);if(t===this.key)return!1;let n=new Map;for(let t of e.nodes)n.set(t.id,this.bodies.get(t.id)??{id:t.id,r:Rp(t)});return this.bodies=n,this.sim.nodes([...n.values()]),this.links.links(e.links.map(e=>({source:e.source,target:e.target}))),this.key=t,!0}warm(){this.sim.alpha(1);for(let e=0;e<Bp;e++)this.tick()}reheat(){this.sim.alpha(Math.max(this.sim.alpha(),Vp))}tick(){this.sim.tick();for(let e of this.bodies.values())e.x!==void 0&&(e.x=Math.min(Math.max(e.x,e.r),Math.max(e.r,this.width-e.r))),e.y!==void 0&&(e.y=Math.min(Math.max(e.y,e.r),this.height-e.r-Hp))}get settled(){return this.sim.alpha()<this.sim.alphaMin()}at(e){let t=this.bodies.get(e);return t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?{x:t.x,y:t.y}:void 0}},Wp={request:e=>globalThis.requestAnimationFrame(e),cancel:e=>globalThis.cancelAnimationFrame(e)};function Gp(e,t,n){return[`ui-tl`,`ui-tl-${e}`,n?`ui-tl-off`:``,t?`ui-tl-hot`:``].filter(Boolean).join(` `)}function Kp({status:e,x:t,y:n}){return(0,P.jsxs)(`g`,{className:`ui-tst ui-tst-${e}`,"aria-hidden":`true`,children:[e===`working`&&(0,P.jsx)(`circle`,{cx:t,cy:n,r:5}),e===`waiting`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`circle`,{cx:t,cy:n,r:5,className:`ui-tst-bg`}),(0,P.jsx)(`path`,{d:`M${t} ${n-4.2} A4.2 4.2 0 0 0 ${t} ${n+4.2} Z`}),(0,P.jsx)(`circle`,{cx:t,cy:n,r:4.2,className:`ui-tst-ring`})]}),(e===`idle`||e===`offline`)&&(0,P.jsx)(`circle`,{cx:t,cy:n,r:4.4})]})}function qp({r:e}){let t=2*Math.PI*e;return(0,P.jsxs)(`g`,{className:`ui-orbit-g`,"aria-hidden":`true`,children:[(0,P.jsx)(`circle`,{r:e,className:`ui-orbit-ring`}),(0,P.jsx)(`circle`,{r:e,className:`ui-orbit`,strokeDasharray:`${t/5} ${t*4/5}`})]})}function Jp({node:e,x:t,y:n,size:r,showName:i}){let a=e.status??`idle`,o=(0,N.useContext)(Se),s=ae()(e.id),c=r*.23,l=-r/2+c-3,u=r/2-c+2,d=s&&(0,P.jsxs)(`g`,{className:`ui-tidb`,"aria-hidden":`true`,children:[(0,P.jsx)(`circle`,{cx:l,cy:u,r:c,style:{fill:`var(--id-${a===`offline`?`off`:s.slot})`}}),(0,P.jsx)(`text`,{x:l,y:u+c*.42,textAnchor:`middle`,fontSize:[...s.letter].length>1?c*.95:c*1.2,children:s.letter})]});return(0,P.jsxs)(`g`,{className:a===`offline`?`ui-ta ui-ta-off`:`ui-ta`,"data-node":e.id,"data-pick":o?``:void 0,transform:`translate(${t} ${n})`,onClick:o?()=>o(e.id):void 0,children:[!i&&(0,P.jsx)(`title`,{children:e.label}),a===`working`&&(0,P.jsx)(qp,{r:r/2+7}),(0,P.jsxs)(`g`,{className:`ui-ta-art`,children:[(0,P.jsx)(`svg`,{x:-r/2,y:-r/2,width:r,height:r,viewBox:`-2 -4 112 112`,overflow:`visible`,dangerouslySetInnerHTML:{__html:Ne(e.vendor,a)}}),i&&(0,P.jsx)(`text`,{y:r/2+13,textAnchor:`middle`,className:`ui-ta-name`,children:e.label}),e.wide&&(0,P.jsxs)(`g`,{className:`ui-wide`,transform:`translate(0 ${r/2+26})`,children:[(0,P.jsx)(`rect`,{x:-70.4/2,y:-8,width:70.4,height:16,rx:6}),(0,P.jsx)(`text`,{y:3.5,textAnchor:`middle`,children:`all channels`})]})]}),d,(0,P.jsx)(Kp,{status:a,x:r/2-2,y:r/2-1})]})}function Yp({node:e,x:t,y:n,hot:r}){let i=Lp(e.label);return(0,P.jsxs)(`g`,{className:r?`ui-tn ui-tn-hot`:`ui-tn`,"data-node":e.id,transform:`translate(${t} ${n})`,children:[(0,P.jsx)(`rect`,{x:-i/2,y:-12,width:i,height:24,rx:8}),(0,P.jsxs)(`text`,{y:4,textAnchor:`middle`,children:[`#`,e.label]})]})}function Xp({model:e,width:t=400,height:n=420,drawingScale:r=1}){let i=t*r,a=n*r,o=(0,N.useRef)(null);o.current===null&&(o.current=new Up(i,a,r),o.current.sync(e),o.current.warm());let s=o.current,[,c]=(0,N.useReducer)(e=>e+1,0),l=(0,N.useRef)(0),u=()=>{if(l.current!==0||s.settled)return;let e=()=>{l.current=0,s.tick(),c(),s.settled||(l.current=Wp.request(e))};l.current=Wp.request(e)};(0,N.useEffect)(()=>{s.resize(i,a,r)&&s.reheat(),s.sync(e)&&s.reheat(),u()}),(0,N.useEffect)(()=>()=>{Wp.cancel(l.current),l.current=0},[]);let d=(0,N.useRef)(null),[f,p]=(0,N.useState)(zf);(0,N.useEffect)(()=>{let e=d.current;return Il(e).call(Jf().scaleExtent([.4,4]).on(`zoom`,e=>p(e.transform))),()=>void Il(e).on(`.zoom`,null)},[]);let m=e=>s.at(e)??{x:i/2,y:a/2},h=new Map(e.nodes.map(e=>[e.id,e])),g=new Set(e.links.filter(e=>e.hot).map(e=>e.target)),_=Math.min(40,t/10);return(0,P.jsx)(`svg`,{ref:d,className:`ui-topo-svg`,viewBox:`0 0 ${i} ${a}`,role:`img`,"aria-label":`Mesh topology`,children:(0,P.jsxs)(`g`,{transform:`translate(${f.x} ${f.y}) scale(${f.k})`,children:[e.links.map(e=>{let t=m(e.source),n=m(e.target);return(0,P.jsx)(`line`,{"data-link":`${e.source}>${e.target}`,className:Gp(e.kind,e.hot,h.get(e.source)?.status===`offline`),x1:t.x,y1:t.y,x2:n.x,y2:n.y},`${e.source}\u0000${e.target}`)}),e.nodes.filter(e=>e.kind===`channel`).map(e=>(0,P.jsx)(Yp,{node:e,...m(e.id),hot:g.has(e.id)},e.id)),e.nodes.filter(e=>e.kind===`agent`).map(e=>(0,P.jsx)(Jp,{node:e,...m(e.id),size:_,showName:r===1},e.id))]})})}var Zp=e=>`#${e}`;function Qp(e){let{roster:t,channels:n,membership:r,recent:i,hideOffline:a,hideEmpty:o,now:s}=e,c=Tn(t),l=new Map;for(let e of t){if(e.card.kind===`endpoint`||!e.card.id)continue;let t=e.card.meta?.connector;l.set(e.card.id,{id:e.card.id,kind:`agent`,label:e.card.name.trim()?e.card.name:e.card.id,...typeof t==`string`?{vendor:t}:{},status:e.status})}let u=new Set(n.map(e=>e.channel)),d=i.filter(e=>e.mode===`chat`&&e.channel).map(e=>({channel:e.channel,sender:e.senderId??e.msg.from.id,ts:e.ts}));for(let e of d)u.add(e.channel);let f=(r.unreadable===void 0?r.snapshot?.members??[]:[]).filter(e=>e.id);for(let e of f)for(let t of je(e.live??[],e.durable??[],[]).channels.keys())u.add(t);let p=new Set,m=new Map,h=(e,t)=>`${e}\u0000${t}`,g=[...u],_=n.filter(e=>e.deliveryClass===`durable`).map(e=>e.channel);for(let e of f){l.has(e.id)||l.set(e.id,{id:e.id,kind:`agent`,label:Zt(e.id,c),status:`offline`});let t=je(e.live??[],e.durable??[],g,_);t.wide&&p.add(e.id);for(let[n,r]of t.channels)m.set(h(e.id,n),{source:e.id,target:Zp(n),kind:r===`live`?`member`:`durable`,hot:!1})}for(let e of d){if(!e.sender)continue;l.has(e.sender)||l.set(e.sender,{id:e.sender,kind:`agent`,label:Zt(e.sender,c),status:`idle`});let t=h(e.sender,e.channel);m.has(t)||m.set(t,{source:e.sender,target:Zp(e.channel),kind:`traffic`,hot:!1})}for(let[e,t]of l)p.has(e)&&(t.wide=!0);for(let e of d)if(!(!e.sender||s-e.ts>=2e3))for(let t of m.values())t.target===Zp(e.channel)&&(t.hot=!0);let v=e=>l.get(e)?.status===`offline`,y=e=>a&&(e.kind===`durable`||v(e.source)),b=new Set;for(let e of m.values())e.kind!==`traffic`&&!y(e)&&b.add(e.target);let x=rt(r),S=e=>o&&x&&!b.has(Zp(e)),ee=[...l.values()].filter(e=>!(a&&e.status===`offline`));for(let e of u)S(e)||ee.push({id:Zp(e),kind:`channel`,label:e});let C=new Set(ee.map(e=>e.id));return{nodes:ee,links:[...m.values()].filter(e=>C.has(e.source)&&C.has(e.target)&&!(e.kind!==`traffic`&&y(e)))}}var $p=[{cls:`ui-lg-member`,label:`Member`},{cls:`ui-lg-durable`,label:`Durable member`},{cls:`ui-lg-offline`,label:`Offline agent`},{cls:`ui-lg-traffic`,label:`Posted here`},{cls:`ui-lg-hot`,label:`Active now`},{cls:`ui-lg-working`,label:`Working`}];function em(e,t,n){let r=A(e,e=>e.roster),i=A(e,e=>e.channels),a=A(e,e=>e.membership),o=A(e,e=>e.activity),[s,c]=(0,N.useState)(n),l=(0,N.useMemo)(()=>o.map(e=>({mode:e.mode,...`channel`in e&&e.channel!==void 0?{channel:e.channel}:{},...`senderId`in e&&e.senderId!==void 0?{senderId:e.senderId}:{},msg:e.msg,ts:e.arrivedAt??-1/0})),[o]),u=t(),d=Qp({roster:r,channels:i,membership:a,recent:l,hideOffline:s,hideEmpty:!0,now:u}),f=d.links.some(e=>e.hot),[,p]=(0,N.useReducer)(e=>e+1,0);return(0,N.useEffect)(()=>{let e=setInterval(p,f?500:5e3);return()=>clearInterval(e)},[f]),{model:d,membership:a,now:u,hideOffline:s,setHideOffline:c}}function tm({store:e,clock:t=Date.now,initialHideOffline:r=!0}){let{model:i,membership:a,now:o,hideOffline:s,setHideOffline:c}=em(e,t,r),l=Math.max(1,Math.sqrt(i.nodes.length/60));return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`header`,{className:`ui-bar`,children:[(0,P.jsx)(An,{}),(0,P.jsx)(`h1`,{children:`Topology`}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsx)(Ss,{state:n(a,o),reason:a.unreadable}),(0,P.jsx)(Be,{variant:`outline`,size:`sm`,pressed:s,onPressedChange:c,children:`Hide offline`})]}),(0,P.jsx)(`div`,{className:`ui-scroll`,children:(0,P.jsxs)(`div`,{className:`ui-col ui-col-wide`,children:[(0,P.jsx)(`div`,{className:`ui-topo`,children:(0,P.jsx)(Xp,{model:i,width:960,height:600,drawingScale:l})}),(0,P.jsxs)(`div`,{className:`ui-legend`,children:[$p.map(e=>(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`i`,{className:e.cls}),e.label]},e.cls)),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`b`,{className:`ui-wide-key`,children:`all channels`}),`Reads every channel`]})]})]})})]})}var nm={width:360,height:420};function rm({store:e,clock:t}){let{model:r,membership:i,now:a,hideOffline:o,setHideOffline:s}=em(e,t,!0);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,marginBottom:10},children:[(0,P.jsx)(Ss,{state:n(i,a),reason:i.unreadable}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsx)(Be,{variant:`outline`,size:`sm`,pressed:o,onPressedChange:s,children:`Hide offline`})]}),(0,P.jsx)(`div`,{className:`ui-topo`,children:(0,P.jsx)(Xp,{model:r,width:nm.width,height:nm.height})})]})}var im=`cotal.panel.open`;function am(){try{let e=globalThis.localStorage?.getItem(im);return e===`1`||e!==`0`&&void 0}catch{return}}function om(e){try{globalThis.localStorage?.setItem(im,e?`1`:`0`)}catch{}}var sm=e=>e.view===`agent`?`agent`:e.view===`channel`?`members`:`topology`;function cm(e,t=!1){let n=It(e),[r,i]=(0,N.useState)(!0),[a,o]=(0,N.useState)(!1),s=(0,N.useRef)(t);s.current=t,(0,N.useLayoutEffect)(()=>{let e=am();e!==void 0&&i(e)},[]);let[c,l]=(0,N.useState)(()=>({key:n,tab:sm(e),agent:e.view===`agent`?e.id:null})),u=c;c.key!==n&&(u={key:n,tab:sm(e),agent:e.view===`channel`?c.agent:null},e.view===`agent`&&(u={...u,agent:e.id}),l(u),o(!1));let d=(0,N.useMemo)(()=>{let e=e=>{if(s.current)return o(e);i(e),om(e)};return{setTab:e=>l(t=>({...t,tab:e})),selectAgent:t=>{l(e=>({...e,tab:`agent`,agent:t})),e(!0)},showMembers:()=>{l(e=>({...e,tab:`members`})),e(!0)},close:()=>e(!1),remember:e}},[]),f=t?a:r;return{open:f,tab:u.tab,agent:u.agent,setTab:d.setTab,selectAgent:d.selectAgent,showMembers:d.showMembers,close:d.close,toggle:()=>d.remember(!f)}}var lm=(e,t)=>e.open&&(t||e.agent!==null);function um({store:e,controller:t,channel:n,route:r,panel:i,clock:a}){let o=[{id:`members`,label:`Members`,off:n===null},{id:`agent`,label:`Agent`,off:i.agent===null},{id:`topology`,label:`Topology`,off:!1}];return(0,P.jsxs)(_t,{value:i.tab,onValueChange:e=>(e===`members`||e===`agent`||e===`topology`)&&i.setTab(e),className:`min-h-0 flex-1 gap-0`,children:[(0,P.jsxs)(`div`,{className:`ui-tabs`,children:[(0,P.jsx)(Cn,{"aria-label":`Details`,children:o.map(e=>(0,P.jsx)(xt,{value:e.id,disabled:e.off,children:e.label},e.id))}),(0,P.jsx)(`span`,{className:`ui-sp`}),(0,P.jsxs)(Ye,{children:[(0,P.jsx)(Qe,{asChild:!0,children:(0,P.jsx)(St,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close panel`,onClick:i.close,children:(0,P.jsx)(M,{icon:an})})}),(0,P.jsx)(E,{children:`Close panel`})]})]}),(0,P.jsx)(Xt,{value:`members`,className:`ui-pane-body`,children:n!==null&&(0,P.jsx)(Rs,{store:e,controller:t,channel:n,now:a(),onPick:i.selectAgent})}),(0,P.jsx)(Xt,{value:`agent`,className:`ui-pane-body`,children:i.agent!==null&&(0,P.jsx)(bs,{store:e,controller:t,id:i.agent,route:r})}),(0,P.jsx)(Xt,{value:`topology`,className:`ui-pane-body`,children:(0,P.jsx)(rm,{store:e,clock:a})})]})}var dm;function fm(){return Ue(()=>import(`./AgentPage-SDUlr64A.js`).then(e=>dm=e),__vite__mapDeps([0,1,2]))}var pm=(0,N.lazy)(()=>{let e=dm;return e?{then:t=>t({default:e.AgentPage})}:fm().then(e=>({default:e.AgentPage}))});function mm({store:e}){let t=br(A(e,e=>e.orderNotes));return(0,P.jsx)(`div`,{children:t&&(0,P.jsx)(`p`,{id:`order-notice`,role:t.fault?`alert`:`status`,children:t.text})})}function hm(e,t,n,r,i,a,o){switch(t.view){case`channel`:return(0,P.jsx)(es,{store:e,channel:t.channel,onMembers:r.showMembers,onViewAgent:r.selectAgent,panelOpen:i,onTogglePanel:r.toggle});case`activity`:return(0,P.jsx)(Ao,{store:e});case`dm`:return(0,P.jsx)(ts,{store:e,peer:t.peer,with:t.with});case`topology`:return(0,P.jsx)(tm,{store:e,clock:n});case`agents`:return(0,P.jsx)(hs,{store:e,controller:o.controller,group:t.group===`host`?`host`:void 0,selected:r.agent,onPick:a,clock:n});case`needs`:return(0,P.jsx)(hs,{store:e,controller:o.controller,group:`status`,focusWaiting:!0,selected:r.agent,onPick:a,clock:n});case`agent`:return(0,P.jsx)(N.Suspense,{fallback:(0,P.jsx)(fo,{}),children:(0,P.jsx)(pm,{store:e,controller:o.controller,id:t.id,tab:t.tab,at:t.at,back:o.back,phone:o.phone,panelOpen:o.panelOpen,onTogglePanel:o.toggle},t.id)})}}function gm({store:e,controller:t,route:n,paneOpen:r,msgPerSecond:i,clock:a=Date.now,phone:o=!1,panelSheet:s=o}){let c=A(e,e=>e.space),l=A(e,e=>e.channels),u=A(e,e=>e.roster),d=A(e,e=>e.dms),f=A(e,e=>e.loading),p=_m(n,l,d,u,A(e,e=>e.operatorId)),m=(0,N.useMemo)(()=>hn(u,{includeOffline:!0}),[u]),h=(0,N.useMemo)(()=>dt(m).length,[m]),g=(0,N.useMemo)(()=>u.filter(e=>e.card.kind===`agent`&&e.status===`working`).length,[u]),_=A(e,e=>e.stale.some(e=>e.name===`roster`)),v=(0,N.useMemo)(()=>S(m),[m]),y=cm(n,s),b=lm(y,r),x={...y,agent:b&&y.tab===`agent`?y.agent:null},ee=ym(n),C=(0,N.useContext)(mn),w=(0,N.useMemo)(()=>o?e=>C({view:`agent`,id:e,tab:`work`}):y.selectAgent,[o,C,y.selectAgent]),te={controller:t,phone:o,back:ee,panelOpen:b,toggle:y.toggle},ne=f.roster||f.channels?(0,P.jsx)(fo,{}):hm(e,n,a,x,b,w,te),T=(0,P.jsx)(um,{store:e,controller:t,channel:n.view===`channel`?n.channel:null,route:n,panel:y,clock:a});return(0,P.jsx)(Sn.Provider,{value:t,children:(0,P.jsx)(Se.Provider,{value:w,children:(0,P.jsx)(k.Provider,{value:v,children:(0,P.jsx)(Ke,{children:(0,P.jsxs)($a,{route:n,controller:t,paneOpen:b,panel:T,places:p,phone:o,panelSheet:s,waiting:h,working:g,stale:_,onPanelClose:y.close,sidebar:(0,P.jsx)(bo,{store:e,route:n,msgPerSecond:i}),children:[(0,P.jsx)(`title`,{children:xr(c)}),(0,P.jsx)(mm,{store:e}),(0,P.jsx)(`section`,{className:`ui-view`,"data-view":n.view,children:ne})]})})})})})}function _m(e,t,n,r,i){let[a,o]=(0,N.useState)({channel:null,dm:null}),s=a;e.view===`channel`&&a.channel!==e.channel&&(s={...a,channel:e.channel}),e.view===`dm`&&(a.dm?.peer!==e.peer||a.dm?.with!==e.with)&&(s={...s,dm:{peer:e.peer,with:e.with}}),s!==a&&o(s);let c=(0,N.useMemo)(()=>vn(n,r),[n,r]),l=s.channel!==null&&t.some(e=>e.channel===s.channel)?s.channel:t[0]?.channel??null,u=s.dm===null?null:s.dm.with??i,d=c[0]?.conversations[0];return{channel:l,dm:s.dm!==null&&u!==null&&c.some(e=>e.id===s.dm?.peer)?{peer:s.dm.peer,with:u}:c[0]&&d?{peer:c[0].id,with:d.with}:null}}function vm(e){switch(e.view){case`channel`:return`#${e.channel}`;case`activity`:return`Activity`;case`dm`:return`Direct messages`;case`topology`:return`Topology`;case`needs`:return`Needs you`;case`agents`:case`agent`:return`Agents`}}function ym(e){let[t,n]=(0,N.useState)(null);e.view!==`agent`&&(t===null||It(t)!==It(e))&&n(e);let r=e.view===`agent`?t:e;return r===null?{label:`Agents`,route:{view:`agents`,group:`status`}}:{label:vm(r),route:r}}var bm=5e3,xm=6e4,Sm={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)},Cm=e=>e.stale.some(e=>e.kind===`refused`&&e.name!==`roster`);function wm(e){let{store:t}=e,n=e.timer??Sm;t.set({loading:{roster:!0,channels:!0}});let r=tn(t,e.api),i=()=>{r.refresh().catch(e=>console.error(`dashboard refresh failed:`,e))},a=!1,o=e=>{a||t.set({connection:e?`session-invalid`:`closed`})},s={open(){t.set({connection:`connected`}),i()},error:()=>t.set(e=>e.connection===`closed`||e.connection===`session-invalid`?{}:{connection:e.connection===`connecting`?`connecting`:`reconnecting`}),closed(e){e?e.then(o):o(!1)},roster:r.onRoster,presenceView:r.onPresenceView,membership:r.onMembership,membershipFailed:r.onMembershipFailed,message(t){e.onArrival?.(),r.onMessage(t)},hello:r.onHello,agentFrame:r.onAgentFrame},{error:c,closed:l}=s;s.error=()=>{r.onFeedLost(),c()},s.closed=e=>{r.onFeedLost(),l(e)};let u=null,d=bm,f=t.subscribe(()=>{Cm(t.get())?u===null&&(u=n.set(()=>{u=null,d=Math.min(d*2,xm),i()},d)):(u!==null&&n.clear(u),u=null,d=bm)}),p=e.openFeed(s);return i(),{controller:r,stop(){a=!0,f(),u!==null&&n.clear(u),u=null,p()}}}function Tm(e){let t=e,n=new Set;return{get:()=>t,set(e){let r=typeof e==`function`?e(t):e;t={...t,...r};for(let e of n)e()},subscribe(e){return n.add(e),()=>n.delete(e)}}}var Em=Tm({space:null,connection:`connecting`,roster:[],presenceView:null,channels:[],unread:{},activity:[],dms:[],dmsCut:!1,open:null,stale:[],orderNotes:[],membership:{},loading:{roster:!1,channels:!1},post:null,channelDeleteSupported:!1,operatorId:null,drafts:{},sessions:{}}),Dm=1e4,Om=(e,t)=>{let n=wm({store:e,api:Xn(),openFeed:er,onArrival:t}),r=setInterval(()=>{let{connection:t,stale:r}=e.get();t===`connected`&&!r.some(e=>e.name===`channels`)&&n.controller.refreshChannels().catch(e=>console.error(`dashboard refresh failed:`,e))},5e3);return{controller:n.controller,stop:()=>{clearInterval(r),n.stop()}}};function km({host:e=window,start:t=Om,clock:n=Date.now}){let[r,i]=(0,N.useState)(null),[a]=(0,N.useState)(()=>fr(Dm,n()));(0,N.useLayoutEffect)(()=>{let e=t(Em,()=>a.hit(n()));return i(e.controller),e.stop},[t,a,n]);let[o,s]=(0,N.useState)(()=>Ct(e));(0,N.useEffect)(()=>en(e,s),[e]),(0,N.useEffect)(()=>un(e,o),[e,o]);let c=(0,N.useCallback)(t=>kt(e,t),[e]),l=me(),[u,d]=(0,N.useState)(!1);return(0,N.useLayoutEffect)(()=>{let e=window.matchMedia(`(width < 1200px)`),t=()=>d(e.matches);return e.addEventListener(`change`,t),t(),()=>e.removeEventListener(`change`,t)},[]),(0,P.jsx)(Ha,{defaultTheme:`system`,storageKey:`cotal.theme`,children:(0,P.jsx)(mn.Provider,{value:c,children:(0,P.jsx)(gm,{store:Em,controller:r,route:o,paneOpen:o.view===`channel`||o.view===`agent`,msgPerSecond:()=>a.perSecond(n()),phone:l,panelSheet:u})})})}var Am=document.getElementById(`root`);if(!Am)throw Error(`index.html has no #root element`);(0,Jn.createRoot)(Am).render((0,P.jsx)(N.StrictMode,{children:(0,P.jsx)(km,{})}));
|
package/dist/web/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
8
|
<title>Cotal</title>
|
|
9
9
|
<link rel="icon" type="image/svg+xml" href="/assets/cotal-mark-CM9Rw-dM.svg" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-CucdhhAW.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/controller-CW9ts98G.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-Ch6waaa2.css">
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cotal-ai/web",
|
|
3
3
|
"description": "Cotal browser observability dashboard as an owned service preset.",
|
|
4
|
-
"version": "0.182.
|
|
4
|
+
"version": "0.182.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@cotal-ai/workspace": "*"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@cotal-ai/core": "0.182.
|
|
28
|
+
"@cotal-ai/core": "0.182.1",
|
|
29
29
|
"@cotal-ai/smoke-kit": "0.0.0",
|
|
30
|
-
"@cotal-ai/workspace": "0.182.
|
|
30
|
+
"@cotal-ai/workspace": "0.182.1",
|
|
31
31
|
"@fontsource-variable/inter": "^5.3.0",
|
|
32
32
|
"@hugeicons/core-free-icons": "^4.3.5",
|
|
33
33
|
"@hugeicons/react": "^1.1.10",
|