@openscout/scout 0.2.65 → 0.2.69

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.
@@ -0,0 +1,186 @@
1
+ function d4(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const r in a)if(r!=="default"&&!(r in e)){const o=Object.getOwnPropertyDescriptor(a,r);o&&Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>a[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();function JM(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xy={exports:{}},Tu={};var rS;function f4(){if(rS)return Tu;rS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,r,o){var c=null;if(o!==void 0&&(c=""+o),r.key!==void 0&&(c=""+r.key),"key"in r){o={};for(var u in r)u!=="key"&&(o[u]=r[u])}else o=r;return r=o.ref,{$$typeof:e,type:a,key:c,ref:r!==void 0?r:null,props:o}}return Tu.Fragment=t,Tu.jsx=n,Tu.jsxs=n,Tu}var iS;function h4(){return iS||(iS=1,xy.exports=f4()),xy.exports}var s=h4(),by={exports:{}},mt={};var oS;function m4(){if(oS)return mt;oS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),y=Symbol.iterator;function x(L){return L===null||typeof L!="object"?null:(L=y&&L[y]||L["@@iterator"],typeof L=="function"?L:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,T={};function E(L,q,K){this.props=L,this.context=q,this.refs=T,this.updater=K||w}E.prototype.isReactComponent={},E.prototype.setState=function(L,q){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,q,"setState")},E.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function S(){}S.prototype=E.prototype;function k(L,q,K){this.props=L,this.context=q,this.refs=T,this.updater=K||w}var N=k.prototype=new S;N.constructor=k,C(N,E.prototype),N.isPureReactComponent=!0;var A=Array.isArray;function R(){}var _={H:null,A:null,T:null,S:null},P=Object.prototype.hasOwnProperty;function $(L,q,K){var ee=K.ref;return{$$typeof:e,type:L,key:q,ref:ee!==void 0?ee:null,props:K}}function H(L,q){return $(L.type,q,L.props)}function I(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function U(L){var q={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(K){return q[K]})}var D=/\/+/g;function V(L,q){return typeof L=="object"&&L!==null&&L.key!=null?U(""+L.key):q.toString(36)}function Z(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(R,R):(L.status="pending",L.then(function(q){L.status==="pending"&&(L.status="fulfilled",L.value=q)},function(q){L.status==="pending"&&(L.status="rejected",L.reason=q)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function O(L,q,K,ee,G){var re=typeof L;(re==="undefined"||re==="boolean")&&(L=null);var Q=!1;if(L===null)Q=!0;else switch(re){case"bigint":case"string":case"number":Q=!0;break;case"object":switch(L.$$typeof){case e:case t:Q=!0;break;case g:return Q=L._init,O(Q(L._payload),q,K,ee,G)}}if(Q)return G=G(L),Q=ee===""?"."+V(L,0):ee,A(G)?(K="",Q!=null&&(K=Q.replace(D,"$&/")+"/"),O(G,q,K,"",function($e){return $e})):G!=null&&(I(G)&&(G=H(G,K+(G.key==null||L&&L.key===G.key?"":(""+G.key).replace(D,"$&/")+"/")+Q)),q.push(G)),1;Q=0;var ae=ee===""?".":ee+":";if(A(L))for(var be=0;be<L.length;be++)ee=L[be],re=ae+V(ee,be),Q+=O(ee,q,K,re,G);else if(be=x(L),typeof be=="function")for(L=be.call(L),be=0;!(ee=L.next()).done;)ee=ee.value,re=ae+V(ee,be++),Q+=O(ee,q,K,re,G);else if(re==="object"){if(typeof L.then=="function")return O(Z(L),q,K,ee,G);throw q=String(L),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return Q}function z(L,q,K){if(L==null)return L;var ee=[],G=0;return O(L,ee,"","",function(re){return q.call(K,re,G++)}),ee}function B(L){if(L._status===-1){var q=L._result;q=q(),q.then(function(K){(L._status===0||L._status===-1)&&(L._status=1,L._result=K)},function(K){(L._status===0||L._status===-1)&&(L._status=2,L._result=K)}),L._status===-1&&(L._status=0,L._result=q)}if(L._status===1)return L._result.default;throw L._result}var X=typeof reportError=="function"?reportError:function(L){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof L=="object"&&L!==null&&typeof L.message=="string"?String(L.message):String(L),error:L});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",L);return}console.error(L)},W={map:z,forEach:function(L,q,K){z(L,function(){q.apply(this,arguments)},K)},count:function(L){var q=0;return z(L,function(){q++}),q},toArray:function(L){return z(L,function(q){return q})||[]},only:function(L){if(!I(L))throw Error("React.Children.only expected to receive a single React element child.");return L}};return mt.Activity=v,mt.Children=W,mt.Component=E,mt.Fragment=n,mt.Profiler=r,mt.PureComponent=k,mt.StrictMode=a,mt.Suspense=h,mt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,mt.__COMPILER_RUNTIME={__proto__:null,c:function(L){return _.H.useMemoCache(L)}},mt.cache=function(L){return function(){return L.apply(null,arguments)}},mt.cacheSignal=function(){return null},mt.cloneElement=function(L,q,K){if(L==null)throw Error("The argument must be a React element, but you passed "+L+".");var ee=C({},L.props),G=L.key;if(q!=null)for(re in q.key!==void 0&&(G=""+q.key),q)!P.call(q,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&q.ref===void 0||(ee[re]=q[re]);var re=arguments.length-2;if(re===1)ee.children=K;else if(1<re){for(var Q=Array(re),ae=0;ae<re;ae++)Q[ae]=arguments[ae+2];ee.children=Q}return $(L.type,G,ee)},mt.createContext=function(L){return L={$$typeof:c,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null},L.Provider=L,L.Consumer={$$typeof:o,_context:L},L},mt.createElement=function(L,q,K){var ee,G={},re=null;if(q!=null)for(ee in q.key!==void 0&&(re=""+q.key),q)P.call(q,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(G[ee]=q[ee]);var Q=arguments.length-2;if(Q===1)G.children=K;else if(1<Q){for(var ae=Array(Q),be=0;be<Q;be++)ae[be]=arguments[be+2];G.children=ae}if(L&&L.defaultProps)for(ee in Q=L.defaultProps,Q)G[ee]===void 0&&(G[ee]=Q[ee]);return $(L,re,G)},mt.createRef=function(){return{current:null}},mt.forwardRef=function(L){return{$$typeof:u,render:L}},mt.isValidElement=I,mt.lazy=function(L){return{$$typeof:g,_payload:{_status:-1,_result:L},_init:B}},mt.memo=function(L,q){return{$$typeof:f,type:L,compare:q===void 0?null:q}},mt.startTransition=function(L){var q=_.T,K={};_.T=K;try{var ee=L(),G=_.S;G!==null&&G(K,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(R,X)}catch(re){X(re)}finally{q!==null&&K.types!==null&&(q.types=K.types),_.T=q}},mt.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},mt.use=function(L){return _.H.use(L)},mt.useActionState=function(L,q,K){return _.H.useActionState(L,q,K)},mt.useCallback=function(L,q){return _.H.useCallback(L,q)},mt.useContext=function(L){return _.H.useContext(L)},mt.useDebugValue=function(){},mt.useDeferredValue=function(L,q){return _.H.useDeferredValue(L,q)},mt.useEffect=function(L,q){return _.H.useEffect(L,q)},mt.useEffectEvent=function(L){return _.H.useEffectEvent(L)},mt.useId=function(){return _.H.useId()},mt.useImperativeHandle=function(L,q,K){return _.H.useImperativeHandle(L,q,K)},mt.useInsertionEffect=function(L,q){return _.H.useInsertionEffect(L,q)},mt.useLayoutEffect=function(L,q){return _.H.useLayoutEffect(L,q)},mt.useMemo=function(L,q){return _.H.useMemo(L,q)},mt.useOptimistic=function(L,q){return _.H.useOptimistic(L,q)},mt.useReducer=function(L,q,K){return _.H.useReducer(L,q,K)},mt.useRef=function(L){return _.H.useRef(L)},mt.useState=function(L){return _.H.useState(L)},mt.useSyncExternalStore=function(L,q,K){return _.H.useSyncExternalStore(L,q,K)},mt.useTransition=function(){return _.H.useTransition()},mt.version="19.2.3",mt}var lS;function Ld(){return lS||(lS=1,by.exports=m4()),by.exports}var m=Ld();const Ql=JM(m),e2=d4({__proto__:null,default:Ql},[m]);var wy={exports:{}},Mu={},jy={exports:{}},Ny={};var cS;function p4(){return cS||(cS=1,(function(e){function t(O,z){var B=O.length;O.push(z);e:for(;0<B;){var X=B-1>>>1,W=O[X];if(0<r(W,z))O[X]=z,O[B]=W,B=X;else break e}}function n(O){return O.length===0?null:O[0]}function a(O){if(O.length===0)return null;var z=O[0],B=O.pop();if(B!==z){O[0]=B;e:for(var X=0,W=O.length,L=W>>>1;X<L;){var q=2*(X+1)-1,K=O[q],ee=q+1,G=O[ee];if(0>r(K,B))ee<W&&0>r(G,K)?(O[X]=G,O[ee]=B,X=ee):(O[X]=K,O[q]=B,X=q);else if(ee<W&&0>r(G,B))O[X]=G,O[ee]=B,X=ee;else break e}}return z}function r(O,z){var B=O.sortIndex-z.sortIndex;return B!==0?B:O.id-z.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var h=[],f=[],g=1,v=null,y=3,x=!1,w=!1,C=!1,T=!1,E=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function N(O){for(var z=n(f);z!==null;){if(z.callback===null)a(f);else if(z.startTime<=O)a(f),z.sortIndex=z.expirationTime,t(h,z);else break;z=n(f)}}function A(O){if(C=!1,N(O),!w)if(n(h)!==null)w=!0,R||(R=!0,U());else{var z=n(f);z!==null&&Z(A,z.startTime-O)}}var R=!1,_=-1,P=5,$=-1;function H(){return T?!0:!(e.unstable_now()-$<P)}function I(){if(T=!1,R){var O=e.unstable_now();$=O;var z=!0;try{e:{w=!1,C&&(C=!1,S(_),_=-1),x=!0;var B=y;try{t:{for(N(O),v=n(h);v!==null&&!(v.expirationTime>O&&H());){var X=v.callback;if(typeof X=="function"){v.callback=null,y=v.priorityLevel;var W=X(v.expirationTime<=O);if(O=e.unstable_now(),typeof W=="function"){v.callback=W,N(O),z=!0;break t}v===n(h)&&a(h),N(O)}else a(h);v=n(h)}if(v!==null)z=!0;else{var L=n(f);L!==null&&Z(A,L.startTime-O),z=!1}}break e}finally{v=null,y=B,x=!1}z=void 0}}finally{z?U():R=!1}}}var U;if(typeof k=="function")U=function(){k(I)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,V=D.port2;D.port1.onmessage=I,U=function(){V.postMessage(null)}}else U=function(){E(I,0)};function Z(O,z){_=E(function(){O(e.unstable_now())},z)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_next=function(O){switch(y){case 1:case 2:case 3:var z=3;break;default:z=y}var B=y;y=z;try{return O()}finally{y=B}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(O,z){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var B=y;y=O;try{return z()}finally{y=B}},e.unstable_scheduleCallback=function(O,z,B){var X=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?X+B:X):B=X,O){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=B+W,O={id:g++,callback:z,priorityLevel:O,startTime:B,expirationTime:W,sortIndex:-1},B>X?(O.sortIndex=B,t(f,O),n(h)===null&&O===n(f)&&(C?(S(_),_=-1):C=!0,Z(A,B-X))):(O.sortIndex=W,t(h,O),w||x||(w=!0,R||(R=!0,U()))),O},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(O){var z=y;return function(){var B=y;y=z;try{return O.apply(this,arguments)}finally{y=B}}}})(Ny)),Ny}var uS;function g4(){return uS||(uS=1,jy.exports=p4()),jy.exports}var ky={exports:{}},fs={};var dS;function v4(){if(dS)return fs;dS=1;var e=Ld();function t(h){var f="https://react.dev/errors/"+h;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)f+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+h+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");function o(h,f,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:v==null?null:""+v,children:h,containerInfo:f,implementation:g}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(h,f){if(h==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return fs.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,fs.createPortal=function(h,f){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return o(h,f,null,g)},fs.flushSync=function(h){var f=c.T,g=a.p;try{if(c.T=null,a.p=2,h)return h()}finally{c.T=f,a.p=g,a.d.f()}},fs.preconnect=function(h,f){typeof h=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,a.d.C(h,f))},fs.prefetchDNS=function(h){typeof h=="string"&&a.d.D(h)},fs.preinit=function(h,f){if(typeof h=="string"&&f&&typeof f.as=="string"){var g=f.as,v=u(g,f.crossOrigin),y=typeof f.integrity=="string"?f.integrity:void 0,x=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;g==="style"?a.d.S(h,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:v,integrity:y,fetchPriority:x}):g==="script"&&a.d.X(h,{crossOrigin:v,integrity:y,fetchPriority:x,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},fs.preinitModule=function(h,f){if(typeof h=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var g=u(f.as,f.crossOrigin);a.d.M(h,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&a.d.M(h)},fs.preload=function(h,f){if(typeof h=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var g=f.as,v=u(g,f.crossOrigin);a.d.L(h,g,{crossOrigin:v,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},fs.preloadModule=function(h,f){if(typeof h=="string")if(f){var g=u(f.as,f.crossOrigin);a.d.m(h,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else a.d.m(h)},fs.requestFormReset=function(h){a.d.r(h)},fs.unstable_batchedUpdates=function(h,f){return h(f)},fs.useFormState=function(h,f,g){return c.H.useFormState(h,f,g)},fs.useFormStatus=function(){return c.H.useHostTransitionStatus()},fs.version="19.2.3",fs}var fS;function t2(){if(fS)return ky.exports;fS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),ky.exports=v4(),ky.exports}var hS;function y4(){if(hS)return Mu;hS=1;var e=g4(),t=Ld(),n=t2();function a(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)l+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function o(i){var l=i,d=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,(l.flags&4098)!==0&&(d=l.return),i=l.return;while(i)}return l.tag===3?d:null}function c(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function u(i){if(i.tag===31){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null}function h(i){if(o(i)!==i)throw Error(a(188))}function f(i){var l=i.alternate;if(!l){if(l=o(i),l===null)throw Error(a(188));return l!==i?null:i}for(var d=i,p=l;;){var b=d.return;if(b===null)break;var j=b.alternate;if(j===null){if(p=b.return,p!==null){d=p;continue}break}if(b.child===j.child){for(j=b.child;j;){if(j===d)return h(b),i;if(j===p)return h(b),l;j=j.sibling}throw Error(a(188))}if(d.return!==p.return)d=b,p=j;else{for(var M=!1,F=b.child;F;){if(F===d){M=!0,d=b,p=j;break}if(F===p){M=!0,p=b,d=j;break}F=F.sibling}if(!M){for(F=j.child;F;){if(F===d){M=!0,d=j,p=b;break}if(F===p){M=!0,p=j,d=b;break}F=F.sibling}if(!M)throw Error(a(189))}}if(d.alternate!==p)throw Error(a(190))}if(d.tag!==3)throw Error(a(188));return d.stateNode.current===d?i:l}function g(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=g(i),l!==null)return l;i=i.sibling}return null}var v=Object.assign,y=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),k=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),$=Symbol.for("react.activity"),H=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function U(i){return i===null||typeof i!="object"?null:(i=I&&i[I]||i["@@iterator"],typeof i=="function"?i:null)}var D=Symbol.for("react.client.reference");function V(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===D?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case C:return"Fragment";case E:return"Profiler";case T:return"StrictMode";case A:return"Suspense";case R:return"SuspenseList";case $:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case w:return"Portal";case k:return i.displayName||"Context";case S:return(i._context.displayName||"Context")+".Consumer";case N:var l=i.render;return i=i.displayName,i||(i=l.displayName||l.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case _:return l=i.displayName||null,l!==null?l:V(i.type)||"Memo";case P:l=i._payload,i=i._init;try{return V(i(l))}catch{}}return null}var Z=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},X=[],W=-1;function L(i){return{current:i}}function q(i){0>W||(i.current=X[W],X[W]=null,W--)}function K(i,l){W++,X[W]=i.current,i.current=l}var ee=L(null),G=L(null),re=L(null),Q=L(null);function ae(i,l){switch(K(re,l),K(G,i),K(ee,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?Ak(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=Ak(l),i=Tk(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}q(ee),K(ee,i)}function be(){q(ee),q(G),q(re)}function $e(i){i.memoizedState!==null&&K(Q,i);var l=ee.current,d=Tk(l,i.type);l!==d&&(K(G,i),K(ee,d))}function ge(i){G.current===i&&(q(ee),q(G)),Q.current===i&&(q(Q),Su._currentValue=B)}var Te,pe;function Xe(i){if(Te===void 0)try{throw Error()}catch(d){var l=d.stack.trim().match(/\n( *(at )?)/);Te=l&&l[1]||"",pe=-1<d.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+Te+i+pe}var Be=!1;function Se(i,l){if(!i||Be)return"";Be=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(l){var je=function(){throw Error()};if(Object.defineProperty(je.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(je,[])}catch(fe){var ue=fe}Reflect.construct(i,[],je)}else{try{je.call()}catch(fe){ue=fe}i.call(je.prototype)}}else{try{throw Error()}catch(fe){ue=fe}(je=i())&&typeof je.catch=="function"&&je.catch(function(){})}}catch(fe){if(fe&&ue&&typeof fe.stack=="string")return[fe.stack,ue.stack]}return[null,null]}};p.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(p.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(p.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=p.DetermineComponentFrameRoot(),M=j[0],F=j[1];if(M&&F){var J=M.split(`
4
+ `),le=F.split(`
5
+ `);for(b=p=0;p<J.length&&!J[p].includes("DetermineComponentFrameRoot");)p++;for(;b<le.length&&!le[b].includes("DetermineComponentFrameRoot");)b++;if(p===J.length||b===le.length)for(p=J.length-1,b=le.length-1;1<=p&&0<=b&&J[p]!==le[b];)b--;for(;1<=p&&0<=b;p--,b--)if(J[p]!==le[b]){if(p!==1||b!==1)do if(p--,b--,0>b||J[p]!==le[b]){var ye=`
6
+ `+J[p].replace(" at new "," at ");return i.displayName&&ye.includes("<anonymous>")&&(ye=ye.replace("<anonymous>",i.displayName)),ye}while(1<=p&&0<=b);break}}}finally{Be=!1,Error.prepareStackTrace=d}return(d=i?i.displayName||i.name:"")?Xe(d):""}function Me(i,l){switch(i.tag){case 26:case 27:case 5:return Xe(i.type);case 16:return Xe("Lazy");case 13:return i.child!==l&&l!==null?Xe("Suspense Fallback"):Xe("Suspense");case 19:return Xe("SuspenseList");case 0:case 15:return Se(i.type,!1);case 11:return Se(i.type.render,!1);case 1:return Se(i.type,!0);case 31:return Xe("Activity");default:return""}}function _e(i){try{var l="",d=null;do l+=Me(i,d),d=i,i=i.return;while(i);return l}catch(p){return`
7
+ Error generating stack: `+p.message+`
8
+ `+p.stack}}var Ne=Object.prototype.hasOwnProperty,Oe=e.unstable_scheduleCallback,Ce=e.unstable_cancelCallback,Ve=e.unstable_shouldYield,Re=e.unstable_requestPaint,Ie=e.unstable_now,De=e.unstable_getCurrentPriorityLevel,ct=e.unstable_ImmediatePriority,ut=e.unstable_UserBlockingPriority,st=e.unstable_NormalPriority,ht=e.unstable_LowPriority,yt=e.unstable_IdlePriority,Mt=e.log,Rt=e.unstable_setDisableYieldValue,xt=null,Y=null;function te(i){if(typeof Mt=="function"&&Rt(i),Y&&typeof Y.setStrictMode=="function")try{Y.setStrictMode(xt,i)}catch{}}var he=Math.clz32?Math.clz32:rt,Pe=Math.log,We=Math.LN2;function rt(i){return i>>>=0,i===0?32:31-(Pe(i)/We|0)|0}var at=256,Ot=262144,jt=4194304;function bt(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Bt(i,l,d){var p=i.pendingLanes;if(p===0)return 0;var b=0,j=i.suspendedLanes,M=i.pingedLanes;i=i.warmLanes;var F=p&134217727;return F!==0?(p=F&~j,p!==0?b=bt(p):(M&=F,M!==0?b=bt(M):d||(d=F&~i,d!==0&&(b=bt(d))))):(F=p&~j,F!==0?b=bt(F):M!==0?b=bt(M):d||(d=p&~i,d!==0&&(b=bt(d)))),b===0?0:l!==0&&l!==b&&(l&j)===0&&(j=b&-b,d=l&-l,j>=d||j===32&&(d&4194048)!==0)?l:b}function Mn(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function es(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function vs(){var i=jt;return jt<<=1,(jt&62914560)===0&&(jt=4194304),i}function cn(i){for(var l=[],d=0;31>d;d++)l.push(i);return l}function Rn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function ts(i,l,d,p,b,j){var M=i.pendingLanes;i.pendingLanes=d,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=d,i.entangledLanes&=d,i.errorRecoveryDisabledLanes&=d,i.shellSuspendCounter=0;var F=i.entanglements,J=i.expirationTimes,le=i.hiddenUpdates;for(d=M&~d;0<d;){var ye=31-he(d),je=1<<ye;F[ye]=0,J[ye]=-1;var ue=le[ye];if(ue!==null)for(le[ye]=null,ye=0;ye<ue.length;ye++){var fe=ue[ye];fe!==null&&(fe.lane&=-536870913)}d&=~je}p!==0&&ys(i,p,0),j!==0&&b===0&&i.tag!==0&&(i.suspendedLanes|=j&~(M&~l))}function ys(i,l,d){i.pendingLanes|=l,i.suspendedLanes&=~l;var p=31-he(l);i.entangledLanes|=l,i.entanglements[p]=i.entanglements[p]|1073741824|d&261930}function la(i,l){var d=i.entangledLanes|=l;for(i=i.entanglements;d;){var p=31-he(d),b=1<<p;b&l|i[p]&l&&(i[p]|=l),d&=~b}}function xs(i,l){var d=l&-l;return d=(d&42)!==0?1:Yt(d),(d&(i.suspendedLanes|l))!==0?0:d}function Yt(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Ht(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Ln(){var i=z.p;return i!==0?i:(i=window.event,i===void 0?32:Qk(i.type))}function Rs(i,l){var d=z.p;try{return z.p=i,l()}finally{z.p=d}}var de=Math.random().toString(36).slice(2),Ue="__reactFiber$"+de,He="__reactProps$"+de,Lt="__reactContainer$"+de,nn="__reactEvents$"+de,ca="__reactListeners$"+de,bs="__reactHandles$"+de,Wt="__reactResources$"+de,Gn="__reactMarker$"+de;function ds(i){delete i[Ue],delete i[He],delete i[nn],delete i[ca],delete i[bs]}function ws(i){var l=i[Ue];if(l)return l;for(var d=i.parentNode;d;){if(l=d[Lt]||d[Ue]){if(d=l.alternate,l.child!==null||d!==null&&d.child!==null)for(i=Pk(i);i!==null;){if(d=i[Ue])return d;i=Pk(i)}return l}i=d,d=i.parentNode}return null}function Xn(i){if(i=i[Ue]||i[Lt]){var l=i.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return i}return null}function js(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i.stateNode;throw Error(a(33))}function ua(i){var l=i[Wt];return l||(l=i[Wt]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function dn(i){i[Gn]=!0}var Qn=new Set,Kr={};function da(i,l){Ma(i,l),Ma(i+"Capture",l)}function Ma(i,l){for(Kr[i]=l,i=0;i<l.length;i++)Qn.add(l[i])}var Ra=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Yr={},Xa={};function Uc(i){return Ne.call(Xa,i)?!0:Ne.call(Yr,i)?!1:Ra.test(i)?Xa[i]=!0:(Yr[i]=!0,!1)}function Ia(i,l,d){if(Uc(l))if(d===null)i.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":i.removeAttribute(l);return;case"boolean":var p=l.toLowerCase().slice(0,5);if(p!=="data-"&&p!=="aria-"){i.removeAttribute(l);return}}i.setAttribute(l,""+d)}}function Nr(i,l,d){if(d===null)i.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(l);return}i.setAttribute(l,""+d)}}function Fs(i,l,d,p){if(p===null)i.removeAttribute(d);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(d);return}i.setAttributeNS(l,d,""+p)}}function ce(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ke(i){var l=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Ge(i,l,d){var p=Object.getOwnPropertyDescriptor(i.constructor.prototype,l);if(!i.hasOwnProperty(l)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var b=p.get,j=p.set;return Object.defineProperty(i,l,{configurable:!0,get:function(){return b.call(this)},set:function(M){d=""+M,j.call(this,M)}}),Object.defineProperty(i,l,{enumerable:p.enumerable}),{getValue:function(){return d},setValue:function(M){d=""+M},stopTracking:function(){i._valueTracker=null,delete i[l]}}}}function Qe(i){if(!i._valueTracker){var l=ke(i)?"checked":"value";i._valueTracker=Ge(i,l,""+i[l])}}function St(i){if(!i)return!1;var l=i._valueTracker;if(!l)return!0;var d=l.getValue(),p="";return i&&(p=ke(i)?i.checked?"true":"false":i.value),i=p,i!==d?(l.setValue(i),!0):!1}function Ct(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sn=/[\n"\\]/g;function ne(i){return i.replace(sn,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function ve(i,l,d,p,b,j,M,F){i.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?i.type=M:i.removeAttribute("type"),l!=null?M==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+ce(l)):i.value!==""+ce(l)&&(i.value=""+ce(l)):M!=="submit"&&M!=="reset"||i.removeAttribute("value"),l!=null?Fe(i,M,ce(l)):d!=null?Fe(i,M,ce(d)):p!=null&&i.removeAttribute("value"),b==null&&j!=null&&(i.defaultChecked=!!j),b!=null&&(i.checked=b&&typeof b!="function"&&typeof b!="symbol"),F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"?i.name=""+ce(F):i.removeAttribute("name")}function Ee(i,l,d,p,b,j,M,F){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(i.type=j),l!=null||d!=null){if(!(j!=="submit"&&j!=="reset"||l!=null)){Qe(i);return}d=d!=null?""+ce(d):"",l=l!=null?""+ce(l):d,F||l===i.value||(i.value=l),i.defaultValue=l}p=p??b,p=typeof p!="function"&&typeof p!="symbol"&&!!p,i.checked=F?i.checked:!!p,i.defaultChecked=!!p,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(i.name=M),Qe(i)}function Fe(i,l,d){l==="number"&&Ct(i.ownerDocument)===i||i.defaultValue===""+d||(i.defaultValue=""+d)}function ze(i,l,d,p){if(i=i.options,l){l={};for(var b=0;b<d.length;b++)l["$"+d[b]]=!0;for(d=0;d<i.length;d++)b=l.hasOwnProperty("$"+i[d].value),i[d].selected!==b&&(i[d].selected=b),b&&p&&(i[d].defaultSelected=!0)}else{for(d=""+ce(d),l=null,b=0;b<i.length;b++){if(i[b].value===d){i[b].selected=!0,p&&(i[b].defaultSelected=!0);return}l!==null||i[b].disabled||(l=i[b])}l!==null&&(l.selected=!0)}}function it(i,l,d){if(l!=null&&(l=""+ce(l),l!==i.value&&(i.value=l),d==null)){i.defaultValue!==l&&(i.defaultValue=l);return}i.defaultValue=d!=null?""+ce(d):""}function fn(i,l,d,p){if(l==null){if(p!=null){if(d!=null)throw Error(a(92));if(Z(p)){if(1<p.length)throw Error(a(93));p=p[0]}d=p}d==null&&(d=""),l=d}d=ce(l),i.defaultValue=d,p=i.textContent,p===d&&p!==""&&p!==null&&(i.value=p),Qe(i)}function Xt(i,l){if(l){var d=i.firstChild;if(d&&d===i.lastChild&&d.nodeType===3){d.nodeValue=l;return}}i.textContent=l}var kn=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function wn(i,l,d){var p=l.indexOf("--")===0;d==null||typeof d=="boolean"||d===""?p?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="":p?i.setProperty(l,d):typeof d!="number"||d===0||kn.has(l)?l==="float"?i.cssFloat=d:i[l]=(""+d).trim():i[l]=d+"px"}function fa(i,l,d){if(l!=null&&typeof l!="object")throw Error(a(62));if(i=i.style,d!=null){for(var p in d)!d.hasOwnProperty(p)||l!=null&&l.hasOwnProperty(p)||(p.indexOf("--")===0?i.setProperty(p,""):p==="float"?i.cssFloat="":i[p]="");for(var b in l)p=l[b],l.hasOwnProperty(b)&&d[b]!==p&&wn(i,b,p)}else for(var j in l)l.hasOwnProperty(j)&&wn(i,j,l[j])}function Zn(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var sf=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),af=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function rf(i){return af.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function kr(){}var gg=null;function vg(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var rl=null,il=null;function Ej(i){var l=Xn(i);if(l&&(i=l.stateNode)){var d=i[He]||null;e:switch(i=l.stateNode,l.type){case"input":if(ve(i,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name),l=d.name,d.type==="radio"&&l!=null){for(d=i;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll('input[name="'+ne(""+l)+'"][type="radio"]'),l=0;l<d.length;l++){var p=d[l];if(p!==i&&p.form===i.form){var b=p[He]||null;if(!b)throw Error(a(90));ve(p,b.value,b.defaultValue,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name)}}for(l=0;l<d.length;l++)p=d[l],p.form===i.form&&St(p)}break e;case"textarea":it(i,d.value,d.defaultValue);break e;case"select":l=d.value,l!=null&&ze(i,!!d.multiple,l,!1)}}}var yg=!1;function Aj(i,l,d){if(yg)return i(l,d);yg=!0;try{var p=i(l);return p}finally{if(yg=!1,(rl!==null||il!==null)&&(Gf(),rl&&(l=rl,i=il,il=rl=null,Ej(l),i)))for(l=0;l<i.length;l++)Ej(i[l])}}function Fc(i,l){var d=i.stateNode;if(d===null)return null;var p=d[He]||null;if(p===null)return null;d=p[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(i=i.type,p=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!p;break e;default:i=!1}if(i)return null;if(d&&typeof d!="function")throw Error(a(231,l,typeof d));return d}var Sr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xg=!1;if(Sr)try{var Vc={};Object.defineProperty(Vc,"passive",{get:function(){xg=!0}}),window.addEventListener("test",Vc,Vc),window.removeEventListener("test",Vc,Vc)}catch{xg=!1}var Xr=null,bg=null,of=null;function Tj(){if(of)return of;var i,l=bg,d=l.length,p,b="value"in Xr?Xr.value:Xr.textContent,j=b.length;for(i=0;i<d&&l[i]===b[i];i++);var M=d-i;for(p=1;p<=M&&l[d-p]===b[j-p];p++);return of=b.slice(i,1<p?1-p:void 0)}function lf(i){var l=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&l===13&&(i=13)):i=l,i===10&&(i=13),32<=i||i===13?i:0}function cf(){return!0}function Mj(){return!1}function Is(i){function l(d,p,b,j,M){this._reactName=d,this._targetInst=b,this.type=p,this.nativeEvent=j,this.target=M,this.currentTarget=null;for(var F in i)i.hasOwnProperty(F)&&(d=i[F],this[F]=d?d(j):j[F]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?cf:Mj,this.isPropagationStopped=Mj,this}return v(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=cf)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=cf)},persist:function(){},isPersistent:cf}),l}var to={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},uf=Is(to),Hc=v({},to,{view:0,detail:0}),cL=Is(Hc),wg,jg,qc,df=v({},Hc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:kg,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==qc&&(qc&&i.type==="mousemove"?(wg=i.screenX-qc.screenX,jg=i.screenY-qc.screenY):jg=wg=0,qc=i),wg)},movementY:function(i){return"movementY"in i?i.movementY:jg}}),Rj=Is(df),uL=v({},df,{dataTransfer:0}),dL=Is(uL),fL=v({},Hc,{relatedTarget:0}),Ng=Is(fL),hL=v({},to,{animationName:0,elapsedTime:0,pseudoElement:0}),mL=Is(hL),pL=v({},to,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),gL=Is(pL),vL=v({},to,{data:0}),Ij=Is(vL),yL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xL={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},bL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wL(i){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(i):(i=bL[i])?!!l[i]:!1}function kg(){return wL}var jL=v({},Hc,{key:function(i){if(i.key){var l=yL[i.key]||i.key;if(l!=="Unidentified")return l}return i.type==="keypress"?(i=lf(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?xL[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:kg,charCode:function(i){return i.type==="keypress"?lf(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?lf(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),NL=Is(jL),kL=v({},df,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_j=Is(kL),SL=v({},Hc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:kg}),CL=Is(SL),EL=v({},to,{propertyName:0,elapsedTime:0,pseudoElement:0}),AL=Is(EL),TL=v({},df,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),ML=Is(TL),RL=v({},to,{newState:0,oldState:0}),IL=Is(RL),_L=[9,13,27,32],Sg=Sr&&"CompositionEvent"in window,Wc=null;Sr&&"documentMode"in document&&(Wc=document.documentMode);var OL=Sr&&"TextEvent"in window&&!Wc,Oj=Sr&&(!Sg||Wc&&8<Wc&&11>=Wc),$j=" ",Pj=!1;function Dj(i,l){switch(i){case"keyup":return _L.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Lj(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ol=!1;function $L(i,l){switch(i){case"compositionend":return Lj(l);case"keypress":return l.which!==32?null:(Pj=!0,$j);case"textInput":return i=l.data,i===$j&&Pj?null:i;default:return null}}function PL(i,l){if(ol)return i==="compositionend"||!Sg&&Dj(i,l)?(i=Tj(),of=bg=Xr=null,ol=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return Oj&&l.locale!=="ko"?null:l.data;default:return null}}var DL={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function zj(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l==="input"?!!DL[i.type]:l==="textarea"}function Bj(i,l,d,p){rl?il?il.push(p):il=[p]:rl=p,l=eh(l,"onChange"),0<l.length&&(d=new uf("onChange","change",null,d,p),i.push({event:d,listeners:l}))}var Gc=null,Zc=null;function LL(i){jk(i,0)}function ff(i){var l=js(i);if(St(l))return i}function Uj(i,l){if(i==="change")return l}var Fj=!1;if(Sr){var Cg;if(Sr){var Eg="oninput"in document;if(!Eg){var Vj=document.createElement("div");Vj.setAttribute("oninput","return;"),Eg=typeof Vj.oninput=="function"}Cg=Eg}else Cg=!1;Fj=Cg&&(!document.documentMode||9<document.documentMode)}function Hj(){Gc&&(Gc.detachEvent("onpropertychange",qj),Zc=Gc=null)}function qj(i){if(i.propertyName==="value"&&ff(Zc)){var l=[];Bj(l,Zc,i,vg(i)),Aj(LL,l)}}function zL(i,l,d){i==="focusin"?(Hj(),Gc=l,Zc=d,Gc.attachEvent("onpropertychange",qj)):i==="focusout"&&Hj()}function BL(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return ff(Zc)}function UL(i,l){if(i==="click")return ff(l)}function FL(i,l){if(i==="input"||i==="change")return ff(l)}function VL(i,l){return i===l&&(i!==0||1/i===1/l)||i!==i&&l!==l}var Vs=typeof Object.is=="function"?Object.is:VL;function Kc(i,l){if(Vs(i,l))return!0;if(typeof i!="object"||i===null||typeof l!="object"||l===null)return!1;var d=Object.keys(i),p=Object.keys(l);if(d.length!==p.length)return!1;for(p=0;p<d.length;p++){var b=d[p];if(!Ne.call(l,b)||!Vs(i[b],l[b]))return!1}return!0}function Wj(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Gj(i,l){var d=Wj(i);i=0;for(var p;d;){if(d.nodeType===3){if(p=i+d.textContent.length,i<=l&&p>=l)return{node:d,offset:l-i};i=p}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Wj(d)}}function Zj(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?Zj(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function Kj(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=Ct(i.document);l instanceof i.HTMLIFrameElement;){try{var d=typeof l.contentWindow.location.href=="string"}catch{d=!1}if(d)i=l.contentWindow;else break;l=Ct(i.document)}return l}function Ag(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var HL=Sr&&"documentMode"in document&&11>=document.documentMode,ll=null,Tg=null,Yc=null,Mg=!1;function Yj(i,l,d){var p=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Mg||ll==null||ll!==Ct(p)||(p=ll,"selectionStart"in p&&Ag(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Yc&&Kc(Yc,p)||(Yc=p,p=eh(Tg,"onSelect"),0<p.length&&(l=new uf("onSelect","select",null,l,d),i.push({event:l,listeners:p}),l.target=ll)))}function no(i,l){var d={};return d[i.toLowerCase()]=l.toLowerCase(),d["Webkit"+i]="webkit"+l,d["Moz"+i]="moz"+l,d}var cl={animationend:no("Animation","AnimationEnd"),animationiteration:no("Animation","AnimationIteration"),animationstart:no("Animation","AnimationStart"),transitionrun:no("Transition","TransitionRun"),transitionstart:no("Transition","TransitionStart"),transitioncancel:no("Transition","TransitionCancel"),transitionend:no("Transition","TransitionEnd")},Rg={},Xj={};Sr&&(Xj=document.createElement("div").style,"AnimationEvent"in window||(delete cl.animationend.animation,delete cl.animationiteration.animation,delete cl.animationstart.animation),"TransitionEvent"in window||delete cl.transitionend.transition);function so(i){if(Rg[i])return Rg[i];if(!cl[i])return i;var l=cl[i],d;for(d in l)if(l.hasOwnProperty(d)&&d in Xj)return Rg[i]=l[d];return i}var Qj=so("animationend"),Jj=so("animationiteration"),e1=so("animationstart"),qL=so("transitionrun"),WL=so("transitionstart"),GL=so("transitioncancel"),t1=so("transitionend"),n1=new Map,Ig="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Ig.push("scrollEnd");function _a(i,l){n1.set(i,l),da(l,[i])}var hf=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},ha=[],ul=0,_g=0;function mf(){for(var i=ul,l=_g=ul=0;l<i;){var d=ha[l];ha[l++]=null;var p=ha[l];ha[l++]=null;var b=ha[l];ha[l++]=null;var j=ha[l];if(ha[l++]=null,p!==null&&b!==null){var M=p.pending;M===null?b.next=b:(b.next=M.next,M.next=b),p.pending=b}j!==0&&s1(d,b,j)}}function pf(i,l,d,p){ha[ul++]=i,ha[ul++]=l,ha[ul++]=d,ha[ul++]=p,_g|=p,i.lanes|=p,i=i.alternate,i!==null&&(i.lanes|=p)}function Og(i,l,d,p){return pf(i,l,d,p),gf(i)}function ao(i,l){return pf(i,null,null,l),gf(i)}function s1(i,l,d){i.lanes|=d;var p=i.alternate;p!==null&&(p.lanes|=d);for(var b=!1,j=i.return;j!==null;)j.childLanes|=d,p=j.alternate,p!==null&&(p.childLanes|=d),j.tag===22&&(i=j.stateNode,i===null||i._visibility&1||(b=!0)),i=j,j=j.return;return i.tag===3?(j=i.stateNode,b&&l!==null&&(b=31-he(d),i=j.hiddenUpdates,p=i[b],p===null?i[b]=[l]:p.push(l),l.lane=d|536870912),j):null}function gf(i){if(50<yu)throw yu=0,Vv=null,Error(a(185));for(var l=i.return;l!==null;)i=l,l=i.return;return i.tag===3?i.stateNode:null}var dl={};function ZL(i,l,d,p){this.tag=i,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Hs(i,l,d,p){return new ZL(i,l,d,p)}function $g(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Cr(i,l){var d=i.alternate;return d===null?(d=Hs(i.tag,l,i.key,i.mode),d.elementType=i.elementType,d.type=i.type,d.stateNode=i.stateNode,d.alternate=i,i.alternate=d):(d.pendingProps=l,d.type=i.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=i.flags&65011712,d.childLanes=i.childLanes,d.lanes=i.lanes,d.child=i.child,d.memoizedProps=i.memoizedProps,d.memoizedState=i.memoizedState,d.updateQueue=i.updateQueue,l=i.dependencies,d.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},d.sibling=i.sibling,d.index=i.index,d.ref=i.ref,d.refCleanup=i.refCleanup,d}function a1(i,l){i.flags&=65011714;var d=i.alternate;return d===null?(i.childLanes=0,i.lanes=l,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=d.childLanes,i.lanes=d.lanes,i.child=d.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=d.memoizedProps,i.memoizedState=d.memoizedState,i.updateQueue=d.updateQueue,i.type=d.type,l=d.dependencies,i.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),i}function vf(i,l,d,p,b,j){var M=0;if(p=i,typeof i=="function")$g(i)&&(M=1);else if(typeof i=="string")M=J5(i,d,ee.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case $:return i=Hs(31,d,l,b),i.elementType=$,i.lanes=j,i;case C:return ro(d.children,b,j,l);case T:M=8,b|=24;break;case E:return i=Hs(12,d,l,b|2),i.elementType=E,i.lanes=j,i;case A:return i=Hs(13,d,l,b),i.elementType=A,i.lanes=j,i;case R:return i=Hs(19,d,l,b),i.elementType=R,i.lanes=j,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case k:M=10;break e;case S:M=9;break e;case N:M=11;break e;case _:M=14;break e;case P:M=16,p=null;break e}M=29,d=Error(a(130,i===null?"null":typeof i,"")),p=null}return l=Hs(M,d,l,b),l.elementType=i,l.type=p,l.lanes=j,l}function ro(i,l,d,p){return i=Hs(7,i,p,l),i.lanes=d,i}function Pg(i,l,d){return i=Hs(6,i,null,l),i.lanes=d,i}function r1(i){var l=Hs(18,null,null,0);return l.stateNode=i,l}function Dg(i,l,d){return l=Hs(4,i.children!==null?i.children:[],i.key,l),l.lanes=d,l.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},l}var i1=new WeakMap;function ma(i,l){if(typeof i=="object"&&i!==null){var d=i1.get(i);return d!==void 0?d:(l={value:i,source:l,stack:_e(l)},i1.set(i,l),l)}return{value:i,source:l,stack:_e(l)}}var fl=[],hl=0,yf=null,Xc=0,pa=[],ga=0,Qr=null,Qa=1,Ja="";function Er(i,l){fl[hl++]=Xc,fl[hl++]=yf,yf=i,Xc=l}function o1(i,l,d){pa[ga++]=Qa,pa[ga++]=Ja,pa[ga++]=Qr,Qr=i;var p=Qa;i=Ja;var b=32-he(p)-1;p&=~(1<<b),d+=1;var j=32-he(l)+b;if(30<j){var M=b-b%5;j=(p&(1<<M)-1).toString(32),p>>=M,b-=M,Qa=1<<32-he(l)+b|d<<b|p,Ja=j+i}else Qa=1<<j|d<<b|p,Ja=i}function Lg(i){i.return!==null&&(Er(i,1),o1(i,1,0))}function zg(i){for(;i===yf;)yf=fl[--hl],fl[hl]=null,Xc=fl[--hl],fl[hl]=null;for(;i===Qr;)Qr=pa[--ga],pa[ga]=null,Ja=pa[--ga],pa[ga]=null,Qa=pa[--ga],pa[ga]=null}function l1(i,l){pa[ga++]=Qa,pa[ga++]=Ja,pa[ga++]=Qr,Qa=l.id,Ja=l.overflow,Qr=i}var ns=null,hn=null,$t=!1,Jr=null,va=!1,Bg=Error(a(519));function ei(i){var l=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Qc(ma(l,i)),Bg}function c1(i){var l=i.stateNode,d=i.type,p=i.memoizedProps;switch(l[Ue]=i,l[He]=p,d){case"dialog":At("cancel",l),At("close",l);break;case"iframe":case"object":case"embed":At("load",l);break;case"video":case"audio":for(d=0;d<bu.length;d++)At(bu[d],l);break;case"source":At("error",l);break;case"img":case"image":case"link":At("error",l),At("load",l);break;case"details":At("toggle",l);break;case"input":At("invalid",l),Ee(l,p.value,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name,!0);break;case"select":At("invalid",l);break;case"textarea":At("invalid",l),fn(l,p.value,p.defaultValue,p.children)}d=p.children,typeof d!="string"&&typeof d!="number"&&typeof d!="bigint"||l.textContent===""+d||p.suppressHydrationWarning===!0||Ck(l.textContent,d)?(p.popover!=null&&(At("beforetoggle",l),At("toggle",l)),p.onScroll!=null&&At("scroll",l),p.onScrollEnd!=null&&At("scrollend",l),p.onClick!=null&&(l.onclick=kr),l=!0):l=!1,l||ei(i,!0)}function u1(i){for(ns=i.return;ns;)switch(ns.tag){case 5:case 31:case 13:va=!1;return;case 27:case 3:va=!0;return;default:ns=ns.return}}function ml(i){if(i!==ns)return!1;if(!$t)return u1(i),$t=!0,!1;var l=i.tag,d;if((d=l!==3&&l!==27)&&((d=l===5)&&(d=i.type,d=!(d!=="form"&&d!=="button")||ay(i.type,i.memoizedProps)),d=!d),d&&hn&&ei(i),u1(i),l===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(a(317));hn=$k(i)}else if(l===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(a(317));hn=$k(i)}else l===27?(l=hn,mi(i.type)?(i=cy,cy=null,hn=i):hn=l):hn=ns?xa(i.stateNode.nextSibling):null;return!0}function io(){hn=ns=null,$t=!1}function Ug(){var i=Jr;return i!==null&&(Ps===null?Ps=i:Ps.push.apply(Ps,i),Jr=null),i}function Qc(i){Jr===null?Jr=[i]:Jr.push(i)}var Fg=L(null),oo=null,Ar=null;function ti(i,l,d){K(Fg,l._currentValue),l._currentValue=d}function Tr(i){i._currentValue=Fg.current,q(Fg)}function Vg(i,l,d){for(;i!==null;){var p=i.alternate;if((i.childLanes&l)!==l?(i.childLanes|=l,p!==null&&(p.childLanes|=l)):p!==null&&(p.childLanes&l)!==l&&(p.childLanes|=l),i===d)break;i=i.return}}function Hg(i,l,d,p){var b=i.child;for(b!==null&&(b.return=i);b!==null;){var j=b.dependencies;if(j!==null){var M=b.child;j=j.firstContext;e:for(;j!==null;){var F=j;j=b;for(var J=0;J<l.length;J++)if(F.context===l[J]){j.lanes|=d,F=j.alternate,F!==null&&(F.lanes|=d),Vg(j.return,d,i),p||(M=null);break e}j=F.next}}else if(b.tag===18){if(M=b.return,M===null)throw Error(a(341));M.lanes|=d,j=M.alternate,j!==null&&(j.lanes|=d),Vg(M,d,i),M=null}else M=b.child;if(M!==null)M.return=b;else for(M=b;M!==null;){if(M===i){M=null;break}if(b=M.sibling,b!==null){b.return=M.return,M=b;break}M=M.return}b=M}}function pl(i,l,d,p){i=null;for(var b=l,j=!1;b!==null;){if(!j){if((b.flags&524288)!==0)j=!0;else if((b.flags&262144)!==0)break}if(b.tag===10){var M=b.alternate;if(M===null)throw Error(a(387));if(M=M.memoizedProps,M!==null){var F=b.type;Vs(b.pendingProps.value,M.value)||(i!==null?i.push(F):i=[F])}}else if(b===Q.current){if(M=b.alternate,M===null)throw Error(a(387));M.memoizedState.memoizedState!==b.memoizedState.memoizedState&&(i!==null?i.push(Su):i=[Su])}b=b.return}i!==null&&Hg(l,i,d,p),l.flags|=262144}function xf(i){for(i=i.firstContext;i!==null;){if(!Vs(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function lo(i){oo=i,Ar=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function ss(i){return d1(oo,i)}function bf(i,l){return oo===null&&lo(i),d1(i,l)}function d1(i,l){var d=l._currentValue;if(l={context:l,memoizedValue:d,next:null},Ar===null){if(i===null)throw Error(a(308));Ar=l,i.dependencies={lanes:0,firstContext:l},i.flags|=524288}else Ar=Ar.next=l;return d}var KL=typeof AbortController<"u"?AbortController:function(){var i=[],l=this.signal={aborted:!1,addEventListener:function(d,p){i.push(p)}};this.abort=function(){l.aborted=!0,i.forEach(function(d){return d()})}},YL=e.unstable_scheduleCallback,XL=e.unstable_NormalPriority,zn={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qg(){return{controller:new KL,data:new Map,refCount:0}}function Jc(i){i.refCount--,i.refCount===0&&YL(XL,function(){i.controller.abort()})}var eu=null,Wg=0,gl=0,vl=null;function QL(i,l){if(eu===null){var d=eu=[];Wg=0,gl=Kv(),vl={status:"pending",value:void 0,then:function(p){d.push(p)}}}return Wg++,l.then(f1,f1),l}function f1(){if(--Wg===0&&eu!==null){vl!==null&&(vl.status="fulfilled");var i=eu;eu=null,gl=0,vl=null;for(var l=0;l<i.length;l++)(0,i[l])()}}function JL(i,l){var d=[],p={status:"pending",value:null,reason:null,then:function(b){d.push(b)}};return i.then(function(){p.status="fulfilled",p.value=l;for(var b=0;b<d.length;b++)(0,d[b])(l)},function(b){for(p.status="rejected",p.reason=b,b=0;b<d.length;b++)(0,d[b])(void 0)}),p}var h1=O.S;O.S=function(i,l){YN=Ie(),typeof l=="object"&&l!==null&&typeof l.then=="function"&&QL(i,l),h1!==null&&h1(i,l)};var co=L(null);function Gg(){var i=co.current;return i!==null?i:an.pooledCache}function wf(i,l){l===null?K(co,co.current):K(co,l.pool)}function m1(){var i=Gg();return i===null?null:{parent:zn._currentValue,pool:i}}var yl=Error(a(460)),Zg=Error(a(474)),jf=Error(a(542)),Nf={then:function(){}};function p1(i){return i=i.status,i==="fulfilled"||i==="rejected"}function g1(i,l,d){switch(d=i[d],d===void 0?i.push(l):d!==l&&(l.then(kr,kr),l=d),l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,y1(i),i;default:if(typeof l.status=="string")l.then(kr,kr);else{if(i=an,i!==null&&100<i.shellSuspendCounter)throw Error(a(482));i=l,i.status="pending",i.then(function(p){if(l.status==="pending"){var b=l;b.status="fulfilled",b.value=p}},function(p){if(l.status==="pending"){var b=l;b.status="rejected",b.reason=p}})}switch(l.status){case"fulfilled":return l.value;case"rejected":throw i=l.reason,y1(i),i}throw fo=l,yl}}function uo(i){try{var l=i._init;return l(i._payload)}catch(d){throw d!==null&&typeof d=="object"&&typeof d.then=="function"?(fo=d,yl):d}}var fo=null;function v1(){if(fo===null)throw Error(a(459));var i=fo;return fo=null,i}function y1(i){if(i===yl||i===jf)throw Error(a(483))}var xl=null,tu=0;function kf(i){var l=tu;return tu+=1,xl===null&&(xl=[]),g1(xl,i,l)}function nu(i,l){l=l.props.ref,i.ref=l!==void 0?l:null}function Sf(i,l){throw l.$$typeof===y?Error(a(525)):(i=Object.prototype.toString.call(l),Error(a(31,i==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":i)))}function x1(i){function l(ie,se){if(i){var oe=ie.deletions;oe===null?(ie.deletions=[se],ie.flags|=16):oe.push(se)}}function d(ie,se){if(!i)return null;for(;se!==null;)l(ie,se),se=se.sibling;return null}function p(ie){for(var se=new Map;ie!==null;)ie.key!==null?se.set(ie.key,ie):se.set(ie.index,ie),ie=ie.sibling;return se}function b(ie,se){return ie=Cr(ie,se),ie.index=0,ie.sibling=null,ie}function j(ie,se,oe){return ie.index=oe,i?(oe=ie.alternate,oe!==null?(oe=oe.index,oe<se?(ie.flags|=67108866,se):oe):(ie.flags|=67108866,se)):(ie.flags|=1048576,se)}function M(ie){return i&&ie.alternate===null&&(ie.flags|=67108866),ie}function F(ie,se,oe,we){return se===null||se.tag!==6?(se=Pg(oe,ie.mode,we),se.return=ie,se):(se=b(se,oe),se.return=ie,se)}function J(ie,se,oe,we){var nt=oe.type;return nt===C?ye(ie,se,oe.props.children,we,oe.key):se!==null&&(se.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===P&&uo(nt)===se.type)?(se=b(se,oe.props),nu(se,oe),se.return=ie,se):(se=vf(oe.type,oe.key,oe.props,null,ie.mode,we),nu(se,oe),se.return=ie,se)}function le(ie,se,oe,we){return se===null||se.tag!==4||se.stateNode.containerInfo!==oe.containerInfo||se.stateNode.implementation!==oe.implementation?(se=Dg(oe,ie.mode,we),se.return=ie,se):(se=b(se,oe.children||[]),se.return=ie,se)}function ye(ie,se,oe,we,nt){return se===null||se.tag!==7?(se=ro(oe,ie.mode,we,nt),se.return=ie,se):(se=b(se,oe),se.return=ie,se)}function je(ie,se,oe){if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return se=Pg(""+se,ie.mode,oe),se.return=ie,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case x:return oe=vf(se.type,se.key,se.props,null,ie.mode,oe),nu(oe,se),oe.return=ie,oe;case w:return se=Dg(se,ie.mode,oe),se.return=ie,se;case P:return se=uo(se),je(ie,se,oe)}if(Z(se)||U(se))return se=ro(se,ie.mode,oe,null),se.return=ie,se;if(typeof se.then=="function")return je(ie,kf(se),oe);if(se.$$typeof===k)return je(ie,bf(ie,se),oe);Sf(ie,se)}return null}function ue(ie,se,oe,we){var nt=se!==null?se.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint")return nt!==null?null:F(ie,se,""+oe,we);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case x:return oe.key===nt?J(ie,se,oe,we):null;case w:return oe.key===nt?le(ie,se,oe,we):null;case P:return oe=uo(oe),ue(ie,se,oe,we)}if(Z(oe)||U(oe))return nt!==null?null:ye(ie,se,oe,we,null);if(typeof oe.then=="function")return ue(ie,se,kf(oe),we);if(oe.$$typeof===k)return ue(ie,se,bf(ie,oe),we);Sf(ie,oe)}return null}function fe(ie,se,oe,we,nt){if(typeof we=="string"&&we!==""||typeof we=="number"||typeof we=="bigint")return ie=ie.get(oe)||null,F(se,ie,""+we,nt);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case x:return ie=ie.get(we.key===null?oe:we.key)||null,J(se,ie,we,nt);case w:return ie=ie.get(we.key===null?oe:we.key)||null,le(se,ie,we,nt);case P:return we=uo(we),fe(ie,se,oe,we,nt)}if(Z(we)||U(we))return ie=ie.get(oe)||null,ye(se,ie,we,nt,null);if(typeof we.then=="function")return fe(ie,se,oe,kf(we),nt);if(we.$$typeof===k)return fe(ie,se,oe,bf(se,we),nt);Sf(se,we)}return null}function Ze(ie,se,oe,we){for(var nt=null,Ut=null,et=se,wt=se=0,_t=null;et!==null&&wt<oe.length;wt++){et.index>wt?(_t=et,et=null):_t=et.sibling;var Ft=ue(ie,et,oe[wt],we);if(Ft===null){et===null&&(et=_t);break}i&&et&&Ft.alternate===null&&l(ie,et),se=j(Ft,se,wt),Ut===null?nt=Ft:Ut.sibling=Ft,Ut=Ft,et=_t}if(wt===oe.length)return d(ie,et),$t&&Er(ie,wt),nt;if(et===null){for(;wt<oe.length;wt++)et=je(ie,oe[wt],we),et!==null&&(se=j(et,se,wt),Ut===null?nt=et:Ut.sibling=et,Ut=et);return $t&&Er(ie,wt),nt}for(et=p(et);wt<oe.length;wt++)_t=fe(et,ie,wt,oe[wt],we),_t!==null&&(i&&_t.alternate!==null&&et.delete(_t.key===null?wt:_t.key),se=j(_t,se,wt),Ut===null?nt=_t:Ut.sibling=_t,Ut=_t);return i&&et.forEach(function(xi){return l(ie,xi)}),$t&&Er(ie,wt),nt}function ot(ie,se,oe,we){if(oe==null)throw Error(a(151));for(var nt=null,Ut=null,et=se,wt=se=0,_t=null,Ft=oe.next();et!==null&&!Ft.done;wt++,Ft=oe.next()){et.index>wt?(_t=et,et=null):_t=et.sibling;var xi=ue(ie,et,Ft.value,we);if(xi===null){et===null&&(et=_t);break}i&&et&&xi.alternate===null&&l(ie,et),se=j(xi,se,wt),Ut===null?nt=xi:Ut.sibling=xi,Ut=xi,et=_t}if(Ft.done)return d(ie,et),$t&&Er(ie,wt),nt;if(et===null){for(;!Ft.done;wt++,Ft=oe.next())Ft=je(ie,Ft.value,we),Ft!==null&&(se=j(Ft,se,wt),Ut===null?nt=Ft:Ut.sibling=Ft,Ut=Ft);return $t&&Er(ie,wt),nt}for(et=p(et);!Ft.done;wt++,Ft=oe.next())Ft=fe(et,ie,wt,Ft.value,we),Ft!==null&&(i&&Ft.alternate!==null&&et.delete(Ft.key===null?wt:Ft.key),se=j(Ft,se,wt),Ut===null?nt=Ft:Ut.sibling=Ft,Ut=Ft);return i&&et.forEach(function(u4){return l(ie,u4)}),$t&&Er(ie,wt),nt}function en(ie,se,oe,we){if(typeof oe=="object"&&oe!==null&&oe.type===C&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case x:e:{for(var nt=oe.key;se!==null;){if(se.key===nt){if(nt=oe.type,nt===C){if(se.tag===7){d(ie,se.sibling),we=b(se,oe.props.children),we.return=ie,ie=we;break e}}else if(se.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===P&&uo(nt)===se.type){d(ie,se.sibling),we=b(se,oe.props),nu(we,oe),we.return=ie,ie=we;break e}d(ie,se);break}else l(ie,se);se=se.sibling}oe.type===C?(we=ro(oe.props.children,ie.mode,we,oe.key),we.return=ie,ie=we):(we=vf(oe.type,oe.key,oe.props,null,ie.mode,we),nu(we,oe),we.return=ie,ie=we)}return M(ie);case w:e:{for(nt=oe.key;se!==null;){if(se.key===nt)if(se.tag===4&&se.stateNode.containerInfo===oe.containerInfo&&se.stateNode.implementation===oe.implementation){d(ie,se.sibling),we=b(se,oe.children||[]),we.return=ie,ie=we;break e}else{d(ie,se);break}else l(ie,se);se=se.sibling}we=Dg(oe,ie.mode,we),we.return=ie,ie=we}return M(ie);case P:return oe=uo(oe),en(ie,se,oe,we)}if(Z(oe))return Ze(ie,se,oe,we);if(U(oe)){if(nt=U(oe),typeof nt!="function")throw Error(a(150));return oe=nt.call(oe),ot(ie,se,oe,we)}if(typeof oe.then=="function")return en(ie,se,kf(oe),we);if(oe.$$typeof===k)return en(ie,se,bf(ie,oe),we);Sf(ie,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"||typeof oe=="bigint"?(oe=""+oe,se!==null&&se.tag===6?(d(ie,se.sibling),we=b(se,oe),we.return=ie,ie=we):(d(ie,se),we=Pg(oe,ie.mode,we),we.return=ie,ie=we),M(ie)):d(ie,se)}return function(ie,se,oe,we){try{tu=0;var nt=en(ie,se,oe,we);return xl=null,nt}catch(et){if(et===yl||et===jf)throw et;var Ut=Hs(29,et,null,ie.mode);return Ut.lanes=we,Ut.return=ie,Ut}}}var ho=x1(!0),b1=x1(!1),ni=!1;function Kg(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Yg(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function si(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function ai(i,l,d){var p=i.updateQueue;if(p===null)return null;if(p=p.shared,(Vt&2)!==0){var b=p.pending;return b===null?l.next=l:(l.next=b.next,b.next=l),p.pending=l,l=gf(i),s1(i,null,d),l}return pf(i,p,l,d),gf(i)}function su(i,l,d){if(l=l.updateQueue,l!==null&&(l=l.shared,(d&4194048)!==0)){var p=l.lanes;p&=i.pendingLanes,d|=p,l.lanes=d,la(i,d)}}function Xg(i,l){var d=i.updateQueue,p=i.alternate;if(p!==null&&(p=p.updateQueue,d===p)){var b=null,j=null;if(d=d.firstBaseUpdate,d!==null){do{var M={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};j===null?b=j=M:j=j.next=M,d=d.next}while(d!==null);j===null?b=j=l:j=j.next=l}else b=j=l;d={baseState:p.baseState,firstBaseUpdate:b,lastBaseUpdate:j,shared:p.shared,callbacks:p.callbacks},i.updateQueue=d;return}i=d.lastBaseUpdate,i===null?d.firstBaseUpdate=l:i.next=l,d.lastBaseUpdate=l}var Qg=!1;function au(){if(Qg){var i=vl;if(i!==null)throw i}}function ru(i,l,d,p){Qg=!1;var b=i.updateQueue;ni=!1;var j=b.firstBaseUpdate,M=b.lastBaseUpdate,F=b.shared.pending;if(F!==null){b.shared.pending=null;var J=F,le=J.next;J.next=null,M===null?j=le:M.next=le,M=J;var ye=i.alternate;ye!==null&&(ye=ye.updateQueue,F=ye.lastBaseUpdate,F!==M&&(F===null?ye.firstBaseUpdate=le:F.next=le,ye.lastBaseUpdate=J))}if(j!==null){var je=b.baseState;M=0,ye=le=J=null,F=j;do{var ue=F.lane&-536870913,fe=ue!==F.lane;if(fe?(It&ue)===ue:(p&ue)===ue){ue!==0&&ue===gl&&(Qg=!0),ye!==null&&(ye=ye.next={lane:0,tag:F.tag,payload:F.payload,callback:null,next:null});e:{var Ze=i,ot=F;ue=l;var en=d;switch(ot.tag){case 1:if(Ze=ot.payload,typeof Ze=="function"){je=Ze.call(en,je,ue);break e}je=Ze;break e;case 3:Ze.flags=Ze.flags&-65537|128;case 0:if(Ze=ot.payload,ue=typeof Ze=="function"?Ze.call(en,je,ue):Ze,ue==null)break e;je=v({},je,ue);break e;case 2:ni=!0}}ue=F.callback,ue!==null&&(i.flags|=64,fe&&(i.flags|=8192),fe=b.callbacks,fe===null?b.callbacks=[ue]:fe.push(ue))}else fe={lane:ue,tag:F.tag,payload:F.payload,callback:F.callback,next:null},ye===null?(le=ye=fe,J=je):ye=ye.next=fe,M|=ue;if(F=F.next,F===null){if(F=b.shared.pending,F===null)break;fe=F,F=fe.next,fe.next=null,b.lastBaseUpdate=fe,b.shared.pending=null}}while(!0);ye===null&&(J=je),b.baseState=J,b.firstBaseUpdate=le,b.lastBaseUpdate=ye,j===null&&(b.shared.lanes=0),ci|=M,i.lanes=M,i.memoizedState=je}}function w1(i,l){if(typeof i!="function")throw Error(a(191,i));i.call(l)}function j1(i,l){var d=i.callbacks;if(d!==null)for(i.callbacks=null,i=0;i<d.length;i++)w1(d[i],l)}var bl=L(null),Cf=L(0);function N1(i,l){i=Lr,K(Cf,i),K(bl,l),Lr=i|l.baseLanes}function Jg(){K(Cf,Lr),K(bl,bl.current)}function ev(){Lr=Cf.current,q(bl),q(Cf)}var qs=L(null),ya=null;function ri(i){var l=i.alternate;K(In,In.current&1),K(qs,i),ya===null&&(l===null||bl.current!==null||l.memoizedState!==null)&&(ya=i)}function tv(i){K(In,In.current),K(qs,i),ya===null&&(ya=i)}function k1(i){i.tag===22?(K(In,In.current),K(qs,i),ya===null&&(ya=i)):ii()}function ii(){K(In,In.current),K(qs,qs.current)}function Ws(i){q(qs),ya===i&&(ya=null),q(In)}var In=L(0);function Ef(i){for(var l=i;l!==null;){if(l.tag===13){var d=l.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||oy(d)||ly(d)))return l}else if(l.tag===19&&(l.memoizedProps.revealOrder==="forwards"||l.memoizedProps.revealOrder==="backwards"||l.memoizedProps.revealOrder==="unstable_legacy-backwards"||l.memoizedProps.revealOrder==="together")){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Mr=0,vt=null,Qt=null,Bn=null,Af=!1,wl=!1,mo=!1,Tf=0,iu=0,jl=null,e5=0;function Cn(){throw Error(a(321))}function nv(i,l){if(l===null)return!1;for(var d=0;d<l.length&&d<i.length;d++)if(!Vs(i[d],l[d]))return!1;return!0}function sv(i,l,d,p,b,j){return Mr=j,vt=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,O.H=i===null||i.memoizedState===null?oN:yv,mo=!1,j=d(p,b),mo=!1,wl&&(j=C1(l,d,p,b)),S1(i),j}function S1(i){O.H=cu;var l=Qt!==null&&Qt.next!==null;if(Mr=0,Bn=Qt=vt=null,Af=!1,iu=0,jl=null,l)throw Error(a(300));i===null||Un||(i=i.dependencies,i!==null&&xf(i)&&(Un=!0))}function C1(i,l,d,p){vt=i;var b=0;do{if(wl&&(jl=null),iu=0,wl=!1,25<=b)throw Error(a(301));if(b+=1,Bn=Qt=null,i.updateQueue!=null){var j=i.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}O.H=lN,j=l(d,p)}while(wl);return j}function t5(){var i=O.H,l=i.useState()[0];return l=typeof l.then=="function"?ou(l):l,i=i.useState()[0],(Qt!==null?Qt.memoizedState:null)!==i&&(vt.flags|=1024),l}function av(){var i=Tf!==0;return Tf=0,i}function rv(i,l,d){l.updateQueue=i.updateQueue,l.flags&=-2053,i.lanes&=~d}function iv(i){if(Af){for(i=i.memoizedState;i!==null;){var l=i.queue;l!==null&&(l.pending=null),i=i.next}Af=!1}Mr=0,Bn=Qt=vt=null,wl=!1,iu=Tf=0,jl=null}function Ns(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bn===null?vt.memoizedState=Bn=i:Bn=Bn.next=i,Bn}function _n(){if(Qt===null){var i=vt.alternate;i=i!==null?i.memoizedState:null}else i=Qt.next;var l=Bn===null?vt.memoizedState:Bn.next;if(l!==null)Bn=l,Qt=i;else{if(i===null)throw vt.alternate===null?Error(a(467)):Error(a(310));Qt=i,i={memoizedState:Qt.memoizedState,baseState:Qt.baseState,baseQueue:Qt.baseQueue,queue:Qt.queue,next:null},Bn===null?vt.memoizedState=Bn=i:Bn=Bn.next=i}return Bn}function Mf(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ou(i){var l=iu;return iu+=1,jl===null&&(jl=[]),i=g1(jl,i,l),l=vt,(Bn===null?l.memoizedState:Bn.next)===null&&(l=l.alternate,O.H=l===null||l.memoizedState===null?oN:yv),i}function Rf(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return ou(i);if(i.$$typeof===k)return ss(i)}throw Error(a(438,String(i)))}function ov(i){var l=null,d=vt.updateQueue;if(d!==null&&(l=d.memoCache),l==null){var p=vt.alternate;p!==null&&(p=p.updateQueue,p!==null&&(p=p.memoCache,p!=null&&(l={data:p.data.map(function(b){return b.slice()}),index:0})))}if(l==null&&(l={data:[],index:0}),d===null&&(d=Mf(),vt.updateQueue=d),d.memoCache=l,d=l.data[l.index],d===void 0)for(d=l.data[l.index]=Array(i),p=0;p<i;p++)d[p]=H;return l.index++,d}function Rr(i,l){return typeof l=="function"?l(i):l}function If(i){var l=_n();return lv(l,Qt,i)}function lv(i,l,d){var p=i.queue;if(p===null)throw Error(a(311));p.lastRenderedReducer=d;var b=i.baseQueue,j=p.pending;if(j!==null){if(b!==null){var M=b.next;b.next=j.next,j.next=M}l.baseQueue=b=j,p.pending=null}if(j=i.baseState,b===null)i.memoizedState=j;else{l=b.next;var F=M=null,J=null,le=l,ye=!1;do{var je=le.lane&-536870913;if(je!==le.lane?(It&je)===je:(Mr&je)===je){var ue=le.revertLane;if(ue===0)J!==null&&(J=J.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),je===gl&&(ye=!0);else if((Mr&ue)===ue){le=le.next,ue===gl&&(ye=!0);continue}else je={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},J===null?(F=J=je,M=j):J=J.next=je,vt.lanes|=ue,ci|=ue;je=le.action,mo&&d(j,je),j=le.hasEagerState?le.eagerState:d(j,je)}else ue={lane:je,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},J===null?(F=J=ue,M=j):J=J.next=ue,vt.lanes|=je,ci|=je;le=le.next}while(le!==null&&le!==l);if(J===null?M=j:J.next=F,!Vs(j,i.memoizedState)&&(Un=!0,ye&&(d=vl,d!==null)))throw d;i.memoizedState=j,i.baseState=M,i.baseQueue=J,p.lastRenderedState=j}return b===null&&(p.lanes=0),[i.memoizedState,p.dispatch]}function cv(i){var l=_n(),d=l.queue;if(d===null)throw Error(a(311));d.lastRenderedReducer=i;var p=d.dispatch,b=d.pending,j=l.memoizedState;if(b!==null){d.pending=null;var M=b=b.next;do j=i(j,M.action),M=M.next;while(M!==b);Vs(j,l.memoizedState)||(Un=!0),l.memoizedState=j,l.baseQueue===null&&(l.baseState=j),d.lastRenderedState=j}return[j,p]}function E1(i,l,d){var p=vt,b=_n(),j=$t;if(j){if(d===void 0)throw Error(a(407));d=d()}else d=l();var M=!Vs((Qt||b).memoizedState,d);if(M&&(b.memoizedState=d,Un=!0),b=b.queue,fv(M1.bind(null,p,b,i),[i]),b.getSnapshot!==l||M||Bn!==null&&Bn.memoizedState.tag&1){if(p.flags|=2048,Nl(9,{destroy:void 0},T1.bind(null,p,b,d,l),null),an===null)throw Error(a(349));j||(Mr&127)!==0||A1(p,l,d)}return d}function A1(i,l,d){i.flags|=16384,i={getSnapshot:l,value:d},l=vt.updateQueue,l===null?(l=Mf(),vt.updateQueue=l,l.stores=[i]):(d=l.stores,d===null?l.stores=[i]:d.push(i))}function T1(i,l,d,p){l.value=d,l.getSnapshot=p,R1(l)&&I1(i)}function M1(i,l,d){return d(function(){R1(l)&&I1(i)})}function R1(i){var l=i.getSnapshot;i=i.value;try{var d=l();return!Vs(i,d)}catch{return!0}}function I1(i){var l=ao(i,2);l!==null&&Ds(l,i,2)}function uv(i){var l=Ns();if(typeof i=="function"){var d=i;if(i=d(),mo){te(!0);try{d()}finally{te(!1)}}}return l.memoizedState=l.baseState=i,l.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rr,lastRenderedState:i},l}function _1(i,l,d,p){return i.baseState=d,lv(i,Qt,typeof p=="function"?p:Rr)}function n5(i,l,d,p,b){if($f(i))throw Error(a(485));if(i=l.action,i!==null){var j={payload:b,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(M){j.listeners.push(M)}};O.T!==null?d(!0):j.isTransition=!1,p(j),d=l.pending,d===null?(j.next=l.pending=j,O1(l,j)):(j.next=d.next,l.pending=d.next=j)}}function O1(i,l){var d=l.action,p=l.payload,b=i.state;if(l.isTransition){var j=O.T,M={};O.T=M;try{var F=d(b,p),J=O.S;J!==null&&J(M,F),$1(i,l,F)}catch(le){dv(i,l,le)}finally{j!==null&&M.types!==null&&(j.types=M.types),O.T=j}}else try{j=d(b,p),$1(i,l,j)}catch(le){dv(i,l,le)}}function $1(i,l,d){d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(function(p){P1(i,l,p)},function(p){return dv(i,l,p)}):P1(i,l,d)}function P1(i,l,d){l.status="fulfilled",l.value=d,D1(l),i.state=d,l=i.pending,l!==null&&(d=l.next,d===l?i.pending=null:(d=d.next,l.next=d,O1(i,d)))}function dv(i,l,d){var p=i.pending;if(i.pending=null,p!==null){p=p.next;do l.status="rejected",l.reason=d,D1(l),l=l.next;while(l!==p)}i.action=null}function D1(i){i=i.listeners;for(var l=0;l<i.length;l++)(0,i[l])()}function L1(i,l){return l}function z1(i,l){if($t){var d=an.formState;if(d!==null){e:{var p=vt;if($t){if(hn){t:{for(var b=hn,j=va;b.nodeType!==8;){if(!j){b=null;break t}if(b=xa(b.nextSibling),b===null){b=null;break t}}j=b.data,b=j==="F!"||j==="F"?b:null}if(b){hn=xa(b.nextSibling),p=b.data==="F!";break e}}ei(p)}p=!1}p&&(l=d[0])}}return d=Ns(),d.memoizedState=d.baseState=l,p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:L1,lastRenderedState:l},d.queue=p,d=aN.bind(null,vt,p),p.dispatch=d,p=uv(!1),j=vv.bind(null,vt,!1,p.queue),p=Ns(),b={state:l,dispatch:null,action:i,pending:null},p.queue=b,d=n5.bind(null,vt,b,j,d),b.dispatch=d,p.memoizedState=i,[l,d,!1]}function B1(i){var l=_n();return U1(l,Qt,i)}function U1(i,l,d){if(l=lv(i,l,L1)[0],i=If(Rr)[0],typeof l=="object"&&l!==null&&typeof l.then=="function")try{var p=ou(l)}catch(M){throw M===yl?jf:M}else p=l;l=_n();var b=l.queue,j=b.dispatch;return d!==l.memoizedState&&(vt.flags|=2048,Nl(9,{destroy:void 0},s5.bind(null,b,d),null)),[p,j,i]}function s5(i,l){i.action=l}function F1(i){var l=_n(),d=Qt;if(d!==null)return U1(l,d,i);_n(),l=l.memoizedState,d=_n();var p=d.queue.dispatch;return d.memoizedState=i,[l,p,!1]}function Nl(i,l,d,p){return i={tag:i,create:d,deps:p,inst:l,next:null},l=vt.updateQueue,l===null&&(l=Mf(),vt.updateQueue=l),d=l.lastEffect,d===null?l.lastEffect=i.next=i:(p=d.next,d.next=i,i.next=p,l.lastEffect=i),i}function V1(){return _n().memoizedState}function _f(i,l,d,p){var b=Ns();vt.flags|=i,b.memoizedState=Nl(1|l,{destroy:void 0},d,p===void 0?null:p)}function Of(i,l,d,p){var b=_n();p=p===void 0?null:p;var j=b.memoizedState.inst;Qt!==null&&p!==null&&nv(p,Qt.memoizedState.deps)?b.memoizedState=Nl(l,j,d,p):(vt.flags|=i,b.memoizedState=Nl(1|l,j,d,p))}function H1(i,l){_f(8390656,8,i,l)}function fv(i,l){Of(2048,8,i,l)}function a5(i){vt.flags|=4;var l=vt.updateQueue;if(l===null)l=Mf(),vt.updateQueue=l,l.events=[i];else{var d=l.events;d===null?l.events=[i]:d.push(i)}}function q1(i){var l=_n().memoizedState;return a5({ref:l,nextImpl:i}),function(){if((Vt&2)!==0)throw Error(a(440));return l.impl.apply(void 0,arguments)}}function W1(i,l){return Of(4,2,i,l)}function G1(i,l){return Of(4,4,i,l)}function Z1(i,l){if(typeof l=="function"){i=i();var d=l(i);return function(){typeof d=="function"?d():l(null)}}if(l!=null)return i=i(),l.current=i,function(){l.current=null}}function K1(i,l,d){d=d!=null?d.concat([i]):null,Of(4,4,Z1.bind(null,l,i),d)}function hv(){}function Y1(i,l){var d=_n();l=l===void 0?null:l;var p=d.memoizedState;return l!==null&&nv(l,p[1])?p[0]:(d.memoizedState=[i,l],i)}function X1(i,l){var d=_n();l=l===void 0?null:l;var p=d.memoizedState;if(l!==null&&nv(l,p[1]))return p[0];if(p=i(),mo){te(!0);try{i()}finally{te(!1)}}return d.memoizedState=[p,l],p}function mv(i,l,d){return d===void 0||(Mr&1073741824)!==0&&(It&261930)===0?i.memoizedState=l:(i.memoizedState=d,i=QN(),vt.lanes|=i,ci|=i,d)}function Q1(i,l,d,p){return Vs(d,l)?d:bl.current!==null?(i=mv(i,d,p),Vs(i,l)||(Un=!0),i):(Mr&42)===0||(Mr&1073741824)!==0&&(It&261930)===0?(Un=!0,i.memoizedState=d):(i=QN(),vt.lanes|=i,ci|=i,l)}function J1(i,l,d,p,b){var j=z.p;z.p=j!==0&&8>j?j:8;var M=O.T,F={};O.T=F,vv(i,!1,l,d);try{var J=b(),le=O.S;if(le!==null&&le(F,J),J!==null&&typeof J=="object"&&typeof J.then=="function"){var ye=JL(J,p);lu(i,l,ye,Ks(i))}else lu(i,l,p,Ks(i))}catch(je){lu(i,l,{then:function(){},status:"rejected",reason:je},Ks())}finally{z.p=j,M!==null&&F.types!==null&&(M.types=F.types),O.T=M}}function r5(){}function pv(i,l,d,p){if(i.tag!==5)throw Error(a(476));var b=eN(i).queue;J1(i,b,l,B,d===null?r5:function(){return tN(i),d(p)})}function eN(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rr,lastRenderedState:B},next:null};var d={};return l.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rr,lastRenderedState:d},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function tN(i){var l=eN(i);l.next===null&&(l=i.alternate.memoizedState),lu(i,l.next.queue,{},Ks())}function gv(){return ss(Su)}function nN(){return _n().memoizedState}function sN(){return _n().memoizedState}function i5(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var d=Ks();i=si(d);var p=ai(l,i,d);p!==null&&(Ds(p,l,d),su(p,l,d)),l={cache:qg()},i.payload=l;return}l=l.return}}function o5(i,l,d){var p=Ks();d={lane:p,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},$f(i)?rN(l,d):(d=Og(i,l,d,p),d!==null&&(Ds(d,i,p),iN(d,l,p)))}function aN(i,l,d){var p=Ks();lu(i,l,d,p)}function lu(i,l,d,p){var b={lane:p,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if($f(i))rN(l,b);else{var j=i.alternate;if(i.lanes===0&&(j===null||j.lanes===0)&&(j=l.lastRenderedReducer,j!==null))try{var M=l.lastRenderedState,F=j(M,d);if(b.hasEagerState=!0,b.eagerState=F,Vs(F,M))return pf(i,l,b,0),an===null&&mf(),!1}catch{}if(d=Og(i,l,b,p),d!==null)return Ds(d,i,p),iN(d,l,p),!0}return!1}function vv(i,l,d,p){if(p={lane:2,revertLane:Kv(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},$f(i)){if(l)throw Error(a(479))}else l=Og(i,d,p,2),l!==null&&Ds(l,i,2)}function $f(i){var l=i.alternate;return i===vt||l!==null&&l===vt}function rN(i,l){wl=Af=!0;var d=i.pending;d===null?l.next=l:(l.next=d.next,d.next=l),i.pending=l}function iN(i,l,d){if((d&4194048)!==0){var p=l.lanes;p&=i.pendingLanes,d|=p,l.lanes=d,la(i,d)}}var cu={readContext:ss,use:Rf,useCallback:Cn,useContext:Cn,useEffect:Cn,useImperativeHandle:Cn,useLayoutEffect:Cn,useInsertionEffect:Cn,useMemo:Cn,useReducer:Cn,useRef:Cn,useState:Cn,useDebugValue:Cn,useDeferredValue:Cn,useTransition:Cn,useSyncExternalStore:Cn,useId:Cn,useHostTransitionStatus:Cn,useFormState:Cn,useActionState:Cn,useOptimistic:Cn,useMemoCache:Cn,useCacheRefresh:Cn};cu.useEffectEvent=Cn;var oN={readContext:ss,use:Rf,useCallback:function(i,l){return Ns().memoizedState=[i,l===void 0?null:l],i},useContext:ss,useEffect:H1,useImperativeHandle:function(i,l,d){d=d!=null?d.concat([i]):null,_f(4194308,4,Z1.bind(null,l,i),d)},useLayoutEffect:function(i,l){return _f(4194308,4,i,l)},useInsertionEffect:function(i,l){_f(4,2,i,l)},useMemo:function(i,l){var d=Ns();l=l===void 0?null:l;var p=i();if(mo){te(!0);try{i()}finally{te(!1)}}return d.memoizedState=[p,l],p},useReducer:function(i,l,d){var p=Ns();if(d!==void 0){var b=d(l);if(mo){te(!0);try{d(l)}finally{te(!1)}}}else b=l;return p.memoizedState=p.baseState=b,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:b},p.queue=i,i=i.dispatch=o5.bind(null,vt,i),[p.memoizedState,i]},useRef:function(i){var l=Ns();return i={current:i},l.memoizedState=i},useState:function(i){i=uv(i);var l=i.queue,d=aN.bind(null,vt,l);return l.dispatch=d,[i.memoizedState,d]},useDebugValue:hv,useDeferredValue:function(i,l){var d=Ns();return mv(d,i,l)},useTransition:function(){var i=uv(!1);return i=J1.bind(null,vt,i.queue,!0,!1),Ns().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,d){var p=vt,b=Ns();if($t){if(d===void 0)throw Error(a(407));d=d()}else{if(d=l(),an===null)throw Error(a(349));(It&127)!==0||A1(p,l,d)}b.memoizedState=d;var j={value:d,getSnapshot:l};return b.queue=j,H1(M1.bind(null,p,j,i),[i]),p.flags|=2048,Nl(9,{destroy:void 0},T1.bind(null,p,j,d,l),null),d},useId:function(){var i=Ns(),l=an.identifierPrefix;if($t){var d=Ja,p=Qa;d=(p&~(1<<32-he(p)-1)).toString(32)+d,l="_"+l+"R_"+d,d=Tf++,0<d&&(l+="H"+d.toString(32)),l+="_"}else d=e5++,l="_"+l+"r_"+d.toString(32)+"_";return i.memoizedState=l},useHostTransitionStatus:gv,useFormState:z1,useActionState:z1,useOptimistic:function(i){var l=Ns();l.memoizedState=l.baseState=i;var d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return l.queue=d,l=vv.bind(null,vt,!0,d),d.dispatch=l,[i,l]},useMemoCache:ov,useCacheRefresh:function(){return Ns().memoizedState=i5.bind(null,vt)},useEffectEvent:function(i){var l=Ns(),d={impl:i};return l.memoizedState=d,function(){if((Vt&2)!==0)throw Error(a(440));return d.impl.apply(void 0,arguments)}}},yv={readContext:ss,use:Rf,useCallback:Y1,useContext:ss,useEffect:fv,useImperativeHandle:K1,useInsertionEffect:W1,useLayoutEffect:G1,useMemo:X1,useReducer:If,useRef:V1,useState:function(){return If(Rr)},useDebugValue:hv,useDeferredValue:function(i,l){var d=_n();return Q1(d,Qt.memoizedState,i,l)},useTransition:function(){var i=If(Rr)[0],l=_n().memoizedState;return[typeof i=="boolean"?i:ou(i),l]},useSyncExternalStore:E1,useId:nN,useHostTransitionStatus:gv,useFormState:B1,useActionState:B1,useOptimistic:function(i,l){var d=_n();return _1(d,Qt,i,l)},useMemoCache:ov,useCacheRefresh:sN};yv.useEffectEvent=q1;var lN={readContext:ss,use:Rf,useCallback:Y1,useContext:ss,useEffect:fv,useImperativeHandle:K1,useInsertionEffect:W1,useLayoutEffect:G1,useMemo:X1,useReducer:cv,useRef:V1,useState:function(){return cv(Rr)},useDebugValue:hv,useDeferredValue:function(i,l){var d=_n();return Qt===null?mv(d,i,l):Q1(d,Qt.memoizedState,i,l)},useTransition:function(){var i=cv(Rr)[0],l=_n().memoizedState;return[typeof i=="boolean"?i:ou(i),l]},useSyncExternalStore:E1,useId:nN,useHostTransitionStatus:gv,useFormState:F1,useActionState:F1,useOptimistic:function(i,l){var d=_n();return Qt!==null?_1(d,Qt,i,l):(d.baseState=i,[i,d.queue.dispatch])},useMemoCache:ov,useCacheRefresh:sN};lN.useEffectEvent=q1;function xv(i,l,d,p){l=i.memoizedState,d=d(p,l),d=d==null?l:v({},l,d),i.memoizedState=d,i.lanes===0&&(i.updateQueue.baseState=d)}var bv={enqueueSetState:function(i,l,d){i=i._reactInternals;var p=Ks(),b=si(p);b.payload=l,d!=null&&(b.callback=d),l=ai(i,b,p),l!==null&&(Ds(l,i,p),su(l,i,p))},enqueueReplaceState:function(i,l,d){i=i._reactInternals;var p=Ks(),b=si(p);b.tag=1,b.payload=l,d!=null&&(b.callback=d),l=ai(i,b,p),l!==null&&(Ds(l,i,p),su(l,i,p))},enqueueForceUpdate:function(i,l){i=i._reactInternals;var d=Ks(),p=si(d);p.tag=2,l!=null&&(p.callback=l),l=ai(i,p,d),l!==null&&(Ds(l,i,d),su(l,i,d))}};function cN(i,l,d,p,b,j,M){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(p,j,M):l.prototype&&l.prototype.isPureReactComponent?!Kc(d,p)||!Kc(b,j):!0}function uN(i,l,d,p){i=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(d,p),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(d,p),l.state!==i&&bv.enqueueReplaceState(l,l.state,null)}function po(i,l){var d=l;if("ref"in l){d={};for(var p in l)p!=="ref"&&(d[p]=l[p])}if(i=i.defaultProps){d===l&&(d=v({},d));for(var b in i)d[b]===void 0&&(d[b]=i[b])}return d}function dN(i){hf(i)}function fN(i){console.error(i)}function hN(i){hf(i)}function Pf(i,l){try{var d=i.onUncaughtError;d(l.value,{componentStack:l.stack})}catch(p){setTimeout(function(){throw p})}}function mN(i,l,d){try{var p=i.onCaughtError;p(d.value,{componentStack:d.stack,errorBoundary:l.tag===1?l.stateNode:null})}catch(b){setTimeout(function(){throw b})}}function wv(i,l,d){return d=si(d),d.tag=3,d.payload={element:null},d.callback=function(){Pf(i,l)},d}function pN(i){return i=si(i),i.tag=3,i}function gN(i,l,d,p){var b=d.type.getDerivedStateFromError;if(typeof b=="function"){var j=p.value;i.payload=function(){return b(j)},i.callback=function(){mN(l,d,p)}}var M=d.stateNode;M!==null&&typeof M.componentDidCatch=="function"&&(i.callback=function(){mN(l,d,p),typeof b!="function"&&(ui===null?ui=new Set([this]):ui.add(this));var F=p.stack;this.componentDidCatch(p.value,{componentStack:F!==null?F:""})})}function l5(i,l,d,p,b){if(d.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){if(l=d.alternate,l!==null&&pl(l,d,b,!0),d=qs.current,d!==null){switch(d.tag){case 31:case 13:return ya===null?Zf():d.alternate===null&&En===0&&(En=3),d.flags&=-257,d.flags|=65536,d.lanes=b,p===Nf?d.flags|=16384:(l=d.updateQueue,l===null?d.updateQueue=new Set([p]):l.add(p),Wv(i,p,b)),!1;case 22:return d.flags|=65536,p===Nf?d.flags|=16384:(l=d.updateQueue,l===null?(l={transitions:null,markerInstances:null,retryQueue:new Set([p])},d.updateQueue=l):(d=l.retryQueue,d===null?l.retryQueue=new Set([p]):d.add(p)),Wv(i,p,b)),!1}throw Error(a(435,d.tag))}return Wv(i,p,b),Zf(),!1}if($t)return l=qs.current,l!==null?((l.flags&65536)===0&&(l.flags|=256),l.flags|=65536,l.lanes=b,p!==Bg&&(i=Error(a(422),{cause:p}),Qc(ma(i,d)))):(p!==Bg&&(l=Error(a(423),{cause:p}),Qc(ma(l,d))),i=i.current.alternate,i.flags|=65536,b&=-b,i.lanes|=b,p=ma(p,d),b=wv(i.stateNode,p,b),Xg(i,b),En!==4&&(En=2)),!1;var j=Error(a(520),{cause:p});if(j=ma(j,d),vu===null?vu=[j]:vu.push(j),En!==4&&(En=2),l===null)return!0;p=ma(p,d),d=l;do{switch(d.tag){case 3:return d.flags|=65536,i=b&-b,d.lanes|=i,i=wv(d.stateNode,p,i),Xg(d,i),!1;case 1:if(l=d.type,j=d.stateNode,(d.flags&128)===0&&(typeof l.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(ui===null||!ui.has(j))))return d.flags|=65536,b&=-b,d.lanes|=b,b=pN(b),gN(b,i,d,p),Xg(d,b),!1}d=d.return}while(d!==null);return!1}var jv=Error(a(461)),Un=!1;function as(i,l,d,p){l.child=i===null?b1(l,null,d,p):ho(l,i.child,d,p)}function vN(i,l,d,p,b){d=d.render;var j=l.ref;if("ref"in p){var M={};for(var F in p)F!=="ref"&&(M[F]=p[F])}else M=p;return lo(l),p=sv(i,l,d,M,j,b),F=av(),i!==null&&!Un?(rv(i,l,b),Ir(i,l,b)):($t&&F&&Lg(l),l.flags|=1,as(i,l,p,b),l.child)}function yN(i,l,d,p,b){if(i===null){var j=d.type;return typeof j=="function"&&!$g(j)&&j.defaultProps===void 0&&d.compare===null?(l.tag=15,l.type=j,xN(i,l,j,p,b)):(i=vf(d.type,null,p,l,l.mode,b),i.ref=l.ref,i.return=l,l.child=i)}if(j=i.child,!Mv(i,b)){var M=j.memoizedProps;if(d=d.compare,d=d!==null?d:Kc,d(M,p)&&i.ref===l.ref)return Ir(i,l,b)}return l.flags|=1,i=Cr(j,p),i.ref=l.ref,i.return=l,l.child=i}function xN(i,l,d,p,b){if(i!==null){var j=i.memoizedProps;if(Kc(j,p)&&i.ref===l.ref)if(Un=!1,l.pendingProps=p=j,Mv(i,b))(i.flags&131072)!==0&&(Un=!0);else return l.lanes=i.lanes,Ir(i,l,b)}return Nv(i,l,d,p,b)}function bN(i,l,d,p){var b=p.children,j=i!==null?i.memoizedState:null;if(i===null&&l.stateNode===null&&(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.mode==="hidden"){if((l.flags&128)!==0){if(j=j!==null?j.baseLanes|d:d,i!==null){for(p=l.child=i.child,b=0;p!==null;)b=b|p.lanes|p.childLanes,p=p.sibling;p=b&~j}else p=0,l.child=null;return wN(i,l,j,d,p)}if((d&536870912)!==0)l.memoizedState={baseLanes:0,cachePool:null},i!==null&&wf(l,j!==null?j.cachePool:null),j!==null?N1(l,j):Jg(),k1(l);else return p=l.lanes=536870912,wN(i,l,j!==null?j.baseLanes|d:d,d,p)}else j!==null?(wf(l,j.cachePool),N1(l,j),ii(),l.memoizedState=null):(i!==null&&wf(l,null),Jg(),ii());return as(i,l,b,d),l.child}function uu(i,l){return i!==null&&i.tag===22||l.stateNode!==null||(l.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.sibling}function wN(i,l,d,p,b){var j=Gg();return j=j===null?null:{parent:zn._currentValue,pool:j},l.memoizedState={baseLanes:d,cachePool:j},i!==null&&wf(l,null),Jg(),k1(l),i!==null&&pl(i,l,p,!0),l.childLanes=b,null}function Df(i,l){return l=zf({mode:l.mode,children:l.children},i.mode),l.ref=i.ref,i.child=l,l.return=i,l}function jN(i,l,d){return ho(l,i.child,null,d),i=Df(l,l.pendingProps),i.flags|=2,Ws(l),l.memoizedState=null,i}function c5(i,l,d){var p=l.pendingProps,b=(l.flags&128)!==0;if(l.flags&=-129,i===null){if($t){if(p.mode==="hidden")return i=Df(l,p),l.lanes=536870912,uu(null,i);if(tv(l),(i=hn)?(i=Ok(i,va),i=i!==null&&i.data==="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:Qr!==null?{id:Qa,overflow:Ja}:null,retryLane:536870912,hydrationErrors:null},d=r1(i),d.return=l,l.child=d,ns=l,hn=null)):i=null,i===null)throw ei(l);return l.lanes=536870912,null}return Df(l,p)}var j=i.memoizedState;if(j!==null){var M=j.dehydrated;if(tv(l),b)if(l.flags&256)l.flags&=-257,l=jN(i,l,d);else if(l.memoizedState!==null)l.child=i.child,l.flags|=128,l=null;else throw Error(a(558));else if(Un||pl(i,l,d,!1),b=(d&i.childLanes)!==0,Un||b){if(p=an,p!==null&&(M=xs(p,d),M!==0&&M!==j.retryLane))throw j.retryLane=M,ao(i,M),Ds(p,i,M),jv;Zf(),l=jN(i,l,d)}else i=j.treeContext,hn=xa(M.nextSibling),ns=l,$t=!0,Jr=null,va=!1,i!==null&&l1(l,i),l=Df(l,p),l.flags|=4096;return l}return i=Cr(i.child,{mode:p.mode,children:p.children}),i.ref=l.ref,l.child=i,i.return=l,i}function Lf(i,l){var d=l.ref;if(d===null)i!==null&&i.ref!==null&&(l.flags|=4194816);else{if(typeof d!="function"&&typeof d!="object")throw Error(a(284));(i===null||i.ref!==d)&&(l.flags|=4194816)}}function Nv(i,l,d,p,b){return lo(l),d=sv(i,l,d,p,void 0,b),p=av(),i!==null&&!Un?(rv(i,l,b),Ir(i,l,b)):($t&&p&&Lg(l),l.flags|=1,as(i,l,d,b),l.child)}function NN(i,l,d,p,b,j){return lo(l),l.updateQueue=null,d=C1(l,p,d,b),S1(i),p=av(),i!==null&&!Un?(rv(i,l,j),Ir(i,l,j)):($t&&p&&Lg(l),l.flags|=1,as(i,l,d,j),l.child)}function kN(i,l,d,p,b){if(lo(l),l.stateNode===null){var j=dl,M=d.contextType;typeof M=="object"&&M!==null&&(j=ss(M)),j=new d(p,j),l.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=bv,l.stateNode=j,j._reactInternals=l,j=l.stateNode,j.props=p,j.state=l.memoizedState,j.refs={},Kg(l),M=d.contextType,j.context=typeof M=="object"&&M!==null?ss(M):dl,j.state=l.memoizedState,M=d.getDerivedStateFromProps,typeof M=="function"&&(xv(l,d,M,p),j.state=l.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(M=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),M!==j.state&&bv.enqueueReplaceState(j,j.state,null),ru(l,p,j,b),au(),j.state=l.memoizedState),typeof j.componentDidMount=="function"&&(l.flags|=4194308),p=!0}else if(i===null){j=l.stateNode;var F=l.memoizedProps,J=po(d,F);j.props=J;var le=j.context,ye=d.contextType;M=dl,typeof ye=="object"&&ye!==null&&(M=ss(ye));var je=d.getDerivedStateFromProps;ye=typeof je=="function"||typeof j.getSnapshotBeforeUpdate=="function",F=l.pendingProps!==F,ye||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(F||le!==M)&&uN(l,j,p,M),ni=!1;var ue=l.memoizedState;j.state=ue,ru(l,p,j,b),au(),le=l.memoizedState,F||ue!==le||ni?(typeof je=="function"&&(xv(l,d,je,p),le=l.memoizedState),(J=ni||cN(l,d,J,p,ue,le,M))?(ye||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(l.flags|=4194308)):(typeof j.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=p,l.memoizedState=le),j.props=p,j.state=le,j.context=M,p=J):(typeof j.componentDidMount=="function"&&(l.flags|=4194308),p=!1)}else{j=l.stateNode,Yg(i,l),M=l.memoizedProps,ye=po(d,M),j.props=ye,je=l.pendingProps,ue=j.context,le=d.contextType,J=dl,typeof le=="object"&&le!==null&&(J=ss(le)),F=d.getDerivedStateFromProps,(le=typeof F=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(M!==je||ue!==J)&&uN(l,j,p,J),ni=!1,ue=l.memoizedState,j.state=ue,ru(l,p,j,b),au();var fe=l.memoizedState;M!==je||ue!==fe||ni||i!==null&&i.dependencies!==null&&xf(i.dependencies)?(typeof F=="function"&&(xv(l,d,F,p),fe=l.memoizedState),(ye=ni||cN(l,d,ye,p,ue,fe,J)||i!==null&&i.dependencies!==null&&xf(i.dependencies))?(le||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(p,fe,J),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(p,fe,J)),typeof j.componentDidUpdate=="function"&&(l.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof j.componentDidUpdate!="function"||M===i.memoizedProps&&ue===i.memoizedState||(l.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||M===i.memoizedProps&&ue===i.memoizedState||(l.flags|=1024),l.memoizedProps=p,l.memoizedState=fe),j.props=p,j.state=fe,j.context=J,p=ye):(typeof j.componentDidUpdate!="function"||M===i.memoizedProps&&ue===i.memoizedState||(l.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||M===i.memoizedProps&&ue===i.memoizedState||(l.flags|=1024),p=!1)}return j=p,Lf(i,l),p=(l.flags&128)!==0,j||p?(j=l.stateNode,d=p&&typeof d.getDerivedStateFromError!="function"?null:j.render(),l.flags|=1,i!==null&&p?(l.child=ho(l,i.child,null,b),l.child=ho(l,null,d,b)):as(i,l,d,b),l.memoizedState=j.state,i=l.child):i=Ir(i,l,b),i}function SN(i,l,d,p){return io(),l.flags|=256,as(i,l,d,p),l.child}var kv={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Sv(i){return{baseLanes:i,cachePool:m1()}}function Cv(i,l,d){return i=i!==null?i.childLanes&~d:0,l&&(i|=Zs),i}function CN(i,l,d){var p=l.pendingProps,b=!1,j=(l.flags&128)!==0,M;if((M=j)||(M=i!==null&&i.memoizedState===null?!1:(In.current&2)!==0),M&&(b=!0,l.flags&=-129),M=(l.flags&32)!==0,l.flags&=-33,i===null){if($t){if(b?ri(l):ii(),(i=hn)?(i=Ok(i,va),i=i!==null&&i.data!=="&"?i:null,i!==null&&(l.memoizedState={dehydrated:i,treeContext:Qr!==null?{id:Qa,overflow:Ja}:null,retryLane:536870912,hydrationErrors:null},d=r1(i),d.return=l,l.child=d,ns=l,hn=null)):i=null,i===null)throw ei(l);return ly(i)?l.lanes=32:l.lanes=536870912,null}var F=p.children;return p=p.fallback,b?(ii(),b=l.mode,F=zf({mode:"hidden",children:F},b),p=ro(p,b,d,null),F.return=l,p.return=l,F.sibling=p,l.child=F,p=l.child,p.memoizedState=Sv(d),p.childLanes=Cv(i,M,d),l.memoizedState=kv,uu(null,p)):(ri(l),Ev(l,F))}var J=i.memoizedState;if(J!==null&&(F=J.dehydrated,F!==null)){if(j)l.flags&256?(ri(l),l.flags&=-257,l=Av(i,l,d)):l.memoizedState!==null?(ii(),l.child=i.child,l.flags|=128,l=null):(ii(),F=p.fallback,b=l.mode,p=zf({mode:"visible",children:p.children},b),F=ro(F,b,d,null),F.flags|=2,p.return=l,F.return=l,p.sibling=F,l.child=p,ho(l,i.child,null,d),p=l.child,p.memoizedState=Sv(d),p.childLanes=Cv(i,M,d),l.memoizedState=kv,l=uu(null,p));else if(ri(l),ly(F)){if(M=F.nextSibling&&F.nextSibling.dataset,M)var le=M.dgst;M=le,p=Error(a(419)),p.stack="",p.digest=M,Qc({value:p,source:null,stack:null}),l=Av(i,l,d)}else if(Un||pl(i,l,d,!1),M=(d&i.childLanes)!==0,Un||M){if(M=an,M!==null&&(p=xs(M,d),p!==0&&p!==J.retryLane))throw J.retryLane=p,ao(i,p),Ds(M,i,p),jv;oy(F)||Zf(),l=Av(i,l,d)}else oy(F)?(l.flags|=192,l.child=i.child,l=null):(i=J.treeContext,hn=xa(F.nextSibling),ns=l,$t=!0,Jr=null,va=!1,i!==null&&l1(l,i),l=Ev(l,p.children),l.flags|=4096);return l}return b?(ii(),F=p.fallback,b=l.mode,J=i.child,le=J.sibling,p=Cr(J,{mode:"hidden",children:p.children}),p.subtreeFlags=J.subtreeFlags&65011712,le!==null?F=Cr(le,F):(F=ro(F,b,d,null),F.flags|=2),F.return=l,p.return=l,p.sibling=F,l.child=p,uu(null,p),p=l.child,F=i.child.memoizedState,F===null?F=Sv(d):(b=F.cachePool,b!==null?(J=zn._currentValue,b=b.parent!==J?{parent:J,pool:J}:b):b=m1(),F={baseLanes:F.baseLanes|d,cachePool:b}),p.memoizedState=F,p.childLanes=Cv(i,M,d),l.memoizedState=kv,uu(i.child,p)):(ri(l),d=i.child,i=d.sibling,d=Cr(d,{mode:"visible",children:p.children}),d.return=l,d.sibling=null,i!==null&&(M=l.deletions,M===null?(l.deletions=[i],l.flags|=16):M.push(i)),l.child=d,l.memoizedState=null,d)}function Ev(i,l){return l=zf({mode:"visible",children:l},i.mode),l.return=i,i.child=l}function zf(i,l){return i=Hs(22,i,null,l),i.lanes=0,i}function Av(i,l,d){return ho(l,i.child,null,d),i=Ev(l,l.pendingProps.children),i.flags|=2,l.memoizedState=null,i}function EN(i,l,d){i.lanes|=l;var p=i.alternate;p!==null&&(p.lanes|=l),Vg(i.return,l,d)}function Tv(i,l,d,p,b,j){var M=i.memoizedState;M===null?i.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:p,tail:d,tailMode:b,treeForkCount:j}:(M.isBackwards=l,M.rendering=null,M.renderingStartTime=0,M.last=p,M.tail=d,M.tailMode=b,M.treeForkCount=j)}function AN(i,l,d){var p=l.pendingProps,b=p.revealOrder,j=p.tail;p=p.children;var M=In.current,F=(M&2)!==0;if(F?(M=M&1|2,l.flags|=128):M&=1,K(In,M),as(i,l,p,d),p=$t?Xc:0,!F&&i!==null&&(i.flags&128)!==0)e:for(i=l.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&EN(i,d,l);else if(i.tag===19)EN(i,d,l);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===l)break e;for(;i.sibling===null;){if(i.return===null||i.return===l)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(b){case"forwards":for(d=l.child,b=null;d!==null;)i=d.alternate,i!==null&&Ef(i)===null&&(b=d),d=d.sibling;d=b,d===null?(b=l.child,l.child=null):(b=d.sibling,d.sibling=null),Tv(l,!1,b,d,j,p);break;case"backwards":case"unstable_legacy-backwards":for(d=null,b=l.child,l.child=null;b!==null;){if(i=b.alternate,i!==null&&Ef(i)===null){l.child=b;break}i=b.sibling,b.sibling=d,d=b,b=i}Tv(l,!0,d,null,j,p);break;case"together":Tv(l,!1,null,null,void 0,p);break;default:l.memoizedState=null}return l.child}function Ir(i,l,d){if(i!==null&&(l.dependencies=i.dependencies),ci|=l.lanes,(d&l.childLanes)===0)if(i!==null){if(pl(i,l,d,!1),(d&l.childLanes)===0)return null}else return null;if(i!==null&&l.child!==i.child)throw Error(a(153));if(l.child!==null){for(i=l.child,d=Cr(i,i.pendingProps),l.child=d,d.return=l;i.sibling!==null;)i=i.sibling,d=d.sibling=Cr(i,i.pendingProps),d.return=l;d.sibling=null}return l.child}function Mv(i,l){return(i.lanes&l)!==0?!0:(i=i.dependencies,!!(i!==null&&xf(i)))}function u5(i,l,d){switch(l.tag){case 3:ae(l,l.stateNode.containerInfo),ti(l,zn,i.memoizedState.cache),io();break;case 27:case 5:$e(l);break;case 4:ae(l,l.stateNode.containerInfo);break;case 10:ti(l,l.type,l.memoizedProps.value);break;case 31:if(l.memoizedState!==null)return l.flags|=128,tv(l),null;break;case 13:var p=l.memoizedState;if(p!==null)return p.dehydrated!==null?(ri(l),l.flags|=128,null):(d&l.child.childLanes)!==0?CN(i,l,d):(ri(l),i=Ir(i,l,d),i!==null?i.sibling:null);ri(l);break;case 19:var b=(i.flags&128)!==0;if(p=(d&l.childLanes)!==0,p||(pl(i,l,d,!1),p=(d&l.childLanes)!==0),b){if(p)return AN(i,l,d);l.flags|=128}if(b=l.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),K(In,In.current),p)break;return null;case 22:return l.lanes=0,bN(i,l,d,l.pendingProps);case 24:ti(l,zn,i.memoizedState.cache)}return Ir(i,l,d)}function TN(i,l,d){if(i!==null)if(i.memoizedProps!==l.pendingProps)Un=!0;else{if(!Mv(i,d)&&(l.flags&128)===0)return Un=!1,u5(i,l,d);Un=(i.flags&131072)!==0}else Un=!1,$t&&(l.flags&1048576)!==0&&o1(l,Xc,l.index);switch(l.lanes=0,l.tag){case 16:e:{var p=l.pendingProps;if(i=uo(l.elementType),l.type=i,typeof i=="function")$g(i)?(p=po(i,p),l.tag=1,l=kN(null,l,i,p,d)):(l.tag=0,l=Nv(null,l,i,p,d));else{if(i!=null){var b=i.$$typeof;if(b===N){l.tag=11,l=vN(null,l,i,p,d);break e}else if(b===_){l.tag=14,l=yN(null,l,i,p,d);break e}}throw l=V(i)||i,Error(a(306,l,""))}}return l;case 0:return Nv(i,l,l.type,l.pendingProps,d);case 1:return p=l.type,b=po(p,l.pendingProps),kN(i,l,p,b,d);case 3:e:{if(ae(l,l.stateNode.containerInfo),i===null)throw Error(a(387));p=l.pendingProps;var j=l.memoizedState;b=j.element,Yg(i,l),ru(l,p,null,d);var M=l.memoizedState;if(p=M.cache,ti(l,zn,p),p!==j.cache&&Hg(l,[zn],d,!0),au(),p=M.element,j.isDehydrated)if(j={element:p,isDehydrated:!1,cache:M.cache},l.updateQueue.baseState=j,l.memoizedState=j,l.flags&256){l=SN(i,l,p,d);break e}else if(p!==b){b=ma(Error(a(424)),l),Qc(b),l=SN(i,l,p,d);break e}else for(i=l.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,hn=xa(i.firstChild),ns=l,$t=!0,Jr=null,va=!0,d=b1(l,null,p,d),l.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(io(),p===b){l=Ir(i,l,d);break e}as(i,l,p,d)}l=l.child}return l;case 26:return Lf(i,l),i===null?(d=Bk(l.type,null,l.pendingProps,null))?l.memoizedState=d:$t||(d=l.type,i=l.pendingProps,p=th(re.current).createElement(d),p[Ue]=l,p[He]=i,rs(p,d,i),dn(p),l.stateNode=p):l.memoizedState=Bk(l.type,i.memoizedProps,l.pendingProps,i.memoizedState),null;case 27:return $e(l),i===null&&$t&&(p=l.stateNode=Dk(l.type,l.pendingProps,re.current),ns=l,va=!0,b=hn,mi(l.type)?(cy=b,hn=xa(p.firstChild)):hn=b),as(i,l,l.pendingProps.children,d),Lf(i,l),i===null&&(l.flags|=4194304),l.child;case 5:return i===null&&$t&&((b=p=hn)&&(p=B5(p,l.type,l.pendingProps,va),p!==null?(l.stateNode=p,ns=l,hn=xa(p.firstChild),va=!1,b=!0):b=!1),b||ei(l)),$e(l),b=l.type,j=l.pendingProps,M=i!==null?i.memoizedProps:null,p=j.children,ay(b,j)?p=null:M!==null&&ay(b,M)&&(l.flags|=32),l.memoizedState!==null&&(b=sv(i,l,t5,null,null,d),Su._currentValue=b),Lf(i,l),as(i,l,p,d),l.child;case 6:return i===null&&$t&&((i=d=hn)&&(d=U5(d,l.pendingProps,va),d!==null?(l.stateNode=d,ns=l,hn=null,i=!0):i=!1),i||ei(l)),null;case 13:return CN(i,l,d);case 4:return ae(l,l.stateNode.containerInfo),p=l.pendingProps,i===null?l.child=ho(l,null,p,d):as(i,l,p,d),l.child;case 11:return vN(i,l,l.type,l.pendingProps,d);case 7:return as(i,l,l.pendingProps,d),l.child;case 8:return as(i,l,l.pendingProps.children,d),l.child;case 12:return as(i,l,l.pendingProps.children,d),l.child;case 10:return p=l.pendingProps,ti(l,l.type,p.value),as(i,l,p.children,d),l.child;case 9:return b=l.type._context,p=l.pendingProps.children,lo(l),b=ss(b),p=p(b),l.flags|=1,as(i,l,p,d),l.child;case 14:return yN(i,l,l.type,l.pendingProps,d);case 15:return xN(i,l,l.type,l.pendingProps,d);case 19:return AN(i,l,d);case 31:return c5(i,l,d);case 22:return bN(i,l,d,l.pendingProps);case 24:return lo(l),p=ss(zn),i===null?(b=Gg(),b===null&&(b=an,j=qg(),b.pooledCache=j,j.refCount++,j!==null&&(b.pooledCacheLanes|=d),b=j),l.memoizedState={parent:p,cache:b},Kg(l),ti(l,zn,b)):((i.lanes&d)!==0&&(Yg(i,l),ru(l,null,null,d),au()),b=i.memoizedState,j=l.memoizedState,b.parent!==p?(b={parent:p,cache:p},l.memoizedState=b,l.lanes===0&&(l.memoizedState=l.updateQueue.baseState=b),ti(l,zn,p)):(p=j.cache,ti(l,zn,p),p!==b.cache&&Hg(l,[zn],d,!0))),as(i,l,l.pendingProps.children,d),l.child;case 29:throw l.pendingProps}throw Error(a(156,l.tag))}function _r(i){i.flags|=4}function Rv(i,l,d,p,b){if((l=(i.mode&32)!==0)&&(l=!1),l){if(i.flags|=16777216,(b&335544128)===b)if(i.stateNode.complete)i.flags|=8192;else if(nk())i.flags|=8192;else throw fo=Nf,Zg}else i.flags&=-16777217}function MN(i,l){if(l.type!=="stylesheet"||(l.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!qk(l))if(nk())i.flags|=8192;else throw fo=Nf,Zg}function Bf(i,l){l!==null&&(i.flags|=4),i.flags&16384&&(l=i.tag!==22?vs():536870912,i.lanes|=l,El|=l)}function du(i,l){if(!$t)switch(i.tailMode){case"hidden":l=i.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?i.tail=null:d.sibling=null;break;case"collapsed":d=i.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?l||i.tail===null?i.tail=null:i.tail.sibling=null:p.sibling=null}}function mn(i){var l=i.alternate!==null&&i.alternate.child===i.child,d=0,p=0;if(l)for(var b=i.child;b!==null;)d|=b.lanes|b.childLanes,p|=b.subtreeFlags&65011712,p|=b.flags&65011712,b.return=i,b=b.sibling;else for(b=i.child;b!==null;)d|=b.lanes|b.childLanes,p|=b.subtreeFlags,p|=b.flags,b.return=i,b=b.sibling;return i.subtreeFlags|=p,i.childLanes=d,l}function d5(i,l,d){var p=l.pendingProps;switch(zg(l),l.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mn(l),null;case 1:return mn(l),null;case 3:return d=l.stateNode,p=null,i!==null&&(p=i.memoizedState.cache),l.memoizedState.cache!==p&&(l.flags|=2048),Tr(zn),be(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(i===null||i.child===null)&&(ml(l)?_r(l):i===null||i.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Ug())),mn(l),null;case 26:var b=l.type,j=l.memoizedState;return i===null?(_r(l),j!==null?(mn(l),MN(l,j)):(mn(l),Rv(l,b,null,p,d))):j?j!==i.memoizedState?(_r(l),mn(l),MN(l,j)):(mn(l),l.flags&=-16777217):(i=i.memoizedProps,i!==p&&_r(l),mn(l),Rv(l,b,i,p,d)),null;case 27:if(ge(l),d=re.current,b=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==p&&_r(l);else{if(!p){if(l.stateNode===null)throw Error(a(166));return mn(l),null}i=ee.current,ml(l)?c1(l):(i=Dk(b,p,d),l.stateNode=i,_r(l))}return mn(l),null;case 5:if(ge(l),b=l.type,i!==null&&l.stateNode!=null)i.memoizedProps!==p&&_r(l);else{if(!p){if(l.stateNode===null)throw Error(a(166));return mn(l),null}if(j=ee.current,ml(l))c1(l);else{var M=th(re.current);switch(j){case 1:j=M.createElementNS("http://www.w3.org/2000/svg",b);break;case 2:j=M.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;default:switch(b){case"svg":j=M.createElementNS("http://www.w3.org/2000/svg",b);break;case"math":j=M.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;case"script":j=M.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof p.is=="string"?M.createElement("select",{is:p.is}):M.createElement("select"),p.multiple?j.multiple=!0:p.size&&(j.size=p.size);break;default:j=typeof p.is=="string"?M.createElement(b,{is:p.is}):M.createElement(b)}}j[Ue]=l,j[He]=p;e:for(M=l.child;M!==null;){if(M.tag===5||M.tag===6)j.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===l)break e;for(;M.sibling===null;){if(M.return===null||M.return===l)break e;M=M.return}M.sibling.return=M.return,M=M.sibling}l.stateNode=j;e:switch(rs(j,b,p),b){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&_r(l)}}return mn(l),Rv(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,d),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==p&&_r(l);else{if(typeof p!="string"&&l.stateNode===null)throw Error(a(166));if(i=re.current,ml(l)){if(i=l.stateNode,d=l.memoizedProps,p=null,b=ns,b!==null)switch(b.tag){case 27:case 5:p=b.memoizedProps}i[Ue]=l,i=!!(i.nodeValue===d||p!==null&&p.suppressHydrationWarning===!0||Ck(i.nodeValue,d)),i||ei(l,!0)}else i=th(i).createTextNode(p),i[Ue]=l,l.stateNode=i}return mn(l),null;case 31:if(d=l.memoizedState,i===null||i.memoizedState!==null){if(p=ml(l),d!==null){if(i===null){if(!p)throw Error(a(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(a(557));i[Ue]=l}else io(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;mn(l),i=!1}else d=Ug(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),i=!0;if(!i)return l.flags&256?(Ws(l),l):(Ws(l),null);if((l.flags&128)!==0)throw Error(a(558))}return mn(l),null;case 13:if(p=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(b=ml(l),p!==null&&p.dehydrated!==null){if(i===null){if(!b)throw Error(a(318));if(b=l.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(a(317));b[Ue]=l}else io(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;mn(l),b=!1}else b=Ug(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=b),b=!0;if(!b)return l.flags&256?(Ws(l),l):(Ws(l),null)}return Ws(l),(l.flags&128)!==0?(l.lanes=d,l):(d=p!==null,i=i!==null&&i.memoizedState!==null,d&&(p=l.child,b=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(b=p.alternate.memoizedState.cachePool.pool),j=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(j=p.memoizedState.cachePool.pool),j!==b&&(p.flags|=2048)),d!==i&&d&&(l.child.flags|=8192),Bf(l,l.updateQueue),mn(l),null);case 4:return be(),i===null&&Jv(l.stateNode.containerInfo),mn(l),null;case 10:return Tr(l.type),mn(l),null;case 19:if(q(In),p=l.memoizedState,p===null)return mn(l),null;if(b=(l.flags&128)!==0,j=p.rendering,j===null)if(b)du(p,!1);else{if(En!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(j=Ef(i),j!==null){for(l.flags|=128,du(p,!1),i=j.updateQueue,l.updateQueue=i,Bf(l,i),l.subtreeFlags=0,i=d,d=l.child;d!==null;)a1(d,i),d=d.sibling;return K(In,In.current&1|2),$t&&Er(l,p.treeForkCount),l.child}i=i.sibling}p.tail!==null&&Ie()>qf&&(l.flags|=128,b=!0,du(p,!1),l.lanes=4194304)}else{if(!b)if(i=Ef(j),i!==null){if(l.flags|=128,b=!0,i=i.updateQueue,l.updateQueue=i,Bf(l,i),du(p,!0),p.tail===null&&p.tailMode==="hidden"&&!j.alternate&&!$t)return mn(l),null}else 2*Ie()-p.renderingStartTime>qf&&d!==536870912&&(l.flags|=128,b=!0,du(p,!1),l.lanes=4194304);p.isBackwards?(j.sibling=l.child,l.child=j):(i=p.last,i!==null?i.sibling=j:l.child=j,p.last=j)}return p.tail!==null?(i=p.tail,p.rendering=i,p.tail=i.sibling,p.renderingStartTime=Ie(),i.sibling=null,d=In.current,K(In,b?d&1|2:d&1),$t&&Er(l,p.treeForkCount),i):(mn(l),null);case 22:case 23:return Ws(l),ev(),p=l.memoizedState!==null,i!==null?i.memoizedState!==null!==p&&(l.flags|=8192):p&&(l.flags|=8192),p?(d&536870912)!==0&&(l.flags&128)===0&&(mn(l),l.subtreeFlags&6&&(l.flags|=8192)):mn(l),d=l.updateQueue,d!==null&&Bf(l,d.retryQueue),d=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),p=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),p!==d&&(l.flags|=2048),i!==null&&q(co),null;case 24:return d=null,i!==null&&(d=i.memoizedState.cache),l.memoizedState.cache!==d&&(l.flags|=2048),Tr(zn),mn(l),null;case 25:return null;case 30:return null}throw Error(a(156,l.tag))}function f5(i,l){switch(zg(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return Tr(zn),be(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ge(l),null;case 31:if(l.memoizedState!==null){if(Ws(l),l.alternate===null)throw Error(a(340));io()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(Ws(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(a(340));io()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return q(In),null;case 4:return be(),null;case 10:return Tr(l.type),null;case 22:case 23:return Ws(l),ev(),i!==null&&q(co),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return Tr(zn),null;case 25:return null;default:return null}}function RN(i,l){switch(zg(l),l.tag){case 3:Tr(zn),be();break;case 26:case 27:case 5:ge(l);break;case 4:be();break;case 31:l.memoizedState!==null&&Ws(l);break;case 13:Ws(l);break;case 19:q(In);break;case 10:Tr(l.type);break;case 22:case 23:Ws(l),ev(),i!==null&&q(co);break;case 24:Tr(zn)}}function fu(i,l){try{var d=l.updateQueue,p=d!==null?d.lastEffect:null;if(p!==null){var b=p.next;d=b;do{if((d.tag&i)===i){p=void 0;var j=d.create,M=d.inst;p=j(),M.destroy=p}d=d.next}while(d!==b)}}catch(F){Zt(l,l.return,F)}}function oi(i,l,d){try{var p=l.updateQueue,b=p!==null?p.lastEffect:null;if(b!==null){var j=b.next;p=j;do{if((p.tag&i)===i){var M=p.inst,F=M.destroy;if(F!==void 0){M.destroy=void 0,b=l;var J=d,le=F;try{le()}catch(ye){Zt(b,J,ye)}}}p=p.next}while(p!==j)}}catch(ye){Zt(l,l.return,ye)}}function IN(i){var l=i.updateQueue;if(l!==null){var d=i.stateNode;try{j1(l,d)}catch(p){Zt(i,i.return,p)}}}function _N(i,l,d){d.props=po(i.type,i.memoizedProps),d.state=i.memoizedState;try{d.componentWillUnmount()}catch(p){Zt(i,l,p)}}function hu(i,l){try{var d=i.ref;if(d!==null){switch(i.tag){case 26:case 27:case 5:var p=i.stateNode;break;case 30:p=i.stateNode;break;default:p=i.stateNode}typeof d=="function"?i.refCleanup=d(p):d.current=p}}catch(b){Zt(i,l,b)}}function er(i,l){var d=i.ref,p=i.refCleanup;if(d!==null)if(typeof p=="function")try{p()}catch(b){Zt(i,l,b)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(b){Zt(i,l,b)}else d.current=null}function ON(i){var l=i.type,d=i.memoizedProps,p=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":d.autoFocus&&p.focus();break e;case"img":d.src?p.src=d.src:d.srcSet&&(p.srcset=d.srcSet)}}catch(b){Zt(i,i.return,b)}}function Iv(i,l,d){try{var p=i.stateNode;O5(p,i.type,d,l),p[He]=l}catch(b){Zt(i,i.return,b)}}function $N(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&mi(i.type)||i.tag===4}function _v(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||$N(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&mi(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Ov(i,l,d){var p=i.tag;if(p===5||p===6)i=i.stateNode,l?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(i,l):(l=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,l.appendChild(i),d=d._reactRootContainer,d!=null||l.onclick!==null||(l.onclick=kr));else if(p!==4&&(p===27&&mi(i.type)&&(d=i.stateNode,l=null),i=i.child,i!==null))for(Ov(i,l,d),i=i.sibling;i!==null;)Ov(i,l,d),i=i.sibling}function Uf(i,l,d){var p=i.tag;if(p===5||p===6)i=i.stateNode,l?d.insertBefore(i,l):d.appendChild(i);else if(p!==4&&(p===27&&mi(i.type)&&(d=i.stateNode),i=i.child,i!==null))for(Uf(i,l,d),i=i.sibling;i!==null;)Uf(i,l,d),i=i.sibling}function PN(i){var l=i.stateNode,d=i.memoizedProps;try{for(var p=i.type,b=l.attributes;b.length;)l.removeAttributeNode(b[0]);rs(l,p,d),l[Ue]=i,l[He]=d}catch(j){Zt(i,i.return,j)}}var Or=!1,Fn=!1,$v=!1,DN=typeof WeakSet=="function"?WeakSet:Set,Jn=null;function h5(i,l){if(i=i.containerInfo,ny=lh,i=Kj(i),Ag(i)){if("selectionStart"in i)var d={start:i.selectionStart,end:i.selectionEnd};else e:{d=(d=i.ownerDocument)&&d.defaultView||window;var p=d.getSelection&&d.getSelection();if(p&&p.rangeCount!==0){d=p.anchorNode;var b=p.anchorOffset,j=p.focusNode;p=p.focusOffset;try{d.nodeType,j.nodeType}catch{d=null;break e}var M=0,F=-1,J=-1,le=0,ye=0,je=i,ue=null;t:for(;;){for(var fe;je!==d||b!==0&&je.nodeType!==3||(F=M+b),je!==j||p!==0&&je.nodeType!==3||(J=M+p),je.nodeType===3&&(M+=je.nodeValue.length),(fe=je.firstChild)!==null;)ue=je,je=fe;for(;;){if(je===i)break t;if(ue===d&&++le===b&&(F=M),ue===j&&++ye===p&&(J=M),(fe=je.nextSibling)!==null)break;je=ue,ue=je.parentNode}je=fe}d=F===-1||J===-1?null:{start:F,end:J}}else d=null}d=d||{start:0,end:0}}else d=null;for(sy={focusedElem:i,selectionRange:d},lh=!1,Jn=l;Jn!==null;)if(l=Jn,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,Jn=i;else for(;Jn!==null;){switch(l=Jn,j=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(d=0;d<i.length;d++)b=i[d],b.ref.impl=b.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&j!==null){i=void 0,d=l,b=j.memoizedProps,j=j.memoizedState,p=d.stateNode;try{var Ze=po(d.type,b);i=p.getSnapshotBeforeUpdate(Ze,j),p.__reactInternalSnapshotBeforeUpdate=i}catch(ot){Zt(d,d.return,ot)}}break;case 3:if((i&1024)!==0){if(i=l.stateNode.containerInfo,d=i.nodeType,d===9)iy(i);else if(d===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":iy(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(a(163))}if(i=l.sibling,i!==null){i.return=l.return,Jn=i;break}Jn=l.return}}function LN(i,l,d){var p=d.flags;switch(d.tag){case 0:case 11:case 15:Pr(i,d),p&4&&fu(5,d);break;case 1:if(Pr(i,d),p&4)if(i=d.stateNode,l===null)try{i.componentDidMount()}catch(M){Zt(d,d.return,M)}else{var b=po(d.type,l.memoizedProps);l=l.memoizedState;try{i.componentDidUpdate(b,l,i.__reactInternalSnapshotBeforeUpdate)}catch(M){Zt(d,d.return,M)}}p&64&&IN(d),p&512&&hu(d,d.return);break;case 3:if(Pr(i,d),p&64&&(i=d.updateQueue,i!==null)){if(l=null,d.child!==null)switch(d.child.tag){case 27:case 5:l=d.child.stateNode;break;case 1:l=d.child.stateNode}try{j1(i,l)}catch(M){Zt(d,d.return,M)}}break;case 27:l===null&&p&4&&PN(d);case 26:case 5:Pr(i,d),l===null&&p&4&&ON(d),p&512&&hu(d,d.return);break;case 12:Pr(i,d);break;case 31:Pr(i,d),p&4&&UN(i,d);break;case 13:Pr(i,d),p&4&&FN(i,d),p&64&&(i=d.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(d=j5.bind(null,d),F5(i,d))));break;case 22:if(p=d.memoizedState!==null||Or,!p){l=l!==null&&l.memoizedState!==null||Fn,b=Or;var j=Fn;Or=p,(Fn=l)&&!j?Dr(i,d,(d.subtreeFlags&8772)!==0):Pr(i,d),Or=b,Fn=j}break;case 30:break;default:Pr(i,d)}}function zN(i){var l=i.alternate;l!==null&&(i.alternate=null,zN(l)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(l=i.stateNode,l!==null&&ds(l)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var jn=null,_s=!1;function $r(i,l,d){for(d=d.child;d!==null;)BN(i,l,d),d=d.sibling}function BN(i,l,d){if(Y&&typeof Y.onCommitFiberUnmount=="function")try{Y.onCommitFiberUnmount(xt,d)}catch{}switch(d.tag){case 26:Fn||er(d,l),$r(i,l,d),d.memoizedState?d.memoizedState.count--:d.stateNode&&(d=d.stateNode,d.parentNode.removeChild(d));break;case 27:Fn||er(d,l);var p=jn,b=_s;mi(d.type)&&(jn=d.stateNode,_s=!1),$r(i,l,d),ju(d.stateNode),jn=p,_s=b;break;case 5:Fn||er(d,l);case 6:if(p=jn,b=_s,jn=null,$r(i,l,d),jn=p,_s=b,jn!==null)if(_s)try{(jn.nodeType===9?jn.body:jn.nodeName==="HTML"?jn.ownerDocument.body:jn).removeChild(d.stateNode)}catch(j){Zt(d,l,j)}else try{jn.removeChild(d.stateNode)}catch(j){Zt(d,l,j)}break;case 18:jn!==null&&(_s?(i=jn,Ik(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,d.stateNode),$l(i)):Ik(jn,d.stateNode));break;case 4:p=jn,b=_s,jn=d.stateNode.containerInfo,_s=!0,$r(i,l,d),jn=p,_s=b;break;case 0:case 11:case 14:case 15:oi(2,d,l),Fn||oi(4,d,l),$r(i,l,d);break;case 1:Fn||(er(d,l),p=d.stateNode,typeof p.componentWillUnmount=="function"&&_N(d,l,p)),$r(i,l,d);break;case 21:$r(i,l,d);break;case 22:Fn=(p=Fn)||d.memoizedState!==null,$r(i,l,d),Fn=p;break;default:$r(i,l,d)}}function UN(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{$l(i)}catch(d){Zt(l,l.return,d)}}}function FN(i,l){if(l.memoizedState===null&&(i=l.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{$l(i)}catch(d){Zt(l,l.return,d)}}function m5(i){switch(i.tag){case 31:case 13:case 19:var l=i.stateNode;return l===null&&(l=i.stateNode=new DN),l;case 22:return i=i.stateNode,l=i._retryCache,l===null&&(l=i._retryCache=new DN),l;default:throw Error(a(435,i.tag))}}function Ff(i,l){var d=m5(i);l.forEach(function(p){if(!d.has(p)){d.add(p);var b=N5.bind(null,i,p);p.then(b,b)}})}function Os(i,l){var d=l.deletions;if(d!==null)for(var p=0;p<d.length;p++){var b=d[p],j=i,M=l,F=M;e:for(;F!==null;){switch(F.tag){case 27:if(mi(F.type)){jn=F.stateNode,_s=!1;break e}break;case 5:jn=F.stateNode,_s=!1;break e;case 3:case 4:jn=F.stateNode.containerInfo,_s=!0;break e}F=F.return}if(jn===null)throw Error(a(160));BN(j,M,b),jn=null,_s=!1,j=b.alternate,j!==null&&(j.return=null),b.return=null}if(l.subtreeFlags&13886)for(l=l.child;l!==null;)VN(l,i),l=l.sibling}var Oa=null;function VN(i,l){var d=i.alternate,p=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:Os(l,i),$s(i),p&4&&(oi(3,i,i.return),fu(3,i),oi(5,i,i.return));break;case 1:Os(l,i),$s(i),p&512&&(Fn||d===null||er(d,d.return)),p&64&&Or&&(i=i.updateQueue,i!==null&&(p=i.callbacks,p!==null&&(d=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=d===null?p:d.concat(p))));break;case 26:var b=Oa;if(Os(l,i),$s(i),p&512&&(Fn||d===null||er(d,d.return)),p&4){var j=d!==null?d.memoizedState:null;if(p=i.memoizedState,d===null)if(p===null)if(i.stateNode===null){e:{p=i.type,d=i.memoizedProps,b=b.ownerDocument||b;t:switch(p){case"title":j=b.getElementsByTagName("title")[0],(!j||j[Gn]||j[Ue]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=b.createElement(p),b.head.insertBefore(j,b.querySelector("head > title"))),rs(j,p,d),j[Ue]=i,dn(j),p=j;break e;case"link":var M=Vk("link","href",b).get(p+(d.href||""));if(M){for(var F=0;F<M.length;F++)if(j=M[F],j.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&j.getAttribute("rel")===(d.rel==null?null:d.rel)&&j.getAttribute("title")===(d.title==null?null:d.title)&&j.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){M.splice(F,1);break t}}j=b.createElement(p),rs(j,p,d),b.head.appendChild(j);break;case"meta":if(M=Vk("meta","content",b).get(p+(d.content||""))){for(F=0;F<M.length;F++)if(j=M[F],j.getAttribute("content")===(d.content==null?null:""+d.content)&&j.getAttribute("name")===(d.name==null?null:d.name)&&j.getAttribute("property")===(d.property==null?null:d.property)&&j.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&j.getAttribute("charset")===(d.charSet==null?null:d.charSet)){M.splice(F,1);break t}}j=b.createElement(p),rs(j,p,d),b.head.appendChild(j);break;default:throw Error(a(468,p))}j[Ue]=i,dn(j),p=j}i.stateNode=p}else Hk(b,i.type,i.stateNode);else i.stateNode=Fk(b,p,i.memoizedProps);else j!==p?(j===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):j.count--,p===null?Hk(b,i.type,i.stateNode):Fk(b,p,i.memoizedProps)):p===null&&i.stateNode!==null&&Iv(i,i.memoizedProps,d.memoizedProps)}break;case 27:Os(l,i),$s(i),p&512&&(Fn||d===null||er(d,d.return)),d!==null&&p&4&&Iv(i,i.memoizedProps,d.memoizedProps);break;case 5:if(Os(l,i),$s(i),p&512&&(Fn||d===null||er(d,d.return)),i.flags&32){b=i.stateNode;try{Xt(b,"")}catch(Ze){Zt(i,i.return,Ze)}}p&4&&i.stateNode!=null&&(b=i.memoizedProps,Iv(i,b,d!==null?d.memoizedProps:b)),p&1024&&($v=!0);break;case 6:if(Os(l,i),$s(i),p&4){if(i.stateNode===null)throw Error(a(162));p=i.memoizedProps,d=i.stateNode;try{d.nodeValue=p}catch(Ze){Zt(i,i.return,Ze)}}break;case 3:if(ah=null,b=Oa,Oa=nh(l.containerInfo),Os(l,i),Oa=b,$s(i),p&4&&d!==null&&d.memoizedState.isDehydrated)try{$l(l.containerInfo)}catch(Ze){Zt(i,i.return,Ze)}$v&&($v=!1,HN(i));break;case 4:p=Oa,Oa=nh(i.stateNode.containerInfo),Os(l,i),$s(i),Oa=p;break;case 12:Os(l,i),$s(i);break;case 31:Os(l,i),$s(i),p&4&&(p=i.updateQueue,p!==null&&(i.updateQueue=null,Ff(i,p)));break;case 13:Os(l,i),$s(i),i.child.flags&8192&&i.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(Hf=Ie()),p&4&&(p=i.updateQueue,p!==null&&(i.updateQueue=null,Ff(i,p)));break;case 22:b=i.memoizedState!==null;var J=d!==null&&d.memoizedState!==null,le=Or,ye=Fn;if(Or=le||b,Fn=ye||J,Os(l,i),Fn=ye,Or=le,$s(i),p&8192)e:for(l=i.stateNode,l._visibility=b?l._visibility&-2:l._visibility|1,b&&(d===null||J||Or||Fn||go(i)),d=null,l=i;;){if(l.tag===5||l.tag===26){if(d===null){J=d=l;try{if(j=J.stateNode,b)M=j.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none";else{F=J.stateNode;var je=J.memoizedProps.style,ue=je!=null&&je.hasOwnProperty("display")?je.display:null;F.style.display=ue==null||typeof ue=="boolean"?"":(""+ue).trim()}}catch(Ze){Zt(J,J.return,Ze)}}}else if(l.tag===6){if(d===null){J=l;try{J.stateNode.nodeValue=b?"":J.memoizedProps}catch(Ze){Zt(J,J.return,Ze)}}}else if(l.tag===18){if(d===null){J=l;try{var fe=J.stateNode;b?_k(fe,!0):_k(J.stateNode,!1)}catch(Ze){Zt(J,J.return,Ze)}}}else if((l.tag!==22&&l.tag!==23||l.memoizedState===null||l===i)&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break e;for(;l.sibling===null;){if(l.return===null||l.return===i)break e;d===l&&(d=null),l=l.return}d===l&&(d=null),l.sibling.return=l.return,l=l.sibling}p&4&&(p=i.updateQueue,p!==null&&(d=p.retryQueue,d!==null&&(p.retryQueue=null,Ff(i,d))));break;case 19:Os(l,i),$s(i),p&4&&(p=i.updateQueue,p!==null&&(i.updateQueue=null,Ff(i,p)));break;case 30:break;case 21:break;default:Os(l,i),$s(i)}}function $s(i){var l=i.flags;if(l&2){try{for(var d,p=i.return;p!==null;){if($N(p)){d=p;break}p=p.return}if(d==null)throw Error(a(160));switch(d.tag){case 27:var b=d.stateNode,j=_v(i);Uf(i,j,b);break;case 5:var M=d.stateNode;d.flags&32&&(Xt(M,""),d.flags&=-33);var F=_v(i);Uf(i,F,M);break;case 3:case 4:var J=d.stateNode.containerInfo,le=_v(i);Ov(i,le,J);break;default:throw Error(a(161))}}catch(ye){Zt(i,i.return,ye)}i.flags&=-3}l&4096&&(i.flags&=-4097)}function HN(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var l=i;HN(l),l.tag===5&&l.flags&1024&&l.stateNode.reset(),i=i.sibling}}function Pr(i,l){if(l.subtreeFlags&8772)for(l=l.child;l!==null;)LN(i,l.alternate,l),l=l.sibling}function go(i){for(i=i.child;i!==null;){var l=i;switch(l.tag){case 0:case 11:case 14:case 15:oi(4,l,l.return),go(l);break;case 1:er(l,l.return);var d=l.stateNode;typeof d.componentWillUnmount=="function"&&_N(l,l.return,d),go(l);break;case 27:ju(l.stateNode);case 26:case 5:er(l,l.return),go(l);break;case 22:l.memoizedState===null&&go(l);break;case 30:go(l);break;default:go(l)}i=i.sibling}}function Dr(i,l,d){for(d=d&&(l.subtreeFlags&8772)!==0,l=l.child;l!==null;){var p=l.alternate,b=i,j=l,M=j.flags;switch(j.tag){case 0:case 11:case 15:Dr(b,j,d),fu(4,j);break;case 1:if(Dr(b,j,d),p=j,b=p.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(le){Zt(p,p.return,le)}if(p=j,b=p.updateQueue,b!==null){var F=p.stateNode;try{var J=b.shared.hiddenCallbacks;if(J!==null)for(b.shared.hiddenCallbacks=null,b=0;b<J.length;b++)w1(J[b],F)}catch(le){Zt(p,p.return,le)}}d&&M&64&&IN(j),hu(j,j.return);break;case 27:PN(j);case 26:case 5:Dr(b,j,d),d&&p===null&&M&4&&ON(j),hu(j,j.return);break;case 12:Dr(b,j,d);break;case 31:Dr(b,j,d),d&&M&4&&UN(b,j);break;case 13:Dr(b,j,d),d&&M&4&&FN(b,j);break;case 22:j.memoizedState===null&&Dr(b,j,d),hu(j,j.return);break;case 30:break;default:Dr(b,j,d)}l=l.sibling}}function Pv(i,l){var d=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(d=i.memoizedState.cachePool.pool),i=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(i=l.memoizedState.cachePool.pool),i!==d&&(i!=null&&i.refCount++,d!=null&&Jc(d))}function Dv(i,l){i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&Jc(i))}function $a(i,l,d,p){if(l.subtreeFlags&10256)for(l=l.child;l!==null;)qN(i,l,d,p),l=l.sibling}function qN(i,l,d,p){var b=l.flags;switch(l.tag){case 0:case 11:case 15:$a(i,l,d,p),b&2048&&fu(9,l);break;case 1:$a(i,l,d,p);break;case 3:$a(i,l,d,p),b&2048&&(i=null,l.alternate!==null&&(i=l.alternate.memoizedState.cache),l=l.memoizedState.cache,l!==i&&(l.refCount++,i!=null&&Jc(i)));break;case 12:if(b&2048){$a(i,l,d,p),i=l.stateNode;try{var j=l.memoizedProps,M=j.id,F=j.onPostCommit;typeof F=="function"&&F(M,l.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(J){Zt(l,l.return,J)}}else $a(i,l,d,p);break;case 31:$a(i,l,d,p);break;case 13:$a(i,l,d,p);break;case 23:break;case 22:j=l.stateNode,M=l.alternate,l.memoizedState!==null?j._visibility&2?$a(i,l,d,p):mu(i,l):j._visibility&2?$a(i,l,d,p):(j._visibility|=2,kl(i,l,d,p,(l.subtreeFlags&10256)!==0||!1)),b&2048&&Pv(M,l);break;case 24:$a(i,l,d,p),b&2048&&Dv(l.alternate,l);break;default:$a(i,l,d,p)}}function kl(i,l,d,p,b){for(b=b&&((l.subtreeFlags&10256)!==0||!1),l=l.child;l!==null;){var j=i,M=l,F=d,J=p,le=M.flags;switch(M.tag){case 0:case 11:case 15:kl(j,M,F,J,b),fu(8,M);break;case 23:break;case 22:var ye=M.stateNode;M.memoizedState!==null?ye._visibility&2?kl(j,M,F,J,b):mu(j,M):(ye._visibility|=2,kl(j,M,F,J,b)),b&&le&2048&&Pv(M.alternate,M);break;case 24:kl(j,M,F,J,b),b&&le&2048&&Dv(M.alternate,M);break;default:kl(j,M,F,J,b)}l=l.sibling}}function mu(i,l){if(l.subtreeFlags&10256)for(l=l.child;l!==null;){var d=i,p=l,b=p.flags;switch(p.tag){case 22:mu(d,p),b&2048&&Pv(p.alternate,p);break;case 24:mu(d,p),b&2048&&Dv(p.alternate,p);break;default:mu(d,p)}l=l.sibling}}var pu=8192;function Sl(i,l,d){if(i.subtreeFlags&pu)for(i=i.child;i!==null;)WN(i,l,d),i=i.sibling}function WN(i,l,d){switch(i.tag){case 26:Sl(i,l,d),i.flags&pu&&i.memoizedState!==null&&e4(d,Oa,i.memoizedState,i.memoizedProps);break;case 5:Sl(i,l,d);break;case 3:case 4:var p=Oa;Oa=nh(i.stateNode.containerInfo),Sl(i,l,d),Oa=p;break;case 22:i.memoizedState===null&&(p=i.alternate,p!==null&&p.memoizedState!==null?(p=pu,pu=16777216,Sl(i,l,d),pu=p):Sl(i,l,d));break;default:Sl(i,l,d)}}function GN(i){var l=i.alternate;if(l!==null&&(i=l.child,i!==null)){l.child=null;do l=i.sibling,i.sibling=null,i=l;while(i!==null)}}function gu(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var d=0;d<l.length;d++){var p=l[d];Jn=p,KN(p,i)}GN(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)ZN(i),i=i.sibling}function ZN(i){switch(i.tag){case 0:case 11:case 15:gu(i),i.flags&2048&&oi(9,i,i.return);break;case 3:gu(i);break;case 12:gu(i);break;case 22:var l=i.stateNode;i.memoizedState!==null&&l._visibility&2&&(i.return===null||i.return.tag!==13)?(l._visibility&=-3,Vf(i)):gu(i);break;default:gu(i)}}function Vf(i){var l=i.deletions;if((i.flags&16)!==0){if(l!==null)for(var d=0;d<l.length;d++){var p=l[d];Jn=p,KN(p,i)}GN(i)}for(i=i.child;i!==null;){switch(l=i,l.tag){case 0:case 11:case 15:oi(8,l,l.return),Vf(l);break;case 22:d=l.stateNode,d._visibility&2&&(d._visibility&=-3,Vf(l));break;default:Vf(l)}i=i.sibling}}function KN(i,l){for(;Jn!==null;){var d=Jn;switch(d.tag){case 0:case 11:case 15:oi(8,d,l);break;case 23:case 22:if(d.memoizedState!==null&&d.memoizedState.cachePool!==null){var p=d.memoizedState.cachePool.pool;p!=null&&p.refCount++}break;case 24:Jc(d.memoizedState.cache)}if(p=d.child,p!==null)p.return=d,Jn=p;else e:for(d=i;Jn!==null;){p=Jn;var b=p.sibling,j=p.return;if(zN(p),p===d){Jn=null;break e}if(b!==null){b.return=j,Jn=b;break e}Jn=j}}}var p5={getCacheForType:function(i){var l=ss(zn),d=l.data.get(i);return d===void 0&&(d=i(),l.data.set(i,d)),d},cacheSignal:function(){return ss(zn).controller.signal}},g5=typeof WeakMap=="function"?WeakMap:Map,Vt=0,an=null,Et=null,It=0,Gt=0,Gs=null,li=!1,Cl=!1,Lv=!1,Lr=0,En=0,ci=0,vo=0,zv=0,Zs=0,El=0,vu=null,Ps=null,Bv=!1,Hf=0,YN=0,qf=1/0,Wf=null,ui=null,Kn=0,di=null,Al=null,zr=0,Uv=0,Fv=null,XN=null,yu=0,Vv=null;function Ks(){return(Vt&2)!==0&&It!==0?It&-It:O.T!==null?Kv():Ln()}function QN(){if(Zs===0)if((It&536870912)===0||$t){var i=Ot;Ot<<=1,(Ot&3932160)===0&&(Ot=262144),Zs=i}else Zs=536870912;return i=qs.current,i!==null&&(i.flags|=32),Zs}function Ds(i,l,d){(i===an&&(Gt===2||Gt===9)||i.cancelPendingCommit!==null)&&(Tl(i,0),fi(i,It,Zs,!1)),Rn(i,d),((Vt&2)===0||i!==an)&&(i===an&&((Vt&2)===0&&(vo|=d),En===4&&fi(i,It,Zs,!1)),tr(i))}function JN(i,l,d){if((Vt&6)!==0)throw Error(a(327));var p=!d&&(l&127)===0&&(l&i.expiredLanes)===0||Mn(i,l),b=p?x5(i,l):qv(i,l,!0),j=p;do{if(b===0){Cl&&!p&&fi(i,l,0,!1);break}else{if(d=i.current.alternate,j&&!v5(d)){b=qv(i,l,!1),j=!1;continue}if(b===2){if(j=l,i.errorRecoveryDisabledLanes&j)var M=0;else M=i.pendingLanes&-536870913,M=M!==0?M:M&536870912?536870912:0;if(M!==0){l=M;e:{var F=i;b=vu;var J=F.current.memoizedState.isDehydrated;if(J&&(Tl(F,M).flags|=256),M=qv(F,M,!1),M!==2){if(Lv&&!J){F.errorRecoveryDisabledLanes|=j,vo|=j,b=4;break e}j=Ps,Ps=b,j!==null&&(Ps===null?Ps=j:Ps.push.apply(Ps,j))}b=M}if(j=!1,b!==2)continue}}if(b===1){Tl(i,0),fi(i,l,0,!0);break}e:{switch(p=i,j=b,j){case 0:case 1:throw Error(a(345));case 4:if((l&4194048)!==l)break;case 6:fi(p,l,Zs,!li);break e;case 2:Ps=null;break;case 3:case 5:break;default:throw Error(a(329))}if((l&62914560)===l&&(b=Hf+300-Ie(),10<b)){if(fi(p,l,Zs,!li),Bt(p,0,!0)!==0)break e;zr=l,p.timeoutHandle=Mk(ek.bind(null,p,d,Ps,Wf,Bv,l,Zs,vo,El,li,j,"Throttled",-0,0),b);break e}ek(p,d,Ps,Wf,Bv,l,Zs,vo,El,li,j,null,-0,0)}}break}while(!0);tr(i)}function ek(i,l,d,p,b,j,M,F,J,le,ye,je,ue,fe){if(i.timeoutHandle=-1,je=l.subtreeFlags,je&8192||(je&16785408)===16785408){je={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:kr},WN(l,j,je);var Ze=(j&62914560)===j?Hf-Ie():(j&4194048)===j?YN-Ie():0;if(Ze=t4(je,Ze),Ze!==null){zr=j,i.cancelPendingCommit=Ze(lk.bind(null,i,l,j,d,p,b,M,F,J,ye,je,null,ue,fe)),fi(i,j,M,!le);return}}lk(i,l,j,d,p,b,M,F,J)}function v5(i){for(var l=i;;){var d=l.tag;if((d===0||d===11||d===15)&&l.flags&16384&&(d=l.updateQueue,d!==null&&(d=d.stores,d!==null)))for(var p=0;p<d.length;p++){var b=d[p],j=b.getSnapshot;b=b.value;try{if(!Vs(j(),b))return!1}catch{return!1}}if(d=l.child,l.subtreeFlags&16384&&d!==null)d.return=l,l=d;else{if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function fi(i,l,d,p){l&=~zv,l&=~vo,i.suspendedLanes|=l,i.pingedLanes&=~l,p&&(i.warmLanes|=l),p=i.expirationTimes;for(var b=l;0<b;){var j=31-he(b),M=1<<j;p[j]=-1,b&=~M}d!==0&&ys(i,d,l)}function Gf(){return(Vt&6)===0?(xu(0),!1):!0}function Hv(){if(Et!==null){if(Gt===0)var i=Et.return;else i=Et,Ar=oo=null,iv(i),xl=null,tu=0,i=Et;for(;i!==null;)RN(i.alternate,i),i=i.return;Et=null}}function Tl(i,l){var d=i.timeoutHandle;d!==-1&&(i.timeoutHandle=-1,D5(d)),d=i.cancelPendingCommit,d!==null&&(i.cancelPendingCommit=null,d()),zr=0,Hv(),an=i,Et=d=Cr(i.current,null),It=l,Gt=0,Gs=null,li=!1,Cl=Mn(i,l),Lv=!1,El=Zs=zv=vo=ci=En=0,Ps=vu=null,Bv=!1,(l&8)!==0&&(l|=l&32);var p=i.entangledLanes;if(p!==0)for(i=i.entanglements,p&=l;0<p;){var b=31-he(p),j=1<<b;l|=i[b],p&=~j}return Lr=l,mf(),d}function tk(i,l){vt=null,O.H=cu,l===yl||l===jf?(l=v1(),Gt=3):l===Zg?(l=v1(),Gt=4):Gt=l===jv?8:l!==null&&typeof l=="object"&&typeof l.then=="function"?6:1,Gs=l,Et===null&&(En=1,Pf(i,ma(l,i.current)))}function nk(){var i=qs.current;return i===null?!0:(It&4194048)===It?ya===null:(It&62914560)===It||(It&536870912)!==0?i===ya:!1}function sk(){var i=O.H;return O.H=cu,i===null?cu:i}function ak(){var i=O.A;return O.A=p5,i}function Zf(){En=4,li||(It&4194048)!==It&&qs.current!==null||(Cl=!0),(ci&134217727)===0&&(vo&134217727)===0||an===null||fi(an,It,Zs,!1)}function qv(i,l,d){var p=Vt;Vt|=2;var b=sk(),j=ak();(an!==i||It!==l)&&(Wf=null,Tl(i,l)),l=!1;var M=En;e:do try{if(Gt!==0&&Et!==null){var F=Et,J=Gs;switch(Gt){case 8:Hv(),M=6;break e;case 3:case 2:case 9:case 6:qs.current===null&&(l=!0);var le=Gt;if(Gt=0,Gs=null,Ml(i,F,J,le),d&&Cl){M=0;break e}break;default:le=Gt,Gt=0,Gs=null,Ml(i,F,J,le)}}y5(),M=En;break}catch(ye){tk(i,ye)}while(!0);return l&&i.shellSuspendCounter++,Ar=oo=null,Vt=p,O.H=b,O.A=j,Et===null&&(an=null,It=0,mf()),M}function y5(){for(;Et!==null;)rk(Et)}function x5(i,l){var d=Vt;Vt|=2;var p=sk(),b=ak();an!==i||It!==l?(Wf=null,qf=Ie()+500,Tl(i,l)):Cl=Mn(i,l);e:do try{if(Gt!==0&&Et!==null){l=Et;var j=Gs;t:switch(Gt){case 1:Gt=0,Gs=null,Ml(i,l,j,1);break;case 2:case 9:if(p1(j)){Gt=0,Gs=null,ik(l);break}l=function(){Gt!==2&&Gt!==9||an!==i||(Gt=7),tr(i)},j.then(l,l);break e;case 3:Gt=7;break e;case 4:Gt=5;break e;case 7:p1(j)?(Gt=0,Gs=null,ik(l)):(Gt=0,Gs=null,Ml(i,l,j,7));break;case 5:var M=null;switch(Et.tag){case 26:M=Et.memoizedState;case 5:case 27:var F=Et;if(M?qk(M):F.stateNode.complete){Gt=0,Gs=null;var J=F.sibling;if(J!==null)Et=J;else{var le=F.return;le!==null?(Et=le,Kf(le)):Et=null}break t}}Gt=0,Gs=null,Ml(i,l,j,5);break;case 6:Gt=0,Gs=null,Ml(i,l,j,6);break;case 8:Hv(),En=6;break e;default:throw Error(a(462))}}b5();break}catch(ye){tk(i,ye)}while(!0);return Ar=oo=null,O.H=p,O.A=b,Vt=d,Et!==null?0:(an=null,It=0,mf(),En)}function b5(){for(;Et!==null&&!Ve();)rk(Et)}function rk(i){var l=TN(i.alternate,i,Lr);i.memoizedProps=i.pendingProps,l===null?Kf(i):Et=l}function ik(i){var l=i,d=l.alternate;switch(l.tag){case 15:case 0:l=NN(d,l,l.pendingProps,l.type,void 0,It);break;case 11:l=NN(d,l,l.pendingProps,l.type.render,l.ref,It);break;case 5:iv(l);default:RN(d,l),l=Et=a1(l,Lr),l=TN(d,l,Lr)}i.memoizedProps=i.pendingProps,l===null?Kf(i):Et=l}function Ml(i,l,d,p){Ar=oo=null,iv(l),xl=null,tu=0;var b=l.return;try{if(l5(i,b,l,d,It)){En=1,Pf(i,ma(d,i.current)),Et=null;return}}catch(j){if(b!==null)throw Et=b,j;En=1,Pf(i,ma(d,i.current)),Et=null;return}l.flags&32768?($t||p===1?i=!0:Cl||(It&536870912)!==0?i=!1:(li=i=!0,(p===2||p===9||p===3||p===6)&&(p=qs.current,p!==null&&p.tag===13&&(p.flags|=16384))),ok(l,i)):Kf(l)}function Kf(i){var l=i;do{if((l.flags&32768)!==0){ok(l,li);return}i=l.return;var d=d5(l.alternate,l,Lr);if(d!==null){Et=d;return}if(l=l.sibling,l!==null){Et=l;return}Et=l=i}while(l!==null);En===0&&(En=5)}function ok(i,l){do{var d=f5(i.alternate,i);if(d!==null){d.flags&=32767,Et=d;return}if(d=i.return,d!==null&&(d.flags|=32768,d.subtreeFlags=0,d.deletions=null),!l&&(i=i.sibling,i!==null)){Et=i;return}Et=i=d}while(i!==null);En=6,Et=null}function lk(i,l,d,p,b,j,M,F,J){i.cancelPendingCommit=null;do Yf();while(Kn!==0);if((Vt&6)!==0)throw Error(a(327));if(l!==null){if(l===i.current)throw Error(a(177));if(j=l.lanes|l.childLanes,j|=_g,ts(i,d,j,M,F,J),i===an&&(Et=an=null,It=0),Al=l,di=i,zr=d,Uv=j,Fv=b,XN=p,(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,k5(st,function(){return hk(),null})):(i.callbackNode=null,i.callbackPriority=0),p=(l.flags&13878)!==0,(l.subtreeFlags&13878)!==0||p){p=O.T,O.T=null,b=z.p,z.p=2,M=Vt,Vt|=4;try{h5(i,l,d)}finally{Vt=M,z.p=b,O.T=p}}Kn=1,ck(),uk(),dk()}}function ck(){if(Kn===1){Kn=0;var i=di,l=Al,d=(l.flags&13878)!==0;if((l.subtreeFlags&13878)!==0||d){d=O.T,O.T=null;var p=z.p;z.p=2;var b=Vt;Vt|=4;try{VN(l,i);var j=sy,M=Kj(i.containerInfo),F=j.focusedElem,J=j.selectionRange;if(M!==F&&F&&F.ownerDocument&&Zj(F.ownerDocument.documentElement,F)){if(J!==null&&Ag(F)){var le=J.start,ye=J.end;if(ye===void 0&&(ye=le),"selectionStart"in F)F.selectionStart=le,F.selectionEnd=Math.min(ye,F.value.length);else{var je=F.ownerDocument||document,ue=je&&je.defaultView||window;if(ue.getSelection){var fe=ue.getSelection(),Ze=F.textContent.length,ot=Math.min(J.start,Ze),en=J.end===void 0?ot:Math.min(J.end,Ze);!fe.extend&&ot>en&&(M=en,en=ot,ot=M);var ie=Gj(F,ot),se=Gj(F,en);if(ie&&se&&(fe.rangeCount!==1||fe.anchorNode!==ie.node||fe.anchorOffset!==ie.offset||fe.focusNode!==se.node||fe.focusOffset!==se.offset)){var oe=je.createRange();oe.setStart(ie.node,ie.offset),fe.removeAllRanges(),ot>en?(fe.addRange(oe),fe.extend(se.node,se.offset)):(oe.setEnd(se.node,se.offset),fe.addRange(oe))}}}}for(je=[],fe=F;fe=fe.parentNode;)fe.nodeType===1&&je.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof F.focus=="function"&&F.focus(),F=0;F<je.length;F++){var we=je[F];we.element.scrollLeft=we.left,we.element.scrollTop=we.top}}lh=!!ny,sy=ny=null}finally{Vt=b,z.p=p,O.T=d}}i.current=l,Kn=2}}function uk(){if(Kn===2){Kn=0;var i=di,l=Al,d=(l.flags&8772)!==0;if((l.subtreeFlags&8772)!==0||d){d=O.T,O.T=null;var p=z.p;z.p=2;var b=Vt;Vt|=4;try{LN(i,l.alternate,l)}finally{Vt=b,z.p=p,O.T=d}}Kn=3}}function dk(){if(Kn===4||Kn===3){Kn=0,Re();var i=di,l=Al,d=zr,p=XN;(l.subtreeFlags&10256)!==0||(l.flags&10256)!==0?Kn=5:(Kn=0,Al=di=null,fk(i,i.pendingLanes));var b=i.pendingLanes;if(b===0&&(ui=null),Ht(d),l=l.stateNode,Y&&typeof Y.onCommitFiberRoot=="function")try{Y.onCommitFiberRoot(xt,l,void 0,(l.current.flags&128)===128)}catch{}if(p!==null){l=O.T,b=z.p,z.p=2,O.T=null;try{for(var j=i.onRecoverableError,M=0;M<p.length;M++){var F=p[M];j(F.value,{componentStack:F.stack})}}finally{O.T=l,z.p=b}}(zr&3)!==0&&Yf(),tr(i),b=i.pendingLanes,(d&261930)!==0&&(b&42)!==0?i===Vv?yu++:(yu=0,Vv=i):yu=0,xu(0)}}function fk(i,l){(i.pooledCacheLanes&=l)===0&&(l=i.pooledCache,l!=null&&(i.pooledCache=null,Jc(l)))}function Yf(){return ck(),uk(),dk(),hk()}function hk(){if(Kn!==5)return!1;var i=di,l=Uv;Uv=0;var d=Ht(zr),p=O.T,b=z.p;try{z.p=32>d?32:d,O.T=null,d=Fv,Fv=null;var j=di,M=zr;if(Kn=0,Al=di=null,zr=0,(Vt&6)!==0)throw Error(a(331));var F=Vt;if(Vt|=4,ZN(j.current),qN(j,j.current,M,d),Vt=F,xu(0,!1),Y&&typeof Y.onPostCommitFiberRoot=="function")try{Y.onPostCommitFiberRoot(xt,j)}catch{}return!0}finally{z.p=b,O.T=p,fk(i,l)}}function mk(i,l,d){l=ma(d,l),l=wv(i.stateNode,l,2),i=ai(i,l,2),i!==null&&(Rn(i,2),tr(i))}function Zt(i,l,d){if(i.tag===3)mk(i,i,d);else for(;l!==null;){if(l.tag===3){mk(l,i,d);break}else if(l.tag===1){var p=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(ui===null||!ui.has(p))){i=ma(d,i),d=pN(2),p=ai(l,d,2),p!==null&&(gN(d,p,l,i),Rn(p,2),tr(p));break}}l=l.return}}function Wv(i,l,d){var p=i.pingCache;if(p===null){p=i.pingCache=new g5;var b=new Set;p.set(l,b)}else b=p.get(l),b===void 0&&(b=new Set,p.set(l,b));b.has(d)||(Lv=!0,b.add(d),i=w5.bind(null,i,l,d),l.then(i,i))}function w5(i,l,d){var p=i.pingCache;p!==null&&p.delete(l),i.pingedLanes|=i.suspendedLanes&d,i.warmLanes&=~d,an===i&&(It&d)===d&&(En===4||En===3&&(It&62914560)===It&&300>Ie()-Hf?(Vt&2)===0&&Tl(i,0):zv|=d,El===It&&(El=0)),tr(i)}function pk(i,l){l===0&&(l=vs()),i=ao(i,l),i!==null&&(Rn(i,l),tr(i))}function j5(i){var l=i.memoizedState,d=0;l!==null&&(d=l.retryLane),pk(i,d)}function N5(i,l){var d=0;switch(i.tag){case 31:case 13:var p=i.stateNode,b=i.memoizedState;b!==null&&(d=b.retryLane);break;case 19:p=i.stateNode;break;case 22:p=i.stateNode._retryCache;break;default:throw Error(a(314))}p!==null&&p.delete(l),pk(i,d)}function k5(i,l){return Oe(i,l)}var Xf=null,Rl=null,Gv=!1,Qf=!1,Zv=!1,hi=0;function tr(i){i!==Rl&&i.next===null&&(Rl===null?Xf=Rl=i:Rl=Rl.next=i),Qf=!0,Gv||(Gv=!0,C5())}function xu(i,l){if(!Zv&&Qf){Zv=!0;do for(var d=!1,p=Xf;p!==null;){if(i!==0){var b=p.pendingLanes;if(b===0)var j=0;else{var M=p.suspendedLanes,F=p.pingedLanes;j=(1<<31-he(42|i)+1)-1,j&=b&~(M&~F),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(d=!0,xk(p,j))}else j=It,j=Bt(p,p===an?j:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(j&3)===0||Mn(p,j)||(d=!0,xk(p,j));p=p.next}while(d);Zv=!1}}function S5(){gk()}function gk(){Qf=Gv=!1;var i=0;hi!==0&&P5()&&(i=hi);for(var l=Ie(),d=null,p=Xf;p!==null;){var b=p.next,j=vk(p,l);j===0?(p.next=null,d===null?Xf=b:d.next=b,b===null&&(Rl=d)):(d=p,(i!==0||(j&3)!==0)&&(Qf=!0)),p=b}Kn!==0&&Kn!==5||xu(i),hi!==0&&(hi=0)}function vk(i,l){for(var d=i.suspendedLanes,p=i.pingedLanes,b=i.expirationTimes,j=i.pendingLanes&-62914561;0<j;){var M=31-he(j),F=1<<M,J=b[M];J===-1?((F&d)===0||(F&p)!==0)&&(b[M]=es(F,l)):J<=l&&(i.expiredLanes|=F),j&=~F}if(l=an,d=It,d=Bt(i,i===l?d:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),p=i.callbackNode,d===0||i===l&&(Gt===2||Gt===9)||i.cancelPendingCommit!==null)return p!==null&&p!==null&&Ce(p),i.callbackNode=null,i.callbackPriority=0;if((d&3)===0||Mn(i,d)){if(l=d&-d,l===i.callbackPriority)return l;switch(p!==null&&Ce(p),Ht(d)){case 2:case 8:d=ut;break;case 32:d=st;break;case 268435456:d=yt;break;default:d=st}return p=yk.bind(null,i),d=Oe(d,p),i.callbackPriority=l,i.callbackNode=d,l}return p!==null&&p!==null&&Ce(p),i.callbackPriority=2,i.callbackNode=null,2}function yk(i,l){if(Kn!==0&&Kn!==5)return i.callbackNode=null,i.callbackPriority=0,null;var d=i.callbackNode;if(Yf()&&i.callbackNode!==d)return null;var p=It;return p=Bt(i,i===an?p:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),p===0?null:(JN(i,p,l),vk(i,Ie()),i.callbackNode!=null&&i.callbackNode===d?yk.bind(null,i):null)}function xk(i,l){if(Yf())return null;JN(i,l,!0)}function C5(){L5(function(){(Vt&6)!==0?Oe(ct,S5):gk()})}function Kv(){if(hi===0){var i=gl;i===0&&(i=at,at<<=1,(at&261888)===0&&(at=256)),hi=i}return hi}function bk(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:rf(""+i)}function wk(i,l){var d=l.ownerDocument.createElement("input");return d.name=l.name,d.value=l.value,i.id&&d.setAttribute("form",i.id),l.parentNode.insertBefore(d,l),i=new FormData(i),d.parentNode.removeChild(d),i}function E5(i,l,d,p,b){if(l==="submit"&&d&&d.stateNode===b){var j=bk((b[He]||null).action),M=p.submitter;M&&(l=(l=M[He]||null)?bk(l.formAction):M.getAttribute("formAction"),l!==null&&(j=l,M=null));var F=new uf("action","action",null,p,b);i.push({event:F,listeners:[{instance:null,listener:function(){if(p.defaultPrevented){if(hi!==0){var J=M?wk(b,M):new FormData(b);pv(d,{pending:!0,data:J,method:b.method,action:j},null,J)}}else typeof j=="function"&&(F.preventDefault(),J=M?wk(b,M):new FormData(b),pv(d,{pending:!0,data:J,method:b.method,action:j},j,J))},currentTarget:b}]})}}for(var Yv=0;Yv<Ig.length;Yv++){var Xv=Ig[Yv],A5=Xv.toLowerCase(),T5=Xv[0].toUpperCase()+Xv.slice(1);_a(A5,"on"+T5)}_a(Qj,"onAnimationEnd"),_a(Jj,"onAnimationIteration"),_a(e1,"onAnimationStart"),_a("dblclick","onDoubleClick"),_a("focusin","onFocus"),_a("focusout","onBlur"),_a(qL,"onTransitionRun"),_a(WL,"onTransitionStart"),_a(GL,"onTransitionCancel"),_a(t1,"onTransitionEnd"),Ma("onMouseEnter",["mouseout","mouseover"]),Ma("onMouseLeave",["mouseout","mouseover"]),Ma("onPointerEnter",["pointerout","pointerover"]),Ma("onPointerLeave",["pointerout","pointerover"]),da("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),da("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),da("onBeforeInput",["compositionend","keypress","textInput","paste"]),da("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),da("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),da("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),M5=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(bu));function jk(i,l){l=(l&4)!==0;for(var d=0;d<i.length;d++){var p=i[d],b=p.event;p=p.listeners;e:{var j=void 0;if(l)for(var M=p.length-1;0<=M;M--){var F=p[M],J=F.instance,le=F.currentTarget;if(F=F.listener,J!==j&&b.isPropagationStopped())break e;j=F,b.currentTarget=le;try{j(b)}catch(ye){hf(ye)}b.currentTarget=null,j=J}else for(M=0;M<p.length;M++){if(F=p[M],J=F.instance,le=F.currentTarget,F=F.listener,J!==j&&b.isPropagationStopped())break e;j=F,b.currentTarget=le;try{j(b)}catch(ye){hf(ye)}b.currentTarget=null,j=J}}}}function At(i,l){var d=l[nn];d===void 0&&(d=l[nn]=new Set);var p=i+"__bubble";d.has(p)||(Nk(l,i,2,!1),d.add(p))}function Qv(i,l,d){var p=0;l&&(p|=4),Nk(d,i,p,l)}var Jf="_reactListening"+Math.random().toString(36).slice(2);function Jv(i){if(!i[Jf]){i[Jf]=!0,Qn.forEach(function(d){d!=="selectionchange"&&(M5.has(d)||Qv(d,!1,i),Qv(d,!0,i))});var l=i.nodeType===9?i:i.ownerDocument;l===null||l[Jf]||(l[Jf]=!0,Qv("selectionchange",!1,l))}}function Nk(i,l,d,p){switch(Qk(l)){case 2:var b=a4;break;case 8:b=r4;break;default:b=my}d=b.bind(null,l,d,i),b=void 0,!xg||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(b=!0),p?b!==void 0?i.addEventListener(l,d,{capture:!0,passive:b}):i.addEventListener(l,d,!0):b!==void 0?i.addEventListener(l,d,{passive:b}):i.addEventListener(l,d,!1)}function ey(i,l,d,p,b){var j=p;if((l&1)===0&&(l&2)===0&&p!==null)e:for(;;){if(p===null)return;var M=p.tag;if(M===3||M===4){var F=p.stateNode.containerInfo;if(F===b)break;if(M===4)for(M=p.return;M!==null;){var J=M.tag;if((J===3||J===4)&&M.stateNode.containerInfo===b)return;M=M.return}for(;F!==null;){if(M=ws(F),M===null)return;if(J=M.tag,J===5||J===6||J===26||J===27){p=j=M;continue e}F=F.parentNode}}p=p.return}Aj(function(){var le=j,ye=vg(d),je=[];e:{var ue=n1.get(i);if(ue!==void 0){var fe=uf,Ze=i;switch(i){case"keypress":if(lf(d)===0)break e;case"keydown":case"keyup":fe=NL;break;case"focusin":Ze="focus",fe=Ng;break;case"focusout":Ze="blur",fe=Ng;break;case"beforeblur":case"afterblur":fe=Ng;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=Rj;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=dL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=CL;break;case Qj:case Jj:case e1:fe=mL;break;case t1:fe=AL;break;case"scroll":case"scrollend":fe=cL;break;case"wheel":fe=ML;break;case"copy":case"cut":case"paste":fe=gL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=_j;break;case"toggle":case"beforetoggle":fe=IL}var ot=(l&4)!==0,en=!ot&&(i==="scroll"||i==="scrollend"),ie=ot?ue!==null?ue+"Capture":null:ue;ot=[];for(var se=le,oe;se!==null;){var we=se;if(oe=we.stateNode,we=we.tag,we!==5&&we!==26&&we!==27||oe===null||ie===null||(we=Fc(se,ie),we!=null&&ot.push(wu(se,we,oe))),en)break;se=se.return}0<ot.length&&(ue=new fe(ue,Ze,null,d,ye),je.push({event:ue,listeners:ot}))}}if((l&7)===0){e:{if(ue=i==="mouseover"||i==="pointerover",fe=i==="mouseout"||i==="pointerout",ue&&d!==gg&&(Ze=d.relatedTarget||d.fromElement)&&(ws(Ze)||Ze[Lt]))break e;if((fe||ue)&&(ue=ye.window===ye?ye:(ue=ye.ownerDocument)?ue.defaultView||ue.parentWindow:window,fe?(Ze=d.relatedTarget||d.toElement,fe=le,Ze=Ze?ws(Ze):null,Ze!==null&&(en=o(Ze),ot=Ze.tag,Ze!==en||ot!==5&&ot!==27&&ot!==6)&&(Ze=null)):(fe=null,Ze=le),fe!==Ze)){if(ot=Rj,we="onMouseLeave",ie="onMouseEnter",se="mouse",(i==="pointerout"||i==="pointerover")&&(ot=_j,we="onPointerLeave",ie="onPointerEnter",se="pointer"),en=fe==null?ue:js(fe),oe=Ze==null?ue:js(Ze),ue=new ot(we,se+"leave",fe,d,ye),ue.target=en,ue.relatedTarget=oe,we=null,ws(ye)===le&&(ot=new ot(ie,se+"enter",Ze,d,ye),ot.target=oe,ot.relatedTarget=en,we=ot),en=we,fe&&Ze)t:{for(ot=R5,ie=fe,se=Ze,oe=0,we=ie;we;we=ot(we))oe++;we=0;for(var nt=se;nt;nt=ot(nt))we++;for(;0<oe-we;)ie=ot(ie),oe--;for(;0<we-oe;)se=ot(se),we--;for(;oe--;){if(ie===se||se!==null&&ie===se.alternate){ot=ie;break t}ie=ot(ie),se=ot(se)}ot=null}else ot=null;fe!==null&&kk(je,ue,fe,ot,!1),Ze!==null&&en!==null&&kk(je,en,Ze,ot,!0)}}e:{if(ue=le?js(le):window,fe=ue.nodeName&&ue.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ue.type==="file")var Ut=Uj;else if(zj(ue))if(Fj)Ut=FL;else{Ut=BL;var et=zL}else fe=ue.nodeName,!fe||fe.toLowerCase()!=="input"||ue.type!=="checkbox"&&ue.type!=="radio"?le&&Zn(le.elementType)&&(Ut=Uj):Ut=UL;if(Ut&&(Ut=Ut(i,le))){Bj(je,Ut,d,ye);break e}et&&et(i,ue,le),i==="focusout"&&le&&ue.type==="number"&&le.memoizedProps.value!=null&&Fe(ue,"number",ue.value)}switch(et=le?js(le):window,i){case"focusin":(zj(et)||et.contentEditable==="true")&&(ll=et,Tg=le,Yc=null);break;case"focusout":Yc=Tg=ll=null;break;case"mousedown":Mg=!0;break;case"contextmenu":case"mouseup":case"dragend":Mg=!1,Yj(je,d,ye);break;case"selectionchange":if(HL)break;case"keydown":case"keyup":Yj(je,d,ye)}var wt;if(Sg)e:{switch(i){case"compositionstart":var _t="onCompositionStart";break e;case"compositionend":_t="onCompositionEnd";break e;case"compositionupdate":_t="onCompositionUpdate";break e}_t=void 0}else ol?Dj(i,d)&&(_t="onCompositionEnd"):i==="keydown"&&d.keyCode===229&&(_t="onCompositionStart");_t&&(Oj&&d.locale!=="ko"&&(ol||_t!=="onCompositionStart"?_t==="onCompositionEnd"&&ol&&(wt=Tj()):(Xr=ye,bg="value"in Xr?Xr.value:Xr.textContent,ol=!0)),et=eh(le,_t),0<et.length&&(_t=new Ij(_t,i,null,d,ye),je.push({event:_t,listeners:et}),wt?_t.data=wt:(wt=Lj(d),wt!==null&&(_t.data=wt)))),(wt=OL?$L(i,d):PL(i,d))&&(_t=eh(le,"onBeforeInput"),0<_t.length&&(et=new Ij("onBeforeInput","beforeinput",null,d,ye),je.push({event:et,listeners:_t}),et.data=wt)),E5(je,i,le,d,ye)}jk(je,l)})}function wu(i,l,d){return{instance:i,listener:l,currentTarget:d}}function eh(i,l){for(var d=l+"Capture",p=[];i!==null;){var b=i,j=b.stateNode;if(b=b.tag,b!==5&&b!==26&&b!==27||j===null||(b=Fc(i,d),b!=null&&p.unshift(wu(i,b,j)),b=Fc(i,l),b!=null&&p.push(wu(i,b,j))),i.tag===3)return p;i=i.return}return[]}function R5(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function kk(i,l,d,p,b){for(var j=l._reactName,M=[];d!==null&&d!==p;){var F=d,J=F.alternate,le=F.stateNode;if(F=F.tag,J!==null&&J===p)break;F!==5&&F!==26&&F!==27||le===null||(J=le,b?(le=Fc(d,j),le!=null&&M.unshift(wu(d,le,J))):b||(le=Fc(d,j),le!=null&&M.push(wu(d,le,J)))),d=d.return}M.length!==0&&i.push({event:l,listeners:M})}var I5=/\r\n?/g,_5=/\u0000|\uFFFD/g;function Sk(i){return(typeof i=="string"?i:""+i).replace(I5,`
9
+ `).replace(_5,"")}function Ck(i,l){return l=Sk(l),Sk(i)===l}function Jt(i,l,d,p,b,j){switch(d){case"children":typeof p=="string"?l==="body"||l==="textarea"&&p===""||Xt(i,p):(typeof p=="number"||typeof p=="bigint")&&l!=="body"&&Xt(i,""+p);break;case"className":Nr(i,"class",p);break;case"tabIndex":Nr(i,"tabindex",p);break;case"dir":case"role":case"viewBox":case"width":case"height":Nr(i,d,p);break;case"style":fa(i,p,j);break;case"data":if(l!=="object"){Nr(i,"data",p);break}case"src":case"href":if(p===""&&(l!=="a"||d!=="href")){i.removeAttribute(d);break}if(p==null||typeof p=="function"||typeof p=="symbol"||typeof p=="boolean"){i.removeAttribute(d);break}p=rf(""+p),i.setAttribute(d,p);break;case"action":case"formAction":if(typeof p=="function"){i.setAttribute(d,"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}else typeof j=="function"&&(d==="formAction"?(l!=="input"&&Jt(i,l,"name",b.name,b,null),Jt(i,l,"formEncType",b.formEncType,b,null),Jt(i,l,"formMethod",b.formMethod,b,null),Jt(i,l,"formTarget",b.formTarget,b,null)):(Jt(i,l,"encType",b.encType,b,null),Jt(i,l,"method",b.method,b,null),Jt(i,l,"target",b.target,b,null)));if(p==null||typeof p=="symbol"||typeof p=="boolean"){i.removeAttribute(d);break}p=rf(""+p),i.setAttribute(d,p);break;case"onClick":p!=null&&(i.onclick=kr);break;case"onScroll":p!=null&&At("scroll",i);break;case"onScrollEnd":p!=null&&At("scrollend",i);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(a(61));if(d=p.__html,d!=null){if(b.children!=null)throw Error(a(60));i.innerHTML=d}}break;case"multiple":i.multiple=p&&typeof p!="function"&&typeof p!="symbol";break;case"muted":i.muted=p&&typeof p!="function"&&typeof p!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(p==null||typeof p=="function"||typeof p=="boolean"||typeof p=="symbol"){i.removeAttribute("xlink:href");break}d=rf(""+p),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":p!=null&&typeof p!="function"&&typeof p!="symbol"?i.setAttribute(d,""+p):i.removeAttribute(d);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":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":p&&typeof p!="function"&&typeof p!="symbol"?i.setAttribute(d,""):i.removeAttribute(d);break;case"capture":case"download":p===!0?i.setAttribute(d,""):p!==!1&&p!=null&&typeof p!="function"&&typeof p!="symbol"?i.setAttribute(d,p):i.removeAttribute(d);break;case"cols":case"rows":case"size":case"span":p!=null&&typeof p!="function"&&typeof p!="symbol"&&!isNaN(p)&&1<=p?i.setAttribute(d,p):i.removeAttribute(d);break;case"rowSpan":case"start":p==null||typeof p=="function"||typeof p=="symbol"||isNaN(p)?i.removeAttribute(d):i.setAttribute(d,p);break;case"popover":At("beforetoggle",i),At("toggle",i),Ia(i,"popover",p);break;case"xlinkActuate":Fs(i,"http://www.w3.org/1999/xlink","xlink:actuate",p);break;case"xlinkArcrole":Fs(i,"http://www.w3.org/1999/xlink","xlink:arcrole",p);break;case"xlinkRole":Fs(i,"http://www.w3.org/1999/xlink","xlink:role",p);break;case"xlinkShow":Fs(i,"http://www.w3.org/1999/xlink","xlink:show",p);break;case"xlinkTitle":Fs(i,"http://www.w3.org/1999/xlink","xlink:title",p);break;case"xlinkType":Fs(i,"http://www.w3.org/1999/xlink","xlink:type",p);break;case"xmlBase":Fs(i,"http://www.w3.org/XML/1998/namespace","xml:base",p);break;case"xmlLang":Fs(i,"http://www.w3.org/XML/1998/namespace","xml:lang",p);break;case"xmlSpace":Fs(i,"http://www.w3.org/XML/1998/namespace","xml:space",p);break;case"is":Ia(i,"is",p);break;case"innerText":case"textContent":break;default:(!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(d=sf.get(d)||d,Ia(i,d,p))}}function ty(i,l,d,p,b,j){switch(d){case"style":fa(i,p,j);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(a(61));if(d=p.__html,d!=null){if(b.children!=null)throw Error(a(60));i.innerHTML=d}}break;case"children":typeof p=="string"?Xt(i,p):(typeof p=="number"||typeof p=="bigint")&&Xt(i,""+p);break;case"onScroll":p!=null&&At("scroll",i);break;case"onScrollEnd":p!=null&&At("scrollend",i);break;case"onClick":p!=null&&(i.onclick=kr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Kr.hasOwnProperty(d))e:{if(d[0]==="o"&&d[1]==="n"&&(b=d.endsWith("Capture"),l=d.slice(2,b?d.length-7:void 0),j=i[He]||null,j=j!=null?j[d]:null,typeof j=="function"&&i.removeEventListener(l,j,b),typeof p=="function")){typeof j!="function"&&j!==null&&(d in i?i[d]=null:i.hasAttribute(d)&&i.removeAttribute(d)),i.addEventListener(l,p,b);break e}d in i?i[d]=p:p===!0?i.setAttribute(d,""):Ia(i,d,p)}}}function rs(i,l,d){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":At("error",i),At("load",i);var p=!1,b=!1,j;for(j in d)if(d.hasOwnProperty(j)){var M=d[j];if(M!=null)switch(j){case"src":p=!0;break;case"srcSet":b=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,l));default:Jt(i,l,j,M,d,null)}}b&&Jt(i,l,"srcSet",d.srcSet,d,null),p&&Jt(i,l,"src",d.src,d,null);return;case"input":At("invalid",i);var F=j=M=b=null,J=null,le=null;for(p in d)if(d.hasOwnProperty(p)){var ye=d[p];if(ye!=null)switch(p){case"name":b=ye;break;case"type":M=ye;break;case"checked":J=ye;break;case"defaultChecked":le=ye;break;case"value":j=ye;break;case"defaultValue":F=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(a(137,l));break;default:Jt(i,l,p,ye,d,null)}}Ee(i,j,F,J,le,M,b,!1);return;case"select":At("invalid",i),p=M=j=null;for(b in d)if(d.hasOwnProperty(b)&&(F=d[b],F!=null))switch(b){case"value":j=F;break;case"defaultValue":M=F;break;case"multiple":p=F;default:Jt(i,l,b,F,d,null)}l=j,d=M,i.multiple=!!p,l!=null?ze(i,!!p,l,!1):d!=null&&ze(i,!!p,d,!0);return;case"textarea":At("invalid",i),j=b=p=null;for(M in d)if(d.hasOwnProperty(M)&&(F=d[M],F!=null))switch(M){case"value":p=F;break;case"defaultValue":b=F;break;case"children":j=F;break;case"dangerouslySetInnerHTML":if(F!=null)throw Error(a(91));break;default:Jt(i,l,M,F,d,null)}fn(i,p,b,j);return;case"option":for(J in d)d.hasOwnProperty(J)&&(p=d[J],p!=null)&&(J==="selected"?i.selected=p&&typeof p!="function"&&typeof p!="symbol":Jt(i,l,J,p,d,null));return;case"dialog":At("beforetoggle",i),At("toggle",i),At("cancel",i),At("close",i);break;case"iframe":case"object":At("load",i);break;case"video":case"audio":for(p=0;p<bu.length;p++)At(bu[p],i);break;case"image":At("error",i),At("load",i);break;case"details":At("toggle",i);break;case"embed":case"source":case"link":At("error",i),At("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(le in d)if(d.hasOwnProperty(le)&&(p=d[le],p!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,l));default:Jt(i,l,le,p,d,null)}return;default:if(Zn(l)){for(ye in d)d.hasOwnProperty(ye)&&(p=d[ye],p!==void 0&&ty(i,l,ye,p,d,void 0));return}}for(F in d)d.hasOwnProperty(F)&&(p=d[F],p!=null&&Jt(i,l,F,p,d,null))}function O5(i,l,d,p){switch(l){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var b=null,j=null,M=null,F=null,J=null,le=null,ye=null;for(fe in d){var je=d[fe];if(d.hasOwnProperty(fe)&&je!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":J=je;default:p.hasOwnProperty(fe)||Jt(i,l,fe,null,p,je)}}for(var ue in p){var fe=p[ue];if(je=d[ue],p.hasOwnProperty(ue)&&(fe!=null||je!=null))switch(ue){case"type":j=fe;break;case"name":b=fe;break;case"checked":le=fe;break;case"defaultChecked":ye=fe;break;case"value":M=fe;break;case"defaultValue":F=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(a(137,l));break;default:fe!==je&&Jt(i,l,ue,fe,p,je)}}ve(i,M,F,J,le,ye,j,b);return;case"select":fe=M=F=ue=null;for(j in d)if(J=d[j],d.hasOwnProperty(j)&&J!=null)switch(j){case"value":break;case"multiple":fe=J;default:p.hasOwnProperty(j)||Jt(i,l,j,null,p,J)}for(b in p)if(j=p[b],J=d[b],p.hasOwnProperty(b)&&(j!=null||J!=null))switch(b){case"value":ue=j;break;case"defaultValue":F=j;break;case"multiple":M=j;default:j!==J&&Jt(i,l,b,j,p,J)}l=F,d=M,p=fe,ue!=null?ze(i,!!d,ue,!1):!!p!=!!d&&(l!=null?ze(i,!!d,l,!0):ze(i,!!d,d?[]:"",!1));return;case"textarea":fe=ue=null;for(F in d)if(b=d[F],d.hasOwnProperty(F)&&b!=null&&!p.hasOwnProperty(F))switch(F){case"value":break;case"children":break;default:Jt(i,l,F,null,p,b)}for(M in p)if(b=p[M],j=d[M],p.hasOwnProperty(M)&&(b!=null||j!=null))switch(M){case"value":ue=b;break;case"defaultValue":fe=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(a(91));break;default:b!==j&&Jt(i,l,M,b,p,j)}it(i,ue,fe);return;case"option":for(var Ze in d)ue=d[Ze],d.hasOwnProperty(Ze)&&ue!=null&&!p.hasOwnProperty(Ze)&&(Ze==="selected"?i.selected=!1:Jt(i,l,Ze,null,p,ue));for(J in p)ue=p[J],fe=d[J],p.hasOwnProperty(J)&&ue!==fe&&(ue!=null||fe!=null)&&(J==="selected"?i.selected=ue&&typeof ue!="function"&&typeof ue!="symbol":Jt(i,l,J,ue,p,fe));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 ot in d)ue=d[ot],d.hasOwnProperty(ot)&&ue!=null&&!p.hasOwnProperty(ot)&&Jt(i,l,ot,null,p,ue);for(le in p)if(ue=p[le],fe=d[le],p.hasOwnProperty(le)&&ue!==fe&&(ue!=null||fe!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(a(137,l));break;default:Jt(i,l,le,ue,p,fe)}return;default:if(Zn(l)){for(var en in d)ue=d[en],d.hasOwnProperty(en)&&ue!==void 0&&!p.hasOwnProperty(en)&&ty(i,l,en,void 0,p,ue);for(ye in p)ue=p[ye],fe=d[ye],!p.hasOwnProperty(ye)||ue===fe||ue===void 0&&fe===void 0||ty(i,l,ye,ue,p,fe);return}}for(var ie in d)ue=d[ie],d.hasOwnProperty(ie)&&ue!=null&&!p.hasOwnProperty(ie)&&Jt(i,l,ie,null,p,ue);for(je in p)ue=p[je],fe=d[je],!p.hasOwnProperty(je)||ue===fe||ue==null&&fe==null||Jt(i,l,je,ue,p,fe)}function Ek(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function $5(){if(typeof performance.getEntriesByType=="function"){for(var i=0,l=0,d=performance.getEntriesByType("resource"),p=0;p<d.length;p++){var b=d[p],j=b.transferSize,M=b.initiatorType,F=b.duration;if(j&&F&&Ek(M)){for(M=0,F=b.responseEnd,p+=1;p<d.length;p++){var J=d[p],le=J.startTime;if(le>F)break;var ye=J.transferSize,je=J.initiatorType;ye&&Ek(je)&&(J=J.responseEnd,M+=ye*(J<F?1:(F-le)/(J-le)))}if(--p,l+=8*(j+M)/(b.duration/1e3),i++,10<i)break}}if(0<i)return l/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var ny=null,sy=null;function th(i){return i.nodeType===9?i:i.ownerDocument}function Ak(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Tk(i,l){if(i===0)switch(l){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&l==="foreignObject"?0:i}function ay(i,l){return i==="textarea"||i==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.children=="bigint"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var ry=null;function P5(){var i=window.event;return i&&i.type==="popstate"?i===ry?!1:(ry=i,!0):(ry=null,!1)}var Mk=typeof setTimeout=="function"?setTimeout:void 0,D5=typeof clearTimeout=="function"?clearTimeout:void 0,Rk=typeof Promise=="function"?Promise:void 0,L5=typeof queueMicrotask=="function"?queueMicrotask:typeof Rk<"u"?function(i){return Rk.resolve(null).then(i).catch(z5)}:Mk;function z5(i){setTimeout(function(){throw i})}function mi(i){return i==="head"}function Ik(i,l){var d=l,p=0;do{var b=d.nextSibling;if(i.removeChild(d),b&&b.nodeType===8)if(d=b.data,d==="/$"||d==="/&"){if(p===0){i.removeChild(b),$l(l);return}p--}else if(d==="$"||d==="$?"||d==="$~"||d==="$!"||d==="&")p++;else if(d==="html")ju(i.ownerDocument.documentElement);else if(d==="head"){d=i.ownerDocument.head,ju(d);for(var j=d.firstChild;j;){var M=j.nextSibling,F=j.nodeName;j[Gn]||F==="SCRIPT"||F==="STYLE"||F==="LINK"&&j.rel.toLowerCase()==="stylesheet"||d.removeChild(j),j=M}}else d==="body"&&ju(i.ownerDocument.body);d=b}while(d);$l(l)}function _k(i,l){var d=i;i=0;do{var p=d.nextSibling;if(d.nodeType===1?l?(d._stashedDisplay=d.style.display,d.style.display="none"):(d.style.display=d._stashedDisplay||"",d.getAttribute("style")===""&&d.removeAttribute("style")):d.nodeType===3&&(l?(d._stashedText=d.nodeValue,d.nodeValue=""):d.nodeValue=d._stashedText||""),p&&p.nodeType===8)if(d=p.data,d==="/$"){if(i===0)break;i--}else d!=="$"&&d!=="$?"&&d!=="$~"&&d!=="$!"||i++;d=p}while(d)}function iy(i){var l=i.firstChild;for(l&&l.nodeType===10&&(l=l.nextSibling);l;){var d=l;switch(l=l.nextSibling,d.nodeName){case"HTML":case"HEAD":case"BODY":iy(d),ds(d);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(d.rel.toLowerCase()==="stylesheet")continue}i.removeChild(d)}}function B5(i,l,d,p){for(;i.nodeType===1;){var b=d;if(i.nodeName.toLowerCase()!==l.toLowerCase()){if(!p&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(p){if(!i[Gn])switch(l){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(j=i.getAttribute("rel"),j==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(j!==b.rel||i.getAttribute("href")!==(b.href==null||b.href===""?null:b.href)||i.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin)||i.getAttribute("title")!==(b.title==null?null:b.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(j=i.getAttribute("src"),(j!==(b.src==null?null:b.src)||i.getAttribute("type")!==(b.type==null?null:b.type)||i.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin))&&j&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(l==="input"&&i.type==="hidden"){var j=b.name==null?null:""+b.name;if(b.type==="hidden"&&i.getAttribute("name")===j)return i}else return i;if(i=xa(i.nextSibling),i===null)break}return null}function U5(i,l,d){if(l==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!d||(i=xa(i.nextSibling),i===null))return null;return i}function Ok(i,l){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!l||(i=xa(i.nextSibling),i===null))return null;return i}function oy(i){return i.data==="$?"||i.data==="$~"}function ly(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function F5(i,l){var d=i.ownerDocument;if(i.data==="$~")i._reactRetry=l;else if(i.data!=="$?"||d.readyState!=="loading")l();else{var p=function(){l(),d.removeEventListener("DOMContentLoaded",p)};d.addEventListener("DOMContentLoaded",p),i._reactRetry=p}}function xa(i){for(;i!=null;i=i.nextSibling){var l=i.nodeType;if(l===1||l===3)break;if(l===8){if(l=i.data,l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"||l==="F!"||l==="F")break;if(l==="/$"||l==="/&")return null}}return i}var cy=null;function $k(i){i=i.nextSibling;for(var l=0;i;){if(i.nodeType===8){var d=i.data;if(d==="/$"||d==="/&"){if(l===0)return xa(i.nextSibling);l--}else d!=="$"&&d!=="$!"&&d!=="$?"&&d!=="$~"&&d!=="&"||l++}i=i.nextSibling}return null}function Pk(i){i=i.previousSibling;for(var l=0;i;){if(i.nodeType===8){var d=i.data;if(d==="$"||d==="$!"||d==="$?"||d==="$~"||d==="&"){if(l===0)return i;l--}else d!=="/$"&&d!=="/&"||l++}i=i.previousSibling}return null}function Dk(i,l,d){switch(l=th(d),i){case"html":if(i=l.documentElement,!i)throw Error(a(452));return i;case"head":if(i=l.head,!i)throw Error(a(453));return i;case"body":if(i=l.body,!i)throw Error(a(454));return i;default:throw Error(a(451))}}function ju(i){for(var l=i.attributes;l.length;)i.removeAttributeNode(l[0]);ds(i)}var ba=new Map,Lk=new Set;function nh(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Br=z.d;z.d={f:V5,r:H5,D:q5,C:W5,L:G5,m:Z5,X:Y5,S:K5,M:X5};function V5(){var i=Br.f(),l=Gf();return i||l}function H5(i){var l=Xn(i);l!==null&&l.tag===5&&l.type==="form"?tN(l):Br.r(i)}var Il=typeof document>"u"?null:document;function zk(i,l,d){var p=Il;if(p&&typeof l=="string"&&l){var b=ne(l);b='link[rel="'+i+'"][href="'+b+'"]',typeof d=="string"&&(b+='[crossorigin="'+d+'"]'),Lk.has(b)||(Lk.add(b),i={rel:i,crossOrigin:d,href:l},p.querySelector(b)===null&&(l=p.createElement("link"),rs(l,"link",i),dn(l),p.head.appendChild(l)))}}function q5(i){Br.D(i),zk("dns-prefetch",i,null)}function W5(i,l){Br.C(i,l),zk("preconnect",i,l)}function G5(i,l,d){Br.L(i,l,d);var p=Il;if(p&&i&&l){var b='link[rel="preload"][as="'+ne(l)+'"]';l==="image"&&d&&d.imageSrcSet?(b+='[imagesrcset="'+ne(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(b+='[imagesizes="'+ne(d.imageSizes)+'"]')):b+='[href="'+ne(i)+'"]';var j=b;switch(l){case"style":j=_l(i);break;case"script":j=Ol(i)}ba.has(j)||(i=v({rel:"preload",href:l==="image"&&d&&d.imageSrcSet?void 0:i,as:l},d),ba.set(j,i),p.querySelector(b)!==null||l==="style"&&p.querySelector(Nu(j))||l==="script"&&p.querySelector(ku(j))||(l=p.createElement("link"),rs(l,"link",i),dn(l),p.head.appendChild(l)))}}function Z5(i,l){Br.m(i,l);var d=Il;if(d&&i){var p=l&&typeof l.as=="string"?l.as:"script",b='link[rel="modulepreload"][as="'+ne(p)+'"][href="'+ne(i)+'"]',j=b;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Ol(i)}if(!ba.has(j)&&(i=v({rel:"modulepreload",href:i},l),ba.set(j,i),d.querySelector(b)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(ku(j)))return}p=d.createElement("link"),rs(p,"link",i),dn(p),d.head.appendChild(p)}}}function K5(i,l,d){Br.S(i,l,d);var p=Il;if(p&&i){var b=ua(p).hoistableStyles,j=_l(i);l=l||"default";var M=b.get(j);if(!M){var F={loading:0,preload:null};if(M=p.querySelector(Nu(j)))F.loading=5;else{i=v({rel:"stylesheet",href:i,"data-precedence":l},d),(d=ba.get(j))&&uy(i,d);var J=M=p.createElement("link");dn(J),rs(J,"link",i),J._p=new Promise(function(le,ye){J.onload=le,J.onerror=ye}),J.addEventListener("load",function(){F.loading|=1}),J.addEventListener("error",function(){F.loading|=2}),F.loading|=4,sh(M,l,p)}M={type:"stylesheet",instance:M,count:1,state:F},b.set(j,M)}}}function Y5(i,l){Br.X(i,l);var d=Il;if(d&&i){var p=ua(d).hoistableScripts,b=Ol(i),j=p.get(b);j||(j=d.querySelector(ku(b)),j||(i=v({src:i,async:!0},l),(l=ba.get(b))&&dy(i,l),j=d.createElement("script"),dn(j),rs(j,"link",i),d.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},p.set(b,j))}}function X5(i,l){Br.M(i,l);var d=Il;if(d&&i){var p=ua(d).hoistableScripts,b=Ol(i),j=p.get(b);j||(j=d.querySelector(ku(b)),j||(i=v({src:i,async:!0,type:"module"},l),(l=ba.get(b))&&dy(i,l),j=d.createElement("script"),dn(j),rs(j,"link",i),d.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},p.set(b,j))}}function Bk(i,l,d,p){var b=(b=re.current)?nh(b):null;if(!b)throw Error(a(446));switch(i){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(l=_l(d.href),d=ua(b).hoistableStyles,p=d.get(l),p||(p={type:"style",instance:null,count:0,state:null},d.set(l,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){i=_l(d.href);var j=ua(b).hoistableStyles,M=j.get(i);if(M||(b=b.ownerDocument||b,M={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(i,M),(j=b.querySelector(Nu(i)))&&!j._p&&(M.instance=j,M.state.loading=5),ba.has(i)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},ba.set(i,d),j||Q5(b,i,d,M.state))),l&&p===null)throw Error(a(528,""));return M}if(l&&p!==null)throw Error(a(529,""));return null;case"script":return l=d.async,d=d.src,typeof d=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=Ol(d),d=ua(b).hoistableScripts,p=d.get(l),p||(p={type:"script",instance:null,count:0,state:null},d.set(l,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,i))}}function _l(i){return'href="'+ne(i)+'"'}function Nu(i){return'link[rel="stylesheet"]['+i+"]"}function Uk(i){return v({},i,{"data-precedence":i.precedence,precedence:null})}function Q5(i,l,d,p){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?p.loading=1:(l=i.createElement("link"),p.preload=l,l.addEventListener("load",function(){return p.loading|=1}),l.addEventListener("error",function(){return p.loading|=2}),rs(l,"link",d),dn(l),i.head.appendChild(l))}function Ol(i){return'[src="'+ne(i)+'"]'}function ku(i){return"script[async]"+i}function Fk(i,l,d){if(l.count++,l.instance===null)switch(l.type){case"style":var p=i.querySelector('style[data-href~="'+ne(d.href)+'"]');if(p)return l.instance=p,dn(p),p;var b=v({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return p=(i.ownerDocument||i).createElement("style"),dn(p),rs(p,"style",b),sh(p,d.precedence,i),l.instance=p;case"stylesheet":b=_l(d.href);var j=i.querySelector(Nu(b));if(j)return l.state.loading|=4,l.instance=j,dn(j),j;p=Uk(d),(b=ba.get(b))&&uy(p,b),j=(i.ownerDocument||i).createElement("link"),dn(j);var M=j;return M._p=new Promise(function(F,J){M.onload=F,M.onerror=J}),rs(j,"link",p),l.state.loading|=4,sh(j,d.precedence,i),l.instance=j;case"script":return j=Ol(d.src),(b=i.querySelector(ku(j)))?(l.instance=b,dn(b),b):(p=d,(b=ba.get(j))&&(p=v({},d),dy(p,b)),i=i.ownerDocument||i,b=i.createElement("script"),dn(b),rs(b,"link",p),i.head.appendChild(b),l.instance=b);case"void":return null;default:throw Error(a(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(p=l.instance,l.state.loading|=4,sh(p,d.precedence,i));return l.instance}function sh(i,l,d){for(var p=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=p.length?p[p.length-1]:null,j=b,M=0;M<p.length;M++){var F=p[M];if(F.dataset.precedence===l)j=F;else if(j!==b)break}j?j.parentNode.insertBefore(i,j.nextSibling):(l=d.nodeType===9?d.head:d,l.insertBefore(i,l.firstChild))}function uy(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.title==null&&(i.title=l.title)}function dy(i,l){i.crossOrigin==null&&(i.crossOrigin=l.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=l.referrerPolicy),i.integrity==null&&(i.integrity=l.integrity)}var ah=null;function Vk(i,l,d){if(ah===null){var p=new Map,b=ah=new Map;b.set(d,p)}else b=ah,p=b.get(d),p||(p=new Map,b.set(d,p));if(p.has(i))return p;for(p.set(i,null),d=d.getElementsByTagName(i),b=0;b<d.length;b++){var j=d[b];if(!(j[Gn]||j[Ue]||i==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var M=j.getAttribute(l)||"";M=i+M;var F=p.get(M);F?F.push(j):p.set(M,[j])}}return p}function Hk(i,l,d){i=i.ownerDocument||i,i.head.insertBefore(d,l==="title"?i.querySelector("head > title"):null)}function J5(i,l,d){if(d===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function qk(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function e4(i,l,d,p){if(d.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var b=_l(p.href),j=l.querySelector(Nu(b));if(j){l=j._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=rh.bind(i),l.then(i,i)),d.state.loading|=4,d.instance=j,dn(j);return}j=l.ownerDocument||l,p=Uk(p),(b=ba.get(b))&&uy(p,b),j=j.createElement("link"),dn(j);var M=j;M._p=new Promise(function(F,J){M.onload=F,M.onerror=J}),rs(j,"link",p),d.instance=j}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(d,l),(l=d.state.preload)&&(d.state.loading&3)===0&&(i.count++,d=rh.bind(i),l.addEventListener("load",d),l.addEventListener("error",d))}}var fy=0;function t4(i,l){return i.stylesheets&&i.count===0&&oh(i,i.stylesheets),0<i.count||0<i.imgCount?function(d){var p=setTimeout(function(){if(i.stylesheets&&oh(i,i.stylesheets),i.unsuspend){var j=i.unsuspend;i.unsuspend=null,j()}},6e4+l);0<i.imgBytes&&fy===0&&(fy=62500*$5());var b=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&oh(i,i.stylesheets),i.unsuspend)){var j=i.unsuspend;i.unsuspend=null,j()}},(i.imgBytes>fy?50:800)+l);return i.unsuspend=d,function(){i.unsuspend=null,clearTimeout(p),clearTimeout(b)}}:null}function rh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)oh(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ih=null;function oh(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ih=new Map,l.forEach(n4,i),ih=null,rh.call(i))}function n4(i,l){if(!(l.state.loading&4)){var d=ih.get(i);if(d)var p=d.get(null);else{d=new Map,ih.set(i,d);for(var b=i.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<b.length;j++){var M=b[j];(M.nodeName==="LINK"||M.getAttribute("media")!=="not all")&&(d.set(M.dataset.precedence,M),p=M)}p&&d.set(null,p)}b=l.instance,M=b.getAttribute("data-precedence"),j=d.get(M)||p,j===p&&d.set(null,b),d.set(M,b),this.count++,p=rh.bind(this),b.addEventListener("load",p),b.addEventListener("error",p),j?j.parentNode.insertBefore(b,j.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(b,i.firstChild)),l.state.loading|=4}}var Su={$$typeof:k,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function s4(i,l,d,p,b,j,M,F,J){this.tag=1,this.containerInfo=i,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=cn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=cn(0),this.hiddenUpdates=cn(null),this.identifierPrefix=p,this.onUncaughtError=b,this.onCaughtError=j,this.onRecoverableError=M,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=J,this.incompleteTransitions=new Map}function Wk(i,l,d,p,b,j,M,F,J,le,ye,je){return i=new s4(i,l,d,M,J,le,ye,je,F),l=1,j===!0&&(l|=24),j=Hs(3,null,null,l),i.current=j,j.stateNode=i,l=qg(),l.refCount++,i.pooledCache=l,l.refCount++,j.memoizedState={element:p,isDehydrated:d,cache:l},Kg(j),i}function Gk(i){return i?(i=dl,i):dl}function Zk(i,l,d,p,b,j){b=Gk(b),p.context===null?p.context=b:p.pendingContext=b,p=si(l),p.payload={element:d},j=j===void 0?null:j,j!==null&&(p.callback=j),d=ai(i,p,l),d!==null&&(Ds(d,i,l),su(d,i,l))}function Kk(i,l){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var d=i.retryLane;i.retryLane=d!==0&&d<l?d:l}}function hy(i,l){Kk(i,l),(i=i.alternate)&&Kk(i,l)}function Yk(i){if(i.tag===13||i.tag===31){var l=ao(i,67108864);l!==null&&Ds(l,i,67108864),hy(i,67108864)}}function Xk(i){if(i.tag===13||i.tag===31){var l=Ks();l=Yt(l);var d=ao(i,l);d!==null&&Ds(d,i,l),hy(i,l)}}var lh=!0;function a4(i,l,d,p){var b=O.T;O.T=null;var j=z.p;try{z.p=2,my(i,l,d,p)}finally{z.p=j,O.T=b}}function r4(i,l,d,p){var b=O.T;O.T=null;var j=z.p;try{z.p=8,my(i,l,d,p)}finally{z.p=j,O.T=b}}function my(i,l,d,p){if(lh){var b=py(p);if(b===null)ey(i,l,p,ch,d),Jk(i,p);else if(o4(b,i,l,d,p))p.stopPropagation();else if(Jk(i,p),l&4&&-1<i4.indexOf(i)){for(;b!==null;){var j=Xn(b);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var M=bt(j.pendingLanes);if(M!==0){var F=j;for(F.pendingLanes|=2,F.entangledLanes|=2;M;){var J=1<<31-he(M);F.entanglements[1]|=J,M&=~J}tr(j),(Vt&6)===0&&(qf=Ie()+500,xu(0))}}break;case 31:case 13:F=ao(j,2),F!==null&&Ds(F,j,2),Gf(),hy(j,2)}if(j=py(p),j===null&&ey(i,l,p,ch,d),j===b)break;b=j}b!==null&&p.stopPropagation()}else ey(i,l,p,null,d)}}function py(i){return i=vg(i),gy(i)}var ch=null;function gy(i){if(ch=null,i=ws(i),i!==null){var l=o(i);if(l===null)i=null;else{var d=l.tag;if(d===13){if(i=c(l),i!==null)return i;i=null}else if(d===31){if(i=u(l),i!==null)return i;i=null}else if(d===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;i=null}else l!==i&&(i=null)}}return ch=i,null}function Qk(i){switch(i){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"resize":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"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"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(De()){case ct:return 2;case ut:return 8;case st:case ht:return 32;case yt:return 268435456;default:return 32}default:return 32}}var vy=!1,pi=null,gi=null,vi=null,Cu=new Map,Eu=new Map,yi=[],i4="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 Jk(i,l){switch(i){case"focusin":case"focusout":pi=null;break;case"dragenter":case"dragleave":gi=null;break;case"mouseover":case"mouseout":vi=null;break;case"pointerover":case"pointerout":Cu.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Eu.delete(l.pointerId)}}function Au(i,l,d,p,b,j){return i===null||i.nativeEvent!==j?(i={blockedOn:l,domEventName:d,eventSystemFlags:p,nativeEvent:j,targetContainers:[b]},l!==null&&(l=Xn(l),l!==null&&Yk(l)),i):(i.eventSystemFlags|=p,l=i.targetContainers,b!==null&&l.indexOf(b)===-1&&l.push(b),i)}function o4(i,l,d,p,b){switch(l){case"focusin":return pi=Au(pi,i,l,d,p,b),!0;case"dragenter":return gi=Au(gi,i,l,d,p,b),!0;case"mouseover":return vi=Au(vi,i,l,d,p,b),!0;case"pointerover":var j=b.pointerId;return Cu.set(j,Au(Cu.get(j)||null,i,l,d,p,b)),!0;case"gotpointercapture":return j=b.pointerId,Eu.set(j,Au(Eu.get(j)||null,i,l,d,p,b)),!0}return!1}function eS(i){var l=ws(i.target);if(l!==null){var d=o(l);if(d!==null){if(l=d.tag,l===13){if(l=c(d),l!==null){i.blockedOn=l,Rs(i.priority,function(){Xk(d)});return}}else if(l===31){if(l=u(d),l!==null){i.blockedOn=l,Rs(i.priority,function(){Xk(d)});return}}else if(l===3&&d.stateNode.current.memoizedState.isDehydrated){i.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}i.blockedOn=null}function uh(i){if(i.blockedOn!==null)return!1;for(var l=i.targetContainers;0<l.length;){var d=py(i.nativeEvent);if(d===null){d=i.nativeEvent;var p=new d.constructor(d.type,d);gg=p,d.target.dispatchEvent(p),gg=null}else return l=Xn(d),l!==null&&Yk(l),i.blockedOn=d,!1;l.shift()}return!0}function tS(i,l,d){uh(i)&&d.delete(l)}function l4(){vy=!1,pi!==null&&uh(pi)&&(pi=null),gi!==null&&uh(gi)&&(gi=null),vi!==null&&uh(vi)&&(vi=null),Cu.forEach(tS),Eu.forEach(tS)}function dh(i,l){i.blockedOn===l&&(i.blockedOn=null,vy||(vy=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,l4)))}var fh=null;function nS(i){fh!==i&&(fh=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){fh===i&&(fh=null);for(var l=0;l<i.length;l+=3){var d=i[l],p=i[l+1],b=i[l+2];if(typeof p!="function"){if(gy(p||d)===null)continue;break}var j=Xn(d);j!==null&&(i.splice(l,3),l-=3,pv(j,{pending:!0,data:b,method:d.method,action:p},p,b))}}))}function $l(i){function l(J){return dh(J,i)}pi!==null&&dh(pi,i),gi!==null&&dh(gi,i),vi!==null&&dh(vi,i),Cu.forEach(l),Eu.forEach(l);for(var d=0;d<yi.length;d++){var p=yi[d];p.blockedOn===i&&(p.blockedOn=null)}for(;0<yi.length&&(d=yi[0],d.blockedOn===null);)eS(d),d.blockedOn===null&&yi.shift();if(d=(i.ownerDocument||i).$$reactFormReplay,d!=null)for(p=0;p<d.length;p+=3){var b=d[p],j=d[p+1],M=b[He]||null;if(typeof j=="function")M||nS(d);else if(M){var F=null;if(j&&j.hasAttribute("formAction")){if(b=j,M=j[He]||null)F=M.formAction;else if(gy(b)!==null)continue}else F=M.action;typeof F=="function"?d[p+1]=F:(d.splice(p,3),p-=3),nS(d)}}}function sS(){function i(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(M){return b=M})},focusReset:"manual",scroll:"manual"})}function l(){b!==null&&(b(),b=null),p||setTimeout(d,20)}function d(){if(!p&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var p=!1,b=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",l),navigation.addEventListener("navigateerror",l),setTimeout(d,100),function(){p=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",l),navigation.removeEventListener("navigateerror",l),b!==null&&(b(),b=null)}}}function yy(i){this._internalRoot=i}hh.prototype.render=yy.prototype.render=function(i){var l=this._internalRoot;if(l===null)throw Error(a(409));var d=l.current,p=Ks();Zk(d,p,i,l,null,null)},hh.prototype.unmount=yy.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var l=i.containerInfo;Zk(i.current,2,null,i,null,null),Gf(),l[Lt]=null}};function hh(i){this._internalRoot=i}hh.prototype.unstable_scheduleHydration=function(i){if(i){var l=Ln();i={blockedOn:null,target:i,priority:l};for(var d=0;d<yi.length&&l!==0&&l<yi[d].priority;d++);yi.splice(d,0,i),d===0&&eS(i)}};var aS=t.version;if(aS!=="19.2.3")throw Error(a(527,aS,"19.2.3"));z.findDOMNode=function(i){var l=i._reactInternals;if(l===void 0)throw typeof i.render=="function"?Error(a(188)):(i=Object.keys(i).join(","),Error(a(268,i)));return i=f(l),i=i!==null?g(i):null,i=i===null?null:i.stateNode,i};var c4={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var mh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!mh.isDisabled&&mh.supportsFiber)try{xt=mh.inject(c4),Y=mh}catch{}}return Mu.createRoot=function(i,l){if(!r(i))throw Error(a(299));var d=!1,p="",b=dN,j=fN,M=hN;return l!=null&&(l.unstable_strictMode===!0&&(d=!0),l.identifierPrefix!==void 0&&(p=l.identifierPrefix),l.onUncaughtError!==void 0&&(b=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(M=l.onRecoverableError)),l=Wk(i,1,!1,null,null,d,p,null,b,j,M,sS),i[Lt]=l.current,Jv(i),new yy(l)},Mu.hydrateRoot=function(i,l,d){if(!r(i))throw Error(a(299));var p=!1,b="",j=dN,M=fN,F=hN,J=null;return d!=null&&(d.unstable_strictMode===!0&&(p=!0),d.identifierPrefix!==void 0&&(b=d.identifierPrefix),d.onUncaughtError!==void 0&&(j=d.onUncaughtError),d.onCaughtError!==void 0&&(M=d.onCaughtError),d.onRecoverableError!==void 0&&(F=d.onRecoverableError),d.formState!==void 0&&(J=d.formState)),l=Wk(i,1,!0,l,d??null,p,b,J,j,M,F,sS),l.context=Gk(null),d=l.current,p=Ks(),p=Yt(p),b=si(p),b.callback=null,ai(d,b,p),d=p,l.current.lanes=d,Rn(l,d),tr(l),i[Lt]=l.current,Jv(i),new hh(l)},Mu.version="19.2.3",Mu}var mS;function x4(){if(mS)return wy.exports;mS=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),wy.exports=y4(),wy.exports}var b4=x4();const n2=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim();const w4=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const j4=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase());const pS=e=>{const t=j4(e);return t.charAt(0).toUpperCase()+t.slice(1)};var N4={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const k4=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const S4=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:o,iconNode:c,...u},h)=>m.createElement("svg",{ref:h,...N4,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:n2("lucide",r),...!o&&!k4(u)&&{"aria-hidden":"true"},...u},[...c.map(([f,g])=>m.createElement(f,g)),...Array.isArray(o)?o:[o]]));const Ye=(e,t)=>{const n=m.forwardRef(({className:a,...r},o)=>m.createElement(S4,{ref:o,iconNode:t,className:n2(`lucide-${w4(pS(e))}`,`lucide-${e}`,a),...r}));return n.displayName=pS(e),n};const C4=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],s2=Ye("activity",C4);const E4=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],a2=Ye("archive",E4);const A4=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],T4=Ye("arrow-left",A4);const M4=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],R4=Ye("arrow-right",M4);const I4=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],_4=Ye("book-open",I4);const O4=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],zd=Ye("bot",O4);const $4=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],r2=Ye("check",$4);const P4=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Vo=Ye("chevron-down",P4);const D4=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Rp=Ye("chevron-right",D4);const L4=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],T0=Ye("chevron-up",L4);const z4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],i2=Ye("circle-alert",z4);const B4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],o2=Ye("circle-check",B4);const U4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],F4=Ye("clock",U4);const V4=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],H4=Ye("code-xml",V4);const q4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],l2=Ye("compass",q4);const W4=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],c2=Ye("copy",W4);const G4=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],Z4=Ye("corner-down-left",G4);const K4=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Y4=Ye("cpu",K4);const X4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],u2=Ye("crosshair",X4);const Q4=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Tc=Ye("external-link",Q4);const J4=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],xd=Ye("file-text",J4);const ez=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],tz=Ye("folder-open",ez);const nz=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Sy=Ye("folder-tree",nz);const sz=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],d2=Ye("folder",sz);const az=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],rz=Ye("git-branch",az);const iz=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],oz=Ye("history",iz);const lz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],cz=Ye("image",lz);const uz=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],dz=Ye("inbox",uz);const fz=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],f2=Ye("key-round",fz);const hz=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ea=Ye("loader-circle",hz);const mz=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],pz=Ye("map",mz);const gz=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Ip=Ye("maximize-2",gz);const vz=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],_p=Ye("message-square",vz);const yz=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],M0=Ye("mic",yz);const xz=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],h2=Ye("minimize-2",xz);const bz=[["path",{d:"M5 12h14",key:"1ays0h"}]],wz=Ye("minus",bz);const jz=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Nz=Ye("network",jz);const kz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Sz=Ye("panel-left-close",kz);const Cz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Ez=Ye("panel-left-open",Cz);const Az=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Tz=Ye("panel-right-close",Az);const Mz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Rz=Ye("panel-right-open",Mz);const Iz=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],_z=Ye("paperclip",Iz);const Oz=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],$z=Ye("pin-off",Oz);const Pz=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],Dz=Ye("pin",Pz);const Lz=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],zz=Ye("plus",Lz);const Bz=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Uz=Ye("radio",Bz);const Fz=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],m2=Ye("refresh-cw",Fz);const Vz=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],gS=Ye("rocket",Vz);const Hz=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],qz=Ye("scroll-text",Hz);const Wz=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Op=Ye("search",Wz);const Gz=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],Zz=Ye("send-horizontal",Gz);const Kz=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Yz=Ye("server",Kz);const Xz=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],$p=Ye("settings",Xz);const Qz=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Jz=Ye("sliders-horizontal",Qz);const e3=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Pp=Ye("sparkles",e3);const t3=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Bd=Ye("square",t3);const n3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],s3=Ye("target",n3);const a3=[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]],r3=Ye("telescope",a3);const i3=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],p2=Ye("terminal",i3);const o3=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],l3=Ye("trash-2",o3);const c3=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],g2=Ye("volume-2",c3);const u3=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],v2=Ye("volume-x",u3);const d3=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],f3=Ye("wrench",d3);const h3=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],gc=Ye("x",h3),m3="modulepreload",p3=function(e){return"/"+e},vS={},Cy=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){let h=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");r=h(n.map(f=>{if(f=p3(f),f in vS)return;vS[f]=!0;const g=f.endsWith(".css"),v=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${v}`))return;const y=document.createElement("link");if(y.rel=g?"stylesheet":m3,g||(y.as="script"),y.crossOrigin="",y.href=f,u&&y.setAttribute("nonce",u),document.head.appendChild(y),g)return new Promise((x,w)=>{y.addEventListener("load",x),y.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return r.then(c=>{for(const u of c||[])u.status==="rejected"&&o(u.reason);return t().catch(o)})};var g3={titleBarInset:0,dragRegionProps:{},onInteractiveMouseDown:void 0,isSSR:!0,apiBaseUrl:"",serviceApiUrl:""},v3=m.createContext(g3);function Dp(){return m.useContext(v3)}var y2="vercel.ai.error",y3=Symbol.for(y2),yS,xS,gr=class x2 extends(xS=Error,yS=y3,xS){constructor({name:t,message:n,cause:a}){super(n),this[yS]=!0,this.name=t,this.cause=a}static isInstance(t){return x2.hasMarker(t,y2)}static hasMarker(t,n){const a=Symbol.for(n);return t!=null&&typeof t=="object"&&a in t&&typeof t[a]=="boolean"&&t[a]===!0}};function b2(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var w2="AI_InvalidArgumentError",j2=`vercel.ai.error.${w2}`,x3=Symbol.for(j2),bS,wS,b3=class extends(wS=gr,bS=x3,wS){constructor({message:e,cause:t,argument:n}){super({name:w2,message:e,cause:t}),this[bS]=!0,this.argument=n}static isInstance(e){return gr.hasMarker(e,j2)}},N2="AI_JSONParseError",k2=`vercel.ai.error.${N2}`,w3=Symbol.for(k2),jS,NS,kS=class extends(NS=gr,jS=w3,NS){constructor({text:e,cause:t}){super({name:N2,message:`JSON parsing failed: Text: ${e}.
10
+ Error message: ${b2(t)}`,cause:t}),this[jS]=!0,this.text=e}static isInstance(e){return gr.hasMarker(e,k2)}},S2="AI_TypeValidationError",C2=`vercel.ai.error.${S2}`,j3=Symbol.for(C2),SS,CS,vc=class Hx extends(CS=gr,SS=j3,CS){constructor({value:t,cause:n,context:a}){let r="Type validation failed";if(a?.field&&(r+=` for ${a.field}`),a?.entityName||a?.entityId){r+=" (";const o=[];a.entityName&&o.push(a.entityName),a.entityId&&o.push(`id: "${a.entityId}"`),r+=o.join(", "),r+=")"}super({name:S2,message:`${r}: Value: ${JSON.stringify(t)}.
11
+ Error message: ${b2(n)}`,cause:n}),this[SS]=!0,this.value=t,this.context=a}static isInstance(t){return gr.hasMarker(t,C2)}static wrap({value:t,cause:n,context:a}){var r,o,c;return Hx.isInstance(n)&&n.value===t&&((r=n.context)==null?void 0:r.field)===a?.field&&((o=n.context)==null?void 0:o.entityName)===a?.entityName&&((c=n.context)==null?void 0:c.entityId)===a?.entityId?n:new Hx({value:t,cause:n,context:a})}};function xe(e,t,n){function a(u,h){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:h,constr:c,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,h);const f=c.prototype,g=Object.keys(f);for(let v=0;v<g.length;v++){const y=g[v];y in u||(u[y]=f[y].bind(u))}}const r=n?.Parent??Object;class o extends r{}Object.defineProperty(o,"name",{value:e});function c(u){var h;const f=n?.Parent?new o:this;a(f,u),(h=f._zod).deferred??(h.deferred=[]);for(const g of f._zod.deferred)g();return f}return Object.defineProperty(c,"init",{value:a}),Object.defineProperty(c,Symbol.hasInstance,{value:u=>n?.Parent&&u instanceof n.Parent?!0:u?._zod?.traits?.has(e)}),Object.defineProperty(c,"name",{value:e}),c}class ic extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class E2 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const A2={};function zi(e){return A2}function T2(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function qx(e,t){return typeof t=="bigint"?t.toString():t}function Lp(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function R0(e){return e==null}function I0(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function N3(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const h=a.match(/\d?e-(\d?)/);h?.[1]&&(r=Number.parseInt(h[1]))}const o=n>r?n:r,c=Number.parseInt(e.toFixed(o).replace(".","")),u=Number.parseInt(t.toFixed(o).replace(".",""));return c%u/10**o}const ES=Symbol("evaluating");function Pt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==ES)return a===void 0&&(a=ES,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Yo(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function qi(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function AS(e){return JSON.stringify(e)}function k3(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const M2="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function bd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const S3=Lp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function yc(e){if(bd(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(bd(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function R2(e){return yc(e)?{...e}:Array.isArray(e)?[...e]:e}const C3=new Set(["string","number","symbol"]);function xc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wi(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function tt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function E3(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const A3={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function T3(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=qi(e._zod.def,{get shape(){const c={};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n.shape[u])}return Yo(this,"shape",c),c},checks:[]});return Wi(e,o)}function M3(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=qi(e._zod.def,{get shape(){const c={...e._zod.def.shape};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete c[u]}return Yo(this,"shape",c),c},checks:[]});return Wi(e,o)}function R3(e,t){if(!yc(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const c in t)if(Object.getOwnPropertyDescriptor(o,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=qi(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Yo(this,"shape",o),o}});return Wi(e,r)}function I3(e,t){if(!yc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=qi(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Yo(this,"shape",a),a}});return Wi(e,n)}function _3(e,t){const n=qi(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Yo(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return Wi(e,n)}function O3(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=qi(t._zod.def,{get shape(){const u=t._zod.def.shape,h={...u};if(n)for(const f in n){if(!(f in u))throw new Error(`Unrecognized key: "${f}"`);n[f]&&(h[f]=e?new e({type:"optional",innerType:u[f]}):u[f])}else for(const f in u)h[f]=e?new e({type:"optional",innerType:u[f]}):u[f];return Yo(this,"shape",h),h},checks:[]});return Wi(t,c)}function $3(e,t,n){const a=qi(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(o[c]=new e({type:"nonoptional",innerType:r[c]}))}else for(const c in r)o[c]=new e({type:"nonoptional",innerType:r[c]});return Yo(this,"shape",o),o}});return Wi(t,a)}function Jl(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ec(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function ph(e){return typeof e=="string"?e:e?.message}function Bi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=ph(e.inst?._zod.def?.error?.(e))??ph(t?.error?.(e))??ph(n.customError?.(e))??ph(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function _0(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function wd(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const I2=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,qx,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},_2=xe("$ZodError",I2),O2=xe("$ZodError",I2,{Parent:Error});function P3(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function D3(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(c=>a({issues:c}));else if(o.code==="invalid_key")a({issues:o.issues});else if(o.code==="invalid_element")a({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){const h=o.path[u];u===o.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(t(o))):c[h]=c[h]||{_errors:[]},c=c[h],u++}}};return a(e),n}const O0=e=>(t,n,a,r)=>{const o=a?Object.assign(a,{async:!1}):{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new ic;if(c.issues.length){const u=new(r?.Err??e)(c.issues.map(h=>Bi(h,o,zi())));throw M2(u,r?.callee),u}return c.value},$0=e=>async(t,n,a,r)=>{const o=a?Object.assign(a,{async:!0}):{async:!0};let c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new(r?.Err??e)(c.issues.map(h=>Bi(h,o,zi())));throw M2(u,r?.callee),u}return c.value},zp=e=>(t,n,a)=>{const r=a?{...a,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new ic;return o.issues.length?{success:!1,error:new(e??_2)(o.issues.map(c=>Bi(c,r,zi())))}:{success:!0,data:o.value}},L3=zp(O2),Bp=e=>async(t,n,a)=>{const r=a?Object.assign(a,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(c=>Bi(c,r,zi())))}:{success:!0,data:o.value}},z3=Bp(O2),B3=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return O0(e)(t,n,r)},U3=e=>(t,n,a)=>O0(e)(t,n,a),F3=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return $0(e)(t,n,r)},V3=e=>async(t,n,a)=>$0(e)(t,n,a),H3=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return zp(e)(t,n,r)},q3=e=>(t,n,a)=>zp(e)(t,n,a),W3=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Bp(e)(t,n,r)},G3=e=>async(t,n,a)=>Bp(e)(t,n,a),Z3=/^[cC][^\s-]{8,}$/,K3=/^[0-9a-z]+$/,Y3=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,X3=/^[0-9a-vA-V]{20}$/,Q3=/^[A-Za-z0-9]{27}$/,J3=/^[a-zA-Z0-9_-]{21}$/,e6=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,t6=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,TS=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,n6=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,s6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function a6(){return new RegExp(s6,"u")}const r6=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,i6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,o6=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,l6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,c6=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$2=/^[A-Za-z0-9_-]*$/,u6=/^\+[1-9]\d{6,14}$/,P2="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",d6=new RegExp(`^${P2}$`);function D2(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function f6(e){return new RegExp(`^${D2(e)}$`)}function h6(e){const t=D2({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${P2}T(?:${a})$`)}const m6=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},p6=/^-?\d+$/,L2=/^-?\d+(?:\.\d+)?$/,g6=/^(?:true|false)$/i,v6=/^null$/i,y6=/^[^A-Z]*$/,x6=/^[^a-z]*$/,Us=xe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),z2={number:"number",bigint:"bigint",object:"date"},B2=xe("$ZodCheckLessThan",(e,t)=>{Us.init(e,t);const n=z2[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,o=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),U2=xe("$ZodCheckGreaterThan",(e,t)=>{Us.init(e,t);const n=z2[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,o=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),b6=xe("$ZodCheckMultipleOf",(e,t)=>{Us.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):N3(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),w6=xe("$ZodCheckNumberFormat",(e,t)=>{Us.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[r,o]=A3[t.format];e._zod.onattach.push(c=>{const u=c._zod.bag;u.format=t.format,u.minimum=r,u.maximum=o,n&&(u.pattern=p6)}),e._zod.check=c=>{const u=c.value;if(n){if(!Number.isInteger(u)){c.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:u,inst:e});return}if(!Number.isSafeInteger(u)){u>0?c.issues.push({input:u,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):c.issues.push({input:u,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}u<r&&c.issues.push({origin:"number",input:u,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),u>o&&c.issues.push({origin:"number",input:u,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),j6=xe("$ZodCheckMaxLength",(e,t)=>{var n;Us.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!R0(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;if(r.length<=t.maximum)return;const c=_0(r);a.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),N6=xe("$ZodCheckMinLength",(e,t)=>{var n;Us.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!R0(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;if(r.length>=t.minimum)return;const c=_0(r);a.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),k6=xe("$ZodCheckLengthEquals",(e,t)=>{var n;Us.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!R0(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=a=>{const r=a.value,o=r.length;if(o===t.length)return;const c=_0(r),u=o>t.length;a.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Up=xe("$ZodCheckStringFormat",(e,t)=>{var n,a;Us.init(e,t),e._zod.onattach.push(r=>{const o=r._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),S6=xe("$ZodCheckRegex",(e,t)=>{Up.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),C6=xe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=y6),Up.init(e,t)}),E6=xe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=x6),Up.init(e,t)}),A6=xe("$ZodCheckIncludes",(e,t)=>{Us.init(e,t);const n=xc(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(a)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),T6=xe("$ZodCheckStartsWith",(e,t)=>{Us.init(e,t);const n=new RegExp(`^${xc(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),M6=xe("$ZodCheckEndsWith",(e,t)=>{Us.init(e,t);const n=new RegExp(`.*${xc(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),R6=xe("$ZodCheckOverwrite",(e,t)=>{Us.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class I6{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
12
+ `).filter(c=>c),r=Math.min(...a.map(c=>c.length-c.trimStart().length)),o=a.map(c=>c.slice(r)).map(c=>" ".repeat(this.indent*2)+c);for(const c of o)this.content.push(c)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,r.join(`
13
+ `))}}const _6={major:4,minor:3,patch:6},xn=xe("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_6;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const r of a)for(const o of r._zod.onattach)o(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(c,u,h)=>{let f=Jl(c),g;for(const v of u){if(v._zod.def.when){if(!v._zod.def.when(c))continue}else if(f)continue;const y=c.issues.length,x=v._zod.check(c);if(x instanceof Promise&&h?.async===!1)throw new ic;if(g||x instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await x,c.issues.length!==y&&(f||(f=Jl(c,y)))});else{if(c.issues.length===y)continue;f||(f=Jl(c,y))}}return g?g.then(()=>c):c},o=(c,u,h)=>{if(Jl(c))return c.aborted=!0,c;const f=r(u,a,h);if(f instanceof Promise){if(h.async===!1)throw new ic;return f.then(g=>e._zod.parse(g,h))}return e._zod.parse(f,h)};e._zod.run=(c,u)=>{if(u.skipChecks)return e._zod.parse(c,u);if(u.direction==="backward"){const f=e._zod.parse({value:c.value,issues:[]},{...u,skipChecks:!0});return f instanceof Promise?f.then(g=>o(g,c,u)):o(f,c,u)}const h=e._zod.parse(c,u);if(h instanceof Promise){if(u.async===!1)throw new ic;return h.then(f=>r(f,a,u))}return r(h,a,u)}}Pt(e,"~standard",()=>({validate:r=>{try{const o=L3(e,r);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return z3(e,r).then(c=>c.success?{value:c.data}:{issues:c.error?.issues})}},vendor:"zod",version:1}))}),P0=xe("$ZodString",(e,t)=>{xn.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??m6(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Nn=xe("$ZodStringFormat",(e,t)=>{Up.init(e,t),P0.init(e,t)}),O6=xe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=t6),Nn.init(e,t)}),$6=xe("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=TS(a))}else t.pattern??(t.pattern=TS());Nn.init(e,t)}),P6=xe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=n6),Nn.init(e,t)}),D6=xe("$ZodURL",(e,t)=>{Nn.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),r=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),L6=xe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=a6()),Nn.init(e,t)}),z6=xe("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=J3),Nn.init(e,t)}),B6=xe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Z3),Nn.init(e,t)}),U6=xe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=K3),Nn.init(e,t)}),F6=xe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Y3),Nn.init(e,t)}),V6=xe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=X3),Nn.init(e,t)}),H6=xe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Q3),Nn.init(e,t)}),q6=xe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=h6(t)),Nn.init(e,t)}),W6=xe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=d6),Nn.init(e,t)}),G6=xe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=f6(t)),Nn.init(e,t)}),Z6=xe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=e6),Nn.init(e,t)}),K6=xe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=r6),Nn.init(e,t),e._zod.bag.format="ipv4"}),Y6=xe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=i6),Nn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),X6=xe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=o6),Nn.init(e,t)}),Q6=xe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=l6),Nn.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[r,o]=a;if(!o)throw new Error;const c=Number(o);if(`${c}`!==o)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function F2(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const J6=xe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=c6),Nn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{F2(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function eB(e){if(!$2.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return F2(n)}const tB=xe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$2),Nn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{eB(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),nB=xe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=u6),Nn.init(e,t)});function sB(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const r=JSON.parse(atob(a));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const aB=xe("$ZodJWT",(e,t)=>{Nn.init(e,t),e._zod.check=n=>{sB(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),V2=xe("$ZodNumber",(e,t)=>{xn.init(e,t),e._zod.pattern=e._zod.bag.pattern??L2,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),rB=xe("$ZodNumberFormat",(e,t)=>{w6.init(e,t),V2.init(e,t)}),iB=xe("$ZodBoolean",(e,t)=>{xn.init(e,t),e._zod.pattern=g6,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),oB=xe("$ZodNull",(e,t)=>{xn.init(e,t),e._zod.pattern=v6,e._zod.values=new Set([null]),e._zod.parse=(n,a)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),lB=xe("$ZodUnknown",(e,t)=>{xn.init(e,t),e._zod.parse=n=>n}),cB=xe("$ZodNever",(e,t)=>{xn.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function MS(e,t,n){e.issues.length&&t.issues.push(...ec(n,e.issues)),t.value[n]=e.value}const uB=xe("$ZodArray",(e,t)=>{xn.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const o=[];for(let c=0;c<r.length;c++){const u=r[c],h=t.element._zod.run({value:u,issues:[]},a);h instanceof Promise?o.push(h.then(f=>MS(f,n,c))):MS(h,n,c)}return o.length?Promise.all(o).then(()=>n):n}});function Lm(e,t,n,a,r){if(e.issues.length){if(r&&!(n in a))return;t.issues.push(...ec(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function H2(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=E3(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function q2(e,t,n,a,r,o){const c=[],u=r.keySet,h=r.catchall._zod,f=h.def.type,g=h.optout==="optional";for(const v in t){if(u.has(v))continue;if(f==="never"){c.push(v);continue}const y=h.run({value:t[v],issues:[]},a);y instanceof Promise?e.push(y.then(x=>Lm(x,n,v,t,g))):Lm(y,n,v,t,g)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const dB=xe("$ZodObject",(e,t)=>{if(xn.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),h}})}const a=Lp(()=>H2(t));Pt(e._zod,"propValues",()=>{const u=t.shape,h={};for(const f in u){const g=u[f]._zod;if(g.values){h[f]??(h[f]=new Set);for(const v of g.values)h[f].add(v)}}return h});const r=bd,o=t.catchall;let c;e._zod.parse=(u,h)=>{c??(c=a.value);const f=u.value;if(!r(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value={};const g=[],v=c.shape;for(const y of c.keys){const x=v[y],w=x._zod.optout==="optional",C=x._zod.run({value:f[y],issues:[]},h);C instanceof Promise?g.push(C.then(T=>Lm(T,u,y,f,w))):Lm(C,u,y,f,w)}return o?q2(g,f,u,h,a.value,e):g.length?Promise.all(g).then(()=>u):u}}),fB=xe("$ZodObjectJIT",(e,t)=>{dB.init(e,t);const n=e._zod.parse,a=Lp(()=>H2(t)),r=y=>{const x=new I6(["shape","payload","ctx"]),w=a.value,C=k=>{const N=AS(k);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};x.write("const input = payload.value;");const T=Object.create(null);let E=0;for(const k of w.keys)T[k]=`key_${E++}`;x.write("const newResult = {};");for(const k of w.keys){const N=T[k],A=AS(k),_=y[k]?._zod?.optout==="optional";x.write(`const ${N} = ${C(k)};`),_?x.write(`
14
+ if (${N}.issues.length) {
15
+ if (${A} in input) {
16
+ payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
17
+ ...iss,
18
+ path: iss.path ? [${A}, ...iss.path] : [${A}]
19
+ })));
20
+ }
21
+ }
22
+
23
+ if (${N}.value === undefined) {
24
+ if (${A} in input) {
25
+ newResult[${A}] = undefined;
26
+ }
27
+ } else {
28
+ newResult[${A}] = ${N}.value;
29
+ }
30
+
31
+ `):x.write(`
32
+ if (${N}.issues.length) {
33
+ payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
34
+ ...iss,
35
+ path: iss.path ? [${A}, ...iss.path] : [${A}]
36
+ })));
37
+ }
38
+
39
+ if (${N}.value === undefined) {
40
+ if (${A} in input) {
41
+ newResult[${A}] = undefined;
42
+ }
43
+ } else {
44
+ newResult[${A}] = ${N}.value;
45
+ }
46
+
47
+ `)}x.write("payload.value = newResult;"),x.write("return payload;");const S=x.compile();return(k,N)=>S(y,k,N)};let o;const c=bd,u=!A2.jitless,f=u&&S3.value,g=t.catchall;let v;e._zod.parse=(y,x)=>{v??(v=a.value);const w=y.value;return c(w)?u&&f&&x?.async===!1&&x.jitless!==!0?(o||(o=r(t.shape)),y=o(y,x),g?q2([],w,y,x,v,e):y):n(y,x):(y.issues.push({expected:"object",code:"invalid_type",input:w,inst:e}),y)}});function RS(e,t,n,a){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const r=e.filter(o=>!Jl(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(c=>Bi(c,a,zi())))}),t)}const W2=xe("$ZodUnion",(e,t)=>{xn.init(e,t),Pt(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Pt(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Pt(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Pt(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>I0(o.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(r,o)=>{if(n)return a(r,o);let c=!1;const u=[];for(const h of t.options){const f=h._zod.run({value:r.value,issues:[]},o);if(f instanceof Promise)u.push(f),c=!0;else{if(f.issues.length===0)return f;u.push(f)}}return c?Promise.all(u).then(h=>RS(h,r,e,o)):RS(u,r,e,o)}}),hB=xe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,W2.init(e,t);const n=e._zod.parse;Pt(e._zod,"propValues",()=>{const r={};for(const o of t.options){const c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[u,h]of Object.entries(c)){r[u]||(r[u]=new Set);for(const f of h)r[u].add(f)}}return r});const a=Lp(()=>{const r=t.options,o=new Map;for(const c of r){const u=c._zod.propValues?.[t.discriminator];if(!u||u.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const h of u){if(o.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);o.set(h,c)}}return o});e._zod.parse=(r,o)=>{const c=r.value;if(!bd(c))return r.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),r;const u=a.value.get(c?.[t.discriminator]);return u?u._zod.run(r,o):t.unionFallback?n(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:c,path:[t.discriminator],inst:e}),r)}}),mB=xe("$ZodIntersection",(e,t)=>{xn.init(e,t),e._zod.parse=(n,a)=>{const r=n.value,o=t.left._zod.run({value:r,issues:[]},a),c=t.right._zod.run({value:r,issues:[]},a);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([h,f])=>IS(n,h,f)):IS(n,o,c)}});function Wx(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(yc(e)&&yc(t)){const n=Object.keys(t),a=Object.keys(e).filter(o=>n.indexOf(o)!==-1),r={...e,...t};for(const o of a){const c=Wx(e[o],t[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};r[o]=c.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let a=0;a<e.length;a++){const r=e[a],o=t[a],c=Wx(r,o);if(!c.valid)return{valid:!1,mergeErrorPath:[a,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function IS(e,t,n){const a=new Map;let r;for(const u of t.issues)if(u.code==="unrecognized_keys"){r??(r=u);for(const h of u.keys)a.has(h)||a.set(h,{}),a.get(h).l=!0}else e.issues.push(u);for(const u of n.issues)if(u.code==="unrecognized_keys")for(const h of u.keys)a.has(h)||a.set(h,{}),a.get(h).r=!0;else e.issues.push(u);const o=[...a].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(o.length&&r&&e.issues.push({...r,keys:o}),Jl(e))return e;const c=Wx(t.value,n.value);if(!c.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);return e.value=c.data,e}const pB=xe("$ZodRecord",(e,t)=>{xn.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;if(!yc(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const o=[],c=t.keyType._zod.values;if(c){n.value={};const u=new Set;for(const f of c)if(typeof f=="string"||typeof f=="number"||typeof f=="symbol"){u.add(typeof f=="number"?f.toString():f);const g=t.valueType._zod.run({value:r[f],issues:[]},a);g instanceof Promise?o.push(g.then(v=>{v.issues.length&&n.issues.push(...ec(f,v.issues)),n.value[f]=v.value})):(g.issues.length&&n.issues.push(...ec(f,g.issues)),n.value[f]=g.value)}let h;for(const f in r)u.has(f)||(h=h??[],h.push(f));h&&h.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:h})}else{n.value={};for(const u of Reflect.ownKeys(r)){if(u==="__proto__")continue;let h=t.keyType._zod.run({value:u,issues:[]},a);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&L2.test(u)&&h.issues.length){const v=t.keyType._zod.run({value:Number(u),issues:[]},a);if(v instanceof Promise)throw new Error("Async schemas not supported in object keys currently");v.issues.length===0&&(h=v)}if(h.issues.length){t.mode==="loose"?n.value[u]=r[u]:n.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map(v=>Bi(v,a,zi())),input:u,path:[u],inst:e});continue}const g=t.valueType._zod.run({value:r[u],issues:[]},a);g instanceof Promise?o.push(g.then(v=>{v.issues.length&&n.issues.push(...ec(u,v.issues)),n.value[h.value]=v.value})):(g.issues.length&&n.issues.push(...ec(u,g.issues)),n.value[h.value]=g.value)}}return o.length?Promise.all(o).then(()=>n):n}}),gB=xe("$ZodEnum",(e,t)=>{xn.init(e,t);const n=T2(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(r=>C3.has(typeof r)).map(r=>typeof r=="string"?xc(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const c=r.value;return a.has(c)||r.issues.push({code:"invalid_value",values:n,input:c,inst:e}),r}}),vB=xe("$ZodLiteral",(e,t)=>{if(xn.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(a=>typeof a=="string"?xc(a):a?xc(a.toString()):String(a)).join("|")})$`),e._zod.parse=(a,r)=>{const o=a.value;return n.has(o)||a.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),a}}),yB=xe("$ZodTransform",(e,t)=>{xn.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new E2(e.constructor.name);const r=t.transform(n.value,n);if(a.async)return(r instanceof Promise?r:Promise.resolve(r)).then(c=>(n.value=c,n));if(r instanceof Promise)throw new ic;return n.value=r,n}});function _S(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const G2=xe("$ZodOptional",(e,t)=>{xn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Pt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Pt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${I0(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,a);return r instanceof Promise?r.then(o=>_S(o,n.value)):_S(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),xB=xe("$ZodExactOptional",(e,t)=>{G2.init(e,t),Pt(e._zod,"values",()=>t.innerType._zod.values),Pt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),bB=xe("$ZodNullable",(e,t)=>{xn.init(e,t),Pt(e._zod,"optin",()=>t.innerType._zod.optin),Pt(e._zod,"optout",()=>t.innerType._zod.optout),Pt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${I0(n.source)}|null)$`):void 0}),Pt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),wB=xe("$ZodDefault",(e,t)=>{xn.init(e,t),e._zod.optin="optional",Pt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,a);return r instanceof Promise?r.then(o=>OS(o,t)):OS(r,t)}});function OS(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const jB=xe("$ZodPrefault",(e,t)=>{xn.init(e,t),e._zod.optin="optional",Pt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),NB=xe("$ZodNonOptional",(e,t)=>{xn.init(e,t),Pt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const r=t.innerType._zod.run(n,a);return r instanceof Promise?r.then(o=>$S(o,e)):$S(r,e)}});function $S(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const kB=xe("$ZodCatch",(e,t)=>{xn.init(e,t),Pt(e._zod,"optin",()=>t.innerType._zod.optin),Pt(e._zod,"optout",()=>t.innerType._zod.optout),Pt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const r=t.innerType._zod.run(n,a);return r instanceof Promise?r.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(c=>Bi(c,a,zi()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(o=>Bi(o,a,zi()))},input:n.value}),n.issues=[]),n)}}),SB=xe("$ZodPipe",(e,t)=>{xn.init(e,t),Pt(e._zod,"values",()=>t.in._zod.values),Pt(e._zod,"optin",()=>t.in._zod.optin),Pt(e._zod,"optout",()=>t.out._zod.optout),Pt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const o=t.out._zod.run(n,a);return o instanceof Promise?o.then(c=>gh(c,t.in,a)):gh(o,t.in,a)}const r=t.in._zod.run(n,a);return r instanceof Promise?r.then(o=>gh(o,t.out,a)):gh(r,t.out,a)}});function gh(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const CB=xe("$ZodReadonly",(e,t)=>{xn.init(e,t),Pt(e._zod,"propValues",()=>t.innerType._zod.propValues),Pt(e._zod,"values",()=>t.innerType._zod.values),Pt(e._zod,"optin",()=>t.innerType?._zod?.optin),Pt(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const r=t.innerType._zod.run(n,a);return r instanceof Promise?r.then(PS):PS(r)}});function PS(e){return e.value=Object.freeze(e.value),e}const EB=xe("$ZodLazy",(e,t)=>{xn.init(e,t),Pt(e._zod,"innerType",()=>t.getter()),Pt(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Pt(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Pt(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Pt(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,a)=>e._zod.innerType._zod.run(n,a)}),AB=xe("$ZodCustom",(e,t)=>{Us.init(e,t),xn.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,r=t.fn(a);if(r instanceof Promise)return r.then(o=>DS(o,n,a,e));DS(r,n,a,e)}});function DS(e,t,n,a){if(!e){const r={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(r.params=a._zod.def.params),t.issues.push(wd(r))}}var LS;class TB{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const a={...this.get(n)??{}};delete a.id;const r={...a,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function MB(){return new TB}(LS=globalThis).__zod_globalRegistry??(LS.__zod_globalRegistry=MB());const qu=globalThis.__zod_globalRegistry;function RB(e,t){return new e({type:"string",...tt(t)})}function IB(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...tt(t)})}function zS(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...tt(t)})}function _B(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...tt(t)})}function OB(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...tt(t)})}function $B(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...tt(t)})}function PB(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...tt(t)})}function DB(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...tt(t)})}function LB(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...tt(t)})}function zB(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...tt(t)})}function BB(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...tt(t)})}function UB(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...tt(t)})}function FB(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...tt(t)})}function VB(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...tt(t)})}function HB(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...tt(t)})}function qB(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...tt(t)})}function WB(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...tt(t)})}function GB(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...tt(t)})}function ZB(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...tt(t)})}function KB(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...tt(t)})}function YB(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...tt(t)})}function XB(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...tt(t)})}function QB(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...tt(t)})}function JB(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...tt(t)})}function e8(e,t){return new e({type:"string",format:"date",check:"string_format",...tt(t)})}function t8(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...tt(t)})}function n8(e,t){return new e({type:"string",format:"duration",check:"string_format",...tt(t)})}function s8(e,t){return new e({type:"number",checks:[],...tt(t)})}function a8(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...tt(t)})}function r8(e,t){return new e({type:"boolean",...tt(t)})}function i8(e,t){return new e({type:"null",...tt(t)})}function o8(e){return new e({type:"unknown"})}function l8(e,t){return new e({type:"never",...tt(t)})}function BS(e,t){return new B2({check:"less_than",...tt(t),value:e,inclusive:!1})}function Ey(e,t){return new B2({check:"less_than",...tt(t),value:e,inclusive:!0})}function US(e,t){return new U2({check:"greater_than",...tt(t),value:e,inclusive:!1})}function Ay(e,t){return new U2({check:"greater_than",...tt(t),value:e,inclusive:!0})}function FS(e,t){return new b6({check:"multiple_of",...tt(t),value:e})}function Z2(e,t){return new j6({check:"max_length",...tt(t),maximum:e})}function zm(e,t){return new N6({check:"min_length",...tt(t),minimum:e})}function K2(e,t){return new k6({check:"length_equals",...tt(t),length:e})}function c8(e,t){return new S6({check:"string_format",format:"regex",...tt(t),pattern:e})}function u8(e){return new C6({check:"string_format",format:"lowercase",...tt(e)})}function d8(e){return new E6({check:"string_format",format:"uppercase",...tt(e)})}function f8(e,t){return new A6({check:"string_format",format:"includes",...tt(t),includes:e})}function h8(e,t){return new T6({check:"string_format",format:"starts_with",...tt(t),prefix:e})}function m8(e,t){return new M6({check:"string_format",format:"ends_with",...tt(t),suffix:e})}function Mc(e){return new R6({check:"overwrite",tx:e})}function p8(e){return Mc(t=>t.normalize(e))}function g8(){return Mc(e=>e.trim())}function v8(){return Mc(e=>e.toLowerCase())}function y8(){return Mc(e=>e.toUpperCase())}function x8(){return Mc(e=>k3(e))}function b8(e,t,n){return new e({type:"array",element:t,...tt(n)})}function w8(e,t,n){const a=tt(n);return a.abort??(a.abort=!0),new e({type:"custom",check:"custom",fn:t,...a})}function j8(e,t,n){return new e({type:"custom",check:"custom",fn:t,...tt(n)})}function N8(e){const t=k8(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(wd(a,n.value,t._zod.def));else{const r=a;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(wd(r))}},e(n.value,n)));return t}function k8(e,t){const n=new Us({check:"custom",...tt(t)});return n._zod.check=e,n}function Bm(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??qu,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function un(e,t,n={path:[],schemaPath:[]}){var a;const r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c);const u=e._zod.toJSONSchema?.();if(u)c.schema=u;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,g);else{const y=c.schema,x=t.processors[r.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);x(e,t,y,g)}const v=e._zod.parent;v&&(c.ref||(c.ref=v),un(v,t,g),t.seen.get(v).isParent=!0)}const h=t.metadataRegistry.get(e);return h&&Object.assign(c.schema,h),t.io==="input"&&Cs(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&c.schema._prefault&&((a=c.schema).default??(a.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function Um(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const c of e.seen.entries()){const u=e.metadataRegistry.get(c[0])?.id;if(u){const h=a.get(u);if(h&&h!==c[0])throw new Error(`Duplicate schema id "${u}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(u,c[0])}}const r=c=>{const u=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const v=e.external.registry.get(c[0])?.id,y=e.external.uri??(w=>w);if(v)return{ref:y(v)};const x=c[1].defId??c[1].schema.id??`schema${e.counter++}`;return c[1].defId=x,{defId:x,ref:`${y("__shared")}#/${u}/${x}`}}if(c[1]===n)return{ref:"#"};const f=`#/${u}/`,g=c[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:f+g}},o=c=>{if(c[1].schema.$ref)return;const u=c[1],{ref:h,defId:f}=r(c);u.def={...u.schema},f&&(u.defId=f);const g=u.schema;for(const v in g)delete g[v];g.$ref=h};if(e.cycles==="throw")for(const c of e.seen.entries()){const u=c[1];if(u.cycle)throw new Error(`Cycle detected: #/${u.cycle?.join("/")}/<root>
48
+
49
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const c of e.seen.entries()){const u=c[1];if(t===c[0]){o(c);continue}if(e.external){const f=e.external.registry.get(c[0])?.id;if(t!==c[0]&&f){o(c);continue}}if(e.metadataRegistry.get(c[0])?.id){o(c);continue}if(u.cycle){o(c);continue}if(u.count>1&&e.reused==="ref"){o(c);continue}}}function Fm(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=c=>{const u=e.seen.get(c);if(u.ref===null)return;const h=u.def??u.schema,f={...h},g=u.ref;if(u.ref=null,g){a(g);const y=e.seen.get(g),x=y.schema;if(x.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(h.allOf=h.allOf??[],h.allOf.push(x)):Object.assign(h,x),Object.assign(h,f),c._zod.parent===g)for(const C in h)C==="$ref"||C==="allOf"||C in f||delete h[C];if(x.$ref&&y.def)for(const C in h)C==="$ref"||C==="allOf"||C in y.def&&JSON.stringify(h[C])===JSON.stringify(y.def[C])&&delete h[C]}const v=c._zod.parent;if(v&&v!==g){a(v);const y=e.seen.get(v);if(y?.schema.$ref&&(h.$ref=y.schema.$ref,y.def))for(const x in h)x==="$ref"||x==="allOf"||x in y.def&&JSON.stringify(h[x])===JSON.stringify(y.def[x])&&delete h[x]}e.override({zodSchema:c,jsonSchema:h,path:u.path??[]})};for(const c of[...e.seen.entries()].reverse())a(c[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const c=e.external.registry.get(t)?.id;if(!c)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(c)}Object.assign(r,n.def??n.schema);const o=e.external?.defs??{};for(const c of e.seen.entries()){const u=c[1];u.def&&u.defId&&(o[u.defId]=u.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{const c=JSON.parse(JSON.stringify(r));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:Vm(t,"input",e.processors),output:Vm(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function Cs(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return Cs(a.element,n);if(a.type==="set")return Cs(a.valueType,n);if(a.type==="lazy")return Cs(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return Cs(a.innerType,n);if(a.type==="intersection")return Cs(a.left,n)||Cs(a.right,n);if(a.type==="record"||a.type==="map")return Cs(a.keyType,n)||Cs(a.valueType,n);if(a.type==="pipe")return Cs(a.in,n)||Cs(a.out,n);if(a.type==="object"){for(const r in a.shape)if(Cs(a.shape[r],n))return!0;return!1}if(a.type==="union"){for(const r of a.options)if(Cs(r,n))return!0;return!1}if(a.type==="tuple"){for(const r of a.items)if(Cs(r,n))return!0;return!!(a.rest&&Cs(a.rest,n))}return!1}const S8=(e,t={})=>n=>{const a=Bm({...n,processors:t});return un(e,a),Um(a,e),Fm(a,e)},Vm=(e,t,n={})=>a=>{const{libraryOptions:r,target:o}=a??{},c=Bm({...r??{},target:o,io:t,processors:n});return un(e,c),Um(c,e),Fm(c,e)},C8={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Y2=(e,t,n,a)=>{const r=n;r.type="string";const{minimum:o,maximum:c,format:u,patterns:h,contentEncoding:f}=e._zod.bag;if(typeof o=="number"&&(r.minLength=o),typeof c=="number"&&(r.maxLength=c),u&&(r.format=C8[u]??u,r.format===""&&delete r.format,u==="time"&&delete r.format),f&&(r.contentEncoding=f),h&&h.size>0){const g=[...h];g.length===1?r.pattern=g[0].source:g.length>1&&(r.allOf=[...g.map(v=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:v.source}))])}},X2=(e,t,n,a)=>{const r=n,{minimum:o,maximum:c,format:u,multipleOf:h,exclusiveMaximum:f,exclusiveMinimum:g}=e._zod.bag;typeof u=="string"&&u.includes("int")?r.type="integer":r.type="number",typeof g=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=g,r.exclusiveMinimum=!0):r.exclusiveMinimum=g),typeof o=="number"&&(r.minimum=o,typeof g=="number"&&t.target!=="draft-04"&&(g>=o?delete r.minimum:delete r.exclusiveMinimum)),typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=f,r.exclusiveMaximum=!0):r.exclusiveMaximum=f),typeof c=="number"&&(r.maximum=c,typeof f=="number"&&t.target!=="draft-04"&&(f<=c?delete r.maximum:delete r.exclusiveMaximum)),typeof h=="number"&&(r.multipleOf=h)},Q2=(e,t,n,a)=>{n.type="boolean"},E8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},A8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},J2=(e,t,n,a)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},T8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},M8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},eR=(e,t,n,a)=>{n.not={}},R8=(e,t,n,a)=>{},tR=(e,t,n,a)=>{},I8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},nR=(e,t,n,a)=>{const r=e._zod.def,o=T2(r.entries);o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),n.enum=o},sR=(e,t,n,a)=>{const r=e._zod.def,o=[];for(const c of r.values)if(c===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof c=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(c))}else o.push(c);if(o.length!==0)if(o.length===1){const c=o[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),o.every(c=>typeof c=="boolean")&&(n.type="boolean"),o.every(c=>c===null)&&(n.type="null"),n.enum=o},_8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},O8=(e,t,n,a)=>{const r=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=o.source},$8=(e,t,n,a)=>{const r=n,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:c,maximum:u,mime:h}=e._zod.bag;c!==void 0&&(o.minLength=c),u!==void 0&&(o.maxLength=u),h?h.length===1?(o.contentMediaType=h[0],Object.assign(r,o)):(Object.assign(r,o),r.anyOf=h.map(f=>({contentMediaType:f}))):Object.assign(r,o)},P8=(e,t,n,a)=>{n.type="boolean"},aR=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},D8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},rR=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},L8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},z8=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},iR=(e,t,n,a)=>{const r=n,o=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(r.minItems=c),typeof u=="number"&&(r.maxItems=u),r.type="array",r.items=un(o.element,t,{...a,path:[...a.path,"items"]})},oR=(e,t,n,a)=>{const r=n,o=e._zod.def;r.type="object",r.properties={};const c=o.shape;for(const f in c)r.properties[f]=un(c[f],t,{...a,path:[...a.path,"properties",f]});const u=new Set(Object.keys(c)),h=new Set([...u].filter(f=>{const g=o.shape[f]._zod;return t.io==="input"?g.optin===void 0:g.optout===void 0}));h.size>0&&(r.required=Array.from(h)),o.catchall?._zod.def.type==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=un(o.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},lR=(e,t,n,a)=>{const r=e._zod.def,o=r.inclusive===!1,c=r.options.map((u,h)=>un(u,t,{...a,path:[...a.path,o?"oneOf":"anyOf",h]}));o?n.oneOf=c:n.anyOf=c},cR=(e,t,n,a)=>{const r=e._zod.def,o=un(r.left,t,{...a,path:[...a.path,"allOf",0]}),c=un(r.right,t,{...a,path:[...a.path,"allOf",1]}),u=f=>"allOf"in f&&Object.keys(f).length===1,h=[...u(o)?o.allOf:[o],...u(c)?c.allOf:[c]];n.allOf=h},B8=(e,t,n,a)=>{const r=n,o=e._zod.def;r.type="array";const c=t.target==="draft-2020-12"?"prefixItems":"items",u=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",h=o.items.map((y,x)=>un(y,t,{...a,path:[...a.path,c,x]})),f=o.rest?un(o.rest,t,{...a,path:[...a.path,u,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=h,f&&(r.items=f)):t.target==="openapi-3.0"?(r.items={anyOf:h},f&&r.items.anyOf.push(f),r.minItems=h.length,f||(r.maxItems=h.length)):(r.items=h,f&&(r.additionalItems=f));const{minimum:g,maximum:v}=e._zod.bag;typeof g=="number"&&(r.minItems=g),typeof v=="number"&&(r.maxItems=v)},uR=(e,t,n,a)=>{const r=n,o=e._zod.def;r.type="object";const c=o.keyType,h=c._zod.bag?.patterns;if(o.mode==="loose"&&h&&h.size>0){const g=un(o.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});r.patternProperties={};for(const v of h)r.patternProperties[v.source]=g}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=un(o.keyType,t,{...a,path:[...a.path,"propertyNames"]})),r.additionalProperties=un(o.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const f=c._zod.values;if(f){const g=[...f].filter(v=>typeof v=="string"||typeof v=="number");g.length>0&&(r.required=g)}},dR=(e,t,n,a)=>{const r=e._zod.def,o=un(r.innerType,t,a),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},fR=(e,t,n,a)=>{const r=e._zod.def;un(r.innerType,t,a);const o=t.seen.get(e);o.ref=r.innerType},hR=(e,t,n,a)=>{const r=e._zod.def;un(r.innerType,t,a);const o=t.seen.get(e);o.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},mR=(e,t,n,a)=>{const r=e._zod.def;un(r.innerType,t,a);const o=t.seen.get(e);o.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},pR=(e,t,n,a)=>{const r=e._zod.def;un(r.innerType,t,a);const o=t.seen.get(e);o.ref=r.innerType;let c;try{c=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},gR=(e,t,n,a)=>{const r=e._zod.def,o=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;un(o,t,a);const c=t.seen.get(e);c.ref=o},vR=(e,t,n,a)=>{const r=e._zod.def;un(r.innerType,t,a);const o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},U8=(e,t,n,a)=>{const r=e._zod.def;un(r.innerType,t,a);const o=t.seen.get(e);o.ref=r.innerType},D0=(e,t,n,a)=>{const r=e._zod.def;un(r.innerType,t,a);const o=t.seen.get(e);o.ref=r.innerType},yR=(e,t,n,a)=>{const r=e._zod.innerType;un(r,t,a);const o=t.seen.get(e);o.ref=r},VS={string:Y2,number:X2,boolean:Q2,bigint:E8,symbol:A8,null:J2,undefined:T8,void:M8,never:eR,any:R8,unknown:tR,date:I8,enum:nR,literal:sR,nan:_8,template_literal:O8,file:$8,success:P8,custom:aR,function:D8,transform:rR,map:L8,set:z8,array:iR,object:oR,union:lR,intersection:cR,tuple:B8,record:uR,nullable:dR,nonoptional:fR,default:hR,prefault:mR,catch:pR,pipe:gR,readonly:vR,promise:U8,optional:D0,lazy:yR};function F8(e,t){if("_idmap"in e){const a=e,r=Bm({...t,processors:VS}),o={};for(const h of a._idmap.entries()){const[f,g]=h;un(g,r)}const c={},u={registry:a,uri:t?.uri,defs:o};r.external=u;for(const h of a._idmap.entries()){const[f,g]=h;Um(r,g),c[f]=Fm(r,g)}if(Object.keys(o).length>0){const h=r.target==="draft-2020-12"?"$defs":"definitions";c.__shared={[h]:o}}return{schemas:c}}const n=Bm({...t,processors:VS});return un(e,n),Um(n,e),Fm(n,e)}const V8=xe("ZodISODateTime",(e,t)=>{q6.init(e,t),Sn.init(e,t)});function H8(e){return JB(V8,e)}const q8=xe("ZodISODate",(e,t)=>{W6.init(e,t),Sn.init(e,t)});function W8(e){return e8(q8,e)}const G8=xe("ZodISOTime",(e,t)=>{G6.init(e,t),Sn.init(e,t)});function Z8(e){return t8(G8,e)}const K8=xe("ZodISODuration",(e,t)=>{Z6.init(e,t),Sn.init(e,t)});function Y8(e){return n8(K8,e)}const X8=(e,t)=>{_2.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>D3(e,n)},flatten:{value:n=>P3(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,qx,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,qx,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ta=xe("ZodError",X8,{Parent:Error}),Q8=O0(Ta),J8=$0(Ta),eU=zp(Ta),xR=Bp(Ta),tU=B3(Ta),nU=U3(Ta),sU=F3(Ta),aU=V3(Ta),rU=H3(Ta),iU=q3(Ta),oU=W3(Ta),lU=G3(Ta),bn=xe("ZodType",(e,t)=>(xn.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Vm(e,"input"),output:Vm(e,"output")}}),e.toJSONSchema=S8(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(qi(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>Wi(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>Q8(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>eU(e,n,a),e.parseAsync=async(n,a)=>J8(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>xR(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>tU(e,n,a),e.decode=(n,a)=>nU(e,n,a),e.encodeAsync=async(n,a)=>sU(e,n,a),e.decodeAsync=async(n,a)=>aU(e,n,a),e.safeEncode=(n,a)=>rU(e,n,a),e.safeDecode=(n,a)=>iU(e,n,a),e.safeEncodeAsync=async(n,a)=>oU(e,n,a),e.safeDecodeAsync=async(n,a)=>lU(e,n,a),e.refine=(n,a)=>e.check(aF(n,a)),e.superRefine=n=>e.check(rF(n)),e.overwrite=n=>e.check(Mc(n)),e.optional=()=>WS(e),e.exactOptional=()=>HU(e),e.nullable=()=>GS(e),e.nullish=()=>WS(GS(e)),e.nonoptional=n=>YU(e,n),e.array=()=>Rc(e),e.or=n=>Ms([e,n]),e.and=n=>LU(e,n),e.transform=n=>ZS(e,FU(n)),e.default=n=>GU(e,n),e.prefault=n=>KU(e,n),e.catch=n=>QU(e,n),e.pipe=n=>ZS(e,n),e.readonly=()=>tF(e),e.describe=n=>{const a=e.clone();return qu.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return qu.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return qu.get(e);const a=e.clone();return qu.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),bR=xe("_ZodString",(e,t)=>{P0.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(a,r,o)=>Y2(e,a,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(c8(...a)),e.includes=(...a)=>e.check(f8(...a)),e.startsWith=(...a)=>e.check(h8(...a)),e.endsWith=(...a)=>e.check(m8(...a)),e.min=(...a)=>e.check(zm(...a)),e.max=(...a)=>e.check(Z2(...a)),e.length=(...a)=>e.check(K2(...a)),e.nonempty=(...a)=>e.check(zm(1,...a)),e.lowercase=a=>e.check(u8(a)),e.uppercase=a=>e.check(d8(a)),e.trim=()=>e.check(g8()),e.normalize=(...a)=>e.check(p8(...a)),e.toLowerCase=()=>e.check(v8()),e.toUpperCase=()=>e.check(y8()),e.slugify=()=>e.check(x8())}),cU=xe("ZodString",(e,t)=>{P0.init(e,t),bR.init(e,t),e.email=n=>e.check(IB(uU,n)),e.url=n=>e.check(DB(dU,n)),e.jwt=n=>e.check(QB(CU,n)),e.emoji=n=>e.check(LB(fU,n)),e.guid=n=>e.check(zS(HS,n)),e.uuid=n=>e.check(_B(vh,n)),e.uuidv4=n=>e.check(OB(vh,n)),e.uuidv6=n=>e.check($B(vh,n)),e.uuidv7=n=>e.check(PB(vh,n)),e.nanoid=n=>e.check(zB(hU,n)),e.guid=n=>e.check(zS(HS,n)),e.cuid=n=>e.check(BB(mU,n)),e.cuid2=n=>e.check(UB(pU,n)),e.ulid=n=>e.check(FB(gU,n)),e.base64=n=>e.check(KB(NU,n)),e.base64url=n=>e.check(YB(kU,n)),e.xid=n=>e.check(VB(vU,n)),e.ksuid=n=>e.check(HB(yU,n)),e.ipv4=n=>e.check(qB(xU,n)),e.ipv6=n=>e.check(WB(bU,n)),e.cidrv4=n=>e.check(GB(wU,n)),e.cidrv6=n=>e.check(ZB(jU,n)),e.e164=n=>e.check(XB(SU,n)),e.datetime=n=>e.check(H8(n)),e.date=n=>e.check(W8(n)),e.time=n=>e.check(Z8(n)),e.duration=n=>e.check(Y8(n))});function Le(e){return RB(cU,e)}const Sn=xe("ZodStringFormat",(e,t)=>{Nn.init(e,t),bR.init(e,t)}),uU=xe("ZodEmail",(e,t)=>{P6.init(e,t),Sn.init(e,t)}),HS=xe("ZodGUID",(e,t)=>{O6.init(e,t),Sn.init(e,t)}),vh=xe("ZodUUID",(e,t)=>{$6.init(e,t),Sn.init(e,t)}),dU=xe("ZodURL",(e,t)=>{D6.init(e,t),Sn.init(e,t)}),fU=xe("ZodEmoji",(e,t)=>{L6.init(e,t),Sn.init(e,t)}),hU=xe("ZodNanoID",(e,t)=>{z6.init(e,t),Sn.init(e,t)}),mU=xe("ZodCUID",(e,t)=>{B6.init(e,t),Sn.init(e,t)}),pU=xe("ZodCUID2",(e,t)=>{U6.init(e,t),Sn.init(e,t)}),gU=xe("ZodULID",(e,t)=>{F6.init(e,t),Sn.init(e,t)}),vU=xe("ZodXID",(e,t)=>{V6.init(e,t),Sn.init(e,t)}),yU=xe("ZodKSUID",(e,t)=>{H6.init(e,t),Sn.init(e,t)}),xU=xe("ZodIPv4",(e,t)=>{K6.init(e,t),Sn.init(e,t)}),bU=xe("ZodIPv6",(e,t)=>{Y6.init(e,t),Sn.init(e,t)}),wU=xe("ZodCIDRv4",(e,t)=>{X6.init(e,t),Sn.init(e,t)}),jU=xe("ZodCIDRv6",(e,t)=>{Q6.init(e,t),Sn.init(e,t)}),NU=xe("ZodBase64",(e,t)=>{J6.init(e,t),Sn.init(e,t)}),kU=xe("ZodBase64URL",(e,t)=>{tB.init(e,t),Sn.init(e,t)}),SU=xe("ZodE164",(e,t)=>{nB.init(e,t),Sn.init(e,t)}),CU=xe("ZodJWT",(e,t)=>{aB.init(e,t),Sn.init(e,t)}),wR=xe("ZodNumber",(e,t)=>{V2.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(a,r,o)=>X2(e,a,r),e.gt=(a,r)=>e.check(US(a,r)),e.gte=(a,r)=>e.check(Ay(a,r)),e.min=(a,r)=>e.check(Ay(a,r)),e.lt=(a,r)=>e.check(BS(a,r)),e.lte=(a,r)=>e.check(Ey(a,r)),e.max=(a,r)=>e.check(Ey(a,r)),e.int=a=>e.check(qS(a)),e.safe=a=>e.check(qS(a)),e.positive=a=>e.check(US(0,a)),e.nonnegative=a=>e.check(Ay(0,a)),e.negative=a=>e.check(BS(0,a)),e.nonpositive=a=>e.check(Ey(0,a)),e.multipleOf=(a,r)=>e.check(FS(a,r)),e.step=(a,r)=>e.check(FS(a,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function EU(e){return s8(wR,e)}const AU=xe("ZodNumberFormat",(e,t)=>{rB.init(e,t),wR.init(e,t)});function qS(e){return a8(AU,e)}const TU=xe("ZodBoolean",(e,t)=>{iB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>Q2(e,n,a)});function Es(e){return r8(TU,e)}const MU=xe("ZodNull",(e,t)=>{oB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>J2(e,n,a)});function RU(e){return i8(MU,e)}const IU=xe("ZodUnknown",(e,t)=>{lB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>tR()});function or(){return o8(IU)}const _U=xe("ZodNever",(e,t)=>{cB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>eR(e,n,a)});function jR(e){return l8(_U,e)}const OU=xe("ZodArray",(e,t)=>{uB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>iR(e,n,a,r),e.element=t.element,e.min=(n,a)=>e.check(zm(n,a)),e.nonempty=n=>e.check(zm(1,n)),e.max=(n,a)=>e.check(Z2(n,a)),e.length=(n,a)=>e.check(K2(n,a)),e.unwrap=()=>e.element});function Rc(e,t){return b8(OU,e,t)}const NR=xe("ZodObject",(e,t)=>{fB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>oR(e,n,a,r),Pt(e,"shape",()=>t.shape),e.keyof=()=>SR(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:or()}),e.loose=()=>e.clone({...e._zod.def,catchall:or()}),e.strict=()=>e.clone({...e._zod.def,catchall:jR()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>R3(e,n),e.safeExtend=n=>I3(e,n),e.merge=n=>_3(e,n),e.pick=n=>T3(e,n),e.omit=n=>M3(e,n),e.partial=(...n)=>O3(CR,e,n[0]),e.required=(...n)=>$3(ER,e,n[0])});function rn(e,t){const n={type:"object",shape:e??{},...tt(t)};return new NR(n)}function pn(e,t){return new NR({type:"object",shape:e,catchall:jR(),...tt(t)})}const kR=xe("ZodUnion",(e,t)=>{W2.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>lR(e,n,a,r),e.options=t.options});function Ms(e,t){return new kR({type:"union",options:e,...tt(t)})}const $U=xe("ZodDiscriminatedUnion",(e,t)=>{kR.init(e,t),hB.init(e,t)});function PU(e,t,n){return new $U({type:"union",options:t,discriminator:e,...tt(n)})}const DU=xe("ZodIntersection",(e,t)=>{mB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>cR(e,n,a,r)});function LU(e,t){return new DU({type:"intersection",left:e,right:t})}const zU=xe("ZodRecord",(e,t)=>{pB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>uR(e,n,a,r),e.keyType=t.keyType,e.valueType=t.valueType});function jd(e,t,n){return new zU({type:"record",keyType:e,valueType:t,...tt(n)})}const Gx=xe("ZodEnum",(e,t)=>{gB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(a,r,o)=>nR(e,a,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,r)=>{const o={};for(const c of a)if(n.has(c))o[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new Gx({...t,checks:[],...tt(r),entries:o})},e.exclude=(a,r)=>{const o={...t.entries};for(const c of a)if(n.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new Gx({...t,checks:[],...tt(r),entries:o})}});function SR(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new Gx({type:"enum",entries:n,...tt(t)})}const BU=xe("ZodLiteral",(e,t)=>{vB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>sR(e,n,a),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function lt(e,t){return new BU({type:"literal",values:Array.isArray(e)?e:[e],...tt(t)})}const UU=xe("ZodTransform",(e,t)=>{yB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>rR(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new E2(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(wd(o,n.value,t));else{const c=o;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),c.input??(c.input=n.value),c.inst??(c.inst=e),n.issues.push(wd(c))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n)):(n.value=r,n)}});function FU(e){return new UU({type:"transform",transform:e})}const CR=xe("ZodOptional",(e,t)=>{G2.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>D0(e,n,a,r),e.unwrap=()=>e._zod.def.innerType});function WS(e){return new CR({type:"optional",innerType:e})}const VU=xe("ZodExactOptional",(e,t)=>{xB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>D0(e,n,a,r),e.unwrap=()=>e._zod.def.innerType});function HU(e){return new VU({type:"optional",innerType:e})}const qU=xe("ZodNullable",(e,t)=>{bB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>dR(e,n,a,r),e.unwrap=()=>e._zod.def.innerType});function GS(e){return new qU({type:"nullable",innerType:e})}const WU=xe("ZodDefault",(e,t)=>{wB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>hR(e,n,a,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function GU(e,t){return new WU({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():R2(t)}})}const ZU=xe("ZodPrefault",(e,t)=>{jB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>mR(e,n,a,r),e.unwrap=()=>e._zod.def.innerType});function KU(e,t){return new ZU({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():R2(t)}})}const ER=xe("ZodNonOptional",(e,t)=>{NB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>fR(e,n,a,r),e.unwrap=()=>e._zod.def.innerType});function YU(e,t){return new ER({type:"nonoptional",innerType:e,...tt(t)})}const XU=xe("ZodCatch",(e,t)=>{kB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>pR(e,n,a,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function QU(e,t){return new XU({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const JU=xe("ZodPipe",(e,t)=>{SB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>gR(e,n,a,r),e.in=t.in,e.out=t.out});function ZS(e,t){return new JU({type:"pipe",in:e,out:t})}const eF=xe("ZodReadonly",(e,t)=>{CB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>vR(e,n,a,r),e.unwrap=()=>e._zod.def.innerType});function tF(e){return new eF({type:"readonly",innerType:e})}const nF=xe("ZodLazy",(e,t)=>{EB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>yR(e,n,a,r),e.unwrap=()=>e._zod.def.getter()});function sF(e){return new nF({type:"lazy",getter:e})}const L0=xe("ZodCustom",(e,t)=>{AB.init(e,t),bn.init(e,t),e._zod.processJSONSchema=(n,a,r)=>aR(e,n)});function AR(e,t){return w8(L0,e??(()=>!0),t)}function aF(e,t={}){return j8(L0,e,t)}function rF(e){return N8(e)}function Hm(e,t={}){const n=new L0({type:"custom",check:"custom",fn:a=>a instanceof e,abort:!0,...tt(t)});return n._zod.bag.Class=e,n._zod.check=a=>{a.value instanceof e||a.issues.push({code:"invalid_type",expected:e.name,input:a.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Nd;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const o={};for(const c of r)o[c]=c;return o},e.getValidEnumValues=r=>{const o=e.objectKeys(r).filter(u=>typeof r[r[u]]!="number"),c={};for(const u of o)c[u]=r[u];return e.objectValues(c)},e.objectValues=r=>e.objectKeys(r).map(function(o){return r[o]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const o=[];for(const c in r)Object.prototype.hasOwnProperty.call(r,c)&&o.push(c);return o},e.find=(r,o)=>{for(const c of r)if(o(c))return c},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function a(r,o=" | "){return r.map(c=>typeof c=="string"?`'${c}'`:c).join(o)}e.joinValues=a,e.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o})(Nd||(Nd={}));var KS;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(KS||(KS={}));Nd.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Nd.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class qm extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(o){return o.message},a={_errors:[]},r=o=>{for(const c of o.issues)if(c.code==="invalid_union")c.unionErrors.map(r);else if(c.code==="invalid_return_type")r(c.returnTypeError);else if(c.code==="invalid_arguments")r(c.argumentsError);else if(c.path.length===0)a._errors.push(n(c));else{let u=a,h=0;for(;h<c.path.length;){const f=c.path[h];h===c.path.length-1?(u[f]=u[f]||{_errors:[]},u[f]._errors.push(n(c))):u[f]=u[f]||{_errors:[]},u=u[f],h++}}};return r(this),a}static assert(t){if(!(t instanceof qm))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Nd.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),a=[];for(const r of this.issues)if(r.path.length>0){const o=r.path[0];n[o]=n[o]||[],n[o].push(t(r))}else a.push(t(r));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}}qm.create=e=>new qm(e);var YS;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(YS||(YS={}));var gt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(gt||(gt={}));class XS extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}const QS=10,iF=13,yo=32;function Ty(e){}function oF(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Ty,onError:n=Ty,onRetry:a=Ty,onComment:r}=e;let o="",c=!0,u,h="",f=0,g;function v(S){if(c){c=!1,y(S);return}const k=o===""?S:o+S;o=x(k)}function y(S){S.charCodeAt(0)===239&&S.charCodeAt(1)===187&&S.charCodeAt(2)===191&&(S=S.slice(3));const k=o===""?S:o+S;o=x(k)}function x(S){let k=0;if(S.indexOf("\r")===-1){let N=S.indexOf(`
50
+ `,k);for(;N!==-1;){if(k===N){f>0&&t({id:u,event:g,data:h}),u=void 0,h="",f=0,g=void 0,k=N+1,N=S.indexOf(`
51
+ `,k);continue}const A=S.charCodeAt(k);if(JS(S,k,A)){const R=S.charCodeAt(k+5)===yo?k+6:k+5,_=S.slice(R,N);if(f===0&&S.charCodeAt(N+1)===QS){t({id:u,event:g,data:_}),u=void 0,h="",g=void 0,k=N+2,N=S.indexOf(`
52
+ `,k);continue}h=f===0?_:`${h}
53
+ ${_}`,f++}else eC(S,k,A)?g=S.slice(S.charCodeAt(k+6)===yo?k+7:k+6,N)||void 0:w(S,k,N);k=N+1,N=S.indexOf(`
54
+ `,k)}return S.slice(k)}for(;k<S.length;){const N=S.indexOf("\r",k),A=S.indexOf(`
55
+ `,k);let R=-1;if(N!==-1&&A!==-1?R=N<A?N:A:N!==-1?N===S.length-1?R=-1:R=N:A!==-1&&(R=A),R===-1)break;w(S,k,R),k=R+1,S.charCodeAt(k-1)===iF&&S.charCodeAt(k)===QS&&k++}return S.slice(k)}function w(S,k,N){if(k===N){T();return}const A=S.charCodeAt(k);if(JS(S,k,A)){const I=S.charCodeAt(k+5)===yo?k+6:k+5,U=S.slice(I,N);h=f===0?U:`${h}
56
+ ${U}`,f++;return}if(eC(S,k,A)){g=S.slice(S.charCodeAt(k+6)===yo?k+7:k+6,N)||void 0;return}if(A===105&&S.charCodeAt(k+1)===100&&S.charCodeAt(k+2)===58){const I=S.slice(S.charCodeAt(k+3)===yo?k+4:k+3,N);u=I.includes("\0")?void 0:I;return}if(A===58){if(r){const I=S.slice(k,N);r(I.slice(S.charCodeAt(k+1)===yo?2:1))}return}const R=S.slice(k,N),_=R.indexOf(":");if(_===-1){C(R,"",R);return}const P=R.slice(0,_),$=R.charCodeAt(_+1)===yo?2:1,H=R.slice(_+$);C(P,H,R)}function C(S,k,N){switch(S){case"event":g=k||void 0;break;case"data":h=f===0?k:`${h}
57
+ ${k}`,f++;break;case"id":u=k.includes("\0")?void 0:k;break;case"retry":/^\d+$/.test(k)?a(parseInt(k,10)):n(new XS(`Invalid \`retry\` value: "${k}"`,{type:"invalid-retry",value:k,line:N}));break;default:n(new XS(`Unknown field "${S.length>20?`${S.slice(0,20)}…`:S}"`,{type:"unknown-field",field:S,value:k,line:N}));break}}function T(){f>0&&t({id:u,event:g,data:h}),u=void 0,h="",f=0,g=void 0}function E(S={}){o&&S.consume&&w(o,0,o.length),c=!0,u=void 0,h="",f=0,g=void 0,o=""}return{feed:v,reset:E}}function JS(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function eC(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class lF extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(o){r=oF({onEvent:c=>{o.enqueue(c)},onError(c){t==="terminate"?o.error(c):typeof t=="function"&&t(c)},onRetry:n,onComment:a})},transform(o){r.feed(o)}})}}var Ud=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:a="-"}={})=>{const r=()=>{const o=n.length,c=new Array(t);for(let u=0;u<t;u++)c[u]=n[Math.random()*o|0];return c.join("")};if(e==null)return r;if(n.includes(a))throw new b3({argument:"separator",message:`The separator "${a}" must not be part of the alphabet "${n}".`});return()=>`${e}${a}${r()}`},cF=Ud();function Pl(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,a)=>{t[a.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,a]of e)a!=null&&(t[n.toLowerCase()]=a)}return t}var uF=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,dF=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function tC(e){const t=JSON.parse(e);return t===null||typeof t!="object"||uF.test(e)===!1&&dF.test(e)===!1?t:fF(t)}function fF(e){let t=[e];for(;t.length;){const n=t;t=[];for(const a of n){if(Object.prototype.hasOwnProperty.call(a,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(a,"constructor")&&a.constructor!==null&&typeof a.constructor=="object"&&Object.prototype.hasOwnProperty.call(a.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in a){const o=a[r];o&&typeof o=="object"&&t.push(o)}}}return e}function hF(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return tC(e)}try{return tC(e)}finally{Error.stackTraceLimit=t}}function z0(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;const{properties:n}=e;if(n!=null)for(const a of Object.keys(n))n[a]=xo(n[a])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(xo):xo(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(xo)),e.allOf!=null&&(e.allOf=e.allOf.map(xo)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(xo));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=xo(t[n]);return e}function xo(e){return typeof e=="boolean"?e:z0(e)}var mF=Symbol("Let zodToJsonSchema decide on which parser to use"),nC={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},pF=e=>typeof e=="string"?{...nC,name:e}:{...nC,...e};function aa(){return{}}function gF(e,t){var n,a,r;const o={type:"array"};return(n=e.type)!=null&&n._def&&((r=(a=e.type)==null?void 0:a._def)==null?void 0:r.typeName)!==gt.ZodAny&&(o.items=Kt(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(o.minItems=e.minLength.value),e.maxLength&&(o.maxItems=e.maxLength.value),e.exactLength&&(o.minItems=e.exactLength.value,o.maxItems=e.exactLength.value),o}function vF(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function yF(){return{type:"boolean"}}function TR(e,t){return Kt(e.type._def,t)}var xF=(e,t)=>Kt(e.innerType._def,t);function MR(e,t,n){const a=n??t.dateStrategy;if(Array.isArray(a))return{anyOf:a.map((r,o)=>MR(e,t,r))};switch(a){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return bF(e)}}var bF=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function wF(e,t){return{...Kt(e.innerType._def,t),default:e.defaultValue()}}function jF(e,t){return t.effectStrategy==="input"?Kt(e.schema._def,t):aa()}function NF(e){return{type:"string",enum:Array.from(e.values)}}var kF=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function SF(e,t){const n=[Kt(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Kt(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(r=>!!r),a=[];return n.forEach(r=>{if(kF(r))a.push(...r.allOf);else{let o=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:c,...u}=r;o=u}a.push(o)}}),a.length?{allOf:a}:void 0}function CF(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var My=void 0,Pa={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(My===void 0&&(My=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),My),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function RR(e,t){const n={type:"string"};if(e.checks)for(const a of e.checks)switch(a.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,a.value):a.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,a.value):a.value;break;case"email":switch(t.emailStrategy){case"format:email":Da(n,"email",a.message,t);break;case"format:idn-email":Da(n,"idn-email",a.message,t);break;case"pattern:zod":ks(n,Pa.email,a.message,t);break}break;case"url":Da(n,"uri",a.message,t);break;case"uuid":Da(n,"uuid",a.message,t);break;case"regex":ks(n,a.regex,a.message,t);break;case"cuid":ks(n,Pa.cuid,a.message,t);break;case"cuid2":ks(n,Pa.cuid2,a.message,t);break;case"startsWith":ks(n,RegExp(`^${Ry(a.value,t)}`),a.message,t);break;case"endsWith":ks(n,RegExp(`${Ry(a.value,t)}$`),a.message,t);break;case"datetime":Da(n,"date-time",a.message,t);break;case"date":Da(n,"date",a.message,t);break;case"time":Da(n,"time",a.message,t);break;case"duration":Da(n,"duration",a.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,a.value):a.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,a.value):a.value;break;case"includes":{ks(n,RegExp(Ry(a.value,t)),a.message,t);break}case"ip":{a.version!=="v6"&&Da(n,"ipv4",a.message,t),a.version!=="v4"&&Da(n,"ipv6",a.message,t);break}case"base64url":ks(n,Pa.base64url,a.message,t);break;case"jwt":ks(n,Pa.jwt,a.message,t);break;case"cidr":{a.version!=="v6"&&ks(n,Pa.ipv4Cidr,a.message,t),a.version!=="v4"&&ks(n,Pa.ipv6Cidr,a.message,t);break}case"emoji":ks(n,Pa.emoji(),a.message,t);break;case"ulid":{ks(n,Pa.ulid,a.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Da(n,"binary",a.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{ks(n,Pa.base64,a.message,t);break}}break}case"nanoid":ks(n,Pa.nanoid,a.message,t)}return n}function Ry(e,t){return t.patternStrategy==="escape"?AF(e):e}var EF=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function AF(e){let t="";for(let n=0;n<e.length;n++)EF.has(e[n])||(t+="\\"),t+=e[n];return t}function Da(e,t,n,a){var r;e.format||(r=e.anyOf)!=null&&r.some(o=>o.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&a.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function ks(e,t,n,a){var r;e.pattern||(r=e.allOf)!=null&&r.some(o=>o.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:sC(t,a),...n&&a.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=sC(t,a)}function sC(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const a={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},r=a.i?e.source.toLowerCase():e.source;let o="",c=!1,u=!1,h=!1;for(let f=0;f<r.length;f++){if(c){o+=r[f],c=!1;continue}if(a.i){if(u){if(r[f].match(/[a-z]/)){h?(o+=r[f],o+=`${r[f-2]}-${r[f]}`.toUpperCase(),h=!1):r[f+1]==="-"&&((n=r[f+2])!=null&&n.match(/[a-z]/))?(o+=r[f],h=!0):o+=`${r[f]}${r[f].toUpperCase()}`;continue}}else if(r[f].match(/[a-z]/)){o+=`[${r[f]}${r[f].toUpperCase()}]`;continue}}if(a.m){if(r[f]==="^"){o+=`(^|(?<=[\r
58
+ ]))`;continue}else if(r[f]==="$"){o+=`($|(?=[\r
59
+ ]))`;continue}}if(a.s&&r[f]==="."){o+=u?`${r[f]}\r
60
+ `:`[${r[f]}\r
61
+ ]`;continue}o+=r[f],r[f]==="\\"?c=!0:u&&r[f]==="]"?u=!1:!u&&r[f]==="["&&(u=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function IR(e,t){var n,a,r,o,c,u;const h={type:"object",additionalProperties:(n=Kt(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((a=e.keyType)==null?void 0:a._def.typeName)===gt.ZodString&&((r=e.keyType._def.checks)!=null&&r.length)){const{type:f,...g}=RR(e.keyType._def,t);return{...h,propertyNames:g}}else{if(((o=e.keyType)==null?void 0:o._def.typeName)===gt.ZodEnum)return{...h,propertyNames:{enum:e.keyType._def.values}};if(((c=e.keyType)==null?void 0:c._def.typeName)===gt.ZodBranded&&e.keyType._def.type._def.typeName===gt.ZodString&&((u=e.keyType._def.type._def.checks)!=null&&u.length)){const{type:f,...g}=TR(e.keyType._def,t);return{...h,propertyNames:g}}}return h}function TF(e,t){if(t.mapStrategy==="record")return IR(e,t);const n=Kt(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||aa(),a=Kt(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||aa();return{type:"array",maxItems:125,items:{type:"array",items:[n,a],minItems:2,maxItems:2}}}function MF(e){const t=e.values,a=Object.keys(e.values).filter(o=>typeof t[t[o]]!="number").map(o=>t[o]),r=Array.from(new Set(a.map(o=>typeof o)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:a}}function RF(){return{not:aa()}}function IF(){return{type:"null"}}var Zx={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function _F(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(a=>a._def.typeName in Zx&&(!a._def.checks||!a._def.checks.length))){const a=n.reduce((r,o)=>{const c=Zx[o._def.typeName];return c&&!r.includes(c)?[...r,c]:r},[]);return{type:a.length>1?a:a[0]}}else if(n.every(a=>a._def.typeName==="ZodLiteral"&&!a.description)){const a=n.reduce((r,o)=>{const c=typeof o._def.value;switch(c){case"string":case"number":case"boolean":return[...r,c];case"bigint":return[...r,"integer"];case"object":if(o._def.value===null)return[...r,"null"];default:return r}},[]);if(a.length===n.length){const r=a.filter((o,c,u)=>u.indexOf(o)===c);return{type:r.length>1?r:r[0],enum:n.reduce((o,c)=>o.includes(c._def.value)?o:[...o,c._def.value],[])}}}else if(n.every(a=>a._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((a,r)=>[...a,...r._def.values.filter(o=>!a.includes(o))],[])};return OF(e,t)}var OF=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((a,r)=>Kt(a._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(a=>!!a&&(!t.strictUnions||typeof a=="object"&&Object.keys(a).length>0));return n.length?{anyOf:n}:void 0};function $F(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Zx[e.innerType._def.typeName],"null"]};const n=Kt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function PF(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function DF(e,t){const n={type:"object",properties:{}},a=[],r=e.shape();for(const c in r){let u=r[c];if(u===void 0||u._def===void 0)continue;const h=zF(u),f=Kt(u._def,{...t,currentPath:[...t.currentPath,"properties",c],propertyPath:[...t.currentPath,"properties",c]});f!==void 0&&(n.properties[c]=f,h||a.push(c))}a.length&&(n.required=a);const o=LF(e,t);return o!==void 0&&(n.additionalProperties=o),n}function LF(e,t){if(e.catchall._def.typeName!=="ZodNever")return Kt(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function zF(e){try{return e.isOptional()}catch{return!0}}var BF=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return Kt(e.innerType._def,t);const a=Kt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:aa()},a]}:aa()},UF=(e,t)=>{if(t.pipeStrategy==="input")return Kt(e.in._def,t);if(t.pipeStrategy==="output")return Kt(e.out._def,t);const n=Kt(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),a=Kt(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,a].filter(r=>r!==void 0)}};function FF(e,t){return Kt(e.type._def,t)}function VF(e,t){const a={type:"array",uniqueItems:!0,items:Kt(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(a.minItems=e.minSize.value),e.maxSize&&(a.maxItems=e.maxSize.value),a}function HF(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,a)=>Kt(n._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((n,a)=>a===void 0?n:[...n,a],[]),additionalItems:Kt(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,a)=>Kt(n._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((n,a)=>a===void 0?n:[...n,a],[])}}function qF(){return{not:aa()}}function WF(){return aa()}var GF=(e,t)=>Kt(e.innerType._def,t),ZF=(e,t,n)=>{switch(t){case gt.ZodString:return RR(e,n);case gt.ZodNumber:return PF(e);case gt.ZodObject:return DF(e,n);case gt.ZodBigInt:return vF(e);case gt.ZodBoolean:return yF();case gt.ZodDate:return MR(e,n);case gt.ZodUndefined:return qF();case gt.ZodNull:return IF();case gt.ZodArray:return gF(e,n);case gt.ZodUnion:case gt.ZodDiscriminatedUnion:return _F(e,n);case gt.ZodIntersection:return SF(e,n);case gt.ZodTuple:return HF(e,n);case gt.ZodRecord:return IR(e,n);case gt.ZodLiteral:return CF(e);case gt.ZodEnum:return NF(e);case gt.ZodNativeEnum:return MF(e);case gt.ZodNullable:return $F(e,n);case gt.ZodOptional:return BF(e,n);case gt.ZodMap:return TF(e,n);case gt.ZodSet:return VF(e,n);case gt.ZodLazy:return()=>e.getter()._def;case gt.ZodPromise:return FF(e,n);case gt.ZodNaN:case gt.ZodNever:return RF();case gt.ZodEffects:return jF(e,n);case gt.ZodAny:return aa();case gt.ZodUnknown:return WF();case gt.ZodDefault:return wF(e,n);case gt.ZodBranded:return TR(e,n);case gt.ZodReadonly:return GF(e,n);case gt.ZodCatch:return xF(e,n);case gt.ZodPipeline:return UF(e,n);case gt.ZodFunction:case gt.ZodVoid:case gt.ZodSymbol:return;default:return(a=>{})()}},KF=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};function Kt(e,t,n=!1){var a;const r=t.seen.get(e);if(t.override){const h=(a=t.override)==null?void 0:a.call(t,e,t,r,n);if(h!==mF)return h}if(r&&!n){const h=YF(r,t);if(h!==void 0)return h}const o={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,o);const c=ZF(e,e.typeName,t),u=typeof c=="function"?Kt(c(),t):c;if(u&&XF(e,t,u),t.postProcess){const h=t.postProcess(u,e,t);return o.jsonSchema=u,h}return o.jsonSchema=u,u}var YF=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:KF(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,a)=>t.currentPath[a]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),aa()):t.$refStrategy==="seen"?aa():void 0}},XF=(e,t,n)=>(e.description&&(n.description=e.description),n),QF=e=>{const t=pF(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([a,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,a],jsonSchema:void 0}]))}},JF=(e,t)=>{var n;const a=QF(t);let r=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((f,[g,v])=>{var y;return{...f,[g]:(y=Kt(v._def,{...a,currentPath:[...a.basePath,a.definitionPath,g]},!0))!=null?y:aa()}},{}):void 0;const o=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,c=(n=Kt(e._def,o===void 0?a:{...a,currentPath:[...a.basePath,a.definitionPath,o]},!1))!=null?n:aa(),u=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;u!==void 0&&(c.title=u);const h=o===void 0?r?{...c,[a.definitionPath]:r}:c:{$ref:[...a.$refStrategy==="relative"?[]:a.basePath,a.definitionPath,o].join("/"),[a.definitionPath]:{...r,[o]:c}};return h.$schema="http://json-schema.org/draft-07/schema#",h},Kx=Symbol.for("vercel.ai.schema");function eV(e){let t;return()=>(t==null&&(t=e()),t)}function Fp(e,{validate:t}={}){return{[Kx]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function tV(e){return typeof e=="object"&&e!==null&&Kx in e&&e[Kx]===!0&&"jsonSchema"in e&&"validate"in e}function B0(e){return e==null?Fp({properties:{},additionalProperties:!1}):tV(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?_R(e):nV(e):e()}function nV(e){return Fp(()=>z0(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{const n=await e["~standard"].validate(t);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new vc({value:t,cause:n.issues})}}})}function sV(e,t){var n;const a=(n=void 0)!=null?n:!1;return Fp(()=>JF(e,{$refStrategy:a?"root":"none"}),{validate:async r=>{const o=await e.safeParseAsync(r);return o.success?{success:!0,value:o.data}:{success:!1,error:o.error}}})}function aV(e,t){var n;const a=(n=void 0)!=null?n:!1;return Fp(()=>z0(F8(e,{target:"draft-7",io:"input",reused:a?"ref":"inline"})),{validate:async r=>{const o=await xR(e,r);return o.success?{success:!0,value:o.data}:{success:!1,error:o.error}}})}function rV(e){return"_zod"in e}function _R(e,t){return rV(e)?aV(e):sV(e)}async function aC({value:e,schema:t,context:n}){const a=await kd({value:e,schema:t,context:n});if(!a.success)throw vc.wrap({value:e,cause:a.error,context:n});return a.value}async function kd({value:e,schema:t,context:n}){const a=B0(t);try{if(a.validate==null)return{success:!0,value:e,rawValue:e};const r=await a.validate(e);return r.success?{success:!0,value:r.value,rawValue:e}:{success:!1,error:vc.wrap({value:e,cause:r.error,context:n}),rawValue:e}}catch(r){return{success:!1,error:vc.wrap({value:e,cause:r,context:n}),rawValue:e}}}async function Ho({text:e,schema:t}){try{const n=hF(e);return t==null?{success:!0,value:n,rawValue:n}:await kd({value:n,schema:t})}catch(n){return{success:!1,error:kS.isInstance(n)?n:new kS({text:e,cause:n}),rawValue:void 0}}}function iV({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new lF).pipeThrough(new TransformStream({async transform({data:n},a){n!=="[DONE]"&&a.enqueue(await Ho({text:n,schema:t}))}}))}async function Ai(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var oV=Object.defineProperty,lV=(e,t)=>{for(var n in t)oV(e,n,{get:t[n],enumerable:!0})},OR="AI_NoObjectGeneratedError",$R=`vercel.ai.error.${OR}`,cV=Symbol.for($R),PR,Oi=class extends gr{constructor({message:e="No object generated.",cause:t,text:n,response:a,usage:r,finishReason:o}){super({name:OR,message:e,cause:t}),this[PR]=!0,this.text=n,this.response=a,this.usage=r,this.finishReason=o}static isInstance(e){return gr.hasMarker(e,$R)}};PR=cV;var DR="AI_UIMessageStreamError",LR=`vercel.ai.error.${DR}`,uV=Symbol.for(LR),zR,Dl=class extends gr{constructor({chunkType:e,chunkId:t,message:n}){super({name:DR,message:n}),this[zR]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return gr.hasMarker(e,LR)}};zR=uV;var BR=Ms([Le(),Hm(Uint8Array),Hm(ArrayBuffer),AR(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Sd=sF(()=>Ms([RU(),Le(),EU(),Es(),jd(Le(),Sd.optional()),Rc(Sd)])),Tt=jd(Le(),jd(Le(),Sd.optional())),UR=rn({type:lt("text"),text:Le(),providerOptions:Tt.optional()}),dV=rn({type:lt("image"),image:Ms([BR,Hm(URL)]),mediaType:Le().optional(),providerOptions:Tt.optional()}),FR=rn({type:lt("file"),data:Ms([BR,Hm(URL)]),filename:Le().optional(),mediaType:Le(),providerOptions:Tt.optional()}),fV=rn({type:lt("reasoning"),text:Le(),providerOptions:Tt.optional()}),hV=rn({type:lt("tool-call"),toolCallId:Le(),toolName:Le(),input:or(),providerOptions:Tt.optional(),providerExecuted:Es().optional()}),mV=PU("type",[rn({type:lt("text"),value:Le(),providerOptions:Tt.optional()}),rn({type:lt("json"),value:Sd,providerOptions:Tt.optional()}),rn({type:lt("execution-denied"),reason:Le().optional(),providerOptions:Tt.optional()}),rn({type:lt("error-text"),value:Le(),providerOptions:Tt.optional()}),rn({type:lt("error-json"),value:Sd,providerOptions:Tt.optional()}),rn({type:lt("content"),value:Rc(Ms([rn({type:lt("text"),text:Le(),providerOptions:Tt.optional()}),rn({type:lt("media"),data:Le(),mediaType:Le()}),rn({type:lt("file-data"),data:Le(),mediaType:Le(),filename:Le().optional(),providerOptions:Tt.optional()}),rn({type:lt("file-url"),url:Le(),providerOptions:Tt.optional()}),rn({type:lt("file-id"),fileId:Ms([Le(),jd(Le(),Le())]),providerOptions:Tt.optional()}),rn({type:lt("image-data"),data:Le(),mediaType:Le(),providerOptions:Tt.optional()}),rn({type:lt("image-url"),url:Le(),providerOptions:Tt.optional()}),rn({type:lt("image-file-id"),fileId:Ms([Le(),jd(Le(),Le())]),providerOptions:Tt.optional()}),rn({type:lt("custom"),providerOptions:Tt.optional()})]))})]),VR=rn({type:lt("tool-result"),toolCallId:Le(),toolName:Le(),output:mV,providerOptions:Tt.optional()}),pV=rn({type:lt("tool-approval-request"),approvalId:Le(),toolCallId:Le()}),gV=rn({type:lt("tool-approval-response"),approvalId:Le(),approved:Es(),reason:Le().optional()}),vV=rn({role:lt("system"),content:Le(),providerOptions:Tt.optional()}),yV=rn({role:lt("user"),content:Ms([Le(),Rc(Ms([UR,dV,FR]))]),providerOptions:Tt.optional()}),xV=rn({role:lt("assistant"),content:Ms([Le(),Rc(Ms([UR,FR,fV,hV,VR,pV]))]),providerOptions:Tt.optional()}),bV=rn({role:lt("tool"),content:Rc(Ms([VR,gV])),providerOptions:Tt.optional()});Ms([vV,yV,xV,bV]);function HR(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const r=t[a];if(r===void 0)continue;const o=a in e?e[a]:void 0,c=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),u=o!=null&&typeof o=="object"&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp);c&&u?n[a]=HR(o,r):n[a]=r}return n}var wV={};lV(wV,{array:()=>SV,choice:()=>CV,json:()=>EV,object:()=>kV,text:()=>NV});function jV(e){const t=["ROOT"];let n=-1,a=null;function r(h,f,g){switch(h){case'"':{n=f,t.pop(),t.push(g),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=f,a=f,t.pop(),t.push(g),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(g),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=f,t.pop(),t.push(g),t.push("INSIDE_NUMBER");break}case"{":{n=f,t.pop(),t.push(g),t.push("INSIDE_OBJECT_START");break}case"[":{n=f,t.pop(),t.push(g),t.push("INSIDE_ARRAY_START");break}}}function o(h,f){switch(h){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=f,t.pop();break}}}function c(h,f){switch(h){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=f,t.pop();break}}}for(let h=0;h<e.length;h++){const f=e[h];switch(t[t.length-1]){case"ROOT":r(f,h,"FINISH");break;case"INSIDE_OBJECT_START":{switch(f){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=h,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{f==='"'&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{f==='"'&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{f===":"&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(f,h,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{o(f,h);break}case"INSIDE_STRING":{switch(f){case'"':{t.pop(),n=h;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=h}break}case"INSIDE_ARRAY_START":{f==="]"?(n=h,t.pop()):(n=h,r(f,h,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(f){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=h,t.pop();break}default:{n=h;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(f,h,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=h;break}case"INSIDE_NUMBER":{switch(f){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=h;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(f,h),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&o(f,h);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&o(f,h);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(f,h);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const v=e.substring(a,h+1);!"false".startsWith(v)&&!"true".startsWith(v)&&!"null".startsWith(v)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?o(f,h):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&c(f,h)):n=h;break}}}let u=e.slice(0,n+1);for(let h=t.length-1;h>=0;h--)switch(t[h]){case"INSIDE_STRING":{u+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{u+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{u+="]";break}case"INSIDE_LITERAL":{const g=e.substring(a,e.length);"true".startsWith(g)?u+="true".slice(g.length):"false".startsWith(g)?u+="false".slice(g.length):"null".startsWith(g)&&(u+="null".slice(g.length))}}return u}async function Fd(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Ho({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Ho({text:jV(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var NV=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),kV=({schema:e,name:t,description:n})=>{const a=B0(e);return{name:"object",responseFormat:Ai(a.jsonSchema).then(r=>({type:"json",schema:r,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:r},o){const c=await Ho({text:r});if(!c.success)throw new Oi({message:"No object generated: could not parse the response.",cause:c.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const u=await kd({value:c.value,schema:a});if(!u.success)throw new Oi({message:"No object generated: response did not match schema.",cause:u.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return u.value},async parsePartialOutput({text:r}){const o=await Fd(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value}}},createElementStreamTransform(){}}},SV=({element:e,name:t,description:n})=>{const a=B0(e);return{name:"array",responseFormat:Ai(a.jsonSchema).then(r=>{const{$schema:o,...c}=r;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:c}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:r},o){const c=await Ho({text:r});if(!c.success)throw new Oi({message:"No object generated: could not parse the response.",cause:c.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const u=c.value;if(u==null||typeof u!="object"||!("elements"in u)||!Array.isArray(u.elements))throw new Oi({message:"No object generated: response did not match schema.",cause:new vc({value:u,cause:"response must be an object with an elements array"}),text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});for(const h of u.elements){const f=await kd({value:h,schema:a});if(!f.success)throw new Oi({message:"No object generated: response did not match schema.",cause:f.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason})}return u.elements},async parsePartialOutput({text:r}){const o=await Fd(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const c=o.value;if(c==null||typeof c!="object"||!("elements"in c)||!Array.isArray(c.elements))return;const u=o.state==="repaired-parse"&&c.elements.length>0?c.elements.slice(0,-1):c.elements,h=[];for(const f of u){const g=await kd({value:f,schema:a});g.success&&h.push(g.value)}return{partial:h}}}},createElementStreamTransform(){let r=0;return new TransformStream({transform({partialOutput:o},c){if(o!=null)for(;r<o.length;r++)c.enqueue(o[r])}})}}},CV=({options:e,name:t,description:n})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:a},r){const o=await Ho({text:a});if(!o.success)throw new Oi({message:"No object generated: could not parse the response.",cause:o.error,text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});const c=o.value;if(c==null||typeof c!="object"||!("result"in c)||typeof c.result!="string"||!e.includes(c.result))throw new Oi({message:"No object generated: response did not match schema.",cause:new vc({value:c,cause:"response must be an object that contains a choice value."}),text:a,response:r.response,usage:r.usage,finishReason:r.finishReason});return c.result},async parsePartialOutput({text:a}){const r=await Fd(a);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const o=r.value;if(o==null||typeof o!="object"||!("result"in o)||typeof o.result!="string")return;const c=e.filter(u=>u.startsWith(o.result));return r.state==="successful-parse"?c.includes(o.result)?{partial:o.result}:void 0:c.length===1?{partial:c[0]}:void 0}}},createElementStreamTransform(){}}),EV=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},a){const r=await Ho({text:n});if(!r.success)throw new Oi({message:"No object generated: could not parse the response.",cause:r.error,text:n,response:a.response,usage:a.usage,finishReason:a.finishReason});return r.value},async parsePartialOutput({text:n}){const a=await Fd(n);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return a.value===void 0?void 0:{partial:a.value}}},createElementStreamTransform(){}});Ud({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
62
+
63
+ `)},flush(e){e.enqueue(`data: [DONE]
64
+
65
+ `)}})}});var AV=eV(()=>_R(Ms([pn({type:lt("text-start"),id:Le(),providerMetadata:Tt.optional()}),pn({type:lt("text-delta"),id:Le(),delta:Le(),providerMetadata:Tt.optional()}),pn({type:lt("text-end"),id:Le(),providerMetadata:Tt.optional()}),pn({type:lt("error"),errorText:Le()}),pn({type:lt("tool-input-start"),toolCallId:Le(),toolName:Le(),providerExecuted:Es().optional(),providerMetadata:Tt.optional(),dynamic:Es().optional(),title:Le().optional()}),pn({type:lt("tool-input-delta"),toolCallId:Le(),inputTextDelta:Le()}),pn({type:lt("tool-input-available"),toolCallId:Le(),toolName:Le(),input:or(),providerExecuted:Es().optional(),providerMetadata:Tt.optional(),dynamic:Es().optional(),title:Le().optional()}),pn({type:lt("tool-input-error"),toolCallId:Le(),toolName:Le(),input:or(),providerExecuted:Es().optional(),providerMetadata:Tt.optional(),dynamic:Es().optional(),errorText:Le(),title:Le().optional()}),pn({type:lt("tool-approval-request"),approvalId:Le(),toolCallId:Le()}),pn({type:lt("tool-output-available"),toolCallId:Le(),output:or(),providerExecuted:Es().optional(),providerMetadata:Tt.optional(),dynamic:Es().optional(),preliminary:Es().optional()}),pn({type:lt("tool-output-error"),toolCallId:Le(),errorText:Le(),providerExecuted:Es().optional(),providerMetadata:Tt.optional(),dynamic:Es().optional()}),pn({type:lt("tool-output-denied"),toolCallId:Le()}),pn({type:lt("reasoning-start"),id:Le(),providerMetadata:Tt.optional()}),pn({type:lt("reasoning-delta"),id:Le(),delta:Le(),providerMetadata:Tt.optional()}),pn({type:lt("reasoning-end"),id:Le(),providerMetadata:Tt.optional()}),pn({type:lt("source-url"),sourceId:Le(),url:Le(),title:Le().optional(),providerMetadata:Tt.optional()}),pn({type:lt("source-document"),sourceId:Le(),mediaType:Le(),title:Le(),filename:Le().optional(),providerMetadata:Tt.optional()}),pn({type:lt("file"),url:Le(),mediaType:Le(),providerMetadata:Tt.optional()}),pn({type:AR(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Le().optional(),data:or(),transient:Es().optional()}),pn({type:lt("start-step")}),pn({type:lt("finish-step")}),pn({type:lt("start"),messageId:Le().optional(),messageMetadata:or().optional()}),pn({type:lt("finish"),finishReason:SR(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:or().optional()}),pn({type:lt("abort"),reason:Le().optional()}),pn({type:lt("message-metadata"),messageMetadata:or()})])));function TV(e){return e.type.startsWith("data-")}function Yx(e){return e.type.startsWith("tool-")}function qR(e){return e.type==="dynamic-tool"}function qo(e){return Yx(e)||qR(e)}function Xx(e){return e.type.split("-").slice(1).join("-")}function WR(e){return qR(e)?e.toolName:Xx(e)}function MV({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function RV({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:a,onError:r,onToolCall:o,onData:c}){return e.pipeThrough(new TransformStream({async transform(u,h){await a(async({state:f,write:g})=>{var v,y,x,w;function C(k){const A=f.message.parts.filter(qo).find(R=>R.toolCallId===k);if(A==null)throw new Dl({chunkType:"tool-invocation",chunkId:k,message:`No tool invocation found for tool call ID "${k}".`});return A}function T(k){var N;const A=f.message.parts.find(P=>Yx(P)&&P.toolCallId===k.toolCallId),R=k,_=A;if(A!=null){A.state=k.state,_.input=R.input,_.output=R.output,_.errorText=R.errorText,_.rawInput=R.rawInput,_.preliminary=R.preliminary,k.title!==void 0&&(_.title=k.title),_.providerExecuted=(N=R.providerExecuted)!=null?N:A.providerExecuted;const P=R.providerMetadata;if(P!=null)if(k.state==="output-available"||k.state==="output-error"){const $=A;$.resultProviderMetadata=P}else A.callProviderMetadata=P}else f.message.parts.push({type:`tool-${k.toolName}`,toolCallId:k.toolCallId,state:k.state,title:k.title,input:R.input,output:R.output,rawInput:R.rawInput,errorText:R.errorText,providerExecuted:R.providerExecuted,preliminary:R.preliminary,...R.providerMetadata!=null&&(k.state==="output-available"||k.state==="output-error")?{resultProviderMetadata:R.providerMetadata}:{},...R.providerMetadata!=null&&!(k.state==="output-available"||k.state==="output-error")?{callProviderMetadata:R.providerMetadata}:{}})}function E(k){var N,A;const R=f.message.parts.find($=>$.type==="dynamic-tool"&&$.toolCallId===k.toolCallId),_=k,P=R;if(R!=null){R.state=k.state,P.toolName=k.toolName,P.input=_.input,P.output=_.output,P.errorText=_.errorText,P.rawInput=(N=_.rawInput)!=null?N:P.rawInput,P.preliminary=_.preliminary,k.title!==void 0&&(P.title=k.title),P.providerExecuted=(A=_.providerExecuted)!=null?A:R.providerExecuted;const $=_.providerMetadata;if($!=null)if(k.state==="output-available"||k.state==="output-error"){const H=R;H.resultProviderMetadata=$}else R.callProviderMetadata=$}else f.message.parts.push({type:"dynamic-tool",toolName:k.toolName,toolCallId:k.toolCallId,state:k.state,input:_.input,output:_.output,errorText:_.errorText,preliminary:_.preliminary,providerExecuted:_.providerExecuted,title:k.title,..._.providerMetadata!=null&&(k.state==="output-available"||k.state==="output-error")?{resultProviderMetadata:_.providerMetadata}:{},..._.providerMetadata!=null&&!(k.state==="output-available"||k.state==="output-error")?{callProviderMetadata:_.providerMetadata}:{}})}async function S(k){if(k!=null){const N=f.message.metadata!=null?HR(f.message.metadata,k):k;t!=null&&await aC({value:N,schema:t,context:{field:"message.metadata",entityId:f.message.id}}),f.message.metadata=N}}switch(u.type){case"text-start":{const k={type:"text",text:"",providerMetadata:u.providerMetadata,state:"streaming"};f.activeTextParts[u.id]=k,f.message.parts.push(k),g();break}case"text-delta":{const k=f.activeTextParts[u.id];if(k==null)throw new Dl({chunkType:"text-delta",chunkId:u.id,message:`Received text-delta for missing text part with ID "${u.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});k.text+=u.delta,k.providerMetadata=(v=u.providerMetadata)!=null?v:k.providerMetadata,g();break}case"text-end":{const k=f.activeTextParts[u.id];if(k==null)throw new Dl({chunkType:"text-end",chunkId:u.id,message:`Received text-end for missing text part with ID "${u.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});k.state="done",k.providerMetadata=(y=u.providerMetadata)!=null?y:k.providerMetadata,delete f.activeTextParts[u.id],g();break}case"reasoning-start":{const k={type:"reasoning",text:"",providerMetadata:u.providerMetadata,state:"streaming"};f.activeReasoningParts[u.id]=k,f.message.parts.push(k),g();break}case"reasoning-delta":{const k=f.activeReasoningParts[u.id];if(k==null)throw new Dl({chunkType:"reasoning-delta",chunkId:u.id,message:`Received reasoning-delta for missing reasoning part with ID "${u.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});k.text+=u.delta,k.providerMetadata=(x=u.providerMetadata)!=null?x:k.providerMetadata,g();break}case"reasoning-end":{const k=f.activeReasoningParts[u.id];if(k==null)throw new Dl({chunkType:"reasoning-end",chunkId:u.id,message:`Received reasoning-end for missing reasoning part with ID "${u.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});k.providerMetadata=(w=u.providerMetadata)!=null?w:k.providerMetadata,k.state="done",delete f.activeReasoningParts[u.id],g();break}case"file":{f.message.parts.push({type:"file",mediaType:u.mediaType,url:u.url,...u.providerMetadata!=null?{providerMetadata:u.providerMetadata}:{}}),g();break}case"source-url":{f.message.parts.push({type:"source-url",sourceId:u.sourceId,url:u.url,title:u.title,providerMetadata:u.providerMetadata}),g();break}case"source-document":{f.message.parts.push({type:"source-document",sourceId:u.sourceId,mediaType:u.mediaType,title:u.title,filename:u.filename,providerMetadata:u.providerMetadata}),g();break}case"tool-input-start":{const k=f.message.parts.filter(Yx);f.partialToolCalls[u.toolCallId]={text:"",toolName:u.toolName,index:k.length,dynamic:u.dynamic,title:u.title},u.dynamic?E({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title,providerMetadata:u.providerMetadata}):T({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-streaming",input:void 0,providerExecuted:u.providerExecuted,title:u.title,providerMetadata:u.providerMetadata}),g();break}case"tool-input-delta":{const k=f.partialToolCalls[u.toolCallId];if(k==null)throw new Dl({chunkType:"tool-input-delta",chunkId:u.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${u.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});k.text+=u.inputTextDelta;const{value:N}=await Fd(k.text);k.dynamic?E({toolCallId:u.toolCallId,toolName:k.toolName,state:"input-streaming",input:N,title:k.title}):T({toolCallId:u.toolCallId,toolName:k.toolName,state:"input-streaming",input:N,title:k.title}),g();break}case"tool-input-available":{u.dynamic?E({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}):T({toolCallId:u.toolCallId,toolName:u.toolName,state:"input-available",input:u.input,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:u.title}),g(),o&&!u.providerExecuted&&await o({toolCall:u});break}case"tool-input-error":{const k=f.message.parts.filter(qo).find(A=>A.toolCallId===u.toolCallId);(k!=null?k.type==="dynamic-tool":!!u.dynamic)?E({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}):T({toolCallId:u.toolCallId,toolName:u.toolName,state:"output-error",input:void 0,rawInput:u.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata}),g();break}case"tool-approval-request":{const k=C(u.toolCallId);k.state="approval-requested",k.approval={id:u.approvalId},g();break}case"tool-output-denied":{const k=C(u.toolCallId);k.state="output-denied",g();break}case"tool-output-available":{const k=C(u.toolCallId);k.type==="dynamic-tool"?E({toolCallId:u.toolCallId,toolName:k.toolName,state:"output-available",input:k.input,output:u.output,preliminary:u.preliminary,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:k.title}):T({toolCallId:u.toolCallId,toolName:Xx(k),state:"output-available",input:k.input,output:u.output,providerExecuted:u.providerExecuted,preliminary:u.preliminary,providerMetadata:u.providerMetadata,title:k.title}),g();break}case"tool-output-error":{const k=C(u.toolCallId);k.type==="dynamic-tool"?E({toolCallId:u.toolCallId,toolName:k.toolName,state:"output-error",input:k.input,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:k.title}):T({toolCallId:u.toolCallId,toolName:Xx(k),state:"output-error",input:k.input,rawInput:k.rawInput,errorText:u.errorText,providerExecuted:u.providerExecuted,providerMetadata:u.providerMetadata,title:k.title}),g();break}case"start-step":{f.message.parts.push({type:"step-start"});break}case"finish-step":{f.activeTextParts={},f.activeReasoningParts={};break}case"start":{u.messageId!=null&&(f.message.id=u.messageId),await S(u.messageMetadata),(u.messageId!=null||u.messageMetadata!=null)&&g();break}case"finish":{u.finishReason!=null&&(f.finishReason=u.finishReason),await S(u.messageMetadata),u.messageMetadata!=null&&g();break}case"message-metadata":{await S(u.messageMetadata),u.messageMetadata!=null&&g();break}case"error":{r?.(new Error(u.errorText));break}default:if(TV(u)){if(n?.[u.type]!=null){const A=f.message.parts.findIndex(_=>"id"in _&&"data"in _&&_.id===u.id&&_.type===u.type),R=A>=0?A:f.message.parts.length;await aC({value:u.data,schema:n[u.type],context:{field:`message.parts[${R}].data`,entityName:u.type,entityId:u.id}})}const k=u;if(k.transient){c?.(k);break}const N=k.id!=null?f.message.parts.find(A=>k.type===A.type&&k.id===A.id):void 0;N!=null?N.data=k.data:f.message.parts.push(k),c?.(k),g()}}h.enqueue(u)})}}))}async function IV({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:a}=await n.read();if(a)break}}catch(a){t?.(a)}finally{n.releaseLock()}}Ud({prefix:"aitxt",size:24});Ud({prefix:"aiobj",size:24});var _V=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(a){n(a)}}),this.processQueue()})}};Ud({prefix:"aiobj",size:24});async function OV(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:a}=t,r=await new Promise((o,c)=>{const u=new FileReader;u.onload=h=>{var f;o((f=h.target)==null?void 0:f.result)},u.onerror=h=>c(h),u.readAsDataURL(t)});return{type:"file",mediaType:a,filename:n,url:r}}))}var $V=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:a,fetch:r,prepareSendMessagesRequest:o,prepareReconnectToStreamRequest:c}){this.api=e,this.credentials=t,this.headers=n,this.body=a,this.fetch=r,this.prepareSendMessagesRequest=o,this.prepareReconnectToStreamRequest=c}async sendMessages({abortSignal:e,...t}){var n,a,r,o,c;const u=await Ai(this.body),h=await Ai(this.headers),f=await Ai(this.credentials),g={...Pl(h),...Pl(t.headers)},v=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...u,...t.body},headers:g,credentials:f,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),y=(a=v?.api)!=null?a:this.api,x=v?.headers!==void 0?Pl(v.headers):g,w=v?.body!==void 0?v.body:{...u,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},C=(r=v?.credentials)!=null?r:f,E=await((o=this.fetch)!=null?o:globalThis.fetch)(y,{method:"POST",headers:{"Content-Type":"application/json",...x},body:JSON.stringify(w),credentials:C,signal:e});if(!E.ok)throw new Error((c=await E.text())!=null?c:"Failed to fetch the chat response.");if(!E.body)throw new Error("The response body is empty.");return this.processResponseStream(E.body)}async reconnectToStream(e){var t,n,a,r,o;const c=await Ai(this.body),u=await Ai(this.headers),h=await Ai(this.credentials),f={...Pl(u),...Pl(e.headers)},g=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...c,...e.body},headers:f,credentials:h,requestMetadata:e.metadata})),v=(n=g?.api)!=null?n:`${this.api}/${e.chatId}/stream`,y=g?.headers!==void 0?Pl(g.headers):f,x=(a=g?.credentials)!=null?a:h,C=await((r=this.fetch)!=null?r:globalThis.fetch)(v,{method:"GET",headers:y,credentials:x});if(C.status===204)return null;if(!C.ok)throw new Error((o=await C.text())!=null?o:"Failed to fetch the chat response.");if(!C.body)throw new Error("The response body is empty.");return this.processResponseStream(C.body)}},GR=class extends $V{constructor(e={}){super(e)}processResponseStream(e){return iV({stream:e,schema:AV}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},PV=class{constructor({generateId:e=cF,id:t=e(),transport:n=new GR,messageMetadataSchema:a,dataPartSchemas:r,state:o,onError:c,onToolCall:u,onFinish:h,onData:f,sendAutomaticallyWhen:g}){this.activeResponse=void 0,this.jobExecutor=new _V,this.sendMessage=async(v,y)=>{var x,w,C,T;if(v==null){await this.makeRequest({trigger:"submit-message",messageId:(x=this.lastMessage)==null?void 0:x.id,...y});return}let E;if("text"in v||"files"in v?E={parts:[...Array.isArray(v.files)?v.files:await OV(v.files),..."text"in v&&v.text!=null?[{type:"text",text:v.text}]:[]]}:E=v,v.messageId!=null){const S=this.state.messages.findIndex(k=>k.id===v.messageId);if(S===-1)throw new Error(`message with id ${v.messageId} not found`);if(this.state.messages[S].role!=="user")throw new Error(`message with id ${v.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,S+1),this.state.replaceMessage(S,{...E,id:v.messageId,role:(w=E.role)!=null?w:"user",metadata:v.metadata})}else this.state.pushMessage({...E,id:(C=E.id)!=null?C:this.generateId(),role:(T=E.role)!=null?T:"user",metadata:v.metadata});await this.makeRequest({trigger:"submit-message",messageId:v.messageId,...y})},this.regenerate=async({messageId:v,...y}={})=>{const x=v==null?this.state.messages.length-1:this.state.messages.findIndex(w=>w.id===v);if(x===-1)throw new Error(`message ${v} not found`);this.state.messages=this.state.messages.slice(0,this.messages[x].role==="assistant"?x:x+1),await this.makeRequest({trigger:"regenerate-message",messageId:v,...y})},this.resumeStream=async(v={})=>{await this.makeRequest({trigger:"resume-stream",...v})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:v,approved:y,reason:x,options:w})=>this.jobExecutor.run(async()=>{const C=this.state.messages,T=C[C.length-1],E=S=>qo(S)&&S.state==="approval-requested"&&S.approval.id===v?{...S,state:"approval-responded",approval:{id:v,approved:y,reason:x}}:S;this.state.replaceMessage(C.length-1,{...T,parts:T.parts.map(E)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(E)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(S=>{var k;S&&this.makeRequest({trigger:"submit-message",messageId:(k=this.lastMessage)==null?void 0:k.id,...w})})}),this.addToolOutput=async({state:v="output-available",toolCallId:y,output:x,errorText:w,options:C})=>this.jobExecutor.run(async()=>{const T=this.state.messages,E=T[T.length-1],S=k=>qo(k)&&k.toolCallId===y?{...k,state:v,output:x,errorText:w}:k;this.state.replaceMessage(T.length-1,{...E,parts:E.parts.map(S)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(S)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(k=>{var N;k&&this.makeRequest({trigger:"submit-message",messageId:(N=this.lastMessage)==null?void 0:N.id,...C})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var v;this.status!=="streaming"&&this.status!=="submitted"||(v=this.activeResponse)!=null&&v.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=a,this.dataPartSchemas=r,this.state=o,this.onError=c,this.onToolCall=u,this.onFinish=h,this.onData=f,this.sendAutomaticallyWhen=g}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:a,messageId:r}){var o,c,u;let h;if(e==="resume-stream")try{const x=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:a});if(x==null)return;h=x}catch(x){this.onError&&x instanceof Error&&this.onError(x),this.setStatus({status:"error",error:x});return}this.setStatus({status:"submitted",error:void 0});const f=this.lastMessage;let g=!1,v=!1,y=!1;try{const x={state:MV({lastMessage:this.state.snapshot(f),messageId:this.generateId()}),abortController:new AbortController};x.abortController.signal.addEventListener("abort",()=>{g=!0}),this.activeResponse=x;let w;e==="resume-stream"?w=h:w=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:x.abortController.signal,metadata:t,headers:n,body:a,trigger:e,messageId:r});const C=T=>this.jobExecutor.run(()=>T({state:x.state,write:()=>{var E;this.setStatus({status:"streaming"}),x.state.message.id===((E=this.lastMessage)==null?void 0:E.id)?this.state.replaceMessage(this.state.messages.length-1,x.state.message):this.state.pushMessage(x.state.message)}}));await IV({stream:RV({stream:w,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:C,onError:T=>{throw T}}),onError:T=>{throw T}}),this.setStatus({status:"ready"})}catch(x){if(g||x.name==="AbortError")return g=!0,this.setStatus({status:"ready"}),null;y=!0,x instanceof TypeError&&(x.message.toLowerCase().includes("fetch")||x.message.toLowerCase().includes("network"))&&(v=!0),this.onError&&x instanceof Error&&this.onError(x),this.setStatus({status:"error",error:x})}finally{try{(c=this.onFinish)==null||c.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:g,isDisconnect:v,isError:y,finishReason:(o=this.activeResponse)==null?void 0:o.state.finishReason})}catch(x){console.error(x)}this.activeResponse=void 0}!y&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(u=this.lastMessage)==null?void 0:u.id,metadata:t,headers:n,body:a})}},Iy,rC;function DV(){if(rC)return Iy;rC=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let a,r=0;return function(...c){clearTimeout(a);const u=Date.now(),h=u-r,f=n-h;f<=0?(r=u,t.apply(this,c)):a=setTimeout(()=>{r=Date.now(),t.apply(this,c)},f)}}return Iy=e,Iy}var LV=DV();const zV=JM(LV);var _y={exports:{}},Oy={};var iC;function BV(){if(iC)return Oy;iC=1;var e=Ld();function t(v,y){return v===y&&(v!==0||1/v===1/y)||v!==v&&y!==y}var n=typeof Object.is=="function"?Object.is:t,a=e.useState,r=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(v,y){var x=y(),w=a({inst:{value:x,getSnapshot:y}}),C=w[0].inst,T=w[1];return o(function(){C.value=x,C.getSnapshot=y,h(C)&&T({inst:C})},[v,x,y]),r(function(){return h(C)&&T({inst:C}),v(function(){h(C)&&T({inst:C})})},[v]),c(x),x}function h(v){var y=v.getSnapshot;v=v.value;try{var x=y();return!n(v,x)}catch{return!0}}function f(v,y){return y()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return Oy.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Oy}var oC;function ZR(){return oC||(oC=1,_y.exports=BV()),_y.exports}var UV=ZR(),KR=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},gn=(e,t,n)=>(KR(e,t,"read from private field"),n?n.call(e):t.get(e)),rr=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Ci=(e,t,n,a)=>(KR(e,t,"write to private field"),t.set(e,n),n);function FV(e,t){return t!=null?zV(e,t):e}var wa,lm,cm,Wu,Gu,Zu,Wl,Qx,Jx,VV=class{constructor(e=[]){rr(this,wa,void 0),rr(this,lm,"ready"),rr(this,cm,void 0),rr(this,Wu,new Set),rr(this,Gu,new Set),rr(this,Zu,new Set),this.pushMessage=t=>{Ci(this,wa,gn(this,wa).concat(t)),gn(this,Wl).call(this)},this.popMessage=()=>{Ci(this,wa,gn(this,wa).slice(0,-1)),gn(this,Wl).call(this)},this.replaceMessage=(t,n)=>{Ci(this,wa,[...gn(this,wa).slice(0,t),this.snapshot(n),...gn(this,wa).slice(t+1)]),gn(this,Wl).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const a=n?FV(t,n):t;return gn(this,Wu).add(a),()=>{gn(this,Wu).delete(a)}},this["~registerStatusCallback"]=t=>(gn(this,Gu).add(t),()=>{gn(this,Gu).delete(t)}),this["~registerErrorCallback"]=t=>(gn(this,Zu).add(t),()=>{gn(this,Zu).delete(t)}),rr(this,Wl,()=>{gn(this,Wu).forEach(t=>t())}),rr(this,Qx,()=>{gn(this,Gu).forEach(t=>t())}),rr(this,Jx,()=>{gn(this,Zu).forEach(t=>t())}),Ci(this,wa,e)}get status(){return gn(this,lm)}set status(e){Ci(this,lm,e),gn(this,Qx).call(this)}get error(){return gn(this,cm)}set error(e){Ci(this,cm,e),gn(this,Jx).call(this)}get messages(){return gn(this,wa)}set messages(e){Ci(this,wa,[...e]),gn(this,Wl).call(this)}};wa=new WeakMap;lm=new WeakMap;cm=new WeakMap;Wu=new WeakMap;Gu=new WeakMap;Zu=new WeakMap;Wl=new WeakMap;Qx=new WeakMap;Jx=new WeakMap;var Gl,lC=class extends PV{constructor({messages:e,...t}){const n=new VV(e);super({...t,state:n}),rr(this,Gl,void 0),this["~registerMessagesCallback"]=(a,r)=>gn(this,Gl)["~registerMessagesCallback"](a,r),this["~registerStatusCallback"]=a=>gn(this,Gl)["~registerStatusCallback"](a),this["~registerErrorCallback"]=a=>gn(this,Gl)["~registerErrorCallback"](a),Ci(this,Gl,n)}};Gl=new WeakMap;function HV({experimental_throttle:e,resume:t=!1,...n}={}){const a=m.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(a.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const r={...n,onToolCall:y=>{var x,w;return(w=(x=a.current).onToolCall)==null?void 0:w.call(x,y)},onData:y=>{var x,w;return(w=(x=a.current).onData)==null?void 0:w.call(x,y)},onFinish:y=>{var x,w;return(w=(x=a.current).onFinish)==null?void 0:w.call(x,y)},onError:y=>{var x,w;return(w=(x=a.current).onError)==null?void 0:w.call(x,y)},sendAutomaticallyWhen:y=>{var x,w,C;return(C=(w=(x=a.current).sendAutomaticallyWhen)==null?void 0:w.call(x,y))!=null?C:!1}},o=m.useRef("chat"in n?n.chat:new lC(r));("chat"in n&&n.chat!==o.current||"id"in n&&o.current.id!==n.id)&&(o.current="chat"in n?n.chat:new lC(r));const u=m.useCallback(y=>o.current["~registerMessagesCallback"](y,e),[e,o.current.id]),h=m.useSyncExternalStore(u,()=>o.current.messages,()=>o.current.messages),f=m.useSyncExternalStore(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),g=m.useSyncExternalStore(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),v=m.useCallback(y=>{typeof y=="function"&&(y=y(o.current.messages)),o.current.messages=y},[o]);return m.useEffect(()=>{t&&o.current.resumeStream()},[t,o]),{id:o.current.id,messages:h,setMessages:v,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:g,resumeStream:o.current.resumeStream,status:f,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput,addToolApprovalResponse:o.current.addToolApprovalResponse}}function qV(e){try{const t=localStorage.getItem(e);if(t)return JSON.parse(t)}catch{}}function WV(e,t){try{localStorage.setItem(e,JSON.stringify(t)),window.dispatchEvent(new CustomEvent("hudson:saved",{detail:{key:e}}))}catch{}}var GV=()=>()=>{},ZV=()=>!0,KV=()=>!1;function YV(){return m.useSyncExternalStore(GV,ZV,KV)}function Ua(e,t){const n=YV(),[a,r]=m.useState(t),o=m.useRef(!1);if(n&&!o.current){o.current=!0;const c=qV(e);c!==void 0&&r(c)}return m.useEffect(()=>{n&&WV(e,a)},[e,a,n]),[a,r]}function XV(e){const t={};for(const n of e.attachmentsRef.current??[])if(e.activeAttachmentsRef.current.has(n.label)){const a=n.content();a!==null&&(t[n.label.toLowerCase()]=a)}return{toolset:e.toolsetRef.current,context:{...e.contextRef.current,...t},mode:e.modeRef.current,sessionId:e.sessionIdRef.current,provider:e.providerRef.current,model:e.modelRef.current}}function QV(e,t){e.current?.(t)}function JV(e,t){e.current?.(t)}function e9(e){const t=new Set;for(const n of e??[])if(n.role==="assistant")for(const a of n.parts??[])a&&qo(a)&&t.add(a.toolCallId);return t}function t9({toolset:e,chatId:t,initialMessages:n,context:a,onToolCall:r,mode:o,attachments:c,provider:u,model:h,sessionId:f,onSessionIdChange:g,onFinish:v,onError:y}){const x=m.useRef(r),w=m.useRef(v),C=m.useRef(y),T=m.useRef(f??crypto.randomUUID()),[E,S]=m.useState(new Set),k=m.useCallback(B=>{S(X=>{const W=new Set(X);return W.has(B)?W.delete(B):W.add(B),W})},[]),[N]=Ua("hudson.settings",{}),A=o??N.aiMode??"api",R=m.useRef(E),_=m.useRef(c),P=m.useRef(a),$=m.useRef(e),H=m.useRef(A),I=m.useRef(u),U=m.useRef(h);m.useEffect(()=>{x.current=r},[r]),m.useEffect(()=>{w.current=v},[v]),m.useEffect(()=>{C.current=y},[y]),m.useEffect(()=>{f&&f!==T.current&&(T.current=f)},[f]),m.useEffect(()=>{g?.(T.current)},[g]),m.useEffect(()=>{R.current=E},[E]),m.useEffect(()=>{_.current=c},[c]),m.useEffect(()=>{P.current=a},[a]),m.useEffect(()=>{$.current=e},[e]),m.useEffect(()=>{H.current=A},[A]),m.useEffect(()=>{I.current=u},[u]),m.useEffect(()=>{U.current=h},[h]);const D=m.useMemo(()=>new GR({api:"/api/ai/chat",body:()=>XV({activeAttachmentsRef:R,attachmentsRef:_,contextRef:P,toolsetRef:$,modeRef:H,sessionIdRef:T,providerRef:I,modelRef:U})}),[]),V=HV({id:t,messages:n,transport:D,onFinish:B=>QV(w,B),onError:B=>JV(C,B)}),Z=m.useRef(e9(n)),O=m.useCallback(()=>{const B=crypto.randomUUID();T.current=B,g?.(B),Z.current.clear(),V.setMessages([])},[V,g]),{messages:z}=V;return m.useEffect(()=>{if(x.current){for(const B of z)if(B.role==="assistant"){for(const X of B.parts??[])if(X&&qo(X)){if("state"in X&&X.state==="input-streaming")continue;const W=X.toolCallId;if(!Z.current.has(W)){Z.current.add(W);const L=WR(X);x.current?.(L,X.input??{})}}}}},[z]),{messages:z,sendMessage:V.sendMessage,stop:V.stop,status:V.status,setMessages:V.setMessages,clearChat:O,error:V.error,mode:A,attachments:c??[],activeAttachments:E,toggleAttachment:k}}function n9({app:e,commands:t,state:n,provider:a,model:r,onFinish:o}){const c=m.useMemo(()=>(e.intents??[]).map(f=>({commandId:f.commandId,title:f.title,description:f.description,category:f.category,keywords:f.keywords,shortcut:f.shortcut,dangerous:f.dangerous,params:f.params?.map(g=>({name:g.name,description:g.description,type:g.type,optional:g.optional,enum:g.enum}))})),[e.intents]),u=m.useMemo(()=>({appId:e.id,appName:e.name,appDescription:e.description,intents:c,state:n}),[e.id,e.name,e.description,c,n]),h=m.useCallback(f=>{const g=t.find(v=>v.id===f);if(!g){console.warn(`[useAssistant] no command for id "${f}"`);return}g.action()},[t]);return t9({toolset:"intents",context:u,provider:a,model:r,onFinish:o,onToolCall:(f,g)=>{if(f!=="dispatch")return;const v=g.commandId;typeof v=="string"&&h(v)}})}function U0(e={}){const{url:t="ws://localhost:3600",healthUrl:n,systemPrompt:a,cwd:r,workspaceFiles:o,autoConnect:c=!1,sessionKey:u,orphanTTL:h,backend:f,tmuxSession:g,agent:v,provider:y,model:x}=e,w=u?`hudson.relay.${u}`:null,C=()=>{if(!w)return null;try{return localStorage.getItem(w)}catch{return null}},T=pe=>{if(w)try{pe?localStorage.setItem(w,pe):localStorage.removeItem(w)}catch{}},[E,S]=m.useState("disconnected"),[k,N]=m.useState(null),[A,R]=m.useState(null),[_,P]=m.useState(null),[$,H]=m.useState(r||"~"),I=m.useRef(null),U=m.useRef(null),D=m.useRef({cols:80,rows:24}),V=m.useRef(!1),Z=m.useRef(""),O=m.useRef(0),z=m.useRef($);z.current=$;const B=m.useRef(C()),X=m.useRef(null),W=512*1024,L=m.useCallback(pe=>{if(pe){if(X.current){X.current(pe);return}Z.current+=pe,Z.current.length>W&&(Z.current=Z.current.slice(-W))}},[]),q=m.useCallback(pe=>{const Xe=I.current;Xe&&Xe.readyState===WebSocket.OPEN&&Xe.send(JSON.stringify(pe))},[]),K=m.useCallback(()=>{const pe=I.current;pe&&(pe.close(),I.current=null)},[]),ee=m.useCallback(()=>{O.current+=1,U.current&&(clearTimeout(U.current),U.current=null),K(),V.current=!1,S("disconnected")},[K]),G=m.useCallback(()=>{const pe=z.current;return{type:"session:init",cols:D.current.cols,rows:D.current.rows,...a?{systemPrompt:a}:{},...pe?{cwd:pe}:{},...o?{workspaceFiles:o}:{},...h?{orphanTTL:h}:{},...f?{backend:f}:{},...g?{tmuxSession:g}:{},...v?{agent:v}:{},...y?{provider:y}:{},...x?{model:x}:{}}},[a,o,h,f,g,v,y,x]),re=m.useCallback(()=>{V.current||(V.current=!0,B.current?q({type:"session:reconnect",sessionId:B.current,cols:D.current.cols,rows:D.current.rows}):q(G()))},[q,G]),Q=m.useCallback(async()=>{const pe=O.current+1;O.current=pe,K(),V.current=!1,S("connecting"),R(null),P(null);const Xe=n||`${t.replace(/^ws(s?):\/\//,"http$1://")}/health`;try{await fetch(Xe,{signal:AbortSignal.timeout(2e3)})}catch{if(O.current!==pe)return;S("error"),R("Relay service is not running");return}if(O.current!==pe)return;K();const Be=new WebSocket(t);I.current=Be;const Se=()=>O.current===pe&&I.current===Be;Be.onopen=()=>{if(!Se()){Be.close();return}re()},Be.onmessage=Me=>{if(Se())try{const _e=JSON.parse(Me.data);switch(_e.type){case"session:ready":B.current=_e.sessionId,T(_e.sessionId),N(_e.sessionId),S("connected"),R(null),P(null);break;case"session:expired":{B.current=null,T(null),V.current=!1,L("\x1B[2J\x1B[H"),q(G()),V.current=!0;break}case"session:error":S("error"),R(_e.error||"Session failed to start");break;case"terminal:data":_e.data&&L(_e.data);break;case"session:exit":B.current=null,T(null),N(null),P(_e.exitCode??null),_e.exitCode!==0?(S("error"),R(_e.reason||`Process exited with code ${_e.exitCode}`)):S("disconnected");break;case"session:detached":B.current=null,T(null),N(null);break}}catch{}},Be.onclose=()=>{Se()&&(I.current=null,V.current=!1,S(Me=>Me==="error"?Me:"disconnected"))},Be.onerror=()=>{Se()&&(S("error"),R("Could not connect to relay"))}},[t,n,re,K,q,a,o]),ae=m.useCallback(pe=>{q({type:"terminal:input",data:pe})},[q]),be=m.useCallback(pe=>{q({type:"terminal:input",data:pe+"\r"})},[q]),$e=m.useCallback((pe,Xe)=>{D.current={cols:pe,rows:Xe},V.current&&q({type:"terminal:resize",cols:pe,rows:Xe})},[q]),ge=m.useCallback(pe=>{X.current=pe,!(!pe||Z.current.length===0)&&(pe(Z.current),Z.current="")},[]);m.useEffect(()=>(c&&Q(),()=>{ee()}),[]);const Te=m.useCallback(()=>{ee(),B.current=null,N(null),T(null),R(null),P(null),setTimeout(()=>Q(),200)},[ee,Q]);return{status:E,sessionId:k,error:A,exitCode:_,cwd:$,setCwd:H,onData:ge,sendInput:ae,sendLine:be,resize:$e,connect:Q,disconnect:ee,restart:Te}}function s9({chat:e,placeholder:t="Ask AI...",inputExtras:n,inputStatus:a,inputValue:r,onInputChange:o}){const{messages:c,sendMessage:u,stop:h,status:f,clearChat:g,error:v,attachments:y,activeAttachments:x,toggleAttachment:w}=e,[C,T]=m.useState(""),E=r!==void 0,S=E?r:C,k=H=>{E?o?.(H):T(H)},N=m.useRef(null),A=m.useRef(null),R=f==="streaming"||f==="submitted",_=y.length>0;m.useEffect(()=>{const H=N.current;H&&(H.scrollTop=H.scrollHeight)},[c]),m.useEffect(()=>{A.current?.focus()},[]);const P=H=>{H.preventDefault();const I=S.trim();!I||R||(k(""),u({text:I}))},$=H=>{H.stopPropagation(),H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),P(H))};return s.jsxs("div",{className:"flex flex-col h-full font-mono text-[12px]",children:[s.jsxs("div",{ref:N,className:"flex-1 overflow-y-auto frame-scrollbar p-3 space-y-3",children:[c.length===0&&s.jsx("div",{className:"text-neutral-500 text-center py-8 select-none",children:t}),c.map(H=>s.jsx("div",{className:`flex ${H.role==="user"?"justify-end":"justify-start"}`,children:s.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 whitespace-pre-wrap break-words leading-relaxed ${H.role==="user"?"bg-emerald-500/10 text-emerald-100 border border-emerald-500/20":"bg-neutral-800/50 text-neutral-200 border border-neutral-700/50"}`,children:(H.parts??[]).map((I,U)=>{if(!I)return null;if(I.type==="text")return s.jsx("span",{children:I.text},U);if(qo(I)){const D=WR(I),V=Object.entries(I.input??{}).map(([Z,O])=>`${Z}: ${JSON.stringify(O)}`).join(", ");return s.jsxs("div",{className:"text-[11px] text-cyan-400/70 mt-1 font-mono",children:[s.jsx("span",{className:"text-neutral-500",children:"↳ "}),D,"(",V,")"]},U)}return null})})},H.id)),R&&c[c.length-1]?.role!=="assistant"&&s.jsx("div",{className:"flex justify-start",children:s.jsx("div",{className:"bg-neutral-800/50 border border-neutral-700/50 rounded-lg px-3 py-2 text-neutral-400",children:s.jsx("span",{className:"animate-pulse",children:"..."})})})]}),v&&s.jsxs("div",{className:"px-3 py-2 bg-red-900/20 border-t border-red-500/30 text-red-400 text-[11px] flex items-center gap-2",children:[s.jsx(i2,{size:12}),s.jsx("span",{className:"truncate",children:v.message||"An error occurred"})]}),s.jsxs("div",{className:"px-3 py-2.5 border-t border-neutral-700/50 bg-neutral-900/50",children:[_&&s.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[s.jsx(_z,{size:11,className:"text-neutral-500 shrink-0"}),y.map(H=>{const I=x.has(H.label);return s.jsx("button",{type:"button",onClick:()=>w(H.label),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${I?"bg-cyan-500/15 text-cyan-300 border-cyan-500/40":"text-neutral-500 border-neutral-700 hover:text-neutral-300 hover:border-neutral-600"}`,children:H.label},H.label)}),x.size>0&&s.jsx("span",{className:"text-[10px] text-neutral-600 ml-1",children:"attached"})]}),s.jsxs("form",{onSubmit:P,className:"flex items-center gap-2 rounded-lg border border-neutral-700 bg-neutral-800/60 px-3 py-2 focus-within:border-emerald-500/40 transition-colors",children:[c.length>0&&s.jsx("button",{type:"button",onClick:()=>g(),className:"p-1 rounded text-neutral-500 hover:text-neutral-300 hover:bg-neutral-700 transition-colors",title:"Clear",children:s.jsx(l3,{size:12})}),s.jsx("input",{ref:A,type:"text",value:S,onChange:H=>k(H.target.value),onKeyDown:$,placeholder:t,className:"flex-1 bg-transparent outline-none text-neutral-100 placeholder:text-neutral-500 caret-emerald-400",disabled:R}),R?s.jsx("button",{type:"button",onClick:()=>h(),className:"p-1.5 rounded text-amber-400 hover:bg-amber-900/20 transition-colors",title:"Stop",children:s.jsx(Bd,{size:12})}):s.jsx("button",{type:"submit",disabled:!S.trim(),className:"text-[11px] px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/30 hover:bg-emerald-500/20 disabled:opacity-30 disabled:cursor-default transition-colors",children:"Send"})]})]})]})}var a9={background:"#1a1a1a",foreground:"#abb2bf",cursor:"#528bff",cursorAccent:"#1a1a1a",selectionBackground:"#3e4451",selectionForeground:"#abb2bf",black:"#1a1a1a",red:"#e06c75",green:"#98c379",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#56b6c2",white:"#abb2bf",brightBlack:"#5c6370",brightRed:"#e06c75",brightGreen:"#98c379",brightYellow:"#e5c07b",brightBlue:"#61afef",brightMagenta:"#c678dd",brightCyan:"#56b6c2",brightWhite:"#ffffff"},r9=`
66
+ .xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
67
+ .xterm.focus, .xterm:focus { outline: none; }
68
+ .xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
69
+ .xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; }
70
+ .xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
71
+ .xterm .composition-view.active { display: block; }
72
+ .xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
73
+ .xterm .xterm-screen { position: relative; }
74
+ .xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
75
+ .xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
76
+ .xterm.enable-mouse-events { cursor: default; }
77
+ .xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
78
+ .xterm.column-select.focus { cursor: crosshair; }
79
+ .xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
80
+ .xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
81
+ .xterm .xterm-accessibility-tree { font-family: monospace; user-select: text; white-space: pre; }
82
+ .xterm .xterm-accessibility-tree > div { transform-origin: left; width: fit-content; }
83
+ .xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
84
+ .xterm-dim { opacity: 1 !important; }
85
+ .xterm-underline-1 { text-decoration: underline; }
86
+ .xterm-underline-2 { text-decoration: double underline; }
87
+ .xterm-underline-3 { text-decoration: wavy underline; }
88
+ .xterm-underline-4 { text-decoration: dotted underline; }
89
+ .xterm-underline-5 { text-decoration: dashed underline; }
90
+ .xterm-overline { text-decoration: overline; }
91
+ .xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
92
+ .xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
93
+ .xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
94
+ .xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
95
+ .xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
96
+ .xterm-strikethrough { text-decoration: line-through; }
97
+ .xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
98
+ .xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
99
+ .xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
100
+ .xterm-decoration-top { z-index: 2; position: relative; }
101
+ .xterm .xterm-scrollable-element > .scrollbar { cursor: default; }
102
+ .xterm .xterm-scrollable-element > .scrollbar > .scra { cursor: pointer; font-size: 11px !important; }
103
+ .xterm .xterm-scrollable-element > .visible { opacity: 1; background: rgba(0,0,0,0); transition: opacity 100ms linear; z-index: 11; }
104
+ .xterm .xterm-scrollable-element > .invisible { opacity: 0; pointer-events: none; }
105
+ .xterm .xterm-scrollable-element > .invisible.fade { transition: opacity 800ms linear; }
106
+ .xterm .xterm-scrollable-element > .shadow { position: absolute; display: none; }
107
+ .xterm .xterm-scrollable-element > .shadow.top { display: block; top: 0; left: 3px; height: 3px; width: 100%; }
108
+ .xterm .xterm-scrollable-element > .shadow.left { display: block; top: 3px; left: 0; height: 100%; width: 3px; }
109
+ `;function i9(){if(typeof document>"u"||document.querySelector("[data-xterm-css]"))return;const e=document.createElement("style");e.setAttribute("data-xterm-css",""),e.textContent=r9,document.head.appendChild(e)}function o9(e){return new Promise((t,n)=>{const a=new FileReader;a.onload=()=>{const r=a.result;t(r.split(",")[1])},a.onerror=n,a.readAsDataURL(e)})}function F0({relay:e,fontSize:t=12,fontFamily:n="'JetBrains Mono', 'Hack Nerd Font', monospace",configItems:a,onOpenSettings:r,onStartService:o,quiet:c=!1}){const{status:u,error:h,exitCode:f,cwd:g,setCwd:v,sendInput:y,resize:x,onData:w,connect:C,disconnect:T}=e,[E,S]=m.useState(!1),{apiBaseUrl:k}=Dp(),N=m.useRef(null),A=m.useRef(null),R=m.useRef(null),_=m.useRef(null),[P,$]=m.useState(!1),[H,I]=m.useState(!1),U=m.useRef(0);m.useEffect(()=>{const K=N.current;if(!K)return;const ee=G=>{G.key===" "&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&G.stopPropagation()};return K.addEventListener("keydown",ee),()=>K.removeEventListener("keydown",ee)},[]);const D=`${k}/api/relay/upload`,V=m.useCallback(async K=>{try{const ee=await o9(K),G=await fetch(D,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K.name,data:ee})}),{path:re}=await G.json();return re||null}catch(ee){return console.error("File upload failed:",ee),null}},[D]);m.useEffect(()=>{const K=N.current;if(!K)return;const ee=async G=>{if(!G.clipboardData)return;const re=Array.from(G.clipboardData.items).filter(Q=>Q.type.startsWith("image/"));if(re.length!==0){G.preventDefault(),G.stopPropagation();for(const Q of re){const ae=Q.getAsFile();if(!ae)continue;const be=await V(ae);be&&y(be)}}};return K.addEventListener("paste",ee),()=>K.removeEventListener("paste",ee)},[y,V]);const Z=m.useCallback(K=>{K.preventDefault(),K.dataTransfer.dropEffect="copy"},[]),O=m.useCallback(K=>{K.preventDefault(),U.current++,K.dataTransfer.types.includes("Files")&&I(!0)},[]),z=m.useCallback(K=>{K.preventDefault(),U.current--,U.current===0&&I(!1)},[]),B=m.useCallback(async K=>{K.preventDefault(),U.current=0,I(!1);const ee=Array.from(K.dataTransfer.files).filter(G=>G.type.startsWith("image/"));if(ee.length!==0)for(const G of ee){const re=await V(G);re&&y(re)}},[y,V]);m.useEffect(()=>{let K=!1,ee=null;async function G(){const[{Terminal:re},{FitAddon:Q},ae]=await Promise.all([Cy(()=>import("./xterm-fBtFsYpq.js").then($e=>$e.x),[]),Cy(()=>import("./addon-fit-DtSNdpy5.js").then($e=>$e.a),[]),Cy(()=>import("./addon-webgl-YYNKPQUg.js").then($e=>$e.a),[]).catch(()=>null)]);if(i9(),K||!A.current)return;ee=new re({fontSize:t,fontFamily:n,theme:a9,cursorBlink:!0,cursorStyle:"bar",allowTransparency:!0,scrollback:5e3,convertEol:!1,allowProposedApi:!0});const be=new Q;if(ee.loadAddon(be),ee.open(A.current),ae)try{const $e=new ae.WebglAddon;$e.onContextLoss(()=>{$e.dispose()}),ee.loadAddon($e)}catch{}try{be.fit()}catch{}R.current=ee,_.current=be,x(ee.cols,ee.rows),ee.onData($e=>{y($e)}),$(!0)}return G(),()=>{K=!0,ee&&(ee.dispose(),R.current=null,_.current=null)}},[]),m.useEffect(()=>{const K=R.current;if(K){K.options.fontSize=t,K.options.fontFamily=n;try{_.current?.fit()}catch{}}},[t,n]),m.useEffect(()=>{if(P)return w(K=>{R.current?.write(K)}),()=>{w(null)}},[P,w]),m.useEffect(()=>{const K=A.current;if(!K||!P)return;const ee=new ResizeObserver(()=>{const G=_.current,re=R.current;if(!(!G||!re))try{G.fit(),x(re.cols,re.rows)}catch{}});return ee.observe(K),()=>ee.disconnect()},[P,x]),m.useEffect(()=>{u==="connected"&&R.current&&R.current.focus()},[u]);const X=m.useCallback(()=>{u==="connected"&&R.current&&R.current.focus()},[u]),W=u==="error"&&h==="Relay service is not running",L=m.useCallback(async()=>{if(o){S(!0);try{await o()&&setTimeout(()=>C(),500)}finally{S(!1)}}},[o,C]);let q=null;return W?q=s.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/10 border border-amber-500/20 flex items-center justify-center",children:s.jsx("span",{className:"text-amber-400 text-[14px]",children:"!"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[12px] text-neutral-300 font-medium mb-1",children:"Relay service not running"}),s.jsx("div",{className:"text-[11px] text-neutral-500 leading-relaxed",children:o?"Start the relay service to open a terminal session.":"Start the relay service from the Workspace Manager."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[o&&s.jsx("button",{type:"button",onClick:L,disabled:E,className:"text-[11px] px-4 py-1.5 rounded-full border border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10 transition-colors font-medium disabled:opacity-50",children:E?"Starting...":"Start Service"}),s.jsx("button",{type:"button",onClick:()=>C(),className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Retry"}),r&&s.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Settings"})]})]}):u==="error"&&h?q=s.jsxs("div",{className:"flex flex-col items-center gap-3 max-w-md text-center px-4",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/10 flex items-center justify-center",children:s.jsx("span",{className:"text-red-400 text-sm",children:"!"})}),s.jsx("span",{className:"text-red-400 text-[12px] font-medium",children:"Session failed"}),s.jsx("code",{className:"text-[11px] text-neutral-400 bg-neutral-800/80 px-3 py-2 rounded-md whitespace-pre-wrap leading-relaxed max-h-32 overflow-y-auto w-full text-left",children:h}),f!==null&&f!==0&&s.jsxs("span",{className:"text-[10px] text-neutral-600",children:["Exit code ",f]}),s.jsx("button",{type:"button",onClick:()=>C(),className:"text-[11px] px-3 py-1 rounded-full border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 transition-colors",children:"Retry"})]}):u==="disconnected"&&!c?q=s.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-neutral-800 border border-neutral-700 flex items-center justify-center",children:s.jsx("span",{className:"text-neutral-500 text-[14px]",children:"▷"})}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[12px] text-neutral-300 font-medium mb-1",children:"Terminal relay disconnected"}),s.jsx("div",{className:"text-[11px] text-neutral-500 leading-relaxed",children:"Set working directory and connect."})]}),s.jsxs("form",{className:"w-full",onSubmit:K=>{K.preventDefault(),C()},children:[s.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-wider mb-1 block text-left",children:"Working Directory"}),s.jsx("input",{type:"text",value:g,onChange:K=>v(K.target.value),placeholder:"~/dev/my-project",className:"w-full bg-neutral-800/80 border border-neutral-700/50 rounded px-3 py-1.5 text-[11px] font-mono text-neutral-200 placeholder:text-neutral-600 outline-none focus:border-cyan-500/40 transition-colors",spellCheck:!1,autoComplete:"off"})]}),a&&a.length>0&&s.jsx("div",{className:"w-full grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[10px] font-mono bg-neutral-800/60 border border-neutral-700/40 rounded-md px-3 py-2",children:a.map(K=>s.jsxs("div",{className:"contents",children:[s.jsx("span",{className:"text-neutral-500",children:K.label}),s.jsx("span",{className:"text-neutral-400 truncate text-left",children:K.value})]},K.label))}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>C(),className:"text-[11px] px-4 py-1.5 rounded-full border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 transition-colors font-medium",children:"Connect"}),r&&s.jsx("button",{type:"button",onClick:r,className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Settings"})]})]}):u==="connecting"&&!c&&(q=s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsx("div",{className:"w-6 h-6 border-2 border-neutral-600 border-t-cyan-400 rounded-full animate-spin"}),s.jsx("span",{className:"text-[12px] text-neutral-400",children:"Connecting to relay..."}),s.jsx("button",{type:"button",onClick:()=>{T()},className:"text-[10px] px-3 py-1 rounded-full border border-neutral-700 text-neutral-500 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Cancel"})]})),s.jsxs("div",{ref:N,className:"relative flex flex-col h-full overflow-hidden",onClick:X,onDragOver:Z,onDragEnter:O,onDragLeave:z,onDrop:B,children:[q&&s.jsx("div",{className:"flex items-center justify-center h-full font-mono text-[12px] absolute inset-0 z-10 bg-neutral-900/90",children:q}),H&&s.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-cyan-500/10 border-2 border-dashed border-cyan-500/50 rounded pointer-events-none",children:s.jsx("span",{className:"text-cyan-400 font-mono text-sm",children:"Drop image to get path"})}),s.jsx("div",{ref:A,className:"flex-1 min-h-0 min-w-0 overflow-hidden",style:{visibility:q?"hidden":"visible",padding:"4px 8px"}})]})}function l9({app:e,commands:t,state:n,relayUrl:a="ws://localhost:3600",cwd:r,agent:o="pi",provider:c,model:u,backend:h="pty",tmuxSession:f,workspaceFiles:g,onOpenSettings:v,onStartService:y,voiceKit:x}){const[w,C]=Ua(`assistant.${e.id}.mode`,"relay"),[T,E]=m.useState(""),[S,k]=Ua(`assistant.${e.id}.voice.speakReplies`,x?.settings.speakReplies??!1),{serviceApiUrl:N}=Dp(),A=m.useMemo(()=>u9(e),[e]),R=U0({url:a,systemPrompt:A,cwd:r,workspaceFiles:g,sessionKey:`assistant-${e.id}`,backend:h,tmuxSession:f,agent:o,provider:o==="pi"?c:void 0,model:o==="pi"?u:void 0}),_=m.useCallback(async()=>{if(y)return y();try{return(await(await fetch(`${N}/api/services/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:"relay",action:"start",triggeredBy:"assistant"})})).json()).success===!0}catch{return!1}},[y,N]),P=m.useMemo(()=>{const B=[{label:"Relay",value:a},{label:"Agent",value:o}];return r&&B.push({label:"CWD",value:r}),o==="pi"&&u&&B.push({label:"Model",value:u}),B},[a,o,r,u]),[$,H]=m.useState("text"),I=n9({app:e,commands:t,state:n,provider:c,model:u,onFinish:({message:B,isAbort:X,isDisconnect:W,isError:L})=>{!x||!S||X||W||L||B.role==="assistant"&&x.speakReply(B,{surface:"hudson-assistant",appId:e.id,source:$})}}),U=m.useCallback(B=>{if(!x)return;const X=[T.trim(),B].filter(Boolean).join(" ");x.settings.autoSend&&I.status!=="streaming"&&I.status!=="submitted"?(E(""),H("voice"),I.sendMessage({text:X})):E(X)},[x,T,I]),D=m.useCallback(()=>{x&&(x.input.status==="recording"?x.input.stop():x.input.start(U))},[x,U]),V=e.intents?.length??0,Z=!!x,O=x?.input.status==="transcribing",z=x?.input.status==="recording";return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-neutral-700/50 bg-neutral-900/50",children:[s.jsx(Pp,{size:11,className:"text-cyan-400/60"}),s.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-neutral-500",children:"Assistant"}),s.jsxs("span",{className:"text-[10px] font-mono text-neutral-600",children:["· ",e.name]}),s.jsx("div",{className:"flex-1"}),Z&&w==="chat"&&s.jsx("button",{type:"button",onClick:()=>{S&&x?.output.stop(),k(!S)},className:`p-1 rounded transition-colors ${S?"text-cyan-300 hover:text-cyan-200":"text-neutral-500 hover:text-neutral-300"}`,title:S?"Speaker on (click to mute)":"Speaker off (click to enable)",children:x?.output.isPlaying?s.jsx(ea,{size:12,className:"animate-spin"}):S?s.jsx(g2,{size:12}):s.jsx(v2,{size:12})}),s.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-neutral-700 p-0.5",children:[s.jsx(uC,{active:w==="relay",onClick:()=>C("relay"),children:"Relay"}),s.jsx(uC,{active:w==="chat",onClick:()=>C("chat"),children:"Chat"})]}),w==="relay"&&R.status==="connected"&&s.jsx("button",{type:"button",onClick:()=>R.restart(),className:"text-[10px] px-2 py-0.5 rounded-full border text-cyan-400 border-cyan-500/30 hover:bg-cyan-500/10 transition-colors",title:"Kill session and start fresh",children:"Restart"}),w==="relay"&&R.status==="connected"&&s.jsx("button",{type:"button",onClick:()=>R.disconnect(),className:"text-[10px] px-2 py-0.5 rounded-full border text-red-400 border-red-500/30 hover:bg-red-500/10 transition-colors",children:"Disconnect"}),w==="relay"&&R.status!=="connected"&&R.status!=="connecting"&&s.jsx("button",{type:"button",onClick:()=>R.connect(),className:"text-[10px] px-2 py-0.5 rounded-full border text-emerald-400 border-emerald-500/30 hover:bg-emerald-500/10 transition-colors",children:"Connect"})]}),s.jsx("div",{className:"flex-1 min-h-0",children:w==="relay"?s.jsx(F0,{relay:R,configItems:P,onOpenSettings:v,onStartService:_}):s.jsx(s9,{chat:I,placeholder:V===0?`Ask about ${e.name} — no intents declared, conversation only.`:`Ask ${e.name} to do something… (${V} intent${V===1?"":"s"})`,inputValue:T,onInputChange:B=>{$==="voice"&&B.length===0&&H("text"),E(B)},inputExtras:Z&&x?.input.isSupported?s.jsx("button",{type:"button",onClick:D,disabled:O,className:`p-1 rounded transition-colors disabled:opacity-30 ${z?"bg-red-500/15 text-red-300 hover:bg-red-500/20":"text-neutral-500 hover:text-cyan-400"}`,title:z?"Stop recording":"Record voice prompt",children:O?s.jsx(ea,{size:12,className:"animate-spin"}):z?s.jsx(Bd,{size:11}):s.jsx(M0,{size:12})}):void 0,inputStatus:Z&&x?s.jsx(c9,{inputStatus:x.input.status,inputError:x.input.error,outputStatus:x.output.status,outputError:x.output.error}):void 0})})]})}function c9({inputStatus:e,inputError:t,outputStatus:n,outputError:a}){const r=cC(e)??cC(n),o=t??a;return!r&&!o?null:s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border font-mono ${r.className}`,children:r.label}),o&&s.jsx("span",{className:"text-[10px] text-neutral-500 truncate flex-1",title:o,children:o})]})}function cC(e){switch(e){case"recording":return{label:"listening",className:"border-red-500/20 bg-red-500/10 text-red-300"};case"transcribing":return{label:"transcribing",className:"border-amber-500/20 bg-amber-500/10 text-amber-300"};case"ready":return{label:"draft ready",className:"border-cyan-500/20 bg-cyan-500/10 text-cyan-300"};case"synthesizing":return{label:"voicing",className:"border-cyan-500/20 bg-cyan-500/10 text-cyan-300"};case"speaking":return{label:"speaking",className:"border-emerald-500/20 bg-emerald-500/10 text-emerald-300"};case"unavailable":return{label:"voice offline",className:"border-amber-500/20 bg-amber-500/10 text-amber-300"};case"error":return{label:"voice error",className:"border-red-500/20 bg-red-500/10 text-red-300"};default:return null}}function uC({active:e,onClick:t,children:n}){return s.jsx("button",{type:"button",onClick:t,className:`text-[10px] px-2 py-0.5 rounded-full transition-colors ${e?"bg-cyan-500/15 text-cyan-300":"text-neutral-500 hover:text-neutral-300"}`,children:n})}function u9(e){const t=[`You are working alongside the user inside the **${e.name}** Hudson app.`];e.description&&t.push(e.description);const n=e.intents??[];if(n.length>0){t.push("","## What this app can do (for context)");for(const a of n)t.push(`- ${a.title} — ${a.description}`);t.push("","These actions live inside the running app. You can describe them to the user, but you do not invoke them yourself — the user can trigger any of them via the command palette (Cmd+K).")}return t.push("","## How to behave","- Be terse. The user is in a terminal; respect their attention.","- Use your own tools (file ops, shell, etc.) freely if it helps.","- When asked to change something inside the app itself, prefer guiding the user to the matching command rather than hacking around it."),t.join(`
110
+ `)}var Ll=4e3,d9=Ql.forwardRef(({pan:e,zoom:t,viewportSize:n,height:a,onClick:r,children:o},c)=>{const[u,h]=Ql.useState(0),f=m.useRef(null),g=Ql.useCallback(S=>{f.current=S,typeof c=="function"?c(S):c&&(c.current=S)},[c]);Ql.useEffect(()=>{const S=f.current;if(!S)return;const k=new ResizeObserver(([N])=>h(N.contentRect.width));return k.observe(S),()=>k.disconnect()},[]);const v=u||260,y=n.width/t/Ll*v,x=n.height/t/Ll*a,w=(-e.x+Ll/2)/Ll*v,C=(-e.y+Ll/2)/Ll*a,T=w-y/2,E=C-x/2;return s.jsxs("div",{ref:g,className:"relative cursor-crosshair overflow-hidden",style:{height:`${a}px`},onClick:r,children:[s.jsx("div",{className:"absolute inset-0 opacity-30",style:{backgroundImage:"radial-gradient(circle, #555 1px, transparent 1px)",backgroundSize:"14px 14px"}}),s.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-neutral-600/40"}),s.jsx("div",{className:"absolute left-1/2 top-0 bottom-0 w-px bg-neutral-600/40"}),s.jsxs("div",{className:"absolute border border-emerald-500/50 bg-emerald-500/5 transition-all duration-75 ease-out",style:{left:`${T}px`,top:`${E}px`,width:`${Math.max(y,4)}px`,height:`${Math.max(x,4)}px`},children:[s.jsx("div",{className:"absolute -top-[1px] -left-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),s.jsx("div",{className:"absolute -top-[1px] -right-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),s.jsx("div",{className:"absolute -bottom-[1px] -left-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),s.jsx("div",{className:"absolute -bottom-[1px] -right-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"})]}),o]})});d9.displayName="MinimapCanvas";var Vp={panels:{statusBar:"bg-neutral-950/95 backdrop-blur-xl border-t border-neutral-700 shadow-[0_-5px_30px_rgba(0,0,0,0.6),inset_0_1px_0_rgba(255,255,255,0.06)] fixed bottom-0 left-0 right-0 z-[60]"},zIndex:{drawer:70},layout:{navHeight:48,statusBarHeight:28}},f9=Vp.panels,h9=({panOffset:e,scale:t,onPan:n,onPanStart:a,onPanEnd:r,isPanLocked:o=!1,onClick:c,showGuides:u=!1,onGuidesChange:h,gridOpacity:f=1})=>{const[g,v]=m.useState(u),[y,x]=m.useState(!1),w=m.useRef(!1),C=m.useRef({x:0,y:0}),T=m.useRef({active:!1,startX:0,startY:0}),E=m.useRef(null),S=m.useRef(null),k=m.useRef(null),N=4,A=m.useRef({x:0,y:0}),R=m.useRef(0),_=m.useRef(!1);m.useEffect(()=>{v(u)},[u]);const P=m.useCallback(W=>{const L=W;return L?L.tagName==="INPUT"||L.tagName==="TEXTAREA"||L.isContentEditable:!1},[]),$=m.useCallback(W=>{const L=W;return L?!!L.closest('button, [role="button"], a, input, textarea, select, [data-interactive="true"]'):!1},[]),H=m.useCallback(W=>{w.current=W,x(W)},[]);m.useEffect(()=>{const W=ee=>{if(R.current=ee.buttons,T.current.active&&(ee.buttons&1)!==1&&(T.current.active=!1),w.current&&(ee.buttons&1)!==1){H(!1),T.current.active=!1,r?.(),document.body.style.cursor="";return}if(o&&w.current){H(!1),T.current.active=!1,r?.(),document.body.style.cursor="";return}const G=E.current?.getBoundingClientRect(),re=G?ee.clientX-G.left:ee.clientX,Q=G?ee.clientY-G.top:ee.clientY;if(A.current={x:re,y:Q},S.current&&(S.current.style.left=`${re}px`),k.current&&(k.current.style.top=`${Q}px`),T.current.active&&!w.current){const ae=ee.clientX-T.current.startX,be=ee.clientY-T.current.startY;Math.hypot(ae,be)>=N&&(T.current.active=!1,H(!0),_.current=!0,a?.(),C.current={x:ee.clientX,y:ee.clientY},document.body.style.cursor="grabbing")}w.current&&(n({x:(ee.clientX-C.current.x)/t,y:(ee.clientY-C.current.y)/t}),C.current={x:ee.clientX,y:ee.clientY})},L=ee=>{R.current=ee.buttons,T.current.active=!1,w.current&&(H(!1),r?.(),document.body.style.cursor="")},q=ee=>{(ee.metaKey||ee.ctrlKey)&&ee.key==="\\"&&(ee.preventDefault(),v(G=>{const re=!G;return h?.(re),re}))},K=()=>{T.current.active=!1,L(new MouseEvent("mouseup"))};return window.addEventListener("mousemove",W),window.addEventListener("mouseup",L),window.addEventListener("keydown",q),window.addEventListener("blur",K),document.addEventListener("visibilitychange",K),()=>{window.removeEventListener("mousemove",W),window.removeEventListener("mouseup",L),window.removeEventListener("keydown",q),window.removeEventListener("blur",K),document.removeEventListener("visibilitychange",K)}},[n,r,a,t,P,$,o,H,h]),m.useEffect(()=>{!o||!w.current||(H(!1),r?.(),document.body.style.cursor="")},[o,r,H]);const I=W=>{_.current=!1,!(o||W.button!==0)&&(P(W.target)||$(W.target)||(R.current=W.buttons,T.current={active:!0,startX:W.clientX,startY:W.clientY},W.preventDefault()))},U=W=>{!_.current&&c&&c(W),_.current=!1},[D,V]=m.useState({w:0,h:0});m.useEffect(()=>{const W=()=>V({w:window.innerWidth,h:window.innerHeight});return W(),window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[]);const Z=Math.max(.4,Math.min(2,t)),O=100*Z,z=20*Z,B=(D.w/2+e.x*t)%O,X=(D.h/2+e.y*t)%O;return s.jsxs("div",{ref:E,className:`absolute inset-0 z-0 overflow-hidden bg-black ${y?"cursor-grabbing":"cursor-grab"}`,onMouseDown:I,onClick:U,children:[s.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.5*f,transition:"opacity 1s ease",backgroundImage:"radial-gradient(circle, #444 1px, transparent 1px)",backgroundSize:`${z}px ${z}px`,backgroundPosition:`${B+100}px ${X+100}px`}}),s.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.25*f,transition:"opacity 1s ease",backgroundImage:"radial-gradient(circle, #555 1px, transparent 1px)",backgroundSize:`${O}px ${O}px`,backgroundPosition:`${B+100}px ${X+100}px`}}),g&&s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:S,className:"absolute top-0 bottom-0 w-px pointer-events-none bg-emerald-500/10",style:{left:0}}),s.jsx("div",{ref:k,className:"absolute left-0 right-0 h-px pointer-events-none bg-emerald-500/10",style:{top:0}})]})]})},YR=h9;const m9={...e2};let dC=0;function p9(e,t="mui"){const[n,a]=m.useState(e),r=e||n;return m.useEffect(()=>{n==null&&(dC+=1,a(`${t}-${dC}`))},[n,t]),r}const fC=m9.useId;function Gi(e,t){if(fC!==void 0){const n=fC();return e??(t?`${t}-${n}`:n)}return p9(e,t)}function Xo(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(a=>n.searchParams.append("args[]",a)),`Base UI error #${e}; visit ${n} for the full message.`}const XR=m.createContext(void 0);function Hp(e=!0){const t=m.useContext(XR);if(t===void 0&&!e)throw new Error(Xo(25));return t}const QR=m.createContext(void 0);function JR(e){const t=m.useContext(QR);if(t===void 0&&!e)throw new Error(Xo(33));return t}const V0=m.createContext(void 0);function Ic(e){const t=m.useContext(V0);if(t===void 0&&!e)throw new Error(Xo(36));return t}const hC={};function Aa(e,t){const n=m.useRef(hC);return n.current===hC&&(n.current=e(t)),n}function Cd(e,t,n,a){const r=Aa(eI).current;return v9(r,e,t,n,a)&&tI(r,[e,t,n,a]),r.callback}function g9(e){const t=Aa(eI).current;return y9(t,e)&&tI(t,e),t.callback}function eI(){return{callback:null,cleanup:null,refs:[]}}function v9(e,t,n,a,r){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==r}function y9(e,t){return e.refs.length!==t.length||e.refs.some((n,a)=>n!==t[a])}function tI(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const a=Array(t.length).fill(null);for(let r=0;r<t.length;r+=1){const o=t[r];if(o!=null)switch(typeof o){case"function":{const c=o(n);typeof c=="function"&&(a[r]=c);break}case"object":{o.current=n;break}}}e.cleanup=()=>{for(let r=0;r<t.length;r+=1){const o=t[r];if(o!=null)switch(typeof o){case"function":{const c=a[r];typeof c=="function"?c():o(null);break}case"object":{o.current=null;break}}}}}}}const x9=parseInt(m.version,10);function H0(e){return x9>=e}function mC(e){if(!m.isValidElement(e))return null;const t=e,n=t.props;return(H0(19)?n?.ref:t.ref)??null}function eb(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function b9(e,t){const n={};for(const a in e){const r=e[a];if(t?.hasOwnProperty(a)){const o=t[a](r);o!=null&&Object.assign(n,o);continue}r===!0?n[`data-${a.toLowerCase()}`]="":r&&(n[`data-${a.toLowerCase()}`]=r.toString())}return n}function w9(e,t){return typeof e=="function"?e(t):e}function j9(e,t){return typeof e=="function"?e(t):e}const nd={};function qp(e,t,n,a,r){let o={...tb(e,nd)};return t&&(o=um(o,t)),n&&(o=um(o,n)),a&&(o=um(o,a)),o}function N9(e){if(e.length===0)return nd;if(e.length===1)return tb(e[0],nd);let t={...tb(e[0],nd)};for(let n=1;n<e.length;n+=1)t=um(t,e[n]);return t}function um(e,t){return nI(t)?t(e):k9(e,t)}function k9(e,t){if(!t)return e;for(const n in t){const a=t[n];switch(n){case"style":{e[n]=eb(e.style,a);break}case"className":{e[n]=sI(e.className,a);break}default:S9(n,a)?e[n]=C9(e[n],a):e[n]=a}}return e}function S9(e,t){const n=e.charCodeAt(0),a=e.charCodeAt(1),r=e.charCodeAt(2);return n===111&&a===110&&r>=65&&r<=90&&(typeof t=="function"||typeof t>"u")}function nI(e){return typeof e=="function"}function tb(e,t){return nI(e)?e(t):e??nd}function C9(e,t){return t?e?n=>{if(E9(n)){const r=n;nb(r);const o=t(r);return r.baseUIHandlerPrevented||e?.(r),o}const a=t(n);return e?.(n),a}:t:e}function nb(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function sI(e,t){return t?e?t+" "+e:t:e}function E9(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function aI(){}const rI=Object.freeze([]),Bs=Object.freeze({}),A9=500,T9={style:{transition:"none"}},M9="data-base-ui-click-trigger",R9={fallbackAxisSide:"none"},I9={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function Zi(e,t,n={}){const a=t.render,r=_9(t,n);if(n.enabled===!1)return null;const o=n.state??Bs;return O9(e,a,r,o)}function _9(e,t={}){const{className:n,style:a,render:r}=e,{state:o=Bs,ref:c,props:u,stateAttributesMapping:h,enabled:f=!0}=t,g=f?w9(n,o):void 0,v=f?j9(a,o):void 0,y=f?b9(o,h):Bs,x=f?eb(y,Array.isArray(u)?N9(u):u)??Bs:Bs;return typeof document<"u"&&(f?Array.isArray(c)?x.ref=g9([x.ref,mC(r),...c]):x.ref=Cd(x.ref,mC(r),c):Cd(null,null)),f?(g!==void 0&&(x.className=sI(x.className,g)),v!==void 0&&(x.style=eb(x.style,v)),x):Bs}function O9(e,t,n,a){if(t){if(typeof t=="function")return t(n,a);const r=qp(n,t.props);return r.ref=n.ref,m.cloneElement(t,r)}return $9(e,n)}function $9(e,t){return m.createElement(e,t)}let Wm=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const P9={[Wm.startingStyle]:""},D9={[Wm.endingStyle]:""},L9={transitionStatus(e){return e==="starting"?P9:e==="ending"?D9:null}};let q0=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Wm.startingStyle]="startingStyle",e[e.endingStyle=Wm.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),pC=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const z9={[pC.popupOpen]:"",[pC.pressed]:""},B9={[q0.open]:""},U9={[q0.closed]:""},F9={[q0.anchorHidden]:""},V9={open(e){return e?z9:null}},iI={open(e){return e?B9:U9},anchorHidden(e){return e?F9:null}},H9="none",Gm="trigger-press",Do="trigger-hover",gC="trigger-focus",W0="outside-press",oI="item-press",Wp="focus-out",lI="escape-key",dm="list-navigation",q9="cancel-open",Ku="sibling-open",W9="imperative-action",$y=e2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],G9=$y&&$y!==m.useLayoutEffect?$y:e=>e();function pt(e){const t=Aa(Z9).current;return t.next=e,G9(t.effect),t.trampoline}function Z9(){const e={next:void 0,callback:K9,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function K9(){}function Gp(){return typeof window<"u"}function Ki(e){return G0(e)?(e.nodeName||"").toLowerCase():"#document"}function us(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wr(e){var t;return(t=(G0(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function G0(e){return Gp()?e instanceof Node||e instanceof us(e).Node:!1}function yn(e){return Gp()?e instanceof Element||e instanceof us(e).Element:!1}function qn(e){return Gp()?e instanceof HTMLElement||e instanceof us(e).HTMLElement:!1}function sb(e){return!Gp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof us(e).ShadowRoot}function Qo(e){const{overflow:t,overflowX:n,overflowY:a,display:r}=ra(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+n)&&r!=="inline"&&r!=="contents"}function Y9(e){return/^(table|td|th)$/.test(Ki(e))}function Zp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const X9=/transform|translate|scale|rotate|perspective|filter/,Q9=/paint|layout|strict|content/,bo=e=>!!e&&e!=="none";let Py;function Z0(e){const t=yn(e)?ra(e):e;return bo(t.transform)||bo(t.translate)||bo(t.scale)||bo(t.rotate)||bo(t.perspective)||!Kp()&&(bo(t.backdropFilter)||bo(t.filter))||X9.test(t.willChange||"")||Q9.test(t.contain||"")}function J9(e){let t=vr(e);for(;qn(t)&&!fr(t);){if(Z0(t))return t;if(Zp(t))return null;t=vr(t)}return null}function Kp(){return Py==null&&(Py=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Py}function fr(e){return/^(html|body|#document)$/.test(Ki(e))}function ra(e){return us(e).getComputedStyle(e)}function Yp(e){return yn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vr(e){if(Ki(e)==="html")return e;const t=e.assignedSlot||e.parentNode||sb(e)&&e.host||wr(e);return sb(t)?t.host:t}function cI(e){const t=vr(e);return fr(t)?e.ownerDocument?e.ownerDocument.body:e.body:qn(t)&&Qo(t)?t:cI(t)}function $i(e,t,n){var a;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=cI(e),o=r===((a=e.ownerDocument)==null?void 0:a.body),c=us(r);if(o){const u=ab(c);return t.concat(c,c.visualViewport||[],Qo(r)?r:[],u&&n?$i(u):[])}else return t.concat(r,$i(r,[],n))}function ab(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const eH=()=>{},ft=typeof document<"u"?m.useLayoutEffect:eH,tH=m.createContext(void 0);function nH(e=!1){const t=m.useContext(tH);if(t===void 0&&!e)throw new Error(Xo(16));return t}function sH(e){const{focusableWhenDisabled:t,disabled:n,composite:a=!1,tabIndex:r=0,isNativeButton:o}=e,c=a&&t!==!1,u=a&&t===!1;return{props:m.useMemo(()=>{const f={onKeyDown(g){n&&t&&g.key!=="Tab"&&g.preventDefault()}};return a||(f.tabIndex=r,!o&&n&&(f.tabIndex=t?r:-1)),(o&&(t||c)||!o&&n)&&(f["aria-disabled"]=n),o&&(!t||u)&&(f.disabled=n),f},[a,n,t,c,u,o,r])}}function aH(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:a=0,native:r=!0}=e,o=m.useRef(null),c=nH(!0)!==void 0,u=pt(()=>{const y=o.current;return!!(y?.tagName==="A"&&y?.href)}),{props:h}=sH({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:a,isNativeButton:r}),f=m.useCallback(()=>{const y=o.current;rH(y)&&c&&t&&h.disabled===void 0&&y.disabled&&(y.disabled=!1)},[t,h.disabled,c]);ft(f,[f]);const g=m.useCallback((y={})=>{const{onClick:x,onMouseDown:w,onKeyUp:C,onKeyDown:T,onPointerDown:E,...S}=y;return qp({type:r?"button":void 0,onClick(N){if(t){N.preventDefault();return}x?.(N)},onMouseDown(N){t||w?.(N)},onKeyDown(N){if(t||(nb(N),T?.(N)),N.baseUIHandlerPrevented)return;const A=N.target===N.currentTarget&&!r&&!u()&&!t,R=N.key==="Enter",_=N.key===" ";A&&((_||R)&&N.preventDefault(),R&&x?.(N))},onKeyUp(N){t||(nb(N),C?.(N)),!N.baseUIHandlerPrevented&&N.target===N.currentTarget&&!r&&!t&&N.key===" "&&x?.(N)},onPointerDown(N){if(t){N.preventDefault();return}E?.(N)}},r?void 0:{role:"button"},h,S)},[t,h,r,u]),v=pt(y=>{o.current=y,f()});return{getButtonProps:g,buttonRef:v}}function rH(e){return qn(e)&&e.tagName==="BUTTON"}const iH={type:"regular-item"};function oH(e){const{closeOnClick:t,disabled:n=!1,highlighted:a,id:r,store:o,nativeButton:c,itemMetadata:u,nodeId:h}=e,f=m.useRef(null),g=Hp(!0),v=g!==void 0,{events:y}=o.useState("floatingTreeRoot"),{getButtonProps:x,buttonRef:w}=aH({disabled:n,focusableWhenDisabled:!0,native:c}),C=m.useCallback(E=>qp({id:r,role:"menuitem",tabIndex:a?0:-1,onMouseMove(S){h&&y.emit("itemhover",{nodeId:h,target:S.currentTarget})},onMouseEnter(){u.type==="submenu-trigger"&&u.setActive()},onKeyUp(S){S.key===" "&&o.context.typingRef.current&&S.preventBaseUIHandler()},onClick(S){t&&y.emit("close",{domEvent:S,reason:oI})},onMouseUp(S){if(g){const k=g.initialCursorPointRef.current;if(g.initialCursorPointRef.current=null,v&&k&&Math.abs(S.clientX-k.x)<=1&&Math.abs(S.clientY-k.y)<=1)return}f.current&&o.context.allowMouseUpTriggerRef.current&&(!v||S.button===2)&&u.type==="regular-item"&&f.current.click()}},E,x),[r,a,x,t,y,o,v,g,u,h]),T=Cd(f,w);return m.useMemo(()=>({getItemProps:C,itemRef:T}),[C,T])}const uI=m.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function lH(){return m.useContext(uI)}let cH=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function uH(e={}){const{label:t,metadata:n,textRef:a,indexGuessBehavior:r,index:o}=e,{register:c,unregister:u,subscribeMapChange:h,elementsRef:f,labelsRef:g,nextIndexRef:v}=lH(),y=m.useRef(-1),[x,w]=m.useState(o??(r===cH.GuessFromOrder?()=>{if(y.current===-1){const E=v.current;v.current+=1,y.current=E}return y.current}:-1)),C=m.useRef(null),T=m.useCallback(E=>{if(C.current=E,x!==-1&&E!==null&&(f.current[x]=E,g)){const S=t!==void 0;g.current[x]=S?t:a?.current?.textContent??E.textContent}},[x,f,g,t,a]);return ft(()=>{if(o!=null)return;const E=C.current;if(E)return c(E,n),()=>{u(E)}},[o,c,u,n]),ft(()=>{if(o==null)return h(E=>{const S=C.current?E.get(C.current)?.index:null;S!=null&&w(S)})},[o,h,w]),m.useMemo(()=>({ref:T,index:x}),[x,T])}function dI(e){return Gi(e,"base-ui")}function Wn(e,t,n,a){let r=!1,o=!1;const c=Bs;return{reason:e,event:t??new Event("base-ui"),cancel(){r=!0},allowPropagation(){o=!0},get isCanceled(){return r},get isPropagationAllowed(){return o},trigger:n,...c}}var yr=t2();const dH=[];function fI(e){m.useEffect(e,dH)}const yh=null;class fH{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,a=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,a>0)for(let r=0;r<n.length;r+=1)n[r]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const xh=new fH;class cr{static create(){return new cr}static request(t){return xh.request(t)}static cancel(t){return xh.cancel(t)}currentId=yh;request(t){this.cancel(),this.currentId=xh.request(()=>{this.currentId=yh,t()})}cancel=()=>{this.currentId!==yh&&(xh.cancel(this.currentId),this.currentId=yh)};disposeEffect=()=>this.cancel}function K0(){const e=Aa(cr.create).current;return fI(e.disposeEffect),e}function hH(e,t=!1,n=!1){const[a,r]=m.useState(e&&t?"idle":void 0),[o,c]=m.useState(e);return e&&!o&&(c(!0),r("starting")),!e&&o&&a!=="ending"&&!n&&r("ending"),!e&&!o&&a==="ending"&&r(void 0),ft(()=>{if(!e&&o&&a!=="ending"&&n){const u=cr.request(()=>{r("ending")});return()=>{cr.cancel(u)}}},[e,o,a,n]),ft(()=>{if(!e||t)return;const u=cr.request(()=>{yr.flushSync(()=>{r(void 0)})});return()=>{cr.cancel(u)}},[t,e]),ft(()=>{if(!e||!t)return;e&&o&&a!=="idle"&&r("starting");const u=cr.request(()=>{r("idle")});return()=>{cr.cancel(u)}},[t,e,o,r,a]),m.useMemo(()=>({mounted:o,setMounted:c,transitionStatus:a}),[o,a])}function Ls(e){const t=Aa(mH,e).current;return t.next=e,ft(t.effect),t}function mH(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Ao(e){return e==null?e:"current"in e?e.current:e}function pH(e,t=!1,n=!0){const a=K0();return pt((r,o=null)=>{a.cancel();const c=Ao(e);c!=null&&(typeof c.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED?r():a.request(()=>{function u(){c&&Promise.all(c.getAnimations().map(h=>h.finished)).then(()=>{o!=null&&o.aborted||yr.flushSync(r)}).catch(()=>{if(n){if(o!=null&&o.aborted)return;yr.flushSync(r)}else c.getAnimations().length>0&&c.getAnimations().some(h=>h.pending||h.playState!=="finished")&&u()})}t?a.request(u):u()}))})}function hI(e){const{enabled:t=!0,open:n,ref:a,onComplete:r}=e,o=Ls(n),c=pt(r),u=pH(a,n);m.useEffect(()=>{t&&u(()=>{n===o.current&&c()})},[t,n,c,u,o])}const mI=m.createContext(void 0);function gH(){const e=m.useContext(mI);if(e===void 0)throw new Error(Xo(31));return e}const vH=m.forwardRef(function(t,n){const{render:a,className:r,...o}=t,[c,u]=m.useState(void 0),h=m.useMemo(()=>({setLabelId:u}),[u]),f=Zi("div",t,{ref:n,props:{role:"group","aria-labelledby":c,...o}});return s.jsx(mI.Provider,{value:h,children:f})}),yH=m.forwardRef(function(t,n){const{className:a,render:r,id:o,...c}=t,u=dI(o),{setLabelId:h}=gH();return ft(()=>(h(u),()=>{h(void 0)}),[h,u]),Zi("div",t,{ref:n,props:{id:u,role:"presentation",...c}})}),xH=m.forwardRef(function(t,n){const{render:a,className:r,id:o,label:c,nativeButton:u=!1,disabled:h=!1,closeOnClick:f=!0,...g}=t,v=uH({label:c}),y=JR(!0),x=dI(o),{store:w}=Ic(),C=w.useState("isActive",v.index),T=w.useState("itemProps"),{getItemProps:E,itemRef:S}=oH({closeOnClick:f,disabled:h,highlighted:C,id:x,store:w,nativeButton:u,nodeId:y?.nodeId,itemMetadata:iH}),k=m.useMemo(()=>({disabled:h,highlighted:C}),[h,C]);return Zi("div",t,{state:k,props:[T,g,E],ref:[S,n,v.ref]})}),Ru=0;class bc{static create(){return new bc}currentId=Ru;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ru,n()},t)}isStarted(){return this.currentId!==Ru}clear=()=>{this.currentId!==Ru&&(clearTimeout(this.currentId),this.currentId=Ru)};disposeEffect=()=>this.clear}function Za(){const e=Aa(bc.create).current;return fI(e.disposeEffect),e}const _c=typeof navigator<"u",Dy=kH(),pI=CH(),gI=SH(),bH=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),wH=Dy.platform==="MacIntel"&&Dy.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Dy.platform),jH=_c&&/apple/i.test(navigator.vendor),rb=_c&&/android/i.test(pI)||/android/i.test(gI);_c&&pI.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const NH=gI.includes("jsdom/");function kH(){if(!_c)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function SH(){if(!_c)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function CH(){if(!_c)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const ib="data-base-ui-focusable",vI="active",yI="selected",xI="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Pi="ArrowLeft",Di="ArrowRight",Y0="ArrowUp",Vd="ArrowDown";function Mi(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function vn(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&sb(n)){let a=t;for(;a;){if(e===a)return!0;a=a.parentNode||a.host}}return!1}function zs(e){return"composedPath"in e?e.composedPath()[0]:e.target}function La(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function EH(e){return e.matches("html,body")}function os(e){return e?.ownerDocument||document}function AH(e){return qn(e)&&e.matches(xI)}function ob(e){return e?e.getAttribute("role")==="combobox"&&AH(e):!1}function Zm(e){return e?e.hasAttribute(ib)?e:e.querySelector(`[${ib}]`)||e:null}function oc(e,t,n=!0){return e.filter(r=>r.parentId===t&&(!n||r.context?.open)).flatMap(r=>[r,...oc(e,r.id,n)])}function vC(e,t){let n=[],a=e.find(r=>r.id===t)?.parentId;for(;a;){const r=e.find(o=>o.id===a);a=r?.parentId,r&&(n=n.concat(r))}return n}function ls(e){e.preventDefault(),e.stopPropagation()}function TH(e){return"nativeEvent"in e}function bI(e){return e.mozInputSource===0&&e.isTrusted?!0:rb&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function wI(e){return NH?!1:!rb&&e.width===0&&e.height===0||rb&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function MH(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function RH(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const IH=["top","right","bottom","left"],wc=Math.min,Qs=Math.max,Km=Math.round,tc=Math.floor,hr=e=>({x:e,y:e}),_H={left:"right",right:"left",bottom:"top",top:"bottom"};function lb(e,t,n){return Qs(e,wc(t,n))}function Zr(e,t){return typeof e=="function"?e(t):e}function ta(e){return e.split("-")[0]}function Yi(e){return e.split("-")[1]}function X0(e){return e==="x"?"y":"x"}function Q0(e){return e==="y"?"height":"width"}function ka(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function J0(e){return X0(ka(e))}function OH(e,t,n){n===void 0&&(n=!1);const a=Yi(e),r=J0(e),o=Q0(r);let c=r==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(c=Ym(c)),[c,Ym(c)]}function $H(e){const t=Ym(e);return[cb(e),t,cb(t)]}function cb(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const yC=["left","right"],xC=["right","left"],PH=["top","bottom"],DH=["bottom","top"];function LH(e,t,n){switch(e){case"top":case"bottom":return n?t?xC:yC:t?yC:xC;case"left":case"right":return t?PH:DH;default:return[]}}function zH(e,t,n,a){const r=Yi(e);let o=LH(ta(e),n==="start",a);return r&&(o=o.map(c=>c+"-"+r),t&&(o=o.concat(o.map(cb)))),o}function Ym(e){const t=ta(e);return _H[t]+e.slice(t.length)}function BH(e){return{top:0,right:0,bottom:0,left:0,...e}}function jI(e){return typeof e!="number"?BH(e):{top:e,right:e,bottom:e,left:e}}function Xm(e){const{x:t,y:n,width:a,height:r}=e;return{width:a,height:r,top:n,left:t,right:t+a,bottom:n+r,x:t,y:n}}function bh(e,t,n){return Math.floor(e/t)!==n}function sd(e,t){return t<0||t>=e.current.length}function Ly(e,t){return ms(e,{disabledIndices:t})}function bC(e,t){return ms(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function ms(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:a,amount:r=1}={}){let o=t;do o+=n?-r:r;while(o>=0&&o<=e.current.length-1&&ad(e,o,a));return o}function UH(e,{event:t,orientation:n,loopFocus:a,rtl:r,cols:o,disabledIndices:c,minIndex:u,maxIndex:h,prevIndex:f,stopEvent:g=!1}){let v=f;const y=[],x={};let w=!1;{let E=null,S=-1;e.current.forEach((k,N)=>{if(k==null)return;const A=k.closest('[role="row"]');A&&(w=!0),(A!==E||S===-1)&&(E=A,S+=1,y[S]=[]),y[S].push(N),x[N]=S})}const C=w&&y.length>0&&y.some(E=>E.length!==o);function T(E){if(!C||f===-1)return;const S=x[f];if(S==null)return;const k=y[S].indexOf(f);let N=E==="up"?S-1:S+1;a&&(N<0?N=y.length-1:N>=y.length&&(N=0));const A=new Set;for(;N>=0&&N<y.length&&!A.has(N);){A.add(N);const R=y[N];if(R.length===0){N=E==="up"?N-1:N+1;continue}const _=Math.min(k,R.length-1);for(let P=_;P>=0;P-=1){const $=R[P];if(!ad(e,$,c))return $}N=E==="up"?N-1:N+1,a&&(N<0?N=y.length-1:N>=y.length&&(N=0))}}if(t.key===Y0){const E=T("up");if(E!==void 0)g&&ls(t),v=E;else{if(g&&ls(t),f===-1)v=h;else if(v=ms(e,{startingIndex:v,amount:o,decrement:!0,disabledIndices:c}),a&&(f-o<u||v<0)){const S=f%o,k=h%o,N=h-(k-S);k===S?v=h:v=k>S?N:N-o}sd(e,v)&&(v=f)}}if(t.key===Vd){const E=T("down");E!==void 0?(g&&ls(t),v=E):(g&&ls(t),f===-1?v=u:(v=ms(e,{startingIndex:f,amount:o,disabledIndices:c}),a&&f+o>h&&(v=ms(e,{startingIndex:f%o-o,amount:o,disabledIndices:c}))),sd(e,v)&&(v=f))}if(n==="both"){const E=tc(f/o);t.key===(r?Pi:Di)&&(g&&ls(t),f%o!==o-1?(v=ms(e,{startingIndex:f,disabledIndices:c}),a&&bh(v,o,E)&&(v=ms(e,{startingIndex:f-f%o-1,disabledIndices:c}))):a&&(v=ms(e,{startingIndex:f-f%o-1,disabledIndices:c})),bh(v,o,E)&&(v=f)),t.key===(r?Di:Pi)&&(g&&ls(t),f%o!==0?(v=ms(e,{startingIndex:f,decrement:!0,disabledIndices:c}),a&&bh(v,o,E)&&(v=ms(e,{startingIndex:f+(o-f%o),decrement:!0,disabledIndices:c}))):a&&(v=ms(e,{startingIndex:f+(o-f%o),decrement:!0,disabledIndices:c})),bh(v,o,E)&&(v=f));const S=tc(h/o)===E;sd(e,v)&&(a&&S?v=t.key===(r?Di:Pi)?h:ms(e,{startingIndex:f-f%o-1,disabledIndices:c}):v=f)}return v}function FH(e,t,n){const a=[];let r=0;return e.forEach(({width:o,height:c},u)=>{let h=!1;for(n&&(r=0);!h;){const f=[];for(let g=0;g<o;g+=1)for(let v=0;v<c;v+=1)f.push(r+g+v*t);r%t+o<=t&&f.every(g=>a[g]==null)?(f.forEach(g=>{a[g]=u}),h=!0):r+=1}}),[...a]}function VH(e,t,n,a,r){if(e===-1)return-1;const o=n.indexOf(e),c=t[e];switch(r){case"tl":return o;case"tr":return c?o+c.width-1:o;case"bl":return c?o+(c.height-1)*a:o;case"br":return n.lastIndexOf(e);default:return-1}}function HH(e,t){return t.flatMap((n,a)=>e.includes(n)?[a]:[])}function ad(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const a=e.current[t];return a?a.hasAttribute("disabled")||a.getAttribute("aria-disabled")==="true":!1}var qH=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Qm=qH.join(","),NI=typeof Element>"u",jc=NI?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Jm=!NI&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},ep=function(t,n){var a;n===void 0&&(n=!0);var r=t==null||(a=t.getAttribute)===null||a===void 0?void 0:a.call(t,"inert"),o=r===""||r==="true",c=o||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):ep(t.parentNode));return c},WH=function(t){var n,a=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return a===""||a==="true"},kI=function(t,n,a){if(ep(t))return[];var r=Array.prototype.slice.apply(t.querySelectorAll(Qm));return n&&jc.call(t,Qm)&&r.unshift(t),r=r.filter(a),r},tp=function(t,n,a){for(var r=[],o=Array.from(t);o.length;){var c=o.shift();if(!ep(c,!1))if(c.tagName==="SLOT"){var u=c.assignedElements(),h=u.length?u:c.children,f=tp(h,!0,a);a.flatten?r.push.apply(r,f):r.push({scopeParent:c,candidates:f})}else{var g=jc.call(c,Qm);g&&a.filter(c)&&(n||!t.includes(c))&&r.push(c);var v=c.shadowRoot||typeof a.getShadowRoot=="function"&&a.getShadowRoot(c),y=!ep(v,!1)&&(!a.shadowRootFilter||a.shadowRootFilter(c));if(v&&y){var x=tp(v===!0?c.children:v.children,!0,a);a.flatten?r.push.apply(r,x):r.push({scopeParent:c,candidates:x})}else o.unshift.apply(o,c.children)}}return r},SI=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},CI=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||WH(t))&&!SI(t)?0:t.tabIndex},GH=function(t,n){var a=CI(t);return a<0&&n&&!SI(t)?0:a},ZH=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},EI=function(t){return t.tagName==="INPUT"},KH=function(t){return EI(t)&&t.type==="hidden"},YH=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(a){return a.tagName==="SUMMARY"});return n},XH=function(t,n){for(var a=0;a<t.length;a++)if(t[a].checked&&t[a].form===n)return t[a]},QH=function(t){if(!t.name)return!0;var n=t.form||Jm(t),a=function(u){return n.querySelectorAll('input[type="radio"][name="'+u+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=a(window.CSS.escape(t.name));else try{r=a(t.name)}catch(c){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",c.message),!1}var o=XH(r,t.form);return!o||o===t},JH=function(t){return EI(t)&&t.type==="radio"},e7=function(t){return JH(t)&&!QH(t)},t7=function(t){var n,a=t&&Jm(t),r=(n=a)===null||n===void 0?void 0:n.host,o=!1;if(a&&a!==t){var c,u,h;for(o=!!((c=r)!==null&&c!==void 0&&(u=c.ownerDocument)!==null&&u!==void 0&&u.contains(r)||t!=null&&(h=t.ownerDocument)!==null&&h!==void 0&&h.contains(t));!o&&r;){var f,g,v;a=Jm(r),r=(f=a)===null||f===void 0?void 0:f.host,o=!!((g=r)!==null&&g!==void 0&&(v=g.ownerDocument)!==null&&v!==void 0&&v.contains(r))}}return o},wC=function(t){var n=t.getBoundingClientRect(),a=n.width,r=n.height;return a===0&&r===0},n7=function(t,n){var a=n.displayCheck,r=n.getShadowRoot;if(a==="full-native"&&"checkVisibility"in t){var o=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(t).visibility==="hidden")return!0;var c=jc.call(t,"details>summary:first-of-type"),u=c?t.parentElement:t;if(jc.call(u,"details:not([open]) *"))return!0;if(!a||a==="full"||a==="full-native"||a==="legacy-full"){if(typeof r=="function"){for(var h=t;t;){var f=t.parentElement,g=Jm(t);if(f&&!f.shadowRoot&&r(f)===!0)return wC(t);t.assignedSlot?t=t.assignedSlot:!f&&g!==t.ownerDocument?t=g.host:t=f}t=h}if(t7(t))return!t.getClientRects().length;if(a!=="legacy-full")return!0}else if(a==="non-zero-area")return wC(t);return!1},s7=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var a=0;a<n.children.length;a++){var r=n.children.item(a);if(r.tagName==="LEGEND")return jc.call(n,"fieldset[disabled] *")?!0:!r.contains(t)}return!0}n=n.parentElement}return!1},ub=function(t,n){return!(n.disabled||KH(n)||n7(n,t)||YH(n)||s7(n))},db=function(t,n){return!(e7(n)||CI(n)<0||!ub(t,n))},a7=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},AI=function(t){var n=[],a=[];return t.forEach(function(r,o){var c=!!r.scopeParent,u=c?r.scopeParent:r,h=GH(u,c),f=c?AI(r.candidates):u;h===0?c?n.push.apply(n,f):n.push(u):a.push({documentOrder:o,tabIndex:h,item:r,isScope:c,content:f})}),a.sort(ZH).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(n)},Xp=function(t,n){n=n||{};var a;return n.getShadowRoot?a=tp([t],n.includeContainer,{filter:db.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:a7}):a=kI(t,n.includeContainer,db.bind(null,n)),AI(a)},r7=function(t,n){n=n||{};var a;return n.getShadowRoot?a=tp([t],n.includeContainer,{filter:ub.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):a=kI(t,n.includeContainer,ub.bind(null,n)),a},TI=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return jc.call(t,Qm)===!1?!1:db(n,t)};const Hd=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function MI(e,t){const n=Xp(e,Hd()),a=n.length;if(a===0)return;const r=Mi(os(e)),o=n.indexOf(r),c=o===-1?t===1?0:a-1:o+t;return n[c]}function RI(e){return MI(os(e).body,1)||e}function II(e){return MI(os(e).body,-1)||e}function rd(e,t){const n=t||e.currentTarget,a=e.relatedTarget;return!a||!vn(n,a)}function i7(e){Xp(e,Hd()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function jC(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const a=n.dataset.tabindex;delete n.dataset.tabindex,a?n.setAttribute("tabindex",a):n.removeAttribute("tabindex")})}function _I(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(a=>a(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class OI{nodesRef={current:[]};events=_I();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(a=>a===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const $I=m.createContext(null),PI=m.createContext(null),Xi=()=>m.useContext($I)?.id||null,Oc=e=>{const t=m.useContext(PI);return e??t};function o7(e){const t=Gi(),n=Oc(e),a=Xi();return ft(()=>{if(!t)return;const r={id:t,parentId:a};return n?.addNode(r),()=>{n?.removeNode(r)}},[n,t,a]),t}function l7(e){const{children:t,id:n}=e,a=Xi();return s.jsx($I.Provider,{value:m.useMemo(()=>({id:n,parentId:a}),[n,a]),children:t})}function c7(e){const{children:t,externalTree:n}=e,a=Aa(()=>n??new OI).current;return s.jsx(PI.Provider,{value:a,children:t})}function Ed(e){return`data-base-ui-${e}`}const DI={clip:"rect(0 0 0 0)",overflow:"hidden",whiteSpace:"nowrap",position:"fixed",top:0,left:0,border:0,padding:0,width:1,height:1,margin:-1};function Wo(e){return e?.ownerDocument||document}const np=m.forwardRef(function(t,n){const[a,r]=m.useState();ft(()=>{jH&&r("button")},[]);const o={tabIndex:0,role:a};return s.jsx("span",{...t,ref:n,style:DI,"aria-hidden":a?void 0:!0,...o,"data-base-ui-focus-guard":""})});let NC=0;function fm(e,t={}){const{preventScroll:n=!1,cancelPrevious:a=!0,sync:r=!1}=t;a&&cancelAnimationFrame(NC);const o=()=>e?.focus({preventScroll:n});r?o():NC=requestAnimationFrame(o)}const lc={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function kC(e){return e==="inert"?lc.inert:e==="aria-hidden"?lc["aria-hidden"]:lc.none}let wh=new WeakSet,jh={},zy=0;const LI=e=>e&&(e.host||LI(e.parentNode)),u7=(e,t)=>t.map(n=>{if(e.contains(n))return n;const a=LI(n);return e.contains(a)?a:null}).filter(n=>n!=null);function d7(e,t,n,a){const r="data-base-ui-inert",o=a?"inert":n?"aria-hidden":null,c=u7(t,e),u=new Set,h=new Set(c),f=[];jh[r]||(jh[r]=new WeakMap);const g=jh[r];c.forEach(v),y(t),u.clear();function v(x){!x||u.has(x)||(u.add(x),x.parentNode&&v(x.parentNode))}function y(x){!x||h.has(x)||[].forEach.call(x.children,w=>{if(Ki(w)!=="script")if(u.has(w))y(w);else{const C=o?w.getAttribute(o):null,T=C!==null&&C!=="false",E=kC(o),S=(E.get(w)||0)+1,k=(g.get(w)||0)+1;E.set(w,S),g.set(w,k),f.push(w),S===1&&T&&wh.add(w),k===1&&w.setAttribute(r,""),!T&&o&&w.setAttribute(o,o==="inert"?"":"true")}})}return zy+=1,()=>{f.forEach(x=>{const w=kC(o),T=(w.get(x)||0)-1,E=(g.get(x)||0)-1;w.set(x,T),g.set(x,E),T||(!wh.has(x)&&o&&x.removeAttribute(o),wh.delete(x)),E||x.removeAttribute(r)}),zy-=1,zy||(lc.inert=new WeakMap,lc["aria-hidden"]=new WeakMap,lc.none=new WeakMap,wh=new WeakSet,jh={})}}function f7(e,t=!1,n=!1){const a=os(e[0]).body;return d7(e.concat(Array.from(a.querySelectorAll("[aria-live]"))),a,t,n)}const zI=m.createContext(null),BI=()=>m.useContext(zI),h7=Ed("portal");function m7(e={}){const{ref:t,container:n,componentProps:a=Bs,elementProps:r,elementState:o}=e,c=Gi(),h=BI()?.portalNode,[f,g]=m.useState(null),[v,y]=m.useState(null),x=m.useRef(null);ft(()=>{if(n===null){x.current&&(x.current=null,y(null),g(null));return}if(c==null)return;const T=(n&&(G0(n)?n:n.current))??h??document.body;if(T==null){x.current&&(x.current=null,y(null),g(null));return}x.current!==T&&(x.current=T,y(null),g(T))},[n,h,c]);const w=Zi("div",a,{ref:[t,y],state:o,props:[{id:c,[h7]:""},r]});return{portalNode:v,portalSubtree:f&&w?yr.createPortal(w,f):null}}const p7=m.forwardRef(function(t,n){const{children:a,container:r,className:o,render:c,renderGuards:u,...h}=t,{portalNode:f,portalSubtree:g}=m7({container:r,ref:n,componentProps:t,elementProps:h}),v=m.useRef(null),y=m.useRef(null),x=m.useRef(null),w=m.useRef(null),[C,T]=m.useState(null),E=C?.modal,S=C?.open,k=typeof u=="boolean"?u:!!C&&!C.modal&&C.open&&!!f;m.useEffect(()=>{if(!f||E)return;function A(R){f&&rd(R)&&(R.type==="focusin"?jC:i7)(f)}return f.addEventListener("focusin",A,!0),f.addEventListener("focusout",A,!0),()=>{f.removeEventListener("focusin",A,!0),f.removeEventListener("focusout",A,!0)}},[f,E]),m.useEffect(()=>{!f||S||jC(f)},[S,f]);const N=m.useMemo(()=>({beforeOutsideRef:v,afterOutsideRef:y,beforeInsideRef:x,afterInsideRef:w,portalNode:f,setFocusManagerState:T}),[f]);return s.jsxs(m.Fragment,{children:[g,s.jsxs(zI.Provider,{value:N,children:[k&&f&&s.jsx(np,{"data-type":"outside",ref:v,onFocus:A=>{if(rd(A,f))x.current?.focus();else{const R=C?C.domReference:null;II(R)?.focus()}}}),k&&f&&s.jsx("span",{"aria-owns":f.id,style:I9}),f&&yr.createPortal(a,f),k&&f&&s.jsx(np,{"data-type":"outside",ref:y,onFocus:A=>{if(rd(A,f))w.current?.focus();else{const R=C?C.domReference:null;RI(R)?.focus(),C?.closeOnFocusOut&&C?.onOpenChange(!1,Wn(Wp,A.nativeEvent))}}})]})]})});function g7(e,t){const n=us(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const SC=20;let Ri=[];function ew(){Ri=Ri.filter(e=>e.isConnected)}function v7(e){ew(),e&&Ki(e)!=="body"&&(Ri.push(e),Ri.length>SC&&(Ri=Ri.slice(-SC)))}function By(){return ew(),Ri[Ri.length-1]}function y7(e){if(!e)return null;const t=Hd();return TI(e,t)?e:Xp(e,t)[0]||e}function x7(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():ra(e).display!=="none"}function CC(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=Hd(),r=r7(e,n).filter(c=>{const u=c.getAttribute("data-tabindex")||"";return TI(c,n)||c.hasAttribute("data-tabindex")&&!u.startsWith("-")}),o=e.getAttribute("tabindex");t.current.includes("floating")||r.length===0?o!=="0"&&e.setAttribute("tabindex","0"):(o!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function b7(e){const{context:t,children:n,disabled:a=!1,order:r=["content"],initialFocus:o=!0,returnFocus:c=!0,restoreFocus:u=!1,modal:h=!0,closeOnFocusOut:f=!0,openInteractionType:g="",getInsideElements:v=()=>[],nextFocusableElement:y,previousFocusableElement:x,beforeContentFocusGuardRef:w,externalTree:C}=e,T="rootStore"in t?t.rootStore:t,E=T.useState("open"),S=T.useState("domReferenceElement"),k=T.useState("floatingElement"),{events:N,dataRef:A}=T.context,R=pt(()=>A.current.floatingContext?.nodeId),_=pt(v),P=o===!1,$=ob(S)&&P,H=Ls(r),I=Ls(o),U=Ls(c),D=Ls(g),V=Oc(C),Z=BI(),O=m.useRef(null),z=m.useRef(null),B=m.useRef(!1),X=m.useRef(!1),W=m.useRef(!1),L=m.useRef(-1),q=m.useRef(""),K=m.useRef(""),ee=Za(),G=Za(),re=K0(),Q=Z!=null,ae=Zm(k),be=pt((Se=ae)=>Se?Xp(Se,Hd()):[]),$e=pt(Se=>{const Me=be(Se);return H.current.map(()=>Me).filter(Boolean).flat()});m.useEffect(()=>{if(a||!h)return;function Se(_e){_e.key==="Tab"&&vn(ae,Mi(os(ae)))&&be().length===0&&!$&&ls(_e)}const Me=os(ae);return Me.addEventListener("keydown",Se),()=>{Me.removeEventListener("keydown",Se)}},[a,S,ae,h,H,$,be,$e]),m.useEffect(()=>{if(a||!k)return;function Se(Me){const _e=zs(Me),Oe=be().indexOf(_e);Oe!==-1&&(L.current=Oe)}return k.addEventListener("focusin",Se),()=>{k.removeEventListener("focusin",Se)}},[a,k,be]),m.useEffect(()=>{if(a||!E)return;const Se=os(ae);function Me(){W.current=!1}function _e(Oe){const Ce=zs(Oe),Ve=vn(k,Ce)||vn(S,Ce)||vn(Z?.portalNode,Ce);W.current=!Ve,K.current=Oe.pointerType||"keyboard"}function Ne(){K.current="keyboard"}return Se.addEventListener("pointerdown",_e,!0),Se.addEventListener("pointerup",Me,!0),Se.addEventListener("pointercancel",Me,!0),Se.addEventListener("keydown",Ne,!0),()=>{Se.removeEventListener("pointerdown",_e,!0),Se.removeEventListener("pointerup",Me,!0),Se.removeEventListener("pointercancel",Me,!0),Se.removeEventListener("keydown",Ne,!0)}},[a,k,S,ae,E,Z]),m.useEffect(()=>{if(a||!f)return;function Se(){X.current=!0,G.start(0,()=>{X.current=!1})}function Me(Ce){const Ve=Ce.relatedTarget,Re=Ce.currentTarget,Ie=zs(Ce);queueMicrotask(()=>{const De=R(),ct=T.context.triggerElements,ut=!(vn(S,Ve)||vn(k,Ve)||vn(Ve,k)||vn(Z?.portalNode,Ve)||Ve!=null&&ct.hasElement(Ve)||ct.hasMatchingElement(st=>vn(st,Ve))||Ve?.hasAttribute(Ed("focus-guard"))||V&&(oc(V.nodesRef.current,De).find(st=>vn(st.context?.elements.floating,Ve)||vn(st.context?.elements.domReference,Ve))||vC(V.nodesRef.current,De).find(st=>[st.context?.elements.floating,Zm(st.context?.elements.floating)].includes(Ve)||st.context?.elements.domReference===Ve)));if(Re===S&&ae&&CC(ae,H),u&&Re!==S&&!x7(Ie)&&Mi(os(ae))===os(ae).body){if(qn(ae)&&(ae.focus(),u==="popup")){re.request(()=>{ae.focus()});return}const st=L.current,ht=be(),yt=ht[st]||ht[ht.length-1]||ae;qn(yt)&&yt.focus()}if(A.current.insideReactTree){A.current.insideReactTree=!1;return}($||!h)&&Ve&&ut&&!X.current&&($||Ve!==By())&&(B.current=!0,T.setOpen(!1,Wn(Wp,Ce)))})}function _e(){W.current||(A.current.insideReactTree=!0,ee.start(0,()=>{A.current.insideReactTree=!1}))}const Ne=qn(S)?S:null,Oe=[];if(!(!k&&!Ne))return Ne&&(Ne.addEventListener("focusout",Me),Ne.addEventListener("pointerdown",Se),Oe.push(()=>{Ne.removeEventListener("focusout",Me),Ne.removeEventListener("pointerdown",Se)})),k&&(k.addEventListener("focusout",Me),Z&&(k.addEventListener("focusout",_e,!0),Oe.push(()=>{k.removeEventListener("focusout",_e,!0)})),Oe.push(()=>{k.removeEventListener("focusout",Me)})),()=>{Oe.forEach(Ce=>{Ce()})}},[a,S,k,ae,h,V,Z,T,f,u,be,$,R,H,A,ee,G,re]);const ge=m.useRef(null),Te=m.useRef(null),pe=Cd(ge,w,Z?.beforeInsideRef),Xe=Cd(Te,Z?.afterInsideRef);m.useEffect(()=>{if(a||!k||!E)return;const Se=Array.from(Z?.portalNode?.querySelectorAll(`[${Ed("portal")}]`)||[]),_e=(V?vC(V.nodesRef.current,R()):[]).find(Ce=>ob(Ce.context?.elements.domReference||null))?.context?.elements.domReference,Ne=[k,_e,...Se,..._(),O.current,z.current,ge.current,Te.current,Z?.beforeOutsideRef.current,Z?.afterOutsideRef.current,Ao(x),Ao(y),$?S:null].filter(Ce=>Ce!=null),Oe=f7(Ne,h||$);return()=>{Oe()}},[E,a,S,k,h,H,Z,$,V,R,_,y,x]),ft(()=>{if(!E||a||!qn(ae))return;const Se=os(ae),Me=Mi(Se);queueMicrotask(()=>{const _e=$e(ae),Ne=I.current,Oe=typeof Ne=="function"?Ne(D.current||""):Ne;if(Oe===void 0||Oe===!1)return;let Ce;Oe===!0||Oe===null?Ce=_e[0]||ae:Ce=Ao(Oe),Ce=Ce||_e[0]||ae,!vn(ae,Me)&&fm(Ce,{preventScroll:Ce===ae})})},[a,E,ae,P,$e,I,D]),ft(()=>{if(a||!ae)return;const Se=os(ae),Me=Mi(Se);v7(Me);function _e(Ce){if(Ce.open||(q.current=g7(Ce.nativeEvent,K.current)),Ce.reason===Do&&Ce.nativeEvent.type==="mouseleave"&&(B.current=!0),Ce.reason===W0)if(Ce.nested)B.current=!1;else if(bI(Ce.nativeEvent)||wI(Ce.nativeEvent))B.current=!1;else{let Ve=!1;document.createElement("div").focus({get preventScroll(){return Ve=!0,!1}}),Ve?B.current=!1:B.current=!0}}N.on("openchange",_e);const Ne=Se.createElement("span");Ne.setAttribute("tabindex","-1"),Ne.setAttribute("aria-hidden","true"),Object.assign(Ne.style,DI),Q&&S&&S.insertAdjacentElement("afterend",Ne);function Oe(){const Ce=U.current;let Ve=typeof Ce=="function"?Ce(q.current):Ce;if(Ve===void 0||Ve===!1)return null;if(Ve===null&&(Ve=!0),typeof Ve=="boolean"){const Ie=S||By();return Ie&&Ie.isConnected?Ie:Ne}const Re=S||By()||Ne;return Ao(Ve)||Re}return()=>{N.off("openchange",_e);const Ce=Mi(Se),Ve=vn(k,Ce)||V&&oc(V.nodesRef.current,R(),!1).some(Ie=>vn(Ie.context?.elements.floating,Ce)),Re=Oe();queueMicrotask(()=>{const Ie=y7(Re),De=typeof U.current!="boolean";U.current&&!B.current&&qn(Ie)&&(!(!De&&Ie!==Ce&&Ce!==Se.body)||Ve)&&Ie.focus({preventScroll:!0}),Ne.remove()})}},[a,k,ae,U,A,N,V,Q,S,R]),m.useEffect(()=>{queueMicrotask(()=>{B.current=!1})},[a]),m.useEffect(()=>{if(a||!E)return;function Se(_e){zs(_e)?.closest(`[${M9}]`)&&(X.current=!0)}const Me=os(ae);return Me.addEventListener("pointerdown",Se,!0),()=>{Me.removeEventListener("pointerdown",Se,!0)}},[a,E,ae]),ft(()=>{if(!a&&Z)return Z.setFocusManagerState({modal:h,closeOnFocusOut:f,open:E,onOpenChange:T.setOpen,domReference:S}),()=>{Z.setFocusManagerState(null)}},[a,Z,h,E,T,f,S]),ft(()=>{if(!(a||!ae))return CC(ae,H),()=>{queueMicrotask(ew)}},[a,ae,H]);const Be=!a&&(h?!$:!0)&&(Q||h);return s.jsxs(m.Fragment,{children:[Be&&s.jsx(np,{"data-type":"inside",ref:pe,onFocus:Se=>{if(h){const Me=$e();fm(Me[Me.length-1])}else Z?.portalNode&&(B.current=!1,rd(Se,Z.portalNode)?RI(S)?.focus():Ao(x??Z.beforeOutsideRef)?.focus())}}),n,Be&&s.jsx(np,{"data-type":"inside",ref:Xe,onFocus:Se=>{h?fm($e()[0]):Z?.portalNode&&(f&&(B.current=!0),rd(Se,Z.portalNode)?II(S)?.focus():Ao(y??Z.afterOutsideRef)?.focus())}})]})}function EC(e,t,n){let{reference:a,floating:r}=e;const o=ka(t),c=J0(t),u=Q0(c),h=ta(t),f=o==="y",g=a.x+a.width/2-r.width/2,v=a.y+a.height/2-r.height/2,y=a[u]/2-r[u]/2;let x;switch(h){case"top":x={x:g,y:a.y-r.height};break;case"bottom":x={x:g,y:a.y+a.height};break;case"right":x={x:a.x+a.width,y:v};break;case"left":x={x:a.x-r.width,y:v};break;default:x={x:a.x,y:a.y}}switch(Yi(t)){case"start":x[c]-=y*(n&&f?-1:1);break;case"end":x[c]+=y*(n&&f?-1:1);break}return x}async function w7(e,t){var n;t===void 0&&(t={});const{x:a,y:r,platform:o,rects:c,elements:u,strategy:h}=e,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:v="floating",altBoundary:y=!1,padding:x=0}=Zr(t,e),w=jI(x),T=u[y?v==="floating"?"reference":"floating":v],E=Xm(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(T)))==null||n?T:T.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(u.floating)),boundary:f,rootBoundary:g,strategy:h})),S=v==="floating"?{x:a,y:r,width:c.floating.width,height:c.floating.height}:c.reference,k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u.floating)),N=await(o.isElement==null?void 0:o.isElement(k))?await(o.getScale==null?void 0:o.getScale(k))||{x:1,y:1}:{x:1,y:1},A=Xm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:S,offsetParent:k,strategy:h}):S);return{top:(E.top-A.top+w.top)/N.y,bottom:(A.bottom-E.bottom+w.bottom)/N.y,left:(E.left-A.left+w.left)/N.x,right:(A.right-E.right+w.right)/N.x}}const j7=50,N7=async(e,t,n)=>{const{placement:a="bottom",strategy:r="absolute",middleware:o=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:w7},h=await(c.isRTL==null?void 0:c.isRTL(t));let f=await c.getElementRects({reference:e,floating:t,strategy:r}),{x:g,y:v}=EC(f,a,h),y=a,x=0;const w={};for(let C=0;C<o.length;C++){const T=o[C];if(!T)continue;const{name:E,fn:S}=T,{x:k,y:N,data:A,reset:R}=await S({x:g,y:v,initialPlacement:a,placement:y,strategy:r,middlewareData:w,rects:f,platform:u,elements:{reference:e,floating:t}});g=k??g,v=N??v,w[E]={...w[E],...A},R&&x<j7&&(x++,typeof R=="object"&&(R.placement&&(y=R.placement),R.rects&&(f=R.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:r}):R.rects),{x:g,y:v}=EC(f,y,h)),C=-1)}return{x:g,y:v,placement:y,strategy:r,middlewareData:w}},k7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,a;const{placement:r,middlewareData:o,rects:c,initialPlacement:u,platform:h,elements:f}=t,{mainAxis:g=!0,crossAxis:v=!0,fallbackPlacements:y,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:C=!0,...T}=Zr(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const E=ta(r),S=ka(u),k=ta(u)===u,N=await(h.isRTL==null?void 0:h.isRTL(f.floating)),A=y||(k||!C?[Ym(u)]:$H(u)),R=w!=="none";!y&&R&&A.push(...zH(u,C,w,N));const _=[u,...A],P=await h.detectOverflow(t,T),$=[];let H=((a=o.flip)==null?void 0:a.overflows)||[];if(g&&$.push(P[E]),v){const V=OH(r,c,N);$.push(P[V[0]],P[V[1]])}if(H=[...H,{placement:r,overflows:$}],!$.every(V=>V<=0)){var I,U;const V=(((I=o.flip)==null?void 0:I.index)||0)+1,Z=_[V];if(Z&&(!(v==="alignment"?S!==ka(Z):!1)||H.every(B=>ka(B.placement)===S?B.overflows[0]>0:!0)))return{data:{index:V,overflows:H},reset:{placement:Z}};let O=(U=H.filter(z=>z.overflows[0]<=0).sort((z,B)=>z.overflows[1]-B.overflows[1])[0])==null?void 0:U.placement;if(!O)switch(x){case"bestFit":{var D;const z=(D=H.filter(B=>{if(R){const X=ka(B.placement);return X===S||X==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(X=>X>0).reduce((X,W)=>X+W,0)]).sort((B,X)=>B[1]-X[1])[0])==null?void 0:D[0];z&&(O=z);break}case"initialPlacement":O=u;break}if(r!==O)return{reset:{placement:O}}}return{}}}};function AC(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function TC(e){return IH.some(t=>e[t]>=0)}const S7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:a}=t,{strategy:r="referenceHidden",...o}=Zr(e,t);switch(r){case"referenceHidden":{const c=await a.detectOverflow(t,{...o,elementContext:"reference"}),u=AC(c,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:TC(u)}}}case"escaped":{const c=await a.detectOverflow(t,{...o,altBoundary:!0}),u=AC(c,n.floating);return{data:{escapedOffsets:u,escaped:TC(u)}}}default:return{}}}}},UI=new Set(["left","top"]);async function C7(e,t){const{placement:n,platform:a,elements:r}=e,o=await(a.isRTL==null?void 0:a.isRTL(r.floating)),c=ta(n),u=Yi(n),h=ka(n)==="y",f=UI.has(c)?-1:1,g=o&&h?-1:1,v=Zr(t,e);let{mainAxis:y,crossAxis:x,alignmentAxis:w}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return u&&typeof w=="number"&&(x=u==="end"?w*-1:w),h?{x:x*g,y:y*f}:{x:y*f,y:x*g}}const E7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,a;const{x:r,y:o,placement:c,middlewareData:u}=t,h=await C7(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(a=u.arrow)!=null&&a.alignmentOffset?{}:{x:r+h.x,y:o+h.y,data:{...h,placement:c}}}}},A7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:a,placement:r,platform:o}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:h={fn:E=>{let{x:S,y:k}=E;return{x:S,y:k}}},...f}=Zr(e,t),g={x:n,y:a},v=await o.detectOverflow(t,f),y=ka(ta(r)),x=X0(y);let w=g[x],C=g[y];if(c){const E=x==="y"?"top":"left",S=x==="y"?"bottom":"right",k=w+v[E],N=w-v[S];w=lb(k,w,N)}if(u){const E=y==="y"?"top":"left",S=y==="y"?"bottom":"right",k=C+v[E],N=C-v[S];C=lb(k,C,N)}const T=h.fn({...t,[x]:w,[y]:C});return{...T,data:{x:T.x-n,y:T.y-a,enabled:{[x]:c,[y]:u}}}}}},T7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:a,placement:r,rects:o,middlewareData:c}=t,{offset:u=0,mainAxis:h=!0,crossAxis:f=!0}=Zr(e,t),g={x:n,y:a},v=ka(r),y=X0(v);let x=g[y],w=g[v];const C=Zr(u,t),T=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(h){const k=y==="y"?"height":"width",N=o.reference[y]-o.floating[k]+T.mainAxis,A=o.reference[y]+o.reference[k]-T.mainAxis;x<N?x=N:x>A&&(x=A)}if(f){var E,S;const k=y==="y"?"width":"height",N=UI.has(ta(r)),A=o.reference[v]-o.floating[k]+(N&&((E=c.offset)==null?void 0:E[v])||0)+(N?0:T.crossAxis),R=o.reference[v]+o.reference[k]+(N?0:((S=c.offset)==null?void 0:S[v])||0)-(N?T.crossAxis:0);w<A?w=A:w>R&&(w=R)}return{[y]:x,[v]:w}}}},M7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,a;const{placement:r,rects:o,platform:c,elements:u}=t,{apply:h=()=>{},...f}=Zr(e,t),g=await c.detectOverflow(t,f),v=ta(r),y=Yi(r),x=ka(r)==="y",{width:w,height:C}=o.floating;let T,E;v==="top"||v==="bottom"?(T=v,E=y===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(E=v,T=y==="end"?"top":"bottom");const S=C-g.top-g.bottom,k=w-g.left-g.right,N=wc(C-g[T],S),A=wc(w-g[E],k),R=!t.middlewareData.shift;let _=N,P=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=k),(a=t.middlewareData.shift)!=null&&a.enabled.y&&(_=S),R&&!y){const H=Qs(g.left,0),I=Qs(g.right,0),U=Qs(g.top,0),D=Qs(g.bottom,0);x?P=w-2*(H!==0||I!==0?H+I:Qs(g.left,g.right)):_=C-2*(U!==0||D!==0?U+D:Qs(g.top,g.bottom))}await h({...t,availableWidth:P,availableHeight:_});const $=await c.getDimensions(u.floating);return w!==$.width||C!==$.height?{reset:{rects:!0}}:{}}}};function FI(e){const t=ra(e);let n=parseFloat(t.width)||0,a=parseFloat(t.height)||0;const r=qn(e),o=r?e.offsetWidth:n,c=r?e.offsetHeight:a,u=Km(n)!==o||Km(a)!==c;return u&&(n=o,a=c),{width:n,height:a,$:u}}function tw(e){return yn(e)?e:e.contextElement}function cc(e){const t=tw(e);if(!qn(t))return hr(1);const n=t.getBoundingClientRect(),{width:a,height:r,$:o}=FI(t);let c=(o?Km(n.width):n.width)/a,u=(o?Km(n.height):n.height)/r;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const R7=hr(0);function VI(e){const t=us(e);return!Kp()||!t.visualViewport?R7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function I7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==us(e)?!1:t}function Go(e,t,n,a){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=tw(e);let c=hr(1);t&&(a?yn(a)&&(c=cc(a)):c=cc(e));const u=I7(o,n,a)?VI(o):hr(0);let h=(r.left+u.x)/c.x,f=(r.top+u.y)/c.y,g=r.width/c.x,v=r.height/c.y;if(o){const y=us(o),x=a&&yn(a)?us(a):a;let w=y,C=ab(w);for(;C&&a&&x!==w;){const T=cc(C),E=C.getBoundingClientRect(),S=ra(C),k=E.left+(C.clientLeft+parseFloat(S.paddingLeft))*T.x,N=E.top+(C.clientTop+parseFloat(S.paddingTop))*T.y;h*=T.x,f*=T.y,g*=T.x,v*=T.y,h+=k,f+=N,w=us(C),C=ab(w)}}return Xm({width:g,height:v,x:h,y:f})}function Qp(e,t){const n=Yp(e).scrollLeft;return t?t.left+n:Go(wr(e)).left+n}function HI(e,t){const n=e.getBoundingClientRect(),a=n.left+t.scrollLeft-Qp(e,n),r=n.top+t.scrollTop;return{x:a,y:r}}function _7(e){let{elements:t,rect:n,offsetParent:a,strategy:r}=e;const o=r==="fixed",c=wr(a),u=t?Zp(t.floating):!1;if(a===c||u&&o)return n;let h={scrollLeft:0,scrollTop:0},f=hr(1);const g=hr(0),v=qn(a);if((v||!v&&!o)&&((Ki(a)!=="body"||Qo(c))&&(h=Yp(a)),v)){const x=Go(a);f=cc(a),g.x=x.x+a.clientLeft,g.y=x.y+a.clientTop}const y=c&&!v&&!o?HI(c,h):hr(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-h.scrollLeft*f.x+g.x+y.x,y:n.y*f.y-h.scrollTop*f.y+g.y+y.y}}function O7(e){return Array.from(e.getClientRects())}function $7(e){const t=wr(e),n=Yp(e),a=e.ownerDocument.body,r=Qs(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),o=Qs(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight);let c=-n.scrollLeft+Qp(e);const u=-n.scrollTop;return ra(a).direction==="rtl"&&(c+=Qs(t.clientWidth,a.clientWidth)-r),{width:r,height:o,x:c,y:u}}const MC=25;function P7(e,t){const n=us(e),a=wr(e),r=n.visualViewport;let o=a.clientWidth,c=a.clientHeight,u=0,h=0;if(r){o=r.width,c=r.height;const g=Kp();(!g||g&&t==="fixed")&&(u=r.offsetLeft,h=r.offsetTop)}const f=Qp(a);if(f<=0){const g=a.ownerDocument,v=g.body,y=getComputedStyle(v),x=g.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,w=Math.abs(a.clientWidth-v.clientWidth-x);w<=MC&&(o-=w)}else f<=MC&&(o+=f);return{width:o,height:c,x:u,y:h}}function D7(e,t){const n=Go(e,!0,t==="fixed"),a=n.top+e.clientTop,r=n.left+e.clientLeft,o=qn(e)?cc(e):hr(1),c=e.clientWidth*o.x,u=e.clientHeight*o.y,h=r*o.x,f=a*o.y;return{width:c,height:u,x:h,y:f}}function RC(e,t,n){let a;if(t==="viewport")a=P7(e,n);else if(t==="document")a=$7(wr(e));else if(yn(t))a=D7(t,n);else{const r=VI(e);a={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Xm(a)}function qI(e,t){const n=vr(e);return n===t||!yn(n)||fr(n)?!1:ra(n).position==="fixed"||qI(n,t)}function L7(e,t){const n=t.get(e);if(n)return n;let a=$i(e,[],!1).filter(u=>yn(u)&&Ki(u)!=="body"),r=null;const o=ra(e).position==="fixed";let c=o?vr(e):e;for(;yn(c)&&!fr(c);){const u=ra(c),h=Z0(c);!h&&u.position==="fixed"&&(r=null),(o?!h&&!r:!h&&u.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||Qo(c)&&!h&&qI(e,c))?a=a.filter(g=>g!==c):r=u,c=vr(c)}return t.set(e,a),a}function z7(e){let{element:t,boundary:n,rootBoundary:a,strategy:r}=e;const c=[...n==="clippingAncestors"?Zp(t)?[]:L7(t,this._c):[].concat(n),a],u=RC(t,c[0],r);let h=u.top,f=u.right,g=u.bottom,v=u.left;for(let y=1;y<c.length;y++){const x=RC(t,c[y],r);h=Qs(x.top,h),f=wc(x.right,f),g=wc(x.bottom,g),v=Qs(x.left,v)}return{width:f-v,height:g-h,x:v,y:h}}function B7(e){const{width:t,height:n}=FI(e);return{width:t,height:n}}function U7(e,t,n){const a=qn(t),r=wr(t),o=n==="fixed",c=Go(e,!0,o,t);let u={scrollLeft:0,scrollTop:0};const h=hr(0);function f(){h.x=Qp(r)}if(a||!a&&!o)if((Ki(t)!=="body"||Qo(r))&&(u=Yp(t)),a){const x=Go(t,!0,o,t);h.x=x.x+t.clientLeft,h.y=x.y+t.clientTop}else r&&f();o&&!a&&r&&f();const g=r&&!a&&!o?HI(r,u):hr(0),v=c.left+u.scrollLeft-h.x-g.x,y=c.top+u.scrollTop-h.y-g.y;return{x:v,y,width:c.width,height:c.height}}function Uy(e){return ra(e).position==="static"}function IC(e,t){if(!qn(e)||ra(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wr(e)===n&&(n=n.ownerDocument.body),n}function WI(e,t){const n=us(e);if(Zp(e))return n;if(!qn(e)){let r=vr(e);for(;r&&!fr(r);){if(yn(r)&&!Uy(r))return r;r=vr(r)}return n}let a=IC(e,t);for(;a&&Y9(a)&&Uy(a);)a=IC(a,t);return a&&fr(a)&&Uy(a)&&!Z0(a)?n:a||J9(e)||n}const F7=async function(e){const t=this.getOffsetParent||WI,n=this.getDimensions,a=await n(e.floating);return{reference:U7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function V7(e){return ra(e).direction==="rtl"}const H7={convertOffsetParentRelativeRectToViewportRelativeRect:_7,getDocumentElement:wr,getClippingRect:z7,getOffsetParent:WI,getElementRects:F7,getClientRects:O7,getDimensions:B7,getScale:cc,isElement:yn,isRTL:V7};function GI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function q7(e,t){let n=null,a;const r=wr(e);function o(){var u;clearTimeout(a),(u=n)==null||u.disconnect(),n=null}function c(u,h){u===void 0&&(u=!1),h===void 0&&(h=1),o();const f=e.getBoundingClientRect(),{left:g,top:v,width:y,height:x}=f;if(u||t(),!y||!x)return;const w=tc(v),C=tc(r.clientWidth-(g+y)),T=tc(r.clientHeight-(v+x)),E=tc(g),k={rootMargin:-w+"px "+-C+"px "+-T+"px "+-E+"px",threshold:Qs(0,wc(1,h))||1};let N=!0;function A(R){const _=R[0].intersectionRatio;if(_!==h){if(!N)return c();_?c(!1,_):a=setTimeout(()=>{c(!1,1e-7)},1e3)}_===1&&!GI(f,e.getBoundingClientRect())&&c(),N=!1}try{n=new IntersectionObserver(A,{...k,root:r.ownerDocument})}catch{n=new IntersectionObserver(A,k)}n.observe(e)}return c(!0),o}function _C(e,t,n,a){a===void 0&&(a={});const{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:h=!1}=a,f=tw(e),g=r||o?[...f?$i(f):[],...t?$i(t):[]]:[];g.forEach(E=>{r&&E.addEventListener("scroll",n,{passive:!0}),o&&E.addEventListener("resize",n)});const v=f&&u?q7(f,n):null;let y=-1,x=null;c&&(x=new ResizeObserver(E=>{let[S]=E;S&&S.target===f&&x&&t&&(x.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var k;(k=x)==null||k.observe(t)})),n()}),f&&!h&&x.observe(f),t&&x.observe(t));let w,C=h?Go(e):null;h&&T();function T(){const E=Go(e);C&&!GI(C,E)&&n(),C=E,w=requestAnimationFrame(T)}return n(),()=>{var E;g.forEach(S=>{r&&S.removeEventListener("scroll",n),o&&S.removeEventListener("resize",n)}),v?.(),(E=x)==null||E.disconnect(),x=null,h&&cancelAnimationFrame(w)}}const W7=E7,G7=A7,Z7=k7,K7=M7,Y7=S7,X7=T7,Q7=(e,t,n)=>{const a=new Map,r={platform:H7,...n},o={...r.platform,_c:a};return N7(e,t,{...r,platform:o})};var J7=typeof document<"u",eq=function(){},hm=J7?m.useLayoutEffect:eq;function sp(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,a,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(a=n;a--!==0;)if(!sp(e[a],t[a]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(t,r[a]))return!1;for(a=n;a--!==0;){const o=r[a];if(!(o==="_owner"&&e.$$typeof)&&!sp(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function ZI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function OC(e,t){const n=ZI(e);return Math.round(t*n)/n}function Fy(e){const t=m.useRef(e);return hm(()=>{t.current=e}),t}function tq(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:a=[],platform:r,elements:{reference:o,floating:c}={},transform:u=!0,whileElementsMounted:h,open:f}=e,[g,v]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,x]=m.useState(a);sp(y,a)||x(a);const[w,C]=m.useState(null),[T,E]=m.useState(null),S=m.useCallback(B=>{B!==R.current&&(R.current=B,C(B))},[]),k=m.useCallback(B=>{B!==_.current&&(_.current=B,E(B))},[]),N=o||w,A=c||T,R=m.useRef(null),_=m.useRef(null),P=m.useRef(g),$=h!=null,H=Fy(h),I=Fy(r),U=Fy(f),D=m.useCallback(()=>{if(!R.current||!_.current)return;const B={placement:t,strategy:n,middleware:y};I.current&&(B.platform=I.current),Q7(R.current,_.current,B).then(X=>{const W={...X,isPositioned:U.current!==!1};V.current&&!sp(P.current,W)&&(P.current=W,yr.flushSync(()=>{v(W)}))})},[y,t,n,I,U]);hm(()=>{f===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,v(B=>({...B,isPositioned:!1})))},[f]);const V=m.useRef(!1);hm(()=>(V.current=!0,()=>{V.current=!1}),[]),hm(()=>{if(N&&(R.current=N),A&&(_.current=A),N&&A){if(H.current)return H.current(N,A,D);D()}},[N,A,D,H,$]);const Z=m.useMemo(()=>({reference:R,floating:_,setReference:S,setFloating:k}),[S,k]),O=m.useMemo(()=>({reference:N,floating:A}),[N,A]),z=m.useMemo(()=>{const B={position:n,left:0,top:0};if(!O.floating)return B;const X=OC(O.floating,g.x),W=OC(O.floating,g.y);return u?{...B,transform:"translate("+X+"px, "+W+"px)",...ZI(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:X,top:W}},[n,u,O.floating,g.x,g.y]);return m.useMemo(()=>({...g,update:D,refs:Z,elements:O,floatingStyles:z}),[g,D,Z,O,z])}const nq=(e,t)=>{const n=W7(e);return{name:n.name,fn:n.fn,options:[e,t]}},sq=(e,t)=>{const n=G7(e);return{name:n.name,fn:n.fn,options:[e,t]}},aq=(e,t)=>({fn:X7(e).fn,options:[e,t]}),rq=(e,t)=>{const n=Z7(e);return{name:n.name,fn:n.fn,options:[e,t]}},iq=(e,t)=>{const n=K7(e);return{name:n.name,fn:n.fn,options:[e,t]}},oq=(e,t)=>{const n=Y7(e);return{name:n.name,fn:n.fn,options:[e,t]}},lq={intentional:"onClick",sloppy:"onPointerDown"};function cq(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function uq(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),r=n.useState("floatingElement"),o=n.useState("referenceElement"),c=n.useState("domReferenceElement"),{onOpenChange:u,dataRef:h}=n.context,{enabled:f=!0,escapeKey:g=!0,outsidePress:v=!0,outsidePressEvent:y="sloppy",referencePress:x=!1,referencePressEvent:w="sloppy",ancestorScroll:C=!1,bubbles:T,externalTree:E}=t,S=Oc(E),k=pt(typeof v=="function"?v:()=>!1),N=typeof v=="function"?k:v,A=m.useRef(!1),{escapeKey:R,outsidePress:_}=cq(T),P=m.useRef(null),$=Za(),H=Za(),I=pt(()=>{H.clear(),h.current.insideReactTree=!1}),U=m.useRef(!1),D=m.useRef(""),V=pt(ge=>{D.current=ge.pointerType}),Z=pt(()=>{const ge=D.current,Te=ge==="pen"||!ge?"mouse":ge,pe=typeof y=="function"?y():y;return typeof pe=="string"?pe:pe[Te]}),O=pt(ge=>{if(!a||!f||!g||ge.key!=="Escape"||U.current)return;const Te=h.current.floatingContext?.nodeId,pe=S?oc(S.nodesRef.current,Te):[];if(!R&&pe.length>0){let Se=!0;if(pe.forEach(Me=>{Me.context?.open&&!Me.context.dataRef.current.__escapeKeyBubbles&&(Se=!1)}),!Se)return}const Xe=TH(ge)?ge.nativeEvent:ge,Be=Wn(lI,Xe);n.setOpen(!1,Be),!R&&!Be.isPropagationAllowed&&ge.stopPropagation()}),z=pt(ge=>{const Te=Z();return Te==="intentional"&&ge.type!=="click"||Te==="sloppy"&&ge.type==="click"}),B=pt(()=>{h.current.insideReactTree=!0,H.start(0,I)}),X=pt((ge,Te=!1)=>{if(z(ge)){I();return}if(h.current.insideReactTree){I();return}if(Z()==="intentional"&&Te||typeof N=="function"&&!N(ge))return;const pe=zs(ge),Xe=`[${Ed("inert")}]`,Be=os(n.select("floatingElement")).querySelectorAll(Xe),Se=n.context.triggerElements;if(pe&&(Se.hasElement(pe)||Se.hasMatchingElement(Ce=>vn(Ce,pe))))return;let Me=yn(pe)?pe:null;for(;Me&&!fr(Me);){const Ce=vr(Me);if(fr(Ce)||!yn(Ce))break;Me=Ce}if(Be.length&&yn(pe)&&!EH(pe)&&!vn(pe,n.select("floatingElement"))&&Array.from(Be).every(Ce=>!vn(Me,Ce)))return;if(qn(pe)&&!("touches"in ge)){const Ce=fr(pe),Ve=ra(pe),Re=/auto|scroll/,Ie=Ce||Re.test(Ve.overflowX),De=Ce||Re.test(Ve.overflowY),ct=Ie&&pe.clientWidth>0&&pe.scrollWidth>pe.clientWidth,ut=De&&pe.clientHeight>0&&pe.scrollHeight>pe.clientHeight,st=Ve.direction==="rtl",ht=ut&&(st?ge.offsetX<=pe.offsetWidth-pe.clientWidth:ge.offsetX>pe.clientWidth),yt=ct&&ge.offsetY>pe.clientHeight;if(ht||yt)return}const _e=h.current.floatingContext?.nodeId,Ne=S&&oc(S.nodesRef.current,_e).some(Ce=>La(ge,Ce.context?.elements.floating));if(La(ge,n.select("floatingElement"))||La(ge,n.select("domReferenceElement"))||Ne)return;const Oe=S?oc(S.nodesRef.current,_e):[];if(Oe.length>0){let Ce=!0;if(Oe.forEach(Ve=>{Ve.context?.open&&!Ve.context.dataRef.current.__outsidePressBubbles&&(Ce=!1)}),!Ce)return}n.setOpen(!1,Wn(W0,ge)),I()}),W=pt(ge=>{Z()!=="sloppy"||ge.pointerType==="touch"||!n.select("open")||!f||La(ge,n.select("floatingElement"))||La(ge,n.select("domReferenceElement"))||X(ge)}),L=pt(ge=>{if(Z()!=="sloppy"||!n.select("open")||!f||La(ge,n.select("floatingElement"))||La(ge,n.select("domReferenceElement")))return;const Te=ge.touches[0];Te&&(P.current={startTime:Date.now(),startX:Te.clientX,startY:Te.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},$.start(1e3,()=>{P.current&&(P.current.dismissOnTouchEnd=!1,P.current.dismissOnMouseDown=!1)}))}),q=pt(ge=>{const Te=zs(ge);function pe(){L(ge),Te?.removeEventListener(ge.type,pe)}Te?.addEventListener(ge.type,pe)}),K=pt(ge=>{const Te=A.current;if(A.current=!1,$.clear(),ge.type==="mousedown"&&P.current&&!P.current.dismissOnMouseDown)return;const pe=zs(ge);function Xe(){ge.type==="pointerdown"?W(ge):X(ge,Te),pe?.removeEventListener(ge.type,Xe)}pe?.addEventListener(ge.type,Xe)}),ee=pt(ge=>{if(Z()!=="sloppy"||!P.current||La(ge,n.select("floatingElement"))||La(ge,n.select("domReferenceElement")))return;const Te=ge.touches[0];if(!Te)return;const pe=Math.abs(Te.clientX-P.current.startX),Xe=Math.abs(Te.clientY-P.current.startY),Be=Math.sqrt(pe*pe+Xe*Xe);Be>5&&(P.current.dismissOnTouchEnd=!0),Be>10&&(X(ge),$.clear(),P.current=null)}),G=pt(ge=>{const Te=zs(ge);function pe(){ee(ge),Te?.removeEventListener(ge.type,pe)}Te?.addEventListener(ge.type,pe)}),re=pt(ge=>{Z()!=="sloppy"||!P.current||La(ge,n.select("floatingElement"))||La(ge,n.select("domReferenceElement"))||(P.current.dismissOnTouchEnd&&X(ge),$.clear(),P.current=null)}),Q=pt(ge=>{const Te=zs(ge);function pe(){re(ge),Te?.removeEventListener(ge.type,pe)}Te?.addEventListener(ge.type,pe)});m.useEffect(()=>{if(!a||!f)return;h.current.__escapeKeyBubbles=R,h.current.__outsidePressBubbles=_;const ge=new bc;function Te(Me){n.setOpen(!1,Wn(H9,Me))}function pe(){ge.clear(),U.current=!0}function Xe(){ge.start(Kp()?5:0,()=>{U.current=!1})}const Be=os(r);Be.addEventListener("pointerdown",V,!0),g&&(Be.addEventListener("keydown",O),Be.addEventListener("compositionstart",pe),Be.addEventListener("compositionend",Xe)),N&&(Be.addEventListener("click",K,!0),Be.addEventListener("pointerdown",K,!0),Be.addEventListener("touchstart",q,!0),Be.addEventListener("touchmove",G,!0),Be.addEventListener("touchend",Q,!0),Be.addEventListener("mousedown",K,!0));let Se=[];return C&&(yn(c)&&(Se=$i(c)),yn(r)&&(Se=Se.concat($i(r))),!yn(o)&&o&&o.contextElement&&(Se=Se.concat($i(o.contextElement)))),Se=Se.filter(Me=>Me!==Be.defaultView?.visualViewport),Se.forEach(Me=>{Me.addEventListener("scroll",Te,{passive:!0})}),()=>{Be.removeEventListener("pointerdown",V,!0),g&&(Be.removeEventListener("keydown",O),Be.removeEventListener("compositionstart",pe),Be.removeEventListener("compositionend",Xe)),N&&(Be.removeEventListener("click",K,!0),Be.removeEventListener("pointerdown",K,!0),Be.removeEventListener("touchstart",q,!0),Be.removeEventListener("touchmove",G,!0),Be.removeEventListener("touchend",Q,!0),Be.removeEventListener("mousedown",K,!0)),Se.forEach(Me=>{Me.removeEventListener("scroll",Te)}),ge.clear()}},[h,r,o,c,g,N,a,u,C,f,R,_,O,X,K,W,q,G,Q,V,n]),m.useEffect(I,[N,I]);const ae=m.useMemo(()=>({onKeyDown:O,...x&&{[lq[w]]:ge=>{n.setOpen(!1,Wn(Gm,ge.nativeEvent))},...w!=="intentional"&&{onClick(ge){n.setOpen(!1,Wn(Gm,ge.nativeEvent))}}}}),[O,n,x,w]),be=pt(ge=>{const Te=zs(ge.nativeEvent);!vn(n.select("floatingElement"),Te)||ge.button!==0||(A.current=!0)}),$e=m.useMemo(()=>({onKeyDown:O,onPointerDown:be,onMouseDown:be,onMouseUp:be,onClickCapture:B,onMouseDownCapture:B,onPointerDownCapture:B,onMouseUpCapture:B,onTouchEndCapture:B,onTouchMoveCapture:B}),[O,be,B]);return m.useMemo(()=>f?{reference:ae,floating:$e,trigger:ae}:{},[f,ae,$e])}var ap=Symbol("NOT_FOUND");function dq(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function fq(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function hq(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(a=>typeof a=="function"?`function ${a.name||"unnamed"}()`:typeof a).join(", ");throw new TypeError(`${t}[${n}]`)}}var $C=e=>Array.isArray(e)?e:[e];function mq(e){const t=Array.isArray(e[0])?e[0]:e;return hq(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function pq(e,t){const n=[],{length:a}=e;for(let r=0;r<a;r++)n.push(e[r].apply(null,t));return n}function gq(e){let t;return{get(n){return t&&e(t.key,n)?t.value:ap},put(n,a){t={key:n,value:a}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function vq(e,t){let n=[];function a(u){const h=n.findIndex(f=>t(u,f.key));if(h>-1){const f=n[h];return h>0&&(n.splice(h,1),n.unshift(f)),f.value}return ap}function r(u,h){a(u)===ap&&(n.unshift({key:u,value:h}),n.length>e&&n.pop())}function o(){return n}function c(){n=[]}return{get:a,put:r,getEntries:o,clear:c}}var yq=(e,t)=>e===t;function xq(e){return function(n,a){if(n===null||a===null||n.length!==a.length)return!1;const{length:r}=n;for(let o=0;o<r;o++)if(!e(n[o],a[o]))return!1;return!0}}function bq(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:a=yq,maxSize:r=1,resultEqualityCheck:o}=n,c=xq(a);let u=0;const h=r<=1?gq(c):vq(r,c);function f(){let g=h.get(arguments);if(g===ap){if(g=e.apply(null,arguments),u++,o){const y=h.getEntries().find(x=>o(x.value,g));y&&(g=y.value,u!==0&&u--)}h.put(arguments,g)}return g}return f.clearCache=()=>{h.clear(),f.resetResultsCount()},f.resultsCount=()=>u,f.resetResultsCount=()=>{u=0},f}var wq=class{constructor(e){this.value=e}deref(){return this.value}},jq=typeof WeakRef<"u"?WeakRef:wq,Nq=0,PC=1;function Nh(){return{s:Nq,v:void 0,o:null,p:null}}function KI(e,t={}){let n=Nh();const{resultEqualityCheck:a}=t;let r,o=0;function c(){let u=n;const{length:h}=arguments;for(let v=0,y=h;v<y;v++){const x=arguments[v];if(typeof x=="function"||typeof x=="object"&&x!==null){let w=u.o;w===null&&(u.o=w=new WeakMap);const C=w.get(x);C===void 0?(u=Nh(),w.set(x,u)):u=C}else{let w=u.p;w===null&&(u.p=w=new Map);const C=w.get(x);C===void 0?(u=Nh(),w.set(x,u)):u=C}}const f=u;let g;if(u.s===PC)g=u.v;else if(g=e.apply(null,arguments),o++,a){const v=r?.deref?.()??r;v!=null&&a(v,g)&&(g=v,o!==0&&o--),r=typeof g=="object"&&g!==null||typeof g=="function"?new jq(g):g}return f.s=PC,f.v=g,g}return c.clearCache=()=>{n=Nh(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}function YI(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,a=(...r)=>{let o=0,c=0,u,h={},f=r.pop();typeof f=="object"&&(h=f,f=r.pop()),dq(f,`createSelector expects an output function after the inputs, but received: [${typeof f}]`);const g={...n,...h},{memoize:v,memoizeOptions:y=[],argsMemoize:x=KI,argsMemoizeOptions:w=[]}=g,C=$C(y),T=$C(w),E=mq(r),S=v(function(){return o++,f.apply(null,arguments)},...C),k=x(function(){c++;const A=pq(E,arguments);return u=S.apply(null,A),u},...T);return Object.assign(k,{resultFunc:f,memoizedResultFunc:S,dependencies:E,dependencyRecomputations:()=>c,resetDependencyRecomputations:()=>{c=0},lastResult:()=>u,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:v,argsMemoize:x})};return Object.assign(a,{withTypes:()=>a}),a}var kq=YI(KI),Sq=Object.assign((e,t=kq)=>{fq(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),a=n.map(o=>e[o]);return t(a,(...o)=>o.reduce((c,u,h)=>(c[n[h]]=u,c),{}))},{withTypes:()=>Sq});YI({memoize:bq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const Nt=(e,t,n,a,r,o,...c)=>{if(c.length>0)throw new Error(Xo(1));let u;if(e)u=e;else throw new Error("Missing arguments");return u};var Vy={exports:{}},Hy={};var DC;function Cq(){if(DC)return Hy;DC=1;var e=Ld(),t=ZR();function n(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var a=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,h=e.useDebugValue;return Hy.useSyncExternalStoreWithSelector=function(f,g,v,y,x){var w=o(null);if(w.current===null){var C={hasValue:!1,value:null};w.current=C}else C=w.current;w=u(function(){function E(R){if(!S){if(S=!0,k=R,R=y(R),x!==void 0&&C.hasValue){var _=C.value;if(x(_,R))return N=_}return N=R}if(_=N,a(k,R))return _;var P=y(R);return x!==void 0&&x(_,P)?(k=R,_):(k=R,N=P)}var S=!1,k,N,A=v===void 0?null:v;return[function(){return E(g())},A===null?void 0:function(){return E(A())}]},[g,v,y,x]);var T=r(f,w[0],w[1]);return c(function(){C.hasValue=!0,C.value=T},[T]),h(T),T},Hy}var LC;function Eq(){return LC||(LC=1,Vy.exports=Cq()),Vy.exports}var Aq=Eq();const Tq=H0(19),Mq=Tq?Iq:_q;function Rq(e,t,n,a,r){return Mq(e,t,n,a,r)}function Iq(e,t,n,a,r){const o=m.useCallback(()=>t(e.getSnapshot(),n,a,r),[e,t,n,a,r]);return UV.useSyncExternalStore(e.subscribe,o,o)}function _q(e,t,n,a,r){return Aq.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,o=>t(o,n,a,r))}class id{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const a of this.listeners){if(n!==this.updateTick)return;a(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){id.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||id.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};id.prototype.setState.call(this,t)}}class XI extends id{constructor(t,n={},a){super(t),this.context=n,this.selectors=a}controlledValues=new Map;useSyncedValue(t,n){m.useDebugValue(t),ft(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){ft(()=>(this.state[t]!==n&&this.set(t,n),()=>{this.set(t,void 0)}),[t,n])}useSyncedValues(t){const n=Object.values(t);ft(()=>{this.update(t)},n)}useControlledProp(t,n,a){m.useDebugValue(t);const r=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,r),!r&&!Object.is(this.state[t],a)&&super.setState({...this.state,[t]:a})),ft(()=>{r&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,a,r])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const a in n)if(Object.hasOwn(n,a)&&this.controlledValues.get(a)===!0){delete n[a];continue}super.update(n)}setState(t){const n={...t};for(const a in n)if(Object.hasOwn(n,a)&&this.controlledValues.get(a)===!0){delete n[a];continue}super.setState({...this.state,...n})}select=(t,n,a,r)=>{const o=this.selectors[t];return o(this.state,n,a,r)};useState=(t,n,a,r)=>{m.useDebugValue(t);const o=this.selectors[t];return Rq(this,o,n,a,r)};useContextCallback(t,n){m.useDebugValue(t);const a=pt(n??aI);this.context[t]=a}useStateSetter(t){const n=m.useRef(void 0);return n.current===void 0&&(n.current=a=>{this.set(t,a)}),n.current}observe(t,n){let a;typeof t=="function"?a=t:a=this.selectors[t];let r=a(this.state);return n(r,r,this),this.subscribe(o=>{const c=a(o);if(!Object.is(r,c)){const u=r;r=c,n(c,u,this)}})}}const Oq={open:Nt(e=>e.open),domReferenceElement:Nt(e=>e.domReferenceElement),referenceElement:Nt(e=>e.positionReference??e.referenceElement),floatingElement:Nt(e=>e.floatingElement),floatingId:Nt(e=>e.floatingId)};class nw extends XI{constructor(t){const{nested:n,noEmit:a,onOpenChange:r,triggerElements:o,...c}=t;super({...c,positionReference:c.referenceElement,domReferenceElement:c.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:_I(),nested:n,noEmit:a,triggerElements:o},Oq)}setOpen=(t,n)=>{if((!t||!this.state.open||RH(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const a={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",a)}this.context.onOpenChange?.(t,n)}}function $q(e){const t=e.useState("open");ft(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[a,r]=n.value;e.update({activeTriggerId:a,activeTriggerElement:r})}}},[t,e])}function Pq(e,t,n){const{mounted:a,setMounted:r,transitionStatus:o}=hH(e);t.useSyncedValues({mounted:a,transitionStatus:o});const c=pt(()=>{r(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),u=t.useState("preventUnmountingOnClose");return hI({enabled:!u,open:e,ref:t.context.popupRef,onComplete(){e||c()}}),{forceUnmount:c,transitionStatus:o}}class sw{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const a=this.idMap.get(t);a!==n&&(a!==void 0&&this.elements.delete(a),this.elements.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elements.delete(n),this.idMap.delete(t))}hasElement(t){return this.elements.has(t)}hasMatchingElement(t){for(const n of this.elements)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}get size(){return this.idMap.size}}function Dq(){return new nw({open:!1,floatingElement:null,referenceElement:null,triggerElements:new sw,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function Lq(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:Dq(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Bs,inactiveTriggerProps:Bs,popupProps:Bs}}const zq={open:Nt(e=>e.open),mounted:Nt(e=>e.mounted),transitionStatus:Nt(e=>e.transitionStatus),floatingRootContext:Nt(e=>e.floatingRootContext),preventUnmountingOnClose:Nt(e=>e.preventUnmountingOnClose),payload:Nt(e=>e.payload),activeTriggerId:Nt(e=>e.activeTriggerId),activeTriggerElement:Nt(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:Nt((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:Nt((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:Nt((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:Nt((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:Nt(e=>e.popupProps),popupElement:Nt(e=>e.popupElement),positionerElement:Nt(e=>e.positionerElement)};function Bq(e){const{open:t=!1,onOpenChange:n,elements:a={}}=e,r=Gi(),o=Xi()!=null,c=Aa(()=>new nw({open:t,onOpenChange:n,referenceElement:a.reference??null,floatingElement:a.floating??null,triggerElements:a.triggers??new sw,floatingId:r,nested:o,noEmit:e.noEmit||!1})).current;return ft(()=>{const u={open:t,floatingId:r};a.reference!==void 0&&(u.referenceElement=a.reference,u.domReferenceElement=yn(a.reference)?a.reference:null),a.floating!==void 0&&(u.floatingElement=a.floating),c.update(u)},[t,r,a.reference,a.floating,c]),c.context.onOpenChange=n,c.context.nested=o,c.context.noEmit=e.noEmit||!1,c}function Uq(e={}){const{nodeId:t,externalTree:n}=e,a=Bq(e),r=e.rootContext||a,o={reference:r.useState("referenceElement"),floating:r.useState("floatingElement"),domReference:r.useState("domReferenceElement")},[c,u]=m.useState(null),h=m.useRef(null),f=Oc(n);ft(()=>{o.domReference&&(h.current=o.domReference)},[o.domReference]);const g=tq({...e,elements:{...o,...c&&{reference:c}}}),v=m.useCallback(_=>{const P=yn(_)?{getBoundingClientRect:()=>_.getBoundingClientRect(),getClientRects:()=>_.getClientRects(),contextElement:_}:_;u(P),g.refs.setReference(P)},[g.refs]),[y,x]=m.useState(null),[w,C]=m.useState(null);r.useSyncedValue("referenceElement",y),r.useSyncedValue("domReferenceElement",yn(y)?y:null),r.useSyncedValue("floatingElement",w);const T=m.useCallback(_=>{(yn(_)||_===null)&&(h.current=_,x(_)),(yn(g.refs.reference.current)||g.refs.reference.current===null||_!==null&&!yn(_))&&g.refs.setReference(_)},[g.refs,x]),E=m.useCallback(_=>{C(_),g.refs.setFloating(_)},[g.refs]),S=m.useMemo(()=>({...g.refs,setReference:T,setFloating:E,setPositionReference:v,domReference:h}),[g.refs,T,E,v]),k=m.useMemo(()=>({...g.elements,domReference:o.domReference}),[g.elements,o.domReference]),N=r.useState("open"),A=r.useState("floatingId"),R=m.useMemo(()=>({...g,dataRef:r.context.dataRef,open:N,onOpenChange:r.setOpen,events:r.context.events,floatingId:A,refs:S,elements:k,nodeId:t,rootStore:r}),[g,S,k,t,r,N,A]);return ft(()=>{r.context.dataRef.current.floatingContext=R;const _=f?.nodesRef.current.find(P=>P.id===t);_&&(_.context=R)}),m.useMemo(()=>({...g,context:R,refs:S,elements:k,rootStore:r}),[g,S,k,R,r])}function Fq(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:a=!1,onOpenChange:r}=e,o=Gi(),c=Xi()!=null,u=t.useState("open"),h=t.useState("activeTriggerElement"),f=t.useState(a?"popupElement":"positionerElement"),g=t.context.triggerElements,v=Aa(()=>new nw({open:u,referenceElement:h,floatingElement:f,triggerElements:g,onOpenChange:r,floatingId:o,nested:c,noEmit:n})).current;return ft(()=>{const y={open:u,floatingId:o,referenceElement:h,floatingElement:f};yn(h)&&(y.domReferenceElement=h),v.update(y)},[u,o,h,f,v]),v.context.onOpenChange=r,v.context.nested=c,v.context.noEmit=n,v}const zC=Ed("safe-polygon"),Vq=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${xI}`;function Hq(e){return e?!!e.closest(Vq):!1}function qq(e){const t=m.useRef(void 0),n=m.useRef(!1),a=m.useRef(void 0),r=m.useRef(!0),o=m.useRef(!1),c=m.useRef(()=>{}),u=m.useRef(!1),h=Za(),f=Za(),g=m.useRef(void 0);return m.useMemo(()=>{const v=e.context.dataRef.current;return v.hoverInteractionState||(v.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:a,blockMouseMoveRef:r,performedPointerEventsMutationRef:o,unbindMouseMoveRef:c,restTimeoutPendingRef:u,openChangeTimeout:h,restTimeout:f,handleCloseOptionsRef:g}),v.hoverInteractionState},[e,t,n,a,r,o,c,u,h,f,g])}const Wq=new Set(["click","mousedown"]);function Gq(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),r=n.useState("floatingElement"),o=n.useState("domReferenceElement"),{dataRef:c}=n.context,{enabled:u=!0,closeDelay:h=0,externalTree:f}=t,{pointerTypeRef:g,interactedInsideRef:v,handlerRef:y,performedPointerEventsMutationRef:x,unbindMouseMoveRef:w,restTimeoutPendingRef:C,openChangeTimeout:T,handleCloseOptionsRef:E}=qq(n),S=Oc(f),k=Xi(),N=pt(()=>v.current?!0:c.current.openEvent?Wq.has(c.current.openEvent.type):!1),A=pt(()=>{const H=c.current.openEvent?.type;return H?.includes("mouse")&&H!=="mousedown"}),R=m.useCallback((H,I=!0)=>{const U=Zq(h,g.current);U&&!y.current?T.start(U,()=>n.setOpen(!1,Wn(Do,H))):I&&(T.clear(),n.setOpen(!1,Wn(Do,H)))},[h,y,n,g,T]),_=pt(()=>{w.current(),y.current=void 0}),P=pt(()=>{if(x.current){const H=os(r).body;H.style.pointerEvents="",H.removeAttribute(zC),x.current=!1}}),$=pt(H=>{const I=zs(H);if(!Hq(I)){v.current=!1;return}v.current=!0});ft(()=>{a||(g.current=void 0,C.current=!1,v.current=!1,_(),P())},[a,g,C,v,_,P]),m.useEffect(()=>()=>{_()},[_]),m.useEffect(()=>P,[P]),ft(()=>{if(u&&a&&E.current?.blockPointerEvents&&A()&&yn(o)&&r){x.current=!0;const H=os(r).body;H.setAttribute(zC,"");const I=o,U=r,D=S?.nodesRef.current.find(V=>V.id===k)?.context?.elements.floating;return D&&(D.style.pointerEvents=""),H.style.pointerEvents="none",I.style.pointerEvents="auto",U.style.pointerEvents="auto",()=>{H.style.pointerEvents="",I.style.pointerEvents="",U.style.pointerEvents=""}}},[u,a,o,r,E,A,S,k,x]),m.useEffect(()=>{if(!u)return;function H(V){if(N()||!c.current.floatingContext)return;const Z=n.context.triggerElements;V.relatedTarget&&Z.hasElement(V.relatedTarget)||(P(),_(),N()||R(V))}function I(V){T.clear(),P(),y.current?.(V),_()}function U(V){N()||R(V,!1)}const D=r;return D&&(D.addEventListener("mouseleave",H),D.addEventListener("mouseenter",I),D.addEventListener("mouseleave",U),D.addEventListener("pointerdown",$,!0)),()=>{D&&(D.removeEventListener("mouseleave",H),D.removeEventListener("mouseenter",I),D.removeEventListener("mouseleave",U),D.removeEventListener("pointerdown",$,!0))}})}function Zq(e,t){return t&&!MH(t)?0:typeof e=="function"?e():e}function Kq(e=[]){const t=e.map(f=>f?.reference),n=e.map(f=>f?.floating),a=e.map(f=>f?.item),r=e.map(f=>f?.trigger),o=m.useCallback(f=>kh(f,e,"reference"),t),c=m.useCallback(f=>kh(f,e,"floating"),n),u=m.useCallback(f=>kh(f,e,"item"),a),h=m.useCallback(f=>kh(f,e,"trigger"),r);return m.useMemo(()=>({getReferenceProps:o,getFloatingProps:c,getItemProps:u,getTriggerProps:h}),[o,c,u,h])}function kh(e,t,n){const a=new Map,r=n==="item",o={};n==="floating"&&(o.tabIndex=-1,o[ib]="");for(const c in e)r&&e&&(c===vI||c===yI)||(o[c]=e[c]);for(let c=0;c<t.length;c+=1){let u;const h=t[c]?.[n];typeof h=="function"?u=e?h(e):null:u=h,u&&BC(o,u,r,a)}return BC(o,e,r,a),o}function BC(e,t,n,a){for(const r in t){const o=t[r];n&&(r===vI||r===yI)||(r.startsWith("on")?(a.has(r)||a.set(r,[]),typeof o=="function"&&(a.get(r)?.push(o),e[r]=(...c)=>a.get(r)?.map(u=>u(...c)).find(u=>u!==void 0))):e[r]=o)}}const Yq="Escape";function Jp(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Sh(e,t){return Jp(t,e===Y0||e===Vd,e===Pi||e===Di)}function qy(e,t,n){return Jp(t,e===Vd,n?e===Pi:e===Di)||e==="Enter"||e===" "||e===""}function Xq(e,t,n){return Jp(t,n?e===Pi:e===Di,e===Vd)}function Qq(e,t,n,a){const r=n?e===Di:e===Pi,o=e===Y0;return t==="both"||t==="horizontal"&&a&&a>1?e===Yq:Jp(t,r,o)}function Jq(e,t){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),r=n.useState("floatingElement"),o=n.useState("domReferenceElement"),c=n.context.dataRef,{listRef:u,activeIndex:h,onNavigate:f=()=>{},enabled:g=!0,selectedIndex:v=null,allowEscape:y=!1,loopFocus:x=!1,nested:w=!1,rtl:C=!1,virtual:T=!1,focusItemOnOpen:E="auto",focusItemOnHover:S=!0,openOnArrowKeyDown:k=!0,disabledIndices:N=void 0,orientation:A="vertical",parentOrientation:R,cols:_=1,scrollItemIntoView:P=!0,itemSizes:$,dense:H=!1,id:I,resetOnPointerLeave:U=!0,externalTree:D}=t,V=Zm(r),Z=Ls(V),O=Xi(),z=Oc(D);ft(()=>{c.current.orientation=A},[c,A]);const B=ob(o),X=m.useRef(E),W=m.useRef(v??-1),L=m.useRef(null),q=m.useRef(!0),K=pt(Re=>{f(W.current===-1?null:W.current,Re)}),ee=m.useRef(K),G=m.useRef(!!r),re=m.useRef(a),Q=m.useRef(!1),ae=m.useRef(!1),be=Ls(N),$e=Ls(a),ge=Ls(P),Te=Ls(v),pe=Ls(U),Xe=pt(()=>{function Re(ut){T?z?.events.emit("virtualfocus",ut):fm(ut,{sync:Q.current,preventScroll:!0})}const Ie=u.current[W.current],De=ae.current;Ie&&Re(Ie),(Q.current?ut=>ut():requestAnimationFrame)(()=>{const ut=u.current[W.current]||Ie;if(!ut)return;Ie||Re(ut);const st=ge.current;st&&Se&&(De||!q.current)&&ut.scrollIntoView?.(typeof st=="boolean"?{block:"nearest",inline:"nearest"}:st)})});ft(()=>{g&&(a&&r?(W.current=v??-1,X.current&&v!=null&&(ae.current=!0,K())):G.current&&(W.current=-1,ee.current()))},[g,a,r,v,K]),ft(()=>{if(g){if(!a){Q.current=!1;return}if(r)if(h==null){if(Q.current=!1,Te.current!=null)return;if(G.current&&(W.current=-1,Xe()),(!re.current||!G.current)&&X.current&&(L.current!=null||X.current===!0&&L.current==null)){let Re=0;const Ie=()=>{u.current[0]==null?(Re<2&&(Re?requestAnimationFrame:queueMicrotask)(Ie),Re+=1):(W.current=L.current==null||qy(L.current,A,C)||w?Ly(u):bC(u),L.current=null,K())};Ie()}}else sd(u,h)||(W.current=h,Xe(),ae.current=!1)}},[g,a,r,h,Te,w,u,A,C,K,Xe,be]),ft(()=>{if(!g||r||!z||T||!G.current)return;const Re=z.nodesRef.current,Ie=Re.find(ut=>ut.id===O)?.context?.elements.floating,De=Mi(os(r)),ct=Re.some(ut=>ut.context&&vn(ut.context.elements.floating,De));Ie&&!ct&&q.current&&Ie.focus({preventScroll:!0})},[g,r,z,O,T]),ft(()=>{ee.current=K,re.current=a,G.current=!!r}),ft(()=>{a||(L.current=null,X.current=E)},[a,E]);const Be=h!=null,Se=m.useMemo(()=>{function Re(De){if(!$e.current)return;const ct=u.current.indexOf(De.currentTarget);ct!==-1&&W.current!==ct&&(W.current=ct,K(De))}return{onFocus(De){Q.current=!0,Re(De)},onClick:({currentTarget:De})=>De.focus({preventScroll:!0}),onMouseMove(De){Q.current=!0,ae.current=!1,S&&Re(De)},onPointerLeave(De){if(!$e.current||!q.current||De.pointerType==="touch")return;Q.current=!0;const ct=De.relatedTarget;!S||u.current.includes(ct)||pe.current&&(W.current=-1,K(De),T||Z.current?.focus({preventScroll:!0}))}}},[$e,Z,S,u,K,pe,T]),Me=m.useCallback(()=>R??z?.nodesRef.current.find(Re=>Re.id===O)?.context?.dataRef?.current.orientation,[O,z,R]),_e=pt(Re=>{if(q.current=!1,Q.current=!0,Re.which===229||!$e.current&&Re.currentTarget===Z.current)return;if(w&&Qq(Re.key,A,C,_)){Sh(Re.key,Me())||ls(Re),n.setOpen(!1,Wn(dm,Re.nativeEvent)),qn(o)&&(T?z?.events.emit("virtualfocus",o):o.focus());return}const Ie=W.current,De=Ly(u,N),ct=bC(u,N);if(B||(Re.key==="Home"&&(ls(Re),W.current=De,K(Re)),Re.key==="End"&&(ls(Re),W.current=ct,K(Re))),_>1){const ut=$||Array.from({length:u.current.length},()=>({width:1,height:1})),st=FH(ut,_,H),ht=st.findIndex(Rt=>Rt!=null&&!ad(u,Rt,N)),yt=st.reduce((Rt,xt,Y)=>xt!=null&&!ad(u,xt,N)?Y:Rt,-1),Mt=st[UH({current:st.map(Rt=>Rt!=null?u.current[Rt]:null)},{event:Re,orientation:A,loopFocus:x,rtl:C,cols:_,disabledIndices:HH([...(typeof N!="function"?N:null)||u.current.map((Rt,xt)=>ad(u,xt,N)?xt:void 0),void 0],st),minIndex:ht,maxIndex:yt,prevIndex:VH(W.current>ct?De:W.current,ut,st,_,Re.key===Vd?"bl":Re.key===(C?Pi:Di)?"tr":"tl"),stopEvent:!0})];if(Mt!=null&&(W.current=Mt,K(Re)),A==="both")return}if(Sh(Re.key,A)){if(ls(Re),a&&!T&&Mi(Re.currentTarget.ownerDocument)===Re.currentTarget){W.current=qy(Re.key,A,C)?De:ct,K(Re);return}qy(Re.key,A,C)?x?Ie>=ct?y&&Ie!==u.current.length?W.current=-1:(Q.current=!1,W.current=De):W.current=ms(u,{startingIndex:Ie,disabledIndices:N}):W.current=Math.min(ct,ms(u,{startingIndex:Ie,disabledIndices:N})):x?Ie<=De?y&&Ie!==-1?W.current=u.current.length:(Q.current=!1,W.current=ct):W.current=ms(u,{startingIndex:Ie,decrement:!0,disabledIndices:N}):W.current=Math.max(De,ms(u,{startingIndex:Ie,decrement:!0,disabledIndices:N})),sd(u,W.current)&&(W.current=-1),K(Re)}}),Ne=m.useMemo(()=>T&&a&&Be&&{"aria-activedescendant":`${I}-${h}`},[T,a,Be,I,h]),Oe=m.useMemo(()=>({"aria-orientation":A==="both"?void 0:A,...B?{}:Ne,onKeyDown(Re){if(Re.key==="Tab"&&Re.shiftKey&&a&&!T){const Ie=zs(Re.nativeEvent);if(Ie&&!vn(Z.current,Ie))return;ls(Re),n.setOpen(!1,Wn(Wp,Re.nativeEvent)),qn(o)&&o.focus();return}_e(Re)},onPointerMove(){q.current=!0}}),[Ne,_e,Z,A,B,n,a,T,o]),Ce=m.useMemo(()=>{function Re(De){E==="auto"&&bI(De.nativeEvent)&&(X.current=!T)}function Ie(De){X.current=E,E==="auto"&&wI(De.nativeEvent)&&(X.current=!0)}return{onKeyDown(De){const ct=n.select("open");q.current=!1;const ut=De.key.startsWith("Arrow"),st=Xq(De.key,Me(),C),ht=Sh(De.key,A),yt=(w?st:ht)||De.key==="Enter"||De.key.trim()==="";if(T&&ct)return _e(De);if(!(!ct&&!k&&ut)){if(yt){const Mt=Sh(De.key,Me());L.current=w&&Mt?null:De.key}if(w){st&&(ls(De),ct?(W.current=Ly(u,be.current),K(De)):n.setOpen(!0,Wn(dm,De.nativeEvent,De.currentTarget)));return}ht&&(Te.current!=null&&(W.current=Te.current),ls(De),!ct&&k?n.setOpen(!0,Wn(dm,De.nativeEvent,De.currentTarget)):_e(De),ct&&K(De))}},onFocus(De){n.select("open")&&!T&&(W.current=-1,K(De))},onPointerDown:Ie,onPointerEnter:Ie,onMouseDown:Re,onClick:Re}},[_e,be,E,u,w,K,n,k,A,Me,C,Te,T]),Ve=m.useMemo(()=>({...Ne,...Ce}),[Ne,Ce]);return m.useMemo(()=>g?{reference:Ve,floating:Oe,item:Se,trigger:Ce}:{},[g,Ve,Oe,Ce,Se])}const eW=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function tW(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),r=n.useState("floatingId"),o=n.useState("domReferenceElement"),c=n.useState("floatingElement"),{enabled:u=!0,role:h="dialog"}=t,f=Gi(),g=o?.id||f,v=m.useMemo(()=>Zm(c)?.id||r,[c,r]),y=eW.get(h)??h,w=Xi()!=null,C=m.useMemo(()=>y==="tooltip"||h==="label"?Bs:{"aria-haspopup":y==="alertdialog"?"dialog":y,"aria-expanded":"false",...y==="listbox"&&{role:"combobox"},...y==="menu"&&w&&{role:"menuitem"},...h==="select"&&{"aria-autocomplete":"none"},...h==="combobox"&&{"aria-autocomplete":"list"}},[y,w,h]),T=m.useMemo(()=>y==="tooltip"||h==="label"?{[`aria-${h==="label"?"labelledby":"describedby"}`]:a?v:void 0}:{...C,"aria-expanded":a?"true":"false","aria-controls":a?v:void 0,...y==="menu"&&{id:g}},[y,v,a,g,h,C]),E=m.useMemo(()=>{const k={id:v,...y&&{role:y}};return y==="tooltip"||h==="label"?k:{...k,...y==="menu"&&{"aria-labelledby":g}}},[y,v,g,h]),S=m.useCallback(({active:k,selected:N})=>{const A={role:"option",...k&&{id:`${v}-fui-option`}};switch(h){case"select":case"combobox":return{...A,"aria-selected":N}}return{}},[v,h]);return m.useMemo(()=>u?{reference:T,floating:E,item:S,trigger:C}:{},[u,T,E,C,S])}function nW(e,t){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),r=n.context.dataRef,{listRef:o,activeIndex:c,onMatch:u,onTypingChange:h,enabled:f=!0,findMatch:g=null,resetMs:v=750,ignoreKeys:y=rI,selectedIndex:x=null}=t,w=Za(),C=m.useRef(""),T=m.useRef(x??c??-1),E=m.useRef(null);ft(()=>{a&&(w.clear(),E.current=null,C.current="")},[a,w]),ft(()=>{a&&C.current===""&&(T.current=x??c??-1)},[a,x,c]);const S=pt(R=>{R?r.current.typing||(r.current.typing=R,h?.(R)):r.current.typing&&(r.current.typing=R,h?.(R))}),k=pt(R=>{function _(U,D,V){const Z=g?g(D,V):D.find(O=>O?.toLocaleLowerCase().indexOf(V.toLocaleLowerCase())===0);return Z?U.indexOf(Z):-1}const P=o.current;if(C.current.length>0&&C.current[0]!==" "&&(_(P,P,C.current)===-1?S(!1):R.key===" "&&ls(R)),P==null||y.includes(R.key)||R.key.length!==1||R.ctrlKey||R.metaKey||R.altKey)return;a&&R.key!==" "&&(ls(R),S(!0)),P.every(U=>U?U[0]?.toLocaleLowerCase()!==U[1]?.toLocaleLowerCase():!0)&&C.current===R.key&&(C.current="",T.current=E.current),C.current+=R.key,w.start(v,()=>{C.current="",T.current=E.current,S(!1)});const H=T.current,I=_(P,[...P.slice((H||0)+1),...P.slice(0,(H||0)+1)],C.current);I!==-1?(u?.(I),E.current=I):R.key!==" "&&(C.current="",S(!1))}),N=m.useMemo(()=>({onKeyDown:k}),[k]),A=m.useMemo(()=>({onKeyDown:k,onKeyUp(R){R.key===" "&&S(!1)}}),[k,S]);return m.useMemo(()=>f?{reference:N,floating:A}:{},[f,N,A])}const sW=m.createContext(void 0);function aW(e){return m.useContext(sW)}const QI="ArrowUp",JI="ArrowDown",e_="ArrowLeft",t_="ArrowRight",n_="Home",s_="End",rW=new Set([e_,t_]),iW=new Set([QI,JI]),oW=new Set([...rW,...iW]);[...oW];const lW=new Set([QI,JI,e_,t_,n_,s_]);function cW(e){return e==="starting"?T9:Bs}const uW={...iI,...L9},dW=m.forwardRef(function(t,n){const{render:a,className:r,finalFocus:o,...c}=t,{store:u}=Ic(),{side:h,align:f}=JR(),g=aW()!=null,v=u.useState("open"),y=u.useState("transitionStatus"),x=u.useState("popupProps"),w=u.useState("mounted"),C=u.useState("instantType"),T=u.useState("activeTriggerElement"),E=u.useState("parent"),S=u.useState("lastOpenChangeReason"),k=u.useState("rootId"),N=u.useState("floatingRootContext"),A=u.useState("floatingTreeRoot"),R=u.useState("closeDelay"),_=u.useState("activeTriggerElement");hI({open:v,ref:u.context.popupRef,onComplete(){v&&u.context.onOpenChangeComplete?.(!0)}}),m.useEffect(()=>{function D(V){u.setOpen(!1,Wn(V.reason,V.domEvent))}return A.events.on("close",D),()=>{A.events.off("close",D)}},[A.events,u]);const P=u.useState("hoverEnabled"),$=u.useState("disabled");Gq(N,{enabled:P&&!$&&E.type!=="context-menu"&&E.type!=="menubar",closeDelay:R});const H=m.useMemo(()=>({transitionStatus:y,side:h,align:f,open:v,nested:E.type==="menu",instant:C}),[y,h,f,v,E.type,C]),I=Zi("div",t,{state:H,ref:[n,u.context.popupRef],stateAttributesMapping:uW,props:[x,{onKeyDown(D){g&&lW.has(D.key)&&D.stopPropagation()}},cW(y),c,{"data-rootownerid":k}]});let U=E.type===void 0||E.type==="context-menu";return(T||E.type==="menubar"&&S!==W0)&&(U=!0),s.jsx(b7,{context:N,modal:!1,disabled:!w,returnFocus:o===void 0?U:o,initialFocus:E.type!=="menu",restoreFocus:!0,externalTree:E.type!=="menubar"?A:void 0,previousFocusableElement:_,nextFocusableElement:E.type===void 0?u.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:E.type===void 0?u.context.beforeContentFocusGuardRef:void 0,children:I})}),a_=m.createContext(void 0);function fW(){const e=m.useContext(a_);if(e===void 0)throw new Error(Xo(32));return e}const hW=m.forwardRef(function(t,n){const{keepMounted:a=!1,...r}=t,{store:o}=Ic();return o.useState("mounted")||a?s.jsx(a_.Provider,{value:a,children:s.jsx(p7,{ref:n,...r})}):null});function mW(e){return H0(19)?e:e?"true":void 0}const pW=m.createContext(void 0);function r_(){return m.useContext(pW)?.direction??"ltr"}const gW=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:a,placement:r,rects:o,platform:c,elements:u,middlewareData:h}=t,{element:f,padding:g=0,offsetParent:v="real"}=Zr(e,t)||{};if(f==null)return{};const y=jI(g),x={x:n,y:a},w=J0(r),C=Q0(w),T=await c.getDimensions(f),E=w==="y",S=E?"top":"left",k=E?"bottom":"right",N=E?"clientHeight":"clientWidth",A=o.reference[C]+o.reference[w]-x[w]-o.floating[C],R=x[w]-o.reference[w],_=v==="real"?await c.getOffsetParent?.(f):u.floating;let P=u.floating[N]||o.floating[C];(!P||!await c.isElement?.(_))&&(P=u.floating[N]||o.floating[C]);const $=A/2-R/2,H=P/2-T[C]/2-1,I=Math.min(y[S],H),U=Math.min(y[k],H),D=I,V=P-T[C]-U,Z=P/2-T[C]/2+$,O=lb(D,Z,V),z=!h.arrow&&Yi(r)!=null&&Z!==O&&o.reference[C]/2-(Z<D?I:U)-T[C]/2<0,B=z?Z<D?Z-D:Z-V:0;return{[w]:x[w]+B,data:{[w]:O,centerOffset:Z-O-B,...z&&{alignmentOffset:B}},reset:z}}}),vW=(e,t)=>({...gW(e),options:[e,t]}),yW={name:"hide",async fn(e){const{width:t,height:n,x:a,y:r}=e.rects.reference,o=t===0&&n===0&&a===0&&r===0;return{data:{referenceHidden:(await oq().fn(e)).data?.referenceHidden||o}}}},xW={sideX:"left",sideY:"top"};function i_(e,t,n){const a=e==="inline-start"||e==="inline-end";return{top:"top",right:a?n?"inline-start":"inline-end":"right",bottom:"bottom",left:a?n?"inline-end":"inline-start":"left"}[t]}function UC(e,t,n){const{rects:a,placement:r}=e;return{side:i_(t,ta(r),n),align:Yi(r)||"center",anchor:{width:a.reference.width,height:a.reference.height},positioner:{width:a.floating.width,height:a.floating.height}}}function bW(e){const{anchor:t,positionMethod:n="absolute",side:a="bottom",sideOffset:r=0,align:o="center",alignOffset:c=0,collisionBoundary:u,collisionPadding:h=5,sticky:f=!1,arrowPadding:g=5,disableAnchorTracking:v=!1,keepMounted:y=!1,floatingRootContext:x,mounted:w,collisionAvoidance:C,shiftCrossAxis:T=!1,nodeId:E,adaptiveOrigin:S,lazyFlip:k=!1,externalTree:N}=e,[A,R]=m.useState(null);!w&&A!==null&&R(null);const _=C.side||"flip",P=C.align||"flip",$=C.fallbackAxisSide||"end",H=typeof t=="function"?t:void 0,I=pt(H),U=H?I:t,D=Ls(t),Z=r_()==="rtl",O=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":Z?"left":"right","inline-start":Z?"right":"left"}[a],z=o==="center"?O:`${O}-${o}`;let B=h;const X=1,W=a==="bottom"?X:0,L=a==="top"?X:0,q=a==="right"?X:0,K=a==="left"?X:0;typeof B=="number"?B={top:B+W,right:B+K,bottom:B+L,left:B+q}:B&&(B={top:(B.top||0)+W,right:(B.right||0)+K,bottom:(B.bottom||0)+L,left:(B.left||0)+q});const ee={boundary:u==="clipping-ancestors"?"clippingAncestors":u,padding:B},G=m.useRef(null),re=Ls(r),Q=Ls(c),$e=[nq(Pe=>{const We=UC(Pe,a,Z),rt=typeof re.current=="function"?re.current(We):re.current,at=typeof Q.current=="function"?Q.current(We):Q.current;return{mainAxis:rt,crossAxis:at,alignmentAxis:at}},[typeof r!="function"?r:0,typeof c!="function"?c:0,Z,a])],ge=P==="none"&&_!=="shift",Te=!ge&&(f||T||_==="shift"),pe=_==="none"?null:rq({...ee,padding:{top:B.top+X,right:B.right+X,bottom:B.bottom+X,left:B.left+X},mainAxis:!T&&_==="flip",crossAxis:P==="flip"?"alignment":!1,fallbackAxisSideDirection:$}),Xe=ge?null:sq(Pe=>{const We=Wo(Pe.elements.floating).documentElement;return{...ee,rootBoundary:T?{x:0,y:0,width:We.clientWidth,height:We.clientHeight}:void 0,mainAxis:P!=="none",crossAxis:Te,limiter:f||T?void 0:aq(rt=>{if(!G.current)return{};const{width:at,height:Ot}=G.current.getBoundingClientRect(),jt=ka(ta(rt.placement)),bt=jt==="y"?at:Ot,Bt=jt==="y"?B.left+B.right:B.top+B.bottom;return{offset:bt/2+Bt/2}})}},[ee,f,T,B,P]);_==="shift"||P==="shift"||o==="center"?$e.push(Xe,pe):$e.push(pe,Xe),$e.push(iq({...ee,apply({elements:{floating:Pe},rects:{reference:We},availableWidth:rt,availableHeight:at}){Object.entries({"--available-width":`${rt}px`,"--available-height":`${at}px`,"--anchor-width":`${We.width}px`,"--anchor-height":`${We.height}px`}).forEach(([Ot,jt])=>{Pe.style.setProperty(Ot,jt)})}}),vW(()=>({element:G.current||document.createElement("div"),padding:g,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(Pe){const{elements:We,middlewareData:rt,placement:at,rects:Ot,y:jt}=Pe,bt=ta(at),Bt=ka(bt),Mn=G.current,es=rt.arrow?.x||0,vs=rt.arrow?.y||0,cn=Mn?.clientWidth||0,Rn=Mn?.clientHeight||0,ts=es+cn/2,ys=vs+Rn/2,la=Math.abs(rt.shift?.y||0),xs=Ot.reference.height/2,Yt=typeof r=="function"?r(UC(Pe,a,Z)):r,Ht=la>Yt,Ln={top:`${ts}px calc(100% + ${Yt}px)`,bottom:`${ts}px ${-Yt}px`,left:`calc(100% + ${Yt}px) ${ys}px`,right:`${-Yt}px ${ys}px`}[bt],Rs=`${ts}px ${Ot.reference.y+xs-jt}px`;return We.floating.style.setProperty("--transform-origin",Te&&Bt==="y"&&Ht?Rs:Ln),{}}},yW,S),ft(()=>{!w&&x&&x.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[w,x]);const Be=m.useMemo(()=>({elementResize:!v&&typeof ResizeObserver<"u",layoutShift:!v&&typeof IntersectionObserver<"u"}),[v]),{refs:Se,elements:Me,x:_e,y:Ne,middlewareData:Oe,update:Ce,placement:Ve,context:Re,isPositioned:Ie,floatingStyles:De}=Uq({rootContext:x,placement:z,middleware:$e,strategy:n,whileElementsMounted:y?void 0:(...Pe)=>_C(...Pe,Be),nodeId:E,externalTree:N}),{sideX:ct,sideY:ut}=Oe.adaptiveOrigin||xW,st=Ie?n:"fixed",ht=m.useMemo(()=>S?{position:st,[ct]:_e,[ut]:Ne}:{position:st,...De},[S,st,ct,_e,ut,Ne,De]),yt=m.useRef(null);ft(()=>{if(!w)return;const Pe=D.current,We=typeof Pe=="function"?Pe():Pe,at=(FC(We)?We.current:We)||null||null;at!==yt.current&&(Se.setPositionReference(at),yt.current=at)},[w,Se,U,D]),m.useEffect(()=>{if(!w)return;const Pe=D.current;typeof Pe!="function"&&FC(Pe)&&Pe.current!==yt.current&&(Se.setPositionReference(Pe.current),yt.current=Pe.current)},[w,Se,U,D]),m.useEffect(()=>{if(y&&w&&Me.domReference&&Me.floating)return _C(Me.domReference,Me.floating,Ce,Be)},[y,w,Me,Ce,Be]);const Mt=ta(Ve),Rt=i_(a,Mt,Z),xt=Yi(Ve)||"center",Y=!!Oe.hide?.referenceHidden;ft(()=>{k&&w&&Ie&&R(Mt)},[k,w,Ie,Mt]);const te=m.useMemo(()=>({position:"absolute",top:Oe.arrow?.y,left:Oe.arrow?.x}),[Oe.arrow]),he=Oe.arrow?.centerOffset!==0;return m.useMemo(()=>({positionerStyles:ht,arrowStyles:te,arrowRef:G,arrowUncentered:he,side:Rt,align:xt,physicalSide:Mt,anchorHidden:Y,refs:Se,context:Re,isPositioned:Ie,update:Ce}),[ht,te,G,he,Rt,xt,Mt,Y,Se,Re,Ie,Ce])}function FC(e){return e!=null&&"current"in e}function wW(e){const{children:t,elementsRef:n,labelsRef:a,onMapChange:r}=e,o=pt(r),c=m.useRef(0),u=Aa(NW).current,h=Aa(jW).current,[f,g]=m.useState(0),v=m.useRef(f),y=pt((E,S)=>{h.set(E,S??null),v.current+=1,g(v.current)}),x=pt(E=>{h.delete(E),v.current+=1,g(v.current)}),w=m.useMemo(()=>{const E=new Map;return Array.from(h.keys()).filter(k=>k.isConnected).sort(kW).forEach((k,N)=>{const A=h.get(k)??{};E.set(k,{...A,index:N})}),E},[h,f]);ft(()=>{if(typeof MutationObserver!="function"||w.size===0)return;const E=new MutationObserver(S=>{const k=new Set,N=A=>k.has(A)?k.delete(A):k.add(A);S.forEach(A=>{A.removedNodes.forEach(N),A.addedNodes.forEach(N)}),k.size===0&&(v.current+=1,g(v.current))});return w.forEach((S,k)=>{k.parentElement&&E.observe(k.parentElement,{childList:!0})}),()=>{E.disconnect()}},[w]),ft(()=>{v.current===f&&(n.current.length!==w.size&&(n.current.length=w.size),a&&a.current.length!==w.size&&(a.current.length=w.size),c.current=w.size),o(w)},[o,w,n,a,f]),ft(()=>()=>{n.current=[]},[n]),ft(()=>()=>{a&&(a.current=[])},[a]);const C=pt(E=>(u.add(E),()=>{u.delete(E)}));ft(()=>{u.forEach(E=>E(w))},[u,w]);const T=m.useMemo(()=>({register:y,unregister:x,subscribeMapChange:C,elementsRef:n,labelsRef:a,nextIndexRef:c}),[y,x,C,n,a,c]);return s.jsx(uI.Provider,{value:T,children:t})}function jW(){return new Map}function NW(){return new Set}function kW(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const SW=m.forwardRef(function(t,n){const{cutout:a,...r}=t;let o;if(a){const c=a?.getBoundingClientRect();o=`polygon(
111
+ 0% 0%,
112
+ 100% 0%,
113
+ 100% 100%,
114
+ 0% 100%,
115
+ 0% 0%,
116
+ ${c.left}px ${c.top}px,
117
+ ${c.left}px ${c.bottom}px,
118
+ ${c.right}px ${c.bottom}px,
119
+ ${c.right}px ${c.top}px,
120
+ ${c.left}px ${c.top}px
121
+ )`}return s.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...r,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),CW=m.forwardRef(function(t,n){const{anchor:a,positionMethod:r="absolute",className:o,render:c,side:u,align:h,sideOffset:f=0,alignOffset:g=0,collisionBoundary:v="clipping-ancestors",collisionPadding:y=5,arrowPadding:x=5,sticky:w=!1,disableAnchorTracking:C=!1,collisionAvoidance:T=R9,...E}=t,{store:S}=Ic(),k=fW(),N=Hp(!0),A=S.useState("parent"),R=S.useState("floatingRootContext"),_=S.useState("floatingTreeRoot"),P=S.useState("mounted"),$=S.useState("open"),H=S.useState("modal"),I=S.useState("activeTriggerElement"),U=S.useState("lastOpenChangeReason"),D=S.useState("floatingNodeId"),V=S.useState("floatingParentNodeId");let Z=a,O=f,z=g,B=h;A.type==="context-menu"&&(Z=a??A.context?.anchor,B=B??"start",!u&&B!=="center"&&(z=t.alignOffset??2,O=t.sideOffset??-5));let X=u,W=B;A.type==="menu"?(X=X??"inline-end",W=W??"start"):A.type==="menubar"&&(X=X??"bottom",W=W??"start");const L=A.type==="context-menu",q=bW({anchor:Z,floatingRootContext:R,positionMethod:N?"fixed":r,mounted:P,side:X,sideOffset:O,align:W,alignOffset:z,arrowPadding:L?0:x,collisionBoundary:v,collisionPadding:y,sticky:w,nodeId:D,keepMounted:k,disableAnchorTracking:C,collisionAvoidance:T,shiftCrossAxis:L,externalTree:_}),K=m.useMemo(()=>{const be={};return $||(be.pointerEvents="none"),{role:"presentation",hidden:!P,style:{...q.positionerStyles,...be}}},[$,P,q.positionerStyles]);m.useEffect(()=>{function be($e){$e.open?($e.parentNodeId===D&&S.set("hoverEnabled",!1),$e.nodeId!==D&&$e.parentNodeId===S.select("floatingParentNodeId")&&S.setOpen(!1,Wn(Ku))):$e.parentNodeId===D&&$e.reason!==Ku&&S.set("hoverEnabled",!0)}return _.events.on("menuopenchange",be),()=>{_.events.off("menuopenchange",be)}},[S,_.events,D]),m.useEffect(()=>{if(S.select("floatingParentNodeId")==null)return;function be($e){if($e.open||$e.nodeId!==S.select("floatingParentNodeId"))return;const ge=$e.reason??Ku;S.setOpen(!1,Wn(ge))}return _.events.on("menuopenchange",be),()=>{_.events.off("menuopenchange",be)}},[_.events,S]),m.useEffect(()=>{function be($e){!$||$e.nodeId!==S.select("floatingParentNodeId")||$e.target&&I&&I!==$e.target&&S.setOpen(!1,Wn(Ku))}return _.events.on("itemhover",be),()=>{_.events.off("itemhover",be)}},[_.events,$,I,S]),m.useEffect(()=>{const be={open:$,nodeId:D,parentNodeId:V,reason:S.select("lastOpenChangeReason")};_.events.emit("menuopenchange",be)},[_.events,$,S,D,V]);const ee=m.useMemo(()=>({open:$,side:q.side,align:q.align,anchorHidden:q.anchorHidden,nested:A.type==="menu"}),[$,q.side,q.align,q.anchorHidden,A.type]),G=m.useMemo(()=>({side:q.side,align:q.align,arrowRef:q.arrowRef,arrowUncentered:q.arrowUncentered,arrowStyles:q.arrowStyles,nodeId:q.context.nodeId}),[q.side,q.align,q.arrowRef,q.arrowUncentered,q.arrowStyles,q.context.nodeId]),re=Zi("div",t,{state:ee,stateAttributesMapping:iI,ref:[n,S.useStateSetter("positionerElement")],props:[K,E]}),Q=P&&A.type!=="menu"&&(A.type!=="menubar"&&H&&U!==Do||A.type==="menubar"&&A.context.modal);let ae=null;return A.type==="menubar"?ae=A.context.contentElement:A.type===void 0&&(ae=I),s.jsxs(QR.Provider,{value:G,children:[Q&&s.jsx(SW,{ref:A.type==="context-menu"||A.type==="nested-context-menu"?A.context.internalBackdropRef:null,inert:mW(!$),cutout:ae}),s.jsx(l7,{id:D,children:s.jsx(wW,{elementsRef:S.context.itemDomElements,labelsRef:S.context.itemLabels,children:re})})]})});let VC={},HC={},qC="";function EW(e){if(typeof document>"u")return!1;const t=Wo(e);return us(t).innerWidth-t.documentElement.clientWidth>0}function AW(e){const t=Wo(e),n=t.documentElement,a=t.body,r=Qo(n)?n:a,o=r.style.overflow;return r.style.overflow="hidden",()=>{r.style.overflow=o}}function TW(e){const t=Wo(e),n=t.documentElement,a=t.body,r=us(n);let o=0,c=0;const u=cr.create(),h=typeof CSS<"u"&&CSS.supports?.("scrollbar-gutter","stable");if(bH&&(r.visualViewport?.scale??1)!==1)return()=>{};function f(){const y=r.getComputedStyle(n),x=r.getComputedStyle(a),T=(y.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,c=n.scrollLeft,VC={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},qC=n.style.scrollBehavior,HC={position:a.style.position,height:a.style.height,width:a.style.width,boxSizing:a.style.boxSizing,overflowY:a.style.overflowY,overflowX:a.style.overflowX,scrollBehavior:a.style.scrollBehavior};const E=n.scrollHeight>n.clientHeight,S=n.scrollWidth>n.clientWidth,k=y.overflowY==="scroll"||x.overflowY==="scroll",N=y.overflowX==="scroll"||x.overflowX==="scroll",A=Math.max(0,r.innerWidth-n.clientWidth),R=Math.max(0,r.innerHeight-n.clientHeight),_=parseFloat(x.marginTop)+parseFloat(x.marginBottom),P=parseFloat(x.marginLeft)+parseFloat(x.marginRight),$=Qo(n)?n:a;if(h){n.style.scrollbarGutter=T,$.style.overflowY="hidden",$.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:T,overflowY:"hidden",overflowX:"hidden"}),(E||k)&&(n.style.overflowY="scroll"),(S||N)&&(n.style.overflowX="scroll"),Object.assign(a.style,{position:"relative",height:_||R?`calc(100dvh - ${_+R}px)`:"100dvh",width:P||A?`calc(100vw - ${P+A}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),a.scrollTop=o,a.scrollLeft=c,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function g(){Object.assign(n.style,VC),Object.assign(a.style,HC),h||(n.scrollTop=o,n.scrollLeft=c,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=qC)}function v(){g(),u.request(f)}return f(),r.addEventListener("resize",v),()=>{u.cancel(),g(),typeof r.removeEventListener=="function"&&r.removeEventListener("resize",v)}}class MW{lockCount=0;restore=null;timeoutLock=bc.create();timeoutUnlock=bc.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const a=Wo(t).documentElement,r=us(a).getComputedStyle(a).overflowY;if(r==="hidden"||r==="clip"){this.restore=aI;return}const o=wH||!EW(t);this.restore=o?AW(t):TW(t)}}const RW=new MW;function IW(e=!0,t=null){ft(()=>{if(e)return RW.acquire(t)},[e,t])}const _W=m.createContext(null);function OW(e){return m.useContext(_W)}function $W(e){const t=m.useRef(""),n=m.useCallback(r=>{r.defaultPrevented||(t.current=r.pointerType,e(r,r.pointerType))},[e]);return{onClick:m.useCallback(r=>{if(r.detail===0){e(r,"keyboard");return}"pointerType"in r&&e(r,r.pointerType),e(r,t.current),t.current=""},[e]),onPointerDown:n}}function PW(e){const[t,n]=m.useState(null),a=pt((u,h)=>{e||n(h)}),r=m.useCallback(()=>{n(null)},[]),{onClick:o,onPointerDown:c}=$W(a);return m.useMemo(()=>({openMethod:t,reset:r,triggerProps:{onClick:o,onPointerDown:c}}),[t,r,o,c])}const DW={...zq,disabled:Nt(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:Nt(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:Nt(e=>e.parent.type==="menu"?e.parent.store.select("allowMouseEnter"):e.allowMouseEnter),stickIfOpen:Nt(e=>e.stickIfOpen),parent:Nt(e=>e.parent),rootId:Nt(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:Nt(e=>e.activeIndex),isActive:Nt((e,t)=>e.activeIndex===t),hoverEnabled:Nt(e=>e.hoverEnabled),instantType:Nt(e=>e.instantType),lastOpenChangeReason:Nt(e=>e.openChangeReason),floatingTreeRoot:Nt(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:Nt(e=>e.floatingNodeId),floatingParentNodeId:Nt(e=>e.floatingParentNodeId),itemProps:Nt(e=>e.itemProps),closeDelay:Nt(e=>e.closeDelay),keyboardEventRelay:Nt(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class aw extends XI{constructor(t){super({...LW(),...t},{positionerRef:m.createRef(),popupRef:m.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:m.createRef(),beforeContentFocusGuardRef:m.createRef(),onOpenChangeComplete:void 0,triggerElements:new sw},DW),this.observe(Nt(n=>n.allowMouseEnter),(n,a)=>{this.state.parent.type==="menu"&&n!==a&&this.state.parent.store.set("allowMouseEnter",n)}),this.unsubscribeParentListener=this.observe("parent",n=>{if(this.unsubscribeParentListener?.(),n.type==="menu"){this.unsubscribeParentListener=n.store.subscribe(()=>{this.notifyAll()}),this.context.allowMouseUpTriggerRef=n.store.context.allowMouseUpTriggerRef;return}n.type!==void 0&&(this.context.allowMouseUpTriggerRef=n.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(t,n){this.state.floatingRootContext.context.events.emit("setOpen",{open:t,eventDetails:n})}static useStore(t,n){return Aa(()=>t??new aw(n)).current}unsubscribeParentListener=null}function LW(){return{...Lq(),disabled:!1,modal:!0,allowMouseEnter:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new OI,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Bs,keyboardEventRelay:void 0,closeDelay:0}}const zW=m.createContext(void 0);function BW(){return m.useContext(zW)}function UW(e){const{children:t,open:n,onOpenChange:a,onOpenChangeComplete:r,defaultOpen:o=!1,disabled:c=!1,modal:u,loopFocus:h=!0,orientation:f="vertical",actionsRef:g,closeParentOnEsc:v=!0,handle:y,triggerId:x,defaultTriggerId:w=null,highlightItemOnHover:C=!0}=e,T=Hp(!0),E=Ic(!0),S=OW(),k=BW(),N=m.useMemo(()=>k&&E?{type:"menu",store:E.store}:S?{type:"menubar",context:S}:T&&!E?{type:"context-menu",context:T}:{type:void 0},[T,E,S,k]),A=aw.useStore(y?.store,{parent:N}),R=A.useState("floatingTreeRoot"),_=o7(R),P=Xi();ft(()=>{T&&!E?A.update({parent:{type:"context-menu",context:T},floatingNodeId:_,floatingParentNodeId:P}):E&&A.update({floatingNodeId:_,floatingParentNodeId:P})},[T,E,_,P,A]),A.useControlledProp("open",n,o),A.useControlledProp("activeTriggerId",x,w),A.useContextCallback("onOpenChangeComplete",r);const $=A.useState("open"),H=A.useState("activeTriggerElement"),I=A.useState("positionerElement"),U=A.useState("hoverEnabled"),D=A.useState("modal"),V=A.useState("disabled"),Z=A.useState("lastOpenChangeReason"),O=A.useState("parent"),z=A.useState("activeIndex"),B=A.useState("payload"),X=A.useState("floatingParentNodeId"),W=m.useRef(null),L=X!=null;let q;A.useSyncedValues({disabled:c,modal:O.type===void 0?u:void 0,rootId:Gi()});const{openMethod:K,triggerProps:ee,reset:G}=PW($);$q(A);const{forceUnmount:re}=Pq($,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0}),G()}),Q=m.useRef(O.type!=="context-menu"),ae=Za();m.useEffect(()=>{if($||(W.current=null),O.type==="context-menu"){if(!$){ae.clear(),Q.current=!1;return}ae.start(500,()=>{Q.current=!0})}},[ae,$,O.type]),IW($&&D&&Z!==Do&&K!=="touch",I),ft(()=>{!$&&!U&&A.set("hoverEnabled",!0)},[$,U,A]);const be=m.useRef(!0),$e=Za(),ge=pt((Y,te)=>{const he=te.reason;if($===Y&&te.trigger===H||(te.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},!Y&&te.trigger==null&&(te.trigger=H??void 0),a?.(Y,te),te.isCanceled))return;const Pe={open:Y,nativeEvent:te.event,reason:te.reason,nested:L};q?.emit("openchange",Pe);const We=te.event;if(Y===!1&&We?.type==="click"&&We.pointerType==="touch"&&!be.current)return;if(!Y&&z!==null){const jt=A.context.itemDomElements.current[z];queueMicrotask(()=>{jt?.setAttribute("tabindex","-1")})}Y&&he===gC?(be.current=!1,$e.start(300,()=>{be.current=!0})):(be.current=!0,$e.clear());const rt=(he===Gm||he===oI)&&We.detail===0&&We?.isTrusted,at=!Y&&(he===lI||he==null);function Ot(){const jt={open:Y,openChangeReason:he};W.current=te.event??null;const bt=te.trigger?.id??null;(bt||Y)&&(jt.activeTriggerId=bt,jt.activeTriggerElement=te.trigger??null),A.update(jt)}he===Do?yr.flushSync(Ot):Ot(),O.type==="menubar"&&(he===gC||he===Wp||he===Do||he===dm||he===Ku)?A.set("instantType","group"):rt||at?A.set("instantType",rt?"click":"dismiss"):A.set("instantType",void 0)}),Te=m.useCallback(Y=>{const te=Wn(Y);return te.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},te},[A]),pe=m.useCallback(()=>{A.setOpen(!1,Te(W9))},[A,Te]);m.useImperativeHandle(g,()=>({unmount:re,close:pe}),[re,pe]);let Xe;O.type==="context-menu"&&(Xe=O.context),m.useImperativeHandle(Xe?.positionerRef,()=>I,[I]),m.useImperativeHandle(Xe?.actionsRef,()=>({setOpen:ge}),[ge]);const Be=Fq({popupStore:A,onOpenChange:ge});q=Be.context.events,m.useEffect(()=>{const Y=({open:te,eventDetails:he})=>ge(te,he);return q.on("setOpen",Y),()=>{q?.off("setOpen",Y)}},[q,ge]);const Se=uq(Be,{enabled:!V,bubbles:v&&O.type==="menu",outsidePress(){return O.type!=="context-menu"||W.current?.type==="contextmenu"?!0:Q.current},externalTree:L?R:void 0}),Me=tW(Be,{role:"menu"}),_e=r_(),Ne=m.useCallback(Y=>{A.select("activeIndex")!==Y&&A.set("activeIndex",Y)},[A]),Oe=Jq(Be,{enabled:!V,listRef:A.context.itemDomElements,activeIndex:z,nested:O.type!==void 0,loopFocus:h,orientation:f,parentOrientation:O.type==="menubar"?O.context.orientation:void 0,rtl:_e==="rtl",disabledIndices:rI,onNavigate:Ne,openOnArrowKeyDown:O.type!=="context-menu",externalTree:L?R:void 0,focusItemOnHover:C}),Ce=m.useCallback(Y=>{A.context.typingRef.current=Y},[A]),Ve=nW(Be,{listRef:A.context.itemLabels,activeIndex:z,resetMs:A9,onMatch:Y=>{$&&Y!==z&&A.set("activeIndex",Y)},onTypingChange:Ce}),{getReferenceProps:Re,getFloatingProps:Ie,getItemProps:De,getTriggerProps:ct}=Kq([Se,Me,Oe,Ve]),ut=m.useMemo(()=>{const Y=qp(Re(),{onMouseEnter(){A.set("hoverEnabled",!0)},onMouseMove(){A.set("allowMouseEnter",!0)}},ee);return delete Y.role,Y},[Re,A,ee]),st=m.useMemo(()=>{const Y=ct();if(!Y)return Y;const{role:te,["aria-controls"]:he,...Pe}=Y;return Pe},[ct]),ht=K0(),yt=m.useMemo(()=>Ie({onMouseEnter(){O.type==="menu"&&ht.request(()=>A.set("hoverEnabled",!1))},onMouseMove(){A.set("allowMouseEnter",!0)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(Y){const te=A.select("keyboardEventRelay");te&&!Y.isPropagationStopped()&&te(Y)}}),[Ie,O.type,ht,A]),Mt=m.useMemo(()=>De(),[De]);A.useSyncedValues({floatingRootContext:Be,activeTriggerProps:ut,inactiveTriggerProps:st,popupProps:yt,itemProps:Mt});const Rt=m.useMemo(()=>({store:A,parent:N}),[A,N]),xt=s.jsx(V0.Provider,{value:Rt,children:typeof t=="function"?t({payload:B}):t});return O.type===void 0||O.type==="context-menu"?s.jsx(c7,{externalTree:R,children:xt}):xt}function o_(e){if(qn(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!fr(e))return o_(vr(e))}const FW=m.forwardRef(function(t,n){const{className:a,render:r,orientation:o="horizontal",...c}=t,u=m.useMemo(()=>({orientation:o}),[o]);return Zi("div",t,{state:u,ref:n,props:[{role:"separator","aria-orientation":o},c]})});function VW(e){const[t,n]=m.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),a=m.useRef(null),r=m.useRef(null),o=m.useRef(null),c=m.useRef(null),u=m.useRef(!0),h=m.useRef(null),f=Gi(),g=m.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:o,backdropRef:a,internalBackdropRef:r,positionerRef:c,allowMouseUpTriggerRef:u,initialCursorPointRef:h,rootId:f}),[t,f]);return s.jsx(XR.Provider,{value:g,children:s.jsx(V0.Provider,{value:void 0,children:s.jsx(UW,{...e})})})}const WC=500,HW=m.forwardRef(function(t,n){const{render:a,className:r,...o}=t,{setAnchor:c,actionsRef:u,internalBackdropRef:h,backdropRef:f,positionerRef:g,allowMouseUpTriggerRef:v,initialCursorPointRef:y,rootId:x}=Hp(!1),{store:w}=Ic(!1),C=w.useState("open"),T=m.useRef(null),E=m.useRef(null),S=Za(),k=Za(),N=m.useRef(!1);function A(U,D,V){const Z=V.type.startsWith("touch");y.current={x:U,y:D},c({getBoundingClientRect(){return DOMRect.fromRect({width:Z?10:0,height:Z?10:0,x:U,y:D})}}),N.current=!1,u.current?.setOpen(!0,Wn(Gm,V)),k.start(WC,()=>{N.current=!0})}function R(U){v.current=!0,ls(U),A(U.clientX,U.clientY,U.nativeEvent),Wo(T.current).addEventListener("mouseup",V=>{if(v.current=!1,!N.current)return;k.clear(),N.current=!1;const Z=zs(V);vn(g.current,Z)||x&&Z&&o_(Z)===x||u.current?.setOpen(!1,Wn(q9,V))},{once:!0})}function _(U){if(v.current=!1,U.touches.length===1){U.stopPropagation();const D=U.touches[0];E.current={x:D.clientX,y:D.clientY},S.start(WC,()=>{E.current&&A(E.current.x,E.current.y,U.nativeEvent)})}}function P(U){if(S.isStarted()&&E.current&&U.touches.length===1){const D=U.touches[0],V=10,Z=Math.abs(D.clientX-E.current.x),O=Math.abs(D.clientY-E.current.y);(Z>V||O>V)&&S.clear()}}function $(){S.clear(),E.current=null}m.useEffect(()=>{function U(V){const O=zs(V);(vn(T.current,O)||vn(h.current,O)||vn(f.current,O))&&V.preventDefault()}const D=Wo(T.current);return D.addEventListener("contextmenu",U),()=>{D.removeEventListener("contextmenu",U)}},[f,h]);const H=m.useMemo(()=>({open:C}),[C]);return Zi("div",t,{state:H,ref:[T,n],props:[{onContextMenu:R,onTouchStart:_,onTouchMove:P,onTouchEnd:$,onTouchCancel:$,style:{WebkitTouchCallout:"none"}},o],stateAttributesMapping:V9})}),rw=m.createContext({});function iw(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const qW=typeof window<"u",l_=qW?m.useLayoutEffect:m.useEffect,eg=m.createContext(null);function ow(e,t){e.indexOf(t)===-1&&e.push(t)}function rp(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const xr=(e,t,n)=>n>t?t:n<e?e:n;let lw=()=>{};const Ui={},c_=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),u_=e=>typeof e=="object"&&e!==null,d_=e=>/^0[^.\s]+$/u.test(e);function f_(e){let t;return()=>(t===void 0&&(t=e()),t)}const Ea=e=>e,qd=(...e)=>e.reduce((t,n)=>a=>n(t(a))),Ad=(e,t,n)=>{const a=t-e;return a?(n-e)/a:1};class cw{constructor(){this.subscriptions=[]}add(t){return ow(this.subscriptions,t),()=>rp(this.subscriptions,t)}notify(t,n,a){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,a);else for(let o=0;o<r;o++){const c=this.subscriptions[o];c&&c(t,n,a)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const na=e=>e*1e3,Sa=e=>e/1e3,h_=(e,t)=>t?e*(1e3/t):0,m_=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,WW=1e-7,GW=12;function ZW(e,t,n,a,r){let o,c,u=0;do c=t+(n-t)/2,o=m_(c,a,r)-e,o>0?n=c:t=c;while(Math.abs(o)>WW&&++u<GW);return c}function Wd(e,t,n,a){if(e===t&&n===a)return Ea;const r=o=>ZW(o,0,1,e,n);return o=>o===0||o===1?o:m_(r(o),t,a)}const p_=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,g_=e=>t=>1-e(1-t),v_=Wd(.33,1.53,.69,.99),uw=g_(v_),y_=p_(uw),x_=e=>e>=1?1:(e*=2)<1?.5*uw(e):.5*(2-Math.pow(2,-10*(e-1))),dw=e=>1-Math.sin(Math.acos(e)),b_=g_(dw),w_=p_(dw),KW=Wd(.42,0,1,1),YW=Wd(0,0,.58,1),j_=Wd(.42,0,.58,1),XW=e=>Array.isArray(e)&&typeof e[0]!="number",N_=e=>Array.isArray(e)&&typeof e[0]=="number",QW={linear:Ea,easeIn:KW,easeInOut:j_,easeOut:YW,circIn:dw,circInOut:w_,circOut:b_,backIn:uw,backInOut:y_,backOut:v_,anticipate:x_},JW=e=>typeof e=="string",GC=e=>{if(N_(e)){lw(e.length===4);const[t,n,a,r]=e;return Wd(t,n,a,r)}else if(JW(e))return QW[e];return e},Ch=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function eG(e,t){let n=new Set,a=new Set,r=!1,o=!1;const c=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function h(g){c.has(g)&&(f.schedule(g),e()),g(u)}const f={schedule:(g,v=!1,y=!1)=>{const w=y&&r?n:a;return v&&c.add(g),w.add(g),g},cancel:g=>{a.delete(g),c.delete(g)},process:g=>{if(u=g,r){o=!0;return}r=!0;const v=n;n=a,a=v,n.forEach(h),n.clear(),r=!1,o&&(o=!1,f.process(g))}};return f}const tG=40;function k_(e,t){let n=!1,a=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,c=Ch.reduce((k,N)=>(k[N]=eG(o),k),{}),{setup:u,read:h,resolveKeyframes:f,preUpdate:g,update:v,preRender:y,render:x,postRender:w}=c,C=()=>{const k=Ui.useManualTiming,N=k?r.timestamp:performance.now();n=!1,k||(r.delta=a?1e3/60:Math.max(Math.min(N-r.timestamp,tG),1)),r.timestamp=N,r.isProcessing=!0,u.process(r),h.process(r),f.process(r),g.process(r),v.process(r),y.process(r),x.process(r),w.process(r),r.isProcessing=!1,n&&t&&(a=!1,e(C))},T=()=>{n=!0,a=!0,r.isProcessing||e(C)};return{schedule:Ch.reduce((k,N)=>{const A=c[N];return k[N]=(R,_=!1,P=!1)=>(n||T(),A.schedule(R,_,P)),k},{}),cancel:k=>{for(let N=0;N<Ch.length;N++)c[Ch[N]].cancel(k)},state:r,steps:c}}const{schedule:ln,cancel:Fi,state:is,steps:Wy}=k_(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ea,!0);let mm;function nG(){mm=void 0}const As={now:()=>(mm===void 0&&As.set(is.isProcessing||Ui.useManualTiming?is.timestamp:performance.now()),mm),set:e=>{mm=e,queueMicrotask(nG)}},S_=e=>t=>typeof t=="string"&&t.startsWith(e),C_=S_("--"),sG=S_("var(--"),fw=e=>sG(e)?aG.test(e.split("/*")[0].trim()):!1,aG=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function ZC(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const $c={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Td={...$c,transform:e=>xr(0,1,e)},Eh={...$c,default:1},od=e=>Math.round(e*1e5)/1e5,hw=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function rG(e){return e==null}const iG=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,mw=(e,t)=>n=>!!(typeof n=="string"&&iG.test(n)&&n.startsWith(e)||t&&!rG(n)&&Object.prototype.hasOwnProperty.call(n,t)),E_=(e,t,n)=>a=>{if(typeof a!="string")return a;const[r,o,c,u]=a.match(hw);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(c),alpha:u!==void 0?parseFloat(u):1}},oG=e=>xr(0,255,e),Gy={...$c,transform:e=>Math.round(oG(e))},Oo={test:mw("rgb","red"),parse:E_("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:a=1})=>"rgba("+Gy.transform(e)+", "+Gy.transform(t)+", "+Gy.transform(n)+", "+od(Td.transform(a))+")"};function lG(e){let t="",n="",a="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),a=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),a=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,a+=a,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(a,16),alpha:r?parseInt(r,16)/255:1}}const fb={test:mw("#"),parse:lG,transform:Oo.transform},Gd=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Vr=Gd("deg"),mr=Gd("%"),Ke=Gd("px"),cG=Gd("vh"),uG=Gd("vw"),KC={...mr,parse:e=>mr.parse(e)/100,transform:e=>mr.transform(e*100)},nc={test:mw("hsl","hue"),parse:E_("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:a=1})=>"hsla("+Math.round(e)+", "+mr.transform(od(t))+", "+mr.transform(od(n))+", "+od(Td.transform(a))+")"},Hn={test:e=>Oo.test(e)||fb.test(e)||nc.test(e),parse:e=>Oo.test(e)?Oo.parse(e):nc.test(e)?nc.parse(e):fb.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Oo.transform(e):nc.transform(e),getAnimatableNone:e=>{const t=Hn.parse(e);return t.alpha=0,Hn.transform(t)}},dG=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function fG(e){return isNaN(e)&&typeof e=="string"&&(e.match(hw)?.length||0)+(e.match(dG)?.length||0)>0}const A_="number",T_="color",hG="var",mG="var(",YC="${}",pG=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Nc(e){const t=e.toString(),n=[],a={color:[],number:[],var:[]},r=[];let o=0;const u=t.replace(pG,h=>(Hn.test(h)?(a.color.push(o),r.push(T_),n.push(Hn.parse(h))):h.startsWith(mG)?(a.var.push(o),r.push(hG),n.push(h)):(a.number.push(o),r.push(A_),n.push(parseFloat(h))),++o,YC)).split(YC);return{values:n,split:u,indexes:a,types:r}}function gG(e){return Nc(e).values}function M_({split:e,types:t}){const n=e.length;return a=>{let r="";for(let o=0;o<n;o++)if(r+=e[o],a[o]!==void 0){const c=t[o];c===A_?r+=od(a[o]):c===T_?r+=Hn.transform(a[o]):r+=a[o]}return r}}function vG(e){return M_(Nc(e))}const yG=e=>typeof e=="number"?0:Hn.test(e)?Hn.getAnimatableNone(e):e,xG=(e,t)=>typeof e=="number"?t?.trim().endsWith("/")?e:0:yG(e);function bG(e){const t=Nc(e);return M_(t)(t.values.map((a,r)=>xG(a,t.split[r])))}const qa={test:fG,parse:gG,createTransformer:vG,getAnimatableNone:bG};function Zy(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function wG({hue:e,saturation:t,lightness:n,alpha:a}){e/=360,t/=100,n/=100;let r=0,o=0,c=0;if(!t)r=o=c=n;else{const u=n<.5?n*(1+t):n+t-n*t,h=2*n-u;r=Zy(h,u,e+1/3),o=Zy(h,u,e),c=Zy(h,u,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(c*255),alpha:a}}function ip(e,t){return n=>n>0?t:e}const on=(e,t,n)=>e+(t-e)*n,Ky=(e,t,n)=>{const a=e*e,r=n*(t*t-a)+a;return r<0?0:Math.sqrt(r)},jG=[fb,Oo,nc],NG=e=>jG.find(t=>t.test(e));function XC(e){const t=NG(e);if(!t)return!1;let n=t.parse(e);return t===nc&&(n=wG(n)),n}const QC=(e,t)=>{const n=XC(e),a=XC(t);if(!n||!a)return ip(e,t);const r={...n};return o=>(r.red=Ky(n.red,a.red,o),r.green=Ky(n.green,a.green,o),r.blue=Ky(n.blue,a.blue,o),r.alpha=on(n.alpha,a.alpha,o),Oo.transform(r))},hb=new Set(["none","hidden"]);function kG(e,t){return hb.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function SG(e,t){return n=>on(e,t,n)}function pw(e){return typeof e=="number"?SG:typeof e=="string"?fw(e)?ip:Hn.test(e)?QC:AG:Array.isArray(e)?R_:typeof e=="object"?Hn.test(e)?QC:CG:ip}function R_(e,t){const n=[...e],a=n.length,r=e.map((o,c)=>pw(o)(o,t[c]));return o=>{for(let c=0;c<a;c++)n[c]=r[c](o);return n}}function CG(e,t){const n={...e,...t},a={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(a[r]=pw(e[r])(e[r],t[r]));return r=>{for(const o in a)n[o]=a[o](r);return n}}function EG(e,t){const n=[],a={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const o=t.types[r],c=e.indexes[o][a[o]],u=e.values[c]??0;n[r]=u,a[o]++}return n}const AG=(e,t)=>{const n=qa.createTransformer(t),a=Nc(e),r=Nc(t);return a.indexes.var.length===r.indexes.var.length&&a.indexes.color.length===r.indexes.color.length&&a.indexes.number.length>=r.indexes.number.length?hb.has(e)&&!r.values.length||hb.has(t)&&!a.values.length?kG(e,t):qd(R_(EG(a,r),r.values),n):ip(e,t)};function I_(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?on(e,t,n):pw(e)(e,t)}const TG=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ln.update(t,n),stop:()=>Fi(t),now:()=>is.isProcessing?is.timestamp:As.now()}},__=(e,t,n=10)=>{let a="";const r=Math.max(Math.round(t/n),2);for(let o=0;o<r;o++)a+=Math.round(e(o/(r-1))*1e4)/1e4+", ";return`linear(${a.substring(0,a.length-2)})`},op=2e4;function gw(e){let t=0;const n=50;let a=e.next(t);for(;!a.done&&t<op;)t+=n,a=e.next(t);return t>=op?1/0:t}function MG(e,t=100,n){const a=n({...e,keyframes:[0,t]}),r=Math.min(gw(a),op);return{type:"keyframes",ease:o=>a.next(r*o).value/t,duration:Sa(r)}}const An={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function mb(e,t){return e*Math.sqrt(1-t*t)}const RG=12;function IG(e,t,n){let a=n;for(let r=1;r<RG;r++)a=a-e(a)/t(a);return a}const Yy=.001;function _G({duration:e=An.duration,bounce:t=An.bounce,velocity:n=An.velocity,mass:a=An.mass}){let r,o,c=1-t;c=xr(An.minDamping,An.maxDamping,c),e=xr(An.minDuration,An.maxDuration,Sa(e)),c<1?(r=f=>{const g=f*c,v=g*e,y=g-n,x=mb(f,c),w=Math.exp(-v);return Yy-y/x*w},o=f=>{const v=f*c*e,y=v*n+n,x=Math.pow(c,2)*Math.pow(f,2)*e,w=Math.exp(-v),C=mb(Math.pow(f,2),c);return(-r(f)+Yy>0?-1:1)*((y-x)*w)/C}):(r=f=>{const g=Math.exp(-f*e),v=(f-n)*e+1;return-Yy+g*v},o=f=>{const g=Math.exp(-f*e),v=(n-f)*(e*e);return g*v});const u=5/e,h=IG(r,o,u);if(e=na(e),isNaN(h))return{stiffness:An.stiffness,damping:An.damping,duration:e};{const f=Math.pow(h,2)*a;return{stiffness:f,damping:c*2*Math.sqrt(a*f),duration:e}}}const OG=["duration","bounce"],$G=["stiffness","damping","mass"];function JC(e,t){return t.some(n=>e[n]!==void 0)}function PG(e){let t={velocity:An.velocity,stiffness:An.stiffness,damping:An.damping,mass:An.mass,isResolvedFromDuration:!1,...e};if(!JC(e,$G)&&JC(e,OG))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,a=2*Math.PI/(n*1.2),r=a*a,o=2*xr(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:An.mass,stiffness:r,damping:o}}else{const n=_G({...e,velocity:0});t={...t,...n,mass:An.mass},t.isResolvedFromDuration=!0}return t}function lp(e=An.visualDuration,t=An.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:a,restDelta:r}=n;const o=n.keyframes[0],c=n.keyframes[n.keyframes.length-1],u={done:!1,value:o},{stiffness:h,damping:f,mass:g,duration:v,velocity:y,isResolvedFromDuration:x}=PG({...n,velocity:-Sa(n.velocity||0)}),w=y||0,C=f/(2*Math.sqrt(h*g)),T=c-o,E=Sa(Math.sqrt(h/g)),S=Math.abs(T)<5;a||(a=S?An.restSpeed.granular:An.restSpeed.default),r||(r=S?An.restDelta.granular:An.restDelta.default);let k,N,A,R,_,P;if(C<1)A=mb(E,C),R=(w+C*E*T)/A,k=H=>{const I=Math.exp(-C*E*H);return c-I*(R*Math.sin(A*H)+T*Math.cos(A*H))},_=C*E*R+T*A,P=C*E*T-R*A,N=H=>Math.exp(-C*E*H)*(_*Math.sin(A*H)+P*Math.cos(A*H));else if(C===1){k=I=>c-Math.exp(-E*I)*(T+(w+E*T)*I);const H=w+E*T;N=I=>Math.exp(-E*I)*(E*H*I-w)}else{const H=E*Math.sqrt(C*C-1);k=V=>{const Z=Math.exp(-C*E*V),O=Math.min(H*V,300);return c-Z*((w+C*E*T)*Math.sinh(O)+H*T*Math.cosh(O))/H};const I=(w+C*E*T)/H,U=C*E*I-T*H,D=C*E*T-I*H;N=V=>{const Z=Math.exp(-C*E*V),O=Math.min(H*V,300);return Z*(U*Math.sinh(O)+D*Math.cosh(O))}}const $={calculatedDuration:x&&v||null,velocity:H=>na(N(H)),next:H=>{if(!x&&C<1){const U=Math.exp(-C*E*H),D=Math.sin(A*H),V=Math.cos(A*H),Z=c-U*(R*D+T*V),O=na(U*(_*D+P*V));return u.done=Math.abs(O)<=a&&Math.abs(c-Z)<=r,u.value=u.done?c:Z,u}const I=k(H);if(x)u.done=H>=v;else{const U=na(N(H));u.done=Math.abs(U)<=a&&Math.abs(c-I)<=r}return u.value=u.done?c:I,u},toString:()=>{const H=Math.min(gw($),op),I=__(U=>$.next(H*U).value,H,30);return H+"ms "+I},toTransition:()=>{}};return $}lp.applyToOptions=e=>{const t=MG(e,100,lp);return e.ease=t.ease,e.duration=na(t.duration),e.type="keyframes",e};const DG=5;function O_(e,t,n){const a=Math.max(t-DG,0);return h_(n-e(a),t-a)}function pb({keyframes:e,velocity:t=0,power:n=.8,timeConstant:a=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:c,min:u,max:h,restDelta:f=.5,restSpeed:g}){const v=e[0],y={done:!1,value:v},x=P=>u!==void 0&&P<u||h!==void 0&&P>h,w=P=>u===void 0?h:h===void 0||Math.abs(u-P)<Math.abs(h-P)?u:h;let C=n*t;const T=v+C,E=c===void 0?T:c(T);E!==T&&(C=E-v);const S=P=>-C*Math.exp(-P/a),k=P=>E+S(P),N=P=>{const $=S(P),H=k(P);y.done=Math.abs($)<=f,y.value=y.done?E:H};let A,R;const _=P=>{x(y.value)&&(A=P,R=lp({keyframes:[y.value,w(y.value)],velocity:O_(k,P,y.value),damping:r,stiffness:o,restDelta:f,restSpeed:g}))};return _(0),{calculatedDuration:null,next:P=>{let $=!1;return!R&&A===void 0&&($=!0,N(P),_(P)),A!==void 0&&P>=A?R.next(P-A):(!$&&N(P),y)}}}function LG(e,t,n){const a=[],r=n||Ui.mix||I_,o=e.length-1;for(let c=0;c<o;c++){let u=r(e[c],e[c+1]);if(t){const h=Array.isArray(t)?t[c]||Ea:t;u=qd(h,u)}a.push(u)}return a}function zG(e,t,{clamp:n=!0,ease:a,mixer:r}={}){const o=e.length;if(lw(o===t.length),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const c=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const u=LG(t,a,r),h=u.length,f=g=>{if(c&&g<e[0])return t[0];let v=0;if(h>1)for(;v<e.length-2&&!(g<e[v+1]);v++);const y=Ad(e[v],e[v+1],g);return u[v](y)};return n?g=>f(xr(e[0],e[o-1],g)):f}function BG(e,t){const n=e[e.length-1];for(let a=1;a<=t;a++){const r=Ad(0,t,a);e.push(on(n,1,r))}}function UG(e){const t=[0];return BG(t,e.length-1),t}function FG(e,t){return e.map(n=>n*t)}function VG(e,t){return e.map(()=>t||j_).splice(0,e.length-1)}function ld({duration:e=300,keyframes:t,times:n,ease:a="easeInOut"}){const r=XW(a)?a.map(GC):GC(a),o={done:!1,value:t[0]},c=FG(n&&n.length===t.length?n:UG(t),e),u=zG(c,t,{ease:Array.isArray(r)?r:VG(t,r)});return{calculatedDuration:e,next:h=>(o.value=u(h),o.done=h>=e,o)}}const HG=e=>e!==null;function tg(e,{repeat:t,repeatType:n="loop"},a,r=1){const o=e.filter(HG),u=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!u||a===void 0?o[u]:a}const qG={decay:pb,inertia:pb,tween:ld,keyframes:ld,spring:lp};function $_(e){typeof e.type=="string"&&(e.type=qG[e.type])}class vw{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const WG=e=>e/100;class cp extends vw{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==As.now()&&this.tick(As.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;$_(t);const{type:n=ld,repeat:a=0,repeatDelay:r=0,repeatType:o,velocity:c=0}=t;let{keyframes:u}=t;const h=n||ld;h!==ld&&typeof u[0]!="number"&&(this.mixKeyframes=qd(WG,I_(u[0],u[1])),u=[0,100]);const f=h({...t,keyframes:u});o==="mirror"&&(this.mirroredGenerator=h({...t,keyframes:[...u].reverse(),velocity:-c})),f.calculatedDuration===null&&(f.calculatedDuration=gw(f));const{calculatedDuration:g}=f;this.calculatedDuration=g,this.resolvedDuration=g+r,this.totalDuration=this.resolvedDuration*(a+1)-r,this.generator=f}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:a,totalDuration:r,mixKeyframes:o,mirroredGenerator:c,resolvedDuration:u,calculatedDuration:h}=this;if(this.startTime===null)return a.next(0);const{delay:f=0,keyframes:g,repeat:v,repeatType:y,repeatDelay:x,type:w,onUpdate:C,finalKeyframe:T}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-r/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const E=this.currentTime-f*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?E<0:E>r;this.currentTime=Math.max(E,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let k=this.currentTime,N=a;if(v){const P=Math.min(this.currentTime,r)/u;let $=Math.floor(P),H=P%1;!H&&P>=1&&(H=1),H===1&&$--,$=Math.min($,v+1),$%2&&(y==="reverse"?(H=1-H,x&&(H-=x/u)):y==="mirror"&&(N=c)),k=xr(0,1,H)*u}let A;S?(this.delayState.value=g[0],A=this.delayState):A=N.next(k),o&&!S&&(A.value=o(A.value));let{done:R}=A;!S&&h!==null&&(R=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const _=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&R);return _&&w!==pb&&(A.value=tg(g,this.options,T,this.speed)),C&&C(A.value),_&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return Sa(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Sa(t)}get time(){return Sa(this.currentTime)}set time(t){t=na(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return O_(a=>this.generator.next(a).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(As.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=Sa(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=TG,startTime:n}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),this.options.onPlay?.();const a=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=a):this.holdTime!==null?this.startTime=a-this.holdTime:this.startTime||(this.startTime=n??a),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(As.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function GG(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const $o=e=>e*180/Math.PI,gb=e=>{const t=$o(Math.atan2(e[1],e[0]));return vb(t)},ZG={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:gb,rotateZ:gb,skewX:e=>$o(Math.atan(e[1])),skewY:e=>$o(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},vb=e=>(e=e%360,e<0&&(e+=360),e),eE=gb,tE=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),nE=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),KG={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:tE,scaleY:nE,scale:e=>(tE(e)+nE(e))/2,rotateX:e=>vb($o(Math.atan2(e[6],e[5]))),rotateY:e=>vb($o(Math.atan2(-e[2],e[0]))),rotateZ:eE,rotate:eE,skewX:e=>$o(Math.atan(e[4])),skewY:e=>$o(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function yb(e){return e.includes("scale")?1:0}function xb(e,t){if(!e||e==="none")return yb(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let a,r;if(n)a=KG,r=n;else{const u=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);a=ZG,r=u}if(!r)return yb(t);const o=a[t],c=r[1].split(",").map(XG);return typeof o=="function"?o(c):c[o]}const YG=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return xb(n,t)};function XG(e){return parseFloat(e.trim())}const Pc=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Dc=new Set([...Pc,"pathRotation"]),sE=e=>e===$c||e===Ke,QG=new Set(["x","y","z"]),JG=Pc.filter(e=>!QG.has(e));function eZ(e){const t=[];return JG.forEach(n=>{const a=e.getValue(n);a!==void 0&&(t.push([n,a.get()]),a.set(n.startsWith("scale")?1:0))}),t}const Ii={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:a})=>{const r=e.max-e.min;return a==="border-box"?r:r-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:a})=>{const r=e.max-e.min;return a==="border-box"?r:r-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>xb(t,"x"),y:(e,{transform:t})=>xb(t,"y")};Ii.translateX=Ii.x;Ii.translateY=Ii.y;const Lo=new Set;let bb=!1,wb=!1,jb=!1;function P_(){if(wb){const e=Array.from(Lo).filter(a=>a.needsMeasurement),t=new Set(e.map(a=>a.element)),n=new Map;t.forEach(a=>{const r=eZ(a);r.length&&(n.set(a,r),a.render())}),e.forEach(a=>a.measureInitialState()),t.forEach(a=>{a.render();const r=n.get(a);r&&r.forEach(([o,c])=>{a.getValue(o)?.set(c)})}),e.forEach(a=>a.measureEndState()),e.forEach(a=>{a.suspendedScrollY!==void 0&&window.scrollTo(0,a.suspendedScrollY)})}wb=!1,bb=!1,Lo.forEach(e=>e.complete(jb)),Lo.clear()}function D_(){Lo.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(wb=!0)})}function tZ(){jb=!0,D_(),P_(),jb=!1}class yw{constructor(t,n,a,r,o,c=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=a,this.motionValue=r,this.element=o,this.isAsync=c}scheduleResolve(){this.state="scheduled",this.isAsync?(Lo.add(this),bb||(bb=!0,ln.read(D_),ln.resolveKeyframes(P_))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:a,motionValue:r}=this;if(t[0]===null){const o=r?.get(),c=t[t.length-1];if(o!==void 0)t[0]=o;else if(a&&n){const u=a.readValue(n,c);u!=null&&(t[0]=u)}t[0]===void 0&&(t[0]=c),r&&o===void 0&&r.set(t[0])}GG(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Lo.delete(this)}cancel(){this.state==="scheduled"&&(Lo.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const nZ=e=>e.startsWith("--");function L_(e,t,n){nZ(t)?e.style.setProperty(t,n):e.style[t]=n}const sZ={};function z_(e,t){const n=f_(e);return()=>sZ[t]??n()}const aZ=z_(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),B_=z_(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Yu=([e,t,n,a])=>`cubic-bezier(${e}, ${t}, ${n}, ${a})`,aE={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Yu([0,.65,.55,1]),circOut:Yu([.55,0,1,.45]),backIn:Yu([.31,.01,.66,-.59]),backOut:Yu([.33,1.53,.69,.99])};function U_(e,t){if(e)return typeof e=="function"?B_()?__(e,t):"ease-out":N_(e)?Yu(e):Array.isArray(e)?e.map(n=>U_(n,t)||aE.easeOut):aE[e]}function rZ(e,t,n,{delay:a=0,duration:r=300,repeat:o=0,repeatType:c="loop",ease:u="easeOut",times:h}={},f=void 0){const g={[t]:n};h&&(g.offset=h);const v=U_(u,r);Array.isArray(v)&&(g.easing=v);const y={delay:a,duration:r,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:o+1,direction:c==="reverse"?"alternate":"normal"};return f&&(y.pseudoElement=f),e.animate(g,y)}function F_(e){return typeof e=="function"&&"applyToOptions"in e}function iZ({type:e,...t}){return F_(e)&&B_()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class V_ extends vw{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:a,keyframes:r,pseudoElement:o,allowFlatten:c=!1,finalKeyframe:u,onComplete:h}=t;this.isPseudoElement=!!o,this.allowFlatten=c,this.options=t,lw(typeof t.type!="string");const f=iZ(t);this.animation=rZ(n,a,r,f,o),f.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const g=tg(r,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(g),L_(n,a,g),this.animation.cancel()}h?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const t=this.options?.element;!this.isPseudoElement&&t?.isConnected&&this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return Sa(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Sa(t)}get time(){return Sa(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=na(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:a,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&aZ()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),a&&(this.animation.rangeEnd=a),Ea):r(this)}}const H_={anticipate:x_,backInOut:y_,circInOut:w_};function oZ(e){return e in H_}function lZ(e){typeof e.ease=="string"&&oZ(e.ease)&&(e.ease=H_[e.ease])}const Xy=10;class cZ extends V_{constructor(t){lZ(t),$_(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:a,onComplete:r,element:o,...c}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const u=new cp({...c,autoplay:!1}),h=Math.max(Xy,As.now()-this.startTime),f=xr(0,Xy,h-Xy),g=u.sample(h).value,{name:v}=this.options;o&&v&&L_(o,v,g),n.setWithVelocity(u.sample(Math.max(0,h-f)).value,g,f),u.stop()}}const rE=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(qa.test(e)||e==="0")&&!e.startsWith("url("));function uZ(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function dZ(e,t,n,a){const r=e[0];if(r===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],c=rE(r,t),u=rE(o,t);return!c||!u?!1:uZ(e)||(n==="spring"||F_(n))&&a}function Nb(e){e.duration=0,e.type="keyframes"}const q_=new Set(["opacity","clipPath","filter","transform"]),fZ=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function hZ(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&fZ.test(e[t]))return!0;return!1}const mZ=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),pZ=f_(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function gZ(e){const{motionValue:t,name:n,repeatDelay:a,repeatType:r,damping:o,type:c,keyframes:u}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:f,transformTemplate:g}=t.owner.getProps();return pZ()&&n&&(q_.has(n)||mZ.has(n)&&hZ(u))&&(n!=="transform"||!g)&&!f&&!a&&r!=="mirror"&&o!==0&&c!=="inertia"}const vZ=40;class yZ extends vw{constructor({autoplay:t=!0,delay:n=0,type:a="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:c="loop",keyframes:u,name:h,motionValue:f,element:g,...v}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=As.now();const y={autoplay:t,delay:n,type:a,repeat:r,repeatDelay:o,repeatType:c,name:h,motionValue:f,element:g,...v},x=g?.KeyframeResolver||yw;this.keyframeResolver=new x(u,(w,C,T)=>this.onKeyframesResolved(w,C,y,!T),h,f,g),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,a,r){this.keyframeResolver=void 0;const{name:o,type:c,velocity:u,delay:h,isHandoff:f,onUpdate:g}=a;this.resolvedAt=As.now();let v=!0;dZ(t,o,c,u)||(v=!1,(Ui.instantAnimations||!h)&&g?.(tg(t,a,n)),t[0]=t[t.length-1],Nb(a),a.repeat=0);const x={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>vZ?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...a,keyframes:t},w=v&&!f&&gZ(x),C=x.motionValue?.owner?.current;let T;if(w)try{T=new cZ({...x,element:C})}catch{T=new cp(x)}else T=new cp(x);T.finished.then(()=>{this.notifyFinished()}).catch(Ea),this.pendingTimeline&&(this.stopTimeline=T.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=T}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),tZ()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function W_(e,t,n,a=0,r=1){const o=Array.from(e).sort((f,g)=>f.sortNodePosition(g)).indexOf(t),c=e.size,u=(c-1)*a;return typeof n=="function"?n(o,c):r===1?o*a:u-o*a}const iE=30,xZ=e=>!isNaN(parseFloat(e));class bZ{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=a=>{const r=As.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(a),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=As.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=xZ(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new cw);const a=this.events[t].add(n);return t==="change"?()=>{a(),ln.read(()=>{this.events.change.getSize()||this.stop()})}:a}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,a){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-a}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=As.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>iE)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,iE);return h_(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function kc(e,t){return new bZ(e,t)}function G_(e,t){if(e?.inherit&&t){const{inherit:n,...a}=e;return{...t,...a}}return e}function xw(e,t){const n=e?.[t]??e?.default??e;return n!==e?G_(n,e):n}const wZ={type:"spring",stiffness:500,damping:25,restSpeed:10},jZ=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),NZ={type:"keyframes",duration:.8},kZ={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},SZ=(e,{keyframes:t})=>t.length>2?NZ:Dc.has(e)?e.startsWith("scale")?jZ(t[1]):wZ:kZ,CZ=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function EZ(e){for(const t in e)if(!CZ.has(t))return!0;return!1}const bw=(e,t,n,a={},r,o)=>c=>{const u=xw(a,e)||{},h=u.delay||a.delay||0;let{elapsed:f=0}=a;f=f-na(h);const g={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...u,delay:-f,onUpdate:y=>{t.set(y),u.onUpdate&&u.onUpdate(y)},onComplete:()=>{c(),u.onComplete&&u.onComplete()},name:e,motionValue:t,element:o?void 0:r};EZ(u)||Object.assign(g,SZ(e,g)),g.duration&&(g.duration=na(g.duration)),g.repeatDelay&&(g.repeatDelay=na(g.repeatDelay)),g.from!==void 0&&(g.keyframes[0]=g.from);let v=!1;if((g.type===!1||g.duration===0&&!g.repeatDelay)&&(Nb(g),g.delay===0&&(v=!0)),(Ui.instantAnimations||Ui.skipAnimations||r?.shouldSkipAnimations||u.skipAnimations)&&(v=!0,Nb(g),g.delay=0),g.allowFlatten=!u.type&&!u.ease,v&&!o&&t.get()!==void 0){const y=tg(g.keyframes,u);if(y!==void 0){ln.update(()=>{g.onUpdate(y),g.onComplete()});return}}return u.isSync?new cp(g):new yZ(g)},AZ=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function TZ(e){const t=AZ.exec(e);if(!t)return[,];const[,n,a,r]=t;return[`--${n??a}`,r]}function Z_(e,t,n=1){const[a,r]=TZ(e);if(!a)return;const o=window.getComputedStyle(t).getPropertyValue(a);if(o){const c=o.trim();return c_(c)?parseFloat(c):c}return fw(r)?Z_(r,t,n+1):r}function oE(e){const t=[{},{}];return e?.values.forEach((n,a)=>{t[0][a]=n.get(),t[1][a]=n.getVelocity()}),t}function ww(e,t,n,a){if(typeof t=="function"){const[r,o]=oE(a);t=t(n!==void 0?n:e.custom,r,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,o]=oE(a);t=t(n!==void 0?n:e.custom,r,o)}return t}function zo(e,t,n){const a=e.getProps();return ww(a,t,n!==void 0?n:a.custom,e)}const K_=new Set(["width","height","top","left","right","bottom",...Pc]),kb=e=>Array.isArray(e);function MZ(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,kc(n))}function RZ(e){return kb(e)?e[e.length-1]||0:e}function IZ(e,t){const n=zo(e,t);let{transitionEnd:a={},transition:r={},...o}=n||{};o={...o,...a};for(const c in o){const u=RZ(o[c]);MZ(e,c,u)}}const cs=e=>!!(e&&e.getVelocity);function _Z(e){return!!(cs(e)&&e.add)}function Sb(e,t){const n=e.getValue("willChange");if(_Z(n))return n.add(t);if(!n&&Ui.WillChange){const a=new Ui.WillChange("auto");e.addValue("willChange",a),a.add(t)}}function jw(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const OZ="framerAppearId",Y_="data-"+jw(OZ);function X_(e){return e.props[Y_]}function $Z({protectedKeys:e,needsAnimating:t},n){const a=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,a}function Q_(e,t,{delay:n=0,transitionOverride:a,type:r}={}){let{transition:o,transitionEnd:c,...u}=t;const h=e.getDefaultTransition();o=o?G_(o,h):h;const f=o?.reduceMotion,g=o?.skipAnimations;a&&(o=a);const v=[],y=r&&e.animationState&&e.animationState.getState()[r],x=o?.path;x&&x.animateVisualElement(e,u,o,n,v);for(const w in u){const C=e.getValue(w,e.latestValues[w]??null),T=u[w];if(T===void 0||y&&$Z(y,w))continue;const E={delay:n,...xw(o||{},w)};g&&(E.skipAnimations=!0);const S=C.get();if(S!==void 0&&!C.isAnimating()&&!Array.isArray(T)&&T===S&&!E.velocity){ln.update(()=>C.set(T));continue}let k=!1;if(window.MotionHandoffAnimation){const R=X_(e);if(R){const _=window.MotionHandoffAnimation(R,w,ln);_!==null&&(E.startTime=_,k=!0)}}Sb(e,w);const N=f??e.shouldReduceMotion;C.start(bw(w,C,T,N&&K_.has(w)?{type:!1}:E,e,k));const A=C.animation;A&&v.push(A)}if(c){const w=()=>ln.update(()=>{c&&IZ(e,c)});v.length?Promise.all(v).then(w):w()}return v}function Cb(e,t,n={}){const a=zo(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=a||{};n.transitionOverride&&(r=n.transitionOverride);const o=a?()=>Promise.all(Q_(e,a,n)):()=>Promise.resolve(),c=e.variantChildren&&e.variantChildren.size?(h=0)=>{const{delayChildren:f=0,staggerChildren:g,staggerDirection:v}=r;return PZ(e,t,h,f,g,v,n)}:()=>Promise.resolve(),{when:u}=r;if(u){const[h,f]=u==="beforeChildren"?[o,c]:[c,o];return h().then(()=>f())}else return Promise.all([o(),c(n.delay)])}function PZ(e,t,n=0,a=0,r=0,o=1,c){const u=[];for(const h of e.variantChildren)h.notify("AnimationStart",t),u.push(Cb(h,t,{...c,delay:n+(typeof a=="function"?0:a)+W_(e.variantChildren,h,a,r,o)}).then(()=>h.notify("AnimationComplete",t)));return Promise.all(u)}function DZ(e,t,n={}){e.notify("AnimationStart",t);let a;if(Array.isArray(t)){const r=t.map(o=>Cb(e,o,n));a=Promise.all(r)}else if(typeof t=="string")a=Cb(e,t,n);else{const r=typeof t=="function"?zo(e,t,n.custom):t;a=Promise.all(Q_(e,r,n))}return a.then(()=>{e.notify("AnimationComplete",t)})}const LZ={test:e=>e==="auto",parse:e=>e},J_=e=>t=>t.test(e),eO=[$c,Ke,mr,Vr,uG,cG,LZ],lE=e=>eO.find(J_(e));function zZ(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||d_(e):!0}const BZ=new Set(["brightness","contrast","saturate","opacity"]);function UZ(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[a]=n.match(hw)||[];if(!a)return e;const r=n.replace(a,"");let o=BZ.has(t)?1:0;return a!==n&&(o*=100),t+"("+o+r+")"}const FZ=/\b([a-z-]*)\(.*?\)/gu,Eb={...qa,getAnimatableNone:e=>{const t=e.match(FZ);return t?t.map(UZ).join(" "):e}},Ab={...qa,getAnimatableNone:e=>{const t=qa.parse(e);return qa.createTransformer(e)(t.map(a=>typeof a=="number"?0:typeof a=="object"?{...a,alpha:1}:a))}},cE={...$c,transform:Math.round},VZ={rotate:Vr,pathRotation:Vr,rotateX:Vr,rotateY:Vr,rotateZ:Vr,scale:Eh,scaleX:Eh,scaleY:Eh,scaleZ:Eh,skew:Vr,skewX:Vr,skewY:Vr,distance:Ke,translateX:Ke,translateY:Ke,translateZ:Ke,x:Ke,y:Ke,z:Ke,perspective:Ke,transformPerspective:Ke,opacity:Td,originX:KC,originY:KC,originZ:Ke},up={borderWidth:Ke,borderTopWidth:Ke,borderRightWidth:Ke,borderBottomWidth:Ke,borderLeftWidth:Ke,borderRadius:Ke,borderTopLeftRadius:Ke,borderTopRightRadius:Ke,borderBottomRightRadius:Ke,borderBottomLeftRadius:Ke,width:Ke,maxWidth:Ke,height:Ke,maxHeight:Ke,top:Ke,right:Ke,bottom:Ke,left:Ke,inset:Ke,insetBlock:Ke,insetBlockStart:Ke,insetBlockEnd:Ke,insetInline:Ke,insetInlineStart:Ke,insetInlineEnd:Ke,padding:Ke,paddingTop:Ke,paddingRight:Ke,paddingBottom:Ke,paddingLeft:Ke,paddingBlock:Ke,paddingBlockStart:Ke,paddingBlockEnd:Ke,paddingInline:Ke,paddingInlineStart:Ke,paddingInlineEnd:Ke,margin:Ke,marginTop:Ke,marginRight:Ke,marginBottom:Ke,marginLeft:Ke,marginBlock:Ke,marginBlockStart:Ke,marginBlockEnd:Ke,marginInline:Ke,marginInlineStart:Ke,marginInlineEnd:Ke,fontSize:Ke,backgroundPositionX:Ke,backgroundPositionY:Ke,...VZ,zIndex:cE,fillOpacity:Td,strokeOpacity:Td,numOctaves:cE},HZ={...up,color:Hn,backgroundColor:Hn,outlineColor:Hn,fill:Hn,stroke:Hn,borderColor:Hn,borderTopColor:Hn,borderRightColor:Hn,borderBottomColor:Hn,borderLeftColor:Hn,filter:Eb,WebkitFilter:Eb,mask:Ab,WebkitMask:Ab},tO=e=>HZ[e],qZ=new Set([Eb,Ab]);function nO(e,t){let n=tO(e);return qZ.has(n)||(n=qa),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const WZ=new Set(["auto","none","0"]);function GZ(e,t,n){let a=0,r;for(;a<e.length&&!r;){const o=e[a];typeof o=="string"&&!WZ.has(o)&&Nc(o).values.length&&(r=e[a]),a++}if(r&&n)for(const o of t)e[o]=nO(n,r)}class ZZ extends yw{constructor(t,n,a,r,o){super(t,n,a,r,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:a}=this;if(!n||!n.current)return;super.readKeyframes();for(let g=0;g<t.length;g++){let v=t[g];if(typeof v=="string"&&(v=v.trim(),fw(v))){const y=Z_(v,n.current);y!==void 0&&(t[g]=y),g===t.length-1&&(this.finalKeyframe=v)}}if(this.resolveNoneKeyframes(),!K_.has(a)||t.length!==2)return;const[r,o]=t,c=lE(r),u=lE(o),h=ZC(r),f=ZC(o);if(h!==f&&Ii[a]){this.needsMeasurement=!0;return}if(c!==u)if(sE(c)&&sE(u))for(let g=0;g<t.length;g++){const v=t[g];typeof v=="string"&&(t[g]=parseFloat(v))}else Ii[a]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,a=[];for(let r=0;r<t.length;r++)(t[r]===null||zZ(t[r]))&&a.push(r);a.length&&GZ(t,a,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:a}=this;if(!t||!t.current)return;a==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ii[a](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(a,r).jump(r,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:a}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const o=a.length-1,c=a[o];a[o]=Ii[n](t.measureViewportBox(),window.getComputedStyle(t.current)),c!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=c),this.removedTransforms?.length&&this.removedTransforms.forEach(([u,h])=>{t.getValue(u).set(h)}),this.resolveNoneKeyframes()}}function sO(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let a=document;const r=n?.[e]??a.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e).filter(a=>a!=null)}const Tb=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function pm(e){return u_(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:Nw}=k_(queueMicrotask,!1),Ba={x:!1,y:!1};function aO(){return Ba.x||Ba.y}function KZ(e){return e==="x"||e==="y"?Ba[e]?null:(Ba[e]=!0,()=>{Ba[e]=!1}):Ba.x||Ba.y?null:(Ba.x=Ba.y=!0,()=>{Ba.x=Ba.y=!1})}function rO(e,t){const n=sO(e),a=new AbortController,r={passive:!0,...t,signal:a.signal};return[n,r,()=>a.abort()]}function YZ(e){return!(e.pointerType==="touch"||aO())}function XZ(e,t,n={}){const[a,r,o]=rO(e,n);return a.forEach(c=>{let u=!1,h=!1,f;const g=()=>{c.removeEventListener("pointerleave",w)},v=T=>{f&&(f(T),f=void 0),g()},y=T=>{u=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),h&&(h=!1,v(T))},x=()=>{u=!0,window.addEventListener("pointerup",y,r),window.addEventListener("pointercancel",y,r)},w=T=>{if(T.pointerType!=="touch"){if(u){h=!0;return}v(T)}},C=T=>{if(!YZ(T))return;h=!1;const E=t(c,T);typeof E=="function"&&(f=E,c.addEventListener("pointerleave",w,r))};c.addEventListener("pointerenter",C,r),c.addEventListener("pointerdown",x,r)}),o}const iO=(e,t)=>t?e===t?!0:iO(e,t.parentElement):!1,kw=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,QZ=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function JZ(e){return QZ.has(e.tagName)||e.isContentEditable===!0}const eK=new Set(["INPUT","SELECT","TEXTAREA"]);function tK(e){return eK.has(e.tagName)||e.isContentEditable===!0}const gm=new WeakSet;function uE(e){return t=>{t.key==="Enter"&&e(t)}}function Qy(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const nK=(e,t)=>{const n=e.currentTarget;if(!n)return;const a=uE(()=>{if(gm.has(n))return;Qy(n,"down");const r=uE(()=>{Qy(n,"up")}),o=()=>Qy(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",a,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",a),t)};function dE(e){return kw(e)&&!aO()}const fE=new WeakSet;function sK(e,t,n={}){const[a,r,o]=rO(e,n),c=u=>{const h=u.currentTarget;if(!dE(u)||fE.has(u))return;gm.add(h),n.stopPropagation&&fE.add(u);const f=t(h,u),g=(x,w)=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",y),gm.has(h)&&gm.delete(h),dE(x)&&typeof f=="function"&&f(x,{success:w})},v=x=>{g(x,h===window||h===document||n.useGlobalTarget||iO(h,x.target))},y=x=>{g(x,!1)};window.addEventListener("pointerup",v,r),window.addEventListener("pointercancel",y,r)};return a.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",c,r),pm(u)&&(u.addEventListener("focus",f=>nK(f,r)),!JZ(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function Sw(e){return u_(e)&&"ownerSVGElement"in e}const vm=new WeakMap;let ym;const oO=(e,t,n)=>(a,r)=>r&&r[0]?r[0][e+"Size"]:Sw(a)&&"getBBox"in a?a.getBBox()[t]:a[n],aK=oO("inline","width","offsetWidth"),rK=oO("block","height","offsetHeight");function iK({target:e,borderBoxSize:t}){vm.get(e)?.forEach(n=>{n(e,{get width(){return aK(e,t)},get height(){return rK(e,t)}})})}function oK(e){e.forEach(iK)}function lK(){typeof ResizeObserver>"u"||(ym=new ResizeObserver(oK))}function cK(e,t){ym||lK();const n=sO(e);return n.forEach(a=>{let r=vm.get(a);r||(r=new Set,vm.set(a,r)),r.add(t),ym?.observe(a)}),()=>{n.forEach(a=>{const r=vm.get(a);r?.delete(t),r?.size||ym?.unobserve(a)})}}const xm=new Set;let sc;function uK(){sc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};xm.forEach(t=>t(e))},window.addEventListener("resize",sc)}function dK(e){return xm.add(e),sc||uK(),()=>{xm.delete(e),!xm.size&&typeof sc=="function"&&(window.removeEventListener("resize",sc),sc=void 0)}}function hE(e,t){return typeof e=="function"?dK(e):cK(e,t)}function fK(e){return Sw(e)&&e.tagName==="svg"}const hK=[...eO,Hn,qa],mK=e=>hK.find(J_(e)),mE=()=>({translate:0,scale:1,origin:0,originPoint:0}),ac=()=>({x:mE(),y:mE()}),pE=()=>({min:0,max:0}),Yn=()=>({x:pE(),y:pE()}),pK=new WeakMap;function ng(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Md(e){return typeof e=="string"||Array.isArray(e)}const Cw=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ew=["initial",...Cw];function sg(e){return ng(e.animate)||Ew.some(t=>Md(e[t]))}function lO(e){return!!(sg(e)||e.variants)}function gK(e,t,n){for(const a in t){const r=t[a],o=n[a];if(cs(r))e.addValue(a,r);else if(cs(o))e.addValue(a,kc(r,{owner:e}));else if(o!==r)if(e.hasValue(a)){const c=e.getValue(a);c.liveStyle===!0?c.jump(r):c.hasAnimated||c.set(r)}else{const c=e.getStaticValue(a);e.addValue(a,kc(c!==void 0?c:r,{owner:e}))}}for(const a in n)t[a]===void 0&&e.removeValue(a);return t}const Mb={current:null},cO={current:!1},vK=typeof window<"u";function yK(){if(cO.current=!0,!!vK)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Mb.current=e.matches;e.addEventListener("change",t),t()}else Mb.current=!1}const gE=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let dp={};function uO(e){dp=e}function xK(){return dp}class bK{scrapeMotionValuesFromProps(t,n,a){return{}}constructor({parent:t,props:n,presenceContext:a,reducedMotionConfig:r,skipAnimations:o,blockInitialAnimation:c,visualState:u},h={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=yw,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const x=As.now();this.renderScheduledAt<x&&(this.renderScheduledAt=x,ln.render(this.render,!1,!0))};const{latestValues:f,renderState:g}=u;this.latestValues=f,this.baseTarget={...f},this.initialValues=n.initial?{...f}:{},this.renderState=g,this.parent=t,this.props=n,this.presenceContext=a,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=o,this.options=h,this.blockInitialAnimation=!!c,this.isControllingVariants=sg(n),this.isVariantNode=lO(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:v,...y}=this.scrapeMotionValuesFromProps(n,{},this);for(const x in y){const w=y[x];f[x]!==void 0&&cs(w)&&w.set(f[x])}}mount(t){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=t,pK.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,a)=>this.bindToMotionValue(a,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(cO.current||yK(),this.shouldReduceMotion=Mb.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Fi(this.notifyUpdate),Fi(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&q_.has(t)&&this.current instanceof HTMLElement){const{factory:c,keyframes:u,times:h,ease:f,duration:g}=n.accelerate,v=new V_({element:this.current,name:t,keyframes:u,times:h,ease:f,duration:na(g)}),y=c(v);this.valueSubscriptions.set(t,()=>{y(),v.cancel()});return}const a=Dc.has(t);a&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",c=>{this.latestValues[t]=c,this.props.onUpdate&&ln.preRender(this.notifyUpdate),a&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),o&&o()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in dp){const n=dp[t];if(!n)continue;const{isEnabled:a,Feature:r}=n;if(!this.features[t]&&r&&a(this.props)&&(this.features[t]=new r(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Yn()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let a=0;a<gE.length;a++){const r=gE[a];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const o="on"+r,c=t[o];c&&(this.propEventSubscriptions[r]=this.on(r,c))}this.prevMotionValues=gK(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const a=this.values.get(t);n!==a&&(a&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let a=this.values.get(t);return a===void 0&&n!==void 0&&(a=kc(n===null?void 0:n,{owner:this}),this.addValue(t,a)),a}readValue(t,n){let a=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return a!=null&&(typeof a=="string"&&(c_(a)||d_(a))?a=parseFloat(a):!mK(a)&&qa.test(n)&&(a=nO(t,n)),this.setBaseTarget(t,cs(a)?a.get():a)),cs(a)?a.get():a}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let a;if(typeof n=="string"||typeof n=="object"){const o=ww(this.props,n,this.presenceContext?.custom);o&&(a=o[t])}if(n&&a!==void 0)return a;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!cs(r)?r:this.initialValues[t]!==void 0&&a===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new cw),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Nw.render(this.render)}}class dO extends bK{constructor(){super(...arguments),this.KeyframeResolver=ZZ}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const a=t.style;return a?a[n]:void 0}removeValueFromRenderState(t,{vars:n,style:a}){delete n[t],delete a[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;cs(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class Qi{constructor(t){this.isMounted=!1,this.node=t}update(){}}function fO({top:e,left:t,right:n,bottom:a}){return{x:{min:t,max:n},y:{min:e,max:a}}}function wK({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function jK(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),a=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:a.y,right:a.x}}function Jy(e){return e===void 0||e===1}function Rb({scale:e,scaleX:t,scaleY:n}){return!Jy(e)||!Jy(t)||!Jy(n)}function To(e){return Rb(e)||hO(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function hO(e){return vE(e.x)||vE(e.y)}function vE(e){return e&&e!=="0%"}function fp(e,t,n){const a=e-n,r=t*a;return n+r}function yE(e,t,n,a,r){return r!==void 0&&(e=fp(e,r,a)),fp(e,n,a)+t}function Ib(e,t=0,n=1,a,r){e.min=yE(e.min,t,n,a,r),e.max=yE(e.max,t,n,a,r)}function mO(e,{x:t,y:n}){Ib(e.x,t.translate,t.scale,t.originPoint),Ib(e.y,n.translate,n.scale,n.originPoint)}const xE=.999999999999,bE=1.0000000000001;function NK(e,t,n,a=!1){const r=n.length;if(!r)return;t.x=t.y=1;let o,c;for(let u=0;u<r;u++){o=n[u],c=o.projectionDelta;const{visualElement:h}=o.options;h&&h.props.style&&h.props.style.display==="contents"||(a&&o.options.layoutScroll&&o.scroll&&o!==o.root&&(ur(e.x,-o.scroll.offset.x),ur(e.y,-o.scroll.offset.y)),c&&(t.x*=c.x.scale,t.y*=c.y.scale,mO(e,c)),a&&To(o.latestValues)&&bm(e,o.latestValues,o.layout?.layoutBox))}t.x<bE&&t.x>xE&&(t.x=1),t.y<bE&&t.y>xE&&(t.y=1)}function ur(e,t){e.min+=t,e.max+=t}function wE(e,t,n,a,r=.5){const o=on(e.min,e.max,r);Ib(e,t,n,o,a)}function jE(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function bm(e,t,n){const a=n??e;wE(e.x,jE(t.x,a.x),t.scaleX,t.scale,t.originX),wE(e.y,jE(t.y,a.y),t.scaleY,t.scale,t.originY)}function pO(e,t){return fO(jK(e.getBoundingClientRect(),t))}function kK(e,t,n){const a=pO(e,n),{scroll:r}=t;return r&&(ur(a.x,r.offset.x),ur(a.y,r.offset.y)),a}const SK={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},CK=Pc.length;function EK(e,t,n){let a="",r=!0;for(let c=0;c<CK;c++){const u=Pc[c],h=e[u];if(h===void 0)continue;let f=!0;if(typeof h=="number")f=h===(u.startsWith("scale")?1:0);else{const g=parseFloat(h);f=u.startsWith("scale")?g===1:g===0}if(!f||n){const g=Tb(h,up[u]);if(!f){r=!1;const v=SK[u]||u;a+=`${v}(${g}) `}n&&(t[u]=g)}}const o=e.pathRotation;return o&&(r=!1,a+=`rotate(${Tb(o,up.pathRotation)}) `),a=a.trim(),n?a=n(t,r?"":a):r&&(a="none"),a}function Aw(e,t,n){const{style:a,vars:r,transformOrigin:o}=e;let c=!1,u=!1;for(const h in t){const f=t[h];if(Dc.has(h)){c=!0;continue}else if(C_(h)){r[h]=f;continue}else{const g=Tb(f,up[h]);h.startsWith("origin")?(u=!0,o[h]=g):a[h]=g}}if(t.transform||(c||n?a.transform=EK(t,e.transform,n):a.transform&&(a.transform="none")),u){const{originX:h="50%",originY:f="50%",originZ:g=0}=o;a.transformOrigin=`${h} ${f} ${g}`}}function gO(e,{style:t,vars:n},a,r){const o=e.style;let c;for(c in t)o[c]=t[c];r?.applyProjectionStyles(o,a);for(c in n)o.setProperty(c,n[c])}function NE(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Iu={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ke.test(e))e=parseFloat(e);else return e;const n=NE(e,t.target.x),a=NE(e,t.target.y);return`${n}% ${a}%`}},AK={correct:(e,{treeScale:t,projectionDelta:n})=>{const a=e,r=qa.parse(e);if(r.length>5)return a;const o=qa.createTransformer(e),c=typeof r[0]!="number"?1:0,u=n.x.scale*t.x,h=n.y.scale*t.y;r[0+c]/=u,r[1+c]/=h;const f=on(u,h,.5);return typeof r[2+c]=="number"&&(r[2+c]/=f),typeof r[3+c]=="number"&&(r[3+c]/=f),o(r)}},_b={borderRadius:{...Iu,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Iu,borderTopRightRadius:Iu,borderBottomLeftRadius:Iu,borderBottomRightRadius:Iu,boxShadow:AK};function vO(e,{layout:t,layoutId:n}){return Dc.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!_b[e]||e==="opacity")}function Tw(e,t,n){const a=e.style,r=t?.style,o={};if(!a)return o;for(const c in a)(cs(a[c])||r&&cs(r[c])||vO(c,e)||n?.getValue(c)?.liveStyle!==void 0)&&(o[c]=a[c]);return o}function TK(e){return window.getComputedStyle(e)}class MK extends dO{constructor(){super(...arguments),this.type="html",this.renderInstance=gO}readValueFromInstance(t,n){if(Dc.has(n))return this.projection?.isProjecting?yb(n):YG(t,n);{const a=TK(t),r=(C_(n)?a.getPropertyValue(n):a[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return pO(t,n)}build(t,n,a){Aw(t,n,a.transformTemplate)}scrapeMotionValuesFromProps(t,n,a){return Tw(t,n,a)}}const RK={offset:"stroke-dashoffset",array:"stroke-dasharray"},IK={offset:"strokeDashoffset",array:"strokeDasharray"};function _K(e,t,n=1,a=0,r=!0){e.pathLength=1;const o=r?RK:IK;e[o.offset]=`${-a}`,e[o.array]=`${t} ${n}`}const OK=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function yO(e,{attrX:t,attrY:n,attrScale:a,pathLength:r,pathSpacing:o=1,pathOffset:c=0,...u},h,f,g){if(Aw(e,u,f),h){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:v,style:y}=e;v.transform&&(y.transform=v.transform,delete v.transform),(y.transform||v.transformOrigin)&&(y.transformOrigin=v.transformOrigin??"50% 50%",delete v.transformOrigin),y.transform&&(y.transformBox=g?.transformBox??"fill-box",delete v.transformBox);for(const x of OK)v[x]!==void 0&&(y[x]=v[x],delete v[x]);t!==void 0&&(v.x=t),n!==void 0&&(v.y=n),a!==void 0&&(v.scale=a),r!==void 0&&_K(v,r,o,c,!1)}const xO=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),bO=e=>typeof e=="string"&&e.toLowerCase()==="svg";function $K(e,t,n,a){gO(e,t,void 0,a);for(const r in t.attrs)e.setAttribute(xO.has(r)?r:jw(r),t.attrs[r])}function wO(e,t,n){const a=Tw(e,t,n);for(const r in e)if(cs(e[r])||cs(t[r])){const o=Pc.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;a[o]=e[r]}return a}class PK extends dO{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Yn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Dc.has(n)){const a=tO(n);return a&&a.default||0}return n=xO.has(n)?n:jw(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,a){return wO(t,n,a)}build(t,n,a){yO(t,n,this.isSVGTag,a.transformTemplate,a.style)}renderInstance(t,n,a,r){$K(t,n,a,r)}mount(t){this.isSVGTag=bO(t.tagName),super.mount(t)}}const DK=Ew.length;function jO(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?jO(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<DK;n++){const a=Ew[n],r=e.props[a];(Md(r)||r===!1)&&(t[a]=r)}return t}function NO(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let a=0;a<n;a++)if(t[a]!==e[a])return!1;return!0}const LK=[...Cw].reverse(),zK=Cw.length;function BK(e){return t=>Promise.all(t.map(({animation:n,options:a})=>DZ(e,n,a)))}function UK(e){let t=BK(e),n=kE(),a=!0,r=!1;const o=f=>(g,v)=>{const y=zo(e,v,f==="exit"?e.presenceContext?.custom:void 0);if(y){const{transition:x,transitionEnd:w,...C}=y;g={...g,...C,...w}}return g};function c(f){t=f(e)}function u(f){const{props:g}=e,v=jO(e.parent)||{},y=[],x=new Set;let w={},C=1/0;for(let E=0;E<zK;E++){const S=LK[E],k=n[S],N=g[S]!==void 0?g[S]:v[S],A=Md(N),R=S===f?k.isActive:null;R===!1&&(C=E);let _=N===v[S]&&N!==g[S]&&A;if(_&&(a||r)&&e.manuallyAnimateOnMount&&(_=!1),k.protectedKeys={...w},!k.isActive&&R===null||!N&&!k.prevProp||ng(N)||typeof N=="boolean")continue;if(S==="exit"&&k.isActive&&R!==!0){k.prevResolvedValues&&(w={...w,...k.prevResolvedValues});continue}const P=FK(k.prevProp,N);let $=P||S===f&&k.isActive&&!_&&A||E>C&&A,H=!1;const I=Array.isArray(N)?N:[N];let U=I.reduce(o(S),{});R===!1&&(U={});const{prevResolvedValues:D={}}=k,V={...D,...U},Z=B=>{$=!0,x.has(B)&&(H=!0,x.delete(B)),k.needsAnimating[B]=!0;const X=e.getValue(B);X&&(X.liveStyle=!1)};for(const B in V){const X=U[B],W=D[B];if(w.hasOwnProperty(B))continue;let L=!1;kb(X)&&kb(W)?L=!NO(X,W)||P:L=X!==W,L?X!=null?Z(B):x.add(B):X!==void 0&&x.has(B)?Z(B):k.protectedKeys[B]=!0}k.prevProp=N,k.prevResolvedValues=U,k.isActive&&(w={...w,...U}),(a||r)&&e.blockInitialAnimation&&($=!1);const O=_&&P;$&&(!O||H)&&y.push(...I.map(B=>{const X={type:S};if(typeof B=="string"&&(a||r)&&!O&&e.manuallyAnimateOnMount&&e.parent){const{parent:W}=e,L=zo(W,B);if(W.enteringChildren&&L){const{delayChildren:q}=L.transition||{};X.delay=W_(W.enteringChildren,e,q)}}return{animation:B,options:X}}))}if(x.size){const E={};if(typeof g.initial!="boolean"){const S=zo(e,Array.isArray(g.initial)?g.initial[0]:g.initial);S&&S.transition&&(E.transition=S.transition)}x.forEach(S=>{const k=e.getBaseTarget(S),N=e.getValue(S);N&&(N.liveStyle=!0),E[S]=k??null}),y.push({animation:E})}let T=!!y.length;return a&&(g.initial===!1||g.initial===g.animate)&&!e.manuallyAnimateOnMount&&(T=!1),a=!1,r=!1,T?t(y):Promise.resolve()}function h(f,g){if(n[f].isActive===g)return Promise.resolve();e.variantChildren?.forEach(y=>y.animationState?.setActive(f,g)),n[f].isActive=g;const v=u(f);for(const y in n)n[y].protectedKeys={};return v}return{animateChanges:u,setActive:h,setAnimateFunction:c,getState:()=>n,reset:()=>{n=kE(),r=!0}}}function FK(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!NO(t,e):!1}function wo(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function kE(){return{animate:wo(!0),whileInView:wo(),whileHover:wo(),whileTap:wo(),whileDrag:wo(),whileFocus:wo(),exit:wo()}}function Ob(e,t){e.min=t.min,e.max=t.max}function za(e,t){Ob(e.x,t.x),Ob(e.y,t.y)}function SE(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const kO=1e-4,VK=1-kO,HK=1+kO,SO=.01,qK=0-SO,WK=0+SO;function Ts(e){return e.max-e.min}function GK(e,t,n){return Math.abs(e-t)<=n}function CE(e,t,n,a=.5){e.origin=a,e.originPoint=on(t.min,t.max,e.origin),e.scale=Ts(n)/Ts(t),e.translate=on(n.min,n.max,e.origin)-e.originPoint,(e.scale>=VK&&e.scale<=HK||isNaN(e.scale))&&(e.scale=1),(e.translate>=qK&&e.translate<=WK||isNaN(e.translate))&&(e.translate=0)}function cd(e,t,n,a){CE(e.x,t.x,n.x,a?a.originX:void 0),CE(e.y,t.y,n.y,a?a.originY:void 0)}function EE(e,t,n,a=0){const r=a?on(n.min,n.max,a):n.min;e.min=r+t.min,e.max=e.min+Ts(t)}function ZK(e,t,n,a){EE(e.x,t.x,n.x,a?.x),EE(e.y,t.y,n.y,a?.y)}function AE(e,t,n,a=0){const r=a?on(n.min,n.max,a):n.min;e.min=t.min-r,e.max=e.min+Ts(t)}function hp(e,t,n,a){AE(e.x,t.x,n.x,a?.x),AE(e.y,t.y,n.y,a?.y)}function TE(e,t,n,a,r){return e-=t,e=fp(e,1/n,a),r!==void 0&&(e=fp(e,1/r,a)),e}function KK(e,t=0,n=1,a=.5,r,o=e,c=e){if(mr.test(t)&&(t=parseFloat(t),t=on(c.min,c.max,t/100)-c.min),typeof t!="number")return;let u=on(o.min,o.max,a);e===o&&(u-=t),e.min=TE(e.min,t,n,u,r),e.max=TE(e.max,t,n,u,r)}function ME(e,t,[n,a,r],o,c){KK(e,t[n],t[a],t[r],t.scale,o,c)}const YK=["x","scaleX","originX"],XK=["y","scaleY","originY"];function RE(e,t,n,a){ME(e.x,t,YK,n?n.x:void 0,a?a.x:void 0),ME(e.y,t,XK,n?n.y:void 0,a?a.y:void 0)}function IE(e){return e.translate===0&&e.scale===1}function CO(e){return IE(e.x)&&IE(e.y)}function _E(e,t){return e.min===t.min&&e.max===t.max}function QK(e,t){return _E(e.x,t.x)&&_E(e.y,t.y)}function OE(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function EO(e,t){return OE(e.x,t.x)&&OE(e.y,t.y)}function $E(e){return Ts(e.x)/Ts(e.y)}function PE(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function ir(e){return[e("x"),e("y")]}function JK(e,t,n){let a="";const r=e.x.translate/t.x,o=e.y.translate/t.y,c=n?.z||0;if((r||o||c)&&(a=`translate3d(${r}px, ${o}px, ${c}px) `),(t.x!==1||t.y!==1)&&(a+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:f,rotate:g,pathRotation:v,rotateX:y,rotateY:x,skewX:w,skewY:C}=n;f&&(a=`perspective(${f}px) ${a}`),g&&(a+=`rotate(${g}deg) `),v&&(a+=`rotate(${v}deg) `),y&&(a+=`rotateX(${y}deg) `),x&&(a+=`rotateY(${x}deg) `),w&&(a+=`skewX(${w}deg) `),C&&(a+=`skewY(${C}deg) `)}const u=e.x.scale*t.x,h=e.y.scale*t.y;return(u!==1||h!==1)&&(a+=`scale(${u}, ${h})`),a||"none"}const AO=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],eY=AO.length,DE=e=>typeof e=="string"?parseFloat(e):e,LE=e=>typeof e=="number"||Ke.test(e);function tY(e,t,n,a,r,o){r?(e.opacity=on(0,n.opacity??1,nY(a)),e.opacityExit=on(t.opacity??1,0,sY(a))):o&&(e.opacity=on(t.opacity??1,n.opacity??1,a));for(let c=0;c<eY;c++){const u=AO[c];let h=zE(t,u),f=zE(n,u);if(h===void 0&&f===void 0)continue;h||(h=0),f||(f=0),h===0||f===0||LE(h)===LE(f)?(e[u]=Math.max(on(DE(h),DE(f),a),0),(mr.test(f)||mr.test(h))&&(e[u]+="%")):e[u]=f}(t.rotate||n.rotate)&&(e.rotate=on(t.rotate||0,n.rotate||0,a))}function zE(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const nY=TO(0,.5,b_),sY=TO(.5,.95,Ea);function TO(e,t,n){return a=>a<e?0:a>t?1:n(Ad(e,t,a))}function aY(e,t,n){const a=cs(e)?e:kc(e);return a.start(bw("",a,t,n)),a.animation}function Rd(e,t,n,a={passive:!0}){return e.addEventListener(t,n,a),()=>e.removeEventListener(t,n)}const rY=(e,t)=>e.depth-t.depth;class iY{constructor(){this.children=[],this.isDirty=!1}add(t){ow(this.children,t),this.isDirty=!0}remove(t){rp(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(rY),this.isDirty=!1,this.children.forEach(t)}}function oY(e,t){const n=As.now(),a=({timestamp:r})=>{const o=r-n;o>=t&&(Fi(a),e(o-t))};return ln.setup(a,!0),()=>Fi(a)}function wm(e){return cs(e)?e.get():e}class lY{constructor(){this.members=[]}add(t){ow(this.members,t);for(let n=this.members.length-1;n>=0;n--){const a=this.members[n];if(a===t||a===this.lead||a===this.prevLead)continue;const r=a.instance;(!r||r.isConnected===!1)&&!a.snapshot&&(rp(this.members,a),a.unmount())}t.scheduleRender()}remove(t){if(rp(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){for(let n=this.members.indexOf(t)-1;n>=0;n--){const a=this.members[n];if(a.isPresent!==!1&&a.instance?.isConnected!==!1)return this.promote(a),!0}return!1}promote(t,n){const a=this.lead;if(t!==a&&(this.prevLead=a,this.lead=t,t.show(),a)){a.updateSnapshot(),t.scheduleRender();const{layoutDependency:r}=a.options,{layoutDependency:o}=t.options;(r===void 0||r!==o)&&(t.resumeFrom=a,n&&(a.preserveOpacity=!0),a.snapshot&&(t.snapshot=a.snapshot,t.snapshot.latestValues=a.animationValues||a.latestValues),t.root?.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&a.hide()}}exitAnimationComplete(){this.members.forEach(t=>{t.options.onExitComplete?.(),t.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const jm={hasAnimatedSinceResize:!0,hasEverUpdated:!1},ex=["","X","Y","Z"],cY=1e3;let uY=0;function tx(e,t,n,a){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),a&&(a[e]=0))}function MO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=X_(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ln,!(r||o))}const{parent:a}=e;a&&!a.hasCheckedOptimisedAppear&&MO(a)}function RO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:a,resetTransform:r}){return class{constructor(c={},u=t?.()){this.id=uY++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(hY),this.nodes.forEach(xY),this.nodes.forEach(bY),this.nodes.forEach(mY)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=c,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let h=0;h<this.path.length;h++)this.path[h].shouldResetTransform=!0;this.root===this&&(this.nodes=new iY)}addEventListener(c,u){return this.eventHandlers.has(c)||this.eventHandlers.set(c,new cw),this.eventHandlers.get(c).add(u)}notifyListeners(c,...u){const h=this.eventHandlers.get(c);h&&h.notify(...u)}hasListeners(c){return this.eventHandlers.has(c)}mount(c){if(this.instance)return;this.isSVG=Sw(c)&&!fK(c),this.instance=c;const{layoutId:u,layout:h,visualElement:f}=this.options;if(f&&!f.current&&f.mount(c),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(h||u)&&(this.isLayoutDirty=!0),e){let g,v=0;const y=()=>this.root.updateBlockedByResize=!1;ln.read(()=>{v=window.innerWidth}),e(c,()=>{const x=window.innerWidth;x!==v&&(v=x,this.root.updateBlockedByResize=!0,g&&g(),g=oY(y,250),jm.hasAnimatedSinceResize&&(jm.hasAnimatedSinceResize=!1,this.nodes.forEach(FE)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&f&&(u||h)&&this.addEventListener("didUpdate",({delta:g,hasLayoutChanged:v,hasRelativeLayoutChanged:y,layout:x})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const w=this.options.transition||f.getDefaultTransition()||SY,{onLayoutAnimationStart:C,onLayoutAnimationComplete:T}=f.getProps(),E=!this.targetLayout||!EO(this.targetLayout,x),S=!v&&y;if(this.options.layoutRoot||this.resumeFrom||S||v&&(E||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const k={...xw(w,"layout"),onPlay:C,onComplete:T};(f.shouldReduceMotion||this.options.layoutRoot)&&(k.delay=0,k.type=!1),this.startAnimation(k),this.setAnimationOrigin(g,S,k.path)}else v||FE(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=x})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const c=this.getStack();c&&c.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Fi(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(wY),this.animationId++)}getTransformTemplate(){const{visualElement:c}=this.options;return c&&c.getProps().transformTemplate}willUpdate(c=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&MO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let g=0;g<this.path.length;g++){const v=this.path[g];v.shouldResetTransform=!0,(typeof v.latestValues.x=="string"||typeof v.latestValues.y=="string")&&(v.isLayoutDirty=!0),v.updateScroll("snapshot"),v.options.layoutRoot&&v.willUpdate(!1)}const{layoutId:u,layout:h}=this.options;if(u===void 0&&!h)return;const f=this.getTransformTemplate();this.prevTransformTemplateValue=f?f(this.latestValues,""):void 0,this.updateSnapshot(),c&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const h=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),h&&this.nodes.forEach(gY),this.nodes.forEach(BE);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(UE);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(vY),this.nodes.forEach(yY),this.nodes.forEach(dY),this.nodes.forEach(fY)):this.nodes.forEach(UE),this.clearAllSnapshots();const u=As.now();is.delta=xr(0,1e3/60,u-is.timestamp),is.timestamp=u,is.isProcessing=!0,Wy.update.process(is),Wy.preRender.process(is),Wy.render.process(is),is.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Nw.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(pY),this.sharedNodes.forEach(jY)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ln.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ln.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ts(this.snapshot.measuredBox.x)&&!Ts(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h<this.path.length;h++)this.path[h].updateScroll();const c=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=Yn()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:u}=this.options;u&&u.notify("LayoutMeasure",this.layout.layoutBox,c?c.layoutBox:void 0)}updateScroll(c="measure"){let u=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===c&&(u=!1),u&&this.instance){const h=a(this.instance);this.scroll={animationId:this.root.animationId,phase:c,isRoot:h,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:h}}}resetTransform(){if(!r)return;const c=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,u=this.projectionDelta&&!CO(this.projectionDelta),h=this.getTransformTemplate(),f=h?h(this.latestValues,""):void 0,g=f!==this.prevTransformTemplateValue;c&&this.instance&&(u||To(this.latestValues)||g)&&(r(this.instance,f),this.shouldResetTransform=!1,this.scheduleRender())}measure(c=!0){const u=this.measurePageBox();let h=this.removeElementScroll(u);return c&&(h=this.removeTransform(h)),CY(h),{animationId:this.root.animationId,measuredBox:u,layoutBox:h,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:c}=this.options;if(!c)return Yn();const u=c.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(EY))){const{scroll:f}=this.root;f&&(ur(u.x,f.offset.x),ur(u.y,f.offset.y))}return u}removeElementScroll(c){const u=Yn();if(za(u,c),this.scroll?.wasRoot)return u;for(let h=0;h<this.path.length;h++){const f=this.path[h],{scroll:g,options:v}=f;f!==this.root&&g&&v.layoutScroll&&(g.wasRoot&&za(u,c),ur(u.x,g.offset.x),ur(u.y,g.offset.y))}return u}applyTransform(c,u=!1,h){const f=h||Yn();za(f,c);for(let g=0;g<this.path.length;g++){const v=this.path[g];!u&&v.options.layoutScroll&&v.scroll&&v!==v.root&&(ur(f.x,-v.scroll.offset.x),ur(f.y,-v.scroll.offset.y)),To(v.latestValues)&&bm(f,v.latestValues,v.layout?.layoutBox)}return To(this.latestValues)&&bm(f,this.latestValues,this.layout?.layoutBox),f}removeTransform(c){const u=Yn();za(u,c);for(let h=0;h<this.path.length;h++){const f=this.path[h];if(!To(f.latestValues))continue;let g;f.instance&&(Rb(f.latestValues)&&f.updateSnapshot(),g=Yn(),za(g,f.measurePageBox())),RE(u,f.latestValues,f.snapshot?.layoutBox,g)}return To(this.latestValues)&&RE(u,this.latestValues),u}setTargetDelta(c){this.targetDelta=c,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(c){this.options={...this.options,...c,crossfade:c.crossfade!==void 0?c.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==is.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(c=!1){const u=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=u.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=u.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=u.isSharedProjectionDirty);const h=!!this.resumingFrom||this!==u;if(!(c||h&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:g,layoutId:v}=this.options;if(!this.layout||!(g||v))return;this.resolvedRelativeTargetAt=is.timestamp;const y=this.getClosestProjectingParent();y&&this.linkedParentVersion!==y.layoutVersion&&!y.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&y&&y.layout?this.createRelativeTarget(y,this.layout.layoutBox,y.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Yn(),this.targetWithTransforms=Yn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),ZK(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):za(this.target,this.layout.layoutBox),mO(this.target,this.targetDelta)):za(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&y&&!!y.resumingFrom==!!this.resumingFrom&&!y.options.layoutScroll&&y.target&&this.animationProgress!==1?this.createRelativeTarget(y,this.target,y.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Rb(this.parent.latestValues)||hO(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(c,u,h){this.relativeParent=c,this.linkedParentVersion=c.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Yn(),this.relativeTargetOrigin=Yn(),hp(this.relativeTargetOrigin,u,h,this.options.layoutAnchor||void 0),za(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const c=this.getLead(),u=!!this.resumingFrom||this!==c;let h=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(h=!1),u&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(h=!1),this.resolvedRelativeTargetAt===is.timestamp&&(h=!1),h)return;const{layout:f,layoutId:g}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(f||g))return;za(this.layoutCorrected,this.layout.layoutBox);const v=this.treeScale.x,y=this.treeScale.y;NK(this.layoutCorrected,this.treeScale,this.path,u),c.layout&&!c.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(c.target=c.layout.layoutBox,c.targetWithTransforms=Yn());const{target:x}=c;if(!x){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(SE(this.prevProjectionDelta.x,this.projectionDelta.x),SE(this.prevProjectionDelta.y,this.projectionDelta.y)),cd(this.projectionDelta,this.layoutCorrected,x,this.latestValues),(this.treeScale.x!==v||this.treeScale.y!==y||!PE(this.projectionDelta.x,this.prevProjectionDelta.x)||!PE(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",x))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(c=!0){if(this.options.visualElement?.scheduleRender(),c){const u=this.getStack();u&&u.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ac(),this.projectionDelta=ac(),this.projectionDeltaWithTransform=ac()}setAnimationOrigin(c,u=!1,h){const f=this.snapshot,g=f?f.latestValues:{},v={...this.latestValues},y=ac();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;const x=Yn(),w=f?f.source:void 0,C=this.layout?this.layout.source:void 0,T=w!==C,E=this.getStack(),S=!E||E.members.length<=1,k=!!(T&&!S&&this.options.crossfade===!0&&!this.path.some(kY));this.animationProgress=0;let N;const A=h?.interpolateProjection(c);this.mixTargetDelta=R=>{const _=R/1e3,P=A?.(_);P?(y.x.translate=P.x,y.x.scale=on(c.x.scale,1,_),y.x.origin=c.x.origin,y.x.originPoint=c.x.originPoint,y.y.translate=P.y,y.y.scale=on(c.y.scale,1,_),y.y.origin=c.y.origin,y.y.originPoint=c.y.originPoint):(VE(y.x,c.x,_),VE(y.y,c.y,_)),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(hp(x,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),NY(this.relativeTarget,this.relativeTargetOrigin,x,_),N&&QK(this.relativeTarget,N)&&(this.isProjectionDirty=!1),N||(N=Yn()),za(N,this.relativeTarget)),T&&(this.animationValues=v,tY(v,g,this.latestValues,_,k,S)),P&&P.rotate!==void 0&&(this.animationValues||(this.animationValues=v),this.animationValues.pathRotation=P.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=_},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(c){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Fi(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ln.update(()=>{jm.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=kc(0)),this.motionValue.jump(0,!1),this.currentAnimation=aY(this.motionValue,[0,1e3],{...c,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),c.onUpdate&&c.onUpdate(u)},onStop:()=>{},onComplete:()=>{c.onComplete&&c.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const c=this.getStack();c&&c.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(cY),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const c=this.getLead();let{targetWithTransforms:u,target:h,layout:f,latestValues:g}=c;if(!(!u||!h||!f)){if(this!==c&&this.layout&&f&&IO(this.options.animationType,this.layout.layoutBox,f.layoutBox)){h=this.target||Yn();const v=Ts(this.layout.layoutBox.x);h.x.min=c.target.x.min,h.x.max=h.x.min+v;const y=Ts(this.layout.layoutBox.y);h.y.min=c.target.y.min,h.y.max=h.y.min+y}za(u,h),bm(u,g),cd(this.projectionDeltaWithTransform,this.layoutCorrected,u,g)}}registerSharedNode(c,u){this.sharedNodes.has(c)||this.sharedNodes.set(c,new lY),this.sharedNodes.get(c).add(u);const f=u.options.initialPromotionConfig;u.promote({transition:f?f.transition:void 0,preserveFollowOpacity:f&&f.shouldPreserveFollowOpacity?f.shouldPreserveFollowOpacity(u):void 0})}isLead(){const c=this.getStack();return c?c.lead===this:!0}getLead(){const{layoutId:c}=this.options;return c?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:c}=this.options;return c?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:c}=this.options;if(c)return this.root.sharedNodes.get(c)}promote({needsReset:c,transition:u,preserveFollowOpacity:h}={}){const f=this.getStack();f&&f.promote(this,h),c&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const c=this.getStack();return c?c.relegate(this):!1}resetSkewAndRotation(){const{visualElement:c}=this.options;if(!c)return;let u=!1;const{latestValues:h}=c;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(u=!0),!u)return;const f={};h.z&&tx("z",c,f,this.animationValues);for(let g=0;g<ex.length;g++)tx(`rotate${ex[g]}`,c,f,this.animationValues),tx(`skew${ex[g]}`,c,f,this.animationValues);c.render();for(const g in f)c.setStaticValue(g,f[g]),this.animationValues&&(this.animationValues[g]=f[g]);c.scheduleRender()}applyProjectionStyles(c,u){if(!this.instance||this.isSVG)return;if(!this.isVisible){c.visibility="hidden";return}const h=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,c.visibility="",c.opacity="",c.pointerEvents=wm(u?.pointerEvents)||"",c.transform=h?h(this.latestValues,""):"none";return}const f=this.getLead();if(!this.projectionDelta||!this.layout||!f.target){this.options.layoutId&&(c.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,c.pointerEvents=wm(u?.pointerEvents)||""),this.hasProjected&&!To(this.latestValues)&&(c.transform=h?h({},""):"none",this.hasProjected=!1);return}c.visibility="";const g=f.animationValues||f.latestValues;this.applyTransformsToTarget();let v=JK(this.projectionDeltaWithTransform,this.treeScale,g);h&&(v=h(g,v)),c.transform=v;const{x:y,y:x}=this.projectionDelta;c.transformOrigin=`${y.origin*100}% ${x.origin*100}% 0`,f.animationValues?c.opacity=f===this?g.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:g.opacityExit:c.opacity=f===this?g.opacity!==void 0?g.opacity:"":g.opacityExit!==void 0?g.opacityExit:0;for(const w in _b){if(g[w]===void 0)continue;const{correct:C,applyTo:T,isCSSVariable:E}=_b[w],S=v==="none"?g[w]:C(g[w],f);if(T){const k=T.length;for(let N=0;N<k;N++)c[T[N]]=S}else E?this.options.visualElement.renderState.vars[w]=S:c[w]=S}this.options.layoutId&&(c.pointerEvents=f===this?wm(u?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(c=>c.currentAnimation?.stop()),this.root.nodes.forEach(BE),this.root.sharedNodes.clear()}}}function dY(e){e.updateLayout()}function fY(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:a}=e.layout,{animationType:r}=e.options,o=t.source!==e.layout.source;if(r==="size")ir(g=>{const v=o?t.measuredBox[g]:t.layoutBox[g],y=Ts(v);v.min=n[g].min,v.max=v.min+y});else if(r==="x"||r==="y"){const g=r==="x"?"y":"x";Ob(o?t.measuredBox[g]:t.layoutBox[g],n[g])}else IO(r,t.layoutBox,n)&&ir(g=>{const v=o?t.measuredBox[g]:t.layoutBox[g],y=Ts(n[g]);v.max=v.min+y,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[g].max=e.relativeTarget[g].min+y)});const c=ac();cd(c,n,t.layoutBox);const u=ac();o?cd(u,e.applyTransform(a,!0),t.measuredBox):cd(u,n,t.layoutBox);const h=!CO(c);let f=!1;if(!e.resumeFrom){const g=e.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:v,layout:y}=g;if(v&&y){const x=e.options.layoutAnchor||void 0,w=Yn();hp(w,t.layoutBox,v.layoutBox,x);const C=Yn();hp(C,n,y.layoutBox,x),EO(w,C)||(f=!0),g.options.layoutRoot&&(e.relativeTarget=C,e.relativeTargetOrigin=w,e.relativeParent=g)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:u,layoutDelta:c,hasLayoutChanged:h,hasRelativeLayoutChanged:f})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function hY(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function mY(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function pY(e){e.clearSnapshot()}function BE(e){e.clearMeasurements()}function gY(e){e.isLayoutDirty=!0,e.updateLayout()}function UE(e){e.isLayoutDirty=!1}function vY(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function yY(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function FE(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function xY(e){e.resolveTargetDelta()}function bY(e){e.calcProjection()}function wY(e){e.resetSkewAndRotation()}function jY(e){e.removeLeadSnapshot()}function VE(e,t,n){e.translate=on(t.translate,0,n),e.scale=on(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function HE(e,t,n,a){e.min=on(t.min,n.min,a),e.max=on(t.max,n.max,a)}function NY(e,t,n,a){HE(e.x,t.x,n.x,a),HE(e.y,t.y,n.y,a)}function kY(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const SY={duration:.45,ease:[.4,0,.1,1]},qE=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),WE=qE("applewebkit/")&&!qE("chrome/")?Math.round:Ea;function GE(e){e.min=WE(e.min),e.max=WE(e.max)}function CY(e){GE(e.x),GE(e.y)}function IO(e,t,n){return e==="position"||e==="preserve-aspect"&&!GK($E(t),$E(n),.2)}function EY(e){return e!==e.root&&e.scroll?.wasRoot}const AY=RO({attachResizeListener:(e,t)=>Rd(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),nx={current:void 0},_O=RO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!nx.current){const e=new AY({});e.mount(window),e.setOptions({layoutScroll:!0}),nx.current=e}return nx.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Mw=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function ZE(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function TY(...e){return t=>{let n=!1;const a=e.map(r=>{const o=ZE(r,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let r=0;r<a.length;r++){const o=a[r];typeof o=="function"?o():ZE(e[r],null)}}}}function MY(...e){return m.useCallback(TY(...e),e)}class RY extends m.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(pm(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const a=n.offsetParent,r=pm(a)&&a.offsetWidth||0,o=pm(a)&&a.offsetHeight||0,c=getComputedStyle(n),u=this.props.sizeRef.current;u.height=parseFloat(c.height),u.width=parseFloat(c.width),u.top=n.offsetTop,u.left=n.offsetLeft,u.right=r-u.width-u.left,u.bottom=o-u.height-u.top,u.direction=c.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function IY({children:e,isPresent:t,anchorX:n,anchorY:a,root:r,pop:o}){const c=m.useId(),u=m.useRef(null),h=m.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:f}=m.useContext(Mw),g=e.props?.ref??e?.ref,v=MY(u,g);return m.useInsertionEffect(()=>{const{width:y,height:x,top:w,left:C,right:T,bottom:E,direction:S}=h.current;if(t||o===!1||!u.current||!y||!x)return;const k=S==="rtl",N=n==="left"?k?`right: ${T}`:`left: ${C}`:k?`left: ${C}`:`right: ${T}`,A=a==="bottom"?`bottom: ${E}`:`top: ${w}`;u.current.dataset.motionPopId=c;const R=document.createElement("style");f&&(R.nonce=f);const _=r??document.head;return _.appendChild(R),R.sheet&&R.sheet.insertRule(`
122
+ [data-motion-pop-id="${c}"] {
123
+ position: absolute !important;
124
+ width: ${y}px !important;
125
+ height: ${x}px !important;
126
+ ${N}px !important;
127
+ ${A}px !important;
128
+ }
129
+ `),()=>{u.current?.removeAttribute("data-motion-pop-id"),_.contains(R)&&_.removeChild(R)}},[t]),s.jsx(RY,{isPresent:t,childRef:u,sizeRef:h,pop:o,children:o===!1?e:m.cloneElement(e,{ref:v})})}const _Y=({children:e,initial:t,isPresent:n,onExitComplete:a,custom:r,presenceAffectsLayout:o,mode:c,anchorX:u,anchorY:h,root:f})=>{const g=iw(OY),v=m.useId();let y=!0,x=m.useMemo(()=>(y=!1,{id:v,initial:t,isPresent:n,custom:r,onExitComplete:w=>{g.set(w,!0);for(const C of g.values())if(!C)return;a&&a()},register:w=>(g.set(w,!1),()=>g.delete(w))}),[n,g,a]);return o&&y&&(x={...x}),m.useMemo(()=>{g.forEach((w,C)=>g.set(C,!1))},[n]),m.useEffect(()=>{!n&&!g.size&&a&&a()},[n]),e=s.jsx(IY,{pop:c==="popLayout",isPresent:n,anchorX:u,anchorY:h,root:f,children:e}),s.jsx(eg.Provider,{value:x,children:e})};function OY(){return new Map}function OO(e=!0){const t=m.useContext(eg);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:a,register:r}=t,o=m.useId();m.useEffect(()=>{if(e)return r(o)},[e]);const c=m.useCallback(()=>e&&a&&a(o),[o,a,e]);return!n&&a?[!1,c]:[!0]}const Ah=e=>e.key||"";function KE(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const $Y=({children:e,custom:t,initial:n=!0,onExitComplete:a,presenceAffectsLayout:r=!0,mode:o="sync",propagate:c=!1,anchorX:u="left",anchorY:h="top",root:f})=>{const[g,v]=OO(c),y=m.useMemo(()=>KE(e),[e]),x=c&&!g?[]:y.map(Ah),w=m.useRef(!0),C=m.useRef(y),T=iw(()=>new Map),E=m.useRef(new Set),[S,k]=m.useState(y),[N,A]=m.useState(y);l_(()=>{w.current=!1,C.current=y;for(let P=0;P<N.length;P++){const $=Ah(N[P]);x.includes($)?(T.delete($),E.current.delete($)):T.get($)!==!0&&T.set($,!1)}},[N,x.length,x.join("-")]);const R=[];if(y!==S){let P=[...y];for(let $=0;$<N.length;$++){const H=N[$],I=Ah(H);x.includes(I)||(P.splice($,0,H),R.push(H))}return o==="wait"&&R.length&&(P=R),A(KE(P)),k(y),null}const{forceRender:_}=m.useContext(rw);return s.jsx(s.Fragment,{children:N.map(P=>{const $=Ah(P),H=c&&!g?!1:y===N||x.includes($),I=()=>{if(E.current.has($))return;if(T.has($))E.current.add($),T.set($,!0);else return;let U=!0;T.forEach(D=>{D||(U=!1)}),U&&(_?.(),A(C.current),c&&v?.(),a&&a())};return s.jsx(_Y,{isPresent:H,initial:!w.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:f,onExitComplete:H?void 0:I,anchorX:u,anchorY:h,children:P},$)})})},$O=m.createContext({strict:!1}),YE={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let XE=!1;function PY(){if(XE)return;const e={};for(const t in YE)e[t]={isEnabled:n=>YE[t].some(a=>!!n[a])};uO(e),XE=!0}function PO(){return PY(),xK()}function DY(e){const t=PO();for(const n in e)t[n]={...t[n],...e[n]};uO(t)}const LY=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function mp(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||LY.has(e)}let DO=e=>!mp(e);function zY(e){typeof e=="function"&&(DO=t=>t.startsWith("on")?!mp(t):e(t))}try{zY(require("@emotion/is-prop-valid").default)}catch{}function BY(e,t,n){const a={};for(const r in e)r==="values"&&typeof e.values=="object"||cs(e[r])||(DO(r)||n===!0&&mp(r)||!t&&!mp(r)||e.draggable&&r.startsWith("onDrag"))&&(a[r]=e[r]);return a}const ag=m.createContext({});function UY(e,t){if(sg(e)){const{initial:n,animate:a}=e;return{initial:n===!1||Md(n)?n:void 0,animate:Md(a)?a:void 0}}return e.inherit!==!1?t:{}}function FY(e){const{initial:t,animate:n}=UY(e,m.useContext(ag));return m.useMemo(()=>({initial:t,animate:n}),[QE(t),QE(n)])}function QE(e){return Array.isArray(e)?e.join(" "):e}const Rw=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function LO(e,t,n){for(const a in t)!cs(t[a])&&!vO(a,n)&&(e[a]=t[a])}function VY({transformTemplate:e},t){return m.useMemo(()=>{const n=Rw();return Aw(n,t,e),Object.assign({},n.vars,n.style)},[t])}function HY(e,t){const n=e.style||{},a={};return LO(a,n,e),Object.assign(a,VY(e,t)),a}function qY(e,t){const n={},a=HY(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,a.userSelect=a.WebkitUserSelect=a.WebkitTouchCallout="none",a.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=a,n}const zO=()=>({...Rw(),attrs:{}});function WY(e,t,n,a){const r=m.useMemo(()=>{const o=zO();return yO(o,t,bO(a),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};LO(o,e.style,e),r.style={...o,...r.style}}return r}const GY=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Iw(e){return typeof e!="string"||e.includes("-")?!1:!!(GY.indexOf(e)>-1||/[A-Z]/u.test(e))}function ZY(e,t,n,{latestValues:a},r,o=!1,c){const h=(c??Iw(e)?WY:qY)(t,a,r,e),f=BY(t,typeof e=="string",o),g=e!==m.Fragment?{...f,...h,ref:n}:{},{children:v}=t,y=m.useMemo(()=>cs(v)?v.get():v,[v]);return m.createElement(e,{...g,children:y})}function KY({scrapeMotionValuesFromProps:e,createRenderState:t},n,a,r){return{latestValues:YY(n,a,r,e),renderState:t()}}function YY(e,t,n,a){const r={},o=a(e,{});for(const y in o)r[y]=wm(o[y]);let{initial:c,animate:u}=e;const h=sg(e),f=lO(e);t&&f&&!h&&e.inherit!==!1&&(c===void 0&&(c=t.initial),u===void 0&&(u=t.animate));let g=n?n.initial===!1:!1;g=g||c===!1;const v=g?u:c;if(v&&typeof v!="boolean"&&!ng(v)){const y=Array.isArray(v)?v:[v];for(let x=0;x<y.length;x++){const w=ww(e,y[x]);if(w){const{transitionEnd:C,transition:T,...E}=w;for(const S in E){let k=E[S];if(Array.isArray(k)){const N=g?k.length-1:0;k=k[N]}k!==null&&(r[S]=k)}for(const S in C)r[S]=C[S]}}}return r}const BO=e=>(t,n)=>{const a=m.useContext(ag),r=m.useContext(eg),o=()=>KY(e,t,a,r);return n?o():iw(o)},XY=BO({scrapeMotionValuesFromProps:Tw,createRenderState:Rw}),QY=BO({scrapeMotionValuesFromProps:wO,createRenderState:zO}),JY=Symbol.for("motionComponentSymbol");function eX(e,t,n){const a=m.useRef(n);m.useInsertionEffect(()=>{a.current=n});const r=m.useRef(null);return m.useCallback(o=>{o&&e.onMount?.(o),t&&(o?t.mount(o):t.unmount());const c=a.current;if(typeof c=="function")if(o){const u=c(o);typeof u=="function"&&(r.current=u)}else r.current?(r.current(),r.current=null):c(o);else c&&(c.current=o)},[t])}const UO=m.createContext({});function Zl(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function tX(e,t,n,a,r,o){const{visualElement:c}=m.useContext(ag),u=m.useContext($O),h=m.useContext(eg),f=m.useContext(Mw),g=f.reducedMotion,v=f.skipAnimations,y=m.useRef(null),x=m.useRef(!1);a=a||u.renderer,!y.current&&a&&(y.current=a(e,{visualState:t,parent:c,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:g,skipAnimations:v,isSVG:o}),x.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const w=y.current,C=m.useContext(UO);w&&!w.projection&&r&&(w.type==="html"||w.type==="svg")&&nX(y.current,n,r,C);const T=m.useRef(!1);m.useInsertionEffect(()=>{w&&T.current&&w.update(n,h)});const E=n[Y_],S=m.useRef(!!E&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(E)&&window.MotionHasOptimisedAnimation?.(E));return l_(()=>{x.current=!0,w&&(T.current=!0,window.MotionIsMounted=!0,w.updateFeatures(),w.scheduleRenderMicrotask(),S.current&&w.animationState&&w.animationState.animateChanges())}),m.useEffect(()=>{w&&(!S.current&&w.animationState&&w.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(E)}),S.current=!1),w.enteringChildren=void 0)}),w}function nX(e,t,n,a){const{layoutId:r,layout:o,drag:c,dragConstraints:u,layoutScroll:h,layoutRoot:f,layoutAnchor:g,layoutCrossfade:v}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:FO(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!c||u&&Zl(u),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:a,crossfade:v,layoutScroll:h,layoutRoot:f,layoutAnchor:g})}function FO(e){if(e)return e.options.allowProjection!==!1?e.projection:FO(e.parent)}function sx(e,{forwardMotionProps:t=!1,type:n}={},a,r){a&&DY(a);const o=n?n==="svg":Iw(e),c=o?QY:XY;function u(f,g){let v;const y={...m.useContext(Mw),...f,layoutId:sX(f)},{isStatic:x}=y,w=FY(f),C=c(f,x);if(!x&&typeof window<"u"){aX();const T=rX(y);v=T.MeasureLayout,w.visualElement=tX(e,C,y,r,T.ProjectionNode,o)}return s.jsxs(ag.Provider,{value:w,children:[v&&w.visualElement?s.jsx(v,{visualElement:w.visualElement,...y}):null,ZY(e,f,eX(C,w.visualElement,g),C,x,t,o)]})}u.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=m.forwardRef(u);return h[JY]=e,h}function sX({layoutId:e}){const t=m.useContext(rw).id;return t&&e!==void 0?t+"-"+e:e}function aX(e,t){m.useContext($O).strict}function rX(e){const t=PO(),{drag:n,layout:a}=t;if(!n&&!a)return{};const r={...n,...a};return{MeasureLayout:n?.isEnabled(e)||a?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function iX(e,t){if(typeof Proxy>"u")return sx;const n=new Map,a=(o,c)=>sx(o,c,e,t),r=(o,c)=>a(o,c);return new Proxy(r,{get:(o,c)=>c==="create"?a:(n.has(c)||n.set(c,sx(c,void 0,e,t)),n.get(c))})}const oX=(e,t)=>t.isSVG??Iw(e)?new PK(t):new MK(t,{allowProjection:e!==m.Fragment});class lX extends Qi{constructor(t){super(t),t.animationState||(t.animationState=UK(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();ng(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let cX=0;class uX extends Qi{constructor(){super(...arguments),this.id=cX++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:a}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===a)return;if(t&&a===!1){if(this.isExitComplete){const{initial:o,custom:c}=this.node.getProps();if(typeof o=="string"||typeof o=="object"&&o!==null&&!Array.isArray(o)){const u=zo(this.node,o,c);if(u){const{transition:h,transitionEnd:f,...g}=u;for(const v in g)this.node.getValue(v)?.jump(g[v])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const dX={animation:{Feature:lX},exit:{Feature:uX}};function Zd(e){return{point:{x:e.pageX,y:e.pageY}}}const fX=e=>t=>kw(t)&&e(t,Zd(t));function ud(e,t,n,a){return Rd(e,t,fX(n),a)}const VO=({current:e})=>e?e.ownerDocument.defaultView:null,JE=(e,t)=>Math.abs(e-t);function hX(e,t){const n=JE(e.x,t.x),a=JE(e.y,t.y);return Math.sqrt(n**2+a**2)}const eA=new Set(["auto","scroll"]);class HO{constructor(t,n,{transformPagePoint:a,contextWindow:r=window,dragSnapToOrigin:o=!1,distanceThreshold:c=3,element:u}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=x=>{this.handleScroll(x.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Th(this.lastRawMoveEventInfo,this.transformPagePoint));const x=ax(this.lastMoveEventInfo,this.history),w=this.startEvent!==null,C=hX(x.offset,{x:0,y:0})>=this.distanceThreshold;if(!w&&!C)return;const{point:T}=x,{timestamp:E}=is;this.history.push({...T,timestamp:E});const{onStart:S,onMove:k}=this.handlers;w||(S&&S(this.lastMoveEvent,x),this.startEvent=this.lastMoveEvent),k&&k(this.lastMoveEvent,x)},this.handlePointerMove=(x,w)=>{this.lastMoveEvent=x,this.lastRawMoveEventInfo=w,this.lastMoveEventInfo=Th(w,this.transformPagePoint),ln.update(this.updatePoint,!0)},this.handlePointerUp=(x,w)=>{this.end();const{onEnd:C,onSessionEnd:T,resumeAnimation:E}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&E&&E(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=ax(x.type==="pointercancel"?this.lastMoveEventInfo:Th(w,this.transformPagePoint),this.history);this.startEvent&&C&&C(x,S),T&&T(x,S)},!kw(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=a,this.distanceThreshold=c,this.contextWindow=r||window;const h=Zd(t),f=Th(h,this.transformPagePoint),{point:g}=f,{timestamp:v}=is;this.history=[{...g,timestamp:v}];const{onSessionStart:y}=n;y&&y(t,ax(f,this.history)),this.removeListeners=qd(ud(this.contextWindow,"pointermove",this.handlePointerMove),ud(this.contextWindow,"pointerup",this.handlePointerUp),ud(this.contextWindow,"pointercancel",this.handlePointerUp)),u&&this.startScrollTracking(u)}startScrollTracking(t){let n=t.parentElement;for(;n;){const a=getComputedStyle(n);(eA.has(a.overflowX)||eA.has(a.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const a=t===window,r=a?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:r.x-n.x,y:r.y-n.y};o.x===0&&o.y===0||(a?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=o.x,this.lastMoveEventInfo.point.y+=o.y):this.history.length>0&&(this.history[0].x-=o.x,this.history[0].y-=o.y),this.scrollPositions.set(t,r),ln.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Fi(this.updatePoint)}}function Th(e,t){return t?{point:t(e.point)}:e}function tA(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ax({point:e},t){return{point:e,delta:tA(e,qO(t)),offset:tA(e,mX(t)),velocity:pX(t,.1)}}function mX(e){return e[0]}function qO(e){return e[e.length-1]}function pX(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,a=null;const r=qO(e);for(;n>=0&&(a=e[n],!(r.timestamp-a.timestamp>na(t)));)n--;if(!a)return{x:0,y:0};a===e[0]&&e.length>2&&r.timestamp-a.timestamp>na(t)*2&&(a=e[1]);const o=Sa(r.timestamp-a.timestamp);if(o===0)return{x:0,y:0};const c={x:(r.x-a.x)/o,y:(r.y-a.y)/o};return c.x===1/0&&(c.x=0),c.y===1/0&&(c.y=0),c}function gX(e,{min:t,max:n},a){return t!==void 0&&e<t?e=a?on(t,e,a.min):Math.max(e,t):n!==void 0&&e>n&&(e=a?on(n,e,a.max):Math.min(e,n)),e}function nA(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function vX(e,{top:t,left:n,bottom:a,right:r}){return{x:nA(e.x,n,r),y:nA(e.y,t,a)}}function sA(e,t){let n=t.min-e.min,a=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,a]=[a,n]),{min:n,max:a}}function yX(e,t){return{x:sA(e.x,t.x),y:sA(e.y,t.y)}}function xX(e,t){let n=.5;const a=Ts(e),r=Ts(t);return r>a?n=Ad(t.min,t.max-a,e.min):a>r&&(n=Ad(e.min,e.max-r,t.min)),xr(0,1,n)}function bX(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const $b=.35;function wX(e=$b){return e===!1?e=0:e===!0&&(e=$b),{x:aA(e,"left","right"),y:aA(e,"top","bottom")}}function aA(e,t,n){return{min:rA(e,t),max:rA(e,n)}}function rA(e,t){return typeof e=="number"?e:e[t]||0}const jX=new WeakMap;class NX{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Yn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:a}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const o=v=>{n&&this.snapToCursor(Zd(v).point),this.stopAnimation()},c=(v,y)=>{const{drag:x,dragPropagation:w,onDragStart:C}=this.getProps();if(x&&!w&&(this.openDragLock&&this.openDragLock(),this.openDragLock=KZ(x),!this.openDragLock))return;this.latestPointerEvent=v,this.latestPanInfo=y,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ir(E=>{let S=this.getAxisMotionValue(E).get()||0;if(mr.test(S)){const{projection:k}=this.visualElement;if(k&&k.layout){const N=k.layout.layoutBox[E];N&&(S=Ts(N)*(parseFloat(S)/100))}}this.originPoint[E]=S}),C&&ln.update(()=>C(v,y),!1,!0),Sb(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},u=(v,y)=>{this.latestPointerEvent=v,this.latestPanInfo=y;const{dragPropagation:x,dragDirectionLock:w,onDirectionLock:C,onDrag:T}=this.getProps();if(!x&&!this.openDragLock)return;const{offset:E}=y;if(w&&this.currentDirection===null){this.currentDirection=SX(E),this.currentDirection!==null&&C&&C(this.currentDirection);return}this.updateAxis("x",y.point,E),this.updateAxis("y",y.point,E),this.visualElement.render(),T&&ln.update(()=>T(v,y),!1,!0)},h=(v,y)=>{this.latestPointerEvent=v,this.latestPanInfo=y,this.stop(v,y),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:v}=this.getProps();(v||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:g}=this.getProps();this.panSession=new HO(t,{onSessionStart:o,onStart:c,onMove:u,onSessionEnd:h,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,distanceThreshold:a,contextWindow:VO(this.visualElement),element:this.visualElement.current})}stop(t,n){const a=t||this.latestPointerEvent,r=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!r||!a)return;const{velocity:c}=r;this.startAnimation(c);const{onDragEnd:u}=this.getProps();u&&ln.postRender(()=>u(a,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:a}=this.getProps();!a&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,a){const{drag:r}=this.getProps();if(!a||!Mh(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let c=this.originPoint[t]+a[t];this.constraints&&this.constraints[t]&&(c=gX(c,this.constraints[t],this.elastic[t])),o.set(c)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;t&&Zl(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&a?this.constraints=vX(a.layoutBox,t):this.constraints=!1,this.elastic=wX(n),r!==this.constraints&&!Zl(t)&&a&&this.constraints&&!this.hasMutatedConstraints&&ir(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=bX(a.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Zl(t))return!1;const a=t.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());const o=kK(a,r.root,this.visualElement.getTransformPagePoint());let c=yX(r.layout.layoutBox,o);if(n){const u=n(wK(c));this.hasMutatedConstraints=!!u,u&&(c=fO(u))}return c}startAnimation(t){const{drag:n,dragMomentum:a,dragElastic:r,dragTransition:o,dragSnapToOrigin:c,onDragTransitionEnd:u}=this.getProps(),h=this.constraints||{},f=ir(g=>{if(!Mh(g,n,this.currentDirection))return;let v=h&&h[g]||{};(c===!0||c===g)&&(v={min:0,max:0});const y=r?200:1e6,x=r?40:1e7,w={type:"inertia",velocity:a?t[g]:0,bounceStiffness:y,bounceDamping:x,timeConstant:750,restDelta:1,restSpeed:10,...o,...v};return this.startAxisValueAnimation(g,w)});return Promise.all(f).then(u)}startAxisValueAnimation(t,n){const a=this.getAxisMotionValue(t);return Sb(this.visualElement,t),a.start(bw(t,a,0,n,this.visualElement,!1))}stopAnimation(){ir(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps()[n];return r||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){ir(n=>{const{drag:a}=this.getProps();if(!Mh(n,a,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(n);if(r&&r.layout){const{min:c,max:u}=r.layout.layoutBox[n],h=o.get()||0;o.set(t[n]-on(c,u,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:a}=this.visualElement;if(!Zl(n)||!a||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};ir(c=>{const u=this.getAxisMotionValue(c);if(u&&this.constraints!==!1){const h=u.get();r[c]=xX({min:h,max:h},this.constraints[c])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",a.root&&a.root.updateScroll(),a.updateLayout(),this.constraints=!1,this.resolveConstraints(),ir(c=>{if(!Mh(c,t,null))return;const u=this.getAxisMotionValue(c),{min:h,max:f}=this.constraints[c];u.set(on(h,f,r[c]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;jX.set(this.visualElement,this);const t=this.visualElement.current,n=ud(t,"pointerdown",f=>{const{drag:g,dragListener:v=!0}=this.getProps(),y=f.target,x=y!==t&&tK(y);g&&v&&!x&&this.start(f)});let a;const r=()=>{const{dragConstraints:f}=this.getProps();Zl(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),a||(a=kX(t,f.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,c=o.addEventListener("measure",r);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),ln.read(r);const u=Rd(window,"resize",()=>this.scalePositionWithinConstraints()),h=o.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:g})=>{this.isDragging&&g&&(ir(v=>{const y=this.getAxisMotionValue(v);y&&(this.originPoint[v]+=f[v].translate,y.set(y.get()+f[v].translate))}),this.visualElement.render())}));return()=>{u(),n(),c(),h&&h(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:a=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:c=$b,dragMomentum:u=!0}=t;return{...t,drag:n,dragDirectionLock:a,dragPropagation:r,dragConstraints:o,dragElastic:c,dragMomentum:u}}}function iA(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function kX(e,t,n){const a=hE(e,iA(n)),r=hE(t,iA(n));return()=>{a(),r()}}function Mh(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function SX(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class CX extends Qi{constructor(t){super(t),this.removeGroupControls=Ea,this.removeListeners=Ea,this.controls=new NX(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ea}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const rx=e=>(t,n)=>{e&&ln.update(()=>e(t,n),!1,!0)};class EX extends Qi{constructor(){super(...arguments),this.removePointerDownListener=Ea}onPointerDown(t){this.session=new HO(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:VO(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:a,onPanEnd:r}=this.node.getProps();return{onSessionStart:rx(t),onStart:rx(n),onMove:rx(a),onEnd:(o,c)=>{delete this.session,r&&ln.postRender(()=>r(o,c))}}}mount(){this.removePointerDownListener=ud(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let ix=!1;class AX extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:a,layoutId:r}=this.props,{projection:o}=t;o&&(n.group&&n.group.add(o),a&&a.register&&r&&a.register(o),ix&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),jm.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:a,drag:r,isPresent:o}=this.props,{projection:c}=a;return c&&(c.isPresent=o,t.layoutDependency!==n&&c.setOptions({...c.options,layoutDependency:n}),ix=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?c.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?c.promote():c.relegate()||ln.postRender(()=>{const u=c.getStack();(!u||!u.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:a}=t;a&&(a.options.layoutAnchor=n,a.root.didUpdate(),Nw.postRender(()=>{!a.currentAnimation&&a.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:a}=this.props,{projection:r}=t;ix=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),a&&a.deregister&&a.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function WO(e){const[t,n]=OO(),a=m.useContext(rw);return s.jsx(AX,{...e,layoutGroup:a,switchLayoutGroup:m.useContext(UO),isPresent:t,safeToRemove:n})}const TX={pan:{Feature:EX},drag:{Feature:CX,ProjectionNode:_O,MeasureLayout:WO}};function oA(e,t,n){const{props:a}=e;e.animationState&&a.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=a[r];o&&ln.postRender(()=>o(t,Zd(t)))}class MX extends Qi{mount(){const{current:t}=this.node;t&&(this.unmount=XZ(t,(n,a)=>(oA(this.node,a,"Start"),r=>oA(this.node,r,"End"))))}unmount(){}}class RX extends Qi{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=qd(Rd(this.node.current,"focus",()=>this.onFocus()),Rd(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function lA(e,t,n){const{props:a}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&a.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),o=a[r];o&&ln.postRender(()=>o(t,Zd(t)))}class IX extends Qi{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:a}=this.node.props;this.unmount=sK(t,(r,o)=>(lA(this.node,o,"Start"),(c,{success:u})=>lA(this.node,c,u?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:a?.tap===!1})}unmount(){}}const Pb=new WeakMap,ox=new WeakMap,_X=e=>{const t=Pb.get(e.target);t&&t(e)},OX=e=>{e.forEach(_X)};function $X({root:e,...t}){const n=e||document;ox.has(n)||ox.set(n,{});const a=ox.get(n),r=JSON.stringify(t);return a[r]||(a[r]=new IntersectionObserver(OX,{root:e,...t})),a[r]}function PX(e,t,n){const a=$X(t);return Pb.set(e,n),a.observe(e),()=>{Pb.delete(e),a.unobserve(e)}}const DX={some:0,all:1};class LX extends Qi{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:n,margin:a,amount:r="some",once:o}=t,c={root:n?n.current:void 0,rootMargin:a,threshold:typeof r=="number"?r:DX[r]},u=h=>{const{isIntersecting:f}=h;if(this.isInView===f||(this.isInView=f,o&&!f&&this.hasEnteredView))return;f&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",f);const{onViewportEnter:g,onViewportLeave:v}=this.node.getProps(),y=f?g:v;y&&y(h)};this.stopObserver=PX(this.node.current,c,u)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(zX(t,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function zX({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const BX={inView:{Feature:LX},tap:{Feature:IX},focus:{Feature:RX},hover:{Feature:MX}},UX={layout:{ProjectionNode:_O,MeasureLayout:WO}},FX={...dX,...BX,...TX,...UX},VX=iX(FX,oX);function HX(e){return"type"in e&&e.type==="separator"}function qX(e){return"type"in e&&e.type==="group"}function cA({item:e}){return s.jsxs(xH,{disabled:e.disabled,onClick:e.action,className:"flex items-center gap-3 px-3 py-1.5 text-[12px] font-mono text-neutral-300 outline-none select-none data-[highlighted]:bg-neutral-700/50 data-[highlighted]:text-white data-[disabled]:opacity-40 data-[disabled]:pointer-events-none cursor-default",children:[e.icon&&s.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-neutral-400",children:e.icon}),s.jsx("span",{className:"flex-1",children:e.label}),e.shortcut&&s.jsx("span",{className:"text-neutral-400 text-[10px] ml-4 tracking-wider",children:e.shortcut})]})}var GO=Ql.forwardRef(({items:e},t)=>s.jsx(VX.div,{ref:t,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.1,ease:"easeOut"},children:s.jsx(dW,{className:"bg-neutral-900/95 backdrop-blur-xl border border-neutral-700/60 rounded-lg shadow-2xl py-1 min-w-[180px] z-[200] outline-none",children:e.map((n,a)=>HX(n)?s.jsx(FW,{className:"h-px bg-neutral-700/50 my-1"},`sep-${a}`):qX(n)?s.jsxs(vH,{children:[s.jsx(yH,{className:"px-3 py-1 text-[10px] font-mono uppercase tracking-widest text-neutral-400",children:n.label}),n.items.map(r=>s.jsx(cA,{item:r},r.id))]},`grp-${a}`):s.jsx(cA,{item:n},n.id))})}));GO.displayName="PopupContent";function WX({items:e,children:t}){return e.length===0?s.jsx(s.Fragment,{children:t}):s.jsxs(VW,{children:[s.jsx(HW,{render:s.jsx("div",{style:{display:"contents"}}),children:t}),s.jsx(hW,{children:s.jsx(CW,{className:"z-[200]",sideOffset:4,children:s.jsx($Y,{children:s.jsx(GO,{items:e})})})})]})}function _w(){const{titleBarInset:e}=Dp();return m.useMemo(()=>{const t=Vp.layout.navHeight+e;return{navTotalHeight:t,panelTopOffset:t}},[e])}var GX=({scale:e,onZoom:t,min:n=.2,max:a=3,step:r=.1})=>{const[o,c]=m.useState(!1),[u,h]=m.useState(""),f=m.useRef(null),g=m.useCallback(T=>Math.min(a,Math.max(n,T)),[n,a]),v=m.useCallback(()=>{t(g(e+r))},[e,r,t,g]),y=m.useCallback(()=>{t(g(e-r))},[e,r,t,g]),x=m.useCallback(()=>{h(Math.round(e*100).toString()),c(!0)},[e]),w=m.useCallback(()=>{c(!1);const T=parseInt(u,10);!isNaN(T)&&T>0&&t(g(T/100))},[u,t,g]),C=m.useCallback(T=>{T.key==="Enter"?w():T.key==="Escape"&&c(!1)},[w]);return m.useEffect(()=>{o&&f.current&&(f.current.focus(),f.current.select())},[o]),s.jsxs("div",{className:"pointer-events-auto flex flex-col items-center bg-neutral-950/95 backdrop-blur-xl border border-neutral-700/80 rounded-md shadow-[0_0_20px_rgba(0,0,0,0.6)] overflow-hidden",children:[s.jsx("button",{onClick:v,className:"w-9 h-8 flex items-center justify-center hover:bg-white/10 text-neutral-300 hover:text-white transition-colors",title:"Zoom in",children:s.jsx(zz,{size:14})}),s.jsx("div",{className:"w-full border-t border-b border-neutral-700/50",children:o?s.jsx("input",{ref:f,type:"text",value:u,onChange:T=>h(T.target.value.replace(/[^0-9]/g,"")),onBlur:w,onKeyDown:C,className:"w-9 py-1.5 text-center text-[11px] font-mono text-white bg-black/60 outline-none tabular-nums"}):s.jsxs("button",{onClick:x,className:"w-9 py-1.5 text-center text-[11px] font-mono text-neutral-200 hover:text-white hover:bg-white/10 transition-colors cursor-text tabular-nums",title:"Click to set zoom",children:[Math.round(e*100),"%"]})}),s.jsx("button",{onClick:y,className:"w-9 h-8 flex items-center justify-center hover:bg-white/10 text-neutral-300 hover:text-white transition-colors",title:"Zoom out",children:s.jsx(wz,{size:14})})]})},ZX=GX,uA=()=>{},KX={x:0,y:0},YX=({children:e,hud:t,mode:n="canvas",panOffset:a=KX,scale:r=1,onPan:o=uA,onZoom:c=uA,onPanStart:u,onPanEnd:h,isTransitioning:f=!1,onViewportChange:g,onCanvasClick:v,canvasProps:y,zoomSensitivity:x,zoomControlsRightOffset:w,canvasContextMenuItems:C})=>{const T=m.useRef(null),E=m.useRef(r);E.current=r;const S=m.useRef(c);S.current=c;const k=m.useRef(o);k.current=o;const N=m.useRef(u);N.current=u;const A=m.useRef(h);A.current=h;const R=m.useRef(x);R.current=x;const[_,P]=m.useState(!1),$=m.useRef(!1),[H,I]=m.useState(!1),U=m.useRef(!1),D=m.useRef({x:0,y:0}),V=m.useRef(O=>{const z=O.target||document.activeElement;if(!z)return!1;const B=z.tagName;return!!(B==="INPUT"||B==="TEXTAREA"||z.isContentEditable||z.closest?.(".xterm"))});m.useEffect(()=>{if(n!=="canvas")return;const O=X=>{X.key!==" "||X.repeat||V.current(X)||f||(X.preventDefault(),$.current=!0,P(!0))},z=X=>{X.key===" "&&$.current&&($.current=!1,P(!1),U.current&&(U.current=!1,I(!1),A.current?.()))},B=()=>{$.current&&($.current=!1,P(!1),U.current&&(U.current=!1,I(!1),A.current?.()))};return window.addEventListener("keydown",O),window.addEventListener("keyup",z),window.addEventListener("blur",B),()=>{window.removeEventListener("keydown",O),window.removeEventListener("keyup",z),window.removeEventListener("blur",B)}},[n,f]);const Z=m.useCallback(O=>{O.button===0&&(O.preventDefault(),U.current=!0,I(!0),D.current={x:O.clientX,y:O.clientY},N.current?.())},[]);return m.useEffect(()=>{if(!_)return;const O=B=>{if(!U.current)return;const X=(B.clientX-D.current.x)/E.current,W=(B.clientY-D.current.y)/E.current;D.current={x:B.clientX,y:B.clientY},k.current({x:X,y:W})},z=()=>{U.current&&(U.current=!1,I(!1),A.current?.())};return window.addEventListener("mousemove",O),window.addEventListener("mouseup",z),()=>{window.removeEventListener("mousemove",O),window.removeEventListener("mouseup",z)}},[_]),m.useEffect(()=>{if(n!=="canvas")return;const O=z=>{if(z.ctrlKey||z.metaKey){z.preventDefault();const B=E.current,X=-z.deltaY*.001*(R.current??1),W=Math.min(Math.max(.2,B+X),3);E.current=W,S.current(W)}};return window.addEventListener("wheel",O,{passive:!1}),()=>window.removeEventListener("wheel",O)},[n]),m.useEffect(()=>{if(!g)return;let O=null;const z=()=>{O&&cancelAnimationFrame(O),O=requestAnimationFrame(()=>{g({width:window.innerWidth,height:window.innerHeight})})};return z(),window.addEventListener("resize",z),()=>{window.removeEventListener("resize",z),O&&cancelAnimationFrame(O)}},[g]),n==="panel"?s.jsxs("div",{ref:T,className:"fixed inset-0 bg-black text-neutral-200 overflow-hidden font-sans select-none z-0",children:[s.jsx("div",{className:"absolute inset-0 z-10 overflow-auto frame-scrollbar",children:e}),s.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]}):s.jsxs("div",{ref:T,className:"fixed inset-0 bg-black text-neutral-200 overflow-hidden font-sans select-none z-0",children:[s.jsx(WX,{items:C??[],children:s.jsx(YR,{panOffset:a,scale:r,onPan:o,onPanStart:u,onPanEnd:h,isPanLocked:f,onClick:v,showGuides:y?.showGuides,onGuidesChange:y?.onGuidesChange,gridOpacity:y?.gridOpacity})}),s.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:"50%",top:"50%",zoom:r},children:s.jsx("div",{style:{position:"absolute",left:a.x,top:a.y},children:e})}),_&&s.jsx("div",{className:`fixed inset-0 z-20 ${H?"cursor-grabbing":"cursor-grab"}`,onMouseDown:Z}),s.jsx("div",{className:"fixed bottom-[36px] z-30",style:{right:(w??280)+16},children:s.jsx(ZX,{scale:r,onZoom:O=>c(O)})}),s.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]})},XX=YX,QX=({title:e,subtitle:t,center:n,actions:a,onTitleClick:r,search:o})=>{const{dragRegionProps:c,onInteractiveMouseDown:u}=Dp(),{navTotalHeight:h}=_w(),f=o&&o.value&&o.value.length>0;return s.jsx("div",{"data-frame-panel":"navigation",className:"fixed top-0 left-0 right-0 z-50 pointer-events-auto",...c,children:s.jsxs("div",{className:"bg-neutral-950/95 backdrop-blur-xl border-b border-neutral-700/80 shadow-[0_4px_30px_rgba(0,0,0,0.5)] flex items-end px-4",style:{height:h},children:[s.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/8 to-transparent"}),s.jsxs("div",{className:"absolute left-4 bottom-0 h-12 z-10 flex items-center gap-3 select-none",onMouseDown:u,children:[t&&s.jsx("span",{className:"text-neutral-400 flex items-center",children:t}),s.jsx("button",{onClick:r,className:"text-[22px] font-bold text-white tracking-[0.25em] font-mono leading-none bg-transparent border-none cursor-pointer",children:e})]}),n&&s.jsx("div",{className:"flex-1 flex justify-center h-12 items-center",onMouseDown:u,children:n}),s.jsxs("div",{className:"absolute right-4 bottom-0 h-12 z-10 flex items-center gap-3",onMouseDown:u,children:[a,o&&s.jsxs("div",{className:"relative w-[220px] bg-white/[0.06] border border-neutral-600/50 rounded px-2.5 hover:border-neutral-500/60 focus-within:border-neutral-400/50 focus-within:bg-white/[0.08] transition-all duration-200",children:[s.jsx(Op,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-400"}),s.jsx("input",{type:"text",value:o.value,onChange:g=>o.onChange(g.target.value),placeholder:o.placeholder??"Search...",className:`
130
+ w-full h-7 pl-5 pr-6 bg-transparent text-[12px] font-mono tracking-wider
131
+ placeholder:text-neutral-400 text-neutral-200
132
+ focus:outline-none transition-all duration-200
133
+ ${f?"text-emerald-400":""}
134
+ `}),f&&s.jsx("button",{onClick:()=>o.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-neutral-400 hover:text-white transition-colors",children:s.jsx(gc,{size:12})})]})]})]})})},JX=QX,eQ=({side:e,title:t,icon:n,isCollapsed:a=!1,onToggleCollapse:r,headerActions:o,footer:c,style:u,width:h,onResizeStart:f,children:g})=>{if(a){const E=e==="left"?Ez:Rz;return s.jsx("button",{onClick:r,className:`fixed top-1/2 -translate-y-1/2 z-40 ${e==="left"?"left-3":"right-3"} p-2.5 rounded bg-neutral-950/95 border border-neutral-700/80 hover:border-emerald-500/60 backdrop-blur-xl shadow-[0_0_20px_rgba(0,0,0,0.5),inset_0_1px_0_rgba(255,255,255,0.08)] hover:shadow-[0_0_30px_rgba(16,185,129,0.2),inset_0_1px_0_rgba(255,255,255,0.1)] transition-all duration-200 group pointer-events-auto`,title:`Expand ${t||"panel"}`,children:s.jsx(E,{size:14,className:"text-neutral-400 group-hover:text-emerald-400 transition-colors",strokeWidth:1.5})})}const v=e==="left"?Sz:Tz,{panelTopOffset:y}=_w(),C=`bg-neutral-950/95 backdrop-blur-xl border border-neutral-700/80 shadow-[0_0_30px_rgba(0,0,0,0.8),inset_0_1px_0_rgba(255,255,255,0.08)] fixed bottom-[28px] z-40 rounded-none border-t-0 overflow-hidden ${e==="left"?"border-l-0 border-r-0":"border-r-0 border-l-0"}`,T={...u,position:"fixed",top:y,left:e==="left"?0:void 0,right:e==="right"?0:void 0,width:`${h||280}px`};return s.jsxs("div",{"data-frame-panel":e==="left"?"manifest":"inspector",className:`${C} pointer-events-none select-none font-mono text-[11px] flex flex-col`,style:T,children:[f&&s.jsxs("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-[7px] cursor-ew-resize z-50 pointer-events-auto group flex items-center justify-center`,onMouseDown:f,children:[s.jsx("div",{className:`absolute top-0 bottom-0 ${e==="left"?"right-0":"left-0"} w-px bg-neutral-700/80 group-hover:bg-emerald-500/50 transition-colors`}),s.jsxs("div",{className:"flex flex-col gap-[3px] opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-neutral-500 group-hover:bg-emerald-400/70"}),s.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-neutral-500 group-hover:bg-emerald-400/70"}),s.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-neutral-500 group-hover:bg-emerald-400/70"})]})]}),!f&&s.jsx("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-px bg-neutral-700/80`}),s.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/12 to-transparent z-10"}),s.jsxs("div",{className:"pointer-events-auto flex-1 flex flex-col overflow-hidden",children:[t&&s.jsx("div",{className:"shrink-0 p-4 border-b border-neutral-700/50",children:s.jsxs("div",{className:"flex items-center justify-between text-neutral-200 text-[12px]",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[n&&s.jsx("span",{className:"text-neutral-400",children:n}),s.jsx("span",{className:"tracking-widest font-bold uppercase",children:t})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[o,r&&s.jsx("button",{onClick:r,className:"p-1 hover:bg-white/10 rounded transition-colors text-neutral-400 hover:text-white",title:"Collapse panel",children:s.jsx(v,{size:12})})]})]})}),s.jsx("div",{className:"flex-1 overflow-y-auto frame-scrollbar",children:g}),c&&s.jsx("div",{className:"shrink-0",children:c})]})]})},dA=eQ,tQ={emerald:{dot:"bg-emerald-500",ping:"bg-emerald-400",text:"text-emerald-500"},amber:{dot:"bg-amber-500",ping:"bg-amber-400",text:"text-amber-500"},red:{dot:"bg-red-500",ping:"bg-red-400",text:"text-red-500"},neutral:{dot:"bg-neutral-500",ping:"bg-neutral-400",text:"text-neutral-400"}},nQ=({left:e,viewport:t,right:n,isMinimapCollapsed:a=!1,onExpandMinimap:r,status:o={label:"READY",color:"emerald"},onToggleTerminal:c,isTerminalOpen:u=!1})=>{const[h,f]=m.useState(new Date),[g,v]=m.useState(!1),[y,x]=m.useState(!1);m.useEffect(()=>{x(!0);const T=setInterval(()=>f(new Date),1e3);return()=>clearInterval(T)},[]);const w=tQ[o.color],C=async()=>{if(!t)return;const T=`PAN: ${t.pan.x.toFixed(0)},${t.pan.y.toFixed(0)} | SIZE: ${t.canvasSize?.w??1024}x${t.canvasSize?.h??1024} | ZOOM: ${(t.zoom*100).toFixed(0)}%`;try{await navigator.clipboard.writeText(T),v(!0),setTimeout(()=>v(!1),1500)}catch{}};return s.jsxs("div",{"data-frame-panel":"status-bar",className:`${f9.statusBar} h-7 flex items-center justify-between px-3 select-none font-mono text-[12px] text-neutral-200 pointer-events-auto`,children:[s.jsxs("div",{className:"flex items-center gap-4",children:[a&&r&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 px-2 py-0.5 rounded bg-white/5 border border-neutral-800 hover:bg-white/10 transition-colors text-neutral-400 hover:text-white",title:"Expand minimap",children:[s.jsx(pz,{size:10}),s.jsx("span",{className:"text-[11px] font-bold",children:"MAP"}),s.jsx(Ip,{size:8,className:"opacity-60"})]}),s.jsx("div",{className:"h-3 w-px bg-neutral-700"})]}),s.jsxs("div",{className:`flex items-center gap-2 ${w.text}`,children:[s.jsxs("div",{className:"relative flex h-2 w-2",children:[s.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${w.ping} opacity-75`}),s.jsx("span",{className:`relative inline-flex rounded-full h-2 w-2 ${w.dot}`})]}),s.jsx("span",{className:"font-bold tracking-wider",children:o.label})]}),e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-3 w-px bg-neutral-700"}),e]})]}),t&&s.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 flex items-center gap-3 opacity-70 hover:opacity-100 transition-opacity",children:s.jsxs("button",{onClick:C,className:"flex items-center gap-3 hover:text-neutral-200 transition-colors cursor-pointer",title:"Copy viewport data",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-neutral-400",children:"PAN:"}),s.jsxs("span",{className:`tabular-nums ${g?"text-emerald-500":""}`,children:[t.pan.x.toFixed(0),",",t.pan.y.toFixed(0)]})]}),s.jsx("div",{className:"h-3 w-px bg-neutral-700"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-neutral-400",children:"SIZE:"}),s.jsxs("span",{className:`tabular-nums ${g?"text-emerald-500":""}`,children:[t.canvasSize?.w??1024,"x",t.canvasSize?.h??1024]})]}),s.jsx("div",{className:"h-3 w-px bg-neutral-700"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-neutral-400",children:"ZOOM:"}),s.jsxs("span",{className:`tabular-nums ${g?"text-emerald-500":""}`,children:[(t.zoom*100).toFixed(0),"%"]})]})]})}),s.jsxs("div",{className:"flex items-center gap-4",children:[n,n&&s.jsx("div",{className:"h-3 w-px bg-neutral-700"}),c&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:c,className:`flex items-center gap-1.5 px-2 py-1 rounded transition-all ${u?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/30":"text-neutral-400 hover:text-neutral-100 hover:bg-white/5 border border-transparent"}`,title:"Toggle Terminal (Ctrl+`)",children:[s.jsxs("span",{className:"text-[12px]",children:[">","_"]}),s.jsx("span",{className:"uppercase text-[11px] font-semibold tracking-wider",children:"Console"})]}),s.jsx("div",{className:"h-3 w-px bg-neutral-700"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-200 min-w-[60px] justify-end",children:[s.jsx(F4,{size:11,className:"text-neutral-400"}),s.jsx("span",{children:y?h.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"})]})]})]})},sQ=nQ,aQ=({onOpenCommandPalette:e,extraControls:t})=>s.jsx("div",{className:"select-none font-mono text-[12px] border-t border-neutral-700/50",children:s.jsxs("div",{className:"px-3 py-2 flex items-center justify-between",children:[s.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-neutral-400 hover:text-white transition-colors",children:[s.jsx(Op,{size:10}),s.jsx("span",{className:"tracking-widest font-bold uppercase",children:"Command Palette"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t,s.jsx("kbd",{className:"text-[11px] text-neutral-400 font-mono",children:"⌘K"})]})]})}),rQ=aQ;typeof window<"u"&&localStorage.getItem("frame_sounds");var{statusBarHeight:Rh}=Vp.layout,fA=120,iQ=({isOpen:e,onClose:t,onToggleMaximize:n,isMaximized:a=!1,height:r=320,onHeightChange:o,title:c,headerActions:u,children:h})=>{const f=m.useRef(!1),g=m.useRef(null),v=m.useCallback(x=>{if(!o)return;x.preventDefault(),f.current=!0;const w=x.clientY,C=r;g.current&&(g.current.style.transition="none");const T=S=>{const k=w-S.clientY,N=window.innerHeight-Rh,A=Math.max(fA,Math.min(N,C+k));g.current&&(g.current.style.height=`${A}px`)},E=S=>{f.current=!1,document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",E),g.current&&(g.current.style.transition="");const k=w-S.clientY,N=window.innerHeight-Rh;o(Math.max(fA,Math.min(N,C+k)))};document.addEventListener("mousemove",T),document.addEventListener("mouseup",E)},[r,o]),y=a?`calc(100vh - ${Rh}px)`:`${r}px`;return s.jsxs("div",{ref:g,className:`
135
+ fixed left-0 right-0 shadow-[0_-10px_40px_rgba(0,0,0,0.8)] flex flex-col border-t border-neutral-700
136
+ bg-neutral-950/95 backdrop-blur-xl
137
+ ${e?"translate-y-0 opacity-100 pointer-events-auto":"translate-y-full opacity-0 pointer-events-none"}
138
+ transition-all duration-300 ease-in-out
139
+ `,style:{bottom:Rh,height:y,zIndex:Vp.zIndex.drawer},children:[s.jsxs("div",{className:"h-9 bg-neutral-900/70 border-b border-neutral-700 flex items-center justify-between px-3 shrink-0 select-none backdrop-blur-sm",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[c||s.jsxs("div",{className:"flex items-center gap-2 text-emerald-400",children:[s.jsx(p2,{size:14}),s.jsx("span",{className:"text-xs font-bold tracking-widest font-mono",children:"TERMINAL"})]}),u]}),s.jsx("div",{className:"flex-1 flex items-center justify-center h-full cursor-ns-resize text-neutral-500 hover:text-neutral-300 transition-colors group",title:"Drag to Resize",onMouseDown:v,children:s.jsx("div",{className:"w-16 h-1 rounded-full bg-neutral-700 group-hover:bg-neutral-500 transition-colors"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:n,className:"p-1.5 rounded hover:bg-neutral-700 text-neutral-400 hover:text-white transition-colors",title:a?"Restore":"Maximize",children:a?s.jsx(h2,{size:14}):s.jsx(Ip,{size:14})}),s.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-red-900/20 text-neutral-400 hover:text-red-400 transition-colors",title:"Close",children:s.jsx(gc,{size:14})})]})]}),s.jsx("div",{className:"flex-1 relative overflow-hidden flex flex-col bg-transparent",children:h})]})},oQ=iQ,lQ=({isOpen:e,onClose:t,commands:n})=>{const[a,r]=m.useState(""),[o,c]=m.useState(0),u=m.useRef(null),h=m.useRef(null),f=n.filter(v=>v.label.toLowerCase().includes(a.toLowerCase()));m.useEffect(()=>{e&&(setTimeout(()=>u.current?.focus(),10),r(""),c(0))},[e]),m.useEffect(()=>{c(0)},[a]),m.useEffect(()=>{h.current?.scrollIntoView({behavior:"smooth",block:"nearest"})},[o]);const g=v=>{v.key==="ArrowDown"?(v.preventDefault(),c(y=>(y+1)%f.length)):v.key==="ArrowUp"?(v.preventDefault(),c(y=>(y-1+f.length)%f.length)):v.key==="Enter"?(v.preventDefault(),f[o]&&(f[o].action(),t())):v.key==="Escape"&&t()};return e?s.jsx("div",{className:"fixed inset-0 z-[100] flex items-start justify-center pt-[15vh] bg-black/60 backdrop-blur-[2px] pointer-events-auto",onClick:t,children:s.jsxs("div",{className:"w-[640px] max-w-[90vw] bg-[#161616] border border-neutral-700 shadow-2xl rounded-lg overflow-hidden flex flex-col animate-in fade-in zoom-in-95 duration-100",onClick:v=>v.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-neutral-700 gap-3",children:[s.jsx(Op,{className:"text-neutral-400",size:18}),s.jsx("input",{ref:u,className:"flex-1 bg-transparent border-none outline-none text-neutral-100 placeholder-neutral-500 font-mono text-sm",placeholder:"Type a command or search...",value:a,onChange:v=>r(v.target.value),onKeyDown:g,autoFocus:!0}),s.jsx("div",{className:"px-1.5 py-0.5 rounded bg-neutral-700 border border-neutral-700 text-[12px] text-neutral-200 font-mono",children:"ESC"})]}),s.jsxs("div",{className:"max-h-[300px] overflow-y-auto py-2 relative",children:[s.jsx("div",{className:"pb-2",children:f.length===0?s.jsx("div",{className:"px-4 py-8 text-center text-neutral-400 text-xs font-mono",children:"No matching commands"}):f.map((v,y)=>s.jsxs("div",{ref:y===o?h:null,className:`px-4 py-2.5 flex items-center gap-3 cursor-pointer transition-colors ${y===o?"bg-emerald-900/20 border-l-2 border-emerald-500":"border-l-2 border-transparent hover:bg-white/5"}`,onClick:()=>{v.action(),t()},onMouseEnter:()=>c(y),children:[v.icon&&s.jsx("div",{className:`text-neutral-300 ${y===o?"text-emerald-400":""}`,children:v.icon}),s.jsx("div",{className:"flex-1",children:s.jsx("div",{className:`text-sm ${y===o?"text-emerald-100":"text-neutral-200"}`,children:v.label})}),v.shortcut&&s.jsx("div",{className:"text-[12px] font-mono text-neutral-300 bg-neutral-800 px-1.5 py-0.5 rounded border border-neutral-700",children:v.shortcut}),y===o&&s.jsx(Z4,{size:14,className:"text-emerald-500 ml-2"})]},v.id))}),f.length>6&&s.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-[#111] to-transparent pointer-events-none"})]}),s.jsxs("div",{className:"px-4 py-1.5 bg-neutral-800/90 backdrop-blur-sm border-t border-neutral-700 flex justify-between items-center text-[12px] text-neutral-300 font-mono relative z-10",children:[s.jsx("span",{children:"Command Palette"}),s.jsxs("span",{children:[f.length," matches"]})]})]})}):null},cQ=lQ;const ZO=m.createContext(null),KO=m.createContext(null);function uQ({children:e}){const[t,n]=m.useState(null);return s.jsx(ZO.Provider,{value:t,children:s.jsx(KO.Provider,{value:n,children:e})})}function dQ(){return m.useContext(ZO)}function fQ(e){const t=m.useContext(KO);m.useEffect(()=>{if(t)return t(e),()=>{t(n=>n?.id===e?.id?null:n)}},[e,t])}const lx=new Map;function hQ(e){const t=e.replace(/\s+/g," ").trim();return t?t.length>180?`${t.slice(0,180)}...`:t:"empty body"}function cx(e,t,n){if(t)try{return JSON.parse(t)}catch{const a=n?.trim()||"non-JSON";throw new Error(`Expected JSON from ${e} but received ${a}: ${hQ(t)}`)}}function mQ(e){return e?JSON.stringify([...new Headers(e).entries()].sort(([t],[n])=>t.localeCompare(n))):""}function pQ(e,t){return`${(t?.method??"GET").toUpperCase()}:${e}:${mQ(t?.headers)}`}async function hA(e,t){const n=await fetch(e,{...t,headers:{...t?.headers??{},...t?.body?{"content-type":"application/json"}:{}}});if(!n.ok){const a=await n.text();let r=a||`HTTP ${n.status}`;try{const o=JSON.parse(a);o?.error&&(r=o.error)}catch{}throw new Error(r)}return{text:await n.text(),contentType:n.headers.get("content-type")}}async function me(e,t){if(!((t?.method??"GET").toUpperCase()==="GET"&&!t?.body)){const u=await hA(e,t);return cx(e,u.text,u.contentType)}const r=pQ(e,t),o=lx.get(r);if(o){const u=await o;return cx(e,u.text,u.contentType)}const c=hA(e,t);lx.set(r,c);try{const u=await c;return cx(e,u.text,u.contentType)}finally{lx.delete(r)}}function Kd(){return!(typeof window>"u"||new URLSearchParams(window.location.search).has("no-ops"))}function gQ(e){switch(e){case"profile":case"observe":case"message":return e;default:return}}function vQ(e){switch(e){case"control":case"mission":case"command":case"warroom":case"conduct":case"conductor":return"mission";case"plan":return"plan";case"issues":case"errors":case"warnings":return"issues";case"agents":case"tail":case"atop":return e;default:return}}function yQ(e){return e==="dm"||e==="channel"||e==="all"?e:void 0}function xQ(e){return e==="recent"||e==="name"||e==="unread"?e:void 0}function bQ(e){switch(e){case"tail":case"session":case"chat":case"work":return e;default:return}}function wQ(e){const t=e?.trim().replace(/\.+$/u,"");return t==="observe"||t==="takeover"?t:void 0}function mA(e){return e==="mission"?"control":e}function jQ(e){return e.searchParams.has("no-ops")?!1:typeof window>"u"?!0:Kd()}const YO="machineId",XO=new Set(["inbox","conversation","agents","fleet","conversations","messages","sessions","channels","mesh","activity","work"]);function NQ(e){return e.searchParams.get(YO)?.trim()||void 0}function kQ(e,t){return!t||!XO.has(e.view)?e:{...e,machineId:t}}function Id(e){return XO.has(e.view)}function oa(e){return"machineId"in e&&e.machineId?e.machineId:null}function Db(e,t){if(!Id(e))return e;const n={...e},a=t?.trim();return a?n.machineId=a:delete n.machineId,n}function SQ(e){return Id(e)?{...e,machineId:""}:e}function CQ(e,t){return Id(e)?"machineId"in e?Db(e,e.machineId??null):Db(e,oa(t)):e}function Nm(e,t){"machineId"in t&&t.machineId&&e.set(YO,t.machineId)}function km(e){const t=e.toString();return t?`?${t}`:""}function bi(e,t){const n=new URLSearchParams;return Nm(n,t),`${e}${km(n)}`}function EQ(e){return"machineId"in e&&e.machineId?`:machine:${e.machineId}`:""}function AQ(e){const t=new URL(e.toString()),n=t.pathname.replace(/^\/+/,"").split("/").filter(Boolean),a=NQ(t),r=h=>kQ(h,a),o=t.searchParams.get("compose")==="ask"?"ask":void 0,c=gQ(t.searchParams.get("tab")),u=t.searchParams.get("project")?.trim()||void 0;if(n[0]==="agent"&&n[1])return{view:"agent-info",conversationId:decodeURIComponent(n[1])};if(n[0]==="agents"&&n[1]&&n[2]==="c"&&n[3])return r({view:"agents",agentId:decodeURIComponent(n[1]),conversationId:decodeURIComponent(n[3]),tab:c??"message"});if(n[0]==="agents"&&n[1]){const h=decodeURIComponent(n[1]);return r(c==="message"?{view:"agents",agentId:h,conversationId:ps(h),tab:"message"}:{view:"agents",agentId:h,...c?{tab:c}:{}})}if(n[0]==="agents")return r({view:"agents",...u?{projectKey:u}:{}});if(n[0]==="fleet")return r({view:"fleet"});if(n[0]==="c"&&n[1])return r({view:"conversation",conversationId:decodeURIComponent(n[1]),...o?{composeMode:o}:{}});if(n[0]==="sessions"&&n[1])return r({view:"sessions",sessionId:decodeURIComponent(n[1])});if(n[0]==="conversations")return r({view:"conversations"});if(n[0]==="messages"){const h=yQ(t.searchParams.get("filter")),f=xQ(t.searchParams.get("sort")),g={view:"messages",...n[1]?{conversationId:decodeURIComponent(n[1])}:{},...h?{filter:h}:{},...f?{sort:f}:{}};return r(g)}if(n[0]==="sessions")return r({view:"sessions"});if(n[0]==="channels"&&n[1])return r({view:"channels",channelId:decodeURIComponent(n[1])});if(n[0]==="channels")return r({view:"channels"});if(n[0]==="mesh")return r({view:"mesh"});if(n[0]==="broker")return{view:"broker"};if(n[0]==="briefings"&&n[1])return{view:"briefings",briefingId:decodeURIComponent(n[1])};if(n[0]==="briefings")return{view:"briefings"};if(n[0]==="activity")return r({view:"activity"});if(n[0]==="work"&&n[1])return r({view:"work",workId:decodeURIComponent(n[1])});if(n[0]==="follow"){const h=bQ(t.searchParams.get("view")),f={view:"follow",...h?{preferredView:h}:{}},g=n[1],v=n[2]?decodeURIComponent(n[2]):"";g==="flight"&&v&&(f.flightId=v),g==="invocation"&&v&&(f.invocationId=v),g==="conversation"&&v&&(f.conversationId=v),g==="work"&&v&&(f.workId=v),g==="session"&&v&&(f.sessionId=v),g==="agent"&&v&&(f.targetAgentId=v);const y=t.searchParams.get("flightId"),x=t.searchParams.get("invocationId"),w=t.searchParams.get("conversationId"),C=t.searchParams.get("workId"),T=t.searchParams.get("sessionId"),E=t.searchParams.get("targetAgentId");return y&&(f.flightId=y),x&&(f.invocationId=x),w&&(f.conversationId=w),C&&(f.workId=C),T&&(f.sessionId=T),E&&(f.targetAgentId=E),f}if(n[0]==="settings")return n[1]==="agents"?{view:"settings",section:"agents",...n[2]?{agentId:decodeURIComponent(n[2])}:{}}:{view:"settings"};if(n[0]==="terminal"){const h=wQ(t.searchParams.get("mode"));return{view:"terminal",...n[1]?{agentId:decodeURIComponent(n[1])}:{},...h?{mode:h}:{}}}if(n[0]==="ops"){if(!jQ(t))return r({view:"inbox"});const h=vQ(n[1])??"mission",f=h==="tail"?t.searchParams.get("q")?.trim():"";return{view:"ops",mode:h,...f?{tailQuery:f}:{}}}return r({view:"inbox"})}function ux(){return AQ(window.location.href)}function TQ(e){switch(e.view){case"inbox":return bi("/",e);case"conversation":{const t=new URLSearchParams;return e.composeMode==="ask"&&t.set("compose","ask"),Nm(t,e),`/c/${encodeURIComponent(e.conversationId)}${km(t)}`}case"agent-info":return`/agent/${encodeURIComponent(e.conversationId)}`;case"agents":{const t=new URLSearchParams,n=!!e.agentId&&!!e.conversationId&&e.conversationId===ps(e.agentId),a=n?"profile":e.conversationId?"message":"profile";return n?t.set("tab",e.tab??"message"):e.tab&&e.tab!==a&&t.set("tab",e.tab),!e.agentId&&e.projectKey&&t.set("project",e.projectKey),Nm(t,e),`${e.agentId?n?`/agents/${encodeURIComponent(e.agentId)}`:e.conversationId?`/agents/${encodeURIComponent(e.agentId)}/c/${encodeURIComponent(e.conversationId)}`:`/agents/${encodeURIComponent(e.agentId)}`:"/agents"}${km(t)}`}case"fleet":return bi("/fleet",e);case"conversations":return bi("/conversations",e);case"messages":{const t=new URLSearchParams;return e.filter&&e.filter!=="all"&&t.set("filter",e.filter),e.sort&&e.sort!=="recent"&&t.set("sort",e.sort),Nm(t,e),`${e.conversationId?`/messages/${encodeURIComponent(e.conversationId)}`:"/messages"}${km(t)}`}case"sessions":return bi(e.sessionId?`/sessions/${encodeURIComponent(e.sessionId)}`:"/sessions",e);case"channels":return bi(e.channelId?`/channels/${encodeURIComponent(e.channelId)}`:"/channels",e);case"mesh":return bi("/mesh",e);case"broker":return"/broker";case"briefings":return e.briefingId?`/briefings/${encodeURIComponent(e.briefingId)}`:"/briefings";case"activity":return bi("/activity",e);case"work":return bi(`/work/${encodeURIComponent(e.workId)}`,e);case"settings":return e.section==="agents"?e.agentId?`/settings/agents/${encodeURIComponent(e.agentId)}`:"/settings/agents":"/settings";case"ops":return e.mode?e.mode==="tail"&&e.tailQuery?`/ops/${mA(e.mode)}?q=${encodeURIComponent(e.tailQuery)}`:`/ops/${mA(e.mode)}`:"/ops";case"follow":{const t=new URLSearchParams;e.preferredView&&t.set("view",e.preferredView),e.flightId&&t.set("flightId",e.flightId),e.invocationId&&t.set("invocationId",e.invocationId),e.conversationId&&t.set("conversationId",e.conversationId),e.workId&&t.set("workId",e.workId),e.sessionId&&t.set("sessionId",e.sessionId),e.targetAgentId&&t.set("targetAgentId",e.targetAgentId);const n=t.toString();return`/follow${n?`?${n}`:""}`}case"terminal":return e.mode?`${e.agentId?`/terminal/${encodeURIComponent(e.agentId)}`:"/terminal"}?mode=${e.mode}`:e.agentId?`/terminal/${encodeURIComponent(e.agentId)}`:"/terminal"}}function dx(e){const t=EQ(e);switch(e.view){case"conversation":return`conv:${e.conversationId}${t}`;case"agent-info":return`agent-info:${e.conversationId}`;case"settings":return e.section==="agents"?`settings:agents:${e.agentId??""}`:"settings";case"agents":return e.conversationId?`agent-conv:${e.conversationId}:${e.tab??"message"}${t}`:e.agentId?`agent:${e.agentId}:${e.tab??"profile"}${t}`:e.projectKey?`agents-project:${e.projectKey}${t}`:`agents${t}`;case"sessions":return e.sessionId?`session:${e.sessionId}${t}`:`sessions${t}`;case"messages":return e.conversationId?`messages:${e.conversationId}${t}`:`messages${t}`;case"channels":return e.channelId?`channel:${e.channelId}${t}`:`channels${t}`;case"work":return`work:${e.workId}${t}`;case"ops":return`ops:${e.mode??"plan"}:${e.tailQuery??""}`;case"follow":return`follow:${e.flightId??e.invocationId??e.conversationId??e.workId??e.sessionId??e.targetAgentId??""}:${e.preferredView??""}`;case"terminal":return`terminal:${e.agentId??""}:${e.mode??"takeover"}`;default:return`${e.view}${t}`}}function MQ(){const[e,t]=m.useState(ux),n=m.useRef({});m.useEffect(()=>{const r=()=>{const o=ux();t(o),requestAnimationFrame(()=>{window.scrollTo(0,n.current[dx(o)]??0)})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[]);const a=m.useCallback(r=>{const o=r.view==="ops"&&!Kd()?{view:"inbox"}:r,c=ux(),u=CQ(o,c);n.current[dx(c)]=window.scrollY,window.history.pushState(null,"",TQ(u)),t(u),requestAnimationFrame(()=>{window.scrollTo(0,n.current[dx(u)]??0)})},[]);return{route:e,navigate:a}}function Ow(e){const t=e.match(/^dm\.operator\.(.+)$/);return t?t[1]:null}function ps(e){return`dm.operator.${e}`}var RQ=Object.create,QO=Object.defineProperty,IQ=Object.getOwnPropertyDescriptor,JO=Object.getOwnPropertyNames,_Q=Object.getPrototypeOf,OQ=Object.prototype.hasOwnProperty,jr=(e,t)=>function(){return t||(0,e[JO(e)[0]])((t={exports:{}}).exports,t),t.exports},$Q=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(var r=JO(t),o=0,c=r.length,u;o<c;o++)u=r[o],!OQ.call(e,u)&&u!==n&&QO(e,u,{get:(h=>t[h]).bind(null,u),enumerable:!(a=IQ(t,u))||a.enumerable});return e},Dn=(e,t,n)=>(n=e!=null?RQ(_Q(e)):{},$Q(QO(n,"default",{value:e,enumerable:!0}),e)),e$=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(a){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},t.exports.__esModule=!0,t.exports.default=t.exports,n(a)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),PQ=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=e$().default;function a(r,o){if(n(r)!="object"||!r)return r;var c=r[Symbol.toPrimitive];if(c!==void 0){var u=c.call(r,o||"default");if(n(u)!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(r)}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),DQ=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=e$().default,a=PQ();function r(o){var c=a(o,"string");return n(c)=="symbol"?c:c+""}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Jo=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=DQ();function a(r,o,c){return(o=n(o))in r?Object.defineProperty(r,o,{value:c,enumerable:!0,configurable:!0,writable:!0}):r[o]=c,r}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),Ka=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=Jo();function a(o,c){var u=Object.keys(o);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(o);c&&(h=h.filter(function(f){return Object.getOwnPropertyDescriptor(o,f).enumerable})),u.push.apply(u,h)}return u}function r(o){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?a(Object(u),!0).forEach(function(h){n(o,h,u[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(u)):a(Object(u)).forEach(function(h){Object.defineProperty(o,h,Object.getOwnPropertyDescriptor(u,h))})}return o}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});function Yd(e){const t={subscribe(n){let a=null,r=!1,o=!1,c=!1;function u(){if(a===null){c=!0;return}o||(o=!0,typeof a=="function"?a():a&&a.unsubscribe())}return a=e({next(h){var f;r||(f=n.next)===null||f===void 0||f.call(n,h)},error(h){var f;r||(r=!0,(f=n.error)===null||f===void 0||f.call(n,h),u())},complete(){var h;r||(r=!0,(h=n.complete)===null||h===void 0||h.call(n),u())}}),c&&u(),{unsubscribe:u}},pipe(...n){return n.reduce(LQ,t)}};return t}function LQ(e,t){return t(e)}function zQ(e){const t=new AbortController;return new Promise((a,r)=>{let o=!1;function c(){o||(o=!0,u.unsubscribe())}t.signal.addEventListener("abort",()=>{r(t.signal.reason)});const u=e.subscribe({next(h){o=!0,a(h),c()},error(h){r(h)},complete(){t.abort(),c()}})})}function BQ(e){return t=>{let n=0,a=null;const r=[];function o(){a||(a=t.subscribe({next(u){for(const f of r){var h;(h=f.next)===null||h===void 0||h.call(f,u)}},error(u){for(const f of r){var h;(h=f.error)===null||h===void 0||h.call(f,u)}},complete(){for(const h of r){var u;(u=h.complete)===null||u===void 0||u.call(h)}}}))}function c(){if(n===0&&a){const u=a;a=null,u.unsubscribe()}}return Yd(u=>(n++,r.push(u),o(),{unsubscribe(){n--,c();const h=r.findIndex(f=>f===u);h>-1&&r.splice(h,1)}}))}}function t$(e){let t=e;const n=[],a=c=>{t!==void 0&&c.next(t),n.push(c)},r=c=>{n.splice(n.indexOf(c),1)},o=Yd(c=>(a(c),()=>{r(c)}));return o.next=c=>{if(t!==c){t=c;for(const u of n)u.next(c)}},o.get=()=>t,o}function UQ(e){return Yd(t=>{function n(r=0,o=e.op){const c=e.links[r];if(!c)throw new Error("No more links to execute - did you forget to add an ending link?");return c({op:o,next(h){return n(r+1,h)}})}return n().subscribe(t)})}function _d(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function FQ(){return Object.create(null)}const pA=e=>e();function gA(e=0){return new Promise(t=>setTimeout(t,e))}var VQ=Object.create,n$=Object.defineProperty,HQ=Object.getOwnPropertyDescriptor,s$=Object.getOwnPropertyNames,qQ=Object.getPrototypeOf,WQ=Object.prototype.hasOwnProperty,Xd=(e,t)=>function(){return t||(0,e[s$(e)[0]])((t={exports:{}}).exports,t),t.exports},GQ=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(var r=s$(t),o=0,c=r.length,u;o<c;o++)u=r[o],!WQ.call(e,u)&&u!==n&&n$(e,u,{get:(h=>t[h]).bind(null,u),enumerable:!(a=HQ(t,u))||a.enumerable});return e},rg=(e,t,n)=>(n=e!=null?VQ(qQ(e)):{},GQ(n$(n,"default",{value:e,enumerable:!0}),e));const a$=()=>{},vA=e=>{Object.freeze&&Object.freeze(e)};function r$(e,t,n){var a;const r=t.join(".");return(a=n[r])!==null&&a!==void 0||(n[r]=new Proxy(a$,{get(o,c){if(!(typeof c!="string"||c==="then"))return r$(e,[...t,c],n)},apply(o,c,u){const h=t[t.length-1];let f={args:u,path:t};return h==="call"?f={args:u.length>=2?[u[1]]:[],path:t.slice(0,-1)}:h==="apply"&&(f={args:u.length>=2?u[1]:[],path:t.slice(0,-1)}),vA(f.args),vA(f.path),e(f)}})),n[r]}const ZQ=e=>r$(e,[],FQ()),KQ=e=>new Proxy(a$,{get(t,n){if(n!=="then")return e(n)}});var i$=Xd({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(a){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},t.exports.__esModule=!0,t.exports.default=t.exports,n(a)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),YQ=Xd({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=i$().default;function a(r,o){if(n(r)!="object"||!r)return r;var c=r[Symbol.toPrimitive];if(c!==void 0){var u=c.call(r,o||"default");if(n(u)!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(r)}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),XQ=Xd({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=i$().default,a=YQ();function r(o){var c=a(o,"string");return n(c)=="symbol"?c:c+""}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),o$=Xd({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=XQ();function a(r,o,c){return(o=n(o))in r?Object.defineProperty(r,o,{value:c,enumerable:!0,configurable:!0,writable:!0}):r[o]=c,r}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),$w=Xd({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=o$();function a(o,c){var u=Object.keys(o);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(o);c&&(h=h.filter(function(f){return Object.getOwnPropertyDescriptor(o,f).enumerable})),u.push.apply(u,h)}return u}function r(o){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?a(Object(u),!0).forEach(function(h){n(o,h,u[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(u)):a(Object(u)).forEach(function(h){Object.defineProperty(o,h,Object.getOwnPropertyDescriptor(u,h))})}return o}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});rg($w());rg(o$());var Ih=rg($w());function QQ(e,t){if("error"in e){const a=t.deserialize(e.error);return{ok:!1,error:(0,Ih.default)((0,Ih.default)({},e),{},{error:a})}}return{ok:!0,result:(0,Ih.default)((0,Ih.default)({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var fx=class extends Error{constructor(){super("Unable to transform response from server")}};function JQ(e,t){let n;try{n=QQ(e,t)}catch{throw new fx}if(!n.ok&&(!_d(n.error.error)||typeof n.error.error.code!="number"))throw new fx;if(n.ok&&!_d(n.result))throw new fx;return n}rg($w());var _h=Dn(Jo()),zl=Dn(Ka());function eJ(e){return e instanceof Io}function tJ(e){return _d(e)&&_d(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function nJ(e,t){return typeof e=="string"?e:_d(e)&&typeof e.message=="string"?e.message:t}var Io=class Sm extends Error{constructor(t,n){var a,r;const o=n?.cause;super(t,{cause:o}),(0,_h.default)(this,"cause",void 0),(0,_h.default)(this,"shape",void 0),(0,_h.default)(this,"data",void 0),(0,_h.default)(this,"meta",void 0),this.meta=n?.meta,this.cause=o,this.shape=n==null||(a=n.result)===null||a===void 0?void 0:a.error,this.data=n==null||(r=n.result)===null||r===void 0?void 0:r.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,Sm.prototype)}static from(t,n={}){const a=t;return eJ(a)?(n.meta&&(a.meta=(0,zl.default)((0,zl.default)({},a.meta),n.meta)),a):tJ(a)?new Sm(a.error.message,(0,zl.default)((0,zl.default)({},n),{},{result:a,cause:n.cause})):new Sm(nJ(a,"Unknown error"),(0,zl.default)((0,zl.default)({},n),{},{cause:a}))}};function sJ(e){const t=e;return t?"input"in t?t:{input:t,output:t}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}Dn(Ka());Dn(Ka());Dn(Ka());Dn(Ka());const aJ={encode:e=>JSON.stringify(e),decode:e=>{if(typeof e!="string")throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");return JSON.parse(e)}},rJ={enabled:!1,closeMs:0},iJ={enabled:!1,pongTimeoutMs:1e3,intervalMs:5e3},oJ=e=>e===0?0:Math.min(1e3*2**e,3e4),l$=(e,...t)=>typeof e=="function"?e(...t):e;var lJ=Dn(Jo()),Bl=class c$ extends Error{constructor(t){super(t.message,{cause:t.cause}),this.name="TRPCWebSocketClosedError",Object.setPrototypeOf(this,c$.prototype)}},cJ=class{constructor(e,t){this.onTimeout=e,this.timeoutMs=t,(0,lJ.default)(this,"timeout",void 0)}reset(){this.timeout&&(clearTimeout(this.timeout),this.timeout=setTimeout(this.onTimeout,this.timeoutMs))}start(){clearTimeout(this.timeout),this.timeout=setTimeout(this.onTimeout,this.timeoutMs)}stop(){clearTimeout(this.timeout),this.timeout=void 0}};function u$(){let e,t;return{promise:new Promise((a,r)=>{e=a,t=r}),resolve:e,reject:t}}async function uJ(e){const t=await l$(e.url);if(!e.connectionParams)return t;const a=`${t.includes("?")?"&":"?"}connectionParams=1`;return t+a}async function dJ(e,t){const n={method:"connectionParams",data:await l$(e)};return t.encode(n)}var yA=Dn(Jo()),fJ=class{constructor(){(0,yA.default)(this,"outgoingRequests",new Array),(0,yA.default)(this,"pendingRequests",{})}register(e,t){const{promise:n,resolve:a}=u$();return this.outgoingRequests.push({id:String(e.id),message:e,end:n,callbacks:{next:t.next,complete:()=>{t.complete(),a()},error:r=>{t.error(r),a()}}}),()=>{this.delete(e.id),t.complete(),a()}}delete(e){e!==null&&(this.outgoingRequests=this.outgoingRequests.filter(({id:t})=>t!==String(e)),delete this.pendingRequests[String(e)])}flush(){const e=this.outgoingRequests;this.outgoingRequests=[];for(const t of e)this.pendingRequests[t.id]=t;return e}getPendingRequests(){return Object.values(this.pendingRequests)}getPendingRequest(e){return e===null?null:this.pendingRequests[String(e)]}getOutgoingRequests(){return this.outgoingRequests}getRequests(){return[...this.getOutgoingRequests().map(e=>({state:"outgoing",message:e.message,end:e.end,callbacks:e.callbacks})),...this.getPendingRequests().map(e=>({state:"pending",message:e.message,end:e.end,callbacks:e.callbacks}))]}hasPendingRequests(){return this.getPendingRequests().length>0}hasPendingSubscriptions(){return this.getPendingRequests().some(e=>e.message.method==="subscription")}hasOutgoingRequests(){return this.outgoingRequests.length>0}},Ei=Dn(Jo());function hJ(e){const{promise:t,resolve:n,reject:a}=u$();return e.addEventListener("open",()=>{e.removeEventListener("error",a),n()}),e.addEventListener("error",a),t}function mJ(e,{intervalMs:t,pongTimeoutMs:n}){let a,r;function o(){a=setTimeout(()=>{e.send("PING"),r=setTimeout(()=>{e.close()},n)},t)}function c(){clearTimeout(a),o()}function u(){clearTimeout(r),c()}e.addEventListener("open",o),e.addEventListener("message",({data:h})=>{clearTimeout(a),o(),h==="PONG"&&u()}),e.addEventListener("close",()=>{clearTimeout(a),clearTimeout(r)})}var d$=class Lb{constructor(t){var n;if((0,Ei.default)(this,"id",++Lb.connectCount),(0,Ei.default)(this,"WebSocketPonyfill",void 0),(0,Ei.default)(this,"urlOptions",void 0),(0,Ei.default)(this,"keepAliveOpts",void 0),(0,Ei.default)(this,"encoder",void 0),(0,Ei.default)(this,"wsObservable",t$(null)),(0,Ei.default)(this,"openPromise",null),this.WebSocketPonyfill=(n=t.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(t){this.wsObservable.next(t)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var t=this;if(t.openPromise)return t.openPromise;t.id=++Lb.connectCount;const n=uJ(t.urlOptions).then(a=>new t.WebSocketPonyfill(a));t.openPromise=n.then(async a=>{t.ws=a,a.binaryType="arraybuffer",a.addEventListener("message",function({data:r}){r==="PING"&&this.send("PONG")}),t.keepAliveOpts.enabled&&mJ(a,t.keepAliveOpts),a.addEventListener("close",()=>{t.ws===a&&(t.ws=null)}),await hJ(a),t.urlOptions.connectionParams&&a.send(await dJ(t.urlOptions.connectionParams,t.encoder))});try{await t.openPromise}finally{t.openPromise=null}}async close(){var t=this;try{await t.openPromise}finally{var n;(n=t.ws)===null||n===void 0||n.close()}}};(0,Ei.default)(d$,"connectCount",0);function pJ(e){return e.isOpen()?{id:e.id,state:"open",ws:e.ws}:e.isClosed()?{id:e.id,state:"closed",ws:e.ws}:e.ws?{id:e.id,state:"connecting",ws:e.ws}:null}var nr=Dn(Jo()),Ul=Dn(Ka()),gJ=class{constructor(e){var t,n;(0,nr.default)(this,"connectionState",void 0),(0,nr.default)(this,"allowReconnect",!1),(0,nr.default)(this,"requestManager",new fJ),(0,nr.default)(this,"activeConnection",void 0),(0,nr.default)(this,"reconnectRetryDelay",void 0),(0,nr.default)(this,"inactivityTimeout",void 0),(0,nr.default)(this,"callbacks",void 0),(0,nr.default)(this,"lazyMode",void 0),(0,nr.default)(this,"encoder",void 0),(0,nr.default)(this,"reconnecting",null),this.encoder=(t=e.experimental_encoder)!==null&&t!==void 0?t:aJ,this.callbacks={onOpen:e.onOpen,onClose:e.onClose,onError:e.onError};const a=(0,Ul.default)((0,Ul.default)({},rJ),e.lazy);this.inactivityTimeout=new cJ(()=>{if(this.requestManager.hasOutgoingRequests()||this.requestManager.hasPendingRequests()){this.inactivityTimeout.reset();return}this.close().catch(()=>null)},a.closeMs),this.activeConnection=new d$({WebSocketPonyfill:e.WebSocket,urlOptions:e,keepAlive:(0,Ul.default)((0,Ul.default)({},iJ),e.keepAlive),encoder:this.encoder}),this.activeConnection.wsObservable.subscribe({next:r=>{r&&this.setupWebSocketListeners(r)}}),this.reconnectRetryDelay=(n=e.retryDelayMs)!==null&&n!==void 0?n:oJ,this.lazyMode=a.enabled,this.connectionState=t$({type:"state",state:a.enabled?"idle":"connecting",error:null}),this.lazyMode||this.open().catch(()=>null)}async open(){var e=this;e.allowReconnect=!0,e.connectionState.get().state==="idle"&&e.connectionState.next({type:"state",state:"connecting",error:null});try{await e.activeConnection.open()}catch(t){return e.reconnect(new Bl({message:"Initialization error",cause:t})),e.reconnecting}}async close(){var e=this;e.allowReconnect=!1,e.inactivityTimeout.stop();const t=[];for(const n of e.requestManager.getRequests())n.message.method==="subscription"?n.callbacks.complete():n.state==="outgoing"?n.callbacks.error(Io.from(new Bl({message:"Closed before connection was established"}))):t.push(n.end);await Promise.all(t).catch(()=>null),await e.activeConnection.close().catch(()=>null),e.connectionState.next({type:"state",state:"idle",error:null})}request({op:{id:e,type:t,path:n,input:a,signal:r},transformer:o,lastEventId:c}){return Yd(u=>{const h=this.batchSend({id:e,method:t,params:{input:o.input.serialize(a),path:n,lastEventId:c}},(0,Ul.default)((0,Ul.default)({},u),{},{next(f){const g=JQ(f,o.output);if(!g.ok){u.error(Io.from(g.error));return}u.next({result:g.result})}}));return()=>{h(),t==="subscription"&&this.activeConnection.isOpen()&&this.send({id:e,method:"subscription.stop"}),r?.removeEventListener("abort",h)}})}get connection(){return pJ(this.activeConnection)}reconnect(e){var t=this;if(this.connectionState.next({type:"state",state:"connecting",error:Io.from(e)}),this.reconnecting)return;const n=async a=>{try{await gA(t.reconnectRetryDelay(a)),t.allowReconnect&&(await t.activeConnection.close(),await t.activeConnection.open(),t.requestManager.hasPendingRequests()&&t.send(t.requestManager.getPendingRequests().map(({message:r})=>r))),t.reconnecting=null}catch{await n(a+1)}};this.reconnecting=n(0)}setupWebSocketListeners(e){var t=this;const n=a=>{const r=this.requestManager.getPendingRequests();for(const{message:o,callbacks:c}of r)o.method!=="subscription"&&(c.error(Io.from(a??new Bl({message:"WebSocket closed",cause:a}))),this.requestManager.delete(o.id))};e.addEventListener("open",()=>{pA(async()=>{var a,r;t.lazyMode&&t.inactivityTimeout.start(),(a=(r=t.callbacks).onOpen)===null||a===void 0||a.call(r),t.connectionState.next({type:"state",state:"pending",error:null})}).catch(a=>{e.close(3e3),n(a)})}),e.addEventListener("message",({data:a})=>{if(this.inactivityTimeout.reset(),["PING","PONG"].includes(a))return;const r=this.encoder.decode(a);if("method"in r){this.handleIncomingRequest(r);return}this.handleResponseMessage(r)}),e.addEventListener("close",a=>{var r,o;n(a),(r=(o=this.callbacks).onClose)===null||r===void 0||r.call(o,a),(!this.lazyMode||this.requestManager.hasPendingSubscriptions())&&this.reconnect(new Bl({message:"WebSocket closed",cause:a}))}),e.addEventListener("error",a=>{var r,o;n(a),(r=(o=this.callbacks).onError)===null||r===void 0||r.call(o,a),this.reconnect(new Bl({message:"WebSocket closed",cause:a}))})}handleResponseMessage(e){const t=this.requestManager.getPendingRequest(e.id);if(!t)return;t.callbacks.next(e);let n=!0;"result"in e&&t.message.method==="subscription"&&(e.result.type==="data"&&(t.message.params.lastEventId=e.result.id),e.result.type!=="stopped"&&(n=!1)),n&&(t.callbacks.complete(),this.requestManager.delete(e.id))}handleIncomingRequest(e){e.method==="reconnect"&&this.reconnect(new Bl({message:"Server requested reconnect"}))}send(e){if(!this.activeConnection.isOpen())throw new Error("Active connection is not open");const t=e instanceof Array?e:[e];this.activeConnection.ws.send(this.encoder.encode(t.length===1?t[0]:t))}batchSend(e,t){var n=this;return this.inactivityTimeout.reset(),pA(async()=>{n.activeConnection.isOpen()||await n.open(),await gA(0),n.requestManager.hasOutgoingRequests()&&n.send(n.requestManager.flush().map(({message:a})=>a))}).catch(a=>{this.requestManager.delete(e.id),t.error(Io.from(a))}),this.requestManager.register(e,t)}};function f$(e){return new gJ(e)}function h$(e){const{client:t}=e,n=sJ(e.transformer);return()=>({op:a})=>Yd(r=>{const o=a.type==="subscription"?t.connectionState.subscribe({next(u){r.next({result:u,context:a.context})}}):null,c=t.request({op:a,transformer:n}).subscribe(r);return()=>{c.unsubscribe(),o?.unsubscribe()}})}var hx=Dn(Jo()),xA=Dn(Ka()),vJ=class{constructor(e){(0,hx.default)(this,"links",void 0),(0,hx.default)(this,"runtime",void 0),(0,hx.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return UQ({links:this.links,op:(0,xA.default)((0,xA.default)({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(BQ())}async requestAsPromise(e){var t=this;try{const n=t.$request(e);return(await zQ(n)).result.data}catch(n){throw Io.from(n)}}query(e,t,n){return this.requestAsPromise({type:"query",path:e,input:t,context:n?.context,signal:n?.signal})}mutation(e,t,n){return this.requestAsPromise({type:"mutation",path:e,input:t,context:n?.context,signal:n?.signal})}subscription(e,t,n){return this.$request({type:"subscription",path:e,input:t,context:n.context,signal:n.signal}).subscribe({next(r){switch(r.result.type){case"state":{var o;(o=n.onConnectionStateChange)===null||o===void 0||o.call(n,r.result);break}case"started":{var c;(c=n.onStarted)===null||c===void 0||c.call(n,{context:r.context});break}case"stopped":{var u;(u=n.onStopped)===null||u===void 0||u.call(n);break}case"data":case void 0:{var h;(h=n.onData)===null||h===void 0||h.call(n,r.result.data);break}}},error(r){var o;(o=n.onError)===null||o===void 0||o.call(n,r)},complete(){var r;(r=n.onComplete)===null||r===void 0||r.call(n)}})}};const yJ=Symbol.for("trpc_untypedClient"),xJ={query:"query",mutate:"mutation",subscribe:"subscription"},bJ=e=>xJ[e];function wJ(e){const t=ZQ(({path:n,args:a})=>{const r=[...n],o=bJ(r.pop()),c=r.join(".");return e[o](c,...a)});return KQ(n=>n===yJ?e:t[n])}function m$(e){const t=new vJ(e);return wJ(t)}Dn(Ka());Dn(Ka());var jJ=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(r){var o,c,u,h=2;for(typeof Symbol<"u"&&(c=Symbol.asyncIterator,u=Symbol.iterator);h--;){if(c&&(o=r[c])!=null)return o.call(r);if(u&&(o=r[u])!=null)return new a(o.call(r));c="@@asyncIterator",u="@@iterator"}throw new TypeError("Object is not async iterable")}function a(r){function o(c){if(Object(c)!==c)return Promise.reject(new TypeError(c+" is not an object."));var u=c.done;return Promise.resolve(c.value).then(function(h){return{value:h,done:u}})}return a=function(u){this.s=u,this.n=u.next},a.prototype={s:null,n:null,next:function(){return o(this.n.apply(this.s,arguments))},return:function(u){var h=this.s.return;return h===void 0?Promise.resolve({value:u,done:!0}):o(h.apply(this.s,arguments))},throw:function(u){var h=this.s.return;return h===void 0?Promise.reject(u):o(h.apply(this.s,arguments))}},new a(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});Dn(jJ());Dn(Ka());var NJ=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var a=typeof SuppressedError=="function"?SuppressedError:function(u,h){var f=Error();return f.name="SuppressedError",f.error=u,f.suppressed=h,f},r={},o=[];function c(u,h){if(h!=null){if(Object(h)!==h)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(u)var f=h[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(f===void 0&&(f=h[Symbol.dispose||Symbol.for("Symbol.dispose")],u))var g=f;if(typeof f!="function")throw new TypeError("Object is not disposable.");g&&(f=function(){try{g.call(h)}catch(y){return Promise.reject(y)}}),o.push({v:h,d:f,a:u})}else u&&o.push({d:h,a:u});return h}return{e:r,u:c.bind(null,!1),a:c.bind(null,!0),d:function(){var h,f=this.e,g=0;function v(){for(;h=o.pop();)try{if(!h.a&&g===1)return g=0,o.push(h),Promise.resolve().then(v);if(h.d){var x=h.d.call(h.v);if(h.a)return g|=2,Promise.resolve(x).then(v,y)}else g|=1}catch(w){return y(w)}if(g===1)return f!==r?Promise.reject(f):Promise.resolve();if(f!==r)throw f}function y(x){return f=f!==r?new a(x,f):x,v()}return v()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),p$=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(a,r){this.v=a,this.k=r}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),kJ=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=p$();function a(r){return new n(r,0)}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),SJ=jr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=p$();function a(o){return function(){return new r(o.apply(this,arguments))}}function r(o){var c,u;function h(g,v){try{var y=o[g](v),x=y.value,w=x instanceof n;Promise.resolve(w?x.v:x).then(function(C){if(w){var T=g==="return"?"return":"next";if(!x.k||C.done)return h(T,C);C=o[T](C).value}f(y.done?"return":"normal",C)},function(C){h("throw",C)})}catch(C){f("throw",C)}}function f(g,v){switch(g){case"return":c.resolve({value:v,done:!0});break;case"throw":c.reject(v);break;default:c.resolve({value:v,done:!1})}(c=c.next)?h(c.key,c.arg):u=null}this._invoke=function(g,v){return new Promise(function(y,x){var w={key:g,arg:v,resolve:y,reject:x,next:null};u?u=u.next=w:(c=u=w,h(g,v))})},typeof o.return!="function"&&(this.return=void 0)}r.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},r.prototype.next=function(o){return this._invoke("next",o)},r.prototype.throw=function(o){return this._invoke("throw",o)},r.prototype.return=function(o){return this._invoke("return",o)},t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}});Dn(NJ());Dn(kJ());Dn(SJ());Dn(Ka());const uc=new Set;let mx=null,bA=null,dd=null,dc=null;function CJ(){return`ws://${typeof window<"u"?window.location.hostname:"127.0.0.1"}:65535/trpc`}function EJ(e){for(const t of[...uc])t(e)}function AJ(){dc||uc.size===0||(dc=setTimeout(()=>{dc=null,g$()},2e3))}function g$(){dd||uc.size===0||(mx||(mx=f$({url:CJ()}),bA=m$({links:[h$({client:mx})]})),dd=bA.control.events.subscribe(void 0,{onData:e=>{const t=e.data;t&&EJ(t)},onError:()=>{dd=null,AJ()}}))}function TJ(){dc&&(clearTimeout(dc),dc=null),dd?.unsubscribe(),dd=null}function MJ(e){return uc.add(e),g$(),()=>{uc.delete(e),!(uc.size>0)&&TJ()}}function tn(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>MJ(n=>{t.current(n)}),[])}function Je(e){return e==="working"?"working":!e||e==="offline"?"offline":"available"}function Vi(e){return Je(e)!=="offline"}function ia(e){switch(Je(e)){case"working":return"Working";case"available":return"Available";default:return"Offline"}}const Pw="scoutbot.main.mini",RJ=new Set([Pw,"scoutbot","@scoutbot"]),IJ=new Set(["plan","conductor","conduct","warroom","command","mission","control","issues","errors","warnings","agents","tail","atop"]),_J=new Set(["available","working","active","idle","waiting","registered"]);function Dw(e){return[e.id,e.name,e.handle??"",e.selector??"",e.role??""].map(n=>n.trim().toLowerCase()).some(n=>RJ.has(n)||n==="scoutbot"||n.startsWith("scoutbot.")||n.includes(".scoutbot.")||n.includes(" scoutbot"))}function OJ(e){return _J.has(e.state?.trim().toLowerCase()??"")}function wA(e){if(!Dw(e))return Number.NEGATIVE_INFINITY;let t=0;return OJ(e)&&(t+=100),e.handle?.trim().toLowerCase()==="scoutbot"&&(t+=20),e.selector?.trim().toLowerCase()==="@scoutbot"&&(t+=20),e.role?.trim().toLowerCase()==="scoutbot"&&(t+=10),e.id===Pw&&(t+=1),t}function $J(e){return e.filter(Dw).sort((t,n)=>{const a=wA(n)-wA(t);return a!==0?a:(n.updatedAt??0)-(t.updatedAt??0)})[0]??null}function PJ(e){return $J(e)?.id??Pw}function DJ(e){return`dm.operator.${e}`}const LJ=new Set(["scout-ui","scout-ui-action","scoutbot-ui"]),jA=/```([a-zA-Z0-9_-]*)\s*([\s\S]*?)```/g;function v$(e){const t=[];let n="",a=0;jA.lastIndex=0;let r;for(;(r=jA.exec(e))!==null;){const[o,c,u]=r,h=(c??"").toLowerCase(),f=u??"";let g=[],v=!1;LJ.has(h)?(v=!0,g=NA(f)):(h==="json"||h==="")&&(g=NA(f),g.length>0&&(v=!0)),v&&(t.push(...g),n+=e.slice(a,r.index),a=r.index+o.length)}return n+=e.slice(a),{stripped:n.replace(/\n{3,}/g,`
140
+
141
+ `).trim(),actions:t}}function zJ(e){return v$(e).actions}function Xu(e){return v$(e).stripped}function NA(e){const t=e.trim();if(!t)return[];try{const n=JSON.parse(t);return(Array.isArray(n)?n:[n]).map(r=>Lw(r)).filter(r=>!!r)}catch{return[]}}function Lw(e){if(!e||typeof e!="object")return null;const t=e,n=t.scoutUi??t.scout_ui??t.scoutbotUi??t.scoutbot_ui;if(n)return Lw(n);const a=typeof t.type=="string"?t.type:typeof t.action=="string"?t.action:"",r=typeof t.reason=="string"?t.reason:void 0;if(a==="open-scoutbot"||a==="open_scoutbot"){const c=t.mode==="tell"?"tell":t.mode==="ask"?"ask":void 0;return{type:"open-scoutbot",...c?{mode:c}:{},...r?{reason:r}:{}}}if(a==="refresh")return{type:"refresh",...r?{reason:r}:{}};if(a==="ask-agent"||a==="ask_agent"||a==="scout-ask"||a==="scout_ask"){const c=jo(t.targetLabel,t.target_label,t.target,t.to,t.agent,t.handle),u=jo(t.targetAgentId,t.target_agent_id,t.agentId,t.agent_id),h=jo(t.body,t.message,t.prompt,t.task,t.question),f=jo(t.channel);return!h?.trim()||!c?.trim()&&!u?.trim()?null:{type:"ask-agent",targetLabel:(c??u??"").trim(),body:h.trim(),...u?.trim()?{targetAgentId:u.trim()}:{},...f?.trim()?{channel:f.trim()}:{},...r?{reason:r}:{}}}if(a==="view-file"||a==="view_file"||a==="open-file"||a==="open_file"){const c=jo(t.path,t.file,t.target);return c?.trim()?{type:"view-file",path:c.trim(),...r?{reason:r}:{}}:null}if(a==="reminder"||a==="set-reminder"||a==="set_reminder"||a==="remind"){const c=jo(t.body,t.text,t.prompt,t.message);if(!c?.trim())return null;const u=jo(t.title,t.label),h=BJ(t.dueAt??t.due_at),f=zb(t.delayMs??t.delay_ms),g=zb(t.delayMinutes??t.delay_minutes);return{type:"reminder",body:c.trim(),...u?.trim()?{title:u.trim()}:{},...h!==null?{dueAt:h}:{},...f!==null?{delayMs:f}:{},...g!==null?{delayMinutes:g}:{},...r?{reason:r}:{}}}if(a!=="navigate"&&a!=="open")return null;const o=UJ(t.route??t);return o?{type:"navigate",route:o,...r?{reason:r}:{}}:null}function jo(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t;return null}function zb(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")return null;const t=Number(e.trim());return Number.isFinite(t)?t:null}function BJ(e){const t=zb(e);if(t!==null)return t;if(typeof e!="string")return null;const n=Date.parse(e);return Number.isFinite(n)?n:null}function UJ(e){if(!e||typeof e!="object")return null;const t=e;switch(typeof t.view=="string"?t.view:""){case"inbox":return{view:"inbox"};case"fleet":return{view:"fleet"};case"agents":return{view:"agents",...typeof t.agentId=="string"?{agentId:t.agentId}:{},...typeof t.conversationId=="string"?{conversationId:t.conversationId}:{},...t.tab==="profile"||t.tab==="observe"||t.tab==="message"?{tab:t.tab}:{}};case"sessions":return{view:"sessions",...typeof t.sessionId=="string"?{sessionId:t.sessionId}:{}};case"mesh":return{view:"mesh"};case"broker":return{view:"broker"};case"activity":return{view:"activity"};case"settings":return{view:"settings"};case"terminal":return{view:"terminal",...typeof t.agentId=="string"?{agentId:t.agentId}:{}};case"work":return typeof t.workId=="string"?{view:"work",workId:t.workId}:null;case"conversation":return typeof t.conversationId=="string"?{view:"conversation",conversationId:t.conversationId,...t.composeMode==="ask"||t.composeMode==="tell"?{composeMode:t.composeMode}:{}}:null;case"ops":{const a=typeof t.mode=="string"&&IJ.has(t.mode)?FJ(t.mode):void 0;return{view:"ops",...a?{mode:a}:{}}}default:return null}}function FJ(e){switch(e){case"control":case"mission":case"command":case"warroom":case"conduct":case"conductor":return"mission";case"plan":return"plan";case"issues":case"errors":case"warnings":return"issues";case"agents":case"tail":case"atop":return e;default:return}}const y$={current:null,setMenu:null};function Lc(){return m.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),y$.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function VJ({children:e}){const[t,n]=m.useState(null),a=m.useRef(null);y$.setMenu=n;const r=m.useCallback(()=>{n(null)},[]);return m.useEffect(()=>{if(!t)return;const o=f=>{f.target instanceof Node&&a.current?.contains(f.target)||r()},c=f=>{f.key==="Escape"&&r()},u=()=>r(),h=f=>{f.defaultPrevented||r()};return window.addEventListener("mousedown",o,!0),window.addEventListener("keydown",c),window.addEventListener("wheel",u,!0),window.addEventListener("contextmenu",h),()=>{window.removeEventListener("mousedown",o,!0),window.removeEventListener("keydown",c),window.removeEventListener("wheel",u,!0),window.removeEventListener("contextmenu",h)}},[t,r]),m.useLayoutEffect(()=>{if(!t||!a.current)return;const o=a.current,c=o.getBoundingClientRect(),u=window.innerWidth,h=window.innerHeight;let f=t.position.x,g=t.position.y;f+c.width>u-8&&(f=u-c.width-8),g+c.height>h-8&&(g=h-c.height-8),f<8&&(f=8),g<8&&(g=8),o.style.left=`${f}px`,o.style.top=`${g}px`,o.style.visibility="visible"},[t]),s.jsxs(s.Fragment,{children:[e,t&&s.jsx("div",{ref:a,className:"s-context-menu",style:{left:t.position.x,top:t.position.y,visibility:"hidden"},role:"menu",onMouseDown:o=>o.stopPropagation(),children:t.items.map((o,c)=>o.kind==="separator"?s.jsx("div",{className:"s-context-menu-sep",role:"separator"},c):s.jsxs("button",{type:"button",className:"s-context-menu-item",role:"menuitem",onClick:()=>{o.onSelect(),r()},children:[s.jsx("span",{className:"s-context-menu-label",children:o.label}),o.shortcut&&s.jsx("span",{className:"s-context-menu-shortcut",children:o.shortcut})]},c))})]})}const HJ={cjs:"javascript",css:"css",htm:"html",html:"html",js:"javascript",jsx:"javascript",json:"json",mjs:"javascript",md:"markdown",mdx:"markdown",sh:"shell",ts:"typescript",tsx:"typescript",txt:"plain"},qJ=new Set(["cjs","css","htm","html","js","jsx","json","mjs","sh","ts","tsx"]);function x$(e){const n=(e.filename??e.title??e.uri??"").split(/[?#]/)[0],a=n.split("/").pop()??n,r=a.lastIndexOf(".");return r>=0?a.slice(r+1).toLowerCase():""}function WJ(e){const t=e.mediaType?.toLowerCase()??"";return t.includes("json")?"json":t.includes("markdown")?"markdown":t.includes("javascript")?"javascript":t.includes("typescript")?"typescript":t.includes("html")?"html":t.includes("css")?"css":t.includes("shell")||t.includes("x-sh")?"shell":HJ[x$(e)]??"plain"}function GJ(e){const t=e.mediaType?.toLowerCase()??"",n=x$(e);if(t.includes("markdown")||n==="md"||n==="mdx")return"markdown";if(t.includes("json")||t.includes("javascript")||t.includes("typescript")||t.includes("html")||t.includes("xml")||t.includes("css")||qJ.has(n))return"code";if(t.startsWith("text/")||n==="txt")return"text";const a=e.value.trim();return/^#{1,6}\s+/m.test(a)||/```[\s\S]*```/.test(a)?"markdown":"text"}function zc(e){const t=e.title??e.filename??e.uri?.split("/").pop()??"Untitled",n=e.language??WJ(e);return{id:e.id??e.uri??t,title:t,uri:e.uri,mediaType:e.mediaType,language:n,kind:e.kind??GJ(e),value:e.value,readOnly:e.readOnly}}function Qd({document:e,mode:t,className:n}){const a=t??(e.kind==="markdown"?"preview":"read"),r=e.kind==="markdown"&&a==="preview"?s.jsx(KJ,{markdown:e.value}):s.jsx(ZJ,{document:e});return s.jsx("div",{className:`s-text-document-surface s-text-document-surface-${e.kind}${n?` ${n}`:""}`,children:r})}function ZJ({document:e}){const t=m.useMemo(()=>b$(e.value,e.language??e.kind),[e.language,e.kind,e.value]);return s.jsx("pre",{className:"s-text-document-code","data-language":e.language??e.kind,children:s.jsx("code",{children:t})})}function KJ({markdown:e}){const t=YJ(e);return s.jsx("div",{className:"s-text-document-markdown",children:t.length>0?t:s.jsx("p",{})})}function YJ(e){const t=e.replace(/\r\n/g,`
142
+ `).split(`
143
+ `),n=[];let a=0;for(;a<t.length;){const r=t[a]??"";if(!r.trim()){a+=1;continue}const o=/^```(\S*)\s*$/.exec(r);if(o){const f=[];for(a+=1;a<t.length&&!/^```\s*$/.test(t[a]??"");)f.push(t[a]??""),a+=1;a<t.length&&(a+=1),n.push({kind:"code",content:f.join(`
144
+ `),language:o[1]||void 0});continue}const c=/^(#{1,6})\s+(.+)$/.exec(r);if(c){n.push({kind:"heading",depth:XJ(c[1].length),content:c[2].trim()}),a+=1;continue}if(/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/.test(r)){n.push({kind:"hr"}),a+=1;continue}if(/^>\s?/.test(r)){const f=[];for(;a<t.length&&/^>\s?/.test(t[a]??"");)f.push((t[a]??"").replace(/^>\s?/,"")),a+=1;n.push({kind:"blockquote",content:f.join(" ")});continue}const u=/^(\s*)([-*+]|\d+[.)])\s+(.+)$/.exec(r);if(u){const f=/\d/.test(u[2]),g=[];for(;a<t.length;){const v=/^(\s*)([-*+]|\d+[.)])\s+(.+)$/.exec(t[a]??"");if(!v||/\d/.test(v[2])!==f)break;g.push(v[3]),a+=1}n.push({kind:"list",ordered:f,items:g});continue}const h=[];for(;a<t.length;){const f=t[a]??"";if(!f.trim()||/^```/.test(f)||/^(#{1,6})\s+/.test(f)||/^ {0,3}([-*_])(?:\s*\1){2,}\s*$/.test(f)||/^>\s?/.test(f)||/^(\s*)([-*+]|\d+[.)])\s+/.test(f))break;h.push(f.trim()),a+=1}n.push({kind:"paragraph",content:h.join(" ")})}return n.map((r,o)=>QJ(r,o))}function XJ(e){return e<=1?1:e===2?2:e===3?3:e===4?4:e===5?5:6}function QJ(e,t){switch(e.kind){case"heading":{const a=`h${e.depth}`;return s.jsx(a,{children:Oh(e.content)},t)}case"paragraph":return s.jsx("p",{children:Oh(e.content)},t);case"blockquote":return s.jsx("blockquote",{children:Oh(e.content)},t);case"list":{const a=e.ordered?"ol":"ul";return s.jsx(a,{children:e.items.map((r,o)=>s.jsx("li",{children:Oh(r)},`${t}:${o}`))},t)}case"code":const n=w$(e.language);return s.jsx("pre",{className:"s-text-document-fenced-code","data-language":n,children:s.jsx("code",{children:b$(e.content,n)})},t);case"hr":return s.jsx("hr",{},t)}}const JJ=/\/\/[^\n]*|\/\*[\s\S]*?\*\/|`(?:\\[\s\S]|[^`\\])*`|'(?:\\.|[^'\\\n])*'|"(?:\\.|[^"\\\n])*"|\b\d+(?:\.\d+)?(?:e[+-]?\d+)?n?\b|\b[A-Za-z_$][\w$]*\b|=>|[{}()[\].,;:?]|[-+*/%=&|!<>~^]+/giu,eee=/"(?:\\.|[^"\\])*"|-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b|\b(?:true|false|null)\b|[{}\[\]:,]/giu,tee=/\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|#[0-9a-f]{3,8}\b|@[a-z-]+|--[a-z0-9-]+|[a-z-]+(?=\s*:)|\b\d+(?:\.\d+)?(?:%|px|r?em|vh|vw|vmin|vmax|s|ms|deg|fr)?\b|[{}():;,]|\.[a-z_][\w-]*|#[a-z_][\w-]*|[a-z_][\w-]*/giu,nee=/<!--[\s\S]*?-->|<!doctype[^>]*>|<\/?[a-z][\w:-]*|\/?>|[a-z_:][\w:.-]*(?==)|=|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|&[a-z0-9#]+;/giu,see=/#[^\n]*|"(?:\\.|[^"\\])*"|'[^']*'|\$\{?[\w?@#$!-]+\}?|--?[A-Za-z0-9][\w-]*(?:=[^\s]+)?|\b(?:case|cd|do|done|echo|elif|else|esac|exit|export|fi|for|function|if|in|local|return|set|source|test|then|unset|while)\b|\b\d+\b|[|&;(){}<>]/giu,aee=new Set(["abstract","as","async","await","break","case","catch","class","const","continue","declare","default","delete","do","else","enum","export","extends","finally","for","from","function","get","if","implements","import","in","infer","interface","is","keyof","let","new","of","private","protected","public","readonly","return","satisfies","set","static","switch","throw","try","type","typeof","var","void","while","with","yield"]),ree=new Set(["false","null","super","this","true","undefined"]);function b$(e,t){switch(w$(t)){case"css":return _u(e,tee,lee);case"html":return _u(e,nee,cee);case"javascript":case"typescript":return _u(e,JJ,iee);case"json":return _u(e,eee,oee);case"shell":return _u(e,see,uee);default:return[e]}}function _u(e,t,n){const a=[];let r=0,o=0;t.lastIndex=0;let c;for(;(c=t.exec(e))!==null;){const u=c[0];if(!u){t.lastIndex+=1;continue}c.index>r&&a.push(e.slice(r,c.index));const h=n(u,c.index,c.index+u.length,e);a.push(h?s.jsx("span",{className:`s-syntax s-syntax-${h}`,children:u},`syntax-${o++}`):u),r=c.index+u.length}return r<e.length&&a.push(e.slice(r)),a.length>0?a:[e]}function w$(e){const t=String(e??"").toLowerCase().replace(/^\./,"");return t==="bash"||t==="sh"||t==="shell"||t==="zsh"?"shell":t==="css"||t==="scss"?"css":t==="html"||t==="htm"||t==="xml"||t==="svg"?"html":t==="js"||t==="jsx"||t==="javascript"||t==="mjs"||t==="cjs"?"javascript":t==="json"||t==="jsonc"?"json":t==="markdown"||t==="md"||t==="mdx"?"markdown":t==="ts"||t==="tsx"||t==="typescript"?"typescript":"plain"}function iee(e,t,n,a){return e.startsWith("//")||e.startsWith("/*")?"comment":Jd(e)?"string":/^\d/u.test(e)?"number":aee.has(e)?"keyword":ree.has(e)?"literal":/^[A-Z][\w$]*$/u.test(e)?"type":/^[A-Za-z_$][\w$]*$/u.test(e)&&a.slice(n).trimStart().startsWith("(")?"function":/^[{}()[\].,;:?]$/u.test(e)?"punctuation":/^(?:=>|[-+*/%=&|!<>~^]+)$/u.test(e)?"operator":null}function oee(e,t,n,a){return Jd(e)?a.slice(n).trimStart().startsWith(":")?"property":"string":/^-?\d/u.test(e)?"number":e==="true"||e==="false"||e==="null"?"literal":"punctuation"}function lee(e,t,n,a){return e.startsWith("/*")?"comment":Jd(e)?"string":e.startsWith("@")?"keyword":e.startsWith("#")&&/^#[0-9a-f]/iu.test(e)||/^\d/u.test(e)?"number":e.startsWith(".")||e.startsWith("#")?"tag":/^--/u.test(e)||a.slice(n).trimStart().startsWith(":")?"property":/^[{}():;,]$/u.test(e)?"punctuation":null}function cee(e){return e.startsWith("<!--")?"comment":/^<!doctype/iu.test(e)||e.startsWith("&")?"meta":e.startsWith("<")?"tag":Jd(e)?"string":e==="="?"operator":e===">"||e==="/>"?"punctuation":"attribute"}function uee(e){return e.startsWith("#")?"comment":Jd(e)?"string":e.startsWith("$")?"property":e.startsWith("-")?"attribute":/^\d/u.test(e)?"number":/^[|&;(){}<>]$/u.test(e)?"operator":dee.has(e)?"keyword":null}const dee=new Set(["case","cd","do","done","echo","elif","else","esac","exit","export","fi","for","function","if","in","local","return","set","source","test","then","unset","while"]);function Jd(e){return e.startsWith('"')||e.startsWith("'")||e.startsWith("`")}function Oh(e){const t=[],n=/(`[^`]+`|\[([^\]]+)\]\(([^)\s]+)\))/g;let a=0,r;for(;(r=n.exec(e))!==null;){r.index>a&&t.push(e.slice(a,r.index));const o=r[0];if(o.startsWith("`"))t.push(s.jsx("code",{children:o.slice(1,-1)},t.length));else{const c=fee(r[3]);t.push(c?s.jsx("a",{href:c,target:"_blank",rel:"noreferrer",children:r[2]},t.length):r[2])}a=n.lastIndex}return a<e.length&&t.push(e.slice(a)),t}function fee(e){if(!e)return null;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"?e:null}catch{return null}}function ig({open:e=!0,focusable:t=!0,kind:n,document:a,title:r,eyebrow:o,subtitle:c,meta:u=[],mode:h,actions:f=[],state:g,error:v,notice:y,body:x,onClose:w}){const[C,T]=m.useState(!1),[E,S]=m.useState({}),k=m.useRef(null);if(m.useEffect(()=>{e||T(!1)},[e]),m.useEffect(()=>{if(!e)return;let _=null;const $=k.current?.closest(".frame-scrollbar, .s-content")??null,H=()=>{if(!$){S({});return}const D=$.getBoundingClientRect();S({"--doc-focus-layer-top":`${Math.max(0,D.top)}px`,"--doc-focus-layer-right":`${Math.max(0,window.innerWidth-D.right)}px`,"--doc-focus-layer-bottom":`${Math.max(0,window.innerHeight-D.bottom)}px`,"--doc-focus-layer-left":`${Math.max(0,D.left)}px`})},I=()=>{_!==null&&cancelAnimationFrame(_),_=requestAnimationFrame(H)};H();const U=$?new ResizeObserver(I):null;return $&&U?.observe($),window.addEventListener("resize",I),()=>{_!==null&&cancelAnimationFrame(_),U?.disconnect(),window.removeEventListener("resize",I)}},[e]),m.useEffect(()=>{if(!e)return;const _=P=>{P.key==="Escape"&&(P.preventDefault(),C?T(!1):w?.())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[C,w,e]),!e)return null;const N=r??a?.title??"Document",A=h??(a?.kind==="markdown"?"preview":"read"),R=t&&!!(a||x);return s.jsxs("div",{ref:k,className:`s-doc-focus-layer${C?" s-doc-focus-layer-focused":""}`,style:E,children:[w&&s.jsx("button",{type:"button",className:"s-doc-focus-scrim","aria-label":"Dismiss document viewer",tabIndex:-1,onClick:w}),s.jsxs("section",{className:`s-doc-focus-viewer s-doc-focus-viewer-${n}${C?" s-doc-focus-viewer-focused":""}`,"aria-label":N,role:"dialog","aria-modal":"true",children:[s.jsxs("div",{className:"s-doc-focus-viewer-head",children:[s.jsxs("div",{className:"s-doc-focus-viewer-title-wrap",children:[s.jsx("div",{className:"s-doc-focus-viewer-icon","aria-hidden":"true",children:s.jsx(xd,{size:15,strokeWidth:1.8})}),s.jsxs("div",{className:"s-doc-focus-viewer-title-main",children:[o&&s.jsx("div",{className:"s-doc-focus-viewer-eyebrow",children:o}),s.jsx("h3",{className:"s-doc-focus-viewer-title",children:N}),c&&s.jsx("div",{className:"s-doc-focus-viewer-subtitle",children:c})]})]}),s.jsxs("div",{className:"s-doc-focus-viewer-actions",children:[u.length>0&&s.jsx("div",{className:"s-doc-focus-viewer-meta","aria-label":"Document metadata",children:u.map(_=>s.jsx("span",{children:_},_))}),f.map(_=>s.jsxs("button",{type:"button",className:`s-doc-focus-viewer-action${_.hideLabel?" s-doc-focus-viewer-action-icon":""}`,onClick:_.onClick,title:_.title??_.label,disabled:_.disabled,"aria-label":_.hideLabel?_.label:void 0,children:[_.icon,!_.hideLabel&&s.jsx("span",{children:_.label})]},_.label)),R&&s.jsx("button",{type:"button",className:"s-doc-focus-viewer-close",onClick:()=>T(_=>!_),"aria-label":C?"Exit focus mode":"Enter focus mode",title:C?"Exit focus mode":"Focus",children:C?s.jsx(h2,{"aria-hidden":"true",size:14,strokeWidth:1.8}):s.jsx(Ip,{"aria-hidden":"true",size:14,strokeWidth:1.8})}),w&&s.jsx("button",{type:"button",className:"s-doc-focus-viewer-close",onClick:w,"aria-label":"Close document viewer",title:"Close",children:s.jsx(gc,{"aria-hidden":"true",size:14,strokeWidth:1.8})})]})]}),g&&!v&&!a&&!x&&s.jsx("div",{className:"s-doc-focus-viewer-state",children:g}),v&&s.jsx("div",{className:"s-doc-focus-viewer-state s-doc-focus-viewer-error",children:v}),!v&&x&&s.jsx("div",{className:"s-doc-focus-viewer-body",children:x}),!v&&!x&&a&&s.jsx(Qd,{document:a,mode:A,showHeader:!1,className:"s-doc-focus-document"}),!v&&y&&s.jsx("div",{className:"s-doc-focus-viewer-notice",children:y})]})]})}const hee={id:"audio",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("audio/"),render:({resource:e})=>{const t=e;return s.jsx("div",{className:"s-file-preview-media-wrap",children:s.jsx("div",{className:"s-file-preview-audio-stage",children:s.jsx("audio",{className:"s-file-preview-audio",src:t.rawUrl,controls:!0})})})}},mee={id:"binary",canHandle:()=>!0,render:({resource:e})=>{const t=e;return s.jsxs("div",{className:"s-file-preview-callout",children:[s.jsxs("div",{className:"s-file-preview-callout-title",children:[t.previewReason," — open in OS"]}),s.jsxs("div",{className:"s-file-preview-callout-copy",children:["Scout can resolve this file, but it does not have an inline preview for ",t.mediaType," yet."]})]})}},pee=new Set(["text/typescript","text/javascript","text/css","text/html","application/json","text/yaml","text/toml","text/x-shellscript","text/plain"]),gee={id:"code",canHandle:e=>e.kind==="file"&&e.previewable&&pee.has(e.mediaType),render:({resource:e})=>{const t=e,n=zc({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"code",readOnly:!0});return s.jsx(Qd,{document:n,mode:"read",className:"s-doc-focus-document"})}},vee={id:"directory",canHandle:e=>e.kind==="directory",render:({resource:e,openFilePreview:t})=>{const n=e,a=yee(n.realPath,n.rootPath);return s.jsxs("div",{className:"s-file-preview-directory",children:[s.jsx("div",{className:"s-file-preview-breadcrumb","aria-label":"Directory breadcrumb",children:a.map((r,o)=>{const c=o===a.length-1;return s.jsxs("div",{className:"s-file-preview-breadcrumb-item",children:[o>0&&s.jsx(Rp,{size:12,"aria-hidden":"true"}),c?s.jsx("span",{className:"s-file-preview-breadcrumb-current",children:r.label}):s.jsx("button",{type:"button",className:"s-file-preview-breadcrumb-link",onClick:()=>t(r.path),children:r.label})]},r.path)})}),s.jsxs("div",{className:"s-file-preview-directory-list",role:"list",children:[n.entries.map(r=>s.jsxs("button",{type:"button",className:"s-file-preview-entry",onClick:()=>t(r.path),children:[s.jsx("span",{className:"s-file-preview-entry-icon","aria-hidden":"true",children:r.kind==="directory"?s.jsx(d2,{size:14}):s.jsx(xd,{size:14})}),s.jsx("span",{className:"s-file-preview-entry-name",children:r.name}),s.jsx("span",{className:"s-file-preview-entry-kind",children:r.kind==="directory"?"dir":"file"})]},r.realPath)),n.entries.length===0&&s.jsx("div",{className:"s-file-preview-directory-empty",children:"This directory is empty."})]})]})}};function yee(e,t){const n=t==="/"?"/":t.replace(/\/+$/u,""),a=e==="/"?"/":e.replace(/\/+$/u,""),r=n.split("/").filter(Boolean),o=a.split("/").filter(Boolean),c=[{label:r[r.length-1]??"/",path:n||"/"}];let u=n||"/";for(let h=r.length;h<o.length;h+=1){const f=o[h];f&&(u=u==="/"?`/${f}`:`${u}/${f}`,c.push({label:f,path:u}))}return c}const xee={id:"image",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("image/"),render:({resource:e})=>s.jsx("div",{className:"s-file-preview-image-wrap",children:s.jsx("div",{className:"s-file-preview-image-stage",children:s.jsx("img",{className:"s-file-preview-image",src:e.kind==="file"?e.rawUrl:"",alt:e.title})})})},bee={id:"markdown",canHandle:e=>e.kind==="file"&&e.previewable&&e.mediaType==="text/markdown",render:({resource:e})=>{const t=e,n=zc({id:t.realPath,title:t.title,uri:t.realPath,mediaType:t.mediaType,value:t.content,filename:t.title,kind:"markdown",readOnly:!0});return s.jsx(Qd,{document:n,mode:"preview",className:"s-doc-focus-document"})}},wee={id:"video",canHandle:e=>e.kind==="file"&&e.mediaType.startsWith("video/"),render:({resource:e})=>{const t=e;return s.jsx("div",{className:"s-file-preview-media-wrap",children:s.jsx("div",{className:"s-file-preview-media-stage",children:s.jsx("video",{className:"s-file-preview-video",src:t.rawUrl,controls:!0})})})}},jee=[vee,bee,gee,xee,wee,hee,mee];function Nee({path:e,onOpenPath:t,onClose:n}){const[a,r]=m.useState(null),[o,c]=m.useState(null),[u,h]=m.useState(!1),[f,g]=m.useState(null),v=m.useRef(null);m.useEffect(()=>{v.current=f},[f]),m.useEffect(()=>{if(!e){r(null),c(null),h(!1);return}let A=!1;return h(!0),c(null),r(null),me(`/api/file/preview?path=${encodeURIComponent(e)}`).then(R=>{A||(r(R),kee(R,v.current,g))}).catch(R=>{A||c(R instanceof Error?R.message:"could not load file")}).finally(()=>{A||h(!1)}),()=>{A=!0}},[e]);const{currentIndex:y,prevPath:x,nextPath:w}=m.useMemo(()=>{if(!a||a.kind!=="file"||!f)return{currentIndex:-1,prevPath:null,nextPath:null};const A=f.files.findIndex(R=>R.realPath===a.realPath);return A<0?{currentIndex:-1,prevPath:null,nextPath:null}:{currentIndex:A,prevPath:A>0?f.files[A-1].path:null,nextPath:A<f.files.length-1?f.files[A+1].path:null}},[a,f]);if(m.useEffect(()=>{if(!e)return;const A=R=>{if(R.key==="Escape"){n();return}if(R.target instanceof HTMLElement){const _=R.target.tagName;if(_==="INPUT"||_==="TEXTAREA"||R.target.isContentEditable)return}R.metaKey||R.ctrlKey||R.altKey||(R.key==="ArrowLeft"&&x?(R.preventDefault(),t(x)):R.key==="ArrowRight"&&w?(R.preventDefault(),t(w)):R.key==="Backspace"&&f&&a?.kind==="file"&&(R.preventDefault(),t(f.dirPath)))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[e,n,t,x,w,f,a]),!e)return null;const C=()=>{me("/api/file/reveal",{method:"POST",body:JSON.stringify({path:a?.realPath??e})}).catch(A=>{c(A instanceof Error?A.message:"reveal failed")})},T=a?jee.find(A=>A.canHandle(a))??null:null,E=!!(a&&a.kind==="file"&&f&&y>=0&&f.files.length>1),S=[];E&&f&&S.push({label:`Folder: ${f.dirTitle}`,icon:s.jsx(T0,{size:12}),onClick:()=>t(f.dirPath),title:`Back to ${f.dirTitle} (Backspace)`}),S.push({label:"Open in OS",icon:s.jsx(Tc,{size:12}),onClick:C,title:"Reveal this file in your operating system"});const k=a?Cee(a):[];E&&k.unshift(`${y+1} / ${f.files.length}`);const N=a&&T?T.render({resource:a,openFilePreview:t}):null;return s.jsx(ig,{open:!0,kind:See(a),document:null,title:a?.title??e.split("/").pop()??"File",eyebrow:"File preview",subtitle:a?.realPath??e,meta:k,state:u?"Loading…":null,error:o,body:N?s.jsxs("div",{className:`s-file-preview-shell${E?" s-file-preview-shell-nav":""}`,children:[E&&s.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-left",onClick:()=>x&&t(x),disabled:!x,"aria-label":"Previous file",title:"Previous file (←)",children:s.jsx(T4,{size:18,strokeWidth:1.8,"aria-hidden":"true"})}),s.jsx("div",{className:"s-file-preview-shell-body",children:N}),E&&s.jsx("button",{type:"button",className:"s-file-preview-side-nav s-file-preview-side-nav-right",onClick:()=>w&&t(w),disabled:!w,"aria-label":"Next file",title:"Next file (→)",children:s.jsx(R4,{size:18,strokeWidth:1.8,"aria-hidden":"true"})})]}):null,actions:S,onClose:n})}function kee(e,t,n){if(e.kind==="directory"){const r=e.entries.filter(o=>o.kind==="file");n({dirPath:e.path,dirTitle:e.title,files:r});return}if(!t){n(null);return}t.files.some(r=>r.realPath===e.realPath)||n(null)}function See(e){return!e||e.kind==="directory"||e.mediaType==="text/markdown"||e.mediaType==="text/plain"?"doc":"code"}function Cee(e){return e.kind==="directory"?[`${e.entries.length} ${e.entries.length===1?"entry":"entries"}`]:[...e.previewable&&e.truncated?["truncated"]:[],Eee(e.sizeBytes),e.mediaType]}function Eee(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const j$={activity:"idle",brief:{lastDeliveredAt:null},reminders:{dueCount:0,upcomingCount:0,due:[],next:null},voice:{available:null,setupBlocked:!1,replies:!1},error:null,session:{title:null,lastActivityAt:null}},wi=()=>{},N$={focusScoutbot:wi,triggerBrief:wi,triggerAskState:wi,toggleVoiceReplies:wi,openScoutbotSettings:wi,startNewChat:wi,dismissReminder:wi,askReminderStatus:wi},zw=m.createContext(null);function Aee({children:e}){const[t,n]=m.useState(j$),a=m.useRef(N$),r=m.useCallback(h=>{n(f=>Ree(f,h)?f:h)},[]),o=m.useCallback(h=>{a.current=h},[]),c=m.useMemo(()=>({focusScoutbot:()=>a.current.focusScoutbot(),triggerBrief:()=>a.current.triggerBrief(),triggerAskState:()=>a.current.triggerAskState(),toggleVoiceReplies:()=>a.current.toggleVoiceReplies(),openScoutbotSettings:()=>a.current.openScoutbotSettings(),startNewChat:()=>a.current.startNewChat(),dismissReminder:h=>a.current.dismissReminder(h),askReminderStatus:h=>a.current.askReminderStatus(h)}),[]),u=m.useMemo(()=>({state:t,actions:c,publishState:r,registerActions:o}),[t,c,r,o]);return s.jsx(zw.Provider,{value:u,children:e})}function Tee(){const e=m.useContext(zw);return e?{state:e.state,actions:e.actions}:{state:j$,actions:N$}}function Mee(){const e=m.useContext(zw);return e?{publishState:e.publishState,registerActions:e.registerActions}:null}function Ree(e,t){return e.activity===t.activity&&e.brief.lastDeliveredAt===t.brief.lastDeliveredAt&&e.reminders.dueCount===t.reminders.dueCount&&e.reminders.upcomingCount===t.reminders.upcomingCount&&Iee(e.reminders.due,t.reminders.due)&&k$(e.reminders.next,t.reminders.next)&&e.voice.available===t.voice.available&&e.voice.setupBlocked===t.voice.setupBlocked&&e.voice.replies===t.voice.replies&&e.error===t.error&&e.session.title===t.session.title&&e.session.lastActivityAt===t.session.lastActivityAt}function Iee(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!k$(e[n],t[n]))return!1;return!0}function k$(e,t){return e===t?!0:!e||!t?!1:e.id===t.id&&e.body===t.body&&e.status===t.status&&e.dueAt===t.dueAt}class sr extends Error{code;cause;constructor(t,n,a){super(n),this.name="HudVaultError",this.code=t,this.cause=a}}const Ou="items",$h="keys",kA="master";class _ee{service;dbPromise;cryptoKeyPromise;constructor(t){this.service=t.service}async set(t,n){const a=new TextEncoder().encode(n);await this.setBytes(t,a)}async get(t){const n=await this.getBytes(t);if(!n)return null;try{return new TextDecoder().decode(n)}catch(a){throw new sr("encoding_failed","value is not valid UTF-8",a)}}async delete(t){await this.idbDelete(Ou,t)}async setBytes(t,n){const a=await this.getOrCreateCryptoKey(),r=crypto.getRandomValues(new Uint8Array(12));let o;try{o=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},a,n)}catch(c){throw new sr("crypto_failed","AES-GCM encrypt failed",c)}await this.idbWrite(Ou,t,{iv:r,ct:new Uint8Array(o)})}async getBytes(t){const n=await this.idbRead(Ou,t);if(!n)return null;const a=await this.getOrCreateCryptoKey();try{const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:n.iv},a,n.ct);return new Uint8Array(r)}catch(r){throw new sr("crypto_failed","AES-GCM decrypt failed",r)}}getOrCreateCryptoKey(){return this.cryptoKeyPromise?this.cryptoKeyPromise:(this.cryptoKeyPromise=(async()=>{if(typeof crypto>"u"||!crypto.subtle)throw new sr("crypto_unsupported","crypto.subtle is not available");const t=await this.idbRead($h,kA);if(t)return t;let n;try{n=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}catch(a){throw new sr("crypto_failed","AES-GCM key generation failed",a)}return await this.idbWrite($h,kA,n),n})(),this.cryptoKeyPromise)}getDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((t,n)=>{if(typeof indexedDB>"u"){n(new sr("idb_unsupported","IndexedDB is not available"));return}const a=indexedDB.open(`hudvault:${this.service}`,1);a.onupgradeneeded=()=>{const r=a.result;r.objectStoreNames.contains(Ou)||r.createObjectStore(Ou),r.objectStoreNames.contains($h)||r.createObjectStore($h)},a.onsuccess=()=>t(a.result),a.onerror=()=>n(new sr("idb_failed",Ph("open",a.error),a.error))}),this.dbPromise)}async idbRead(t,n){const a=await this.getDB();return new Promise((r,o)=>{const u=a.transaction(t,"readonly").objectStore(t).get(n);u.onsuccess=()=>r(u.result),u.onerror=()=>o(new sr("idb_failed",Ph("read",u.error),u.error))})}async idbWrite(t,n,a){const r=await this.getDB();await new Promise((o,c)=>{const u=r.transaction(t,"readwrite");u.oncomplete=()=>o(),u.onerror=()=>c(new sr("idb_failed",Ph("write",u.error),u.error)),u.objectStore(t).put(a,n)})}async idbDelete(t,n){const a=await this.getDB();await new Promise((r,o)=>{const c=a.transaction(t,"readwrite");c.oncomplete=()=>r(),c.onerror=()=>o(new sr("idb_failed",Ph("delete",c.error),c.error)),c.objectStore(t).delete(n)})}}function Ph(e,t){return`IndexedDB ${e} failed${t?.message?`: ${t.message}`:""}`}const Oee="dev.openscout.credentials",Bw="openai_api_key",Uw=new _ee({service:Oee});async function S$(){const t=(await Uw.get(Bw))?.trim();return t&&t.startsWith("sk-")?t:null}async function $ee(e){const t=e.trim();if(!t.startsWith("sk-"))throw new Error("OpenAI API keys should start with sk-.");await Uw.set(Bw,t)}async function Pee(){await Uw.delete(Bw)}async function C$(e){return me("/api/scoutbot/credentials/openai",{method:"POST",body:JSON.stringify({apiKey:e.trim()})})}async function Dee(){return me("/api/scoutbot/credentials/openai",{method:"DELETE"})}async function E$(){return me("/api/scoutbot/credentials")}async function Bb(){const e=await E$();if(e.openai.configured)return e;const t=await S$();return t?C$(t):null}async function Lee(){const e=await S$();return{configured:!!e,preview:e?zee(e):null}}function zee(e){return e.length<=10?"configured":`${e.slice(0,5)}...${e.slice(-4)}`}const Bee=[195,125,300,45,355,210];function SA(e){return`oklch(0.80 0.14 ${e})`}function Uee(e){return`oklch(0.18 0.08 ${e})`}function Li({label:e,right:t}){return s.jsxs("div",{className:"s-settings-section-rule",children:[s.jsx("span",{className:"s-settings-section-label",children:e}),s.jsx("span",{className:"s-settings-section-line"}),t&&s.jsx("span",{className:"s-settings-section-right",children:t})]})}function Js({label:e,hint:t,children:n}){return s.jsxs("div",{className:"s-settings-field",children:[s.jsx("label",{className:"s-settings-field-label",children:e}),n,t&&s.jsx("span",{className:"s-settings-field-hint",children:t})]})}function Kl({value:e,onChange:t,mono:n}){return s.jsx("input",{className:`s-settings-input${n?" s-settings-input--mono":""}`,value:e,onChange:a=>t(a.target.value)})}function Fee({value:e,onChange:t,rows:n=3}){return s.jsx("textarea",{className:"s-settings-textarea",value:e,onChange:a=>t(a.target.value),rows:n})}function Vee({value:e,onChange:t,min:n,max:a,step:r=1,unit:o=""}){return s.jsxs("div",{className:"s-settings-slider-wrap",children:[s.jsx("input",{type:"range",min:n,max:a,step:r,value:e,onChange:c=>t(Number(c.target.value))}),s.jsxs("span",{className:"s-settings-slider-value",children:[e," ",o]})]})}function Dh({value:e,onChange:t,options:n,stacked:a,columns:r}){return s.jsx("div",{className:a?"s-settings-option-stacked":"s-settings-option-grid",style:a?void 0:{gridTemplateColumns:`repeat(${r??n.length}, 1fr)`},children:n.map(o=>s.jsxs("button",{className:`s-settings-option-btn${e===o.id?" s-settings-option-btn--active":""}`,onClick:()=>t(o.id),children:[s.jsx("span",{className:"s-settings-option-label",children:o.label}),s.jsx("span",{className:"s-settings-option-sub",children:o.sub})]},o.id))})}function Hee({profile:e,update:t}){return s.jsxs("div",{className:"s-settings-col-gap",children:[s.jsx(Li,{label:"Identity",right:"visible to every agent"}),s.jsxs("div",{className:"s-settings-identity-card",children:[s.jsx("span",{className:"s-settings-identity-dot",style:{background:SA(e.hue),color:Uee(e.hue)},children:(e.name||"?")[0].toUpperCase()}),s.jsxs("div",{style:{flex:1},children:[s.jsx("div",{className:"s-settings-identity-name",children:e.name||"Unnamed"}),s.jsxs("div",{className:"s-settings-identity-meta",children:[e.handle||"@you"," · ",e.pronouns||"—"," · operator"]})]}),s.jsxs("div",{className:"s-settings-hue-wrap",children:[s.jsx("span",{className:"s-settings-field-label",children:"Identity hue"}),s.jsx("div",{className:"s-settings-hue-row",children:Bee.map(n=>s.jsx("button",{onClick:()=>t({hue:n}),className:`s-settings-hue-dot${e.hue===n?" s-settings-hue-dot--active":""}`,style:{background:SA(n)}},n))})]})]}),s.jsx(Js,{label:"Display name",hint:"Shown when agents address you.",children:s.jsx(Kl,{value:e.name,onChange:n=>t({name:n})})}),s.jsx(Js,{label:"Handle",hint:"Used in @mentions across threads.",children:s.jsx(Kl,{value:e.handle,onChange:n=>t({handle:n}),mono:!0})}),s.jsx(Js,{label:"Pronouns",children:s.jsx(Kl,{value:e.pronouns,onChange:n=>t({pronouns:n})})}),s.jsx(Li,{label:"How agents understand you",right:"shipped as system prompt context"}),s.jsx(Js,{label:"Operator bio",hint:"How you want to be worked with. Agents read this before asking you things.",children:s.jsx(Fee,{value:e.bio,onChange:n=>t({bio:n}),rows:4})}),s.jsxs("div",{className:"s-settings-two-col",children:[s.jsx(Js,{label:"Timezone",children:s.jsx(Kl,{value:e.timezone,onChange:n=>t({timezone:n}),mono:!0})}),s.jsx(Js,{label:"Working hours",children:s.jsx(Kl,{value:e.workingHours,onChange:n=>t({workingHours:n}),mono:!0})})]})]})}function qee({profile:e,update:t}){return s.jsxs("div",{className:"s-settings-col-gap",children:[s.jsx(Li,{label:"Interrupt policy"}),s.jsx(Js,{label:"When agents can ping you directly",hint:"Blocking-only means only asks that truly stall work. Others get batched.",children:s.jsx(Dh,{value:e.interruptThreshold,onChange:n=>t({interruptThreshold:n}),options:[{id:"always",label:"Always",sub:"any ask, any time"},{id:"blocking-only",label:"Blocking only",sub:"stuck agents · default"},{id:"batched",label:"Batched",sub:"grouped every 15m"},{id:"never",label:"Never",sub:"queue only, I'll check in"}]})}),s.jsxs("div",{className:"s-settings-two-col",children:[s.jsx(Js,{label:"Batch window (min)",children:s.jsx(Vee,{value:e.batchWindow,min:5,max:60,step:5,onChange:n=>t({batchWindow:n}),unit:"min"})}),s.jsx(Js,{label:"Quiet hours",children:s.jsx(Kl,{value:e.quietHours,onChange:n=>t({quietHours:n}),mono:!0})})]}),s.jsx(Li,{label:"Where to reach you"}),s.jsx(Js,{label:"Preferred channel",children:s.jsx(Dh,{value:e.channel,onChange:n=>t({channel:n}),options:[{id:"here",label:"Here only",sub:"desktop app"},{id:"mobile",label:"Mobile only",sub:"paired phone"},{id:"here+mobile",label:"Both",sub:"whichever is active"}]})}),s.jsx(Li,{label:"Tone calibration",right:"how agents write to you"}),s.jsxs("div",{className:"s-settings-two-col",children:[s.jsx(Js,{label:"Verbosity",children:s.jsx(Dh,{stacked:!0,value:e.verbosity,onChange:n=>t({verbosity:n}),options:[{id:"terse",label:"Terse",sub:"one-liners, answers only"},{id:"normal",label:"Normal",sub:"context + answer"},{id:"detailed",label:"Detailed",sub:"show reasoning"}]})}),s.jsx(Js,{label:"Tone",children:s.jsx(Dh,{stacked:!0,value:e.tone,onChange:n=>t({tone:n}),options:[{id:"direct",label:"Direct",sub:"no hedging"},{id:"warm",label:"Warm",sub:"friendly, conversational"},{id:"formal",label:"Formal",sub:"business-like"}]})})]})]})}function Wee({clientCredentials:e,serverCredentials:t,reloadCredentials:n}){const[a,r]=m.useState(""),[o,c]=m.useState(!1),[u,h]=m.useState(null),f=t?.openai??null,g=!!f?.configured,v=f?.source==="env"?"OPENAI_API_KEY":f?.source==="local-config"?"local Scout config":f?.source==="local-store"?"local OpenScout store":"missing",y=f?.source==="local-store"&&e?.configured?"local OpenScout store + HudVault mirror":v,x=f?.preview??e?.preview??null,w=async()=>{c(!0),h(null);try{const T=a.trim();await C$(T);let E=null;try{await $ee(T)}catch(S){E=S instanceof Error?S.message:"HudVault save failed."}r(""),await n(),h(E?`Saved to local OpenScout store. Browser mirror failed: ${E}`:"Saved to local OpenScout store and Hudson Vault.")}catch(T){h(T instanceof Error?T.message:"Could not save key.")}finally{c(!1)}},C=async()=>{c(!0),h(null);try{const[T,E]=await Promise.allSettled([Pee(),Dee()]);r(""),await n(),T.status==="rejected"||E.status==="rejected"?h("Cleared what I could; one credential store did not respond."):h(f?.source==="env"||f?.source==="local-config"?"Removed saved key. Server fallback is still configured.":"Removed saved key.")}catch(T){h(T instanceof Error?T.message:"Could not clear key.")}finally{c(!1)}};return s.jsxs("div",{className:"s-settings-col-gap",children:[s.jsx(Li,{label:"Model providers",right:g?`configured · ${y}`:"missing"}),s.jsx("div",{className:"s-settings-relay-card",children:s.jsxs("div",{children:[s.jsxs("div",{className:"s-settings-relay-title",children:["OpenAI · ",s.jsxs("span",{className:"s-settings-device-status",style:{color:g?"var(--green)":"var(--dim)"},children:["●"," ",g?"ready":"missing"]})]}),s.jsxs("div",{className:"s-settings-relay-meta",children:[x??"No key stored"," · ",y]}),s.jsx("div",{className:"s-settings-relay-desc",children:"Scout stores user-entered keys in the local OpenScout credential store and keeps a HudVault mirror for this browser profile."})]})}),s.jsx(Js,{label:"OpenAI API key",hint:"Saved locally. Existing keys are never shown again.",children:s.jsx("input",{className:"s-settings-input s-settings-input--mono",type:"password",value:a,placeholder:g?"Saved key configured":"sk-...",autoComplete:"off",spellCheck:!1,onChange:T=>r(T.target.value)})}),u&&s.jsx("div",{className:"s-settings-field-hint",children:u}),s.jsxs("div",{className:"s-settings-button-row",children:[s.jsx("button",{type:"button",className:"s-btn",disabled:o||!a.trim(),onClick:()=>{w()},children:o?"Saving":"Save key"}),s.jsx("button",{type:"button",className:"s-btn",disabled:o||!(e?.configured||f?.source==="local-store"),onClick:()=>{C()},children:"Clear saved key"})]})]})}const Gee={desktop:"◻",mobile:"▯",tablet:"▭"};function Zee({device:e}){const t=e.status==="this-device"?"var(--accent)":e.status==="online"?"var(--green)":"var(--dim)";return s.jsxs("div",{className:"s-settings-device-row",children:[s.jsx("span",{className:"s-settings-device-icon",children:Gee[e.kind]??"□"}),s.jsxs("div",{children:[s.jsx("div",{className:"s-settings-device-name",children:e.name}),s.jsxs("div",{className:"s-settings-device-meta",children:[e.kind," · via ",e.relay," · ",e.lastSeen]})]}),s.jsxs("span",{className:"s-settings-device-status",style:{color:t},children:["●"," ",e.status==="this-device"?"this device":e.status]}),s.jsx("button",{className:"s-btn",disabled:e.status==="this-device",children:e.status==="this-device"?"—":"Unpair"})]})}function Kee({pairing:e}){const t=[{id:"local",name:"This machine",kind:"desktop",status:"this-device",relay:"local",lastSeen:"now"}];if(e?.trustedPeers)for(const n of e.trustedPeers){const a=n.fingerprint===e.connectedPeerFingerprint;t.push({id:n.fingerprint,name:n.name??"Paired device",kind:"mobile",status:a?"online":"offline",relay:"tailscale",lastSeen:n.lastSeenLabel??"—"})}return s.jsxs("div",{className:"s-settings-col-gap",children:[s.jsx(Li,{label:`Paired devices · ${t.length}`}),s.jsx("div",{className:"s-settings-col-gap",style:{gap:10},children:t.map(n=>s.jsx(Zee,{device:n},n.id))}),s.jsx(Li,{label:"Relay"}),s.jsxs("div",{className:"s-settings-relay-card",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"s-settings-relay-title",children:["Relay · ",s.jsxs("span",{className:"s-settings-device-status",style:{color:e?.isRunning?"var(--green)":"var(--dim)"},children:["●"," ",e?.isRunning?"connected":"offline"]})]}),s.jsxs("div",{className:"s-settings-relay-meta",children:[e?.relay??"not configured"," · tailscale"]}),s.jsx("div",{className:"s-settings-relay-desc",children:"Agents route through your relay to reach mobile when the app is backgrounded. End-to-end encrypted; keys never leave your devices."})]}),s.jsx("button",{className:"s-btn",children:"Configure"})]})]})}const Yee=[{id:"operator",label:"Operator",sub:"identity · bio · hours"},{id:"comms",label:"Communication",sub:"how agents reach you"},{id:"credentials",label:"Credentials",sub:"model provider keys"},{id:"devices",label:"Paired devices",sub:"relay · connected"}],Xee={operator:"Operator identity",comms:"Communication",credentials:"Credentials",devices:"Paired devices"},Qee={name:"",handle:"",pronouns:"",hue:195,bio:"",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,workingHours:"08:00 – 18:00",interruptThreshold:"blocking-only",batchWindow:15,channel:"here+mobile",verbosity:"terse",tone:"direct",quietHours:"22:00 – 07:00"};function Jee({open:e,onClose:t}){const{refreshOnboarding:n}=qe(),[a,r]=m.useState("operator"),[o,c]=m.useState(Qee),[u,h]=m.useState(null),[f,g]=m.useState(null),[v,y]=m.useState(null),[x,w]=m.useState(!1),C=m.useRef(null),T=m.useCallback(async()=>{const[N,A]=await Promise.allSettled([Lee(),E$()]),R=N.status==="fulfilled"?N.value:null;let _=A.status==="fulfilled"?A.value:null;R?.configured&&!_?.openai.configured&&(_=await Bb().catch(()=>_)),g(R),y(_)},[]),E=m.useCallback(async()=>{try{const N=me("/api/user"),A=Promise.race([me("/api/pairing-state"),new Promise((P,$)=>setTimeout(()=>$(new Error("timeout")),3e3))]),[R,_]=await Promise.allSettled([N,A]);R.status==="fulfilled"&&c(R.value),_.status==="fulfilled"&&h(_.value),await T()}finally{w(!0)}},[T]);m.useEffect(()=>{e&&E()},[e,E]),m.useEffect(()=>{if(!e)return;const N=A=>{A.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e,t]);const S=m.useCallback(N=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{me("/api/user",{method:"POST",body:JSON.stringify(N)}).then(()=>n()).catch(()=>{})},400)},[n]),k=m.useCallback(N=>{c(A=>{const R={...A,...N};return S(R),R})},[S]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`s-settings-scrim ${e?"s-settings-scrim--open":"s-settings-scrim--closed"}`,onClick:t}),s.jsxs("div",{className:`s-settings-drawer ${e?"s-settings-drawer--open":"s-settings-drawer--closed"}`,children:[s.jsxs("div",{className:"s-settings-header",children:[s.jsxs("div",{className:"s-settings-header-title",children:["⚙"," SETTINGS"]}),s.jsx("span",{className:"s-settings-header-sep",children:"/"}),s.jsx("span",{className:"s-settings-header-section",children:Xee[a]}),s.jsx("span",{style:{flex:1}}),s.jsx("span",{className:"s-settings-header-hint",children:"ESC to close"}),s.jsx("button",{className:"s-settings-close",onClick:t,children:"×"})]}),s.jsx("nav",{className:"s-settings-rail",children:Yee.map(N=>s.jsxs("button",{onClick:()=>r(N.id),className:`s-settings-rail-btn${a===N.id?" s-settings-rail-btn--active":""}`,children:[s.jsx("span",{className:"s-settings-rail-label",children:N.label}),s.jsx("span",{className:"s-settings-rail-sub",children:N.sub})]},N.id))}),s.jsx("main",{className:"s-settings-content",children:x?s.jsxs(s.Fragment,{children:[a==="operator"&&s.jsx(Hee,{profile:o,update:k}),a==="comms"&&s.jsx(qee,{profile:o,update:k}),a==="credentials"&&s.jsx(Wee,{clientCredentials:f,serverCredentials:v,reloadCredentials:T}),a==="devices"&&s.jsx(Kee,{pairing:u})]}):s.jsx("div",{style:{color:"var(--dim)",fontFamily:"var(--font-mono)",fontSize:12},children:"Loading..."})}),s.jsxs("div",{className:"s-settings-footer",children:[s.jsxs("span",{className:"s-settings-footer-sync",children:["●"," synced"]}),s.jsx("span",{children:"·"}),s.jsx("span",{children:"changes apply instantly to every agent in your fleet"}),s.jsx("span",{style:{flex:1}}),s.jsx("button",{className:"s-btn",onClick:t,children:"Done"})]})]})]})}const A$=m.createContext(null),ete=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],tte=new Set(ete),nte=15e3,ste={"--hud-bg":"oklch(0.14 0.008 80)","--hud-surface":"oklch(0.18 0.009 80)","--hud-ink":"oklch(0.96 0.008 80)","--hud-muted":"oklch(0.72 0.012 80)","--hud-dim":"oklch(0.58 0.012 80)","--hud-border":"oklch(0.96 0.008 80 / 0.035)","--hud-accent":"oklch(0.86 0.17 125)","--hud-accent-soft":"oklch(0.86 0.17 125 / 0.08)","--hud-shadow-soft":"oklch(0.10 0.006 75 / 0.4)","--hud-chrome-border":"oklch(0.96 0.008 80 / 0.009)","--hud-shadow-panel":"0 12px 34px oklch(0.08 0.006 75 / 0.45)","--hud-shadow-panel-hover":"0 14px 38px oklch(0.08 0.006 75 / 0.52)","--hud-shadow-bar":"0 -10px 28px oklch(0.08 0.006 75 / 0.38)","--hud-shadow-nav":"0 8px 24px oklch(0.08 0.006 75 / 0.32)","--hud-shadow-minimap":"0 10px 24px oklch(0.08 0.006 75 / 0.38)","--hud-status-ok":"oklch(0.80 0.15 155)","--hud-status-warn":"oklch(0.82 0.15 85)","--hud-status-error":"oklch(0.72 0.18 25)","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 92%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 58%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 38%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 22%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-avatar-ink":"#111111","--hud-font-sans":"'Inter Tight', 'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Play', 'Inter Tight', ui-sans-serif, system-ui, sans-serif","--hud-font-accent-title":"var(--hud-font-sans)"},ate={"--hud-bg":"oklch(0.978 0.004 85)","--hud-surface":"oklch(0.992 0.003 85)","--hud-ink":"oklch(0.24 0.01 80)","--hud-muted":"oklch(0.56 0.014 80)","--hud-dim":"oklch(0.72 0.01 80)","--hud-border":"oklch(0.88 0.008 82 / 0.95)","--hud-accent":"oklch(0.72 0.16 125)","--hud-accent-soft":"oklch(0.72 0.16 125 / 0.11)","--hud-shadow-soft":"oklch(0.42 0.01 80 / 0.12)","--hud-status-ok":"oklch(0.64 0.16 155)","--hud-status-warn":"oklch(0.72 0.15 85)","--hud-status-error":"oklch(0.62 0.19 25)","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 94%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 60%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 40%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 24%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-border) 80%, transparent)","--scout-chrome-avatar-ink":"#ffffff","--hud-font-sans":"'Inter Tight', 'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Play', 'Inter Tight', ui-sans-serif, system-ui, sans-serif","--hud-font-accent-title":"var(--hud-font-sans)"};function qe(){const e=m.useContext(A$);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function rte({children:e,initialTheme:t="dark"}){const{route:n,navigate:a}=MQ(),[r,o]=m.useState([]),[c,u]=m.useState(null),[h,f]=m.useState(!1),g=m.useCallback(()=>f(!0),[]),[v,y]=m.useState(!1),[x,w]=m.useState(null),C=m.useCallback(()=>y(!0),[]),T=m.useCallback(()=>y(!1),[]),E=m.useCallback(z=>{w(z)},[]),S=m.useCallback(()=>w(null),[]),k=t==="light"?ate:ste,N=m.useMemo(()=>PJ(r),[r]),A=m.useMemo(()=>DJ(N),[N]),R=m.useRef(null),_=m.useCallback(async()=>{if(R.current)return R.current;const z=(async()=>{const B=await me("/api/agents").catch(()=>null);B&&o(B.filter(X=>!Dw(X)))})();R.current=z;try{await z}finally{R.current=null}},[]),P=m.useCallback(async()=>{try{const z=await me("/api/onboarding/state");u(z)}catch{u({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null})}},[]);m.useEffect(()=>{_(),P()},[_,P]),m.useEffect(()=>{const z=()=>{document.visibilityState!=="hidden"&&_()},B=window.setInterval(z,nte);return window.addEventListener("focus",z),document.addEventListener("visibilitychange",z),()=>{window.clearInterval(B),window.removeEventListener("focus",z),document.removeEventListener("visibilitychange",z)}},[_]);const $=m.useMemo(()=>r.filter(z=>Vi(z.state)).length,[r]),[H,I]=m.useState(null),U=m.useCallback(z=>{z?.trim()&&I(z.trim())},[]),D=m.useCallback(()=>I(null),[]),V=m.useCallback(z=>{switch(z.type){case"navigate":a(z.route);break;case"open-scoutbot":window.dispatchEvent(new CustomEvent("scout:scoutbot-panel-open",{detail:z}));break;case"refresh":_();break;case"view-file":U(z.path);break}},[a,U,_]),Z=m.useRef({applyScoutbotUiAction:V});Z.current={applyScoutbotUiAction:V},tn(z=>{tte.has(z.kind)&&_()}),m.useEffect(()=>{const z=B=>{const X=B.detail,W=X&&typeof X=="object"&&"type"in X?X:null;W&&Z.current.applyScoutbotUiAction(W)};return window.addEventListener("scout:scoutbot-ui-action",z),window.scoutScoutbot={applyUiAction:B=>Z.current.applyScoutbotUiAction(B),navigate:B=>Z.current.applyScoutbotUiAction({type:"navigate",route:B})},()=>{window.removeEventListener("scout:scoutbot-ui-action",z),window.scoutScoutbot?.applyUiAction&&delete window.scoutScoutbot}},[]);const O=m.useMemo(()=>({route:n,navigate:a,agents:r,onlineCount:$,reload:_,onboarding:c,refreshOnboarding:P,onboardingSkipped:h,skipOnboarding:g,settingsOpen:v,openSettings:C,closeSettings:T,scoutbotAgentId:N,scoutbotConversationId:A,applyScoutbotUiAction:V,selectedBrokerAttempt:x,inspectBrokerAttempt:E,clearBrokerAttempt:S,openFilePreview:U,closeFilePreview:D}),[n,a,r,$,_,c,P,h,g,v,C,T,N,A,V,x,E,S,U,D]);return s.jsx(A$.Provider,{value:O,children:s.jsx("div",{"data-scout-theme":t,"data-scout-theme-mode":t,style:{...k},children:s.jsx(VJ,{children:s.jsxs(Aee,{children:[e,s.jsx(Jee,{open:v,onClose:T}),s.jsx(Nee,{path:H,onOpenPath:U,onClose:D})]})})})})}function ite(e){return e?e.replace(/^https?:\/\//,"").split("/")[0].split(":")[0].split(".")[0]||e:""}function CA(e){return ite(e?.hostName)||e?.name||"machine"}function $u(e,t,n,a){const r=t?.trim();!r||e.has(r)||e.set(r,{id:r,label:n?.trim()||r,group:a})}function ote(e,t,n){const a=new Map;e?.localNode?.id&&$u(a,e.localNode.id,CA(e.localNode),"local");for(const r of Object.values(e?.nodes??{}))$u(a,r.id,CA(r),r.id===e?.localNode?.id?"local":"mesh");for(const r of t)$u(a,r.authorityNodeId,r.authorityNodeName??r.authorityNodeId,"agent"),$u(a,r.homeNodeId,r.homeNodeName??r.homeNodeId,"agent");return n&&$u(a,n,n,"selected"),Array.from(a.values()).sort((r,o)=>{const c=r.group==="local"?0:r.group==="mesh"?1:r.group==="agent"?2:3,u=o.group==="local"?0:o.group==="mesh"?1:o.group==="agent"?2:3;return c!==u?c-u:r.label.localeCompare(o.label)})}function lte({variant:e="bar"}){const{route:t,navigate:n,agents:a}=qe(),[r,o]=m.useState(null),c=oa(t);m.useEffect(()=>{if(!Id(t))return;let h=!1;return me("/api/mesh").then(f=>{h||o(f)}).catch(()=>{h||o(null)}),()=>{h=!0}},[t.view]);const u=m.useMemo(()=>ote(r,a,c),[a,r,c]);return Id(t)?s.jsxs("div",{className:`machine-scope machine-scope--${e}`,children:[s.jsx("label",{className:"machine-scope-label",htmlFor:"machine-scope-select",children:"Scope"}),s.jsxs("select",{id:"machine-scope-select",className:"machine-scope-select",value:c??"",onChange:h=>{const f=h.currentTarget.value;n(f?Db(t,f):SQ(t))},children:[s.jsx("option",{value:"",children:"All machines"}),u.map(h=>s.jsx("option",{value:h.id,children:h.group==="local"?`${h.label} (this machine)`:h.label},h.id))]})]}):null}function cte(){const{navigate:e,agents:t,reload:n,openSettings:a,applyScoutbotUiAction:r}=qe(),o=Kd(),c=m.useCallback(()=>{r({type:"open-scoutbot",mode:"ask"}),window.dispatchEvent(new CustomEvent("scout:scoutbot-submit",{detail:{body:"What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend."}}))},[r]),u=m.useCallback(async h=>{await me(`/api/agents/${encodeURIComponent(h)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]);return m.useMemo(()=>{const h=[{id:"nav:home",label:"Go to Home",action:()=>e({view:"inbox"}),shortcut:"Cmd+1"},{id:"nav:agents",label:"Go to Agents",action:()=>e({view:"agents"}),shortcut:"Cmd+2"},{id:"nav:fleet",label:"Go to Fleet",action:()=>e({view:"fleet"}),shortcut:"Cmd+3"},{id:"nav:messages",label:"Go to Messages",action:()=>e({view:"messages"}),shortcut:"Cmd+4"},{id:"nav:messages-dms",label:"Go to Messages — DMs",action:()=>e({view:"messages",filter:"dm"})},{id:"nav:messages-channels",label:"Go to Messages — Channels",action:()=>e({view:"messages",filter:"channel"}),shortcut:"Cmd+5"},{id:"nav:sessions",label:"Go to Sessions",action:()=>e({view:"sessions"})},{id:"nav:activity",label:"Go to Activity",action:()=>e({view:"activity"}),shortcut:"Cmd+6"},{id:"nav:mesh",label:"Go to Mesh",action:()=>e({view:"mesh"}),shortcut:"Cmd+7"},...o?[{id:"nav:ops",label:"Go to Ops",action:()=>e({view:"ops"}),shortcut:"Cmd+8"}]:[],{id:"nav:settings",label:"Open Settings",action:()=>a(),shortcut:"Cmd+,"},{id:"nav:agent-config",label:"Open Agent Configuration",action:()=>e({view:"settings",section:"agents"})},{id:"scoutbot:open",label:"Open Scout",action:()=>r({type:"open-scoutbot",mode:"ask"})},{id:"scoutbot:state",label:"Ask Scout for State",action:()=>c()},{id:"scoutbot:ops-tail",label:"Scout: Open Ops Tail",action:()=>r({type:"navigate",route:{view:"ops",mode:"tail"}})},{id:"nav:pair",label:"Pair Device",action:()=>a()},{id:"scout:reload",label:"Reload Agents",action:()=>{n()}}];for(const f of t)h.push({id:`scout:open:${f.id}`,label:`Open ${f.name}`,action:()=>e({view:"conversation",conversationId:ps(f.id)})}),h.push({id:`scout:send:${f.id}`,label:`Tell ${f.name}`,action:()=>e({view:"conversation",conversationId:ps(f.id)})}),h.push({id:`scout:ask:${f.id}`,label:`Ask ${f.name}`,action:()=>e({view:"conversation",conversationId:ps(f.id),composeMode:"ask"})}),h.push({id:`scout:interrupt:${f.id}`,label:`Interrupt ${f.name}`,action:()=>{u(f.id)}});return h},[t,r,c,u,e,o,n,a])}function T$(){const{onlineCount:e}=qe(),[t,n]=m.useState(null),[a,r]=m.useState(null),o=m.useRef(0),c=m.useCallback(async()=>{const h=++o.current;try{const f=await me("/api/mesh");if(h!==o.current)return;n(f)}catch{if(h!==o.current)return;n(null)}},[]);m.useEffect(()=>{c();const h=setInterval(()=>{c()},15e3);return()=>clearInterval(h)},[c]),m.useEffect(()=>{me("/api/build").then(r).catch(()=>r(null))},[]);const u=(()=>{if(!a)return{label:"dev",title:"Build information unavailable"};const h=a.mode==="production"?"prod":"dev",f=a.branch??"unknown",g=a.commit?` @ ${a.commit}${a.dirty?"*":""}`:"";return{label:`${h} ${f}${g}`,title:[`Mode: ${a.mode}`,`Version: ${a.version??"unknown"}`,`Branch: ${a.branch??"unknown"}`,`Commit: ${a.commit??"unknown"}`,`Dirty: ${a.dirty===null?"unknown":a.dirty?"yes":"no"}`].join(`
145
+ `)}})();return{status:t===null?{label:"Broker: …",color:"neutral"}:t.health.reachable?{label:"Broker: UP",color:"emerald"}:{label:"Broker: DOWN",color:"red"},activeAgents:{label:"Active Agents",count:e},mesh:t===null?{label:"Mesh",value:"checking",color:"neutral"}:t.health.reachable?Object.values(t.nodes).filter(f=>f.id!==t.localNode?.id).length>0?{label:"Mesh",value:"connected",color:"neutral"}:t.identity.discoverable?{label:"Mesh",value:"discoverable",color:"neutral"}:{label:"Mesh",value:"local",color:"amber"}:{label:"Mesh",value:"offline",color:"neutral"},build:u}}function ute(){return T$().status}const dte={inbox:"Fleet",conversation:"Conversation","agent-info":"Agent",agents:"Agents",fleet:"Fleet",conversations:"Conversations",sessions:"Sessions",channels:"Channels",activity:"Activity",mesh:"Mesh",broker:"Broker",settings:"Settings",work:"Work",ops:"Ops"};function fte(){const{route:e,navigate:t}=qe(),n=Kd(),a=[{label:"Fleet",view:"inbox"},{label:"Agents",view:"agents"},{label:"Messages",view:"messages"},{label:"Sessions",view:"sessions"},{label:"Mesh",view:"mesh"},{label:"Broker",view:"broker"},...n?[{label:"Ops",view:"ops"}]:[]],r=e.view==="fleet"||e.view==="activity"?"inbox":e.view==="conversation"?"messages":e.view==="agent-info"?"agents":e.view==="conversations"||e.view==="channels"?"messages":e.view==="work"?n?"ops":"inbox":e.view,o=e.view==="conversation"||e.view==="agent-info"||e.view==="work"?dte[e.view]??e.view:null;return m.createElement("div",{className:"scout-nav-tabs"},a.map(({label:c,view:u})=>m.createElement("button",{key:u,className:`scout-nav-tab${r===u?" active":""}`,onClick:()=>t({view:u})},c)),o&&m.createElement("span",{className:"scout-nav-slash"},"/"),o&&m.createElement("span",{className:"scout-nav-crumb"},o))}function hte(){const{openSettings:e}=qe();return m.createElement("div",{className:"scout-nav-actions"},m.createElement(lte,{variant:"nav"}),m.createElement("button",{onClick:()=>e(),className:"scout-nav-action scout-nav-action--settings",title:"Settings"},m.createElement($p,{size:12,strokeWidth:1.6,"aria-hidden":!0}),m.createElement("span",null,"Settings")))}function mte(){return"panel"}function pte(){const{onboarding:e,onboardingSkipped:t,skipOnboarding:n}=qe();if(!e)return null;if(t)return{active:!1,dismissible:!0};const a=!e.hasLocalConfig,r=!e.hasProjectConfig,o=!e.hasOperatorName;return{active:a||o||r,dismissible:!0,onDismiss:n}}const Ub=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(", ");function Fw(e=!0){const t=m.useRef(null),n=m.useRef(null);m.useEffect(()=>{if(!e)return;n.current=document.activeElement;const r=t.current;return r?((r.querySelector(Ub)??r).focus(),()=>{n.current?.focus?.()}):void 0},[e]);const a=m.useCallback(r=>{if(!e||r.key!=="Tab")return;const o=t.current;if(!o)return;const c=Array.from(o.querySelectorAll(Ub));if(c.length===0){r.preventDefault(),o.focus();return}const u=c[0],h=c[c.length-1],f=document.activeElement;r.shiftKey?(f===u||!o.contains(f))&&(r.preventDefault(),h.focus()):f===h&&(r.preventDefault(),u.focus())},[e]);return{ref:t,onKeyDown:a}}function M$(e){return Array.from(e.querySelectorAll(":scope > button:not([disabled]), :scope > [role='button']:not([aria-disabled='true'])"))}function R$(e,t){e.forEach((n,a)=>{n.tabIndex=a===t?0:-1}),e[t]?.focus()}function I$(){return m.useCallback(e=>{const t=e.key==="ArrowDown"||e.key==="j",n=e.key==="ArrowUp"||e.key==="k",a=e.key==="Home"||e.key==="g"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey,r=e.key==="End"||e.key==="G";if(!t&&!n&&!a&&!r)return;const o=M$(e.currentTarget);if(o.length===0)return;const c=document.activeElement,u=o.findIndex(f=>f===c);let h;t?h=u<0?0:Math.min(o.length-1,u+1):n?h=u<0?o.length-1:Math.max(0,u-1):a?h=0:h=o.length-1,e.preventDefault(),R$(o,h)},[])}function Fb(e,t,n){return e||!t&&n?0:-1}function gte(){m.useEffect(()=>{const e=t=>{if(t.key!=="["&&t.key!=="]")return;const n=t.target;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||(n?.isContentEditable??!1))return;const r=["left","center","right"],o=t.key==="]"?1:-1,c=r.findIndex(h=>{const f=document.querySelector(`[data-pane="${h}"]`);return f?f.contains(n):!1}),u=c<0?o>0?-1:r.length:c;for(let h=u+o;h>=0&&h<r.length;h+=o){const f=document.querySelector(`[data-pane="${r[h]}"]`);if(!f)continue;const g=f.querySelector(Ub);if(g){t.preventDefault(),g.focus();return}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}function _$(e){m.useEffect(()=>{const t=n=>{if(n.key!=="/")return;const a=n.target;if(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement||(a?.isContentEditable??!1))return;const o=e();o&&(n.preventDefault(),o.focus(),o.select())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e])}function O$(e){return t=>{if(t.key!=="ArrowDown")return;const n=e();if(!n)return;const a=M$(n);if(a.length===0)return;const r=a.findIndex(c=>c.tabIndex===0),o=r>=0?r:0;t.preventDefault(),R$(a,o)}}const vte=[{title:"Global",bindings:[{keys:["?"],label:"Toggle this help"},{keys:["Esc"],label:"Close dialog / clear search"},{keys:["Tab","⇧ Tab"],label:"Move focus"},{keys:["["],label:"Focus previous pane"},{keys:["]"],label:"Focus next pane"}]},{title:"Lists",bindings:[{keys:["↓","j"],label:"Next item"},{keys:["↑","k"],label:"Previous item"},{keys:["g","Home"],label:"First item"},{keys:["G","End"],label:"Last item"},{keys:["Enter"],label:"Open / activate"}]},{title:"Search",bindings:[{keys:["/"],label:"Focus filter input"},{keys:["↓"],label:"From filter → first match"},{keys:["Esc"],label:"Clear filter (while focused)"}]},{title:"Tail · Atop",bindings:[{keys:["/"],label:"Open filter (Tail)"},{keys:["G"],label:"Jump to live (Tail)"},{keys:["j","k"],label:"Walk rows (Atop)"}]},{title:"Session scrubber",bindings:[{keys:["←","→"],label:"Seek ±1%"},{keys:["⇧ ←","⇧ →"],label:"Seek ±5%"},{keys:["Home","End"],label:"Jump to start / end"}]}];function yte({open:e,onClose:t}){const{ref:n,onKeyDown:a}=Fw(e);return e?s.jsx("div",{className:"kb-help-backdrop",onClick:t,role:"presentation",children:s.jsxs("div",{ref:n,className:"kb-help-panel",role:"dialog","aria-modal":"true","aria-labelledby":"kb-help-title",onClick:r=>r.stopPropagation(),onKeyDown:a,tabIndex:-1,children:[s.jsxs("header",{className:"kb-help-head",children:[s.jsx("h2",{id:"kb-help-title",className:"kb-help-title",children:"Keyboard shortcuts"}),s.jsx("button",{type:"button",className:"kb-help-close",onClick:t,"aria-label":"Close (Esc)",children:"✕"})]}),s.jsx("div",{className:"kb-help-grid",children:vte.map(r=>s.jsxs("section",{className:"kb-help-group",children:[s.jsx("h3",{className:"kb-help-group-title",children:r.title}),s.jsx("dl",{className:"kb-help-list",children:r.bindings.map((o,c)=>s.jsxs("div",{className:"kb-help-row",children:[s.jsx("dt",{className:"kb-help-keys",children:o.keys.map((u,h)=>s.jsxs("span",{children:[h>0&&s.jsx("span",{className:"kb-help-or",children:"or"}),s.jsx("kbd",{className:"kb-help-kbd",children:u})]},h))}),s.jsx("dd",{className:"kb-help-label",children:o.label})]},`${r.title}-${c}`))})]},r.title))}),s.jsxs("footer",{className:"kb-help-foot",children:["Press ",s.jsx("kbd",{className:"kb-help-kbd",children:"?"})," to toggle · ",s.jsx("kbd",{className:"kb-help-kbd",children:"Esc"})," to close"]})]})}):null}function xte(){const[e,t]=m.useState(!1);return m.useEffect(()=>{const n=a=>{if(a.key==="Escape"&&e){a.preventDefault(),t(!1);return}if(a.key!=="?")return;const r=a.target;r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||(r?.isContentEditable??!1)||(a.preventDefault(),t(c=>!c))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e]),{open:e,setOpen:t}}const Zo=50,bte=3e4,wte=5*6e4,Vb="openscout:toggle-scoutbot",$$="openscout.broadcast.mute",Cm={filter:"all",goDark:!1,muteUntil:0};let Em={history:[],latest:null,promotedId:null,dismissedId:null,now:Date.now(),mute:Cm};const _i=new Set;let rc=null,fc=null,Od=0,fd=null,EA=!1,hc=null;function P$(){if(typeof window>"u")return Cm;try{const e=window.localStorage.getItem($$);if(!e)return Cm;const t=JSON.parse(e);return{filter:t.filter==="warn-plus"||t.filter==="errors-only"?t.filter:"all",goDark:t.goDark===!0,muteUntil:typeof t.muteUntil=="number"?t.muteUntil:0}}catch{return Cm}}function jte(e,t){return t==="all"?!0:t==="warn-plus"?e!=="info":e==="error"}function Nte(e,t){return!!(e.goDark||e.muteUntil>t)}function kte(e,t,n){return Nte(t,n)?!1:jte(e.tier,t.filter)}function Ste(){for(const e of[..._i])e()}function Ji(e){const t=e(Em);t!==Em&&(Em=t,Ste())}function Cte(e){Ji(t=>{if(t.history.some(r=>r.id===e.id))return t;const n=[...t.history,e],a=n.length>Zo?n.slice(n.length-Zo):n;return{...t,history:a,latest:e,promotedId:e.id,dismissedId:null}})}function Ete(e){Ji(t=>{const n=new Set(t.history.map(c=>c.id)),a=[...t.history];for(const c of e)n.has(c.id)||a.push(c);a.sort((c,u)=>c.ts-u.ts);const r=a.length>Zo?a.slice(a.length-Zo):a,o=r.length?r[r.length-1]:null;return{...t,history:r,latest:o,promotedId:t.promotedId??o?.id??null}})}function Ate(){if(fc||_i.size===0)return;Od++;const e=Math.min(2e3*2**(Od-1),3e4);fc=setTimeout(()=>{fc=null,_i.size>0&&D$()},e)}function D$(){if(rc||_i.size===0)return;const e=new EventSource("/api/broadcast/stream");rc=e,e.onopen=()=>{Od=0},e.onmessage=t=>{try{const n=JSON.parse(t.data);Cte(n)}catch{}},e.addEventListener("ready",()=>{Od=0}),e.onerror=()=>{rc===e&&(rc=null),e.close(),Ate()}}function Tte(){rc?.close(),rc=null,fc&&(clearTimeout(fc),fc=null),Od=0}function Mte(){fd||(fd=setInterval(()=>{Ji(e=>({...e,now:Date.now()}))},1e3))}function Rte(){fd&&(clearInterval(fd),fd=null)}async function Ite(){if(!EA){EA=!0;try{const e=await me(`/api/broadcast/recent?limit=${Zo}`);e.broadcasts?.length&&Ete(e.broadcasts)}catch{}}}function _te(){hc||typeof window>"u"||(hc=e=>{if(e.key!==$$)return;const t=P$();Ji(n=>({...n,mute:t}))},window.addEventListener("storage",hc))}function Ote(){!hc||typeof window>"u"||(window.removeEventListener("storage",hc),hc=null)}function $te(e){return _i.add(e),_i.size===1&&(Ji(t=>({...t,mute:P$()})),D$(),Mte(),_te(),Ite()),()=>{_i.delete(e),_i.size===0&&(Tte(),Rte(),Ote())}}function AA(){return Em}function L$(){return m.useSyncExternalStore($te,AA,AA)}function Pte(){Ji(e=>e.promotedId?{...e,dismissedId:e.promotedId,promotedId:null}:e)}function z$(e){if(!e.promotedId||e.dismissedId&&e.dismissedId===e.promotedId)return null;const t=e.history.find(n=>n.id===e.promotedId);return!t||e.now-t.ts>wte||!kte(t,e.mute,e.now)?null:t}function Dte(e){const t=z$(e);return!t||e.now-t.ts>bte?null:t}function B$(e){return`client:${e}`}function Am(e){const t=B$(e.key);Ji(n=>{const a=Date.now(),r={id:t,tier:e.tier,text:e.text,ts:a,ruleId:`client.${e.key}`,key:e.key},o=n.history.findIndex(u=>u.id===t);let c;return o>=0?(c=[...n.history],c[o]=r):(c=[...n.history,r],c.length>Zo&&(c=c.slice(c.length-Zo))),{...n,history:c,latest:r,promotedId:t,dismissedId:n.dismissedId===t?null:n.dismissedId}})}function Tm(e){const t=B$(e);Ji(n=>{const a=n.history.filter(u=>u.id!==t);if(a.length===n.history.length)return n;const r=n.promotedId===t?null:n.promotedId,o=n.dismissedId===t?null:n.dismissedId,c=n.latest?.id===t?a.length>0?a[a.length-1]:null:n.latest;return{...n,history:a,latest:c??null,promotedId:r,dismissedId:o}})}function Lte(e){if(typeof window>"u")return;const t=e?{broadcastId:e.id}:{};window.dispatchEvent(new CustomEvent(Vb,{detail:t}))}function zte(e){if(typeof window>"u")return()=>{};const t=n=>{const a=n.detail??{};e(a)};return window.addEventListener(Vb,t),()=>window.removeEventListener(Vb,t)}const Bte=5*6e4,Ute=15e3;function Fte(e){return`s-scoutbot-chip-dot s-scoutbot-chip-dot--${e}`}function Vte(e){switch(e){case"listening":return"listening";case"thinking":return"thinking";case"speaking":return"speaking";case"briefing":return"briefing";default:return""}}function Hte(e){return e==="thinking"||e==="briefing"}function qte(e){const t=Math.floor(e/6e4);return t<1?"now":`${t}m`}function Wte(e,t,n){if(e.activity!=="idle")return{kind:"activity",activity:e.activity,label:Vte(e.activity)};if(t)return{kind:"broadcast",tier:t.tier,text:t.text,clickTarget:t};if(e.brief.lastDeliveredAt){const a=Math.max(0,n-e.brief.lastDeliveredAt);if(a<=Bte)return{kind:"brief-fresh",label:qte(a)}}return{kind:"idle"}}function Gte(e,t){const n=t.session.title??null,a=[];switch(e.kind){case"activity":a.push(`Scout · ${e.label}`);break;case"broadcast":a.push(e.text);break;case"brief-fresh":a.push(`Brief delivered ${e.label} ago`);break;default:a.push("Toggle Scout");break}return n&&a.push(n),t.error&&e.kind!=="broadcast"&&a.push(t.error),a.join(`
146
+ `)}function U$(){const e=L$(),t=Dte(e),{state:n,actions:a}=Tee(),r=Lc(),[o,c]=m.useState(()=>Date.now());m.useEffect(()=>{const y=window.setInterval(()=>c(Date.now()),Ute);return()=>window.clearInterval(y)},[]);const u=Wte(n,t,o),h=Gte(u,n),f=(()=>{switch(u.kind){case"activity":return"s-scoutbot-chip--activity";case"broadcast":return"s-scoutbot-chip--active";case"brief-fresh":return"s-scoutbot-chip--fresh";default:return"s-scoutbot-chip--idle"}})(),g=()=>{Lte(t??null)},v=y=>{r(y,[{kind:"action",label:"Brief me now",onSelect:()=>a.triggerBrief()},{kind:"action",label:"Ask state",onSelect:()=>a.triggerAskState()},{kind:"action",label:"New chat",onSelect:()=>a.startNewChat()},{kind:"separator"},{kind:"action",label:"Open chat",onSelect:()=>a.focusScoutbot()}])};return s.jsxs("button",{type:"button",className:`s-scoutbot-chip ${f}`,onClick:g,onContextMenu:v,title:h,children:[s.jsx(zd,{size:14,className:"s-scoutbot-chip-icon","aria-hidden":"true"}),u.kind==="activity"&&s.jsxs(s.Fragment,{children:[Hte(u.activity)?s.jsx(ea,{size:10,className:"s-scoutbot-chip-spinner","aria-hidden":"true"}):s.jsx("span",{className:"s-scoutbot-chip-dot s-scoutbot-chip-dot--pulse","aria-hidden":"true"}),s.jsx("span",{className:"s-scoutbot-chip-text",children:u.label})]}),u.kind==="broadcast"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:Fte(u.tier),"aria-hidden":"true"}),s.jsx("span",{className:"s-scoutbot-chip-text",children:u.text})]}),u.kind==="brief-fresh"&&s.jsx("span",{className:"s-scoutbot-chip-text",children:u.label})]})}const Lh=240,Zte=900,Kte=.45,Yte=500;function TA(e){return Math.min(Zte,Math.max(Yte,Math.floor(e*Kte)))}function Xte({app:e,assistant:t=!0}){return s.jsx(e.Provider,{children:s.jsx(uQ,{children:s.jsx(ene,{app:e,assistantEnabled:t})})})}function Qte({statusBar:e}){const t=e.mesh.color==="amber"?"text-amber-400":e.mesh.color==="red"?"text-red-400":"text-foreground";return s.jsxs("div",{className:"flex items-center gap-3 font-mono leading-none",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[9px] font-normal uppercase tracking-[0.16em] text-muted-foreground",children:e.activeAgents.label}),s.jsx("span",{className:"text-[10px] tabular-nums text-foreground",children:e.activeAgents.count})]}),s.jsx("span",{"aria-hidden":"true",className:"select-none text-muted-foreground/40 text-[10px]",children:"·"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[9px] font-normal uppercase tracking-[0.16em] text-muted-foreground",children:e.mesh.label}),s.jsx("span",{className:`text-[10px] ${t}`,children:e.mesh.value})]}),s.jsx("span",{"aria-hidden":"true",className:"select-none text-muted-foreground/40 text-[10px]",children:"·"}),s.jsx(U$,{})]})}function Jte({statusBar:e}){return s.jsx("div",{className:"max-w-[38vw] truncate font-mono text-[10px] leading-none text-muted-foreground",title:e.build.title,children:e.build.label})}function ene({app:e,assistantEnabled:t}){const{navTotalHeight:n}=_w(),a=xte();gte();const r=e.hooks.useCommands(),o=e.hooks.useSearch?.()??null,c=e.hooks.useNavCenter?.()??null,u=e.hooks.useNavActions?.()??null,h=e.hooks.useLayoutMode?.()??e.mode,f=h==="focus"?"panel":h,g=e.hooks.useActiveToolHint?.()??null,v=e.hooks.useTakeover?.()??null,y=v?.active===!0,x=y&&v?.dismissible===!0,w=v?.onDismiss,C=e.slots.Takeover,T=T$(),E=dQ(),[S,k]=Ua(`appshell.${e.id}.left`,!1),[N,A]=Ua(`appshell.${e.id}.right`,!1),[R,_]=Ua(`appshell.${e.id}.rightOverlay`,!1),[P,$]=Ua(`appshell.${e.id}.leftW`,260),[H,I]=Ua(`appshell.${e.id}.rightW`,280),[U,D]=Ua("openscout.ops.minimap.collapsed",!1),[V,Z]=m.useState(()=>TA(typeof window<"u"?window.innerWidth:1280));m.useEffect(()=>{const Y=()=>Z(TA(window.innerWidth));return Y(),window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},[]),m.useEffect(()=>{$(Y=>Math.min(V,Math.max(Lh,Y))),I(Y=>Math.min(V,Math.max(Lh,Y)))},[V,$,I]);const[O,z]=m.useState({x:0,y:0}),[B,X]=m.useState(1),W=m.useCallback(Y=>{z(te=>({x:te.x+Y.x,y:te.y+Y.y}))},[]),L=m.useCallback(Y=>{X(Y)},[]),[q,K]=m.useState(!1),[ee,G]=m.useState(!1),[re,Q]=Ua(`appshell.${e.id}.termH`,320),ae=!!e.slots.Terminal,be=m.useMemo(()=>{const Y=[];return ae&&Y.push("terminal"),t&&Y.push("assistant"),Y},[ae,t]),$e=be[0]??"terminal",[ge,Te]=Ua(`appshell.${e.id}.drawerTab`,$e),pe=be.includes(ge)?ge:$e,[Xe,Be]=m.useState(!1),[Se,Me]=m.useState(new Set),_e=m.useCallback(Y=>{Me(te=>{const he=new Set(te);return he.has(Y)?he.delete(Y):he.add(Y),he})},[]),Ne=m.useCallback(Y=>te=>{te.preventDefault();const he=te.clientX,Pe=Y==="left"?P:H,We=Y==="left"?$:I,rt=Y==="left"?1:-1,at=jt=>{const bt=(jt.clientX-he)*rt;We(Math.max(Lh,Math.min(V,Pe+bt)))},Ot=()=>{document.removeEventListener("mousemove",at),document.removeEventListener("mouseup",Ot)};document.addEventListener("mousemove",at),document.addEventListener("mouseup",Ot)},[P,H,$,I,V]),Oe=m.useMemo(()=>{const Y=[{id:"shell:toggle-left",label:"Toggle Left Panel",shortcut:"Cmd+[",action:()=>k(te=>!te)},{id:"shell:toggle-right",label:"Toggle Right Panel",shortcut:"Cmd+]",action:()=>A(te=>!te)},{id:"shell:toggle-right-overlay",label:"Toggle Inspector Overlay",shortcut:"Cmd+Shift+]",action:()=>_(te=>!te)},{id:"shell:toggle-terminal",label:"Toggle Terminal",shortcut:"Ctrl+`",action:()=>K(te=>!te)}];return t&&Y.push({id:"shell:toggle-assistant",label:"Toggle Assistant",shortcut:"Cmd+J",action:()=>{Te("assistant"),K(te=>!te||ge!=="assistant")}}),Y},[t,ge,Te,k,A,_]),Ce=m.useMemo(()=>[...r,...Oe],[r,Oe]);m.useEffect(()=>{const Y=te=>{y||((te.metaKey||te.ctrlKey)&&te.key==="k"&&(te.preventDefault(),Be(!0)),(te.metaKey||te.ctrlKey)&&te.key==="["&&(te.preventDefault(),k(he=>!he)),(te.metaKey||te.ctrlKey)&&te.key==="]"&&(te.preventDefault(),te.shiftKey?_(he=>!he):A(he=>!he)),te.ctrlKey&&te.key==="`"&&(te.preventDefault(),K(he=>!he)),t&&(te.metaKey||te.ctrlKey)&&te.key==="j"&&(te.preventDefault(),Te("assistant"),K(he=>!(he&&pe==="assistant"))))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[t,pe,Te,k,A,_,y]),m.useEffect(()=>{const Y=()=>{Te("terminal"),K(!0),Q(te=>te>window.innerHeight*.8?420:te)};return window.addEventListener("scout:open-terminal",Y),()=>window.removeEventListener("scout:open-terminal",Y)},[Te,Q]),m.useEffect(()=>{const Y=te=>{const he=te.detail,Pe=typeof he?.width=="number"?he.width:420;A(!1),I(We=>Math.max(We,Math.min(V,Math.max(Lh,Pe))))};return window.addEventListener("scout:set-inspector-width",Y),()=>window.removeEventListener("scout:set-inspector-width",Y)},[A,I,V]);const Ve=e.slots.Inspector,Re=e.slots.RightPanel,Ie=e.tools&&e.tools.length>0,De=s.jsxs(s.Fragment,{children:[Ve&&s.jsx(Ve,{}),!Ve&&Re&&s.jsx(Re,{}),Ie&&s.jsx("div",{className:"border-t border-neutral-700/50",children:e.tools.map(Y=>{const te=Se.has(Y.id);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>_e(Y.id),className:`w-full flex items-center gap-2 px-4 py-2.5 text-[11px] font-mono tracking-wider uppercase transition-colors hover:bg-white/5 ${g===Y.id?"text-emerald-400":"text-neutral-300"}`,children:[te?s.jsx(Vo,{size:10}):s.jsx(Rp,{size:10}),s.jsx("span",{className:"text-neutral-400",children:Y.icon}),s.jsx("span",{className:"font-bold",children:Y.name})]}),te&&s.jsx("div",{className:"px-4 pb-3",children:s.jsx(Y.Component,{})})]},Y.id)})})]}),ct=s.jsx(rQ,{onOpenCommandPalette:()=>Be(!0)}),ut=m.useMemo(()=>({isCollapsed:U,onToggleCollapse:()=>D(Y=>!Y)}),[U,D]),st=E?s.jsx("div",{className:`scout-canvas-minimap-shell${U?" scout-canvas-minimap-shell--collapsed":""}`,children:E.render(ut)}):null,ht=E?s.jsx("div",{className:`scout-canvas-minimap-shell scout-canvas-minimap-shell--floating${U?" scout-canvas-minimap-shell--collapsed":""}`,children:E.render(ut)}):null,yt=m.useRef(null),Mt=m.useRef(null);m.useEffect(()=>{const Y=yt.current;Y&&(y?Y.setAttribute("inert",""):Y.removeAttribute("inert"))},[y]),m.useEffect(()=>{if(!y)return;const Y=Mt.current;if(Y&&(Y.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")??Y).focus(),!x)return;const te=he=>{he.key==="Escape"&&(he.preventDefault(),w?.())};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[y,x,w]);const Rt=N||R?0:H,xt=h==="panel"?{position:"absolute",top:n,bottom:28,left:S?0:P,right:Rt,overflow:"auto",transition:"left 200ms ease, right 200ms ease"}:{};return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:yt,"aria-hidden":y?!0:void 0,style:{display:"contents"},children:s.jsx(XX,{mode:f,panOffset:O,scale:B,onPan:W,onZoom:L,hud:s.jsxs(s.Fragment,{children:[s.jsx(JX,{title:e.name.toUpperCase(),search:o??void 0,center:c,actions:u}),s.jsx(dA,{side:"left",title:e.leftPanel?.title??"Navigation",icon:e.leftPanel?.icon,isCollapsed:S,onToggleCollapse:()=>k(!S),width:P,onResizeStart:Ne("left"),footer:S?void 0:st,headerActions:e.leftPanel?.headerActions&&s.jsx(e.leftPanel.headerActions,{}),children:s.jsx("div",{"data-pane":"left",style:{display:"contents"},children:e.slots.LeftPanel&&s.jsx(e.slots.LeftPanel,{})})}),S?ht:null,s.jsx(dA,{side:"right",title:e.rightPanel?.title??"Inspector",icon:e.rightPanel?.icon,isCollapsed:N,onToggleCollapse:()=>A(!N),width:H,onResizeStart:Ne("right"),style:R?{backgroundColor:"rgba(13, 14, 16, 0.72)",backdropFilter:"blur(24px) saturate(140%)",WebkitBackdropFilter:"blur(24px) saturate(140%)",boxShadow:"-18px 0 48px -12px rgba(0,0,0,0.7), inset 1px 0 0 0 rgba(255,255,255,0.06)"}:void 0,footer:ct,headerActions:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>_(Y=>!Y),title:R?"Pin inspector (push content)":"Float inspector (overlay content)","aria-label":R?"Pin inspector":"Float inspector",className:"p-1 hover:bg-accent/10 rounded transition-colors text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",children:R?s.jsx($z,{size:12}):s.jsx(Dz,{size:12})}),e.rightPanel?.headerActions&&s.jsx(e.rightPanel.headerActions,{})]}),children:s.jsx("div",{"data-pane":"right",style:{display:"contents"},children:De})}),s.jsx(sQ,{status:T.status,left:s.jsx(Qte,{statusBar:T}),right:s.jsx(Jte,{statusBar:T}),onToggleTerminal:()=>K(Y=>!Y),isTerminalOpen:q}),s.jsx("div",{className:"pointer-events-none",style:{position:"fixed",left:S?0:P,right:Rt,bottom:0,top:0,zIndex:45,transition:"left 200ms ease, right 200ms ease",transform:"translateZ(0)"},children:s.jsxs(oQ,{isOpen:q,onClose:()=>K(!1),onToggleMaximize:()=>G(Y=>!Y),isMaximized:ee,height:Math.min(re,window.innerHeight*.8),onHeightChange:Y=>Q(Math.min(Y,window.innerHeight*.8)),title:s.jsx(tne,{tabs:be,active:pe,onSelect:Te}),children:[q&&pe==="terminal"&&(e.slots.Terminal?s.jsx(e.slots.Terminal,{}):s.jsx("div",{className:"p-4 font-mono text-[12px] text-neutral-400",children:"No terminal content"})),q&&pe==="assistant"&&s.jsx(l9,{app:e,commands:r})]})}),s.jsx(cQ,{isOpen:Xe,onClose:()=>Be(!1),commands:Ce})]}),children:s.jsx("div",{style:xt,className:"frame-scrollbar","data-pane":"center",children:s.jsx(e.slots.Content,{})})})}),y&&C?s.jsx("div",{ref:Mt,tabIndex:-1,role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:80,outline:"none"},children:s.jsx(C,{})}):null,s.jsx(yte,{open:a.open,onClose:()=>a.setOpen(!1)})]})}function tne({tabs:e,active:t,onSelect:n}){return e.length===0?null:s.jsx("div",{className:"flex items-center gap-0.5",children:e.map(a=>{const r=a===t,o=a==="terminal"?p2:Pp,c=a==="terminal"?"TERMINAL":"ASSISTANT",u=a==="terminal"?"text-emerald-400":"text-cyan-400";return s.jsxs("button",{type:"button",onClick:()=>n(a),className:`flex items-center gap-1.5 px-2.5 py-1 rounded text-xs font-bold tracking-widest font-mono transition-colors ${r?`${u} bg-white/[0.04]`:"text-neutral-500 hover:text-neutral-300"}`,children:[s.jsx(o,{size:13}),s.jsx("span",{children:c})]},a)})})}async function On(e){if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}const MA=["#6366f1","#8b5cf6","#0ea5e9","#14b8a6","#f59e0b","#ef4444","#ec4899","#10b981"];function qt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return MA[Math.abs(t)%MA.length]}function Pn(e){switch(Je(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}function px(e,t){const n=t?.trim();n&&e.add(n)}function nne(e,t){const n=new Set;return px(n,e.authorityNodeId),px(n,e.homeNodeId),n.size===0&&px(n,t),n}function F$(e,t,n){return t?nne(e,n).has(t):!0}function el(e,t,n){return t?e.filter(a=>F$(a,t,n)):e}function eo(e,t,n){return t?new Set(e.filter(a=>F$(a,t,n)).map(a=>a.id)):null}function Bo(e,t,n){return!t&&!n||n&&e.authorityNodeId===n?!0:t?e.agentId&&t.has(e.agentId)||e.actorId&&t.has(e.actorId)||e.ownerId&&t.has(e.ownerId)||e.nextMoveOwnerId&&t.has(e.nextMoveOwnerId)?!0:!!e.participantIds?.some(a=>t.has(a)):!1}function sne(e,t,n){return Bo(e,t,n)}function og(e,t,n){return!t&&!n?e:e.filter(a=>sne(a,t,n))}function ane(e,t){return Bo(e,t)}function V$(e,t){return t?e.filter(n=>ane(n,t)):e}function RA(e,t){return Bo(e,t)}function H$(e,t){if(!e||!t)return e;const n=e.activeAsks.filter(c=>Bo(c,t)),a=e.recentCompleted.filter(c=>Bo(c,t)),r=e.needsAttention.filter(c=>Bo(c,t)),o=V$(e.activity,t);return{...e,totals:{active:n.length,recentCompleted:a.length,needsAttention:r.length,activity:o.length},activeAsks:n,recentCompleted:a,needsAttention:r,activity:o}}function rne(e,t){if(!t)return e;const n=e.activeFlights.filter(o=>Bo(o,t)),a=e.childWork.filter(o=>RA(o,t));return RA(e,t)||n.length>0||a.length>0?{...e,activeFlights:n,childWork:a}:null}const ine=1e12;function one(e){return Number.isFinite(e)&&e>0}function lne(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):null;return t===null||!one(t)?null:Math.trunc(t<ine?t*1e3:t)}const cne={workspace:"workspace",worktree:"workspace",branch:"workspace",profile:"profile",persona:"profile",harness:"harness",runtime:"harness",model:"model",node:"node",host:"node"};function une(e){return e.trim().replace(/^@+/,"").replace(/[.,!?;)\]]+$/,"")}function Fa(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const dne="scout";function fne(e){return cne[Fa(e)]??null}function q$(e){const t=Fa(e.definitionId),n=e.workspaceQualifier?Fa(e.workspaceQualifier):void 0,a=e.profile?Fa(e.profile):void 0,r=e.harness?Fa(e.harness):void 0,o=e.model?Fa(e.model):void 0,c=e.nodeQualifier?Fa(e.nodeQualifier):void 0;return t?{definitionId:t,...n?{workspaceQualifier:n}:{},...a?{profile:a}:{},...r?{harness:r}:{},...o?{model:o}:{},...c?{nodeQualifier:c}:{}}:null}function W$(e){const t=e.split(".").filter(Boolean),n=t.shift();if(!n)return null;const a={definitionId:n},r=[];for(const o of t){if(o.includes(":")){const[c,u=""]=o.split(":",2),h=fne(c),f=Fa(u);if(!h||!f)return null;h==="workspace"?a.workspaceQualifier=f:h==="profile"?a.profile=f:h==="harness"?a.harness=f:h==="model"?a.model=f:h==="node"&&(a.nodeQualifier=f);continue}r.push(o)}if(r.length===1){const o=Fa(r[0]);if(!o)return null;a.workspaceQualifier=o}else if(r.length===2){const o=Fa(r[0]),c=Fa(r[1]);if(!o||!c)return null;a.workspaceQualifier||(a.workspaceQualifier=o),a.nodeQualifier||(a.nodeQualifier=c)}else if(r.length>2)return null;return Vw(a,{raw:e})}function hne(e){const t=e.indexOf("#"),n=e.indexOf("?");if(t===-1&&n===-1||e.indexOf("#",t+1)!==-1||e.indexOf("?",n+1)!==-1||t!==-1&&n!==-1&&n<t)return null;const a=Math.min(...[t,n].filter(h=>h>=0)),r=e.slice(0,a);if(!r)return null;const o=W$(r);if(!o)return null;const c=t>=0?e.slice(t+1,n>=0?n:e.length):"",u=n>=0?e.slice(n+1):"";return t>=0&&!c||n>=0&&!u||c.includes("#")||c.includes("?")||u.includes("#")||u.includes("?")||o.harness&&c||o.model&&u?null:Vw({definitionId:o.definitionId,nodeQualifier:o.nodeQualifier,workspaceQualifier:o.workspaceQualifier,profile:o.profile,harness:c||o.harness,model:u||o.model},{raw:e})}function mne(e){const t=une(e);return!t||t.includes("@")?null:t.includes("#")||t.includes("?")?hne(t):W$(t)}function IA(e,t={}){const n=q$(e);if(!n)return t.includeSigil===!1?"":"@";const r=[`${t.includeSigil===!1?"":"@"}${n.definitionId}`];return n.workspaceQualifier&&r.push(n.workspaceQualifier),n.profile&&r.push(`profile:${n.profile}`),n.harness&&r.push(`harness:${n.harness}`),n.model&&r.push(`model:${n.model}`),n.nodeQualifier&&r.push(`node:${n.nodeQualifier}`),r.join(".")}function Vw(e,t={}){const n=q$(e);return n?{raw:t.raw??IA(n,{includeSigil:!1}),label:IA(n),definitionId:n.definitionId,...n.nodeQualifier?{nodeQualifier:n.nodeQualifier}:{},...n.workspaceQualifier?{workspaceQualifier:n.workspaceQualifier}:{},...n.profile?{profile:n.profile}:{},...n.harness?{harness:n.harness}:{},...n.model?{model:n.model}:{}}:null}function pne(e){return gne(e).parsed}function gne(e){const t=Array.from(e.matchAll(/(^|[\s([{'"`])@([a-z0-9][a-z0-9._/:-]*(?:#[a-z0-9][a-z0-9._/:-]*)?(?:\?[a-z0-9][a-z0-9._/:-]*)?)(?=$|[\s)\]}",.!?:;'"`])/gi)),n=new Map,a=[];for(const r of t){const o=r[2]??"",c=mne(o);if(!c){o&&a.push(`@${o}`);continue}n.set(c.label,c)}return{parsed:Array.from(n.values()),unparsed:Array.from(new Set(a))}}function zt(e){return lne(e)}function G$(e,t){return(zt(e)??0)-(zt(t)??0)}function lg(e,t){return G$(t,e)}function Ae(e,t=Date.now()){const n=zt(e);if(n===null)return"";const a=Math.floor((t-n)/1e3);return a<5?"now":a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function Wa(e){const t=zt(e);return t===null?"":new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"})}function Mm(e){const t=zt(e);return t===null?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function _A(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):null}const Z$=m.forwardRef(function({agent:t,pinned:n,onOpen:a,onClose:r,style:o,className:c},u){const h=Je(t.state),f=_A(t.cwd)??_A(t.projectRoot),g=t.handle??t.name,v=t.authorityNodeName??t.homeNodeName??t.authorityNodeId??t.homeNodeId,y=h==="working"?"Working":h==="available"?"Available":"Offline";return s.jsxs("div",{ref:u,className:`agent-card${n?" agent-card--pinned":""}${c?` ${c}`:""}`,style:o,role:"dialog","aria-label":`${g} details`,children:[s.jsxs("header",{className:"agent-card-head",children:[s.jsx("div",{className:"agent-card-name",children:g}),s.jsxs("div",{className:"agent-card-meta",children:[s.jsx("span",{className:`agent-card-dot agent-card-dot--${h}`,style:h==="working"?{background:Pn(t.state)}:void 0}),s.jsx("span",{className:`agent-card-state agent-card-state--${h}`,children:y}),t.updatedAt&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"agent-card-sep",children:"·"}),s.jsx("span",{className:"agent-card-time",children:Ae(t.updatedAt)})]})]})]}),s.jsxs("div",{className:"agent-card-body",children:[f&&s.jsx(No,{label:"cwd",children:s.jsx("code",{className:"agent-card-mono",children:f})}),v&&s.jsx(No,{label:"machine",children:s.jsx("span",{className:"agent-card-mono",children:v})}),(t.project||t.branch)&&s.jsx(No,{label:"project",children:s.jsxs("span",{className:"agent-card-mono",children:[t.project??"—",t.branch&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"agent-card-sep agent-card-sep--inline",children:"·"}),s.jsx("span",{className:"agent-card-branch",children:t.branch})]})]})}),(t.harness||t.model)&&s.jsx(No,{label:"harness",children:s.jsxs("span",{className:"agent-card-mono",children:[t.harness??"—",t.model&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"agent-card-sep agent-card-sep--inline",children:"·"}),s.jsx("span",{className:"agent-card-model",children:t.model})]})]})}),t.transport&&s.jsx(No,{label:"transport",children:s.jsx("span",{className:"agent-card-mono",children:t.transport})}),t.role&&s.jsx(No,{label:"role",children:s.jsx("span",{className:"agent-card-mono",children:t.role})}),t.capabilities&&t.capabilities.length>0&&s.jsx(No,{label:"capabilities",children:s.jsxs("div",{className:"agent-card-caps",children:[t.capabilities.slice(0,8).map(x=>s.jsx("span",{className:"agent-card-cap",children:x},x)),t.capabilities.length>8&&s.jsxs("span",{className:"agent-card-cap agent-card-cap--more",children:["+",t.capabilities.length-8]})]})})]}),s.jsxs("footer",{className:"agent-card-foot",children:[s.jsxs("button",{type:"button",className:"agent-card-link",onClick:a,children:["Open agent ",s.jsx("span",{"aria-hidden":!0,children:"→"})]}),n&&s.jsx("button",{type:"button",className:"agent-card-close",onClick:r,"aria-label":"Close",children:"esc"})]})]})});function No({label:e,children:t}){return s.jsxs("div",{className:"agent-card-field",children:[s.jsx("span",{className:"agent-card-label",children:e}),s.jsx("div",{className:"agent-card-value",children:t})]})}const vne=280,yne=120,Hb=320,zh=8,Bh=new Map,xne=1e4;function hs(e){const t=e?.trim().replace(/^@+/,"").toLowerCase();return t&&t.length>0?t:null}function K$(e){const t=new Set,n=a=>{const r=hs(a);r&&t.add(r)};return n(e.id),n(e.handle),n(e.name),n(e.selector),n(e.defaultSelector),n(e.definitionId),e.definitionId&&e.workspaceQualifier&&n(`${e.definitionId}.${e.workspaceQualifier}`),e.definitionId&&e.workspaceQualifier&&e.nodeQualifier&&(n(`${e.definitionId}.${e.workspaceQualifier}.${e.nodeQualifier}`),n(`${e.definitionId}.${e.workspaceQualifier}.node:${e.nodeQualifier}`)),e.definitionId&&e.nodeQualifier&&n(`${e.definitionId}.node:${e.nodeQualifier}`),t}function bne(e,t){const n=hs(t.label),a=hs(t.raw),r=K$(e);return n&&r.has(n)||a&&r.has(a)?!0:t.definitionId&&hs(e.definitionId)!==hs(t.definitionId)||t.workspaceQualifier&&hs(e.workspaceQualifier)!==hs(t.workspaceQualifier)||t.nodeQualifier&&hs(e.nodeQualifier)!==hs(t.nodeQualifier)||t.harness&&hs(e.harness)!==hs(t.harness)||t.model&&hs(e.model)!==hs(t.model)?!1:!!t.definitionId}function OA(e,t){const n=hs(t.label),a=hs(t.raw),r=K$(e),o=n&&r.has(n)||a&&r.has(a)?1e3:0,c=[t.workspaceQualifier,t.nodeQualifier,t.harness,t.model,t.profile].filter(Boolean).length*100,u=Je(e.state),h=u==="working"?30:u==="available"?20:0;return o+c+h+Math.min(e.updatedAt??0,9999999999)/1e9}function wne(e){const t=hs(e.raw);return t&&t.split(".").length>=3?t:null}function Y$(e,t){const n=t.filter(a=>bne(a,e)).sort((a,r)=>OA(r,e)-OA(a,e));return n[0]?n[0]:null}async function jne(e,t){const n=Y$(e,t),a=n?.id??wne(e),r=a??e.label,o=Bh.get(r);if(o&&Date.now()-o.fetchedAt<xne)return o.agent;if(!a)return Bh.set(r,{agent:n,fetchedAt:Date.now()}),n;try{const c=await me(`/api/agents/${encodeURIComponent(a)}`);return Bh.set(r,{agent:c,fetchedAt:Date.now()}),c}catch{return Bh.set(r,{agent:n,fetchedAt:Date.now()}),n}}function $A(e){const t=window.innerWidth,n=window.innerHeight,a=Math.max(zh,Math.min(t-Hb-zh,e.left+e.width/2-Hb/2)),r=e.top-zh;return r>200||e.bottom>n-200?{top:r,left:a,placement:"above"}:{top:e.bottom+zh,left:a,placement:"below"}}function Nne(e){let t=e;for(;t;){if(t instanceof HTMLElement&&t.dataset.scoutTheme)return t;t=t.parentElement??null}return document.body}function kne({identity:e,agent:t,triggerEl:n,onRequestClose:a}){const{agents:r,navigate:o}=qe(),[c,u]=m.useState(()=>t??Y$(e,r)),[h,f]=m.useState(!t),[g,v]=m.useState(()=>$A(n.getBoundingClientRect())),y=m.useRef(null),x=Nne(n);m.useEffect(()=>{if(t){u(t),f(!1);return}let S=!1;return f(!0),jne(e,r).then(k=>{S||(u(k),f(!1))}),()=>{S=!0}},[e,r,t]),m.useEffect(()=>{const S=()=>{v($A(n.getBoundingClientRect()))};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[n]),m.useEffect(()=>{const S=k=>{k.key==="Escape"&&a()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[a]);const w=m.useCallback(()=>{c&&(o({view:"agents",agentId:c.id}),a())},[c,o,a]),C=g.placement==="above"?"bottom center":"top center",T=g.placement==="above"?"translateY(-100%)":"",E={position:"fixed",top:g.top,left:g.left,width:Hb,transform:T,transformOrigin:C};return c?yr.createPortal(s.jsx("div",{onMouseEnter:()=>{},onMouseLeave:a,children:s.jsx(Z$,{ref:y,agent:c,pinned:!0,onOpen:w,onClose:a,style:E,className:"agent-card--mention"})}),x):yr.createPortal(s.jsx("div",{ref:y,className:"agent-card agent-card--pinned agent-card--mention",role:"dialog","aria-label":`${e.label} snapshot`,style:E,onMouseEnter:()=>{},onMouseLeave:a,children:s.jsx("div",{style:{fontSize:"12px",color:"var(--dim)",padding:"4px 2px"},children:h?"loading…":s.jsxs(s.Fragment,{children:["No agent registered as ",s.jsx("code",{children:e.label}),"."]})})}),x)}function Sne(e){return Vw({definitionId:e.definitionId,workspaceQualifier:e.workspaceQualifier??void 0,nodeQualifier:e.nodeQualifier??void 0,harness:e.harness??void 0,model:e.model??void 0})}function Hw(e){const{agent:t,identity:n}=e,[a,r]=m.useState(!1),[o,c]=m.useState(!1),u=m.useRef(null),h=m.useRef(null),f=m.useRef(null),g=m.useCallback(()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null),f.current!==null&&(window.clearTimeout(f.current),f.current=null)},[]),v=m.useCallback(()=>{a||(g(),h.current=window.setTimeout(()=>r(!0),vne))},[a,g]),y=m.useCallback(()=>{o||(g(),f.current=window.setTimeout(()=>r(!1),yne))},[o,g]),x=m.useCallback(()=>{g(),r(!1),c(!1)},[g]);m.useEffect(()=>()=>g(),[g]);const w=m.useMemo(()=>n??(t?Sne(t):null),[n,t]),C=!!w,T=m.useCallback(N=>{if(N.preventDefault(),N.stopPropagation(),a&&o){x();return}g(),c(!0),r(!0)},[a,o,x,g]),E=m.useCallback(N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),c(!0),r(!0))},[]),S=C?{ref:u,onMouseEnter:v,onMouseLeave:y,onFocus:v,onBlur:y,onClick:T,onKeyDown:E,"data-hover-open":a?"true":void 0,"aria-haspopup":"dialog","aria-expanded":a}:{ref:u},k=a&&u.current&&w?s.jsx(kne,{identity:w,agent:t??null,triggerEl:u.current,onRequestClose:()=>{o?x():y()}}):null;return{triggerProps:S,popover:k,open:a,pinned:o}}function Cne({identity:e,color:t}){const{triggerProps:n,popover:a}=Hw({identity:e});return s.jsxs(s.Fragment,{children:[s.jsx("span",{...n,className:"s-mention",role:"button",tabIndex:0,style:{"--mention-color":t},children:e.label}),a]})}const Ene=["ts","tsx","js","jsx","mjs","cjs","md","mdx","txt","log","json","jsonc","yaml","yml","toml","css","scss","html","htm","sh","py","rb","go","rs","swift","kt","java","c","cpp","h","png","jpg","jpeg","gif","svg","webp","avif","env","conf","ini","gitignore","sql","xml"],Ane=Ene.join("|"),PA=new RegExp(`\\.(?:${Ane})(?:$|[?#])`,"i"),Tne=/^(?:\/Users\/|\/home\/|\/Volumes\/|\/var\/|\/etc\/|\/opt\/|\/tmp\/|\/private\/|\/mnt\/|\/Applications\/|\/usr\/|\/Library\/)/u,Mne=/(?:^|[\s(\[`'"])((?:~\/|\.\/|\.\.\/|\/)[A-Za-z0-9._/\-]+|[A-Za-z0-9._\-]+(?:\/[A-Za-z0-9._\-]+)+)/g;function Rne(e){return e.startsWith("~/")||e.startsWith("./")||e.startsWith("../")?!0:e.startsWith("/")&&Tne.test(e)||PA.test(e)}function DA(e){const t=[],n=new RegExp(Mne.source,"g");let a;for(;(a=n.exec(e))!==null;){const r=a[1];if(!r)continue;const o=r.replace(/[.,;:!?]+$/u,"");if(!o||!Rne(o))continue;const c=a[0].lastIndexOf(r);if(c<0)continue;const u=a.index+c;t.push({start:u,end:u+o.length,path:o})}return t}function Ine(e){return/\.(png|jpe?g|gif|svg|webp|avif)(?:$|[?#])/iu.test(e)}function _ne(e){return e.endsWith("/")?!0:!(e.split("/").pop()??"").includes(".")&&!e.startsWith("./")&&!e.startsWith("../")}function One({kind:e}){return e==="dir"?s.jsx("svg",{className:"s-path-token-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:s.jsx("path",{d:"M2 5a1 1 0 0 1 1-1h3.5l1.5 1.5h5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1Z"})}):e==="image"?s.jsxs("svg",{className:"s-path-token-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("rect",{x:"2",y:"3",width:"12",height:"10",rx:"1.5"}),s.jsx("circle",{cx:"6",cy:"7",r:"1"}),s.jsx("path",{d:"m3 12 3.5-3 2.5 2 3-2.5L14 11"})]}):s.jsxs("svg",{className:"s-path-token-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M4 2h5l3 3v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Z"}),s.jsx("path",{d:"M9 2v3h3"})]})}function LA({path:e}){const{openFilePreview:t}=qe(),n=Ine(e)?"image":_ne(e)?"dir":"file";return s.jsxs("button",{type:"button",className:"s-path-token",onClick:a=>{a.preventDefault(),a.stopPropagation(),t(e)},title:`Open ${e}`,children:[s.jsx(One,{kind:n}),e]})}function $ne(e,t){if(t.length===0)return[{kind:"text",value:e}];const n=new Map;for(const c of t)n.set(c.label.toLowerCase(),c);const a=[];let r=e;const o=/@([a-z0-9][a-z0-9._/:-]*)/i;for(;r.length>0;){const c=o.exec(r);if(!c||c.index===void 0){a.push({kind:"text",value:r});break}c.index>0&&a.push({kind:"text",value:r.slice(0,c.index)});const u=c[0],h=u.toLowerCase(),f=n.get(h);f?a.push({kind:"mention",identity:f}):a.push({kind:"text",value:u}),r=r.slice(c.index+u.length)}return a}function Pne(e,t){const n=[],a=/`([^`\n]+)`|\*\*(.+?)\*\*|\*([^*\s][^*]*?)\*|\[([^\]\n]+)\]\(([^)\s]+)\)|(https?:\/\/[^\s<>"')\]]+)/g;let r=0,o,c=0;const u=h=>{if(!h)return;const f=DA(h);if(f.length===0){n.push(s.jsx("span",{children:h},`${t}-${c++}`));return}let g=0;for(const v of f)v.start>g&&n.push(s.jsx("span",{children:h.slice(g,v.start)},`${t}-${c++}`)),n.push(s.jsx(LA,{path:v.path},`${t}-${c++}`)),g=v.end;g<h.length&&n.push(s.jsx("span",{children:h.slice(g)},`${t}-${c++}`))};for(;(o=a.exec(e))!==null;){if(o.index>r&&u(e.slice(r,o.index)),o[1]!==void 0){const h=o[1],f=DA(` ${h}`);f.length===1&&f[0].path===h?n.push(s.jsx(LA,{path:h},`${t}-${c++}`)):n.push(s.jsx("code",{className:"s-inline-code",children:h},`${t}-${c++}`))}else if(o[2]!==void 0)n.push(s.jsx("strong",{children:o[2]},`${t}-${c++}`));else if(o[3]!==void 0)n.push(s.jsx("em",{children:o[3]},`${t}-${c++}`));else if(o[4]!==void 0&&o[5]!==void 0&&zA(o[5]))n.push(s.jsx("a",{className:"s-inline-link",href:o[5],target:"_blank",rel:"noreferrer",children:o[4]},`${t}-${c++}`));else if(o[6]!==void 0&&zA(o[6])){const h=o[6].replace(/[.,;:!?]+$/u,""),f=o[6].slice(h.length);n.push(s.jsx("a",{className:"s-inline-link",href:h,target:"_blank",rel:"noreferrer",children:h},`${t}-${c++}`)),f&&n.push(s.jsx("span",{children:f},`${t}-${c++}`))}else n.push(s.jsx("span",{children:o[0]},`${t}-${c++}`));r=o.index+o[0].length}return r<e.length&&u(e.slice(r)),n.length>0?n:[s.jsx("span",{children:e},t)]}function zA(e){return/^(?:https?:\/\/|mailto:|\/|#)/iu.test(e)}function Ca(e){if(!e)return e??"";const t=pne(e);return $ne(e,t).flatMap((a,r)=>{if(a.kind==="text")return Pne(a.value,r*100);const{identity:o}=a,u=o.definitionId===dne?"var(--accent)":qt(o.definitionId);return s.jsx(Cne,{identity:o,color:u},r)})}function sa({title:e,body:t,icon:n,action:a,className:r}){const o=r?`sys-panel sys-state-card ${r}`:"sys-panel sys-state-card";return s.jsxs("div",{className:o,children:[n,s.jsx("h3",{className:"sys-state-title",children:e}),t!=null&&(typeof t=="string"?s.jsx("p",{className:"sys-state-body",children:t}):t),a&&s.jsx("div",{className:"sys-inline-actions",children:a})]})}const Dne={"agent.registered":"registered","agent.online":"came online","agent.offline":"went offline","flight.started":"started task","flight.completed":"completed task","flight.updated":"updated task","message.sent":"sent message","message.received":"received message","collaboration.ask":"asked a question","collaboration.answer":"answered",ask_sent:"asked",ask_replied:"replied",ask_working:"working",flight_created:"started task",flight_updated:"updated task",message_sent:"sent",message_received:"received"},Lne={presence:{label:"Presence",tone:"notice"},work:{label:"Execution",tone:"working"},message:{label:"Delivery",tone:"completed"},collaboration:{label:"Coordination",tone:"working"},system:{label:"System",tone:"notice"}};function X$(e){return Dne[e]??e.replace(/[._]/g," ")}function zne(e){return e.startsWith("agent.")||e.includes("registered")||e.includes("online")||e.includes("offline")?"presence":e.startsWith("flight")||e.startsWith("ask_")?"work":e.startsWith("message")?"message":e.startsWith("collaboration")?"collaboration":"system"}function Bne(e){return(e??"system").charAt(0).toUpperCase()}function Mo(e){return e.length<=14?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Une(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function Fne(e){return`${e.actorName??"system"} ${X$(e.kind)}`}function Vne(e){return e.workspaceRoot?`Recorded from ${e.workspaceRoot}.`:e.conversationId?`Linked to thread ${Mo(e.conversationId)}.`:"No additional detail was captured for this event."}function Hne({navigate:e}){const{agents:t,route:n}=qe(),[a,r]=m.useState([]),[o,c]=m.useState(null),[u,h]=m.useState(!0),[f,g]=m.useState(!1),[v,y]=m.useState(null),[x,w]=m.useState(null),C=m.useRef([]),T=m.useRef(0),E=m.useRef(null),S=Lc(),k=oa(n),N=m.useMemo(()=>eo(t,k),[t,k]),A=m.useMemo(()=>V$(a,N),[a,N]);m.useEffect(()=>{C.current=a},[a]),m.useEffect(()=>{o&&!A.some(I=>I.id===o)&&c(null)},[o,A]);const R=m.useCallback(async(I="initial")=>{const U=++T.current;!(C.current.length>0)&&I!=="background"?(h(!0),y(null)):g(!0);try{const V=await me("/api/activity");if(U!==T.current)return;r(V),y(null),w(Date.now()),c(Z=>V.some(O=>O.id===Z)?Z:null)}catch(V){if(U!==T.current)return;y(V instanceof Error?V.message:String(V))}finally{U===T.current&&(h(!1),g(!1))}},[]),_=m.useCallback(()=>{E.current||(E.current=setTimeout(()=>{E.current=null,R("background")},250))},[R]);m.useEffect(()=>(R("initial"),()=>{E.current&&clearTimeout(E.current)}),[R]),tn(_);const P=m.useMemo(()=>{const I=new Set(A.map(D=>D.actorName??"system")),U=new Set(A.map(D=>D.conversationId).filter(D=>!!D));return[{label:"Events",value:`${A.length}`,detail:A.length>0?`Latest ${Ae(A[0].ts)}`:"Waiting for records"},{label:"Actors",value:`${I.size}`,detail:I.size>0?"Distinct event owners":"No actors yet"},{label:"Threads",value:`${U.size}`,detail:U.size>0?"Conversation-linked records":"No linked threads"}]},[A]),$=!u&&A.length===0&&!!v,H=!u&&A.length===0&&!v;return s.jsxs("div",{className:"sys-surface-page",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Activity"}),s.jsx("p",{className:"sys-page-subtitle",children:"Broker events, task execution, and collaboration handoffs."})]}),s.jsxs("div",{className:"sys-page-actions",children:[s.jsx("div",{className:"sys-sync-note",children:u?"Loading audit ledger...":v&&A.length>0?`Showing last confirmed snapshot from ${x?Ae(x):"earlier"}`:x?`Updated ${Ae(x)}`:"Waiting for first snapshot"}),s.jsx("button",{type:"button",className:"s-btn",disabled:u||f,onClick:()=>{R("manual")},children:f?"Refreshing...":"Refresh"})]})]}),s.jsx("div",{className:"sys-stat-grid",children:P.map(I=>s.jsxs("div",{className:"sys-stat-card",children:[s.jsx("span",{className:"sys-stat-label",children:I.label}),s.jsx("strong",{className:"sys-stat-value",children:I.value}),s.jsx("span",{className:"sys-stat-detail",children:I.detail})]},I.label))}),v&&A.length>0&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Refresh failed."}),s.jsx("span",{children:v})]}),u&&A.length===0&&s.jsx(sa,{title:"Loading activity",body:"Pulling the latest records from the broker database."}),$&&s.jsx(sa,{className:"sys-state-card-error",title:"Activity is unavailable",body:v,action:s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{R("manual")},children:"Try again"})}),H&&s.jsx(sa,{title:"No activity yet",body:"Events appear here after agents register, send messages, or advance work."}),A.length>0&&s.jsx("div",{className:"sys-audit-list",children:A.map(I=>{const U=o===I.id,D=zne(I.kind),V=Lne[D],Z=Une(I.workspaceRoot),O=I.summary&&I.summary!==I.title?I.summary:Vne(I),z=[];if(I.conversationId&&z.push({key:"thread",label:"Thread",title:`Open thread ${Mo(I.conversationId)}`,route:{view:"conversation",conversationId:I.conversationId}}),I.recordId&&z.push({key:"work",label:"Work",title:"Open work item",route:{view:"work",workId:I.recordId}}),I.agentId){const X=I.agentName??"Agent";z.push({key:"agent",label:X,title:`Open agent ${X}`,route:{view:"agents",agentId:I.agentId}})}I.sessionId&&z.push({key:"session",label:"Session",title:"Open session",route:{view:"sessions",sessionId:I.sessionId}}),(I.flightId||I.invocationId)&&z.push({key:"follow",label:"Follow",title:"Follow live execution",route:{view:"follow",...I.flightId?{flightId:I.flightId}:{},...I.invocationId?{invocationId:I.invocationId}:{},...I.conversationId?{conversationId:I.conversationId}:{}}});const B=()=>c(U?null:I.id);return s.jsxs("article",{className:`sys-audit-entry${U?" sys-audit-entry-expanded":""}`,onContextMenu:X=>{const W=window.getSelection()?.toString().trim(),L=[];W&&(L.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>{On(W)}}),L.push({kind:"separator"}));const q=I.title??I.summary??"";if(q&&L.push({kind:"action",label:"Copy Details",onSelect:()=>{On(q)}}),I.actorName&&L.push({kind:"action",label:"Copy Actor",onSelect:()=>{On(I.actorName)}}),L.push({kind:"action",label:"Copy Event ID",onSelect:()=>{On(I.id)}}),z.length>0){L.push({kind:"separator"});for(const K of z)L.push({kind:"action",label:`Open ${K.label}`,onSelect:()=>e(K.route)})}S(X,L)},children:[s.jsxs("div",{className:"sys-audit-toggle",role:"button",tabIndex:0,"aria-expanded":U,onClick:B,onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),B())},children:[s.jsxs("div",{className:"sys-audit-stamp",children:[s.jsx("span",{className:"sys-audit-time",children:Ae(I.ts)}),s.jsx("span",{className:"sys-audit-date",children:Wa(I.ts)})]}),s.jsx("div",{className:`sys-audit-marker sys-audit-marker-${V.tone}`,children:s.jsx("span",{})}),s.jsxs("div",{className:"sys-audit-body",children:[s.jsxs("div",{className:"sys-audit-topline",children:[s.jsx("span",{className:"sys-audit-category",children:V.label}),s.jsx("span",{className:"sys-audit-kind",children:X$(I.kind)})]}),s.jsx("h3",{className:"sys-audit-title",children:Ca(I.title??Fne(I))}),s.jsx("p",{className:"sys-audit-summary",children:Ca(O)}),s.jsxs("div",{className:"sys-audit-meta",children:[s.jsxs("span",{className:"sys-audit-meta-item",children:[s.jsx("span",{className:"sys-audit-avatar",style:{background:qt(I.actorName??"system")},children:Bne(I.actorName)}),I.actorName??"system"]}),Z&&s.jsxs("span",{className:"sys-audit-meta-item",children:["Workspace ",Z]})]}),z.length>0&&s.jsxs("div",{className:"sys-audit-jumps",children:[s.jsx("span",{className:"sys-audit-jumps-label",children:"Open"}),z.map(X=>s.jsx("button",{type:"button",className:"sys-audit-jump",title:X.title,onClick:W=>{W.stopPropagation(),e(X.route)},children:X.label},X.key))]})]}),s.jsx("div",{className:"sys-audit-expand",children:U?"Close":"Details"})]}),U&&s.jsxs("div",{className:"sys-audit-details",children:[s.jsxs("div",{className:"sys-detail-grid",children:[s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Event"}),s.jsx("code",{className:"sys-detail-value",children:I.kind})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Recorded"}),s.jsx("span",{className:"sys-detail-value",children:Wa(I.ts)})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Actor"}),s.jsx("span",{className:"sys-detail-value",children:I.actorName??"system"})]}),I.agentName&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Agent"}),s.jsx("span",{className:"sys-detail-value",children:I.agentName})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Workspace"}),s.jsx("span",{className:"sys-detail-value",children:I.workspaceRoot??"Not attached"})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Thread"}),s.jsx("span",{className:"sys-detail-value",children:I.conversationId?Mo(I.conversationId):"Not attached"})]}),I.recordId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Work"}),s.jsx("span",{className:"sys-detail-value",children:Mo(I.recordId)})]}),I.sessionId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Session"}),s.jsx("span",{className:"sys-detail-value",children:Mo(I.sessionId)})]}),I.flightId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Flight"}),s.jsx("span",{className:"sys-detail-value",children:Mo(I.flightId)})]}),I.invocationId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Invocation"}),s.jsx("span",{className:"sys-detail-value",children:Mo(I.invocationId)})]}),s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Record id"}),s.jsx("code",{className:"sys-detail-value",children:I.id})]})]}),z.length>0&&s.jsx("div",{className:"sys-inline-actions",children:z.map(X=>s.jsxs("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>e(X.route),children:["Open ",X.label]},X.key))})]})]},I.id)})})]})}function br(e){const t=e?.trim();if(!t)return null;const[n]=t.split(".");return n?.trim()||t}function Q$(e){const t=e.handle?.trim().replace(/^@+/,"");if(t)return`@${t}`;const n=e.selector?.trim();if(n)return n;const a=br(e.id);return a?`@${a}`:null}function J$(e){return e.name?.trim()||e.agentName?.trim()||br(e.id)||e.title?.trim()||"Conversation"}function gx(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}const qne="openscout.navReturn.v1.",pp=new Map;function qw(e){return qne+e}function Wne(e){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.view=="string")return t}catch{}return null}function eP(e,t){if(pp.set(e,t),!(typeof window>"u"))try{window.sessionStorage.setItem(qw(e),JSON.stringify(t))}catch{}}function Gne(e){const t=pp.get(e);if(t)return t;if(typeof window>"u")return null;try{const n=window.sessionStorage.getItem(qw(e));if(n){const a=Wne(n);return a&&pp.set(e,a),a}}catch{}return null}function Zne(e){if(pp.delete(e),!(typeof window>"u"))try{window.sessionStorage.removeItem(qw(e))}catch{}}const Kne={agents:"agents",conversation:"conversation",work:"work",terminal:"terminal",sessions:"sessions","agent-info":"agent-info",channels:"channels"};function Yne(e){return Kne[e.view]??null}function kt(e,t,n={}){if(n.returnTo){const a=Yne(t);a&&eP(a,n.returnTo)}e(t)}function Xne(e){switch(e.view){case"mesh":return"Back to mesh";case"ops":return"Back to ops";case"agents":return e.agentId?"Back to agent":"All agents";case"messages":return"Back to messages";case"conversation":return"Back to conversation";case"inbox":return"Back to inbox";case"sessions":return"Back to sessions";case"channels":return"Back to channels";case"fleet":return"Back to fleet";case"work":return"Back to work";case"broker":return"Back to broker";case"activity":return"Back to activity";default:return"Back"}}function Ga({slot:e,fallback:t,navigate:n,className:a,label:r}){const c=m.useMemo(()=>Gne(e),[e])??t,u=r??Xne(c);return s.jsxs("button",{type:"button",className:`s-back-pill${a?` ${a}`:""}`,onClick:()=>{Zne(e),n(c)},children:[s.jsx("span",{"aria-hidden":!0,className:"s-back-pill-glyph",children:"←"}),s.jsx("span",{children:u})]})}function Qne({values:e}){return s.jsx("span",{className:"s-agent-token-list",children:e.map(t=>s.jsx("span",{className:"s-agent-token",children:t},t))})}function Ys({value:e}){return s.jsx("span",{className:"s-agent-code-value",children:e})}function Pu({title:e,items:t}){return t.length===0?null:s.jsxs("section",{className:"s-agent-profile-card",children:[s.jsx("div",{className:"s-agent-profile-card-header",children:s.jsx("div",{className:"s-agent-profile-card-title",children:e})}),s.jsx("div",{className:"s-agent-meta-card-body",children:t.map(n=>s.jsxs("div",{className:"s-agent-meta-row",children:[s.jsx("span",{className:"s-agent-meta-label",children:n.label}),s.jsx("span",{className:"s-agent-meta-value",children:n.value})]},n.label))})]})}function Jne({conversationId:e,navigate:t}){const{agents:n,route:a}=qe(),[r,o]=m.useState(null),[c,u]=m.useState(null),[h,f]=m.useState(null),g=Ow(e),v=m.useCallback(async()=>{f(null);try{const P=await me(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);o(P)}catch(P){f(P instanceof Error?P.message:String(P)),o(null)}},[e]);m.useEffect(()=>{v()},[v]),tn(()=>{v()});const y=r?.agentId??g;m.useEffect(()=>{if(!y||n.some($=>$.id===y)){u(null);return}let P=!1;return me(`/api/agents/${encodeURIComponent(y)}`).then($=>{P||u($)}).catch(()=>{P||u(null)}),()=>{P=!0}},[n,y]);const x=m.useMemo(()=>y?n.find(P=>P.id===y)??(c?.id===y?c:null):null,[c,n,y]);if(!x)return s.jsxs("div",{children:[s.jsx(Ga,{slot:"agent-info",fallback:{view:"conversation",conversationId:e},navigate:t}),h&&s.jsx("p",{className:"s-error",children:h}),s.jsx("div",{className:"s-empty",children:s.jsx("p",{children:"Agent not found"})})]});const w=Q$(x),C=x.handle?`@${x.handle.replace(/^@+/,"")}`:null,T=x.selector??x.defaultSelector??C,E=x.authorityNodeName?`${x.authorityNodeName} (${x.authorityNodeId??"unknown"})`:x.authorityNodeId,S=x.homeNodeName?`${x.homeNodeName} (${x.homeNodeId??"unknown"})`:x.homeNodeId,k=[{label:"Fully qualified ID",value:s.jsx(Ys,{value:x.id})},{label:"Definition",value:s.jsx(Ys,{value:x.definitionId})},...C?[{label:"Handle",value:s.jsx(Ys,{value:C})}]:[],...x.selector?[{label:"Selector",value:s.jsx(Ys,{value:x.selector})}]:[],...x.defaultSelector&&x.defaultSelector!==x.selector?[{label:"Default selector",value:s.jsx(Ys,{value:x.defaultSelector})}]:[],...x.workspaceQualifier?[{label:"Workspace qualifier",value:s.jsx(Ys,{value:x.workspaceQualifier})}]:[],...x.nodeQualifier?[{label:"Node qualifier",value:s.jsx(Ys,{value:x.nodeQualifier})}]:[],{label:"Class",value:gx(x.agentClass)??"—"},...x.role?[{label:"Role",value:x.role}]:[],...x.staleLocalRegistration?[{label:"Registration",value:x.replacedByAgentId?`Stale hint, superseded by ${x.replacedByAgentId}`:"Stale hint"}]:[],...x.retiredFromFleet?[{label:"Fleet state",value:"Retired"}]:[]],N=[...E?[{label:"Authority node",value:s.jsx(Ys,{value:E})}]:[],...S?[{label:"Home node",value:s.jsx(Ys,{value:S})}]:[],...x.ownerId?[{label:"Owner",value:x.ownerName?`${x.ownerName} (${x.ownerId})`:x.ownerId}]:[],...x.conversationId?[{label:"Direct conversation",value:s.jsx(Ys,{value:x.conversationId})}]:[]],A=[...x.project?[{label:"Project",value:x.project}]:[],...x.branch?[{label:"Branch",value:x.branch}]:[],...x.projectRoot?[{label:"Path",value:x.projectRoot}]:[],...x.cwd?[{label:"Working dir",value:x.cwd}]:[]],R=[...x.harness?[{label:"Harness",value:x.harness}]:[],...x.model?[{label:"Model",value:x.model}]:[],...x.transport?[{label:"Transport",value:gx(x.transport)??x.transport}]:[],...x.wakePolicy?[{label:"Wake policy",value:gx(x.wakePolicy)??x.wakePolicy}]:[],...x.capabilities.length>0?[{label:"Capabilities",value:s.jsx(Qne,{values:x.capabilities})}]:[]],_=[{label:"Thread ID",value:e},...r?.workspaceRoot?[{label:"Workspace",value:r.workspaceRoot}]:[],...r?.currentBranch?[{label:"Session branch",value:r.currentBranch}]:[],...r?.messageCount!=null?[{label:"Messages",value:String(r.messageCount)}]:[],...r?.lastMessageAt?[{label:"Last message",value:Wa(r.lastMessageAt)}]:[],...x.harnessSessionId?[{label:"Harness session",value:x.harnessSessionId}]:[],...x.harnessLogPath?[{label:"Harness log",value:x.harnessLogPath}]:[]];return s.jsxs("div",{className:"s-agent-profile-page",children:[s.jsxs("div",{className:"s-agent-profile-page-topbar",children:[s.jsx(Ga,{slot:"agent-info",fallback:{view:"conversation",conversationId:e},navigate:t}),s.jsx("button",{type:"button",className:"s-btn",onClick:()=>t({view:"agents",agentId:x.id}),children:"Open in Agents"})]}),h&&s.jsx("p",{className:"s-error",children:h}),s.jsxs("section",{className:"s-agent-profile-hero",children:[s.jsx("div",{className:"s-agent-profile-hero-main",children:s.jsxs("div",{className:"s-agent-profile-hero-title-row",children:[s.jsx("div",{className:"s-avatar s-agent-profile-hero-avatar",style:{background:qt(x.name)},children:x.name[0].toUpperCase()}),s.jsxs("div",{className:"s-agent-profile-hero-copy",children:[s.jsxs("div",{className:"s-agent-casefile-title-meta",children:[s.jsx("span",{className:"s-agent-casefile-record",children:T??w??br(x.id)??x.id}),s.jsxs("span",{className:`s-agent-state-chip s-agent-state-chip-${Je(x.state)}`,children:[s.jsx("span",{className:"s-dot",style:{background:Pn(x.state)}}),ia(x.state)]}),x.staleLocalRegistration&&s.jsx("span",{className:"s-agent-state-chip s-agent-state-chip-offline",children:"Stale hint"})]}),s.jsx("h1",{className:"s-agent-profile-hero-title",children:x.name}),s.jsxs("div",{className:"s-agent-profile-hero-tags",children:[s.jsx(Ys,{value:x.id}),x.selector&&s.jsx(Ys,{value:x.selector}),x.defaultSelector&&x.defaultSelector!==x.selector&&s.jsx(Ys,{value:x.defaultSelector})]}),s.jsxs("p",{className:"s-agent-profile-hero-context",children:[r?.title?`Conversation: ${r.title}.`:"Attached to the current conversation.",x.updatedAt?` Updated ${Ae(x.updatedAt)}.`:""]})]})]})}),s.jsx("div",{className:"s-agent-profile-hero-actions",children:s.jsx("button",{type:"button",className:"s-btn s-btn-primary",onClick:()=>kt(t,{view:"conversation",conversationId:e},{returnTo:a}),children:"Open conversation"})})]}),s.jsxs("div",{className:"s-agent-profile-grid",children:[s.jsx(Pu,{title:"Identity",items:k}),s.jsx(Pu,{title:"Topology",items:N}),s.jsx(Pu,{title:"Workspace",items:A}),s.jsx(Pu,{title:"Runtime",items:R}),s.jsx(Pu,{title:"Conversation context",items:_})]})]})}function ese(e){switch(e){case"success":return"completed";case"danger":return"failed";case"working":return"working";default:return"updated"}}function tP(e){return e.attention==="interrupt"?"danger":e.state==="done"?"success":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"warning":"working"}function tse(e){return e.attention==="interrupt"?"danger":"warning"}function nse(e,t){return e==="success"||t==="sent"||t==="acknowledged"||t==="completed"?"success":e==="failed_query"||e==="failed_delivery"||t==="failed"||t==="cancelled"?"danger":t==="running"||t==="accepted"||t==="deferred"||t==="pending"?"working":"neutral"}function sse(e){return e?e.status==="paired"||e.status==="connected"?"success":e.status==="error"||e.status==="closed"?"danger":"warning":"warning"}function Wr({tone:e,children:t,variant:n="chip",className:a,title:r}){const o=n==="pill"?"s-pill":"sys-chip",c=n==="pill"?`s-pill-${ese(e)}`:`sys-chip-${e}`,u=a?`${o} ${c} ${a}`:`${o} ${c}`;return s.jsx("span",{className:u,title:r,children:t})}function ase(e){switch(e){case"review":return"In review";case"waiting":return"Waiting";case"working":return"Working";case"done":return"Done";default:return e.replace(/_/g," ")}}function rse(e){switch(e){case"badge":return"Noteworthy";case"interrupt":return"Blocked signal";default:return null}}function BA({items:e,navigate:t,emptyTitle:n,emptyDetail:a}){const{route:r}=qe();if(e.length===0){const o=[{titleWidth:"56%",metaWidths:["18%","14%","16%"],summaryWidth:"74%"},{titleWidth:"48%",metaWidths:["16%","20%","12%"],summaryWidth:"62%"}];return s.jsxs("div",{className:"s-work-empty-state",children:[s.jsxs("div",{className:"s-work-empty-copy",children:[s.jsx("p",{className:"s-work-empty-kicker",children:"Quiet for now"}),s.jsx("p",{className:"s-work-empty-title",children:n}),a&&s.jsx("p",{className:"s-work-empty-detail",children:a})]}),s.jsx("div",{className:"s-work-empty-skeleton","aria-hidden":"true",children:o.map((c,u)=>s.jsxs("div",{className:"s-work-empty-row",children:[s.jsxs("div",{className:"s-work-empty-row-header",children:[s.jsx("span",{className:"s-work-empty-line s-work-empty-line-title",style:{width:c.titleWidth}}),s.jsx("span",{className:"s-work-empty-pill"})]}),s.jsx("div",{className:"s-work-empty-row-meta",children:c.metaWidths.map(h=>s.jsx("span",{className:"s-work-empty-line s-work-empty-line-meta",style:{width:h}},h))}),s.jsx("span",{className:"s-work-empty-line s-work-empty-line-summary",style:{width:c.summaryWidth}})]},u))})]})}return s.jsx("div",{className:"s-work-list",children:e.map(o=>{const c=!!o.id||!!o.conversationId,u=rse(o.attention),h=o.ownerName??o.ownerId??"Unassigned",f=o.id?()=>kt(t,{view:"work",workId:o.id},{returnTo:r}):o.conversationId?()=>kt(t,{view:"conversation",conversationId:o.conversationId},{returnTo:r}):void 0;return s.jsxs("div",{className:`s-work-row${c?" s-work-row-clickable":""}`,onClick:f,children:[s.jsxs("div",{className:"s-work-row-header",children:[s.jsxs("div",{className:"s-work-row-title-wrap",children:[s.jsx("span",{className:"s-work-row-title",children:o.title}),o.priority&&s.jsx("span",{className:"s-badge",children:o.priority})]}),s.jsx(Wr,{tone:tP(o),variant:"pill",children:o.currentPhase})]}),s.jsxs("div",{className:"s-work-row-meta",children:[s.jsx("span",{children:h}),s.jsx("span",{children:ase(o.state)}),o.activeChildWorkCount>0&&s.jsxs("span",{children:[o.activeChildWorkCount," child",o.activeChildWorkCount===1?"":"ren"]}),o.activeFlightCount>0&&s.jsxs("span",{children:[o.activeFlightCount," flight",o.activeFlightCount===1?"":"s"]}),u&&s.jsx("span",{children:u}),s.jsx("span",{children:Ae(o.lastMeaningfulAt)})]}),o.lastMeaningfulSummary&&s.jsx("p",{className:"s-work-row-summary",children:Ca(o.lastMeaningfulSummary)})]},o.id)})})}async function Rm(e){await me("/api/operator-attention/dismiss",{method:"POST",body:JSON.stringify(e)})}const Ww="/api",ise=`${Ww}/health`,ose=`${Ww}/terminal/run`,lse=`${Ww}/vantage/open`,nP="/ws/terminal",cse=`${nP}/health`,use="/ws/hmr";function dse(e,t){if(typeof e!="string")return t;const n=e.trim();return n&&`${n.startsWith("/")?"":"/"}${n}`.replace(/\/{2,}/g,"/").replace(/\/+$/g,"")||t}const fse={healthPath:ise,terminalRunPath:ose,vantageOpenPath:lse,terminalRelayPath:nP,terminalRelayHealthPath:cse,viteHmrPath:use};function sP(){return typeof window>"u"?null:window.__OPENSCOUT_WEB_BOOTSTRAP__??null}function hse(){const e=sP()?.theme;return typeof e=="string"?e:null}function cg(e){return dse(sP()?.routes?.[e],fse[e])}function aP(){const e=cg("terminalRelayPath");return typeof window>"u"?`ws://localhost:3200${e}`:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${e}`}function rP(){const e=cg("terminalRelayHealthPath");return typeof window>"u"?`http://localhost:3200${e}`:`${window.location.protocol}//${window.location.host}${e}`}async function ef(e){if(mse(e.agentId),!(await fetch(cg("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e.command,...e.cwd?{cwd:e.cwd}:{},...e.agentId?{agentId:e.agentId}:{}})})).ok)throw new Error("Failed to queue takeover")}function mse(e){if(!(typeof window>"u"))try{window.localStorage.removeItem("hudson.relay.scout-takeover"),e&&window.localStorage.removeItem(`hudson.relay.scout-takeover-${e}`)}catch{}}const UA=48,FA=720;function pse(e){if(!e||typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n||typeof n!="object")return null;const a={};for(const[r,o]of Object.entries(n))typeof o=="number"&&Number.isFinite(o)&&o>0&&(a[r]=o);return a}catch{return null}}function vx(e,t){if(e&&!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function gse({storageKey:e,columns:t}){const n=m.useMemo(()=>{const y=pse(e)??{},x={};for(const w of t)x[w.key]=y[w.key]??w.defaultWidth;return x},[e,t]),[a,r]=m.useState(n);m.useEffect(()=>{r(y=>{let x=!1;const w={...y};for(const C of t)w[C.key]==null&&(w[C.key]=C.defaultWidth,x=!0);return x?w:y})},[t]);const o=m.useMemo(()=>{const y=new Map;for(const x of t)y.set(x.key,x);return y},[t]),c=m.useRef(null),u=m.useCallback(y=>{const x=c.current;if(!x)return;const w=y.clientX-x.startX,C=Math.min(x.max,Math.max(x.min,x.startWidth+w));r(T=>T[x.key]===C?T:{...T,[x.key]:C})},[]),h=m.useCallback(()=>{c.current&&(c.current=null,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),r(y=>(vx(e,y),y)))},[u,e]);m.useEffect(()=>()=>{window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)},[u,h]);const f=m.useCallback(y=>{const x=a[y],w=o.get(y),C=w?.minWidth??UA,T=w?.maxWidth??FA;return{style:{width:x,minWidth:C,maxWidth:T},"data-resize-key":y}},[a,o]),g=m.useCallback(y=>({onPointerDown:T=>{if(T.button!==0)return;T.preventDefault(),T.stopPropagation();const E=o.get(y),S=E?.minWidth??UA,k=E?.maxWidth??FA,N=a[y]??E?.defaultWidth??S;c.current={key:y,startX:T.clientX,startWidth:N,min:S,max:k},document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",u),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h)},onClick:T=>{T.stopPropagation()},onDoubleClick:T=>{T.preventDefault(),T.stopPropagation();const E=o.get(y);E&&r(S=>{const k={...S,[y]:E.defaultWidth};return vx(e,k),k})},role:"separator","aria-orientation":"vertical","aria-label":"Resize column",className:"s-resize-handle"}),[a,o,u,h,e]),v=m.useCallback(()=>{r(()=>{const y={};for(const x of t)y[x.key]=x.defaultWidth;return vx(e,y),y})},[t,e]);return{widths:a,getColumnProps:f,getResizeHandleProps:g,resetAll:v}}function vse(e){return e==="number"||e==="time"?"right":"left"}function VA(e){return e==="number"||e==="time"?-1:1}function iP(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?String(e):Array.isArray(e)?e.map(t=>iP(t)).join(""):""}function HA(e,t){if(e.sortValue)return e.sortValue(t);const n=e.render(t),a=iP(n).trim();return a||null}function qA(e){if(typeof e=="number")return e;const t=Date.parse(e);return Number.isFinite(t)?t:Number.NaN}function yse(e,t,n,a){const r=HA(n,e),o=HA(n,t);return r==null&&o==null?0:r==null?1:o==null?-1:n.kind==="number"?((Number(r)||0)-(Number(o)||0))*a:n.kind==="time"?(qA(r)-qA(o))*a:String(r).localeCompare(String(o),void 0,{numeric:!0,sensitivity:"base"})*a}function xse(e,t){return n=>{typeof e=="function"&&e(n),n.defaultPrevented||t?.(n)}}function bse(e,t){return n=>{typeof e=="function"&&e(n),n.defaultPrevented||t?.(n)}}function ug({rows:e,columns:t,rowId:n,storageKey:a,initialSort:r,sort:o,onSortChange:c,secondarySort:u,onRowClick:h,rowBindings:f,rowState:g,empty:v={title:"No rows"},rowClassName:y,density:x="comfortable",className:w,ariaLabel:C="Data table"}){const T=m.useMemo(()=>t.map($=>{const H=$.kind??"text";return{...$,kind:H,align:$.align??vse(H),sortable:$.sortable??H!=="custom",resizable:$.resizable??!0}}),[t]),E=m.useMemo(()=>new Map(T.map($=>[$.key,$])),[T]),[S,k]=m.useState(()=>{if(!r)return null;const H=t.find(I=>I.key===r.key)?.kind??"text";return{key:r.key,dir:r.dir??VA(H)}}),N=o??S,{getColumnProps:A,getResizeHandleProps:R}=gse({storageKey:a,columns:T.map($=>({key:$.key,defaultWidth:$.defaultWidth,minWidth:$.minWidth,maxWidth:$.maxWidth}))}),_=m.useMemo(()=>{const $=e.map((I,U)=>({row:I,index:U}));if(!N)return $.map(I=>I.row);const H=E.get(N.key);return H?.sortable?$.slice().sort((I,U)=>{const D=yse(I.row,U.row,H,N.dir);if(D!==0)return D;const V=u?.(I.row,U.row)??0;return V!==0?V:I.index-U.index}).map(I=>I.row):$.map(I=>I.row)},[e,N,E,u]),P=$=>{o==null&&k($),c?.($)};return s.jsx("div",{className:`dt-wrap dt-wrap--${x}${w?` ${w}`:""}`,children:s.jsxs("table",{className:"dt-table","aria-label":C,children:[s.jsx("thead",{children:s.jsx("tr",{children:T.map($=>{const H=N?.key===$.key,I=H?N.dir===1?"ascending":"descending":"none",U=["dt-th",`dt-align-${$.align}`,$.cls,H?"dt-th--sorted":""].filter(Boolean).join(" ");return s.jsxs("th",{className:U,title:$.tip,"aria-sort":I,...A($.key),children:[$.sortable?s.jsxs("button",{type:"button",className:"dt-th-sort",onClick:()=>{if(N?.key===$.key){P({key:$.key,dir:N.dir===1?-1:1});return}P({key:$.key,dir:VA($.kind)})},children:[s.jsx("span",{className:"dt-th-label",children:$.label}),s.jsx("span",{className:`dt-th-arrow${H?" dt-th-arrow--active":""}`,"aria-hidden":"true",children:H?N?.dir===1?"↑":"↓":"↕"})]}):s.jsx("div",{className:"dt-th-static",children:s.jsx("span",{className:"dt-th-label",children:$.label})}),$.resizable?s.jsx("span",{...R($.key)}):null]},$.key)})})}),s.jsx("tbody",{children:_.length===0?s.jsx("tr",{className:"dt-empty-row",children:s.jsx("td",{colSpan:T.length,children:s.jsxs("div",{className:"dt-empty",children:[s.jsx("div",{className:"dt-empty-title",children:v.title}),v.body?s.jsx("div",{children:v.body}):null]})})}):_.map($=>{const H=n($),I=f?.(H)??{},U=g?.(H)??{isActive:!1,isPinned:!1},D=!!(h||f),V=["dt-row",D?"dt-row--interactive":"",U.isActive?"dt-row--active":"",U.isPinned?"dt-row--pinned":"",y?.($),typeof I.className=="string"?I.className:""].filter(Boolean).join(" "),Z=h?()=>h($):void 0,O=D?bse(I.onKeyDown,B=>{h&&(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),h($))}):typeof I.onKeyDown=="function"?I.onKeyDown:void 0,z={...I,className:V,onClick:xse(I.onClick,Z),onKeyDown:O};return D&&z.tabIndex==null&&(z.tabIndex=0),s.jsx("tr",{...z,children:T.map(B=>s.jsx("td",{className:["dt-td",`dt-align-${B.align}`,B.cls].filter(Boolean).join(" "),children:B.render($)},B.key))},H)})})]})})}function wse(e){const t=e?.trim();return t?t.replace(/^handoff-/,"").slice(0,18):null}function oP(e){const t=e.plan.manifest.workspaceID?.trim(),n=wse(e.plan.manifest.handoffId??e.handoffId);return[t,n].filter(Boolean).join(" · ")}async function lP(e={}){return await me(cg("vantageOpenPath"),{method:"POST",body:JSON.stringify({agentId:e.agentId??null,agentIds:e.agentIds??[],nativeSessionIds:e.nativeSessionIds??[],launch:e.launch??!0})})}function dg({agentId:e,agentIds:t,nativeSessionIds:n,className:a,statusClassName:r,label:o="Vantage",openingLabel:c="Opening",title:u="Open this session context in the native Vantage canvas",disabled:h=!1}){const[f,g]=m.useState({state:"idle"}),v=()=>{g({state:"opening"}),lP({agentId:e??null,agentIds:t,nativeSessionIds:n,launch:!0}).then(y=>{const x=y.plan.manifest.nodes.length,w=oP(y);if(x===0){const T=y.plan.diagnostics.find(E=>E.severity==="warning")??y.plan.diagnostics[0];g({state:"failed",error:T?`${w} · no windows: ${T.message}`:`${w} · no Vantage windows.`});return}if(!y.launch.ok&&y.launch.error){g({state:"failed",error:y.launch.error});return}const C=y.launch.ok?"launch requested":"handoff written";g({state:"opened",detail:`${w} · ${x} node${x===1?"":"s"} · ${C}`})}).catch(y=>{g({state:"failed",error:y instanceof Error?y.message:String(y)})})};return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:a,onClick:v,disabled:h||f.state==="opening",title:u,children:f.state==="opening"?c:o}),f.state==="opened"&&r&&s.jsx("span",{className:`${r} ${r}--ok`,children:f.detail}),f.state==="failed"&&r&&s.jsx("span",{className:`${r} ${r}--error`,children:f.error})]})}function cP(e,t){const n=zt(e),a=zt(t);if(n===null||a===null)return!1;const r=new Date(n),o=new Date(a);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()&&r.getDate()===o.getDate()}function qb(e){const t=zt(e);if(t===null)return"";const n=new Date(t),a=new Date,r=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),o=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),c=1440*60*1e3;return o===r?"Today":o===r-c?"Yesterday":new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(t)}const jse=30*6e4;function Nse(e){return e.kind==="direct"}function Uo(e){return e.kind==="channel"||e.kind==="group_direct"||e.id.startsWith("channel.")}function Ha(e){return e.title&&e.title!==e.id?e.title:e.id.startsWith("channel.")?e.id.replace(/^channel\./,""):e.agentName??e.id}function uP(e){return e.id.startsWith("channel.")?e.id.replace(/^channel\./,""):Ha(e)}const dP=new Set(["completed","failed","cancelled"]);function Bc(e){return!!(e&&!dP.has(e.state))}function kse(e){return Bc(e)&&!fP(e)}function fP(e){return!!(e?.summary?.includes("Scout stopped waiting for a synchronous result")||e?.summary?.includes("the requester stopped waiting after"))}function hP(e,t=Date.now(),n=jse){if(!Bc(e))return!1;const a=zt(e?.startedAt);return a!==null&&t-a>n}function Sse(e,t,n=Date.now()){if(!hP(e,n))return!1;const a=zt(e?.startedAt),r=zt(t);return a!==null&&r!==null&&r>a}function Cse(e){return!Bc(e)}const Wb=/^```([a-z0-9_-]+)?\s*$/iu,mP=/^(#{1,6})\s+(.+)$/u,Ese=/^(?:-{3,}|\*{3,}|_{3,})$/u,Ase=/^\s*[-*]\s+(.+)$/u,Tse=/^\s*\d+[.)]\s+(.+)$/u,Mse=/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?$/u;function Rse(e){const t=e.replace(/\r\n?/gu,`
147
+ `).trim();return t?t.replace(/([^\n])\s+---\s+(?=(?:#{1,6}\s|\*\*|[A-Z0-9]))/gu,`$1
148
+
149
+ ---
150
+
151
+ `).replace(/([^\n])\s+(#{1,6}\s+)/gu,`$1
152
+
153
+ $2`).replace(/\n{3,}/gu,`
154
+
155
+ `):""}function pP(e){return e.trim().length===0}function Ise(e){return mP.test(e.trim())}function gP(e){return Ese.test(e.trim())}function Gb(e){return e.match(Ase)?.[1]?.trim()??null}function Zb(e){return e.match(Tse)?.[1]?.trim()??null}function _se(e){return Gb(e)!==null||Zb(e)!==null}function WA(e){return e.trim().replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(n=>n.trim())}function vP(e,t){const n=e[t]?.trim(),a=e[t+1]?.trim();return!!(n&&a&&n.includes("|")&&Mse.test(a))}function Ose(e,t){const n=e[t]??"",a=n.trim();return!!(pP(n)||Wb.test(a)||Ise(n)||gP(n)||_se(n)||a.startsWith(">")||vP(e,t))}function $se(e){const t=Rse(e);if(!t)return[];const n=t.split(`
156
+ `),a=[];let r=0;for(;r<n.length;){const o=n[r]??"",c=o.trim();if(!c){r+=1;continue}const u=c.match(Wb);if(u){const y=[];for(r+=1;r<n.length&&!Wb.test(n[r].trim());)y.push(n[r]),r+=1;r<n.length&&(r+=1),a.push({type:"code",language:u[1]??null,text:y.join(`
157
+ `)});continue}if(gP(o)){a.push({type:"hr"}),r+=1;continue}const h=c.match(mP);if(h){a.push({type:"heading",depth:h[1].length,text:h[2].trim()}),r+=1;continue}if(vP(n,r)){const y=WA(n[r]);r+=2;const x=[];for(;r<n.length&&n[r].includes("|")&&!pP(n[r]);)x.push(WA(n[r])),r+=1;a.push({type:"table",headers:y,rows:x});continue}const f=Gb(o),g=Zb(o);if(f!==null||g!==null){const y=g!==null,x=[];for(;r<n.length;){const w=y?Zb(n[r]):Gb(n[r]);if(w===null)break;x.push(w),r+=1}a.push({type:"list",ordered:y,items:x});continue}if(c.startsWith(">")){const y=[];for(;r<n.length&&n[r].trim().startsWith(">");)y.push(n[r].trim().replace(/^>\s?/u,"")),r+=1;a.push({type:"blockquote",text:y.join(`
158
+ `).trim()});continue}const v=[];for(;r<n.length&&!Ose(n,r);)v.push(n[r].trimEnd()),r+=1;a.push({type:"paragraph",text:v.join(`
159
+ `).trim()})}return a}function Pse(e,t){const n=Math.min(6,Math.max(2,e.depth+1));return s.jsx("div",{role:"heading","aria-level":n,className:`s-message-markup-heading s-message-markup-heading-${e.depth}`,children:Ca(e.text)},t)}function Dse(e,t){return s.jsx("div",{className:"s-message-markup-table-wrap",children:s.jsxs("table",{className:"s-message-markup-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.headers.map((n,a)=>s.jsx("th",{children:Ca(n)},`${t}:h:${a}`))})}),s.jsx("tbody",{children:e.rows.map((n,a)=>s.jsx("tr",{children:e.headers.map((r,o)=>s.jsx("td",{children:Ca(n[o]??"")},`${t}:c:${a}:${o}`))},`${t}:r:${a}`))})]})},t)}function Lse(e,t){switch(e.type){case"paragraph":return s.jsx("p",{className:"s-message-markup-paragraph",children:Ca(e.text)},t);case"heading":return Pse(e,t);case"hr":return s.jsx("hr",{className:"s-message-markup-rule"},t);case"list":return e.ordered?s.jsx("ol",{className:"s-message-markup-list",children:e.items.map((n,a)=>s.jsx("li",{children:Ca(n)},`${t}:${a}`))},t):s.jsx("ul",{className:"s-message-markup-list",children:e.items.map((n,a)=>s.jsx("li",{children:Ca(n)},`${t}:${a}`))},t);case"blockquote":return s.jsx("blockquote",{className:"s-message-markup-quote",children:Ca(e.text)},t);case"code":return s.jsx("pre",{className:"s-message-markup-code",children:s.jsx("code",{children:e.text})},t);case"table":return Dse(e,t)}}function Gw({text:e,className:t}){const n=$se(e??"");return n.length===0?e??"":s.jsx("div",{className:["s-message-markup",t].filter(Boolean).join(" "),children:n.map(Lse)})}const yP="scout:sessions:lastViewed";function Zw(){if(typeof localStorage>"u")return{};try{const e=localStorage.getItem(yP);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Kw(e,t=Date.now()){const n=Zw();n[e]=t;try{localStorage.setItem(yP,JSON.stringify(n))}catch{}return n}function Im(e,t,n){return e?e>(n[t]??0):!1}const zse={defaultPort:43115},Bse=zse.defaultPort,Use="127.0.0.1",Fse=2e3,Vse=500;function Hse(e){return new qse(e)}class qse{base;clientId;probeTimeout;pollInterval;_state="unknown";constructor(t){if(t?.baseUrl)this.base=t.baseUrl.replace(/\/$/,"");else{const n=t?.host??Use,a=t?.port??Bse;this.base=`http://${n}:${a}`}this.clientId=t?.clientId??"vox-web",this.probeTimeout=t?.probeTimeout??Fse,this.pollInterval=t?.pollInterval??Vse}get state(){return this._state}get isConnected(){return this._state==="connected"}async probe(){this._state="probing";try{const n=await(await this.fetch("/health",{timeout:this.probeTimeout})).json();return this._state=n.ok?"connected":"unavailable",n.ok}catch{return this._state="unavailable",!1}}async health(){return(await this.fetch("/health")).json()}async capabilities(){return(await this.fetch("/capabilities")).json()}async transcribe(t){const{audio:n,modelId:a,format:r,language:o,timestamps:c,metadata:u}=t,h=new FormData;if(n instanceof Blob){const g=r??Zse(n.type)??"wav";h.append("audio",n,`audio.${g}`)}else{const g=r??"wav",v=new Blob([n],{type:Kse(g)});h.append("audio",v,`audio.${g}`)}return r&&h.append("format",r),a&&h.append("modelId",a),o&&h.append("language",o),c&&h.append("timestamps","true"),h.append("metadata",JSON.stringify(this.withClientMetadata(u))),(await this.fetch("/transcribe",{method:"POST",body:h})).json()}async createJob(t){return(await this.fetch("/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,metadata:this.withClientMetadata(t.metadata)})})).json()}async getJob(t){return(await this.fetch(`/jobs/${t}`)).json()}async align(t){const{jobId:n}=await this.createJob({...t,type:"alignment"});return this.waitForJob(n)}createLiveSession(){return new Wse(t=>this.openLiveSession(t),t=>this.stopLiveSession(t),t=>this.cancelLiveSession(t))}async getLiveSessionStatus(){const a=(await(await this.fetch("/live")).json()).session;return!a||typeof a!="object"?null:{sessionId:String(a.sessionId??""),connectionId:String(a.connectionId??""),clientId:String(a.clientId??""),modelId:String(a.modelId??""),startedAt:String(a.startedAt??""),state:String(a.state??"error")}}async stopLiveSession(t){const a=await(await this.fetch("/live/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionId:t}:{})})).json();return{stopped:!!a.stopped,sessionId:String(a.sessionId??t??"")}}async cancelLiveSession(t){const a=await(await this.fetch("/live/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionId:t}:{})})).json();return{cancelled:!!a.cancelled,sessionId:String(a.sessionId??t??"")}}launch(){window.location.href="vox://launch"}openSettings(){window.location.href="vox://settings"}async waitForJob(t){for(let a=0;a<600;a++){const r=await this.getJob(t);if(r.status==="completed"){if(!r.result?.alignment)throw new Na("Job completed but no alignment result","no_result");return r.result.alignment}if(r.status==="failed")throw new Na(r.error??"Job failed","job_failed");await Gse(this.pollInterval)}throw new Na("Job timed out","timeout")}async openLiveSession(t){const n={clientId:this.clientId};return t?.modelId&&(n.modelId=t.modelId),this.fetch("/live",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}withClientMetadata(t){const n=t?{...t}:{};return n.clientId==null&&n.surface==null&&(n.clientId=this.clientId),n}async fetch(t,n){const{timeout:a,...r}=n??{},o=new AbortController,c=a?setTimeout(()=>o.abort(),a):void 0;try{const u=await globalThis.fetch(`${this.base}${t}`,{...r,signal:o.signal});if(!u.ok){const h=await u.text().catch(()=>"");throw new Na(`${u.status} ${u.statusText}: ${h}`,"http_error")}return u}catch(u){throw u instanceof Na?u:new Na(u instanceof Error?u.message:"Companion unreachable","network_error")}finally{c&&clearTimeout(c)}}}class Na extends Error{code;constructor(t,n){super(t),this.code=n,this.name="VoxDError"}}class Wse{open;stopRequest;cancelRequest;sessionId=null;runPromise=null;finalEvent=null;stateListeners=new Set;partialListeners=new Set;finalListeners=new Set;errorListeners=new Set;constructor(t,n,a){this.open=t,this.stopRequest=n,this.cancelRequest=a}get id(){return this.sessionId}start(t){return this.runPromise||(this.runPromise=this.run(t)),this.runPromise}async stop(){await this.stopRequest(this.sessionId??void 0)}async cancel(){await this.cancelRequest(this.sessionId??void 0)}onState(t){return this.stateListeners.add(t),()=>this.stateListeners.delete(t)}onPartial(t){return this.partialListeners.add(t),()=>this.partialListeners.delete(t)}onFinal(t){return this.finalListeners.add(t),()=>this.finalListeners.delete(t)}onError(t){return this.errorListeners.add(t),()=>this.errorListeners.delete(t)}close(){this.cancel().catch(t=>{this.emitError(t instanceof Error?t:new Error(String(t)))})}async run(t){try{const n=await this.open(t);if(!n.body)throw new Na("Live session stream did not include a response body.","protocol_error");let a=null;await Yse(n.body,o=>{if(typeof o.error=="string"&&o.error)throw new Na(o.error,"live_session_error");if(typeof o.event=="string"){this.handleEvent(o.event,GA(o.data));return}o.result&&typeof o.result=="object"&&(a=GA(o.result))});const r=this.finalEvent??this.parseResult(a);if(!r)throw new Na("Live session ended without a final result.","protocol_error");return r}catch(n){const a=n instanceof Error?n:new Error(String(n));throw this.emitError(a),a}}handleEvent(t,n){switch(t){case"session.state":{const a={sessionId:String(n.sessionId??this.sessionId??""),state:String(n.state??"error"),previous:n.previous??null,reason:typeof n.reason=="string"?n.reason:void 0};a.sessionId&&(this.sessionId=a.sessionId);for(const r of this.stateListeners)r(a);break}case"session.partial":{const a={sessionId:String(n.sessionId??this.sessionId??""),text:String(n.text??"")};a.sessionId&&(this.sessionId=a.sessionId);for(const r of this.partialListeners)r(a);break}case"session.final":{const a=this.parseResult(n);if(!a)return;this.finalEvent=a,this.sessionId=a.sessionId||this.sessionId;for(const r of this.finalListeners)r(a);break}}}parseResult(t){if(!t)return null;if(t.cancelled)throw new Na(`Live session ${String(t.sessionId??this.sessionId??"")} was cancelled.`,"session_cancelled");return{sessionId:String(t.sessionId??this.sessionId??""),text:String(t.text??""),durationMs:Number(t.durationMs??t.elapsedMs??0),words:Array.isArray(t.words)?t.words:void 0,metrics:Qse(t.metrics)?t.metrics:void 0}}emitError(t){for(const n of this.errorListeners)n(t)}}function Gse(e){return new Promise(t=>setTimeout(t,e))}function Zse(e){if(e.includes("mp3")||e.includes("mpeg"))return"mp3";if(e.includes("wav"))return"wav";if(e.includes("aac")||e.includes("mp4"))return"aac";if(e.includes("opus")||e.includes("ogg"))return"opus"}function Kse(e){switch(e){case"mp3":return"audio/mpeg";case"wav":return"audio/wav";case"aac":return"audio/aac";case"opus":return"audio/ogg; codecs=opus";case"pcm16":return"audio/pcm";default:return"application/octet-stream"}}async function Yse(e,t){const n=e.getReader(),a=new TextDecoder;let r="";try{for(;;){const{value:c,done:u}=await n.read();if(u)break;r+=a.decode(c,{stream:!0}),r=Xse(r,t)}r+=a.decode();const o=r.trim();o&&t(xP(o))}finally{n.releaseLock()}}function Xse(e,t){let n=e;for(;;){const a=n.indexOf(`
160
+ `);if(a===-1)return n;const r=n.slice(0,a).trim();n=n.slice(a+1),r&&t(xP(r))}}function xP(e){try{return JSON.parse(e)}catch{throw new Na("Live session stream returned invalid JSON.","protocol_error")}}function GA(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Qse(e){return!!(e&&typeof e=="object")}const fg={lowCutHz:350,highCutHz:2800,bandQ:.85,saturationAmount:.25,bitcrushAmount:.12,hissGain:.045,hissCutoffHz:1200,presencePeakDb:4,presenceCenterHz:1500,presenceQ:1,compressorThresholdDb:-22,compressorRatio:5,clickEnabled:!0,clickGain:.35,clickDurationMs:70,squelchTailEnabled:!0,squelchTailGain:.07,squelchTailDurationMs:180,playbackRate:1,outputGain:1.1,wetMix:1},$d=[{id:"chill-dispatcher",label:"Chill Dispatcher",family:"dispatch",description:"Warm, friendly, takes its time. Like the calmest voice on the channel.",params:{lowCutHz:280,highCutHz:3200,bandQ:.7,saturationAmount:.2,bitcrushAmount:.08,hissGain:.035,hissCutoffHz:1400,presencePeakDb:3.5,presenceCenterHz:1500,presenceQ:1,compressorThresholdDb:-20,compressorRatio:4,clickEnabled:!0,clickGain:.3,clickDurationMs:60,squelchTailEnabled:!0,squelchTailGain:.06,squelchTailDurationMs:160,playbackRate:.97,outputGain:1.1,wetMix:1}},{id:"tower-control",label:"Tower Control",family:"dispatch",description:"Crisp, clipped, all-business. Pushes you out the door a little faster.",params:{lowCutHz:500,highCutHz:2400,bandQ:1,saturationAmount:.42,bitcrushAmount:.22,hissGain:.06,hissCutoffHz:1800,presencePeakDb:6,presenceCenterHz:1700,presenceQ:1.3,compressorThresholdDb:-28,compressorRatio:8,clickEnabled:!0,clickGain:.5,clickDurationMs:80,squelchTailEnabled:!0,squelchTailGain:.1,squelchTailDurationMs:200,playbackRate:1.08,outputGain:1.15,wetMix:1}},{id:"carrier-wave",label:"Carrier Wave",family:"dispatch",description:"Always-on hiss like someone's holding the mic just to keep you company.",params:{lowCutHz:320,highCutHz:3e3,bandQ:.55,saturationAmount:.15,bitcrushAmount:.06,hissGain:.11,hissCutoffHz:900,presencePeakDb:2,presenceCenterHz:1300,presenceQ:.8,compressorThresholdDb:-18,compressorRatio:3,clickEnabled:!0,clickGain:.18,clickDurationMs:50,squelchTailEnabled:!0,squelchTailGain:.12,squelchTailDurationMs:300,playbackRate:.95,outputGain:1.05,wetMix:1}},{id:"pocket-walkie",label:"Pocket Walkie",family:"walkie",description:"That nostalgic kid-radio crunch. Narrow, snappy, just-this-side-of-toy.",params:{lowCutHz:600,highCutHz:2300,bandQ:1.2,saturationAmount:.5,bitcrushAmount:.35,hissGain:.08,hissCutoffHz:1700,presencePeakDb:7,presenceCenterHz:1800,presenceQ:1.5,compressorThresholdDb:-26,compressorRatio:7,clickEnabled:!0,clickGain:.6,clickDurationMs:50,squelchTailEnabled:!0,squelchTailGain:.09,squelchTailDurationMs:120,playbackRate:1.05,outputGain:1.15,wetMix:1}},{id:"trail-buddy",label:"Trail Buddy",family:"walkie",description:"Breezy handheld vibe — wider, hissier, like your hiking partner two ridges over.",params:{lowCutHz:380,highCutHz:2900,bandQ:.75,saturationAmount:.32,bitcrushAmount:.18,hissGain:.14,hissCutoffHz:1100,presencePeakDb:4,presenceCenterHz:1500,presenceQ:1,compressorThresholdDb:-22,compressorRatio:5,clickEnabled:!0,clickGain:.35,clickDurationMs:65,squelchTailEnabled:!0,squelchTailGain:.1,squelchTailDurationMs:180,playbackRate:.98,outputGain:1.1,wetMix:1}},{id:"am-broadcast",label:"AM Broadcast",family:"other",description:"Vintage lo-fi, no PTT click. The voice on a radio left on in the next room.",params:{lowCutHz:250,highCutHz:2200,bandQ:.9,saturationAmount:.55,bitcrushAmount:.4,hissGain:.05,hissCutoffHz:700,presencePeakDb:3,presenceCenterHz:1200,presenceQ:1.2,compressorThresholdDb:-24,compressorRatio:6,clickEnabled:!1,clickGain:0,clickDurationMs:60,squelchTailEnabled:!1,squelchTailGain:0,squelchTailDurationMs:120,playbackRate:.96,outputGain:1.05,wetMix:1}},{id:"clean-mic",label:"Clean Mic",family:"other",description:"Almost no FX — just a tiny click. A/B reference for everything else.",params:{lowCutHz:150,highCutHz:5e3,bandQ:.4,saturationAmount:.03,bitcrushAmount:0,hissGain:0,hissCutoffHz:1200,presencePeakDb:1,presenceCenterHz:1500,presenceQ:.6,compressorThresholdDb:-16,compressorRatio:2,clickEnabled:!0,clickGain:.22,clickDurationMs:45,squelchTailEnabled:!1,squelchTailGain:0,squelchTailDurationMs:80,playbackRate:1,outputGain:1,wetMix:1}}];let Du=null;function Yw(){if(Du&&Du.state!=="closed")return Du;const e=window.AudioContext??window.webkitAudioContext;if(!e)throw new Error("Web Audio API is not available in this browser.");return Du=new e,Du}async function bP(e,t="audio/wav"){const n=atob(e),a=new Uint8Array(n.length);for(let r=0;r<n.length;r+=1)a[r]=n.charCodeAt(r);return await wP(a.buffer,t)}async function wP(e,t="audio/wav"){const n=Yw();return n.state==="suspended"&&await n.resume(),await n.decodeAudioData(e.slice(0))}async function Jse(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to load audio (${t.status}): ${e}`);const n=await t.arrayBuffer(),a=t.headers.get("content-type")??"audio/wav";return await wP(n,a)}function eae(e){return{...fg,...e??{}}}function tae(e){const t=1+Math.max(0,Math.min(1,e))*14,n=2048,a=new Float32Array(new ArrayBuffer(n*4)),r=Math.tanh(t);for(let o=0;o<n;o+=1){const c=o/(n-1)*2-1;a[o]=Math.tanh(t*c)/r}return a}function nae(e){const t=Math.max(0,Math.min(1,e)),n=Math.max(4,Math.round(256*Math.pow(1-t,2.5))),a=4096,r=new Float32Array(new ArrayBuffer(a*4));for(let o=0;o<a;o+=1){const c=o/(a-1)*2-1;r[o]=Math.round(c*n)/n}return r}function ZA(e){const t=e.sampleRate,n=Math.floor(2*t),a=e.createBuffer(1,n,t),r=a.getChannelData(0);let o=0;for(let c=0;c<n;c+=1){const u=Math.random()*2-1;o=o*.78+u*.22,r[c]=o}return a}function sae(e,t){const n=e.sampleRate,a=Math.max(16,Math.floor(t/1e3*n)),r=e.createBuffer(1,a,n),o=r.getChannelData(0);let c=0;for(let u=0;u<a;u+=1){const h=u/a,f=Math.pow(1-h,2.4)+(u<32?Math.pow(1-u/32,3)*.6:0),g=Math.random()*2-1;c=c*.6+g*.4,o[u]=c*f}return r}function KA(e,t,n,a,r){const o=e.createBufferSource();o.buffer=n;const c=e.createGain();return c.gain.value=r,o.connect(c).connect(t),o.start(a),{source:o,startsAt:a}}function Xw(e,t={}){const n=eae(t.params),a=Yw();a.state==="suspended"&&a.resume();const r=a.createBiquadFilter();r.type="highpass",r.frequency.value=n.lowCutHz,r.Q.value=n.bandQ;const o=a.createBiquadFilter();o.type="lowpass",o.frequency.value=n.highCutHz,o.Q.value=n.bandQ;const c=a.createWaveShaper();c.curve=tae(n.saturationAmount),c.oversample="2x";const u=a.createWaveShaper();u.curve=nae(n.bitcrushAmount);const h=a.createBiquadFilter();h.type="peaking",h.frequency.value=n.presenceCenterHz,h.Q.value=n.presenceQ,h.gain.value=n.presencePeakDb;const f=a.createDynamicsCompressor();f.threshold.value=n.compressorThresholdDb,f.ratio.value=n.compressorRatio,f.attack.value=.003,f.release.value=.08,f.knee.value=6;const g=a.createGain();g.gain.value=n.wetMix;const v=a.createGain();v.gain.value=1-n.wetMix;const y=a.createGain();y.gain.value=n.outputGain;const x=a.createBufferSource();x.buffer=e;const w=Math.max(.5,Math.min(2,n.playbackRate));x.playbackRate.value=w;const C=e.duration/w;x.connect(r),r.connect(o),o.connect(c),c.connect(u),u.connect(h),h.connect(f),f.connect(g),g.connect(y),x.connect(v),v.connect(y),y.connect(a.destination);const T=a.currentTime,S=40/1e3,k=n.clickEnabled?sae(a,n.clickDurationMs):null,N=T+(n.clickEnabled?S+n.clickDurationMs/1e3:0);x.start(N);let A=null;if(n.hissGain>0&&n.wetMix>0){const z=ZA(a);A=a.createBufferSource(),A.buffer=z,A.loop=!0;const B=a.createBiquadFilter();B.type="highpass",B.frequency.value=n.hissCutoffHz,B.Q.value=.7;const X=a.createGain();X.gain.value=n.hissGain,A.connect(B).connect(X).connect(g);const W=T,L=N+C+.18;X.gain.setValueAtTime(0,W),X.gain.linearRampToValueAtTime(n.hissGain,W+.03),X.gain.setValueAtTime(n.hissGain,L-.08),X.gain.linearRampToValueAtTime(0,L),A.start(W),A.stop(L+.02)}const R=N+C,_=n.squelchTailEnabled&&n.squelchTailGain>0&&n.wetMix>0,P=n.squelchTailDurationMs/1e3,$=R+.005,H=_?$+P:R;let I=null;if(_){const z=ZA(a);I=a.createBufferSource(),I.buffer=z,I.loop=!0;const B=a.createBiquadFilter();B.type="highpass",B.frequency.value=1e3,B.Q.value=.7;const X=a.createGain();X.gain.value=0,I.connect(B).connect(X).connect(g),X.gain.setValueAtTime(0,$),X.gain.linearRampToValueAtTime(n.squelchTailGain,$+.008),X.gain.exponentialRampToValueAtTime(.001,H),I.start($),I.stop(H+.02)}const U=[];if(k&&n.clickEnabled){U.push(KA(a,y,k,T,n.clickGain));const z=(_?H:R)+.02;U.push(KA(a,y,k,z,n.clickGain*.85))}let D=!1,V=!1;const Z=()=>{V||(V=!0,t.onEnded?.())};return{promise:new Promise(z=>{const B=_?P+.02:0,X=(n.clickEnabled?S+n.clickDurationMs/1e3:0)+C+B+(n.clickEnabled?n.clickDurationMs/1e3+.04:0)+.02,W=setTimeout(()=>{Z(),z()},Math.ceil(X*1e3)),L=()=>{if(!D){D=!0,clearTimeout(W);try{x.stop()}catch{}if(A)try{A.stop()}catch{}if(I)try{I.stop()}catch{}for(const q of U)try{q.source.stop()}catch{}try{x.disconnect()}catch{}try{y.disconnect()}catch{}Z(),z()}};t.signal&&(t.signal.aborted?L():t.signal.addEventListener("abort",L,{once:!0}))}),stop:()=>{try{x.stop()}catch{}if(A)try{A.stop()}catch{}if(I)try{I.stop()}catch{}for(const z of U)try{z.source.stop()}catch{}}}}function aae(e,t={}){const n=Yw();n.state==="suspended"&&n.resume();const a=n.createBufferSource();a.buffer=e,a.connect(n.destination),a.start(n.currentTime);let r=!1;const o=()=>{r||(r=!0,t.onEnded?.())};return{promise:new Promise(u=>{const h=setTimeout(()=>{o(),u()},Math.ceil(e.duration*1e3)+20),f=()=>{clearTimeout(h);try{a.stop()}catch{}try{a.disconnect()}catch{}o(),u()};t.signal&&(t.signal.aborted?f():t.signal.addEventListener("abort",f,{once:!0}))}),stop:()=>{try{a.stop()}catch{}}}}const rae="http://127.0.0.1:43115",iae="openscout-web";class Qu{constructor(t=rae){this.baseUrl=t,this.client=this.createClient()}baseUrl;state="unknown";unavailableReason=null;client;get connectionState(){return this.state}get lastUnavailableReason(){return this.unavailableReason}async probe(t=1200){this.state="probing",this.unavailableReason=null,this.client=this.createClient(t);try{return await this.client.probe()?(await this.client.capabilities(),this.state="connected",!0):(this.state="unavailable",!1)}catch(n){return this.state="unavailable",this.unavailableReason=JA(n),!1}}launch(t={}){window.location.href=YA("launch",{source:t.source,returnTo:t.returnTo??QA(),context:XA(t.context)})}openSettings(t={}){window.location.href=YA("settings",{source:t.source,returnTo:t.returnTo??QA(),context:XA(t.context)})}async startLive(t={}){const n=this.client.createLiveSession();let a=null;mae(n,t,o=>{a=o});const r=n.start({modelId:"parakeet:v3"}).then(o=>(a??=NP(o),a)).catch(o=>{throw new Error(JA(o))});return{get sessionId(){return n.id},result:r,stop:async()=>{await n.stop()},cancel:async()=>{await n.cancel().catch(()=>{})}}}createClient(t=1200){return Hse({baseUrl:this.baseUrl,clientId:iae,probeTimeout:t})}}function gp(){const e=new Error("Speech stopped.");return e.name="AbortError",e}function Yl(e){return e instanceof Error&&e.name==="AbortError"}async function Qw(e,t={}){const n={text:e,speed:hae(t.speed)};t.originAppId&&(n.originAppId=t.originAppId),t.utteranceId&&(n.utteranceId=t.utteranceId),t.instructions&&(n.instructions=t.instructions),t.speechTiming?.enabled&&(n.speechTiming=t.speechTiming);const a=await fetch("/api/voice/speak",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:t.signal});if(!a.ok){const r=await a.text().catch(()=>"");try{const o=JSON.parse(r);throw new Error(o.error??`Voice returned HTTP ${a.status}`)}catch(o){throw o instanceof SyntaxError?new Error(r||`Voice returned HTTP ${a.status}`):o}}return await a.json()}async function oae(e,t={}){if(t.signal?.aborted)throw gp();const n=new Audio(`data:${e.contentType};base64,${e.audioBase64}`),a=()=>{n.pause(),n.currentTime=0};t.signal?.addEventListener("abort",a,{once:!0}),await n.play(),t.onPlaybackStart?.();try{return await new Promise((r,o)=>{const c=()=>{n.removeEventListener("ended",u),n.removeEventListener("error",h),t.signal?.removeEventListener("abort",f)},u=()=>{c(),r()},h=()=>{c(),o(new Error("Vox audio playback failed."))},f=()=>{c(),o(gp())};if(t.signal?.aborted){f();return}n.addEventListener("ended",u,{once:!0}),n.addEventListener("error",h,{once:!0}),t.signal?.addEventListener("abort",f,{once:!0})}),e}finally{t.signal?.removeEventListener("abort",a)}}async function lae(e,t={}){const n=await Qw(e,t);return await oae(n,{signal:t.signal})}function cae(e,t={}){const n=new AbortController;return{promise:lae(e,{...t,signal:n.signal}),stop:()=>n.abort()}}function jP(e,t){const n=e?$d.find(a=>a.id===e)?.params:void 0;return{...fg,...n??{},...t??{}}}async function uae(e,t={}){const n=await Qw(e,t);if(t.signal?.aborted)throw gp();const a=await bP(n.audioBase64,n.contentType),r=jP(t.presetId,t.params);return await Xw(a,{params:r,signal:t.signal}).promise,n}async function dae(e,t={}){if(t.signal?.aborted)throw gp();const n=await bP(e.audioBase64,e.contentType),a=jP(t.presetId,t.params),r=Xw(n,{params:a,signal:t.signal});return t.onPlaybackStart?.(),await r.promise,e}function fae(e,t={}){const n=new AbortController;return{promise:uae(e,{...t,signal:n.signal}),stop:()=>n.abort()}}function hae(e){if(!(e===void 0||!Number.isFinite(e)))return Math.min(2,Math.max(.5,Number(e.toFixed(2))))}function mae(e,t,n){e.onState(a=>t.onState?.(a.state)),e.onPartial(a=>t.onPartial?.(a.text)),e.onFinal(a=>{const r=NP(a);n(r),t.onFinal?.(r)})}function NP(e){return{sessionId:e.sessionId,text:e.text.trim(),durationMs:e.durationMs}}function YA(e,t){const n=new URLSearchParams;for(const[r,o]of Object.entries(t))o&&n.set(r,o);const a=n.toString();return a?`vox://${e}?${a}`:`vox://${e}`}function XA(e){if(e)return JSON.stringify(e)}function QA(){try{return window.location.origin}catch{return}}function JA(e){const t=e instanceof Error?e.message:String(e);return e instanceof Na&&e.code==="http_error"&&/origin not allowed/i.test(t)||/origin not allowed/i.test(t)?"Vox blocked this OpenScout URL. Restart OpenScout so it can register its Vox browser origin, then try again.":t||"Vox request failed."}function Jw({onAppend:e,disabled:t,className:n}){const a=m.useRef(null),r=m.useRef(null),[o,c]=m.useState("probing"),[u,h]=m.useState(null);m.useEffect(()=>{let S=!1;const k=new Qu;return a.current=k,k.probe().then(N=>{S||(N?(c("idle"),h(null)):(c("unavailable"),h(k.lastUnavailableReason??"Voice unavailable — open Ranger to launch Vox.")))}),()=>{S=!0;const N=r.current;N&&(N.cancel().catch(()=>{}),r.current=null)}},[]);const f=m.useCallback(async()=>{const S=a.current;if(!S)return;c("starting");let k=null;try{k=await S.startLive({onState:()=>{},onPartial:()=>{}}),r.current=k,c("recording");const N=await k.result;r.current=null,c("idle");const A=N.text?.trim();A&&e(A)}catch{r.current=null,c("idle")}},[e]),g=m.useCallback(async()=>{const S=r.current;if(S){c("processing");try{await S.stop()}catch{try{await S.cancel()}catch{}r.current=null,c("idle")}}},[]),v=m.useCallback(()=>{o==="recording"?g():o==="idle"&&f()},[o,f,g]),y=o==="starting"||o==="processing",x=o==="unavailable"||o==="probing",w=o==="unavailable"?u??"Voice unavailable":o==="probing"?"Checking voice…":o==="recording"?"Stop dictation":y?"Working…":"Dictate",C=o==="recording"?"s-dictation-mic--recording":y?"s-dictation-mic--busy":"",T=y?ea:o==="recording"?Bd:M0,E=o==="recording"?12:14;return s.jsx("button",{type:"button",title:w,"aria-label":w,"aria-pressed":o==="recording",onClick:v,disabled:t||x||y,className:["s-dictation-mic",C,n].filter(Boolean).join(" "),children:s.jsx(T,{size:E,className:y?"s-dictation-mic-spin":o==="recording"?"fill-current":""})})}const pae=/\.(?:apng|avif|gif|jpe?g|png|svg|webp)(?:$|[?#])/iu,gae=/\bhttps?:\/\/[^\s<>"')\]]+/giu;function hd(e){if(typeof e!="string")return null;try{const t=new URL(e.trim());return t.protocol==="http:"||t.protocol==="https:"?t.toString():null}catch{return null}}function lr(e,t){const n=e?.[t];return typeof n=="string"&&n.trim()?n.trim():null}function vae(e){return e.mediaType.toLowerCase().startsWith("image/")}function kP(e){return pae.test(e)}function SP(e){try{const t=new URL(e),n=[t.pathname==="/"?"":t.pathname,t.search].join("").trim();return{host:t.hostname.replace(/^www\./iu,""),detail:n||t.hostname}}catch{return{host:e,detail:e}}}function yae(e){const t=new Set,n=[];for(const a of e.matchAll(gae)){const r=a[0]?.replace(/[.,;:!?]+$/u,""),o=hd(r);!o||t.has(o)||(t.add(o),n.push(o))}return n}function Kb(e){return hd(e.url)??hd(lr(e.metadata,"url"))??hd(lr(e.metadata,"href"))}function xae(e){const t=e.metadata??null,n=lr(t,"kind")??lr(t,"type"),a=Kb(e);if(!a||n!=="link_preview"&&n!=="link-preview"&&e.mediaType!=="text/x-uri")return null;const r=SP(a);return{id:e.id,url:a,title:lr(t,"title")??r.host,description:lr(t,"description"),imageUrl:hd(lr(t,"imageUrl")??lr(t,"image")),siteName:lr(t,"siteName")??r.host}}function bae(e){const t=SP(e);return{id:e,url:e,title:t.host,description:t.detail===t.host?null:t.detail,imageUrl:kP(e)?e:null,siteName:t.host}}function wae({src:e,alt:t}){return s.jsx("a",{className:"s-message-embed s-message-embed--image",href:e,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:e,alt:t,loading:"lazy",decoding:"async"})})}function jae({preview:e}){return s.jsxs("a",{className:"s-message-embed s-message-embed--link",href:e.url,target:"_blank",rel:"noreferrer",children:[e.imageUrl&&s.jsx("span",{className:"s-message-embed-thumb",children:s.jsx("img",{src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"})}),s.jsxs("span",{className:"s-message-embed-copy",children:[e.siteName&&s.jsx("span",{className:"s-message-embed-site",children:e.siteName}),s.jsx("span",{className:"s-message-embed-title",children:e.title}),e.description&&s.jsx("span",{className:"s-message-embed-description",children:e.description})]})]})}function CP({message:e}){const t=e.attachments??[],n=new Set,a=[],r=[];for(const u of t){const h=Kb(u);if(h&&vae(u)){n.add(u.id),a.push({id:u.id,src:h,alt:u.fileName??"Image attachment"});continue}const f=xae(u);f&&(n.add(u.id),r.push(f))}const o=new Set(r.map(u=>u.url));for(const u of yae(e.body))o.has(u)||(kP(u)?a.push({id:u,src:u,alt:"Embedded image"}):r.length===0&&r.push(bae(u)));const c=t.filter(u=>!n.has(u.id));return a.length===0&&r.length===0&&c.length===0?null:s.jsxs("div",{className:"s-message-embeds",children:[a.map(u=>s.jsx(wae,{src:u.src,alt:u.alt},u.id)),r.slice(0,1).map(u=>s.jsx(jae,{preview:u},u.id)),c.map(u=>{const h=Kb(u),f=u.fileName??lr(u.metadata,"title")??u.mediaType;return h?s.jsxs("a",{className:"s-message-embed s-message-embed--file",href:h,target:"_blank",rel:"noreferrer",children:[s.jsx("span",{className:"s-message-embed-title",children:f}),s.jsx("span",{className:"s-message-embed-description",children:u.mediaType})]},u.id):s.jsxs("div",{className:"s-message-embed s-message-embed--file",children:[s.jsx("span",{className:"s-message-embed-title",children:f}),s.jsx("span",{className:"s-message-embed-description",children:u.mediaType})]},u.id)})]})}const Nae={direct:"Direct message",channel:"Channel",group_direct:"Group",thread:"Thread"},eT=[{command:"/ask",label:"/ask",description:"Ask the agent owned work with a reply",insert:"/ask "},{command:"/tell",label:"/tell",description:"Send a heads-up or quick message",insert:"/tell "},{command:"/steer",label:"/steer",description:"Steer the active turn mid-flight",insert:"/steer "},{command:"/route",label:"/route",description:"Route this to another agent",insert:"/route @"},{command:"/inbox",label:"/inbox",description:"Go to the inbox",insert:"/inbox"},{command:"/agents",label:"/agents",description:"Open the agents list",insert:"/agents"},{command:"/fleet",label:"/fleet",description:"Open the fleet view",insert:"/fleet"},{command:"/sessions",label:"/sessions",description:"Browse sessions",insert:"/sessions"},{command:"/mesh",label:"/mesh",description:"Open the mesh view",insert:"/mesh"},{command:"/activity",label:"/activity",description:"Open activity feed",insert:"/activity"},{command:"/settings",label:"/settings",description:"Open settings",insert:"/settings"}];function EP(e,t){if(t<=0)return!0;const n=e[t-1];return!n||/\s/.test(n)}function kae(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const r=e[n];if(r==="/")break;if(!r||/\s/.test(r))return null;n-=1}if(n<0||e[n]!=="/"||!EP(e,n))return null;const a=e.slice(n+1,t);return/[^a-zA-Z0-9_-]/.test(a)?null:{start:n,query:a}}function Sae(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const r=e[n];if(r==="@")break;if(!r||/\s/.test(r))return null;n-=1}if(n<0||e[n]!=="@"||!EP(e,n))return null;const a=e.slice(n+1,t);return/[^a-zA-Z0-9._/:-]/.test(a)?null:{start:n,query:a}}function Cae(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function Eae(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-")||"shared"}function Aae(e){return e.kind==="direct"&&e.agentName?e.agentName:e.kind==="direct"&&e.agentId?br(e.agentId)??e.agentId:e.title.replace(/\s*<>\s*/g," · ")}function Tae(e){switch(e){case"status":return"Status";case"system":return"System";case"scout.dispatch":return"Dispatch";default:return null}}function Uh(e){return[...e].sort((t,n)=>G$(t.createdAt,n.createdAt))}function Mae(e){return e.filter(Bc).sort((t,n)=>lg(t.startedAt,n.startedAt))[0]??null}function tT(e,t,n){return{id:e.id,invocationId:e.invocationId,agentId:e.targetAgentId||n,agentName:null,conversationId:t,collaborationRecordId:null,state:e.state,summary:e.summary??null,startedAt:e.startedAt??null,completedAt:e.completedAt??null}}function nT(e){const t=new Set;for(const n of e.needsAttention)n.conversationId&&t.add(n.conversationId),n.agentId&&t.add(n.agentId);for(const n of e.activeAsks)n.status==="needs_attention"&&n.conversationId&&t.add(n.conversationId);return t}function Rae(){return{generatedAt:Date.now(),totals:{active:0,recentCompleted:0,needsAttention:0,activity:0},activeAsks:[],recentCompleted:[],needsAttention:[],activity:[]}}function Iae(e,t,n,a){if(!t)return[];const r=zt(t.startedAt)??0,o=new Set;return e.filter(c=>c.flightId===t.id||c.invocationId===t.invocationId?!0:!a||c.agentId!==a||c.conversationId!==n?!1:(zt(c.ts)??0)>=r).filter(c=>o.has(c.id)?!1:(o.add(c.id),!0)).sort((c,u)=>lg(c.ts,u.ts))}function _ae(e,t,n,a){return t?e.find(r=>r.flightId===t.id||r.invocationId===t.invocationId)??e.find(r=>r.conversationId===n&&(!a||r.agentId===a)&&(r.status==="queued"||r.status==="working"))??null:null}function sT(e){const t=e.summary?.trim();if(t)return t;const n=e.title?.trim();return n||null}function Oae(e){return e===1?"1 signal":`${e} signals`}function $ae(e){const{currentFlight:t,presence:n,turnActivity:a,turnAsk:r,nowMs:o}=e,c=a.find(v=>sT(v)),u=(c?sT(c):null)??r?.summary?.trim()??t?.summary?.trim()??n.detail,h=zt(t?.startedAt)??zt(r?.startedAt),f=zt(c?.ts)??zt(r?.updatedAt)??h,g=Math.max(a.length,r?.acknowledgedAt?1:0,t?1:0);return{latest:u,signalsLabel:Oae(g),elapsedLabel:h?Ae(h,o):"now",lastSignalLabel:f?Ae(f,o):"now"}}function Pae(e){const t=e.metadata?.scoutDispatch;if(!t||typeof t!="object")return null;const n=t;return!n.id||!n.kind||!Array.isArray(n.candidates)?null:n}function Yb(e,t){if(e.class==="operator"||e.actorId==="operator")return!0;const n=e.actorName?.toLowerCase()??"";return n===t.toLowerCase()||n==="operator"||n==="you"}function Dae(e){const t=e.metadata?.returnAddress;if(!t||typeof t!="object")return null;const n=t.actorId;return typeof n=="string"&&n.trim().length>0?n.trim():null}function Lae(e,t,n){const a=e.actorId??Dae(e);if(a){const o=t.find(c=>c.id===a);if(o)return o}if(n){const o=t.find(c=>c.id===n);if(o)return o}if(!e.actorName)return null;const r=t.filter(o=>o.name===e.actorName);return r.length===1?r[0]:null}function zae(e,t){return e.reduce((n,a)=>{if(Yb(a,t))return n;const r=zt(a.createdAt);return r===null?n:n===null||r>n?r:n},null)}function Bae(e,t){switch(t){case"queued":return`${e} has your message and is waiting to start.`;case"waking":return`${e} is waking up now.`;case"waiting":return`${e} is thinking through the request.`;case"running":return`${e} is working on your request.`;default:return`${e} is working on it.`}}function Uae(e){const{agentName:t,agentState:n,sending:a,currentFlight:r,showWorkingTurn:o,workingTurnIsGone:c,workingTurnIsStale:u,nowMs:h}=e;if(a&&!r)return{label:"Sending",detail:`Handing your message to ${t}.`,tone:"pending",showStrip:!0,showTyping:!1};if(r&&o&&u){const f=Ae(r.startedAt,h),g=f?`No update from ${t} for ${f}.`:`No recent update from ${t}.`;return{label:c?"Gone":"Stale",detail:c?`${g} Agent is offline.`:g,tone:"stale",showStrip:!0,showTyping:!0}}if(r&&o){const f=r.summary?.trim()||Bae(t,r.state);switch(r.state){case"queued":return{label:"Queued",detail:f,tone:"pending",showStrip:!0,showTyping:!0};case"waking":return{label:"Coming online",detail:f,tone:"working",showStrip:!0,showTyping:!0};case"waiting":return{label:"Thinking",detail:f,tone:"working",showStrip:!0,showTyping:!0};default:return{label:"Working",detail:f,tone:"working",showStrip:!0,showTyping:!0}}}return Vi(n)?{label:"Available",detail:`${t} is connected.`,tone:"idle",showStrip:!1,showTyping:!1}:{label:"Offline",detail:`${t} is offline right now. Sending a message will wake it up.`,tone:"offline",showStrip:!0,showTyping:!1}}function Fae(e,t){switch(e.tone){case"pending":return"var(--accent)";case"working":return"var(--green)";case"stale":return"var(--amber)";case"offline":return"var(--dim)";default:return Pn(t)}}function Vae(){return s.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"m3 11 18-8-8 18-2.8-7.2L3 11Z"}),s.jsx("path",{d:"M10.2 13.8 21 3"})]})}function Hae(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}function qae(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M4 4l8 8"}),s.jsx("path",{d:"M12 4l-8 8"})]})}function Wae(e){if(!e)return null;if(e.kind==="direct")return e.agentName??br(e.agentId)??null;const t=e.participantIds.filter(n=>n!=="operator");return t.length===0?null:t.map(n=>br(n)??n).join(", ")}function hg({conversationId:e,initialComposeMode:t,initialDraft:n,navigate:a,embedded:r}){const{agents:o,route:c}=qe(),u=oa(c),h=m.useMemo(()=>eo(o,u),[o,u]),f=m.useMemo(()=>el(o,u),[o,u]),[g,v]=m.useState(null),[y,x]=m.useState([]),[w,C]=m.useState(null),[T,E]=m.useState([]),[S,k]=m.useState(null),[N,A]=m.useState(new Set),[R,_]=m.useState([]),[P,$]=m.useState(null),H=m.useRef(null),I=m.useRef(null),U=m.useRef(new Set),D=m.useRef(null),V=m.useRef(0),Z=m.useRef(null);m.useEffect(()=>{e.startsWith("channel.")&&a({view:"channels",channelId:e})},[e,a]);const O=Ow(e),z=g?.agentId??O,B=g?.kind==="direct"||O!==null,X=m.useMemo(()=>z?f.find(ne=>ne.id===z)??null:null,[f,z]),[W,L]=m.useState([]),q=m.useMemo(()=>og(W,h,u),[W,h,u]),[K,ee]=m.useState(new Set),[G]=m.useState(()=>Zw());m.useEffect(()=>{me("/api/conversations").then(ne=>L(ne.sort((ve,Ee)=>(Ee.lastMessageAt??0)-(ve.lastMessageAt??0)))).catch(()=>{}),me("/api/fleet").then(ne=>{ee(nT(ne))}).catch(()=>{})},[]),m.useEffect(()=>{const ne=q.find(ve=>ve.id===e);ne&&Uo(ne)&&a({view:"channels",channelId:e})},[e,a,q]);const re=m.useCallback(async()=>{$(null);try{const ne=await me(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);v(ne);const ve=ne?.agentId??O,Ee=ne?.kind==="direct"&&ve&&ve.startsWith("local-session-agent-")?ps(ve):e;if(Ee!==e){a({view:"conversation",conversationId:Ee,...t?{composeMode:t}:{}});return}const[Fe,ze,it]=await Promise.all([me(`/api/messages?conversationId=${encodeURIComponent(Ee)}&limit=300`),me(`/api/flights?conversationId=${encodeURIComponent(Ee)}`),me("/api/fleet?limit=24&activityLimit=160").catch(()=>Rae())]),fn=Uh(Fe);x(fn),Kw(Ee);const Xt=fn.at(-1);Xt&&me(`/api/conversations/${encodeURIComponent(Ee)}/read-cursor`,{method:"POST",body:JSON.stringify({lastReadMessageId:Xt.id})}).catch(()=>{}),_(ze),U.current=new Set(ze.map(fa=>fa.invocationId));const kn=Mae(ze),wn=kn?.agentId??ve??null;C(kn),E(Iae(it.activity,kn,Ee,wn)),k(_ae(it.activeAsks,kn,Ee,wn)),ee(nT(it))}catch(ne){$(ne instanceof Error?ne.message:String(ne))}},[e,t,O,a]);m.useEffect(()=>{re()},[re]);const[Q,ae]=m.useState(null),[be,$e]=m.useState(!1);m.useEffect(()=>{if(!z)return;let ne=!1;return me(`/api/agents/${encodeURIComponent(z)}/session-catalog`).then(ve=>{ne||ae(ve)}).catch(()=>{}),()=>{ne=!0}},[z]),m.useEffect(()=>{D.current=w},[w]);const ge=m.useCallback(()=>{w?.id&&A(ne=>{const ve=new Set(ne);return ve.add(w.id),ve})},[w?.id]),[Te,pe]=m.useState(()=>n??""),[Xe,Be]=m.useState(!1),[Se,Me]=m.useState("operator"),[_e,Ne]=m.useState({open:!1,query:"",triggerStart:-1,index:0}),[Oe,Ce]=m.useState({open:!1,query:"",triggerStart:-1,index:0}),[Ve,Re]=m.useState(null),[Ie,De]=m.useState(t==="ask"?"ask":"tell"),[ct,ut]=m.useState(!1),[st,ht]=m.useState(""),[yt,Mt]=m.useState(""),[Rt,xt]=m.useState(null),[Y,te]=m.useState(!1);m.useEffect(()=>{De(B&&t==="ask"?"ask":"tell")},[e,t,B]),m.useEffect(()=>{ut(!1),ht(""),Mt(""),xt(null),te(!1)},[e]),m.useEffect(()=>{if(!n)return;const ne=`${e}:${n}`;Z.current!==ne&&(Z.current=ne,pe(n),requestAnimationFrame(()=>I.current?.focus()))},[e,n]);const he=m.useMemo(()=>{const ne=new Set,ve=[];for(const Ee of f){const Fe=Ee.handle?.trim().replace(/^@+/,"")??br(Ee.id)??Ee.id;if(!Fe)continue;const ze=Fe.toLowerCase();ne.has(ze)||(ne.add(ze),ve.push({id:Ee.id,label:Fe,name:Ee.name??Fe,handle:Fe}))}return ve.sort((Ee,Fe)=>Ee.handle.localeCompare(Fe.handle))},[f]),Pe=m.useMemo(()=>{if(!_e.open)return[];const ne=_e.query.toLowerCase();return ne?eT.filter(ve=>ve.command.toLowerCase().startsWith("/"+ne)||ve.command.toLowerCase().includes(ne)):eT},[_e.open,_e.query]),We=m.useMemo(()=>{if(!Oe.open)return[];const ne=Oe.query.toLowerCase();return ne?he.filter(ve=>ve.handle.toLowerCase().includes(ne)||ve.name.toLowerCase().includes(ne)).slice(0,8):he.slice(0,8)},[Oe.open,Oe.query,he]),rt=m.useCallback(()=>{Ne(ne=>ne.open?{...ne,open:!1}:ne),Ce(ne=>ne.open?{...ne,open:!1}:ne)},[]),at=m.useCallback((ne,ve)=>{const Ee=kae(ne,ve);Ne(Ee?ze=>({open:!0,query:Ee.query,triggerStart:Ee.start,index:ze.open&&ze.triggerStart===Ee.start?ze.index:0}):ze=>ze.open?{...ze,open:!1}:ze);const Fe=Sae(ne,ve);Ce(Fe?ze=>({open:!0,query:Fe.query,triggerStart:Fe.start,index:ze.open&&ze.triggerStart===Fe.start?ze.index:0}):ze=>ze.open?{...ze,open:!1}:ze)},[]),Ot=m.useCallback(ne=>{const ve=I.current,Ee=_e.triggerStart;if(Ee<0)return;const Fe=ve?.selectionStart??Te.length,ze=Te.slice(0,Ee),it=Te.slice(Fe),fn=ne.insert,Xt=`${ze}${fn}${it}`;pe(Xt),Ne(kn=>({...kn,open:!1})),requestAnimationFrame(()=>{const kn=I.current;if(!kn)return;const wn=ze.length+fn.length;kn.focus(),kn.setSelectionRange(wn,wn)})},[Te,_e.triggerStart]),jt=m.useCallback(ne=>{const ve=I.current,Ee=Oe.triggerStart;if(Ee<0)return;const Fe=ve?.selectionStart??Te.length,ze=Te.slice(0,Ee),it=Te.slice(Fe),fn=it.length===0||!it.startsWith(" "),Xt=`@${ne.handle}${fn?" ":""}`,kn=`${ze}${Xt}${it}`;pe(kn),Ce(wn=>({...wn,open:!1})),requestAnimationFrame(()=>{const wn=I.current;if(!wn)return;const fa=ze.length+Xt.length;wn.focus(),wn.setSelectionRange(fa,fa)})},[Te,Oe.triggerStart]);m.useEffect(()=>{const ne=I.current;if(!ne)return;ne.style.height="0px";const ve=Math.min(Math.max(ne.scrollHeight,40),160);ne.style.height=`${ve}px`,ne.style.overflowY=ne.scrollHeight>ve?"auto":"hidden"},[Te]),m.useEffect(()=>{me("/api/user").then(ne=>Me(ne.name)).catch(()=>{})},[]);const bt=m.useMemo(()=>zae(y,Se),[y,Se]);m.useEffect(()=>{Ve===null||bt===null||bt>=Ve&&Re(null)},[Ve,bt]);const Bt=m.useMemo(()=>kse(w),[w]),Mn=Date.now(),es=hP(w,Mn),vs=Sse(w,bt,Mn),cn=w?N.has(w.id):!1,Rn=Bt&&!vs&&!cn,ts=Rn&&es,ys=ts&&Je(X?.state??null)==="offline",la=Xe||Ve!==null||Rn,xs=Xe||Ve!==null||Rn&&!ts,Yt=J$({name:X?.name,agentName:g?.agentName,id:z,title:g?.title}),Ht=m.useMemo(()=>Uae({agentName:Yt,agentState:X?.state??null,sending:Xe,currentFlight:w,showWorkingTurn:Rn,workingTurnIsGone:ys,workingTurnIsStale:ts,nowMs:Mn}),[X?.state,Yt,w,Mn,Xe,Rn,ys,ts]),Ln=Ht.tone==="stale",Rs=Ln?Ht.label:"Live",de=m.useMemo(()=>$ae({currentFlight:w,presence:Ht,turnActivity:T,turnAsk:S,nowMs:Mn}),[w,Mn,Ht,T,S]),Ue=["s-thread-msg-card","s-thread-msg-working-card","s-thread-msg-card--avatar-row",Ln?"s-thread-msg-working-card--stale":null].filter(Boolean).join(" "),He=["s-thread-msg-kind",Ln?"s-thread-msg-kind--stale":null,ys?"s-thread-msg-kind--gone":null].filter(Boolean).join(" "),Lt=["s-thread-stale-indicator",ys?"s-thread-stale-indicator--gone":null].filter(Boolean).join(" "),nn=["s-thread-turn-snapshot",Ln?"s-thread-turn-snapshot--stale":null].filter(Boolean).join(" "),ca=["s-thread-turn-snapshot-pulse",Ln?"s-thread-turn-snapshot-pulse--stale":null].filter(Boolean).join(" "),bs=["s-thread-presence-line",Ln?"s-thread-presence-line--stale":null].filter(Boolean).join(" "),Wt=["s-thread-presence-strip",Ln?"s-thread-presence-strip--stale":null].filter(Boolean).join(" "),Gn=Ln?Ht.detail:`${Yt}: ${de.latest}`,ds=g?Aae(g):Yt,ws=g?.kind?Nae[g.kind]??g.kind:"Conversation";Wae(g);const Xn=Cae(g?.workspaceRoot),js=g?.lastMessageAt??y[y.length-1]?.createdAt??null,ua=[Xn?{label:Xn,title:g?.workspaceRoot??void 0}:null,g?.currentBranch?{label:g.currentBranch,title:g.currentBranch}:null,X?.harness??g?.harness?{label:X?.harness??g?.harness??"",title:void 0}:null].filter(ne=>!!ne),dn=g?g.participantIds.length:B?2:1,Qn=m.useMemo(()=>(!K.has(e)&&!(z&&K.has(z)),null),[e,z,K]);tn(m.useCallback(ne=>{if(ne.kind==="message.posted"){const ve=ne.payload?.message;if(!ve||ve.conversationId!==e)return;const Ee=ve.actorId===z,Fe={id:ve.id,conversationId:ve.conversationId,actorId:ve.actorId,actorName:Ee?Yt:Se,body:ve.body,createdAt:ve.createdAt,class:Ee?ve.class:"operator",attachments:ve.attachments,metadata:ve.metadata};if(x(ze=>{if(ze.some(it=>it.id===ve.id))return ze;if(!Ee){const it=ze.findIndex(fn=>fn.id.startsWith("optimistic-")&&fn.body===ve.body&&Math.abs((zt(fn.createdAt)??0)-(zt(ve.createdAt)??0))<=6e4);if(it!==-1){const fn=[...ze];return fn[it]=Fe,Uh(fn)}}return Uh([...ze,Fe])}),Ee){const ze=zt(ve.createdAt)??Date.now();Re(it=>it===null||ze<it||Bc(D.current)?it:null),C(it=>Cse(it)?null:it)}return}if(ne.kind==="invocation.requested"){const ve=ne.payload?.invocation;if(!ve||ve.targetAgentId!==z||ve.conversationId!==e)return;U.current.add(ve.id),E([]),k(null),Re(Ee=>Ee??Date.now());return}if(ne.kind==="flight.updated"){const ve=ne.payload?.flight;if(!ve||ve.targetAgentId!==z||!(U.current.has(ve.invocationId)||D.current?.id===ve.id))return;if(dP.has(ve.state)){C(it=>it?.id===ve.id?null:it),E([]),k(null),Re(null),re();return}U.current.add(ve.invocationId);const Fe=D.current?.id===ve.id,ze=tT(ve,e,z??"");fP(ze)&&Re(null),C(ze),Fe||(E([]),k(null));return}ne.kind!=="agent.endpoint.upserted"&&ne.kind==="unknown"&&re()},[z,Yt,e,re,Se])),m.useEffect(()=>{if(!la)return;const ne=setInterval(()=>{re()},5e3);return()=>clearInterval(ne)},[la,re]),m.useEffect(()=>{const ne=()=>{if(document.visibilityState!=="visible")return;const ve=Date.now();ve-V.current<1e3||(V.current=ve,re())};return window.addEventListener("focus",ne),document.addEventListener("visibilitychange",ne),()=>{window.removeEventListener("focus",ne),document.removeEventListener("visibilitychange",ne)}},[re]);const Kr=y.length+(Ht.showTyping?1:0),da=m.useRef(0),Ma=m.useRef(!1);m.useEffect(()=>{if(Kr>da.current){const ne=Ma.current?"smooth":"instant";H.current?.scrollIntoView({behavior:ne}),Ma.current=!0}da.current=Kr},[Kr]);const[,Ra]=m.useState(0);m.useEffect(()=>{const ne=setInterval(()=>Ra(ve=>ve+1),15e3);return()=>clearInterval(ne)},[]);const Yr=async(ne,ve)=>{const Ee=ne.trim();if(!Ee||Xe)return;const Fe=ve?.forceMode??Ie,ze=B?xs?"steer":Fe:"tell",it=Date.now(),fn={id:`optimistic-${it}`,conversationId:e,actorId:"operator",actorName:Se,body:Ee,createdAt:it,class:"operator"};Be(!0),Re(it),$(null),x(Xt=>Uh([...Xt,fn]));try{const Xt=await me(ze==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:Ee,conversationId:e})}),kn=Xt.conversationId?.trim();if(kn&&kn!==e){x(wn=>wn.filter(fa=>fa.id!==fn.id)),Re(null),a({view:"conversation",conversationId:kn});return}Xt.flight&&(U.current.add(Xt.flight.invocationId),C(tT(Xt.flight,e,z??"")),E([]),k(null))}catch(Xt){x(kn=>kn.filter(wn=>wn.id!==fn.id)),Re(null),$(Xt instanceof Error?Xt.message:String(Xt))}finally{Be(!1)}},Xa=async()=>{const ne=Te.trim();ne&&(pe(""),await Yr(ne))},Uc=async()=>{if(z)try{await me("/api/agents/"+encodeURIComponent(z)+"/interrupt",{method:"POST",body:JSON.stringify({})})}catch{}},Ia=Ht.tone==="working"||Ht.tone==="pending",Nr=B?xs?"steer":Ie:"tell",Fs=B?"Reply — or type / to route, @ to mention an agent, ? to ask a question":`Message ${Yt}...`,ce=!Te.trim()&&Ia,ke=Lc(),Ge=m.useCallback((ne,ve)=>{const Ee=window.getSelection()?.toString().trim(),Fe=[];Ee&&(Fe.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>{On(Ee)}}),Fe.push({kind:"separator"})),Fe.push({kind:"action",label:"Copy Message",onSelect:()=>{On(ve.body)}}),ve.actorName&&!Yb(ve,Se)&&Fe.push({kind:"action",label:"Copy Agent ID",onSelect:()=>{On(ve.actorName??"")}}),Fe.push({kind:"separator"}),Fe.push({kind:"action",label:"Copy Message ID",onSelect:()=>{On(ve.id)}}),ke(ne,Fe)},[Se,ke]),Qe=async(ne,ve)=>{const Ee=`@${ve.agentId} `,Fe=Te.trim();if(Fe){pe(""),await Yr(`${Ee}${Fe}`,{forceMode:"tell"});return}pe(Ee),I.current?.focus()},St=m.useMemo(()=>g?g.participantIds.filter(ne=>ne!=="operator").slice(0,4).map(ne=>{const ve=f.find(Ee=>Ee.id===ne);return{id:ne,name:ve?.name??ne}}):[],[g,f]),Ct=m.useMemo(()=>{const ne=q.filter(ve=>ve.kind==="channel"||ve.id.startsWith("channel.")).map(ve=>uP(ve)).filter(ve=>ve.trim().length>0);return[...new Set(ne)].sort((ve,Ee)=>ve.localeCompare(Ee))},[q]),sn=m.useCallback(async()=>{if(!z||!B)return;const ne=Eae(st),ve=`channel.${ne}`,Ee=yt.trim(),Fe=Ee?`@${z} ${Ee}`:`@${z} Continue this in #${ne}.`;te(!0),xt(null);try{const ze=await me("/api/send",{method:"POST",body:JSON.stringify({body:Fe,conversationId:ve})});if((ze.unresolvedTargets?.length??0)>0){xt(ze.targetDiagnostic?.detail??`Couldn't resolve ${ze.unresolvedTargets.join(", ")} for this channel.`);return}ut(!1),Mt(""),ht(""),a({view:"channels",channelId:ve})}catch(ze){xt(ze instanceof Error?ze.message:String(ze))}finally{te(!1)}},[yt,st,z,B,a]);return s.jsx("div",{className:`s-thread-layout${r?" s-thread-layout--embedded":""}`,children:s.jsxs("div",{className:"s-thread-center",children:[!r&&s.jsx(Ga,{slot:"conversation",fallback:{view:"inbox"},navigate:a}),!r&&s.jsxs("div",{className:"s-thread-center-header",onClick:()=>B?kt(a,{view:"agent-info",conversationId:e},{returnTo:c}):void 0,style:B?{cursor:"pointer"}:void 0,onContextMenu:ne=>{const ve=[{kind:"action",label:"Copy Title",onSelect:()=>{On(ds)}}];z&&ve.push({kind:"action",label:"Copy Agent ID",onSelect:()=>{On(z)}}),ve.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>{On(e)}}),ke(ne,ve)},children:[s.jsxs("div",{className:"s-thread-center-header-info",children:[s.jsx("span",{className:"s-thread-center-header-name",children:ds}),s.jsxs("div",{className:"s-thread-center-header-eyebrow",children:[s.jsx("span",{className:"s-thread-center-header-kicker",children:ws}),js&&s.jsx("span",{className:"s-thread-center-header-time",title:Mm(js),children:Ae(js)})]})]}),s.jsxs("div",{className:"s-thread-center-header-right",children:[ua.length>0&&s.jsx("div",{className:"s-thread-center-header-chips",children:ua.map((ne,ve)=>s.jsx("span",{className:"s-thread-center-chip",title:ne.title,children:ne.label},`${ne.label}-${ve}`))}),!r&&B&&z&&s.jsx("button",{type:"button",className:"s-btn s-btn-sm s-thread-add-channel-trigger",onClick:ne=>{ne.stopPropagation(),xt(null),ut(ve=>{const Ee=!ve;return Ee&&st.trim().length===0&&ht(Ct[0]??""),Ee})},children:"Add to channel"}),St.length>0&&s.jsxs("div",{className:"s-thread-center-avatars",children:[St.map(ne=>s.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:qt(ne.name)},title:ne.name,children:ne.name[0]?.toUpperCase()??"?"},ne.id)),s.jsx("span",{className:"s-thread-center-participant-count",children:dn})]})]})]}),!r&&B&&z&&ct&&s.jsxs("form",{className:"s-thread-add-channel",onSubmit:ne=>{ne.preventDefault(),sn()},children:[s.jsxs("div",{className:"s-thread-add-channel-row",children:[s.jsxs("div",{className:"s-thread-add-channel-field",children:[s.jsx("label",{className:"s-thread-add-channel-label",htmlFor:"thread-add-channel-input",children:"Channel"}),s.jsx("input",{id:"thread-add-channel-input",className:"s-thread-add-channel-input",value:st,onChange:ne=>ht(ne.target.value),placeholder:"ops",list:"thread-add-channel-suggestions",autoFocus:!0}),s.jsx("datalist",{id:"thread-add-channel-suggestions",children:Ct.map(ne=>s.jsx("option",{value:ne},ne))})]}),s.jsxs("div",{className:"s-thread-add-channel-actions",children:[s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>{ut(!1),xt(null)},disabled:Y,children:"Cancel"}),s.jsx("button",{type:"submit",className:"s-btn s-btn-primary s-btn-sm",disabled:Y||st.trim().length===0,children:Y?"Adding…":"Add"})]})]}),s.jsxs("div",{className:"s-thread-add-channel-field",children:[s.jsx("label",{className:"s-thread-add-channel-label",htmlFor:"thread-add-channel-note",children:"Intro note"}),s.jsx("textarea",{id:"thread-add-channel-note",className:"s-thread-add-channel-textarea",value:yt,onChange:ne=>Mt(ne.target.value),placeholder:`Optional note for ${Yt}`,rows:2})]}),s.jsxs("div",{className:"s-thread-add-channel-hint",children:["Scout will send a channel message that mentions ",Yt,", so the broker adds them to the shared thread."]}),Rt&&s.jsx("div",{className:"s-thread-add-channel-error",children:Rt})]}),Qn&&s.jsxs("div",{className:"s-thread-pinned-ask",children:[s.jsx("div",{className:"s-thread-pinned-ask-label",children:"Pinned ask · Awaiting operator"}),s.jsx("div",{className:"s-thread-pinned-ask-body",children:Qn.task}),s.jsxs("div",{className:"s-thread-pinned-ask-routing",children:[s.jsx("span",{children:Qn.agentName??br(Qn.agentId)??Qn.agentId}),s.jsx("span",{className:"s-thread-pinned-ask-routing-arrow",children:"→"}),s.jsx("span",{children:"You"})]}),s.jsxs("div",{className:"s-thread-pinned-ask-actions",children:[s.jsx("button",{type:"button",className:"s-ops-btn s-ops-btn--primary",onClick:()=>{I.current?.focus()},children:"Answer"}),s.jsx("button",{type:"button",className:"s-ops-btn",children:"Defer"}),s.jsx("button",{type:"button",className:"s-ops-btn",children:"Route"})]}),s.jsx("div",{className:"s-thread-pinned-ask-strip"})]}),Ht.showStrip&&s.jsxs("div",{className:`s-thread-status s-thread-status--${Ht.tone}`,"aria-live":"polite",children:[s.jsx("span",{className:"s-thread-status-dot",style:{background:Fae(Ht,X?.state??null)}}),s.jsxs("div",{className:"s-thread-status-copy",children:[s.jsx("span",{className:"s-thread-status-label",children:Ht.label}),s.jsx("span",{className:"s-thread-status-detail",children:Ht.detail})]})]}),!r&&B&&X&&(X.harnessSessionId||X.harnessLogPath||Q?.activeSessionId)&&s.jsxs("details",{className:"s-thread-meta-disclosure",children:[s.jsx("summary",{className:"s-thread-meta-toggle",children:"Session details"}),s.jsxs("div",{className:"s-thread-meta-block",children:[Q?.activeSessionId&&s.jsxs("div",{className:"s-thread-meta-row",children:[s.jsx("span",{className:"s-thread-meta-row-label",children:"Session ID"}),s.jsx("span",{className:"s-thread-meta-row-value s-thread-meta-row-value--accent",title:Q.activeSessionId,children:Q.activeSessionId.slice(0,8)})]}),Q?.resumeCommand&&s.jsxs("div",{className:"s-thread-meta-row",children:[s.jsx("span",{className:"s-thread-meta-row-label",children:"Takeover"}),s.jsx("span",{className:"s-thread-meta-row-value",children:s.jsx("button",{type:"button",className:"s-thread-meta-takeover-btn",title:Q.resumeCommand,onClick:()=>{ef({command:Q.resumeCommand,cwd:Q.resumeCwd,agentId:z}).then(()=>kt(a,{view:"terminal",agentId:z??void 0},{returnTo:c})),$e(!0)},children:be?"Going…":`Takeover — ${Q.resumeCommand}`})})]}),Q?.activeSessionId&&s.jsxs("div",{className:"s-thread-meta-row",children:[s.jsx("span",{className:"s-thread-meta-row-label",children:"Vantage"}),s.jsx("span",{className:"s-thread-meta-row-value s-thread-meta-actions",children:s.jsx(dg,{agentId:z,className:"s-thread-meta-vantage-btn",statusClassName:"s-thread-meta-vantage-status",label:"Open in Vantage",openingLabel:"Opening…"})})]}),X.harnessSessionId&&s.jsxs("div",{className:"s-thread-meta-row",children:[s.jsx("span",{className:"s-thread-meta-row-label",children:"Harness Session"}),s.jsx("span",{className:"s-thread-meta-row-value",children:X.harnessSessionId})]}),X.harnessLogPath&&s.jsxs("div",{className:"s-thread-meta-row",children:[s.jsx("span",{className:"s-thread-meta-row-label",children:"Harness Log"}),s.jsx("span",{className:"s-thread-meta-row-value",children:X.harnessLogPath})]})]})]}),P&&s.jsx("p",{className:"s-thread-error",children:P}),s.jsxs("div",{className:"s-thread-feed",children:[s.jsx("div",{className:"s-thread-feed-spacer"}),y.length===0?s.jsxs("div",{className:"s-thread-empty",children:[s.jsx("div",{className:"s-thread-empty-glyph","aria-hidden":"true",children:B?"@":"#"}),s.jsx("p",{children:ds}),s.jsx("p",{children:B?"No messages yet. Use Tell for quick updates or Ask to create owned work with a reply.":"No messages yet. Start the thread below."}),(Xn||g?.currentBranch)&&s.jsxs("div",{className:"s-thread-empty-chips",children:[Xn&&s.jsx("span",{className:"s-thread-empty-chip",children:Xn}),g?.currentBranch&&s.jsx("span",{className:"s-thread-empty-chip",children:g.currentBranch})]})]}):y.map((ne,ve)=>{const Ee=Yb(ne,Se),Fe=Pae(ne),ze=Fe?"scout.dispatch":ne.class,it=Tae(ze),fn=ze==="status",Xt=ve===0||!cP(y[ve-1]?.createdAt,ne.createdAt),kn=Mm(ne.createdAt),wn=Ee?null:Lae(ne,f,z),fa=Ee?Se.toLowerCase():wn?.handle??null;return s.jsxs("div",{className:["s-thread-feed-block",Ee&&"s-thread-feed-block--you",Xt&&"s-thread-feed-block--full-width"].filter(Boolean).join(" "),children:[Xt&&s.jsxs("div",{className:"s-thread-day-divider","aria-label":qb(ne.createdAt),children:[s.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"}),s.jsx("span",{className:"s-thread-day-label",children:qb(ne.createdAt)}),s.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"})]}),s.jsx("article",{id:`msg-${ne.id}`,className:["s-thread-msg",Ee&&"s-thread-msg--you",fn&&"s-thread-msg--tool"].filter(Boolean).join(" "),"data-class":ze,onContextMenu:Zn=>Ge(Zn,ne),children:s.jsxs("div",{className:"s-thread-msg-card s-thread-msg-card--avatar-row",children:[(()=>{const Zn=!Ee&&wn?()=>kt(a,{view:"agent-info",conversationId:ps(wn.id)},{returnTo:c}):null,sf=(Ee?Se[0]:ne.actorName?.[0]??"?").toUpperCase(),af={"--size":"28px",background:qt(Ee?Se:ne.actorName??"?")};return Zn?s.jsx("button",{type:"button",className:"s-ops-avatar s-thread-msg-avatar s-thread-msg-avatar--nav",style:af,onClick:Zn,"aria-label":`View profile for ${ne.actorName??"agent"}`,title:`View profile for ${ne.actorName??"agent"}`,children:sf}):s.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:af,children:sf})})(),s.jsxs("div",{className:"s-thread-msg-card-content",children:[s.jsxs("div",{className:"s-thread-msg-header",children:[s.jsxs("div",{className:"s-thread-msg-meta",children:[!Ee&&wn?s.jsx("button",{type:"button",className:"s-thread-msg-actor s-thread-msg-actor--nav",onClick:()=>kt(a,{view:"agent-info",conversationId:ps(wn.id)},{returnTo:c}),title:`View profile for ${ne.actorName}`,children:ne.actorName}):s.jsx("span",{className:"s-thread-msg-actor",children:Ee?Se:ne.actorName}),fa&&s.jsxs("span",{className:"s-thread-msg-handle",children:["@",fa]}),it&&s.jsx("span",{className:"s-thread-msg-kind",children:it})]}),s.jsx("span",{className:"s-thread-msg-time",title:kn,children:Ae(ne.createdAt)}),s.jsx("button",{type:"button",className:"s-thread-msg-permalink","aria-label":"Copy link to message",title:"Copy link to message",onClick:()=>{const Zn=`${window.location.origin}${window.location.pathname}#msg-${ne.id}`;navigator.clipboard.writeText(Zn)},children:s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M6.5 9.5a2.5 2.5 0 0 0 3.54 0l2.12-2.12a2.5 2.5 0 0 0-3.54-3.54l-.7.7"}),s.jsx("path",{d:"M9.5 6.5a2.5 2.5 0 0 0-3.54 0L3.84 8.62a2.5 2.5 0 0 0 3.54 3.54l.7-.7"})]})})]}),s.jsx("div",{className:"s-thread-msg-body",title:kn,children:s.jsx(Gw,{text:ne.body})}),s.jsx(CP,{message:ne}),Fe&&Fe.candidates.length>0&&s.jsx("div",{className:"s-thread-dispatch",children:Fe.candidates.map(Zn=>s.jsxs("button",{type:"button",className:"s-thread-dispatch-tile",onClick:()=>{Qe(Fe,Zn)},children:[s.jsxs("span",{className:"s-thread-dispatch-tile-id",children:["@",Zn.agentId]}),s.jsx("span",{className:"s-thread-dispatch-tile-state",children:Zn.endpointState}),s.jsx("span",{className:"s-thread-dispatch-tile-meta",children:[Zn.workspace,Zn.node,Zn.projectRoot].filter(Boolean).join(" · ")||Zn.displayName})]},Zn.agentId))})]})]})})]},ne.id)}),Ht.showTyping&&s.jsx("div",{className:"s-thread-feed-block",children:s.jsx("div",{className:"s-thread-msg","aria-live":"polite",children:s.jsxs("div",{className:Ue,children:[s.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:{"--size":"28px",background:qt(Yt)},children:Yt[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"s-thread-msg-card-content",children:[s.jsxs("div",{className:"s-thread-msg-header",children:[s.jsxs("div",{className:"s-thread-msg-meta",children:[s.jsx("span",{className:"s-thread-msg-actor",children:Yt}),s.jsx("span",{className:He,children:Rs})]}),s.jsx("span",{className:"s-thread-msg-time",title:w?.startedAt?Mm(w.startedAt):"now",children:w?.startedAt?Ae(w.startedAt):"now"}),Ln&&s.jsx("button",{type:"button",className:"s-thread-msg-dismiss","aria-label":"Dismiss stale turn",title:"Dismiss stale turn",onClick:ge,children:s.jsx(qae,{})})]}),s.jsxs("div",{className:"s-thread-msg-working-body",children:[s.jsxs("div",{className:nn,children:[Ln?s.jsx("span",{className:Lt,"aria-hidden":"true"}):s.jsx("span",{className:ca,"aria-hidden":"true"}),s.jsxs("div",{className:"s-thread-turn-snapshot-main",children:[s.jsx("span",{className:"s-thread-turn-snapshot-label",children:"Latest"}),s.jsx("span",{className:"s-thread-msg-working-copy",children:de.latest})]})]}),s.jsxs("dl",{className:"s-thread-turn-snapshot-stats",children:[s.jsxs("div",{className:"s-thread-turn-snapshot-stat",children:[s.jsx("dt",{children:"Signals"}),s.jsx("dd",{children:de.signalsLabel})]}),s.jsxs("div",{className:"s-thread-turn-snapshot-stat",children:[s.jsx("dt",{children:"Elapsed"}),s.jsx("dd",{children:de.elapsedLabel})]}),s.jsxs("div",{className:"s-thread-turn-snapshot-stat",children:[s.jsx("dt",{children:"Last"}),s.jsx("dd",{children:de.lastSignalLabel})]})]})]})]})]})})}),s.jsx("div",{ref:H})]}),Ht.showTyping&&s.jsxs("div",{className:bs,children:[s.jsx("div",{className:"s-thread-presence-line-avatars",children:s.jsx("div",{className:"s-ops-avatar",style:{"--size":"20px",background:qt(Yt)},children:Yt[0]?.toUpperCase()??"?"})}),s.jsx("span",{className:"s-thread-presence-line-label",children:Gn}),s.jsx("div",{className:Wt})]}),s.jsx("form",{className:"s-thread-compose",onSubmit:ne=>{ne.preventDefault(),Xa()},children:s.jsxs("div",{className:"s-thread-compose-shell",children:[_e.open&&Pe.length>0&&s.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Slash commands",children:[s.jsx("div",{className:"s-thread-compose-suggest-label",children:"Slash commands"}),Pe.map((ne,ve)=>s.jsxs("button",{type:"button",role:"option","aria-selected":ve===_e.index,className:["s-thread-compose-suggest-item",ve===_e.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:Ee=>{Ee.preventDefault(),Ot(ne)},onMouseEnter:()=>Ne(Ee=>({...Ee,index:ve})),children:[s.jsx("span",{className:"s-thread-compose-suggest-cmd",children:ne.label}),s.jsx("span",{className:"s-thread-compose-suggest-desc",children:ne.description})]},ne.command))]}),Oe.open&&We.length>0&&s.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Mention agents",children:[s.jsx("div",{className:"s-thread-compose-suggest-label",children:"Mention agent"}),We.map((ne,ve)=>s.jsxs("button",{type:"button",role:"option","aria-selected":ve===Oe.index,className:["s-thread-compose-suggest-item",ve===Oe.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:Ee=>{Ee.preventDefault(),jt(ne)},onMouseEnter:()=>Ce(Ee=>({...Ee,index:ve})),children:[s.jsx("span",{className:"s-ops-avatar s-thread-compose-suggest-avatar",style:{"--size":"20px",background:qt(ne.name)},children:ne.name[0]?.toUpperCase()??"?"}),s.jsxs("span",{className:"s-thread-compose-suggest-cmd",children:["@",ne.handle]}),s.jsx("span",{className:"s-thread-compose-suggest-desc",children:ne.name})]},ne.id))]}),s.jsxs("div",{className:"s-thread-compose-row",children:[s.jsx("textarea",{ref:I,className:"s-thread-compose-input",placeholder:Fs,value:Te,onChange:ne=>{const ve=ne.target.value;pe(ve),at(ve,ne.target.selectionStart)},onSelect:ne=>{const ve=ne.currentTarget;at(ve.value,ve.selectionStart)},onBlur:()=>{setTimeout(rt,120)},onKeyDown:ne=>{if(_e.open&&Pe.length>0||Oe.open&&We.length>0){if(ne.key==="ArrowDown"){ne.preventDefault(),_e.open?Ne(Ee=>({...Ee,index:(Ee.index+1)%Pe.length})):Oe.open&&Ce(Ee=>({...Ee,index:(Ee.index+1)%We.length}));return}if(ne.key==="ArrowUp"){ne.preventDefault(),_e.open?Ne(Ee=>({...Ee,index:(Ee.index-1+Pe.length)%Pe.length})):Oe.open&&Ce(Ee=>({...Ee,index:(Ee.index-1+We.length)%We.length}));return}if(ne.key==="Escape"){ne.preventDefault(),rt();return}if(ne.key==="Enter"||ne.key==="Tab"){if(ne.shiftKey)return;if(ne.preventDefault(),_e.open){const Ee=Pe[_e.index]??Pe[0];Ee&&Ot(Ee)}else if(Oe.open){const Ee=We[Oe.index]??We[0];Ee&&jt(Ee)}return}}ne.key!=="Enter"||ne.shiftKey||ne.nativeEvent.isComposing||(ne.preventDefault(),!Xe&&Te.trim()&&Xa())},rows:1}),s.jsx(Jw,{onAppend:ne=>pe(ve=>ve.trim()?`${ve.trimEnd()} ${ne}`:ne)}),ce?s.jsx("button",{type:"button",className:"s-thread-compose-send s-thread-compose-send--stop",onClick:()=>{Uc()},"aria-label":"Stop agent",children:s.jsx(Hae,{})}):s.jsx("button",{type:"submit",className:"s-thread-compose-send",disabled:Xe||!Te.trim(),"aria-label":Nr==="ask"?"Ask agent":Nr==="steer"?"Steer agent":B?"Tell agent":"Send message",children:s.jsx(Vae,{})})]})]})})]})})}function AP(e){if(!e)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null}function Gae(e){return e?e.length<=12?e:e.slice(0,12):null}function Zae(e){if(!e)return null;const t=Math.max(0,Date.now()-e);return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function Kae(e){return e.includes("codex")?"Codex":e.includes("claude")?"Claude Code":e.replace(/[-_]/g," ")}function TP(e){return e.name??Gae(e.externalSessionId)??e.id.replace(/^.*:/,"")}function Yae(e){return e.status??e.role??e.type??"observed"}function Xae(e,t,n){return t.filter(a=>a.kind==="spawned"&&a.toId===e.id).map(a=>n.get(a.fromId)).filter(a=>!!a).map(TP)}function Qae(e,t){return t.find(n=>n.assigneeId===e.id)??null}function Jae(e){return e?e.observations.map(t=>({source:t.source,observedAt:AP(t.observedAt),topology:t.topology})):[]}function MP({topology:e,size:t="full",title:n="Internal topology",maxAgents:a=t==="rail"?5:8,maxTasks:r=t==="rail"?3:5,showEmpty:o=!1}){const[c,u]=m.useState(null),[h,f]=m.useState(!1);m.useEffect(()=>{if(e)return;let y=!1;return me("/api/topology/snapshot").then(x=>{y||(u(x),f(!1))}).catch(()=>{y||f(!0)}),()=>{y=!0}},[e]);const g=m.useMemo(()=>e?[{source:e.source,observedAt:AP(e.observedAt),topology:e}]:Jae(c),[c,e]),v=m.useMemo(()=>g.reduce((y,x)=>(y.sources+=1,y.agents+=x.topology.agents.length,y.subagents+=x.topology.agents.filter(w=>w.role==="subagent").length,y.tasks+=x.topology.tasks.length,y.spawned+=x.topology.relationships.filter(w=>w.kind==="spawned").length,y),{sources:0,agents:0,subagents:0,tasks:0,spawned:0}),[g]);return g.length===0?!o&&!h?null:s.jsxs("section",{className:`s-observed-topology s-observed-topology--${t}`,children:[s.jsx("header",{className:"s-observed-topology-head",children:s.jsxs("div",{children:[s.jsx("div",{className:"s-observed-topology-kicker",children:"Harness observed"}),s.jsx("h3",{children:n})]})}),s.jsx("div",{className:"s-observed-topology-empty",children:h?"Topology is unavailable right now.":"No Codex or Claude Code internal agent family observed yet."})]}):s.jsxs("section",{className:`s-observed-topology s-observed-topology--${t}`,children:[s.jsxs("header",{className:"s-observed-topology-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"s-observed-topology-kicker",children:"Harness observed"}),s.jsx("h3",{children:n})]}),s.jsxs("div",{className:"s-observed-topology-counts",children:[s.jsxs("span",{children:[v.subagents," subagents"]}),s.jsxs("span",{children:[v.tasks," tasks"]}),s.jsxs("span",{children:[v.spawned," spawn links"]})]})]}),s.jsx("div",{className:"s-observed-topology-sources",children:g.map(y=>s.jsx(ere,{source:y,maxAgents:a,maxTasks:r},`${y.source}:${y.topology.observedAt}`))})]})}function ere({source:e,maxAgents:t,maxTasks:n}){const{topology:a}=e,r=new Map(a.agents.map(g=>[g.id,g])),o=a.agents.filter(g=>g.role==="subagent"),c=a.agents.filter(g=>g.role==="lead"),u=a.agents.filter(g=>g.role!=="subagent"&&g.role!=="lead"),h=[...c,...o,...u].slice(0,t),f=a.tasks.filter(g=>g.state!=="completed").slice(0,n);return s.jsxs("div",{className:"s-observed-topology-source",children:[s.jsxs("div",{className:"s-observed-topology-source-head",children:[s.jsx("span",{children:Kae(e.source)}),s.jsx("span",{children:Zae(e.observedAt)??"observed"})]}),s.jsx("div",{className:"s-observed-topology-agent-list",children:h.map(g=>{const v=Xae(g,a.relationships,r),y=Qae(g,a.tasks);return s.jsxs("div",{className:"s-observed-topology-agent",children:[s.jsxs("div",{className:"s-observed-topology-agent-main",children:[s.jsx("span",{className:`s-observed-topology-agent-role s-observed-topology-agent-role--${g.role??"observed"}`,children:g.role??"observed"}),s.jsx("span",{className:"s-observed-topology-agent-name",children:TP(g)}),s.jsx("span",{className:"s-observed-topology-agent-status",children:Yae(g)})]}),(v.length>0||y?.title)&&s.jsxs("div",{className:"s-observed-topology-agent-detail",children:[v.length>0&&s.jsxs("span",{children:["spawned by ",v.join(", ")]}),y?.title&&s.jsx("span",{children:y.title})]})]},g.id)})}),f.length>0&&s.jsx("div",{className:"s-observed-topology-task-list",children:f.map(g=>s.jsxs("div",{className:"s-observed-topology-task",children:[s.jsx("span",{children:g.state??"task"}),s.jsx("strong",{children:g.title??g.id.replace(/^.*:/,"")})]},g.id))})]})}async function tre(e){await me("/api/local-path/reveal",{method:"POST",body:JSON.stringify({path:e.path,...e.basePath?{basePath:e.basePath}:{},...e.agentId?{agentId:e.agentId}:{},...e.sessionId?{sessionId:e.sessionId}:{}})})}const RP={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},nre={read:"◎",edit:"✎",bash:"$",grep:"⌕",write:"✎",think:"∿"},sre=20,IP=new Intl.NumberFormat("en-US"),are=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1});function rre(e){const t=Math.floor(e/60),n=Math.floor(e%60);return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function aT(e,t){return e>=Math.max(0,t-sre)}function Lu(e){return typeof e!="number"||!Number.isFinite(e)?null:IP.format(e)}function ji(e){return typeof e!="number"||!Number.isFinite(e)?"—":Math.abs(e)<1e3?IP.format(e):are.format(e).toLowerCase()}function ire(e){if(!Number.isFinite(e)||e<=0)return"0s";if(e<60)return`${Math.round(e)}s`;const t=Math.round(e),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h ${a}m`:a>=10||r===0?`${a}m`:`${a}m ${r}s`}function rT(e){return!!e&&Object.keys(e).length>0}function yx(e){return e.filter(t=>!!t)}function ore(e){const n=e.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n[n.length-1]??e}function lre(e){tre(e).catch(t=>{console.warn("Failed to reveal local path",t)})}function tl({text:e,label:t="Copy",className:n}){const[a,r]=m.useState(!1),o=m.useRef(null);m.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const c=m.useCallback(u=>{u.preventDefault(),u.stopPropagation();const h=e,f=()=>{r(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>r(!1),1100)};navigator.clipboard?.writeText?navigator.clipboard.writeText(h).then(f).catch(()=>{iT(h),f()}):(iT(h),f())},[e]);return s.jsx("button",{type:"button",className:`s-observe-copy-btn${a?" s-observe-copy-btn--copied":""}${n?` ${n}`:""}`,onClick:c,"aria-label":t,title:a?"Copied":t,children:a?s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 11 11",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M2 5.5l2.4 2.4L9 3.4"})}):s.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 11 11",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("rect",{x:"3.4",y:"3.4",width:"6.1",height:"6.1",rx:"1.2"}),s.jsx("path",{d:"M7.6 3.4V2.2a.8.8 0 0 0-.8-.8H2.2a.8.8 0 0 0-.8.8v4.6a.8.8 0 0 0 .8.8h1.2"})]})})}function iT(e){try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}catch(t){console.warn("Clipboard copy failed",t)}}function cre(e){const t=[],n=[e.tool,e.arg].filter(Boolean).join(" ");return n&&t.push(n),e.result&&t.push(Object.entries(e.result).map(([a,r])=>`${a}: ${r}`).join(" · ")),e.diff&&(t.push(`+${e.diff.add}${e.diff.del>0?` -${e.diff.del}`:""}`),e.diff.preview&&t.push(e.diff.preview)),e.stream&&e.stream.length>0&&t.push(e.stream.join(`
161
+ `)),t.join(`
162
+ `)}function ure({event:e}){return s.jsxs("div",{className:"s-observe-block",children:[s.jsx("div",{className:"s-observe-think-label",children:"thinking"}),s.jsxs("div",{className:"s-observe-think-text",children:[s.jsx("span",{className:"s-observe-quoted",children:e.text}),e.live&&s.jsx("span",{className:"s-observe-cursor"})]}),s.jsx(tl,{text:e.text??"",label:"Copy thought"})]})}function dre({preview:e}){const t=e.split(`
163
+ `);return s.jsx("pre",{className:"s-observe-tool-diff-preview",children:t.map((n,a)=>{const r=n[0],o=r==="+"?"add":r==="-"||r==="−"?"del":n.startsWith("@@")?"hunk":"ctx";return s.jsxs("span",{className:`s-observe-diff-line s-observe-diff-line--${o}`,children:[n,a<t.length-1?`
164
+ `:null]},a)})})}function fre({event:e}){const t=nre[e.tool??""]??"▸",n=!!(e.result||e.diff||e.stream);return s.jsxs("div",{className:"s-observe-tool s-observe-block",children:[s.jsxs("div",{className:`s-observe-tool-header${n?" s-observe-tool-header--has-body":""}`,children:[s.jsx("span",{className:"s-observe-tool-glyph",children:t}),s.jsxs("span",{className:"s-observe-tool-cmd",children:[s.jsx("span",{className:"s-observe-tool-cmd-name",children:e.tool})," ",e.arg]})]}),e.result&&s.jsx("div",{className:"s-observe-tool-result",children:Object.entries(e.result).map(([a,r])=>`${a}: ${r}`).join(" · ")}),e.diff&&s.jsxs("div",{className:"s-observe-tool-diff",children:[s.jsxs("div",{className:"s-observe-tool-diff-stats",children:[s.jsxs("span",{className:"s-observe-tool-diff-add",children:["+",e.diff.add]}),e.diff.del>0&&s.jsxs(s.Fragment,{children:[" ",s.jsxs("span",{className:"s-observe-tool-diff-del",children:["−",e.diff.del]})]})]}),s.jsx(dre,{preview:e.diff.preview})]}),e.stream&&s.jsx("pre",{className:"s-observe-tool-stream",children:e.stream.join(`
165
+ `)}),s.jsx(tl,{text:cre(e),label:"Copy tool call"})]})}function hre({event:e}){const t=e.to==="human"?"you":e.to??"?",n=e.answer?`${e.text}
166
+
167
+ ↳ ${e.to??"you"}: ${e.answer}`:e.text??"";return s.jsxs("div",{className:"s-observe-ask s-observe-block",children:[s.jsxs("div",{className:"s-observe-ask-label",children:["↗ ask → ",t]}),s.jsx("div",{className:"s-observe-ask-text",children:s.jsx("span",{className:"s-observe-quoted",children:e.text})}),e.answer&&s.jsxs("div",{className:"s-observe-ask-answer",children:[s.jsxs("span",{className:"s-observe-ask-answer-meta",children:["↳ @",e.to??"you"," · +",(e.answerT??e.t)-e.t,"s"]}),s.jsx("div",{className:"s-observe-ask-answer-text",children:e.answer})]}),s.jsx(tl,{text:n,label:"Copy ask"})]})}function mre({event:e}){const t=e.to==="human"?"you":e.to??"?";return s.jsxs("div",{className:"s-observe-block",children:[s.jsxs("div",{className:"s-observe-message-label",children:["→ message → ",t]}),s.jsx("div",{className:"s-observe-message-text",children:s.jsx(Gw,{text:e.text})}),s.jsx(tl,{text:e.text??"",label:"Copy message"})]})}function pre({event:e}){return s.jsxs("div",{className:"s-observe-note s-observe-block s-observe-block--inline",children:[s.jsx("span",{className:"s-observe-note-icon",children:"✓"}),s.jsx("span",{className:"s-observe-note-text",children:e.text}),s.jsx(tl,{text:e.text??"",label:"Copy note"})]})}function gre({event:e}){const t=e.detail?`${e.text}
168
+ ${e.detail}`:e.text??"";return s.jsxs("div",{className:"s-observe-system s-observe-block",children:[s.jsx("span",{className:"s-observe-system-arrow",children:"▸ "}),e.text,e.detail&&s.jsx("div",{className:"s-observe-system-detail",children:e.detail}),s.jsx(tl,{text:t,label:"Copy system event"})]})}function vre({isFollowing:e,isLive:t,onToggle:n}){return s.jsxs("button",{className:`s-observe-follow-btn${e?" s-observe-follow-btn--on":""}`,onClick:n,title:e?"Pause auto-scroll":"Jump to latest and follow",children:[e?s.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:[s.jsx("rect",{x:"1.5",y:"1",width:"3",height:"8",rx:"1"}),s.jsx("rect",{x:"5.5",y:"1",width:"3",height:"8",rx:"1"})]}):s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:s.jsx("path",{d:"M2 1.5l7 3.5-7 3.5V1.5z"})}),s.jsx("span",{children:e?t?"Live":"Latest":"Follow"})]})}function yre({event:e,prevT:t}){const n=e.t-t,a=RP[e.kind]??"var(--dim)";return s.jsxs("div",{className:"s-observe-row",children:[n>15&&s.jsxs("div",{className:"s-observe-row-gap",children:["+",n,"s"]}),s.jsx("div",{className:"s-observe-row-time",children:rre(e.t)}),s.jsx("span",{className:"s-observe-row-bead",style:{background:a}}),e.kind==="think"&&s.jsx(ure,{event:e}),e.kind==="tool"&&s.jsx(fre,{event:e}),e.kind==="ask"&&s.jsx(hre,{event:e}),e.kind==="message"&&s.jsx(mre,{event:e}),e.kind==="note"&&s.jsx(pre,{event:e}),(e.kind==="system"||e.kind==="boot")&&s.jsx(gre,{event:e})]})}function xre({events:e,followEnd:t}){const n=m.useRef(null),a=m.useRef(t);return m.useLayoutEffect(()=>{if(!t){a.current=!1;return}const r=!a.current;a.current=!0,n.current?.scrollIntoView({behavior:r?"instant":"smooth"})},[e.length,t]),s.jsxs("div",{className:"s-observe-stream",children:[s.jsx("div",{className:"s-observe-spine"}),e.map((r,o)=>s.jsx(yre,{event:r,prevT:o>0?e[o-1].t:0},r.id)),s.jsx("div",{ref:n})]})}function bre({data:e,cursor:t}){const r=e.length;if(r<2)return null;const o=276/(r-1),c=e.map((h,f)=>`${f===0?"M":"L"} ${(f*o).toFixed(1)} ${((1-h)*44).toFixed(1)}`).join(" "),u=t*276;return s.jsxs("svg",{viewBox:"0 0 276 44",style:{width:"100%",height:44,display:"block"},children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"observeCtxFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:.25}),s.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:0})]})}),s.jsx("path",{d:`${c} L 276 44 L 0 44 Z`,fill:"url(#observeCtxFill)"}),s.jsx("path",{d:c,fill:"none",stroke:"var(--accent)",strokeWidth:1.2}),s.jsx("line",{x1:u,y1:0,x2:u,y2:44,stroke:"var(--accent)",strokeWidth:1,opacity:.6,strokeDasharray:"2 3"})]})}function wre({state:e}){const t=e==="created"?"var(--green)":e==="modified"?"var(--accent)":"var(--dim)",n=e==="created"?"+":e==="modified"?"~":"◎";return s.jsx("span",{className:"s-observe-file-glyph",style:{background:"color-mix(in srgb, var(--bg) 70%, black)",border:`1px solid color-mix(in srgb, ${t} 40%, var(--border))`,color:t},children:n})}function Ur({label:e,value:t,detail:n}){return s.jsxs("div",{className:"s-observe-stat",children:[s.jsx("div",{className:"s-observe-stat-label",children:e}),s.jsx("div",{className:"s-observe-stat-value",children:t}),n&&s.jsx("div",{className:"s-observe-stat-detail",children:n})]})}function ej({path:e,basePath:t,agentId:n,sessionId:a,className:r,children:o}){const{openFilePreview:c}=qe(),u=e.startsWith("/")||e.startsWith("~/")?e:t?`${t.replace(/\/$/,"")}/${e}`:e;return s.jsxs("span",{className:"s-observe-path-link-group",children:[s.jsx("button",{type:"button",className:r,title:`Preview ${e} in Scout`,onClick:()=>c(u),children:o}),s.jsx("button",{type:"button",className:"s-observe-path-link-external",title:`Reveal ${e} in OS`,"aria-label":"Reveal in OS",onClick:()=>lre({path:e,basePath:t,agentId:n,sessionId:a}),children:s.jsx(Tc,{size:11,strokeWidth:1.6})})]})}function jre({path:e,basePath:t,agentId:n,sessionId:a}){return s.jsxs("div",{className:"s-observe-source",children:[s.jsx("span",{className:"s-observe-source-label",children:"Source"}),s.jsx(ej,{path:e,basePath:t,agentId:n,sessionId:a,className:"s-observe-source-link",children:ore(e)})]})}function xx({rows:e,agentId:t,sessionId:n}){return e.length===0?null:s.jsx("div",{className:"s-observe-detail-list",children:e.map(a=>{const r=`s-observe-detail-value s-observe-detail-value--${a.tone??"default"}${a.wrap?" s-observe-detail-value--wrap":""}`;return s.jsxs("div",{className:"s-observe-detail-row",children:[s.jsx("div",{className:"s-observe-detail-label",children:a.label}),s.jsxs("div",{className:"s-observe-detail-value-wrap",children:[a.actionPath?s.jsx(ej,{path:a.actionPath,basePath:a.actionBasePath,agentId:t,sessionId:n,className:`${r} s-observe-detail-link`,children:a.value}):s.jsx("div",{className:r,title:a.title,children:a.value}),s.jsx(tl,{text:a.actionPath??a.value,label:`Copy ${a.label.toLowerCase()}`,className:"s-observe-copy-btn--inline"})]})]},a.label)})})}function Nre({events:e,duration:t,cursor:n,onCursor:a}){const r=m.useRef(null),o=m.useCallback(u=>{const h=r.current.getBoundingClientRect(),f=u.clientX-h.left;a(Math.max(0,Math.min(t,f/h.width*t)))},[t,a]),c=m.useCallback(u=>{if(t<=0)return;const h=t*.01,f=t*.05;let g=n;switch(u.key){case"ArrowLeft":g=n-(u.shiftKey?f:h);break;case"ArrowRight":g=n+(u.shiftKey?f:h);break;case"PageDown":g=n-f;break;case"PageUp":g=n+f;break;case"Home":g=0;break;case"End":g=t;break;default:return}u.preventDefault(),a(Math.max(0,Math.min(t,g)))},[n,t,a]);return s.jsx("div",{className:"s-observe-track-wrap",children:s.jsxs("div",{ref:r,className:"s-observe-track",onClick:o,onKeyDown:c,role:"slider",tabIndex:t>0?0:-1,"aria-label":"Session timeline","aria-valuemin":0,"aria-valuemax":t,"aria-valuenow":Math.max(0,Math.min(t,n)),children:[e.map(u=>{const h=u.kind==="tool"?6:u.kind==="think"?4:5;return s.jsx("span",{className:"s-observe-track-tick",style:{left:`${u.t/t*100}%`,top:h===6?-2:-1,height:h,background:RP[u.kind]??"var(--dim)"}},u.id)}),s.jsx("div",{className:"s-observe-track-played",style:{width:`${n/t*100}%`}}),s.jsx("span",{className:"s-observe-track-cursor",style:{left:`${n/t*100}%`}})]})})}function oT(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function kre(e,t){const n=t-e;return n<6e4?`${Math.floor(n/1e3)}s`:n<36e5?`${Math.floor(n/6e4)}m`:`${Math.floor(n/36e5)}h ${Math.floor(n%36e5/6e4)}m`}function Sre({catalog:e,sessionId:t,agentId:n}){const{navigate:a,route:r}=qe(),[o,c]=m.useState(!1),u=e.sessions.find(x=>x.id===e.activeSessionId),h=e.sessions.filter(x=>x.id!==e.activeSessionId&&x.endedAt).sort((x,w)=>(w.endedAt??0)-(x.endedAt??0)).slice(0,5),f=e.activeSessionId??t,g=f?f.slice(0,8):null,v=m.useCallback(()=>{e.resumeCommand&&(ef({command:e.resumeCommand,cwd:e.resumeCwd,agentId:n}).then(()=>{kt(a,{view:"terminal",agentId:n},{returnTo:r})}),c(!0))},[e.resumeCommand,e.resumeCwd,a,r,n]),y=m.useCallback(()=>{a({view:"messages",conversationId:`dm.operator.${n}`})},[a,n]);return s.jsxs("div",{className:"s-observe-session-header",children:[s.jsx("div",{className:"s-observe-session-active",children:s.jsxs("div",{className:"s-observe-session-row",children:[g&&s.jsx("span",{className:"s-observe-session-id",title:f??void 0,children:g}),u&&s.jsxs("span",{className:"s-observe-session-time",children:["started ",oT(u.startedAt)]}),s.jsx("button",{className:"s-observe-pair-btn",onClick:y,title:"Send messages into the live session without taking the terminal",children:"Pair"}),e.resumeCommand&&s.jsx("button",{className:"s-observe-takeover-btn",onClick:v,title:e.resumeCommand,children:o?"Sent":"Takeover"}),s.jsx(dg,{agentId:n,className:"s-observe-vantage-btn",statusClassName:"s-observe-vantage-status"})]})}),h.length>0&&s.jsxs("div",{className:"s-observe-session-history",children:[s.jsxs("div",{className:"s-observe-session-history-label",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," total"]}),h.map(x=>s.jsxs("div",{className:"s-observe-session-past",children:[s.jsx("span",{className:"s-observe-session-id",children:x.id.slice(0,8)}),s.jsxs("span",{className:"s-observe-session-time",children:[oT(x.startedAt),x.endedAt?` · ${kre(x.startedAt,x.endedAt)}`:""]})]},x.id))]})]})}const Cre={events:[{id:"observe:empty",t:0,kind:"system",text:"No session trace is available for this agent yet.",detail:"Waiting for a live session or readable history file."}],files:[],contextUsage:[],live:!1};function _P({data:e,agentId:t,sessionId:n,showRail:a=!0}){const r=e??Cre,{events:o,files:c,contextUsage:u}=r,h=r.live===!0,[f,g]=m.useState(null);m.useEffect(()=>{if(!t)return;let Q=!1;return me(`/api/agents/${encodeURIComponent(t)}/session-catalog`).then(ae=>{Q||g(ae)}).catch(()=>{}),()=>{Q=!0}},[t]);const v=o.length>0?o[o.length-1].t+30:60,[y,x]=m.useState(v),[w,C]=m.useState(!1),[T,E]=m.useState(1),[S,k]=m.useState(!0),N=m.useRef(v);m.useEffect(()=>{x(Q=>{const ae=N.current;N.current=v;const be=aT(Q,ae);return Q>v||be&&S?v:Q})},[v,S]),m.useEffect(()=>{if(!w)return;const Q=setInterval(()=>{x(ae=>{const be=ae+T;return be>=v?(C(!1),v):be})},100);return()=>clearInterval(Q)},[w,v,T]);const A=o.filter(Q=>Q.t<=y),_=aT(y,v)&&S,P=h&&_,$=m.useCallback(()=>{_?k(!1):(x(v),k(!0))},[_,v]),H=r.metadata,I=H?.session,U=I?.threadPath??null,D=H?.usage,V=o.filter(Q=>Q.kind==="tool").length,Z=o.filter(Q=>Q.kind==="think").length,O=o.filter(Q=>Q.kind==="ask").length,z=o.filter(Q=>Q.kind==="tool"&&Q.tool==="read").length,B=o.filter(Q=>Q.kind==="tool"&&(Q.tool==="edit"||Q.tool==="write")).length,X=o.length>0?o[o.length-1].t:0,W=u&&u.length>0?Math.round((u[u.length-1]??0)*100):null,L=[{label:"Input",value:D?.inputTokens},{label:"Output",value:D?.outputTokens},{label:"Cache hit",value:D?.cacheReadInputTokens},{label:"Cache write",value:D?.cacheCreationInputTokens},{label:"Total",value:D?.totalTokens},{label:"Reasoning",value:D?.reasoningOutputTokens}].filter(Q=>typeof Q.value=="number"),q=yx([typeof D?.assistantMessages=="number"?{label:"Assistant msgs",value:Lu(D.assistantMessages)??"0",tone:"accent"}:null,typeof D?.webSearchRequests=="number"?{label:"Web search",value:Lu(D.webSearchRequests)??"0"}:null,typeof D?.webFetchRequests=="number"?{label:"Web fetch",value:Lu(D.webFetchRequests)??"0"}:null,D?.serviceTier?{label:"Service tier",value:D.serviceTier,tone:"good"}:null,D?.speed?{label:"Speed",value:D.speed}:null,D?.planType?{label:"Plan",value:D.planType}:null]),K=yx([typeof D?.contextWindowTokens=="number"?{label:"Model window",value:`${Lu(D.contextWindowTokens)} tokens`,title:Lu(D.contextWindowTokens)??void 0,tone:"accent"}:null,W!==null?{label:"Derived load",value:`${W}%`,tone:W>=80?"warn":"default"}:null]),ee=yx([I?.model?{label:"Model",value:I.model,tone:"accent"}:null,I?.adapterType?{label:"Adapter",value:I.adapterType}:null,I?.gitBranch?{label:"Branch",value:I.gitBranch}:null,I?.cwd?{label:"Workspace",value:I.cwd,title:I.cwd,wrap:!0,actionPath:I.cwd}:null,I?.entrypoint?{label:"Entrypoint",value:I.entrypoint}:null,I?.cliVersion?{label:"CLI",value:I.cliVersion}:null,I?.permissionMode?{label:"Permissions",value:I.permissionMode}:null,I?.approvalPolicy?{label:"Approval",value:I.approvalPolicy}:null,I?.sandbox?{label:"Sandbox",value:I.sandbox}:null,I?.userType?{label:"User type",value:I.userType}:null,I?.originator?{label:"Originator",value:I.originator}:null,I?.modelProvider?{label:"Provider",value:I.modelProvider}:null,I?.effort?{label:"Effort",value:I.effort}:null,I?.timezone?{label:"Timezone",value:I.timezone}:null,I?.externalSessionId?{label:"External session",value:I.externalSessionId,title:I.externalSessionId,wrap:!0}:null,I?.threadId?{label:"Thread",value:I.threadId,title:I.threadId,wrap:!0}:null,I?.threadPath?{label:"Thread path",value:I.threadPath,title:I.threadPath,wrap:!0,actionPath:I.threadPath,actionBasePath:I.cwd??null}:null,I?.source?{label:"Runtime source",value:I.source}:null]),G=rT(D),re=rT(I);return s.jsxs("div",{className:`s-observe${a?"":" s-observe--content-only"}`,children:[s.jsxs("main",{className:"s-observe-main",children:[U&&s.jsx(jre,{path:U,basePath:I?.cwd??null,agentId:t??null,sessionId:n??null}),s.jsx("div",{className:"s-observe-live-sticky",children:s.jsx(vre,{isFollowing:_,isLive:P,onToggle:$})}),s.jsx(xre,{events:A,followEnd:_})]}),a&&s.jsxs("aside",{className:"s-observe-rail",children:[f&&f.sessions.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Session"}),s.jsx(Sre,{catalog:f,sessionId:n??null,agentId:t})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Trace stats"}),s.jsxs("div",{className:"s-observe-stats",children:[s.jsx(Ur,{label:"Turns",value:ji(I?.turnCount??0)}),s.jsx(Ur,{label:"Tools",value:ji(V)}),s.jsx(Ur,{label:"Thinks",value:ji(Z)}),s.jsx(Ur,{label:"Asks",value:ji(O)}),s.jsx(Ur,{label:"Reads",value:ji(z)}),s.jsx(Ur,{label:"Edits",value:ji(B)}),s.jsx(Ur,{label:"Files",value:ji(c.length)}),s.jsx(Ur,{label:"Window",value:ire(X)})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Agent family"}),s.jsx(MP,{topology:H?.topology??null,title:"Internal agents",size:"rail"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Context window"}),s.jsx(xx,{rows:K,agentId:t??null,sessionId:n??null}),u&&u.length>=2?s.jsxs(s.Fragment,{children:[s.jsx(bre,{data:u,cursor:y/v}),s.jsx("div",{className:"s-observe-ctx-detail",children:"Sparkline shows derived session load across the observed trace."})]}):K.length===0?s.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"}):s.jsx("div",{className:"s-observe-ctx-detail",children:"Exact window metadata is available, but no derived load trace was captured."})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"s-observe-rail-label",children:["Files touched · ",c.length]}),s.jsx("div",{className:"s-observe-files",children:c.map(Q=>s.jsxs("div",{className:`s-observe-file${Q.lastT<=y?" s-observe-file--visible":" s-observe-file--hidden"}`,children:[s.jsx(wre,{state:Q.state}),s.jsx(ej,{path:Q.path,basePath:I?.cwd??null,agentId:t??null,sessionId:n??null,className:"s-observe-file-path",children:Q.path}),s.jsxs("span",{className:"s-observe-file-touches",children:["×",Q.touches]})]},Q.path))})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Usage"}),L.length>0&&s.jsx("div",{className:"s-observe-stats s-observe-stats--usage",children:L.map(Q=>s.jsx(Ur,{label:Q.label,value:ji(Q.value)},Q.label))}),q.length>0?s.jsx(xx,{rows:q,agentId:t??null,sessionId:n??null}):G?null:s.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"s-observe-rail-label",children:"Metadata"}),ee.length>0?s.jsx(xx,{rows:ee,agentId:t??null,sessionId:n??null}):re?null:s.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]})]}),s.jsxs("footer",{className:"s-observe-scrubber",children:[s.jsx("button",{className:"s-observe-play-btn",onClick:()=>C(!w),children:w?"❚❚":"▶"}),s.jsx("button",{className:"s-observe-rewind-btn",onClick:()=>{x(0),C(!1)},children:"⏮"}),s.jsx(Nre,{events:o,duration:v,cursor:y,onCursor:x}),s.jsx("div",{className:"s-observe-speed-group",children:[.5,1,2,4].map(Q=>s.jsxs("button",{className:`s-observe-speed-btn${T===Q?" s-observe-speed-btn--active":""}`,onClick:()=>E(Q),children:[Q,"×"]},Q))})]})]})}function Ere(e,t){if(t.filter(r=>r.name===e.name).length<=1)return{name:e.name,qualifier:null};const a=e.project??e.branch??e.id.replace(/^.*\./,"");return{name:e.name,qualifier:a}}function Hi(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}function Are(e){return e.handle?`@${e.handle.replace(/^@+/,"")}`:null}function tj(e){return e.selector??e.defaultSelector??Are(e)}function Tre(e){const t=[...e].filter(r=>r.kind==="direct"&&!!r.agentId).sort((r,o)=>(o.lastMessageAt??0)-(r.lastMessageAt??0)),n=new Map,a=new Map;for(const r of t){const o=a.get(r.agentId);(!o||Mre(r,o))&&(n.set(r.agentId,r.id),a.set(r.agentId,r))}return{conversationByAgentId:n,sessionByAgentId:a}}function Mre(e,t){const n=ps(e.agentId),a=e.id===n,r=t.id===n;if(a!==r)return a;const o=e.id.startsWith("dm.operator."),c=t.id.startsWith("dm.operator.");if(o!==c)return o;const u=e.lastMessageAt??0,h=t.lastMessageAt??0;return u!==h?u>h:e.id<t.id}const qr={working:0,available:1,offline:2},Fh={key:"target",dir:1},Rre=[{key:"target",label:"Target",sortable:!0},{key:"state",label:"State",sortable:!0},{key:"harness",label:"Harness",sortable:!0},{key:"branch",label:"Branch / cwd",sortable:!0},{key:"sessions",label:"Sessions",sortable:!0},{key:"last",label:"Last",sortable:!0},{key:"actions",label:"Actions",sortable:!1}],Ire=6e4;function pr(e){if(!e)return null;const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function vp(e){const t=e?.trim();return t&&t.replace(/\/+$/,"")||null}function _re(e,t){const n=t.trim().toLowerCase();return n&&n!=="unscoped"&&n!=="unknown"?`project:${n}`:e?`root:${e}`:`project:${n||"unscoped"}`}function lT(e){return!!e?.startsWith("/tmp/")}function nj(e,t){const n=vp(t),a=e?.trim()||pr(n)||"Unscoped";return{key:_re(n,a),title:a,root:n}}function OP(e){const t=vp(e.agent.projectRoot??e.agent.cwd),n=e.agent.project??e.project;return nj(n,t)}function Ore(e){return nj(e.project,e.cwd)}function $re(e){return nj(e.agentName??e.title,e.workspaceRoot)}function yp(e){const t=e?.trim();if(!t)return null;const n=pr(t)??t;return n.endsWith(".jsonl")?n.slice(0,-6):n}function ko(e,t){const n=t?.trim();n&&e.add(n.toLowerCase());const a=yp(n);a&&e.add(a.toLowerCase())}function $P(e){const t=new Set;return ko(t,e.agent.conversationId),ko(t,ps(e.agent.id)),ko(t,e.agent.harnessSessionId),ko(t,e.agent.harnessLogPath),ko(t,e.session?.id),ko(t,e.session?.harnessSessionId),ko(t,e.session?.harnessLogPath),t}function mc(e,t){const n=t?.trim();if(n&&e.has(n.toLowerCase()))return!0;const a=yp(n);return!!(a&&e.has(a.toLowerCase()))}function Pre(e,t){if(e.agentId&&e.agentId===t.agent.id)return!0;const n=$P(t);return mc(n,e.id)||mc(n,e.harnessSessionId)||mc(n,e.harnessLogPath)}function Dre(e,t){const n=$P(t);return mc(n,e.refId)||mc(n,e.sessionId)||mc(n,e.transcriptPath)}function bx(e,t){return`${e}\0${t??""}`}function Lre(e,t){if(!e)return[];const n=new Map;for(const o of e.processes??[]){const c=bx(o.source||"unknown",o.cwd),u=n.get(c);(!u||o.pid<u.pid)&&n.set(c,o)}const a=new Set,r=[];for(const o of e.transcripts??[]){const c=o.source||"unknown",u=bx(c,o.cwd),h=n.get(u)??null;h&&a.add(u);const f=yp(o.sessionId)??yp(o.transcriptPath);if(!f)continue;const g=o.mtimeMs||null;r.push({key:`transcript:${o.transcriptPath}`,refId:f,source:c,project:o.project?.trim()||pr(o.cwd)||pr(o.transcriptPath)||"unknown",cwd:vp(o.cwd),transcriptPath:o.transcriptPath,sessionId:o.sessionId,mtimeMs:o.mtimeMs,size:o.size,status:h||g&&t-g<=Ire?"active":"idle",process:h,lastActivityAt:g})}for(const o of e.processes??[]){const c=o.source||"unknown",u=bx(c,o.cwd);if(a.has(u))continue;const h=vp(o.cwd);r.push({key:`process:${c}:${o.pid}`,refId:`pid-${o.pid}`,source:c,project:pr(h)??"unknown",cwd:h,transcriptPath:null,sessionId:null,mtimeMs:null,size:null,status:"active",process:o,lastActivityAt:null})}return r.sort((o,c)=>{const u=(o.status==="active"?0:1)-(c.status==="active"?0:1);return u!==0?u:(c.lastActivityAt??0)-(o.lastActivityAt??0)||o.project.localeCompare(c.project)})}function PP(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function nl(e){return`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${PP(e)}`}function tf(e){if(!e)return"—";const t=e.replace(/^session[_:-]?/i,"");return t.length>10?t.slice(0,8):t}function zre(e){if(e.length===0)return null;const t={working:0,needs_attention:1,queued:2,failed:3,completed:4},n=[...e].sort((a,r)=>{const o=t[a.status]-t[r.status];return o!==0?o:(r.updatedAt??0)-(a.updatedAt??0)})[0];return(n.summary??n.task??n.statusLabel??"").trim()||null}function Bre(e,t,n){const a=Je(e.state),r=e.project??pr(e.projectRoot)??"Unscoped",o=e.branch??"—",c=Hi(e.harness)??Hi(e.agentClass)??"agent";return{agent:e,status:a,stateLabel:ia(e.state),project:r,branch:o,harness:c,session:t,activeTask:zre(n),activeAskCount:n.length,lastActivityAt:Math.max(0,t?.lastMessageAt??0,e.updatedAt??0)||null}}function Ure(e){return{...e,agents:[],scoutSessions:[],nativeSessions:[],status:"offline",lastActivityAt:null}}function wx(e,t){const n=e.get(t.key);if(n)return t.root&&(!n.root||lT(n.root)&&!lT(t.root))&&(n.root=t.root),n;const a=Ure(t);return e.set(t.key,a),a}function Fre(e){const t=e.agents.some(h=>h.status==="working"),n=e.nativeSessions.some(h=>h.status==="active"),a=e.agents.some(h=>h.status==="available");e.status=t||n?"working":a?"available":"offline";const r=e.agents.map(h=>h.lastActivityAt??0),o=e.scoutSessions.map(h=>h.lastMessageAt??0),c=e.nativeSessions.map(h=>h.lastActivityAt??0),u=Math.max(0,...r,...o,...c);e.lastActivityAt=u||null}function cT(e,t,n){const a=new Map,r=new Map;for(const c of e){const u=OP(c);wx(a,u).agents.push(c),r.set(c.agent.id,u.key)}for(const c of n)wx(a,Ore(c)).nativeSessions.push(c);const o=new Map;for(const c of t){const u=c.agentId?r.get(c.agentId):void 0,h=u?a.get(u)??null:c.workspaceRoot?wx(a,$re(c)):null;if(!h)continue;const f=h,g=o.get(f.key)??new Set;g.has(c.id)||(g.add(c.id),o.set(f.key,g),f.scoutSessions.push(c))}for(const c of a.values())c.agents.sort((u,h)=>{const f=qr[u.status]-qr[h.status];return f!==0?f:(h.lastActivityAt??0)-(u.lastActivityAt??0)||u.agent.name.localeCompare(h.agent.name)}),c.scoutSessions.sort((u,h)=>(h.lastMessageAt??0)-(u.lastMessageAt??0)),c.nativeSessions.sort((u,h)=>{const f=(u.status==="active"?0:1)-(h.status==="active"?0:1);return f!==0?f:(h.lastActivityAt??0)-(u.lastActivityAt??0)}),Fre(c);return[...a.values()].sort((c,u)=>{const h=qr[c.status]-qr[u.status];return h!==0?h:(u.lastActivityAt??0)-(c.lastActivityAt??0)||c.title.localeCompare(u.title)})}function uT(e){const t=Hi(e.harness)??"scout";return{key:`scout:${e.id}`,kind:"scout",status:e.kind,harness:t,label:e.title||e.agentName||e.id,detail:e.preview??e.id,lastActivityAt:e.lastMessageAt,route:{view:"conversation",conversationId:e.id}}}function dT(e){return{key:`native:${e.key}`,kind:"native",status:e.status,harness:e.source,label:tf(e.sessionId??e.refId),detail:e.transcriptPath??e.process?.command??e.cwd,lastActivityAt:e.lastActivityAt,route:e.sessionId||e.transcriptPath?{view:"sessions",sessionId:e.refId}:null}}function Xb(e,t){return e.agent.name.localeCompare(t.agent.name)||e.agent.id.localeCompare(t.agent.id)}function md(e,t){return(e??"").localeCompare(t??"")}function DP(e,t){return(e??0)-(t??0)}function fT(e){return e.branch!=="—"?e.branch:pr(e.agent.cwd??e.agent.projectRoot)??""}function hT(e){return e.status==="active"?0:e.status==="direct"?1:e.status==="idle"?2:3}function Vre(e){return e==="last"||e==="sessions"?-1:1}function Qb(e){const t={native:0,scout:1};return[...e].sort((n,a)=>{const r=t[n.kind]-t[a.kind];return r!==0?r:n.harness.localeCompare(a.harness)||n.key.localeCompare(a.key)})}function mT(e,t,n){let a=0;switch(n.key){case"target":a=md(e.label,t.label);break;case"state":a=hT(e)-hT(t);break;case"harness":a=md(e.harness,t.harness);break;case"branch":a=md(e.kind,t.kind);break;case"sessions":a=0;break;case"last":a=DP(e.lastActivityAt,t.lastActivityAt);break}return a!==0?a*n.dir:Qb([e,t])[0]===e?-1:1}function Hre(e,t,n){let a=0;switch(n.key){case"target":a=Xb(e.row,t.row);break;case"state":a=qr[e.row.status]-qr[t.row.status];break;case"harness":a=md(e.row.harness,t.row.harness);break;case"branch":a=md(fT(e.row),fT(t.row));break;case"sessions":a=e.sessions.length-t.sessions.length;break;case"last":a=DP(e.row.lastActivityAt,t.row.lastActivityAt);break}return a!==0?a*n.dir:Xb(e.row,t.row)}function qre(e,t){return{agents:[...e.agents].sort((n,a)=>Hre(n,a,t)).map(n=>({...n,sessions:[...n.sessions].sort((a,r)=>mT(a,r,t))})),unassignedSessions:[...e.unassignedSessions].sort((n,a)=>mT(n,a,t))}}function Wre(e){const t=new Set,n=new Set,a=[...e.agents].sort(Xb).map(o=>{const c=[];for(const u of e.scoutSessions)t.has(u.id)||Pre(u,o)&&(t.add(u.id),c.push(uT(u)));for(const u of e.nativeSessions)n.has(u.key)||Dre(u,o)&&(n.add(u.key),c.push(dT(u)));return{key:o.agent.id,row:o,sessions:Qb(c)}}),r=Qb([...e.nativeSessions.filter(o=>!n.has(o.key)).map(dT),...e.scoutSessions.filter(o=>!t.has(o.id)).map(uT)]);return{agents:a,unassignedSessions:r}}function Gre(e){return`openscout.agents.projectTree.collapsed:${e}`}function Zre(e){return`openscout.agents.projectTree.sort:${e}`}function Kre(e){return e==="target"||e==="state"||e==="harness"||e==="branch"||e==="sessions"||e==="last"}function Yre(e){if(typeof window>"u")return Fh;try{const t=window.localStorage.getItem(e);if(!t)return Fh;const n=JSON.parse(t);if(n&&typeof n=="object"&&Kre(n.key)&&(n.dir===1||n.dir===-1))return n}catch{return Fh}return Fh}function Xre(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function Qre(e){if(typeof window>"u")return new Set;try{const t=window.localStorage.getItem(e);if(!t)return new Set;const n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(a=>typeof a=="string")):new Set}catch{return new Set}}function Jre(e,t){if(!(typeof window>"u"))try{t.size===0?window.localStorage.removeItem(e):window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function eie({row:e}){return s.jsxs("span",{className:`s-agents-inventory-status s-agents-inventory-status--${e.status}`,children:[s.jsx("span",{className:"s-agents-inventory-status-dot"}),e.stateLabel.toLowerCase()]})}function tie({row:e}){return s.jsxs("span",{className:"s-agents-inventory-agent-cell",children:[s.jsx("span",{className:"s-agents-inventory-agent-name",children:e.agent.name}),s.jsx("span",{className:"s-agents-inventory-agent-id",children:e.agent.handle?`@${e.agent.handle}`:e.agent.id})]})}function nie({row:e}){const t=e.activeTask??e.session?.preview??e.stateLabel;return s.jsx("span",{className:`s-agents-inventory-task${e.activeTask?"":" s-agents-inventory-task--dim"}`,title:t,children:t})}const sie=[{key:"status",label:"Status",cls:"s-agents-inventory-col-status",kind:"text",defaultWidth:108,minWidth:82,sortValue:e=>qr[e.status],render:e=>s.jsx(eie,{row:e})},{key:"agent",label:"Agent",cls:"s-agents-inventory-col-agent",kind:"text",defaultWidth:230,minWidth:150,sortValue:e=>e.agent.name.toLowerCase(),render:e=>s.jsx(tie,{row:e})},{key:"project",label:"Project",cls:"s-atop-col-project",kind:"text",defaultWidth:176,minWidth:96,maxWidth:420,sortValue:e=>e.project.toLowerCase(),render:e=>s.jsx("span",{title:e.agent.projectRoot??void 0,children:e.project})},{key:"task",label:"Current signal",cls:"s-agents-inventory-col-task",kind:"text",defaultWidth:340,minWidth:160,maxWidth:640,sortValue:e=>(e.activeTask??e.session?.preview??"").toLowerCase()||null,render:e=>s.jsx(nie,{row:e})},{key:"harness",label:"Harness",cls:"s-agents-inventory-col-harness",kind:"text",defaultWidth:104,minWidth:76,sortValue:e=>e.harness.toLowerCase(),render:e=>s.jsx("span",{className:nl(e.harness),children:e.harness})},{key:"branch",label:"Branch",cls:"s-agents-inventory-col-branch",kind:"text",defaultWidth:132,minWidth:82,maxWidth:260,sortValue:e=>e.branch==="—"?null:e.branch.toLowerCase(),render:e=>s.jsx("span",{title:e.agent.branch??void 0,children:e.branch})},{key:"active",label:"Active",cls:"s-atop-col-num",kind:"number",defaultWidth:70,minWidth:58,sortValue:e=>e.activeAskCount,render:e=>s.jsx("span",{className:e.activeAskCount>0?"s-atop-col-num s-atop-col-num--green":"s-atop-col-num s-atop-col-num--dim",children:e.activeAskCount||"—"})},{key:"session",label:"Session",cls:"s-agents-inventory-col-session",kind:"text",defaultWidth:96,minWidth:74,sortValue:e=>e.session?.lastMessageAt??null,render:e=>s.jsx("span",{title:e.session?.id??e.agent.harnessSessionId??void 0,children:tf(e.session?.id??e.agent.harnessSessionId)})},{key:"last",label:"Last",cls:"s-atop-col-last",kind:"time",defaultWidth:82,minWidth:64,sortValue:e=>e.lastActivityAt,render:e=>e.lastActivityAt?Ae(e.lastActivityAt):"—"}];function aie(e,t){return t?[e.agent.name,e.agent.handle,e.agent.id,e.agent.selector,e.agent.defaultSelector,e.project,e.agent.projectRoot,e.branch,e.harness,e.activeTask,e.session?.preview,e.session?.id,e.agent.harnessSessionId].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function rie(e,t,n){return n.size>0&&!n.has(e.source)?!1:t?[e.refId,e.sessionId,e.source,e.project,e.cwd,e.transcriptPath,e.process?.command].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function iie(e,t,n){const a=Hi(e.harness)??"scout";return n.size>0&&!n.has(a)?!1:t?[e.id,e.kind,e.title,e.agentName,e.harness,e.harnessSessionId,e.currentBranch,e.preview,e.workspaceRoot].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function oie(e,t){if(!t)return null;const n=t.trim().replace(/^@+/,"");if(!n)return null;const a=e.find(u=>u.id===n);if(a)return a;if(n.split(".").filter(Boolean).length>=3)return null;const o=e.filter(u=>u.handle===n||u.selector===`@${n}`||u.defaultSelector===`@${n}`||u.id.startsWith(`${n}.`)),c=Array.from(new Map(o.map(u=>[u.id,u])).values());return c.length===1?c[0]:null}function lie({catalog:e,agentId:t}){const{navigate:n,route:a}=qe(),[r,o]=m.useState(!1),c=e.activeSessionId?.slice(0,8)??null,u=e.sessions.find(g=>g.id===e.activeSessionId),h=()=>{e.resumeCommand&&(ef({command:e.resumeCommand,cwd:e.resumeCwd,agentId:t}).then(()=>kt(n,{view:"terminal",agentId:t},{returnTo:a})),o(!0))},f=()=>{n({view:"messages",conversationId:ps(t)})};return s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Session"}),s.jsxs("div",{className:"s-profile-facet-value s-profile-facet-value--mono",title:e.activeSessionId??void 0,children:[c,s.jsx("button",{type:"button",className:"s-profile-facet-action s-profile-facet-action--pair",onClick:f,title:"Send messages into the live session without taking the terminal",children:"Pair"}),e.resumeCommand&&s.jsx("button",{type:"button",className:"s-profile-facet-action",onClick:h,title:e.resumeCommand,children:r?"Going…":"Takeover"}),s.jsx(dg,{agentId:t,className:"s-profile-facet-action s-profile-facet-action--vantage",statusClassName:"s-profile-facet-handoff"})]}),u&&s.jsxs("div",{className:"s-profile-facet-detail",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," · started ",Ae(u.startedAt)]})]})}function cie(e){if(e===null)return"age unknown";const t=Math.max(0,Math.round(e/6e4));if(t<60)return`${t}m old`;const n=Math.floor(t/60),a=t%60;return a>0?`${n}h ${a}m old`:`${n}h old`}function uie(e){const t=e.policy.maxTurns>0?e.turnCount/e.policy.maxTurns:0;return Math.max(0,Math.min(100,Math.round(t*100)))}function die(e){return e.policy.maxTurns<=0?`${e.turnCount} turn${e.turnCount===1?"":"s"}`:`${e.turnCount} / ${e.policy.maxTurns} turns`}function fie(e,t){if(e){const n=Ae(e);return n==="now"?"last activity now":`last activity ${n} ago`}return t!==null?`session ${cie(t)}`:"last activity unknown"}function hie({context:e,lastActivityAt:t,resetting:n,onReset:a}){const r=uie(e),o=die(e),c=fie(t,e.sessionAgeMs),u=n||e.currentTurnActive;return s.jsxs("div",{className:"s-profile-facet s-profile-context",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Context"}),s.jsxs("div",{className:"s-profile-context-head",children:[s.jsxs("span",{className:"s-profile-context-metric",children:[r,"% used"]}),s.jsx("button",{type:"button",className:"s-profile-facet-action",disabled:u,onClick:a,title:e.currentTurnActive?"Agent is currently working":"Start a fresh session",children:n?"Starting...":"New"})]}),s.jsx("div",{className:"s-profile-context-gauge","aria-label":`Context load ${r}%`,children:s.jsx("div",{className:"s-profile-context-gauge-fill",style:{width:`${r}%`}})}),s.jsxs("div",{className:"s-profile-facet-detail",title:`${o} · ${c}`,children:[o," · ",c]})]})}function mie({agent:e,fleet:t,navigate:n}){const a=m.useMemo(()=>t?t.activity.filter(o=>o.agentId===e.id||o.actorId===e.id).slice(0,6):[],[t,e.id]),r=m.useMemo(()=>t?t.recentCompleted.filter(o=>o.agentId===e.id).slice(0,4):[],[t,e.id]);return a.length===0&&r.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx(pd,{label:"Activity"}),s.jsx("div",{className:"s-profile-work",children:s.jsxs("div",{className:"s-profile-activity-feed",children:[r.map(o=>s.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{o.conversationId&&n({view:"agents",agentId:e.id,conversationId:o.conversationId})},children:[s.jsx("div",{className:"s-profile-activity-dot s-profile-activity-dot--done"}),s.jsxs("div",{className:"s-profile-activity-body",children:[s.jsx("div",{className:"s-profile-activity-title",children:o.summary??o.task}),s.jsxs("div",{className:"s-profile-activity-meta",children:[o.status==="completed"?"completed":o.status,o.completedAt&&` · ${Ae(o.completedAt)}`]})]})]},o.invocationId)),a.map(o=>s.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{o.conversationId&&n({view:"agents",agentId:e.id,conversationId:o.conversationId})},children:[s.jsx("div",{className:"s-profile-activity-dot"}),s.jsxs("div",{className:"s-profile-activity-body",children:[s.jsx("div",{className:"s-profile-activity-title",children:o.title??o.summary??o.kind}),s.jsxs("div",{className:"s-profile-activity-meta",children:[o.kind.replace(/_/g," "),o.actorName&&` · ${o.actorName}`,` · ${Ae(o.ts)}`]})]})]},o.id))]})})]})}function pd({label:e,right:t,rightClassName:n}){return s.jsxs("div",{className:"s-profile-section-rule",children:[s.jsx("span",{className:"s-profile-section-rule-label",children:e}),s.jsx("span",{className:"s-profile-section-rule-line"}),t&&s.jsx("span",{className:`s-profile-section-rule-right${n?` ${n}`:""}`,children:t})]})}function pie({messages:e,navigate:t,conversationId:n,agentId:a}){const r=e.slice(-8).reverse();return r.length===0?null:s.jsxs("div",{className:"s-profile-signals",children:[s.jsx(pd,{label:"Recent signal",right:"last 1h"}),s.jsx("div",{className:"s-profile-signal-list",children:r.map(o=>{const u=o.class==="ask"||o.body?.toLowerCase().startsWith("@")?"ASK":"MESSAGE";return s.jsxs("div",{className:"s-profile-signal",onClick:()=>{n&&t({view:"agents",agentId:a,conversationId:n})},children:[s.jsx("div",{className:"s-profile-signal-avatar",style:{background:qt(o.actorName??"?")},children:(o.actorName??"?")[0].toUpperCase()}),s.jsxs("div",{className:"s-profile-signal-body",children:[s.jsxs("div",{className:"s-profile-signal-header",children:[s.jsx("span",{className:"s-profile-signal-kind",children:u}),s.jsx("span",{className:"s-profile-signal-sep",children:"·"}),s.jsx("span",{className:"s-profile-signal-routing",children:o.actorName}),s.jsx("span",{className:"s-profile-signal-time",children:Ae(o.createdAt)})]}),s.jsx("div",{className:"s-profile-signal-text",children:o.body})]})]},o.id)})})]})}function gie({agent:e,allAgents:t,session:n,conversationId:a,navigate:r,activeTab:o}){const{name:c,qualifier:u}=Ere(e,t),[h,f]=m.useState([]),[g,v]=m.useState([]),[y,x]=m.useState(null),[w,C]=m.useState(null),[T,E]=m.useState(!1),[S,k]=m.useState(null),[N,A]=m.useState(null),[R,_]=m.useState(!1),[P,$]=m.useState(null),H=Je(e.state),I=Lc(),{route:U}=qe(),D=m.useCallback(async()=>{const[Ne,Oe]=await Promise.allSettled([me(`/api/work?agentId=${encodeURIComponent(e.id)}&active=false&limit=12`),me("/api/fleet")]);Ne.status==="fulfilled"&&f(Ne.value),Oe.status==="fulfilled"&&x(Oe.value)},[e.id]),V=m.useCallback(async Ne=>{$(Ne.id);try{await Rm({recordKind:"work_item",recordId:Ne.id,itemUpdatedAt:Ne.updatedAt}),await D()}finally{$(null)}},[D]),Z=m.useCallback(async()=>{if(!a){v([]);return}try{const Ne=await me(`/api/messages?conversationId=${encodeURIComponent(a)}&limit=20`);v(Ne)}catch{v([])}},[a]),O=m.useCallback(async()=>{E(!0);try{const Ne=await me(`/api/agents/${encodeURIComponent(e.id)}/observe`);C(Ne)}catch{C({agentId:e.id,source:"unavailable",fidelity:"synthetic",historyPath:null,sessionId:null,updatedAt:Date.now(),data:{events:[{id:`${e.id}:observe-error`,t:0,kind:"system",text:"Observer data is temporarily unavailable.",detail:"Retrying will resume once the session source becomes reachable."}],files:[],contextUsage:[],live:!1}})}finally{E(!1)}},[e.id]),z=m.useCallback(async()=>{if(!e.transport){A(null);return}try{const Ne=await me(`/api/agents/${encodeURIComponent(e.id)}/session/context`);A(Ne)}catch{A(null)}},[e.id,e.transport]),B=m.useCallback(async()=>{_(!0);try{const Ne=await me(`/api/agents/${encodeURIComponent(e.id)}/session/reset`,{method:"POST"});k(Ne.catalog),await z(),o==="observe"&&await O()}catch{await z()}finally{_(!1)}},[o,e.id,z,O]);m.useEffect(()=>{D(),Z(),z(),me(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).then(k).catch(()=>{})},[D,Z,z,e.id]),m.useEffect(()=>{C(null),E(!1),A(null)},[e.id]),m.useEffect(()=>{o==="observe"&&O()},[o,O]),tn(()=>{D(),Z(),z(),o==="observe"&&O()}),m.useEffect(()=>{if(o!=="observe"||!w?.data.live)return;const Ne=setInterval(()=>{O()},2500);return()=>clearInterval(Ne)},[o,w?.data.live,O]);const X=h.find(Ne=>Ne.state==="working"||Ne.state==="review"),W=h.filter(Ne=>(Ne.state==="working"||Ne.state==="review"||Ne.state==="waiting")&&Ne.id!==X?.id),L=h.filter(Ne=>Ne.state==="done").slice(0,5),q=Hi(e.role)??Hi(e.agentClass),K=e.harness,ee=e.authorityNodeName??e.homeNodeName??e.authorityNodeId??e.homeNodeId,G=e.authorityNodeId&&e.homeNodeId&&e.authorityNodeId!==e.homeNodeId?`home ${e.homeNodeName??e.homeNodeId}`:null,re=tj(e),Q=e.authorityNodeName&&e.authorityNodeId?`${e.authorityNodeName} (${e.authorityNodeId})`:e.authorityNodeName??e.authorityNodeId,ae=e.homeNodeName&&e.homeNodeId?`${e.homeNodeName} (${e.homeNodeId})`:e.homeNodeName??e.homeNodeId,be=[e.workspaceQualifier?`workspace ${e.workspaceQualifier}`:null,e.nodeQualifier?`node ${e.nodeQualifier}`:null].filter(Boolean),$e=[q,K].filter(Boolean).filter((Ne,Oe,Ce)=>Ce.indexOf(Ne)===Oe),ge=m.useMemo(()=>t.filter(Ne=>Ne.project===e.project).length,[t,e.project]),Te=X?.currentPhase==="review"?85:X?.currentPhase==="working"?50:20,Xe=(X?Date.now()-X.lastMeaningfulAt:0)>30*6e4,Be=X?Xe?`stale · ${Ae(X.lastMeaningfulAt)}`:`${Te}% · live`:"",Se=[{key:"profile",label:"Profile"},{key:"observe",label:"Observe"},{key:"message",label:"Message",disabled:!a}],Me=Ne=>{r({view:"agents",agentId:e.id,...a?{conversationId:a}:{},tab:Ne})},_e=(Ne="")=>s.jsx("nav",{className:`s-profile-tabs${Ne?` ${Ne}`:""}`,children:Se.map(Oe=>s.jsx("button",{type:"button",className:`s-profile-tab${o===Oe.key?" s-profile-tab--active":""}`,disabled:Oe.disabled,onClick:()=>Me(Oe.key),children:Oe.label},Oe.key))});return s.jsxs("div",{className:`s-profile-center${o!=="profile"?" s-profile-center--tabbed":""}`,children:[s.jsx("div",{className:"s-profile-return-row",children:s.jsx(Ga,{slot:"agents",fallback:{view:"agents"},navigate:r,className:"s-profile-back-position"})}),o==="profile"?s.jsx("section",{className:"s-profile-identity",onContextMenu:Ne=>{const Oe=window.getSelection()?.toString().trim(),Ce=[];Oe&&(Ce.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>{On(Oe)}}),Ce.push({kind:"separator"})),Ce.push({kind:"action",label:"Copy Agent Name",onSelect:()=>{On(c)}}),Ce.push({kind:"action",label:"Copy Agent ID",onSelect:()=>{On(e.id)}}),e.handle&&Ce.push({kind:"action",label:`Copy @${e.handle}`,onSelect:()=>{On(`@${e.handle}`)}}),e.selector&&Ce.push({kind:"action",label:"Copy Selector",onSelect:()=>{On(e.selector??"")}}),e.defaultSelector&&e.defaultSelector!==e.selector&&Ce.push({kind:"action",label:"Copy Default Selector",onSelect:()=>{On(e.defaultSelector??"")}}),I(Ne,Ce)},children:s.jsxs("div",{className:"s-profile-identity-top",children:[s.jsxs("div",{className:"s-profile-identity-avatar-wrap",children:[s.jsx("div",{className:"s-profile-identity-avatar",style:{background:qt(e.name)},children:e.name[0].toUpperCase()}),s.jsx("span",{className:`s-profile-identity-pulse s-profile-identity-pulse--${H}`,style:{background:Pn(e.state)}})]}),s.jsxs("div",{className:"s-profile-identity-copy",children:[$e.length>0&&s.jsx("div",{className:"s-profile-identity-eyebrow",children:$e.join(" · ")}),s.jsxs("h1",{className:"s-profile-identity-name",children:[c,u&&s.jsx("span",{className:"s-profile-identity-name-qualifier",children:u}),e.handle&&s.jsxs("span",{className:"s-profile-identity-name-handle",children:["@",e.handle]})]}),s.jsx("div",{className:"s-profile-identity-state-row",children:s.jsxs("span",{className:"s-profile-identity-state",children:[s.jsx("span",{className:`s-profile-identity-state-dot${H==="working"?" s-profile-identity-state-dot--pulse":""}`,style:{background:Pn(e.state)}}),s.jsx("span",{className:"s-profile-identity-state-label",children:ia(e.state)}),e.updatedAt&&s.jsxs("span",{className:"s-profile-identity-state-detail",children:["— ",Ae(e.updatedAt)]}),e.staleLocalRegistration&&s.jsx("span",{className:"s-profile-identity-state-detail",children:"stale hint"})]})}),s.jsxs("div",{className:"s-profile-identity-qualified",children:[s.jsx("span",{children:e.id}),re&&s.jsx("span",{children:re}),e.defaultSelector&&e.defaultSelector!==re&&s.jsx("span",{children:e.defaultSelector})]})]}),_e()]})}):s.jsx("div",{className:"s-profile-compact-tabs",children:_e("s-profile-tabs--compact")}),o==="profile"&&s.jsxs("div",{className:"s-profile-tab-content",children:[(e.id||re||ee||e.project||e.branch||e.cwd||S?.activeSessionId||N)&&s.jsxs("div",{className:"s-profile-facets",children:[s.jsxs("div",{className:"s-profile-facet s-profile-facet--identity",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Agent ID"}),s.jsx("div",{className:"s-profile-facet-value s-profile-facet-value--mono",children:e.id}),s.jsxs("div",{className:"s-profile-facet-detail",children:["definition ",e.definitionId]})]}),re&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Selector"}),s.jsx("div",{className:"s-profile-facet-value s-profile-facet-value--mono",children:re}),e.defaultSelector&&e.defaultSelector!==re&&s.jsxs("div",{className:"s-profile-facet-detail",children:["default ",e.defaultSelector]})]}),(be.length>0||Q||ae)&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Authority"}),s.jsx("div",{className:"s-profile-facet-value",children:Q??ee??"local"}),s.jsx("div",{className:"s-profile-facet-detail",children:be.length>0?be.join(" · "):ae&&ae!==Q?`home ${ae}`:"qualified route"})]}),ee&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Machine"}),s.jsx("div",{className:"s-profile-facet-value",children:ee}),G&&s.jsx("div",{className:"s-profile-facet-detail",children:G})]}),e.project&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Workspace"}),s.jsx("div",{className:"s-profile-facet-value",children:e.project}),ge>1&&s.jsxs("div",{className:"s-profile-facet-detail",children:[ge," teammates"]})]}),(e.branch||e.projectRoot)&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Repo / Branch"}),s.jsx("div",{className:"s-profile-facet-value",children:e.projectRoot?e.projectRoot.split("/").pop():e.project??"—"}),e.branch&&s.jsxs("div",{className:"s-profile-facet-detail",children:[s.jsx("span",{className:"s-profile-facet-accent",children:"⎇"})," ",e.branch]})]}),e.cwd&&s.jsxs("div",{className:"s-profile-facet",children:[s.jsx("div",{className:"s-profile-facet-label",children:"Working Dir"}),s.jsx("div",{className:"s-profile-facet-value",children:e.cwd.startsWith("/Users/")?"~/"+e.cwd.split("/").slice(3).join("/"):e.cwd}),e.updatedAt&&s.jsxs("div",{className:"s-profile-facet-detail",children:["uptime ",Ae(e.updatedAt)]})]}),S?.activeSessionId&&s.jsx(lie,{catalog:S,agentId:e.id}),N&&s.jsx(hie,{context:N,lastActivityAt:e.updatedAt??null,resetting:R,onReset:()=>{B()}})]}),X&&H==="working"&&s.jsxs(s.Fragment,{children:[s.jsx(pd,{label:"Current task",right:Be}),s.jsxs("div",{className:"s-profile-task",children:[s.jsx("div",{className:"s-profile-task-title",children:X.title}),X.lastMeaningfulSummary&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"s-profile-task-progress",children:s.jsx("div",{className:"s-profile-task-progress-bar",style:{width:`${Te}%`}})}),s.jsxs("div",{className:"s-profile-task-action",children:[s.jsx("span",{className:"s-profile-task-action-chevron",children:"›"}),s.jsx("span",{children:X.lastMeaningfulSummary}),s.jsx("span",{className:"s-profile-task-cursor"})]})]}),s.jsxs("div",{className:"s-profile-task-meta",children:[s.jsx("span",{children:X.currentPhase}),s.jsx("span",{children:Ae(X.lastMeaningfulAt)})]}),s.jsxs("div",{className:"s-profile-task-controls","aria-label":"Current task actions",children:[s.jsx("button",{type:"button",className:"s-profile-task-btn s-profile-task-btn--primary",onClick:()=>kt(r,{view:"work",workId:X.id},{returnTo:U}),children:"Open work"}),s.jsx("button",{type:"button",className:"s-profile-task-btn",onClick:()=>Me("observe"),children:"Observe"}),a&&s.jsx("button",{type:"button",className:"s-profile-task-btn",onClick:()=>Me("message"),children:"Message"})]})]})]}),W.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(pd,{label:"Active work",right:`${W.length} in flight`}),s.jsx("div",{className:"s-profile-work",children:s.jsx(BA,{items:W,navigate:r,emptyTitle:"Nothing in flight",onDismissAttention:Ne=>{V(Ne)},dismissingId:P})})]}),L.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(pd,{label:W.length>0?"Recently completed":"Recent work",right:`${L.length}`}),s.jsx("div",{className:"s-profile-work",children:s.jsx(BA,{items:L,navigate:r,emptyTitle:""})})]}),s.jsx(mie,{agent:e,fleet:y,navigate:r}),s.jsx(pie,{messages:g,navigate:r,conversationId:a,agentId:e.id})]}),o==="observe"&&s.jsx("div",{className:"s-profile-tab-conversation",children:T&&!w?s.jsxs("div",{className:"s-profile-activity-empty",children:[s.jsx("div",{className:"s-profile-activity-empty-title",children:"Loading trace"}),s.jsx("div",{className:"s-profile-activity-empty-detail",children:"Resolving the best available live or history-backed session stream for this agent."})]}):s.jsx(_P,{data:w?.data,agentId:e.id,sessionId:w?.sessionId,showRail:!1})}),o==="message"&&a&&s.jsx("div",{className:"s-profile-tab-conversation",children:s.jsx(hg,{conversationId:a,navigate:r,embedded:!0})})]})}function vie({navigate:e,selectedAgentId:t,conversationId:n,tab:a}){const{agents:r,route:o}=qe(),[c,u]=m.useState([]),[h,f]=m.useState(null),[g,v]=m.useState(null),y=oa(o),x=m.useMemo(()=>el(r,y),[r,y]),w=m.useCallback(async()=>{const[k,N,A]=await Promise.allSettled([me("/api/conversations"),me("/api/fleet"),me("/api/tail/discover")]);k.status==="fulfilled"&&u(k.value),N.status==="fulfilled"&&f(N.value),A.status==="fulfilled"&&v(A.value)},[]);m.useEffect(()=>{w()},[w]),m.useEffect(()=>{const k=window.setInterval(()=>{w()},1e4);return()=>window.clearInterval(k)},[w]),tn(()=>{w()});const C=oie(x,t),T=!!(t&&C&&C.id!==t),{conversationByAgentId:E,sessionByAgentId:S}=Tre(c);if(m.useEffect(()=>{if(!t||!C||!T)return;const k=ps(t),N=n===k?C.conversationId:n;e({view:"agents",agentId:C.id,...N?{conversationId:N}:{},...a?{tab:a}:{}})},[n,a,e,C,t,T]),C){const k=T&&t?ps(t):null,N=n===k?C.conversationId:n??E.get(C.id)??C.conversationId??null,A=a??(n?"message":"profile");return s.jsx(gie,{agent:C,allAgents:x,session:S.get(C.id)??null,conversationId:N,navigate:e,activeTab:A})}return s.jsx(yie,{agents:x,fleet:h,sessionByAgentId:S,conversationByAgentId:E,sessions:c,discovery:g,navigate:e})}function yie({agents:e,fleet:t,sessionByAgentId:n,conversationByAgentId:a,sessions:r,discovery:o,navigate:c}){const{route:u}=qe(),[h,f]=m.useState(""),[g,v]=m.useState(()=>new Set),[y,x]=m.useState(()=>new Set),[w,C]=m.useState("projects"),[T,E]=m.useState(Date.now()),[S,k]=m.useState({key:"status",dir:1});m.useEffect(()=>{const G=window.setInterval(()=>E(Date.now()),15e3);return()=>window.clearInterval(G)},[]);const N=m.useMemo(()=>{const G=new Map;for(const re of t?.activeAsks??[]){const Q=G.get(re.agentId)??[];Q.push(re),G.set(re.agentId,Q)}return G},[t?.activeAsks]),A=m.useMemo(()=>e.map(G=>Bre(G,n.get(G.id)??null,N.get(G.id)??[])),[N,e,n]),R=m.useMemo(()=>Lre(o,T),[o,T]),_=m.useMemo(()=>cT(A,r,R),[R,A,r]),P=m.useMemo(()=>({total:A.length,online:A.filter(G=>G.status!=="offline").length,working:A.filter(G=>G.status==="working").length,available:A.filter(G=>G.status==="available").length,offline:A.filter(G=>G.status==="offline").length,projects:_.length,scoutSessions:_.reduce((G,re)=>G+re.scoutSessions.length,0),nativeSessions:R.length,activeNativeSessions:R.filter(G=>G.status==="active").length}),[_,R,A]),$=m.useMemo(()=>{const G=new Map;for(const re of A)G.set(re.harness,(G.get(re.harness)??0)+1);for(const re of R)G.set(re.source,(G.get(re.source)??0)+1);for(const re of r){const Q=Hi(re.harness)??"scout";G.set(Q,(G.get(Q)??0)+1)}return[...G.entries()].sort((re,Q)=>Q[1]-re[1]||re[0].localeCompare(Q[0]))},[R,A,r]),H=m.useMemo(()=>{const G=new Set(A.map(re=>re.status));return["working","available","offline"].filter(re=>G.has(re))},[A]),I=m.useMemo(()=>{const G=h.trim().toLowerCase();return A.filter(re=>g.size>0&&!g.has(re.harness)||y.size>0&&!y.has(re.status)?!1:aie(re,G))},[g,h,A,y]),U=m.useMemo(()=>{const G=h.trim().toLowerCase();return R.filter(re=>rie(re,G,g))},[g,R,h]),D=m.useMemo(()=>{const G=h.trim().toLowerCase();return r.filter(re=>iie(re,G,g))},[g,h,r]),V=m.useMemo(()=>cT(I,D,U),[U,I,D]),Z=u.view==="agents"&&!u.agentId?u.projectKey:void 0,O=m.useMemo(()=>Z?_.find(G=>G.key===Z)??null:null,[_,Z]),z=m.useMemo(()=>Z?V.filter(G=>G.key===Z):V,[V,Z]),B=m.useMemo(()=>Z?I.filter(G=>OP(G).key===Z):I,[I,Z]),X=m.useMemo(()=>S.key==="status"?void 0:(G,re)=>qr[G.status]-qr[re.status],[S.key]),W=G=>{const re=a.get(G.agent.id);c({view:"agents",agentId:G.agent.id,...re?{conversationId:re}:{}})},L=G=>{C("projects"),c({view:"agents",projectKey:G.key})},q=()=>{c({view:"agents"})},K=G=>{v(re=>{const Q=new Set(re);return Q.has(G)?Q.delete(G):Q.add(G),Q})},ee=G=>{x(re=>{const Q=new Set(re);return Q.has(G)?Q.delete(G):Q.add(G),Q})};return s.jsx("div",{className:"s-agents-library s-agents-library--inventory",children:s.jsxs("div",{className:"s-agents-inventory",children:[s.jsxs("div",{className:"s-atop-summary",children:[s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--primary",children:[s.jsxs("div",{className:"s-atop-summary-num",children:[s.jsx("strong",{children:P.online}),s.jsxs("span",{className:"s-atop-summary-of",children:["/ ",P.total]})]}),s.jsx("span",{className:"s-atop-summary-lbl",children:"active"})]}),s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:P.projects})}),s.jsx("span",{className:"s-atop-summary-lbl",children:"projects"})]}),s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsxs("div",{className:"s-atop-summary-num",children:[s.jsx("strong",{children:P.activeNativeSessions}),s.jsxs("span",{className:"s-atop-summary-of",children:["/ ",P.nativeSessions]})]}),s.jsx("span",{className:"s-atop-summary-lbl",children:"native sessions"})]}),s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:P.scoutSessions})}),s.jsx("span",{className:"s-atop-summary-lbl",children:"scout sessions"})]}),s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--breakdown",children:[s.jsx("span",{className:"s-atop-summary-lbl",children:"harness"}),s.jsx("div",{className:"s-atop-summary-row",children:$.length===0?s.jsx("span",{className:"s-atop-chip s-atop-chip--mute",children:"none"}):$.slice(0,6).map(([G,re])=>s.jsxs("span",{className:nl(G),children:[G," ",re]},G))})]}),s.jsx("div",{className:"s-atop-summary-spacer"}),s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--rate",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:P.working})}),s.jsx("span",{className:"s-atop-summary-lbl",children:"working"})]})]}),s.jsxs("div",{className:"s-atop-fbar",children:[s.jsxs("div",{className:"s-atop-search",children:[s.jsx("span",{className:"s-atop-search-prompt",children:"▸"}),s.jsx("input",{className:"s-atop-search-input",value:h,onChange:G=>f(G.target.value),placeholder:"filter projects · agents · sessions"}),s.jsx("span",{className:"s-atop-search-kbd",children:"/"})]}),s.jsxs("div",{className:"s-agents-library-view",role:"group","aria-label":"Agents view",children:[s.jsx("button",{type:"button",className:"s-agents-library-view-btn","data-active":w==="projects",onClick:()=>C("projects"),children:"projects"}),s.jsx("button",{type:"button",className:"s-agents-library-view-btn","data-active":w==="inventory",onClick:()=>C("inventory"),children:"inventory"})]}),Z&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"project"}),s.jsxs("button",{type:"button",className:"s-atop-pill s-atop-pill--on s-atop-pill--project",onClick:q,title:"Return to all project overviews",children:[s.jsx("span",{className:"s-atop-pill-main",children:O?.title??"selected project"}),s.jsx("span",{className:"s-atop-pill-ct",children:"clear"})]})]}),$.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"harness"}),$.map(([G,re])=>{const Q=g.has(G);return s.jsxs("button",{type:"button",className:`s-atop-pill s-atop-pill--harness${Q?" s-atop-pill--on":""}`,onClick:()=>K(G),children:[G,s.jsx("span",{className:"s-atop-pill-ct",children:re})]},G)})]}),H.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"status"}),H.map(G=>{const re=y.has(G),Q=A.filter(ae=>ae.status===G).length;return s.jsxs("button",{type:"button",className:`s-atop-pill s-agents-inventory-pill--status-${G}${re?" s-atop-pill--on":""}`,onClick:()=>ee(G),children:[G,s.jsx("span",{className:"s-atop-pill-ct",children:Q})]},G)})]}),s.jsx("div",{className:"s-atop-fbar-spacer"}),(g.size>0||y.size>0||h||Z)&&s.jsx("button",{type:"button",className:"s-atop-pill",onClick:()=>{f(""),v(new Set),x(new Set),Z&&q()},children:"clear"})]}),w==="projects"?s.jsx(xie,{projects:z,totalProjects:P.projects,query:h,selectedProject:O,selectedProjectKey:Z,navigate:c,route:u,openAgent:W,onSelectProject:L}):s.jsx(ug,{rows:B,columns:sie,rowId:G=>G.agent.id,storageKey:"openscout.agents.inventory.cols",sort:S,onSortChange:k,secondarySort:X,onRowClick:W,rowClassName:G=>`s-agents-inventory-row s-agents-inventory-row--${G.status}`,empty:{title:e.length===0?"no agents registered":"no agents match",body:e.length===0?"Start or register an agent to populate the inventory.":"Adjust filters to widen the current slice."},density:"compact",className:"s-atop-data-table s-agents-inventory-table",ariaLabel:"Agents inventory"}),s.jsxs("div",{className:"s-atop-keys",children:[s.jsx("span",{className:"s-atop-keys-count",children:w==="projects"?s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:z.length})," / ",P.projects," project",P.projects===1?"":"s",Z?" selected":""]}):s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:B.length})," / ",A.length," agents"]})}),s.jsx("span",{className:"s-atop-keys-spacer"}),s.jsxs("span",{children:[P.offline," offline"]}),s.jsxs("span",{children:[P.nativeSessions," native session",P.nativeSessions===1?"":"s"]})]})]})})}function xie({projects:e,totalProjects:t,query:n,selectedProject:a,selectedProjectKey:r,navigate:o,route:c,openAgent:u,onSelectProject:h}){return e.length===0?s.jsx("div",{className:"s-agent-projects s-agent-projects--empty",children:s.jsxs("div",{className:"s-agent-project-empty",children:[s.jsx("div",{className:"s-agent-project-empty-title",children:r?a?"selected project hidden":"project no longer visible":t===0?"no projects visible":"no projects match"}),s.jsx("div",{className:"s-agent-project-empty-body",children:r&&a?"Adjust the current filters to bring this project overview back into view.":r?"Return to all projects or select another project from the current inventory.":n.trim()?"Adjust the current project, agent, or session filter.":"Projects appear when agents, Scout sessions, or native harness sessions are discovered."})]})}):s.jsx("div",{className:"s-agent-projects",children:e.map(f=>s.jsx(bie,{project:f,navigate:o,route:c,openAgent:u,selected:f.key===r,onSelectProject:h},f.key))})}function bie({project:e,navigate:t,route:n,openAgent:a,selected:r,onSelectProject:o}){const c=e.agents.filter(f=>f.status!=="offline").length,u=e.nativeSessions.filter(f=>f.status==="active").length,h=e.agents.reduce((f,g)=>f+g.activeAskCount,0);return s.jsxs("section",{className:`s-agent-project s-agent-project--${e.status}${r?" s-agent-project--selected":""}`,children:[s.jsxs("div",{className:"s-agent-project-head",children:[s.jsx("button",{type:"button",className:"s-agent-project-select","data-selected":r,onClick:()=>o(e),"aria-pressed":r,title:`Open ${e.title} project overview`,children:s.jsxs("span",{className:"s-agent-project-title-block",children:[s.jsxs("span",{className:"s-agent-project-eyebrow",children:["Project",r&&s.jsx("span",{className:"s-agent-project-selected-label",children:"selected"})]}),s.jsx("span",{className:"s-agent-project-title",children:e.title}),e.root&&s.jsx("span",{className:"s-agent-project-root",title:e.root,children:e.root})]})}),s.jsxs("div",{className:"s-agent-project-metrics","aria-label":`${e.title} project metrics`,children:[s.jsx(zu,{label:"agents",value:`${c}/${e.agents.length}`,tone:c>0?"green":"dim"}),s.jsx(zu,{label:"native",value:`${u}/${e.nativeSessions.length}`,tone:u>0?"green":"dim"}),s.jsx(zu,{label:"scout",value:`${e.scoutSessions.length}`}),s.jsx(zu,{label:"work",value:`${h||"—"}`,tone:h>0?"green":"dim"}),s.jsx(zu,{label:"last",value:e.lastActivityAt?Ae(e.lastActivityAt):"—"})]})]}),r?s.jsx(wie,{project:e,navigate:t,route:n,openAgent:a}):s.jsxs("div",{className:"s-agent-project-body",children:[s.jsxs("div",{className:"s-agent-project-column s-agent-project-column--agents",children:[s.jsxs("div",{className:"s-agent-project-section-head",children:[s.jsx("span",{children:"Agent cards"}),s.jsx("strong",{children:e.agents.length})]}),e.agents.length===0?s.jsx("div",{className:"s-agent-project-empty-inline",children:"No Scout agent cards."}):s.jsx("div",{className:"s-agent-project-card-grid",children:e.agents.map(f=>s.jsx(jie,{row:f,onOpen:()=>a(f)},f.agent.id))})]}),s.jsxs("div",{className:"s-agent-project-column s-agent-project-column--sessions",children:[s.jsxs("div",{className:"s-agent-project-section-head",children:[s.jsx("span",{children:"Native sessions"}),s.jsx("strong",{children:e.nativeSessions.length})]}),s.jsx(Nie,{sessions:e.nativeSessions,navigate:t,route:n}),s.jsxs("div",{className:"s-agent-project-section-head s-agent-project-section-head--secondary",children:[s.jsx("span",{children:"Scout layer"}),s.jsx("strong",{children:e.scoutSessions.length})]}),s.jsx(kie,{sessions:e.scoutSessions,navigate:t,route:n})]})]})]})}function wie({project:e,navigate:t,route:n,openAgent:a}){const r=m.useMemo(()=>Wre(e),[e]),o=Gre(e.key),c=Zre(e.key),[u,h]=m.useState(()=>Qre(o)),[f,g]=m.useState(()=>Yre(c)),v=m.useMemo(()=>qre(r,f),[r,f]),y=e.nativeSessions.length+e.scoutSessions.length;m.useEffect(()=>{Jre(o,u)},[u,o]),m.useEffect(()=>{Xre(c,f)},[f,c]);const x=S=>{h(k=>{const N=new Set(k);return N.has(S)?N.delete(S):N.add(S),N})},w=S=>{S.route&&kt(t,S.route,{returnTo:n})},C=S=>{g(k=>k.key===S?{key:S,dir:k.dir===1?-1:1}:{key:S,dir:Vre(S)})},T=`${e.key}:project-sessions`,E=!u.has(T);return s.jsx("div",{className:"s-agent-project-tree",role:"treegrid","aria-label":`${e.title} agent and session tree`,children:s.jsxs("div",{className:"s-agent-project-tree-grid",children:[s.jsx("div",{className:"s-agent-project-tree-head",role:"row",children:Rre.map(S=>{const k=S.key===f.key;return S.sortable?s.jsxs("button",{type:"button",className:"s-agent-project-tree-sort","data-active":k,"aria-sort":k?f.dir===1?"ascending":"descending":"none",onClick:()=>C(S.key),children:[s.jsx("span",{children:S.label}),s.jsx("span",{className:"s-agent-project-tree-sort-mark","aria-hidden":!0,children:k?f.dir===1?"↑":"↓":"↕"})]},S.key):s.jsx("span",{children:S.label},S.key)})}),s.jsxs("div",{className:"s-agent-project-tree-row s-agent-project-tree-row--root",role:"row",children:[s.jsxs("div",{className:"s-agent-project-tree-target",children:[s.jsx("span",{className:"s-agent-project-tree-gutter","aria-hidden":!0}),s.jsxs("span",{className:"s-agent-project-tree-copy",children:[s.jsx("span",{className:"s-agent-project-tree-primary",children:e.title}),s.jsx("span",{className:"s-agent-project-tree-secondary",children:e.root??"Project root unknown"})]})]}),s.jsx("span",{className:`s-agent-project-tree-state s-agent-project-tree-state--${e.status}`,children:e.status}),s.jsx("span",{className:"s-agent-project-tree-muted",children:"mixed"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:pr(e.root)??"—"}),s.jsxs("span",{className:"s-agent-project-tree-mono",children:[e.agents.length," / ",y]}),s.jsx("span",{className:"s-agent-project-tree-mono",children:e.lastActivityAt?Ae(e.lastActivityAt):"—"}),s.jsx("span",{className:"s-agent-project-tree-actions"})]}),v.unassignedSessions.length>0&&s.jsxs(m.Fragment,{children:[s.jsxs("div",{className:"s-agent-project-tree-row s-agent-project-tree-row--group",role:"row",children:[s.jsxs("div",{className:"s-agent-project-tree-target",children:[s.jsx("button",{type:"button",className:"s-agent-project-tree-toggle","aria-label":`${E?"Collapse":"Expand"} project sessions`,"aria-expanded":E,onClick:()=>x(T),children:E?"▾":"▸"}),s.jsxs("span",{className:"s-agent-project-tree-copy",children:[s.jsx("span",{className:"s-agent-project-tree-primary",children:"Project sessions"}),s.jsx("span",{className:"s-agent-project-tree-secondary",children:"Not attached to a registered agent card"})]})]}),s.jsx("span",{className:"s-agent-project-tree-muted",children:"observed"}),s.jsx("span",{className:"s-agent-project-tree-muted",children:"mixed"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:pr(e.root)??"—"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:v.unassignedSessions.length}),s.jsx("span",{className:"s-agent-project-tree-mono",children:v.unassignedSessions[0]?.lastActivityAt?Ae(v.unassignedSessions[0].lastActivityAt):"—"}),s.jsx("span",{className:"s-agent-project-tree-actions"})]}),E&&v.unassignedSessions.map(S=>s.jsx(pT,{session:S,onOpen:()=>w(S)},S.key))]}),v.agents.map(S=>{const k=!u.has(S.key),N=S.row;return s.jsxs(m.Fragment,{children:[s.jsxs("div",{className:`s-agent-project-tree-row s-agent-project-tree-row--agent s-agent-project-tree-row--${N.status}`,role:"row",children:[s.jsxs("div",{className:"s-agent-project-tree-target",children:[s.jsx("button",{type:"button",className:"s-agent-project-tree-toggle",disabled:S.sessions.length===0,"aria-label":`${k?"Collapse":"Expand"} ${N.agent.name} sessions`,"aria-expanded":k,onClick:()=>x(S.key),children:S.sessions.length===0?"•":k?"▾":"▸"}),s.jsxs("button",{type:"button",className:"s-agent-project-tree-link",onClick:()=>a(N),title:tj(N.agent)??N.agent.id,children:[s.jsxs("span",{className:"s-agent-project-tree-primary",children:[s.jsx("span",{className:"s-agent-project-tree-dot",style:{background:Pn(N.agent.state)},"aria-hidden":!0}),N.agent.name]}),s.jsx("span",{className:"s-agent-project-tree-secondary",children:N.activeTask??N.session?.preview??N.agent.id})]})]}),s.jsx("span",{className:`s-agent-project-tree-state s-agent-project-tree-state--${N.status}`,children:N.stateLabel.toLowerCase()}),s.jsx("span",{className:nl(N.harness),children:N.harness}),s.jsx("span",{className:"s-agent-project-tree-mono",title:N.agent.cwd??N.agent.projectRoot??void 0,children:N.branch!=="—"?N.branch:pr(N.agent.cwd??N.agent.projectRoot)??"—"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:S.sessions.length}),s.jsx("span",{className:"s-agent-project-tree-mono",children:N.lastActivityAt?Ae(N.lastActivityAt):"—"}),s.jsxs("span",{className:"s-agent-project-tree-actions",children:[N.session&&s.jsx("button",{type:"button",className:"s-agent-project-tree-action",onClick:()=>kt(t,{view:"conversation",conversationId:N.session.id},{returnTo:n}),children:"message"}),s.jsx("button",{type:"button",className:"s-agent-project-tree-action",onClick:()=>a(N),children:"open"})]})]}),k&&S.sessions.map(A=>s.jsx(pT,{session:A,onOpen:()=>w(A)},A.key))]},S.key)})]})})}function pT({session:e,onOpen:t}){return s.jsxs("div",{className:`s-agent-project-tree-row s-agent-project-tree-row--session s-agent-project-tree-row--${e.kind}`,role:"row",children:[s.jsxs("div",{className:"s-agent-project-tree-target",children:[s.jsx("span",{className:"s-agent-project-tree-branch","aria-hidden":!0}),s.jsxs("button",{type:"button",className:"s-agent-project-tree-link",disabled:!e.route,onClick:t,title:e.detail??e.label,children:[s.jsx("span",{className:"s-agent-project-tree-primary",children:e.label}),s.jsx("span",{className:"s-agent-project-tree-secondary",children:e.detail??e.kind})]})]}),s.jsx("span",{className:`s-agent-project-tree-state s-agent-project-tree-state--${PP(e.status)}`,children:e.status}),s.jsx("span",{className:nl(e.harness),children:e.harness}),s.jsx("span",{className:"s-agent-project-tree-muted",children:e.kind}),s.jsx("span",{className:"s-agent-project-tree-muted",children:"—"}),s.jsx("span",{className:"s-agent-project-tree-mono",children:e.lastActivityAt?Ae(e.lastActivityAt):"live"}),s.jsx("span",{className:"s-agent-project-tree-actions",children:s.jsx("button",{type:"button",className:"s-agent-project-tree-action",disabled:!e.route,onClick:t,children:e.kind==="native"?"observe":"open"})})]})}function zu({label:e,value:t,tone:n="default"}){return s.jsxs("span",{className:`s-agent-project-metric s-agent-project-metric--${n}`,children:[s.jsx("strong",{children:t}),s.jsx("span",{children:e})]})}function jie({row:e,onOpen:t}){const n=tj(e.agent),a=e.activeTask??e.session?.preview??e.stateLabel,r=!e.activeTask&&!e.session?.preview;return s.jsxs("button",{type:"button",className:"s-agent-project-card","data-state":e.status,onClick:t,title:n??e.agent.id,children:[s.jsxs("span",{className:"s-agent-project-card-top",children:[s.jsx("span",{className:"s-agent-project-card-dot",style:{background:Pn(e.agent.state)},"aria-hidden":"true"}),s.jsx("span",{className:"s-agent-project-card-name",children:e.agent.name}),e.lastActivityAt&&s.jsx("span",{className:"s-agent-project-card-time",children:Ae(e.lastActivityAt)})]}),s.jsx("span",{className:`s-agent-project-card-signal${r?" s-agent-project-card-signal--quiet":""}`,children:a}),s.jsxs("span",{className:"s-agent-project-card-chips",children:[s.jsx("span",{className:nl(e.harness),children:e.harness}),e.branch!=="—"&&s.jsx("span",{className:"s-agent-project-chip",children:e.branch}),(e.session?.id||e.agent.harnessSessionId)&&s.jsxs("span",{className:"s-agent-project-chip",children:["session ",tf(e.session?.id??e.agent.harnessSessionId)]}),e.activeAskCount>0&&s.jsxs("span",{className:"s-agent-project-chip s-agent-project-chip--active",children:[e.activeAskCount," active"]})]})]})}function Nie({sessions:e,navigate:t,route:n}){return e.length===0?s.jsx("div",{className:"s-agent-project-empty-inline",children:"No native sessions discovered."}):s.jsx("div",{className:"s-agent-project-session-list",children:e.map(a=>{const r=!!(a.sessionId||a.transcriptPath),o=tf(a.sessionId??a.refId);return s.jsxs("button",{type:"button",className:`s-agent-project-session s-agent-project-session--${a.status}`,disabled:!r,onClick:()=>{r&&kt(t,{view:"sessions",sessionId:a.refId},{returnTo:n})},title:a.transcriptPath??a.process?.command??a.refId,children:[s.jsx("span",{className:"s-agent-project-session-status",children:a.status}),s.jsx("span",{className:nl(a.source),children:a.source}),s.jsx("span",{className:"s-agent-project-session-main",children:o}),s.jsx("span",{className:"s-agent-project-session-sub",children:a.process?a.process.etime:a.lastActivityAt?Ae(a.lastActivityAt):"live"})]},a.key)})})}function kie({sessions:e,navigate:t,route:n}){return e.length===0?s.jsx("div",{className:"s-agent-project-empty-inline",children:"No Scout conversations yet."}):s.jsx("div",{className:"s-agent-project-session-list",children:e.map(a=>{const r=Hi(a.harness)??"scout";return s.jsxs("button",{type:"button",className:"s-agent-project-session s-agent-project-session--scout",onClick:()=>kt(t,{view:"conversation",conversationId:a.id},{returnTo:n}),title:a.preview??a.id,children:[s.jsx("span",{className:"s-agent-project-session-status",children:a.kind}),s.jsx("span",{className:nl(r),children:r}),s.jsx("span",{className:"s-agent-project-session-main",children:a.title||a.id}),s.jsx("span",{className:"s-agent-project-session-sub",children:a.lastMessageAt?Ae(a.lastMessageAt):tf(a.harnessSessionId)})]},a.id)})})}const gT=new RegExp("(?:^|(?<=[\\s(`'\"<>]))(?:~\\/|\\/(?:Users|home|opt|var|etc|tmp|private)\\/)[^\\s)`'\"<>]+\\.[A-Za-z0-9]{1,8}\\b","g");function Sie(e){const t=e.replace(/\r\n?/g,`
169
+ `).split(`
170
+ `),n=[];let a=0;for(;a<t.length;){const r=t[a];if(r.trim()===""){a+=1;continue}if(r.startsWith("```")){const u=[];for(a+=1;a<t.length&&!t[a].startsWith("```");)u.push(t[a]),a+=1;a<t.length&&(a+=1),n.push({kind:"code",body:u.join(`
171
+ `)});continue}const o=r.match(/^(#{1,3})\s+(.*\S)\s*$/);if(o){const u=o[1].length;n.push({kind:"heading",level:u,tokens:Nx(o[2])}),a+=1;continue}if(jx(r)){const u=[];for(;a<t.length&&jx(t[a]);)u.push(Nx(Cie(t[a]))),a+=1;n.push({kind:"list",items:u});continue}const c=[];for(;a<t.length&&t[a].trim()!==""&&!t[a].startsWith("```")&&!jx(t[a])&&!/^#{1,3}\s+\S/.test(t[a]);)c.push(Nx(t[a])),a+=1;n.push({kind:"paragraph",lines:c})}return n}const LP=/^\s*[-*]\s+/;function jx(e){return LP.test(e)}function Cie(e){return e.replace(LP,"")}function Nx(e){const t=[];let n=0,a="";const r=()=>{a&&(t.push({kind:"text",body:a}),a="")};for(;n<e.length;){const o=e[n];if(o==="`"){const c=e.indexOf("`",n+1);if(c!==-1&&c>n+1){r(),t.push({kind:"code",body:e.slice(n+1,c)}),n=c+1;continue}}else if(o==="*"&&e[n+1]==="*"){const c=e.indexOf("**",n+2);if(c!==-1&&c>n+2){r(),t.push({kind:"bold",body:e.slice(n+2,c)}),n=c+2;continue}}else if(o==="*"||o==="_"){const c=Tie(e,n+1,o);if(c!==-1){r(),t.push({kind:"italic",body:e.slice(n+1,c)}),n=c+1;continue}}a+=o,n+=1}return r(),Eie(t)}function Eie(e){const t=[];for(const n of e){if(n.kind!=="text"){t.push(n);continue}const a=Aie(n.body);a.length===1&&a[0].kind==="text"?t.push(n):t.push(...a)}return t}function Aie(e){if(!e)return[];const t=[];let n=0;gT.lastIndex=0;let a;for(;(a=gT.exec(e))!==null;){const r=a.index,o=r+a[0].length;r>n&&t.push({kind:"text",body:e.slice(n,r)}),t.push({kind:"file-path",body:a[0]}),n=o}return n===0?[{kind:"text",body:e}]:(n<e.length&&t.push({kind:"text",body:e.slice(n)}),t)}function Tie(e,t,n){if(e[t]===void 0||/\s/.test(e[t]))return-1;for(let a=t;a<e.length;a+=1){const r=e[a];if(r===n){const o=e[a-1];if(o&&!/\s/.test(o)&&e[a+1]!==n)return a}if(r===`
172
+ `)return-1}return-1}function zP({text:e}){const t=Sie(e);return t.length===0?null:s.jsx("div",{className:"flex flex-col gap-1.5 text-[11px] leading-relaxed text-[var(--scout-chrome-ink)]",children:t.map((n,a)=>s.jsx(Mie,{block:n},a))})}function Mie({block:e}){switch(e.kind){case"paragraph":return s.jsx("p",{className:"whitespace-pre-wrap break-words",children:e.lines.map((t,n)=>s.jsxs(m.Fragment,{children:[n>0&&`
173
+ `,s.jsx(Bu,{tokens:t})]},n))});case"list":return s.jsx("ul",{className:"ml-3 flex list-disc flex-col gap-1 marker:text-[var(--scout-chrome-ink-ghost)]",children:e.items.map((t,n)=>s.jsx("li",{className:"break-words pl-0.5",children:s.jsx(Bu,{tokens:t})},n))});case"code":return s.jsx("pre",{className:"overflow-x-auto rounded border border-[var(--scout-chrome-border-soft)] bg-black/25 px-2 py-1.5 text-[10px] leading-relaxed text-lime-100/90",children:e.body});case"heading":{const t="font-mono text-[var(--scout-chrome-ink-strong)] mt-2 first:mt-0";return e.level===1?s.jsx("h2",{className:`${t} text-[13px] font-bold uppercase tracking-[0.12em]`,children:s.jsx(Bu,{tokens:e.tokens})}):e.level===2?s.jsx("h3",{className:`${t} text-[11px] font-bold uppercase tracking-[0.14em] text-[var(--scout-chrome-ink)]`,children:s.jsx(Bu,{tokens:e.tokens})}):s.jsx("h4",{className:`${t} text-[10px] font-bold uppercase tracking-[0.16em] text-[var(--scout-chrome-ink-faint)]`,children:s.jsx(Bu,{tokens:e.tokens})})}}}function Bu({tokens:e}){return s.jsx(s.Fragment,{children:e.map((t,n)=>{switch(t.kind){case"text":return s.jsx(m.Fragment,{children:t.body},n);case"code":return s.jsx("code",{className:"rounded bg-black/25 px-1 text-[10px] text-lime-100/90",children:t.body},n);case"bold":return s.jsx("strong",{className:"font-bold text-[var(--scout-chrome-ink-strong)]",children:t.body},n);case"italic":return s.jsx("em",{className:"italic",children:t.body},n);case"file-path":return s.jsx(Rie,{path:t.body},n)}})})}function Rie({path:e}){const{openFilePreview:t}=qe(),n=Iie(e),a=r=>{r.stopPropagation(),me("/api/file/reveal",{method:"POST",body:JSON.stringify({path:e})}).catch(()=>{})};return s.jsxs("span",{className:"inline-flex items-center gap-1 align-baseline",children:[s.jsx("button",{type:"button",onClick:()=>t(e),title:`Preview ${e} in Scout`,className:"inline-flex items-center gap-1 rounded border border-lime-300/30 bg-lime-300/[0.05] px-1.5 py-[1px] font-mono text-[10px] text-lime-200 transition-colors hover:bg-lime-300/[0.12] hover:text-lime-100",children:s.jsx("span",{className:"truncate",children:n})}),s.jsx("button",{type:"button",onClick:a,title:`Open ${e} in your OS`,"aria-label":"Open in OS",className:"inline-flex items-center justify-center rounded border border-[var(--scout-chrome-border-soft)] p-[2px] text-[var(--scout-chrome-ink-faint)] transition-colors hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]",children:s.jsx(Tc,{size:10})})]})}function Iie(e){const t=e.split("/").filter(Boolean);return t.length<=3?e:`…/${t.slice(-2).join("/")}`}const _ie={"fleet-home":"fleet briefing",tour:"tour briefing"};function Oie({briefingId:e,navigate:t}){const[n,a]=m.useState(null),[r,o]=m.useState(null),c=m.useCallback(async()=>{try{const u=await me(`/api/briefings/${encodeURIComponent(e)}`);a(u),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to load briefing")}},[e]);return m.useEffect(()=>{c()},[c]),r?s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide",children:[s.jsx("button",{type:"button",className:"briefing-detail-back",onClick:()=>t({view:"briefings"}),children:"← back to briefings"}),s.jsx(sa,{title:"Couldn't load briefing",body:r})]}):n?s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide briefing-detail",children:[s.jsx("button",{type:"button",className:"briefing-detail-back",onClick:()=>t({view:"briefings"}),children:"← back to briefings"}),s.jsxs("header",{className:"briefing-detail-header",children:[s.jsx("h2",{children:n.title}),s.jsxs("div",{className:"briefing-detail-header-meta",children:[s.jsx("span",{className:`briefing-kind briefing-kind-${n.kind}`,children:_ie[n.kind]}),s.jsx("span",{children:Wa(n.preparedAt)}),s.jsxs("span",{children:["· ",Ae(n.preparedAt)]})]}),s.jsx("p",{className:"briefing-detail-summary",children:n.summary}),n.recommendation?s.jsx("div",{className:"briefing-detail-recommendation",children:n.recommendation}):null]}),n.markdown?s.jsx($ie,{markdown:n.markdown}):null,n.brief?.presented?s.jsx(Die,{presented:n.brief.presented}):null,s.jsx(Pie,{call:n.call}),s.jsx(Lie,{brief:n.brief,navigate:t}),s.jsx(zie,{observations:n.observations,navigate:t}),s.jsx(Uie,{snapshot:n.snapshot,call:n.call})]}):s.jsx("div",{className:"sys-surface-page sys-surface-page-wide",children:s.jsx("div",{className:"briefings-placeholder",children:"Loading briefing..."})})}function $ie({markdown:e}){return s.jsxs("section",{className:"briefing-layer briefing-layer-markdown",children:[s.jsx(Ko,{eyebrow:"Layer 0",title:"Brief (markdown)"}),s.jsx("div",{className:"briefing-markdown",children:s.jsx(zP,{text:e})})]})}function Pie({call:e}){return!e||!e.telemetry&&!e.presenter?null:s.jsxs("section",{className:"briefing-layer briefing-layer-telemetry",children:[s.jsx(Ko,{eyebrow:"Telemetry",title:"Calls & usage"}),s.jsxs("dl",{className:"briefing-telemetry",children:[s.jsx(vT,{label:"Analyst",model:e.model,responseId:e.responseId,telemetry:e.telemetry??null}),e.presenter?s.jsx(vT,{label:"Presenter",model:e.presenter.model,responseId:e.presenter.responseId,telemetry:e.presenter,note:e.presenter.skipped==="rate-guard"?"skipped — rate-guard hit":e.presenter.skipped==="error"?`failed — ${e.presenter.errorMessage??"unknown"}`:null}):null]})]})}function vT({label:e,model:t,responseId:n,telemetry:a,note:r}){const o=a?.usage??null;return s.jsxs("div",{className:"briefing-telemetry-row",children:[s.jsxs("div",{className:"briefing-telemetry-row-head",children:[s.jsx("span",{className:"briefing-telemetry-label",children:e}),s.jsx("span",{className:"briefing-telemetry-model",children:t}),r?s.jsx("span",{className:"briefing-telemetry-note",children:r}):null]}),s.jsxs("div",{className:"briefing-telemetry-stats",children:[s.jsx("span",{children:a&&a.elapsedMs>0?`${(a.elapsedMs/1e3).toFixed(2)}s`:"—"}),s.jsxs("span",{children:["in ",o?.inputTokens??"—"]}),s.jsxs("span",{children:["out ",o?.outputTokens??"—"]}),s.jsxs("span",{children:["total ",o?.totalTokens??"—"]}),n?s.jsx("span",{className:"briefing-telemetry-response",children:n}):null]})]})}function Die({presented:e}){return s.jsxs("section",{className:"briefing-layer briefing-layer-presented",children:[s.jsx(Ko,{eyebrow:"Spoken",title:`Presented as · ${e.voiceSpec.persona}, ~${e.voiceSpec.targetWords} words`}),s.jsx("ol",{className:"briefing-presented-sentences",children:e.sentences.map((t,n)=>s.jsx("li",{className:"briefing-presented-sentence",children:t},n))}),s.jsxs("div",{className:"briefing-presented-meta",children:["model: ",e.model,e.responseId?` · response: ${e.responseId}`:""]})]})}function Lie({brief:e,navigate:t}){return e?s.jsxs("section",{className:"briefing-layer",children:[s.jsx(Ko,{eyebrow:"Layer 3",title:"Brief"}),e.steps.length>0?s.jsx("ol",{className:"briefing-steps",children:e.steps.map((n,a)=>s.jsxs("li",{className:"briefing-step",children:[s.jsxs("div",{className:"briefing-step-label",children:[a+1,". ",n.label]}),n.narration?s.jsx("p",{className:"briefing-step-narration",children:n.narration}):null]},n.id??a))}):null,e.actions.length>0?s.jsx("div",{className:"briefing-actions",children:e.actions.map((n,a)=>s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{n.route&&t(n.route)},children:n.label},`${n.label}-${a}`))}):null]}):s.jsxs("section",{className:"briefing-layer",children:[s.jsx(Ko,{eyebrow:"Layer 3",title:"Brief & call"}),s.jsx("p",{className:"briefings-placeholder",children:"No brief body persisted."})]})}function zie({observations:e,navigate:t}){return s.jsxs("section",{className:"briefing-layer",children:[s.jsx(Ko,{eyebrow:"Layer 2",title:`Observations (${e.length})`}),e.length===0?s.jsx("p",{className:"briefings-placeholder",children:"No observations on this brief."}):s.jsx("div",{className:"briefing-observations",children:e.map((n,a)=>{const r=n.tone==="warn"?"briefing-observation-warn":n.tone==="err"||n.tone==="error"?"briefing-observation-err":"";return s.jsxs("div",{className:`briefing-observation ${r}`.trim(),children:[s.jsx("div",{className:"briefing-observation-text",children:n.text}),n.references.length>0?s.jsx("div",{className:"briefing-observation-refs",children:n.references.map((o,c)=>s.jsx(Bie,{reference:o,navigate:t},`${o.label}-${c}`))}):null]},a)})})]})}function Bie({reference:e,navigate:t}){const n=!!e.route,a=e.detail?`${e.label} · ${e.detail}`:e.label;return n?s.jsx("button",{type:"button",className:"briefing-ref-chip",onClick:()=>t(e.route),children:a}):s.jsx("span",{className:"briefing-ref-chip briefing-ref-chip-static",children:a})}function Uie({snapshot:e,call:t}){const n=m.useMemo(()=>Fie(e),[e]),[a,r]=m.useState(!1);return s.jsxs("section",{className:"briefing-layer",children:[s.jsx(Ko,{eyebrow:"Layer 1",title:"Read snapshot"}),n.length>0?s.jsx("div",{className:"briefing-snapshot-counts",children:n.map(o=>s.jsxs("span",{className:"briefing-snapshot-count",children:[s.jsx("strong",{children:o.value})," ",o.label]},o.label))}):null,t?s.jsxs("details",{className:"briefing-snapshot-section",children:[s.jsx("summary",{className:"briefing-snapshot-section-head",children:"Call metadata"}),s.jsxs("dl",{className:"briefing-call-grid",children:[s.jsx("dt",{children:"Model"}),s.jsx("dd",{children:t.model}),s.jsx("dt",{children:"Response ID"}),s.jsx("dd",{children:t.responseId??"—"}),s.jsx("dt",{children:"System prompt"}),s.jsx("dd",{children:s.jsx("pre",{className:"briefing-call-prompt",children:t.systemPrompt})}),s.jsx("dt",{children:"Operator request"}),s.jsx("dd",{children:s.jsx("pre",{className:"briefing-call-prompt",children:t.operatorRequest})})]})]}):null,s.jsxs("div",{className:"briefing-snapshot-section",children:[s.jsx("button",{type:"button",className:"briefing-detail-back",onClick:()=>r(o=>!o),children:a?"Hide raw snapshot":"Show raw snapshot JSON"}),a?s.jsx("pre",{className:"briefing-snapshot-raw",children:JSON.stringify(e??{},null,2)}):null]})]})}function Ko({eyebrow:e,title:t}){return s.jsxs("div",{className:"briefing-layer-head",children:[s.jsx("span",{className:"briefing-layer-eyebrow",children:e}),s.jsx("span",{className:"briefing-layer-title",children:t})]})}function Fie(e){if(!e?.state)return[];const t=e.state,n=[],a=(r,o)=>{Array.isArray(o)&&n.push({label:r,value:o.length})};if(a("agents",t.agents),t.fleet&&typeof t.fleet=="object"){const r=t.fleet;a("active asks",r.activeAsks),a("attention",r.needsAttention),a("recent",r.recentCompleted)}if(t.broker&&typeof t.broker=="object"){const r=t.broker;a("broker msgs",r.recentMessages)}if(a("scout chatter",t.scoutChatter),a("tail events",t.agentLogMessages),t.operatorAttention&&typeof t.operatorAttention=="object"){const r=t.operatorAttention;a("operator items",r.items)}return n}const Vie={"fleet-home":"fleet",tour:"tour"};function Hie({navigate:e}){const[t,n]=m.useState(null),[a,r]=m.useState(null),[o,c]=m.useState(!1),u=m.useCallback(async()=>{c(!0);try{const h=await me("/api/briefings?limit=50");n(h.briefings),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to load briefings")}finally{c(!1)}},[]);return m.useEffect(()=>{u()},[u]),s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Briefings"}),s.jsx("p",{className:"sys-page-subtitle",children:"Scoutbot's archived fleet briefs — what it told you, when, and what it saw. Rolling 100."})]}),s.jsx("div",{className:"sys-page-actions",children:s.jsx("button",{type:"button",className:"s-btn",disabled:o,onClick:()=>{u()},children:o?"Refreshing...":"Refresh"})})]}),a?s.jsx(sa,{title:"Couldn't load briefings",body:a}):t===null?s.jsx("div",{className:"briefings-placeholder",children:"Loading briefings..."}):t.length===0?s.jsx(sa,{title:"No briefings yet",body:"Scoutbot writes here when it generates a fleet brief — either on Home or via tour. Briefs land in this archive automatically."}):s.jsx("ul",{className:"briefings-list",children:t.map(h=>s.jsx("li",{children:s.jsxs("button",{type:"button",className:"briefing-row",onClick:()=>e({view:"briefings",briefingId:h.id}),children:[s.jsxs("div",{className:"briefing-row-head",children:[s.jsx("span",{className:`briefing-kind briefing-kind-${h.kind}`,children:Vie[h.kind]}),s.jsx("span",{className:"briefing-row-title",children:h.title}),s.jsx("span",{className:"briefing-row-time",children:Ae(h.preparedAt)})]}),s.jsx("div",{className:"briefing-row-summary",children:h.summary}),s.jsxs("div",{className:"briefing-row-meta",children:[s.jsxs("span",{children:[h.observationCount," observations"]}),h.recommendation?s.jsxs("span",{children:["· ",h.recommendation]}):null]})]})},h.id))})]})}const yT={attempts:"Dispatch",dialogue:"Dialogue",failed_queries:"Failed queries",failed_deliveries:"Failed deliveries"};function Jb(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-5)}`:"none"}function qie(e){return`${Math.round(e*100)}%`}function BP(e){switch(e){case"success":return"sent";case"failed_query":return"query";case"failed_delivery":return"delivery";default:return"attempt"}}function Wie({navigate:e}){const{selectedBrokerAttempt:t,inspectBrokerAttempt:n}=qe(),[a,r]=m.useState(null),[o,c]=m.useState("attempts"),[u,h]=m.useState(!0),[f,g]=m.useState(!1),[v,y]=m.useState(null),x=m.useRef(null),w=m.useRef(0),C=m.useRef(null),T=m.useCallback(async(A="initial")=>{const R=++w.current;!x.current&&A!=="background"?(h(!0),y(null)):g(!0);try{const _=await me("/api/broker?limit=160");if(R!==w.current)return;x.current=_,r(_),y(null)}catch(_){if(R!==w.current)return;y(_ instanceof Error?_.message:String(_))}finally{R===w.current&&(h(!1),g(!1))}},[]),E=m.useCallback(()=>{C.current||(C.current=setTimeout(()=>{C.current=null,T("background")},250))},[T]);m.useEffect(()=>(T("initial"),()=>{C.current&&clearTimeout(C.current)}),[T]),tn(A=>{(A.kind==="message.posted"||A.kind==="delivery.planned"||A.kind==="delivery.attempted"||A.kind==="delivery.state.changed"||A.kind==="scout.dispatched")&&E()});const S=m.useMemo(()=>{if(!a)return[];switch(o){case"failed_queries":return a.failedQueries;case"failed_deliveries":return a.failedDeliveries;case"dialogue":return a.dialogue;default:return a.attempts}},[o,a]),k=m.useMemo(()=>!a||!t?null:a.attempts.find(A=>A.id===t.id)??a.failedQueries.find(A=>A.id===t.id)??a.failedDeliveries.find(A=>A.id===t.id)??null,[a,t]);m.useEffect(()=>{k&&k!==t&&n(k)},[n,k,t]);const N=a?[{label:"Dispatch",value:String(a.totals.successfulDispatches),detail:`${a.rates.messagesPerHour}/hour chatter`},{label:"Failed queries",value:String(a.totals.failedQueries),detail:`${a.rates.failedQueriesPerHour}/hour`},{label:"Failed deliveries",value:String(a.totals.failedDeliveries+a.totals.failedDeliveryAttempts),detail:`${a.rates.failedDeliveriesPerHour}/hour`},{label:"Failure rate",value:qie(a.rates.failureRate),detail:`${a.totals.deliveryAttempts} delivery attempts`}]:[];return s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Broker"}),s.jsx("p",{className:"sys-page-subtitle",children:"Dispatch success, failed queries, delivery failures, and broker dialogue."})]}),s.jsxs("div",{className:"sys-page-actions",children:[s.jsx("div",{className:"sys-sync-note",children:u?"Loading broker ledger...":a?`Updated ${Ae(a.generatedAt)}`:"Waiting for broker data"}),s.jsx("button",{type:"button",className:"s-btn",disabled:u||f,onClick:()=>{T("manual")},children:f?"Refreshing...":"Refresh"})]})]}),a&&s.jsx("div",{className:"sys-stat-grid",children:N.map(A=>s.jsxs("div",{className:"sys-stat-card",children:[s.jsx("span",{className:"sys-stat-label",children:A.label}),s.jsx("strong",{className:"sys-stat-value",children:A.value}),s.jsx("span",{className:"sys-stat-detail",children:A.detail})]},A.label))}),v&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Refresh failed."}),s.jsx("span",{children:v})]}),u&&!a&&s.jsx(sa,{title:"Loading broker",body:"Reading the broker database snapshot."}),!u&&!a&&!v&&s.jsx(sa,{title:"No broker data",body:"No broker records are available yet."}),a&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sys-tab-row",role:"tablist","aria-label":"Broker diagnostics",children:Object.keys(yT).map(A=>s.jsx("button",{type:"button",role:"tab","aria-selected":o===A,className:`sys-tab${o===A?" sys-tab-active":""}`,onClick:()=>c(A),children:yT[A]},A))}),o==="dialogue"?s.jsx(Xie,{items:S,navigate:e}):s.jsx(Gie,{attempts:S,navigate:e,selectedAttemptId:t?.id??null,onInspect:n})]})]})}function Gie({attempts:e,navigate:t,selectedAttemptId:n,onInspect:a}){const{route:r}=qe();return e.length===0?s.jsx(sa,{title:"No records",body:"This broker slice is empty for the selected window."}):s.jsx("div",{className:"sys-audit-list",children:e.map(o=>{const c=nse(o.kind,o.status),u=()=>{a(o),window.dispatchEvent(new CustomEvent("scout:set-inspector-width",{detail:{width:420}}))};return s.jsxs("article",{className:`sys-broker-row${n===o.id?" sys-broker-row-selected":""}`,tabIndex:0,"aria-label":`Inspect ${o.detail}`,onClick:u,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u())},children:[s.jsxs("div",{className:"sys-broker-row-main",children:[s.jsxs("div",{className:"sys-broker-row-head",children:[s.jsx(Wr,{tone:c,children:BP(o.kind)}),s.jsx("span",{className:"sys-broker-status",children:o.status}),s.jsx("span",{className:"sys-broker-time",children:Ae(o.ts)})]}),s.jsx("h3",{className:"sys-broker-title",children:o.detail}),s.jsxs("div",{className:"sys-broker-meta",children:[s.jsxs("span",{children:["from ",o.actorName??"unknown"]}),s.jsxs("span",{children:["to ",o.target??"none"]}),s.jsxs("span",{children:["route ",o.route??"none"]})]})]}),s.jsxs("div",{className:"sys-broker-row-side",children:[s.jsx("code",{children:Jb(o.messageId??o.deliveryId??o.invocationId??o.id)}),o.conversationId&&s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:h=>{h.stopPropagation(),kt(t,{view:"conversation",conversationId:o.conversationId},{returnTo:r})},children:"Open thread"})]})]},o.id)})})}function Zie(e){return[{label:"Status",value:e.status},{label:"Kind",value:BP(e.kind)},{label:"Time",value:Wa(e.ts)},{label:"Actor",value:e.actorName},{label:"Target",value:e.target},{label:"Route",value:e.route},{label:"Conversation",value:e.conversationId},{label:"Message",value:e.messageId},{label:"Delivery",value:e.deliveryId},{label:"Invocation",value:e.invocationId}].filter(t=>t.value)}function Kie(e){return!e||Object.keys(e).length===0?"{}":JSON.stringify(e,null,2)}function Yie({attempt:e,navigate:t,onClose:n}){const{route:a}=qe(),r=Zie(e);return s.jsxs("aside",{className:"sys-panel sys-broker-inspector","aria-label":"Broker route inspector",children:[s.jsxs("div",{className:"sys-broker-inspector-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"sys-kicker",children:"Inspector"}),s.jsx("h3",{className:"sys-state-title",children:e.detail})]}),s.jsxs("div",{className:"sys-inline-actions",children:[e.conversationId&&s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>kt(t,{view:"conversation",conversationId:e.conversationId},{returnTo:a}),children:"Open thread"}),s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:n,children:"Close"})]})]}),s.jsx("div",{className:"sys-detail-grid sys-broker-inspector-grid",children:r.map(o=>s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:o.label}),s.jsx("code",{className:"sys-detail-value",children:o.value})]},o.label))}),s.jsxs("div",{className:"sys-broker-metadata",children:[s.jsx("span",{className:"sys-detail-label",children:"Metadata"}),s.jsx("pre",{children:Kie(e.metadata)})]})]})}function Xie({items:e,navigate:t}){const{route:n}=qe();return e.length===0?s.jsx(sa,{title:"No dialogue",body:"No messages were recorded in the selected window."}):s.jsx("div",{className:"sys-audit-list",children:e.map(a=>s.jsxs("article",{className:"sys-broker-row",children:[s.jsxs("div",{className:"sys-broker-row-main",children:[s.jsxs("div",{className:"sys-broker-row-head",children:[s.jsx(Wr,{tone:"neutral",children:a.class}),s.jsx("span",{className:"sys-broker-status",children:a.actorName??"unknown"}),s.jsx("span",{className:"sys-broker-time",children:Wa(a.ts)})]}),s.jsx("h3",{className:"sys-broker-title",children:a.body}),s.jsx("div",{className:"sys-broker-meta",children:s.jsxs("span",{children:["thread ",Jb(a.conversationId)]})})]}),s.jsxs("div",{className:"sys-broker-row-side",children:[s.jsx("code",{children:Jb(a.id)}),s.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>kt(t,{view:"conversation",conversationId:a.conversationId},{returnTo:n}),children:"Open thread"})]})]},a.id))})}function sj(e){return e.handle??e.id}function Qie(e,t){if(!t)return!0;const n=t.toLowerCase();return e.name.toLowerCase().includes(n)||sj(e).toLowerCase().includes(n)||e.id.toLowerCase().includes(n)}function UP({agents:e,query:t,excludeIds:n,maxResults:a=50}){const r=m.useMemo(()=>new Set(n??[]),[n]),o=m.useMemo(()=>e.filter(v=>!r.has(v.id)&&Qie(v,t.trim())).slice(0,a),[e,r,t,a]),[c,u]=m.useState(0);m.useEffect(()=>{u(g=>o.length===0?0:Math.min(g,o.length-1))},[o]);const h=m.useCallback(g=>{u(v=>o.length===0?0:(v+g+o.length)%o.length)},[o.length]),f=m.useCallback(()=>u(0),[]);return{filtered:o,highlightedIndex:c,setHighlightedIndex:u,moveHighlight:h,resetHighlight:f}}function FP({agents:e,highlightedIndex:t,onSelect:n,onHover:a,emptyHint:r,pendingId:o,className:c,id:u}){return e.length===0?s.jsx("div",{className:`agent-autocomplete ${c??""}`,id:u,children:s.jsx("div",{className:"agent-autocomplete-empty",children:r??"No matches."})}):s.jsx("div",{className:`agent-autocomplete ${c??""}`,role:"listbox",id:u,children:e.map((h,f)=>{const g=sj(h),v=f===t;return s.jsxs("button",{type:"button",role:"option","aria-selected":v,className:`agent-autocomplete-item${v?" is-active":""}`,onMouseDown:y=>{y.preventDefault(),n(h)},onMouseEnter:()=>a?.(f),disabled:o===h.id,children:[s.jsx("div",{className:"agent-autocomplete-avatar",style:{background:qt(h.name)},children:h.name[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"agent-autocomplete-info",children:[s.jsx("span",{className:"agent-autocomplete-name",children:h.name}),s.jsxs("span",{className:"agent-autocomplete-handle",children:["@",g]})]})]},h.id)})})}function Jie({agents:e,excludeIds:t,open:n,onClose:a,onSelect:r,placeholder:o="Search agents…",emptyHint:c,pendingId:u,anchor:h="below-right",className:f,triggerRef:g}){const[v,y]=m.useState(""),x=m.useRef(null),w=m.useRef(null),{filtered:C,highlightedIndex:T,setHighlightedIndex:E,moveHighlight:S}=UP({agents:e,query:v,excludeIds:t});if(m.useEffect(()=>{if(!n){y("");return}queueMicrotask(()=>x.current?.focus());const N=R=>{const _=R.target;w.current?.contains(_)||g?.current?.contains(_)||a()},A=R=>{R.key==="Escape"&&a()};return document.addEventListener("mousedown",N),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",A)}},[n,a,g]),!n)return null;const k=N=>{if(N.key==="ArrowDown")N.preventDefault(),S(1);else if(N.key==="ArrowUp")N.preventDefault(),S(-1);else if(N.key==="Enter"){const A=C[T];A&&(N.preventDefault(),r(A))}};return s.jsxs("div",{ref:w,className:`agent-picker agent-picker--${h} ${f??""}`,children:[s.jsx("input",{ref:x,className:"agent-picker-search",placeholder:o,value:v,onChange:N=>y(N.target.value),onKeyDown:k,"aria-autocomplete":"list"}),s.jsx(FP,{agents:C,highlightedIndex:T,onSelect:N=>{r(N)},onHover:E,emptyHint:c,pendingId:u})]})}const eoe=/(^|\s)@([a-zA-Z0-9_.-]*)$/,Vh=4,toe=254;function noe(e,t){if(t<=0)return null;const n=e.slice(0,t),a=eoe.exec(n);if(!a)return null;a[1];const r=a[2]??"",o=n.length-r.length-1;return o<0?null:(e.slice(t,t+1),{start:o,end:t,query:r})}const soe=["boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","whiteSpace","wordWrap","wordBreak"];function aoe(e,t){const n=document.createElement("div");document.body.appendChild(n);const a=n.style,r=window.getComputedStyle(e);a.position="absolute",a.visibility="hidden",a.whiteSpace="pre-wrap",a.wordWrap="break-word",a.top="0",a.left="-9999px";for(const f of soe)a[f]=r[f];n.textContent=e.value.slice(0,t);const o=document.createElement("span");o.textContent=e.value.slice(t)||".",n.appendChild(o);const c=o.offsetTop,u=o.offsetLeft,h=parseInt(r.lineHeight,10)||o.offsetHeight;return document.body.removeChild(n),{top:c,left:u,height:h}}const roe=m.forwardRef(function({agents:t,excludeIds:n,value:a,onChange:r,onSubmit:o,placeholder:c,rows:u=1,disabled:h,className:f,textareaClassName:g,emptyHint:v,onMention:y},x){const w=m.useRef(null),C=m.useRef(null),[T,E]=m.useState(null),[S,k]=m.useState(null);m.useImperativeHandle(x,()=>({focus:()=>w.current?.focus(),blur:()=>w.current?.blur(),get textarea(){return w.current}}),[]);const N=T?.query??"",{filtered:A,highlightedIndex:R,setHighlightedIndex:_,moveHighlight:P}=UP({agents:t,query:N,excludeIds:n}),$=m.useCallback(()=>{const U=w.current;if(!U)return;const D=noe(U.value,U.selectionStart??0);E(D)},[]);m.useLayoutEffect(()=>{const U=w.current;if(!U||!T){k(null);return}const{top:D,left:V,height:Z}=aoe(U,T.start),O=U.getBoundingClientRect(),z=U.parentElement?.getBoundingClientRect(),B=z?O.top-z.top:0,X=z?O.left-z.left:0,W=C.current?.offsetHeight||toe,L=window.visualViewport,q=L?.offsetTop??0,K=q+(L?.height??window.innerHeight),ee=O.top+D-U.scrollTop,G=ee+Z,re=K-G-Vh,Q=ee-q-Vh,ae=re<W&&Q>re;k({top:ae?B+D-U.scrollTop-W-Vh:B+D+Z-U.scrollTop+Vh,left:X+V-U.scrollLeft})},[T,a,A.length]);const H=m.useCallback(U=>{const D=w.current,V=T;if(!D||!V)return;const Z=sj(U),O=a.slice(0,V.start),z=a.slice(V.end),B=`@${Z} `,X=`${O}${B}${z}`;r(X),y?.(U),E(null);const W=V.start+B.length;queueMicrotask(()=>{const L=w.current;L&&(L.focus(),L.setSelectionRange(W,W))})},[T,a,r,y]),I=U=>{if(T&&A.length>0){if(U.key==="ArrowDown"){U.preventDefault(),P(1);return}if(U.key==="ArrowUp"){U.preventDefault(),P(-1);return}if(U.key==="Enter"||U.key==="Tab"){const D=A[R];if(D){U.preventDefault(),H(D);return}}if(U.key==="Escape"){U.preventDefault(),E(null);return}}U.key==="Enter"&&!U.shiftKey&&!T&&(U.preventDefault(),o?.())};return s.jsxs("div",{className:`agent-mention-wrap ${f??""}`,children:[s.jsx("textarea",{ref:w,className:g,value:a,rows:u,placeholder:c,disabled:h,onChange:U=>{r(U.target.value),queueMicrotask($)},onKeyUp:$,onClick:$,onBlur:()=>E(null),onKeyDown:I,"aria-autocomplete":"list"}),T&&s.jsx("div",{ref:C,className:"agent-mention-popover",style:{top:`${S?.top??0}px`,left:`${S?.left??0}px`,visibility:S?void 0:"hidden"},children:s.jsx(FP,{agents:A,highlightedIndex:R,onSelect:H,onHover:_,emptyHint:v??"No matches."})})]})});function xT(e){return[...e].sort((t,n)=>t.createdAt-n.createdAt)}function ioe(e,t){if(e.actorId){const a=t.find(r=>r.id===e.actorId);if(a)return a}if(!e.actorName)return null;const n=t.filter(a=>a.name===e.actorName);return n.length===1?n[0]:null}function ooe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n].id!==t[n].id||e[n].name!==t[n].name)return!1;return!0}function loe({channel:e,agents:t,extraActors:n}){const a=m.useMemo(()=>e.participantIds.filter(S=>S!=="operator"),[e.participantIds]),r=m.useMemo(()=>{const S=new Map,k=new Set(a),N=(A,R,_)=>{if(S.has(A))return;const P=t.find($=>$.id===A)??null;S.set(A,P?{id:P.id,name:P.name,handle:P.handle??P.id,state:Je(P.state),isMember:_,agent:P}:{id:A,name:R,handle:A,state:Je(null),isMember:_,agent:null})};for(const A of a)N(A,A,!0);for(const A of n)A.id!=="operator"&&N(A.id,A.name,k.has(A.id));return Array.from(S.values())},[a,n,t]),o=r.filter(S=>S.state!=="offline").length,c=r.filter(S=>!S.isMember).length,[u,h]=m.useState(!1),[f,g]=m.useState(!1),[v,y]=m.useState(null),x=m.useRef(null),w=m.useRef(null),C=m.useRef(null);m.useEffect(()=>{if(!u)return;const S=N=>{const A=N.target;x.current?.contains(A)||w.current?.contains(A)||h(!1)},k=N=>{N.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",S),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",k)}},[u]);const T=async S=>{y(S);try{await me(`/api/conversations/${encodeURIComponent(e.id)}/members`,{method:"POST",body:JSON.stringify({actorId:S})}),g(!1)}finally{y(null)}},E=async S=>{y(S);try{await me(`/api/conversations/${encodeURIComponent(e.id)}/members/${encodeURIComponent(S)}`,{method:"DELETE"})}finally{y(null)}};return s.jsxs("div",{className:"ch-members-control",children:[s.jsxs("button",{ref:w,type:"button",className:"ch-members-trigger",onClick:()=>h(S=>!S),"aria-label":`${r.length} members${o?`, ${o} online`:""}`,"aria-expanded":u,title:"View members",children:[s.jsxs("div",{className:"ch-members-stack",children:[r.slice(0,4).map(S=>s.jsx("div",{className:"ch-members-pip",style:{background:qt(S.name)},children:S.name[0]?.toUpperCase()??"?"},S.id)),r.length>4&&s.jsxs("span",{className:"ch-members-overflow",children:["+",r.length-4]})]}),s.jsxs("span",{className:"ch-members-count",children:[r.length,o>0&&s.jsx("span",{className:"ch-members-online-dot","aria-hidden":!0})]})]}),u&&s.jsxs("div",{ref:x,className:"ch-members-roster",role:"dialog","aria-label":"Members",children:[s.jsxs("div",{className:"ch-members-roster-header",children:[s.jsxs("span",{className:"ch-members-roster-title",children:[r.length," member",r.length!==1?"s":""]}),o>0&&s.jsxs("span",{className:"ch-members-roster-online",children:[o," online"]})]}),s.jsx("div",{className:"ch-members-roster-list",children:r.length===0?s.jsx("div",{className:"ch-members-roster-empty",children:"No agents in this channel yet."}):r.map(S=>s.jsx(coe,{member:S,removeBusy:v===S.id,onRemove:()=>{E(S.id)}},S.id))}),c>0&&s.jsxs("div",{className:"ch-members-roster-footnote",children:[c," ",c===1?"guest is":"guests are"," posting without being formally added."]})]}),s.jsx("button",{ref:C,type:"button",className:"ch-members-add",onClick:()=>g(S=>!S),"aria-label":"Add member","aria-expanded":f,children:"+"}),s.jsx(Jie,{agents:t,excludeIds:a,open:f,onClose:()=>g(!1),onSelect:S=>{T(S.id)},pendingId:v,emptyHint:"All agents already in channel.",triggerRef:C})]})}function coe({member:e,removeBusy:t,onRemove:n}){const{triggerProps:a,popover:r}=Hw({agent:e.agent}),o=e.name[0]?.toUpperCase()??"?";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ch-members-roster-row","data-guest":e.isMember?void 0:"true",children:[s.jsxs("button",{type:"button",className:"ch-members-roster-trigger",...a,"aria-label":`Open ${e.name} profile`,children:[s.jsxs("div",{className:"ch-members-roster-avatar-wrap",children:[s.jsx("div",{className:"ch-members-roster-avatar",style:{background:qt(e.name)},children:o}),s.jsx("span",{className:"ch-members-roster-dot",style:{background:Pn(e.state)}})]}),s.jsxs("div",{className:"ch-members-roster-info",children:[s.jsx("span",{className:"ch-members-roster-name",children:e.name}),s.jsxs("span",{className:"ch-members-roster-handle",children:["@",e.handle,!e.isMember&&s.jsx("span",{className:"ch-members-roster-guest-tag",children:"guest"})]})]}),e.state==="working"&&s.jsx("span",{className:"ch-members-roster-state",children:"working"})]}),e.isMember&&s.jsx("button",{type:"button",className:"ch-members-roster-remove",onClick:n,disabled:t,"aria-label":`Remove ${e.name}`,title:`Remove ${e.name}`,children:"×"})]}),r]})}function uoe({message:e,agent:t,isYou:n,operatorName:a,showAvatar:r,showDay:o}){const{triggerProps:c,popover:u}=Hw({agent:n?null:t}),h=Wa(e.createdAt),f=n?a:e.actorName??"?",g=(n?a[0]:e.actorName?.[0]??"?").toUpperCase(),v=qt(n?a:e.actorName??"?"),y=n?a.toLowerCase():t?.handle??null,x=!n&&t!==null;return s.jsxs("div",{className:"ch-msg-group",children:[o&&s.jsxs("div",{className:"s-thread-day-divider",children:[s.jsx("span",{className:"s-thread-day-line"}),s.jsx("span",{className:"s-thread-day-label",children:qb(e.createdAt)}),s.jsx("span",{className:"s-thread-day-line"})]}),s.jsxs("article",{id:`msg-${e.id}`,className:["ch-msg",r&&"ch-msg--with-meta"].filter(Boolean).join(" "),children:[s.jsx("div",{className:"ch-msg-meta",children:r?s.jsxs(s.Fragment,{children:[x?s.jsxs("button",{type:"button",className:"ch-msg-meta-top ch-msg-meta-top--trigger",...c,"aria-label":`Open ${f} profile`,children:[s.jsx("div",{className:"ch-msg-avatar",style:{background:v},children:g}),s.jsx("span",{className:"ch-msg-author",style:{color:v},children:f})]}):s.jsxs("div",{className:"ch-msg-meta-top",children:[s.jsx("div",{className:"ch-msg-avatar",style:{background:v},children:g}),s.jsx("span",{className:"ch-msg-author",style:{color:v},children:f})]}),s.jsxs("div",{className:"ch-msg-meta-detail",children:[y&&s.jsxs("span",{className:"ch-msg-handle",children:["@",y]}),s.jsx("span",{className:"ch-msg-time",title:h,children:Ae(e.createdAt)})]})]}):s.jsx("span",{className:"ch-msg-inline-time",title:h,children:Ae(e.createdAt)})}),s.jsxs("div",{className:"ch-msg-body-col",children:[s.jsx("div",{className:"ch-msg-body",children:s.jsx(Gw,{text:e.body})}),s.jsx(CP,{message:e})]})]}),u]})}function doe({channelId:e,channelName:t,agents:n,operatorName:a,onMessageCountChange:r,onSeenActorsChange:o}){const[c,u]=m.useState([]),[h,f]=m.useState(""),[g,v]=m.useState(!1),[y,x]=m.useState(null),w=m.useRef(null),C=m.useRef(0),T=m.useRef(!1),E=m.useCallback(async()=>{try{const N=await me(`/api/messages?conversationId=${encodeURIComponent(e)}&limit=300`),A=xT(N);u(A),Kw(e);const R=A.at(-1);R&&me(`/api/conversations/${encodeURIComponent(e)}/read-cursor`,{method:"POST",body:JSON.stringify({lastReadMessageId:R.id})}).catch(()=>{}),A.length!==C.current&&(C.current=A.length,r(A.length))}catch{}},[e,r]);m.useEffect(()=>{E()},[E]),tn(N=>{N.kind==="message.posted"&&N.payload?.message?.conversationId===e&&E()}),m.useEffect(()=>{if(c.length===0)return;const N=T.current?"smooth":"instant";w.current?.scrollIntoView({behavior:N}),T.current=!0},[c.length]);const S=m.useRef([]);m.useEffect(()=>{if(!o)return;const N=new Map;for(const R of c)!R.actorId||R.actorId==="operator"||N.has(R.actorId)||N.set(R.actorId,R.actorName);const A=Array.from(N,([R,_])=>({id:R,name:_})).sort((R,_)=>R.id.localeCompare(_.id));ooe(S.current,A)||(S.current=A,o(A))},[c,o]);const k=async()=>{const N=h.trim();if(!N||g)return;v(!0),f(""),x(null);const A={id:`optimistic-${Date.now()}`,conversationId:e,actorId:"operator",actorName:a,body:N,createdAt:Date.now(),class:"operator"};u(R=>xT([...R,A]));try{await me("/api/send",{method:"POST",body:JSON.stringify({body:N,conversationId:e})})}catch(R){u(_=>_.filter(P=>P.id!==A.id)),x(R instanceof Error?R.message:"Failed to send")}finally{v(!1)}};return s.jsxs("div",{className:"ch-feed-shell",children:[s.jsxs("div",{className:"ch-feed",children:[s.jsx("div",{className:"ch-feed-spacer"}),c.length===0&&s.jsxs("div",{className:"ch-empty-feed",children:[s.jsx("div",{className:"ch-empty-feed-hash",children:"#"}),s.jsxs("p",{className:"ch-empty-feed-title",children:["Welcome to #",t]}),s.jsx("p",{className:"ch-empty-feed-sub",children:"This is the beginning of the channel. Be the first to post."})]}),c.map((N,A)=>{const R=N.actorName===a||N.class==="operator",_=A===0||!cP(c[A-1]?.createdAt,N.createdAt),P=A===0||c[A-1]?.actorName!==N.actorName||_,$=R?null:ioe(N,n);return s.jsx(uoe,{message:N,agent:$,isYou:R,operatorName:a,showAvatar:P,showDay:_},N.id)}),s.jsx("div",{ref:w})]}),y&&s.jsx("div",{className:"ch-compose-error",children:y}),s.jsx("div",{className:"ch-compose-wrap",children:s.jsxs("form",{className:"ch-compose",onSubmit:N=>{N.preventDefault(),k()},children:[s.jsx(roe,{agents:n,value:h,onChange:f,onSubmit:()=>{k()},placeholder:`Message #${t}…`,rows:1,disabled:g,textareaClassName:"ch-compose-input"}),s.jsx(Jw,{onAppend:N=>f(A=>A.trim()?`${A.trimEnd()} ${N}`:N)}),s.jsx("button",{type:"submit",className:"ch-compose-send",disabled:!h.trim()||g,"aria-label":"Send message",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"}),s.jsx("polyline",{points:"8 2 14 8 8 14"})]})})]})})]})}const foe=[{slug:"releases",description:"Coordinate deploys across agents working different repos."},{slug:"triage",description:"Route incoming issues to the right agent automatically."},{slug:"reviews",description:"All PR feedback and review requests in one thread."}];function hoe({count:e}){return s.jsxs("div",{className:"ch-overview",children:[s.jsxs("div",{className:"ch-overview-header",children:[s.jsx("div",{className:"ch-overview-hash",children:"#"}),s.jsxs("div",{className:"ch-overview-heading",children:[s.jsx("h2",{className:"ch-overview-title",children:"Channels"}),s.jsx("p",{className:"ch-overview-tagline",children:"Shared spaces where agents and operators coordinate over a common thread."})]})]}),s.jsxs("div",{className:"ch-overview-body",children:[s.jsxs("div",{className:"ch-overview-block",children:[s.jsx("div",{className:"ch-overview-block-label",children:"How it works"}),s.jsxs("p",{className:"ch-overview-block-text",children:["A channel is a broker-backed conversation anyone on the mesh can join. Send a message to any ",s.jsx("code",{className:"ch-overview-code",children:"channel.*"})," address and the broker creates it automatically. Agents, bridges, and operators all share the same thread."]})]}),s.jsxs("div",{className:"ch-overview-block",children:[s.jsx("div",{className:"ch-overview-block-label",children:e===0?"Start your first channel":`${e} channel${e!==1?"s":""} — pick one from the left`}),s.jsx("div",{className:"ch-overview-examples",children:foe.map(t=>s.jsxs("div",{className:"ch-overview-example",children:[s.jsxs("span",{className:"ch-overview-example-name",children:[s.jsx("span",{className:"ch-overview-example-hash",children:"#"}),t.slug]}),s.jsx("span",{className:"ch-overview-example-desc",children:t.description})]},t.slug))}),e===0&&s.jsxs("div",{className:"ch-overview-hint",children:["From any agent: ",s.jsx("code",{className:"ch-overview-code",children:'send --to channel.releases "deploy ready"'})]})]})]})]})}function VP({channelId:e,navigate:t}){const{agents:n,route:a}=qe(),[r,o]=m.useState([]),[c,u]=m.useState("operator"),h=oa(a),f=m.useMemo(()=>eo(n,h),[n,h]),g=m.useMemo(()=>el(n,h),[n,h]),v=m.useMemo(()=>og(r,f,h).filter(Uo),[r,f,h]),y=e?v.find(T=>T.id===e)??null:null,[x,w]=m.useState([]);m.useEffect(()=>{w([])},[e]);const C=m.useCallback(async()=>{const T=await me("/api/conversations").catch(()=>[]);o(T)},[]);return m.useEffect(()=>{C()},[C]),m.useEffect(()=>{me("/api/user").then(T=>{T?.name&&u(T.name)}).catch(()=>{})},[]),tn(T=>{(T.kind==="message.posted"||T.kind==="conversation.upserted")&&C()}),s.jsx("div",{className:"ch-screen",children:y?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ch-center-header",children:[s.jsxs("div",{className:"ch-center-header-left",children:[s.jsx("span",{className:"ch-center-hash",children:"#"}),s.jsx("span",{className:"ch-center-title",children:Ha(y)}),s.jsx("span",{className:"ch-center-slug",children:uP(y)})]}),s.jsx("div",{className:"ch-center-header-right",children:s.jsx(loe,{channel:y,agents:g,extraActors:x})})]}),s.jsx("div",{className:"ch-body",children:s.jsx(doe,{channelId:e,channelName:Ha(y),agents:g,operatorName:c,onMessageCountChange:()=>{},onSeenActorsChange:w},e)})]}):s.jsx(hoe,{count:v.length})})}const bT=["direct","channel","group_direct","thread","system"],moe={direct:"Direct messages",channel:"Channels",group_direct:"Group DMs",thread:"Threads",system:"System"};function wT(e){const t=bT.indexOf(e);return t===-1?bT.length:t}function poe(e){const t=[e.agentName,e.currentBranch,e.workspaceRoot].filter(Boolean);return t.length>0?t.join(" · "):`${e.participantIds.length} participant${e.participantIds.length===1?"":"s"}`}function goe({navigate:e}){const{agents:t,route:n}=qe(),[a,r]=m.useState([]),[o,c]=m.useState(!0),[u,h]=m.useState(null),[f,g]=m.useState(""),v=oa(n),y=m.useMemo(()=>eo(t,v),[t,v]),x=m.useCallback(async()=>{try{const T=await me("/api/conversations");r(T),h(null)}catch(T){h(T instanceof Error?T.message:"Failed to load conversations")}finally{c(!1)}},[]);m.useEffect(()=>{x()},[x]),tn(T=>{(T.kind==="message.posted"||T.kind==="conversation.upserted"||T.kind==="agent.endpoint.upserted")&&x()});const w=m.useMemo(()=>{const T=f.trim().toLowerCase(),E=og(a,y,v);return T?E.filter(S=>[S.title,S.kind,S.agentName??"",S.preview??"",S.workspaceRoot??"",...S.participantIds].some(k=>k.toLowerCase().includes(T))):E},[a,y,v,f]),C=m.useMemo(()=>{const T=new Map;for(const E of w){const S=T.get(E.kind)??[];S.push(E),T.set(E.kind,S)}return[...T.entries()].sort((E,S)=>wT(E[0])-wT(S[0])).map(([E,S])=>({key:E,label:moe[E]??E,items:S}))},[w]);return s.jsxs("div",{className:"s-conversations",children:[s.jsxs("div",{className:"s-conversations__hero",children:[s.jsxs("div",{children:[s.jsx("div",{className:"s-conversations__eyebrow",children:"Playground"}),s.jsx("h1",{children:"Conversations"}),s.jsx("p",{children:"Unified, normalized conversation summaries from the broker service — no direct web DB reads in this view."})]}),s.jsx("button",{type:"button",className:"s-conversations__refresh",onClick:()=>{c(!0),x()},children:"Refresh"})]}),s.jsxs("div",{className:"s-conversations__toolbar",children:[s.jsx("input",{type:"text",className:"s-conversations__search",placeholder:"Filter conversations…",value:f,onChange:T=>g(T.target.value)}),s.jsxs("div",{className:"s-conversations__meta",children:[s.jsxs("span",{children:[w.length," shown"]}),s.jsxs("span",{children:[a.length," total"]})]})]}),u?s.jsx("div",{className:"s-conversations__state s-conversations__state--error",children:u}):null,!u&&o?s.jsx("div",{className:"s-conversations__state",children:"Loading conversations…"}):null,!o&&!u&&C.length===0?s.jsx("div",{className:"s-conversations__state",children:"No conversations yet."}):null,s.jsx("div",{className:"s-conversations__sections",children:C.map(T=>s.jsxs("section",{className:"s-conversations__section",children:[s.jsxs("div",{className:"s-conversations__section-header",children:[s.jsx("h2",{children:T.label}),s.jsx("span",{children:T.items.length})]}),s.jsx("div",{className:"s-conversations__list",children:T.items.map(E=>s.jsxs("button",{type:"button",className:"s-conversations__row",onClick:()=>kt(e,{view:"conversation",conversationId:E.id},{returnTo:n}),children:[s.jsxs("div",{className:"s-conversations__row-main",children:[s.jsxs("div",{className:"s-conversations__row-titleline",children:[s.jsx("strong",{children:E.title}),s.jsx("span",{className:`s-conversations__kind s-conversations__kind--${E.kind.replace(/_/g,"-")}`,children:E.kind})]}),s.jsx("div",{className:"s-conversations__row-sub",children:poe(E)}),s.jsx("div",{className:"s-conversations__row-preview",children:E.preview?.trim()||"No preview yet"})]}),s.jsxs("div",{className:"s-conversations__row-side",children:[s.jsxs("span",{children:[E.messageCount," msg"]}),s.jsx("span",{children:E.lastMessageAt?Ae(E.lastMessageAt):"—"})]})]},E.id))})]},T.key))})]})}function Fl(...e){return e.find(t=>t&&t.trim().length>0)?.trim()??null}function jT(e,t){return t==="work"&&e.workId?{view:"work",workId:e.workId}:t==="session"&&e.sessionId?{view:"sessions",sessionId:e.sessionId}:t==="chat"&&e.conversationId?{view:"conversation",conversationId:e.conversationId}:t==="tail"?{view:"ops",mode:"tail",...e.sessionId?{tailQuery:e.sessionId}:{}}:e.workId?{view:"work",workId:e.workId}:e.sessionId?{view:"sessions",sessionId:e.sessionId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.flightId||e.invocationId||e.targetAgentId?{view:"ops",mode:"tail"}:{view:"inbox"}}function voe(e){return{flightId:e.flightId??null,invocationId:e.invocationId??null,conversationId:e.conversationId??null,workId:e.workId??null,sessionId:e.sessionId??null,targetAgentId:e.targetAgentId??null}}function yoe({route:e,navigate:t}){const[n,a]=m.useState(null),r=m.useMemo(()=>voe(e),[e]);return m.useEffect(()=>{let o=!1;const c=new URLSearchParams;return e.flightId&&c.set("flightId",e.flightId),e.invocationId&&c.set("invocationId",e.invocationId),e.conversationId&&c.set("conversationId",e.conversationId),e.workId&&c.set("workId",e.workId),e.sessionId&&c.set("sessionId",e.sessionId),e.targetAgentId&&c.set("targetAgentId",e.targetAgentId),(async()=>{try{const u=c.toString(),h=u?await me(`/api/follow?${u}`):r;if(o)return;t(jT({flightId:Fl(h.flightId,r.flightId),invocationId:Fl(h.invocationId,r.invocationId),conversationId:Fl(h.conversationId,r.conversationId),workId:Fl(h.workId,r.workId),sessionId:Fl(h.sessionId,r.sessionId),targetAgentId:Fl(h.targetAgentId,r.targetAgentId)},e.preferredView))}catch(u){if(o)return;a(u instanceof Error?u.message:String(u)),t(jT(r,e.preferredView))}})(),()=>{o=!0}},[r,t,e]),s.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:s.jsx("section",{className:"s-thread-overview",children:s.jsxs("div",{className:"s-thread-overview-copy",children:[s.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[s.jsx("h2",{className:"s-page-title",children:"Follow"}),s.jsx("span",{className:"s-meta s-tabular",children:e.preferredView??"auto"})]}),s.jsx("p",{className:"s-thread-overview-summary",children:n?"Opening the closest available Scout view.":"Resolving Scout context..."})]})})})}function kx(e){return e.map(t=>({step:t,state:"pending",progress:0}))}function xoe(e){switch(e){case"scan":return r3;case"collect":return dz;case"inspect":return a2;case"analyze":return Nz;case"synthesize":return Pp;default:return s3}}function boe(e,t={active:!1}){const n=t.speed??1,[a,r]=m.useState(()=>kx(e)),[o,c]=m.useState(!1),[u,h]=m.useState(!1),f=m.useRef(null),g=m.useRef(null),v=m.useRef(0);return m.useEffect(()=>{if(!t.active){f.current!==null&&cancelAnimationFrame(f.current),f.current=null,g.current=null,v.current=0,r(kx(e)),c(!1),h(!1);return}c(!0),h(!1),v.current=0,g.current=null,r(kx(e));const y=x=>{const w=v.current;if(w>=e.length){h(!0),c(!1);return}const T=e[w].duration/n;g.current===null&&(g.current=x,r(k=>{const N=[...k];return N[w]&&N[w].state!=="done"&&(N[w]={...N[w],state:"active",progress:0}),N}));const E=x-(g.current??x),S=Math.min(1,E/T);if(r(k=>{const N=[...k];return N[w]&&N[w].state!=="done"&&(N[w]={...N[w],state:"active",progress:S}),N}),S>=1&&(r(k=>{const N=[...k];return N[w]&&(N[w]={...N[w],state:"done",progress:1}),N}),v.current=w+1,g.current=null,w+1>=e.length)){h(!0),c(!1);return}f.current=requestAnimationFrame(y)};return f.current=requestAnimationFrame(y),()=>{f.current!==null&&cancelAnimationFrame(f.current),f.current=null}},[t.active,e,n]),{runtime:a,playing:o,done:u}}function woe({runtime:e}){return s.jsx("div",{className:"bstudio-seq",children:e.map(t=>s.jsx(joe,{runtime:t},t.step.id))})}function joe({runtime:e}){const{step:t,state:n}=e,a=xoe(t.kind);return s.jsxs("div",{className:"bstudio-seq-row","data-state":n,children:[s.jsxs("div",{className:"bstudio-seq-head",children:[s.jsx("span",{className:"bstudio-seq-state","aria-hidden":"true",children:n==="done"?s.jsx(o2,{size:12}):n==="active"?s.jsx(ea,{size:12,className:"bstudio-spin"}):s.jsx(a,{size:12})}),s.jsx("span",{className:"bstudio-seq-label",children:t.label}),s.jsx("span",{className:"bstudio-seq-leader","aria-hidden":"true"}),s.jsx("span",{className:`bstudio-seq-result${t.countTone?` bstudio-seq-result--${t.countTone}`:""}`,children:n==="done"?t.result:n==="active"?"scanning…":""})]}),n==="active"&&s.jsx("div",{className:"bstudio-seq-body",children:s.jsx(Noe,{sample:t.sample})})]})}function Noe({sample:e}){switch(e.type){case"fleet":return s.jsx(koe,{sample:e});case"sessions":return s.jsx(Soe,{sample:e});case"broker":return s.jsx(Eoe,{sample:e});case"tail":return s.jsx(Aoe,{sample:e});case"plans":return s.jsx(Toe,{sample:e});case"anomalies":return s.jsx(Moe,{sample:e});case"synthesize":return s.jsx(Roe,{lines:e.lines});default:return null}}function koe({sample:e}){return s.jsx("div",{className:"bstudio-sample bstudio-sample--fleet",children:s.jsxs("div",{className:"bstudio-sample-chips",children:[e.agents.map((t,n)=>s.jsxs("span",{className:`bstudio-agent-chip bstudio-agent-chip--${t.tone??"active"}`,style:{animationDelay:`${n*60}ms`},children:[s.jsx("span",{className:"bstudio-agent-dot","aria-hidden":"true"}),t.name,s.jsxs("span",{className:"bstudio-agent-project",children:["/",t.project]})]},t.id)),s.jsxs("span",{className:"bstudio-sample-more",children:["+ ",e.more," more"]})]})})}function Soe({sample:e}){return s.jsx("div",{className:"bstudio-sample",children:s.jsxs("ul",{className:"bstudio-sample-rows",children:[e.sessions.map((t,n)=>s.jsxs("li",{className:"bstudio-session-card",style:{animationDelay:`${n*100}ms`},children:[s.jsxs("div",{className:"bstudio-session-meta",children:[s.jsx("span",{className:"bstudio-session-id",children:t.id}),s.jsx("span",{className:"bstudio-session-project-chip",children:t.project}),s.jsxs("span",{className:"bstudio-session-ago",children:["· ",t.lastActive]})]}),s.jsx("p",{className:"bstudio-session-summary",children:t.summary})]},t.id)),s.jsxs("li",{className:"bstudio-sample-more bstudio-sample-more--row",children:["+ ",e.more," more sessions"]})]})})}function Coe(e){const t=e.split(/[-_/]/).filter(Boolean);return t.length===0?e.slice(0,2).toUpperCase():t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function Eoe({sample:e}){return s.jsx("div",{className:"bstudio-sample",children:s.jsxs("ul",{className:"bstudio-sample-rows",children:[e.messages.map((t,n)=>s.jsxs("li",{className:`bstudio-broker-card${t.tone?` bstudio-broker-card--${t.tone}`:""}`,style:{animationDelay:`${n*110}ms`},children:[s.jsx("div",{className:"bstudio-broker-avatar","aria-hidden":"true",children:Coe(t.from)}),s.jsxs("div",{className:"bstudio-broker-main",children:[s.jsxs("div",{className:"bstudio-broker-meta",children:[s.jsx("span",{className:"bstudio-broker-from",children:t.from}),s.jsx("span",{className:"bstudio-broker-arrow",children:"→"}),s.jsx("span",{className:"bstudio-broker-to",children:t.to}),t.tone&&s.jsx("span",{className:`bstudio-broker-tag bstudio-broker-tag--${t.tone}`,children:t.tone==="err"?"error":"warning"}),s.jsxs("span",{className:"bstudio-broker-ago",children:[t.ago," ago"]})]}),s.jsx("p",{className:"bstudio-broker-body",children:t.body})]})]},`${t.from}-${n}`)),s.jsxs("li",{className:"bstudio-sample-more bstudio-sample-more--row",children:["+ ",e.more," more messages in queue"]})]})})}function Aoe({sample:e}){return s.jsx("div",{className:"bstudio-sample",children:s.jsxs("ul",{className:"bstudio-sample-rows bstudio-tail-rows",children:[e.events.map((t,n)=>s.jsxs("li",{className:"bstudio-tail-row","data-kind":t.kind,style:{animationDelay:`${n*80}ms`},children:[s.jsx("span",{className:"bstudio-tail-ts",children:t.ts}),s.jsx("span",{className:"bstudio-tail-source",children:t.source}),s.jsx("span",{className:"bstudio-tail-kind",children:t.kind}),s.jsx("span",{className:"bstudio-tail-body",children:t.body})]},`${t.ts}-${n}`)),s.jsxs("li",{className:"bstudio-sample-more bstudio-sample-more--row",children:["streaming over ",e.more.toLocaleString()," more events…"]})]})})}function Toe({sample:e}){return s.jsx("div",{className:"bstudio-sample",children:s.jsx("ul",{className:"bstudio-sample-rows",children:e.plans.map((t,n)=>s.jsxs("li",{className:"bstudio-plan-row",style:{animationDelay:`${n*120}ms`},children:[s.jsxs("div",{className:"bstudio-plan-meta",children:[s.jsx("span",{className:"bstudio-plan-title",children:t.title}),s.jsxs("span",{className:"bstudio-plan-status",children:["[",t.status,"]"]})]}),s.jsxs("div",{className:"bstudio-plan-sub",children:[s.jsxs("span",{children:["owner: ",t.owner]}),s.jsx("span",{className:"bstudio-sep",children:"·"}),s.jsxs("span",{children:[t.files," associated files"]})]})]},t.title))})})}function Moe({sample:e}){return s.jsx("div",{className:"bstudio-sample",children:s.jsx("ul",{className:"bstudio-sample-rows",children:e.items.map((t,n)=>s.jsxs("li",{className:`bstudio-anom-card bstudio-anom-card--${t.kind}`,style:{animationDelay:`${n*120}ms`},children:[s.jsxs("div",{className:"bstudio-anom-head",children:[s.jsx(i2,{size:13,className:"bstudio-anom-icon"}),s.jsx("span",{className:"bstudio-anom-label",children:t.label}),s.jsx("span",{className:"bstudio-anom-severity",children:t.kind})]}),s.jsxs("div",{className:"bstudio-anom-rows",children:[s.jsxs("div",{className:"bstudio-anom-row",children:[s.jsx("span",{className:"bstudio-anom-key",children:"on"}),s.jsx("span",{className:"bstudio-anom-val",children:t.resource})]}),s.jsxs("div",{className:"bstudio-anom-row",children:[s.jsx("span",{className:"bstudio-anom-key",children:"reason"}),s.jsx("span",{className:"bstudio-anom-val",children:t.detail})]}),s.jsxs("div",{className:"bstudio-anom-row",children:[s.jsx("span",{className:"bstudio-anom-key",children:"action"}),s.jsx("span",{className:"bstudio-anom-val bstudio-anom-val--action",children:t.suggested})]})]})]},t.label))})})}function Roe({lines:e}){return s.jsxs("div",{className:"bstudio-sample bstudio-sample--synth",children:[s.jsxs("p",{className:"bstudio-synth-copy",children:["Folding ",e," observations into a briefing…"]}),s.jsx("div",{className:"bstudio-synth-bars",children:Array.from({length:e}).map((t,n)=>s.jsx("span",{className:"bstudio-synth-bar",style:{animationDelay:`${n*110}ms`}},n))})]})}const Ioe=[{id:"fleet",kind:"scan",label:"scan fleet snapshot",duration:3200,result:"47 agents · 8 projects",sample:{type:"fleet",more:43,agents:[{id:"a1",name:"hero-codex",project:"hero",tone:"active"},{id:"a2",name:"hudson-claude",project:"hudson",tone:"active"},{id:"a3",name:"openscout",project:"openscout",tone:"active"},{id:"a4",name:"hkshell",project:"hkshell",tone:"idle"}]}},{id:"sessions",kind:"collect",label:"read recent sessions",duration:3800,result:"7 sessions · 6h window",sample:{type:"sessions",more:4,sessions:[{id:"019e32c6",project:"openscout",lastActive:"16h ago",summary:"consolidating ops modes — Plan + Mission"},{id:"019e32b3",project:"hero",lastActive:"16h ago",summary:"reviewing broker delivery sync code paths"},{id:"019e32ac",project:"openscout",lastActive:"16h ago",summary:"GlobalJumpDock + Atop drawer fix landed"}]}},{id:"broker",kind:"inspect",label:"inspect broker queue",duration:4200,result:"20 msgs · 3 errors",countTone:"warn",sample:{type:"broker",more:17,messages:[{from:"hudson-claude",to:"arach",body:"PR #114 ready — 30 commits consolidating ops modes",ago:"2h"},{from:"hero-codex",to:"openscout",body:"broker delivery sync failing on flight 401 — needs ack",ago:"4h",tone:"err"},{from:"hkshell",to:"arach",body:"tail discovery missed 12 sessions in last hour",ago:"6h",tone:"warn"}]}},{id:"tail",kind:"collect",label:"pull tail events",duration:4200,result:"4,891 events · 6h window",sample:{type:"tail",more:4884,events:[{ts:"11:24:08",source:"claude",kind:"tool",body:'bash("git status")'},{ts:"11:24:11",source:"claude",kind:"tool-result",body:"On branch ux-maximalists"},{ts:"11:24:14",source:"codex",kind:"assistant",body:"verifying tape-advance variant lands cleanly…"},{ts:"11:24:20",source:"claude",kind:"error",body:"tool failure: ENOENT openscout/packages/web/null"}]}},{id:"plans",kind:"analyze",label:"analyze plans in motion",duration:3200,result:"2 plans · 12 associated files",sample:{type:"plans",plans:[{title:"UX maximalists — Scoutbot consolidation",owner:"arach",status:"in motion",files:8},{title:"Broker delivery sync rewrite",owner:"hero-codex",status:"awaiting review",files:4}]}},{id:"anomalies",kind:"analyze",label:"identify anomalies",duration:3200,result:"1 idle · 3 errors",countTone:"warn",sample:{type:"anomalies",items:[{kind:"idle",label:"hkshell quiet for 6h",detail:"last tail event was a tool-result at 05:24",resource:"hkshell · /Users/arach/dev/hkshell",suggested:"send a wake-up ping or dismiss the agent"},{kind:"error",label:"broker delivery sync failing",detail:"flight 401 unacked, 3 retries exhausted",resource:"broker · workspace-hero",suggested:"open flight 401 in broker · investigate ack chain"}]}},{id:"synthesize",kind:"synthesize",label:"synthesize observations",duration:2200,result:"4 observations · brief ready",sample:{type:"synthesize",lines:4}}];function _oe(e){return e>=.9?"err":e>=.75?"warn":"ok"}const Ooe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function HP(e,t){const n=e-t.getTime(),a=new Date(e).toDateString()===t.toDateString(),r=new Date(e),o=String(r.getHours()).padStart(2,"0"),c=String(r.getMinutes()).padStart(2,"0"),u=n>0&&n<6*3600*1e3;return a?{label:`${o}:${c}`,imminent:u}:{label:`${Ooe[r.getDay()]} ${o}:${c}`,imminent:u}}function $oe(e,t){const n=Math.max(0,Math.floor((e-t.getTime())/1e3));if(n>=86400){const a=Math.floor(n/86400),r=Math.floor(n%86400/3600);return r>0?`${a}d ${r}h`:`${a}d`}if(n>=3600){const a=Math.floor(n/3600),r=Math.floor(n%3600/60);return r>0?`${a}h ${r}m`:`${a}h`}return`${Math.max(1,Math.floor(n/60))}m`}function Poe(e,t){const n=HP(e.resetAt,t),a=$oe(e.resetAt,t);return`${e.usedLabel} / ${e.capLabel} ${e.unitLabel} · resets ${n.label} (in ${a})`}function Doe(e){if(e.length===0)return"";if(e.length===1)return`M ${e[0].x} ${e[0].y}`;const t=[`M ${e[0].x} ${e[0].y}`];for(let n=0;n<e.length-1;n++){const a=e[n-1]??e[n],r=e[n],o=e[n+1],c=e[n+2]??o,u=r.x+(o.x-a.x)/6,h=r.y+(o.y-a.y)/6,f=o.x-(c.x-r.x)/6,g=o.y-(c.y-r.y)/6;t.push(`C ${u} ${h}, ${f} ${g}, ${o.x} ${o.y}`)}return t.join(" ")}function Loe({buckets:e}){const c=e.length;if(c<2||e.every(y=>y.count===0))return s.jsxs("svg",{viewBox:"0 0 372 70",style:{width:"100%",height:70,display:"block"},children:[s.jsx("line",{x1:"0",y1:56,x2:372,y2:56,stroke:"var(--border)"}),s.jsx("text",{x:372/2,y:70/2+2,textAnchor:"middle",fill:"var(--dim)",fontSize:"10",fontFamily:"var(--font-mono)",letterSpacing:"0.18em",children:"NO SIGNAL"})]});const h=372/(c-1),f=e.map((y,x)=>({x:x*h,y:56-Math.max(0,Math.min(1,y.value))*50})),g=Doe(f),v=`${g} L 372 56 L 0 56 Z`;return s.jsxs("svg",{viewBox:"0 0 372 70",style:{width:"100%",height:70,display:"block"},children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"hrdFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.22"}),s.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),s.jsx("line",{x1:"0",y1:6,x2:372,y2:6,stroke:"var(--border)",opacity:"0.18"}),s.jsx("line",{x1:"0",y1:62/2,x2:372,y2:62/2,stroke:"var(--border)",opacity:"0.22"}),s.jsx("line",{x1:"0",y1:56,x2:372,y2:56,stroke:"var(--border)"}),s.jsx("path",{d:v,fill:"url(#hrdFill)"}),s.jsx("path",{d:g,fill:"none",stroke:"var(--accent)",strokeWidth:"1.5",strokeLinecap:"round"}),s.jsx("circle",{cx:f[c-1].x,cy:f[c-1].y,r:"2.5",fill:"var(--accent)"}),s.jsx("text",{x:"0",y:67,fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"7d"}),s.jsx("text",{x:372/2,y:67,textAnchor:"middle",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"3d"}),s.jsx("text",{x:372,y:67,textAnchor:"end",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"now"})]})}function zoe(e){const t=e.toLocaleDateString([],{weekday:"short"}).toUpperCase(),n=e.toLocaleDateString([],{month:"short"}).toUpperCase(),a=String(e.getDate()).padStart(2,"0");return`${t} ${a} ${n}`}function Boe(e){const t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`${t}:${n}:${a}`}function Uoe(e){const t=e.replace(/\s+/g," ").trim();if(!t)return[];const n=t.match(/[^.!?]+[.!?]?/g)?.map(r=>r.trim()).filter(Boolean)??[];return(n.length>1?n:t.split(/\s+[;:]\s+|\s+—\s+/).map(r=>r.trim()).filter(Boolean)).slice(0,4).map(r=>/[.!?]$/.test(r)?r:`${r}.`)}function Foe(e){return Uoe(e).map((t,n)=>({id:`fallback-${n+1}`,text:t,references:[]}))}function Voe({gauge:e,now:t,onClick:n}){const a=n?"button":"span",r=n?{type:"button",onClick:n}:{};if(e.kind==="status")return s.jsxs(a,{className:`hd-gauge hd-gauge--${e.tone}${n?" hd-gauge--interactive":""}`,...r,children:[s.jsx("span",{className:"hd-gauge-label",children:e.label}),s.jsx("span",{className:`hd-gauge-dot hd-gauge-dot--${e.tone}`,"aria-hidden":"true"}),s.jsx("span",{className:"hd-gauge-status",children:e.statusLabel})]});const o=_oe(e.fill),c=Math.round(e.fill*100),u=HP(e.resetAt,t);return s.jsxs(a,{className:`hd-gauge hd-gauge--${o}${n?" hd-gauge--interactive":""}`,title:Poe(e,t),...r,children:[s.jsx("span",{className:"hd-gauge-label",children:e.label}),s.jsx("span",{className:"hd-gauge-bar","aria-hidden":"true",children:s.jsx("span",{className:"hd-gauge-bar-fill",style:{width:`${c}%`}})}),s.jsxs("span",{className:"hd-gauge-pct",children:[c,"%"]}),u.imminent&&s.jsxs("span",{className:"hd-gauge-reset hd-gauge-reset--imminent",children:["↻ ",u.label]})]})}function Hoe({signals:e,navigate:t}){return e.length===0?null:s.jsx("div",{className:"hd-signal-stack","aria-label":"system signals",children:e.map(n=>{const a=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`hd-signal-led hd-signal-led--${n.tone??"dim"}`,"aria-hidden":"true"}),s.jsxs("span",{className:"hd-signal-copy",children:[s.jsx("span",{className:"hd-signal-label",children:n.label}),s.jsx("span",{className:"hd-signal-value",children:n.value})]})]}),r=n.route,o=n.onClick??(r?()=>t(r):void 0);return o?s.jsx("button",{type:"button",className:"hd-signal-row hd-signal-row--button",onClick:o,children:a},n.id):s.jsx("div",{className:"hd-signal-row",children:a},n.id)})})}function qoe({references:e,navigate:t}){return e.length===0?null:s.jsx("span",{className:"hd-brief-refs","aria-label":"brief references",children:e.slice(0,4).map(n=>{const a=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hd-brief-ref-kind",children:n.kind}),s.jsx("span",{className:"hd-brief-ref-label",children:n.label})]});return n.route?s.jsx("button",{type:"button",className:"hd-brief-ref hd-brief-ref--button",title:n.detail,onClick:()=>t(n.route),children:a},n.id):s.jsx("span",{className:"hd-brief-ref",title:n.detail,children:a},n.id)})})}function Woe(e){const{now:t,operatorName:n,syncLabel:a,error:r,loading:o,refreshing:c,briefRefreshing:u,onRefresh:h,onRegenerateBrief:f,onSpeakBrief:g,briefSpeaking:v=!1,briefIsNew:y=!1,totalOperatorQueue:x,narrativeParts:w,briefStatement:C,briefObservations:T,navigate:E,opsEnabled:S,onReviewQueue:k,heartrate:N,heartrateWindow:A,heartrateBucketLabel:R,serviceGauges:_,systemSignals:P}=e,$=C?.trim()||"",H=w.find(W=>W.includes("need"))??w[0]??"",I=$||(H?`${H}.`:""),U=T.length>0?T:Foe(I),D=$?w:w.filter(W=>W!==H),V=!$&&H.includes("need"),Z=D.join(" · "),O=r?"err":"ok",z=_,B=u||U.length>0,{runtime:X}=boe(Ioe,{active:u,speed:3});return s.jsxs("section",{className:"hd",children:[s.jsxs("div",{className:"hd-topbar",children:[s.jsxs("div",{className:"hd-topbar-l",children:[s.jsx("span",{className:"hd-mark","aria-hidden":"true",children:"◆"}),s.jsx("span",{className:"hd-mark-text",children:"SCOUT"}),s.jsx("span",{className:"hd-sep",children:"·"}),s.jsx("span",{className:"hd-mark-role",children:"home"})]}),z.length>0&&s.jsxs("div",{className:"hd-topbar-c","aria-label":"service usage",children:[s.jsx("span",{className:"hd-gauge-window",children:"USAGE"}),s.jsx("span",{className:"hd-gauge-divider","aria-hidden":"true"}),z.map((W,L)=>s.jsxs("span",{className:"hd-gauge-wrap",children:[L>0&&s.jsx("span",{className:"hd-gauge-divider","aria-hidden":"true"}),s.jsx(Voe,{gauge:W,now:t,onClick:()=>E({view:"ops"})})]},W.id))]}),s.jsxs("div",{className:"hd-topbar-r",children:[s.jsxs("span",{className:"hd-meta",children:["operator: ",n.toLowerCase()]}),s.jsx("span",{className:"hd-sep",children:"·"}),s.jsx("span",{className:"hd-meta",children:Boe(t)}),s.jsx("span",{className:`hd-dot hd-dot--${O}`,"aria-hidden":"true"}),s.jsx("span",{className:`hd-meta hd-meta--${O}`,children:a})]})]}),s.jsxs("div",{className:"hd-grid",children:[s.jsxs("div",{className:"hd-panel hd-panel--lede","data-brief-refreshing":u||void 0,children:[s.jsxs("div",{className:"hd-panel-title",children:[s.jsx(zd,{className:"hd-brief-scoutbot-glyph",size:12,"aria-hidden":"true"}),s.jsx("span",{children:"BRIEFING"}),s.jsx("span",{className:"hd-sep",children:"·"}),s.jsx("span",{children:zoe(t)}),s.jsx("button",{type:"button",className:"hd-brief-archive-link",onClick:()=>E({view:"briefings"}),children:"view archive"})]}),B&&s.jsx("div",{className:"hd-brief-sheet","data-brief-refreshing":u||void 0,"aria-busy":u||void 0,children:u?s.jsx("div",{className:"hd-brief-seq","aria-busy":"true",children:s.jsx(woe,{runtime:X})}):s.jsx("div",{className:"hd-brief-copy",children:U.map((W,L)=>s.jsxs("p",{className:`hd-brief-line${V&&L===0?" hd-brief-line--warn":""}`,children:[s.jsx(u2,{className:"hd-brief-icon",size:14,strokeWidth:1.7,"aria-hidden":"true"}),s.jsxs("span",{className:"hd-brief-line-body",children:[s.jsx("span",{children:W.text}),s.jsx(qoe,{references:W.references,navigate:E})]})]},W.id||`${W.text}-${L}`))})}),Z.length>0&&s.jsxs("p",{className:"hd-sub",children:[Z,"."]}),r&&s.jsxs("p",{className:"hd-sub hd-sub--err",children:["sync: ",r]}),s.jsxs("div",{className:"hd-actions",children:[x>0&&s.jsxs("button",{type:"button",className:"hd-btn hd-btn--primary",onClick:k,children:["[review queue · ",x,"]"]}),S&&s.jsx("button",{type:"button",className:"hd-btn",onClick:()=>E({view:"ops"}),children:"[open ops]"}),g&&s.jsxs("button",{type:"button",className:`hd-btn${y&&!v?" hd-btn--primary":""}`,onClick:g,title:v?"Stop reading the brief":y?"Read the new brief aloud":"Replay the brief",children:["[",v?"■ stop":y?"▸ speak brief":"▸ replay","]"]}),s.jsxs("button",{type:"button",className:"hd-btn",disabled:u,onClick:f,children:["[",u?"briefing":"new brief","]"]}),s.jsxs("button",{type:"button",className:"hd-btn",disabled:o||c,onClick:h,children:["[",c?"refreshing":"r refresh","]"]})]})]}),s.jsxs("div",{className:"hd-panel hd-panel--hr",children:[s.jsxs("div",{className:"hd-panel-title",children:[s.jsx("span",{children:"HEART-RATE"}),s.jsx("span",{className:"hd-sep",children:"·"}),s.jsx("span",{children:A}),R?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hd-sep",children:"·"}),s.jsx("span",{children:R})]}):null]}),s.jsx(Loe,{buckets:N}),s.jsx(Hoe,{signals:P,navigate:E})]})]})]})}const Goe=new Set(["air-local","local","mini","node"]),Zoe=new Set(["main","master","trunk"]);function xp(e){return e.replace(/```[\s\S]*?```/g," code omitted ").replace(/\*\*([^*\n]+)\*\*/g,"$1").replace(/(^|[\s(])\*([^\s*][^*\n]*?[^\s*]|[^\s*])\*(?=[\s)\].,!?;:]|$)/g,"$1$2").replace(/(^|[\s(])_([^\s_][^_\n]*?[^\s_]|[^\s_])_(?=[\s)\].,!?;:]|$)/g,"$1$2").replace(/^\s*[-*]\s+/gm,"").replace(/\bhttps?:\/\/[^\s)]+/gi,t=>Koe(t)).replace(/\b(session|conversation|message|flight|invocation|work)(?:\s+(?:id|ref))?\s*[:#]?\s+([a-z0-9][a-z0-9._:-]{9,})\b/gi,(t,n,a)=>`${n.toLowerCase()} ending in ${e0(a)}`).replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,t=>`ID ending in ${e0(t)}`).replace(/@?([a-z][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*){2,})\b/gi,(t,n)=>Yoe(t)?t:Xoe(n)).replace(/`([^`]+)`/g,(t,n)=>Qoe(n)).replace(/\s+/g," ").trim()}function Koe(e){try{return new URL(e).hostname.replace(/^www\./,"").replace(/\./g," dot ")}catch{return"link"}}function Yoe(e){const t=e.replace(/^@/,"").toLowerCase();return/\.(com|app|dev|org|net|io|local)(?:\b|\/)/.test(t)&&!t.endsWith(".air-local")}function Xoe(e){const t=e.split(".").filter(Boolean);if(t.length<2)return e;const n=[...t];for(;n.length>1&&Goe.has(n.at(-1).toLowerCase());)n.pop();const[a,...r]=n,o=r.filter(c=>!Zoe.has(c.toLowerCase())).map(t0).filter(Boolean);return[t0(a),...o].filter(Boolean).join(", ")}function Qoe(e){return/^[a-z0-9][a-z0-9._:-]{12,}$/i.test(e)?`ID ending in ${e0(e)}`:t0(e)}function e0(e){return(e.replace(/[^a-z0-9]/gi,"").slice(-4)||e.slice(-4)).split("").join(" ")}function t0(e){return e.replace(/^@/,"").replace(/[_./:-]+/g," ").replace(/\s+/g," ").trim()}const qP="openscout.home.lastSpokenBriefId.v1",WP="home.brief.voice",Joe="briefing mode voice >>",ele=2e4,n0=new Set;let gd=null,pc=null,dr={speaking:!1,activeBriefId:null,lastSpokenBriefId:tle(),error:null};function tle(){if(typeof window>"u")return null;try{return window.localStorage.getItem(qP)}catch{return null}}function nle(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qP,e)}catch{}}function sle(){for(const e of n0)e()}function Ju(e){dr.speaking===e.speaking&&dr.activeBriefId===e.activeBriefId&&dr.lastSpokenBriefId===e.lastSpokenBriefId&&dr.error===e.error||(dr=e,sle())}function ale(e){return n0.add(e),()=>{n0.delete(e)}}function NT(){return dr}function kT(){Am({key:WP,tier:"info",text:Joe})}function rle(){kT(),pc&&clearInterval(pc),pc=setInterval(kT,ele)}function GP(){pc&&(clearInterval(pc),pc=null),Tm(WP)}function ile(){return m.useSyncExternalStore(ale,NT,NT)}function ole(e){const t=e.text.trim();if(!t)return;ZP();let n;try{n=cae(xp(t))}catch(a){const r=a instanceof Error?a.message:"Could not start brief voice";Ju({...dr,error:r});return}gd=n,nle(e.briefId),Ju({speaking:!0,activeBriefId:e.briefId,lastSpokenBriefId:e.briefId,error:null}),rle(),n.promise.catch(a=>{if(!Yl(a)){const r=a instanceof Error?a.message:"Brief voice failed";console.warn("brief speech failed",a),Ju({...dr,error:r})}}).finally(()=>{gd===n&&(gd=null,GP(),Ju({...dr,speaking:!1,activeBriefId:null}))})}function ZP(){const e=gd;gd=null,e?.stop(),GP(),Ju({...dr,speaking:!1,activeBriefId:null,error:null})}const s0="openscout:persistent-state-change";function lle(e,t){typeof window>"u"||window.dispatchEvent(new CustomEvent(s0,{detail:{key:e,value:t}}))}function ST(e){try{return window.localStorage.getItem(e)}catch{return null}}function aj(e,t){try{window.localStorage.setItem(e,t)}catch{}lle(e,t)}function rj(e){const[t,n]=m.useState(()=>typeof window>"u"?null:ST(e));return m.useEffect(()=>{n(ST(e));const a=o=>{const c=o.detail;!c||c.key!==e||n(c.value)},r=o=>{o.key===e&&n(o.newValue)};return window.addEventListener(s0,a),window.addEventListener("storage",r),()=>{window.removeEventListener(s0,a),window.removeEventListener("storage",r)}},[e]),t}function a0(e,t){const n=rj(e),a=n===null?t:n==="true",r=m.useCallback(o=>{aj(e,o?"true":"false")},[e]);return[a,r]}function ij(e,t){const n=rj(e),a=n===null?Number.NaN:Number(n),r=Number.isFinite(a)?a:t,o=m.useCallback(c=>{aj(e,String(c))},[e]);return[r,o]}function KP(e,t){const a=rj(e)??t,r=m.useCallback(o=>{aj(e,o)},[e]);return[a,r]}const Ti=[{label:"30m",value:30*6e4,activityLimit:80},{label:"6h",value:360*6e4,activityLimit:250},{label:"24h",value:1440*6e4,activityLimit:800}],cle=Ti[2].value,ule="openscout.home.lookbackMs.v1",dle=60*6e4,fle=5*6e4,YP=30*6e4,hle="openscout.home.staleMotionInactive.v1",mle=200,ple={"fleet-home":"fleet",tour:"tour"};function XP(e,t){const n=zt(e);if(n===null)return"—";const a=Math.max(0,Math.floor((t-n)/1e3));if(a<60)return`${a}s`;const r=Math.floor(a/60);if(r<60)return`${r}m`;const o=Math.floor(r/60);return o<48?`${o}h`:`${Math.floor(o/24)}d`}function oj(e,t=140){const n=(e??"").replace(/\s+/g," ").trim();return n?n.length>t?`${n.slice(0,t-1)}…`:n:""}function QP(e){return{handoff_sent:"handed off",handoff_received:"received handoff",flight_updated:"replied",ask_sent:"asked",ask_replied:"answered",message_sent:"said",message_received:"received"}[e]??e.replace(/[._]/g," ")}function gle(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.recordId?{view:"work",workId:e.recordId}:e.agentId?{view:"agents",agentId:e.agentId}:null}function JP(e){const t=Math.round(e/6e4);if(t<60)return`${t}m`;const n=t/60;return`${Number.isInteger(n)?n:n.toFixed(1)}h`}function r0(e){if(!Number.isFinite(e)||e<=0)return"now";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);if(n<60)return`${n}m`;const a=Math.floor(n/60);return a<48?`${a}h`:`${Math.floor(a/24)}d`}function vle(e,t,n){if(e.length===0)return null;const a=e.map(h=>zt(h.ts)).filter(h=>h!==null).sort((h,f)=>f-h);if(a.length===0)return null;const r=a[0],o=a[a.length-1];let c=0;for(let h=1;h<a.length;h++)c=Math.max(c,a[h-1]-a[h]);const u=n-t;return c=Math.max(c,o-u),{count:e.length,lastAgoMs:Math.max(0,n-r),longestGapMs:Math.max(0,c)}}function yle(e,t){const n=zt(e);if(n===null)return"unknown";const a=Math.floor((n-t)/1e3);if(a<=0)return"expired";if(a<60)return`in ${a}s`;const r=Math.floor(a/60);if(r<60)return`in ${r}m`;const o=Math.floor(r/60);return o<48?`in ${o}h`:`in ${Math.floor(o/24)}d`}function Sx(e,t){const n=zt(e);return n!==null&&t-n<=YP}function xle(e){try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[a,r]of Object.entries(t)){const o=typeof r=="number"?r:Number(r);a&&Number.isFinite(o)&&(n[a]=o)}return n}catch{return{}}}function CT(e){const t=Object.entries(e).filter(n=>Number.isFinite(n[1])).sort((n,a)=>a[1]-n[1]).slice(0,mle);return JSON.stringify(Object.fromEntries(t))}function eD(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function ble(e){const t=[];return e.hasAgentState&&t.push("agent state"),e.askCount>0&&t.push(`${e.askCount} ask${e.askCount===1?"":"s"}`),t.join(" + ")||"stale state"}function wle(e){return e<5?"Still up":e<12?"Good morning":e<18?"Good afternoon":"Good evening"}function Hh(e){return e.status==="fulfilled"?null:e.reason instanceof Error?e.reason.message:String(e.reason)}function ET({navigate:e}){const{agents:t,onboarding:n,reload:a,route:r}=qe(),o=oa(r),c=m.useMemo(()=>eo(t,o),[t,o]),u=m.useMemo(()=>el(t,o),[t,o]),[h,f]=m.useState(null),[g,v]=m.useState(null),[y,x]=m.useState([]),[w,C]=m.useState("trailing 7d"),[T,E]=m.useState("3h buckets"),[S,k]=m.useState([]),[N,A]=m.useState(null),[R,_]=m.useState(null),[P,$]=m.useState(!1),[H,I]=m.useState(!1),[U,D]=m.useState(!0),[V,Z]=m.useState(!1),[O,z]=m.useState(null),[B,X]=m.useState(null),W=m.useRef(null),L=m.useRef(0),q=m.useRef(0),K=m.useRef(null);m.useEffect(()=>{K.current=h},[h]);const ee=m.useMemo(()=>H$(h,c),[h,c]),[G,re]=ij(ule,cle),Q=m.useMemo(()=>Ti.find(de=>de.value===G)??Ti[Ti.length-1],[G]),ae=m.useCallback(async(de="initial")=>{const Ue=++L.current;!(K.current!==null)&&de!=="background"?(D(!0),z(null)):Z(!0);const Lt=new URLSearchParams({activityLookbackMs:String(Q.value),activityLimit:String(Q.activityLimit)}).toString(),[nn,ca,bs,Wt]=await Promise.allSettled([me(`/api/fleet?${Lt}`),me("/api/operator-attention"),me("/api/heartrate"),a()]);if(Ue!==L.current)return;nn.status==="fulfilled"&&(K.current=nn.value,f(nn.value)),ca.status==="fulfilled"&&v(ca.value),bs.status==="fulfilled"&&(x(bs.value.buckets),C(bs.value.windowLabel),E(bs.value.bucketLabel??""));const Gn=[Hh(nn),Hh(ca),Hh(bs),Hh(Wt)].filter(ds=>!!ds);z(Gn[0]??null),Gn.length<4&&X(Date.now()),D(!1),Z(!1)},[a,Q]),be=m.useCallback(()=>{W.current||(W.current=setTimeout(()=>{W.current=null,ae("background")},250))},[ae]);m.useEffect(()=>(ae(),()=>{W.current&&clearTimeout(W.current)}),[ae]),tn(be),m.useEffect(()=>{let de=!1;const Ue=async()=>{try{const Lt=await me("/api/service-budgets");de||k(Lt.gauges??[])}catch{}};Ue();const He=setInterval(Ue,dle);return()=>{de=!0,clearInterval(He)}},[]);const $e=m.useCallback(async()=>{try{const de=await me("/api/briefings?limit=1");_(de.briefings[0]??null),$(!0)}catch{$(!0)}},[]),ge=m.useCallback(async(de=!1)=>{de&&I(!0);try{const He=await me(de?"/api/fleet/brief?refresh=1":"/api/fleet/brief");A(He),$e()}catch{}finally{de&&I(!1)}},[$e]),Te=ile();m.useEffect(()=>{$e(),ge();const de=setInterval(()=>{ge()},fle);return()=>clearInterval(de)},[ge,$e]),m.useEffect(()=>{const de=setInterval(()=>{document.visibilityState==="visible"&&ae("background")},15e3);return()=>clearInterval(de)},[ae]),m.useEffect(()=>{const de=()=>{if(document.visibilityState!=="visible")return;const Ue=Date.now();Ue-q.current<1e3||(q.current=Ue,ae("background"))};return window.addEventListener("focus",de),document.addEventListener("visibilitychange",de),()=>{window.removeEventListener("focus",de),document.removeEventListener("visibilitychange",de)}},[ae]);const[pe,Xe]=m.useState(()=>Date.now()),[Be,Se]=KP(hle,"{}"),Me=m.useMemo(()=>xle(Be),[Be]);m.useEffect(()=>{const de=setInterval(()=>Xe(Date.now()),1e3);return()=>clearInterval(de)},[]);const _e=m.useMemo(()=>u.filter(de=>Je(de.state)==="available"),[u]);m.useMemo(()=>u.filter(de=>Je(de.state)==="offline"),[u]);const Ne=m.useMemo(()=>[...ee?.activeAsks??[],...ee?.recentCompleted??[]].filter(de=>de.status==="needs_attention"||de.status==="failed"),[ee]),Oe=m.useMemo(()=>(ee?.activeAsks??[]).filter(de=>de.status==="queued"||de.status==="working"),[ee]),Ce=m.useMemo(()=>Oe.filter(de=>Sx(de.updatedAt,pe)),[Oe,pe]),Ve=m.useMemo(()=>ee?.needsAttention??[],[ee]),Re=m.useMemo(()=>{const de=new Map;for(const Ue of Ce){const He=de.get(Ue.agentId),Lt=zt(Ue.updatedAt)??0,nn=zt(He?.updatedAt)??0;(!He||Lt>nn)&&de.set(Ue.agentId,Ue)}return de},[Ce]),Ie=m.useMemo(()=>u.filter(de=>Je(de.state)==="working"&&(Sx(de.updatedAt,pe)||Re.has(de.id))),[Re,u,pe]),De=m.useMemo(()=>new Set(Ie.map(de=>de.id)),[Ie]),ct=m.useMemo(()=>u.filter(de=>Je(de.state)==="working"&&!De.has(de.id)),[De,u]),ut=m.useMemo(()=>Oe.filter(de=>!Sx(de.updatedAt,pe)),[Oe,pe]),st=m.useMemo(()=>{const de=new Map,Ue=He=>{const Lt=de.get(He.agentId);if(!Lt){de.set(He.agentId,He);return}const nn=He.updatedAtMs>=Lt.updatedAtMs;de.set(He.agentId,{agentId:He.agentId,agentName:Lt.agentName||He.agentName,updatedAtMs:Math.max(Lt.updatedAtMs,He.updatedAtMs),summary:nn?He.summary:Lt.summary,route:nn?He.route:Lt.route,hasAgentState:Lt.hasAgentState||He.hasAgentState,askCount:Lt.askCount+He.askCount})};for(const He of ct)Ue({agentId:He.id,agentName:He.name,updatedAtMs:zt(He.updatedAt)??0,summary:He.cwd??He.projectRoot??He.project??He.branch??"Registered as working",route:{view:"agents",agentId:He.id,tab:"profile"},hasAgentState:!0,askCount:0});for(const He of ut)Ue({agentId:He.agentId,agentName:He.agentName??He.agentId,updatedAtMs:zt(He.updatedAt)??0,summary:He.summary??He.task??He.statusLabel,route:eD(He),hasAgentState:!1,askCount:1});return[...de.values()].sort((He,Lt)=>Lt.updatedAtMs-He.updatedAtMs)},[ut,ct]),ht=m.useMemo(()=>st.filter(de=>(Me[de.agentId]??-1)<de.updatedAtMs),[Me,st]),yt=m.useMemo(()=>Ce.filter(de=>!Ie.some(Ue=>Ue.id===de.agentId)),[Ie,Ce]),Mt=Ne.length+Ve.length,Rt=m.useMemo(()=>c?(g?.items??[]).filter(de=>de.agentId&&c.has(de.agentId)):g?.items??[],[g?.items,c]),xt=o?Mt+Rt.length:g?.totals.all??Mt,Y=m.useMemo(()=>{const de=[...Ne.map(Ue=>Ue.updatedAt),...Ve.map(Ue=>Ue.updatedAt),...Rt.map(Ue=>Ue.updatedAt)].map(zt).filter(Ue=>Ue!==null);return de.length>0?Math.min(...de):null},[Rt,Ne,Ve]),te=pe-G,he=m.useMemo(()=>(ee?.activity??[]).filter(Ue=>(zt(Ue.ts)??0)>=te),[ee?.activity,te]),Pe=m.useMemo(()=>vle(he,G,pe),[he,G,pe]),We=he.length>=Q.activityLimit,rt=m.useMemo(()=>{const de=Ti.findIndex(Ue=>Ue.value===G);return de>=0&&de<Ti.length-1?Ti[de+1]:null},[G]),at=new Date,Ot=wle(at.getHours()),jt=Kd(),bt=n?.operatorName?.trim()||n?.operatorNameSuggestion?.trim()||"operator",Bt=m.useMemo(()=>{const Ue=pe-6e5,He=ee?.activity??[],Lt=new Set(u.map(Wt=>Wt.name.toLowerCase())),nn=new Set(u.map(Wt=>Wt.id)),ca=new Set(["agent_message","status_message","ask_opened","ask_working","ask_failed","handoff_sent","collaboration_event"]),bs=new Map;for(const Wt of He){const Gn=zt(Wt.ts);if(Gn===null||Gn<Ue||!ca.has(Wt.kind))continue;const ds=Wt.actorName?.trim();if(!ds||ds.toLowerCase()===bt.toLowerCase()||Lt.has(ds.toLowerCase())||Wt.agentId&&nn.has(Wt.agentId))continue;const ws=ds.toLowerCase(),Xn=bs.get(ws),js=zt(Xn?.ts)??0;(!Xn||Gn>js)&&bs.set(ws,Wt)}return[...bs.values()].sort((Wt,Gn)=>lg(Wt.ts,Gn.ts))},[ee?.activity,pe,u,bt]),Mn=zt(N?.expiresAt),es=Mn!==null&&Mn>pe,vs=m.useCallback(de=>{Se(CT({...Me,[de.agentId]:de.updatedAtMs}))},[Se,Me]),cn=m.useCallback(()=>{const de={...Me};for(const Ue of ht)de[Ue.agentId]=Ue.updatedAtMs;Se(CT(de))},[Se,Me,ht]),Rn=m.useCallback(()=>{document.getElementById("home-stale-motion")?.scrollIntoView({behavior:"smooth",block:"start"})},[]),ts=m.useMemo(()=>{const de=[];if(xt>0?de.push({id:"attention-age",label:"needs you",value:Y?`oldest item has waited ${Ae(Y)}`:"operator queue has waiting work",tone:"warn"}):de.push({id:"attention-clear",label:"needs you",value:"no human-only queue in the current snapshot",tone:"ok"}),yt.length>0)de.push({id:"unanchored-work",label:"hidden motion",value:`${yt.length} moving ask${yt.length===1?"":"s"} without an active registered agent`,tone:"warn",route:{view:"activity"}});else if(ht.length>0){const nn=ht.length;de.push({id:"stale-motion",label:"stale motion",value:`${nn} old state${nn===1?"":"s"} ready to mark inactive`,tone:"dim",onClick:Rn})}else Bt.length>0?de.push({id:"organic-work",label:"organic work",value:`${Bt.length} recent actor${Bt.length===1?"":"s"} outside the managed roster`,tone:"ok",route:{view:"activity"}}):de.push({id:"hidden-clear",label:"hidden motion",value:"no recent untracked movement detected",tone:"dim"});const Ue=S.find(nn=>nn.kind==="status"?nn.tone==="warn"||nn.tone==="err":nn.fill>=.75);Ue?de.push({id:"service-pressure",label:"service pressure",value:Ue.kind==="status"?`${Ue.label} reports ${Ue.statusLabel.toLowerCase()}`:`${Ue.label} is at ${Math.round(Ue.fill*100)}% of ${Ue.unitLabel}`,tone:Ue.kind==="status"?Ue.tone:"warn",route:{view:"ops"}}):de.push({id:"service-pressure",label:"service pressure",value:"no usage pressure above threshold",tone:"ok",route:{view:"ops"}});const He=R?{view:"briefings",briefingId:R.id}:N?.sourceBriefId?{view:"briefings",briefingId:N.sourceBriefId}:{view:"briefings"},Lt=N?`prepared ${Ae(N.preparedAt)} · expires ${yle(N.expiresAt,pe)}`:R?`latest ${ple[R.kind]} prepared ${Ae(R.preparedAt)} · archived`:P?"no generated brief loaded yet":"checking brief archive...";return de.push({id:"brief-memory",label:"brief memory",value:Lt,tone:es||R||!P?"dim":"warn",route:He}),de},[N,es,P,R,yt.length,pe,Bt.length,Y,Rn,S,xt,ht.length]),ys=m.useMemo(()=>{const de=[];return Ie.length>0&&de.push(`${Ie.length} agent${Ie.length===1?" is":"s are"} working now`),_e.length>0&&de.push(`${_e.length} agent${_e.length===1?" is":"s are"} available`),xt>0&&de.push(`${xt} thing${xt===1?"":"s"} need${xt===1?"s":""} you`),de.length===0&&u.length>0&&de.push(`${u.length} agent${u.length===1?" is":"s are"} registered`),de.length===0&&de.push("no agents are connected yet"),de},[Ie,_e,xt,u]),la=U?"syncing":O?`sync issue · ${B?Ae(B):"waiting"}`:B?`updated ${Ae(B)}`:"waiting",xs=m.useMemo(()=>{if(!N||!es)return"";const de=[],Ue=N.statement?.trim();Ue&&de.push(Ue);for(const He of N.observations??[]){const Lt=He.text?.trim();Lt&&de.push(Lt)}return de.join(". ")},[N,es]),Yt=m.useCallback(()=>{if(Te.speaking){ZP();return}!N||!xs||ole({briefId:N.id,text:xs})},[Te.speaking,xs,N]),Ht=!!xs,Ln=!!(N&&es&&N.id!==Te.lastSpokenBriefId),Rs={now:at,greeting:Ot,operatorName:bt,syncLabel:la,error:O,loading:U,refreshing:V,briefRefreshing:H,onRefresh:()=>{ae("manual")},onRegenerateBrief:()=>{ge(!0)},onSpeakBrief:Ht||Te.speaking?Yt:void 0,briefSpeaking:Te.speaking,briefIsNew:Ln,totalOperatorQueue:xt,narrativeParts:ys,briefStatement:N&&es?N.statement:null,briefObservations:N&&es?N.observations??[]:[],navigate:e,opsEnabled:jt,onReviewQueue:()=>{document.getElementById("home-needs-you")?.scrollIntoView({behavior:"smooth",block:"start"})},heartrate:y,heartrateWindow:w,heartrateBucketLabel:T,serviceGauges:S,systemSignals:ts};return s.jsx("div",{className:"s-fleet-home",children:s.jsxs("div",{className:"s-fleet-home-inner",children:[s.jsx(Woe,{...Rs}),(Ie.length>0||Bt.length>0||yt.length>0)&&s.jsxs("div",{className:"s-fleet-section",children:[s.jsx(qh,{label:`What's moving · ${Ie.length+Bt.length+yt.length}`,right:s.jsx("button",{className:"s-link-btn",onClick:()=>e({view:"mesh"}),children:"open mesh ↗"})}),(Ie.length>0||Bt.length>0)&&s.jsxs("div",{className:"s-now-grid",style:{gridTemplateColumns:`repeat(${Math.min(Ie.length+Bt.length,3)}, 1fr)`},children:[Ie.map(de=>s.jsx(Tle,{agent:de,ask:Re.get(de.id)??null,navigate:e},de.id)),Bt.map(de=>s.jsx(Mle,{actor:de,nowMs:pe,navigate:e},de.id))]}),yt.length>0&&s.jsx("div",{className:"s-moving-ask-list",children:yt.map(de=>s.jsx(Ile,{ask:de,navigate:e},de.invocationId))})]}),ht.length>0&&s.jsxs("div",{className:"s-fleet-section",id:"home-stale-motion",children:[s.jsx(qh,{label:`Stale motion · ${ht.length}`,right:s.jsx("button",{type:"button",className:"s-link-btn",onClick:cn,children:"mark all inactive"})}),s.jsx("div",{className:"s-stale-motion-list",children:ht.map(de=>s.jsx(_le,{item:de,navigate:e,onMarkInactive:()=>vs(de)},de.agentId))})]}),s.jsxs("div",{className:"s-fleet-section",children:[s.jsx(qh,{label:`Live activity · ${he.length}${We?"+":""}`,right:s.jsx(Ole,{value:G,onChange:re,refreshing:V&&!U})}),Pe&&s.jsxs("div",{className:"s-fleet-live-shape",children:[s.jsxs("span",{children:["last ",r0(Pe.lastAgoMs)," ago"]}),s.jsx("span",{children:"·"}),s.jsxs("span",{children:["longest gap ",r0(Pe.longestGapMs)]}),We&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{style:{color:"var(--amber)"},children:["showing ",Math.min(he.length,30)," of ",Q.activityLimit,"+ (capped)"]})]}),!We&&he.length>30&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{children:["showing 30 of ",he.length]})]})]}),U&&he.length===0?s.jsx($le,{}):he.length===0?s.jsx(Ple,{lookbackMs:G,nextOption:rt,onWiden:de=>re(de.value),loadedAt:B,nowMs:pe,error:O,onRetry:()=>{ae("manual")}}):s.jsx("div",{className:"s-mc-stream s-fleet-live-stream",children:he.slice(0,30).map(de=>s.jsx(Dle,{item:de,nowMs:pe,onOpen:()=>{const Ue=gle(de);Ue&&e(Ue)}},de.id))})]}),xt>0&&s.jsxs("div",{className:"s-fleet-section",id:"home-needs-you",children:[s.jsx(qh,{label:`Network signals · ${xt}`,right:Y!==null?s.jsxs("span",{style:{color:"var(--amber)"},children:["oldest ",Ae(Y)]}):null}),Rt.length>0?s.jsx(jle,{items:Rt,navigate:e,onResolved:de=>v(de)}):Ne.length>0&&s.jsx("div",{className:"s-ask-grid",children:Ne.slice(0,4).map(de=>s.jsx(Ele,{ask:de,agents:u,navigate:e,operatorName:bt,pending:!0},de.invocationId))}),Rt.length===0&&Ve.length>0&&s.jsx("div",{className:"s-attention-list",children:Ve.map(de=>s.jsx(Ale,{item:de,navigate:e},de.recordId))})]})]})})}function qh({label:e,right:t}){return s.jsxs("div",{className:"s-section-rule",children:[s.jsx("span",{className:"s-eyebrow",children:e}),s.jsx("span",{className:"s-section-rule-line"}),t&&s.jsx("span",{className:"s-section-rule-right",children:t})]})}function jle({items:e,navigate:t,onResolved:n}){return s.jsxs("div",{className:"s-operator-queue",children:[s.jsxs("div",{className:"s-operator-queue-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"s-operator-queue-title",children:"Operator queue"}),s.jsx("div",{className:"s-operator-queue-subtitle",children:"Permissions, questions, and setup blockers in one place."})]}),s.jsx("div",{className:"s-operator-queue-count",children:e.length})]}),s.jsx("div",{className:"s-operator-queue-list",children:e.map(a=>s.jsx(Cle,{item:a,navigate:t,onResolved:n},a.id))})]})}function Nle(e){switch(e){case"critical":return"blocked";case"warning":return"needs input";default:return"review"}}function kle(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:null}function Sle(e){const t=e.actions.filter(a=>(a.kind==="open"||a.kind==="configure")&&!!a.route);if(t.length>0)return t;const n=kle(e);return n?[{kind:"open",label:"Open",route:n}]:[]}function Cle({item:e,navigate:t,onResolved:n}){const[a,r]=m.useState(null),[o,c]=m.useState(!1),[u,h]=m.useState(null),f=e.actions.find(E=>E.kind==="copy"&&E.value),g=e.actions.find(E=>E.kind==="approve"),v=e.actions.find(E=>E.kind==="deny"),y=e.actions.find(E=>E.kind==="dismiss"),x=Sle(e),w=async E=>{if(e.approval){r(E),h(null);try{const S=await me("/api/operator-attention/approvals/decide",{method:"POST",body:JSON.stringify({sessionId:e.approval.sessionId,turnId:e.approval.turnId,blockId:e.approval.blockId,version:e.approval.version,decision:E})});n(S)}catch(S){h(S instanceof Error?S.message:String(S))}finally{r(null)}}},C=()=>{f?.value&&navigator.clipboard.writeText(f.value).then(()=>{c(!0),window.setTimeout(()=>c(!1),1400)})},T=async()=>{if(!y?.unblockRequestId&&!y?.flightId&&(!y?.recordKind||!y.recordId)){h("This queue item cannot be dismissed from here yet.");return}r("dismiss"),h(null);try{if(y.unblockRequestId)await Rm({unblockRequestId:y.unblockRequestId,itemUpdatedAt:e.updatedAt});else if(y.flightId)await Rm({flightId:y.flightId,itemUpdatedAt:e.updatedAt});else{const S=y.recordKind,k=y.recordId;if(!S||!k)throw new Error("This queue item cannot be dismissed from here yet.");await Rm({recordKind:S,recordId:k,itemUpdatedAt:e.updatedAt})}const E=await me("/api/operator-attention");n(E)}catch(E){h(E instanceof Error?E.message:String(E))}finally{r(null)}};return s.jsxs("div",{className:`s-operator-card s-operator-card--${e.severity}`,children:[s.jsxs("div",{className:"s-operator-card-main",children:[s.jsxs("div",{className:"s-operator-card-top",children:[s.jsx("span",{className:"s-eyebrow",children:e.sourceLabel}),s.jsx("span",{className:"s-operator-card-severity",children:Nle(e.severity)}),s.jsx("span",{className:"s-operator-card-age",children:Ae(e.updatedAt)})]}),s.jsx("div",{className:"s-operator-card-title",children:e.title}),e.summary&&s.jsx("div",{className:"s-operator-card-summary",children:e.summary}),e.detail&&s.jsx("div",{className:"s-operator-card-detail",children:e.detail}),e.agentName&&s.jsx("div",{className:"s-operator-card-meta",children:e.agentName}),u&&s.jsx("div",{className:"s-operator-card-error",children:u})]}),s.jsxs("div",{className:"s-operator-card-actions",children:[g&&s.jsxs("button",{type:"button",className:"s-icon-btn s-icon-btn--primary",disabled:!!a,title:"Approve",onClick:()=>{w("approve")},children:[s.jsx(r2,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:a==="approve"?"Approving":g.label})]}),v&&s.jsxs("button",{type:"button",className:"s-icon-btn",disabled:!!a,title:"Deny",onClick:()=>{w("deny")},children:[s.jsx(gc,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:a==="deny"?"Denying":v.label})]}),f&&s.jsxs("button",{type:"button",className:"s-icon-btn",title:f.label,onClick:C,children:[s.jsx(c2,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:o?"Copied":f.label})]}),x.map((E,S)=>s.jsxs("button",{type:"button",className:"s-icon-btn",title:E.label,onClick:()=>t(E.route),children:[E.kind==="configure"?s.jsx($p,{size:14,"aria-hidden":"true"}):s.jsx(Tc,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:E.label})]},`${E.kind}:${E.label}:${S}`)),y&&s.jsxs("button",{type:"button",className:"s-icon-btn",disabled:!!a,title:"Dismiss from queue",onClick:()=>{T()},children:[s.jsx(gc,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:a==="dismiss"?"Dismissing":y.label})]})]})]})}function Ele({ask:e,agents:t,navigate:n,operatorName:a,pending:r}){const c=t.find(h=>h.id===e.agentId)?.name??e.agentName??e.agentId,u=e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId};return s.jsxs("div",{className:`s-ask-block${r?" s-ask-block--pending":""}`,style:{cursor:"pointer"},onClick:()=>n(u),children:[s.jsxs("div",{className:"s-ask-header",children:[s.jsx("span",{className:"s-eyebrow s-ask-label",children:r?"◌ ASK — ATTENTION":"● ASK"}),s.jsx("span",{style:{flex:1}}),s.jsx("span",{className:"s-eyebrow",children:Ae(e.updatedAt)})]}),s.jsxs("div",{className:"s-ask-body",children:[s.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:qt(c)},children:c[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"s-ask-body-copy",children:[s.jsxs("div",{className:"s-ask-route",children:[s.jsx("span",{className:"s-ask-route-name",children:c}),s.jsx("span",{children:" → "}),s.jsx("span",{style:{color:"var(--accent)"},children:a})]}),s.jsxs("div",{className:"s-ask-text",children:['"',e.summary??e.task,'"']})]})]}),r&&s.jsxs("div",{className:"s-ask-actions",children:[s.jsx("button",{className:"s-btn-fleet s-btn-fleet--primary",children:"Answer"}),s.jsx("button",{className:"s-btn-fleet",children:"Defer"}),s.jsx("button",{className:"s-btn-fleet",children:"Route…"}),s.jsx("span",{className:"s-ask-thinking",children:s.jsx("span",{className:"s-thinking-strip"})})]})]})}function Ale({item:e,navigate:t}){const n=e.kind==="work_item"&&e.recordId?{view:"work",workId:e.recordId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:null,a=e.kind==="question"?"question":e.state.replace(/_/g," "),r=e.acceptanceState!=="none"?e.kind==="question"?e.acceptanceState.replace(/_/g," "):"agent-owned":e.kind==="question"?"awaiting answer":"surfaced",o=e.kind==="question"?"answer":e.state==="review"?"view plan":e.acceptanceState==="pending"?"view signal":"open work";return s.jsxs("div",{className:`s-attention-row${n?" s-attention-row--clickable":""}`,onClick:n?()=>t(n):void 0,children:[s.jsx("div",{className:"s-attention-row-title",children:e.title}),s.jsxs("div",{className:"s-attention-row-meta",children:[s.jsx("span",{className:"s-eyebrow",children:e.kind==="work_item"?"WORK ITEM":"QUESTION"}),e.agentName&&s.jsx("span",{children:e.agentName}),s.jsx("span",{children:a}),s.jsx("span",{style:{color:"var(--amber)"},children:r}),s.jsx("span",{style:{marginLeft:"auto"},children:Ae(e.updatedAt)}),n&&s.jsxs("span",{className:"s-attention-row-action",children:[o," ↗"]})]}),e.summary&&s.jsx("p",{className:"s-attention-row-summary",children:e.summary})]})}function Tle({agent:e,ask:t,navigate:n}){const a=e.handle?`@${e.handle}`:e.id,r=e.role??e.agentClass,o=e.branch??"main",c=ps(e.id),u=t?.summary??t?.task??e.cwd??`Working in ${e.project??"workspace"}`;return s.jsxs("div",{className:"s-now-card",onClick:()=>n({view:"agents",agentId:e.id,conversationId:c,tab:"observe"}),children:[s.jsxs("div",{className:"s-now-card-head",children:[s.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:qt(e.name)},children:e.name[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"s-now-card-copy",children:[s.jsx("div",{className:"s-now-card-name",children:e.name}),s.jsxs("div",{className:"s-now-card-meta",children:[a," · ",r]})]}),s.jsxs("span",{className:"s-now-card-live",children:[s.jsx("span",{className:"s-now-card-live-dot","aria-hidden":"true"}),"live"]})]}),s.jsx("div",{className:"s-now-card-task",children:u}),s.jsxs("div",{className:"s-now-card-ticker",children:[s.jsx("span",{className:"s-now-card-ticker-prompt",children:"›"}),s.jsx("span",{className:"s-now-card-ticker-text",children:t?`${t.statusLabel} · ${t.harness??e.harness??"agent"}`:"working"}),s.jsxs("span",{className:"s-now-card-ticker-dots","aria-hidden":"true",children:[s.jsx("span",{}),s.jsx("span",{}),s.jsx("span",{})]}),s.jsx("span",{className:"s-now-card-cursor"})]}),s.jsxs("div",{className:"s-now-card-footer",children:[s.jsx("span",{children:e.updatedAt?`updated ${Ae(e.updatedAt)}`:"active"}),s.jsx("span",{children:o})]})]})}function Mle({actor:e,nowMs:t,navigate:n}){const a=e.actorName??"—",r=a[0]?.toUpperCase()??"?",o=QP(e.kind),c=oj(e.title??e.summary,140),u=e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.recordId?{view:"work",workId:e.recordId}:e.agentId?{view:"agents",agentId:e.agentId}:null,h=Rle(a);return s.jsxs("div",{className:"s-now-card s-now-card--observed",style:{cursor:u?"pointer":"default"},onClick:()=>{u&&n(u)},children:[s.jsxs("div",{className:"s-now-card-head",children:[s.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:qt(a)},children:r}),s.jsxs("div",{className:"s-now-card-copy",children:[s.jsx("div",{className:"s-now-card-name",children:a}),s.jsxs("div",{className:"s-now-card-meta",children:["observed",h?` · ${h}`:""," · ",o]})]}),s.jsxs("span",{className:"s-now-card-live s-now-card-live--observed",children:[s.jsx("span",{className:"s-now-card-live-dot","aria-hidden":"true"}),"live"]})]}),s.jsx("div",{className:"s-now-card-task",children:c||"(no recent text)"}),s.jsxs("div",{className:"s-now-card-ticker",children:[s.jsx("span",{className:"s-now-card-ticker-prompt",children:"›"}),s.jsx("span",{className:"s-now-card-ticker-text",children:e.kind.replace(/[._]/g," ")}),s.jsxs("span",{className:"s-now-card-ticker-dots","aria-hidden":"true",children:[s.jsx("span",{}),s.jsx("span",{}),s.jsx("span",{})]})]}),s.jsxs("div",{className:"s-now-card-footer",children:[s.jsxs("span",{children:["updated ",XP(e.ts,t)]}),s.jsx("span",{children:"unmanaged"})]})]})}function Rle(e){const t=e.toLowerCase();return t.includes("claude")?"claude":t.includes("codex")?"codex":t.includes("gemini")?"gemini":t.includes("hudson")?"hudson":null}function Ile({ask:e,navigate:t}){const n=eD(e);return s.jsxs("button",{className:"s-moving-ask-row",onClick:()=>t(n),children:[s.jsx("span",{className:"s-moving-ask-agent",children:e.agentName??e.agentId}),s.jsx("span",{className:"s-moving-ask-title",children:e.summary??e.task}),s.jsx("span",{className:"s-moving-ask-state",children:e.statusLabel}),s.jsx("span",{className:"s-moving-ask-time",children:Ae(e.updatedAt)})]})}function _le({item:e,navigate:t,onMarkInactive:n}){const a=e.updatedAtMs>0?Ae(e.updatedAtMs):"unknown",r=ble(e),o=oj(e.summary,180);return s.jsxs("div",{className:"s-stale-motion-row",children:[s.jsxs("button",{type:"button",className:"s-stale-motion-main",onClick:()=>t(e.route),children:[s.jsx("span",{className:"s-avatar s-avatar-sm",style:{background:qt(e.agentName)},children:e.agentName[0]?.toUpperCase()??"?"}),s.jsxs("span",{className:"s-stale-motion-copy",children:[s.jsx("span",{className:"s-stale-motion-name",children:e.agentName}),s.jsxs("span",{className:"s-stale-motion-meta",children:[s.jsxs("span",{children:["last signal ",a]}),s.jsx("span",{children:r}),s.jsxs("span",{children:["hidden after ",JP(YP)," idle"]})]}),o&&s.jsx("span",{className:"s-stale-motion-summary",children:o})]})]}),s.jsxs("div",{className:"s-stale-motion-actions",children:[s.jsxs("button",{type:"button",className:"s-icon-btn",title:"Open stale source",onClick:()=>t(e.route),children:[s.jsx(Tc,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Open"})]}),s.jsxs("button",{type:"button",className:"s-icon-btn",title:"Mark inactive",onClick:n,children:[s.jsx(r2,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Mark inactive"})]})]})]})}function Ole({value:e,onChange:t,refreshing:n}){return s.jsxs("div",{className:"s-mc-window",role:"group","aria-label":"Lookback window",children:[s.jsxs("span",{className:"s-mc-window-label",children:["Lookback",n&&s.jsx("span",{className:"s-mc-window-refreshing","aria-label":"refreshing"})]}),s.jsx("div",{className:"s-mc-window-tabs",children:Ti.map(a=>s.jsx("button",{type:"button",className:`s-mc-window-tab${a.value===e?" is-active":""}`,onClick:()=>t(a.value),children:a.label},a.value))})]})}function $le(){return s.jsx("div",{className:"s-mc-stream s-fleet-live-stream s-fleet-live-stream--skeleton","aria-hidden":"true",children:[0,1,2,3,4].map(e=>s.jsxs("div",{className:"s-fleet-live-skeleton-row",children:[s.jsx("span",{className:"s-fleet-live-skeleton-time"}),s.jsx("span",{className:"s-fleet-live-skeleton-actor"}),s.jsx("span",{className:"s-fleet-live-skeleton-text"})]},e))})}function Ple({lookbackMs:e,nextOption:t,onWiden:n,loadedAt:a,nowMs:r,error:o,onRetry:c}){if(o)return s.jsxs("div",{className:"s-mc-empty s-fleet-live-empty",children:[s.jsx("div",{className:"s-fleet-live-empty-title",children:"Couldn’t load activity."}),s.jsx("div",{className:"s-fleet-live-empty-detail",children:o}),s.jsx("div",{className:"s-fleet-live-empty-actions",children:s.jsx("button",{type:"button",className:"s-link-btn",onClick:c,children:"Try again"})})]});const u=a?`Polled ${r0(Math.max(0,r-a))} ago.`:"Polling…";return s.jsxs("div",{className:"s-mc-empty s-fleet-live-empty",children:[s.jsxs("div",{className:"s-fleet-live-empty-title",children:["Quiet — no activity in the last ",JP(e),"."]}),s.jsx("div",{className:"s-fleet-live-empty-detail",children:u}),t&&s.jsx("div",{className:"s-fleet-live-empty-actions",children:s.jsxs("button",{type:"button",className:"s-link-btn",onClick:()=>n(t),children:["Widen to ",t.label," →"]})})]})}function Dle({item:e,nowMs:t,onOpen:n}){const a=e.actorName??"—",r=QP(e.kind),o=oj(e.title??e.summary,110);return s.jsxs("button",{type:"button",className:"s-mc-stream-row",onClick:n,children:[s.jsx("span",{className:"s-mc-stream-time",children:XP(e.ts,t)}),s.jsx("span",{className:"s-mc-stream-actor",children:a}),s.jsx("span",{className:"s-mc-stream-verb",children:r}),s.jsx("span",{className:"s-mc-stream-text",children:o})]})}const Lle=new Set(["working","available","offline"]),tD="openscout.mesh.machinePositions.v1";function zle(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(tD);if(!e)return{};const t=JSON.parse(e);if(t&&typeof t=="object"){const n={};for(const[a,r]of Object.entries(t))r&&typeof r=="object"&&typeof r.x=="number"&&typeof r.y=="number"&&(n[a]={x:r.x,y:r.y});return n}}catch{}return{}}function nD(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tD,JSON.stringify(e))}catch{}}let dt={mode:"map",density:"comfortable",selectedId:null,selectedType:null,meshSnapshot:null,probeCache:{},query:"",stateFilter:"all",agentStateFilters:Lle,hiddenMachineIds:new Set,collapsedMachineIds:new Set,treeFullMachineIds:new Set,scrollTargetMachineId:null,machinePositions:zle()};const i0=new Set;function gs(){for(const e of i0)e()}function AT(e){dt.mode!==e&&(dt={...dt,mode:e},gs())}function Cx(e){dt.density!==e&&(dt={...dt,density:e},gs())}function Fo(e,t){dt.selectedId===e&&dt.selectedType===t||(dt={...dt,selectedId:e,selectedType:t},gs())}function bp(e){dt={...dt,meshSnapshot:e},gs()}function sD(e){dt.query!==e&&(dt={...dt,query:e},gs())}function Ex(e){dt.stateFilter!==e&&(dt={...dt,stateFilter:e},gs())}function Ble(e){const t=new Set(dt.agentStateFilters);t.has(e)?t.delete(e):t.add(e),dt={...dt,agentStateFilters:t},gs()}function TT(e){const t=new Set(dt.treeFullMachineIds);t.has(e)?t.delete(e):t.add(e),dt={...dt,treeFullMachineIds:t},gs()}function aD(e){const t=new Set(dt.hiddenMachineIds);t.has(e)?t.delete(e):t.add(e),dt={...dt,hiddenMachineIds:t},gs()}function Ule(e,t){const n=new Set;for(const a of t)a!==e&&n.add(a);dt={...dt,hiddenMachineIds:n},gs()}function Fle(){dt.hiddenMachineIds.size!==0&&(dt={...dt,hiddenMachineIds:new Set},gs())}function Vle(e){const t=new Set(dt.collapsedMachineIds);t.has(e)?t.delete(e):t.add(e),dt={...dt,collapsedMachineIds:t},gs()}function Hle(e,t){const n={...dt.machinePositions,[e]:t};dt={...dt,machinePositions:n},nD(n),gs()}function qle(){if(Object.keys(dt.machinePositions).length===0)return;const e={};dt={...dt,machinePositions:e},nD(e),gs()}function o0(e){dt={...dt,scrollTargetMachineId:e},gs(),queueMicrotask(()=>{dt.scrollTargetMachineId===e&&(dt={...dt,scrollTargetMachineId:null},gs())})}function Wle(e){return i0.add(e),()=>{i0.delete(e)}}function Gle(){return dt}function Sc(){return m.useSyncExternalStore(Wle,Gle)}const vd=340,l0=16,Zle=180,Kle=100,MT=vd+l0;function Yle(e,t){const n=window.innerWidth,a=window.innerHeight,r=12,o=n-e.right,c=e.left;if(o<MT&&c<MT)return{top:Math.max(r,Math.min(a/2-t/2,a-t-r)),left:Math.max(r,n/2-vd/2),side:"center"};const u=o>=c?"right":"left",h=u==="right"?Math.min(e.right+l0,n-vd-r):Math.max(e.left-l0-vd,r),g=e.top+e.height/2-t/2;return{top:Math.max(r,Math.min(g,a-t-r)),left:h,side:u}}function lj({agents:e,orderedIds:t,navigate:n,selectMode:a="preview"}){const[r,o]=m.useState(null),[c,u]=m.useState(null),[h,f]=m.useState(null),g=m.useRef(new Map),v=m.useRef(null),y=m.useRef(null),x=m.useRef(null),w=m.useRef(null),C=c??r,T=m.useMemo(()=>C?e.find(D=>D.id===C)??null:null,[C,e]),E=m.useMemo(()=>c?e.find(D=>D.id===c)??null:null,[c,e]),S=m.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null),y.current&&(window.clearTimeout(y.current),y.current=null)},[]);m.useEffect(()=>()=>S(),[S]),m.useEffect(()=>{if(!C){f(null);return}const D=g.current.get(C);if(!D)return;const V=()=>{const O=D.getBoundingClientRect(),z=x.current?.offsetHeight??260;f(Yle(O,z))};V(),window.addEventListener("scroll",V,!0),window.addEventListener("resize",V);const Z=new ResizeObserver(V);return x.current&&Z.observe(x.current),()=>{window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V),Z.disconnect()}},[C]),m.useEffect(()=>{if(!c)return;const D=Z=>{Z.key==="Escape"&&(u(null),o(null))},V=Z=>{const O=Z.target;if(!x.current?.contains(O)){for(const z of g.current.values())if(z.contains(O))return;u(null)}};return window.addEventListener("keydown",D),window.addEventListener("mousedown",V),()=>{window.removeEventListener("keydown",D),window.removeEventListener("mousedown",V)}},[c]);const k=m.useCallback(D=>{if(!D)return;const V=g.current.get(D);V&&(typeof V.focus=="function"&&V.focus({preventScroll:!1}),V.scrollIntoView({block:"nearest",behavior:"smooth"}))},[]);m.useEffect(()=>{const D=w.current;if(!D)return;const V=Z=>{const O=document.activeElement,z=O?.dataset?.agentId??null,B=t;if(!(B.length===0||!D.contains(O)&&Z.key!=="Escape")){if(Z.key==="ArrowDown"||Z.key==="ArrowUp"){Z.preventDefault();const W=z?B.indexOf(z):-1,L=Z.key==="ArrowDown"?W<0?0:Math.min(W+1,B.length-1):W<=0?0:W-1;k(B[L]);return}if(Z.key==="Home"){Z.preventDefault(),k(B[0]);return}if(Z.key==="End"){Z.preventDefault(),k(B[B.length-1]);return}Z.key.toLowerCase()==="o"&&z&&!Z.metaKey&&!Z.ctrlKey&&!Z.altKey&&(Z.preventDefault(),n({view:"agents",agentId:z}))}};return D.addEventListener("keydown",V),()=>D.removeEventListener("keydown",V)},[t,k,n]);const N=m.useCallback(D=>{if(S(),!(c&&c!==D)){if(r||c===D){o(D);return}v.current=window.setTimeout(()=>{o(D),v.current=null},Zle)}},[S,r,c]),A=m.useCallback(()=>{c||(v.current&&(window.clearTimeout(v.current),v.current=null),y.current=window.setTimeout(()=>{o(null),y.current=null},Kle))},[c]),R=m.useCallback(D=>{if(a==="navigate"){n({view:"agents",agentId:D});return}S(),u(V=>V===D?null:D),o(D)},[a,n,S]),_=m.useCallback(()=>{T&&n({view:"agents",agentId:T.id})},[T,n]),P=m.useCallback(()=>{S(),u(null),o(null)},[S]),$=m.useCallback(D=>({ref:V=>{V?g.current.set(D,V):g.current.delete(D)},onMouseEnter:()=>N(D),onMouseLeave:()=>A(),onFocus:()=>N(D),onBlur:()=>A(),onClick:()=>R(D),"data-agent-id":D,tabIndex:0}),[N,A,R]),H=m.useCallback(D=>({isActive:C===D,isPinned:c===D}),[C,c]),I=h?{position:"fixed",top:h.top,left:h.left,width:vd}:void 0,U=T&&h&&typeof document<"u"?yr.createPortal(s.jsx(Z$,{ref:x,agent:T,pinned:c===T.id,onOpen:_,onClose:P,style:I,className:`agent-card--side-${h.side}${c===T.id?"":" agent-card--preview"}`}),document.querySelector("[data-scout-theme]")??document.body):null;return{bind:$,getState:H,activeAgent:T,pinnedAgent:E,clear:P,card:U,containerRef:w}}function Cc(e){return e?e.replace(/^https?:\/\//,"").split("/")[0].split(":")[0].split(".")[0]||e.slice(0,8):""}function RT(e){return e&&((e.hostName?Cc(e.hostName):null)||e.name)||"this host"}function Xle(e){return Cc(e.hostName)||e.name||"tailnet peer"}function Qle(e){return Cc(e.dnsName)||Cc(e.hostName)||(e.name??"").toLowerCase()}function Jle(e){return Cc(e.hostName)||(e.name?Cc(e.name):"")}function cj(e,t){const n=new Map,a=t.localNode?.id??"local",r=RT(t.localNode),o=(t.localNode&&t.nodes?.[t.localNode.id]?.host)??t.nodes?.[a]?.host;n.set(a,{machineId:a,machineLabel:r,reachability:"this",online:!0,host:o,agents:[]});for(const h of e){const f=h.authorityNodeId??h.homeNodeId??a;let g=n.get(f);if(!g){const v=t.nodes?.[f];g={machineId:f,machineLabel:RT(v)||h.authorityNodeName||h.homeNodeName||f,reachability:"peer",online:!0,host:v?.host,agents:[]},n.set(f,g)}g.agents.push(h)}const c=new Set;for(const h of n.values()){c.add(h.machineLabel.toLowerCase());const f=t.nodes?.[h.machineId];if(f){const g=Jle(f);g&&c.add(g.toLowerCase())}}for(const h of t.tailscale?.peers??[]){const f=Xle(h),g=Qle(h).toLowerCase();if(g&&c.has(g)||c.has(f.toLowerCase()))continue;const v=`tailnet:${h.id}`;n.has(v)||(n.set(v,{machineId:v,machineLabel:f,reachability:"tailnet",online:!!(h.online&&t.tailscale?.running),agents:[]}),g&&c.add(g),c.add(f.toLowerCase()))}const u=h=>h.reachability==="this"?0:h.reachability==="peer"?1:2;return Array.from(n.values()).sort((h,f)=>{const g=u(h)-u(f);return g!==0?g:h.machineLabel.localeCompare(f.machineLabel)})}function ece(e,t){if(t.type==="pan")return{...e,pan:{x:e.pan.x+t.delta.x,y:e.pan.y+t.delta.y}};if(t.type==="zoom"){const n=Math.max(.25,Math.min(4,e.scale*t.factor)),{mx:a,my:r,cx:o,cy:c}=t,u=(a-o)/e.scale-e.pan.x,h=(r-c)/e.scale-e.pan.y;return{scale:n,pan:{x:(a-o)/n-u,y:(r-c)/n-h}}}return e}const rD="openscout.mesh.canvas.viewport.v1";function tce(){const e={pan:{x:0,y:0},scale:1};if(typeof window>"u")return e;try{const t=window.sessionStorage.getItem(rD);if(!t)return e;const n=JSON.parse(t);if(n&&typeof n=="object"&&typeof n.scale=="number"&&n.pan&&typeof n.pan.x=="number"&&typeof n.pan.y=="number")return{pan:{x:n.pan.x,y:n.pan.y},scale:n.scale}}catch{}return e}function nce(e){const t=e.name&&e.name.trim()||e.handle&&e.handle.trim()||e.harness&&e.harness.trim()||"agent";return{key:t.toLowerCase(),label:t}}function sce(e){const t=new Map;for(const n of e){const{key:a,label:r}=nce(n);let o=t.get(a);o||(o={key:a,label:r,instances:[]},t.set(a,o)),o.instances.push(n)}return Array.from(t.values()).map(n=>(n.instances.sort((a,r)=>a.id.localeCompare(r.id)),n)).sort((n,a)=>{const r=n.label.localeCompare(a.label);return r!==0?r:a.instances.length-n.instances.length})}function ace(e){switch(e){case"compact":return{density:e,instanceW:138,instanceH:32,stepX:144,stepY:38,clusterPadX:12,clusterPadY:12,labelH:22,clusterGap:16};case"spacious":return{density:e,instanceW:260,instanceH:68,stepX:268,stepY:76,clusterPadX:14,clusterPadY:14,labelH:26,clusterGap:16};default:return{density:"comfortable",instanceW:210,instanceH:52,stepX:218,stepY:60,clusterPadX:12,clusterPadY:12,labelH:24,clusterGap:14}}}function rce(e,t){return Math.max(1,Math.round(Math.sqrt(e*t)))}function ice(e,t,n){if(e.length===0)return[];const a=e.map(E=>{const S=E.instances.length,k=rce(S,Math.max(.6,Math.min(n,2))),N=Math.ceil(S/k),A=k*t.stepX-(t.stepX-t.instanceW),R=N*t.stepY-(t.stepY-t.instanceH);return{cluster:E,cols:k,width:A+t.clusterPadX*2,height:R+t.clusterPadY*2+t.labelH}}),r=a.reduce((E,S)=>E+S.width*S.height,0),o=Math.max(Math.max(...a.map(E=>E.width)),Math.sqrt(r*n)),c=t.clusterGap,u=[];let h=0,f=0,g=0;for(const E of a)h>0&&h+E.width>o&&(f+=g+c,h=0,g=0),u.push({cluster:E.cluster,x:h,y:f,width:E.width,height:E.height,cols:E.cols}),h+=E.width+c,g=Math.max(g,E.height);const v=Math.min(...u.map(E=>E.x)),y=Math.max(...u.map(E=>E.x+E.width)),x=Math.min(...u.map(E=>E.y)),w=Math.max(...u.map(E=>E.y+E.height)),C=-((v+y)/2),T=-((x+w)/2);return u.map(E=>({...E,x:E.x+C,y:E.y+T}))}function oce(e,t,n){const a=e%t,r=Math.floor(e/t);return{x:n.clusterPadX+a*n.stepX,y:n.labelH+n.clusterPadY+r*n.stepY}}function uj(e){const t=e.harness?.trim(),n=e.model?.trim();return t&&n?`${t}/${n}`:t||n||"—"}function dj(e){const t=e.project?.trim(),n=e.branch?.trim();return t&&n?`${t}/${n}`:t||n||"—"}function wp(e){return e.cwd||e.projectRoot||"—"}function fj({onClick:e}){return s.jsx("button",{type:"button",className:"mesh-sheet-open",title:"Open agent view","aria-label":"Open agent view",onClick:t=>{t.stopPropagation(),e()},children:"↗"})}function lce({agent:e,onOpen:t,bindings:n,active:a}){const r=Je(e.state),o=e.agentClass==="organic",c=e.updatedAt?Ae(e.updatedAt):"",u=uj(e),h=dj(e);return s.jsxs("div",{...n??{},className:`mesh-instance-spec mesh-instance-spec--${r}${o?" mesh-instance-spec--organic":""}${a?" mesh-instance--active":""}`,style:{"--state-stripe":Pn(e.state)},title:`${u} — ${h}`,children:[s.jsxs("span",{className:"mesh-instance-spec-row",children:[s.jsx("span",{className:"mesh-instance-spec-primary",children:u}),c&&s.jsx("span",{className:"mesh-instance-spec-time",children:c})]}),s.jsxs("span",{className:"mesh-instance-spec-row",children:[s.jsx("span",{className:"mesh-instance-spec-secondary",children:h}),s.jsx(fj,{onClick:t})]})]})}function cce({agent:e,onOpen:t,bindings:n,active:a}){const r=Je(e.state),o=e.agentClass==="organic",c=e.updatedAt?Ae(e.updatedAt):"—",u=`${uj(e)} · ${dj(e)}`;return s.jsxs("div",{...n??{},className:`mesh-instance-sheet mesh-instance-sheet--${r}${o?" mesh-instance-sheet--organic":""}${a?" mesh-instance--active":""}`,style:{"--state-stripe":Pn(e.state)},title:`${u}
174
+ ${wp(e)}`,children:[s.jsxs("span",{className:"mesh-sheet-line mesh-sheet-line--head",children:[s.jsx("span",{className:"mesh-sheet-id",children:u}),s.jsx("span",{className:"mesh-sheet-time",children:c}),s.jsx(fj,{onClick:t})]}),s.jsxs("span",{className:"mesh-sheet-line",children:[s.jsx("span",{className:"mesh-sheet-path",children:wp(e)}),s.jsxs("span",{className:"mesh-sheet-ctx",children:[s.jsx("span",{className:"mesh-sheet-ctx-label",children:"CTX"})," —"]})]})]})}function uce({agent:e,onOpen:t,bindings:n,active:a}){const r=Je(e.state),o=e.agentClass==="organic",c=e.updatedAt?Ae(e.updatedAt):"—",u=`${uj(e)} · ${dj(e)}`,h=e.agentClass?.trim();return s.jsxs("div",{...n??{},className:`mesh-instance-sheet mesh-instance-sheet--spacious mesh-instance-sheet--${r}${o?" mesh-instance-sheet--organic":""}${a?" mesh-instance--active":""}`,style:{"--state-stripe":Pn(e.state)},title:`${u}
175
+ ${wp(e)}`,children:[s.jsxs("span",{className:"mesh-sheet-line mesh-sheet-line--head",children:[s.jsx("span",{className:"mesh-sheet-id",children:u}),s.jsx("span",{className:"mesh-sheet-time",children:c}),s.jsx(fj,{onClick:t})]}),s.jsx("span",{className:"mesh-sheet-line",children:s.jsx("span",{className:"mesh-sheet-path",children:wp(e)})}),s.jsxs("span",{className:"mesh-sheet-line",children:[s.jsxs("span",{className:"mesh-sheet-ctx",children:[s.jsx("span",{className:"mesh-sheet-ctx-label",children:"CTX"})," —"]}),h&&s.jsx("span",{className:"mesh-sheet-tag",children:h})]})]})}function dce({layout:e,metrics:t,onAgentOpen:n,bindFor:a,activeId:r}){const{cluster:o,x:c,y:u,width:h,height:f,cols:g}=e,v=m.useMemo(()=>{const y={working:0,available:0,offline:0};for(const x of o.instances)y[Je(x.state)]+=1;return y},[o.instances]);return s.jsxs("div",{className:"mesh-cluster",style:{position:"absolute",left:c,top:u,width:h,height:f},children:[s.jsxs("div",{className:"mesh-cluster-header",style:{height:t.labelH},children:[s.jsx("span",{className:"mesh-cluster-name",children:o.label}),s.jsx("span",{className:"mesh-cluster-count",children:o.instances.length}),s.jsxs("span",{className:"mesh-cluster-states",children:[v.working>0&&s.jsxs("span",{className:"mesh-cluster-state mesh-cluster-state--working",children:[s.jsx("span",{className:"mesh-cluster-state-dot"}),v.working]}),v.available>0&&s.jsxs("span",{className:"mesh-cluster-state mesh-cluster-state--available",children:[s.jsx("span",{className:"mesh-cluster-state-dot"}),v.available]}),v.offline>0&&s.jsxs("span",{className:"mesh-cluster-state mesh-cluster-state--offline",children:[s.jsx("span",{className:"mesh-cluster-state-dot"}),v.offline]})]})]}),o.instances.map((y,x)=>{const w=oce(x,g,t);return s.jsx("div",{style:{position:"absolute",left:w.x,top:w.y,width:t.instanceW,height:t.instanceH},children:t.density==="compact"?s.jsx(lce,{agent:y,onOpen:()=>n(y),bindings:a(y.id),active:r===y.id}):t.density==="spacious"?s.jsx(uce,{agent:y,onOpen:()=>n(y),bindings:a(y.id),active:r===y.id}):s.jsx(cce,{agent:y,onOpen:()=>n(y),bindings:a(y.id),active:r===y.id})},y.id)})]})}const c0=34,iD=22,fce=6,IT=28,_T=10,Ax=12,OT=380,hce=240,Tx=38;function mce(e,t,n,a,r,o){const c=[],u=[],h=[];for(const C of e)a[C.machineId]?h.push(C):u.push(C);let f=0,g=OT;const v=(C,T)=>{const S=t.has(C.machineId)||!C.online,k=n.has(C.machineId);let N=0,A=0,R=0;for(const z of C.agents){const B=Je(z.state);B==="working"?N+=1:B==="available"?A+=1:R+=1}const _=C.online?N>0?"working":A>0?"available":"offline":"offline";if(S)return{machineId:C.machineId,machineLabel:C.machineLabel,reachability:C.reachability,online:C.online,agentCount:C.agents.length,workingCount:N,availableCount:A,offlineCount:R,dominantState:_,host:C.host,collapsed:!1,ghost:!0,pinned:T,x:0,y:0,width:hce,height:Tx,headerHeight:Tx,chromeHeight:Tx,layouts:[]};const P=k?[]:sce(C.agents),$=k?[]:ice(P,r,o),H=k?yce():0,I=k?oD+H*iD+fce:0,U=c0+I;let D=0,V=0;if(!k&&$.length>0){const z=Math.min(...$.map(K=>K.x)),B=Math.max(...$.map(K=>K.x+K.width)),X=Math.min(...$.map(K=>K.y)),W=Math.max(...$.map(K=>K.y+K.height));D=B-z,V=W-X;const L=-z+Ax,q=-X+U+_T;for(const K of $)K.x+=L,K.y+=q}const Z=Math.max(OT,D+Ax*2),O=k?U:U+_T+V+Ax;return{machineId:C.machineId,machineLabel:C.machineLabel,reachability:C.reachability,online:C.online,agentCount:C.agents.length,workingCount:N,availableCount:A,offlineCount:R,dominantState:_,host:C.host,collapsed:k,ghost:!1,pinned:T,x:0,y:0,width:Z,height:O,headerHeight:c0,chromeHeight:U,layouts:$}};for(const C of u){const T=v(C,!1);T.x=0,T.y=f,c.push(T),g=Math.max(g,T.width),f+=T.height+IT}const y=Math.max(0,f-IT),x=-g/2,w=-y/2;for(const C of c)C.ghost||(C.width=g),C.x=x,C.y+=w;for(const C of h){const T=v(C,!0),E=a[C.machineId];T.x=E.x,T.y=E.y,c.push(T)}return c}function pce({section:e,metrics:t,onAgentOpen:n,bindFor:a,activeId:r,onHeaderPointerDown:o,onHeaderClick:c,onGhostActivate:u}){const h=e.reachability==="this"?"this node":e.reachability==="peer"?"peer":e.reachability==="tailnet"?"tailnet":"",f=e.online?e.agentCount===0?"idle":"standby":"unreachable";if(e.ghost)return s.jsx("div",{"data-machine-id":e.machineId,className:"mesh-machine-ghost",style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,pointerEvents:"all"},title:`${e.machineLabel} · ${f} — click to show`,children:s.jsxs("button",{type:"button",className:"mesh-machine-ghost-body",onPointerDown:v=>o(v,e),onClick:()=>u(e.machineId),children:[s.jsx("span",{className:"mesh-machine-ghost-led","aria-hidden":!0}),s.jsx("span",{className:"mesh-machine-ghost-name",children:e.machineLabel}),s.jsx("span",{className:"mesh-machine-ghost-stamp",children:f}),h&&s.jsx("span",{className:`mesh-machine-chip mesh-machine-chip--${e.reachability} mesh-machine-chip--ghost`,children:h}),s.jsxs("span",{className:"mesh-machine-ghost-counts",children:[s.jsx("span",{className:"mesh-machine-count",children:e.agentCount}),e.workingCount>0&&s.jsxs("span",{className:"mesh-machine-count mesh-machine-count--working",children:[e.workingCount,"W"]})]})]})});const g=e.collapsed?gce(e):[];return s.jsxs("div",{"data-machine-id":e.machineId,className:`mesh-machine-section${e.collapsed?" mesh-machine-section--collapsed":""}${e.pinned?" mesh-machine-section--pinned":""}`,style:{position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,pointerEvents:"all"},children:[s.jsxs("button",{type:"button",className:"mesh-machine-header",style:{height:e.headerHeight},onPointerDown:v=>o(v,e),onClick:()=>c(e.machineId),"aria-expanded":!e.collapsed,children:[s.jsx("span",{className:`mesh-machine-led mesh-machine-led--${e.dominantState}`,style:{color:Pn(e.dominantState)},"aria-hidden":!0}),s.jsx("span",{className:"mesh-machine-caret","aria-hidden":!0,children:e.collapsed?"▸":"▾"}),s.jsx("span",{className:"mesh-machine-grip","aria-hidden":!0,children:"⠿"}),s.jsx("span",{className:"mesh-machine-name",children:e.machineLabel}),h&&s.jsx("span",{className:`mesh-machine-chip mesh-machine-chip--${e.reachability}`,children:h})]}),e.collapsed&&s.jsxs("div",{className:"mesh-machine-spec",children:[s.jsxs("div",{className:"mesh-machine-state-strip",style:{height:oD},children:[s.jsxs("div",{className:"mesh-machine-state-cell mesh-machine-state-cell--working",children:[s.jsx("span",{className:"mesh-machine-state-num",children:e.workingCount}),s.jsx("span",{className:"mesh-machine-state-label",children:"working"})]}),s.jsxs("div",{className:"mesh-machine-state-cell",children:[s.jsx("span",{className:"mesh-machine-state-num",children:e.availableCount}),s.jsx("span",{className:"mesh-machine-state-label",children:"available"})]}),s.jsxs("div",{className:"mesh-machine-state-cell",children:[s.jsx("span",{className:"mesh-machine-state-num",children:e.agentCount}),s.jsx("span",{className:"mesh-machine-state-label",children:"total"})]})]}),g.map(v=>s.jsxs("div",{className:"mesh-machine-spec-row",style:{height:iD},children:[s.jsx("span",{className:"mesh-machine-spec-label",children:v.label}),s.jsx("span",{className:"mesh-machine-spec-value",title:v.value,children:v.value})]},v.label))]}),!e.collapsed&&e.layouts.map(v=>s.jsx(dce,{layout:v,metrics:t,onAgentOpen:n,bindFor:a,activeId:r},v.cluster.key))]})}function gce(e){const t=e.host;return[{label:"os",value:t?.os??"—"},{label:"arch",value:t?.arch??"—"},{label:"cpu",value:t?.cpuCores?`${t.cpuCores}c`:"—"},{label:"ram",value:t?.memoryGb?`${t.memoryGb} G`:"—"},{label:"disk",value:t?.storageCapacityGb?`${t.storageCapacityGb} G`:"—"},{label:"network",value:t?.network??"—"},{label:"scout",value:t?.scoutVersion?`v${t.scoutVersion}`:"—"}]}const vce=7,oD=54;function yce(e,t,n,a){return vce}function xce({mesh:e,agents:t=[]}){const n=m.useRef(null),[a,r]=m.useState({w:0,h:0}),[o,c]=m.useReducer(ece,void 0,tce);m.useEffect(()=>{if(!(typeof window>"u"))try{window.sessionStorage.setItem(rD,JSON.stringify({pan:o.pan,scale:o.scale}))}catch{}},[o.pan,o.scale]);const{density:u,query:h,agentStateFilters:f,hiddenMachineIds:g,collapsedMachineIds:v,scrollTargetMachineId:y}=Sc(),{navigate:x}=qe();m.useLayoutEffect(()=>{const q=n.current;if(!q)return;const K=()=>r({w:q.clientWidth,h:q.clientHeight});K();const ee=new ResizeObserver(K);return ee.observe(q),()=>ee.disconnect()},[]),m.useLayoutEffect(()=>{const q=n.current;if(!q)return;const K=ee=>{ee.preventDefault();const G=ee.deltaY<0?1.12:1/1.12,re=q.getBoundingClientRect();c({type:"zoom",factor:G,mx:ee.clientX-re.left,my:ee.clientY-re.top,cx:re.width/2,cy:re.height/2})};return q.addEventListener("wheel",K,{passive:!1}),()=>q.removeEventListener("wheel",K)},[]);const{machinePositions:w}=Sc(),C=m.useMemo(()=>ace(u),[u]),T=m.useMemo(()=>{const q=h.trim().toLowerCase();return t.filter(K=>{const ee=Je(K.state),G=ee==="working"||ee==="available"?ee:"offline";return f.has(G)?q?`${K.name??""} ${K.handle??""} ${K.harness??""} ${K.project??""} ${K.branch??""}`.toLowerCase().includes(q):!0:!1})},[t,h,f]),E=m.useMemo(()=>cj(T,e),[T,e]),S=a.w>0&&a.h>0?a.w/a.h:1.6,k=m.useMemo(()=>mce(E,g,v,w,C,S),[E,g,v,w,C,S]),N=m.useRef(null),[A,R]=m.useState(null),_=m.useCallback((q,K)=>{if(q.button!==0)return;q.stopPropagation(),q.currentTarget.setPointerCapture(q.pointerId),N.current={machineId:K.machineId,startClientX:q.clientX,startClientY:q.clientY,startSectionX:K.x,startSectionY:K.y,pointerId:q.pointerId,moved:!1}},[]);m.useEffect(()=>{const q=ee=>{const G=N.current;if(!G||ee.pointerId!==G.pointerId)return;const re=ee.clientX-G.startClientX,Q=ee.clientY-G.startClientY;if(!G.moved&&Math.hypot(re,Q)<4)return;G.moved=!0;const ae=re/o.scale,be=Q/o.scale;R({machineId:G.machineId,x:G.startSectionX+ae,y:G.startSectionY+be})},K=ee=>{const G=N.current;if(!(!G||ee.pointerId!==G.pointerId)){if(N.current=null,G.moved){const re=(ee.clientX-G.startClientX)/o.scale,Q=(ee.clientY-G.startClientY)/o.scale;Hle(G.machineId,{x:G.startSectionX+re,y:G.startSectionY+Q})}R(null)}};return window.addEventListener("pointermove",q),window.addEventListener("pointerup",K),window.addEventListener("pointercancel",K),()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",K),window.removeEventListener("pointercancel",K)}},[o.scale]);const P=m.useRef(!1);m.useEffect(()=>{if(A)P.current=!0;else{const q=setTimeout(()=>{P.current=!1},50);return()=>clearTimeout(q)}},[A]);const $=m.useCallback(q=>{P.current||aD(q)},[]),H=m.useCallback(q=>{P.current||Vle(q)},[]),I=m.useMemo(()=>A?k.map(q=>q.machineId===A.machineId?{...q,x:A.x,y:A.y,pinned:!0}:q):k,[k,A]);m.useEffect(()=>{if(!y)return;const q=I.find(K=>K.machineId===y);q&&c({type:"pan",delta:{x:-q.x-o.pan.x-q.width/2,y:-q.y-o.pan.y+a.h/4-c0}})},[y,I,o.pan.x,o.pan.y,a.h]);const U=m.useCallback(q=>{q.agentClass!=="organic"&&x({view:"agents",agentId:q.id})},[x]),D=m.useMemo(()=>T.filter(q=>q.agentClass!=="organic"),[T]),V=m.useMemo(()=>D.map(q=>q.id),[D]),Z=lj({agents:D,orderedIds:V,navigate:x,selectMode:"preview"}),O=m.useCallback(q=>V.includes(q)?Z.bind(q):null,[Z,V]),z=Z.activeAgent?.id??null,{pan:B,scale:X}=o,W=a.w/2,L=a.h/2;return s.jsxs("div",{ref:n,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[a.w>0&&s.jsx(YR,{panOffset:B,scale:X,onPan:q=>c({type:"pan",delta:q}),gridOpacity:.7}),s.jsx("div",{style:{position:"absolute",left:0,top:0,width:0,height:0,transform:`translate(${W}px, ${L}px) translate(${B.x*X}px, ${B.y*X}px) scale(${X})`,transformOrigin:"0 0",pointerEvents:"none"},children:I.length===0?s.jsx("div",{style:{position:"absolute",left:-120,top:-20,width:240,textAlign:"center",pointerEvents:"none"},children:s.jsx("div",{className:"mesh-empty-pill",children:"no machines visible"})}):I.map(q=>s.jsx(pce,{section:q,metrics:C,onAgentOpen:U,bindFor:O,activeId:z,onHeaderPointerDown:_,onHeaderClick:H,onGhostActivate:$},q.machineId))}),s.jsx("div",{className:"mesh-canvas-hint",children:"scroll to zoom · drag to pan"}),Z.card]})}function bce(e){const t=new Map,n=new Map;for(const o of e){const c=o.project??"Unassigned",u=c.toLowerCase(),h=o.branch??"—";let f=t.get(u);f||(f=new Map,t.set(u,f));const g=f.get(h)??[];g.push(o),f.set(h,g);let v=n.get(u);v||(v=new Map,n.set(u,v)),v.set(c,(v.get(c)??0)+1)}const a=o=>{const c=n.get(o);if(!c)return o;let u=null,h=-1;for(const[f,g]of c)g>h&&(u=f,h=g);return u??o},r=[];for(const[o,c]of t){const u=a(o),h=[];let f=0;const g={working:0,available:0,offline:0},v=[];for(const[y,x]of c){const w=[...x].sort((T,E)=>(E.updatedAt??0)-(T.updatedAt??0)),C=w.reduce((T,E)=>Math.max(T,E.updatedAt??0),0);f=Math.max(f,C);for(const T of w)g[Je(T.state)]+=1,v.push(T);h.push({branch:y,agents:w,latest:C})}h.sort((y,x)=>x.latest-y.latest),r.push({project:u,branches:h,agents:v,latest:f,counts:g})}return r.sort((o,c)=>c.latest-o.latest),r}function $T(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):null}function wce({agents:e,emptyTitle:t="No agents registered",emptyBody:n="Agents connected to this broker will appear here.",selectMode:a="preview"}){const{navigate:r}=qe(),o=m.useMemo(()=>bce(e),[e]),[c,u]=m.useState(()=>new Set),h=m.useMemo(()=>{const v=[];for(const y of o)if(!c.has(y.project))for(const x of y.branches)for(const w of x.agents)v.push(w.id);return v},[o,c]),f=lj({agents:e,orderedIds:h,navigate:r,selectMode:a});if(e.length===0)return s.jsxs("div",{className:"sys-list-empty",children:[s.jsx("h3",{children:t}),s.jsx("p",{children:n})]});const g=v=>{u(y=>{const x=new Set(y);return x.has(v)?x.delete(v):x.add(v),x})};return s.jsxs("div",{className:"mesh-tree",ref:f.containerRef,children:[o.map(v=>{const y=c.has(v.project);return s.jsxs("div",{className:`mesh-tree-group${y?" mesh-tree-group--collapsed":""}`,children:[s.jsxs("button",{type:"button",className:"mesh-tree-project",onClick:()=>g(v.project),"aria-expanded":!y,children:[s.jsx("span",{className:`mesh-tree-caret${y?"":" mesh-tree-caret--open"}`,"aria-hidden":!0,children:"›"}),s.jsx("span",{className:"mesh-tree-project-name",children:v.project}),s.jsx("span",{className:"mesh-tree-project-count",children:v.agents.length}),s.jsxs("span",{className:"mesh-tree-counts",children:[v.counts.working>0&&s.jsxs("span",{className:"mesh-tree-count mesh-tree-count--working",children:[s.jsx("span",{className:"mesh-tree-count-dot"}),v.counts.working]}),v.counts.available>0&&s.jsxs("span",{className:"mesh-tree-count mesh-tree-count--available",children:[s.jsx("span",{className:"mesh-tree-count-dot"}),v.counts.available]}),v.counts.offline>0&&s.jsxs("span",{className:"mesh-tree-count mesh-tree-count--offline",children:[s.jsx("span",{className:"mesh-tree-count-dot"}),v.counts.offline]})]}),s.jsx("span",{className:"mesh-tree-project-time",children:v.latest?Ae(v.latest):""})]}),!y&&s.jsx("div",{className:"mesh-tree-branches",children:v.branches.map(x=>s.jsxs("div",{className:"mesh-tree-branch",children:[s.jsxs("div",{className:"mesh-tree-branch-head",children:[s.jsx("span",{className:"mesh-tree-branch-elbow","aria-hidden":!0,children:"└"}),s.jsx("span",{className:"mesh-tree-branch-name",children:x.branch})]}),s.jsx("div",{className:"mesh-tree-agents",children:x.agents.map(w=>{const C=Je(w.state),T=w.agentClass==="organic",E=f.getState(w.id),S=$T(w.cwd)??$T(w.projectRoot),k=w.harnessSessionId?w.harnessSessionId.slice(0,8):null,N=[];S&&N.push({kind:"cwd",text:S}),w.harness&&N.push({kind:"harness",text:w.harness}),w.model&&N.push({kind:"model",text:w.model}),k&&N.push({kind:"sess",text:`sess:${k}`});const A=f.bind(w.id);return s.jsxs("button",{type:"button",className:`mesh-tree-agent${T?" mesh-tree-agent--organic":""}${E.isActive?" mesh-tree-agent--active":""}${E.isPinned?" mesh-tree-agent--pinned":""}`,title:T?`${w.harness??w.name} · organic session`:void 0,...A,children:[s.jsx("span",{className:`mesh-tree-agent-dot mesh-tree-agent-dot--${C}`,style:{background:Pn(w.state)}}),s.jsx("span",{className:"mesh-tree-agent-name",children:w.handle??w.name}),T&&s.jsx("span",{className:"mesh-tree-agent-organic","aria-label":"organic session",children:"○"}),s.jsx("span",{className:"mesh-tree-agent-inline",children:N.map((R,_)=>s.jsxs("span",{className:`mesh-tree-agent-inline-part mesh-tree-agent-inline-part--${R.kind}`,children:[_>0&&s.jsx("span",{className:"mesh-tree-agent-inline-sep",children:"·"}),R.text]},R.kind))}),s.jsx("span",{className:`mesh-tree-agent-state mesh-tree-agent-state--${C}`,children:C}),s.jsx("span",{className:"mesh-tree-agent-time",children:w.updatedAt?Ae(w.updatedAt):""})]},w.id)})})]},x.branch))})]},v.project)}),f.card]})}function jce(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??null}function Nce(e,t){if(!e)return[];const n=new Set;for(const o of t)o.cwd&&n.add(o.cwd),o.projectRoot&&n.add(o.projectRoot);const a=new Map;for(const o of e.transcripts){if(!o.cwd)continue;const c=a.get(o.cwd);(!c||o.mtimeMs>c.mtimeMs)&&a.set(o.cwd,o)}const r=[];for(const o of e.processes){if(o.harness==="scout-managed"||o.cwd&&n.has(o.cwd))continue;const c=o.cwd?a.get(o.cwd):void 0,u=c?.project??jce(o.cwd)??null,h=c?.mtimeMs??e.generatedAt,f=c?.sessionId??null;r.push({id:`harness:${o.source}:${o.pid}`,name:o.source,handle:null,agentClass:"organic",harness:o.source,state:"working",projectRoot:o.cwd,cwd:o.cwd,updatedAt:h,createdAt:null,transport:null,selector:null,wakePolicy:null,capabilities:[],project:u,branch:null,role:null,model:null,harnessSessionId:f,harnessLogPath:c?.transcriptPath??null,conversationId:f??`harness:${o.pid}`,homeNodeId:null,homeNodeName:null,ownerId:null,ownerName:null,ownerHandle:null})}return r}function lD(){const{agents:e}=qe(),[t,n]=m.useState(null);m.useEffect(()=>{let o=!1;const c=async()=>{const h=await me("/api/tail/discover").catch(()=>null);o||n(h)};c();const u=setInterval(()=>{c()},1e4);return()=>{o=!0,clearInterval(u)}},[]);const a=m.useMemo(()=>Nce(t,e),[t,e]);return{agents:m.useMemo(()=>[...e,...a],[e,a]),scoutAgents:e,organicAgents:a,discovery:t}}function PT({mode:e,density:t,query:n,stateFilter:a,loading:r,refreshing:o,error:c,lastLoadedAt:u,hasMesh:h,onRefresh:f}){return s.jsxs("div",{className:`mesh-hud mesh-hud--${e}`,children:[s.jsxs("div",{className:"mesh-hud-left",children:[s.jsx("span",{className:"mesh-hud-title",children:"Mesh"}),s.jsxs("div",{className:"mesh-mode-toggle",children:[s.jsx("button",{type:"button",className:`mesh-mode-btn${e==="map"?" mesh-mode-btn--active":""}`,onClick:()=>AT("map"),children:"Map"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${e==="tree"?" mesh-mode-btn--active":""}`,onClick:()=>AT("tree"),children:"Tree"})]}),s.jsxs("div",{className:"mesh-mode-toggle mesh-density-toggle",role:"group","aria-label":"Density","aria-hidden":e!=="map","data-mode-only":"map",children:[s.jsx("button",{type:"button",className:`mesh-mode-btn${t==="compact"?" mesh-mode-btn--active":""}`,onClick:()=>Cx("compact"),disabled:e!=="map",title:"Compact — dots",children:"Compact"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${t==="comfortable"?" mesh-mode-btn--active":""}`,onClick:()=>Cx("comfortable"),disabled:e!=="map",title:"Comfortable — chips",children:"Comfortable"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${t==="spacious"?" mesh-mode-btn--active":""}`,onClick:()=>Cx("spacious"),disabled:e!=="map",title:"Spacious — cards",children:"Spacious"})]})]}),h&&s.jsxs("div",{className:"mesh-hud-filters",children:[s.jsx("input",{type:"search",className:"mesh-hud-search",placeholder:"Filter agents…",value:n,onChange:g=>sD(g.target.value),spellCheck:!1,autoCorrect:"off",autoCapitalize:"off"}),s.jsxs("div",{className:"mesh-mode-toggle",role:"group","aria-label":"State",children:[s.jsx("button",{type:"button",className:`mesh-mode-btn${a==="all"?" mesh-mode-btn--active":""}`,onClick:()=>Ex("all"),children:"All"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${a==="working"?" mesh-mode-btn--active":""}`,onClick:()=>Ex("working"),children:"Working"}),s.jsx("button",{type:"button",className:`mesh-mode-btn${a==="available"?" mesh-mode-btn--active":""}`,onClick:()=>Ex("available"),children:"Available"})]})]}),s.jsxs("div",{className:"mesh-hud-right",children:[s.jsx("span",{className:"mesh-hud-sync",children:r?"Loading…":c&&h?`Stale — ${u?Ae(u):"unknown"}`:u?Ae(u):"—"}),s.jsx("button",{type:"button",className:"s-btn",disabled:r||o,onClick:f,children:o?"Refreshing…":"Refresh"})]})]})}function kce({navigate:e}){const[t,n]=m.useState(!0),[a,r]=m.useState(!1),[o,c]=m.useState(null),[u,h]=m.useState(null),{mode:f,density:g,query:v,stateFilter:y,meshSnapshot:x}=Sc(),{agents:w}=lD(),{route:C}=qe(),T=oa(C),E=m.useMemo(()=>el(w,T,x?.localNode?.id),[w,T,x?.localNode?.id]),S=m.useRef(null),k=m.useRef(0);m.useEffect(()=>{S.current=x},[x]),m.useEffect(()=>{T&&Fo(T,"node")},[T]);const N=m.useCallback(async(_="initial")=>{const P=++k.current;!(S.current!==null)&&_!=="background"?(n(!0),c(null)):r(!0);try{const H=await me("/api/mesh");if(P!==k.current)return;bp(H),c(null),h(Date.now())}catch(H){if(P!==k.current)return;c(H instanceof Error?H.message:String(H))}finally{P===k.current&&(n(!1),r(!1))}},[]);m.useEffect(()=>{N("initial")},[N]),m.useEffect(()=>{const _=setInterval(()=>{N("background")},1e4);return()=>clearInterval(_)},[N]);const A=m.useMemo(()=>{const _=v.trim().toLowerCase();return E.filter(P=>y!=="all"&&Je(P.state)!==y?!1:_?`${P.name??""} ${P.handle??""} ${P.harness??""} ${P.project??""} ${P.branch??""}`.toLowerCase().includes(_):!0)},[v,E,y]),R={mode:f,density:g,query:v,stateFilter:y,loading:t,refreshing:a,error:o,lastLoadedAt:u,hasMesh:!!x,onRefresh:()=>{N("manual")}};return f==="map"?s.jsxs("div",{className:"mesh-map-canvas",children:[x&&s.jsx(xce,{mesh:x,agents:A}),t&&!x&&s.jsx("div",{className:"mesh-canvas-center",children:s.jsx("p",{className:"mesh-canvas-center-label",children:"Loading mesh…"})}),!t&&!x&&o&&s.jsxs("div",{className:"mesh-canvas-center",children:[s.jsx("p",{className:"mesh-canvas-center-label",children:o}),s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{N("manual")},children:"Try again"})]}),s.jsx(PT,{...R})]}):s.jsxs("div",{className:"mesh-tree-page",children:[s.jsx(PT,{...R}),t&&!x&&s.jsxs("div",{className:"sys-panel sys-state-card mesh-tree-state",children:[s.jsx("h3",{className:"sys-state-title",children:"Loading mesh status"}),s.jsx("p",{className:"sys-state-body",children:"Inspecting broker reachability and peer discovery inputs."})]}),!t&&!x&&o&&s.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error mesh-tree-state",children:[s.jsx("h3",{className:"sys-state-title",children:"Mesh status is unavailable"}),s.jsx("p",{className:"sys-state-body",children:o}),s.jsx("div",{className:"sys-inline-actions",children:s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{N("manual")},children:"Try again"})})]}),x&&s.jsxs("section",{className:"mesh-tree-panel",children:[s.jsxs("div",{className:"mesh-tree-hint","aria-hidden":!0,children:[s.jsx("kbd",{children:"↑"}),s.jsx("kbd",{children:"↓"}),s.jsx("span",{children:"navigate"}),s.jsx("span",{className:"mesh-tree-hint-sep",children:"·"}),s.jsx("kbd",{children:"enter"}),s.jsx("span",{children:"pin"}),s.jsx("span",{className:"mesh-tree-hint-sep",children:"·"}),s.jsx("kbd",{children:"o"}),s.jsx("span",{children:"open"}),s.jsx("span",{className:"mesh-tree-hint-sep",children:"·"}),s.jsx("kbd",{children:"esc"}),s.jsx("span",{children:"clear"})]}),s.jsx(wce,{agents:A,emptyTitle:E.length===0?T?"No agents on this machine":"No agents registered":"No agents match your filter",emptyBody:E.length===0?"Agents connected to this broker will appear here.":"Try clearing the search or switching the state pill back to All."})]})]})}function Sce({conversationId:e,navigate:t}){const[n,a]=m.useState(null),[r,o]=m.useState(!1);return m.useEffect(()=>{if(!e){a(null);return}let c=!1;return o(!0),me(`/api/session/${encodeURIComponent(e)}`).then(u=>{c||a(u)}).catch(()=>{c||a(null)}).finally(()=>{c||o(!1)}),()=>{c=!0}},[e]),tn(c=>{e&&c.kind==="conversation.upserted"&&me(`/api/session/${encodeURIComponent(e)}`).then(u=>a(u)).catch(()=>{})}),e?r&&!n?s.jsx(Ece,{}):n&&Uo(n)?s.jsx(VP,{channelId:e,navigate:t}):s.jsx(hg,{conversationId:e,navigate:t}):s.jsx(Cce,{})}function Cce(){return s.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:32,color:"var(--muted)",fontFamily:"var(--font-mono)",fontSize:12,letterSpacing:"0.04em"},children:s.jsxs("div",{style:{textAlign:"center",maxWidth:360},children:[s.jsx("div",{style:{textTransform:"uppercase",letterSpacing:"0.18em",fontSize:10,color:"color-mix(in srgb, var(--accent) 70%, var(--muted))",marginBottom:8},children:"Messages"}),s.jsx("p",{style:{lineHeight:1.6,margin:0},children:"Pick a DM or channel from the left rail. Use the filter chips to switch scopes and the sort selector to reorder."})]})})}function Ece(){return s.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--muted)",fontFamily:"var(--font-mono)",fontSize:12},children:"Loading conversation…"})}const _m=new Set;let Mx=null,DT=null,jp=null;function Ace(){return`ws://${typeof window<"u"?window.location.hostname:"127.0.0.1"}:65535/trpc`}function Tce(e){for(const t of[..._m])t(e)}function Mce(){jp||(Mx||(Mx=f$({url:Ace()}),DT=m$({links:[h$({client:Mx})]})),jp=DT.tail.events.subscribe(void 0,{onData:e=>{const t=e.data;t&&Tce(t)}}))}function Rce(){jp?.unsubscribe(),jp=null}function nf(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>{const n=a=>t.current(a);return _m.add(n),Mce(),()=>{_m.delete(n),_m.size===0&&Rce()}},[])}const Ice=1e4,_ce=500,LT=1e3,Oce=6e4,$ce=[{key:"status",label:"status",cls:"s-atop-col-status",kind:"text",sortable:!1,defaultWidth:96,minWidth:70,render:e=>s.jsxs("span",{className:`s-atop-status s-atop-status--${e.status}`,children:[s.jsx("span",{className:"s-atop-status-dot","aria-hidden":"true"}),e.statusLabel]})},{key:"session",label:"session",cls:"s-atop-col-agent",kind:"text",sortable:!1,defaultWidth:168,minWidth:110,maxWidth:280,render:e=>s.jsxs("div",{className:"s-atop-agent-cell",title:e.sessionId??e.refId,children:[s.jsx("span",{className:`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${uD(e.source)}`,children:e.source}),s.jsx("span",{className:"s-atop-agent-id",children:e.refId.slice(0,8)})]})},{key:"project",label:"project",cls:"s-atop-col-project",kind:"text",sortable:!1,defaultWidth:200,minWidth:96,maxWidth:360,render:e=>s.jsx("span",{title:e.cwd??e.project,children:e.project})},{key:"updated",label:"updated",cls:"s-atop-col-last",kind:"time",sortable:!1,defaultWidth:86,minWidth:64,render:e=>s.jsx("span",{title:zce(e.mtimeMs),children:Lce(Math.max(e.mtimeMs,e.lastEvent?.ts??0),Date.now())})},{key:"size",label:"size",cls:"s-atop-col-runtime",kind:"number",sortable:!1,defaultWidth:80,minWidth:64,render:e=>Dce(e.size)},{key:"path",label:"path",kind:"text",sortable:!1,defaultWidth:360,minWidth:160,maxWidth:800,render:e=>s.jsx("span",{title:e.transcriptPath,children:e.cwd??e.transcriptPath})}];function zT(e){const t=e?.trim();if(!t)return null;const n=cD(t);return n.endsWith(".jsonl")?n.slice(0,-6):n}function cD(e){const t=e.replace(/[\\/]+$/,"");return t.split(/[\\/]/).filter(Boolean).at(-1)??t}function Pce(e){const n=e.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n.pop(),n.at(-1)??""}function uD(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function Dce(e){if(!Number.isFinite(e)||e<0)return"-";if(e<1024)return`${e} B`;const t=e/1024;if(t<1024)return`${t.toFixed(t>=10?0:1)} KiB`;const n=t/1024;return`${n.toFixed(n>=10?0:1)} MiB`}function Lce(e,t){if(!e)return"-";const n=Math.max(0,Math.round((t-e)/1e3));return n<2?"now":n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function zce(e){return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e))}function Bce(e,t){return t?[e.refId,e.sessionId??"",e.source,e.project,e.cwd??"",e.transcriptPath,e.lastEvent?.summary??"",e.process?.command??""].join(" ").toLowerCase().includes(t.toLowerCase()):!0}function BT(e){return`${e.source}\0${e.cwd??""}`}function Uce(e){return`${e.source}\0${e.cwd??""}`}function Fce(e,t,n){if(!e?.transcripts?.length)return[];const a=new Map;for(const o of t){const c=a.get(o.sessionId);(!c||o.ts>c.ts)&&a.set(o.sessionId,o)}const r=new Map;for(const o of e.processes){if(!o.cwd)continue;const c=r.get(BT(o));(!c||o.pid<c.pid)&&r.set(BT(o),o)}return e.transcripts.map(o=>{const c=zT(o.sessionId)??zT(o.transcriptPath);if(!c)return null;const u=o.sessionId?a.get(o.sessionId)??null:null,h=r.get(Uce(o))??null,f=Math.max(o.mtimeMs,u?.ts??0),g=!!h||n-f<=Oce,v=o.project?.trim()||(o.cwd?cD(o.cwd):Pce(o.transcriptPath))||"unknown";return{refId:c,source:o.source||"unknown",project:v,cwd:o.cwd,transcriptPath:o.transcriptPath,sessionId:o.sessionId,mtimeMs:o.mtimeMs,size:o.size,status:g?"run":"idle",statusLabel:g?"active":"idle",lastEvent:u,process:h}}).filter(o=>o!==null).sort((o,c)=>{const u=Math.max(o.mtimeMs,o.lastEvent?.ts??0);return Math.max(c.mtimeMs,c.lastEvent?.ts??0)-u||o.project.localeCompare(c.project)})}function Vce({navigate:e}){const{route:t}=qe(),[n,a]=m.useState(null),[r,o]=m.useState([]),[c,u]=m.useState(""),[h,f]=m.useState("all"),[g,v]=m.useState(0),[y,x]=m.useState(null),[w,C]=m.useState(Date.now()),T=m.useRef(null),E=m.useCallback(async()=>{x(null);try{a(await me("/api/tail/discover"))}catch(I){x(I instanceof Error?I.message:String(I))}},[]);m.useEffect(()=>{E();const I=setInterval(()=>{E()},Ice);return()=>clearInterval(I)},[E]),m.useEffect(()=>{let I=!1;return(async()=>{try{const U=await me(`/api/tail/recent?limit=${_ce}`);I||o(U.events??[])}catch{}})(),()=>{I=!0}},[]),nf(I=>{o(U=>U.length>=LT?[...U.slice(U.length-LT+1),I]:[...U,I])}),m.useEffect(()=>{const I=setInterval(()=>C(Date.now()),15e3);return()=>clearInterval(I)},[]);const S=m.useMemo(()=>Fce(n,r,w),[n,r,w]),k=m.useMemo(()=>[...new Set(S.map(I=>I.source))].sort(),[S]),N=m.useMemo(()=>S.filter(I=>(h==="all"||I.source===h)&&Bce(I,c.trim())),[S,h,c]);m.useEffect(()=>{g>=N.length&&v(Math.max(0,N.length-1))},[N.length,g]);const A=m.useCallback(I=>{I&&kt(e,{view:"sessions",sessionId:I.refId},{returnTo:t})},[e,t]);m.useEffect(()=>{const I=U=>{const D=U.target,V=D instanceof HTMLInputElement||D instanceof HTMLTextAreaElement||(D?.isContentEditable??!1);if(U.key==="/"&&!V){U.preventDefault(),T.current?.focus();return}if(V){U.key==="Escape"&&D===T.current&&(u(""),T.current?.blur());return}if(U.key==="ArrowDown"||U.key==="j"){U.preventDefault(),v(Z=>N.length===0?0:Math.min(N.length-1,Z+1));return}if(U.key==="ArrowUp"||U.key==="k"){U.preventDefault(),v(Z=>Math.max(0,Z-1));return}(U.key==="Enter"||U.key==="o")&&(U.preventDefault(),A(N[g]))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[N,g,A]);const R=S.filter(I=>I.status==="run").length,_=n?.totals.transcripts??n?.transcripts?.length??0,P=y?[]:N,$=m.useCallback(I=>`${I.source}:${I.transcriptPath}`,[]),H=m.useMemo(()=>new Map(N.map((I,U)=>[$(I),U])),[N,$]);return s.jsxs("div",{className:"s-atop",children:[s.jsxs("div",{className:"s-atop-summary",children:[s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsxs("div",{className:"s-atop-summary-num",children:[s.jsx("strong",{children:S.length}),s.jsxs("span",{className:"s-atop-summary-of",children:["of ",_]})]}),s.jsx("div",{className:"s-atop-summary-lbl",children:"raw sessions"})]}),s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:R})}),s.jsx("div",{className:"s-atop-summary-lbl",children:"active"})]}),s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--breakdown",children:[s.jsx("div",{className:"s-atop-summary-row",children:k.length===0?s.jsx("span",{className:"s-atop-chip s-atop-chip--mute",children:"no sources"}):k.map(I=>s.jsx("span",{className:`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${uD(I)}`,children:I},I))}),s.jsx("div",{className:"s-atop-summary-lbl",children:"sources"})]}),s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--rate",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:N.length})}),s.jsx("div",{className:"s-atop-summary-lbl",children:"visible"})]})]}),s.jsxs("div",{className:"s-atop-fbar",children:[s.jsxs("label",{className:"s-atop-search",children:[s.jsx("span",{className:"s-atop-search-prompt",children:"/"}),s.jsx("input",{ref:T,className:"s-atop-search-input",placeholder:"filter sessions",value:c,onChange:I=>u(I.target.value)}),s.jsx("kbd",{className:"s-atop-search-kbd",children:"/"})]}),s.jsx("span",{className:"s-atop-fbar-label",children:"source"}),s.jsxs("button",{type:"button",className:`s-atop-pill${h==="all"?" s-atop-pill--on":""}`,onClick:()=>f("all"),children:["all",s.jsx("span",{className:"s-atop-pill-ct",children:S.length})]}),k.map(I=>s.jsxs("button",{type:"button",className:`s-atop-pill${h===I?" s-atop-pill--on":""}`,onClick:()=>f(I),children:[I,s.jsx("span",{className:"s-atop-pill-ct",children:S.filter(U=>U.source===I).length})]},I)),s.jsx("div",{className:"s-atop-fbar-spacer"})]}),s.jsx(ug,{rows:P,columns:$ce,rowId:$,storageKey:"openscout.sessions.cols",rowBindings:I=>({onMouseEnter:()=>{const U=H.get(I);U!=null&&v(U)},onFocus:()=>{const U=H.get(I);U!=null&&v(U)}}),onRowClick:I=>A(I),rowClassName:I=>H.get($(I))===g?"s-atop-row--selected":void 0,empty:y?{title:"Discovery failed",body:y}:{title:"No raw sessions",body:c?"No sessions match the current filter.":"No transcript sessions were discovered."},density:"compact",className:"s-atop-data-table",ariaLabel:"Raw sessions"}),s.jsxs("div",{className:"s-atop-keys",children:[s.jsxs("span",{children:[s.jsx("kbd",{children:"/"}),"filter"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"j/k"}),"select"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"enter"}),"open"]}),s.jsx("span",{className:"s-atop-keys-spacer"}),s.jsxs("span",{className:"s-atop-keys-count",children:[s.jsx("strong",{children:N.length})," sessions"]})]})]})}function Wh(e){const t=e?.trim()??"",n=t.split(/[\\/]/).filter(Boolean).at(-1)??t;return n.endsWith(".jsonl")?n.slice(0,-6):n}function Hce({sessionRef:e,navigate:t}){const[n,a]=m.useState(null),[r,o]=m.useState(!0),[c,u]=m.useState(null),h=m.useRef(null),f=m.useCallback(async()=>{u(null);try{const g=await me(`/api/session-ref/${encodeURIComponent(e)}`);a(g)}catch(g){a(null),u(g instanceof Error?g.message:String(g))}finally{o(!1)}},[e]);return m.useEffect(()=>{o(!0),f()},[f]),tn(()=>{f()}),nf(g=>{const v=Wh(g.sessionId),y=Wh(e),x=n?.kind==="observe"?Wh(n.observe.sessionId??n.observe.refId):"",w=n?.kind==="observe"?Wh(n.observe.data.metadata?.session?.externalSessionId):"";v!==y&&(!x||v!==x)&&(!w||v!==w)||(h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,f()},150))}),m.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]),n?.kind==="conversation"?s.jsx(hg,{conversationId:n.conversationId,navigate:t}):n?.kind==="observe"?s.jsx(_P,{data:n.observe.data,agentId:n.observe.agentId??n.session?.agentId??void 0,sessionId:n.observe.sessionId??n.observe.refId}):r?s.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:s.jsx("section",{className:"s-thread-overview",children:s.jsxs("div",{className:"s-thread-overview-copy",children:[s.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[s.jsx("h2",{className:"s-page-title",children:"Session"}),s.jsx("span",{className:"s-meta s-tabular",children:e.slice(0,8)})]}),s.jsxs("p",{className:"s-thread-overview-summary s-session-ref-loading",children:[s.jsx("span",{className:"s-session-ref-loading-dot"}),s.jsx("span",{className:"s-session-ref-loading-dot"}),s.jsx("span",{className:"s-session-ref-loading-dot"}),"Resolving session reference"]})]})})}):s.jsx("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:s.jsx("section",{className:"s-thread-overview",children:s.jsxs("div",{className:"s-thread-overview-copy",children:[s.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[s.jsx("h2",{className:"s-page-title",children:"Session not found"}),s.jsx("span",{className:"s-meta s-tabular",children:e.slice(0,8)})]}),s.jsx("p",{className:"s-thread-overview-summary",children:"This session may have ended or the archive is not available on this machine."}),c&&s.jsx("p",{className:"s-session-ref-error-detail",children:c}),s.jsx("div",{className:"s-session-ref-nav-hint",children:s.jsx(Ga,{slot:"sessions",fallback:{view:"sessions"},navigate:t})})]})})})}var _o=(e=>(e[e.Border=-1]="Border",e[e.Data=0]="Data",e[e.Function=1]="Function",e[e.Position=2]="Position",e[e.Timing=3]="Timing",e[e.Alignment=4]="Alignment",e))(_o||{});const qce=[0,1],dD=[1,0],fD=[2,3],hD=[3,2],Wce={L:qce,M:dD,Q:fD,H:hD},Gce=/^\d*$/,Zce=/^[A-Z0-9 $%*+./:-]*$/,Rx="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",hj=1,mj=40,UT=3,Kce=3,Gh=40,Yce=10,mD=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],pD=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class Xce{constructor(t,n,a,r){if(this.version=t,this.ecc=n,t<hj||t>mj)throw new RangeError("Version value out of range");if(r<-1||r>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const o=Array.from({length:this.size}).fill(!1);for(let u=0;u<this.size;u++)this.modules.push(o.slice()),this.types.push(o.map(()=>0));this.drawFunctionPatterns();const c=this.addEccAndInterleave(a);if(this.drawCodewords(c),r===-1){let u=1e9;for(let h=0;h<8;h++){this.applyMask(h),this.drawFormatBits(h);const f=this.getPenaltyScore();f<u&&(r=h,u=f),this.applyMask(h)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(t,n){return t>=0&&t<this.size&&n>=0&&n<this.size&&this.modules[n][t]}drawFunctionPatterns(){for(let a=0;a<this.size;a++)this.setFunctionModule(6,a,a%2===0,_o.Timing),this.setFunctionModule(a,6,a%2===0,_o.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),n=t.length;for(let a=0;a<n;a++)for(let r=0;r<n;r++)a===0&&r===0||a===0&&r===n-1||a===n-1&&r===0||this.drawAlignmentPattern(t[a],t[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let a=n;for(let o=0;o<10;o++)a=a<<1^(a>>>9)*1335;const r=(n<<10|a)^21522;for(let o=0;o<=5;o++)this.setFunctionModule(8,o,Fr(r,o));this.setFunctionModule(8,7,Fr(r,6)),this.setFunctionModule(8,8,Fr(r,7)),this.setFunctionModule(7,8,Fr(r,8));for(let o=9;o<15;o++)this.setFunctionModule(14-o,8,Fr(r,o));for(let o=0;o<8;o++)this.setFunctionModule(this.size-1-o,8,Fr(r,o));for(let o=8;o<15;o++)this.setFunctionModule(8,this.size-15+o,Fr(r,o));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let a=0;a<12;a++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let a=0;a<18;a++){const r=Fr(n,a),o=this.size-11+a%3,c=Math.floor(a/3);this.setFunctionModule(o,c,r),this.setFunctionModule(c,o,r)}}drawFinderPattern(t,n){for(let a=-4;a<=4;a++)for(let r=-4;r<=4;r++){const o=Math.max(Math.abs(r),Math.abs(a)),c=t+r,u=n+a;c>=0&&c<this.size&&u>=0&&u<this.size&&this.setFunctionModule(c,u,o!==2&&o!==4,_o.Position)}}drawAlignmentPattern(t,n){for(let a=-2;a<=2;a++)for(let r=-2;r<=2;r++)this.setFunctionModule(t+r,n+a,Math.max(Math.abs(r),Math.abs(a))!==1,_o.Alignment)}setFunctionModule(t,n,a,r=_o.Function){this.modules[n][t]=a,this.types[n][t]=r}addEccAndInterleave(t){const n=this.version,a=this.ecc;if(t.length!==Om(n,a))throw new RangeError("Invalid argument");const r=pD[a[0]][n],o=mD[a[0]][n],c=Math.floor(u0(n)/8),u=r-c%r,h=Math.floor(c/r),f=[],g=iue(o);for(let y=0,x=0;y<r;y++){const w=t.slice(x,x+h-o+(y<u?0:1));x+=w.length;const C=oue(w,g);y<u&&w.push(0),f.push(w.concat(C))}const v=[];for(let y=0;y<f[0].length;y++)f.forEach((x,w)=>{(y!==h-o||w>=u)&&v.push(x[y])});return v}drawCodewords(t){if(t.length!==Math.floor(u0(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let a=this.size-1;a>=1;a-=2){a===6&&(a=5);for(let r=0;r<this.size;r++)for(let o=0;o<2;o++){const c=a-o,h=(a+1&2)===0?this.size-1-r:r;!this.types[h][c]&&n<t.length*8&&(this.modules[h][c]=Fr(t[n>>>3],7-(n&7)),n++)}}}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let a=0;a<this.size;a++){let r;switch(t){case 0:r=(a+n)%2===0;break;case 1:r=n%2===0;break;case 2:r=a%3===0;break;case 3:r=(a+n)%3===0;break;case 4:r=(Math.floor(a/3)+Math.floor(n/2))%2===0;break;case 5:r=a*n%2+a*n%3===0;break;case 6:r=(a*n%2+a*n%3)%2===0;break;case 7:r=((a+n)%2+a*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][a]&&r&&(this.modules[n][a]=!this.modules[n][a])}}getPenaltyScore(){let t=0;for(let o=0;o<this.size;o++){let c=!1,u=0;const h=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[o][f]===c?(u++,u===5?t+=UT:u>5&&t++):(this.finderPenaltyAddHistory(u,h),c||(t+=this.finderPenaltyCountPatterns(h)*Gh),c=this.modules[o][f],u=1);t+=this.finderPenaltyTerminateAndCount(c,u,h)*Gh}for(let o=0;o<this.size;o++){let c=!1,u=0;const h=[0,0,0,0,0,0,0];for(let f=0;f<this.size;f++)this.modules[f][o]===c?(u++,u===5?t+=UT:u>5&&t++):(this.finderPenaltyAddHistory(u,h),c||(t+=this.finderPenaltyCountPatterns(h)*Gh),c=this.modules[f][o],u=1);t+=this.finderPenaltyTerminateAndCount(c,u,h)*Gh}for(let o=0;o<this.size-1;o++)for(let c=0;c<this.size-1;c++){const u=this.modules[o][c];u===this.modules[o][c+1]&&u===this.modules[o+1][c]&&u===this.modules[o+1][c+1]&&(t+=Kce)}let n=0;for(const o of this.modules)n=o.reduce((c,u)=>c+(u?1:0),n);const a=this.size*this.size,r=Math.ceil(Math.abs(n*20-a*10)/a)-1;return t+=r*Yce,t}getAlignmentPatternPositions(){if(this.version===1)return[];{const t=Math.floor(this.version/7)+2,n=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,a=[6];for(let r=this.size-7;a.length<t;r-=n)a.splice(1,0,r);return a}}finderPenaltyCountPatterns(t){const n=t[1],a=n>0&&t[2]===n&&t[3]===n*3&&t[4]===n&&t[5]===n;return(a&&t[0]>=n*4&&t[6]>=n?1:0)+(a&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,a){return t&&(this.finderPenaltyAddHistory(n,a),n=0),n+=this.size,this.finderPenaltyAddHistory(n,a),this.finderPenaltyCountPatterns(a)}finderPenaltyAddHistory(t,n){n[0]===0&&(t+=this.size),n.pop(),n.unshift(t)}}function Hr(e,t,n){if(t<0||t>31||e>>>t)throw new RangeError("Value out of range");for(let a=t-1;a>=0;a--)n.push(e>>>a&1)}function Fr(e,t){return(e>>>t&1)!==0}class pj{constructor(t,n,a){if(this.mode=t,this.numChars=n,this.bitData=a,n<0)throw new RangeError("Invalid argument");this.bitData=a.slice()}getData(){return this.bitData.slice()}}const Qce=[1,10,12,14],Jce=[2,9,11,13],eue=[4,8,16,16];function gD(e,t){return e[Math.floor((t+7)/17)+1]}function vD(e){const t=[];for(const n of e)Hr(n,8,t);return new pj(eue,e.length,t)}function tue(e){if(!yD(e))throw new RangeError("String contains non-numeric characters");const t=[];for(let n=0;n<e.length;){const a=Math.min(e.length-n,3);Hr(Number.parseInt(e.substring(n,n+a),10),a*3+1,t),n+=a}return new pj(Qce,e.length,t)}function nue(e){if(!xD(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");const t=[];let n;for(n=0;n+2<=e.length;n+=2){let a=Rx.indexOf(e.charAt(n))*45;a+=Rx.indexOf(e.charAt(n+1)),Hr(a,11,t)}return n<e.length&&Hr(Rx.indexOf(e.charAt(n)),6,t),new pj(Jce,e.length,t)}function sue(e){return e===""?[]:yD(e)?[tue(e)]:xD(e)?[nue(e)]:[vD(rue(e))]}function yD(e){return Gce.test(e)}function xD(e){return Zce.test(e)}function aue(e,t){let n=0;for(const a of e){const r=gD(a.mode,t);if(a.numChars>=1<<r)return Number.POSITIVE_INFINITY;n+=4+r+a.bitData.length}return n}function rue(e){e=encodeURI(e);const t=[];for(let n=0;n<e.length;n++)e.charAt(n)!=="%"?t.push(e.charCodeAt(n)):(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2);return t}function u0(e){if(e<hj||e>mj)throw new RangeError("Version number out of range");let t=(16*e+128)*e+64;if(e>=2){const n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function Om(e,t){return Math.floor(u0(e)/8)-mD[t[0]][e]*pD[t[0]][e]}function iue(e){if(e<1||e>255)throw new RangeError("Degree out of range");const t=[];for(let a=0;a<e-1;a++)t.push(0);t.push(1);let n=1;for(let a=0;a<e;a++){for(let r=0;r<t.length;r++)t[r]=d0(t[r],n),r+1<t.length&&(t[r]^=t[r+1]);n=d0(n,2)}return t}function oue(e,t){const n=t.map(a=>0);for(const a of e){const r=a^n.shift();n.push(0),t.forEach((o,c)=>n[c]^=d0(o,r))}return n}function d0(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let n=0;for(let a=7;a>=0;a--)n=n<<1^(n>>>7)*285,n^=(t>>>a&1)*e;return n}function lue(e,t,n=1,a=40,r=-1,o=!0){if(!(hj<=n&&n<=a&&a<=mj)||r<-1||r>7)throw new RangeError("Invalid value");let c,u;for(c=n;;c++){const v=Om(c,t)*8,y=aue(e,c);if(y<=v){u=y;break}if(c>=a)throw new RangeError("Data too long")}for(const v of[dD,fD,hD])o&&u<=Om(c,v)*8&&(t=v);const h=[];for(const v of e){Hr(v.mode[0],4,h),Hr(v.numChars,gD(v.mode,c),h);for(const y of v.getData())h.push(y)}const f=Om(c,t)*8;Hr(0,Math.min(4,f-h.length),h),Hr(0,(8-h.length%8)%8,h);for(let v=236;h.length<f;v^=253)Hr(v,8,h);const g=Array.from({length:Math.ceil(h.length/8)},()=>0);return h.forEach((v,y)=>g[y>>>3]|=v<<7-(y&7)),new Xce(c,t,g,r)}function cue(e,t){const{ecc:n="L",boostEcc:a=!1,minVersion:r=1,maxVersion:o=40,maskPattern:c=-1,border:u=1}=t||{},h=typeof e=="string"?sue(e):Array.isArray(e)?[vD(e)]:void 0;if(!h)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const f=lue(h,Wce[n],r,o,c,a),g=uue({version:f.version,maskPattern:f.mask,size:f.size,data:f.modules,types:f.types},u);return t?.invert&&(g.data=g.data.map(v=>v.map(y=>!y))),t?.onEncoded?.(g),g}function uue(e,t=1){if(!t)return e;const{size:n}=e,a=n+t*2;e.size=a,e.data.forEach(o=>{for(let c=0;c<t;c++)o.unshift(!1),o.push(!1)});for(let o=0;o<t;o++)e.data.unshift(Array.from({length:a},c=>!1)),e.data.push(Array.from({length:a},c=>!1));const r=_o.Border;e.types.forEach(o=>{for(let c=0;c<t;c++)o.unshift(r),o.push(r)});for(let o=0;o<t;o++)e.types.unshift(Array.from({length:a},c=>r)),e.types.push(Array.from({length:a},c=>r));return e}function FT(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function due(e,t={}){const n=cue(e,t),{pixelSize:a=10,whiteColor:r="white",blackColor:o="black"}=t,c=n.size*a,u=n.size*a;let h=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${c}">`;const f=[];for(let g=0;g<n.size;g++)for(let v=0;v<n.size;v++){const y=v*a,x=g*a;n.data[g][v]&&f.push(`M${y},${x}h${a}v${a}h-${a}z`)}return h+=`<rect fill="${FT(r)}" width="${u}" height="${c}"/>`,h+=`<path fill="${FT(o)}" d="${f.join("")}"/>`,h+="</svg>",h}function mg(e){switch(e){case"ready":case"running":case"available":case"enabled":return"sys-chip-success";case"configured":case"installed":case"working":return"sys-chip-warning";case"missing":case"offline":case"error":return"sys-chip-danger";default:return"sys-chip-neutral"}}function bD(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):"Not reported"}function fue(e){return e.length>0?e.join(", "):"No capabilities reported"}function hue({runtime:e}){return s.jsxs("div",{className:"agent-config-row",children:[s.jsxs("div",{className:"agent-config-row-main",children:[s.jsx("span",{className:"agent-config-icon",children:s.jsx(Y4,{size:14})}),s.jsxs("div",{className:"agent-config-row-copy",children:[s.jsx("div",{className:"agent-config-row-title",children:e.label}),s.jsx("div",{className:"agent-config-row-detail",children:e.description}),s.jsx("div",{className:"agent-config-row-meta",children:e.detail})]})]}),s.jsxs("div",{className:"agent-config-row-side",children:[s.jsx("span",{className:`sys-chip ${mg(e.state)}`,children:e.state}),s.jsx("span",{className:"agent-config-row-meta",children:e.binaryPath??e.loginCommand??e.source})]})]})}function mue({provider:e}){return s.jsxs("div",{className:"agent-config-row",children:[s.jsxs("div",{className:"agent-config-row-main",children:[s.jsx("span",{className:"agent-config-icon",children:s.jsx(f2,{size:14})}),s.jsxs("div",{className:"agent-config-row-copy",children:[s.jsx("div",{className:"agent-config-row-title",children:e.name}),s.jsx("div",{className:"agent-config-row-detail",children:e.protocol}),s.jsx("code",{className:"agent-config-code",children:e.baseUrl}),s.jsxs("div",{className:"agent-config-row-meta",children:["Keys: ",e.envKeys.join(", ")]}),s.jsx("div",{className:"agent-config-row-meta",children:e.note})]})]}),s.jsxs("div",{className:"agent-config-row-side",children:[s.jsx("span",{className:`sys-chip ${mg(e.status)}`,children:e.status}),s.jsx("a",{className:"agent-config-link",href:e.docsUrl,target:"_blank",rel:"noreferrer",children:"Docs"})]})]})}function pue({agent:e,selected:t,navigate:n}){return s.jsxs("button",{type:"button",className:`agent-config-row agent-config-row-button${t?" agent-config-row-selected":""}`,onClick:()=>n({view:"settings",section:"agents",agentId:e.id}),children:[s.jsxs("div",{className:"agent-config-row-main",children:[s.jsx("span",{className:"agent-config-icon",children:s.jsx(zd,{size:14})}),s.jsxs("div",{className:"agent-config-row-copy",children:[s.jsx("div",{className:"agent-config-row-title",children:e.name}),s.jsx("div",{className:"agent-config-row-detail",children:e.id}),s.jsxs("div",{className:"agent-config-row-meta",children:[e.harness??"unknown harness"," / ",e.transport??"unknown transport",e.model?` / ${e.model}`:""]})]})]}),s.jsxs("div",{className:"agent-config-row-side",children:[s.jsx("span",{className:`sys-chip ${mg(e.status)}`,children:e.status}),s.jsx("span",{className:"agent-config-row-meta",children:bD(e.projectRoot??e.cwd)})]})]})}function gue({agent:e,navigate:t}){const{route:n}=qe();return e?s.jsxs("div",{className:"sys-panel agent-config-detail-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:e.name}),s.jsx("p",{className:"sys-section-subtitle",children:e.id})]}),s.jsxs("div",{className:"sys-page-actions",children:[s.jsx("button",{type:"button",className:"s-btn",onClick:()=>t({view:"agents",agentId:e.id}),children:"Open Agent"}),s.jsx("button",{type:"button",className:"s-btn",onClick:()=>kt(t,{view:"conversation",conversationId:e.conversationId},{returnTo:n}),children:"Open DM"})]})]}),s.jsxs("div",{className:"agent-config-detail-grid",children:[s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Status"}),s.jsx("span",{className:`sys-chip ${mg(e.status)}`,children:e.status})]}),s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Harness"}),s.jsx("strong",{children:e.harness??"Not reported"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Transport"}),s.jsx("strong",{children:e.transport??"Not reported"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Model"}),s.jsx("strong",{children:e.model??"Not reported"})]}),s.jsxs("div",{className:"agent-config-detail-wide",children:[s.jsx("span",{className:"agent-config-label",children:"Project"}),s.jsx("code",{children:bD(e.projectRoot)})]}),s.jsxs("div",{className:"agent-config-detail-wide",children:[s.jsx("span",{className:"agent-config-label",children:"Capabilities"}),s.jsx("span",{children:fue(e.capabilities)})]})]})]}):s.jsxs("div",{className:"sys-panel agent-config-detail-panel",children:[s.jsx("div",{className:"sys-section-head",children:s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Agent Details"}),s.jsx("p",{className:"sys-section-subtitle",children:"Select an agent to inspect runtime, model, and tool context."})]})}),s.jsxs("div",{className:"sys-list-empty",children:[s.jsx("h3",{children:"No agent selected"}),s.jsx("p",{children:"Choose an agent from the configuration roster."})]})]})}function vue({navigate:e,selectedAgentId:t}){const[n,a]=m.useState(null),[r,o]=m.useState(!0),[c,u]=m.useState(!1),[h,f]=m.useState(null),g=m.useRef(0),v=m.useCallback(async(C="initial")=>{const T=++g.current;C==="initial"?o(!0):u(!0),f(null);try{const E=await me("/api/agent-config/snapshot");if(T!==g.current)return;a(E)}catch(E){if(T!==g.current)return;f(E instanceof Error?E.message:String(E))}finally{T===g.current&&(o(!1),u(!1))}},[]);m.useEffect(()=>{v()},[v]);const y=m.useMemo(()=>n?n.agents.find(C=>C.id===t)??n.agents[0]??null:null,[t,n]),x=n?.providers??[],w=n?[{label:"Runtimes",value:String(n.runtimes.length),detail:`${n.runtimes.filter(C=>C.state==="ready").length} ready`},{label:"BYOK",value:String(x.length),detail:`${x.filter(C=>C.status==="configured").length} configured`},{label:"Agents",value:String(n.agents.length),detail:`${n.agents.filter(C=>C.status!=="offline").length} reachable`},{label:"Broker",value:n.broker.label,detail:n.broker.nodeId??"No node id"}]:[];return s.jsxs("div",{className:"sys-surface-page sys-surface-page-wide",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Agent Configuration"}),s.jsx("p",{className:"sys-page-subtitle",children:"Runtimes, agents, project inventory, delivery bridges, and the missing tool/provider surfaces in one control plane."})]}),s.jsxs("div",{className:"sys-page-actions",children:[n&&s.jsxs("div",{className:"sys-sync-note",children:["Updated ",new Date(n.generatedAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})]}),s.jsxs("button",{type:"button",className:"s-btn",disabled:r||c,onClick:()=>{v("manual")},children:[s.jsx(m2,{size:13}),c?"Refreshing...":"Refresh"]})]})]}),n&&s.jsx("div",{className:"sys-stat-grid",children:w.map(C=>s.jsxs("div",{className:"sys-stat-card",children:[s.jsx("span",{className:"sys-stat-label",children:C.label}),s.jsx("strong",{className:"sys-stat-value",children:C.value}),s.jsx("span",{className:"sys-stat-detail",children:C.detail})]},C.label))}),h&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Configuration snapshot failed."}),s.jsx("span",{children:h})]}),r&&!n&&s.jsx(sa,{title:"Loading configuration",body:"Reading Scout settings, runtime readiness, broker agents, and project inventory."}),n&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"agent-config-layout",children:[s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Runtimes"}),s.jsx("p",{className:"sys-section-subtitle",children:"Harness readiness replaces provider auth for the current local-first posture."})]}),s.jsx($p,{size:15})]}),s.jsx("div",{className:"agent-config-list",children:n.runtimes.map(C=>s.jsx(hue,{runtime:C},C.id))})]}),s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"BYOK Providers"}),s.jsx("p",{className:"sys-section-subtitle",children:"OpenAI-compatible vendors OpenScout can discover from local environment configuration."})]}),s.jsx(f2,{size:15})]}),s.jsx("div",{className:"agent-config-list",children:x.map(C=>s.jsx(mue,{provider:C},C.id))})]})]}),s.jsxs("div",{className:"agent-config-layout agent-config-layout-primary",children:[s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Agents"}),s.jsx("p",{className:"sys-section-subtitle",children:"Broker-visible endpoints with runtime, model, and source state."})]}),s.jsx(zd,{size:15})]}),s.jsx("div",{className:"agent-config-list agent-config-list-scroll",children:n.agents.length===0?s.jsxs("div",{className:"sys-list-empty",children:[s.jsx("h3",{children:"No agents registered"}),s.jsx("p",{children:"Run setup or start a local agent to populate this roster."})]}):n.agents.map(C=>s.jsx(pue,{agent:C,selected:C.id===y?.id,navigate:e},C.id))})]}),s.jsx(gue,{agent:y,navigate:e})]}),s.jsxs("div",{className:"agent-config-layout",children:[s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Tools & Context"}),s.jsx("p",{className:"sys-section-subtitle",children:"The next model boundary to make first-class."})]}),s.jsx(f3,{size:15})]}),s.jsx("p",{className:"agent-config-copy",children:n.toolContext.note}),s.jsxs("div",{className:"agent-config-chip-row",children:[s.jsxs("span",{className:"sys-chip sys-chip-neutral",children:[n.toolContext.mcpServerCount," MCP servers"]}),s.jsx("span",{className:"sys-chip sys-chip-warning",children:"loadouts pending"})]})]}),s.jsxs("div",{className:"sys-panel",children:[s.jsxs("div",{className:"sys-section-head",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Broker & Delivery"}),s.jsx("p",{className:"sys-section-subtitle",children:"Control-plane state and bridges that route attention back to you."})]}),s.jsx(Yz,{size:15})]}),s.jsxs("div",{className:"agent-config-detail-grid",children:[s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Broker"}),s.jsx("span",{className:`sys-chip ${n.broker.healthy?"sys-chip-success":"sys-chip-danger"}`,children:n.broker.label})]}),s.jsxs("div",{children:[s.jsx("span",{className:"agent-config-label",children:"Messages"}),s.jsx("strong",{children:n.broker.messageCount})]}),n.integrations.map(C=>s.jsxs("div",{className:"agent-config-detail-wide",children:[s.jsx("span",{className:"agent-config-label",children:C.name}),s.jsx("span",{children:C.detail})]},C.id))]})]})]}),s.jsxs("div",{className:"sys-panel",children:[s.jsx("div",{className:"sys-section-head",children:s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Known Missing Pieces"}),s.jsx("p",{className:"sys-section-subtitle",children:"The configuration model is now visible; these are the next root-cause surfaces to build."})]})}),s.jsx("div",{className:"agent-config-gap-list",children:n.gaps.map(C=>s.jsx("span",{children:C},C))})]})]})]})}function yue(e){return e?e.replace(/^wss?:\/\//,"").replace(/:\d+$/,""):null}function VT(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-6)}`:null}function xue(e,t){if(!e)return null;const n=Math.max(0,Math.floor((e-t)/1e3));if(n===0)return null;if(n<60)return`${n}s`;const a=Math.floor(n/60),r=n%60;return r>0?`${a}m ${r}s`:`${a}m`}function HT({value:e}){const[t,n]=m.useState(!1),a=m.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},[e]);return s.jsx("button",{type:"button",className:"sys-copy-btn",onClick:a,title:"Copy",children:t?s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}):s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})}function bue({navigate:e,section:t,agentId:n}){return t==="agents"?s.jsx(vue,{navigate:e,selectedAgentId:n}):s.jsx(wue,{})}function wue(){const[e,t]=m.useState(null),[n,a]=m.useState(""),[r,o]=m.useState(""),[c,u]=m.useState(!0),[h,f]=m.useState(!1),[g,v]=m.useState(!1),[y,x]=m.useState(null),[w,C]=m.useState(null),[T,E]=m.useState(null),[S,k]=m.useState(null),[N,A]=m.useState(()=>Date.now()),[R,_]=m.useState(null),P=m.useRef(null),$=m.useRef(0),H=m.useRef(null);m.useEffect(()=>{P.current=e},[e]),m.useEffect(()=>{H.current=y},[y]);const I=m.useCallback(async(G="initial")=>{if(G==="background"&&H.current)return;const re=++$.current;!(P.current!==null)&&G!=="background"?(u(!0),C(null)):f(!0);try{const ae=await me(G==="manual"?"/api/pairing-state/refresh":"/api/pairing-state");if(re!==$.current)return;t(ae),C(null),k(Date.now())}catch(ae){if(re!==$.current)return;C(ae instanceof Error?ae.message:String(ae))}finally{re===$.current&&(u(!1),f(!1))}},[]),U=m.useCallback(async()=>{try{const G=await me("/api/user");o(G.name),a(G.name),E(null)}catch(G){E(G instanceof Error?G.message:String(G))}},[]),D=m.useRef(!1);m.useEffect(()=>{I("initial"),U()},[I,U]),m.useEffect(()=>{const G=setInterval(()=>{I("background")},1e4);return()=>clearInterval(G)},[I]),m.useEffect(()=>{if(!e?.pairing?.expiresAt)return;A(Date.now());const G=setInterval(()=>{A(Date.now())},1e3);return()=>clearInterval(G)},[e?.pairing?.expiresAt]);const V=m.useCallback(async()=>{v(!0),E(null);try{const G=await me("/api/user",{method:"POST",body:JSON.stringify({name:n})});o(G.name),a(G.name)}catch(G){E(G instanceof Error?G.message:String(G))}finally{v(!1)}},[n]),Z=m.useCallback(async G=>{const re=++$.current;x(G),C(null);try{const Q=await me("/api/pairing/control",{method:"POST",body:JSON.stringify({action:G})});if(re!==$.current)return;t(Q),k(Date.now())}catch(Q){if(re!==$.current)return;C(Q instanceof Error?Q.message:String(Q))}finally{re===$.current&&x(null)}},[]);m.useEffect(()=>{!e||e.isRunning||D.current||(D.current=!0,Z("start"))},[e,Z]);const O=m.useCallback(async G=>{_(G);try{await me(`/api/pairing/peers/${encodeURIComponent(G)}`,{method:"DELETE"}),I("manual")}catch{}finally{_(null)}},[I]),z=m.useMemo(()=>{const G=e?.pairing?.qrValue?.trim();return G?due(G,{border:2,ecc:"M",pixelSize:8}):null},[e?.pairing?.qrValue]),B=yue(e?.pairing?.relay??e?.relay??null),X=xue(e?.pairing?.expiresAt,N),L=(e?.trustedPeers.find(G=>G.fingerprint===e.connectedPeerFingerprint)??null)?.name??VT(e?.connectedPeerFingerprint??null),q=sse(e),K=n.trim()!==r,ee=!c&&!e&&!!w;return s.jsxs("div",{className:"sys-surface-page sys-settings-page",children:[s.jsxs("div",{className:"sys-page-head",children:[s.jsxs("div",{className:"sys-page-title-group",children:[s.jsx("h2",{className:"sys-page-title",children:"Settings"}),s.jsx("p",{className:"sys-page-subtitle",children:"Identity, pairing, and trusted devices."})]}),s.jsxs("div",{className:"sys-page-actions",children:[e&&s.jsx(Wr,{tone:q,children:e.statusLabel}),s.jsx("div",{className:"sys-sync-note",children:c?"Loading...":w&&e?`Snapshot from ${S?Ae(S):"earlier"}`:S?`Updated ${Ae(S)}`:""}),s.jsx("button",{type:"button",className:"s-btn",disabled:c||h||!!y,onClick:()=>{I("manual")},children:h?"Refreshing...":"Refresh"})]})]}),w&&e&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Refresh failed."}),s.jsx("span",{children:w})]}),T&&s.jsxs("div",{className:"sys-banner sys-banner-warning",children:[s.jsx("strong",{children:"Identity error."}),s.jsx("span",{children:T})]}),c&&!e&&s.jsx(sa,{title:"Loading settings",body:"Checking relay status and trusted peers."}),ee&&s.jsx(sa,{className:"sys-state-card-error",title:"Pairing unavailable",body:w,action:s.jsx("button",{type:"button",className:"s-btn",onClick:()=>{I("manual")},children:"Try again"})}),s.jsxs("div",{className:"sys-settings-hero",children:[s.jsx("div",{className:"sys-settings-qr-col",children:z?s.jsxs("div",{className:"sys-settings-qr-frame",children:[s.jsx("div",{className:"s-qr",dangerouslySetInnerHTML:{__html:z}}),X&&s.jsxs("span",{className:"sys-settings-qr-expires",children:["Expires in ",X]})]}):s.jsx("div",{className:"sys-settings-qr-empty",children:s.jsx("span",{className:"sys-settings-qr-empty-label",children:"Generating QR..."})})}),s.jsxs("div",{className:"sys-settings-info-col",children:[s.jsxs("div",{className:"sys-input-row",children:[s.jsx("input",{className:"sys-input",type:"text",placeholder:"Your name",value:n,onChange:G=>a(G.target.value),onKeyDown:G=>{G.key==="Enter"&&K&&!g&&V()}}),s.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!K||g,onClick:()=>{V()},children:g?"Saving...":"Save"})]}),s.jsxs("div",{className:"sys-settings-kv-list",children:[e?.identityFingerprint&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Fingerprint"}),s.jsxs("span",{className:"sys-settings-kv-value",children:[s.jsx("code",{children:e.identityFingerprint}),s.jsx(HT,{value:e.identityFingerprint})]})]}),B&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Relay"}),s.jsxs("span",{className:"sys-settings-kv-value",children:[s.jsx("code",{children:B}),s.jsx(HT,{value:B})]})]}),e?.statusDetail&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Status"}),s.jsx("span",{className:"sys-settings-kv-value sys-settings-kv-nowrap",children:e.statusDetail})]}),L&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Connected"}),s.jsx("span",{className:"sys-settings-kv-value",children:L})]}),e?.secure&&s.jsxs("div",{className:"sys-settings-kv",children:[s.jsx("span",{className:"sys-settings-kv-label",children:"Security"}),s.jsx("span",{className:"sys-settings-kv-value",children:s.jsx(Wr,{tone:"success",children:"Noise XX"})})]})]}),e&&s.jsx("div",{className:"sys-inline-actions sys-settings-controls",children:e.isRunning?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"s-btn",disabled:!!y,onClick:()=>{Z("restart")},children:y==="restart"?"Restarting...":"Restart"}),s.jsx("button",{type:"button",className:"s-btn",disabled:!!y,onClick:()=>{Z("stop")},children:y==="stop"?"Stopping...":"Stop"})]}):s.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!!y,onClick:()=>{Z("start")},children:y==="start"?"Starting...":"Start pairing"})})]})]}),e&&s.jsxs("section",{className:"sys-settings-peers",children:[s.jsx("div",{className:"sys-section-head",children:s.jsxs("div",{children:[s.jsx("h3",{className:"sys-section-title",children:"Trusted peers"}),s.jsxs("p",{className:"sys-section-subtitle",children:[e.trustedPeers.length," device",e.trustedPeers.length!==1?"s":""," paired with this broker."]})]})}),e.trustedPeers.length===0?s.jsxs("div",{className:"sys-list-empty",children:[s.jsx("h3",{children:"No trusted peers"}),s.jsx("p",{children:"Devices appear here after completing pairing."})]}):s.jsxs("table",{className:"sys-peers-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Device"}),s.jsx("th",{children:"Fingerprint"}),s.jsx("th",{children:"Paired"}),s.jsx("th",{children:"Last seen"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.trustedPeers.map(G=>{const re=G.fingerprint===e.connectedPeerFingerprint;return s.jsxs("tr",{className:re?"sys-peers-row-connected":"",children:[s.jsx("td",{children:s.jsxs("span",{className:"sys-peers-name",children:[G.name??VT(G.fingerprint)??"Peer",re&&s.jsx(Wr,{tone:"success",className:"sys-peers-badge",children:"Connected"})]})}),s.jsx("td",{children:s.jsx("code",{className:"sys-peers-fp",children:G.fingerprint})}),s.jsx("td",{children:G.pairedAtLabel??"—"}),s.jsx("td",{children:G.lastSeenLabel??"—"}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"sys-peers-remove",disabled:R===G.fingerprint,onClick:()=>{O(G.fingerprint)},title:"Remove peer",children:R===G.fingerprint?"...":"Remove"})})]},G.fingerprint)})})]})]})]})}let yd={hover:null,content:null};const f0=new Set;function jue(){for(const e of f0)e()}function Nue(e){return f0.add(e),()=>{f0.delete(e)}}function qT(){return yd}function kue(){return m.useSyncExternalStore(Nue,qT,qT)}function WT(e){yd.hover!==e&&(yd={...yd,hover:e},jue())}function Gr(e){return!e||!e.route&&!e.label?{onPointerEnter:void 0,onPointerLeave:void 0}:{onPointerEnter:()=>WT(e),onPointerLeave:()=>{yd.hover===e&&WT(null)}}}const Sue=220;function Cue(){const e=kue(),t=!!(e.hover||e.content),[n,a]=m.useState(t?{hover:e.hover,content:e.content}:null),[r,o]=m.useState(t?"enter":"hidden"),c=m.useRef(null);if(m.useEffect(()=>{if(t){c.current&&(clearTimeout(c.current),c.current=null),a({hover:e.hover,content:e.content}),o(g=>g==="show"?"show":"enter");const f=requestAnimationFrame(()=>o("show"));return()=>cancelAnimationFrame(f)}return o("leave"),c.current=setTimeout(()=>{o("hidden"),a(null),c.current=null},Sue),()=>{c.current&&(clearTimeout(c.current),c.current=null)}},[t,e.hover,e.content]),r==="hidden"||!n)return null;const u=n.hover?.label??n.hover?.route??null,h=n.hover?.label&&n.hover?.route?n.hover.route:null;return s.jsxs("div",{className:`s-page-status s-page-status--${r}`,role:"status","aria-live":"polite",children:[s.jsx("div",{className:"s-page-status-left",children:u&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-page-status-arrow","aria-hidden":!0,children:"→"}),s.jsx("span",{className:"s-page-status-target",children:u}),h&&s.jsx("span",{className:"s-page-status-route",children:h})]})}),s.jsx("div",{className:"s-page-status-right",children:n.content&&s.jsx("span",{className:"s-page-status-content",children:n.content})})]})}const Np=[{label:"15m",value:15*6e4},{label:"1h",value:60*6e4},{label:"24h",value:1440*6e4}];let Dt={activityFilter:"all",sourceFilter:"all",recentWindowMs:Np[1].value,groupMode:"activity",query:"",focusedId:null,canvasFocusRequest:null,visibleAgents:[],selectedIds:[]};const h0=new Set;let GT=0;function Ya(){for(const e of h0)e()}function wD(e){Dt.activityFilter!==e&&(Dt={...Dt,activityFilter:e},Ya())}function jD(e){Dt.sourceFilter!==e&&(Dt={...Dt,sourceFilter:e},Ya())}function ND(e){Dt.recentWindowMs!==e&&(Dt={...Dt,recentWindowMs:e},Ya())}function Eue(e){Dt.groupMode!==e&&(Dt={...Dt,groupMode:e},Ya())}function kp(e){Dt.query!==e&&(Dt={...Dt,query:e},Ya())}function Aue(e){Dt.focusedId!==e&&(Dt={...Dt,focusedId:e},Ya())}function Tue(e){GT+=1,Dt={...Dt,canvasFocusRequest:{id:e,serial:GT}},Ya()}function Mue(e){Dt.canvasFocusRequest?.serial===e&&(Dt={...Dt,canvasFocusRequest:null},Ya())}function Rue(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const a=e[n],r=t[n];if(a.id!==r.id||a.state!==r.state||a.updatedAt!==r.updatedAt||a.activity!==r.activity||a.lastActiveAt!==r.lastActiveAt)return!1}return!0}function Iue(e){Rue(Dt.visibleAgents,e)||(Dt={...Dt,visibleAgents:e},Ya())}function Xl(e){const t=Dt.selectedIds.includes(e);Dt={...Dt,selectedIds:t?Dt.selectedIds.filter(n=>n!==e):[...Dt.selectedIds,e]},Ya()}function $m(){Dt.selectedIds.length!==0&&(Dt={...Dt,selectedIds:[]},Ya())}function _ue(e){return h0.add(e),()=>{h0.delete(e)}}function Oue(){return Dt}function kD(){return m.useSyncExternalStore(_ue,Oue)}function ZT(e,t){if(!t)return!0;const n=t.trim().toLowerCase();return n?[e.name,e.handle,e.project,e.branch,e.harness,e.id].filter(r=>!!r).map(r=>r.toLowerCase()).some(r=>r.includes(n)):!0}const $ue=2500,Pue=1e4;function Due(e){const[t,n]=m.useState({}),a=m.useRef(!0),r=m.useRef(!1),o=m.useRef(!1),c=e.map(f=>f.id.trim()).filter(f=>f.length>0).join(","),u=e.some(f=>Je(f.state)==="working")?$ue:Pue,h=m.useCallback(async()=>{if(e.length===0){n({});return}if(r.current){o.current=!0;return}r.current=!0;try{const f=c?`?ids=${encodeURIComponent(c)}`:"",g=await me(`/api/observe/agents${f}`);if(!a.current)return;n(v=>{const y={};for(const x of e)y[x.id]=v[x.id];for(const x of g){const{agentId:w,...C}=x;y[w]=C}return y})}finally{r.current=!1,o.current&&(o.current=!1,h())}},[c,e]);return m.useEffect(()=>{if(a.current=!0,e.length===0)return n({}),()=>{a.current=!1};h();const f=setInterval(()=>{h()},u);return()=>{a.current=!1,clearInterval(f)}},[e.length,h,u]),t}function Lue(e){switch(e.kind){case"tool":return`${e.tool??"tool"} ${e.arg??""}`.trim();case"think":return e.text.slice(0,120);case"ask":return`ask: ${e.text}`.slice(0,120);case"message":return e.text.slice(0,100);case"note":return e.text.slice(0,100);case"system":case"boot":return e.text.slice(0,100)}}const Po=420,Ec=320,Vl=20,zue=48,Bue=36,KT=28,Zh=40,YT=72,Uue=.35,Fue=1.15,Vue=244,Hue=160,que=6e4;function Wue(e,t,n){return Math.max(t,Math.min(n,e))}const SD="scout_mc_vp";function Gue(e){try{localStorage.setItem(SD,JSON.stringify(e))}catch{}}function Zue(){try{const e=localStorage.getItem(SD);if(!e)return null;const t=JSON.parse(e);if(typeof t?.zoom=="number"&&typeof t?.pan?.x=="number"&&typeof t?.pan?.y=="number")return t}catch{}return null}function Kue(e,t,n){const a=Que(e,t,n);if(a.length===0)return{groups:[],canvasW:0,canvasH:0};const r=Math.max(1,Math.round(Math.sqrt(a.length*1.2))),o=[],c=new Array(r).fill(Zh),u=Array.from({length:r},(g,v)=>Zh+v*(Po*2+Vl+zue));for(const g of a){const v=c.indexOf(Math.min(...c)),y=u[v],x=c[v],w=Math.min(2,g.subjects.length),C=Math.ceil(g.subjects.length/w),T=w*Po+(w-1)*Vl,E=KT+C*Ec+(C-1)*Vl,S=g.subjects.map((k,N)=>({agentId:k.id,x:y+N%w*(Po+Vl),y:x+KT+Math.floor(N/w)*(Ec+Vl)}));o.push({label:g.label,x:y,y:x,w:T,h:E,tiles:S}),c[v]=x+E+Bue}const h=Math.max(...u.map(g=>g+Po*2+Vl))+Zh,f=Math.max(...c)+Zh;return{groups:o,canvasW:h,canvasH:f}}function Pd(e){switch(e){case"active":return 0;case"recent":return 1;default:return 2}}function Yue(e,t,n){return t==="workspace"?e.group:e.activity==="active"?"Active now":e.activity==="recent"?`Recent ${n}`:e.group}function Xue(e,t){const n=Pd(e.activity),a=Pd(t.activity);return n!==a?n-a:e.lastActiveAt!==t.lastActiveAt?t.lastActiveAt-e.lastActiveAt:e.stateRank!==t.stateRank?e.stateRank-t.stateRank:e.name.localeCompare(t.name)}function XT(e,t){if(t==="activity"){if(e.label==="Active now")return 0;if(e.label.startsWith("Recent "))return 1}return Math.min(...e.subjects.map(n=>Pd(n.activity)))}function Que(e,t,n){const a=[...e].sort((c,u)=>Xue(c,u)),r=new Map;for(const c of a){const u=Yue(c,t,n);r.has(u)||r.set(u,[]),r.get(u).push(c)}const o=[];for(const[c,u]of r)o.push({label:c,subjects:u});return o.sort((c,u)=>{const h=XT(c,t)-XT(u,t);if(h!==0)return h;const f=Math.max(...u.subjects.map(g=>g.lastActiveAt))-Math.max(...c.subjects.map(g=>g.lastActiveAt));return f!==0?f:u.subjects.length!==c.subjects.length?u.subjects.length-c.subjects.length:c.label.localeCompare(u.label)}),o}function Jue(e,t){const n={working:0,available:1,offline:2},a=Je(e.state),r=t?.current?"active":t?.recent?"recent":"idle";return{id:e.id,name:e.name,group:e.project??"unassigned",stateRank:n[a]??1,activity:r,lastActiveAt:t?.lastActiveAt??e.updatedAt??0}}function ede(e){return{id:e.id,name:e.agent.name,group:`native ${e.transcript.source}`,stateRank:e.current?0:1,activity:e.current?"active":e.recent?"recent":"idle",lastActiveAt:e.lastActiveAt}}function tde(e){const t=new Map;for(const n of e)n.agentId&&t.set(n.agentId,(t.get(n.agentId)??0)+1);return t}function nde(e){const t=new Map;for(const n of e)!n.agentId||!n.lastMessageAt||t.set(n.agentId,Math.max(t.get(n.agentId)??0,n.lastMessageAt));return t}function sde(e){const t=e?.data.metadata?.session?.sessionStart;if(typeof t!="number"||!Number.isFinite(t))return 0;const n=Math.max(0,...(e?.data.events??[]).map(a=>a.t));return n>0?t+n*1e3:t}function ade(e,t,n){return Math.max(n.get(e.id)??0,sde(t),Je(e.state)==="working"?e.updatedAt??0:0)}function rde(e,t){return Je(e.state)==="working"||t?.data.live===!0||(t?.data.events??[]).some(n=>n.live===!0)}function m0(e){return e?.current?"active":e?.recent?"recent":"idle"}function gj(e,t){const n=Pd(m0(e))-Pd(m0(t));return n!==0?n:(t?.lastActiveAt??0)-(e?.lastActiveAt??0)}function ide(e,t,n){const a=gj(n.get(e.id),n.get(t.id));if(a!==0)return a;const r={working:0,available:1,offline:2},o=(r[Je(e.state)]??1)-(r[Je(t.state)]??1);return o!==0?o:e.name.localeCompare(t.name)}function ode(e,t){const n=gj(e,t);return n!==0?n:e.agent.name.localeCompare(t.agent.name)}function lde(e){return e?e.replace(/\.jsonl$/u,"").slice(0,8):"session"}function cde(e){return e?`${e[0]?.toUpperCase()}${e.slice(1)}`:"Native"}function ude(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Sp(e){const t=e.sessionId?.trim()||"session";return`native:${e.source}:${t}:${ude(e.transcriptPath)}`}function dde(e){switch(e){case"assistant":return"message";case"tool":case"tool-result":return"tool";case"user":return"ask";case"system":return"system";default:return"note"}}const fde=5*6e4;function hde(e,t,n){const a=t.slice(-12),r=a.map((c,u)=>({id:c.id,t:u,kind:dde(c.kind),text:c.summary,tool:c.kind==="tool"||c.kind==="tool-result"?c.source:void 0,detail:`${c.source} · ${c.harness}`,live:n&&u===a.length-1}));return{events:r.length>0?r:Date.now()-e.mtimeMs<=fde?[{id:`${Sp(e)}:discovered`,t:0,kind:"system",text:`Native ${e.source} transcript discovered.`,detail:e.cwd??e.transcriptPath}]:[],files:[],live:n,metadata:{session:{adapterType:e.source,externalSessionId:e.sessionId??void 0,threadPath:e.transcriptPath,cwd:e.cwd??void 0,originator:e.harness,source:"tail"}}}}function mde(e,t,n){return{id:Sp(e),name:`${cde(e.source)} · ${e.project}`,handle:lde(e.sessionId),agentClass:"native-session",harness:e.source,state:n?"working":"available",projectRoot:e.cwd,cwd:e.cwd,updatedAt:t,createdAt:null,transport:"tail",selector:null,wakePolicy:null,capabilities:[],project:e.project,branch:e.harness==="unattributed"?"native session":e.harness,role:"native session",model:null,harnessSessionId:e.sessionId,harnessLogPath:e.transcriptPath,conversationId:Sp(e),homeNodeId:null,homeNodeName:null,ownerId:null,ownerName:null,ownerHandle:null}}const pde={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},vj={think:"think",tool:"tool",ask:"ask",message:"msg",note:"note",system:"sys",boot:"boot"};function gde({navigate:e,agents:t}){const n=kD(),{activityFilter:a,sourceFilter:r,recentWindowMs:o,groupMode:c,query:u,focusedId:h,canvasFocusRequest:f}=n,g=wD,v=jD,y=ND,x=Eue,w=Aue,[C,T]=m.useState([]),[E,S]=m.useState(null),[k,N]=m.useState([]),[A,R]=m.useState(Date.now()),_=Due(t);nf(Y=>{N(te=>te.length>=500?[...te.slice(te.length-499),Y]:[...te,Y])}),m.useEffect(()=>{const Y=setInterval(()=>R(Date.now()),1e4);return()=>clearInterval(Y)},[]),m.useEffect(()=>{let Y=!1;const te=async()=>{try{const[Pe,We,rt]=await Promise.allSettled([me("/api/conversations"),me("/api/tail/discover"),me("/api/tail/recent?limit=500")]);if(Y)return;Pe.status==="fulfilled"?T(Pe.value):T([]),We.status==="fulfilled"&&S(We.value),rt.status==="fulfilled"&&N(rt.value.events??[])}catch{Y||(T([]),S(null))}};te();const he=setInterval(()=>{te()},3e4);return()=>{Y=!0,clearInterval(he)}},[]);const P=m.useRef(null),[$,H]=m.useState({w:0,h:0}),[I,U]=m.useState({x:0,y:0}),[D,V]=m.useState(1),[Z,O]=m.useState(!1),z=m.useRef(!1),B=m.useRef({x:0,y:0,panX:0,panY:0}),X=m.useRef(!1);m.useEffect(()=>{const Y=P.current;if(!Y)return;const te=new ResizeObserver(([he])=>{H({w:he.contentRect.width,h:he.contentRect.height})});return te.observe(Y),()=>te.disconnect()},[]);const W=m.useMemo(()=>tde(C),[C]),L=m.useMemo(()=>nde(C),[C]),q=m.useMemo(()=>{const Y=new Map;for(const te of t){const he=_[te.id],Pe=ade(te,he,L),We=rde(te,he);Y.set(te.id,{lastActiveAt:Pe,current:We,recent:We||Pe>0&&A-Pe<=o})}return Y},[t,A,_,o,L]),K=m.useMemo(()=>{const Y=new Set(t.map(he=>he.harnessSessionId?.trim()).filter(he=>!!he)),te=new Map;for(const he of k){const Pe=te.get(he.sessionId)??[];Pe.push(he),te.set(he.sessionId,Pe)}return(E?.transcripts??[]).filter(he=>he.harness!=="scout-managed").filter(he=>{const Pe=he.sessionId?.trim();return!Pe||!Y.has(Pe)}).slice(0,80).map(he=>{const Pe=he.sessionId?te.get(he.sessionId)??[]:[],We=Math.max(0,...Pe.map(bt=>bt.ts)),rt=Math.max(We,he.mtimeMs),at=rt>0&&A-rt<=que,Ot=at||rt>0&&A-rt<=o,jt=hde(he,Pe,at);return{id:Sp(he),transcript:he,events:Pe,agent:mde(he,rt,at),observe:jt,lastActiveAt:rt,current:at,recent:Ot}})},[t,A,o,E?.transcripts,k]),ee=m.useMemo(()=>{if(r==="native")return[];let Y=t;return a!=="all"&&(Y=Y.filter(te=>{const he=q.get(te.id);return a==="active"?he?.current:he?.recent})),u.trim()&&(Y=Y.filter(te=>ZT({name:te.name,handle:te.handle,project:te.project,branch:te.branch,harness:te.harness,id:te.id},u))),[...Y].sort((te,he)=>ide(te,he,q))},[q,a,t,u,r]),G=m.useMemo(()=>{if(r==="scout")return[];let Y=K;return a!=="all"&&(Y=Y.filter(te=>a==="active"?te.current:te.recent)),u.trim()&&(Y=Y.filter(te=>ZT({name:te.agent.name,handle:te.agent.handle,project:te.agent.project,branch:te.agent.branch,harness:te.agent.harness,id:te.agent.id},u))),[...Y].sort(ode)},[a,K,u,r]);m.useEffect(()=>{const Y=[...ee.map(te=>({activity:m0(q.get(te.id)),lastActiveAt:q.get(te.id)?.lastActiveAt??null,id:te.id,name:te.name,handle:te.handle,harness:te.harness,branch:te.branch,project:te.project,model:te.model,state:te.state,agentClass:te.agentClass,updatedAt:te.updatedAt,source:"scout"})),...G.map(te=>({activity:te.current?"active":te.recent?"recent":"idle",lastActiveAt:te.lastActiveAt,id:te.agent.id,name:te.agent.name,handle:te.agent.handle,harness:te.agent.harness,branch:te.agent.branch,project:te.agent.project,model:te.agent.model,state:te.agent.state,agentClass:te.agent.agentClass,updatedAt:te.agent.updatedAt,source:"native"}))].sort((te,he)=>{const Pe=gj({current:te.activity==="active",recent:te.activity!=="idle",lastActiveAt:te.lastActiveAt??0},{current:he.activity==="active",recent:he.activity!=="idle",lastActiveAt:he.lastActiveAt??0});return Pe!==0?Pe:te.name.localeCompare(he.name)});Iue(Y)},[q,ee,G]);const re=m.useMemo(()=>Np.find(Y=>Y.value===o)?.label??"recent",[o]),Q=m.useMemo(()=>[...ee.map(Y=>Jue(Y,q.get(Y.id))),...G.map(ede)],[q,ee,G]),ae=m.useMemo(()=>Kue(Q,c,re),[Q,c,re]),be=m.useRef([]),[$e,ge]=m.useState(null),Te=m.useRef(null),pe=m.useCallback((Y=!0)=>{if(ae.canvasW===0||$.w===0)return;be.current.forEach(clearTimeout),ge(null);const te=Math.min(1,$.w/ae.canvasW,$.h/ae.canvasH),he=Math.max(.15,Math.min(1,te*.92));O(!1),V(he),U({x:($.w-ae.canvasW*he)/2,y:Math.max(8,($.h-ae.canvasH*he)/2)});const Pe=setTimeout(()=>{O(!0);const rt=Y?Zue():null;rt?(U(rt.pan),V(rt.zoom)):(U({x:24,y:24}),V(.55))},700),We=setTimeout(()=>O(!1),1700);be.current=[Pe,We]},[ae,$]),Xe=m.useCallback(()=>{if(ae.canvasW===0||$.w===0)return;be.current.forEach(clearTimeout),ge(null);const Y=Math.min(1,$.w/ae.canvasW,$.h/ae.canvasH),te=Math.max(.15,Math.min(1,Y*.92));O(!0),V(te),U({x:($.w-ae.canvasW*te)/2,y:Math.max(8,($.h-ae.canvasH*te)/2)});const he=setTimeout(()=>O(!1),500);be.current=[he]},[ae,$]);m.useEffect(()=>{ae.canvasW===0||$.w===0||X.current||(X.current=!0,pe(!1))},[ae,$,pe]),m.useEffect(()=>{const Y=setInterval(()=>{Gue({pan:I,zoom:D})},3e4);return()=>clearInterval(Y)},[I,D]);const Be=m.useCallback(Y=>{Y.target.closest(".s-mission-tile")||(z.current=!0,B.current={x:Y.clientX,y:Y.clientY,panX:I.x,panY:I.y})},[I]),Se=m.useCallback(Y=>{z.current&&U({x:B.current.panX+(Y.clientX-B.current.x),y:B.current.panY+(Y.clientY-B.current.y)})},[]),Me=m.useCallback(()=>{z.current=!1},[]);m.useEffect(()=>{const Y=P.current;if(!Y)return;const te=he=>{he.preventDefault();const Pe=Y.getBoundingClientRect(),We=he.clientX-Pe.left,rt=he.clientY-Pe.top,at=he.deltaY>0?.92:1.08,Ot=Math.max(.2,Math.min(2,D*at)),jt=Ot/D;U(bt=>({x:We-(We-bt.x)*jt,y:rt-(rt-bt.y)*jt})),V(Ot)};return Y.addEventListener("wheel",te,{passive:!1}),()=>Y.removeEventListener("wheel",te)},[D]);const _e=h?t.find(Y=>Y.id===h)??G.find(Y=>Y.agent.id===h)?.agent??null:null;m.useEffect(()=>{const Y=te=>{const he=te.target;if(!(he.tagName==="INPUT"||he.tagName==="TEXTAREA"||he.isContentEditable)){if(te.key==="Escape"){h?w(null):n.selectedIds.length>0&&$m();return}if((te.metaKey||te.ctrlKey)&&te.key==="a"){if(n.visibleAgents.length===0)return;te.preventDefault();const We=n.visibleAgents.map(at=>at.id);if(We.length>0&&We.every(at=>n.selectedIds.includes(at)))$m();else for(const at of We)n.selectedIds.includes(at)||Xl(at);return}(te.key==="h"||te.key==="H")&&pe(!1)}};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[_e,h,n.selectedIds,n.visibleAgents,pe]);const Ne=m.useCallback(Y=>{const te=P.current;te&&(be.current.forEach(clearTimeout),ge(null),U({x:te.clientWidth/2-Y.x*D,y:te.clientHeight/2-Y.y*D}))},[D]),Oe=m.useMemo(()=>{const Y={};for(const te of ae.groups)for(const he of te.tiles)Y[he.agentId]={x:he.x,y:he.y};return Y},[ae]),Ce=m.useCallback(Y=>{const te=Oe[Y];if(!te||$.w===0||$.h===0)return!1;be.current.forEach(clearTimeout);const he=($.w-YT*2)/Po,Pe=($.h-YT*2)/Ec,We=Wue(Math.min(he,Pe),Uue,Fue),rt={x:$.w/2-(te.x+Po/2)*We,y:$.h/2-(te.y+Ec/2)*We};O(!0),V(We),U(rt),ge(Y);const at=setTimeout(()=>O(!1),650),Ot=setTimeout(()=>ge(null),1800);return be.current=[at,Ot],!0},[Oe,$]);m.useEffect(()=>{f&&Te.current!==f.serial&&Ce(f.id)&&(Te.current=f.serial,Mue(f.serial))},[f,Ce]);const Ve=ee.filter(Y=>q.get(Y.id)?.current).length+G.filter(Y=>Y.current).length,Re=(r==="native"?0:t.filter(Y=>q.get(Y.id)?.recent).length)+(r==="scout"?0:K.filter(Y=>Y.recent).length),Ie=ee.reduce((Y,te)=>Y+(W.get(te.id)??0),0)+G.length,De=ee.length+G.length,ct=t.length+K.length,ut=m.useMemo(()=>[...ee,...G.map(Y=>Y.agent)],[ee,G]),st=m.useMemo(()=>De>0?{id:"ops-control",render:({isCollapsed:Y,onToggleCollapse:te})=>s.jsx(Sde,{layout:ae,agents:ut,pan:I,zoom:D,viewportRef:P,isCollapsed:Y,onToggleCollapse:te,onFitAll:Xe,onHome:()=>pe(!1),onClick:Ne})}:null,[Xe,ae,ut,Ne,I,pe,De,D]);fQ(st);const ht=m.useMemo(()=>{const Y=new Set(t.map(te=>te.id));return n.selectedIds.filter(te=>Y.has(te))},[t,n.selectedIds]),yt=m.useMemo(()=>{const Y=new Set(G.map(te=>te.id));return n.selectedIds.filter(te=>Y.has(te))},[n.selectedIds,G]),Mt=yt.length,Rt=ht.length+yt.length,xt=c==="activity"?"group":"workspace";return s.jsxs("div",{className:"s-mission",children:[s.jsxs("div",{className:"s-mission-bar",children:[s.jsxs("span",{className:"s-mission-bar-label",children:[De,"/",ct," tile",ct!==1?"s":""," ·"," ",Ie," session",Ie!==1?"s":""," ·"," ",ae.groups.length," ",xt,ae.groups.length!==1?"s":""]}),s.jsxs("span",{className:`s-mission-bar-live${Ve===0?" s-mission-bar-live--idle":""}`,children:[s.jsx("span",{className:"s-mission-bar-live-dot"}),Ve," active now"]}),s.jsx("div",{className:"s-mission-bar-search",children:s.jsx("input",{type:"text",className:"s-mission-bar-search-input",placeholder:"Search agents… (press /)",value:u,onChange:Y=>kp(Y.target.value),onKeyDown:Y=>{Y.key==="Escape"&&(u?kp(""):Y.target.blur())}})}),s.jsxs("div",{className:"s-mission-controls",role:"group","aria-label":"Agent activity filter",children:[s.jsx("button",{type:"button",className:`s-mission-filter${a==="all"?" s-mission-filter--active":""}`,onClick:()=>g("all"),children:"All"}),s.jsx("button",{type:"button",className:`s-mission-filter${a==="active"?" s-mission-filter--active":""}`,onClick:()=>g("active"),children:"Active now"}),s.jsxs("button",{type:"button",className:`s-mission-filter${a==="recent"?" s-mission-filter--active":""}`,onClick:()=>g("recent"),children:["Recent ",Re]})]}),s.jsxs("div",{className:"s-mission-controls",role:"group","aria-label":"Session source filter",children:[s.jsx("button",{type:"button",className:`s-mission-filter${r==="all"?" s-mission-filter--active":""}`,onClick:()=>v("all"),children:"All sources"}),s.jsx("button",{type:"button",className:`s-mission-filter${r==="scout"?" s-mission-filter--active":""}`,onClick:()=>v("scout"),children:"Scout"}),s.jsxs("button",{type:"button",className:`s-mission-filter${r==="native"?" s-mission-filter--active":""}`,onClick:()=>v("native"),children:["Native ",K.length]})]}),s.jsxs("div",{className:"s-mission-controls",role:"group","aria-label":"Canvas grouping",children:[s.jsx("button",{type:"button",className:`s-mission-filter${c==="activity"?" s-mission-filter--active":""}`,onClick:()=>x("activity"),children:"Activity first"}),s.jsx("button",{type:"button",className:`s-mission-filter${c==="workspace"?" s-mission-filter--active":""}`,onClick:()=>x("workspace"),children:"Workspace"})]}),a==="recent"&&s.jsx("div",{className:"s-mission-controls",role:"group","aria-label":"Recent activity window",children:Np.map(Y=>s.jsx("button",{type:"button",className:`s-mission-filter s-mission-filter--compact${o===Y.value?" s-mission-filter--active":""}`,onClick:()=>y(Y.value),children:Y.label},Y.value))}),s.jsxs("div",{className:"s-mission-hotkeys",children:[n.selectedIds.length>0&&s.jsxs("div",{className:"s-mission-selection",role:"group","aria-label":"Selected agent actions",children:[s.jsxs("span",{className:"s-mission-selection-count",children:[n.selectedIds.length," selected"]}),Mt>0&&s.jsxs("span",{className:"s-mission-selection-note",children:[ht.length," Scout · ",Mt," native"]}),s.jsx(dg,{agentIds:ht,nativeSessionIds:yt,className:"s-mission-selection-action s-mission-selection-action--vantage",statusClassName:"s-mission-selection-status",label:"Open in Vantage",openingLabel:"Opening...",disabled:Rt===0,title:Rt>0?"Open selected sessions in the native Vantage canvas":"Select Scout agents or native sessions to open in Vantage"}),s.jsx("button",{type:"button",className:"s-mission-selection-action",onClick:$m,children:"Clear"})]}),s.jsxs("button",{className:"s-mission-hotkey s-mission-hotkey--btn",onClick:()=>pe(!1),title:"Reset to overview",children:[s.jsx("kbd",{children:"H"})," Home"]}),s.jsxs("span",{className:"s-mission-hotkey",children:[s.jsx("kbd",{children:"Esc"})," Close focus"]})]})]}),s.jsx("div",{ref:P,className:"s-mission-viewport",onMouseDown:Be,onMouseMove:Se,onMouseUp:Me,onMouseLeave:Me,children:ct===0?s.jsxs("div",{className:"s-mission-empty",children:[s.jsx("div",{className:"s-mission-empty-title",children:"No agents connected"}),s.jsx("div",{className:"s-mission-empty-sub",children:"Agents appear here as they join the mesh."}),s.jsx("div",{className:"s-mission-empty-hint",children:s.jsx("code",{children:"scout watch --as myagent"})})]}):De===0?s.jsxs("div",{className:"s-mission-empty",children:[s.jsx("div",{className:"s-mission-empty-title",children:"No matching sessions"}),s.jsx("div",{className:"s-mission-empty-sub",children:"Try another activity filter or recent window."})]}):s.jsxs("div",{className:"s-mission-canvas",style:{transform:`translate(${I.x}px, ${I.y}px) scale(${D})`,transition:Z?"transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94)":"none"},children:[ae.groups.map(Y=>s.jsx("div",{className:["s-mission-group-label",Y.label==="Active now"&&"s-mission-group-label--active",Y.label.startsWith("Recent ")&&"s-mission-group-label--recent"].filter(Boolean).join(" "),style:{left:Y.x,top:Y.y},children:Y.label},Y.label)),ee.map(Y=>{const te=Oe[Y.id];if(!te)return null;const he=_[Y.id],Pe=n.selectedIds.includes(Y.id);return s.jsx(QT,{agent:Y,observe:he?.data??null,x:te.x,y:te.y,selected:Pe,canvasFocused:$e===Y.id,onToggleSelected:()=>Xl(Y.id),onClick:We=>{We.metaKey||We.ctrlKey||We.shiftKey?Xl(Y.id):w(Y.id)}},Y.id)}),G.map(Y=>{const te=Oe[Y.id];if(!te)return null;const he=n.selectedIds.includes(Y.id);return s.jsx(QT,{agent:Y.agent,observe:Y.observe,x:te.x,y:te.y,selected:he,canvasFocused:$e===Y.id,onToggleSelected:()=>Xl(Y.id),onClick:Pe=>{Pe.metaKey||Pe.ctrlKey||Pe.shiftKey?Xl(Y.id):w(Y.id)}},Y.id)})]})}),_e&&s.jsx(vde,{agent:_e,observe:_[_e.id]?.data??null,onClose:()=>w(null),onSend:async(Y,te)=>{await me(te==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:Y,conversationId:ps(_e.id)})})},onOpenConversation:()=>{w(null),e({view:"conversation",conversationId:ps(_e.id)})},onTail:()=>{w(null),e({view:"ops",mode:"tail",tailQuery:_e.handle??_e.name})},onProfile:()=>{w(null),e({view:"agents",agentId:_e.id})}})]})}function QT({agent:e,observe:t,x:n,y:a,selected:r=!1,canvasFocused:o=!1,onToggleSelected:c,onClick:u}){const h=m.useRef(null),f=Je(e.state),g=qt(e.name),v=t?.events??[],y=v.slice(-8),x=t?.live===!0,w=v.some(N=>N.kind==="ask"&&!N.answer),C=t?.contextUsage,T=C&&C.length>0?Math.round(C[C.length-1]*100):null,E=v.filter(N=>N.kind==="tool").length,S=v.filter(N=>N.kind==="tool"&&N.tool==="edit").length,k=Gr({label:`Focus ${e.handle??e.name}`,route:`/ops/control · ${e.id}`});return m.useEffect(()=>{h.current&&(h.current.scrollTop=h.current.scrollHeight)},[v.length]),s.jsxs("div",{className:["s-mission-tile",f==="working"?"s-mission-tile--working":null,w?"s-mission-tile--asking":null,r?"s-mission-tile--selected":null,o?"s-mission-tile--canvas-focused":null].filter(Boolean).join(" "),style:{left:n,top:a,height:Ec},onClick:N=>{N.stopPropagation(),u(N)},onPointerEnter:k.onPointerEnter,onPointerLeave:k.onPointerLeave,children:[s.jsxs("div",{className:"s-mission-tile-header",children:[s.jsx("button",{type:"button",className:`s-mission-select${r?" s-mission-select--selected":""}`,"aria-pressed":r,title:r?"Remove from selection":"Select for batch actions",onClick:N=>{N.stopPropagation(),c()}}),s.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:g},children:e.name[0]?.toUpperCase()}),s.jsxs("div",{className:"s-mission-tile-identity",children:[s.jsxs("div",{className:"s-mission-tile-name",children:[e.name,s.jsx("span",{className:"s-mission-tile-handle",children:e.handle?`@${e.handle}`:""})]}),s.jsxs("div",{className:"s-mission-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),s.jsx("span",{className:"s-ops-state-chip",style:{color:Cde(f)},children:ia(e.state).toUpperCase()})]}),s.jsx("div",{className:"s-mission-tile-stream",ref:h,children:y.length===0?s.jsx("div",{className:"s-mission-tile-stream-inner",children:s.jsxs("div",{className:"s-mission-evt",children:[s.jsx("span",{className:"s-mission-evt-bead",style:{background:"var(--dim)"}}),s.jsx("span",{className:"s-mission-evt-text",style:{color:"var(--dim)"},children:f==="offline"?"No session data":"Waiting for events…"})]})}):s.jsx("div",{className:"s-mission-tile-stream-inner",children:y.map(N=>s.jsxs("div",{className:"s-mission-evt",children:[s.jsx("span",{className:"s-mission-evt-bead",style:{background:pde[N.kind]??"var(--dim)"}}),s.jsx("span",{className:"s-mission-evt-kind",children:vj[N.kind]??N.kind}),s.jsxs("span",{className:`s-mission-evt-text s-mission-evt-text--${N.kind}`,children:[Lue(N),N.live&&s.jsx("span",{className:"s-observe-cursor"})]})]},N.id))})}),s.jsxs("div",{className:"s-mission-tile-footer",children:[T!==null&&s.jsx("div",{className:"s-mission-tile-ctx",title:`Context: ${T}%`,children:s.jsx("div",{className:"s-mission-tile-ctx-fill",style:{width:`${T}%`}})}),s.jsxs("div",{className:"s-mission-tile-stats",children:[E>0&&s.jsxs("span",{children:[E," tools"]}),S>0&&s.jsxs("span",{children:[S," edits"]})]}),x&&s.jsxs("span",{className:"s-mission-tile-live",children:[s.jsx("span",{className:"s-mission-tile-live-dot"}),"LIVE"]})]})]})}function vde({agent:e,observe:t,onClose:n,onSend:a,onOpenConversation:r,onTail:o,onProfile:c}){const u=qt(e.name),{ref:h,onKeyDown:f}=Fw(),[g,v]=m.useState("profile"),y=x=>{if(f(x),x.defaultPrevented)return;const w=x.target;w instanceof HTMLInputElement||w instanceof HTMLTextAreaElement||(w?.isContentEditable??!1)||(x.key==="1"?(x.preventDefault(),v("profile")):x.key==="2"?(x.preventDefault(),v("activity")):x.key==="3"&&(x.preventDefault(),v("message")))};return s.jsx("div",{className:"s-mission-overlay",onClick:n,children:s.jsxs("div",{ref:h,role:"dialog","aria-modal":"true","aria-labelledby":"mission-overlay-title",onClick:x=>x.stopPropagation(),onKeyDown:y,tabIndex:-1,className:"s-mission-overlay-dialog",children:[s.jsxs("div",{className:"s-mission-overlay-header",children:[s.jsx("div",{className:"s-ops-avatar",style:{"--size":"28px",background:u},children:e.name[0]?.toUpperCase()}),s.jsxs("div",{className:"s-mission-overlay-identity",children:[s.jsxs("div",{className:"s-mission-overlay-name",id:"mission-overlay-title",children:[e.name," ",s.jsx("span",{className:"s-mission-overlay-handle",children:e.handle?`@${e.handle}`:""})]}),s.jsxs("div",{className:"s-mission-overlay-meta",children:[e.project??"—"," · ",e.branch??"main"," · ",ia(e.state)]})]}),s.jsx("button",{className:"s-mission-overlay-close",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),s.jsxs("div",{className:"s-mission-overlay-tabs",role:"tablist",children:[s.jsxs("div",{className:"s-mission-overlay-tabs-group",children:[s.jsx("button",{type:"button",role:"tab","aria-selected":g==="profile",className:`s-mission-overlay-tab${g==="profile"?" s-mission-overlay-tab--active":""}`,onClick:()=>v("profile"),children:"Profile"}),s.jsx("button",{type:"button",role:"tab","aria-selected":g==="activity",className:`s-mission-overlay-tab${g==="activity"?" s-mission-overlay-tab--active":""}`,onClick:()=>v("activity"),children:"Activity"}),s.jsx("button",{type:"button",role:"tab","aria-selected":g==="message",className:`s-mission-overlay-tab${g==="message"?" s-mission-overlay-tab--active":""}`,onClick:()=>v("message"),children:"Message"})]}),s.jsxs("div",{className:"s-mission-overlay-tabs-action",children:[g==="profile"&&s.jsx("button",{type:"button",className:"s-mission-overlay-jump",onClick:c,...Gr({label:`Open profile · ${e.handle??e.name}`,route:`/agents/${e.id}`}),children:"Open profile ↗"}),g==="activity"&&s.jsx("button",{type:"button",className:"s-mission-overlay-jump",onClick:o,...Gr({label:`Tail · ${e.handle??e.name}`,route:`/ops/tail?q=${encodeURIComponent(e.handle??e.name)}`}),children:"Open in Tail ↗"}),g==="message"&&s.jsx("button",{type:"button",className:"s-mission-overlay-jump",onClick:r,...Gr({label:`Open conversation with ${e.handle??e.name}`,route:`/c/${e.conversationId}`}),children:"Open conversation ↗"})]})]}),s.jsxs("div",{className:"s-mission-overlay-body",children:[g==="profile"&&s.jsx(yde,{agent:e}),g==="activity"&&s.jsx(jde,{agent:e,observe:t,onOpenConversation:r,onMessage:()=>v("message")}),g==="message"&&s.jsx(kde,{agent:e,onSend:a,onOpenConversation:r})]})]})})}function yde({agent:e}){const t=[["MODEL",[e.harness,e.model].filter(Boolean).join("/")||"—"],["AT",[e.project,e.branch].filter(Boolean).join("/")||"—"],["CWD",e.cwd||e.projectRoot||"—"],["AGENT",e.agentClass||"—"],["ROLE",e.role||e.transport||"—"],["MACHINE",e.authorityNodeName??e.homeNodeName??e.authorityNodeId??e.homeNodeId??"—"],["OWNER",e.ownerHandle??e.ownerName??e.ownerId??"—"],["SPAWNED",e.createdAt?Ae(e.createdAt):"—"],["STATE",ia(e.state)]];return s.jsx("div",{className:"s-focus-tab",children:s.jsx("dl",{className:"s-focus-spec",children:t.map(([n,a])=>s.jsxs("div",{className:"s-focus-spec-row",children:[s.jsx("dt",{className:"s-focus-spec-label",children:n}),s.jsx("dd",{className:"s-focus-spec-value",title:a,children:a})]},n))})})}const xde={tool:"▸",think:"·",ask:"?",message:"✉",note:"•",system:"◇",boot:"↑"};function bde(e,t){if(t){const a=Date.now()-(t+e*1e3);return a<6e4?`${Math.max(0,Math.round(a/1e3))}s`:a<36e5?`${Math.round(a/6e4)}m`:a<864e5?`${Math.round(a/36e5)}h`:`${Math.round(a/864e5)}d`}const n=Math.max(0,Math.round(e));return n<60?`${n}s`:n<3600?`${Math.round(n/60)}m`:`${Math.round(n/3600)}h`}function wde(e){if(e.kind==="tool"){const t=e.tool??"tool";return e.arg?`${t} · ${e.arg}`:t}return e.kind==="ask"?e.text||"asked something":e.text||e.detail||vj[e.kind]||e.kind}function jde({agent:e,observe:t,onOpenConversation:n,onMessage:a}){const r=t?.events??[],o=t?.metadata?.usage,c=typeof t?.metadata?.session?.sessionStart=="number"?(t?.metadata?.session).sessionStart:null,u=r.slice(-14).reverse(),h=o?.assistantMessages??r.filter(x=>x.kind==="message").length,f=r.filter(x=>x.kind==="tool").length,g=r.filter(x=>x.kind==="tool"&&(x.tool==="edit"||x.tool==="write")).length,v=t?.contextUsage&&t.contextUsage.length>0?Math.round(t.contextUsage[t.contextUsage.length-1]*100):null,y=v!==null?`${v}%`:o?.contextWindowTokens&&o?.totalTokens?`${Math.round(o.totalTokens/o.contextWindowTokens*100)}%`:"—";return s.jsxs("div",{className:"s-focus-tab s-focus-tab--activity-preview",children:[s.jsxs("dl",{className:"s-focus-stats",children:[s.jsx(Kh,{label:"Turns",value:h||"—"}),s.jsx(Kh,{label:"Tools",value:f||"—"}),s.jsx(Kh,{label:"Edits",value:g||"—"}),s.jsx(Kh,{label:"Context",value:y})]}),u.length===0?s.jsx(Nde,{agent:e,onOpenConversation:n,onMessage:a}):s.jsx("ul",{className:"s-focus-activity-list",children:u.map(x=>s.jsxs("li",{className:`s-focus-activity-row s-focus-activity-row--${x.kind}`,children:[s.jsx("span",{className:"s-focus-activity-time",children:bde(x.t,c)}),s.jsx("span",{className:"s-focus-activity-glyph","aria-hidden":!0,children:xde[x.kind]??"·"}),s.jsx("span",{className:"s-focus-activity-kind",children:vj[x.kind]??x.kind}),s.jsx("span",{className:"s-focus-activity-text",children:wde(x)})]},x.id))})]})}function Nde({agent:e,onOpenConversation:t,onMessage:n}){const a=e.role?.trim(),r=[e.harness,e.model].filter(Boolean).join("/"),o=[e.project,e.branch].filter(Boolean).join("/"),c=Je(e.state),u=ia(c),h=e.createdAt?Ae(e.createdAt):null,f=e.updatedAt?Ae(e.updatedAt):null,g=e.homeNodeName??e.homeNodeId,v=e.ownerHandle??e.ownerName??e.ownerId,y=[];return a&&y.push({label:"Role",value:a}),r&&y.push({label:"Stack",value:r}),o&&y.push({label:"At",value:o}),g&&y.push({label:"Home",value:g}),v&&y.push({label:"Owner",value:v}),h&&y.push({label:"Spawned",value:h}),y.push({label:"State",value:u}),f&&y.push({label:"Last seen",value:f}),s.jsxs("div",{className:"s-focus-activity-empty s-focus-activity-empty--rich",children:[s.jsxs("div",{className:"s-focus-activity-empty-head",children:[s.jsx("span",{className:"s-focus-activity-empty-eyebrow",children:"No tool or turn events recorded"}),s.jsx("span",{className:"s-focus-activity-empty-title",children:e.handle??e.name})]}),s.jsx("dl",{className:"s-focus-activity-empty-facts",children:y.map(x=>s.jsxs("div",{className:"s-focus-activity-empty-fact",children:[s.jsx("dt",{children:x.label}),s.jsx("dd",{title:x.value,children:x.value})]},x.label))}),s.jsxs("div",{className:"s-focus-activity-empty-actions",children:[s.jsx("button",{type:"button",className:"s-focus-activity-empty-btn",onClick:t,...Gr({label:`Open conversation with ${e.handle??e.name}`,route:`/c/${e.conversationId}`}),children:"Open conversation ↗"}),s.jsx("button",{type:"button",className:"s-focus-activity-empty-btn s-focus-activity-empty-btn--primary",onClick:n,...Gr({label:`Compose message · ${e.handle??e.name}`}),children:"Send a message"})]})]})}function Kh({label:e,value:t}){return s.jsxs("div",{className:"s-focus-stat",children:[s.jsx("dt",{className:"s-focus-stat-label",children:e}),s.jsx("dd",{className:"s-focus-stat-value",children:t})]})}function kde({agent:e,onSend:t,onOpenConversation:n}){const[a,r]=m.useState(""),[o,c]=m.useState(!1),[u,h]=m.useState(null),[f,g]=m.useState(null),v=m.useRef(null);m.useEffect(()=>{v.current?.focus()},[]);const y=async T=>{const E=a.trim();if(!(!E||o)){c(!0),g(null);try{await t(E,T),r(""),h(T),setTimeout(()=>h(null),1800)}catch(S){g(S instanceof Error?S.message:String(S))}finally{c(!1)}}},x=T=>{(T.metaKey||T.ctrlKey)&&T.key==="Enter"&&(T.preventDefault(),T.shiftKey?y("ask"):y("tell"))},w=e.handle??e.name,C=a.trim().length>0&&!o;return s.jsx("div",{className:"s-focus-tab",children:s.jsxs("div",{className:"s-focus-compose",children:[s.jsxs("label",{className:"s-focus-compose-label",htmlFor:"s-focus-compose-input",children:["Message ",s.jsxs("span",{className:"s-focus-compose-target",children:["@",w]})]}),s.jsx("textarea",{id:"s-focus-compose-input",ref:v,className:"s-focus-compose-input",placeholder:`Steer @${w}… (⌘↩ to Steer · ⌘⇧↩ to Ask)`,rows:6,value:a,onChange:T=>r(T.target.value),onKeyDown:x,disabled:o}),s.jsxs("div",{className:"s-focus-compose-foot",children:[s.jsx("div",{className:"s-focus-compose-hint",children:f?s.jsxs("span",{className:"s-focus-compose-error",children:["Send failed: ",f]}):u==="tell"?s.jsxs("span",{className:"s-focus-compose-ok",children:["Steered ↗ ",s.jsx("button",{type:"button",className:"s-focus-compose-link",onClick:n,children:"Open thread"})]}):u==="ask"?s.jsxs("span",{className:"s-focus-compose-ok",children:["Asked ↗ ",s.jsx("button",{type:"button",className:"s-focus-compose-link",onClick:n,children:"Open thread"})]}):s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Steer"})," redirects what they're doing. ",s.jsx("strong",{children:"Ask"})," waits for a structured answer."]})}),s.jsxs("div",{className:"s-focus-compose-actions",children:[s.jsx(Jw,{onAppend:T=>r(E=>E.trim()?`${E.trimEnd()} ${T}`:T)}),s.jsx("button",{type:"button",className:"s-ops-btn",onClick:()=>{y("ask")},disabled:!C,children:"Ask"}),s.jsx("button",{type:"button",className:"s-ops-btn s-ops-btn--primary",onClick:()=>{y("tell")},disabled:!C,children:"Steer"})]})]})]})})}function Sde({layout:e,agents:t,pan:n,zoom:a,viewportRef:r,isCollapsed:o,onToggleCollapse:c,onFitAll:u,onHome:h,onClick:f}){const g=m.useRef(null),[v,y]=m.useState(0);if(m.useEffect(()=>{const H=g.current;if(!H)return;const I=()=>y(H.getBoundingClientRect().width);I();const U=new ResizeObserver(I);return U.observe(H),()=>U.disconnect()},[]),e.canvasW===0)return null;const x=v||Vue,w=Math.min(x/e.canvasW,Hue/e.canvasH),C=e.canvasW*w,T=e.canvasH*w,E=Math.max(0,(x-C)/2),S=r.current,k=S?.clientWidth??0,N=S?.clientHeight??0,A=-n.x/a*w,R=-n.y/a*w,_=k/a*w,P=N/a*w,$=m.useCallback(H=>{const I=H.currentTarget.getBoundingClientRect(),U=Math.max(0,Math.min(C,H.clientX-I.left-E)),D=Math.max(0,Math.min(T,H.clientY-I.top));f({x:U/w,y:D/w})},[E,T,w,C,f]);return o?s.jsx("div",{className:"s-mission-minimap s-mission-minimap--collapsed",children:s.jsxs("div",{className:"s-mission-minimap-header",children:[s.jsxs("span",{className:"s-mission-minimap-title",children:[s.jsx("span",{className:"s-mission-minimap-title-mark","aria-hidden":!0}),"MAP"]}),s.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Expand map","aria-label":"Expand map",onClick:c,children:s.jsx(T0,{size:12,strokeWidth:1.5})})]})}):s.jsxs("div",{className:"s-mission-minimap",children:[s.jsxs("div",{className:"s-mission-minimap-header",children:[s.jsxs("span",{className:"s-mission-minimap-title",children:[s.jsx("span",{className:"s-mission-minimap-title-mark","aria-hidden":!0}),"MAP"]}),s.jsxs("div",{className:"s-mission-minimap-actions",children:[s.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Fit all","aria-label":"Fit all",onClick:u,children:s.jsx(Ip,{size:12,strokeWidth:1.5})}),s.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Recenter","aria-label":"Recenter",onClick:h,children:s.jsx(u2,{size:12,strokeWidth:1.5})}),s.jsx("button",{type:"button",className:"s-mission-minimap-action",title:"Minimize map","aria-label":"Minimize map",onClick:c,children:s.jsx(Vo,{size:12,strokeWidth:1.5})})]})]}),s.jsxs("div",{ref:g,className:"s-mission-minimap-canvas",style:{height:T},onClick:$,"aria-hidden":"true",children:[e.groups.flatMap(H=>H.tiles.map(I=>{const U=t.find(D=>D.id===I.agentId);return s.jsx("div",{className:"s-mission-minimap-tile",style:{left:E+I.x*w,top:I.y*w,width:Po*w,height:Ec*w,background:U?qt(U.name):"var(--dim)",opacity:U&&Je(U.state)==="working"?.8:.35}},I.agentId)})),s.jsx("div",{className:"s-mission-minimap-viewport",style:{left:E+Math.max(0,A),top:Math.max(0,R),width:Math.min(_,C),height:Math.min(P,T)}})]})]})}function Cde(e){switch(e){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const Ede=["openai","codex","codex_app_server"],Ade=["anthropic","claude","claude-code","claude_stream_json"],So={"openai:gpt-5.5":{provider:"openai",model:"gpt-5.5",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:null,outputPerM:30,webSearchPer1K:10},"openai:gpt-5.5-pro":{provider:"openai",model:"gpt-5.5-pro",inputPerM:30,cachedInputPerM:null,cacheWritePerM:null,outputPerM:180,webSearchPer1K:10},"openai:gpt-5.4":{provider:"openai",model:"gpt-5.4",inputPerM:2.5,cachedInputPerM:.25,cacheWritePerM:null,outputPerM:15,webSearchPer1K:10},"openai:gpt-5.4-mini":{provider:"openai",model:"gpt-5.4-mini",inputPerM:.75,cachedInputPerM:.075,cacheWritePerM:null,outputPerM:4.5,webSearchPer1K:10},"openai:gpt-5.4-nano":{provider:"openai",model:"gpt-5.4-nano",inputPerM:.2,cachedInputPerM:.02,cacheWritePerM:null,outputPerM:1.25,webSearchPer1K:10},"openai:gpt-5.4-pro":{provider:"openai",model:"gpt-5.4-pro",inputPerM:30,cachedInputPerM:null,cacheWritePerM:null,outputPerM:180,webSearchPer1K:10},"openai:gpt-5.3-codex":{provider:"openai",model:"gpt-5.3-codex",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.3-chat-latest":{provider:"openai",model:"gpt-5.3-chat-latest",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2":{provider:"openai",model:"gpt-5.2",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-codex":{provider:"openai",model:"gpt-5.2-codex",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-chat-latest":{provider:"openai",model:"gpt-5.2-chat-latest",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-pro":{provider:"openai",model:"gpt-5.2-pro",inputPerM:21,cachedInputPerM:null,cacheWritePerM:null,outputPerM:168,webSearchPer1K:10},"openai:gpt-5.1":{provider:"openai",model:"gpt-5.1",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-codex":{provider:"openai",model:"gpt-5.1-codex",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-codex-max":{provider:"openai",model:"gpt-5.1-codex-max",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-chat-latest":{provider:"openai",model:"gpt-5.1-chat-latest",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5":{provider:"openai",model:"gpt-5",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-codex":{provider:"openai",model:"gpt-5-codex",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-chat-latest":{provider:"openai",model:"gpt-5-chat-latest",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-mini":{provider:"openai",model:"gpt-5-mini",inputPerM:.25,cachedInputPerM:.025,cacheWritePerM:null,outputPerM:2,webSearchPer1K:10},"openai:gpt-5-nano":{provider:"openai",model:"gpt-5-nano",inputPerM:.05,cachedInputPerM:.005,cacheWritePerM:null,outputPerM:.4,webSearchPer1K:10},"openai:gpt-5-pro":{provider:"openai",model:"gpt-5-pro",inputPerM:15,cachedInputPerM:null,cacheWritePerM:null,outputPerM:120,webSearchPer1K:10},"openai:gpt-4.1":{provider:"openai",model:"gpt-4.1",inputPerM:2,cachedInputPerM:.5,cacheWritePerM:null,outputPerM:8,webSearchPer1K:10},"openai:gpt-4.1-mini":{provider:"openai",model:"gpt-4.1-mini",inputPerM:.4,cachedInputPerM:.1,cacheWritePerM:null,outputPerM:1.6,webSearchPer1K:10},"openai:gpt-4.1-nano":{provider:"openai",model:"gpt-4.1-nano",inputPerM:.1,cachedInputPerM:.025,cacheWritePerM:null,outputPerM:.4,webSearchPer1K:10},"openai:gpt-4o":{provider:"openai",model:"gpt-4o",inputPerM:2.5,cachedInputPerM:1.25,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-4o-mini":{provider:"openai",model:"gpt-4o-mini",inputPerM:.15,cachedInputPerM:.075,cacheWritePerM:null,outputPerM:.6,webSearchPer1K:10},"anthropic:claude-opus-4.6":{provider:"anthropic",model:"claude-opus-4.6",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:6.25,outputPerM:25,webSearchPer1K:10},"anthropic:claude-opus-4.5":{provider:"anthropic",model:"claude-opus-4.5",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:6.25,outputPerM:25,webSearchPer1K:10},"anthropic:claude-opus-4.1":{provider:"anthropic",model:"claude-opus-4.1",inputPerM:15,cachedInputPerM:1.5,cacheWritePerM:18.75,outputPerM:75,webSearchPer1K:10},"anthropic:claude-opus-4":{provider:"anthropic",model:"claude-opus-4",inputPerM:15,cachedInputPerM:1.5,cacheWritePerM:18.75,outputPerM:75,webSearchPer1K:10},"anthropic:claude-sonnet-4.6":{provider:"anthropic",model:"claude-sonnet-4.6",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-sonnet-4.5":{provider:"anthropic",model:"claude-sonnet-4.5",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-sonnet-4":{provider:"anthropic",model:"claude-sonnet-4",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-3-7-sonnet":{provider:"anthropic",model:"claude-3-7-sonnet",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-haiku-4.5":{provider:"anthropic",model:"claude-haiku-4.5",inputPerM:1,cachedInputPerM:.1,cacheWritePerM:1.25,outputPerM:5,webSearchPer1K:10}},Tde={"claude-sonnet-4-5":"anthropic:claude-sonnet-4.5","claude-sonnet-4-6":"anthropic:claude-sonnet-4.6","claude-opus-4-5":"anthropic:claude-opus-4.5","claude-opus-4-6":"anthropic:claude-opus-4.6","claude-haiku-4-5":"anthropic:claude-haiku-4.5"};function Mde(e){const t=e.provider?.trim().toLowerCase()??"",n=e.adapterType?.trim().toLowerCase()??"",a=CD(e.model)??"",r=[t,n].filter(Boolean);return r.some(o=>Ede.some(c=>o.includes(c)))?"openai":r.some(o=>Ade.some(c=>o.includes(c)))?"anthropic":a.startsWith("gpt-")||a.startsWith("o")||a.includes("codex")?"openai":a.startsWith("claude-")?"anthropic":"unknown"}function CD(e){return e?e.trim().toLowerCase().replace(/^(openai|anthropic)\//,"").replace(/_/g,"-").replace(/-\d{8}$/,""):null}function Rde(e){const t=Ni(e?.inputTokens),n=Ni(e?.cacheReadInputTokens),a=Ni(e?.cacheCreationInputTokens),r=Ni(e?.outputTokens),o=Ni(e?.reasoningOutputTokens),c=[t,r].reduce((h,f)=>h+(f??0),0),u=Ni(e?.totalTokens)??(c||null);return{input:t,uncachedInput:t==null?null:Math.max(0,t-(n??0)-(a??0)),cachedInput:n,cacheWrite:a,output:r,reasoningOutput:o,total:u,webSearchRequests:Ni(e?.webSearchRequests),webFetchRequests:Ni(e?.webFetchRequests)}}function Ide(e){const t=Mde(e),n=CD(e.model),a=Rde(e.usage),r=_de(t,n),o=Ode(e);if(!r.rateCard)return{provider:t,model:n,rateCard:null,rateCardSource:"unknown",capturedAt:e.capturedAt??Date.now(),usage:a,lineItems:[],totalUsd:null,billedTotalUsd:null,billingMode:o,subscriptionWindows:e.subscriptionWindows??[]};const c=r.rateCard,u=a.uncachedInput??a.input??0,h=a.cachedInput??0,f=a.cacheWrite??0,g=a.output??0,v=a.webSearchRequests??0,y=[Yh("input","Input",u,c.inputPerM,o),Yh("cached_input","Cached input",h,c.cachedInputPerM??c.inputPerM,o),Yh("cache_write","Cache write",f,c.cacheWritePerM??c.inputPerM,o),Yh("output","Output",g,c.outputPerM,o),{key:"web_search",label:"Web search",quantity:v,unit:"requests",rate:c.webSearchPer1K??0,billedRate:o==="subscription"?0:c.webSearchPer1K??0,costUsd:v/1e3*(c.webSearchPer1K??0),billedCostUsd:o==="subscription"?0:v/1e3*(c.webSearchPer1K??0)}].filter(x=>x.quantity>0);return{provider:t,model:n,rateCard:c,rateCardSource:r.source,capturedAt:e.capturedAt??Date.now(),usage:a,lineItems:y,totalUsd:y.reduce((x,w)=>x+w.costUsd,0),billedTotalUsd:y.reduce((x,w)=>x+w.billedCostUsd,0),billingMode:o,subscriptionWindows:e.subscriptionWindows??[]}}function _de(e,t){if(e==="unknown")return{rateCard:null,source:"unknown"};const n=t?`${e}:${t}`:null;if(n&&So[n])return{rateCard:So[n],source:"exact"};const a=t?Tde[t]:null;if(a&&So[a])return{rateCard:So[a],source:"alias"};if(e==="anthropic"){if(t?.includes("opus"))return{rateCard:So["anthropic:claude-opus-4.5"],source:"provider-default"};if(t?.includes("haiku"))return{rateCard:So["anthropic:claude-haiku-4.5"],source:"provider-default"};if(t?.includes("sonnet")||!t)return{rateCard:So["anthropic:claude-sonnet-4.5"],source:"provider-default"}}return{rateCard:null,source:"unknown"}}function Yh(e,t,n,a,r){const o=r==="subscription"?0:a;return{key:e,label:t,quantity:n,unit:"tokens",rate:a,billedRate:o,costUsd:n/1e6*a,billedCostUsd:n/1e6*o}}function Ni(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Ode(e){if(e.billingMode)return e.billingMode;const t=e.adapterType?.trim().toLowerCase();if(t==="claude-code"||t==="claude_stream_json")return"subscription";const n=e.usage?.planType?.trim().toLowerCase();return!n||n==="api"||n.includes("api")?"api":"subscription"}const p0=1440*6e4,$de=90*6e4,JT={working:0,available:1,offline:2},Pde=[{key:"agent",label:"Agent",kind:"custom",sortable:!0,sortValue:e=>e.agent.name.toLowerCase(),defaultWidth:220,minWidth:160,render:e=>s.jsxs("div",{className:"s-ops-agents-agent-cell",children:[s.jsx("span",{className:"s-ops-agents-dot",style:{background:Pn(e.state)},"aria-hidden":!0}),s.jsx("span",{className:"s-ops-agents-agent-name",title:e.agent.name,children:e.agent.handle??e.agent.name})]})},{key:"task",label:"Active task",kind:"custom",sortable:!0,sortValue:e=>(e.activeTask??"").toLowerCase()||null,defaultWidth:240,minWidth:140,render:e=>e.activeTask?s.jsx("span",{className:"s-ops-agents-task",title:e.activeTask,children:e.activeTask}):s.jsx("span",{className:"s-ops-agents-task s-ops-agents-task--idle",children:"—"})},{key:"team",label:"Project",kind:"text",defaultWidth:140,minWidth:90,cls:"s-ops-agents-meta",render:e=>s.jsx("span",{className:"s-ops-agents-meta-cell",children:e.team}),sortValue:e=>e.team.toLowerCase()},{key:"machine",label:"Machine",kind:"text",defaultWidth:120,minWidth:88,cls:"s-ops-agents-meta",render:e=>s.jsx("span",{className:"s-ops-agents-meta-cell",children:e.machine}),sortValue:e=>e.machine.toLowerCase()},{key:"active",label:"Active",kind:"number",defaultWidth:90,minWidth:64,cls:"s-ops-agents-num",render:e=>e.activeFlights,sortValue:e=>e.activeFlights},{key:"sessions24h",label:"24h sessions",kind:"number",defaultWidth:108,minWidth:78,cls:"s-ops-agents-num",render:e=>e.sessions24h,sortValue:e=>e.sessions24h},{key:"throughput",label:"Throughput",kind:"custom",sortable:!1,defaultWidth:110,minWidth:90,render:e=>s.jsx(zde,{values:e.throughput,warn:e.errors>0})},{key:"avgLatency",label:"Avg latency",kind:"number",defaultWidth:108,minWidth:80,cls:"s-ops-agents-num",render:e=>ED(e.avgLatencyMs),sortValue:e=>e.avgLatencyMs},{key:"input",label:"Input",kind:"number",defaultWidth:88,minWidth:64,cls:"s-ops-agents-num",render:e=>ed(e.usage.uncachedInput??e.usage.input),sortValue:e=>e.usage.uncachedInput??e.usage.input??null},{key:"cacheRead",label:"Cache read",kind:"number",defaultWidth:98,minWidth:72,cls:"s-ops-agents-num",render:e=>ed(e.usage.cachedInput),sortValue:e=>e.usage.cachedInput??null},{key:"cacheWrite",label:"Cache write",kind:"number",defaultWidth:98,minWidth:72,cls:"s-ops-agents-num",render:e=>ed(e.usage.cacheWrite),sortValue:e=>e.usage.cacheWrite??null},{key:"output",label:"Output",kind:"number",defaultWidth:88,minWidth:64,cls:"s-ops-agents-num",render:e=>ed(e.usage.output),sortValue:e=>e.usage.output??null},{key:"apiEquiv",label:"API equiv",kind:"number",defaultWidth:92,minWidth:72,cls:"s-ops-agents-num",render:e=>s.jsx("span",{className:e.cost.rateCardSource==="unknown"?"s-ops-agents-num--dim":void 0,children:Cp(e.cost.totalUsd)}),sortValue:e=>e.cost.totalUsd??null},{key:"billed",label:"Billed",kind:"number",defaultWidth:92,minWidth:72,cls:"s-ops-agents-num",render:e=>s.jsx("span",{className:e.cost.billingMode==="subscription"?"s-ops-agents-num--covered":void 0,children:Cp(e.cost.billedTotalUsd)}),sortValue:e=>e.cost.billedTotalUsd??null},{key:"errors",label:"Errors",kind:"number",defaultWidth:72,minWidth:58,cls:"s-ops-agents-num",render:e=>s.jsx("span",{className:e.errors>0?"s-ops-agents-num--warn":void 0,children:e.errors}),sortValue:e=>e.errors},{key:"lastActive",label:"Last active",kind:"time",defaultWidth:104,minWidth:78,cls:"s-ops-agents-last",render:e=>e.lastActiveAt?Ae(e.lastActiveAt):"—",sortValue:e=>e.lastActiveAt}];function eM(e){if(!e)return null;const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function ed(e){return e==null?"—":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}K`:String(e)}function ED(e){return e==null?"—":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function Cp(e){return e==null?"$—":e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function Dde(e,t){if(!e)return null;const n=e.data.events.filter(r=>r.kind==="message"||r.kind==="tool").filter(r=>t-r.t<=$de).sort((r,o)=>r.t-o.t);if(n.length<2)return null;const a=[];for(let r=1;r<n.length;r+=1){const o=n[r].t-n[r-1].t;o>0&&o<12e4&&a.push(o)}return a.length===0?null:Math.round(a.reduce((r,o)=>r+o,0)/a.length)}function Lde(e,t){const n=new Array(24).fill(0),a=t-p0;for(const r of e){if(r.ts<a||r.ts>t)continue;const o=Math.min(23,Math.max(0,Math.floor((r.ts-a)/p0*n.length)));n[o]+=1}return n}function zde({values:e,warn:t=!1}){const r=Math.max(1,...e),o=e.map((c,u)=>{const h=u/Math.max(1,e.length-1)*92,f=22-c/r*19-1.5;return`${h.toFixed(1)},${f.toFixed(1)}`}).join(" ");return s.jsx("svg",{className:`s-ops-agents-spark${t?" s-ops-agents-spark--warn":""}`,viewBox:"0 0 92 22","aria-hidden":"true",children:s.jsx("polyline",{points:o,fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function Bde(e){return e.authorityNodeName??e.homeNodeName??e.authorityNodeId??e.homeNodeId??e.transport??eM(e.cwd)??eM(e.projectRoot)??"local"}function Ude(e){return e.project??e.role??e.agentClass??"Unassigned"}function Fde(e){if(e.length===0)return null;const t={working:0,needs_attention:1,queued:2,failed:3,completed:4},a=[...e].sort((o,c)=>{const u=t[o.status]-t[c.status];return u!==0?u:(c.updatedAt??0)-(o.updatedAt??0)})[0];return(a.task??a.summary??"").trim()||null}function Vde(e,t,n,a,r,o){const c=t.filter(w=>w.agentId===e.id),u=c.filter(w=>{const C=w.lastMessageAt??0;return C>0&&o-C<=p0}),h=n.filter(w=>w.actorName===e.name||w.conversationId===e.conversationId),f=r.get(e.id),g=f?.data.metadata?.session?.model??null,v=f?.data.metadata?.session?.modelProvider??null,y=Ide({adapterType:f?.data.metadata?.session?.adapterType,capturedAt:f?.updatedAt??o,model:g,provider:v,usage:f?.data.metadata?.usage}),x=a.filter(w=>w.agentId===e.id);return{agent:e,team:Ude(e),machine:Bde(e),model:g,provider:v,state:Je(e.state),activeFlights:x.length,activeTask:Fde(x),sessions24h:u.length,throughput:Lde(h,o),avgLatencyMs:Dde(f,o),usage:y.usage,cost:y,errors:x.filter(w=>w.status==="failed"||w.status==="needs_attention").length,lastActiveAt:Math.max(0,...c.map(w=>w.lastMessageAt??0),...h.map(w=>w.ts),e.updatedAt??0)||null}}function Hde({navigate:e,agents:t}){const[n,a]=m.useState(null),[r,o]=m.useState([]),[c,u]=m.useState([]),[h,f]=m.useState([]),[g,v]=m.useState(""),[y,x]=m.useState(()=>Date.now()),w=m.useCallback(async()=>{const V=t.map(X=>X.id).join(","),[Z,O,z,B]=await Promise.allSettled([me("/api/fleet"),me("/api/conversations"),me("/api/activity"),V?me(`/api/observe/agents?ids=${encodeURIComponent(V)}`):Promise.resolve([])]);Z.status==="fulfilled"&&a(Z.value),O.status==="fulfilled"&&o(O.value),z.status==="fulfilled"&&u(z.value),B.status==="fulfilled"&&f(B.value),x(Date.now())},[t]);m.useEffect(()=>{w()},[w]),tn(()=>{w()}),m.useEffect(()=>{const V=setInterval(()=>x(Date.now()),1e3);return()=>clearInterval(V)},[]);const C=m.useMemo(()=>new Map(h.map(V=>[V.agentId,V])),[h]),T=m.useMemo(()=>{const V=n?.activeAsks??[];return t.map(Z=>Vde(Z,r,c,V,C,y))},[c,t,n?.activeAsks,y,C,r]),E=m.useMemo(()=>{const V=g.trim().toLowerCase();return V?T.filter(Z=>`${Z.agent.name} ${Z.team} ${Z.machine} ${Z.agent.handle??""} ${Z.agent.harness??""} ${Z.activeTask??""}`.toLowerCase().includes(V)):T},[g,T]),[S,k]=m.useState({key:"lastActive",dir:-1}),N=m.useMemo(()=>S?.key==="agent"?void 0:(V,Z)=>JT[V.state]-JT[Z.state],[S?.key]),A=m.useMemo(()=>E.map(V=>V.agent),[E]),R=m.useMemo(()=>E.map(V=>V.agent.id),[E]),_=lj({agents:A,orderedIds:R,navigate:e,selectMode:"preview"}),P=T.filter(V=>V.state==="working").length,$=T.filter(V=>V.state!=="offline").length,H=T.reduce((V,Z)=>V+(Z.usage.total??0),0),I=T.some(V=>V.cost.totalUsd!=null)?T.reduce((V,Z)=>V+(Z.cost.totalUsd??0),0):null,U=T.some(V=>V.cost.billedTotalUsd!=null)?T.reduce((V,Z)=>V+(Z.cost.billedTotalUsd??0),0):null,D=(()=>{const V=T.map(Z=>Z.avgLatencyMs).filter(Z=>Z!=null);return V.length===0?null:Math.round(V.reduce((Z,O)=>Z+O,0)/V.length)})();return s.jsxs("div",{className:"s-ops-agents",children:[s.jsxs("main",{className:"s-ops-agents-main",children:[s.jsxs("div",{className:"s-ops-agents-toolbar",children:[s.jsxs("div",{className:"s-ops-agents-breadcrumb",children:["Fleet ",s.jsx("span",{children:"/"})," Agents"]}),s.jsxs("div",{className:"s-ops-agents-live",children:[s.jsx("span",{className:"s-ops-agents-live-dot"}),$," active"]}),s.jsxs("div",{className:"s-ops-agents-search",children:[s.jsx(Op,{size:13}),s.jsx("input",{value:g,onChange:V=>v(V.target.value),placeholder:"Search agents, tasks, projects, machines…"})]}),s.jsx("button",{className:"s-ops-agents-icon-btn",type:"button",title:"Filters",children:s.jsx(Jz,{size:14})})]}),s.jsx("section",{className:"s-ops-agents-hero",children:s.jsxs("div",{children:[s.jsx("div",{className:"s-ops-agents-kicker",children:"Agents"}),s.jsx("h1",{children:"All agents"}),s.jsx("p",{children:"Every registered agent across the local fleet, sorted by live status."})]})}),s.jsxs("section",{className:"s-ops-agents-stats",children:[s.jsx(Xh,{label:"Running",value:String(P),sub:`of ${t.length} total`}),s.jsx(Xh,{label:"Tokens",value:ed(H||null),sub:I==null?"usage metadata pending":`${Cp(I)} API equiv`}),s.jsx(Xh,{label:"Avg latency",value:ED(D),sub:"recent observe events"}),s.jsx(Xh,{label:"Billed",value:Cp(U),sub:"subscription usage can mark this down"})]}),s.jsxs("section",{className:"s-ops-agents-table-panel",children:[s.jsxs("div",{className:"s-ops-agents-table-title",children:["Agents ",s.jsx("span",{children:E.length}),s.jsxs("span",{className:"s-ops-agents-hint","aria-hidden":!0,children:[s.jsx("kbd",{children:"↑"}),s.jsx("kbd",{children:"↓"})," navigate · ",s.jsx("kbd",{children:"enter"})," pin · ",s.jsx("kbd",{children:"o"})," open · ",s.jsx("kbd",{children:"esc"})," clear"]})]}),s.jsx("div",{className:"s-ops-agents-table-wrap",ref:_.containerRef,children:s.jsx(ug,{rows:E,columns:Pde,rowId:V=>V.agent.id,storageKey:"openscout.opsAgents.cols",sort:S,onSortChange:k,secondarySort:N,density:"compact",rowBindings:V=>{const Z=_.bind(V);return{...Z,onKeyDown:O=>{O.key!=="Enter"&&O.key!==" "||(O.preventDefault(),Z.onClick())}}},rowState:V=>_.getState(V),empty:{title:"No agents match",body:"Adjust the search to find a different slice of the fleet."},className:"s-ops-agents-data-table",ariaLabel:"Fleet agents"})})]})]}),_.card]})}function Xh({label:e,value:t,sub:n,tone:a="default"}){return s.jsxs("div",{className:`s-ops-agents-metric s-ops-agents-metric--${a}`,children:[s.jsx("div",{className:"s-ops-agents-metric-label",children:e}),s.jsx("div",{className:"s-ops-agents-metric-value",children:t}),s.jsx("div",{className:"s-ops-agents-metric-sub",children:n})]})}const qde={total:0,byAuthor:{all:0,operator:0,agent:0},byOutcome:{all:0,running:0,review:0,completed:0,abandoned:0},byProject:[]};let $n={authorFilter:"all",outcomeFilter:"all",timeFilter:"7d",projectFilter:"all",query:"",counts:qde,focusedPlanId:null};const g0=new Set;function sl(){for(const e of g0)e()}function Wde(e){return g0.add(e),()=>{g0.delete(e)}}function tM(){return $n}function AD(){return m.useSyncExternalStore(Wde,tM,tM)}function Gde(e){$n.authorFilter!==e&&($n={...$n,authorFilter:e},sl())}function Zde(e){$n.outcomeFilter!==e&&($n={...$n,outcomeFilter:e},sl())}function Kde(e){$n.timeFilter!==e&&($n={...$n,timeFilter:e},sl())}function nM(e){$n.projectFilter!==e&&($n={...$n,projectFilter:e},sl())}function TD(e){$n.query!==e&&($n={...$n,query:e},sl())}function Yde(e){$n={...$n,counts:e},sl()}function Ix(e){$n.focusedPlanId!==e&&($n={...$n,focusedPlanId:e},sl())}const MD=[{id:"24h",label:"24h",ms:1440*60*1e3},{id:"7d",label:"7d",ms:10080*60*1e3},{id:"30d",label:"30d",ms:720*60*60*1e3},{id:"all",label:"All",ms:null}],Xde=[{id:"all",label:"All"},{id:"operator",label:"Operator"},{id:"agent",label:"Agent"}],Qde=[{id:"all",label:"All"},{id:"running",label:"Running"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"abandoned",label:"Abandoned"}],Jde=new Set(["open","working","waiting"]),efe=new Set(["review"]),tfe=new Set(["completed","done","shipped"]);function nfe(e){const t=e.toLowerCase();return Jde.has(t)?"running":efe.has(t)?"review":tfe.has(t)?"completed":"abandoned"}function sfe(e){const t=e.ownerId??"",n=t==="operator"||t===""||t.startsWith("operator.");return{author:n?"operator":"agent",label:e.ownerName??t??(n?"operator":"agent")}}function afe(e){if(e.parentTitle){const t=e.parentTitle.match(/^([a-z0-9_-]+)/i);if(t)return t[1]}return"—"}function rfe(e){const{author:t,label:n}=sfe(e);return{id:e.id,source:"work",title:e.title,summary:e.summary??e.lastMeaningfulSummary??null,author:t,authorLabel:n,ownerId:e.ownerId,project:afe(e),state:e.state,outcome:nfe(e.state),route:{view:"work",workId:e.id},taskText:null,createdAt:e.createdAt,updatedAt:e.updatedAt,lastMeaningfulAt:e.lastMeaningfulAt,parentId:e.parentId,parentTitle:e.parentTitle}}function Ep(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function v0(e,t=260){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}function ife(e){return e.split(/\r?\n/).map(t=>t.trim()).find(Boolean)??e.trim()}function RD(e){return Ep(e.input?.task)}function ofe(e){return Ep(e.output?.summary)??Ep(e.output?.text)}function sM(e,t){const n=e&&typeof e=="object"&&!Array.isArray(e)?e[t]:null;return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function lfe(e){const t=sM(e.metadata,"invocationMetadata")??e.metadata??null,n=sM(t,"returnAddress"),a=Ep(n?.projectRoot);if(a){const c=a.split("/").filter(Boolean);return c[c.length-1]??a}return(e.conversationId??"").match(/dm\.[^.]+\.([a-z0-9_-]+)/i)?.[1]??"—"}function cfe(e){switch(e.state){case"queued":case"waking":case"running":case"waiting":return"running";case"review":return"review";case"completed":return"completed";default:return"abandoned"}}const ufe=["acceptance","artifact","blocker","checkpoint","component","deliverable","divide-and-conquer","execution","implementation","milestone","next move","parallel","phase","plan","proceed","roadmap","scope","ship","spec","task","todo"];function dfe(e,t){if(e.workId&&t.has(e.workId)||e.collaborationRecordId&&t.has(e.collaborationRecordId))return!1;const n=RD(e);if(!n)return!1;const a=n.toLowerCase(),r=/(^|\n)\s*(?:\d+\.|[-*]\s|\[[ x]\])/m.test(n),o=ufe.filter(u=>a.includes(u)).length;return!!((e.state==="queued"||e.state==="waking"||e.state==="running"||e.state==="waiting"||e.state==="review")&&n.length>=80||r&&o>=1||n.length>=360&&o>=2)}function ffe(e,t){const n=RD(e);if(!n)return null;const a=t[e.agentId],r=e.agentName??a?.name??e.agentId,o=`${r}: ${v0(ife(n),120)}`,c=ofe(e)??v0(n);return{id:e.id,source:"run",title:o,summary:c,author:"agent",authorLabel:r,ownerId:e.agentId,project:lfe(e),state:e.state,outcome:cfe(e),route:e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId},taskText:n,createdAt:e.createdAt??e.startedAt??e.updatedAt,updatedAt:e.updatedAt,lastMeaningfulAt:e.updatedAt,parentId:null,parentTitle:null}}function yj(e){return e.source==="work"?"work item":"agent run"}function ID(e){return e.route.view==="work"?`/work/${e.route.workId}`:e.route.view==="conversation"?`/messages/${e.route.conversationId}`:e.route.view==="agents"&&e.route.agentId?`/agents/${e.route.agentId}`:"/ops/plan"}function hfe(e,t){const n=new Map;for(const a of[...e,...t])n.has(a.id)||n.set(a.id,a);return[...n.values()]}function mfe({navigate:e,agents:t}){const{route:n}=qe(),a=AD(),[r,o]=m.useState([]),[c,u]=m.useState([]),[h,f]=m.useState(!0),[g,v]=m.useState(null),[y,x]=m.useState(null),w=m.useRef(0),C=m.useCallback(async()=>{const A=++w.current;try{const[R,_,P]=await Promise.all([me("/api/work?limit=250"),me("/api/work?active=false&limit=250"),me("/api/runs?active=false&limit=500")]);if(A!==w.current)return;o(hfe(R,_)),u(P),x(null),v(Date.now())}catch(R){if(A!==w.current)return;x(R instanceof Error?R.message:String(R))}finally{A===w.current&&f(!1)}},[]);m.useEffect(()=>{C()},[C]),tn(()=>{C()});const T=m.useMemo(()=>Object.fromEntries(t.map(A=>[A.id,A])),[t]),E=m.useMemo(()=>{const A=r.map(rfe),R=new Set(r.map(P=>P.id)),_=c.filter(P=>dfe(P,R)).map(P=>ffe(P,T)).filter(P=>P!==null);return[...A,..._]},[T,c,r]),S=m.useMemo(()=>{const A=E.filter(R=>R.source==="work").length;return{work:A,run:E.length-A}},[E]);m.useEffect(()=>{const A={all:E.length,operator:E.filter($=>$.author==="operator").length,agent:E.filter($=>$.author==="agent").length},R={all:E.length,running:E.filter($=>$.outcome==="running").length,review:E.filter($=>$.outcome==="review").length,completed:E.filter($=>$.outcome==="completed").length,abandoned:E.filter($=>$.outcome==="abandoned").length},_=new Map;for(const $ of E)_.set($.project,(_.get($.project)??0)+1);const P=[..._.entries()].sort(([,$],[,H])=>H-$).map(([$,H])=>({id:$,count:H}));Yde({total:E.length,byAuthor:A,byOutcome:R,byProject:P})},[E]);const k=m.useMemo(()=>{const A=Date.now(),R=MD.find(P=>P.id===a.timeFilter)?.ms??null,_=a.query.trim().toLowerCase();return E.filter(P=>a.authorFilter==="all"||P.author===a.authorFilter).filter(P=>a.outcomeFilter==="all"||P.outcome===a.outcomeFilter).filter(P=>a.projectFilter==="all"||P.project===a.projectFilter).filter(P=>R===null||A-P.lastMeaningfulAt<=R).filter(P=>_?P.title.toLowerCase().includes(_)||(P.summary?.toLowerCase().includes(_)??!1)||P.project.toLowerCase().includes(_)||P.authorLabel.toLowerCase().includes(_):!0).sort((P,$)=>$.lastMeaningfulAt-P.lastMeaningfulAt)},[E,a.authorFilter,a.outcomeFilter,a.projectFilter,a.timeFilter,a.query]),N=g?`${E.length} records · ${S.work} work items · ${S.run} runs · indexed ${Ae(g)}`:h?"Indexing…":"0 records";return s.jsxs("section",{className:"s-plan-main",children:[s.jsxs("header",{className:"s-plan-head",children:[s.jsxs("div",{className:"s-plan-head-left",children:[s.jsx("span",{className:"s-plan-eyebrow",children:"Work archive"}),s.jsx("span",{className:"s-plan-stat",children:N})]}),s.jsxs("div",{className:"s-plan-head-right",children:[s.jsx("input",{type:"search",className:"s-plan-search",placeholder:"Search records, titles, projects…",value:a.query,onChange:A=>TD(A.target.value),spellCheck:!1}),s.jsx("button",{type:"button",className:"s-plan-refresh",onClick:()=>{f(!0),C()},disabled:h,children:h?"Refreshing…":"Refresh"})]})]}),y&&s.jsxs("div",{className:"s-plan-error",children:["Error loading records: ",y]}),s.jsxs("div",{className:"s-plan-table",role:"table",children:[s.jsxs("div",{className:"s-plan-table-head",role:"row",children:[s.jsx("span",{role:"columnheader",children:"Created"}),s.jsx("span",{role:"columnheader",children:"Author"}),s.jsx("span",{role:"columnheader",children:"Record"}),s.jsx("span",{role:"columnheader",children:"Project"}),s.jsx("span",{role:"columnheader",children:"Lifecycle"}),s.jsx("span",{role:"columnheader",children:"Outcome"})]}),k.length===0?s.jsx("div",{className:"s-plan-empty",children:E.length===0?"No records yet.":"No records match these filters."}):k.map(A=>s.jsx(pfe,{record:A,onOpen:()=>Ix(A.id)},A.id))]}),a.focusedPlanId&&s.jsx(gfe,{planId:a.focusedPlanId,record:E.find(A=>A.id===a.focusedPlanId)??null,onClose:()=>Ix(null),onOpenFullPage:()=>{const A=a.focusedPlanId,R=E.find(_=>_.id===A)??null;Ix(null),R&&kt(e,R.route,{returnTo:n})}})]})}function pfe({record:e,onOpen:t}){const n=Ae(e.createdAt),a=Ae(e.lastMeaningfulAt);return s.jsxs("button",{type:"button",role:"row",className:`s-plan-row s-plan-row--${e.outcome}`,onClick:t,...Gr({label:`Open ${e.title}`,route:ID(e)}),children:[s.jsx("span",{className:"s-plan-cell s-plan-cell--time",role:"cell",children:n}),s.jsx("span",{className:"s-plan-cell s-plan-cell--author",role:"cell",children:s.jsx("span",{className:`s-plan-author s-plan-author--${e.author}`,children:e.author==="operator"?"you":e.authorLabel})}),s.jsxs("span",{className:"s-plan-cell s-plan-cell--plan",role:"cell",children:[s.jsxs("span",{className:"s-plan-row-title-line",children:[s.jsx("span",{className:"s-plan-row-title",children:e.title}),s.jsx("span",{className:`s-plan-source s-plan-source--${e.source}`,children:yj(e)})]}),e.summary&&s.jsx("span",{className:"s-plan-row-summary",children:e.summary})]}),s.jsx("span",{className:"s-plan-cell s-plan-cell--project",role:"cell",children:e.project}),s.jsx("span",{className:"s-plan-cell s-plan-cell--life",role:"cell",children:s.jsx(jfe,{record:e})}),s.jsx("span",{className:"s-plan-cell s-plan-cell--outcome",role:"cell",children:s.jsx("span",{className:`s-plan-outcome s-plan-outcome--${e.outcome}`,children:e.outcome==="running"?`running · ${a}`:e.outcome})})]})}function gfe({planId:e,record:t,onClose:n,onOpenFullPage:a}){const{ref:r,onKeyDown:o}=Fw(),[c,u]=m.useState("profile"),[h,f]=m.useState(null),[g,v]=m.useState(!1),[y,x]=m.useState(null);m.useEffect(()=>{let I=!1;return t?.source!=="work"?(f(null),v(!1),x(null),()=>{I=!0}):(v(!0),x(null),me(`/api/work/${encodeURIComponent(e)}`).then(U=>{I||f(U)}).catch(U=>{I||x(U instanceof Error?U.message:String(U))}).finally(()=>{I||v(!1)}),()=>{I=!0})},[e,t?.source]),m.useEffect(()=>{u("profile")},[e,t?.source]);const w=m.useCallback(I=>{if(o(I),I.key==="Escape"){I.preventDefault(),n();return}if(I.key==="1"){u("profile");return}if(t?.source!=="run"){if(I.key==="2"){u("planning");return}if(I.key==="3"){u("execution");return}if(I.key==="4"){u("activity");return}}},[n,o,t?.source]),C=t?.title??h?.title??"Record",T=t?.authorLabel??"—",E=t?.author??"operator",S=h?.inventory?.materials??[],k=m.useMemo(()=>S.filter(I=>rM.has(I.kind)),[S]),N=m.useMemo(()=>S.filter(I=>!rM.has(I.kind)),[S]),A=k.length,R=N.length,_=h?.timeline.length??0,P=t?.source==="run",$={title:"No plan, spec, or doc files detected.",detail:"Scout has a work record here, but did not find attached planning documents in the material inventory."},H={title:"No changed files detected.",detail:"Scout has a work record here, but did not infer code, tests, config, assets, or other execution files."};return s.jsx("div",{className:"s-mission-overlay",onClick:n,children:s.jsxs("div",{ref:r,className:"s-mission-overlay-dialog",role:"dialog","aria-modal":"true","aria-label":`Record ${C}`,onClick:I=>I.stopPropagation(),onKeyDown:w,tabIndex:-1,children:[s.jsxs("header",{className:"s-mission-overlay-header",children:[s.jsxs("div",{className:"s-mission-overlay-identity",children:[s.jsx("span",{className:"s-mission-overlay-handle",children:C}),s.jsxs("span",{className:"s-mission-overlay-sub",children:[t&&s.jsx("span",{className:`s-plan-source s-plan-source--${t.source}`,children:yj(t)}),s.jsx("span",{className:`s-plan-author s-plan-author--${E}`,children:E==="operator"?"you":T}),t?.project&&t.project!=="—"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-mission-overlay-sep",children:"·"}),s.jsx("span",{children:t.project})]}),t&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-mission-overlay-sep",children:"·"}),s.jsx("span",{className:`s-plan-outcome s-plan-outcome--${t.outcome}`,children:t.outcome})]})]})]}),s.jsx("button",{type:"button",className:"s-mission-overlay-close",onClick:n,"aria-label":"Close (Esc)",children:"×"})]}),s.jsxs("div",{className:"s-mission-overlay-tabs",role:"tablist",children:[s.jsx("div",{className:"s-mission-overlay-tabs-group",children:P?s.jsx(Uu,{label:"Run",active:!0,onClick:()=>u("profile")}):s.jsxs(s.Fragment,{children:[s.jsx(Uu,{label:"Profile",active:c==="profile",onClick:()=>u("profile")}),s.jsx(Uu,{label:"Plans/docs",count:A,active:c==="planning",onClick:()=>u("planning")}),s.jsx(Uu,{label:"Files",count:R,active:c==="execution",onClick:()=>u("execution")}),s.jsx(Uu,{label:"Timeline",count:_,active:c==="activity",onClick:()=>u("activity")})]})}),s.jsx("div",{className:"s-mission-overlay-tabs-action",children:s.jsx("button",{type:"button",className:"s-mission-overlay-jump",onClick:a,...Gr({label:t?.source==="run"?`Open conversation · ${C}`:`Open work page · ${C}`,route:t?ID(t):`/work/${e}`}),children:t?.source==="run"?"Open conversation ↗":"Open work page ↗"})})]}),s.jsx("div",{className:"s-mission-overlay-body",children:g&&!h?s.jsx("div",{className:"s-plan-overlay-loading",children:"Loading record…"}):s.jsxs(s.Fragment,{children:[y&&s.jsxs("div",{className:"s-plan-error",children:["Error loading record: ",y]}),P?s.jsx(aM,{record:t,detail:h}):s.jsxs(s.Fragment,{children:[c==="profile"&&s.jsx(aM,{record:t,detail:h}),c==="planning"&&s.jsx(iM,{workId:e,materials:k,empty:$}),c==="execution"&&s.jsx(iM,{workId:e,materials:N,empty:H}),c==="activity"&&s.jsx(bfe,{record:t,detail:h})]})]})})]})})}function Uu({label:e,count:t,active:n,onClick:a}){return s.jsxs("button",{type:"button",role:"tab","aria-selected":n,className:`s-mission-overlay-tab${n?" s-mission-overlay-tab--active":""}`,onClick:a,children:[e,typeof t=="number"&&s.jsxs(s.Fragment,{children:[" ",s.jsx("span",{className:`s-mission-overlay-tab-count${t===0?" s-mission-overlay-tab-count--empty":""}`,children:t})]})]})}function aM({record:e,detail:t}){const n=[["TITLE",e?.title??t?.title??"—"],["TYPE",e?yj(e):t?"work item":"—"],["AUTHOR",e?.authorLabel??t?.ownerName??"—"],["PROJECT",e?.project??"—"],["STATE",e?.state??t?.state??"—"],["OUTCOME",e?.outcome??"—"],["CREATED",e?.createdAt?Ae(e.createdAt):t?.createdAt?Ae(t.createdAt):"—"],["LAST ACTION",e?.lastMeaningfulAt?Ae(e.lastMeaningfulAt):"—"]],a=e?.summary??t?.summary??t?.lastMeaningfulSummary??null,r=e?.parentTitle??t?.parentTitle??null;return s.jsxs("div",{className:"s-focus-tab",children:[a&&s.jsx("p",{className:"s-plan-overlay-summary",children:a}),e?.taskText&&e.taskText!==a&&s.jsx("p",{className:"s-plan-overlay-summary",children:v0(e.taskText,900)}),s.jsxs("dl",{className:"s-focus-spec",children:[n.map(([o,c])=>s.jsxs("div",{className:"s-focus-spec-row",children:[s.jsx("dt",{className:"s-focus-spec-label",children:o}),s.jsx("dd",{className:"s-focus-spec-value",title:c,children:c})]},o)),r&&s.jsxs("div",{className:"s-focus-spec-row",children:[s.jsx("dt",{className:"s-focus-spec-label",children:"PARENT"}),s.jsx("dd",{className:"s-focus-spec-value",title:r,children:r})]})]})]})}const rM=new Set(["plan","spec","doc"]),vfe=["node_modules/","dist/","build/",".git/","vendor/",".next/",".cache/"];function yfe(e){const t=e.toLowerCase();return vfe.some(n=>t.includes(n))}function iM({workId:e,materials:t,empty:n}){const[a,r]=m.useState(null),o=m.useMemo(()=>t.filter(u=>!yfe(u.path)),[t]),c=t.length-o.length;if(o.length===0&&t.length===0)return s.jsx(_D,{title:n.title,detail:n.detail});if(a){const u=o.find(h=>h.id===a);return u?s.jsxs("div",{className:"s-plan-materials-reader-pane",children:[s.jsxs("header",{className:"s-plan-materials-back-bar",children:[s.jsxs("button",{type:"button",className:"s-plan-materials-back",onClick:()=>r(null),children:["← Back to ",o.length," files"]}),s.jsx("span",{className:"s-plan-materials-back-path",title:u.path,children:u.path})]}),s.jsx(xfe,{workId:e,material:u})]}):(setTimeout(()=>r(null),0),null)}return s.jsxs("div",{className:"s-plan-materials-table-wrap",children:[s.jsxs("div",{className:"s-plan-materials-table",role:"table",children:[s.jsxs("div",{className:"s-plan-materials-table-head",role:"row",children:[s.jsx("span",{role:"columnheader",children:"Kind"}),s.jsx("span",{role:"columnheader",children:"Path"}),s.jsx("span",{role:"columnheader",children:"Status"}),s.jsx("span",{role:"columnheader",children:"Diff"})]}),o.map(u=>s.jsxs("button",{type:"button",role:"row",className:"s-plan-materials-table-row",onClick:()=>r(u.id),title:u.path,children:[s.jsx("span",{className:`s-plan-materials-kind s-plan-materials-kind--${u.kind}`,role:"cell",children:u.kind}),s.jsx("span",{className:"s-plan-materials-path",role:"cell",children:u.path}),s.jsx("span",{className:`s-plan-materials-status s-plan-materials-status--${u.status}`,role:"cell",children:u.status}),s.jsx("span",{className:"s-plan-materials-diff",role:"cell",children:u.diffStat&&(u.diffStat.additions>0||u.diffStat.deletions>0)?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"s-plan-overlay-material-diff-add",children:["+",u.diffStat.additions]}),s.jsxs("span",{className:"s-plan-overlay-material-diff-del",children:["−",u.diffStat.deletions]})]}):s.jsx("span",{className:"s-plan-materials-diff-none",children:"—"})})]},u.id))]}),c>0&&s.jsxs("div",{className:"s-plan-materials-hidden-note",children:[c," path",c===1?"":"s"," hidden (node_modules, dist, build, .git, vendor)"]})]})}function xfe({workId:e,material:t}){const[n,a]=m.useState(null),[r,o]=m.useState(!0),[c,u]=m.useState(null);if(m.useEffect(()=>{let f=!1;return o(!0),a(null),u(null),me(`/api/work/${encodeURIComponent(e)}/material?materialId=${encodeURIComponent(t.id)}`).then(g=>{f||a(g)}).catch(g=>{f||u(g instanceof Error?g.message:String(g))}).finally(()=>{f||o(!1)}),()=>{f=!0}},[e,t.id]),r&&!n)return s.jsxs("div",{className:"s-plan-overlay-empty",children:["Loading ",t.path.split("/").pop(),"…"]});if(c)return s.jsxs("div",{className:"s-plan-error",children:["Error loading file: ",c]});if(!n)return s.jsx("div",{className:"s-plan-overlay-empty",children:"No content."});const h=zc({id:n.materialId,title:n.title,uri:n.uri,mediaType:n.mediaType,value:n.content});return s.jsxs("div",{className:"s-plan-materials-reader-inner",children:[s.jsxs("header",{className:"s-plan-materials-reader-head",children:[s.jsx("span",{className:"s-plan-materials-reader-title",children:n.title}),s.jsxs("span",{className:"s-plan-materials-reader-meta",children:[n.mediaType,n.truncated&&" · truncated"]})]}),s.jsx("div",{className:"s-plan-materials-reader-body",children:s.jsx(Qd,{document:h,mode:"preview"})})]})}function _D({title:e,detail:t}){return s.jsxs("div",{className:"s-plan-overlay-empty",children:[s.jsx("div",{className:"s-plan-overlay-empty-title",children:e}),t&&s.jsx("div",{className:"s-plan-overlay-empty-detail",children:t})]})}function bfe({record:e,detail:t}){const n=t?.timeline??[];return n.length===0?s.jsx(_D,{title:"No timeline events recorded.",detail:e?.source==="run"?"This row is an archived agent run. Open the conversation to inspect the run's surrounding messages.":"Scout only has the current record state and summary for this work item."}):s.jsx("ul",{className:"s-plan-overlay-timeline",children:n.slice(-20).reverse().map(a=>s.jsx(wfe,{event:a},a.id))})}function wfe({event:e}){return s.jsxs("li",{className:`s-plan-overlay-timeline-row s-plan-overlay-timeline-row--${e.kind}`,children:[s.jsx("span",{className:"s-plan-overlay-timeline-time",children:Ae(e.at)}),s.jsx("span",{className:"s-plan-overlay-timeline-kind",children:e.detailKind??e.kind}),s.jsx("span",{className:"s-plan-overlay-timeline-text",children:e.title||e.summary||e.actorName||e.kind})]})}function jfe({record:e}){const t=e.createdAt,n=e.lastMeaningfulAt,a=Math.max(1,n-t),r=Math.round(a/(3600*1e3)),o=Math.round(a/(1440*60*1e3)),c=o>=2?`${o}d`:r>=1?`${r}h`:"<1h";return s.jsxs("span",{className:`s-plan-life s-plan-life--${e.outcome}`,"aria-label":`Span ${c}`,children:[s.jsx("span",{className:"s-plan-life-dot s-plan-life-dot--start"}),s.jsx("span",{className:"s-plan-life-bar"}),s.jsx("span",{className:`s-plan-life-dot s-plan-life-dot--end s-plan-life-dot--${e.outcome}`}),s.jsx("span",{className:"s-plan-life-span",children:c})]})}const oM=4e3,Nfe=500,kfe=5e3,Sfe=5e3,Cfe=6e4,Ap={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},xj={tool:"working",run:"active",idle:"idle"};function y0(e){const t=e.split(/\s+/)[0]??"",n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function Efe(e,t=60){const n=e.split(/\s+/);if(n.length===0)return e;n[0]=y0(n[0]);const a=n.join(" ");return a.length<=t?a:a.slice(0,t-1)+"…"}function Afe(e){for(const t of e){const n=y0(t.command);if(n&&!(n==="sh"||n==="zsh"||n==="bash"||n==="login"))return n}return e[0]?.command?y0(e[0].command):"—"}function Tfe(e){const t=e.match(/^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/);if(!t){const u=e.match(/^(\d+)$/);return u?Number.parseInt(u[1],10):0}const[,n,a,r,o]=t;let c=Number.parseInt(o,10)+Number.parseInt(r,10)*60;return a&&(c+=Number.parseInt(a,10)*3600),n&&(c+=Number.parseInt(n,10)*86400),c}function OD(e){if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m${String(e%60).padStart(2,"0")}`;if(e<86400){const a=Math.floor(e/3600),r=Math.floor(e%3600/60);return`${a}h${String(r).padStart(2,"0")}`}const t=Math.floor(e/86400),n=Math.floor(e%86400/3600);return`${t}d${String(n).padStart(2,"0")}h`}function $D(e,t){if(e==null)return"—";const n=Math.max(0,Math.round((t-e)/1e3));return n<2?"just now":n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:`${Math.floor(n/3600)}h ago`}function Mfe(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function x0(e){return e?e.slice(0,8):"—"}function PD(e){return e?.trim().toLowerCase()||"unknown"}function Rfe(e){return PD(e).replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function bj(e){return`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${Rfe(e)}`}const Ife=/permission-mode/i;function lM(e){return e.kind!=="system"?!1:Ife.test(e.summary)}function b0(e){return e.kind==="assistant"}function _fe(e,t,n){if(!e)return[];const a=new Map,r=new Map;for(const y of t){let x=a.get(y.pid);if(x||(x={firstEventAt:y.ts,lastEventAt:y.ts,lastKind:y.kind,lastSummary:y.summary,reqCount:0,toolCount:0,permCount:0,eventCount:0,sessionId:y.sessionId||null,model:null,tokIn:null,tokOut:null,cacheReadIn:null,cacheWriteIn:null},a.set(y.pid,x)),y.ts<x.firstEventAt&&(x.firstEventAt=y.ts),y.ts>=x.lastEventAt&&(x.lastEventAt=y.ts,x.lastKind=y.kind,x.lastSummary=y.summary),x.eventCount++,y.kind==="tool"&&x.toolCount++,b0(y)&&x.reqCount++,lM(y)&&x.permCount++,y.sessionId&&!x.sessionId&&(x.sessionId=y.sessionId),y.sessionId){let w=r.get(y.sessionId);w||(w={firstEventAt:y.ts,lastEventAt:y.ts,lastKind:y.kind,lastSummary:y.summary,reqCount:0,toolCount:0,permCount:0,eventCount:0,sessionId:y.sessionId,model:null,tokIn:null,tokOut:null,cacheReadIn:null,cacheWriteIn:null},r.set(y.sessionId,w)),y.ts<w.firstEventAt&&(w.firstEventAt=y.ts),y.ts>=w.lastEventAt&&(w.lastEventAt=y.ts,w.lastKind=y.kind,w.lastSummary=y.summary),w.eventCount++,y.kind==="tool"&&w.toolCount++,b0(y)&&w.reqCount++,lM(y)&&w.permCount++}}const o=new Map;for(const y of e.processes){if(!y.cwd)continue;const x=_x(y.source,y.cwd),w=o.get(x);(!w||y.pid<w.pid)&&o.set(x,y)}const c=new Map,u=new Map;for(const y of e.transcripts??[]){const x=_x(y.source,y.cwd),w=cM(y),C=u.get(x)??Number.NEGATIVE_INFINITY,T=c.get(x)??"";(y.mtimeMs>C||y.mtimeMs===C&&w>T)&&(u.set(x,y.mtimeMs),c.set(x,w))}const h=new Set,f=(y,x,w,C)=>{x&&h.add(x.pid);let T="idle";const E=Math.max(w?.lastEventAt??0,C?.mtimeMs??0);w&&n-w.lastEventAt<Sfe&&(T=w.lastKind==="tool"?"tool":"run"),T==="idle"&&n-E<6e4&&(T="run");const S=x?Tfe(x.etime):0,k=w?.firstEventAt??null,N=w&&w.firstEventAt<w.lastEventAt?Math.min(Math.max(0,Math.round((w.lastEventAt-w.firstEventAt)/1e3)),S||Number.POSITIVE_INFINITY):0,A=x?.pid??Pfe(y),R=C?.cwd??x?.cwd??"";return{key:y,pid:A,ppid:x?.ppid??0,sessionId:C?.sessionId??w?.sessionId??null,transcriptPath:C?.transcriptPath??null,harness:PD(C?.source??x?.source),attribution:x?.harness??C?.harness??"unattributed",project:C?.project?.trim()||(R?Ofe(R):"(unknown)"),cwd:R,command:x?.command??`${C?.source??"unknown"} transcript`,parentLabel:x?Afe(x.parentChain??[]):"transcript",procRuntimeSec:S,procEtime:x?.etime??"0",sessionStartAt:k,sessionRuntimeSec:N,status:T,lastEventAt:E||null,lastEventKind:w?.lastKind??null,lastSummary:w?.lastSummary??null,reqCount:w?.reqCount??0,toolCount:w?.toolCount??0,permCount:w?.permCount??0,eventCount:w?.eventCount??0,model:w?.model??null,tokIn:w?.tokIn??null,tokOut:w?.tokOut??null,cacheReadIn:w?.cacheReadIn??null,cacheWriteIn:w?.cacheWriteIn??null}},g=(e.transcripts??[]).map(y=>{const x=cM(y),w=_x(y.source,y.cwd),C=c.get(w)===x?o.get(w)??null:null,T=y.sessionId?r.get(y.sessionId):void 0;return f(x,C,T,y)}),v=e.processes.filter(y=>!h.has(y.pid)).map(y=>f($fe(y),y,a.get(y.pid),null));return[...g,...v]}function Ac(e){if(e.cacheReadIn==null||e.tokIn==null)return null;const t=e.cacheReadIn+e.tokIn;return t===0?null:e.cacheReadIn/t}function Ro(e){return e==null?"—":e===0?"0":e>=1e6?(e/1e6).toFixed(e>=1e7?0:1)+"M":e>=1e3?(e/1e3).toFixed(e>=1e4?0:1)+"k":String(e)}function DD(e){return e==null?"—":`${Math.round(e*100)}%`}function Ofe(e){if(!e)return"";const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function cM(e){return`session:${e.source}:${e.sessionId??e.transcriptPath}`}function $fe(e){return`process:${e.source}:${e.pid}`}function Pfe(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return-((t>>>0)%9e5+1e3)}function _x(e,t){return`${e}\0${t??""}`}function Dfe(e,t,n){const a=n-Cfe;let r=0;for(const u of t)b0(u)&&u.ts>=a&&r++;const o={total:e.length,running:0,tooling:0,idle:0,harnesses:[],reqsPerMin:r},c=new Map;for(const u of e)u.status==="tool"?(o.tooling++,o.running++):u.status==="run"?o.running++:o.idle++,c.set(u.harness,(c.get(u.harness)??0)+1);return o.harnesses=[...c.entries()].map(([u,h])=>({harness:u,count:h})).sort((u,h)=>h.count-u.count||u.harness.localeCompare(h.harness)),o}const Dd={tool:0,run:1,idle:2};function Hl(e){return e??-1}function Lfe(e,t,n,a){switch(n){case"status":return(Dd[e.status]-Dd[t.status])*a;case"agent":{const r=e.harness.localeCompare(t.harness);return r!==0?r*a:(e.sessionId??"").localeCompare(t.sessionId??"")*a}case"project":return e.project.localeCompare(t.project)*a;case"reqs":return(e.reqCount-t.reqCount)*a;case"tokIn":return(Hl(e.tokIn)-Hl(t.tokIn))*a;case"tokOut":return(Hl(e.tokOut)-Hl(t.tokOut))*a;case"cache":return(Hl(Ac(e))-Hl(Ac(t)))*a;case"tools":return(e.toolCount-t.toolCount)*a;case"perms":return(e.permCount-t.permCount)*a;case"last":{const r=e.lastEventAt??0,o=t.lastEventAt??0;return(r-o)*a}case"runtime":return(e.sessionRuntimeSec-t.sessionRuntimeSec)*a}}function uM({values:e,color:t}){if(e.length<2)return s.jsx("svg",{className:"s-atop-spark",width:88,height:18,viewBox:"0 0 88 18"});const r=Math.max(1,...e),o=88/(e.length-1),c=e.map((u,h)=>`${(h*o).toFixed(1)},${(18-u/r*18).toFixed(1)}`).join(" ");return s.jsx("svg",{className:"s-atop-spark",width:88,height:18,viewBox:"0 0 88 18",children:s.jsx("polyline",{fill:"none",stroke:t,strokeWidth:"1.25",points:c})})}function zfe(){const[e,t]=m.useState([]),[n,a]=m.useState(null),[r,o]=m.useState(()=>Date.now()),[c,u]=m.useState(""),[h,f]=m.useState(()=>new Set),[g,v]=m.useState(()=>new Set),[y,x]=m.useState({key:"status",dir:1}),[w,C]=m.useState(null),T=m.useRef([]),E=m.useRef([]),[S,k]=m.useState([]),[N,A]=m.useState([]),R=m.useCallback(W=>{t(L=>L.length>=oM?[...L.slice(L.length-oM+1),W]:[...L,W])},[]);nf(R),m.useEffect(()=>{let W=!1;return(async()=>{try{const L=await me(`/api/tail/recent?limit=${Nfe}`);W||t(L.events??[])}catch{}})(),()=>{W=!0}},[]);const _=m.useCallback(async()=>{try{const W=await me("/api/tail/discover");a(W)}catch{}},[]);m.useEffect(()=>{_();const W=setInterval(()=>{_()},kfe);return()=>clearInterval(W)},[_]),m.useEffect(()=>{const W=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(W)},[]);const P=m.useMemo(()=>_fe(n,e,r),[n,e,r]),$=m.useMemo(()=>Dfe(P,e,r),[P,e,r]);m.useEffect(()=>{T.current=[...T.current,$.running].slice(-24),E.current=[...E.current,$.tooling].slice(-24),k(T.current),A(E.current)},[$.running,$.tooling]);const H=m.useMemo(()=>{const W=new Set;return P.forEach(L=>W.add(L.harness)),[...W]},[P]),I=m.useMemo(()=>{const W=new Set;return P.forEach(L=>W.add(L.status)),[...W]},[P]),U=m.useMemo(()=>{const W=c.trim().toLowerCase();return P.filter(L=>{if(h.size>0&&!h.has(L.harness)||g.size>0&&!g.has(L.status))return!1;if(!W)return!0;const q=Ap[L.attribution];return`${L.pid} ${L.project} ${L.command} ${L.harness} ${L.attribution} ${q} ${L.sessionId??""} ${L.transcriptPath??""} ${L.lastSummary??""}`.toLowerCase().includes(W)})},[P,c,h,g]),D=m.useMemo(()=>y.key==="status"?void 0:(W,L)=>Dd[W.status]-Dd[L.status],[y.key]),V=m.useMemo(()=>U.map((W,L)=>({row:W,index:L})).sort((W,L)=>{const q=Lfe(W.row,L.row,y.key,y.dir);if(q!==0)return q;const K=D?.(W.row,L.row)??0;return K!==0?K:W.index-L.index}).map(W=>W.row),[U,y,D]);m.useEffect(()=>{w!=null&&(P.some(W=>W.key===w)||C(null))},[P,w]),m.useEffect(()=>{const W=L=>{const q=L.target,K=q instanceof HTMLInputElement||q instanceof HTMLTextAreaElement||(q?.isContentEditable??!1);if(L.key==="Escape"&&w!=null){L.preventDefault(),C(null);return}if(K)return;const ee=L.key==="j"||L.key==="ArrowDown",G=L.key==="k"||L.key==="ArrowUp";if(ee||G){if(V.length===0)return;L.preventDefault();const re=V.findIndex(ae=>ae.key===w),Q=ee?V[Math.min(V.length-1,re<0?0:re+1)]:V[Math.max(0,re<0?0:re-1)];Q&&C(Q.key);return}if(L.key==="Enter"&&w!=null){L.preventDefault();return}};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[V,w]);const Z=W=>{f(L=>{const q=new Set(L);return q.has(W)?q.delete(W):q.add(W),q})},O=W=>{v(L=>{const q=new Set(L);return q.has(W)?q.delete(W):q.add(W),q})},z=m.useMemo(()=>w!=null?P.find(W=>W.key===w)??null:null,[P,w]),B=m.useMemo(()=>z?n?.processes.find(W=>W.pid===z.pid)??null:null,[n,z]),X=m.useMemo(()=>z?e.filter(W=>z.sessionId?W.sessionId===z.sessionId:W.pid===z.pid).slice(-40):[],[e,z]);return s.jsxs("div",{className:"s-atop",children:[s.jsx(Bfe,{summary:$,runHistory:S,toolHistory:N}),s.jsx(MP,{title:"Harness families",size:"compact",maxAgents:6,maxTasks:3}),s.jsx(Ufe,{search:c,onSearch:u,harnessOptions:H,harnessFilter:h,onToggleHarness:Z,statusOptions:I,statusFilter:g,onToggleStatus:O,summary:$}),s.jsx(ug,{rows:U,columns:Ffe,rowId:W=>W.key,storageKey:"openscout.atop.cols",sort:y,onSortChange:x,secondarySort:D,onRowClick:W=>C(W.key),rowClassName:W=>w===W.key?"s-atop-row--selected":void 0,empty:{title:"no agents match",body:"adjust filters or start a session to populate"},density:"compact",className:"s-atop-data-table",ariaLabel:"Agent activity inventory"}),s.jsx(Hfe,{shown:V.length,total:P.length,hasSelection:w!=null}),z&&s.jsx(qfe,{row:z,process:B,events:X,now:r,onClose:()=>C(null)})]})}function Bfe({summary:e,runHistory:t,toolHistory:n}){return s.jsxs("div",{className:"s-atop-summary",children:[s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--primary",children:[s.jsxs("div",{className:"s-atop-summary-num",children:[s.jsx("strong",{children:e.running}),s.jsxs("span",{className:"s-atop-summary-of",children:["/ ",e.total]})]}),s.jsx("span",{className:"s-atop-summary-lbl",children:"active"}),s.jsx(uM,{values:t,color:"var(--green)"})]}),s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:e.tooling})}),s.jsx("span",{className:"s-atop-summary-lbl",children:"working"}),s.jsx(uM,{values:n,color:"var(--accent)"})]}),s.jsxs("div",{className:"s-atop-summary-cell",children:[s.jsx("div",{className:"s-atop-summary-num",children:s.jsx("strong",{children:e.idle})}),s.jsx("span",{className:"s-atop-summary-lbl",children:"idle"})]}),s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--breakdown",children:[s.jsx("span",{className:"s-atop-summary-lbl",children:"harness"}),s.jsx("div",{className:"s-atop-summary-row",children:e.harnesses.length>0?e.harnesses.slice(0,4).map(a=>s.jsxs("span",{className:bj(a.harness),children:[a.harness," ",a.count]},a.harness)):s.jsx("span",{className:"s-atop-chip s-atop-chip--mute",children:"none"})})]}),s.jsx("div",{className:"s-atop-summary-spacer"}),s.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--rate",children:[s.jsxs("div",{className:"s-atop-summary-num",children:[s.jsx("strong",{children:e.reqsPerMin}),s.jsx("span",{className:"s-atop-summary-of",children:"/ min"})]}),s.jsx("span",{className:"s-atop-summary-lbl",children:"requests"})]})]})}function Ufe({search:e,onSearch:t,harnessOptions:n,harnessFilter:a,onToggleHarness:r,statusOptions:o,statusFilter:c,onToggleStatus:u,summary:h}){const f=y=>h.harnesses.find(x=>x.harness===y)?.count??0,g=y=>y==="tool"?h.tooling:y==="run"?h.running-h.tooling:h.idle,v=m.useRef(null);return m.useEffect(()=>{const y=x=>{if(x.key!=="/")return;const w=x.target;w instanceof HTMLInputElement||w instanceof HTMLTextAreaElement||(w?.isContentEditable??!1)||(x.preventDefault(),v.current?.focus())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]),s.jsxs("div",{className:"s-atop-fbar",children:[s.jsxs("div",{className:"s-atop-search",children:[s.jsx("span",{className:"s-atop-search-prompt",children:"▸"}),s.jsx("input",{ref:v,className:"s-atop-search-input",value:e,onChange:y=>t(y.target.value),placeholder:"filter by pid · project · command · summary",spellCheck:!1}),s.jsx("span",{className:"s-atop-search-kbd",children:"/"})]}),n.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"harness"}),n.map(y=>{const x=a.has(y);return s.jsxs("button",{className:`s-atop-pill s-atop-pill--harness${x?" s-atop-pill--on":""}`,onClick:()=>r(y),children:[y,s.jsx("span",{className:"s-atop-pill-ct",children:f(y)})]},y)})]}),o.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"s-atop-fbar-label",children:"status"}),["tool","run","idle"].filter(y=>o.includes(y)).map(y=>{const x=c.has(y);return s.jsxs("button",{className:`s-atop-pill s-atop-pill--status-${y}${x?" s-atop-pill--on":""}`,onClick:()=>u(y),children:[xj[y],s.jsx("span",{className:"s-atop-pill-ct",children:g(y)})]},y)})]}),s.jsx("div",{className:"s-atop-fbar-spacer"})]})}const Ffe=[{key:"status",label:"Status",cls:"s-atop-col-status",kind:"text",defaultWidth:96,minWidth:70,sortValue:e=>Dd[e.status],render:e=>s.jsxs("span",{className:`s-atop-status s-atop-status--${e.status}`,children:[s.jsx("span",{className:"s-atop-status-dot"}),xj[e.status]]})},{key:"agent",label:"Agent",cls:"s-atop-col-agent",kind:"text",tip:"Harness · short session id",defaultWidth:168,minWidth:110,sortValue:e=>`${e.harness}\0${e.sessionId??""}`,render:e=>s.jsxs("div",{className:"s-atop-agent-cell",children:[s.jsx("span",{className:bj(e.harness),title:`origin: ${Ap[e.attribution]}`,children:e.harness}),s.jsx("span",{className:"s-atop-agent-id",title:e.sessionId??`pid ${e.pid}`,children:x0(e.sessionId)})]})},{key:"project",label:"Project",cls:"s-atop-col-project",kind:"text",defaultWidth:200,minWidth:96,maxWidth:480,sortValue:e=>e.project,render:e=>s.jsx("span",{title:e.cwd,children:e.project})},{key:"reqs",label:"Reqs",cls:"s-atop-col-num",kind:"number",tip:"Model invocations (assistant turns) for this session",defaultWidth:64,minWidth:56,sortValue:e=>e.reqCount,render:e=>s.jsx(Fu,{value:e.reqCount||null})},{key:"tokIn",label:"Tok ↓",cls:"s-atop-col-num",kind:"number",tip:"Input tokens — populated when backend emits usage",defaultWidth:64,minWidth:56,sortValue:e=>e.tokIn,render:e=>s.jsx(Fu,{value:e.tokIn})},{key:"tokOut",label:"Tok ↑",cls:"s-atop-col-num",kind:"number",tip:"Output tokens — populated when backend emits usage",defaultWidth:64,minWidth:56,sortValue:e=>e.tokOut,render:e=>s.jsx(Fu,{value:e.tokOut})},{key:"cache",label:"Cache",cls:"s-atop-col-num",kind:"number",tip:"Cache hit rate — populated when backend emits usage",defaultWidth:64,minWidth:56,sortValue:e=>Ac(e),render:e=>s.jsx(Vfe,{value:Ac(e)})},{key:"tools",label:"Tools",cls:"s-atop-col-num",kind:"number",defaultWidth:64,minWidth:56,sortValue:e=>e.toolCount,render:e=>s.jsx(Fu,{value:e.toolCount||null})},{key:"perms",label:"Perms",cls:"s-atop-col-num",kind:"number",tip:"Permission requests — heuristic count of permission-mode events",defaultWidth:64,minWidth:56,sortValue:e=>e.permCount,render:e=>s.jsx(Fu,{value:e.permCount||null,accent:e.permCount>0?"amber":void 0})},{key:"last",label:"Last",cls:"s-atop-col-last",kind:"time",defaultWidth:86,minWidth:64,sortValue:e=>e.lastEventAt,render:e=>$D(e.lastEventAt,Date.now())},{key:"runtime",label:"Runtime",cls:"s-atop-col-runtime",kind:"number",tip:"Session duration (active period in current buffer)",defaultWidth:80,minWidth:64,sortValue:e=>e.sessionRuntimeSec,render:e=>OD(e.sessionRuntimeSec)}];function Fu({value:e,accent:t}){const n=e==null?"s-atop-col-num s-atop-col-num--dim":`s-atop-col-num${t?` s-atop-col-num--${t}`:""}`;return s.jsx("span",{className:n,children:Ro(e)})}function Vfe({value:e}){const t=e==null?"s-atop-col-num s-atop-col-num--dim":"s-atop-col-num";return s.jsx("span",{className:t,children:DD(e)})}function Hfe({shown:e,total:t,hasSelection:n}){return s.jsxs("div",{className:"s-atop-keys",children:[s.jsxs("span",{className:"s-atop-keys-count",children:[s.jsx("strong",{children:e})," / ",t," agents"]}),s.jsx("span",{className:"s-atop-keys-spacer"}),s.jsxs("span",{children:[s.jsx("kbd",{children:"/"})," filter"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"j"}),"/",s.jsx("kbd",{children:"k"})," select"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"click"})," drill in"]}),n&&s.jsxs("span",{children:[s.jsx("kbd",{children:"esc"})," close"]})]})}function qfe({row:e,process:t,events:n,now:a,onClose:r}){const o=m.useMemo(()=>{const u={};for(const g of n){if(g.kind!=="tool")continue;const v=g.summary.match(/^([a-z_][a-z0-9_]*)/i),y=v?v[1]:"(tool)";u[y]=(u[y]??0)+1}const h=Object.entries(u).sort((g,v)=>v[1]-g[1]).slice(0,6),f=Math.max(1,...h.map(g=>g[1]));return h.map(([g,v])=>({name:g,count:v,frac:v/f}))},[n]),c=n.slice(-40).reverse();return s.jsxs("aside",{className:"s-atop-drawer","aria-label":`Agent ${e.key}`,children:[s.jsxs("header",{className:"s-atop-drawer-head",children:[s.jsxs("div",{className:"s-atop-drawer-head-meta",children:[s.jsxs("span",{className:`s-atop-status s-atop-status--${e.status}`,children:[s.jsx("span",{className:"s-atop-status-dot"}),xj[e.status]]}),s.jsx("span",{className:"s-atop-drawer-pid",children:e.pid>0?`pid ${e.pid}`:"transcript"}),s.jsx("span",{className:bj(e.harness),title:`origin: ${Ap[e.attribution]}`,children:e.harness}),s.jsxs("span",{className:"s-atop-drawer-session",children:["session ",x0(e.sessionId)]})]}),s.jsx("h2",{className:"s-atop-drawer-title",children:e.project}),s.jsxs("p",{className:"s-atop-drawer-sub",children:["session ",x0(e.sessionId)," · runtime ",OD(e.sessionRuntimeSec)," · last activity ",$D(e.lastEventAt,a)]}),s.jsx("button",{className:"s-atop-drawer-close",onClick:r,"aria-label":"Close (Esc)",children:"✕"})]}),s.jsxs("div",{className:"s-atop-drawer-body",children:[s.jsxs("section",{children:[s.jsx("h3",{className:"s-atop-drawer-h3",children:"Activity"}),s.jsxs("div",{className:"s-atop-metrics",children:[s.jsx(ki,{label:"Requests",value:Ro(e.reqCount||null)}),s.jsx(ki,{label:"Tools",value:Ro(e.toolCount||null)}),s.jsx(ki,{label:"Permissions",value:Ro(e.permCount||null),accent:e.permCount>0?"amber":void 0}),s.jsx(ki,{label:"Tok in",value:Ro(e.tokIn),dim:e.tokIn==null}),s.jsx(ki,{label:"Tok out",value:Ro(e.tokOut),dim:e.tokOut==null}),s.jsx(ki,{label:"Cache hit",value:DD(Ac(e)),dim:Ac(e)==null}),s.jsx(ki,{label:"Model",value:e.model??"—",dim:e.model==null}),s.jsx(ki,{label:"Events",value:Ro(e.eventCount||null)})]})]}),o.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"s-atop-drawer-h3",children:"Tool calls"}),s.jsx("ul",{className:"s-atop-histo",children:o.map(u=>s.jsxs("li",{children:[s.jsx("span",{className:"s-atop-histo-name",children:u.name}),s.jsx("span",{className:"s-atop-histo-bar",children:s.jsx("span",{className:"s-atop-histo-fill",style:{width:`${(u.frac*100).toFixed(1)}%`}})}),s.jsx("span",{className:"s-atop-histo-count",children:u.count})]},u.name))})]}),s.jsxs("section",{children:[s.jsxs("h3",{className:"s-atop-drawer-h3",children:["Recent activity",s.jsxs("span",{className:"s-atop-drawer-h3-aside",children:[n.length," buffered"]})]}),c.length===0?s.jsx("div",{className:"s-atop-peek-empty",children:"no events buffered for this agent yet"}):s.jsx("ol",{className:"s-atop-peek",children:c.map(u=>s.jsxs("li",{className:`s-atop-peek-row s-atop-peek-row--${u.kind}`,children:[s.jsx("span",{className:"s-atop-peek-time",children:Mfe(u.ts)}),s.jsx("span",{className:"s-atop-peek-kind",children:u.kind}),s.jsx("span",{className:"s-atop-peek-text",children:u.summary})]},u.id))})]}),s.jsxs("section",{className:"s-atop-drawer-section--secondary",children:[s.jsx("h3",{className:"s-atop-drawer-h3",children:"Process"}),s.jsx("code",{className:"s-atop-codeblock",children:e.command}),s.jsxs("dl",{className:"s-atop-kvs",children:[s.jsx("dt",{children:"PID"}),s.jsx("dd",{children:e.pid>0?e.pid:"transcript-only"}),s.jsx("dt",{children:"Parent"}),s.jsxs("dd",{children:[e.parentLabel," (ppid ",e.ppid,")"]}),s.jsx("dt",{children:"Process etime"}),s.jsx("dd",{children:e.procEtime}),e.transcriptPath&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Transcript"}),s.jsx("dd",{children:e.transcriptPath})]}),s.jsx("dt",{children:"Origin"}),s.jsx("dd",{children:Ap[e.attribution]}),s.jsx("dt",{children:"CWD"}),s.jsx("dd",{children:e.cwd||"(none)"})]}),t?.parentChain&&t.parentChain.length>0&&s.jsx("ol",{className:"s-atop-chain",children:t.parentChain.map(u=>s.jsxs("li",{children:[s.jsx("span",{className:"s-atop-chain-pid",children:u.pid}),s.jsx("span",{className:"s-atop-chain-cmd",children:Efe(u.command,80)})]},u.pid))})]})]})]})}function ki({label:e,value:t,dim:n,accent:a}){const r=`s-atop-metric${n?" s-atop-metric--dim":""}${a?` s-atop-metric--${a}`:""}`;return s.jsxs("div",{className:r,children:[s.jsx("span",{className:"s-atop-metric-lbl",children:e}),s.jsx("span",{className:"s-atop-metric-val",children:t})]})}const Wfe=e=>e==="right"?"railOccupantRight":"railOccupantBottom";function Gfe(e,t,n,a){m.useEffect(()=>{if(!n||typeof window>"u"||typeof document>"u")return;const r=Wfe(e),o=document.body.dataset[r];document.body.dataset[r]=t,window.dispatchEvent(new CustomEvent("hudson:rail:claim",{detail:{owner:t,side:e}})),o&&o!==t&&window.dispatchEvent(new CustomEvent("hudson:rail:preempted",{detail:{owner:o,side:e,by:t}}));const c=h=>{const f=h.detail;f&&f.side===e&&f.owner!==t&&a?.()},u=h=>{const f=h.detail;f&&f.side===e&&f.owner===t&&a?.()};return window.addEventListener("hudson:rail:claim",c),window.addEventListener("hudson:rail:preempted",u),()=>{window.removeEventListener("hudson:rail:claim",c),window.removeEventListener("hudson:rail:preempted",u),document.body.dataset[r]===t&&delete document.body.dataset[r],window.dispatchEvent(new CustomEvent("hudson:rail:release",{detail:{owner:t,side:e}}))}},[e,t,n,a])}const Zfe=620,Kfe=360,Yfe=280,Xfe=900,Qfe=720,dM=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(", ");function Jfe({open:e,onClose:t,side:n="right",owner:a,defaultSize:r,minSize:o=Yfe,maxSize:c,resizable:u=!1,backdrop:h=!0,scrollLock:f=!1,focusTrap:g=!1,ariaLabel:v,className:y,children:x}){const w=r??(n==="right"?Zfe:Kfe),C=c??(n==="right"?Xfe:Qfe),[T,E]=m.useState(w),[S,k]=m.useState(!1),N=m.useRef(null),A=m.useRef(null),R=m.useCallback(()=>t(),[t]);Gfe(n,a,e,R),m.useEffect(()=>{if(!e)return;const $=H=>{H.key==="Escape"&&(H.preventDefault(),R())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e,R]),m.useEffect(()=>{if(!e||!f)return;const $=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=$}},[e,f]),m.useEffect(()=>{if(!e)return;A.current=document.activeElement;const $=N.current;return $?(($.querySelector(dM)??$).focus(),()=>{A.current?.focus?.()}):void 0},[e]),m.useEffect(()=>{if(!S)return;const $=I=>{if(n==="right"){const U=window.innerWidth-I.clientX;E(Math.min(C,Math.max(o,U)))}else{const U=window.innerHeight-I.clientY;E(Math.min(C,Math.max(o,U)))}},H=()=>k(!1);return window.addEventListener("pointermove",$),window.addEventListener("pointerup",H),window.addEventListener("pointercancel",H),()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",H),window.removeEventListener("pointercancel",H)}},[S,n,o,C]);const _=$=>{if(!g||$.key!=="Tab")return;const H=N.current;if(!H)return;const I=Array.from(H.querySelectorAll(dM));if(I.length===0){$.preventDefault(),H.focus();return}const U=I[0],D=I[I.length-1],V=document.activeElement;$.shiftKey?(V===U||!H.contains(V))&&($.preventDefault(),D.focus()):V===D&&($.preventDefault(),U.focus())};if(!e)return null;const P=n==="right"?{width:T}:{height:T};return s.jsxs(s.Fragment,{children:[h&&s.jsx("div",{className:"s-slide-backdrop","data-side":n,onClick:R,"aria-hidden":"true"}),s.jsxs("aside",{ref:N,className:`s-slide s-slide--${n}${S?" s-slide--resizing":""}${y?` ${y}`:""}`,role:"dialog","aria-modal":"true","aria-label":v,tabIndex:-1,onKeyDown:_,style:P,children:[u&&s.jsx("div",{className:`s-slide-resize s-slide-resize--${n}`,onPointerDown:$=>{$.preventDefault(),k(!0)},role:"separator","aria-orientation":n==="right"?"vertical":"horizontal","aria-label":"Resize panel"}),x]})]})}const fM=5e3,ehe=500,hM=5e3,the=3e4,LD={user:">",assistant:"<",tool:"*","tool-result":"=",system:"~",other:"·"},wj={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},zD={"scout-managed":"s-tail-chip--origin-scout","hudson-managed":"s-tail-chip--origin-hudson",unattributed:"s-tail-chip--origin-native"};function jj(e){return e?.trim().toLowerCase()||"unknown"}function nhe(e,t){const n=new Map,a=e?.transcripts?.length?e.transcripts:e?.processes.length?e.processes:t;for(const r of a){const o=jj(r.source);n.set(o,(n.get(o)??0)+1)}return[...n.entries()].map(([r,o])=>({source:r,count:o})).sort((r,o)=>o.count-r.count||r.source.localeCompare(o.source))}function she(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),r=String(t.getSeconds()).padStart(2,"0"),o=String(t.getMilliseconds()).padStart(3,"0");return`${n}:${a}:${r}.${o}`}function ahe(e){return e?(e.split(":")[0]??e).slice(0,8):"—"}function rhe(e,t){return`${e.id}:${e.ts}:${t}`}const ihe=/\b(error|failed|failure|exception|panic|timeout|timed out|refused|crash|fatal|non[- ]?zero|exit(?:ed)? with code [1-9])\b/i,ohe=/\b(warn(?:ing)?|deprecated|retry|rate limit|rate-limited|blocked|skipped|interrupted|aborted|stale|conflict|permission denied|denied)\b/i;function BD(e){const t=e.replace(/[_-]+/g," ");return ihe.test(t)?"error":ohe.test(t)?"warn":null}function mM(e){return!(e==null||e===!1||typeof e=="string"&&!e.trim())}function w0(e,t=0){if(e==null||t>4||typeof e=="string"||typeof e!="object")return null;if(Array.isArray(e)){let a=null;for(const r of e.slice(0,40)){const o=w0(r,t+1);if(o==="error")return"error";a??=o}return a}let n=null;for(const[a,r]of Object.entries(e).slice(0,80)){const o=a.toLowerCase();if((o==="is_error"||o==="failed")&&r===!0||o==="error"&&mM(r))return"error";if((o==="warning"||o==="warn")&&mM(r)&&(n="warn"),typeof r=="string"&&(o==="level"||o==="severity"||o==="status"||o==="type"||o==="subtype")){const u=BD(r);if(u==="error")return"error";n??=u}const c=w0(r,t+1);if(c==="error")return"error";n??=c}return n}function UD(e){const t=w0(e.raw);if(t==="error")return"error";if(e.kind==="tool-result"||e.kind==="system"||e.kind==="other"){const n=BD(e.summary);return n==="error"?"error":t??n}return t}function lhe(e,t){return t==="all"?!0:t==="warn-plus"?e!=null:e==="error"}function che(e){switch(e){case"errors-only":return"errors";case"warn-plus":return"warnings or errors";case"all":return"all session events"}}function uhe(e,t,n=null,a="all"){if(!t)return!0;const r=wj[e.harness],o=n==="error"?"error failed failure issue":n==="warn"?"warn warning issue":"",u=(a==="context"?[e.project,e.cwd,e.sessionId,e.source,e.harness,r,o]:[e.summary,e.project,e.cwd,e.sessionId,e.source,e.harness,r,o]).join(" ").toLowerCase(),h=t.toLowerCase().split("|").map(f=>f.trim()).filter(Boolean);return h.length===0?!0:h.some(f=>u.includes(f))}function j0({navigate:e,initialFilter:t,variant:n="tail",chrome:a="full",filterLabel:r,filterScope:o="all"}={}){const{route:c}=qe(),u=n==="issues",h=a==="embedded",[f,g]=m.useState([]),[v,y]=m.useState(null),[x,w]=m.useState(t??""),[C,T]=m.useState(!!t&&!h),[E,S]=m.useState("warn-plus"),[k,N]=m.useState(!1),[A,R]=m.useState(0),[_,P]=m.useState(0),[$,H]=m.useState(null),I=m.useRef(null),U=m.useRef(null),D=m.useRef(!0),V=m.useRef([]),Z=m.useCallback(Q=>{V.current.push(Date.now()),g(ae=>ae.length>=fM?[...ae.slice(ae.length-fM+1),Q]:[...ae,Q])},[]);nf(Z),m.useEffect(()=>{w(t??""),T(!!t&&!h)},[h,t]),m.useEffect(()=>{let Q=!1;return(async()=>{try{const ae=new URLSearchParams({limit:String(ehe)});h&&ae.set("transcripts","true");const be=await me(`/api/tail/recent?${ae.toString()}`);Q||g(be.events??[])}catch{}})(),()=>{Q=!0}},[h]);const O=m.useCallback(async()=>{try{const Q=await me("/api/tail/discover");y(Q)}catch{}},[]);m.useEffect(()=>{O();const Q=setInterval(()=>{O()},the);return()=>clearInterval(Q)},[O]),m.useEffect(()=>{const Q=setInterval(()=>{const be=Date.now()-hM,$e=V.current.filter(ge=>ge>=be);V.current=$e,P($e.length/(hM/1e3))},1e3);return()=>clearInterval(Q)},[]);const z=m.useMemo(()=>f.map(Q=>({event:Q,severity:UD(Q)})),[f]),B=m.useMemo(()=>{let Q=0,ae=0;for(const be of z)be.severity==="error"&&ae++,be.severity==="warn"&&Q++;return{warn:Q,error:ae,total:Q+ae}},[z]),X=m.useMemo(()=>z.filter(({event:Q,severity:ae})=>u&&!lhe(ae,E)?!1:uhe(Q,x,ae,o)),[z,x,o,E,u]);m.useLayoutEffect(()=>{const Q=I.current;if(Q){if(k){R(ae=>ae+1);return}Q.scrollTop=Q.scrollHeight}},[X,k]);const W=m.useCallback(()=>{const Q=I.current;if(!Q)return;const be=Q.scrollHeight-Q.scrollTop-Q.clientHeight<24;D.current=be,be?(N(!1),R(0)):k||N(!0)},[k]),L=m.useCallback(Q=>{w(Q),T(!0),requestAnimationFrame(()=>U.current?.focus())},[]),q=m.useCallback(Q=>{!Q||!e||kt(e,{view:"sessions",sessionId:Q},{returnTo:c})},[e,c]),K=m.useCallback(()=>{const Q=I.current;Q&&(Q.scrollTop=Q.scrollHeight,N(!1),R(0))},[]);m.useEffect(()=>{if(h)return;const Q=ae=>{const be=ae.target,$e=be instanceof HTMLInputElement||be instanceof HTMLTextAreaElement||(be?.isContentEditable??!1);if(ae.key==="/"&&!$e){ae.preventDefault(),T(!0),requestAnimationFrame(()=>U.current?.focus());return}if(ae.key==="Escape"&&C&&document.activeElement===U.current){ae.preventDefault(),T(!1),U.current?.blur(),w("");return}(ae.key==="g"||ae.key==="G")&&!$e&&(ae.preventDefault(),K())};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[h,C,K]);const ee=v?.totals,G=ee?.transcripts??v?.transcripts?.length??0,re=m.useMemo(()=>nhe(v,f),[v,f]);return s.jsxs("div",{className:`s-tail s-tail--${a}`,children:[s.jsxs("div",{className:`s-tail-status${u?" s-tail-status--issues":""}`,children:[s.jsxs("span",{className:"s-tail-status-cluster s-tail-status-cluster--metrics",children:[s.jsxs("span",{className:"s-tail-status-cell",children:[s.jsx("span",{className:"s-tail-rate-pulse"}),s.jsx("strong",{children:G})," log",G===1?"":"s"]}),s.jsxs("span",{className:"s-tail-status-cell",children:[s.jsx("strong",{children:ee?.total??0})," proc",(ee?.total??0)===1?"":"s"]}),s.jsxs("span",{className:"s-tail-status-cell",children:[s.jsx("strong",{children:_.toFixed(1)})," lines/s"]})]}),u&&s.jsxs("span",{className:"s-tail-status-cluster s-tail-status-cluster--issues",children:[s.jsx("span",{className:"s-tail-status-label",children:"alerts"}),s.jsxs("span",{className:"s-tail-issue-filter",role:"group","aria-label":"Alert severity filter",children:[s.jsxs("button",{type:"button",className:`s-tail-issue-filter-btn${E==="errors-only"?" s-tail-issue-filter-btn--active":""}`,onClick:()=>S("errors-only"),"aria-pressed":E==="errors-only",children:["Errors ",s.jsx("strong",{children:B.error})]}),s.jsxs("button",{type:"button",className:`s-tail-issue-filter-btn${E==="warn-plus"?" s-tail-issue-filter-btn--active":""}`,onClick:()=>S("warn-plus"),"aria-pressed":E==="warn-plus",children:["Warn+ ",s.jsx("strong",{children:B.total})]}),s.jsxs("button",{type:"button",className:`s-tail-issue-filter-btn${E==="all"?" s-tail-issue-filter-btn--active":""}`,onClick:()=>S("all"),"aria-pressed":E==="all",children:["All ",s.jsx("strong",{children:f.length})]})]})]}),s.jsx("span",{className:"s-tail-status-spacer"}),s.jsxs("span",{className:"s-tail-status-cluster s-tail-status-cluster--harnesses",children:[s.jsx("span",{className:"s-tail-status-label",children:"harness"}),s.jsx("span",{className:"s-tail-status-inline",children:re.length>0?re.slice(0,4).map(Q=>s.jsxs("span",{children:[s.jsx("strong",{children:Q.count})," ",Q.source]},Q.source)):s.jsx("strong",{children:"none"})})]}),x&&h&&s.jsx("span",{className:"s-tail-status-filter",title:x,children:r??"filtered"}),k&&s.jsx("span",{className:"s-tail-status-paused",children:"paused"})]}),C&&s.jsxs("div",{className:"s-tail-filter",children:[s.jsx("span",{className:"s-tail-filter-prompt",children:"/"}),s.jsx("input",{ref:U,className:"s-tail-filter-input",value:x,placeholder:"substring across summary · project · session",onChange:Q=>w(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),U.current?.blur())},autoFocus:!0,spellCheck:!1}),s.jsx("span",{className:"s-tail-filter-hint",children:"esc to clear"})]}),s.jsxs("div",{className:"s-tail-body",ref:I,onScroll:W,children:[X.length===0?s.jsxs("div",{className:"s-tail-empty",children:[s.jsxs("span",{className:"s-tail-empty-title",children:[u?"No alert events":"Waiting for events",s.jsx("span",{className:"s-tail-empty-cursor","aria-hidden":"true"})]}),s.jsx("span",{className:"s-tail-empty-body",children:x?h?s.jsxs(s.Fragment,{children:["no events match ",s.jsx("strong",{children:r??"this work filter"})]}):s.jsxs(s.Fragment,{children:["no events match filter ",s.jsx("strong",{children:x})]}):u?s.jsxs(s.Fragment,{children:["no ",che(E)," in the buffered session tail"]}):G?s.jsxs(s.Fragment,{children:["watching ",G," transcript",G===1?"":"s"," · no events yet"]}):s.jsx(s.Fragment,{children:"agent tool calls, messages, and system events stream here"})}),!G&&!x&&s.jsxs("span",{className:"s-tail-empty-hint",children:["Start a session to see traffic",s.jsx("span",{className:"s-tail-empty-hint-sep",children:" · "}),s.jsx("code",{children:"scout watch --tail"})]})]}):X.map(({event:Q,severity:ae},be)=>s.jsx(dhe,{event:Q,issueSeverity:ae,selected:$===Q,onSelect:H,onProjectClick:L,onSessionClick:q},rhe(Q,be))),k&&A>0&&s.jsxs("div",{className:"s-tail-divider",onClick:K,onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),K())},role:"button",tabIndex:0,"aria-label":`Resume live tail · ${A} new`,children:["── paused · ",A," new · click or press G to jump back to live ──"]})]}),h?s.jsxs("div",{className:"s-tail-keys s-tail-keys--embedded",children:[s.jsxs("span",{children:[X.length," / ",f.length," lines buffered"]}),k&&A>0&&s.jsxs("span",{children:[A," new"]})]}):s.jsxs("div",{className:"s-tail-keys",children:[s.jsxs("span",{children:[s.jsx("kbd",{children:"j"}),"/",s.jsx("kbd",{children:"k"})," scroll"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"/"})," filter"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"G"})," jump live"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"esc"})," close filter"]}),s.jsx("span",{className:"s-tail-keys-spacer"}),s.jsxs("span",{children:[X.length," / ",f.length," lines buffered"]})]}),$&&s.jsx(mhe,{event:$,onClose:()=>H(null),onProjectClick:L,onSessionClick:q})]})}function dhe({event:e,issueSeverity:t,selected:n,onSelect:a,onProjectClick:r,onSessionClick:o}){const c=zD[e.harness],u=wj[e.harness],h=jj(e.source),f=t?` s-tail-row--issue s-tail-row--issue-${t}`:"";return s.jsxs("div",{className:`s-tail-row s-tail-row--${e.kind}${f}${n?" s-tail-row--selected":""}`,role:"button",tabIndex:0,onClick:()=>a(e),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),a(e))},children:[s.jsx("span",{className:"s-tail-cell-time",children:she(e.ts)}),s.jsx("span",{className:"s-tail-gutter",children:"│"}),s.jsx("span",{className:"s-tail-chip s-tail-chip--harness",children:h}),s.jsx("span",{className:`s-tail-chip s-tail-chip--origin ${c}`,title:`origin: ${u}`,children:u}),s.jsxs("span",{className:"s-tail-cell-context",children:[s.jsx(Tp,{className:"s-tail-link s-tail-link--project",onClick:r?()=>r(e.project):void 0,title:`Filter to ${e.project}`,children:s.jsx("strong",{children:e.project})})," · ",s.jsx(Tp,{className:"s-tail-link s-tail-link--session",onClick:o&&e.sessionId?()=>o(e.sessionId):void 0,title:e.sessionId?`Open session ${e.sessionId}`:void 0,children:ahe(e.sessionId)})," · ",s.jsx("span",{className:"s-tail-cell-pid",title:e.pid>0?`pid ${e.pid}`:"file-backed log",children:e.pid>0?e.pid:"log"})]}),s.jsx("span",{className:`s-tail-glyph s-tail-glyph--${e.kind}`,children:LD[e.kind]}),s.jsx("span",{className:"s-tail-summary",children:e.summary})]})}function Tp({className:e,onClick:t,title:n,children:a}){return t?s.jsx("span",{className:`${e} s-tail-link--active`,role:"link",tabIndex:0,title:n,onClick:r=>{r.stopPropagation(),t()},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),r.stopPropagation(),t())},children:a}):s.jsx("span",{className:e,title:n,children:a})}function fhe(e){const t=new Date(e),n=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),c=String(t.getMinutes()).padStart(2,"0"),u=String(t.getSeconds()).padStart(2,"0"),h=String(t.getMilliseconds()).padStart(3,"0");return`${n}-${a}-${r} ${o}:${c}:${u}.${h}`}function Pm(e){return(JSON.stringify(e,null,2)??"undefined").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/("(?:\\.|[^"\\])*"\s*:)|("(?:\\.|[^"\\])*")|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,(a,r,o,c,u)=>r?`<span class="s-tail-jk">${r}</span>`:o?`<span class="s-tail-js">${o}</span>`:c?`<span class="s-tail-jl">${c}</span>`:u?`<span class="s-tail-jn">${u}</span>`:a)}function hhe(e){if(!e||typeof e!="object")return null;const t=e,a=t.message?.content??t.content;return Array.isArray(a)?a:typeof a=="string"?[{type:"text",text:a}]:null}function mhe({event:e,onClose:t,onProjectClick:n,onSessionClick:a}){const[r,o]=m.useState(!0),c=zD[e.harness],u=wj[e.harness],h=jj(e.source),f=UD(e),g=hhe(e.raw);return s.jsxs(Jfe,{open:!0,onClose:t,side:"right",owner:"openscout.tail",resizable:!0,defaultSize:620,minSize:400,maxSize:960,ariaLabel:"Tail event detail",children:[s.jsxs("div",{className:"s-slide-header s-tail-sheet-header",children:[s.jsx("span",{className:`s-tail-glyph s-tail-glyph--${e.kind}`,children:LD[e.kind]}),s.jsx("span",{className:"s-tail-sheet-kind",children:e.kind}),f&&s.jsx("span",{className:`s-tail-chip s-tail-chip--issue-${f}`,children:f}),s.jsx("span",{className:"s-tail-chip s-tail-chip--harness",children:h}),s.jsx("span",{className:`s-tail-chip s-tail-chip--origin ${c}`,title:`origin: ${u}`,children:u}),s.jsx("span",{className:"s-slide-spacer"}),s.jsx("span",{className:"s-tail-sheet-time",children:fhe(e.ts)}),s.jsx("button",{type:"button",className:"s-slide-close",onClick:t,"aria-label":"Close",children:"×"})]}),s.jsxs("div",{className:"s-slide-body s-tail-sheet-body",children:[s.jsx("section",{className:"s-tail-sheet-section",children:s.jsxs("div",{className:"s-tail-sheet-grid",children:[s.jsx("span",{className:"s-tail-sheet-key",children:"project"}),s.jsx("span",{className:"s-tail-sheet-val",children:s.jsx(Tp,{className:"s-tail-link s-tail-link--project",onClick:n?()=>n(e.project):void 0,title:`Filter to ${e.project}`,children:e.project})}),s.jsx("span",{className:"s-tail-sheet-key",children:"cwd"}),s.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:e.cwd||"—"}),s.jsx("span",{className:"s-tail-sheet-key",children:"session"}),s.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:s.jsx(Tp,{className:"s-tail-link s-tail-link--session",onClick:a&&e.sessionId?()=>a(e.sessionId):void 0,title:e.sessionId?`Open session ${e.sessionId}`:void 0,children:e.sessionId||"—"})}),s.jsx("span",{className:"s-tail-sheet-key",children:"harness"}),s.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:h}),s.jsx("span",{className:"s-tail-sheet-key",children:"origin"}),s.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:u}),s.jsx("span",{className:"s-tail-sheet-key",children:"pid"}),s.jsxs("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:[e.pid,e.parentPid!=null?` ← ${e.parentPid}`:""]})]})}),s.jsxs("section",{className:"s-tail-sheet-section",children:[s.jsx("h4",{className:"s-tail-sheet-h",children:"summary"}),s.jsx("div",{className:"s-tail-sheet-summary",children:e.summary})]}),g&&g.length>0&&s.jsxs("section",{className:"s-tail-sheet-section",children:[s.jsx("h4",{className:"s-tail-sheet-h",children:"content"}),g.map((v,y)=>s.jsx(phe,{block:v},y))]}),s.jsxs("section",{className:"s-tail-sheet-section",children:[s.jsxs("button",{type:"button",className:"s-tail-sheet-toggle",onClick:()=>o(v=>!v),children:[r?"▾":"▸"," raw event"]}),r&&s.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:Pm(e.raw??e)}})]})]})]})}function phe({block:e}){if(e.type==="text"){const t=e.text??"";return s.jsx("div",{className:"s-tail-sheet-text",children:t})}if(e.type==="tool_use"){const t=e;return s.jsxs("div",{className:"s-tail-sheet-block s-tail-sheet-block--tool",children:[s.jsxs("div",{className:"s-tail-sheet-block-head",children:[s.jsx("span",{className:"s-tail-glyph s-tail-glyph--tool",children:"*"}),s.jsx("span",{className:"s-tail-sheet-block-title",children:t.name??"tool_use"})]}),s.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:Pm(t.input??{})}})]})}if(e.type==="tool_result"){const t=e,n=typeof t.content=="string";return s.jsxs("div",{className:`s-tail-sheet-block s-tail-sheet-block--tool-result${t.is_error?" s-tail-sheet-block--err":""}`,children:[s.jsxs("div",{className:"s-tail-sheet-block-head",children:[s.jsx("span",{className:"s-tail-glyph s-tail-glyph--tool-result",children:"="}),s.jsxs("span",{className:"s-tail-sheet-block-title",children:["tool_result",t.is_error?" · error":""]})]}),n?s.jsx("pre",{className:"s-tail-sheet-pre",children:t.content}):s.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:Pm(t.content??{})}})]})}return s.jsxs("div",{className:"s-tail-sheet-block",children:[s.jsxs("div",{className:"s-tail-sheet-block-head",children:[s.jsx("span",{className:"s-tail-glyph s-tail-glyph--other",children:"·"}),s.jsx("span",{className:"s-tail-sheet-block-title",children:e.type})]}),s.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:Pm(e)}})]})}const ghe=[{id:"mission",label:"Control"},{id:"plan",label:"Work"},{id:"issues",label:"Alerts"},{id:"tail",label:"Tail"},{id:"atop",label:"Atop"},{id:"agents",label:"Agents"}];function vhe({navigate:e,mode:t="mission",tailQuery:n}){const{agents:a}=qe();return s.jsxs("div",{className:"s-ops",children:[s.jsx("div",{className:"s-ops-header",children:s.jsx("div",{className:"s-ops-tabs",children:ghe.map(r=>s.jsx("button",{className:`s-ops-tab${t===r.id?" s-ops-tab--active":""}`,onClick:()=>e({view:"ops",mode:r.id}),children:r.label},r.id))})}),s.jsxs("div",{className:"s-ops-body",children:[t==="mission"&&s.jsx(gde,{navigate:e,agents:a}),t==="agents"&&s.jsx(Hde,{navigate:e,agents:a}),t==="plan"&&s.jsx(mfe,{navigate:e,agents:a}),t==="issues"&&s.jsx(j0,{navigate:e,initialFilter:n,variant:"issues"}),t==="tail"&&s.jsx(j0,{navigate:e,initialFilter:n}),t==="atop"&&s.jsx(zfe,{})]}),s.jsx(Cue,{})]})}function yhe(e){return e==="pi"?"pi":void 0}function xhe(e,t){return`scout-tmux-${e}-${t}`}function bhe(e,t){if(!t)return e;try{const n=new URL(e);return n.searchParams.set("agentId",t),n.toString()}catch{const n=e.includes("?")?"&":"?";return`${e}${n}agentId=${encodeURIComponent(t)}`}}function whe(e,t){return t==="takeover"&&!!e&&e?.transport!=="tmux"}function jhe({agentId:e,mode:t,navigate:n}){const{agents:a}=qe(),r=e?a.find(u=>u.id===e):null;if(e&&!r)return s.jsx("div",{className:"s-term",children:s.jsxs("div",{className:"s-term-bar",children:[s.jsx(Ga,{slot:"terminal",fallback:{view:"agents"},navigate:n,className:"s-term-back"}),s.jsx("span",{className:"s-term-label",children:"Terminal"}),s.jsx("div",{className:"s-term-status",children:"Resolving agent..."})]})});const o=r?.transport==="tmux"?r.harnessSessionId:null,c=r&&o?`tmux:${r.id}:${o}`:e?`takeover:${e}`:"takeover";return s.jsx(Nhe,{agentId:e,agent:r,mode:t,navigate:n,children:s.jsx(She,{agentId:e,agent:r,mode:t,navigate:n})},c)}function Nhe({agentId:e,agent:t,mode:n,navigate:a,children:r}){const o=whe(t,n),[c,u]=m.useState(o?{state:"preparing"}:{state:"ready"}),[h,f]=m.useState(0);return m.useEffect(()=>{if(!o||!e){u({state:"ready"});return}let g=!1;return u({state:"preparing"}),me(`/api/agents/${encodeURIComponent(e)}/session-catalog`).then(v=>{if(v.resumeCommand)return ef({command:v.resumeCommand,cwd:v.resumeCwd,agentId:e})}).then(()=>{g||u({state:"ready"})}).catch(v=>{g||u({state:"failed",error:v instanceof Error?v.message:String(v)})}),()=>{g=!0}},[e,o,h]),c.state==="ready"?s.jsx(s.Fragment,{children:r}):s.jsx(khe,{agent:t,agentId:e,navigate:a,label:c.state==="failed"?"TAKEOVER FAILED":"PREPARING TAKEOVER",status:c.state==="failed"?c.error:"Resolving live session...",onRetry:c.state==="failed"?()=>f(g=>g+1):void 0})}function khe({agent:e,agentId:t,navigate:n,label:a,status:r,onRetry:o}){const c=e?qt(e.name):"var(--accent)";return s.jsxs("div",{className:"s-term",children:[s.jsxs("div",{className:"s-term-bar",children:[s.jsx(Ga,{slot:"terminal",fallback:t?{view:"agents",agentId:t}:{view:"inbox"},navigate:n,className:"s-term-back"}),e&&s.jsxs("div",{className:"s-term-agent",children:[s.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:c},children:e.name[0]?.toUpperCase()}),s.jsx("span",{className:"s-term-agent-name",children:e.name}),e.handle&&s.jsxs("span",{className:"s-term-agent-handle",children:["@",e.handle]})]}),s.jsx("span",{className:"s-term-label",children:a}),s.jsxs("div",{className:"s-term-status",children:[s.jsx("span",{className:"s-term-dot s-term-dot--connecting"}),o?"OFFLINE":"CONNECTING"]})]}),s.jsx("div",{className:"s-term-body s-term-body--placeholder",children:s.jsxs("div",{className:"s-term-placeholder",children:[s.jsx("span",{children:r}),o&&s.jsx("button",{type:"button",onClick:o,children:"Retry"})]})})]})}function She({agentId:e,agent:t,mode:n,navigate:a}){const r=t?qt(t.name):"var(--accent)",o=t?.transport==="tmux"?t.harnessSessionId:null,c=n==="observe",u=t?.cwd??t?.projectRoot??void 0,h=yhe(t?.harness),[f,g]=m.useState({state:"idle"}),v=aP(),y=rP(),x=bhe(v,e),w=U0({url:x,healthUrl:y,autoConnect:!0,sessionKey:t&&o?xhe(t.id,o):e?`scout-takeover-${e}`:"scout-takeover",...o?{backend:"tmux",tmuxSession:o}:{},...u?{cwd:u}:{},...h?{agent:h}:{}}),C=m.useMemo(()=>c?{...w,sendInput:()=>{},sendLine:()=>{},restart:()=>{}}:w,[c,w]),T=()=>{g({state:"opening"}),lP({agentId:e??null,launch:!0}).then(E=>{const S=E.plan.manifest.nodes.length,k=oP(E);if(S===0){const A=E.plan.diagnostics.find(R=>R.severity==="warning")??E.plan.diagnostics[0];g({state:"failed",error:A?`${k} · no windows: ${A.message}`:`${k} · no Vantage windows.`});return}if(!E.launch.ok&&E.launch.error){g({state:"failed",error:E.launch.error});return}const N=E.launch.ok?"Vantage launch requested":"Vantage handoff written";g({state:"opened",detail:`${k} · ${S} node${S===1?"":"s"} · ${N}`})}).catch(E=>{g({state:"failed",error:E instanceof Error?E.message:String(E)})})};return s.jsxs("div",{className:"s-term",children:[s.jsxs("div",{className:"s-term-bar",children:[s.jsx(Ga,{slot:"terminal",fallback:e?{view:"agents",agentId:e}:{view:"inbox"},navigate:a,className:"s-term-back"}),t&&s.jsxs("div",{className:"s-term-agent",children:[s.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:r},children:t.name[0]?.toUpperCase()}),s.jsx("span",{className:"s-term-agent-name",children:t.name}),t.handle&&s.jsxs("span",{className:"s-term-agent-handle",children:["@",t.handle]})]}),s.jsx("span",{className:"s-term-label",children:o?c?"TMUX OBSERVE":"TMUX TAKEOVER":"TAKEOVER"}),o&&s.jsx("span",{className:"s-term-session",title:o,children:o}),o&&s.jsx("button",{type:"button",className:"s-term-vantage",onClick:()=>a({view:"terminal",agentId:e,mode:c?"takeover":"observe"}),title:c?"Switch to interactive takeover":"Switch to read-only terminal observe",children:c?"Takeover":"Observe"}),s.jsx("button",{type:"button",className:"s-term-vantage",onClick:T,disabled:f.state==="opening",title:"Open this terminal context in the native Vantage canvas",children:f.state==="opening"?"Opening...":"Open in Vantage"}),f.state==="opened"&&s.jsx("span",{className:"s-term-handoff s-term-handoff--ok",children:f.detail}),f.state==="failed"&&s.jsx("span",{className:"s-term-handoff s-term-handoff--error",children:f.error}),s.jsxs("div",{className:"s-term-status",children:[s.jsx("span",{className:`s-term-dot${w.status==="connected"?" s-term-dot--live":w.status==="connecting"?" s-term-dot--connecting":""}`}),w.status==="connected"?"LIVE":w.status==="connecting"?"CONNECTING":"OFFLINE"]})]}),s.jsx("div",{className:"s-term-body",children:s.jsx(F0,{relay:C,fontSize:13,quiet:!0,configItems:[...o?[{label:"backend",value:"tmux"},{label:"session",value:o},{label:"mode",value:c?"read-only":"takeover"}]:[],{label:"ws",value:x},{label:"health",value:y}]})})]})}const Che=new Set(["png","jpg","jpeg","gif","webp","avif","svg"]),pM=[{value:"all",label:"All"},{value:"plan",label:"Plans"},{value:"doc",label:"Docs"},{value:"code",label:"Code"},{value:"test",label:"Tests"},{value:"config",label:"Config"},{value:"asset",label:"Assets"}];function Ehe(e){const t=e.split("/").pop()??e,n=t.lastIndexOf(".");return n>=0?t.slice(n+1).toLowerCase():""}function FD(e){return Che.has(Ehe(e.path))}function Ahe(e){const t={type:"dir",children:[]};for(const n of e){const a=n.path.split("/").filter(Boolean);if(a.length===0)continue;let r=t;for(let o=0;o<a.length-1;o+=1){const c=a[o],u=a.slice(0,o+1).join("/");let h=r.children.find(f=>f.type==="dir"&&f.name===c);h||(h={type:"dir",name:c,path:u,children:[]},r.children.push(h)),r=h}r.children.push({type:"file",name:a[a.length-1],path:n.path,material:n})}return VD(t),HD(t.children)}function VD(e){if(e.type==="dir"){e.children.sort((t,n)=>t.type!==n.type?t.type==="dir"?-1:1:t.name.localeCompare(n.name));for(const t of e.children)VD(t)}}function HD(e){return e.map(t=>{if(t.type!=="dir")return t;let n=t;for(;n.children.length===1&&n.children[0].type==="dir";){const a=n.children[0];n={type:"dir",name:`${n.name}/${a.name}`,path:a.path,children:a.children}}return{...n,children:HD(n.children)}})}function The(e){switch(e){case"added":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?";case"observed":return null}}function qD({node:e,depth:t,selectedId:n,collapsed:a,onToggle:r,onSelect:o}){if(e.type==="dir"){const g=a.has(e.path);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"s-work-files-tree-row s-work-files-tree-dir",style:{paddingLeft:`${8+t*12}px`},onClick:()=>r(e.path),children:[s.jsx("span",{className:"s-work-files-tree-chevron","aria-hidden":"true",children:g?s.jsx(Rp,{size:12,strokeWidth:1.8}):s.jsx(Vo,{size:12,strokeWidth:1.8})}),s.jsx("span",{className:"s-work-files-tree-icon","aria-hidden":"true",children:g?s.jsx(d2,{size:12,strokeWidth:1.8}):s.jsx(tz,{size:12,strokeWidth:1.8})}),s.jsx("span",{className:"s-work-files-tree-name",children:e.name||"/"})]}),!g&&e.children.map(v=>s.jsx(qD,{node:v,depth:t+1,selectedId:n,collapsed:a,onToggle:r,onSelect:o},v.type==="dir"?`d:${v.path}`:`f:${v.material.id}`))]})}const c=e.material.id===n,u=FD(e.material),h=The(e.material.status),f=e.material.status==="deleted";return s.jsxs("button",{type:"button",className:`s-work-files-tree-row s-work-files-tree-file${c?" s-work-files-tree-file-selected":""}`,style:{paddingLeft:`${8+t*12}px`},onClick:()=>o(e.material),disabled:f,title:e.path,children:[s.jsx("span",{className:"s-work-files-tree-chevron","aria-hidden":"true"}),s.jsx("span",{className:"s-work-files-tree-icon","aria-hidden":"true",children:u?s.jsx(cz,{size:12,strokeWidth:1.8}):s.jsx(xd,{size:12,strokeWidth:1.8})}),s.jsx("span",{className:"s-work-files-tree-name",children:e.name}),h&&s.jsx("span",{className:`s-work-files-tree-status s-work-files-tree-status-${e.material.status}`,"aria-label":e.material.status,children:h})]})}function Mhe({path:e}){const t=e.split("/").filter(Boolean);if(t.length===0)return s.jsx("span",{className:"s-work-files-breadcrumb",children:e});const n=t[t.length-1],a=t.slice(0,-1).join("/");return s.jsxs("span",{className:"s-work-files-breadcrumb",children:[a&&s.jsxs("span",{className:"s-work-files-breadcrumb-folder",children:[a,"/"]}),s.jsx("span",{className:"s-work-files-breadcrumb-name",children:n})]})}function Rhe({workId:e,material:t}){const n=FD(t),[a,r]=m.useState(null),[o,c]=m.useState(null),[u,h]=m.useState(!1);if(m.useEffect(()=>{if(n){r(null),c(null),h(!1);return}let g=!1;return h(!0),c(null),r(null),me(`/api/work/${encodeURIComponent(e)}/material?materialId=${encodeURIComponent(t.id)}`).then(v=>{g||r(v)}).catch(v=>{g||c(v instanceof Error?v.message:String(v))}).finally(()=>{g||h(!1)}),()=>{g=!0}},[n,t.id,e]),n){const g=`/api/work/${encodeURIComponent(e)}/material/raw?materialId=${encodeURIComponent(t.id)}`;return s.jsx("div",{className:"s-work-files-pane s-work-files-pane-image",children:s.jsx("img",{src:g,alt:t.path,className:"s-work-files-image"})})}if(u&&!a)return s.jsx("div",{className:"s-work-files-pane-state",children:"Loading file…"});if(o)return s.jsx("div",{className:"s-work-files-pane-state s-work-files-pane-error",children:o});if(!a)return s.jsx("div",{className:"s-work-files-pane-state",children:"No content."});const f=zc({id:a.materialId,title:a.title,uri:a.uri,mediaType:a.mediaType,value:a.content,readOnly:!0});return s.jsxs("div",{className:"s-work-files-pane",children:[s.jsx(Qd,{document:f,mode:f.kind==="markdown"?"preview":"read"}),a.truncated&&s.jsxs("div",{className:"s-work-files-pane-notice",children:["Preview truncated at ",Math.round(a.content.length/1024)," KB."]})]})}function Ihe({workId:e,workTitle:t,materials:n,open:a,initialKind:r="all",onClose:o}){const c=m.useMemo(()=>n.filter(k=>k.status!=="deleted"),[n]),[u,h]=m.useState(r),[f,g]=m.useState(null),[v,y]=m.useState(()=>new Set);m.useEffect(()=>{a&&h(r)},[r,a]);const x=m.useMemo(()=>u==="all"?c:u==="plan"?c.filter(k=>k.kind==="plan"||k.kind==="spec"):c.filter(k=>k.kind===u),[c,u]),w=m.useMemo(()=>Ahe(x),[x]);m.useEffect(()=>{if(!f&&x.length>0){g(x[0].id);return}f&&!x.some(k=>k.id===f)&&g(x[0]?.id??null)},[x,f]);const C=m.useCallback(k=>{g(k.id)},[]),T=m.useCallback(k=>{y(N=>{const A=new Set(N);return A.has(k)?A.delete(k):A.add(k),A})},[]),E=x.find(k=>k.id===f)??null,S=m.useMemo(()=>{const k={all:c.length};for(const N of pM)N.value!=="all"&&(k[N.value]=c.filter(A=>N.value==="plan"?A.kind==="plan"||A.kind==="spec":A.kind===N.value).length);return k},[c]);return s.jsx(ig,{open:a,kind:"code",document:null,title:`Files · ${c.length}`,eyebrow:"Work materials",subtitle:t,focusable:!0,onClose:o,body:s.jsxs("div",{className:"s-work-files-layout",children:[s.jsxs("aside",{className:"s-work-files-tree","aria-label":"File tree",children:[s.jsx("div",{className:"s-work-files-tree-filters",role:"tablist",children:pM.map(k=>{const N=S[k.value]??0;if(k.value!=="all"&&N===0)return null;const A=k.value===u;return s.jsxs("button",{type:"button",role:"tab","aria-selected":A,className:`s-work-files-tree-filter${A?" s-work-files-tree-filter-active":""}`,onClick:()=>h(k.value),children:[s.jsx("span",{children:k.label}),s.jsx("span",{className:"s-work-files-tree-filter-count",children:N})]},k.value)})}),s.jsx("div",{className:"s-work-files-tree-list",children:w.length===0?s.jsx("div",{className:"s-work-files-tree-empty",children:"No files match this filter."}):w.map(k=>s.jsx(qD,{node:k,depth:0,selectedId:f,collapsed:v,onToggle:T,onSelect:C},k.type==="dir"?`d:${k.path}`:`f:${k.material.id}`))})]}),s.jsx("section",{className:"s-work-files-content","aria-label":"File preview",children:E?s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"s-work-files-content-head",children:[s.jsx(Mhe,{path:E.path}),s.jsxs("div",{className:"s-work-files-content-meta",children:[s.jsx("span",{children:E.kind}),s.jsx("span",{children:E.status}),E.diffStat&&s.jsxs("span",{children:["+",E.diffStat.additions," -",E.diffStat.deletions]})]})]}),s.jsx(Rhe,{workId:e,material:E})]}):s.jsx("div",{className:"s-work-files-pane-state",children:"Select a file to preview."})})]})})}function gM(e){switch(e){case"review":return"In review";case"waiting":return"Waiting";case"working":return"Working";case"done":return"Done";default:return e.replace(/_/g," ")}}function _he(e){switch(e){case"badge":return"Noteworthy";case"interrupt":return"Blocked signal";default:return null}}function Ohe({detail:e,signal:t,ownerLabel:n,nextMoveLabel:a}){const r=a==="—"?n:a;return e.attention==="interrupt"?{eyebrow:"Network signal",title:`Blocker surfaced for ${r}`,body:e.conversationId?"Open the thread if you want the blocking context.":"No thread is attached; the record and timeline hold the current context.",tone:"blocked"}:t?{eyebrow:"Network signal",title:`Plan activity from ${r}`,body:e.conversationId?"A plan or spec discussion is active in the agent network. Open the thread only if you want context.":"A plan or spec discussion is active in the agent network, but no thread is attached yet.",tone:"attention"}:e.activeFlights.length>0||e.state==="working"?{eyebrow:"Next move",title:`${n} is working`,body:e.conversationId?"The thread has the freshest working context.":"Watch the flight list and timeline for the next update.",tone:"active"}:e.state==="waiting"||e.state==="review"?{eyebrow:"Next move",title:`Waiting on ${a}`,body:e.conversationId?"The thread has the current unblock context.":"No thread is attached; ownership and timeline are the best context.",tone:"quiet"}:e.state==="done"?{eyebrow:"Outcome",title:"Work is done",body:e.conversationId?"The thread keeps the handoff and final context.":"The record and timeline are preserved here.",tone:"quiet"}:{eyebrow:"Next move",title:a==="—"?"No next owner set":`Next move: ${a}`,body:e.conversationId?"The thread has the latest context.":"Use the record and timeline to decide where this should go next.",tone:"quiet"}}function WD({children:e,icon:t,onClick:n,primary:a=!1,disabled:r=!1}){return s.jsxs("button",{type:"button",className:`s-work-action-button${a?" s-work-action-button-primary":""}`,onClick:n,disabled:r,children:[t,s.jsx("span",{children:e})]})}function $he({detail:e,navigate:t}){const n=!!e.conversationId,a=e.inventory??Lhe(e),r=a.materials.filter(D=>D.kind==="plan"||D.kind==="spec"),o=a.materials.filter(D=>D.kind==="doc"),c=a.materials.filter(D=>D.kind==="code"||D.kind==="test"||D.kind==="config"||D.kind==="asset"||D.kind==="other"),u=r.length>0,h=o.length>0,f=Dhe(e),g=r[0]?Bhe(r[0]):f??"No plan or spec file detected yet.",v=[...r,...o,...c].filter(D=>D.status!=="deleted"),[y,x]=m.useState(!1),[w,C]=m.useState(null),[T,E]=m.useState(null),[S,k]=m.useState(null),[N,A]=m.useState(null),[R,_]=m.useState(!1),[P,$]=m.useState("all"),H=m.useCallback(D=>{x(!1),C(D)},[]),I=m.useCallback(()=>{C(null),x(!0)},[]),U=m.useCallback(D=>{x(!1),C(null),$(D),_(!0)},[]);return m.useEffect(()=>{w&&!v.some(D=>D.id===w)&&C(null)},[w,v]),m.useEffect(()=>{if(!w){E(null),k(null),A(null);return}let D=!1;return A(w),k(null),me(`/api/work/${encodeURIComponent(e.id)}/material?materialId=${encodeURIComponent(w)}`).then(V=>{D||E(V)}).catch(V=>{D||(E(null),k(V instanceof Error?V.message:String(V)))}).finally(()=>{D||A(null)}),()=>{D=!0}},[e.id,w]),s.jsxs("section",{className:"s-work-casefile-section s-work-materials-section",children:[s.jsxs("div",{className:"s-agent-section-heading",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"s-agent-section-title",children:"Work materials"}),s.jsxs("p",{className:"s-work-section-note",children:[zhe(a.mode)," · ",a.source," evidence · ",a.confidence," confidence"]})]}),s.jsxs("div",{className:"s-work-inventory-meta","aria-label":"Inventory totals",children:[s.jsxs("span",{children:[a.totals.materials," files"]}),s.jsxs("span",{children:[a.totals.agents," agents"]}),s.jsxs("span",{children:[a.totals.sessions," sessions"]})]})]}),s.jsxs("div",{className:"s-work-material-grid",children:[s.jsxs("article",{className:"s-work-material-card s-work-material-card-primary",children:[s.jsxs("div",{className:"s-work-material-head",children:[s.jsx("span",{className:"s-work-material-icon","aria-hidden":"true",children:s.jsx(xd,{size:15,strokeWidth:1.8})}),s.jsxs("div",{children:[s.jsx("div",{className:"s-work-material-kicker",children:u?"Plans & specs":"Brief"}),s.jsx("div",{className:"s-work-material-title",children:u?`${r.length} surfaced`:f?"Original ask":"No plan file yet"})]})]}),s.jsx("p",{className:"s-work-material-copy",children:g}),s.jsx(Ox,{materials:r.slice(0,3),empty:"No plan or spec files detected yet.",selectedId:w,onOpen:H}),s.jsxs("div",{className:"s-work-material-card-actions",children:[f&&s.jsxs("button",{type:"button",className:`s-work-material-link${y?" s-work-material-link-active":""}`,onClick:I,children:[s.jsx(xd,{"aria-hidden":"true",size:13,strokeWidth:1.8}),"View ask"]}),r.length>3&&s.jsxs("button",{type:"button",className:"s-work-material-link",onClick:()=>U("plan"),children:[s.jsx(Sy,{"aria-hidden":"true",size:13,strokeWidth:1.8}),"View all ",r.length]})]})]}),s.jsxs("div",{className:`s-work-material-evidence-stack${h?"":" s-work-material-evidence-stack-single"}`,children:[h&&s.jsxs("article",{className:"s-work-material-card s-work-material-card-docs",children:[s.jsxs("div",{className:"s-work-material-head",children:[s.jsx("span",{className:"s-work-material-icon","aria-hidden":"true",children:s.jsx(_4,{size:15,strokeWidth:1.8})}),s.jsxs("div",{children:[s.jsx("div",{className:"s-work-material-kicker",children:"Docs"}),s.jsxs("div",{className:"s-work-material-title",children:[o.length," documents"]})]})]}),s.jsx(Ox,{materials:o.slice(0,3),empty:"Docs from git or trace evidence will appear here.",selectedId:w,onOpen:H}),o.length>3&&s.jsx("div",{className:"s-work-material-card-actions",children:s.jsxs("button",{type:"button",className:"s-work-material-link",onClick:()=>U("doc"),children:[s.jsx(Sy,{"aria-hidden":"true",size:13,strokeWidth:1.8}),"View all ",o.length]})})]}),s.jsxs("article",{className:"s-work-material-card s-work-material-card-code",children:[s.jsxs("div",{className:"s-work-material-head",children:[s.jsx("span",{className:"s-work-material-icon","aria-hidden":"true",children:s.jsx(H4,{size:15,strokeWidth:1.8})}),s.jsxs("div",{children:[s.jsx("div",{className:"s-work-material-kicker",children:"Code"}),s.jsx("div",{className:"s-work-material-title",children:c.length>0?`${c.length} related files`:"No code yet"})]})]}),s.jsx(Ox,{materials:c.slice(0,5),empty:"Changed code from git or session traces will appear here.",selectedId:w,onOpen:H}),c.length>5&&s.jsx("div",{className:"s-work-material-card-actions",children:s.jsxs("button",{type:"button",className:"s-work-material-link",onClick:()=>U("code"),children:[s.jsx(Sy,{"aria-hidden":"true",size:13,strokeWidth:1.8}),"View all ",c.length]})})]})]})]}),s.jsx(Phe,{detail:e,summary:f,open:y,hasThread:n,navigate:t,onClose:()=>x(!1)}),s.jsx(Uhe,{material:v.find(D=>D.id===w)??null,content:T,loading:!!N,error:S,onClose:()=>C(null)}),s.jsx(Ihe,{workId:e.id,workTitle:e.title,materials:v,open:R,initialKind:P,onClose:()=>_(!1)}),a.limitations.length>0&&s.jsx("div",{className:"s-work-inventory-note",children:a.limitations[0]})]})}function Phe({detail:e,summary:t,open:n,hasThread:a,navigate:r,onClose:o}){const{route:c}=qe();if(!n||!t)return null;const u=zc({id:`${e.id}:brief`,title:"Original ask",uri:`scout://work/${e.id}/brief`,mediaType:"text/markdown",value:`# Original ask
176
+
177
+ ${t}`,readOnly:!0});return s.jsx(ig,{kind:"ask",document:u,title:"Original ask",eyebrow:"Brief",subtitle:e.title,meta:["ask",a?"thread linked":"threadless"],mode:"preview",actions:a&&e.conversationId?[{label:"Thread",icon:s.jsx(_p,{"aria-hidden":"true",size:13,strokeWidth:1.8}),onClick:()=>kt(r,{view:"conversation",conversationId:e.conversationId},{returnTo:c}),title:"Open source thread"}]:[],onClose:o})}function Dhe(e){const t=[...e.timeline].sort((r,o)=>r.at-o.at),n=t.find(r=>r.kind==="collaboration_event"&&r.detailKind==="created"&&r.summary),a=t.find(r=>r.kind==="message"&&r.summary);return n?.summary??a?.summary??null}function Lhe(e){return{workId:e.id,generatedAt:Date.now(),mode:"trace-only",source:"broker",confidence:"low",agents:[],sessions:[],materials:[],totals:{materials:0,plans:0,specs:0,docs:0,code:0,tests:0,config:0,assets:0,agents:0,sessions:0},limitations:["Inventory is not available from this server yet."]}}function zhe(e){switch(e){case"isolated-git-worktree":return"Isolated git worktree";case"shared-git-repo":return"Shared git repo";case"explicit-artifacts":return"Explicit artifacts";default:return"Trace-only"}}function Bhe(e){const t=e.diffStat?`+${e.diffStat.additions} / -${e.diffStat.deletions}`:e.status;return`${e.path} · ${t} · ${e.confidence} confidence`}function Ox({materials:e,empty:t,selectedId:n,onOpen:a}){return e.length===0?s.jsx("div",{className:"s-work-material-empty",children:t}):s.jsx("div",{className:"s-work-material-list",children:e.map(r=>s.jsxs("button",{type:"button",className:`s-work-material-row${n===r.id?" s-work-material-row-active":""}`,title:r.path,onClick:()=>a?.(r.id),disabled:!a||r.status==="deleted",children:[s.jsx("div",{className:"s-work-material-path",children:r.path}),s.jsxs("div",{className:"s-work-material-row-meta",children:[s.jsx("span",{children:r.status}),r.diffStat&&s.jsxs("span",{children:["+",r.diffStat.additions," -",r.diffStat.deletions]}),s.jsx("span",{children:r.confidence})]})]},r.id))})}function Uhe({material:e,content:t,loading:n,error:a,onClose:r}){if(!e)return null;const o=t?zc({id:t.materialId,title:t.title,uri:t.uri,mediaType:t.mediaType,value:t.content,readOnly:!0}):null;return s.jsx(ig,{kind:Fhe(e),document:o,title:e.path,eyebrow:e.kind==="spec"?"Spec":e.kind,subtitle:t?.uri??e.worktreeRoot??void 0,meta:[e.status,e.confidence,...t?[vM(t.sizeBytes)]:[]],mode:o?.kind==="markdown"?"preview":"read",state:n||!t&&!a?"Loading file...":null,error:n?null:a,notice:t?.truncated?`Preview truncated at ${vM(t.content.length)}.`:null,onClose:r})}function Fhe(e){return e.kind==="plan"||e.kind==="spec"?"plan":e.kind==="doc"?"doc":"code"}function vM(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function GD(e){const t=e.split(".");return t[t.length-1]||e}function Vn(e,t){const n=t?.trim();!n||n.length<3||e.add(n)}function $x(e,t){Vn(e,t);const a=t?.trim().replace(/\/+$/,"")?.split("/").filter(Boolean).at(-1);a&&a.length>=3&&e.add(a)}function Vhe(e){return e.replace(/^\/Users\/[^/]+/,"~")}function Hhe(e){const t=new Set,n=[],a=e.ownerName??e.ownerId??e.nextMoveOwnerName??e.nextMoveOwnerId;Vn(t,e.id),Vn(t,e.conversationId),Vn(t,e.ownerId),Vn(t,e.nextMoveOwnerId),Vn(t,e.ownerName),Vn(t,e.nextMoveOwnerName);for(const o of e.activeFlights)Vn(t,o.id),Vn(t,o.invocationId),Vn(t,o.agentId),Vn(t,o.agentName),Vn(t,o.conversationId),Vn(t,o.collaborationRecordId);for(const o of e.inventory?.agents??[])Vn(t,o.id),Vn(t,o.name),Vn(t,o.sessionId),$x(t,o.cwd),$x(t,o.projectRoot);const r=e.inventory?.sessions.find(o=>o.cwd)??e.inventory?.sessions[0]??null;for(const o of e.inventory?.sessions??[])Vn(t,o.id),Vn(t,o.conversationId),Vn(t,o.agentId),Vn(t,o.agentName),$x(t,o.cwd);return a&&n.push(a),r?.cwd&&n.push(Vhe(r.cwd)),{query:[...t].slice(0,20).join("|"),label:n.length>0?n.join(" · "):`Case ${GD(e.id)}`}}function qhe({detail:e,navigate:t}){const{route:n}=qe(),a=Hhe(e);return s.jsxs("section",{className:"s-work-casefile-section s-work-tail-section",children:[s.jsxs("div",{className:"s-agent-section-heading s-work-tail-heading",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"s-agent-section-title s-work-tail-title",children:[s.jsx(s2,{"aria-hidden":"true",size:15,strokeWidth:1.8}),"Live tail"]}),s.jsxs("p",{className:"s-work-section-note",children:["Filtered to ",a.label]})]}),s.jsx(WD,{icon:s.jsx(Tc,{"aria-hidden":"true",size:13,strokeWidth:1.8}),onClick:()=>kt(t,{view:"ops",mode:"tail",tailQuery:a.query||void 0},{returnTo:n}),children:"Open Tail"})]}),s.jsx("div",{className:"s-work-tail-frame",children:s.jsx(j0,{navigate:t,initialFilter:a.query,filterLabel:a.label,filterScope:"context",chrome:"embedded"})})]})}function Whe({workId:e,navigate:t}){const{agents:n,route:a}=qe(),[r,o]=m.useState(null),[c,u]=m.useState(null),[h,f]=m.useState(!1),g=m.useCallback(async()=>{u(null);try{const N=await me(`/api/work/${encodeURIComponent(e)}`);o(N)}catch(N){u(N instanceof Error?N.message:String(N)),o(null)}finally{f(!0)}},[e]);m.useEffect(()=>{f(!1),g()},[g]),tn(()=>{g()});const v=oa(a),y=m.useMemo(()=>eo(n,v),[n,v]),x=m.useMemo(()=>r?rne(r,y):null,[r,y]);if(!h)return s.jsxs("div",{children:[s.jsx(Ga,{slot:"work",fallback:{view:"inbox"},navigate:t}),s.jsx("div",{className:"s-empty",children:s.jsx("p",{children:"Loading…"})})]});if(!r||!x)return s.jsxs("div",{className:"s-work-not-found",children:[s.jsx(Ga,{slot:"work",fallback:{view:"inbox"},navigate:t}),s.jsxs("div",{className:"s-work-not-found-body",children:[s.jsx("div",{className:"s-work-not-found-glyph","aria-hidden":"true",children:"□"}),s.jsx("h2",{className:"s-work-not-found-title",children:r?"Work item outside this machine scope":"Work item not found"}),s.jsx("p",{className:"s-work-not-found-sub",children:r?"Clear the machine scope or switch machines to inspect this work item.":"This work item may have been removed or does not exist on this broker."}),c&&s.jsx("p",{className:"s-work-not-found-detail",children:c})]})]});const w=x,C=_he(w.attention),T=w.ownerName??w.ownerId??"Unassigned",E=w.nextMoveOwnerName??w.nextMoveOwnerId??"—",S=Ohe({detail:w,signal:C,ownerLabel:T,nextMoveLabel:E}),k=w.activeFlights.length>0||w.childWork.length>0;return s.jsxs("div",{className:"s-work-detail s-work-casefile",children:[s.jsxs("div",{className:"s-work-casefile-topbar",children:[s.jsx(Ga,{slot:"work",fallback:{view:"inbox"},navigate:t}),s.jsxs("span",{className:"s-work-casefile-record",children:["Case ",GD(w.id)]})]}),c&&s.jsx("p",{className:"s-error",children:c}),s.jsxs("section",{className:"s-work-casefile-hero",children:[s.jsxs("div",{className:"s-work-casefile-hero-main",children:[s.jsxs("div",{className:"s-work-casefile-title-row",children:[s.jsx("h1",{className:"s-work-casefile-title",children:w.title}),s.jsx(Wr,{tone:tP(w),variant:"pill",children:w.currentPhase})]}),w.lastMeaningfulSummary&&s.jsx("div",{className:"s-work-casefile-summary",children:Ca(w.lastMeaningfulSummary)}),s.jsxs("div",{className:"s-work-casefile-meta",children:[s.jsxs("span",{children:["Updated ",Ae(w.updatedAt)]}),s.jsx("span",{children:T}),s.jsx("span",{children:gM(w.state)}),C&&s.jsx("span",{children:C}),w.priority&&s.jsxs("span",{children:["Priority ",w.priority]})]})]}),s.jsxs("aside",{className:`s-work-next-move s-work-next-move-${S.tone}`,children:[s.jsx("div",{className:"s-work-next-move-kicker",children:S.eyebrow}),s.jsx("div",{className:"s-work-next-move-title",children:S.title}),s.jsx("p",{className:"s-work-next-move-copy",children:S.body}),s.jsx("div",{className:"s-work-next-move-actions",children:w.conversationId&&s.jsx(WD,{primary:!0,icon:s.jsx(_p,{"aria-hidden":"true",size:14,strokeWidth:1.8}),onClick:()=>kt(t,{view:"conversation",conversationId:w.conversationId},{returnTo:a}),children:"Open thread"})})]})]}),s.jsxs("div",{className:"s-work-casefile-layout s-work-casefile-layout-main",children:[s.jsx("div",{className:"s-work-casefile-main s-work-casefile-main-materials",children:s.jsx($he,{detail:w,navigate:t})}),s.jsx(qhe,{detail:w,navigate:t}),k&&s.jsxs("div",{className:"s-work-casefile-main s-work-casefile-main-lower",children:[w.activeFlights.length>0&&s.jsxs("section",{className:"s-work-casefile-section",children:[s.jsx("div",{className:"s-agent-section-heading",children:s.jsx("h2",{className:"s-agent-section-title",children:"Flights"})}),s.jsx("div",{className:"s-work-flight-list",children:w.activeFlights.map(N=>s.jsxs("button",{type:"button",className:"s-work-flight-card",onClick:N.conversationId?()=>kt(t,{view:"conversation",conversationId:N.conversationId},{returnTo:a}):void 0,disabled:!N.conversationId,children:[s.jsxs("div",{className:"s-work-flight-card-header",children:[s.jsx("span",{className:"s-work-flight-card-title",children:N.agentName??N.agentId}),s.jsx(Wr,{tone:"working",variant:"pill",children:N.state})]}),s.jsxs("div",{className:"s-work-flight-card-meta",children:[s.jsx("span",{children:N.startedAt?`Started ${Ae(N.startedAt)}`:"Start time unavailable"}),N.completedAt&&s.jsxs("span",{children:["Completed ",Ae(N.completedAt)]})]}),N.summary&&s.jsx("div",{className:"s-work-flight-card-copy",children:N.summary})]},N.id))})]}),w.childWork.length>0&&s.jsxs("section",{className:"s-work-casefile-section",children:[s.jsx("div",{className:"s-agent-section-heading",children:s.jsx("h2",{className:"s-agent-section-title",children:"Child work"})}),s.jsx("div",{className:"s-work-related-list",children:w.childWork.map(N=>s.jsxs("button",{type:"button",className:"s-work-related-card",onClick:()=>kt(t,{view:"work",workId:N.id},{returnTo:a}),children:[s.jsxs("div",{className:"s-work-related-card-header",children:[s.jsx("span",{className:"s-work-related-card-title",children:N.title}),s.jsx(Wr,{tone:tse(N),variant:"pill",children:N.currentPhase})]}),s.jsxs("div",{className:"s-work-related-card-meta",children:[s.jsx("span",{children:N.ownerName??N.ownerId??"Unassigned"}),s.jsx("span",{children:gM(N.state)}),s.jsx("span",{children:Ae(N.lastMeaningfulAt)})]}),N.lastMeaningfulSummary&&s.jsx("div",{className:"s-work-related-card-copy",children:Ca(N.lastMeaningfulSummary)})]},N.id))})]})]})]})]})}function Ghe(){const{route:e,navigate:t}=qe();return s.jsx(Zhe,{children:Khe(e,t)})}function Zhe({children:e}){return s.jsx("div",{style:{background:"var(--bg)",color:"var(--ink)",minHeight:"100%",height:"100%",display:"flex",flexDirection:"column"},children:s.jsx("div",{className:"scout-surface-body",children:e})})}function Khe(e,t){switch(e.view){case"conversation":return s.jsx(hg,{conversationId:e.conversationId,initialComposeMode:e.composeMode,initialDraft:e.composeDraft,navigate:t});case"agent-info":return s.jsx(Jne,{conversationId:e.conversationId,navigate:t});case"settings":return s.jsx(bue,{navigate:t,section:e.section,agentId:e.agentId});case"agents":return s.jsx(vie,{navigate:t,selectedAgentId:e.agentId,conversationId:e.conversationId,tab:e.tab});case"fleet":return s.jsx(ET,{navigate:t});case"conversations":return s.jsx(goe,{navigate:t});case"messages":return s.jsx(Sce,{conversationId:e.conversationId,navigate:t});case"sessions":return e.sessionId?s.jsx(Hce,{sessionRef:e.sessionId,navigate:t}):s.jsx(Vce,{navigate:t});case"channels":return s.jsx(VP,{channelId:e.channelId,navigate:t});case"mesh":return s.jsx(kce,{navigate:t});case"broker":return s.jsx(Wie,{navigate:t});case"briefings":return e.briefingId?s.jsx(Oie,{briefingId:e.briefingId,navigate:t}):s.jsx(Hie,{navigate:t});case"activity":return s.jsx(Hne,{navigate:t});case"ops":return s.jsx(vhe,{navigate:t,mode:e.mode,tailQuery:e.tailQuery});case"terminal":return s.jsx(jhe,{agentId:e.agentId,mode:e.mode,navigate:t});case"work":return s.jsx(Whe,{workId:e.workId,navigate:t});case"follow":return s.jsx(yoe,{route:e,navigate:t});default:return s.jsx(ET,{navigate:t})}}function al(e,t,n={}){n.returnTo&&eP("agents",n.returnTo),e({view:"agents",agentId:t.id,...n.observe?{conversationId:t.conversationId,tab:"observe"}:{}})}const Yhe=new Intl.NumberFormat("en-US"),Xhe=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1});function Co(e){return typeof e!="number"||!Number.isFinite(e)?"-":Math.abs(e)<1e3?Yhe.format(e):Xhe.format(e).toLowerCase()}function Qhe(e){if(!Number.isFinite(e)||e<=0)return"0s";if(e<60)return`${Math.round(e)}s`;const t=Math.round(e),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?`${n}h ${a}m`:a>=10||r===0?`${a}m`:`${a}m ${r}s`}function Jhe(e){return e.replace(/\.local$/i,"").replace(/-local-openscout$/i,"")}function ZD(e){const n=e.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return n[n.length-1]??e}async function eme(e){await me("/api/local-path/reveal",{method:"POST",body:JSON.stringify({path:e.path,agentId:e.agentId,...e.basePath?{basePath:e.basePath}:{},...e.sessionId?{sessionId:e.sessionId}:{}})})}function KD(e){eme(e).catch(t=>{console.warn("Failed to reveal local path",t)})}function tme(){const{route:e,agents:t,navigate:n}=qe();if(e.view!=="agents")return null;const a=e.agentId?t.find(r=>r.id===e.agentId)??null:null;if(!a){const r=t.filter(o=>Vi(o.state)).length;return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsx(ja,{label:"Total",value:`${t.length}`}),s.jsx(ja,{label:"Working",value:`${r}`}),s.jsx(ja,{label:"Available",value:`${t.length-r}`}),s.jsx("div",{className:"mt-2 text-[10px] font-mono uppercase tracking-[0.15em] leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:"Select an agent from the roster to see its context here."})]})}return s.jsx(nme,{agent:a,agents:t,navigate:n,route:e,observeMode:e.tab==="observe"})}function nme({agent:e,agents:t,navigate:n,route:a,observeMode:r}){const o=Vi(e.state),[c,u]=m.useState(null),[h,f]=m.useState(null),g=m.useCallback(async()=>{const[v,y]=await Promise.all([me("/api/fleet").catch(()=>null),me(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).catch(()=>null)]);v&&u(v),f(y)},[e.id]);return m.useEffect(()=>{g()},[g]),m.useEffect(()=>{f(null)},[e.id]),tn(()=>{g()}),s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[s.jsxs("div",{className:"relative flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-[13px] font-mono text-[var(--scout-chrome-avatar-ink)]",style:{background:qt(e.name)},children:[e.name[0]?.toUpperCase()??"?",o&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-[var(--hud-bg)]",style:{background:Pn(e.state),opacity:Je(e.state)==="working"?.85:.6}})]}),s.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[s.jsx("span",{className:"truncate text-[13px] text-[var(--scout-chrome-ink-strong)]",children:e.name}),e.handle&&s.jsxs("span",{className:"text-[10px] font-mono text-cyan-400/70",children:["@",e.handle]})]})]}),s.jsxs(Va,{label:"State",children:[s.jsxs("div",{className:"flex items-baseline gap-2",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:Pn(e.state),opacity:o?1:.4}}),s.jsx("span",{className:"text-[12px] capitalize text-[var(--scout-chrome-ink)]",children:ia(e.state)})]}),e.updatedAt&&s.jsxs("div",{className:"mt-1 text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:["Updated ",Ae(e.updatedAt)]})]}),s.jsx(Va,{label:"Presence",children:s.jsx(lme,{focusAgent:e,agents:t,onOpenAgent:v=>al(n,v,{returnTo:a})})}),r&&s.jsx(ime,{agentId:e.id}),c&&s.jsx(cme,{asks:c.activeAsks,agentId:e.id,navigate:n}),s.jsxs(Va,{label:"Identity",children:[s.jsx(ja,{label:"Class",value:e.agentClass}),e.role&&s.jsx(ja,{label:"Role",value:e.role}),e.harness&&s.jsx(ja,{label:"Harness",value:e.harness}),e.transport&&s.jsx(ja,{label:"Transport",value:e.transport}),(e.homeNodeName||e.homeNodeId)&&s.jsx(ja,{label:"Host",value:Jhe(e.homeNodeName??e.homeNodeId??"")})]}),(e.project||e.branch||e.cwd)&&s.jsxs(Va,{label:"Project",children:[e.project&&s.jsx(ja,{label:"Name",value:e.project}),e.branch&&s.jsx(ja,{label:"Branch",value:e.branch}),e.cwd&&s.jsx(ja,{label:"Cwd",value:e.cwd})]}),e.capabilities.length>0&&s.jsx(Va,{label:`Capabilities · ${e.capabilities.length}`,children:s.jsx("div",{className:"flex flex-wrap gap-1",children:e.capabilities.map(v=>s.jsx("span",{className:"rounded-sm bg-[var(--scout-chrome-hover)] px-1.5 py-0.5 text-[10px] font-mono text-[var(--scout-chrome-ink-soft)]",children:v},v))})}),s.jsx(sme,{agent:e,catalog:h,navigate:n,returnTo:a})]})}function sme({agent:e,catalog:t,navigate:n,returnTo:a}){const r=Lc(),o=t?.activeSessionId??(e.transport==="tmux"?e.harnessSessionId:null),u=m.useMemo(()=>ame(e,t,o),[e,t,o]).filter(x=>x.id===o||!x.endedAt),h=u.slice(0,5);if(h.length===0)return null;const f=x=>kt(n,{view:"terminal",agentId:e.id,mode:x},{returnTo:a}),g=()=>{if(e.transport==="tmux"){f("takeover");return}t?.resumeCommand&&ef({command:t.resumeCommand,cwd:t.resumeCwd,agentId:e.id}).then(()=>f("takeover"))},v=x=>kt(n,{view:"sessions",sessionId:x},{returnTo:a}),y=(x,w,C)=>{const T=[];return w&&T.push({kind:"action",label:"Observe in terminal",onSelect:()=>f("observe")}),C&&T.push({kind:"action",label:"Takeover terminal",onSelect:g}),T.length>0&&T.push({kind:"separator"}),T.push({kind:"action",label:"Open session detail",onSelect:()=>v(x.id)}),T.push({kind:"action",label:"Open agent profile",onSelect:()=>al(n,e,{returnTo:a})}),T};return s.jsx(Va,{label:`Running sessions · ${u.length}`,children:s.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.map(x=>{const w=x.id===o,C=w&&e.transport==="tmux",T=w&&(e.transport==="tmux"||!!t?.resumeCommand),E=Ae(x.startedAt)||"recent",S=x.transport??x.harness??e.transport??e.harness??"session",k=w?E:x.endedAt?`${Ae(x.endedAt)||E} ended`:S,N=y(x,C,T);return s.jsxs("div",{onContextMenu:A=>r(A,N),className:`rounded border px-2 py-1.5 transition-colors ${w?"border-cyan-400/40 bg-cyan-400/[0.08]":"border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)]"}`,children:[s.jsxs("button",{type:"button",title:C?`Observe tmux terminal ${x.id}`:`Open session ${x.id}`,onClick:()=>C?f("observe"):v(x.id),className:"flex w-full items-center justify-between gap-2 bg-transparent p-0 text-left",children:[s.jsxs("span",{className:"flex min-w-0 flex-col",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[w&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-cyan-300"}),s.jsx("span",{className:"truncate font-mono text-[10.5px] text-[var(--scout-chrome-ink)]",children:rme(x.id)}),s.jsx("span",{className:"shrink-0 rounded-sm bg-[var(--scout-chrome-hover)] px-1 py-0.5 font-mono text-[8px] uppercase tracking-[0.08em] text-[var(--scout-chrome-ink-faint)]",children:S})]}),s.jsx("span",{className:"mt-0.5 truncate font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:x.cwd?ZD(x.cwd):"workspace"})]}),s.jsxs("span",{className:"flex shrink-0 flex-col items-end",children:[s.jsx("span",{className:"font-mono text-[9px] uppercase tracking-[0.12em] text-cyan-400/70",children:w?"active":"running"}),s.jsx("span",{className:"mt-0.5 max-w-[78px] truncate font-mono text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:k})]})]}),s.jsx("button",{type:"button",title:"Session actions",onClick:A=>r(A,N),className:"mt-1.5 h-5 rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-1.5 font-mono text-[8.5px] uppercase tracking-[0.08em] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-active)] hover:text-[var(--scout-chrome-ink)]",children:"..."})]},x.id)}),u.length>h.length&&s.jsxs("div",{className:"px-1 pt-0.5 font-mono text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:[u.length-h.length," more running"]})]})})}function ame(e,t,n){const a=[...t?.sessions??[]];return e.transport==="tmux"&&n&&!a.some(r=>r.id===n)&&a.unshift({id:n,startedAt:e.createdAt??e.updatedAt??Date.now(),cwd:e.cwd??e.projectRoot??".",...e.harness?{harness:e.harness}:{},...e.transport?{transport:e.transport}:{},model:e.model}),a.sort((r,o)=>{const c=r.endedAt??r.startedAt,u=o.endedAt??o.startedAt;return lg(c,u)})}function rme(e){const t=e.replace(/^session[_:-]?/i,"");return t.length>10?t.slice(0,8):t}function ime({agentId:e}){const[t,n]=m.useState(null),a=m.useCallback(async()=>{const r=await me(`/api/agents/${encodeURIComponent(e)}/observe`).catch(()=>null);n(r)},[e]);return m.useEffect(()=>{a()},[a]),tn(()=>{a()}),t?.data?s.jsx(ome,{agentId:e,data:t.data,sessionId:t.sessionId}):s.jsx(Va,{label:"Trace",children:s.jsx("div",{className:"text-[10px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:"Resolving session trace."})})}function ome({agentId:e,data:t,sessionId:n}){const a=t.metadata?.session,r=t.events,o=t.files,c=r.filter(x=>x.kind==="tool").length,u=r.filter(x=>x.kind==="think").length,h=r.filter(x=>x.kind==="ask").length,f=r.filter(x=>x.kind==="tool"&&x.tool==="read").length,g=r.filter(x=>x.kind==="tool"&&(x.tool==="edit"||x.tool==="write")).length,v=r.length>0?r[r.length-1].t:0,y=a?.threadPath;return s.jsxs(s.Fragment,{children:[s.jsxs(Va,{label:"Session",children:[n&&s.jsx(ja,{label:"Active",value:n.slice(0,8)}),y&&s.jsx(yM,{label:"Source",path:y,basePath:a?.cwd??null,value:ZD(y),agentId:e,sessionId:n}),a?.cwd&&s.jsx(yM,{label:"Workspace",path:a.cwd,value:a.cwd,agentId:e,sessionId:n})]}),s.jsx(Va,{label:"Trace stats",children:s.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[s.jsx(Si,{label:"Turns",value:Co(a?.turnCount??0)}),s.jsx(Si,{label:"Tools",value:Co(c)}),s.jsx(Si,{label:"Thinks",value:Co(u)}),s.jsx(Si,{label:"Asks",value:Co(h)}),s.jsx(Si,{label:"Reads",value:Co(f)}),s.jsx(Si,{label:"Edits",value:Co(g)}),s.jsx(Si,{label:"Files",value:Co(o.length)}),s.jsx(Si,{label:"Window",value:Qhe(v)})]})}),o.length>0&&s.jsx(Va,{label:`Files touched · ${o.length}`,children:s.jsx("div",{className:"flex flex-col gap-1",children:o.slice(0,8).map(x=>s.jsxs("button",{type:"button",title:x.path,onClick:()=>KD({path:x.path,basePath:a?.cwd??null,agentId:e,sessionId:n}),className:"flex items-center justify-between gap-2 rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-2 py-1 text-left hover:border-[var(--accent)]",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-[10px] text-[var(--scout-chrome-ink-soft)]",children:x.path}),s.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:["x",x.touches]})]},x.path))})})]})}function yM({label:e,path:t,basePath:n,value:a,agentId:r,sessionId:o}){return s.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("button",{type:"button",title:`Reveal ${t}`,onClick:()=>KD({path:t,basePath:n,agentId:r,sessionId:o}),className:"min-w-0 truncate bg-transparent p-0 text-right font-mono text-[11px] text-cyan-400/80 hover:text-[var(--scout-chrome-ink)] hover:underline",children:a})]})}function Si({label:e,value:t}){return s.jsxs("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] px-2 py-1.5",children:[s.jsx("div",{className:"font-mono text-[8.5px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("div",{className:"mt-0.5 font-mono text-[12px] text-[var(--scout-chrome-ink)]",children:t})]})}function lme({focusAgent:e,agents:t,onOpenAgent:n}){const h=t.filter(g=>g.id!==e.id).slice(0,8),f=m.useMemo(()=>{const g=[{agent:e,x:120,y:90,focused:!0}];return h.forEach((v,y)=>{const x=2*Math.PI*y/Math.max(h.length,1)-Math.PI/2;g.push({agent:v,x:120+68*Math.cos(x),y:90+68*Math.sin(x),focused:!1})}),g},[e,h,120,90,68]);return s.jsxs("svg",{viewBox:"0 0 240 180",className:"w-full block",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("defs",{children:s.jsxs("radialGradient",{id:"inspMeshGlow",cx:"50%",cy:"50%",r:"50%",children:[s.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.06"}),s.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),s.jsx("circle",{cx:120,cy:90,r:82,fill:"url(#inspMeshGlow)"}),s.jsx("circle",{cx:120,cy:90,r:68,fill:"none",stroke:"var(--border)",strokeDasharray:"2 4"}),f.slice(1).map((g,v)=>s.jsxs("g",{children:[s.jsx("line",{x1:120,y1:90,x2:g.x,y2:g.y,stroke:"var(--accent)",strokeWidth:1,opacity:.6}),s.jsx("circle",{r:2,fill:"var(--accent)",children:s.jsx("animateMotion",{dur:`${2+v*.3}s`,repeatCount:"indefinite",path:`M 120,90 L ${g.x},${g.y}`})})]},`e-${g.agent.id}`)),f.map(g=>{const v=Je(g.agent.state),y=v==="working"||v==="available",x=g.focused?14:9;return s.jsxs("g",{style:{cursor:"pointer"},onClick:()=>n(g.agent),children:[y&&s.jsxs("circle",{cx:g.x,cy:g.y,r:x+5,fill:"none",stroke:qt(g.agent.name),strokeWidth:.8,opacity:.3,children:[s.jsx("animate",{attributeName:"r",values:`${x};${x+8};${x}`,dur:"2.5s",repeatCount:"indefinite"}),s.jsx("animate",{attributeName:"opacity",values:"0.3;0;0.3",dur:"2.5s",repeatCount:"indefinite"})]}),s.jsx("circle",{cx:g.x,cy:g.y,r:x,fill:qt(g.agent.name),stroke:g.focused?"var(--accent)":"var(--surface)",strokeWidth:g.focused?1.5:1}),s.jsx("text",{x:g.x,y:g.y,dy:"0.35em",textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:g.focused?10:8,fontWeight:600,fill:"var(--scout-chrome-avatar-ink)",children:g.agent.name[0].toUpperCase()}),s.jsx("text",{x:g.x,y:g.y+x+10,textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:8,fill:"var(--dim)",letterSpacing:"0.04em",children:g.agent.name.length>9?g.agent.name.slice(0,8)+"...":g.agent.name})]},g.agent.id)})]})}function cme({asks:e,agentId:t,navigate:n}){const a=e.filter(r=>r.agentId===t&&(r.status==="needs_attention"||r.status==="queued"));return a.length===0?null:s.jsx(Va,{label:`Incoming asks · ${a.length}`,children:s.jsx("div",{className:"flex flex-col gap-2",children:a.map(r=>s.jsxs("div",{className:"p-2.5 rounded-md border border-amber-500/30 bg-amber-500/[0.04] cursor-pointer hover:bg-amber-500/[0.08] transition-colors",onClick:()=>{r.conversationId&&n({view:"agents",agentId:t,conversationId:r.conversationId})},children:[s.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.12em] text-amber-500/80 mb-1",children:"awaiting"}),s.jsx("div",{className:"line-clamp-2 text-[11px] leading-relaxed text-[var(--scout-chrome-ink)]",children:r.summary??r.task}),s.jsxs("div",{className:"mt-1.5 text-[9px] font-mono text-[var(--scout-chrome-ink-ghost)]",children:[r.harness??"operator"," → ",r.agentName??"agent"]})]},r.invocationId))})})}function Va({label:e,children:t}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function ja({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}const ume={direct:"Direct message",channel:"Channel",group_direct:"Group",thread:"Thread"};function dme(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function fme(e){switch(e){case"queued":return"Queued";case"waking":return"Waking";case"waiting":return"Thinking";case"running":return"Working";default:return e.replace(/_/g," ")}}function hme(){const{route:e,agents:t,navigate:n}=qe(),a=e.view==="conversation"?e.conversationId:null,[r,o]=m.useState(null),[c,u]=m.useState([]),[h,f]=m.useState(null),[g,v]=m.useState(!1),y=m.useCallback(async()=>{if(!a){o(null),u([]),f(null),v(!0);return}try{const[V,Z,O]=await Promise.all([me(`/api/session/${encodeURIComponent(a)}`).catch(()=>null),me(`/api/flights?conversationId=${encodeURIComponent(a)}`).catch(()=>[]),me(`/api/messages?conversationId=${encodeURIComponent(a)}&limit=1`).catch(()=>[])]);o(V),u(Z??[]),f(O?.[O.length-1]??null),v(!0)}catch{v(!0)}},[a]);m.useEffect(()=>{v(!1),y()},[y]),tn(V=>{if(a){if(V.kind==="message.posted"){V.payload?.message?.conversationId===a&&y();return}(V.kind==="flight.updated"||V.kind==="invocation.requested")&&y()}});const x=r?.agentId??Ow(a??""),w=m.useMemo(()=>x?t.find(V=>V.id===x)??null:null,[t,x]),C=J$({name:w?.name,agentName:r?.agentName,id:x,title:r?.title}),T=w?Q$(w)??br(w.id)??w.id:x?br(x)??x:null,E=m.useMemo(()=>c.filter(Bc).sort((V,Z)=>(Z.startedAt??0)-(V.startedAt??0))[0]??null,[c]);if(!a)return null;if(!g)return s.jsx("div",{className:"ctx-panel ctx-panel--conversation",children:s.jsx("div",{className:"ctx-panel-empty-state",children:s.jsx("div",{className:"ctx-panel-empty-hint",children:"Loading conversation…"})})});const S=r?.kind?ume[r.kind]??r.kind:"Conversation",k=dme(r?.workspaceRoot??null),N=r?.currentBranch??null,A=w?.harness??r?.harness??null,R=r?.lastMessageAt??h?.createdAt??null,_=r?.messageCount??null,P=r?r.participantIds.filter(V=>V!=="operator").length+1:null,$=w?.state??null,H=Je($),I=h?.body?.trim()||r?.preview?.trim()||null,U=h?.actorName??null,D=()=>{x&&kt(n,{view:"agent-info",conversationId:a},{returnTo:e})};return s.jsxs("div",{className:"ctx-panel ctx-panel--conversation",children:[s.jsxs("section",{className:"ctx-panel-section ctx-panel-conversation-summary",children:[s.jsx("div",{className:"ctx-panel-section-label",children:S}),s.jsxs("div",{className:"ctx-panel-conversation-card",children:[s.jsx("div",{className:"ctx-panel-conversation-title",children:C}),T&&s.jsxs("div",{className:"ctx-panel-conversation-handle",children:["@",T]}),s.jsxs("div",{className:"ctx-panel-conversation-state",children:[s.jsx("span",{className:"ctx-panel-conversation-state-dot",style:{background:Pn($)}}),s.jsx("span",{children:ia($)})]})]})]}),E&&s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Now"}),s.jsxs("div",{className:"ctx-panel-conversation-flight",children:[s.jsxs("div",{className:"ctx-panel-conversation-flight-row",children:[s.jsx("span",{className:"ctx-panel-conversation-flight-label",children:fme(E.state)}),E.startedAt&&s.jsx("span",{className:"ctx-panel-conversation-flight-time",children:Ae(E.startedAt)})]}),E.summary&&s.jsx("div",{className:"ctx-panel-conversation-flight-summary",children:E.summary})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Workspace"}),s.jsxs("div",{className:"ctx-panel-conversation-rows",children:[k&&s.jsx(Eo,{label:"Project",value:k,title:r?.workspaceRoot??void 0}),N&&s.jsx(Eo,{label:"Branch",value:N}),A&&s.jsx(Eo,{label:"Harness",value:A}),!k&&!N&&!A&&s.jsx("div",{className:"ctx-panel-empty",children:"No workspace metadata yet"})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Activity"}),s.jsxs("div",{className:"ctx-panel-conversation-rows",children:[typeof _=="number"&&s.jsx(Eo,{label:"Messages",value:`${_}`}),typeof P=="number"&&s.jsx(Eo,{label:"In thread",value:`${P}`}),R&&s.jsx(Eo,{label:"Last",value:Ae(R)??"",title:Mm(R)}),H&&s.jsx(Eo,{label:"Agent",value:ia($)})]})]}),I&&s.jsxs("section",{className:"ctx-panel-section ctx-panel-conversation-preview",children:[s.jsx("div",{className:"ctx-panel-section-label",children:U?`Latest · ${U}`:"Latest"}),s.jsx("div",{className:"ctx-panel-conversation-preview-body",children:I})]}),x&&s.jsx("section",{className:"ctx-panel-section",children:s.jsxs("button",{type:"button",className:"ctx-panel-roster-button ctx-panel-conversation-profile-button",onClick:D,children:[s.jsx("span",{className:"ctx-panel-roster-label",children:"Open agent profile"}),s.jsx("span",{className:"ctx-panel-roster-count",children:s.jsx("span",{children:"→"})})]})})]})}function Eo({label:e,value:t,title:n}){return s.jsxs("div",{className:"ctx-panel-conversation-row",title:n,children:[s.jsx("span",{className:"ctx-panel-conversation-row-label",children:e}),s.jsx("span",{className:"ctx-panel-conversation-row-value",children:t})]})}function mme(){const{agents:e,navigate:t,route:n}=qe(),a=c=>al(t,c,{returnTo:n});if(e.length===0)return s.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center font-mono text-[11px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:[s.jsx("div",{className:"mb-1 uppercase tracking-[0.15em]",children:"No agents"}),s.jsx("div",{children:"Connect an agent to see your roster here."})]});const r=e.filter(c=>Vi(c.state)),o=e.filter(c=>!Vi(c.state));return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[r.length>0&&s.jsx(xM,{label:"Online",count:r.length,children:r.map(c=>s.jsx(bM,{agent:c,onOpen:a},c.id))}),o.length>0&&s.jsx(xM,{label:"Standby",count:o.length,children:o.map(c=>s.jsx(bM,{agent:c,onOpen:a,dim:!0},c.id))})]})}function xM({label:e,count:t,children:n}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[s.jsx("span",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:t})]}),s.jsx("div",{className:"flex flex-col gap-0.5",children:n})]})}function bM({agent:e,onOpen:t,dim:n}){const a=Vi(e.state);return s.jsxs("button",{onClick:()=>t(e),className:`group flex items-center gap-2.5 px-2 py-1.5 rounded-sm text-left transition-colors ${n?"opacity-60 hover:opacity-100 hover:bg-[var(--scout-chrome-hover)]":"hover:bg-[var(--scout-chrome-hover)]"}`,children:[s.jsxs("div",{className:"relative h-6 w-6 shrink-0 rounded-full text-[10px] font-mono flex items-center justify-center text-[var(--scout-chrome-avatar-ink)]",style:{background:qt(e.name)},children:[e.name[0]?.toUpperCase()??"?",a&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full bg-emerald-400 ring-2 ring-[var(--hud-bg)]"})]}),s.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[s.jsx("span",{className:"truncate text-[12px] text-[var(--scout-chrome-ink)] transition-colors group-hover:text-[var(--scout-chrome-ink-strong)]",children:e.name}),s.jsx("span",{className:"truncate text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:ia(e.state)})]}),e.updatedAt&&s.jsx("span",{className:"shrink-0 text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:Ae(e.updatedAt)})]})}function pme(){const{route:e}=qe(),[t,n]=m.useState([]),a=m.useCallback(async()=>{try{n(await me("/api/sessions"))}catch{}},[]);if(m.useEffect(()=>{a()},[a]),tn(()=>{a()}),e.view!=="sessions")return null;const r=e.sessionId?t.find(o=>o.id===e.sessionId)??null:null;if(!r){const o=new Set(t.map(u=>u.kind)),c=t.filter(u=>u.currentBranch).length;return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsx(ar,{label:"Total",value:`${t.length}`}),s.jsx(ar,{label:"Kinds",value:`${o.size}`}),s.jsx(ar,{label:"Branched",value:`${c}`}),s.jsx("div",{className:"mt-2 text-[10px] font-mono uppercase tracking-[0.15em] leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:"Select a session from the list to see its context here."})]})}return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[s.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[s.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:r.title}),s.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-cyan-400/70 mt-1",children:r.kind})]}),r.agentName&&s.jsxs(Qh,{label:"Agent",children:[s.jsx(ar,{label:"Name",value:r.agentName}),r.harness&&s.jsx(ar,{label:"Harness",value:r.harness})]}),(r.currentBranch||r.workspaceRoot)&&s.jsxs(Qh,{label:"Workspace",children:[r.currentBranch&&s.jsx(ar,{label:"Branch",value:r.currentBranch}),r.workspaceRoot&&s.jsx(ar,{label:"Root",value:r.workspaceRoot})]}),s.jsxs(Qh,{label:"Activity",children:[s.jsx(ar,{label:"Messages",value:`${r.messageCount}`}),r.lastMessageAt&&s.jsx(ar,{label:"Last",value:Ae(r.lastMessageAt)}),r.participantIds.length>0&&s.jsx(ar,{label:"Participants",value:`${r.participantIds.length}`})]}),r.preview&&s.jsx(Qh,{label:"Preview",children:s.jsxs("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:['"',r.preview,'"']})})]})}function Qh({label:e,children:t}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function ar({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function gme(){const{route:e,agents:t,navigate:n}=qe();if(e.view!=="terminal")return null;const a=e.agentId?t.find(c=>c.id===e.agentId)??null:null,r=e.mode??"takeover";if(!a)return s.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-4 text-[11px]",children:s.jsxs(em,{label:"Terminal",children:[s.jsx(Ss,{label:"Mode",value:jM(r)}),e.agentId&&s.jsx(Ss,{label:"Agent",value:e.agentId})]})});const o=a.transport==="tmux"?a.harnessSessionId:null;return s.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-y-auto p-4 text-[11px] frame-scrollbar",children:[s.jsx(vme,{agent:a}),s.jsxs(em,{label:"Terminal",children:[s.jsx(Ss,{label:"Mode",value:jM(r)}),s.jsx(Ss,{label:"Backend",value:o?"tmux":"pty"}),o&&s.jsx(Ss,{label:"Session",value:o}),s.jsx(Ss,{label:"State",value:ia(a.state)})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[o&&s.jsx(Jh,{active:r==="observe",label:"Observe",onClick:()=>n(wM(a.id,"observe"))}),s.jsx(Jh,{active:r==="takeover",label:"Takeover",onClick:()=>n(wM(a.id,"takeover"))}),s.jsx(Jh,{label:"Profile",onClick:()=>n({view:"agents",agentId:a.id,tab:"profile"})}),s.jsx(Jh,{label:"Trace",onClick:()=>n({view:"agents",agentId:a.id,tab:"observe"})})]}),s.jsxs(em,{label:"Agent",children:[s.jsx(Ss,{label:"Harness",value:a.harness??"-"}),s.jsx(Ss,{label:"Transport",value:a.transport??"-"}),a.role&&s.jsx(Ss,{label:"Role",value:a.role}),a.handle&&s.jsx(Ss,{label:"Handle",value:`@${a.handle}`}),a.updatedAt&&s.jsx(Ss,{label:"Updated",value:Ae(a.updatedAt)})]}),(a.project||a.branch||a.cwd||a.projectRoot)&&s.jsxs(em,{label:"Workspace",children:[a.project&&s.jsx(Ss,{label:"Name",value:a.project}),a.branch&&s.jsx(Ss,{label:"Branch",value:a.branch}),a.cwd&&s.jsx(Ss,{label:"Cwd",value:a.cwd}),!a.cwd&&a.projectRoot&&s.jsx(Ss,{label:"Root",value:a.projectRoot})]})]})}function wM(e,t){return{view:"terminal",agentId:e,mode:t}}function jM(e){return e==="observe"?"Read-only observe":"Interactive takeover"}function vme({agent:e}){return s.jsx("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full font-mono text-[12px] text-[var(--scout-chrome-avatar-ink)]",style:{background:qt(e.name)},children:e.name[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:e.name}),e.handle&&s.jsxs("div",{className:"truncate font-mono text-[10px] text-cyan-400/70",children:["@",e.handle]})]})]})})}function Jh({active:e,label:t,onClick:n}){return s.jsx("button",{type:"button",onClick:n,className:`h-7 rounded border px-2 font-mono text-[9px] uppercase tracking-[0.1em] transition-colors ${e?"border-cyan-400/35 bg-cyan-400/[0.12] text-cyan-200":"border-[var(--scout-chrome-border-soft)] bg-[var(--scout-chrome-hover)] text-[var(--scout-chrome-ink-soft)] hover:bg-[var(--scout-chrome-active)] hover:text-[var(--scout-chrome-ink)]"}`,children:t})}function em({label:e,children:t}){return s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Ss({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"truncate text-right text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}const yme=5;function xme(){const{route:e,navigate:t}=qe(),n=e.view==="work"?e.workId:null,[a,r]=m.useState(null),o=m.useCallback(async()=>{if(!n){r(null);return}try{r(await me(`/api/work/${encodeURIComponent(n)}`))}catch{r(null)}},[n]);if(m.useEffect(()=>{o()},[o]),tn(()=>{n&&o()}),e.view!=="work")return null;if(!a)return s.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-[11px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-ghost)]",children:"Loading work item…"});const c=jme(a.state),u=wme(a.attention),h=a.ownerName??a.ownerId??"Unassigned",f=a.nextMoveOwnerName??a.nextMoveOwnerId??null,g=f!==null&&(a.ownerId??null)!==(a.nextMoveOwnerId??null)&&f!==h,v=1+(g?1:0)+(a.priority?1:0)+2+(a.parentId?1:0)+(a.conversationId?1:0);return s.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar text-[11px]",children:[s.jsx("div",{className:"sticky top-0 z-10 border-b border-[var(--scout-chrome-border-soft)] bg-black/55 px-4 py-2 backdrop-blur",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c.dot}`}),s.jsx("span",{className:`font-mono text-[10px] uppercase tracking-[0.15em] ${c.text}`,children:bme(a.state)}),s.jsxs("span",{className:"min-w-0 flex-1 truncate text-[10px] text-[var(--scout-chrome-ink-faint)]",children:[s.jsx("span",{className:"text-[var(--scout-chrome-ink)]",children:h}),g&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"px-1 text-[var(--scout-chrome-ink-ghost)]",children:"→"}),s.jsx("span",{className:"text-[var(--scout-chrome-ink)]",children:f})]})]}),u&&s.jsx("span",{className:"shrink-0 rounded border border-amber-400/30 bg-amber-400/10 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-amber-300/90",children:u})]})}),s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs(Vu,{label:"Case facts",children:[s.jsx(Xs,{label:"Phase",value:a.currentPhase}),s.jsx(Xs,{label:"Acceptance",value:a.acceptanceState.replace(/_/g," ")}),a.priority&&s.jsx(Xs,{label:"Priority",value:a.priority})]}),s.jsx(Vu,{label:"Timeline",children:a.timeline.length===0?s.jsx("div",{className:"text-[10px] text-[var(--scout-chrome-ink-faint)]",children:"No activity yet."}):s.jsx("div",{className:"flex flex-col gap-1.5",children:a.timeline.slice(0,yme).map(y=>s.jsx(Nme,{item:y,onOpen:y.conversationId?()=>kt(t,{view:"conversation",conversationId:y.conversationId},{returnTo:e}):void 0},y.id))})}),s.jsxs(Vu,{label:"Routing",collapsible:!0,defaultOpen:!1,count:v,children:[s.jsx(Xs,{label:"Owner",value:h}),g&&f&&s.jsx(Xs,{label:"Next move",value:f}),a.priority&&s.jsx(Xs,{label:"Priority",value:a.priority}),s.jsx(Xs,{label:"Children",value:`${a.activeChildWorkCount}`}),s.jsx(Xs,{label:"Flights",value:`${a.activeFlightCount}`}),a.lastMeaningfulAt&&s.jsx(Xs,{label:"Last update",value:Ae(a.lastMeaningfulAt)}),(a.conversationId||a.parentId)&&s.jsxs("div",{className:"mt-2 flex flex-col gap-1.5",children:[a.conversationId&&s.jsx(NM,{label:"Open thread",onClick:()=>kt(t,{view:"conversation",conversationId:a.conversationId},{returnTo:e})}),a.parentId&&a.parentTitle&&s.jsx(NM,{label:a.parentTitle,eyebrow:"Parent",onClick:()=>kt(t,{view:"work",workId:a.parentId},{returnTo:e})})]})]}),s.jsxs(Vu,{label:"Record",collapsible:!0,defaultOpen:!1,children:[s.jsx(Xs,{label:"Case ID",value:a.id}),s.jsx(Xs,{label:"Created",value:Wa(a.createdAt)}),s.jsx(Xs,{label:"Updated",value:Wa(a.updatedAt)}),s.jsx(Xs,{label:"Last activity",value:Wa(a.lastMeaningfulAt)})]}),a.lastMeaningfulSummary&&s.jsxs(Vu,{label:"Hudson context",collapsible:!0,defaultOpen:!1,children:[s.jsx("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:a.lastMeaningfulSummary}),s.jsxs("div",{className:"mt-2 flex gap-1.5",children:[s.jsx("span",{className:"rounded border border-[var(--scout-chrome-border-soft)] px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:"Plan"}),s.jsx("span",{className:"rounded border border-[var(--scout-chrome-border-soft)] px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:"Docs"}),s.jsx("span",{className:"rounded border border-[var(--scout-chrome-border-soft)] px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:"Code"})]})]})]})]})}function bme(e){switch(e){case"review":return"In review";case"waiting":return"Waiting";case"working":return"Working";case"done":return"Done";default:return e.replace(/_/g," ")}}function wme(e){switch(e){case"badge":return"Noteworthy";case"interrupt":return"Blocked";default:return null}}function jme(e){return/complete|done|finished/i.test(e)?{dot:"bg-emerald-400",text:"text-emerald-300/90"}:/fail|error/i.test(e)?{dot:"bg-red-400",text:"text-red-300/90"}:/block|wait|pause/i.test(e)?{dot:"bg-amber-400",text:"text-amber-300/90"}:/active|working|in[_-]?progress/i.test(e)?{dot:"bg-cyan-400",text:"text-cyan-300/90"}:{dot:"bg-[var(--scout-chrome-ink-faint)]",text:"text-[var(--scout-chrome-ink)]"}}function Vu({label:e,children:t,collapsible:n=!1,defaultOpen:a=!0,count:r}){const[o,c]=m.useState(a);return n?s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("button",{type:"button",onClick:()=>c(u=>!u),className:"flex items-center gap-1.5 text-left text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)] hover:text-[var(--scout-chrome-ink)]",children:[o?s.jsx(Vo,{"aria-hidden":"true",size:10,strokeWidth:2}):s.jsx(Rp,{"aria-hidden":"true",size:10,strokeWidth:2}),s.jsx("span",{children:e}),typeof r=="number"&&r>0&&s.jsx("span",{className:"rounded border border-[var(--scout-chrome-border-soft)] px-1 py-0 font-mono text-[8px] tracking-[0.1em] text-[var(--scout-chrome-ink-faint)]",children:r})]}),o&&s.jsx("div",{className:"mt-1.5",children:t})]}):s.jsxs("div",{className:"flex flex-col",children:[s.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function NM({label:e,eyebrow:t,onClick:n}){return s.jsxs("button",{type:"button",onClick:n,className:"flex items-center justify-between gap-2 rounded border border-[var(--scout-chrome-border-soft)] bg-white/[0.025] px-2 py-1.5 text-left hover:border-cyan-400/25 hover:bg-cyan-400/10",children:[s.jsxs("span",{className:"min-w-0",children:[t&&s.jsx("span",{className:"block font-mono text-[9px] uppercase tracking-[0.14em] text-[var(--scout-chrome-ink-faint)]",children:t}),s.jsx("span",{className:"block truncate font-mono text-[10px] text-[var(--scout-chrome-ink)]",children:e})]}),s.jsx(_p,{"aria-hidden":"true",size:11,strokeWidth:1.8,className:"shrink-0 text-cyan-300/75"})]})}function Nme({item:e,onOpen:t}){const n=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`mt-1 h-1.5 w-1.5 shrink-0 rounded-full ${Sme(e)}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"font-mono text-[9px] text-[var(--scout-chrome-ink-faint)]",children:Ae(e.at)}),s.jsx("span",{className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] px-1 py-0.5 font-mono text-[8px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:kme(e)})]}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] font-semibold text-[var(--scout-chrome-ink-strong)]",children:e.actorName??"system"}),e.title&&s.jsx("span",{className:"mt-0.5 block truncate text-[10px] leading-snug text-[var(--scout-chrome-ink)]",children:e.title}),e.summary&&s.jsx("span",{className:"mt-0.5 block text-[10px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",style:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,overflow:"hidden"},children:e.summary})]})]}),a="flex gap-2 border-t border-[var(--scout-chrome-border-soft)] pt-1.5 first:border-t-0 first:pt-0",r=Wa(e.at);return t?s.jsx("button",{type:"button",onClick:t,title:r,className:`${a} text-left hover:text-cyan-300/90`,children:n}):s.jsx("div",{className:a,title:r,children:n})}function kme(e){switch(e.kind){case"flight_started":return"flight started";case"flight_completed":return e.detailKind?`flight ${e.detailKind}`:"flight ended";case"message":return"message";default:return e.title??e.detailKind??"event"}}function Sme(e){return e.kind==="message"?"bg-cyan-400":e.kind==="flight_started"?"bg-lime-400":e.kind==="flight_completed"?e.detailKind?.includes("fail")?"bg-red-400":"bg-emerald-400":e.detailKind?.includes("interrupt")||e.detailKind?.includes("block")?"bg-amber-400":"bg-[var(--scout-chrome-ink-faint)]"}function Xs({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[s.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),s.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function Cme(e){return e.issues.some(t=>t.code==="mesh_loopback")?"loopback":e.identity.discoverable?"discoverable":e.tailscale.available?e.tailscale.running?"local-only":"tailnet-stopped":"unavailable"}function Eme(e){const t=new Map;for(const n of e){const a=(n.harness??n.agentClass??"agent").toLowerCase(),r=t.get(a)??{total:0,working:0};r.total+=1,Je(n.state)==="working"&&(r.working+=1),t.set(a,r)}return Array.from(t.entries()).map(([n,a])=>({label:n,total:a.total,working:a.working})).sort((n,a)=>a.total-n.total).slice(0,6)}function kM(e){return e?e.replace(/^https?:\/\//,"").split("/")[0]??e:"Unavailable"}function Ame(e){return e.split("/")[0]}function Tme(e){return new Promise(t=>window.setTimeout(t,e))}async function SM(e,t){let n=null,a=null;for(let r=0;r<=t.attempts;r+=1){try{if(n=await me("/api/mesh"),bp(n),e(n))return n}catch(o){a=o}r<t.attempts&&await Tme(t.intervalMs)}if(n)return n;throw a instanceof Error?a:new Error("Mesh status is temporarily unavailable.")}function Mme(e){return e.issues.find(t=>t.code==="local_only"||t.code==="mesh_loopback"||t.code==="tailscale_stopped")?.summary??null}function Rme(){const{meshSnapshot:e,selectedId:t,selectedType:n,probeCache:a}=Sc(),{agents:r}=lD(),[o,c]=m.useState(!1),[u,h]=m.useState(!1),[f,g]=m.useState(null),v=m.useCallback(async()=>{c(!0),g({tone:"info",text:"Restarting broker with mesh discovery enabled..."});try{const N=await me("/api/mesh/announce",{method:"POST",body:"{}"});bp(N);const A=N.identity.discoverable?N:await SM(R=>R.identity.discoverable,{attempts:6,intervalMs:750});A.identity.discoverable?g({tone:"success",text:`Discoverable at ${kM(A.identity.announceUrl??A.brokerUrl)}.`}):g({tone:"warning",text:Mme(A)??"Scout restarted the broker, but it is not discoverable yet."})}catch(N){g({tone:"error",text:N instanceof Error?N.message:String(N)})}finally{c(!1)}},[]),y=m.useCallback(async()=>{h(!0),g({tone:"info",text:"Opening Tailscale and waiting for the backend..."});try{const N=await me("/api/mesh/tailscale",{method:"POST",body:JSON.stringify({action:"open_app"})});bp(N);const A=N.tailscale.running?N:await SM(R=>R.tailscale.running,{attempts:12,intervalMs:1e3});A.tailscale.running?g({tone:"success",text:`Tailscale is running with ${A.tailscale.onlineCount} online peer${A.tailscale.onlineCount===1?"":"s"}.`}):g({tone:"warning",text:`Tailscale opened, but the backend is still ${A.tailscale.backendState??"not running"}. Finish startup or sign-in in Tailscale.app.`})}catch(N){g({tone:"error",text:N instanceof Error?N.message:String(N)})}finally{h(!1)}},[]),x=m.useMemo(()=>{const N={total:r.length,working:0,available:0,offline:0};for(const A of r){const R=Je(A.state);N[R]+=1}return N},[r]),w=m.useMemo(()=>Eme(r),[r]);if(!e)return s.jsx("div",{className:"sys-inspector-empty",children:s.jsx("p",{children:"Loading mesh…"})});if(t?.startsWith("tailnet:")&&n==="node"){const N=t.slice(8),A=e.tailscale.peers.find($=>$.id===N),R=a[t]??null,_=A?.addresses?.[0]?Ame(A.addresses[0]):null,P=A?.hostName?.split(".")[0]??A?.hostName??"Tailnet peer";return s.jsxs("div",{className:"sys-inspector-content",children:[s.jsxs("div",{className:"sys-inspector-head",children:[s.jsx("h3",{className:"sys-inspector-title",children:P}),s.jsx("span",{className:`sys-chip sys-chip-${A?.online?"success":"failed"}`,children:A?.online?"Online":"Offline"})]}),s.jsxs("div",{className:"sys-detail-grid",children:[_&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Address"}),s.jsx("code",{className:"sys-detail-value",children:_})]}),A?.os&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Platform"}),s.jsx("span",{className:"sys-detail-value",children:A.os})]}),R?.result?.node?.meshId&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Mesh ID"}),s.jsxs("code",{className:"sys-detail-value",children:[R.result.node.meshId.slice(0,14),"…"]})]}),R?.result?.node?.name&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Node name"}),s.jsx("span",{className:"sys-detail-value",children:R.result.node.name})]})]}),(!R||R.status==="loading")&&s.jsx("div",{className:"sys-banner sys-banner-muted",style:{marginTop:8},children:s.jsx("span",{children:"Connecting to Scout broker…"})}),R?.status==="error"&&s.jsxs("div",{className:"sys-banner sys-banner-warning",style:{marginTop:8},children:[s.jsx("strong",{children:"Broker unreachable."}),s.jsx("span",{children:R.result?.error??"Could not reach the remote broker."})]}),R?.status==="done"&&R.result?.node?.capabilities?.length&&s.jsxs("div",{style:{marginTop:10},children:[s.jsx("div",{className:"sys-inspector-section-label",children:"Capabilities"}),s.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:R.result.node.capabilities.map($=>s.jsx("span",{className:"sys-chip sys-chip-neutral",children:$},$))})]}),R?.status==="done"&&R.result?.home&&s.jsxs("div",{style:{marginTop:14},children:[s.jsxs("div",{className:"sys-inspector-section-label",children:["Agents — ",R.result.home.agents.length," registered"]}),R.result.home.agents.length===0?s.jsx("div",{className:"sys-list-empty",style:{marginTop:4},children:s.jsx("p",{children:"No agents registered on this broker."})}):s.jsx("div",{className:"mesh-agent-table",style:{marginTop:4},children:R.result.home.agents.map($=>{const H=$.state==="working"?"working":$.state==="available"?"available":"offline";return s.jsxs("div",{className:"mesh-detail-agent",style:{padding:"4px 0"},children:[s.jsx("span",{className:`mesh-detail-dot mesh-detail-dot--${H}`}),s.jsxs("div",{className:"mesh-detail-agent-body",children:[s.jsx("span",{className:"mesh-detail-agent-name",style:{fontSize:12},children:$.title}),$.activeTask&&s.jsx("span",{className:"mesh-detail-agent-task",children:$.activeTask})]}),s.jsx("span",{className:`mesh-detail-agent-state mesh-detail-agent-state--${H}`,children:$.statusLabel||H})]},$.id)})})]}),s.jsx("button",{type:"button",className:"s-btn",style:{marginTop:14},onClick:()=>Fo(null,null),children:"Clear selection"})]})}if(t&&n==="node"){const A=Object.values(e.nodes).find(_=>_.id===t)??(e.localNode?.id===t?e.localNode:null),R=e.localNode?.id===t;return A?s.jsxs("div",{className:"sys-inspector-content",children:[s.jsxs("div",{className:"sys-inspector-head",children:[s.jsx("h3",{className:"sys-inspector-title",children:A.hostName?.split(".")[0]??A.name??"Node"}),R&&s.jsx("span",{className:"sys-chip sys-chip-neutral",children:"this broker"})]}),s.jsxs("div",{className:"sys-detail-grid",children:[s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Node ID"}),s.jsxs("code",{className:"sys-detail-value",children:[A.id.slice(0,16),"…"]})]}),A.brokerUrl&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Broker URL"}),s.jsx("code",{className:"sys-detail-value",children:kM(A.brokerUrl)})]}),A.hostName&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Host"}),s.jsx("span",{className:"sys-detail-value",children:A.hostName})]}),!R&&"lastSeenAt"in A&&typeof A.lastSeenAt=="number"&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Last seen"}),s.jsx("span",{className:"sys-detail-value",children:Ae(A.lastSeenAt)})]}),!R&&s.jsxs("div",{className:"sys-detail-card",children:[s.jsx("span",{className:"sys-detail-label",children:"Scope"}),s.jsx("span",{className:"sys-detail-value",children:A.advertiseScope==="mesh"?"Announced to mesh":"Local only"})]})]}),R&&e.issues.length>0&&s.jsx("div",{className:"sys-issue-grid",style:{marginTop:12},children:e.issues.map((_,P)=>s.jsxs("article",{className:`sys-issue-card sys-issue-card-${_.severity==="error"?"error":"warning"}`,children:[s.jsx("div",{className:"sys-issue-head",children:s.jsx("h3",{className:"sys-issue-title",children:_.title})}),s.jsx("p",{className:"sys-issue-body",children:_.summary}),_.actionCommand&&s.jsx("div",{className:"sys-issue-action",children:s.jsx("code",{className:"sys-code-inline",children:_.actionCommand})})]},P))}),s.jsx("button",{type:"button",className:"s-btn",style:{marginTop:12},onClick:()=>Fo(null,null),children:"Clear selection"})]}):s.jsxs("div",{className:"sys-inspector-empty",children:[s.jsx("p",{children:"Node not found."}),s.jsx("button",{type:"button",className:"s-btn",onClick:()=>Fo(null,null),children:"Clear"})]})}const C=e,T=Cme(C),E=Object.values(C.nodes).filter(N=>N.id!==C.localNode?.id).length,S=C.tailscale.onlineCount??0,k=C.localNode?.hostName?.split(".")[0]??C.localNode?.name??C.identity.name??"this broker";return s.jsxs("div",{className:"sys-inspector-content mesh-summary",children:[s.jsxs("div",{className:"sys-inspector-head",children:[s.jsx("h3",{className:"sys-inspector-title",children:k}),s.jsx("span",{className:"mesh-summary-mode",children:C.identity.modeLabel})]}),s.jsx("section",{className:"mesh-summary-section",children:s.jsxs("div",{className:"mesh-summary-counts",children:[s.jsxs("div",{className:"mesh-summary-count",children:[s.jsx("span",{className:"mesh-summary-count-value",children:x.total}),s.jsx("span",{className:"mesh-summary-count-label",children:"agents"})]}),s.jsxs("div",{className:"mesh-summary-count mesh-summary-count--working",children:[s.jsx("span",{className:"mesh-summary-count-value",children:x.working}),s.jsx("span",{className:"mesh-summary-count-label",children:"working"})]}),s.jsxs("div",{className:"mesh-summary-count",children:[s.jsx("span",{className:"mesh-summary-count-value",children:x.available}),s.jsx("span",{className:"mesh-summary-count-label",children:"available"})]}),s.jsxs("div",{className:"mesh-summary-count mesh-summary-count--offline",children:[s.jsx("span",{className:"mesh-summary-count-value",children:x.offline}),s.jsx("span",{className:"mesh-summary-count-label",children:"offline"})]})]})}),w.length>0&&s.jsxs("section",{className:"mesh-summary-section",children:[s.jsx("div",{className:"sys-inspector-section-label",children:"By harness"}),s.jsx("div",{className:"mesh-summary-harness",children:w.map(N=>s.jsxs("div",{className:"mesh-summary-harness-row",children:[s.jsx("span",{className:"mesh-summary-harness-name",children:N.label}),s.jsx("span",{className:"mesh-summary-harness-count",children:N.total}),N.working>0&&s.jsxs("span",{className:"mesh-summary-harness-working",children:[N.working," working"]})]},N.label))})]}),s.jsxs("section",{className:"mesh-summary-section",children:[s.jsx("div",{className:"sys-inspector-section-label",children:"Peers"}),s.jsxs("div",{className:"mesh-summary-peers",children:[s.jsxs("div",{className:"mesh-summary-peer-row",children:[s.jsx("span",{className:"mesh-summary-peer-label",children:"Mesh"}),s.jsx("span",{className:"mesh-summary-peer-value",children:E})]}),C.tailscale.available&&s.jsxs("div",{className:"mesh-summary-peer-row",children:[s.jsx("span",{className:"mesh-summary-peer-label",children:"Tailnet"}),s.jsx("span",{className:`mesh-summary-peer-value${C.tailscale.running?"":" mesh-summary-peer-value--dim"}`,children:C.tailscale.running?`${S} online`:"stopped"})]})]})]}),s.jsxs("section",{className:"mesh-summary-section mesh-summary-reach",children:[s.jsx("div",{className:"sys-inspector-section-label",children:"Reach"}),s.jsx(Ime,{state:T,tailscaleAvailable:C.tailscale.available,announcing:o,tailscaleBusy:u,onAnnounce:()=>{v()},onStartTailscale:()=>{y()}}),f&&s.jsx("div",{className:`sys-banner mesh-action-message sys-banner-${f.tone}`,children:s.jsx("span",{children:f.text})})]})]})}function Ime({state:e,tailscaleAvailable:t,announcing:n,tailscaleBusy:a,onAnnounce:r,onStartTailscale:o}){return e==="discoverable"?s.jsxs("div",{className:"mesh-reach mesh-reach--on",children:[s.jsx("span",{className:"mesh-reach-dot"}),s.jsx("span",{className:"mesh-reach-label",children:"Discoverable on mesh"})]}):e==="tailnet-stopped"?s.jsxs("div",{className:"mesh-reach",children:[s.jsxs("div",{className:"mesh-reach-row",children:[s.jsx("span",{className:"mesh-reach-dot mesh-reach-dot--off"}),s.jsx("span",{className:"mesh-reach-label",children:"Tailscale stopped"})]}),s.jsx("button",{type:"button",className:"s-btn mesh-reach-action",disabled:a,onClick:o,children:a?"Opening…":"Start Tailscale"})]}):e==="loopback"?s.jsxs("div",{className:"mesh-reach",children:[s.jsxs("div",{className:"mesh-reach-row",children:[s.jsx("span",{className:"mesh-reach-dot mesh-reach-dot--off"}),s.jsx("span",{className:"mesh-reach-label",children:"Announcement broken"})]}),s.jsx("button",{type:"button",className:"s-btn mesh-reach-action",disabled:n,onClick:r,children:n?"Fixing…":"Fix announcement"})]}):e==="unavailable"?s.jsxs("div",{className:"mesh-reach mesh-reach--neutral",children:[s.jsx("span",{className:"mesh-reach-dot mesh-reach-dot--off"}),s.jsx("span",{className:"mesh-reach-label",children:"Local only — no tailnet on this host"})]}):s.jsxs("div",{className:"mesh-reach",children:[s.jsxs("div",{className:"mesh-reach-row",children:[s.jsx("span",{className:"mesh-reach-dot mesh-reach-dot--off"}),s.jsx("span",{className:"mesh-reach-label",children:"Local only"})]}),s.jsx("button",{type:"button",className:"s-btn s-btn-primary mesh-reach-action",disabled:n||!t,onClick:r,children:n?"Announcing…":"Make discoverable"})]})}const _me=new Map([["a",1],["an",1],["one",1],["two",2],["three",3],["four",4],["five",5],["six",6],["seven",7],["eight",8],["nine",9],["ten",10],["eleven",11],["twelve",12],["fifteen",15],["twenty",20],["thirty",30],["forty",40],["forty-five",45],["sixty",60]]),tm=String.raw`(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty|thirty|forty|forty-five|sixty)`,nm=String.raw`(seconds?|secs?|minutes?|mins?|hours?|hrs?)`,Ome=[new RegExp(String.raw`\b(?:please\s+)?(?:can\s+you\s+|could\s+you\s+)?(?:set\s+(?:a\s+)?reminder|remind\s+me|ping\s+me|nudge\s+me)(?:\s+for\s+(?:me|you|us))?\s+(?:in|after|for)\s+${tm}\s+${nm}\b(?:\s+(?:to|about|on|for)\s+(.+))?`,"i"),new RegExp(String.raw`\b(?:please\s+)?(?:check\s+back|follow\s+up)(?:\s+with\s+(?:me|us))?\s+(?:in|after)\s+${tm}\s+${nm}\b(?:\s+(?:to|about|on|for)\s+(.+))?`,"i"),new RegExp(String.raw`\b(?:please\s+)?(?:can\s+i\s+get|can\s+you\s+give\s+me|give\s+me|send\s+me|get\s+me)\s+(?:a\s+|an\s+)?(?:quick\s+|short\s+)?(?:status\s+)?update\s+(?:in|after)\s+${tm}\s+${nm}\b(?:\s+(?:to|about|on|for)\s+(.+))?`,"i"),new RegExp(String.raw`\bin\s+${tm}\s+${nm}\s+(?:remind\s+me|ping\s+me|nudge\s+me)(?:\s+(?:to|about|on|for)\s+(.+))?`,"i")];function $me(e,t=Date.now()){const n=e.replace(/\s+/g," ").trim();if(!n)return null;for(const a of Ome){const r=n.match(a);if(!r)continue;const o=Pme(r[1]??""),c=r[2]??"";if(o===null)continue;const u=Dme(o,c);if(u===null)continue;const h=Lme(r[3]??"",n);return{body:h,title:zme(h),delayMs:u,dueAt:t+u}}return null}function Pme(e){const t=e.trim().toLowerCase();if(!t)return null;const n=_me.get(t);if(n!==void 0)return n;const a=Number(t);return Number.isFinite(a)&&a>=0?a:null}function Dme(e,t){const n=t.trim().toLowerCase();return n.startsWith("sec")?Math.round(e*1e3):n.startsWith("min")?Math.round(e*6e4):n.startsWith("hr")||n.startsWith("hour")?Math.round(e*60*6e4):null}function Lme(e,t){const n=e.replace(/[.?!]+$/g,"").replace(/^(?:please\s+)?(?:that\s+)?/i,"").trim();return n||(/\bcheck\s+back\b/i.test(t)?"check back":/\bupdate\b/i.test(t)?"give me an update":"follow up")}function zme(e){const t=e.replace(/\s+/g," ").trim();return t.length<=42?t:`${t.slice(0,39).trim()}...`}const Bme="chill-dispatcher",Ume=100,Fme=6e4,Vme=2500,Hme={lowCutHz:160,highCutHz:5200,bandQ:.35,saturationAmount:.035,bitcrushAmount:0,hissGain:0,hissCutoffHz:1800,presencePeakDb:1.5,presenceCenterHz:1500,presenceQ:.65,compressorThresholdDb:-15,compressorRatio:2.2,clickEnabled:!0,clickGain:.24,clickDurationMs:45,squelchTailEnabled:!0,squelchTailGain:.018,squelchTailDurationMs:95,outputGain:1,wetMix:.38};function qme(e){const t=Math.min(1,e/8);return{saturationAmount:.035+t*.025,presencePeakDb:1.5+t*1.5}}function CM(e,t){return{...e==="chill-dispatcher"?Hme:{},...qme(t)}}function YD(e,t,n){return new Promise((a,r)=>{const o=window.setTimeout(()=>r(new Error(n)),t);e.then(a,r).finally(()=>window.clearTimeout(o))})}async function EM(e,t={}){!e.sessionId&&!t.allowCurrentSession||await YD(e.cancel(),Vme,"Timed out releasing Vox live session.").catch(()=>{})}function Wme(e){const t=e instanceof Error?e.message:String(e);return/session_cancelled|was cancelled|cancelled/i.test(t)}const Gme="What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend.",sm=[1,1.2,1.35],Zme=1.2,Kme=`
178
+
179
+ `,Yme=["Read as a calm local operations briefer.","Use the paragraph breaks as short breath moments so the operator can look at the screen.","Keep the tone warm, focused, and unhurried; do not sound like an advertisement."].join(" ");function Xme(e){let t="";const n=[];for(const a of e){const r=xp(a.narration);if(!r)continue;t&&(t+=Kme);const o=t.length;t+=r,n.push({id:a.cueId,textStart:o,textEnd:t.length})}return{text:t,cues:n}}function Qme(e,t){const n=e.speechTiming?.cues;if(!n?.length)return null;const a=new globalThis.Map(n.map(o=>[o.id,o])),r=[];for(let o=0;o<t.length;o+=1){const c=t[o],u=a.get(c.cueId);if(!u||!Number.isFinite(u.startMs))return null;r.push({cueId:c.cueId,segmentIndex:o,activateMs:Math.max(0,u.startMs-Ume)})}return r}function Jme({height:e}={}){const{applyScoutbotUiAction:t,route:n,onlineCount:a}=qe(),r=Mee(),[o,c]=a0("openscout.scoutbot.collapsed",!0),[u,h]=m.useState(""),[f,g]=m.useState(!1),[v,y]=m.useState(null),[x,w]=m.useState(null),[C,T]=m.useState(null),[E,S]=m.useState("idle"),[k,N]=a0("openscout.scoutbot.voiceReplies",!1),[A,R]=ij("openscout.scoutbot.voiceSpeed",Zme),[_,P]=KP("openscout.scoutbot.voicePresetId",Bme),[$,H]=m.useState(!1),[I,U]=m.useState(null),[D,V]=m.useState(null),[Z,O]=m.useState(!1),[z,B]=m.useState(null),[X,W]=m.useState(""),[L,q]=m.useState(!1),[K,ee]=m.useState(null),[G,re]=m.useState(null),[Q,ae]=m.useState(null),[be,$e]=m.useState(!1),[ge,Te]=m.useState(null),[pe,Xe]=m.useState(!1),[Be,Se]=m.useState(null),[Me,_e]=m.useState(!1),[Ne,Oe]=m.useState(!1),[Ce,Ve]=m.useState(null),[Re,Ie]=m.useState(null),[De,ct]=m.useState(""),[ut,st]=m.useState(""),[ht,yt]=m.useState(null),[Mt,Rt]=m.useState(null),[xt,Y]=m.useState(!1),[te,he]=m.useState(!1),[Pe,We]=m.useState(null),rt=m.useRef(null),at=m.useRef(null),Ot=m.useRef(null),jt=m.useRef(null),bt=m.useRef(null),Bt=m.useRef(null),Mn=m.useRef(!1),es=m.useRef(new Set),vs=m.useRef(k);vs.current=k;const cn=m.useCallback(()=>{bt.current?.abort(),bt.current=null,jt.current?.stop(),jt.current=null,q(!1)},[]),Rn=m.useCallback(ce=>{if(!ce)return;cn();const ke=fae(xp(ce),{speed:A,presetId:_,params:CM(_,a)});jt.current=ke,q(!0),ke.promise.catch(Ge=>{Yl(Ge)||y(Ge instanceof Error?Ge.message:"Vox speech failed.")}).finally(()=>{jt.current===ke&&(jt.current=null,q(!1))})},[cn,A,a,_]),ts=m.useCallback(ce=>{vs.current&&Rn(ce)},[Rn]),ys=m.useCallback(ce=>{Rn(Xu(ce))},[Rn]),{openFilePreview:la}=qe(),xs=Lc(),Yt=m.useCallback((ce,ke)=>{const Ge=window.getSelection()?.toString().trim(),Qe=Xu(ke),St=epe(Qe),Ct=[];if(Ge&&(Ct.push({kind:"action",label:"Copy selection",shortcut:"⌘C",onSelect:()=>{On(Ge)}}),Ct.push({kind:"separator"})),Ct.push({kind:"action",label:"Copy message",onSelect:()=>{On(Qe)}}),St.length>0){Ct.push({kind:"separator"});for(const sn of St.slice(0,5)){const ne=TM(sn);Ct.push({kind:"action",label:`Preview ${ne}`,onSelect:()=>la(sn)})}for(const sn of St.slice(0,5)){const ne=TM(sn);Ct.push({kind:"action",label:`Open ${ne} in OS`,onSelect:()=>{me("/api/file/reveal",{method:"POST",body:JSON.stringify({path:sn})}).catch(()=>{})}})}Ct.push({kind:"action",label:St.length===1?"Copy path":"Copy first path",onSelect:()=>{On(St[0])}})}Ct.push({kind:"separator"}),Ct.push({kind:"action",label:L?"Say again (stop current)":"Say",onSelect:()=>ys(ke)}),xs(ce,Ct)},[la,ys,xs,L]);m.useEffect(()=>()=>{Bt.current=null,cn()},[cn]);const Ht=m.useCallback(ce=>{const ke=[...ce.messages].reverse().find(Qe=>Qe.role==="user"),Ge=[...ce.messages].reverse().find(Qe=>Qe.role==="assistant");ee(ke?.body??null),re(Ge?Xu(Ge.body):null)},[]),Ln=m.useCallback(async()=>{try{const ce=await me("/api/scoutbot/session");Te(ce),Ht(ce.session)}catch{Te(null)}},[Ht]);m.useEffect(()=>{Ln()},[Ln]);const Rs=m.useCallback(async()=>{try{Rt(await me("/api/scoutbot/reminders"))}catch{Rt(null)}},[]);m.useEffect(()=>{Rs();const ce=window.setInterval(()=>{Rs()},15e3);return window.addEventListener("focus",Rs),()=>{window.clearInterval(ce),window.removeEventListener("focus",Rs)}},[Rs]);const de=m.useCallback(async ce=>{const ke=await me("/api/scoutbot/reminders",{method:"POST",body:JSON.stringify({...ce,source:"scoutbot"})});return Rt({generatedAt:ke.generatedAt,reminders:ke.reminders,due:ke.due,scheduled:ke.scheduled}),ke.reminder},[]),Ue=m.useCallback(async ce=>{const ke=await me(`/api/scoutbot/reminders/${encodeURIComponent(ce)}/dismiss`,{method:"POST"});Rt(ke)},[]),He=m.useCallback(async()=>{_e(!0),Ve(null);try{const ce=await me("/api/scoutbot/config");ct(ce.model),st(ce.systemPrompt),Ie(null)}catch(ce){Ve(ce instanceof Error?ce.message:"Could not load settings.")}finally{_e(!1)}},[]);m.useEffect(()=>{be&&He()},[He,be]),m.useEffect(()=>{if(!be)return;let ce=!1;return me("/api/voice/defaults").then(ke=>{ce||yt(ke)}).catch(()=>{ce||yt(null)}),()=>{ce=!0}},[be]);const Lt=m.useCallback(async()=>{Oe(!0),Ve(null),Ie(null);try{const ce=await me("/api/scoutbot/config",{method:"POST",body:JSON.stringify({model:De,systemPrompt:ut})});ct(ce.config.model),st(ce.config.systemPrompt),Ie("Saved")}catch(ce){Ve(ce instanceof Error?ce.message:"Could not save settings.")}finally{Oe(!1)}},[De,ut]),nn=m.useCallback(async ce=>{if(!(!ce||Pe)){We(ce),y(null),cn();try{const ke=await me("/api/scoutbot/session/switch",{method:"POST",body:JSON.stringify({id:ce})});Te(ke),Ht(ke.session),he(!1),Y(!1)}catch(ke){y(ke instanceof Error?ke.message:"Could not switch session.")}finally{We(null)}}},[cn,Pe,Ht]),ca=m.useCallback(async()=>{Xe(!0),y(null),ae("Starting fresh session"),cn();try{const ce=await me("/api/scoutbot/session/reset",{method:"POST"});Te(ce),ee(null),re(null),Y(!1),he(!1),ae("Fresh session ready")}catch(ce){ae(null),y(ce instanceof Error?ce.message:"Could not start a fresh session.")}finally{Xe(!1)}},[cn]),bs=m.useCallback(async ce=>{if(!(!ce||Be)){Se(ce),y(null),cn();try{const ke=await me("/api/scoutbot/session/archive",{method:"POST",body:JSON.stringify({id:ce})});Te(ke),Ht(ke.session),Y(!1),ae("session archived")}catch(ke){y(ke instanceof Error?ke.message:"Could not archive session.")}finally{Se(null)}}},[Be,cn,Ht]),Wt=m.useCallback(async()=>{const ce=rt.current??new Qu;rt.current=ce,S("probing");const ke=await ce.probe();return w(ke),T(ke?null:ce.lastUnavailableReason??"Vox Companion is not reachable."),S("idle"),ke},[]);m.useEffect(()=>{Wt();const ce=()=>{Wt()},ke=()=>{document.visibilityState==="visible"&&Wt()};return window.addEventListener("focus",ce),document.addEventListener("visibilitychange",ke),()=>{window.removeEventListener("focus",ce),document.removeEventListener("visibilitychange",ke)}},[Wt]);const Gn=m.useCallback(()=>{const ce=rt.current??new Qu;rt.current=ce,y(null),S("launching"),ce.launch({source:"openscout",context:MM()}),window.setTimeout(()=>{Wt()},2400)},[Wt]),ds=m.useCallback(()=>{const ce=rt.current??new Qu;rt.current=ce,ce.openSettings({source:"openscout",context:MM()})},[]),ws=m.useCallback(ce=>{const ke=Xu(ce);re(ke);for(const Ge of zJ(ce))Ge.type==="ask-agent"?(ae(`Asking ${Ge.targetLabel}`),me("/api/scoutbot/actions/ask",{method:"POST",body:JSON.stringify({targetLabel:Ge.targetLabel,targetAgentId:Ge.targetAgentId,body:Ge.body,channel:Ge.channel})}).then(Qe=>{ae(Qe.flightId?`Asked ${Qe.targetAgentId??Qe.targetLabel} · flight ${Qe.flightId}`:`Asked ${Qe.targetAgentId??Qe.targetLabel}`)}).catch(Qe=>{ae(null),y(Qe instanceof Error?Qe.message:"Could not ask agent.")})):Ge.type==="reminder"?de({title:Ge.title,body:Ge.body,dueAt:Ge.dueAt,delayMs:Ge.delayMs,delayMinutes:Ge.delayMinutes,context:{route:n,reason:Ge.reason}}).then(Qe=>{ae(`Reminder set for ${RM(Qe.dueAt)}`)}).catch(Qe=>{y(Qe instanceof Error?Qe.message:"Could not set reminder.")}):t(Ge);ts(ke)},[t,de,n,ts]);m.useEffect(()=>{const ce=Mt?.due??[];if(!Mn.current){for(const Qe of ce)es.current.add(Qe.id);Mn.current=!0;return}const ke=ce.find(Qe=>!es.current.has(Qe.id));if(!ke)return;for(const Qe of ce)es.current.add(Qe.id);const Ge=`Reminder due: ${ke.body}`;ae("Reminder due"),re(Ge),ts(Ge)},[Mt,ts]),m.useCallback(()=>{const ce=sm.reduce((ke,Ge,Qe)=>Math.abs(Ge-A)<Math.abs(sm[ke]-A)?Qe:ke,0);R(sm[(ce+1)%sm.length])},[R,A]);const Xn=m.useCallback((ce,ke,Ge)=>{if(!vs.current)return{promise:Promise.resolve(null),abort:()=>{}};bt.current?.abort();const Qe=new AbortController;bt.current=Qe;const St=()=>{Qe.abort(),bt.current===Qe&&(bt.current=null)};return{promise:Qw(ce,{speed:A,instructions:Yme,signal:Qe.signal,originAppId:"openscout.scoutbot",utteranceId:`scoutbot-brief:${Ge}`,...ke.length>0?{speechTiming:{enabled:!0,cues:ke}}:{}}).catch(sn=>(Yl(sn)||y(sn instanceof Error?sn.message:"Vox speech failed."),null)).finally(()=>{bt.current===Qe&&(bt.current=null)}),abort:St}},[A]),js=m.useCallback(async(ce,ke,Ge={})=>{const Qe=await ce;if(!Qe||Bt.current!==ke||!vs.current)return!1;const St=new AbortController,Ct=[],sn=CM(_,a),ne=Math.min(2,Math.max(.5,sn.playbackRate??1)),ve=()=>{for(const it of Ct)window.clearTimeout(it);Ct.length=0},Ee=()=>{if(Ge.cueSchedule?.length)for(const it of Ge.cueSchedule){const fn=Math.max(0,it.activateMs/ne);Ct.push(window.setTimeout(()=>{St.signal.aborted||Bt.current!==ke||Ge.onCue?.(it)},fn))}},Fe=dae(Qe,{signal:St.signal,presetId:_,params:sn,onPlaybackStart:Ee}),ze={promise:Fe,stop:()=>{ve(),St.abort()}};jt.current?.stop(),jt.current=ze,q(!0);try{await Fe}catch(it){if(!Yl(it))throw it}finally{ve(),jt.current===ze&&(jt.current=null,q(!1))}return!0},[a,_]),ua=m.useCallback(async(ce,ke)=>{const Ge=[...ce.steps.map(Fe=>({id:Fe.id,cueId:`step:${Fe.id}`,label:Fe.label,route:Fe.route,narration:Fe.narration,durationMs:Fe.durationMs})),{id:"recommendation",cueId:"recommendation",label:"Recommendation",route:null,narration:`Recommendation: ${ce.recommendation}`,durationMs:tpe(ce.recommendation)}],Qe=[],St=Xme(Ge);let Ct=null,sn=null;const ne=(Fe,ze)=>{if(V(Math.min(ze,ce.steps.length-1)),ae(`Brief ${Math.min(ze+1,ce.steps.length)}/${ce.steps.length}: ${Fe.label}`),Fe.route){const it=Lw({type:"navigate",route:Fe.route});it?.type==="navigate"&&t(it)}Qe.push(`${Fe.label}: ${Fe.narration}`)},ve=async()=>{for(let Fe=0;Fe<Ge.length;Fe+=1){if(Bt.current!==ke)return;if(Date.now()>ce.expiresAt){ae("Brief expired; refresh before acting");break}const ze=Ge[Fe];ne(ze,Fe),await rpe(Math.min(ze.durationMs,2400))}};if(vs.current&&(ae("Preparing brief audio"),Ct=Xn(St.text||xp(ce.summary),St.cues,ke),sn=await Ct.promise,Bt.current!==ke)){Ct.abort();return}const Ee=sn?Qme(sn,Ge):null;if(sn&&Ee){const Fe=new Set;try{!await js(Promise.resolve(sn),ke,{cueSchedule:Ee,onCue:it=>{if(!Fe.has(it.segmentIndex)){if(Date.now()>ce.expiresAt){ae("Brief expired; refresh before acting");return}Fe.add(it.segmentIndex),ne(Ge[it.segmentIndex],it.segmentIndex)}}})&&Bt.current===ke&&await ve()}catch(ze){Yl(ze)||y(ze instanceof Error?ze.message:"Vox speech failed.")}}else{const Fe=sn&&vs.current?js(Promise.resolve(sn),ke):null;if(await ve(),Fe)try{await Fe}catch(ze){Yl(ze)||y(ze instanceof Error?ze.message:"Vox speech failed.")}}Bt.current===ke&&(re([ce.summary,"",...Qe].join(`
180
+ `)),ae(Date.now()>ce.expiresAt?"Brief expired":"Brief complete"),H(!1),V(null),Bt.current=null)},[t,js,Xn]),dn=m.useCallback(async()=>{if($||f)return;const ce=`brief-${Date.now()}`;Bt.current=ce,H(!0),U(null),V(null),y(null),ee("One-minute brief"),re(null),ae("Preparing one-minute brief"),cn();try{await Bb().catch(()=>null);const ke=await me("/api/scoutbot/brief",{method:"POST",body:JSON.stringify({route:n,ttlMs:2*6e4})});if(Bt.current!==ce)return;U(ke),await ua(ke,ce)}catch(ke){Bt.current===ce&&(ae(null),y(ke instanceof Error?ke.message:"Could not prepare brief."),H(!1),V(null),Bt.current=null)}},[$,n,ua,f,cn]),Qn=m.useCallback(async ce=>{const ke=ce.trim();if(!(!ke||f)){g(!0),y(null),ee(ke),re(null),ae("Sending"),h(Ge=>Ge.trim()===ke?"":Ge);try{const Ge=$me(ke);if(Ge){ae("Setting reminder");const St=await de({title:Ge.title,body:Ge.body,delayMs:Ge.delayMs,context:{route:n,naturalLanguage:ke}}),Ct=`Reminder set for ${RM(St.dueAt)}: ${St.body}`;ae("Reminder set"),ws(Ct);return}await Bb().catch(()=>null);const Qe=await me("/api/scoutbot/chat",{method:"POST",body:JSON.stringify({body:ke,route:n})});Te({session:Qe.session,sessions:Qe.sessions,config:Qe.config}),ae("Reply received"),ws(Qe.reply.body)}catch(Ge){ae(null),y(Ge instanceof Error?Ge.message:"Could not send.")}finally{g(!1)}}},[de,ws,n,f]),Kr=m.useCallback(async()=>{if(Z)return;const ce=rt.current??new Qu;if(rt.current=ce,Ot.current=null,y(null),W(""),B("starting"),x!==!0&&!await Wt()){B(null);return}let ke=null,Ge=!1;const Qe=async()=>{!ke||Ge||(Ge=!0,await EM(ke,{allowCurrentSession:at.current===ke}),at.current===ke&&(at.current=null))};try{ke=await ce.startLive({onState:B,onPartial:W}),at.current=ke,O(!0);const St=await ke.result;if(await Qe(),O(!1),W(""),Ot.current)return;B("done"),St.text&&await Qn(St.text)}catch(St){const Ct=Ot.current,sn=!!Ct||Wme(St);if(await Qe(),O(!1),W(""),Ct==="stop-failed")return;B(sn?null:"error"),sn||y(St instanceof Error?St.message:"Vox recording failed.")}finally{await Qe(),Ot.current=null}},[Qn,Wt,Z,x]),da=m.useCallback(async()=>{const ce=at.current;if(ce){B("processing");try{await YD(ce.stop(),Fme,"Vox did not finish processing the recording.")}catch(ke){Ot.current="stop-failed",await EM(ce,{allowCurrentSession:!0}),at.current===ce&&(at.current=null,O(!1),W(""),B("error")),y(ke instanceof Error?`Vox recording did not finish: ${ke.message}`:"Vox recording did not finish.")}}},[]);m.useEffect(()=>{const ce=()=>c(!1);return window.addEventListener("scout:scoutbot-panel-open",ce),()=>window.removeEventListener("scout:scoutbot-panel-open",ce)},[c]),m.useEffect(()=>zte(()=>c(!o)),[o,c]);const Ma=L$(),Ra=z$(Ma);m.useEffect(()=>{const ce=ke=>{const Ge=ke.detail,Qe=Ge&&typeof Ge=="object"&&"body"in Ge?Ge.body:null;typeof Qe=="string"&&Qe.trim()&&(c(!1),Qn(Qe))};return window.addEventListener("scout:scoutbot-submit",ce),()=>window.removeEventListener("scout:scoutbot-submit",ce)},[Qn,c]),m.useEffect(()=>{const ce=()=>{c(!1),!$&&!f&&dn()};return window.addEventListener("scout:scoutbot-brief-now",ce),()=>window.removeEventListener("scout:scoutbot-brief-now",ce)},[$,f,c,dn]);const Yr=m.useMemo(()=>{const ce=L?"speaking":$?"briefing":f?"thinking":Z?"listening":"idle",ke=ge?.session??null,Ge=ke&&ke.messages.length>0?ke.messages[ke.messages.length-1]:null,Qe=(Mt?.due??[]).slice(0,5).map(Ct=>({id:Ct.id,body:Ct.body,status:Ct.status,dueAt:Ct.dueAt})),St=Mt?.scheduled[0];return{activity:ce,brief:{lastDeliveredAt:I&&!$?I.preparedAt:null},reminders:{dueCount:Mt?.due.length??0,upcomingCount:Mt?.scheduled.length??0,due:Qe,next:St?{id:St.id,body:St.body,status:St.status,dueAt:St.dueAt}:null},voice:{available:x,setupBlocked:x===!1,replies:k},error:v,session:{title:ke?.title??null,lastActivityAt:Ge?.createdAt??ke?.updatedAt??null}}},[L,$,f,Z,I,Mt,x,k,v,ge]);m.useEffect(()=>{r?.publishState(Yr)},[r,Yr]),m.useEffect(()=>{if(!r)return;const ce={focusScoutbot:()=>c(!1),triggerBrief:()=>{c(!1),!$&&!f&&dn()},triggerAskState:()=>{c(!1),Qn(Gme)},toggleVoiceReplies:()=>{const ke=!k;N(ke),ke||cn()},openScoutbotSettings:()=>{c(!1),$e(!0)},startNewChat:()=>{c(!1),pe||ca()},dismissReminder:ke=>{Ue(ke)},askReminderStatus:({body:ke})=>{c(!1),Qn(`Reminder due: ${ke}. Check the current Scout control-plane state and give me the shortest useful status update.`)}};r.registerActions(ce)},[r,c,$,f,dn,Qn,k,N,cn,$e,pe,ca,Ue]);const Xa=Mt?.due.length??0;m.useEffect(()=>{Xa>0?Am({key:"reminder.due",tier:"warn",text:`${Xa} reminder${Xa===1?"":"s"} due`}):Tm("reminder.due")},[Xa]),m.useEffect(()=>{x===!1?Am({key:"voice.offline",tier:"warn",text:"Voice setup needed"}):x===!0&&Tm("voice.offline")},[x]),m.useEffect(()=>{v?Am({key:"scoutbot.error",tier:"error",text:v}):Tm("scoutbot.error")},[v]);const Uc=Z?z==="processing"?"Sending":"Stop":E==="probing"?"Checking Vox":E==="launching"?"Opening Vox":x===!1?"Launch Vox":"Start Talking",Ia=ge?.session??null;if(Ia?.id,Ia?.createdAt&&new Date(Ia.createdAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),Ia?.model??ge?.config.model,o)return s.jsx("div",{className:"flex shrink-0 items-center border-t border-[var(--scout-chrome-border-soft)] px-3 py-1.5",children:s.jsx(U$,{})});const Nr=e===void 0?"flex max-h-[60vh] shrink-0 flex-col overflow-hidden border-t border-[var(--scout-chrome-border-soft)]":"flex shrink-0 flex-col overflow-hidden border-t border-[var(--scout-chrome-border-soft)]",Fs=e===void 0?void 0:{height:`${e}px`};return s.jsxs("section",{className:Nr,style:Fs,children:[s.jsxs("div",{className:"flex shrink-0 flex-col gap-2 px-3 pt-2.5 pb-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex min-w-0 items-center gap-2",children:s.jsx(zd,{size:20,className:"shrink-0 text-lime-300","aria-hidden":"true"})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[s.jsx(_M,{icon:k?s.jsx(g2,{size:11}):s.jsx(v2,{size:11}),title:k?"Voice replies on (click to mute)":"Voice replies off (click to enable)",onClick:()=>{const ce=!k;N(ce),ce||cn()},active:k}),s.jsx(_M,{icon:s.jsx(Vo,{size:11}),title:"Minimize",onClick:()=>c(!0)})]})]}),Ra&&s.jsx("div",{className:`rounded border px-2.5 py-1.5 font-mono text-[10px] leading-relaxed ${Ra.tier==="error"?"border-rose-300/30 bg-rose-300/[0.07] text-rose-50":Ra.tier==="warn"?"border-amber-300/30 bg-amber-300/[0.07] text-amber-50":"border-lime-300/20 bg-lime-300/[0.05] text-[var(--scout-chrome-ink)]"}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pp,{size:11,className:`shrink-0 ${Ra.tier==="error"?"text-rose-200":Ra.tier==="warn"?"text-amber-200":"text-lime-200"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--scout-chrome-ink)]",children:Ra.text}),s.jsx("button",{type:"button",title:"Ask about this","aria-label":"Ask about this",onClick:()=>{Qn(`Tell me about this broadcast: ${Ra.text}`)},disabled:f||$,className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] p-1 text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)] disabled:opacity-40",children:s.jsx(Uz,{size:11})}),s.jsx("button",{type:"button",title:"Dismiss","aria-label":"Dismiss broadcast",onClick:()=>Pte(),className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] p-1 text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]",children:s.jsx(gc,{size:11})})]})}),be&&s.jsx("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 p-3",children:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["Voice FX",s.jsx("select",{value:_,onChange:ce=>P(ce.target.value),className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] normal-case tracking-normal text-[var(--scout-chrome-ink)]",children:$d.map(ce=>s.jsxs("option",{value:ce.id,children:[ce.label," — ",ce.family]},ce.id))}),s.jsx("span",{className:"font-mono text-[9px] normal-case leading-relaxed tracking-normal text-[var(--scout-chrome-ink-ghost)]",children:$d.find(ce=>ce.id===_)?.description??"Custom voice mood for spoken replies."})]}),s.jsxs("div",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["Vox Voice",s.jsx("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] normal-case tracking-normal text-[var(--scout-chrome-ink)]",children:ht?`${ht.modelId}${ht.voiceId?` / ${ht.voiceId}`:""}`:"Unavailable"})]}),s.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["Model",s.jsx("input",{value:De,onChange:ce=>ct(ce.target.value),placeholder:"gpt-4.1-mini",className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] normal-case tracking-normal text-[var(--scout-chrome-ink)] placeholder:text-[var(--scout-chrome-ink-ghost)]",disabled:Me||Ne})]}),s.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["System Prompt",s.jsx("textarea",{value:ut,onChange:ce=>st(ce.target.value),rows:6,className:"w-full resize-y rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[10px] normal-case leading-relaxed tracking-normal text-[var(--scout-chrome-ink)]",disabled:Me||Ne})]}),Ce&&s.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-red-300",children:Ce}),Re&&s.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-lime-200",children:Re}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Lt()},disabled:Me||Ne||!ut.trim(),className:"flex items-center justify-center gap-2 rounded bg-lime-300/90 px-2.5 py-2 font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-black transition-opacity disabled:cursor-not-allowed disabled:opacity-40",children:[(Me||Ne)&&s.jsx(ea,{size:13,className:"animate-spin"}),Ne?"Saving":"Save"]}),s.jsx("button",{type:"button",onClick:()=>{He()},disabled:Me||Ne,className:"rounded border border-[var(--scout-chrome-border-soft)] px-2.5 py-2 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] disabled:cursor-not-allowed disabled:opacity-40",children:"Reload"})]})]})})]}),s.jsx("div",{className:"flex min-h-0 flex-1 flex-col px-3 pb-1.5",children:ge&&s.jsx(ipe,{state:ge,chatExpanded:xt,onToggleExpanded:()=>Y(ce=>!ce),sessionPickerOpen:te,onToggleSessionPicker:()=>he(ce=>!ce),onSwitchSession:ce=>{nn(ce)},switchingSessionId:Pe,sending:f,briefing:$,pendingAsk:f?K:null,onArchiveSession:ce=>{bs(ce)},archivingSessionId:Be,onAssistantContextMenu:Yt})}),s.jsxs("div",{className:"flex shrink-0 flex-col gap-1.5 border-t border-[var(--scout-chrome-border-soft)] bg-black/10 px-3 pt-2 pb-2.5",children:[x===!1&&s.jsx(lpe,{issue:C,probeState:E,onLaunch:Gn,onRetry:()=>{Wt()},onSettings:ds}),(X||L)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 px-2.5 py-2 font-mono text-[10px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:[s.jsx("span",{className:"min-w-0 truncate",children:L?"Speaking reply…":X}),L&&s.jsx("button",{type:"button",title:"Stop spoken reply",onClick:cn,className:"shrink-0 rounded border border-[var(--scout-chrome-border-soft)] p-1 text-[var(--scout-chrome-ink)] hover:bg-[var(--scout-chrome-hover)]",children:s.jsx(Bd,{size:11,className:"fill-current"})})]}),Q&&!f&&s.jsx("div",{className:"font-mono text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:Q}),s.jsx(ope,{draft:u,onDraftChange:h,onSubmit:()=>{Qn(u)},sending:f,recording:Z,voiceLabel:Uc,voiceBusy:z==="processing"||E==="probing"||E==="launching",voiceUnavailable:x===!1,onMicClick:()=>{if(x===!1){Gn();return}Z?da():Kr()}}),v&&s.jsx("div",{className:"rounded border border-red-400/30 bg-red-400/10 px-2.5 py-2 font-mono text-[10px] leading-relaxed text-red-200",children:v})]})]})}const AM=new RegExp("(?:^|(?<=[\\s(`'\"<>]))(?:~\\/|\\/(?:Users|home|opt|var|etc|tmp|private)\\/)[^\\s)`'\"<>]+\\.[A-Za-z0-9]{1,8}\\b","g");function epe(e){const t=[],n=new Set;AM.lastIndex=0;let a;for(;(a=AM.exec(e))!==null;)n.has(a[0])||(n.add(a[0]),t.push(a[0]));return t}function TM(e){const t=e.split("/").filter(Boolean);return t.length<=2?e:`…/${t.slice(-2).join("/")}`}function MM(){return{requesterName:"OpenScout",productName:"Scout Audio",headline:"Turn on local voice",body:"Scout Audio uses Vox for local speech capture and spoken replies. Start Vox, then return here to talk with your workspace.",actionLabel:"Return to OpenScout",logo:{url:new URL("/openscout-icon.png",window.location.href).toString(),symbolName:"sparkles"}}}function tpe(e){const t=e.split(/\s+/).filter(Boolean).length;return Math.min(12e3,Math.max(3500,t*360))}function RM(e){return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}const npe=5*6e4;function spe(e,t){return!e||!N0(e.createdAt,t.createdAt)?!0:Math.abs(t.createdAt-e.createdAt)>=npe}function N0(e,t){const n=new Date(e),a=new Date(t);return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}function ape(e){const t=new Date(e),n=new Date,a=new Date(n);a.setDate(n.getDate()-1);const r=t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return N0(e,n.getTime())?`Today ${r}`:N0(e,a.getTime())?`Yesterday ${r}`:t.getFullYear()===n.getFullYear()?`${t.toLocaleDateString([],{month:"short",day:"numeric"})} ${r}`:`${t.toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"})} ${r}`}function rpe(e){return new Promise(t=>window.setTimeout(t,e))}function ipe({state:e,chatExpanded:t,onToggleExpanded:n,sessionPickerOpen:a,onToggleSessionPicker:r,onSwitchSession:o,switchingSessionId:c,sending:u,briefing:h,pendingAsk:f,onArchiveSession:g,archivingSessionId:v,onAssistantContextMenu:y}){const w=e.session.messages,C=t?w:w.slice(-4),T=t?0:Math.max(0,w.length-C.length),E=w.length,S=e.sessions.length,k=e.retention,N=e.session.createdAt?new Date(e.session.createdAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):null,A=e.session.title&&e.session.title!=="New Scout Session"?e.session.title:`Session ${e.session.id.slice(0,8)}`,R=m.useRef(null),_=w[w.length-1]?.id??null,P=w[w.length-1]?.body??"";return m.useEffect(()=>{const $=R.current;$&&($.scrollTop=$.scrollHeight)},[_,P,f,u,t,e.session.id]),s.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col overflow-hidden rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 font-mono text-[10px] text-[var(--scout-chrome-ink-faint)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-[var(--scout-chrome-border-soft)] px-2.5 py-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 truncate text-[var(--scout-chrome-ink)]",title:e.session.id,children:A}),N&&s.jsxs("span",{className:"shrink-0 text-[var(--scout-chrome-ink-ghost)]",children:["· ",N]}),s.jsxs("span",{className:"shrink-0 text-[var(--scout-chrome-ink-ghost)]",children:["· ",E," msg",E===1?"":"s"]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsxs("button",{type:"button",title:`Switch session (${S} total)`,"aria-label":"Switch session",onClick:r,className:`flex items-center gap-1 rounded border px-1.5 py-0.5 text-[9px] uppercase tracking-[0.1em] transition-colors ${a?"border-lime-300/40 bg-lime-300/10 text-lime-100":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"}`,children:[s.jsx(oz,{size:10}),s.jsx("span",{children:"Sessions"}),s.jsx("span",{className:"text-[var(--scout-chrome-ink-ghost)]",children:S}),s.jsx(Vo,{size:9,className:a?"rotate-180 transition-transform":"transition-transform"})]}),E>4&&s.jsxs("button",{type:"button",title:t?"Collapse chat":"View full session","aria-label":t?"Collapse chat":"View full session",onClick:n,className:"flex items-center gap-1 rounded border border-[var(--scout-chrome-border-soft)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.1em] text-[var(--scout-chrome-ink-faint)] transition-colors hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]",children:[s.jsx("span",{children:t?"Collapse":"Full"}),t?s.jsx(T0,{size:9}):s.jsx(Vo,{size:9})]})]})]}),a&&s.jsxs("div",{className:"shrink-0 border-b border-[var(--scout-chrome-border-soft)] px-2 py-1.5",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:[s.jsx("span",{children:"Recent sessions"}),k&&k.archivedCount>0&&s.jsxs("span",{children:[k.archivedCount," archived"]})]}),s.jsx("div",{className:"flex max-h-40 flex-col gap-0.5 overflow-y-auto pr-0.5",children:e.sessions.map($=>{const H=$.id===e.session.id,I=c===$.id,U=v===$.id,D=new Date($.updatedAt).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),V=$.title&&$.title!=="New Scout Session"?$.title:`Session ${$.id.slice(0,8)}`;return s.jsxs("div",{className:`flex items-center gap-2 rounded border px-2 py-1 text-left transition-colors ${H?"border-lime-300/40 bg-lime-300/[0.06] text-lime-100":"border-transparent text-[var(--scout-chrome-ink-faint)] hover:border-[var(--scout-chrome-border-soft)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"}`,children:[s.jsxs("button",{type:"button",onClick:()=>{H||o($.id)},disabled:H||!!c||!!v,className:"flex min-w-0 flex-1 items-center gap-2 text-left disabled:cursor-not-allowed disabled:opacity-40",children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${H?"bg-lime-300":"bg-[var(--scout-chrome-ink-ghost)]"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] text-[var(--scout-chrome-ink)]",children:V}),s.jsxs("span",{className:"shrink-0 text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:[$.messageCount," msg"]}),s.jsx("span",{className:"shrink-0 text-[9px] text-[var(--scout-chrome-ink-ghost)]",children:D}),I&&s.jsx(ea,{size:10,className:"shrink-0 animate-spin text-lime-200"})]}),s.jsx("button",{type:"button",title:"Archive chat","aria-label":`Archive chat ${V}`,onClick:()=>g($.id),disabled:!!c||!!v,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded border border-transparent text-[var(--scout-chrome-ink-ghost)] transition-colors hover:border-[var(--scout-chrome-border-soft)] hover:bg-black/20 hover:text-[var(--scout-chrome-ink)] disabled:cursor-not-allowed disabled:opacity-30",children:U?s.jsx(ea,{size:10,className:"animate-spin"}):s.jsx(a2,{size:10})})]},$.id)})})]}),s.jsxs("div",{ref:R,className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-2.5 py-2",children:[T>0&&s.jsxs("button",{type:"button",onClick:n,className:"self-start text-[9px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)] hover:text-[var(--scout-chrome-ink)]",children:["↑ ",T," earlier message",T===1?"":"s"]}),C.length===0&&!f&&s.jsx("p",{className:"text-[var(--scout-chrome-ink-ghost)]",children:"No messages yet — ask anything below."}),C.map(($,H)=>{const I=spe(C[H-1],$),U=ape($.createdAt);return s.jsxs("div",{className:"flex flex-col gap-1",children:[I&&s.jsx("div",{className:"self-center rounded-full bg-white/[0.06] px-2.5 py-0.5 font-mono text-[9px] font-medium text-[var(--scout-chrome-ink-ghost)]",title:new Date($.createdAt).toLocaleString(),"aria-label":U,children:U}),s.jsx(IM,{role:$.role,body:$.body,onContextMenu:$.role==="assistant"&&y?D=>y(D,$.body):void 0})]},$.id)}),f&&s.jsx(IM,{role:"user",body:f,pending:!0}),u&&!f&&s.jsx("p",{className:"text-[var(--scout-chrome-ink-ghost)]",children:"Reading the control plane…"}),h&&s.jsxs("div",{className:"flex items-center gap-2 rounded border border-lime-300/30 bg-lime-300/[0.06] px-2.5 py-2 font-mono text-[10px] leading-relaxed text-lime-100",children:[s.jsx(ea,{size:12,className:"shrink-0 animate-spin text-lime-300","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex flex-col gap-0.5",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-[0.14em] text-lime-300",children:"Briefing"}),s.jsx("span",{className:"text-[var(--scout-chrome-ink)]",children:"Codex is reviewing the control-plane snapshot. Voice will pick up when it lands."})]})]})]})]})}function ope({draft:e,onDraftChange:t,onSubmit:n,sending:a,recording:r,voiceLabel:o,voiceBusy:c,voiceUnavailable:u,onMicClick:h}){let f="Start talking";u&&(f="Launch Vox"),r&&(f="Stop talking"),c&&(f=o);const g=u||c||r;return s.jsxs("form",{className:"grid grid-cols-[auto_1fr_auto] gap-2",onSubmit:v=>{v.preventDefault(),n()},children:[s.jsxs("button",{type:"button",title:f,"aria-label":f,onClick:h,disabled:a||c,className:`flex items-center justify-center self-stretch rounded border transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${r?"border-lime-300/50 bg-lime-300/10 text-lime-200":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"} ${g?"min-w-[7.5rem] gap-1.5 px-2.5 font-mono text-[10px] uppercase tracking-[0.12em]":"w-9"}`,children:[c?s.jsx(ea,{size:13,className:"animate-spin"}):r?s.jsx(Bd,{size:12,className:"fill-current"}):s.jsx(M0,{size:13}),g&&s.jsx("span",{className:"truncate",children:o})]}),s.jsx("textarea",{value:e,onChange:v=>t(v.target.value),placeholder:"Ask to inspect state or move the UI…",rows:2,className:"w-full resize-none rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] leading-relaxed text-[var(--scout-chrome-ink)] placeholder:text-[var(--scout-chrome-ink-ghost)]",onKeyDown:v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),e.trim()&&!a&&n())}}),s.jsx("button",{type:"submit",title:"Send","aria-label":"Send",disabled:!e.trim()||a,className:"flex w-9 items-center justify-center self-stretch rounded bg-lime-300/90 px-0 text-black transition-opacity disabled:cursor-not-allowed disabled:opacity-40",children:a?s.jsx(ea,{size:13,className:"animate-spin"}):s.jsx(Zz,{size:13})})]})}function IM({role:e,body:t,pending:n=!1,onContextMenu:a}){const r=e==="user",o=r?t:Xu(t),[c,u]=m.useState(!1),h=m.useCallback(()=>{On(o).then(()=>{u(!0),window.setTimeout(()=>u(!1),1200)}).catch(()=>{})},[o]);return s.jsxs("div",{className:"group flex flex-col gap-0.5",onContextMenu:a,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:`text-[9px] uppercase tracking-[0.12em] ${r?"text-[var(--scout-chrome-ink-ghost)]":"text-lime-300"}`,children:[r?"You":"Reply",n&&" · sending"]}),s.jsx("button",{type:"button",title:c?"Copied":"Copy message","aria-label":c?"Copied message":"Copy message",disabled:n||!o.trim(),onClick:h,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded border border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-ghost)] opacity-70 transition hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)] disabled:cursor-not-allowed disabled:opacity-20 group-hover:opacity-100",children:c?s.jsx(o2,{size:11}):s.jsx(c2,{size:11})})]}),r?s.jsx("p",{className:`whitespace-pre-wrap break-words text-[11px] leading-relaxed text-[var(--scout-chrome-ink)] ${n?"opacity-60":""}`,children:o}):s.jsx("div",{className:n?"opacity-60":"",children:s.jsx(zP,{text:o})})]})}function _M({icon:e,title:t,onClick:n,disabled:a,active:r,badge:o}){return s.jsxs("button",{type:"button",title:t,"aria-label":t,onClick:n,disabled:a,className:`flex shrink-0 items-center gap-1 rounded border p-1 text-[10px] transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${r?"border-lime-300/50 bg-lime-300/10 text-lime-200":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"}`,children:[e,o&&s.jsx("span",{className:"font-mono text-[8.5px] tracking-tight",children:o})]})}function lpe({issue:e,probeState:t,onLaunch:n,onRetry:a,onSettings:r}){const o=t==="probing"||t==="launching";return s.jsxs("div",{className:"rounded border border-lime-300/25 bg-lime-300/[0.06] px-3 py-3 font-mono text-[10px] text-[var(--scout-chrome-ink)]",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(gS,{size:14,className:"mt-0.5 shrink-0 text-lime-300"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"uppercase tracking-[0.14em] text-lime-200",children:"Connect Vox"}),s.jsx("p",{className:"mt-1 leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:"Start Vox, then retry once the menu bar icon is visible."}),e&&s.jsx("p",{className:"mt-2 break-words leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:e})]})]}),s.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[s.jsx(Px,{icon:t==="launching"?s.jsx(ea,{size:12,className:"animate-spin"}):s.jsx(gS,{size:12}),label:t==="launching"?"Opening":"Launch Vox",onClick:n,disabled:t==="probing",title:"Launch Vox"}),s.jsx(Px,{icon:t==="probing"?s.jsx(ea,{size:12,className:"animate-spin"}):s.jsx(m2,{size:12}),label:"Retry",onClick:a,disabled:o,title:"Check Vox again"}),s.jsx(Px,{icon:s.jsx($p,{size:12}),label:"Settings",onClick:r,disabled:t==="probing",title:"Open Vox settings"})]})]})}function Px({icon:e,label:t,onClick:n,disabled:a,title:r}){return s.jsxs("button",{type:"button",title:r,onClick:n,disabled:a,className:"flex min-h-8 items-center justify-center gap-1.5 rounded border border-lime-300/20 px-2 text-[9px] uppercase tracking-[0.12em] text-lime-100 transition-colors hover:bg-lime-300/10 disabled:cursor-not-allowed disabled:opacity-45",children:[e,t]})}function cpe({onResizeStart:e}){const t=m.useCallback(n=>{n.preventDefault(),e(n)},[e]);return s.jsxs("div",{role:"separator","aria-orientation":"horizontal",onMouseDown:t,className:"group relative flex h-[7px] shrink-0 cursor-ns-resize items-center justify-center",children:[s.jsx("div",{className:"absolute inset-x-0 top-0 h-px bg-[var(--scout-chrome-border-soft)] transition-colors group-hover:bg-[var(--scout-chrome-ink-faint)]"}),s.jsxs("div",{className:"flex flex-row gap-[3px] opacity-0 transition-opacity group-hover:opacity-100",children:[s.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"}),s.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"}),s.jsx("div",{className:"h-[3px] w-[3px] rounded-full bg-[var(--scout-chrome-ink-faint)]"})]})]})}const OM=180,upe=.7,dpe=260;function Dx(e,t){const n=Math.max(OM,Math.floor(t*upe));return Math.min(n,Math.max(OM,Math.round(e)))}function fpe(){const{route:e,navigate:t,agents:n,selectedBrokerAttempt:a,clearBrokerAttempt:r}=qe(),[o]=a0("openscout.scoutbot.collapsed",!0),[c,u]=ij("openscout.scoutbot.height",dpe),h=m.useRef(null),[f,g]=m.useState(0);m.useLayoutEffect(()=>{const w=h.current;if(!w)return;g(w.getBoundingClientRect().height);const C=new ResizeObserver(T=>{const E=T[0];E&&g(E.contentRect.height)});return C.observe(w),()=>C.disconnect()},[]),m.useEffect(()=>{if(f<=0)return;const w=Dx(c,f);w!==c&&u(w)},[f,c,u]);const v=m.useCallback(w=>{const C=w.clientY,T=c,E=h.current?.getBoundingClientRect().height??f,S=N=>{const A=N.clientY-C;u(Dx(T-A,E))},k=()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",k),document.body.style.removeProperty("cursor"),document.body.style.removeProperty("user-select")};document.body.style.cursor="ns-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",S),document.addEventListener("mouseup",k)},[f,c,u]);let y=null;switch(e.view){case"inbox":case"fleet":y=s.jsx(mme,{});break;case"agents":case"agent-info":y=s.jsx(tme,{});break;case"sessions":y=s.jsx(pme,{});break;case"conversation":y=s.jsx(hme,{});break;case"terminal":y=s.jsx(gme,{});break;case"channels":y=s.jsx(Spe,{channelId:e.channelId,agents:n,navigate:t,returnRoute:e});break;case"work":y=s.jsx(xme,{});break;case"mesh":y=s.jsx(Rme,{});break;case"ops":y=s.jsx(Epe,{mode:e.mode??"mission",agents:n,navigate:t,returnRoute:e});break;case"broker":y=a?s.jsx(Yie,{attempt:a,navigate:t,onClose:r}):s.jsx(hpe,{});break;default:y=null}const x=f>0?Dx(c,f):c;return s.jsxs("div",{ref:h,className:"flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:y}),!o&&s.jsx(cpe,{onResizeStart:v}),s.jsx(Jme,{height:o?void 0:x})]})}function hpe(){return s.jsxs("div",{className:"sys-broker-right-empty",children:[s.jsx("div",{className:"sys-kicker",children:"Broker"}),s.jsx("p",{children:"Select any broker ledger row to inspect route metadata here."})]})}const mpe=new Set(["completed","failed","cancelled"]);function ppe(e){return e.startsWith("channel.")?`#${e.slice(8)}`:e.startsWith("dm.")?"Direct message":e}function gpe(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?e[t]:void 0}function Mp(e,t){const n=gpe(e,t);return typeof n=="string"&&n.trim()?n.trim():null}function XD(e,t,n){return t?.trim()?t.trim():(e?n.find(r=>r.id===e):null)?.name??e??"Unassigned"}function vpe(e){return Mp(e.input,"task")??Mp(e.input,"action")}function ype(e){return Mp(e.output,"summary")??Mp(e.output,"text")}function k0(e){return!mpe.has(e.state)}function xpe(e){return e.updatedAt??e.completedAt??e.startedAt??e.createdAt??Date.now()}function bpe(e){return e.replace(/_/g," ")}function wpe(e){if(e.workId)return{view:"work",workId:e.workId};const t=e.flightIds?.[0]??null;return t?{view:"follow",flightId:t,preferredView:"chat"}:e.invocationId?{view:"follow",invocationId:e.invocationId,preferredView:"chat"}:null}function jpe(e,t){const n=e.nextMoveOwnerId??e.ownerId,a=XD(n,e.nextMoveOwnerName??e.ownerName,t),r=e.activeFlightCount>0?`${e.activeFlightCount} active flight${e.activeFlightCount===1?"":"s"}`:null;return{id:`work:${e.id}`,kind:"work",actorId:n,actorName:a,status:r??e.currentPhase,title:e.title,detail:e.lastMeaningfulSummary??e.summary,updatedAt:e.lastMeaningfulAt||e.updatedAt,active:!0,route:{view:"work",workId:e.id}}}function Npe(e,t){const n=k0(e),a=ype(e);return{id:`run:${e.id}`,kind:"run",actorId:e.agentId,actorName:XD(e.agentId,e.agentName,t),status:bpe(e.state),title:vpe(e)??a??"Agent run",detail:n?a:null,updatedAt:xpe(e),active:n,route:wpe(e)}}function kpe(e,t,n){const a=new Set(e.map(h=>h.id)),r=e.map(h=>jpe(h,n)),o=t.filter(h=>k0(h)),c=t.filter(h=>!k0(h)).slice(0,6),u=[...o,...c].filter(h=>!h.workId||!a.has(h.workId)).map(h=>Npe(h,n));return[...r,...u].sort((h,f)=>h.active!==f.active?h.active?-1:1:f.updatedAt-h.updatedAt).slice(0,12)}function Spe({channelId:e,agents:t,navigate:n,returnRoute:a}){const[r,o]=m.useState([]),[c,u]=m.useState([]),[h,f]=m.useState(!1),g=m.useCallback(async()=>{if(!e){f(!0),o([]),u([]);return}try{const[w,C]=await Promise.all([me(`/api/work?conversationId=${encodeURIComponent(e)}&active=true&limit=12`),me(`/api/runs?conversationId=${encodeURIComponent(e)}&active=false&limit=24`)]);o(w),u(C),f(!0)}catch{f(!0)}},[e]);m.useEffect(()=>{f(!1),g()},[g]),tn(w=>{if(e){if(w.kind==="message.posted"){w.payload?.message?.conversationId===e&&g();return}(w.kind==="invocation.requested"||w.kind==="flight.updated"||w.kind==="collaboration.event.appended")&&g()}});const v=m.useMemo(()=>kpe(r,c,t),[r,c,t]),y=v.filter(w=>w.active),x=v.filter(w=>!w.active);return e?s.jsxs("div",{className:"ctx-panel ctx-panel--channel",children:[s.jsxs("section",{className:"ctx-panel-section ctx-panel-channel-summary",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Channel"}),s.jsxs("div",{className:"ctx-panel-channel-card",children:[s.jsx("span",{className:"ctx-panel-hash",children:"#"}),s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:ppe(e)}),s.jsx("span",{className:"ctx-panel-preview",children:h?`${v.length} related item${v.length===1?"":"s"}`:"Loading context"})]})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Doing",s.jsx("span",{className:"ctx-panel-count",children:y.length})]}),y.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No active channel work"}):s.jsx("div",{className:"ctx-panel-list",children:y.map(w=>s.jsx($M,{item:w,navigate:n,returnRoute:a},w.id))})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Recent",s.jsx("span",{className:"ctx-panel-count",children:x.length})]}),x.length===0?s.jsx("div",{className:"ctx-panel-empty",children:h?"No recent channel runs":"Loading context"}):s.jsx("div",{className:"ctx-panel-list ctx-panel-list--scroll",children:x.map(w=>s.jsx($M,{item:w,navigate:n,returnRoute:a},w.id))})]})]}):s.jsx("div",{className:"ctx-panel ctx-panel--empty",children:s.jsx("div",{className:"ctx-panel-empty-state",children:s.jsx("div",{className:"ctx-panel-empty-hint",children:"Select a channel to see related work."})})})}function $M({item:e,navigate:t,returnRoute:n}){const a=s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ctx-panel-avatar",style:{background:qt(e.actorName)},children:e.actorName[0]?.toUpperCase()??"?"}),s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:e.actorName}),s.jsxs("span",{className:"ctx-panel-sub",children:[e.kind," · ",e.status]}),s.jsx("span",{className:"ctx-panel-preview",children:e.title}),e.detail&&s.jsx("span",{className:"ctx-panel-preview",children:e.detail})]}),s.jsxs("div",{className:"ctx-panel-trailing",children:[s.jsx("span",{className:"ctx-panel-time",children:Ae(e.updatedAt)}),e.active&&s.jsx("span",{className:"ctx-panel-dot"})]})]});return e.route?s.jsx("button",{type:"button",className:["ctx-panel-item","ctx-panel-channel-item",e.active&&"ctx-panel-item--active"].filter(Boolean).join(" "),onClick:()=>kt(t,e.route,{returnTo:n}),children:a}):s.jsx("div",{className:"ctx-panel-item ctx-panel-channel-item",children:a})}const Cpe={mission:"Control",plan:"Work",issues:"Alerts",tail:"Tail",atop:"Atop",agents:"Agents"};function Epe({mode:e,agents:t,navigate:n,returnRoute:a}){const[r,o]=m.useState(null),[c,u]=m.useState(()=>typeof window>"u"?null:PM(window.scoutOpsDetailSnapshot)),h=m.useCallback(async()=>{const w=await me("/api/fleet").catch(()=>null);o(w)},[]);m.useEffect(()=>{h()},[h]),m.useEffect(()=>{const w=C=>{u(PM(C.detail))};return window.addEventListener("scout:ops-detail",w),()=>window.removeEventListener("scout:ops-detail",w)},[]),tn(w=>{(w.kind==="message.posted"||w.kind==="flight.updated"||w.kind==="collaboration.event.appended")&&h()});const f=(r?.activeAsks??[]).filter(w=>w.status!=="needs_attention"),g=r?.needsAttention??[],v=t.filter(w=>Je(w.state)==="working"),y=t.filter(w=>Je(w.state)!=="offline"),x=[...t].sort((w,C)=>(C.updatedAt??0)-(w.updatedAt??0)).slice(0,7);return s.jsxs("div",{className:"ctx-panel ctx-panel--ops-inspector",children:[c&&s.jsxs("section",{className:"ctx-panel-section ctx-panel-selected-detail",children:[s.jsx("div",{className:"ctx-panel-section-label",children:c.focus==="flow"?"Message":"Selection"}),s.jsxs("div",{className:"ctx-panel-selected-card",children:[s.jsx("div",{className:"ctx-panel-selected-title",children:c.title}),s.jsx("div",{className:"ctx-panel-selected-meta",children:c.meta}),s.jsx("div",{className:"ctx-panel-selected-body",children:c.body}),c.action&&s.jsx("button",{type:"button",className:"ctx-panel-selected-action",onClick:()=>n(c.action.route),children:c.action.label})]})]}),s.jsxs("section",{className:"ctx-panel-section ctx-panel-ops-summary",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Ops Context"}),s.jsxs("div",{className:"ctx-panel-ops-mode-card",children:[s.jsx("span",{children:"Current"}),s.jsx("strong",{children:Cpe[e]}),s.jsx("small",{children:r?`${Ae(r.generatedAt)} refresh`:"loading"})]}),s.jsxs("div",{className:"ctx-panel-stat-grid",children:[s.jsx(am,{label:"Needs",value:g.length,tone:g.length>0?"warn":"ok"}),s.jsx(am,{label:"Active",value:f.length}),s.jsx(am,{label:"Online",value:`${y.length}/${t.length}`}),s.jsx(am,{label:"Working",value:v.length})]})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Queue",g.length>0&&s.jsx("span",{className:"ctx-panel-count",children:g.length})]}),g.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No operator cues"}):s.jsx("div",{className:"ctx-panel-list",children:g.slice(0,5).map(w=>s.jsx(Ape,{item:w,navigate:n},w.recordId))})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Runs",f.length>0&&s.jsx("span",{className:"ctx-panel-count",children:f.length})]}),f.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No active asks"}):s.jsx("div",{className:"ctx-panel-list",children:f.slice(0,5).map(w=>s.jsx(Tpe,{ask:w,navigate:n},w.invocationId))})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Agent Pulse"}),s.jsx("div",{className:"ctx-panel-pulse-list",children:x.map(w=>s.jsxs("button",{type:"button",className:"ctx-panel-pulse-row",onClick:()=>al(n,w,{returnTo:a}),children:[s.jsx("span",{className:`ctx-panel-pulse-dot ctx-panel-pulse-dot--${Je(w.state)}`}),s.jsx("span",{children:w.name}),s.jsxs("small",{children:[ia(w.state)," · ",w.updatedAt?Ae(w.updatedAt):"unknown"]})]},w.id))})]})]})}function am({label:e,value:t,tone:n}){return s.jsxs("div",{className:`ctx-panel-stat${n?` ctx-panel-stat--${n}`:""}`,children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function PM(e){if(!e||typeof e!="object")return null;const t=e;return t.focus!=="flow"&&t.focus!=="item"||typeof t.title!="string"||typeof t.meta!="string"||typeof t.body!="string"?null:{focus:t.focus,title:t.title,meta:t.meta,body:t.body,action:t.action&&typeof t.action=="object"?t.action:null}}function Ape({item:e,navigate:t}){const{route:n}=qe();return s.jsx("button",{type:"button",className:"ctx-panel-item ctx-panel-item--attention",onClick:()=>{e.conversationId?kt(t,{view:"conversation",conversationId:e.conversationId},{returnTo:n}):t({view:"ops",mode:"mission"})},children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:e.title}),s.jsxs("span",{className:"ctx-panel-sub",children:[e.agentName??e.agentId??"operator"," · ",Ae(e.updatedAt)]})]})})}function Tpe({ask:e,navigate:t}){const{route:n}=qe();return s.jsx("button",{type:"button",className:"ctx-panel-item",onClick:()=>{e.conversationId?kt(t,{view:"conversation",conversationId:e.conversationId},{returnTo:n}):t({view:"ops",mode:"mission"})},children:s.jsxs("div",{className:"ctx-panel-body",children:[s.jsx("span",{className:"ctx-panel-name",children:e.task}),s.jsxs("span",{className:"ctx-panel-sub",children:[e.agentName??e.agentId," · ",e.statusLabel]})]})})}const Mpe=new Set(["working","queued","needs_attention"]);function pg(){const[e,t]=m.useState(null),n=m.useCallback(async()=>{const a=await me("/api/fleet").catch(()=>null);t(a)},[]);return m.useEffect(()=>{n()},[n]),tn(a=>{(a.kind==="message.posted"||a.kind==="flight.updated"||a.kind==="collaboration.event.appended")&&n()}),m.useMemo(()=>{const a=new Map;for(const r of e?.activeAsks??[]){if(!Mpe.has(r.status))continue;const o=a.get(r.agentId);(!o||r.updatedAt>o.updatedAt)&&a.set(r.agentId,r)}return a},[e])}function DM({name:e,kind:t="user",presence:n,className:a,channelClassName:r,background:o,style:c,title:u}){if(t==="channel")return s.jsx("span",{className:r??a,style:c,title:u,children:"#"});const h=e&&e.length>0?e[0].toUpperCase():"?",f=o??qt(e),g=n!=null?s.jsx(QD,{state:n}):null;return g?s.jsxs("span",{className:"oc-avatar-wrap",children:[s.jsx("span",{className:a,style:{background:f,...c},title:u,children:h}),g]}):s.jsx("span",{className:a,style:{background:f,...c},title:u,children:h})}function QD({state:e,className:t,style:n}){const a=Je(typeof e=="string"?e:e??null),r=a==="working"?"working":a==="available"?"available":null;return s.jsx("span",{className:t,style:{background:Pn(r),...n}})}function Tn({name:e,meta:t,sub:n,tone:a="neutral",avatarName:r,avatarKind:o="user",leadingIcon:c,caret:u,active:h,selected:f,unread:g,depth:v=0,detail:y,expanded:x,onClick:w,onKeyDown:C,onPointerEnter:T,onPointerLeave:E,title:S,tabIndex:k}){const N=["rr-row",v===1&&"rr-row--child",h&&"rr-row--active",f&&"rr-row--selected",g&&"rr-row--unread",x&&"rr-row--expanded"].filter(Boolean).join(" ");return s.jsxs("div",{className:N,children:[s.jsxs("button",{type:"button",className:"rr-row-head",onClick:w,onKeyDown:C,onPointerEnter:T,onPointerLeave:E,title:S,tabIndex:k,"aria-expanded":y!==void 0?!!x:void 0,children:[s.jsx(Rpe,{icon:c,tone:a,caret:u,avatarName:r,avatarKind:o}),s.jsxs("span",{className:"rr-row-body",children:[s.jsx("span",{className:"rr-row-name",children:e}),n&&s.jsx("span",{className:"rr-row-sub",children:n})]}),t&&s.jsx("span",{className:"rr-row-meta",children:t})]}),x&&y&&s.jsx("div",{className:"rr-row-detail",children:y})]})}function Rpe({icon:e,tone:t,caret:n,avatarName:a,avatarKind:r}){if(n)return s.jsx("span",{className:`rr-row-caret rr-row-caret--leading rr-row-caret--${n}`,"aria-hidden":!0,children:s.jsx(Ipe,{open:n==="open"})});if(a){if(r==="channel")return s.jsx(DM,{kind:"channel",name:a,channelClassName:"rr-row-hash"});const c=LM(t),u=c==="working"||c==="available";return s.jsxs("span",{className:"rr-row-avatar-wrap","aria-hidden":!0,children:[s.jsx(DM,{className:"rr-row-avatar",name:a}),u&&s.jsx(QD,{state:c,className:`rr-row-presence rr-row-presence--${c}`})]})}if(e)return s.jsx("span",{className:"rr-row-icon","aria-hidden":!0,children:e});const o=LM(t);return s.jsx("span",{className:`rr-row-dot rr-row-dot--${o}`,style:o==="working"||o==="available"?{background:Pn(o)}:void 0,"aria-hidden":!0})}function Ipe({open:e}){return s.jsx("svg",{className:`rr-chevron${e?" rr-chevron--open":""}`,viewBox:"0 0 12 12",width:"12",height:"12",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M4.25 3L7.75 6L4.25 9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function LM(e){return e==="channel"||e==="dm"||e==="neutral"?e:Je(e)}const _pe=new Set(["message.posted","flight.updated","collaboration.event.appended","agent.updated"]),Ope=4,$pe=4,Ppe=3;function Dpe({prepend:e}){const{agents:t,navigate:n,route:a}=qe(),[r,o]=m.useState(null),c=oa(a),u=m.useMemo(()=>eo(t,c),[t,c]),h=m.useMemo(()=>el(t,c),[t,c]),f=m.useMemo(()=>H$(r,u),[r,u]),g=m.useCallback(async()=>{const w=await me("/api/fleet").catch(()=>null);o(w)},[]);m.useEffect(()=>{g()},[g]),tn(w=>{_pe.has(w.kind)&&g()});const v=m.useMemo(()=>Fpe(h).slice(0,Ope),[h]),y=m.useMemo(()=>(f?.activity??[]).slice(0,$pe),[f]),x=m.useMemo(()=>(f?.needsAttention??[]).slice(0,Ppe),[f]);return s.jsxs("div",{className:"ctx-panel base-rail",children:[e?s.jsx("div",{className:"base-rail-prepend",children:e}):null,s.jsx(Lpe,{agents:v,totalCount:h.length,onlineCount:h.filter(w=>Vi(w.state)).length,onSelect:w=>al(n,w,{returnTo:a}),onSeeAll:()=>n({view:"agents"})}),s.jsx(Bpe,{items:y,onSelect:w=>n(Vpe(w)),onSeeAll:()=>n({view:"activity"})}),s.jsx(Upe,{items:x,onSelect:w=>n(w.conversationId?{view:"conversation",conversationId:w.conversationId}:{view:"ops",mode:"mission"})})]})}function Lpe({agents:e,totalCount:t,onlineCount:n,onSelect:a,onSeeAll:r}){return s.jsxs("section",{className:"ctx-panel-section base-rail-section",children:[s.jsx(Nj,{title:"Recent agents",meta:t>0?`${n} on · ${t}`:void 0,onSeeAll:t>0?r:void 0}),e.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No agents yet"}):e.map(o=>s.jsx(Tn,{name:o.name||o.id,meta:o.updatedAt?Ae(o.updatedAt):void 0,tone:Je(o.state),title:zpe(o),onClick:()=>a(o)},o.id))]})}function zpe(e){const t=[];return e.project&&t.push(`project: ${e.project}`),e.branch&&t.push(`branch: ${e.branch}`),e.harness&&t.push(`harness: ${e.harness}`),t.join(`
181
+ `)}function Bpe({items:e,onSelect:t,onSeeAll:n}){return s.jsxs("section",{className:"ctx-panel-section base-rail-section",children:[s.jsx(Nj,{title:"Recent activity",meta:(e.length>0,void 0),onSeeAll:e.length>0?n:void 0}),e.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"Quiet so far"}):e.map(a=>{const r=a.actorName??a.agentName??a.agentId??"system",o=a.title??a.summary??zM(a.kind);return s.jsx(Tn,{name:o,meta:a.ts?Ae(a.ts):void 0,tone:"neutral",title:`${r} · ${zM(a.kind)}`,onClick:()=>t(a)},a.id)})]})}function Upe({items:e,onSelect:t}){return s.jsxs("section",{className:"ctx-panel-section base-rail-section",children:[s.jsx(Nj,{title:"Needs attention",meta:e.length>0?`${e.length}`:void 0}),e.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"All clear"}):e.map(n=>{const a=n.agentName??n.agentId??"operator";return s.jsx(Tn,{name:n.title,meta:Ae(n.updatedAt),tone:"working",unread:!0,title:`${a} · ${n.kind}`,onClick:()=>t(n)},n.recordId)})]})}function Nj({title:e,meta:t,onSeeAll:n}){return s.jsxs("div",{className:"ctx-panel-section-label base-rail-section-label",children:[s.jsx("span",{children:e}),s.jsxs("span",{className:"base-rail-section-trailing",children:[t?s.jsx("span",{className:"ctx-panel-count",children:t}):null,n?s.jsx("button",{type:"button",className:"base-rail-see-all",onClick:n,children:"all"}):null]})]})}function Fpe(e){return[...e].sort((t,n)=>(n.updatedAt??0)-(t.updatedAt??0))}function zM(e){switch(e){case"message":return"Message";case"invocation":return"Invocation";case"flight":return"Flight update";case"collaboration":return"Collaboration";default:return e.replace(/_/g," ")}}function Vpe(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:{view:"activity"}}function Hpe(){const[e,t]=m.useState("rack"),{agents:n}=qe(),{meshSnapshot:a,selectedId:r,selectedType:o,hiddenMachineIds:c,machinePositions:u}=Sc(),h=m.useMemo(()=>a?cj(n,a):[],[n,a]);if(!a||h.length===0)return null;const f=h.filter(x=>!c.has(x.machineId)).length,g=h.length,v=Object.keys(u).length,y=x=>{Fo(x,"node"),o0(x)};return s.jsxs("div",{className:"mesh-rail",children:[s.jsxs("div",{className:"mesh-rail-head",children:[s.jsx("span",{className:"mesh-rail-ear","aria-hidden":!0}),s.jsxs("div",{className:"mesh-rail-mode",role:"group","aria-label":"Bottom view",children:[s.jsx("button",{type:"button",className:`mesh-rail-mode-btn${e==="map"?" mesh-rail-mode-btn--active":""}`,onClick:()=>t("map"),"aria-pressed":e==="map",children:"map"}),s.jsx("button",{type:"button",className:`mesh-rail-mode-btn${e==="rack"?" mesh-rail-mode-btn--active":""}`,onClick:()=>t("rack"),"aria-pressed":e==="rack",children:"rack"})]}),s.jsx("span",{className:"mesh-rail-title-count",children:g}),s.jsx("span",{className:"mesh-rail-ear","aria-hidden":!0})]}),e==="rack"?s.jsx(qpe,{buckets:h,hiddenMachineIds:c,selectedId:r,selectedType:o,onFocus:y}):s.jsx(Wpe,{buckets:h,selectedId:r,selectedType:o,onFocus:y}),s.jsxs("div",{className:"mesh-rail-foot",children:[s.jsx("span",{className:"mesh-rail-foot-mark","aria-hidden":!0}),s.jsx("span",{className:"mesh-rail-foot-meta",children:e==="map"?`${g} machines`:`${f}/${g} shown`}),v>0&&e==="rack"?s.jsx("button",{type:"button",className:"mesh-rail-foot-reset",onClick:()=>qle(),title:"Reset machine layout",children:"reset"}):s.jsx("span",{className:"mesh-rail-foot-mark","aria-hidden":!0})]})]})}function qpe({buckets:e,hiddenMachineIds:t,selectedId:n,selectedType:a,onFocus:r}){return s.jsx("div",{className:"mesh-rail-body",children:e.map((o,c)=>{const u=t.has(o.machineId),h=n===o.machineId&&a==="node",f=o.agents.filter(T=>Je(T.state)==="working").length,g=o.agents.filter(T=>Je(T.state)==="available").length,v=o.online?o.agents.length===0?"offline":f>0?"working":"available":"offline",y=u||!o.online?void 0:Pn(v),x=o.reachability==="this"?"L":o.reachability==="peer"?"P":o.reachability==="tailnet"?"T":"·",w=String(c+1).padStart(2,"0"),C=o.online?o.agents.length===0?"idle":`${f}w · ${g}a`:"unreachable";return s.jsxs("div",{className:["mesh-rail-unit",u&&"mesh-rail-unit--off",!o.online&&"mesh-rail-unit--unreachable",h&&"mesh-rail-unit--active"].filter(Boolean).join(" "),children:[s.jsxs("button",{type:"button",className:"mesh-rail-unit-body",onClick:()=>r(o.machineId),title:`Focus ${o.machineLabel} on the map`,children:[s.jsx("span",{className:"mesh-rail-slot",children:w}),s.jsx("span",{className:`mesh-rail-led${u||!o.online?"":" mesh-rail-led--on"}`,style:y?{background:y,color:y}:void 0,"aria-hidden":!0}),s.jsxs("span",{className:"mesh-rail-unit-text",children:[s.jsx("span",{className:"mesh-rail-unit-name",title:o.machineLabel,children:o.machineLabel}),s.jsxs("span",{className:"mesh-rail-unit-sub",children:[s.jsx("span",{className:`mesh-rail-reach mesh-rail-reach--${o.reachability}`,children:x}),s.jsx("span",{className:"mesh-rail-unit-stamp",children:C})]})]}),s.jsx("span",{className:"mesh-rail-unit-count",children:o.agents.length})]}),s.jsx("div",{className:"mesh-rail-unit-actions",children:s.jsx("button",{type:"button",className:`mesh-rail-unit-eye${u?" mesh-rail-unit-eye--off":""}`,onClick:T=>{T.stopPropagation(),aD(o.machineId)},title:u?"Show in workspace":"Hide from workspace","aria-pressed":!u,children:u?"○":"●"})}),s.jsx("span",{className:"mesh-rail-vent","aria-hidden":!0})]},o.machineId)})})}function Wpe({buckets:e,selectedId:t,selectedType:n,onFocus:a}){return s.jsx("div",{className:"mesh-rail-body mesh-rail-body--map",children:s.jsx("div",{className:"mesh-mini-map",children:e.map(r=>{const o=t===r.machineId&&n==="node",c=r.agents.filter(f=>Je(f.state)==="working").length,u=r.online?r.agents.length===0?"offline":c>0?"working":"available":"offline",h=r.online?Pn(u):void 0;return s.jsxs("button",{type:"button",className:`mesh-mini-node mesh-mini-node--${u}${o?" mesh-mini-node--active":""}${r.online?"":" mesh-mini-node--off"}`,onClick:()=>a(r.machineId),title:`${r.machineLabel} — ${r.agents.length} agents`,children:[s.jsx("span",{className:"mesh-mini-led",style:h?{background:h}:void 0,"aria-hidden":!0}),s.jsx("span",{className:"mesh-mini-label",children:r.machineLabel}),r.agents.length>0&&s.jsx("span",{className:"mesh-mini-count",children:r.agents.length})]},r.machineId)})})})}const JD="openscout.globalJumpDock.mode.v1";function Gpe(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(JD);return e==="jump"||e==="minimap"?e:null}catch{return null}}function Zpe(e){try{window.localStorage.setItem(JD,e)}catch{}}function Kpe(){const{route:e,navigate:t}=qe(),n=e.view==="mesh",[a,r]=m.useState(()=>{const c=Gpe();return c==="minimap"&&n?"minimap":c==="jump"?"jump":n?"minimap":"jump"});m.useEffect(()=>{a==="minimap"&&!n&&r("jump")},[a,n]);const o=c=>{r(c),Zpe(c)};return s.jsxs("div",{className:"gjd",children:[s.jsxs("div",{className:"gjd-head",children:[s.jsx("span",{className:"gjd-ear","aria-hidden":!0}),s.jsxs("div",{className:"gjd-mode",role:"group","aria-label":"Bottom dock mode",children:[s.jsx("button",{type:"button",className:`gjd-mode-btn${a==="jump"?" gjd-mode-btn--active":""}`,onClick:()=>o("jump"),"aria-pressed":a==="jump",children:"jump"}),n&&s.jsx("button",{type:"button",className:`gjd-mode-btn${a==="minimap"?" gjd-mode-btn--active":""}`,onClick:()=>o("minimap"),"aria-pressed":a==="minimap",children:"minimap"})]}),s.jsx("span",{className:"gjd-ear","aria-hidden":!0})]}),s.jsx("div",{className:"gjd-body",children:a==="minimap"&&n?s.jsx(Hpe,{}):s.jsx(Xpe,{navigate:t})})]})}const Ype=[{id:"sessions",label:"Sessions",icon:s.jsx(_p,{size:13,strokeWidth:1.6}),route:{view:"sessions"}},{id:"tail",label:"Tail",icon:s.jsx(qz,{size:13,strokeWidth:1.6}),route:{view:"ops",mode:"tail"}},{id:"control",label:"Control",icon:s.jsx(l2,{size:13,strokeWidth:1.6}),route:{view:"ops",mode:"mission"}},{id:"fleet",label:"Fleet",icon:s.jsx(s2,{size:13,strokeWidth:1.6}),route:{view:"fleet"}},{id:"broker",label:"Broker",icon:s.jsx(rz,{size:13,strokeWidth:1.6}),route:{view:"broker"}}];function Xpe({navigate:e}){return s.jsx("div",{className:"gjd-jumps",children:Ype.map(t=>s.jsxs("button",{type:"button",className:"gjd-jump",onClick:()=>e(t.route),children:[s.jsx("span",{className:"gjd-jump-icon",children:t.icon}),s.jsx("span",{className:"gjd-jump-label",children:t.label})]},t.id))})}function eL({value:e,onChange:t,placeholder:n="Search…",onKeyDown:a}){return s.jsx("input",{type:"search",className:"fleet-search",placeholder:n,value:e,onChange:r=>t(r.target.value),onKeyDown:a,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off"})}const Qpe=["working","available","offline"];function tL({active:e,onToggle:t}){return s.jsx("div",{className:"fleet-pills",role:"group","aria-label":"State filters",children:Qpe.map(n=>{const a=e.has(n);return s.jsx("button",{type:"button",className:`fleet-pill fleet-pill--${n}${a?" fleet-pill--on":""}`,onClick:()=>t(n),"aria-pressed":a,children:n},n)})})}const BM=10;function Jpe(e){const t=Je(e.state);return t==="working"||t==="available"?t:"offline"}function UM(e){return e.updatedAt??e.createdAt??0}function ege(){const{agents:e,navigate:t}=qe(),{meshSnapshot:n,selectedId:a,selectedType:r,query:o,agentStateFilters:c,hiddenMachineIds:u,treeFullMachineIds:h}=Sc(),f=pg(),g=m.useMemo(()=>n?cj(e,n):[],[e,n]),v=m.useMemo(()=>{const S=o.trim().toLowerCase();return g.filter(k=>!u.has(k.machineId)).map(k=>{const N=k.agents.filter(A=>c.has(Jpe(A))?S?`${A.name??""} ${A.project??""} ${A.branch??""} ${A.harness??""}`.toLowerCase().includes(S):!0:!1);return{...k,agents:N}})},[g,o,c,u]),y=m.useMemo(()=>{const S=new Map([["this",[]],["peer",[]],["tailnet",[]]]);for(const k of v){const N=k.reachability==="this"?"this":k.reachability==="peer"?"peer":"tailnet";S.get(N)?.push(k)}return S},[v]);if(!n)return s.jsx("div",{className:"ctx-panel ctx-panel--empty",children:s.jsx("div",{className:"ctx-panel-empty-state",children:s.jsx("div",{className:"ctx-panel-empty-hint",children:"Loading mesh…"})})});const x=S=>{const k=g.map(N=>N.machineId);Ule(S,k),Fo(S,"node"),o0(S)},w=u.size,C=g.length,T=S=>{Fo(S.id,"agent");const k=S.authorityNodeId??S.homeNodeId;k&&o0(k),al(t,S,{returnTo:{view:"mesh"}})},E=(S,k)=>k.length===0?null:s.jsxs("section",{className:"mesh-nav-group",children:[s.jsx("div",{className:"mesh-nav-group-label",children:S}),k.map(N=>{const A=h.has(N.machineId),R=[...N.agents].sort((U,D)=>UM(D)-UM(U)),_=A?R:R.slice(0,BM),P=R.length-_.length,$=a===N.machineId&&r==="node",H=N.agents.filter(U=>Je(U.state)==="working").length,I=N.agents.length>0?`${H}/${N.agents.length}`:N.online?"—":"offline";return s.jsxs("div",{className:"mesh-nav-machine",children:[s.jsx(Tn,{name:N.machineLabel,meta:I,tone:"neutral",active:$,onClick:()=>x(N.machineId),title:`Focus ${N.machineLabel} on the map`}),_.map(U=>{const D=a===U.id&&r==="agent",V=f.has(U.id);return s.jsx(Tn,{name:U.name,tone:Je(U.state),depth:1,active:D,unread:V,onClick:()=>T(U),title:U.name},U.id)}),!A&&P>0&&s.jsx(Tn,{name:`see ${P} more`,depth:1,tone:"neutral",onClick:()=>TT(N.machineId),title:"Show all agents on this machine"}),A&&R.length>BM&&s.jsx(Tn,{name:"see less",depth:1,tone:"neutral",onClick:()=>TT(N.machineId),title:"Show recent agents only"})]},N.machineId)})]},S);return s.jsxs("div",{className:"ctx-panel mesh-nav",children:[s.jsxs("div",{className:"mesh-nav-head",children:[s.jsx(eL,{value:o,onChange:sD,placeholder:"Find machines or agents…"}),s.jsx(tL,{active:c,onToggle:Ble}),w>0&&w<C&&s.jsxs("button",{type:"button",className:"mesh-nav-focus-chip",onClick:Fle,title:"Show all machines",children:[s.jsxs("span",{className:"mesh-nav-focus-chip-label",children:["focused · ",C-w,"/",C]}),s.jsx("span",{className:"mesh-nav-focus-chip-clear","aria-hidden":!0,children:"×"})]})]}),s.jsxs("div",{className:"mesh-nav-tree",children:[E("this host",y.get("this")??[]),E("peers",y.get("peer")??[]),E("tailnet",y.get("tailnet")??[])]})]})}const FM={working:0,available:1,offline:2},tge=["all","dm","channel"],nge={all:"All",dm:"DMs",channel:"Channels"},sge=["recent","name","unread"],VM={recent:"Recent",name:"Name",unread:"Unread"};function age(){const{route:e,navigate:t,agents:n}=qe(),[a,r]=m.useState([]),[o,c]=m.useState(()=>Zw()),[u,h]=m.useState(""),[f,g]=m.useState(()=>new Set),v=pg(),y=oa(e),x=m.useMemo(()=>eo(n,y),[n,y]),w=m.useMemo(()=>{const D=new Map,V=x?n.filter(Z=>x.has(Z.id)):n;for(const Z of V)D.set(Z.id,Z);return D},[n,x]),C=e.view==="messages"&&e.filter?e.filter:"all",T=e.view==="messages"&&e.sort?e.sort:"recent",E=e.view==="messages"||e.view==="conversation"?e.conversationId:e.view==="channels"?e.channelId:e.view==="agent-info"||e.view==="agents"?e.conversationId:void 0,S=m.useCallback(async()=>{const D=await me("/api/conversations").catch(()=>[]);r(D)},[]);m.useEffect(()=>{S()},[S]),tn(D=>{(D.kind==="message.posted"||D.kind==="conversation.upserted")&&S()});const k=m.useMemo(()=>{let D=og(a,x,y);if(C==="dm"?D=D.filter(Nse):C==="channel"&&(D=D.filter(Uo)),u){const Z=u.toLowerCase();D=D.filter(O=>Ha(O).toLowerCase().includes(Z)||O.id.toLowerCase().includes(Z)||(O.preview??"").toLowerCase().includes(Z))}const V=[...D];switch(T){case"name":V.sort((Z,O)=>Ha(Z).toLowerCase().localeCompare(Ha(O).toLowerCase()));break;case"unread":{const Z=O=>Im(O.lastMessageAt,O.id,o)?0:1;V.sort((O,z)=>{const B=Z(O),X=Z(z);return B!==X?B-X:(z.lastMessageAt??0)-(O.lastMessageAt??0)});break}default:V.sort((Z,O)=>(O.lastMessageAt??0)-(Z.lastMessageAt??0));break}return V},[a,x,C,T,u,o]),N=D=>{t({view:"messages",...E?{conversationId:E}:{},...D!=="all"?{filter:D}:{},...T!=="recent"?{sort:T}:{}})},A=D=>{t({view:"messages",...E?{conversationId:E}:{},...C!=="all"?{filter:C}:{},...D!=="recent"?{sort:D}:{}})},R=D=>{if(c(Kw(D.id)),Uo(D)&&e.view==="channels"){t({view:"channels",channelId:D.id});return}t({view:"messages",conversationId:D.id,...C!=="all"?{filter:C}:{},...T!=="recent"?{sort:T}:{}})},_=D=>{g(V=>{const Z=new Set(V);return Z.has(D)?Z.delete(D):Z.add(D),Z})},P=m.useMemo(()=>rge(k,w,o,T),[k,w,o,T]),$=m.useRef(null),H=m.useRef(null),I=I$(),U=O$(()=>$.current);return _$(m.useCallback(()=>H.current,[])),s.jsxs("div",{className:"ctx-panel",children:[s.jsx("div",{className:"ctx-panel-tabs",children:tge.map(D=>s.jsx("button",{type:"button",className:["ctx-panel-tab",C===D&&"ctx-panel-tab--active"].filter(Boolean).join(" "),onClick:()=>N(D),children:nge[D]},D))}),s.jsxs("div",{className:"ctx-panel-toolbar",children:[s.jsx("input",{ref:H,type:"text",className:"ctx-panel-search-input",placeholder:"Filter… (/)",value:u,onChange:D=>h(D.target.value),onKeyDown:U}),s.jsx("div",{className:"ctx-panel-sort",role:"group","aria-label":"Sort",children:sge.map(D=>s.jsx("button",{type:"button",title:`Sort by ${VM[D].toLowerCase()}`,className:["ctx-panel-sort-option",T===D&&"ctx-panel-sort-option--active"].filter(Boolean).join(" "),onClick:()=>A(D),children:VM[D]},D))})]}),s.jsx("div",{ref:$,className:"ctx-panel-list ctx-panel-list--scroll",onKeyDown:I,children:P.length===0?s.jsx("div",{className:"ctx-panel-empty",children:u?"No match":"Nothing yet"}):(()=>{const D=P.flatMap(O=>O.conversations),V=D[0]?.id,Z=E!=null&&D.some(O=>O.id===E);return P.map(O=>{const z=O.conversations.length===1,B=!!u||f.has(O.key),X=O.conversations.some(W=>W.id===E);if(z){const W=O.conversations[0],L=W.id===E,q=Im(W.lastMessageAt,W.id,o),K=Ha(W),ee=Uo(W),G=W.agentId?w.get(W.agentId):void 0;return s.jsx(Tn,{name:K,meta:W.lastMessageAt?Ae(W.lastMessageAt):void 0,tone:ee?"channel":G?Je(G.state):"dm",avatarName:K,avatarKind:ee?"channel":"user",active:L,unread:q,tabIndex:Fb(L,Z,W.id===V),onClick:()=>R(W)},O.key)}return s.jsxs("div",{children:[s.jsx(Tn,{name:O.label,meta:lge(O),tone:O.bestState,caret:B?"open":"closed",active:X&&!B,unread:O.unreadCount>0&&!B,onClick:()=>_(O.key)}),B&&O.conversations.map(W=>{const L=W.id===E,q=Im(W.lastMessageAt,W.id,o),K=W.agentId?w.get(W.agentId):void 0,ee=W.agentId?v.get(W.agentId):void 0;return s.jsx(Tn,{depth:1,name:HM(W,K,ee),meta:W.lastMessageAt?Ae(W.lastMessageAt):void 0,tone:K?Je(K.state):"dm",avatarName:K?.name??HM(W,K,ee),active:L,unread:q,title:ige(W,K,ee),tabIndex:Fb(L,Z,W.id===V),onClick:()=>R(W)},W.id)})]},O.key)})})()})]})}function rge(e,t,n,a){const r=new Map;for(const c of e){const u=Uo(c);let h,f;if(u)h=`channel:${c.id}`,f=Ha(c);else{const y=(c.agentId?t.get(c.agentId):void 0)?.project??null;if(y)h=`project:${y.toLowerCase()}`,f=y;else{const x=(c.agentName??Ha(c)).trim();x?(h=`name:${x.toLowerCase()}`,f=x):(h=`dm:${c.id}`,f=Ha(c))}}let g=r.get(h);if(g||(g={key:h,label:f,isChannel:u,conversations:[],bestState:"offline",latestUpdate:0,unreadCount:0},r.set(h,g)),g.conversations.push(c),g.latestUpdate=Math.max(g.latestUpdate,c.lastMessageAt??0),Im(c.lastMessageAt,c.id,n)&&(g.unreadCount+=1),!u){const v=c.agentId?t.get(c.agentId):void 0;if(v){const y=Je(v.state);(FM[y]??9)<(FM[g.bestState]??9)&&(g.bestState=y)}}}for(const c of r.values())c.conversations.sort((u,h)=>(h.lastMessageAt??0)-(u.lastMessageAt??0));const o=Array.from(r.values());switch(a){case"name":o.sort((c,u)=>c.label.toLowerCase().localeCompare(u.label.toLowerCase()));break;case"unread":o.sort((c,u)=>c.unreadCount>0!=u.unreadCount>0?c.unreadCount>0?-1:1:u.latestUpdate-c.latestUpdate);break;default:o.sort((c,u)=>u.latestUpdate-c.latestUpdate);break}return o}function HM(e,t,n){const a=n?.task??oge(e.preview)??e.currentBranch??t?.branch??"",r=t?.name??e.agentName??Ha(e);return a?`${r} · ${a}`:r}function ige(e,t,n){const a=[];return n&&a.push(`task: ${n.task}`),e.preview&&a.push(`preview: ${e.preview}`),(e.currentBranch??t?.branch)&&a.push(`branch: ${e.currentBranch??t?.branch}`),t?.harness&&a.push(`harness: ${t.harness}`),a.length>0?a.join(`
182
+ `):void 0}function oge(e){if(!e)return null;const t=e.replace(/\s+/g," ").trim();return t?t.length>60?`${t.slice(0,57)}…`:t:null}function lge(e){const t=e.latestUpdate?Ae(e.latestUpdate):"",n=e.unreadCount>0?`${e.unreadCount}/${e.conversations.length}`:`${e.conversations.length}`;return t?`${n} · ${t}`:n}function cge(){const{navigate:e}=qe(),t=kD(),n=t.visibleAgents,a=m.useRef(null),r=m.useRef(null),o=I$(),c=O$(()=>a.current);_$(m.useCallback(()=>r.current,[]));const[u,h]=m.useState(null),f=t.activityFilter==="recent",g=t.selectedIds.length,v=x=>{h(w=>w===x?null:x)},y=()=>{if(g===0)return;const w=n.filter(C=>t.selectedIds.includes(C.id)).map(C=>C.handle??C.name).filter(Boolean).join("|");w&&e({view:"ops",mode:"tail",tailQuery:w})};return s.jsxs("div",{className:"ctx-panel ml-panel",children:[s.jsxs("div",{className:"ml-section",children:[s.jsx("div",{className:"ml-section-label",children:"Source"}),s.jsx("div",{className:"ml-chips ml-chips--primary",children:["all","scout","native"].map(x=>s.jsx("button",{type:"button",className:["ml-chip",t.sourceFilter===x&&"ml-chip--active"].filter(Boolean).join(" "),onClick:()=>jD(x),children:x==="all"?"All":x==="scout"?"Scout":"Native"},x))})]}),s.jsx("div",{className:"ctx-panel-search",children:s.jsx("input",{ref:r,type:"text",className:"ctx-panel-search-input",placeholder:"Filter agents… (press /)",value:t.query,onChange:x=>kp(x.target.value),onKeyDown:x=>{c(x),x.key==="Escape"&&t.query&&kp("")}})}),s.jsx("div",{className:"ml-section ml-section--secondary",children:s.jsxs("div",{className:"ml-chips ml-chips--secondary",children:[["all","active","recent"].map(x=>s.jsx("button",{type:"button",className:["ml-chip ml-chip--ghost",t.activityFilter===x&&"ml-chip--ghost-active"].filter(Boolean).join(" "),onClick:()=>wD(x),children:x==="all"?"Any":x==="active"?"Active":"Recent"},x)),f&&s.jsx("span",{className:"ml-divider","aria-hidden":!0}),f&&Np.map(x=>s.jsx("button",{type:"button",className:["ml-chip ml-chip--ghost",t.recentWindowMs===x.value&&"ml-chip--ghost-active"].filter(Boolean).join(" "),onClick:()=>ND(x.value),children:x.label},x.value))]})}),g>0?s.jsxs("div",{className:"ml-selection",children:[s.jsxs("span",{className:"ml-selection-label",children:[g," selected"]}),s.jsxs("div",{className:"ml-selection-actions",children:[s.jsx("button",{type:"button",className:"ml-selection-btn ml-selection-btn--primary",onClick:y,children:"Tail ↗"}),s.jsx("button",{type:"button",className:"ml-selection-btn",onClick:$m,children:"Clear"})]})]}):s.jsxs("div",{className:"ml-count",children:[n.length," visible",s.jsx("span",{className:"ml-count-hint",children:"⌘-click · ⌘A all"})]}),s.jsx("div",{ref:a,className:"ctx-panel-list ctx-panel-list--scroll",onKeyDown:o,children:n.length===0?s.jsx("div",{className:"ctx-panel-empty",children:t.query?"No match":"Nothing visible"}):n.map((x,w)=>{const C=x.id===u,T=n.some(k=>k.id===u),E=t.selectedIds.includes(x.id),S=Je(x.state);return s.jsx(uge,{agent:x,state:S,isExpanded:C,isSelected:E,tabIndex:Fb(C,T,w===0),onToggle:k=>{k.metaKey||k.ctrlKey||k.shiftKey?Xl(x.id):v(x.id)},onFocusOnCanvas:()=>Tue(x.id),onOpen:()=>e({view:"agents",agentId:x.id})},x.id)})})]})}function uge({agent:e,state:t,isExpanded:n,isSelected:a,tabIndex:r,onToggle:o,onFocusOnCanvas:c,onOpen:u}){const h=Gr({label:`Focus ${e.handle??e.name}`,route:`/ops/control · ${e.id}`}),f=s.jsxs(s.Fragment,{children:[s.jsxs("dl",{className:"rr-spec-list",children:[s.jsx(Hu,{label:"MODEL",value:[e.harness,e.model].filter(Boolean).join("/")||"—"}),s.jsx(Hu,{label:"AT",value:[e.project,e.branch].filter(Boolean).join("/")||"—"}),s.jsx(Hu,{label:"STATE",value:t}),s.jsx(Hu,{label:"ACTIVITY",value:e.activity}),s.jsx(Hu,{label:"SOURCE",value:e.source})]}),s.jsxs("div",{className:"ml-detail-actions",children:[s.jsx("button",{type:"button",className:"ml-detail-btn",onClick:c,children:"Focus on canvas"}),s.jsx("button",{type:"button",className:"ml-detail-btn ml-detail-btn--primary",onClick:u,children:"Open ↗"})]})]});return s.jsx(Tn,{name:e.handle??e.name,meta:e.lastActiveAt?Ae(e.lastActiveAt):e.updatedAt?Ae(e.updatedAt):void 0,tone:t,caret:n?"open":"closed",selected:a,expanded:n,detail:f,tabIndex:r,onClick:g=>o(g),onPointerEnter:h.onPointerEnter,onPointerLeave:h.onPointerLeave})}function Hu({label:e,value:t}){return s.jsxs("div",{className:"rr-spec",children:[s.jsx("dt",{className:"rr-spec-label",children:e}),s.jsx("dd",{className:"rr-spec-value",title:t,children:t})]})}const dge=new Set(["message.posted","conversation.upserted","agent.updated"]);function fge(e){const t=qM(e.cwd),n=qM(e.projectRoot);return e.authorityNodeName??e.homeNodeName??e.authorityNodeId??e.homeNodeId??e.transport??t??n??"local"}function hge(e){return e.project??e.role??e.agentClass??"Unassigned"}function qM(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??null}function mge(){const{agents:e,navigate:t}=qe(),[n,a]=m.useState([]),r=pg(),o=m.useCallback(async()=>{const g=await me("/api/conversations").catch(()=>[]);a(g)},[]);m.useEffect(()=>{o()},[o]),tn(g=>{dge.has(g.kind)&&o()});const c=m.useMemo(()=>e.filter(g=>g.state!=="offline").length,[e]),u=m.useMemo(()=>{let g=0;for(const v of r.values())(v.status==="failed"||v.status==="needs_attention")&&(g+=1);return g},[r]),h=m.useMemo(()=>{const g=new Map;for(const v of e){const y=hge(v);g.set(y,(g.get(y)??0)+1)}return[...g.entries()].sort((v,y)=>y[1]-v[1]).slice(0,8)},[e]),f=m.useMemo(()=>{const g=new Map;for(const v of e){const y=fge(v);g.set(y,(g.get(y)??0)+1)}return[...g.entries()].sort((v,y)=>y[1]-v[1]).slice(0,8)},[e]);return s.jsxs("div",{className:"ctx-panel",children:[s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Fleet"}),s.jsx(Tn,{name:"Overview",meta:`${e.length}`,tone:"neutral",onClick:()=>t({view:"fleet"})}),s.jsx(Tn,{name:"Agents",meta:`${c}`,tone:"available",active:!0,onClick:()=>t({view:"ops",mode:"agents"})}),s.jsx(Tn,{name:"Sessions",meta:`${n.length}`,tone:"neutral",onClick:()=>t({view:"sessions"})}),s.jsx(Tn,{name:"Alerts",meta:`${u}`,tone:u>0?"working":"neutral",unread:u>0,onClick:()=>t({view:"activity"})})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Projects"}),h.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No projects"}):h.map(([g,v])=>s.jsx(Tn,{name:g,meta:`${v}`,tone:"neutral",title:`${v} agent${v===1?"":"s"} on ${g}`},g))]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsx("div",{className:"ctx-panel-section-label",children:"Machines"}),f.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No machines"}):f.map(([g,v])=>s.jsx(Tn,{name:g,meta:`${v}`,tone:"neutral",title:`${v} agent${v===1?"":"s"} on ${g}`},g))]})]})}function pge(){const{navigate:e,route:t}=qe(),[n,a]=m.useState(null),r=m.useCallback(async()=>{const f=await me("/api/fleet").catch(()=>null);a(f)},[]);m.useEffect(()=>{r()},[r]),tn(f=>{(f.kind==="message.posted"||f.kind==="flight.updated"||f.kind==="collaboration.event.appended")&&r()});const o=n?.needsAttention??[],c=(n?.activeAsks??[]).filter(f=>f.status!=="needs_attention"),u=f=>{f.conversationId?kt(e,{view:"conversation",conversationId:f.conversationId},{returnTo:t}):e({view:"ops",mode:"mission"})},h=f=>{f.conversationId?kt(e,{view:"conversation",conversationId:f.conversationId},{returnTo:t}):e({view:"ops",mode:"mission"})};return s.jsxs("div",{className:"ctx-panel ctx-panel--ops",children:[s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Needs you",o.length>0&&s.jsx("span",{className:"ctx-panel-count",children:o.length})]}),o.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"All clear"}):o.slice(0,4).map(f=>{const g=f.agentName??f.agentId??"operator";return s.jsx(Tn,{name:f.title,meta:Ae(f.updatedAt),tone:"working",unread:!0,title:`${g} · ${f.kind}`,onClick:()=>u(f)},f.recordId)})]}),s.jsxs("section",{className:"ctx-panel-section",children:[s.jsxs("div",{className:"ctx-panel-section-label",children:["Active",c.length>0&&s.jsx("span",{className:"ctx-panel-count",children:c.length})]}),c.length===0?s.jsx("div",{className:"ctx-panel-empty",children:"No active asks"}):c.slice(0,10).map(f=>s.jsx(Tn,{name:f.task,meta:Ae(f.updatedAt),tone:f.agentState,title:`${f.agentName??f.agentId} · ${f.statusLabel}`,onClick:()=>h(f)},f.invocationId))]})]})}function gge(){const e=AD(),t=e.counts;return s.jsxs("div",{className:"ctx-panel pa-panel",children:[s.jsx("div",{className:"ctx-panel-search",children:s.jsx("input",{type:"text",className:"ctx-panel-search-input",placeholder:"Search records…",value:e.query,onChange:n=>TD(n.target.value)})}),s.jsx(rm,{title:"Author",children:Xde.map(n=>s.jsx(im,{label:n.label,count:t.byAuthor[n.id]??0,active:e.authorFilter===n.id,onClick:()=>Gde(n.id)},n.id))}),s.jsx(rm,{title:"Outcome",children:Qde.map(n=>s.jsx(im,{label:n.label,count:t.byOutcome[n.id]??0,active:e.outcomeFilter===n.id,onClick:()=>Zde(n.id)},n.id))}),s.jsx(rm,{title:"Time",children:s.jsx("div",{className:"pa-chips",children:MD.map(n=>s.jsx("button",{type:"button",className:`pa-chip${e.timeFilter===n.id?" pa-chip--active":""}`,onClick:()=>Kde(n.id),children:n.label},n.id))})}),t.byProject.length>1&&s.jsxs(rm,{title:"Project",children:[s.jsx(im,{label:"All",count:t.total,active:e.projectFilter==="all",onClick:()=>nM("all")}),t.byProject.slice(0,12).map(n=>s.jsx(im,{label:n.id,count:n.count,active:e.projectFilter===n.id,onClick:()=>nM(n.id)},n.id))]})]})}function rm({title:e,children:t}){return s.jsxs("div",{className:"pa-group",children:[s.jsx("div",{className:"pa-group-title",children:e}),t]})}function im({label:e,count:t,active:n,onClick:a}){return s.jsxs("button",{type:"button",className:`pa-row${n?" pa-row--active":""}`,onClick:a,children:[s.jsx("span",{className:"pa-row-label",children:e}),s.jsx("span",{className:"pa-row-count",children:t})]})}function vge(e){if(e.view==="ops")return e.mode==="mission"?{mode:"takeover",render:()=>s.jsx(cge,{})}:e.mode==="plan"?{mode:"takeover",render:()=>s.jsx(gge,{})}:e.mode==="agents"?{mode:"takeover",render:()=>s.jsx(mge,{})}:{mode:"takeover",render:()=>s.jsx(pge,{})};switch(e.view){case"agents":case"agent-info":return{mode:"takeover",render:()=>s.jsx(Cge,{})};case"messages":case"channels":case"conversation":return{mode:"takeover",render:()=>s.jsx(age,{})};case"mesh":return{mode:"takeover",render:()=>s.jsx(ege,{})};default:return null}}const ql={working:0,available:1,offline:2};function yge(e){return e.project?e.project.toLowerCase():"other"}function xge(e){return`project:${e.agents[0]?.project?.trim().toLowerCase()||"unscoped"}`}function bge(e){const t=new Map;for(const a of e){const r=yge(a),o=t.get(r);o?o.push(a):t.set(r,[a])}const n=[];for(const[a,r]of t){r.sort((u,h)=>{const f=(ql[Je(u.state)]??9)-(ql[Je(h.state)]??9);return f!==0?f:(h.updatedAt??0)-(u.updatedAt??0)});const o=r.reduce((u,h)=>{const f=Je(h.state);return(ql[f]??9)<(ql[u]??9)?f:u},"offline"),c=Math.max(...r.map(u=>u.updatedAt??0));n.push({key:a,label:a,agents:r,bestState:o,latestUpdate:c})}return n.sort((a,r)=>{const o=(ql[a.bestState]??9)-(ql[r.bestState]??9);return o!==0?o:r.latestUpdate-a.latestUpdate}),n}function wge(e){return e.trim().toLowerCase()}function jge(e){return[e.id,e.name,e.handle??"",e.selector??"",e.project??"",e.branch??"",e.role??"",e.harness??"",e.harnessSessionId??"",e.conversationId,e.harnessLogPath??""]}function Nge(e,t){return t?jge(e).some(n=>n.toLowerCase().includes(t)):!0}function Lx(e,t){return t?[e.harnessSessionId,e.conversationId].find(a=>a?.toLowerCase().includes(t))??null:null}function zx(e,t,n={}){al(e,t,{...n,returnTo:{view:"agents"}})}function kge(){const{route:e}=qe(),t=vge(e),n=t?.mode==="takeover"?t.render():s.jsx(Dpe,{prepend:t?.mode==="prepend"?t.render():void 0});return s.jsxs("div",{className:"scout-left-shell",children:[s.jsx("div",{className:"scout-left-shell-rail",children:n}),s.jsx(Kpe,{})]})}const Sge=new Set(["working","available","offline"]);function Cge(){const{agents:e,route:t,navigate:n}=qe(),[a,r]=m.useState(()=>new Set),[o,c]=m.useState(""),[u,h]=m.useState(Sge),f=pg(),g=oa(t),v=m.useMemo(()=>el(e,g),[e,g]),y=wge(o),x=y.length>0,w=A=>{h(R=>{const _=new Set(R);return _.has(A)?_.delete(A):_.add(A),_})},C=m.useMemo(()=>v.filter(A=>{const R=Je(A.state),_=R==="working"||R==="available"?R:"offline";return u.has(_)?Nge(A,y):!1}),[y,v,u]),T=m.useMemo(()=>bge(C),[C]),E=C[0]??null,S=t.view==="agents"?t.agentId:void 0,k=t.view==="agents"&&!t.agentId?t.projectKey:void 0,N=A=>{r(R=>{if(R.has(A))return R;const _=new Set(R);return _.add(A),_})};return s.jsxs("div",{className:"s-left-roster",children:[s.jsxs("div",{className:"s-left-roster-search",children:[s.jsx(eL,{value:o,onChange:c,placeholder:"Search agents or session IDs…",onKeyDown:A=>{A.key==="Escape"&&(o?c(""):A.target.blur()),A.key==="Enter"&&E&&zx(n,E,{observe:!!Lx(E,y)})}}),s.jsx(tL,{active:u,onToggle:w})]}),s.jsx("div",{style:{flex:1,overflow:"auto"},children:v.length===0?s.jsx("div",{className:"s-left-roster-empty",children:g?"No agents on this machine":"No agents registered"}):C.length===0?s.jsx("div",{className:"s-left-roster-empty",children:"No agents match this session or agent search."}):T.map(A=>{const R=A.agents.length===1,_=x||a.has(A.key),P=R?A.agents[0]:null,$=A.agents.some(V=>V.id===S),H=P?Lx(P,y):null,I=xge(A),U=k===I;if(R&&P){const V=f.get(P.id);return s.jsx(Tn,{name:A.label,meta:P.updatedAt?Ae(P.updatedAt):void 0,sub:Tge(P,V,H),tone:Je(P.state),avatarName:P.name,active:P.id===S||U,title:WM(P,V,H),onClick:()=>zx(n,P,{observe:!!H})},A.key)}const D=Rge(A.agents);return s.jsxs("div",{children:[s.jsx(Tn,{name:A.label,meta:Ige(A.agents),sub:`${A.agents.length} agents`,tone:A.bestState,caret:_?"open":"closed",active:U||$&&!_,selected:$&&!U,onClick:()=>{N(A.key),n({view:"agents",projectKey:I})}}),_&&A.agents.map(V=>{const Z=f.get(V.id),O=Lx(V,y),z=D.has(V.id);return s.jsx(Tn,{depth:1,name:V.name,meta:V.updatedAt?Ae(V.updatedAt):void 0,sub:Mge(V,Z,O,z),tone:Je(V.state),avatarName:V.name,active:V.id===S,title:WM(V,Z,O),onClick:()=>zx(n,V,{observe:!!O})},V.id)})]},A.key)})})]})}const Ege="⎇";function Age(e){return(e.conversationId??e.harnessSessionId??"").slice(-5)}function nL(e){return e.branch?`${Ege} ${e.branch}`:null}function Tge(e,t,n){if(n)return`session · ${n}`;if(t)return t.task;const a=nL(e);if(a)return a}function Mge(e,t,n,a){if(n)return`session · ${n}`;if(t)return t.task;const r=[],o=nL(e);if(o&&r.push(o),a){const c=Age(e);c&&r.push(`#${c}`)}return r.length>0?r.join(" · "):void 0}function Rge(e){const t=new Map;for(const a of e){const r=`${a.name}::${a.branch??""}`;t.set(r,(t.get(r)??0)+1)}const n=new Set;for(const a of e){const r=`${a.name}::${a.branch??""}`;(t.get(r)??0)>1&&n.add(a.id)}return n}function WM(e,t,n){const a=[];return t&&a.push(`task: ${t.task}`),e.branch&&a.push(`branch: ${e.branch}`),e.harness&&a.push(`harness: ${e.harness}`),n&&a.push(`session: ${n}`),a.length>0?a.join(`
183
+ `):void 0}function Ige(e){let t=0,n=0,a=0;for(const o of e){const c=Je(o.state);c==="working"?t+=1:c==="available"?n+=1:a+=1}const r=[];return t&&r.push(`${t}w`),n&&r.push(`${n}a`),a&&!t&&!n&&r.push(`${a}o`),r.length===0?`${e.length}`:r.join(" · ")}function _ge(){const e=aP(),t=rP(),n=U0({url:e,healthUrl:t,autoConnect:!0,sessionKey:"scout-terminal"});return s.jsx("div",{style:{height:"100%",background:"#0d0d0d",overflow:"hidden"},children:s.jsx(F0,{relay:n,fontSize:13,configItems:[{label:"ws",value:e},{label:"health",value:t}]})})}function Oge(){const{onboarding:e}=qe();return e?e.hasLocalConfig?e.hasOperatorName?e.hasProjectConfig?null:s.jsx(Bx,{children:s.jsx(Dge,{})}):s.jsx(Bx,{children:s.jsx(Pge,{})}):s.jsx(Bx,{children:s.jsx($ge,{})}):null}function Bx({children:e}){return s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"auto",background:"var(--bg)",color:"var(--ink)"},children:s.jsx("div",{style:{width:"100%",maxWidth:720,padding:"80px 72px",display:"flex",flexDirection:"column",gap:40},children:e})})}function kj({eyebrow:e,title:t,description:n}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[s.jsx("div",{style:Lge,children:e}),s.jsx("div",{style:zge,children:t}),s.jsx("div",{style:Bge,children:n})]})}function Sj({primary:e,onPrimary:t,primaryDisabled:n,busy:a}){const{skipOnboarding:r}=qe();return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:24,paddingTop:8},children:[s.jsx("button",{type:"button",onClick:t,disabled:n||a,style:{...Fge,opacity:n||a?.5:1,cursor:n||a?"default":"pointer"},children:a?"Working…":e}),s.jsx("button",{type:"button",onClick:r,style:Vge,onMouseEnter:o=>{o.currentTarget.style.color="rgba(255,255,255,0.8)"},onMouseLeave:o=>{o.currentTarget.style.color="rgba(255,255,255,0.45)"},children:"Skip for now"})]})}function Cj({message:e}){return e?s.jsx("div",{style:{borderRadius:8,border:"1px solid rgba(239,68,68,0.35)",backgroundColor:"rgba(239,68,68,0.08)",color:"rgba(252,165,165,0.95)",padding:"12px 16px",fontSize:12,lineHeight:1.5},children:e}):null}function $ge(){const{onboarding:e,refreshOnboarding:t}=qe(),[n,a]=m.useState(!1),[r,o]=m.useState(null),c=async()=>{a(!0),o(null);try{await me("/api/onboarding/init",{method:"POST",body:"{}"}),await t()}catch(u){o(u instanceof Error?u.message:String(u))}finally{a(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(kj,{eyebrow:"First-run setup",title:"Welcome to Scout",description:s.jsxs(s.Fragment,{children:["Scout needs a local config before it can talk to the broker, the web app, and paired devices. This writes"," ",s.jsx("code",{style:C0,children:"~/.openscout/config.json"})," with sensible defaults — you can edit it any time."]})}),s.jsxs("ul",{style:Hge,children:[s.jsx(GM,{label:"Local config (~/.openscout/config.json)",done:!1,hint:"missing"}),s.jsx(GM,{label:".openscout/project.json in a repo",done:!!e?.hasProjectConfig,hint:e?.hasProjectConfig?e.projectRoot??void 0:"checked after setup"})]}),s.jsx(Cj,{message:r}),s.jsx(Sj,{primary:"Initialize Scout",onPrimary:()=>{c()},busy:n})]})}function Pge(){const{onboarding:e,refreshOnboarding:t}=qe(),n=e?.operatorNameSuggestion??"",[a,r]=m.useState(n),[o,c]=m.useState(!1),[u,h]=m.useState(null);m.useEffect(()=>{!a&&n&&r(n)},[n,a]);const f=async()=>{const g=a.trim();if(!g){h("Name is required.");return}c(!0),h(null);try{await me("/api/user",{method:"POST",body:JSON.stringify({name:g})}),await t()}catch(v){h(v instanceof Error?v.message:String(v))}finally{c(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(kj,{eyebrow:"Step 1 of 2",title:"What should we call you?",description:"Your name shows up on messages you send and in any agent that speaks for you. You can change it later in Settings."}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsx("label",{style:Dm,children:"Your name"}),s.jsx("input",{autoFocus:!0,value:a,onChange:g=>{r(g.target.value),h(null)},onKeyDown:g=>{g.key==="Enter"&&f()},placeholder:n||"Operator",style:S0}),n?s.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontFamily:"var(--hud-font-mono)"},children:"Prefilled from your machine."}):null]}),s.jsx(Cj,{message:u}),s.jsx(Sj,{primary:"Continue",onPrimary:()=>{f()},busy:o,primaryDisabled:!a.trim()})]})}function Dge(){const{onboarding:e,refreshOnboarding:t}=qe(),n=e?.currentDirectory??"",[a,r]=m.useState([n||"~/dev"]),[o,c]=m.useState(n),[u,h]=m.useState("claude"),[f,g]=m.useState(!1),[v,y]=m.useState(null),x=(E,S)=>{r(k=>k.map((N,A)=>A===E?S:N))},w=()=>r(E=>[...E,""]),C=E=>r(S=>S.filter((k,N)=>N!==E)),T=async()=>{const E=a.map(k=>k.trim()).filter(Boolean),S=o.trim();if(!S){y("Pick where Scout should anchor this context.");return}g(!0),y(null);try{await me("/api/onboarding/project",{method:"POST",body:JSON.stringify({contextRoot:S,sourceRoots:E,defaultHarness:u})}),await t()}catch(k){y(k instanceof Error?k.message:String(k))}finally{g(!1)}};return s.jsxs(s.Fragment,{children:[s.jsx(kj,{eyebrow:"Step 2 of 2",title:"Where do your repos live?",description:s.jsxs(s.Fragment,{children:["Scout scans these folders for projects and anchors this context at"," ",s.jsx("code",{style:C0,children:"<context>/.openscout/project.json"}),"."]})}),s.jsxs("div",{style:Ux,children:[s.jsx("label",{style:Dm,children:"Scan folders"}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.map((E,S)=>s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsx("input",{value:E,onChange:k=>x(S,k.target.value),placeholder:S===0?"~/dev":"Add another folder",style:{...S0,flex:1}}),s.jsx("button",{type:"button",onClick:()=>C(S),disabled:a.length<=1,style:{...ZM,opacity:a.length<=1?.4:1,cursor:a.length<=1?"default":"pointer"},"aria-label":`Remove folder ${S+1}`,children:"−"})]},S)),s.jsx("button",{type:"button",onClick:w,style:{...ZM,alignSelf:"flex-start"},children:"+ Add folder"})]})]}),s.jsxs("div",{style:Ux,children:[s.jsx("label",{style:Dm,children:"Context root"}),s.jsx("input",{value:o,onChange:E=>c(E.target.value),placeholder:"~/dev",style:S0}),s.jsxs("div",{style:Uge,children:["Scout writes ",s.jsx("code",{style:C0,children:".openscout/project.json"})," ","inside this folder."]})]}),s.jsxs("div",{style:Ux,children:[s.jsx("label",{style:Dm,children:"Default harness"}),s.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:["claude","codex"].map(E=>{const S=u===E;return s.jsxs("button",{type:"button",onClick:()=>h(E),style:{...qge,borderColor:S?"var(--accent, #2dd4bf)":"rgba(255,255,255,0.12)",backgroundColor:S?"rgba(45,212,191,0.08)":"rgba(255,255,255,0.02)"},children:[s.jsx("div",{style:{fontSize:15,fontWeight:600,textTransform:"capitalize"},children:E}),s.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",marginTop:6,lineHeight:1.5},children:E==="claude"?"Anthropic Claude Code — local CLI agent.":"OpenAI Codex — cloud agentic sandbox."})]},E)})})]}),s.jsx(Cj,{message:v}),s.jsx(Sj,{primary:"Create project",onPrimary:()=>{T()},busy:f,primaryDisabled:!o.trim()})]})}function GM({label:e,done:t,hint:n}){return s.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:16},children:[s.jsx("span",{style:{marginTop:2,width:20,height:20,borderRadius:999,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,flexShrink:0,backgroundColor:t?"rgba(34,197,94,0.15)":"rgba(239,68,68,0.12)",color:t?"#4ade80":"#f87171"},children:t?"✓":"•"}),s.jsxs("div",{style:{minWidth:0},children:[s.jsx("div",{style:{fontSize:13,lineHeight:1.5,color:t?"rgba(255,255,255,0.75)":"rgba(255,255,255,0.9)"},children:e}),n?s.jsx("div",{style:{fontSize:11,fontFamily:"var(--hud-font-mono)",color:"rgba(255,255,255,0.35)",marginTop:4,wordBreak:"break-all"},children:n}):null]})]})}const Lge={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.18em",color:"rgba(255,255,255,0.4)"},zge={fontSize:36,fontWeight:600,letterSpacing:"-0.01em",lineHeight:1.15},Bge={fontSize:15,lineHeight:1.75,color:"rgba(255,255,255,0.6)",maxWidth:580},Ux={display:"flex",flexDirection:"column",gap:10},Dm={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.5)"},S0={width:"100%",padding:"10px 14px",fontSize:14,fontFamily:"var(--hud-font-mono)",color:"rgba(255,255,255,0.92)",backgroundColor:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,outline:"none",boxSizing:"border-box"},Uge={fontSize:12,color:"rgba(255,255,255,0.45)",lineHeight:1.6},C0={fontFamily:"var(--hud-font-mono)",fontSize:12,padding:"2px 6px",borderRadius:4,backgroundColor:"rgba(255,255,255,0.06)"},Fge={fontSize:13,fontWeight:600,padding:"12px 24px",borderRadius:10,backgroundColor:"var(--accent, #2dd4bf)",color:"#0b0d12",border:"none",transition:"opacity 0.15s ease"},ZM={fontSize:13,fontWeight:500,padding:"10px 14px",borderRadius:8,backgroundColor:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.12)",color:"rgba(255,255,255,0.85)",transition:"all 0.15s ease"},Vge={fontSize:12,color:"rgba(255,255,255,0.45)",textDecoration:"underline dotted rgba(255,255,255,0.25)",textUnderlineOffset:4,background:"none",border:"none",cursor:"pointer",padding:"4px 2px",transition:"color 0.15s ease"},Hge={display:"flex",flexDirection:"column",gap:20,margin:0,padding:0,listStyle:"none"},qge={textAlign:"left",padding:"16px 18px",borderRadius:12,border:"1px solid rgba(255,255,255,0.12)",color:"rgba(255,255,255,0.9)",cursor:"pointer",transition:"all 0.15s ease"},Wge=[{commandId:"nav:home",title:"Go to Home",description:"Navigate to the home overview showing queue, threads, signal, and activity",category:"navigation",keywords:["home","inbox","dashboard"],shortcut:"Cmd+1"},{commandId:"nav:agents",title:"Go to Agents",description:"Navigate to the agents roster showing all registered agents",category:"navigation",keywords:["agents","roster","list"],shortcut:"Cmd+2"},{commandId:"nav:fleet",title:"Go to Fleet",description:"Navigate to the fleet overview with agent status summary",category:"navigation",keywords:["fleet","overview","status"],shortcut:"Cmd+3"},{commandId:"nav:conversations",title:"Go to Conversations",description:"Navigate to the unified conversations playground backed by the normalized conversations service",category:"navigation",keywords:["conversations","comms","chat","threads"]},{commandId:"nav:sessions",title:"Go to Sessions",description:"Navigate to the sessions list showing all active conversations",category:"navigation",keywords:["sessions","conversations","threads"],shortcut:"Cmd+4"},{commandId:"nav:channels",title:"Go to Channels",description:"Navigate to the channels browser for group conversations",category:"navigation",keywords:["channels","channel","group","broadcast"],shortcut:"Cmd+5"},{commandId:"nav:activity",title:"Go to Activity",description:"Navigate to the activity feed showing recent events",category:"navigation",keywords:["activity","feed","events","log"],shortcut:"Cmd+6"},{commandId:"nav:mesh",title:"Go to Mesh",description:"Navigate to the mesh network view showing nodes and topology",category:"navigation",keywords:["mesh","network","nodes","peers","topology"],shortcut:"Cmd+7"},{commandId:"nav:settings",title:"Open Settings",description:"Open the settings screen for pairing, identity, and relay config",category:"settings",keywords:["settings","preferences","config","pair"],shortcut:"Cmd+,"},{commandId:"nav:agent-config",title:"Open Agent Configuration",description:"Open the unified agent configuration surface for runtimes, agents, tools, delivery, and broker state",category:"settings",keywords:["agent config","runtimes","providers","mcp","tools"]},{commandId:"nav:pair",title:"Pair Device",description:"Open the device pairing flow to connect a mobile device",category:"settings",keywords:["pair","qr","device","phone","mobile"]},{commandId:"scout:reload",title:"Reload Agents",description:"Refresh the agent list and message state from the broker",category:"workspace",keywords:["reload","refresh","sync"]},{commandId:"scout:open:*",title:"Open Agent Conversation",description:"Open the DM lane for one specific agent. One agent maps to a DM; group work belongs in an explicit channel and broadcasts belong in the shared channel.",category:"navigation",keywords:["open","chat","conversation","dm","message"],params:[{name:"agentId",description:"The agent identifier to open",type:"string"}]},{commandId:"scout:send:*",title:"Tell Agent",description:"Open or compose the DM tell/update path for one specific agent. Use Tell for heads-up, replies, status, and steering an active turn inside the same DM.",category:"workspace",keywords:["tell","message","update","dm","reply","steer"],params:[{name:"agentId",description:"The agent identifier to tell",type:"string"},{name:"message",description:"The message body to send",type:"string"}]},{commandId:"scout:ask:*",title:"Ask Agent",description:"Open the DM ask path for one specific agent. Use Ask when the meaning is 'own this work and get back to me' and keep follow-up in the same DM.",category:"workspace",keywords:["ask","assign","task","dm","work","reply"],params:[{name:"agentId",description:"The agent identifier to ask",type:"string"},{name:"message",description:"The message body to send",type:"string"}]},{commandId:"scout:interrupt:*",title:"Interrupt Agent",description:"Send Ctrl-C to interrupt a working agent. The commandId is scout:interrupt:{agentId}.",category:"workspace",keywords:["stop","interrupt","cancel","halt","kill"],dangerous:!0,params:[{name:"agentId",description:"The agent identifier to interrupt",type:"string"}]}];function sL(e={}){const{initialTheme:t="dark"}=e;return{id:"openscout",name:"Scout",description:"All your agents, one message away. Scout is a control plane for managing coding agents: one agent means a DM, group work means an explicit channel, Tell stays conversational, Ask is owned work with a reply path, and shared updates mean broadcast.",mode:"panel",icon:m.createElement(l2,{size:14,strokeWidth:1.2}),Provider:({children:n})=>m.createElement(rte,{initialTheme:t,children:n}),leftPanel:{title:"Navigation"},rightPanel:{title:"Context"},slots:{Content:Ghe,LeftPanel:kge,Inspector:fpe,Takeover:Oge,Terminal:_ge},intents:Wge,hooks:{useCommands:cte,useStatus:ute,useNavCenter:fte,useNavActions:hte,useLayoutMode:mte,useTakeover:pte}}}sL();function KM(e){return e==="dark"||e==="light"?e:null}function Gge(){if(typeof window>"u")return"dark";const e=KM(hse());if(e)return e;const t=KM(new URLSearchParams(window.location.search).get("theme"));return t||"dark"}function Zge(e){typeof document>"u"||(document.documentElement.dataset.scoutThemeMode=e,document.documentElement.style.colorScheme=e)}const Kge=[{title:"Tone (band-pass)",sliders:[{key:"lowCutHz",label:"Low cut",min:80,max:1200,step:10,format:e=>`${e.toFixed(0)} Hz`},{key:"highCutHz",label:"High cut",min:1500,max:6e3,step:50,format:e=>`${e.toFixed(0)} Hz`},{key:"bandQ",label:"Filter Q",min:.2,max:2,step:.05,format:e=>e.toFixed(2)}]},{title:"Grit (saturation + bit-crush)",sliders:[{key:"saturationAmount",label:"Saturation",min:0,max:1,step:.01,format:e=>e.toFixed(2)},{key:"bitcrushAmount",label:"Bit-crush",min:0,max:1,step:.01,format:e=>e.toFixed(2)}]},{title:"Carrier hiss",sliders:[{key:"hissGain",label:"Hiss level",min:0,max:.25,step:.005,format:e=>e.toFixed(3)},{key:"hissCutoffHz",label:"Hiss high-pass",min:300,max:4e3,step:50,format:e=>`${e.toFixed(0)} Hz`}]},{title:"Presence (mid-band peak — comm intelligibility)",sliders:[{key:"presencePeakDb",label:"Boost",min:0,max:12,step:.5,format:e=>`${e.toFixed(1)} dB`},{key:"presenceCenterHz",label:"Center",min:600,max:3e3,step:50,format:e=>`${e.toFixed(0)} Hz`},{key:"presenceQ",label:"Q (narrowness)",min:.3,max:3,step:.1,format:e=>e.toFixed(1)}]},{title:"Squelch tail (channel-drop noise)",sliders:[{key:"squelchTailGain",label:"Tail gain",min:0,max:.3,step:.005,format:e=>e.toFixed(3)},{key:"squelchTailDurationMs",label:"Tail length",min:40,max:500,step:10,format:e=>`${e.toFixed(0)} ms`}]},{title:"Compressor",sliders:[{key:"compressorThresholdDb",label:"Threshold",min:-60,max:0,step:1,format:e=>`${e.toFixed(0)} dB`},{key:"compressorRatio",label:"Ratio",min:1,max:12,step:.5,format:e=>`${e.toFixed(1)} : 1`}]},{title:"Delivery",sliders:[{key:"playbackRate",label:"Speed (pitch-shifts)",min:.75,max:1.35,step:.01,format:e=>`${e.toFixed(2)}×`}]},{title:"Kerchunk / output",sliders:[{key:"clickGain",label:"Click gain",min:0,max:1,step:.01,format:e=>e.toFixed(2)},{key:"clickDurationMs",label:"Click length",min:20,max:200,step:5,format:e=>`${e.toFixed(0)} ms`},{key:"outputGain",label:"Output gain",min:0,max:2,step:.05,format:e=>e.toFixed(2)},{key:"wetMix",label:"Wet mix",min:0,max:1,step:.01,format:e=>e.toFixed(2)}]}],YM=.12,Yge=e=>Math.max(.7,Math.min(1.45,e)),Xge=220,E0={...fg,lowCutHz:160,highCutHz:5200,bandQ:.35,saturationAmount:.035,bitcrushAmount:0,hissGain:0,hissCutoffHz:1800,presencePeakDb:1.5,presenceCenterHz:1500,presenceQ:.65,compressorThresholdDb:-15,compressorRatio:2.2,clickEnabled:!0,clickGain:.24,clickDurationMs:45,squelchTailEnabled:!0,squelchTailGain:.018,squelchTailDurationMs:95,playbackRate:1,outputGain:1,wetMix:.38},Qge={...E0,lowCutHz:190,highCutHz:5e3,saturationAmount:.055,bitcrushAmount:.01,hissGain:.006,presencePeakDb:2.5,compressorThresholdDb:-17,compressorRatio:2.8,clickGain:.28,squelchTailGain:.024,squelchTailDurationMs:105,wetMix:.44};function Jge(e){return`const SCOUTBOT_VOICE_FX: Partial<VoiceFxParams> = {
184
+ ${Object.entries(e).map(([n,a])=>` ${n}: ${typeof a=="number"?Number(a.toFixed(3)):String(a)},`).join(`
185
+ `)}
186
+ };`}function eve(){const[e,t]=m.useState(null),[n,a]=m.useState(null),[r,o]=m.useState({}),[c,u]=m.useState(E0),[h,f]=m.useState(null),[g,v]=m.useState(null),[y,x]=m.useState(null),[w,C]=m.useState(!1),[T,E]=m.useState(!1),S=m.useRef(null),k=m.useRef(null),N=m.useRef(c),A=m.useRef(w),R=m.useRef(T);m.useEffect(()=>{N.current=c},[c]),m.useEffect(()=>{A.current=w},[w]),m.useEffect(()=>{R.current=T},[T]),m.useEffect(()=>{let O=!1;return(async()=>{try{const z=await fetch("/api/dev/scoutbot-fx/fixtures");if(!z.ok)throw new Error(`HTTP ${z.status}`);const B=await z.json();O||t(B)}catch(z){O||a(z instanceof Error?z.message:String(z))}})(),()=>{O=!0}},[]);const _=m.useCallback(async O=>{if(r[O.slug])return r[O.slug].buffer;const z=await Jse(`/api/dev/scoutbot-fx/audio/${encodeURIComponent(O.file)}`);return o(B=>({...B,[O.slug]:{fixture:O,buffer:z}})),z},[r]),P=m.useCallback(()=>{k.current=null,S.current?.stop(),S.current=null,v(null)},[]),$=m.useCallback(O=>{const z=$d.find(B=>B.id===O);z&&(u(z.params),f(O))},[]),H=m.useCallback(async()=>{try{await navigator.clipboard.writeText(Jge(c)),x("Copied"),window.setTimeout(()=>x(null),1600)}catch(O){x(O instanceof Error?O.message:"Copy failed")}},[c]),I=m.useCallback(async(O,z)=>{P();const B=Symbol(`${z}:${O.slug}`);k.current=B;const X=`${z}:${O.slug}`;try{const W=await _(O);for(;k.current===B;){const L=R.current?{...N.current,playbackRate:Yge(N.current.playbackRate+(Math.random()*2-1)*YM)}:N.current,q=z==="fx"?Xw(W,{params:L}):aae(W);if(S.current=q,v(X),await q.promise,k.current!==B||!A.current)break;await new Promise(K=>{const ee=setTimeout(K,Xge),G=setInterval(()=>{k.current!==B&&(clearTimeout(ee),clearInterval(G),K())},40)})}}catch(W){console.error(`[scoutbot-fx] ${z} playback failed`,W)}finally{k.current===B&&(k.current=null),S.current=null,v(W=>W===X?null:W)}},[_,P]),U=m.useCallback(O=>I(O,"fx"),[I]),D=m.useCallback(O=>I(O,"dry"),[I]),V=m.useMemo(()=>Kge.map(O=>({title:O.title,rows:O.sliders.map(z=>({spec:z,value:c[z.key]}))})),[c]),Z=e?.fixtures??[];return s.jsxs("div",{style:tve,children:[s.jsxs("header",{style:nve,children:[s.jsxs("div",{children:[s.jsx("h1",{style:sve,children:"Scoutbot FX Lab"}),s.jsxs("p",{style:ave,children:["Dispatcher-radio FX prototyping. Generate fixtures with"," ",s.jsx("code",{style:XM,children:"node packages/web/scripts/generate-scoutbot-fx-fixtures.mjs"}),"."]})]}),s.jsxs("div",{style:rve,children:[e?.generatedAt?s.jsxs("span",{children:["Fixtures generated ",new Date(e.generatedAt).toLocaleString()]}):null,e?.note?s.jsx("span",{style:ive,children:e.note}):null,n?s.jsxs("span",{style:ove,children:["Could not load fixtures: ",n]}):null]})]}),s.jsxs("section",{style:lve,children:[s.jsxs("div",{style:Fx,children:[s.jsx("h2",{style:Vx,children:"Presets"}),s.jsx("div",{style:cve,children:"Click to load. Tweaking any slider clears the active preset."})]}),s.jsx("div",{style:uve,children:$d.map(O=>{const z=h===O.id;return s.jsxs("button",{type:"button",style:z?dve:aL,onClick:B=>{$(O.id),B.currentTarget.blur()},title:O.description,children:[s.jsxs("div",{style:z?fve:rL,children:[O.label,s.jsx("span",{style:mve,children:O.family})]}),s.jsx("div",{style:z?hve:iL,children:O.description})]},O.id)})})]}),s.jsxs("section",{style:pve,children:[s.jsxs("div",{style:Fx,children:[s.jsx("h2",{style:Vx,children:"FX chain"}),s.jsxs("div",{style:{display:"flex",gap:8},children:[s.jsxs("label",{style:om,children:[s.jsx("input",{type:"checkbox",checked:c.clickEnabled,onChange:O=>{const z=O.target.checked;f(null),u(B=>({...B,clickEnabled:z}))}}),"Kerchunk click"]}),s.jsxs("label",{style:om,children:[s.jsx("input",{type:"checkbox",checked:c.squelchTailEnabled,onChange:O=>{const z=O.target.checked;f(null),u(B=>({...B,squelchTailEnabled:z}))}}),"Squelch tail"]}),s.jsx("button",{type:"button",style:td,onClick:()=>{f("scoutbot-clean-dispatch"),u(E0)},children:"Scoutbot default"}),s.jsx("button",{type:"button",style:td,onClick:()=>{f("codex-clean-dispatch"),u(Qge)},children:"Codex take"}),s.jsx("button",{type:"button",style:td,onClick:()=>{f(null),u(fg)},children:"Raw default"}),s.jsx("button",{type:"button",style:A0,onClick:()=>{H()},children:y??"Copy params"})]})]}),s.jsx("div",{style:gve,children:V.map(O=>s.jsxs("div",{style:vve,children:[s.jsx("div",{style:yve,children:O.title}),s.jsx("div",{style:xve,children:O.rows.map(({spec:z,value:B})=>s.jsxs("label",{style:bve,children:[s.jsxs("div",{style:wve,children:[s.jsx("span",{children:z.label}),s.jsx("span",{style:jve,children:z.format(B)})]}),s.jsx("input",{type:"range",min:z.min,max:z.max,step:z.step,value:B,onChange:X=>{const W=Number(X.target.value);f(null),u(L=>({...L,[z.key]:W}))}})]},z.key))})]},O.title))})]}),s.jsxs("section",{style:Nve,children:[s.jsxs("div",{style:Fx,children:[s.jsx("h2",{style:Vx,children:"Fixtures"}),s.jsxs("div",{style:{display:"flex",gap:16},children:[s.jsxs("label",{style:om,children:[s.jsx("input",{type:"checkbox",checked:w,onChange:O=>C(O.target.checked)}),"Loop playback",w?" (tweaks apply next iteration)":""]}),s.jsxs("label",{style:om,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:O=>E(O.target.checked)}),"Vary speed ±",Math.round(YM*100),"%"]})]})]}),e?Z.length===0?s.jsxs("p",{style:QM,children:["No fixtures yet. Run"," ",s.jsx("code",{style:XM,children:"node packages/web/scripts/generate-scoutbot-fx-fixtures.mjs"})," ","(Vox must be running) and reload."]}):s.jsx("ul",{style:kve,children:Z.map(O=>{const z=g===`dry:${O.slug}`,B=g===`fx:${O.slug}`;return s.jsxs("li",{style:Sve,children:[s.jsxs("div",{style:Cve,children:[s.jsx("div",{style:Eve,children:O.slug}),s.jsx("div",{style:Ave,children:O.text}),s.jsxs("div",{style:Tve,children:[O.voiceId?`voice ${O.voiceId}`:null,O.voiceId&&O.bytes?" · ":null,O.bytes?`${Math.round(O.bytes/1024)} KB`:null]})]}),s.jsxs("div",{style:Mve,children:[s.jsx("button",{type:"button",style:z?Rve:td,onClick:()=>z?P():D(O),children:z?"Stop":"Play dry"}),s.jsx("button",{type:"button",style:B?Ive:A0,onClick:()=>B?P():U(O),children:B?"Stop":"Play with FX"})]})]},O.slug)})}):s.jsx("p",{style:QM,children:"Loading…"})]})]})}const tve={minHeight:"100vh",background:"#0b0d10",color:"#e6e8eb",padding:"32px 40px 64px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"},nve={display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:24,marginBottom:28},sve={fontSize:22,fontWeight:600,margin:0},ave={color:"#9aa1ab",fontSize:13,marginTop:6,marginBottom:0},rve={display:"flex",flexDirection:"column",gap:4,fontSize:12,color:"#9aa1ab",alignItems:"flex-end"},ive={color:"#f5b342"},ove={color:"#ef6b6b"},XM={fontFamily:"ui-monospace, SFMono-Regular, monospace",background:"#181b20",padding:"1px 6px",borderRadius:4,fontSize:12},lve={background:"#121519",border:"1px solid #1f242b",borderRadius:10,padding:20,marginBottom:18},cve={fontSize:11,color:"#6b727d"},uve={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:10,marginTop:12},aL={textAlign:"left",background:"#0f1216",border:"1px solid #1f242b",borderRadius:8,padding:"12px 14px",color:"#c5cad2",cursor:"pointer",display:"flex",flexDirection:"column",gap:6,fontFamily:"inherit",outline:"none",WebkitAppearance:"none",appearance:"none",transition:"border-color 80ms ease, background 80ms ease, color 80ms ease"},dve={...aL,background:"#1a1f26",borderColor:"#f1f3f5",color:"#ffffff",boxShadow:"0 0 0 1px rgba(241,243,245,0.18)"},rL={fontSize:13,fontWeight:600,display:"flex",alignItems:"center",gap:8},fve={...rL,color:"#ffffff"},iL={fontSize:11,color:"#9aa1ab",lineHeight:1.4},hve={...iL,color:"#c5cad2"},mve={fontSize:9,fontWeight:500,letterSpacing:.6,textTransform:"uppercase",padding:"2px 6px",borderRadius:4,background:"rgba(255,255,255,0.06)",color:"#9aa1ab"},pve={background:"#121519",border:"1px solid #1f242b",borderRadius:10,padding:20,marginBottom:28},Fx={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},Vx={fontSize:14,textTransform:"uppercase",letterSpacing:.6,color:"#9aa1ab",margin:0},gve={display:"flex",flexDirection:"column",gap:18},vve={display:"flex",flexDirection:"column",gap:10},yve={fontSize:11,textTransform:"uppercase",letterSpacing:.8,color:"#6b727d",fontWeight:600},xve={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:16},bve={display:"flex",flexDirection:"column",gap:6,fontSize:12},wve={display:"flex",justifyContent:"space-between",color:"#c5cad2"},jve={color:"#7f8693",fontFamily:"ui-monospace, SFMono-Regular, monospace"},Nve={background:"#121519",border:"1px solid #1f242b",borderRadius:10,padding:20},kve={listStyle:"none",padding:0,margin:"16px 0 0",display:"flex",flexDirection:"column",gap:12},Sve={display:"flex",alignItems:"center",gap:16,background:"#0f1216",border:"1px solid #1f242b",borderRadius:8,padding:"14px 16px"},Cve={flex:1,display:"flex",flexDirection:"column",gap:4},Eve={fontFamily:"ui-monospace, SFMono-Regular, monospace",color:"#9aa1ab",fontSize:12},Ave={color:"#e6e8eb",fontSize:14},Tve={color:"#6b727d",fontSize:11},Mve={display:"flex",gap:8},td={background:"#1c2128",color:"#e6e8eb",border:"1px solid #2a3038",padding:"6px 12px",borderRadius:6,fontSize:12,cursor:"pointer"},Rve={...td,background:"#2a3038",borderColor:"#3c4350"},A0={background:"#2e6cdf",color:"#fff",border:"1px solid #2e6cdf",padding:"6px 12px",borderRadius:6,fontSize:12,cursor:"pointer"},Ive={...A0,background:"#1f57bf",borderColor:"#1f57bf"},om={display:"flex",alignItems:"center",gap:6,fontSize:12,color:"#c5cad2",cursor:"pointer"},QM={color:"#9aa1ab",fontSize:13,margin:"12px 0 0"},oL=document.getElementById("root");if(!oL)throw new Error("missing #root");const lL=Gge();Zge(lL);const _ve=window.location.pathname==="/dev/scoutbot-fx";b4.createRoot(oL).render(s.jsx(m.StrictMode,{children:_ve?s.jsx(eve,{}):s.jsx(Xte,{app:sL({initialTheme:lL})})}));export{JM as g};