@camstack/addon-admin-ui 1.1.37 → 1.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddLocationWizard-RRlx3cRe.js → AddLocationWizard-C6d7Rl2b.js} +1 -1
- package/dist/assets/{AddonCollectionPage-CWvsH8SQ.js → AddonCollectionPage-6BdYLe6i.js} +1 -1
- package/dist/assets/Addons-DRZkv8if.js +1 -0
- package/dist/assets/{AdminTabs-CiYcSYbj.js → AdminTabs-B163y6NF.js} +1 -1
- package/dist/assets/{BrokerForm-B9Pyef82.js → BrokerForm-Blc6VNTn.js} +1 -1
- package/dist/assets/{Capabilities-DLYbrJz4.js → Capabilities-CMoqY-Ug.js} +1 -1
- package/dist/assets/{CapabilityBadges-DgQBa83l.js → CapabilityBadges-khS3I08e.js} +1 -1
- package/dist/assets/{Cluster-DTY2DUrV.js → Cluster-DUuIC1Di.js} +1 -1
- package/dist/assets/{Dashboard-BB_7zhcP.js → Dashboard-BUIPjBAI.js} +1 -1
- package/dist/assets/{Data-D56cbbtl.js → Data-CI9RNUqg.js} +1 -1
- package/dist/assets/{DetectionIntelligence-CvHAORbN.js → DetectionIntelligence-BWjYUpoc.js} +1 -1
- package/dist/assets/DeviceDetail-ncfqxizt.js +2 -0
- package/dist/assets/{Devices-K_L5xpp2.js → Devices-BI0K3L20.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-Br4TfZLq.js → EmbedPlayerPage-DTJcJ-K0.js} +1 -1
- package/dist/assets/{FormBuilder-inLQWViM.js → FormBuilder-Dq7rzw2g.js} +1 -1
- package/dist/assets/Identity-BClKA5CP.js +1 -0
- package/dist/assets/IntegrationDetail-CddIVuAg.js +1 -0
- package/dist/assets/{Integrations-CJV1Uy9R.js → Integrations-BqqLAeN1.js} +1 -1
- package/dist/assets/{Integrations-CFtirtyU.js → Integrations-Co_wJVPe.js} +1 -1
- package/dist/assets/{Logs-CQf1pQ47.js → Logs-CBR7x9NW.js} +1 -1
- package/dist/assets/{MotionZonesSettings-3tt6mBQ0.js → MotionZonesSettings-BzuwNLPu.js} +1 -1
- package/dist/assets/{MyAccess-Cn7kN9Oc.js → MyAccess-DN5XJRXk.js} +1 -1
- package/dist/assets/Network-DWjMAaiC.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-Cpl4rjtk.js → NodeAddonsSettingsPanel-DLEbHtxx.js} +1 -1
- package/dist/assets/{NotificationTargets-BOs4Ypzw.js → NotificationTargets-BiiLAuNs.js} +1 -1
- package/dist/assets/Pipeline-CX07C-rk.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-aLsRsfB3.js → PrivacyMaskSettings-B86k8eCd.js} +1 -1
- package/dist/assets/{ProviderIcon-x3ks3Cgc.js → ProviderIcon-BLTH0Ake.js} +1 -1
- package/dist/assets/{ScanNetworkModal-DrMPFU3B.js → ScanNetworkModal-DVZ-75GA.js} +1 -1
- package/dist/assets/{Settings-DnOYBfde.js → Settings-EwkM7qrL.js} +1 -1
- package/dist/assets/{Showroom-v8sUA896.js → Showroom-ByaFbcYn.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DjSJzFMJ.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CJNw3KPL.js} +1 -1
- package/dist/assets/addon-display-names-DvSEQty-.js +1 -0
- package/dist/assets/{build-cluster-graph-DIEEuf36.js → build-cluster-graph-QwpFUUjE.js} +2 -2
- package/dist/assets/circle-check-big-Ybrsd8CR.js +1 -0
- package/dist/assets/{copy-BRliESit.js → copy-BwUimuA-.js} +1 -1
- package/dist/assets/dist-BAlJw4R3.js +7 -0
- package/dist/assets/{dist-B8dNOlY9.js → dist-DAY4wmmI.js} +1 -1
- package/dist/assets/{download-BuixOtcX.js → download-DDSz9DfI.js} +1 -1
- package/dist/assets/{hostInit-BWL1MjJX.js → hostInit-8o1E_qzk.js} +1 -1
- package/dist/assets/index-ByJMV5aQ.js +4 -0
- package/dist/assets/index-DufitHjX.css +2 -0
- package/dist/assets/{key-round-DovZ-dE_.js → key-round-DH-NOckT.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-145aa705.js → mf-entry-bootstrap-0-a41549da.js} +2 -2
- package/dist/assets/{pencil-D2v4UbT5.js → pencil-D-LLTb5E.js} +1 -1
- package/dist/assets/{player-overlays-CpsGl45o.js → player-overlays-2Q1miaEN.js} +1 -1
- package/dist/assets/plus-BWeUQ-Wm.js +1 -0
- package/dist/assets/{radio-BXRkVjee.js → radio-DqOn-16x.js} +1 -1
- package/dist/assets/{refresh-cw-B_eIWqpa.js → refresh-cw-DuM6oiTl.js} +1 -1
- package/dist/assets/remoteEntry-zKeZuvbY.js +1 -0
- package/dist/assets/{rotate-ccw-BWUd8OlD.js → rotate-ccw-AVemYpzI.js} +1 -1
- package/dist/assets/rotate-cw-8j5op9rY.js +1 -0
- package/dist/assets/search-Cb4-y9a0.js +1 -0
- package/dist/assets/{server-CcpmRIQF.js → server-BKvjFwOh.js} +1 -1
- package/dist/assets/{sparkles-Bs3uod4E.js → sparkles-UVx0u2KJ.js} +1 -1
- package/dist/assets/{square-check-big-O_vP3vWT.js → square-check-big-BUD8eXmE.js} +1 -1
- package/dist/assets/square-fxMkH5ka.js +1 -0
- package/dist/assets/src-CKNSRfvW.js +7 -0
- package/dist/assets/src-D37vd48r.js +67 -0
- package/dist/assets/{upload-CW3eN_Z6.js → upload-B9TkBT8Q.js} +1 -1
- package/dist/assets/{useDevice-CNqajtmH.js → useDevice-Dt2O2ZfS.js} +1 -1
- package/dist/assets/{useEventInvalidation-ycuHWtpd.js → useEventInvalidation-UIA6NlSS.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BIUGfAw_.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CsRvw1py.js} +2 -2
- package/dist/assets/{wifi-Yyiz1n_M.js → wifi-C2e4NNeF.js} +1 -1
- package/dist/assets/{zap-GMWRUOGp.js → zap-C-u-esEw.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +45 -83
- package/package.json +1 -1
- package/dist/assets/Addons-CAzgXiLH.js +0 -1
- package/dist/assets/DeviceDetail-WSoEsPnD.js +0 -2
- package/dist/assets/Identity-CUzVP34n.js +0 -1
- package/dist/assets/IntegrationDetail-ogpWJl32.js +0 -1
- package/dist/assets/Network-Cb5KR0mO.js +0 -1
- package/dist/assets/Pipeline-Bsjgzu7B.js +0 -1
- package/dist/assets/circle-check-big-CLMjysyy.js +0 -1
- package/dist/assets/dist-DRenWL4F.js +0 -7
- package/dist/assets/index-CdAVDEco.js +0 -4
- package/dist/assets/index-DC5LZGUt.css +0 -2
- package/dist/assets/plus-DMWGd7B0.js +0 -1
- package/dist/assets/remoteEntry-Ccem7OUi.js +0 -1
- package/dist/assets/rotate-cw-BNKHRv84.js +0 -1
- package/dist/assets/search-DNeYxEqb.js +0 -1
- package/dist/assets/square-BelYTwAy.js +0 -1
- package/dist/assets/src-BXL7z3gT.js +0 -7
- package/dist/assets/src-cK1rmJgB.js +0 -67
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$i as e,Ai as t,Br as n,C as r,Di as i,Ei as a,Fr as o,Gr as s,Hr as c,Jr as l,Kr as u,La as d,Lr as f,Oi as p,Qr as m,Rr as h,Si as g,T as _,Ur as v,Vr as y,Xr as b,Yr as x,Zr as S,_ as C,aa as w,ai as T,bi as E,ca as D,ci as O,da as k,di as A,ei as j,fa as M,fi as N,ia as P,it as F,ja as I,la as ee,mi as te,oa as L,oi as ne,ot as re,pi as ie,qr as ae,ra as oe,ri as se,si as ce,ti as le,ui as ue,wi as de,xi as fe,yi as pe,za as me,zr as he}from"./src-cK1rmJgB.js";import{I as ge,K as _e,Q as R,S as z,T as ve,W as B,a as ye,b as V,o as H,q as U,x as W,z as G}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as K,V as be}from"./src-BXL7z3gT.js";import{p as xe}from"./player-overlays-CpsGl45o.js";import{t as Se}from"./download-BuixOtcX.js";import{i as Ce,n as we,r as Te,t as Ee}from"./AddLocationWizard-RRlx3cRe.js";import{n as De,r as Oe,t as ke}from"./zap-GMWRUOGp.js";import{i as Ae,r as je}from"./useDevice-CNqajtmH.js";import{t as Me}from"./pencil-D2v4UbT5.js";import{t as Ne}from"./plus-DMWGd7B0.js";import{t as Pe}from"./refresh-cw-B_eIWqpa.js";import{t as Fe}from"./search-DNeYxEqb.js";import{t as Ie}from"./server-CcpmRIQF.js";import{t as Le}from"./square-check-big-O_vP3vWT.js";import{t as Re}from"./square-BelYTwAy.js";import{A as ze,F as Be,G as Ve,M as He,P as Ue,V as We,i as Ge,j as Ke,k as q,o as qe,s as Je,w as Ye,x as J}from"./index-CdAVDEco.js";import{t as Xe}from"./AdminPage-BwmGKnRf.js";import{t as Ze}from"./useEventInvalidation-ycuHWtpd.js";import{a as Qe,c as Y,i as $e,l as et,o as X,r as tt,s as nt,t as rt}from"./build-cluster-graph-DIEEuf36.js";import{n as it}from"./format-size-CO9d3C3-.js";import{t as at}from"./NodeAddonsSettingsPanel-Cpl4rjtk.js";var ot=We(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),st=We(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),ct=We(`flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),lt=We(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);R();function ut(e){return e}function dt(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ft(e,t){return typeof e==`boolean`?e:ut(t)}function pt(e,t){return{decode:ft(dt(e,`decode`),t),pipeline:ft(dt(e,`detect`),t),audio:ft(dt(e,`audio`),t),ingest:ft(dt(e,`ingest`),t)}}function mt(e,t,n){let r=e?.find(e=>e.nodeId===t);return pt(r?.settings,n)}function ht({selectedNodeId:e,onSelect:t,refreshToken:n}){let{data:r}=o(void 0),{data:i}=T(void 0),{data:a}=ne(void 0),s=new Map;for(let e of i??[])s.set(e.agentNodeId,(s.get(e.agentNodeId)??0)+1);let c=r??[],l=c.filter(e=>e.isOnline).length,u=c.filter(e=>!e.isOnline).length;return z(`div`,{className:`flex flex-col h-full`,children:[z(`button`,{type:`button`,onClick:()=>t(Rr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[W(Ye,{className:`h-4 w-4 flex-shrink-0`}),z(`div`,{className:`min-w-0 flex-1`,children:[W(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),W(`div`,{className:`flex-1 overflow-y-auto`,children:c.map(n=>{let r=e===n.id,i=s.get(n.id)??0,o=n.isHub?Ie:q,c=mt(a,n.id,n.isHub),l=n.isOnline?null:me(et(n.lastSeen));return z(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${r?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[W(o,{className:`h-4 w-4 flex-shrink-0`}),z(`div`,{className:`min-w-0 flex-1`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&W(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!n.isOnline&&W(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&W(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),z(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[z(`span`,{children:[n.cpuCores,` cores`]}),W(`span`,{children:`•`}),z(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),i>0&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[W(De,{className:`h-2.5 w-2.5`}),i]})]}),!n.isOnline&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{className:`text-destructive`,children:[`offline`,l===null?``:` · ${l}`]})]})]}),z(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[W(I,{variant:c.decode?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:c.decode?`Decode: enabled`:`Decode: not enabled (agent capability)`,children:`Dec`}),W(I,{variant:c.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:c.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),W(I,{variant:c.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:c.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},n.id)})}),z(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[z(`span`,{children:[l,` online`]}),u>0&&z(`span`,{className:`text-destructive`,children:[u,` offline`]})]})]})}function gt({nodeId:e,refreshToken:t}){let{data:n}=o(void 0),r=n?.find(t=>t.id===e),i=P(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?z(`div`,{className:`px-6 py-4 border-b border-border`,children:[z(`div`,{className:`flex items-center gap-2 mb-1`,children:[W(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?W(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):W(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&W(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),z(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[W(`span`,{children:r.cpuModel??`CPU`}),W(`span`,{children:`•`}),z(`span`,{children:[r.cpuCores,` cores`]}),W(`span`,{children:`•`}),z(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),i&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{children:[i.attachedCameras,` cameras (`,i.activeCameras,` active)`]}),W(`span`,{children:`•`}),z(`span`,{children:[i.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),W(`span`,{children:`•`}),z(`span`,{children:[`queue `,i.queueDepthTotal]}),i.hardware.hasGpu&&z(V,{children:[W(`span`,{children:`•`}),W(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):W(`div`,{className:`px-6 py-4 border-b border-border`,children:z(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function _t({refreshToken:e,nodeId:t}){let[n,r]=U(new Map),{nodes:i}=oe();L(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:a}=m(void 0),o=B(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=B(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),c=B(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=B(()=>{let e=0,t=0,n=0,r=0,a=0;for(let i of s.values())e+=i.attachedCameras,t+=i.activeCameras,n+=i.totalFps,r+=i.totalInferenceWeighted,a+=i.queueDepth;let o=e>0?r/e:0;return{totalAgents:i.length,onlineAgents:i.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:a,totalFps:n}},[s,i]);if(t){let e=s.get(t);return z(`div`,{className:`@container/liveload`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),z(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[W(Z,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),W(Z,{label:`Cameras`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),W(Z,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),W(Z,{label:`Queue`,value:e?String(e.queueDepth):`—`}),W(Z,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let u=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return z(`div`,{className:`@container/liveload`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),z(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[W(Z,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),W(Z,{label:`Cameras`,value:`${l.activeCameras}/${l.attachedCameras}`}),W(Z,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),W(Z,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),W(Z,{label:`Queue depth`,value:String(l.queueDepth)})]}),W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[480px]`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[W(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),W(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),W(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),W(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),W(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),W(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),z(`tbody`,{children:[u.map(([e,t])=>z(`tr`,{className:`border-t border-border`,children:[W(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),u.length===0&&W(`tr`,{children:W(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function Z({label:e,value:t}){return z(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[W(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),W(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}R();var vt={active:!1,pinned:!1,nodeId:null,reason:``},yt=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],bt={pipeline:q,decoder:st,audio:Oe},xt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function St({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let r=H(),[i,a]=U(null),[o,s]=U(null),[c,d]=U(new Map);Ze([`pipelineOrchestrator`,`getPipelineAssignments`],yt),Ze([`pipelineOrchestrator`,`getDecoderAssignments`],yt),Ze([`pipelineOrchestrator`,`getAudioAssignments`],yt);let{data:f}=T(void 0),{data:p}=se(void 0),{data:m}=S(void 0),{nodes:h}=oe(),{data:g}=je();L(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&d(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),G(()=>{if(c.size===0)return;let e=setInterval(()=>{d(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[c.size]);let v=B(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),y=B(()=>{let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:v.get(e)??`Device ${e}`,pipeline:vt,decoder:vt,audio:vt};return n.set(e,r),r};for(let i of f??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``}})}for(let i of p??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,decoder:{active:e===`cluster`?!0:i.decoderNodeId===t,pinned:i.pinned,nodeId:i.decoderNodeId,reason:i.reason??``}})}for(let i of m??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,audio:{active:e===`cluster`?!0:i.nodeId===t,pinned:i.pinned,nodeId:i.nodeId,reason:`capacity`}})}let i=[...n.values()];return e===`agent`&&(i=i.filter(e=>e.pipeline.active||e.decoder.active||e.audio.active)),i.sort((e,t)=>e.deviceId-t.deviceId),i},[f,p,m,v,e,t]),b=B(()=>(h??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[h]),x=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},C=l({onSuccess:x}),w=fe({onSuccess:x}),D=ae({onSuccess:x}),O=E({onSuccess:x}),k=u({onSuccess:x}),A=pe({onSuccess:x}),j=(e,t,n)=>{t===`pipeline`?C.mutate({deviceId:e,agentNodeId:n}):t===`decoder`?D.mutate({deviceId:e,nodeId:n}):k.mutate({deviceId:e,nodeId:n}),a(null)},M=(e,t)=>{t===`pipeline`?w.mutate({deviceId:e}):t===`decoder`?O.mutate({deviceId:e}):A.mutate({deviceId:e}),a(null)};return W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&W(`th`,{className:`w-10`}),W(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?z(V,{children:[W(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),W(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):z(V,{children:[W(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),W(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),W(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),W(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),z(`tbody`,{children:[y.map(t=>{let r=c.get(t.deviceId),l=o===t.deviceId;return z(ve.Fragment,{children:[z(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&W(`td`,{className:`px-2 py-2 align-middle`,children:W(`button`,{type:`button`,onClick:()=>s(l?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":l?`Collapse broker details`:`Expand broker details`,children:W(l?Ue:He,{className:`h-3.5 w-3.5`})})}),z(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[W(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),z(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?z(V,{children:[W(`td`,{className:`px-3 py-2 align-middle`,children:W(Ct,{state:t.pipeline,onlineNodes:b,pending:C.isPending||w.isPending,onChange:e=>{e===`auto`?M(t.deviceId,`pipeline`):j(t.deviceId,`pipeline`,e)}})}),W(`td`,{className:`px-3 py-2 align-middle`,children:W(wt,{state:t.pipeline})})]}):z(V,{children:[W(Tt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`pipeline`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>a(null),onMove:e=>j(t.deviceId,`pipeline`,e),onUnpin:()=>M(t.deviceId,`pipeline`)}),W(Tt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`decoder`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`decoder`?null:{deviceId:t.deviceId,role:`decoder`}),onCloseMenu:()=>a(null),onMove:e=>j(t.deviceId,`decoder`,e),onUnpin:()=>M(t.deviceId,`decoder`)}),W(Tt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`audio`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>a(null),onMove:e=>j(t.deviceId,`audio`,e),onUnpin:()=>M(t.deviceId,`audio`)})]}),W(`td`,{className:`px-3 py-2 align-middle`,children:W(Ot,{snap:r})})]}),l&&!n&&z(`tr`,{className:`bg-surface/50`,children:[W(`td`,{}),W(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2`,children:W(_,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})})]})]},t.deviceId)}),y.length===0&&W(`tr`,{children:W(`td`,{colSpan:n?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function Ct({state:e,onlineNodes:t,pending:n,onChange:r}){let i=e.pinned&&e.nodeId?e.nodeId:`auto`,a=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return z(`select`,{value:i,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[W(`option`,{value:`auto`,children:`Auto`}),a.map(e=>z(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function wt({state:e}){if(!e.active||!e.nodeId)return W(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let t=e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`;return z(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[W(`span`,{className:`font-mono text-[11px] text-foreground truncate`,title:e.nodeId,children:e.nodeId}),W(`span`,{className:`truncate ${e.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:t,children:t})]})}function Tt({role:e,state:t,mode:n,onlineNodes:r,isMenuOpen:i,onToggleMenu:a,onCloseMenu:o,onMove:s,onUnpin:c}){let l=bt[e],u=r.filter(e=>e.id!==(t.nodeId??``)),d=(t.active||n===`cluster`)&&(u.length>0||t.pinned);return z(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[z(`div`,{className:`flex items-center gap-2 min-w-0`,children:[W(n===`agent`?Et:Dt,{state:t,Icon:l}),W(`div`,{className:`ml-auto shrink-0`,children:d&&W(`button`,{type:`button`,onClick:a,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${xt[e]} actions`,children:W(ot,{className:`h-3 w-3 text-foreground-subtle`})})})]}),i&&d&&W(kt,{title:xt[e],targets:u,pinned:t.pinned,onMove:s,onUnpin:c,onClose:o})]})}function Et({state:e,Icon:t}){return z(`div`,{className:`flex items-center gap-1.5`,children:[W(e.active?Le:Re,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),W(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&W(lt,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Dt({state:e,Icon:t}){return!e.active||!e.nodeId?z(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[W(t,{className:`h-3 w-3`}),W(`span`,{className:`text-[10px] italic`,children:`—`})]}):z(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[W(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),z(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[W(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),W(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?z(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[W(lt,{className:`h-2.5 w-2.5`}),` manual`]}):z(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}function Ot({snap:e}){if(!e)return W(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:i,configuredFps:a,droppedFrames:o}=e.metrics,s=d(t);return z(`div`,{className:`flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0`,children:[z(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${s.textColor}`,children:[W(C,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),W(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:s.label})]}),z(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[W(`span`,{className:`text-foreground`,children:n.toFixed(1)}),z(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),z(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[W(`span`,{className:`text-foreground`,children:r.toFixed(0)}),W(`span`,{children:` ms`}),i>0&&z(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]}),z(`span`,{className:`whitespace-nowrap truncate ${o>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,W(`span`,{className:`text-foreground`,children:o})]})]})}function kt({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=_e(null);return G(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),z(`div`,{ref:o,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[W(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&W(`div`,{className:`py-1`,children:t.map(e=>z(`button`,{type:`button`,onClick:()=>r(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),n&&z(`button`,{type:`button`,onClick:i,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),t.length===0&&!n&&W(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function At({nodeId:e,refreshToken:t}){return z(`div`,{className:`space-y-6`,children:[W(_t,{refreshToken:t,nodeId:e}),z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),W(St,{mode:`agent`,nodeId:e,compact:!0})]})}R();function jt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Mt({nodeId:e,refreshToken:t}){let n=H(),r=c({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:i}=v({nodeId:e}),a=P(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??i??null,o=a===null;Ze([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:s}=de({nodeId:e}),{values:l}=w(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),u=B(()=>l.filter(e=>e.metrics.phase===`active`).length,[l]),d=t=>{let n=s??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||r.mutate({nodeId:e,engine:t,force:n.length>0})};return z(`div`,{className:`space-y-6`,children:[z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(a??[]).length,` engine(s) resident in RAM. `,(s??[]).length,` `,`camera(s) attached, `,u,` actively dispatching frames. Refreshes every 5s.`]})]}),W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[640px]`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[W(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),W(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),W(`th`,{className:`text-left px-3 py-2`,children:`Models`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),W(`th`,{className:`w-20`})]})}),z(`tbody`,{children:[o&&W(`tr`,{children:W(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!o&&(a??[]).map(e=>{let t=e.kind===`warm-override`;return z(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:``}`,children:[W(`td`,{className:`px-3 py-2`,children:z(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:`bg-success/15 text-success`}`,children:[W(t?ct:q,{className:`h-3 w-3`}),t?`warm`:`runtime`]})}),W(`td`,{className:`px-3 py-2`,children:z(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[W(ke,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),W(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?W(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):W(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>W(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),W(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),W(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?W(`span`,{className:`text-foreground-subtle`,children:jt(e.idleMs,e.idleTtlMs)}):W(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(s??[]).length}),W(`td`,{className:`px-3 py-2 text-right`,children:z(`button`,{type:`button`,disabled:r.isPending,onClick:()=>d(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[W(Je,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!o&&(a??[]).length===0&&W(`tr`,{children:W(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),z(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[W(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,W(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`]}),r.isError&&z(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,r.error instanceof Error?r.error.message:`unknown`]})]})}R();var Nt=new Set(be);function Pt(e){return Nt.has(e)}function Ft(e,t,n){return`${e}/${t}/${n}`}function It(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Lt(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function Q(e){return e.format}function Rt(e,t){let n=0,r=0,i=0;for(let a of e)for(let e of a.addons)for(let a of e.models){let e=a.formats[t];e&&(n++,e.downloaded&&(r++,i+=e.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:i}}function zt({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?z(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[W(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),z(`div`,{className:`flex-1 min-w-0`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),z(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&z(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[W(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:W(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),z(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),W(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:it(c.sizeMB)}),a&&z(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[W(Ke,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?z(`button`,{onClick:s,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[r?W(J,{className:`h-3 w-3 animate-spin`}):W(Je,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):z(`button`,{onClick:o,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[r?W(J,{className:`h-3 w-3 animate-spin`}):W(Se,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function Bt({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=U(!1);return z(`div`,{className:`relative`,children:[z(`button`,{type:`button`,onClick:()=>a(!i),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[W(q,{className:`h-4 w-4 text-primary shrink-0`}),z(`div`,{className:`flex-1 min-w-0`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium text-foreground`,children:It(n)}),Q(n)===Q(t)&&W(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:Lt(n)})]}),W(Ue,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&W(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=Q(e)===Q(n),o=Q(e)===Q(t);return z(`button`,{type:`button`,onClick:()=>{r(e),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${i?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[W(q,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),z(`div`,{className:`flex-1`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:It(e)}),o&&W(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:Lt(e)})]}),i&&W(ze,{className:`h-4 w-4 text-primary shrink-0`})]},Q(e))})})]})}function Vt({embedded:e=!1,nodeId:t}={}){let r=H(),i=t??`hub`,[a,o]=U(null),[s,c]=U(new Set),[l,u]=U(new Map),[d,p]=U(new Map),[m,g]=U(``),{data:_=[]}=he({nodeId:i}),v=_.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:b}=y({nodeId:i}),x=b,{data:S,isLoading:C}=n({nodeId:i}),w=h(),T=f();L(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,i=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||i===void 0||(u(e=>{let t=new Map(e);return i===100||i===-1?t.delete(n):t.set(n,{modelId:n,progress:i,totalMB:a}),t}),i===100&&r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let E=x??{runtime:`node`,backend:`cpu`,format:`onnx`},D=v.find(e=>e.format===a)??E,O=D.format,k=S?.slots??[],A=k.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[O]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),j=Rt(A,O),M=ge(async(e,t,n)=>{if(!Pt(n))return;let a=Ft(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await w.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[w,r,i]),N=ge(async(e,t,n)=>{if(!Pt(n))return;let a=Ft(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await T.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[T,r,i]),P=ge(e=>{o(e.format)},[]),F=m.trim()?A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(m.toLowerCase())||t.id.toLowerCase().includes(m.toLowerCase())||e.name.toLowerCase().includes(m.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):A,I=z(V,{children:[C&&W(`div`,{className:`flex items-center justify-center py-16`,children:W(J,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!C&&k.length===0&&z(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[W(Ce,{className:`h-8 w-8 mb-3 opacity-30`}),W(`span`,{className:`text-sm`,children:`No pipeline steps available`}),W(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!C&&k.length>0&&z(V,{children:[W(Bt,{engines:v,activeEngine:E,viewEngine:D,onSelect:P}),z(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[z(`span`,{children:[W(`span`,{className:`font-semibold text-foreground tabular-nums`,children:j.total}),W(`span`,{className:`ml-1`,children:`compatible models`})]}),W(`span`,{className:`text-border`,children:`|`}),z(`span`,{children:[W(`span`,{className:`font-semibold text-success tabular-nums`,children:j.downloaded}),W(`span`,{className:`ml-1`,children:`downloaded`})]}),W(`span`,{className:`text-border`,children:`|`}),z(`span`,{className:`tabular-nums`,children:[it(j.downloadedSizeMB),W(`span`,{className:`ml-1`,children:`on disk`})]})]}),j.total>5&&z(`div`,{className:`relative`,children:[W(Fe,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),W(`input`,{type:`text`,value:m,onChange:e=>g(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),F.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+t.models.filter(e=>e.formats[O]?.downloaded).length,0);return z(`div`,{children:[z(`div`,{className:`flex items-center gap-2 mb-2`,children:[W(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),W(`div`,{className:`flex-1 h-px bg-border`}),z(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),W(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=Ft(e.id,t.id,O);return W(zt,{addonId:e.id,model:t,format:O,isActive:s.has(n),progress:l.get(t.id),errorMsg:d.get(n),onDownload:()=>M(e.id,t.id,O),onDelete:()=>N(e.id,t.id,O)},`${e.id}/${t.id}`)}))})]},e.id)}),F.length===0&&W(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:m.trim()?z(V,{children:[`No models matching “`,m,`”`]}):z(V,{children:[`No models available for `,It(D),` format`]})})]})]});return e?W(`div`,{className:`space-y-4`,children:I}):W(Xe,{children:I})}function Ht({nodeId:e,refreshToken:t}){return W(Vt,{embedded:!0,nodeId:e})}var Ut=[{concern:`pipeline`,label:`Pipeline`,advisory:!1},{concern:`audio`,label:`Audio`,advisory:!1},{concern:`decode`,label:`Decode`,advisory:!0,advisoryNote:`Advisory: decode currently runs co-located with the stream source (hub). Pins are stored and take effect with Phase-2 stream load-balancing.`}];function Wt(e,t){return e.filter(e=>e.currentNodeId!==t)}var Gt=`This node is not decoder-enabled (enabledDecoderNodes). Pinning detection here strands frames (0 fps) until frame-source-aware placement ships. Enable decode on this node first, or pick a decoder-enabled node.`;function Kt(e,t,n){return t.includes(e)?{verdict:`ok`}:n?{verdict:`warn`,reason:Gt}:{verdict:`block`,reason:Gt}}R();var qt=`pipeline-orchestrator`,Jt=`enabledDecoderNodes`;function Yt(e,t){if(!e||typeof e!=`object`)return;let n=e.sections;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e.fields;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(n.key!==t)continue;let r=n.value;return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0}}}function Xt({nodeId:e,nodeName:t,concern:n,open:r,onClose:i}){let a=H(),o=je(),s=T(void 0),c=se(void 0),d=S(void 0),f=F({addonId:qt}),p=l(),m=ae(),h=u(),[g,_]=U(new Set),[v,y]=U(!1),[b,x]=U(null),[C,w]=U([]),[E,D]=U(null),O=Ut.find(e=>e.concern===n),k=B(()=>{let e=new Map;if(n===`pipeline`)for(let t of s.data??[])e.set(t.deviceId,t.agentNodeId);else if(n===`decode`)for(let t of c.data??[])e.set(t.deviceId,t.decoderNodeId);else for(let t of d.data??[])e.set(t.deviceId,t.nodeId);return e},[n,s.data,c.data,d.data]),A=B(()=>(o.data??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,currentNodeId:k.get(e.id)??null})),[o.data,k]),j=B(()=>Wt(A,e),[A,e]),M=Yt(f.data,Jt),N=n===`pipeline`?Kt(e,M??[],!1):{verdict:`ok`},[P,I]=U(!1);if(!r)return null;let ee=N.verdict===`block`,te=N.verdict===`warn`&&!P,L=g.size>0&&!v&&!ee&&!te,ne=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},re=j.length>0&&j.every(e=>g.has(e.deviceId)),ie=()=>{_(re?new Set:new Set(j.map(e=>e.deviceId)))},oe=async t=>{n===`pipeline`?await p.mutateAsync({deviceId:t,agentNodeId:e}):n===`decode`?await m.mutateAsync({deviceId:t,nodeId:e}):await h.mutateAsync({deviceId:t,nodeId:e})},ce=new Map(A.map(e=>[e.deviceId,e.name]));return z(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[W(`div`,{className:`absolute inset-0 bg-black/60`,onClick:i}),z(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col h-[80vh] rounded-xl border border-border bg-background shadow-2xl`,children:[z(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[z(`div`,{className:`min-w-0`,children:[z(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Batch assign `,O?.label??n,` → `,t]}),z(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:[`Pick the cameras whose `,O?.label.toLowerCase()??n,` should run on this node.`]})]}),W(`button`,{type:`button`,onClick:i,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,"aria-label":`Close`,children:W(Ge,{className:`h-4 w-4`})})]}),z(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[O?.advisory&&O.advisoryNote&&W(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2 shrink-0`,children:z(`div`,{className:`flex items-start gap-2`,children:[W(qe,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),W(`p`,{className:`text-[11px] text-warning`,children:O.advisoryNote})]})}),N.verdict!==`ok`&&W(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2 shrink-0`,children:z(`div`,{className:`flex items-start gap-2`,children:[W(qe,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),z(`div`,{className:`min-w-0`,children:[W(`p`,{className:`text-[11px] text-destructive`,children:N.reason}),N.verdict===`warn`&&z(`label`,{className:`mt-1 flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[W(`input`,{type:`checkbox`,checked:P,onChange:e=>I(e.target.checked),className:`accent-primary`}),`I understand — assign anyway`]})]})]})}),j.length>0&&z(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle shrink-0`,children:[W(`input`,{type:`checkbox`,"aria-label":`Select all`,checked:re,onChange:ie,className:`accent-primary`}),`Select all (`,j.length,`)`]}),W(`div`,{className:`flex-1 min-h-0 overflow-y-auto rounded-lg border border-border divide-y divide-border`,children:j.length===0?z(`div`,{className:`px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:[`No eligible cameras — all cameras are already assigned to `,t,`.`]}):j.map(e=>z(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground hover:bg-surface-hover cursor-pointer`,children:[W(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:g.has(e.deviceId),onChange:()=>ne(e.deviceId),className:`accent-primary`}),W(`span`,{className:`truncate`,children:e.name}),e.currentNodeId&&z(`span`,{className:`ml-auto text-[10px] text-foreground-subtle shrink-0`,children:[`on `,e.currentNodeId]})]},e.deviceId))}),(E!==null||C.length>0)&&z(`div`,{className:`space-y-1 text-[10px] shrink-0`,children:[E!==null&&E>0&&z(`p`,{className:`text-success`,children:[`Assigned `,E,` camera(s) to `,t,`.`]}),C.map(e=>z(`p`,{className:`text-destructive`,children:[e.name,`: `,e.message]},e.deviceId))]})]}),z(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[W(`span`,{className:`text-[10px] text-foreground-subtle`,children:v&&b?`${b.done} / ${b.total}…`:``}),z(`div`,{className:`flex items-center gap-2`,children:[W(`button`,{type:`button`,onClick:i,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),z(`button`,{type:`button`,onClick:async()=>{let e=[...g];if(e.length===0)return;y(!0),w([]),D(null),x({done:0,total:e.length});let t=[],n=0;for(let r=0;r<e.length;r+=1){let i=e[r];try{await oe(i),n+=1}catch(e){t.push({deviceId:i,name:ce.get(i)??String(i),message:e instanceof Error?e.message:String(e)})}x({done:r+1,total:e.length})}y(!1),w(t),D(n),_(new Set),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},disabled:!L,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50 disabled:cursor-not-allowed`,children:[v&&W(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign `,g.size,` to `,t]})]})]})]})]})}R();function Zt({nodeId:e,title:t}){let{data:n}=je(),{data:r}=T(void 0),i=B(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=B(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[o,s]=U(new Map);L(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||s(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),G(()=>{if(o.size===0)return;let e=setInterval(()=>{s(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[o.size]);let c=B(()=>{let e=[];for(let t of o.values())a&&!a.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[o,a]);return c.length===0?z(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):z(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[z(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[W(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),W(`span`,{className:`text-[10px] text-foreground-subtle`,children:c.length})]}),W(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=d(e.metrics.phase);return z(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[W(C,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),W(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),W(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),W(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}var Qt={key:`maxCameras`,type:`slider`,label:`Max cameras`,description:`Hard cap on cameras the balancer may assign to this node.`,min:1,max:64,step:1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Unlimited`};R();var $t=350;function en(e){return typeof e==`number`&&e>0?Math.floor(e):null}function tn({value:e,pending:t,errorMessage:n,onCommit:i}){let[a,o]=U(e);G(()=>{o(e)},[e]);let s=_e(i);return s.current=i,G(()=>{if(a===e)return;let t=setTimeout(()=>s.current(a),$t);return()=>clearTimeout(t)},[a,e]),z(`div`,{className:`flex items-center gap-3 text-xs text-foreground`,children:[W(`div`,{className:`max-w-md flex-1`,children:W(r,{field:Qt,values:{maxCameras:a},disabled:t,onChange:(e,t)=>o(en(t))})}),t&&W(`span`,{className:`text-[10px] text-muted-foreground animate-pulse`,children:`Saving…`}),n&&z(`span`,{className:`text-[10px] text-destructive`,children:[`Save failed: `,n]})]})}R();var nn=[`pipeline-orchestrator`],rn=[`decoder`];function an(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function on({nodeId:e,refreshToken:t}){let r=H(),[i,a]=U(null),[c,l]=U(null),[u,d]=U(null),[f,p]=U(null),m=(o(void 0).data??[]).find(t=>t.id===e)?.name??e,h=n({nodeId:e},{refetchOnMount:`always`}),g=b({agentNodeId:e},{refetchOnMount:`always`}),_=()=>{r.invalidateQueries({queryKey:[[`addonSettings`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]})},v=ue({onSuccess:_}),y=ie({onSuccess:_}),x=s({onSuccess:e=>{_(),p(`Reset done — regenerated default model: ${e.regeneratedModelId}`)}}),S=()=>{window.confirm(`Reset ${m} to hardware-aware defaults?\n\nThis clears the node's global pipeline seed and every per-camera step override, then re-seeds from the hardware default. Existing per-camera customisations on this node are lost.`)&&(p(null),x.mutate({nodeId:e}))},C=h.data??null,w=g.data,T=C?.selectedEngine.format??`coreml`,E=B(()=>C?k(C):[],[C]),O=B(()=>[{agentNodeId:e,engineLabel:T}],[e,T]),A=(e,t)=>{let n=w?.addonDefaults[e];return!an(C,e)?.models.some(e=>!!e.formats[T])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId??`Auto`}:{kind:`disabled`}},j=i&&C?an(C,i.addonId):null,N=t=>{let n=w?.addonDefaults[t]??null;a({addonId:t,agentNodeId:e}),l(n)},P=(t,n)=>{if(!w)return;let r=w.addonDefaults[t],i=an(C,t);if(!r&&!i)return;let a={enabled:n,modelId:r?.modelId??i?.defaultModelId??``,settings:r?.settings??{}};v.mutate({agentNodeId:e,defaults:{...w.addonDefaults,[t]:a}})},F=()=>{a(null),l(null)},I=()=>{!c||!i||!w||v.mutate({agentNodeId:e,defaults:{...w.addonDefaults,[i.addonId]:c}},{onSuccess:F})};if(h.isLoading||g.isLoading)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading pipeline…`});if(h.error)return z(`div`,{className:`text-xs text-red-400`,children:[`Failed to load catalog: `,String(h.error)]});if(!C)return W(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog unavailable for this node (runner offline?).`});let te=i!==null&&j!==null&&c!==null,L=g.data?.maxCameras??null;return z(`div`,{className:`relative h-full w-full space-y-3`,children:[z(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[f&&W(`span`,{className:`text-emerald-400`,children:f}),x.isError&&W(`span`,{className:`text-red-400`,children:x.error instanceof Error?x.error.message:`Reset failed`}),W(`button`,{type:`button`,onClick:S,disabled:x.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's global pipeline seed + per-camera overrides and re-seed from the hardware default`,children:x.isPending?`Resetting…`:`Reset to default`})]}),W(Zt,{nodeId:e}),W(tn,{value:L,pending:y.isPending,errorMessage:y.isError?y.error instanceof Error?y.error.message:`Unknown error`:null,onCommit:t=>y.mutate({agentNodeId:e,maxCameras:t})}),W(at,{nodeId:e,addonIds:nn,level:`global`,sectionIds:rn}),z(`div`,{className:`flex items-center gap-2 text-xs`,children:[W(`span`,{className:`font-medium text-muted-foreground`,children:`Batch assign:`}),W(`button`,{type:`button`,onClick:()=>d(`pipeline`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Pipeline…`}),W(`button`,{type:`button`,onClick:()=>d(`audio`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Audio…`}),W(`button`,{type:`button`,onClick:()=>d(`decode`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs text-foreground-subtle hover:bg-surface-hover`,children:`Decode… (advisory)`})]}),u&&W(Xt,{nodeId:e,nodeName:m,concern:u,open:u!==null,onClose:()=>d(null)}),W(`div`,{className:te?`pr-[360px]`:``,children:E.length>0?W(D,{tree:E,agents:O,getCellState:A,onCellClick:N,selectedCell:i,onToggleEnabled:P}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),W(M,{open:te,onClose:F,title:j?.name??``,subtitle:i?`${i.agentNodeId} · ${T}`:``,footer:z(V,{children:[W(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:F,children:`Cancel`}),W(`button`,{type:`button`,disabled:!c||!i||v.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:I,children:v.isPending?`Saving…`:`Save`})]}),children:j&&c&&i&&W(ee,{mode:`agent`,addon:j,agentDefault:c,agentNodeId:i.agentNodeId,engineFormat:T,onChangeAgentConfig:e=>l(e)})})]})}var sn=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],cn=`decoder-nodeav`;function ln({nodeId:e,refreshToken:t}){let{data:n}=o(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??cn,i=[...sn,r];return z(`div`,{className:`flex flex-col h-full`,children:[W(gt,{nodeId:e,refreshToken:t}),W(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:W(at,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:W(At,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:W(on,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:W(Mt,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:W(Ht,{nodeId:e,refreshToken:t})}]})})]})}var un=`pipeline-orchestrator`,dn=`recorder`,fn=`recordingNodeId`,pn=[`ingestNode`,`recordingNode`,`audioNode`],mn=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline for assigned cameras`},{key:`decode`,label:`Decode`,hint:`Decodes video frames locally (advisory placement)`},{key:`audio`,label:`Audio`,hint:`Handles audio codec + analysis work`},{key:`ingest`,label:`Ingest`,hint:`Terminates camera ingest streams`}];function hn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function gn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function _n(e,t,n){let r=hn(e,t);return typeof r==`string`&&r.length>0?r:n}function vn(e,t,n){let r=hn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function yn(e,t){let n=gn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function bn(e,t){let n=gn(e,t);return typeof n==`string`&&n.length>0?n:null}function xn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:`Audio`}function Sn(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:`Node that runs singleton audio work`}function Cn(e,t){return t===`detect`?e.pipeline:e[t]}function wn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function Tn({capability:e,label:t,hint:n,nodeId:r,active:i,pending:a,layout:o,onToggle:s}){let c=i?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,l=o===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,u=i?Be:Ae;return z(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} capability for ${r}`,title:`${t} — ${n}`,disabled:a,onClick:()=>s(e,!i),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${c} ${l}`,children:[W(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),W(`span`,{children:t})]})}R();function En({nodeId:e,value:t,pending:n,onCommit:r}){let[i,a]=U(t===null?``:String(t));G(()=>{a(t===null?``:String(t))},[t]);let o=()=>{let t=Number(i);r(e,Number.isFinite(t)&&t>0?Math.floor(t):null)};return W(`input`,{"aria-label":`Max cameras for ${e}`,type:`number`,min:0,step:1,placeholder:`∞`,value:i,disabled:n,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&o()},className:`w-20 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`})}function Dn({node:e,emphasis:t=!1}){let n=e.isHub?Ie:q;return z(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[W(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),W(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),z(`div`,{className:`min-w-0`,children:[z(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[W(`span`,{className:`truncate`,children:e.name}),e.isHub&&W(I,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&W(I,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),W(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}R();function On({nodeId:e,value:t,detectedHosts:n,pending:r,onCommit:i}){let[a,o]=U(t??``);G(()=>{o(t??``)},[t]);let s=n[0],c=s===void 0?`auto-detect`:`auto: ${s}`,l=()=>{let t=a.trim();i(e,t.length>0?t:null)};return W(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:c,value:a,disabled:r,onChange:e=>o(e.target.value),onBlur:l,onKeyDown:e=>{e.key===`Enter`&&l()},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`})}R();function kn({nodeId:e,weight:t,totalWeight:n,pending:r,onCommit:i}){let[a,o]=U(String(t));G(()=>{o(String(t))},[t]);let s=n>0?t/n:0,c=2*Math.PI*15,l=c*s,u=()=>{let t=Number(a);i(e,Number.isFinite(t)&&t>0?t:null)};return z(`div`,{className:`flex items-center gap-3`,children:[z(`svg`,{viewBox:`0 0 40 40`,className:`h-11 w-11 shrink-0`,"aria-hidden":`true`,children:[W(`circle`,{cx:`20`,cy:`20`,r:15,fill:`none`,className:`stroke-border`,strokeWidth:`4`}),W(`circle`,{cx:`20`,cy:`20`,r:15,fill:`none`,className:`stroke-primary transition-all`,strokeWidth:`4`,strokeDasharray:`${l} ${c-l}`,strokeLinecap:`round`,transform:`rotate(-90 20 20)`}),z(`text`,{x:`20`,y:`23`,textAnchor:`middle`,className:`fill-foreground text-[9px] font-bold`,children:[Math.round(s*100),`%`]})]}),W(`input`,{"aria-label":`Detect weight for ${e}`,type:`number`,min:0,step:.25,value:a,disabled:r,onChange:e=>o(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&u()},className:`w-20 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`})]})}function An({label:e,children:t}){return z(`div`,{className:`flex items-center justify-between gap-3`,children:[W(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function jn({node:e,actions:t}){return z(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[W(Dn,{node:e,emphasis:!0}),W(`div`,{className:`grid grid-cols-2 gap-2`,children:mn.map(n=>W(Tn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:Cn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),z(`div`,{className:`space-y-3 border-t border-border pt-3`,children:[W(An,{label:`Detect weight`,children:e.effective.pipeline?W(kn,{nodeId:e.id,weight:e.weight,totalWeight:t.totalWeight,pending:t.weightPending,onCommit:t.onCommitWeight}):W(`span`,{className:`text-[11px] italic text-foreground-subtle`,children:`Detect off`})}),W(An,{label:`Max cameras`,children:W(En,{nodeId:e.id,value:e.maxCameras,pending:t.maxCamerasPending,onCommit:t.onCommitMaxCameras})}),W(An,{label:`Reachable host`,children:W(On,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,pending:t.reachableHostPending,onCommit:t.onCommitReachableHost})})]})]})}function Mn(){return z(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[z(`span`,{className:`inline-flex items-center gap-1.5`,children:[W(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),z(`span`,{className:`inline-flex items-center gap-1.5`,children:[W(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),z(`span`,{className:`inline-flex items-center gap-1.5`,children:[W(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),z(`span`,{className:`inline-flex items-center gap-1.5`,children:[W(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function Nn({nodes:e,actions:t}){return W(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:z(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[W(`thead`,{children:z(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[W(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),mn.map(e=>W(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),W(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Detect weight`}),W(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Max cameras`}),W(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),W(`tbody`,{children:e.map(e=>z(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[W(`td`,{className:`px-4 py-3 align-middle`,children:W(Dn,{node:e})}),mn.map(n=>W(`td`,{className:`px-3 py-3 text-center align-middle`,children:W(Tn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:Cn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),W(`td`,{className:`px-4 py-3 align-middle`,children:e.effective.pipeline?W(kn,{nodeId:e.id,weight:e.weight,totalWeight:t.totalWeight,pending:t.weightPending,onCommit:t.onCommitWeight}):W(`span`,{className:`text-[11px] italic text-foreground-subtle`,children:`Detect off`})}),W(`td`,{className:`px-4 py-3 align-middle`,children:W(En,{nodeId:e.id,value:e.maxCameras,pending:t.maxCamerasPending,onCommit:t.onCommitMaxCameras})}),W(`td`,{className:`px-4 py-3 align-middle`,children:W(On,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,pending:t.reachableHostPending,onCommit:t.onCommitReachableHost})})]},e.id))})]})})}function Pn({role:e,value:t,options:n,pending:r,onChange:i}){return z(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[W(`span`,{className:`text-xs font-semibold text-foreground`,children:xn(e)}),W(`select`,{value:t,disabled:r,onChange:t=>i(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:n.map(e=>W(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),W(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:Sn(e)})]})}function Fn({roleValues:e,options:t,pending:n,lowFpsEnabled:r,fpsMinThreshold:i,onRoleChange:a,onLowFpsToggle:o}){return z(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[pn.map(r=>W(Pn,{role:r,value:e[r],options:t,pending:n,onChange:a},r)),z(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[W(`input`,{type:`checkbox`,checked:r,disabled:n,onChange:e=>o(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),z(`span`,{className:`flex flex-col gap-0.5`,children:[W(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),z(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,r?`${i} fps`:`disabled`]})]})]})]})}R();function In(){let e=H(),{nodes:t}=oe(),n=ne(void 0),r=F({addonId:un}),i=F({addonId:dn}),a=()=>wn(e),o=A({onSuccess:a}),s=N({onSuccess:a}),c=ie({onSuccess:a}),l=te({onSuccess:a}),u=re({onSuccess:a}),d=B(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),f=B(()=>t.map(e=>{let t=d.get(e.id),n=pt(t,e.isHub),r=yn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:yn(t,`maxCameras`),reachableHost:bn(t,`reachableHost`),detectedHosts:e.localIps}}),[t,d]),p=f.filter(e=>e.effective.pipeline).reduce((e,t)=>e+t.weight,0),m={ingestNode:_n(r.data,`ingestNode`,`hub`),recordingNode:_n(i.data,fn,`hub`),audioNode:_n(r.data,`audioNode`,`hub`)},h=B(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...pn.map(e=>m[e]),...e])].filter(e=>e.length>0)},[t,m]),g=vn(r.data,`fpsMinThreshold`,0),_=g>0,v=n.isLoading||r.isLoading||i.isLoading,y=(e,t,n)=>{o.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){u.mutate({addonId:dn,patch:{[fn]:t}});return}u.mutate({addonId:un,patch:{[e]:t}})},x=e=>{u.mutate({addonId:un,patch:{fpsMinThreshold:e?Math.max(1,g):0}})},S={totalWeight:p,capabilityPending:o.isPending,weightPending:s.isPending,maxCamerasPending:c.isPending,reachableHostPending:l.isPending,onToggleCapability:y,onCommitWeight:(e,t)=>s.mutate({agentNodeId:e,detectWeight:t}),onCommitMaxCameras:(e,t)=>c.mutate({agentNodeId:e,maxCameras:t}),onCommitReachableHost:(e,t)=>l.mutate({agentNodeId:e,reachableHost:t})};return z(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[z(`header`,{className:`flex items-start justify-between gap-4`,children:[z(`div`,{className:`space-y-1`,children:[W(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),W(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, tune relative detection weights, set per-node camera ceilings, and choose the singleton cluster roles. Weights are relative shares across detect-capable nodes.`})]}),v&&W(J,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),z(`div`,{className:`space-y-3`,children:[W(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),W(Fn,{roleValues:m,options:h,pending:u.isPending,lowFpsEnabled:_,fpsMinThreshold:g,onRoleChange:b,onLowFpsToggle:x})]}),z(`div`,{className:`space-y-3`,children:[z(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[W(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),W(Mn,{})]}),f.length===0?W(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No cluster nodes reporting yet.`}):z(V,{children:[W(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:f.map(e=>W(jn,{node:e,actions:S},e.id))}),W(`div`,{className:`hidden @3xl/clustertab:block`,children:W(Nn,{nodes:f,actions:S})})]})]})]})}R();var Ln=!1;function Rn({refreshToken:e}){let t=H(),{data:n}=o(void 0);B(()=>rt(n??[]),[n]);let r=O({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return z(`div`,{className:`space-y-6`,children:[W(_t,{refreshToken:e}),W(In,{}),Ln,z(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[z(`div`,{className:`min-w-0`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),W(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · decoder · audio assignments per camera. Click the kebab to pin / unpin / move any role; expand the chevron for the per-camera broker drill-down.`})]}),z(`button`,{type:`button`,onClick:()=>r.mutate(void 0),disabled:r.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[W(ke,{className:`h-3.5 w-3.5`}),r.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),W(St,{mode:`cluster`})]})}var zn=[`pipeline-orchestrator`];function Bn({refreshToken:e}){return W(`div`,{className:`space-y-4 max-w-3xl`,children:W(at,{nodeId:`hub`,addonIds:zn,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})})}R();function Vn({refreshToken:e}){let t=H(),{data:n,isLoading:r}=ce(),[i,a]=U(null),[o,s]=U(``),[c,l]=U(``),u=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},d=g({onSuccess:()=>{a(null),u()}}),f=x({onSuccess:u}),p=e=>{a(e.id),s(e.name),l(e.description??``)},m=()=>{a(null),s(``),l(``)},h=()=>{if(!i)return;let e=c.trim();d.mutate({id:i,name:o.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return W(`div`,{className:`space-y-6 max-w-4xl`,children:z(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[z(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),W(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),z(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?z(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[W(Ne,{className:`h-6 w-6 opacity-40`}),W(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):W(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return W(`li`,{className:`px-4 py-3 text-xs`,children:z(`div`,{className:`flex items-start gap-3`,children:[W(`div`,{className:`flex-1 min-w-0`,children:t?z(`div`,{className:`space-y-2`,children:[W(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:o,onChange:e=>s(e.target.value),placeholder:`Template name`,autoFocus:!0}),W(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:c,onChange:e=>l(e.target.value),placeholder:`Description (optional)`})]}):z(V,{children:[W(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&W(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),z(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,z(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),W(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?z(V,{children:[z(`button`,{type:`button`,onClick:h,disabled:d.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[W(Be,{className:`h-3 w-3`}),`Save`]}),z(`button`,{type:`button`,onClick:m,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[W(Ge,{className:`h-3 w-3`}),`Cancel`]})]}):z(V,{children:[W(`button`,{type:`button`,onClick:()=>p(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:W(Me,{className:`h-3 w-3`})}),W(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&f.mutate({id:e.id})},disabled:f.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:W(Je,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}R();function Hn(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function Un({nodeId:e,refreshToken:t}){let r=H(),i=xe().trpcClient,[a,s]=U(null),[c,l]=U(null),u=ne(void 0,{refetchOnMount:`always`});Ze([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`,`addon.updated`]);let d=o(void 0,{refetchOnMount:`always`}),f=B(()=>{let e=new Set;for(let t of d.data??[])t.isOnline&&e.add(t.id);return e},[d.data]),p=n({nodeId:e},{refetchOnMount:`always`}),m=B(()=>(u.data??[]).filter(e=>f.has(e.nodeId)).map(e=>e.nodeId),[u.data,f]),h=ye({enabled:m.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`schema-by-agent`,m.join(`,`),t],queryFn:async()=>{let e={};for(let t of m)try{e[t]=(await i.pipelineExecutor.getSchema.query({nodeId:t})).selectedEngine.format}catch{e[t]=`coreml`}return e}}),g=ue({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]}),r.invalidateQueries({queryKey:[[`addonSettings`]]})}}),_=B(()=>p.data?k(p.data):[],[p.data]),v=B(()=>{let e=u.data??[],t=f;return(t.size===0?[]:e.filter(e=>t.has(e.nodeId))).map(e=>{let t=h.data?.[e.nodeId];return{agentNodeId:e.nodeId,engineLabel:t??`(engine unknown)`}})},[u.data,h.data,f]),y=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e],r=h.data?.[t];return!Hn(p.data??null,e)?.models.some(e=>r!==void 0&&!!e.formats[r])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId??`Auto`}:{kind:`disabled`}},b=a?u.data?.find(e=>e.nodeId===a.agentNodeId)??null:null,x=a&&p.data?Hn(p.data,a.addonId):null,S=a?h.data?.[a.agentNodeId]??`coreml`:`coreml`,C=()=>{s(null),l(null)},w=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e]??null;s({addonId:e,agentNodeId:t}),l(n)},T=()=>{!c||!a||!b||g.mutate({agentNodeId:a.agentNodeId,defaults:{...b.settings.addonDefaults,[a.addonId]:c}},{onSuccess:C})};if(u.isLoading||p.isLoading)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading agents…`});if(!p.data)return z(`div`,{className:`text-xs text-foreground-subtle`,children:[`Catalog unavailable for `,e,`.`]});let E=a!==null&&x!==null&&c!==null;return z(`div`,{className:`relative h-full w-full space-y-3`,children:[W(Zt,{title:`Cluster cameras`}),W(`div`,{className:E?`pr-[360px]`:``,children:_.length>0&&v.length>0?W(D,{tree:_,agents:v,getCellState:y,onCellClick:w,selectedCell:a}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`No agents or catalog empty.`})}),W(M,{open:E,onClose:C,title:x?.name??``,subtitle:a?`${a.agentNodeId} · ${S}`:``,footer:z(V,{children:[W(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:C,children:`Cancel`}),W(`button`,{type:`button`,disabled:!c||!a||g.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:T,children:g.isPending?`Saving…`:`Save`})]}),children:x&&c&&a&&W(ee,{mode:`agent`,addon:x,agentDefault:c,agentNodeId:a.agentNodeId,engineFormat:S,onChangeAgentConfig:e=>l(e)})})]})}R();function Wn({types:n}){let r=H(),o=e(),{data:s}=p({}),c=i(),l=B(()=>c.data??[],[c.data]),[u,d]=U(null),[f,m]=U(null),h=()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},g=t({onSuccess:h}),_=a({onSuccess:h}),v=B(()=>{let e=new Map;for(let t of s??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[s]),y=e=>{e.isDefault||g.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},b=async e=>{if(e.isDefault){await o({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await o({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&_.mutate({id:e.id})},x=n.map(e=>l.find(t=>t.id===e)).filter(e=>e!==void 0);return z(`div`,{className:`space-y-3`,children:[x.length===0?W(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):x.map(e=>W(Te,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:v.get(e.id)??[],onAdd:e=>d(e),onEdit:e=>m(e),onDelete:e=>{b(e)},onSetDefault:e=>y(e)},e.id)),u!==null&&W(Ee,{initialType:u,onClose:()=>d(null),onCreated:()=>{h(),d(null)}}),f!==null&&W(we,{location:f,onClose:()=>m(null),onSaved:()=>{h(),m(null)}})]})}R();var Gn=`pipeline-analytics`;function Kn(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function qn(){let e=H(),{data:t}=o(void 0),{data:n,isLoading:r}=F({addonId:Gn}),i=Kn(n),a=re({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=B(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return z(`div`,{className:`flex flex-col gap-6`,children:[z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),W(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),z(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?W(J,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):W(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:Gn,patch:{postProcessingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>W(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&W(J,{className:`h-4 w-4 animate-spin text-primary`})]})]}),z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),W(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),W(Wn,{types:[`eventMedia`]})]})]})}R();var Jn=`recorder`;function Yn(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function Xn(){let e=H(),{data:t}=o(void 0),{data:n,isLoading:r}=F({addonId:Jn}),i=Yn(n,`recordingNodeId`,`hub`),a=re({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=B(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return z(`div`,{className:`flex flex-col gap-6`,children:[z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),W(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),z(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?W(J,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):W(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:Jn,patch:{recordingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>W(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&W(J,{className:`h-4 w-4 animate-spin text-primary`})]}),i!==`hub`&&z(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,W(`span`,{className:`font-medium`,children:i}),`. If the auto-derived host doesn't work, set the recorder's`,W(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),W(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),W(Wn,{types:[`recordings`,`recordingsLow`]})]})]})}R();var Zn=[{id:`assignments`,label:`Assignments`},{id:`pipeline`,label:`Pipeline`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`}];function Qn({refreshToken:e}){let[t,n]=U(`assignments`),{data:r}=o(void 0),i=r?.find(e=>e.isHub&&e.isOnline)?.id??r?.find(e=>e.isOnline)?.id??null;return z(`div`,{className:`flex flex-col h-full`,children:[z(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[W(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),W(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),W(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Zn.map(e=>W(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),z(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&W(Rn,{refreshToken:e}),t===`pipeline`&&(i?W(Un,{nodeId:i,refreshToken:e}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`No online node available — schema unreachable.`})),t===`events`&&W(qn,{}),t===`recording`&&W(Xn,{}),t===`settings`&&W(Bn,{refreshToken:e}),t===`templates`&&W(Vn,{refreshToken:e})]})]})}function $n(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}R();var er={healthy:`bg-green-500`,idle:`bg-yellow-400`,error:`bg-red-500`},tr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function nr({health:e}){return W(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${er[e]}`,title:tr[e],"aria-label":tr[e],role:`img`})}function rr({selectedDeviceId:e,onSelect:t}){let{data:n}=je(),{data:r}=le({}),i=B(()=>{let e=new Map;for(let t of r??[])e.set(t.deviceId,t);return e},[r]),a=B(()=>(n??[]).filter(e=>e.isCamera).map(e=>{let t=i.get(e.id);return{deviceId:e.id,name:e.name,health:t===void 0?`idle`:$n(t)}}),[n,i]);return a.length===0?W(`div`,{className:`px-4 py-6 text-center text-[11px] text-foreground-subtle italic`,children:`No cameras found`}):W(`ul`,{className:`divide-y divide-border`,children:a.map(n=>{let r=n.deviceId===e;return W(`li`,{children:z(`button`,{type:`button`,onClick:()=>t(n.deviceId),className:[`w-full flex items-center gap-2.5 px-4 py-3 text-left transition-colors`,r?`bg-surface-active text-foreground`:`hover:bg-surface-hover text-foreground-subtle hover:text-foreground`].join(` `),"aria-pressed":r,children:[W(nr,{health:n.health}),z(`span`,{className:`flex-1 min-w-0`,children:[W(`span`,{className:`block truncate text-[12px] font-medium leading-tight`,children:n.name}),z(`span`,{className:`block text-[10px] text-foreground-subtle leading-tight mt-0.5`,children:[`#`,n.deviceId]})]})]})},n.deviceId)})})}var ir=300,ar=158,or={camera:0,source:1,broker:2,decoder:3,motion:4,detection:4,audio:4,recorder:4};function $(e){return or[e]*ir}function sr(e,t){return e===null||t===null?!1:e!==t}function cr(e){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.reduce((e,t)=>e+t.inFps,0),r=e.profiles.reduce((e,t)=>e+t.outFps,0);return`${t} subs · ${n.toFixed(1)}→${r.toFixed(1)} fps`}function lr(e){return`${e.actualFps.toFixed(1)} fps · q${e.queueDepth} · ${e.avgInferenceMs.toFixed(1)}ms`}function ur(e){return`shm ${e.shm.getFrameHits+e.shm.getFrameMisses>0?Math.round(e.shm.getFrameHits/(e.shm.getFrameHits+e.shm.getFrameMisses)*100):0}% hit`}function dr(e){let t=[],n=[],r=e.decoder===null?0:[e.motion,e.detection,e.audio,e.recording].filter(e=>e!==null).length,i=r>1?(r-1)/2*ar:0,a={id:`camera`,kind:`camera`,nodeId:null,data:{deviceId:e.deviceId},position:{x:$(`camera`),y:i}};t.push(a);let o={id:`source`,kind:`source`,nodeId:null,data:{streams:e.source.streams},position:{x:$(`source`),y:i}};t.push(o),n.push({id:`camera->source`,source:`camera`,target:`source`,crossNode:!1});let s=e.broker;if(s!==null){let e={id:`broker`,kind:`broker`,nodeId:null,data:{profiles:s.profiles,webrtcSessions:s.webrtcSessions,rtspRestream:s.rtspRestream},position:{x:$(`broker`),y:i}};t.push(e),n.push({id:`source->broker`,source:`source`,target:`broker`,crossNode:!1})}let c=e.decoder;if(c!==null){let r={id:`decoder`,kind:`decoder`,nodeId:c.nodeId,data:{nodeId:c.nodeId,formats:c.formats,sessionCount:c.sessionCount,shm:c.shm},position:{x:$(`decoder`),y:i}};t.push(r);let a=s===null?`source`:`broker`,o=s===null?void 0:cr(s),l=s===null?ur(c):o;n.push({id:`${a}->decoder`,source:a,target:`decoder`,crossNode:sr(null,c.nodeId),...l===void 0?{}:{label:l}});let u=0,d=e.motion;if(d!==null){let e={id:`motion`,kind:`motion`,nodeId:null,data:{enabled:d.enabled,fps:d.fps},position:{x:$(`motion`),y:u*ar}};t.push(e),n.push({id:`decoder->motion`,source:`decoder`,target:`motion`,crossNode:!1}),u++}let f=e.detection;if(f!==null){let e={id:`detection`,kind:`detection`,nodeId:f.nodeId,data:{nodeId:f.nodeId,engine:f.engine,phase:f.phase,configuredFps:f.configuredFps,actualFps:f.actualFps,queueDepth:f.queueDepth,avgInferenceMs:f.avgInferenceMs,provisioning:f.provisioning},position:{x:$(`detection`),y:u*ar}};t.push(e),n.push({id:`decoder->detection`,source:`decoder`,target:`detection`,crossNode:sr(c.nodeId,f.nodeId),label:lr(f)}),u++}let p=e.audio;if(p!==null){let e={id:`audio`,kind:`audio`,nodeId:p.nodeId,data:{nodeId:p.nodeId,enabled:p.enabled},position:{x:$(`audio`),y:u*ar}};t.push(e),n.push({id:`decoder->audio`,source:`decoder`,target:`audio`,crossNode:sr(c.nodeId,p.nodeId)}),u++}let m=e.recording;if(m!==null){let e={id:`recorder`,kind:`recorder`,nodeId:null,data:{mode:m.mode,active:m.active,storageBytes:m.storageBytes},position:{x:$(`recorder`),y:u*ar}};t.push(e),n.push({id:`decoder->recorder`,source:`decoder`,target:`recorder`,crossNode:!1})}}return{nodes:t,edges:n}}R();function fr(e){let{data:t,isLoading:n}=j({deviceId:e}),[r,i]=U(void 0);return G(()=>{t!==void 0&&i(t)},[t]),L(K.PipelineCameraMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.detection===null?e:{...e,detection:{...e.detection,phase:n.metrics.phase,actualFps:n.metrics.actualFps,queueDepth:n.metrics.queueDepth,avgInferenceMs:n.metrics.avgInferenceTimeMs}})}),L(K.PipelineEngineProvisioning,e=>{let t=e.data;i(n=>{if(n===void 0||n.detection===null)return n;let r=n.detection.nodeId??n.assignment?.detectionNodeId??null;return r===null||e.source.type!==`node`||e.source.id!==r?n:{...n,detection:{...n.detection,provisioning:{state:t.state,error:t.error}}}})}),L(K.MotionAnalysis,t=>{t.source.type!==`device`||t.source.id!==e||i(e=>e===void 0||e.motion===null?e:{...e,motion:{...e.motion,enabled:!0}})}),L(K.StreamBrokerMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.broker===null?e:{...e,broker:{...e.broker,profiles:e.broker.profiles.map(e=>e.profile===n.profile?{...e,subscribers:n.stats.encodedSubscribers+n.stats.decodedSubscribers,inFps:n.stats.inputFps,outFps:n.stats.decodeFps}:e)}})}),L(K.PipelineAudioInferenceResult,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.audio===null?e:{...e,audio:{...e.audio,enabled:!0}})}),L(K.RecordingStarted,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!0}})}),L(K.RecordingStopped,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!1}})}),{status:r,isLoading:n}}function pr({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(X,{type:`source`,position:Y.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full bg-green-500 shrink-0`,"aria-label":`healthy`}),z(`span`,{className:`text-sm font-semibold truncate`,children:[`Camera #`,e.deviceId]})]}),W(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`source`})]})}function mr(e){return e>0?`bg-green-500`:`bg-yellow-500`}function hr({data:e}){let t=e.streams[0],n=e.streams.length;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(X,{type:`target`,position:Y.Left}),W(X,{type:`source`,position:Y.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${mr(n)}`,"aria-label":n>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Source`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[n,` streams`]})]}),t!==void 0&&z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t.codec,` `,t.width,`×`,t.height,` `,t.fps,`fps`]})]})}function gr(e){return e>0?`bg-green-500`:`bg-yellow-500`}function _r({data:e}){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.length;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(X,{type:`target`,position:Y.Left}),W(X,{type:`source`,position:Y.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${gr(t)}`,"aria-label":t>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Broker`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[n,` profiles`]})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t,` subs · WebRTC `,e.webrtcSessions,e.rtspRestream&&` · RTSP`]})]})}function vr(e){return e>0?`bg-green-500`:`bg-yellow-500`}function yr(e,t){let n=e+t;return n>0?Math.round(e/n*100):0}function br({data:e}){let t=yr(e.shm.getFrameHits,e.shm.getFrameMisses),n=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${n?` opacity-50`:``}`,children:[W(X,{type:`target`,position:Y.Left}),W(X,{type:`source`,position:Y.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${vr(e.sessionCount)}`,"aria-label":e.sessionCount>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Decoder`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),n&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.formats.join(`, `),` · `,e.sessionCount,` sessions`]}),z(`div`,{className:`text-xs text-muted-foreground`,children:[`shm `,t,`% hit`]})]})}function xr(e){return e?`bg-green-500`:`bg-yellow-500`}function Sr({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(X,{type:`target`,position:Y.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${xr(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),W(`span`,{className:`text-sm font-semibold`,children:`Motion`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.enabled?`enabled`:`disabled`,` · `,e.fps,` fps`]})]})}function Cr(e){return e.provisioning.state===`failed`?`bg-red-500`:e.phase===`active`?`bg-green-500`:(e.phase,`bg-yellow-500`)}function wr(e){return e===`ready`?`bg-green-500 text-white`:e===`failed`?`bg-red-500 text-white`:`bg-yellow-500 text-white`}function Tr({data:e}){let t=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[180px] px-3 py-2${t?` opacity-50`:``}`,children:[W(X,{type:`target`,position:Y.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Cr(e)}`,"aria-label":e.phase}),W(`span`,{className:`text-sm font-semibold`,children:`Detection`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.engine.backend,`·`,e.engine.device,` · `,e.phase]}),z(`div`,{className:`text-xs text-muted-foreground`,children:[e.actualFps.toFixed(1),`/`,e.configuredFps,` fps · q`,e.queueDepth,` ·`,` `,e.avgInferenceMs.toFixed(1),`ms`]}),z(`div`,{className:`flex items-center gap-1 mt-1`,children:[W(`span`,{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded ${wr(e.provisioning.state)}`,"aria-label":`provisioning ${e.provisioning.state}`,children:e.provisioning.state}),e.provisioning.state===`failed`&&e.provisioning.error!==void 0&&W(`span`,{className:`text-[10px] text-red-500 truncate`,children:e.provisioning.error})]})]})}function Er(e){return e?`bg-green-500`:`bg-yellow-500`}function Dr({data:e}){let t=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${t?` opacity-50`:``}`,children:[W(X,{type:`target`,position:Y.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Er(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),W(`span`,{className:`text-sm font-semibold`,children:`Audio`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),W(`div`,{className:`text-xs text-muted-foreground mt-1`,children:e.enabled?`enabled`:`disabled`})]})}function Or(e){return e.mode===`off`?`bg-red-500`:e.active?`bg-green-500`:`bg-yellow-500`}function kr(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:`${(e/1048576).toFixed(1)} MB`}function Ar({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(X,{type:`target`,position:Y.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Or(e)}`,"aria-label":e.active?`active`:e.mode===`off`?`off`:`inactive`}),W(`span`,{className:`text-sm font-semibold`,children:`Recorder`}),W(`span`,{className:`text-xs text-muted-foreground`,children:e.mode})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.active?`active`:`inactive`,` · `,kr(e.storageBytes)]})]})}R();var jr={camera:pr,source:hr,broker:_r,decoder:br,motion:Sr,detection:Tr,audio:Dr,recorder:Ar},Mr={stroke:`#f59e0b`,strokeWidth:2},Nr={strokeWidth:1.5},Pr=`camstack-pipeline-flow-layout`,Fr=`Camera → Source → Broker → Decoder → Motion · Detection · Audio · Recorder`,Ir={padding:.2};function Lr({deviceId:e}){let{status:t,isLoading:n}=fr(e),{data:r}=o(void 0),i=B(()=>{let e=new Set;for(let t of r??[])t.isOnline||e.add(t.id);return e},[r]),{computedNodes:a,rfEdges:s}=B(()=>{if(t===void 0)return{computedNodes:[],rfEdges:[]};let e=dr(t);return{computedNodes:e.nodes.map(e=>({id:e.id,type:e.kind,position:{x:e.position.x,y:e.position.y},data:{...e.data,offline:e.nodeId!==null&&i.has(e.nodeId)}})),rfEdges:e.edges.map(e=>({id:e.id,source:e.source,target:e.target,animated:e.crossNode,style:e.crossNode?Mr:Nr,label:e.label}))}},[t,i]),{nodes:c,onNodesChange:l,resetLayout:u}=tt(`${Pr}:${e}`,a);return n?W(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`Loading…`}):t===void 0?W(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`No pipeline data`}):z(`div`,{className:`w-full h-full relative overflow-hidden`,children:[z(`div`,{className:`absolute top-2 left-2 z-10 max-w-[calc(100%-7rem)] rounded border border-border bg-background/90 px-2 py-1 backdrop-blur-sm`,children:[W(`div`,{className:`text-xs font-semibold text-foreground`,children:`Pipeline flow`}),W(`div`,{className:`text-[10px] text-muted-foreground truncate`,children:Fr})]}),W(`button`,{type:`button`,onClick:u,className:`absolute top-2 right-2 z-10 text-xs px-2 py-1 rounded border border-border bg-background hover:bg-muted`,title:`Restore the automatic layout, discarding dragged positions`,children:`Reset layout`}),z(nt,{nodes:c,edges:s,onNodesChange:l,nodesDraggable:!0,nodeTypes:jr,fitView:!0,fitViewOptions:Ir,minZoom:.2,proOptions:{hideAttribution:!0},children:[W($e,{gap:20,size:1}),W(Qe,{showInteractive:!1})]})]})}R();var Rr=`__cluster__`;function zr(e){return e===`cameras`?`cameras`:`nodes`}function Br(){let[e,t]=Ve(),n=zr(e.get(`view`)),r=e.get(`node`)??`__cluster__`,i=e.get(`camera`),a=i===null?null:parseInt(i,10),[o,s]=U(0),[c,l]=U(!1);return G(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:Rr},{replace:!0})},[n,e,t]),z(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[z(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[z(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[W(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),W(`button`,{type:`button`,onClick:()=>{let e={view:`cameras`};a!==null&&(e.camera=String(a)),t(e,{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),z(`button`,{type:`button`,onClick:()=>s(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[W(Pe,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),z(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[z(`span`,{children:[c?`Hide`:`Show`,` `,n===`nodes`?`node list`:`camera list`]}),W(Ue,{className:[`h-4 w-4 transition-transform`,c?`rotate-180`:``].join(` `)})]}),W(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?z(V,{children:[W(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:W(ht,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),l(!1)},refreshToken:o})}),W(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?W(Qn,{refreshToken:o}):W(ln,{nodeId:r,refreshToken:o})})]}):z(V,{children:[W(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:W(rr,{selectedDeviceId:a,onSelect:e=>{t({view:`cameras`,camera:String(e)},{replace:!0}),l(!1)}})}),W(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:a!==null&&Number.isFinite(a)&&!Number.isNaN(a)?W(Lr,{deviceId:a}):W(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Select a camera to view its pipeline flow`})})]})})]})}export{Br as PipelinePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{V as e}from"./index-CdAVDEco.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
|