@camstack/addon-admin-ui 1.2.83 → 1.2.84
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-De7ns5QL.js → AddLocationWizard-CNcGS2EP.js} +1 -1
- package/dist/assets/{AddonCollectionPage-DXsxDYkh.js → AddonCollectionPage-SG0XXnDN.js} +1 -1
- package/dist/assets/Addons-i2kGOrOA.js +1 -0
- package/dist/assets/{AdminTabs-Ea5QF5Xy.js → AdminTabs-Bml9sY2f.js} +1 -1
- package/dist/assets/{AiProfiles-Cf11u16h.js → AiProfiles-Bkve7K-d.js} +2 -2
- package/dist/assets/{BrokerForm-B-sL3dqC.js → BrokerForm-CBVRdxmh.js} +1 -1
- package/dist/assets/{Build-_kPogt2B.js → Build-NxtOO0V2.js} +4 -4
- package/dist/assets/{Capabilities-D-_vyuUw.js → Capabilities-BROK90Se.js} +1 -1
- package/dist/assets/{CapabilityBadges-DVcflr6z.js → CapabilityBadges-CUituID7.js} +1 -1
- package/dist/assets/{Cluster-CP-cfGdm.js → Cluster-BrFa4n0G.js} +1 -1
- package/dist/assets/{Data-D3-pzcKz.js → Data-G9jbwfOG.js} +1 -1
- package/dist/assets/DetectionIntelligence-DiGPeWhN.js +1 -0
- package/dist/assets/{DeviceAggregateSection-CZPFsC_N.js → DeviceAggregateSection-SWBVkQZo.js} +1 -1
- package/dist/assets/DeviceDetail-O6xEze8u.js +2 -0
- package/dist/assets/{Devices-CQEzT4CH.js → Devices-LRxw3I54.js} +1 -1
- package/dist/assets/EmbedPlayerPage-kAcRRhLT.js +1 -0
- package/dist/assets/Events-D5RYcT1o.js +1 -0
- package/dist/assets/FormBuilder-D5TM9i1v.js +1 -0
- package/dist/assets/Identity-BRBs5jpM.js +1 -0
- package/dist/assets/IntegrationDetail-Bi2LK7OU.js +1 -0
- package/dist/assets/{Integrations-Bs6_6m2A.js → Integrations-DGLN-Oxt.js} +1 -1
- package/dist/assets/Integrations-qkldKVTw.js +1 -0
- package/dist/assets/{Logs-CJEauzfn.js → Logs-gPb8NR8H.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CrtWFnAG.js → MotionZonesSettings-DshKL17j.js} +1 -1
- package/dist/assets/{MyAccess-MG2HC7n3.js → MyAccess-X5GKXeQP.js} +1 -1
- package/dist/assets/{Network-DaZHubTl.js → Network-D6gOeprQ.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-Cm3hCWxL.js → NodeAddonsSettingsPanel-DQFTkg1Y.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-2-PPLG4L.js → NodeInferenceDevices-Dp-l4FwP.js} +1 -1
- package/dist/assets/Notifications-D1d2Q-ix.js +1 -0
- package/dist/assets/Pipeline-DcVa4THx.js +1 -0
- package/dist/assets/{Plates-CdlwAHjB.js → Plates-ffuMaQFQ.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-1sJg0nCf.js → PrivacyMaskSettings-MMzNNe4D.js} +1 -1
- package/dist/assets/{ProviderIcon-CIB9wAOh.js → ProviderIcon-DYBwyw9a.js} +1 -1
- package/dist/assets/Recordings-C8wX8f22.js +1 -0
- package/dist/assets/{ScanNetworkModal-QJjU9tvg.js → ScanNetworkModal-loGcDZBw.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-B_qhxMl3.js → SceneMonitorEditor-8DCu2vt2.js} +1 -1
- package/dist/assets/{Scenes-S26M2qHR.js → Scenes-0XwrxsM3.js} +1 -1
- package/dist/assets/{Settings-BgvNkBP1.js → Settings-ZUSTjvUu.js} +1 -1
- package/dist/assets/{Showroom-GHOpXZqD.js → Showroom-6YL7UJbf.js} +1 -1
- package/dist/assets/{Terminal-B0ibWMEy.js → Terminal-ykCkur7X.js} +2 -2
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BxzyL6ky.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CmZvmCxO.js} +1 -1
- package/dist/assets/{bell-ring-C1CDDXf4.js → bell-ring-B2rpaFtk.js} +1 -1
- package/dist/assets/{boxes-D1jLdgix.js → boxes-DFTZfyUt.js} +1 -1
- package/dist/assets/{build-cluster-graph-C4jX8n1A.js → build-cluster-graph-CLTUpmuN.js} +2 -2
- package/dist/assets/circle-check-big-BBxWSiDJ.js +1 -0
- package/dist/assets/{circle-x-CJJu15h-.js → circle-x-BBjSRoMP.js} +1 -1
- package/dist/assets/clock-6MQBaiID.js +1 -0
- package/dist/assets/{copy-CCWWm0Zr.js → copy-DWZC1oTP.js} +1 -1
- package/dist/assets/{debounced-invalidate-Bo_vaBxo.js → debounced-invalidate-CwLD5Weo.js} +1 -1
- package/dist/assets/dist-DHSKR8rX.js +345 -0
- package/dist/assets/{dist-B7jD-S4H.js → dist-Do647wcg.js} +1 -1
- package/dist/assets/{download-BkhXjXOx.js → download-CxGsHyPn.js} +1 -1
- package/dist/assets/{face-bbox-BOyxoUe0.js → face-bbox-BBED_iSc.js} +1 -1
- package/dist/assets/{hard-drive-fVjmkYpz.js → hard-drive-mR1KIPtt.js} +1 -1
- package/dist/assets/{hostInit-CFYQGKqd.js → hostInit-COJyRwPi.js} +1 -1
- package/dist/assets/index-D8DOnspM.js +4 -0
- package/dist/assets/{key-round-BWUCyF0a.js → key-round-Ds9BFc7u.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-8a7c339b.js → mf-entry-bootstrap-0-a5a42ace.js} +2 -2
- package/dist/assets/{pencil-BOy-rDbD.js → pencil-LYk12AGI.js} +1 -1
- package/dist/assets/play-BSZQjLkZ.js +1 -0
- package/dist/assets/{player-overlays-UTlrOH4s.js → player-overlays-BDAoS5mj.js} +1 -1
- package/dist/assets/plus-DpCA4f3I.js +1 -0
- package/dist/assets/power-VPCWTEZu.js +1 -0
- package/dist/assets/{radio-DKuDbOsT.js → radio-DOknapBC.js} +1 -1
- package/dist/assets/{refresh-cw-BRs_7wGu.js → refresh-cw-aVMqVAXK.js} +1 -1
- package/dist/assets/remoteEntry-DBWzSJRP.js +1 -0
- package/dist/assets/rotate-ccw-D7VfDBtK.js +1 -0
- package/dist/assets/rotate-cw-1XMucssR.js +1 -0
- package/dist/assets/search-CcmIbGXi.js +1 -0
- package/dist/assets/{send-DSafmQi_.js → send-CStKcKMW.js} +1 -1
- package/dist/assets/{server-wq15CL48.js → server-DpQquxi2.js} +1 -1
- package/dist/assets/square-BeUYnpBQ.js +1 -0
- package/dist/assets/{square-check-big-DO81u3O2.js → square-check-big-D_32NB3x.js} +1 -1
- package/dist/assets/src-B4-xc1-S.js +345 -0
- package/dist/assets/{src-DVZrqMsD.js → src-BHAm1a2j.js} +10 -10
- package/dist/assets/{star-Docf4EYZ.js → star-CnMUDmNT.js} +1 -1
- package/dist/assets/{undo-2-LIqqVOPk.js → undo-2-Bu9cI3K3.js} +1 -1
- package/dist/assets/{upload-D4XiPM-V.js → upload-DITj7pmV.js} +1 -1
- package/dist/assets/{use-scenes-feed-BdUI8ZzS.js → use-scenes-feed-ClYTNH65.js} +1 -1
- package/dist/assets/useEventInvalidation-CYexmqD-.js +1 -0
- package/dist/assets/{video-DdJ2lmUL.js → video-D3MA7ngK.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-cD-zqb5y.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-PnuvqzUU.js} +2 -2
- package/dist/assets/{wifi-Dx0-akbW.js → wifi-CmMg3Cu0.js} +1 -1
- package/dist/assets/{zap-BLI50LGc.js → zap-H6dvIirs.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +32 -52
- package/package.json +1 -1
- package/dist/assets/Addons-iB8Jj8Wa.js +0 -1
- package/dist/assets/DetectionIntelligence-B914KqGk.js +0 -1
- package/dist/assets/DeviceDetail-Cz70xnHl.js +0 -2
- package/dist/assets/EmbedPlayerPage-BQ1dgL2t.js +0 -1
- package/dist/assets/Events-B9-2qvUg.js +0 -1
- package/dist/assets/FormBuilder-ERsdhqXU.js +0 -1
- package/dist/assets/Identity-BNMnBiNq.js +0 -1
- package/dist/assets/IntegrationDetail-CY-7m0wv.js +0 -1
- package/dist/assets/Integrations-CbfIXyMv.js +0 -1
- package/dist/assets/Notifications-DMPhSkZ8.js +0 -1
- package/dist/assets/Pipeline-D4RLE8zf.js +0 -1
- package/dist/assets/Recordings-D4KRWthc.js +0 -1
- package/dist/assets/circle-check-big-Be_uVG-B.js +0 -1
- package/dist/assets/clock-9WRXwSMf.js +0 -1
- package/dist/assets/dist-Cpz6pXi5.js +0 -345
- package/dist/assets/index-DM4pp8Vx.js +0 -4
- package/dist/assets/play-tYEpmInf.js +0 -1
- package/dist/assets/plus-uTnAmy5n.js +0 -1
- package/dist/assets/power-DLJJxxZ5.js +0 -1
- package/dist/assets/remoteEntry-B-TTgn5K.js +0 -1
- package/dist/assets/rotate-ccw-CZY9UuXq.js +0 -1
- package/dist/assets/rotate-cw-rDbUnEsj.js +0 -1
- package/dist/assets/search-BGsNM6IN.js +0 -1
- package/dist/assets/square-BFMdi_Qm.js +0 -1
- package/dist/assets/src-C9CFJqET.js +0 -345
- package/dist/assets/useEventInvalidation-DLMOtAJP.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,T as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Aa as d,As as f,Ba as p,Bt as m,Ca as h,Da as g,Ds as _,Ea as v,H as y,Ha as b,Ht as x,Ja as S,Ka as C,La as w,Ma as T,Oa as E,Os as D,Pa as O,Rt as k,S as A,Sa as j,Ta as M,Ua as N,Ut as P,Vt as F,Wa as I,Wt as ee,X as L,Xa as R,Xi as z,Xt as te,Ya as ne,Za as B,_n as V,ao as re,d as ie,dn as ae,h as oe,hn as se,i as H,io as ce,ja as le,ka as ue,ks as de,mn as fe,no as pe,qa as me,ro as he,so as ge,tt as _e,u as ve,wa as ye,xa as be,za as xe}from"./src-DVZrqMsD.js";import{Nt as Se,Pt as Ce,gt as we}from"./src-C9CFJqET.js";import{c as Te,i as Ee,l as De,n as U,r as Oe,s as ke,t as Ae}from"./NodeInferenceDevices-2-PPLG4L.js";import{t as je}from"./download-BkhXjXOx.js";import{t as Me}from"./hard-drive-fVjmkYpz.js";import{n as Ne,t as Pe}from"./video-DdJ2lmUL.js";import{t as Fe}from"./pencil-BOy-rDbD.js";import{t as Ie}from"./plus-uTnAmy5n.js";import{t as Le}from"./radio-DKuDbOsT.js";import{t as Re}from"./refresh-cw-BRs_7wGu.js";import{t as ze}from"./search-BGsNM6IN.js";import{t as Be}from"./server-wq15CL48.js";import{t as Ve}from"./square-check-big-DO81u3O2.js";import{t as He}from"./square-BFMdi_Qm.js";import{t as Ue}from"./zap-BLI50LGc.js";import{C as W,E as We,F as Ge,I as Ke,K as qe,N as G,O as Je,P as Ye,R as Xe,X as Ze,i as Qe,o as $e,s as et,z as tt}from"./index-DM4pp8Vx.js";import{t as nt}from"./AdminPage-CCD07UMs.js";import"./useEventInvalidation-DLMOtAJP.js";import{r as rt,t as it}from"./build-cluster-graph-C4jX8n1A.js";import{n as at}from"./format-size-CO9d3C3-.js";import{t as ot}from"./NodeAddonsSettingsPanel-Cm3hCWxL.js";var st=qe(`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`}]]),ct=qe(`flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),lt=qe(`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`}]]);n();function ut(e){return e}function dt(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ft(e,t){return typeof e==`boolean`?e:ut(t)}function pt(e,t){return{pipeline:ft(dt(e,`detect`),t),audio:ft(dt(e,`audio`),t),ingest:ft(dt(e,`ingest`),t)}}function mt(e,t,n){let r=e?.find(e=>e.nodeId===t);return pt(r?.settings,n)}function ht({selectedNodeId:e,onSelect:t,refreshToken:n}){let{data:i}=z(void 0),{data:a}=xe(void 0),{data:s}=b(void 0),c=new Map;for(let e of a??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let u=i??[],d=u.filter(e=>e.isOnline).length,f=u.filter(e=>!e.isOnline).length;return r(`div`,{className:`flex flex-col h-full`,children:[r(`button`,{type:`button`,onClick:()=>t(Cr),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:[l(We,{className:`h-4 w-4 flex-shrink-0`}),r(`div`,{className:`min-w-0 flex-1`,children:[l(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),l(`div`,{className:`flex-1 overflow-y-auto`,children:u.map(n=>{let i=e===n.id,a=c.get(n.id)??0,u=n.isHub?Be:G,d=mt(s,n.id,n.isHub),f=n.isOnline?null:y(rt(n.lastSeen));return r(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[l(u,{className:`h-4 w-4 flex-shrink-0`}),r(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&l(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!n.isOnline&&l(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&l(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),r(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[r(`span`,{children:[n.cpuCores,` cores`]}),l(`span`,{children:`•`}),r(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),a>0&&r(o,{children:[l(`span`,{children:`•`}),r(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[l(Pe,{className:`h-2.5 w-2.5`}),a]})]}),!n.isOnline&&r(o,{children:[l(`span`,{children:`•`}),r(`span`,{className:`text-destructive`,children:[`offline`,f===null?``:` · ${f}`]})]})]}),r(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[l(k,{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`}),l(k,{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`})]})]})]},n.id)})}),r(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[r(`span`,{children:[d,` online`]}),f>0&&r(`span`,{className:`text-destructive`,children:[f,` offline`]})]})]})}function gt({nodeId:e,refreshToken:t}){let{data:n}=z(void 0),i=n?.find(t=>t.id===e),a=D(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?r(`div`,{className:`px-6 py-4 border-b border-border`,children:[r(`div`,{className:`flex items-center gap-2 mb-1`,children:[l(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?l(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):l(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),i.isHub&&l(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),r(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[l(`span`,{children:i.cpuModel??`CPU`}),l(`span`,{children:`•`}),r(`span`,{children:[i.cpuCores,` cores`]}),l(`span`,{children:`•`}),r(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),a&&r(o,{children:[l(`span`,{children:`•`}),r(`span`,{children:[a.attachedCameras,` cameras (`,a.activeCameras,` active)`]}),l(`span`,{children:`•`}),r(`span`,{children:[a.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),l(`span`,{children:`•`}),r(`span`,{children:[`queue `,a.queueDepthTotal]}),a.hardware.hasGpu&&r(o,{children:[l(`span`,{children:`•`}),l(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):l(`div`,{className:`px-6 py-4 border-b border-border`,children:r(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function _t({refreshToken:e,nodeId:t}){let[n,i]=c(new Map),{nodes:o}=_();f(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&i(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:s}=T(void 0),u=a(()=>{let e=new Map;for(let t of s??[])e.set(t.nodeId,t.deviceCount);return e},[s]),d=a(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),p=a(()=>{let e=new Map;for(let t of o)e.set(t.id,t.shortName);return e},[o]),m=a(()=>{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 r(`div`,{className:`@container/liveload`,children:[l(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),r(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[l(K,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),l(K,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),l(K,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),l(K,{label:`Queue`,value:e?String(e.queueDepth):`—`}),l(K,{label:`Audio`,value:String(u.get(t)??`—`)})]})]})}let h=[...d.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return r(`div`,{className:`@container/liveload`,children:[l(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),r(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[l(K,{label:`Total agents`,value:`${m.onlineAgents}/${m.totalAgents}`}),l(K,{label:`Active / Attached`,value:`${m.activeCameras}/${m.attachedCameras}`}),l(K,{label:`Total FPS`,value:m.totalFps.toFixed(1)}),l(K,{label:`Avg inference ms`,value:m.avgInferenceTimeMs.toFixed(0)}),l(K,{label:`Queue depth`,value:String(m.queueDepth)})]}),l(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:r(`table`,{className:`w-full text-xs min-w-[480px]`,children:[l(`thead`,{className:`bg-surface`,children:r(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[l(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),l(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),l(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),l(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),l(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),l(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),r(`tbody`,{children:[h.map(([e,t])=>r(`tr`,{className:`border-t border-border`,children:[l(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(e)??e}),l(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),l(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),l(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),l(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),l(`td`,{className:`px-3 py-2 text-right text-foreground`,children:u.get(e)??`—`})]},e)),h.length===0&&l(`tr`,{children:l(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function K({label:e,value:t}){return r(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[l(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),l(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}n();var vt={active:!1,pinned:!1,nodeId:null,reason:``},yt=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],bt={pipeline:G,decoder:Je,audio:Ne},xt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function St({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let d=s(),[p,m]=c(null),[h,g]=c(null),[v,y]=c(new Map);H([`pipelineOrchestrator`,`getPipelineAssignments`],yt),H([`pipelineOrchestrator`,`getAudioAssignments`],yt),H([`pipelineOrchestrator`,`getCameraStatuses`],yt);let{data:b}=xe(void 0),{data:x}=le(void 0),{data:S}=O({},{enabled:e===`agent`}),{nodes:C}=_(),{data:w}=ke();f(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&y(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),u(()=>{if(v.size===0)return;let e=setInterval(()=>{y(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[v.size]);let T=a(()=>{let e=new Map;for(let t of w??[])e.set(t.id,t.name);return e},[w]),D=a(()=>{if(e===`agent`){let e=[];for(let n of S??[]){let r=n.assignment,i=(e,n,r)=>({active:e!==null&&e===t,pinned:n,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:n.deviceId,deviceName:T.get(n.deviceId)??`Device ${n.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:T.get(e)??`Device ${e}`,pipeline:vt,decoder:vt,audio:vt};return n.set(e,r),r};for(let i of b??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of x??[]){let t=r(e.deviceId);n.set(e.deviceId,{...t,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...n.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[b,x,S,T,e,t]),k=a(()=>(C??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[C]),A=()=>{d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},j=ue({onSuccess:A}),M=ce({onSuccess:A}),N=E({onSuccess:A}),P=he({onSuccess:A}),F=(e,t,n)=>{t===`pipeline`?j.mutate({deviceId:e,agentNodeId:n}):N.mutate({deviceId:e,nodeId:n}),m(null)},I=(e,t)=>{t===`pipeline`?M.mutate({deviceId:e}):P.mutate({deviceId:e}),m(null)};return l(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:r(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[l(`thead`,{className:`bg-surface`,children:r(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&l(`th`,{className:`w-10`}),l(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?r(o,{children:[l(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),l(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):r(o,{children:[l(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),l(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),l(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),l(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),r(`tbody`,{children:[D.map(t=>{let a=v.get(t.deviceId),s=h===t.deviceId;return r(i.Fragment,{children:[r(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&l(`td`,{className:`px-2 py-2 align-middle`,children:l(`button`,{type:`button`,onClick:()=>g(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:l(s?Xe:Ke,{className:`h-3.5 w-3.5`})})}),r(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[l(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),r(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?r(o,{children:[l(`td`,{className:`px-3 py-2 align-middle`,children:l(wt,{state:t.pipeline,onlineNodes:k,pending:j.isPending||M.isPending,onChange:e=>{e===`auto`?I(t.deviceId,`pipeline`):F(t.deviceId,`pipeline`,e)}})}),l(`td`,{className:`px-3 py-2 align-middle`,children:l(Tt,{state:t.pipeline,deviceId:t.deviceId})})]}):r(o,{children:[l(Dt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:k,isMenuOpen:p?.deviceId===t.deviceId&&p.role===`pipeline`,onToggleMenu:()=>m(p?.deviceId===t.deviceId&&p.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>m(null),onMove:e=>F(t.deviceId,`pipeline`,e),onUnpin:()=>I(t.deviceId,`pipeline`)}),l(Dt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:k,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),l(Dt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:k,isMenuOpen:p?.deviceId===t.deviceId&&p.role===`audio`,onToggleMenu:()=>m(p?.deviceId===t.deviceId&&p.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>m(null),onMove:e=>F(t.deviceId,`audio`,e),onUnpin:()=>I(t.deviceId,`audio`)})]}),l(`td`,{className:`px-3 py-2 align-middle`,children:l(jt,{snap:a})})]}),s&&!n&&r(`tr`,{className:`bg-surface/50`,children:[l(`td`,{}),r(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2 space-y-3`,children:[t.pipeline.nodeId&&l(Ct,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),l(te,{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&&l(`tr`,{children:l(`td`,{colSpan:n?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 Ct({deviceId:e,nodeId:t}){let n=s(),{data:i}=w({nodeId:t}),{data:a}=p({deviceId:e}),o=pe({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}}),c=i?.devices??[],u=a?.deviceKey??`auto`,d=u!==`auto`&&!c.some(e=>e.key===u);return r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[l(`span`,{className:`shrink-0 font-medium text-foreground`,children:`Inference device`}),r(`select`,{value:u,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:[l(`option`,{value:`auto`,children:`Auto (balanced)`}),d&&r(`option`,{value:u,children:[`Pin → `,u,` (not on this node)`]}),c.map(e=>r(`option`,{value:e.key,children:[`Pin → `,e.key,e.available?``:` (unavailable)`]},e.key))]}),o.isPending&&l(`span`,{className:`text-[10px] opacity-70`,children:`saving…`})]})}function wt({state:e,onlineNodes:t,pending:n,onChange:i}){let a=e.pinned&&e.nodeId?e.nodeId:`auto`,o=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return r(`select`,{value:a,disabled:n,"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:[l(`option`,{value:`auto`,children:`Auto`}),o.map(e=>r(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function Tt({state:e,deviceId:t}){if(!e.active||!e.nodeId)return l(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let n=e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`;return r(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[l(`span`,{className:`font-mono text-[11px] text-foreground truncate`,title:e.nodeId,children:e.nodeId}),l(`span`,{className:`truncate ${e.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:n,children:n}),l(Et,{deviceId:t,nodeId:e.nodeId})]})}function Et({deviceId:e,nodeId:t}){let n=s(),{data:i}=p({deviceId:e},{refetchOnMount:`always`}),{data:a}=w({nodeId:t},{refetchOnMount:`always`}),o=pe({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return l(`span`,{className:`mt-0.5 text-[10px] text-foreground-subtle italic`,children:`device: …`});let c=a.devices??[],u=c.filter(e=>e.enabled),d=i.deviceKey??`auto`,f=d!==`auto`&&!u.some(e=>e.key===d),m=c.find(e=>e.key===d);return r(`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:[l(`option`,{value:`auto`,children:`Auto (balanced)`}),f&&r(`option`,{value:d,children:[m?`${U(m).label} (${d})`:d,` (not enabled)`]}),u.map(e=>r(`option`,{value:e.key,children:[U(e).label,` · `,e.format]},e.key))]})}function Dt({role:e,state:t,mode:n,onlineNodes:i,readOnly:a=!1,isMenuOpen:o,onToggleMenu:s,onCloseMenu:c,onMove:u,onUnpin:d}){let f=bt[e],p=i.filter(e=>e.id!==(t.nodeId??``)),m=!a&&(t.active||n===`cluster`)&&(p.length>0||t.pinned);return r(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[l(n===`agent`?Ot:kt,{state:t,Icon:f}),l(`div`,{className:`ml-auto shrink-0`,children:m&&l(`button`,{type:`button`,onClick:s,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${xt[e]} actions`,children:l(st,{className:`h-3 w-3 text-foreground-subtle`})})})]}),o&&m&&l(Mt,{title:xt[e],targets:p,pinned:t.pinned,onMove:u,onUnpin:d,onClose:c})]})}function Ot({state:e,Icon:t}){return r(`div`,{className:`flex items-center gap-1.5`,children:[l(e.active?Ve:He,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),l(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&l(lt,{className:`h-2.5 w-2.5 text-amber-400`})]})}function kt({state:e,Icon:t}){return!e.active||!e.nodeId?r(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[l(t,{className:`h-3 w-3`}),l(`span`,{className:`text-[10px] italic`,children:`—`})]}):r(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[l(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),r(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[l(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),l(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?r(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[l(lt,{className:`h-2.5 w-2.5`}),` manual`]}):r(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var At=`min-h-[3.25rem]`;function jt({snap:e}){if(!e)return l(`div`,{className:`flex items-center ${At}`,children:l(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:n,avgInferenceTimeMs:i,queueDepth:a,configuredFps:o,droppedFrames:s}=e.metrics,c=_e(t);return r(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${At}`,children:[r(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${c.textColor}`,children:[l(oe,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),l(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:c.label})]}),r(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[l(`span`,{className:`text-foreground`,children:n.toFixed(1)}),r(`span`,{children:[`/`,o.toFixed(0),` fps`]})]}),r(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[l(`span`,{className:`text-foreground`,children:i.toFixed(0)}),l(`span`,{children:` ms`}),a>0&&r(`span`,{className:`text-warning ml-1`,children:[`q`,a]})]}),r(`span`,{className:`whitespace-nowrap truncate ${s>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,l(`span`,{className:`text-foreground`,children:s})]})]})}function Mt({title:e,targets:n,pinned:i,onMove:a,onUnpin:o,onClose:s}){let c=t(null);return u(()=>{let e=e=>{c.current?.contains(e.target)||s()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]),r(`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:[l(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),n.length>0&&l(`div`,{className:`py-1`,children:n.map(e=>r(`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&&r(`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 `,e.toLowerCase()]}),n.length===0&&!i&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Nt({nodeId:e,refreshToken:t}){return r(`div`,{className:`space-y-6`,children:[l(_t,{refreshToken:t,nodeId:e}),r(`div`,{children:[l(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),r(`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.`]})]}),l(St,{mode:`agent`,nodeId:e,compact:!0})]})}n();function Pt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Ft({nodeId:e,refreshToken:t}){let n=s(),i=v({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:o}=g({nodeId:e}),c=D(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??o??null,u=c===null;H([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:d}=ge({nodeId:e}),{values:f}=de(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),p=a(()=>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?`)||i.mutate({nodeId:e,engine:t,force:n.length>0})};return r(`div`,{className:`space-y-6`,children:[r(`div`,{children:[l(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),r(`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.`]})]}),l(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:r(`table`,{className:`w-full text-xs min-w-[640px]`,children:[l(`thead`,{className:`bg-surface`,children:r(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[l(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),l(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),l(`th`,{className:`text-left px-3 py-2`,children:`Models`}),l(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),l(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),l(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),l(`th`,{className:`w-20`})]})}),r(`tbody`,{children:[u&&l(`tr`,{children:l(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!u&&(c??[]).map(e=>{let t=e.kind===`warm-override`,n=e.kind===`device-pool`;return r(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:n?`bg-primary/[0.05]`:``}`,children:[l(`td`,{className:`px-3 py-2`,children:r(`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`:n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[l(t?ct:n?De:G,{className:`h-3 w-3`}),t?`warm`:n?`pool`:`runtime`]})}),l(`td`,{className:`px-3 py-2`,children:r(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[l(Ue,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),l(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?l(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):l(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>l(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),l(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),l(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?l(`span`,{className:`text-foreground-subtle`,children:Pt(e.idleMs,e.idleTtlMs)}):l(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),l(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(d??[]).length}),l(`td`,{className:`px-3 py-2 text-right`,children:n?l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`auto`}):r(`button`,{type:`button`,disabled:i.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:[l(et,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!u&&(c??[]).length===0&&l(`tr`,{children:l(`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.`})})]})]})}),r(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[l(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,l(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,l(`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.`]}),i.isError&&r(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,i.error instanceof Error?i.error.message:`unknown`]})]})}n();var It=new Set(we);function Lt(e){return It.has(e)}function Rt(e,t,n){return`${e}/${t}/${n}`}function zt(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Bt(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function q(e){return e.format}function Vt(e,t){let n=0,r=0,i=0;for(let a of e)for(let e of a.addons)for(let a of e.models){let e=a.formats[t];e&&(n++,e.downloaded&&(r++,i+=e.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:i}}function Ht({addonId:e,model:t,format:n,isActive:i,progress:a,errorMsg:o,onDownload:s,onDelete:c}){let u=t.formats[n];return u?r(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[l(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${u.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),r(`div`,{className:`flex-1 min-w-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),a&&a.progress>=0&&a.progress<100&&r(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[l(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:l(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${a.progress}%`}})}),r(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(a.progress),`%`]})]})]}),l(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:at(u.sizeMB)}),o&&r(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:o,children:[l(Ge,{className:`h-3 w-3 shrink-0`}),o]}),u.downloaded?r(`button`,{onClick:c,disabled:i,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[i?l(W,{className:`h-3 w-3 animate-spin`}):l(et,{className:`h-3 w-3`}),i?`Deleting...`:`Delete`]}):r(`button`,{onClick:s,disabled:i,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[i?l(W,{className:`h-3 w-3 animate-spin`}):l(je,{className:`h-3 w-3`}),i?`Downloading...`:`Download`]})]}):null}function Ut({engines:e,activeEngine:t,viewEngine:n,onSelect:i}){let[a,o]=c(!1);return r(`div`,{className:`relative`,children:[r(`button`,{type:`button`,onClick:()=>o(!a),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[l(G,{className:`h-4 w-4 text-primary shrink-0`}),r(`div`,{className:`flex-1 min-w-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`text-sm font-medium text-foreground`,children:zt(n)}),q(n)===q(t)&&l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:Bt(n)})]}),l(Xe,{className:`h-4 w-4 text-foreground-subtle transition-transform ${a?`rotate-180`:``}`})]}),a&&l(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let a=q(e)===q(n),s=q(e)===q(t);return r(`button`,{type:`button`,onClick:()=>{i(e),o(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${a?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[l(G,{className:`h-4 w-4 shrink-0 ${a?`text-primary`:`text-foreground-subtle`}`}),r(`div`,{className:`flex-1`,children:[r(`div`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`text-sm font-medium ${a?`text-primary`:`text-foreground`}`,children:zt(e)}),s&&l(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:Bt(e)})]}),a&&l(Ye,{className:`h-4 w-4 text-primary shrink-0`})]},q(e))})})]})}function Wt({embedded:t=!1,nodeId:n}={}){let i=s(),a=n??`hub`,[u,d]=c(null),[p,m]=c(new Set),[g,_]=c(new Map),[v,y]=c(new Map),[b,x]=c(``),{data:S=[]}=h({nodeId:a}),C=S.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:w}=M({nodeId:a}),T=w,{data:E,isLoading:D}=ye({nodeId:a}),O=j(),k=be();f(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,r=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||r===void 0||(_(e=>{let t=new Map(e);return r===100||r===-1?t.delete(n):t.set(n,{modelId:n,progress:r,totalMB:a}),t}),r===100&&i.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let A=T??{runtime:`node`,backend:`cpu`,format:`onnx`},N=C.find(e=>e.format===u)??A,P=N.format,F=e=>e.formats[P]?.downloaded===!0,I=E?.slots??[],L=I.map(e=>({...e,addons:e.addons.map(e=>({...e,models:ee(e.models,P)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),R=Vt(L,P),z=e(async(e,t,n)=>{if(!Lt(n))return;let r=Rt(e,t,n);m(e=>new Set([...e,r])),y(e=>{let t=new Map(e);return t.delete(r),t});try{await O.mutateAsync({addonId:e,modelId:t,format:n,nodeId:a}),i.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){y(t=>new Map([...t,[r,e instanceof Error?e.message:`Download failed`]]))}finally{m(e=>{let t=new Set(e);return t.delete(r),t})}},[O,i,a]),te=e(async(e,t,n)=>{if(!Lt(n))return;let r=Rt(e,t,n);m(e=>new Set([...e,r])),y(e=>{let t=new Map(e);return t.delete(r),t});try{await k.mutateAsync({addonId:e,modelId:t,format:n,nodeId:a}),i.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){y(t=>new Map([...t,[r,e instanceof Error?e.message:`Delete failed`]]))}finally{m(e=>{let t=new Set(e);return t.delete(r),t})}},[k,i,a]),ne=e(e=>{d(e.format)},[]),B=b.trim()?L.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(b.toLowerCase())||t.id.toLowerCase().includes(b.toLowerCase())||e.name.toLowerCase().includes(b.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):L,V=r(o,{children:[D&&l(`div`,{className:`flex items-center justify-center py-16`,children:l(W,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!D&&I.length===0&&r(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[l(Me,{className:`h-8 w-8 mb-3 opacity-30`}),l(`span`,{className:`text-sm`,children:`No pipeline steps available`}),l(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!D&&I.length>0&&r(o,{children:[l(Ut,{engines:C,activeEngine:A,viewEngine:N,onSelect:ne}),r(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[r(`span`,{children:[l(`span`,{className:`font-semibold text-foreground tabular-nums`,children:R.total}),l(`span`,{className:`ml-1`,children:`compatible models`})]}),l(`span`,{className:`text-border`,children:`|`}),r(`span`,{children:[l(`span`,{className:`font-semibold text-success tabular-nums`,children:R.downloaded}),l(`span`,{className:`ml-1`,children:`downloaded`})]}),l(`span`,{className:`text-border`,children:`|`}),r(`span`,{className:`tabular-nums`,children:[at(R.downloadedSizeMB),l(`span`,{className:`ml-1`,children:`on disk`})]})]}),R.total>5&&r(`div`,{className:`relative`,children:[l(ze,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),l(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),B.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+ee(t.models,P).filter(F).length,0);return r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 mb-2`,children:[l(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),l(`div`,{className:`flex-1 h-px bg-border`}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),l(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=Rt(e.id,t.id,P);return l(Ht,{addonId:e.id,model:t,format:P,isActive:p.has(n),progress:g.get(t.id),errorMsg:v.get(n),onDownload:()=>z(e.id,t.id,P),onDelete:()=>te(e.id,t.id,P)},`${e.id}/${t.id}`)}))})]},e.id)}),B.length===0&&l(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:b.trim()?r(o,{children:[`No models matching “`,b,`”`]}):r(o,{children:[`No models available for `,zt(N),` format`]})})]})]});return t?l(`div`,{className:`space-y-4`,children:V}):l(nt,{children:V})}function Gt({nodeId:e,refreshToken:t}){return l(Wt,{embedded:!0,nodeId:e})}var Kt=`pipeline-runner`,qt=200;function Jt({nodeId:e}){return r(`div`,{className:`flex flex-col gap-3`,children:[r(`div`,{children:[l(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),r(`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.`]})]}),l(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:l(L,{agentId:e,addonId:Kt,limit:qt,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}n(),n();function Yt({nodeId:e,title:t}){let{data:n}=ke(),{data:i}=xe(void 0),o=a(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),s=a(()=>{if(!e)return null;let t=new Set;for(let n of i??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,i]),[d,p]=c(new Map);f(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||p(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),u(()=>{if(d.size===0)return;let e=setInterval(()=>{p(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)},[d.size]);let m=a(()=>{let e=[];for(let t of d.values())s&&!s.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[d,s]);return m.length===0?r(`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`]}):r(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[r(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:m.length})]}),l(`div`,{className:`flex flex-wrap gap-1.5`,children:m.map(e=>{let t=o.get(e.deviceId)??`#${e.deviceId}`,n=_e(e.metrics.phase);return r(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[l(oe,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),l(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),l(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),l(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}n();function J(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 n=s(),[i,u]=c(null),[d,f]=c(null),[p,h]=c(``),[g,_]=c(null),v=w({nodeId:e},{refetchOnMount:`always`}),y=ye({nodeId:e},{refetchOnMount:`always`}),b=v.data?.devices??[],S=R({onSuccess:()=>{n.invalidateQueries({queryKey:[`pipelineOrchestrator`,`getNodeInferenceDevices`]})}}),C=a(()=>y.data?ve(y.data):[],[y.data]),T=a(()=>b.map(t=>({agentNodeId:e,engineLabel:t.format,deviceKey:t.key,deviceLabel:U(t).label})),[b,e]),E=e=>b.find(t=>t.key===e)??null,D=a(()=>b.filter(e=>e.enabled),[b]),O=D.length>=2,k=(e,t)=>P(J(y.data??null,e)?.models??[],t?.format),j=e=>{let t=E(e);return t?U(t).label:e},M=(e,t)=>D.filter(n=>n.key!==t&&k(e,n)).toSorted((e,t)=>e.key<t.key?-1:+(e.key>t.key))[0]??null,N=e=>{let t=J(y.data??null,e)?.enabledByDefault??!0;return{kind:`gate`,effectiveOn:t,defaultOn:t,explicit:!1}},I=(e,t)=>{let n=J(y.data??null,e);if(n)return F(n,t)},ee=(e,t)=>{let n=N(e),r=n.kind===`gate`?n.effectiveOn:!1,i=J(y.data??null,e),a=t.deviceKey===void 0?null:E(t.deviceKey),o=P(i?.models??[],a?.format),s=a?.steps?.[e];if(!o){if(!r)return{kind:`na`};let n=s?.jumpDeviceKey,i=n!==void 0&&D.some(e=>e.key===n)?n:t.deviceKey===void 0?void 0:M(e,t.deviceKey)?.key;return i===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:j(i)}}return{kind:`enabled`,modelId:(i?x({catalog:i,device:a,base:s?.modelId}):void 0)??`Auto`,...s?.jumpDeviceKey!==void 0&&D.some(e=>e.key===s.jumpDeviceKey)?{jumpTo:j(s.jumpDeviceKey)}:{}}},L=i&&y.data?J(y.data,i.addonId):null,z=i?E(i.deviceKey):null,te=z?.format??`coreml`,ne=i?I(i.addonId,z):void 0,B=()=>{u(null),f(null),h(``)},V=(e,t)=>{if(t.deviceKey===void 0)return;let n=E(t.deviceKey)?.steps?.[e];u({addonId:e,deviceKey:t.deviceKey}),f({enabled:!0,...n?.modelId===void 0?{}:{modelId:n.modelId},settings:n?.settings??{}}),h(n?.jumpDeviceKey??``)},re=()=>{if(!i)return;let t=Xt(d),n=p!==``&&p!==i.deviceKey?p:void 0,r=t||n!==void 0?{...t,...n===void 0?{}:{jumpDeviceKey:n}}:null,a=b.map(e=>{let t={...e.steps};return e.key===i.deviceKey&&(r?t[i.addonId]=r:delete t[i.addonId]),{key:e.key,enabled:e.key===i.deviceKey?!0:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:t}});S.mutate({agentNodeId:e,inferenceDevices:Ee(a)},{onSuccess:B})};if(v.isLoading||y.isLoading)return l(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(b.length===0)return l(`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 l(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let ae=i!==null&&L!==null&&z!==null;return r(`div`,{className:`relative h-full w-full space-y-3`,children:[r(`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`,` `,l(`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.`]}),l(`div`,{className:ae?`md:pr-[360px]`:``,children:C.length>0?l(A,{tree:C,agents:T,gateFor:N,getCellState:ee,onCellClick:V,selectedCell:i?{addonId:i.addonId,agentNodeId:e,deviceKey:i.deviceKey}:null,onSetGate:()=>{},fallbackNodeId:g,onFallbackNodeChange:_,hideGate:!0}):l(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),l(ie,{open:ae,onClose:B,title:L?.name??``,subtitle:i&&z?`${e} · ${U(z).label} · ${z.format}`:``,footer:r(o,{children:[l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:B,children:`Cancel`}),l(`button`,{type:`button`,disabled:!i||!d||S.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:re,children:S.isPending?`Saving…`:`Save`})]}),children:L&&i&&d?r(`div`,{className:`space-y-3`,children:[O&&r(`div`,{className:`rounded-md border border-border bg-muted/10 px-3 py-2 space-y-1`,children:[l(`label`,{className:`block text-[11px] font-medium text-foreground`,children:`Run on`}),r(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:p,onChange:e=>h(e.target.value),children:[l(`option`,{value:``,children:`Auto (this device, or auto-jump if unsupported)`}),D.filter(e=>e.key!==i.deviceKey).map(e=>r(`option`,{value:e.key,children:[U(e).label,` · `,e.format]},e.key))]}),l(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Route this step (and its child steps) to another accelerator on this node.`})]}),l(m,{mode:`agent`,addon:L,agentDefault:d,agentNodeId:e,engineFormat:te,effectiveModelId:ne,onChangeAgentConfig:f})]}):l(`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.`})})]})}n();var Qt=[`pipeline-orchestrator`],$t=[`decoder`],en=!1;function tn({nodeId:e,refreshToken:t}){let n=ae(),[i,a]=c(null),[o,s]=c(null),u=(z(void 0).data??[]).find(t=>t.id===e),d=u?.name??e,f=u?.isOnline??!1,p=C({onSuccess:e=>{s(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),m=async()=>{await n({title:`Reset ${d} to hardware-aware defaults?`,message:`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(s(null),p.mutate({agentNodeId:e}))};return r(`div`,{className:`relative h-full w-full space-y-3`,children:[r(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[o&&l(`span`,{className:`text-emerald-400`,children:o}),p.isError&&l(`span`,{className:`text-red-400`,children:p.error instanceof Error?p.error.message:`Reset failed`}),l(`button`,{type:`button`,onClick:()=>{m()},disabled:p.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's per-device model defaults + per-camera overrides scoped to this node`,children:p.isPending?`Resetting…`:`Reset to default`})]}),l(Yt,{nodeId:e}),l(ot,{nodeId:e,addonIds:Qt,level:`global`,sectionIds:$t}),en,en,r(`div`,{children:[l(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices — default model per accelerator`}),l(Ae,{nodeId:e,nodeName:d,isOnline:f})]}),r(`div`,{children:[l(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection steps — model per accelerator`}),l(Zt,{nodeId:e,refreshToken:t})]})]})}var nn=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],rn=`decoder-nodeav`;function an({nodeId:e,refreshToken:t}){let{data:n}=z(void 0),i=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??rn,a=[...nn,i];return r(`div`,{className:`flex flex-col h-full`,children:[l(gt,{nodeId:e,refreshToken:t}),l(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:l(ot,{nodeId:e,addonIds:a,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:l(Nt,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:l(tn,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:l(Ft,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:l(Gt,{nodeId:e,refreshToken:t})},{id:`logs`,label:`Logs`,order:300,content:l(Jt,{nodeId:e})}]})})]})}function on(){return r(`div`,{className:`space-y-6`,children:[l(Yt,{title:`Cluster cameras`}),r(`div`,{className:`min-w-0`,children:[l(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),l(`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.`})]}),l(St,{mode:`cluster`})]})}var sn=`pipeline-orchestrator`,cn=`recorder`,ln=`recordingNodeId`,un=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`],dn=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function fn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function pn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function mn(e,t,n){let r=fn(e,t);return typeof r==`string`&&r.length>0?r:n}function hn(e,t,n){let r=fn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function gn(e,t){let n=pn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function _n(e,t){let n=pn(e,t);return typeof n==`string`&&n.length>0?n:null}function vn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:`Motion Node`}function yn(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:e===`audioNode`?`Node that runs singleton audio work`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function bn(e,t){switch(t){case`detect`:return e.pipeline}}function xn(e){return e instanceof Error?e.message:`Failed to save`}function Sn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function Cn({capability:e,label:t,hint:n,nodeId:i,active:a,pending:o,layout:s,onToggle:c}){let u=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?tt:Te;return r(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":`${t} capability for ${i}`,title:`${t} — ${n}`,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 ${u} ${d}`,children:[l(f,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),l(`span`,{children:t})]})}function wn({node:e,emphasis:t=!1}){let n=e.isHub?Be:G;return r(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[l(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),l(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[l(`span`,{className:`truncate`,children:e.name}),e.isHub&&l(k,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&l(k,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),l(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}n();function Tn({nodeId:e,value:t,detectedHosts:n,status:i,errorMessage:a,onCommit:o}){let[s,d]=c(t??``);u(()=>{d(t??``)},[t]);let f=n[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 r(`div`,{className:`flex items-center gap-1.5`,children:[l(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:p,value:s,disabled:m,onChange:e=>d(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&d(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`}),r(`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?l(W,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):l(tt,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!g&&!m&&i===`success`&&l(tt,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),i===`error`&&l(`span`,{title:a??`Failed to save reachable host`,children:l(Ge,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":a??`Failed to save reachable host`,role:`img`})})]})}function En({label:e,children:t}){return r(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function Dn({node:e,actions:t}){return r(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[l(wn,{node:e,emphasis:!0}),l(`div`,{className:`grid grid-cols-2 gap-2`,children:dn.map(n=>l(Cn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:bn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),l(`div`,{className:`space-y-3 border-t border-border pt-3`,children:l(En,{label:`Reachable host`,children:l(Tn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function On(){return r(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[r(`span`,{className:`inline-flex items-center gap-1.5`,children:[l(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),r(`span`,{className:`inline-flex items-center gap-1.5`,children:[l(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),r(`span`,{className:`inline-flex items-center gap-1.5`,children:[l(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),r(`span`,{className:`inline-flex items-center gap-1.5`,children:[l(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function kn({nodes:e,actions:t}){return l(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:r(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[l(`thead`,{children:r(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[l(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),dn.map(e=>l(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),l(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),l(`tbody`,{children:e.map(e=>r(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[l(`td`,{className:`px-4 py-3 align-middle`,children:l(wn,{node:e})}),dn.map(n=>l(`td`,{className:`px-3 py-3 text-center align-middle`,children:l(Cn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:bn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),l(`td`,{className:`px-4 py-3 align-middle`,children:l(Tn,{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 An({role:e,value:t,options:n,pending:i,onChange:a}){return r(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[l(`span`,{className:`text-xs font-semibold text-foreground`,children:vn(e)}),l(`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:n.map(e=>l(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:yn(e)})]})}function jn({roleValues:e,options:t,pending:n,lowFpsEnabled:i,fpsMinThreshold:a,onRoleChange:o,onLowFpsToggle:s}){return r(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[un.map(r=>l(An,{role:r,value:e[r],options:t,pending:n,onChange:o},r)),r(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[l(`input`,{type:`checkbox`,checked:i,disabled:n,onChange:e=>s(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),r(`span`,{className:`flex flex-col gap-0.5`,children:[l(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),r(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,i?`${a} fps`:`disabled`]})]})]})]})}n();function Mn(){let e=s(),{nodes:t}=_(),n=b(void 0),i=se({addonId:sn}),u=se({addonId:cn}),d=()=>Sn(e),f=S({onSuccess:d}),p=ne(),m=B({onSuccess:d}),h=V({onSuccess:d}),[g,v]=c(!1),y=a(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),x=a(()=>t.map(e=>{let t=y.get(e.id),n=pt(t,e.isHub),r=gn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:gn(t,`maxCameras`),reachableHost:_n(t,`reachableHost`),detectedHosts:e.localIps}}),[t,y]),C=x.filter(e=>e.effective.pipeline),w={ingestNode:mn(i.data,`ingestNode`,`hub`),recordingNode:mn(u.data,ln,`hub`),audioNode:mn(i.data,`audioNode`,`hub`),motionNode:mn(i.data,`motionNode`,`hub`)},T=a(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...un.map(e=>w[e]),...e])].filter(e=>e.length>0)},[t,w]),E=hn(i.data,`fpsMinThreshold`,0),D=E>0,O=n.isLoading||i.isLoading||u.isLoading,k=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},A=(e,t)=>{if(e===`recordingNode`){h.mutate({addonId:cn,patch:{[ln]:t}});return}h.mutate({addonId:sn,patch:{[e]:t}})},j=e=>{h.mutate({addonId:sn,patch:{fpsMinThreshold:e?Math.max(1,E):0}})},M=e=>m.variables?.agentNodeId===e?m.isPending?`pending`:m.isError?`error`:m.isSuccess?`success`:`idle`:`idle`,N=e=>M(e)===`error`?xn(m.error):null,P=async e=>{v(!0);try{for(let t of e)await p.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{v(!1),d()}},F={capabilityPending:f.isPending,onToggleCapability:k,onCommitReachableHost:(e,t)=>m.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:M,reachableHostErrorMessage:N};return r(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[r(`header`,{className:`flex items-start justify-between gap-4`,children:[r(`div`,{className:`space-y-1`,children:[l(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),l(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),O&&l(W,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),r(`div`,{className:`space-y-3`,children:[l(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),l(jn,{roleValues:w,options:T,pending:h.isPending,lowFpsEnabled:D,fpsMinThreshold:E,onRoleChange:A,onLowFpsToggle:j})]}),r(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[l(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),l(On,{})]}),x.length===0?l(`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.`}):r(o,{children:[l(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:x.map(e=>l(Dn,{node:e,actions:F},e.id))}),l(`div`,{className:`hidden @3xl/clustertab:block`,children:l(kn,{nodes:x,actions:F})})]})]}),r(`div`,{className:`space-y-3`,children:[l(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),l(Oe,{nodes:C,pending:g,onCommitWeights:e=>void P(e)})]}),r(`div`,{className:`space-y-3`,children:[l(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices`}),C.length===0?l(`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.`}):l(`div`,{className:`space-y-2`,children:C.map(e=>l(Ae,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline},e.id))})]})]})}n();var Nn=!1;function Pn({refreshToken:e}){let t=s(),{data:n}=z(void 0);a(()=>it(n??[]),[n]);let i=I({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return r(`div`,{className:`space-y-6`,children:[l(_t,{refreshToken:e}),l(Mn,{}),Nn,r(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[r(`div`,{className:`min-w-0`,children:[l(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Rebalance`}),l(`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.`})]}),r(`button`,{type:`button`,onClick:()=>i.mutate(void 0),disabled:i.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:[l(Ue,{className:`h-3.5 w-3.5`}),i.isPending?`Rebalancing…`:`Rebalance pipelines`]})]})]})}var Fn=[`pipeline-orchestrator`];function In({refreshToken:e}){return l(`div`,{className:`space-y-4 max-w-3xl`,children:l(ot,{nodeId:`hub`,addonIds:Fn,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})})}n();function Ln({refreshToken:e}){let t=s(),{data:n,isLoading:i}=N(),[a,u]=c(null),[f,p]=c(``),[m,h]=c(``),g=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},_=re({onSuccess:()=>{u(null),g()}}),v=d({onSuccess:g}),y=e=>{u(e.id),p(e.name),h(e.description??``)},b=()=>{u(null),p(``),h(``)},x=()=>{if(!a)return;let e=m.trim();_.mutate({id:a,name:f.trim()||`Untitled`,...e?{description:e}:{}})};if(i)return l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let S=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return l(`div`,{className:`space-y-6 max-w-4xl`,children:r(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[r(`div`,{children:[l(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),l(`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.`})]}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[S.length,` template`,S.length===1?``:`s`]})]}),S.length===0?r(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[l(Ie,{className:`h-6 w-6 opacity-40`}),l(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):l(`ul`,{className:`divide-y divide-border`,children:S.map(e=>{let t=a===e.id;return l(`li`,{className:`px-4 py-3 text-xs`,children:r(`div`,{className:`flex items-start gap-3`,children:[l(`div`,{className:`flex-1 min-w-0`,children:t?r(`div`,{className:`space-y-2`,children:[l(`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:f,onChange:e=>p(e.target.value),placeholder:`Template name`,autoFocus:!0}),l(`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)`})]}):r(o,{children:[l(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&l(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),r(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,r(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),l(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?r(o,{children:[r(`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:[l(tt,{className:`h-3 w-3`}),`Save`]}),r(`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:[l(Qe,{className:`h-3 w-3`}),`Cancel`]})]}):r(o,{children:[l(`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:l(Fe,{className:`h-3 w-3`})}),l(`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:l(et,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}var Rn=`pipeline-orchestrator`,zn=200;function Bn(){return r(`div`,{className:`flex flex-col gap-3`,children:[r(`div`,{children:[l(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),l(`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.`})]}),l(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:l(L,{addonId:Rn,limit:zn,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}n();var Vn=[{id:`assignments`,label:`Assignments`},{id:`balancer`,label:`Balancer`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function Hn({refreshToken:e}){let[t,n]=c(`assignments`);return r(`div`,{className:`flex flex-col h-full`,children:[r(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[l(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),l(`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.`})]}),l(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Vn.map(e=>l(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),r(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&l(on,{}),t===`balancer`&&l(Pn,{refreshToken:e}),t===`settings`&&l(In,{refreshToken:e}),t===`templates`&&l(Ln,{refreshToken:e}),t===`logs`&&l(Bn,{})]})]})}var Un=`armed:`;function Wn(e){return e.assignment.reasons.detection?.startsWith(Un)===!0}function Gn(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!Wn(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function Kn(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&&!Wn(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 qn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Jn(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Yn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Xn(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var Zn={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 Qn(e){if(!qn(e)||!Array.isArray(e.sections))return Zn;let t=Se(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)Xn(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Jn(n(`detectionFps`)),motionSources:Yn(n(`motionSources`)),motionFps:Jn(n(`motionFps`)),motionCooldownMs:Jn(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 $n(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(...$n(r.children,t+1));return n}function X({title:e,children:t}){return r(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[l(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),l(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return r(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[l(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),l(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&l(er,{})]})}function er(){return l(`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 tr={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 l(`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 ${tr[e]}`,children:t})}function $({children:e}){return l(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function nr({icon:e,label:t,nodeId:n,pinned:i,reason:a,overridden:s}){return r(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[l(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),l(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?l(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):r(o,{children:[l(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),i?r(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[l(lt,{className:`h-2.5 w-2.5`}),` manual`]}):r(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,a!==void 0&&a.length>0?a:`capacity`]}),s&&l(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function rr({assignment:e,settings:t,onlineNodes:n,pinPending:i,onDetectionPinChange:a}){let o=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,s=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return r(X,{title:`Where it runs`,children:[l(nr,{icon:G,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),l(nr,{icon:Je,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),l(nr,{icon:Ne,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),l(nr,{icon:Le,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),l(`div`,{className:`mt-1.5`,children:r(`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:[l(`option`,{value:`auto`,children:`Auto (load balanced)`}),s.map(e=>r(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function ir(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function ar(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function or(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function sr({streams:e,brokerProfiles:t,settings:n,motionEnabled:i,motionFpsLive:a}){let s=ar(t,n.detectionStreamProfile),c=ar(t,n.motionStreamProfile),u=n.motionSources.includes(`analyzer`);return r(X,{title:`Streams & motion`,children:[r(Z,{label:`Detect stream`,overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,s!==void 0&&` · ${s.width}×${s.height} ${s.codec}`]}),l(Z,{label:`Detect FPS`,overridden:n.overriddenKeys.has(`detectionFps`),children:or(n.detectionFps)}),r(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.join(` + `):`none`,i===!1&&` · inactive`]}),u&&r(o,{children:[r(Z,{label:`Motion stream`,overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,c!==void 0&&` · ${c.width}×${c.height} ${c.codec}`]}),r(Z,{label:`Motion FPS`,overridden:n.overriddenKeys.has(`motionFps`),children:[or(n.motionFps),a!==null&&` · live ${a.toFixed(1)}`]})]}),l(Z,{label:`Cooldown`,overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),l(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?l($,{children:`No streams registered`}):e.map(e=>r(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[l(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,ir(e)]},e.camStreamId))})]})}function cr({steps:e,audioModelId:t,audioEnabled:n,audioMode:i}){return r(X,{title:`Pipeline steps`,children:[e===void 0?l($,{children:`Resolving…`}):e.length===0?l($,{children:`No steps configured`}):l(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>l(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:r(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&l(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&r(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),l(`div`,{className:`mt-1`,children:r(Z,{label:`Audio class.`,children:[i??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var lr={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function ur({detection:e,live:t,detectionMode:n,modeOverridden:i}){if(e===null)return r(X,{title:`Detection runtime`,children:[l(Z,{label:`Mode`,overridden:i,children:n??`—`}),l($,{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,u=t?.queueDepth??e.queueDepth,d=_e(a),f=a===`active`&&o===0;return r(X,{title:`Detection runtime`,children:[r(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[r(`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:[l(oe,{phase:a,className:`h-2.5 w-2.5`}),d.label]}),t!==void 0&&l(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),l(Z,{label:`Mode`,overridden:i,children:n??`—`}),r(Z,{label:`FPS`,children:[l(`span`,{className:f?`text-danger font-semibold`:``,children:o.toFixed(1)}),r(`span`,{className:`text-foreground-subtle`,children:[` / `,s.toFixed(0),` configured`]})]}),r(Z,{label:`Inference`,children:[c.toFixed(0),` ms`,u>0&&r(`span`,{className:`text-warning`,children:[` · queue `,u]}),t!==void 0&&t.droppedFrames>0&&r(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),r(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),r(Z,{label:`Provisioning`,children:[l(Q,{tone:lr[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&r(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function dr({broker:e}){return e===null?l(X,{title:`Stream broker`,children:l($,{children:`Broker stage inactive or unreachable`})}):r(X,{title:`Stream broker`,children:[e.profiles.length===0?l($,{children:`No broker profiles`}):l(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,n=t&&e.inFps===0;return r(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[l(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${n?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),l(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),r(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),r(`span`,{className:`ml-auto shrink-0 ${n?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),r(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),r(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[r(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),r(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function fr({decoder:e,detectionActive:t}){if(e===null)return l(X,{title:`Decoder`,children:l($,{children:`Decoder stage inactive or unreachable`})});let n=t&&e.shm.framesWritten===0;return r(X,{title:`Decoder`,children:[l(Z,{label:`Node`,children:e.nodeId}),l(Z,{label:`Sessions`,children:e.sessionCount}),r(Z,{label:`SHM frames`,children:[l(`span`,{className:n?`text-danger font-semibold`:``,children:e.shm.framesWritten}),l(`span`,{className:`text-foreground-subtle`,children:` written`})]}),r(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&r(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),r(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&l(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}n();var pr=`pipeline-orchestrator`,mr={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},hr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function gr({problems:e}){return l(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>r(`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:[l($e,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),l(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function _r({deviceId:e,name:t,online:n,status:i,live:o,onlineNodes:c}){let u=s(),{data:d}=fe({addonId:pr,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:f}=me({deviceId:e},{staleTime:3e4}),p=a(()=>Qn(d),[d]),m=a(()=>f===void 0?void 0:$n(f.steps),[f]),h=a(()=>i===void 0?[]:Kn(i),[i]),g=()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},_=ue({onSuccess:g}),v=ce({onSuccess:g}),y=t=>{t===`auto`?v.mutate({deviceId:e}):_.mutate({deviceId:e,agentNodeId:t})},b=i===void 0?`idle`:Gn(i),x=h.some(e=>e.severity===`error`),S=h.length>0,C=x?`border-danger/50`:S?`border-warning/40`:`border-border`;return r(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${C} bg-background overflow-hidden`,children:[r(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[l(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${x?`bg-danger`:mr[b]}`,title:x?`Error`:hr[b],"aria-label":x?`Error`:hr[b],role:`img`}),l(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),r(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&l(Q,{tone:`danger`,children:`offline`}),r(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[p.detectionMode!==null&&l(Q,{tone:p.detectionMode===`disabled`?`warning`:p.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:p.detectionMode===`disabled`?`detection off`:p.detectionMode}),i?.recording!=null&&(i.recording.active?r(Q,{tone:`danger`,title:`Recording (${i.recording.mode})`,children:[l(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&r(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,i.recording.mode]}))]})]}),h.length>0&&l(gr,{problems:h}),i===void 0?l(`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.`}):r(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[l(rr,{assignment:i.assignment,settings:p,onlineNodes:c,pinPending:_.isPending||v.isPending,onDetectionPinChange:y}),l(ur,{detection:i.detection,live:o,detectionMode:p.detectionMode,modeOverridden:p.overriddenKeys.has(`detectionMode`)}),l(cr,{steps:m,audioModelId:f?.audio?.modelId??null,audioEnabled:i.audio?.enabled??f?.audio?.enabled??null,audioMode:p.audioMode}),l(sr,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:p,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null}),l(dr,{broker:i.broker}),l(fr,{decoder:i.decoder,detectionActive:i.detection?.phase===`active`})]})]})}n();var vr=5e3,yr=1e4,br=5e3;function xr(e){let t=s(),{data:n,isLoading:r}=ke(),{data:i,isLoading:o}=O({},{refetchInterval:vr}),{nodes:l}=_();u(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,p]=c(new Map);f(Ce.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&p(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})}),u(()=>{if(d.size===0)return;let e=setInterval(()=>{p(e=>{let t=Date.now()-yr,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},br);return()=>clearInterval(e)},[d.size]);let m=a(()=>{let e=new Map;for(let t of i??[])e.set(t.deviceId,t);return e},[i]);return{rows:a(()=>(n??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:m.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[n,m]),liveMetrics:d,onlineNodes:a(()=>(l??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[l]),isLoading:r||o}}n();function Sr({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:i,isLoading:o}=xr(e),s=a(()=>[...t.map(e=>{let t=e.status===void 0?[]:Kn(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=a(()=>{let e=0,t=0;for(let r of s)(r.errorCount>0||r.warningCount>0)&&(t+=1),(n.get(r.row.deviceId)?.phase??r.row.status?.detection?.phase)===`active`&&(e+=1);return{total:s.length,active:e,issues:t}},[s,n]);return o&&t.length===0?l(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?l(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):l(`div`,{className:`h-full overflow-y-auto`,children:r(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[r(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[r(`span`,{children:[l(`span`,{className:`font-semibold text-foreground`,children:c.total}),` cameras`]}),r(`span`,{children:[l(`span`,{className:`font-semibold text-success`,children:c.active}),` actively inferring`]}),r(`span`,{children:[l(`span`,{className:`font-semibold ${c.issues>0?`text-danger`:`text-foreground`}`,children:c.issues}),` `,`with issues`]}),l(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),s.map(({row:e})=>l(_r,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:i},e.deviceId))]})})}n();var Cr=`__cluster__`;function wr(e){return e===`cameras`?`cameras`:`nodes`}function Tr(){let[e,t]=Ze(),n=wr(e.get(`view`)),i=e.get(`node`)??`__cluster__`,[a,s]=c(0),[d,f]=c(!1);return u(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:Cr},{replace:!0})},[n,e,t]),r(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[r(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[r(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[l(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:i},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),l(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),l(`div`,{className:`flex items-center gap-2`,children:r(`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:[l(Re,{className:`h-3.5 w-3.5`}),`Refresh`]})})]}),n===`nodes`&&r(`button`,{type:`button`,onClick:()=>f(e=>!e),"aria-expanded":d,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:[r(`span`,{children:[d?`Hide`:`Show`,` node list`]}),l(Xe,{className:[`h-4 w-4 transition-transform`,d?`rotate-180`:``].join(` `)})]}),l(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?r(o,{children:[l(`aside`,{className:[d?`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:l(ht,{selectedNodeId:i,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),f(!1)},refreshToken:a})}),l(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:i===`__cluster__`?l(Hn,{refreshToken:a}):l(an,{nodeId:i,refreshToken:a})})]}):l(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:l(Sr,{refreshToken:a})})})]})}export{Tr as PipelinePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as c,q as l}from"./player-overlays-UTlrOH4s.js";import{Ao as u,Bo as d,Co as f,Eo as p,Ga as m,Ho as h,Io as g,Lo as _,Oo as v,Qt as y,Ro as b,So as x,To as S,Uo as C,Va as w,Vo as T,Wo as E,Xi as D,_n as O,aa as k,dn as A,ha as j,hn as M,ko as N,ks as P,nt as F,sn as ee,ta as te,ua as ne,wo as re,zr as I}from"./src-DVZrqMsD.js";import{Pt as L,ut as R}from"./src-C9CFJqET.js";import{t as ie}from"./circle-x-CJJu15h-.js";import{t as ae}from"./download-BkhXjXOx.js";import{t as z}from"./hard-drive-fVjmkYpz.js";import{C as B,G as V,K as H,M as U,O as W,V as G,i as K,s as q}from"./index-DM4pp8Vx.js";import{t as oe}from"./AdminPage-CCD07UMs.js";import{r as se}from"./authed-media-BPd_L9jr.js";import{t as ce}from"./DeviceAggregateSection-CZPFsC_N.js";import{t as le}from"./AdminTabs-Ea5QF5Xy.js";import{t as J}from"./format-size-CO9d3C3-.js";import{i as Y,n as ue,r as de,t as fe}from"./AddLocationWizard-De7ns5QL.js";var X=H(`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`}]]),Z=H(`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`}]]),pe=H(`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();function me(){let e=I({}),t=r(()=>(e.data??[]).filter(e=>e.type===R.Camera).sort((e,t)=>e.name.localeCompare(t.name)),[e.data]),[i,s]=a(null),c=i??t[0]?.id??null;return!e.isLoading&&t.length===0?o(y,{icon:G,title:`No cameras`,description:`Add a camera first.`}):n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),o(`select`,{value:c??``,onChange:e=>s(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:t.map(e=>o(`option`,{value:e.id,children:e.name},e.id))})]}),c!==null&&o(ee,{deviceId:c,children:o(ce,{deviceId:c,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},c)]})}t();var he=[`high`,`mid`,`low`],ge=[{value:1,label:`Real time (1×)`},{value:2,label:`2×`},{value:4,label:`4×`},{value:8,label:`8×`},{value:16,label:`16×`}],_e=10080*60*1e3;function Q(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 ve({onClose:e,onCreated:t}){let i=I({}),s=r(()=>(i.data??[]).filter(e=>e.type===R.Camera).sort((e,t)=>e.name.localeCompare(t.name)),[i.data]),[c,l]=a(``),[u,d]=a(`high`),[f,p]=a(Q(60)),[m,h]=a(Q(0)),[g,_]=a(1),[v,y]=a(!0),[b,x]=a(``),[S,C]=a(null),w=c===``?s[0]?.id??null:c,T=new Date(f).getTime(),E=new Date(m).getTime(),D=Number.isFinite(T)&&Number.isFinite(E)&&T<E,O=re({onSuccess:()=>{t(),e()},onError:e=>C(e instanceof Error?e.message:String(e))});return o(`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:[o(W,{className:`h-3.5 w-3.5`}),`New export`]}),o(`button`,{onClick:e,className:`text-foreground-subtle hover:text-foreground`,children:o(K,{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:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),o(`select`,{value:w??``,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:s.map(e=>o(`option`,{value:e.id,children:e.name},e.id))})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Profile`}),o(`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:he.map(e=>o(`option`,{value:e,children:e},e))})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`From`}),o(`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:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`To`}),o(`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:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Speed`}),o(`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:ge.map(e=>o(`option`,{value:e.value,children:e.label},e.value))})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Title (optional)`}),o(`input`,{type:`text`,value:b,onChange:e=>x(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:[o(`input`,{type:`checkbox`,checked:v,disabled:g!==1,onChange:e=>y(e.target.checked),className:`accent-primary`}),`Include audio`,g===1?``:` (real-time only)`]}),!D&&o(`p`,{className:`text-[11px] text-danger`,children:`"From" must be before "To".`}),S&&o(`p`,{className:`text-[11px] text-danger`,children:S})]}),n(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[o(`button`,{onClick:e,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Cancel`}),o(`button`,{onClick:()=>{if(w===null||!D)return;C(null);let e=b.trim();O.mutate({deviceId:w,profile:u,fromMs:T,toMs:E,options:{includeAudio:v,maxLifeMs:_e,deleteAfterDownload:!1,...g===1?{}:{speed:g},...e.length>0?{title:e}:{}}})},disabled:w===null||!D||O.isPending,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:O.isPending?`Queuing…`:`Create export`})]})]})})}function ye(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 be(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function xe(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`${be(e)} · ${o}`}function Se(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 Ce(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 we=[[`recordingExport`]],Te={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 Ee(){let{data:e,isLoading:t}=p({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:n}=P(L.RecordingExportProgress,e=>e.exportId),{map:i}=P(L.RecordingExportCompleted,e=>e.exportId),{map:a}=P(L.RecordingExportFailed,e=>e.exportId);return{rows:r(()=>Ce(e??[],n,i,a),[e,n,i,a]),isLoading:t}}function De(e){let[t,n]=a(()=>Date.now());return s(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Oe(){let t=i(),[s,l]=a(!1),u=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},d=A(),p=c().trpcClient,m=De(6e4),{rows:h,isLoading:g}=Ee(),{data:_}=I({}),v=r(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),b=e(()=>{t.invalidateQueries({queryKey:we})},[t]),x=f({onSuccess:b}),C=S({onSuccess:b}),[w,T]=a(null),E=e(async e=>{T(e.id);try{let{url:t}=await p.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await se(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),b()}finally{T(null)}},[p,b]),D=e(async e=>{await d({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&x.mutate({exportId:e.id})},[d,x]),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=>o(`span`,{className:`text-foreground`,children:v.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:xe(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>o(`span`,{className:`text-foreground-subtle`,children:ye(e.options)})},{key:`state`,header:`State`,render:e=>{let t=Te[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&&o(B,{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`?o(`span`,{className:`text-foreground-subtle`,children:`—`}):o(`span`,{className:`text-foreground-subtle tabular-nums`,children:Se(e.expiresAt,m)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:J(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?o(B,{className:`h-3 w-3 animate-spin`}):o(ae,{className:`h-3 w-3`}),`Download`]}),r&&n(`button`,{onClick:()=>{D(e)},disabled:x.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:[o(ie,{className:`h-3 w-3`}),`Cancel`]}),i&&o(`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:o(q,{className:`h-3 w-3`})})]})}}],[v,m,w,x.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:[o(B,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):n(`div`,{className:`space-y-3`,children:[o(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>l(!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:[o(W,{className:`h-3.5 w-3.5`}),`New export`]})}),h.length===0?o(y,{icon:W,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.`}):o(F,{columns:k,rows:h,rowKey:e=>e.id,minWidthPx:720}),s&&o(ve,{onClose:()=>l(!1),onCreated:u})]})}function ke(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Ae(e,t){let n=ke(e);return n.length===0?`default root`:n.map(e=>t.get(e)??e).join(` + `)}function je(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:Ae(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>ke(e).includes(n));return i===void 0?null:{label:Ae(i,t),exact:!1}}var Me=[`ok`,`warn`,`critical`];function Ne(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Pe(e){return Math.min(1,Math.max(0,e))}function Fe(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Pe((n-t)/n);return{fraction:r,severity:Ne(r),recordingsFraction:Pe(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Ie(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=Fe(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Me.indexOf(e.severity)>Me.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}t();var Le=[[`recording`]],Re=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}],ze={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Be={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Ve(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 He(){let t=i(),s=A(),[c,d]=a(`retention`),{data:f,isLoading:p}=v({},{refetchOnWindowFocus:!1}),{data:m}=I({}),{data:h}=b({}),g=r(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),_=r(()=>{let e=new Map;for(let t of h??[])e.set(t.id,t.displayName);return e},[h]),S=r(()=>(h??[]).find(e=>e.type===`recordings`&&e.isDefault)?.id??null,[h]),C=r(()=>f?.locations??[],[f?.locations]),w=r(()=>je(C,_,S),[C,_,S]),T=r(()=>Ie(C),[C]),E=e(()=>{t.invalidateQueries({queryKey:Le})},[t]),D=u({onSuccess:E}),O=x({onSuccess:E}),k=e(async e=>{await s({title:`Prune ${g.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})},[s,D,c,g]),j=e(async e=>{await s({title:`Delete all footage for ${g.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${J(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${J(e.usedBytes)}`,variant:`danger`})&&O.mutate({deviceId:e.deviceId})},[s,O,g]),M=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:g.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:`Disk`,nowrap:!0,render:()=>w===null?o(`span`,{className:`text-foreground-subtle`,children:`—`}):n(`span`,{className:w.exact?`text-foreground`:`text-foreground-subtle`,title:w.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:[w.label,!w.exact&&o(`span`,{className:`ml-1 text-foreground-subtle`,children:`(default)`})]})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:J(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:[o(Z,{className:`h-3 w-3`}),`Prune`]}),n(`button`,{onClick:()=>{j(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:[o(q,{className:`h-3 w-3`}),`Delete`]})]})}],[g,w,k,j,D.isPending,O.isPending]);if(p&&!f)return n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(B,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!f)return o(y,{icon:z,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let N=f.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:[o(l,{label:`Total used`,icon:o(z,{className:`h-3 w-3`}),footer:`${String(N)} camera${N===1?``:`s`} on ${f.nodeId}`,children:J(f.totalUsedBytes)}),T!==null&&T.severity!==null&&o(l,{label:`Free on recordings volumes`,icon:o(z,{className:`h-3 w-3`}),footer:`across ${String(T.knownVolumes)} volume${T.knownVolumes===1?``:`s`} of ${J(T.totalBytes)}`+(T.unknownVolumes>0?` · ${String(T.unknownVolumes)} did not report capacity`:``),children:o(`span`,{className:`tabular-nums ${Be[T.severity]}`,children:J(T.freeBytes)})}),C.map(e=>{let t=Fe(e),r=e.locationId??e.root??`default`;return o(l,{label:`Disk: ${Ve(e,_)}`,footer:t===null?`${J(e.usedBytes)} of recordings · volume capacity unknown`:`${J(t.freeBytes)} free of ${J(t.totalBytes)} · ${J(e.usedBytes)} recordings (${$(t.recordingsFraction)})`,children:t===null?o(`span`,{className:`tabular-nums`,children:J(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:[o(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:o(`div`,{className:`h-full rounded ${ze[t.severity]}`,style:{width:$(t.fraction)}})}),o(`span`,{className:`tabular-nums text-xs ${Be[t.severity]}`,children:$(t.fraction)})]})},r)})]}),n(`section`,{className:`flex items-center gap-2 text-xs`,children:[o(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:`Prune reason`}),o(`select`,{id:`prune-reason`,value:c,onChange:e=>{let t=Re.find(t=>t.value===e.target.value);t&&d(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Re.map(e=>o(`option`,{value:e.value,children:e.label},e.value))})]}),N===0?o(y,{icon:z,title:`No recorded footage`,description:`No camera has recorded footage on this node yet.`}):o(F,{columns:M,rows:[...f.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}t();var Ue=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],We={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`};function Ge(e){return new Date(e).toLocaleString()}function Ke(){let[e,t]=a(`all`),{data:i,isLoading:s}=N({},{refetchOnWindowFocus:!1}),{data:c,isLoading:l}=ne({},{refetchOnWindowFocus:!1}),{data:u}=I({}),d=r(()=>{let e=new Map;for(let t of u??[])e.set(t.id,t.name);return e},[u]),f=r(()=>{let t=[...i??[],...c??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[i,c,e]),p=r(()=>[{key:`at`,header:`When`,nowrap:!0,render:e=>o(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ge(e.at)})},{key:`domain`,header:`Domain`,render:e=>o(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${We[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,render:e=>o(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,render:e=>o(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,render:e=>e.deviceId===null?o(`span`,{className:`text-foreground-subtle`,children:`cluster`}):o(`span`,{className:`text-foreground`,children:d.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?J(e.bytesReclaimed):`—`})}],[d]),m=s||l;return n(`div`,{className:`flex flex-col gap-4`,children:[o(`div`,{className:`flex items-center gap-1`,children:Ue.map(n=>o(`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))}),m&&f.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(B,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):f.length===0?o(y,{icon:V,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):o(F,{columns:p,rows:f,rowKey:e=>e.id,minWidthPx:720})]})}t();function qe({types:e}){let t=i(),s=A(),{data:c}=b({}),l=_(),u=r(()=>l.data??[],[l.data]),[d,f]=a(null),[p,m]=a(null),h=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},v=E({onSuccess:h}),y=g({onSuccess:h}),x=r(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),S=e=>{e.isDefault||v.mutate(Y(e,{isDefault:!0}))},C=(e,t)=>{v.mutate(Y(e,{enabled:t}))},w=async e=>{if(e.isDefault){await s({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await s({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&y.mutate({id:e.id})},T=e.map(e=>u.find(t=>t.id===e)).filter(e=>e!==void 0);return n(`div`,{className:`space-y-3`,children:[T.length===0?o(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):T.map(e=>o(de,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:x.get(e.id)??[],onAdd:e=>f(e),onEdit:e=>m(e),onDelete:e=>{w(e)},onSetDefault:e=>S(e),onToggleEnabled:(e,t)=>C(e,t)},e.id)),d!==null&&o(fe,{initialType:d,onClose:()=>f(null),onCreated:()=>{h(),f(null)}}),p!==null&&o(ue,{location:p,onClose:()=>m(null),onSaved:()=>{h(),m(null)}})]})}t();var Je=`pipeline-analytics`;function Ye(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 Xe(){let e=i(),{data:t}=D(void 0),{data:a,isLoading:s}=M({addonId:Je}),c=Ye(a),l=O({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:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),o(`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:[s?o(B,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):o(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Je,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=>o(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&o(B,{className:`h-4 w-4 animate-spin text-primary`})]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),o(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),o(qe,{types:[`eventMedia`]})]})]})}t();var Ze=`recorder`;function Qe(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 $e(){let e=i(),{data:t}=D(void 0),{data:a,isLoading:s}=M({addonId:Ze}),c=Qe(a,`recordingNodeId`,`hub`),l=O({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:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),o(`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:[s?o(B,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):o(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Ze,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=>o(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&o(B,{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`,` `,o(`span`,{className:`font-medium`,children:c}),`. If the auto-derived host doesn't work, set the recorder's`,o(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),o(`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.`}),o(qe,{types:[`recordings`,`recordingsLow`]})]})]})}t();var et=2e3;function tt(){let e=A(),t=i(),r=m(),a=w(void 0,{refetchInterval:e=>e.state.data?.state===`running`?et:!1}),c=a.data,l=c?.state===`running`,u=l||r.isPending;s(()=>{c?.state!==`done`||c.finishedAtMs===null||(t.invalidateQueries({queryKey:[[`recording`]]}),t.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[c?.state,c?.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 a.refetch())},f=l?c.total>0?`Reconciling ${String(c.completed)}/${String(c.total)}…`:`Reconciling…`:r.isPending?`Reconciling…`:`Reconcile from disk`;return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Disk reconcile`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Makes the database match the filesystem for recordings, tracks, events and media. Rows whose files are gone are deleted, including snapshot-less motion events. Enrolled identities stay. The walk runs on the hub; you can leave this page.`}),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?o(B,{className:`h-3.5 w-3.5 animate-spin`}):o(z,{className:`h-3.5 w-3.5`}),f]}),c?.state===`done`?n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Last run: `,String(c.completed),` camera(s) — dropped `,String(c.tracks),` tracks,`,` `,String(c.events),` events, `,String(c.mediaDropped),` media`,c.failed.length>0?`, ${String(c.failed.length)} failed (${c.failed.join(`, `)})`:``,`.`]}):null,c?.state===`error`&&c.error!==null?n(`p`,{className:`text-[11px] text-destructive`,children:[`Reconcile failed: `,c.error]}):null]})]})}t();var nt=[[`pipelineAnalytics`]],rt=1440*60*1e3,it=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function at(){let t=i(),s=A(),[c,u]=a(30),{data:d,isLoading:f}=k({},{refetchOnWindowFocus:!1}),{data:p}=I({}),m=r(()=>{let e=new Map;for(let t of p??[])e.set(t.id,t.name);return e},[p]),h=e(()=>{t.invalidateQueries({queryKey:nt})},[t]),g=j({onSuccess:h}),_=te({onSuccess:h}),v=e(async()=>{await s({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`})&&g.mutate({olderThanMs:Date.now()-c*rt,reason:`retention`})},[s,g,c]),b=e(async e=>{await s({title:`Delete all events for ${m.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${J(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})&&_.mutate({deviceId:e.deviceId})},[s,_,m]),x=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:m.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`rows`,header:`Events`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:`Media`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:J(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`button`,{onClick:()=>{b(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all events for this camera`,children:[o(q,{className:`h-3 w-3`}),`Delete`]})}],[m,b,_.isPending]);return f&&!d?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(B,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):d?n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[o(l,{label:`Total events`,icon:o(U,{className:`h-3 w-3`}),footer:`across ${String(d.devices.length)} camera${d.devices.length===1?``:`s`}`,children:d.totalRows.toLocaleString()}),o(l,{label:`Event media on disk`,children:J(d.totalBytes)})]}),n(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[o(`span`,{className:`text-foreground-subtle`,children:`Prune events older than`}),o(`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:it.map(e=>o(`option`,{value:e.days,children:e.label},e.days))}),n(`button`,{onClick:()=>{v()},disabled:g.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:[g.isPending?o(B,{className:`h-3 w-3 animate-spin`}):o(Z,{className:`h-3 w-3`}),`Prune now`]})]}),d.devices.length===0?o(y,{icon:U,title:`No stored events`,description:`No camera has persisted events yet.`}):o(F,{columns:x,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]}):o(y,{icon:U,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}t();var ot=`storage-migration`;function st(){let{data:e}=D(void 0);return(e??[]).some(e=>e.addons.some(e=>e.capabilities.includes(ot)))}var ct=[{id:`recordings`,label:`Recordings`,locationType:`recordings`},{id:`recordingsLow`,label:`Low-res recordings`,locationType:`recordingsLow`},{id:`eventMedia`,label:`Event media`,locationType:`eventMedia`}],lt=new Set([`planning`,`pausing`,`moving`,`verifying`,`repointing`,`refreshing`,`resuming`]);function ut(){return st()?o(dt,{}):o(y,{icon:X,title:`Storage migration not installed`,description:`This system doesn't advertise the storage-migration capability yet. Once it's deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`})}function dt(){let e=A(),{data:t}=b({}),[i,s]=a({}),[c,l]=a(null),[u,f]=a(null),p=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]),m=C({},{refetchInterval:2e3}),g=m.data??null,_=g!==null&<.has(g.phase),v=r(()=>{let e={};for(let t of ct){let n=i[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[i]),y=T({destinations:v??{}},{enabled:!1,retry:!1}),x=h(),S=d(),w=async()=>{if(!v)return;f(null);let e=await y.refetch();if(e.error){f(e.error instanceof Error?e.error.message:String(e.error));return}l(e.data??null)},E=async()=>{if(v&&await e({title:`Start storage migration?`,message:`Pauses the affected writers, copies the data to the new locations, verifies it, then repoints the defaults. Safe to re-run if interrupted.`,confirmLabel:`Start migration`,variant:`danger`})){f(null);try{await x.mutateAsync({destinations:v}),l(null),await m.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}},D=async()=>{if(g&&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 S.mutateAsync({jobId:g.jobId}),await m.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:[o(X,{className:`h-3.5 w-3.5`}),`Storage migration`]}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Move recordings, low-res recordings and/or event media to new storage locations in one coordinated operation: pauses the writers, copies via the recorder / pipeline-analytics movers, verifies, then repoints the defaults. Always applies to every camera — destinations are global defaults per storage class, so migration can't be scoped to a subset of cameras. This is the only supported way to move a storage location's data — the Storage tab no longer offers a per-location "Relocate" action.`}),o(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:ct.map(e=>{let t=p.get(e.locationType)??[];return n(`div`,{className:`space-y-1`,children:[o(`label`,{htmlFor:`migration-dest-${e.id}`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.label}),n(`select`,{id:`migration-dest-${e.id}`,value:i[e.id]??``,onChange:t=>{let n=t.target.value;s(t=>({...t,[e.id]:n}))},disabled:_,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`— unchanged —`}),t.map(e=>o(`option`,{value:e.id,children:e.displayName},e.id))]})]},e.id)})}),u&&o(`p`,{className:`mt-2 text-[11px] text-danger`,children:u}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[n(`button`,{type:`button`,onClick:()=>{w()},disabled:!v||y.isFetching||_,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:[y.isFetching&&o(B,{className:`h-3 w-3 animate-spin`}),`Plan`]}),n(`button`,{type:`button`,onClick:()=>{E()},disabled:!v||x.isPending||_,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:[x.isPending&&o(B,{className:`h-3 w-3 animate-spin`}),`Start migration`]})]}),c&&o(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:c.moves.length===0?o(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:`Nothing to move — selected destinations match the current defaults.`}):c.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}`))})]}),g&&n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`div`,{className:`flex items-center justify-between`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Migration status`}),_&&n(`button`,{type:`button`,onClick:()=>{D()},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:[o(K,{className:`h-3 w-3`}),`Cancel`]})]}),n(`p`,{className:`mt-1 text-xs text-foreground`,children:[`Phase: `,o(`span`,{className:`font-medium`,children:g.phase}),_&&o(B,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),g.error&&o(`p`,{className:`mt-1 text-[11px] text-danger`,children:g.error}),g.pausedParticipants.length>0&&n(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[`Paused: `,g.pausedParticipants.join(`, `)]}),o(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:g.moves.map(e=>n(`div`,{className:`flex items-center justify-between px-2.5 py-1.5 text-[11px]`,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.storageClass))})]})]})}function ft(){return n(`div`,{className:`flex flex-col gap-8`,children:[n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Recording`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The cluster recording node and recordings folders.`}),n(`div`,{className:`mt-3 flex flex-col gap-6`,children:[o($e,{}),o(tt,{})]})]}),n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Events`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The cluster post-processing node, the events folder, and the durable event-store footprint with retention and per-camera deletion.`}),n(`div`,{className:`mt-3 flex flex-col gap-6`,children:[o(Xe,{}),o(at,{})]})]}),n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Migration`}),o(`div`,{className:`mt-3`,children:o(ut,{})})]})]})}function pt(){return o(oe,{icon:W,title:`Recordings`,subtitle:`Recording node & storage, event-store management, exported clips, and an activity log.`,children:o(le,{tabs:[{id:`storage`,label:`Storage`,icon:z,content:o(He,{})},{id:`cameras`,label:`Cameras`,icon:G,content:o(me,{})},{id:`exports`,label:`Export`,icon:W,content:o(Oe,{})},{id:`activity`,label:`Activity`,icon:V,content:o(Ke,{})},{id:`management`,label:`Management`,icon:pe,content:o(ft,{})}]})})}export{pt as RecordingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{K as e}from"./index-DM4pp8Vx.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{K as e}from"./index-DM4pp8Vx.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};
|