@camstack/addon-admin-ui 1.2.526 → 1.2.527
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/CHANGELOG.md +11 -0
- package/dist/assets/{AddonAssetIcon-Bk09xHqf.js → AddonAssetIcon-BZ0hQcho.js} +1 -1
- package/dist/assets/Addons-BAqAfY0r.js +5 -0
- package/dist/assets/{AdminPage-CYSYefaL.js → AdminPage-7avIuDBh.js} +1 -1
- package/dist/assets/{AdminSectionedPage-B4MRvqE8.js → AdminSectionedPage-Bd2owMGm.js} +1 -1
- package/dist/assets/AiProfiles-aCDtxD2T.js +3 -0
- package/dist/assets/BrokerEditorDialog-Cp7neyJC.js +1 -0
- package/dist/assets/Build-SObpGxas.js +40 -0
- package/dist/assets/{Calendars-D4ed6Nqc.js → Calendars-B2TORAnq.js} +1 -1
- package/dist/assets/Cluster-CD4DYic_.js +1 -0
- package/dist/assets/{ComposedDeviceEditDialog-DJ5mqI6C.js → ComposedDeviceEditDialog-BiIiBFG-.js} +1 -1
- package/dist/assets/CompositionBlockEditor-BXYXXUEU.js +2 -0
- package/dist/assets/{CompositionEditorPage-4rHclFIA.js → CompositionEditorPage-Cm4C-7Z-.js} +1 -1
- package/dist/assets/Data-CRPVPhFT.js +2 -0
- package/dist/assets/{DeviceDetail-3jKJ80IC.js → DeviceDetail-DNsWQGiy.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-1jte2ge2.js → DeviceDoActionFields-BEhy6_KW.js} +1 -1
- package/dist/assets/{Devices-Bq4yRli5.js → Devices-CS5P4d9n.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DlIQigBi.js → EmbedPlayerPage-B7MIw7cv.js} +1 -1
- package/dist/assets/History-BbOfWf-p.js +1 -0
- package/dist/assets/Identity-Df140-fX.js +1 -0
- package/dist/assets/IntegrationDetail-B7sqZ94w.js +1 -0
- package/dist/assets/{IntegrationHub-8GCewFBs.js → IntegrationHub-DndCuqMe.js} +1 -1
- package/dist/assets/Integrations-BJh_WZAT.js +1 -0
- package/dist/assets/{Integrations-Bt3Im7Mh.js → Integrations-DRCpstaG.js} +1 -1
- package/dist/assets/{Library-DTn9Nkjs.js → Library-Cx17_SRL.js} +1 -1
- package/dist/assets/Locations-Dt9LOu5v.js +3 -0
- package/dist/assets/{Logs-BxTfJ-wk.js → Logs-CrxQn3Uq.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-DBEbXuH2.js → MaskShapeCanvas-tJyuoOTy.js} +1 -1
- package/dist/assets/{MotionZonesSettings-D3Xxjf5N.js → MotionZonesSettings-DaGyceJa.js} +1 -1
- package/dist/assets/{MyAccess-BTEJNJtS.js → MyAccess-Bp2dsON4.js} +1 -1
- package/dist/assets/Network-DftlNAIH.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-Do_I93Mx.js → NodeAddonsSettingsPanel-JIXh-CLX.js} +1 -1
- package/dist/assets/Notifications-2tj0VaIS.js +1 -0
- package/dist/assets/{Pipeline-Cjj8XOuS.js → Pipeline-CqZqLWQZ.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CswE6pks.js → PrivacyMaskSettings-zzQcpeb0.js} +1 -1
- package/dist/assets/Recordings-DoAJqZqc.js +1 -0
- package/dist/assets/{RemoteGrid-BjtzHkpg.js → RemoteGrid-Bz_u9tq6.js} +1 -1
- package/dist/assets/ScanNetworkModal-DL-mWRtG.js +1 -0
- package/dist/assets/{SceneMonitorEditor-C2X6jZvS.js → SceneMonitorEditor-B0ICySEi.js} +1 -1
- package/dist/assets/SessionsList-QvqpXCDN.js +2 -0
- package/dist/assets/{Showroom-CHwcC6p6.js → Showroom-B6CDELO1.js} +1 -1
- package/dist/assets/System-C0KUcOaJ.js +1 -0
- package/dist/assets/{Templates-tilFwunF.js → Templates-uAAxbV9V.js} +1 -1
- package/dist/assets/{Terminal-DiMnsE8i.js → Terminal-D1fhPY66.js} +5 -5
- package/dist/assets/{Viewer-BwirleAM.js → Viewer-BWN8qfBa.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-w6FCrjgB.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-sshFQYnL.js} +1 -1
- package/dist/assets/{addon-icons-context-CHk3ePjj.js → addon-icons-context-BHF-RdY-.js} +1 -1
- package/dist/assets/{archive-BU_eXxQC.js → archive-2V-x_y9T.js} +1 -1
- package/dist/assets/{assignment-candidates-B4bOK7k8.js → assignment-candidates-BpC51VXR.js} +1 -1
- package/dist/assets/{authed-media-BYuQnqbF.js → authed-media-CdbbdgDZ.js} +1 -1
- package/dist/assets/{bell-off-DCQedZIx.js → bell-off-DDQ8FbF1.js} +1 -1
- package/dist/assets/{board-model-t0EX_kXW.js → board-model-D3wYwuI4.js} +1 -1
- package/dist/assets/{boxes-BZMO9uMf.js → boxes-BwEV9Act.js} +1 -1
- package/dist/assets/circle-slash-BjzSCz4-.js +1 -0
- package/dist/assets/client-r4i0EpF6.js +711 -0
- package/dist/assets/{cloud-upload-CApwQ18P.js → cloud-upload-BII8r4p9.js} +1 -1
- package/dist/assets/crop-D9cpl5_W.js +1 -0
- package/dist/assets/{device-integration-icon-CXG5v8dp.js → device-integration-icon-Cf2JTj5q.js} +1 -1
- package/dist/assets/device-picker-model-B_Zjyqyk.js +1 -0
- package/dist/assets/{dist-Hz1nnJDv.js → dist-B0LFF94V.js} +1 -1
- package/dist/assets/dist-BOdjk8IV.js +711 -0
- package/dist/assets/{file-up-cso0QIDs.js → file-up-Bizrs9Ca.js} +1 -1
- package/dist/assets/{format-Csy9sDox.js → format-Bqo-j708.js} +1 -1
- package/dist/assets/{grip-vertical-DqjjXK1h.js → grip-vertical-C-qhB3oM.js} +1 -1
- package/dist/assets/{hard-drive-download-D-ykdsm5.js → hard-drive-download-Dym9jihx.js} +1 -1
- package/dist/assets/{hostInit-CTFssGi8.js → hostInit-bmlgmSTk.js} +1 -1
- package/dist/assets/i18n-BE1bPZOs.js +1 -0
- package/dist/assets/icons-BZ8D05w2.js +1 -0
- package/dist/assets/index-DimGtYV1.css +2 -0
- package/dist/assets/index-Ohn-2iW_.js +4 -0
- package/dist/assets/{key-C_dbeH7F.js → key-DddJ6bil.js} +1 -1
- package/dist/assets/{key-round-CPg0Y5qN.js → key-round-CbCqycf3.js} +1 -1
- package/dist/assets/{layers-Cb-ro1vb.js → layers-C-ZqYk3U.js} +1 -1
- package/dist/assets/{linked-devices-model-ZCUJsj_d.js → linked-devices-model-BPUD1khJ.js} +1 -1
- package/dist/assets/{list-ordered-V6P5uujF.js → list-ordered-Cxznlat2.js} +1 -1
- package/dist/assets/{location-owned-usage-C6DcC3IT.js → location-owned-usage-DOmOvdiG.js} +1 -1
- package/dist/assets/{log-in-Cxvw8rxc.js → log-in-9Uirjetj.js} +1 -1
- package/dist/assets/{memory-stick-Mm_iVwSZ.js → memory-stick-CLL3KiND.js} +1 -1
- package/dist/assets/{message-square-plus-Bfam15lf.js → message-square-plus-C2nVnMG1.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-019f9c14.js → mf-entry-bootstrap-0-edf9b20a.js} +2 -2
- package/dist/assets/{mic-off-CeSZf8K2.js → mic-off-CcHQBwDt.js} +1 -1
- package/dist/assets/{monitor-off-U-RK64kw.js → monitor-off-DUE1gt1S.js} +1 -1
- package/dist/assets/{monitor-smartphone-DezRerVw.js → monitor-smartphone-CwOoXB0L.js} +1 -1
- package/dist/assets/mount-B_Zjyqyk.js +1 -0
- package/dist/assets/{player-overlays-DgedyCX9.js → player-overlays-Cw_gjG75.js} +1 -1
- package/dist/assets/{recycle-Dkb1d-SV.js → recycle-hW2Os1lc.js} +1 -1
- package/dist/assets/remoteEntry-CHuAXwj-.js +1 -0
- package/dist/assets/{ruler-DzpBI-EP.js → ruler-SYjqj9n_.js} +1 -1
- package/dist/assets/{scan-eye-BmLTXsIf.js → scan-eye-BZlKp5Ev.js} +1 -1
- package/dist/assets/{scissors-lBRCylhQ.js → scissors-Prn6Kbb7.js} +1 -1
- package/dist/assets/{search-x-BRhrXpKx.js → search-x-CCA8373c.js} +1 -1
- package/dist/assets/{send-DVJoNc0-.js → send-C5rCH5_0.js} +1 -1
- package/dist/assets/{settings-2-D6sp_FTm.js → settings-2-wlw_-rxi.js} +1 -1
- package/dist/assets/{shapes-CQn3wvpk.js → shapes-Kj0bK1D8.js} +1 -1
- package/dist/assets/{sigma-CKK8bLRa.js → sigma-NPxR3lj1.js} +1 -1
- package/dist/assets/{speaker-BYorOPbN.js → speaker-CIKbprnA.js} +1 -1
- package/dist/assets/src-nnHXOip7.js +67 -0
- package/dist/assets/{step-inspector-model-DEfajBM3.js → step-inspector-model-BKKc_lkM.js} +1 -1
- package/dist/assets/{table-2-BPB4V5Fg.js → table-2-Sw__YAPa.js} +1 -1
- package/dist/assets/{timer-reset-Cu_VSXbl.js → timer-reset-BhPZYoCT.js} +1 -1
- package/dist/assets/{unlink-BcrHT0zX.js → unlink-DNy8sNAV.js} +1 -1
- package/dist/assets/{usb-DhXPqJtn.js → usb-CyQsTtlO.js} +1 -1
- package/dist/assets/{use-device-bound-caps-K47AcsQ5.js → use-device-bound-caps-BQo_OD1O.js} +1 -1
- package/dist/assets/{use-scenes-feed-DQrMGL5E.js → use-scenes-feed-BCDAv1nN.js} +1 -1
- package/dist/assets/{use-stationary-objects-yu-O0RPa.js → use-stationary-objects-BnIfyZw5.js} +1 -1
- package/dist/assets/useEventInvalidation-B_Zjyqyk.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BuraZwll.js → useNodeUrlSelection-CR_BnlEg.js} +1 -1
- package/dist/assets/user-round-BY4YxbLZ.js +1 -0
- package/dist/assets/{user-x-DRSOzwTr.js → user-x-CUkBojXx.js} +1 -1
- package/dist/assets/variable-CpgCMY_Q.js +1 -0
- package/dist/assets/{video-5IaJhdjU.js → video-DXegVNA2.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BtgDin-X.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-2LL0aB_0.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +902 -116
- package/package.json +1 -1
- package/dist/assets/Addons-BwXNg54C.js +0 -5
- package/dist/assets/AiProfiles-CRZH6xR0.js +0 -3
- package/dist/assets/BrokerEditorDialog-D9rZCGl9.js +0 -1
- package/dist/assets/Build-BJaqr-_Y.js +0 -40
- package/dist/assets/Cluster-Dkt_tVUy.js +0 -1
- package/dist/assets/CompositionBlockEditor-BEondavu.js +0 -2
- package/dist/assets/Data-pZe3A7Va.js +0 -2
- package/dist/assets/History-DTt-NAMR.js +0 -1
- package/dist/assets/Identity-C3GHYP7_.js +0 -1
- package/dist/assets/IntegrationDetail-EOwq3jVG.js +0 -1
- package/dist/assets/Integrations-BocurtE0.js +0 -1
- package/dist/assets/Locations-chgnzdWz.js +0 -3
- package/dist/assets/Network-plYS78UN.js +0 -1
- package/dist/assets/Notifications-mslnotOB.js +0 -1
- package/dist/assets/Recordings-BpB53ln_.js +0 -1
- package/dist/assets/ScanNetworkModal-BR3tzZcL.js +0 -1
- package/dist/assets/SessionsList-BOjlUhj5.js +0 -2
- package/dist/assets/System-CiZ0xcyP.js +0 -1
- package/dist/assets/circle-slash-DFl97Cbx.js +0 -1
- package/dist/assets/client-F3l12jEi.js +0 -674
- package/dist/assets/crop-gfwPOF8e.js +0 -1
- package/dist/assets/device-picker-model-Fpx4y0MY.js +0 -1
- package/dist/assets/dist-B2m_6_7g.js +0 -674
- package/dist/assets/i18n-BH0PY6IL.js +0 -1
- package/dist/assets/icons-B9uR9qKs.js +0 -1
- package/dist/assets/index-CQ7TjSgs.js +0 -4
- package/dist/assets/index-DjwiZ7qT.css +0 -2
- package/dist/assets/mount-Fpx4y0MY.js +0 -1
- package/dist/assets/remoteEntry-DpkkaSO3.js +0 -1
- package/dist/assets/src-B0EA_4Ed.js +0 -67
- package/dist/assets/useEventInvalidation-Fpx4y0MY.js +0 -1
- package/dist/assets/user-round-D6wDvac9.js +0 -1
- package/dist/assets/variable-cv0ONmJ-.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,i as c,o as l,p as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{A as f,Bn as p,D as m,Di as h,Dn as g,Fr as _,Hr as v,Ht as y,N as b,O as x,On as S,St as C,T as w,V as T,_n as E,_r as D,b as O,bn as k,dr as A,dt as j,gt as M,ha as N,ht as P,ii as F,j as I,k as L,ki as R,la as ee,mn as z,pr as B,rn as V,rr as H,st as U,ur as te,v as ne,y as re,z as W,zt as ie}from"./player-overlays-DgedyCX9.js";import{$r as ae,Br as oe,Cn as se,Go as ce,Hr as le,Ir as ue,Lr as de,Pr as fe,Rr as pe,Vr as me,Zr as he,ei as ge,f as _e,l as ve,ni as ye,ti as be,u as xe,zr as Se}from"./client-F3l12jEi.js";import{d as Ce,t as we,u as Te}from"./video-5IaJhdjU.js";import{a as Ee,i as De,n as Oe,r as ke,t as Ae}from"./usb-DhXPqJtn.js";import{t as je}from"./crop-gfwPOF8e.js";import{t as Me}from"./layers-Cb-ro1vb.js";import{n as Ne}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js";import{$c as Pe,$n as Fe,Ad as Ie,An as Le,At as Re,Bl as ze,Cl as Be,Cn as Ve,Cr as He,El as Ue,Fd as We,Fl as Ge,Fn as Ke,Fo as qe,Hd as Je,Hl as Ye,Id as Xe,Il as Ze,In as Qe,Jc as $e,Jn as et,Kn as tt,Ll as nt,Mi as rt,Nr as it,Oi as at,On as G,Pl as ot,Pn as st,Pr as ct,Qc as lt,Rl as ut,Sl as dt,Sr as ft,St as pt,Tl as mt,Tr as ht,Ud as gt,Wd as _t,Xc as vt,Xn as yt,Yc as bt,Yn as xt,Zn as St,Zt as Ct,af as wt,at as Tt,bl as Et,br as Dt,cl as Ot,cn as kt,di as K,dl as At,dr as jt,el as Mt,er as Nt,fl as Pt,fr as Ft,gl as It,gn as Lt,hl as Rt,hr as zt,hs as Bt,ht as Vt,if as Ht,il as Ut,it as Wt,jn as Gt,ki as Kt,kt as qt,lr as Jt,ml as Yt,ms as Xt,nf as Zt,nl as Qt,nr as $t,nt as en,of as tn,ps as nn,qc as rn,r as an,rf as on,ri as q,rl as sn,rr as cn,rt as ln,st as un,tf as J,tl as dn,tr as fn,tt as pn,vl as mn,vr as hn,wl as gn,wr as _n,wt as vn,xr as yn,yl as bn,yr as xn,zl as Sn}from"./src-B0EA_4Ed.js";import{t as Y}from"./i18n-BH0PY6IL.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{lr as Cn,mr as wn,pr as Tn,yr as En}from"./index-CQ7TjSgs.js";import{_ as Dn,a as On,b as kn,c as An,d as jn,f as Mn,g as Nn,h as Pn,i as Fn,l as In,m as Ln,n as Rn,p as zn,r as Bn,s as Vn,u as Hn,v as Un,y as Wn}from"./step-inspector-model-DEfajBM3.js";import"./useEventInvalidation-Fpx4y0MY.js";import{t as Gn}from"./NodeAddonsSettingsPanel-Do_I93Mx.js";import{a as Kn,c as qn,d as Jn,g as Yn,h as Xn,i as Zn,l as Qn,n as $n,o as er,p as tr,r as nr,s as rr,t as ir}from"./board-model-t0EX_kXW.js";s();function ar(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function or(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function sr(e){return e!==!1}function cr(e){return{pipeline:sr(or(e,`detect`)),audio:sr(or(e,`audio`)),ingest:sr(or(e,`ingest`))}}function lr(e,t){let n=e?.find(e=>e.nodeId===t);return cr(n?.settings)}function ur({selectedNodeId:t,onSelect:n,refreshToken:r}){let a=N(),{t:o}=X(),{nodes:s}=Zt(),{data:c}=Yt(void 0),{data:l}=mn(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let f=s??[],p=f.filter(e=>e.isOnline).length,m=f.filter(e=>!e.isOnline).length;return e(`div`,{className:`flex flex-col h-full`,children:[e(`button`,{type:`button`,onClick:()=>n(Yo),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${t===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[i(Te,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`text-xs font-semibold truncate`,children:o(`pipeline.nodeList.cluster`,`Cluster`)}),i(`div`,{className:`text-[10px] text-foreground-subtle`,children:o(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),i(`div`,{className:`flex-1 overflow-y-auto`,children:f.map(r=>{let s=t===r.id,c=u.get(r.id)??0,f=r.isHub?E:F,p=lr(l,r.id),m=r.isOnline?null:Ct(ar(r.lastSeen),a);return e(`button`,{type:`button`,onClick:()=>n(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${s?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[i(f,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:o(`common.hubWord`)}),!r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),e(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[i(`span`,{children:o(`common.coresCount`,{count:r.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),c>0&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[i(we,{className:`h-2.5 w-2.5`}),c]})]}),!r.isOnline&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`text-danger`,children:[o(`common.offline`),m===null?``:` · ${m}`]})]})]}),e(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[i(K,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?o(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):o(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:o(`pipeline.nodeList.pipe`,`Pipe`)}),i(K,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?o(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):o(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:o(`pipeline.nodeList.aud`,`Aud`)})]})]})]},r.id)})}),e(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[i(`span`,{children:o(`common.onlineCount`,{count:p})}),m>0&&i(`span`,{className:`text-danger`,children:o(`common.offlineCount`,{count:m})})]})]})}function dr({nodeId:t,refreshToken:n}){let{t:r}=X(),{nodes:a}=Zt(),o=a?.find(e=>e.id===t),s=on(`pipeline.runner-load-snapshot`,e=>e.nodeId===t)?.load??null;return o?e(`div`,{className:`px-6 py-4 border-b border-border`,children:[e(`div`,{className:`flex items-center gap-2 mb-1`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:o.name}),o.isOnline?i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:r(`common.online`)}):i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:r(`common.offline`)}),o.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:r(`common.hubWord`)})]}),e(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[i(`span`,{children:o.cpuModel??`CPU`}),i(`span`,{children:`•`}),i(`span`,{children:r(`common.coresCount`,{count:o.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(o.memoryMB/1024),` GB`]}),s&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.cameras`,{attached:s.attachedCameras,active:s.activeCameras})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.avgInference`,{ms:s.avgInferenceTimeMs.toFixed(0)})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.queue`,{depth:s.queueDepthTotal})}),s.hardware.hasGpu&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):i(`div`,{className:`px-6 py-4 border-b border-border`,children:e(`div`,{className:`text-xs text-foreground-subtle`,children:[r(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,t]})})}var fr=[`assignments`,`tree`,`engines`,`logs`];function pr({refreshToken:t,nodeId:r}){let{t:a}=X(),[s,c]=o(new Map),{nodes:l}=J();wt(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&c(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:u}=Ut(void 0),d=n(()=>{let e=new Map;for(let t of u??[])e.set(t.nodeId,t.deviceCount);return e},[u]),f=n(()=>{let e=new Map,t=Date.now()-3e4;for(let n of s.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[s]),p=n(()=>{let e=new Map;for(let t of l)e.set(t.id,t.shortName);return e},[l]),m=n(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of f.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:l.length,onlineAgents:l.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[f,l]);if(r){let t=f.get(r);return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[i(Z,{label:`FPS`,value:t?t.totalFps.toFixed(1):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:t?`${t.activeCameras}/${t.attachedCameras}`:`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:t&&t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.queue`,`Queue`),value:t?String(t.queueDepth):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(d.get(r)??`—`)})]})]})}let h=[...f.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[i(Z,{label:a(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),i(Z,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),i(Z,{label:a(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),i(Z,{label:a(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),i(Z,{label:a(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[480px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.liveLoadPanel.agent`,`Agent`)}),i(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.queue`,`Queue`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),e(`tbody`,{children:[h.map(([t,n])=>e(`tr`,{className:`border-t border-border`,children:[i(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(t)??t}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.totalFps.toFixed(1)}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras>0?(n.totalInferenceWeighted/n.attachedCameras).toFixed(0):`—`}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.queueDepth}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:d.get(t)??`—`})]},t)),h.length===0&&i(`tr`,{children:i(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function Z({label:t,value:n}){return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[i(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:t}),i(`div`,{className:`text-lg font-semibold text-foreground`,children:n})]})}var mr={active:!1,pinned:!1,nodeId:null,reason:``};function hr(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function gr(e,t,n){let r=new Map(t.map(e=>[e.deviceId,e])),i=new Map(n.map(e=>[e.deviceId,e]));return e.map(e=>{let t=r.get(e.id),n=i.get(e.id),a=t?{active:!0,pinned:t.pinned,nodeId:t.agentNodeId,reason:t.reason??``}:mr,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:mr;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:mr,audio:o}}).toSorted(hr)}function _r(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function vr(e,t){let n=new Map(t.map(e=>[e.deviceId,e.assignment]));return e.map(e=>{let t=n.get(e.deviceId);return t===void 0?e:{...e,detection:_r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:_r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:_r(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function yr(e,t,n){let r=(t,n,r)=>({active:t!==null&&t===e,pinned:n,nodeId:t,reason:r??``});return t.map(({deviceId:e,assignment:t})=>({deviceId:e,deviceName:n(e),detection:r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:r(t.audioNodeId,t.pinned.audio,t.reasons.audio)})).filter(e=>e.detection.active||e.decoder.active||e.audio.active).toSorted(hr)}function br(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>{let n=t.get(e);return n!==void 0&&n!==``?n:e}}function xr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??Y.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function Sr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:Y.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:Y.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function Cr({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:a,emphasizeOnNodeId:o}){if(n.nodeId===null)return null;let s=n.nodeId,c=o===void 0?!1:n.active&&s===o;return i(st,{roleId:e,roleLabel:t,nodeName:r(s),colorId:Qe(a,s),emphasized:c,pinned:n.pinned})}function wr({detection:t,decoder:n,audio:r,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s}){let c=(e,t,n)=>i(Cr,{roleId:e,roleLabel:t,state:n,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s},e);return e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[c(`detection`,`Detection`,t),c(`decode`,`Decode`,n),c(`audio`,`Audio`,r)]})}function Tr({snap:t}){let n=N(),{t:r}=X();if(t===void 0)return i(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:r(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:r(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:a,actualFps:o,avgInferenceTimeMs:s,queueDepth:c,configuredFps:l,droppedFrames:u}=t.metrics,d=Lt(a,n);return e(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[e(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${d.textColor}`,children:[i(Vt,{phase:a,className:`h-2.5 w-2.5 shrink-0`}),i(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:d.label}),i(`span`,{className:`text-foreground`,children:o.toFixed(1)}),i(`span`,{className:`text-foreground-subtle`,children:r(`pipeline.assignmentStatusCell.configuredFps`,{fps:l.toFixed(0)})})]}),e(`span`,{className:`truncate text-foreground-subtle`,children:[i(`span`,{className:`text-foreground`,children:s.toFixed(0)}),` ms`,c>0&&e(`span`,{className:`ml-1 text-warning`,children:[`q`,c]}),i(`span`,{className:u>0?`ml-1 text-warning`:`ml-1`,children:r(`pipeline.assignmentStatusCell.drops`,{count:u})})]})]})}s();var Er=1e4,Dr=5e3;function Or(e){let[t,n]=o(new Map);return wt(`pipeline.camera-metrics-snapshot`,t=>{let r=t.data;typeof r.deviceId==`number`&&(e!==void 0&&r.nodeId!==e||n(e=>new Map(e).set(r.deviceId,r)))}),a(()=>{if(t.size===0)return;let e=setInterval(()=>{n(e=>{let t=Date.now()-Er,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},Dr);return()=>clearInterval(e)},[t.size]),t}var kr=3e5;function Ar({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:a}){let{t:o}=X();return i(Ie,{"aria-label":o(`assignments.placementControls.nodePin`,`Node pin`),title:o(`assignments.placementControls.autoLetsEachSessionPick`,`Auto lets each session pick its node; a pin keeps the camera on one node.`),value:e.pinned&&e.nodeId!==null?e.nodeId:`auto`,disabled:r,options:[...Sr(e,t,n)],onChange:e=>a(e.target.value)})}function jr({deviceId:e,nodeId:t}){let{t:n}=X(),r=l(),{data:a}=Rt({deviceId:e},{refetchOnMount:`always`}),{data:o}=Pt({nodeId:t},{staleTime:kr}),s=Ze({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(a===void 0||o===void 0)return i(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let c=o.devices??[],u=c.filter(e=>e.enabled),d=a?.deviceKey??`auto`,f=d!==`auto`&&!u.some(e=>e.key===d),p=c.find(e=>e.key===d),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...f?[{value:d,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${jt(p)} (${d})`:d})}]:[],...u.map(e=>({value:e.key,label:`${jt(e)} · ${e.format}`}))];return i(Ie,{"aria-label":n(`assignments.placementControls.inferenceDevicePin`,`Inference device pin`),title:n(`assignments.placementControls.pinDetectionToOneAccelerator`,`Pin detection to one accelerator of the node, or let each session pick.`),value:d,disabled:s.isPending,options:m,onChange:t=>s.mutate({deviceId:e,deviceKey:t.target.value})})}s();function Mr(e){let n=t(null);return e.nodeId!==null&&(n.current=e),n.current}function Nr({deviceId:t,state:n,...r}){let{t:a}=X(),o=Mr(n);return e(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[i(Ar,{state:n,...r}),o?.nodeId==null?i(Ie,{"aria-label":a(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:a(`assignments.clusterRowCells.anAcceleratorIsPinnedOn`,`An accelerator is pinned on the camera's node; this camera has not run on one yet.`),disabled:!0,defaultValue:`auto`,options:[{value:`auto`,label:a(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):i(jr,{deviceId:t,nodeId:o.nodeId})]})}function Pr({state:t,nameOf:n}){let{t:r}=X(),a=Mr(t);if(a?.nodeId==null)return i(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let o=t.active&&t.nodeId!==null,s=a.pinned?`pinned`:`auto · ${a.reason||`capacity`}`;return e(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:a.pinned?void 0:r(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[e(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[i(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${o?`bg-success`:`bg-foreground-subtle/40`}`}),i(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${o?`text-foreground`:`text-foreground-muted`}`,children:n(a.nodeId)})]}),i(`span`,{className:`truncate pl-3 text-[10px] ${a.pinned?`text-warning`:`text-foreground-subtle`}`,children:o?s:r(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:s})})]})}function Fr({deviceId:t,deviceName:n}){let{t:r}=X(),[a,s]=o(!1);return e(d,{children:[i(Xe,{icon:S,variant:`ghost`,size:`sm`,"aria-label":r(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:n}),title:r(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>s(!0)}),i(xn,{open:a,onOpenChange:s,children:e(yn,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[i(_n,{children:i(ht,{children:r(`pipeline.clusterRowCells.brokersTitle`,{device:n})})}),i(Dt,{children:a&&i(hn,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t,instanceId:`pipeline-row/${t}`,config:{variant:`compact`}})})]})})]})}function Ir(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function Lr(e,t){return t.size===0?!0:t.has(e)}var Rr=[{value:`active`,get label(){return Y.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return Y.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return Y.t(`helpers.cameraActivity.inactive`)}}];s();var zr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function Br(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function Vr(){let{t}=X(),r=l();an([`pipelineOrchestrator`,`getPipelineAssignments`],zr),an([`pipelineOrchestrator`,`getAudioAssignments`],zr),an([`pipelineOrchestrator`,`getCameraStatuses`],zr);let{data:a}=qe({isCamera:!0,projection:`slim`}),{data:s}=Yt(void 0),{data:c}=sn(void 0),{data:u}=Ot({}),{data:d}=mn(void 0),{nodes:f}=J(),p=Or(),m=n(()=>br(f),[f]),h=n(()=>Ke(d),[d]),g=n(()=>f.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[f]),_=n(()=>vr(gr((a??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),s??[],c??[]),u??[]),[a,s,c,u]),[v,y]=o(()=>new Set),b=n(()=>_.filter(e=>Lr(Ir({hasPipelineAssignment:e.pipeline.active,hasFreshMetrics:p.has(e.deviceId)}),v)),[_,p,v]),x=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=()=>Br(r),C=Pe({onSuccess:S}),w=ze({onSuccess:S}),T=C.isPending||w.isPending,E=[{key:`camera`,header:t(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:n=>e(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[i(wn,{to:`/devices/${String(n.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:n.deviceName,children:n.deviceName}),n.disabled&&i(K,{variant:`default`,children:t(`common.off`)})]})},{key:`placement`,header:t(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>i(Nr,{deviceId:e.deviceId,state:e.pipeline,onlineNodes:g,nameOf:m,pending:T,onChange:t=>t===`auto`?w.mutate({deviceId:e.deviceId}):C.mutate({deviceId:e.deviceId,agentNodeId:t})})},{key:`roles`,header:t(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>i(wr,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:t(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>i(Pr,{state:e.pipeline,nameOf:m})},{key:`status`,header:t(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(Tr,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>i(Fr,{deviceId:e.deviceId,deviceName:e.deviceName})}],D=a===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return e(`div`,{className:`flex flex-col gap-2`,children:[i(`nav`,{"aria-label":t(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:i(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:Rr.map(e=>{let t=v.has(e.value);return i(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:gt(re,t?ne:O),onClick:()=>x(e.value),children:e.label},e.value)})})}),i(Le,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:Gt,emptyMessage:D})]})}s();function Hr({nodeId:e}){let{t}=X(),r=l();an([`pipelineOrchestrator`,`getCameraStatuses`],zr);let{data:a}=Ot({}),{data:o}=mn(void 0),{data:s}=qe({isCamera:!0,projection:`slim`}),{nodes:c}=J(),u=Or(),d=n(()=>br(c),[c]),f=n(()=>Ke(o),[o]),p=n(()=>yr(e,a??[],xr((s??[]).map(e=>({id:e.id,name:e.name})))),[e,a,s]),m=c.filter(t=>t.isOnline&&t.id!==e),h=()=>Br(r),g=Pe({onSuccess:h}),_=ze({onSuccess:h}),v=lt({onSuccess:h}),y=Sn({onSuccess:h}),b=e=>[...e.detection.active?m.map(n=>({id:`detect-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveDetectionTo`,`Move detection to {{name}}`,{name:n.name}),onClick:()=>g.mutate({deviceId:e.deviceId,agentNodeId:n.id})})):[],...e.audio.active?m.map(n=>({id:`audio-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveAudioTo`,`Move audio to {{name}}`,{name:n.name}),onClick:()=>v.mutate({deviceId:e.deviceId,nodeId:n.id})})):[],{id:`unpin-detect`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinDetection`,`Unpin detection`),hidden:!(e.detection.active&&e.detection.pinned),separatorBefore:!0,onClick:()=>_.mutate({deviceId:e.deviceId})},{id:`unpin-audio`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinAudio`,`Unpin audio`),hidden:!(e.audio.active&&e.audio.pinned),onClick:()=>y.mutate({deviceId:e.deviceId})}];return i(Le,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>i(wn,{to:`/devices/${String(e.deviceId)}`,className:`block w-44 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName})},{key:`roles`,header:t(`pipeline.nodeCameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:t=>i(wr,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:d,colorByNodeId:f,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>u.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(Tr,{snap:u.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>i(vn,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:Gt,emptyMessage:a===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Ur({nodeId:t,refreshToken:n}){let{t:r}=X(),{nodes:a}=J(),o=a.find(e=>e.id===t)?.name??t;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(pr,{refreshToken:n,nodeId:t}),e(`div`,{className:`space-y-2`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`pipeline.nodeCamerasTab.camerasOn`,{node:o})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`pipeline.nodeCamerasTab.theRolesEachCameraRuns`,`The roles each camera runs here right now. Move a role or unpin it from the row menu; pins for every camera are on Cluster → Assignments.`)})]}),i(Hr,{nodeId:t})]})]})}s();function Wr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return Y.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Gr({nodeId:t,refreshToken:r}){let{t:a}=X(),o=l(),s=U(),c=$e({onSettled:()=>{o.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:u}=bt({nodeId:t}),d=on(`pipeline.engine-metrics-snapshot`,e=>e.nodeId===t)?.engines??u??null,f=d===null;an([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=Ye({nodeId:t}),{values:m}=Ht(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,e=>e.nodeId===t),h=n(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),g=e=>{let n=p??[];if(n.length===0){c.mutate({nodeId:t,engine:e,force:!1});return}(async()=>{await s({title:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(n.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&c.mutate({nodeId:t,engine:e,force:!0})})()};return e(`div`,{className:`space-y-6`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:a(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`pipeline.nodeEnginesTab.summary`,{engines:(d??[]).length,cameras:(p??[]).length,active:h})})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[640px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.kind`,`Kind`)}),i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.nodeEnginesTab.models`,`Models`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.inUse`,`In use`)}),i(`th`,{className:`w-20`})]})}),e(`tbody`,{children:[f&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`common.loading`,`Loading…`)})}),!f&&(d??[]).map(t=>{let n=t.kind===`device-pool`;return e(`tr`,{className:`border-t border-border ${n?`bg-primary/[0.05]`:``}`,children:[i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[i(n?Me:F,{className:`h-3 w-3`}),a(n?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[i(P,{className:`h-3 w-3`}),t.engine.runtime,`/`,t.engine.backend,t.engine.device?`/${t.engine.device}`:``,t.engine.format?` · ${t.engine.format}`:``]})}),i(`td`,{className:`px-3 py-2`,children:t.modelsLoaded.length===0?i(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.modelsLoaded.map(e=>i(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),i(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:t.poolPid??`—`}),i(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:t.idleMs!==null&&t.idleTtlMs!==null?i(`span`,{className:`text-foreground-subtle`,children:Wr(t.idleMs,t.idleTtlMs)}):i(`span`,{className:`text-foreground-subtle/50`,children:a(`common.never`)})}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),i(`td`,{className:`px-3 py-2 text-right`,children:n?i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.auto`)}):e(q,{variant:`ghost`,size:`sm`,disabled:c.isPending,onClick:()=>g(t.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[i(y,{className:`h-3.5 w-3.5`}),a(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},t.engineKey)}),!f&&(d??[]).length===0&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),i(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:i(Tn,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:i(`strong`,{className:`text-foreground`})}})}),c.isError&&i(it,{message:a(`pipeline.nodeEnginesTab.killFailed`,{message:c.error instanceof Error?c.error.message:a(`common.unknownError`)})})]})}var Kr=`pipeline-runner`,qr=200;function Jr({nodeId:t}){let{t:n}=X();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeLogsTab.description`,{node:t})})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(kt,{agentId:t,addonId:Kr,limit:qr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}s();function Yr({nodeId:t,title:r}){let a=N(),{t:o}=X(),{data:s}=Cn(),{data:c}=Yt(void 0),l=n(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),u=n(()=>{if(!t)return null;let e=new Set;for(let n of c??[])n.agentNodeId===t&&e.add(n.deviceId);return e},[t,c]),d=Or(t),f=n(()=>{let e=[];for(let t of d.values())u&&!u.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[d,u]);return f.length===0?e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[i(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:f.length})]}),i(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(t=>{let n=l.get(t.deviceId)??`#${t.deviceId}`,r=Lt(t.metrics.phase,a);return e(`div`,{title:o(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:n,label:r.label,value3:t.metrics.actualFps.toFixed(1),value4:t.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:t.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[i(Vt,{phase:t.metrics.phase,className:`h-2.5 w-2.5`}),i(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:n}),i(`span`,{className:`font-mono tabular-nums`,children:t.metrics.actualFps.toFixed(1)}),i(`span`,{className:`opacity-60`,children:o(`common.fpsWord`)})]},t.deviceId)})})]})}function Xr(e,t,n,r){let i=t===void 0?void 0:e.find(e=>e.key===t)?.steps?.[n]?.settings,a={...r?.[n],...i};return Object.keys(a).length>0?a:void 0}function Zr(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}var Qr=`pipeline-analytics`,$r=`face-gallery`,ei=`pipeline-orchestrator`,ti=`pipeline-runner`,ni=`audio-analyzer`;function ri(e){return[...ue.filter(t=>t.stepId===e).map(e=>pe(e.stepId)),...de.filter(t=>t.stepId===e).map(e=>oe(e.stepId,e.key))]}var ii=`faces`,ai=`semantic-search`,oi=`load-balancer`,si=`load`,ci=[{id:ii,get title(){return Y.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:ei,fieldKeys:ri(`face-embedding`)},{addonId:Qr,capability:$r}]},{id:ai,get title(){return Y.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:ei,fieldKeys:ri(`clip-embedding`)}]},{id:xe,get title(){return Y.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:ei,sectionIds:[xe]}]},{id:ve,get title(){return Y.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:ei,sectionIds:[ve]}]},{id:`runner-defaults`,get title(){return Y.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:ti,fieldScope:`cluster`},{addonId:ni,fieldScope:`cluster`}]},{id:oi,get title(){return Y.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:ei,sectionIds:[si]}]},{id:`failover`,get title(){return Y.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:ei,sectionIds:[`failover`]}]}],li={"cluster-step-models":ii};function ui(e){return e===`clip-embedding`?ai:ii}var di=`ctab`,fi=`section`;function pi(e,t){let n=new URLSearchParams({view:`nodes`,node:Yo,[di]:e});return t!==void 0&&n.set(fi,t),`/system/pipeline?${n.toString()}`}function mi(e){return pi(`settings`,ui(e))}function hi(){return pi(`load-balancing`)}var gi=`pipeline-orchestrator`;function _i(e){return ue.find(t=>t.stepId===e)??null}function vi({step:t,engineFormat:n,runnableModelIds:r}){let{t:a}=X(),{data:o}=Kt({addonId:gi}),s=me(o??null)[t.stepId]??t.defaultModelId,c=t.options.find(e=>e.id===s)?.label??s,l=r.length>0&&!r.includes(s);return e(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:c}),i(`span`,{title:a(`pipeline.clusterStepModel.oneValueForTheWhole`,`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`),className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:a(`pipeline.clusterStepModel.clusterWide`)}),i(wn,{to:mi(t.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:a(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),e(`p`,{className:W,children:[a(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,a(`pipeline.clusterStepModel.indexNote`,{index:t.indexName})]}),l&&i(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:i(Tn,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:n,model:s,index:t.indexName},components:{b:i(`b`,{})}})})]})}var yi=`pipeline-orchestrator`;function bi({addonId:t,highlightLabel:n}){let{t:r}=X(),a=Se(t),{data:o}=Kt({addonId:yi});if(a.length===0)return null;let s=le(o??null)[t]??{};return e(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`h3`,{className:T,children:r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),i(wn,{to:mi(t),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),a.map(t=>e(`div`,{className:`${f} rounded px-2 ${n===t.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[i(`span`,{className:I,children:t.label}),i(`span`,{className:b,children:i(`span`,{className:`font-mono text-xs text-foreground`,children:String(s[t.key]??t.default)})})]},t.key)),i(`p`,{className:W,children:r(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function xi({rows:t,hint:n}){let{t:r}=X();return e(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(t=>e(`li`,{className:`${w} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[i(`span`,{className:t.href===void 0?`min-w-0 flex-1 truncate text-foreground-muted`:`basis-full text-foreground-muted`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:t.modelId??`—`}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:t.sourceLabel}),t.href!==void 0&&i(wn,{to:t.href,className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.effectiveModelSummary.changeOnAccelerator`)})]},t.id))}),i(`p`,{className:W,children:n??r(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}s();function Si(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:jt(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Ci({tree:a,searchRows:s,accelerators:c,cellState:l,stepBadge:u,disabledCount:d,showDisabled:f,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=X(),x=U(),S=Je(),{selection:C,open:w,close:T}=Ln(n(()=>On(a).map(e=>e.node.addonId),[a]),n(()=>c.map(e=>e.id),[c])),[E,D]=o(``),[O,k]=o(null),[A,j]=o(null),N=t(null),P=t(null),F=t(null);_t(F);let I=t(null),L=n(()=>en(s,E),[s,E]),R=n(()=>E.trim()===``?a:Bn(a,new Set(L.map(e=>e.addonId))),[a,L,E]),ee=e=>L.find(t=>t.addonId===e)?.matchedField??null,z=n(()=>c.map(Si),[c]),B=e=>c.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),V=c.find(e=>e.id===C.acceleratorId)??null,H=C.stepId!==null,te=r(async e=>{if(m){if(!await x({title:b(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:b(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:b(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[x,m,h,b]),ne=()=>{requestAnimationFrame(()=>I.current?.focus())},re=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&ne();return}let r=()=>{k(ee(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&ne()};e===C.stepId?r():te(r)},ie=()=>{let e=C.stepId;te(()=>{if(T(),e!==null){let t=V===null?null:Re({agentNodeId:V.nodeId,deviceKey:V.deviceKey});requestAnimationFrame(()=>N.current?.focusCell(e,t))}})},ae=e=>{if(e.key===`Enter`){let t=L[0];if(t===void 0)return;e.preventDefault(),re(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},oe=S?i(Tt,{onClick:ie}):i(Xe,{icon:M,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:ie});return e(`div`,{ref:P,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),F.current?.focus()),e.key===`Escape`&&t&&H&&(e.preventDefault(),ie())},children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),i(`input`,{ref:F,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown:ae,placeholder:b(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":b(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),d>0&&e(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(St,{checked:f,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:d})]}),_]}),C.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:b(`stepInspector.stepMatrixFrame.staleStep`,{id:C.staleStepId})}),R.length===0?i(`p`,{className:`${W} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:E})}):i(qt,{ref:N,tree:R,agents:z,label:v,getCellState:(e,t)=>{let n=B(t);return n===void 0?{kind:`na`}:l(e,n)},onCellClick:(e,t,n)=>re(e,B(t),n),onStepClick:(e,t)=>re(e,void 0,t),...u===void 0?{}:{stepBadge:u},selectedCell:H&&C.stepId!==null&&V!==null?{addonId:C.stepId,agentNodeId:V.nodeId,deviceKey:V.deviceKey}:null,fallbackNodeId:A,onFallbackNodeChange:j,reserveRightPx:H&&!S?432:0}),i(un,{open:H,anchor:P,onClose:ie,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:V,matchedField:O,closeButton:oe,onEscape:ie,headingRef:e=>{I.current=e}})})]})}s();function wi(e){a(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}s();function Ti(e,t,n){return e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=t.accelerator?.deviceKey===e.key?{...Object.fromEntries(Object.entries(i.settings??{}).filter(([e])=>!n(e))),...t.accelerator.settings}:i.settings,c=s!==void 0&&Object.keys(s).length>0?s:void 0,l=a===void 0?i.modelId:a??void 0,u=o===void 0?i.jumpDeviceKey:o||void 0,d={...l===void 0?{}:{modelId:l},...c===void 0?{}:{settings:c},...u===void 0?{}:{jumpDeviceKey:u}};return Object.keys(d).length>0?r[t.stepId]=d:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}})}function Ei(e,t){return t===void 0?0:[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!_e(e[n],t[n])).length}function Di(e,t,n,r){if(t===null)return 0;let i=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,a=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,o=Ei(n,t.nodeSettings),s=t.accelerator===void 0?0:Ei(r(t.accelerator.deviceKey),t.accelerator.settings);return i+a+o+s}function Oi({nodeId:t,nodeName:r,toolbar:a}){let{t:s}=X(),c=l(),u=Pt({nodeId:t},{refetchOnMount:`always`}),f=rn({nodeId:t},{refetchOnMount:`always`}),p=Qt({agentNodeId:t},{refetchOnMount:`always`}),m=p.data?.stepSettings,h=me(Kt({addonId:`pipeline-orchestrator`}).data??null),g=u.data?.devices??[],_=f.data??null,[v,y]=o(null),[b,x]=o(null),[S,C]=o(null),w=mt({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),E=Ge({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})}}),[D,O]=o(!1),k=n(()=>_?pn(_):[],[_]),A=n(()=>On(k),[k]),[j,M]=o(!1),N=n(()=>Vn(t,r,g,j),[t,r,g,j]),P=n(()=>Vn(t,r,g),[t,r,g]),F=P.length>=2,I=(e,t)=>Xr(g,t?.deviceKey,e,m)??{},L=e=>m?.[e]??{},R=(e,t)=>g.find(e=>e.key===t)?.steps?.[e]?.settings??{},ee=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return P.find(e=>e.deviceKey===r);if(!In(e,t))return P.filter(n=>n.id!==t.id&&In(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},z=(e,t)=>{let n=Fn(_,e),r=_i(e),i=An(_,t),a=I(e,t),o=ee(n,t);return Rn({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?Mn(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...zn(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:h[e]??r.defaultModelId}:{},...o?{jumpTo:Ft(o.device)}:{}})},B=A.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:jn(Fn(_,e.addonId))}));if(u.isLoading||f.isLoading||p.isLoading)return i(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(_===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let V=e(`span`,{className:W,children:[s(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,i(`span`,{className:`text-foreground`,children:P.length>0?P.map(e=>Ft(e.device)).join(` · `):s(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),g.some(e=>!e.enabled)&&e(d,{children:[` `,s(`stepInspector.nodeStepInspector.off`,`— off:`),` `,g.filter(e=>!e.enabled).map(Ft).join(`, `)]}),` `,`·`,` `,i(wn,{to:hi(),className:`text-primary hover:underline`,children:s(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return i(Ci,{tree:k,searchRows:B,accelerators:N,cellState:z,disabledCount:g.filter(e=>!e.enabled).length,showDisabled:j,onShowDisabledChange:M,dirty:v!==null&&Di(g,v,L(v.stepId),e=>R(v.stepId,e))>0,onDiscard:()=>y(null),summary:V,...a===void 0?{}:{toolbar:a},label:s(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:a,matchedField:o,closeButton:c,onEscape:l,headingRef:u})=>{let f=Fn(_,n);if(f===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=v?.stepId===n?v:null,m=a??P[0]??N[0],h=p?.nodeSettings??L(n),k=a===null?{}:p?.accelerator?.deviceKey===a.deviceKey?p.accelerator.settings:R(n,a.deviceKey),A={...h,...k},j=Di(g,p,L(n),e=>R(n,e)),M=e=>{C(null),y(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},z=_i(n),B=fn(f),{nodeFields:V,acceleratorFields:H}=Hn(B),U=new Set(H.flatMap(e=>`key`in e?[e.key,`${e.key}ModelId`]:[])),te=m===void 0?void 0:An(_,m),ne=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},re=m===void 0?void 0:Mn(f,m,{nodePin:ne(m)}).modelId,ie=t=>{let r=ne(t),o=Mn(f,t,{nodePin:r}),c=An(_,t),l=zn(n,a?.id===t.id?A:I(n,t),c),u=p?.jumps[t.deviceKey],m=ee(f,t,u),h=In(f,t)?l&&c?i(Fe,{rootModel:c,stepModelId:o.modelId}):void 0:e(d,{children:[s(`stepInspector.nodeStepInspector.noBuild`,{format:t.device.format}),` `,m?s(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:m.shortLabel}):s(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=F?e(`label`,{className:`block space-y-1`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:s(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),i(Ie,{"aria-label":s(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:u??t.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:s(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...P.filter(e=>e.id!==t.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:e=>M({jumps:{...p?.jumps,[t.deviceKey]:e.target.value}})}),i(`span`,{className:W,children:s(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:t.label,format:t.device.format,modelId:o.modelId,source:o.source===`node`?`node`:`default`,sourceLabel:o.source===`node`?`node pin`:`hardware default`,models:Jt(f.models??[],t.device.format),defaultModelId:f.defaultModelIdByFormat?.[t.device.format]??f.defaultModelId,expanded:b===t.id,onToggle:()=>x(e=>e===t.id?null:t.id),onChangeModel:e=>M({models:{...p?.models,[t.deviceKey]:e}}),...r===void 0?{}:{onReset:()=>M({models:{...p?.models,[t.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...h===void 0?{}:{note:h},...g===void 0?{}:{extra:g},changed:p?.models[t.deviceKey]!==void 0||u!==void 0}},ae=async()=>{if(p!==null){O(!0);try{(Object.keys(p.models).length>0||Object.keys(p.jumps).length>0||p.accelerator!==void 0)&&await w.mutateAsync({agentNodeId:t,inferenceDevices:Zr(Ti(g,p,e=>U.has(e)))}),p.nodeSettings!==void 0&&Ei(L(n),p.nodeSettings)>0&&await E.mutateAsync({agentNodeId:t,addonId:n,settings:Object.keys(p.nodeSettings).length>0?{...p.nodeSettings}:null}),y(null),C({kind:`saved`})}catch(e){C({kind:`error`,error:e instanceof Error?e.message:String(e)})}finally{O(!1)}}};return i(Wt,{ref:u,title:a===null?`${f.name} · ${r}`:`${f.name} · ${a.label}`,subtitle:a===null?s(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:f.slot,nodeName:r}):s(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:f.slot,format:a.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:j,saving:D,status:S?.kind??null,...S?.error===void 0?{}:{error:S.error},onSave:()=>void ae(),onDiscard:()=>y(null)},children:e(`div`,{className:`space-y-3`,children:[e(`section`,{className:`space-y-2`,"aria-label":s(`stepInspector.nodeStepInspector.model`,`Model`),children:[i(`h3`,{className:T,children:s(`stepInspector.nodeStepInspector.model`,`Model`)}),z!==null&&m!==void 0?i(vi,{step:z,engineFormat:m.device.format,runnableModelIds:Jt(f.models??[],m.device.format).map(e=>e.id)}):N.length===0?i(`p`,{className:W,children:i(Tn,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:i(wn,{to:hi(),className:`text-primary hover:underline`})}})}):a===null?i(xi,{rows:N.map(e=>{let t=Mn(f,e,{nodePin:ne(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):i(ln,{...ie(a)},a.id)]}),(B.length>0||te!==void 0)&&z===null&&e(`section`,{"aria-label":s(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:s(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:r})}),(V.length>0||te!==void 0)&&i(ki,{addon:f,fields:V,settings:h,layerLabel:s(`stepInspector.nodeStepInspector.nodeLayer`,`Node`),modelId:Nt(f,re,A,te),root:te,highlight:o,onChange:e=>M({nodeSettings:e})}),H.length>0&&(a===null?i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-hint`,children:s(`stepInspector.nodeStepInspector.thresholdsPerAccelerator`,`Confidence thresholds belong to the model, so they are set per accelerator: open that accelerator's cell.`)}):e(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-scope`,children:s(`stepInspector.nodeStepInspector.acceleratorSettings`,{accelerator:a.label})}),i(ki,{addon:f,fields:H,settings:k,layerLabel:s(`stepInspector.nodeStepInspector.acceleratorLayer`,`This accelerator`),modelId:Nt(f,re,A,te),root:void 0,highlight:o,onChange:e=>M({accelerator:{deviceKey:a.deviceKey,settings:e}})})]}))]}),i(bi,{addonId:n,highlightLabel:o})]})})}})}function ki({addon:e,fields:t,settings:n,layerLabel:r,modelId:a,root:o,highlight:s,onChange:c}){let l=t.find(e=>`label`in e&&e.label===s)?.key??null;return wi(l===null?null:cn(l)),i($t,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:r},modelId:a,...o===void 0?{}:{rootModel:o},highlightKey:l,onChangeLayer:c})}s();function Ai({nodeId:t,refreshToken:n}){let{t:r}=X(),a=U(),[s,c]=o(null),{nodes:l}=J(),u=l.find(e=>e.id===t)?.name??t,f=dt({onSuccess:e=>{c(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await a({title:r(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:r(`pipeline.nodePipelineTab.thisClearsEveryPerDevice`,`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:r(`common.reset`,`Reset`),variant:`danger`})&&(c(null),f.mutate({agentNodeId:t}))};return e(`div`,{className:`space-y-2`,children:[i(Yr,{nodeId:t}),i(Oi,{nodeId:t,nodeName:u,toolbar:e(d,{children:[s&&i(`span`,{className:`text-[11px] text-success`,children:s}),f.isError&&i(`span`,{className:`text-[11px] text-danger`,children:f.error instanceof Error?f.error.message:r(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),i(q,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:f.isPending,title:r(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:f.isPending?r(`pipeline.nodePipelineTab.resetting`,`Resetting…`):r(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var ji=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],Mi=`decoder-nodeav`,Ni=`ntab`,Pi={decoder:`engine`},Fi={engine:`Engine & decoder`},Ii=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function Li({nodeId:t,refreshToken:n}){let{t:r}=X(),[a,o]=En(),{nodes:s}=J(),c=s.find(e=>e.id===t)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??Mi,l=[...ji,c],u=a.get(Ni),d={assignments:{id:`assignments`,label:r(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:i(Ur,{nodeId:t,refreshToken:n})},tree:{id:`tree`,label:r(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:i(Ai,{nodeId:t,refreshToken:n})},engines:{id:`engines`,label:r(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:i(Gr,{nodeId:t,refreshToken:n})},logs:{id:`logs`,label:r(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:i(Jr,{nodeId:t})}},f=fr.map(e=>d[e]);return e(`div`,{className:`flex flex-col h-full`,children:[i(dr,{nodeId:t,refreshToken:n}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:i(Gn,{nodeId:t,addonIds:l,level:`global`,fieldScope:`perNode`,emptyMessage:Ii,tabAliases:Pi,tabLabelOverrides:Fi,extraTabs:f,activeTab:u===null?null:Pi[u]??u,onActiveTabChange:e=>o(t=>{let n=new URLSearchParams(t);n.set(Ni,e);for(let e of kn)n.delete(e);return n},{replace:!0})})})]})}function Ri(){let{t}=X();return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAssignmentsTab.pinACameraToA`,`Pin a camera to a node, or to one accelerator of its node; Auto lets each session pick. Decode always runs with detection. Load, shares and caps are on Load balancing.`)})]}),i(Vr,{})]})}function zi(e){return`${Math.round(e*100)}%`}function Bi(e){return Y.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var Vi={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},Hi={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,unknown:`Not measured`};function Ui(e){return e===null?`—`:Vi[e]??e}function Wi(e){return e===null?`—`:Hi[e]??e}function Gi(e){switch(e.kind){case`capacity`:return Y.t(`helpers.autoTuneViewModel.capacity`,{sessions:Bi(e.sessions),min:e.minSessions});case`tie-faster`:return Y.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:zi(e.recallDelta)});case`stepped-down`:return Y.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return Y.t(`helpers.autoTuneViewModel.noFitLightest`,{min:Bi(e.minSessions),sessions:Bi(e.sessions)});case`derived-latency`:return Y.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return Y.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return Y.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return Y.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return Y.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return Y.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return Y.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return Y.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return Y.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function Ki(e,t){switch(e.kind){case`custom-pin-kept`:return Y.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey});case`custom-registry-unreadable`:return Y.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function qi(e){return{modelChanges:e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),thresholdClears:e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0)}}function Ji(e){let t=qi(e);return t.modelChanges+t.thresholdClears===0}function Yi(e,t,n){let r=e.nodeChanges.find(e=>e.nodeId===t&&e.deviceKey===n)?.modelPins.find(e=>e.stepId===`object-detection`);return r===void 0?null:{before:r.before,after:r.after}}function Xi(e,t){return e?.kind===`node-benchmark`?Y.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):e?.kind===`estimated`?Y.t(`helpers.autoTuneViewModel.latencyEstimated`,{hardware:Wi(e.estimatedFrom)}):Y.t(`helpers.autoTuneViewModel.latencyTable`)}s();var Zi=[.3,.4,.5];function Qi(e){return Zi.some(t=>t===e)}var $i=[1,2,3,4,6,8];function ea({plan:t,node:n,nodeName:r}){let{t:a}=X();return e(`section`,{className:x,"data-testid":`auto-tune-node-${n.nodeId}`,children:[e(`header`,{className:`${L} flex flex-wrap items-center gap-2`,children:[i(F,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${T} min-w-0 flex-1`,children:r(n.nodeId)}),e(`span`,{className:`text-[11px] text-foreground-subtle`,children:[Wi(n.hardwareClass),n.cpuModel===null?``:` · ${n.cpuModel}`]}),n.skipped?i(K,{variant:`warning`,children:a(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):n.acceleratorModelId!==null&&i(K,{variant:`info`,children:n.acceleratorModelId})]}),n.reasons.length>0&&i(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>i(`li`,{children:Gi(e)},t))}),i(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs`,children:[i(`thead`,{children:e(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.device`,`Device`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),i(`tbody`,{children:n.devices.map(r=>{let o=Yi(t,n.nodeId,r.deviceKey);return e(`tr`,{className:`border-t border-border align-top`,children:[e(`td`,{className:`px-3 py-1.5`,children:[i(`div`,{className:`font-mono text-foreground`,children:r.deviceKey}),i(`div`,{className:`text-[11px] text-foreground-subtle`,children:Ui(r.accelerator)})]}),e(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[r.chosen===null?`—`:a(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:r.chosen.capacitySessions,fps:t.cameraFps}),r.chosen!==null&&e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[a(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:r.chosen.fps,percent:Math.round(t.headroom*100)}),i(`div`,{children:Xi(r.chosen.source)})]})]}),i(`td`,{className:`px-3 py-1.5`,children:r.chosen===null?i(`span`,{className:`text-foreground-subtle`,children:a(`common.unchanged`)}):o!==null&&o.before!==o.after?e(`span`,{children:[i(`span`,{className:`text-foreground-subtle`,children:o.before??a(`common.defaultWord`)}),` → `,i(`span`,{className:`font-medium text-foreground`,children:o.after})]}):i(`span`,{className:`text-foreground`,children:r.chosen.modelId})}),i(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:r.reasons.map((e,t)=>i(`div`,{children:Gi(e)},t))})]},r.deviceKey)})})]})})]})}function ta({plan:t,nodeName:n}){let{t:r}=X();return i(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:e(`div`,{children:[i(`div`,{className:T,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),t.nodeChanges.length===0?i(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:t.nodeChanges.flatMap(t=>[...t.modelPins.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`— `,i.stepId,`: `,i.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,i.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/pin`)),...t.thresholds.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:i.stepId,keys:i.keys.join(`, `)})]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/thr`))])})]})})}function na({result:t}){let{t:n}=X();return t.kind===`refused`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):t.kind===`stale`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):e(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[t.kind===`aborted`&&i(`li`,{className:`text-danger`,children:n(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),t.phases.map(t=>e(`li`,{className:t.ok?`text-foreground-muted`:`text-danger`,children:[t.ok?`✓`:`✗`,` `,t.phase,`: `,t.detail]},t.phase))]})}function ra(){let{t}=X(),r=l(),[a,s]=o(.4),[c,u]=o(2),[d,f]=o(!1),[p,m]=o(!1),[h,g]=o(null),{nodes:_}=J(),v=n(()=>br(_),[_]),y=bn({headroom:a,minSessionsPerDevice:c},{enabled:d,refetchOnWindowFocus:!1}),b=vt({onSuccess:e=>{g(e),m(!1),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),e.kind===`applied`&&y.refetch()}}),S=h?.kind===`stale`?h.plan:y.data,C=S===void 0?null:qi(S);return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[e(`section`,{className:x,children:[e(`header`,{className:`${L} flex flex-wrap items-center gap-2`,children:[i(V,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${T} min-w-0 flex-1`,children:t(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),e(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[i(`p`,{children:t(`pipeline.clusterAutoTuneTab.picksForEveryAcceleratorThe`,`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models on the accelerators and clears their threshold overrides, so each model runs its own default thresholds. Cameras carry no model or threshold of their own. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),i(Ie,{"aria-label":t(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(a),options:Zi.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(e*100)})})),onChange:e=>{let t=Number(e.target.value);Qi(t)&&s(t)}})]}),e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),i(Ie,{"aria-label":t(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(c),options:$i.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:e})})),onChange:e=>{let t=Number(e.target.value);$i.some(e=>e===t)&&u(t)}})]}),i(q,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),f(!0),d&&y.refetch()},children:y.isFetching?t(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):S===void 0?t(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):t(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),S!==void 0&&i(q,{size:`sm`,disabled:Ji(S),onClick:()=>m(!0),children:t(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),y.error!==null&&i(`div`,{className:`text-danger`,children:y.error.message}),h!==null&&i(na,{result:h}),C!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:C.modelChanges,thresholdClears:C.thresholdClears})})]})]}),S?.warnings.map((e,t)=>i(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:Ki(e,v)},t)),S?.nodes.map(e=>i(ea,{plan:S,node:e,nodeName:v},e.nodeId)),S!==void 0&&i(xn,{open:p,onOpenChange:m,children:e(yn,{width:`lg`,scroll:`body`,children:[e(_n,{children:[i(ht,{children:t(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),i(ft,{children:t(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),i(Dt,{children:i(ta,{plan:S,nodeName:v})}),e(He,{children:[i(q,{variant:`ghost`,onClick:()=>m(!1),children:t(`common.cancel`,`Cancel`)}),i(q,{variant:`danger`,disabled:b.isPending,onClick:()=>b.mutate({planHash:S.planHash,headroom:a,minSessionsPerDevice:c}),children:b.isPending?t(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):t(`common.apply`,`Apply`)})]})]})})]})}var ia={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`};function aa(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function oa(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function sa(e,t,n){let r=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let i=t.get(e.key)??(n?0:null),a=e.weight>0?e.weight:1;return{key:e.key,label:jt(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?aa(a,r):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function ca(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.nodes.map(r=>{let i=t.get(r.id),a=sa(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),oa(i)),o=r.isOnline&&r.detectEnabled,s=r.weight>0?r.weight:1,c=i?.load.attachedCameras??null;return{nodeId:r.id,name:r.name,isOnline:r.isOnline,detectEnabled:r.detectEnabled,reported:i!==void 0,attachedCameras:c,activeCameras:i?.load.activeCameras??null,maxCameras:r.maxCameras,capacityPct:c!==null&&r.maxCameras!==null&&r.maxCameras>0?aa(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?aa(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}s();var la=2e4,ua=3e5;function da({stats:e,targetWeights:t,showAccelerators:r=!0}){let{t:a}=X(),{nodes:o}=J(),s=j().trpcClient,l=dn(void 0,{placeholderData:u,staleTime:la,refetchInterval:la,refetchOnWindowFocus:!0}),d=mn(void 0,{staleTime:ua}),f=n(()=>o.map(e=>e.id),[o]),p=c({queries:f.map(e=>({queryKey:Ne(tn.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>s.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:ua,refetchOnWindowFocus:!1,placeholderData:u}))}),h=n(()=>{let e={};return f.forEach((t,n)=>{let r=p[n]?.data;r&&(e[t]=r.devices)}),e},[f,p.map(e=>e.dataUpdatedAt).join(`|`)]),g=n(()=>{let e=new Map;for(let t of d.data??[])e.set(t.nodeId,t.settings);return e},[d.data]),_=n(()=>o.map(e=>{let n=g.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:cr(n).pipeline,weight:t?.[e.id]??Jn(n,`detectWeight`)??1,maxCameras:Jn(n,`maxCameras`)}}),[o,g,t]),v=l.data??[],y=n(()=>ca({nodes:_,loads:v,devicesByNode:h}),[_,v,h]),b=y.reduce((e,t)=>e+(t.attachedCameras??0),0),x=y.reduce((e,t)=>e+(t.activeCameras??0),0),S=l.dataUpdatedAt>0?Date.now()-l.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return i(G,{headingId:`load-balancing-node-load`,title:a(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:ee,actions:i(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:a(`pipeline.nodeLoadOverview.summaryLine`,{active:x,attached:b,reading:l.data===void 0?a(`pipeline.nodeLoadOverview.reading`,`reading…`):a(`pipeline.nodeLoadOverview.readingAge`,{age:S===null?`—`:`${Math.round(S/1e3)}s`})})}),children:i(`div`,{className:m,children:y.length===0?i(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):i(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:y.map(e=>i(fa,{row:e,placed:C.get(e.nodeId),showAccelerators:r},e.nodeId))})})})}function fa({row:t,placed:n,showAccelerators:r}){let{t:a}=X(),o=t.attachedCameras===null?`—`:`${t.activeCameras??0} / ${t.attachedCameras}${t.maxCameras===null?``:` of ${t.maxCameras}`}`;return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[i(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),i(`span`,{className:`truncate text-xs font-medium text-foreground`,title:t.nodeId,children:t.name}),!t.detectEnabled&&i(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!t.reported&&t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:a(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[i(ie,{className:`h-2.5 w-2.5`}),` `,a(`pipeline.nodeLoadOverview.noReading`)]}),!t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[i(C,{className:`h-2.5 w-2.5`}),` `,a(`common.offline`)]})]}),e(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[i(ha,{label:a(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:o,title:a(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),i(ha,{label:a(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:t.weightSharePct===null?`out of play`:`${t.weightSharePct}%`,title:a(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),i(ha,{label:a(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:n?.observedShare===null||n===void 0?`—`:`${Math.round(n.observedShare*100)}%`,title:a(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),i(ha,{label:a(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:n===void 0?`—`:`${n.peakSessions} · ${n.yieldsAway}`,title:a(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),i(ha,{label:a(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:t.score===null?`—`:`${t.score} · ${t.queueDepthTotal??0}`,title:a(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),t.capacityPct!==null&&i(ha,{label:a(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${t.capacityPct}%`,title:a(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),t.avgInferenceTimeMs!==null&&i(ha,{label:a(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(t.avgInferenceTimeMs)} ms`,title:a(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),t.decodeHwaccel!==null&&i(ha,{label:a(`pipeline.nodeLoadOverview.decode`,`Decode`),value:t.decodeHwaccel,title:a(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),r&&i(pa,{row:t})]})}function pa({row:t}){let{t:n}=X();return t.devices.length===0?i(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):e(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[e(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[i(_,{className:`h-2.5 w-2.5`}),n(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),t.eligibleDeviceCount===0&&i(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:n(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:n(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),i(`ul`,{className:`mt-1 space-y-0.5`,children:t.devices.map(e=>i(ma,{device:e},e.key))})]})}function ma({device:t}){let{t:n}=X(),r=t.exclusion;return e(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[i(F,{className:`h-2.5 w-2.5 shrink-0 ${r===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),i(`span`,{className:`shrink-0 font-medium ${r===null?`text-foreground`:`text-foreground-subtle`}`,title:`${t.key} · ${t.format}`,children:t.label}),r===null?e(d,{children:[i(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.sharePct`,{pct:t.weightSharePct})}),e(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:t.sessions===null?n(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,n(`common.sessionsCount`,{count:t.sessions??0}),t.maxSessions===null?``:`/${t.maxSessions}`]}),t.atCap&&i(`span`,{className:`shrink-0 text-amber-400`,title:n(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:n(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):i(`span`,{className:`truncate text-foreground-subtle/80`,title:n(ia[r]),children:n(`pipeline.nodeLoadOverview.excludedWith`,{reason:n(ia[r])})})]})}function ha({label:t,value:n,title:r}){return e(`div`,{className:`min-w-0`,title:r,children:[i(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:t}),i(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:n})]})}function ga(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function _a(e){let t={},n={};for(let r of e.nodes){if(r.share===null||r.share<=0)continue;t[r.nodeId]=r.share;let e=Object.fromEntries(r.devices.filter(e=>e.share>0).map(e=>[e.deviceKey,e.share]));Object.keys(e).length>0&&(n[r.nodeId]=e)}return{nodes:t,devices:n}}function va(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function ya(e){return e.reason===`disabled`?Y.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):Y.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function ba(e,t){if(t===void 0||t.source===`manual`||t.autoPending)return{nodes:e,readOnly:t!==void 0&&t.source!==`manual`};let n=new Map(t.nodes.map(e=>[e.nodeId,e.configuredPct]));return{nodes:e.map(e=>({...e,weight:Math.round(n.get(e.id)??e.weight)})),readOnly:!0}}function xa(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `),i=n.map(e=>t(e.nodeId)).join(`, `);return Y.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var Sa=[{value:`hardware`,get label(){return Y.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return Y.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return Y.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.manualHint`)}}];function Ca(e){return e===`no-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function wa(e,t){if(e.source!==`benchmark`)return null;let n=e.nodes.filter(e=>e.capacityFallback!==null);return n.length===0?null:n.map(e=>`${t(e.nodeId)}: ${Ca(e.capacityFallback)??``}`).join(` · `)}s();function Ta(e,t,n){return Math.min(Math.max(e,t),n)}function Ea(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function Da(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:Ta(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function Oa(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function ka({nodes:t,pending:n,onCommitWeights:r,weightLabel:s=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:f}=X(),[p,m]=o(()=>Ea(t)),[h,g]=o(new Set);a(()=>{m(Ea(t)),g(e=>new Set([...e].filter(e=>t.some(t=>t.id===e))))},[t.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let _=t.map(e=>e.id),v=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=(e,t)=>{m(n=>Da(n,e,t,h,_))},b=()=>{let e=Oa(p,_,h),n=t.filter(t=>(e[t.id]??0)!==t.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...h]);r(t.filter(e=>i.has(e.id)).map(t=>({nodeId:t.id,weight:e[t.id]??0})))};if(t.length===0)return i(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??f(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=t.length===1;return e(`div`,{className:`space-y-3`,children:[t.map(t=>{let r=p[t.id]??0,a=h.has(t.id);return e(`div`,{className:`flex items-center gap-3`,children:[i(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:t.name,children:t.name}),i(`input`,{"aria-label":f(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:s,name:t.name}),type:`range`,min:0,max:100,step:1,value:Math.round(r),disabled:u||n||a||x,onChange:e=>y(t.id,Number(e.target.value)),onPointerUp:()=>b(),onKeyUp:()=>b(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),e(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(r),`%`]}),!u&&i(`button`,{type:`button`,onClick:()=>v(t.id),disabled:n||x,"aria-pressed":a,title:a?f(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):f(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${a?`text-amber-400`:`text-foreground-subtle`}`,children:i(a?te:A,{className:`h-3.5 w-3.5`})})]},t.id)}),i(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??i(d,{children:f(`placementBoard.weightSliderStack.draggingOneSliderSplitsThe`,`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`)})})]})}function Aa(e){let t=e.steps?.[`object-detection`]?.modelId;return typeof t==`string`&&t.length>0?t:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null}function ja(e){if(e.presence===`absent`)return`absent`;if(e.presence===`unknown`)return`unknown`;switch(e.exclusion){case null:return`active`;case`disabled`:return`disabled`;case`unavailable`:return e.available?`backoff`:`unavailable`;case`cannot-host-camera-root`:return`root-incapable`;case`accelerator-preferred`:return`standby`}}function Ma(e,t,n){let r=new Map((t?.devices??[]).map(e=>[e.deviceKey,e])),i=new Map((n?.devices??[]).map(e=>[e.deviceKey,e.sessionsNow]));return e.map(e=>{let t=r.get(e.key),a=n===void 0?null:i.get(e.key)??0;return{device:e,state:ja(e),share:t===void 0?null:{configuredPct:t.configuredPct,effectivePct:t.effectivePct},sessionsNow:a,atCap:a!==null&&e.maxSessions!==null&&a>=e.maxSessions}})}var Na={active:`success`,disabled:`neutral`,absent:`danger`,unknown:`neutral`,unavailable:`warning`,backoff:`warning`,"root-incapable":`info`,standby:`neutral`};s();function Pa(e){let t=jt(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:F,hue:`slate`}:r===`npu`?{label:t,Icon:P,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:Ee,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Ae,hue:`emerald`}:{label:t,Icon:F,hue:`slate`}}var Fa={active:[`placementBoard.nodeInferenceDevices.state.active`,`in use`],disabled:[`placementBoard.nodeInferenceDevices.state.disabled`,`switched off`],absent:[`placementBoard.nodeInferenceDevices.state.absent`,`absent`],unknown:[`placementBoard.nodeInferenceDevices.state.unknown`,`unknown`],unavailable:[`placementBoard.nodeInferenceDevices.state.unavailable`,`unavailable`],backoff:[`placementBoard.nodeInferenceDevices.state.backoff`,`pool down`],"root-incapable":[`placementBoard.nodeInferenceDevices.state.rootIncapable`,`no root model`],standby:[`placementBoard.nodeInferenceDevices.state.standby`,`fallback`]},Ia={active:[`placementBoard.nodeInferenceDevices.stateHint.active`,`A camera-root candidate: placement may start sessions on it.`],disabled:[`placementBoard.nodeInferenceDevices.stateHint.disabled`,`Switched off: it takes no sessions.`],absent:[`placementBoard.nodeInferenceDevices.stateHint.absent`,`The node no longer reports this device (unplugged, or moved to another node). Its settings are kept; it is never used. Forget it to delete them.`],unknown:[`placementBoard.nodeInferenceDevices.stateHint.unknown`,`The node's probe did not answer, so whether the device is there is not known.`],unavailable:[`placementBoard.nodeInferenceDevices.stateHint.unavailable`,`On the node, but the probe reports it unusable.`],backoff:[`placementBoard.nodeInferenceDevices.stateHint.backoff`,`Reported by the node, but its inference pool is down or backing off.`],"root-incapable":[`placementBoard.nodeInferenceDevices.stateHint.rootIncapable`,`Its format cannot run the camera root detector; it serves enrichment steps only.`],standby:[`placementBoard.nodeInferenceDevices.stateHint.standby`,`The CPU fallback: it takes no sessions while an accelerator is serving this node.`]};function La({nodeId:t,nodeName:r,isOnline:s,suggestedMaxSessions:c,shareSource:u,sharesAutomatic:f,share:p,placed:m}){let{t:_}=X(),v=l(),{data:b,isLoading:x}=Pt({nodeId:t},{refetchInterval:15e3}),S=()=>{v.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},w=mt({onSettled:S}),T=Mt({onSettled:S}),E=tn.platformProbe.rescanAccelerators.useMutation({onSettled:S}),D=b?.devices??[],O=b?.reachable??s,[k,A]=o({});a(()=>{A(Object.fromEntries(D.map(e=>[e.key,Ra(e)])))},[D.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let j=n(()=>D.filter(e=>(k[e.key]?.enabled??e.enabled)&&e.available).length,[D,k]),[M,N]=o(null),P=M??!0,F=e=>{let n=D.map(t=>{let n=e[t.key]??Ra(t);return{key:t.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});w.mutate({agentNodeId:t,inferenceDevices:Zr(n)})},I=(e,t)=>{let n=k[e.key]??Ra(e),r={...k,[e.key]:{...n,...t}};A(r),F(r)},L=n(()=>Ma(D,p,m),[D,p,m]),R=n(()=>D.filter(e=>(k[e.key]?.enabled??e.enabled)&&e.available),[D,k]),ee=n(()=>R.map(e=>({id:e.key,name:Pa(e).label,weight:k[e.key]?.weight??e.weight})),[R,k]),z=e=>{let t={...k};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}A(t),F(t)},B=w.isPending||T.isPending,V=za(_,f?u:`manual`),H=[{key:`device`,header:_(`placementBoard.nodeInferenceDevices.colDevice`,`Device`),nowrap:!1,sortValue:e=>Pa(e.device).label,render:e=>i(Va,{row:e,steps:k[e.device.key]?.steps})},{key:`state`,header:_(`placementBoard.nodeInferenceDevices.colState`,`State`),sortValue:e=>e.state,render:e=>i(`span`,{title:_(Ia[e.state][0],Ia[e.state][1]),children:i(K,{variant:Na[e.state],size:`sm`,children:_(Fa[e.state][0],Fa[e.state][1])})})},{key:`share`,header:_(`placementBoard.nodeInferenceDevices.colShare`,`Share`),align:`right`,sortValue:e=>e.share?.effectivePct??null,render:e=>i(Ha,{row:e,sourceLabel:V})},{key:`sessions`,header:_(`placementBoard.nodeInferenceDevices.colSessions`,`Sessions`),align:`right`,sortValue:e=>e.sessionsNow,render:t=>e(`span`,{className:`tabular-nums text-xs text-foreground`,children:[t.sessionsNow??`—`,t.atCap&&i(K,{variant:`warning`,size:`sm`,className:`ml-1`,children:_(`placementBoard.nodeInferenceDevices.atCap`,`at cap`)})]})},{key:`cap`,header:_(`placementBoard.nodeInferenceDevices.colCap`,`Max sessions`),notSortableReason:_(`placementBoard.nodeInferenceDevices.capNotSortable`,`An editable field: sort by Sessions instead.`),render:t=>{let n=k[t.device.key]??Ra(t.device);if(!(n.enabled&&t.device.available))return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let r=Pa(t.device).label;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(We,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10);I(t.device,{maxSessions:r!==null&&r>0?r:null})},disabled:B,"aria-label":_(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:r}),className:`w-16 text-right`}),i(Ua,{suggested:c?.[t.device.key]??null,current:n.maxSessions,pending:B,onApply:e=>I(t.device,{maxSessions:e})})]})}},{key:`enabled`,header:_(`placementBoard.nodeInferenceDevices.colEnabled`,`Enabled`),align:`right`,notSortableReason:_(`placementBoard.nodeInferenceDevices.enabledNotSortable`,`A switch: sort by State instead.`),render:e=>{let n=Pa(e.device).label;if(e.state===`absent`)return i(Ve,{label:_(`placementBoard.nodeInferenceDevices.forget`,`Forget`),icon:y,size:`sm`,triggerVariant:`ghost`,disabled:B,title:_(`placementBoard.nodeInferenceDevices.forgetTitle`,`Forget {{label}} on {{node}}?`,{label:n,node:r}),description:_(`placementBoard.nodeInferenceDevices.forgetDescription`,`Its stored settings (switch, weight, cap, step models) are deleted. If the device comes back it starts from the defaults.`),action:()=>T.mutateAsync({agentNodeId:t,deviceKey:e.device.key})});let a=k[e.device.key]??Ra(e.device);return i(yt,{checked:a.enabled&&e.device.available,onCheckedChange:()=>I(e.device,{enabled:!a.enabled}),disabled:!e.device.available||B,"aria-label":_(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:n})})}}],U=w.error??T.error??E.error;return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[e(q,{variant:`ghost`,size:`sm`,onClick:()=>N(!P),className:`min-w-0 flex-1 justify-start`,"aria-expanded":P,children:[i(h,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${P?`rotate-90`:``}`}),i(`span`,{className:`truncate text-sm font-medium text-foreground`,children:r}),i(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-foreground-subtle`,children:O?e(d,{children:[i(Me,{className:`h-3.5 w-3.5`}),_(`pipeline.nodeInferenceDevices.accelerators`,{count:j})]}):e(d,{children:[i(C,{className:`h-3.5 w-3.5`}),` `,_(`common.unreachable`)]})})]}),e(q,{variant:`ghost`,size:`sm`,onClick:()=>E.mutate({nodeId:t}),disabled:E.isPending||!O,title:_(`placementBoard.nodeInferenceDevices.rescanTitle`,`Probe this node for accelerators now (a Coral plugged in or pulled out). The node also re-probes every minute.`),children:[i(g,{className:`h-3.5 w-3.5 ${E.isPending?`animate-spin`:``}`}),_(`placementBoard.nodeInferenceDevices.rescan`,`Rescan`)]})]}),P&&e(`div`,{className:`space-y-3 border-t border-border p-3`,children:[O?x&&D.length===0?i(`p`,{className:`text-center text-xs text-foreground-subtle`,children:_(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):i(Le,{columns:H,rows:L,rowKey:e=>e.device.key,minWidthPx:640,bordered:!1,emptyMessage:_(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):i(Wa,{}),E.data!==void 0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:Ba(_,E.data.appeared,E.data.disappeared)}),O&&!f&&R.length>=2&&e(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[e(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[i(Oe,{className:`h-3.5 w-3.5`}),_(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),i(ka,{nodes:ee,pending:B,onCommitWeights:z,weightLabel:`Accelerator share`,footnote:_(`placementBoard.nodeInferenceDevices.dragToShiftTheShare`,`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`)})]}),U!=null&&e(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-xs text-danger`,children:[_(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,U.message]})]})]})}function Ra(e){return{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}}function za(e,t){switch(t){case`benchmark`:return e(`placementBoard.nodeInferenceDevices.sourceBenchmark`,`benchmark`);case`hardware`:return e(`placementBoard.nodeInferenceDevices.sourceHardware`,`hardware`);case`manual`:return e(`placementBoard.nodeInferenceDevices.sourceManual`,`manual`);case void 0:return null}}function Ba(e,t,n){return t.length===0&&n.length===0?e(`placementBoard.nodeInferenceDevices.rescanNoChange`,`Rescanned: no change.`):e(`placementBoard.nodeInferenceDevices.rescanChanged`,`Rescanned: appeared {{appeared}} · disappeared {{disappeared}}`,{appeared:t.length>0?t.join(`, `):`—`,disappeared:n.length>0?n.join(`, `):`—`})}function Va({row:t,steps:n}){let r=Pa(t.device),a=Aa({defaultModelId:t.device.defaultModelId,steps:n??t.device.steps??{}});return e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i(r.Icon,{className:`h-4 w-4 shrink-0 text-foreground-subtle`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:r.label}),i(K,{variant:`neutral`,size:`sm`,className:`font-mono`,children:t.device.format})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-xs text-foreground-subtle`,children:[i(`span`,{className:`font-mono`,children:t.device.key}),a!==null&&e(d,{children:[i(`span`,{"aria-hidden":!0,children:`·`}),i(`span`,{children:i(Tn,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:a},components:{mono:i(`span`,{className:`font-mono text-foreground-muted`})}})})]})]})]})]})}function Ha({row:t,sourceLabel:n}){let{t:r}=X();if(t.share===null)return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let{configuredPct:a,effectivePct:o}=t.share,s=Math.round(a)!==Math.round(o);return e(`div`,{className:`text-right`,children:[e(`div`,{className:`tabular-nums text-sm text-foreground`,children:[Math.round(o),`%`]}),e(`div`,{className:`text-xs text-foreground-subtle`,children:[s?r(`placementBoard.nodeInferenceDevices.shareConfigured`,`set {{pct}}%`,{pct:Math.round(a)}):null,s&&n!==null?` · `:null,n]})]})}function Ua({suggested:e,current:t,pending:n,onApply:r}){let{t:a}=X();return e===null||e<1||e===t?null:i(q,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:a(`placementBoard.nodeInferenceDevices.advisoryCapFromTheMeasured`,`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`),children:a(`pipeline.nodeInferenceDevices.use`,{value:e})})}function Wa(){let{t}=X();return e(`div`,{className:`flex flex-col items-center gap-2 px-4 py-6 text-center`,children:[i(C,{className:`h-6 w-6 text-foreground-subtle`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:t(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),i(`p`,{className:`max-w-sm text-xs text-foreground-subtle`,children:t(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}s();var Ga=3600*1e3,Ka=2e4,qa=.4;function Ja({refreshToken:t,onOpenAutoTune:r}){let{t:a}=X(),s=l(),{nodes:c}=J(),f=mn(void 0),p=qe({isCamera:!0,projection:`slim`}),h=It({windowMs:Ga},{refetchInterval:Ka,placeholderData:u}).data,g=At(void 0,{refetchInterval:Ka,placeholderData:u}).data,_=()=>{Qn(s),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=ot({onSuccess:_}),y=nt({onSuccess:()=>{_(),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=Ue({onSuccess:_}),x=Et(),[S,C]=o(!1),T=g?.source,E=T===`benchmark`?`benchmark`:`hardware`,O=ut({headroom:qa,source:E},{enabled:S,staleTime:1/0}),k=O.data,A=n(()=>{let e=new Map((f.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>cr(e.get(t.id)).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:Jn(n,`detectWeight`)??1,maxCameras:Jn(n,`maxCameras`)}})},[c,f.data]),j=e=>c.find(t=>t.id===e)?.name??e,M=xr((p.data??[]).map(e=>({id:e.id,name:e.name}))),N=k?va(k):void 0,I=ba(A,g),L=T!==`manual`,R=g!==void 0&&g.source!==`manual`&&!g.autoPending,ee=e=>g?.nodes.find(t=>t.nodeId===e),z=e=>h?.nodes.find(t=>t.nodeId===e),B=g?xa(g,j):null,H=g?wa(g,j):null,U=Sa.find(e=>e.value===T)?.hint;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(pr,{refreshToken:t}),i(da,{stats:h,showAccelerators:!1,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),i(G,{headingId:`load-balancing-node-shares`,title:a(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:Oe,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`div`,{role:`radiogroup`,"aria-label":a(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:Sa.map(e=>i(q,{role:`radio`,"aria-checked":T===e.value,variant:T===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{T!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),e(q,{variant:`outline`,size:`sm`,onClick:()=>{C(!0),S&&O.refetch()},disabled:O.isFetching,children:[i(D,{className:`h-3.5 w-3.5`}),O.isFetching?a(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):E===`benchmark`?a(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):a(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),e(q,{variant:`ghost`,size:`sm`,onClick:r,children:[i(V,{className:`h-3.5 w-3.5`}),a(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),e(q,{variant:`outline`,size:`sm`,onClick:()=>x.mutate(void 0),disabled:x.isPending,title:a(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[i(P,{className:`h-3.5 w-3.5`}),x.isPending?a(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):a(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:e(`div`,{className:`${m} space-y-3`,children:[U!==void 0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U}),h&&e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[a(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,i(K,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?a(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${a(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${a(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),i(ka,{nodes:I.nodes,pending:v.isPending,readOnly:I.readOnly,onCommitWeights:e=>v.mutate(ga(e)),weightLabel:`Node share`,...I.readOnly?{footnote:g?.autoPending?i(d,{children:a(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):e(d,{children:[T===`benchmark`?a(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):a(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),a(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&i(`span`,{className:`ml-1`,children:a(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),B!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:B}),H!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:H}),y.isError&&i(it,{message:a(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:a(`common.unknownError`)})}),v.isError&&i(it,{message:a(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:a(`common.unknownError`)})}),e(`details`,{className:`rounded-md border border-border`,children:[i(`summary`,{className:`${w} cursor-pointer text-xs text-foreground`,children:a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),i(`ul`,{className:`divide-y divide-border border-t border-border`,children:A.map(t=>e(`li`,{className:`${w} flex items-center gap-2`,children:[i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:t.name}),i(We,{type:`number`,min:1,placeholder:`∞`,defaultValue:t.maxCameras??``,"aria-label":a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:t.name}),className:`w-20 text-right`,disabled:b.isPending,onBlur:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==t.maxCameras&&b.mutate({agentNodeId:t.id,maxCameras:i})}})]},t.id))}),i(`p`,{className:`${w} ${W} border-t border-border`,children:a(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),O.isError&&i(it,{message:a(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:O.error instanceof Error?O.error.message:a(`common.unknownError`)})}),k&&i(Ya,{suggestion:k,nameOf:j,pending:v.isPending,...L?{}:{onApply:()=>v.mutate(_a(k))}}),i(G,{headingId:`load-balancing-accelerators`,title:a(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:F,children:i(`div`,{className:`${m} space-y-2`,children:A.length===0?i(ct,{title:a(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:a(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):A.map(e=>i(La,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...N?.[e.id]===void 0?{}:{suggestedMaxSessions:N[e.id]},sharesAutomatic:R,...g===void 0?{}:{shareSource:g.source},...ee(e.id)===void 0?{}:{share:ee(e.id)},...z(e.id)===void 0?{}:{placed:z(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&i(Xa,{stats:h,cameraName:M})]})}function Ya({suggestion:t,nameOf:n,pending:r,onApply:a}){let{t:o}=X();return e(G,{headingId:`load-balancing-suggestion`,title:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):o(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:D,...a===void 0?{}:{actions:i(q,{size:`sm`,onClick:a,disabled:r,children:o(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[i(`ul`,{className:`divide-y divide-border`,children:t.nodes.map(t=>e(`li`,{className:`${w} space-y-0.5`,children:[e(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[i(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:n(t.nodeId)}),i(`span`,{className:`tabular-nums text-foreground`,children:t.share===null?o(`common.skipped`):`${t.share}%`})]}),e(`p`,{className:W,children:[Ca(t.capacityFallback)===null?``:`${Ca(t.capacityFallback)} · `,t.skippedReason===null?o(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:t.capacitySessions,value2:t.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):o(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:t.skippedReason})]})]},t.nodeId))}),e(`p`,{className:`${w} ${W} border-t border-border`,children:[o(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:t.cameraFps,headroom:Math.round(t.headroom*100),basis:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):o(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:t.minSessionsPerDevice})}),` `,a===void 0?o(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):o(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function Xa({stats:t,cameraName:n}){let{t:r}=X(),a=l(),o=Ze({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return i(G,{headingId:`load-balancing-stale-pins`,title:r(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:ke,children:i(`ul`,{className:`divide-y divide-border`,children:t.stalePins.map(t=>e(`li`,{className:`${w} flex items-center gap-2`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs text-foreground`,title:n(t.deviceId),children:n(t.deviceId)}),i(`p`,{className:W,children:ya(t)})]}),i(q,{variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate({deviceId:t.deviceId,deviceKey:`auto`}),children:r(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},t.deviceId))})})}function Za({node:t,emphasis:n=!1}){let{t:r}=X(),a=t.isHub?E:F;return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[i(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),i(a,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 ${n?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[i(`span`,{className:`truncate`,children:t.name}),t.isHub&&i(K,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.hubWord`)}),!t.isOnline&&i(K,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.offline`)})]}),i(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:t.id})]})]})}function Qa({nodes:e,actions:t}){let{t:n}=X();return i(Le,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>i(Za,{node:e})},...$n.map(e=>({key:e.key,header:n(e.labelKey),align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>i(yt,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:qn(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function $a({roleValues:t,options:n,pending:r,onRoleChange:a}){let{t:o}=X(),s=n.map(e=>({value:e.id,label:e.id===`hub`?o(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return i(`ul`,{className:`divide-y divide-border`,children:rr.map(n=>e(`li`,{className:`${w} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[e(`div`,{className:`min-w-0 flex-1 basis-56`,children:[i(`div`,{className:`text-xs font-medium text-foreground`,children:Yn(n)}),i(`p`,{className:W,children:Xn(n)})]}),i(`div`,{className:`w-full sm:w-48`,children:i(Ie,{"aria-label":o(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:Yn(n)}),value:t[n],disabled:r,options:s,onChange:e=>a(n,e.target.value)})})]},n))})}s();function eo(){let{t}=X(),r=l(),{nodes:a}=J(),o=mn(void 0),s=Kt({addonId:nr}),c=Kt({addonId:Kn}),u=Kt({addonId:ir}),d=()=>Qn(r),f=gn({onSuccess:d}),p=rt({onSuccess:d}),m=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.nodeId,t.settings);return e},[o.data]),h=n(()=>a.map(e=>{let t=m.get(e.id),n=cr(t);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[a,m]),g={ingestNode:tr(s.data,`ingestNode`,`hub`),recordingNode:tr(c.data,er,`hub`),audioNode:tr(s.data,`audioNode`,`hub`),motionNode:tr(s.data,`motionNode`,`hub`),postProcessingNode:tr(u.data,Zn,`hub`)},_=n(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id),t=e=>a.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...rr.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[a,g]),v=o.isLoading||s.isLoading||c.isLoading||u.isLoading,y=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:Kn,patch:{[er]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:ir,patch:{[Zn]:t}});return}p.mutate({addonId:nr,patch:{[e]:t}})},x={capabilityPending:f.isPending,onToggleCapability:y},S=v?i(B,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":t(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[e(G,{headingId:`roles-nodes-cluster-roles`,title:t(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:De,actions:S,children:[i(`p`,{className:`${W} border-b border-border px-3 py-1.5 sm:px-4`,children:t(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),i($a,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),i(G,{headingId:`roles-nodes-node-capabilities`,title:t(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:E,children:i(Qa,{nodes:h,actions:x})})]})}s();var to=2500,no={faces:k,"semantic-search":V,"detail-crop":je,"native-lease":Me,"runner-defaults":F,"load-balancer":Oe,failover:z},ro=[`cluster`,si];function io(e){a(()=>{if(e===null)return;let t=li[e]??e,n=`[data-cluster-settings-card="${CSS.escape(t)}"]`,r=()=>{let e=document.querySelector(n);return e===null?!1:(e.scrollIntoView({block:`start`,behavior:`smooth`}),e.classList.add(`ring-2`,`ring-primary/60`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-primary/60`),to),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function ao({section:t}){let{t:n}=X();return i(`div`,{"data-cluster-settings-card":t.id,className:`rounded-lg`,children:i(G,{headingId:`cluster-settings-${t.id}`,title:t.title,...no[t.id]===void 0?{}:{icon:no[t.id]},children:e(`div`,{className:`${m} space-y-3`,children:[i(`p`,{className:W,children:t.hint}),t.panels.map(e=>i(Gn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:ro.filter(t=>!(e.sectionIds??[]).includes(t)),emptyMessage:n(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}`))]})})})}function oo({refreshToken:e}){let[t]=En();return io(t.get(fi)),i(`div`,{className:`space-y-3 sm:space-y-4`,children:ci.map(e=>i(ao,{section:e},e.id))})}function so(e){return e?.hex}function co({hex:e}){return i(`span`,{className:`inline-block h-3 w-3 shrink-0 rounded-sm border border-border`,style:{backgroundColor:e}})}function lo({id:t,label:n,swatch:r}){let a=so(r);return a===void 0?null:e(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs`,"data-testid":`palette-entry-${t}`,children:[r?.form===`gradient`?i(`span`,{className:`flex h-4 overflow-hidden rounded-sm`,children:be.map(e=>i(`span`,{className:`h-4 w-2`,style:{backgroundColor:a,opacity:e}},e))}):i(`span`,{className:`h-4 w-3 shrink-0 rounded-sm`,style:{backgroundColor:a}}),i(`span`,{children:n}),i(`span`,{className:`font-mono text-[11px] opacity-80`,children:a})]})}function uo({ground:t,group:n,swatches:r}){let{t:a}=X();return e(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[i(lo,{id:n.id,label:n.label,swatch:r[n.id]}),n.children.length>0&&e(`details`,{"data-testid":`palette-subs-${t}-${n.id}`,children:[i(`summary`,{className:`cursor-pointer text-[11px] opacity-80`,children:a(`pipeline.palette.subclasses`,`Subclasses`)}),i(`div`,{className:`mt-1 flex flex-col gap-1 pl-4`,children:n.children.map(e=>i(lo,{id:e.id,label:e.label,swatch:r[e.id]},e.id))})]})]})}function fo({swatches:t}){let{t:n}=X(),r=se(),a=[{id:`dark`,background:ge.dark,ink:ge.light},{id:`light`,background:ge.light,ink:ge.dark}];return e(`div`,{className:`flex flex-col gap-2`,"data-testid":`palette-preview`,children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.palette.preview`,`Timeline marks`)}),a.map(e=>i(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-2 rounded-md border border-border p-2 sm:grid-cols-2`,"data-testid":`palette-ground-${e.id}`,style:{backgroundColor:e.background,color:e.ink},children:r.map(n=>i(uo,{ground:e.id,group:n,swatches:t},n.id))},e.id))]})}function po(e){for(let t of se()){if(t.id===e)return t.label;let n=t.children.find(t=>t.id===e);if(n!==void 0)return n.label}return e}s();function mo(e){return/^#[0-9a-f]{6}$/.test(e)}function ho(e,t){let n={};for(let r of ye){let i=t[r],a=e[r];i===void 0||a===void 0||i.hex!==a.hex&&(n[r]=i)}return n}function go({status:t,reason:r,source:a,presetId:s,customized:c,swatches:l,presets:u,saving:d,onApply:f}){let{t:p}=X(),[m,h]=o(c===!0),[g,_]=o(s??u[0]?.id??`camstack`),[v,y]=o(l??u[0]?.swatches??{}),b=u.find(e=>e.id===g)??u[0],x=n(()=>b===void 0?null:ae(v,b.fallbacks),[b,v]);if(t===`pending`)return i(`p`,{className:`text-xs text-foreground-subtle`,role:`status`,children:p(`pipeline.palette.pending`,`Reading the cluster palette…`)});let S=e=>{let t=u.find(t=>t.id===e);t!==void 0&&(h(!1),_(e),y(t.swatches),f({presetId:e}))},C=()=>{b!==void 0&&(h(!0),y(b.swatches))},w=(e,t)=>{if(typeof t!=`string`)return;let n=t.trim().toLowerCase();if(!mo(n))return;let r=v[e],i=r?.form===`gradient`?{...r,hex:n}:{form:`solid`,hex:n};y({...v,[e]:i})};return e(`div`,{className:`flex flex-col gap-4`,children:[t===`unknown`&&i(`p`,{className:`text-xs text-warning`,role:`status`,"data-testid":`palette-unknown`,children:p(`pipeline.palette.unknown`,`The stored palette cannot be read ({{reason}}). Boxes use the bundled CamStack preset.`,{reason:r??``})}),t===`ready`&&a===`unconfigured`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:p(`pipeline.palette.sourceUnconfigured`,`CamStack preset (cluster default)`)}),i(G,{headingId:`palette-presets`,title:p(`pipeline.palette.presets`,`Presets`),children:e(`div`,{className:`flex flex-wrap gap-2 p-3`,children:[u.map(t=>i(q,{type:`button`,size:`sm`,variant:!m&&t.id===g?`primary`:`outline`,onClick:()=>S(t.id),disabled:d,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[[`person`,`vehicle`,`animal`].map(e=>{let n=so(t.swatches[e]);return n===void 0?null:i(co,{hex:n},e)}),t.name]})},t.id)),i(q,{type:`button`,size:`sm`,variant:m?`primary`:`outline`,onClick:C,disabled:d||b===void 0,children:p(`pipeline.palette.custom`,`Custom`)})]})}),i(fo,{swatches:v}),x!==null&&x.ok&&i(`p`,{className:`text-xs text-success`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.valid`,`Every colour is distinct on both themes.`)}),x!==null&&!x.ok&&i(`p`,{className:`text-xs text-danger`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.invalid`,`This palette is refused: {{reason}}`,{reason:he(x.violations)})}),m&&b!==void 0&&i(G,{headingId:`palette-custom`,title:p(`pipeline.palette.custom`,`Custom`),children:e(`div`,{className:`flex flex-col gap-2 p-3`,children:[ye.map(e=>{let t=so(v[e]);return t===void 0?null:i(zt,{field:{type:`color`,key:e,label:po(e)},values:{[e]:t},onChange:(t,n)=>w(e,n)},e)}),i(q,{type:`button`,size:`sm`,onClick:()=>{if(b===void 0||x===null||!x.ok)return;let e=ho(b.swatches,v);f(Object.keys(e).length>0?{presetId:b.id,overrides:e}:{presetId:b.id})},disabled:d||x===null||!x.ok,children:p(`pipeline.palette.save`,`Save custom palette`)})]})})]})}function _o(){let e=nn({}),t=Xt({}),n=Bt(),r=r=>{n.mutate(r,{onSuccess:()=>{e.refetch(),t.refetch()}})};if(e.isPending||t.isPending)return i(go,{status:`pending`,presets:[],onApply:r});if(e.isError||e.data===void 0)return i(go,{status:`unknown`,reason:e.isError?String(e.error):`no palette`,presets:t.data??[],saving:n.isPending,onApply:r});if(t.isError||t.data===void 0)return i(go,{status:`unknown`,reason:String(t.error),presets:[],saving:n.isPending,onApply:r});if(e.data.status===`unknown`)return i(go,{status:`unknown`,reason:e.data.reason,presets:t.data,saving:n.isPending,onApply:r});let a=e.data;return i(go,{status:`ready`,source:a.source,presetId:a.presetId,customized:a.customized,swatches:a.swatches,presets:t.data,saving:n.isPending,onApply:r},`${a.presetId}:${String(a.customized)}`)}var vo=`pipeline-orchestrator`,yo=200;function bo(){let{t}=X();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterOrchestratorLogsTab.dispatchDecisionsBalancerMovesAnd`,`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.`)})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(kt,{addonId:vo,limit:yo,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}var xo=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`},{id:`palette`,labelKey:`pipeline.clusterDetail.tabPalette`}];function So(e){return xo.some(t=>t.id===e)}function Co({refreshToken:t}){let{t:n}=X(),[r,a]=En(),o=r.get(di),s=So(o)?o:`assignments`,c=e=>{a(t=>{let n=new URLSearchParams(t);return n.set(di,e),n.delete(fi),n},{replace:!0})};return e(`div`,{className:`flex flex-col h-full`,children:[e(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:n(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),i(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:n(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles, settings and the display palette.`)})]}),i(tt,{value:s,onValueChange:e=>{So(e)&&c(e)},className:`px-4 sm:px-6`,children:i(et,{className:`border-border`,children:xo.map(e=>i(xt,{value:e.id,className:`h-auto py-2 border-b-2`,children:n(e.labelKey)},e.id))})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[s===`assignments`&&i(Ri,{}),s===`load-balancing`&&i(Ja,{refreshToken:t,onOpenAutoTune:()=>c(`auto-tune`)}),s===`auto-tune`&&i(ra,{}),s===`roles-nodes`&&i(eo,{}),s===`settings`&&i(oo,{refreshToken:t}),s===`logs`&&i(bo,{}),s===`palette`&&i(_o,{})]})]})}function Q({title:t,children:n}){return e(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[i(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:t}),i(`div`,{className:`flex flex-col gap-1 min-w-0`,children:n})]})}function $({label:t,children:n,overridden:r=!1}){return e(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[i(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:t,children:t}),i(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:n}),r&&i(wo,{})]})}function wo(){let{t:e}=X();return i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),"aria-label":e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),role:`img`})}var To={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 Eo({tone:e=`neutral`,children:t,title:n}){return i(`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 ${To[e]}`,children:t})}function Do({children:e}){return i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function Oo({icon:t,label:n,nodeId:r,pinned:a,reason:o,overridden:s}){let{t:c}=X();return e(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[i(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),i(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:n}),r===null?i(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):e(d,{children:[i(`span`,{className:`font-mono text-foreground truncate`,title:r,children:r}),a?e(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[i(p,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:o!==void 0&&o.length>0?o:c(`cameras.configBlocks.capacity`)})}),s&&i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:c(`cameras.configBlocks.persistedSettingsPinForThis`,`Persisted settings pin for this role`)})]})]})}function ko({assignment:t,settings:n,onlineNodes:r,pinPending:a,onDetectionPinChange:o}){let{t:s}=X(),c=t.pinned.detection&&t.detectionNodeId!==null?t.detectionNodeId:`auto`,l=[...new Set([...t.detectionNodeId===null?[]:[t.detectionNodeId],...r.map(e=>e.id)])];return e(Q,{title:s(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[i(Oo,{icon:F,label:s(`cameras.configBlocks.detection`,`Detection`),nodeId:t.detectionNodeId,pinned:t.pinned.detection,reason:t.reasons.detection,overridden:n.overriddenKeys.has(`pipelineNodeId`)}),i(Oo,{icon:v,label:s(`cameras.configBlocks.decoder`,`Decoder`),nodeId:t.decoderNodeId,pinned:t.pinned.decoder,reason:t.reasons.decoder,overridden:n.overriddenKeys.has(`decoderNodeId`)}),i(Oo,{icon:H,label:s(`cameras.configBlocks.audio`,`Audio`),nodeId:t.audioNodeId,pinned:t.pinned.audio,reason:t.reasons.audio,overridden:n.overriddenKeys.has(`audioNodeId`)}),i(Oo,{icon:S,label:s(`cameras.configBlocks.source`,`Source`),nodeId:t.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),i(`div`,{className:`mt-1.5`,children:e(`select`,{value:c,disabled:a,"aria-label":s(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>o(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:[i(`option`,{value:`auto`,children:s(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),l.map(e=>i(`option`,{value:e,children:s(`cameras.configBlocks.pinDetection`,{node:r.find(t=>t.id===e)?.name??e})},e))]})})]})}function Ao(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function jo(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function Mo(e){return e===null?Y.t(`pipeline.configBlocks.fpsDefault`):e===0?Y.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function No({streams:t,brokerProfiles:n,settings:r,motionEnabled:a,motionFpsLive:o,cameraSensors:s}){let{t:c}=X(),l=jo(n,r.detectionStreamProfile),u=jo(n,r.motionStreamProfile),f=r.motionSources.includes(`analyzer`);return e(Q,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[e($,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:r.overriddenKeys.has(`detectionStreamProfile`),children:[r.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),i($,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:r.overriddenKeys.has(`detectionFps`),children:Mo(r.detectionFps)}),e($,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:r.overriddenKeys.has(`motionSources`),children:[r.motionSources.length>0?r.motionSources.map(fe).join(` + `):c(`cameras.configBlocks.none`),a===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),i($,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:Pn(s)}),f&&e(d,{children:[e($,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:r.overriddenKeys.has(`motionStreamProfile`),children:[r.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),e($,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:r.overriddenKeys.has(`motionFps`),children:[Mo(r.motionFps),o!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:o.toFixed(1)})}`]})]}),i($,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:r.overriddenKeys.has(`motionCooldownMs`),children:r.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${r.motionCooldownMs/1e3}s`}),i(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:t.length===0?i(Do,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):t.map(t=>e(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:t.camStreamId,children:[i(`span`,{className:`text-foreground-muted`,children:t.kind}),` `,Ao(t)]},t.camStreamId))})]})}function Po({steps:t,audioModelId:n,audioEnabled:r,audioMode:a}){let{t:o}=X();return e(Q,{title:o(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[t===void 0?i(Do,{children:o(`cameras.configBlocks.resolving`,`Resolving…`)}):t.length===0?i(Do,{children:o(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.map((t,n)=>i(Eo,{tone:t.enabled&&t.depth===0?`info`:`neutral`,title:t.modelId??t.addonId,children:e(`span`,{className:t.enabled?``:`line-through opacity-60`,children:[t.depth>0&&i(`span`,{className:`opacity-50`,children:`↳ `}),t.addonId,t.modelId!==null&&e(`span`,{className:`font-mono opacity-75`,children:[` · `,t.modelId]})]})},`${t.addonId}-${n}`))}),i(`div`,{className:`mt-1`,children:e($,{label:o(`cameras.configBlocks.audioClass`,`Audio class.`),children:[a??`—`,r!==null&&` · ${o(r?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,n!==null&&` · ${n}`]})})]})}var Fo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Io({detection:t,live:n,detectionMode:r,modeOverridden:a}){let o=N(),{t:s}=X();if(t===null)return e(Q,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),i(Do,{children:s(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let c=n?.phase??t.phase,l=n?.actualFps??t.actualFps,u=n?.configuredFps??t.configuredFps,d=n?.avgInferenceTimeMs??t.avgInferenceMs,f=n?.queueDepth??t.queueDepth,p=Lt(c,o),m=c===`active`&&l===0;return e(Q,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[e(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${p.badgeClass}`,children:[i(Vt,{phase:c,className:`h-2.5 w-2.5`}),p.label]}),n!==void 0&&i(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:s(`common.live`)})]}),i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),e($,{label:`FPS`,children:[i(`span`,{className:m?`text-danger font-semibold`:``,children:l.toFixed(1)}),i(`span`,{className:`ml-1 text-foreground-subtle`,children:s(`cameras.runtimeBlocks.configuredFps`,{fps:u.toFixed(0)})})]}),e($,{label:s(`cameras.runtimeBlocks.inference`,`Inference`),children:[d.toFixed(0),` ms`,f>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.queue`,{depth:f})}),n!==void 0&&n.droppedFrames>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.drops`,{count:n.droppedFrames})})]}),e($,{label:s(`cameras.runtimeBlocks.engine`,`Engine`),children:[t.engine.backend,` · `,t.engine.device]}),e($,{label:s(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[i(Eo,{tone:Fo[t.provisioning.state]??`neutral`,children:t.provisioning.state}),t.provisioning.error!==void 0&&e(`span`,{className:`text-danger text-[10px]`,children:[` `,t.provisioning.error]})]})]})}function Lo({broker:t}){let{t:n}=X();return t===null?i(Q,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:i(Do,{children:n(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):e(Q,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[t.profiles.length===0?i(Do,{children:n(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):i(`div`,{className:`flex flex-col gap-1`,children:t.profiles.map(t=>{let r=t.status===`streaming`,a=r&&t.inFps===0;return e(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${a?`bg-danger`:r?`bg-success animate-pulse`:`bg-border`}`,title:t.status}),i(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:t.profile,children:t.profile}),e(`span`,{className:`text-foreground-subtle truncate`,children:[t.width,`×`,t.height,` `,t.codec]}),i(`span`,{className:`ml-auto shrink-0 ${a?`text-danger`:`text-foreground`}`,children:n(`cameras.runtimeBlocks.fpsValue`,{value:t.inFps===null?`—`:t.inFps.toFixed(0)})}),e(`span`,{className:`text-foreground-subtle shrink-0`,title:n(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,t.subscribers]})]},t.profile)})}),e(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[i(Eo,{tone:t.webrtcSessions>0?`info`:`neutral`,children:n(`cameras.runtimeBlocks.webrtc`,{count:t.webrtcSessions})}),i(Eo,{tone:t.rtspRestream?`success`:`neutral`,children:t.rtspRestream?n(`cameras.runtimeBlocks.restreamOn`):n(`cameras.runtimeBlocks.restreamOff`)})]})]})}function Ro({decoder:e}){let{t}=X();return e===null?i(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i(Do,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):i(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i($,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}s();var zo=`pipeline-orchestrator`,Bo={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Vo={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function Ho({problems:t}){return i(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:t.map(t=>e(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${t.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[i(ie,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),i(`span`,{className:`min-w-0`,children:t.message})]},t.code))})}function Uo({deviceId:t,name:r,online:a,status:o,live:s,onlineNodes:c}){let{t:u}=X(),d=l(),{data:f}=at({addonId:zo,deviceId:t,nodeId:`hub`},{staleTime:3e4}),{data:p}=Be({deviceId:t},{staleTime:3e4}),m=n(()=>Dn(f),[f]),h=n(()=>p===void 0?void 0:Un(p.steps),[p]),g=n(()=>o===void 0?[]:Nn(o),[o]),_=()=>{d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=Pe({onSuccess:_}),y=ze({onSuccess:_}),b=e=>{e===`auto`?y.mutate({deviceId:t}):v.mutate({deviceId:t,agentNodeId:e})},x=o===void 0?`idle`:Wn(o),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return e(`article`,{"aria-label":u(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:r}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[e(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[i(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:Bo[x]}`,title:S?u(`common.error`,`Error`):u(Vo[x]),"aria-label":S?u(`common.error`,`Error`):u(Vo[x]),role:`img`}),i(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:r,children:r}),e(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,t]}),!a&&i(Eo,{tone:`danger`,children:u(`common.offline`)}),e(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&i(Eo,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:u(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?u(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),o?.recording!=null&&(o.recording.active?e(Eo,{tone:`danger`,title:u(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:o.recording.mode}),children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):o.recording.mode!==`off`&&i(Eo,{tone:`neutral`,title:u(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:u(`pipeline.cameraPipelineCard.recMode`,{mode:o.recording.mode})}))]})]}),g.length>0&&i(Ho,{problems:g}),o===void 0?i(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:u(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[i(ko,{assignment:o.assignment,settings:m,onlineNodes:c,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),i(Io,{detection:o.detection,live:s,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),i(Po,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:o.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),i(No,{streams:o.source.streams,brokerProfiles:o.broker?.profiles,settings:m,motionEnabled:o.motion?.enabled??null,motionFpsLive:o.motion?.fps??null,cameraSensors:o.cameraSensors}),i(Lo,{broker:o.broker}),i(Ro,{decoder:o.decoder})]})]})}s();var Wo=5e3,Go=1e4,Ko=5e3;function qo(e){let t=l(),{data:r,isLoading:i}=Cn(),{data:s,isLoading:c}=Ot({},{refetchInterval:Wo}),{nodes:u}=J();a(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=o(new Map);wt(ce.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),a(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Go,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Ko);return()=>clearInterval(e)},[d.size]);let p=n(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:n(()=>(r??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[r,p]),liveMetrics:d,onlineNodes:n(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:i||c}}s();function Jo({refreshToken:t}){let{t:r}=X(),{rows:a,liveMetrics:o,onlineNodes:s,isLoading:c}=qo(t),l=n(()=>[...a.map(e=>{let t=e.status===void 0?[]:Nn(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),[a]),u=n(()=>{let e=0,t=0;for(let n of l)(n.errorCount>0||n.warningCount>0)&&(t+=1),(o.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:l.length,active:e,issues:t}},[l,o]);return c&&a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):i(`div`,{className:`h-full overflow-y-auto`,children:e(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[e(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[i(`span`,{children:i(Tn,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:u.total},components:{b:i(`span`,{className:`font-semibold text-foreground`})}})}),i(`span`,{children:i(Tn,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:u.active},components:{b:i(`span`,{className:`font-semibold text-success`})}})}),e(`span`,{children:[i(`span`,{className:`font-semibold ${u.issues>0?`text-danger`:`text-foreground`}`,children:u.issues}),` `,r(`cameras.camerasOverview.withIssues`,`with issues`)]}),i(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:r(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),l.map(({row:e})=>i(Uo,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:o.get(e.deviceId),onlineNodes:s},e.deviceId))]})})}s();var Yo=`__cluster__`;function Xo(e){return e===`cameras`?`cameras`:`nodes`}function Zo({viewMode:t,onNodes:n,onCameras:r}){let{t:a}=X();return e(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":a(`pipeline.pipelineView`,`Pipeline view`),children:[i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`nodes`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.nodes`,`Nodes`)}),i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`cameras`,onClick:r,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.cameras`,`Cameras`)})]})}function Qo(){let{t}=X(),[n,r]=En(),s=Xo(n.get(`view`)),c=n.get(`node`)??`__cluster__`,[l,u]=o(0),[f,p]=o(!1);return a(()=>{s===`nodes`&&!n.get(`node`)&&r(e=>{let t=new URLSearchParams(e);return t.set(`view`,`nodes`),t.set(`node`,Yo),t},{replace:!0})},[s,n,r]),e(pt,{icon:Ce,title:t(`pipeline.pipeline`,`Pipeline`),subtitle:t(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:e(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:t(`common.refresh`,`Refresh`),children:[i(g,{className:`h-3.5 w-3.5`}),t(`common.refresh`,`Refresh`)]}),nav:i(Zo,{viewMode:s,onNodes:()=>{r({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{r({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[s===`nodes`&&e(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":f,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[i(`span`,{children:t(f?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),i(R,{className:[`h-4 w-4 transition-transform`,f?`rotate-180`:``].join(` `)})]}),i(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:s===`nodes`?e(d,{children:[i(`aside`,{className:[f?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b border-border md:border-b-0 md:border-r`,`max-h-[60vh] overflow-y-auto md:max-h-none`].join(` `),children:i(ur,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?i(Co,{refreshToken:l}):i(Li,{nodeId:c,refreshToken:l})})]}):i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:i(Jo,{refreshToken:l})})})]})}export{Qo as PipelinePage};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,i as c,o as l,p as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{A as f,Bn as p,D as m,Di as h,Dn as g,Fr as _,Hr as v,Ht as y,N as b,O as x,On as S,St as C,T as w,V as T,_n as E,_r as D,b as O,bn as k,dr as A,dt as j,gt as M,ha as N,ht as P,ii as F,j as I,k as L,ki as R,la as ee,mn as z,pr as B,rn as V,rr as H,st as U,ur as te,v as ne,y as re,z as W,zt as ie}from"./player-overlays-Cw_gjG75.js";import{$r as ae,Br as oe,Cn as se,Hr as ce,Ir as le,Lr as ue,Pr as de,Rr as fe,Vr as pe,Zo as me,Zr as he,ei as ge,f as _e,l as ve,ni as ye,ti as be,u as xe,zr as Se}from"./client-r4i0EpF6.js";import{d as Ce,t as we,u as Te}from"./video-DXegVNA2.js";import{a as Ee,i as De,n as Oe,r as ke,t as Ae}from"./usb-CyQsTtlO.js";import{t as je}from"./crop-D9cpl5_W.js";import{t as Me}from"./layers-C-ZqYk3U.js";import{n as Ne}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js";import{$n as Pe,An as Fe,At as Ie,Bl as Le,Cn as Re,Cr as ze,Dl as Be,El as Ve,Fn as He,Fo as Ue,Gd as We,Hl as Ge,Il as Ke,In as qe,Jn as Je,Kd as Ye,Kn as Xe,Ll as Ze,Mi as Qe,Nd as $e,Nr as et,Oi as tt,Ol as nt,On as G,Pn as rt,Pr as it,Qc as at,Rd as ot,Rl as st,Sl as ct,Sr as lt,St as ut,Tl as dt,Tr as ft,Vl as pt,Wl as mt,Xc as ht,Xn as gt,Yc as _t,Yn as vt,Zc as yt,Zn as bt,Zt as xt,_l as St,af as Ct,al as wt,at as Tt,bl as Et,br as Dt,cf as Ot,cn as kt,di as K,dr as At,el as jt,er as Mt,fr as Nt,gl as Pt,gn as Ft,hr as It,hs as Lt,ht as Rt,if as q,il as zt,it as Bt,jn as Vt,ki as Ht,kt as Ut,lf as Wt,lr as Gt,ml as Kt,ms as qt,nl as Jt,nr as Yt,nt as Xt,of as Zt,ol as Qt,pl as $t,ps as en,qd as tn,r as nn,ri as J,rl as rn,rr as an,rt as on,sf as sn,st as cn,tl as ln,tr as un,tt as dn,ul as fn,vl as pn,vr as mn,wl as hn,wr as gn,wt as _n,xl as vn,xr as yn,yr as bn,zd as xn,zl as Sn}from"./src-nnHXOip7.js";import{t as Y}from"./i18n-BE1bPZOs.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{br as Cn,hr as wn,mr as Tn,ur as En}from"./index-Ohn-2iW_.js";import{_ as Dn,a as On,b as kn,c as An,d as jn,f as Mn,g as Nn,h as Pn,i as Fn,l as In,m as Ln,n as Rn,p as zn,r as Bn,s as Vn,u as Hn,v as Un,y as Wn}from"./step-inspector-model-BKKc_lkM.js";import"./useEventInvalidation-B_Zjyqyk.js";import{t as Gn}from"./NodeAddonsSettingsPanel-JIXh-CLX.js";import{a as Kn,c as qn,d as Jn,g as Yn,h as Xn,i as Zn,l as Qn,n as $n,o as er,p as tr,r as nr,s as rr,t as ir}from"./board-model-D3wYwuI4.js";s();function ar(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function or(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function sr(e){return e!==!1}function cr(e){return{pipeline:sr(or(e,`detect`)),audio:sr(or(e,`audio`)),ingest:sr(or(e,`ingest`))}}function lr(e,t){let n=e?.find(e=>e.nodeId===t);return cr(n?.settings)}function ur({selectedNodeId:t,onSelect:n,refreshToken:r}){let a=N(),{t:o}=X(),{nodes:s}=Ct(),{data:c}=Pt(void 0),{data:l}=Et(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let f=s??[],p=f.filter(e=>e.isOnline).length,m=f.filter(e=>!e.isOnline).length;return e(`div`,{className:`flex flex-col h-full`,children:[e(`button`,{type:`button`,onClick:()=>n(Yo),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${t===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[i(Te,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`text-xs font-semibold truncate`,children:o(`pipeline.nodeList.cluster`,`Cluster`)}),i(`div`,{className:`text-[10px] text-foreground-subtle`,children:o(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),i(`div`,{className:`flex-1 overflow-y-auto`,children:f.map(r=>{let s=t===r.id,c=u.get(r.id)??0,f=r.isHub?E:F,p=lr(l,r.id),m=r.isOnline?null:xt(ar(r.lastSeen),a);return e(`button`,{type:`button`,onClick:()=>n(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${s?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[i(f,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:o(`common.hubWord`)}),!r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),e(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[i(`span`,{children:o(`common.coresCount`,{count:r.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),c>0&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[i(we,{className:`h-2.5 w-2.5`}),c]})]}),!r.isOnline&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`text-danger`,children:[o(`common.offline`),m===null?``:` · ${m}`]})]})]}),e(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[i(K,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?o(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):o(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:o(`pipeline.nodeList.pipe`,`Pipe`)}),i(K,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?o(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):o(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:o(`pipeline.nodeList.aud`,`Aud`)})]})]})]},r.id)})}),e(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[i(`span`,{children:o(`common.onlineCount`,{count:p})}),m>0&&i(`span`,{className:`text-danger`,children:o(`common.offlineCount`,{count:m})})]})]})}function dr({nodeId:t,refreshToken:n}){let{t:r}=X(),{nodes:a}=Ct(),o=a?.find(e=>e.id===t),s=Zt(`pipeline.runner-load-snapshot`,e=>e.nodeId===t)?.load??null;return o?e(`div`,{className:`px-6 py-4 border-b border-border`,children:[e(`div`,{className:`flex items-center gap-2 mb-1`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:o.name}),o.isOnline?i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:r(`common.online`)}):i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:r(`common.offline`)}),o.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:r(`common.hubWord`)})]}),e(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[i(`span`,{children:o.cpuModel??`CPU`}),i(`span`,{children:`•`}),i(`span`,{children:r(`common.coresCount`,{count:o.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(o.memoryMB/1024),` GB`]}),s&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.cameras`,{attached:s.attachedCameras,active:s.activeCameras})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.avgInference`,{ms:s.avgInferenceTimeMs.toFixed(0)})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.queue`,{depth:s.queueDepthTotal})}),s.hardware.hasGpu&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):i(`div`,{className:`px-6 py-4 border-b border-border`,children:e(`div`,{className:`text-xs text-foreground-subtle`,children:[r(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,t]})})}var fr=[`assignments`,`tree`,`engines`,`logs`];function pr({refreshToken:t,nodeId:r}){let{t:a}=X(),[s,c]=o(new Map),{nodes:l}=q();Ot(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&c(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:u}=Qt(void 0),d=n(()=>{let e=new Map;for(let t of u??[])e.set(t.nodeId,t.deviceCount);return e},[u]),f=n(()=>{let e=new Map,t=Date.now()-3e4;for(let n of s.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[s]),p=n(()=>{let e=new Map;for(let t of l)e.set(t.id,t.shortName);return e},[l]),m=n(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of f.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:l.length,onlineAgents:l.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[f,l]);if(r){let t=f.get(r);return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[i(Z,{label:`FPS`,value:t?t.totalFps.toFixed(1):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:t?`${t.activeCameras}/${t.attachedCameras}`:`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:t&&t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.queue`,`Queue`),value:t?String(t.queueDepth):`—`}),i(Z,{label:a(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(d.get(r)??`—`)})]})]})}let h=[...f.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[i(Z,{label:a(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),i(Z,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),i(Z,{label:a(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),i(Z,{label:a(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),i(Z,{label:a(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[480px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.liveLoadPanel.agent`,`Agent`)}),i(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.queue`,`Queue`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),e(`tbody`,{children:[h.map(([t,n])=>e(`tr`,{className:`border-t border-border`,children:[i(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(t)??t}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.totalFps.toFixed(1)}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras>0?(n.totalInferenceWeighted/n.attachedCameras).toFixed(0):`—`}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.queueDepth}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:d.get(t)??`—`})]},t)),h.length===0&&i(`tr`,{children:i(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function Z({label:t,value:n}){return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[i(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:t}),i(`div`,{className:`text-lg font-semibold text-foreground`,children:n})]})}var mr={active:!1,pinned:!1,nodeId:null,reason:``};function hr(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function gr(e,t,n){let r=new Map(t.map(e=>[e.deviceId,e])),i=new Map(n.map(e=>[e.deviceId,e]));return e.map(e=>{let t=r.get(e.id),n=i.get(e.id),a=t?{active:!0,pinned:t.pinned,nodeId:t.agentNodeId,reason:t.reason??``}:mr,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:mr;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:mr,audio:o}}).toSorted(hr)}function _r(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function vr(e,t){let n=new Map(t.map(e=>[e.deviceId,e.assignment]));return e.map(e=>{let t=n.get(e.deviceId);return t===void 0?e:{...e,detection:_r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:_r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:_r(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function yr(e,t,n){let r=(t,n,r)=>({active:t!==null&&t===e,pinned:n,nodeId:t,reason:r??``});return t.map(({deviceId:e,assignment:t})=>({deviceId:e,deviceName:n(e),detection:r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:r(t.audioNodeId,t.pinned.audio,t.reasons.audio)})).filter(e=>e.detection.active||e.decoder.active||e.audio.active).toSorted(hr)}function br(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>{let n=t.get(e);return n!==void 0&&n!==``?n:e}}function xr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??Y.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function Sr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:Y.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:Y.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function Cr({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:a,emphasizeOnNodeId:o}){if(n.nodeId===null)return null;let s=n.nodeId,c=o===void 0?!1:n.active&&s===o;return i(rt,{roleId:e,roleLabel:t,nodeName:r(s),colorId:qe(a,s),emphasized:c,pinned:n.pinned})}function wr({detection:t,decoder:n,audio:r,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s}){let c=(e,t,n)=>i(Cr,{roleId:e,roleLabel:t,state:n,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s},e);return e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[c(`detection`,`Detection`,t),c(`decode`,`Decode`,n),c(`audio`,`Audio`,r)]})}function Tr({snap:t}){let n=N(),{t:r}=X();if(t===void 0)return i(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:r(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:r(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:a,actualFps:o,avgInferenceTimeMs:s,queueDepth:c,configuredFps:l,droppedFrames:u}=t.metrics,d=Ft(a,n);return e(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[e(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${d.textColor}`,children:[i(Rt,{phase:a,className:`h-2.5 w-2.5 shrink-0`}),i(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:d.label}),i(`span`,{className:`text-foreground`,children:o.toFixed(1)}),i(`span`,{className:`text-foreground-subtle`,children:r(`pipeline.assignmentStatusCell.configuredFps`,{fps:l.toFixed(0)})})]}),e(`span`,{className:`truncate text-foreground-subtle`,children:[i(`span`,{className:`text-foreground`,children:s.toFixed(0)}),` ms`,c>0&&e(`span`,{className:`ml-1 text-warning`,children:[`q`,c]}),i(`span`,{className:u>0?`ml-1 text-warning`:`ml-1`,children:r(`pipeline.assignmentStatusCell.drops`,{count:u})})]})]})}s();var Er=1e4,Dr=5e3;function Or(e){let[t,n]=o(new Map);return Ot(`pipeline.camera-metrics-snapshot`,t=>{let r=t.data;typeof r.deviceId==`number`&&(e!==void 0&&r.nodeId!==e||n(e=>new Map(e).set(r.deviceId,r)))}),a(()=>{if(t.size===0)return;let e=setInterval(()=>{n(e=>{let t=Date.now()-Er,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},Dr);return()=>clearInterval(e)},[t.size]),t}var kr=3e5;function Ar({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:a}){let{t:o}=X();return i($e,{"aria-label":o(`assignments.placementControls.nodePin`,`Node pin`),title:o(`assignments.placementControls.autoLetsEachSessionPick`,`Auto lets each session pick its node; a pin keeps the camera on one node.`),value:e.pinned&&e.nodeId!==null?e.nodeId:`auto`,disabled:r,options:[...Sr(e,t,n)],onChange:e=>a(e.target.value)})}function jr({deviceId:e,nodeId:t}){let{t:n}=X(),r=l(),{data:a}=St({deviceId:e},{refetchOnMount:`always`}),{data:o}=Kt({nodeId:t},{staleTime:kr}),s=st({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(a===void 0||o===void 0)return i(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let c=o.devices??[],u=c.filter(e=>e.enabled),d=a?.deviceKey??`auto`,f=d!==`auto`&&!u.some(e=>e.key===d),p=c.find(e=>e.key===d),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...f?[{value:d,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${At(p)} (${d})`:d})}]:[],...u.map(e=>({value:e.key,label:`${At(e)} · ${e.format}`}))];return i($e,{"aria-label":n(`assignments.placementControls.inferenceDevicePin`,`Inference device pin`),title:n(`assignments.placementControls.pinDetectionToOneAccelerator`,`Pin detection to one accelerator of the node, or let each session pick.`),value:d,disabled:s.isPending,options:m,onChange:t=>s.mutate({deviceId:e,deviceKey:t.target.value})})}s();function Mr(e){let n=t(null);return e.nodeId!==null&&(n.current=e),n.current}function Nr({deviceId:t,state:n,...r}){let{t:a}=X(),o=Mr(n);return e(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[i(Ar,{state:n,...r}),o?.nodeId==null?i($e,{"aria-label":a(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:a(`assignments.clusterRowCells.anAcceleratorIsPinnedOn`,`An accelerator is pinned on the camera's node; this camera has not run on one yet.`),disabled:!0,defaultValue:`auto`,options:[{value:`auto`,label:a(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):i(jr,{deviceId:t,nodeId:o.nodeId})]})}function Pr({state:t,nameOf:n}){let{t:r}=X(),a=Mr(t);if(a?.nodeId==null)return i(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let o=t.active&&t.nodeId!==null,s=a.pinned?`pinned`:`auto · ${a.reason||`capacity`}`;return e(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:a.pinned?void 0:r(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[e(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[i(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${o?`bg-success`:`bg-foreground-subtle/40`}`}),i(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${o?`text-foreground`:`text-foreground-muted`}`,children:n(a.nodeId)})]}),i(`span`,{className:`truncate pl-3 text-[10px] ${a.pinned?`text-warning`:`text-foreground-subtle`}`,children:o?s:r(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:s})})]})}function Fr({deviceId:t,deviceName:n}){let{t:r}=X(),[a,s]=o(!1);return e(d,{children:[i(xn,{icon:S,variant:`ghost`,size:`sm`,"aria-label":r(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:n}),title:r(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>s(!0)}),i(bn,{open:a,onOpenChange:s,children:e(yn,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[i(gn,{children:i(ft,{children:r(`pipeline.clusterRowCells.brokersTitle`,{device:n})})}),i(Dt,{children:a&&i(mn,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t,instanceId:`pipeline-row/${t}`,config:{variant:`compact`}})})]})})]})}function Ir(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function Lr(e,t){return t.size===0?!0:t.has(e)}var Rr=[{value:`active`,get label(){return Y.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return Y.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return Y.t(`helpers.cameraActivity.inactive`)}}];s();var zr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function Br(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function Vr(){let{t}=X(),r=l();nn([`pipelineOrchestrator`,`getPipelineAssignments`],zr),nn([`pipelineOrchestrator`,`getAudioAssignments`],zr),nn([`pipelineOrchestrator`,`getCameraStatuses`],zr);let{data:a}=Ue({isCamera:!0,projection:`slim`}),{data:s}=Pt(void 0),{data:c}=wt(void 0),{data:u}=fn({}),{data:d}=Et(void 0),{nodes:f}=q(),p=Or(),m=n(()=>br(f),[f]),h=n(()=>He(d),[d]),g=n(()=>f.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[f]),_=n(()=>vr(gr((a??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),s??[],c??[]),u??[]),[a,s,c,u]),[v,y]=o(()=>new Set),b=n(()=>_.filter(e=>Lr(Ir({hasPipelineAssignment:e.pipeline.active,hasFreshMetrics:p.has(e.deviceId)}),v)),[_,p,v]),x=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=()=>Br(r),C=ln({onSuccess:S}),w=Ge({onSuccess:S}),T=C.isPending||w.isPending,E=[{key:`camera`,header:t(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:n=>e(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[i(wn,{to:`/devices/${String(n.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:n.deviceName,children:n.deviceName}),n.disabled&&i(K,{variant:`default`,children:t(`common.off`)})]})},{key:`placement`,header:t(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>i(Nr,{deviceId:e.deviceId,state:e.pipeline,onlineNodes:g,nameOf:m,pending:T,onChange:t=>t===`auto`?w.mutate({deviceId:e.deviceId}):C.mutate({deviceId:e.deviceId,agentNodeId:t})})},{key:`roles`,header:t(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>i(wr,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:t(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>i(Pr,{state:e.pipeline,nameOf:m})},{key:`status`,header:t(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(Tr,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>i(Fr,{deviceId:e.deviceId,deviceName:e.deviceName})}],D=a===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return e(`div`,{className:`flex flex-col gap-2`,children:[i(`nav`,{"aria-label":t(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:i(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:Rr.map(e=>{let t=v.has(e.value);return i(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:Ye(re,t?ne:O),onClick:()=>x(e.value),children:e.label},e.value)})})}),i(Fe,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:Vt,emptyMessage:D})]})}s();function Hr({nodeId:e}){let{t}=X(),r=l();nn([`pipelineOrchestrator`,`getCameraStatuses`],zr);let{data:a}=fn({}),{data:o}=Et(void 0),{data:s}=Ue({isCamera:!0,projection:`slim`}),{nodes:c}=q(),u=Or(),d=n(()=>br(c),[c]),f=n(()=>He(o),[o]),p=n(()=>yr(e,a??[],xr((s??[]).map(e=>({id:e.id,name:e.name})))),[e,a,s]),m=c.filter(t=>t.isOnline&&t.id!==e),h=()=>Br(r),g=ln({onSuccess:h}),_=Ge({onSuccess:h}),v=jt({onSuccess:h}),y=pt({onSuccess:h}),b=e=>[...e.detection.active?m.map(n=>({id:`detect-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveDetectionTo`,`Move detection to {{name}}`,{name:n.name}),onClick:()=>g.mutate({deviceId:e.deviceId,agentNodeId:n.id})})):[],...e.audio.active?m.map(n=>({id:`audio-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveAudioTo`,`Move audio to {{name}}`,{name:n.name}),onClick:()=>v.mutate({deviceId:e.deviceId,nodeId:n.id})})):[],{id:`unpin-detect`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinDetection`,`Unpin detection`),hidden:!(e.detection.active&&e.detection.pinned),separatorBefore:!0,onClick:()=>_.mutate({deviceId:e.deviceId})},{id:`unpin-audio`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinAudio`,`Unpin audio`),hidden:!(e.audio.active&&e.audio.pinned),onClick:()=>y.mutate({deviceId:e.deviceId})}];return i(Fe,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>i(wn,{to:`/devices/${String(e.deviceId)}`,className:`block w-44 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName})},{key:`roles`,header:t(`pipeline.nodeCameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:t=>i(wr,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:d,colorByNodeId:f,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>u.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(Tr,{snap:u.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>i(_n,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:Vt,emptyMessage:a===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Ur({nodeId:t,refreshToken:n}){let{t:r}=X(),{nodes:a}=q(),o=a.find(e=>e.id===t)?.name??t;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(pr,{refreshToken:n,nodeId:t}),e(`div`,{className:`space-y-2`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`pipeline.nodeCamerasTab.camerasOn`,{node:o})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`pipeline.nodeCamerasTab.theRolesEachCameraRuns`,`The roles each camera runs here right now. Move a role or unpin it from the row menu; pins for every camera are on Cluster → Assignments.`)})]}),i(Hr,{nodeId:t})]})]})}s();function Wr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return Y.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function Gr({nodeId:t,refreshToken:r}){let{t:a}=X(),o=l(),s=U(),c=ht({onSettled:()=>{o.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:u}=yt({nodeId:t}),d=Zt(`pipeline.engine-metrics-snapshot`,e=>e.nodeId===t)?.engines??u??null,f=d===null;nn([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=mt({nodeId:t}),{values:m}=sn(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,e=>e.nodeId===t),h=n(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),g=e=>{let n=p??[];if(n.length===0){c.mutate({nodeId:t,engine:e,force:!1});return}(async()=>{await s({title:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(n.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&c.mutate({nodeId:t,engine:e,force:!0})})()};return e(`div`,{className:`space-y-6`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:a(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`pipeline.nodeEnginesTab.summary`,{engines:(d??[]).length,cameras:(p??[]).length,active:h})})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[640px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.kind`,`Kind`)}),i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.nodeEnginesTab.models`,`Models`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.inUse`,`In use`)}),i(`th`,{className:`w-20`})]})}),e(`tbody`,{children:[f&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`common.loading`,`Loading…`)})}),!f&&(d??[]).map(t=>{let n=t.kind===`device-pool`;return e(`tr`,{className:`border-t border-border ${n?`bg-primary/[0.05]`:``}`,children:[i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[i(n?Me:F,{className:`h-3 w-3`}),a(n?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[i(P,{className:`h-3 w-3`}),t.engine.runtime,`/`,t.engine.backend,t.engine.device?`/${t.engine.device}`:``,t.engine.format?` · ${t.engine.format}`:``]})}),i(`td`,{className:`px-3 py-2`,children:t.modelsLoaded.length===0?i(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.modelsLoaded.map(e=>i(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),i(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:t.poolPid??`—`}),i(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:t.idleMs!==null&&t.idleTtlMs!==null?i(`span`,{className:`text-foreground-subtle`,children:Wr(t.idleMs,t.idleTtlMs)}):i(`span`,{className:`text-foreground-subtle/50`,children:a(`common.never`)})}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),i(`td`,{className:`px-3 py-2 text-right`,children:n?i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.auto`)}):e(J,{variant:`ghost`,size:`sm`,disabled:c.isPending,onClick:()=>g(t.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[i(y,{className:`h-3.5 w-3.5`}),a(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},t.engineKey)}),!f&&(d??[]).length===0&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),i(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:i(Tn,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:i(`strong`,{className:`text-foreground`})}})}),c.isError&&i(et,{message:a(`pipeline.nodeEnginesTab.killFailed`,{message:c.error instanceof Error?c.error.message:a(`common.unknownError`)})})]})}var Kr=`pipeline-runner`,qr=200;function Jr({nodeId:t}){let{t:n}=X();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeLogsTab.description`,{node:t})})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(kt,{agentId:t,addonId:Kr,limit:qr,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}s();function Yr({nodeId:t,title:r}){let a=N(),{t:o}=X(),{data:s}=En(),{data:c}=Pt(void 0),l=n(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),u=n(()=>{if(!t)return null;let e=new Set;for(let n of c??[])n.agentNodeId===t&&e.add(n.deviceId);return e},[t,c]),d=Or(t),f=n(()=>{let e=[];for(let t of d.values())u&&!u.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[d,u]);return f.length===0?e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[i(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:f.length})]}),i(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(t=>{let n=l.get(t.deviceId)??`#${t.deviceId}`,r=Ft(t.metrics.phase,a);return e(`div`,{title:o(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:n,label:r.label,value3:t.metrics.actualFps.toFixed(1),value4:t.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:t.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[i(Rt,{phase:t.metrics.phase,className:`h-2.5 w-2.5`}),i(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:n}),i(`span`,{className:`font-mono tabular-nums`,children:t.metrics.actualFps.toFixed(1)}),i(`span`,{className:`opacity-60`,children:o(`common.fpsWord`)})]},t.deviceId)})})]})}function Xr(e,t,n,r){let i=t===void 0?void 0:e.find(e=>e.key===t)?.steps?.[n]?.settings,a={...r?.[n],...i};return Object.keys(a).length>0?a:void 0}function Zr(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}var Qr=`pipeline-analytics`,$r=`face-gallery`,ei=`pipeline-orchestrator`,ti=`pipeline-runner`,ni=`audio-analyzer`;function ri(e){return[...le.filter(t=>t.stepId===e).map(e=>fe(e.stepId)),...ue.filter(t=>t.stepId===e).map(e=>oe(e.stepId,e.key))]}var ii=`faces`,ai=`semantic-search`,oi=`load-balancer`,si=`load`,ci=[{id:ii,get title(){return Y.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:ei,fieldKeys:ri(`face-embedding`)},{addonId:Qr,capability:$r}]},{id:ai,get title(){return Y.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:ei,fieldKeys:ri(`clip-embedding`)}]},{id:xe,get title(){return Y.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:ei,sectionIds:[xe]}]},{id:ve,get title(){return Y.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:ei,sectionIds:[ve]}]},{id:`runner-defaults`,get title(){return Y.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:ti,fieldScope:`cluster`},{addonId:ni,fieldScope:`cluster`}]},{id:oi,get title(){return Y.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:ei,sectionIds:[si]}]},{id:`failover`,get title(){return Y.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return Y.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:ei,sectionIds:[`failover`]}]}],li={"cluster-step-models":ii};function ui(e){return e===`clip-embedding`?ai:ii}var di=`ctab`,fi=`section`;function pi(e,t){let n=new URLSearchParams({view:`nodes`,node:Yo,[di]:e});return t!==void 0&&n.set(fi,t),`/system/pipeline?${n.toString()}`}function mi(e){return pi(`settings`,ui(e))}function hi(){return pi(`load-balancing`)}var gi=`pipeline-orchestrator`;function _i(e){return le.find(t=>t.stepId===e)??null}function vi({step:t,engineFormat:n,runnableModelIds:r}){let{t:a}=X(),{data:o}=Ht({addonId:gi}),s=pe(o??null)[t.stepId]??t.defaultModelId,c=t.options.find(e=>e.id===s)?.label??s,l=r.length>0&&!r.includes(s);return e(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:c}),i(`span`,{title:a(`pipeline.clusterStepModel.oneValueForTheWhole`,`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`),className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:a(`pipeline.clusterStepModel.clusterWide`)}),i(wn,{to:mi(t.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:a(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),e(`p`,{className:W,children:[a(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,a(`pipeline.clusterStepModel.indexNote`,{index:t.indexName})]}),l&&i(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:i(Tn,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:n,model:s,index:t.indexName},components:{b:i(`b`,{})}})})]})}var yi=`pipeline-orchestrator`;function bi({addonId:t,highlightLabel:n}){let{t:r}=X(),a=Se(t),{data:o}=Ht({addonId:yi});if(a.length===0)return null;let s=ce(o??null)[t]??{};return e(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`h3`,{className:T,children:r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),i(wn,{to:mi(t),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),a.map(t=>e(`div`,{className:`${f} rounded px-2 ${n===t.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[i(`span`,{className:I,children:t.label}),i(`span`,{className:b,children:i(`span`,{className:`font-mono text-xs text-foreground`,children:String(s[t.key]??t.default)})})]},t.key)),i(`p`,{className:W,children:r(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function xi({rows:t,hint:n}){let{t:r}=X();return e(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(t=>e(`li`,{className:`${w} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[i(`span`,{className:t.href===void 0?`min-w-0 flex-1 truncate text-foreground-muted`:`basis-full text-foreground-muted`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:t.modelId??`—`}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:t.sourceLabel}),t.href!==void 0&&i(wn,{to:t.href,className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.effectiveModelSummary.changeOnAccelerator`)})]},t.id))}),i(`p`,{className:W,children:n??r(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}s();function Si(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:At(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Ci({tree:a,searchRows:s,accelerators:c,cellState:l,stepBadge:u,disabledCount:d,showDisabled:f,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=X(),x=U(),S=We(),{selection:C,open:w,close:T}=Ln(n(()=>On(a).map(e=>e.node.addonId),[a]),n(()=>c.map(e=>e.id),[c])),[E,D]=o(``),[O,k]=o(null),[A,j]=o(null),N=t(null),P=t(null),F=t(null);tn(F);let I=t(null),L=n(()=>Xt(s,E),[s,E]),R=n(()=>E.trim()===``?a:Bn(a,new Set(L.map(e=>e.addonId))),[a,L,E]),ee=e=>L.find(t=>t.addonId===e)?.matchedField??null,z=n(()=>c.map(Si),[c]),B=e=>c.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),V=c.find(e=>e.id===C.acceleratorId)??null,H=C.stepId!==null,te=r(async e=>{if(m){if(!await x({title:b(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:b(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:b(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[x,m,h,b]),ne=()=>{requestAnimationFrame(()=>I.current?.focus())},re=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&ne();return}let r=()=>{k(ee(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&ne()};e===C.stepId?r():te(r)},ie=()=>{let e=C.stepId;te(()=>{if(T(),e!==null){let t=V===null?null:Ie({agentNodeId:V.nodeId,deviceKey:V.deviceKey});requestAnimationFrame(()=>N.current?.focusCell(e,t))}})},ae=e=>{if(e.key===`Enter`){let t=L[0];if(t===void 0)return;e.preventDefault(),re(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},oe=S?i(Tt,{onClick:ie}):i(xn,{icon:M,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:ie});return e(`div`,{ref:P,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),F.current?.focus()),e.key===`Escape`&&t&&H&&(e.preventDefault(),ie())},children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),i(`input`,{ref:F,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown:ae,placeholder:b(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":b(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),d>0&&e(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(bt,{checked:f,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:d})]}),_]}),C.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:b(`stepInspector.stepMatrixFrame.staleStep`,{id:C.staleStepId})}),R.length===0?i(`p`,{className:`${W} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:E})}):i(Ut,{ref:N,tree:R,agents:z,label:v,getCellState:(e,t)=>{let n=B(t);return n===void 0?{kind:`na`}:l(e,n)},onCellClick:(e,t,n)=>re(e,B(t),n),onStepClick:(e,t)=>re(e,void 0,t),...u===void 0?{}:{stepBadge:u},selectedCell:H&&C.stepId!==null&&V!==null?{addonId:C.stepId,agentNodeId:V.nodeId,deviceKey:V.deviceKey}:null,fallbackNodeId:A,onFallbackNodeChange:j,reserveRightPx:H&&!S?432:0}),i(cn,{open:H,anchor:P,onClose:ie,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:V,matchedField:O,closeButton:oe,onEscape:ie,headingRef:e=>{I.current=e}})})]})}s();function wi(e){a(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}s();function Ti(e,t,n){return e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=t.accelerator?.deviceKey===e.key?{...Object.fromEntries(Object.entries(i.settings??{}).filter(([e])=>!n(e))),...t.accelerator.settings}:i.settings,c=s!==void 0&&Object.keys(s).length>0?s:void 0,l=a===void 0?i.modelId:a??void 0,u=o===void 0?i.jumpDeviceKey:o||void 0,d={...l===void 0?{}:{modelId:l},...c===void 0?{}:{settings:c},...u===void 0?{}:{jumpDeviceKey:u}};return Object.keys(d).length>0?r[t.stepId]=d:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}})}function Ei(e,t){return t===void 0?0:[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!_e(e[n],t[n])).length}function Di(e,t,n,r){if(t===null)return 0;let i=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,a=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,o=Ei(n,t.nodeSettings),s=t.accelerator===void 0?0:Ei(r(t.accelerator.deviceKey),t.accelerator.settings);return i+a+o+s}function Oi({nodeId:t,nodeName:r,toolbar:a}){let{t:s}=X(),c=l(),u=Kt({nodeId:t},{refetchOnMount:`always`}),f=_t({nodeId:t},{refetchOnMount:`always`}),p=zt({agentNodeId:t},{refetchOnMount:`always`}),m=p.data?.stepSettings,h=pe(Ht({addonId:`pipeline-orchestrator`}).data??null),g=u.data?.devices??[],_=f.data??null,[v,y]=o(null),[b,x]=o(null),[S,C]=o(null),w=Be({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),E=Ze({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})}}),[D,O]=o(!1),k=n(()=>_?dn(_):[],[_]),A=n(()=>On(k),[k]),[j,M]=o(!1),N=n(()=>Vn(t,r,g,j),[t,r,g,j]),P=n(()=>Vn(t,r,g),[t,r,g]),F=P.length>=2,I=(e,t)=>Xr(g,t?.deviceKey,e,m)??{},L=e=>m?.[e]??{},R=(e,t)=>g.find(e=>e.key===t)?.steps?.[e]?.settings??{},ee=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return P.find(e=>e.deviceKey===r);if(!In(e,t))return P.filter(n=>n.id!==t.id&&In(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},z=(e,t)=>{let n=Fn(_,e),r=_i(e),i=An(_,t),a=I(e,t),o=ee(n,t);return Rn({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?Mn(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...zn(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:h[e]??r.defaultModelId}:{},...o?{jumpTo:Nt(o.device)}:{}})},B=A.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:jn(Fn(_,e.addonId))}));if(u.isLoading||f.isLoading||p.isLoading)return i(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(_===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let V=e(`span`,{className:W,children:[s(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,i(`span`,{className:`text-foreground`,children:P.length>0?P.map(e=>Nt(e.device)).join(` · `):s(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),g.some(e=>!e.enabled)&&e(d,{children:[` `,s(`stepInspector.nodeStepInspector.off`,`— off:`),` `,g.filter(e=>!e.enabled).map(Nt).join(`, `)]}),` `,`·`,` `,i(wn,{to:hi(),className:`text-primary hover:underline`,children:s(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return i(Ci,{tree:k,searchRows:B,accelerators:N,cellState:z,disabledCount:g.filter(e=>!e.enabled).length,showDisabled:j,onShowDisabledChange:M,dirty:v!==null&&Di(g,v,L(v.stepId),e=>R(v.stepId,e))>0,onDiscard:()=>y(null),summary:V,...a===void 0?{}:{toolbar:a},label:s(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:a,matchedField:o,closeButton:c,onEscape:l,headingRef:u})=>{let f=Fn(_,n);if(f===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=v?.stepId===n?v:null,m=a??P[0]??N[0],h=p?.nodeSettings??L(n),k=a===null?{}:p?.accelerator?.deviceKey===a.deviceKey?p.accelerator.settings:R(n,a.deviceKey),A={...h,...k},j=Di(g,p,L(n),e=>R(n,e)),M=e=>{C(null),y(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},z=_i(n),B=un(f),{nodeFields:V,acceleratorFields:H}=Hn(B),U=new Set(H.flatMap(e=>`key`in e?[e.key,`${e.key}ModelId`]:[])),te=m===void 0?void 0:An(_,m),ne=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},re=m===void 0?void 0:Mn(f,m,{nodePin:ne(m)}).modelId,ie=t=>{let r=ne(t),o=Mn(f,t,{nodePin:r}),c=An(_,t),l=zn(n,a?.id===t.id?A:I(n,t),c),u=p?.jumps[t.deviceKey],m=ee(f,t,u),h=In(f,t)?l&&c?i(Pe,{rootModel:c,stepModelId:o.modelId}):void 0:e(d,{children:[s(`stepInspector.nodeStepInspector.noBuild`,{format:t.device.format}),` `,m?s(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:m.shortLabel}):s(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=F?e(`label`,{className:`block space-y-1`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:s(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),i($e,{"aria-label":s(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:u??t.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:s(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...P.filter(e=>e.id!==t.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:e=>M({jumps:{...p?.jumps,[t.deviceKey]:e.target.value}})}),i(`span`,{className:W,children:s(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:t.label,format:t.device.format,modelId:o.modelId,source:o.source===`node`?`node`:`default`,sourceLabel:o.source===`node`?`node pin`:`hardware default`,models:Gt(f.models??[],t.device.format),defaultModelId:f.defaultModelIdByFormat?.[t.device.format]??f.defaultModelId,expanded:b===t.id,onToggle:()=>x(e=>e===t.id?null:t.id),onChangeModel:e=>M({models:{...p?.models,[t.deviceKey]:e}}),...r===void 0?{}:{onReset:()=>M({models:{...p?.models,[t.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...h===void 0?{}:{note:h},...g===void 0?{}:{extra:g},changed:p?.models[t.deviceKey]!==void 0||u!==void 0}},ae=async()=>{if(p!==null){O(!0);try{(Object.keys(p.models).length>0||Object.keys(p.jumps).length>0||p.accelerator!==void 0)&&await w.mutateAsync({agentNodeId:t,inferenceDevices:Zr(Ti(g,p,e=>U.has(e)))}),p.nodeSettings!==void 0&&Ei(L(n),p.nodeSettings)>0&&await E.mutateAsync({agentNodeId:t,addonId:n,settings:Object.keys(p.nodeSettings).length>0?{...p.nodeSettings}:null}),y(null),C({kind:`saved`})}catch(e){C({kind:`error`,error:e instanceof Error?e.message:String(e)})}finally{O(!1)}}};return i(Bt,{ref:u,title:a===null?`${f.name} · ${r}`:`${f.name} · ${a.label}`,subtitle:a===null?s(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:f.slot,nodeName:r}):s(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:f.slot,format:a.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:j,saving:D,status:S?.kind??null,...S?.error===void 0?{}:{error:S.error},onSave:()=>void ae(),onDiscard:()=>y(null)},children:e(`div`,{className:`space-y-3`,children:[e(`section`,{className:`space-y-2`,"aria-label":s(`stepInspector.nodeStepInspector.model`,`Model`),children:[i(`h3`,{className:T,children:s(`stepInspector.nodeStepInspector.model`,`Model`)}),z!==null&&m!==void 0?i(vi,{step:z,engineFormat:m.device.format,runnableModelIds:Gt(f.models??[],m.device.format).map(e=>e.id)}):N.length===0?i(`p`,{className:W,children:i(Tn,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:i(wn,{to:hi(),className:`text-primary hover:underline`})}})}):a===null?i(xi,{rows:N.map(e=>{let t=Mn(f,e,{nodePin:ne(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):i(on,{...ie(a)},a.id)]}),(B.length>0||te!==void 0)&&z===null&&e(`section`,{"aria-label":s(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:s(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:r})}),(V.length>0||te!==void 0)&&i(ki,{addon:f,fields:V,settings:h,layerLabel:s(`stepInspector.nodeStepInspector.nodeLayer`,`Node`),modelId:Mt(f,re,A,te),root:te,highlight:o,onChange:e=>M({nodeSettings:e})}),H.length>0&&(a===null?i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-hint`,children:s(`stepInspector.nodeStepInspector.thresholdsPerAccelerator`,`Confidence thresholds belong to the model, so they are set per accelerator: open that accelerator's cell.`)}):e(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-scope`,children:s(`stepInspector.nodeStepInspector.acceleratorSettings`,{accelerator:a.label})}),i(ki,{addon:f,fields:H,settings:k,layerLabel:s(`stepInspector.nodeStepInspector.acceleratorLayer`,`This accelerator`),modelId:Mt(f,re,A,te),root:void 0,highlight:o,onChange:e=>M({accelerator:{deviceKey:a.deviceKey,settings:e}})})]}))]}),i(bi,{addonId:n,highlightLabel:o})]})})}})}function ki({addon:e,fields:t,settings:n,layerLabel:r,modelId:a,root:o,highlight:s,onChange:c}){let l=t.find(e=>`label`in e&&e.label===s)?.key??null;return wi(l===null?null:an(l)),i(Yt,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:r},modelId:a,...o===void 0?{}:{rootModel:o},highlightKey:l,onChangeLayer:c})}s();function Ai({nodeId:t,refreshToken:n}){let{t:r}=X(),a=U(),[s,c]=o(null),{nodes:l}=q(),u=l.find(e=>e.id===t)?.name??t,f=hn({onSuccess:e=>{c(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await a({title:r(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:r(`pipeline.nodePipelineTab.thisClearsEveryPerDevice`,`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:r(`common.reset`,`Reset`),variant:`danger`})&&(c(null),f.mutate({agentNodeId:t}))};return e(`div`,{className:`space-y-2`,children:[i(Yr,{nodeId:t}),i(Oi,{nodeId:t,nodeName:u,toolbar:e(d,{children:[s&&i(`span`,{className:`text-[11px] text-success`,children:s}),f.isError&&i(`span`,{className:`text-[11px] text-danger`,children:f.error instanceof Error?f.error.message:r(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),i(J,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:f.isPending,title:r(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:f.isPending?r(`pipeline.nodePipelineTab.resetting`,`Resetting…`):r(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var ji=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],Mi=`decoder-nodeav`,Ni=`ntab`,Pi={decoder:`engine`},Fi={engine:`Engine & decoder`},Ii=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function Li({nodeId:t,refreshToken:n}){let{t:r}=X(),[a,o]=Cn(),{nodes:s}=q(),c=s.find(e=>e.id===t)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??Mi,l=[...ji,c],u=a.get(Ni),d={assignments:{id:`assignments`,label:r(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:i(Ur,{nodeId:t,refreshToken:n})},tree:{id:`tree`,label:r(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:i(Ai,{nodeId:t,refreshToken:n})},engines:{id:`engines`,label:r(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:i(Gr,{nodeId:t,refreshToken:n})},logs:{id:`logs`,label:r(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:i(Jr,{nodeId:t})}},f=fr.map(e=>d[e]);return e(`div`,{className:`flex flex-col h-full`,children:[i(dr,{nodeId:t,refreshToken:n}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:i(Gn,{nodeId:t,addonIds:l,level:`global`,fieldScope:`perNode`,emptyMessage:Ii,tabAliases:Pi,tabLabelOverrides:Fi,extraTabs:f,activeTab:u===null?null:Pi[u]??u,onActiveTabChange:e=>o(t=>{let n=new URLSearchParams(t);n.set(Ni,e);for(let e of kn)n.delete(e);return n},{replace:!0})})})]})}function Ri(){let{t}=X();return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAssignmentsTab.pinACameraToA`,`Pin a camera to a node, or to one accelerator of its node; Auto lets each session pick. Decode always runs with detection. Load, shares and caps are on Load balancing.`)})]}),i(Vr,{})]})}function zi(e){return`${Math.round(e*100)}%`}function Bi(e){return Y.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var Vi={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},Hi={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,unknown:`Not measured`};function Ui(e){return e===null?`—`:Vi[e]??e}function Wi(e){return e===null?`—`:Hi[e]??e}function Gi(e){switch(e.kind){case`capacity`:return Y.t(`helpers.autoTuneViewModel.capacity`,{sessions:Bi(e.sessions),min:e.minSessions});case`tie-faster`:return Y.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:zi(e.recallDelta)});case`stepped-down`:return Y.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return Y.t(`helpers.autoTuneViewModel.noFitLightest`,{min:Bi(e.minSessions),sessions:Bi(e.sessions)});case`derived-latency`:return Y.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return Y.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return Y.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return Y.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return Y.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return Y.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return Y.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return Y.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return Y.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function Ki(e,t){switch(e.kind){case`custom-pin-kept`:return Y.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey});case`custom-registry-unreadable`:return Y.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function qi(e){return{modelChanges:e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),thresholdClears:e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0)}}function Ji(e){let t=qi(e);return t.modelChanges+t.thresholdClears===0}function Yi(e,t,n){let r=e.nodeChanges.find(e=>e.nodeId===t&&e.deviceKey===n)?.modelPins.find(e=>e.stepId===`object-detection`);return r===void 0?null:{before:r.before,after:r.after}}function Xi(e,t){return e?.kind===`node-benchmark`?Y.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):e?.kind===`estimated`?Y.t(`helpers.autoTuneViewModel.latencyEstimated`,{hardware:Wi(e.estimatedFrom)}):Y.t(`helpers.autoTuneViewModel.latencyTable`)}s();var Zi=[.3,.4,.5];function Qi(e){return Zi.some(t=>t===e)}var $i=[1,2,3,4,6,8];function ea({plan:t,node:n,nodeName:r}){let{t:a}=X();return e(`section`,{className:x,"data-testid":`auto-tune-node-${n.nodeId}`,children:[e(`header`,{className:`${L} flex flex-wrap items-center gap-2`,children:[i(F,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${T} min-w-0 flex-1`,children:r(n.nodeId)}),e(`span`,{className:`text-[11px] text-foreground-subtle`,children:[Wi(n.hardwareClass),n.cpuModel===null?``:` · ${n.cpuModel}`]}),n.skipped?i(K,{variant:`warning`,children:a(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):n.acceleratorModelId!==null&&i(K,{variant:`info`,children:n.acceleratorModelId})]}),n.reasons.length>0&&i(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>i(`li`,{children:Gi(e)},t))}),i(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs`,children:[i(`thead`,{children:e(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.device`,`Device`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),i(`tbody`,{children:n.devices.map(r=>{let o=Yi(t,n.nodeId,r.deviceKey);return e(`tr`,{className:`border-t border-border align-top`,children:[e(`td`,{className:`px-3 py-1.5`,children:[i(`div`,{className:`font-mono text-foreground`,children:r.deviceKey}),i(`div`,{className:`text-[11px] text-foreground-subtle`,children:Ui(r.accelerator)})]}),e(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[r.chosen===null?`—`:a(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:r.chosen.capacitySessions,fps:t.cameraFps}),r.chosen!==null&&e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[a(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:r.chosen.fps,percent:Math.round(t.headroom*100)}),i(`div`,{children:Xi(r.chosen.source)})]})]}),i(`td`,{className:`px-3 py-1.5`,children:r.chosen===null?i(`span`,{className:`text-foreground-subtle`,children:a(`common.unchanged`)}):o!==null&&o.before!==o.after?e(`span`,{children:[i(`span`,{className:`text-foreground-subtle`,children:o.before??a(`common.defaultWord`)}),` → `,i(`span`,{className:`font-medium text-foreground`,children:o.after})]}):i(`span`,{className:`text-foreground`,children:r.chosen.modelId})}),i(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:r.reasons.map((e,t)=>i(`div`,{children:Gi(e)},t))})]},r.deviceKey)})})]})})]})}function ta({plan:t,nodeName:n}){let{t:r}=X();return i(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:e(`div`,{children:[i(`div`,{className:T,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),t.nodeChanges.length===0?i(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:t.nodeChanges.flatMap(t=>[...t.modelPins.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`— `,i.stepId,`: `,i.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,i.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/pin`)),...t.thresholds.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:i.stepId,keys:i.keys.join(`, `)})]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/thr`))])})]})})}function na({result:t}){let{t:n}=X();return t.kind===`refused`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):t.kind===`stale`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):e(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[t.kind===`aborted`&&i(`li`,{className:`text-danger`,children:n(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),t.phases.map(t=>e(`li`,{className:t.ok?`text-foreground-muted`:`text-danger`,children:[t.ok?`✓`:`✗`,` `,t.phase,`: `,t.detail]},t.phase))]})}function ra(){let{t}=X(),r=l(),[a,s]=o(.4),[c,u]=o(2),[d,f]=o(!1),[p,m]=o(!1),[h,g]=o(null),{nodes:_}=q(),v=n(()=>br(_),[_]),y=vn({headroom:a,minSessionsPerDevice:c},{enabled:d,refetchOnWindowFocus:!1}),b=at({onSuccess:e=>{g(e),m(!1),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),e.kind===`applied`&&y.refetch()}}),S=h?.kind===`stale`?h.plan:y.data,C=S===void 0?null:qi(S);return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[e(`section`,{className:x,children:[e(`header`,{className:`${L} flex flex-wrap items-center gap-2`,children:[i(V,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${T} min-w-0 flex-1`,children:t(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),e(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[i(`p`,{children:t(`pipeline.clusterAutoTuneTab.picksForEveryAcceleratorThe`,`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models on the accelerators and clears their threshold overrides, so each model runs its own default thresholds. Cameras carry no model or threshold of their own. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),i($e,{"aria-label":t(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(a),options:Zi.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(e*100)})})),onChange:e=>{let t=Number(e.target.value);Qi(t)&&s(t)}})]}),e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),i($e,{"aria-label":t(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(c),options:$i.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:e})})),onChange:e=>{let t=Number(e.target.value);$i.some(e=>e===t)&&u(t)}})]}),i(J,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),f(!0),d&&y.refetch()},children:y.isFetching?t(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):S===void 0?t(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):t(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),S!==void 0&&i(J,{size:`sm`,disabled:Ji(S),onClick:()=>m(!0),children:t(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),y.error!==null&&i(`div`,{className:`text-danger`,children:y.error.message}),h!==null&&i(na,{result:h}),C!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:C.modelChanges,thresholdClears:C.thresholdClears})})]})]}),S?.warnings.map((e,t)=>i(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:Ki(e,v)},t)),S?.nodes.map(e=>i(ea,{plan:S,node:e,nodeName:v},e.nodeId)),S!==void 0&&i(bn,{open:p,onOpenChange:m,children:e(yn,{width:`lg`,scroll:`body`,children:[e(gn,{children:[i(ft,{children:t(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),i(lt,{children:t(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),i(Dt,{children:i(ta,{plan:S,nodeName:v})}),e(ze,{children:[i(J,{variant:`ghost`,onClick:()=>m(!1),children:t(`common.cancel`,`Cancel`)}),i(J,{variant:`danger`,disabled:b.isPending,onClick:()=>b.mutate({planHash:S.planHash,headroom:a,minSessionsPerDevice:c}),children:b.isPending?t(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):t(`common.apply`,`Apply`)})]})]})})]})}var ia={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`};function aa(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function oa(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function sa(e,t,n){let r=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let i=t.get(e.key)??(n?0:null),a=e.weight>0?e.weight:1;return{key:e.key,label:At(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?aa(a,r):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function ca(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.nodes.map(r=>{let i=t.get(r.id),a=sa(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),oa(i)),o=r.isOnline&&r.detectEnabled,s=r.weight>0?r.weight:1,c=i?.load.attachedCameras??null;return{nodeId:r.id,name:r.name,isOnline:r.isOnline,detectEnabled:r.detectEnabled,reported:i!==void 0,attachedCameras:c,activeCameras:i?.load.activeCameras??null,maxCameras:r.maxCameras,capacityPct:c!==null&&r.maxCameras!==null&&r.maxCameras>0?aa(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?aa(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}s();var la=2e4,ua=3e5;function da({stats:e,targetWeights:t,showAccelerators:r=!0}){let{t:a}=X(),{nodes:o}=q(),s=j().trpcClient,l=rn(void 0,{placeholderData:u,staleTime:la,refetchInterval:la,refetchOnWindowFocus:!0}),d=Et(void 0,{staleTime:ua}),f=n(()=>o.map(e=>e.id),[o]),p=c({queries:f.map(e=>({queryKey:Ne(Wt.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>s.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:ua,refetchOnWindowFocus:!1,placeholderData:u}))}),h=n(()=>{let e={};return f.forEach((t,n)=>{let r=p[n]?.data;r&&(e[t]=r.devices)}),e},[f,p.map(e=>e.dataUpdatedAt).join(`|`)]),g=n(()=>{let e=new Map;for(let t of d.data??[])e.set(t.nodeId,t.settings);return e},[d.data]),_=n(()=>o.map(e=>{let n=g.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:cr(n).pipeline,weight:t?.[e.id]??Jn(n,`detectWeight`)??1,maxCameras:Jn(n,`maxCameras`)}}),[o,g,t]),v=l.data??[],y=n(()=>ca({nodes:_,loads:v,devicesByNode:h}),[_,v,h]),b=y.reduce((e,t)=>e+(t.attachedCameras??0),0),x=y.reduce((e,t)=>e+(t.activeCameras??0),0),S=l.dataUpdatedAt>0?Date.now()-l.dataUpdatedAt:null,C=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return i(G,{headingId:`load-balancing-node-load`,title:a(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:ee,actions:i(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:a(`pipeline.nodeLoadOverview.summaryLine`,{active:x,attached:b,reading:l.data===void 0?a(`pipeline.nodeLoadOverview.reading`,`reading…`):a(`pipeline.nodeLoadOverview.readingAge`,{age:S===null?`—`:`${Math.round(S/1e3)}s`})})}),children:i(`div`,{className:m,children:y.length===0?i(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):i(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:y.map(e=>i(fa,{row:e,placed:C.get(e.nodeId),showAccelerators:r},e.nodeId))})})})}function fa({row:t,placed:n,showAccelerators:r}){let{t:a}=X(),o=t.attachedCameras===null?`—`:`${t.activeCameras??0} / ${t.attachedCameras}${t.maxCameras===null?``:` of ${t.maxCameras}`}`;return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[i(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),i(`span`,{className:`truncate text-xs font-medium text-foreground`,title:t.nodeId,children:t.name}),!t.detectEnabled&&i(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!t.reported&&t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:a(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[i(ie,{className:`h-2.5 w-2.5`}),` `,a(`pipeline.nodeLoadOverview.noReading`)]}),!t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[i(C,{className:`h-2.5 w-2.5`}),` `,a(`common.offline`)]})]}),e(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[i(ha,{label:a(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:o,title:a(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),i(ha,{label:a(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:t.weightSharePct===null?`out of play`:`${t.weightSharePct}%`,title:a(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),i(ha,{label:a(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:n?.observedShare===null||n===void 0?`—`:`${Math.round(n.observedShare*100)}%`,title:a(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),i(ha,{label:a(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:n===void 0?`—`:`${n.peakSessions} · ${n.yieldsAway}`,title:a(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),i(ha,{label:a(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:t.score===null?`—`:`${t.score} · ${t.queueDepthTotal??0}`,title:a(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),t.capacityPct!==null&&i(ha,{label:a(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${t.capacityPct}%`,title:a(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),t.avgInferenceTimeMs!==null&&i(ha,{label:a(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(t.avgInferenceTimeMs)} ms`,title:a(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),t.decodeHwaccel!==null&&i(ha,{label:a(`pipeline.nodeLoadOverview.decode`,`Decode`),value:t.decodeHwaccel,title:a(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),r&&i(pa,{row:t})]})}function pa({row:t}){let{t:n}=X();return t.devices.length===0?i(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):e(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[e(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[i(_,{className:`h-2.5 w-2.5`}),n(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),t.eligibleDeviceCount===0&&i(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:n(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:n(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),i(`ul`,{className:`mt-1 space-y-0.5`,children:t.devices.map(e=>i(ma,{device:e},e.key))})]})}function ma({device:t}){let{t:n}=X(),r=t.exclusion;return e(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[i(F,{className:`h-2.5 w-2.5 shrink-0 ${r===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),i(`span`,{className:`shrink-0 font-medium ${r===null?`text-foreground`:`text-foreground-subtle`}`,title:`${t.key} · ${t.format}`,children:t.label}),r===null?e(d,{children:[i(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.sharePct`,{pct:t.weightSharePct})}),e(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:t.sessions===null?n(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,n(`common.sessionsCount`,{count:t.sessions??0}),t.maxSessions===null?``:`/${t.maxSessions}`]}),t.atCap&&i(`span`,{className:`shrink-0 text-amber-400`,title:n(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:n(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):i(`span`,{className:`truncate text-foreground-subtle/80`,title:n(ia[r]),children:n(`pipeline.nodeLoadOverview.excludedWith`,{reason:n(ia[r])})})]})}function ha({label:t,value:n,title:r}){return e(`div`,{className:`min-w-0`,title:r,children:[i(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:t}),i(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:n})]})}function ga(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function _a(e){let t={},n={};for(let r of e.nodes){if(r.share===null||r.share<=0)continue;t[r.nodeId]=r.share;let e=Object.fromEntries(r.devices.filter(e=>e.share>0).map(e=>[e.deviceKey,e.share]));Object.keys(e).length>0&&(n[r.nodeId]=e)}return{nodes:t,devices:n}}function va(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function ya(e){return e.reason===`disabled`?Y.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):Y.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function ba(e,t){if(t===void 0||t.source===`manual`||t.autoPending)return{nodes:e,readOnly:t!==void 0&&t.source!==`manual`};let n=new Map(t.nodes.map(e=>[e.nodeId,e.configuredPct]));return{nodes:e.map(e=>({...e,weight:Math.round(n.get(e.id)??e.weight)})),readOnly:!0}}function xa(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `),i=n.map(e=>t(e.nodeId)).join(`, `);return Y.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var Sa=[{value:`hardware`,get label(){return Y.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return Y.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return Y.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return Y.t(`helpers.loadBalancingViewModel.manualHint`)}}];function Ca(e){return e===`no-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?Y.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function wa(e,t){if(e.source!==`benchmark`)return null;let n=e.nodes.filter(e=>e.capacityFallback!==null);return n.length===0?null:n.map(e=>`${t(e.nodeId)}: ${Ca(e.capacityFallback)??``}`).join(` · `)}s();function Ta(e,t,n){return Math.min(Math.max(e,t),n)}function Ea(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function Da(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:Ta(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function Oa(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function ka({nodes:t,pending:n,onCommitWeights:r,weightLabel:s=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:f}=X(),[p,m]=o(()=>Ea(t)),[h,g]=o(new Set);a(()=>{m(Ea(t)),g(e=>new Set([...e].filter(e=>t.some(t=>t.id===e))))},[t.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let _=t.map(e=>e.id),v=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=(e,t)=>{m(n=>Da(n,e,t,h,_))},b=()=>{let e=Oa(p,_,h),n=t.filter(t=>(e[t.id]??0)!==t.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...h]);r(t.filter(e=>i.has(e.id)).map(t=>({nodeId:t.id,weight:e[t.id]??0})))};if(t.length===0)return i(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??f(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=t.length===1;return e(`div`,{className:`space-y-3`,children:[t.map(t=>{let r=p[t.id]??0,a=h.has(t.id);return e(`div`,{className:`flex items-center gap-3`,children:[i(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:t.name,children:t.name}),i(`input`,{"aria-label":f(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:s,name:t.name}),type:`range`,min:0,max:100,step:1,value:Math.round(r),disabled:u||n||a||x,onChange:e=>y(t.id,Number(e.target.value)),onPointerUp:()=>b(),onKeyUp:()=>b(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),e(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(r),`%`]}),!u&&i(`button`,{type:`button`,onClick:()=>v(t.id),disabled:n||x,"aria-pressed":a,title:a?f(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):f(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${a?`text-amber-400`:`text-foreground-subtle`}`,children:i(a?te:A,{className:`h-3.5 w-3.5`})})]},t.id)}),i(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??i(d,{children:f(`placementBoard.weightSliderStack.draggingOneSliderSplitsThe`,`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`)})})]})}function Aa(e){let t=e.steps?.[`object-detection`]?.modelId;return typeof t==`string`&&t.length>0?t:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null}function ja(e){if(e.presence===`absent`)return`absent`;if(e.presence===`unknown`)return`unknown`;switch(e.exclusion){case null:return`active`;case`disabled`:return`disabled`;case`unavailable`:return e.available?`backoff`:`unavailable`;case`cannot-host-camera-root`:return`root-incapable`;case`accelerator-preferred`:return`standby`}}function Ma(e,t,n){let r=new Map((t?.devices??[]).map(e=>[e.deviceKey,e])),i=new Map((n?.devices??[]).map(e=>[e.deviceKey,e.sessionsNow]));return e.map(e=>{let t=r.get(e.key),a=n===void 0?null:i.get(e.key)??0;return{device:e,state:ja(e),share:t===void 0?null:{configuredPct:t.configuredPct,effectivePct:t.effectivePct},sessionsNow:a,atCap:a!==null&&e.maxSessions!==null&&a>=e.maxSessions}})}var Na={active:`success`,disabled:`neutral`,absent:`danger`,unknown:`neutral`,unavailable:`warning`,backoff:`warning`,"root-incapable":`info`,standby:`neutral`};s();function Pa(e){let t=At(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:F,hue:`slate`}:r===`npu`?{label:t,Icon:P,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:Ee,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Ae,hue:`emerald`}:{label:t,Icon:F,hue:`slate`}}var Fa={active:[`placementBoard.nodeInferenceDevices.state.active`,`in use`],disabled:[`placementBoard.nodeInferenceDevices.state.disabled`,`switched off`],absent:[`placementBoard.nodeInferenceDevices.state.absent`,`absent`],unknown:[`placementBoard.nodeInferenceDevices.state.unknown`,`unknown`],unavailable:[`placementBoard.nodeInferenceDevices.state.unavailable`,`unavailable`],backoff:[`placementBoard.nodeInferenceDevices.state.backoff`,`pool down`],"root-incapable":[`placementBoard.nodeInferenceDevices.state.rootIncapable`,`no root model`],standby:[`placementBoard.nodeInferenceDevices.state.standby`,`fallback`]},Ia={active:[`placementBoard.nodeInferenceDevices.stateHint.active`,`A camera-root candidate: placement may start sessions on it.`],disabled:[`placementBoard.nodeInferenceDevices.stateHint.disabled`,`Switched off: it takes no sessions.`],absent:[`placementBoard.nodeInferenceDevices.stateHint.absent`,`The node no longer reports this device (unplugged, or moved to another node). Its settings are kept; it is never used. Forget it to delete them.`],unknown:[`placementBoard.nodeInferenceDevices.stateHint.unknown`,`The node's probe did not answer, so whether the device is there is not known.`],unavailable:[`placementBoard.nodeInferenceDevices.stateHint.unavailable`,`On the node, but the probe reports it unusable.`],backoff:[`placementBoard.nodeInferenceDevices.stateHint.backoff`,`Reported by the node, but its inference pool is down or backing off.`],"root-incapable":[`placementBoard.nodeInferenceDevices.stateHint.rootIncapable`,`Its format cannot run the camera root detector; it serves enrichment steps only.`],standby:[`placementBoard.nodeInferenceDevices.stateHint.standby`,`The CPU fallback: it takes no sessions while an accelerator is serving this node.`]};function La({nodeId:t,nodeName:r,isOnline:s,suggestedMaxSessions:c,shareSource:u,sharesAutomatic:f,share:p,placed:m}){let{t:_}=X(),v=l(),{data:b,isLoading:x}=Kt({nodeId:t},{refetchInterval:15e3}),S=()=>{v.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},w=Be({onSettled:S}),T=Jt({onSettled:S}),E=Wt.platformProbe.rescanAccelerators.useMutation({onSettled:S}),D=b?.devices??[],O=b?.reachable??s,[k,A]=o({});a(()=>{A(Object.fromEntries(D.map(e=>[e.key,Ra(e)])))},[D.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let j=n(()=>D.filter(e=>(k[e.key]?.enabled??e.enabled)&&e.available).length,[D,k]),[M,N]=o(null),P=M??!0,F=e=>{let n=D.map(t=>{let n=e[t.key]??Ra(t);return{key:t.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});w.mutate({agentNodeId:t,inferenceDevices:Zr(n)})},I=(e,t)=>{let n=k[e.key]??Ra(e),r={...k,[e.key]:{...n,...t}};A(r),F(r)},L=n(()=>Ma(D,p,m),[D,p,m]),R=n(()=>D.filter(e=>(k[e.key]?.enabled??e.enabled)&&e.available),[D,k]),ee=n(()=>R.map(e=>({id:e.key,name:Pa(e).label,weight:k[e.key]?.weight??e.weight})),[R,k]),z=e=>{let t={...k};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}A(t),F(t)},B=w.isPending||T.isPending,V=za(_,f?u:`manual`),H=[{key:`device`,header:_(`placementBoard.nodeInferenceDevices.colDevice`,`Device`),nowrap:!1,sortValue:e=>Pa(e.device).label,render:e=>i(Va,{row:e,steps:k[e.device.key]?.steps})},{key:`state`,header:_(`placementBoard.nodeInferenceDevices.colState`,`State`),sortValue:e=>e.state,render:e=>i(`span`,{title:_(Ia[e.state][0],Ia[e.state][1]),children:i(K,{variant:Na[e.state],size:`sm`,children:_(Fa[e.state][0],Fa[e.state][1])})})},{key:`share`,header:_(`placementBoard.nodeInferenceDevices.colShare`,`Share`),align:`right`,sortValue:e=>e.share?.effectivePct??null,render:e=>i(Ha,{row:e,sourceLabel:V})},{key:`sessions`,header:_(`placementBoard.nodeInferenceDevices.colSessions`,`Sessions`),align:`right`,sortValue:e=>e.sessionsNow,render:t=>e(`span`,{className:`tabular-nums text-xs text-foreground`,children:[t.sessionsNow??`—`,t.atCap&&i(K,{variant:`warning`,size:`sm`,className:`ml-1`,children:_(`placementBoard.nodeInferenceDevices.atCap`,`at cap`)})]})},{key:`cap`,header:_(`placementBoard.nodeInferenceDevices.colCap`,`Max sessions`),notSortableReason:_(`placementBoard.nodeInferenceDevices.capNotSortable`,`An editable field: sort by Sessions instead.`),render:t=>{let n=k[t.device.key]??Ra(t.device);if(!(n.enabled&&t.device.available))return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let r=Pa(t.device).label;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(ot,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10);I(t.device,{maxSessions:r!==null&&r>0?r:null})},disabled:B,"aria-label":_(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:r}),className:`w-16 text-right`}),i(Ua,{suggested:c?.[t.device.key]??null,current:n.maxSessions,pending:B,onApply:e=>I(t.device,{maxSessions:e})})]})}},{key:`enabled`,header:_(`placementBoard.nodeInferenceDevices.colEnabled`,`Enabled`),align:`right`,notSortableReason:_(`placementBoard.nodeInferenceDevices.enabledNotSortable`,`A switch: sort by State instead.`),render:e=>{let n=Pa(e.device).label;if(e.state===`absent`)return i(Re,{label:_(`placementBoard.nodeInferenceDevices.forget`,`Forget`),icon:y,size:`sm`,triggerVariant:`ghost`,disabled:B,title:_(`placementBoard.nodeInferenceDevices.forgetTitle`,`Forget {{label}} on {{node}}?`,{label:n,node:r}),description:_(`placementBoard.nodeInferenceDevices.forgetDescription`,`Its stored settings (switch, weight, cap, step models) are deleted. If the device comes back it starts from the defaults.`),action:()=>T.mutateAsync({agentNodeId:t,deviceKey:e.device.key})});let a=k[e.device.key]??Ra(e.device);return i(gt,{checked:a.enabled&&e.device.available,onCheckedChange:()=>I(e.device,{enabled:!a.enabled}),disabled:!e.device.available||B,"aria-label":_(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:n})})}}],U=w.error??T.error??E.error;return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[e(J,{variant:`ghost`,size:`sm`,onClick:()=>N(!P),className:`min-w-0 flex-1 justify-start`,"aria-expanded":P,children:[i(h,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${P?`rotate-90`:``}`}),i(`span`,{className:`truncate text-sm font-medium text-foreground`,children:r}),i(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-foreground-subtle`,children:O?e(d,{children:[i(Me,{className:`h-3.5 w-3.5`}),_(`pipeline.nodeInferenceDevices.accelerators`,{count:j})]}):e(d,{children:[i(C,{className:`h-3.5 w-3.5`}),` `,_(`common.unreachable`)]})})]}),e(J,{variant:`ghost`,size:`sm`,onClick:()=>E.mutate({nodeId:t}),disabled:E.isPending||!O,title:_(`placementBoard.nodeInferenceDevices.rescanTitle`,`Probe this node for accelerators now (a Coral plugged in or pulled out). The node also re-probes every minute.`),children:[i(g,{className:`h-3.5 w-3.5 ${E.isPending?`animate-spin`:``}`}),_(`placementBoard.nodeInferenceDevices.rescan`,`Rescan`)]})]}),P&&e(`div`,{className:`space-y-3 border-t border-border p-3`,children:[O?x&&D.length===0?i(`p`,{className:`text-center text-xs text-foreground-subtle`,children:_(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):i(Fe,{columns:H,rows:L,rowKey:e=>e.device.key,minWidthPx:640,bordered:!1,emptyMessage:_(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):i(Wa,{}),E.data!==void 0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:Ba(_,E.data.appeared,E.data.disappeared)}),O&&!f&&R.length>=2&&e(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[e(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[i(Oe,{className:`h-3.5 w-3.5`}),_(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),i(ka,{nodes:ee,pending:B,onCommitWeights:z,weightLabel:`Accelerator share`,footnote:_(`placementBoard.nodeInferenceDevices.dragToShiftTheShare`,`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`)})]}),U!=null&&e(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-xs text-danger`,children:[_(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,U.message]})]})]})}function Ra(e){return{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}}function za(e,t){switch(t){case`benchmark`:return e(`placementBoard.nodeInferenceDevices.sourceBenchmark`,`benchmark`);case`hardware`:return e(`placementBoard.nodeInferenceDevices.sourceHardware`,`hardware`);case`manual`:return e(`placementBoard.nodeInferenceDevices.sourceManual`,`manual`);case void 0:return null}}function Ba(e,t,n){return t.length===0&&n.length===0?e(`placementBoard.nodeInferenceDevices.rescanNoChange`,`Rescanned: no change.`):e(`placementBoard.nodeInferenceDevices.rescanChanged`,`Rescanned: appeared {{appeared}} · disappeared {{disappeared}}`,{appeared:t.length>0?t.join(`, `):`—`,disappeared:n.length>0?n.join(`, `):`—`})}function Va({row:t,steps:n}){let r=Pa(t.device),a=Aa({defaultModelId:t.device.defaultModelId,steps:n??t.device.steps??{}});return e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i(r.Icon,{className:`h-4 w-4 shrink-0 text-foreground-subtle`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:r.label}),i(K,{variant:`neutral`,size:`sm`,className:`font-mono`,children:t.device.format})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-xs text-foreground-subtle`,children:[i(`span`,{className:`font-mono`,children:t.device.key}),a!==null&&e(d,{children:[i(`span`,{"aria-hidden":!0,children:`·`}),i(`span`,{children:i(Tn,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:a},components:{mono:i(`span`,{className:`font-mono text-foreground-muted`})}})})]})]})]})]})}function Ha({row:t,sourceLabel:n}){let{t:r}=X();if(t.share===null)return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let{configuredPct:a,effectivePct:o}=t.share,s=Math.round(a)!==Math.round(o);return e(`div`,{className:`text-right`,children:[e(`div`,{className:`tabular-nums text-sm text-foreground`,children:[Math.round(o),`%`]}),e(`div`,{className:`text-xs text-foreground-subtle`,children:[s?r(`placementBoard.nodeInferenceDevices.shareConfigured`,`set {{pct}}%`,{pct:Math.round(a)}):null,s&&n!==null?` · `:null,n]})]})}function Ua({suggested:e,current:t,pending:n,onApply:r}){let{t:a}=X();return e===null||e<1||e===t?null:i(J,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:a(`placementBoard.nodeInferenceDevices.advisoryCapFromTheMeasured`,`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`),children:a(`pipeline.nodeInferenceDevices.use`,{value:e})})}function Wa(){let{t}=X();return e(`div`,{className:`flex flex-col items-center gap-2 px-4 py-6 text-center`,children:[i(C,{className:`h-6 w-6 text-foreground-subtle`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:t(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),i(`p`,{className:`max-w-sm text-xs text-foreground-subtle`,children:t(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}s();var Ga=3600*1e3,Ka=2e4,qa=.4;function Ja({refreshToken:t,onOpenAutoTune:r}){let{t:a}=X(),s=l(),{nodes:c}=q(),f=Et(void 0),p=Ue({isCamera:!0,projection:`slim`}),h=pn({windowMs:Ga},{refetchInterval:Ka,placeholderData:u}).data,g=$t(void 0,{refetchInterval:Ka,placeholderData:u}).data,_=()=>{Qn(s),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=Ke({onSuccess:_}),y=Sn({onSuccess:()=>{_(),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=nt({onSuccess:_}),x=ct(),[S,C]=o(!1),T=g?.source,E=T===`benchmark`?`benchmark`:`hardware`,O=Le({headroom:qa,source:E},{enabled:S,staleTime:1/0}),k=O.data,A=n(()=>{let e=new Map((f.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>cr(e.get(t.id)).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:Jn(n,`detectWeight`)??1,maxCameras:Jn(n,`maxCameras`)}})},[c,f.data]),j=e=>c.find(t=>t.id===e)?.name??e,M=xr((p.data??[]).map(e=>({id:e.id,name:e.name}))),N=k?va(k):void 0,I=ba(A,g),L=T!==`manual`,R=g!==void 0&&g.source!==`manual`&&!g.autoPending,ee=e=>g?.nodes.find(t=>t.nodeId===e),z=e=>h?.nodes.find(t=>t.nodeId===e),B=g?xa(g,j):null,H=g?wa(g,j):null,U=Sa.find(e=>e.value===T)?.hint;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(pr,{refreshToken:t}),i(da,{stats:h,showAccelerators:!1,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),i(G,{headingId:`load-balancing-node-shares`,title:a(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:Oe,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`div`,{role:`radiogroup`,"aria-label":a(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:Sa.map(e=>i(J,{role:`radio`,"aria-checked":T===e.value,variant:T===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{T!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),e(J,{variant:`outline`,size:`sm`,onClick:()=>{C(!0),S&&O.refetch()},disabled:O.isFetching,children:[i(D,{className:`h-3.5 w-3.5`}),O.isFetching?a(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):E===`benchmark`?a(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):a(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),e(J,{variant:`ghost`,size:`sm`,onClick:r,children:[i(V,{className:`h-3.5 w-3.5`}),a(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),e(J,{variant:`outline`,size:`sm`,onClick:()=>x.mutate(void 0),disabled:x.isPending,title:a(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[i(P,{className:`h-3.5 w-3.5`}),x.isPending?a(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):a(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:e(`div`,{className:`${m} space-y-3`,children:[U!==void 0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U}),h&&e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[a(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,i(K,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?a(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${a(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${a(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),i(ka,{nodes:I.nodes,pending:v.isPending,readOnly:I.readOnly,onCommitWeights:e=>v.mutate(ga(e)),weightLabel:`Node share`,...I.readOnly?{footnote:g?.autoPending?i(d,{children:a(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):e(d,{children:[T===`benchmark`?a(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):a(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),a(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&i(`span`,{className:`ml-1`,children:a(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),B!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:B}),H!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:H}),y.isError&&i(et,{message:a(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:a(`common.unknownError`)})}),v.isError&&i(et,{message:a(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:a(`common.unknownError`)})}),e(`details`,{className:`rounded-md border border-border`,children:[i(`summary`,{className:`${w} cursor-pointer text-xs text-foreground`,children:a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),i(`ul`,{className:`divide-y divide-border border-t border-border`,children:A.map(t=>e(`li`,{className:`${w} flex items-center gap-2`,children:[i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:t.name}),i(ot,{type:`number`,min:1,placeholder:`∞`,defaultValue:t.maxCameras??``,"aria-label":a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:t.name}),className:`w-20 text-right`,disabled:b.isPending,onBlur:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==t.maxCameras&&b.mutate({agentNodeId:t.id,maxCameras:i})}})]},t.id))}),i(`p`,{className:`${w} ${W} border-t border-border`,children:a(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),O.isError&&i(et,{message:a(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:O.error instanceof Error?O.error.message:a(`common.unknownError`)})}),k&&i(Ya,{suggestion:k,nameOf:j,pending:v.isPending,...L?{}:{onApply:()=>v.mutate(_a(k))}}),i(G,{headingId:`load-balancing-accelerators`,title:a(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:F,children:i(`div`,{className:`${m} space-y-2`,children:A.length===0?i(it,{title:a(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:a(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):A.map(e=>i(La,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...N?.[e.id]===void 0?{}:{suggestedMaxSessions:N[e.id]},sharesAutomatic:R,...g===void 0?{}:{shareSource:g.source},...ee(e.id)===void 0?{}:{share:ee(e.id)},...z(e.id)===void 0?{}:{placed:z(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&i(Xa,{stats:h,cameraName:M})]})}function Ya({suggestion:t,nameOf:n,pending:r,onApply:a}){let{t:o}=X();return e(G,{headingId:`load-balancing-suggestion`,title:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):o(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:D,...a===void 0?{}:{actions:i(J,{size:`sm`,onClick:a,disabled:r,children:o(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[i(`ul`,{className:`divide-y divide-border`,children:t.nodes.map(t=>e(`li`,{className:`${w} space-y-0.5`,children:[e(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[i(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:n(t.nodeId)}),i(`span`,{className:`tabular-nums text-foreground`,children:t.share===null?o(`common.skipped`):`${t.share}%`})]}),e(`p`,{className:W,children:[Ca(t.capacityFallback)===null?``:`${Ca(t.capacityFallback)} · `,t.skippedReason===null?o(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:t.capacitySessions,value2:t.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):o(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:t.skippedReason})]})]},t.nodeId))}),e(`p`,{className:`${w} ${W} border-t border-border`,children:[o(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:t.cameraFps,headroom:Math.round(t.headroom*100),basis:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):o(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:t.minSessionsPerDevice})}),` `,a===void 0?o(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):o(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function Xa({stats:t,cameraName:n}){let{t:r}=X(),a=l(),o=st({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return i(G,{headingId:`load-balancing-stale-pins`,title:r(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:ke,children:i(`ul`,{className:`divide-y divide-border`,children:t.stalePins.map(t=>e(`li`,{className:`${w} flex items-center gap-2`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs text-foreground`,title:n(t.deviceId),children:n(t.deviceId)}),i(`p`,{className:W,children:ya(t)})]}),i(J,{variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate({deviceId:t.deviceId,deviceKey:`auto`}),children:r(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},t.deviceId))})})}function Za({node:t,emphasis:n=!1}){let{t:r}=X(),a=t.isHub?E:F;return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[i(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),i(a,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 ${n?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[i(`span`,{className:`truncate`,children:t.name}),t.isHub&&i(K,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.hubWord`)}),!t.isOnline&&i(K,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.offline`)})]}),i(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:t.id})]})]})}function Qa({nodes:e,actions:t}){let{t:n}=X();return i(Fe,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>i(Za,{node:e})},...$n.map(e=>({key:e.key,header:n(e.labelKey),align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>i(gt,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:qn(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function $a({roleValues:t,options:n,pending:r,onRoleChange:a}){let{t:o}=X(),s=n.map(e=>({value:e.id,label:e.id===`hub`?o(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return i(`ul`,{className:`divide-y divide-border`,children:rr.map(n=>e(`li`,{className:`${w} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[e(`div`,{className:`min-w-0 flex-1 basis-56`,children:[i(`div`,{className:`text-xs font-medium text-foreground`,children:Yn(n)}),i(`p`,{className:W,children:Xn(n)})]}),i(`div`,{className:`w-full sm:w-48`,children:i($e,{"aria-label":o(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:Yn(n)}),value:t[n],disabled:r,options:s,onChange:e=>a(n,e.target.value)})})]},n))})}s();function eo(){let{t}=X(),r=l(),{nodes:a}=q(),o=Et(void 0),s=Ht({addonId:nr}),c=Ht({addonId:Kn}),u=Ht({addonId:ir}),d=()=>Qn(r),f=Ve({onSuccess:d}),p=Qe({onSuccess:d}),m=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.nodeId,t.settings);return e},[o.data]),h=n(()=>a.map(e=>{let t=m.get(e.id),n=cr(t);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[a,m]),g={ingestNode:tr(s.data,`ingestNode`,`hub`),recordingNode:tr(c.data,er,`hub`),audioNode:tr(s.data,`audioNode`,`hub`),motionNode:tr(s.data,`motionNode`,`hub`),postProcessingNode:tr(u.data,Zn,`hub`)},_=n(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id),t=e=>a.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...rr.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[a,g]),v=o.isLoading||s.isLoading||c.isLoading||u.isLoading,y=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:Kn,patch:{[er]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:ir,patch:{[Zn]:t}});return}p.mutate({addonId:nr,patch:{[e]:t}})},x={capabilityPending:f.isPending,onToggleCapability:y},S=v?i(B,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":t(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[e(G,{headingId:`roles-nodes-cluster-roles`,title:t(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:De,actions:S,children:[i(`p`,{className:`${W} border-b border-border px-3 py-1.5 sm:px-4`,children:t(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),i($a,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),i(G,{headingId:`roles-nodes-node-capabilities`,title:t(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:E,children:i(Qa,{nodes:h,actions:x})})]})}s();var to=2500,no={faces:k,"semantic-search":V,"detail-crop":je,"native-lease":Me,"runner-defaults":F,"load-balancer":Oe,failover:z},ro=[`cluster`,si];function io(e){a(()=>{if(e===null)return;let t=li[e]??e,n=`[data-cluster-settings-card="${CSS.escape(t)}"]`,r=()=>{let e=document.querySelector(n);return e===null?!1:(e.scrollIntoView({block:`start`,behavior:`smooth`}),e.classList.add(`ring-2`,`ring-primary/60`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-primary/60`),to),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function ao({section:t}){let{t:n}=X();return i(`div`,{"data-cluster-settings-card":t.id,className:`rounded-lg`,children:i(G,{headingId:`cluster-settings-${t.id}`,title:t.title,...no[t.id]===void 0?{}:{icon:no[t.id]},children:e(`div`,{className:`${m} space-y-3`,children:[i(`p`,{className:W,children:t.hint}),t.panels.map(e=>i(Gn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:ro.filter(t=>!(e.sectionIds??[]).includes(t)),emptyMessage:n(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}`))]})})})}function oo({refreshToken:e}){let[t]=Cn();return io(t.get(fi)),i(`div`,{className:`space-y-3 sm:space-y-4`,children:ci.map(e=>i(ao,{section:e},e.id))})}function so(e){return e?.hex}function co({hex:e}){return i(`span`,{className:`inline-block h-3 w-3 shrink-0 rounded-sm border border-border`,style:{backgroundColor:e}})}function lo({id:t,label:n,swatch:r}){let a=so(r);return a===void 0?null:e(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs`,"data-testid":`palette-entry-${t}`,children:[r?.form===`gradient`?i(`span`,{className:`flex h-4 overflow-hidden rounded-sm`,children:be.map(e=>i(`span`,{className:`h-4 w-2`,style:{backgroundColor:a,opacity:e}},e))}):i(`span`,{className:`h-4 w-3 shrink-0 rounded-sm`,style:{backgroundColor:a}}),i(`span`,{children:n}),i(`span`,{className:`font-mono text-[11px] opacity-80`,children:a})]})}function uo({ground:t,group:n,swatches:r}){let{t:a}=X();return e(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[i(lo,{id:n.id,label:n.label,swatch:r[n.id]}),n.children.length>0&&e(`details`,{"data-testid":`palette-subs-${t}-${n.id}`,children:[i(`summary`,{className:`cursor-pointer text-[11px] opacity-80`,children:a(`pipeline.palette.subclasses`,`Subclasses`)}),i(`div`,{className:`mt-1 flex flex-col gap-1 pl-4`,children:n.children.map(e=>i(lo,{id:e.id,label:e.label,swatch:r[e.id]},e.id))})]})]})}function fo({swatches:t}){let{t:n}=X(),r=se(),a=[{id:`dark`,background:ge.dark,ink:ge.light},{id:`light`,background:ge.light,ink:ge.dark}];return e(`div`,{className:`flex flex-col gap-2`,"data-testid":`palette-preview`,children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.palette.preview`,`Timeline marks`)}),a.map(e=>i(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-2 rounded-md border border-border p-2 sm:grid-cols-2`,"data-testid":`palette-ground-${e.id}`,style:{backgroundColor:e.background,color:e.ink},children:r.map(n=>i(uo,{ground:e.id,group:n,swatches:t},n.id))},e.id))]})}function po(e){for(let t of se()){if(t.id===e)return t.label;let n=t.children.find(t=>t.id===e);if(n!==void 0)return n.label}return e}s();function mo(e){return/^#[0-9a-f]{6}$/.test(e)}function ho(e,t){let n={};for(let r of ye){let i=t[r],a=e[r];i===void 0||a===void 0||i.hex!==a.hex&&(n[r]=i)}return n}function go({status:t,reason:r,source:a,presetId:s,customized:c,swatches:l,presets:u,saving:d,onApply:f}){let{t:p}=X(),[m,h]=o(c===!0),[g,_]=o(s??u[0]?.id??`camstack`),[v,y]=o(l??u[0]?.swatches??{}),b=u.find(e=>e.id===g)??u[0],x=n(()=>b===void 0?null:ae(v,b.fallbacks),[b,v]);if(t===`pending`)return i(`p`,{className:`text-xs text-foreground-subtle`,role:`status`,children:p(`pipeline.palette.pending`,`Reading the cluster palette…`)});let S=e=>{let t=u.find(t=>t.id===e);t!==void 0&&(h(!1),_(e),y(t.swatches),f({presetId:e}))},C=()=>{b!==void 0&&(h(!0),y(b.swatches))},w=(e,t)=>{if(typeof t!=`string`)return;let n=t.trim().toLowerCase();if(!mo(n))return;let r=v[e],i=r?.form===`gradient`?{...r,hex:n}:{form:`solid`,hex:n};y({...v,[e]:i})};return e(`div`,{className:`flex flex-col gap-4`,children:[t===`unknown`&&i(`p`,{className:`text-xs text-warning`,role:`status`,"data-testid":`palette-unknown`,children:p(`pipeline.palette.unknown`,`The stored palette cannot be read ({{reason}}). Boxes use the bundled CamStack preset.`,{reason:r??``})}),t===`ready`&&a===`unconfigured`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:p(`pipeline.palette.sourceUnconfigured`,`CamStack preset (cluster default)`)}),i(G,{headingId:`palette-presets`,title:p(`pipeline.palette.presets`,`Presets`),children:e(`div`,{className:`flex flex-wrap gap-2 p-3`,children:[u.map(t=>i(J,{type:`button`,size:`sm`,variant:!m&&t.id===g?`primary`:`outline`,onClick:()=>S(t.id),disabled:d,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[[`person`,`vehicle`,`animal`].map(e=>{let n=so(t.swatches[e]);return n===void 0?null:i(co,{hex:n},e)}),t.name]})},t.id)),i(J,{type:`button`,size:`sm`,variant:m?`primary`:`outline`,onClick:C,disabled:d||b===void 0,children:p(`pipeline.palette.custom`,`Custom`)})]})}),i(fo,{swatches:v}),x!==null&&x.ok&&i(`p`,{className:`text-xs text-success`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.valid`,`Every colour is distinct on both themes.`)}),x!==null&&!x.ok&&i(`p`,{className:`text-xs text-danger`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.invalid`,`This palette is refused: {{reason}}`,{reason:he(x.violations)})}),m&&b!==void 0&&i(G,{headingId:`palette-custom`,title:p(`pipeline.palette.custom`,`Custom`),children:e(`div`,{className:`flex flex-col gap-2 p-3`,children:[ye.map(e=>{let t=so(v[e]);return t===void 0?null:i(It,{field:{type:`color`,key:e,label:po(e)},values:{[e]:t},onChange:(t,n)=>w(e,n)},e)}),i(J,{type:`button`,size:`sm`,onClick:()=>{if(b===void 0||x===null||!x.ok)return;let e=ho(b.swatches,v);f(Object.keys(e).length>0?{presetId:b.id,overrides:e}:{presetId:b.id})},disabled:d||x===null||!x.ok,children:p(`pipeline.palette.save`,`Save custom palette`)})]})})]})}function _o(){let e=en({}),t=qt({}),n=Lt(),r=r=>{n.mutate(r,{onSuccess:()=>{e.refetch(),t.refetch()}})};if(e.isPending||t.isPending)return i(go,{status:`pending`,presets:[],onApply:r});if(e.isError||e.data===void 0)return i(go,{status:`unknown`,reason:e.isError?String(e.error):`no palette`,presets:t.data??[],saving:n.isPending,onApply:r});if(t.isError||t.data===void 0)return i(go,{status:`unknown`,reason:String(t.error),presets:[],saving:n.isPending,onApply:r});if(e.data.status===`unknown`)return i(go,{status:`unknown`,reason:e.data.reason,presets:t.data,saving:n.isPending,onApply:r});let a=e.data;return i(go,{status:`ready`,source:a.source,presetId:a.presetId,customized:a.customized,swatches:a.swatches,presets:t.data,saving:n.isPending,onApply:r},`${a.presetId}:${String(a.customized)}`)}var vo=`pipeline-orchestrator`,yo=200;function bo(){let{t}=X();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterOrchestratorLogsTab.dispatchDecisionsBalancerMovesAnd`,`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.`)})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(kt,{addonId:vo,limit:yo,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}var xo=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`},{id:`palette`,labelKey:`pipeline.clusterDetail.tabPalette`}];function So(e){return xo.some(t=>t.id===e)}function Co({refreshToken:t}){let{t:n}=X(),[r,a]=Cn(),o=r.get(di),s=So(o)?o:`assignments`,c=e=>{a(t=>{let n=new URLSearchParams(t);return n.set(di,e),n.delete(fi),n},{replace:!0})};return e(`div`,{className:`flex flex-col h-full`,children:[e(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:n(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),i(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:n(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles, settings and the display palette.`)})]}),i(Xe,{value:s,onValueChange:e=>{So(e)&&c(e)},className:`px-4 sm:px-6`,children:i(Je,{className:`border-border`,children:xo.map(e=>i(vt,{value:e.id,className:`h-auto py-2 border-b-2`,children:n(e.labelKey)},e.id))})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[s===`assignments`&&i(Ri,{}),s===`load-balancing`&&i(Ja,{refreshToken:t,onOpenAutoTune:()=>c(`auto-tune`)}),s===`auto-tune`&&i(ra,{}),s===`roles-nodes`&&i(eo,{}),s===`settings`&&i(oo,{refreshToken:t}),s===`logs`&&i(bo,{}),s===`palette`&&i(_o,{})]})]})}function Q({title:t,children:n}){return e(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[i(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:t}),i(`div`,{className:`flex flex-col gap-1 min-w-0`,children:n})]})}function $({label:t,children:n,overridden:r=!1}){return e(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[i(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:t,children:t}),i(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:n}),r&&i(wo,{})]})}function wo(){let{t:e}=X();return i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),"aria-label":e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),role:`img`})}var To={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 Eo({tone:e=`neutral`,children:t,title:n}){return i(`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 ${To[e]}`,children:t})}function Do({children:e}){return i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function Oo({icon:t,label:n,nodeId:r,pinned:a,reason:o,overridden:s}){let{t:c}=X();return e(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[i(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),i(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:n}),r===null?i(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):e(d,{children:[i(`span`,{className:`font-mono text-foreground truncate`,title:r,children:r}),a?e(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[i(p,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:o!==void 0&&o.length>0?o:c(`cameras.configBlocks.capacity`)})}),s&&i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:c(`cameras.configBlocks.persistedSettingsPinForThis`,`Persisted settings pin for this role`)})]})]})}function ko({assignment:t,settings:n,onlineNodes:r,pinPending:a,onDetectionPinChange:o}){let{t:s}=X(),c=t.pinned.detection&&t.detectionNodeId!==null?t.detectionNodeId:`auto`,l=[...new Set([...t.detectionNodeId===null?[]:[t.detectionNodeId],...r.map(e=>e.id)])];return e(Q,{title:s(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[i(Oo,{icon:F,label:s(`cameras.configBlocks.detection`,`Detection`),nodeId:t.detectionNodeId,pinned:t.pinned.detection,reason:t.reasons.detection,overridden:n.overriddenKeys.has(`pipelineNodeId`)}),i(Oo,{icon:v,label:s(`cameras.configBlocks.decoder`,`Decoder`),nodeId:t.decoderNodeId,pinned:t.pinned.decoder,reason:t.reasons.decoder,overridden:n.overriddenKeys.has(`decoderNodeId`)}),i(Oo,{icon:H,label:s(`cameras.configBlocks.audio`,`Audio`),nodeId:t.audioNodeId,pinned:t.pinned.audio,reason:t.reasons.audio,overridden:n.overriddenKeys.has(`audioNodeId`)}),i(Oo,{icon:S,label:s(`cameras.configBlocks.source`,`Source`),nodeId:t.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),i(`div`,{className:`mt-1.5`,children:e(`select`,{value:c,disabled:a,"aria-label":s(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>o(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:[i(`option`,{value:`auto`,children:s(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),l.map(e=>i(`option`,{value:e,children:s(`cameras.configBlocks.pinDetection`,{node:r.find(t=>t.id===e)?.name??e})},e))]})})]})}function Ao(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function jo(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function Mo(e){return e===null?Y.t(`pipeline.configBlocks.fpsDefault`):e===0?Y.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function No({streams:t,brokerProfiles:n,settings:r,motionEnabled:a,motionFpsLive:o,cameraSensors:s}){let{t:c}=X(),l=jo(n,r.detectionStreamProfile),u=jo(n,r.motionStreamProfile),f=r.motionSources.includes(`analyzer`);return e(Q,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[e($,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:r.overriddenKeys.has(`detectionStreamProfile`),children:[r.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),i($,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:r.overriddenKeys.has(`detectionFps`),children:Mo(r.detectionFps)}),e($,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:r.overriddenKeys.has(`motionSources`),children:[r.motionSources.length>0?r.motionSources.map(de).join(` + `):c(`cameras.configBlocks.none`),a===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),i($,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:Pn(s)}),f&&e(d,{children:[e($,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:r.overriddenKeys.has(`motionStreamProfile`),children:[r.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),e($,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:r.overriddenKeys.has(`motionFps`),children:[Mo(r.motionFps),o!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:o.toFixed(1)})}`]})]}),i($,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:r.overriddenKeys.has(`motionCooldownMs`),children:r.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${r.motionCooldownMs/1e3}s`}),i(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:t.length===0?i(Do,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):t.map(t=>e(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:t.camStreamId,children:[i(`span`,{className:`text-foreground-muted`,children:t.kind}),` `,Ao(t)]},t.camStreamId))})]})}function Po({steps:t,audioModelId:n,audioEnabled:r,audioMode:a}){let{t:o}=X();return e(Q,{title:o(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[t===void 0?i(Do,{children:o(`cameras.configBlocks.resolving`,`Resolving…`)}):t.length===0?i(Do,{children:o(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.map((t,n)=>i(Eo,{tone:t.enabled&&t.depth===0?`info`:`neutral`,title:t.modelId??t.addonId,children:e(`span`,{className:t.enabled?``:`line-through opacity-60`,children:[t.depth>0&&i(`span`,{className:`opacity-50`,children:`↳ `}),t.addonId,t.modelId!==null&&e(`span`,{className:`font-mono opacity-75`,children:[` · `,t.modelId]})]})},`${t.addonId}-${n}`))}),i(`div`,{className:`mt-1`,children:e($,{label:o(`cameras.configBlocks.audioClass`,`Audio class.`),children:[a??`—`,r!==null&&` · ${o(r?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,n!==null&&` · ${n}`]})})]})}var Fo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Io({detection:t,live:n,detectionMode:r,modeOverridden:a}){let o=N(),{t:s}=X();if(t===null)return e(Q,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),i(Do,{children:s(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let c=n?.phase??t.phase,l=n?.actualFps??t.actualFps,u=n?.configuredFps??t.configuredFps,d=n?.avgInferenceTimeMs??t.avgInferenceMs,f=n?.queueDepth??t.queueDepth,p=Ft(c,o),m=c===`active`&&l===0;return e(Q,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[e(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${p.badgeClass}`,children:[i(Rt,{phase:c,className:`h-2.5 w-2.5`}),p.label]}),n!==void 0&&i(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:s(`common.live`)})]}),i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),e($,{label:`FPS`,children:[i(`span`,{className:m?`text-danger font-semibold`:``,children:l.toFixed(1)}),i(`span`,{className:`ml-1 text-foreground-subtle`,children:s(`cameras.runtimeBlocks.configuredFps`,{fps:u.toFixed(0)})})]}),e($,{label:s(`cameras.runtimeBlocks.inference`,`Inference`),children:[d.toFixed(0),` ms`,f>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.queue`,{depth:f})}),n!==void 0&&n.droppedFrames>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.drops`,{count:n.droppedFrames})})]}),e($,{label:s(`cameras.runtimeBlocks.engine`,`Engine`),children:[t.engine.backend,` · `,t.engine.device]}),e($,{label:s(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[i(Eo,{tone:Fo[t.provisioning.state]??`neutral`,children:t.provisioning.state}),t.provisioning.error!==void 0&&e(`span`,{className:`text-danger text-[10px]`,children:[` `,t.provisioning.error]})]})]})}function Lo({broker:t}){let{t:n}=X();return t===null?i(Q,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:i(Do,{children:n(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):e(Q,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[t.profiles.length===0?i(Do,{children:n(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):i(`div`,{className:`flex flex-col gap-1`,children:t.profiles.map(t=>{let r=t.status===`streaming`,a=r&&t.inFps===0;return e(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${a?`bg-danger`:r?`bg-success animate-pulse`:`bg-border`}`,title:t.status}),i(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:t.profile,children:t.profile}),e(`span`,{className:`text-foreground-subtle truncate`,children:[t.width,`×`,t.height,` `,t.codec]}),i(`span`,{className:`ml-auto shrink-0 ${a?`text-danger`:`text-foreground`}`,children:n(`cameras.runtimeBlocks.fpsValue`,{value:t.inFps===null?`—`:t.inFps.toFixed(0)})}),e(`span`,{className:`text-foreground-subtle shrink-0`,title:n(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,t.subscribers]})]},t.profile)})}),e(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[i(Eo,{tone:t.webrtcSessions>0?`info`:`neutral`,children:n(`cameras.runtimeBlocks.webrtc`,{count:t.webrtcSessions})}),i(Eo,{tone:t.rtspRestream?`success`:`neutral`,children:t.rtspRestream?n(`cameras.runtimeBlocks.restreamOn`):n(`cameras.runtimeBlocks.restreamOff`)})]})]})}function Ro({decoder:e}){let{t}=X();return e===null?i(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i(Do,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):i(Q,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i($,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}s();var zo=`pipeline-orchestrator`,Bo={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Vo={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function Ho({problems:t}){return i(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:t.map(t=>e(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${t.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[i(ie,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),i(`span`,{className:`min-w-0`,children:t.message})]},t.code))})}function Uo({deviceId:t,name:r,online:a,status:o,live:s,onlineNodes:c}){let{t:u}=X(),d=l(),{data:f}=tt({addonId:zo,deviceId:t,nodeId:`hub`},{staleTime:3e4}),{data:p}=dt({deviceId:t},{staleTime:3e4}),m=n(()=>Dn(f),[f]),h=n(()=>p===void 0?void 0:Un(p.steps),[p]),g=n(()=>o===void 0?[]:Nn(o),[o]),_=()=>{d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=ln({onSuccess:_}),y=Ge({onSuccess:_}),b=e=>{e===`auto`?y.mutate({deviceId:t}):v.mutate({deviceId:t,agentNodeId:e})},x=o===void 0?`idle`:Wn(o),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return e(`article`,{"aria-label":u(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:r}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[e(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[i(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:Bo[x]}`,title:S?u(`common.error`,`Error`):u(Vo[x]),"aria-label":S?u(`common.error`,`Error`):u(Vo[x]),role:`img`}),i(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:r,children:r}),e(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,t]}),!a&&i(Eo,{tone:`danger`,children:u(`common.offline`)}),e(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&i(Eo,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:u(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?u(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),o?.recording!=null&&(o.recording.active?e(Eo,{tone:`danger`,title:u(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:o.recording.mode}),children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):o.recording.mode!==`off`&&i(Eo,{tone:`neutral`,title:u(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:u(`pipeline.cameraPipelineCard.recMode`,{mode:o.recording.mode})}))]})]}),g.length>0&&i(Ho,{problems:g}),o===void 0?i(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:u(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[i(ko,{assignment:o.assignment,settings:m,onlineNodes:c,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),i(Io,{detection:o.detection,live:s,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),i(Po,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:o.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),i(No,{streams:o.source.streams,brokerProfiles:o.broker?.profiles,settings:m,motionEnabled:o.motion?.enabled??null,motionFpsLive:o.motion?.fps??null,cameraSensors:o.cameraSensors}),i(Lo,{broker:o.broker}),i(Ro,{decoder:o.decoder})]})]})}s();var Wo=5e3,Go=1e4,Ko=5e3;function qo(e){let t=l(),{data:r,isLoading:i}=En(),{data:s,isLoading:c}=fn({},{refetchInterval:Wo}),{nodes:u}=q();a(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=o(new Map);Ot(me.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),a(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Go,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Ko);return()=>clearInterval(e)},[d.size]);let p=n(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:n(()=>(r??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[r,p]),liveMetrics:d,onlineNodes:n(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:i||c}}s();function Jo({refreshToken:t}){let{t:r}=X(),{rows:a,liveMetrics:o,onlineNodes:s,isLoading:c}=qo(t),l=n(()=>[...a.map(e=>{let t=e.status===void 0?[]:Nn(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),[a]),u=n(()=>{let e=0,t=0;for(let n of l)(n.errorCount>0||n.warningCount>0)&&(t+=1),(o.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:l.length,active:e,issues:t}},[l,o]);return c&&a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):i(`div`,{className:`h-full overflow-y-auto`,children:e(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[e(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[i(`span`,{children:i(Tn,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:u.total},components:{b:i(`span`,{className:`font-semibold text-foreground`})}})}),i(`span`,{children:i(Tn,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:u.active},components:{b:i(`span`,{className:`font-semibold text-success`})}})}),e(`span`,{children:[i(`span`,{className:`font-semibold ${u.issues>0?`text-danger`:`text-foreground`}`,children:u.issues}),` `,r(`cameras.camerasOverview.withIssues`,`with issues`)]}),i(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:r(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),l.map(({row:e})=>i(Uo,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:o.get(e.deviceId),onlineNodes:s},e.deviceId))]})})}s();var Yo=`__cluster__`;function Xo(e){return e===`cameras`?`cameras`:`nodes`}function Zo({viewMode:t,onNodes:n,onCameras:r}){let{t:a}=X();return e(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":a(`pipeline.pipelineView`,`Pipeline view`),children:[i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`nodes`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.nodes`,`Nodes`)}),i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`cameras`,onClick:r,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.cameras`,`Cameras`)})]})}function Qo(){let{t}=X(),[n,r]=Cn(),s=Xo(n.get(`view`)),c=n.get(`node`)??`__cluster__`,[l,u]=o(0),[f,p]=o(!1);return a(()=>{s===`nodes`&&!n.get(`node`)&&r(e=>{let t=new URLSearchParams(e);return t.set(`view`,`nodes`),t.set(`node`,Yo),t},{replace:!0})},[s,n,r]),e(ut,{icon:Ce,title:t(`pipeline.pipeline`,`Pipeline`),subtitle:t(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:e(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:t(`common.refresh`,`Refresh`),children:[i(g,{className:`h-3.5 w-3.5`}),t(`common.refresh`,`Refresh`)]}),nav:i(Zo,{viewMode:s,onNodes:()=>{r({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{r({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[s===`nodes`&&e(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":f,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[i(`span`,{children:t(f?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),i(R,{className:[`h-4 w-4 transition-transform`,f?`rotate-180`:``].join(` `)})]}),i(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:s===`nodes`?e(d,{children:[i(`aside`,{className:[f?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b border-border md:border-b-0 md:border-r`,`max-h-[60vh] overflow-y-auto md:max-h-none`].join(` `),children:i(ur,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?i(Co,{refreshToken:l}):i(Li,{nodeId:c,refreshToken:l})})]}):i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:i(Jo,{refreshToken:l})})})]})}export{Qo as PipelinePage};
|