@camstack/addon-admin-ui 1.1.38 → 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.
Files changed (86) hide show
  1. package/dist/assets/{AddLocationWizard-6UQCTSu4.js → AddLocationWizard-C6d7Rl2b.js} +1 -1
  2. package/dist/assets/{AddonCollectionPage-C7y1Xqv4.js → AddonCollectionPage-6BdYLe6i.js} +1 -1
  3. package/dist/assets/Addons-DRZkv8if.js +1 -0
  4. package/dist/assets/{AdminTabs-Bn5jDw8C.js → AdminTabs-B163y6NF.js} +1 -1
  5. package/dist/assets/{BrokerForm-E7__Uhl9.js → BrokerForm-Blc6VNTn.js} +1 -1
  6. package/dist/assets/{Capabilities-DWu3W2I3.js → Capabilities-CMoqY-Ug.js} +1 -1
  7. package/dist/assets/{CapabilityBadges-D4uPGt_S.js → CapabilityBadges-khS3I08e.js} +1 -1
  8. package/dist/assets/Cluster-DUuIC1Di.js +1 -0
  9. package/dist/assets/{Dashboard-DRARX0g8.js → Dashboard-BUIPjBAI.js} +1 -1
  10. package/dist/assets/{Data-Cgi4uVIl.js → Data-CI9RNUqg.js} +1 -1
  11. package/dist/assets/{DetectionIntelligence-B-VvnmfI.js → DetectionIntelligence-BWjYUpoc.js} +1 -1
  12. package/dist/assets/DeviceDetail-ncfqxizt.js +2 -0
  13. package/dist/assets/{Devices-BFoz2HIh.js → Devices-BI0K3L20.js} +1 -1
  14. package/dist/assets/{EmbedPlayerPage-BY9eFyyg.js → EmbedPlayerPage-DTJcJ-K0.js} +1 -1
  15. package/dist/assets/{FormBuilder-CJrUV3p4.js → FormBuilder-Dq7rzw2g.js} +1 -1
  16. package/dist/assets/Identity-BClKA5CP.js +1 -0
  17. package/dist/assets/IntegrationDetail-CddIVuAg.js +1 -0
  18. package/dist/assets/{Integrations-Bj35Jpxj.js → Integrations-BqqLAeN1.js} +1 -1
  19. package/dist/assets/{Integrations-DpfC2qld.js → Integrations-Co_wJVPe.js} +1 -1
  20. package/dist/assets/{Logs-B2WAadmI.js → Logs-CBR7x9NW.js} +1 -1
  21. package/dist/assets/{MotionZonesSettings-3tt6mBQ0.js → MotionZonesSettings-BzuwNLPu.js} +1 -1
  22. package/dist/assets/{MyAccess-DXmHi-4Y.js → MyAccess-DN5XJRXk.js} +1 -1
  23. package/dist/assets/Network-DWjMAaiC.js +1 -0
  24. package/dist/assets/{NodeAddonsSettingsPanel-DTzycFzS.js → NodeAddonsSettingsPanel-DLEbHtxx.js} +1 -1
  25. package/dist/assets/{NotificationTargets-C3VSwqNL.js → NotificationTargets-BiiLAuNs.js} +1 -1
  26. package/dist/assets/Pipeline-CX07C-rk.js +1 -0
  27. package/dist/assets/{PrivacyMaskSettings-temQSWYL.js → PrivacyMaskSettings-B86k8eCd.js} +1 -1
  28. package/dist/assets/{ProviderIcon-DwFpv01K.js → ProviderIcon-BLTH0Ake.js} +1 -1
  29. package/dist/assets/{ScanNetworkModal-C6OLnfky.js → ScanNetworkModal-DVZ-75GA.js} +1 -1
  30. package/dist/assets/{Settings-BmZ2YcWY.js → Settings-EwkM7qrL.js} +1 -1
  31. package/dist/assets/{Showroom-CHFvHOSL.js → Showroom-ByaFbcYn.js} +1 -1
  32. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-xXz7MEuT.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CJNw3KPL.js} +1 -1
  33. package/dist/assets/addon-display-names-DvSEQty-.js +1 -0
  34. package/dist/assets/{build-cluster-graph-DIgt00ch.js → build-cluster-graph-QwpFUUjE.js} +2 -2
  35. package/dist/assets/circle-check-big-Ybrsd8CR.js +1 -0
  36. package/dist/assets/{copy-CpT57v81.js → copy-BwUimuA-.js} +1 -1
  37. package/dist/assets/dist-BAlJw4R3.js +7 -0
  38. package/dist/assets/{dist-B8dNOlY9.js → dist-DAY4wmmI.js} +1 -1
  39. package/dist/assets/{download-fsWmKUMh.js → download-DDSz9DfI.js} +1 -1
  40. package/dist/assets/{hostInit-sp7Rf71V.js → hostInit-8o1E_qzk.js} +1 -1
  41. package/dist/assets/index-ByJMV5aQ.js +4 -0
  42. package/dist/assets/index-DufitHjX.css +2 -0
  43. package/dist/assets/{key-round-0X280kmV.js → key-round-DH-NOckT.js} +1 -1
  44. package/dist/assets/{mf-entry-bootstrap-0-2b967ba8.js → mf-entry-bootstrap-0-a41549da.js} +2 -2
  45. package/dist/assets/{pencil-BlQGw-pI.js → pencil-D-LLTb5E.js} +1 -1
  46. package/dist/assets/{player-overlays-CpsGl45o.js → player-overlays-2Q1miaEN.js} +1 -1
  47. package/dist/assets/plus-BWeUQ-Wm.js +1 -0
  48. package/dist/assets/{radio-DO0Dq2MF.js → radio-DqOn-16x.js} +1 -1
  49. package/dist/assets/{refresh-cw-CMRlnF-M.js → refresh-cw-DuM6oiTl.js} +1 -1
  50. package/dist/assets/remoteEntry-zKeZuvbY.js +1 -0
  51. package/dist/assets/{rotate-ccw-CaH5zDeG.js → rotate-ccw-AVemYpzI.js} +1 -1
  52. package/dist/assets/rotate-cw-8j5op9rY.js +1 -0
  53. package/dist/assets/search-Cb4-y9a0.js +1 -0
  54. package/dist/assets/{server-CaW_paWO.js → server-BKvjFwOh.js} +1 -1
  55. package/dist/assets/{sparkles-D1oHkgOm.js → sparkles-UVx0u2KJ.js} +1 -1
  56. package/dist/assets/{square-check-big-D7lGfpqc.js → square-check-big-BUD8eXmE.js} +1 -1
  57. package/dist/assets/square-fxMkH5ka.js +1 -0
  58. package/dist/assets/src-CKNSRfvW.js +7 -0
  59. package/dist/assets/src-D37vd48r.js +67 -0
  60. package/dist/assets/{upload-7zSY3rlx.js → upload-B9TkBT8Q.js} +1 -1
  61. package/dist/assets/{useDevice-BwzYPnLK.js → useDevice-Dt2O2ZfS.js} +1 -1
  62. package/dist/assets/{useEventInvalidation-CETyyXeZ.js → useEventInvalidation-UIA6NlSS.js} +1 -1
  63. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DkH43QoX.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CsRvw1py.js} +2 -2
  64. package/dist/assets/{wifi-BeF9XXWL.js → wifi-C2e4NNeF.js} +1 -1
  65. package/dist/assets/{zap-abOrEOMQ.js → zap-C-u-esEw.js} +1 -1
  66. package/dist/index.html +6 -6
  67. package/dist/server/addon.js +45 -83
  68. package/package.json +1 -1
  69. package/dist/assets/Addons-BMHA1UvX.js +0 -1
  70. package/dist/assets/Cluster-dHKbt5S3.js +0 -1
  71. package/dist/assets/DeviceDetail-DiuVtjgW.js +0 -2
  72. package/dist/assets/Identity-B0ygozcS.js +0 -1
  73. package/dist/assets/IntegrationDetail-Brj01VUG.js +0 -1
  74. package/dist/assets/Network-CaKLSIvm.js +0 -1
  75. package/dist/assets/Pipeline-Cp7B8YFG.js +0 -1
  76. package/dist/assets/circle-check-big-wzEehng2.js +0 -1
  77. package/dist/assets/dist-DRenWL4F.js +0 -7
  78. package/dist/assets/index-CY52lvbZ.js +0 -4
  79. package/dist/assets/index-_8k1nh07.css +0 -2
  80. package/dist/assets/plus-DSiRMRVx.js +0 -1
  81. package/dist/assets/remoteEntry-BTav0B7H.js +0 -1
  82. package/dist/assets/rotate-cw-CCcZjC0U.js +0 -1
  83. package/dist/assets/search-CN_ccU_h.js +0 -1
  84. package/dist/assets/square-DWukmPnU.js +0 -1
  85. package/dist/assets/src-BXL7z3gT.js +0 -7
  86. package/dist/assets/src-BZ1dd5LI.js +0 -67
@@ -1 +0,0 @@
1
- import{Aa as e,Br as t,Ci as n,Di as r,Ei as i,Fr as a,Gr as o,Hr as s,Ia as c,Jr as l,Kr as u,Lr as d,Qi as f,Qr as p,Ra as m,Rr as h,T as g,Ti 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,fi as M,ia as N,it as P,ki as F,na as I,oi as L,ot as ee,pi as te,qr as ne,ra as re,ri as ie,sa as ae,si as oe,ti as se,ua as ce,ui as le,vi as ue,xi as de,yi as fe,zr as pe}from"./src-BZ1dd5LI.js";import{I as me,K as he,Q as R,S as z,T as ge,W as B,a as _e,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 ve}from"./src-BXL7z3gT.js";import{p as ye}from"./player-overlays-CpsGl45o.js";import{t as be}from"./download-fsWmKUMh.js";import{i as xe,n as Se,r as Ce,t as we}from"./AddLocationWizard-6UQCTSu4.js";import{n as Te,r as Ee,t as De}from"./zap-abOrEOMQ.js";import{i as Oe,r as ke}from"./useDevice-BwzYPnLK.js";import{t as Ae}from"./pencil-BlQGw-pI.js";import{t as je}from"./plus-DSiRMRVx.js";import{t as Me}from"./refresh-cw-CMRlnF-M.js";import{t as Ne}from"./search-CN_ccU_h.js";import{t as Pe}from"./server-CaW_paWO.js";import{t as Fe}from"./square-check-big-D7lGfpqc.js";import{t as Ie}from"./square-DWukmPnU.js";import{A as Le,F as Re,G as ze,M as Be,P as Ve,V as He,b as Ue,i as We,j as Ge,k as q,o as Ke,s as qe,w as Je,x as J}from"./index-CY52lvbZ.js";import{t as Ye}from"./AdminPage-BwmGKnRf.js";import{t as Xe}from"./useEventInvalidation-CETyyXeZ.js";import{a as Ze,c as Y,i as Qe,l as $e,o as X,r as et,s as tt,t as nt}from"./build-cluster-graph-DIgt00ch.js";import{n as rt}from"./format-size-CO9d3C3-.js";import{t as it}from"./NodeAddonsSettingsPanel-DTzycFzS.js";var at=He(`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`}]]),ot=He(`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`}]]),st=He(`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`}]]),ct=He(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),lt=He(`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:t,onSelect:n,refreshToken:r}){let{data:i}=a(void 0),{data:o}=T(void 0),{data:s}=L(void 0),c=new Map;for(let e of o??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=i??[],u=l.filter(e=>e.isOnline).length,d=l.filter(e=>!e.isOnline).length;return z(`div`,{className:`flex flex-col h-full`,children:[z(`button`,{type:`button`,onClick:()=>n(Lr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${t===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[W(Je,{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:l.map(r=>{let i=t===r.id,a=c.get(r.id)??0,o=r.isHub?Pe:q,l=mt(s,r.id,r.isHub),u=r.isOnline?null:m($e(r.lastSeen));return z(`button`,{type:`button`,onClick:()=>n(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.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:r.name}),r.isHub&&W(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!r.isOnline&&W(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),r.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:[r.cpuCores,` cores`]}),W(`span`,{children:`•`}),z(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a>0&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[W(Te,{className:`h-2.5 w-2.5`}),a]})]}),!r.isOnline&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),z(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[W(e,{variant:l.decode?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.decode?`Decode: enabled`:`Decode: not enabled (agent capability)`,children:`Dec`}),W(e,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),W(e,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},r.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:[u,` online`]}),d>0&&z(`span`,{className:`text-destructive`,children:[d,` offline`]})]})]})}function gt({nodeId:e,refreshToken:t}){let{data:n}=a(void 0),r=n?.find(t=>t.id===e),i=re(`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}=I();w(`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}=p(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:`Active / Attached`,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:`Active / Attached`,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:ot,audio:Ee},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);Xe([`pipelineOrchestrator`,`getPipelineAssignments`],yt),Xe([`pipelineOrchestrator`,`getDecoderAssignments`],yt),Xe([`pipelineOrchestrator`,`getAudioAssignments`],yt);let{data:f}=T(void 0),{data:p}=ie(void 0),{data:m}=S(void 0),{nodes:h}=I(),{data:_}=ke();w(`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 _??[])e.set(t.id,t.name);return e},[_]),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}),D=E({onSuccess:x}),O=ne({onSuccess:x}),k=fe({onSuccess:x}),A=u({onSuccess:x}),j=ue({onSuccess:x}),M=(e,t,n)=>{t===`pipeline`?C.mutate({deviceId:e,agentNodeId:n}):t===`decoder`?O.mutate({deviceId:e,nodeId:n}):A.mutate({deviceId:e,nodeId:n}),a(null)},N=(e,t)=>{t===`pipeline`?D.mutate({deviceId:e}):t===`decoder`?k.mutate({deviceId:e}):j.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(ge.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?Ve:Be,{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||D.isPending,onChange:e=>{e===`auto`?N(t.deviceId,`pipeline`):M(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=>M(t.deviceId,`pipeline`,e),onUnpin:()=>N(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=>M(t.deviceId,`decoder`,e),onUnpin:()=>N(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=>M(t.deviceId,`audio`,e),onUnpin:()=>N(t.deviceId,`audio`)})]}),W(`td`,{className:`px-3 py-2 align-middle`,children:W(kt,{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(g,{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(at,{className:`h-3 w-3 text-foreground-subtle`})})})]}),i&&d&&W(At,{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?Fe:Ie,{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`]})})]})]})}var Ot=`min-h-[3.25rem]`;function kt({snap:e}){if(!e)return W(`div`,{className:`flex items-center ${Ot}`,children: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=c(t);return z(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Ot}`,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 At({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=he(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 jt({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 Mt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Nt({nodeId:e,refreshToken:t}){let r=H(),i=s({onSettled:()=>{r.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:a}=v({nodeId:e}),o=re(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??a??null,c=o===null;Xe([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:l}=n({nodeId:e}),{values:u}=N(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),d=B(()=>u.filter(e=>e.metrics.phase===`active`).length,[u]),f=t=>{let n=l??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||i.mutate({nodeId:e,engine:t,force:n.length>0})};return 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:[(o??[]).length,` engine(s) resident in RAM. `,(l??[]).length,` `,`camera(s) attached, `,d,` 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:[c&&W(`tr`,{children:W(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!c&&(o??[]).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?st: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(De,{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:Mt(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?`—`:(l??[]).length}),W(`td`,{className:`px-3 py-2 text-right`,children:z(`button`,{type:`button`,disabled:i.isPending,onClick:()=>f(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[W(qe,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!c&&(o??[]).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.`]}),i.isError&&z(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,i.error instanceof Error?i.error.message:`unknown`]})]})}R();var Pt=new Set(ve);function Ft(e){return Pt.has(e)}function It(e,t,n){return`${e}/${t}/${n}`}function Lt(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Rt(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 zt(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 Bt({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:rt(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(Ge,{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(qe,{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(be,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function Vt({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:Lt(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:Rt(n)})]}),W(Ve,{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:Lt(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:Rt(e)})]}),i&&W(Le,{className:`h-4 w-4 text-primary shrink-0`})]},Q(e))})})]})}function Ht({embedded:e=!1,nodeId:n}={}){let r=H(),i=n??`hub`,[a,o]=U(null),[s,c]=U(new Set),[l,u]=U(new Map),[f,p]=U(new Map),[m,g]=U(``),{data:_=[]}=pe({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}=t({nodeId:i}),T=h(),E=d();w(`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 D=x??{runtime:`node`,backend:`cpu`,format:`onnx`},O=v.find(e=>e.format===a)??D,k=O.format,A=S?.slots??[],j=A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[k]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),M=zt(j,k),N=me(async(e,t,n)=>{if(!Ft(n))return;let a=It(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:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[T,r,i]),P=me(async(e,t,n)=>{if(!Ft(n))return;let a=It(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await E.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})}},[E,r,i]),F=me(e=>{o(e.format)},[]),I=m.trim()?j.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):j,L=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&&A.length===0&&z(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[W(xe,{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&&A.length>0&&z(V,{children:[W(Vt,{engines:v,activeEngine:D,viewEngine:O,onSelect:F}),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:M.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:M.downloaded}),W(`span`,{className:`ml-1`,children:`downloaded`})]}),W(`span`,{className:`text-border`,children:`|`}),z(`span`,{className:`tabular-nums`,children:[rt(M.downloadedSizeMB),W(`span`,{className:`ml-1`,children:`on disk`})]})]}),M.total>5&&z(`div`,{className:`relative`,children:[W(Ne,{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`})]}),I.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[k]?.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=It(e.id,t.id,k);return W(Bt,{addonId:e.id,model:t,format:k,isActive:s.has(n),progress:l.get(t.id),errorMsg:f.get(n),onDownload:()=>N(e.id,t.id,k),onDelete:()=>P(e.id,t.id,k)},`${e.id}/${t.id}`)}))})]},e.id)}),I.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 `,Lt(O),` format`]})})]})]});return e?W(`div`,{className:`space-y-4`,children:L}):W(Ye,{children:L})}function Ut({nodeId:e,refreshToken:t}){return W(Ht,{embedded:!0,nodeId:e})}var Wt=[{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 Gt(e,t){return e.filter(e=>e.currentNodeId!==t)}var Kt=`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 qt(e,t,n){return t.includes(e)?{verdict:`ok`}:n?{verdict:`warn`,reason:Kt}:{verdict:`block`,reason:Kt}}R();var Jt=`pipeline-orchestrator`,Yt=`enabledDecoderNodes`;function Xt(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 Zt({nodeId:e,nodeName:t,concern:n,open:r,onClose:i}){let a=H(),o=ke(),s=T(void 0),c=ie(void 0),d=S(void 0),f=P({addonId:Jt}),p=l(),m=ne(),h=u(),[g,_]=U(new Set),[v,y]=U(!1),[b,x]=U(null),[C,w]=U([]),[E,D]=U(null),O=Wt.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(()=>Gt(A,e),[A,e]),M=Xt(f.data,Yt),N=n===`pipeline`?qt(e,M??[],!1):{verdict:`ok`},[F,I]=U(!1);if(!r)return null;let L=N.verdict===`block`,ee=N.verdict===`warn`&&!F,te=g.size>0&&!v&&!L&&!ee,re=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ae=j.length>0&&j.every(e=>g.has(e.deviceId)),oe=()=>{_(ae?new Set:new Set(j.map(e=>e.deviceId)))},se=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(We,{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(Ke,{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(Ke,{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:F,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:ae,onChange:oe,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:()=>re(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 se(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:!te,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 Qt({nodeId:e,title:t}){let{data:n}=ke(),{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);w(`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 l=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 l.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:l.length})]}),W(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=c(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)})})]})}R();var $t=[`pipeline-orchestrator`],en=[`decoder`];function tn(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 nn({nodeId:e,refreshToken:n}){let r=H(),[i,s]=U(null),[c,l]=U(null),[u,d]=U(null),[f,p]=U(null),m=(a(void 0).data??[]).find(t=>t.id===e)?.name??e,h=t({nodeId:e},{refetchOnMount:`always`}),g=b({agentNodeId:e},{refetchOnMount:`always`}),_=()=>{r.invalidateQueries({queryKey:[[`addonSettings`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]})},v=le({onSuccess:_}),y=o({onSuccess:e=>{_(),p(`Reset done — regenerated default model: ${e.regeneratedModelId}`)}}),x=()=>{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),y.mutate({nodeId:e}))},S=h.data??null,C=g.data,w=S?.selectedEngine.format??`coreml`,T=B(()=>S?ce(S):[],[S]),E=B(()=>[{agentNodeId:e,engineLabel:w}],[e,w]),O=(e,t)=>{let n=C?.addonDefaults[e];return!tn(S,e)?.models.some(e=>!!e.formats[w])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId??`Auto`}:{kind:`disabled`}},A=i&&S?tn(S,i.addonId):null,j=t=>{let n=C?.addonDefaults[t]??null;s({addonId:t,agentNodeId:e}),l(n)},M=(t,n)=>{if(!C)return;let r=C.addonDefaults[t],i=tn(S,t);if(!r&&!i)return;let a={enabled:n,modelId:r?.modelId??i?.defaultModelId??``,settings:r?.settings??{}};v.mutate({agentNodeId:e,defaults:{...C.addonDefaults,[t]:a}})},N=()=>{s(null),l(null)},P=()=>{!c||!i||!C||v.mutate({agentNodeId:e,defaults:{...C.addonDefaults,[i.addonId]:c}},{onSuccess:N})};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(!S)return W(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog unavailable for this node (runner offline?).`});let F=i!==null&&A!==null&&c!==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}),y.isError&&W(`span`,{className:`text-red-400`,children:y.error instanceof Error?y.error.message:`Reset failed`}),W(`button`,{type:`button`,onClick:x,disabled:y.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:y.isPending?`Resetting…`:`Reset to default`})]}),W(Qt,{nodeId:e}),W(it,{nodeId:e,addonIds:$t,level:`global`,sectionIds:en}),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(Zt,{nodeId:e,nodeName:m,concern:u,open:u!==null,onClose:()=>d(null)}),W(`div`,{className:F?`pr-[360px]`:``,children:T.length>0?W(ae,{tree:T,agents:E,getCellState:O,onCellClick:j,selectedCell:i,onToggleEnabled:M}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),W(k,{open:F,onClose:N,title:A?.name??``,subtitle:i?`${i.agentNodeId} · ${w}`:``,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:N,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:P,children:v.isPending?`Saving…`:`Save`})]}),children:A&&c&&i&&W(D,{mode:`agent`,addon:A,agentDefault:c,agentNodeId:i.agentNodeId,engineFormat:w,onChangeAgentConfig:e=>l(e)})})]})}var rn=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],an=`decoder-nodeav`;function on({nodeId:e,refreshToken:t}){let{data:n}=a(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??an,i=[...rn,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(it,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:W(jt,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:W(nn,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:W(Nt,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:W(Ut,{nodeId:e,refreshToken:t})}]})})]})}var sn=`pipeline-orchestrator`,cn=`recorder`,ln=`recordingNodeId`,un=[`ingestNode`,`recordingNode`,`audioNode`],dn=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline for assigned cameras`},{key:`decode`,label:`Decode`,hint:`Decodes video frames locally (advisory placement)`}];function fn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function pn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function mn(e,t,n){let r=fn(e,t);return typeof r==`string`&&r.length>0?r:n}function hn(e,t,n){let r=fn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function gn(e,t){let n=pn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function _n(e,t){let n=pn(e,t);return typeof n==`string`&&n.length>0?n:null}function vn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:`Audio`}function yn(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 bn(e,t){return t===`detect`?e.pipeline:e[t]}function xn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function Sn({capability:e,label:t,hint:n,nodeId:r,active:i,pending:a,layout:o,onToggle:s}){let c=i?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,l=o===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,u=i?Re:Oe;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})]})}function Cn({node:t,emphasis:n=!1}){let r=t.isHub?Pe: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 ${t.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),W(r,{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 ${n?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[W(`span`,{className:`truncate`,children:t.name}),t.isHub&&W(e,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!t.isOnline&&W(e,{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:t.id})]})]})}R();function wn({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`})}function Tn({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 En({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(Cn,{node:e,emphasis:!0}),W(`div`,{className:`grid grid-cols-2 gap-2`,children:dn.map(n=>W(Sn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:bn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),W(`div`,{className:`space-y-3 border-t border-border pt-3`,children:W(Tn,{label:`Reachable host`,children:W(wn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,pending:t.reachableHostPending,onCommit:t.onCommitReachableHost})})})]})}function Dn(){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 On({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`}),dn.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:`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(Cn,{node:e})}),dn.map(n=>W(`td`,{className:`px-3 py-3 text-center align-middle`,children:W(Sn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:bn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),W(`td`,{className:`px-4 py-3 align-middle`,children:W(wn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,pending:t.reachableHostPending,onCommit:t.onCommitReachableHost})})]},e.id))})]})})}function kn({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:vn(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:yn(e)})]})}function An({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:[un.map(r=>W(kn,{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 jn(e,t,n){return Math.min(Math.max(e,t),n)}function Mn(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function Nn(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+(e[n]??0),0),o=jn(n,0,Math.max(0,100-a)),s=i.filter(e=>e!==t&&!r.has(e)),c=Math.max(0,100-o-a),l=s.reduce((t,n)=>t+(e[n]??0),0),u={...e,[t]:o};if(s.length>0)if(l>0)for(let t of s)u[t]=c*((e[t]??0)/l);else{let e=c/s.length;for(let t of s)u[t]=e}return u}function Pn({nodes:e,pending:t,onCommitWeight:n}){let[r,i]=U(()=>Mn(e)),[a,o]=U(new Set);G(()=>{i(Mn(e)),o(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let s=e.map(e=>e.id),c=e=>{o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},l=(e,t)=>{i(n=>Nn(n,e,t,a,s))},u=()=>{for(let t of e)n(t.id,Math.round(r[t.id]??0))};if(e.length===0)return 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 detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`});let d=e.length===1;return z(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=r[e.id]??0,i=a.has(e.id);return z(`div`,{className:`flex items-center gap-3`,children:[W(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),W(`input`,{"aria-label":`Detection weight for ${e.name}`,type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:t||i||d,onChange:t=>l(e.id,Number(t.target.value)),onPointerUp:u,onKeyUp:u,className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),z(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),W(`button`,{type:`button`,onClick:()=>c(e.id),disabled:t||d,"aria-pressed":i,title:i?`Unlock — allow rebalancing`:`Lock this share when others change`,className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${i?`text-amber-400`:`text-foreground-subtle`}`,children:W(i?Ue:ct,{className:`h-3.5 w-3.5`})})]},e.id)}),W(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:`Shares sum to 100%. Dragging one slider rebalances the unlocked nodes; lock a node to pin its share. Detection only distributes across nodes that can source a camera’s frames.`})]})}R();function Fn(){let e=H(),{nodes:t}=I(),n=L(void 0),r=P({addonId:sn}),i=P({addonId:cn}),a=()=>xn(e),o=A({onSuccess:a}),s=M({onSuccess:a}),c=te({onSuccess:a}),l=ee({onSuccess:a}),u=B(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),d=B(()=>t.map(e=>{let t=u.get(e.id),n=pt(t,e.isHub),r=gn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:gn(t,`maxCameras`),reachableHost:_n(t,`reachableHost`),detectedHosts:e.localIps}}),[t,u]),f=d.filter(e=>e.effective.pipeline),p={ingestNode:mn(r.data,`ingestNode`,`hub`),recordingNode:mn(i.data,ln,`hub`),audioNode:mn(r.data,`audioNode`,`hub`)},m=B(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...un.map(e=>p[e]),...e])].filter(e=>e.length>0)},[t,p]),h=hn(r.data,`fpsMinThreshold`,0),g=h>0,_=n.isLoading||r.isLoading||i.isLoading,v=(e,t,n)=>{o.mutate({agentNodeId:e,[t]:n})},y=(e,t)=>{if(e===`recordingNode`){l.mutate({addonId:cn,patch:{[ln]:t}});return}l.mutate({addonId:sn,patch:{[e]:t}})},b=e=>{l.mutate({addonId:sn,patch:{fpsMinThreshold:e?Math.max(1,h):0}})},x={capabilityPending:o.isPending,reachableHostPending:c.isPending,onToggleCapability:v,onCommitReachableHost:(e,t)=>c.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, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),_&&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(An,{roleValues:p,options:m,pending:l.isPending,lowFpsEnabled:g,fpsMinThreshold:h,onRoleChange:y,onLowFpsToggle:b})]}),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(Dn,{})]}),d.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:d.map(e=>W(En,{node:e,actions:x},e.id))}),W(`div`,{className:`hidden @3xl/clustertab:block`,children:W(On,{nodes:d,actions:x})})]})]}),z(`div`,{className:`space-y-3`,children:[W(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),W(Pn,{nodes:f,pending:s.isPending,onCommitWeight:(e,t)=>s.mutate({agentNodeId:e,detectWeight:t})})]})]})}R();var In=!1;function Ln({refreshToken:e}){let t=H(),{data:n}=a(void 0);B(()=>nt(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(Fn,{}),In,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(De,{className:`h-3.5 w-3.5`}),r.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),W(St,{mode:`cluster`})]})}var Rn=[`pipeline-orchestrator`];function zn({refreshToken:e}){return W(`div`,{className:`space-y-4 max-w-3xl`,children:W(it,{nodeId:`hub`,addonIds:Rn,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 Bn({refreshToken:e}){let t=H(),{data:n,isLoading:r}=oe(),[i,a]=U(null),[o,s]=U(``),[c,l]=U(``),u=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},d=de({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 g=[...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:[g.length,` template`,g.length===1?``:`s`]})]}),g.length===0?z(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[W(je,{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:g.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(Re,{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(We,{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(Ae,{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(qe,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}R();function Vn(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 Hn({nodeId:e,refreshToken:n}){let r=H(),i=ye().trpcClient,[o,s]=U(null),[c,l]=U(null),u=L(void 0,{refetchOnMount:`always`});Xe([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`,`addon.updated`]);let d=a(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=t({nodeId:e},{refetchOnMount:`always`}),m=B(()=>(u.data??[]).filter(e=>f.has(e.nodeId)).map(e=>e.nodeId),[u.data,f]),h=_e({enabled:m.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`schema-by-agent`,m.join(`,`),n],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=le({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]}),r.invalidateQueries({queryKey:[[`addonSettings`]]})}}),_=B(()=>p.data?ce(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!Vn(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=o?u.data?.find(e=>e.nodeId===o.agentNodeId)??null:null,x=o&&p.data?Vn(p.data,o.addonId):null,S=o?h.data?.[o.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||!o||!b||g.mutate({agentNodeId:o.agentNodeId,defaults:{...b.settings.addonDefaults,[o.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=o!==null&&x!==null&&c!==null;return z(`div`,{className:`relative h-full w-full space-y-3`,children:[W(Qt,{title:`Cluster cameras`}),W(`div`,{className:E?`pr-[360px]`:``,children:_.length>0&&v.length>0?W(ae,{tree:_,agents:v,getCellState:y,onCellClick:w,selectedCell:o}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`No agents or catalog empty.`})}),W(k,{open:E,onClose:C,title:x?.name??``,subtitle:o?`${o.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||!o||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&&o&&W(D,{mode:`agent`,addon:x,agentDefault:c,agentNodeId:o.agentNodeId,engineFormat:S,onChangeAgentConfig:e=>l(e)})})]})}R();function Un({types:e}){let t=H(),n=f(),{data:a}=r({}),o=i(),s=B(()=>o.data??[],[o.data]),[c,l]=U(null),[u,d]=U(null),p=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},m=F({onSuccess:p}),h=_({onSuccess:p}),g=B(()=>{let e=new Map;for(let t of a??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[a]),v=e=>{e.isDefault||m.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},y=async e=>{if(e.isDefault){await n({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 n({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&h.mutate({id:e.id})},b=e.map(e=>s.find(t=>t.id===e)).filter(e=>e!==void 0);return z(`div`,{className:`space-y-3`,children:[b.length===0?W(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):b.map(e=>W(Ce,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:g.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>d(e),onDelete:e=>{y(e)},onSetDefault:e=>v(e)},e.id)),c!==null&&W(we,{initialType:c,onClose:()=>l(null),onCreated:()=>{p(),l(null)}}),u!==null&&W(Se,{location:u,onClose:()=>d(null),onSaved:()=>{p(),d(null)}})]})}R();var Wn=`pipeline-analytics`;function Gn(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 Kn(){let e=H(),{data:t}=a(void 0),{data:n,isLoading:r}=P({addonId:Wn}),i=Gn(n),o=ee({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&&o.mutate({addonId:Wn,patch:{postProcessingNodeId:e.target.value}})},disabled:o.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))}),o.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(Un,{types:[`eventMedia`]})]})]})}R();var qn=`recorder`;function Jn(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 Yn(){let e=H(),{data:t}=a(void 0),{data:n,isLoading:r}=P({addonId:qn}),i=Jn(n,`recordingNodeId`,`hub`),o=ee({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&&o.mutate({addonId:qn,patch:{recordingNodeId:e.target.value}})},disabled:o.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))}),o.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(Un,{types:[`recordings`,`recordingsLow`]})]})]})}R();var Xn=[{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 Zn({refreshToken:e}){let[t,n]=U(`assignments`),{data:r}=a(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:Xn.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(Ln,{refreshToken:e}),t===`pipeline`&&(i?W(Hn,{nodeId:i,refreshToken:e}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`No online node available — schema unreachable.`})),t===`events`&&W(Kn,{}),t===`recording`&&W(Yn,{}),t===`settings`&&W(zn,{refreshToken:e}),t===`templates`&&W(Bn,{refreshToken:e})]})]})}function Qn(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 $n={healthy:`bg-green-500`,idle:`bg-yellow-400`,error:`bg-red-500`},er={healthy:`Healthy`,idle:`Idle`,error:`Error`};function tr({health:e}){return W(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${$n[e]}`,title:er[e],"aria-label":er[e],role:`img`})}function nr({selectedDeviceId:e,onSelect:t}){let{data:n}=ke(),{data:r}=se({}),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`:Qn(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(tr,{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 rr=300,ir=158,ar={camera:0,source:1,broker:2,decoder:3,motion:4,detection:4,audio:4,recorder:4};function $(e){return ar[e]*rr}function or(e,t){return e===null||t===null?!1:e!==t}function sr(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 cr(e){return`${e.actualFps.toFixed(1)} fps · q${e.queueDepth} · ${e.avgInferenceMs.toFixed(1)}ms`}function lr(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 ur(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*ir: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:sr(s),l=s===null?lr(c):o;n.push({id:`${a}->decoder`,source:a,target:`decoder`,crossNode:or(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*ir}};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*ir}};t.push(e),n.push({id:`decoder->detection`,source:`decoder`,target:`detection`,crossNode:or(c.nodeId,f.nodeId),label:cr(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*ir}};t.push(e),n.push({id:`decoder->audio`,source:`decoder`,target:`audio`,crossNode:or(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*ir}};t.push(e),n.push({id:`decoder->recorder`,source:`decoder`,target:`recorder`,crossNode:!1})}}return{nodes:t,edges:n}}R();function dr(e){let{data:t,isLoading:n}=j({deviceId:e}),[r,i]=U(void 0);return G(()=>{t!==void 0&&i(t)},[t]),w(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}})}),w(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}}}})}),w(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}})}),w(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)}})}),w(K.PipelineAudioInferenceResult,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.audio===null?e:{...e,audio:{...e.audio,enabled:!0}})}),w(K.RecordingStarted,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!0}})}),w(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 fr({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 pr(e){return e>0?`bg-green-500`:`bg-yellow-500`}function mr({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 ${pr(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 hr(e){return e>0?`bg-green-500`:`bg-yellow-500`}function gr({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 ${hr(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 _r(e){return e>0?`bg-green-500`:`bg-yellow-500`}function vr(e,t){let n=e+t;return n>0?Math.round(e/n*100):0}function yr({data:e}){let t=vr(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 ${_r(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 br(e){return e?`bg-green-500`:`bg-yellow-500`}function xr({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 ${br(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 Sr(e){return e.provisioning.state===`failed`?`bg-red-500`:e.phase===`active`?`bg-green-500`:(e.phase,`bg-yellow-500`)}function Cr(e){return e===`ready`?`bg-green-500 text-white`:e===`failed`?`bg-red-500 text-white`:`bg-yellow-500 text-white`}function wr({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 ${Sr(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 ${Cr(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 Tr(e){return e?`bg-green-500`:`bg-yellow-500`}function Er({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 ${Tr(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 Dr(e){return e.mode===`off`?`bg-red-500`:e.active?`bg-green-500`:`bg-yellow-500`}function Or(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:`${(e/1048576).toFixed(1)} MB`}function kr({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 ${Dr(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`,` · `,Or(e.storageBytes)]})]})}R();var Ar={camera:fr,source:mr,broker:gr,decoder:yr,motion:xr,detection:wr,audio:Er,recorder:kr},jr={stroke:`#f59e0b`,strokeWidth:2},Mr={strokeWidth:1.5},Nr=`camstack-pipeline-flow-layout`,Pr=`Camera → Source → Broker → Decoder → Motion · Detection · Audio · Recorder`,Fr={padding:.2};function Ir({deviceId:e}){let{status:t,isLoading:n}=dr(e),{data:r}=a(void 0),i=B(()=>{let e=new Set;for(let t of r??[])t.isOnline||e.add(t.id);return e},[r]),{computedNodes:o,rfEdges:s}=B(()=>{if(t===void 0)return{computedNodes:[],rfEdges:[]};let e=ur(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?jr:Mr,label:e.label}))}},[t,i]),{nodes:c,onNodesChange:l,resetLayout:u}=et(`${Nr}:${e}`,o);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:Pr})]}),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(tt,{nodes:c,edges:s,onNodesChange:l,nodesDraggable:!0,nodeTypes:Ar,fitView:!0,fitViewOptions:Fr,minZoom:.2,proOptions:{hideAttribution:!0},children:[W(Qe,{gap:20,size:1}),W(Ze,{showInteractive:!1})]})]})}R();var Lr=`__cluster__`;function Rr(e){return e===`cameras`?`cameras`:`nodes`}function zr(){let[e,t]=ze(),n=Rr(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:Lr},{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(Me,{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(Ve,{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(Zn,{refreshToken:o}):W(on,{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(nr,{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(Ir,{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{zr as PipelinePage};
@@ -1 +0,0 @@
1
- import{V as e}from"./index-CY52lvbZ.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};