@camstack/addon-admin-ui 1.2.719 → 1.2.720

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 (115) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/assets/{AccessSection-BDNf7fWa.js → AccessSection-DLcqIdIE.js} +1 -1
  3. package/dist/assets/Addons-Cqy437m_.js +5 -0
  4. package/dist/assets/{AdminPage-Cgexl7PK.js → AdminPage-B8wrcNpW.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-DeBFqnL9.js → AdminSectionedPage-BshPvazW.js} +1 -1
  6. package/dist/assets/AiProfiles-Bcs-HN_u.js +3 -0
  7. package/dist/assets/Archive-Dg-8ZFEk.js +1 -0
  8. package/dist/assets/{BootstrapSettingsForm-CQ3gKeRA.js → BootstrapSettingsForm-DrZ2Qxpr.js} +1 -1
  9. package/dist/assets/Build-DCEyOlh3.js +51 -0
  10. package/dist/assets/{Calendars-B2_pD0Oc.js → Calendars-CLOqo_A9.js} +1 -1
  11. package/dist/assets/Cluster-CWjdu2SA.js +1 -0
  12. package/dist/assets/{CompositionBlockEditor-QKA5nMCB.js → CompositionBlockEditor-BcAg9cd1.js} +2 -2
  13. package/dist/assets/{CompositionEditorPage-BsIycFw4.js → CompositionEditorPage-BkISVE7J.js} +1 -1
  14. package/dist/assets/Data-CjK1CJ6a.js +2 -0
  15. package/dist/assets/DeviceDetail-9JbRREF0.js +1 -0
  16. package/dist/assets/{Devices-DjJ2lZFz.js → Devices-Khov-G-p.js} +1 -1
  17. package/dist/assets/{EmbedDevicePage-B6jliGSU.js → EmbedDevicePage-BEgkFa13.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-DPSpe0fe.js → EmbedPlayerPage-yq9ib_WG.js} +1 -1
  19. package/dist/assets/History-BDzN5PSp.js +1 -0
  20. package/dist/assets/Identity-CQaHQdfp.js +1 -0
  21. package/dist/assets/InstancesTable-d_ArcJzn.js +1 -0
  22. package/dist/assets/IntegrationDetail-H5iG4cp4.js +1 -0
  23. package/dist/assets/{Integrations-BLSCtn93.js → Integrations-CIQ1TTLm.js} +2 -2
  24. package/dist/assets/Integrations-JSq4q6Yk.js +1 -0
  25. package/dist/assets/Library-D4AldvQF.js +1 -0
  26. package/dist/assets/Locations-DWOOuQIu.js +3 -0
  27. package/dist/assets/{Logs-C9YNGUTC.js → Logs-5nXs4_ea.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-DdB2to38.js → MaskShapeCanvas-BuhGkMAd.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-C0AZq1h1.js → MotionZonesSettings-taxdtueq.js} +1 -1
  30. package/dist/assets/MyAccess-HwIUJzaA.js +2 -0
  31. package/dist/assets/Network-B75AEe4T.js +1 -0
  32. package/dist/assets/NewExportModal-4pbJXUN7.js +1 -0
  33. package/dist/assets/{NodeAddonsSettingsPanel-DK5hH6AQ.js → NodeAddonsSettingsPanel-BWKFONDO.js} +1 -1
  34. package/dist/assets/Notifications-Dir45cKh.js +1 -0
  35. package/dist/assets/{PanelContent-DvRTzrSI.js → PanelContent-CjTOcp45.js} +2 -2
  36. package/dist/assets/Pipeline-dzujvaiX.js +1 -0
  37. package/dist/assets/{PrivacyMaskSettings-DMAeCCre.js → PrivacyMaskSettings-CUn9ND-1.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-yL3465Qt.js → SceneMonitorEditor-BmIPmhsF.js} +1 -1
  39. package/dist/assets/SessionsList-BJMw8pbD.js +2 -0
  40. package/dist/assets/{Showroom-C8uNo6FX.js → Showroom-oEYjHOaZ.js} +1 -1
  41. package/dist/assets/StorageLocationsTable-BWV3gXtd.js +1 -0
  42. package/dist/assets/System-YDUueTZD.js +2 -0
  43. package/dist/assets/TemplateEditorDialog-BACs8PgY.js +1 -0
  44. package/dist/assets/{Terminal-BSi5279J.js → Terminal-C-szbt5x.js} +5 -5
  45. package/dist/assets/{TrainingProviders-B5mWrv0H.js → TrainingProviders-CslXBK7R.js} +1 -1
  46. package/dist/assets/{Viewer-CVHhRxp4.js → Viewer-DjhhF28L.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BcuvvAg7.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CPbbpoxt.js} +1 -1
  48. package/dist/assets/{ai-page.helpers-CQuYVO3v.js → ai-page.helpers-DTU60-gO.js} +1 -1
  49. package/dist/assets/{assignment-candidates-BspACTRE.js → assignment-candidates-Su99quoq.js} +1 -1
  50. package/dist/assets/{authed-media-C1lGKHUu.js → authed-media-D2JT3vve.js} +1 -1
  51. package/dist/assets/{board-model-iKJIk-mi.js → board-model-C35BJaTl.js} +1 -1
  52. package/dist/assets/{camera-block-model-Cy-p9VXW.js → camera-block-model-D7ROcocN.js} +1 -1
  53. package/dist/assets/client-CPPa5guW.js +1136 -0
  54. package/dist/assets/{command-vocab-DrT4yI_w.js → command-vocab-ByChDwV9.js} +1 -1
  55. package/dist/assets/{device-integration-icon-ltuTuHtu.js → device-integration-icon-CH2i6Msq.js} +1 -1
  56. package/dist/assets/device-picker-model-DQ7GTxXG.js +1 -0
  57. package/dist/assets/dist-Bi72cwT_.js +1136 -0
  58. package/dist/assets/{dist-DFGzwWFe.js → dist-Dhkg8AWn.js} +1 -1
  59. package/dist/assets/{format-D6Vp8m4u.js → format-Cr5Z7hEa.js} +1 -1
  60. package/dist/assets/{hostInit-CML8wGF-.js → hostInit-DqW1fxc7.js} +1 -1
  61. package/dist/assets/i18n-OcaOH-Ge.js +1 -0
  62. package/dist/assets/{icons-C86IhfQA.js → icons-CICuugQ1.js} +1 -1
  63. package/dist/assets/index-BzUvVt-V.js +6 -0
  64. package/dist/assets/{linked-devices-model-Bdif5rHp.js → linked-devices-model-nwfi8vH4.js} +1 -1
  65. package/dist/assets/{mf-entry-bootstrap-0-442bdc59.js → mf-entry-bootstrap-0-6a8a6c87.js} +2 -2
  66. package/dist/assets/mount-DQ7GTxXG.js +1 -0
  67. package/dist/assets/{notification-rule-status-nbzziCD-.js → notification-rule-status-Di4wqTIA.js} +1 -1
  68. package/dist/assets/player-overlays-Doz3g2Qx.js +1 -0
  69. package/dist/assets/remoteEntry-CZJPvesV.js +1 -0
  70. package/dist/assets/src-DmQ7Cv69.js +279 -0
  71. package/dist/assets/{sso-popup-duz3lpD8.js → sso-popup-B-tqkFkc.js} +1 -1
  72. package/dist/assets/{step-inspector-model-xQUBFCp-.js → step-inspector-model-BSL8kZ_q.js} +1 -1
  73. package/dist/assets/use-notification-targets-8N18acum.js +1 -0
  74. package/dist/assets/{use-scenes-feed-CzaOWh_W.js → use-scenes-feed-4hfR1es_.js} +1 -1
  75. package/dist/assets/{useAdminDeviceRemoval-D_Wkm6SL.js → useAdminDeviceRemoval-Do1Lkxt-.js} +1 -1
  76. package/dist/assets/useEventInvalidation-DQ7GTxXG.js +1 -0
  77. package/dist/assets/{useNodeUrlSelection-CfVGV8Yj.js → useNodeUrlSelection-BsRfsDk3.js} +1 -1
  78. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CGyGOGfX.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-AMUX_sNo.js} +2 -2
  79. package/dist/index.html +8 -8
  80. package/dist/server/addon.js +113 -8
  81. package/package.json +2 -2
  82. package/dist/assets/Addons-BBg5QUv1.js +0 -5
  83. package/dist/assets/AiProfiles-DK-d5If4.js +0 -3
  84. package/dist/assets/Archive-BmeuZDgK.js +0 -1
  85. package/dist/assets/Build-C46zZKEk.js +0 -40
  86. package/dist/assets/Cluster-D35XsJOD.js +0 -1
  87. package/dist/assets/Data-Dufa6STk.js +0 -2
  88. package/dist/assets/DeviceDetail-iGVYGmkf.js +0 -1
  89. package/dist/assets/History-YW45zgFF.js +0 -1
  90. package/dist/assets/Identity-CB93BP9K.js +0 -1
  91. package/dist/assets/InstancesTable-DqOZKOiw.js +0 -1
  92. package/dist/assets/IntegrationDetail-DRGef_TD.js +0 -1
  93. package/dist/assets/Integrations-D3HWeUYL.js +0 -1
  94. package/dist/assets/Library-B0AK9o5k.js +0 -1
  95. package/dist/assets/Locations-MSracM56.js +0 -3
  96. package/dist/assets/MyAccess-D1eUb8NO.js +0 -2
  97. package/dist/assets/Network-D5UuhaFs.js +0 -1
  98. package/dist/assets/NewExportModal-CRG5X9Xd.js +0 -1
  99. package/dist/assets/Notifications-DkXaGj0i.js +0 -1
  100. package/dist/assets/Pipeline-CUzcbUT6.js +0 -1
  101. package/dist/assets/SessionsList-DeqXjMvl.js +0 -2
  102. package/dist/assets/StorageLocationsTable-Blio9Uwn.js +0 -1
  103. package/dist/assets/System-B_Bhbm6A.js +0 -2
  104. package/dist/assets/TemplateEditorDialog-B7nwBFDa.js +0 -1
  105. package/dist/assets/action-draft-mvm1fG3Z.js +0 -1
  106. package/dist/assets/client-CiiufhtZ.js +0 -1125
  107. package/dist/assets/device-picker-model-CHH_K0iv.js +0 -1
  108. package/dist/assets/dist-3oPp68KS.js +0 -1125
  109. package/dist/assets/i18n-5KJwF-JB.js +0 -1
  110. package/dist/assets/index-BYgap-bt.js +0 -6
  111. package/dist/assets/mount-CHH_K0iv.js +0 -1
  112. package/dist/assets/player-overlays-CX_koJa1.js +0 -1
  113. package/dist/assets/remoteEntry-CWH31XW5.js +0 -1
  114. package/dist/assets/src-vFbZMtSO.js +0 -279
  115. package/dist/assets/useEventInvalidation-CHH_K0iv.js +0 -1
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,i as c,o as l,p as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as f,A as p,D as m,Dr as h,Hn as g,Ir as _,Lr as v,N as y,O as b,Pn as x,Qa as S,Rn as C,Rt as w,T,Tt as ee,Ur as te,V as E,Xn as D,Yn as O,Zt as k,aa as ne,b as A,ci as j,cr as M,ct as N,eo as P,ft as F,hi as I,j as L,ji as R,jt as z,k as re,so as B,tn as V,to as H,v as ie,wt as U,y as ae,yn as W,yt as oe,z as G,zr as se}from"./player-overlays-CX_koJa1.js";import{$i as ce,Ci as le,Di as ue,Ei as de,Oi as fe,Si as pe,Ti as me,Yn as he,_ as ge,bi as _e,di as ve,g as ye,h as be,ia as xe,na as Se,ra as Ce,ta as we,wi as Te,xl as Ee,y as De}from"./client-CiiufhtZ.js";import{t as Oe}from"./chevron-down-CBb-F8DT.js";import{d as ke,u as Ae}from"./terminal-DZ5OZpgC.js";import{a as je,i as Me,n as Ne,r as Pe,t as Fe}from"./usb-P4R9CjYI.js";import{t as Ie}from"./crop-B-t0rzRY.js";import{t as Le}from"./layers-BH9u1mrE.js";import{n as Re}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js";import{$p as K,$s as ze,Ai as Be,An as Ve,Ar as He,Au as Ue,B as We,Br as Ge,Cd as Ke,Cu as qe,Eu as Je,Fc as Ye,Fp as Xe,Gi as Ze,Gr as Qe,Gu as $e,H as et,Hi as tt,Ic as nt,Ji as rt,K as it,Ki as at,Kr as ot,Ku as st,Lc as ct,Lp as lt,Lr as q,Ma as ut,Mu as dt,Nn as ft,Nu as pt,Oi as mt,Op as ht,Ou as gt,Pi as _t,Pu as vt,Qu as yt,Ru as bt,Si as xt,Sr as St,Tu as Ct,U as wt,Uu as Tt,V as Et,Vr as Dt,Vu as Ot,W as kt,Wi as At,Wr as jt,Xi as Mt,Xu as Nt,Yi as Pt,Yu as Ft,Zu as It,_d as Lt,a as Rt,bd as zt,bi as Bt,bp as J,ci as Vt,ed as Ht,em as Ut,eo as Wt,et as Gt,fd as Kt,gd as qt,hd as Jt,hr as Yt,id as Xt,im as Zt,ja as Y,ji as Qt,ju as $t,ka as en,kp as tn,ku as nn,li as rn,md as an,mi as on,mt as sn,nd as cn,nm as ln,oi as un,pd as dn,pt as fn,qi as pn,qu as mn,rd as hn,rm as gn,ro as _n,st as vn,td as yn,tm as bn,to as xn,ua as Sn,vd as Cn,vi as wn,wu as Tn,xd as En,xi as Dn,yd as On,yi as kn}from"./src-vFbZMtSO.js";import{t as X}from"./i18n-5KJwF-JB.js";import{t as Z}from"./useTranslation-BJr-n0es.js";import{H as An,Si as jn,_i as Mn,gi as Nn}from"./index-BYgap-bt.js";import{t as Pn}from"./NodeAddonsSettingsPanel-DK5hH6AQ.js";import"./useEventInvalidation-CHH_K0iv.js";import{_ as Fn,a as In,b as Ln,c as Rn,d as zn,f as Bn,g as Vn,h as Hn,i as Un,l as Wn,m as Gn,n as Kn,p as qn,r as Jn,s as Yn,u as Xn,v as Zn,y as Qn}from"./step-inspector-model-xQUBFCp-.js";import{a as $n,c as er,d as tr,f as nr,g as rr,i as ir,l as ar,m as or,n as sr,o as cr,r as lr,s as ur,t as dr,u as fr,v as pr,y as mr}from"./board-model-iKJIk-mi.js";s();function hr(e){if(e==null)return null;if(typeof e==`number`)return e>0?e:null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function gr(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function _r(e){return e!==!1}function vr(e){return{pipeline:_r(gr(e,`detect`)),audio:_r(gr(e,`audio`)),ingest:_r(gr(e,`ingest`))}}function yr(e,t){let n=e?.find(e=>e.nodeId===t);return vr(n?.settings)}function br({selectedNodeId:t,onSelect:n,refreshToken:r}){let a=B(),{t:o}=Z(),{nodes:s}=Ut(),{data:c}=$e(void 0),{data:l}=Nt(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let f=s??[],p=f.filter(e=>e.isOnline).length,m=f.filter(e=>!e.isOnline).length;return e(`div`,{className:`flex flex-col h-full`,children:[e(J,{variant:`unstyled`,type:`button`,onClick:()=>n(Vs),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${t===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[i(Ae,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`text-xs font-semibold truncate`,children:o(`pipeline.nodeList.cluster`,`Cluster`)}),i(`div`,{className:`text-[10px] text-foreground-subtle`,children:o(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),i(`div`,{className:`flex-1 overflow-y-auto`,children:f.map(r=>{let s=t===r.id,c=u.get(r.id)??0,f=r.isHub?C:R,p=yr(l,r.id),m=r.isOnline?null:ft(hr(r.lastSeen),a);return e(J,{variant:`unstyled`,type:`button`,onClick:()=>n(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${s?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[i(f,{className:`h-4 w-4 flex-shrink-0`}),e(`div`,{className:`min-w-0 flex-1`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:o(`common.hubWord`)}),!r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),r.isOnline&&i(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),e(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[i(`span`,{children:o(`common.coresCount`,{count:r.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),c>0&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[i(w,{className:`h-2.5 w-2.5`}),c]})]}),!r.isOnline&&e(d,{children:[i(`span`,{children:`•`}),e(`span`,{className:`text-danger`,children:[o(`common.offline`),m===null?``:` · ${m}`]})]})]}),e(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[i(Y,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?o(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):o(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:o(`pipeline.nodeList.pipe`,`Pipe`)}),i(Y,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?o(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):o(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:o(`pipeline.nodeList.aud`,`Aud`)})]})]})]},r.id)})}),e(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[i(`span`,{children:o(`common.onlineCount`,{count:p})}),m>0&&i(`span`,{className:`text-danger`,children:o(`common.offlineCount`,{count:m})})]})]})}function xr({nodeId:t,refreshToken:n}){let{t:r}=Z(),{nodes:a}=Ut(),o=a?.find(e=>e.id===t),s=bn(`pipeline.runner-load-snapshot`,e=>e.nodeId===t)?.load??null;return o?e(`div`,{className:`px-6 py-4 border-b border-border`,children:[e(`div`,{className:`flex items-center gap-2 mb-1`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:o.name}),o.isOnline?i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:r(`common.online`)}):i(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:r(`common.offline`)}),o.isHub&&i(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:r(`common.hubWord`)})]}),e(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[i(`span`,{children:o.cpuModel??`CPU`}),i(`span`,{children:`•`}),i(`span`,{children:r(`common.coresCount`,{count:o.cpuCores})}),i(`span`,{children:`•`}),e(`span`,{children:[Math.round(o.memoryMB/1024),` GB`]}),s&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.cameras`,{attached:s.attachedCameras,active:s.activeCameras})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.avgInference`,{ms:s.avgInferenceTimeMs.toFixed(0)})}),i(`span`,{children:`•`}),i(`span`,{children:r(`pipeline.nodeDetailHeader.queue`,{depth:s.queueDepthTotal})}),s.hardware.hasGpu&&e(d,{children:[i(`span`,{children:`•`}),i(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):i(`div`,{className:`px-6 py-4 border-b border-border`,children:e(`div`,{className:`text-xs text-foreground-subtle`,children:[r(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,t]})})}var Sr=[`assignments`,`tree`,`engines`,`logs`];function Cr({refreshToken:t,nodeId:r}){let{t:a}=Z(),[s,c]=o(new Map),{nodes:l}=K();gn(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&c(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:u}=vt(void 0),d=n(()=>{let e=new Map;for(let t of u??[])e.set(t.nodeId,t.deviceCount);return e},[u]),f=n(()=>{let e=new Map,t=Date.now()-3e4;for(let n of s.values()){if(n.timestamp<t)continue;let r=n.nodeId??`hub`,i=e.get(r)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,n.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=n.metrics.actualFps,i.totalInferenceWeighted+=n.metrics.avgInferenceTimeMs,i.queueDepth+=n.metrics.queueDepth,e.set(r,i)}return e},[s]),p=n(()=>{let e=new Map;for(let t of l)e.set(t.id,t.shortName);return e},[l]),m=n(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of f.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:l.length,onlineAgents:l.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[f,l]);if(r){let t=f.get(r);return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[i(Q,{label:`FPS`,value:t?t.totalFps.toFixed(1):`—`}),i(Q,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:t?`${t.activeCameras}/${t.attachedCameras}`:`—`}),i(Q,{label:a(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:t&&t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),i(Q,{label:a(`pipeline.liveLoadPanel.queue`,`Queue`),value:t?String(t.queueDepth):`—`}),i(Q,{label:a(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(d.get(r)??`—`)})]})]})}let h=[...f.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return e(`div`,{className:`@container/liveload`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:a(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),e(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[i(Q,{label:a(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),i(Q,{label:a(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),i(Q,{label:a(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),i(Q,{label:a(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),i(Q,{label:a(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[480px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.liveLoadPanel.agent`,`Agent`)}),i(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.queue`,`Queue`)}),i(`th`,{className:`text-right px-3 py-2`,children:a(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),e(`tbody`,{children:[h.map(([t,n])=>e(`tr`,{className:`border-t border-border`,children:[i(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(t)??t}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.totalFps.toFixed(1)}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.attachedCameras>0?(n.totalInferenceWeighted/n.attachedCameras).toFixed(0):`—`}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:n.queueDepth}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:d.get(t)??`—`})]},t)),h.length===0&&i(`tr`,{children:i(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function Q({label:t,value:n}){return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[i(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:t}),i(`div`,{className:`text-lg font-semibold text-foreground`,children:n})]})}var wr={active:!1,pinned:!1,nodeId:null,reason:``};function Tr(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function Er(e,t,n){let r=new Map(t.map(e=>[e.deviceId,e])),i=new Map(n.map(e=>[e.deviceId,e]));return e.map(e=>{let t=r.get(e.id),n=i.get(e.id),a=t?{active:!0,pinned:t.pinned,nodeId:t.agentNodeId,reason:t.reason??``}:wr,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:wr;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:wr,audio:o}}).toSorted(Tr)}function Dr(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function Or(e,t){let n=new Map(t.map(e=>[e.deviceId,e.assignment]));return e.map(e=>{let t=n.get(e.deviceId);return t===void 0?e:{...e,detection:Dr(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:Dr(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:Dr(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function kr(e,t,n){let r=(t,n,r)=>({active:t!==null&&t===e,pinned:n,nodeId:t,reason:r??``});return t.map(({deviceId:e,assignment:t})=>({deviceId:e,deviceName:n(e),detection:r(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:r(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:r(t.audioNodeId,t.pinned.audio,t.reasons.audio)})).filter(e=>e.detection.active||e.decoder.active||e.audio.active).toSorted(Tr)}function Ar(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>{let n=t.get(e);return n!==void 0&&n!==``?n:e}}function jr(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??X.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function Mr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:X.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:X.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function Nr({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:a,emphasizeOnNodeId:o}){if(n.nodeId===null)return null;let s=n.nodeId,c=o===void 0?!1:n.active&&s===o;return i(jt,{roleId:e,roleLabel:t,nodeName:r(s),colorId:ot(a,s),emphasized:c,pinned:n.pinned})}function Pr({detection:t,decoder:n,audio:r,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s}){let c=(e,t,n)=>i(Nr,{roleId:e,roleLabel:t,state:n,nameOf:a,colorByNodeId:o,emphasizeOnNodeId:s},e);return e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[c(`detection`,`Detection`,t),c(`decode`,`Decode`,n),c(`audio`,`Audio`,r)]})}function Fr({snap:t}){let n=B(),{t:r}=Z();if(t===void 0)return i(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:r(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:r(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:a,actualFps:o,avgInferenceTimeMs:s,queueDepth:c,configuredFps:l,droppedFrames:u}=t.metrics,d=St(a,n);return e(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[e(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${d.textColor}`,children:[i(Gt,{phase:a,className:`h-2.5 w-2.5 shrink-0`}),i(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:d.label}),i(`span`,{className:`text-foreground`,children:o.toFixed(1)}),i(`span`,{className:`text-foreground-subtle`,children:r(`pipeline.assignmentStatusCell.configuredFps`,{fps:l.toFixed(0)})})]}),e(`span`,{className:`truncate text-foreground-subtle`,children:[i(`span`,{className:`text-foreground`,children:s.toFixed(0)}),` ms`,c>0&&e(`span`,{className:`ml-1 text-warning`,children:[`q`,c]}),i(`span`,{className:u>0?`ml-1 text-warning`:`ml-1`,children:r(`pipeline.assignmentStatusCell.drops`,{count:u})})]})]})}s();var Ir=1e4,Lr=5e3;function Rr(e){let[t,n]=o(new Map);return gn(`pipeline.camera-metrics-snapshot`,t=>{let r=t.data;typeof r.deviceId==`number`&&(e!==void 0&&r.nodeId!==e||n(e=>new Map(e).set(r.deviceId,r)))}),a(()=>{if(t.size===0)return;let e=setInterval(()=>{n(e=>{let t=Date.now()-Ir,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},Lr);return()=>clearInterval(e)},[t.size]),t}var zr=3e5;function Br({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:a}){let{t:o}=Z();return i(F,{"aria-label":o(`assignments.placementControls.nodePin`,`Node pin`),title:o(`assignments.placementControls.autoLetsEachSessionPick`,`Auto lets each session pick its node; a pin keeps the camera on one node.`),value:e.pinned&&e.nodeId!==null?e.nodeId:`auto`,disabled:r,options:[...Mr(e,t,n)],onChange:e=>a(e.target.value)})}function Vr({deviceId:e,nodeId:t}){let{t:n}=Z(),r=l(),{data:a}=st({deviceId:e},{refetchOnMount:`always`}),{data:o}=Tt({nodeId:t},{staleTime:zr}),s=Lt({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(a===void 0||o===void 0)return i(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let c=o.devices??[],u=c.filter(e=>e.enabled),d=a?.deviceKey??`auto`,f=d!==`auto`&&!u.some(e=>e.key===d),p=c.find(e=>e.key===d),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...f?[{value:d,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${Be(p)} (${d})`:d})}]:[],...u.map(e=>({value:e.key,label:`${Be(e)} · ${e.format}`}))];return i(F,{"aria-label":n(`assignments.placementControls.inferenceDevicePin`,`Inference device pin`),title:n(`assignments.placementControls.pinDetectionToOneAccelerator`,`Pin detection to one accelerator of the node, or let each session pick.`),value:d,disabled:s.isPending,options:m,onChange:t=>s.mutate({deviceId:e,deviceKey:t.target.value})})}s();function Hr(e){let n=t(null);return e.nodeId!==null&&(n.current=e),n.current}function Ur({deviceId:t,state:n,...r}){let{t:a}=Z(),o=Hr(n);return e(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[i(Br,{state:n,...r}),o?.nodeId==null?i(F,{"aria-label":a(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:a(`assignments.clusterRowCells.anAcceleratorIsPinnedOn`,`An accelerator is pinned on the camera's node; this camera has not run on one yet.`),disabled:!0,defaultValue:`auto`,options:[{value:`auto`,label:a(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):i(Vr,{deviceId:t,nodeId:o.nodeId})]})}function Wr({state:t,nameOf:n}){let{t:r}=Z(),a=Hr(t);if(a?.nodeId==null)return i(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let o=t.active&&t.nodeId!==null,s=a.pinned?`pinned`:`auto · ${a.reason||`capacity`}`;return e(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:a.pinned?void 0:r(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[e(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[i(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${o?`bg-success`:`bg-foreground-subtle/40`}`}),i(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${o?`text-foreground`:`text-foreground-muted`}`,children:n(a.nodeId)})]}),i(`span`,{className:`truncate pl-3 text-[10px] ${a.pinned?`text-warning`:`text-foreground-subtle`}`,children:o?s:r(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:s})})]})}function Gr({deviceId:t,deviceName:n}){let{t:r}=Z(),[a,s]=o(!1);return e(d,{children:[i(tn,{icon:D,variant:`ghost`,size:`sm`,"aria-label":r(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:n}),title:r(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>s(!0)}),i(At,{open:a,onOpenChange:s,children:e(at,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[i(Pt,{children:i(Mt,{children:r(`pipeline.clusterRowCells.brokersTitle`,{device:n})})}),i(Ze,{children:a&&i(tt,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t,instanceId:`pipeline-row/${t}`,config:{variant:`compact`}})})]})})]})}function Kr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function qr(e,t){return t.size===0?!0:t.has(e)}var Jr=[{value:`active`,get label(){return X.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return X.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return X.t(`helpers.cameraActivity.inactive`)}}];s();var Yr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function Xr(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function Zr(){let{t}=Z(),r=l();Rt([`pipelineOrchestrator`,`getPipelineAssignments`],Yr),Rt([`pipelineOrchestrator`,`getAudioAssignments`],Yr),Rt([`pipelineOrchestrator`,`getCameraStatuses`],Yr);let{data:a}=ze({isCamera:!0,projection:`slim`}),{data:s}=$e(void 0),{data:c}=pt(void 0),{data:u}=bt({}),{data:d}=Nt(void 0),{nodes:f}=K(),p=Rr(),m=n(()=>Ar(f),[f]),h=n(()=>Qe(d),[d]),g=n(()=>f.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[f]),_=n(()=>Or(Er((a??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),s??[],c??[]),u??[]),[a,s,c,u]),[v,y]=o(()=>new Set),b=n(()=>_.filter(e=>qr(Kr({hasPipelineAssignment:e.pipeline.active,hasFreshMetrics:p.has(e.deviceId)}),v)),[_,p,v]),x=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=()=>Xr(r),C=nn({onSuccess:S}),w=En({onSuccess:S}),T=C.isPending||w.isPending,ee=[{key:`camera`,header:t(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:n=>e(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[i(Mn,{to:`/devices/${String(n.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:n.deviceName,children:n.deviceName}),n.disabled&&i(Y,{variant:`default`,children:t(`common.off`)})]})},{key:`placement`,header:t(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>i(Ur,{deviceId:e.deviceId,state:e.pipeline,onlineNodes:g,nameOf:m,pending:T,onChange:t=>t===`auto`?w.mutate({deviceId:e.deviceId}):C.mutate({deviceId:e.deviceId,agentNodeId:t})})},{key:`roles`,header:t(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>i(Pr,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:t(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>i(Wr,{state:e.pipeline,nameOf:m})},{key:`status`,header:t(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(Fr,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>i(Gr,{deviceId:e.deviceId,deviceName:e.deviceName})}],te=a===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return e(`div`,{className:`flex flex-col gap-2`,children:[i(`nav`,{"aria-label":t(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:i(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:Jr.map(e=>{let t=v.has(e.value);return i(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:H(ae,t?ie:A),onClick:()=>x(e.value),children:e.label},e.value)})})}),i(Ge,{columns:ee,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:Dt,emptyMessage:te})]})}s();function Qr({nodeId:e}){let{t}=Z(),r=l();Rt([`pipelineOrchestrator`,`getCameraStatuses`],Yr);let{data:a}=bt({}),{data:o}=Nt(void 0),{data:s}=ze({isCamera:!0,projection:`slim`}),{nodes:c}=K(),u=Rr(),d=n(()=>Ar(c),[c]),f=n(()=>Qe(o),[o]),p=n(()=>kr(e,a??[],jr((s??[]).map(e=>({id:e.id,name:e.name})))),[e,a,s]),m=c.filter(t=>t.isOnline&&t.id!==e),h=()=>Xr(r),g=nn({onSuccess:h}),_=En({onSuccess:h}),v=gt({onSuccess:h}),y=zt({onSuccess:h}),b=e=>[...e.detection.active?m.map(n=>({id:`detect-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveDetectionTo`,`Move detection to {{name}}`,{name:n.name}),onClick:()=>g.mutate({deviceId:e.deviceId,agentNodeId:n.id})})):[],...e.audio.active?m.map(n=>({id:`audio-${n.id}`,label:t(`pipeline.nodeCameraAssignmentsTable.moveAudioTo`,`Move audio to {{name}}`,{name:n.name}),onClick:()=>v.mutate({deviceId:e.deviceId,nodeId:n.id})})):[],{id:`unpin-detect`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinDetection`,`Unpin detection`),hidden:!(e.detection.active&&e.detection.pinned),separatorBefore:!0,onClick:()=>_.mutate({deviceId:e.deviceId})},{id:`unpin-audio`,label:t(`pipeline.nodeCameraAssignmentsTable.unpinAudio`,`Unpin audio`),hidden:!(e.audio.active&&e.audio.pinned),onClick:()=>y.mutate({deviceId:e.deviceId})}];return i(Ge,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>i(Mn,{to:`/devices/${String(e.deviceId)}`,className:`block w-44 truncate text-xs font-medium text-primary hover:underline`,title:e.deviceName,children:e.deviceName})},{key:`roles`,header:t(`pipeline.nodeCameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:t=>i(Pr,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:d,colorByNodeId:f,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>u.get(e.deviceId)?.metrics.actualFps??null,render:e=>i(Fr,{snap:u.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>i(Ve,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:Dt,emptyMessage:a===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function $r({nodeId:t,refreshToken:n}){let{t:r}=Z(),{nodes:a}=K(),o=a.find(e=>e.id===t)?.name??t;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(Cr,{refreshToken:n,nodeId:t}),e(`div`,{className:`space-y-2`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`pipeline.nodeCamerasTab.camerasOn`,{node:o})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`pipeline.nodeCamerasTab.theRolesEachCameraRuns`,`The roles each camera runs here right now. Move a role or unpin it from the row menu; pins for every camera are on Cluster → Assignments.`)})]}),i(Qr,{nodeId:t})]})]})}s();function ei(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return X.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function ti({nodeId:t,refreshToken:r}){let{t:a}=Z(),o=l(),s=N(),c=Tn({onSettled:()=>{o.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:u}=Ct({nodeId:t}),d=bn(`pipeline.engine-metrics-snapshot`,e=>e.nodeId===t)?.engines??u??null,f=d===null;Rt([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=Ke({nodeId:t}),{values:m}=ln(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,e=>e.nodeId===t),h=n(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),g=e=>{let n=p??[];if(n.length===0){c.mutate({nodeId:t,engine:e,force:!1});return}(async()=>{await s({title:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(n.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:a(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&c.mutate({nodeId:t,engine:e,force:!0})})()};return e(`div`,{className:`space-y-6`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:a(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`pipeline.nodeEnginesTab.summary`,{engines:(d??[]).length,cameras:(p??[]).length,active:h})})]}),i(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[640px]`,children:[i(`thead`,{className:`bg-surface`,children:e(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.kind`,`Kind`)}),i(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),i(`th`,{className:`text-left px-3 py-2`,children:a(`pipeline.nodeEnginesTab.models`,`Models`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),i(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:a(`pipeline.nodeEnginesTab.inUse`,`In use`)}),i(`th`,{className:`w-20`})]})}),e(`tbody`,{children:[f&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`common.loading`,`Loading…`)})}),!f&&(d??[]).map(t=>{let n=t.kind===`device-pool`;return e(`tr`,{className:`border-t border-border ${n?`bg-primary/[0.05]`:``}`,children:[i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[i(n?Le:R,{className:`h-3 w-3`}),a(n?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),i(`td`,{className:`px-3 py-2`,children:e(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[i(U,{className:`h-3 w-3`}),t.engine.runtime,`/`,t.engine.backend,t.engine.device?`/${t.engine.device}`:``,t.engine.format?` · ${t.engine.format}`:``]})}),i(`td`,{className:`px-3 py-2`,children:t.modelsLoaded.length===0?i(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.modelsLoaded.map(e=>i(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),i(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:t.poolPid??`—`}),i(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:t.idleMs!==null&&t.idleTtlMs!==null?i(`span`,{className:`text-foreground-subtle`,children:ei(t.idleMs,t.idleTtlMs)}):i(`span`,{className:`text-foreground-subtle/50`,children:a(`common.never`)})}),i(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),i(`td`,{className:`px-3 py-2 text-right`,children:n?i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.auto`)}):e(J,{variant:`ghost`,size:`sm`,disabled:c.isPending,onClick:()=>g(t.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[i(V,{className:`h-3.5 w-3.5`}),a(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},t.engineKey)}),!f&&(d??[]).length===0&&i(`tr`,{children:i(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:a(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),i(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:i(Nn,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:i(`strong`,{className:`text-foreground`})}})}),c.isError&&i(en,{message:a(`pipeline.nodeEnginesTab.killFailed`,{message:c.error instanceof Error?c.error.message:a(`common.unknownError`)})})]})}var ni=`pipeline-runner`,ri=200;function ii({nodeId:t}){let{t:n}=Z();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeLogsTab.description`,{node:t})})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(Yt,{agentId:t,addonId:ni,limit:ri,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}s();function ai({nodeId:t,title:r}){let a=B(),{t:o}=Z(),{data:s}=An(),{data:c}=$e(void 0),l=n(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),u=n(()=>{if(!t)return null;let e=new Set;for(let n of c??[])n.agentNodeId===t&&e.add(n.deviceId);return e},[t,c]),d=Rr(t),f=n(()=>{let e=[];for(let t of d.values())u&&!u.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[d,u]);return f.length===0?e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):e(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[i(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r??o(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:f.length})]}),i(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(t=>{let n=l.get(t.deviceId)??`#${t.deviceId}`,r=St(t.metrics.phase,a);return e(`div`,{title:o(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:n,label:r.label,value3:t.metrics.actualFps.toFixed(1),value4:t.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:t.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[i(Gt,{phase:t.metrics.phase,className:`h-2.5 w-2.5`}),i(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:n}),i(`span`,{className:`font-mono tabular-nums`,children:t.metrics.actualFps.toFixed(1)}),i(`span`,{className:`opacity-60`,children:o(`common.fpsWord`)})]},t.deviceId)})})]})}function oi(e,t,n,r){let i=t===void 0?void 0:e.find(e=>e.key===t)?.steps?.[n]?.settings,a={...r?.[n],...i};return Object.keys(a).length>0?a:void 0}function si(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}var ci=`pipeline-analytics`,li=`face-gallery`,ui=`pipeline-orchestrator`,di=`pipeline-runner`,fi=`audio-analyzer`,pi=`stream-broker`,mi=`snapshot`,hi=`recorder`,gi=`embedding-encoder`,_i=`recordingNodeId`;function vi(e){return[...pe.filter(t=>t.stepId===e).map(e=>Te(e.stepId)),...le.filter(t=>t.stepId===e).map(e=>de(e.stepId,e.key))]}var yi=`faces`,bi=`semantic-search`,xi=`load-balancer`,Si=`streaming`,Ci=`recorder`,wi=`load`,Ti=[{id:yi,get title(){return X.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:ui,fieldKeys:vi(`face-embedding`)},{addonId:ci,capability:li},{addonId:ui,sectionIds:[ye]}]},{id:bi,get title(){return X.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:ui,fieldKeys:vi(`clip-embedding`)},{addonId:gi,capability:`embedding-encoder`,fieldScope:`cluster`}]},{id:ge,get title(){return X.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:ui,sectionIds:[ge]}]},{id:be,get title(){return X.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:ui,sectionIds:[be]}]},{id:Si,get title(){return X.t(`helpers.clusterSettingsSections.streamingTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.streamingHint`)},panels:[{addonId:pi,capability:`stream-broker`,fieldScope:`cluster`},{addonId:mi,capability:`snapshot`,fieldScope:`cluster`}]},{id:Ci,get title(){return X.t(`helpers.clusterSettingsSections.recorderTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.recorderHint`)},panels:[{addonId:hi,capability:`recording`,fieldScope:`cluster`,omitFieldKeys:[_i]}]},{id:`runner-defaults`,get title(){return X.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:di,fieldScope:`cluster`},{addonId:fi,fieldScope:`cluster`}]},{id:xi,get title(){return X.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:ui,sectionIds:[wi]}]},{id:`failover`,get title(){return X.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return X.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:ui,sectionIds:[`failover`]}]}],Ei={"cluster-step-models":yi};function Di(e){return e===`clip-embedding`?bi:yi}var Oi=`ctab`,ki=`section`;function Ai(e,t){let n=new URLSearchParams({view:`nodes`,node:Vs,[Oi]:e});return t!==void 0&&n.set(ki,t),`/system/pipeline?${n.toString()}`}function ji(e){return Ai(`settings`,Di(e))}function Mi(){return Ai(`load-balancing`)}var Ni=`pipeline-orchestrator`;function Pi(e){return pe.find(t=>t.stepId===e)??null}function Fi({step:t,engineFormat:n,runnableModelIds:r}){let{t:a}=Z(),{data:o}=xn({addonId:Ni,cap:Ni,scope:`cluster`}),s=ue(o??null)[t.stepId]??t.defaultModelId,c=t.options.find(e=>e.id===s)?.label??s,l=r.length>0&&!r.includes(s);return e(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:c}),i(`span`,{title:a(`pipeline.clusterStepModel.oneValueForTheWhole`,`One value for the whole cluster — this step writes into a shared vector index, where two encoders make similarity scores meaningless.`),className:`rounded border border-primary/40 bg-primary/10 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-primary`,children:a(`pipeline.clusterStepModel.clusterWide`)}),i(Mn,{to:ji(t.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:a(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),e(`p`,{className:G,children:[a(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,a(`pipeline.clusterStepModel.indexNote`,{index:t.indexName})]}),l&&i(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:i(Nn,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:n,model:s,index:t.indexName},components:{b:i(`b`,{})}})})]})}var Ii=`pipeline-orchestrator`;function Li({addonId:t,highlightLabel:n}){let{t:r}=Z(),a=me(t),{data:o}=xn({addonId:Ii,cap:Ii,scope:`cluster`});if(a.length===0)return null;let s=fe(o??null)[t]??{};return e(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`h3`,{className:E,children:r(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),i(Mn,{to:ji(t),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),a.map(t=>e(`div`,{className:`${p} rounded px-2 ${n===t.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[i(`span`,{className:L,children:t.label}),i(`span`,{className:y,children:i(`span`,{className:`font-mono text-xs text-foreground`,children:String(s[t.key]??t.default)})})]},t.key)),i(`p`,{className:G,children:r(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function Ri({rows:t,hint:n}){let{t:r}=Z();return e(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(t=>e(`li`,{className:`${T} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[i(`span`,{className:t.href===void 0?`min-w-0 flex-1 truncate text-foreground-muted`:`basis-full text-foreground-muted`,children:t.label}),i(`span`,{className:`font-mono text-foreground`,children:t.modelId??`—`}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:t.sourceLabel}),t.href!==void 0&&i(Mn,{to:t.href,className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`stepInspector.effectiveModelSummary.changeOnAccelerator`)})]},t.id))}),i(`p`,{className:G,children:n??r(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}s();function zi(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:Be(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Bi({tree:a,searchRows:s,accelerators:c,cellState:l,stepBadge:u,stepAction:d,disabledCount:p,showDisabled:m,onShowDisabledChange:h,dirty:g,onDiscard:_,summary:v,toolbar:y,label:b,renderDetail:x}){let{t:S}=Z(),C=N(),w=Xe(),{selection:T,open:te,close:E}=Gn(n(()=>In(a).map(e=>e.node.addonId),[a]),n(()=>c.map(e=>e.id),[c])),[D,O]=o(``),[k,ne]=o(null),[A,j]=o(null),M=t(null),P=t(null),F=t(null);lt(F);let I=t(null),L=n(()=>Et(s,D),[s,D]),R=n(()=>D.trim()===``?a:Jn(a,new Set(L.map(e=>e.addonId))),[a,L,D]),z=e=>L.find(t=>t.addonId===e)?.matchedField??null,re=n(()=>c.map(zi),[c]),B=e=>c.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),V=c.find(e=>e.id===T.acceleratorId)??null,H=T.stepId!==null,ie=r(async e=>{if(g){if(!await C({title:S(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:S(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:S(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;_()}e()},[C,g,_,S]),U=()=>{requestAnimationFrame(()=>I.current?.focus())},ae=(e,t,n=!1)=>{if(e===T.stepId&&(t?.id??null)===T.acceleratorId){n&&U();return}let r=()=>{ne(z(e)),te({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&U()};e===T.stepId?r():ie(r)},W=()=>{let e=T.stepId;ie(()=>{if(E(),e!==null){let t=V===null?null:sn({agentNodeId:V.nodeId,deviceKey:V.deviceKey});requestAnimationFrame(()=>M.current?.focusCell(e,t))}})},oe=e=>{if(e.key===`Enter`){let t=L[0];if(t===void 0)return;e.preventDefault(),ae(t.addonId,void 0,!0)}else e.key===`Escape`&&O(``)},se=w?i(kt,{onClick:W}):i(tn,{icon:ee,variant:`ghost`,size:`sm`,"aria-label":S(`common.close`,`Close`),onClick:W});return e(`div`,{ref:P,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),F.current?.focus()),e.key===`Escape`&&t&&H&&(e.preventDefault(),W())},children:[e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:v}),i(ht,{ref:F,type:`search`,value:D,onChange:e=>O(e.target.value),onKeyDown:oe,placeholder:S(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":S(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),p>0&&e(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(f,{checked:m,onChange:e=>h(e.target.checked)}),S(`stepInspector.stepMatrixFrame.showDisabled`,{count:p})]}),y]}),T.staleStepId!==null&&i(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:S(`stepInspector.stepMatrixFrame.staleStep`,{id:T.staleStepId})}),R.length===0?i(`p`,{className:`${G} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:S(`stepInspector.stepMatrixFrame.noStepMatches`,{query:D})}):i(fn,{ref:M,tree:R,agents:re,label:b,getCellState:(e,t)=>{let n=B(t);return n===void 0?{kind:`na`}:l(e,n)},onCellClick:(e,t,n)=>ae(e,B(t),n),onStepClick:(e,t)=>ae(e,void 0,t),...u===void 0?{}:{stepBadge:u},...d===void 0?{}:{stepAction:d},selectedCell:H&&T.stepId!==null&&V!==null?{addonId:T.stepId,agentNodeId:V.nodeId,deviceKey:V.deviceKey}:null,fallbackNodeId:A,onFallbackNodeChange:j,reserveRightPx:H&&!w?432:0}),i(it,{open:H,anchor:P,onClose:W,label:S(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:T.stepId!==null&&x({stepId:T.stepId,accelerator:V,matchedField:k,closeButton:se,onEscape:W,headingRef:e=>{I.current=e}})})]})}var Vi=[`cluster`,`node`,`device`,`opt-in`,`model`];function Hi(e){switch(e.kind){case`on`:return{state:`on`,via:`direct`};case`jump`:return{state:`on`,via:`jump`,toDeviceKey:e.toDeviceKey};case`supplied-by-root`:return{state:`on`,via:`root`};case`zone-driven`:return{state:`on`,via:`zone`};case`off-cluster`:return{state:`off`,level:`cluster`};case`off-node`:return{state:`off`,level:`node`};case`off-device`:return{state:`off`,level:`device`};case`opt-in-unused`:return{state:`off`,level:`opt-in`};case`skip`:return{state:`off`,level:`model`}}}function Ui(e){return Hi(e.cell)}function Wi(e){if(!e.reachable||e.devices.length===0)return{state:`unknown`};let t=e.devices.map(Ui),n=t.find(e=>e.state===`on`);if(n!==void 0)return n;for(let e of Vi)if(t.some(t=>t.state===`off`&&t.level===e))return{state:`off`,level:e};return{state:`unknown`}}function Gi(e,t){return e.nodes.find(e=>e.nodeId===t)}function Ki(e,t,n){return Gi(e,t)?.devices.find(e=>e.deviceKey===n)}function qi(e,t){return e===null||e.state!==`off`?null:e.level===`cluster`?`cluster`:t===`device`&&e.level===`node`?`node`:null}var Ji={cluster:[`pipeline.stepSwitches.reason.cluster`,`Off for the whole cluster`],node:[`pipeline.stepSwitches.reason.node`,`Off on this node`],device:[`pipeline.stepSwitches.reason.device`,`Off on this accelerator`],"opt-in":[`pipeline.stepSwitches.reason.optIn`,`Opt-in: no camera has turned it on`],model:[`pipeline.stepSwitches.reason.model`,`No build of it fits this node`]};function Yi({effect:t,unknownHint:n,ownLevel:r}){let{t:a}=Z(),o=r===void 0?null:qi(t,r);if(o!==null)return i(`span`,{className:`text-[11px] text-foreground-muted`,children:o===`cluster`?a(`pipeline.stepSwitches.held.cluster`,`Held off by the cluster — this switch is kept`):a(`pipeline.stepSwitches.held.node`,`Held off by the node — this switch is kept`)});if(t===null||t.state===`unknown`)return i(Y,{variant:`neutral`,dashed:!0,style:`outline`,size:`sm`,children:n??a(`pipeline.stepSwitches.state.unknown`,`Not known yet`)});if(t.state===`off`){let[n,r]=Ji[t.level];return e(`span`,{className:`inline-flex flex-wrap items-center gap-1.5`,children:[i(Y,{variant:`warning`,size:`sm`,children:a(`pipeline.stepSwitches.state.off`,`Off`)}),i(`span`,{className:`text-[11px] text-foreground-muted`,children:a(n,r)})]})}return e(`span`,{className:`inline-flex flex-wrap items-center gap-1.5`,children:[i(Y,{variant:`success`,size:`sm`,children:a(`pipeline.stepSwitches.state.on`,`On`)}),t.via===`jump`&&t.toDeviceKey!==void 0&&i(`span`,{className:`text-[11px] text-foreground-muted`,children:a(`pipeline.stepSwitches.via.jump`,`Runs on {{device}}`,{device:t.toDeviceKey})}),t.via===`root`&&i(`span`,{className:`text-[11px] text-foreground-muted`,children:a(`pipeline.stepSwitches.via.root`,`Supplied by the root model`)}),t.via===`zone`&&i(`span`,{className:`text-[11px] text-foreground-muted`,children:a(`pipeline.stepSwitches.via.zone`,`Runs where a zone is drawn`)})]})}function Xi({nodeId:t,deviceKey:n,stepId:r,view:a,writers:o}){let{t:s}=Z();if(a.status!==`ready`)return null;let c=a.rows.find(e=>e.stepId===r),l=c===void 0?void 0:Ki(c,t,n);if(c===void 0||l===void 0)return null;let u=Ui(l),d=s(`pipeline.stepSwitches.deviceSection`,`Accelerator switch`);return e(`section`,{className:`space-y-2`,"aria-label":d,children:[i(`h3`,{className:E,children:d}),e(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[i(on,{checked:l.stepEnabled!==!1,disabled:qi(u,`device`)!==null||o.isPending,onCheckedChange:e=>o.setDeviceEnabled(t,n,r,e?null:!1),"aria-label":s(`pipeline.stepSwitches.deviceToggle`,`Run {{step}} on this accelerator`,{step:c.name})}),i(Yi,{ownLevel:`device`,effect:u})]})]})}var Zi=``;function Qi(e){let t=e.nodes.map(Wi).filter(e=>e.state!==`unknown`);return{running:t.filter(e=>e.state===`on`).length,known:t.length}}function $i({row:t,writers:n}){let{t:r}=Z(),a={off:r(`pipeline.stepSwitches.mode.off`,`Off`),on:r(`pipeline.stepSwitches.mode.on`,`On`),"opt-in":r(`pipeline.stepSwitches.mode.optIn`,`Opt-in`)},{running:o,known:s}=Qi(t);return e(`div`,{className:`space-y-1`,children:[i(F,{"aria-label":r(`pipeline.stepSwitches.clusterModeFor`,`Cluster mode for {{step}}`,{step:t.name}),wrapperClassName:`relative w-full max-w-44`,value:t.clusterMode??Zi,disabled:n.isPending,options:[{value:Zi,label:r(`pipeline.stepSwitches.mode.default`,`Default ({{mode}})`,{mode:a[t.effectiveMode]})},{value:`on`,label:a.on},{value:`opt-in`,label:a[`opt-in`]},{value:`off`,label:a.off}],onChange:e=>{let r=ve.safeParse(e.target.value);n.setClusterMode(t.stepId,r.success?r.data:null)}}),i(`p`,{className:`text-[11px] text-foreground-muted`,children:t.effectiveMode===`off`?r(`pipeline.stepSwitches.cluster.hardOff`,`Off everywhere: no camera can turn it on`):r(`pipeline.stepSwitches.cluster.cameras`,{defaultValue:`Cameras: {{enabling}} turn it on, {{disabling}} turn it off · runs on {{running}} of {{known}} nodes`,enabling:t.camerasEnabling,disabling:t.camerasDisabling,running:o,known:s})})]})}function ea({row:t,nodeId:n,writers:r}){let{t:a}=Z(),o=Gi(t,n),s=o===void 0?null:Wi(o);return e(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[o!==void 0&&i(on,{checked:o.stepEnabled!==!1,disabled:qi(s,`node`)!==null||r.isPending,onCheckedChange:e=>r.setNodeEnabled(n,t.stepId,e?null:!1),"aria-label":a(`pipeline.stepSwitches.nodeToggle`,`Run {{step}} on this node`,{step:t.name})}),i(Yi,{ownLevel:`node`,effect:s,...o!==void 0&&!o.reachable?{unknownHint:a(`pipeline.stepSwitches.state.nodeSilent`,`Node not answering`)}:{}})]})}function ta(e){let t=new Map,n=e=>{for(let r of e.children)t.set(r.addonId,e),n(r)};return e.forEach(n),t}function na(e,t){return e.status===`ready`?e.rows.find(e=>e.stepId===t):void 0}function ra(e,t,n,r){for(let i=t.get(n);i!==void 0;i=t.get(i.addonId)){let t=na(e,i.addonId);if(t!==void 0)return r(t)?i:null}return null}function ia(e,t,n,r,i){let a=na(e,n);if(a?.effectiveMode===`off`||a!==void 0&&Gi(a,r)?.stepEnabled===!1)return!0;let o=a===void 0?void 0:Ki(a,r,i);if(o!==void 0){let e=Ui(o);if(e.state===`off`&&e.level!==`model`)return!0}return ra(e,t,n,e=>{let t=Gi(e,r);return t!==void 0&&Wi(t).state===`off`})!==null}function aa({parent:e}){let{t}=Z();return i(`span`,{className:`text-[11px] text-foreground-muted`,"data-testid":`off-with-parent`,children:t(`pipeline.stepSwitches.offWithParent`,`Off with {{parent}}`,{parent:e.addonName})})}function oa({addonId:e,nodeId:t,parents:n,view:r,writers:a}){let o=na(r,e);if(o!==void 0)return i(ea,{row:o,nodeId:t,writers:a});let s=ra(r,n,e,e=>{let n=Gi(e,t);return n!==void 0&&Wi(n).state===`off`});return s===null?null:i(aa,{parent:s})}function sa({addonId:e,parents:t,view:n,writers:r}){let a=na(n,e);if(a!==void 0)return i($i,{row:a,writers:r});let o=ra(n,t,e,e=>e.effectiveMode===`off`);return o===null?null:i(aa,{parent:o})}function ca({view:t,writers:n}){let{t:r}=Z();return e(d,{children:[t.status===`error`&&i(en,{title:r(`pipeline.stepSwitches.loadFailed`,`Step switches did not load`),message:t.message}),n.error!==null&&i(en,{title:r(`pipeline.stepSwitches.writeFailed`,`The change was not saved`),message:n.error})]})}s();var la=15e3;function ua(e,t){return e instanceof Error&&e.message!==``?e.message:t}function da(e){let t=Ft(void 0,{refetchInterval:la});return t.data===void 0?t.isError?{status:`error`,message:ua(t.error,e)}:{status:`pending`}:{status:`ready`,rows:t.data.steps}}function fa(e){let t=l(),[n,r]=o(null),i={onSuccess:()=>r(null),onError:t=>r(ua(t,e)),onSettled:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getStepSwitches`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}},a=Kt(i),s=Jt(i),c=dn(i);return{setClusterMode:(e,t)=>a.mutate({stepId:e,mode:t}),setNodeEnabled:(e,t,n)=>s.mutate({agentNodeId:e,stepId:t,enabled:n}),setDeviceEnabled:(e,t,n,r)=>c.mutate({agentNodeId:e,deviceKey:t,stepId:n,enabled:r}),isPending:a.isPending||s.isPending||c.isPending,error:n}}s();function pa(e){a(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}s();function ma(e,t,n){return e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=t.accelerator?.deviceKey===e.key?{...Object.fromEntries(Object.entries(i.settings??{}).filter(([e])=>!n(e))),...t.accelerator.settings}:i.settings,c=s!==void 0&&Object.keys(s).length>0?s:void 0,l=a===void 0?i.modelId:a??void 0,u=o===void 0?i.jumpDeviceKey:o||void 0,d={...l===void 0?{}:{modelId:l},...c===void 0?{}:{settings:c},...u===void 0?{}:{jumpDeviceKey:u}};return Object.keys(d).length>0?r[t.stepId]=d:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}})}function ha(e,t){return t===void 0?0:[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!De(e[n],t[n])).length}function ga(e,t,n,r){if(t===null)return 0;let i=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,a=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,o=ha(n,t.nodeSettings),s=t.accelerator===void 0?0:ha(r(t.accelerator.deviceKey),t.accelerator.settings);return i+a+o+s}function _a({nodeId:t,nodeName:r,toolbar:a}){let{t:s}=Z(),c=l(),u=Tt({nodeId:t},{refetchOnMount:`always`}),f=qe({nodeId:t},{refetchOnMount:`always`}),p=dt({agentNodeId:t},{refetchOnMount:`always`}),m=p.data?.stepSettings,h=ue(xn({addonId:`pipeline-orchestrator`,cap:`pipeline-orchestrator`,scope:`cluster`}).data??null),g=u.data?.devices??[],_=f.data??null,[v,y]=o(null),[b,x]=o(null),[S,C]=o(null),w=hn({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),T=qt({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})}}),[ee,te]=o(!1),D=da(s(`pipeline.stepSwitches.loadFailed`,`Step switches did not load`)),O=fa(s(`pipeline.stepSwitches.writeFailed`,`The change was not saved`)),k=n(()=>_?We(_):[],[_]),ne=n(()=>In(k),[k]),A=n(()=>ta(k),[k]),[j,M]=o(!1),N=n(()=>Yn(t,r,g,j),[t,r,g,j]),P=n(()=>Yn(t,r,g),[t,r,g]),I=P.length>=2,L=(e,t)=>oi(g,t?.deviceKey,e,m)??{},R=e=>m?.[e]??{},z=(e,t)=>g.find(e=>e.key===t)?.steps?.[e]?.settings??{},re=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return P.find(e=>e.deviceKey===r);if(!Wn(e,t))return P.filter(n=>n.id!==t.id&&Wn(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},B=(e,n)=>{let r=Un(_,e),i=Pi(e),a=Rn(_,n),o=L(e,n),s=re(r,n);return ia(D,A,e,t,n.deviceKey)?{kind:`disabled`}:Kn({addon:r,acc:n,gatedOn:r?.enabledByDefault??!0,model:r?Bn(r,n,{nodePin:n.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...qn(e,o,a)&&a?{rootName:a.name}:{},...i?{clusterModelId:h[e]??i.defaultModelId}:{},...s?{jumpTo:Qt(s.device)}:{}})},V=ne.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:zn(Un(_,e.addonId))}));if(u.isLoading||f.isLoading||p.isLoading)return i(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(_===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let H=e(`div`,{className:`space-y-2`,children:[e(`span`,{className:G,children:[s(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,i(`span`,{className:`text-foreground`,children:P.length>0?P.map(e=>Qt(e.device)).join(` · `):s(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),g.some(e=>!e.enabled)&&e(d,{children:[` `,s(`stepInspector.nodeStepInspector.off`,`— off:`),` `,g.filter(e=>!e.enabled).map(Qt).join(`, `)]}),` `,`·`,` `,i(Mn,{to:Mi(),className:`text-primary hover:underline`,children:s(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]}),i(ca,{view:D,writers:O})]});return i(Bi,{tree:k,searchRows:V,accelerators:N,cellState:B,disabledCount:g.filter(e=>!e.enabled).length,showDisabled:j,onShowDisabledChange:M,dirty:v!==null&&ga(g,v,R(v.stepId),e=>z(v.stepId,e))>0,onDiscard:()=>y(null),summary:H,stepAction:e=>i(oa,{addonId:e,nodeId:t,parents:A,view:D,writers:O}),...a===void 0?{}:{toolbar:a},label:s(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:a,matchedField:o,closeButton:c,onEscape:l,headingRef:u})=>{let f=Un(_,n);if(f===null)return i(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:s(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=v?.stepId===n?v:null,m=a??P[0]??N[0],h=p?.nodeSettings??R(n),k=a===null?{}:p?.accelerator?.deviceKey===a.deviceKey?p.accelerator.settings:z(n,a.deviceKey),ne={...h,...k},A=ga(g,p,R(n),e=>z(n,e)),j=e=>{C(null),y(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},M=Pi(n),B=Bt(f),{nodeFields:V,acceleratorFields:H}=Xn(B),ie=new Set(H.flatMap(e=>`key`in e?[e.key,`${e.key}ModelId`]:[])),U=m===void 0?void 0:Rn(_,m),ae=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},W=m===void 0?void 0:Bn(f,m,{nodePin:ae(m)}).modelId,oe=t=>{let r=ae(t),o=Bn(f,t,{nodePin:r}),c=Rn(_,t),l=qn(n,a?.id===t.id?ne:L(n,t),c),u=p?.jumps[t.deviceKey],m=re(f,t,u),h=Wn(f,t)?l&&c?i(wn,{rootModel:c,stepModelId:o.modelId}):void 0:e(d,{children:[s(`stepInspector.nodeStepInspector.noBuild`,{format:t.device.format}),` `,m?s(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:m.shortLabel}):s(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=I?e(`label`,{className:`block space-y-1`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:s(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),i(F,{"aria-label":s(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:u??t.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:s(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...P.filter(e=>e.id!==t.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:e=>j({jumps:{...p?.jumps,[t.deviceKey]:e.target.value}})}),i(`span`,{className:G,children:s(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:t.label,format:t.device.format,modelId:o.modelId,source:o.source===`node`?`node`:`default`,sourceLabel:o.source===`node`?`node pin`:`hardware default`,models:mt(f.models??[],t.device.format),defaultModelId:f.defaultModelIdByFormat?.[t.device.format]??f.defaultModelId,expanded:b===t.id,onToggle:()=>x(e=>e===t.id?null:t.id),onChangeModel:e=>j({models:{...p?.models,[t.deviceKey]:e}}),...r===void 0?{}:{onReset:()=>j({models:{...p?.models,[t.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...h===void 0?{}:{note:h},...g===void 0?{}:{extra:g},changed:p?.models[t.deviceKey]!==void 0||u!==void 0}},se=async()=>{if(p!==null){te(!0);try{(Object.keys(p.models).length>0||Object.keys(p.jumps).length>0||p.accelerator!==void 0)&&await w.mutateAsync({agentNodeId:t,inferenceDevices:si(ma(g,p,e=>ie.has(e)))}),p.nodeSettings!==void 0&&ha(R(n),p.nodeSettings)>0&&await T.mutateAsync({agentNodeId:t,addonId:n,settings:Object.keys(p.nodeSettings).length>0?{...p.nodeSettings}:null}),y(null),C({kind:`saved`})}catch(e){C({kind:`error`,error:e instanceof Error?e.message:String(e)})}finally{te(!1)}}};return i(wt,{ref:u,title:a===null?`${f.name} · ${r}`:`${f.name} · ${a.label}`,subtitle:a===null?s(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:f.slot,nodeName:r}):s(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:f.slot,format:a.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:A,saving:ee,status:S?.kind??null,...S?.error===void 0?{}:{error:S.error},onSave:()=>void se(),onDiscard:()=>y(null)},children:e(`div`,{className:`space-y-3`,children:[a!==null&&i(Xi,{nodeId:t,deviceKey:a.deviceKey,stepId:n,view:D,writers:O}),e(`section`,{className:`space-y-2`,"aria-label":s(`stepInspector.nodeStepInspector.model`,`Model`),children:[i(`h3`,{className:E,children:s(`stepInspector.nodeStepInspector.model`,`Model`)}),M!==null&&m!==void 0?i(Fi,{step:M,engineFormat:m.device.format,runnableModelIds:mt(f.models??[],m.device.format).map(e=>e.id)}):N.length===0?i(`p`,{className:G,children:i(Nn,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:i(Mn,{to:Mi(),className:`text-primary hover:underline`})}})}):a===null?i(Ri,{rows:N.map(e=>{let t=Bn(f,e,{nodePin:ae(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):i(et,{...oe(a)},a.id)]}),(B.length>0||U!==void 0)&&M===null&&e(`section`,{"aria-label":s(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:s(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:r})}),(V.length>0||U!==void 0)&&i(va,{addon:f,fields:V,settings:h,layerLabel:s(`stepInspector.nodeStepInspector.nodeLayer`,`Node`),modelId:kn(f,W,ne,U),root:U,highlight:o,onChange:e=>j({nodeSettings:e})}),H.length>0&&(a===null?i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-hint`,children:s(`stepInspector.nodeStepInspector.thresholdsPerAccelerator`,`Confidence thresholds belong to the model, so they are set per accelerator: open that accelerator's cell.`)}):e(`div`,{className:`space-y-1 border-t border-border/60 pt-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`accelerator-settings-scope`,children:s(`stepInspector.nodeStepInspector.acceleratorSettings`,{accelerator:a.label})}),i(va,{addon:f,fields:H,settings:k,layerLabel:s(`stepInspector.nodeStepInspector.acceleratorLayer`,`This accelerator`),modelId:kn(f,W,ne,U),root:void 0,highlight:o,onChange:e=>j({accelerator:{deviceKey:a.deviceKey,settings:e}})})]}))]}),i(Li,{addonId:n,highlightLabel:o})]})})}})}function va({addon:e,fields:t,settings:n,layerLabel:r,modelId:a,root:o,highlight:s,onChange:c}){let l=t.find(e=>`label`in e&&e.label===s)?.key??null;return pa(l===null?null:xt(l)),i(Dn,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:r},modelId:a,...o===void 0?{}:{rootModel:o},highlightKey:l,onChangeLayer:c})}s();function ya({nodeId:t,refreshToken:n}){let{t:r}=Z(),a=N(),[s,c]=o(null),{nodes:l}=K(),u=l.find(e=>e.id===t)?.name??t,f=Ht({onSuccess:e=>{c(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),p=async()=>{await a({title:r(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:r(`pipeline.nodePipelineTab.thisClearsEveryPerDevice`,`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`),confirmLabel:r(`common.reset`,`Reset`),variant:`danger`})&&(c(null),f.mutate({agentNodeId:t}))};return e(`div`,{className:`space-y-2`,children:[i(ai,{nodeId:t}),i(_a,{nodeId:t,nodeName:u,toolbar:e(d,{children:[s&&i(`span`,{className:`text-[11px] text-success`,children:s}),f.isError&&i(`span`,{className:`text-[11px] text-danger`,children:f.error instanceof Error?f.error.message:r(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),i(J,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:f.isPending,title:r(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:f.isPending?r(`pipeline.nodePipelineTab.resetting`,`Resetting…`):r(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var ba=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],xa=`decoder-nodeav`,Sa=`ntab`,Ca={decoder:`engine`},wa={engine:`Engine & decoder`},Ta=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function Ea({nodeId:t,refreshToken:n}){let{t:r}=Z(),[a,o]=jn(),{nodes:s}=K(),c=s.find(e=>e.id===t)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??xa,l=[...ba,c],u=a.get(Sa),d={assignments:{id:`assignments`,label:r(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:i($r,{nodeId:t,refreshToken:n})},tree:{id:`tree`,label:r(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:i(ya,{nodeId:t,refreshToken:n})},engines:{id:`engines`,label:r(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:i(ti,{nodeId:t,refreshToken:n})},logs:{id:`logs`,label:r(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:i(ii,{nodeId:t})}},f=Sr.map(e=>d[e]);return e(`div`,{className:`flex flex-col h-full`,children:[i(xr,{nodeId:t,refreshToken:n}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:i(Pn,{nodeId:t,addonIds:l,level:`global`,fieldScope:`perNode`,emptyMessage:Ta,tabAliases:Ca,tabLabelOverrides:wa,extraTabs:f,activeTab:u===null?null:Ca[u]??u,onActiveTabChange:e=>o(t=>{let n=new URLSearchParams(t);n.set(Sa,e);for(let e of Hn)n.delete(e);return n},{replace:!0})})})]})}function Da(){let{t}=Z();return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAssignmentsTab.pinACameraToA`,`Pin a camera to a node, or to one accelerator of its node; Auto lets each session pick. Decode always runs with detection. Load, shares and caps are on Load balancing.`)})]}),i(Zr,{})]})}s();function Oa(e,t){let n=new Set,r=e=>{n.add(e.addonId),e.children.forEach(r)};return t.forEach(r),e.filter(e=>!n.has(e.stepId)).map(e=>e.name)}function ka(){let{t}=Z(),r=qe(void 0,{refetchOnMount:`always`}),a=da(t(`pipeline.stepSwitches.loadFailed`,`Step switches did not load`)),s=fa(t(`pipeline.stepSwitches.writeFailed`,`The change was not saved`)),[c,l]=o(null),u=r.data??null,d=n(()=>u===null?[]:We(u),[u]),f=n(()=>ta(d),[d]),p=n(()=>a.status===`ready`&&u!==null?Oa(a.rows,d):[],[a,u,d]);return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`pipeline.clusterPipelineTab.title`,`Pipeline steps`)}),i(`p`,{className:G,children:t(`pipeline.clusterPipelineTab.hint`,`Off turns a step off for every camera. On runs it unless a camera turns it off. Opt-in runs it only on cameras that turn it on. A node or accelerator switch can still turn it off below that — those are on the node page.`)})]}),i(ca,{view:a,writers:s}),r.isError&&i(en,{title:t(`pipeline.clusterPipelineTab.catalogFailed`,`The step catalog did not load`),message:r.error.message}),r.isLoading&&i(ut,{className:`h-24 w-full`}),u!==null&&d.length===0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:t(`pipeline.clusterPipelineTab.noSteps`,`The catalog reports no pipeline steps.`)}),d.length>0&&i(fn,{tree:d,agents:[],label:t(`pipeline.clusterPipelineTab.label`,`Pipeline steps`),getCellState:()=>({kind:`na`}),onCellClick:()=>void 0,selectedCell:null,fallbackNodeId:c,onFallbackNodeChange:l,stepAction:e=>i(sa,{addonId:e,parents:f,view:a,writers:s})}),p.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`uncontrolled-steps`,children:t(`pipeline.clusterPipelineTab.missingSteps`,`Not in this tree, so their cluster mode cannot be set here: {{steps}}.`,{steps:p.join(`, `)})})]})}function Aa(e){return`${Math.round(e*100)}%`}function ja(e){return X.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var Ma={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"nvidia-gpu":`NVIDIA GPU (CUDA)`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},Na={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,"nvidia-gpu":`NVIDIA GPU (estimate)`,unknown:`Not measured`};function Pa(e){return e===null?`—`:Ma[e]??e}function Fa(e){return e===null?`—`:Na[e]??e}function Ia(e){switch(e.kind){case`capacity`:return X.t(`helpers.autoTuneViewModel.capacity`,{sessions:ja(e.sessions),min:e.minSessions});case`tie-faster`:return X.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:Aa(e.recallDelta)});case`stepped-down`:return X.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return X.t(`helpers.autoTuneViewModel.noFitLightest`,{min:ja(e.minSessions),sessions:ja(e.sessions)});case`derived-latency`:return X.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return X.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return X.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return X.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return X.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return X.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return X.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return X.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return X.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function La(e,t){switch(e.kind){case`custom-pin-kept`:return X.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey});case`custom-registry-unreadable`:return X.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function Ra(e){return{modelChanges:e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),thresholdClears:e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0)}}function za(e){let t=Ra(e);return t.modelChanges+t.thresholdClears===0}function Ba(e,t,n){let r=e.nodeChanges.find(e=>e.nodeId===t&&e.deviceKey===n)?.modelPins.find(e=>e.stepId===`object-detection`);return r===void 0?null:{before:r.before,after:r.after}}function Va(e,t){return e?.kind===`node-benchmark`?X.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):e?.kind===`estimated`?X.t(`helpers.autoTuneViewModel.latencyEstimated`,{hardware:Fa(e.estimatedFrom)}):X.t(`helpers.autoTuneViewModel.latencyTable`)}s();var Ha=[.3,.4,.5];function Ua(e){return Ha.some(t=>t===e)}var Wa=[1,2,3,4,6,8];function Ga({plan:t,node:n,nodeName:r}){let{t:a}=Z();return e(`section`,{className:b,"data-testid":`auto-tune-node-${n.nodeId}`,children:[e(`header`,{className:`${re} flex flex-wrap items-center gap-2`,children:[i(R,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${E} min-w-0 flex-1`,children:r(n.nodeId)}),e(`span`,{className:`text-[11px] text-foreground-subtle`,children:[Fa(n.hardwareClass),n.cpuModel===null?``:` · ${n.cpuModel}`]}),n.skipped?i(Y,{variant:`warning`,children:a(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):n.acceleratorModelId!==null&&i(Y,{variant:`info`,children:n.acceleratorModelId})]}),n.reasons.length>0&&i(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>i(`li`,{children:Ia(e)},t))}),i(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs`,children:[i(`thead`,{children:e(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.device`,`Device`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),i(`th`,{className:`px-3 py-1.5 font-medium`,children:a(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),i(`tbody`,{children:n.devices.map(r=>{let o=Ba(t,n.nodeId,r.deviceKey);return e(`tr`,{className:`border-t border-border align-top`,children:[e(`td`,{className:`px-3 py-1.5`,children:[i(`div`,{className:`font-mono text-foreground`,children:r.deviceKey}),i(`div`,{className:`text-[11px] text-foreground-subtle`,children:Pa(r.accelerator)})]}),e(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[r.chosen===null?`—`:a(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:r.chosen.capacitySessions,fps:t.cameraFps}),r.chosen!==null&&e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[a(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:r.chosen.fps,percent:Math.round(t.headroom*100)}),i(`div`,{children:Va(r.chosen.source)})]})]}),i(`td`,{className:`px-3 py-1.5`,children:r.chosen===null?i(`span`,{className:`text-foreground-subtle`,children:a(`common.unchanged`)}):o!==null&&o.before!==o.after?e(`span`,{children:[i(`span`,{className:`text-foreground-subtle`,children:o.before??a(`common.defaultWord`)}),` → `,i(`span`,{className:`font-medium text-foreground`,children:o.after})]}):i(`span`,{className:`text-foreground`,children:r.chosen.modelId})}),i(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:r.reasons.map((e,t)=>i(`div`,{children:Ia(e)},t))})]},r.deviceKey)})})]})})]})}function Ka({plan:t,nodeName:n}){let{t:r}=Z();return i(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:e(`div`,{children:[i(`div`,{className:E,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),t.nodeChanges.length===0?i(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):i(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:t.nodeChanges.flatMap(t=>[...t.modelPins.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`— `,i.stepId,`: `,i.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,i.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/pin`)),...t.thresholds.map(i=>e(`li`,{children:[e(`span`,{className:`font-mono`,children:[n(t.nodeId),` · `,t.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:i.stepId,keys:i.keys.join(`, `)})]},`${t.nodeId}/${t.deviceKey}/${i.stepId}/thr`))])})]})})}function qa({result:t}){let{t:n}=Z();return t.kind===`refused`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):t.kind===`stale`?i(`div`,{className:`text-xs text-warning`,children:n(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):e(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[t.kind===`aborted`&&i(`li`,{className:`text-danger`,children:n(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),t.phases.map(t=>e(`li`,{className:t.ok?`text-foreground-muted`:`text-danger`,children:[t.ok?`✓`:`✗`,` `,t.phase,`: `,t.detail]},t.phase))]})}function Ja(){let{t}=Z(),r=l(),[a,s]=o(.4),[c,u]=o(2),[d,f]=o(!1),[p,m]=o(!1),[h,g]=o(null),{nodes:_}=K(),v=n(()=>Ar(_),[_]),y=It({headroom:a,minSessionsPerDevice:c},{enabled:d,refetchOnWindowFocus:!1}),x=Je({onSuccess:e=>{g(e),m(!1),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),e.kind===`applied`&&y.refetch()}}),S=h?.kind===`stale`?h.plan:y.data,C=S===void 0?null:Ra(S);return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[e(`section`,{className:b,children:[e(`header`,{className:`${re} flex flex-wrap items-center gap-2`,children:[i(W,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),i(`h3`,{className:`${E} min-w-0 flex-1`,children:t(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),e(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[i(`p`,{children:t(`pipeline.clusterAutoTuneTab.picksForEveryAcceleratorThe`,`Picks, for every accelerator, the most accurate YOLOv9 detector that still carries at least the chosen number of cameras at once, from the node's hardware and measured speeds. Nothing is measured or estimated about your cameras' activity. Applying it sets those models on the accelerators and clears their threshold overrides, so each model runs its own default thresholds. Cameras carry no model or threshold of their own. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),i(F,{"aria-label":t(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(a),options:Ha.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(e*100)})})),onChange:e=>{let t=Number(e.target.value);Ua(t)&&s(t)}})]}),e(`label`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`whitespace-nowrap`,children:t(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),i(F,{"aria-label":t(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(c),options:Wa.map(e=>({value:String(e),label:t(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:e})})),onChange:e=>{let t=Number(e.target.value);Wa.some(e=>e===t)&&u(t)}})]}),i(J,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),f(!0),d&&y.refetch()},children:y.isFetching?t(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):S===void 0?t(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):t(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),S!==void 0&&i(J,{size:`sm`,disabled:za(S),onClick:()=>m(!0),children:t(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),y.error!==null&&i(`div`,{className:`text-danger`,children:y.error.message}),h!==null&&i(qa,{result:h}),C!==null&&i(`div`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:C.modelChanges,thresholdClears:C.thresholdClears})})]})]}),S?.warnings.map((e,t)=>i(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:La(e,v)},t)),S?.nodes.map(e=>i(Ga,{plan:S,node:e,nodeName:v},e.nodeId)),S!==void 0&&i(At,{open:p,onOpenChange:m,children:e(at,{width:`lg`,scroll:`body`,children:[e(Pt,{children:[i(Mt,{children:t(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),i(pn,{children:t(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),i(Ze,{children:i(Ka,{plan:S,nodeName:v})}),e(rt,{children:[i(J,{variant:`ghost`,onClick:()=>m(!1),children:t(`common.cancel`,`Cancel`)}),i(J,{variant:`danger`,disabled:x.isPending,onClick:()=>x.mutate({planHash:S.planHash,headroom:a,minSessionsPerDevice:c}),children:x.isPending?t(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):t(`common.apply`,`Apply`)})]})]})})]})}var Ya={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`,"root-switched-off":`pipeline.nodeLoadOverview.exclusion.rootSwitchedOff`,"no-gpu-device":`pipeline.nodeLoadOverview.exclusion.noGpuDevice`};function Xa(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function Za(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function Qa(e,t,n){let r=e.filter(e=>e.exclusion===null).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.map(e=>{let i=t.get(e.key)??(n?0:null),a=e.weight>0?e.weight:1;return{key:e.key,label:Be(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?Xa(a,r):null,maxSessions:e.maxSessions,atCap:e.maxSessions!==null&&i!==null&&i>=e.maxSessions,available:e.available,enabled:e.enabled,exclusion:e.exclusion}}).toSorted((e,t)=>e.exclusion===null==(t.exclusion===null)?e.key.localeCompare(t.key):e.exclusion===null?-1:1)}function $a(e){let t=new Map(e.loads.map(e=>[e.nodeId,e])),n=e.nodes.filter(e=>e.isOnline&&e.detectEnabled).reduce((e,t)=>e+(t.weight>0?t.weight:1),0);return e.nodes.map(r=>{let i=t.get(r.id),a=Qa(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),Za(i)),o=r.isOnline&&r.detectEnabled,s=r.weight>0?r.weight:1,c=i?.load.attachedCameras??null;return{nodeId:r.id,name:r.name,isOnline:r.isOnline,detectEnabled:r.detectEnabled,reported:i!==void 0,attachedCameras:c,activeCameras:i?.load.activeCameras??null,maxCameras:r.maxCameras,capacityPct:c!==null&&r.maxCameras!==null&&r.maxCameras>0?Xa(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?Xa(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}s();var eo=2e4,to=3e5;function no({stats:e,targetWeights:t,showAccelerators:r=!0}){let{t:a}=Z(),{nodes:o}=K(),s=oe().trpcClient,l=$t(void 0,{placeholderData:u,staleTime:eo,refetchInterval:eo,refetchOnWindowFocus:!0}),d=Nt(void 0,{staleTime:to}),f=n(()=>o.map(e=>e.id),[o]),p=c({queries:f.map(e=>({queryKey:Re(Zt.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>s.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:to,refetchOnWindowFocus:!1,placeholderData:u}))}),h=n(()=>{let e={};return f.forEach((t,n)=>{let r=p[n]?.data;r&&(e[t]=r.devices)}),e},[f,p.map(e=>e.dataUpdatedAt).join(`|`)]),g=n(()=>{let e=new Map;for(let t of d.data??[])e.set(t.nodeId,t.settings);return e},[d.data]),_=n(()=>o.map(e=>{let n=g.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:vr(n).pipeline,weight:t?.[e.id]??or(n,`detectWeight`)??1,maxCameras:or(n,`maxCameras`)}}),[o,g,t]),v=l.data??[],y=n(()=>$a({nodes:_,loads:v,devicesByNode:h}),[_,v,h]),b=y.reduce((e,t)=>e+(t.attachedCameras??0),0),x=y.reduce((e,t)=>e+(t.activeCameras??0),0),C=l.dataUpdatedAt>0?Date.now()-l.dataUpdatedAt:null,w=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return i(q,{headingId:`load-balancing-node-load`,title:a(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:S,actions:i(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:a(`pipeline.nodeLoadOverview.summaryLine`,{active:x,attached:b,reading:l.data===void 0?a(`pipeline.nodeLoadOverview.reading`,`reading…`):a(`pipeline.nodeLoadOverview.readingAge`,{age:C===null?`—`:`${Math.round(C/1e3)}s`})})}),children:i(`div`,{className:m,children:y.length===0?i(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):i(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:y.map(e=>i(ro,{row:e,placed:w.get(e.nodeId),showAccelerators:r},e.nodeId))})})})}function ro({row:t,placed:n,showAccelerators:r}){let{t:a}=Z(),o=t.attachedCameras===null?`—`:`${t.activeCameras??0} / ${t.attachedCameras}${t.maxCameras===null?``:` of ${t.maxCameras}`}`;return e(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[i(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${t.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),i(`span`,{className:`truncate text-xs font-medium text-foreground`,title:t.nodeId,children:t.name}),!t.detectEnabled&&i(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!t.reported&&t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:a(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[i(k,{className:`h-2.5 w-2.5`}),` `,a(`pipeline.nodeLoadOverview.noReading`)]}),!t.isOnline&&e(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[i(z,{className:`h-2.5 w-2.5`}),` `,a(`common.offline`)]})]}),e(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[i(oo,{label:a(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:o,title:a(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),i(oo,{label:a(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:t.weightSharePct===null?`out of play`:`${t.weightSharePct}%`,title:a(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),i(oo,{label:a(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:n?.observedShare===null||n===void 0?`—`:`${Math.round(n.observedShare*100)}%`,title:a(`pipeline.nodeLoadOverview.timeWeightedShareOfThe`,`Time-weighted share of the cluster's PARALLEL detection sessions this node carried over the last hour — the quantity a share holds. '—' = no session ran here in the window.`)}),i(oo,{label:a(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:n===void 0?`—`:`${n.peakSessions} · ${n.yieldsAway}`,title:a(`pipeline.nodeLoadOverview.mostSessionsThisNodeRan`,`Most sessions this node ran at once in the last hour, and how many share turns it handed to another node because it was full or drowning.`)}),i(oo,{label:a(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:t.score===null?`—`:`${t.score} · ${t.queueDepthTotal??0}`,title:a(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),t.capacityPct!==null&&i(oo,{label:a(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${t.capacityPct}%`,title:a(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),t.avgInferenceTimeMs!==null&&i(oo,{label:a(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(t.avgInferenceTimeMs)} ms`,title:a(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),t.decodeHwaccel!==null&&i(oo,{label:a(`pipeline.nodeLoadOverview.decode`,`Decode`),value:t.decodeHwaccel,title:a(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),r&&i(io,{row:t})]})}function io({row:t}){let{t:n}=Z();return t.devices.length===0?i(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):e(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[e(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[i(j,{className:`h-2.5 w-2.5`}),n(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),t.eligibleDeviceCount===0&&i(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:n(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:n(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),i(`ul`,{className:`mt-1 space-y-0.5`,children:t.devices.map(e=>i(ao,{device:e},e.key))})]})}function ao({device:t}){let{t:n}=Z(),r=t.exclusion;return e(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[i(R,{className:`h-2.5 w-2.5 shrink-0 ${r===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),i(`span`,{className:`shrink-0 font-medium ${r===null?`text-foreground`:`text-foreground-subtle`}`,title:`${t.key} · ${t.format}`,children:t.label}),r===null?e(d,{children:[i(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.sharePct`,{pct:t.weightSharePct})}),e(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:t.sessions===null?n(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,n(`common.sessionsCount`,{count:t.sessions??0}),t.maxSessions===null?``:`/${t.maxSessions}`]}),t.atCap&&i(`span`,{className:`shrink-0 text-amber-400`,title:n(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:n(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):i(`span`,{className:`truncate text-foreground-subtle/80`,title:n(Ya[r]),children:n(`pipeline.nodeLoadOverview.excludedWith`,{reason:n(Ya[r])})})]})}function oo({label:t,value:n,title:r}){return e(`div`,{className:`min-w-0`,title:r,children:[i(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:t}),i(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:n})]})}function so(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function co(e){let t={},n={};for(let r of e.nodes){if(r.share===null||r.share<=0)continue;t[r.nodeId]=r.share;let e=Object.fromEntries(r.devices.filter(e=>e.share>0).map(e=>[e.deviceKey,e.share]));Object.keys(e).length>0&&(n[r.nodeId]=e)}return{nodes:t,devices:n}}function lo(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function uo(e){return e.reason===`disabled`?X.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):X.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function fo(e,t){if(t===void 0||t.source===`manual`||t.autoPending)return{nodes:e,readOnly:t!==void 0&&t.source!==`manual`};let n=new Map(t.nodes.map(e=>[e.nodeId,e.configuredPct]));return{nodes:e.map(e=>({...e,weight:Math.round(n.get(e.id)??e.weight)})),readOnly:!0}}function po(e,t){let n=e.nodes.filter(e=>!e.eligible);if(n.length===0)return null;let r=e.nodes.filter(e=>e.eligible).map(e=>`${t(e.nodeId)} ${Math.round(e.effectivePct)}%`).join(`, `),i=n.map(e=>t(e.nodeId)).join(`, `);return X.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var mo=[{value:`hardware`,get label(){return X.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return X.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return X.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return X.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return X.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return X.t(`helpers.loadBalancingViewModel.manualHint`)}}];function ho(e){return e===`no-benchmark-results`?X.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?X.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function go(e,t){if(e.source!==`benchmark`)return null;let n=e.nodes.filter(e=>e.capacityFallback!==null);return n.length===0?null:n.map(e=>`${t(e.nodeId)}: ${ho(e.capacityFallback)??``}`).join(` · `)}s();function _o(e,t,n){return Math.min(Math.max(e,t),n)}function vo(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 yo(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:_o(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function bo(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function xo({nodes:t,pending:n,onCommitWeights:r,weightLabel:s=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:f}=Z(),[p,m]=o(()=>vo(t)),[h,g]=o(new Set);a(()=>{m(vo(t)),g(e=>new Set([...e].filter(e=>t.some(t=>t.id===e))))},[t.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let y=t.map(e=>e.id),b=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},x=(e,t)=>{m(n=>yo(n,e,t,h,y))},S=()=>{let e=bo(p,y,h),n=t.filter(t=>(e[t.id]??0)!==t.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...h]);r(t.filter(e=>i.has(e.id)).map(t=>({nodeId:t.id,weight:e[t.id]??0})))};if(t.length===0)return i(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??f(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let C=t.length===1;return e(`div`,{className:`space-y-3`,children:[t.map(t=>{let r=p[t.id]??0,a=h.has(t.id);return e(`div`,{className:`flex items-center gap-3`,children:[i(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:t.name,children:t.name}),i(P,{"aria-label":f(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:s,name:t.name}),min:0,max:100,step:1,value:Math.round(r),disabled:u||n||a||C,onChange:e=>x(t.id,Number(e.target.value)),onPointerUp:()=>S(),onKeyUp:()=>S(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),e(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(r),`%`]}),!u&&i(J,{variant:`unstyled`,type:`button`,onClick:()=>b(t.id),disabled:n||C,"aria-pressed":a,title:a?f(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):f(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${a?`text-amber-400`:`text-foreground-subtle`}`,children:i(a?_:v,{className:`h-3.5 w-3.5`})})]},t.id)}),i(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??i(d,{children:f(`placementBoard.weightSliderStack.draggingOneSliderSplitsThe`,`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`)})})]})}function So(e){let t=e.steps?.[`object-detection`]?.modelId;return typeof t==`string`&&t.length>0?t:typeof e.defaultModelId==`string`&&e.defaultModelId.length>0?e.defaultModelId:null}function Co(e){if(e.presence===`absent`)return`absent`;if(e.presence===`unknown`)return`unknown`;switch(e.exclusion){case null:return`active`;case`disabled`:return`disabled`;case`unavailable`:return e.available?`backoff`:`unavailable`;case`no-gpu-device`:return`unavailable`;case`cannot-host-camera-root`:return`root-incapable`;case`accelerator-preferred`:return`standby`;case`root-switched-off`:return`root-off`}}function wo(e,t,n){let r=new Map((t?.devices??[]).map(e=>[e.deviceKey,e])),i=new Map((n?.devices??[]).map(e=>[e.deviceKey,e.sessionsNow]));return e.map(e=>{let t=r.get(e.key),a=n===void 0?null:i.get(e.key)??0;return{device:e,state:Co(e),share:t===void 0?null:{configuredPct:t.configuredPct,effectivePct:t.effectivePct},sessionsNow:a,atCap:a!==null&&e.maxSessions!==null&&a>=e.maxSessions}})}var To={active:`success`,disabled:`neutral`,absent:`danger`,unknown:`neutral`,unavailable:`warning`,backoff:`warning`,"root-incapable":`info`,"root-off":`neutral`,standby:`neutral`};s();function Eo(e){let t=Be(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:R,hue:`slate`}:r===`npu`?{label:t,Icon:U,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:je,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Fe,hue:`emerald`}:{label:t,Icon:R,hue:`slate`}}var Do={active:[`placementBoard.nodeInferenceDevices.state.active`,`in use`],disabled:[`placementBoard.nodeInferenceDevices.state.disabled`,`switched off`],absent:[`placementBoard.nodeInferenceDevices.state.absent`,`absent`],unknown:[`placementBoard.nodeInferenceDevices.state.unknown`,`unknown`],unavailable:[`placementBoard.nodeInferenceDevices.state.unavailable`,`unavailable`],backoff:[`placementBoard.nodeInferenceDevices.state.backoff`,`pool down`],"root-incapable":[`placementBoard.nodeInferenceDevices.state.rootIncapable`,`no root model`],"root-off":[`placementBoard.nodeInferenceDevices.state.rootOff`,`detection off`],standby:[`placementBoard.nodeInferenceDevices.state.standby`,`fallback`]},Oo={active:[`placementBoard.nodeInferenceDevices.stateHint.active`,`A camera-root candidate: placement may start sessions on it.`],disabled:[`placementBoard.nodeInferenceDevices.stateHint.disabled`,`Switched off: it takes no sessions.`],absent:[`placementBoard.nodeInferenceDevices.stateHint.absent`,`The node no longer reports this device (unplugged, or moved to another node). Its settings are kept; it is never used. Forget it to delete them.`],unknown:[`placementBoard.nodeInferenceDevices.stateHint.unknown`,`The node's probe did not answer, so whether the device is there is not known.`],unavailable:[`placementBoard.nodeInferenceDevices.stateHint.unavailable`,`On the node, but the probe reports it unusable.`],backoff:[`placementBoard.nodeInferenceDevices.stateHint.backoff`,`Reported by the node, but its inference pool is down or backing off.`],"root-incapable":[`placementBoard.nodeInferenceDevices.stateHint.rootIncapable`,`Its format cannot run the camera root detector; it serves enrichment steps only.`],"root-off":[`placementBoard.nodeInferenceDevices.stateHint.rootOff`,`Object detection is switched off on this device, its node or the cluster: it hosts no camera and serves enrichment steps only.`],standby:[`placementBoard.nodeInferenceDevices.stateHint.standby`,`The CPU fallback: it takes no sessions while an accelerator is serving this node.`]};function ko({nodeId:t,nodeName:r,isOnline:s,suggestedMaxSessions:c,shareSource:u,sharesAutomatic:f,share:p,placed:m}){let{t:h}=Z(),g=l(),{data:_,isLoading:v}=Tt({nodeId:t},{refetchInterval:15e3}),y=()=>{g.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},b=hn({onSettled:y}),x=Ue({onSettled:y}),S=Zt.platformProbe.rescanAccelerators.useMutation({onSettled:y}),C=_?.devices??[],w=_?.reachable??s,[T,ee]=o({});a(()=>{ee(Object.fromEntries(C.map(e=>[e.key,Ao(e)])))},[C.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let te=n(()=>C.filter(e=>(T[e.key]?.enabled??e.enabled)&&e.available).length,[C,T]),[E,D]=o(null),k=E??!0,A=e=>{let n=C.map(t=>{let n=e[t.key]??Ao(t);return{key:t.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});b.mutate({agentNodeId:t,inferenceDevices:si(n)})},j=(e,t)=>{let n=T[e.key]??Ao(e),r={...T,[e.key]:{...n,...t}};ee(r),A(r)},M=n(()=>wo(C,p,m),[C,p,m]),N=n(()=>C.filter(e=>(T[e.key]?.enabled??e.enabled)&&e.available),[C,T]),P=n(()=>N.map(e=>({id:e.key,name:Eo(e).label,weight:T[e.key]?.weight??e.weight})),[N,T]),F=e=>{let t={...T};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}ee(t),A(t)},I=b.isPending||x.isPending,L=jo(h,f?u:`manual`),R=[{key:`device`,header:h(`placementBoard.nodeInferenceDevices.colDevice`,`Device`),nowrap:!1,sortValue:e=>Eo(e.device).label,render:e=>i(No,{row:e,steps:T[e.device.key]?.steps})},{key:`state`,header:h(`placementBoard.nodeInferenceDevices.colState`,`State`),sortValue:e=>e.state,render:e=>i(`span`,{title:h(Oo[e.state][0],Oo[e.state][1]),children:i(Y,{variant:To[e.state],size:`sm`,children:h(Do[e.state][0],Do[e.state][1])})})},{key:`share`,header:h(`placementBoard.nodeInferenceDevices.colShare`,`Share`),align:`right`,sortValue:e=>e.share?.effectivePct??null,render:e=>i(Po,{row:e,sourceLabel:L})},{key:`sessions`,header:h(`placementBoard.nodeInferenceDevices.colSessions`,`Sessions`),align:`right`,sortValue:e=>e.sessionsNow,render:t=>e(`span`,{className:`tabular-nums text-xs text-foreground`,children:[t.sessionsNow??`—`,t.atCap&&i(Y,{variant:`warning`,size:`sm`,className:`ml-1`,children:h(`placementBoard.nodeInferenceDevices.atCap`,`at cap`)})]})},{key:`cap`,header:h(`placementBoard.nodeInferenceDevices.colCap`,`Max sessions`),notSortableReason:h(`placementBoard.nodeInferenceDevices.capNotSortable`,`An editable field: sort by Sessions instead.`),render:t=>{let n=T[t.device.key]??Ao(t.device);if(!(n.enabled&&t.device.available))return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let r=Eo(t.device).label;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[i(ht,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10);j(t.device,{maxSessions:r!==null&&r>0?r:null})},disabled:I,"aria-label":h(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:r}),className:`w-16 text-right`}),i(Fo,{suggested:c?.[t.device.key]??null,current:n.maxSessions,pending:I,onApply:e=>j(t.device,{maxSessions:e})})]})}},{key:`enabled`,header:h(`placementBoard.nodeInferenceDevices.colEnabled`,`Enabled`),align:`right`,notSortableReason:h(`placementBoard.nodeInferenceDevices.enabledNotSortable`,`A switch: sort by State instead.`),render:e=>{let n=Eo(e.device).label;if(e.state===`absent`)return i(He,{label:h(`placementBoard.nodeInferenceDevices.forget`,`Forget`),icon:V,size:`sm`,triggerVariant:`ghost`,disabled:I,title:h(`placementBoard.nodeInferenceDevices.forgetTitle`,`Forget {{label}} on {{node}}?`,{label:n,node:r}),description:h(`placementBoard.nodeInferenceDevices.forgetDescription`,`Its stored settings (switch, weight, cap, step models) are deleted. If the device comes back it starts from the defaults.`),action:()=>x.mutateAsync({agentNodeId:t,deviceKey:e.device.key})});let a=T[e.device.key]??Ao(e.device);return i(on,{checked:a.enabled&&e.device.available,onCheckedChange:()=>j(e.device,{enabled:!a.enabled}),disabled:!e.device.available||I,"aria-label":h(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:n})})}}],re=b.error??x.error??S.error;return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[e(J,{variant:`ghost`,size:`sm`,onClick:()=>D(!k),className:`min-w-0 flex-1 justify-start`,"aria-expanded":k,children:[i(ne,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${k?`rotate-90`:``}`}),i(`span`,{className:`truncate text-sm font-medium text-foreground`,children:r}),i(`span`,{className:`ml-auto flex items-center gap-1 text-xs text-foreground-subtle`,children:w?e(d,{children:[i(Le,{className:`h-3.5 w-3.5`}),h(`pipeline.nodeInferenceDevices.accelerators`,{count:te})]}):e(d,{children:[i(z,{className:`h-3.5 w-3.5`}),` `,h(`common.unreachable`)]})})]}),e(J,{variant:`ghost`,size:`sm`,onClick:()=>S.mutate({nodeId:t}),disabled:S.isPending||!w,title:h(`placementBoard.nodeInferenceDevices.rescanTitle`,`Probe this node for accelerators now (a Coral plugged in or pulled out). The node also re-probes every minute.`),children:[i(O,{className:`h-3.5 w-3.5 ${S.isPending?`animate-spin`:``}`}),h(`placementBoard.nodeInferenceDevices.rescan`,`Rescan`)]})]}),k&&e(`div`,{className:`space-y-3 border-t border-border p-3`,children:[w?v&&C.length===0?i(`p`,{className:`text-center text-xs text-foreground-subtle`,children:h(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):i(Ge,{columns:R,rows:M,rowKey:e=>e.device.key,minWidthPx:640,bordered:!1,emptyMessage:h(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):i(Io,{}),S.data!==void 0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:Mo(h,S.data.appeared,S.data.disappeared)}),w&&!f&&N.length>=2&&e(`div`,{className:`space-y-3 rounded-lg border border-border p-3`,children:[e(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[i(Ne,{className:`h-3.5 w-3.5`}),h(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),i(xo,{nodes:P,pending:I,onCommitWeights:F,weightLabel:`Accelerator share`,footnote:h(`placementBoard.nodeInferenceDevices.dragToShiftTheShare`,`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`)})]}),re!=null&&e(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-xs text-danger`,children:[h(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,re.message]})]})]})}function Ao(e){return{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}}function jo(e,t){switch(t){case`benchmark`:return e(`placementBoard.nodeInferenceDevices.sourceBenchmark`,`benchmark`);case`hardware`:return e(`placementBoard.nodeInferenceDevices.sourceHardware`,`hardware`);case`manual`:return e(`placementBoard.nodeInferenceDevices.sourceManual`,`manual`);case void 0:return null}}function Mo(e,t,n){return t.length===0&&n.length===0?e(`placementBoard.nodeInferenceDevices.rescanNoChange`,`Rescanned: no change.`):e(`placementBoard.nodeInferenceDevices.rescanChanged`,`Rescanned: appeared {{appeared}} · disappeared {{disappeared}}`,{appeared:t.length>0?t.join(`, `):`—`,disappeared:n.length>0?n.join(`, `):`—`})}function No({row:t,steps:n}){let r=Eo(t.device),a=So({defaultModelId:t.device.defaultModelId,steps:n??t.device.steps??{}});return e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i(r.Icon,{className:`h-4 w-4 shrink-0 text-foreground-subtle`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:r.label}),i(Y,{variant:`neutral`,size:`sm`,className:`font-mono`,children:t.device.format})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-1.5 text-xs text-foreground-subtle`,children:[i(`span`,{className:`font-mono`,children:t.device.key}),a!==null&&e(d,{children:[i(`span`,{"aria-hidden":!0,children:`·`}),i(`span`,{children:i(Nn,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:a},components:{mono:i(`span`,{className:`font-mono text-foreground-muted`})}})})]})]})]})]})}function Po({row:t,sourceLabel:n}){let{t:r}=Z();if(t.share===null)return i(`span`,{className:`text-xs text-foreground-subtle`,children:`—`});let{configuredPct:a,effectivePct:o}=t.share,s=Math.round(a)!==Math.round(o);return e(`div`,{className:`text-right`,children:[e(`div`,{className:`tabular-nums text-sm text-foreground`,children:[Math.round(o),`%`]}),e(`div`,{className:`text-xs text-foreground-subtle`,children:[s?r(`placementBoard.nodeInferenceDevices.shareConfigured`,`set {{pct}}%`,{pct:Math.round(a)}):null,s&&n!==null?` · `:null,n]})]})}function Fo({suggested:e,current:t,pending:n,onApply:r}){let{t:a}=Z();return e===null||e<1||e===t?null:i(J,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:a(`placementBoard.nodeInferenceDevices.advisoryCapFromTheMeasured`,`Advisory cap from the measured throughput at the suggested model, with the headroom kept free. Applying it writes this device's cap.`),children:a(`pipeline.nodeInferenceDevices.use`,{value:e})})}function Io(){let{t}=Z();return e(`div`,{className:`flex flex-col items-center gap-2 px-4 py-6 text-center`,children:[i(z,{className:`h-6 w-6 text-foreground-subtle`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:t(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),i(`p`,{className:`max-w-sm text-xs text-foreground-subtle`,children:t(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}s();var Lo=3600*1e3,Ro=2e4,zo=.4;function Bo({refreshToken:t,onOpenAutoTune:r}){let{t:a}=Z(),s=l(),{nodes:c}=K(),f=Nt(void 0),p=ze({isCamera:!0,projection:`slim`}),h=mn({windowMs:Lo},{refetchInterval:Ro,placeholderData:u}).data,g=Ot(void 0,{refetchInterval:Ro,placeholderData:u}).data,_=()=>{nr(s),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=an({onSuccess:_}),y=Cn({onSuccess:()=>{_(),s.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=Xt({onSuccess:_}),x=yt(),[S,C]=o(!1),w=g?.source,ee=w===`benchmark`?`benchmark`:`hardware`,E=On({headroom:zo,source:ee},{enabled:S,staleTime:1/0}),D=E.data,O=n(()=>{let e=new Map((f.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>vr(e.get(t.id)).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:or(n,`detectWeight`)??1,maxCameras:or(n,`maxCameras`)}})},[c,f.data]),k=e=>c.find(t=>t.id===e)?.name??e,ne=jr((p.data??[]).map(e=>({id:e.id,name:e.name}))),A=D?lo(D):void 0,j=fo(O,g),M=w!==`manual`,N=g!==void 0&&g.source!==`manual`&&!g.autoPending,P=e=>g?.nodes.find(t=>t.nodeId===e),F=e=>h?.nodes.find(t=>t.nodeId===e),I=g?po(g,k):null,L=g?go(g,k):null,z=mo.find(e=>e.value===w)?.hint;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[i(Cr,{refreshToken:t}),i(no,{stats:h,showAccelerators:!1,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),i(q,{headingId:`load-balancing-node-shares`,title:a(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:Ne,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`div`,{role:`radiogroup`,"aria-label":a(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:mo.map(e=>i(J,{role:`radio`,"aria-checked":w===e.value,variant:w===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{w!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),e(J,{variant:`outline`,size:`sm`,onClick:()=>{C(!0),S&&E.refetch()},disabled:E.isFetching,children:[i(te,{className:`h-3.5 w-3.5`}),E.isFetching?a(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):ee===`benchmark`?a(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):a(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),e(J,{variant:`ghost`,size:`sm`,onClick:r,children:[i(W,{className:`h-3.5 w-3.5`}),a(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),e(J,{variant:`outline`,size:`sm`,onClick:()=>x.mutate(void 0),disabled:x.isPending,title:a(`pipeline.clusterLoadBalancingTab.moveStandingAlwaysOnCameras`,`Move standing (always-on) cameras that are no longer on their best node. Pinned cameras never move; on-motion sessions are placed per session anyway.`),children:[i(U,{className:`h-3.5 w-3.5`}),x.isPending?a(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):a(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:e(`div`,{className:`${m} space-y-3`,children:[z!==void 0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:z}),h&&e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[a(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,i(Y,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?a(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${a(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${a(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),i(xo,{nodes:j.nodes,pending:v.isPending,readOnly:j.readOnly,onCommitWeights:e=>v.mutate(so(e)),weightLabel:`Node share`,...j.readOnly?{footnote:g?.autoPending?i(d,{children:a(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):e(d,{children:[w===`benchmark`?a(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):a(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),a(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&i(`span`,{className:`ml-1`,children:a(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),I!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:I}),L!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:L}),y.isError&&i(en,{message:a(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:a(`common.unknownError`)})}),v.isError&&i(en,{message:a(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:a(`common.unknownError`)})}),e(`details`,{className:`rounded-md border border-border`,children:[i(`summary`,{className:`${T} cursor-pointer text-xs text-foreground`,children:a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),i(`ul`,{className:`divide-y divide-border border-t border-border`,children:O.map(t=>e(`li`,{className:`${T} flex items-center gap-2`,children:[i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:t.name}),i(ht,{type:`number`,min:1,placeholder:`∞`,defaultValue:t.maxCameras??``,"aria-label":a(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:t.name}),className:`w-20 text-right`,disabled:b.isPending,onBlur:e=>{let n=e.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==t.maxCameras&&b.mutate({agentNodeId:t.id,maxCameras:i})}})]},t.id))}),i(`p`,{className:`${T} ${G} border-t border-border`,children:a(`pipeline.clusterLoadBalancingTab.aHardCapOnThe`,`A hard cap on the sessions a node runs at once (always-on cameras count too). A node at its cap is never chosen; under shares its turn goes to a free node. Empty = unlimited.`)})]})]})}),E.isError&&i(en,{message:a(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:E.error instanceof Error?E.error.message:a(`common.unknownError`)})}),D&&i(Vo,{suggestion:D,nameOf:k,pending:v.isPending,...M?{}:{onApply:()=>v.mutate(co(D))}}),i(q,{headingId:`load-balancing-accelerators`,title:a(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:R,children:i(`div`,{className:`${m} space-y-2`,children:O.length===0?i(Sn,{title:a(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:a(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):O.map(e=>i(ko,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...A?.[e.id]===void 0?{}:{suggestedMaxSessions:A[e.id]},sharesAutomatic:N,...g===void 0?{}:{shareSource:g.source},...P(e.id)===void 0?{}:{share:P(e.id)},...F(e.id)===void 0?{}:{placed:F(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&i(Ho,{stats:h,cameraName:ne})]})}function Vo({suggestion:t,nameOf:n,pending:r,onApply:a}){let{t:o}=Z();return e(q,{headingId:`load-balancing-suggestion`,title:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):o(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:te,...a===void 0?{}:{actions:i(J,{size:`sm`,onClick:a,disabled:r,children:o(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[i(`ul`,{className:`divide-y divide-border`,children:t.nodes.map(t=>e(`li`,{className:`${T} space-y-0.5`,children:[e(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[i(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:n(t.nodeId)}),i(`span`,{className:`tabular-nums text-foreground`,children:t.share===null?o(`common.skipped`):`${t.share}%`})]}),e(`p`,{className:G,children:[ho(t.capacityFallback)===null?``:`${ho(t.capacityFallback)} · `,t.skippedReason===null?o(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:t.capacitySessions,value2:t.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):o(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:t.skippedReason})]})]},t.nodeId))}),e(`p`,{className:`${T} ${G} border-t border-border`,children:[o(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:t.cameraFps,headroom:Math.round(t.headroom*100),basis:t.source===`benchmark`?o(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):o(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:t.minSessionsPerDevice})}),` `,a===void 0?o(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):o(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function Ho({stats:t,cameraName:n}){let{t:r}=Z(),a=l(),o=Lt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return i(q,{headingId:`load-balancing-stale-pins`,title:r(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:Pe,children:i(`ul`,{className:`divide-y divide-border`,children:t.stalePins.map(t=>e(`li`,{className:`${T} flex items-center gap-2`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs text-foreground`,title:n(t.deviceId),children:n(t.deviceId)}),i(`p`,{className:G,children:uo(t)})]}),i(J,{variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate({deviceId:t.deviceId,deviceKey:`auto`}),children:r(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},t.deviceId))})})}function Uo({node:t,emphasis:n=!1}){let{t:r}=Z(),a=t.isHub?C:R;return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[i(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),i(a,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-1.5 ${n?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[i(`span`,{className:`truncate`,children:t.name}),t.isHub&&i(Y,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.hubWord`)}),!t.isOnline&&i(Y,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:r(`common.offline`)})]}),i(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:t.id})]})]})}function Wo({nodes:e,actions:t}){let{t:n}=Z();return i(Ge,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>i(Uo,{node:e})},...lr.map(e=>({key:e.key,header:n(e.labelKey),align:`center`,notSortableReason:`A switch — sorting would move the row while it is being changed.`,render:r=>i(on,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:tr(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function Go({roleValues:t,options:n,pending:r,onRoleChange:a}){let{t:o}=Z(),s=n.map(e=>({value:e.id,label:e.id===`hub`?o(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return i(`ul`,{className:`divide-y divide-border`,children:fr.map(n=>e(`li`,{className:`${T} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[e(`div`,{className:`min-w-0 flex-1 basis-56`,children:[i(`div`,{className:`text-xs font-medium text-foreground`,children:mr(n)}),i(`p`,{className:G,children:pr(n)})]}),i(`div`,{className:`w-full sm:w-48`,children:i(F,{"aria-label":o(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:mr(n)}),value:t[n],disabled:r,options:s,onChange:e=>a(n,e.target.value)})})]},n))})}s();function Ko(){let{t}=Z(),r=l(),{nodes:a}=K(),o=Nt(void 0),s=xn({addonId:ir,cap:$n,scope:`cluster`}),c=xn({addonId:ur,cap:er,scope:`cluster`}),u=xn({addonId:dr,cap:sr,scope:`cluster`}),d=()=>nr(r),f=cn({onSuccess:d}),p=_n({onSuccess:d}),m=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.nodeId,t.settings);return e},[o.data]),h=n(()=>a.map(e=>{let t=m.get(e.id),n=vr(t);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[a,m]),g={ingestNode:rr(s.data,`ingestNode`,`hub`),recordingNode:rr(c.data,ar,`hub`),audioNode:rr(s.data,`audioNode`,`hub`),motionNode:rr(s.data,`motionNode`,`hub`),postProcessingNode:rr(u.data,cr,`hub`)},_=n(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id),t=e=>a.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...fr.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[a,g]),v=o.isLoading||s.isLoading||c.isLoading||u.isLoading,y=(e,t,n)=>{f.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:ur,cap:er,scope:`cluster`,patch:{[ar]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:dr,cap:sr,scope:`cluster`,patch:{[cr]:t}});return}p.mutate({addonId:ir,cap:$n,scope:`cluster`,patch:{[e]:t}})},x={capabilityPending:f.isPending,onToggleCapability:y},S=v?i(se,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":t(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[e(q,{headingId:`roles-nodes-cluster-roles`,title:t(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:Me,actions:S,children:[i(`p`,{className:`${G} border-b border-border px-3 py-1.5 sm:px-4`,children:t(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),i(Go,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),i(q,{headingId:`roles-nodes-node-capabilities`,title:t(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:C,children:i(Wo,{nodes:h,actions:x})})]})}s();var qo=2500,Jo={faces:g,"semantic-search":W,"detail-crop":Ie,"native-lease":Le,streaming:D,recorder:I,"runner-defaults":R,"load-balancer":Ne,failover:x},Yo=[`cluster`,wi];function Xo(e){a(()=>{if(e===null)return;let t=Ei[e]??e,n=`[data-cluster-settings-card="${CSS.escape(t)}"]`,r=()=>{let e=document.querySelector(n);return e===null?!1:(e.scrollIntoView({block:`start`,behavior:`smooth`}),e.classList.add(`ring-2`,`ring-primary/60`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-primary/60`),qo),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function Zo({section:t}){let{t:n}=Z();return i(`div`,{"data-cluster-settings-card":t.id,className:`rounded-lg`,children:i(q,{headingId:`cluster-settings-${t.id}`,title:t.title,...Jo[t.id]===void 0?{}:{icon:Jo[t.id]},children:e(`div`,{className:`${m} space-y-3`,children:[i(`p`,{className:G,children:t.hint}),t.panels.map(e=>i(Pn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:Yo.filter(t=>!(e.sectionIds??[]).includes(t)),emptyMessage:n(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.omitFieldKeys===void 0?{}:{omitFieldKeys:e.omitFieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}:${(e.sectionIds??e.fieldKeys??[]).join(`,`)}`))]})})})}function Qo({refreshToken:e}){let[t]=jn();return Xo(t.get(ki)),i(`div`,{className:`space-y-3 sm:space-y-4`,children:Ti.map(e=>i(Zo,{section:e},e.id))})}function $o(e){return e?.hex}function es({hex:e}){return i(`span`,{className:`inline-block h-3 w-3 shrink-0 rounded-sm border border-border`,style:{backgroundColor:e}})}function ts({id:t,label:n,swatch:r}){let a=$o(r);return a===void 0?null:e(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs`,"data-testid":`palette-entry-${t}`,children:[r?.form===`gradient`?i(`span`,{className:`flex h-4 overflow-hidden rounded-sm`,children:Ce.map(e=>i(`span`,{className:`h-4 w-2`,style:{backgroundColor:a,opacity:e}},e))}):i(`span`,{className:`h-4 w-3 shrink-0 rounded-sm`,style:{backgroundColor:a}}),i(`span`,{children:n}),i(`span`,{className:`font-mono text-[11px] opacity-80`,children:a})]})}function ns({ground:t,group:n,swatches:r}){let{t:a}=Z();return e(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[i(ts,{id:n.id,label:n.label,swatch:r[n.id]}),n.children.length>0&&e(`details`,{"data-testid":`palette-subs-${t}-${n.id}`,children:[i(`summary`,{className:`cursor-pointer text-[11px] opacity-80`,children:a(`pipeline.palette.subclasses`,`Subclasses`)}),i(`div`,{className:`mt-1 flex flex-col gap-1 pl-4`,children:n.children.map(e=>i(ts,{id:e.id,label:e.label,swatch:r[e.id]},e.id))})]})]})}function rs({swatches:t}){let{t:n}=Z(),r=he(),a=[{id:`dark`,background:Se.dark,ink:Se.light},{id:`light`,background:Se.light,ink:Se.dark}];return e(`div`,{className:`flex flex-col gap-2`,"data-testid":`palette-preview`,children:[i(`div`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.palette.preview`,`Timeline marks`)}),a.map(e=>i(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-2 rounded-md border border-border p-2 sm:grid-cols-2`,"data-testid":`palette-ground-${e.id}`,style:{backgroundColor:e.background,color:e.ink},children:r.map(n=>i(ns,{ground:e.id,group:n,swatches:t},n.id))},e.id))]})}function is(e){for(let t of he()){if(t.id===e)return t.label;let n=t.children.find(t=>t.id===e);if(n!==void 0)return n.label}return e}s();function as(e){return/^#[0-9a-f]{6}$/.test(e)}function os(e,t){let n={};for(let r of xe){let i=t[r],a=e[r];i===void 0||a===void 0||i.hex!==a.hex&&(n[r]=i)}return n}function ss({status:t,reason:r,source:a,presetId:s,customized:c,swatches:l,presets:u,saving:d,onApply:f}){let{t:p}=Z(),[m,h]=o(c===!0),[g,_]=o(s??u[0]?.id??`camstack`),[v,y]=o(l??u[0]?.swatches??{}),b=u.find(e=>e.id===g)??u[0],x=n(()=>b===void 0?null:we(v,b.fallbacks),[b,v]);if(t===`pending`)return i(`p`,{className:`text-xs text-foreground-subtle`,role:`status`,children:p(`pipeline.palette.pending`,`Reading the cluster palette…`)});let S=e=>{let t=u.find(t=>t.id===e);t!==void 0&&(h(!1),_(e),y(t.swatches),f({presetId:e}))},C=()=>{b!==void 0&&(h(!0),y(b.swatches))},w=(e,t)=>{if(typeof t!=`string`)return;let n=t.trim().toLowerCase();if(!as(n))return;let r=v[e],i=r?.form===`gradient`?{...r,hex:n}:{form:`solid`,hex:n};y({...v,[e]:i})};return e(`div`,{className:`flex flex-col gap-4`,children:[t===`unknown`&&i(`p`,{className:`text-xs text-warning`,role:`status`,"data-testid":`palette-unknown`,children:p(`pipeline.palette.unknown`,`The stored palette cannot be read ({{reason}}). Boxes use the bundled CamStack preset.`,{reason:r??``})}),t===`ready`&&a===`unconfigured`&&i(`p`,{className:`text-xs text-foreground-subtle`,children:p(`pipeline.palette.sourceUnconfigured`,`CamStack preset (cluster default)`)}),i(q,{headingId:`palette-presets`,title:p(`pipeline.palette.presets`,`Presets`),children:e(`div`,{className:`flex flex-wrap gap-2 p-3`,children:[u.map(t=>i(J,{type:`button`,size:`sm`,variant:!m&&t.id===g?`primary`:`outline`,onClick:()=>S(t.id),disabled:d,children:e(`span`,{className:`inline-flex items-center gap-1`,children:[[`person`,`vehicle`,`animal`].map(e=>{let n=$o(t.swatches[e]);return n===void 0?null:i(es,{hex:n},e)}),t.name]})},t.id)),i(J,{type:`button`,size:`sm`,variant:m?`primary`:`outline`,onClick:C,disabled:d||b===void 0,children:p(`pipeline.palette.custom`,`Custom`)})]})}),i(rs,{swatches:v}),x!==null&&x.ok&&i(`p`,{className:`text-xs text-success`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.valid`,`Every colour is distinct on both themes.`)}),x!==null&&!x.ok&&i(`p`,{className:`text-xs text-danger`,"data-testid":`palette-verdict`,children:p(`pipeline.palette.invalid`,`This palette is refused: {{reason}}`,{reason:ce(x.violations)})}),m&&b!==void 0&&i(q,{headingId:`palette-custom`,title:p(`pipeline.palette.custom`,`Custom`),children:e(`div`,{className:`flex flex-col gap-2 p-3`,children:[xe.map(e=>{let t=$o(v[e]);return t===void 0?null:i(_t,{field:{type:`color`,key:e,label:is(e)},values:{[e]:t},onChange:(t,n)=>w(e,n)},e)}),i(J,{type:`button`,size:`sm`,onClick:()=>{if(b===void 0||x===null||!x.ok)return;let e=os(b.swatches,v);f(Object.keys(e).length>0?{presetId:b.id,overrides:e}:{presetId:b.id})},disabled:d||x===null||!x.ok,children:p(`pipeline.palette.save`,`Save custom palette`)})]})})]})}function cs(){let e=Ye({}),t=nt({}),n=ct(),r=r=>{n.mutate(r,{onSuccess:()=>{e.refetch(),t.refetch()}})};if(e.isPending||t.isPending)return i(ss,{status:`pending`,presets:[],onApply:r});if(e.isError||e.data===void 0)return i(ss,{status:`unknown`,reason:e.isError?String(e.error):`no palette`,presets:t.data??[],saving:n.isPending,onApply:r});if(t.isError||t.data===void 0)return i(ss,{status:`unknown`,reason:String(t.error),presets:[],saving:n.isPending,onApply:r});if(e.data.status===`unknown`)return i(ss,{status:`unknown`,reason:e.data.reason,presets:t.data,saving:n.isPending,onApply:r});let a=e.data;return i(ss,{status:`ready`,source:a.source,presetId:a.presetId,customized:a.customized,swatches:a.swatches,presets:t.data,saving:n.isPending,onApply:r},`${a.presetId}:${String(a.customized)}`)}var ls=`pipeline-orchestrator`,us=200;function ds(){let{t}=Z();return e(`div`,{className:`flex flex-col gap-3`,children:[e(`div`,{children:[i(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.clusterOrchestratorLogsTab.dispatchDecisionsBalancerMovesAnd`,`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`)})]}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(Yt,{addonId:ls,limit:us,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}var fs=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`pipeline`,labelKey:`pipeline.clusterDetail.tabPipeline`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`},{id:`palette`,labelKey:`pipeline.clusterDetail.tabPalette`}];function ps(e){return fs.some(t=>t.id===e)}function ms({refreshToken:t}){let{t:n}=Z(),[r,a]=jn(),o=r.get(Oi),s=ps(o)?o:`assignments`,c=e=>{a(t=>{let n=new URLSearchParams(t);return n.set(Oi,e),n.delete(ki),n},{replace:!0})};return e(`div`,{className:`flex flex-col h-full`,children:[e(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[i(`h2`,{className:`text-base font-semibold text-foreground`,children:n(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),i(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:n(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles, settings and the display palette.`)})]}),i(un,{value:s,onValueChange:e=>{ps(e)&&c(e)},className:`px-4 sm:px-6`,children:i(Vt,{className:`border-border`,children:fs.map(e=>i(rn,{value:e.id,className:`h-auto py-2 border-b-2`,children:n(e.labelKey)},e.id))})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[s===`assignments`&&i(Da,{}),s===`pipeline`&&i(ka,{}),s===`load-balancing`&&i(Bo,{refreshToken:t,onOpenAutoTune:()=>c(`auto-tune`)}),s===`auto-tune`&&i(Ja,{}),s===`roles-nodes`&&i(Ko,{}),s===`settings`&&i(Qo,{refreshToken:t}),s===`logs`&&i(ds,{}),s===`palette`&&i(cs,{})]})]})}function hs({title:t,children:n}){return e(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[i(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:t}),i(`div`,{className:`flex flex-col gap-1 min-w-0`,children:n})]})}function $({label:t,children:n,overridden:r=!1}){return e(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[i(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:t,children:t}),i(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:n}),r&&i(gs,{})]})}function gs(){let{t:e}=Z();return i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),"aria-label":e(`cameras.cardPrimitives.deviceLevelOverrideActive`,`Device-level override active`),role:`img`})}var _s={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function vs({tone:e=`neutral`,children:t,title:n}){return i(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${_s[e]}`,children:t})}function ys({children:e}){return i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function bs({icon:t,label:n,nodeId:r,pinned:a,reason:o,overridden:s}){let{t:c}=Z();return e(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[i(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),i(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:n}),r===null?i(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):e(d,{children:[i(`span`,{className:`font-mono text-foreground truncate`,title:r,children:r}),a?e(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[i(M,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:o!==void 0&&o.length>0?o:c(`cameras.configBlocks.capacity`)})}),s&&i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:c(`cameras.configBlocks.persistedSettingsPinForThis`,`Persisted settings pin for this role`)})]})]})}function xs({assignment:t,settings:n,onlineNodes:r,pinPending:a,onDetectionPinChange:o}){let{t:s}=Z(),c=t.pinned.detection&&t.detectionNodeId!==null?t.detectionNodeId:`auto`,l=[...new Set([...t.detectionNodeId===null?[]:[t.detectionNodeId],...r.map(e=>e.id)])];return e(hs,{title:s(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[i(bs,{icon:R,label:s(`cameras.configBlocks.detection`,`Detection`),nodeId:t.detectionNodeId,pinned:t.pinned.detection,reason:t.reasons.detection,overridden:n.overriddenKeys.has(`pipelineNodeId`)}),i(bs,{icon:I,label:s(`cameras.configBlocks.decoder`,`Decoder`),nodeId:t.decoderNodeId,pinned:t.pinned.decoder,reason:t.reasons.decoder,overridden:n.overriddenKeys.has(`decoderNodeId`)}),i(bs,{icon:h,label:s(`cameras.configBlocks.audio`,`Audio`),nodeId:t.audioNodeId,pinned:t.pinned.audio,reason:t.reasons.audio,overridden:n.overriddenKeys.has(`audioNodeId`)}),i(bs,{icon:D,label:s(`cameras.configBlocks.source`,`Source`),nodeId:t.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),i(`div`,{className:`mt-1.5`,children:e(F,{value:c,disabled:a,"aria-label":s(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>o(e.target.value),className:`w-full min-w-0`,children:[i(`option`,{value:`auto`,children:s(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),l.map(e=>i(`option`,{value:e,children:s(`cameras.configBlocks.pinDetection`,{node:r.find(t=>t.id===e)?.name??e})},e))]})})]})}function Ss(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function Cs(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function ws(e){return e===null?X.t(`pipeline.configBlocks.fpsDefault`):e===0?X.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function Ts({streams:t,brokerProfiles:n,settings:r,motionEnabled:a,motionFpsLive:o,cameraSensors:s}){let{t:c}=Z(),l=Cs(n,r.detectionStreamProfile),u=Cs(n,r.motionStreamProfile),f=r.motionSources.includes(`analyzer`);return e(hs,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[e($,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:r.overriddenKeys.has(`detectionStreamProfile`),children:[r.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),i($,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:r.overriddenKeys.has(`detectionFps`),children:ws(r.detectionFps)}),e($,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:r.overriddenKeys.has(`motionSources`),children:[r.motionSources.length>0?r.motionSources.map(_e).join(` + `):c(`cameras.configBlocks.none`),a===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),i($,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:Vn(s)}),f&&e(d,{children:[e($,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:r.overriddenKeys.has(`motionStreamProfile`),children:[r.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),e($,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:r.overriddenKeys.has(`motionFps`),children:[ws(r.motionFps),o!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:o.toFixed(1)})}`]})]}),i($,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:r.overriddenKeys.has(`motionCooldownMs`),children:r.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${r.motionCooldownMs/1e3}s`}),i(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:t.length===0?i(ys,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):t.map(t=>e(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:t.camStreamId,children:[i(`span`,{className:`text-foreground-muted`,children:t.kind}),` `,Ss(t)]},t.camStreamId))})]})}function Es({steps:t,audioModelId:n,audioEnabled:r,audioMode:a}){let{t:o}=Z();return e(hs,{title:o(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[t===void 0?i(ys,{children:o(`cameras.configBlocks.resolving`,`Resolving…`)}):t.length===0?i(ys,{children:o(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:t.map((t,n)=>i(vs,{tone:t.enabled&&t.depth===0?`info`:`neutral`,title:t.modelId??t.addonId,children:e(`span`,{className:t.enabled?``:`line-through opacity-60`,children:[t.depth>0&&i(`span`,{className:`opacity-50`,children:`↳ `}),t.addonId,t.modelId!==null&&e(`span`,{className:`font-mono opacity-75`,children:[` · `,t.modelId]})]})},`${t.addonId}-${n}`))}),i(`div`,{className:`mt-1`,children:e($,{label:o(`cameras.configBlocks.audioClass`,`Audio class.`),children:[a??`—`,r!==null&&` · ${o(r?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,n!==null&&` · ${n}`]})})]})}var Ds={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function Os({detection:t,live:n,detectionMode:r,modeOverridden:a}){let o=B(),{t:s}=Z();if(t===null)return e(hs,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),i(ys,{children:s(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let c=n?.phase??t.phase,l=n?.actualFps??t.actualFps,u=n?.configuredFps??t.configuredFps,d=n?.avgInferenceTimeMs??t.avgInferenceMs,f=n?.queueDepth??t.queueDepth,p=St(c,o),m=c===`active`&&l===0;return e(hs,{title:s(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[e(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${p.badgeClass}`,children:[i(Gt,{phase:c,className:`h-2.5 w-2.5`}),p.label]}),n!==void 0&&i(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:s(`common.live`)})]}),i($,{label:s(`cameras.runtimeBlocks.mode`,`Mode`),overridden:a,children:r??`—`}),e($,{label:`FPS`,children:[i(`span`,{className:m?`text-danger font-semibold`:``,children:l.toFixed(1)}),i(`span`,{className:`ml-1 text-foreground-subtle`,children:s(`cameras.runtimeBlocks.configuredFps`,{fps:u.toFixed(0)})})]}),e($,{label:s(`cameras.runtimeBlocks.inference`,`Inference`),children:[d.toFixed(0),` ms`,f>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.queue`,{depth:f})}),n!==void 0&&n.droppedFrames>0&&i(`span`,{className:`ml-1 text-warning`,children:s(`cameras.runtimeBlocks.drops`,{count:n.droppedFrames})})]}),e($,{label:s(`cameras.runtimeBlocks.engine`,`Engine`),children:[t.engine.backend,` · `,t.engine.device]}),e($,{label:s(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[i(vs,{tone:Ds[t.provisioning.state]??`neutral`,children:t.provisioning.state}),t.provisioning.error!==void 0&&e(`span`,{className:`text-danger text-[10px]`,children:[` `,t.provisioning.error]})]})]})}function ks({broker:t}){let{t:n}=Z();return t===null?i(hs,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:i(ys,{children:n(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):e(hs,{title:n(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[t.profiles.length===0?i(ys,{children:n(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):i(`div`,{className:`flex flex-col gap-1`,children:t.profiles.map(t=>{let r=t.status===`streaming`,a=r&&t.inFps===0;return e(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${a?`bg-danger`:r?`bg-success animate-pulse`:`bg-border`}`,title:t.status}),i(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:t.profile,children:t.profile}),e(`span`,{className:`text-foreground-subtle truncate`,children:[t.width,`×`,t.height,` `,t.codec]}),i(`span`,{className:`ml-auto shrink-0 ${a?`text-danger`:`text-foreground`}`,children:n(`cameras.runtimeBlocks.fpsValue`,{value:t.inFps===null?`—`:t.inFps.toFixed(0)})}),e(`span`,{className:`text-foreground-subtle shrink-0`,title:n(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,t.subscribers]})]},t.profile)})}),e(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[i(vs,{tone:t.webrtcSessions>0?`info`:`neutral`,children:n(`cameras.runtimeBlocks.webrtc`,{count:t.webrtcSessions})}),i(vs,{tone:t.rtspRestream?`success`:`neutral`,children:t.rtspRestream?n(`cameras.runtimeBlocks.restreamOn`):n(`cameras.runtimeBlocks.restreamOff`)})]})]})}function As({decoder:e}){let{t}=Z();return e===null?i(hs,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i(ys,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):i(hs,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:i($,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}s();var js=`pipeline-orchestrator`,Ms={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Ns={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function Ps({problems:t}){return i(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:t.map(t=>e(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${t.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[i(k,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),i(`span`,{className:`min-w-0`,children:t.message})]},t.code))})}function Fs({deviceId:t,name:r,online:a,status:o,live:s,onlineNodes:c}){let{t:u}=Z(),d=l(),{data:f}=Wt({addonId:js,deviceId:t,nodeId:`hub`},{staleTime:3e4}),{data:p}=yn({deviceId:t},{staleTime:3e4}),m=n(()=>Zn(f),[f]),h=n(()=>p===void 0?void 0:Qn(p.steps),[p]),g=n(()=>o===void 0?[]:Fn(o),[o]),_=()=>{d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),d.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=nn({onSuccess:_}),y=En({onSuccess:_}),b=e=>{e===`auto`?y.mutate({deviceId:t}):v.mutate({deviceId:t,agentNodeId:e})},x=o===void 0?`idle`:Ln(o),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return e(`article`,{"aria-label":u(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:r}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[e(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[i(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:Ms[x]}`,title:S?u(`common.error`,`Error`):u(Ns[x]),"aria-label":S?u(`common.error`,`Error`):u(Ns[x]),role:`img`}),i(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:r,children:r}),e(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,t]}),!a&&i(vs,{tone:`danger`,children:u(`common.offline`)}),e(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&i(vs,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:u(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?u(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),o?.recording!=null&&(o.recording.active?e(vs,{tone:`danger`,title:u(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:o.recording.mode}),children:[i(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):o.recording.mode!==`off`&&i(vs,{tone:`neutral`,title:u(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:u(`pipeline.cameraPipelineCard.recMode`,{mode:o.recording.mode})}))]})]}),g.length>0&&i(Ps,{problems:g}),o===void 0?i(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:u(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[i(xs,{assignment:o.assignment,settings:m,onlineNodes:c,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),i(Os,{detection:o.detection,live:s,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),i(Es,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:o.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),i(Ts,{streams:o.source.streams,brokerProfiles:o.broker?.profiles,settings:m,motionEnabled:o.motion?.enabled??null,motionFpsLive:o.motion?.fps??null,cameraSensors:o.cameraSensors}),i(ks,{broker:o.broker}),i(As,{decoder:o.decoder})]})]})}s();var Is=5e3,Ls=1e4,Rs=5e3;function zs(e){let t=l(),{data:r,isLoading:i}=An(),{data:s,isLoading:c}=bt({},{refetchInterval:Is}),{nodes:u}=K();a(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=o(new Map);gn(Ee.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&f(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),a(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Ls,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},Rs);return()=>clearInterval(e)},[d.size]);let p=n(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:n(()=>(r??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:p.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[r,p]),liveMetrics:d,onlineNodes:n(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:i||c}}s();function Bs({refreshToken:t}){let{t:r}=Z(),{rows:a,liveMetrics:o,onlineNodes:s,isLoading:c}=zs(t),l=n(()=>[...a.map(e=>{let t=e.status===void 0?[]:Fn(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[a]),u=n(()=>{let e=0,t=0;for(let n of l)(n.errorCount>0||n.warningCount>0)&&(t+=1),(o.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:l.length,active:e,issues:t}},[l,o]);return c&&a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):a.length===0?i(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:r(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):i(`div`,{className:`h-full overflow-y-auto`,children:e(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[e(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[i(`span`,{children:i(Nn,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:u.total},components:{b:i(`span`,{className:`font-semibold text-foreground`})}})}),i(`span`,{children:i(Nn,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:u.active},components:{b:i(`span`,{className:`font-semibold text-success`})}})}),e(`span`,{children:[i(`span`,{className:`font-semibold ${u.issues>0?`text-danger`:`text-foreground`}`,children:u.issues}),` `,r(`cameras.camerasOverview.withIssues`,`with issues`)]}),i(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:r(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),l.map(({row:e})=>i(Fs,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:o.get(e.deviceId),onlineNodes:s},e.deviceId))]})})}s();var Vs=`__cluster__`;function Hs(e){return e===`cameras`?`cameras`:`nodes`}function Us({viewMode:t,onNodes:n,onCameras:r}){let{t:a}=Z();return e(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":a(`pipeline.pipelineView`,`Pipeline view`),children:[i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`nodes`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.nodes`,`Nodes`)}),i(`button`,{type:`button`,role:`tab`,"aria-selected":t===`cameras`,onClick:r,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,t===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:a(`pipeline.cameras`,`Cameras`)})]})}function Ws(){let{t}=Z(),[n,r]=jn(),s=Hs(n.get(`view`)),c=n.get(`node`)??`__cluster__`,[l,u]=o(0),[f,p]=o(!1);return a(()=>{s===`nodes`&&!n.get(`node`)&&r(e=>{let t=new URLSearchParams(e);return t.set(`view`,`nodes`),t.set(`node`,Vs),t},{replace:!0})},[s,n,r]),e(vn,{icon:ke,title:t(`pipeline.pipeline`,`Pipeline`),subtitle:t(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:e(J,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:t(`common.refresh`,`Refresh`),children:[i(O,{className:`h-3.5 w-3.5`}),t(`common.refresh`,`Refresh`)]}),nav:i(Us,{viewMode:s,onNodes:()=>{r({view:`nodes`,node:c},{replace:!0})},onCameras:()=>{r({view:`cameras`},{replace:!0})}}),className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[s===`nodes`&&e(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":f,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[i(`span`,{children:t(f?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),i(Oe,{className:[`h-4 w-4 transition-transform`,f?`rotate-180`:``].join(` `)})]}),i(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:s===`nodes`?e(d,{children:[i(`aside`,{className:[f?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b border-border md:border-b-0 md:border-r`,`max-h-[60vh] overflow-y-auto md:max-h-none`].join(` `),children:i(br,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?i(ms,{refreshToken:l}):i(Ea,{nodeId:c,refreshToken:l})})]}):i(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:i(Bs,{refreshToken:l})})})]})}export{Ws as PipelinePage};
@@ -1,2 +0,0 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$a as o,Cr as s,Nn as c,Pn as l,Tt as u,_i as d,ct as f,ft as p,so as m,tn as h,ut as g,zr as _}from"./player-overlays-CX_koJa1.js";import{sc as v}from"./client-CiiufhtZ.js";import{a as y,l as b}from"./terminal-DZ5OZpgC.js";import{$i as x,$s as ee,Br as S,Ea as C,Er as w,Gi as T,Ji as E,Ki as D,Op as O,Or as k,Q as A,Qi as te,Vr as j,Wi as M,Xi as N,Yi as P,Z as ne,_i as F,bp as I,ci as L,ht as R,im as z,ja as B,ka as V,kr as H,li as U,nt as re,oi as ie,rt as ae,sp as oe}from"./src-vFbZMtSO.js";import{t as W}from"./i18n-5KJwF-JB.js";import{t as G}from"./useTranslation-BJr-n0es.js";import{R as se,gi as ce,n as K}from"./index-BYgap-bt.js";import{n as le,r as q,t as J}from"./AccessSection-BDNf7fWa.js";a();var ue={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function Y(e){return W.t(ue[e])}var de={active:`success`,expired:`warning`,revoked:`default`,current:`info`},fe={current:0,active:1,expired:2,revoked:3};function X(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function Z({status:e}){return n(B,{variant:de[e],className:`text-[10px]`,children:Y(e)})}function pe({row:t,action:r}){if(!r.isAvailable(t))return null;let i=r.icon,a=r.busyId===t.id;return e(I,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.onRun(t),disabled:r.disabled,"aria-label":W.t(`access.credentialColumns.actionOn`,{action:r.label,name:t.name}),className:r.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(i,{className:`h-3 w-3`,"aria-hidden":!0}),r.label]})}function me(t){return[{key:`name`,header:W.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[n(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&n(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:W.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:W.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[n(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&n(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:W.t(`access.credentialColumns.status`,`Status`),sortValue:e=>fe[e.status],render:e=>n(Z,{status:e.status})},{key:`created`,header:W.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.createdAt,`—`)})},{key:`lastUsed`,header:W.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.lastUsedAt,W.t(`access.credentialColumns.never`))})},{key:`expires`,header:W.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:X(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:W.t(`access.credentialColumns.actionsHeader`),render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:n(pe,{row:e,action:t},t.label))})}].filter(e=>e!==null)}var he=6,ge={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function _e(e){let t=ge[e];return t===void 0?e:W.t(t)}function ve(e,t){return W.t(t.key,{count:e})}function Q(e,t){return W.t(`access.bulk.countOf`,{count:e,noun:ve(e,t)})}function ye(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>W.t(`access.bulk.statusCount`,{count:t,status:Y(e).toLowerCase()})).join(`, `)}function be(e,t){let n=e.slice(0,he).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>he?[W.t(`access.bulk.previewMore`,{count:e.length-he})]:[];return[W.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:ye(e)}),``,...n,...r].join(`
2
- `)}async function xe(e,t,n){let r=String(t.length),i=await e({title:W.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:be(t,n),label:W.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:W.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:W.t(`access.bulk.confirmMismatch`,{expected:r,noun:ve(2,n)})});return i!==null&&i.trim()===r}function Se(e,t){let n=g(),r=z.auth.revokeCredentials.useMutation(),[a,o]=i(null);return{run:async i=>{if(i.length===0||!await xe(n,i,e))return!1;o(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>_e(e.reason));return o({tone:`success`,message:n.length>0?W.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):W.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return o({tone:`danger`,message:W.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:W.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:a,dismiss:()=>o(null)}}function Ce(e,t,n){let r=g(),[a,o]=i(!1),[s,c]=i(null);return{run:async i=>{if(i.length===0||!await xe(r,i,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){a.push(`${e.name}: ${t instanceof Error?t.message:W.t(`access.bulk.requestFailed`)}`)}return o(!1),n(),a.length===0?(c({tone:`success`,message:W.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:W.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}a();var we={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Te={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Ee=e=>e.status!==`current`,De=[`active`,`current`];function Oe({rows:r,label:a,isLoading:o,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:d,extraActions:f,bulk:p,defaultStatus:m=De}){let{t:h}=G(),[g]=i(()=>m.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...m]}}),v=w(r,we,g),[y,b]=i(()=>new Set),x=u??h(`access.credentialColumns.never`),ee=t(()=>me({hideOwner:l,expiresNone:x,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,x,d,f,h]),C=t(()=>p===void 0?()=>!1:e=>Ee(e)&&p.isSelectable(e),[p]),T=t(()=>v.rows.filter(e=>y.has(e.id)&&C(e)),[v.rows,y,C]);return o?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[n(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),h(`access.credentialTable.loading`,{label:a})]}):s===null?e(`div`,{className:`space-y-3`,children:[n(k,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Te[e.id]===void 0?e.id:h(Te[e.id]),...e.id===`status`?{facetLabel:e=>Y(e)}:{}})),labels:{searchPlaceholder:h(`access.credentialTable.searchPlaceholder`,{label:a}),searchLabel:h(`access.credentialTable.searchLabel`,{label:a}),facetsLabel:h(`access.credentialTable.facetsLabel`,{label:a}),clearLabel:h(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),p!==void 0&&n(ke,{bulk:p,shown:v.rows.filter(C),targets:T,onSelect:b}),n(S,{columns:ee,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:j,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:h(`access.credentialTable.pagesLabel`,{label:a}),previous:h(`access.credentialTable.previousPage`),next:h(`access.credentialTable.nextPage`),range:(e,t,n)=>h(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?h(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:a}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...p===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:C,rowLabel:e=>h(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:h(`access.credentialTable.pageLabel`,{noun:ve(1,p.noun)})}}})]}):n(V,{title:h(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:a}),message:s})}function ke({bulk:t,shown:r,targets:i,onSelect:a}){let{t:o}=G(),{revoke:s,noun:c}=t,l=(t.quickSelect??[]).map(e=>({...e,rows:r.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(i)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[r.length>0&&n(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(r.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:r.length})}),l.map(t=>e(I,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),i.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(i.length,c)})}),e(I,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[n(u,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(I,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(h,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(i.length,c)})]})]})]})}var Ae=(e,t)=>t===null?`—`:e.get(t)??t;function je(e,t){return e!=null&&e<=t?`expired`:`active`}function Me(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:Ae(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ne(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var Pe=`All permissions`,Fe=`View link`,Ie=`Scoped`,Le={"grid-view":`Grid`,"events-view":`Events`};function Re(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function ze(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Be(e,t,n){return e===`*`?Pe:ze(e)?`${`${Le[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${Re(e.grant.deviceIds,t)}`:n(e)}function Ve(e){return e.includes(`*`)?Pe:e.some(ze)?Fe:Ie}function He(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:Ae(t,e.subjectId),kind:Ve(e.scopes),scope:n,status:e.revokedAt===null?je(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ue(e){return`${e.provider}\u0000${e.subject}`}function We(e,t){return{id:Ue(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:Ae(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var Ge=40,Ke=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],qe=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],Je=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function Ye(e,t){return e.find(e=>e.test.test(t))?.name??null}function Xe(e){return e.length<=Ge?e:`${e.slice(0,Ge)}…`}function Ze(e){if(e===null||e.trim().length===0)return{label:W.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=Ye(Je,t);if(n!==null)return{label:n,raw:t};let r=Ye(Ke,t),i=Ye(qe,t);return r!==null&&i!==null?{label:W.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:Xe(t),raw:t}:{label:r,raw:t}}var Qe={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,"cli-approval":`helpers.sessionClient.method.cliApproval`,exchange:`helpers.sessionClient.method.exchange`};function $e(e){let t=Qe[e];return t===void 0?e:W.t(t)}function et(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function tt({token:t,label:r,onClose:i}){let{t:a}=G();return n(M,{open:!0,onOpenChange:e=>!e&&i(),children:e(D,{width:`md`,scroll:`body`,children:[n(P,{children:n(N,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:r})})}),e(T,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),n(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(E,{children:[n(H,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),n(I,{type:`button`,variant:`primary`,size:`sm`,onClick:i,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var nt={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};a();var rt=80,$=86400,it=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],at=[v.Camera],ot=64,st={type:`capability`,target:``,access:[`view`,`create`]};function ct({open:a,users:s,onClose:u,onSubmit:f,submitting:h,formError:g,awaitingProof:v}){let{t:y}=G(),ee=m(),{user:S}=se(),w=S?.isAdmin===!0,T=w?null:S?.scopes??[],[E,D]=i(`scopes`),[k,j]=i(S?.id??``),[M,N]=i(``),[P,R]=i([st]),[z,B]=i([]),[V,H]=i(`grid-view`),[re,oe]=i(!1),[W,K]=i(`30`);r(()=>{a||(D(`scopes`),j(S?.id??``),N(``),R([st]),B([]),H(`grid-view`),oe(!1),K(`30`))},[a,S?.id]),r(()=>{E!==`view-link`&&W===`never`&&K(`30`)},[E,W]);let le=t(()=>it.filter(e=>e.seconds!==`never`||E===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?y(`access.createTokenModal.never`,`Never (until revoked)`):y(`access.createTokenModal.days`,{count:Number(e.value)})})),[E,y]),q=M.trim(),J=E===`scopes`?A(P,ee):null,ue=[...z],Y=it.find(e=>e.value===W)?.seconds??30*$,de=()=>E===`all`?[`*`]:E===`view-link`?[{type:`share-view`,grant:{kind:V,deviceIds:ue,...re?{talk:!0}:{}}}]:P,fe=q.length>0&&q.length<=rt&&!h&&!v&&(E===`all`?w:E===`view-link`?ue.length>0:P.length>0&&J===null),X=()=>{if(!fe)return;let e=w&&E!==`all`&&k!==``&&k!==S?.id;f({scopes:de(),expiresIn:Y,label:q,...e?{subjectId:k}:{}})},Z=E===`all`,pe=Z?l:c;return n(ae,{open:a,onClose:u,title:y(`access.createTokenModal.createToken`,`Create token`),icon:Z?l:b,error:g,width:`md`,testId:`create-token-dialog`,footer:e(I,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:X,disabled:!fe,"data-testid":`create-token-submit`,children:[h||v?n(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):n(pe,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),y(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[n(F,{children:y(`access.createTokenModal.whatItMayDo`,`What it may do`)}),n(ie,{appearance:`pills`,value:E,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&D(e)},children:e(L,{"aria-label":y(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(U,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[n(c,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(U,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[n(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachViewLink`,`View link`)]}),w?e(U,{value:`all`,"data-testid":`token-reach-all`,children:[n(l,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),y(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?n(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:n(`p`,{children:n(ce,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:n(`strong`,{})}})})}):null,w&&E!==`all`&&s.length>1?e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-user`,children:y(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),n(p,{id:`token-user`,value:k,onChange:e=>j(e.target.value),options:s.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-name`,children:y(`access.createTokenModal.label`,`Label`)}),n(O,{id:`token-name`,value:M,maxLength:rt,required:!0,onChange:e=>N(e.target.value),placeholder:E===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),E===`scopes`?e(`div`,{className:`space-y-1`,children:[n(F,{children:y(`access.createTokenModal.scopes`,`Scopes`)}),n(ne,{value:P,onChange:R,clampToParent:T}),J&&n(`p`,{className:`text-[10px] text-danger`,children:J}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:y(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,E===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-view-cameras`,children:y(`access.createTokenModal.cameras`,`Cameras`)}),n(C,{id:`token-view-cameras`,multiple:!0,pick:`device`,noun:`camera`,fixedTypes:at,maxItems:ot,recentKey:`token-view-cameras`,testId:`token-view-cameras`,value:x(z),onChange:e=>B(te(e))})]}),e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-view-kind`,children:y(`access.createTokenModal.viewKind`,`Shows`)}),n(p,{id:`token-view-kind`,value:V,onChange:e=>H(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:y(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:y(`access.createTokenModal.viewEvents`,`Events`)}]})]}),V===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[n(o,{className:`mt-0.5`,checked:re,onChange:e=>oe(e.target.checked),"data-testid":`token-view-talk`}),n(`span`,{children:y(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[n(F,{htmlFor:`token-lifetime`,children:y(`access.createTokenModal.expires`,`Expires after`)}),n(p,{id:`token-lifetime`,value:W,onChange:e=>K(e.target.value),options:le})]})]})})}a();var lt={key:`access.nouns.token`};function ut(e){return typeof e==`object`&&!!e&&`kind`in e}function dt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${ut(e.selector)?R(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function ft({headerOwnsCreate:a=!1,createRequested:o=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:l}=G(),u=m(),{user:d}=se(),p=f(),g=z.useUtils(),_=q(),{data:v}=oe(),y=t(()=>v??[],[v]),{data:x}=ee({}),S=t(()=>{let e=new Map;for(let t of x??[])e.set(t.id,t.name);return e},[x]),C=z.auth.listTokens.useQuery(void 0),{requestProof:w,dialog:T}=K(`Creating a token with all permissions`),{state:E,openNew:D,close:O}=re({newKey:nt.token}),[k,A]=i(null),[te,j]=i(null),[M,N]=i(!1),[P,ne]=i(null),[F,L]=i(null);r(()=>{o&&(D(),s?.())},[o,D,s]);let R=()=>{g.auth.listTokens.invalidate(),g.auth.listAuthAudit.invalidate()},B=z.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{R(),O(),j(null),N(!1),ne({token:e,label:t.label})},onError:e=>{j(`Create failed: ${e.message}`),N(!1)}}),V=z.auth.revokeToken.useMutation({onSuccess:()=>{L(null),R()},onError:e=>{L(null),A(`Revoke failed: ${e.message}`)}}),H=Se(lt,R),U=Date.now(),ie=(C.data??[]).filter(e=>!c||e.subjectId===d?.id).map(e=>He(e,_,e.scopes.includes(`*`)?null:e.scopes.map(e=>Be(e,S,e=>dt(e,u))).join(`, `),U)),ae=async e=>{await p({title:l(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?l(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):l(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:l(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(A(null),L(e.id),V.mutate({id:e.id}))},W=e=>{(async()=>{A(null),j(null);let t;if(e.scopes.includes(`*`)){N(!0);let e=await w();if(N(!1),e===null)return;t=e}B.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[T,n(J,{notice:le(k,H.outcome),onDismissNotice:()=>{A(null),H.dismiss()},id:c?`my-tokens`:`tokens`,title:c?l(`access.tokensSection.myTokens`,`My tokens`):l(`access.tokensSection.tokens`,`Tokens`),icon:b,actions:a?void 0:e(I,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:D,children:[n(b,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),l(`system.access.newToken`,`New token`)]}),description:l(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:n(Oe,{rows:ie,label:l(`common.tokensLabel`),isLoading:C.isLoading,loadError:C.isError?C.error?.message??`Request failed`:null,emptyText:l(`access.tokensSection.noTokens`,`No tokens.`),action:{label:l(`access.tokensSection.revoke2`,`Revoke`),icon:h,isAvailable:e=>e.status===`active`,onRun:e=>void ae(e),busyId:F,disabled:H.busy||F!==null},...d?.isAdmin===!0?{bulk:{revoke:H,noun:lt,isSelectable:e=>e.status===`active`}}:{}})}),n(ct,{open:E.mode===`new`,users:y.map(e=>({id:e.id,username:e.username})),onClose:()=>{O(),j(null),N(!1)},submitting:B.isPending,formError:te,awaitingProof:M,onSubmit:W}),P&&n(tt,{token:P.token,label:P.label,onClose:()=>ne(null)})]})}var pt=864e5,mt={qr:`QR (by an admin)`,self:`Self-enrolled`},ht={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function gt(e){return e.status===`revoked`}function _t(e){return e.status!==`revoked`}function vt(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function yt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/pt)}function bt(e,t){let n=yt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function xt(e,t){let n=yt(e,t);return n===null?W.t(`helpers.certificateModel.unknown`):n===0?W.t(`helpers.certificateModel.today`):n>0?W.t(`helpers.certificateModel.inDays`,{count:n}):W.t(`helpers.certificateModel.daysAgo`,{count:-n})}function St(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Ct(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function wt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Tt(e){if(!e.online)return{allowed:!1,reason:W.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:W.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:W.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var Et={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Dt(e){if(e.ok)return{tone:`success`,message:W.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:wt(e.newSerial)})};let t=e.keptPreviousLeaf?W.t(`helpers.certificateModel.keptPrevious`):W.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:W.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:W.t(Et[e.stage]),reason:e.reason,kept:t})}}function Ot(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var kt=11;function At(e,t){let n=e.slice(0,kt);return t===null?n:`${n} · ${t}`}function jt(e){return{id:e.id,name:e.deviceName,detail:At(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:ht[e.platform],scope:mt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Mt(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:ht[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Nt({sessions:t,isLoading:r,loadError:i,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=G();return r?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(_,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):i===null?t.length===0?n(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):n(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(Pt,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,i]})}function Pt({session:t,revoking:r,onRevoke:i}){let{t:a}=G(),o=Ze(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[n(s,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&n(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:$e(t.method)}),n(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),n(`span`,{children:a(`auth.sessionsList.lastActive`,{when:et(t.lastUsedAt)})}),n(`span`,{children:a(`auth.sessionsList.expires`,{when:et(t.expiresAt)})})]})]}),!t.current&&e(I,{variant:`unstyled`,onClick:i,disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r?n(_,{className:`h-3 w-3 animate-spin`}):n(y,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{Me as C,Ce as E,Ne as S,Se as T,Ze as _,_t as a,Ue as b,xt as c,vt as d,Tt as f,nt as g,ft as h,gt as i,Dt as l,wt as m,jt as n,Ot as o,Ct as p,Mt as r,St as s,Nt as t,bt as u,$e as v,Oe as w,We as x,et as y};
@@ -1 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Tt as c,ct as l,ti as u,tr as d,vi as f,zr as p}from"./player-overlays-CX_koJa1.js";import{Vc as m}from"./client-CiiufhtZ.js";import{t as h}from"./chevron-down-CBb-F8DT.js";import{_ as g}from"./terminal-DZ5OZpgC.js";import{t as _}from"./eraser-B3lnG9yK.js";import{t as v}from"./hard-drive-download-C6N6tovA.js";import{Ud as y,_f as b,ao as x,bp as S,ja as C,sl as w,vf as T,yf as ee}from"./src-vFbZMtSO.js";import{t as E}from"./i18n-5KJwF-JB.js";import{t as D}from"./useTranslation-BJr-n0es.js";import{It as O,xt as k}from"./index-BYgap-bt.js";import{t as A}from"./format-size-DIxKXxtj.js";import{t as te}from"./InstancesTable-DqOZKOiw.js";o();var j=[`ok`,`warn`,`critical`];function ne(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function M(e){return Math.min(1,Math.max(0,e))}function N(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=M((n-t)/n);return{fraction:r,severity:ne(r),recordingsFraction:M(e.usedBytes/n),freeBytes:t,totalBytes:n}}function re(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=N(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||j.indexOf(e.severity)>j.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function ie(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function ae(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function P({drain:t}){let{t:n}=D();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:ie(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:ae(t.estimatedEmptyAtMs)})]})]})}function F(e){return Math.min(1,Math.max(0,e))}function I(e){return Math.round(F(e)*1e3)/10}function L(e){return`${String(Math.round(F(e)*100))}%`}function oe(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:A(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?E.t(`helpers.locationCapacityBar.unknownSummary`):E.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=N({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?F(o/r):m.fraction,g=m===null?ne(h):m.severity,_=f===null?null:m===null?F(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:F((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:A(r),freeTotal:A(a),freeTotalPercent:L(a/r),used:A(p),usedPercent:L(p/r),free:A(u),freePercent:L(u/r),reserve:s===0?null:E.t(`helpers.locationCapacityBar.reserveKept`,{size:A(s)}),owned:f===null||_===null?null:E.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:A(f),percent:L(_)}),cap:v===null?null:v.reason===`drain`?E.t(`helpers.locationCapacityBar.capDrain`,{size:A(v.bytes)}):E.t(`helpers.locationCapacityBar.capCap`,{size:A(v.bytes)})},S=[E.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:E.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?E.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?E.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:E.t(`helpers.locationCapacityBar.legendKeptFree`),value:A(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:E.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?E.t(`helpers.locationCapacityBar.legendUsed`):E.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:E.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?E.t(`helpers.locationCapacityBar.legendDrainTarget`):E.t(`helpers.locationCapacityBar.legendCap`),value:E.t(`helpers.locationCapacityBar.legendCapValue`,{size:A(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:I(c/r),ownedPercent:f===null?null:I(f/r),usedPercent:I(p/r),freePercent:I(u/r),capPercent:y===null?null:I(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}function R(e){return m(e)}function z(e){return e===`active`}var B=[{mode:`active`,get label(){return E.t(`helpers.locationMode.activeLabel`)},get consequence(){return E.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return E.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return E.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return E.t(`helpers.locationMode.drainLabel`)},get consequence(){return E.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return E.t(`helpers.locationMode.disabledLabel`)},get consequence(){return E.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function V(e){return B.find(t=>t.mode===e)??B[0]}function se(e){return V(e).requiresConfirmation}var ce=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function H(e,t,n){return z(n)||!z(R(e))||t.some(t=>t.id!==e.id&&z(R(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:ce}}function le(e,t){return{active:H(e,t,`active`).reason,readonly:H(e,t,`readonly`).reason,drain:H(e,t,`drain`).reason,disabled:H(e,t,`disabled`).reason}}var ue=1024**3;function U(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function de(e){let t=U(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=U(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function fe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ue;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function pe(e,t){let n=U(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ue,reason:t===`drain`?`drain`:`legacy`}}var W={ok:`bg-primary`,warn:`bg-warning`,critical:`bg-danger`},G={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function me(e,t){return e===`used`?W[t]:G[e]}function K({location:t,ownedBytes:n}){let{t:i}=D(),a=t.capacity??null,o=fe(de(t.config),a?.totalBytes??null),s=oe({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:pe(t.config,R(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:G.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:G.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:W[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:G.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:G.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${me(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var he={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},ge={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},_e=`storage.discardLocation`,q=`storage.discardLocationStatus`,ve=`storage.discardLocationCancel`;function ye(e){return he[e]??null}function be(e){return ge[e]??null}function xe(e){return!z(R(e))}function Se(e,t){return ye(e.type)===null||!xe(e)?!1:t.some(t=>t.id!==e.id&&z(R(t)))}var Ce=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function J(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Y(e){return typeof e==`string`?e:null}function X(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!Ce.has(n))return null;let r=J(t.camerasTotal),i=J(t.camerasDone),a=J(t.foldersRemoved),o=J(t.dbRowsDeleted),s=J(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:Y(t.locationId),jobId:Y(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:Y(t.detail)??``,startedAtMs:J(t.startedAtMs),finishedAtMs:J(t.finishedAtMs),error:Y(t.error)}}function we(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}var Te=2e3;function Ee({location:e,siblings:t}){return Se(e,t)?r(De,{location:e}):null}function De({location:t}){let{t:n}=D(),o=l(),s=x(),u=be(t.type),[d,f]=a(null),[m,h]=a(null),[g,v]=a(!1);if(i(()=>{if(u===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:u,action:q,input:{}});if(e)return;f(X(t))}catch{}};t();let n=setInterval(()=>void t(),Te);return()=>{e=!0,clearInterval(n)}},[u,t.id]),u===null)return null;let y=d!==null&&d.locationId===t.id,b=y&&d.running,C=y&&d.phase!==`idle`,w=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){h(null),v(!0);try{await s.mutateAsync({addonId:u,action:_e,input:{locationId:t.id}}),f(X(await s.mutateAsync({addonId:u,action:q,input:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{v(!1)}}},T=async()=>{try{await s.mutateAsync({addonId:u,action:ve,input:{}})}catch(e){h(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[b?e(S,{variant:`unstyled`,type:`button`,onClick:()=>void T(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[r(c,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(S,{variant:`unstyled`,type:`button`,onClick:()=>void w(),disabled:g,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[g?r(p,{className:`h-3 w-3 animate-spin`}):r(_,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),C&&d!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${we(d)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[d.phase,d.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:d.camerasDone,total:d.camerasTotal})}`:``,d.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:d.dbRowsDeleted})}`:``,d.detail?` · ${d.detail}`:``]})]}),(m||y&&d?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:m??d?.error})]})}o();var Z={active:d,readonly:g,drain:v,disabled:f},Oe={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function ke({mode:t,open:n,onToggle:i}){let{t:a}=D(),o=V(t),s=Z[t];return e(S,{variant:`unstyled`,type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${Oe[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(h,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function Ae({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=D();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(S,{variant:`unstyled`,type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(c,{className:`h-3 w-3`})})]}),B.map(i=>{let c=n[i.mode],l=c!==``,u=Z[i.mode],d=i.mode===t;return e(S,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}function je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Me(e){if(!je(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=Q(e.startedAtMs),r=Q(e.startBytes),i=Q(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:Q(e.estimatedEmptyAtMs)}}function Ne(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Me(n);e!==null&&t.set(e.locationId,e)}return t}function Pe(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Fe(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Pe(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ie(e){return m(e)===`drain`}var Le=[`recordings`,`recordingsLow`];function Re(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ze(e,t){if(t===void 0||!Le.includes(e.type))return null;let n=t.find(t=>Re(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function Be(e,t){let n=new Map;for(let r of e){let e=ze(r,t);e!==null&&n.set(r.id,e)}return n}o();var Ve=[];function $(){let e=ee({}),n=y({},{refetchOnWindowFocus:!1}),r=b({},{refetchOnWindowFocus:!1}),i=e.data??Ve,a=t(()=>Be(i,n.data?.locations),[i,n.data?.locations]),o=t(()=>Ne(r.data),[r.data]);return t(()=>({locations:i,ownedBytesById:a,drainOf:e=>Fe(Ie(e),o.get(e.id))}),[i,a,o])}o();function He({row:t}){let{t:n}=D(),i=l(),o=s(),c=$(),[u,d]=a(!1),f=w({onSuccess:()=>{o.invalidateQueries({queryKey:[k]}),o.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),d(!1)},onError:e=>O({title:n(`system.storage.modeFailed`,`Could not change the state`),message:`${t.name}: ${e.message}`,severity:`critical`})}),p=c.locations.find(e=>e.id===t.id);if(p===void 0)return null;let m=c.locations.filter(e=>e.type===p.type),h=R(p),g=c.drainOf(p),_=async e=>{se(e)&&!await i({title:n(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:p.displayName}),message:n(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:V(e).consequence}),confirmLabel:n(`common.disable`,`Disable`),variant:`danger`})||f.mutate({addonId:t.addonId,id:t.id,values:{mode:e}})};return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`min-w-0 flex-1 basis-60`,children:[r(K,{location:p,ownedBytes:c.ownedBytesById.get(p.id)??null}),g.kind!==`idle`&&r(P,{drain:g})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[r(Ee,{location:p,siblings:m}),r(ke,{mode:h,open:u,onToggle:()=>d(e=>!e)})]}),u&&r(Ae,{mode:h,blockedReasons:le(p,m),onSelect:e=>void _(e),onDismiss:()=>d(!1)})]})}function Ue({row:t}){let n=$();if(t.kind!==`instance`)return null;let i=n.locations.find(e=>e.id===t.id);if(i===void 0)return null;let a=n.drainOf(i);return e(`div`,{className:`min-w-48`,children:[r(K,{location:i,ownedBytes:n.ownedBytesById.get(i.id)??null}),a.kind!==`idle`&&r(P,{drain:a})]})}function We({row:e}){let t=$();if(e.kind!==`instance`)return null;let n=t.locations.find(t=>t.id===e.id);if(n===void 0)return null;let i=R(n);return r(C,{variant:i===`active`?`success`:i===`disabled`?`danger`:`default`,children:V(i).label})}function Ge(e){return[{key:`capacity`,header:e.capacity,notSortableReason:e.capacity,render:e=>r(Ue,{row:e})},{key:`mode`,header:e.mode,nowrap:!0,notSortableReason:e.mode,render:e=>r(We,{row:e})}]}function Ke(e,t,n){return!(n===`single`||t.length<=1||z(R(e))&&t.filter(e=>z(R(e))).length<=1)}function qe(e){let t=e instanceof Error?e.message:String(e);return/still holds data — drain it first/.test(t)?`holds-data`:/could not be checked for remaining data/.test(t)?`unverifiable`:null}o();var Je=`forceDeleteLocation`;function Ye(){let{t:e}=D(),t=l(),r=s(),i=x();return n(async(n,a)=>{let o=qe(a);if(o===null)return!1;let s=o===`holds-data`?e(`system.storage.deleteBlockedHoldsData`,`This location still holds data. Drain it first (storage migration or relocate), or force the delete.`):e(`system.storage.deleteBlockedUnverifiable`,`What is stored on this location could not be checked (unreachable provider, another node or an unmounted root). Force the delete only if you are sure it is empty or no longer needed.`);if(!await t({title:e(`system.storage.deleteBlockedTitle`,`Cannot delete {{name}}`,{name:n.name}),message:s,confirmLabel:e(`system.storage.forceDelete`,`Force delete`),variant:`danger`})||!await t({title:e(`system.storage.forceDeleteTitle`,`Force delete "{{name}}"?`,{name:n.name}),message:e(`system.storage.forceDeleteStrands`,`Recordings and media stored on this location will be stranded: the record is deleted, the files stay on disk, and playback of the segments on it stops working.`),confirmLabel:e(`system.storage.forceDeleteConfirm`,`Delete and strand data`),variant:`danger`}))return!0;try{await i.mutateAsync({addonId:n.addonId,action:Je,input:{id:n.id}}),await r.invalidateQueries({queryKey:[k]}),await r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}catch(t){O({title:e(`providerInstances.deleteFailed`,`Could not delete`),message:`${n.name}: ${t instanceof Error?t.message:String(t)}`,severity:`critical`})}return!0},[t,i,r,e])}o();var Xe=`storage`;function Ze({kinds:e}){let{t:n}=D(),{locations:i}=$(),a=T({}).data,o=Ye(),s=e=>{let t=i.find(t=>t.id===e.id),n=a?.find(e=>e.id===t?.type);return t===void 0||n===void 0?!1:Ke(t,i.filter(e=>e.type===t.type),n.cardinality)},c=t(()=>Ge({capacity:n(`system.storage.colCapacity`,`Capacity`),mode:n(`system.storage.colMode`,`State`)}),[n]),l=t(()=>e===void 0?void 0:t=>t.kind===`instance`&&t.kindId!==void 0&&e.includes(t.kindId),[e]);return r(te,{functionCap:Xe,icon:u,title:n(`system.storage.title`,`Storage locations`),subtitle:n(`system.storage.subtitle`,`Where recordings, event media, artifacts and backups are kept. Each location is one kind on one provider; the state decides whether it takes writes, is only read, drains or is left alone.`),emptyTitle:n(`system.storage.emptyTitle`,`No storage locations yet`),emptyDescription:n(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`),addLabel:n(`system.storage.addLocation`,`Add location`),extraColumns:c,lead:e=>r(He,{row:e}),canDelete:s,onDeleteRefused:o,...l===void 0?{}:{rowFilter:l}})}export{R as a,V as i,$ as n,P as o,K as r,re as s,Ze as t};