@camstack/addon-admin-ui 1.2.148 → 1.2.150
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-D_iTdqkQ.js → AddLocationWizard-Cygq281h.js} +1 -1
- package/dist/assets/{AddonCollectionPage-BPOTO331.js → AddonCollectionPage-DzYy61Rn.js} +1 -1
- package/dist/assets/{Addons-DNJjYeO0.js → Addons-CafwvZRt.js} +1 -1
- package/dist/assets/{AdminTabs-OUb2J4UV.js → AdminTabs-C6Txjg4K.js} +1 -1
- package/dist/assets/{AiProfiles-CUqeroik.js → AiProfiles-u3weKAzd.js} +1 -1
- package/dist/assets/{BrokerForm-Dg21WcfK.js → BrokerForm-CsDjlHsn.js} +1 -1
- package/dist/assets/{Build-BiQ2Aqi7.js → Build-CQJnyRvg.js} +3 -3
- package/dist/assets/{Capabilities-KR4TE2g7.js → Capabilities-Blgw3qT5.js} +1 -1
- package/dist/assets/{CapabilityBadges-Y9Chk6R1.js → CapabilityBadges-B-Zdhd_g.js} +1 -1
- package/dist/assets/Cluster-BvDBA4z3.js +11 -0
- package/dist/assets/{Data-CLovswR9.js → Data-iwAR2n2x.js} +1 -1
- package/dist/assets/{DetectionIntelligence-Cm-a7ogb.js → DetectionIntelligence-rq9e-djO.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-BEIHuj3x.js → DeviceAggregateSection-C0TlHGhr.js} +1 -1
- package/dist/assets/DeviceDetail-CRC0ZJte.js +2 -0
- package/dist/assets/{Devices-D5QPN2l2.js → Devices-CpUPoeSV.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BQStQZrB.js → EmbedPlayerPage-yZezZbVt.js} +1 -1
- package/dist/assets/Events-kj2pMyST.js +1 -0
- package/dist/assets/{FormBuilder-atK-x7p-.js → FormBuilder-CTAWt-d7.js} +1 -1
- package/dist/assets/Identity-BQWsI2gX.js +1 -0
- package/dist/assets/{IntegrationDetail-CSga69wy.js → IntegrationDetail-UsEEY1i_.js} +1 -1
- package/dist/assets/{Integrations-BxUOlmxO.js → Integrations-kmN1gZpw.js} +1 -1
- package/dist/assets/{Integrations-Di2MxGFF.js → Integrations-tiLbVf0u.js} +1 -1
- package/dist/assets/{Locations-tKjlxnXZ.js → Locations-YluUYbPN.js} +1 -1
- package/dist/assets/{Logs-BPa6qlz5.js → Logs-CgmgrJDp.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DjxRpCro.js → MotionZonesSettings-U9GLdP13.js} +1 -1
- package/dist/assets/{MyAccess-CF4pNAS8.js → MyAccess-B5lQZvEA.js} +1 -1
- package/dist/assets/Network-CrQFpUU3.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-DcDnArOn.js → NodeAddonsSettingsPanel-C1qpOXdE.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-fvP1rwQM.js → NodeInferenceDevices-CyRmZRNQ.js} +1 -1
- package/dist/assets/Notifications-CAnCouUA.js +1 -0
- package/dist/assets/Pipeline-B2MjX_0o.js +1 -0
- package/dist/assets/{Plates-Dtt3GmFo.js → Plates-CzkRRxQI.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-Dq4L4D7f.js → PrivacyMaskSettings-CWfERTWr.js} +1 -1
- package/dist/assets/{ProviderIcon-BI5YhQ_F.js → ProviderIcon-sJ2yQ7k5.js} +1 -1
- package/dist/assets/Recordings-ICHkgSMH.js +1 -0
- package/dist/assets/{ScanNetworkModal-D9QTX471.js → ScanNetworkModal-C6VMJXCP.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CBfq7Zl_.js → SceneMonitorEditor-B7tgtd0X.js} +1 -1
- package/dist/assets/{Scenes-Rgm7Vr0e.js → Scenes-DAdgWq5F.js} +1 -1
- package/dist/assets/{Settings-DGtdM9Pk.js → Settings-CfThFogU.js} +1 -1
- package/dist/assets/{Showroom-C-Gv1rY0.js → Showroom-ByPAETrz.js} +1 -1
- package/dist/assets/{StorageLocationsPanel-BoO_ye8J.js → StorageLocationsPanel-HmQIB_Vb.js} +1 -1
- package/dist/assets/{Terminal-DQPWkwYR.js → Terminal-DuCZUxxn.js} +3 -3
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Bo8GlVVQ.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CuD0Cawh.js} +1 -1
- package/dist/assets/{bell-off-CAFZxXKP.js → bell-off-Bk5AAH07.js} +1 -1
- package/dist/assets/{bell-ring-CQIGT-N3.js → bell-ring-C1kUJndA.js} +1 -1
- package/dist/assets/{boxes-BuWaWmzZ.js → boxes-pBOk19g7.js} +1 -1
- package/dist/assets/circle-check-big-C_Y6Vlxm.js +1 -0
- package/dist/assets/circle-dot-9xHGX09F.js +1 -0
- package/dist/assets/circle-slash-Dm33z33z.js +1 -0
- package/dist/assets/{circle-x-BJOy6Vqs.js → circle-x-CAhZI9-Z.js} +1 -1
- package/dist/assets/clock-B2c2NvPX.js +1 -0
- package/dist/assets/{copy-Dw9plIaw.js → copy-CBN-3t7U.js} +1 -1
- package/dist/assets/{debounced-invalidate-C37rLcsf.js → debounced-invalidate-D3QWowRZ.js} +1 -1
- package/dist/assets/dist-CejD4EtJ.js +349 -0
- package/dist/assets/{dist-BHYIPa5D.js → dist-DAR8MsD0.js} +1 -1
- package/dist/assets/{download-Brjekdgb.js → download-BO2bWpuB.js} +1 -1
- package/dist/assets/{face-bbox-CNZfU4D3.js → face-bbox-BJyMDEB2.js} +1 -1
- package/dist/assets/{flame-Cr9Cm5Or.js → flame-CbasE8zE.js} +1 -1
- package/dist/assets/{hard-drive-B0b-qzJJ.js → hard-drive-BZoL5PO_.js} +1 -1
- package/dist/assets/{hard-drive-download-BhmUySz5.js → hard-drive-download-Dy3MSxTR.js} +1 -1
- package/dist/assets/{hostInit-BwaQsXcx.js → hostInit-D9dV-3dF.js} +1 -1
- package/dist/assets/index-Ni_XmFA2.js +4 -0
- package/dist/assets/{key-round-G2DYGMKU.js → key-round-Dq5tsceV.js} +1 -1
- package/dist/assets/{layers-BKn1NdrP.js → layers-CA52-zkw.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-60a864b5.js → mf-entry-bootstrap-0-dafa8f15.js} +2 -2
- package/dist/assets/{pencil-B4d1qxgc.js → pencil-B3W7yf67.js} +1 -1
- package/dist/assets/play-Bh6S9yKU.js +1 -0
- package/dist/assets/{player-overlays-DnMxj3iS.js → player-overlays-CZoMxbfX.js} +1 -1
- package/dist/assets/plus-B6XLLrt6.js +1 -0
- package/dist/assets/power-BJT7ky5f.js +1 -0
- package/dist/assets/{radio-BwofUoi1.js → radio-mrrSsTIU.js} +1 -1
- package/dist/assets/{refresh-cw-D047ng7X.js → refresh-cw-BzYEnhKV.js} +1 -1
- package/dist/assets/remoteEntry-aArvVD5f.js +1 -0
- package/dist/assets/rotate-ccw-DoSIpKLh.js +1 -0
- package/dist/assets/rotate-cw-B3VMz5IH.js +1 -0
- package/dist/assets/{send-D7r2eZhm.js → send-BALBLr9E.js} +1 -1
- package/dist/assets/{server-SQ15Zvmj.js → server-D4gG6ibk.js} +1 -1
- package/dist/assets/{shield-alert-Cka28J7b.js → shield-alert-3IVfz-zv.js} +1 -1
- package/dist/assets/{shield-BC0SEK4n.js → shield-fn3DscNj.js} +1 -1
- package/dist/assets/square-DnnUsoaE.js +1 -0
- package/dist/assets/{square-check-big-C1Gn5BzK.js → square-check-big-h44-BB01.js} +1 -1
- package/dist/assets/src-DAFoNsA_.js +67 -0
- package/dist/assets/src-TPXNmZuu.js +349 -0
- package/dist/assets/{undo-2-BJ7rBlnO.js → undo-2-CCRS1A6P.js} +1 -1
- package/dist/assets/{use-scenes-feed-xWdJ6AfR.js → use-scenes-feed-D1R0HooM.js} +1 -1
- package/dist/assets/useEventInvalidation-DhyGa1qR.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DfVJACml.js → useNodeUrlSelection-B_AUHOMQ.js} +1 -1
- package/dist/assets/user-round-B7KGgAcJ.js +1 -0
- package/dist/assets/{video-Cg1AtHJT.js → video-C4ev2Wfq.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-btVrAfQq.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Cee58BQv.js} +2 -2
- package/dist/assets/{wifi-DIyJo9CL.js → wifi-D0POhWlD.js} +1 -1
- package/dist/assets/{zap-sg6ozzFD.js → zap-Uymmrarp.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +67 -2
- package/package.json +1 -1
- package/dist/assets/Cluster-CjdoCBfA.js +0 -11
- package/dist/assets/DeviceDetail-BAa7rtgK.js +0 -2
- package/dist/assets/Events-hafxhn3V.js +0 -1
- package/dist/assets/Identity-Dz3SO7WO.js +0 -1
- package/dist/assets/Network-CT4GJmhk.js +0 -1
- package/dist/assets/Notifications-BWkFNvX5.js +0 -1
- package/dist/assets/Pipeline-tvS781ww.js +0 -1
- package/dist/assets/Recordings-B-8qx3Va.js +0 -1
- package/dist/assets/circle-check-big-AVmLjJsy.js +0 -1
- package/dist/assets/circle-dot-DDt31J32.js +0 -1
- package/dist/assets/circle-slash-h6Lu76oj.js +0 -1
- package/dist/assets/clock-5P5QLkr9.js +0 -1
- package/dist/assets/dist-DwBBqYN3.js +0 -349
- package/dist/assets/index-vAjGJjNh.js +0 -4
- package/dist/assets/play-BxlXoTln.js +0 -1
- package/dist/assets/plus-B1Brk-os.js +0 -1
- package/dist/assets/power-DDpzbeij.js +0 -1
- package/dist/assets/remoteEntry-Dlhp3Qao.js +0 -1
- package/dist/assets/rotate-ccw-BMmMAgHT.js +0 -1
- package/dist/assets/rotate-cw-CXEU54W1.js +0 -1
- package/dist/assets/square-Bh-hyOLr.js +0 -1
- package/dist/assets/src-C9Is_nwm.js +0 -67
- package/dist/assets/src-D4B8ZNXP.js +0 -349
- package/dist/assets/useEventInvalidation-CjAf5L5U.js +0 -1
- package/dist/assets/user-round-DcSv_rMS.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{K as e,Q as t,S as n,T as r,W as i,b as a,i as o,o as s,p as c,q as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Q as f}from"./player-overlays-DnMxj3iS.js";import{$a as p,$s as m,Ba as h,Fa as g,Ft as _,Gt as v,Ha as y,Ia as b,It as x,J as S,Js as C,La as w,Lt as T,Nt as E,Pa as D,Qa as O,Qs as k,Ra as ee,Rt as A,V as j,Va as M,Wa as te,Xa as N,Xs as P,Ya as F,Ys as I,Zs as L,_n as R,_o as ne,an as re,ao as z,b as ie,bn as ae,d as oe,eo as se,et as B,fo as ce,gn as le,h as ue,ho as de,io as fe,mo as pe,no as me,oo as he,po as ge,qa as _e,r as ve,ro as ye,so as be,u as xe,za as Se,zt as Ce}from"./src-C9Is_nwm.js";import{n as we}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DX7sYWrs.js";import{Ht as Te,Ut as Ee,f as De,h as Oe,p as ke}from"./src-D4B8ZNXP.js";import{a as Ae,i as je,l as Me,n as V,o as Ne,r as Pe,t as Fe,u as Ie}from"./NodeInferenceDevices-fvP1rwQM.js";import{t as Le}from"./flame-Cr9Cm5Or.js";import{t as Re}from"./layers-BKn1NdrP.js";import{n as ze,t as Be}from"./video-Cg1AtHJT.js";import{t as Ve}from"./pencil-B4d1qxgc.js";import{t as He}from"./plus-B1Brk-os.js";import{t as Ue}from"./radio-BwofUoi1.js";import{t as We}from"./refresh-cw-D047ng7X.js";import{t as Ge}from"./server-SQ15Zvmj.js";import{t as Ke}from"./square-check-big-C1Gn5BzK.js";import{t as qe}from"./square-Bh-hyOLr.js";import{t as Je}from"./zap-sg6ozzFD.js";import{B as H,D as Ye,I as Xe,J as Ze,L as Qe,O as $e,P as U,Q as et,a as tt,i as nt,k as rt,o as it,r as at,w as ot,z as st}from"./index-vAjGJjNh.js";import"./useEventInvalidation-CjAf5L5U.js";import{t as ct}from"./NodeAddonsSettingsPanel-DcDnArOn.js";import{t as lt}from"./StorageLocationsPanel-BoO_ye8J.js";var ut=Ze(`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`}]]),dt=Ze(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);t();function ft(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function pt(e){return e}function mt(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ht(e,t){return typeof e==`boolean`?e:pt(t)}function gt(e,t){return{pipeline:ht(mt(e,`detect`),t),audio:ht(mt(e,`audio`),t),ingest:ht(mt(e,`ingest`),t)}}function _t(e,t,n){let r=e?.find(e=>e.nodeId===t);return gt(r?.settings,n)}function vt({selectedNodeId:e,onSelect:t,refreshToken:r}){let{nodes:i}=I(),{data:o}=F(void 0),{data:s}=O(void 0),c=new Map;for(let e of o??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=i??[],d=l.filter(e=>e.isOnline).length,f=l.filter(e=>!e.isOnline).length;return n(`div`,{className:`flex flex-col h-full`,children:[n(`button`,{type:`button`,onClick:()=>t(Rr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[u(Ye,{className:`h-4 w-4 flex-shrink-0`}),n(`div`,{className:`min-w-0 flex-1`,children:[u(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),u(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),u(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(r=>{let i=e===r.id,o=c.get(r.id)??0,l=r.isHub?Ge:U,d=_t(s,r.id,r.isHub),f=r.isOnline?null:j(ft(r.lastSeen));return n(`button`,{type:`button`,onClick:()=>t(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[u(l,{className:`h-4 w-4 flex-shrink-0`}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex items-center gap-2`,children:[u(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&u(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!r.isOnline&&u(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),r.isOnline&&u(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),n(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[n(`span`,{children:[r.cpuCores,` cores`]}),u(`span`,{children:`•`}),n(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),o>0&&n(a,{children:[u(`span`,{children:`•`}),n(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[u(Be,{className:`h-2.5 w-2.5`}),o]})]}),!r.isOnline&&n(a,{children:[u(`span`,{children:`•`}),n(`span`,{className:`text-destructive`,children:[`offline`,f===null?``:` · ${f}`]})]})]}),n(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[u(E,{variant:d.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:d.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),u(E,{variant:d.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:d.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},r.id)})}),n(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[n(`span`,{children:[d,` online`]}),f>0&&n(`span`,{className:`text-destructive`,children:[f,` offline`]})]})]})}function yt({nodeId:e,refreshToken:t}){let{nodes:r}=I(),i=r?.find(t=>t.id===e),o=P(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?n(`div`,{className:`px-6 py-4 border-b border-border`,children:[n(`div`,{className:`flex items-center gap-2 mb-1`,children:[u(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?u(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):u(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),i.isHub&&u(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),n(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[u(`span`,{children:i.cpuModel??`CPU`}),u(`span`,{children:`•`}),n(`span`,{children:[i.cpuCores,` cores`]}),u(`span`,{children:`•`}),n(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),o&&n(a,{children:[u(`span`,{children:`•`}),n(`span`,{children:[o.attachedCameras,` cameras (`,o.activeCameras,` active)`]}),u(`span`,{children:`•`}),n(`span`,{children:[o.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),u(`span`,{children:`•`}),n(`span`,{children:[`queue `,o.queueDepthTotal]}),o.hardware.hasGpu&&n(a,{children:[u(`span`,{children:`•`}),u(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):u(`div`,{className:`px-6 py-4 border-b border-border`,children:n(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}var bt=[`assignments`,`tree`,`engines`,`logs`];function xt({refreshToken:e,nodeId:t}){let[r,a]=l(new Map),{nodes:o}=C();k(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&a(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:s}=y(void 0),c=i(()=>{let e=new Map;for(let t of s??[])e.set(t.nodeId,t.deviceCount);return e},[s]),d=i(()=>{let e=new Map,t=Date.now()-3e4;for(let n of r.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[r]),f=i(()=>{let e=new Map;for(let t of o)e.set(t.id,t.shortName);return e},[o]),p=i(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of d.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:o.length,onlineAgents:o.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[d,o]);if(t){let e=d.get(t);return n(`div`,{className:`@container/liveload`,children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),n(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[u(W,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),u(W,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),u(W,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),u(W,{label:`Queue`,value:e?String(e.queueDepth):`—`}),u(W,{label:`Audio`,value:String(c.get(t)??`—`)})]})]})}let m=[...d.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return n(`div`,{className:`@container/liveload`,children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),n(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[u(W,{label:`Total agents`,value:`${p.onlineAgents}/${p.totalAgents}`}),u(W,{label:`Active / Attached`,value:`${p.activeCameras}/${p.attachedCameras}`}),u(W,{label:`Total FPS`,value:p.totalFps.toFixed(1)}),u(W,{label:`Avg inference ms`,value:p.avgInferenceTimeMs.toFixed(0)}),u(W,{label:`Queue depth`,value:String(p.queueDepth)})]}),u(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[480px]`,children:[u(`thead`,{className:`bg-surface`,children:n(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[u(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),u(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),u(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),u(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),u(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),u(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),n(`tbody`,{children:[m.map(([e,t])=>n(`tr`,{className:`border-t border-border`,children:[u(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:f.get(e)??e}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:c.get(e)??`—`})]},e)),m.length===0&&u(`tr`,{children:u(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function W({label:e,value:t}){return n(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[u(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),u(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}t();var St={active:!1,pinned:!1,nodeId:null,reason:``},Ct=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],wt=3e5,Tt={pipeline:U,decoder:rt,audio:ze},Et={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function Dt({mode:e,nodeId:t,compact:o=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let c=s(),[f,p]=l(null),[m,h]=l(null),[g,_]=l(new Map);ve([`pipelineOrchestrator`,`getPipelineAssignments`],Ct),ve([`pipelineOrchestrator`,`getAudioAssignments`],Ct),ve([`pipelineOrchestrator`,`getCameraStatuses`],Ct);let{data:y}=F(void 0),{data:b}=M(void 0),{data:x}=te({},{enabled:e===`agent`}),{nodes:S}=C(),{data:T}=Me();k(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&_(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),d(()=>{if(g.size===0)return;let e=setInterval(()=>{_(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)},[g.size]);let E=i(()=>{let e=new Map;for(let t of T??[])e.set(t.id,t.name);return e},[T]),D=i(()=>{if(e===`agent`){let e=[];for(let n of x??[]){let r=n.assignment,i=(e,n,r)=>({active:e!==null&&e===t,pinned:n,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:n.deviceId,deviceName:E.get(n.deviceId)??`Device ${n.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:E.get(e)??`Device ${e}`,pipeline:St,decoder:St,audio:St};return n.set(e,r),r};for(let i of y??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of b??[]){let t=r(e.deviceId);n.set(e.deviceId,{...t,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...n.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[y,b,x,E,e,t]),O=i(()=>(S??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[S]),A=()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},j=ee({onSuccess:A}),N=pe({onSuccess:A}),P=w({onSuccess:A}),I=ge({onSuccess:A}),L=(e,t,n)=>{t===`pipeline`?j.mutate({deviceId:e,agentNodeId:n}):P.mutate({deviceId:e,nodeId:n}),p(null)},R=(e,t)=>{t===`pipeline`?N.mutate({deviceId:e}):I.mutate({deviceId:e}),p(null)};return u(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[u(`thead`,{className:`bg-surface`,children:n(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!o&&u(`th`,{className:`w-10`}),u(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?n(a,{children:[u(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),u(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):n(a,{children:[u(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),u(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),u(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),u(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),n(`tbody`,{children:[D.map(t=>{let i=g.get(t.deviceId),s=m===t.deviceId;return n(r.Fragment,{children:[n(`tr`,{className:`border-t border-border align-middle relative`,children:[!o&&u(`td`,{className:`px-2 py-2 align-middle`,children:u(`button`,{type:`button`,onClick:()=>h(s?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":s?`Collapse broker details`:`Expand broker details`,children:u(s?st:Qe,{className:`h-3.5 w-3.5`})})}),n(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[u(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),n(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?n(a,{children:[u(`td`,{className:`px-3 py-2 align-middle`,children:u(kt,{state:t.pipeline,onlineNodes:O,pending:j.isPending||N.isPending,onChange:e=>{e===`auto`?R(t.deviceId,`pipeline`):L(t.deviceId,`pipeline`,e)}})}),u(`td`,{className:`px-3 py-2 align-middle`,children:u(jt,{state:t.pipeline,deviceId:t.deviceId})})]}):n(a,{children:[u(Nt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:O,isMenuOpen:f?.deviceId===t.deviceId&&f.role===`pipeline`,onToggleMenu:()=>p(f?.deviceId===t.deviceId&&f.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>p(null),onMove:e=>L(t.deviceId,`pipeline`,e),onUnpin:()=>R(t.deviceId,`pipeline`)}),u(Nt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:O,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),u(Nt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:O,isMenuOpen:f?.deviceId===t.deviceId&&f.role===`audio`,onToggleMenu:()=>p(f?.deviceId===t.deviceId&&f.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>p(null),onMove:e=>L(t.deviceId,`audio`,e),onUnpin:()=>R(t.deviceId,`audio`)})]}),u(`td`,{className:`px-3 py-2 align-middle`,children:u(Lt,{snap:i})})]}),s&&!o&&n(`tr`,{className:`bg-surface/50`,children:[u(`td`,{}),n(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2 space-y-3`,children:[t.pipeline.nodeId&&u(Ot,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),u(v,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})]})]})]},t.deviceId)}),D.length===0&&u(`tr`,{children:u(`td`,{colSpan:o?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function Ot({deviceId:e,nodeId:t}){let r=s(),{data:i}=_e({nodeId:t}),{data:a}=N({deviceId:e}),o=ce({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}}),c=i?.devices??[],l=a?.deviceKey??`auto`,d=l!==`auto`&&!c.some(e=>e.key===l);return n(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[u(`span`,{className:`shrink-0 font-medium text-foreground`,children:`Inference device`}),n(`select`,{value:l,disabled:o.isPending,"aria-label":`Inference device pin`,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value}),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[u(`option`,{value:`auto`,children:`Auto (balanced)`}),d&&n(`option`,{value:l,children:[`Pin → `,l,` (not on this node)`]}),c.map(e=>n(`option`,{value:e.key,children:[`Pin → `,e.key,e.available?``:` (unavailable)`]},e.key))]}),o.isPending&&u(`span`,{className:`text-[10px] opacity-70`,children:`saving…`})]})}function kt({state:e,onlineNodes:t,pending:r,onChange:i}){let a=e.pinned&&e.nodeId?e.nodeId:`auto`,o=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return n(`select`,{value:a,disabled:r,"aria-label":`Pipeline placement pin`,onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[u(`option`,{value:`auto`,children:`Auto`}),o.map(e=>n(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function At(t){let n=e(null);return t.nodeId!==null&&(n.current=t),n.current}function jt({state:e,deviceId:t}){let r=At(e),i=e.active&&e.nodeId!==null;if(r===null||r.nodeId===null)return u(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`— · no session yet`});let a=r.pinned?`pinned · manual`:`auto · ${r.reason||`capacity`}`;return n(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[u(`span`,{className:`font-mono text-[11px] truncate ${i?`text-foreground`:`text-foreground-subtle`}`,title:r.pinned?r.nodeId:`${r.nodeId} — an unpinned camera is re-elected per on-motion session, so this can change between sessions`,children:r.nodeId}),u(`span`,{className:`truncate ${r.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:a,children:a}),u(`span`,{className:`truncate text-[10px] ${i?`text-emerald-400`:`text-foreground-subtle/70`}`,children:i?`● running here`:`○ idle · last session here`}),u(Mt,{deviceId:t,nodeId:r.nodeId})]})}function Mt({deviceId:e,nodeId:t}){let r=s(),{data:i}=N({deviceId:e},{refetchOnMount:`always`}),{data:a}=_e({nodeId:t},{staleTime:wt}),o=ce({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return u(`span`,{className:`mt-0.5 text-[10px] text-foreground-subtle italic`,children:`device: …`});let c=a.devices??[],l=c.filter(e=>e.enabled),d=i.deviceKey??`auto`,f=d!==`auto`&&!l.some(e=>e.key===d),p=c.find(e=>e.key===d);return n(`select`,{value:d,disabled:o.isPending,"aria-label":`Inference device pin`,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value}),className:`mt-0.5 w-full min-w-0 rounded border border-border bg-background px-1 py-0.5 text-[10px] text-foreground disabled:opacity-50`,children:[u(`option`,{value:`auto`,children:`Auto (balanced)`}),f&&n(`option`,{value:d,children:[p?`${V(p).label} (${d})`:d,` (not enabled)`]}),l.map(e=>n(`option`,{value:e.key,children:[V(e).label,` · `,e.format]},e.key))]})}function Nt({role:e,state:t,mode:r,onlineNodes:i,readOnly:a=!1,isMenuOpen:o,onToggleMenu:s,onCloseMenu:c,onMove:l,onUnpin:d}){let f=Tt[e],p=i.filter(e=>e.id!==(t.nodeId??``)),m=!a&&(t.active||r===`cluster`)&&(p.length>0||t.pinned);return n(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[n(`div`,{className:`flex items-center gap-2 min-w-0`,children:[u(r===`agent`?Pt:Ft,{state:t,Icon:f}),u(`div`,{className:`ml-auto shrink-0`,children:m&&u(`button`,{type:`button`,onClick:s,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${Et[e]} actions`,children:u(ut,{className:`h-3 w-3 text-foreground-subtle`})})})]}),o&&m&&u(Rt,{title:Et[e],targets:p,pinned:t.pinned,onMove:l,onUnpin:d,onClose:c})]})}function Pt({state:e,Icon:t}){return n(`div`,{className:`flex items-center gap-1.5`,children:[u(e.active?Ke:qe,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),u(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&u(dt,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Ft({state:e,Icon:t}){return!e.active||!e.nodeId?n(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[u(t,{className:`h-3 w-3`}),u(`span`,{className:`text-[10px] italic`,children:`—`})]}):n(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[u(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),n(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[u(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),u(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?n(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[u(dt,{className:`h-2.5 w-2.5`}),` manual`]}):n(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var It=`min-h-[3.25rem]`;function Lt({snap:e}){if(!e)return u(`div`,{className:`flex items-center ${It}`,children:u(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:r,avgInferenceTimeMs:i,queueDepth:a,configuredFps:o,droppedFrames:s}=e.metrics,c=B(t);return n(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${It}`,children:[n(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${c.textColor}`,children:[u(ue,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),u(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:c.label})]}),n(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[u(`span`,{className:`text-foreground`,children:r.toFixed(1)}),n(`span`,{children:[`/`,o.toFixed(0),` fps`]})]}),n(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[u(`span`,{className:`text-foreground`,children:i.toFixed(0)}),u(`span`,{children:` ms`}),a>0&&n(`span`,{className:`text-warning ml-1`,children:[`q`,a]})]}),n(`span`,{className:`whitespace-nowrap truncate ${s>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,u(`span`,{className:`text-foreground`,children:s})]})]})}function Rt({title:t,targets:r,pinned:i,onMove:a,onUnpin:o,onClose:s}){let c=e(null);return d(()=>{let e=e=>{c.current?.contains(e.target)||s()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]),n(`div`,{ref:c,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[u(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:t}),r.length>0&&u(`div`,{className:`py-1`,children:r.map(e=>n(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),i&&n(`button`,{type:`button`,onClick:o,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,t.toLowerCase()]}),r.length===0&&!i&&u(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function zt({nodeId:e,refreshToken:t}){return n(`div`,{className:`space-y-6`,children:[u(xt,{refreshToken:t,nodeId:e}),n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),u(Dt,{mode:`agent`,nodeId:e,compact:!0})]})}t();function Bt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Vt({nodeId:e,refreshToken:t}){let r=s(),a=g({onSettled:()=>{r.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:o}=b({nodeId:e}),c=P(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??o??null,l=c===null;ve([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:d}=ne({nodeId:e}),{values:f}=L(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),p=i(()=>f.filter(e=>e.metrics.phase===`active`).length,[f]),m=t=>{let n=d??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||a.mutate({nodeId:e,engine:t,force:n.length>0})};return n(`div`,{className:`space-y-6`,children:[n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(c??[]).length,` engine(s) resident in RAM. `,(d??[]).length,` `,`camera(s) attached, `,p,` actively dispatching frames. Refreshes every 5s.`]})]}),u(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[640px]`,children:[u(`thead`,{className:`bg-surface`,children:n(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[u(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),u(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),u(`th`,{className:`text-left px-3 py-2`,children:`Models`}),u(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),u(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),u(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),u(`th`,{className:`w-20`})]})}),n(`tbody`,{children:[l&&u(`tr`,{children:u(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!l&&(c??[]).map(e=>{let t=e.kind===`warm-override`,r=e.kind===`device-pool`;return n(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:r?`bg-primary/[0.05]`:``}`,children:[u(`td`,{className:`px-3 py-2`,children:n(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:r?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[u(t?Le:r?Re:U,{className:`h-3 w-3`}),t?`warm`:r?`pool`:`runtime`]})}),u(`td`,{className:`px-3 py-2`,children:n(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[u(Je,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),u(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?u(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):u(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>u(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),u(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),u(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?u(`span`,{className:`text-foreground-subtle`,children:Bt(e.idleMs,e.idleTtlMs)}):u(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),u(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(d??[]).length}),u(`td`,{className:`px-3 py-2 text-right`,children:r?u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`auto`}):n(`button`,{type:`button`,disabled:a.isPending,onClick:()=>m(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[u(it,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!l&&(c??[]).length===0&&u(`tr`,{children:u(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),n(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[u(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,u(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,u(`strong`,{className:`text-foreground`,children:`pool`}),`: a per-device balanced inference pool (one per enabled accelerator, running concurrently); reaper-managed on its own idle TTL.`]}),a.isError&&n(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,a.error instanceof Error?a.error.message:`unknown`]})]})}var Ht=`pipeline-runner`,Ut=200;function Wt({nodeId:e}){return n(`div`,{className:`flex flex-col gap-3`,children:[n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. Streaming live; the device chip on a line tells which camera it refers to.`]})]}),u(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:u(S,{agentId:e,addonId:Ht,limit:Ut,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}t(),t();function Gt({nodeId:e,title:t}){let{data:r}=Me(),{data:a}=F(void 0),o=i(()=>{let e=new Map;for(let t of r??[])e.set(t.id,t.name);return e},[r]),s=i(()=>{if(!e)return null;let t=new Set;for(let n of a??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,a]),[c,f]=l(new Map);k(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||f(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),d(()=>{if(c.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[c.size]);let p=i(()=>{let e=[];for(let t of c.values())s&&!s.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[c,s]);return p.length===0?n(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):n(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[n(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[u(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),u(`span`,{className:`text-[10px] text-foreground-subtle`,children:p.length})]}),u(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map(e=>{let t=o.get(e.deviceId)??`#${e.deviceId}`,r=B(e.metrics.phase);return n(`div`,{title:`${t} · ${r.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[u(ue,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),u(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),u(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),u(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}var Kt=`pipeline-orchestrator`;function qt(e){return De.find(t=>t.stepId===e)??null}function Jt({title:e}){return u(`span`,{title:e??`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`,className:`ml-1 rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:`cluster-wide`})}function Yt({step:e,engineFormat:t,runnableModelIds:r}){let i=s(),{data:a,isLoading:o}=R({addonId:Kt}),c=ae({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),l=Oe(a??null)[e.stepId]??e.defaultModelId,d=r.length>0&&!r.includes(l);return n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[n(`div`,{className:`flex items-center text-[11px] font-medium text-foreground`,children:[e.label,u(Jt,{})]}),n(`p`,{className:`mt-1 text-[10px] leading-snug text-foreground-subtle`,children:[`Applies to every node. Changing it does not corrupt `,e.indexName,` — every vector carries the model that produced it and only matches its own — but it STRANDS it: the existing vectors stay readable and match nothing until a re-embed pass has run.`]})]}),o?u(ot,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):u(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:l,disabled:c.isPending,onChange:t=>{t.target.value!==l&&c.mutate({addonId:Kt,patch:{[ke(e.stepId)]:t.target.value}})},children:e.options.map(t=>n(`option`,{value:t.id,children:[t.label,t.id===e.defaultModelId?` (default)`:``]},t.id))}),d&&n(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[10px] leading-snug text-amber-300`,children:[`This node's engine (`,t,`) ships no build of `,u(`b`,{children:l}),`. It will REFUSE this step rather than run a different encoder — a substitute would put a second feature space into `,e.indexName,`. Either pick a model with a `,t,` build, or accept that this node contributes nothing to that index.`]}),u(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Stored once, in Pipeline → Cluster → Settings → Enrichment models. This editor writes that same row — there is no per-node copy of this value. Step knobs for this encoder (minimum face size, …) live on that same settings page.`})]})}t();function G(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 Xt(e){if(!e)return null;let t=e.modelId!==void 0&&e.modelId!==``?e.modelId:void 0,n=e.settings&&Object.keys(e.settings).length>0?e.settings:void 0;return t===void 0&&n===void 0?null:{...t===void 0?{}:{modelId:t},...n===void 0?{}:{settings:n}}}function Zt({nodeId:e,refreshToken:t}){let r=s(),[o,c]=l(null),[d,f]=l(null),[p,m]=l(``),[h,g]=l(null),v=_e({nodeId:e},{refetchOnMount:`always`}),y=D({nodeId:e},{refetchOnMount:`always`}),b=Oe(R({addonId:`pipeline-orchestrator`}).data??null),S=v.data?.devices??[],C=he({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),w=i(()=>y.data?xe(y.data):[],[y.data]),E=i(()=>S.map(t=>({agentNodeId:e,engineLabel:t.format,deviceKey:t.key,deviceLabel:V(t).label})),[S,e]),O=e=>S.find(t=>t.key===e)??null,k=i(()=>S.filter(e=>e.enabled),[S]),ee=k.length>=2,j=(e,t)=>A(G(y.data??null,e)?.models??[],t?.format),M=e=>{let t=O(e);return t?V(t).label:e},te=(e,t)=>k.filter(n=>n.key!==t&&j(e,n)).toSorted((e,t)=>e.key<t.key?-1:+(e.key>t.key))[0]??null,N=e=>{let t=G(y.data??null,e)?.enabledByDefault??!0;return{kind:`gate`,effectiveOn:t,defaultOn:t,explicit:!1}},P=(e,t)=>{let n=G(y.data??null,e);if(n)return x(n,t)},F=(e,t)=>{let n=N(e),r=n.kind===`gate`?n.effectiveOn:!1,i=G(y.data??null,e),a=t.deviceKey===void 0?null:O(t.deviceKey),o=A(i?.models??[],a?.format),s=a?.steps?.[e];if(!o){if(!r)return{kind:`na`};let n=s?.jumpDeviceKey,i=n!==void 0&&k.some(e=>e.key===n)?n:t.deviceKey===void 0?void 0:te(e,t.deviceKey)?.key;return i===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:M(i)}}let c=qt(e);return c?{kind:`enabled`,modelId:b[e]??c.defaultModelId,clusterWide:!0}:{kind:`enabled`,modelId:(i?T({catalog:i,device:a,base:s?.modelId}):void 0)??`Auto`,...s?.jumpDeviceKey!==void 0&&k.some(e=>e.key===s.jumpDeviceKey)?{jumpTo:M(s.jumpDeviceKey)}:{}}},I=o&&y.data?G(y.data,o.addonId):null,L=o?O(o.deviceKey):null,ne=L?.format??`coreml`,re=o?P(o.addonId,L):void 0,z=()=>{c(null),f(null),m(``)},ae=(e,t)=>{if(t.deviceKey===void 0)return;let n=O(t.deviceKey)?.steps?.[e];c({addonId:e,deviceKey:t.deviceKey});let r=n?.settings??Ae(S.map(e=>({key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}})),t.deviceKey,e)??{};f({enabled:!0,...n?.modelId===void 0?{}:{modelId:n.modelId},settings:r}),m(n?.jumpDeviceKey??``)},se=()=>{if(!o)return;let t=Xt(d),n=p!==``&&p!==o.deviceKey?p:void 0,r=t||n!==void 0?{...t,...n===void 0?{}:{jumpDeviceKey:n}}:null,i=S.map(e=>{let t={...e.steps};return e.key===o.deviceKey&&(r?t[o.addonId]=r:delete t[o.addonId]),{key:e.key,enabled:e.key===o.deviceKey?!0:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:t}}),a=r?.settings!==void 0&&Object.keys(r.settings).length>0?Ne(i,o.deviceKey,o.addonId):i;C.mutate({agentNodeId:e,inferenceDevices:je(a)},{onSuccess:z})};if(v.isLoading||y.isLoading)return u(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(S.length===0)return u(`div`,{className:`rounded-md border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`});if(!y.data)return u(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let B=o!==null&&I!==null&&L!==null;return n(`div`,{className:`relative h-full w-full space-y-3`,children:[n(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[`Each column is one of this node's inference accelerators. A cell shows the`,` `,u(`span`,{className:`font-medium text-foreground`,children:`base model`}),` every camera landing on that accelerator runs; click to change it. Whether a camera runs a step is set per-camera on that camera's Detection pipeline tab — there is no gate here.`]}),u(`div`,{className:B?`md:pr-[360px]`:``,children:w.length>0?u(ie,{tree:w,agents:E,gateFor:N,getCellState:F,onCellClick:ae,selectedCell:o?{addonId:o.addonId,agentNodeId:e,deviceKey:o.deviceKey}:null,onSetGate:()=>{},fallbackNodeId:h,onFallbackNodeChange:g,hideGate:!0}):u(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),u(oe,{open:B,onClose:z,title:I?.name??``,subtitle:o&&L?`${e} · ${V(L).label} · ${L.format}`:``,footer:n(a,{children:[u(`div`,{className:`flex-1`}),u(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:z,children:`Cancel`}),u(`button`,{type:`button`,disabled:!o||!d||C.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:se,children:C.isPending?`Saving…`:`Save`})]}),children:I&&o&&qt(o.addonId)?u(Yt,{step:qt(o.addonId),engineFormat:ne,runnableModelIds:Ce(I.models??[],ne).map(e=>e.id)}):I&&o&&d?n(`div`,{className:`space-y-3`,children:[ee&&n(`div`,{className:`rounded-md border border-border bg-muted/10 px-3 py-2 space-y-1`,children:[u(`label`,{className:`block text-[11px] font-medium text-foreground`,children:`Run on`}),n(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:p,onChange:e=>m(e.target.value),children:[u(`option`,{value:``,children:`Auto (this device, or auto-jump if unsupported)`}),k.filter(e=>e.key!==o.deviceKey).map(e=>n(`option`,{value:e.key,children:[V(e).label,` · `,e.format]},e.key))]}),u(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Route this step (and its child steps) to another accelerator on this node.`})]}),u(_,{mode:`agent`,addon:I,agentDefault:d,agentNodeId:e,engineFormat:ne,effectiveModelId:re,onChangeAgentConfig:f})]}):u(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300`,children:`This accelerator is no longer reported by the node, so there is nothing to provision here.`})})]})}t();var Qt=!1;function $t({nodeId:e,refreshToken:t}){let r=re(),[i,a]=l(null),[o,s]=l(null),{nodes:c}=C(),d=c.find(t=>t.id===e),f=d?.name??e,p=d?.isOnline??!1,m=me({onSuccess:e=>{s(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),h=async()=>{await r({title:`Reset ${f} to hardware-aware defaults?`,message:`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(s(null),m.mutate({agentNodeId:e}))};return n(`div`,{className:`relative h-full w-full space-y-3`,children:[n(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[o&&u(`span`,{className:`text-emerald-400`,children:o}),m.isError&&u(`span`,{className:`text-red-400`,children:m.error instanceof Error?m.error.message:`Reset failed`}),u(`button`,{type:`button`,onClick:()=>{h()},disabled:m.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's per-device model defaults + per-camera overrides scoped to this node`,children:m.isPending?`Resetting…`:`Reset to default`})]}),u(Gt,{nodeId:e}),Qt,Qt,n(`div`,{children:[u(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices — default model per accelerator`}),u(Fe,{nodeId:e,nodeName:f,isOnline:p})]}),n(`div`,{children:[u(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection steps — model per accelerator`}),u(Zt,{nodeId:e,refreshToken:t})]})]})}var en=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],tn=`decoder-nodeav`;function nn({nodeId:e,refreshToken:t}){let{nodes:r}=C(),i=r.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??tn,a=[...en,i],o={assignments:{id:`assignments`,label:`Assignments`,order:-10,content:u(zt,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:`Pipeline`,order:39,content:u($t,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:`Warm instances`,order:180,content:u(Vt,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:`Logs`,order:300,content:u(Wt,{nodeId:e})}},s=bt.map(e=>o[e]);return n(`div`,{className:`flex flex-col h-full`,children:[u(yt,{nodeId:e,refreshToken:t}),u(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:u(ct,{nodeId:e,addonIds:a,level:`global`,extraTabs:s})})]})}function rn(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?`CPU`:t===`openvino`&&n===`npu`?`Intel NPU`:t===`openvino`&&(n===`gpu`||n===`igpu`)?`Intel iGPU`:t===`edgetpu`?`Coral Edge TPU`:t===`coreml`?`Apple ANE`:`${e.backend} ${e.device}`.trim()}var an={disabled:`switched off — not a dispatch target`,unavailable:`the node probe does not see it (unplugged or still provisioning)`,"cannot-host-camera-root":`its engine format has no object-detection root model`,"accelerator-preferred":`CPU fallback — it never competes while an accelerator is serving`};function K(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function on(e,t){let n=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let r=t.get(e.key),i=r?.sessions??0,a=e.weight>0?e.weight:1;return{key:e.key,label:rn(e),format:e.format,sessions:i,queueDepth:r?.queueDepth??0,weight:a,weightSharePct:e.exclusion===null?K(a,n):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function sn(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0),r=e.loads.reduce((e,t)=>e+t.load.attachedCameras,0);return e.nodes.map(i=>{let a=t.get(i.id),o=on(e.devicesByNode[i.id]??[],new Map((a?.load.devices??[]).map(e=>[e.deviceKey,{sessions:e.attachedCameras,queueDepth:e.queueDepthTotal}]))),s=i.isOnline&&i.detectEnabled,c=i.weight>0?i.weight:1,l=a?.load.attachedCameras??null;return{nodeId:i.id,name:i.name,isOnline:i.isOnline,detectEnabled:i.detectEnabled,reported:a!==void 0,attachedCameras:l,activeCameras:a?.load.activeCameras??null,maxCameras:i.maxCameras,capacityPct:l!==null&&i.maxCameras!==null&&i.maxCameras>0?K(l,i.maxCameras):null,queueDepthTotal:a?.load.queueDepthTotal??null,avgInferenceTimeMs:a?.load.avgInferenceTimeMs??null,score:a?.score??null,weight:c,weightSharePct:s?K(c,n):null,cameraSharePct:l===null?null:K(l,r),decodeHwaccel:a?.decodeHwaccel??null,devices:o,eligibleDeviceCount:o.filter(e=>e.exclusion===null).length}})}var cn=`pipeline-orchestrator`,ln=`recorder`,un=`recordingNodeId`,dn=`pipeline-analytics`,fn=`postProcessingNodeId`,pn=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`,`postProcessingNode`],mn=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function hn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function gn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function q(e,t,n){let r=hn(e,t);return typeof r==`string`&&r.length>0?r:n}function _n(e,t,n){let r=hn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function vn(e,t){let n=gn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function yn(e,t){let n=gn(e,t);return typeof n==`string`&&n.length>0?n:null}function bn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:e===`postProcessingNode`?`Post-processing`:`Motion Node`}function xn(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`:e===`postProcessingNode`?`Runs detection post-processing (events, media, audio & motion)`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function Sn(e,t){switch(t){case`detect`:return e.pipeline}}function Cn(e){return e instanceof Error?e.message:`Failed to save`}function wn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}t();var Tn=2e4,En=3e5;function Dn(){let{nodes:e}=C(),t=f().trpcClient,r=h(void 0,{placeholderData:c,staleTime:Tn,refetchInterval:Tn,refetchOnWindowFocus:!0}),a=O(void 0,{staleTime:En}),s=i(()=>e.map(e=>e.id),[e]),l=o({queries:s.map(e=>({queryKey:we(m.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>t.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:En,refetchOnWindowFocus:!1,placeholderData:c}))}),d=i(()=>{let e={};return s.forEach((t,n)=>{let r=l[n]?.data;r&&(e[t]=r.devices)}),e},[s,l.map(e=>e.dataUpdatedAt).join(`|`)]),p=i(()=>{let e=new Map;for(let t of a.data??[])e.set(t.nodeId,t.settings);return e},[a.data]),g=i(()=>e.map(e=>{let t=p.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:gt(t,e.isHub).pipeline,weight:vn(t,`detectWeight`)??1,maxCameras:vn(t,`maxCameras`)}}),[e,p]),_=r.data??[],v=i(()=>sn({nodes:g,loads:_,devicesByNode:d}),[g,_,d]),y=v.reduce((e,t)=>e+(t.attachedCameras??0),0),b=v.reduce((e,t)=>e+(t.activeCameras??0),0),x=r.dataUpdatedAt>0?Date.now()-r.dataUpdatedAt:null;return n(`section`,{className:`rounded-md border border-border bg-surface px-3 py-2.5`,children:[n(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 mb-2`,children:[u(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Node load`}),n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[b,` running · `,y,` attached across `,v.length,` `,v.length===1?`node`:`nodes`]}),u(`span`,{className:`ml-auto text-[10px] text-foreground-subtle/70 tabular-nums`,children:r.data===void 0?`reading…`:`reading ${x===null?`—`:`${Math.round(x/1e3)}s`} old · every ${Tn/1e3}s`})]}),v.length===0?u(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:`No cluster nodes reported yet.`}):u(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:v.map(e=>u(On,{row:e},e.nodeId))})]})}function On({row:e}){let t=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return n(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[n(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[u(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),u(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&u(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:`no detect`}),!e.reported&&e.isOnline&&n(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`,children:[u(tt,{className:`h-2.5 w-2.5`}),` no reading`]}),!e.isOnline&&n(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[u(nt,{className:`h-2.5 w-2.5`}),` offline`]})]}),n(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[u(J,{label:`Running / attached`,value:t,title:`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`}),u(J,{label:`Target share`,value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:`detectWeight normalised over the nodes the balancer actually ranks (online AND detect-enabled).`}),u(J,{label:`Actual share`,value:e.cameraSharePct===null?`—`:`${e.cameraSharePct}%`,title:`Share of the cluster's attached cameras this node carries right now.`}),u(J,{label:`Score · queue`,value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`}),e.capacityPct!==null&&u(J,{label:`Cap fill`,value:`${e.capacityPct}%`,title:`attached / maxCameras.`}),e.avgInferenceTimeMs!==null&&u(J,{label:`Avg infer`,value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:`Mean inference time across this node's attached cameras.`}),e.decodeHwaccel!==null&&u(J,{label:`Decode`,value:e.decodeHwaccel,title:`This node's probed decode hwaccel.`})]}),u(kn,{row:e})]})}function kn({row:e}){return e.devices.length===0?u(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:`Accelerators not read yet.`}):n(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[n(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[u($e,{className:`h-2.5 w-2.5`}),`Accelerators`,e.eligibleDeviceCount===0&&u(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`,children:`none in play · runner default pool`})]}),u(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>u(An,{device:e},e.key))})]})}function An({device:e}){let t=e.exclusion;return n(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[u(U,{className:`h-2.5 w-2.5 shrink-0 ${t===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),u(`span`,{className:`shrink-0 font-medium ${t===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),t===null?n(a,{children:[n(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[e.weightSharePct,`% share`]}),n(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:[`· `,e.sessions,` session`,e.sessions===1?``:`s`,e.maxSessions===null?``:`/${e.maxSessions}`]}),e.queueDepth>0&&n(`span`,{className:`shrink-0 tabular-nums text-amber-400`,children:[`· q`,e.queueDepth]}),e.atCap&&u(`span`,{className:`shrink-0 text-amber-400`,title:`At its maxSessions cap — the balancer skips it until a session ends.`,children:`· at cap`})]}):n(`span`,{className:`truncate text-foreground-subtle/80`,title:an[t],children:[`excluded — `,an[t]]})]})}function J({label:e,value:t,title:r}){return n(`div`,{className:`min-w-0`,title:r,children:[u(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),u(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function jn(){return n(`div`,{className:`space-y-6`,children:[u(Gt,{title:`Cluster cameras`}),u(Dn,{}),n(`div`,{className:`min-w-0`,children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Use the Auto | Pin control to pin a camera to a node, the inference-device select to pin it to an accelerator, or the kebab to move a role; expand the chevron for the per-camera broker drill-down. Cluster load, inference-device weights, and Rebalance live on the Balancer tab.`})]}),u(Dt,{mode:`cluster`})]})}function Mn({capability:e,label:t,hint:r,nodeId:i,active:a,pending:o,layout:s,onToggle:c}){let l=a?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,d=s===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,f=a?H:Ie;return n(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":`${t} capability for ${i}`,title:`${t} — ${r}`,disabled:o,onClick:()=>c(e,!a),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${l} ${d}`,children:[u(f,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),u(`span`,{children:t})]})}function Nn({node:e,emphasis:t=!1}){let r=e.isHub?Ge:U;return n(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[u(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),u(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),n(`div`,{className:`min-w-0`,children:[n(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[u(`span`,{className:`truncate`,children:e.name}),e.isHub&&u(E,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&u(E,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),u(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}t();function Pn({nodeId:e,value:t,detectedHosts:r,status:i,errorMessage:a,onCommit:o}){let[s,c]=l(t??``);d(()=>{c(t??``)},[t]);let f=r[0],p=f===void 0?`auto-detect`:`auto: ${f}`,m=i===`pending`,h=s.trim(),g=h!==(t??``),_=g&&!m,v=()=>{_&&o(e,h.length>0?h:null)};return n(`div`,{className:`flex items-center gap-1.5`,children:[u(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:p,value:s,disabled:m,onChange:e=>c(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&c(t??``)},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`}),n(`button`,{type:`button`,onClick:v,disabled:!_,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[m?u(ot,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):u(H,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&i===`success`&&u(H,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),i===`error`&&u(`span`,{title:a??`Failed to save reachable host`,children:u(Xe,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}function Fn({label:e,children:t}){return n(`div`,{className:`flex items-center justify-between gap-3`,children:[u(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function In({node:e,actions:t}){return n(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[u(Nn,{node:e,emphasis:!0}),u(`div`,{className:`grid grid-cols-2 gap-2`,children:mn.map(n=>u(Mn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:Sn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),u(`div`,{className:`space-y-3 border-t border-border pt-3`,children:u(Fn,{label:`Reachable host`,children:u(Pn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function Ln(){return n(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[n(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),n(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),n(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),n(`span`,{className:`inline-flex items-center gap-1.5`,children:[u(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function Rn({nodes:e,actions:t}){return u(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:n(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[u(`thead`,{children:n(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[u(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),mn.map(e=>u(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),u(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),u(`tbody`,{children:e.map(e=>n(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[u(`td`,{className:`px-4 py-3 align-middle`,children:u(Nn,{node:e})}),mn.map(n=>u(`td`,{className:`px-3 py-3 text-center align-middle`,children:u(Mn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:Sn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),u(`td`,{className:`px-4 py-3 align-middle`,children:u(Pn,{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 zn({role:e,value:t,options:r,pending:i,onChange:a}){return n(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[u(`span`,{className:`text-xs font-semibold text-foreground`,children:bn(e)}),u(`select`,{value:t,disabled:i,onChange:t=>a(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:r.map(e=>u(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),u(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:xn(e)})]})}function Bn({roleValues:e,options:t,pending:r,lowFpsEnabled:i,fpsMinThreshold:a,onRoleChange:o,onLowFpsToggle:s}){return n(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-3`,children:[pn.map(n=>u(zn,{role:n,value:e[n],options:t,pending:r,onChange:o},n)),n(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[u(`input`,{type:`checkbox`,checked:i,disabled:r,onChange:e=>s(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),n(`span`,{className:`flex flex-col gap-0.5`,children:[u(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),n(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,i?`${a} fps`:`disabled`]})]})]})]})}t();function Vn(){let e=s(),{nodes:t}=C(),r=O(void 0),o=R({addonId:cn}),c=R({addonId:ln}),d=R({addonId:dn}),f=()=>wn(e),p=fe({onSuccess:f}),m=z(),h=be({onSuccess:f}),g=ae({onSuccess:f}),[_,v]=l(!1),y=i(()=>{let e=new Map;for(let t of r.data??[])e.set(t.nodeId,t.settings);return e},[r.data]),b=i(()=>t.map(e=>{let t=y.get(e.id),n=gt(t,e.isHub),r=vn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:vn(t,`maxCameras`),reachableHost:yn(t,`reachableHost`),detectedHosts:e.localIps}}),[t,y]),x=b.filter(e=>e.effective.pipeline),S={ingestNode:q(o.data,`ingestNode`,`hub`),recordingNode:q(c.data,un,`hub`),audioNode:q(o.data,`audioNode`,`hub`),motionNode:q(o.data,`motionNode`,`hub`),postProcessingNode:q(d.data,fn,`hub`)},w=i(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...pn.map(e=>S[e]),...e])].filter(e=>e.length>0)},[t,S]),T=_n(o.data,`fpsMinThreshold`,0),E=T>0,D=r.isLoading||o.isLoading||c.isLoading||d.isLoading,k=(e,t,n)=>{p.mutate({agentNodeId:e,[t]:n})},ee=(e,t)=>{if(e===`recordingNode`){g.mutate({addonId:ln,patch:{[un]:t}});return}if(e===`postProcessingNode`){g.mutate({addonId:dn,patch:{[fn]:t}});return}g.mutate({addonId:cn,patch:{[e]:t}})},A=e=>{g.mutate({addonId:cn,patch:{fpsMinThreshold:e?Math.max(1,T):0}})},j=e=>h.variables?.agentNodeId===e?h.isPending?`pending`:h.isError?`error`:h.isSuccess?`success`:`idle`:`idle`,M=e=>j(e)===`error`?Cn(h.error):null,te=async e=>{v(!0);try{for(let t of e)await m.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{v(!1),f()}},N={capabilityPending:p.isPending,onToggleCapability:k,onCommitReachableHost:(e,t)=>h.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:j,reachableHostErrorMessage:M};return n(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[n(`header`,{className:`flex items-start justify-between gap-4`,children:[n(`div`,{className:`space-y-1`,children:[u(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),u(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),D&&u(ot,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),n(`div`,{className:`space-y-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),u(Bn,{roleValues:S,options:w,pending:g.isPending,lowFpsEnabled:E,fpsMinThreshold:T,onRoleChange:ee,onLowFpsToggle:A})]}),n(`div`,{className:`space-y-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Events folder`}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),u(lt,{types:[`eventMedia`]})]}),n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),u(Ln,{})]}),b.length===0?u(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No cluster nodes reporting yet.`}):n(a,{children:[u(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:b.map(e=>u(In,{node:e,actions:N},e.id))}),u(`div`,{className:`hidden @3xl/clustertab:block`,children:u(Rn,{nodes:b,actions:N})})]})]}),n(`div`,{className:`space-y-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),u(Pe,{nodes:x,pending:_,onCommitWeights:e=>void te(e)})]}),n(`div`,{className:`space-y-3`,children:[u(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices`}),x.length===0?u(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No detect-capable nodes — enable detection on a node above to configure its accelerators.`}):u(`div`,{className:`space-y-2`,children:x.map(e=>u(Fe,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline},e.id))})]})]})}t(),t(),t(),t();function Hn(e){if(e===void 0||e.length===0)return[];let t=new Set,n=[];for(let r of e)for(let e of r.capabilities){let i=`${e}\0${r.addonId}`;t.has(i)||(t.add(i),n.push({name:e,addonId:r.addonId}))}return n.toSorted((e,t)=>e.name.localeCompare(t.name))}function Un(e){let t=e.services;return{pid:e.pid,name:e.name,addonId:t?.[0]?.addonId??``,cpu:e.cpuPercent,mem:e.memoryRss,state:e.state,caps:Hn(t)}}function Wn(e){return{nodeId:e.id,isHub:e.isHub,isOnline:e.isOnline,lastSeen:e.lastSeen,identity:{name:e.name,ip:e.localIps?.[0]??``,cpu:e.cpuPercent,mem:e.memoryPercent,platform:e.platform,arch:e.arch},runners:e.processes.map(Un)}}function Gn(e){let t=e.toSorted((e,t)=>{let n=+!!e.isHub;return+!!t.isHub-n}).map(Wn),n=t.find(e=>e.isHub);return n===void 0?{nodes:t,edges:[]}:{nodes:t,edges:t.filter(e=>!e.isHub).map(e=>({id:`hub:${n.nodeId}->${e.nodeId}`,source:n.nodeId,target:e.nodeId,online:e.isOnline&&n.isOnline}))}}t();var Kn=!1;function qn({refreshToken:e}){let t=s(),{nodes:r}=I();i(()=>Gn(r??[]),[r]);let a=se({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return n(`div`,{className:`space-y-6`,children:[u(xt,{refreshToken:e}),u(Vn,{}),Kn,n(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[n(`div`,{className:`min-w-0`,children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Rebalance`}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Recompute the optimal node for every assigned camera from current load + hardware affinity, and migrate the ones no longer on their best node. Pinned cameras never move.`})]}),n(`button`,{type:`button`,onClick:()=>a.mutate(void 0),disabled:a.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[u(Je,{className:`h-3.5 w-3.5`}),a.isPending?`Rebalancing…`:`Rebalance pipelines`]})]})]})}var Jn=[`pipeline-orchestrator`],Yn=`pipeline-analytics`,Xn=`face-gallery`;function Zn({refreshToken:e}){return n(`div`,{className:`space-y-4 max-w-3xl`,children:[u(ct,{nodeId:`hub`,addonIds:Jn,level:`global`,omitSectionIds:[`cluster`],title:`Cluster settings`,description:`Cluster-wide orchestration knobs: load balancer, failover, enrichment models, and the admission settings those models share. Ingest / Audio / Motion / Recording / Post-processing node pickers live on the Balancer tab. Per-camera pipelines live in Device Overrides.`}),u(ct,{nodeId:`hub`,addonIds:[Yn],level:`global`,capability:Xn,title:`Face recognition`,description:`Match threshold, ambiguity margin, and auto-assign floors. Same settings as System → Settings → pipeline-analytics — this page asks the face-gallery cap, it does not store a second copy.`})]})}t();function Qn({refreshToken:e}){let t=s(),{data:r,isLoading:i}=p(),[o,c]=l(null),[d,f]=l(``),[m,h]=l(``),g=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},_=de({onSuccess:()=>{c(null),g()}}),v=Se({onSuccess:g}),y=e=>{c(e.id),f(e.name),h(e.description??``)},b=()=>{c(null),f(``),h(``)},x=()=>{if(!o)return;let e=m.trim();_.mutate({id:o,name:d.trim()||`Untitled`,...e?{description:e}:{}})};if(i)return u(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let S=[...r??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return u(`div`,{className:`space-y-6 max-w-4xl`,children:n(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),u(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[S.length,` template`,S.length===1?``:`s`]})]}),S.length===0?n(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[u(He,{className:`h-6 w-6 opacity-40`}),u(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):u(`ul`,{className:`divide-y divide-border`,children:S.map(e=>{let t=o===e.id;return u(`li`,{className:`px-4 py-3 text-xs`,children:n(`div`,{className:`flex items-start gap-3`,children:[u(`div`,{className:`flex-1 min-w-0`,children:t?n(`div`,{className:`space-y-2`,children:[u(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:d,onChange:e=>f(e.target.value),placeholder:`Template name`,autoFocus:!0}),u(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:m,onChange:e=>h(e.target.value),placeholder:`Description (optional)`})]}):n(a,{children:[u(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&u(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),n(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,n(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),u(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?n(a,{children:[n(`button`,{type:`button`,onClick:x,disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[u(H,{className:`h-3 w-3`}),`Save`]}),n(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[u(at,{className:`h-3 w-3`}),`Cancel`]})]}):n(a,{children:[u(`button`,{type:`button`,onClick:()=>y(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:u(Ve,{className:`h-3 w-3`})}),u(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&v.mutate({id:e.id})},disabled:v.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:u(it,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}var $n=`pipeline-orchestrator`,er=200;function tr(){return n(`div`,{className:`flex flex-col gap-3`,children:[n(`div`,{children:[u(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),u(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`})]}),u(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:u(S,{addonId:$n,limit:er,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}t();var nr=[{id:`assignments`,label:`Assignments`},{id:`balancer`,label:`Balancer`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function rr({refreshToken:e}){let[t,r]=l(`assignments`);return n(`div`,{className:`flex flex-col h-full`,children:[n(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[u(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),u(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Per-camera assignments, the load balancer (live load + inference-device weights), cluster-wide settings, and the pipeline template library.`})]}),u(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:nr.map(e=>u(`button`,{type:`button`,onClick:()=>r(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),n(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&u(jn,{}),t===`balancer`&&u(qn,{refreshToken:e}),t===`settings`&&u(Zn,{refreshToken:e}),t===`templates`&&u(Qn,{refreshToken:e}),t===`logs`&&u(tr,{})]})]})}var ir=`armed:`;function ar(e){return e.assignment.reasons.detection?.startsWith(ir)===!0}function or(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!ar(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function sr(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&&!ar(e)&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});let s=e.degraded??[];if(s.length>0){let e=[...new Set(s.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:`Could not read ${e} for this camera — those blocks are unknown, not empty (a switch read that failed does NOT mean nothing is switched off)`})}for(let e of o?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function cr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function lr(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ur(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function dr(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var fr={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 pr(e){if(!cr(e)||!Array.isArray(e.sections))return fr;let t=Te(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)dr(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:lr(n(`detectionFps`)),motionSources:ur(n(`motionSources`)),motionFps:lr(n(`motionFps`)),motionCooldownMs:lr(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 mr(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(...mr(r.children,t+1));return n}function X({title:e,children:t}){return n(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[u(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),u(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:r=!1}){return n(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[u(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),u(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),r&&u(hr,{})]})}function hr(){return u(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:`Device-level override active`,"aria-label":`Device-level override active`,role:`img`})}var gr={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return u(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${gr[e]}`,children:t})}function $({children:e}){return u(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function _r({icon:e,label:t,nodeId:r,pinned:i,reason:o,overridden:s}){return n(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[u(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),u(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),r===null?u(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):n(a,{children:[u(`span`,{className:`font-mono text-foreground truncate`,title:r,children:r}),i?n(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[u(dt,{className:`h-2.5 w-2.5`}),` manual`]}):n(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,o!==void 0&&o.length>0?o:`capacity`]}),s&&u(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function vr({assignment:e,settings:t,onlineNodes:r,pinPending:i,onDetectionPinChange:a}){let o=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,s=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...r.map(e=>e.id)])];return n(X,{title:`Where it runs`,children:[u(_r,{icon:U,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),u(_r,{icon:rt,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),u(_r,{icon:ze,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),u(_r,{icon:Ue,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),u(`div`,{className:`mt-1.5`,children:n(`select`,{value:o,disabled:i,"aria-label":`Detection placement pin`,onChange:e=>a(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[u(`option`,{value:`auto`,children:`Auto (load balanced)`}),s.map(e=>n(`option`,{value:e,children:[`Pin detection → `,r.find(t=>t.id===e)?.name??e]},e))]})})]})}function yr(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function br(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function xr(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function Sr({streams:e,brokerProfiles:t,settings:r,motionEnabled:i,motionFpsLive:o}){let s=br(t,r.detectionStreamProfile),c=br(t,r.motionStreamProfile),l=r.motionSources.includes(`analyzer`);return n(X,{title:`Streams & motion`,children:[n(Z,{label:`Detect stream`,overridden:r.overriddenKeys.has(`detectionStreamProfile`),children:[r.detectionStreamProfile??`—`,s!==void 0&&` · ${s.width}×${s.height} ${s.codec}`]}),u(Z,{label:`Detect FPS`,overridden:r.overriddenKeys.has(`detectionFps`),children:xr(r.detectionFps)}),n(Z,{label:`Motion src`,overridden:r.overriddenKeys.has(`motionSources`),children:[r.motionSources.length>0?r.motionSources.join(` + `):`none`,i===!1&&` · inactive`]}),l&&n(a,{children:[n(Z,{label:`Motion stream`,overridden:r.overriddenKeys.has(`motionStreamProfile`),children:[r.motionStreamProfile??`—`,c!==void 0&&` · ${c.width}×${c.height} ${c.codec}`]}),n(Z,{label:`Motion FPS`,overridden:r.overriddenKeys.has(`motionFps`),children:[xr(r.motionFps),o!==null&&` · live ${o.toFixed(1)}`]})]}),u(Z,{label:`Cooldown`,overridden:r.overriddenKeys.has(`motionCooldownMs`),children:r.motionCooldownMs===null?`default`:`${r.motionCooldownMs/1e3}s`}),u(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?u($,{children:`No streams registered`}):e.map(e=>n(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[u(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,yr(e)]},e.camStreamId))})]})}function Cr({steps:e,audioModelId:t,audioEnabled:r,audioMode:i}){return n(X,{title:`Pipeline steps`,children:[e===void 0?u($,{children:`Resolving…`}):e.length===0?u($,{children:`No steps configured`}):u(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>u(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:n(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&u(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&n(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),u(`div`,{className:`mt-1`,children:n(Z,{label:`Audio class.`,children:[i??`—`,r!==null&&(r?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var wr={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Tr({detection:e,live:t,detectionMode:r,modeOverridden:i}){if(e===null)return n(X,{title:`Detection runtime`,children:[u(Z,{label:`Mode`,overridden:i,children:r??`—`}),u($,{children:`Detection stage inactive or unreachable`})]});let a=t?.phase??e.phase,o=t?.actualFps??e.actualFps,s=t?.configuredFps??e.configuredFps,c=t?.avgInferenceTimeMs??e.avgInferenceMs,l=t?.queueDepth??e.queueDepth,d=B(a),f=a===`active`&&o===0;return n(X,{title:`Detection runtime`,children:[n(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[n(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${d.badgeClass}`,children:[u(ue,{phase:a,className:`h-2.5 w-2.5`}),d.label]}),t!==void 0&&u(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),u(Z,{label:`Mode`,overridden:i,children:r??`—`}),n(Z,{label:`FPS`,children:[u(`span`,{className:f?`text-danger font-semibold`:``,children:o.toFixed(1)}),n(`span`,{className:`text-foreground-subtle`,children:[` / `,s.toFixed(0),` configured`]})]}),n(Z,{label:`Inference`,children:[c.toFixed(0),` ms`,l>0&&n(`span`,{className:`text-warning`,children:[` · queue `,l]}),t!==void 0&&t.droppedFrames>0&&n(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),n(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),n(Z,{label:`Provisioning`,children:[u(Q,{tone:wr[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&n(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function Er({broker:e}){return e===null?u(X,{title:`Stream broker`,children:u($,{children:`Broker stage inactive or unreachable`})}):n(X,{title:`Stream broker`,children:[e.profiles.length===0?u($,{children:`No broker profiles`}):u(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,r=t&&e.inFps===0;return n(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[u(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${r?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),u(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),n(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),n(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),n(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),n(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[n(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),n(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function Dr({decoder:e,detectionActive:t}){if(e===null)return u(X,{title:`Decoder`,children:u($,{children:`Decoder stage inactive or unreachable`})});let r=t&&e.shm.framesWritten===0;return n(X,{title:`Decoder`,children:[u(Z,{label:`Node`,children:e.nodeId}),u(Z,{label:`Sessions`,children:e.sessionCount}),n(Z,{label:`SHM frames`,children:[u(`span`,{className:r?`text-danger font-semibold`:``,children:e.shm.framesWritten}),u(`span`,{className:`text-foreground-subtle`,children:` written`})]}),n(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&n(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),n(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&u(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}t();var Or=`pipeline-orchestrator`,kr={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Ar={healthy:`Healthy`,idle:`Idle`,error:`Error`};function jr({problems:e}){return u(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>n(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[u(tt,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),u(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function Mr({deviceId:e,name:t,online:r,status:a,live:o,onlineNodes:c}){let l=s(),{data:d}=le({addonId:Or,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:f}=ye({deviceId:e},{staleTime:3e4}),p=i(()=>pr(d),[d]),m=i(()=>f===void 0?void 0:mr(f.steps),[f]),h=i(()=>a===void 0?[]:sr(a),[a]),g=()=>{l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),l.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},_=ee({onSuccess:g}),v=pe({onSuccess:g}),y=t=>{t===`auto`?v.mutate({deviceId:e}):_.mutate({deviceId:e,agentNodeId:t})},b=a===void 0?`idle`:or(a),x=h.some(e=>e.severity===`error`),S=h.length>0,C=x?`border-danger/50`:S?`border-warning/40`:`border-border`;return n(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${C} bg-background overflow-hidden`,children:[n(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[u(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${x?`bg-danger`:kr[b]}`,title:x?`Error`:Ar[b],"aria-label":x?`Error`:Ar[b],role:`img`}),u(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),n(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!r&&u(Q,{tone:`danger`,children:`offline`}),n(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[p.detectionMode!==null&&u(Q,{tone:p.detectionMode===`disabled`?`warning`:p.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:p.detectionMode===`disabled`?`detection off`:p.detectionMode}),a?.recording!=null&&(a.recording.active?n(Q,{tone:`danger`,title:`Recording (${a.recording.mode})`,children:[u(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):a.recording.mode!==`off`&&n(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,a.recording.mode]}))]})]}),h.length>0&&u(jr,{problems:h}),a===void 0?u(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`}):n(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[u(vr,{assignment:a.assignment,settings:p,onlineNodes:c,pinPending:_.isPending||v.isPending,onDetectionPinChange:y}),u(Tr,{detection:a.detection,live:o,detectionMode:p.detectionMode,modeOverridden:p.overriddenKeys.has(`detectionMode`)}),u(Cr,{steps:m,audioModelId:f?.audio?.modelId??null,audioEnabled:a.audio?.enabled??f?.audio?.enabled??null,audioMode:p.audioMode}),u(Sr,{streams:a.source.streams,brokerProfiles:a.broker?.profiles,settings:p,motionEnabled:a.motion?.enabled??null,motionFpsLive:a.motion?.fps??null}),u(Er,{broker:a.broker}),u(Dr,{decoder:a.decoder,detectionActive:a.detection?.phase===`active`})]})]})}t();var Nr=5e3,Pr=1e4,Fr=5e3;function Ir(e){let t=s(),{data:n,isLoading:r}=Me(),{data:a,isLoading:o}=te({},{refetchInterval:Nr}),{nodes:c}=C();d(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[u,f]=l(new Map);k(Ee.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),d(()=>{if(u.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Pr,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Fr);return()=>clearInterval(e)},[u.size]);let p=i(()=>{let e=new Map;for(let t of a??[])e.set(t.deviceId,t);return e},[a]);return{rows:i(()=>(n??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[n,p]),liveMetrics:u,onlineNodes:i(()=>(c??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[c]),isLoading:r||o}}t();function Lr({refreshToken:e}){let{rows:t,liveMetrics:r,onlineNodes:a,isLoading:o}=Ir(e),s=i(()=>[...t.map(e=>{let t=e.status===void 0?[]:sr(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[t]),c=i(()=>{let e=0,t=0;for(let n of s)(n.errorCount>0||n.warningCount>0)&&(t+=1),(r.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:s.length,active:e,issues:t}},[s,r]);return o&&t.length===0?u(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?u(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):u(`div`,{className:`h-full overflow-y-auto`,children:n(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[n(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[n(`span`,{children:[u(`span`,{className:`font-semibold text-foreground`,children:c.total}),` cameras`]}),n(`span`,{children:[u(`span`,{className:`font-semibold text-success`,children:c.active}),` actively inferring`]}),n(`span`,{children:[u(`span`,{className:`font-semibold ${c.issues>0?`text-danger`:`text-foreground`}`,children:c.issues}),` `,`with issues`]}),u(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),s.map(({row:e})=>u(Mr,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:r.get(e.deviceId),onlineNodes:a},e.deviceId))]})})}t();var Rr=`__cluster__`;function zr(e){return e===`cameras`?`cameras`:`nodes`}function Br(){let[e,t]=et(),r=zr(e.get(`view`)),i=e.get(`node`)??`__cluster__`,[o,s]=l(0),[c,f]=l(!1);return d(()=>{r===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:Rr},{replace:!0})},[r,e,t]),n(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[n(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[n(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[u(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:i},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,r===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),u(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,r===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),u(`div`,{className:`flex items-center gap-2`,children:n(`button`,{type:`button`,onClick:()=>s(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[u(We,{className:`h-3.5 w-3.5`}),`Refresh`]})})]}),r===`nodes`&&n(`button`,{type:`button`,onClick:()=>f(e=>!e),"aria-expanded":c,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[n(`span`,{children:[c?`Hide`:`Show`,` node list`]}),u(st,{className:[`h-4 w-4 transition-transform`,c?`rotate-180`:``].join(` `)})]}),u(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:r===`nodes`?n(a,{children:[u(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:u(vt,{selectedNodeId:i,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),f(!1)},refreshToken:o})}),u(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:i===`__cluster__`?u(rr,{refreshToken:o}):u(nn,{nodeId:i,refreshToken:o})})]}):u(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:u(Lr,{refreshToken:o})})})]})}export{Br as PipelinePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{J as l,Q as u}from"./player-overlays-DnMxj3iS.js";import{$o as d,$s as f,Bo as p,Fo as m,Io as h,Jo as g,Js as _,Kr as v,Mo as y,No as b,Oa as x,Po as S,Qo as C,Ro as w,Sa as T,Xo as E,Za as D,Zo as O,Zs as k,_a as A,_n as j,an as M,as as N,bn as ee,es as te,is as ne,ma as re,ns as ie,nt as ae,os as oe,qt as P,rs as se,tn as ce,to as le,ts as ue,tt as F,zo as de}from"./src-C9Is_nwm.js";import{Ut as I}from"./src-D4B8ZNXP.js";import{t as fe}from"./circle-x-BJOy6Vqs.js";import{t as pe}from"./download-Brjekdgb.js";import{t as L}from"./hard-drive-B0b-qzJJ.js";import{H as R,J as z,N as B,a as V,k as H,o as U,q as me,r as he,w as W}from"./index-vAjGJjNh.js";import{t as ge}from"./AdminPage-CCD07UMs.js";import{r as _e}from"./authed-media-BPd_L9jr.js";import{t as ve}from"./DeviceAggregateSection-BEIHuj3x.js";import{t as ye}from"./AdminTabs-OUb2J4UV.js";import{t as be}from"./StorageLocationsPanel-BoO_ye8J.js";import{t as G}from"./format-size-DIxKXxtj.js";var xe=z(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),Se=z(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]),Ce=z(`settings-2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);t();var we=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],Te={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Ee={columnKey:`at`,dir:`desc`};function De(e){return new Date(e).toLocaleString()}function Oe(){let[e,t]=o(`all`),{data:a,isLoading:c,isError:l}=de({},{refetchOnWindowFocus:!1}),{data:u,isLoading:d,isError:f}=T({},{refetchOnWindowFocus:!1}),{data:p}=v({isCamera:!0,projection:`slim`}),m=r(()=>{let e=new Map;for(let t of p??[])e.set(t.id,t.name);return e},[p]),h=r(()=>{let t=[...a??[],...u??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[a,u,e]),g=r(()=>{let t=[];return l&&e!==`events`&&t.push(`Recordings`),f&&e!==`recording`&&t.push(`Events`),t},[l,f,e]),_=r(()=>[{key:`at`,header:`When`,nowrap:!0,sortValue:e=>e.at,render:e=>s(`span`,{className:`text-foreground-subtle tabular-nums`,children:De(e.at)})},{key:`domain`,header:`Domain`,sortValue:e=>e.domain,render:e=>s(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Te[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,sortValue:e=>e.op,render:e=>s(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,sortValue:e=>e.reason,render:e=>s(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,sortValue:e=>e.deviceId===null?`cluster`:m.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?s(`span`,{className:`text-foreground-subtle`,children:`cluster`}):s(`span`,{className:`text-foreground`,children:m.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>s(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>s(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?G(e.bytesReclaimed):`—`})}],[m]),y=c||d;return n(`div`,{className:`flex flex-col gap-4`,children:[s(`div`,{className:`flex items-center gap-1`,children:we.map(n=>s(`button`,{onClick:()=>t(n.value),className:`rounded px-2 py-1 text-xs font-medium ${e===n.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n.label},n.value))}),y&&h.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(W,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):h.length===0?g.length>0?s(P,{icon:V,title:`Activity could not be read`,description:`The ${g.join(` and `)} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`}):s(P,{icon:me,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):n(i,{children:[g.length>0&&n(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[s(V,{className:`h-3 w-3 shrink-0`}),g.join(` and `),` did not answer — rows from`,` `,g.length===1?`that domain`:`those domains`,` are missing below.`]}),s(F,{columns:_,rows:h,rowKey:e=>e.id,minWidthPx:720,mobileMode:`scroll`,maxBodyHeight:ae,defaultSort:Ee})]})]})}t();function ke(){let e=v({isCamera:!0,projection:`slim`}),t=r(()=>(e.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[e.data]),[i,a]=o(null),c=i??t[0]?.id??null;return!e.isLoading&&t.length===0?s(P,{icon:R,title:`No cameras`,description:`Add a camera first.`}):n(`div`,{className:`space-y-3`,children:[n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Per-camera recording & retention`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Recording mode, schedule bands and the retention policy for one camera — the same controls as the camera's own Recording tab. Retention is one policy over footage and analytics; per-camera event deletion lives on the Events tab.`})]}),n(`div`,{className:`flex items-center gap-2`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),s(`select`,{value:c??``,onChange:e=>a(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:t.map(e=>s(`option`,{value:e.id,children:e.name},e.id))})]}),c!==null&&s(ce,{deviceId:c,children:s(ve,{deviceId:c,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},c)]})}t();var Ae=`pipeline-analytics`;function je(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 Me(){let e=a(),{nodes:t}=_(),{data:i,isLoading:o}=j({addonId:Ae}),c=je(i),l=ee({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),s(`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.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?s(W,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):s(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Ae,patch:{postProcessingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>s(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&s(W,{className:`h-4 w-4 animate-spin text-primary`})]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),s(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),s(be,{types:[`eventMedia`]})]})]})}t();var Ne=[[`pipelineAnalytics`]],Pe=1440*60*1e3;function Fe(e,t){return t.get(e)??`Removed camera #${String(e)}`}var Ie=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function Le(){let t=a(),i=M(),[c,u]=o(30),[d,f]=o(null),{data:p,isLoading:m}=A({},{refetchOnWindowFocus:!1}),{data:h}=v({isCamera:!0,projection:`slim`}),g=r(()=>{let e=new Map;for(let t of h??[])e.set(t.id,t.name);return e},[h]),_=e(()=>{t.invalidateQueries({queryKey:Ne})},[t]),y=x({onSuccess:_}),b=re(),S=e(async()=>{await i({title:`Prune events older than ${String(c)} day${c===1?``:`s`}?`,message:`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`,confirmLabel:`Prune events`,variant:`danger`})&&y.mutate({olderThanMs:Date.now()-c*Pe,reason:`retention`})},[i,y,c]),C=e(async e=>{let t=Fe(e.deviceId,g);if(await i({title:`Delete all events for ${t}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${G(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})){f(null);try{let n=await b.mutateAsync({deviceId:e.deviceId});_();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){f(`0 events deleted for ${t}. Media still listed (${G(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}f(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){f(e instanceof Error?e.message:String(e))}}},[i,b,g,_]),w=r(()=>[{key:`camera`,header:`Camera`,render:e=>s(`span`,{className:`text-foreground`,children:Fe(e.deviceId,g)})},{key:`rows`,header:`Events`,align:`right`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:`Media`,align:`right`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums`,children:G(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`button`,{onClick:()=>{C(e)},disabled:b.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all events for this camera`,children:[s(U,{className:`h-3 w-3`}),`Delete`]})}],[g,C,b.isPending]);return m&&!p?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(W,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):p?n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[s(l,{label:`Total events`,icon:s(B,{className:`h-3 w-3`}),footer:`across ${String(p.devices.length)} camera${p.devices.length===1?``:`s`}`,children:p.totalRows.toLocaleString()}),s(l,{label:`Event media on disk`,children:G(p.totalBytes)})]}),n(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[s(`span`,{className:`text-foreground-subtle`,children:`Prune events older than`}),s(`select`,{value:c,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Ie.map(e=>s(`option`,{value:e.days,children:e.label},e.days))}),n(`button`,{onClick:()=>{S()},disabled:y.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,children:[y.isPending?s(W,{className:`h-3 w-3 animate-spin`}):s(Se,{className:`h-3 w-3`}),`Prune now`]})]}),p.devices.length===0?s(P,{icon:B,title:`No stored events`,description:`No camera has persisted events yet.`}):s(F,{columns:w,rows:[...p.devices],rowKey:e=>e.deviceId,minWidthPx:480}),d===null?null:s(`p`,{className:d.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:d})]}):s(P,{icon:B,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}function Re(){return n(`div`,{className:`flex flex-col gap-8`,children:[n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Event store`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`}),s(`div`,{className:`mt-3`,children:s(Le,{})})]}),n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node & folders`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that writes event crops, and the storage location they land in.`}),s(`div`,{className:`mt-3`,children:s(Me,{})})]})]})}t();var ze=[`high`,`mid`,`low`],Be=[{value:1,label:`Real time (1×)`},{value:2,label:`2×`},{value:4,label:`4×`},{value:8,label:`8×`},{value:16,label:`16×`}],Ve=10080*60*1e3;function He(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Ue({onClose:e,onCreated:t}){let i=v({isCamera:!0,projection:`slim`}),a=r(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[c,l]=o(``),[u,d]=o(`high`),[f,p]=o(He(60)),[m,h]=o(He(0)),[g,_]=o(1),[y,b]=o(!0),[x,C]=o(``),[w,T]=o(null),E=c===``?a[0]?.id??null:c,D=new Date(f).getTime(),O=new Date(m).getTime(),k=Number.isFinite(D)&&Number.isFinite(O)&&D<O,A=S({onSuccess:()=>{t(),e()},onError:e=>T(e instanceof Error?e.message:String(e))});return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:e,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[s(H,{className:`h-3.5 w-3.5`}),`New export`]}),s(`button`,{onClick:e,className:`text-foreground-subtle hover:text-foreground`,children:s(he,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-3`,children:[n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),s(`select`,{value:E??``,onChange:e=>l(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:a.map(e=>s(`option`,{value:e.id,children:e.name},e.id))})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Profile`}),s(`select`,{value:u,onChange:e=>d(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:ze.map(e=>s(`option`,{value:e,children:e},e))})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`From`}),s(`input`,{type:`datetime-local`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`To`}),s(`input`,{type:`datetime-local`,value:m,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Speed`}),s(`select`,{value:g,onChange:e=>_(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:Be.map(e=>s(`option`,{value:e.value,children:e.label},e.value))})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Title (optional)`}),s(`input`,{type:`text`,value:x,onChange:e=>C(e.target.value),placeholder:`e.g. courier at the gate`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),n(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:y,disabled:g!==1,onChange:e=>b(e.target.checked),className:`accent-primary`}),`Include audio`,g===1?``:` (real-time only)`]}),!k&&s(`p`,{className:`text-[11px] text-danger`,children:`"From" must be before "To".`}),w&&s(`p`,{className:`text-[11px] text-danger`,children:w})]}),n(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[s(`button`,{onClick:e,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Cancel`}),s(`button`,{onClick:()=>{if(E===null||!k)return;T(null);let e=x.trim();A.mutate({deviceId:E,profile:u,fromMs:D,toMs:O,options:{includeAudio:y,maxLifeMs:Ve,deleteAfterDownload:!1,...g===1?{}:{speed:g},...e.length>0?{title:e}:{}}})},disabled:E===null||!k||A.isPending,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:A.isPending?`Queuing…`:`Create export`})]})]})})}function We(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function Ge(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function Ke(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${Ge(e)} · ${o}`}function qe(e,t){let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/6e4);if(r<60)return`in ${String(r)}m`;let i=Math.floor(r/60);return i<24?`in ${String(i)}h`:`in ${String(Math.floor(i/24))}d`}function Je(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}t();var Ye=[[`recordingExport`]],Xe={queued:{cls:`bg-muted text-foreground-subtle`,label:`queued`},rendering:{cls:`bg-primary/10 text-primary`,label:`rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,label:`ready`},failed:{cls:`bg-danger/10 text-danger`,label:`failed`},expired:{cls:`bg-muted text-foreground-subtle`,label:`expired`},deleted:{cls:`bg-muted text-foreground-subtle`,label:`deleted`}};function Ze(){let{data:e,isLoading:t}=h({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:n}=k(I.RecordingExportProgress,e=>e.exportId),{map:i}=k(I.RecordingExportCompleted,e=>e.exportId),{map:a}=k(I.RecordingExportFailed,e=>e.exportId);return{rows:r(()=>Je(e??[],n,i,a),[e,n,i,a]),isLoading:t}}function Qe(e){let[t,n]=o(()=>Date.now());return c(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function $e(){let t=a(),[i,c]=o(!1),l=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},d=M(),f=u().trpcClient,p=Qe(6e4),{rows:h,isLoading:g}=Ze(),{data:_}=v({isCamera:!0,projection:`slim`}),y=r(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),x=e(()=>{t.invalidateQueries({queryKey:Ye})},[t]),S=b({onSuccess:x}),C=m({onSuccess:x}),[w,T]=o(null),E=e(async e=>{T(e.id);try{let{url:t}=await f.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await _e(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),x()}finally{T(null)}},[f,x]),D=e(async e=>{await d({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&S.mutate({exportId:e.id})},[d,S]),O=e(async e=>{await d({title:`Delete this export?`,message:`Permanently removes the rendered file and its history row.`,confirmLabel:`Delete`,variant:`danger`})&&C.mutate({exportId:e.id})},[d,C]),k=r(()=>[{key:`camera`,header:`Camera`,render:e=>s(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums`,children:Ke(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>s(`span`,{className:`text-foreground-subtle`,children:We(e.options)})},{key:`state`,header:`State`,render:e=>{let t=Xe[e.state];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${t.cls}`,children:[t.spin&&s(W,{className:`h-2.5 w-2.5 animate-spin`}),t.label,e.state===`rendering`&&e.progressPct!==null&&n(`span`,{className:`tabular-nums`,children:[e.progressPct,`%`]})]})}},{key:`expiry`,header:`Expires`,nowrap:!0,render:e=>e.state===`deleted`?s(`span`,{className:`text-foreground-subtle`,children:`—`}):s(`span`,{className:`text-foreground-subtle tabular-nums`,children:qe(e.expiresAt,p)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:G(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:e=>{let t=e.state===`ready`,r=e.state===`queued`||e.state===`rendering`,i=e.state!==`deleted`;return n(`div`,{className:`flex items-center justify-end gap-1`,children:[t&&n(`button`,{onClick:()=>{E(e)},disabled:w===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:`Download MP4`,children:[w===e.id?s(W,{className:`h-3 w-3 animate-spin`}):s(pe,{className:`h-3 w-3`}),`Download`]}),r&&n(`button`,{onClick:()=>{D(e)},disabled:S.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Cancel render`,children:[s(fe,{className:`h-3 w-3`}),`Cancel`]}),i&&s(`button`,{onClick:()=>{O(e)},disabled:C.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete export`,children:s(U,{className:`h-3 w-3`})})]})}}],[y,p,w,S.isPending,C.isPending,E,D,O]);return g&&h.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(W,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):n(`div`,{className:`space-y-3`,children:[s(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>c(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[s(H,{className:`h-3.5 w-3.5`}),`New export`]})}),h.length===0?s(P,{icon:H,title:`No exports yet`,description:`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`}):s(F,{columns:k,rows:h,rowKey:e=>e.id,minWidthPx:720}),i&&s(Ue,{onClose:()=>c(!1),onCreated:l})]})}var et=`inline-flex w-fit 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 disabled:opacity-50`;function tt(e){return e===null?`absent`:e.providers.length>0?`present`:`absent`}function nt(e){let t=f.capabilities.getCapability.useQuery({name:e});return t.status===`pending`?`pending`:t.status===`error`?`unknown`:tt(t.data)}t();var rt=`storage-migration`,it=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function at(e){return[`${e.orphansReclaimed} orphan rows (${G(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${G(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${G(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function ot(){return nt(rt)===`present`?s(st,{}):null}function st(){let e=M(),[t,r]=o(!1),[i,a]=o(null),c=d({},{refetchInterval:2e3}),l=c.data??null,u=l!==null&&it.has(l.phase),f=C(),p=O(),m=async()=>{if(await e({title:`Run storage cleanup?`,message:t?`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`:`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`,confirmLabel:`Run cleanup`,variant:`danger`})){a(null);try{await f.mutateAsync({includeDebugMedia:t}),await c.refetch()}catch(e){a(e instanceof Error?e.message:String(e))}}},h=async()=>{if(l&&await e({title:`Cancel cleanup?`,message:`Stops after the current step. Work already done stays done.`,confirmLabel:`Cancel cleanup`,variant:`danger`}))try{await p.mutateAsync({jobId:l.jobId}),await c.refetch()}catch{}};return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Cleanup`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`}),n(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[s(`input`,{type:`checkbox`,checked:t,disabled:u,onChange:e=>{r(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),s(`span`,{children:`Also remove debug media (motion stills and track filmstrips)`})]}),n(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[n(`button`,{type:`button`,disabled:u||f.isPending,onClick:()=>{m()},className:et,children:[(u||f.isPending)&&s(W,{className:`h-3 w-3 animate-spin`}),s(U,{className:`h-3 w-3`}),`Run cleanup`]}),u&&s(`button`,{type:`button`,onClick:()=>{h()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:`Cancel`})]}),i&&s(`p`,{className:`mt-2 text-[11px] text-danger`,children:i}),l&&n(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[n(`p`,{className:`text-xs text-foreground`,children:[`Phase: `,s(`span`,{className:`font-medium`,children:l.phase}),u&&s(W,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),l.detail&&s(`p`,{className:`text-[11px] text-foreground-subtle`,children:l.detail}),s(`p`,{className:`text-[11px] text-foreground-subtle`,children:at(l)}),l.error&&s(`p`,{className:`text-[11px] text-danger`,children:l.error})]})]})}t();var ct=2e3;function lt(){let e=M(),t=a(),r=le(),i=D(void 0,{refetchInterval:e=>e.state.data?.state===`running`?ct:!1}),o=i.data,l=o?.state===`running`,u=l||r.isPending;c(()=>{o?.state!==`done`||o.finishedAtMs===null||(t.invalidateQueries({queryKey:[[`recording`]]}),t.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[o?.state,o?.finishedAtMs,t]);let d=async()=>{await e({title:`Reconcile storage from disk?`,message:`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`,confirmLabel:`Reconcile`,variant:`warning`})&&(await r.mutateAsync(),await i.refetch())},f=l?o.total>0?`Reconciling ${String(o.completed)}/${String(o.total)}…`:`Reconciling…`:r.isPending?`Reconciling…`:`Reconcile from disk`;return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Disk reconcile`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Deletes database rows whose files are gone. Enrolled identities stay.`}),n(`div`,{className:`mt-3 flex flex-col gap-2`,children:[n(`button`,{type:`button`,onClick:()=>void d(),disabled:u,className:`inline-flex w-fit 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 disabled:opacity-50`,children:[u?s(W,{className:`h-3.5 w-3.5 animate-spin`}):s(L,{className:`h-3.5 w-3.5`}),f]}),o?.state===`done`?n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Last run: `,String(o.completed),` camera(s) — dropped `,String(o.tracks),` tracks,`,` `,String(o.events),` events, `,String(o.mediaDropped),` media`,o.failed.length>0?`, ${String(o.failed.length)} failed (${o.failed.join(`, `)})`:``,`.`]}):null,o?.state===`error`&&o.error!==null?n(`p`,{className:`text-[11px] text-destructive`,children:[`Reconcile failed: `,o.error]}):null]})]})}var K=1e3,q=60*K,J=60*q;function Y(e){return e.toLocaleString(`en-US`)}function ut(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=J){let t=Math.floor(e/J),n=Math.round(e%J/q);return`${t.toString()}h ${n.toString()}m`}if(e>=q){let t=Math.floor(e/q),n=Math.round(e%q/K);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/K)).toString()}s`}function dt(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${Y(e.filesMoved)} files`:`${Y(e.filesMoved)} / ${Y(e.filesTotal)} files`,r=e.filesTotal===null||e.filesTotal===0?null:Math.min(1,e.filesMoved/e.filesTotal),i=t>0&&e.filesMoved>0,a=i?`${G(e.bytesMoved/t*K)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${ut(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${G(e.bytesMoved)} moved`,rate:a,eta:s}}function ft(e){let t=dt(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}t();var pt=`storage-migration`,X=[{id:`recordings`,label:`Recordings`,locationType:`recordings`},{id:`recordingsLow`,label:`Low-res recordings`,locationType:`recordingsLow`},{id:`eventMedia`,label:`Event media`,locationType:`eventMedia`}],mt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function ht(){let e=nt(pt);return e===`pending`?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(W,{className:`h-4 w-4 animate-spin`}),`Checking whether storage migration is installed…`]}):e===`unknown`?s(P,{icon:V,title:`Couldn't check whether storage migration is installed`,description:`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`}):e===`absent`?s(P,{icon:xe,title:`Storage migration not installed`,description:`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`}):s(gt,{})}function gt(){let e=M(),{data:t}=g({}),[i,a]=o({}),[c,l]=o({}),[u,d]=o(null),[f,p]=o(null),m=r(()=>{let e=new Map;for(let n of t??[]){let t=e.get(n.type);t?t.push(n):e.set(n.type,[n])}return e},[t]),h=r(()=>{let e=new Map;for(let n of t??[])n.isDefault&&e.set(n.type,n.id);return e},[t]),_=oe({},{refetchInterval:2e3}),v=_.data??null,y=v!==null&&mt.has(v.phase),b=r(()=>{let e={};for(let t of X){let n=i[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[i]),x=r(()=>{let e={};for(let t of X){if(!i[t.id])continue;let n=c[t.id]??h.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[i,c,h]),S=r(()=>({destinations:b??{},...x?{sources:x}:{}}),[b,x]),C=se(S,{enabled:!1,retry:!1}),w=N(),T=E(),D=async()=>{if(!b)return;p(null);let e=await C.refetch();if(e.error){p(e.error instanceof Error?e.error.message:String(e.error));return}d(e.data??null)},O=async()=>{if(b&&await e({title:`Start storage migration?`,message:`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`,confirmLabel:`Start migration`,variant:`danger`})){p(null);try{await w.mutateAsync(S),d(null),await _.refetch()}catch(e){p(e instanceof Error?e.message:String(e))}}},k=async()=>{if(v&&await e({title:`Cancel migration?`,message:`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`,confirmLabel:`Cancel migration`,variant:`danger`}))try{await T.mutateAsync({jobId:v.jobId}),await _.refetch()}catch{}};return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[s(xe,{className:`h-3.5 w-3.5`}),`Storage migration`]}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`}),s(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:X.map(e=>{let t=m.get(e.locationType)??[],r=h.get(e.locationType)??``;return n(`div`,{className:`space-y-2`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.label}),n(`div`,{className:`space-y-1`,children:[n(`label`,{htmlFor:`migration-from-${e.id}`,className:`text-[10px] text-foreground-subtle`,children:[e.label,` from`]}),s(`select`,{id:`migration-from-${e.id}`,value:c[e.id]??r,onChange:t=>{let n=t.target.value;l(t=>({...t,[e.id]:n}))},disabled:y,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:t.map(e=>n(`option`,{value:e.id,children:[e.displayName,e.isDefault?` (default)`:``]},e.id))})]}),n(`div`,{className:`space-y-1`,children:[n(`label`,{htmlFor:`migration-dest-${e.id}`,className:`text-[10px] text-foreground-subtle`,children:[e.label,` to`]}),n(`select`,{id:`migration-dest-${e.id}`,value:i[e.id]??``,onChange:t=>{let n=t.target.value;a(t=>({...t,[e.id]:n}))},disabled:y,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[s(`option`,{value:``,children:`— skip —`}),t.map(e=>s(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},e.id)})}),f&&s(`p`,{className:`mt-2 text-[11px] text-danger`,children:f}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[n(`button`,{type:`button`,onClick:()=>{D()},disabled:!b||C.isFetching||y,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isFetching&&s(W,{className:`h-3 w-3 animate-spin`}),`Plan`]}),n(`button`,{type:`button`,onClick:()=>{O()},disabled:!b||w.isPending||y,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[w.isPending&&s(W,{className:`h-3 w-3 animate-spin`}),`Start migration`]})]}),u&&s(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:u.moves.length===0?s(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:`Nothing to move — selected destinations match the current defaults.`}):u.moves.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]},`${e.storageClass}-${e.toLocationId}`))}),v&&n(`div`,{className:`mt-4 border-t border-border pt-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[s(`h4`,{className:`text-xs font-semibold text-foreground`,children:`Migration status`}),y&&n(`button`,{type:`button`,onClick:()=>{k()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[s(he,{className:`h-3 w-3`}),`Cancel`]})]}),n(`p`,{className:`mt-1 text-xs text-foreground`,children:[`Phase: `,s(`span`,{className:`font-medium`,children:v.phase}),y&&s(W,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),v.error&&s(`p`,{className:`mt-1 text-[11px] text-danger`,children:v.error}),v.pausedParticipants.length>0&&n(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[`Paused: `,v.pausedParticipants.join(`, `)]}),s(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:v.moves.map(e=>s(_t,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),s(vt,{})]}),s(yt,{running:y}),s(xt,{})]})}function _t({move:e}){let t=e.progress===null?null:dt(e.progress);return n(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`span`,{className:`text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]}),n(`span`,{className:`text-foreground-subtle`,children:[e.state??`pending`,e.error?` (${e.error})`:``]})]}),e.progress!==null&&n(`div`,{className:`mt-1 space-y-1`,children:[t!==null&&t.fraction!==null&&s(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:s(`div`,{className:`h-full bg-primary`,style:{width:`${(t.fraction*100).toFixed(1)}%`}})}),s(`p`,{className:`text-[10px] text-foreground-subtle`,children:ft(e.progress)})]})]})}function vt(){let{data:e}=ue({});return!e||e.length===0?null:n(`div`,{className:`mt-4 border-t border-border pt-3`,children:[s(`h4`,{className:`text-xs font-semibold text-foreground`,children:`Migration history`}),s(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:e.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[s(`span`,{className:`font-medium text-foreground`,children:e.phase}),` · `,Object.entries(e.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(e.startedAt).toLocaleString()]},e.jobId))})]})}function yt({running:e}){let t=M(),r=ne({},{staleTime:1/0,refetchOnWindowFocus:!1}),i=te(),[a,c]=o(null),l=r.data??[];if(l.length===0)return null;let u=async e=>{if(await t({title:`Drain remaining ${e.storageClass}?`,message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:`Drain remaining`,variant:`danger`})){c(null);try{await i.mutateAsync({classes:[e.storageClass]}),await r.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}};return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`div`,{className:`flex items-start justify-between gap-2`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Left on the old location`}),n(`div`,{className:`flex shrink-0 items-center gap-2`,children:[s(`span`,{className:`text-[10px] text-foreground-subtle`,children:r.dataUpdatedAt>0?`Measured ${new Date(r.dataUpdatedAt).toLocaleTimeString()}`:`Measured — never`}),s(`button`,{type:`button`,onClick:()=>{r.refetch()},disabled:r.isFetching,className:`rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:r.isFetching?`Counting…`:`Refresh`})]})]}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`}),s(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`}),a&&s(`p`,{className:`mt-2 text-[11px] text-danger`,children:a}),s(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:l.map(t=>n(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[n(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId,s(`span`,{className:`ml-2 text-foreground-subtle`,children:bt(t)})]}),s(`button`,{type:`button`,onClick:()=>{u(t)},disabled:e||i.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:`Drain remaining`})]},`${t.storageClass}-${t.fromLocationId}`))})]})}function bt(e){if(e.items===null)return`amount unknown — the archive could not be read`;let t=e.items.toLocaleString(`en-US`);return e.bytes===null?`${t} rows`:`${t} segments · ${G(e.bytes)}`}function xt(){let{data:e}=ie({},{refetchInterval:2e3}),t=(e??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return t.length===0?null:n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Movers running outside a migration`}),s(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[n(`div`,{className:`text-foreground`,children:[e.lane,`: `,e.job.fromLocationId,` → `,e.job.toLocationId]}),s(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:ft({filesMoved:e.job.filesMoved,filesTotal:e.job.filesTotal,bytesMoved:e.job.bytesMoved,startedAt:e.job.startedAt,observedAt:e.observedAt})})]},e.job.jobId))})]})}function St(){return n(`div`,{className:`flex flex-col gap-4`,children:[s(ot,{}),s(lt,{}),n(`section`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Move storage`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`}),s(`div`,{className:`mt-3`,children:s(ht,{})})]})]})}t();var Ct=`recorder`;function wt(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function Tt(){let e=a(),{nodes:t}=_(),{data:i,isLoading:o}=j({addonId:Ct}),c=wt(i,`recordingNodeId`,`hub`),l=ee({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?s(W,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):s(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Ct,patch:{recordingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>s(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&s(W,{className:`h-4 w-4 animate-spin text-primary`})]}),c!==`hub`&&n(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,s(`span`,{className:`font-medium`,children:c}),`. If the auto-derived host doesn't work, set the recorder's`,s(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),s(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),s(be,{types:[`recordings`,`recordingsLow`]})]})]})}function Et(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Dt(e,t){let n=Et(e);return n.length===0?`default root`:n.map(e=>t.get(e)??e).join(` + `)}function Ot(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:Dt(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Et(e).includes(n));return i===void 0?null:{label:Dt(i,t),exact:!1}}var Z=[`ok`,`warn`,`critical`];function kt(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function At(e){return Math.min(1,Math.max(0,e))}function jt(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=At((n-t)/n);return{fraction:r,severity:kt(r),recordingsFraction:At(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Mt(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=jt(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Z.indexOf(e.severity)>Z.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}t();var Nt=[[`recording`]],Pt=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}],Ft={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Q={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function It(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):`default root`:e.root}function Lt(){let t=a(),i=M(),[c,u]=o(`retention`),{data:d,isLoading:f}=w({},{refetchOnWindowFocus:!1}),{data:m}=v({isCamera:!0,projection:`slim`}),{data:h}=g({}),_=r(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),b=r(()=>{let e=new Map;for(let t of h??[])e.set(t.id,t.displayName);return e},[h]),x=r(()=>{let e=h??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[h]),S=r(()=>d?.locations??[],[d?.locations]),C=r(()=>Ot(S,b,x),[S,b,x]),T=r(()=>Mt(S),[S]),E=e(()=>{t.invalidateQueries({queryKey:Nt})},[t]),D=p({onSuccess:E}),O=y({onSuccess:E}),k=e(async e=>{await i({title:`Prune ${_.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Applies the retention policy now (reason: ${c}). Footage beyond the policy is permanently deleted.`,confirmLabel:`Prune now`,variant:`danger`})&&D.mutate({deviceId:e.deviceId,reason:c})},[i,D,c,_]),A=e(async e=>{await i({title:`Delete all footage for ${_.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${G(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${G(e.usedBytes)}`,variant:`danger`})&&O.mutate({deviceId:e.deviceId})},[i,O,_]),j=r(()=>[{key:`camera`,header:`Camera`,render:e=>s(`span`,{className:`text-foreground`,children:_.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:`Disk`,nowrap:!0,render:()=>C===null?s(`span`,{className:`text-foreground-subtle`,children:`—`}):n(`span`,{className:C.exact?`text-foreground`:`text-foreground-subtle`,title:C.exact?`The only recordings volume on this node — this camera can only be here.`:`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`,children:[C.label,!C.exact&&s(`span`,{className:`ml-1 text-foreground-subtle`,children:`(default)`})]})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums`,children:G(e.usedBytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[n(`button`,{onClick:()=>{k(e)},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Apply retention policy now`,children:[s(Se,{className:`h-3 w-3`}),`Prune`]}),n(`button`,{onClick:()=>{A(e)},disabled:O.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all footage`,children:[s(U,{className:`h-3 w-3`}),`Delete`]})]})}],[_,C,k,A,D.isPending,O.isPending]);if(f&&!d)return n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(W,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!d)return s(P,{icon:L,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let N=d.devices.length;return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[s(l,{label:`Total used`,icon:s(L,{className:`h-3 w-3`}),footer:`${String(N)} camera${N===1?``:`s`} on ${d.nodeId}`,children:G(d.totalUsedBytes)}),T!==null&&T.severity!==null&&s(l,{label:`Free on recordings volumes`,icon:s(L,{className:`h-3 w-3`}),footer:`across ${String(T.knownVolumes)} volume${T.knownVolumes===1?``:`s`} of ${G(T.totalBytes)}`+(T.unknownVolumes>0?` · ${String(T.unknownVolumes)} did not report capacity`:``),children:s(`span`,{className:`tabular-nums ${Q[T.severity]}`,children:G(T.freeBytes)})}),S.map(e=>{let t=jt(e),r=e.locationId??e.root??`default`;return s(l,{label:`Disk: ${It(e,b)}`,footer:t===null?`${G(e.usedBytes)} of recordings · volume capacity unknown`:`${G(t.freeBytes)} free of ${G(t.totalBytes)} · ${G(e.usedBytes)} recordings (${$(t.recordingsFraction)})`,children:t===null?s(`span`,{className:`tabular-nums`,children:G(e.usedBytes)}):n(`div`,{className:`flex items-center gap-2`,title:`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`,children:[s(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:s(`div`,{className:`h-full rounded ${Ft[t.severity]}`,style:{width:$(t.fraction)}})}),s(`span`,{className:`tabular-nums text-xs ${Q[t.severity]}`,children:$(t.fraction)})]})},r)})]}),n(`section`,{className:`flex items-center gap-2 text-xs`,children:[s(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:`Prune reason`}),s(`select`,{id:`prune-reason`,value:c,onChange:e=>{let t=Pt.find(t=>t.value===e.target.value);t&&u(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Pt.map(e=>s(`option`,{value:e.value,children:e.label},e.value))})]}),N===0?s(P,{icon:L,title:`No recorded footage`,description:`No camera has recorded footage on this node yet.`}):s(F,{columns:j,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Rt(){return n(`div`,{className:`flex flex-col gap-8`,children:[n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Footage on disk`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`}),s(`div`,{className:`mt-3`,children:s(Lt,{})})]}),n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Recording node & folders`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records and serves playback, and the storage locations footage is written to.`}),s(`div`,{className:`mt-3`,children:s(Tt,{})})]})]})}function zt(){return s(ge,{icon:H,title:`Recordings`,subtitle:`Recorded footage and the durable event store — what each occupies, where it is written, and the operations that move or reconcile both.`,children:s(ye,{tabs:[{id:`storage`,label:`Recordings`,icon:L,content:s(Rt,{})},{id:`events`,label:`Events`,icon:B,content:s(Re,{})},{id:`cameras`,label:`Cameras`,icon:R,content:s(ke,{})},{id:`exports`,label:`Export`,icon:H,content:s($e,{})},{id:`activity`,label:`Activity`,icon:me,content:s(Oe,{})},{id:`management`,label:`Management`,icon:Ce,content:s(St,{})}]})})}export{zt as RecordingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{J as e}from"./index-vAjGJjNh.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{J as e}from"./index-vAjGJjNh.js";var t=e(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{J as e}from"./index-vAjGJjNh.js";var t=e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{J as e}from"./index-vAjGJjNh.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};
|