@camstack/addon-admin-ui 1.2.114 → 1.2.117
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/dist/assets/{AddLocationWizard-CLEzgi3l.js → AddLocationWizard-Bob-o0Kv.js} +1 -1
- package/dist/assets/{AddonCollectionPage-OF4NjZlv.js → AddonCollectionPage-BRZ5wnDA.js} +1 -1
- package/dist/assets/{Addons-BSLvVtBh.js → Addons-C7ugoYzx.js} +1 -1
- package/dist/assets/{AdminTabs-BeziKJ1a.js → AdminTabs-DVhMhCwB.js} +1 -1
- package/dist/assets/{AiProfiles-DWqdEEFT.js → AiProfiles-BOumh8Sy.js} +1 -1
- package/dist/assets/{BrokerForm-FeLKeIbG.js → BrokerForm-DUIN2thN.js} +1 -1
- package/dist/assets/{Build-CLl2lkHL.js → Build-CKeeP86Z.js} +1 -1
- package/dist/assets/{Capabilities-RFtp6PdX.js → Capabilities-Dy5fksAD.js} +1 -1
- package/dist/assets/{CapabilityBadges-Cwy0xRxA.js → CapabilityBadges-KzSV_NH7.js} +1 -1
- package/dist/assets/Cluster-BviBUX6y.js +11 -0
- package/dist/assets/Data-DujVsgdF.js +1 -0
- package/dist/assets/{DetectionIntelligence-CWUQ3uGY.js → DetectionIntelligence-CM7P-dMx.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-BwOtBLRt.js → DeviceAggregateSection-Bsi6p5YO.js} +1 -1
- package/dist/assets/{DeviceDetail-cMn7hEIF.js → DeviceDetail-DQMiHdyF.js} +1 -1
- package/dist/assets/{Devices-C8ai26zO.js → Devices-BJcC70V3.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-GtDaGVsR.js → EmbedPlayerPage-CSY1rShh.js} +1 -1
- package/dist/assets/{Events-D3nW6go3.js → Events-BTAz2irZ.js} +1 -1
- package/dist/assets/{FormBuilder-zxwVa7JY.js → FormBuilder-Cl04f_JD.js} +1 -1
- package/dist/assets/Identity-DwP0DWZT.js +1 -0
- package/dist/assets/{IntegrationDetail-DCobOfAh.js → IntegrationDetail-DrtquA7G.js} +1 -1
- package/dist/assets/{Integrations-kH0JLtNh.js → Integrations-D3WabD9o.js} +1 -1
- package/dist/assets/{Integrations-Ck7eESXp.js → Integrations-sedJLouZ.js} +1 -1
- package/dist/assets/{Logs-zMy08xFK.js → Logs-CprZOubd.js} +1 -1
- package/dist/assets/{MotionZonesSettings-C05ExQff.js → MotionZonesSettings-CJ739aet.js} +1 -1
- package/dist/assets/{MyAccess-Cc08fwMh.js → MyAccess-eCoyemMZ.js} +1 -1
- package/dist/assets/{Network-KBymfAaD.js → Network-GD5AYiiW.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-B2J7nqRT.js → NodeAddonsSettingsPanel-BKGrAKXv.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-HkYGItBF.js → NodeInferenceDevices-BCYhY7nQ.js} +1 -1
- package/dist/assets/{Notifications-KDIWKsV3.js → Notifications-f42HlHqJ.js} +1 -1
- package/dist/assets/Pipeline-Jv-H2NAp.js +1 -0
- package/dist/assets/Plates-DNXJ0ZGd.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-D-g-QaJb.js → PrivacyMaskSettings-0i9ff8gY.js} +1 -1
- package/dist/assets/{ProviderIcon-BWszI_oc.js → ProviderIcon-O1y41-9_.js} +1 -1
- package/dist/assets/Recordings-BLl9b2uJ.js +1 -0
- package/dist/assets/{ScanNetworkModal-Bma1D7QR.js → ScanNetworkModal-Bkpvy3_p.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-Dfur0iW8.js → SceneMonitorEditor-CRrYOWn_.js} +1 -1
- package/dist/assets/{Scenes-CKblcP19.js → Scenes-5wMKZRPv.js} +1 -1
- package/dist/assets/{Settings-CTZm6yG1.js → Settings-DWYKhvBB.js} +1 -1
- package/dist/assets/{Showroom-CDw9FMvO.js → Showroom-CUXHrY5P.js} +1 -1
- package/dist/assets/{Terminal-DyRD1wmv.js → Terminal-BlZVC9iW.js} +3 -3
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C5GDGlzj.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CAribm2M.js} +1 -1
- package/dist/assets/{bell-ring-Dq81DIcx.js → bell-ring-BLQ-V73q.js} +1 -1
- package/dist/assets/{boxes-B1LvR_EC.js → boxes-Dypj31sZ.js} +1 -1
- package/dist/assets/circle-check-big-xsZd2yKi.js +1 -0
- package/dist/assets/{circle-x-Bvjbrjwc.js → circle-x-B3MSB8Og.js} +1 -1
- package/dist/assets/clock-BtMlIKiK.js +1 -0
- package/dist/assets/{copy-DXEey34g.js → copy-D55okrt8.js} +1 -1
- package/dist/assets/{debounced-invalidate-C8FjdM4j.js → debounced-invalidate-Bq_-Ngtg.js} +1 -1
- package/dist/assets/{dist-DlvXnCGJ.js → dist-BKLAovWG.js} +1 -1
- package/dist/assets/dist-vBVTdcJV.js +349 -0
- package/dist/assets/{download-D5kL_Go0.js → download-DPaR139q.js} +1 -1
- package/dist/assets/{face-bbox-LHvxscZZ.js → face-bbox-Dl112HSj.js} +1 -1
- package/dist/assets/{hostInit-CAcT8QY6.js → hostInit-BEpzKY8C.js} +1 -1
- package/dist/assets/index-C5g8h6ZU.js +4 -0
- package/dist/assets/{key-round-DM-bc9EL.js → key-round-DUZWZ_rI.js} +1 -1
- package/dist/assets/{layers-Bpr1190F.js → layers-Czk9MtAZ.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-bb6403be.js → mf-entry-bootstrap-0-bb1142ed.js} +2 -2
- package/dist/assets/{pencil-DwVxBtRq.js → pencil-DtuLbgSG.js} +1 -1
- package/dist/assets/play-BJCc4fGn.js +1 -0
- package/dist/assets/{player-overlays-BCQdGsro.js → player-overlays-Bx-E68JT.js} +1 -1
- package/dist/assets/plus-D5JVg6nA.js +1 -0
- package/dist/assets/power-BjgBAjFq.js +1 -0
- package/dist/assets/{radio-lPQ2yM4-.js → radio-B_dQ98Hi.js} +1 -1
- package/dist/assets/{refresh-cw-B71pScMn.js → refresh-cw-DsTF0HtQ.js} +1 -1
- package/dist/assets/remoteEntry-BWuMimQ_.js +1 -0
- package/dist/assets/rotate-ccw-CFqgYAHl.js +1 -0
- package/dist/assets/rotate-cw-D7RHGKK4.js +1 -0
- package/dist/assets/{send-McKGaUOv.js → send-BP6R0rRO.js} +1 -1
- package/dist/assets/{server-BgQAF0aD.js → server-D37fa07L.js} +1 -1
- package/dist/assets/{shield-DXMW1GPu.js → shield-B6cq5CW6.js} +1 -1
- package/dist/assets/square-CZw5Ock3.js +1 -0
- package/dist/assets/{square-check-big-DScyC9MB.js → square-check-big-Jbtwig6c.js} +1 -1
- package/dist/assets/{src-C8hTTV3c.js → src-BoA1cQeV.js} +17 -17
- package/dist/assets/src-Hd2A_xp6.js +349 -0
- package/dist/assets/{star-BiT5sdqS.js → star-f_-GYi1D.js} +1 -1
- package/dist/assets/{undo-2-DfbcPL7P.js → undo-2-S6HqaEGy.js} +1 -1
- package/dist/assets/{use-scenes-feed-Bgj1reXk.js → use-scenes-feed-C5C2RGwJ.js} +1 -1
- package/dist/assets/useEventInvalidation-2W9yFdBU.js +1 -0
- package/dist/assets/{video-BYECCQZN.js → video-CxvKF_Ar.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-uqvcPwW_.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B11mjU62.js} +2 -2
- package/dist/assets/{wifi-DibERz0x.js → wifi-B9yskYca.js} +1 -1
- package/dist/assets/{zap-OPtC9jyC.js → zap-8iaR87i8.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +453 -24
- package/package.json +1 -1
- package/dist/assets/Cluster-BvpnwAD3.js +0 -11
- package/dist/assets/Data-BaMNNJrD.js +0 -1
- package/dist/assets/Identity-zbCRfiNF.js +0 -1
- package/dist/assets/Pipeline-WHTwvGXg.js +0 -1
- package/dist/assets/Plates-qEe_Mv2J.js +0 -1
- package/dist/assets/Recordings-DLxT8YmO.js +0 -1
- package/dist/assets/circle-check-big-BlFY96nJ.js +0 -1
- package/dist/assets/clock-BVH-Z5HY.js +0 -1
- package/dist/assets/dist-PqtOFQle.js +0 -349
- package/dist/assets/index-BIfDsZsD.js +0 -4
- package/dist/assets/play-BjgANexL.js +0 -1
- package/dist/assets/plus-M-gqh1gB.js +0 -1
- package/dist/assets/power-Dx5nuIxU.js +0 -1
- package/dist/assets/remoteEntry-CKAtt3xy.js +0 -1
- package/dist/assets/rotate-ccw-7C_SQNwr.js +0 -1
- package/dist/assets/rotate-cw-OeCPV-3E.js +0 -1
- package/dist/assets/square-CEBPzPgT.js +0 -1
- package/dist/assets/src-D_m3ma12.js +0 -349
- package/dist/assets/useEventInvalidation-DE7flGNJ.js +0 -1
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,V as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as d}from"./player-overlays-BCQdGsro.js";import{Ba as f,Ct as p,Hr as m,Io as h,Is as g,J as _,Ji as v,Lo as y,Qo as b,Ro as x,Rs as S,St as C,ao as w,ea as T,ia as ee,na as te,nt as E,q as ne,qi as re,ra as ie,ta as ae,tt as D,un as O,wt as oe,xt as se,zo as ce}from"./src-C8hTTV3c.js";import{Et as le}from"./src-D_m3ma12.js";import{t as ue}from"./pencil-DwVxBtRq.js";import{t as de}from"./radio-lPQ2yM4-.js";import{t as fe}from"./refresh-cw-B71pScMn.js";import{t as k}from"./rotate-cw-OeCPV-3E.js";import{t as pe}from"./server-BgQAF0aD.js";import{C as A,H as me,I as he,K as j,N as M,R as ge,X as _e,a as N,m as ve,o as ye,p as be,r as P,t as F,z as xe}from"./index-BIfDsZsD.js";import{t as Se}from"./NodeAddonsSettingsPanel-B2J7nqRT.js";import{t as I}from"./format-size-DIxKXxtj.js";var L=j(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Ce=j(`hard-drive-download`,[[`path`,{d:`M12 2v8`,key:`1q4o3n`}],[`path`,{d:`m16 6-4 4-4-4`,key:`6wukr`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,key:`w68u3i`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M10 18h.01`,key:`h775k`}]]),R=j(`memory-stick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]);n();function we(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Te({state:e}){return l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e===`running`?`bg-success/10 text-success`:e===`crashed`||e===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e})}var Ee=[`trace`,`debug`,`info`,`warn`,`error`];function De({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,d]=c(s||n),[f,m]=c(null),[h,g]=c(`info`),v=e.name.includes(`(core)`),y=ae(),b=te(),x=ie(),S=async e=>{m(e);try{await y.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},w=async()=>{m(e.name);try{await b.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{m(null)}},T=async n=>{let r=`${t}/${e.name}`;try{await x.mutateAsync({nodeId:r,level:n}),g(n)}catch(e){console.error(`Failed to set log level:`,e)}};return r(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[r(`div`,{role:s?void 0:`button`,tabIndex:s?void 0:0,onClick:s?void 0:()=>d(!u),onKeyDown:s?void 0:e=>{(e.key===`Enter`||e.key===` `)&&d(!u)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?l(`span`,{className:`h-3 w-3 shrink-0`}):l(u?ge:he,{className:`h-3 w-3 text-muted-foreground shrink-0`}),v?l(pe,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(me,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),l(`span`,{className:`text-xs font-semibold flex-1`,children:e.name}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,e.pid]}),l(Te,{state:e.state}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.cpuPercent,`% CPU`]}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:I(e.memoryRss)}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:we(e.uptimeSeconds)}),!v&&r(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[r(se,{children:[l(oe,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:`Set log level`,children:h}),l(C,{align:`end`,className:`min-w-[70px] py-0.5`,children:Ee.map(e=>l(p,{onClick:()=>T(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:w,disabled:f===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:l(k,{className:`h-3 w-3 ${f===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&l(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),l(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&r(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&r(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[l(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:l(ve,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:l(de,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>S(e.addonId),disabled:f===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:l(k,{className:`h-3 w-3 ${f===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(_,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(ne,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&l(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function Oe({nodeId:e,processes:t}){let[n,r]=c(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):l(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>l(De,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}var ke={system:0,managed:1,root:2};n();function Ae(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function je(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Me({nodeId:e}){let t=s(),n=g(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:i}=v({nodeId:e}),o=n?.processes??i,c=a(()=>o?[...o]:[],[o]),u=a(()=>[{key:`classification`,header:`Class`,sortValue:e=>ke[e.classification],render:e=>l(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-sky-500/20 text-sky-400`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>l(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>l(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:`Addon`,sortValue:e=>e.addonId,render:e=>l(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:`Command`,nowrap:!1,render:e=>l(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:je(e.command)})},{key:`cpuPercent`,header:`CPU%`,align:`right`,sortValue:e=>e.cpuPercent,render:e=>e.cpuPercent.toFixed(1)},{key:`memoryRssBytes`,header:`RSS`,align:`right`,sortValue:e=>e.memoryRssBytes,render:e=>I(e.memoryRssBytes)},{key:`uptimeSec`,header:`Uptime`,align:`right`,sortValue:e=>e.uptimeSec,render:e=>l(`span`,{className:`text-foreground-subtle`,children:Ae(e.uptimeSec)})}],[]);return r(`div`,{className:`space-y-4`,children:[l(`div`,{className:`flex items-start justify-end gap-4`,children:r(`button`,{type:`button`,onClick:()=>t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[l(fe,{className:`h-3 w-3`}),` Refresh`]})}),l(D,{columns:u,rows:c,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`scroll`,maxBodyHeight:E,emptyMessage:`Scanning…`})]})}var z={width:320,height:64},B=.8,V=Math.ceil(8*B-3)+1,H=z.width+34,U=z.height+V+1+11,Ne=V+z.height+1+3+Math.ceil(8*B),Pe=[1,2,5,10],Fe=[1,2,4,8,16,32,64,128,256,512,1024],W=[1,1.5,2,2.5,3,4,5],G=[4,3,5,2],Ie=1e-9;function Le(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return W.some(e=>Math.abs(t-e)<Ie)}let n=e/10**Math.floor(Math.log10(e));return W.some(e=>Math.abs(n-e)<Ie)}function Re(e,t,n){let r=0;for(let t of e)t!==null&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of Fe){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of Pe){let t=e*i;if(t>=r)return t}return 10*i}function ze(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=G.find(n=>Le(e/n,t))??G[G.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var Be=2.5;function Ve(e){return e*Be}function K(e,t,n,r){if(e.length===0)return[];let i=e[0].atMs,a=e.at(-1).atMs-i,o=n<=0?1:n,s=r!==void 0&&r>0?r:null;return e.map((r,c)=>{let l=a>0?(r.atMs-i)/a*t.width:c/Math.max(1,e.length-1)*t.width,u=c>0?e[c-1]:void 0;return{x:l,y:r.value===null?null:t.height-Math.min(r.value,n)/o*t.height,gapBefore:s!==null&&u!==void 0&&r.atMs-u.atMs>s}})}function He(e){let t=[],n=!1;for(let r of e){if(r.y===null){n=!1;continue}r.gapBefore&&(n=!1),t.push(`${n?`L`:`M`}${r.x.toFixed(1)},${r.y.toFixed(1)}`),n=!0}return t.join(` `)}function Ue(e,t){let n=[],r=[],i=()=>{if(r.length<2){r=[];return}let e=r.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(1)},${e.top.toFixed(1)}`),t=[...r].reverse().map(e=>`L${e.x.toFixed(1)},${e.bottom.toFixed(1)}`);n.push(`${e.join(` `)} ${t.join(` `)} Z`),r=[]};for(let n=0;n<e.length;n++){let a=e[n],o=t[n];if(!a||!o||a.y===null||o.y===null){i();continue}(a.gapBefore||o.gapBefore)&&i(),r.push({x:a.x,top:a.y,bottom:o.y})}return i(),n.join(` `)}function We(e,t,n=3){if(e.length<2||n<2)return[];let r=e[0].atMs,i=e.at(-1).atMs-r;if(i<=0)return[];let a=[];for(let e=0;e<n;e++){let o=e/(n-1);a.push({atMs:r+i*o,x:o*t.width,anchor:e===0?`start`:e===n-1?`end`:`middle`})}return a}function Ge(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function Ke(e){let t=[];for(let n=1;n<e.length;n++){let r=e[n];r.gapBefore&&t.push({fromX:e[n-1].x,toX:r.x})}return t}function qe(e,t){if(e.length===0)return null;let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i].x-t);a<r&&(r=a,n=i)}return n}n();var q={main:`var(--load-series-main)`,gc:`var(--load-series-gc)`},Je=`
|
|
2
|
-
.load-chart-scope { --load-series-main: #2a78d6; --load-series-gc: #e87ba4; }
|
|
3
|
-
@media (prefers-color-scheme: dark) {
|
|
4
|
-
:root:not([data-theme="light"]) .load-chart-scope {
|
|
5
|
-
--load-series-main: #3987e5; --load-series-gc: #d55181;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
:root[data-theme="dark"] .load-chart-scope {
|
|
9
|
-
--load-series-main: #3987e5; --load-series-gc: #d55181;
|
|
10
|
-
}
|
|
11
|
-
`,J=z,Ye={height:U};function Xe({title:e,points:n,mainLabel:s,gcLabel:u,formatValue:d,emptyMessage:f,gapMs:p}){let m=i(),h=t(null),[g,_]=c(null),v=a(()=>{let e=n.map(e=>({atMs:e.atMs,value:e.main===null||e.gc===null?null:e.main+e.gc})),t=n.map(e=>({atMs:e.atMs,value:e.main})),r=Re(e.map(e=>e.value),25,`linear`),i=K(e,J,r,p),a=K(t,J,r,p),o=a.map(e=>({x:e.x,y:e.y===null?null:J.height,gapBefore:e.gapBefore}));return{max:r,ticks:ze(r,`linear`),upper:i,middle:a,base:o,gaps:Ke(i),times:We(e,J),spanMs:Ge(e)}},[n,p]),y=n.at(-1),b=g===null?void 0:n[g.index],x=b??y;return n.length===0||v.upper.every(e=>e.y===null)?l(Z,{title:e,children:l(at,{message:f})}):l(Z,{title:e,legend:r(o,{children:[l(it,{color:q.main,label:s}),l(it,{color:q.gc,label:u})]}),readout:x&&x.main!==null&&x.gc!==null?r(o,{children:[b!==void 0&&l(rt,{atMs:b.atMs,spanMs:v.spanMs}),l(Q,{color:q.main,text:d(x.main)}),l(Q,{color:q.gc,text:d(x.gc)})]}):null,children:r(`svg`,{ref:h,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,className:`w-full`,style:Ye,role:`img`,"aria-label":`${e}: ${s} and ${u} over time`,onMouseLeave:()=>_(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*H-34,r=qe(v.upper,n);r!==null&&_({index:r,xPx:v.upper[r].x})},children:[l(Ze,{ticks:v.ticks,max:v.max,formatValue:d}),l(nt,{ticks:v.times,spanMs:v.spanMs}),r(`g`,{transform:`translate(34,${V})`,clipPath:`url(#${m})`,children:[l(`clipPath`,{id:m,children:l(`rect`,{x:0,y:0,width:J.width,height:J.height})}),l(X,{spans:v.gaps}),l(`path`,{d:Ue(v.middle,v.base),fill:q.main,fillOpacity:.85}),l(`path`,{d:Ue(v.upper,v.middle),fill:q.gc,fillOpacity:.85,stroke:`var(--color-surface, transparent)`,strokeWidth:2}),l(`path`,{d:He(v.upper),fill:`none`,stroke:q.gc,strokeWidth:2}),g!==null&&l(`line`,{x1:g.xPx,x2:g.xPx,y1:0,y2:J.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function Y({title:e,points:n,formatValue:i,emptyMessage:s,axisFloor:u,axisScale:d=`linear`,gapMs:f}){let p=t(null),[m,h]=c(null),g=a(()=>{let e=Re(n.map(e=>e.value),u,d),t=K(n,J,e,f);return{max:e,ticks:ze(e,d),projected:t,gaps:Ke(t),times:We(n,J),spanMs:Ge(n)}},[n,u,d,f]),_=m===null?void 0:n[m.index],v=_??n.at(-1)??void 0;return n.length===0||g.projected.every(e=>e.y===null)?l(Z,{title:e,children:l(at,{message:s})}):l(Z,{title:e,readout:v&&v.value!==null?r(o,{children:[_!==void 0&&l(rt,{atMs:_.atMs,spanMs:g.spanMs}),l(Q,{color:q.main,text:i(v.value)})]}):null,children:r(`svg`,{ref:p,viewBox:`0 0 ${H} ${U}`,preserveAspectRatio:`none`,className:`w-full`,style:Ye,role:`img`,"aria-label":e,onMouseLeave:()=>h(null),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();if(t.width===0)return;let n=(e.clientX-t.left)/t.width*H-34,r=qe(g.projected,n);r!==null&&h({index:r,xPx:g.projected[r].x})},children:[l(Ze,{ticks:g.ticks,max:g.max,formatValue:i}),l(nt,{ticks:g.times,spanMs:g.spanMs}),r(`g`,{transform:`translate(34,${V})`,children:[l(X,{spans:g.gaps}),l(`path`,{d:He(g.projected),fill:`none`,stroke:q.main,strokeWidth:2}),m!==null&&l(`line`,{x1:m.xPx,x2:m.xPx,y1:0,y2:J.height,stroke:`currentColor`,strokeWidth:1,className:`text-foreground-subtle`})]})]})})}function Ze({ticks:e,max:t,formatValue:n}){let i=t<=0?1:t;return l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>{let t=V+J.height-e/i*J.height;return r(`g`,{children:[l(`line`,{x1:34,x2:34+J.width,y1:t,y2:t,stroke:`currentColor`,strokeWidth:.5,strokeOpacity:.3}),l(`text`,{x:0,y:t+3,fontSize:8,fill:`currentColor`,children:n(e)})]},e)})})}function X({spans:e}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`rect`,{x:e.fromX,y:0,width:Math.max(1,e.toX-e.fromX),height:J.height,fill:`currentColor`,fillOpacity:.12,children:l(`title`,{children:`No samples in this interval — nothing was measured, nothing is drawn.`})},`${e.fromX}-${e.toX}`))})}var Qe=10*6e4,$e={hour:`2-digit`,minute:`2-digit`},et={hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function tt(e,t){return new Date(e).toLocaleTimeString(void 0,t<Qe?et:$e)}function nt({ticks:e,spanMs:t}){return e.length===0?null:l(`g`,{className:`text-foreground-subtle`,children:e.map(e=>l(`text`,{x:34+e.x,y:Ne,fontSize:8,textAnchor:e.anchor,fill:`currentColor`,children:tt(e.atMs,t)},e.atMs))})}function rt({atMs:e,spanMs:t}){return l(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:tt(e,t)})}function Z({title:e,legend:t,readout:n,children:i}){return r(`div`,{className:`load-chart-scope min-w-0`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:e}),l(`div`,{className:`flex items-center gap-2`,children:n})]}),i,t&&l(`div`,{className:`flex items-center gap-3 mt-1`,children:t})]})}function it({color:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[9px] text-foreground-subtle`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function Q({color:e,text:t}){return r(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-[2px]`,style:{backgroundColor:e}}),t]})}function at({message:e}){return l(`div`,{className:`h-16 flex items-center justify-center rounded border border-dashed border-border text-[10px] text-foreground-subtle text-center px-2`,children:e})}function ot(e,t){let n=e.at(-1);return n===void 0?[t]:t.atMs>n.atMs?[...e,t]:e.some(e=>e.atMs===t.atMs)?e:[...e,t].toSorted((e,t)=>e.atMs-t.atMs)}function st(e,t,n,r){let i=e.get(t),a=ot(i?.points??[],r);if(i!==void 0&&a===i.points)return e;let o=new Map(e);return o.set(t,{key:t,kind:n,points:a.slice(Math.max(0,a.length-720))}),o}function ct(e,t,n){let r=e;for(let e of le(t,n))r=st(r,e.key,e.kind,e.point);return r}function lt(e,t){let n=e;for(let e of t)for(let t of e.points)n=st(n,e.key,e.kind,t);return n}function ut(e){let t=null;for(let n of e.values()){let e=n.points.at(-1);e!==void 0&&(t===null||e.atMs>t)&&(t=e.atMs)}return t}var dt=12e4;function ft(e,t){return e===null?!1:t-e>dt}function pt(e){let t=e=>{let t=e.points.at(-1);return t===void 0?-1:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.key.localeCompare(n.key):r})}function mt(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var ht={key:`cpu`,dir:`desc`};function gt(e){let t=e.points.at(-1);return t===void 0?null:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent}function _t(e){return e.points.at(-1)?.memoryRssBytes??null}function vt(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function yt(e,t){return t===`memory`?_t(e):gt(e)}function bt(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:vt(n(e),e.key,t.search)),i=(e,t)=>e.key.localeCompare(t.key);return[...r].toSorted((e,r)=>{if(t.sort.key===`name`){let a=n(e).localeCompare(n(r)),o=t.sort.dir===`asc`?a:-a;return o===0?i(e,r):o}let a=yt(e,t.sort.key),o=yt(r,t.sort.key);if(a===null&&o===null)return i(e,r);if(a===null)return 1;if(o===null)return-1;let s=t.sort.dir===`desc`?o-a:a-o;return s===0?i(e,r):s})}n();function xt(e,n=720){let r=g(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,a]=c(new Map),[o,s]=c(void 0),l=t(null),{data:d,isPending:f}=re({forNodeId:e,sinceMs:o,maxPoints:n});u(()=>{d!==void 0&&a(e=>{let t=lt(e,d.series);return l.current=ut(t),t})},[d]);let p=r?.timestamp;u(()=>{r==null||p===void 0||(ft(l.current,p)&&s(l.current??0),a(e=>{let t=ct(e,r.processes,p);return l.current=ut(t),t}))},[p]),u(()=>{a(new Map),s(void 0),l.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:pt(i),sampleCount:m,threadSplitAvailable:mt(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var St=`__unclaimed__`;function Ct(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function wt(e,t){return{key:e,kind:t.kind,deviceId:t.deviceId,cpuSeconds:t.cpuKnown?Math.round(t.cpu*100)/100:null,rssBytes:t.rssKnown?t.rss:null,unitCount:t.count,roles:[...t.roles].sort()}}function Tt(e,t){let n=new Map,r=new Set;for(let t of e){t.pid!==void 0&&r.add(t.pid);let e=t.deviceId!==null&&t.attribution!==`unattributable`,i=e?`device:${t.deviceId}`:`shared:${t.role}`,a=n.get(i)??Ct(e?`camera`:`shared`,e?t.deviceId:null);a.count+=1,a.roles.add(t.role),t.cpuSeconds===void 0?a.cpuKnown=!1:a.cpu+=t.cpuSeconds,t.rssBytes===void 0?a.rssKnown=!1:a.rss+=t.rssBytes,n.set(i,a)}let i=[...n.entries()].map(([e,t])=>wt(e,t));if(t===void 0)return i;let a=t.filter(e=>!r.has(e.pid));if(a.length===0)return i;let o=Ct(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,wt(St,o)]}var Et=[{family:`decode`,attribution:`measured`,unit:`one forked decode-worker child per decode SESSION`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:118`,`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:131`,`packages/addon-pipeline/src/pipeline-runner/index.ts:2765`,`packages/types/src/process/child-cost-registry.ts:188`]},{family:`transcode`,attribution:`measured`,unit:`one ffmpeg child per (camera, encode plan)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/egress-transcode-manager.ts:960`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:282`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:324`,`packages/types/src/ffmpeg/sharing-key.ts:139`]},{family:`recording`,attribution:`measured`,unit:`one passthrough ffmpeg per (camera, profile)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:33`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:217`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:279`,`packages/addon-pipeline/src/recorder/addon/recording-controller.ts:1710`]},{family:`detection`,attribution:`accounted`,unit:`a SHARED inference pool per (node, runtime, device) — no per-camera process`,perCamera:!1,wiredToday:!0,missingLink:"Nothing is missing for COUNTING — per-camera inference milliseconds, processed/shed frames and bytes-to-pool are already accumulated. What is missing is any basis for CPU seconds: `deviceId` reaches the pool as a diagnostic label and selects nothing, so cost can only ever be apportioned, never measured. Since 2026-08-27 the pool DECLARES this itself, contributing `deviceId: null` + `attribution: unattributable` rather than leaving an observer to infer it — the renunciation is data, and it is still refused by the chart gate.",evidence:[`packages/addon-pipeline/src/detection-pipeline/provider.ts:540`,`packages/addon-pipeline/src/detection-pipeline/engine/shared-inference-pool.ts:413`,`packages/types/src/interfaces/inference-engine.ts:24`,`packages/addon-pipeline/src/pipeline-runner/timing-sampler.ts:63`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:353`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:849`,`packages/addon-pipeline/src/pipeline-runner/frame-lazy-metrics.ts:100`]},{family:`streaming`,attribution:`measured`,unit:"one StreamBroker per `${deviceId}/${camStreamId}`, with an exact RTP ring byte counter",perCamera:!0,wiredToday:!1,missingLink:"The ffmpeg-backed ingest is now reported per camera, but that is the minority path. `rtpRingBytes` — the exact figure for the in-process case — is maintained on every push and drop and is still private and absent from `getStats()`. The three `EncodedRingBuffer`s track packets and duration and have no byte accumulator at all; the only byte figure they offer is `preRollBudgetBytes`, which is a BUDGET, not an occupancy.",evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2895`,`packages/addon-pipeline/src/stream-broker/rtsp/ffmpeg-push-reader.ts:189`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:494`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:498`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2505`,`packages/addon-pipeline/src/stream-broker/stream-broker/pre-roll.ts:269`]}];function Dt(e){return e.attribution===`measured`&&e.wiredToday}function Ot(){let e=new Set;for(let t of Et)Dt(t)&&e.add(t.family);return e}var kt=Ot();function At(e){return!kt.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function jt(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function Mt(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function Nt(e,t,n){if(t.cpuSeconds===void 0)return null;if(e===void 0)return t.startedAtMs===void 0||t.startedAtMs<n?null:t.cpuSeconds;if(e.cpuSeconds===void 0||e.startedAtMs===void 0||t.startedAtMs===void 0||e.startedAtMs!==t.startedAtMs)return null;let r=t.cpuSeconds-e.cpuSeconds;return r<0?null:r}function Pt(e){return Math.round(e*10)/10}function Ft(e,t){let n=t.atMs-e.atMs;if(n<=0)return[];let r=n/1e3,i=new Map;for(let t of e.entries)At(t)&&i.set(jt(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!At(n)||n.deviceId===null)continue;let t=jt(n);o.add(t);let r=a.get(n.deviceId)??Mt();r.unitCount+=1,r.roles.add(n.role);let s=Nt(i.get(t),n,e.atMs);s===null?r.cpuKnown=!1:r.cpuSeconds+=s,n.rssBytes===void 0?r.rssKnown=!1:r.rssBytes+=n.rssBytes,a.set(n.deviceId,r)}for(let[e,t]of i){if(o.has(e)||t.deviceId===null)continue;let n=a.get(t.deviceId);n!==void 0&&(n.cpuKnown=!1)}return[...a.entries()].map(([e,n])=>({deviceId:e,point:{atMs:t.atMs,cpuPercent:n.cpuKnown?Pt(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function It(e,t){if(t.length===0)return e;let n=new Map(e);for(let e of t){let t=n.get(e.deviceId),r=t?.points.at(-1);if(r!==void 0&&e.point.atMs<=r.atMs)continue;let i=[...t?.points??[],e.point];n.set(e.deviceId,{deviceId:e.deviceId,points:i.slice(Math.max(0,i.length-720))})}return n}function Lt(e){let t=e=>{for(let t=e.points.length-1;t>=0;t--){let n=e.points[t]?.cpuPercent;if(n!=null)return n}return-1};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.deviceId-n.deviceId:r})}function Rt(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function zt(e,t){let n=Rt(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Bt(e,t){return e.filter(e=>zt(e.addonId,t))}n();function Vt(e){let n=g(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=b(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,a]=c(new Map),o=t(null),s=t(r.refetch);s.current=r.refetch;let l=n?.timestamp;u(()=>{l!==void 0&&s.current()},[l]),u(()=>{a(new Map),o.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;u(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:Bt(d,e)},n=o.current;if(o.current=t,n===null)return;let r=Ft(n,t);r.length!==0&&a(e=>It(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Bt(d,e),m=n?.processes,h=Tt(p,m);return{series:Lt(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Ht(e){let t=new Map;for(let n of e){let e=n.name?.trim();e===void 0||e===``||t.set(n.id,e)}return t}var Ut=25,Wt=64*1024*1024,Gt=1e4;function Kt({scope:e,cadenceMs:t}){let{t:n}=F(),i=Vt(e),{data:a=[]}=m({isCamera:!0,projection:`slim`}),o=Ht(a),s=Ve(t??Gt);return r(`section`,{className:`space-y-3`,children:[i.error!==null&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[l(N,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:i.error})})]}),l(Jt,{unclaimed:i.unclaimed}),i.series.length===0&&i.error===null&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:i.loading?n(`cameraLoad.loading`,`Reading what the addons report…`):n(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),l(`div`,{className:`space-y-3`,children:i.series.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(qt,{deviceId:e.deviceId,name:o.get(e.deviceId)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:e.points.at(-1)?.unitCount??0,roles:(e.points.at(-1)?.roles??[]).join(`, `)})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(Y,{title:n(`cameraLoad.cpuTitle`,`CPU % of one core (delta)`),points:e.points.map(e=>({atMs:e.atMs,value:e.cpuPercent})),formatValue:e=>`${e.toFixed(1)}%`,axisFloor:Ut,gapMs:s,emptyMessage:n(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),l(Y,{title:n(`cameraLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:I,axisFloor:Wt,axisScale:`bytes`,gapMs:s,emptyMessage:n(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},e.deviceId))})]})}function qt({deviceId:e,name:t}){let{t:n}=F();return t===void 0?l(`span`,{className:`text-xs font-medium text-foreground`,children:n(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:e})}):r(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[l(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t}),r(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,e]})]})}function Jt({unclaimed:e}){let{t}=F();return e===null||e.unitCount===0?null:l(`div`,{className:`flex items-center gap-2`,children:l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full bg-amber-500/10 text-amber-400 font-medium tabular-nums`,children:t(`cameraLoad.unclaimedBadge`,`{{count}} unclaimed · {{rss}}`,{count:e.unitCount,rss:e.rssBytes===null?`—`:I(e.rssBytes)})})})}n();var Yt=256*1024*1024,Xt=1e4;function Zt({nodeId:e,isHub:t}){let{t:n}=F(),{series:i,sampleCount:o,threadSplitAvailable:s,loadingRetained:u,bucketMs:d,cadenceMs:f}=xt(e),[p,m]=c(``),[h,g]=c(new Set),[_,v]=c(ht),y=e=>e.key===`__root__`?n(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?n(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,b=Ve(d??f??Xt),x=a(()=>bt(i,{search:p,selectedKeys:h,sort:_},y),[i,p,h,_]),S=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return r(`div`,{className:`space-y-4`,children:[l(`style`,{children:Je}),l(Qt,{bucketMs:d,cadenceMs:f}),!s&&o>0&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/5 px-3 py-2 text-[11px] text-amber-400`,children:[l(N,{className:`h-3 w-3 mt-0.5 shrink-0`}),l(`span`,{children:n(`clusterLoad.noThreadSplit`,`No thread-level CPU split on this node — /proc/<pid>/task is Linux-only, and the first sample after a restart has no window to measure. CPU below falls back to the ps lifetime AVERAGE, which is not a rate.`)})]}),o===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?n(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):n(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),i.length>0&&r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`label`,{className:`relative flex-1 min-w-[160px]`,children:[l(be,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),l(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:n(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":n(`clusterLoad.searchLabel`,`Find a runner`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle`})]}),l($t,{sort:_,onChange:v})]}),r(`div`,{className:`flex flex-wrap items-center gap-1`,children:[i.map(e=>{let t=h.has(e.key);return l(`button`,{type:`button`,"aria-pressed":t,onClick:()=>S(e.key),className:`rounded-full border px-2 py-0.5 text-[10px] transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:y(e)},e.key)}),h.size>0&&r(`button`,{type:`button`,onClick:()=>g(new Set),className:`inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:[l(P,{className:`h-2.5 w-2.5`}),n(`clusterLoad.clearFilter`,`All runners`)]})]})]}),i.length>0&&x.length===0&&l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:n(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:i.length})}),l(`div`,{className:`space-y-3`,children:x.map(e=>r(`div`,{className:`rounded-lg border border-border p-3`,children:[r(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[l(`span`,{className:`text-xs font-medium text-foreground`,children:y(e)}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.processCount`,`{{count}} process(es)`,{count:e.points.at(-1)?.processCount??0})})]}),r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[l(Xe,{title:s?n(`clusterLoad.cpuTitle`,`CPU % of one core`):n(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:n(`clusterLoad.seriesMain`,`Main threads`),gcLabel:n(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:e.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:b,emptyMessage:n(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(e.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),l(Y,{title:n(`clusterLoad.memoryTitle`,`Memory RSS`),points:e.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:I,axisFloor:Yt,axisScale:`bytes`,gapMs:b,emptyMessage:n(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},e.key))}),l(Kt,{scope:{nodeId:e,isHub:t},cadenceMs:f})]})}function Qt({bucketMs:e,cadenceMs:t}){let{t:n}=F();return e===null?null:l(`p`,{className:`text-[10px] text-foreground-subtle`,children:t!==null&&e>t?n(`clusterLoad.captionBucket`,`1 point = {{bucket}}s (bucket MAXIMUM, not a mean)`,{bucket:Math.round(e/1e3)}):n(`clusterLoad.captionRaw`,`1 point = 1 snapshot`)})}function $t({sort:e,onChange:t}){let{t:n}=F(),i=[{key:`cpu`,label:n(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:n(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:n(`clusterLoad.sortName`,`Name`)}];return r(`div`,{className:`flex items-center gap-1`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`clusterLoad.sortBy`,`Sort by`)}),i.map(n=>{let i=e.key===n.key;return r(`button`,{type:`button`,"aria-pressed":i,onClick:()=>t(i?{key:n.key,dir:e.dir===`desc`?`asc`:`desc`}:{key:n.key,dir:n.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[n.label,i&&(e.dir===`desc`?` ↓`:` ↑`)]},n.key)})]})}var en=`No per-node settings on this node. Every other setting these addons expose is one value for the whole cluster — edit those in System → Settings, not here.`;function tn({nodeId:e,addonIds:t}){return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):l(`div`,{className:`w-full py-2`,children:l(Se,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:en,selfTabbed:!0})})}n();function nn({nodeId:e,addons:t}){let n=s(),{data:r,isLoading:i}=f({nodeId:e}),o=a(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),c=w({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return o.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):l(D,{columns:[{key:`capName`,header:`Capability`,width:`w-1/2`,sortValue:e=>e.capName,render:e=>l(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:`Bound provider`,render:t=>{let n=r?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return l(`select`,{value:n,onChange:n=>c.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||c.isPending||i,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:a?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:t.providers.map(e=>l(`option`,{value:e,children:e},e))})}}],rows:o,rowKey:e=>e.capName,minWidthPx:520,mobileMode:`scroll`,maxBodyHeight:E})}n();function rn(e){if(e==null)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:`${i}m`}function an(e){let[t,n]=c(!1),[i,a]=c(e.name),o=s(),u=T({onSuccess:()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),d=(e.localIps??[]).filter(e=>!e.includes(`:`)),f=(e.localIps??[]).filter(e=>e.includes(`:`)),p=async()=>{if(!i.trim()||i===e.name){n(!1);return}try{await u.mutateAsync({nodeId:e.nodeId,name:i.trim()}),n(!1)}catch(e){console.error(`Rename failed:`,e)}},m=[[`Node ID`,l(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,t?r(`div`,{className:`flex items-center gap-1.5`,children:[l(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&n(!1)},disabled:u.isPending,autoFocus:!0}),l(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:l(xe,{className:`h-3.5 w-3.5`})}),l(`button`,{onClick:()=>n(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:l(P,{className:`h-3.5 w-3.5`})})]}):r(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&l(`button`,{onClick:()=>{a(e.name),n(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:l(ue,{className:`h-3 w-3`})})]})],[`Hostname`,l(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Root Package`,e.rootPackage?r(`span`,{className:`font-mono text-xs`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,r(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,r(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,e.cpuCores,` cores)`]})],[`Memory`,l(`span`,{className:`text-xs`,children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,l(`span`,{className:`text-xs`,children:rn(e.uptime)})],[`Engines`,e.engines.length>0?l(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e))}):l(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return d.length>0&&m.push([`IPv4`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map((e,t)=>l(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),f.length>0&&m.push([`IPv6`,l(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>l(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),l(`div`,{className:`py-2`,children:l(`table`,{className:`w-full text-sm`,children:l(`tbody`,{children:m.map(([e,t],n)=>r(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[l(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),l(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}n();var on=[[`serverManagement`,`getServerPackageStatus`]];function sn({label:e,tone:t}){return l(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${{neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-emerald-500/15 text-emerald-500`,info:`bg-sky-500/15 text-sky-500`,warn:`bg-amber-500/15 text-amber-500`,error:`bg-red-500/15 text-red-500`}[t]}`,children:e})}function $({label:e,value:t}){return r(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:e}),l(`span`,{className:`font-mono text-foreground`,children:t??`—`})]})}function cn({node:t}){let{t:n}=F(),i=s(),a=O(),[o,u]=c(!1),d=t.isHub?void 0:{nodeId:t.id},f=x(d,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),p=f.data??null,m=e(()=>{i.invalidateQueries({queryKey:on})},[i]),g=y({onSettled:m}),_=h({onSettled:m}),v=ce({onSettled:m}),b=e(async()=>{p?.latestVersion!=null&&await a({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:p.packageName,version:p.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})&&(await _.mutateAsync({version:p.latestVersion,...d})).restarting&&u(!0)},[_,a,t.name,d,p,n]),S=e(async()=>{await a({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})&&(await v.mutateAsync(d)).restarting&&u(!0)},[a,t.name,v,d,n]),C=()=>{switch(p?.bootMode){case`data-root`:return{label:n(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:n(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:n(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},w=()=>{if(p==null)return null;switch(p.updateState){case`checking`:return{label:n(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:n(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:n(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return p.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},T=p?.bootMode===`workspace`,ee=t.isOnline&&p!=null&&!T&&p.updateAvailable&&p.updateState===`idle`&&!_.isPending,te=t.isOnline&&p!=null&&p.updateState===`idle`&&!v.isPending,E=t.isOnline?w():null;return r(`div`,{className:`space-y-4 py-2`,children:[r(`div`,{className:`flex items-center justify-between gap-3`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[l(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:p?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&p!=null&&l(sn,{...C()})]}),E!=null&&l(sn,{...E})]}),!t.isOnline&&l($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&f.isLoading&&r(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[l(A,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&f.isError&&r(`div`,{className:`space-y-1.5`,children:[l(`p`,{className:`text-sm text-red-500`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&l($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&p!=null&&r(`div`,{className:`space-y-1.5`,children:[l($,{label:n(`serverManagement.runningVersion`,`Running version`),value:p.runningVersion}),l($,{label:n(`serverManagement.latestVersion`,`Latest on registry`),value:p.latestVersion}),l($,{label:n(`serverManagement.imageSeedVersion`,`Image seed (baked)`),value:p.seedVersion}),l($,{label:n(`serverManagement.nodeRuntimeVersion`,`Node.js runtime`),value:p.nodeRuntimeVersion}),p.pendingVersion!=null&&l($,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:p.pendingVersion})]}),t.isOnline&&p?.imageContract?.state===`behind-series`&&r(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-xs leading-relaxed text-red-500`,children:[l(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),l(`p`,{children:p.imageContract.message})]}),t.isOnline&&T&&l(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),o&&r(`div`,{className:`flex items-center gap-2 text-sm text-amber-500`,children:[l(A,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&r(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:g.isPending||p?.updateState===`staging`,onClick:()=>g.mutate(d),children:[g.isPending?l(A,{className:`h-3.5 w-3.5 animate-spin`}):l(fe,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),ee&&r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void b(),children:[_.isPending?l(A,{className:`h-3.5 w-3.5 animate-spin`}):l(L,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:p?.latestVersion??``})]}),r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!te,onClick:()=>void S(),children:[v.isPending?l(A,{className:`h-3.5 w-3.5 animate-spin`}):l(k,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&p?.lastCheckedAtMs!=null&&r(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(Ce,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(p.lastCheckedAtMs).toLocaleString()})]})]})}n();function ln({node:e}){let t=d(),[n,i]=c(`info`),[a,o]=c(!1),s=e.processes??[],u=e.addons.map(e=>e.id),f=async()=>{if(!a){o(!0);try{await Promise.allSettled([t.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:e.id}),t.trpcClient.clusterNodes.forgetNode.mutate({nodeId:e.id})])}finally{o(!1)}}};return e.isOnline?r(`div`,{className:`border border-border rounded-xl`,children:[r(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success`}),l(`span`,{className:`text-sm font-semibold`,children:e.name}),r(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),r(`div`,{className:`ml-auto flex gap-3 text-xs text-muted-foreground`,children:[r(`span`,{className:`flex items-center gap-1`,children:[l(M,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),r(`span`,{className:`flex items-center gap-1`,children:[l(R,{className:`h-3 w-3`}),` `,e.memoryPercent,`%`]})]})]}),l(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>l(`button`,{onClick:()=>i(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${n===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?`General`:e===`forks`?`Forks (${s.length})`:e===`processes`?`Processes`:e===`load`?`Load`:e===`settings`?`Settings`:`Capabilities`},e))}),r(`div`,{className:`px-4 py-2`,children:[n===`info`&&r(`div`,{className:`space-y-3`,children:[l(an,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps,rootPackage:e.rootPackage}),l(`div`,{className:`border-t border-border pt-1`,children:l(cn,{node:{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,rootPackage:e.rootPackage??null}})})]}),n===`forks`&&l(Oe,{nodeId:e.id,processes:s}),n===`processes`&&l(Me,{nodeId:e.id}),n===`load`&&l(Zt,{nodeId:e.id,isHub:e.isHub}),n===`settings`&&l(tn,{nodeId:e.id,addonIds:u}),n===`capabilities`&&l(nn,{nodeId:e.id,addons:e.addons})]})]}):r(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[r(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30`,children:[l(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive`}),l(`span`,{className:`text-sm font-semibold`,children:e.name}),r(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),e.rootPackage&&r(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[e.rootPackage.name,`@`,e.rootPackage.version]}),l(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),r(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[r(`span`,{className:`text-xs text-muted-foreground`,children:[e.lastSeen?`Last seen ${new Date(e.lastSeen).toLocaleString()} — `:``,e.addons.length,` addon`,e.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),r(`button`,{type:`button`,onClick:()=>void f(),disabled:a,title:`Forget this node — removes its saved history and pipeline assignments`,className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[l(ye,{className:`h-3 w-3`}),a?`Forgetting…`:`Forget node`]})]})]})}function un(e){return[...e].toSorted((e,t)=>e.isHub===t.isHub?e.isOnline===t.isOnline?e.name.localeCompare(t.name):e.isOnline?-1:1:e.isHub?-1:1)}function dn(e,t){let n=un(e);return(t===null?void 0:n.find(e=>e.id===t))??n[0]??null}function fn({nodes:e,selected:t,onSelect:n}){let{t:i}=F(),a=un(e);return t===null?l(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-foreground-subtle`,children:i(`cluster.noNodes`,`No nodes in this cluster yet.`)}):r(`div`,{className:`flex flex-col gap-3`,children:[a.length>1&&l(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`tablist`,"aria-label":i(`cluster.nodeSelectorLabel`,`Nodes`),children:a.map(e=>l(pn,{node:e,active:e.id===t.id,onSelect:()=>n(e.id)},e.id))}),l(ln,{node:t})]})}function pn({node:e,active:t,onSelect:n}){let{t:i}=F();return r(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:n,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`}`,children:[l(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-destructive`}`}),l(`span`,{className:`font-medium`,children:e.name}),e.isOnline?r(`span`,{className:`inline-flex items-center gap-1 text-[10px] tabular-nums text-muted-foreground`,children:[l(M,{className:`h-3 w-3`}),e.cpuPercent,`%`,l(R,{className:`h-3 w-3`}),e.memoryPercent,`%`]}):l(`span`,{className:`text-[10px] text-destructive`,children:i(`cluster.offline`,`offline`)})]})}n();var mn=`node`;function hn(){let{data:e,isLoading:t}=ee(void 0,{staleTime:1/0}),[n,r]=c(null);return S(`cluster.topology-snapshot`,e=>{let t=e.data?.nodes;Array.isArray(t)&&r(t)}),{nodes:a(()=>n??e??[],[n,e]),isLoading:t&&!n}}function gn(){let{t}=F(),n=O(),{nodes:i,isLoading:o}=hn(),[s,u]=_e(),d=a(()=>dn(i,s.get(mn)),[i,s]),f=e(e=>{let t=new URLSearchParams(s);t.set(mn,e),u(t,{replace:!0})},[s,u]),p=a(()=>i.filter(e=>e.isOnline),[i]),m=p.length,g=i.filter(e=>!e.isOnline).length,_=h(),[v,y]=c(!1),b=e(async()=>{let e=[...p].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1);if(await n({title:t(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:t(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){y(!0);try{for(let t of e)try{await _.mutateAsync(t.isHub?{}:{nodeId:t.id})}catch{}}finally{y(!1)}}},[_,n,p,t]);return r(`div`,{className:`flex flex-col h-full gap-4 p-4`,children:[r(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[r(`div`,{className:`flex items-center gap-2`,children:[m>0&&r(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-success/10 text-success`,children:[m,` online`]}),g>0&&r(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:[g,` offline`]})]}),l(`div`,{className:`flex items-center gap-2`,children:m>1&&r(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,disabled:v,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void b(),children:[v?l(A,{className:`h-3.5 w-3.5 animate-spin`}):l(L,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})})]}),o?l(`div`,{className:`flex items-center justify-center flex-1 text-muted-foreground`,children:`Loading cluster topology...`}):l(`div`,{className:`flex-1 overflow-auto`,children:l(fn,{nodes:i,selected:d,onSelect:f})})]})}export{gn as ClusterPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{$n as l,Bo as u,Ho as d,Jo as f,Pn as p,Qn as m,Vo as h,Xn as g,Zn as _,ar as v,er as y,ir as b,nr as x,rr as S,tr as C,un as w}from"./src-C8hTTV3c.js";import{t as T}from"./download-D5kL_Go0.js";import{a as E,i as D,n as O,r as k,t as A}from"./AddLocationWizard-CLEzgi3l.js";import{t as j}from"./pencil-DwVxBtRq.js";import{t as M}from"./play-BjgANexL.js";import{t as N}from"./plus-M-gqh1gB.js";import{t as P}from"./rotate-cw-OeCPV-3E.js";import{C as F,I,K as L,R as ee,W as te,o as R,r as z}from"./index-BIfDsZsD.js";import{t as B}from"./AdminPage-CCD07UMs.js";import{r as ne}from"./authed-media-BPd_L9jr.js";import{t as re}from"./AdminTabs-BeziKJ1a.js";import{t as V}from"./format-size-DIxKXxtj.js";var H=L(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),U=L(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),W=L(`calendar-clock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]);t();function G(){let e=a(),t=w(),{data:i,isLoading:c,isError:l}=d({}),p=h(),m=r(()=>p.data??[],[p.data]),[g,_]=o(null),[v,y]=o(null),b=u({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),x=f({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),S=e=>{e.isDefault||x.mutate(D(e,{isDefault:!0}))},C=(e,t)=>{x.mutate(D(e,{enabled:t}))},T=async e=>{if(e.isDefault){await t({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another location as default first, then delete this one.`,confirmLabel:`OK`,variant:`warning`});return}await t({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`})&&b.mutate({id:e.id})},E=r(()=>{let e=new Map;for(let t of i??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[i]),j=c||p.isLoading,M=l||p.isError;return n(B,{children:[j&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),M&&s(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!j&&!M&&n(`div`,{className:`space-y-3`,children:[m.length===0&&s(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),m.map(e=>s(k,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:E.get(e.id)??[],onAdd:e=>_(e),onEdit:e=>y(e),onDelete:e=>{T(e)},onSetDefault:e=>S(e),onToggleEnabled:(e,t)=>C(e,t)},e.id))]}),g!==null&&s(A,{initialType:g,onClose:()=>_(null),onCreated:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),_(null)}}),v!==null&&s(O,{location:v,onClose:()=>y(null),onSaved:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),y(null)}})]})}t();var K=[[`backup`,`listDestinations`]],q=[`backup`,`listArchives`];function J({destinationId:t,restoreSupported:i,onOpenRestoreWizard:c}){let u=a(),d=w(),{data:f,isLoading:p,isError:m}=l({destinationId:t}),h=f??[],_=g({onSuccess:()=>{u.invalidateQueries({queryKey:[[...q]]}),u.invalidateQueries({queryKey:K})}}),v=e(async e=>{await d({title:`Delete this archive?`,message:`Permanently deletes "${e.label??e.id}" and frees ${V(e.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&_.mutate({destinationId:t,backupId:e.id})},[d,t,_]),[y,b]=o(null),x=e(async e=>{b(e.id);try{let n=await ne(Y(t,e.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.label??e.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{b(null)}},[t]),S=r(()=>[...h].toSorted((e,t)=>t.createdAt-e.createdAt),[h]);return p?s(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):m?s(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):S.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):s(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[640px]`,children:[s(`thead`,{children:n(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),s(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),s(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),s(`tbody`,{children:S.map(e=>n(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:ie(e.createdAt)}),s(`td`,{className:`px-3 py-1.5 text-foreground`,children:e.label??s(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),s(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:e.locations.join(`, `)}),s(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:V(e.sizeBytes)}),s(`td`,{className:`px-3 py-1.5`,children:n(`div`,{className:`flex items-center justify-end gap-1`,children:[n(`button`,{onClick:()=>{x(e)},disabled:y===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[y===e.id?s(F,{className:`h-3 w-3 animate-spin`}):s(T,{className:`h-3 w-3`}),`Download`]}),i&&c&&n(`button`,{onClick:()=>c({destinationId:t,archiveId:e.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[s(P,{className:`h-3 w-3`}),`Restore`]}),s(`button`,{onClick:()=>{v(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:_.isPending?s(F,{className:`h-3 w-3 animate-spin`}):s(R,{className:`h-3 w-3`})})]})})]},e.id))})]})})}function Y(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function ie(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}t();var X=[[`backup`,`listSchedules`]];function ae({onEdit:e,onOpenRestoreWizard:t}){let{data:i,isLoading:a,isError:c}=C(),l=i??[],u=y().data??[],d=r(()=>{let e=new Map;for(let t of u)e.set(t.id,t);return e},[u]),[f,p]=o(null),m=e=>{p(t=>t===e?null:e)};return a?s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading backup entries…`}):c?s(`div`,{className:`text-xs text-danger`,children:`Failed to load backup entries`}):l.length===0?s(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:s(`p`,{className:`text-xs text-foreground-subtle`,children:`No backup entries yet. Create one to schedule backups across one or more storage locations.`})}):s(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[820px]`,children:[s(`thead`,{children:n(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[s(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),s(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Entry`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),s(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Locations`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-24`,children:`Retention`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-48`,children:`Schedule`}),s(`th`,{className:`text-right px-3 py-2 font-medium w-52`,children:`Actions`})]})}),s(`tbody`,{children:l.map(n=>s(oe,{row:n,destById:d,isOpen:f===n.id,onToggle:()=>m(n.id),onEdit:()=>e(n),...t?{onOpenRestoreWizard:t}:{}},n.id))})]})})}function oe({row:t,destById:l,isOpen:u,onToggle:d,onEdit:f,onOpenRestoreWizard:p}){let m=a(),h=w(),g=v({onSuccess:()=>{m.invalidateQueries({queryKey:X})}}),y=_({onSuccess:()=>{m.invalidateQueries({queryKey:X})}}),x=b({onSuccess:()=>{m.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),m.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}}),[S,C]=o(String(t.retentionCount));c(()=>{C(String(t.retentionCount))},[t.retentionCount]);let T=r(()=>({id:t.id,label:t.label,cron:t.cron,locationIds:[...t.locationIds],retentionCount:t.retentionCount,...t.dataSources?{dataSources:[...t.dataSources]}:{}}),[t]),E=e(e=>{g.mutate({...T,enabled:e})},[g,T]),D=e(()=>{let e=Number.parseInt(S,10);if(Number.isNaN(e)||e<1){C(String(t.retentionCount));return}e!==t.retentionCount&&g.mutate({...T,enabled:t.enabled,retentionCount:e})},[g,T,S,t.retentionCount,t.enabled]),O=e(()=>{t.locationIds.length!==0&&x.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount})},[x,t]),k=e(async()=>{await h({title:`Delete backup entry?`,message:`"${t.label||t.id}" will stop running. Existing archives are kept.`,confirmLabel:`Delete`,variant:`warning`})&&y.mutate({id:t.id})},[h,y,t.id,t.label]),A=t.cron.trim().length>0,N=g.isPending||y.isPending;return n(i,{children:[n(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[s(`td`,{className:`px-2 py-2`,children:s(`button`,{onClick:d,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:u?`Hide archives`:`Show archives`,children:s(u?ee:I,{className:`h-3.5 w-3.5`})})}),s(`td`,{className:`px-3 py-2`,children:n(`button`,{onClick:f,className:`text-left hover:underline focus:outline-none`,children:[s(`div`,{className:`text-foreground font-medium`,children:t.label||`(unnamed)`}),t.lastRunAt!==void 0&&n(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[`last run `,new Date(t.lastRunAt).toLocaleString()]})]})}),s(`td`,{className:`px-3 py-2`,children:s(`label`,{className:`inline-flex items-center cursor-pointer`,children:s(`input`,{type:`checkbox`,className:`accent-primary`,checked:t.enabled,disabled:N,onChange:e=>E(e.target.checked)})})}),s(`td`,{className:`px-3 py-2`,children:n(`div`,{className:`flex flex-wrap gap-1`,children:[t.locationIds.length===0&&s(`span`,{className:`text-[11px] text-danger italic`,children:`No locations`}),t.locationIds.map(e=>s(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:l.get(e)?.displayName??e},e))]})}),s(`td`,{className:`px-3 py-2`,children:s(`input`,{type:`number`,min:1,max:1e3,value:S,disabled:N,onChange:e=>C(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&C(String(t.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),s(`td`,{className:`px-3 py-2`,children:n(`button`,{onClick:f,className:`group flex flex-col items-start gap-0.5 text-left`,title:`Edit schedule`,children:[n(`span`,{className:`inline-flex items-center gap-1`,children:[s(W,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),s(`span`,{className:`font-mono text-[11px] text-foreground`,children:A?t.cron:`Manual`})]}),A&&t.nextRunAt!==void 0&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`next `,new Date(t.nextRunAt).toLocaleString()]})]})}),s(`td`,{className:`px-3 py-2`,children:n(`div`,{className:`flex items-center justify-end gap-1.5`,children:[n(`button`,{onClick:O,disabled:x.isPending||t.locationIds.length===0,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,title:`Run this entry now`,children:[x.isPending?s(F,{className:`h-3 w-3 animate-spin`}):s(M,{className:`h-3 w-3`}),`Run now`]}),s(`button`,{onClick:f,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-foreground hover:bg-primary/5`,title:`Edit entry`,children:s(j,{className:`h-3 w-3`})}),s(`button`,{onClick:()=>{k()},disabled:N,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-danger hover:border-danger/40 disabled:opacity-50`,title:`Delete entry`,children:s(R,{className:`h-3 w-3`})})]})})]}),u&&s(`tr`,{className:`border-t border-border bg-background/30`,children:n(`td`,{colSpan:7,className:`px-4 py-3 space-y-4`,children:[t.locationIds.length===0&&s(`p`,{className:`text-xs text-foreground-subtle italic`,children:`This entry has no locations selected.`}),t.locationIds.map(e=>n(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:l.get(e)?.displayName??e}),s(J,{destinationId:e,restoreSupported:l.get(e)?.restoreSupported??!0,...p?{onOpenRestoreWizard:p}:{}})]},e))]})})]})}t();var Z=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function se(e){let t=e.trim();for(let e of Z)if(e.cron===t)return e.id;return`custom`}function ce({value:e,onChange:t,previewCount:r=5,disabled:i=!1}){let a=se(e),[l,u]=o(a===`custom`);c(()=>{a!==`custom`&&u(!1)},[a]);let d=de(e,250),f=x({cron:d,count:r},{enabled:d.trim().length>0}),p=f.data??null,m=e=>{u(!1),t(e.cron)},h=l||a===`custom`;return n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),n(`div`,{className:`flex flex-wrap gap-1.5`,children:[Z.map(e=>s(`button`,{type:`button`,onClick:()=>m(e),disabled:i,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!l&&a===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),s(`button`,{type:`button`,onClick:()=>{u(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:i,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(h?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),h&&n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),s(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:i,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,s(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),s(le,{cron:d,preview:p,loading:f.isFetching})]})}function le({cron:e,preview:t,loading:r}){return r&&t===null?n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[s(F,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?s(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),s(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>n(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[s(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),s(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:ue(e)})]},`${e}-${t}`))})]}):s(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function ue(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function de(e,t){let[n,i]=o(e),a=r(()=>e,[e]);return c(()=>{let e=setTimeout(()=>i(a),t);return()=>clearTimeout(e)},[a,t]),n}t();var fe=[[`backup`,`listSchedules`]];function pe({entry:e,onClose:t,onSaved:i}){let c=a(),l=y(),u=l.data??[],[d,f]=o(e?.label??``),[p,m]=o(e?.cron??`0 3 * * *`),[h,g]=o(e?.enabled??!0),[_,b]=o(String(e?.retentionCount??7)),[x,S]=o(new Set(e?.locationIds??[])),C=v({onSuccess:()=>{c.invalidateQueries({queryKey:fe}),i()}}),w=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},T=Number.parseInt(_,10),E=r(()=>d.trim().length>0&&x.size>0&&!Number.isNaN(T)&&T>=1&&T<=1e3,[d,x,T]),D=()=>{E&&C.mutate({...e?{id:e.id}:{},label:d.trim(),cron:p.trim(),enabled:h,locationIds:Array.from(x),retentionCount:T})},O=C.error instanceof Error?C.error.message:null;return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:n(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3 sticky top-0 bg-surface`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:e?`Edit backup entry`:`New backup entry`}),s(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:s(z,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-4`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Name`}),s(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`Nightly offsite`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1.5`,children:[n(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:[`Locations (`,x.size,` selected)`]}),l.isLoading&&n(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[s(F,{className:`h-3.5 w-3.5 animate-spin`}),`Loading locations…`]}),!l.isLoading&&u.length===0&&s(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:"No `backups` storage locations configured. Add one in Settings → Storage first."}),u.length>0&&s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-52 overflow-y-auto`,children:u.map(e=>n(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:x.has(e.id),onChange:()=>w(e.id),className:`accent-primary`}),s(`span`,{className:`text-foreground`,children:e.displayName})]}),n(`div`,{className:`flex items-center gap-1.5`,children:[s(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-surface border border-border rounded px-1.5 py-0.5`,children:e.kind}),s(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]},e.id))})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Retention (archives kept)`}),s(`input`,{type:`number`,min:1,max:1e3,value:_,onChange:e=>b(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Enabled`}),n(`label`,{className:`inline-flex items-center gap-2 py-1.5 cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),className:`accent-primary`}),s(`span`,{className:`text-xs text-foreground-subtle`,children:`Run on schedule`})]})]})]}),n(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Schedule`}),s(ce,{value:p,onChange:m,disabled:C.isPending})]}),O&&s(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:O})]}),n(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3 sticky bottom-0 bg-surface`,children:[s(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),n(`button`,{onClick:D,disabled:!E||C.isPending,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[C.isPending&&s(F,{className:`h-3.5 w-3.5 animate-spin`}),e?`Save`:`Create entry`]})]})]})})}t();var me=[[`backup`,`list`]];function he({initialDestinationId:e,initialArchiveId:t,onClose:i,onScheduled:u}){let d=a(),[f,p]=o(e&&t?2:1),[h,g]=o(e),[_,v]=o(t),[b,x]=o(new Set),{data:C}=y(),w=C??[],{data:T,isLoading:E}=l({destinationId:h??``},{enabled:!!h}),D=T??[];c(()=>{if(h!==void 0)return;let e=w.filter(e=>e.restoreSupported);e.length===1&&g(e[0].id)},[h,w]);let{data:O}=m({destinationId:h??``,backupId:_??``},{enabled:!!h&&!!_}),k=r(()=>O?.locations??[],[O]);c(()=>{k.length!==0&&x(e=>e.size===0?new Set(k):e)},[k]);let A=S({onSuccess:()=>{d.invalidateQueries({queryKey:me}),u(),i()}}),j=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=!!h&&!!_,N=b.size>0,I=M&&N&&!A.isPending,L=()=>{!h||!_||A.mutate({destinationId:h,backupId:_,locations:[...b]})};return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:i,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`div`,{className:`space-y-0.5`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,f,` of 3 —`,` `,f===1?`pick source`:f===2?`pick locations`:`confirm`]})]}),s(`button`,{onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:s(z,{className:`h-4 w-4`})})]}),f===1&&s(Q,{destinations:w,destinationId:h,onPickDestination:e=>{g(e),v(void 0),x(new Set)},archives:D,archivesLoading:E,archiveId:_,onPickArchive:v}),f===2&&s(ge,{locations:k,picked:b,onToggle:j}),f===3&&s(_e,{destinationName:w.find(e=>e.id===h)?.displayName??h??``,archive:D.find(e=>e.id===_),picked:[...b]}),n(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[s(`div`,{children:f>1&&n(`button`,{onClick:()=>p(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[s(te,{className:`h-3 w-3`}),`Back`]})}),n(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{onClick:i,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),f<3?n(`button`,{disabled:f===1&&!M||f===2&&!N,onClick:()=>p(e=>e===1?2:3),className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[`Next`,s(U,{className:`h-3 w-3`})]}):n(`button`,{onClick:L,disabled:!I,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[A.isPending?s(F,{className:`h-3.5 w-3.5 animate-spin`}):s(P,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function Q({destinations:e,destinationId:t,onPickDestination:r,archives:i,archivesLoading:a,archiveId:o,onPickArchive:c}){let l=e.filter(e=>e.restoreSupported);return n(`div`,{className:`p-4 space-y-3`,children:[n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),n(`select`,{value:t??``,onChange:e=>r(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[s(`option`,{value:``,disabled:!0,children:`Select destination…`}),l.map(e=>n(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&s(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&a&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!a&&i.length===0&&s(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&i.length>0&&s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:i.map(e=>{let t=o===e.id;return n(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>c(e.id),className:`accent-primary`}),n(`div`,{children:[s(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),s(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),s(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:V(e.sizeBytes)})]},e.id)})})]})]})}function ge({locations:e,picked:t,onToggle:r}){return e.length===0?s(`div`,{className:`p-4`,children:s(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):n(`div`,{className:`p-4 space-y-3`,children:[s(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>n(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>r(e),className:`accent-primary`}),s(`span`,{className:`font-mono text-foreground`,children:e}),s(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:ye(e)})]},e))})]})]})}function _e({destinationName:e,archive:t,picked:r}){return n(`div`,{className:`p-4 space-y-3 text-xs`,children:[s(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),n(`dl`,{className:`space-y-1.5`,children:[s($,{term:`Destination`,value:e}),s($,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&s($,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${V(t.sizeBytes)}`}),s($,{term:`Locations`,value:r.length>0?r.join(`, `):`— (full archive)`})]})]})}function $({term:e,value:t}){return n(`div`,{className:`flex justify-between gap-3`,children:[s(`dt`,{className:`text-foreground-subtle`,children:e}),s(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var ve={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function ye(e){return ve[e]??``}t();function be(){let e=w(),t=p(),[r,i]=o(null),[a,c]=o(!1),[l,u]=o(!1),[d,f]=o(void 0),m=async()=>{await e({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&t.mutate({confirm:!0})};return n(B,{children:[n(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[n(`button`,{onClick:()=>c(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[s(P,{className:`h-3.5 w-3.5`}),`Restore…`]}),n(`button`,{onClick:()=>f(null),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[s(N,{className:`h-3.5 w-3.5`}),`New entry`]})]}),l&&s(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(P,{className:`h-3.5 w-3.5`}),s(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),n(`button`,{onClick:()=>{m()},disabled:t.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[t.isPending?s(F,{className:`h-3.5 w-3.5 animate-spin`}):s(P,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),s(ae,{onEdit:e=>f(e),onOpenRestoreWizard:e=>i(e)}),d!==void 0&&s(pe,{entry:d,onClose:()=>f(void 0),onSaved:()=>f(void 0)}),(r||a)&&s(he,{...r?{initialDestinationId:r.destinationId,initialArchiveId:r.archiveId}:{},onClose:()=>{i(null),c(!1)},onScheduled:()=>u(!0)})]})}function xe(){return s(`div`,{className:`flex flex-col p-4`,children:s(re,{tabs:[{id:`storage`,label:`Storage`,icon:E,content:s(G,{})},{id:`backup`,label:`Backup`,icon:H,content:s(be,{})}]})})}export{xe as DataPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,a as r,b as i,o as a,q as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as c}from"./player-overlays-BCQdGsro.js";import{As as l,Cs as u,Ds as d,Es as f,Hr as p,Ms as m,Ns as h,On as g,Os as _,Rt as v,S as y,Ss as b,Ts as x,bs as S,f as C,js as w,kn as T,ks as E,p as D,tt as ee,un as O,ws as k,x as A,xs as te,ys as j}from"./src-C8hTTV3c.js";import{c as M,d as N,l as P,u as F}from"./src-D_m3ma12.js";import{t as I}from"./circle-check-big-BlFY96nJ.js";import{t as ne}from"./copy-DXEey34g.js";import{t as re}from"./key-round-DM-bc9EL.js";import{t as ie}from"./pencil-DwVxBtRq.js";import{t as ae}from"./plus-M-gqh1gB.js";import{C as L,E as R,I as oe,K as z,R as se,d as B,k as ce,l as V,n as H,o as U,r as W,w as G,z as le}from"./index-BIfDsZsD.js";import{t as K}from"./AdminPage-CCD07UMs.js";import{t as ue}from"./AdminTabs-BeziKJ1a.js";import{t as de}from"./AddonCollectionPage-OF4NjZlv.js";import{t as fe}from"./addon-display-names-DvSEQty-.js";var pe=z(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),me=z(`key-square`,[[`path`,{d:`M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z`,key:`165ttr`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814`,key:`1ubxi2`}]]),he=z(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),ge=z(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),_e=z(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ve=z(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]);e();function ye({userId:e,username:n,onClose:r}){let o=a(),c=O(),l=u({userId:e}),d=l.data,f=()=>o.invalidateQueries({queryKey:[[`userManagement`,`getTotpStatus`]]}),p=b({onSuccess:()=>{f(),r()}}),m=l.isLoading?`loading`:d?.enabled?`enrolled`:`not_enrolled`;return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4`,children:t(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl overflow-hidden`,children:[t(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[t(`div`,{className:`flex items-center gap-2`,children:[s(V,{className:`h-4 w-4 text-primary`}),t(`div`,{children:[s(`div`,{className:`text-sm font-medium text-foreground`,children:`Two-factor authentication`}),t(`div`,{className:`text-[11px] text-foreground-subtle`,children:[`User: `,s(`span`,{className:`font-mono`,children:n})]})]})]}),s(`button`,{onClick:r,className:`p-1 rounded hover:bg-foreground-subtle/10 text-foreground-subtle`,children:s(W,{className:`h-4 w-4`})})]}),t(`div`,{className:`p-4 space-y-4`,children:[m===`loading`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[s(L,{className:`h-3.5 w-3.5 animate-spin`}),`Checking status…`]}),m===`not_enrolled`&&t(`div`,{className:`rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle`,children:[s(G,{className:`h-4 w-4 mt-0.5 shrink-0`}),t(`div`,{children:[s(`div`,{className:`font-medium text-foreground`,children:`2FA not enrolled`}),s(`p`,{className:`mt-0.5`,children:`Only the user themselves can enable 2FA, from their own profile page.`})]})]}),m===`enrolled`&&d&&t(i,{children:[t(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[s(I,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),t(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[s(`div`,{className:`font-medium`,children:`2FA is active`}),t(`div`,{className:`text-foreground-subtle`,children:[`Enrolled on`,` `,d.confirmedAt?new Date(d.confirmedAt).toLocaleString():`—`]})]})]}),s(`div`,{className:`text-[11px] text-foreground-subtle`,children:`Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards.`}),t(`div`,{className:`flex justify-end gap-2`,children:[s(v,{onClick:r,variant:`secondary`,children:`Close`}),t(`button`,{onClick:async()=>{await c({title:`Remove 2FA`,message:`Remove two-factor authentication for "${n}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,confirmLabel:`Remove`,variant:`danger`})&&p.mutate({userId:e})},disabled:p.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[p.isPending?s(L,{className:`h-3 w-3 animate-spin`}):s(W,{className:`h-3 w-3`}),`Remove 2FA`]})]})]})]})]})})}function q({icon:e,label:n,count:r,all:i,total:a}){return t(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[s(e,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),s(`span`,{className:`min-w-0 flex-1 text-foreground-subtle`,children:n}),s(`span`,{className:r===0?`text-foreground-subtle`:`font-medium text-foreground`,children:r===0?`none`:i?`all ${a}`:`${r} of ${a}`})]})}function be({scopes:e,isAdmin:n,invalidReason:a}){let o=c(),l=r({queryKey:[`auth`,`previewScope`,e,n],enabled:a===null,queryFn:()=>o.trpcClient.auth.previewScope.query({scopes:[...e],isAdmin:n})}),{data:u}=p({projection:`slim`}),d=u?.length??0;if(a!==null)return s(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:t(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,children:[s(_e,{className:`h-3 w-3 shrink-0`}),a]})});if(l.isLoading)return t(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface p-3 text-[11px] text-foreground-subtle`,children:[s(L,{className:`h-3 w-3 animate-spin`}),`Resolving…`]});if(l.isError||!l.data)return s(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:s(`p`,{className:`text-[11px] text-danger`,children:`Could not resolve this grant set. Saving is still allowed — the server enforces the same rules either way.`})});let f=l.data;return s(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-3`,children:f.isAdmin?t(`p`,{className:`text-[11px] text-foreground`,children:[s(`span`,{className:`font-medium`,children:`Administrator`}),` — unrestricted. Grants are ignored for an admin.`]}):t(i,{children:[s(q,{icon:ce,label:`Devices they can see`,count:f.device.view.deviceCount,all:f.device.view.all,total:d}),s(q,{icon:ie,label:`Devices they can operate`,count:f.device.create.deviceCount,all:f.device.create.all,total:d}),s(q,{icon:U,label:`Devices they can delete`,count:f.device.delete.deviceCount,all:f.device.delete.all,total:d}),t(`div`,{className:`border-t border-border pt-2 text-[10px] text-foreground-subtle`,children:[`System access: `,f.system.length===0?`none`:f.system.join(`, `),f.capabilities.length>0&&t(i,{children:[` · Extra capabilities: `,f.capabilities.map(e=>e.name).join(`, `)]}),f.addons.length>0&&t(i,{children:[` · Addons: `,f.addons.map(e=>e.name).join(`, `)]})]}),f.device.view.deviceCount===0&&s(`p`,{className:`text-[10px] text-warning`,children:`This user will not be able to see any device.`})]})})}function xe(e){let t=F(e);return t===null?{mode:e.length===0?`role`:`advanced`,roleId:null,selector:{kind:`all`},includeLinked:!0,advancedScopes:e}:{mode:`role`,roleId:t.roleId,selector:t.selector,includeLinked:t.includeLinked,advancedScopes:e}}function Se(e){return e.mode===`advanced`?e.advancedScopes:e.roleId===null?[]:P({roleId:e.roleId,selector:e.selector,includeLinked:e.includeLinked})}function Ce({user:e,onClose:r,onSubmit:a,submitting:c,callerScopes:l}){let u=n(()=>xe(e.scopes??[]),[e.scopes]),[d,f]=o(u),[p,m]=o(u.mode===`advanced`),h=n(()=>Se(d),[d]),g=!e.isAdmin&&d.mode===`role`&&d.roleId===null,_=n(()=>e.isAdmin?null:d.mode===`role`&&d.roleId===null?`Pick what this user can do to see the result.`:D(h),[e.isAdmin,d.mode,d.roleId,h]),v=e=>f({...d,...e});return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 pt-[calc(1rem+env(safe-area-inset-top))] pb-[calc(1rem+env(safe-area-inset-bottom))]`,children:t(`div`,{className:`flex max-h-full w-full max-w-2xl flex-col rounded-lg border border-border bg-surface shadow-xl`,children:[t(`div`,{className:`flex shrink-0 items-start justify-between border-b border-border px-4 py-3`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`text-sm font-semibold text-foreground`,children:[`Access — `,e.username]}),s(`div`,{className:`text-[10px] text-foreground-subtle`,children:e.isAdmin?`This user is an administrator — they can do everything, and the settings below are ignored.`:`Choose what they can do, then which devices it applies to.`})]}),s(`button`,{onClick:r,className:`shrink-0 text-foreground-subtle hover:text-foreground`,title:`Close`,children:s(W,{className:`h-4 w-4`})})]}),t(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-4`,children:[g&&t(`div`,{className:`flex items-start gap-2 rounded-lg border border-warning/40 bg-warning/10 p-3`,children:[s(_e,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),t(`p`,{className:`text-[11px] text-foreground`,children:[s(`span`,{className:`font-medium`,children:`No access.`}),` `,t(`span`,{className:`text-foreground-subtle`,children:[e.username,` cannot see or do anything yet. Configure it below.`]})]})]}),t(`section`,{className:`space-y-2`,children:[s(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:`1 · What can they do`}),s(`div`,{className:`space-y-1.5`,children:M.map(e=>{let n=d.mode===`role`&&d.roleId===e.id;return t(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg border p-2.5 transition-colors ${n?`border-primary bg-primary/5`:`border-border hover:bg-foreground-subtle/5`}`,children:[s(`input`,{type:`radio`,name:`access-role`,checked:n,onChange:()=>v({mode:`role`,roleId:e.id}),className:`mt-0.5 border-border focus:ring-primary`}),t(`span`,{className:`min-w-0`,children:[s(`span`,{className:`block text-[12px] font-medium text-foreground`,children:e.label}),s(`span`,{className:`mt-0.5 block text-[10px] text-foreground-subtle`,children:e.description})]})]},e.id)})}),t(`button`,{type:`button`,onClick:()=>{if(!p){f({...d,mode:`advanced`,advancedScopes:h}),m(!0);return}m(!1),f(xe(d.advancedScopes))},className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] text-foreground-subtle transition-colors hover:bg-foreground-subtle/10 hover:text-foreground`,children:[s(p?se:oe,{className:`h-3 w-3`}),`Advanced — edit raw grants`]}),p&&t(`div`,{className:`rounded-lg border border-border p-2`,children:[s(`p`,{className:`mb-2 text-[10px] text-foreground-subtle`,children:`One row per grant. Anything expressible here overrides the three roles above; close this section to go back to them.`}),s(C,{value:d.advancedScopes,onChange:e=>v({mode:`advanced`,advancedScopes:e}),clampToParent:l,emptyHint:t(i,{children:[`No grants.`,` `,s(`span`,{className:`font-medium text-foreground`,children:e.username}),` cannot call any protected endpoint until one is added.`]})})]})]}),d.mode===`role`&&t(`section`,{className:`space-y-2`,children:[s(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:`2 · On which devices`}),s(A,{value:d.selector,onChange:e=>v({selector:e}),includeLinked:d.includeLinked,onIncludeLinkedChange:e=>v({includeLinked:e}),clampToDeviceIds:null})]}),t(`section`,{className:`space-y-2`,children:[s(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:d.mode===`role`?`3 · Result`:`2 · Result`}),s(be,{scopes:h,isAdmin:e.isAdmin,invalidReason:_})]})]}),t(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3`,children:[s(`button`,{onClick:r,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Cancel`}),s(`button`,{onClick:()=>a([...h]),disabled:c||_!==null,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:c?s(L,{className:`h-3 w-3 animate-spin`}):`Save access`})]})]})})}e();function we(){let e=a(),{user:n}=H(),[r,i]=o(!1),[c,l]=o(``),[u,f]=o(``),[p,g]=o(!1),[v,y]=o(null),{data:b,isLoading:x,isError:C}=d(),w=O(),T=()=>e.invalidateQueries({queryKey:[[`userManagement`,`listUsers`]]}),E=S({onSuccess:()=>{T(),i(!1),l(``),f(``),g(!1),y(null)},onError:e=>{y(e instanceof Error?e.message:`Failed to create user`)}}),D=te({onSuccess:T}),k=h({onSuccess:T}),A=_({onSuccess:T}),j=m({onSuccess:()=>{T(),N(null)}}),[M,N]=o(null),[P,F]=o(null),I=b??[];async function ne(e){await w({title:`Delete user`,message:`Permanently delete user "${e.username}"? This cannot be undone — any active sessions will be revoked on next request.`,confirmLabel:`Delete`,variant:`danger`})&&D.mutate({id:e.id})}async function re(e){let t=window.prompt(`New password for "${e.username}":`);if(t){if(t.length<8){window.alert(`Password must be at least 8 characters.`);return}await w({title:`Reset password`,message:`Reset the password for "${e.username}"? They will need to use the new password on their next login.`,confirmLabel:`Reset`})&&A.mutate({id:e.id,newPassword:t})}}function ie(e,t){t!==e.isAdmin&&k.mutate({id:e.id,isAdmin:t})}function R(e){return e?new Date(typeof e==`number`?e:String(e)).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`}):`—`}return t(K,{children:[s(`div`,{className:`flex items-center justify-end`,children:t(`button`,{onClick:()=>i(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm hover:bg-primary/90`,children:[s(ae,{className:`h-3.5 w-3.5`}),`Create User`]})}),r&&t(`div`,{className:`rounded-lg border border-border bg-surface p-4 space-y-3`,children:[t(`div`,{className:`flex items-center justify-between`,children:[s(`span`,{className:`text-xs font-medium text-foreground`,children:`New User`}),s(`button`,{onClick:()=>i(!1),className:`text-foreground-subtle hover:text-foreground`,children:s(W,{className:`h-4 w-4`})})]}),t(`div`,{className:`grid grid-cols-3 gap-3`,children:[t(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Username`}),s(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`john`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),t(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Password`}),s(`input`,{type:`password`,value:u,onChange:e=>f(e.target.value),placeholder:`••••••••`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),t(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Admin`}),t(`label`,{className:`flex items-center gap-2 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:p,onChange:e=>g(e.target.checked),className:`rounded border-border focus:ring-primary`}),s(`span`,{className:`text-foreground-subtle`,children:`Unrestricted access`})]})]})]}),v&&s(`p`,{className:`text-[10px] text-danger`,children:v}),t(`div`,{className:`flex justify-end gap-2`,children:[s(`button`,{onClick:()=>i(!1),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),s(`button`,{onClick:()=>E.mutate({username:c,password:u,isAdmin:p}),disabled:E.isPending||!c||!u,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:E.isPending?`Creating...`:`Create`})]})]}),x&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading...`}),C&&s(`div`,{className:`text-xs text-danger`,children:`Failed to load`}),!x&&!C&&I.length===0&&s(`div`,{className:`text-xs text-foreground-subtle`,children:`No data`}),(()=>{let e=e=>D.isPending&&D.variables?.id===e.id||k.isPending&&k.variables?.id===e.id||A.isPending&&A.variables?.id===e.id;return s(ee,{columns:[{key:`username`,header:`Username`,render:e=>e.username},{key:`isAdmin`,header:`Admin`,render:n=>t(`label`,{className:`inline-flex items-center gap-1.5 text-xs cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:n.isAdmin,onChange:e=>ie(n,e.target.checked),disabled:e(n),className:`rounded border-border focus:ring-primary disabled:opacity-50`}),s(`span`,{className:n.isAdmin?`text-primary font-medium`:`text-foreground-subtle`,children:n.isAdmin?`Admin`:`Regular`})]})},{key:`scopes`,header:`Access`,render:e=>e.isAdmin?s(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:`everything (admin)`}):t(`button`,{onClick:()=>N(e),className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] hover:bg-foreground-subtle/10`,title:`Configure access`,children:[s(B,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),s(Te,{scopes:e.scopes??[]})]})},{key:`createdAt`,header:`Created`,render:e=>s(`span`,{className:`text-foreground-subtle`,children:R(e.createdAt)})},{key:`actions`,header:`Actions`,align:`right`,render:r=>{let i=e(r);return t(`div`,{className:`flex items-center justify-end gap-1`,children:[r.id!==n?.id&&r.totpEnabled&&t(`button`,{onClick:()=>F(r),disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50`,title:`Remove two-factor authentication`,children:[s(V,{className:`h-3 w-3`}),`Remove 2FA`]}),t(`button`,{onClick:()=>re(r),disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground disabled:opacity-50`,title:`Reset password`,children:[s(he,{className:`h-3 w-3`}),`Reset password`]}),t(`button`,{onClick:()=>ne(r),disabled:i,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete user`,children:[i?s(L,{className:`h-3 w-3 animate-spin`}):s(U,{className:`h-3 w-3`}),`Delete`]})]})}}],rows:I,rowKey:e=>e.id,minWidthPx:560})})(),P&&s(ye,{userId:P.id,username:P.username,onClose:()=>F(null)}),M&&s(Ee,{user:M,onClose:()=>N(null),onSubmit:e=>j.mutate({userId:M.id,scopes:e}),submitting:j.isPending})]})}function Te({scopes:e}){if(e.length===0)return s(`span`,{className:`font-medium text-warning`,children:`No access`});let n=F(e);return n===null?t(`span`,{className:`text-foreground-subtle`,children:[`Custom · `,e.length,` grant`,e.length===1?``:`s`]}):t(`span`,{className:`text-foreground-subtle`,children:[s(`span`,{className:`font-medium text-foreground`,children:N(n.roleId).label}),` ·`,` `,y(n.selector)]})}function Ee(e){let{user:t}=H(),n=t?.isAdmin===!0;return s(Ce,{...e,callerScopes:n?null:t?.scopes??[]})}e();var De=`bg-primary/10 text-primary`,Oe=`bg-foreground-subtle/10 text-foreground-subtle`;function J(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function ke(e){return e?e===`*`?`*`:e.join(`, `):``}function Ae(){let e=a(),r=O(),{data:i,isLoading:c}=k(),{data:l}=d(),u=n(()=>i??[],[i]),f=n(()=>l??[],[l]),p=()=>e.invalidateQueries({queryKey:[[`userManagement`,`listApiKeys`]]}),m=()=>e.invalidateQueries({queryKey:[[`userManagement`,`listScopedTokens`]]}),[h,g]=o(!1),[_,v]=o(null),y=E({onSuccess:p}),b=j({onSuccess:({token:e,record:t})=>{m(),g(!1),v({token:e,label:t.name})}}),x=w({onSuccess:m}),S=async(e,t)=>{await r({title:`Revoke "${t}"?`,message:`Any client using this token will lose access immediately. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&y.mutate({id:e})},C=async(e,t)=>{await r({title:`Revoke "${t}"?`,message:`The scoped token will be invalid on its next use.`,confirmLabel:`Revoke`,variant:`danger`})&&x.mutate({id:e})};return t(K,{children:[t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[s(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Issue scoped tokens to grant a user a narrow surface — a specific addon, integration, or capability. Every token MUST be scoped: revoking it has predictable blast radius.`}),t(`button`,{onClick:()=>g(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,disabled:f.length===0,title:f.length===0?`Create a user first`:`Issue a scoped token`,children:[s(B,{className:`h-3.5 w-3.5`}),`New token`]})]}),t(je,{title:`Scoped tokens`,subtitle:`Grouped per user`,children:[f.length===0&&s(Ne,{text:`No users yet — scoped tokens are issued on behalf of an existing user.`}),f.map(e=>s(Fe,{userId:e.id,username:e.username,onRevoke:(e,t)=>{C(e,t)},revokePending:x.isPending,revokeId:x.variables?.id},e.id))]}),u.length>0&&s(je,{title:`Legacy API keys`,subtitle:`${u.length} pre-existing — revoke only`,children:s(Pe,{headers:[`Label`,`Admin`,`Prefix`,`Allowed providers`,`Created`,`Last used`,``],rows:u.map(e=>{let n=!!e.isAdmin,r=y.isPending&&y.variables?.id===e.id;return t(`tr`,{className:`hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-medium`,children:e.label}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border`,children:s(`span`,{className:`inline-block rounded px-2 py-0.5 text-[10px] uppercase tracking-wide ${n?De:Oe}`,children:n?`admin`:`regular`})}),t(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-mono text-[11px]`,children:[e.tokenPrefix,`…`]}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border text-foreground-subtle`,children:ke(e.allowedProviders)||`all`}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:J(e.createdAt)}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:J(e.lastUsedAt)}),s(`td`,{className:`px-3 py-2 border-b border-border text-right`,children:t(`button`,{onClick:()=>{S(e.id,e.label)},disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Revoke`,children:[r?s(L,{className:`h-3 w-3 animate-spin`}):s(U,{className:`h-3 w-3`}),`Revoke`]})})]},e.id)})})}),c&&s(Me,{}),h&&s(Ie,{users:f.map(e=>({id:e.id,username:e.username})),onClose:()=>g(!1),onSubmit:e=>b.mutate({userId:e.userId,name:e.name,scopes:e.scopes,...e.expiresAt===void 0?{}:{expiresAt:e.expiresAt}}),submitting:b.isPending}),_&&s(Le,{token:_.token,label:_.label,onClose:()=>v(null)})]})}function je({title:e,subtitle:n,children:r}){return t(`div`,{className:`space-y-2`,children:[t(`div`,{className:`flex items-baseline justify-between`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),n&&s(`span`,{className:`text-[10px] text-foreground-subtle`,children:n})]}),r]})}function Me(){return s(`div`,{className:`space-y-2`,children:[1,2].map(e=>s(`div`,{className:`h-10 rounded border border-border bg-surface animate-pulse`},e))})}function Ne({text:e}){return s(`div`,{className:`rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center`,children:e})}function Pe({headers:e,rows:n}){return s(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:t(`table`,{className:`w-full text-xs min-w-[640px]`,children:[s(`thead`,{children:s(`tr`,{children:e.map((t,n)=>s(`th`,{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${n===e.length-1?`text-right`:`text-left`}`,children:t},n))})}),s(`tbody`,{children:n})]})})}function Fe({userId:e,username:n,onRevoke:r,revokePending:i,revokeId:a}){let{data:o,isLoading:c}=f({userId:e}),l=o??[];return c||l.length===0?null:t(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-medium text-foreground`,children:n}),s(Pe,{headers:[`Name`,`Prefix`,`Scopes`,`Expires`,`Last used`,`Created`,``],rows:l.map(e=>{let n=i&&a===e.id;return t(`tr`,{className:`hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-medium`,children:e.name}),t(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-mono text-[11px]`,children:[e.tokenPrefix,`…`]}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border`,children:s(`div`,{className:`flex flex-wrap gap-1`,children:e.scopes.map((e,n)=>t(`span`,{className:`inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono`,children:[e.type,`:`,e.type===`device`?`[${y(e.selector)}]`:e.target]},n))})}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:J(e.expiresAt)}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:J(e.lastUsedAt)}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:J(e.createdAt)}),s(`td`,{className:`px-3 py-2 border-b border-border text-right`,children:t(`button`,{onClick:()=>r(e.id,e.name),disabled:n,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[n?s(L,{className:`h-3 w-3 animate-spin`}):s(U,{className:`h-3 w-3`}),`Revoke`]})})]},e.id)})})]})}function Ie({users:e,onClose:n,onSubmit:r,submitting:i}){let{user:a}=H(),c=a?.isAdmin===!0?null:a?.scopes??[],[l,u]=o(e[0]?.id??``),[d,f]=o(``),[p,m]=o([{type:`capability`,target:``,access:[`view`,`create`]}]),[h,g]=o(``),_=D(p),v=l!==``&&d.trim().length>0&&p.length>0&&_===null&&!i;return t(Re,{title:`Create scoped token`,onClose:n,children:[t(`div`,{className:`space-y-3`,children:[s(Y,{label:`On behalf of user`,children:s(`select`,{value:l,onChange:e=>u(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary`,children:e.map(e=>s(`option`,{value:e.id,children:e.username},e.id))})}),s(Y,{label:`Name`,children:s(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`cloudflare-tunnel-route`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary`})}),t(Y,{label:`Scopes`,hint:`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`,children:[s(C,{value:p,onChange:m,clampToParent:c}),_&&s(`p`,{className:`mt-1 text-[10px] text-danger`,children:_})]}),s(Y,{label:`Expires in (days)`,hint:`Leave blank for non-expiring.`,children:s(`input`,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value),placeholder:`30`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary`})})]}),t(ze,{children:[s(`button`,{onClick:n,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),t(`button`,{onClick:()=>{let e=parseInt(h,10),t=Number.isFinite(e)&&e>0?Date.now()+e*864e5:void 0;r({userId:l,name:d.trim(),scopes:p,expiresAt:t})},disabled:!v,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[i?s(L,{className:`h-3.5 w-3.5 animate-spin`}):s(B,{className:`h-3.5 w-3.5`}),`Issue token`]})]})]})}function Le({token:e,label:n,onClose:r}){let[i,a]=o(!1),c=async()=>{try{await navigator.clipboard.writeText(e),a(!0)}catch{}};return t(Re,{title:`Token: ${n}`,onClose:r,children:[t(`div`,{className:`space-y-3`,children:[s(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:`Copy this token now. Once you close this dialog the secret cannot be displayed again.`}),s(`div`,{className:`rounded border border-border bg-background p-2 font-mono text-[11px] break-all select-all`,children:e})]}),t(ze,{children:[t(`button`,{onClick:()=>{c()},className:`inline-flex items-center gap-1.5 rounded bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[i?s(le,{className:`h-3.5 w-3.5 text-primary`}):s(ne,{className:`h-3.5 w-3.5`}),i?`Copied`:`Copy`]}),s(`button`,{onClick:r,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Done`})]})]})}function Re({title:e,onClose:n,children:r}){return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:n,children:t(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),s(`button`,{onClick:n,className:`text-foreground-subtle hover:text-foreground`,children:s(W,{className:`h-4 w-4`})})]}),s(`div`,{className:`p-4`,children:r})]})})}function ze({children:e}){return s(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:e})}function Y({label:e,hint:n,children:r}){return t(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:e}),r,n&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:n})]})}e();function X(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function Be(e){if(e.type===`category`){let t=e.target??``;return t===`device`?`all devices`:`all ${t}`}if(e.type===`device`)return`device:[${(e.targets??[]).join(`,`)}]`;let t=e;return`${t.type}:${t.target??``}`}function Ve(){return s(`div`,{className:`space-y-2`,children:[1,2].map(e=>s(`div`,{className:`h-10 rounded border border-border bg-surface animate-pulse`},e))})}function He({text:e}){return s(`div`,{className:`rounded border border-dashed border-border bg-surface px-3 py-4 text-xs text-foreground-subtle text-center`,children:e})}function Ue({headers:e,rows:n}){return s(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:t(`table`,{className:`w-full text-xs min-w-[640px]`,children:[s(`thead`,{children:s(`tr`,{children:e.map((t,n)=>s(`th`,{className:`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border whitespace-nowrap ${n===e.length-1?`text-right`:`text-left`}`,children:t},n))})}),s(`tbody`,{children:n})]})})}function We(){let e=a(),r=O(),{data:i,isLoading:o}=x(),c=n(()=>i??[],[i]),u=l({onSuccess:()=>e.invalidateQueries({queryKey:[[`userManagement`,`listOauthSessions`]]})}),d=async(e,t)=>{await r({title:`Revoke "${t}" session?`,message:`This integration will lose access immediately on its next API call. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&u.mutate({id:e})};return t(K,{icon:ge,title:`Linked Sessions`,subtitle:`External integrations (Alexa, …) linked to this hub via OAuth. Revoke a session to immediately invalidate that integration's access.`,children:[o&&s(Ve,{}),!o&&c.length===0&&s(He,{text:`No linked sessions — once an external integration completes the OAuth flow its session will appear here.`}),!o&&c.length>0&&s(Ue,{headers:[`Integration`,`User`,`Scopes`,`Created`,`Last used`,`Status`,``],rows:c.map(e=>{let n=e.revokedAt!==null,r=(u.isPending?u.variables?.id:void 0)===e.id;return t(`tr`,{className:`hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-2 text-foreground border-b border-border font-medium`,children:e.integrationId}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border`,children:e.username}),s(`td`,{className:`px-3 py-2 text-foreground border-b border-border`,children:s(`div`,{className:`flex flex-wrap gap-1`,children:e.scopes.map((e,t)=>s(`span`,{className:`inline-block rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-mono`,children:Be(e)},t))})}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:X(e.createdAt)}),s(`td`,{className:`px-3 py-2 text-foreground-subtle border-b border-border`,children:X(e.lastUsedAt)}),s(`td`,{className:`px-3 py-2 border-b border-border`,children:n?t(`span`,{className:`inline-block rounded bg-foreground-subtle/10 px-2 py-0.5 text-[10px] text-foreground-subtle`,children:[`Revoked `,X(e.revokedAt)]}):s(`span`,{className:`inline-block rounded bg-emerald-500/15 px-2 py-0.5 text-[10px] text-emerald-700 dark:text-emerald-300`,children:`Active`})}),s(`td`,{className:`px-3 py-2 border-b border-border text-right`,children:!n&&t(`button`,{onClick:()=>{d(e.id,e.integrationId)},disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Revoke`,children:[r?s(L,{className:`h-3 w-3 animate-spin`}):s(U,{className:`h-3 w-3`}),`Revoke`]})})]},e.id)})})]})}e();var Z=3e4,Q=[{capName:`auth-provider`,stageBadge:null},{capName:`user-passkeys`,stageBadge:`Second factor`}],$={title:`Authentication providers`,subtitle:`Every registered authentication surface in one list: login providers (local password, OIDC, SAML, magic-link) and second-factor providers (passkeys / WebAuthn — configure the relying-party RP ID + origin inline; users enroll from My access → Passkeys). Multiple providers run in parallel — enable/disable each independently. Disabling one only removes that method; local password login is unaffected.`,emptyTitle:`No authentication providers registered`,emptyDescription:`Local auth should always be available — if this list is empty the local-auth builtin failed to register. Check the Addons page for load errors.`,installLabel:`Add provider`};function Ge(e){return e===`local-auth`?{headline:`Username + password (local).`,icon:me,bullets:[`Users live in the hub’s SQLite database — no IdP roundtrip.`,`TOTP / 2FA is self-enrolled: each user enables it from their own profile page (My access → Two-factor authentication).`,`API keys + scoped tokens are managed from the API Keys page.`],setupSteps:[`Add users from Users → New user (or seed via CAMSTACK_ADMIN_USER / CAMSTACK_ADMIN_PASS).`,`Hand out either passwords or scoped tokens — both validate through this provider.`]}:e.startsWith(`auth-oidc`)?{headline:`OpenID Connect (Google, Microsoft, Okta, Keycloak, …).`,icon:R,bullets:[`Three-leg redirect flow with PKCE S256 + nonce.`,`id_token is signature-verified against the IdP’s JWKS — no implicit trust.`,`First-time sign-ins are auto-provisioned with the configured Default Role.`],setupSteps:[`Register a web app at your IdP and copy the client_id + client_secret.`,"Set the redirect URI to `https://<this-hub>/addon/<addon-id>/callback`.",`Paste issuer + credentials in the Settings panel below — saves on every change.`]}:e.startsWith(`auth-saml`)?{headline:`SAML 2.0 — enterprise SSO (Azure AD, Okta, OneLogin).`,icon:R,bullets:[`Heavier handshake than OIDC — exchange metadata XML with your IdP.`,`Group → role mapping via SAML assertions.`]}:e.startsWith(`auth-webauthn`)||e.startsWith(`auth-passkey`)?{headline:`Passkeys / WebAuthn — passwordless second factor.`,icon:V,bullets:[`Enroll a YubiKey, Touch ID, or platform passkey per user.`,`Resistant to phishing — the browser binds the credential to your hub origin.`]}:e.startsWith(`auth-totp`)||e.startsWith(`auth-magic-link`)?{headline:`TOTP / magic-link — second factor or passwordless sign-in.`,icon:V,bullets:[`Codes / links delivered out-of-band (RFC 6238 for TOTP).`,`Compatible with Google Authenticator, Aegis, 1Password, Bitwarden, etc.`]}:{headline:`Authentication provider.`,icon:B,bullets:[`Generic authentication provider. No additional hints registered.`]}}function Ke(){let e=T({capName:Q[0].capName},{refetchInterval:Z}),t=T({capName:Q[1].capName},{refetchInterval:Z}),r=g(void 0,{refetchInterval:Z}),i=n(()=>fe(r.data??[]),[r.data]),a=n(()=>{let n=[],r=[e.data??[],t.data??[]];for(let[e,t]of Q.entries())for(let a of r[e]??[])n.push({addonId:a.addonId,displayName:i.get(a.addonId)??a.addonId,isActive:a.isActive,capName:t.capName,stageBadge:t.stageBadge});return n},[e.data,t.data,i]);return s(de,{title:$.title,subtitle:$.subtitle,pageIcon:B,itemIcon:B,capability:Q[0].capName,installButtonLabel:$.installLabel,items:a,isLoading:e.isLoading||t.isLoading,emptyTitle:$.emptyTitle,emptyDescription:$.emptyDescription,renderStatusBadges:e=>e.stageBadge===null?null:s(`span`,{className:`inline-flex items-center rounded-full border border-primary/30 bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary`,children:e.stageBadge}),renderExpandedPanel:e=>s(qe,{addonId:e.addonId})})}function qe({addonId:e}){let n=Ge(e),r=n.icon;return t(`div`,{className:`rounded-lg border border-border bg-surface p-4 space-y-3`,children:[t(`div`,{className:`flex items-start gap-2.5`,children:[s(r,{className:`h-4 w-4 mt-0.5 text-primary shrink-0`}),s(`div`,{className:`text-xs text-foreground font-medium`,children:n.headline})]}),s(`ul`,{className:`text-xs text-foreground-subtle space-y-1.5 pl-6 list-disc`,children:n.bullets.map((e,t)=>s(`li`,{children:e},t))}),n.setupSteps&&n.setupSteps.length>0&&t(`div`,{className:`rounded-md border border-border bg-surface-hover/40 px-3 py-2.5 space-y-1.5`,children:[t(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:[s(pe,{className:`h-3 w-3`}),`Setup steps`]}),s(`ol`,{className:`text-xs text-foreground space-y-0.5 pl-4 list-decimal`,children:n.setupSteps.map((e,t)=>s(`li`,{children:e},t))})]}),e===`local-auth`&&t(`div`,{className:`rounded-md border border-blue-500/30 bg-blue-500/5 px-3 py-2 flex items-start gap-2 text-[11px] text-foreground`,children:[s(G,{className:`h-3.5 w-3.5 mt-0.5 text-blue-500 shrink-0`}),t(`span`,{children:[`TOTP / 2FA is self-service: each user enrols from their own profile page —`,` `,s(`a`,{href:`/system/my-access`,className:`underline text-primary`,children:`My access`}),` `,`→ “Two-factor authentication” → Enable 2FA. Admins can only remove a user’s active enrollment (lost device) from the`,` `,s(`a`,{href:`/system/users`,className:`underline text-primary`,children:`Users`}),` `,`page via Actions → “Remove 2FA”.`]})]})]})}function Je(){return s(`div`,{className:`flex flex-col p-4`,children:s(ue,{tabs:[{id:`users`,label:`Users`,icon:ve,content:s(we,{})},{id:`api-keys`,label:`Tokens`,icon:re,content:s(Ae,{})},{id:`linked-sessions`,label:`Linked Sessions`,icon:ge,content:s(We,{})},{id:`authentication`,label:`Authentication`,icon:B,content:s(Ke,{})}]})})}export{Je as IdentityPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{K as e,Q as t,S as n,T as r,W as i,b as a,i as o,o as s,p as c,q as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as f}from"./player-overlays-BCQdGsro.js";import{$a as p,Aa as m,Bt as h,Fa as g,Fs as _,Ht as v,Ia as y,Is as b,J as x,Ja as S,Ka as C,Ls as w,Lt as T,Ma as E,Na as D,Oa as O,Pa as k,Qa as ee,Ra as A,Rs as j,Ua as M,Ut as te,V as ne,Va as N,Vt as P,Wa as F,Xa as I,Yt as L,Za as re,_n as R,b as ie,bn as ae,co as z,d as oe,do as se,eo as ce,et as le,gn as ue,h as de,i as fe,ia as B,ja as pe,ka as me,lo as he,oo as ge,qa as _e,so as ve,to as ye,u as be,un as xe,zs as Se,zt as Ce}from"./src-C8hTTV3c.js";import{n as we}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DX7sYWrs.js";import{Bt as Te,Vt as Ee,f as De,h as Oe,p as ke}from"./src-D_m3ma12.js";import{a as Ae,i as je,l as Me,n as V,o as Ne,r as Pe,t as Fe,u as Ie}from"./NodeInferenceDevices-HkYGItBF.js";import{t as Le}from"./layers-Bpr1190F.js";import{n as Re,t as ze}from"./video-BYECCQZN.js";import{t as Be}from"./pencil-DwVxBtRq.js";import{t as Ve}from"./plus-M-gqh1gB.js";import{t as He}from"./radio-lPQ2yM4-.js";import{t as Ue}from"./refresh-cw-B71pScMn.js";import{t as We}from"./server-BgQAF0aD.js";import{t as Ge}from"./square-check-big-DScyC9MB.js";import{t as Ke}from"./square-CEBPzPgT.js";import{t as qe}from"./zap-OPtC9jyC.js";import{C as Je,D as Ye,E as Xe,F as Ze,I as Qe,K as $e,N as H,O as et,R as tt,X as nt,a as rt,i as it,o as at,r as ot,z as st}from"./index-BIfDsZsD.js";import"./useEventInvalidation-DE7flGNJ.js";import{t as ct}from"./NodeAddonsSettingsPanel-B2J7nqRT.js";var lt=$e(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ut=$e(`flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),dt=$e(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);t();function ft(e){return e}function pt(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function mt(e,t){return typeof e==`boolean`?e:ft(t)}function ht(e,t){return{pipeline:mt(pt(e,`detect`),t),audio:mt(pt(e,`audio`),t),ingest:mt(pt(e,`ingest`),t)}}function gt(e,t,n){let r=e?.find(e=>e.nodeId===t);return ht(r?.settings,n)}function _t(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function vt({selectedNodeId:e,onSelect:t,refreshToken:r}){let{data:i}=B(void 0),{data:o}=M(void 0),{data:s}=C(void 0),c=new Map;for(let e of o??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=i??[],d=l.filter(e=>e.isOnline).length,f=l.filter(e=>!e.isOnline).length;return n(`div`,{className:`flex flex-col h-full`,children:[n(`button`,{type:`button`,onClick:()=>t(Fr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[u(Xe,{className:`h-4 w-4 flex-shrink-0`}),n(`div`,{className:`min-w-0 flex-1`,children:[u(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),u(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),u(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(r=>{let i=e===r.id,o=c.get(r.id)??0,l=r.isHub?We:H,d=gt(s,r.id,r.isHub),f=r.isOnline?null:ne(_t(r.lastSeen));return n(`button`,{type:`button`,onClick:()=>t(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[u(l,{className:`h-4 w-4 flex-shrink-0`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex items-center gap-2`,children:[u(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&u(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!r.isOnline&&u(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),r.isOnline&&u(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),n(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[n(`span`,{children:[r.cpuCores,` cores`]}),u(`span`,{children:`•`}),n(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),o>0&&n(a,{children:[u(`span`,{children:`•`}),n(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[u(ze,{className:`h-2.5 w-2.5`}),o]})]}),!r.isOnline&&n(a,{children:[u(`span`,{children:`•`}),n(`span`,{className:`text-destructive`,children:[`offline`,f===null?``:` · ${f}`]})]})]}),n(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[u(T,{variant:d.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:d.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),u(T,{variant:d.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:d.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},r.id)})}),n(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[n(`span`,{children:[d,` online`]}),f>0&&n(`span`,{className:`text-destructive`,children:[f,` offline`]})]})]})}function yt({nodeId:e,refreshToken:t}){let{data:r}=B(void 0),i=r?.find(t=>t.id===e),o=b(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?n(`div`,{className:`px-6 py-4 border-b border-border`,children:[n(`div`,{className:`flex items-center gap-2 mb-1`,children:[u(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?u(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):u(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),i.isHub&&u(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),n(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[u(`span`,{children:i.cpuModel??`CPU`}),u(`span`,{children:`•`}),n(`span`,{children:[i.cpuCores,` cores`]}),u(`span`,{children:`•`}),n(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),o&&n(a,{children:[u(`span`,{children:`•`}),n(`span`,{children:[o.attachedCameras,` cameras (`,o.activeCameras,` active)`]}),u(`span`,{children:`•`}),n(`span`,{children:[o.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),u(`span`,{children:`•`}),n(`span`,{children:[`queue `,o.queueDepthTotal]}),o.hardware.hasGpu&&n(a,{children:[u(`span`,{children:`•`}),u(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):u(`div`,{className:`px-6 py-4 border-b border-border`,children:n(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function bt({refreshToken:e,nodeId:t}){let[r,a]=l(new Map),{nodes:o}=_();j(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&a(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:s}=y(void 0),c=i(()=>{let e=new Map;for(let t of s??[])e.set(t.nodeId,t.deviceCount);return e},[s]),d=i(()=>{let e=new Map,t=Date.now()-3e4;for(let n of r.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[r]),f=i(()=>{let e=new Map;for(let t of o)e.set(t.id,t.shortName);return e},[o]),p=i(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of d.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:o.length,onlineAgents:o.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[d,o]);if(t){let e=d.get(t);return n(`div`,{className:`@container/liveload`,children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),n(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[u(U,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),u(U,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),u(U,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),u(U,{label:`Queue`,value:e?String(e.queueDepth):`—`}),u(U,{label:`Audio`,value:String(c.get(t)??`—`)})]})]})}let m=[...d.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return n(`div`,{className:`@container/liveload`,children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),n(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[u(U,{label:`Total agents`,value:`${p.onlineAgents}/${p.totalAgents}`}),u(U,{label:`Active / Attached`,value:`${p.activeCameras}/${p.attachedCameras}`}),u(U,{label:`Total FPS`,value:p.totalFps.toFixed(1)}),u(U,{label:`Avg inference ms`,value:p.avgInferenceTimeMs.toFixed(0)}),u(U,{label:`Queue depth`,value:String(p.queueDepth)})]}),u(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[480px]`,children:[u(`thead`,{className:`bg-surface`,children:n(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[u(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),u(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),u(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),u(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),u(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),u(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),n(`tbody`,{children:[m.map(([e,t])=>n(`tr`,{className:`border-t border-border`,children:[u(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:f.get(e)??e}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:c.get(e)??`—`})]},e)),m.length===0&&u(`tr`,{children:u(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function U({label:e,value:t}){return n(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[u(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),u(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}t();var xt={active:!1,pinned:!1,nodeId:null,reason:``},St=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],Ct=3e5,wt={pipeline:H,decoder:et,audio:Re},Tt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function Et({mode:e,nodeId:t,compact:o=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let c=s(),[f,p]=l(null),[m,h]=l(null),[v,y]=l(new Map);fe([`pipelineOrchestrator`,`getPipelineAssignments`],St),fe([`pipelineOrchestrator`,`getAudioAssignments`],St),fe([`pipelineOrchestrator`,`getCameraStatuses`],St);let{data:b}=M(void 0),{data:x}=g(void 0),{data:S}=A({},{enabled:e===`agent`}),{nodes:C}=_(),{data:w}=Me();j(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&y(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),d(()=>{if(v.size===0)return;let e=setInterval(()=>{y(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[v.size]);let T=i(()=>{let e=new Map;for(let t of w??[])e.set(t.id,t.name);return e},[w]),D=i(()=>{if(e===`agent`){let e=[];for(let n of S??[]){let r=n.assignment,i=(e,n,r)=>({active:e!==null&&e===t,pinned:n,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:n.deviceId,deviceName:T.get(n.deviceId)??`Device ${n.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:T.get(e)??`Device ${e}`,pipeline:xt,decoder:xt,audio:xt};return n.set(e,r),r};for(let i of b??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of x??[]){let t=r(e.deviceId);n.set(e.deviceId,{...t,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...n.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[b,x,S,T,e,t]),O=i(()=>(C??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[C]),k=()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},ee=E({onSuccess:k}),te=z({onSuccess:k}),ne=pe({onSuccess:k}),N=ve({onSuccess:k}),P=(e,t,n)=>{t===`pipeline`?ee.mutate({deviceId:e,agentNodeId:n}):ne.mutate({deviceId:e,nodeId:n}),p(null)},F=(e,t)=>{t===`pipeline`?te.mutate({deviceId:e}):N.mutate({deviceId:e}),p(null)};return u(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[u(`thead`,{className:`bg-surface`,children:n(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!o&&u(`th`,{className:`w-10`}),u(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?n(a,{children:[u(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),u(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):n(a,{children:[u(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),u(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),u(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),u(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),n(`tbody`,{children:[D.map(t=>{let i=v.get(t.deviceId),s=m===t.deviceId;return n(r.Fragment,{children:[n(`tr`,{className:`border-t border-border align-middle relative`,children:[!o&&u(`td`,{className:`px-2 py-2 align-middle`,children:u(`button`,{type:`button`,onClick:()=>h(s?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":s?`Collapse broker details`:`Expand broker details`,children:u(s?tt:Qe,{className:`h-3.5 w-3.5`})})}),n(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[u(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),n(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?n(a,{children:[u(`td`,{className:`px-3 py-2 align-middle`,children:u(Ot,{state:t.pipeline,onlineNodes:O,pending:ee.isPending||te.isPending,onChange:e=>{e===`auto`?F(t.deviceId,`pipeline`):P(t.deviceId,`pipeline`,e)}})}),u(`td`,{className:`px-3 py-2 align-middle`,children:u(At,{state:t.pipeline,deviceId:t.deviceId})})]}):n(a,{children:[u(Mt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:O,isMenuOpen:f?.deviceId===t.deviceId&&f.role===`pipeline`,onToggleMenu:()=>p(f?.deviceId===t.deviceId&&f.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>p(null),onMove:e=>P(t.deviceId,`pipeline`,e),onUnpin:()=>F(t.deviceId,`pipeline`)}),u(Mt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:O,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),u(Mt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:O,isMenuOpen:f?.deviceId===t.deviceId&&f.role===`audio`,onToggleMenu:()=>p(f?.deviceId===t.deviceId&&f.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>p(null),onMove:e=>P(t.deviceId,`audio`,e),onUnpin:()=>F(t.deviceId,`audio`)})]}),u(`td`,{className:`px-3 py-2 align-middle`,children:u(It,{snap:i})})]}),s&&!o&&n(`tr`,{className:`bg-surface/50`,children:[u(`td`,{}),n(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2 space-y-3`,children:[t.pipeline.nodeId&&u(Dt,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),u(L,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})]})]})]},t.deviceId)}),D.length===0&&u(`tr`,{children:u(`td`,{colSpan:o?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function Dt({deviceId:e,nodeId:t}){let r=s(),{data:i}=N({nodeId:t}),{data:a}=F({deviceId:e}),o=ge({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}}),c=i?.devices??[],l=a?.deviceKey??`auto`,d=l!==`auto`&&!c.some(e=>e.key===l);return n(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[u(`span`,{className:`shrink-0 font-medium text-foreground`,children:`Inference device`}),n(`select`,{value:l,disabled:o.isPending,"aria-label":`Inference device pin`,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value}),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[u(`option`,{value:`auto`,children:`Auto (balanced)`}),d&&n(`option`,{value:l,children:[`Pin → `,l,` (not on this node)`]}),c.map(e=>n(`option`,{value:e.key,children:[`Pin → `,e.key,e.available?``:` (unavailable)`]},e.key))]}),o.isPending&&u(`span`,{className:`text-[10px] opacity-70`,children:`saving…`})]})}function Ot({state:e,onlineNodes:t,pending:r,onChange:i}){let a=e.pinned&&e.nodeId?e.nodeId:`auto`,o=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return n(`select`,{value:a,disabled:r,"aria-label":`Pipeline placement pin`,onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[u(`option`,{value:`auto`,children:`Auto`}),o.map(e=>n(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function kt(t){let n=e(null);return t.nodeId!==null&&(n.current=t),n.current}function At({state:e,deviceId:t}){let r=kt(e),i=e.active&&e.nodeId!==null;if(r===null||r.nodeId===null)return u(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`— · no session yet`});let a=r.pinned?`pinned · manual`:`auto · ${r.reason||`capacity`}`;return n(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[u(`span`,{className:`font-mono text-[11px] truncate ${i?`text-foreground`:`text-foreground-subtle`}`,title:r.pinned?r.nodeId:`${r.nodeId} — an unpinned camera is re-elected per on-motion session, so this can change between sessions`,children:r.nodeId}),u(`span`,{className:`truncate ${r.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:a,children:a}),u(`span`,{className:`truncate text-[10px] ${i?`text-emerald-400`:`text-foreground-subtle/70`}`,children:i?`● running here`:`○ idle · last session here`}),u(jt,{deviceId:t,nodeId:r.nodeId})]})}function jt({deviceId:e,nodeId:t}){let r=s(),{data:i}=F({deviceId:e},{refetchOnMount:`always`}),{data:a}=N({nodeId:t},{staleTime:Ct}),o=ge({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return u(`span`,{className:`mt-0.5 text-[10px] text-foreground-subtle italic`,children:`device: …`});let c=a.devices??[],l=c.filter(e=>e.enabled),d=i.deviceKey??`auto`,f=d!==`auto`&&!l.some(e=>e.key===d),p=c.find(e=>e.key===d);return n(`select`,{value:d,disabled:o.isPending,"aria-label":`Inference device pin`,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value}),className:`mt-0.5 w-full min-w-0 rounded border border-border bg-background px-1 py-0.5 text-[10px] text-foreground disabled:opacity-50`,children:[u(`option`,{value:`auto`,children:`Auto (balanced)`}),f&&n(`option`,{value:d,children:[p?`${V(p).label} (${d})`:d,` (not enabled)`]}),l.map(e=>n(`option`,{value:e.key,children:[V(e).label,` · `,e.format]},e.key))]})}function Mt({role:e,state:t,mode:r,onlineNodes:i,readOnly:a=!1,isMenuOpen:o,onToggleMenu:s,onCloseMenu:c,onMove:l,onUnpin:d}){let f=wt[e],p=i.filter(e=>e.id!==(t.nodeId??``)),m=!a&&(t.active||r===`cluster`)&&(p.length>0||t.pinned);return n(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[u(r===`agent`?Nt:Pt,{state:t,Icon:f}),u(`div`,{className:`ml-auto shrink-0`,children:m&&u(`button`,{type:`button`,onClick:s,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${Tt[e]} actions`,children:u(lt,{className:`h-3 w-3 text-foreground-subtle`})})})]}),o&&m&&u(Lt,{title:Tt[e],targets:p,pinned:t.pinned,onMove:l,onUnpin:d,onClose:c})]})}function Nt({state:e,Icon:t}){return n(`div`,{className:`flex items-center gap-1.5`,children:[u(e.active?Ge:Ke,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),u(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&u(dt,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Pt({state:e,Icon:t}){return!e.active||!e.nodeId?n(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[u(t,{className:`h-3 w-3`}),u(`span`,{className:`text-[10px] italic`,children:`—`})]}):n(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[u(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),n(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[u(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),u(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?n(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[u(dt,{className:`h-2.5 w-2.5`}),` manual`]}):n(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var Ft=`min-h-[3.25rem]`;function It({snap:e}){if(!e)return u(`div`,{className:`flex items-center ${Ft}`,children:u(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:r,avgInferenceTimeMs:i,queueDepth:a,configuredFps:o,droppedFrames:s}=e.metrics,c=le(t);return n(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Ft}`,children:[n(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${c.textColor}`,children:[u(de,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),u(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:c.label})]}),n(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[u(`span`,{className:`text-foreground`,children:r.toFixed(1)}),n(`span`,{children:[`/`,o.toFixed(0),` fps`]})]}),n(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[u(`span`,{className:`text-foreground`,children:i.toFixed(0)}),u(`span`,{children:` ms`}),a>0&&n(`span`,{className:`text-warning ml-1`,children:[`q`,a]})]}),n(`span`,{className:`whitespace-nowrap truncate ${s>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,u(`span`,{className:`text-foreground`,children:s})]})]})}function Lt({title:t,targets:r,pinned:i,onMove:a,onUnpin:o,onClose:s}){let c=e(null);return d(()=>{let e=e=>{c.current?.contains(e.target)||s()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]),n(`div`,{ref:c,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[u(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:t}),r.length>0&&u(`div`,{className:`py-1`,children:r.map(e=>n(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),i&&n(`button`,{type:`button`,onClick:o,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,t.toLowerCase()]}),r.length===0&&!i&&u(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Rt({nodeId:e,refreshToken:t}){return n(`div`,{className:`space-y-6`,children:[u(bt,{refreshToken:t,nodeId:e}),n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),u(Et,{mode:`agent`,nodeId:e,compact:!0})]})}t();function zt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Bt({nodeId:e,refreshToken:t}){let r=s(),a=me({onSettled:()=>{r.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:o}=m({nodeId:e}),c=b(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??o??null,l=c===null;fe([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:d}=se({nodeId:e}),{values:f}=w(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),p=i(()=>f.filter(e=>e.metrics.phase===`active`).length,[f]),h=t=>{let n=d??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||a.mutate({nodeId:e,engine:t,force:n.length>0})};return n(`div`,{className:`space-y-6`,children:[n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(c??[]).length,` engine(s) resident in RAM. `,(d??[]).length,` `,`camera(s) attached, `,p,` actively dispatching frames. Refreshes every 5s.`]})]}),u(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[640px]`,children:[u(`thead`,{className:`bg-surface`,children:n(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[u(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),u(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),u(`th`,{className:`text-left px-3 py-2`,children:`Models`}),u(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),u(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),u(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),u(`th`,{className:`w-20`})]})}),n(`tbody`,{children:[l&&u(`tr`,{children:u(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!l&&(c??[]).map(e=>{let t=e.kind===`warm-override`,r=e.kind===`device-pool`;return n(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:r?`bg-primary/[0.05]`:``}`,children:[u(`td`,{className:`px-3 py-2`,children:n(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:r?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[u(t?ut:r?Le:H,{className:`h-3 w-3`}),t?`warm`:r?`pool`:`runtime`]})}),u(`td`,{className:`px-3 py-2`,children:n(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[u(qe,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),u(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?u(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):u(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>u(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),u(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),u(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?u(`span`,{className:`text-foreground-subtle`,children:zt(e.idleMs,e.idleTtlMs)}):u(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(d??[]).length}),u(`td`,{className:`px-3 py-2 text-right`,children:r?u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`auto`}):n(`button`,{type:`button`,disabled:a.isPending,onClick:()=>h(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[u(at,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!l&&(c??[]).length===0&&u(`tr`,{children:u(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),n(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[u(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,u(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,u(`strong`,{className:`text-foreground`,children:`pool`}),`: a per-device balanced inference pool (one per enabled accelerator, running concurrently); reaper-managed on its own idle TTL.`]}),a.isError&&n(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,a.error instanceof Error?a.error.message:`unknown`]})]})}var Vt=`pipeline-runner`,Ht=200;function Ut({nodeId:e}){return n(`div`,{className:`flex flex-col gap-3`,children:[n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. Streaming live; the device chip on a line tells which camera it refers to.`]})]}),u(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:u(x,{agentId:e,addonId:Vt,limit:Ht,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}t(),t();function Wt({nodeId:e,title:t}){let{data:r}=Me(),{data:a}=M(void 0),o=i(()=>{let e=new Map;for(let t of r??[])e.set(t.id,t.name);return e},[r]),s=i(()=>{if(!e)return null;let t=new Set;for(let n of a??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,a]),[c,f]=l(new Map);j(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||f(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),d(()=>{if(c.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[c.size]);let p=i(()=>{let e=[];for(let t of c.values())s&&!s.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[c,s]);return p.length===0?n(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):n(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[n(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[u(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),u(`span`,{className:`text-[10px] text-foreground-subtle`,children:p.length})]}),u(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map(e=>{let t=o.get(e.deviceId)??`#${e.deviceId}`,r=le(e.metrics.phase);return n(`div`,{title:`${t} · ${r.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[u(de,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),u(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),u(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),u(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}var Gt=`pipeline-orchestrator`;function Kt(e){return De.find(t=>t.stepId===e)??null}function qt({title:e}){return u(`span`,{title:e??`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`,className:`ml-1 rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:`cluster-wide`})}function Jt({step:e,engineFormat:t,runnableModelIds:r}){let i=s(),{data:a,isLoading:o}=R({addonId:Gt}),c=ae({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),l=Oe(a??null)[e.stepId]??e.defaultModelId,d=r.length>0&&!r.includes(l);return n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[n(`div`,{className:`flex items-center text-[11px] font-medium text-foreground`,children:[e.label,u(qt,{})]}),n(`p`,{className:`mt-1 text-[10px] leading-snug text-foreground-subtle`,children:[`Applies to every node. Changing it does not corrupt `,e.indexName,` — every vector carries the model that produced it and only matches its own — but it STRANDS it: the existing vectors stay readable and match nothing until a re-embed pass has run.`]})]}),o?u(Je,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):u(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:l,disabled:c.isPending,onChange:t=>{t.target.value!==l&&c.mutate({addonId:Gt,patch:{[ke(e.stepId)]:t.target.value}})},children:e.options.map(t=>n(`option`,{value:t.id,children:[t.label,t.id===e.defaultModelId?` (default)`:``]},t.id))}),d&&n(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[10px] leading-snug text-amber-300`,children:[`This node's engine (`,t,`) ships no build of `,u(`b`,{children:l}),`. It will REFUSE this step rather than run a different encoder — a substitute would put a second feature space into `,e.indexName,`. Either pick a model with a `,t,` build, or accept that this node contributes nothing to that index.`]}),u(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Stored once, in Pipeline → Cluster → Settings → Enrichment models. This editor writes that same row — there is no per-node copy of this value. Step knobs for this encoder (minimum face size, …) live on that same settings page.`})]})}t();function W(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function Yt(e){if(!e)return null;let t=e.modelId!==void 0&&e.modelId!==``?e.modelId:void 0,n=e.settings&&Object.keys(e.settings).length>0?e.settings:void 0;return t===void 0&&n===void 0?null:{...t===void 0?{}:{modelId:t},...n===void 0?{}:{settings:n}}}function Xt({nodeId:e,refreshToken:t}){let r=s(),[o,c]=l(null),[d,f]=l(null),[p,m]=l(``),[g,_]=l(null),y=N({nodeId:e},{refetchOnMount:`always`}),b=O({nodeId:e},{refetchOnMount:`always`}),x=Oe(R({addonId:`pipeline-orchestrator`}).data??null),S=y.data?.devices??[],C=ce({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),w=i(()=>b.data?be(b.data):[],[b.data]),T=i(()=>S.map(t=>({agentNodeId:e,engineLabel:t.format,deviceKey:t.key,deviceLabel:V(t).label})),[S,e]),E=e=>S.find(t=>t.key===e)??null,D=i(()=>S.filter(e=>e.enabled),[S]),k=D.length>=2,ee=(e,t)=>v(W(b.data??null,e)?.models??[],t?.format),A=e=>{let t=E(e);return t?V(t).label:e},j=(e,t)=>D.filter(n=>n.key!==t&&ee(e,n)).toSorted((e,t)=>e.key<t.key?-1:+(e.key>t.key))[0]??null,M=e=>{let t=W(b.data??null,e)?.enabledByDefault??!0;return{kind:`gate`,effectiveOn:t,defaultOn:t,explicit:!1}},ne=(e,t)=>{let n=W(b.data??null,e);if(n)return h(n,t)},F=(e,t)=>{let n=M(e),r=n.kind===`gate`?n.effectiveOn:!1,i=W(b.data??null,e),a=t.deviceKey===void 0?null:E(t.deviceKey),o=v(i?.models??[],a?.format),s=a?.steps?.[e];if(!o){if(!r)return{kind:`na`};let n=s?.jumpDeviceKey,i=n!==void 0&&D.some(e=>e.key===n)?n:t.deviceKey===void 0?void 0:j(e,t.deviceKey)?.key;return i===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:A(i)}}let c=Kt(e);return c?{kind:`enabled`,modelId:x[e]??c.defaultModelId,clusterWide:!0}:{kind:`enabled`,modelId:(i?P({catalog:i,device:a,base:s?.modelId}):void 0)??`Auto`,...s?.jumpDeviceKey!==void 0&&D.some(e=>e.key===s.jumpDeviceKey)?{jumpTo:A(s.jumpDeviceKey)}:{}}},I=o&&b.data?W(b.data,o.addonId):null,L=o?E(o.deviceKey):null,re=L?.format??`coreml`,ae=o?ne(o.addonId,L):void 0,z=()=>{c(null),f(null),m(``)},se=(e,t)=>{if(t.deviceKey===void 0)return;let n=E(t.deviceKey)?.steps?.[e];c({addonId:e,deviceKey:t.deviceKey});let r=n?.settings??Ae(S.map(e=>({key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}})),t.deviceKey,e)??{};f({enabled:!0,...n?.modelId===void 0?{}:{modelId:n.modelId},settings:r}),m(n?.jumpDeviceKey??``)},le=()=>{if(!o)return;let t=Yt(d),n=p!==``&&p!==o.deviceKey?p:void 0,r=t||n!==void 0?{...t,...n===void 0?{}:{jumpDeviceKey:n}}:null,i=S.map(e=>{let t={...e.steps};return e.key===o.deviceKey&&(r?t[o.addonId]=r:delete t[o.addonId]),{key:e.key,enabled:e.key===o.deviceKey?!0:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:t}}),a=r?.settings!==void 0&&Object.keys(r.settings).length>0?Ne(i,o.deviceKey,o.addonId):i;C.mutate({agentNodeId:e,inferenceDevices:je(a)},{onSuccess:z})};if(y.isLoading||b.isLoading)return u(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(S.length===0)return u(`div`,{className:`rounded-md border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`});if(!b.data)return u(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let ue=o!==null&&I!==null&&L!==null;return n(`div`,{className:`relative h-full w-full space-y-3`,children:[n(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[`Each column is one of this node's inference accelerators. A cell shows the`,` `,u(`span`,{className:`font-medium text-foreground`,children:`base model`}),` every camera landing on that accelerator runs; click to change it. Whether a camera runs a step is set per-camera on that camera's Detection pipeline tab — there is no gate here.`]}),u(`div`,{className:ue?`md:pr-[360px]`:``,children:w.length>0?u(ie,{tree:w,agents:T,gateFor:M,getCellState:F,onCellClick:se,selectedCell:o?{addonId:o.addonId,agentNodeId:e,deviceKey:o.deviceKey}:null,onSetGate:()=>{},fallbackNodeId:g,onFallbackNodeChange:_,hideGate:!0}):u(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),u(oe,{open:ue,onClose:z,title:I?.name??``,subtitle:o&&L?`${e} · ${V(L).label} · ${L.format}`:``,footer:n(a,{children:[u(`div`,{className:`flex-1`}),u(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:z,children:`Cancel`}),u(`button`,{type:`button`,disabled:!o||!d||C.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:le,children:C.isPending?`Saving…`:`Save`})]}),children:I&&o&&Kt(o.addonId)?u(Jt,{step:Kt(o.addonId),engineFormat:re,runnableModelIds:te(I.models??[],re).map(e=>e.id)}):I&&o&&d?n(`div`,{className:`space-y-3`,children:[k&&n(`div`,{className:`rounded-md border border-border bg-muted/10 px-3 py-2 space-y-1`,children:[u(`label`,{className:`block text-[11px] font-medium text-foreground`,children:`Run on`}),n(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:p,onChange:e=>m(e.target.value),children:[u(`option`,{value:``,children:`Auto (this device, or auto-jump if unsupported)`}),D.filter(e=>e.key!==o.deviceKey).map(e=>n(`option`,{value:e.key,children:[V(e).label,` · `,e.format]},e.key))]}),u(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Route this step (and its child steps) to another accelerator on this node.`})]}),u(Ce,{mode:`agent`,addon:I,agentDefault:d,agentNodeId:e,engineFormat:re,effectiveModelId:ae,onChangeAgentConfig:f})]}):u(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300`,children:`This accelerator is no longer reported by the node, so there is nothing to provision here.`})})]})}t();var Zt=!1;function Qt({nodeId:e,refreshToken:t}){let r=xe(),[i,a]=l(null),[o,s]=l(null),c=(B(void 0).data??[]).find(t=>t.id===e),d=c?.name??e,f=c?.isOnline??!1,p=I({onSuccess:e=>{s(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),m=async()=>{await r({title:`Reset ${d} to hardware-aware defaults?`,message:`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(s(null),p.mutate({agentNodeId:e}))};return n(`div`,{className:`relative h-full w-full space-y-3`,children:[n(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[o&&u(`span`,{className:`text-emerald-400`,children:o}),p.isError&&u(`span`,{className:`text-red-400`,children:p.error instanceof Error?p.error.message:`Reset failed`}),u(`button`,{type:`button`,onClick:()=>{m()},disabled:p.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's per-device model defaults + per-camera overrides scoped to this node`,children:p.isPending?`Resetting…`:`Reset to default`})]}),u(Wt,{nodeId:e}),Zt,Zt,n(`div`,{children:[u(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices — default model per accelerator`}),u(Fe,{nodeId:e,nodeName:d,isOnline:f})]}),n(`div`,{children:[u(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection steps — model per accelerator`}),u(Xt,{nodeId:e,refreshToken:t})]})]})}var $t=[`assignments`,`tree`,`engines`,`logs`],en=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],tn=`decoder-nodeav`;function nn({nodeId:e,refreshToken:t}){let{data:r}=B(void 0),i=r?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??tn,a=[...en,i],o={assignments:{id:`assignments`,label:`Assignments`,order:-10,content:u(Rt,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:`Pipeline`,order:39,content:u(Qt,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:`Warm instances`,order:180,content:u(Bt,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:`Logs`,order:300,content:u(Ut,{nodeId:e})}},s=$t.map(e=>o[e]);return n(`div`,{className:`flex flex-col h-full`,children:[u(yt,{nodeId:e,refreshToken:t}),u(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:u(ct,{nodeId:e,addonIds:a,level:`global`,extraTabs:s})})]})}function rn(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?`CPU`:t===`openvino`&&n===`npu`?`Intel NPU`:t===`openvino`&&(n===`gpu`||n===`igpu`)?`Intel iGPU`:t===`edgetpu`?`Coral Edge TPU`:t===`coreml`?`Apple ANE`:`${e.backend} ${e.device}`.trim()}var an={disabled:`switched off — not a dispatch target`,unavailable:`the node probe does not see it (unplugged or still provisioning)`,"cannot-host-camera-root":`its engine format has no object-detection root model`,"accelerator-preferred":`CPU fallback — it never competes while an accelerator is serving`};function G(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function on(e,t){let n=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let r=t.get(e.key),i=r?.sessions??0,a=e.weight>0?e.weight:1;return{key:e.key,label:rn(e),format:e.format,sessions:i,queueDepth:r?.queueDepth??0,weight:a,weightSharePct:e.exclusion===null?G(a,n):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function sn(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0),r=e.loads.reduce((e,t)=>e+t.load.attachedCameras,0);return e.nodes.map(i=>{let a=t.get(i.id),o=on(e.devicesByNode[i.id]??[],new Map((a?.load.devices??[]).map(e=>[e.deviceKey,{sessions:e.attachedCameras,queueDepth:e.queueDepthTotal}]))),s=i.isOnline&&i.detectEnabled,c=i.weight>0?i.weight:1,l=a?.load.attachedCameras??null;return{nodeId:i.id,name:i.name,isOnline:i.isOnline,detectEnabled:i.detectEnabled,reported:a!==void 0,attachedCameras:l,activeCameras:a?.load.activeCameras??null,maxCameras:i.maxCameras,capacityPct:l!==null&&i.maxCameras!==null&&i.maxCameras>0?G(l,i.maxCameras):null,queueDepthTotal:a?.load.queueDepthTotal??null,avgInferenceTimeMs:a?.load.avgInferenceTimeMs??null,score:a?.score??null,weight:c,weightSharePct:s?G(c,n):null,cameraSharePct:l===null?null:G(l,r),decodeHwaccel:a?.decodeHwaccel??null,devices:o,eligibleDeviceCount:o.filter(e=>e.exclusion===null).length}})}var cn=`pipeline-orchestrator`,ln=`recorder`,un=`recordingNodeId`,dn=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`],fn=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function pn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function mn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function K(e,t,n){let r=pn(e,t);return typeof r==`string`&&r.length>0?r:n}function hn(e,t,n){let r=pn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function q(e,t){let n=mn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function gn(e,t){let n=mn(e,t);return typeof n==`string`&&n.length>0?n:null}function _n(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:`Motion Node`}function vn(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:e===`audioNode`?`Node that runs singleton audio work`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function yn(e,t){switch(t){case`detect`:return e.pipeline}}function bn(e){return e instanceof Error?e.message:`Failed to save`}function xn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}t();var Sn=2e4,Cn=3e5;function wn(){let{nodes:e}=_(),t=f().trpcClient,r=k(void 0,{placeholderData:c,staleTime:Sn,refetchInterval:Sn,refetchOnWindowFocus:!0}),a=C(void 0,{staleTime:Cn}),s=i(()=>e.map(e=>e.id),[e]),l=o({queries:s.map(e=>({queryKey:we(Se.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>t.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:Cn,refetchOnWindowFocus:!1,placeholderData:c}))}),d=i(()=>{let e={};return s.forEach((t,n)=>{let r=l[n]?.data;r&&(e[t]=r.devices)}),e},[s,l.map(e=>e.dataUpdatedAt).join(`|`)]),p=i(()=>{let e=new Map;for(let t of a.data??[])e.set(t.nodeId,t.settings);return e},[a.data]),m=i(()=>e.map(e=>{let t=p.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:ht(t,e.isHub).pipeline,weight:q(t,`detectWeight`)??1,maxCameras:q(t,`maxCameras`)}}),[e,p]),h=r.data??[],g=i(()=>sn({nodes:m,loads:h,devicesByNode:d}),[m,h,d]),v=g.reduce((e,t)=>e+(t.attachedCameras??0),0),y=g.reduce((e,t)=>e+(t.activeCameras??0),0),b=r.dataUpdatedAt>0?Date.now()-r.dataUpdatedAt:null;return n(`section`,{className:`rounded-md border border-border bg-surface px-3 py-2.5`,children:[n(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 mb-2`,children:[u(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Node load`}),n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[y,` running · `,v,` attached across `,g.length,` `,g.length===1?`node`:`nodes`]}),u(`span`,{className:`ml-auto text-[10px] text-foreground-subtle/70 tabular-nums`,children:r.data===void 0?`reading…`:`reading ${b===null?`—`:`${Math.round(b/1e3)}s`} old · every ${Sn/1e3}s`})]}),g.length===0?u(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:`No cluster nodes reported yet.`}):u(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:g.map(e=>u(Tn,{row:e},e.nodeId))})]})}function Tn({row:e}){let t=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return n(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[n(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[u(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),u(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&u(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:`no detect`}),!e.reported&&e.isOnline&&n(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`,children:[u(rt,{className:`h-2.5 w-2.5`}),` no reading`]}),!e.isOnline&&n(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[u(it,{className:`h-2.5 w-2.5`}),` offline`]})]}),n(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[u(J,{label:`Running / attached`,value:t,title:`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`}),u(J,{label:`Target share`,value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:`detectWeight normalised over the nodes the balancer actually ranks (online AND detect-enabled).`}),u(J,{label:`Actual share`,value:e.cameraSharePct===null?`—`:`${e.cameraSharePct}%`,title:`Share of the cluster's attached cameras this node carries right now.`}),u(J,{label:`Score · queue`,value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`}),e.capacityPct!==null&&u(J,{label:`Cap fill`,value:`${e.capacityPct}%`,title:`attached / maxCameras.`}),e.avgInferenceTimeMs!==null&&u(J,{label:`Avg infer`,value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:`Mean inference time across this node's attached cameras.`}),e.decodeHwaccel!==null&&u(J,{label:`Decode`,value:e.decodeHwaccel,title:`This node's probed decode hwaccel.`})]}),u(En,{row:e})]})}function En({row:e}){return e.devices.length===0?u(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:`Accelerators not read yet.`}):n(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[n(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[u(Ye,{className:`h-2.5 w-2.5`}),`Accelerators`,e.eligibleDeviceCount===0&&u(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`,children:`none in play · runner default pool`})]}),u(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>u(Dn,{device:e},e.key))})]})}function Dn({device:e}){let t=e.exclusion;return n(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[u(H,{className:`h-2.5 w-2.5 shrink-0 ${t===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),u(`span`,{className:`shrink-0 font-medium ${t===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),t===null?n(a,{children:[n(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[e.weightSharePct,`% share`]}),n(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[`· `,e.sessions,` session`,e.sessions===1?``:`s`,e.maxSessions===null?``:`/${e.maxSessions}`]}),e.queueDepth>0&&n(`span`,{className:`shrink-0 tabular-nums text-amber-400`,children:[`· q`,e.queueDepth]}),e.atCap&&u(`span`,{className:`shrink-0 text-amber-400`,title:`At its maxSessions cap — the balancer skips it until a session ends.`,children:`· at cap`})]}):n(`span`,{className:`truncate text-foreground-subtle/80`,title:an[t],children:[`excluded — `,an[t]]})]})}function J({label:e,value:t,title:r}){return n(`div`,{className:`min-w-0`,title:r,children:[u(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),u(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function On(){return n(`div`,{className:`space-y-6`,children:[u(Wt,{title:`Cluster cameras`}),u(wn,{}),n(`div`,{className:`min-w-0`,children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Use the Auto | Pin control to pin a camera to a node, the inference-device select to pin it to an accelerator, or the kebab to move a role; expand the chevron for the per-camera broker drill-down. Cluster load, inference-device weights, and Rebalance live on the Balancer tab.`})]}),u(Et,{mode:`cluster`})]})}function kn({capability:e,label:t,hint:r,nodeId:i,active:a,pending:o,layout:s,onToggle:c}){let l=a?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,d=s===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,f=a?st:Ie;return n(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":`${t} capability for ${i}`,title:`${t} — ${r}`,disabled:o,onClick:()=>c(e,!a),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${l} ${d}`,children:[u(f,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),u(`span`,{children:t})]})}function An({node:e,emphasis:t=!1}){let r=e.isHub?We:H;return n(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[u(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),u(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[u(`span`,{className:`truncate`,children:e.name}),e.isHub&&u(T,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&u(T,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),u(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}t();function jn({nodeId:e,value:t,detectedHosts:r,status:i,errorMessage:a,onCommit:o}){let[s,c]=l(t??``);d(()=>{c(t??``)},[t]);let f=r[0],p=f===void 0?`auto-detect`:`auto: ${f}`,m=i===`pending`,h=s.trim(),g=h!==(t??``),_=g&&!m,v=()=>{_&&o(e,h.length>0?h:null)};return n(`div`,{className:`flex items-center gap-1.5`,children:[u(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:p,value:s,disabled:m,onChange:e=>c(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&c(t??``)},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`}),n(`button`,{type:`button`,onClick:v,disabled:!_,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[m?u(Je,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):u(st,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&i===`success`&&u(st,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),i===`error`&&u(`span`,{title:a??`Failed to save reachable host`,children:u(Ze,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}function Mn({label:e,children:t}){return n(`div`,{className:`flex items-center justify-between gap-3`,children:[u(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function Nn({node:e,actions:t}){return n(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[u(An,{node:e,emphasis:!0}),u(`div`,{className:`grid grid-cols-2 gap-2`,children:fn.map(n=>u(kn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:yn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),u(`div`,{className:`space-y-3 border-t border-border pt-3`,children:u(Mn,{label:`Reachable host`,children:u(jn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function Pn(){return n(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[n(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),n(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),n(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),n(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function Fn({nodes:e,actions:t}){return u(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:n(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[u(`thead`,{children:n(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[u(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),fn.map(e=>u(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),u(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),u(`tbody`,{children:e.map(e=>n(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[u(`td`,{className:`px-4 py-3 align-middle`,children:u(An,{node:e})}),fn.map(n=>u(`td`,{className:`px-3 py-3 text-center align-middle`,children:u(kn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:yn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),u(`td`,{className:`px-4 py-3 align-middle`,children:u(jn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})]},e.id))})]})})}function In({role:e,value:t,options:r,pending:i,onChange:a}){return n(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[u(`span`,{className:`text-xs font-semibold text-foreground`,children:_n(e)}),u(`select`,{value:t,disabled:i,onChange:t=>a(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:r.map(e=>u(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),u(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:vn(e)})]})}function Ln({roleValues:e,options:t,pending:r,lowFpsEnabled:i,fpsMinThreshold:a,onRoleChange:o,onLowFpsToggle:s}){return n(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[dn.map(n=>u(In,{role:n,value:e[n],options:t,pending:r,onChange:o},n)),n(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[u(`input`,{type:`checkbox`,checked:i,disabled:r,onChange:e=>s(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),n(`span`,{className:`flex flex-col gap-0.5`,children:[u(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),n(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,i?`${a} fps`:`disabled`]})]})]})]})}t();function Rn(){let e=s(),{nodes:t}=_(),r=C(void 0),o=R({addonId:cn}),c=R({addonId:ln}),d=()=>xn(e),f=ee({onSuccess:d}),m=p(),h=ye({onSuccess:d}),g=ae({onSuccess:d}),[v,y]=l(!1),b=i(()=>{let e=new Map;for(let t of r.data??[])e.set(t.nodeId,t.settings);return e},[r.data]),x=i(()=>t.map(e=>{let t=b.get(e.id),n=ht(t,e.isHub),r=q(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:q(t,`maxCameras`),reachableHost:gn(t,`reachableHost`),detectedHosts:e.localIps}}),[t,b]),S=x.filter(e=>e.effective.pipeline),w={ingestNode:K(o.data,`ingestNode`,`hub`),recordingNode:K(c.data,un,`hub`),audioNode:K(o.data,`audioNode`,`hub`),motionNode:K(o.data,`motionNode`,`hub`)},T=i(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...dn.map(e=>w[e]),...e])].filter(e=>e.length>0)},[t,w]),E=hn(o.data,`fpsMinThreshold`,0),D=E>0,O=r.isLoading||o.isLoading||c.isLoading,k=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},A=(e,t)=>{if(e===`recordingNode`){g.mutate({addonId:ln,patch:{[un]:t}});return}g.mutate({addonId:cn,patch:{[e]:t}})},j=e=>{g.mutate({addonId:cn,patch:{fpsMinThreshold:e?Math.max(1,E):0}})},M=e=>h.variables?.agentNodeId===e?h.isPending?`pending`:h.isError?`error`:h.isSuccess?`success`:`idle`:`idle`,te=e=>M(e)===`error`?bn(h.error):null,ne=async e=>{y(!0);try{for(let t of e)await m.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{y(!1),d()}},N={capabilityPending:f.isPending,onToggleCapability:k,onCommitReachableHost:(e,t)=>h.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:M,reachableHostErrorMessage:te};return n(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[n(`header`,{className:`flex items-start justify-between gap-4`,children:[n(`div`,{className:`space-y-1`,children:[u(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),u(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),O&&u(Je,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),n(`div`,{className:`space-y-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),u(Ln,{roleValues:w,options:T,pending:g.isPending,lowFpsEnabled:D,fpsMinThreshold:E,onRoleChange:A,onLowFpsToggle:j})]}),n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),u(Pn,{})]}),x.length===0?u(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No cluster nodes reporting yet.`}):n(a,{children:[u(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:x.map(e=>u(Nn,{node:e,actions:N},e.id))}),u(`div`,{className:`hidden @3xl/clustertab:block`,children:u(Fn,{nodes:x,actions:N})})]})]}),n(`div`,{className:`space-y-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),u(Pe,{nodes:S,pending:v,onCommitWeights:e=>void ne(e)})]}),n(`div`,{className:`space-y-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices`}),S.length===0?u(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No detect-capable nodes — enable detection on a node above to configure its accelerators.`}):u(`div`,{className:`space-y-2`,children:S.map(e=>u(Fe,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline},e.id))})]})]})}t(),t(),t(),t();function zn(e){if(e===void 0||e.length===0)return[];let t=new Set,n=[];for(let r of e)for(let e of r.capabilities){let i=`${e}\0${r.addonId}`;t.has(i)||(t.add(i),n.push({name:e,addonId:r.addonId}))}return n.toSorted((e,t)=>e.name.localeCompare(t.name))}function Bn(e){let t=e.services;return{pid:e.pid,name:e.name,addonId:t?.[0]?.addonId??``,cpu:e.cpuPercent,mem:e.memoryRss,state:e.state,caps:zn(t)}}function Vn(e){return{nodeId:e.id,isHub:e.isHub,isOnline:e.isOnline,lastSeen:e.lastSeen,identity:{name:e.name,ip:e.localIps?.[0]??``,cpu:e.cpuPercent,mem:e.memoryPercent,platform:e.platform,arch:e.arch},runners:e.processes.map(Bn)}}function Hn(e){let t=e.toSorted((e,t)=>{let n=+!!e.isHub;return+!!t.isHub-n}).map(Vn),n=t.find(e=>e.isHub);return n===void 0?{nodes:t,edges:[]}:{nodes:t,edges:t.filter(e=>!e.isHub).map(e=>({id:`hub:${n.nodeId}->${e.nodeId}`,source:n.nodeId,target:e.nodeId,online:e.isOnline&&n.isOnline}))}}t();var Un=!1;function Wn({refreshToken:e}){let t=s(),{data:r}=B(void 0);i(()=>Hn(r??[]),[r]);let a=S({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return n(`div`,{className:`space-y-6`,children:[u(bt,{refreshToken:e}),u(Rn,{}),Un,n(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[n(`div`,{className:`min-w-0`,children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Rebalance`}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Recompute the optimal node for every assigned camera from current load + hardware affinity, and migrate the ones no longer on their best node. Pinned cameras never move.`})]}),n(`button`,{type:`button`,onClick:()=>a.mutate(void 0),disabled:a.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[u(qe,{className:`h-3.5 w-3.5`}),a.isPending?`Rebalancing…`:`Rebalance pipelines`]})]})]})}var Gn=[`pipeline-orchestrator`],Kn=`pipeline-analytics`,qn=`face-gallery`;function Jn({refreshToken:e}){return n(`div`,{className:`space-y-4 max-w-3xl`,children:[u(ct,{nodeId:`hub`,addonIds:Gn,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer, failover, enrichment models, and the admission settings those models share. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`}),u(ct,{nodeId:`hub`,addonIds:[Kn],level:`global`,capability:qn,title:`Face recognition`,description:`Match threshold, ambiguity margin, and auto-assign floors. Same settings as System → Settings → pipeline-analytics — this page asks the face-gallery cap, it does not store a second copy.`})]})}t();function Yn({refreshToken:e}){let t=s(),{data:r,isLoading:i}=_e(),[o,c]=l(null),[d,f]=l(``),[p,m]=l(``),h=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},g=he({onSuccess:()=>{c(null),h()}}),_=D({onSuccess:h}),v=e=>{c(e.id),f(e.name),m(e.description??``)},y=()=>{c(null),f(``),m(``)},b=()=>{if(!o)return;let e=p.trim();g.mutate({id:o,name:d.trim()||`Untitled`,...e?{description:e}:{}})};if(i)return u(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let x=[...r??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return u(`div`,{className:`space-y-6 max-w-4xl`,children:n(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),u(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[x.length,` template`,x.length===1?``:`s`]})]}),x.length===0?n(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[u(Ve,{className:`h-6 w-6 opacity-40`}),u(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):u(`ul`,{className:`divide-y divide-border`,children:x.map(e=>{let t=o===e.id;return u(`li`,{className:`px-4 py-3 text-xs`,children:n(`div`,{className:`flex items-start gap-3`,children:[u(`div`,{className:`flex-1 min-w-0`,children:t?n(`div`,{className:`space-y-2`,children:[u(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:d,onChange:e=>f(e.target.value),placeholder:`Template name`,autoFocus:!0}),u(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:p,onChange:e=>m(e.target.value),placeholder:`Description (optional)`})]}):n(a,{children:[u(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&u(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),n(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,n(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),u(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?n(a,{children:[n(`button`,{type:`button`,onClick:b,disabled:g.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[u(st,{className:`h-3 w-3`}),`Save`]}),n(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[u(ot,{className:`h-3 w-3`}),`Cancel`]})]}):n(a,{children:[u(`button`,{type:`button`,onClick:()=>v(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:u(Be,{className:`h-3 w-3`})}),u(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&_.mutate({id:e.id})},disabled:_.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:u(at,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}var Xn=`pipeline-orchestrator`,Zn=200;function Qn(){return n(`div`,{className:`flex flex-col gap-3`,children:[n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`})]}),u(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:u(x,{addonId:Xn,limit:Zn,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}t();var $n=[{id:`assignments`,label:`Assignments`},{id:`balancer`,label:`Balancer`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function er({refreshToken:e}){let[t,r]=l(`assignments`);return n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[u(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),u(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Per-camera assignments, the load balancer (live load + inference-device weights), cluster-wide settings, and the pipeline template library.`})]}),u(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:$n.map(e=>u(`button`,{type:`button`,onClick:()=>r(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),n(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&u(On,{}),t===`balancer`&&u(Wn,{refreshToken:e}),t===`settings`&&u(Jn,{refreshToken:e}),t===`templates`&&u(Yn,{refreshToken:e}),t===`logs`&&u(Qn,{})]})]})}var tr=`armed:`;function nr(e){return e.assignment.reasons.detection?.startsWith(tr)===!0}function rr(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!nr(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function ir(e){let t=[],n=[],{assignment:r,detection:i,decoder:a,broker:o}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?`Engine provisioning failed: ${i.provisioning.error}`:`Engine provisioning failed on the detection node`}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:`Detection phase is ACTIVE but 0 fps are being processed — frames are not reaching the detector (cross-node black-hole signature)`}),i!==null&&i.phase===`active`&&a!==null&&a.shm.framesWritten===0&&t.push({code:`decoder-black-hole`,severity:`error`,message:`Decoder on ${a.nodeId} has written 0 frames to the shared-memory plane while detection is active — the decode path is stalled`}),r.detectionNodeId===null&&i===null&&!nr(e)&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});let s=e.degraded??[];if(s.length>0){let e=[...new Set(s.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:`Could not read ${e} for this camera — those blocks are unknown, not empty (a switch read that failed does NOT mean nothing is switched off)`})}for(let e of o?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function ar(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function or(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function sr(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function cr(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var lr={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function ur(e){if(!ar(e)||!Array.isArray(e.sections))return lr;let t=Te(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)cr(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:or(n(`detectionFps`)),motionSources:sr(n(`motionSources`)),motionFps:or(n(`motionFps`)),motionCooldownMs:or(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function dr(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...dr(r.children,t+1));return n}function X({title:e,children:t}){return n(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[u(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),u(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:r=!1}){return n(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[u(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),u(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),r&&u(fr,{})]})}function fr(){return u(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:`Device-level override active`,"aria-label":`Device-level override active`,role:`img`})}var pr={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return u(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${pr[e]}`,children:t})}function $({children:e}){return u(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function mr({icon:e,label:t,nodeId:r,pinned:i,reason:o,overridden:s}){return n(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[u(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),u(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),r===null?u(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):n(a,{children:[u(`span`,{className:`font-mono text-foreground truncate`,title:r,children:r}),i?n(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[u(dt,{className:`h-2.5 w-2.5`}),` manual`]}):n(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,o!==void 0&&o.length>0?o:`capacity`]}),s&&u(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function hr({assignment:e,settings:t,onlineNodes:r,pinPending:i,onDetectionPinChange:a}){let o=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,s=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...r.map(e=>e.id)])];return n(X,{title:`Where it runs`,children:[u(mr,{icon:H,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),u(mr,{icon:et,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),u(mr,{icon:Re,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),u(mr,{icon:He,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),u(`div`,{className:`mt-1.5`,children:n(`select`,{value:o,disabled:i,"aria-label":`Detection placement pin`,onChange:e=>a(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[u(`option`,{value:`auto`,children:`Auto (load balanced)`}),s.map(e=>n(`option`,{value:e,children:[`Pin detection → `,r.find(t=>t.id===e)?.name??e]},e))]})})]})}function gr(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function _r(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function vr(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function yr({streams:e,brokerProfiles:t,settings:r,motionEnabled:i,motionFpsLive:o}){let s=_r(t,r.detectionStreamProfile),c=_r(t,r.motionStreamProfile),l=r.motionSources.includes(`analyzer`);return n(X,{title:`Streams & motion`,children:[n(Z,{label:`Detect stream`,overridden:r.overriddenKeys.has(`detectionStreamProfile`),children:[r.detectionStreamProfile??`—`,s!==void 0&&` · ${s.width}×${s.height} ${s.codec}`]}),u(Z,{label:`Detect FPS`,overridden:r.overriddenKeys.has(`detectionFps`),children:vr(r.detectionFps)}),n(Z,{label:`Motion src`,overridden:r.overriddenKeys.has(`motionSources`),children:[r.motionSources.length>0?r.motionSources.join(` + `):`none`,i===!1&&` · inactive`]}),l&&n(a,{children:[n(Z,{label:`Motion stream`,overridden:r.overriddenKeys.has(`motionStreamProfile`),children:[r.motionStreamProfile??`—`,c!==void 0&&` · ${c.width}×${c.height} ${c.codec}`]}),n(Z,{label:`Motion FPS`,overridden:r.overriddenKeys.has(`motionFps`),children:[vr(r.motionFps),o!==null&&` · live ${o.toFixed(1)}`]})]}),u(Z,{label:`Cooldown`,overridden:r.overriddenKeys.has(`motionCooldownMs`),children:r.motionCooldownMs===null?`default`:`${r.motionCooldownMs/1e3}s`}),u(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?u($,{children:`No streams registered`}):e.map(e=>n(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[u(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,gr(e)]},e.camStreamId))})]})}function br({steps:e,audioModelId:t,audioEnabled:r,audioMode:i}){return n(X,{title:`Pipeline steps`,children:[e===void 0?u($,{children:`Resolving…`}):e.length===0?u($,{children:`No steps configured`}):u(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>u(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:n(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&u(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&n(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),u(`div`,{className:`mt-1`,children:n(Z,{label:`Audio class.`,children:[i??`—`,r!==null&&(r?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var xr={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Sr({detection:e,live:t,detectionMode:r,modeOverridden:i}){if(e===null)return n(X,{title:`Detection runtime`,children:[u(Z,{label:`Mode`,overridden:i,children:r??`—`}),u($,{children:`Detection stage inactive or unreachable`})]});let a=t?.phase??e.phase,o=t?.actualFps??e.actualFps,s=t?.configuredFps??e.configuredFps,c=t?.avgInferenceTimeMs??e.avgInferenceMs,l=t?.queueDepth??e.queueDepth,d=le(a),f=a===`active`&&o===0;return n(X,{title:`Detection runtime`,children:[n(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[n(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${d.badgeClass}`,children:[u(de,{phase:a,className:`h-2.5 w-2.5`}),d.label]}),t!==void 0&&u(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),u(Z,{label:`Mode`,overridden:i,children:r??`—`}),n(Z,{label:`FPS`,children:[u(`span`,{className:f?`text-danger font-semibold`:``,children:o.toFixed(1)}),n(`span`,{className:`text-foreground-subtle`,children:[` / `,s.toFixed(0),` configured`]})]}),n(Z,{label:`Inference`,children:[c.toFixed(0),` ms`,l>0&&n(`span`,{className:`text-warning`,children:[` · queue `,l]}),t!==void 0&&t.droppedFrames>0&&n(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),n(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),n(Z,{label:`Provisioning`,children:[u(Q,{tone:xr[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&n(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function Cr({broker:e}){return e===null?u(X,{title:`Stream broker`,children:u($,{children:`Broker stage inactive or unreachable`})}):n(X,{title:`Stream broker`,children:[e.profiles.length===0?u($,{children:`No broker profiles`}):u(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,r=t&&e.inFps===0;return n(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[u(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${r?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),u(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),n(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),n(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),n(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),n(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[n(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),n(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function wr({decoder:e,detectionActive:t}){if(e===null)return u(X,{title:`Decoder`,children:u($,{children:`Decoder stage inactive or unreachable`})});let r=t&&e.shm.framesWritten===0;return n(X,{title:`Decoder`,children:[u(Z,{label:`Node`,children:e.nodeId}),u(Z,{label:`Sessions`,children:e.sessionCount}),n(Z,{label:`SHM frames`,children:[u(`span`,{className:r?`text-danger font-semibold`:``,children:e.shm.framesWritten}),u(`span`,{className:`text-foreground-subtle`,children:` written`})]}),n(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&n(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),n(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&u(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}t();var Tr=`pipeline-orchestrator`,Er={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Dr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function Or({problems:e}){return u(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>n(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[u(rt,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),u(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function kr({deviceId:e,name:t,online:r,status:a,live:o,onlineNodes:c}){let l=s(),{data:d}=ue({addonId:Tr,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:f}=re({deviceId:e},{staleTime:3e4}),p=i(()=>ur(d),[d]),m=i(()=>f===void 0?void 0:dr(f.steps),[f]),h=i(()=>a===void 0?[]:ir(a),[a]),g=()=>{l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},_=E({onSuccess:g}),v=z({onSuccess:g}),y=t=>{t===`auto`?v.mutate({deviceId:e}):_.mutate({deviceId:e,agentNodeId:t})},b=a===void 0?`idle`:rr(a),x=h.some(e=>e.severity===`error`),S=h.length>0,C=x?`border-danger/50`:S?`border-warning/40`:`border-border`;return n(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${C} bg-background overflow-hidden`,children:[n(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[u(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${x?`bg-danger`:Er[b]}`,title:x?`Error`:Dr[b],"aria-label":x?`Error`:Dr[b],role:`img`}),u(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),n(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!r&&u(Q,{tone:`danger`,children:`offline`}),n(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[p.detectionMode!==null&&u(Q,{tone:p.detectionMode===`disabled`?`warning`:p.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:p.detectionMode===`disabled`?`detection off`:p.detectionMode}),a?.recording!=null&&(a.recording.active?n(Q,{tone:`danger`,title:`Recording (${a.recording.mode})`,children:[u(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):a.recording.mode!==`off`&&n(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,a.recording.mode]}))]})]}),h.length>0&&u(Or,{problems:h}),a===void 0?u(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`}):n(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[u(hr,{assignment:a.assignment,settings:p,onlineNodes:c,pinPending:_.isPending||v.isPending,onDetectionPinChange:y}),u(Sr,{detection:a.detection,live:o,detectionMode:p.detectionMode,modeOverridden:p.overriddenKeys.has(`detectionMode`)}),u(br,{steps:m,audioModelId:f?.audio?.modelId??null,audioEnabled:a.audio?.enabled??f?.audio?.enabled??null,audioMode:p.audioMode}),u(yr,{streams:a.source.streams,brokerProfiles:a.broker?.profiles,settings:p,motionEnabled:a.motion?.enabled??null,motionFpsLive:a.motion?.fps??null}),u(Cr,{broker:a.broker}),u(wr,{decoder:a.decoder,detectionActive:a.detection?.phase===`active`})]})]})}t();var Ar=5e3,jr=1e4,Mr=5e3;function Nr(e){let t=s(),{data:n,isLoading:r}=Me(),{data:a,isLoading:o}=A({},{refetchInterval:Ar}),{nodes:c}=_();d(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[u,f]=l(new Map);j(Ee.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),d(()=>{if(u.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-jr,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Mr);return()=>clearInterval(e)},[u.size]);let p=i(()=>{let e=new Map;for(let t of a??[])e.set(t.deviceId,t);return e},[a]);return{rows:i(()=>(n??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[n,p]),liveMetrics:u,onlineNodes:i(()=>(c??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[c]),isLoading:r||o}}t();function Pr({refreshToken:e}){let{rows:t,liveMetrics:r,onlineNodes:a,isLoading:o}=Nr(e),s=i(()=>[...t.map(e=>{let t=e.status===void 0?[]:ir(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[t]),c=i(()=>{let e=0,t=0;for(let n of s)(n.errorCount>0||n.warningCount>0)&&(t+=1),(r.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:s.length,active:e,issues:t}},[s,r]);return o&&t.length===0?u(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?u(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):u(`div`,{className:`h-full overflow-y-auto`,children:n(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[n(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[n(`span`,{children:[u(`span`,{className:`font-semibold text-foreground`,children:c.total}),` cameras`]}),n(`span`,{children:[u(`span`,{className:`font-semibold text-success`,children:c.active}),` actively inferring`]}),n(`span`,{children:[u(`span`,{className:`font-semibold ${c.issues>0?`text-danger`:`text-foreground`}`,children:c.issues}),` `,`with issues`]}),u(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),s.map(({row:e})=>u(kr,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:r.get(e.deviceId),onlineNodes:a},e.deviceId))]})})}t();var Fr=`__cluster__`;function Ir(e){return e===`cameras`?`cameras`:`nodes`}function Lr(){let[e,t]=nt(),r=Ir(e.get(`view`)),i=e.get(`node`)??`__cluster__`,[o,s]=l(0),[c,f]=l(!1);return d(()=>{r===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:Fr},{replace:!0})},[r,e,t]),n(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[n(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[n(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[u(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:i},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,r===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),u(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,r===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),u(`div`,{className:`flex items-center gap-2`,children:n(`button`,{type:`button`,onClick:()=>s(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[u(Ue,{className:`h-3.5 w-3.5`}),`Refresh`]})})]}),r===`nodes`&&n(`button`,{type:`button`,onClick:()=>f(e=>!e),"aria-expanded":c,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[n(`span`,{children:[c?`Hide`:`Show`,` node list`]}),u(tt,{className:[`h-4 w-4 transition-transform`,c?`rotate-180`:``].join(` `)})]}),u(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:r===`nodes`?n(a,{children:[u(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:u(vt,{selectedNodeId:i,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),f(!1)},refreshToken:o})}),u(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:i===`__cluster__`?u(er,{refreshToken:o}):u(nn,{nodeId:i,refreshToken:o})})]}):u(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:u(Pr,{refreshToken:o})})})]})}export{Lr as PipelinePage};
|