@camstack/addon-admin-ui 1.1.62 → 1.1.63
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-DloYiu2S.js → AddLocationWizard-VuBsssbs.js} +1 -1
- package/dist/assets/{AddonCollectionPage-C9umFG6x.js → AddonCollectionPage-rY0iw4Lx.js} +1 -1
- package/dist/assets/Addons-waDrxMrF.js +1 -0
- package/dist/assets/{AdminTabs-TF8h_0Re.js → AdminTabs-DdlxkzYF.js} +1 -1
- package/dist/assets/{AiProfiles-evBlKpAk.js → AiProfiles-CXfreEns.js} +1 -1
- package/dist/assets/{BrokerForm-CQiMr-0k.js → BrokerForm-Bi1zDzJU.js} +1 -1
- package/dist/assets/{Capabilities-CpLtxdIb.js → Capabilities-CBqnCVAQ.js} +1 -1
- package/dist/assets/{CapabilityBadges-BaPmSkOh.js → CapabilityBadges-bb3Kp76B.js} +1 -1
- package/dist/assets/{Cluster-DXC7Y0WT.js → Cluster-CkmNDo_z.js} +1 -1
- package/dist/assets/{ClusterRecordingTab-C8mgxr8n.js → ClusterRecordingTab-qj7qdRav.js} +1 -1
- package/dist/assets/{Dashboard-B8VEZ1hu.js → Dashboard-0L-WtwHw.js} +1 -1
- package/dist/assets/{Data-C4BVroUC.js → Data-B-KdcyYb.js} +1 -1
- package/dist/assets/{DetectionIntelligence-C4VkDPxu.js → DetectionIntelligence-DH2CerYz.js} +1 -1
- package/dist/assets/DeviceDetail-C0xHmlNy.js +2 -0
- package/dist/assets/{Devices-Bo3g7ayF.js → Devices-BqWTi9bF.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-ChQqe1h_.js → EmbedPlayerPage-BmllV_ir.js} +1 -1
- package/dist/assets/{Events-BEqbcBJ_.js → Events-Cg33ehHw.js} +1 -1
- package/dist/assets/{FormBuilder-CEAqDJkq.js → FormBuilder-DDOu77Pz.js} +1 -1
- package/dist/assets/Identity-DokGTNX5.js +1 -0
- package/dist/assets/{IntegrationDetail-C34UIPLB.js → IntegrationDetail-HKDhoWtW.js} +1 -1
- package/dist/assets/{Integrations-B1rfOrsh.js → Integrations-as3Ez0fd.js} +1 -1
- package/dist/assets/{Integrations-CNkb6EXJ.js → Integrations-qqFL0Gs0.js} +1 -1
- package/dist/assets/{Logs-b1hP9wnb.js → Logs-C0i-qXwM.js} +1 -1
- package/dist/assets/{MotionZonesSettings-QJdI6XiU.js → MotionZonesSettings-rxIHdY6l.js} +1 -1
- package/dist/assets/{MyAccess-Dsd8wzR-.js → MyAccess-52fP18AF.js} +1 -1
- package/dist/assets/Network-s1InxtpH.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-PSaY411C.js +1 -0
- package/dist/assets/NodeInferenceDevices-CoLAPH96.js +1 -0
- package/dist/assets/{NotificationTargets-DCtElvUz.js → NotificationTargets-BYTjEwxL.js} +1 -1
- package/dist/assets/Pipeline-D3jI3Huf.js +1 -0
- package/dist/assets/{Plates-Bf-xBe2z.js → Plates-BwI8RHl9.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-7obyiJDJ.js → PrivacyMaskSettings-DDk6LoXQ.js} +1 -1
- package/dist/assets/{ProviderIcon-Dn5ec0PG.js → ProviderIcon-CWyyzoZB.js} +1 -1
- package/dist/assets/{Recordings-Dft02-H7.js → Recordings-D5IKi_ba.js} +1 -1
- package/dist/assets/{ScanNetworkModal-Rg9lE9vS.js → ScanNetworkModal-B2bUhuZ1.js} +1 -1
- package/dist/assets/{Settings-Wyhgkdl2.js → Settings-DKkqVGNC.js} +1 -1
- package/dist/assets/{Showroom-xc9oNpRl.js → Showroom-ablwi-TX.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BzYJJkX0.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CCcHjOIo.js} +1 -1
- package/dist/assets/{build-cluster-graph-pFpr-a1b.js → build-cluster-graph-C1vd_7m_.js} +1 -1
- package/dist/assets/circle-check-big-GmO5fdEl.js +1 -0
- package/dist/assets/clock-OUNfpFX_.js +1 -0
- package/dist/assets/{copy-D3_V1b8c.js → copy-St-1O01R.js} +1 -1
- package/dist/assets/{debounced-invalidate-B8289fFj.js → debounced-invalidate-DlIKzA73.js} +1 -1
- package/dist/assets/{dist-Bhw1R8vS.js → dist-CYW0dAGQ.js} +1 -1
- package/dist/assets/dist-D7nNU2QV.js +7 -0
- package/dist/assets/{download-DRBnzzV8.js → download-CJ-1cdDh.js} +1 -1
- package/dist/assets/{face-bbox-DMbv2bqb.js → face-bbox-CTcnAI8I.js} +1 -1
- package/dist/assets/{hostInit-DVAMD32c.js → hostInit-D4IGCyt3.js} +1 -1
- package/dist/assets/index-BKBKdGDb.css +2 -0
- package/dist/assets/index-Cjto-EXm.js +4 -0
- package/dist/assets/{key-round-Ck0BlLku.js → key-round-LcTErOxf.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-b01246c3.js → mf-entry-bootstrap-0-c57c6485.js} +2 -2
- package/dist/assets/{pencil-BtT77pEX.js → pencil-BkXeyiDf.js} +1 -1
- package/dist/assets/{player-overlays-QWBHo29P.js → player-overlays-BfnV1C0Q.js} +1 -1
- package/dist/assets/plus-DXXZ8pd7.js +1 -0
- package/dist/assets/{radio-BW05_hyT.js → radio-CGyv3voN.js} +1 -1
- package/dist/assets/{refresh-cw-CNpUNbYp.js → refresh-cw-DC4KMLsa.js} +1 -1
- package/dist/assets/remoteEntry-CXtVdVO7.js +1 -0
- package/dist/assets/{rotate-ccw-NNRCRLfM.js → rotate-ccw-DlNmHkpr.js} +1 -1
- package/dist/assets/rotate-cw-d8IjPUYX.js +1 -0
- package/dist/assets/search-DkClo4ZA.js +1 -0
- package/dist/assets/{send-Dg4BnyPy.js → send-CeJ2J9V3.js} +1 -1
- package/dist/assets/{server-DGvm2Yhg.js → server-CArIZ-KL.js} +1 -1
- package/dist/assets/square-BFjZ9GUs.js +1 -0
- package/dist/assets/{square-check-big-yVkG_6n8.js → square-check-big--y441eG8.js} +1 -1
- package/dist/assets/src-CCZM6rtM.js +7 -0
- package/dist/assets/src-CfZUxvPx.js +67 -0
- package/dist/assets/{upload-CYyYTPKF.js → upload-D6H_84gF.js} +1 -1
- package/dist/assets/{useEventInvalidation-BLqZqkUr.js → useEventInvalidation-DxjiYIcd.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B2mPipaU.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-zgU2Aw4J.js} +2 -2
- package/dist/assets/{wifi-DnJudwD3.js → wifi-B0toFYT9.js} +1 -1
- package/dist/assets/{zap-BfS-dLf9.js → zap-d6IKZFEN.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +128 -33
- package/package.json +1 -1
- package/dist/assets/Addons-Cse26rBh.js +0 -1
- package/dist/assets/DeviceDetail-C8hpQWzm.js +0 -2
- package/dist/assets/Identity-CEdFWuZM.js +0 -1
- package/dist/assets/Network-CffBO4S5.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-MlyYe60u.js +0 -1
- package/dist/assets/Pipeline-DhPbloot.js +0 -1
- package/dist/assets/circle-check-big-BZqYU7ME.js +0 -1
- package/dist/assets/clock-FEgXpSrj.js +0 -1
- package/dist/assets/dist-CGJaNSH2.js +0 -7
- package/dist/assets/index-Cmef4Jek.css +0 -2
- package/dist/assets/index-DCWyP9SY.js +0 -4
- package/dist/assets/plus-KUJYci_9.js +0 -1
- package/dist/assets/remoteEntry-C9xa2tPo.js +0 -1
- package/dist/assets/rotate-cw-XFiHXxEb.js +0 -1
- package/dist/assets/search-By_XOQoF.js +0 -1
- package/dist/assets/square-CDRKBQqh.js +0 -1
- package/dist/assets/src-Ck8eP0y_.js +0 -7
- package/dist/assets/src-aCTgvsel.js +0 -67
- package/dist/assets/useDevice-D5MwztfZ.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$r as e,Ai as t,Ba as n,Ci as r,Eo as i,Fa as a,Ga as o,Ha as s,Ja as c,Ka as l,Mi as u,Pi as d,Qr as f,Si as p,T as m,Ti as h,Va as g,Vr as _,Ya as v,_ as y,_i as b,bi as x,ci as S,di as C,ei as w,ft as T,g as E,gi as D,ii as O,ji as k,li as A,lt as j,ni as ee,oi as te,pi as M,ri as ne,si as N,ti as re,ui as ie,ut as P,vi as ae,vo as oe,wi as se,wo as ce,xi as le,yi as ue,za as de}from"./src-aCTgvsel.js";import{I as fe,K as pe,Q as F,S as I,T as me,W as L,a as he,b as R,o as z,q as B,x as V,z as H}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{G as ge,K as _e,X as ve}from"./src-Ck8eP0y_.js";import{p as ye}from"./player-overlays-QWBHo29P.js";import{t as be}from"./download-DRBnzzV8.js";import{i as xe}from"./AddLocationWizard-DloYiu2S.js";import{n as Se,r as Ce,t as we}from"./zap-BfS-dLf9.js";import{i as Te,r as Ee}from"./useDevice-D5MwztfZ.js";import{t as De}from"./pencil-BtT77pEX.js";import{t as Oe}from"./plus-KUJYci_9.js";import{t as ke}from"./radio-BW05_hyT.js";import{t as Ae}from"./refresh-cw-CNpUNbYp.js";import{t as je}from"./search-By_XOQoF.js";import{t as Me}from"./server-DGvm2Yhg.js";import{t as Ne}from"./square-check-big-yVkG_6n8.js";import{t as Pe}from"./square-CDRKBQqh.js";import{E as Fe,I as Ie,J as Le,L as Re,M as ze,N as Be,P as Ve,S as U,T as He,W,i as Ue,j as G,o as We,s as Ge,x as Ke}from"./index-DCWyP9SY.js";import{t as qe}from"./AdminPage-BwmGKnRf.js";import{t as K}from"./useEventInvalidation-BLqZqkUr.js";import{r as Je,t as Ye}from"./build-cluster-graph-pFpr-a1b.js";import{n as Xe}from"./format-size-CO9d3C3-.js";import{t as Ze}from"./NodeAddonsSettingsPanel-MlyYe60u.js";import{n as Qe,t as $e}from"./ClusterRecordingTab-C8mgxr8n.js";var et=W(`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`}]]),tt=W(`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`}]]),nt=W(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),rt=W(`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`}]]);F();function it(e){return e}function at(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ot(e,t){return typeof e==`boolean`?e:it(t)}function st(e,t){return{pipeline:ot(at(e,`detect`),t),audio:ot(at(e,`audio`),t),ingest:ot(at(e,`ingest`),t)}}function ct(e,t,n){let r=e?.find(e=>e.nodeId===t);return st(r?.settings,n)}function lt({selectedNodeId:e,onSelect:t,refreshToken:n}){let{data:r}=_(void 0),{data:a}=D(void 0),{data:o}=b(void 0),s=new Map;for(let e of a??[])s.set(e.agentNodeId,(s.get(e.agentNodeId)??0)+1);let c=r??[],l=c.filter(e=>e.isOnline).length,u=c.filter(e=>!e.isOnline).length;return I(`div`,{className:`flex flex-col h-full`,children:[I(`button`,{type:`button`,onClick:()=>t(xr),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:[V(He,{className:`h-4 w-4 flex-shrink-0`}),I(`div`,{className:`min-w-0 flex-1`,children:[V(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),V(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),V(`div`,{className:`flex-1 overflow-y-auto`,children:c.map(n=>{let r=e===n.id,a=s.get(n.id)??0,c=n.isHub?Me:G,l=ct(o,n.id,n.isHub),u=n.isOnline?null:i(Je(n.lastSeen));return I(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${r?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[V(c,{className:`h-4 w-4 flex-shrink-0`}),I(`div`,{className:`min-w-0 flex-1`,children:[I(`div`,{className:`flex items-center gap-2`,children:[V(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&V(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!n.isOnline&&V(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&V(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),I(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[I(`span`,{children:[n.cpuCores,` cores`]}),V(`span`,{children:`•`}),I(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),a>0&&I(R,{children:[V(`span`,{children:`•`}),I(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[V(Se,{className:`h-2.5 w-2.5`}),a]})]}),!n.isOnline&&I(R,{children:[V(`span`,{children:`•`}),I(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),I(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[V(oe,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),V(oe,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},n.id)})}),I(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[I(`span`,{children:[l,` online`]}),u>0&&I(`span`,{className:`text-destructive`,children:[u,` offline`]})]})]})}function ut({nodeId:e,refreshToken:t}){let{data:r}=_(void 0),i=r?.find(t=>t.id===e),a=n(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?I(`div`,{className:`px-6 py-4 border-b border-border`,children:[I(`div`,{className:`flex items-center gap-2 mb-1`,children:[V(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?V(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):V(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),i.isHub&&V(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),I(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[V(`span`,{children:i.cpuModel??`CPU`}),V(`span`,{children:`•`}),I(`span`,{children:[i.cpuCores,` cores`]}),V(`span`,{children:`•`}),I(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),a&&I(R,{children:[V(`span`,{children:`•`}),I(`span`,{children:[a.attachedCameras,` cameras (`,a.activeCameras,` active)`]}),V(`span`,{children:`•`}),I(`span`,{children:[a.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),V(`span`,{children:`•`}),I(`span`,{children:[`queue `,a.queueDepthTotal]}),a.hardware.hasGpu&&I(R,{children:[V(`span`,{children:`•`}),V(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):V(`div`,{className:`px-6 py-4 border-b border-border`,children:I(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function dt({refreshToken:e,nodeId:t}){let[n,r]=B(new Map),{nodes:i}=de();s(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:a}=C(void 0),o=L(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),c=L(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),l=L(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),u=L(()=>{let e=0,t=0,n=0,r=0,a=0;for(let i of c.values())e+=i.attachedCameras,t+=i.activeCameras,n+=i.totalFps,r+=i.totalInferenceWeighted,a+=i.queueDepth;let o=e>0?r/e:0;return{totalAgents:i.length,onlineAgents:i.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:a,totalFps:n}},[c,i]);if(t){let e=c.get(t);return I(`div`,{className:`@container/liveload`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),I(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[V(q,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),V(q,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),V(q,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),V(q,{label:`Queue`,value:e?String(e.queueDepth):`—`}),V(q,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let d=[...c.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return I(`div`,{className:`@container/liveload`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),I(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[V(q,{label:`Total agents`,value:`${u.onlineAgents}/${u.totalAgents}`}),V(q,{label:`Active / Attached`,value:`${u.activeCameras}/${u.attachedCameras}`}),V(q,{label:`Total FPS`,value:u.totalFps.toFixed(1)}),V(q,{label:`Avg inference ms`,value:u.avgInferenceTimeMs.toFixed(0)}),V(q,{label:`Queue depth`,value:String(u.queueDepth)})]}),V(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:I(`table`,{className:`w-full text-xs min-w-[480px]`,children:[V(`thead`,{className:`bg-surface`,children:I(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[V(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),V(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),V(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),V(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),V(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),V(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),I(`tbody`,{children:[d.map(([e,t])=>I(`tr`,{className:`border-t border-border`,children:[V(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:l.get(e)??e}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),d.length===0&&V(`tr`,{children:V(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function q({label:e,value:t}){return I(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[V(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),V(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}F();var ft={active:!1,pinned:!1,nodeId:null,reason:``},pt=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],mt={pipeline:G,decoder:Fe,audio:Ce},ht={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function gt({mode:e,nodeId:n,compact:r=!1}){if(e===`agent`&&!n)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let i=z(),[a,o]=B(null),[c,l]=B(null),[u,d]=B(new Map);K([`pipelineOrchestrator`,`getPipelineAssignments`],pt),K([`pipelineOrchestrator`,`getAudioAssignments`],pt),K([`pipelineOrchestrator`,`getCameraStatuses`],pt);let{data:f}=D(void 0),{data:p}=ie(void 0),{data:h}=M({},{enabled:e===`agent`}),{nodes:g}=de(),{data:_}=Ee();s(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&d(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),H(()=>{if(u.size===0)return;let e=setInterval(()=>{d(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)},[u.size]);let v=L(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),y=L(()=>{if(e===`agent`){let e=[];for(let t of h??[]){let r=t.assignment,i=(e,t,r)=>({active:e!==null&&e===n,pinned:t,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:t.deviceId,deviceName:v.get(t.deviceId)??`Device ${t.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let t=new Map,r=e=>{let n=t.get(e);if(n)return n;let r={deviceId:e,deviceName:v.get(e)??`Device ${e}`,pipeline:ft,decoder:ft,audio:ft};return t.set(e,r),r};for(let i of f??[]){let a=r(i.deviceId);t.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===n,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of p??[]){let n=r(e.deviceId);t.set(e.deviceId,{...n,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...t.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[f,p,h,v,e,n]),b=L(()=>(g??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[g]),x=()=>{i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),i.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},S=N({onSuccess:x}),C=k({onSuccess:x}),w=te({onSuccess:x}),T=t({onSuccess:x}),E=(e,t,n)=>{t===`pipeline`?S.mutate({deviceId:e,agentNodeId:n}):w.mutate({deviceId:e,nodeId:n}),o(null)},O=(e,t)=>{t===`pipeline`?C.mutate({deviceId:e}):T.mutate({deviceId:e}),o(null)};return V(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:I(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[V(`thead`,{className:`bg-surface`,children:I(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!r&&V(`th`,{className:`w-10`}),V(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?I(R,{children:[V(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),V(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):I(R,{children:[V(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),V(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),V(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),V(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),I(`tbody`,{children:[y.map(t=>{let n=u.get(t.deviceId),i=c===t.deviceId;return I(me.Fragment,{children:[I(`tr`,{className:`border-t border-border align-middle relative`,children:[!r&&V(`td`,{className:`px-2 py-2 align-middle`,children:V(`button`,{type:`button`,onClick:()=>l(i?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":i?`Collapse broker details`:`Expand broker details`,children:V(i?Ie:Ve,{className:`h-3.5 w-3.5`})})}),I(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[V(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),I(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?I(R,{children:[V(`td`,{className:`px-3 py-2 align-middle`,children:V(_t,{state:t.pipeline,onlineNodes:b,pending:S.isPending||C.isPending,onChange:e=>{e===`auto`?O(t.deviceId,`pipeline`):E(t.deviceId,`pipeline`,e)}})}),V(`td`,{className:`px-3 py-2 align-middle`,children:V(vt,{state:t.pipeline})})]}):I(R,{children:[V(yt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:a?.deviceId===t.deviceId&&a.role===`pipeline`,onToggleMenu:()=>o(a?.deviceId===t.deviceId&&a.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>o(null),onMove:e=>E(t.deviceId,`pipeline`,e),onUnpin:()=>O(t.deviceId,`pipeline`)}),V(yt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:b,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),V(yt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:a?.deviceId===t.deviceId&&a.role===`audio`,onToggleMenu:()=>o(a?.deviceId===t.deviceId&&a.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>o(null),onMove:e=>E(t.deviceId,`audio`,e),onUnpin:()=>O(t.deviceId,`audio`)})]}),V(`td`,{className:`px-3 py-2 align-middle`,children:V(Ct,{snap:n})})]}),i&&!r&&I(`tr`,{className:`bg-surface/50`,children:[V(`td`,{}),V(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2`,children:V(m,{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)}),y.length===0&&V(`tr`,{children:V(`td`,{colSpan:r?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 _t({state:e,onlineNodes:t,pending:n,onChange:r}){let i=e.pinned&&e.nodeId?e.nodeId:`auto`,a=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return I(`select`,{value:i,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(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:[V(`option`,{value:`auto`,children:`Auto`}),a.map(e=>I(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function vt({state:e}){if(!e.active||!e.nodeId)return V(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let t=e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`;return I(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[V(`span`,{className:`font-mono text-[11px] text-foreground truncate`,title:e.nodeId,children:e.nodeId}),V(`span`,{className:`truncate ${e.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:t,children:t})]})}function yt({role:e,state:t,mode:n,onlineNodes:r,readOnly:i=!1,isMenuOpen:a,onToggleMenu:o,onCloseMenu:s,onMove:c,onUnpin:l}){let u=mt[e],d=r.filter(e=>e.id!==(t.nodeId??``)),f=!i&&(t.active||n===`cluster`)&&(d.length>0||t.pinned);return I(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[I(`div`,{className:`flex items-center gap-2 min-w-0`,children:[V(n===`agent`?bt:xt,{state:t,Icon:u}),V(`div`,{className:`ml-auto shrink-0`,children:f&&V(`button`,{type:`button`,onClick:o,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${ht[e]} actions`,children:V(et,{className:`h-3 w-3 text-foreground-subtle`})})})]}),a&&f&&V(wt,{title:ht[e],targets:d,pinned:t.pinned,onMove:c,onUnpin:l,onClose:s})]})}function bt({state:e,Icon:t}){return I(`div`,{className:`flex items-center gap-1.5`,children:[V(e.active?Ne:Pe,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),V(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&V(rt,{className:`h-2.5 w-2.5 text-amber-400`})]})}function xt({state:e,Icon:t}){return!e.active||!e.nodeId?I(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[V(t,{className:`h-3 w-3`}),V(`span`,{className:`text-[10px] italic`,children:`—`})]}):I(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[V(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),I(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[V(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),V(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?I(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[V(rt,{className:`h-2.5 w-2.5`}),` manual`]}):I(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var St=`min-h-[3.25rem]`;function Ct({snap:e}){if(!e)return V(`div`,{className:`flex items-center ${St}`,children:V(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:i,configuredFps:a,droppedFrames:o}=e.metrics,s=ce(t);return I(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${St}`,children:[I(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${s.textColor}`,children:[V(y,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),V(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:s.label})]}),I(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[V(`span`,{className:`text-foreground`,children:n.toFixed(1)}),I(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),I(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[V(`span`,{className:`text-foreground`,children:r.toFixed(0)}),V(`span`,{children:` ms`}),i>0&&I(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]}),I(`span`,{className:`whitespace-nowrap truncate ${o>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,V(`span`,{className:`text-foreground`,children:o})]})]})}function wt({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=pe(null);return H(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),I(`div`,{ref:o,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[V(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&V(`div`,{className:`py-1`,children:t.map(e=>I(`button`,{type:`button`,onClick:()=>r(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))}),n&&I(`button`,{type:`button`,onClick:i,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 `,e.toLowerCase()]}),t.length===0&&!n&&V(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Tt({nodeId:e,refreshToken:t}){return I(`div`,{className:`space-y-6`,children:[V(dt,{refreshToken:t,nodeId:e}),I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),I(`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.`]})]}),V(gt,{mode:`agent`,nodeId:e,compact:!0})]})}F();function Et(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Dt({nodeId:e,refreshToken:t}){let r=z(),i=ne({onSettled:()=>{r.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:a}=O({nodeId:e}),o=n(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??a??null,s=o===null;K([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:c}=d({nodeId:e}),{values:l}=g(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),u=L(()=>l.filter(e=>e.metrics.phase===`active`).length,[l]),f=t=>{let n=c??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||i.mutate({nodeId:e,engine:t,force:n.length>0})};return I(`div`,{className:`space-y-6`,children:[I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),I(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(o??[]).length,` engine(s) resident in RAM. `,(c??[]).length,` `,`camera(s) attached, `,u,` actively dispatching frames. Refreshes every 5s.`]})]}),V(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:I(`table`,{className:`w-full text-xs min-w-[640px]`,children:[V(`thead`,{className:`bg-surface`,children:I(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[V(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),V(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),V(`th`,{className:`text-left px-3 py-2`,children:`Models`}),V(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),V(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),V(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),V(`th`,{className:`w-20`})]})}),I(`tbody`,{children:[s&&V(`tr`,{children:V(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!s&&(o??[]).map(e=>{let t=e.kind===`warm-override`;return I(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:``}`,children:[V(`td`,{className:`px-3 py-2`,children:I(`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`:`bg-success/15 text-success`}`,children:[V(t?tt:G,{className:`h-3 w-3`}),t?`warm`:`runtime`]})}),V(`td`,{className:`px-3 py-2`,children:I(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[V(we,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),V(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?V(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):V(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>V(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),V(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),V(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?V(`span`,{className:`text-foreground-subtle`,children:Et(e.idleMs,e.idleTtlMs)}):V(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),V(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(c??[]).length}),V(`td`,{className:`px-3 py-2 text-right`,children:I(`button`,{type:`button`,disabled:i.isPending,onClick:()=>f(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:[V(Ge,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!s&&(o??[]).length===0&&V(`tr`,{children:V(`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.`})})]})]})}),I(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[V(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,V(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`]}),i.isError&&I(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,i.error instanceof Error?i.error.message:`unknown`]})]})}F();var Ot=new Set(ve);function kt(e){return Ot.has(e)}function At(e,t,n){return`${e}/${t}/${n}`}function jt(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Mt(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function J(e){return e.format}function Nt(e,t){let n=0,r=0,i=0;for(let a of e)for(let e of a.addons)for(let a of e.models){let e=a.formats[t];e&&(n++,e.downloaded&&(r++,i+=e.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:i}}function Pt({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?I(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[V(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),I(`div`,{className:`flex-1 min-w-0`,children:[I(`div`,{className:`flex items-center gap-2`,children:[V(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),I(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&I(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[V(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:V(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),I(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),V(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:Xe(c.sizeMB)}),a&&I(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[V(Be,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?I(`button`,{onClick:s,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[r?V(U,{className:`h-3 w-3 animate-spin`}):V(Ge,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):I(`button`,{onClick:o,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[r?V(U,{className:`h-3 w-3 animate-spin`}):V(be,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function Ft({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=B(!1);return I(`div`,{className:`relative`,children:[I(`button`,{type:`button`,onClick:()=>a(!i),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[V(G,{className:`h-4 w-4 text-primary shrink-0`}),I(`div`,{className:`flex-1 min-w-0`,children:[I(`div`,{className:`flex items-center gap-2`,children:[V(`span`,{className:`text-sm font-medium text-foreground`,children:jt(n)}),J(n)===J(t)&&V(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),V(`div`,{className:`text-[10px] text-foreground-subtle`,children:Mt(n)})]}),V(Ie,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&V(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=J(e)===J(n),o=J(e)===J(t);return I(`button`,{type:`button`,onClick:()=>{r(e),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${i?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[V(G,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),I(`div`,{className:`flex-1`,children:[I(`div`,{className:`flex items-center gap-2`,children:[V(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:jt(e)}),o&&V(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),V(`div`,{className:`text-[10px] text-foreground-subtle`,children:Mt(e)})]}),i&&V(ze,{className:`h-4 w-4 text-primary shrink-0`})]},J(e))})})]})}function It({embedded:t=!1,nodeId:n}={}){let r=z(),i=n??`hub`,[a,o]=B(null),[c,l]=B(new Set),[u,d]=B(new Map),[p,m]=B(new Map),[h,g]=B(``),{data:_=[]}=w({nodeId:i}),v=_.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:y}=ee({nodeId:i}),b=y,{data:x,isLoading:S}=re({nodeId:i}),C=e(),T=f();s(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,i=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||i===void 0||(d(e=>{let t=new Map(e);return i===100||i===-1?t.delete(n):t.set(n,{modelId:n,progress:i,totalMB:a}),t}),i===100&&r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let E=b??{runtime:`node`,backend:`cpu`,format:`onnx`},D=v.find(e=>e.format===a)??E,O=D.format,k=x?.slots??[],A=k.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[O]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),j=Nt(A,O),te=fe(async(e,t,n)=>{if(!kt(n))return;let a=At(e,t,n);l(e=>new Set([...e,a])),m(e=>{let t=new Map(e);return t.delete(a),t});try{await C.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){m(t=>new Map([...t,[a,e instanceof Error?e.message:`Download failed`]]))}finally{l(e=>{let t=new Set(e);return t.delete(a),t})}},[C,r,i]),M=fe(async(e,t,n)=>{if(!kt(n))return;let a=At(e,t,n);l(e=>new Set([...e,a])),m(e=>{let t=new Map(e);return t.delete(a),t});try{await T.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){m(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{l(e=>{let t=new Set(e);return t.delete(a),t})}},[T,r,i]),ne=fe(e=>{o(e.format)},[]),N=h.trim()?A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(h.toLowerCase())||t.id.toLowerCase().includes(h.toLowerCase())||e.name.toLowerCase().includes(h.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):A,ie=I(R,{children:[S&&V(`div`,{className:`flex items-center justify-center py-16`,children:V(U,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!S&&k.length===0&&I(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[V(xe,{className:`h-8 w-8 mb-3 opacity-30`}),V(`span`,{className:`text-sm`,children:`No pipeline steps available`}),V(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!S&&k.length>0&&I(R,{children:[V(Ft,{engines:v,activeEngine:E,viewEngine:D,onSelect:ne}),I(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[I(`span`,{children:[V(`span`,{className:`font-semibold text-foreground tabular-nums`,children:j.total}),V(`span`,{className:`ml-1`,children:`compatible models`})]}),V(`span`,{className:`text-border`,children:`|`}),I(`span`,{children:[V(`span`,{className:`font-semibold text-success tabular-nums`,children:j.downloaded}),V(`span`,{className:`ml-1`,children:`downloaded`})]}),V(`span`,{className:`text-border`,children:`|`}),I(`span`,{className:`tabular-nums`,children:[Xe(j.downloadedSizeMB),V(`span`,{className:`ml-1`,children:`on disk`})]})]}),j.total>5&&I(`div`,{className:`relative`,children:[V(je,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),V(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),N.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+t.models.filter(e=>e.formats[O]?.downloaded).length,0);return I(`div`,{children:[I(`div`,{className:`flex items-center gap-2 mb-2`,children:[V(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),V(`div`,{className:`flex-1 h-px bg-border`}),I(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),V(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=At(e.id,t.id,O);return V(Pt,{addonId:e.id,model:t,format:O,isActive:c.has(n),progress:u.get(t.id),errorMsg:p.get(n),onDownload:()=>te(e.id,t.id,O),onDelete:()=>M(e.id,t.id,O)},`${e.id}/${t.id}`)}))})]},e.id)}),N.length===0&&V(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:h.trim()?I(R,{children:[`No models matching “`,h,`”`]}):I(R,{children:[`No models available for `,jt(D),` format`]})})]})]});return t?V(`div`,{className:`space-y-4`,children:ie}):V(qe,{children:ie})}function Lt({nodeId:e,refreshToken:t}){return V(It,{embedded:!0,nodeId:e})}var Rt=`pipeline-runner`,zt=200;function Bt({nodeId:e}){return I(`div`,{className:`flex flex-col gap-3`,children:[I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),I(`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.`]})]}),V(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:V(E,{agentId:e,addonId:Rt,limit:zt,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}F(),F();function Vt({nodeId:e,title:t}){let{data:n}=Ee(),{data:r}=D(void 0),i=L(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=L(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[o,c]=B(new Map);s(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||c(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),H(()=>{if(o.size===0)return;let e=setInterval(()=>{c(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)},[o.size]);let l=L(()=>{let e=[];for(let t of o.values())a&&!a.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[o,a]);return l.length===0?I(`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`]}):I(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[I(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[V(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),V(`span`,{className:`text-[10px] text-foreground-subtle`,children:l.length})]}),V(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=ce(e.metrics.phase);return I(`div`,{title:`${t} · ${n.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] ${n.badgeClass}`,children:[V(y,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),V(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),V(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),V(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}F();var Ht=[`pipeline-orchestrator`],Ut=[`decoder`],Wt=!1;function Gt(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 Kt({nodeId:e,refreshToken:t}){let n=z(),r=a(),[i,s]=B(null),[u,d]=B(null),[f,m]=B(null),[h,g]=B(null),y=(_(void 0).data??[]).find(t=>t.id===e)?.name??e,b=re({nodeId:e},{refetchOnMount:`always`}),S=A({agentNodeId:e},{refetchOnMount:`always`}),C=()=>{n.invalidateQueries({queryKey:[[`addonSettings`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),n.invalidateQueries({queryKey:[[`pipelineExecutor`]]})},w=p({onSuccess:C}),T=x({onSuccess:e=>{C(),g(e.effectiveModelId===null?`Reset done — model pins cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),E=async()=>{await r({title:`Reset ${y} to hardware-aware defaults?`,message:`This clears every model pin on this node (back to Auto) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(g(null),T.mutate({agentNodeId:e}))},D=b.data??null,O=S.data,k=D?.selectedEngine.format??`coreml`,j=L(()=>D?c(D):[],[D]),ee=L(()=>[{agentNodeId:e,engineLabel:k}],[e,k]),te=(e,t)=>{let n=O?.addonDefaults[e];return Gt(D,e)?.models.some(e=>!!e.formats[k])?{kind:`enabled`,modelId:n?.modelId??`Auto`}:{kind:`na`}},M=i&&D?Gt(D,i.addonId):null,ne=t=>{let n=O?.addonDefaults[t]??null;s({addonId:t,agentNodeId:e}),d(n)},N=()=>{s(null),d(null)},ie=()=>{!u||!i||!O||w.mutate({agentNodeId:e,defaults:{...O.addonDefaults,[i.addonId]:u}},{onSuccess:N})};if(b.isLoading||S.isLoading)return V(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading pipeline…`});if(b.error)return I(`div`,{className:`text-xs text-red-400`,children:[`Failed to load catalog: `,String(b.error)]});if(!D)return V(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog unavailable for this node (runner offline?).`});let P=i!==null&&M!==null&&u!==null;return I(`div`,{className:`relative h-full w-full space-y-3`,children:[I(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[h&&V(`span`,{className:`text-emerald-400`,children:h}),T.isError&&V(`span`,{className:`text-red-400`,children:T.error instanceof Error?T.error.message:`Reset failed`}),V(`button`,{type:`button`,onClick:()=>{E()},disabled:T.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 model pins (back to Auto) + per-camera overrides scoped to this node`,children:T.isPending?`Resetting…`:`Reset to default`})]}),V(Vt,{nodeId:e}),V(Ze,{nodeId:e,addonIds:Ht,level:`global`,sectionIds:Ut}),Wt,Wt,V(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Provisioning only — pick each step's model here. Per-camera on/off now lives on the device's Detection pipeline view.`}),V(`div`,{className:P?`md:pr-[360px]`:``,children:j.length>0?V(o,{tree:j,agents:ee,getCellState:te,onCellClick:ne,selectedCell:i}):V(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),I(v,{open:P,onClose:N,title:M?.name??``,subtitle:i?`${i.agentNodeId} · ${k}`:``,footer:I(R,{children:[V(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:N,children:`Cancel`}),V(`button`,{type:`button`,disabled:!u||!i||w.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:ie,children:w.isPending?`Saving…`:`Save`})]}),children:[w.isError&&I(`div`,{className:`mb-3 rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed:`,` `,w.error instanceof Error?w.error.message:String(w.error)]}),M&&u&&i&&V(l,{mode:`agent`,addon:M,agentDefault:u,agentNodeId:i.agentNodeId,engineFormat:k,onChangeAgentConfig:e=>d(e)})]})]})}var qt=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],Jt=`decoder-nodeav`;function Yt({nodeId:e,refreshToken:t}){let{data:n}=_(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??Jt,i=[...qt,r];return I(`div`,{className:`flex flex-col h-full`,children:[V(ut,{nodeId:e,refreshToken:t}),V(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:V(Ze,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:V(Tt,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:V(Kt,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:V(Dt,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:V(Lt,{nodeId:e,refreshToken:t})},{id:`logs`,label:`Logs`,order:300,content:V(Bt,{nodeId:e})}]})})]})}var Xt=`pipeline-orchestrator`,Zt=`recorder`,Qt=`recordingNodeId`,$t=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`],en=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function tn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function nn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function rn(e,t,n){let r=tn(e,t);return typeof r==`string`&&r.length>0?r:n}function an(e,t,n){let r=tn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function on(e,t){let n=nn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function sn(e,t){let n=nn(e,t);return typeof n==`string`&&n.length>0?n:null}function cn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:`Motion Node`}function ln(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 un(e,t){switch(t){case`detect`:return e.pipeline}}function dn(e){return e instanceof Error?e.message:`Failed to save`}function fn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function pn({capability:e,label:t,hint:n,nodeId:r,active:i,pending:a,layout:o,onToggle:s}){let c=i?`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`,l=o===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,u=i?Re:Te;return I(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} capability for ${r}`,title:`${t} — ${n}`,disabled:a,onClick:()=>s(e,!i),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 ${c} ${l}`,children:[V(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),V(`span`,{children:t})]})}function mn({node:e,emphasis:t=!1}){let n=e.isHub?Me:G;return I(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[V(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),V(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),I(`div`,{className:`min-w-0`,children:[I(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[V(`span`,{className:`truncate`,children:e.name}),e.isHub&&V(oe,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&V(oe,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),V(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}F();function hn({nodeId:e,value:t,detectedHosts:n,status:r,errorMessage:i,onCommit:a}){let[o,s]=B(t??``);H(()=>{s(t??``)},[t]);let c=n[0],l=c===void 0?`auto-detect`:`auto: ${c}`,u=r===`pending`,d=o.trim(),f=d!==(t??``),p=f&&!u,m=()=>{p&&a(e,d.length>0?d:null)};return I(`div`,{className:`flex items-center gap-1.5`,children:[V(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:l,value:o,disabled:u,onChange:e=>s(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&s(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`}),I(`button`,{type:`button`,onClick:m,disabled:!p,"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:[u?V(U,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):V(Re,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!f&&!u&&r===`success`&&V(Re,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),r===`error`&&V(`span`,{title:i??`Failed to save reachable host`,children:V(Be,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":i??`Failed to save reachable host`,role:`img`})})]})}function gn({label:e,children:t}){return I(`div`,{className:`flex items-center justify-between gap-3`,children:[V(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function _n({node:e,actions:t}){return I(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[V(mn,{node:e,emphasis:!0}),V(`div`,{className:`grid grid-cols-2 gap-2`,children:en.map(n=>V(pn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:un(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),V(`div`,{className:`space-y-3 border-t border-border pt-3`,children:V(gn,{label:`Reachable host`,children:V(hn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function vn(){return I(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[I(`span`,{className:`inline-flex items-center gap-1.5`,children:[V(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),I(`span`,{className:`inline-flex items-center gap-1.5`,children:[V(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),I(`span`,{className:`inline-flex items-center gap-1.5`,children:[V(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),I(`span`,{className:`inline-flex items-center gap-1.5`,children:[V(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function yn({nodes:e,actions:t}){return V(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:I(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[V(`thead`,{children:I(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[V(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),en.map(e=>V(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),V(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),V(`tbody`,{children:e.map(e=>I(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[V(`td`,{className:`px-4 py-3 align-middle`,children:V(mn,{node:e})}),en.map(n=>V(`td`,{className:`px-3 py-3 text-center align-middle`,children:V(pn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:un(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),V(`td`,{className:`px-4 py-3 align-middle`,children:V(hn,{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 bn({role:e,value:t,options:n,pending:r,onChange:i}){return I(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[V(`span`,{className:`text-xs font-semibold text-foreground`,children:cn(e)}),V(`select`,{value:t,disabled:r,onChange:t=>i(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:n.map(e=>V(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),V(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:ln(e)})]})}function xn({roleValues:e,options:t,pending:n,lowFpsEnabled:r,fpsMinThreshold:i,onRoleChange:a,onLowFpsToggle:o}){return I(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[$t.map(r=>V(bn,{role:r,value:e[r],options:t,pending:n,onChange:a},r)),I(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[V(`input`,{type:`checkbox`,checked:r,disabled:n,onChange:e=>o(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),I(`span`,{className:`flex flex-col gap-0.5`,children:[V(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),I(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,r?`${i} fps`:`disabled`]})]})]})]})}F();function Sn(e,t,n){return Math.min(Math.max(e,t),n)}function Cn(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function wn(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:Sn(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function Tn(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function En({nodes:e,pending:t,onCommitWeights:n}){let[r,i]=B(()=>Cn(e)),[a,o]=B(new Set);H(()=>{i(Cn(e)),o(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let s=e.map(e=>e.id),c=e=>{o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},l=(e,t)=>{i(n=>wn(n,e,t,a,s))},u=()=>{let t=Tn(r,s,a),i=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(i.length===0)return;let o=new Set([...i,...a]);n(e.filter(e=>o.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return V(`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-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`});let d=e.length===1;return I(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=r[e.id]??0,i=a.has(e.id);return I(`div`,{className:`flex items-center gap-3`,children:[V(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),V(`input`,{"aria-label":`Detection weight for ${e.name}`,type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:t||i||d,onChange:t=>l(e.id,Number(t.target.value)),onPointerUp:()=>u(),onKeyUp:()=>u(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),I(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),V(`button`,{type:`button`,onClick:()=>c(e.id),disabled:t||d,"aria-pressed":i,title:i?`Unlock — allow rebalancing`:`Lock this share when others change`,className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${i?`text-amber-400`:`text-foreground-subtle`}`,children:V(i?Ke:nt,{className:`h-3.5 w-3.5`})})]},e.id)}),V(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`})]})}F();function Dn(){let e=z(),{nodes:t}=de(),n=b(void 0),i=P({addonId:Xt}),a=P({addonId:Zt}),o=()=>fn(e),s=r({onSuccess:o}),c=se(),l=h({onSuccess:o}),u=T({onSuccess:o}),[d,f]=B(!1),p=L(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),m=L(()=>t.map(e=>{let t=p.get(e.id),n=st(t,e.isHub),r=on(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:on(t,`maxCameras`),reachableHost:sn(t,`reachableHost`),detectedHosts:e.localIps}}),[t,p]),g=m.filter(e=>e.effective.pipeline),_={ingestNode:rn(i.data,`ingestNode`,`hub`),recordingNode:rn(a.data,Qt,`hub`),audioNode:rn(i.data,`audioNode`,`hub`),motionNode:rn(i.data,`motionNode`,`hub`)},v=L(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...$t.map(e=>_[e]),...e])].filter(e=>e.length>0)},[t,_]),y=an(i.data,`fpsMinThreshold`,0),x=y>0,S=n.isLoading||i.isLoading||a.isLoading,C=(e,t,n)=>{s.mutate({agentNodeId:e,[t]:n})},w=(e,t)=>{if(e===`recordingNode`){u.mutate({addonId:Zt,patch:{[Qt]:t}});return}u.mutate({addonId:Xt,patch:{[e]:t}})},E=e=>{u.mutate({addonId:Xt,patch:{fpsMinThreshold:e?Math.max(1,y):0}})},D=e=>l.variables?.agentNodeId===e?l.isPending?`pending`:l.isError?`error`:l.isSuccess?`success`:`idle`:`idle`,O=e=>D(e)===`error`?dn(l.error):null,k=async e=>{f(!0);try{for(let t of e)await c.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{f(!1),o()}},A={capabilityPending:s.isPending,onToggleCapability:C,onCommitReachableHost:(e,t)=>l.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:D,reachableHostErrorMessage:O};return I(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[I(`header`,{className:`flex items-start justify-between gap-4`,children:[I(`div`,{className:`space-y-1`,children:[V(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),V(`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.`})]}),S&&V(U,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),I(`div`,{className:`space-y-3`,children:[V(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),V(xn,{roleValues:_,options:v,pending:u.isPending,lowFpsEnabled:x,fpsMinThreshold:y,onRoleChange:w,onLowFpsToggle:E})]}),I(`div`,{className:`space-y-3`,children:[I(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[V(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),V(vn,{})]}),m.length===0?V(`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.`}):I(R,{children:[V(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:m.map(e=>V(_n,{node:e,actions:A},e.id))}),V(`div`,{className:`hidden @3xl/clustertab:block`,children:V(yn,{nodes:m,actions:A})})]})]}),I(`div`,{className:`space-y-3`,children:[V(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),V(En,{nodes:g,pending:d,onCommitWeights:e=>void k(e)})]})]})}F();var On=!1;function kn({refreshToken:e}){let t=z(),{data:n}=_(void 0);L(()=>Ye(n??[]),[n]);let r=ue({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return I(`div`,{className:`space-y-6`,children:[V(dt,{refreshToken:e}),V(Dn,{}),On,I(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[I(`div`,{className:`min-w-0`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),V(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Click the kebab to pin / unpin / move a role; expand the chevron for the per-camera broker drill-down.`})]}),I(`button`,{type:`button`,onClick:()=>r.mutate(void 0),disabled:r.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:[V(we,{className:`h-3.5 w-3.5`}),r.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),V(gt,{mode:`cluster`})]})}var An=[`pipeline-orchestrator`];function jn({refreshToken:e}){return V(`div`,{className:`space-y-4 max-w-3xl`,children:V(Ze,{nodeId:`hub`,addonIds:An,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})})}F();function Mn({refreshToken:e}){let t=z(),{data:n,isLoading:r}=ae(),[i,a]=B(null),[o,s]=B(``),[c,l]=B(``),d=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},f=u({onSuccess:()=>{a(null),d()}}),p=S({onSuccess:d}),m=e=>{a(e.id),s(e.name),l(e.description??``)},h=()=>{a(null),s(``),l(``)},g=()=>{if(!i)return;let e=c.trim();f.mutate({id:i,name:o.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return V(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return V(`div`,{className:`space-y-6 max-w-4xl`,children:I(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[I(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),V(`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.`})]}),I(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?I(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[V(Oe,{className:`h-6 w-6 opacity-40`}),V(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):V(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return V(`li`,{className:`px-4 py-3 text-xs`,children:I(`div`,{className:`flex items-start gap-3`,children:[V(`div`,{className:`flex-1 min-w-0`,children:t?I(`div`,{className:`space-y-2`,children:[V(`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:o,onChange:e=>s(e.target.value),placeholder:`Template name`,autoFocus:!0}),V(`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:c,onChange:e=>l(e.target.value),placeholder:`Description (optional)`})]}):I(R,{children:[V(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&V(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),I(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,I(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),V(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?I(R,{children:[I(`button`,{type:`button`,onClick:g,disabled:f.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:[V(Re,{className:`h-3 w-3`}),`Save`]}),I(`button`,{type:`button`,onClick:h,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[V(Ue,{className:`h-3 w-3`}),`Cancel`]})]}):I(R,{children:[V(`button`,{type:`button`,onClick:()=>m(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:V(De,{className:`h-3 w-3`})}),V(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&p.mutate({id:e.id})},disabled:p.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:V(Ge,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}F();function Nn(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 Pn({nodeId:e,refreshToken:t}){let n=z(),r=ye().trpcClient,[i,a]=B(null),[s,u]=B(null),d=b(void 0,{refetchOnMount:`always`});K([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`,`addon.updated`]);let f=_(void 0,{refetchOnMount:`always`}),m=L(()=>{let e=new Set;for(let t of f.data??[])t.isOnline&&e.add(t.id);return e},[f.data]),h=re({nodeId:e},{refetchOnMount:`always`}),g=L(()=>(d.data??[]).filter(e=>m.has(e.nodeId)).map(e=>e.nodeId),[d.data,m]),y=he({enabled:g.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`schema-by-agent`,g.join(`,`),t],queryFn:async()=>{let e={};for(let t of g)try{e[t]=(await r.pipelineExecutor.getSchema.query({nodeId:t})).selectedEngine.format}catch{e[t]=`coreml`}return e}}),x=p({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),n.invalidateQueries({queryKey:[[`pipelineExecutor`]]}),n.invalidateQueries({queryKey:[[`addonSettings`]]})}}),S=L(()=>h.data?c(h.data):[],[h.data]),C=L(()=>{let e=d.data??[],t=m;return(t.size===0?[]:e.filter(e=>t.has(e.nodeId))).map(e=>{let t=y.data?.[e.nodeId];return{agentNodeId:e.nodeId,engineLabel:t??`(engine unknown)`}})},[d.data,y.data,m]),w=(e,t)=>{let n=(d.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e],r=y.data?.[t];return Nn(h.data??null,e)?.models.some(e=>r!==void 0&&!!e.formats[r])?{kind:`enabled`,modelId:n?.modelId??`Auto`}:{kind:`na`}},T=i?d.data?.find(e=>e.nodeId===i.agentNodeId)??null:null,E=i&&h.data?Nn(h.data,i.addonId):null,D=i?y.data?.[i.agentNodeId]??`coreml`:`coreml`,O=()=>{a(null),u(null)},k=(e,t)=>{let n=(d.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e]??null;a({addonId:e,agentNodeId:t}),u(n)},A=()=>{!s||!i||!T||x.mutate({agentNodeId:i.agentNodeId,defaults:{...T.settings.addonDefaults,[i.addonId]:s}},{onSuccess:O})};if(d.isLoading||h.isLoading)return V(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading agents…`});if(!h.data)return I(`div`,{className:`text-xs text-foreground-subtle`,children:[`Catalog unavailable for `,e,`.`]});let j=i!==null&&E!==null&&s!==null;return I(`div`,{className:`relative h-full w-full space-y-3`,children:[V(Vt,{title:`Cluster cameras`}),V(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Provisioning only — each cell is the model a node runs for that step. Per-camera on/off now lives on the device's Detection pipeline view.`}),V(`div`,{className:j?`md:pr-[360px]`:``,children:S.length>0&&C.length>0?V(o,{tree:S,agents:C,getCellState:w,onCellClick:k,selectedCell:i}):V(`div`,{className:`text-xs text-foreground-subtle`,children:`No agents or catalog empty.`})}),I(v,{open:j,onClose:O,title:E?.name??``,subtitle:i?`${i.agentNodeId} · ${D}`:``,footer:I(R,{children:[V(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:O,children:`Cancel`}),V(`button`,{type:`button`,disabled:!s||!i||x.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:A,children:x.isPending?`Saving…`:`Save`})]}),children:[x.isError&&I(`div`,{className:`mb-3 rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed:`,` `,x.error instanceof Error?x.error.message:String(x.error)]}),E&&s&&i&&V(l,{mode:`agent`,addon:E,agentDefault:s,agentNodeId:i.agentNodeId,engineFormat:D,onChangeAgentConfig:e=>u(e)})]})]})}F();var Fn=`pipeline-analytics`;function In(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Ln(){let e=z(),{data:t}=_(void 0),{data:n,isLoading:r}=P({addonId:Fn}),i=In(n),a=T({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),o=L(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return I(`div`,{className:`flex flex-col gap-6`,children:[I(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[V(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),V(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),I(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?V(U,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):V(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:Fn,patch:{postProcessingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:o.map(e=>V(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&V(U,{className:`h-4 w-4 animate-spin text-primary`})]})]}),I(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[V(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),V(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),V(Qe,{types:[`eventMedia`]})]})]})}var Rn=`pipeline-orchestrator`,zn=200;function Bn(){return I(`div`,{className:`flex flex-col gap-3`,children:[I(`div`,{children:[V(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),V(`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.`})]}),V(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:V(E,{addonId:Rn,limit:zn,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}F();var Vn=[{id:`assignments`,label:`Assignments`},{id:`pipeline`,label:`Pipeline`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function Hn({refreshToken:e}){let[t,n]=B(`assignments`),{data:r}=_(void 0),i=r?.find(e=>e.isHub&&e.isOnline)?.id??r?.find(e=>e.isOnline)?.id??null;return I(`div`,{className:`flex flex-col h-full`,children:[I(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[V(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),V(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),V(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Vn.map(e=>V(`button`,{type:`button`,onClick:()=>n(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))}),I(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&V(kn,{refreshToken:e}),t===`pipeline`&&(i?V(Pn,{nodeId:i,refreshToken:e}):V(`div`,{className:`text-xs text-foreground-subtle`,children:`No online node available — schema unreachable.`})),t===`events`&&V(Ln,{}),t===`recording`&&V($e,{}),t===`settings`&&V(jn,{refreshToken:e}),t===`templates`&&V(Mn,{refreshToken:e}),t===`logs`&&V(Bn,{})]})]})}function Un(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&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});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 Wn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Gn(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Kn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function qn(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var Jn={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 Yn(e){if(!Wn(e)||!Array.isArray(e.sections))return Jn;let t=ge(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)qn(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Gn(n(`detectionFps`)),motionSources:Kn(n(`motionSources`)),motionFps:Gn(n(`motionFps`)),motionCooldownMs:Gn(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 Xn(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(...Xn(r.children,t+1));return n}function Zn(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function X({title:e,children:t}){return I(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[V(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),V(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return I(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[V(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),V(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&V(Qn,{})]})}function Qn(){return V(`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 $n={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 V(`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 ${$n[e]}`,children:t})}function $({children:e}){return V(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function er({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){return I(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[V(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),V(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?V(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):I(R,{children:[V(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?I(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[V(rt,{className:`h-2.5 w-2.5`}),` manual`]}):I(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,i!==void 0&&i.length>0?i:`capacity`]}),a&&V(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function tr({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let a=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,o=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return I(X,{title:`Where it runs`,children:[V(er,{icon:G,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),V(er,{icon:Fe,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),V(er,{icon:Ce,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),V(er,{icon:ke,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),V(`div`,{className:`mt-1.5`,children:I(`select`,{value:a,disabled:r,"aria-label":`Detection 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-[11px] text-foreground disabled:opacity-50`,children:[V(`option`,{value:`auto`,children:`Auto (load balanced)`}),o.map(e=>I(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function nr(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function rr(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function ir(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function ar({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i}){let a=rr(t,n.detectionStreamProfile),o=rr(t,n.motionStreamProfile),s=n.motionSources.includes(`analyzer`);return I(X,{title:`Streams & motion`,children:[I(Z,{label:`Detect stream`,overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,a!==void 0&&` · ${a.width}×${a.height} ${a.codec}`]}),V(Z,{label:`Detect FPS`,overridden:n.overriddenKeys.has(`detectionFps`),children:ir(n.detectionFps)}),I(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.join(` + `):`none`,r===!1&&` · inactive`]}),s&&I(R,{children:[I(Z,{label:`Motion stream`,overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,o!==void 0&&` · ${o.width}×${o.height} ${o.codec}`]}),I(Z,{label:`Motion FPS`,overridden:n.overriddenKeys.has(`motionFps`),children:[ir(n.motionFps),i!==null&&` · live ${i.toFixed(1)}`]})]}),V(Z,{label:`Cooldown`,overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),V(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?V($,{children:`No streams registered`}):e.map(e=>I(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[V(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,nr(e)]},e.camStreamId))})]})}function or({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){return I(X,{title:`Pipeline steps`,children:[e===void 0?V($,{children:`Resolving…`}):e.length===0?V($,{children:`No steps configured`}):V(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>V(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:I(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&V(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&I(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),V(`div`,{className:`mt-1`,children:I(Z,{label:`Audio class.`,children:[r??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var sr={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function cr({detection:e,live:t,detectionMode:n,modeOverridden:r}){if(e===null)return I(X,{title:`Detection runtime`,children:[V(Z,{label:`Mode`,overridden:r,children:n??`—`}),V($,{children:`Detection stage inactive or unreachable`})]});let i=t?.phase??e.phase,a=t?.actualFps??e.actualFps,o=t?.configuredFps??e.configuredFps,s=t?.avgInferenceTimeMs??e.avgInferenceMs,c=t?.queueDepth??e.queueDepth,l=ce(i),u=i===`active`&&a===0;return I(X,{title:`Detection runtime`,children:[I(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[I(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${l.badgeClass}`,children:[V(y,{phase:i,className:`h-2.5 w-2.5`}),l.label]}),t!==void 0&&V(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),V(Z,{label:`Mode`,overridden:r,children:n??`—`}),I(Z,{label:`FPS`,children:[V(`span`,{className:u?`text-danger font-semibold`:``,children:a.toFixed(1)}),I(`span`,{className:`text-foreground-subtle`,children:[` / `,o.toFixed(0),` configured`]})]}),I(Z,{label:`Inference`,children:[s.toFixed(0),` ms`,c>0&&I(`span`,{className:`text-warning`,children:[` · queue `,c]}),t!==void 0&&t.droppedFrames>0&&I(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),I(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),I(Z,{label:`Provisioning`,children:[V(Q,{tone:sr[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&I(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function lr({broker:e}){return e===null?V(X,{title:`Stream broker`,children:V($,{children:`Broker stage inactive or unreachable`})}):I(X,{title:`Stream broker`,children:[e.profiles.length===0?V($,{children:`No broker profiles`}):V(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,n=t&&e.inFps===0;return I(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[V(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${n?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),V(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),I(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),I(`span`,{className:`ml-auto shrink-0 ${n?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),I(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),I(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[I(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),I(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function ur({decoder:e,detectionActive:t}){if(e===null)return V(X,{title:`Decoder`,children:V($,{children:`Decoder stage inactive or unreachable`})});let n=t&&e.shm.framesWritten===0;return I(X,{title:`Decoder`,children:[V(Z,{label:`Node`,children:e.nodeId}),V(Z,{label:`Sessions`,children:e.sessionCount}),I(Z,{label:`SHM frames`,children:[V(`span`,{className:n?`text-danger font-semibold`:``,children:e.shm.framesWritten}),V(`span`,{className:`text-foreground-subtle`,children:` written`})]}),I(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&I(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),I(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&V(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}F();var dr=`pipeline-orchestrator`,fr={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},pr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function mr({problems:e}){return V(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>I(`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:[V(We,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),V(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function hr({deviceId:e,name:t,online:n,status:r,live:i,onlineNodes:a}){let o=z(),{data:s}=j({addonId:dr,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:c}=le({deviceId:e},{staleTime:3e4}),l=L(()=>Yn(s),[s]),u=L(()=>c===void 0?void 0:Xn(c.steps),[c]),d=L(()=>r===void 0?[]:Un(r),[r]),f=()=>{o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},p=N({onSuccess:f}),m=k({onSuccess:f}),h=t=>{t===`auto`?m.mutate({deviceId:e}):p.mutate({deviceId:e,agentNodeId:t})},g=r===void 0?`idle`:Zn(r),_=d.some(e=>e.severity===`error`),v=d.length>0,y=_?`border-danger/50`:v?`border-warning/40`:`border-border`;return I(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${y} bg-background overflow-hidden`,children:[I(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[V(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${_?`bg-danger`:fr[g]}`,title:_?`Error`:pr[g],"aria-label":_?`Error`:pr[g],role:`img`}),V(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),I(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&V(Q,{tone:`danger`,children:`offline`}),I(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[l.detectionMode!==null&&V(Q,{tone:l.detectionMode===`disabled`?`warning`:l.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:l.detectionMode===`disabled`?`detection off`:l.detectionMode}),r?.recording!=null&&(r.recording.active?I(Q,{tone:`danger`,title:`Recording (${r.recording.mode})`,children:[V(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):r.recording.mode!==`off`&&I(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,r.recording.mode]}))]})]}),d.length>0&&V(mr,{problems:d}),r===void 0?V(`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.`}):I(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[V(tr,{assignment:r.assignment,settings:l,onlineNodes:a,pinPending:p.isPending||m.isPending,onDetectionPinChange:h}),V(cr,{detection:r.detection,live:i,detectionMode:l.detectionMode,modeOverridden:l.overriddenKeys.has(`detectionMode`)}),V(or,{steps:u,audioModelId:c?.audio?.modelId??null,audioEnabled:r.audio?.enabled??c?.audio?.enabled??null,audioMode:l.audioMode}),V(ar,{streams:r.source.streams,brokerProfiles:r.broker?.profiles,settings:l,motionEnabled:r.motion?.enabled??null,motionFpsLive:r.motion?.fps??null}),V(lr,{broker:r.broker}),V(ur,{decoder:r.decoder,detectionActive:r.detection?.phase===`active`})]})]})}F();var gr=5e3,_r=1e4,vr=5e3;function yr(e){let t=z(),{data:n,isLoading:r}=Ee(),{data:i,isLoading:a}=M({},{refetchInterval:gr}),{nodes:o}=de();H(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[c,l]=B(new Map);s(_e.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&l(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})}),H(()=>{if(c.size===0)return;let e=setInterval(()=>{l(e=>{let t=Date.now()-_r,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},vr);return()=>clearInterval(e)},[c.size]);let u=L(()=>{let e=new Map;for(let t of i??[])e.set(t.deviceId,t);return e},[i]);return{rows:L(()=>(n??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:u.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[n,u]),liveMetrics:c,onlineNodes:L(()=>(o??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[o]),isLoading:r||a}}F();function br({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:r,isLoading:i}=yr(e),a=L(()=>[...t.map(e=>{let t=e.status===void 0?[]:Un(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]),o=L(()=>{let e=0,t=0;for(let r of a)(r.errorCount>0||r.warningCount>0)&&(t+=1),(n.get(r.row.deviceId)?.phase??r.row.status?.detection?.phase)===`active`&&(e+=1);return{total:a.length,active:e,issues:t}},[a,n]);return i&&t.length===0?V(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?V(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):V(`div`,{className:`h-full overflow-y-auto`,children:I(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[I(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[I(`span`,{children:[V(`span`,{className:`font-semibold text-foreground`,children:o.total}),` cameras`]}),I(`span`,{children:[V(`span`,{className:`font-semibold text-success`,children:o.active}),` actively inferring`]}),I(`span`,{children:[V(`span`,{className:`font-semibold ${o.issues>0?`text-danger`:`text-foreground`}`,children:o.issues}),` `,`with issues`]}),V(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),a.map(({row:e})=>V(hr,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:r},e.deviceId))]})})}F();var xr=`__cluster__`;function Sr(e){return e===`cameras`?`cameras`:`nodes`}function Cr(){let[e,t]=Le(),n=Sr(e.get(`view`)),r=e.get(`node`)??`__cluster__`,[i,a]=B(0),[o,s]=B(!1);return H(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:xr},{replace:!0})},[n,e,t]),I(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[I(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[I(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[V(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),V(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),I(`button`,{type:`button`,onClick:()=>a(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:[V(Ae,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),n===`nodes`&&I(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,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:[I(`span`,{children:[o?`Hide`:`Show`,` node list`]}),V(Ie,{className:[`h-4 w-4 transition-transform`,o?`rotate-180`:``].join(` `)})]}),V(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?I(R,{children:[V(`aside`,{className:[o?`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:V(lt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),s(!1)},refreshToken:i})}),V(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?V(Hn,{refreshToken:i}):V(Yt,{nodeId:r,refreshToken:i})})]}):V(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:V(br,{refreshToken:i})})})]})}export{Cr as PipelinePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as e}from"./index-DCWyP9SY.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as e}from"./index-DCWyP9SY.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]);export{t};
|