durable-actors-observer 0.1.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/ConsoleApp.d.ts +3 -2
- package/dist/FilterCombobox.d.ts +1 -2
- package/dist/Overview.d.ts +1 -2
- package/dist/RequestObserver.d.ts +1 -1
- package/dist/SocketTimeline.d.ts +1 -1
- package/dist/TimeRangePicker.d.ts +1 -2
- package/dist/WebSocketObserver.d.ts +1 -2
- package/dist/client.d.ts +26 -10
- package/dist/index.d.ts +25 -4
- package/dist/index.js +2138 -765
- package/dist/observer-hooks.d.ts +2 -2
- package/dist/{overview-sql.d.ts → overview-metrics.d.ts} +2 -4
- package/dist/queue-wait-history.d.ts +1 -1
- package/dist/queue-wait.d.ts +1 -4
- package/dist/request-history.d.ts +2 -3
- package/dist/socket-history.d.ts +1 -1
- package/dist/socket-sessions.d.ts +2 -4
- package/dist/standalone/app.css +1 -1
- package/dist/standalone/app.js +6 -53
- package/dist/styles.css +1 -1
- package/dist/theme.css +1 -1
- package/package.json +1 -1
- package/dist/request-sql.d.ts +0 -10
package/dist/standalone/app.js
CHANGED
|
@@ -46,58 +46,11 @@ Error generating stack: `+e.message+`
|
|
|
46
46
|
`},Gd=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Kd=function(){O.useEffect(function(){return document.body.setAttribute(Ud,(Gd()+1).toString()),function(){var e=Gd()-1;e<=0?document.body.removeAttribute(Ud):document.body.setAttribute(Ud,e.toString())}},[])},qd=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Kd();var a=O.useMemo(function(){return Vd(i)},[i]);return O.createElement(Hd,{styles:Wd(a,!t,i,n?``:`!important`)})},Jd=!1;if(typeof window<`u`)try{var Yd=Object.defineProperty({},"passive",{get:function(){return Jd=!0,!0}});window.addEventListener(`test`,Yd,Yd),window.removeEventListener(`test`,Yd,Yd)}catch{Jd=!1}var Xd=Jd?{passive:!1}:!1,Zd=function(e){return e.tagName===`TEXTAREA`},Qd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Zd(e)&&n[t]===`visible`)},$d=function(e){return Qd(e,`overflowY`)},ef=function(e){return Qd(e,`overflowX`)},tf=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),af(e,r)){var i=of(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},nf=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},rf=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},af=function(e,t){return e===`v`?$d(t):ef(t)},of=function(e,t){return e===`v`?nf(t):rf(t)},sf=function(e,t){return e===`h`&&t===`rtl`?-1:1},cf=function(e,t,n,r,i){var a=sf(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=of(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&af(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},lf=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},uf=function(e){return[e.deltaX,e.deltaY]},df=function(e){return e&&`current`in e?e.current:e},ff=function(e,t){return e[0]===t[0]&&e[1]===t[1]},pf=function(e){return`
|
|
47
47
|
.block-interactivity-${e} {pointer-events: none;}
|
|
48
48
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
49
|
-
`},mf=0,hf=[];function gf(e){var t=O.useRef([]),n=O.useRef([0,0]),r=O.useRef(),i=O.useState(mf++)[0],a=O.useState(Ld)[0],o=O.useRef(e);O.useEffect(function(){o.current=e},[e]),O.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=pd([e.lockRef.current],(e.shards||[]).map(df),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=O.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=lf(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=tf(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=tf(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return cf(h,t,e,h===`h`?s:c,!0)},[]),c=O.useCallback(function(e){var n=e;if(hf.length&&hf[hf.length-1]===a){var r=`deltaY`in n?uf(n):lf(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&ff(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(df).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=O.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:_f(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=O.useCallback(function(e){n.current=lf(e),r.current=void 0},[]),d=O.useCallback(function(t){l(t.type,uf(t),t.target,s(t,e.lockRef.current))},[]),f=O.useCallback(function(t){l(t.type,lf(t),t.target,s(t,e.lockRef.current))},[]);O.useEffect(function(){return hf.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Xd),document.addEventListener(`touchmove`,c,Xd),document.addEventListener(`touchstart`,u,Xd),function(){hf=hf.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Xd),document.removeEventListener(`touchmove`,c,Xd),document.removeEventListener(`touchstart`,u,Xd)}},[]);var p=e.removeScrollBar,m=e.inert;return O.createElement(O.Fragment,null,m?O.createElement(a,{styles:pf(i)}):null,p?O.createElement(qd,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function _f(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var vf=Dd(Od,gf),yf=O.forwardRef(function(e,t){return O.createElement(Ad,dd({},e,{ref:t,sideCar:vf}))});yf.classNames=Ad.classNames;var bf=Object.defineProperty,xf=(e,t)=>bf(e,`name`,{value:t,configurable:!0}),Sf=`Popover`,[Cf,wf]=is(Sf,[bu]),Tf=bu(),[Ef,Df]=Cf(Sf),Of=xf(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Tf(t),c=O.useRef(null),[l,u]=O.useState(!1),[d,f]=Q({prop:r,defaultProp:i??!1,onChange:a,caller:Sf});return(0,B.jsx)(Nu,{...s,children:(0,B.jsx)(Ef,{scope:t,contentId:rc(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:O.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:O.useCallback(()=>u(!0),[]),onCustomAnchorRemove:O.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),kf=`PopoverTrigger`,Af=O.forwardRef(xf(function(e,t){let{__scopePopover:n,...r}=e,i=Df(kf,n),a=Tf(n),o=ze(t,i.triggerRef),s=(0,B.jsx)(ls.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":$(i.open),...r,ref:o,onClick:Xo(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,B.jsx)(Pu,{asChild:!0,...a,children:s})},`PopoverTrigger`)),jf=`PopoverPortal`,[Mf,Nf]=Cf(jf,{forceMount:void 0}),Pf=xf(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Df(jf,t);return(0,B.jsx)(Mf,{scope:t,forceMount:n,children:(0,B.jsx)(Vu,{present:n||a.open,children:(0,B.jsx)(Lu,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),Ff=`PopoverContent`,If=O.forwardRef(xf(function(e,t){let n=Nf(Ff,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Df(Ff,e.__scopePopover);return(0,B.jsx)(Vu,{present:r||a.open,children:a.modal?(0,B.jsx)(Rf,{...i,ref:t}):(0,B.jsx)(zf,{...i,ref:t})})},`PopoverContent`)),Lf=He(`PopoverContent.RemoveScroll`),Rf=O.forwardRef(xf(function(e,t){let n=Df(Ff,e.__scopePopover),r=O.useRef(null),i=ze(t,r),a=O.useRef(!1);return O.useEffect(()=>{let e=r.current;if(e)return ud(e)},[]),(0,B.jsx)(yf,{as:Lf,allowPinchZoom:!0,children:(0,B.jsx)(Bf,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Xo(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Xo(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:Xo(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),zf=O.forwardRef(xf(function(e,t){let n=Df(Ff,e.__scopePopover),r=O.useRef(!1),i=O.useRef(!1);return(0,B.jsx)(Bf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),Bf=O.forwardRef(xf(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Df(Ff,n),p=Tf(n);return Ns(),(0,B.jsx)(Bs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,B.jsx)(xs,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,B.jsx)(Fu,{"data-state":$(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function $(e){return e?`open`:`closed`}xf($,`getState`);var Vf=Of,Hf=Af,Uf=Pf,Wf=If;function Gf({...e}){return(0,B.jsx)(Vf,{"data-slot":`popover`,...e})}function Kf({...e}){return(0,B.jsx)(Hf,{"data-slot":`popover-trigger`,...e})}function qf({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,B.jsx)(Uf,{children:(0,B.jsx)(Wf,{"data-slot":`popover-content`,align:t,sideOffset:n,className:z(`la:z-50 la:w-72 la:origin-(--radix-popover-content-transform-origin) la:rounded-md la:border la:bg-popover la:p-4 la:text-popover-foreground la:shadow-md la:outline-hidden`,e),...r})})}var Jf=[{minutes:5,label:`Last 5 minutes`},{minutes:15,label:`Last 15 minutes`},{minutes:60,label:`Last hour`},{minutes:360,label:`Last 6 hours`},{minutes:1440,label:`Last 24 hours`},{minutes:10080,label:`Last 7 days`}],Yf={kind:`relative`,minutes:60};function Xf(e,t){switch(e.kind){case`relative`:return{fromMs:Math.floor((t-e.minutes*6e4)/6e4)*6e4};case`absolute`:return{fromMs:e.fromMs,toMs:e.toMs};case`all`:return{}}}function Zf(e){switch(e.kind){case`relative`:return Jf.find(t=>t.minutes===e.minutes)?.label??`Last ${e.minutes} minutes`;case`absolute`:return`${ep(e.fromMs,e.toMs)} – ${ep(e.toMs,e.fromMs)}`;case`all`:return`All retained`}}function Qf(e){switch(e.kind){case`relative`:return`in the ${Zf(e).toLocaleLowerCase()}`;case`absolute`:return`between ${Zf(e)}`;case`all`:return`in retained history`}}function $f(e,t){return e.kind===t.kind&&(e.kind!==`relative`||e.minutes===t.minutes)&&(e.kind!==`absolute`||e.fromMs===t.fromMs&&e.toMs===t.toMs)}function ep(e,t){let n=new Date(e),r=n.toDateString()===new Date(t).toDateString(),i=n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1});return r&&e>t?i:`${n.toLocaleDateString([],{month:`short`,day:`numeric`})} ${i}`}function tp({value:e,onChange:t,allowAll:n=!0,className:r,align:i=`end`}){let[a,o]=(0,O.useState)(!1),[s,c]=(0,O.useState)(()=>rp(e)),[l,u]=(0,O.useState)(!1),d=e=>{t(e),o(!1)};return(0,B.jsxs)(Gf,{open:a,onOpenChange:t=>{t&&(c(rp(e)),u(!1)),o(t)},children:[(0,B.jsx)(Kf,{asChild:!0,children:(0,B.jsxs)(Bn,{type:`button`,variant:`outline`,className:r,"aria-label":`Time range: ${Zf(e)}`,children:[(0,B.jsx)(le,{"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`la:truncate la:tabular-nums`,children:Zf(e)}),(0,B.jsx)(de,{"aria-hidden":`true`,className:`la:text-muted-foreground`})]})}),(0,B.jsxs)(qf,{align:i,"aria-label":`Time range`,className:`la:flex la:w-auto la:p-0 la:text-sm`,children:[(0,B.jsxs)(`div`,{className:`la:flex la:flex-col la:gap-0.5 la:border-r la:p-2`,role:`group`,"aria-label":`Preset ranges`,children:[Jf.map(t=>(0,B.jsx)(np,{label:t.label,selected:$f(e,{kind:`relative`,minutes:t.minutes}),onSelect:()=>d({kind:`relative`,minutes:t.minutes})},t.minutes)),n&&(0,B.jsx)(np,{label:`All retained`,selected:e.kind===`all`,onSelect:()=>d({kind:`all`})})]}),(0,B.jsxs)(`form`,{className:`la:flex la:w-[22rem] la:flex-col`,"aria-label":`Custom range`,onSubmit:e=>{e.preventDefault();let t=ip(s);if(!t){u(!0);return}u(!1),d(t)},children:[(0,B.jsx)(Wo,{mode:`range`,numberOfMonths:1,defaultMonth:s.dates?.to??s.dates?.from,selected:s.dates,onSelect:e=>c(t=>({...t,dates:e})),disabled:{after:new Date}}),(0,B.jsxs)(`div`,{className:`la:flex la:items-end la:gap-2 la:border-t la:px-3 la:py-3`,children:[(0,B.jsxs)(`label`,{className:`la:grid la:gap-1 la:text-xs la:text-muted-foreground`,children:[`From`,(0,B.jsx)(Ko,{type:`time`,name:`from`,required:!0,className:`la:h-8 la:w-24 la:tabular-nums`,value:s.fromTime,onChange:e=>c({...s,fromTime:e.target.value}),"aria-invalid":l||void 0})]}),(0,B.jsxs)(`label`,{className:`la:grid la:gap-1 la:text-xs la:text-muted-foreground`,children:[`To`,(0,B.jsx)(Ko,{type:`time`,name:`to`,required:!0,className:`la:h-8 la:w-24 la:tabular-nums`,value:s.toTime,onChange:e=>c({...s,toTime:e.target.value}),"aria-invalid":l||void 0})]}),(0,B.jsx)(Bn,{type:`submit`,variant:`outline`,size:`sm`,className:`la:ml-auto`,disabled:!s.dates?.from,children:`Apply range`})]}),l&&(0,B.jsx)(`p`,{className:`la:px-3 la:pb-3 la:text-xs la:text-danger`,role:`alert`,children:`From must be before To.`})]})]})]})}function np({label:e,selected:t,onSelect:n}){return(0,B.jsx)(Bn,{type:`button`,variant:t?`secondary`:`ghost`,size:`sm`,className:`la:justify-start la:font-normal la:aria-pressed:font-semibold`,"aria-pressed":t,onClick:n,children:e})}function rp(e){let t=Date.now(),n=Xf(e,t),r=new Date(n.fromMs??t-36e5),i=new Date(n.toMs??t);return{dates:{from:ap(r),to:ap(i)},fromTime:op(r),toTime:op(i)}}function ip(e){let t=e.dates?.from,n=e.dates?.to??t;if(!t||!n)return null;let r=sp(t,e.fromTime),i=sp(n,e.toTime);return Number.isFinite(r)&&Number.isFinite(i)&&r<i?{kind:`absolute`,fromMs:r,toMs:i}:null}function ap(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function op(e){return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}function sp(e,t){let[n,r]=t.split(`:`).map(Number);return new Date(e.getFullYear(),e.getMonth(),e.getDate(),n??0,r??0).getTime()}var cp=ot(`la:inline-flex la:items-center la:justify-center la:gap-1.5 la:rounded-md la:border la:px-2 la:py-0.5 la:text-xs la:font-medium la:whitespace-nowrap`,{variants:{variant:{default:`la:border-transparent la:bg-muted la:text-muted-foreground`,outline:`la:border-border la:text-muted-foreground`}},defaultVariants:{variant:`default`}});function lp({className:e,variant:t,...n}){return(0,B.jsx)(`span`,{"data-slot":`badge`,className:z(cp({variant:t}),e),...n})}var up=Object.defineProperty,dp=(e,t)=>up(e,`name`,{value:t,configurable:!0}),fp=`Dialog`,[pp,mp]=is(fp),[hp,gp]=pp(fp),_p=dp(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=O.useRef(null),c=O.useRef(null),[l,u]=Q({prop:r,defaultProp:i??!1,onChange:a,caller:fp}),[d,f]=O.useState(0),[p,m]=O.useState(0);return(0,B.jsx)(hp,{scope:t,triggerRef:s,contentRef:c,contentId:rc(),titleId:rc(),descriptionId:rc(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:O.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),vp=`DialogPortal`,[yp,bp]=pp(vp,{forceMount:void 0}),xp=dp(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=gp(vp,t);return(0,B.jsx)(yp,{scope:t,forceMount:n,children:O.Children.map(r,e=>(0,B.jsx)(Vu,{present:n||a.open,children:(0,B.jsx)(Lu,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Sp=`DialogOverlay`,Cp=O.forwardRef(dp(function(e,t){let n=bp(Sp,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=gp(Sp,e.__scopeDialog);return a.modal?(0,B.jsx)(Vu,{present:r||a.open,children:(0,B.jsx)(Tp,{...i,ref:t})}):null},`DialogOverlay`)),wp=He(`DialogOverlay.RemoveScroll`),Tp=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,...r}=e,i=gp(Sp,n),a=ze(t,Ss());return(0,B.jsx)(yf,{as:wp,allowPinchZoom:!0,shards:[i.contentRef],children:(0,B.jsx)(ls.div,{"data-state":Lp(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Ep=`DialogContent`,Dp=O.forwardRef(dp(function(e,t){let n=bp(Ep,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=gp(Ep,e.__scopeDialog);return(0,B.jsx)(Vu,{present:r||a.open,children:a.modal?(0,B.jsx)(Op,{...i,ref:t}):(0,B.jsx)(kp,{...i,ref:t})})},`DialogContent`)),Op=O.forwardRef(dp(function(e,t){let n=gp(Ep,e.__scopeDialog),r=O.useRef(null),i=ze(t,n.contentRef,r);return O.useEffect(()=>{let e=r.current;if(e)return ud(e)},[]),(0,B.jsx)(Ap,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Xo(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Xo(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Xo(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),kp=O.forwardRef(dp(function(e,t){let n=gp(Ep,e.__scopeDialog),r=O.useRef(!1),i=O.useRef(!1);return(0,B.jsx)(Ap,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Ap=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=gp(Ep,n);return Ns(),(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(Bs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,B.jsx)(xs,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Lp(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),jp=`DialogTitle`,Mp=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,...r}=e,i=gp(jp,n),{setTitleCount:a}=i;return Qs(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,B.jsx)(ls.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Np=`DialogDescription`,Pp=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,...r}=e,i=gp(Np,n),{setDescriptionCount:a}=i;return Qs(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,B.jsx)(ls.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Fp=`DialogClose`,Ip=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,...r}=e,i=gp(Fp,n);return(0,B.jsx)(ls.button,{type:`button`,...r,ref:t,onClick:Xo(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Lp(e){return e?`open`:`closed`}dp(Lp,`getState`);var Rp=_p,zp=Mp,Bp=Pp;function Vp({className:e,children:t,container:n,...r}){return(0,B.jsxs)(xp,{container:n,children:[(0,B.jsx)(Cp,{className:`la-sheet-overlay`}),(0,B.jsxs)(Dp,{"data-slot":`sheet-content`,className:z(`la-observer la-sheet`,e),...r,children:[t,(0,B.jsx)(Ip,{asChild:!0,children:(0,B.jsx)(Bn,{className:`la-sheet-close`,variant:`ghost`,size:`icon`,"aria-label":`Close`,children:(0,B.jsx)(Ne,{"aria-hidden":`true`})})})]})]})}function Hp({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`table-container`,className:`la:relative la:w-full la:overflow-x-auto`,children:(0,B.jsx)(`table`,{"data-slot":`table`,className:z(`la:w-full la:caption-bottom la:text-sm la:tabular-nums`,e),...t})})}function Up({className:e,...t}){return(0,B.jsx)(`thead`,{"data-slot":`table-header`,className:z(`la:[&_tr]:border-b`,e),...t})}function Wp({className:e,...t}){return(0,B.jsx)(`tbody`,{"data-slot":`table-body`,className:z(`la:[&_tr:last-child]:border-0`,e),...t})}function Gp({className:e,...t}){return(0,B.jsx)(`tr`,{"data-slot":`table-row`,className:z(`la:border-b la:transition-colors la:duration-150 la:hover:bg-muted/60 la:data-[state=selected]:bg-muted`,e),...t})}function Kp({className:e,...t}){return(0,B.jsx)(`th`,{"data-slot":`table-head`,className:z(`la:h-10 la:whitespace-nowrap la:px-3 la:text-left la:align-middle la:text-xs la:font-medium la:text-muted-foreground la:[&:has([role=checkbox])]:pr-0 la:[&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function qp({className:e,...t}){return(0,B.jsx)(`td`,{"data-slot":`table-cell`,className:z(`la:whitespace-nowrap la:px-3 la:py-2.5 la:align-middle la:[&:has([role=checkbox])]:pr-0 la:[&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Jp(e){let[t,n]=(0,O.useState)(0),[r,i]=(0,O.useState)(),[a,o]=(0,O.useState)(!0),[s,c]=(0,O.useState)(!1);return(0,O.useEffect)(()=>{let t=new AbortController,n,r=1e3;return c(!1),o(!0),s(),()=>{t.abort(),clearTimeout(n)};function a(n){t.signal.aborted||(i({client:e,inventory:n,updatedAt:Date.now()}),c(!1),o(!1),r=1e3)}async function s(){try{if(e.watchActors){if(await e.watchActors(a,t.signal),!t.signal.aborted)throw Error(`Stream ended`)}else o(!0),a(await e.listActors(t.signal))}catch{t.signal.aborted||c(!0)}finally{t.signal.aborted||(o(!1),n=setTimeout(s,e.watchActors?r:5e3),r=Math.min(r*2,1e4))}}},[e,t]),{updatedAt:r?.client===e?r.updatedAt:void 0,inventory:r?.client===e?r.inventory:void 0,loading:a,failed:s,retry:()=>n(e=>e+1)}}function Yp(e,t=!0){let[n,r]=(0,O.useState)(),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(0);return(0,O.useEffect)(()=>r(void 0),[e]),(0,O.useEffect)(()=>{if(!t)return;let n,i=new AbortController,o,s=1e3;async function c(){try{if(!e.watchRequests)throw Error(`Request traces unavailable`);if(await e.watchRequests(e=>{i.signal.aborted||(n=e.resumeCursor,r(t=>Xp(t,e)),a(!1),s=1e3)},i.signal,n),!i.signal.aborted)throw Error(`Request stream disconnected`)}catch{i.signal.aborted||a(!0)}finally{i.signal.aborted||(o=setTimeout(c,s),s=Math.min(s*2,1e4))}}return a(!1),c(),()=>{i.abort(),clearTimeout(o)}},[e,o,t]),{page:n,failed:i,retry:()=>s(e=>e+1)}}function Xp(e,t){let n=new Map((e?.epoch===t.epoch&&!t.reset?e.records:[]).map(e=>[e.eventId??e.sequence,e]));for(let e of t.records)n.set(e.eventId??e.sequence,e);return{...t,reset:t.reset||e?.epoch===t.epoch&&e.reset,records:[...n.values()].sort((e,t)=>t.sequence-e.sequence).slice(0,t.capacity)}}function Zp(e,t,n,r=1e4){let i=t&&e.query?JSON.stringify(t):void 0,a=(0,O.useRef)(n);a.current=n;let[o,s]=(0,O.useState)(0),[c,l]=(0,O.useState)(),[u,d]=(0,O.useState)(!1),[f,p]=(0,O.useState)(!1);(0,O.useEffect)(()=>{if(!i)return;let t=new AbortController,n;return d(!1),p(!0),o(),()=>{t.abort(),clearTimeout(n)};async function o(){try{let n=a.current(await e.query(JSON.parse(i),t.signal));if(t.signal.aborted)return;l({client:e.query,key:i,value:n,updatedAt:Date.now()}),d(!1)}catch{t.signal.aborted||d(!0)}finally{t.signal.aborted||(p(!1),n=setTimeout(o,r))}}},[e,i,o,r]);let m=c&&c.client===e.query&&c.key===i?c:void 0;return{supported:!!e.query,value:m?.value,updatedAt:m?.updatedAt,loading:f,failed:u,retry:()=>s(e=>e+1)}}var Qp=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},$p=10,em=13,tm=32,nm=6;function rm(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{maxBufferSize:t,onComment:n,onError:r,onEvent:i,onId:a,onRetry:o}=e,s=[],c=0,l=``,u,d=``,f=0,p,m=!1,h=!1,g=!1;function _(e){if(m)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l!==void 0){if(e=l+e,e===``||e===`ï`||e===`ï»`){l=e;return}l=void 0,e=e.replace(/^(?:\uFEFF|\xEF\xBB\xBF)/,``)}if((h||g)&&(e=v(e),!e))return;if(!s.length){let t=S(e);t!==``&&y(t),x();return}if(e.indexOf(`
|
|
50
|
-
`)===-1&&e.indexOf(`\r`)===-1){if(c<
|
|
51
|
-
`),r=t===-1?n:n===-1||t<n?t:n;return r===-1?``:r===e.length-1&&e.charCodeAt(r)===
|
|
49
|
+
`},mf=0,hf=[];function gf(e){var t=O.useRef([]),n=O.useRef([0,0]),r=O.useRef(),i=O.useState(mf++)[0],a=O.useState(Ld)[0],o=O.useRef(e);O.useEffect(function(){o.current=e},[e]),O.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=pd([e.lockRef.current],(e.shards||[]).map(df),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=O.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=lf(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=tf(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=tf(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return cf(h,t,e,h===`h`?s:c,!0)},[]),c=O.useCallback(function(e){var n=e;if(hf.length&&hf[hf.length-1]===a){var r=`deltaY`in n?uf(n):lf(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&ff(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(df).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=O.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:_f(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=O.useCallback(function(e){n.current=lf(e),r.current=void 0},[]),d=O.useCallback(function(t){l(t.type,uf(t),t.target,s(t,e.lockRef.current))},[]),f=O.useCallback(function(t){l(t.type,lf(t),t.target,s(t,e.lockRef.current))},[]);O.useEffect(function(){return hf.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Xd),document.addEventListener(`touchmove`,c,Xd),document.addEventListener(`touchstart`,u,Xd),function(){hf=hf.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Xd),document.removeEventListener(`touchmove`,c,Xd),document.removeEventListener(`touchstart`,u,Xd)}},[]);var p=e.removeScrollBar,m=e.inert;return O.createElement(O.Fragment,null,m?O.createElement(a,{styles:pf(i)}):null,p?O.createElement(qd,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function _f(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var vf=Dd(Od,gf),yf=O.forwardRef(function(e,t){return O.createElement(Ad,dd({},e,{ref:t,sideCar:vf}))});yf.classNames=Ad.classNames;var bf=Object.defineProperty,xf=(e,t)=>bf(e,`name`,{value:t,configurable:!0}),Sf=`Popover`,[Cf,wf]=is(Sf,[bu]),Tf=bu(),[Ef,Df]=Cf(Sf),Of=xf(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Tf(t),c=O.useRef(null),[l,u]=O.useState(!1),[d,f]=Q({prop:r,defaultProp:i??!1,onChange:a,caller:Sf});return(0,B.jsx)(Nu,{...s,children:(0,B.jsx)(Ef,{scope:t,contentId:rc(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:O.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:O.useCallback(()=>u(!0),[]),onCustomAnchorRemove:O.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),kf=`PopoverTrigger`,Af=O.forwardRef(xf(function(e,t){let{__scopePopover:n,...r}=e,i=Df(kf,n),a=Tf(n),o=ze(t,i.triggerRef),s=(0,B.jsx)(ls.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":$(i.open),...r,ref:o,onClick:Xo(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,B.jsx)(Pu,{asChild:!0,...a,children:s})},`PopoverTrigger`)),jf=`PopoverPortal`,[Mf,Nf]=Cf(jf,{forceMount:void 0}),Pf=xf(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Df(jf,t);return(0,B.jsx)(Mf,{scope:t,forceMount:n,children:(0,B.jsx)(Vu,{present:n||a.open,children:(0,B.jsx)(Lu,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),Ff=`PopoverContent`,If=O.forwardRef(xf(function(e,t){let n=Nf(Ff,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Df(Ff,e.__scopePopover);return(0,B.jsx)(Vu,{present:r||a.open,children:a.modal?(0,B.jsx)(Rf,{...i,ref:t}):(0,B.jsx)(zf,{...i,ref:t})})},`PopoverContent`)),Lf=He(`PopoverContent.RemoveScroll`),Rf=O.forwardRef(xf(function(e,t){let n=Df(Ff,e.__scopePopover),r=O.useRef(null),i=ze(t,r),a=O.useRef(!1);return O.useEffect(()=>{let e=r.current;if(e)return ud(e)},[]),(0,B.jsx)(yf,{as:Lf,allowPinchZoom:!0,children:(0,B.jsx)(Bf,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Xo(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Xo(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:Xo(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),zf=O.forwardRef(xf(function(e,t){let n=Df(Ff,e.__scopePopover),r=O.useRef(!1),i=O.useRef(!1);return(0,B.jsx)(Bf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),Bf=O.forwardRef(xf(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Df(Ff,n),p=Tf(n);return Ns(),(0,B.jsx)(Bs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,B.jsx)(xs,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,B.jsx)(Fu,{"data-state":$(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function $(e){return e?`open`:`closed`}xf($,`getState`);var Vf=Of,Hf=Af,Uf=Pf,Wf=If;function Gf({...e}){return(0,B.jsx)(Vf,{"data-slot":`popover`,...e})}function Kf({...e}){return(0,B.jsx)(Hf,{"data-slot":`popover-trigger`,...e})}function qf({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,B.jsx)(Uf,{children:(0,B.jsx)(Wf,{"data-slot":`popover-content`,align:t,sideOffset:n,className:z(`la:z-50 la:w-72 la:origin-(--radix-popover-content-transform-origin) la:rounded-md la:border la:bg-popover la:p-4 la:text-popover-foreground la:shadow-md la:outline-hidden`,e),...r})})}var Jf=[{minutes:5,label:`Last 5 minutes`},{minutes:15,label:`Last 15 minutes`},{minutes:60,label:`Last hour`},{minutes:360,label:`Last 6 hours`},{minutes:1440,label:`Last 24 hours`},{minutes:10080,label:`Last 7 days`}],Yf={kind:`relative`,minutes:60};function Xf(e,t){switch(e.kind){case`relative`:return{fromMs:Math.floor((t-e.minutes*6e4)/6e4)*6e4};case`absolute`:return{fromMs:e.fromMs,toMs:e.toMs};case`all`:return{}}}function Zf(e){switch(e.kind){case`relative`:return Jf.find(t=>t.minutes===e.minutes)?.label??`Last ${e.minutes} minutes`;case`absolute`:return`${ep(e.fromMs,e.toMs)} – ${ep(e.toMs,e.fromMs)}`;case`all`:return`All retained`}}function Qf(e){switch(e.kind){case`relative`:return`in the ${Zf(e).toLocaleLowerCase()}`;case`absolute`:return`between ${Zf(e)}`;case`all`:return`in retained history`}}function $f(e,t){return e.kind===t.kind&&(e.kind!==`relative`||e.minutes===t.minutes)&&(e.kind!==`absolute`||e.fromMs===t.fromMs&&e.toMs===t.toMs)}function ep(e,t){let n=new Date(e),r=n.toDateString()===new Date(t).toDateString(),i=n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1});return r&&e>t?i:`${n.toLocaleDateString([],{month:`short`,day:`numeric`})} ${i}`}function tp({value:e,onChange:t,allowAll:n=!0,className:r,align:i=`end`}){let[a,o]=(0,O.useState)(!1),[s,c]=(0,O.useState)(()=>rp(e)),[l,u]=(0,O.useState)(!1),d=e=>{t(e),o(!1)};return(0,B.jsxs)(Gf,{open:a,onOpenChange:t=>{t&&(c(rp(e)),u(!1)),o(t)},children:[(0,B.jsx)(Kf,{asChild:!0,children:(0,B.jsxs)(Bn,{type:`button`,variant:`outline`,className:r,"aria-label":`Time range: ${Zf(e)}`,children:[(0,B.jsx)(le,{"aria-hidden":`true`}),(0,B.jsx)(`span`,{className:`la:truncate la:tabular-nums`,children:Zf(e)}),(0,B.jsx)(de,{"aria-hidden":`true`,className:`la:text-muted-foreground`})]})}),(0,B.jsxs)(qf,{align:i,"aria-label":`Time range`,className:`la:flex la:w-auto la:p-0 la:text-sm`,children:[(0,B.jsxs)(`div`,{className:`la:flex la:flex-col la:gap-0.5 la:border-r la:p-2`,role:`group`,"aria-label":`Preset ranges`,children:[Jf.map(t=>(0,B.jsx)(np,{label:t.label,selected:$f(e,{kind:`relative`,minutes:t.minutes}),onSelect:()=>d({kind:`relative`,minutes:t.minutes})},t.minutes)),n&&(0,B.jsx)(np,{label:`All retained`,selected:e.kind===`all`,onSelect:()=>d({kind:`all`})})]}),(0,B.jsxs)(`form`,{className:`la:flex la:w-[22rem] la:flex-col`,"aria-label":`Custom range`,onSubmit:e=>{e.preventDefault();let t=ip(s);if(!t){u(!0);return}u(!1),d(t)},children:[(0,B.jsx)(Wo,{mode:`range`,numberOfMonths:1,defaultMonth:s.dates?.to??s.dates?.from,selected:s.dates,onSelect:e=>c(t=>({...t,dates:e})),disabled:{after:new Date}}),(0,B.jsxs)(`div`,{className:`la:flex la:items-end la:gap-2 la:border-t la:px-3 la:py-3`,children:[(0,B.jsxs)(`label`,{className:`la:grid la:gap-1 la:text-xs la:text-muted-foreground`,children:[`From`,(0,B.jsx)(Ko,{type:`time`,name:`from`,required:!0,className:`la:h-8 la:w-24 la:tabular-nums`,value:s.fromTime,onChange:e=>c({...s,fromTime:e.target.value}),"aria-invalid":l||void 0})]}),(0,B.jsxs)(`label`,{className:`la:grid la:gap-1 la:text-xs la:text-muted-foreground`,children:[`To`,(0,B.jsx)(Ko,{type:`time`,name:`to`,required:!0,className:`la:h-8 la:w-24 la:tabular-nums`,value:s.toTime,onChange:e=>c({...s,toTime:e.target.value}),"aria-invalid":l||void 0})]}),(0,B.jsx)(Bn,{type:`submit`,variant:`outline`,size:`sm`,className:`la:ml-auto`,disabled:!s.dates?.from,children:`Apply range`})]}),l&&(0,B.jsx)(`p`,{className:`la:px-3 la:pb-3 la:text-xs la:text-danger`,role:`alert`,children:`From must be before To.`})]})]})]})}function np({label:e,selected:t,onSelect:n}){return(0,B.jsx)(Bn,{type:`button`,variant:t?`secondary`:`ghost`,size:`sm`,className:`la:justify-start la:font-normal la:aria-pressed:font-semibold`,"aria-pressed":t,onClick:n,children:e})}function rp(e){let t=Date.now(),n=Xf(e,t),r=new Date(n.fromMs??t-36e5),i=new Date(n.toMs??t);return{dates:{from:ap(r),to:ap(i)},fromTime:op(r),toTime:op(i)}}function ip(e){let t=e.dates?.from,n=e.dates?.to??t;if(!t||!n)return null;let r=sp(t,e.fromTime),i=sp(n,e.toTime);return Number.isFinite(r)&&Number.isFinite(i)&&r<i?{kind:`absolute`,fromMs:r,toMs:i}:null}function ap(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function op(e){return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}function sp(e,t){let[n,r]=t.split(`:`).map(Number);return new Date(e.getFullYear(),e.getMonth(),e.getDate(),n??0,r??0).getTime()}var cp=ot(`la:inline-flex la:items-center la:justify-center la:gap-1.5 la:rounded-md la:border la:px-2 la:py-0.5 la:text-xs la:font-medium la:whitespace-nowrap`,{variants:{variant:{default:`la:border-transparent la:bg-muted la:text-muted-foreground`,outline:`la:border-border la:text-muted-foreground`}},defaultVariants:{variant:`default`}});function lp({className:e,variant:t,...n}){return(0,B.jsx)(`span`,{"data-slot":`badge`,className:z(cp({variant:t}),e),...n})}var up=Object.defineProperty,dp=(e,t)=>up(e,`name`,{value:t,configurable:!0}),fp=`Dialog`,[pp,mp]=is(fp),[hp,gp]=pp(fp),_p=dp(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=O.useRef(null),c=O.useRef(null),[l,u]=Q({prop:r,defaultProp:i??!1,onChange:a,caller:fp}),[d,f]=O.useState(0),[p,m]=O.useState(0);return(0,B.jsx)(hp,{scope:t,triggerRef:s,contentRef:c,contentId:rc(),titleId:rc(),descriptionId:rc(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:O.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),vp=`DialogPortal`,[yp,bp]=pp(vp,{forceMount:void 0}),xp=dp(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=gp(vp,t);return(0,B.jsx)(yp,{scope:t,forceMount:n,children:O.Children.map(r,e=>(0,B.jsx)(Vu,{present:n||a.open,children:(0,B.jsx)(Lu,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Sp=`DialogOverlay`,Cp=O.forwardRef(dp(function(e,t){let n=bp(Sp,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=gp(Sp,e.__scopeDialog);return a.modal?(0,B.jsx)(Vu,{present:r||a.open,children:(0,B.jsx)(Tp,{...i,ref:t})}):null},`DialogOverlay`)),wp=He(`DialogOverlay.RemoveScroll`),Tp=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,...r}=e,i=gp(Sp,n),a=ze(t,Ss());return(0,B.jsx)(yf,{as:wp,allowPinchZoom:!0,shards:[i.contentRef],children:(0,B.jsx)(ls.div,{"data-state":Lp(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Ep=`DialogContent`,Dp=O.forwardRef(dp(function(e,t){let n=bp(Ep,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=gp(Ep,e.__scopeDialog);return(0,B.jsx)(Vu,{present:r||a.open,children:a.modal?(0,B.jsx)(Op,{...i,ref:t}):(0,B.jsx)(kp,{...i,ref:t})})},`DialogContent`)),Op=O.forwardRef(dp(function(e,t){let n=gp(Ep,e.__scopeDialog),r=O.useRef(null),i=ze(t,n.contentRef,r);return O.useEffect(()=>{let e=r.current;if(e)return ud(e)},[]),(0,B.jsx)(Ap,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Xo(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Xo(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Xo(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),kp=O.forwardRef(dp(function(e,t){let n=gp(Ep,e.__scopeDialog),r=O.useRef(!1),i=O.useRef(!1);return(0,B.jsx)(Ap,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Ap=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=gp(Ep,n);return Ns(),(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(Bs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,B.jsx)(xs,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Lp(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),jp=`DialogTitle`,Mp=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,...r}=e,i=gp(jp,n),{setTitleCount:a}=i;return Qs(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,B.jsx)(ls.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Np=`DialogDescription`,Pp=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,...r}=e,i=gp(Np,n),{setDescriptionCount:a}=i;return Qs(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,B.jsx)(ls.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Fp=`DialogClose`,Ip=O.forwardRef(dp(function(e,t){let{__scopeDialog:n,...r}=e,i=gp(Fp,n);return(0,B.jsx)(ls.button,{type:`button`,...r,ref:t,onClick:Xo(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Lp(e){return e?`open`:`closed`}dp(Lp,`getState`);var Rp=_p,zp=Mp,Bp=Pp;function Vp({className:e,children:t,container:n,...r}){return(0,B.jsxs)(xp,{container:n,children:[(0,B.jsx)(Cp,{className:`la-sheet-overlay`}),(0,B.jsxs)(Dp,{"data-slot":`sheet-content`,className:z(`la-observer la-sheet`,e),...r,children:[t,(0,B.jsx)(Ip,{asChild:!0,children:(0,B.jsx)(Bn,{className:`la-sheet-close`,variant:`ghost`,size:`icon`,"aria-label":`Close`,children:(0,B.jsx)(Ne,{"aria-hidden":`true`})})})]})]})}function Hp({className:e,...t}){return(0,B.jsx)(`div`,{"data-slot":`table-container`,className:`la:relative la:w-full la:overflow-x-auto`,children:(0,B.jsx)(`table`,{"data-slot":`table`,className:z(`la:w-full la:caption-bottom la:text-sm la:tabular-nums`,e),...t})})}function Up({className:e,...t}){return(0,B.jsx)(`thead`,{"data-slot":`table-header`,className:z(`la:[&_tr]:border-b`,e),...t})}function Wp({className:e,...t}){return(0,B.jsx)(`tbody`,{"data-slot":`table-body`,className:z(`la:[&_tr:last-child]:border-0`,e),...t})}function Gp({className:e,...t}){return(0,B.jsx)(`tr`,{"data-slot":`table-row`,className:z(`la:border-b la:transition-colors la:duration-150 la:hover:bg-muted/60 la:data-[state=selected]:bg-muted`,e),...t})}function Kp({className:e,...t}){return(0,B.jsx)(`th`,{"data-slot":`table-head`,className:z(`la:h-10 la:whitespace-nowrap la:px-3 la:text-left la:align-middle la:text-xs la:font-medium la:text-muted-foreground la:[&:has([role=checkbox])]:pr-0 la:[&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function qp({className:e,...t}){return(0,B.jsx)(`td`,{"data-slot":`table-cell`,className:z(`la:whitespace-nowrap la:px-3 la:py-2.5 la:align-middle la:[&:has([role=checkbox])]:pr-0 la:[&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function Jp(e){let[t,n]=(0,O.useState)(0),[r,i]=(0,O.useState)(),[a,o]=(0,O.useState)(!0),[s,c]=(0,O.useState)(!1);return(0,O.useEffect)(()=>{let t=new AbortController,n,r=1e3;return c(!1),o(!0),s(),()=>{t.abort(),clearTimeout(n)};function a(n){t.signal.aborted||(i({client:e,inventory:n,updatedAt:Date.now()}),c(!1),o(!1),r=1e3)}async function s(){try{if(e.watchActors){if(await e.watchActors(a,t.signal),!t.signal.aborted)throw Error(`Stream ended`)}else o(!0),a(await e.listActors(t.signal))}catch{t.signal.aborted||c(!0)}finally{t.signal.aborted||(o(!1),n=setTimeout(s,e.watchActors?r:5e3),r=Math.min(r*2,1e4))}}},[e,t]),{updatedAt:r?.client===e?r.updatedAt:void 0,inventory:r?.client===e?r.inventory:void 0,loading:a,failed:s,retry:()=>n(e=>e+1)}}function Yp(e,t=!0){let[n,r]=(0,O.useState)(),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(0);return(0,O.useEffect)(()=>r(void 0),[e]),(0,O.useEffect)(()=>{if(!t)return;let n,i=new AbortController,o,s=1e3;async function c(){try{if(!e.watchRequests)throw Error(`Request traces unavailable`);if(await e.watchRequests(e=>{i.signal.aborted||(n=e.resumeCursor,r(t=>Xp(t,e)),a(!1),s=1e3)},i.signal,n),!i.signal.aborted)throw Error(`Request stream disconnected`)}catch{i.signal.aborted||a(!0)}finally{i.signal.aborted||(o=setTimeout(c,s),s=Math.min(s*2,1e4))}}return a(!1),c(),()=>{i.abort(),clearTimeout(o)}},[e,o,t]),{page:n,failed:i,retry:()=>s(e=>e+1)}}function Xp(e,t){let n=new Map((e?.epoch===t.epoch&&!t.reset?e.records:[]).map(e=>[e.eventId??e.sequence,e]));for(let e of t.records)n.set(e.eventId??e.sequence,e);return{...t,reset:t.reset||e?.epoch===t.epoch&&e.reset,records:[...n.values()].sort((e,t)=>t.sequence-e.sequence).slice(0,t.capacity)}}function Zp(e,t,n,r=1e4){let i=n?JSON.stringify(t):void 0,[a,o]=(0,O.useState)(0),[s,c]=(0,O.useState)(),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(!1);(0,O.useEffect)(()=>{if(!i)return;let t=new AbortController,a;return u(!1),f(!0),o(),()=>{t.abort(),clearTimeout(a)};async function o(){try{let r=await n.call(e,JSON.parse(i),t.signal);if(t.signal.aborted)return;c({client:e,key:i,value:r,updatedAt:Date.now()}),u(!1)}catch{t.signal.aborted||u(!0)}finally{t.signal.aborted||(f(!1),a=setTimeout(o,r))}}},[e,n,i,a,r]);let p=s&&s.client===e&&s.key===i?s:void 0;return{supported:!!n,value:p?.value,updatedAt:p?.updatedAt,loading:d,failed:l,retry:()=>o(e=>e+1)}}function Qp(e,t){let[n,r]=(0,O.useState)(),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(!1),c=(0,O.useRef)(()=>{});return(0,O.useEffect)(()=>{if(r(void 0),s(!1),a(!1),!t)return;let n=new AbortController,i=!1;c.current=e=>{i||n.signal.aborted||(i=!0,a(!0),s(!1),o(e))};async function o(o){try{if(!e.listRequests)throw Error(`History is unavailable`);let i=await e.listRequests({...t,cursor:o},n.signal);if(n.signal.aborted)return;r(e=>{if(!o||!e||i.reset||e.epoch!==i.epoch)return i;let t=new Map(e.records.map(e=>[e.eventId??e.sequence,e]));for(let e of i.records)t.set(e.eventId??e.sequence,e);return{...i,reset:e.reset||i.reset,records:[...t.values()]}})}catch{n.signal.aborted||s(!0)}finally{i=!1,n.signal.aborted||a(!1)}}return c.current(),()=>n.abort()},[e,t]),{page:n,loading:i,failed:o,loadOlder:()=>c.current(n?.nextCursor??void 0),retry:()=>c.current(n?.nextCursor??void 0)}}function $p({client:e,actor:t,timeRange:n,onTimeRangeChange:r}){let[i,a]=(0,O.useState)(),[o,s]=(0,O.useState)(Yf),c=n??o,l=r??s,u=Qp(e,(0,O.useMemo)(()=>i?{...i,...t,...Xf(c,Date.now())}:void 0,[i,t?.actorName,t?.actorId,c])),{page:d,failed:f,retry:p}=Yp(e),[m,h]=(0,O.useState)(),[g,_]=(0,O.useState)(),v=(0,O.useRef)(null),y=(0,O.useRef)(null),b=t?`h3`:`h1`,x=i?u.page:m??d,S=d??u.page,C=(x?.records??[]).filter(e=>!t||e.actorName===t.actorName&&e.actorId===t.actorId);return(0,O.useEffect)(()=>{h(void 0),a(void 0)},[e,t?.actorName,t?.actorId]),(0,O.useEffect)(()=>_(void 0),[e,d?.epoch,i,t?.actorName,t?.actorId]),(0,B.jsxs)(`section`,{ref:v,className:`la-observer la-requests`,"aria-label":`Request observer`,children:[(0,B.jsxs)(`div`,{className:`la-observer-toolbar`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(b,{children:`Requests`}),(0,B.jsx)(`p`,{children:t?`Method calls and WebSocket events for this instance.`:`Method calls and WebSocket events, with time spent waiting and processing.`})]}),(0,B.jsxs)(`div`,{className:`la-request-actions`,children:[e.listRequests&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Bn,{variant:i?`outline`:`secondary`,"aria-pressed":!i,onClick:()=>{a(void 0),h(void 0)},children:`Live`}),(0,B.jsx)(Bn,{variant:i?`secondary`:`outline`,"aria-pressed":!!i,onClick:()=>{i||a({})},children:`History`})]}),!i&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Bn,{variant:`outline`,disabled:!x,onClick:()=>h(m?void 0:d),children:[m?(0,B.jsx)(Ce,{"aria-hidden":`true`}):(0,B.jsx)(xe,{"aria-hidden":`true`}),m?`Resume`:`Pause`]}),f&&(0,B.jsxs)(Bn,{variant:`outline`,onClick:p,children:[(0,B.jsx)(Te,{"aria-hidden":`true`}),`Retry`]})]})]})]}),i&&(0,B.jsx)(em,{query:i,range:c,onRangeChange:l,loading:u.loading,onSearch:a,scoped:!!t}),i&&u.failed&&(0,B.jsxs)(`div`,{className:`la-observer-error`,role:`alert`,children:[`Request history unavailable.`,` `,(0,B.jsx)(Bn,{variant:`outline`,onClick:u.retry,children:`Retry history`})]}),!i&&f&&(0,B.jsxs)(`div`,{className:`la-observer-error`,role:`alert`,children:[`Request stream disconnected. Reconnecting… `,d?`Showing the last received requests.`:`Check your connection and runtime version.`]}),!!S?.dropped&&(0,B.jsxs)(`div`,{className:`la-observer-error`,role:`alert`,children:[S.dropped.toLocaleString(),` request traces were not delivered. This history is incomplete.`]}),S?.persistenceFailed&&(0,B.jsx)(`div`,{className:`la-observer-error`,role:`alert`,children:`Some request events could not be saved. This history may be incomplete.`}),x?.reset&&(0,B.jsx)(`div`,{className:`la-observer-error`,role:`alert`,children:`Some older events are no longer retained. Showing available history.`}),(0,B.jsxs)(`div`,{className:`la-observer-table-frame`,children:[(0,B.jsxs)(Hp,{"aria-label":i?`Saved requests`:`Recent requests`,className:`la-request-table`,children:[(0,B.jsx)(Up,{children:(0,B.jsxs)(Gp,{children:[(0,B.jsx)(Kp,{scope:`col`,children:`Time`}),(0,B.jsx)(Kp,{scope:`col`,children:`Request`}),(0,B.jsx)(Kp,{scope:`col`,children:`Instance`}),(0,B.jsx)(Kp,{scope:`col`,children:`Transport`}),(0,B.jsx)(Kp,{scope:`col`,children:`Outcome`}),(0,B.jsx)(Kp,{scope:`col`,children:`Total`}),(0,B.jsx)(Kp,{scope:`col`,children:`Queue wait`}),(0,B.jsx)(Kp,{scope:`col`,children:(0,B.jsx)(`span`,{className:`la:sr-only`,children:`Details`})})]})}),(0,B.jsx)(Wp,{children:C.map(e=>(0,B.jsxs)(Gp,{className:`la-clickable-row`,"data-state":g===e?`selected`:void 0,onClick:t=>{y.current=t.currentTarget.querySelector(`button`),_(e)},children:[(0,B.jsx)(qp,{children:(0,B.jsx)(`time`,{dateTime:new Date(e.startedAtMs).toISOString(),title:new Date(e.startedAtMs).toLocaleString(),children:i?new Date(e.startedAtMs).toLocaleString([],{hour12:!1}):new Date(e.startedAtMs).toLocaleTimeString([],{hour12:!1})})}),(0,B.jsx)(qp,{children:(0,B.jsx)(`span`,{className:`la-request-operation`,title:e.operation,children:e.operation})}),(0,B.jsx)(qp,{children:(0,B.jsxs)(`span`,{className:`la-request-actor`,title:`${e.actorName} / ${e.actorId}`,children:[e.actorName,` / `,e.actorId]})}),(0,B.jsx)(qp,{children:e.kind===`method`?`Method`:`WebSocket`}),(0,B.jsx)(qp,{children:(0,B.jsx)(lp,{variant:`outline`,className:`la-request-outcome-${e.outcome}`,children:e.outcome[0].toUpperCase()+e.outcome.slice(1)})}),(0,B.jsx)(qp,{children:nm(e.durationMs)}),(0,B.jsx)(qp,{children:e.queueWaitMs===null?(0,B.jsx)(`span`,{title:`Request did not begin processing`,children:`—`}):nm(e.queueWaitMs)}),(0,B.jsx)(qp,{children:(0,B.jsx)(Bn,{variant:`ghost`,size:`sm`,"aria-label":`Inspect ${e.operation} request`,"aria-haspopup":`dialog`,children:`Details`})})]},e.eventId??`${x.epoch}-${e.sequence}`))})]}),!C.length&&(0,B.jsxs)(`div`,{className:`la-request-empty`,role:`status`,children:[(0,B.jsx)(`strong`,{children:i?u.loading?`Loading history…`:u.failed?`History unavailable`:`No saved requests in this range`:x?`No requests yet`:f?`Requests unavailable`:`Connecting to requests…`}),(0,B.jsx)(`p`,{children:i?`Try a wider time range or fewer filters. Local history retains the latest 10,000 events.`:`Call an actor method or send a WebSocket message to see its timings.`})]})]}),i&&x?.nextCursor&&(0,B.jsx)(Bn,{className:`la-request-load-older`,variant:`outline`,disabled:u.loading,onClick:u.loadOlder,children:u.loading?`Loading…`:`Load older`}),(0,B.jsxs)(`div`,{className:`la-observer-footnote`,children:[(0,B.jsxs)(`span`,{className:`la-observer-refresh-status`,children:[!i&&(0,B.jsx)(`span`,{className:`la-observer-dot ${f?`la-observer-dot-unknown`:`la-observer-dot-live`}`}),i?`Saved history`:m?`Display paused · collection continues`:f?`Reconnecting…`:d?`Live updates`:`Connecting…`]}),(0,B.jsx)(`span`,{children:i?`${C.length.toLocaleString()} saved requests shown`:t?`${C.length} matching requests from the latest ${x?.capacity??500} on this control plane.`:`Latest ${x?.capacity??500} requests on this control plane.`})]}),!i&&!!x?.evicted&&(0,B.jsxs)(`p`,{className:`la-request-note`,children:[x.evicted.toLocaleString(),` older records have left this history window.`]}),(0,B.jsx)(`p`,{className:`la-request-note`,children:`Total includes queue wait, actor processing, and persistence. Queue wait includes the WebSocket message queue. Timings exclude the caller’s network round trip.`}),(0,B.jsx)(Rp,{open:!!g,onOpenChange:e=>{e||_(void 0)},children:(0,B.jsxs)(Vp,{container:v.current,onCloseAutoFocus:e=>{e.preventDefault(),y.current?.focus()},children:[(0,B.jsx)(zp,{children:`Request details`}),(0,B.jsx)(Bp,{children:`Full identifiers and timings for this request.`}),g&&(0,B.jsx)(tm,{record:g})]})})]})}function em({query:e,range:t,onRangeChange:n,loading:r,onSearch:i,scoped:a}){return(0,B.jsxs)(`form`,{className:`la-request-history-filters`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget);i({actorId:String(t.get(`actorId`)||``).trim()||void 0,outcome:String(t.get(`outcome`)||``)||void 0})},children:[(0,B.jsxs)(`div`,{className:`la-request-history-range`,children:[(0,B.jsx)(`span`,{children:`Time range`}),(0,B.jsx)(tp,{value:t,onChange:n,align:`start`})]}),!a&&(0,B.jsxs)(`label`,{children:[`Actor ID`,(0,B.jsx)(Ko,{name:`actorId`,placeholder:`All actors`,maxLength:256,defaultValue:e.actorId})]}),(0,B.jsxs)(`label`,{children:[`Outcome`,(0,B.jsxs)(`select`,{className:`la-observer-select`,name:`outcome`,defaultValue:e.outcome??``,children:[(0,B.jsx)(`option`,{value:``,children:`All outcomes`}),[`completed`,`failed`,`rejected`,`rerouted`,`interrupted`].map(e=>(0,B.jsx)(`option`,{value:e,children:e[0].toUpperCase()+e.slice(1)},e))]})]}),(0,B.jsx)(Bn,{type:`submit`,variant:`outline`,disabled:r,children:`Search`})]})}function tm({record:e}){let t={Operation:e.operation,"Actor class":e.actorName,"Instance ID":e.actorId,"Request ID":e.requestId,Time:new Date(e.startedAtMs).toLocaleString(),Transport:e.kind===`method`?`Method`:`WebSocket`,Outcome:e.outcome,Total:nm(e.durationMs),"Queue wait":e.queueWaitMs===null?`Did not begin processing`:nm(e.queueWaitMs),Host:e.hostId,...e.connectionId?{Connection:e.connectionId}:{}};return(0,B.jsx)(`dl`,{className:`la-request-details`,children:Object.entries(t).map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e}),(0,B.jsx)(`dd`,{children:t})]},e))})}function nm(e){return e>=1e3?`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:2})} s`:`${e.toLocaleString(void 0,{maximumFractionDigits:1})} ms`}function rm(e,t,n){let r=Zp(e,{...t,actorName:n},e.listQueueWaits);return{supported:r.supported,rows:r.value,failed:r.failed}}function im(e){if(!Array.isArray(e)||!e.every(am))throw Error(`Invalid queue wait response`);return e}function am(e){return!!e&&typeof e.actorName==`string`&&typeof e.actorId==`string`&&Number.isSafeInteger(e.admitted)&&e.admitted>0&&[e.averageMs,e.maxMs].every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0)&&e.averageMs<=e.maxMs}function om(e){return um(e,()=>`all`).get(`all`)??null}function sm(e){return um(e,e=>e.actorName)}function cm(e,t){return um(e.filter(e=>e.actorName===t),e=>e.actorId)}function lm(e){return e===void 0?`—`:e>=1e3?`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:2})} s`:`${e.toLocaleString(void 0,{maximumFractionDigits:1})} ms`}function um(e,t){let n=new Map;for(let r of e){let e=n.get(t(r))??{admitted:0,averageMs:0,maxMs:0},i=e.admitted+r.admitted;n.set(t(r),{admitted:i,averageMs:(e.averageMs*e.admitted+r.averageMs*r.admitted)/i,maxMs:Math.max(e.maxMs,r.maxMs)})}return n}function dm({client:e,className:t=``,initialActorName:n,navigation:r,timeRange:i,onTimeRangeChange:a}){let{inventory:o,loading:s,failed:c,retry:l}=Jp(e),[u,d]=(0,O.useState)(Yf),f=i??u,p=a??d,[m,h]=(0,O.useState)(n),g=r?r.actorName:m,_=r?r.onSelectActor:h,[v,y]=(0,O.useState)(``),b=(0,O.useRef)(null),x=(0,O.useRef)(n),S=(0,O.useId)(),C=o?.actors.find(e=>e.actorName===g),w=rm(e,Xf(f,Date.now()),g),T=w.rows&&sm(w.rows),E=w.rows&&g!==void 0?cm(w.rows,g):void 0,D=w.supported&&w.rows?om(w.rows):void 0;return(0,O.useEffect)(()=>{h(n),y(``)},[e,n]),(0,O.useEffect)(()=>{x.current!==g&&b.current?.focus(),x.current=g},[g]),(0,B.jsxs)(`section`,{className:`la-observer ${t}`,"aria-label":`Actor observer`,children:[g!==void 0&&(0,B.jsxs)(`nav`,{className:`la-observer-breadcrumb`,"aria-label":`Breadcrumb`,children:[(0,B.jsx)(Bn,{variant:`link`,type:`button`,"aria-label":`Back to actors`,onClick:()=>_(void 0),children:`Actors`}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,B.jsx)(`span`,{"aria-current":`page`,children:g})]}),(0,B.jsxs)(`div`,{className:`la-observer-toolbar`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`la-observer-title`,children:(0,B.jsx)(`h1`,{ref:b,tabIndex:-1,children:g??`Actors`})}),(0,B.jsx)(`p`,{children:g===void 0?`Inspect instances, residency, and connections.`:`Inspect this actor class’s instances, residency, and connections.`})]}),(0,B.jsxs)(`div`,{className:`la-observer-actions`,children:[w.supported&&(0,B.jsx)(tp,{value:f,onChange:p}),(0,B.jsxs)(Bn,{variant:`outline`,type:`button`,disabled:s,onClick:l,children:[(0,B.jsx)(Te,{"aria-hidden":`true`,className:s?`la-observer-spin`:void 0}),s?`Refreshing…`:c?`Try again`:`Refresh`]})]})]}),c&&(0,B.jsxs)(`div`,{className:`la-observer-error`,role:`alert`,children:[(0,B.jsx)(_e,{"aria-hidden":`true`}),(0,B.jsx)(`p`,{children:o?`Could not refresh. These counts may be out of date.`:`Could not load actors. Check your connection and access, then try again.`})]}),!o&&!c&&(0,B.jsx)(fm,{}),o&&(0,B.jsxs)(B.Fragment,{children:[g===void 0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pm,{inventory:o,queueWait:w.supported?D??null:void 0,range:f}),o.actors.length?(0,B.jsx)(mm,{inventory:o,query:v,onQueryChange:y,onSelectActor:_,waits:w.supported?T:void 0}):(0,B.jsx)(Sm,{title:`No actors yet`,description:`Deploy your actor classes to see them here. Instance counts appear as actors are used.`})]}):C?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(pm,{inventory:{actors:[C]},actorName:g,queueWait:w.supported?D??null:void 0,range:f}),(0,B.jsx)(hm,{client:e,id:S,actorName:g,instances:C.instances,waits:w.supported?E:void 0,range:f},g)]}):(0,B.jsx)(Sm,{title:`Actor class unavailable`,description:`This actor class is no longer in the latest inventory. Return to Actors to see available classes.`}),(0,B.jsxs)(`div`,{className:`la-observer-footnote`,children:[(0,B.jsxs)(`span`,{className:`la-observer-refresh-status`,children:[(0,B.jsx)(`span`,{className:`la-observer-dot ${c?`la-observer-dot-unknown`:e.watchActors?`la-observer-dot-live`:``}`}),c?`Reconnecting…`:e.watchActors?`Live updates`:`Auto-refresh every 5s`]}),(0,B.jsx)(`span`,{children:e.watchActors?`Changes stream from the control plane.`:`Counts follow the latest host heartbeat.`})]})]})]})}function fm(){return(0,B.jsxs)(`div`,{className:`la-observer-skeleton`,role:`status`,"aria-label":`Loading actors`,children:[(0,B.jsx)(`span`,{className:`la:sr-only`,children:`Loading actors…`}),(0,B.jsx)(`div`,{}),(0,B.jsx)(`div`,{}),(0,B.jsx)(`div`,{})]})}function pm({inventory:e,actorName:t,queueWait:n,range:r}){let i=e.actors.reduce((e,t)=>({live:e.live+t.live,dormant:e.dormant+t.dormant,unknown:e.unknown+t.unknown}),{live:0,dormant:0,unknown:0});return(0,B.jsxs)(`dl`,{className:`la-observer-summary`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Total instances`}),(0,B.jsx)(`dd`,{"aria-label":`Total instances`,children:(i.live+i.dormant+i.unknown).toLocaleString()}),(0,B.jsx)(`p`,{children:t===void 0?`${e.actors.length} actor ${e.actors.length===1?`type`:`types`}`:`In this actor class`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`dt`,{children:[(0,B.jsx)(`span`,{className:`la-observer-dot la-observer-dot-live`}),`Live`]}),(0,B.jsx)(`dd`,{"aria-label":`Live instances`,children:i.live.toLocaleString()}),(0,B.jsx)(`p`,{children:`Loaded in memory`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`dt`,{children:[(0,B.jsx)(`span`,{className:`la-observer-dot`}),`Dormant`]}),(0,B.jsx)(`dd`,{"aria-label":`Dormant instances`,children:i.dormant.toLocaleString()}),(0,B.jsx)(`p`,{children:`Currently unloaded`})]}),i.unknown>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`dt`,{children:[(0,B.jsx)(`span`,{className:`la-observer-dot la-observer-dot-unknown`}),`Unknown`]}),(0,B.jsx)(`dd`,{"aria-label":`Unknown instances`,children:i.unknown.toLocaleString()}),(0,B.jsx)(`p`,{children:`Awaiting host report`})]}),n!==void 0&&(0,B.jsxs)(`div`,{className:`la-observer-queue-wait`,children:[(0,B.jsx)(`dt`,{children:`Avg queue wait`}),(0,B.jsx)(`dd`,{"aria-label":`Average queue wait`,children:lm(n?.averageMs)}),(0,B.jsx)(`p`,{children:n?`Max ${lm(n.maxMs)} · ${n.admitted.toLocaleString()} admitted ${Qf(r)}`:`No admitted requests ${Qf(r)}`})]})]})}function mm({inventory:e,query:t,onQueryChange:n,onSelectActor:r,waits:i}){let a=e.actors.some(e=>e.unknown>0),o=e.actors.filter(e=>Cm(e.actorName,t)).sort((e,t)=>Number(t.live>0)-Number(e.live>0));return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`la-observer-list-toolbar`,children:[(0,B.jsxs)(`h2`,{children:[`Actor names `,(0,B.jsx)(lp,{children:e.actors.length})]}),(0,B.jsx)(xm,{label:`Search actors`,placeholder:`Search actors…`,value:t,onChange:n})]}),(0,B.jsx)(`div`,{className:`la-observer-table-frame`,children:o.length?(0,B.jsxs)(Hp,{"aria-label":`Actor instance counts`,className:`la-observer-table`,children:[(0,B.jsx)(Up,{children:(0,B.jsxs)(Gp,{children:[(0,B.jsx)(Kp,{scope:`col`,children:`Actor`}),(0,B.jsx)(Kp,{scope:`col`,children:`Live`}),(0,B.jsx)(Kp,{scope:`col`,children:`Dormant`}),a&&(0,B.jsx)(Kp,{scope:`col`,children:`Unknown`}),(0,B.jsx)(Kp,{scope:`col`,children:`Total`}),i&&(0,B.jsx)(Kp,{scope:`col`,className:`la-observer-wait-cell`,children:`Avg queue wait`})]})}),(0,B.jsx)(Wp,{children:o.map(e=>(0,B.jsxs)(Gp,{className:`la-clickable-row`,onClick:()=>r(e.actorName),children:[(0,B.jsx)(qp,{className:`la-observer-name`,children:(0,B.jsxs)(Bn,{variant:`ghost`,type:`button`,className:`la-observer-actor-button la-observer-class-button`,children:[(0,B.jsx)(ae,{className:`la-observer-type-icon`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{children:e.actorName})]})}),(0,B.jsx)(qp,{children:(0,B.jsx)(`span`,{className:e.live>0?`la-observer-live`:void 0,children:e.live.toLocaleString()})}),(0,B.jsx)(qp,{children:e.dormant.toLocaleString()}),a&&(0,B.jsx)(qp,{children:e.unknown.toLocaleString()}),(0,B.jsx)(qp,{children:(e.live+e.dormant+e.unknown).toLocaleString()}),i&&(0,B.jsx)(qp,{className:`la-observer-wait-cell`,children:(0,B.jsx)(gm,{stats:i.get(e.actorName)})})]},e.actorName))})]}):(0,B.jsx)(Sm,{title:`No matching actors`,description:`Try a different actor name.`,action:`Clear search`,onReset:()=>n(``)})}),a&&(0,B.jsxs)(`p`,{className:`la-observer-unknown`,children:[(0,B.jsx)(_e,{"aria-hidden":`true`}),`Some hosts have not reported which instances are loaded. Their counts are shown as unknown.`]})]})}function hm({client:e,id:t,actorName:n,instances:r,waits:i,range:a}){let[o,s]=(0,O.useState)(``),[c,l]=(0,O.useState)(`all`),[u,d]=(0,O.useState)(),f=`${t}-connections`,p=r.filter(e=>Cm(e.actorId,o)&&(c===`all`||e.status===c));p.sort((e,t)=>Number(t.status===`live`)-Number(e.status===`live`));let m=r.find(e=>e.actorId===u),h=(0,O.useRef)(null);return(0,O.useEffect)(()=>{h.current?.focus()},[u]),u===void 0?(0,B.jsxs)(`section`,{id:t,className:`la-observer-instances`,"aria-labelledby":`${t}-heading`,children:[(0,B.jsx)(`div`,{className:`la-observer-instances-heading`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h2`,{ref:h,tabIndex:-1,id:`${t}-heading`,children:[n,` instances `,(0,B.jsx)(lp,{"aria-hidden":`true`,children:r.length.toLocaleString()})]}),(0,B.jsx)(`p`,{children:`Select an instance to inspect its waiting line, requests, and WebSocket connections.`})]})}),r.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`la-observer-filters`,children:[(0,B.jsx)(xm,{label:`Search instances`,placeholder:`Search instance IDs…`,value:o,onChange:s}),(0,B.jsxs)(`select`,{className:`la-observer-select`,"aria-label":`Instance state`,value:c,onChange:e=>l(e.target.value),children:[(0,B.jsx)(`option`,{value:`all`,children:`All states`}),(0,B.jsx)(`option`,{value:`live`,children:`Live`}),(0,B.jsx)(`option`,{value:`dormant`,children:`Dormant`}),(0,B.jsx)(`option`,{value:`unknown`,children:`Unknown`})]})]}),(0,B.jsx)(`div`,{className:`la-observer-table-frame`,children:p.length?(0,B.jsxs)(Hp,{"aria-label":`${n} instances`,className:`la-observer-instance-table`,children:[(0,B.jsx)(Up,{children:(0,B.jsxs)(Gp,{children:[(0,B.jsx)(Kp,{scope:`col`,children:`Instance`}),(0,B.jsx)(Kp,{scope:`col`,children:`State`}),(0,B.jsx)(Kp,{scope:`col`,children:`Connections`}),i&&(0,B.jsx)(Kp,{scope:`col`,className:`la-observer-wait-cell`,children:`Avg queue wait`}),(0,B.jsx)(Kp,{scope:`col`,className:`la-observer-waiting-cell`,children:`Waiting`})]})}),(0,B.jsx)(Wp,{children:p.map(e=>(0,B.jsxs)(Gp,{className:`la-clickable-row`,onClick:()=>d(e.actorId),children:[(0,B.jsx)(qp,{className:`la-observer-instance-id`,children:(0,B.jsx)(Bn,{variant:`ghost`,type:`button`,className:`la-observer-actor-button`,children:(0,B.jsx)(`span`,{children:e.actorId})})}),(0,B.jsx)(qp,{children:(0,B.jsxs)(lp,{variant:`outline`,className:`la-observer-status-${e.status}`,children:[(0,B.jsx)(`span`,{className:`la-observer-dot la-observer-dot-${e.status}`}),wm(e.status)]})}),(0,B.jsx)(qp,{children:e.connections.length.toLocaleString()}),i&&(0,B.jsx)(qp,{className:`la-observer-wait-cell`,children:(0,B.jsx)(gm,{stats:i.get(e.actorId)})}),(0,B.jsx)(qp,{className:`la-observer-waiting-cell`,children:(0,B.jsx)(ym,{waiting:e.waiting,compact:!0})})]},e.actorId))})]}):(0,B.jsx)(Sm,{title:`No matching instances`,description:`Try another instance ID or state.`,action:`Clear filters`,onReset:()=>{s(``),l(`all`)}})}),(0,B.jsx)(`p`,{className:`la-observer-connection-note`,children:`Connections are active WebSocket connections, not unique people.`})]}):(0,B.jsxs)(`p`,{className:`la-observer-instance-empty`,role:`status`,children:[`No `,n,` instances have been created yet.`]})]}):(0,B.jsxs)(`section`,{className:`la-observer-instance-detail`,"aria-label":`${n} / ${u}`,children:[(0,B.jsx)(Bn,{variant:`link`,"aria-label":`Back to instances`,onClick:()=>d(void 0),children:`Back to instances`}),(0,B.jsxs)(`div`,{className:`la-observer-instance-heading`,children:[(0,B.jsx)(`h2`,{ref:h,tabIndex:-1,children:u}),m&&(0,B.jsx)(lp,{variant:`outline`,className:`la-observer-status-${m.status}`,children:wm(m.status)})]}),!m&&(0,B.jsx)(`p`,{role:`status`,children:`This instance is no longer in the current inventory. Its retained requests are still available below.`}),i&&(0,B.jsx)(_m,{stats:i.get(u),range:a}),m&&(0,B.jsx)(vm,{waiting:m.waiting}),e.watchRequests||e.listRequests?(0,B.jsx)($p,{client:e,actor:{actorName:n,actorId:u},timeRange:a},u):(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`Requests`}),(0,B.jsx)(`p`,{children:`Request timings are unavailable for this connection.`})]}),m&&(0,B.jsx)(bm,{id:f,actorId:m.actorId,connections:m.connections})]})}function gm({stats:e}){return e?(0,B.jsxs)(`span`,{className:`la-observer-wait`,title:`Average of ${e.admitted.toLocaleString()} admitted requests in the selected time range; longest wait ${lm(e.maxMs)}`,children:[lm(e.averageMs),(0,B.jsxs)(`small`,{children:[`max `,lm(e.maxMs)]})]}):(0,B.jsx)(`span`,{title:`No admitted requests in the selected time range`,children:`—`})}function _m({stats:e,range:t}){return(0,B.jsxs)(`section`,{className:`la-observer-queue-wait-detail`,"aria-label":`Queue wait`,children:[(0,B.jsx)(`h3`,{children:`Queue wait`}),(0,B.jsx)(`p`,{children:e?`Time requests spent waiting to enter this actor ${Qf(t)}.`:`No requests were admitted to this actor ${Qf(t)}.`}),e&&(0,B.jsxs)(`dl`,{className:`la-observer-summary la-observer-summary-compact`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Average`}),(0,B.jsx)(`dd`,{"aria-label":`Average queue wait`,children:lm(e.averageMs)}),(0,B.jsx)(`p`,{children:`Per admitted request`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Longest`}),(0,B.jsx)(`dd`,{"aria-label":`Longest queue wait`,children:lm(e.maxMs)}),(0,B.jsx)(`p`,{children:`Single request`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Admitted`}),(0,B.jsx)(`dd`,{"aria-label":`Admitted requests`,children:e.admitted.toLocaleString()}),(0,B.jsx)(`p`,{children:`Requests that entered the actor`})]})]})]})}function vm({waiting:e}){return(0,B.jsxs)(`section`,{className:`la-observer-waiting`,"aria-label":`Waiting requests`,children:[(0,B.jsxs)(`h3`,{children:[`Waiting requests`,e!=null&&` (${e.length})`]}),(0,B.jsx)(`p`,{children:e==null?`This host has not reported its waiting line.`:e.length?`Next to run first. Operations leave this line when they start.`:`No requests waiting.`}),!!e?.length&&(0,B.jsx)(ym,{waiting:e})]})}function ym({waiting:e,compact:t=!1}){if(e==null)return(0,B.jsx)(`span`,{title:`Queue reporting is unavailable`,children:`Unavailable`});if(!e.length)return(0,B.jsx)(`span`,{className:`la-observer-queue-empty`,children:`None`});let n=t?e.slice(0,3):e;return(0,B.jsxs)(`ol`,{className:`la-observer-queue${t?` la-observer-queue-compact`:``}`,"aria-label":`${e.length} waiting requests, next to run first`,children:[n.map((e,n)=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(lp,{variant:`outline`,className:`la-observer-queue-bubble`,title:e.operation,children:[!t&&(0,B.jsx)(`span`,{className:`la-observer-queue-position`,children:n+1}),(0,B.jsx)(`span`,{className:`la-observer-queue-operation`,children:e.operation})]})},e.id)),t&&e.length>n.length&&(0,B.jsx)(`li`,{children:(0,B.jsxs)(lp,{"aria-label":`${e.length-n.length} more waiting requests`,children:[`+`,e.length-n.length]})})]})}function bm({id:e,actorId:t,connections:n}){return(0,B.jsxs)(`section`,{id:e,className:`la-observer-connections`,"aria-labelledby":`${e}-heading`,children:[(0,B.jsx)(`div`,{className:`la-observer-instances-heading`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h3`,{id:`${e}-heading`,children:[t,` WebSockets `,(0,B.jsx)(lp,{"aria-hidden":`true`,children:n.length.toLocaleString()})]}),(0,B.jsx)(`p`,{children:`${n.length.toLocaleString()} active ${n.length===1?`connection`:`connections`}`})]})}),n.length?(0,B.jsx)(`div`,{className:`la-observer-table-frame`,children:(0,B.jsxs)(Hp,{"aria-label":`${t} WebSocket connections`,className:`la-observer-connection-table`,children:[(0,B.jsx)(Up,{children:(0,B.jsxs)(Gp,{children:[(0,B.jsx)(Kp,{scope:`col`,children:`Socket`}),(0,B.jsx)(Kp,{scope:`col`,children:`Metadata`})]})}),(0,B.jsx)(Wp,{children:n.map(e=>(0,B.jsxs)(Gp,{children:[(0,B.jsx)(qp,{className:`la-observer-socket-id`,children:e.id}),(0,B.jsx)(qp,{children:(0,B.jsx)(`pre`,{children:JSON.stringify(e.metadata,null,2)})})]},e.id))})]})}):(0,B.jsxs)(`div`,{className:`la-observer-no-connections`,role:`status`,children:[(0,B.jsx)(je,{"aria-hidden":`true`}),(0,B.jsx)(`p`,{children:`No active WebSocket connections.`})]})]})}function xm({label:e,placeholder:t,value:n,onChange:r}){return(0,B.jsxs)(`div`,{className:`la-observer-search`,children:[(0,B.jsx)(De,{"aria-hidden":`true`}),(0,B.jsx)(Ko,{type:`search`,"aria-label":e,placeholder:t,value:n,onInput:e=>r(e.currentTarget.value)})]})}function Sm({title:e,description:t,action:n,onReset:r}){return(0,B.jsxs)(`div`,{className:`la-observer-empty`,children:[(0,B.jsx)(De,{"aria-hidden":`true`}),(0,B.jsx)(`h3`,{children:e}),(0,B.jsx)(`p`,{children:t}),n&&(0,B.jsx)(Bn,{type:`button`,variant:`outline`,onClick:r,children:n})]})}function Cm(e,t){return e.toLocaleLowerCase().includes(t.trim().toLocaleLowerCase())}function wm(e){return e[0].toUpperCase()+e.slice(1)}function Tm(e){let t=e.filter(e=>e.outcome!==`rerouted`);return{count:e.length,success:t.length?100*t.filter(e=>e.outcome===`completed`).length/t.length:null,p95:km(t.map(e=>e.durationMs))}}function Em(e,t,n){return e.filter(e=>e.startedAtMs>=(t.fromMs??0)&&e.startedAtMs<=(t.toMs??n))}function Dm(e){return e.actors.reduce((e,t)=>({live:e.live+t.live,dormant:e.dormant+t.dormant,unknown:e.unknown+t.unknown,connections:e.connections+t.instances.reduce((e,t)=>e+t.connections.length,0)}),{live:0,dormant:0,unknown:0,connections:0})}function Om(e){return km(e.filter(e=>e.outcome!==`rerouted`&&e.queueWaitMs!==null).map(e=>e.queueWaitMs))}function km(e){return e.length?e.sort((e,t)=>e-t)[Math.ceil(e.length*.95)-1]:null}function Am(e){let t=e;if(!t||!jm(t.total)||!Array.isArray(t.classes)||!t.classes.every(jm))throw Error(`Invalid overview metrics response`);return t}function jm(e){return!!e&&typeof e.actorName==`string`&&Number.isSafeInteger(e.count)&&e.count>=0&&[e.success,e.p95,e.queueP95].every(e=>e===null||typeof e==`number`&&Number.isFinite(e)&&e>=0)&&(e.success===null||e.success<=100)}function Mm(e){let t=new Map;for(let n of e)t.set(n.actorName,[...t.get(n.actorName)??[],n]);let n=(e,t)=>({actorName:e,...Tm(t),queueP95:Om(t)});return{total:n(``,e),classes:[...t].map(([e,t])=>n(e,t))}}function Nm({client:e,onSelectActor:t,timeRange:n,onTimeRangeChange:r}){let i=Jp(e),[a,o]=(0,O.useState)(Yf),s=n??a,c=r??o,[l,u]=(0,O.useState)(Date.now);(0,O.useEffect)(()=>{let e=setInterval(()=>u(Date.now()),1e4);return()=>clearInterval(e)},[]);let d=Xf(s,l),f=Zp(e,d,e.getMetrics),p=Yp(e,!f.supported),m=p.page?Mm(Em(p.page.records,d,Math.max(l,Date.now()))):void 0,h=f.supported?f.value:m,g=f.supported?f.failed:p.failed;return(0,B.jsxs)(`section`,{className:`la-observer overview`,"aria-label":`Runtime overview`,children:[(0,B.jsxs)(`div`,{className:`overview-heading`,children:[(0,B.jsx)(`h1`,{children:`Durable Actors`}),(0,B.jsxs)(`div`,{className:`overview-controls`,children:[(0,B.jsx)(`span`,{className:`overview-updated`,children:i.failed?`Inventory reconnecting…`:i.updatedAt?(0,B.jsxs)(B.Fragment,{children:[`Last inventory update `,(0,B.jsx)(`time`,{dateTime:new Date(i.updatedAt).toISOString(),children:new Date(i.updatedAt).toLocaleTimeString([],{hour12:!1})})]}):`Connecting…`}),(0,B.jsx)(tp,{value:s,onChange:c,className:`overview-range`}),(0,B.jsx)(Bn,{variant:`outline`,size:`icon`,"aria-label":`Refresh overview`,onClick:()=>{i.retry(),f.retry(),p.retry()},children:(0,B.jsx)(Te,{"aria-hidden":`true`})})]})]}),i.failed&&(0,B.jsxs)(`p`,{className:`overview-alert`,role:`alert`,children:[`Inventory unavailable. `,i.inventory?`Showing the last received counts; they may be out of date.`:`Check your connection and access.`,` Retrying automatically.`]}),g&&(0,B.jsxs)(`p`,{className:`overview-alert`,role:`alert`,children:[f.supported?`Request history unavailable.`:`Request stream unavailable.`,` `,h?`Showing the last received metrics.`:`Request metrics are not available yet.`,` `,`Retrying automatically.`]}),(0,B.jsx)(Pm,{inventory:i.inventory,metrics:h,range:s}),(0,B.jsx)(Fm,{inventory:i.inventory,metrics:h,failed:i.failed,onSelectActor:t}),(0,B.jsx)(zm,{page:f.supported?void 0:p.page,range:s,saved:f.supported})]})}function Pm({inventory:e,metrics:t,range:n}){let r=e?Dm(e):void 0,i=r?r.live+r.dormant+r.unknown:void 0,a=t?.total;return(0,B.jsxs)(`div`,{className:`overview-metrics`,children:[(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Actor instances`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Actor instances`,children:Vm(i)}),(0,B.jsx)(`span`,{children:e?`${e.actors.length} actor ${e.actors.length===1?`class`:`classes`}`:`Waiting for inventory`})]}),(0,B.jsx)(`div`,{className:`overview-residency`,"aria-hidden":`true`,children:r&&Object.entries(r).filter(([e])=>e!==`connections`).map(([e,t])=>(0,B.jsx)(`span`,{className:`residency-${e}`,style:{flexGrow:t}},e))}),(0,B.jsxs)(`div`,{className:`overview-metric-foot`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:Vm(r?.live)}),` live`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:Vm(r?.dormant)}),` dormant`]}),!!r?.unknown&&(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:Vm(r.unknown)}),` unknown`]})]})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Requests`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Retained requests`,children:Vm(a?.count)}),(0,B.jsx)(`span`,{children:Qf(n)})]}),(0,B.jsxs)(`div`,{className:`overview-health`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(Lm,{value:a?.success,kind:`success`}),` success`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(Lm,{value:a?.p95,kind:`latency`}),` p95 latency`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:Hm(a?.queueP95)}),` p95 queue wait`]})]})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`WebSocket connections`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Open WebSocket connections`,children:Vm(r?.connections)}),(0,B.jsx)(`span`,{children:`open`})]}),(0,B.jsxs)(`div`,{className:`overview-health`,children:[(0,B.jsx)(`span`,{children:`Current inventory snapshot`}),(0,B.jsx)(`span`,{children:`Active sockets`})]})]})]})}function Fm({inventory:e,metrics:t,failed:n,onSelectActor:r}){let[i,a]=(0,O.useState)(``),[o,s]=(0,O.useState)(`all`),c=e?.actors.filter(e=>e.actorName.toLocaleLowerCase().includes(i.trim().toLocaleLowerCase())&&(o===`all`||e[o]>0)).sort((e,t)=>Number(t.live>0)-Number(e.live>0))??[];return(0,B.jsxs)(`section`,{"aria-label":`Actor classes`,children:[(0,B.jsxs)(`div`,{className:`overview-section-heading`,children:[(0,B.jsxs)(`h2`,{children:[`Actor classes `,(0,B.jsx)(`span`,{children:Vm(e?.actors.length)})]}),(0,B.jsx)(Rm,{})]}),(0,B.jsxs)(`div`,{className:`overview-panel`,children:[(0,B.jsxs)(`div`,{className:`overview-filterbar`,children:[(0,B.jsxs)(`div`,{className:`overview-search`,children:[(0,B.jsx)(De,{"aria-hidden":`true`}),(0,B.jsx)(Ko,{"aria-label":`Filter actor classes`,placeholder:`Filter actor classes…`,value:i,onInput:e=>a(e.currentTarget.value)})]}),(0,B.jsxs)(`select`,{"aria-label":`Filter by residency`,value:o,onChange:e=>s(e.target.value),children:[(0,B.jsx)(`option`,{value:`all`,children:`All states`}),(0,B.jsx)(`option`,{value:`live`,children:`Live instances`}),(0,B.jsx)(`option`,{value:`dormant`,children:`Dormant instances`}),(0,B.jsx)(`option`,{value:`unknown`,children:`Unknown residency`})]})]}),(0,B.jsx)(`div`,{className:`overview-table-scroll`,role:`region`,"aria-label":`Actor class metrics`,tabIndex:0,children:(0,B.jsxs)(`table`,{className:`overview-table`,children:[(0,B.jsxs)(`colgroup`,{children:[(0,B.jsx)(`col`,{className:`overview-class-column`}),(0,B.jsx)(`col`,{span:6})]}),(0,B.jsxs)(`thead`,{children:[(0,B.jsxs)(`tr`,{className:`overview-groups`,children:[(0,B.jsx)(`th`,{scope:`colgroup`,colSpan:2,children:`Actors`}),(0,B.jsx)(`th`,{scope:`colgroup`,colSpan:4,children:`Requests`}),(0,B.jsx)(`th`,{scope:`colgroup`,children:`WebSockets`})]}),(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Class`}),(0,B.jsx)(`th`,{scope:`col`,children:`Instances`}),(0,B.jsx)(`th`,{scope:`col`,children:`Total`}),(0,B.jsx)(`th`,{scope:`col`,children:`Success`}),(0,B.jsx)(`th`,{scope:`col`,children:`p95 latency`}),(0,B.jsx)(`th`,{scope:`col`,children:`p95 queue wait`}),(0,B.jsx)(`th`,{scope:`col`,children:`Connected`})]})]}),(0,B.jsx)(`tbody`,{children:c.map(e=>(0,B.jsx)(Im,{actor:e,metrics:t&&(t.classes.find(t=>t.actorName===e.actorName)??Bm(e.actorName)),onSelectActor:r},e.actorName))})]})}),!c.length&&(0,B.jsxs)(`div`,{className:`overview-empty`,role:`status`,children:[(0,B.jsx)(`strong`,{children:e?e.actors.length?`No matching actor classes`:`No actors yet`:n?`Inventory unavailable`:`Loading actor classes…`}),(0,B.jsx)(`p`,{children:e?.actors.length?`Try another class name or residency state.`:`Actor classes appear after deployment.`}),!!e?.actors.length&&(0,B.jsx)(Bn,{variant:`outline`,onClick:()=>{a(``),s(`all`)},children:`Clear filters`})]})]})]})}function Im({actor:e,metrics:t,onSelectActor:n}){return(0,B.jsxs)(`tr`,{className:`la-clickable-row`,onClick:()=>n(e.actorName),children:[(0,B.jsx)(`td`,{children:(0,B.jsx)(Bn,{variant:`ghost`,type:`button`,className:`overview-class-link`,"aria-label":`Inspect ${e.actorName}`,children:(0,B.jsx)(`span`,{title:e.actorName,children:e.actorName})})}),(0,B.jsx)(`td`,{children:Vm(e.live+e.dormant+e.unknown)}),(0,B.jsx)(`td`,{children:Vm(t?.count)}),(0,B.jsx)(`td`,{children:(0,B.jsx)(Lm,{value:t?.success,kind:`success`})}),(0,B.jsx)(`td`,{children:(0,B.jsx)(Lm,{value:t?.p95,kind:`latency`})}),(0,B.jsx)(`td`,{children:Hm(t?.queueP95)}),(0,B.jsx)(`td`,{children:Vm(e.instances.reduce((e,t)=>e+t.connections.length,0))})]})}function Lm({value:e,kind:t}){if(e==null)return(0,B.jsx)(`span`,{title:`No retained execution attempts`,children:`—`});let n=t===`success`?e<95?`bad`:e<99?`warn`:`good`:e>100?`bad`:`good`;return(0,B.jsxs)(`span`,{className:`overview-signal signal-${n}`,title:n===`bad`?`Critical threshold breached`:n===`warn`?`Warning threshold breached`:`Within threshold`,children:[n!==`good`&&(0,B.jsx)(`span`,{"aria-hidden":`true`,children:n===`warn`?`!`:`×`}),t===`success`?`${e.toLocaleString(void 0,{maximumFractionDigits:2})}%`:Hm(e)]})}function Rm(){return(0,B.jsxs)(`details`,{className:`overview-thresholds`,children:[(0,B.jsxs)(`summary`,{children:[(0,B.jsxs)(`span`,{className:`threshold-dots`,"aria-hidden":`true`,children:[(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{})]}),`Thresholds`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:`Display thresholds`}),(0,B.jsx)(`p`,{children:`Success: warning below 99%; critical below 95%.`}),(0,B.jsx)(`p`,{children:`Latency: critical when p95 exceeds 100 ms.`}),(0,B.jsx)(`p`,{children:`Reroutes are excluded from success and latency. Queue wait has no health threshold.`})]})]})}function zm({page:e,range:t,saved:n}){return(0,B.jsxs)(`div`,{className:`overview-data-scope`,children:[(0,B.jsx)(`p`,{children:n?`Request metrics cover every retained request ${Qf(t)}${t.kind===`relative`?` (refreshed every 10 seconds)`:``}. Inventory counts are current snapshots.`:`Request metrics cover the latest ${e?.capacity??500} retained traces within the selected window. Inventory counts are current snapshots.`}),!!e?.dropped&&(0,B.jsxs)(`p`,{role:`alert`,children:[Vm(e.dropped),` traces were not delivered. Request metrics are incomplete.`]}),e?.persistenceFailed&&(0,B.jsx)(`p`,{role:`alert`,children:`Some request events could not be saved. This history may be incomplete.`}),!!e?.evicted&&(0,B.jsx)(`p`,{children:`Earlier traces have expired; these metrics do not represent the full time window.`})]})}function Bm(e){return{actorName:e,count:0,success:null,p95:null,queueP95:null}}function Vm(e){return e===void 0?`—`:e.toLocaleString()}function Hm(e){return e==null?`—`:`${e.toLocaleString(void 0,{maximumFractionDigits:1})} ms`}var Um=1,Wm=.9,Gm=.8,Km=.17,qm=.1,Jm=.999,Ym=.9999,Xm=.99,Zm=/[\\\/_+.#"@\[\(\{&]/,Qm=/[\\\/_+.#"@\[\(\{&]/g,$m=/[\s-]/,eh=/[\s-]/g;function th(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Um:Xm;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=th(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Um:Zm.test(e.charAt(l-1))?(d*=Gm,p=e.slice(i,l-1).match(Qm),p&&i>0&&(d*=Jm**+p.length)):$m.test(e.charAt(l-1))?(d*=Wm,m=e.slice(i,l-1).match(eh),m&&i>0&&(d*=Jm**+m.length)):(d*=Km,i>0&&(d*=Jm**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Ym)),(d<qm&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=th(e,t,n,r,l+1,a+2,o),f*qm>d&&(d=f*qm)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function nh(e){return e.toLowerCase().replace(eh,` `)}function rh(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,th(e,t,nh(e),nh(t),0,0,{})}var ih=`[cmdk-group=""]`,ah=`[cmdk-group-items=""]`,oh=`[cmdk-group-heading=""]`,sh=`[cmdk-item=""]`,ch=`${sh}:not([aria-disabled="true"])`,lh=`cmdk-item-select`,uh=`data-value`,dh=(e,t,n)=>rh(e,t,n),fh=O.createContext(void 0),ph=()=>O.useContext(fh),mh=O.createContext(void 0),hh=()=>O.useContext(mh),gh=O.createContext(void 0),_h=O.forwardRef((e,t)=>{let n=jh(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=jh(()=>new Set),i=jh(()=>new Map),a=jh(()=>new Map),o=jh(()=>new Set),s=kh(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=rc(),y=rc(),b=rc(),x=O.useRef(null),S=Ph();Ah(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Ah(()=>{S(6,ee)},[]);let C=O.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,ee),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=O.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{k(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{k(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??dh;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(ah);t?t.appendChild(e.parentElement===t?e:e.closest(`${ah} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${ah} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${ih}[${uh}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(uh);C.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function ee(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(ih)?.querySelector(oh))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${sh}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(ch)||[])}function te(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(uh))}function ne(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(uh))}function re(e){let t=A()?.closest(ih),n;for(;t&&!n;)t=e>0?Dh(t,ih):Oh(t,ih),n=t?.querySelector(ch);n?C.setState(`value`,n.getAttribute(uh)):ne(e)}let M=()=>te(j().length-1),ie=e=>{e.preventDefault(),e.metaKey?M():e.altKey?re(1):ne(1)},ae=e=>{e.preventDefault(),e.metaKey?te(0):e.altKey?re(-1):ne(-1)};return O.createElement(ls.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ie(e);break;case`ArrowDown`:ie(e);break;case`p`:case`k`:g&&e.ctrlKey&&ae(e);break;case`ArrowUp`:ae(e);break;case`Home`:e.preventDefault(),te(0);break;case`End`:e.preventDefault(),M();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(lh);t.dispatchEvent(e)}}}}},O.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Lh},c),Ih(e,e=>O.createElement(mh.Provider,{value:C},O.createElement(fh.Provider,{value:w},e))))}),vh=O.forwardRef((e,t)=>{let n=rc(),r=O.useRef(null),i=O.useContext(gh),a=ph(),o=kh(e),s=o.current?.forceMount??i?.forceMount;Ah(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Nh(n,r,[e.value,e.children,r],e.keywords),l=hh(),u=Mh(e=>e.value&&e.value===c.current),d=Mh(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);O.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(lh,f),()=>t.removeEventListener(lh,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return O.createElement(ls.div,{ref:Re(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),yh=O.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=rc(),s=O.useRef(null),c=O.useRef(null),l=rc(),u=ph(),d=Mh(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Ah(()=>u.group(o),[]),Nh(o,s,[e.value,e.heading,c]);let f=O.useMemo(()=>({id:o,forceMount:i}),[i]);return O.createElement(ls.div,{ref:Re(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&O.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Ih(e,e=>O.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},O.createElement(gh.Provider,{value:f},e))))}),bh=O.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=O.useRef(null),a=Mh(e=>!e.search);return!n&&!a?null:O.createElement(ls.div,{ref:Re(i,t),...r,"cmdk-separator":``,role:`separator`})}),xh=O.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=hh(),o=Mh(e=>e.search),s=Mh(e=>e.selectedItemId),c=ph();return O.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),O.createElement(ls.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Sh=O.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=O.useRef(null),o=O.useRef(null),s=Mh(e=>e.selectedItemId),c=ph();return O.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),O.createElement(ls.div,{ref:Re(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Ih(e,e=>O.createElement(`div`,{ref:Re(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Ch=O.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return O.createElement(_p,{open:n,onOpenChange:r},O.createElement(xp,{container:o},O.createElement(Cp,{"cmdk-overlay":``,className:i}),O.createElement(Dp,{"aria-label":e.label,"cmdk-dialog":``,className:a},O.createElement(_h,{ref:t,...s}))))}),wh=O.forwardRef((e,t)=>Mh(e=>e.filtered.count===0)?O.createElement(ls.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Th=O.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return O.createElement(ls.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Ih(e,e=>O.createElement(`div`,{"aria-hidden":!0},e)))}),Eh=Object.assign(_h,{List:Sh,Item:vh,Input:xh,Group:yh,Separator:bh,Dialog:Ch,Empty:wh,Loading:Th});function Dh(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Oh(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function kh(e){let t=O.useRef(e);return Ah(()=>{t.current=e}),t}var Ah=typeof window>`u`?O.useEffect:O.useLayoutEffect;function jh(e){let t=O.useRef();return t.current===void 0&&(t.current=e()),t}function Mh(e){let t=hh(),n=()=>e(t.snapshot());return O.useSyncExternalStore(t.subscribe,n,n)}function Nh(e,t,n,r=[]){let i=O.useRef(),a=ph();return Ah(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(uh,s),i.current=s}),i}var Ph=()=>{let[e,t]=O.useState(),n=jh(()=>new Map);return Ah(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Fh(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Ih({asChild:e,children:t},n){return e&&O.isValidElement(t)?O.cloneElement(Fh(t),{ref:t.ref},n(t.props.children)):n(t)}var Lh={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Rh({className:e,...t}){return(0,B.jsx)(Eh,{"data-slot":`command`,className:z(`la:flex la:h-full la:w-full la:flex-col la:overflow-hidden la:rounded-md la:bg-popover la:text-popover-foreground`,e),...t})}function zh({className:e,...t}){return(0,B.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`la:flex la:h-9 la:items-center la:gap-2 la:border-b la:px-3`,children:[(0,B.jsx)(De,{className:`la:size-4 la:shrink-0 la:opacity-50`}),(0,B.jsx)(Eh.Input,{"data-slot":`command-input`,className:z(`la:flex la:h-10 la:w-full la:rounded-md la:bg-transparent la:py-3 la:text-sm la:outline-hidden la:placeholder:text-muted-foreground la:disabled:cursor-not-allowed la:disabled:opacity-50`,e),...t})]})}function Bh({className:e,...t}){return(0,B.jsx)(Eh.List,{"data-slot":`command-list`,className:z(`la:max-h-[300px] la:scroll-py-1 la:overflow-x-hidden la:overflow-y-auto`,e),...t})}function Vh({className:e,...t}){return(0,B.jsx)(Eh.Group,{"data-slot":`command-group`,className:z(`la:overflow-hidden la:p-1 la:text-foreground la:[&_[cmdk-group-heading]]:px-2 la:[&_[cmdk-group-heading]]:py-1.5 la:[&_[cmdk-group-heading]]:text-xs la:[&_[cmdk-group-heading]]:font-medium la:[&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function Hh({className:e,...t}){return(0,B.jsx)(Eh.Item,{"data-slot":`command-item`,className:z(`la:relative la:flex la:cursor-default la:items-center la:gap-2 la:rounded-sm la:px-2 la:py-1.5 la:text-sm la:outline-hidden la:select-none la:data-[disabled=true]:pointer-events-none la:data-[disabled=true]:opacity-50 la:data-[selected=true]:bg-accent la:data-[selected=true]:text-accent-foreground la:[&_svg]:pointer-events-none la:[&_svg]:shrink-0 la:[&_svg:not([class*='size-'])]:size-4 la:[&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function Uh({label:e,placeholder:t,value:n,onChange:r,suggestions:i,limit:a=8}){let[o,s]=(0,O.useState)(!1),c=Wh(i,n,a),l=c.reduce((e,t)=>e.set(t.group,[...e.get(t.group)??[],t]),new Map),u=o&&c.length>0;return(0,B.jsxs)(Rh,{label:e,shouldFilter:!1,loop:!0,className:`la-combobox la:relative la:overflow-visible la:bg-transparent`,onKeyDown:e=>{e.key===`Escape`&&s(!1),e.key===`ArrowDown`&&s(!0)},children:[(0,B.jsx)(zh,{placeholder:t,value:n,onValueChange:e=>{r(e),s(!0)},onFocus:()=>s(!0),onBlur:()=>s(!1)}),u&&(0,B.jsx)(Bh,{label:`${e} suggestions`,className:`la:absolute la:top-full la:right-0 la:left-0 la:z-20 la:mt-1.5 la:rounded-md la:border la:bg-popover la:text-popover-foreground la:shadow-md`,onMouseDown:e=>e.preventDefault(),children:[...l].map(([e,t])=>(0,B.jsx)(Vh,{heading:e,children:t.map(t=>(0,B.jsxs)(Hh,{value:`${e}:${t.value}`,onSelect:()=>{r(t.value),s(!1)},children:[(0,B.jsx)(`span`,{className:`la:truncate la:font-mono la:text-xs`,children:t.value}),t.hint&&(0,B.jsx)(`span`,{className:`la:ml-auto la:text-xs la:text-muted-foreground`,children:t.hint})]},t.value))},e))})]})}function Wh(e,t,n){let r=t.trim().toLocaleLowerCase(),i=new Set,a=[];for(let t of e){let e=`${t.group}:${t.value}`,n=t.value.toLocaleLowerCase();i.has(e)||n===r||r&&!n.includes(r)||(i.add(e),a.push(t))}return a.sort((e,t)=>Number(t.value.toLocaleLowerCase().startsWith(r))-Number(e.value.toLocaleLowerCase().startsWith(r))).slice(0,n)}function Gh(e){if(!Array.isArray(e)||!e.every(e=>!!e&&typeof e==`object`&&$h(e)))throw Error(`Invalid WebSocket session response`);return e}function Kh(e,t,n){return JSON.stringify([e,t,n])}function qh(e,t,n=new Map){let r=new Map;for(let e of t?.actors??[])for(let t of e.instances)for(let n of t.connections)r.set(JSON.stringify([e.actorName,t.actorId,n.id]),n.metadata);let i=e.map(e=>{let t=JSON.stringify([e.actorName,e.actorId,e.connectionId]),n=e.closedAtMs===null?r.has(t)?`open`:`lost`:`closed`;return n===`open`?{...e,status:n,metadata:r.get(t)}:{...e,status:n}}),a=new Set(i.map(e=>JSON.stringify([e.actorName,e.actorId,e.connectionId])));for(let e of t?.actors??[])for(let t of e.instances)for(let r of t.connections){let o=Kh(e.actorName,t.actorId,r.id);if(a.has(o))continue;let s=n.get(o);i.unshift({connectionId:r.id,actorName:e.actorName,actorId:t.actorId,hostId:null,openedAtMs:s??null,estimatedStart:s!==void 0,closedAtMs:null,lastSeenMs:null,messages:0,failures:0,status:`open`,metadata:r.metadata})}return i}function Jh(e,t){if(e.openedAtMs===null)return null;let n=e.status===`closed`?e.closedAtMs:e.status===`open`?Math.max(t,e.openedAtMs):e.lastSeenMs;return{ms:Math.max(0,n-e.openedAtMs),lowerBound:e.status===`lost`}}function Yh(e,t){let n=e.map(e=>Jh(e,t)).filter(e=>e!==null&&!e.lowerBound),r=e.reduce((e,t)=>e+t.messages,0);return{total:e.length,open:e.filter(e=>e.status===`open`).length,lost:e.filter(e=>e.status===`lost`).length,median:Qh(n.map(e=>e.ms),.5),p95:Qh(n.map(e=>e.ms),.95),messages:r,messagesPerSession:e.length?r/e.length:null}}function Xh(e){if(e<1e3)return`${e.toLocaleString(void 0,{maximumFractionDigits:0})} ms`;if(e<6e4)return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} s`;let t=Math.floor(e/6e4);if(t<60)return`${t}m ${Math.floor(e%6e4/1e3)}s`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Zh(e,t=3){if(e==null)return null;if(typeof e!=`object`)return String(e);let n=Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e);if(!n.length)return null;let r=n.slice(0,t).map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)}`);return n.length>t?`${r.join(` · `)} · +${n.length-t}`:r.join(` · `)}function Qh(e,t){return e.length?e.sort((e,t)=>e-t)[Math.max(0,Math.ceil(e.length*t)-1)]:null}function $h(e){return typeof e.connectionId==`string`&&typeof e.actorName==`string`&&typeof e.actorId==`string`&&(e.hostId===null||typeof e.hostId==`string`)&&[e.openedAtMs,e.closedAtMs,e.lastSeenMs].every(e=>e===null||Number.isSafeInteger(e)&&Number(e)>=0)&&[e.messages,e.failures].every(e=>Number.isSafeInteger(e)&&Number(e)>=0)&&(e.openedAtMs!==null||e.lastSeenMs!==null)}var eg=18,tg=8,ng=40,rg=6e4,ig=60*rg,ag=24*ig,og=[1e3,2e3,5e3,1e4,15e3,3e4,rg,2*rg,5*rg,10*rg,15*rg,30*rg,ig,2*ig,3*ig,6*ig,12*ig,ag,2*ag,7*ag];function sg({sessions:e,start:t,end:n,endLabel:r=`now`,selected:i,onSelect:a}){let[o,s]=(0,O.useState)(),c=ug(e,t,n),l=c.slice(0,ng),u=Math.max(1,n-t),d=mg(t,n),f=hg(u),p=e=>`${(Math.min(Math.max(e,t),n)-t)/u*100}%`,m=(e,t)=>{let n=t.getBoundingClientRect(),r=t.closest(`.socket-timeline`).getBoundingClientRect(),i=n.top-r.top<150;s({session:e,left:Math.min(Math.max(n.left-r.left+n.width/2,120),r.width-120),top:i?n.bottom-r.top:n.top-r.top,below:i})};return(0,B.jsxs)(`div`,{className:`socket-timeline`,role:`group`,"aria-label":`Connection timeline`,onMouseLeave:()=>s(void 0),children:[(0,B.jsxs)(`div`,{className:`socket-timeline-axis`,"aria-hidden":`true`,children:[(0,B.jsx)(`span`,{}),(0,B.jsxs)(`div`,{children:[d.map(e=>(0,B.jsx)(`span`,{style:{left:p(e)},children:gg(e,f)},e)),(0,B.jsx)(`span`,{className:`socket-timeline-now`,children:r})]})]}),(0,B.jsxs)(`div`,{className:`socket-timeline-body`,children:[(0,B.jsx)(`div`,{className:`socket-timeline-grid`,"aria-hidden":`true`,children:d.map(e=>(0,B.jsx)(`i`,{style:{left:p(e)}},e))}),l.map(e=>(0,B.jsxs)(`div`,{className:`socket-timeline-row`,children:[(0,B.jsxs)(`div`,{className:`socket-timeline-label`,title:`${e.actorName} / ${e.actorId}`,children:[(0,B.jsx)(`span`,{children:e.actorName}),(0,B.jsx)(`strong`,{children:e.actorId})]}),(0,B.jsx)(`div`,{className:`socket-timeline-lanes`,style:{height:e.rows.length*eg+16},children:e.rows.flatMap((e,t)=>e.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`socket-bar socket-bar-${e.session.status}${e.openEnded?` socket-bar-open-ended`:``}${e.unknownStart?` socket-bar-unknown-start`:``}`,"data-state":i===e.session?`selected`:void 0,style:{left:p(e.from),width:`${(e.to-e.from)/u*100}%`,top:tg+t*eg},"aria-label":bg(e.session,n),onClick:t=>a(e.session,t.currentTarget),onMouseEnter:t=>m(e.session,t.currentTarget),onFocus:t=>m(e.session,t.currentTarget),onBlur:()=>s(void 0)},e.session.connectionId)))})]},e.key)),c.length>ng&&(0,B.jsxs)(`p`,{className:`socket-timeline-more`,children:[(c.length-ng).toLocaleString(),` more `,c.length-ng===1?`instance is`:`instances are`,` listed in the table below.`]})]}),o&&(0,B.jsxs)(`div`,{role:`tooltip`,className:`socket-tooltip${o.below?` socket-tooltip-below`:``}`,style:{left:o.left,top:o.top},children:[(0,B.jsx)(lg,{metadata:o.session.metadata}),(0,B.jsxs)(`dl`,{children:[(0,B.jsx)(`dt`,{children:`Connection`}),(0,B.jsx)(`dd`,{children:yg(o.session.connectionId)}),(0,B.jsx)(`dt`,{children:`Instance`}),(0,B.jsxs)(`dd`,{children:[o.session.actorName,` / `,o.session.actorId]}),(0,B.jsx)(`dt`,{children:`Status`}),(0,B.jsx)(`dd`,{children:_g(o.session.status)}),(0,B.jsx)(`dt`,{children:`Opened`}),(0,B.jsx)(`dd`,{children:o.session.openedAtMs===null?`Before retained history`:`${o.session.estimatedStart?`≈ `:``}${new Date(o.session.openedAtMs).toLocaleTimeString([],{hour12:!1})}`}),(0,B.jsx)(`dt`,{children:`Duration`}),(0,B.jsx)(`dd`,{children:vg(o.session,n)}),(0,B.jsx)(`dt`,{children:`Messages`}),(0,B.jsx)(`dd`,{children:o.session.messages.toLocaleString()})]})]})]})}var cg=4;function lg({metadata:e}){if(e==null)return null;let t=typeof e==`object`?Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e):[[`value`,e]];return t.length?(0,B.jsxs)(`dl`,{className:`socket-tooltip-metadata`,"aria-label":`Connection metadata`,children:[t.slice(0,cg).map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e}),(0,B.jsx)(`dd`,{children:typeof t==`string`?t:JSON.stringify(t)})]},e)),t.length>cg&&(0,B.jsxs)(`p`,{children:[`+`,t.length-cg,` more in details`]})]}):null}function ug(e,t,n){let r=new Map,i=e.map(e=>dg(e,t,n)).filter(e=>e.to>t).sort((e,t)=>e.from-t.from||e.to-t.to);for(let e of i){let i=`${e.session.actorName}${e.session.actorId}`,a=r.get(i)??{key:i,actorName:e.session.actorName,actorId:e.session.actorId,rows:[]};r.set(i,a);let o=a.rows.find(r=>r.at(-1).to+fg(t,n)<=e.from);o?o.push(e):a.rows.push([e])}return[...r.values()].sort((e,t)=>pg(t)-pg(e))}function dg(e,t,n){let r=e.openedAtMs??(e.status===`open`?t:e.lastSeenMs??t),i=e.status===`closed`?e.closedAtMs:e.status===`open`?n:e.lastSeenMs??r;return{session:e,from:Math.max(t,r),to:Math.max(Math.max(t,r)+fg(t,n),Math.min(n,i)),openEnded:e.status!==`closed`,unknownStart:e.openedAtMs===null}}function fg(e,t){return Math.max(1,(t-e)/160)}function pg(e){return Math.max(...e.rows.flat().map(e=>e.to))}function mg(e,t){let n=hg(Math.max(1,t-e)),r=[];for(let i=Math.floor(e/n)*n+n;i<t-n*.35;i+=n)r.push(i);return r}function hg(e){return og.find(t=>e/t<=9)??og.at(-1)}function gg(e,t){let n=new Date(e);return t>=ag?n.toLocaleDateString([],{month:`short`,day:`numeric`}):t>=rg?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):n.toLocaleTimeString([],{hour12:!1})}function _g(e){return e===`open`?`Open`:e===`closed`?`Closed`:`Lost`}function vg(e,t){let n=Jh(e,t);return n?`${n.lowerBound?`≥ `:``}${Xh(n.ms)}`:`Unknown`}function yg(e){return e.length>14?`${e.slice(0,8)}…${e.slice(-4)}`:e}function bg(e,t){let n=Zh(e.metadata);return`${_g(e.status)} connection ${yg(e.connectionId)}${n===null?``:` (${n})`} on ${e.actorName} ${e.actorId}, ${vg(e,t)}`}function xg(e,t){let n=Zp(e,t,e.listWebSockets,5e3);return{...n,rows:n.value,capped:(n.value?.length??0)>=500}}function Sg({client:e,onSelectActor:t,timeRange:n,onTimeRangeChange:r}){let{inventory:i,failed:a,retry:o}=Jp(e),[s,c]=(0,O.useState)(Yf),l=n??s,u=r??c,[d,f]=(0,O.useState)(Date.now),[p,m]=(0,O.useState)(``),[h,g]=(0,O.useState)(`all`),[_,v]=(0,O.useState)(),y=(0,O.useRef)(null),b=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=setInterval(()=>f(Date.now()),5e3);return()=>clearInterval(e)},[]);let x=Xf(l,d),S=x.toMs??d,C=xg(e,x),w=Dg(i,C.retry),T=(0,O.useMemo)(()=>qh(C.rows??[],i,w),[C.rows,i,w]),E=!!i||a,D=p.trim().toLocaleLowerCase(),k=T.filter(e=>(h===`all`||e.status===h)&&(!D||`${e.connectionId} ${e.actorName} ${e.actorId} ${e.hostId??``}`.toLocaleLowerCase().includes(D))).sort((e,t)=>Number(t.status===`open`)-Number(e.status===`open`)||(t.openedAtMs??t.lastSeenMs??1/0)-(e.openedAtMs??e.lastSeenMs??1/0)),ee=Yh(T,d),A=Math.max(0,...T.filter(e=>e.status!==`open`).map(e=>Jh(e,d)?.ms??0))||ee.p95,j=Eg(k,x.fromMs,S),te=(0,O.useMemo)(()=>Og(T,i),[T,i]);return(0,O.useEffect)(()=>v(void 0),[e,l]),(0,B.jsxs)(`section`,{ref:y,className:`la-observer overview websockets`,"aria-label":`WebSocket observer`,children:[(0,B.jsxs)(`div`,{className:`overview-heading`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{children:`WebSockets`}),(0,B.jsx)(`p`,{children:E?`${ee.open.toLocaleString()} open now${C.supported?` · ${ee.total.toLocaleString()} ${ee.total===1?`session`:`sessions`} ${Qf(l)}`:``}`:`Connecting to inventory…`})]}),(0,B.jsxs)(`div`,{className:`overview-controls`,children:[(0,B.jsx)(`span`,{className:`overview-updated`,children:C.failed?`History reconnecting…`:C.updatedAt?(0,B.jsxs)(B.Fragment,{children:[`Updated `,(0,B.jsx)(`time`,{dateTime:new Date(C.updatedAt).toISOString(),children:new Date(C.updatedAt).toLocaleTimeString([],{hour12:!1})})]}):null}),C.supported&&(0,B.jsx)(tp,{value:l,onChange:u,className:`overview-range`}),(0,B.jsx)(Bn,{variant:`outline`,size:`icon`,"aria-label":`Refresh connections`,onClick:()=>{o(),C.retry()},children:(0,B.jsx)(Te,{"aria-hidden":`true`})})]})]}),a&&(0,B.jsxs)(`p`,{role:`alert`,className:`overview-alert`,children:[`Could not refresh connections.`,` `,i?`Showing the last received inventory; it may be out of date.`:`Open connections cannot be confirmed, so unfinished sessions show as lost.`,` Retrying automatically.`]}),C.failed&&(0,B.jsxs)(`p`,{role:`alert`,className:`overview-alert`,children:[`Connection history unavailable. `,C.rows?`Showing the last loaded sessions.`:`Only currently open connections are shown.`,` Retrying automatically.`]}),(0,B.jsx)(Cg,{summary:ee,ready:E,history:C.supported&&!!C.rows,range:l}),(0,B.jsxs)(`div`,{className:`socket-filterbar`,children:[(0,B.jsx)(Uh,{label:`Filter connections`,placeholder:`Filter by connection, actor, instance, or host…`,value:p,onChange:m,suggestions:te}),(0,B.jsxs)(`select`,{"aria-label":`Filter by status`,value:h,onChange:e=>g(e.target.value),children:[(0,B.jsx)(`option`,{value:`all`,children:`All statuses`}),(0,B.jsx)(`option`,{value:`open`,children:`Open`}),(0,B.jsx)(`option`,{value:`closed`,children:`Closed`}),(0,B.jsx)(`option`,{value:`lost`,children:`Lost`})]})]}),C.supported&&(0,B.jsxs)(`section`,{className:`overview-panel socket-timeline-panel`,"aria-label":`Connection timeline`,children:[(0,B.jsxs)(`div`,{className:`socket-panel-heading`,children:[(0,B.jsxs)(`h2`,{children:[`Timeline `,(0,B.jsx)(`span`,{children:k.length.toLocaleString()})]}),(0,B.jsxs)(`ul`,{className:`socket-legend`,"aria-label":`Timeline legend`,children:[(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`i`,{className:`socket-swatch socket-swatch-open`}),` Open`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`i`,{className:`socket-swatch socket-swatch-closed`}),` Closed`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`i`,{className:`socket-swatch socket-swatch-lost`}),` Lost · no disconnect recorded`]})]})]}),k.length?(0,B.jsx)(sg,{sessions:k,start:j,end:S,endLabel:x.toMs===void 0?`now`:new Date(x.toMs).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}),selected:_,onSelect:(e,t)=>{b.current=t,v(e)}}):(0,B.jsxs)(`div`,{className:`overview-empty socket-timeline-empty`,role:`status`,children:[(0,B.jsx)(`strong`,{children:kg(E,C,T.length)}),(0,B.jsx)(`p`,{children:T.length?`Try another filter or a wider time window.`:`Sessions appear here as clients connect to actors.`})]})]}),(0,B.jsxs)(`div`,{className:`overview-panel`,children:[(0,B.jsx)(`div`,{className:`overview-table-scroll`,role:`region`,"aria-label":`WebSocket connections`,tabIndex:0,children:(0,B.jsxs)(`table`,{className:`overview-table socket-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Status`}),(0,B.jsx)(`th`,{scope:`col`,children:`Connection`}),(0,B.jsx)(`th`,{scope:`col`,children:`Actor class`}),(0,B.jsx)(`th`,{scope:`col`,children:`Instance`}),(0,B.jsx)(`th`,{scope:`col`,children:`Opened`}),(0,B.jsx)(`th`,{scope:`col`,children:`Duration`}),(0,B.jsx)(`th`,{scope:`col`,children:`Messages`}),(0,B.jsx)(`th`,{scope:`col`,children:`Metadata`})]})}),(0,B.jsx)(`tbody`,{children:k.map(e=>(0,B.jsx)(wg,{session:e,now:d,longest:A,selected:_===e,onSelect:t=>{b.current=t,v(e)}},JSON.stringify([e.actorName,e.actorId,e.connectionId])))})]})}),!k.length&&(0,B.jsxs)(`div`,{className:`overview-empty`,role:`status`,children:[(0,B.jsx)(`strong`,{children:kg(E,C,T.length)}),(0,B.jsx)(`p`,{children:T.length?`Try another connection, actor, or status.`:`Open an actor WebSocket to see its connection and metadata here.`}),!!T.length&&(0,B.jsx)(Bn,{variant:`outline`,onClick:()=>{m(``),g(`all`)},children:`Clear filter`})]})]}),(0,B.jsx)(`div`,{className:`overview-data-scope`,children:(0,B.jsx)(`p`,{children:C.supported?`Sessions pair each connection’s onConnect and onDisconnect events from retained request history${C.capped?`; only the 500 most recent sessions are shown`:``}. Open connections follow the latest host report. Lost connections have no recorded disconnect and are no longer reported by a host, so their duration is a lower bound.`:`Connections are active WebSockets, not unique people. Counts follow the latest host report.`})}),(0,B.jsx)(Rp,{open:!!_,onOpenChange:e=>{e||v(void 0)},children:(0,B.jsxs)(Vp,{container:y.current,onCloseAutoFocus:e=>{e.preventDefault(),b.current?.focus()},children:[(0,B.jsx)(zp,{children:`Connection details`}),(0,B.jsx)(Bp,{children:`Identifiers, timings, and metadata for this WebSocket.`}),_&&(0,B.jsx)(Tg,{session:_,now:d,onSelectActor:t})]})})]})}function Cg({summary:e,ready:t,history:n,range:r}){return(0,B.jsxs)(`div`,{className:`overview-metrics socket-metrics`,children:[(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Open now`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Open WebSocket connections`,children:t?e.open.toLocaleString():`—`}),(0,B.jsx)(`span`,{children:`live connections`})]}),(0,B.jsx)(`div`,{className:`overview-metric-foot`,children:(0,B.jsx)(`span`,{children:`Latest host report`})})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Sessions`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`WebSocket sessions`,children:n?e.total.toLocaleString():`—`}),(0,B.jsx)(`span`,{children:r.kind===`absolute`?Zf(r):Qf(r)})]}),(0,B.jsxs)(`div`,{className:`overview-metric-foot`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:n?(e.total-e.open-e.lost).toLocaleString():`—`}),` closed`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:n?e.lost.toLocaleString():`—`}),` lost`]})]})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Session duration`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Median session duration`,children:n&&e.median!==null?Xh(e.median):`—`}),(0,B.jsx)(`span`,{children:`median`})]}),(0,B.jsxs)(`div`,{className:`overview-metric-foot`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:n&&e.p95!==null?Xh(e.p95):`—`}),` p95`]}),(0,B.jsx)(`span`,{children:`Open sessions count up to now`})]})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Messages`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`WebSocket messages`,children:n?e.messages.toLocaleString():`—`}),(0,B.jsx)(`span`,{children:`received`})]}),(0,B.jsx)(`div`,{className:`overview-metric-foot`,children:(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:n&&e.messagesPerSession!==null?e.messagesPerSession.toLocaleString(void 0,{maximumFractionDigits:1}):`—`}),` per session`]})})]})]})}function wg({session:e,now:t,longest:n,selected:r,onSelect:i}){let a=Jh(e,t),o=a&&n?Math.min(1,a.ms/n):0;return(0,B.jsxs)(`tr`,{className:`la-clickable-row`,"data-state":r?`selected`:void 0,onClick:e=>i(e.currentTarget.querySelector(`button`)??e.currentTarget),children:[(0,B.jsx)(`td`,{children:(0,B.jsxs)(`span`,{className:`socket-status socket-status-${e.status}`,children:[(0,B.jsx)(`i`,{className:`socket-swatch socket-swatch-${e.status}`,"aria-hidden":`true`}),_g(e.status)]})}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`button`,{type:`button`,className:`socket-connection`,title:e.connectionId,"aria-label":`Inspect connection ${e.connectionId}`,children:yg(e.connectionId)})}),(0,B.jsx)(`td`,{title:e.actorName,children:e.actorName}),(0,B.jsx)(`td`,{title:e.actorId,children:e.actorId}),(0,B.jsx)(`td`,{children:e.openedAtMs===null?(0,B.jsx)(`span`,{title:`The connect event is not in retained history`,children:`—`}):(0,B.jsxs)(`time`,{dateTime:new Date(e.openedAtMs).toISOString(),title:e.estimatedStart?`Approximate: first reported by the host; the connect event has not been saved yet`:new Date(e.openedAtMs).toLocaleString(),children:[e.estimatedStart?`≈ `:``,new Date(e.openedAtMs).toLocaleTimeString([],{hour12:!1})]})}),(0,B.jsx)(`td`,{children:(0,B.jsxs)(`span`,{className:`socket-duration`,children:[(0,B.jsx)(`span`,{children:vg(e,t)}),(0,B.jsx)(`i`,{className:`socket-duration-bar socket-duration-${e.status}`,"aria-hidden":`true`,children:(0,B.jsx)(`b`,{style:{width:`${o*100}%`}})})]})}),(0,B.jsx)(`td`,{children:e.messages.toLocaleString()}),(0,B.jsx)(`td`,{children:e.metadata===void 0?(0,B.jsx)(`span`,{title:`No metadata was recorded for this connection`,children:`—`}):(0,B.jsx)(`code`,{className:`socket-metadata`,title:JSON.stringify(e.metadata),children:JSON.stringify(e.metadata)})})]})}function Tg({session:e,now:t,onSelectActor:n}){let r={Status:e.status===`lost`?`Lost — no disconnect recorded`:_g(e.status),Connection:e.connectionId,"Actor class":e.actorName,"Instance ID":e.actorId,Opened:e.openedAtMs===null?`Before retained history`:`${e.estimatedStart?`≈ `:``}${new Date(e.openedAtMs).toLocaleString()}`,...e.closedAtMs===null?{}:{Closed:new Date(e.closedAtMs).toLocaleString()},...e.status===`lost`&&e.lastSeenMs!==null?{"Last activity":new Date(e.lastSeenMs).toLocaleString()}:{},Duration:vg(e,t),Messages:e.messages.toLocaleString(),Failures:e.failures.toLocaleString(),Host:e.hostId??`Unknown`};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dl`,{className:`la-request-details`,children:Object.entries(r).map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e}),(0,B.jsx)(`dd`,{children:t})]},e))}),e.metadata!==void 0&&(0,B.jsxs)(`details`,{className:`socket-metadata-details`,open:!0,children:[(0,B.jsx)(`summary`,{children:`Metadata`}),(0,B.jsx)(`pre`,{children:JSON.stringify(e.metadata,null,2)})]}),n&&(0,B.jsxs)(Bn,{variant:`outline`,onClick:()=>n(e.actorName),children:[`Open `,e.actorName]})]})}function Eg(e,t,n){let r=Math.min(...e.map(e=>e.openedAtMs??e.lastSeenMs??n)),i=Number.isFinite(r)?r-Math.max(5e3,(n-r)*.06):n-6e4;return Math.max(t??-1/0,Math.min(i,n-1e4))}function Dg(e,t){let[n,r]=(0,O.useState)(new Map),i=(0,O.useRef)(void 0);return(0,O.useEffect)(()=>{if(!e)return;let n=new Set(e.actors.flatMap(e=>e.instances.flatMap(t=>t.connections.map(n=>Kh(e.actorName,t.actorId,n.id))))),a=i.current;if(i.current=n,!a)return;let o=[...n].filter(e=>!a.has(e)),s=[...a].filter(e=>!n.has(e));if(o.length||s.length){if(o.length){let e=Date.now();r(t=>new Map([...t,...o.map(t=>[t,e])]))}t()}},[e]),n}function Og(e,t){let n=new Map;for(let e of t?.actors??[])n.set(e.actorName,new Set(e.instances.map(e=>e.actorId)));for(let t of e){let e=n.get(t.actorName)??new Set;n.set(t.actorName,e.add(t.actorId))}return[...[...n.keys()].map(e=>({group:`Actor class`,value:e,hint:`${n.get(e).size.toLocaleString()} ${n.get(e).size===1?`instance`:`instances`}`})),...[...n].flatMap(([e,t])=>[...t].map(t=>({group:`Instances`,value:t,hint:e})))]}function kg(e,t,n){return!e&&!t.rows?t.failed?`Connections unavailable`:`Loading connections…`:n?`No matching connections`:t.supported?`No WebSocket sessions`:`No active WebSockets`}var Ag=[{id:`overview`,label:`Durable Actors`,icon:ye},{id:`actors`,label:`Actors`,icon:ae},{id:`requests`,label:`Requests`,icon:ne},{id:`websockets`,label:`WebSockets`,icon:se}];function jg({client:e,toggleTheme:t}){let[n,r]=(0,O.useState)(`overview`),[i,a]=(0,O.useState)(),[o,s]=(0,O.useState)(Yf),c={timeRange:o,onTimeRangeChange:s};function l(e){a(e),r(`actors`)}return(0,B.jsxs)(`div`,{className:`console-shell`,children:[(0,B.jsx)(`a`,{className:`skip-link`,href:`#main`,children:`Skip to content`}),(0,B.jsxs)(`aside`,{className:`console-sidebar`,children:[(0,B.jsxs)(`div`,{className:`console-brand`,children:[(0,B.jsx)(P,{"aria-hidden":`true`}),(0,B.jsx)(`strong`,{children:`Terse`})]}),(0,B.jsx)(`nav`,{"aria-label":`Observability`,children:Ag.map(e=>(0,B.jsxs)(`button`,{type:`button`,"aria-current":n===e.id?`page`:void 0,onClick:()=>{a(void 0),r(e.id)},children:[(0,B.jsx)(e.icon,{"aria-hidden":`true`}),e.label]},e.id))}),(0,B.jsxs)(`div`,{className:`console-sidebar-foot`,children:[(0,B.jsx)(ae,{"aria-hidden":`true`}),(0,B.jsxs)(`span`,{children:[`Runtime inspector`,(0,B.jsx)(`small`,{children:`Read-only observability`})]})]})]}),(0,B.jsxs)(`div`,{className:`console-workspace`,children:[(0,B.jsxs)(`header`,{className:`console-topbar`,children:[(0,B.jsx)(`button`,{className:`theme-toggle`,type:`button`,onClick:t,"aria-label":`Toggle color theme`,children:(0,B.jsx)(ke,{"aria-hidden":`true`})}),(0,B.jsxs)(`a`,{href:`https://github.com/TerseAI/durable-actors#readme`,target:`_blank`,rel:`noopener noreferrer`,children:[`Docs`,(0,B.jsx)(M,{"aria-hidden":`true`})]})]}),(0,B.jsxs)(`main`,{id:`main`,tabIndex:-1,children:[n===`overview`&&(0,B.jsx)(Nm,{client:e,onSelectActor:l,...c}),n===`actors`&&(0,B.jsx)(dm,{client:e,navigation:{actorName:i,onSelectActor:a},...c}),n===`requests`&&(0,B.jsx)($p,{client:e,...c}),n===`websockets`&&(0,B.jsx)(Sg,{client:e,onSelectActor:l,...c})]})]})]})}var Mg=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},Ng=10,Pg=13,Fg=32,Ig=6;function Lg(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{maxBufferSize:t,onComment:n,onError:r,onEvent:i,onId:a,onRetry:o}=e,s=[],c=0,l=``,u,d=``,f=0,p,m=!1,h=!1,g=!1;function _(e){if(m)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l!==void 0){if(e=l+e,e===``||e===`ï`||e===`ï»`){l=e;return}l=void 0,e=e.replace(/^(?:\uFEFF|\xEF\xBB\xBF)/,``)}if((h||g)&&(e=v(e),!e))return;if(!s.length){let t=S(e);t!==``&&y(t),x();return}if(e.indexOf(`
|
|
50
|
+
`)===-1&&e.indexOf(`\r`)===-1){if(c<Ig&&!b(s.join(``)+e.slice(0,Ig-c))){s.length=0,c=0,h=!0;return}s.push(e),c+=e.length,x();return}s.push(e);let t=s.join(``);s.length=0,c=0,y(S(t)),x()}function v(e){if(e.length===0)return e;if(g)return g=!1,e.charCodeAt(0)===Ng?e.slice(1):e;let t=e.indexOf(`\r`),n=e.indexOf(`
|
|
51
|
+
`),r=t===-1?n:n===-1||t<n?t:n;return r===-1?``:r===e.length-1&&e.charCodeAt(r)===Pg?(h=!1,g=!0,``):(h=!1,e.slice(r+(e.charCodeAt(r)===Pg&&e.charCodeAt(r+1)===Ng?2:1)))}function y(e){if(e){if(e.charCodeAt(e.length-1)===Pg){C(e,0,e.length-1),g=!0;return}if(b(e)){s.push(e),c=e.length;return}h=!0}}function b(e){let t=e.charCodeAt(0);return t===58&&!!n||t===100&&Bg(e,`data`)||t===101&&Bg(e,`event`)||t===105&&Bg(e,`id`)||t===114&&Bg(e,`retry`)}function x(){t!==void 0&&(c+d.length<=t||(m=!0,s.length=0,c=0,u=void 0,d=``,f=0,p=void 0,h=!1,g=!1,r?.(new Mg(`Buffered data exceeded max buffer size of ${t} characters`,{type:`max-buffer-size-exceeded`}))))}function S(e){let t=0;if(e.indexOf(`\r`)===-1){let n=e.indexOf(`
|
|
52
52
|
`,t);for(;n!==-1;){if(t===n){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0,t=n+1,n=e.indexOf(`
|
|
53
|
-
`,t);continue}let r=e.charCodeAt(t);if(
|
|
54
|
-
`,t);continue}d=f===0?o:`${d}\n${o}`,f++}else
|
|
53
|
+
`,t);continue}let r=e.charCodeAt(t);if(Rg(e,t,r)){let r=e.charCodeAt(t+5)===Fg?t+6:t+5,o=e.slice(r,n);if(f===0&&e.charCodeAt(n+1)===Ng){u!==void 0&&a?.(u),i?.({id:u,event:p,data:o}),u=void 0,d=``,p=void 0,t=n+2,n=e.indexOf(`
|
|
54
|
+
`,t);continue}d=f===0?o:`${d}\n${o}`,f++}else zg(e,t,r)?p=e.slice(e.charCodeAt(t+6)===Fg?t+7:t+6,n)||void 0:C(e,t,n);t=n+1,n=e.indexOf(`
|
|
55
55
|
`,t)}return e.slice(t)}for(;t<e.length;){let n=e.indexOf(`\r`,t),r=e.indexOf(`
|
|
56
|
-
`,t),i=-1;if(n!==-1&&r!==-1?i=n<r?n:r:n===-1?r!==-1&&(i=r):i=n===e.length-1?-1:n,i===-1)break;C(e,t,i),t=i+1,e.charCodeAt(t-1)===
|
|
57
|
-
FROM request_history h LEFT JOIN (
|
|
58
|
-
SELECT sequence, event, started_at_ms FROM request_events
|
|
59
|
-
${n.length?`WHERE ${n.join(` AND `)}`:``}
|
|
60
|
-
ORDER BY started_at_ms DESC, sequence DESC LIMIT 101
|
|
61
|
-
) r ON 1 = 1
|
|
62
|
-
ORDER BY r.started_at_ms DESC, r.sequence DESC`,params:r}}function gm(e,t){if(e.truncated)throw Error(`History query exceeded the server result limit`);let n=e.rows[0];if(!n||typeof n.generation!=`string`||![n.watermark,n.pruned,n.total].every(e=>Number.isSafeInteger(e)&&Number(e)>=0))throw Error(`Invalid history metadata`);let r=t?JSON.parse(t):void 0,i=e.rows.filter(e=>e.sequence!==null).map(e=>{if(typeof e.event!=`string`)throw Error(`Invalid saved event`);let t={...JSON.parse(e.event),sequence:e.sequence};if(!pm(t))throw Error(`Invalid saved event`);return t}),a=i.length>mm;i.length=Math.min(i.length,mm);let o=i.at(-1),s=r?.watermark??Number(n.watermark);return{epoch:n.generation,cursor:Number(n.watermark),capacity:mm,dropped:0,evicted:0,records:i,reset:!!r&&(r.generation!==n.generation||r.pruned<Number(n.pruned)),nextCursor:a&&o?JSON.stringify({watermark:s,sequence:o.sequence,time:o.startedAtMs,generation:n.generation,pruned:Number(n.pruned)}):null}}function _m(e,t){let[n,r]=(0,O.useState)(),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(!1),c=(0,O.useRef)(()=>{});return(0,O.useEffect)(()=>{if(r(void 0),s(!1),a(!1),!t)return;let n=new AbortController,i=!1;c.current=e=>{i||n.signal.aborted||(i=!0,a(!0),s(!1),o(e))};async function o(o){try{if(!e.query)throw Error(`History is unavailable`);let i=gm(await e.query(hm(t,o),n.signal),o);if(n.signal.aborted)return;r(e=>{if(!o||!e||e.epoch!==i.epoch)return i;let t=new Map(e.records.map(e=>[e.eventId??e.sequence,e]));for(let e of i.records)t.set(e.eventId??e.sequence,e);return{...i,reset:e.reset||i.reset,records:[...t.values()]}})}catch{n.signal.aborted||s(!0)}finally{i=!1,n.signal.aborted||a(!1)}}return c.current(),()=>n.abort()},[e,t]),{page:n,loading:i,failed:o,loadOlder:()=>c.current(n?.nextCursor??void 0),retry:()=>c.current(n?.nextCursor??void 0)}}function vm({client:e,actor:t,timeRange:n,onTimeRangeChange:r}){let[i,a]=(0,O.useState)(),[o,s]=(0,O.useState)(Yf),c=n??o,l=r??s,u=_m(e,(0,O.useMemo)(()=>i?{...i,...t,...Xf(c,Date.now())}:void 0,[i,t?.actorName,t?.actorId,c])),{page:d,failed:f,retry:p}=Yp(e),[m,h]=(0,O.useState)(),[g,_]=(0,O.useState)(),v=(0,O.useRef)(null),y=(0,O.useRef)(null),b=t?`h3`:`h1`,x=i?u.page:m??d,S=d??u.page,C=(x?.records??[]).filter(e=>!t||e.actorName===t.actorName&&e.actorId===t.actorId);return(0,O.useEffect)(()=>{h(void 0),a(void 0)},[e,t?.actorName,t?.actorId]),(0,O.useEffect)(()=>_(void 0),[e,d?.epoch,i,t?.actorName,t?.actorId]),(0,B.jsxs)(`section`,{ref:v,className:`la-observer la-requests`,"aria-label":`Request observer`,children:[(0,B.jsxs)(`div`,{className:`la-observer-toolbar`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(b,{children:`Requests`}),(0,B.jsx)(`p`,{children:t?`Method calls and WebSocket events for this instance.`:`Method calls and WebSocket events, with time spent waiting and processing.`})]}),(0,B.jsxs)(`div`,{className:`la-request-actions`,children:[e.query&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Bn,{variant:i?`outline`:`secondary`,"aria-pressed":!i,onClick:()=>{a(void 0),h(void 0)},children:`Live`}),(0,B.jsx)(Bn,{variant:i?`secondary`:`outline`,"aria-pressed":!!i,onClick:()=>{i||a({})},children:`History`})]}),!i&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(Bn,{variant:`outline`,disabled:!x,onClick:()=>h(m?void 0:d),children:[m?(0,B.jsx)(Ce,{"aria-hidden":`true`}):(0,B.jsx)(xe,{"aria-hidden":`true`}),m?`Resume`:`Pause`]}),f&&(0,B.jsxs)(Bn,{variant:`outline`,onClick:p,children:[(0,B.jsx)(Te,{"aria-hidden":`true`}),`Retry`]})]})]})]}),i&&(0,B.jsx)(ym,{query:i,range:c,onRangeChange:l,loading:u.loading,onSearch:a,scoped:!!t}),i&&u.failed&&(0,B.jsxs)(`div`,{className:`la-observer-error`,role:`alert`,children:[`Request history unavailable.`,` `,(0,B.jsx)(Bn,{variant:`outline`,onClick:u.retry,children:`Retry history`})]}),!i&&f&&(0,B.jsxs)(`div`,{className:`la-observer-error`,role:`alert`,children:[`Request stream disconnected. Reconnecting… `,d?`Showing the last received requests.`:`Check your connection and runtime version.`]}),!!S?.dropped&&(0,B.jsxs)(`div`,{className:`la-observer-error`,role:`alert`,children:[S.dropped.toLocaleString(),` request traces were not delivered. This history is incomplete.`]}),S?.persistenceFailed&&(0,B.jsx)(`div`,{className:`la-observer-error`,role:`alert`,children:`Some request events could not be saved. This history may be incomplete.`}),x?.reset&&(0,B.jsx)(`div`,{className:`la-observer-error`,role:`alert`,children:`Some older events are no longer retained. Showing available history.`}),(0,B.jsxs)(`div`,{className:`la-observer-table-frame`,children:[(0,B.jsxs)(Hp,{"aria-label":i?`Saved requests`:`Recent requests`,className:`la-request-table`,children:[(0,B.jsx)(Up,{children:(0,B.jsxs)(Gp,{children:[(0,B.jsx)(Kp,{scope:`col`,children:`Time`}),(0,B.jsx)(Kp,{scope:`col`,children:`Request`}),(0,B.jsx)(Kp,{scope:`col`,children:`Instance`}),(0,B.jsx)(Kp,{scope:`col`,children:`Transport`}),(0,B.jsx)(Kp,{scope:`col`,children:`Outcome`}),(0,B.jsx)(Kp,{scope:`col`,children:`Total`}),(0,B.jsx)(Kp,{scope:`col`,children:`Queue wait`}),(0,B.jsx)(Kp,{scope:`col`,children:(0,B.jsx)(`span`,{className:`la:sr-only`,children:`Details`})})]})}),(0,B.jsx)(Wp,{children:C.map(e=>(0,B.jsxs)(Gp,{className:`la-clickable-row`,"data-state":g===e?`selected`:void 0,onClick:t=>{y.current=t.currentTarget.querySelector(`button`),_(e)},children:[(0,B.jsx)(qp,{children:(0,B.jsx)(`time`,{dateTime:new Date(e.startedAtMs).toISOString(),title:new Date(e.startedAtMs).toLocaleString(),children:i?new Date(e.startedAtMs).toLocaleString([],{hour12:!1}):new Date(e.startedAtMs).toLocaleTimeString([],{hour12:!1})})}),(0,B.jsx)(qp,{children:(0,B.jsx)(`span`,{className:`la-request-operation`,title:e.operation,children:e.operation})}),(0,B.jsx)(qp,{children:(0,B.jsxs)(`span`,{className:`la-request-actor`,title:`${e.actorName} / ${e.actorId}`,children:[e.actorName,` / `,e.actorId]})}),(0,B.jsx)(qp,{children:e.kind===`method`?`Method`:`WebSocket`}),(0,B.jsx)(qp,{children:(0,B.jsx)(lp,{variant:`outline`,className:`la-request-outcome-${e.outcome}`,children:e.outcome[0].toUpperCase()+e.outcome.slice(1)})}),(0,B.jsx)(qp,{children:xm(e.durationMs)}),(0,B.jsx)(qp,{children:e.queueWaitMs===null?(0,B.jsx)(`span`,{title:`Request did not begin processing`,children:`—`}):xm(e.queueWaitMs)}),(0,B.jsx)(qp,{children:(0,B.jsx)(Bn,{variant:`ghost`,size:`sm`,"aria-label":`Inspect ${e.operation} request`,"aria-haspopup":`dialog`,children:`Details`})})]},e.eventId??`${x.epoch}-${e.sequence}`))})]}),!C.length&&(0,B.jsxs)(`div`,{className:`la-request-empty`,role:`status`,children:[(0,B.jsx)(`strong`,{children:i?u.loading?`Loading history…`:u.failed?`History unavailable`:`No saved requests in this range`:x?`No requests yet`:f?`Requests unavailable`:`Connecting to requests…`}),(0,B.jsx)(`p`,{children:i?`Try a wider time range or fewer filters. Local history retains the latest 10,000 events.`:`Call an actor method or send a WebSocket message to see its timings.`})]})]}),i&&x?.nextCursor&&(0,B.jsx)(Bn,{className:`la-request-load-older`,variant:`outline`,disabled:u.loading,onClick:u.loadOlder,children:u.loading?`Loading…`:`Load older`}),(0,B.jsxs)(`div`,{className:`la-observer-footnote`,children:[(0,B.jsxs)(`span`,{className:`la-observer-refresh-status`,children:[!i&&(0,B.jsx)(`span`,{className:`la-observer-dot ${f?`la-observer-dot-unknown`:`la-observer-dot-live`}`}),i?`Saved history`:m?`Display paused · collection continues`:f?`Reconnecting…`:d?`Live updates`:`Connecting…`]}),(0,B.jsx)(`span`,{children:i?`${C.length.toLocaleString()} saved requests shown`:t?`${C.length} matching requests from the latest ${x?.capacity??500} on this control plane.`:`Latest ${x?.capacity??500} requests on this control plane.`})]}),!i&&!!x?.evicted&&(0,B.jsxs)(`p`,{className:`la-request-note`,children:[x.evicted.toLocaleString(),` older records have left this history window.`]}),(0,B.jsx)(`p`,{className:`la-request-note`,children:`Total includes queue wait, actor processing, and persistence. Queue wait includes the WebSocket message queue. Timings exclude the caller’s network round trip.`}),(0,B.jsx)(Rp,{open:!!g,onOpenChange:e=>{e||_(void 0)},children:(0,B.jsxs)(Vp,{container:v.current,onCloseAutoFocus:e=>{e.preventDefault(),y.current?.focus()},children:[(0,B.jsx)(zp,{children:`Request details`}),(0,B.jsx)(Bp,{children:`Full identifiers and timings for this request.`}),g&&(0,B.jsx)(bm,{record:g})]})})]})}function ym({query:e,range:t,onRangeChange:n,loading:r,onSearch:i,scoped:a}){return(0,B.jsxs)(`form`,{className:`la-request-history-filters`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget);i({actorId:String(t.get(`actorId`)||``).trim()||void 0,outcome:String(t.get(`outcome`)||``)||void 0})},children:[(0,B.jsxs)(`div`,{className:`la-request-history-range`,children:[(0,B.jsx)(`span`,{children:`Time range`}),(0,B.jsx)(tp,{value:t,onChange:n,align:`start`})]}),!a&&(0,B.jsxs)(`label`,{children:[`Actor ID`,(0,B.jsx)(Ko,{name:`actorId`,placeholder:`All actors`,maxLength:256,defaultValue:e.actorId})]}),(0,B.jsxs)(`label`,{children:[`Outcome`,(0,B.jsxs)(`select`,{className:`la-observer-select`,name:`outcome`,defaultValue:e.outcome??``,children:[(0,B.jsx)(`option`,{value:``,children:`All outcomes`}),[`completed`,`failed`,`rejected`,`rerouted`,`interrupted`].map(e=>(0,B.jsx)(`option`,{value:e,children:e[0].toUpperCase()+e.slice(1)},e))]})]}),(0,B.jsx)(Bn,{type:`submit`,variant:`outline`,disabled:r,children:`Search`})]})}function bm({record:e}){let t={Operation:e.operation,"Actor class":e.actorName,"Instance ID":e.actorId,"Request ID":e.requestId,Time:new Date(e.startedAtMs).toLocaleString(),Transport:e.kind===`method`?`Method`:`WebSocket`,Outcome:e.outcome,Total:xm(e.durationMs),"Queue wait":e.queueWaitMs===null?`Did not begin processing`:xm(e.queueWaitMs),Host:e.hostId,...e.connectionId?{Connection:e.connectionId}:{}};return(0,B.jsx)(`dl`,{className:`la-request-details`,children:Object.entries(t).map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e}),(0,B.jsx)(`dd`,{children:t})]},e))})}function xm(e){return e>=1e3?`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:2})} s`:`${e.toLocaleString(void 0,{maximumFractionDigits:1})} ms`}function Sm(e,t){let n=[`queue_wait_ms IS NOT NULL`,`outcome <> 'rerouted'`],r=[];return e.fromMs!==void 0&&(n.push(`started_at_ms >= ?`),r.push(e.fromMs)),e.toMs!==void 0&&(n.push(`started_at_ms <= ?`),r.push(e.toMs)),t!==void 0&&(n.push(`actor_name = ?`),r.push(t)),{sql:`SELECT actor_name, actor_id, COUNT(*) AS admitted, AVG(queue_wait_ms) AS average_ms, MAX(queue_wait_ms) AS max_ms
|
|
63
|
-
FROM request_events
|
|
64
|
-
WHERE ${n.join(` AND `)}
|
|
65
|
-
GROUP BY actor_name, actor_id
|
|
66
|
-
ORDER BY admitted DESC, actor_name, actor_id
|
|
67
|
-
LIMIT 500`,params:r}}function Cm(e){return e.rows.map(e=>{let t={actorName:e.actor_name,actorId:e.actor_id,admitted:e.admitted,averageMs:e.average_ms,maxMs:e.max_ms};if(typeof t.actorName!=`string`||typeof t.actorId!=`string`||!Number.isSafeInteger(t.admitted)||Number(t.admitted)<=0||![t.averageMs,t.maxMs].every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0))throw Error(`Invalid queue wait row`);return t})}function wm(e){return Om(e,()=>`all`).get(`all`)??null}function Tm(e){return Om(e,e=>e.actorName)}function Em(e,t){return Om(e.filter(e=>e.actorName===t),e=>e.actorId)}function Dm(e){return e===void 0?`—`:e>=1e3?`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:2})} s`:`${e.toLocaleString(void 0,{maximumFractionDigits:1})} ms`}function Om(e,t){let n=new Map;for(let r of e){let e=n.get(t(r))??{admitted:0,averageMs:0,maxMs:0},i=e.admitted+r.admitted;n.set(t(r),{admitted:i,averageMs:(e.averageMs*e.admitted+r.averageMs*r.admitted)/i,maxMs:Math.max(e.maxMs,r.maxMs)})}return n}function km(e,t,n){let r=Zp(e,Sm(t,n),Cm);return{supported:r.supported,rows:r.value,failed:r.failed}}function Am({client:e,className:t=``,initialActorName:n,navigation:r,timeRange:i,onTimeRangeChange:a}){let{inventory:o,loading:s,failed:c,retry:l}=Jp(e),[u,d]=(0,O.useState)(Yf),f=i??u,p=a??d,[m,h]=(0,O.useState)(n),g=r?r.actorName:m,_=r?r.onSelectActor:h,[v,y]=(0,O.useState)(``),b=(0,O.useRef)(null),x=(0,O.useRef)(n),S=(0,O.useId)(),C=o?.actors.find(e=>e.actorName===g),w=km(e,Xf(f,Date.now()),g),T=w.rows&&Tm(w.rows),E=w.rows&&g!==void 0?Em(w.rows,g):void 0,D=w.supported&&w.rows?wm(w.rows):void 0;return(0,O.useEffect)(()=>{h(n),y(``)},[e,n]),(0,O.useEffect)(()=>{x.current!==g&&b.current?.focus(),x.current=g},[g]),(0,B.jsxs)(`section`,{className:`la-observer ${t}`,"aria-label":`Actor observer`,children:[g!==void 0&&(0,B.jsxs)(`nav`,{className:`la-observer-breadcrumb`,"aria-label":`Breadcrumb`,children:[(0,B.jsx)(Bn,{variant:`link`,type:`button`,"aria-label":`Back to actors`,onClick:()=>_(void 0),children:`Actors`}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,B.jsx)(`span`,{"aria-current":`page`,children:g})]}),(0,B.jsxs)(`div`,{className:`la-observer-toolbar`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`la-observer-title`,children:(0,B.jsx)(`h1`,{ref:b,tabIndex:-1,children:g??`Actors`})}),(0,B.jsx)(`p`,{children:g===void 0?`Inspect instances, residency, and connections.`:`Inspect this actor class’s instances, residency, and connections.`})]}),(0,B.jsxs)(`div`,{className:`la-observer-actions`,children:[w.supported&&(0,B.jsx)(tp,{value:f,onChange:p}),(0,B.jsxs)(Bn,{variant:`outline`,type:`button`,disabled:s,onClick:l,children:[(0,B.jsx)(Te,{"aria-hidden":`true`,className:s?`la-observer-spin`:void 0}),s?`Refreshing…`:c?`Try again`:`Refresh`]})]})]}),c&&(0,B.jsxs)(`div`,{className:`la-observer-error`,role:`alert`,children:[(0,B.jsx)(_e,{"aria-hidden":`true`}),(0,B.jsx)(`p`,{children:o?`Could not refresh. These counts may be out of date.`:`Could not load actors. Check your connection and access, then try again.`})]}),!o&&!c&&(0,B.jsx)(jm,{}),o&&(0,B.jsxs)(B.Fragment,{children:[g===void 0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Mm,{inventory:o,queueWait:w.supported?D??null:void 0,range:f}),o.actors.length?(0,B.jsx)(Nm,{inventory:o,query:v,onQueryChange:y,onSelectActor:_,waits:w.supported?T:void 0}):(0,B.jsx)(Vm,{title:`No actors yet`,description:`Deploy your actor classes to see them here. Instance counts appear as actors are used.`})]}):C?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Mm,{inventory:{actors:[C]},actorName:g,queueWait:w.supported?D??null:void 0,range:f}),(0,B.jsx)(Pm,{client:e,id:S,actorName:g,instances:C.instances,waits:w.supported?E:void 0,range:f},g)]}):(0,B.jsx)(Vm,{title:`Actor class unavailable`,description:`This actor class is no longer in the latest inventory. Return to Actors to see available classes.`}),(0,B.jsxs)(`div`,{className:`la-observer-footnote`,children:[(0,B.jsxs)(`span`,{className:`la-observer-refresh-status`,children:[(0,B.jsx)(`span`,{className:`la-observer-dot ${c?`la-observer-dot-unknown`:e.watchActors?`la-observer-dot-live`:``}`}),c?`Reconnecting…`:e.watchActors?`Live updates`:`Auto-refresh every 5s`]}),(0,B.jsx)(`span`,{children:e.watchActors?`Changes stream from the control plane.`:`Counts follow the latest host heartbeat.`})]})]})]})}function jm(){return(0,B.jsxs)(`div`,{className:`la-observer-skeleton`,role:`status`,"aria-label":`Loading actors`,children:[(0,B.jsx)(`span`,{className:`la:sr-only`,children:`Loading actors…`}),(0,B.jsx)(`div`,{}),(0,B.jsx)(`div`,{}),(0,B.jsx)(`div`,{})]})}function Mm({inventory:e,actorName:t,queueWait:n,range:r}){let i=e.actors.reduce((e,t)=>({live:e.live+t.live,dormant:e.dormant+t.dormant,unknown:e.unknown+t.unknown}),{live:0,dormant:0,unknown:0});return(0,B.jsxs)(`dl`,{className:`la-observer-summary`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Total instances`}),(0,B.jsx)(`dd`,{"aria-label":`Total instances`,children:(i.live+i.dormant+i.unknown).toLocaleString()}),(0,B.jsx)(`p`,{children:t===void 0?`${e.actors.length} actor ${e.actors.length===1?`type`:`types`}`:`In this actor class`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`dt`,{children:[(0,B.jsx)(`span`,{className:`la-observer-dot la-observer-dot-live`}),`Live`]}),(0,B.jsx)(`dd`,{"aria-label":`Live instances`,children:i.live.toLocaleString()}),(0,B.jsx)(`p`,{children:`Loaded in memory`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`dt`,{children:[(0,B.jsx)(`span`,{className:`la-observer-dot`}),`Dormant`]}),(0,B.jsx)(`dd`,{"aria-label":`Dormant instances`,children:i.dormant.toLocaleString()}),(0,B.jsx)(`p`,{children:`Currently unloaded`})]}),i.unknown>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`dt`,{children:[(0,B.jsx)(`span`,{className:`la-observer-dot la-observer-dot-unknown`}),`Unknown`]}),(0,B.jsx)(`dd`,{"aria-label":`Unknown instances`,children:i.unknown.toLocaleString()}),(0,B.jsx)(`p`,{children:`Awaiting host report`})]}),n!==void 0&&(0,B.jsxs)(`div`,{className:`la-observer-queue-wait`,children:[(0,B.jsx)(`dt`,{children:`Avg queue wait`}),(0,B.jsx)(`dd`,{"aria-label":`Average queue wait`,children:Dm(n?.averageMs)}),(0,B.jsx)(`p`,{children:n?`Max ${Dm(n.maxMs)} · ${n.admitted.toLocaleString()} admitted ${Qf(r)}`:`No admitted requests ${Qf(r)}`})]})]})}function Nm({inventory:e,query:t,onQueryChange:n,onSelectActor:r,waits:i}){let a=e.actors.some(e=>e.unknown>0),o=e.actors.filter(e=>Hm(e.actorName,t)).sort((e,t)=>Number(t.live>0)-Number(e.live>0));return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`la-observer-list-toolbar`,children:[(0,B.jsxs)(`h2`,{children:[`Actor names `,(0,B.jsx)(lp,{children:e.actors.length})]}),(0,B.jsx)(Bm,{label:`Search actors`,placeholder:`Search actors…`,value:t,onChange:n})]}),(0,B.jsx)(`div`,{className:`la-observer-table-frame`,children:o.length?(0,B.jsxs)(Hp,{"aria-label":`Actor instance counts`,className:`la-observer-table`,children:[(0,B.jsx)(Up,{children:(0,B.jsxs)(Gp,{children:[(0,B.jsx)(Kp,{scope:`col`,children:`Actor`}),(0,B.jsx)(Kp,{scope:`col`,children:`Live`}),(0,B.jsx)(Kp,{scope:`col`,children:`Dormant`}),a&&(0,B.jsx)(Kp,{scope:`col`,children:`Unknown`}),(0,B.jsx)(Kp,{scope:`col`,children:`Total`}),i&&(0,B.jsx)(Kp,{scope:`col`,className:`la-observer-wait-cell`,children:`Avg queue wait`})]})}),(0,B.jsx)(Wp,{children:o.map(e=>(0,B.jsxs)(Gp,{className:`la-clickable-row`,onClick:()=>r(e.actorName),children:[(0,B.jsx)(qp,{className:`la-observer-name`,children:(0,B.jsxs)(Bn,{variant:`ghost`,type:`button`,className:`la-observer-actor-button la-observer-class-button`,children:[(0,B.jsx)(ae,{className:`la-observer-type-icon`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{children:e.actorName})]})}),(0,B.jsx)(qp,{children:(0,B.jsx)(`span`,{className:e.live>0?`la-observer-live`:void 0,children:e.live.toLocaleString()})}),(0,B.jsx)(qp,{children:e.dormant.toLocaleString()}),a&&(0,B.jsx)(qp,{children:e.unknown.toLocaleString()}),(0,B.jsx)(qp,{children:(e.live+e.dormant+e.unknown).toLocaleString()}),i&&(0,B.jsx)(qp,{className:`la-observer-wait-cell`,children:(0,B.jsx)(Fm,{stats:i.get(e.actorName)})})]},e.actorName))})]}):(0,B.jsx)(Vm,{title:`No matching actors`,description:`Try a different actor name.`,action:`Clear search`,onReset:()=>n(``)})}),a&&(0,B.jsxs)(`p`,{className:`la-observer-unknown`,children:[(0,B.jsx)(_e,{"aria-hidden":`true`}),`Some hosts have not reported which instances are loaded. Their counts are shown as unknown.`]})]})}function Pm({client:e,id:t,actorName:n,instances:r,waits:i,range:a}){let[o,s]=(0,O.useState)(``),[c,l]=(0,O.useState)(`all`),[u,d]=(0,O.useState)(),f=`${t}-connections`,p=r.filter(e=>Hm(e.actorId,o)&&(c===`all`||e.status===c));p.sort((e,t)=>Number(t.status===`live`)-Number(e.status===`live`));let m=r.find(e=>e.actorId===u),h=(0,O.useRef)(null);return(0,O.useEffect)(()=>{h.current?.focus()},[u]),u===void 0?(0,B.jsxs)(`section`,{id:t,className:`la-observer-instances`,"aria-labelledby":`${t}-heading`,children:[(0,B.jsx)(`div`,{className:`la-observer-instances-heading`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h2`,{ref:h,tabIndex:-1,id:`${t}-heading`,children:[n,` instances `,(0,B.jsx)(lp,{"aria-hidden":`true`,children:r.length.toLocaleString()})]}),(0,B.jsx)(`p`,{children:`Select an instance to inspect its waiting line, requests, and WebSocket connections.`})]})}),r.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`la-observer-filters`,children:[(0,B.jsx)(Bm,{label:`Search instances`,placeholder:`Search instance IDs…`,value:o,onChange:s}),(0,B.jsxs)(`select`,{className:`la-observer-select`,"aria-label":`Instance state`,value:c,onChange:e=>l(e.target.value),children:[(0,B.jsx)(`option`,{value:`all`,children:`All states`}),(0,B.jsx)(`option`,{value:`live`,children:`Live`}),(0,B.jsx)(`option`,{value:`dormant`,children:`Dormant`}),(0,B.jsx)(`option`,{value:`unknown`,children:`Unknown`})]})]}),(0,B.jsx)(`div`,{className:`la-observer-table-frame`,children:p.length?(0,B.jsxs)(Hp,{"aria-label":`${n} instances`,className:`la-observer-instance-table`,children:[(0,B.jsx)(Up,{children:(0,B.jsxs)(Gp,{children:[(0,B.jsx)(Kp,{scope:`col`,children:`Instance`}),(0,B.jsx)(Kp,{scope:`col`,children:`State`}),(0,B.jsx)(Kp,{scope:`col`,children:`Connections`}),i&&(0,B.jsx)(Kp,{scope:`col`,className:`la-observer-wait-cell`,children:`Avg queue wait`}),(0,B.jsx)(Kp,{scope:`col`,className:`la-observer-waiting-cell`,children:`Waiting`})]})}),(0,B.jsx)(Wp,{children:p.map(e=>(0,B.jsxs)(Gp,{className:`la-clickable-row`,onClick:()=>d(e.actorId),children:[(0,B.jsx)(qp,{className:`la-observer-instance-id`,children:(0,B.jsx)(Bn,{variant:`ghost`,type:`button`,className:`la-observer-actor-button`,children:(0,B.jsx)(`span`,{children:e.actorId})})}),(0,B.jsx)(qp,{children:(0,B.jsxs)(lp,{variant:`outline`,className:`la-observer-status-${e.status}`,children:[(0,B.jsx)(`span`,{className:`la-observer-dot la-observer-dot-${e.status}`}),Um(e.status)]})}),(0,B.jsx)(qp,{children:e.connections.length.toLocaleString()}),i&&(0,B.jsx)(qp,{className:`la-observer-wait-cell`,children:(0,B.jsx)(Fm,{stats:i.get(e.actorId)})}),(0,B.jsx)(qp,{className:`la-observer-waiting-cell`,children:(0,B.jsx)(Rm,{waiting:e.waiting,compact:!0})})]},e.actorId))})]}):(0,B.jsx)(Vm,{title:`No matching instances`,description:`Try another instance ID or state.`,action:`Clear filters`,onReset:()=>{s(``),l(`all`)}})}),(0,B.jsx)(`p`,{className:`la-observer-connection-note`,children:`Connections are active WebSocket connections, not unique people.`})]}):(0,B.jsxs)(`p`,{className:`la-observer-instance-empty`,role:`status`,children:[`No `,n,` instances have been created yet.`]})]}):(0,B.jsxs)(`section`,{className:`la-observer-instance-detail`,"aria-label":`${n} / ${u}`,children:[(0,B.jsx)(Bn,{variant:`link`,"aria-label":`Back to instances`,onClick:()=>d(void 0),children:`Back to instances`}),(0,B.jsxs)(`div`,{className:`la-observer-instance-heading`,children:[(0,B.jsx)(`h2`,{ref:h,tabIndex:-1,children:u}),m&&(0,B.jsx)(lp,{variant:`outline`,className:`la-observer-status-${m.status}`,children:Um(m.status)})]}),!m&&(0,B.jsx)(`p`,{role:`status`,children:`This instance is no longer in the current inventory. Its retained requests are still available below.`}),i&&(0,B.jsx)(Im,{stats:i.get(u),range:a}),m&&(0,B.jsx)(Lm,{waiting:m.waiting}),e.watchRequests||e.query?(0,B.jsx)(vm,{client:e,actor:{actorName:n,actorId:u},timeRange:a},u):(0,B.jsxs)(`section`,{children:[(0,B.jsx)(`h3`,{children:`Requests`}),(0,B.jsx)(`p`,{children:`Request timings are unavailable for this connection.`})]}),m&&(0,B.jsx)(zm,{id:f,actorId:m.actorId,connections:m.connections})]})}function Fm({stats:e}){return e?(0,B.jsxs)(`span`,{className:`la-observer-wait`,title:`Average of ${e.admitted.toLocaleString()} admitted requests in the selected time range; longest wait ${Dm(e.maxMs)}`,children:[Dm(e.averageMs),(0,B.jsxs)(`small`,{children:[`max `,Dm(e.maxMs)]})]}):(0,B.jsx)(`span`,{title:`No admitted requests in the selected time range`,children:`—`})}function Im({stats:e,range:t}){return(0,B.jsxs)(`section`,{className:`la-observer-queue-wait-detail`,"aria-label":`Queue wait`,children:[(0,B.jsx)(`h3`,{children:`Queue wait`}),(0,B.jsx)(`p`,{children:e?`Time requests spent waiting to enter this actor ${Qf(t)}.`:`No requests were admitted to this actor ${Qf(t)}.`}),e&&(0,B.jsxs)(`dl`,{className:`la-observer-summary la-observer-summary-compact`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Average`}),(0,B.jsx)(`dd`,{"aria-label":`Average queue wait`,children:Dm(e.averageMs)}),(0,B.jsx)(`p`,{children:`Per admitted request`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Longest`}),(0,B.jsx)(`dd`,{"aria-label":`Longest queue wait`,children:Dm(e.maxMs)}),(0,B.jsx)(`p`,{children:`Single request`})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`Admitted`}),(0,B.jsx)(`dd`,{"aria-label":`Admitted requests`,children:e.admitted.toLocaleString()}),(0,B.jsx)(`p`,{children:`Requests that entered the actor`})]})]})]})}function Lm({waiting:e}){return(0,B.jsxs)(`section`,{className:`la-observer-waiting`,"aria-label":`Waiting requests`,children:[(0,B.jsxs)(`h3`,{children:[`Waiting requests`,e!=null&&` (${e.length})`]}),(0,B.jsx)(`p`,{children:e==null?`This host has not reported its waiting line.`:e.length?`Next to run first. Operations leave this line when they start.`:`No requests waiting.`}),!!e?.length&&(0,B.jsx)(Rm,{waiting:e})]})}function Rm({waiting:e,compact:t=!1}){if(e==null)return(0,B.jsx)(`span`,{title:`Queue reporting is unavailable`,children:`Unavailable`});if(!e.length)return(0,B.jsx)(`span`,{className:`la-observer-queue-empty`,children:`None`});let n=t?e.slice(0,3):e;return(0,B.jsxs)(`ol`,{className:`la-observer-queue${t?` la-observer-queue-compact`:``}`,"aria-label":`${e.length} waiting requests, next to run first`,children:[n.map((e,n)=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(lp,{variant:`outline`,className:`la-observer-queue-bubble`,title:e.operation,children:[!t&&(0,B.jsx)(`span`,{className:`la-observer-queue-position`,children:n+1}),(0,B.jsx)(`span`,{className:`la-observer-queue-operation`,children:e.operation})]})},e.id)),t&&e.length>n.length&&(0,B.jsx)(`li`,{children:(0,B.jsxs)(lp,{"aria-label":`${e.length-n.length} more waiting requests`,children:[`+`,e.length-n.length]})})]})}function zm({id:e,actorId:t,connections:n}){return(0,B.jsxs)(`section`,{id:e,className:`la-observer-connections`,"aria-labelledby":`${e}-heading`,children:[(0,B.jsx)(`div`,{className:`la-observer-instances-heading`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h3`,{id:`${e}-heading`,children:[t,` WebSockets `,(0,B.jsx)(lp,{"aria-hidden":`true`,children:n.length.toLocaleString()})]}),(0,B.jsx)(`p`,{children:`${n.length.toLocaleString()} active ${n.length===1?`connection`:`connections`}`})]})}),n.length?(0,B.jsx)(`div`,{className:`la-observer-table-frame`,children:(0,B.jsxs)(Hp,{"aria-label":`${t} WebSocket connections`,className:`la-observer-connection-table`,children:[(0,B.jsx)(Up,{children:(0,B.jsxs)(Gp,{children:[(0,B.jsx)(Kp,{scope:`col`,children:`Socket`}),(0,B.jsx)(Kp,{scope:`col`,children:`Metadata`})]})}),(0,B.jsx)(Wp,{children:n.map(e=>(0,B.jsxs)(Gp,{children:[(0,B.jsx)(qp,{className:`la-observer-socket-id`,children:e.id}),(0,B.jsx)(qp,{children:(0,B.jsx)(`pre`,{children:JSON.stringify(e.metadata,null,2)})})]},e.id))})]})}):(0,B.jsxs)(`div`,{className:`la-observer-no-connections`,role:`status`,children:[(0,B.jsx)(je,{"aria-hidden":`true`}),(0,B.jsx)(`p`,{children:`No active WebSocket connections.`})]})]})}function Bm({label:e,placeholder:t,value:n,onChange:r}){return(0,B.jsxs)(`div`,{className:`la-observer-search`,children:[(0,B.jsx)(De,{"aria-hidden":`true`}),(0,B.jsx)(Ko,{type:`search`,"aria-label":e,placeholder:t,value:n,onInput:e=>r(e.currentTarget.value)})]})}function Vm({title:e,description:t,action:n,onReset:r}){return(0,B.jsxs)(`div`,{className:`la-observer-empty`,children:[(0,B.jsx)(De,{"aria-hidden":`true`}),(0,B.jsx)(`h3`,{children:e}),(0,B.jsx)(`p`,{children:t}),n&&(0,B.jsx)(Bn,{type:`button`,variant:`outline`,onClick:r,children:n})]})}function Hm(e,t){return e.toLocaleLowerCase().includes(t.trim().toLocaleLowerCase())}function Um(e){return e[0].toUpperCase()+e.slice(1)}function Wm(e){let t=e.filter(e=>e.outcome!==`rerouted`);return{count:e.length,success:t.length?100*t.filter(e=>e.outcome===`completed`).length/t.length:null,p95:Jm(t.map(e=>e.durationMs))}}function Gm(e,t,n){return e.filter(e=>e.startedAtMs>=(t.fromMs??0)&&e.startedAtMs<=(t.toMs??n))}function Km(e){return e.actors.reduce((e,t)=>({live:e.live+t.live,dormant:e.dormant+t.dormant,unknown:e.unknown+t.unknown,connections:e.connections+t.instances.reduce((e,t)=>e+t.connections.length,0)}),{live:0,dormant:0,unknown:0,connections:0})}function qm(e){return Jm(e.filter(e=>e.outcome!==`rerouted`&&e.queueWaitMs!==null).map(e=>e.queueWaitMs))}function Jm(e){return e.length?e.sort((e,t)=>e-t)[Math.ceil(e.length*.95)-1]:null}function Ym(e){let t=[],n=[];return e.fromMs!==void 0&&(t.push(`started_at_ms >= ?`),n.push(e.fromMs)),e.toMs!==void 0&&(t.push(`started_at_ms <= ?`),n.push(e.toMs)),{sql:`WITH scoped AS (
|
|
68
|
-
SELECT actor_name, outcome, duration_ms, queue_wait_ms FROM request_events
|
|
69
|
-
${t.length?`WHERE ${t.join(` AND `)}`:``}
|
|
70
|
-
), events AS (
|
|
71
|
-
SELECT actor_name, outcome, duration_ms, queue_wait_ms FROM scoped
|
|
72
|
-
UNION ALL
|
|
73
|
-
SELECT '' AS actor_name, outcome, duration_ms, queue_wait_ms FROM scoped
|
|
74
|
-
), attempts AS (
|
|
75
|
-
SELECT actor_name, outcome, duration_ms, queue_wait_ms,
|
|
76
|
-
ROW_NUMBER() OVER (PARTITION BY actor_name ORDER BY duration_ms) AS duration_rank,
|
|
77
|
-
COUNT(*) OVER (PARTITION BY actor_name) AS attempts,
|
|
78
|
-
ROW_NUMBER() OVER (PARTITION BY actor_name ORDER BY queue_wait_ms IS NULL, queue_wait_ms) AS queue_rank,
|
|
79
|
-
COUNT(queue_wait_ms) OVER (PARTITION BY actor_name) AS queued
|
|
80
|
-
FROM events WHERE outcome <> 'rerouted'
|
|
81
|
-
), summary AS (
|
|
82
|
-
SELECT actor_name, MAX(attempts) AS attempts, SUM(outcome = 'completed') AS completed,
|
|
83
|
-
MAX(CASE WHEN duration_rank = MAX(1, (attempts * 95 + 99) / 100) THEN duration_ms END) AS p95_duration_ms,
|
|
84
|
-
MAX(CASE WHEN queued > 0 AND queue_rank = MAX(1, (queued * 95 + 99) / 100) THEN queue_wait_ms END) AS p95_queue_wait_ms
|
|
85
|
-
FROM attempts GROUP BY actor_name
|
|
86
|
-
)
|
|
87
|
-
SELECT e.actor_name, COUNT(*) AS total, COALESCE(s.attempts, 0) AS attempts, COALESCE(s.completed, 0) AS completed, s.p95_duration_ms, s.p95_queue_wait_ms
|
|
88
|
-
FROM events e LEFT JOIN summary s ON s.actor_name = e.actor_name
|
|
89
|
-
GROUP BY e.actor_name
|
|
90
|
-
ORDER BY e.actor_name
|
|
91
|
-
LIMIT 500`,params:n}}function Xm(e){let t=e.rows.map(e=>{let{actor_name:t,total:n,attempts:r,completed:i,p95_duration_ms:a,p95_queue_wait_ms:o}=e;if(typeof t!=`string`||![n,r,i].every(e=>Number.isSafeInteger(e)&&Number(e)>=0)||Number(r)>Number(n)||Number(i)>Number(r)||![a,o].every(e=>e==null||typeof e==`number`&&Number.isFinite(e)&&e>=0))throw Error(`Invalid overview metrics row`);return{actorName:t,count:Number(n),success:Number(r)?100*Number(i)/Number(r):null,p95:typeof a==`number`?a:null,queueP95:typeof o==`number`?o:null}});return{total:t.find(e=>e.actorName===``)??{actorName:``,count:0,success:null,p95:null,queueP95:null},classes:t.filter(e=>e.actorName!==``)}}function Zm(e){let t=new Map;for(let n of e)t.set(n.actorName,[...t.get(n.actorName)??[],n]);let n=(e,t)=>({actorName:e,...Wm(t),queueP95:qm(t)});return{total:n(``,e),classes:[...t].map(([e,t])=>n(e,t))}}function Qm({client:e,onSelectActor:t,timeRange:n,onTimeRangeChange:r}){let i=Jp(e),[a,o]=(0,O.useState)(Yf),s=n??a,c=r??o,[l,u]=(0,O.useState)(Date.now);(0,O.useEffect)(()=>{let e=setInterval(()=>u(Date.now()),1e4);return()=>clearInterval(e)},[]);let d=Xf(s,l),f=Zp(e,Ym(d),Xm),p=Yp(e,!f.supported),m=p.page?Zm(Gm(p.page.records,d,Math.max(l,Date.now()))):void 0,h=f.supported?f.value:m,g=f.supported?f.failed:p.failed;return(0,B.jsxs)(`section`,{className:`la-observer overview`,"aria-label":`Runtime overview`,children:[(0,B.jsxs)(`div`,{className:`overview-heading`,children:[(0,B.jsx)(`h1`,{children:`Durable Actors`}),(0,B.jsxs)(`div`,{className:`overview-controls`,children:[(0,B.jsx)(`span`,{className:`overview-updated`,children:i.failed?`Inventory reconnecting…`:i.updatedAt?(0,B.jsxs)(B.Fragment,{children:[`Last inventory update `,(0,B.jsx)(`time`,{dateTime:new Date(i.updatedAt).toISOString(),children:new Date(i.updatedAt).toLocaleTimeString([],{hour12:!1})})]}):`Connecting…`}),(0,B.jsx)(tp,{value:s,onChange:c,className:`overview-range`}),(0,B.jsx)(Bn,{variant:`outline`,size:`icon`,"aria-label":`Refresh overview`,onClick:()=>{i.retry(),f.retry(),p.retry()},children:(0,B.jsx)(Te,{"aria-hidden":`true`})})]})]}),i.failed&&(0,B.jsxs)(`p`,{className:`overview-alert`,role:`alert`,children:[`Inventory unavailable. `,i.inventory?`Showing the last received counts; they may be out of date.`:`Check your connection and access.`,` Retrying automatically.`]}),g&&(0,B.jsxs)(`p`,{className:`overview-alert`,role:`alert`,children:[f.supported?`Request history unavailable.`:`Request stream unavailable.`,` `,h?`Showing the last received metrics.`:`Request metrics are not available yet.`,` `,`Retrying automatically.`]}),(0,B.jsx)($m,{inventory:i.inventory,metrics:h,range:s}),(0,B.jsx)(eh,{inventory:i.inventory,metrics:h,failed:i.failed,onSelectActor:t}),(0,B.jsx)(ih,{page:f.supported?void 0:p.page,range:s,saved:f.supported})]})}function $m({inventory:e,metrics:t,range:n}){let r=e?Km(e):void 0,i=r?r.live+r.dormant+r.unknown:void 0,a=t?.total;return(0,B.jsxs)(`div`,{className:`overview-metrics`,children:[(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Actor instances`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Actor instances`,children:oh(i)}),(0,B.jsx)(`span`,{children:e?`${e.actors.length} actor ${e.actors.length===1?`class`:`classes`}`:`Waiting for inventory`})]}),(0,B.jsx)(`div`,{className:`overview-residency`,"aria-hidden":`true`,children:r&&Object.entries(r).filter(([e])=>e!==`connections`).map(([e,t])=>(0,B.jsx)(`span`,{className:`residency-${e}`,style:{flexGrow:t}},e))}),(0,B.jsxs)(`div`,{className:`overview-metric-foot`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:oh(r?.live)}),` live`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:oh(r?.dormant)}),` dormant`]}),!!r?.unknown&&(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:oh(r.unknown)}),` unknown`]})]})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Requests`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Retained requests`,children:oh(a?.count)}),(0,B.jsx)(`span`,{children:Qf(n)})]}),(0,B.jsxs)(`div`,{className:`overview-health`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(nh,{value:a?.success,kind:`success`}),` success`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(nh,{value:a?.p95,kind:`latency`}),` p95 latency`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:sh(a?.queueP95)}),` p95 queue wait`]})]})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`WebSocket connections`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Open WebSocket connections`,children:oh(r?.connections)}),(0,B.jsx)(`span`,{children:`open`})]}),(0,B.jsxs)(`div`,{className:`overview-health`,children:[(0,B.jsx)(`span`,{children:`Current inventory snapshot`}),(0,B.jsx)(`span`,{children:`Active sockets`})]})]})]})}function eh({inventory:e,metrics:t,failed:n,onSelectActor:r}){let[i,a]=(0,O.useState)(``),[o,s]=(0,O.useState)(`all`),c=e?.actors.filter(e=>e.actorName.toLocaleLowerCase().includes(i.trim().toLocaleLowerCase())&&(o===`all`||e[o]>0)).sort((e,t)=>Number(t.live>0)-Number(e.live>0))??[];return(0,B.jsxs)(`section`,{"aria-label":`Actor classes`,children:[(0,B.jsxs)(`div`,{className:`overview-section-heading`,children:[(0,B.jsxs)(`h2`,{children:[`Actor classes `,(0,B.jsx)(`span`,{children:oh(e?.actors.length)})]}),(0,B.jsx)(rh,{})]}),(0,B.jsxs)(`div`,{className:`overview-panel`,children:[(0,B.jsxs)(`div`,{className:`overview-filterbar`,children:[(0,B.jsxs)(`div`,{className:`overview-search`,children:[(0,B.jsx)(De,{"aria-hidden":`true`}),(0,B.jsx)(Ko,{"aria-label":`Filter actor classes`,placeholder:`Filter actor classes…`,value:i,onInput:e=>a(e.currentTarget.value)})]}),(0,B.jsxs)(`select`,{"aria-label":`Filter by residency`,value:o,onChange:e=>s(e.target.value),children:[(0,B.jsx)(`option`,{value:`all`,children:`All states`}),(0,B.jsx)(`option`,{value:`live`,children:`Live instances`}),(0,B.jsx)(`option`,{value:`dormant`,children:`Dormant instances`}),(0,B.jsx)(`option`,{value:`unknown`,children:`Unknown residency`})]})]}),(0,B.jsx)(`div`,{className:`overview-table-scroll`,role:`region`,"aria-label":`Actor class metrics`,tabIndex:0,children:(0,B.jsxs)(`table`,{className:`overview-table`,children:[(0,B.jsxs)(`colgroup`,{children:[(0,B.jsx)(`col`,{className:`overview-class-column`}),(0,B.jsx)(`col`,{span:6})]}),(0,B.jsxs)(`thead`,{children:[(0,B.jsxs)(`tr`,{className:`overview-groups`,children:[(0,B.jsx)(`th`,{scope:`colgroup`,colSpan:2,children:`Actors`}),(0,B.jsx)(`th`,{scope:`colgroup`,colSpan:4,children:`Requests`}),(0,B.jsx)(`th`,{scope:`colgroup`,children:`WebSockets`})]}),(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Class`}),(0,B.jsx)(`th`,{scope:`col`,children:`Instances`}),(0,B.jsx)(`th`,{scope:`col`,children:`Total`}),(0,B.jsx)(`th`,{scope:`col`,children:`Success`}),(0,B.jsx)(`th`,{scope:`col`,children:`p95 latency`}),(0,B.jsx)(`th`,{scope:`col`,children:`p95 queue wait`}),(0,B.jsx)(`th`,{scope:`col`,children:`Connected`})]})]}),(0,B.jsx)(`tbody`,{children:c.map(e=>(0,B.jsx)(th,{actor:e,metrics:t&&(t.classes.find(t=>t.actorName===e.actorName)??ah(e.actorName)),onSelectActor:r},e.actorName))})]})}),!c.length&&(0,B.jsxs)(`div`,{className:`overview-empty`,role:`status`,children:[(0,B.jsx)(`strong`,{children:e?e.actors.length?`No matching actor classes`:`No actors yet`:n?`Inventory unavailable`:`Loading actor classes…`}),(0,B.jsx)(`p`,{children:e?.actors.length?`Try another class name or residency state.`:`Actor classes appear after deployment.`}),!!e?.actors.length&&(0,B.jsx)(Bn,{variant:`outline`,onClick:()=>{a(``),s(`all`)},children:`Clear filters`})]})]})]})}function th({actor:e,metrics:t,onSelectActor:n}){return(0,B.jsxs)(`tr`,{className:`la-clickable-row`,onClick:()=>n(e.actorName),children:[(0,B.jsx)(`td`,{children:(0,B.jsx)(Bn,{variant:`ghost`,type:`button`,className:`overview-class-link`,"aria-label":`Inspect ${e.actorName}`,children:(0,B.jsx)(`span`,{title:e.actorName,children:e.actorName})})}),(0,B.jsx)(`td`,{children:oh(e.live+e.dormant+e.unknown)}),(0,B.jsx)(`td`,{children:oh(t?.count)}),(0,B.jsx)(`td`,{children:(0,B.jsx)(nh,{value:t?.success,kind:`success`})}),(0,B.jsx)(`td`,{children:(0,B.jsx)(nh,{value:t?.p95,kind:`latency`})}),(0,B.jsx)(`td`,{children:sh(t?.queueP95)}),(0,B.jsx)(`td`,{children:oh(e.instances.reduce((e,t)=>e+t.connections.length,0))})]})}function nh({value:e,kind:t}){if(e==null)return(0,B.jsx)(`span`,{title:`No retained execution attempts`,children:`—`});let n=t===`success`?e<95?`bad`:e<99?`warn`:`good`:e>100?`bad`:`good`;return(0,B.jsxs)(`span`,{className:`overview-signal signal-${n}`,title:n===`bad`?`Critical threshold breached`:n===`warn`?`Warning threshold breached`:`Within threshold`,children:[n!==`good`&&(0,B.jsx)(`span`,{"aria-hidden":`true`,children:n===`warn`?`!`:`×`}),t===`success`?`${e.toLocaleString(void 0,{maximumFractionDigits:2})}%`:sh(e)]})}function rh(){return(0,B.jsxs)(`details`,{className:`overview-thresholds`,children:[(0,B.jsxs)(`summary`,{children:[(0,B.jsxs)(`span`,{className:`threshold-dots`,"aria-hidden":`true`,children:[(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{}),(0,B.jsx)(`i`,{})]}),`Thresholds`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`strong`,{children:`Display thresholds`}),(0,B.jsx)(`p`,{children:`Success: warning below 99%; critical below 95%.`}),(0,B.jsx)(`p`,{children:`Latency: critical when p95 exceeds 100 ms.`}),(0,B.jsx)(`p`,{children:`Reroutes are excluded from success and latency. Queue wait has no health threshold.`})]})]})}function ih({page:e,range:t,saved:n}){return(0,B.jsxs)(`div`,{className:`overview-data-scope`,children:[(0,B.jsx)(`p`,{children:n?`Request metrics cover every retained request ${Qf(t)}${t.kind===`relative`?` (refreshed every 10 seconds)`:``}. Inventory counts are current snapshots.`:`Request metrics cover the latest ${e?.capacity??500} retained traces within the selected window. Inventory counts are current snapshots.`}),!!e?.dropped&&(0,B.jsxs)(`p`,{role:`alert`,children:[oh(e.dropped),` traces were not delivered. Request metrics are incomplete.`]}),e?.persistenceFailed&&(0,B.jsx)(`p`,{role:`alert`,children:`Some request events could not be saved. This history may be incomplete.`}),!!e?.evicted&&(0,B.jsx)(`p`,{children:`Earlier traces have expired; these metrics do not represent the full time window.`})]})}function ah(e){return{actorName:e,count:0,success:null,p95:null,queueP95:null}}function oh(e){return e===void 0?`—`:e.toLocaleString()}function sh(e){return e==null?`—`:`${e.toLocaleString(void 0,{maximumFractionDigits:1})} ms`}var ch=1,lh=.9,uh=.8,dh=.17,fh=.1,ph=.999,mh=.9999,hh=.99,gh=/[\\\/_+.#"@\[\(\{&]/,_h=/[\\\/_+.#"@\[\(\{&]/g,vh=/[\s-]/,yh=/[\s-]/g;function bh(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?ch:hh;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=bh(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=ch:gh.test(e.charAt(l-1))?(d*=uh,p=e.slice(i,l-1).match(_h),p&&i>0&&(d*=ph**+p.length)):vh.test(e.charAt(l-1))?(d*=lh,m=e.slice(i,l-1).match(yh),m&&i>0&&(d*=ph**+m.length)):(d*=dh,i>0&&(d*=ph**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=mh)),(d<fh&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=bh(e,t,n,r,l+1,a+2,o),f*fh>d&&(d=f*fh)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function xh(e){return e.toLowerCase().replace(yh,` `)}function Sh(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,bh(e,t,xh(e),xh(t),0,0,{})}var Ch=`[cmdk-group=""]`,wh=`[cmdk-group-items=""]`,Th=`[cmdk-group-heading=""]`,Eh=`[cmdk-item=""]`,Dh=`${Eh}:not([aria-disabled="true"])`,Oh=`cmdk-item-select`,kh=`data-value`,Ah=(e,t,n)=>Sh(e,t,n),jh=O.createContext(void 0),Mh=()=>O.useContext(jh),Nh=O.createContext(void 0),Ph=()=>O.useContext(Nh),Fh=O.createContext(void 0),Ih=O.forwardRef((e,t)=>{let n=Xh(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Xh(()=>new Set),i=Xh(()=>new Map),a=Xh(()=>new Map),o=Xh(()=>new Set),s=Jh(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=rc(),y=rc(),b=rc(),x=O.useRef(null),S=$h();Yh(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Yh(()=>{S(6,ee)},[]);let C=O.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,ee),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=O.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{k(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{k(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Ah;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(wh);t?t.appendChild(e.parentElement===t?e:e.closest(`${wh} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${wh} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Ch}[${kh}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(kh);C.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function ee(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Ch)?.querySelector(Th))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Eh}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Dh)||[])}function te(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(kh))}function ne(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(kh))}function re(e){let t=A()?.closest(Ch),n;for(;t&&!n;)t=e>0?Kh(t,Ch):qh(t,Ch),n=t?.querySelector(Dh);n?C.setState(`value`,n.getAttribute(kh)):ne(e)}let M=()=>te(j().length-1),ie=e=>{e.preventDefault(),e.metaKey?M():e.altKey?re(1):ne(1)},ae=e=>{e.preventDefault(),e.metaKey?te(0):e.altKey?re(-1):ne(-1)};return O.createElement(ls.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ie(e);break;case`ArrowDown`:ie(e);break;case`p`:case`k`:g&&e.ctrlKey&&ae(e);break;case`ArrowUp`:ae(e);break;case`Home`:e.preventDefault(),te(0);break;case`End`:e.preventDefault(),M();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Oh);t.dispatchEvent(e)}}}}},O.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:ng},c),tg(e,e=>O.createElement(Nh.Provider,{value:C},O.createElement(jh.Provider,{value:w},e))))}),Lh=O.forwardRef((e,t)=>{let n=rc(),r=O.useRef(null),i=O.useContext(Fh),a=Mh(),o=Jh(e),s=o.current?.forceMount??i?.forceMount;Yh(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Qh(n,r,[e.value,e.children,r],e.keywords),l=Ph(),u=Zh(e=>e.value&&e.value===c.current),d=Zh(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);O.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(Oh,f),()=>t.removeEventListener(Oh,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return O.createElement(ls.div,{ref:Re(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Rh=O.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=rc(),s=O.useRef(null),c=O.useRef(null),l=rc(),u=Mh(),d=Zh(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Yh(()=>u.group(o),[]),Qh(o,s,[e.value,e.heading,c]);let f=O.useMemo(()=>({id:o,forceMount:i}),[i]);return O.createElement(ls.div,{ref:Re(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&O.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),tg(e,e=>O.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},O.createElement(Fh.Provider,{value:f},e))))}),zh=O.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=O.useRef(null),a=Zh(e=>!e.search);return!n&&!a?null:O.createElement(ls.div,{ref:Re(i,t),...r,"cmdk-separator":``,role:`separator`})}),Bh=O.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Ph(),o=Zh(e=>e.search),s=Zh(e=>e.selectedItemId),c=Mh();return O.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),O.createElement(ls.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Vh=O.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=O.useRef(null),o=O.useRef(null),s=Zh(e=>e.selectedItemId),c=Mh();return O.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),O.createElement(ls.div,{ref:Re(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},tg(e,e=>O.createElement(`div`,{ref:Re(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Hh=O.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return O.createElement(_p,{open:n,onOpenChange:r},O.createElement(xp,{container:o},O.createElement(Cp,{"cmdk-overlay":``,className:i}),O.createElement(Dp,{"aria-label":e.label,"cmdk-dialog":``,className:a},O.createElement(Ih,{ref:t,...s}))))}),Uh=O.forwardRef((e,t)=>Zh(e=>e.filtered.count===0)?O.createElement(ls.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Wh=O.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return O.createElement(ls.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},tg(e,e=>O.createElement(`div`,{"aria-hidden":!0},e)))}),Gh=Object.assign(Ih,{List:Vh,Item:Lh,Input:Bh,Group:Rh,Separator:zh,Dialog:Hh,Empty:Uh,Loading:Wh});function Kh(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function qh(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Jh(e){let t=O.useRef(e);return Yh(()=>{t.current=e}),t}var Yh=typeof window>`u`?O.useEffect:O.useLayoutEffect;function Xh(e){let t=O.useRef();return t.current===void 0&&(t.current=e()),t}function Zh(e){let t=Ph(),n=()=>e(t.snapshot());return O.useSyncExternalStore(t.subscribe,n,n)}function Qh(e,t,n,r=[]){let i=O.useRef(),a=Mh();return Yh(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(kh,s),i.current=s}),i}var $h=()=>{let[e,t]=O.useState(),n=Xh(()=>new Map);return Yh(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function eg(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function tg({asChild:e,children:t},n){return e&&O.isValidElement(t)?O.cloneElement(eg(t),{ref:t.ref},n(t.props.children)):n(t)}var ng={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function rg({className:e,...t}){return(0,B.jsx)(Gh,{"data-slot":`command`,className:z(`la:flex la:h-full la:w-full la:flex-col la:overflow-hidden la:rounded-md la:bg-popover la:text-popover-foreground`,e),...t})}function ig({className:e,...t}){return(0,B.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`la:flex la:h-9 la:items-center la:gap-2 la:border-b la:px-3`,children:[(0,B.jsx)(De,{className:`la:size-4 la:shrink-0 la:opacity-50`}),(0,B.jsx)(Gh.Input,{"data-slot":`command-input`,className:z(`la:flex la:h-10 la:w-full la:rounded-md la:bg-transparent la:py-3 la:text-sm la:outline-hidden la:placeholder:text-muted-foreground la:disabled:cursor-not-allowed la:disabled:opacity-50`,e),...t})]})}function ag({className:e,...t}){return(0,B.jsx)(Gh.List,{"data-slot":`command-list`,className:z(`la:max-h-[300px] la:scroll-py-1 la:overflow-x-hidden la:overflow-y-auto`,e),...t})}function og({className:e,...t}){return(0,B.jsx)(Gh.Group,{"data-slot":`command-group`,className:z(`la:overflow-hidden la:p-1 la:text-foreground la:[&_[cmdk-group-heading]]:px-2 la:[&_[cmdk-group-heading]]:py-1.5 la:[&_[cmdk-group-heading]]:text-xs la:[&_[cmdk-group-heading]]:font-medium la:[&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function sg({className:e,...t}){return(0,B.jsx)(Gh.Item,{"data-slot":`command-item`,className:z(`la:relative la:flex la:cursor-default la:items-center la:gap-2 la:rounded-sm la:px-2 la:py-1.5 la:text-sm la:outline-hidden la:select-none la:data-[disabled=true]:pointer-events-none la:data-[disabled=true]:opacity-50 la:data-[selected=true]:bg-accent la:data-[selected=true]:text-accent-foreground la:[&_svg]:pointer-events-none la:[&_svg]:shrink-0 la:[&_svg:not([class*='size-'])]:size-4 la:[&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function cg({label:e,placeholder:t,value:n,onChange:r,suggestions:i,limit:a=8}){let[o,s]=(0,O.useState)(!1),c=lg(i,n,a),l=c.reduce((e,t)=>e.set(t.group,[...e.get(t.group)??[],t]),new Map),u=o&&c.length>0;return(0,B.jsxs)(rg,{label:e,shouldFilter:!1,loop:!0,className:`la-combobox la:relative la:overflow-visible la:bg-transparent`,onKeyDown:e=>{e.key===`Escape`&&s(!1),e.key===`ArrowDown`&&s(!0)},children:[(0,B.jsx)(ig,{placeholder:t,value:n,onValueChange:e=>{r(e),s(!0)},onFocus:()=>s(!0),onBlur:()=>s(!1)}),u&&(0,B.jsx)(ag,{label:`${e} suggestions`,className:`la:absolute la:top-full la:right-0 la:left-0 la:z-20 la:mt-1.5 la:rounded-md la:border la:bg-popover la:text-popover-foreground la:shadow-md`,onMouseDown:e=>e.preventDefault(),children:[...l].map(([e,t])=>(0,B.jsx)(og,{heading:e,children:t.map(t=>(0,B.jsxs)(sg,{value:`${e}:${t.value}`,onSelect:()=>{r(t.value),s(!1)},children:[(0,B.jsx)(`span`,{className:`la:truncate la:font-mono la:text-xs`,children:t.value}),t.hint&&(0,B.jsx)(`span`,{className:`la:ml-auto la:text-xs la:text-muted-foreground`,children:t.hint})]},t.value))},e))})]})}function lg(e,t,n){let r=t.trim().toLocaleLowerCase(),i=new Set,a=[];for(let t of e){let e=`${t.group}:${t.value}`,n=t.value.toLocaleLowerCase();i.has(e)||n===r||r&&!n.includes(r)||(i.add(e),a.push(t))}return a.sort((e,t)=>Number(t.value.toLocaleLowerCase().startsWith(r))-Number(e.value.toLocaleLowerCase().startsWith(r))).slice(0,n)}function ug(e={}){let t=[],n=[];return e.fromMs!==void 0&&(t.push(`MAX(started_at_ms) >= ?`),n.push(e.fromMs)),e.toMs!==void 0&&(t.push(`MIN(started_at_ms) <= ?`),n.push(e.toMs)),{sql:`SELECT connection_id, actor_name, actor_id, MIN(host_id) AS host_id,
|
|
92
|
-
MIN(CASE WHEN operation = 'onConnect' THEN started_at_ms END) AS opened_at_ms,
|
|
93
|
-
MAX(CASE WHEN operation = 'onDisconnect' THEN started_at_ms END) AS closed_at_ms,
|
|
94
|
-
MAX(started_at_ms) AS last_seen_ms,
|
|
95
|
-
MAX(CASE WHEN operation = 'onConnect' THEN event END) AS connect_event,
|
|
96
|
-
SUM(operation = 'onMessage') AS messages,
|
|
97
|
-
SUM(outcome NOT IN ('completed', 'rerouted')) AS failures
|
|
98
|
-
FROM request_events
|
|
99
|
-
WHERE kind = 'websocket' AND connection_id IS NOT NULL
|
|
100
|
-
GROUP BY connection_id, actor_name, actor_id
|
|
101
|
-
${t.length?`HAVING ${t.join(` AND `)}`:``}
|
|
102
|
-
ORDER BY COALESCE(opened_at_ms, last_seen_ms) DESC, connection_id
|
|
103
|
-
LIMIT 500`,params:n}}function dg(e){return e.rows.map(e=>{let t={connectionId:e.connection_id,actorName:e.actor_name,actorId:e.actor_id,hostId:e.host_id??null,openedAtMs:e.opened_at_ms??null,closedAtMs:e.closed_at_ms??null,lastSeenMs:e.last_seen_ms??null,messages:e.messages??0,failures:e.failures??0,metadata:fg(e.connect_event)};if(!bg(t))throw Error(`Invalid WebSocket session row`);return t})}function fg(e){if(typeof e!=`string`)return;let t=JSON.parse(e);return t&&typeof t==`object`&&`metadata`in t?t.metadata:void 0}function pg(e,t,n){return JSON.stringify([e,t,n])}function mg(e,t,n=new Map){let r=new Map;for(let e of t?.actors??[])for(let t of e.instances)for(let n of t.connections)r.set(JSON.stringify([e.actorName,t.actorId,n.id]),n.metadata);let i=e.map(e=>{let t=JSON.stringify([e.actorName,e.actorId,e.connectionId]),n=e.closedAtMs===null?r.has(t)?`open`:`lost`:`closed`;return n===`open`?{...e,status:n,metadata:r.get(t)}:{...e,status:n}}),a=new Set(i.map(e=>JSON.stringify([e.actorName,e.actorId,e.connectionId])));for(let e of t?.actors??[])for(let t of e.instances)for(let r of t.connections){let o=pg(e.actorName,t.actorId,r.id);if(a.has(o))continue;let s=n.get(o);i.unshift({connectionId:r.id,actorName:e.actorName,actorId:t.actorId,hostId:null,openedAtMs:s??null,estimatedStart:s!==void 0,closedAtMs:null,lastSeenMs:null,messages:0,failures:0,status:`open`,metadata:r.metadata})}return i}function hg(e,t){if(e.openedAtMs===null)return null;let n=e.status===`closed`?e.closedAtMs:e.status===`open`?Math.max(t,e.openedAtMs):e.lastSeenMs;return{ms:Math.max(0,n-e.openedAtMs),lowerBound:e.status===`lost`}}function gg(e,t){let n=e.map(e=>hg(e,t)).filter(e=>e!==null&&!e.lowerBound),r=e.reduce((e,t)=>e+t.messages,0);return{total:e.length,open:e.filter(e=>e.status===`open`).length,lost:e.filter(e=>e.status===`lost`).length,median:yg(n.map(e=>e.ms),.5),p95:yg(n.map(e=>e.ms),.95),messages:r,messagesPerSession:e.length?r/e.length:null}}function _g(e){if(e<1e3)return`${e.toLocaleString(void 0,{maximumFractionDigits:0})} ms`;if(e<6e4)return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} s`;let t=Math.floor(e/6e4);if(t<60)return`${t}m ${Math.floor(e%6e4/1e3)}s`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function vg(e,t=3){if(e==null)return null;if(typeof e!=`object`)return String(e);let n=Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e);if(!n.length)return null;let r=n.slice(0,t).map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)}`);return n.length>t?`${r.join(` · `)} · +${n.length-t}`:r.join(` · `)}function yg(e,t){return e.length?e.sort((e,t)=>e-t)[Math.max(0,Math.ceil(e.length*t)-1)]:null}function bg(e){return typeof e.connectionId==`string`&&typeof e.actorName==`string`&&typeof e.actorId==`string`&&(e.hostId===null||typeof e.hostId==`string`)&&[e.openedAtMs,e.closedAtMs,e.lastSeenMs].every(e=>e===null||Number.isSafeInteger(e)&&Number(e)>=0)&&[e.messages,e.failures].every(e=>Number.isSafeInteger(e)&&Number(e)>=0)&&(e.openedAtMs!==null||e.lastSeenMs!==null)}var xg=18,Sg=8,Cg=40,wg=6e4,Tg=60*wg,Eg=24*Tg,Dg=[1e3,2e3,5e3,1e4,15e3,3e4,wg,2*wg,5*wg,10*wg,15*wg,30*wg,Tg,2*Tg,3*Tg,6*Tg,12*Tg,Eg,2*Eg,7*Eg];function Og({sessions:e,start:t,end:n,endLabel:r=`now`,selected:i,onSelect:a}){let[o,s]=(0,O.useState)(),c=jg(e,t,n),l=c.slice(0,Cg),u=Math.max(1,n-t),d=Fg(t,n),f=Ig(u),p=e=>`${(Math.min(Math.max(e,t),n)-t)/u*100}%`,m=(e,t)=>{let n=t.getBoundingClientRect(),r=t.closest(`.socket-timeline`).getBoundingClientRect(),i=n.top-r.top<150;s({session:e,left:Math.min(Math.max(n.left-r.left+n.width/2,120),r.width-120),top:i?n.bottom-r.top:n.top-r.top,below:i})};return(0,B.jsxs)(`div`,{className:`socket-timeline`,role:`group`,"aria-label":`Connection timeline`,onMouseLeave:()=>s(void 0),children:[(0,B.jsxs)(`div`,{className:`socket-timeline-axis`,"aria-hidden":`true`,children:[(0,B.jsx)(`span`,{}),(0,B.jsxs)(`div`,{children:[d.map(e=>(0,B.jsx)(`span`,{style:{left:p(e)},children:Lg(e,f)},e)),(0,B.jsx)(`span`,{className:`socket-timeline-now`,children:r})]})]}),(0,B.jsxs)(`div`,{className:`socket-timeline-body`,children:[(0,B.jsx)(`div`,{className:`socket-timeline-grid`,"aria-hidden":`true`,children:d.map(e=>(0,B.jsx)(`i`,{style:{left:p(e)}},e))}),l.map(e=>(0,B.jsxs)(`div`,{className:`socket-timeline-row`,children:[(0,B.jsxs)(`div`,{className:`socket-timeline-label`,title:`${e.actorName} / ${e.actorId}`,children:[(0,B.jsx)(`span`,{children:e.actorName}),(0,B.jsx)(`strong`,{children:e.actorId})]}),(0,B.jsx)(`div`,{className:`socket-timeline-lanes`,style:{height:e.rows.length*xg+16},children:e.rows.flatMap((e,t)=>e.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`socket-bar socket-bar-${e.session.status}${e.openEnded?` socket-bar-open-ended`:``}${e.unknownStart?` socket-bar-unknown-start`:``}`,"data-state":i===e.session?`selected`:void 0,style:{left:p(e.from),width:`${(e.to-e.from)/u*100}%`,top:Sg+t*xg},"aria-label":Vg(e.session,n),onClick:t=>a(e.session,t.currentTarget),onMouseEnter:t=>m(e.session,t.currentTarget),onFocus:t=>m(e.session,t.currentTarget),onBlur:()=>s(void 0)},e.session.connectionId)))})]},e.key)),c.length>Cg&&(0,B.jsxs)(`p`,{className:`socket-timeline-more`,children:[(c.length-Cg).toLocaleString(),` more `,c.length-Cg===1?`instance is`:`instances are`,` listed in the table below.`]})]}),o&&(0,B.jsxs)(`div`,{role:`tooltip`,className:`socket-tooltip${o.below?` socket-tooltip-below`:``}`,style:{left:o.left,top:o.top},children:[(0,B.jsx)(Ag,{metadata:o.session.metadata}),(0,B.jsxs)(`dl`,{children:[(0,B.jsx)(`dt`,{children:`Connection`}),(0,B.jsx)(`dd`,{children:Bg(o.session.connectionId)}),(0,B.jsx)(`dt`,{children:`Instance`}),(0,B.jsxs)(`dd`,{children:[o.session.actorName,` / `,o.session.actorId]}),(0,B.jsx)(`dt`,{children:`Status`}),(0,B.jsx)(`dd`,{children:Rg(o.session.status)}),(0,B.jsx)(`dt`,{children:`Opened`}),(0,B.jsx)(`dd`,{children:o.session.openedAtMs===null?`Before retained history`:`${o.session.estimatedStart?`≈ `:``}${new Date(o.session.openedAtMs).toLocaleTimeString([],{hour12:!1})}`}),(0,B.jsx)(`dt`,{children:`Duration`}),(0,B.jsx)(`dd`,{children:zg(o.session,n)}),(0,B.jsx)(`dt`,{children:`Messages`}),(0,B.jsx)(`dd`,{children:o.session.messages.toLocaleString()})]})]})]})}var kg=4;function Ag({metadata:e}){if(e==null)return null;let t=typeof e==`object`?Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e):[[`value`,e]];return t.length?(0,B.jsxs)(`dl`,{className:`socket-tooltip-metadata`,"aria-label":`Connection metadata`,children:[t.slice(0,kg).map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e}),(0,B.jsx)(`dd`,{children:typeof t==`string`?t:JSON.stringify(t)})]},e)),t.length>kg&&(0,B.jsxs)(`p`,{children:[`+`,t.length-kg,` more in details`]})]}):null}function jg(e,t,n){let r=new Map,i=e.map(e=>Mg(e,t,n)).filter(e=>e.to>t).sort((e,t)=>e.from-t.from||e.to-t.to);for(let e of i){let i=`${e.session.actorName}${e.session.actorId}`,a=r.get(i)??{key:i,actorName:e.session.actorName,actorId:e.session.actorId,rows:[]};r.set(i,a);let o=a.rows.find(r=>r.at(-1).to+Ng(t,n)<=e.from);o?o.push(e):a.rows.push([e])}return[...r.values()].sort((e,t)=>Pg(t)-Pg(e))}function Mg(e,t,n){let r=e.openedAtMs??(e.status===`open`?t:e.lastSeenMs??t),i=e.status===`closed`?e.closedAtMs:e.status===`open`?n:e.lastSeenMs??r;return{session:e,from:Math.max(t,r),to:Math.max(Math.max(t,r)+Ng(t,n),Math.min(n,i)),openEnded:e.status!==`closed`,unknownStart:e.openedAtMs===null}}function Ng(e,t){return Math.max(1,(t-e)/160)}function Pg(e){return Math.max(...e.rows.flat().map(e=>e.to))}function Fg(e,t){let n=Ig(Math.max(1,t-e)),r=[];for(let i=Math.floor(e/n)*n+n;i<t-n*.35;i+=n)r.push(i);return r}function Ig(e){return Dg.find(t=>e/t<=9)??Dg.at(-1)}function Lg(e,t){let n=new Date(e);return t>=Eg?n.toLocaleDateString([],{month:`short`,day:`numeric`}):t>=wg?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):n.toLocaleTimeString([],{hour12:!1})}function Rg(e){return e===`open`?`Open`:e===`closed`?`Closed`:`Lost`}function zg(e,t){let n=hg(e,t);return n?`${n.lowerBound?`≥ `:``}${_g(n.ms)}`:`Unknown`}function Bg(e){return e.length>14?`${e.slice(0,8)}…${e.slice(-4)}`:e}function Vg(e,t){let n=vg(e.metadata);return`${Rg(e.status)} connection ${Bg(e.connectionId)}${n===null?``:` (${n})`} on ${e.actorName} ${e.actorId}, ${zg(e,t)}`}function Hg(e,t){let n=Zp(e,ug(t),dg,5e3);return{...n,rows:n.value,capped:(n.value?.length??0)>=500}}function Ug({client:e,onSelectActor:t,timeRange:n,onTimeRangeChange:r}){let{inventory:i,failed:a,retry:o}=Jp(e),[s,c]=(0,O.useState)(Yf),l=n??s,u=r??c,[d,f]=(0,O.useState)(Date.now),[p,m]=(0,O.useState)(``),[h,g]=(0,O.useState)(`all`),[_,v]=(0,O.useState)(),y=(0,O.useRef)(null),b=(0,O.useRef)(null);(0,O.useEffect)(()=>{let e=setInterval(()=>f(Date.now()),5e3);return()=>clearInterval(e)},[]);let x=Xf(l,d),S=x.toMs??d,C=Hg(e,x),w=Jg(i,C.retry),T=(0,O.useMemo)(()=>mg(C.rows??[],i,w),[C.rows,i,w]),E=!!i||a,D=p.trim().toLocaleLowerCase(),k=T.filter(e=>(h===`all`||e.status===h)&&(!D||`${e.connectionId} ${e.actorName} ${e.actorId} ${e.hostId??``}`.toLocaleLowerCase().includes(D))).sort((e,t)=>Number(t.status===`open`)-Number(e.status===`open`)||(t.openedAtMs??t.lastSeenMs??1/0)-(e.openedAtMs??e.lastSeenMs??1/0)),ee=gg(T,d),A=Math.max(0,...T.filter(e=>e.status!==`open`).map(e=>hg(e,d)?.ms??0))||ee.p95,j=qg(k,x.fromMs,S),te=(0,O.useMemo)(()=>Yg(T,i),[T,i]);return(0,O.useEffect)(()=>v(void 0),[e,l]),(0,B.jsxs)(`section`,{ref:y,className:`la-observer overview websockets`,"aria-label":`WebSocket observer`,children:[(0,B.jsxs)(`div`,{className:`overview-heading`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{children:`WebSockets`}),(0,B.jsx)(`p`,{children:E?`${ee.open.toLocaleString()} open now${C.supported?` · ${ee.total.toLocaleString()} ${ee.total===1?`session`:`sessions`} ${Qf(l)}`:``}`:`Connecting to inventory…`})]}),(0,B.jsxs)(`div`,{className:`overview-controls`,children:[(0,B.jsx)(`span`,{className:`overview-updated`,children:C.failed?`History reconnecting…`:C.updatedAt?(0,B.jsxs)(B.Fragment,{children:[`Updated `,(0,B.jsx)(`time`,{dateTime:new Date(C.updatedAt).toISOString(),children:new Date(C.updatedAt).toLocaleTimeString([],{hour12:!1})})]}):null}),C.supported&&(0,B.jsx)(tp,{value:l,onChange:u,className:`overview-range`}),(0,B.jsx)(Bn,{variant:`outline`,size:`icon`,"aria-label":`Refresh connections`,onClick:()=>{o(),C.retry()},children:(0,B.jsx)(Te,{"aria-hidden":`true`})})]})]}),a&&(0,B.jsxs)(`p`,{role:`alert`,className:`overview-alert`,children:[`Could not refresh connections.`,` `,i?`Showing the last received inventory; it may be out of date.`:`Open connections cannot be confirmed, so unfinished sessions show as lost.`,` Retrying automatically.`]}),C.failed&&(0,B.jsxs)(`p`,{role:`alert`,className:`overview-alert`,children:[`Connection history unavailable. `,C.rows?`Showing the last loaded sessions.`:`Only currently open connections are shown.`,` Retrying automatically.`]}),(0,B.jsx)(Wg,{summary:ee,ready:E,history:C.supported&&!!C.rows,range:l}),(0,B.jsxs)(`div`,{className:`socket-filterbar`,children:[(0,B.jsx)(cg,{label:`Filter connections`,placeholder:`Filter by connection, actor, instance, or host…`,value:p,onChange:m,suggestions:te}),(0,B.jsxs)(`select`,{"aria-label":`Filter by status`,value:h,onChange:e=>g(e.target.value),children:[(0,B.jsx)(`option`,{value:`all`,children:`All statuses`}),(0,B.jsx)(`option`,{value:`open`,children:`Open`}),(0,B.jsx)(`option`,{value:`closed`,children:`Closed`}),(0,B.jsx)(`option`,{value:`lost`,children:`Lost`})]})]}),C.supported&&(0,B.jsxs)(`section`,{className:`overview-panel socket-timeline-panel`,"aria-label":`Connection timeline`,children:[(0,B.jsxs)(`div`,{className:`socket-panel-heading`,children:[(0,B.jsxs)(`h2`,{children:[`Timeline `,(0,B.jsx)(`span`,{children:k.length.toLocaleString()})]}),(0,B.jsxs)(`ul`,{className:`socket-legend`,"aria-label":`Timeline legend`,children:[(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`i`,{className:`socket-swatch socket-swatch-open`}),` Open`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`i`,{className:`socket-swatch socket-swatch-closed`}),` Closed`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`i`,{className:`socket-swatch socket-swatch-lost`}),` Lost · no disconnect recorded`]})]})]}),k.length?(0,B.jsx)(Og,{sessions:k,start:j,end:S,endLabel:x.toMs===void 0?`now`:new Date(x.toMs).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}),selected:_,onSelect:(e,t)=>{b.current=t,v(e)}}):(0,B.jsxs)(`div`,{className:`overview-empty socket-timeline-empty`,role:`status`,children:[(0,B.jsx)(`strong`,{children:Xg(E,C,T.length)}),(0,B.jsx)(`p`,{children:T.length?`Try another filter or a wider time window.`:`Sessions appear here as clients connect to actors.`})]})]}),(0,B.jsxs)(`div`,{className:`overview-panel`,children:[(0,B.jsx)(`div`,{className:`overview-table-scroll`,role:`region`,"aria-label":`WebSocket connections`,tabIndex:0,children:(0,B.jsxs)(`table`,{className:`overview-table socket-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Status`}),(0,B.jsx)(`th`,{scope:`col`,children:`Connection`}),(0,B.jsx)(`th`,{scope:`col`,children:`Actor class`}),(0,B.jsx)(`th`,{scope:`col`,children:`Instance`}),(0,B.jsx)(`th`,{scope:`col`,children:`Opened`}),(0,B.jsx)(`th`,{scope:`col`,children:`Duration`}),(0,B.jsx)(`th`,{scope:`col`,children:`Messages`}),(0,B.jsx)(`th`,{scope:`col`,children:`Metadata`})]})}),(0,B.jsx)(`tbody`,{children:k.map(e=>(0,B.jsx)(Gg,{session:e,now:d,longest:A,selected:_===e,onSelect:t=>{b.current=t,v(e)}},JSON.stringify([e.actorName,e.actorId,e.connectionId])))})]})}),!k.length&&(0,B.jsxs)(`div`,{className:`overview-empty`,role:`status`,children:[(0,B.jsx)(`strong`,{children:Xg(E,C,T.length)}),(0,B.jsx)(`p`,{children:T.length?`Try another connection, actor, or status.`:`Open an actor WebSocket to see its connection and metadata here.`}),!!T.length&&(0,B.jsx)(Bn,{variant:`outline`,onClick:()=>{m(``),g(`all`)},children:`Clear filter`})]})]}),(0,B.jsx)(`div`,{className:`overview-data-scope`,children:(0,B.jsx)(`p`,{children:C.supported?`Sessions pair each connection’s onConnect and onDisconnect events from retained request history${C.capped?`; only the 500 most recent sessions are shown`:``}. Open connections follow the latest host report. Lost connections have no recorded disconnect and are no longer reported by a host, so their duration is a lower bound.`:`Connections are active WebSockets, not unique people. Counts follow the latest host report.`})}),(0,B.jsx)(Rp,{open:!!_,onOpenChange:e=>{e||v(void 0)},children:(0,B.jsxs)(Vp,{container:y.current,onCloseAutoFocus:e=>{e.preventDefault(),b.current?.focus()},children:[(0,B.jsx)(zp,{children:`Connection details`}),(0,B.jsx)(Bp,{children:`Identifiers, timings, and metadata for this WebSocket.`}),_&&(0,B.jsx)(Kg,{session:_,now:d,onSelectActor:t})]})})]})}function Wg({summary:e,ready:t,history:n,range:r}){return(0,B.jsxs)(`div`,{className:`overview-metrics socket-metrics`,children:[(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Open now`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Open WebSocket connections`,children:t?e.open.toLocaleString():`—`}),(0,B.jsx)(`span`,{children:`live connections`})]}),(0,B.jsx)(`div`,{className:`overview-metric-foot`,children:(0,B.jsx)(`span`,{children:`Latest host report`})})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Sessions`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`WebSocket sessions`,children:n?e.total.toLocaleString():`—`}),(0,B.jsx)(`span`,{children:r.kind===`absolute`?Zf(r):Qf(r)})]}),(0,B.jsxs)(`div`,{className:`overview-metric-foot`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:n?(e.total-e.open-e.lost).toLocaleString():`—`}),` closed`]}),(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:n?e.lost.toLocaleString():`—`}),` lost`]})]})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Session duration`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`Median session duration`,children:n&&e.median!==null?_g(e.median):`—`}),(0,B.jsx)(`span`,{children:`median`})]}),(0,B.jsxs)(`div`,{className:`overview-metric-foot`,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:n&&e.p95!==null?_g(e.p95):`—`}),` p95`]}),(0,B.jsx)(`span`,{children:`Open sessions count up to now`})]})]}),(0,B.jsxs)(`section`,{className:`overview-metric`,children:[(0,B.jsx)(`h2`,{children:`Messages`}),(0,B.jsxs)(`div`,{className:`overview-value`,children:[(0,B.jsx)(`strong`,{"aria-label":`WebSocket messages`,children:n?e.messages.toLocaleString():`—`}),(0,B.jsx)(`span`,{children:`received`})]}),(0,B.jsx)(`div`,{className:`overview-metric-foot`,children:(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`b`,{children:n&&e.messagesPerSession!==null?e.messagesPerSession.toLocaleString(void 0,{maximumFractionDigits:1}):`—`}),` per session`]})})]})]})}function Gg({session:e,now:t,longest:n,selected:r,onSelect:i}){let a=hg(e,t),o=a&&n?Math.min(1,a.ms/n):0;return(0,B.jsxs)(`tr`,{className:`la-clickable-row`,"data-state":r?`selected`:void 0,onClick:e=>i(e.currentTarget.querySelector(`button`)??e.currentTarget),children:[(0,B.jsx)(`td`,{children:(0,B.jsxs)(`span`,{className:`socket-status socket-status-${e.status}`,children:[(0,B.jsx)(`i`,{className:`socket-swatch socket-swatch-${e.status}`,"aria-hidden":`true`}),Rg(e.status)]})}),(0,B.jsx)(`td`,{children:(0,B.jsx)(`button`,{type:`button`,className:`socket-connection`,title:e.connectionId,"aria-label":`Inspect connection ${e.connectionId}`,children:Bg(e.connectionId)})}),(0,B.jsx)(`td`,{title:e.actorName,children:e.actorName}),(0,B.jsx)(`td`,{title:e.actorId,children:e.actorId}),(0,B.jsx)(`td`,{children:e.openedAtMs===null?(0,B.jsx)(`span`,{title:`The connect event is not in retained history`,children:`—`}):(0,B.jsxs)(`time`,{dateTime:new Date(e.openedAtMs).toISOString(),title:e.estimatedStart?`Approximate: first reported by the host; the connect event has not been saved yet`:new Date(e.openedAtMs).toLocaleString(),children:[e.estimatedStart?`≈ `:``,new Date(e.openedAtMs).toLocaleTimeString([],{hour12:!1})]})}),(0,B.jsx)(`td`,{children:(0,B.jsxs)(`span`,{className:`socket-duration`,children:[(0,B.jsx)(`span`,{children:zg(e,t)}),(0,B.jsx)(`i`,{className:`socket-duration-bar socket-duration-${e.status}`,"aria-hidden":`true`,children:(0,B.jsx)(`b`,{style:{width:`${o*100}%`}})})]})}),(0,B.jsx)(`td`,{children:e.messages.toLocaleString()}),(0,B.jsx)(`td`,{children:e.metadata===void 0?(0,B.jsx)(`span`,{title:`No metadata was recorded for this connection`,children:`—`}):(0,B.jsx)(`code`,{className:`socket-metadata`,title:JSON.stringify(e.metadata),children:JSON.stringify(e.metadata)})})]})}function Kg({session:e,now:t,onSelectActor:n}){let r={Status:e.status===`lost`?`Lost — no disconnect recorded`:Rg(e.status),Connection:e.connectionId,"Actor class":e.actorName,"Instance ID":e.actorId,Opened:e.openedAtMs===null?`Before retained history`:`${e.estimatedStart?`≈ `:``}${new Date(e.openedAtMs).toLocaleString()}`,...e.closedAtMs===null?{}:{Closed:new Date(e.closedAtMs).toLocaleString()},...e.status===`lost`&&e.lastSeenMs!==null?{"Last activity":new Date(e.lastSeenMs).toLocaleString()}:{},Duration:zg(e,t),Messages:e.messages.toLocaleString(),Failures:e.failures.toLocaleString(),Host:e.hostId??`Unknown`};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`dl`,{className:`la-request-details`,children:Object.entries(r).map(([e,t])=>(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e}),(0,B.jsx)(`dd`,{children:t})]},e))}),e.metadata!==void 0&&(0,B.jsxs)(`details`,{className:`socket-metadata-details`,open:!0,children:[(0,B.jsx)(`summary`,{children:`Metadata`}),(0,B.jsx)(`pre`,{children:JSON.stringify(e.metadata,null,2)})]}),n&&(0,B.jsxs)(Bn,{variant:`outline`,onClick:()=>n(e.actorName),children:[`Open `,e.actorName]})]})}function qg(e,t,n){let r=Math.min(...e.map(e=>e.openedAtMs??e.lastSeenMs??n)),i=Number.isFinite(r)?r-Math.max(5e3,(n-r)*.06):n-6e4;return Math.max(t??-1/0,Math.min(i,n-1e4))}function Jg(e,t){let[n,r]=(0,O.useState)(new Map),i=(0,O.useRef)(void 0);return(0,O.useEffect)(()=>{if(!e)return;let n=new Set(e.actors.flatMap(e=>e.instances.flatMap(t=>t.connections.map(n=>pg(e.actorName,t.actorId,n.id))))),a=i.current;if(i.current=n,!a)return;let o=[...n].filter(e=>!a.has(e)),s=[...a].filter(e=>!n.has(e));if(o.length||s.length){if(o.length){let e=Date.now();r(t=>new Map([...t,...o.map(t=>[t,e])]))}t()}},[e]),n}function Yg(e,t){let n=new Map;for(let e of t?.actors??[])n.set(e.actorName,new Set(e.instances.map(e=>e.actorId)));for(let t of e){let e=n.get(t.actorName)??new Set;n.set(t.actorName,e.add(t.actorId))}return[...[...n.keys()].map(e=>({group:`Actor class`,value:e,hint:`${n.get(e).size.toLocaleString()} ${n.get(e).size===1?`instance`:`instances`}`})),...[...n].flatMap(([e,t])=>[...t].map(t=>({group:`Instances`,value:t,hint:e})))]}function Xg(e,t,n){return!e&&!t.rows?t.failed?`Connections unavailable`:`Loading connections…`:n?`No matching connections`:t.supported?`No WebSocket sessions`:`No active WebSockets`}var Zg=[{id:`overview`,label:`Durable Actors`,icon:ye},{id:`actors`,label:`Actors`,icon:ae},{id:`requests`,label:`Requests`,icon:ne},{id:`websockets`,label:`WebSockets`,icon:se}];function Qg({client:e,toggleTheme:t}){let[n,r]=(0,O.useState)(`overview`),[i,a]=(0,O.useState)(),[o,s]=(0,O.useState)(Yf),c={timeRange:o,onTimeRangeChange:s};function l(e){a(e),r(`actors`)}return(0,B.jsxs)(`div`,{className:`console-shell`,children:[(0,B.jsx)(`a`,{className:`skip-link`,href:`#main`,children:`Skip to content`}),(0,B.jsxs)(`aside`,{className:`console-sidebar`,children:[(0,B.jsxs)(`div`,{className:`console-brand`,children:[(0,B.jsx)(P,{"aria-hidden":`true`}),(0,B.jsx)(`strong`,{children:`Terse`})]}),(0,B.jsx)(`nav`,{"aria-label":`Observability`,children:Zg.map(e=>(0,B.jsxs)(`button`,{type:`button`,"aria-current":n===e.id?`page`:void 0,onClick:()=>{a(void 0),r(e.id)},children:[(0,B.jsx)(e.icon,{"aria-hidden":`true`}),e.label]},e.id))}),(0,B.jsxs)(`div`,{className:`console-sidebar-foot`,children:[(0,B.jsx)(ae,{"aria-hidden":`true`}),(0,B.jsxs)(`span`,{children:[`Runtime inspector`,(0,B.jsx)(`small`,{children:`Read-only observability`})]})]})]}),(0,B.jsxs)(`div`,{className:`console-workspace`,children:[(0,B.jsxs)(`header`,{className:`console-topbar`,children:[(0,B.jsx)(`button`,{className:`theme-toggle`,type:`button`,onClick:t,"aria-label":`Toggle color theme`,children:(0,B.jsx)(ke,{"aria-hidden":`true`})}),(0,B.jsxs)(`a`,{href:`https://github.com/TerseAI/durable-actors#readme`,target:`_blank`,rel:`noopener noreferrer`,children:[`Docs`,(0,B.jsx)(M,{"aria-hidden":`true`})]})]}),(0,B.jsxs)(`main`,{id:`main`,tabIndex:-1,children:[n===`overview`&&(0,B.jsx)(Qm,{client:e,onSelectActor:l,...c}),n===`actors`&&(0,B.jsx)(Am,{client:e,navigation:{actorName:i,onSelectActor:a},...c}),n===`requests`&&(0,B.jsx)(vm,{client:e,...c}),n===`websockets`&&(0,B.jsx)(Ug,{client:e,onSelectActor:l,...c})]})]})]})}var $g=new sm,e_=window.matchMedia(`(prefers-color-scheme: dark)`),t_=!1,n_=()=>{t_||document.documentElement.classList.toggle(`dark`,e_.matches)};n_(),e_.addEventListener(`change`,n_);function r_(){t_=!0,document.documentElement.classList.toggle(`dark`)}(0,Pe.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(Qg,{client:$g,toggleTheme:r_}));
|
|
56
|
+
`,t),i=-1;if(n!==-1&&r!==-1?i=n<r?n:r:n===-1?r!==-1&&(i=r):i=n===e.length-1?-1:n,i===-1)break;C(e,t,i),t=i+1,e.charCodeAt(t-1)===Pg&&e.charCodeAt(t)===Ng&&t++}return e.slice(t)}function C(e,t,r){if(t===r){T();return}let i=e.charCodeAt(t);if(Rg(e,t,i)){let n=e.charCodeAt(t+5)===Fg?t+6:t+5,i=e.slice(n,r);d=f===0?i:`${d}\n${i}`,f++;return}if(zg(e,t,i)){p=e.slice(e.charCodeAt(t+6)===Fg?t+7:t+6,r)||void 0;return}if(i===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let n=e.slice(e.charCodeAt(t+3)===Fg?t+4:t+3,r);n.includes(`\0`)||(u=n);return}if(i===58){if(n){let i=e.slice(t,r);n(i.slice(e.charCodeAt(t+1)===Fg?2:1))}return}let a=e.slice(t,r),o=a.indexOf(`:`);if(o===-1){w(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===Fg?2:1;w(s,a.slice(o+c),a)}function w(e,t,n){switch(e){case`event`:p=t||void 0;break;case`data`:d=f===0?t:`${d}\n${t}`,f++;break;case`id`:t.includes(`\0`)||(u=t);break;case`retry`:/^\d+$/.test(t)?o?.(parseInt(t,10)):r?.(new Mg(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:n}));break;default:r?.(new Mg(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:`unknown-field`,field:e,value:t,line:n}))}}function T(){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0}function E(e={}){if(e.consume&&s.length>0){let e=s.join(``);C(e,0,e.length)}l=``,u=void 0,d=``,f=0,p=void 0,s.length=0,c=0,m=!1,h=!1,g=!1}return{feed:_,reset:E}}function Rg(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 zg(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}function Bg(e,t){let n=1;for(;n<e.length&&n<t.length;){if(e.charCodeAt(n)!==t.charCodeAt(n))return!1;n++}return e.length<=t.length||e.charCodeAt(t.length)===58}var Vg=class{baseUrl;request;constructor(e=`/api/observe`,t=globalThis.fetch.bind(globalThis)){this.baseUrl=e,this.request=t}async getMetrics(e,t){return Am(await this.get(`metrics${Hg(e)}`,t))}async listQueueWaits(e,t){return im(await this.get(`queue-waits${Hg(e)}`,t))}async listWebSockets(e,t){return Gh(await this.get(`websockets${Hg(e)}`,t))}async listActors(e){let t=await this.get(`actors`,e);if(!Ug(t))throw Error(`Invalid actor inventory response.`);return t}async watchActors(e,t){return this.watch(`events`,`inventory`,Ug,e,t)}async watchRequests(e,t,n){let r=n?`?${new URLSearchParams({after:n})}`:``;return this.watch(`requests/events${r}`,`requests`,Kg,e,t)}async listRequests(e,t){let n=await this.get(`requests${Hg(e)}`,t);if(!Kg(n))throw Error(`Invalid request history response`);return n}async watch(e,t,n,r,i){let a=await this.request(`${this.baseUrl.replace(/\/$/u,``)}/${e}`,{signal:i,credentials:`same-origin`,redirect:`error`,headers:{accept:`text/event-stream`}});if(!a.ok||!a.headers.get(`content-type`)?.startsWith(`text/event-stream`)||!a.body)throw await a.body?.cancel(),Error(`Live inventory is unavailable`);let o=a.body.getReader(),s=new TextDecoder,c=Lg({onEvent(e){if(i.aborted)return;if(e.event===`error`)throw Error(`Live inventory is unavailable`);if(e.event!==t)return;let a=JSON.parse(e.data);if(!n(a))throw Error(`Invalid observer response`);r(a)}}),l=()=>{o.cancel().catch(()=>{})};i.addEventListener(`abort`,l,{once:!0});try{for(;!i.aborted;){let{value:e,done:t}=await o.read();if(t)break;c.feed(s.decode(e,{stream:!0}))}if(!i.aborted)throw Error(`Live inventory disconnected`)}finally{i.removeEventListener(`abort`,l),await o.cancel().catch(()=>{}),o.releaseLock()}}async checkConnection(e){let t=await this.get(`connection`,e);if(!t||typeof t!=`object`||!(`connected`in t)||t.connected!==!0)throw Error(`Invalid connection response.`)}async get(e,t){let n=await this.request(`${this.baseUrl.replace(/\/$/u,``)}/${e}`,{method:`GET`,credentials:`same-origin`,redirect:`error`,signal:t,headers:{accept:`application/json`}});if(!n.ok)throw Error(`Connection check failed (HTTP ${n.status}).`);return n.json()}};function Hg(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&t.set(n,String(r));return t.size?`?${t}`:``}function Ug(e){return!e||typeof e!=`object`||!(`actors`in e)||!Array.isArray(e.actors)?!1:e.actors.every(e=>e&&typeof e.actorName==`string`&&[e.live,e.dormant,e.unknown].every(e=>Number.isSafeInteger(e)&&e>=0)&&Array.isArray(e.instances)&&e.instances.every(Wg))}function Wg(e){return!!e&&typeof e==`object`&&`actorId`in e&&typeof e.actorId==`string`&&`status`in e&&[`live`,`dormant`,`unknown`].includes(String(e.status))&&`connections`in e&&Array.isArray(e.connections)&&e.connections.every(Gg)&&(!(`waiting`in e)||e.waiting==null||Array.isArray(e.waiting)&&e.waiting.every(e=>!!e&&typeof e==`object`&&typeof e.id==`string`&&typeof e.operation==`string`))}function Gg(e){return!!e&&typeof e==`object`&&`id`in e&&typeof e.id==`string`&&`metadata`in e}function Kg(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.epoch==`string`&&[t.cursor,t.capacity,t.evicted,t.dropped].every(qg)&&(t.persistenceFailed===void 0||typeof t.persistenceFailed==`boolean`)&&(t.nextCursor==null||typeof t.nextCursor==`string`)&&(t.resumeCursor===void 0||typeof t.resumeCursor==`string`)&&(t.reset===void 0||typeof t.reset==`boolean`)&&t.capacity>0&&t.capacity<=500&&Array.isArray(t.records)&&t.records.length<=t.capacity&&t.records.every(e=>Jg(e)&&e.sequence<=t.cursor)}function qg(e){return Number.isSafeInteger(e)&&Number(e)>=0}function Jg(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.projectId==`string`&&/^[A-Za-z0-9._-]{1,64}$/u.test(t.projectId)&&[t.requestId,t.hostId,t.sessionId,t.actorName,t.actorId,t.operation].every(e=>typeof e==`string`)&&(t.eventId===void 0||typeof t.eventId==`string`&&t.eventId.length>0)&&qg(t.sequence)&&qg(t.startedAtMs)&&t.startedAtMs<=864e13&&[`method`,`websocket`].includes(t.kind)&&[`completed`,`failed`,`rejected`,`rerouted`,`interrupted`].includes(t.outcome)&&(t.connectionId===null||typeof t.connectionId==`string`)&&Number.isFinite(t.durationMs)&&t.durationMs>=0&&(t.queueWaitMs===null||Number.isFinite(t.queueWaitMs)&&t.queueWaitMs>=0&&t.queueWaitMs<=t.durationMs)}var Yg=new Vg,Xg=window.matchMedia(`(prefers-color-scheme: dark)`),Zg=!1,Qg=()=>{Zg||document.documentElement.classList.toggle(`dark`,Xg.matches)};Qg(),Xg.addEventListener(`change`,Qg);function $g(){Zg=!0,document.documentElement.classList.toggle(`dark`)}(0,Pe.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(jg,{client:Yg,toggleTheme:$g}));
|