@camstack/addon-admin-ui 1.2.455 → 1.2.457
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddonAssetIcon-BYNabO6z.js → AddonAssetIcon-BOcwQMt3.js} +1 -1
- package/dist/assets/Addons-BrsHM2rE.js +4 -0
- package/dist/assets/{AdminPage-RJcN6Anu.js → AdminPage-0E8EpSO9.js} +1 -1
- package/dist/assets/{AdminSectionedPage-DvK84QvU.js → AdminSectionedPage-CxodN1sn.js} +1 -1
- package/dist/assets/AiProfiles-EJziTK6H.js +3 -0
- package/dist/assets/{BrokerForm-Bua9uB8w.js → BrokerForm-Dbs6DDhN.js} +1 -1
- package/dist/assets/Build-G3WNIoIu.js +40 -0
- package/dist/assets/{Calendars-ClbErr_S.js → Calendars-DwIn1aCE.js} +1 -1
- package/dist/assets/{Cluster-DmQM6H_p.js → Cluster-FzZaIb80.js} +1 -1
- package/dist/assets/ClusterStepModel-BKwbYUSr.js +1 -0
- package/dist/assets/CompositionEditor-Du0918m6.js +1 -0
- package/dist/assets/{CompositionEditorPage-Bicamzo6.js → CompositionEditorPage-I6-ghm-F.js} +1 -1
- package/dist/assets/Data-CWXYjuUH.js +2 -0
- package/dist/assets/{DeviceDetail-4Vysat6s.js → DeviceDetail-DEN9C3es.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-lfq-_s87.js → DeviceDoActionFields-XK5u9sG-.js} +1 -1
- package/dist/assets/{Devices-BCTvzI3Z.js → Devices-CPoElWdX.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BzklJ0a5.js → EmbedPlayerPage-CwqeH_Vp.js} +1 -1
- package/dist/assets/History-146ywVRO.js +1 -0
- package/dist/assets/Identity-NsWnwCVn.js +1 -0
- package/dist/assets/IntegrationDetail-CUffTwqo.js +1 -0
- package/dist/assets/{IntegrationHub-DHgjRUIy.js → IntegrationHub-DAndpOVJ.js} +1 -1
- package/dist/assets/{Integrations-CQ3JYsSK.js → Integrations-DaNoA1oi.js} +1 -1
- package/dist/assets/Integrations-DrSNiPXr.js +1 -0
- package/dist/assets/Library-BMJeDfUP.js +1 -0
- package/dist/assets/Locations-DpWQPPRR.js +3 -0
- package/dist/assets/{Logs-QE5m7m6F.js → Logs-ClfIrCg_.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-C7r7jgVz.js → MaskShapeCanvas-BACSOVPv.js} +1 -1
- package/dist/assets/{MotionZonesSettings-qCWVDb2U.js → MotionZonesSettings-C-BWiqKl.js} +1 -1
- package/dist/assets/MyAccess-B2mddc8z.js +2 -0
- package/dist/assets/{Network-CJOuBFOQ.js → Network-CCpscaUS.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CTmPFs3s.js → NodeAddonsSettingsPanel-J8GvbAOS.js} +1 -1
- package/dist/assets/Notifications-CJvDmENV.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-CBAaR7ZM.js → PrivacyMaskSettings-_hgbaRHe.js} +1 -1
- package/dist/assets/Recordings-CmuOayrH.js +1 -0
- package/dist/assets/{ScanNetworkModal-CiOVqs0H.js → ScanNetworkModal-CHpDtEMN.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BbPp4N2N.js → SceneMonitorEditor-DNX5LjxD.js} +1 -1
- package/dist/assets/SessionsList-CO2JCtUA.js +2 -0
- package/dist/assets/{Showroom-or-UvZ6_.js → Showroom-C1Cx5rmM.js} +1 -1
- package/dist/assets/{System-DSx33GfC.js → System-8QdXWXlv.js} +1 -1
- package/dist/assets/{Terminal-B3oKTozT.js → Terminal-D-QqW5OC.js} +5 -5
- package/dist/assets/{Viewer-CpC1lsu6.js → Viewer-DEkhIs_o.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-cERw53qT.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DXRH_g5-.js} +1 -1
- package/dist/assets/{addon-icons-context-BVO6QLZm.js → addon-icons-context-r4-8qNuL.js} +1 -1
- package/dist/assets/{archive-jvBvOOAa.js → archive-CHNksUXE.js} +1 -1
- package/dist/assets/{authed-media-DubLoRPM.js → authed-media-CLfNNAcR.js} +1 -1
- package/dist/assets/{bell-off-h_oVtaH_.js → bell-off-BQUuLgGa.js} +1 -1
- package/dist/assets/{board-model-lfov_Io5.js → board-model-CCKjMnih.js} +1 -1
- package/dist/assets/{boxes-CqZzX6pS.js → boxes-OM3WXXCF.js} +1 -1
- package/dist/assets/circle-slash-B-qX3Tzf.js +1 -0
- package/dist/assets/client-Tf7DwHzR.js +358 -0
- package/dist/assets/{cloud-upload-_iPugQ2o.js → cloud-upload-DnQzN7Zu.js} +1 -1
- package/dist/assets/crop-BXCCBrRT.js +1 -0
- package/dist/assets/{device-integration-icon-CFPzExgG.js → device-integration-icon-T6DuiFIe.js} +1 -1
- package/dist/assets/device-picker-model-CJDjbyFR.js +1 -0
- package/dist/assets/dist-COc-M7x5.js +358 -0
- package/dist/assets/{dist-BYCY5p_8.js → dist-DWpE4F9Y.js} +1 -1
- package/dist/assets/{eraser-RaYHha2L.js → eraser-2zvTICay.js} +1 -1
- package/dist/assets/{hard-drive-download-DobqoKaY.js → hard-drive-download-BuPae4i9.js} +1 -1
- package/dist/assets/{hostInit-Bk_2heUx.js → hostInit-B0H8YgMs.js} +1 -1
- package/dist/assets/i18n-dPXh_JKN.js +1 -0
- package/dist/assets/{icons-DzYBV1xx.js → icons-Bf1g4TTU.js} +1 -1
- package/dist/assets/index-BGRimCPP.css +2 -0
- package/dist/assets/index-k7RW-84l.js +4 -0
- package/dist/assets/{key-round-CNTVmlFS.js → key-round-PVl1EIeU.js} +1 -1
- package/dist/assets/{key-Dtkr3Nze.js → key-y1dQIrgn.js} +1 -1
- package/dist/assets/{layers-DGhugmpj.js → layers-BvTBL45e.js} +1 -1
- package/dist/assets/{linked-devices-model-BpGYuse3.js → linked-devices-model-NEAloVak.js} +1 -1
- package/dist/assets/{list-ordered-DR6Fc-kF.js → list-ordered-Cy6LNkX7.js} +1 -1
- package/dist/assets/{location-owned-usage-CScwnhi4.js → location-owned-usage-COJFqP2Z.js} +1 -1
- package/dist/assets/{log-in-B8yxXP-a.js → log-in-C8bG6uHT.js} +1 -1
- package/dist/assets/{memory-stick-DEd977DV.js → memory-stick-DgCbrom_.js} +1 -1
- package/dist/assets/{message-square-plus-czVBdg8z.js → message-square-plus-T2Q-JaNP.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ffeb770c.js → mf-entry-bootstrap-0-fa03047b.js} +2 -2
- package/dist/assets/{mic-off-CuWOtzwH.js → mic-off-CQXTB132.js} +1 -1
- package/dist/assets/{monitor-off-D1_Vx25v.js → monitor-off-CvP-Xwqs.js} +1 -1
- package/dist/assets/{monitor-smartphone-EKfsOXbl.js → monitor-smartphone-DgPyh0bq.js} +1 -1
- package/dist/assets/mount-CJDjbyFR.js +1 -0
- package/dist/assets/notification-schedule-field-DXLce27m.js +1 -0
- package/dist/assets/{player-overlays-D98Lvll4.js → player-overlays-DTcu3p6k.js} +1 -1
- package/dist/assets/{recycle-BDYRIJo4.js → recycle-BgfATMDb.js} +1 -1
- package/dist/assets/remoteEntry-T1NwEQgU.js +1 -0
- package/dist/assets/{scan-eye-BF9NJNXB.js → scan-eye-Cw7uLDDg.js} +1 -1
- package/dist/assets/{scissors-BNz1ybHC.js → scissors-GZwoMkJz.js} +1 -1
- package/dist/assets/{search-x-DOr7Uth6.js → search-x-mGDaYxQw.js} +1 -1
- package/dist/assets/{send-BfMMesXE.js → send-B4zTG8IX.js} +1 -1
- package/dist/assets/{settings-2-CpTdKS6A.js → settings-2-7MkaO5_9.js} +1 -1
- package/dist/assets/{speaker-DiDPOBlm.js → speaker-iZgcW4qe.js} +1 -1
- package/dist/assets/src-CxF5mieK.js +67 -0
- package/dist/assets/{timer-reset-Dw4WCNKZ.js → timer-reset-CZOKA6Qu.js} +1 -1
- package/dist/assets/{ungroup-CLr3vekJ.js → ungroup-CmTgkman.js} +1 -1
- package/dist/assets/{unlink-pUA2UXXM.js → unlink-DgTv7GBL.js} +1 -1
- package/dist/assets/{usb-wx8HtogA.js → usb-CDpFB3qV.js} +1 -1
- package/dist/assets/{use-scenes-feed-DF4B8gD1.js → use-scenes-feed-Xf26vjq3.js} +1 -1
- package/dist/assets/{use-stationary-objects-CPcayJEy.js → use-stationary-objects-piZ9a4go.js} +1 -1
- package/dist/assets/useEventInvalidation-CJDjbyFR.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Dm8ObY95.js → useNodeUrlSelection-Bmr7pzZ8.js} +1 -1
- package/dist/assets/user-round-XpdQk1Uf.js +1 -0
- package/dist/assets/{user-x-CzTAjxJ0.js → user-x-DG-dacDQ.js} +1 -1
- package/dist/assets/{video-a3E1zR0a.js → video-DSWn6X4v.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C-d2SXqo.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-9bgJ3bqj.js} +2 -2
- package/dist/index.html +30 -11
- package/dist/server/addon.js +6817 -1413
- package/package.json +1 -1
- package/dist/assets/Addons-B7UpJkGs.js +0 -4
- package/dist/assets/AiProfiles-WyUbwQQi.js +0 -3
- package/dist/assets/Build-w6vEia_c.js +0 -40
- package/dist/assets/ClusterStepModel-hpdBn30Y.js +0 -1
- package/dist/assets/CompositionEditor-CpN510VP.js +0 -1
- package/dist/assets/Data-DoXqW90G.js +0 -2
- package/dist/assets/History-BYogPAEo.js +0 -1
- package/dist/assets/Identity-DtlH2M6Y.js +0 -1
- package/dist/assets/IntegrationDetail-B0PsG3wF.js +0 -1
- package/dist/assets/Integrations-DD48mmxj.js +0 -1
- package/dist/assets/Library-02NRO2CR.js +0 -1
- package/dist/assets/Locations-CUmRk0or.js +0 -3
- package/dist/assets/MyAccess-CIhAKN-2.js +0 -2
- package/dist/assets/Notifications-WPdPSM1o.js +0 -1
- package/dist/assets/Recordings-BeU7j2Jf.js +0 -1
- package/dist/assets/SessionsList-DTdwgdgY.js +0 -2
- package/dist/assets/circle-slash-DFnFtATu.js +0 -1
- package/dist/assets/client-Cj9cIFJV.js +0 -358
- package/dist/assets/crop-CesdRTv2.js +0 -1
- package/dist/assets/device-picker-model-CVKD2t0V.js +0 -1
- package/dist/assets/dist-o4U_Imrg.js +0 -358
- package/dist/assets/i18n-BuS8cl72.js +0 -1
- package/dist/assets/index-BuOqDa4D.css +0 -2
- package/dist/assets/index-CM1JjjBW.js +0 -4
- package/dist/assets/mount-CVKD2t0V.js +0 -1
- package/dist/assets/notification-schedule-field-i8rEjVxQ.js +0 -1
- package/dist/assets/remoteEntry-BtmyK6Gf.js +0 -1
- package/dist/assets/src-MJ2k3G6o.js +0 -67
- package/dist/assets/useEventInvalidation-CVKD2t0V.js +0 -1
- package/dist/assets/user-round-vZzgqRIQ.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{$ as t,B as n,G as r,J as i,L as a,S as o,b as s,i as c,o as l,p as u,q as d,x as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{A as p,D as m,Fr as h,It as g,N as _,Nn as v,Nt as y,O as b,Or as x,T as S,V as C,Xn as w,Xr as T,Zt as E,_t as D,b as O,bn as k,cn as A,dn as j,dt as ee,ir as M,j as N,k as P,mn as F,or as I,ot as te,rr as ne,sa as L,ta as re,ur as R,ut as z,v as ie,xi as ae,xn as oe,y as se,yi as ce,z as B}from"./player-overlays-D98Lvll4.js";import{$n as le,Jn as ue,Kn as de,Qi as fe,Qn as pe,Vi as me,Wn as he,Xn as ge,Yn as _e,Zn as ve,h as ye,hi as be,l as xe,mi as Se,qn as Ce,u as we}from"./client-Cj9cIFJV.js";import{l as Te,t as Ee,u as De}from"./video-a3E1zR0a.js";import{a as Oe,i as ke,n as Ae,r as je,t as Me}from"./usb-wx8HtogA.js";import{t as Ne}from"./crop-CesdRTv2.js";import{t as Pe}from"./layers-DGhugmpj.js";import{n as Fe}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DdJYWyu3.js";import{$n as Ie,Ac as Le,Ar as Re,Au as ze,Bc as Be,Bn as Ve,Cc as He,Dc as Ue,Fn as We,Gc as Ge,Gn as Ke,Gu as V,Hc as qe,Hn as Je,In as Ye,J as Xe,Jr as Ze,Ju as Qe,K as $e,Ku as et,Ln as tt,Lu as nt,Mn as rt,Oc as it,Pn as at,Q as ot,Qn as st,Rn as ct,Rr as H,Ru as lt,Sn as ut,St as dt,Tc as ft,Tu as U,Uc as pt,Vc as mt,Vn as ht,Wc as gt,Wn as _t,Wt as vt,X as yt,Xu as bt,Y as xt,Ya as St,Yu as Ct,Zn as wt,Zr as Tt,Zt as Et,_c as Dt,_n as Ot,ac as kt,an as At,bc as jt,bn as Mt,cc as Nt,ec as Pt,er as Ft,fc as It,fr as Lt,gc as Rt,gn as zt,gt as Bt,hr as W,ic as Vt,ir as Ht,jc as Ut,jn as Wt,ju as Gt,kc as Kt,mn as G,mt as qt,nc as Jt,nr as Yt,oc as Xt,pr as Zt,q as Qt,qc as $t,qr as en,qu as tn,r as nn,rc as rn,rr as an,sc as on,st as sn,tc as cn,tr as ln,wc as un,xc as dn,xn as fn,xt as pn,yc as mn}from"./src-MJ2k3G6o.js";import{t as K}from"./i18n-BuS8cl72.js";import{t as q}from"./useTranslation-D3Is_4B6.js";import{G as hn,Q as gn,Z as _n,nt as vn}from"./index-CM1JjjBW.js";import"./useEventInvalidation-CVKD2t0V.js";import{t as yn}from"./NodeAddonsSettingsPanel-CTmPFs3s.js";import{a as bn,c as xn,d as Sn,g as Cn,h as wn,i as Tn,l as En,n as Dn,o as On,p as kn,r as An,s as jn,t as Mn}from"./board-model-lfov_Io5.js";var Nn=`step`,Pn=[Nn,`acc`];function Fn(e,t){return`${e}/${t}`}function In(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}function Ln(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 Rn(e){return e}function zn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function Bn(e,t){return typeof e==`boolean`?e:Rn(t)}function Vn(e,t){return{pipeline:Bn(zn(e,`detect`),t),audio:Bn(zn(e,`audio`),t),ingest:Bn(zn(e,`ingest`),t)}}function Hn(e,t,n){let r=e?.find(e=>e.nodeId===t);return Vn(r?.settings,n)}function Un({selectedNodeId:e,onSelect:t,refreshToken:n}){let r=L(),{t:i}=q(),{nodes:a}=et(),{data:c}=mn(void 0),{data:l}=He(void 0),u=new Map;for(let e of c??[])u.set(e.agentNodeId,(u.get(e.agentNodeId)??0)+1);let d=a??[],p=d.filter(e=>e.isOnline).length,m=d.filter(e=>!e.isOnline).length;return o(`div`,{className:`flex flex-col h-full`,children:[o(`button`,{type:`button`,onClick:()=>t(Fo),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[f(Te,{className:`h-4 w-4 flex-shrink-0`}),o(`div`,{className:`min-w-0 flex-1`,children:[f(`div`,{className:`text-xs font-semibold truncate`,children:i(`pipeline.nodeList.cluster`,`Cluster`)}),f(`div`,{className:`text-[10px] text-foreground-subtle`,children:i(`pipeline.nodeList.assignmentsLoadBalancingRoles`,`Assignments, load balancing, roles`)})]})]}),f(`div`,{className:`flex-1 overflow-y-auto`,children:d.map(n=>{let a=e===n.id,c=u.get(n.id)??0,d=n.isHub?j:T,p=Hn(l,n.id,n.isHub),m=n.isOnline?null:vt(Ln(n.lastSeen),r);return o(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${a?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[f(d,{className:`h-4 w-4 flex-shrink-0`}),o(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:i(`common.hubWord`)}),!n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-danger flex-shrink-0`}),n.isOnline&&f(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),o(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[f(`span`,{children:i(`common.coresCount`,{count:n.cpuCores})}),f(`span`,{children:`•`}),o(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),c>0&&o(s,{children:[f(`span`,{children:`•`}),o(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[f(Ee,{className:`h-2.5 w-2.5`}),c]})]}),!n.isOnline&&o(s,{children:[f(`span`,{children:`•`}),o(`span`,{className:`text-danger`,children:[i(`common.offline`),m===null?``:` · ${m}`]})]})]}),o(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[f(H,{variant:p.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.pipeline?i(`pipeline.nodeList.pipelineEnabled`,`Pipeline: enabled`):i(`pipeline.nodeList.pipelineNotEnabledAgentCapability`,`Pipeline: not enabled (agent capability)`),children:i(`pipeline.nodeList.pipe`,`Pipe`)}),f(H,{variant:p.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:p.audio?i(`pipeline.nodeList.audioEnabled`,`Audio: enabled`):i(`pipeline.nodeList.audioNotEnabledAgentCapability`,`Audio: not enabled (agent capability)`),children:i(`pipeline.nodeList.aud`,`Aud`)})]})]})]},n.id)})}),o(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[f(`span`,{children:i(`common.onlineCount`,{count:p})}),m>0&&f(`span`,{className:`text-danger`,children:i(`common.offlineCount`,{count:m})})]})]})}function Wn({nodeId:e,refreshToken:t}){let{t:n}=q(),{nodes:r}=et(),i=r?.find(t=>t.id===e),a=tn(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return i?o(`div`,{className:`px-6 py-4 border-b border-border`,children:[o(`div`,{className:`flex items-center gap-2 mb-1`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:i.name}),i.isOnline?f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:n(`common.online`)}):f(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-danger/10 text-danger`,children:n(`common.offline`)}),i.isHub&&f(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:n(`common.hubWord`)})]}),o(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[f(`span`,{children:i.cpuModel??`CPU`}),f(`span`,{children:`•`}),f(`span`,{children:n(`common.coresCount`,{count:i.cpuCores})}),f(`span`,{children:`•`}),o(`span`,{children:[Math.round(i.memoryMB/1024),` GB`]}),a&&o(s,{children:[f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.cameras`,{attached:a.attachedCameras,active:a.activeCameras})}),f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.avgInference`,{ms:a.avgInferenceTimeMs.toFixed(0)})}),f(`span`,{children:`•`}),f(`span`,{children:n(`pipeline.nodeDetailHeader.queue`,{depth:a.queueDepthTotal})}),a.hardware.hasGpu&&o(s,{children:[f(`span`,{children:`•`}),f(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):f(`div`,{className:`px-6 py-4 border-b border-border`,children:o(`div`,{className:`text-xs text-foreground-subtle`,children:[n(`pipeline.nodeDetailHeader.nodeNotFound`,`Node not found:`),` `,e]})})}var Gn=[`assignments`,`tree`,`engines`,`logs`];t();function Kn({refreshToken:e,nodeId:t}){let{t:n}=q(),[a,s]=i(new Map),{nodes:c}=V();Ct(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&s(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:l}=Nt(void 0),u=r(()=>{let e=new Map;for(let t of l??[])e.set(t.nodeId,t.deviceCount);return e},[l]),d=r(()=>{let e=new Map,t=Date.now()-3e4;for(let n of a.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},[a]),p=r(()=>{let e=new Map;for(let t of c)e.set(t.id,t.shortName);return e},[c]),m=r(()=>{let e=0,t=0,n=0,r=0,i=0;for(let a of d.values())e+=a.attachedCameras,t+=a.activeCameras,n+=a.totalFps,r+=a.totalInferenceWeighted,i+=a.queueDepth;let a=e>0?r/e:0;return{totalAgents:c.length,onlineAgents:c.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:a,queueDepth:i,totalFps:n}},[d,c]);if(t){let e=d.get(t);return o(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),o(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[f(J,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),f(J,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),f(J,{label:n(`pipeline.liveLoadPanel.avgInferMs`,`Avg infer ms`),value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),f(J,{label:n(`pipeline.liveLoadPanel.queue`,`Queue`),value:e?String(e.queueDepth):`—`}),f(J,{label:n(`pipeline.liveLoadPanel.audio`,`Audio`),value:String(u.get(t)??`—`)})]})]})}let h=[...d.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return o(`div`,{className:`@container/liveload`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:n(`pipeline.liveLoadPanel.liveLoad`,`Live load`)}),o(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[f(J,{label:n(`pipeline.liveLoadPanel.totalAgents`,`Total agents`),value:`${m.onlineAgents}/${m.totalAgents}`}),f(J,{label:n(`pipeline.liveLoadPanel.activeAttached`,`Active / Attached`),value:`${m.activeCameras}/${m.attachedCameras}`}),f(J,{label:n(`pipeline.liveLoadPanel.totalFps`,`Total FPS`),value:m.totalFps.toFixed(1)}),f(J,{label:n(`pipeline.liveLoadPanel.avgInferenceMs`,`Avg inference ms`),value:m.avgInferenceTimeMs.toFixed(0)}),f(J,{label:n(`pipeline.liveLoadPanel.queueDepth`,`Queue depth`),value:String(m.queueDepth)})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:o(`table`,{className:`w-full text-xs min-w-[480px]`,children:[f(`thead`,{className:`bg-surface`,children:o(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.liveLoadPanel.agent`,`Agent`)}),f(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.cameras`,`Cameras`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.inferenceMs`,`Inference ms`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.queue`,`Queue`)}),f(`th`,{className:`text-right px-3 py-2`,children:n(`pipeline.liveLoadPanel.audio`,`Audio`)})]})}),o(`tbody`,{children:[h.map(([e,t])=>o(`tr`,{className:`border-t border-border`,children:[f(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:p.get(e)??e}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:u.get(e)??`—`})]},e)),h.length===0&&f(`tr`,{children:f(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`pipeline.liveLoadPanel.noCameraMetricsReceivedYet`,`No camera metrics received yet`)})})]})]})})]})}function J({label:e,value:t}){return o(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[f(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),f(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}var qn={active:!1,pinned:!1,nodeId:null,reason:``};function Jn(e,t){return e.deviceName.localeCompare(t.deviceName)||e.deviceId-t.deviceId}function Yn(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??``}:qn,o=n?{active:!0,pinned:n.pinned,nodeId:n.nodeId,reason:``}:qn;return{deviceId:e.id,deviceName:e.name,disabled:e.disabled===!0,pipeline:a,detection:a,decoder:qn,audio:o}}).toSorted(Jn)}function Xn(e,t,n){return{active:e!==null,pinned:t,nodeId:e,reason:n??``}}function Zn(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:Xn(t.detectionNodeId,t.pinned.detection,t.reasons.detection),decoder:Xn(t.decoderNodeId,t.pinned.decoder,t.reasons.decoder),audio:Xn(t.audioNodeId,t.pinned.audio,t.reasons.audio)}})}function Qn(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(Jn)}function $n(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 er(e){let t=new Map(e.map(e=>[e.id,e.name]));return e=>t.get(e)??K.t(`helpers.assignmentRows.cameraFallback`,{id:e})}function tr(e,t,n){let r=[...new Set([...e.nodeId===null?[]:[e.nodeId],...t.map(e=>e.id)])];return[{value:`auto`,label:K.t(`helpers.assignmentRows.auto`)},...r.map(e=>({value:e,label:K.t(`helpers.assignmentRows.pinTo`,{node:n(e)})}))]}function nr({roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a}){if(n.nodeId===null)return null;let o=n.nodeId,s=a===void 0?!1:n.active&&o===a;return f(Mt,{roleId:e,roleLabel:t,nodeName:r(o),colorId:ut(i,o),emphasized:s,pinned:n.pinned})}function rr({detection:e,decoder:t,audio:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a}){let s=(e,t,n)=>f(nr,{roleId:e,roleLabel:t,state:n,nameOf:r,colorByNodeId:i,emphasizeOnNodeId:a},e);return o(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[s(`detection`,`Detection`,e),s(`decode`,`Decode`,t),s(`audio`,`Audio`,n)]})}function ir({snap:e}){let t=L(),{t:n}=q();if(e===void 0)return f(`div`,{className:`flex h-8 items-center text-[11px] text-foreground-subtle`,title:n(`assignments.assignmentStatusCell.noMetricsInTheLast`,`No metrics in the last 10 s — the camera has no session running`),children:n(`assignments.assignmentStatusCell.noLiveData`,`no live data`)});let{phase:r,actualFps:i,avgInferenceTimeMs:a,queueDepth:s,configuredFps:c,droppedFrames:l}=e.metrics,u=At(r,t);return o(`div`,{className:`flex h-8 min-w-0 flex-col justify-center font-mono text-[10px] leading-tight tabular-nums`,children:[o(`span`,{className:`inline-flex min-w-0 items-center gap-1 ${u.textColor}`,children:[f(sn,{phase:r,className:`h-2.5 w-2.5 shrink-0`}),f(`span`,{className:`truncate font-semibold uppercase tracking-wider`,children:u.label}),f(`span`,{className:`text-foreground`,children:i.toFixed(1)}),f(`span`,{className:`text-foreground-subtle`,children:n(`pipeline.assignmentStatusCell.configuredFps`,{fps:c.toFixed(0)})})]}),o(`span`,{className:`truncate text-foreground-subtle`,children:[f(`span`,{className:`text-foreground`,children:a.toFixed(0)}),` ms`,s>0&&o(`span`,{className:`ml-1 text-warning`,children:[`q`,s]}),f(`span`,{className:l>0?`ml-1 text-warning`:`ml-1`,children:n(`pipeline.assignmentStatusCell.drops`,{count:l})})]})]})}t();var ar=1e4,or=5e3;function sr(e){let[t,r]=i(new Map);return Ct(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e!==void 0&&n.nodeId!==e||r(e=>new Map(e).set(n.deviceId,n)))}),n(()=>{if(t.size===0)return;let e=setInterval(()=>{r(e=>{let t=Date.now()-ar,n=[...e].filter(([,e])=>e.timestamp>=t);return n.length===e.size?e:new Map(n)})},or);return()=>clearInterval(e)},[t.size]),t}var cr=3e5;function lr({state:e,onlineNodes:t,nameOf:n,pending:r,onChange:i}){let{t:a}=q();return f(U,{"aria-label":a(`assignments.placementControls.nodePin`,`Node pin`),title:a(`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:[...tr(e,t,n)],onChange:e=>i(e.target.value)})}function ur({deviceId:e,nodeId:t}){let{t:n}=q(),r=l(),{data:i}=jt({deviceId:e},{refetchOnMount:`always`}),{data:a}=Dt({nodeId:t},{staleTime:cr}),o=mt({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});if(i===void 0||a===void 0)return f(`span`,{className:`text-[10px] italic text-foreground-subtle`,children:n(`assignments.placementControls.accelerator`,`accelerator: …`)});let s=a.devices??[],c=s.filter(e=>e.enabled),u=i?.deviceKey??`auto`,d=u!==`auto`&&!c.some(e=>e.key===u),p=s.find(e=>e.key===u),m=[{value:`auto`,label:n(`assignments.placementControls.anyAccelerator`,`Any accelerator`)},...d?[{value:u,label:n(`pipeline.placementControls.notEnabled`,{name:p?`${_t(p)} (${u})`:u})}]:[],...c.map(e=>({value:e.key,label:`${_t(e)} · ${e.format}`}))];return f(U,{"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:u,disabled:o.isPending,options:m,onChange:t=>o.mutate({deviceId:e,deviceKey:t.target.value})})}t();function dr(e){let t=d(null);return e.nodeId!==null&&(t.current=e),t.current}function fr({deviceId:e,state:t,...n}){let{t:r}=q(),i=dr(t);return o(`div`,{className:`grid w-80 grid-cols-2 gap-1.5`,children:[f(lr,{state:t,...n}),i?.nodeId==null?f(U,{"aria-label":r(`assignments.clusterRowCells.inferenceDevicePinNoNode`,`Inference device pin (no node yet)`),title:r(`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:r(`assignments.clusterRowCells.anyAccelerator`,`Any accelerator`)}]}):f(ur,{deviceId:e,nodeId:i.nodeId})]})}function pr({state:e,nameOf:t}){let{t:n}=q(),r=dr(e);if(r?.nodeId==null)return f(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`assignments.clusterRowCells.noSessionYet`,`— no session yet`)});let i=e.active&&e.nodeId!==null,a=r.pinned?`pinned`:`auto · ${r.reason||`capacity`}`;return o(`div`,{"data-testid":`resolved-placement`,className:`flex w-40 min-w-0 flex-col leading-tight`,title:r.pinned?void 0:n(`assignments.clusterRowCells.anUnpinnedCameraIsPlaced`,`An unpinned camera is placed again at every session start, so this can change between sessions.`),children:[o(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,children:[f(`span`,{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${i?`bg-success`:`bg-foreground-subtle/40`}`}),f(`span`,{"data-testid":`resolved-placement-node`,className:`truncate font-medium ${i?`text-foreground`:`text-foreground-muted`}`,children:t(r.nodeId)})]}),f(`span`,{className:`truncate pl-3 text-[10px] ${r.pinned?`text-warning`:`text-foreground-subtle`}`,children:i?a:n(`assignments.clusterRowCells.idleLastSession`,`{{how}} · idle, last session`,{how:a})})]})}function mr({deviceId:e,deviceName:t}){let{t:n}=q(),[r,a]=i(!1);return o(s,{children:[f(Gt,{icon:oe,variant:`ghost`,size:`sm`,"aria-label":n(`assignments.clusterRowCells.streamBrokersOf`,`Stream brokers of {{deviceName}}`,{deviceName:t}),title:n(`assignments.clusterRowCells.streamBrokersClients`,`Stream brokers & clients`),onClick:()=>a(!0)}),f(st,{open:r,onOpenChange:a,children:o(Ft,{width:`lg`,scroll:`body`,placement:`sheet-on-mobile`,children:[f(an,{children:f(Ht,{children:n(`pipeline.clusterRowCells.brokersTitle`,{device:t})})}),f(Ie,{children:r&&f(wt,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:e,instanceId:`pipeline-row/${e}`,config:{variant:`compact`}})})]})})]})}function hr(e){return e.hasFreshMetrics?`active`:e.hasPipelineAssignment?`recently-active`:`inactive`}function gr(e,t){return t.size===0?!0:t.has(e)}var _r=[{value:`active`,get label(){return K.t(`helpers.cameraActivity.active`)}},{value:`recently-active`,get label(){return K.t(`helpers.cameraActivity.recentlyActive`)}},{value:`inactive`,get label(){return K.t(`helpers.cameraActivity.inactive`)}}];t();var vr=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`];function yr(e){for(let t of[`getPipelineAssignments`,`getAudioAssignments`,`getCameraStatuses`])e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,t]]})}function br(){let{t:e}=q(),t=l();nn([`pipelineOrchestrator`,`getPipelineAssignments`],vr),nn([`pipelineOrchestrator`,`getAudioAssignments`],vr),nn([`pipelineOrchestrator`,`getCameraStatuses`],vr);let{data:n}=St({isCamera:!0,projection:`slim`}),{data:a}=mn(void 0),{data:s}=on(void 0),{data:c}=It({}),{data:u}=He(void 0),{nodes:d}=V(),p=sr(),m=r(()=>$n(d),[d]),h=r(()=>fn(u),[u]),g=r(()=>d.filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[d]),_=r(()=>Zn(Yn((n??[]).map(e=>({id:e.id,name:e.name,disabled:e.disabled})),a??[],s??[]),c??[]),[n,a,s,c]),[v,y]=i(()=>new Set),b=r(()=>_.filter(e=>gr(hr({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=()=>yr(t),C=kt({onSuccess:S}),w=Ge({onSuccess:S}),T=C.isPending||w.isPending,E=[{key:`camera`,header:e(`pipeline.cameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:t=>o(`div`,{className:`flex w-44 min-w-0 items-center gap-1.5`,children:[f(gn,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs font-medium text-primary hover:underline`,title:t.deviceName,children:t.deviceName}),t.disabled&&f(H,{variant:`default`,children:e(`common.off`)})]})},{key:`placement`,header:e(`pipeline.cameraAssignmentsTable.placement`,`Placement`),width:`w-80`,notSortableReason:`A pair of controls — editing one would move the row under the cursor.`,render:e=>f(fr,{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:e(`pipeline.cameraAssignmentsTable.rolesHere`,`Roles here`),notSortableReason:`A set of roles has no single order.`,render:e=>f(rr,{detection:e.detection,decoder:e.decoder,audio:e.audio,nameOf:m,colorByNodeId:h})},{key:`resolved`,header:e(`pipeline.cameraAssignmentsTable.runningOn`,`Running on`),width:`w-40`,sortValue:e=>e.pipeline.nodeId===null?null:m(e.pipeline.nodeId),render:e=>f(pr,{state:e.pipeline,nameOf:m})},{key:`status`,header:e(`pipeline.cameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>p.get(e.deviceId)?.metrics.actualFps??null,render:e=>f(ir,{snap:p.get(e.deviceId)})},{key:`brokers`,header:``,align:`right`,width:`w-10`,notSortableReason:`An action`,render:e=>f(mr,{deviceId:e.deviceId,deviceName:e.deviceName})}],D=n===void 0?`Loading cameras…`:_.length===0?`No cameras`:`No cameras match this activity filter.`;return o(`div`,{className:`flex flex-col gap-2`,children:[f(`nav`,{"aria-label":e(`pipeline.cameraAssignmentsTable.filterByCameraActivity`,`Filter by camera activity`),"data-testid":`assignments-activity-filter`,children:f(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:_r.map(e=>{let t=v.has(e.value);return f(`button`,{type:`button`,"aria-pressed":t,"data-testid":`assignments-activity-${e.value}`,className:lt(se,t?ie:O),onClick:()=>x(e.value),children:e.label},e.value)})})}),f(zt,{columns:E,rows:b,rowKey:e=>e.deviceId,minWidthPx:920,maxBodyHeight:Ot,emptyMessage:D})]})}t();function xr({nodeId:e}){let{t}=q(),n=l();nn([`pipelineOrchestrator`,`getCameraStatuses`],vr);let{data:i}=It({}),{data:a}=He(void 0),{data:o}=St({isCamera:!0,projection:`slim`}),{nodes:s}=V(),c=sr(),u=r(()=>$n(s),[s]),d=r(()=>fn(a),[a]),p=r(()=>Qn(e,i??[],er((o??[]).map(e=>({id:e.id,name:e.name})))),[e,i,o]),m=s.filter(t=>t.isOnline&&t.id!==e),h=()=>yr(n),g=kt({onSuccess:h}),_=Ge({onSuccess:h}),v=Vt({onSuccess:h}),y=gt({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 f(zt,{columns:[{key:`camera`,header:t(`pipeline.nodeCameraAssignmentsTable.camera`,`Camera`),width:`w-44`,sortValue:e=>e.deviceName,render:e=>f(gn,{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=>f(rr,{detection:t.detection,decoder:t.decoder,audio:t.audio,nameOf:u,colorByNodeId:d,emphasizeOnNodeId:e})},{key:`status`,header:t(`pipeline.nodeCameraAssignmentsTable.status`,`Status`),width:`w-40`,sortValue:e=>c.get(e.deviceId)?.metrics.actualFps??null,render:e=>f(ir,{snap:c.get(e.deviceId)})},{key:`actions`,header:``,align:`right`,width:`w-10`,notSortableReason:`Actions`,render:e=>f(Bt,{items:b(e),title:t(`pipeline.nodeCameraAssignmentsTable.move`,`Move {{deviceName}}`,{deviceName:e.deviceName})})}],rows:p,rowKey:e=>e.deviceId,minWidthPx:560,maxBodyHeight:Ot,emptyMessage:i===void 0?t(`pipeline.nodeCameraAssignmentsTable.loadingCameras`,`Loading cameras…`):t(`pipeline.nodeCameraAssignmentsTable.noCameraRunsOnThis`,`No camera runs on this node right now`)})}function Sr({nodeId:e,refreshToken:t}){let{t:n}=q(),{nodes:r}=V(),i=r.find(t=>t.id===e)?.name??e;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(Kn,{refreshToken:t,nodeId:e}),o(`div`,{className:`space-y-2`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.nodeCamerasTab.camerasOn`,{node:i})}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`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.`)})]}),f(xr,{nodeId:e})]})]})}t();function Cr(e,t){let n=Math.max(0,t-e),r=Math.floor(e/1e3),i=Math.floor(n/1e3);return K.t(`pipeline.nodeEnginesTab.idleLeft`,{idle:r,left:i})}function wr({nodeId:e,refreshToken:t}){let{t:n}=q(),i=l(),a=Re(),s=cn({onSettled:()=>{i.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:c}=Jt({nodeId:e}),u=tn(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??c??null,d=u===null;nn([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:p}=$t({nodeId:e}),{values:m}=Qe(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),h=r(()=>m.filter(e=>e.metrics.phase===`active`).length,[m]),_=t=>{let r=p??[];if(r.length===0){s.mutate({nodeId:e,engine:t,force:!1});return}(async()=>{await a({title:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),message:`${String(r.length)} camera(s) are dispatching through this engine. Killing it drops their in-flight work and forces a respawn on the next frame.`,confirmLabel:n(`pipeline.nodeEnginesTab.killEngine`,`Kill engine`),variant:`danger`})&&s.mutate({nodeId:e,engine:t,force:!0})})()};return o(`div`,{className:`space-y-6`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:n(`pipeline.nodeEnginesTab.inferenceEnginesOnThisNode`,`Inference engines on this node`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`pipeline.nodeEnginesTab.summary`,{engines:(u??[]).length,cameras:(p??[]).length,active:h})})]}),f(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:o(`table`,{className:`w-full text-xs min-w-[640px]`,children:[f(`thead`,{className:`bg-surface`,children:o(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.kind`,`Kind`)}),f(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.runtimeBackendDevice`,`Runtime / Backend / Device`)}),f(`th`,{className:`text-left px-3 py-2`,children:n(`pipeline.nodeEnginesTab.models`,`Models`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.poolPid`,`Pool PID`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.autoKill`,`Auto-kill`)}),f(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:n(`pipeline.nodeEnginesTab.inUse`,`In use`)}),f(`th`,{className:`w-20`})]})}),o(`tbody`,{children:[d&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`common.loading`,`Loading…`)})}),!d&&(u??[]).map(e=>{let t=e.kind===`device-pool`;return o(`tr`,{className:`border-t border-border ${t?`bg-primary/[0.05]`:``}`,children:[f(`td`,{className:`px-3 py-2`,children:o(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[f(t?Pe:T,{className:`h-3 w-3`}),n(t?`pipeline.nodeEnginesTab.pool`:`pipeline.nodeEnginesTab.runtime`)]})}),f(`td`,{className:`px-3 py-2`,children:o(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[f(z,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),f(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?f(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):f(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>f(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),f(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),f(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?f(`span`,{className:`text-foreground-subtle`,children:Cr(e.idleMs,e.idleTtlMs)}):f(`span`,{className:`text-foreground-subtle/50`,children:n(`common.never`)})}),f(`td`,{className:`px-3 py-2 text-right text-foreground`,children:(p??[]).length}),f(`td`,{className:`px-3 py-2 text-right`,children:t?f(`span`,{className:`text-[11px] text-foreground-subtle`,children:n(`common.auto`)}):o(W,{variant:`ghost`,size:`sm`,disabled:s.isPending,onClick:()=>_(e.engine),className:`text-danger hover:bg-danger/10 hover:text-danger`,children:[f(g,{className:`h-3.5 w-3.5`}),n(`pipeline.nodeEnginesTab.kill`,`Kill`)]})})]},e.engineKey)}),!d&&(u??[]).length===0&&f(`tr`,{children:f(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:n(`pipeline.nodeEnginesTab.noEnginesResidentTheFactory`,`No engines resident — the factory spins up on the first pipeline run.`)})})]})]})}),f(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:f(_n,{i18nKey:`pipeline.nodeEnginesTab.legend`,components:{strong:f(`strong`,{className:`text-foreground`})}})}),s.isError&&f(Lt,{message:n(`pipeline.nodeEnginesTab.killFailed`,{message:s.error instanceof Error?s.error.message:n(`common.unknownError`)})})]})}var Tr=`pipeline-runner`,Er=200;function Dr({nodeId:e}){let{t}=q();return o(`div`,{className:`flex flex-col gap-3`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:t(`pipeline.nodeLogsTab.runnerLogs`,`Runner logs`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`pipeline.nodeLogsTab.description`,{node:e})})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(Et,{agentId:e,addonId:Tr,limit:Er,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}t();function Or({nodeId:e,title:t}){let n=L(),{t:i}=q(),{data:a}=hn(),{data:s}=mn(void 0),c=r(()=>{let e=new Map;for(let t of a??[])e.set(t.id,t.name);return e},[a]),l=r(()=>{if(!e)return null;let t=new Set;for(let n of s??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,s]),u=sr(e),d=r(()=>{let e=[];for(let t of u.values())l&&!l.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[u,l]);return d.length===0?o(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`),`: no live snapshots yet`]}):o(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[o(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[f(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??i(`pipeline.cameraStatusStrip.cameras`,`Cameras`)}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:d.length})]}),f(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>{let t=c.get(e.deviceId)??`#${e.deviceId}`,r=At(e.metrics.phase,n);return o(`div`,{title:i(`pipeline.cameraStatusStrip.fpsMsInferQ`,`{{name}} · {{label}} · {{value3}} fps · {{value4}}ms infer · q={{queueDepth}}`,{name:t,label:r.label,value3:e.metrics.actualFps.toFixed(1),value4:e.metrics.avgInferenceTimeMs.toFixed(0),queueDepth:e.metrics.queueDepth}),className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${r.badgeClass}`,children:[f(sn,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),f(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),f(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),f(`span`,{className:`opacity-60`,children:i(`common.fpsWord`)})]},e.deviceId)})})]})}function kr(e,t,n){return e.map(e=>{if(e.key===t)return e;let r=e.steps[n];if(!r||r.settings===void 0)return e;let{settings:i,...a}=r,o={...e.steps};return Object.keys(a).length>0?o[n]=a:delete o[n],{...e,steps:o}})}function Ar(e,t,n){let r=e.filter(e=>e.key!==t).toSorted((e,t)=>e.key.localeCompare(t.key)),i=[...r.filter(e=>!e.enabled),...r.filter(e=>e.enabled),...e.filter(e=>e.key===t)],a;for(let e of i){let t=e.steps?.[n]?.settings;!t||Object.keys(t).length===0||(a={...a,...t})}return a}function jr(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 Mr=`pipeline-orchestrator`;function Nr({addonId:e,highlightLabel:t}){let{t:n}=q(),r=_e(e),{data:i}=Ze({addonId:Mr});if(r.length===0)return null;let a=pe(i??null)[e]??{};return o(`section`,{className:`space-y-1.5 border-t border-border/60 pt-3`,"aria-label":n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`),children:[o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`h3`,{className:C,children:n(`stepInspector.clusterOwnedSettings.clusterWideSettings`,`Cluster-wide settings`)}),f(gn,{to:Ho(e),className:`ml-auto text-[11px] text-primary hover:underline`,children:n(`stepInspector.clusterOwnedSettings.editInClusterSettings`,`Edit in Cluster → Settings ›`)})]}),r.map(e=>o(`div`,{className:`${p} rounded px-2 ${t===e.label?`bg-primary/5 ring-1 ring-primary/40`:``}`,children:[f(`span`,{className:N,children:e.label}),f(`span`,{className:_,children:f(`span`,{className:`font-mono text-xs text-foreground`,children:String(a[e.key]??e.default)})})]},e.key)),f(`p`,{className:B,children:n(`stepInspector.clusterOwnedSettings.oneValueForEveryNode`,`One value for every node and camera — this step writes into a shared index.`)})]})}function Pr({rows:e}){let{t}=q();return o(`div`,{className:`space-y-1.5`,"data-testid":`effective-models`,children:[f(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(`li`,{className:`${S} flex flex-wrap items-baseline gap-x-2 text-xs`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-foreground-muted`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:e.modelId??`—`}),f(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.sourceLabel})]},e.id))}),f(`p`,{className:B,children:t(`stepInspector.effectiveModelSummary.toChangeAModelOpen`,`To change a model, open that accelerator's cell in the table.`)})]})}t();function Fr(e,t){let[n,i]=vn(),o=n.get(Nn),s=n.get(`acc`),c=r(()=>In(e,t,{step:o,acc:s}),[e,t,o,s]),l=a(e=>{i(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[i]);return{selection:c,open:a(e=>l(t=>{t.set(Nn,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:a(()=>l(e=>{e.delete(Nn),e.delete(`acc`)}),[l])}}function Ir(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function Lr(e){return e.split(`.`)[0]??e}function Rr(e,t,n){return{id:Fn(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${Lr(t)} · ${_t(n)}`,shortLabel:`${Lr(t)} · ${Ke(n)}`,nodeLabel:Lr(t),disabled:!n.enabled}}function zr(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>Rr(e,t,n))}function Br(e,t,n=!1){return e.flatMap(e=>{let r=t[e.id]??[];if(n)return r.map(t=>Rr(e.id,e.name,t));let i=r.filter(e=>e.enabled&&e.available);if(i.length>0)return i.map(t=>Rr(e.id,e.name,t));let a=r.find(e=>e.available)??r[0];return a===void 0?[]:[Rr(e.id,e.name,a)]})}function Vr(e,t,n){return{modelId:Ve({catalog:e,device:t.device,base:n.nodePin,override:n.cameraPin}),source:n.cameraPin===void 0?n.nodePin===void 0?`default`:`node`:`camera`}}function Hr(e,t,n){let r=Ir(e,`object-detection`);if(r===null)return;let i=Ve({catalog:r,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId,override:n});if(i===void 0)return;let a=r.models.find(e=>e.id===i);return{modelId:i,name:a?.name??i,supplies:a?.suppliesSteps??[]}}function Ur(e,t,n){return!Se(e)||n===void 0?!1:be(e,t,n.supplies).effective}function Wr(e,t){return e!==null&&ht(e.models,t.device.format)}function Gr(e){return Wr(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,overridden:e.model.source===`camera`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function Kr(e){return Object.values(e).reduce((e,t)=>e+t.filter(e=>!e.enabled).length,0)}function qr(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=_e(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function Jr(e){return e.flatMap(e=>[{node:e,depth:0},...Jr(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function Yr(e,t){return e.flatMap(e=>{let n=Yr(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}t();function Xr(e){return{agentNodeId:e.nodeId,nodeLabel:e.nodeLabel,engineLabel:e.device.format,deviceKey:e.deviceKey,deviceLabel:_t(e.device),detail:e.device.defaultModelId,disabled:e.disabled}}function Zr({tree:e,searchRows:t,accelerators:n,cellState:s,stepBadge:c,disabledCount:l,showDisabled:u,onShowDisabledChange:p,dirty:m,onDiscard:h,summary:g,toolbar:_,label:v,renderDetail:y}){let{t:b}=q(),x=Re(),S=nt(),{selection:C,open:w,close:T}=Fr(r(()=>Jr(e).map(e=>e.node.addonId),[e]),r(()=>n.map(e=>e.id),[n])),[E,D]=i(``),[O,k]=i(null),[A,j]=i(null),M=d(null),N=d(null),P=d(null),F=d(null),I=r(()=>Qt(t,E),[t,E]),te=r(()=>E.trim()===``?e:Yr(e,new Set(I.map(e=>e.addonId))),[e,I,E]),ne=e=>I.find(t=>t.addonId===e)?.matchedField??null,L=r(()=>n.map(Xr),[n]),re=e=>n.find(t=>t.nodeId===e.agentNodeId&&t.deviceKey===e.deviceKey),R=n.find(e=>e.id===C.acceleratorId)??null,z=C.stepId!==null,ie=a(async e=>{if(m){if(!await x({title:b(`stepInspector.stepMatrixFrame.discardUnsavedChanges`,`Discard unsaved changes?`),message:b(`stepInspector.stepMatrixFrame.thisStepHasChangesThat`,`This step has changes that are not saved yet.`),confirmLabel:b(`stepInspector.stepMatrixFrame.discard`,`Discard`),variant:`danger`}))return;h()}e()},[x,m,h,b]),ae=()=>{requestAnimationFrame(()=>F.current?.focus())},oe=(e,t,n=!1)=>{if(e===C.stepId&&(t?.id??null)===C.acceleratorId){n&&ae();return}let r=()=>{k(ne(e)),w({stepId:e,...t===void 0?{}:{acceleratorId:t.id}}),n&&ae()};e===C.stepId?r():ie(r)},se=()=>{let e=C.stepId;ie(()=>{if(T(),e!==null){let t=R===null?null:dt({agentNodeId:R.nodeId,deviceKey:R.deviceKey});requestAnimationFrame(()=>M.current?.focusCell(e,t))}})},ce=e=>{if(e.key===`Enter`){let t=I[0];if(t===void 0)return;e.preventDefault(),oe(t.addonId,void 0,!0)}else e.key===`Escape`&&D(``)},le=S?f(yt,{onClick:se}):f(Gt,{icon:ee,variant:`ghost`,size:`sm`,"aria-label":b(`common.close`,`Close`),onClick:se});return o(`div`,{ref:N,className:`space-y-2`,onKeyDown:e=>{let t=e.target instanceof HTMLElement&&e.target.dataset.r!==void 0;e.key===`/`&&t&&(e.preventDefault(),P.current?.focus()),e.key===`Escape`&&t&&z&&(e.preventDefault(),se())},children:[o(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`div`,{className:`min-w-0 basis-full sm:basis-auto`,children:g}),f(`input`,{ref:P,type:`search`,value:E,onChange:e=>D(e.target.value),onKeyDown:ce,placeholder:b(`stepInspector.stepMatrixFrame.filterStepsOrSettings`,`Filter steps or settings /`),"aria-label":b(`stepInspector.stepMatrixFrame.filterStepsOrSettings2`,`Filter steps or settings`),className:`h-9 w-56 rounded-md border border-border bg-background px-2 text-xs text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 md:h-7`}),l>0&&o(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[f(rt,{checked:u,onChange:e=>p(e.target.checked)}),b(`stepInspector.stepMatrixFrame.showDisabled`,{count:l})]}),_]}),C.staleStepId!==null&&f(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-1.5 text-[11px] text-warning`,children:b(`stepInspector.stepMatrixFrame.staleStep`,{id:C.staleStepId})}),te.length===0?f(`p`,{className:`${B} rounded-md border border-dashed border-border px-3 py-4 text-center`,children:b(`stepInspector.stepMatrixFrame.noStepMatches`,{query:E})}):f(pn,{ref:M,tree:te,agents:L,label:v,getCellState:(e,t)=>{let n=re(t);return n===void 0?{kind:`na`}:s(e,n)},onCellClick:(e,t,n)=>oe(e,re(t),n),onStepClick:(e,t)=>oe(e,void 0,t),...c===void 0?{}:{stepBadge:c},selectedCell:z&&C.stepId!==null&&R!==null?{addonId:C.stepId,agentNodeId:R.nodeId,deviceKey:R.deviceKey}:null,fallbackNodeId:A,onFallbackNodeChange:j,reserveRightPx:z&&!S?432:0}),f(ot,{open:z,anchor:N,onClose:se,label:b(`stepInspector.stepMatrixFrame.stepSettings`,`Step settings`),children:C.stepId!==null&&y({stepId:C.stepId,accelerator:R,matchedField:O,closeButton:le,onEscape:se,headingRef:e=>{F.current=e}})})]})}t();function Qr(e){n(()=>{if(e===null)return;let t=document.getElementById(e);t===null||typeof t.scrollIntoView!=`function`||t.scrollIntoView({block:`center`,behavior:`smooth`})},[e])}t();function $r(e,t){let n=e.filter(e=>e.steps?.[t]?.settings!==void 0),r=e=>e.toSorted((e,t)=>e.key.localeCompare(t.key));return r(n.filter(e=>e.enabled))[0]?.key??r(n)[0]?.key??r(e.filter(e=>e.enabled))[0]?.key??e[0]?.key}function ei(e,t){let n=t.settings===void 0?void 0:$r(e,t.stepId),r=e.map(e=>{let r={...e.steps},i=r[t.stepId]??{},a=t.models[e.key],o=t.jumps[e.key],s=e.key===n&&t.settings!==void 0?Object.keys(t.settings).length>0?t.settings:void 0:i.settings,c=a===void 0?i.modelId:a??void 0,l=o===void 0?i.jumpDeviceKey:o||void 0,u={...c===void 0?{}:{modelId:c},...s===void 0?{}:{settings:s},...l===void 0?{}:{jumpDeviceKey:l}};return Object.keys(u).length>0?r[t.stepId]=u:delete r[t.stepId],{key:e.key,enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:r}});return n===void 0?r:kr(r,n,t.stepId)}function ti(e,t,n){if(t===null)return 0;let r=Object.entries(t.models).filter(([n,r])=>(r??void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.modelId).length,i=Object.entries(t.jumps).filter(([n,r])=>(r||void 0)!==e.find(e=>e.key===n)?.steps?.[t.stepId]?.jumpDeviceKey).length,a=new Set([...Object.keys(n),...Object.keys(t.settings??{})]),o=t.settings===void 0?0:[...a].filter(e=>!ye(n[e],t.settings?.[e])).length;return r+i+o}function ni({nodeId:e,nodeName:t,toolbar:n}){let{t:a}=q(),c=l(),u=Dt({nodeId:e},{refetchOnMount:`always`}),d=Pt({nodeId:e},{refetchOnMount:`always`}),p=ve(Ze({addonId:`pipeline-orchestrator`}).data??null),m=u.data?.devices??[],h=d.data??null,[g,_]=i(null),[v,y]=i(null),[b,x]=i(null),S=Le({onSuccess:()=>{c.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),w=r(()=>h?$e(h):[],[h]),T=r(()=>Jr(w),[w]),[E,D]=i(!1),O=r(()=>zr(e,t,m,E),[e,t,m,E]),k=r(()=>zr(e,t,m),[e,t,m]),A=k.length>=2,j=(e,t)=>(t===void 0?void 0:Ar(m,t.deviceKey,e))??{},ee=(e,t,n)=>{let r=n??t.device.steps?.[e?.id??``]?.jumpDeviceKey;if(r!==void 0&&r!==``)return k.find(e=>e.deviceKey===r);if(!Wr(e,t))return k.filter(n=>n.id!==t.id&&Wr(e,n)).toSorted((e,t)=>e.deviceKey.localeCompare(t.deviceKey))[0]},M=(e,t)=>{let n=Ir(h,e),r=Go(e),i=Hr(h,t),a=j(e,t),o=ee(n,t);return Gr({addon:n,acc:t,gatedOn:n?.enabledByDefault??!0,model:n?Vr(n,t,{nodePin:t.device.steps?.[e]?.modelId}):{modelId:void 0,source:`default`},...Ur(e,a,i)&&i?{rootName:i.name}:{},...r?{clusterModelId:p[e]??r.defaultModelId}:{},...o?{jumpTo:Ke(o.device)}:{}})},N=T.map(({node:e})=>({addonId:e.addonId,name:e.addonName,fieldLabels:qr(Ir(h,e.addonId))}));if(u.isLoading||d.isLoading)return f(`div`,{className:`animate-pulse p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.loadingPipeline`,`Loading pipeline…`)});if(h===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.catalogUnavailable`,`Catalog unavailable.`)});let P=o(`span`,{className:B,children:[a(`stepInspector.nodeStepInspector.accelerators`,`Accelerators:`),` `,f(`span`,{className:`text-foreground`,children:k.length>0?k.map(e=>Ke(e.device)).join(` · `):a(`stepInspector.nodeStepInspector.noneEnabled`,`none enabled`)}),m.some(e=>!e.enabled)&&o(s,{children:[` `,a(`stepInspector.nodeStepInspector.off`,`— off:`),` `,m.filter(e=>!e.enabled).map(Ke).join(`, `)]}),` `,`·`,` `,f(gn,{to:Uo(),className:`text-primary hover:underline`,children:a(`stepInspector.nodeStepInspector.clusterLoadBalancing`,`Cluster → Load balancing ›`)})]});return f(Zr,{tree:w,searchRows:N,accelerators:O,cellState:M,disabledCount:m.filter(e=>!e.enabled).length,showDisabled:E,onShowDisabledChange:D,dirty:g!==null&&ti(m,g,j(g.stepId,O[0]))>0,onDiscard:()=>_(null),summary:P,...n===void 0?{}:{toolbar:n},label:a(`stepInspector.nodeStepInspector.detectionSteps`,`Detection steps`),renderDetail:({stepId:n,accelerator:r,matchedField:i,closeButton:c,onEscape:l,headingRef:u})=>{let d=Ir(h,n);if(d===null)return f(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:a(`stepInspector.nodeStepInspector.noStepSelected`,`No step selected.`)});let p=g?.stepId===n?g:null,w=r??k[0]??O[0],T=j(n,w),E=p?.settings??T,D=ti(m,p,T),M=e=>{x(null),_(t=>({...t?.stepId===n?t:{stepId:n,models:{},jumps:{}},...e}))},N=Go(n),P=Ye(d),F=w===void 0?void 0:Hr(h,w),I=e=>{let t=p?.models[e.deviceKey];return t===void 0?e.device.steps?.[n]?.modelId:t??void 0},te=w===void 0?void 0:Vr(d,w,{nodePin:I(w)}).modelId,ne=O.length>1&&O.some(e=>!ye(j(n,e),T)),L=e=>{let t=I(e),r=Vr(d,e,{nodePin:t}),i=Hr(h,e),c=Ur(n,p?.settings??j(n,e),i),l=p?.jumps[e.deviceKey],u=ee(d,e,l),m=Wr(d,e)?c&&i?f(at,{rootModel:i,stepModelId:r.modelId}):void 0:o(s,{children:[a(`stepInspector.nodeStepInspector.noBuild`,{format:e.device.format}),` `,u?a(`stepInspector.nodeStepInspector.itRunsOnInstead`,`It runs on {{shortLabel}} instead.`,{shortLabel:u.shortLabel}):a(`stepInspector.nodeStepInspector.itDoesNotRunHere`,`It does not run here.`)]}),g=A?o(`label`,{className:`block space-y-1`,children:[f(`span`,{className:`text-[11px] font-medium text-foreground`,children:a(`stepInspector.nodeStepInspector.runOn`,`Run on`)}),f(U,{"aria-label":a(`stepInspector.nodeStepInspector.runOn`,`Run on`),value:l??e.device.steps?.[n]?.jumpDeviceKey??``,options:[{value:``,label:a(`stepInspector.nodeStepInspector.autoThisAcceleratorOrThe`,`Auto (this accelerator, or the next one that can run it)`)},...k.filter(t=>t.id!==e.id).map(e=>({value:e.deviceKey,label:`${e.label} · ${e.device.format}`}))],onChange:t=>M({jumps:{...p?.jumps,[e.deviceKey]:t.target.value}})}),f(`span`,{className:B,children:a(`stepInspector.nodeStepInspector.routesThisStepAndIts`,`Routes this step (and its child steps) to another accelerator of this node.`)})]}):void 0;return{label:e.label,format:e.device.format,modelId:r.modelId,source:r.source===`node`?`node`:`default`,sourceLabel:r.source===`node`?`node pin`:`hardware default`,models:Je(d.models??[],e.device.format),defaultModelId:d.defaultModelIdByFormat?.[e.device.format]??d.defaultModelId,expanded:v===e.id,onToggle:()=>y(t=>t===e.id?null:e.id),onChangeModel:t=>M({models:{...p?.models,[e.deviceKey]:t}}),...t===void 0?{}:{onReset:()=>M({models:{...p?.models,[e.deviceKey]:null}}),resetLabel:`Reset to hardware default`},...m===void 0?{}:{note:m},...g===void 0?{}:{extra:g},changed:p?.models[e.deviceKey]!==void 0||l!==void 0}},re=()=>{p!==null&&S.mutate({agentNodeId:e,inferenceDevices:jr(ei(m,p))},{onSuccess:()=>{_(null),x({kind:`saved`})},onError:e=>x({kind:`error`,error:e.message})})};return f(xt,{ref:u,title:r===null?`${d.name} · ${t}`:`${d.name} · ${r.label}`,subtitle:r===null?a(`stepInspector.nodeStepInspector.everyAcceleratorOf`,`{{slot}} · every accelerator of {{nodeName}}`,{slot:d.slot,nodeName:t}):a(`stepInspector.nodeStepInspector.baseForEveryCameraThat`,`{{slot}} · {{format}} · base for every camera that lands here`,{slot:d.slot,format:r.device.format}),leading:c,onEscape:l,saveBar:{dirtyCount:D,saving:S.isPending,status:b?.kind??null,...b?.error===void 0?{}:{error:b.error},onSave:re,onDiscard:()=>_(null)},children:o(`div`,{className:`space-y-3`,children:[o(`section`,{className:`space-y-2`,"aria-label":a(`stepInspector.nodeStepInspector.model`,`Model`),children:[f(`h3`,{className:C,children:a(`stepInspector.nodeStepInspector.model`,`Model`)}),N!==null&&w!==void 0?f(Ko,{step:N,engineFormat:w.device.format,runnableModelIds:Je(d.models??[],w.device.format).map(e=>e.id)}):O.length===0?f(`p`,{className:B,children:f(_n,{i18nKey:`stepInspector.nodeStepInspector.noAcceleratorEnabled`,components:{link:f(gn,{to:Uo(),className:`text-primary hover:underline`})}})}):r===null?f(Pr,{rows:O.map(e=>{let t=Vr(d,e,{nodePin:I(e)});return{id:e.id,label:e.label,modelId:t.modelId,sourceLabel:t.source===`node`?`node pin`:`hardware default`}})}):f(Xe,{...L(r)},r.id)]}),(P.length>0||F!==void 0)&&N===null&&o(`section`,{"aria-label":a(`stepInspector.nodeStepInspector.settings`,`Settings`),className:`space-y-2 border-t border-border/60 pt-2`,children:[f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`settings-scope`,children:a(`stepInspector.nodeStepInspector.nodeWideSettings`,{node:t})}),ne&&f(`p`,{className:`rounded-md border border-warning/40 bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:a(`stepInspector.nodeStepInspector.thisStepSSettingsDiffer`,`This step's settings differ between this node's accelerators. Saving makes the values shown here node-wide.`)}),f(ri,{addon:d,fields:P,settings:E,modelId:We(d,te,E,F),root:F,highlight:i,onChange:e=>M({settings:e})})]}),f(Nr,{addonId:n,highlightLabel:i})]})})}})}function ri({addon:e,fields:t,settings:n,modelId:r,root:i,highlight:a,onChange:o}){let s=t.find(e=>`label`in e&&e.label===a)?.key??null;return Qr(s===null?null:ct(s)),f(tt,{addon:e,fields:t,layers:{node:n},target:`node`,labels:{node:`Node`},modelId:r,...i===void 0?{}:{rootModel:i},highlightKey:s,onChangeLayer:o})}t();function ii({nodeId:e,refreshToken:t}){let{t:n}=q(),r=Re(),[a,c]=i(null),{nodes:l}=V(),u=l.find(t=>t.id===e)?.name??e,d=Ue({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 r({title:n(`pipeline.nodePipelineTab.resetToHardwareAwareDefaults`,`Reset {{nodeName}} to hardware-aware defaults?`,{nodeName:u}),message:n(`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:n(`common.reset`,`Reset`),variant:`danger`})&&(c(null),d.mutate({agentNodeId:e}))};return o(`div`,{className:`space-y-2`,children:[f(Or,{nodeId:e}),f(ni,{nodeId:e,nodeName:u,toolbar:o(s,{children:[a&&f(`span`,{className:`text-[11px] text-success`,children:a}),d.isError&&f(`span`,{className:`text-[11px] text-danger`,children:d.error instanceof Error?d.error.message:n(`pipeline.nodePipelineTab.resetFailed`,`Reset failed`)}),f(W,{variant:`outline`,size:`sm`,onClick:()=>{p()},disabled:d.isPending,title:n(`pipeline.nodePipelineTab.clearThisNodeSPer`,`Clear this node's per-device model defaults + per-camera overrides scoped to this node`),children:d.isPending?n(`pipeline.nodePipelineTab.resetting`,`Resetting…`):n(`pipeline.nodePipelineTab.resetToDefault`,`Reset to default`)})]})})]})}var ai=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],oi=`decoder-nodeav`,si=`ntab`,ci={decoder:`engine`},li={engine:`Engine & decoder`},ui=`Nothing here is set per node. Cluster-wide values are on Cluster → Settings.`;function di({nodeId:e,refreshToken:t}){let{t:n}=q(),[r,i]=vn(),{nodes:a}=V(),s=a.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.addonId??oi,c=[...ai,s],l=r.get(si),u={assignments:{id:`assignments`,label:n(`pipeline.nodeDetail.assignments`,`Assignments`),order:-10,content:f(Sr,{nodeId:e,refreshToken:t})},tree:{id:`tree`,label:n(`pipeline.nodeDetail.pipeline`,`Pipeline`),order:39,content:f(ii,{nodeId:e,refreshToken:t})},engines:{id:`engines`,label:n(`pipeline.nodeDetail.warmInstances`,`Warm instances`),order:180,content:f(wr,{nodeId:e,refreshToken:t})},logs:{id:`logs`,label:n(`pipeline.nodeDetail.logs`,`Logs`),order:300,content:f(Dr,{nodeId:e})}},d=Gn.map(e=>u[e]);return o(`div`,{className:`flex flex-col h-full`,children:[f(Wn,{nodeId:e,refreshToken:t}),f(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6`,children:f(yn,{nodeId:e,addonIds:c,level:`global`,fieldScope:`perNode`,emptyMessage:ui,tabAliases:ci,tabLabelOverrides:li,extraTabs:d,activeTab:l===null?null:ci[l]??l,onActiveTabChange:e=>i(t=>{let n=new URLSearchParams(t);n.set(si,e);for(let e of Pn)n.delete(e);return n},{replace:!0})})})]})}function fi(){let{t:e}=q();return o(`div`,{className:`space-y-2`,children:[o(`div`,{className:`min-w-0`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterAssignmentsTab.cameraPlacement`,`Camera placement`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`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.`)})]}),f(br,{})]})}function pi(e){return`${Math.round(e*100)}%`}function mi(e){return K.t(`helpers.autoTuneViewModel.sessions`,{count:e})}var hi={"intel-npu":`Intel NPU`,"intel-igpu":`Intel iGPU`,"amd-igpu":`AMD iGPU (WebGPU)`,"amd-npu":`AMD XDNA NPU`,"x86-cpu":`CPU`,"arm-cpu":`CPU`,"apple-ane":`Apple Neural Engine`,coral:`Coral Edge TPU`},gi={"intel-core-ultra":`Intel Core Ultra`,"intel-n-series":`Intel N-series`,"apple-m-base":`Apple M (base)`,"apple-m-pro":`Apple M Pro / Max / Ultra`,"amd-phoenix":`AMD Ryzen Phoenix / Hawk Point`,unknown:`Not measured`};function _i(e){return e===null?`—`:hi[e]??e}function vi(e){return e===null?`—`:gi[e]??e}function yi(e){switch(e.kind){case`capacity`:return K.t(`helpers.autoTuneViewModel.capacity`,{sessions:mi(e.sessions),min:e.minSessions});case`tie-faster`:return K.t(`helpers.autoTuneViewModel.tieFaster`,{over:e.over,recall:pi(e.recallDelta)});case`stepped-down`:return K.t(`helpers.autoTuneViewModel.steppedDown`,{from:e.from,limitedBy:e.limitedBy,to:e.to});case`no-fit-lightest`:return K.t(`helpers.autoTuneViewModel.noFitLightest`,{min:mi(e.minSessions),sessions:mi(e.sessions)});case`derived-latency`:return K.t(`helpers.autoTuneViewModel.derivedLatency`,{modelId:e.modelId});case`cpu-device`:return K.t(`helpers.autoTuneViewModel.cpuDevice`);case`device-disabled`:return K.t(`helpers.autoTuneViewModel.deviceDisabled`);case`device-unavailable`:return K.t(`helpers.autoTuneViewModel.deviceUnavailable`);case`node-offline`:return K.t(`helpers.autoTuneViewModel.nodeOffline`);case`no-hardware-facts`:return K.t(`helpers.autoTuneViewModel.noHardwareFacts`);case`no-measured-data`:return K.t(`helpers.autoTuneViewModel.noMeasuredData`);case`no-family-build`:return K.t(`helpers.autoTuneViewModel.noFamilyBuild`,{format:e.format});case`kept-custom-pin`:return K.t(`helpers.autoTuneViewModel.keptCustomPin`,{modelId:e.modelId,deviceKey:e.deviceKey})}}function bi(e,t){switch(e.kind){case`detector-store-cluster-wide`:return K.t(`helpers.autoTuneViewModel.detectorStoreClusterWide`,{nodes:e.skippedNodes.map(t).join(`, `)});case`detector-store-unreadable`:return K.t(`helpers.autoTuneViewModel.detectorStoreUnreadable`,{error:e.error});case`custom-pin-kept`:return e.deviceId===null?K.t(`helpers.autoTuneViewModel.customPinNode`,{node:t(e.nodeId),modelId:e.modelId,deviceKey:e.deviceKey??`—`}):K.t(`helpers.autoTuneViewModel.customPinCamera`,{deviceId:e.deviceId,modelId:e.modelId,node:t(e.nodeId)});case`custom-registry-unreadable`:return K.t(`helpers.autoTuneViewModel.customRegistryUnreadable`,{error:e.error})}}function xi(e){let t=e.nodeChanges.reduce((e,t)=>e+t.modelPins.length,0),n=e.nodeChanges.reduce((e,t)=>e+t.thresholds.length,0),r=new Set([...e.cameraClears.map(e=>e.deviceId),...e.detectorStoreClears.map(e=>e.deviceId)]);return{modelChanges:t,thresholdClears:n,cameraOverrideClears:e.cameraClears.length,detectorStoreClears:e.detectorStoreClears.length,camerasTouched:r.size}}function Si(e){let t=xi(e);return t.modelChanges+t.thresholdClears+t.cameraOverrideClears+t.detectorStoreClears===0}function Ci(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 wi(e,t){return e?.kind===`node-benchmark`?K.t(`helpers.autoTuneViewModel.latencyMeasured`,{date:new Date(e.measuredAtMs).toLocaleDateString(t,{day:`numeric`,month:`short`})}):K.t(`helpers.autoTuneViewModel.latencyTable`)}t();var Ti=[.3,.4,.5];function Ei(e){return Ti.some(t=>t===e)}var Di=[1,2,3,4,6,8];function Oi({plan:e,node:t,nodeName:n}){let{t:r}=q();return o(`section`,{className:b,"data-testid":`auto-tune-node-${t.nodeId}`,children:[o(`header`,{className:`${P} flex flex-wrap items-center gap-2`,children:[f(T,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${C} min-w-0 flex-1`,children:n(t.nodeId)}),o(`span`,{className:`text-[11px] text-foreground-subtle`,children:[vi(t.hardwareClass),t.cpuModel===null?``:` · ${t.cpuModel}`]}),t.skipped?f(H,{variant:`warning`,children:r(`pipeline.clusterAutoTuneTab.notChanged`,`Not changed`)}):t.acceleratorModelId!==null&&f(H,{variant:`info`,children:t.acceleratorModelId})]}),t.reasons.length>0&&f(`ul`,{className:`px-3 pt-2 text-[11px] text-foreground-muted`,children:t.reasons.map((e,t)=>f(`li`,{children:yi(e)},t))}),f(`div`,{className:`overflow-x-auto`,children:o(`table`,{className:`w-full text-xs`,children:[f(`thead`,{children:o(`tr`,{className:`text-left text-[11px] text-foreground-subtle`,children:[f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.device`,`Device`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.capacity`,`Capacity`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.detector`,`Detector`)}),f(`th`,{className:`px-3 py-1.5 font-medium`,children:r(`pipeline.clusterAutoTuneTab.why`,`Why`)})]})}),f(`tbody`,{children:t.devices.map(n=>{let i=Ci(e,t.nodeId,n.deviceKey);return o(`tr`,{className:`border-t border-border align-top`,children:[o(`td`,{className:`px-3 py-1.5`,children:[f(`div`,{className:`font-mono text-foreground`,children:n.deviceKey}),f(`div`,{className:`text-[11px] text-foreground-subtle`,children:_i(n.accelerator)})]}),o(`td`,{className:`px-3 py-1.5 text-foreground-muted`,children:[n.chosen===null?`—`:r(`pipeline.clusterAutoTuneTab.sessionsAtFps`,{count:n.chosen.capacitySessions,fps:e.cameraFps}),n.chosen!==null&&o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r(`pipeline.clusterAutoTuneTab.fpsKeptFree`,{fps:n.chosen.fps,percent:Math.round(e.headroom*100)}),f(`div`,{children:wi(n.chosen.source)})]})]}),f(`td`,{className:`px-3 py-1.5`,children:n.chosen===null?f(`span`,{className:`text-foreground-subtle`,children:r(`common.unchanged`)}):i!==null&&i.before!==i.after?o(`span`,{children:[f(`span`,{className:`text-foreground-subtle`,children:i.before??r(`common.defaultWord`)}),` → `,f(`span`,{className:`font-medium text-foreground`,children:i.after})]}):f(`span`,{className:`text-foreground`,children:n.chosen.modelId})}),f(`td`,{className:`px-3 py-1.5 text-[11px] text-foreground-muted`,children:n.reasons.map((e,t)=>f(`div`,{children:yi(e)},t))})]},n.deviceKey)})})]})})]})}function ki({plan:e,nameOf:t,nodeName:n}){let{t:r}=q();return o(`div`,{className:`flex flex-col gap-3 text-xs`,"data-testid":`auto-tune-change-list`,children:[o(`div`,{children:[f(`div`,{className:C,children:r(`pipeline.clusterAutoTuneTab.nodeSettings`,`Node settings`)}),e.nodeChanges.length===0?f(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.noChange`,`No change.`)}):f(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.nodeChanges.flatMap(e=>[...e.modelPins.map(t=>o(`li`,{children:[o(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`— `,t.stepId,`: `,t.before??r(`pipeline.clusterAutoTuneTab.defaultModel`),` →`,` `,t.after??r(`pipeline.clusterAutoTuneTab.stepDefault`,`step default`)]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/pin`)),...e.thresholds.map(t=>o(`li`,{children:[o(`span`,{className:`font-mono`,children:[n(e.nodeId),` · `,e.deviceKey]}),` `,`—`,` `,r(`pipeline.clusterAutoTuneTab.thresholdReset`,{step:t.stepId,keys:t.keys.join(`, `)})]},`${e.nodeId}/${e.deviceKey}/${t.stepId}/thr`))])})]}),o(`div`,{children:[f(`div`,{className:C,children:r(`pipeline.clusterAutoTuneTab.cameraOverridesCleared`,`Camera overrides cleared`)}),e.cameraClears.length===0&&e.detectorStoreClears.length===0?f(`div`,{className:`text-foreground-subtle`,children:r(`pipeline.clusterAutoTuneTab.none`,`None.`)}):o(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:[e.cameraClears.map((e,i)=>o(`li`,{children:[t(e.deviceId),` — `,n(e.nodeId),e.deviceKey===null?` (${r(`pipeline.clusterAutoTuneTab.wholePipeline`)})`:` · ${e.deviceKey}`,` `,`— `,e.stepId,e.modelIdBefore===null?``:r(`pipeline.clusterAutoTuneTab.modelRemoved`,`: model {{modelIdBefore}} removed`,{modelIdBefore:e.modelIdBefore}),e.keys.length>0?r(`pipeline.clusterAutoTuneTab.reset`,`; {{value1}} reset`,{value1:e.keys.join(`, `)}):``]},`c${i}`)),e.detectorStoreClears.map(e=>o(`li`,{children:[t(e.deviceId),` —`,` `,r(`pipeline.clusterAutoTuneTab.detectorThresholdsReset`,{keys:e.keys.join(`, `)})]},`d${e.deviceId}`))]})]})]})}function Ai({result:e}){let{t}=q();return e.kind===`refused`?f(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.anotherApplyIsAlreadyRunning`,`Another apply is already running.`)}):e.kind===`stale`?f(`div`,{className:`text-xs text-warning`,children:t(`pipeline.clusterAutoTuneTab.theConfigurationChangedSinceThe`,`The configuration changed since the plan was shown. Review the updated plan below and apply again.`)}):o(`ul`,{className:`text-xs`,"data-testid":`auto-tune-result`,children:[e.kind===`aborted`&&f(`li`,{className:`text-danger`,children:t(`pipeline.clusterAutoTuneTab.aModelCouldNotBe`,`A model could not be downloaded: nothing was changed.`)}),e.phases.map(e=>o(`li`,{className:e.ok?`text-foreground-muted`:`text-danger`,children:[e.ok?`✓`:`✗`,` `,e.phase,`: `,e.detail]},e.phase))]})}function ji(){let{t:e}=q(),t=l(),[n,a]=i(.4),[s,c]=i(2),[u,d]=i(!1),[p,m]=i(!1),[h,g]=i(null),{data:_}=hn(),v=r(()=>new Map((_??[]).map(e=>[e.id,e.name])),[_]),y=t=>v.get(t)??e(`pipeline.clusterAutoTuneTab.cameraFallback`,{id:t}),{nodes:x}=V(),S=r(()=>$n(x),[x]),w=un({headroom:n,minSessionsPerDevice:s},{enabled:u,refetchOnWindowFocus:!1}),T=rn({onSuccess:e=>{g(e),m(!1),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),e.kind===`applied`&&w.refetch()}}),D=h?.kind===`stale`?h.plan:w.data,O=D===void 0?null:xi(D);return o(`div`,{className:`flex flex-col gap-3`,"data-testid":`cluster-auto-tune`,children:[o(`section`,{className:b,children:[o(`header`,{className:`${P} flex flex-wrap items-center gap-2`,children:[f(E,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),f(`h3`,{className:`${C} min-w-0 flex-1`,children:e(`pipeline.clusterAutoTuneTab.autoTune`,`Auto tune`)})]}),o(`div`,{className:`flex flex-col gap-2 px-3 py-2 text-xs text-foreground-muted`,children:[f(`p`,{children:e(`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 and clears every model and threshold override — node level and per camera — so each model runs its own default thresholds. Enabled steps, devices, pins, recording, notifications, zones and rules are not touched. There is no undo.`)}),o(`div`,{className:`flex flex-wrap items-center gap-2`,children:[o(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.keepFree`,`Keep free`)}),f(U,{"aria-label":e(`pipeline.clusterAutoTuneTab.shareOfEachAcceleratorKept`,`Share of each accelerator kept free`),value:String(n),options:Ti.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.ofEachAccelerator`,`{{value1}}% of each accelerator`,{value1:Math.round(t*100)})})),onChange:e=>{let t=Number(e.target.value);Ei(t)&&a(t)}})]}),o(`label`,{className:`flex items-center gap-1.5`,children:[f(`span`,{className:`whitespace-nowrap`,children:e(`pipeline.clusterAutoTuneTab.atLeast`,`At least`)}),f(U,{"aria-label":e(`pipeline.clusterAutoTuneTab.minimumParallelSessionsPerDevice`,`Minimum parallel sessions per device`),value:String(s),options:Di.map(t=>({value:String(t),label:e(`pipeline.clusterAutoTuneTab.camerasAtOnce`,{count:t})})),onChange:e=>{let t=Number(e.target.value);Di.some(e=>e===t)&&c(t)}})]}),f(W,{size:`sm`,variant:`secondary`,onClick:()=>{g(null),d(!0),u&&w.refetch()},children:w.isFetching?e(`pipeline.clusterAutoTuneTab.computing`,`Computing…`):D===void 0?e(`pipeline.clusterAutoTuneTab.computePlan`,`Compute plan`):e(`pipeline.clusterAutoTuneTab.recompute`,`Recompute`)}),D!==void 0&&f(W,{size:`sm`,disabled:Si(D),onClick:()=>m(!0),children:e(`pipeline.clusterAutoTuneTab.apply`,`Apply…`)})]}),w.error!==null&&f(`div`,{className:`text-danger`,children:w.error.message}),h!==null&&f(Ai,{result:h}),O!==null&&f(`div`,{className:`text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterAutoTuneTab.planSummary`,{modelChanges:O.modelChanges,thresholdClears:O.thresholdClears,overrides:O.cameraOverrideClears+O.detectorStoreClears,cameras:O.camerasTouched})})]})]}),D?.warnings.map((e,t)=>f(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:bi(e,S)},t)),D?.nodes.map(e=>f(Oi,{plan:D,node:e,nodeName:S},e.nodeId)),D!==void 0&&f(st,{open:p,onOpenChange:m,children:o(Ft,{width:`lg`,scroll:`body`,children:[o(an,{children:[f(Ht,{children:e(`pipeline.clusterAutoTuneTab.applyAutoTune`,`Apply auto tune?`)}),f(ln,{children:e(`pipeline.clusterAutoTuneTab.theseAreAllTheChanges`,`These are all the changes. Every override listed is removed and cannot be restored.`)})]}),f(Ie,{children:f(ki,{plan:D,nameOf:y,nodeName:S})}),o(Yt,{children:[f(W,{variant:`ghost`,onClick:()=>m(!1),children:e(`common.cancel`,`Cancel`)}),f(W,{variant:`danger`,disabled:T.isPending,onClick:()=>T.mutate({planHash:D.planHash,headroom:n,minSessionsPerDevice:s}),children:T.isPending?e(`pipeline.clusterAutoTuneTab.applying`,`Applying…`):e(`common.apply`,`Apply`)})]})]})})]})}var Mi={disabled:`pipeline.nodeLoadOverview.exclusion.disabled`,unavailable:`pipeline.nodeLoadOverview.exclusion.unavailable`,"cannot-host-camera-root":`pipeline.nodeLoadOverview.exclusion.cannotHostCameraRoot`,"accelerator-preferred":`pipeline.nodeLoadOverview.exclusion.acceleratorPreferred`};function Ni(e,t){return t<=0?0:Math.round(e/t*1e3)/10}function Pi(e){return e===void 0?!1:e.load.devices.reduce((e,t)=>e+t.attachedCameras,0)>=e.load.attachedCameras}function Fi(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:_t(e),format:e.format,sessions:i,weight:a,weightSharePct:e.exclusion===null?Ni(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 Ii(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=Fi(e.devicesByNode[r.id]??[],new Map((i?.load.devices??[]).map(e=>[e.deviceKey,e.attachedCameras])),Pi(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?Ni(c,r.maxCameras):null,queueDepthTotal:i?.load.queueDepthTotal??null,avgInferenceTimeMs:i?.load.avgInferenceTimeMs??null,score:i?.score??null,weight:s,weightSharePct:o?Ni(s,n):null,decodeHwaccel:i?.decodeHwaccel??null,devices:a,eligibleDeviceCount:a.filter(e=>e.exclusion===null).length}})}t();var Li=2e4,Ri=3e5;function zi({stats:e,targetWeights:t}){let{t:n}=q(),{nodes:i}=V(),a=te().trpcClient,o=Xt(void 0,{placeholderData:u,staleTime:Li,refetchInterval:Li,refetchOnWindowFocus:!0}),s=He(void 0,{staleTime:Ri}),l=r(()=>i.map(e=>e.id),[i]),d=c({queries:l.map(e=>({queryKey:Fe(bt.pipelineOrchestrator.getNodeInferenceDevices,{nodeId:e},`query`),queryFn:()=>a.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:e}),staleTime:Ri,refetchOnWindowFocus:!1,placeholderData:u}))}),p=r(()=>{let e={};return l.forEach((t,n)=>{let r=d[n]?.data;r&&(e[t]=r.devices)}),e},[l,d.map(e=>e.dataUpdatedAt).join(`|`)]),h=r(()=>{let e=new Map;for(let t of s.data??[])e.set(t.nodeId,t.settings);return e},[s.data]),g=r(()=>i.map(e=>{let n=h.get(e.id);return{id:e.id,name:e.name,isOnline:e.isOnline,detectEnabled:Vn(n,e.isHub).pipeline,weight:t?.[e.id]??Sn(n,`detectWeight`)??1,maxCameras:Sn(n,`maxCameras`)}}),[i,h,t]),_=o.data??[],v=r(()=>Ii({nodes:g,loads:_,devicesByNode:p}),[g,_,p]),y=v.reduce((e,t)=>e+(t.attachedCameras??0),0),b=v.reduce((e,t)=>e+(t.activeCameras??0),0),x=o.dataUpdatedAt>0?Date.now()-o.dataUpdatedAt:null,S=new Map((e?.nodes??[]).map(e=>[e.nodeId,e]));return f(G,{headingId:`load-balancing-node-load`,title:n(`pipeline.nodeLoadOverview.nodeLoad`,`Node load`),icon:re,actions:f(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:n(`pipeline.nodeLoadOverview.summaryLine`,{active:b,attached:y,reading:o.data===void 0?n(`pipeline.nodeLoadOverview.reading`,`reading…`):n(`pipeline.nodeLoadOverview.readingAge`,{age:x===null?`—`:`${Math.round(x/1e3)}s`})})}),children:f(`div`,{className:m,children:v.length===0?f(`p`,{className:`text-[11px] italic text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.noClusterNodesReportedYet`,`No cluster nodes reported yet.`)}):f(`div`,{className:`grid gap-2 @2xl/clustertab:grid-cols-2 @5xl/clustertab:grid-cols-3`,children:v.map(e=>f(Bi,{row:e,placed:S.get(e.nodeId)},e.nodeId))})})})}function Bi({row:e,placed:t}){let{t:n}=q(),r=e.attachedCameras===null?`—`:`${e.activeCameras??0} / ${e.attachedCameras}${e.maxCameras===null?``:` of ${e.maxCameras}`}`;return o(`div`,{className:`rounded-lg border border-border bg-surface/60 p-2.5 min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[f(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${e.isOnline?`bg-emerald-400`:`bg-foreground-subtle/40`}`}),f(`span`,{className:`truncate text-xs font-medium text-foreground`,title:e.nodeId,children:e.name}),!e.detectEnabled&&f(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:n(`pipeline.nodeLoadOverview.noDetect`,`no detect`)}),!e.reported&&e.isOnline&&o(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-amber-400`,title:n(`pipeline.nodeLoadOverview.onlineButItDidNot`,`Online, but it did not answer the last load read — its numbers below are unknown, not zero.`),children:[f(y,{className:`h-2.5 w-2.5`}),` `,n(`pipeline.nodeLoadOverview.noReading`)]}),!e.isOnline&&o(`span`,{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[9px] text-foreground-subtle`,children:[f(D,{className:`h-2.5 w-2.5`}),` `,n(`common.offline`)]})]}),o(`dl`,{className:`mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px]`,children:[f(Y,{label:n(`pipeline.nodeLoadOverview.runningAttached`,`Running / attached`),value:r,title:n(`pipeline.nodeLoadOverview.sessionsInInferenceNowCameras`,`Sessions in inference now / cameras attached to this runner (the balancer's committed load) / operator cap.`)}),f(Y,{label:n(`pipeline.nodeLoadOverview.targetShare`,`Target share`),value:e.weightSharePct===null?`out of play`:`${e.weightSharePct}%`,title:n(`pipeline.nodeLoadOverview.theNodeShareAutomaticOr`,`The node share (automatic or manual) normalised over the nodes the balancer actually ranks (online AND detect-enabled).`)}),f(Y,{label:n(`pipeline.nodeLoadOverview.actualShare1H`,`Actual share (1 h)`),value:t?.observedShare===null||t===void 0?`—`:`${Math.round(t.observedShare*100)}%`,title:n(`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.`)}),f(Y,{label:n(`pipeline.nodeLoadOverview.peakYields`,`Peak · yields`),value:t===void 0?`—`:`${t.peakSessions} · ${t.yieldsAway}`,title:n(`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.`)}),f(Y,{label:n(`pipeline.nodeLoadOverview.scoreQueue`,`Score · queue`),value:e.score===null?`—`:`${e.score} · ${e.queueDepthTotal??0}`,title:n(`pipeline.nodeLoadOverview.theCapacityScoreBalanceMinimises`,`The capacity score balance() minimises (attached + queue depth), and the raw queue depth.`)}),e.capacityPct!==null&&f(Y,{label:n(`pipeline.nodeLoadOverview.capFill`,`Cap fill`),value:`${e.capacityPct}%`,title:n(`pipeline.nodeLoadOverview.attachedMaxcameras`,`attached / maxCameras.`)}),e.avgInferenceTimeMs!==null&&f(Y,{label:n(`pipeline.nodeLoadOverview.avgInfer`,`Avg infer`),value:`${Math.round(e.avgInferenceTimeMs)} ms`,title:n(`pipeline.nodeLoadOverview.meanInferenceTimeAcrossThis`,`Mean inference time across this node's attached cameras.`)}),e.decodeHwaccel!==null&&f(Y,{label:n(`pipeline.nodeLoadOverview.decode`,`Decode`),value:e.decodeHwaccel,title:n(`pipeline.nodeLoadOverview.thisNodeSProbedDecode`,`This node's probed decode hwaccel.`)})]}),f(Vi,{row:e})]})}function Vi({row:e}){let{t}=q();return e.devices.length===0?f(`p`,{className:`mt-2 text-[10px] italic text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.acceleratorsNotReadYet`,`Accelerators not read yet.`)}):o(`div`,{className:`mt-2 border-t border-border pt-1.5`,children:[o(`div`,{className:`flex items-center gap-1 text-[9px] uppercase tracking-wider text-foreground-subtle`,children:[f(x,{className:`h-2.5 w-2.5`}),t(`pipeline.nodeLoadOverview.accelerators`,`Accelerators`),e.eligibleDeviceCount===0&&f(`span`,{className:`ml-1 normal-case tracking-normal text-amber-400`,title:t(`pipeline.nodeLoadOverview.noDeviceIsACamera`,`No device is a camera-root candidate on this node — sessions run on the runner's default (CPU) pool.`),children:t(`pipeline.nodeLoadOverview.noneInPlayRunnerDefault`,`none in play · runner default pool`)})]}),f(`ul`,{className:`mt-1 space-y-0.5`,children:e.devices.map(e=>f(Hi,{device:e},e.key))})]})}function Hi({device:e}){let{t}=q(),n=e.exclusion;return o(`li`,{className:`flex items-baseline gap-1.5 text-[10px] min-w-0`,children:[f(T,{className:`h-2.5 w-2.5 shrink-0 ${n===null?`text-foreground-subtle`:`text-foreground-subtle/50`}`}),f(`span`,{className:`shrink-0 font-medium ${n===null?`text-foreground`:`text-foreground-subtle`}`,title:`${e.key} · ${e.format}`,children:e.label}),n===null?o(s,{children:[f(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,children:t(`pipeline.nodeLoadOverview.sharePct`,{pct:e.weightSharePct})}),o(`span`,{className:`shrink-0 tabular-nums text-foreground-subtle`,title:e.sessions===null?t(`pipeline.nodeLoadOverview.notKnownTheNodeDid`,`Not known: the node did not report, or runs a session no device accounts for.`):void 0,children:[`· `,t(`common.sessionsCount`,{count:e.sessions??0}),e.maxSessions===null?``:`/${e.maxSessions}`]}),e.atCap&&f(`span`,{className:`shrink-0 text-amber-400`,title:t(`pipeline.nodeLoadOverview.atItsMaxsessionsCapThe`,`At its maxSessions cap — the balancer skips it until a session ends.`),children:t(`pipeline.nodeLoadOverview.atCap`,`· at cap`)})]}):f(`span`,{className:`truncate text-foreground-subtle/80`,title:t(Mi[n]),children:t(`pipeline.nodeLoadOverview.excludedWith`,{reason:t(Mi[n])})})]})}function Y({label:e,value:t,title:n}){return o(`div`,{className:`min-w-0`,title:n,children:[f(`dt`,{className:`text-[9px] uppercase tracking-wide text-foreground-subtle`,children:e}),f(`dd`,{className:`truncate font-medium tabular-nums text-foreground`,children:t})]})}function Ui(e){return{nodes:Object.fromEntries(e.map(e=>[e.nodeId,Math.max(1,e.weight)])),devices:{}}}function Wi(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 Gi(e){return Object.fromEntries(e.nodes.map(e=>[e.nodeId,Object.fromEntries(e.devices.map(e=>[e.deviceKey,e.suggestedMaxSessions]))]))}function Ki(e){return e.reason===`disabled`?K.t(`helpers.loadBalancingViewModel.stalePinDisabled`,{deviceKey:e.deviceKey}):K.t(`helpers.loadBalancingViewModel.stalePinMissing`,{deviceKey:e.deviceKey})}function qi(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 Ji(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 K.t(`helpers.loadBalancingViewModel.shareNote`,{count:n.length,names:i,into:r})}var Yi=[{value:`hardware`,get label(){return K.t(`helpers.loadBalancingViewModel.hardwareLabel`)},get hint(){return K.t(`helpers.loadBalancingViewModel.hardwareHint`)}},{value:`benchmark`,get label(){return K.t(`helpers.loadBalancingViewModel.benchmarkLabel`)},get hint(){return K.t(`helpers.loadBalancingViewModel.benchmarkHint`)}},{value:`manual`,get label(){return K.t(`helpers.loadBalancingViewModel.manualLabel`)},get hint(){return K.t(`helpers.loadBalancingViewModel.manualHint`)}}];function Xi(e){return e===`no-benchmark-results`?K.t(`helpers.loadBalancingViewModel.fallbackNone`):e===`partial-benchmark-results`?K.t(`helpers.loadBalancingViewModel.fallbackPartial`):null}function Zi(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)}: ${Xi(e.capacityFallback)??``}`).join(` · `)}t();function Qi(e,t,n){return Math.min(Math.max(e,t),n)}function $i(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 ea(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:Qi(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 ta(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 na({nodes:e,pending:t,onCommitWeights:r,weightLabel:a=`Detection weight`,emptyHint:c,footnote:l,readOnly:u=!1}){let{t:d}=q(),[p,m]=i(()=>$i(e)),[h,g]=i(new Set);n(()=>{m($i(e)),g(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let _=e.map(e=>e.id),v=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=(e,t)=>{m(n=>ea(n,e,t,h,_))},b=()=>{let t=ta(p,_,h),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...h]);r(e.filter(e=>i.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:c??d(`placementBoard.weightSliderStack.noDetectEnabledNodesEnable`,`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`)});let x=e.length===1;return o(`div`,{className:`space-y-3`,children:[e.map(e=>{let n=p[e.id]??0,r=h.has(e.id);return o(`div`,{className:`flex items-center gap-3`,children:[f(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),f(`input`,{"aria-label":d(`placementBoard.weightSliderStack.for`,`{{weightLabel}} for {{name}}`,{weightLabel:a,name:e.name}),type:`range`,min:0,max:100,step:1,value:Math.round(n),disabled:u||t||r||x,onChange:t=>y(e.id,Number(t.target.value)),onPointerUp:()=>b(),onKeyUp:()=>b(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),o(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(n),`%`]}),!u&&f(`button`,{type:`button`,onClick:()=>v(e.id),disabled:t||x,"aria-pressed":r,title:r?d(`placementBoard.weightSliderStack.unlockAllowRebalancing`,`Unlock — allow rebalancing`):d(`placementBoard.weightSliderStack.lockThisShareWhenOthers`,`Lock this share when others change`),className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${r?`text-amber-400`:`text-foreground-subtle`}`,children:f(r?ne:M,{className:`h-3.5 w-3.5`})})]},e.id)}),f(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:l??f(s,{children:d(`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 ra(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}t();function ia(e){let t=_t(e),n=e.backend.toLowerCase(),r=e.device.toLowerCase();return e.key===`cpu`||r===`cpu`?{label:t,Icon:T,hue:`slate`}:r===`npu`?{label:t,Icon:z,hue:`sky`}:r===`gpu`||r===`igpu`?{label:t,Icon:Oe,hue:`violet`}:n===`edgetpu`?{label:t,Icon:Me,hue:`emerald`}:{label:t,Icon:T,hue:`slate`}}var aa={sky:`bg-sky-500/12 text-sky-400 ring-sky-500/25`,violet:`bg-violet-500/12 text-violet-400 ring-violet-500/25`,emerald:`bg-emerald-500/12 text-emerald-400 ring-emerald-500/25`,slate:`bg-surface-hover text-foreground-subtle ring-border`};function oa({nodeId:e,nodeName:t,isOnline:a,suggestedMaxSessions:c,autoDeviceShares:u}){let{t:d}=q(),p=l(),{data:m,isLoading:h}=Dt({nodeId:e},{refetchInterval:15e3}),g=Le({onSettled:()=>{p.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),_=m?.devices??[],v=m?.reachable??a,[y,b]=i({});n(()=>{b(Object.fromEntries(_.map(e=>[e.key,{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}])))},[_.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let x=r(()=>_.filter(e=>y[e.key]?.enabled??e.enabled).length,[_,y]),[S,C]=i(null),w=S??x>0,T=t=>{let n=_.map(e=>{let n=t[e.key]??E(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});g.mutate({agentNodeId:e,inferenceDevices:jr(n)})},E=e=>({enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}),O=e=>{if(!e.available)return;let t=y[e.key]??E(e),n={...y,[e.key]:{...t,enabled:!t.enabled}};b(n),T(n)},k=(e,t)=>{let n=y[e.key]??E(e),r={...y,[e.key]:{...n,maxSessions:t}};b(r),T(r)},A=r(()=>_.filter(e=>(y[e.key]?.enabled??e.enabled)&&e.available),[_,y]),j=r(()=>A.map(e=>({id:e.key,name:ia(e).label,weight:u===void 0?y[e.key]?.weight??e.weight:Math.round(u[e.key]??0)})),[A,y,u]);return o(`div`,{className:`rounded-lg border border-border bg-surface/60`,children:[o(`button`,{type:`button`,onClick:()=>C(!w),className:`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left`,"aria-expanded":w,children:[f(ce,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${w?`rotate-90`:``}`}),f(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t}),f(`span`,{className:`ml-auto flex items-center gap-2 text-[11px]`,children:v?x>=2?o(`span`,{className:`inline-flex items-center gap-1 text-emerald-400`,children:[f(Pe,{className:`h-3.5 w-3.5`}),d(`pipeline.nodeInferenceDevices.accelerators`,{count:x})]}):x===1?f(`span`,{className:`text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.singleDefault`,`single default`)}):f(`span`,{className:`text-foreground-subtle/70`,children:d(`placementBoard.nodeInferenceDevices.autoDefault`,`auto default`)}):o(`span`,{className:`inline-flex items-center gap-1 text-foreground-subtle`,children:[f(D,{className:`h-3.5 w-3.5`}),` `,d(`common.unreachable`)]})})]}),w&&o(`div`,{className:`space-y-3 border-t border-border px-3.5 py-3`,children:[v?h&&_.length===0?f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.probingAccelerators`,`Probing accelerators…`)}):_.length===0?f(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:d(`placementBoard.nodeInferenceDevices.noInferenceDevicesReportedBy`,`No inference devices reported by this node's platform probe.`)}):f(`ul`,{className:`space-y-2`,children:_.map(e=>{let t=ia(e),n=y[e.key]??E(e),r=n.enabled&&e.available,i=ra({defaultModelId:e.defaultModelId,steps:n.steps});return o(`li`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ${e.available?r?`border-primary/40 bg-primary/[0.04] ring-1 ring-inset ring-primary/20`:`border-border bg-surface`:`border-border/60 bg-background opacity-55`}`,children:[f(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-md ring-1 ring-inset ${aa[t.hue]}`,children:f(t.Icon,{className:`h-4.5 w-4.5`})}),o(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.label}),f(H,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&f(H,{variant:`warning`,className:`text-[9px]`,children:d(`common.unavailable`)})]}),o(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[f(`span`,{className:`font-mono`,children:e.key}),i!==null&&o(s,{children:[f(`span`,{"aria-hidden":!0,children:`·`}),f(`span`,{children:f(_n,{i18nKey:`pipeline.nodeInferenceDevices.rootModel`,values:{model:i},components:{mono:f(`span`,{className:`font-mono text-foreground/80`})}})})]})]})]}),r&&o(`label`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-foreground-subtle`,children:[f(`span`,{className:`hidden @sm/clustertab:inline`,children:d(`pipeline.nodeInferenceDevices.cap`)}),f(`input`,{type:`number`,min:1,placeholder:`∞`,value:n.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);k(e,r!=null&&r>0?r:null)},disabled:g.isPending,"aria-label":d(`placementBoard.nodeInferenceDevices.maxConcurrentSessionsFor`,`Max concurrent sessions for {{label}}`,{label:t.label}),className:`w-14 rounded border border-border bg-background px-1.5 py-1 text-right font-mono text-[11px] text-foreground focus:border-primary focus:outline-none`})]}),r&&f(sa,{suggested:c?.[e.key]??null,current:n.maxSessions,pending:g.isPending,onApply:t=>k(e,t)}),f(Wt,{checked:r,onCheckedChange:()=>O(e),disabled:!e.available||g.isPending,"aria-label":d(`placementBoard.nodeInferenceDevices.enable`,`Enable {{label}}`,{label:t.label}),className:e.available?``:`cursor-not-allowed opacity-50`})]},e.key)})}):f(ca,{}),v&&A.length>=2&&o(`div`,{className:`space-y-3 rounded-lg border border-border bg-background/60 p-3.5`,children:[o(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[f(Ae,{className:`h-3.5 w-3.5`}),d(`placementBoard.nodeInferenceDevices.acceleratorShare`,`Accelerator share`)]}),f(na,{nodes:j,pending:g.isPending,onCommitWeights:e=>{let t={...y};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}b(t),T(t)},weightLabel:`Accelerator share`,readOnly:u!==void 0,footnote:u===void 0?f(s,{children:d(`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%.`)}):f(s,{children:d(`placementBoard.nodeInferenceDevices.automaticEachAcceleratorSShare`,`Automatic: each accelerator's share follows its measured throughput at its model. Switch the node shares to manual to set them yourself.`)})})]}),g.isError&&o(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] text-danger`,children:[d(`placementBoard.nodeInferenceDevices.failedToSaveInferenceDevices`,`Failed to save inference devices:`),` `,g.error instanceof Error?g.error.message:d(`placementBoard.nodeInferenceDevices.unknownError`,`unknown error`)]})]})]})}function sa({suggested:e,current:t,pending:n,onApply:r}){let{t:i}=q();return e===null||e<1||e===t?null:f(W,{variant:`ghost`,size:`sm`,onClick:()=>r(e),disabled:n,title:i(`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:i(`pipeline.nodeInferenceDevices.use`,{value:e})})}function ca(){let{t:e}=q();return o(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-background px-4 py-8 text-center`,children:[f(D,{className:`h-6 w-6 text-foreground-subtle/60`}),f(`p`,{className:`text-xs font-medium text-foreground`,children:e(`placementBoard.nodeInferenceDevices.nodeUnreachable`,`Node unreachable`)}),f(`p`,{className:`max-w-sm text-[11px] text-foreground-subtle`,children:e(`placementBoard.nodeInferenceDevices.thePlatformProbeCouldnT`,`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`)})]})}t();var la=3600*1e3,ua=2e4,da=.4;function fa({refreshToken:e,onOpenAutoTune:t}){let{t:n}=q(),a=l(),{nodes:c}=V(),d=He(void 0),p=St({isCamera:!0,projection:`slim`}),h=dn({windowMs:la},{refetchInterval:ua,placeholderData:u}).data,g=Rt(void 0,{refetchInterval:ua,placeholderData:u}).data,_=()=>{En(a),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})},v=Be({onSuccess:_}),y=qe({onSuccess:()=>{_(),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getEffectiveShares`]]})}}),b=Ut({onSuccess:_}),x=ft(),[C,w]=i(!1),D=g?.source,O=D===`benchmark`?`benchmark`:`hardware`,k=pt({headroom:da,source:O},{enabled:C,staleTime:1/0}),A=k.data,j=r(()=>{let e=new Map((d.data??[]).map(e=>[e.nodeId,e.settings]));return c.filter(t=>Vn(e.get(t.id),t.isHub).pipeline).map(t=>{let n=e.get(t.id);return{id:t.id,name:t.name,isOnline:t.isOnline,weight:Sn(n,`detectWeight`)??1,maxCameras:Sn(n,`maxCameras`)}})},[c,d.data]),ee=e=>c.find(t=>t.id===e)?.name??e,M=er((p.data??[]).map(e=>({id:e.id,name:e.name}))),N=A?Gi(A):void 0,P=qi(j,g),F=D!==`manual`,I=e=>{if(g===void 0||g.source===`manual`||g.autoPending)return;let t=g.nodes.find(t=>t.nodeId===e);return t===void 0?void 0:Object.fromEntries(t.devices.map(e=>[e.deviceKey,e.configuredPct]))},te=g?Ji(g,ee):null,ne=g?Zi(g,ee):null,L=Yi.find(e=>e.value===D)?.hint;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[f(Kn,{refreshToken:e}),f(zi,{stats:h,...g!==void 0&&g.source!==`manual`&&!g.autoPending?{targetWeights:Object.fromEntries(g.nodes.map(e=>[e.nodeId,e.configuredPct]))}:{}}),f(G,{headingId:`load-balancing-node-shares`,title:n(`pipeline.clusterLoadBalancingTab.nodeShares`,`Node shares`),icon:Ae,actions:o(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[f(`div`,{role:`radiogroup`,"aria-label":n(`pipeline.clusterLoadBalancingTab.shareSource`,`Share source`),className:`flex items-center gap-1`,children:Yi.map(e=>f(W,{role:`radio`,"aria-checked":D===e.value,variant:D===e.value?`primary`:`outline`,size:`sm`,title:e.hint,disabled:y.isPending||g===void 0,onClick:()=>{D!==e.value&&y.mutate({source:e.value})},children:e.label},e.value))}),o(W,{variant:`outline`,size:`sm`,onClick:()=>{w(!0),C&&k.refetch()},disabled:k.isFetching,children:[f(R,{className:`h-3.5 w-3.5`}),k.isFetching?n(`pipeline.clusterLoadBalancingTab.suggesting`,`Suggesting…`):O===`benchmark`?n(`pipeline.clusterLoadBalancingTab.suggestFromBenchmark`,`Suggest from benchmark`):n(`pipeline.clusterLoadBalancingTab.suggestFromHardware`,`Suggest from hardware`)]}),o(W,{variant:`ghost`,size:`sm`,onClick:t,children:[f(E,{className:`h-3.5 w-3.5`}),n(`pipeline.clusterLoadBalancingTab.autoTune`,`Auto tune`)]}),o(W,{variant:`outline`,size:`sm`,onClick:()=>x.mutate(void 0),disabled:x.isPending,title:n(`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:[f(z,{className:`h-3.5 w-3.5`}),x.isPending?n(`pipeline.clusterLoadBalancingTab.rebalancing`,`Rebalancing…`):n(`pipeline.clusterLoadBalancingTab.rebalance`,`Rebalance`)]})]}),children:o(`div`,{className:`${m} space-y-3`,children:[L!==void 0&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:L}),h&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:[n(`pipeline.clusterLoadBalancingTab.policy`,`Policy:`),` `,f(H,{variant:h.policy===`share`?`info`:`default`,children:h.policy===`share`?n(`pipeline.clusterLoadBalancingTab.honourShares`,`honour shares`):`least-loaded`}),` `,` · ${n(`pipeline.clusterLoadBalancingTab.clusterPeak`,{count:h.clusterPeakSessions})}`,h.policy===`least-loaded`&&` · ${n(`pipeline.clusterLoadBalancingTab.leastLoadedNote`)}`]}),f(na,{nodes:P.nodes,pending:v.isPending,readOnly:P.readOnly,onCommitWeights:e=>v.mutate(Ui(e)),weightLabel:`Node share`,...P.readOnly?{footnote:g?.autoPending?f(s,{children:n(`pipeline.clusterLoadBalancingTab.automaticSharesAreBeingComputed`,`Automatic shares are being computed from the cluster's measured capacity; the stored values are used meanwhile.`)}):o(s,{children:[D===`benchmark`?n(`pipeline.clusterLoadBalancingTab.benchmarkEachNodeSShare`,`Benchmark: each node's share follows its measured capacity from node benchmark results (hardware capacity where it has none)`):n(`pipeline.clusterLoadBalancingTab.hardwareEachNodeSShare`,`Hardware: each node's share follows its capacity at its Auto tune model, from the measured speed of its hardware`),n(`pipeline.clusterLoadBalancingTab.recomputedWheneverANodeOr`,`, recomputed whenever a node or accelerator is added, removed, switched on or off, or changes model`),g?.computedAt!=null&&f(`span`,{className:`ml-1`,children:n(g.trigger===null?`pipeline.clusterLoadBalancingTab.lastAt`:`pipeline.clusterLoadBalancingTab.lastAtTrigger`,{time:new Date(g.computedAt).toLocaleTimeString(),trigger:g.trigger??``})}),`.`]})}:{}}),te!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,children:te}),ne!==null&&f(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`benchmark-fallback-note`,children:ne}),y.isError&&f(Lt,{message:n(`pipeline.clusterLoadBalancingTab.switchFailed`,{message:y.error instanceof Error?y.error.message:n(`common.unknownError`)})}),v.isError&&f(Lt,{message:n(`pipeline.clusterLoadBalancingTab.saveFailed`,{message:v.error instanceof Error?v.error.message:n(`common.unknownError`)})}),o(`details`,{className:`rounded-md border border-border`,children:[f(`summary`,{className:`${S} cursor-pointer text-xs text-foreground`,children:n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsAdvanced`,`Max concurrent sessions (advanced)`)}),f(`ul`,{className:`divide-y divide-border border-t border-border`,children:j.map(e=>o(`li`,{className:`${S} flex items-center gap-2`,children:[f(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:e.name}),f(ze,{type:`number`,min:1,placeholder:`∞`,defaultValue:e.maxCameras??``,"aria-label":n(`pipeline.clusterLoadBalancingTab.maxConcurrentSessionsFor`,`Max concurrent sessions for {{name}}`,{name:e.name}),className:`w-20 text-right`,disabled:b.isPending,onBlur:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10),i=r!==null&&r>0?r:null;i!==e.maxCameras&&b.mutate({agentNodeId:e.id,maxCameras:i})}})]},e.id))}),f(`p`,{className:`${S} ${B} border-t border-border`,children:n(`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.`)})]})]})}),k.isError&&f(Lt,{message:n(`pipeline.clusterLoadBalancingTab.suggestionFailed`,{message:k.error instanceof Error?k.error.message:n(`common.unknownError`)})}),A&&f(pa,{suggestion:A,nameOf:ee,pending:v.isPending,...F?{}:{onApply:()=>v.mutate(Wi(A))}}),f(G,{headingId:`load-balancing-accelerators`,title:n(`pipeline.clusterLoadBalancingTab.accelerators`,`Accelerators`),icon:T,children:f(`div`,{className:`${m} space-y-2`,children:j.length===0?f(Zt,{title:n(`pipeline.clusterLoadBalancingTab.noDetectCapableNodes`,`No detect-capable nodes`),description:n(`pipeline.clusterLoadBalancingTab.enableDetectionOnANode`,`Enable detection on a node in Roles & nodes to configure its accelerators.`)}):j.map(e=>f(oa,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline,...N?.[e.id]===void 0?{}:{suggestedMaxSessions:N[e.id]},...I(e.id)===void 0?{}:{autoDeviceShares:I(e.id)}},e.id))})}),h!==void 0&&h.stalePins.length>0&&f(ma,{stats:h,cameraName:M})]})}function pa({suggestion:e,nameOf:t,pending:n,onApply:r}){let{t:i}=q();return o(G,{headingId:`load-balancing-suggestion`,title:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.suggestedFromBenchmark`,`Suggested from benchmark`):i(`pipeline.clusterLoadBalancingTab.suggestedFromHardware`,`Suggested from hardware`),icon:R,...r===void 0?{}:{actions:f(W,{size:`sm`,onClick:r,disabled:n,children:i(`pipeline.clusterLoadBalancingTab.applySuggestedShares`,`Apply suggested shares`)})},children:[f(`ul`,{className:`divide-y divide-border`,children:e.nodes.map(e=>o(`li`,{className:`${S} space-y-0.5`,children:[o(`div`,{className:`flex items-baseline gap-2 text-xs`,children:[f(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(e.nodeId)}),f(`span`,{className:`tabular-nums text-foreground`,children:e.share===null?i(`common.skipped`):`${e.share}%`})]}),o(`p`,{className:B,children:[Xi(e.capacityFallback)===null?``:`${Xi(e.capacityFallback)} · `,e.skippedReason===null?i(`pipeline.clusterLoadBalancingTab.parallelSessions`,`≈ {{capacitySessions}} parallel sessions · {{value2}}`,{capacitySessions:e.capacitySessions,value2:e.devices.map(e=>`${e.deviceKey} ${e.share}% (${e.modelId??`—`}${e.measured?``:`, estimated`}, cap ${e.suggestedMaxSessions??`—`})`).join(` · `)}):i(`pipeline.clusterLoadBalancingTab.notPartOfTheSuggestion`,`not part of the suggestion — {{skippedReason}}`,{skippedReason:e.skippedReason})]})]},e.nodeId))}),o(`p`,{className:`${S} ${B} border-t border-border`,children:[i(`pipeline.clusterLoadBalancingTab.sharesIntro`,{fps:e.cameraFps,headroom:Math.round(e.headroom*100),basis:e.source===`benchmark`?i(`pipeline.clusterLoadBalancingTab.measuredByNodeBenchmarksOr`,`measured by node benchmarks, or from the hardware table where a node has no results`):i(`pipeline.clusterLoadBalancingTab.atTheModelsAutoTune`,`at the models Auto tune picks (at least {{minSessionsPerDevice}} per accelerator), from the measured speed of each node's hardware`,{minSessionsPerDevice:e.minSessionsPerDevice})}),` `,r===void 0?i(`pipeline.clusterLoadBalancingTab.automaticSharesAlreadyFollowThis`,`Automatic shares already follow this; the caps are advisory — apply each from its accelerator row.`):i(`pipeline.clusterLoadBalancingTab.applyingWritesTheNodeAnd`,`Applying writes the node and accelerator shares; the caps are advisory — apply each from its accelerator row.`)]})]})}function ma({stats:e,cameraName:t}){let{t:n}=q(),r=l(),i=mt({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPlacementStats`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}});return f(G,{headingId:`load-balancing-stale-pins`,title:n(`pipeline.clusterLoadBalancingTab.staleDevicePins`,`Stale device pins`),icon:je,children:f(`ul`,{className:`divide-y divide-border`,children:e.stalePins.map(e=>o(`li`,{className:`${S} flex items-center gap-2`,children:[o(`div`,{className:`min-w-0 flex-1`,children:[f(`p`,{className:`truncate text-xs text-foreground`,title:t(e.deviceId),children:t(e.deviceId)}),f(`p`,{className:B,children:Ki(e)})]}),f(W,{variant:`outline`,size:`sm`,disabled:i.isPending,onClick:()=>i.mutate({deviceId:e.deviceId,deviceKey:`auto`}),children:n(`pipeline.clusterLoadBalancingTab.clearPin`,`Clear pin`)})]},e.deviceId))})})}function ha({node:e,emphasis:t=!1}){let{t:n}=q(),r=e.isHub?j:T;return o(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[f(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),f(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),o(`div`,{className:`min-w-0`,children:[o(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[f(`span`,{className:`truncate`,children:e.name}),e.isHub&&f(H,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.hubWord`)}),!e.isOnline&&f(H,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:n(`common.offline`)})]}),f(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}function ga({nodes:e,actions:t}){let{t:n}=q();return f(zt,{columns:[{key:`node`,header:n(`placementBoard.nodeCapabilitiesTable.node`,`Node`),sortValue:e=>e.name,render:e=>f(ha,{node:e})},...Dn.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=>f(Wt,{"aria-label":n(`placementBoard.nodeCapabilitiesTable.on`,`{{label}} on {{name}}`,{label:n(e.labelKey),name:r.name}),title:n(e.hintKey),checked:xn(r.effective,e.key),disabled:t.capabilityPending,onCheckedChange:n=>t.onToggleCapability(r.id,e.key,n)})}))],rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:720,rowClassName:e=>e.isOnline?void 0:`opacity-60`,emptyMessage:n(`placementBoard.nodeCapabilitiesTable.noClusterNodesReportingYet`,`No cluster nodes reporting yet.`)})}function _a({roleValues:e,options:t,pending:n,onRoleChange:r}){let{t:i}=q(),a=t.map(e=>({value:e.id,label:e.id===`hub`?i(`placementBoard.roleControls.default`,`{{name}} (default)`,{name:e.name}):e.name}));return f(`ul`,{className:`divide-y divide-border`,children:jn.map(t=>o(`li`,{className:`${S} flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[o(`div`,{className:`min-w-0 flex-1 basis-56`,children:[f(`div`,{className:`text-xs font-medium text-foreground`,children:Cn(t)}),f(`p`,{className:B,children:wn(t)})]}),f(`div`,{className:`w-full sm:w-48`,children:f(U,{"aria-label":i(`placementBoard.roleControls.node`,`{{value1}} node`,{value1:Cn(t)}),value:e[t],disabled:n,options:a,onChange:e=>r(t,e.target.value)})})]},t))})}t();function va(){let{t:e}=q(),t=l(),{nodes:n}=V(),i=He(void 0),a=Ze({addonId:An}),s=Ze({addonId:bn}),c=Ze({addonId:Mn}),u=()=>En(t),d=Kt({onSuccess:u}),p=Tt({onSuccess:u}),m=r(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),h=r(()=>n.map(e=>{let t=m.get(e.id),n=Vn(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n}}),[n,m]),g={ingestNode:kn(a.data,`ingestNode`,`hub`),recordingNode:kn(s.data,On,`hub`),audioNode:kn(a.data,`audioNode`,`hub`),motionNode:kn(a.data,`motionNode`,`hub`),postProcessingNode:kn(c.data,Tn,`hub`)},_=r(()=>{let e=n.filter(e=>e.isOnline).map(e=>e.id),t=e=>n.find(t=>t.id===e)?.name||e;return[...new Set([`hub`,...jn.map(e=>g[e]),...e])].filter(e=>e.length>0).map(e=>({id:e,name:t(e)}))},[n,g]),v=i.isLoading||a.isLoading||s.isLoading||c.isLoading,y=(e,t,n)=>{d.mutate({agentNodeId:e,[t]:n})},b=(e,t)=>{if(e===`recordingNode`){p.mutate({addonId:bn,patch:{[On]:t}});return}if(e===`postProcessingNode`){p.mutate({addonId:Mn,patch:{[Tn]:t}});return}p.mutate({addonId:An,patch:{[e]:t}})},x={capabilityPending:d.isPending,onToggleCapability:y},S=v?f(I,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`,"aria-label":e(`pipeline.clusterRolesNodesTab.loading`,`Loading`)}):null;return o(`div`,{className:`space-y-3 sm:space-y-4`,children:[o(G,{headingId:`roles-nodes-cluster-roles`,title:e(`pipeline.clusterRolesNodesTab.clusterRoles`,`Cluster roles`),icon:ke,actions:S,children:[f(`p`,{className:`${B} border-b border-border px-3 py-1.5 sm:px-4`,children:e(`pipeline.clusterRolesNodesTab.oneNodeHoldsEachRole`,`One node holds each role for every camera. Detection shares and caps are on Load balancing.`)}),f(_a,{roleValues:g,options:_,pending:p.isPending,onRoleChange:b})]}),f(G,{headingId:`roles-nodes-node-capabilities`,title:e(`pipeline.clusterRolesNodesTab.nodeCapabilities`,`Node capabilities`),icon:j,children:f(ga,{nodes:h,actions:x})})]})}var ya=`pipeline-analytics`,ba=`face-gallery`,xa=`pipeline-orchestrator`,Sa=`pipeline-runner`,Ca=`audio-analyzer`;function wa(e){return[...de.filter(t=>t.stepId===e).map(e=>ue(e.stepId)),...Ce.filter(t=>t.stepId===e).map(e=>ge(e.stepId,e.key))]}var Ta=`faces`,Ea=`semantic-search`,Da=`load-balancer`,Oa=`load`,ka=[{id:Ta,get title(){return K.t(`helpers.clusterSettingsSections.facesTitle`)},get hint(){return K.t(`helpers.clusterSettingsSections.facesHint`)},panels:[{addonId:xa,fieldKeys:wa(`face-embedding`)},{addonId:ya,capability:ba}]},{id:Ea,get title(){return K.t(`helpers.clusterSettingsSections.semanticTitle`)},get hint(){return K.t(`helpers.clusterSettingsSections.semanticHint`)},panels:[{addonId:xa,fieldKeys:wa(`clip-embedding`)}]},{id:we,get title(){return K.t(`helpers.clusterSettingsSections.cropTitle`)},get hint(){return K.t(`helpers.clusterSettingsSections.cropHint`)},panels:[{addonId:xa,sectionIds:[we]}]},{id:xe,get title(){return K.t(`helpers.clusterSettingsSections.nativeTitle`)},get hint(){return K.t(`helpers.clusterSettingsSections.nativeHint`)},panels:[{addonId:xa,sectionIds:[xe]}]},{id:`runner-defaults`,get title(){return K.t(`helpers.clusterSettingsSections.runnerTitle`)},get hint(){return K.t(`helpers.clusterSettingsSections.runnerHint`)},panels:[{addonId:Sa,fieldScope:`cluster`},{addonId:Ca,fieldScope:`cluster`}]},{id:Da,get title(){return K.t(`helpers.clusterSettingsSections.loadTitle`)},get hint(){return K.t(`helpers.clusterSettingsSections.loadHint`)},panels:[{addonId:xa,sectionIds:[Oa]}]},{id:`failover`,get title(){return K.t(`helpers.clusterSettingsSections.failoverTitle`)},get hint(){return K.t(`helpers.clusterSettingsSections.failoverHint`)},panels:[{addonId:xa,sectionIds:[`failover`]}]}],Aa={"cluster-step-models":Ta};function ja(e){return e===`clip-embedding`?Ea:Ta}t();var Ma=2500,Na={faces:F,"semantic-search":E,"detail-crop":Ne,"native-lease":Pe,"runner-defaults":T,"load-balancer":Ae,failover:A},Pa=[`cluster`,Oa];function Fa(e){n(()=>{if(e===null)return;let t=Aa[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`),Ma),!0)};if(r())return;let i=new MutationObserver(()=>{r()&&i.disconnect()});return i.observe(document.body,{childList:!0,subtree:!0}),()=>i.disconnect()},[e])}function Ia({section:e}){let{t}=q();return f(`div`,{"data-cluster-settings-card":e.id,className:`rounded-lg`,children:f(G,{headingId:`cluster-settings-${e.id}`,title:e.title,...Na[e.id]===void 0?{}:{icon:Na[e.id]},children:o(`div`,{className:`${m} space-y-3`,children:[f(`p`,{className:B,children:e.hint}),e.panels.map(e=>f(yn,{nodeId:`hub`,addonIds:[e.addonId],level:`global`,hideSectionChrome:!0,omitSectionIds:Pa.filter(t=>!(e.sectionIds??[]).includes(t)),emptyMessage:t(`pipeline.clusterSettingsTab.notAvailableTheAddonThat`,`Not available — the addon that owns these settings did not answer.`),...e.capability===void 0?{}:{capability:e.capability},...e.sectionIds===void 0?{}:{sectionIds:e.sectionIds},...e.fieldKeys===void 0?{}:{fieldKeys:e.fieldKeys},...e.fieldScope===void 0?{}:{fieldScope:e.fieldScope}},`${e.addonId}:${e.capability??``}`))]})})})}function La({refreshToken:e}){let[t]=vn();return Fa(t.get(Bo)),f(`div`,{className:`space-y-3 sm:space-y-4`,children:ka.map(e=>f(Ia,{section:e},e.id))})}var Ra=`pipeline-orchestrator`,za=200;function Ba(){let{t:e}=q();return o(`div`,{className:`flex flex-col gap-3`,children:[o(`div`,{children:[f(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:e(`pipeline.clusterOrchestratorLogsTab.orchestratorLogs`,`Orchestrator logs`)}),f(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`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.`)})]}),f(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:f(Et,{addonId:Ra,limit:za,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1,showSourceSelect:!0})})]})}var Va=[{id:`assignments`,labelKey:`pipeline.clusterDetail.tabAssignments`},{id:`load-balancing`,labelKey:`pipeline.clusterDetail.tabLoadBalancing`},{id:`auto-tune`,labelKey:`pipeline.clusterDetail.tabAutoTune`},{id:`roles-nodes`,labelKey:`pipeline.clusterDetail.tabRoles`},{id:`settings`,labelKey:`common.settings`},{id:`logs`,labelKey:`common.logs`}];function Ha(e){return Va.some(t=>t.id===e)}function Ua({refreshToken:e}){let{t}=q(),[n,r]=vn(),i=n.get(zo),a=Ha(i)?i:`assignments`,s=e=>{r(t=>{let n=new URLSearchParams(t);return n.set(zo,e),n.delete(Bo),n},{replace:!0})};return o(`div`,{className:`flex flex-col h-full`,children:[o(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[f(`h2`,{className:`text-base font-semibold text-foreground`,children:t(`pipeline.clusterDetail.clusterOrchestration`,`Cluster Orchestration`)}),f(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:t(`pipeline.clusterDetail.cameraAssignmentsLoadBalancingThe`,`Camera assignments, load balancing, the detector recommendation, cluster roles and settings.`)})]}),f(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Va.map(e=>f(`button`,{type:`button`,onClick:()=>s(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${a===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:t(e.labelKey)},e.id))}),o(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[a===`assignments`&&f(fi,{}),a===`load-balancing`&&f(fa,{refreshToken:e,onOpenAutoTune:()=>s(`auto-tune`)}),a===`auto-tune`&&f(ji,{}),a===`roles-nodes`&&f(va,{}),a===`settings`&&f(La,{refreshToken:e}),a===`logs`&&f(Ba,{})]})]})}var Wa=`armed:`;function Ga(e){return e.assignment.reasons.detection?.startsWith(Wa)===!0}function Ka(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!Ga(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function qa(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?K.t(`helpers.cameraCardModel.provisioningFailedWith`,{error:i.provisioning.error}):K.t(`helpers.cameraCardModel.provisioningFailed`)}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:K.t(`helpers.cameraCardModel.blackHole`)}),r.detectionNodeId===null&&i===null&&!Ga(e)&&n.push({code:`unassigned`,severity:`warning`,message:K.t(`helpers.cameraCardModel.unassigned`)});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:K.t(`helpers.cameraCardModel.statusUnreadable`,{stages:e})})}n.push(...Xa(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:K.t(`helpers.cameraCardModel.brokerStalled`,{profile:e.profile})});return[...t,...n]}function Ja(e){return e.state===`unreadable`&&le.state===`unreadable`&&e.reason===le.reason}function Ya(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:K.t(`helpers.cameraCardModel.sensorMissing`,{addonId:e.addonId,stableId:e.stableId})};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:K.t(`helpers.cameraCardModel.sensorOffline`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:K.t(`helpers.cameraCardModel.sensorUnsupported`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:K.t(`helpers.cameraCardModel.sensorUnreadable`,{addonId:e.addonId,stableId:e.stableId,reason:e.reason})}}}function Xa(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return Ja(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:K.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=Ya(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[Za(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:K.t(`helpers.cameraCardModel.notEnforced`)},...n]}function Za(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?K.t(`helpers.cameraCardModel.notForwardedOnboard`):K.t(`helpers.cameraCardModel.notForwardedNoDetection`)}}function Qa(e){return e===void 0?K.t(`helpers.cameraCardModel.summaryUnavailable`):e.state===`not-configured`?K.t(`helpers.cameraCardModel.summaryNone`):e.state===`unreadable`?K.t(`helpers.cameraCardModel.summaryUnknown`,{reason:e.reason}):e.sensors.map(eo).join(`, `)}function $a(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function eo(e){return`${to(e)}${$a(e)}`}function to(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return K.t(`helpers.cameraCardModel.summaryUnsupported`,{name:e.name,deviceId:e.deviceId});case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function no(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){return typeof e==`string`&&e.length>0?e:null}function ro(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function io(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ao(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var oo={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function so(e){if(!no(e)||!Array.isArray(e.sections))return oo;let t=me(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)ao(n.value,n.default)&&r.add(e);return{detectionMode:X(n(`detectionMode`)),detectionStreamProfile:X(n(`detectionStreamProfile`)),detectionFps:ro(n(`detectionFps`)),motionSources:io(n(`motionSources`)),motionFps:ro(n(`motionFps`)),motionCooldownMs:ro(n(`motionCooldownMs`)),motionStreamProfile:X(n(`motionStreamProfile`)),audioMode:X(n(`audioMode`)),pipelineNodeId:X(n(`pipelineNodeId`)),decoderNodeId:X(n(`decoderNodeId`)),audioNodeId:X(n(`audioNodeId`)),overriddenKeys:r}}function co(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...co(r.children,t+1));return n}function Z({title:e,children:t}){return o(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[f(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),f(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Q({label:e,children:t,overridden:n=!1}){return o(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[f(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),f(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&f(lo,{})]})}function lo(){let{t:e}=q();return f(`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 uo={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 $({tone:e=`neutral`,children:t,title:n}){return f(`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 ${uo[e]}`,children:t})}function fo({children:e}){return f(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function po({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){let{t:c}=q();return o(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[f(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),f(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?f(`span`,{className:`text-foreground-subtle italic`,children:c(`cameras.configBlocks.unassigned`)}):o(s,{children:[f(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?o(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:c(`cameras.configBlocks.manuallyPinned`,`Manually pinned`),children:[f(v,{className:`h-2.5 w-2.5`}),` `,c(`cameras.configBlocks.manual`)]}):f(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:c(`cameras.configBlocks.autoReason`,{reason:i!==void 0&&i.length>0?i:c(`cameras.configBlocks.capacity`)})}),a&&f(`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 mo({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let{t:a}=q(),s=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,c=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return o(Z,{title:a(`cameras.configBlocks.whereItRuns`,`Where it runs`),children:[f(po,{icon:T,label:a(`cameras.configBlocks.detection`,`Detection`),nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),f(po,{icon:h,label:a(`cameras.configBlocks.decoder`,`Decoder`),nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),f(po,{icon:w,label:a(`cameras.configBlocks.audio`,`Audio`),nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),f(po,{icon:oe,label:a(`cameras.configBlocks.source`,`Source`),nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),f(`div`,{className:`mt-1.5`,children:o(`select`,{value:s,disabled:r,"aria-label":a(`cameras.configBlocks.detectionPlacementPin`,`Detection placement pin`),onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[f(`option`,{value:`auto`,children:a(`cameras.configBlocks.autoLoadBalanced`,`Auto (load balanced)`)}),c.map(e=>f(`option`,{value:e,children:a(`cameras.configBlocks.pinDetection`,{node:n.find(t=>t.id===e)?.name??e})},e))]})})]})}function ho(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function go(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function _o(e){return e===null?K.t(`pipeline.configBlocks.fpsDefault`):e===0?K.t(`pipeline.configBlocks.fpsNative`):`${e} fps`}function vo({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i,cameraSensors:a}){let{t:c}=q(),l=go(t,n.detectionStreamProfile),u=go(t,n.motionStreamProfile),d=n.motionSources.includes(`analyzer`);return o(Z,{title:c(`cameras.configBlocks.streamsMotion`,`Streams & motion`),children:[o(Q,{label:c(`cameras.configBlocks.detectStream`,`Detect stream`),overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,l!==void 0&&` · ${l.width}×${l.height} ${l.codec}`]}),f(Q,{label:c(`cameras.configBlocks.detectFps`,`Detect FPS`),overridden:n.overriddenKeys.has(`detectionFps`),children:_o(n.detectionFps)}),o(Q,{label:c(`cameras.configBlocks.motionSrc`,`Motion src`),overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.map(he).join(` + `):c(`cameras.configBlocks.none`),r===!1&&` · ${c(`cameras.configBlocks.inactive`)}`]}),f(Q,{label:c(`cameras.configBlocks.cameraSensors`,`Camera sensors`),children:Qa(a)}),d&&o(s,{children:[o(Q,{label:c(`cameras.configBlocks.motionStream`,`Motion stream`),overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,u!==void 0&&` · ${u.width}×${u.height} ${u.codec}`]}),o(Q,{label:c(`cameras.configBlocks.motionFps`,`Motion FPS`),overridden:n.overriddenKeys.has(`motionFps`),children:[_o(n.motionFps),i!==null&&` · ${c(`cameras.configBlocks.liveFps`,{fps:i.toFixed(1)})}`]})]}),f(Q,{label:c(`cameras.configBlocks.cooldown`,`Cooldown`),overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?c(`cameras.configBlocks.defaultValue`):`${n.motionCooldownMs/1e3}s`}),f(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?f(fo,{children:c(`cameras.configBlocks.noStreamsRegistered`,`No streams registered`)}):e.map(e=>o(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[f(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,ho(e)]},e.camStreamId))})]})}function yo({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){let{t:i}=q();return o(Z,{title:i(`cameras.configBlocks.pipelineSteps`,`Pipeline steps`),children:[e===void 0?f(fo,{children:i(`cameras.configBlocks.resolving`,`Resolving…`)}):e.length===0?f(fo,{children:i(`cameras.configBlocks.noStepsConfigured`,`No steps configured`)}):f(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>f($,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:o(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&f(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&o(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),f(`div`,{className:`mt-1`,children:o(Q,{label:i(`cameras.configBlocks.audioClass`,`Audio class.`),children:[r??`—`,n!==null&&` · ${i(n?`cameras.configBlocks.running`:`cameras.configBlocks.off`)}`,t!==null&&` · ${t}`]})})]})}var bo={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function xo({detection:e,live:t,detectionMode:n,modeOverridden:r}){let i=L(),{t:a}=q();if(e===null)return o(Z,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[f(Q,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),f(fo,{children:a(`cameras.runtimeBlocks.detectionStageInactiveOrUnreachable`,`Detection stage inactive or unreachable`)})]});let s=t?.phase??e.phase,c=t?.actualFps??e.actualFps,l=t?.configuredFps??e.configuredFps,u=t?.avgInferenceTimeMs??e.avgInferenceMs,d=t?.queueDepth??e.queueDepth,p=At(s,i),m=s===`active`&&c===0;return o(Z,{title:a(`cameras.runtimeBlocks.detectionRuntime`,`Detection runtime`),children:[o(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[o(`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:[f(sn,{phase:s,className:`h-2.5 w-2.5`}),p.label]}),t!==void 0&&f(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:a(`common.live`)})]}),f(Q,{label:a(`cameras.runtimeBlocks.mode`,`Mode`),overridden:r,children:n??`—`}),o(Q,{label:`FPS`,children:[f(`span`,{className:m?`text-danger font-semibold`:``,children:c.toFixed(1)}),f(`span`,{className:`ml-1 text-foreground-subtle`,children:a(`cameras.runtimeBlocks.configuredFps`,{fps:l.toFixed(0)})})]}),o(Q,{label:a(`cameras.runtimeBlocks.inference`,`Inference`),children:[u.toFixed(0),` ms`,d>0&&f(`span`,{className:`ml-1 text-warning`,children:a(`cameras.runtimeBlocks.queue`,{depth:d})}),t!==void 0&&t.droppedFrames>0&&f(`span`,{className:`ml-1 text-warning`,children:a(`cameras.runtimeBlocks.drops`,{count:t.droppedFrames})})]}),o(Q,{label:a(`cameras.runtimeBlocks.engine`,`Engine`),children:[e.engine.backend,` · `,e.engine.device]}),o(Q,{label:a(`cameras.runtimeBlocks.provisioning`,`Provisioning`),children:[f($,{tone:bo[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&o(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function So({broker:e}){let{t}=q();return e===null?f(Z,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:f(fo,{children:t(`cameras.runtimeBlocks.brokerStageInactiveOrUnreachable`,`Broker stage inactive or unreachable`)})}):o(Z,{title:t(`cameras.runtimeBlocks.streamBroker`,`Stream broker`),children:[e.profiles.length===0?f(fo,{children:t(`cameras.runtimeBlocks.noBrokerProfiles`,`No broker profiles`)}):f(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let n=e.status===`streaming`,r=n&&e.inFps===0;return o(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${r?`bg-danger`:n?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),f(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),o(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),f(`span`,{className:`ml-auto shrink-0 ${r?`text-danger`:`text-foreground`}`,children:t(`cameras.runtimeBlocks.fpsValue`,{value:e.inFps===null?`—`:e.inFps.toFixed(0)})}),o(`span`,{className:`text-foreground-subtle shrink-0`,title:t(`cameras.runtimeBlocks.subscribers`,`Subscribers`),children:[`×`,e.subscribers]})]},e.profile)})}),o(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[f($,{tone:e.webrtcSessions>0?`info`:`neutral`,children:t(`cameras.runtimeBlocks.webrtc`,{count:e.webrtcSessions})}),f($,{tone:e.rtspRestream?`success`:`neutral`,children:e.rtspRestream?t(`cameras.runtimeBlocks.restreamOn`):t(`cameras.runtimeBlocks.restreamOff`)})]})]})}function Co({decoder:e}){let{t}=q();return e===null?f(Z,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:f(fo,{children:t(`cameras.runtimeBlocks.decoderStageInactiveOrUnreachable`,`Decoder stage inactive or unreachable`)})}):f(Z,{title:t(`cameras.runtimeBlocks.decoder`,`Decoder`),children:f(Q,{label:t(`cameras.runtimeBlocks.node`,`Node`),children:e.nodeId})})}t();var wo=`pipeline-orchestrator`,To={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},Eo={healthy:`pipeline.cameraPipelineCard.healthHealthy`,idle:`pipeline.cameraPipelineCard.healthIdle`,error:`pipeline.cameraPipelineCard.healthError`};function Do({problems:e}){return f(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>o(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[f(y,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),f(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function Oo({deviceId:e,name:t,online:n,status:i,live:a,onlineNodes:s}){let{t:c}=q(),u=l(),{data:d}=en({addonId:wo,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:p}=it({deviceId:e},{staleTime:3e4}),m=r(()=>so(d),[d]),h=r(()=>p===void 0?void 0:co(p.steps),[p]),g=r(()=>i===void 0?[]:qa(i),[i]),_=()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},v=kt({onSuccess:_}),y=Ge({onSuccess:_}),b=t=>{t===`auto`?y.mutate({deviceId:e}):v.mutate({deviceId:e,agentNodeId:t})},x=i===void 0?`idle`:Ka(i),S=g.some(e=>e.severity===`error`),C=g.length>0,w=S?`border-danger/50`:C?`border-warning/40`:`border-border`;return o(`article`,{"aria-label":c(`cameras.cameraPipelineCard.pipelineStatus`,`{{name}} pipeline status`,{name:t}),className:`rounded-lg border ${w} bg-background overflow-hidden`,children:[o(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[f(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${S?`bg-danger`:To[x]}`,title:S?c(`common.error`,`Error`):c(Eo[x]),"aria-label":S?c(`common.error`,`Error`):c(Eo[x]),role:`img`}),f(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),o(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&f($,{tone:`danger`,children:c(`common.offline`)}),o(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[m.detectionMode!==null&&f($,{tone:m.detectionMode===`disabled`?`warning`:m.detectionMode===`always-on`?`info`:`neutral`,title:c(`cameras.cameraPipelineCard.objectDetectionMode`,`Object detection mode`),children:m.detectionMode===`disabled`?c(`cameras.cameraPipelineCard.detectionOff`,`detection off`):m.detectionMode}),i?.recording!=null&&(i.recording.active?o($,{tone:`danger`,title:c(`cameras.cameraPipelineCard.recording`,`Recording ({{mode}})`,{mode:i.recording.mode}),children:[f(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):i.recording.mode!==`off`&&f($,{tone:`neutral`,title:c(`cameras.cameraPipelineCard.recordingMode`,`Recording mode`),children:c(`pipeline.cameraPipelineCard.recMode`,{mode:i.recording.mode})}))]})]}),g.length>0&&f(Do,{problems:g}),i===void 0?f(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:c(`cameras.cameraPipelineCard.noPipelineStatusYetThe`,`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`)}):o(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[f(mo,{assignment:i.assignment,settings:m,onlineNodes:s,pinPending:v.isPending||y.isPending,onDetectionPinChange:b}),f(xo,{detection:i.detection,live:a,detectionMode:m.detectionMode,modeOverridden:m.overriddenKeys.has(`detectionMode`)}),f(yo,{steps:h,audioModelId:p?.audio?.modelId??null,audioEnabled:i.audio?.enabled??p?.audio?.enabled??null,audioMode:m.audioMode}),f(vo,{streams:i.source.streams,brokerProfiles:i.broker?.profiles,settings:m,motionEnabled:i.motion?.enabled??null,motionFpsLive:i.motion?.fps??null,cameraSensors:i.cameraSensors}),f(So,{broker:i.broker}),f(Co,{decoder:i.decoder})]})]})}t();var ko=5e3,Ao=1e4,jo=5e3;function Mo(e){let t=l(),{data:a,isLoading:o}=hn(),{data:s,isLoading:c}=It({},{refetchInterval:ko}),{nodes:u}=V();n(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[d,f]=i(new Map);Ct(fe.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})}),n(()=>{if(d.size===0)return;let e=setInterval(()=>{f(e=>{let t=Date.now()-Ao,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},jo);return()=>clearInterval(e)},[d.size]);let p=r(()=>{let e=new Map;for(let t of s??[])e.set(t.deviceId,t);return e},[s]);return{rows:r(()=>(a??[]).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)),[a,p]),liveMetrics:d,onlineNodes:r(()=>(u??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[u]),isLoading:o||c}}t();function No({refreshToken:e}){let{t}=q(),{rows:n,liveMetrics:i,onlineNodes:a,isLoading:s}=Mo(e),c=r(()=>[...n.map(e=>{let t=e.status===void 0?[]:qa(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),[n]),l=r(()=>{let e=0,t=0;for(let n of c)(n.errorCount>0||n.warningCount>0)&&(t+=1),(i.get(n.row.deviceId)?.phase??n.row.status?.detection?.phase)===`active`&&(e+=1);return{total:c.length,active:e,issues:t}},[c,i]);return s&&n.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.loadingCameraPipelines`,`Loading camera pipelines…`)}):n.length===0?f(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:t(`cameras.camerasOverview.noCamerasFound`,`No cameras found`)}):f(`div`,{className:`h-full overflow-y-auto`,children:o(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[o(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[f(`span`,{children:f(_n,{i18nKey:`pipeline.camerasOverview.camerasTotal`,values:{count:l.total},components:{b:f(`span`,{className:`font-semibold text-foreground`})}})}),f(`span`,{children:f(_n,{i18nKey:`pipeline.camerasOverview.activelyInferring`,values:{count:l.active},components:{b:f(`span`,{className:`font-semibold text-success`})}})}),o(`span`,{children:[f(`span`,{className:`font-semibold ${l.issues>0?`text-danger`:`text-foreground`}`,children:l.issues}),` `,t(`cameras.camerasOverview.withIssues`,`with issues`)]}),f(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:t(`cameras.camerasOverview.polledEvery5SDetection`,`polled every 5 s · detection metrics live at 1 Hz`)})]}),c.map(({row:e})=>f(Oo,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:i.get(e.deviceId),onlineNodes:a},e.deviceId))]})})}var Po=e({CLUSTER_NODE_ID:()=>Fo,PipelinePage:()=>Ro});t();var Fo=`__cluster__`;function Io(e){return e===`cameras`?`cameras`:`nodes`}function Lo({viewMode:e,onNodes:t,onCameras:n}){let{t:r}=q();return o(`div`,{className:`flex items-center gap-1 rounded-lg border border-border bg-surface p-0.5`,role:`tablist`,"aria-label":r(`pipeline.pipelineView`,`Pipeline view`),children:[f(`button`,{type:`button`,role:`tab`,"aria-selected":e===`nodes`,onClick:t,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,e===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:r(`pipeline.nodes`,`Nodes`)}),f(`button`,{type:`button`,role:`tab`,"aria-selected":e===`cameras`,onClick:n,className:[`rounded-md px-3 py-1 text-[11px] font-medium transition-colors`,e===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:r(`pipeline.cameras`,`Cameras`)})]})}function Ro(){let{t:e}=q(),[t,r]=vn(),a=Io(t.get(`view`)),c=t.get(`node`)??`__cluster__`,[l,u]=i(0),[d,p]=i(!1);return n(()=>{a===`nodes`&&!t.get(`node`)&&r({view:`nodes`,node:Fo},{replace:!0})},[a,t,r]),o(qt,{icon:De,title:e(`pipeline.pipeline`,`Pipeline`),subtitle:e(`pipeline.detectionPlacementLoadAndPer`,`Detection placement, load and per-camera runtime across the cluster.`),actions:o(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(e=>e+1),title:e(`common.refresh`,`Refresh`),children:[f(k,{className:`h-3.5 w-3.5`}),e(`common.refresh`,`Refresh`)]}),nav:f(Lo,{viewMode:a,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:[a===`nodes`&&o(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>!e),"aria-expanded":d,className:`flex w-full shrink-0 justify-between border-b border-border md:hidden`,children:[f(`span`,{children:e(d?`pipeline.hideNodeList`:`pipeline.showNodeList`)}),f(ae,{className:[`h-4 w-4 transition-transform`,d?`rotate-180`:``].join(` `)})]}),f(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:a===`nodes`?o(s,{children:[f(`aside`,{className:[d?`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:f(Un,{selectedNodeId:c,onSelect:e=>{r({view:`nodes`,node:e},{replace:!0}),p(!1)},refreshToken:l})}),f(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:c===`__cluster__`?f(Ua,{refreshToken:l}):f(di,{nodeId:c,refreshToken:l})})]}):f(`section`,{className:`min-h-0 flex-1 overflow-hidden`,children:f(No,{refreshToken:l})})})]})}var zo=`ctab`,Bo=`section`;function Vo(e,t){let n=new URLSearchParams({view:`nodes`,node:Fo,[zo]:e});return t!==void 0&&n.set(Bo,t),`/system/pipeline?${n.toString()}`}function Ho(e){return Vo(`settings`,ja(e))}function Uo(){return Vo(`load-balancing`)}var Wo=`pipeline-orchestrator`;function Go(e){return de.find(t=>t.stepId===e)??null}function Ko({step:e,engineFormat:t,runnableModelIds:n}){let{t:r}=q(),{data:i}=Ze({addonId:Wo}),a=ve(i??null)[e.stepId]??e.defaultModelId,s=e.options.find(e=>e.id===a)?.label??a,c=n.length>0&&!n.includes(a);return o(`div`,{className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2`,children:[o(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[f(`span`,{className:`font-medium text-foreground`,children:e.label}),f(`span`,{className:`font-mono text-foreground`,children:s}),f(`span`,{title:r(`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:r(`pipeline.clusterStepModel.clusterWide`)}),f(gn,{to:Ho(e.stepId),className:`ml-auto text-[11px] text-primary hover:underline`,children:r(`pipeline.clusterStepModel.changeInClusterSettings`,`Change in Cluster → Settings ›`)})]}),o(`p`,{className:B,children:[r(`pipeline.clusterStepModel.oneModelForEveryNode`,`One model for every node and camera:`),` `,r(`pipeline.clusterStepModel.indexNote`,{index:e.indexName})]}),c&&f(`p`,{className:`rounded border border-warning/40 bg-warning/10 px-2 py-1 text-[10px] leading-snug text-warning`,children:f(_n,{i18nKey:`pipeline.clusterStepModel.noBuild`,values:{engine:t,model:a,index:e.indexName},components:{b:f(`b`,{})}})})]})}export{Nr as _,Zr as a,Ir as c,Hr as d,Wr as f,Pr as g,Ur as h,Qr as i,Jr as l,Vr as m,Go as n,Br as o,qr as p,Po as r,Gr as s,Ko as t,Kr as u,Ar as v,Pn as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,J as n,K as r,L as i,S as a,b as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as l,O as u,V as d,ot as f,sa as p}from"./player-overlays-D98Lvll4.js";import{Cn as m,Fn as h,Hr as g,Jr as _,Kr as v,Sn as y,Tn as b,Ur as x,Wr as S,Xr as C,Yr as w,Zr as T,ai as ee,di as E,ii as D,qr as te,ui as O,wn as ne,xn as re,zr as k}from"./client-Cj9cIFJV.js";import{Ar as ie,Au as ae,Hu as oe,Ja as se,Rr as ce,Wu as le,Ya as A,_a as ue,da as de,fr as j,hr as M,s as fe,wo as pe}from"./src-MJ2k3G6o.js";import{t as N}from"./i18n-BuS8cl72.js";import{t as P}from"./useTranslation-D3Is_4B6.js";e();function me(e){return{target:{kind:`new`,type:e},name:``,features:[]}}function he(e){return{target:{kind:`existing`,device:e},name:``,features:[]}}function F(e,t){return{target:e.target,name:t,features:e.features.flatMap(e=>e.kind===`fields`?[e]:[])}}function I(e,t,n){return{...e,features:e.features.map(e=>e.cap===t?n(e):e)}}function L(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function ge(e,t){switch(t.type){case`set-new-type`:return e.target.kind===`new`?{...e,target:{...e.target,type:t.deviceType}}:e;case`set-new-role`:{if(e.target.kind!==`new`)return e;let{role:n,...r}=e.target;return{...e,target:t.role===null?r:{...r,role:t.role}}}case`set-name`:return{...e,name:t.name};case`add-feature`:return e.features.some(e=>e.cap===t.cap)?e:{...e,features:[...e.features,{kind:`fields`,cap:t.cap,fields:{}}]};case`remove-feature`:return{...e,features:e.features.filter(e=>e.cap!==t.cap)};case`set-field`:return I(e,t.cap,e=>({...e,fields:{...e.fields,[t.path]:t.source}}));case`clear-field`:return I(e,t.cap,e=>({...e,fields:L(e.fields,t.path)}));case`remove-binding`:return I(e,t.cap,e=>{let n=e.fields[t.path];return n?.kind===`expression`?{...e,fields:{...e.fields,[t.path]:{...n,bindings:L(n.bindings,t.bindingName)}}}:e});case`copy-feature`:return I(e,t.cap,e=>({...e,fields:{...e.fields,...Object.fromEntries(t.paths.map(e=>[e,{kind:`from`,source:t.from,cap:t.sourceCap,fieldPath:e}]))}}))}}function _e(e){let t=S.safeParse({target:e.target,features:e.features});return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:t.error.issues.map(e=>`${e.path.join(`.`)||`composition`}: ${e.message}`)}}function ve(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function ye(e){for(let t=1;;t++){let n=`s${t}`;if(!e.includes(n))return n}}var be=[`room`,`converted-sensor`,`derived-binary`],R={addonId:`provider-homeassistant`,stableId:`sensor.template_source`};function xe(){return F(ne({temperatureSources:y,motionSources:re,occupancyWindowMs:m}),`Room`)}function Se(){return F({target:{kind:`new`,type:E.Sensor},features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:{kind:`expression`,expr:`convert(v, "°C", "°F")`,bindings:{v:{kind:`from`,source:R,cap:`numeric-sensor`,fieldPath:`value`}}},unit:{kind:`expression`,expr:`"°F"`,bindings:{}},lastFetchedAt:{kind:`expression`,expr:`now`,bindings:{}}}}]},`Converted sensor`)}function Ce(){return F({target:{kind:`new`,type:E.Sensor},features:[{kind:`fields`,cap:`binary`,fields:{on:{kind:`expression`,expr:`v > 20`,bindings:{v:{kind:`from`,source:R,cap:`temperature-sensor`,fieldPath:`celsius`}}},lastChangedAt:{kind:`expression`,expr:`now`,bindings:{}}}}]},`Derived binary`)}function we(e){switch(e){case`room`:return xe();case`converted-sensor`:return Se();case`derived-binary`:return Ce()}}function Te(e,t){return typeof t==`number`&&Number.isFinite(t)&&t>0?{kind:`device`,path:`/devices/${t}`}:{kind:`editor`,path:`/build/compositions/${encodeURIComponent(e)}`}}var z=`rounded-lg border border-border bg-surface p-4`,Ee=z;function De(e){return{addonId:e.addonId,stableId:e.stableId}}function B(e){return new Map(e.map(e=>[C(De(e)),e]))}function Oe(e,t,n){let r=e?.features??[],i=r.findIndex(e=>e.cap===n.cap);return{target:e?.target??{kind:`existing`,device:t},features:i===-1?[...r,n]:r.map((e,t)=>t===i?n:e)}}function ke(e,t){let n=e.features.filter(e=>e.cap!==t);return n.length===0?null:{target:e.target,features:n}}function Ae(e,t){let n=e?.features.find(e=>e.cap===t);return n!==void 0&&n.kind===`fields`?n:null}function V(e){return Array.isArray(e)?e.map(V):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,V(t)]))}function H(e){return JSON.stringify(V(e))}function je(e,t){return H(e)===H(t)}function U(e,t){return H(e)===H(t)}function Me(e,t){switch(e.kind){case`pending`:return{kind:`refused`,reason:N.t(`helpers.customizationSave.notReadYet`)};case`unknown`:return{kind:`refused`,reason:`the customization could not be read: ${e.reason}`};case`not-loaded`:return{kind:`refused`,reason:`the customizations are not loaded yet: ${e.reason}`};case`none`:return t===null?{kind:`noop`}:{kind:`create`,input:{enabled:!0,composition:t}};case`present`:{let n=e.view.block.id;return t===null?{kind:`delete`,blockId:n}:H(t)===H(e.composition)?{kind:`noop`}:{kind:`update`,blockId:n,expectedUpdatedAt:e.view.block.updatedAt,composition:t}}}}function W(e,t){let n=e===`enum`?`string`:e,r=t.kind===`enum`?`string`:t.kind,i={source:t.source,cap:t.cap,fieldPath:t.fieldPath};return r===n?{kind:`from`,...i}:n===`number`&&r===`string`?{kind:`expression`,expr:`number(x)`,bindings:{x:{kind:`from`,...i}}}:null}function G(e){return{kind:`expression`,expr:e,bindings:{}}}function K(e){let t=W(`number`,e.percentage);return t===null?null:{kind:`fields`,cap:`battery`,fields:e.mode===`replace`?{percentage:t}:{percentage:t,charging:G(`"unknown"`),sleeping:G(`false`),lastUpdated:G(`now`)}}}var Ne=[`percent`,...h.options];function q(e,t){return t===`percent`?{level:e}:{"remaining.value":e,"remaining.unit":G(JSON.stringify(t))}}function Pe(e,t){let n=W(`number`,t.remaining);if(n===null||!x.test(t.key)||t.label.trim()===``)return null;let r={label:t.label.trim(),fields:q(n,t.unit)};return{kind:`fields`,cap:`consumables`,...e?.enabled===void 0?{}:{enabled:e.enabled},fields:e?.fields??{lastChangedAt:G(`now`),lastFetchedAt:G(`now`)},items:{...e?.items,[t.key]:r}}}function Fe(e){if(e.level!==void 0)return`percent`;let t=e[`remaining.unit`];if(t===void 0||t.kind!==`expression`)return null;try{let e=h.safeParse(JSON.parse(t.expr));return e.success?e.data:null}catch{return null}}function Ie(e){return Object.entries(e?.items??{}).map(([e,t])=>{let n=Fe(t.fields),r=J(t.fields.level??t.fields[`remaining.value`]),i=r===null?null:W(`number`,r);return n!==null&&i!==null&&je(q(i,n),t.fields)?{key:e,label:t.label,unit:n,source:r}:{key:e,label:t.label,unit:null,source:null}})}function Le(e,t){let n=Object.fromEntries(Object.entries(e.items??{}).filter(([e])=>e!==t));return Object.keys(n).length===0?null:{...e,items:n}}function Re(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function ze(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=Object.entries(t.bindings).filter(([e])=>e.startsWith(`active`)).flatMap(([,e])=>e.kind===`from`?[e.source]:[]);return[...new Map(n.map(e=>[C(e),e])).values()]}function Be(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=t.bindings;return Object.entries(n).flatMap(([e,t])=>{if(!e.startsWith(`active`)||t.kind!==`from`)return[];let r=n[`changed${e.slice(6)}`];return r===void 0||r.kind!==`from`?[]:[{source:t.source,cap:t.cap,activeField:t.fieldPath,changedAtField:r.fieldPath}]})}function J(e){if(e===void 0)return null;if(e.kind===`from`){let{kind:t,...n}=e;return{...n,kind:`number`}}if(e.kind!==`expression`||e.expr!==`number(x)`)return null;let t=e.bindings.x;if(t===void 0||t.kind!==`from`||Object.keys(e.bindings).length!==1)return null;let{kind:n,...r}=t;return{...r,kind:`string`}}function Ve(e,t){let n=J(e.fields.percentage);if(n===null)return!1;let r=K({percentage:n,mode:t}),{enabled:i,...a}=e;return r!==null&&U(a,r)}function Y(e){return e.map(e=>({id:e.id,name:e.name,addonId:e.addonId,stableId:e.stableId,location:e.location,type:e.type}))}function He(e,t,n){let r=t.trim().toLowerCase();return r===``?[]:e.filter(e=>!n.includes(e.id)&&[e.name,e.stableId,e.location??``].some(e=>e.toLowerCase().includes(r))).toSorted((e,t)=>e.name.localeCompare(t.name)).slice(0,20)}function X(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=Object.getOwnPropertyDescriptor(n,e)?.value}return n}function Ue(e,t,n,r){return r===null?{kind:`from`,source:e,cap:t,fieldPath:n.path}:W(r,{source:e,cap:t,fieldPath:n.path,kind:n.kind})}function We(e,t,n,r){let i={addonId:e.addonId,stableId:e.stableId};return t.caps.flatMap(e=>e.fields.filter(e=>e.item!==!0).map(t=>({cap:e.cap,path:t.path,kind:t.kind,value:n===null?void 0:X(n[e.cap],t.path),source:Ue(i,e.cap,t,r)})))}function Z(e,t){return t?e===void 0?`—`:e===null?`null`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e):`…`}var Ge=[];function Ke({title:e,targetKind:t,excludeDeviceIds:r=Ge,onPick:i,onCancel:o}){let{t:s}=P(),[f,p]=n(null);return a(`aside`,{"aria-label":e,className:`${u} ${l} flex flex-col gap-2`,children:[c(`h3`,{className:d,children:e}),f===null?c(qe,{excludeDeviceIds:r,onSelect:p}):c(Je,{device:f,targetKind:t,onPick:i,onBack:()=>p(null)}),c(`div`,{children:c(M,{variant:`ghost`,size:`sm`,onClick:o,children:s(`customize.picker.cancel`)})})]})}function qe({excludeDeviceIds:e,onSelect:t}){let{t:r}=P(),[i,s]=n(``),l=A({projection:`slim`});return a(o,{children:[a(`label`,{className:`flex flex-col gap-1 text-[11px] text-foreground-subtle`,children:[r(`customize.picker.search`),c(ae,{type:`search`,"aria-label":r(`customize.picker.search`),value:i,onChange:e=>s(e.target.value)})]}),l.status===`pending`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:r(`customize.picker.loadingDevices`)}),l.status===`error`&&c(j,{title:r(`customize.picker.devicesFailed`),message:l.error?.message??``}),l.status===`success`&&c(`ul`,{className:`flex flex-col gap-1`,children:He(Y(l.data),i,e).map(e=>c(`li`,{children:a(`button`,{type:`button`,className:`text-left text-[11px] hover:underline`,onClick:()=>t(e),children:[e.name,` `,a(`span`,{className:`text-foreground-subtle`,children:[`· `,e.stableId]})]})},e.id))})]})}function Je({device:e,targetKind:t,selected:n,onPick:r,onBack:i}){let{t:o}=P(),s=se({deviceId:e.id}),l=pe({deviceId:e.id});if(s.status===`pending`)return c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:o(`customize.picker.loadingFields`)});if(s.status===`error`)return c(j,{title:o(`customize.picker.fieldsFailed`),message:s.error?.message??``});let u=We(e,s.data,l.status===`success`?l.data:null,t),d=u.filter(e=>e.source===null).length,f={addonId:e.addonId,stableId:e.stableId};return a(`div`,{className:`flex flex-col gap-1`,children:[a(`button`,{type:`button`,className:`text-left text-[11px] text-primary`,onClick:i,children:[`← `,e.name]}),l.status===`error`&&c(`p`,{role:`alert`,className:`text-[10px] text-warning`,children:o(`customize.picker.valuesFailed`,{reason:l.error?.message??``})}),c(`ul`,{role:`listbox`,"aria-label":o(`customize.picker.fields`),className:`flex flex-col gap-1`,children:u.map(t=>{let i=t.source;if(i===null)return null;let o=()=>r({device:e,ref:f,cap:t.cap,path:t.path,kind:t.kind,source:i,value:t.value});return a(`li`,{role:`option`,"aria-selected":n?.cap===t.cap&&n.path===t.path,tabIndex:0,className:`flex justify-between gap-2 text-[11px] cursor-pointer hover:bg-surface-hover rounded px-1`,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o()},children:[a(`span`,{className:`font-mono`,children:[t.cap,`.`,t.path]}),c(`span`,{children:Z(t.value,l.status===`success`)})]},`${t.cap}.${t.path}`)})}),d>0&&t!==null&&c(`p`,{className:`text-[10px] text-foreground-subtle`,children:o(`customize.picker.hidden`,{count:d,kind:o(`customize.kinds.${t}`)})})]})}var Ye=`integration`;function Q(e,t){switch(e.kind){case`from`:{let n=C(e.source);return`${t.get(n)??n} · ${e.cap}.${e.fieldPath}`}case`expression`:return e.expr;case`code`:return`code`}}function Xe(e,t){if(e.kind===`unreachable`)return{kind:`unknown`,reason:e.error};if(e.state===null)return{kind:`unknown`,reason:N.t(`helpers.fieldsTableRows.composerNotReported`)};let n=e.state.fields.find(t);return n===void 0?{kind:`unknown`,reason:N.t(`helpers.fieldsTableRows.noValue`)}:n.state===`unavailable`?{kind:`unavailable`,reason:n.reason??N.t(`common.unavailable`)}:{kind:`value`,value:n.value,staleReason:n.state===`stale`?n.reason??N.t(`common.stale`):null}}function Ze(e,t,n,r){return{key:`${e.feature.cap}.${t}`,cap:e.feature.cap,field:t,origin:`composed`,mode:e.mode,from:Q(n,e.input.sourceNames),value:e.enabled?Xe(e.input.state,r):{kind:`off`}}}function Qe(e){let t=e.feature.cap;return Object.entries(e.feature.fields).map(([n,r])=>Ze(e,n,r,e=>e.cap===t&&e.path===n&&e.item===void 0))}function $e(e){let t=e.feature.cap;return Object.entries(e.feature.items??{}).flatMap(([n,r])=>Object.entries(r.fields).map(([r,i])=>Ze(e,te(g,n,r),i,e=>e.cap===t&&e.path===r&&e.item?.arrayPath===`items`&&e.item.key===n)))}function et(e,t,n){if(e===null)return{kind:`unknown`,reason:N.t(`helpers.fieldsTableRows.stateUnreadable`)};let r=X(e[t],n),i=r===void 0?void 0:D(r);return i===void 0?{kind:`unknown`,reason:N.t(`helpers.fieldsTableRows.notReported`)}:{kind:`value`,value:i,staleReason:null}}function tt(e){if(e.mode!==`replace`)return[];let t=e.feature.cap,n=new Set(Object.keys(e.feature.fields));return(e.input.nativeFields.get(t)??[]).filter(e=>!n.has(e)).map(n=>({key:`${t}.${n}`,cap:t,field:n,origin:`native`,mode:e.mode,from:Ye,value:et(e.input.snapshot,t,n)}))}function nt(e){return e.composition.features.flatMap(t=>{if(t.kind!==`fields`)return[];let n={feature:t,mode:e.nativeCaps.has(t.cap)?`replace`:`add`,enabled:v(t),input:e};return[...Qe(n),...$e(n),...tt(n)]})}var rt={min:`min(a, b, …)`,max:`max(a, b, …)`,abs:`abs(x)`,floor:`floor(x)`,ceil:`ceil(x)`,sqrt:`sqrt(x)`,round:`round(x, digits?)`,pow:`pow(x, y)`,clamp:`clamp(x, lo, hi)`,avg:`avg(a, b, …)`,sum:`sum(a, b, …)`,coalesce:`coalesce(a, b, …)`,age:`age(now, ts)`,convert:`convert(x, "from", "to")`,any:`any(a, b, …)`,all:`all(a, b, …)`,within:`within(ts, ms)`,number:`number(x)`,latest:`latest(ts, …)`,rose:`rose(level, changedAt, debounceMs?)`,count:`count(x)`},it=/[A-Za-z_][A-Za-z0-9_]*$/;function at(e,t,n){let r=it.exec(e.slice(0,t))?.[0]??``;if(r===``)return[];let i=n.filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`binding`,label:e,insert:e,hintKey:null})),a=`now`.startsWith(r)?[{kind:`now`,label:`now`,insert:`now`,hintKey:`compositionEditor.now`}]:[],o=[...ee].filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`builtin`,label:rt[e]??e,insert:`${e}(`,hintKey:`compositionEditor.builtins.${e}`}));return[...i,...a,...o].slice(0,8)}function ot(e,t,n){let r=t-(it.exec(e.slice(0,t))?.[0]??``).length;return{text:`${e.slice(0,r)}${n.insert}${e.slice(t)}`,cursor:r+n.insert.length}}e();function st({label:e,value:t,bindings:r,onChange:i}){let{t:o}=P(),l=s(null),[u,d]=n(t.length),f=at(t,u,r);return a(`div`,{className:`flex flex-col gap-1`,children:[a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[e,c(`input`,{ref:l,className:`font-mono px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`,value:t,onChange:e=>{i(e.target.value),d(e.target.selectionStart??e.target.value.length)},onSelect:e=>d(e.currentTarget.selectionStart??t.length)})]}),f.length>0&&c(`ul`,{role:`listbox`,"aria-label":o(`compositionEditor.suggestions`),className:`rounded border border-border bg-surface text-[11px]`,children:f.map(e=>a(`li`,{role:`option`,"aria-selected":!1,tabIndex:0,className:`flex justify-between gap-2 px-1 cursor-pointer hover:bg-surface-hover`,onClick:()=>{let n=ot(t,u,e);i(n.text),d(n.cursor),l.current?.focus()},children:[c(`span`,{className:`font-mono`,children:e.label}),e.hintKey!==null&&c(`span`,{className:`text-foreground-subtle`,children:o(e.hintKey)})]},`${e.kind}:${e.label}`))})]})}function ct(e,t,n){if(e.kind===`code`)return{kind:`unavailable`,reason:N.t(`helpers.fieldPreview.codeFields`)};if(e.kind===`expression`&&(k(e.expr,`rose`)||k(e.expr,`count`)))return{kind:`runtime-only`};let r=T(e).filter(e=>t.get(w(e.source,e.cap))?.kind!==`value`).map(_);if(r.length>0)return{kind:`waiting`,missing:r};let i=b({source:e,now:n,read:e=>{let n=t.get(w(e.source,e.cap)),r=n?.kind===`value`?X(n.slice,e.fieldPath):void 0,i=r===void 0?void 0:D(r);return i===void 0?{state:`unavailable`,reason:N.t(`helpers.fieldPreview.notReported`,{path:`${e.cap}.${e.fieldPath}`}),fatal:!1}:{state:`fresh`,value:i}}});return i.state===`unavailable`?{kind:`unavailable`,reason:i.reason}:{kind:`value`,value:i.value,stale:i.reason}}e();function lt({sliceKey:e,deviceId:n,capName:r,onReading:i}){let a=fe(f().trpcClient,n,r);return t(()=>{i(e,a===void 0?{kind:`pending`}:{kind:`value`,slice:a})},[e,a,i]),null}function ut(e,t){return[...new Map(T(e).map(e=>[w(e.source,e.cap),e]))].map(([e,n])=>({key:e,read:n,device:t.get(C(n.source))}))}function dt({source:e}){let{t}=P(),r=A({projection:`slim`}),[o,s]=n(new Map),l=i((e,t)=>{s(n=>new Map([...n,[e,t]]))},[]),u=ut(e,B(r.status===`success`?Y(r.data):[])),d=r.status===`success`?u.filter(e=>e.device===void 0).map(e=>C(e.read.source)):[];return a(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[u.map(e=>e.device===void 0?null:c(lt,{sliceKey:e.key,deviceId:e.device.id,capName:e.read.cap,onReading:l},e.key)),c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.label`)}),r.status===`error`?c(`span`,{className:`text-warning`,children:t(`compositionEditor.preview.devicesFailed`,{reason:r.error?.message??``})}):d.length>0?c(`span`,{className:`text-warning`,children:t(`compositionEditor.preview.unknownDevice`,{sources:d.join(`, `)})}):c(ft,{preview:ct(e,o,Date.now())})]})}function ft({preview:e}){let{t}=P();switch(e.kind){case`value`:return a(`strong`,{children:[`→ `,Z(e.value,!0),e.stale===null?``:` (${e.stale})`]});case`unavailable`:return c(`span`,{className:`text-warning`,children:e.reason});case`waiting`:return c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.waiting`,{sources:e.missing.join(`, `)})});case`runtime-only`:return c(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.runtimeOnly`)})}}e();function pt({path:e,kind:t,required:r,source:i,onSet:s,onClear:l,onRemoveBinding:u,sourceNames:d}){let{t:f}=P(),[p,m]=n(`idle`),h=i?.kind===`expression`?i:null;return a(`div`,{className:`flex flex-col gap-1 rounded border border-border p-2`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`span`,{className:`font-mono text-[11px]`,children:e}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[f(`customize.kinds.${t}`),r?` · ${f(`compositionEditor.required`)}`:``]}),c(M,{size:`sm`,variant:`outline`,onClick:()=>m(`take`),children:f(`compositionEditor.takeFrom`)}),c(M,{size:`sm`,variant:`outline`,"aria-pressed":h!==null,onClick:()=>s(h??{kind:`expression`,expr:`null`,bindings:{}}),children:f(`compositionEditor.formula`)}),i!==void 0&&c(M,{size:`sm`,variant:`ghost`,onClick:l,children:f(`compositionEditor.clear`)})]}),i?.kind===`from`&&c(`span`,{className:`text-[11px]`,children:Q(i,d)}),h!==null&&a(o,{children:[c(st,{label:f(`compositionEditor.formulaFor`,{path:e}),value:h.expr,bindings:Object.keys(h.bindings),onChange:e=>s({...h,expr:e})}),c(`ul`,{className:`text-[11px] flex flex-col gap-0.5`,children:Object.entries(h.bindings).map(([e,t])=>a(`li`,{className:`flex flex-wrap items-center gap-2`,children:[c(`span`,{className:`font-mono`,children:e}),c(`span`,{children:t.kind===`from`?Q(t,d):JSON.stringify(t.value)}),c(M,{size:`sm`,variant:`ghost`,"aria-label":f(`compositionEditor.removeBinding`,{name:e}),onClick:()=>u(e),children:`×`})]},e))}),c(M,{size:`sm`,variant:`ghost`,onClick:()=>m(`add-binding`),children:f(`compositionEditor.addSource`)})]}),p!==`idle`&&c(Ke,{title:f(p===`take`?`compositionEditor.takeFrom`:`compositionEditor.addSource`),targetKind:p===`take`?t:null,onCancel:()=>m(`idle`),onPick:e=>{if(p===`take`)s(e.source);else if(h!==null){let t=ye(Object.keys(h.bindings));s({...h,bindings:{...h.bindings,[t]:{kind:`from`,source:e.ref,cap:e.cap,fieldPath:e.path}}})}m(`idle`)}}),i!==void 0&&c(dt,{source:i})]})}e();function mt(e){return e===null||e.kind===`known`?null:e}function ht({draft:e,deviceType:t,nativeCaps:r,targetFields:i,dispatch:s}){let{t:l}=P(),u=de({deviceType:t}),d=A({projection:`slim`}),f=new Map([...B(d.status===`success`?Y(d.data):[])].map(([e,t])=>[e,t.name])),[p,m]=n(null),h=mt(r)??mt(i),g=r?.kind===`known`?r.value:new Set,_=new Set(e.features.map(e=>e.cap)),v=u.status===`success`?u.data.caps.filter(e=>!_.has(e.cap)&&!g.has(e.cap)):[],y=[...g].filter(e=>!_.has(e)),b=e=>g.has(e)?((i?.kind===`known`?i.value.caps.find(t=>t.cap===e):void 0)?.fields??[]).filter(e=>e.item!==!0&&!e.path.includes(`.`)).map(e=>({path:e.path,kind:e.kind,required:!1})):((u.status===`success`?u.data.caps.find(t=>t.cap===e):void 0)?.fields??[]).map(e=>({path:e.path,kind:e.kind,required:e.required}));return h===null?a(o,{children:[a(`section`,{"aria-labelledby":`editor-features`,className:`${z} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),u.status===`pending`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`compositionEditor.checking`)}),u.status===`error`&&c(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`compositionEditor.unknown`,{reason:u.error?.message??``})}),a(`div`,{className:`flex flex-wrap gap-1`,children:[e.features.map(e=>a(`span`,{className:`flex items-center gap-1 rounded border border-border px-1.5 text-[11px]`,children:[e.cap,c(ce,{variant:g.has(e.cap)?`default`:`info`,children:g.has(e.cap)?l(`compositionEditor.replaces`):l(`compositionEditor.added`)}),c(`button`,{type:`button`,"aria-label":l(`compositionEditor.removeFeature`,{cap:e.cap}),onClick:()=>s({type:`remove-feature`,cap:e.cap}),children:`×`})]},e.cap)),v.map(e=>a(M,{size:`sm`,variant:`outline`,onClick:()=>s({type:`add-feature`,cap:e.cap}),children:[`+ `,e.cap]},e.cap)),y.map(e=>c(M,{size:`sm`,variant:`ghost`,onClick:()=>s({type:`add-feature`,cap:e}),children:l(`compositionEditor.replaceIn`,{cap:e})},e))]})]}),e.features.map(e=>a(`section`,{"aria-label":l(`compositionEditor.steps.fieldsOf`,{cap:e.cap}),className:`${z} flex flex-col gap-2`,children:[a(`div`,{className:`flex items-center justify-between`,children:[c(`h2`,{className:`text-sm font-semibold`,children:l(`compositionEditor.steps.fieldsOf`,{cap:e.cap})}),c(M,{size:`sm`,variant:`outline`,onClick:()=>m(e.cap),children:l(`compositionEditor.copyFeature`)})]}),p===e.cap&&c(Ke,{title:l(`compositionEditor.copyFeature`),targetKind:null,onCancel:()=>m(null),onPick:t=>{s({type:`copy-feature`,cap:e.cap,from:t.ref,sourceCap:t.cap,paths:b(e.cap).map(e=>e.path)}),m(null)}}),b(e.cap).map(t=>c(pt,{path:t.path,kind:t.kind,required:t.required,source:e.fields[t.path],onSet:n=>s({type:`set-field`,cap:e.cap,path:t.path,source:n}),onClear:()=>s({type:`clear-field`,cap:e.cap,path:t.path}),onRemoveBinding:n=>s({type:`remove-binding`,cap:e.cap,path:t.path,bindingName:n}),sourceNames:f},t.path))]},e.cap))]}):a(`section`,{"aria-labelledby":`editor-features`,className:`${z} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:h.kind===`unknown`?h.reason:l(`compositionEditor.reading`)})]})}var $=`px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`;function gt({draft:e,targetName:t,dispatch:n}){let r=p(),{t:i}=P(),o=e.target;return a(`section`,{"aria-labelledby":`editor-target`,className:`${z} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-target`,className:`text-sm font-semibold`,children:i(`compositionEditor.steps.target`)}),o.kind===`existing`?c(`p`,{className:`text-[11px]`,children:i(`compositionEditor.existingTarget`,{name:t??`${o.device.addonId}/${o.device.stableId}`})}):a(`div`,{className:`grid grid-cols-3 gap-2`,children:[a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`compositionEditor.targetType`),c(`select`,{className:$,value:o.type,onChange:e=>{let t=Object.values(E).find(t=>t===e.target.value);t!==void 0&&n({type:`set-new-type`,deviceType:t})},children:Object.values(E).map(e=>c(`option`,{value:e,children:le(e,r).label},e))})]}),a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`customize.identity.role`),a(`select`,{className:$,value:o.role??``,onChange:e=>n({type:`set-new-role`,role:Object.values(O).find(t=>t===e.target.value)??null}),children:[c(`option`,{value:``,children:i(`customize.identity.noRole`)}),Object.values(O).map(e=>c(`option`,{value:e,children:oe(e,r).label},e))]})]}),a(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[i(`compositionEditor.name`),c(`input`,{className:$,value:e.name,onChange:e=>n({type:`set-name`,name:e.target.value})})]})]})]})}e();function _t({draft:e,blockId:r,saving:i,onSave:o,onCancel:s}){let{t:l}=P(),u=ue(),d=_e(e),f=d.ok?JSON.stringify(d.composition):``,[p,m]=n({key:``,state:{kind:`checking`}});t(()=>{if(!d.ok)return;let e=d.composition,t=setTimeout(()=>{u.mutateAsync({composition:e,...r===null?{}:{blockId:r}}).then(e=>m({key:f,state:e.ok?{kind:`ok`}:{kind:`refused`,problems:e.problems}})).catch(e=>m({key:f,state:{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}))},500);return()=>clearTimeout(t)},[f,r]);let h=d.ok?p.key===f?p.state:{kind:`checking`}:{kind:`invalid-draft`,problems:d.problems};return a(`section`,{"aria-labelledby":`editor-verify`,className:`${z} flex flex-col gap-2`,children:[c(`h2`,{id:`editor-verify`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.verify`)}),h.kind===`checking`&&c(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`compositionEditor.verify.checking`)}),h.kind===`ok`&&c(`p`,{className:`text-[11px] text-success`,children:l(`compositionEditor.verify.ok`)}),h.kind===`unknown`&&c(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`compositionEditor.verify.unknown`,{reason:h.reason})}),(h.kind===`invalid-draft`||h.kind===`refused`)&&c(`ul`,{role:`alert`,className:`flex flex-col gap-1 text-[11px] text-danger`,children:h.kind===`invalid-draft`?h.problems.map(e=>c(`li`,{children:e},e)):h.problems.map(e=>a(`li`,{children:[c(`span`,{className:`font-mono`,children:e.path}),` — `,e.message]},`${e.path}:${e.code}`))}),a(`div`,{className:`flex gap-2`,children:[c(M,{variant:`ghost`,onClick:s,children:l(`compositionEditor.cancel`)}),c(M,{disabled:h.kind!==`ok`||i||!d.ok,onClick:()=>d.ok&&o(d.composition),children:l(`compositionEditor.save`)})]})]})}e();function vt({initial:e,blockId:t,deviceType:r,targetName:i=null,nativeCaps:a,targetFields:o,save:s,onCancel:l,showTemplates:u=!1}){let[d,f]=n(e),p=`${d.name}:${d.features.map(e=>e.cap).join(`,`)}:${d.target.kind===`new`?d.target.type:`existing`}`;return c(yt,{seed:d,blockId:t,deviceType:r,targetName:i,nativeCaps:a,targetFields:o,showTemplates:u,onApplyTemplate:e=>{f(we(e))},save:s,onCancel:l},p)}function yt({seed:e,blockId:t,deviceType:i,targetName:o,nativeCaps:s,targetFields:l,showTemplates:u,onApplyTemplate:d,save:f,onCancel:p}){let{t:m}=P(),h=ie(),[g,_]=r(ge,e),[v,y]=n(!1),[b,x]=n(null),S=async t=>{ve(e,g)&&!await h({title:m(`compositionEditor.templates.confirmTitle`),message:m(`compositionEditor.templates.confirmMessage`),confirmLabel:m(`compositionEditor.templates.confirmApply`),variant:`danger`})||d(t)},C=g.target.kind===`new`?g.target.type:i,w=async e=>{y(!0);let t=await f(e,g.name);y(!1),x(t.kind===`refused`?t.reason:null)};return a(`div`,{className:`flex flex-col gap-4`,children:[u&&g.target.kind===`new`&&a(`div`,{className:`rounded-lg border border-border bg-surface p-4 flex flex-wrap gap-2`,"data-testid":`composition-templates`,children:[c(`span`,{className:`text-[11px] text-foreground-subtle self-center`,children:m(`compositionEditor.templates.label`)}),be.map(e=>c(M,{size:`sm`,variant:`outline`,onClick:()=>void S(e),children:m(`compositionEditor.templates.${e}`)},e))]}),c(gt,{draft:g,targetName:o,dispatch:_}),c(ht,{draft:g,deviceType:C,nativeCaps:s,targetFields:l,dispatch:_}),c(_t,{draft:g,blockId:t,saving:v,onSave:e=>void w(e),onCancel:p}),b!==null&&c(`p`,{role:`alert`,className:`text-[11px] text-danger break-words`,children:b})]})}export{ke as C,he as D,F as E,me as O,Oe as S,Te as T,J as _,Je as a,Me as b,Y as c,Pe as d,Ie as f,Re as g,Ve as h,nt as i,Ne as l,Be as m,ct as n,Z as o,ze as p,st as r,X as s,vt as t,K as u,Le as v,Ee as w,U as x,Ae as y};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{An as l,D as u,Fn as d,Gi as f,It as p,Jr as m,Nt as h,Q as g,Wr as _,Xi as v,Yi as y,Zr as b,ai as x,fn as S,ir as C,kn as w,or as T,pi as E,rr as D,si as O,vn as k,xi as A,yi as j}from"./player-overlays-D98Lvll4.js";import{n as M,t as N}from"./cloud-upload-_iPugQ2o.js";import{t as P}from"./circle-slash-DFnFtATu.js";import{t as F}from"./hard-drive-download-DobqoKaY.js";import{$n as I,Ai as ee,An as L,Ar as R,Au as z,Bi as te,Cl as ne,Dn as re,Fi as ie,Hi as ae,Ii as oe,Li as se,Ll as ce,Mi as le,Mn as ue,Ni as de,Pa as fe,Pi as pe,Qn as me,Ri as he,Sl as ge,Tu as _e,Ui as ve,Vi as ye,Wi as be,_n as xe,at as Se,dt as Ce,er as we,fr as Te,gn as Ee,hr as B,ir as De,ji as Oe,ju as V,ki as ke,kn as Ae,lt as je,nr as Me,pi as Ne,pr as Pe,rr as Fe,ul as Ie,ut as Le,vt as H,wl as Re,xl as ze,zi as Be}from"./src-MJ2k3G6o.js";import{t as U}from"./i18n-BuS8cl72.js";import{t as W}from"./useTranslation-D3Is_4B6.js";import"./mount-CVKD2t0V.js";import{$ as Ve,T as He,Z as Ue,nt as We}from"./index-CM1JjjBW.js";import{t as Ge}from"./AdminSectionedPage-DvK84QvU.js";import{t as Ke}from"./AdminPage-RJcN6Anu.js";import{n as qe}from"./authed-media-DubLoRPM.js";import{t as G}from"./format-size-DIxKXxtj.js";import{a as Je,c as Ye,l as Xe,n as Ze,o as Qe,s as $e,t as et,u as tt}from"./location-owned-usage-CScwnhi4.js";e();function nt(){let{t:e}=W(),r=s(),i=R(),{data:o,isLoading:l,isError:u}=Re({}),d=ne(),f=n(()=>d.data??[],[d.data]),{data:p}=Ie({},{refetchOnWindowFocus:!1}),m=n(()=>et(o??[],p?.locations),[o,p?.locations]),{data:h}=ge({},{refetchOnWindowFocus:!1}),g=n(()=>Je(h),[h]),{state:_,openNew:v,openEdit:y,close:b}=je(),[x,S]=Le(`type`),C=()=>{S(null),b()},w=e=>{S(e),v()},T=e=>{S(null),y(e.id)},E=o??[],D=_.mode===`edit`?E.find(e=>e.id===_.id)??null:null;t(()=>{_.mode===`new`&&(x===null||x===``)&&(S(null),b())},[_.mode,x,b,S]),t(()=>{_.mode===`edit`&&!l&&D===null&&(S(null),b())},[_.mode,l,D,b,S]),t(()=>{_.mode===`closed`&&x!==null&&S(null)},[_.mode,x,S]);let O=ze({onSuccess:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),k=ce({onSuccess:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),A=async(t,n)=>{Xe(n)&&!await i({title:e(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:t.displayName}),message:e(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Ye(n).consequence}),confirmLabel:e(`common.disable`,`Disable`),variant:`danger`})||k.mutate($e(t,{mode:n}))},j=async t=>{if(await i({title:e(`system.storage.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:t.displayName}),message:e(`system.storage.thisRemovesTheLocationRecord`,`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`}))try{await O.mutateAsync({id:t.id}),_.mode===`edit`&&_.id===t.id&&C()}catch(n){await i({title:e(`system.storage.deleteAnyway`,`Delete anyway?`),message:e(`system.storage.forcingNote`,{error:n instanceof Error?n.message:String(n)}),confirmLabel:e(`system.storage.forceDelete`,`Force delete`),variant:`danger`})&&O.mutate({id:t.id,force:!0},{onSuccess:()=>{_.mode===`edit`&&_.id===t.id&&C()}})}},M=n(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),N=l||d.isLoading,P=u||d.isError,F=_.mode===`new`&&x!==null&&x!==``,I=_.mode===`edit`&&D!==null;return a(Ke,{embedded:!0,children:[N&&c(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:e(`system.storage.loadingLocations`,`Loading locations…`)}),P&&c(`div`,{className:`text-xs text-danger`,children:e(`system.storage.failedToLoadStorageLocations`,`Failed to load storage locations.`)}),!N&&!P&&a(`div`,{className:`space-y-3`,children:[f.length===0&&c(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:e(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`)}),f.map(e=>c(Ze,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:M.get(e.id)??[],onAdd:w,onEdit:T,onDelete:e=>{j(e)},ownedBytesById:m,drainById:g,onSetMode:(e,t)=>{A(e,t)}},e.id))]}),F&&x!==null&&c(tt,{initialType:x,onClose:C,onCreated:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}}),I&&D!==null&&c(Qe,{location:D,onClose:C,onSaved:()=>{r.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),C()}})]})}var K={settings:{labelKey:`helpers.backupDatabases.settings.label`,descriptionKey:`helpers.backupDatabases.settings.description`,shortKey:`helpers.backupDatabases.settings.short`},events:{labelKey:`helpers.backupDatabases.events.label`,descriptionKey:`helpers.backupDatabases.events.description`,shortKey:`helpers.backupDatabases.events.short`},history:{labelKey:`helpers.backupDatabases.history.label`,descriptionKey:`helpers.backupDatabases.history.description`,shortKey:`helpers.backupDatabases.history.short`}},rt=Object.keys(K),q=[`settings`];function it(){return U.t(`helpers.backupDatabases.notCreated`)}function at(e){return U.t(K[e].labelKey)}function ot(e){return U.t(K[e].shortKey)}function st(e){return U.t(K[e].descriptionKey)}function J(e){let t=new Set(e);return rt.filter(e=>t.has(e))}function Y(e){return e!==void 0&&e.length>0?J(e):q}function ct(e){return J(e)}function lt(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function ut(e,t,n){return lt(e,t)===`absent`&&!n.has(e)}function dt(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function ft(e){return!e.includes(`settings`)}function pt(e){return{databases:[...ct(e)]}}function mt(e,t){return e!==void 0&&e.length>0?J(e):t!==void 0&&t.length>0?J(t.map(e=>e.databaseId??`settings`)):q}function X({databases:e}){return c(`span`,{className:`text-xs font-medium uppercase tracking-wide text-foreground-muted`,"data-testid":`backup-database-badges`,children:e.map(e=>ot(e)).join(` · `)})}e();var ht=[[`backup`,`listDestinations`]],gt=[`backup`,`listArchives`];function _t({destinationId:e,restoreSupported:t,onOpenRestoreWizard:o}){let{t:l}=W(),u=s(),d=R(),{data:f,isLoading:m,isError:h}=ie({destinationId:e}),g=f??[],v=ee({onSuccess:()=>{u.invalidateQueries({queryKey:[[...gt]]}),u.invalidateQueries({queryKey:ht})}}),y=i(async t=>{await d({title:l(`backup.archiveList.deleteThisArchive`,`Delete this archive?`),message:l(`backup.archiveList.permanentlyDeletesAndFrees`,`Permanently deletes "{{value1}}" and frees {{value2}}.`,{value1:t.label??t.id,value2:G(t.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&v.mutate({destinationId:e,backupId:t.id})},[d,e,v,l]),[b,x]=r(null),S=i(async t=>{x(t.id);try{let n=await qe(vt(e,t.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t.label??t.id}.tar.gz${t.encryption===void 0?``:`.csbk`}`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{x(null)}},[e]),C=n(()=>[...g].toSorted((e,t)=>t.createdAt-e.createdAt),[g]);return m?c(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):h?c(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):C.length===0?c(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)}):c(Ee,{columns:[{key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>c(`span`,{className:`tabular-nums`,children:yt(e.createdAt)})},{key:`label`,header:l(`backup.archiveList.label`,`Label`),sortValue:e=>e.label??null,render:e=>a(`span`,{className:`inline-flex items-center gap-1`,children:[e.encryption!==void 0&&c(D,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.archiveList.encryptedRestoreNeedsBackupKey`,`encrypted — restore needs backup key {{keyId}}`,{keyId:e.encryption.keyId})}),e.label??c(`span`,{className:`text-foreground-subtle italic`,children:`—`})]})},{key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>c(X,{databases:Y(e.databases)})},{key:`includes`,header:l(`backup.archiveList.files`,`Files`),nowrap:!1,notSortableReason:`Location list`,render:e=>e.locations.length>0?c(`span`,{className:`text-foreground-subtle`,children:e.locations.join(`, `)}):c(`span`,{className:`text-foreground-subtle italic`,children:l(`common.none`)})},{key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>c(`span`,{className:`tabular-nums`,children:G(e.sizeBytes)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:n=>a(`span`,{className:`flex items-center justify-end gap-1`,children:[a(B,{variant:`ghost`,size:`sm`,onClick:()=>{S(n)},disabled:b===n.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[b===n.id?c(T,{className:`h-3 w-3 animate-spin`}):c(_,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),t&&o&&a(B,{variant:`ghost`,size:`sm`,onClick:()=>o({destinationId:e,archiveId:n.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[c(k,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),c(V,{variant:`ghost`,size:`sm`,icon:p,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:n.label??n.id}),disabled:v.isPending,onClick:()=>{y(n)}})]})}],rows:C,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function vt(e,t){return g(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function yt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}e();var bt=[[`backup`,`listSchedules`]];function xt({onEdit:e,onOpenRestoreWizard:t}){let{t:o}=W(),{data:s,isLoading:l,isError:u,error:d,refetch:f}=Be(),p=s??[],m=se().data??[],h=n(()=>{let e=new Map;for(let t of m)e.set(t.id,t);return e},[m]),[g,_]=r(null),v=i(e=>{_(t=>t===e?null:e)},[]),y=n(()=>St({destById:h,expandedId:g,onToggleExpand:v,onEdit:e}),[h,g,v,e]);return l?a(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[c(T,{className:`h-3.5 w-3.5 animate-spin`}),o(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):u?c(Te,{title:o(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:d instanceof Error?d.message:o(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void f()}):p.length===0?c(Pe,{icon:M,title:o(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:o(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):c(Ee,{columns:y,rows:p,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:xe,emptyMessage:o(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:t=>e(t),isExpanded:e=>e.id===g,renderExpanded:e=>c(kt,{row:e,destById:h,...t?{onOpenRestoreWizard:t}:{}})})}function St(e){return[{key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:t=>{let n=e.expandedId===t.id;return c(V,{variant:`ghost`,size:`sm`,icon:n?A:j,"aria-label":n?U.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):U.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),e.onToggleExpand(t.id)}})}},{key:`entry`,header:U.t(`backup.backupEntriesTable.entry`,`Entry`),sortValue:e=>e.label,render:e=>a(`span`,{className:`flex min-w-0 flex-col`,children:[c(`span`,{className:`truncate font-medium text-foreground`,children:e.label||U.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),e.lastRunAt!==void 0&&c(`span`,{className:`text-[10px] text-foreground-subtle`,children:U.t(`backup.backupEntriesTable.lastRun`,{when:new Date(e.lastRunAt).toLocaleString()})})]})},{key:`enabled`,header:U.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>c(`span`,{onClick:e=>e.stopPropagation(),children:c(Et,{row:e})})},{key:`databases`,header:U.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>c(X,{databases:Y(e.databases)})},{key:`locations`,header:U.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:t=>c(Ct,{row:t,destById:e.destById})},{key:`retention`,header:U.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>c(`span`,{onClick:e=>e.stopPropagation(),children:c(Dt,{row:e})})},{key:`schedule`,header:U.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>c(wt,{row:e})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:t=>c(`span`,{onClick:e=>e.stopPropagation(),children:c(Ot,{row:t,onEdit:()=>e.onEdit(t)})})}]}function Ct({row:e,destById:t}){let{t:n}=W();return e.locationIds.length===0?c(`span`,{className:`text-[11px] italic text-danger`,children:n(`backup.backupEntriesTable.noLocations`,`No locations`)}):c(`span`,{className:`flex flex-wrap gap-1`,children:e.locationIds.map(e=>c(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))})}function wt({row:e}){let{t}=W(),n=e.cron.trim().length>0;return a(`span`,{className:`flex flex-col items-start gap-0.5`,children:[a(`span`,{className:`inline-flex items-center gap-1`,children:[c(M,{className:`h-3 w-3 text-foreground-subtle`}),c(`span`,{className:`font-mono text-[11px] text-foreground`,children:n?e.cron:t(`backup.backupEntriesTable.manual`,`Manual`)})]}),n&&e.nextRunAt!==void 0&&c(`span`,{className:`text-[10px] text-foreground-subtle`,children:U.t(`common.nextRun`,{when:new Date(e.nextRunAt).toLocaleString()})})]})}function Tt(e){return n(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{},...e.databases?{databases:[...e.databases]}:{}}),[e])}function Et({row:e}){let{t}=W(),n=s(),r=be({onSuccess:()=>{n.invalidateQueries({queryKey:bt})}}),i=Tt(e);return c(`label`,{className:`inline-flex cursor-pointer items-center`,children:c(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:r.isPending,onChange:e=>r.mutate({...i,enabled:e.target.checked}),"aria-label":t(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function Dt({row:e}){let{t:n}=W(),i=s(),a=be({onSuccess:()=>{i.invalidateQueries({queryKey:bt})}}),o=Tt(e),[l,u]=r(String(e.retentionCount));return t(()=>{u(String(e.retentionCount))},[e.retentionCount]),c(z,{type:`number`,min:1,max:1e3,value:l,disabled:a.isPending,onChange:e=>u(e.target.value),onBlur:()=>{let t=Number.parseInt(l,10);if(Number.isNaN(t)||t<1){u(String(e.retentionCount));return}t!==e.retentionCount&&a.mutate({...o,enabled:e.enabled,retentionCount:t})},onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&u(String(e.retentionCount))},className:`w-16`,"aria-label":n(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})}function Ot({row:e,onEdit:t}){let{t:n}=W(),r=s(),i=R(),o=Oe({onSuccess:()=>{r.invalidateQueries({queryKey:bt})}}),u=ve({onMutate:()=>{r.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{r.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),r.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),r.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),f=()=>{e.locationIds.length!==0&&u.mutate({destinations:[...e.locationIds],...e.dataSources&&e.dataSources.length>0?{locations:[...e.dataSources]}:{},label:e.label,retentionCount:e.retentionCount,databases:[...Y(e.databases)]})},m=async()=>{await i({title:n(`backup.backupEntriesTable.deleteBackupEntry`,`Delete backup entry?`),message:n(`backup.backupEntriesTable.willStopRunningExistingArchives`,`"{{value1}}" will stop running. Existing archives are kept.`,{value1:e.label||e.id}),confirmLabel:n(`common.delete`,`Delete`),variant:`warning`})&&o.mutate({id:e.id})};return a(`span`,{className:`flex items-center justify-end gap-1.5`,children:[a(B,{size:`sm`,type:`button`,onClick:f,disabled:u.isPending||e.locationIds.length===0,title:n(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[u.isPending?c(T,{className:`h-3 w-3 animate-spin`}):c(l,{className:`h-3 w-3`}),n(`backup.backupEntriesTable.runNow`,`Run now`)]}),c(V,{variant:`ghost`,size:`sm`,icon:d,"aria-label":n(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:e.label||e.id}),onClick:t}),c(V,{variant:`ghost`,size:`sm`,icon:p,"aria-label":n(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:e.label||e.id}),disabled:o.isPending,onClick:()=>{m()}})]})}function kt({row:e,destById:t,onOpenRestoreWizard:n}){let{t:r}=W();return a(`div`,{className:`space-y-4 rounded-lg border border-border bg-background/30 px-4 py-3`,children:[c(`p`,{className:`text-[11px] font-medium text-foreground-subtle`,children:r(`backup.backupEntriesTable.archivesFor`,{name:e.label||e.id})}),e.locationIds.length===0&&c(`p`,{className:`text-xs italic text-foreground-subtle`,children:r(`backup.backupEntriesTable.thisEntryHasNoLocations`,`This entry has no locations selected.`)}),e.locationIds.map(e=>a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:t.get(e)?.displayName??e}),c(_t,{destinationId:e,restoreSupported:t.get(e)?.restoreSupported??!0,...n?{onOpenRestoreWizard:n}:{}})]},e))]})}function At({selected:e,onChange:t,disabled:n=!1,testId:r=`backup-databases`}){let{t:i}=W(),o=oe().data,s=e.size>0&&ft(J(e)),l=e.size===0?`Pick at least one.`:s?`Snapshots only: configuration and files are not part of this backup.`:null;return c(H,{label:i(`backup.backupDatabasePicker.whatToBackUp`,`What to back up`),required:!0,...l===null?{}:{description:l},children:c(`div`,{className:`divide-y divide-border rounded border border-border bg-background`,"data-testid":r,children:rt.map(i=>{let s=lt(i,o),l=n||ut(i,o,e);return a(`label`,{className:`flex items-start gap-2 px-3 py-2 text-xs ${l?`opacity-60`:`cursor-pointer hover:bg-primary/5`}`,children:[c(ue,{checked:e.has(i),disabled:l,onChange:()=>t(dt(e,i)),"data-testid":`${r}-${i}`}),a(`span`,{className:`min-w-0 flex-1`,children:[c(`span`,{className:`flex flex-wrap items-center gap-1.5 text-foreground`,children:at(i)}),c(`span`,{className:`block text-[11px] text-foreground-subtle`,children:s===`absent`?it():st(i)})]})]},i)})})})}e();function jt({onClose:e}){let{t}=W(),n=s(),[i,o]=r(new Set(q)),u=ve({onMutate:()=>{n.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{n.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),n.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),n.invalidateQueries({queryKey:[[`backup`,`listRuns`]]}),e()}});return c(me,{open:!0,onOpenChange:t=>!t&&e(),children:a(we,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(Fe,{children:[c(De,{children:t(`backup.backupNowDialog.backUpNow`,`Back up now`)}),c(`p`,{className:`text-xs text-foreground-subtle`,children:t(`backup.backupNowDialog.runsOnceAndWritesThe`,`Runs once and writes the archive to every enabled backup location.`)})]}),c(I,{children:a(`div`,{className:`p-4`,children:[c(At,{selected:i,onChange:o,disabled:u.isPending,testId:`backup-now-databases`}),u.error&&c(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:u.error.message})]})}),a(Me,{children:[c(B,{variant:`outline`,size:`sm`,onClick:e,children:t(`common.cancel`,`Cancel`)}),a(B,{size:`sm`,onClick:()=>{i.size!==0&&u.mutate(pt(i))},disabled:i.size===0||u.isPending,"data-testid":`backup-now-run`,children:[u.isPending?c(T,{className:`h-3.5 w-3.5 animate-spin`}):c(l,{className:`h-3.5 w-3.5`}),t(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}e();function Z(e){return e===null?`—`:new Date(e).toLocaleString()}function Mt(e){let t=new Blob([`${e.secretKey}\n`],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`camstack-backup-key-${e.keyId}.txt`,r.click(),URL.revokeObjectURL(n)}function Nt({revealed:e,onDone:t}){let{t:n}=W(),[i,o]=r(!1),[s,l]=r(!1);return c(me,{open:!0,onOpenChange:e=>!e&&i&&t(),children:a(we,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[c(Fe,{children:c(De,{id:`backup-key-title`,children:n(`backup.encryptionCard.yourKey`,{keyId:e.keyId})})}),a(I,{className:`space-y-3`,children:[a(`p`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 p-2 text-xs text-foreground`,children:[c(h,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),c(`span`,{children:n(`backup.backupEncryptionCard.thisKeyIsShownOnly`,`This key is shown only once. CamStack does not keep it — not the hub, not its database, not its backups. Without it, an encrypted backup cannot be restored by anyone, including you. Store it in a password manager or print it, away from this server.`)})]}),c(`div`,{className:`break-all rounded-md border border-border bg-background p-2 font-mono text-xs text-foreground select-all`,children:e.secretKey}),a(`div`,{className:`flex flex-wrap gap-2`,children:[a(B,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(e.secretKey).then(()=>l(!0))},children:[c(b,{className:`mr-1 h-3.5 w-3.5`}),s?n(`backup.backupEncryptionCard.copied`,`Copied`):n(`common.copy`,`Copy`)]}),a(B,{size:`sm`,variant:`outline`,onClick:()=>Mt(e),children:[c(_,{className:`mr-1 h-3.5 w-3.5`}),n(`backup.backupEncryptionCard.downloadAsFile`,`Download as file`)]})]}),a(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[c(`input`,{type:`checkbox`,checked:i,onChange:e=>o(e.target.checked),className:`accent-primary`}),n(`backup.backupEncryptionCard.iHaveStoredThisKey`,`I have stored this key somewhere safe, off this server.`)]})]}),c(Me,{children:c(B,{size:`sm`,disabled:!i,onClick:t,children:n(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function Pt(){let{t:e}=W(),t=de(),n=ae(),i=le(),s=R(),[l,u]=r(null),[d,f]=r(null),p=t.data?.enabled??!1,m=t.data?.active??null,h=(t.data?.keys??[]).filter(e=>e.retiredAt!==null),g=async()=>{if(await s({title:p?e(`backup.backupEncryptionCard.replaceTheBackupKey`,`Replace the backup key`):e(`backup.backupEncryptionCard.encryptBackups`,`Encrypt backups`),message:p?e(`backup.backupEncryptionCard.aNewKeyIsGenerated`,`A new key is generated and shown once; new backups are encrypted to it. Older backups keep needing the key they were made with — keep that one too.`):e(`backup.backupEncryptionCard.aBackupKeyIsGenerated`,`A backup key is generated and shown once. Every new backup is encrypted to it, and restoring one will ask for it. Existing backups stay as they are.`),confirmLabel:p?e(`backup.backupEncryptionCard.generateANewKey`,`Generate a new key`):e(`backup.backupEncryptionCard.generateTheKey`,`Generate the key`),variant:`warning`})){f(null);try{let e=await n.mutateAsync({});u({keyId:e.keyId,secretKey:e.secretKey})}catch(e){f(e instanceof Error?e.message:String(e))}}},_=async()=>{if(await s({title:e(`backup.backupEncryptionCard.turnBackupEncryptionOff`,`Turn backup encryption off`),message:e(`backup.backupEncryptionCard.newBackupsWillBeWritten`,`New backups will be written unencrypted. Existing encrypted backups still need their key to be restored.`),confirmLabel:e(`backup.backupEncryptionCard.turnOff`,`Turn off`),variant:`danger`})){f(null);try{await i.mutateAsync({}),t.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}};return a(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-4`,children:[a(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[a(`div`,{className:`flex items-center gap-2`,children:[p?c(D,{className:`h-4 w-4 text-success`}):c(C,{className:`h-4 w-4 text-foreground-subtle`}),c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`backup.backupEncryptionCard.encryption`,`Encryption`)}),c(`span`,{className:`text-xs text-foreground-subtle`,children:p&&m!==null?e(`backup.backupEncryptionCard.onKeySince`,`On — key {{keyId}}, since {{value2}}`,{keyId:m.keyId,value2:Z(m.createdAt)}):e(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),c(`div`,{className:`flex gap-2`,children:p?a(o,{children:[c(B,{size:`sm`,variant:`outline`,disabled:n.isPending,onClick:()=>void g(),children:e(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),c(B,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void _(),children:e(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):c(B,{size:`sm`,disabled:n.isPending,onClick:()=>void g(),children:e(`backup.backupEncryptionCard.enableEncryption`,`Enable encryption`)})})]}),c(`p`,{className:`text-xs text-foreground-subtle`,children:e(`backup.backupEncryptionCard.archivesAreEncryptedOnThis`,`Archives are encrypted on this server before they reach any destination. The server keeps only a public key, so it can encrypt scheduled backups but cannot decrypt them — only your backup key can. Covers the database snapshot, config.yaml, addon data (HomeKit pairing, Matter fabric, Tailscale state) and TLS.`)}),h.length>0&&a(`div`,{className:`text-xs`,children:[c(`p`,{className:`text-foreground-subtle`,children:e(`backup.backupEncryptionCard.olderKeysBackupsMadeWith`,`Older keys (backups made with them still need them):`)}),c(`ul`,{className:`font-mono text-foreground`,children:h.map(e=>a(`li`,{children:[e.keyId,` · `,Z(e.createdAt),` → `,Z(e.retiredAt)]},e.keyId))})]}),d!==null&&c(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&c(Nt,{revealed:l,onDone:()=>{u(null),t.refetch()}})]})}e();var Ft=[{id:`manual`,labelKey:`backup.cronEditor.presetManual`,cron:``},{id:`hourly`,labelKey:`backup.cronEditor.presetHourly`,cron:`0 * * * *`,descriptionKey:`backup.cronEditor.presetHourlyDesc`},{id:`every-3h`,labelKey:`backup.cronEditor.preset3h`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,labelKey:`backup.cronEditor.preset6h`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,labelKey:`backup.cronEditor.presetDaily`,cron:`0 3 * * *`,descriptionKey:`backup.cronEditor.presetDailyDesc`},{id:`weekly-sun`,labelKey:`backup.cronEditor.presetWeekly`,cron:`0 3 * * 0`,descriptionKey:`backup.cronEditor.presetWeeklyDesc`}];function It(e){let t=e.trim();for(let e of Ft)if(e.cron===t)return e.id;return`custom`}function Lt({value:e,onChange:n,previewCount:i=5,disabled:o=!1}){let{t:s}=W(),l=It(e),[u,d]=r(l===`custom`);t(()=>{l!==`custom`&&d(!1)},[l]);let f=Bt(e,250),p=te({cron:f,count:i},{enabled:f.trim().length>0}),m=p.data??null,h=e=>{d(!1),n(e.cron)},g=u||l===`custom`;return a(`div`,{className:`space-y-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.cronEditor.schedulePreset`,`Schedule preset`)}),a(`div`,{className:`flex flex-wrap gap-1.5`,children:[Ft.map(e=>c(`button`,{type:`button`,onClick:()=>h(e),disabled:o,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!u&&l===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.descriptionKey===void 0?e.description??s(e.labelKey):s(e.descriptionKey),children:s(e.labelKey)},e.id)),c(`button`,{type:`button`,onClick:()=>{d(!0),e.trim().length===0&&n(`0 3 * * *`)},disabled:o,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(g?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:s(`backup.cronEditor.custom`,`Custom…`)})]})]}),g&&a(`div`,{className:`space-y-1`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.cronEditor.cronExpression5FieldPosix`,`Cron expression (5-field POSIX)`)}),c(`input`,{type:`text`,value:e,onChange:e=>n(e.target.value),disabled:o,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),a(`p`,{className:`text-[10px] text-foreground-subtle`,children:[s(`backup.cronEditor.format`,`Format:`),` `,c(Ue,{i18nKey:`backup.cronEditor.formatLine`,components:{code:c(`span`,{className:`font-mono`})}})]})]}),c(Rt,{cron:f,preview:m,loading:p.isFetching})]})}function Rt({cron:e,preview:t,loading:n}){let{t:r}=W();return n&&t===null?a(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[c(T,{className:`h-3 w-3 animate-spin`}),r(`backup.cronEditor.validating`,`Validating…`)]}):t===null?null:t.ok?t.nextRuns.length===0?c(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:r(`backup.cronEditor.noFutureRunsMatchThis`,`No future runs match this expression.`)}):a(`div`,{className:`space-y-1`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:r(`backup.cronEditor.nextRuns`,`Next runs`)}),c(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>a(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[c(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),c(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:zt(e)})]},`${e}-${t}`))})]}):c(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??r(`backup.cronEditor.invalidCronExpression`,`Invalid cron expression`)})}function zt(e){let t=e-Date.now();if(t<=0)return U.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return U.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return U.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return U.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return U.t(`helpers.relativeTime.inDays`,{count:a})}function Bt(e,i){let[a,o]=r(e),s=n(()=>e,[e]);return t(()=>{let e=setTimeout(()=>o(s),i);return()=>clearTimeout(e)},[s,i]),a}e();var Vt=[[`backup`,`listSchedules`]];function Ht({entry:e,onClose:t,onSaved:i}){let{t:o}=W(),l=s(),u=se(),d=u.data??[],[f,p]=r(e?.label??``),[m,h]=r(e?.cron??`0 3 * * *`),[g,_]=r(e?.enabled??!0),[v,y]=r(String(e?.retentionCount??7)),[b,x]=r(new Set(e?.locationIds??[])),[S,C]=r(new Set(e===null?q:Y(e.databases))),w=be({onSuccess:()=>{l.invalidateQueries({queryKey:Vt}),i()}}),E=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=Number.parseInt(v,10),O=n(()=>f.trim().length>0&&b.size>0&&S.size>0&&!Number.isNaN(D)&&D>=1&&D<=1e3,[f,b,S,D]),k=()=>{O&&w.mutate({...e?{id:e.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(b),retentionCount:D,databases:[...ct(S)]})},A=w.error instanceof Error?w.error.message:null;return c(Ce,{open:!0,onClose:t,title:e?o(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):o(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:M,error:A,width:`lg`,testId:`backup-entry-form`,footer:a(B,{size:`sm`,type:`button`,onClick:k,disabled:!O||w.isPending,children:[w.isPending?c(T,{className:`h-3.5 w-3.5 animate-spin`}):null,e?o(`common.save`,`Save`):o(`backup.backupEntryModal.createEntry`,`Create entry`)]}),children:a(`div`,{className:`space-y-4`,children:[c(H,{label:o(`backup.backupEntryModal.name`,`Name`),required:!0,children:c(z,{value:f,onChange:e=>p(e.target.value),placeholder:o(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),a(H,{label:o(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(b.size)}),required:!0,children:[u.isLoading&&a(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[c(T,{className:`h-3.5 w-3.5 animate-spin`}),o(`backup.backupEntryModal.loadingLocations`,`Loading locations…`)]}),!u.isLoading&&d.length===0&&c(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:o(`backup.backupEntryModal.noBackupsStorageLocationsConfigured`,"No `backups` storage locations configured. Add one in Settings → Storage first.")}),d.length>0&&c(`div`,{className:`max-h-52 divide-y divide-border overflow-y-auto rounded border border-border bg-background`,children:d.map(e=>a(`label`,{className:`flex cursor-pointer items-center justify-between px-3 py-2 text-xs hover:bg-primary/5`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(`input`,{type:`checkbox`,checked:b.has(e.id),onChange:()=>E(e.id),className:`accent-primary`}),c(`span`,{className:`text-foreground`,children:e.displayName})]}),a(`div`,{className:`flex items-center gap-1.5`,children:[c(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.kind}),c(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.id})]})]},e.id))})]}),c(At,{selected:S,onChange:C,disabled:w.isPending,testId:`backup-entry-databases`}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[c(H,{label:o(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:c(z,{type:`number`,min:1,max:1e3,value:v,onChange:e=>y(e.target.value),"data-testid":`backup-entry-retention`})}),c(H,{label:o(`backup.backupEntryModal.enabled`,`Enabled`),description:o(`backup.backupEntryModal.runOnScheduleWhenChecked`,`Run on schedule when checked.`),children:a(`label`,{className:`inline-flex cursor-pointer items-center gap-2 py-1.5 text-xs text-foreground`,children:[c(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`,"data-testid":`backup-entry-enabled`}),c(`span`,{children:o(`backup.backupEntryModal.runOnSchedule`,`Run on schedule`)})]})})]}),c(H,{label:o(`backup.backupEntryModal.schedule`,`Schedule`),children:c(Lt,{value:m,onChange:h,disabled:w.isPending})})]})})}e();var Ut=2e3,Wt=5e3;function Q(e){return e.state===`queued`||e.state===`running`}function Gt(e){if(e.state===`queued`)return{title:U.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:U.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:U.t(`backup.backupRunsPanel.cancelRun`,`Cancel run`),variant:`warning`};let t=e.completedDestinationIds.length,n=t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`;return{title:U.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:U.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:U.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function Kt(){let e=R(),[t,n]=r(null),a=he(void 0,{refetchInterval:e=>(e.state.data??[]).some(Q)?Ut:Wt}),o=ke({onSettled:()=>{n(null),a.refetch()}}),s=i(async t=>{await e(Gt(t))&&(n(t.id),o.mutate({runId:t.id}))},[e,o]);return c(qt,{queryState:a.isError?`error`:a.data===void 0?`pending`:`ready`,runs:a.data??[],cancelingId:t,onCancelRequest:e=>{s(e)},now:Date.now()})}function qt({queryState:e,runs:t,cancelingId:n,onCancelRequest:r,now:i}){let{t:o}=W(),s=e===`ready`&&t.some(Q),l=t.filter(e=>e.state===`running`),u=t.filter(e=>e.state===`queued`),d=t.filter(e=>!Q(e)),f=[...l,...u,...d];return a(`section`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[c(`h2`,{className:`text-xs font-semibold text-foreground`,children:o(`backup.backupRunsPanel.runs`,`Runs`)}),s&&a(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:o(`backup.backupRunsPanel.aBackupRunIsIn`,`A backup run is in progress`),children:[c(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),o(`backup.runsPanel.live`)]}),c(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:o(`backup.backupRunsPanel.oneRunExecutesAtA`,`One run executes at a time — queued runs wait in line.`)})]}),e===`pending`&&c(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:o(`backup.backupRunsPanel.checkingForBackupRuns`,`Checking for backup runs…`)}),e===`error`&&c(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:o(`backup.backupRunsPanel.couldNotReadBackupRuns`,`Could not read backup runs — the orchestrator did not answer.`)}),e===`ready`&&t.length===0&&c(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:o(`backup.backupRunsPanel.noBackupRunsYetRuns`,`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`)}),e===`ready`&&t.length>0&&c(`div`,{className:`overflow-x-auto`,children:a(`table`,{className:`w-full text-xs min-w-[720px]`,children:[c(`thead`,{children:a(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.run`,`Run`)}),c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.state`,`State`)}),c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.progress`,`Progress`)}),c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.destinations`,`Destinations`)}),c(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:o(`backup.backupRunsPanel.timing`,`Timing`)}),c(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:o(`backup.backupRunsPanel.actions`,`Actions`)})]})}),c(`tbody`,{children:f.map(e=>c(Jt,{run:e,canceling:n===e.id,onCancelRequest:r,now:i},e.id))})]})})]})}function Jt({run:e,canceling:t,onCancelRequest:n,now:r}){let{t:i}=W(),o=Q(e);return a(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[c(`td`,{className:`px-3 py-2`,children:c(`div`,{className:`text-foreground`,title:e.id,children:e.label??c(`span`,{className:`text-foreground-subtle italic`,children:i(`backup.runsPanel.manual`)})})}),a(`td`,{className:`px-3 py-2`,children:[c(Yt,{run:e}),e.state===`failed`&&e.error!==void 0&&c(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:e.error,children:e.error})]}),c(`td`,{className:`px-3 py-2`,children:c(Xt,{run:e})}),c(`td`,{className:`px-3 py-2`,children:c(Zt,{run:e})}),c(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:c(Qt,{run:e,now:r})}),c(`td`,{className:`px-3 py-2`,children:c(`div`,{className:`flex justify-end`,children:o&&a(`button`,{onClick:()=>n(e),disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:e.state===`queued`?i(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):i(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[t?c(T,{className:`h-3 w-3 animate-spin`}):c(f,{className:`h-3 w-3`}),e.state===`queued`?i(`common.cancel`,`Cancel`):i(`backup.backupRunsPanel.stop`,`Stop`)]})})})]})}function Yt({run:e}){let{t}=W();switch(e.state){case`queued`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[c(x,{className:`h-3 w-3`}),t(`backup.backupRunsPanel.queued`,`Queued`)]});case`running`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[c(T,{className:`h-3 w-3 animate-spin`}),e.phase===`uploading`?t(`backup.backupRunsPanel.uploading`,`Uploading`):t(`backup.backupRunsPanel.buildingArchive`,`Building archive`)]});case`succeeded`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[c(E,{className:`h-3 w-3`}),t(`backup.backupRunsPanel.succeeded`,`Succeeded`)]});case`failed`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[c(O,{className:`h-3 w-3`}),t(`backup.backupRunsPanel.failed`,`Failed`)]});case`cancelled`:return a(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:t(`backup.backupRunsPanel.stoppedBeforeCompletingEveryDestination`,`Stopped before completing every destination — not a success`),children:[c(P,{className:`h-3 w-3`}),t(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function Xt({run:e}){let{t}=W();if(e.state===`queued`)return c(`span`,{className:`text-foreground-subtle`,children:e.queuePosition===void 0?c(`span`,{className:`italic`,children:t(`backup.backupRunsPanel.waitingItsTurn`,`waiting its turn`)}):a(`span`,{className:`inline-flex items-center gap-1`,children:[c(`span`,{className:e.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:$t(e.queuePosition)}),t(`backup.backupRunsPanel.inLine`,`in line`)]})});if(e.state===`running`&&e.phase===`building`)return a(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[c(F,{className:`h-3 w-3 text-primary`}),c(`span`,{className:`tabular-nums font-medium animate-pulse`,children:G(e.stagedBytes)}),c(`span`,{className:`text-foreground-subtle`,children:t(`backup.backupRunsPanel.stagedSoFar`,`staged so far`)})]});if(e.state===`running`){let n=e.archiveSizeBytes;return a(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[c(N,{className:`h-3 w-3 text-primary`}),a(`span`,{className:`tabular-nums font-medium`,children:[G(e.uploadedBytes),n===void 0?``:` / ${G(n)}`]}),c(`span`,{className:`text-foreground-subtle`,children:t(`backup.backupRunsPanel.toCurrentDestination`,`to current destination`)})]})}let n=e.archiveSizeBytes??(e.stagedBytes>0?e.stagedBytes:void 0);return n===void 0?c(`span`,{className:`text-foreground-subtle italic`,children:`—`}):c(`span`,{className:`tabular-nums text-foreground`,children:t(`backup.runsPanel.archiveSize`,{size:G(n)})})}function Zt({run:e}){let{t}=W(),n=e.destinationIds.length,r=e.completedDestinationIds.length,i=e.failedDestinationIds.length;return n===0?c(`span`,{className:`text-foreground-subtle italic`,children:t(`backup.backupRunsPanel.notResolvedYet`,`not resolved yet`)}):a(`div`,{className:`flex flex-col gap-0.5`,children:[c(`span`,{className:`text-foreground-subtle`,title:e.destinationIds.join(`, `),children:t(`backup.runsPanel.targets`,{count:n})}),a(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[r>0&&c(`span`,{className:`text-success`,title:t(`backup.backupRunsPanel.keptTheirArchive`,`Kept their archive: {{value1}}`,{value1:e.completedDestinationIds.join(`, `)}),children:t(`backup.runsPanel.completed`,{count:r})}),i>0&&c(`span`,{className:`text-danger`,title:t(`backup.backupRunsPanel.failed2`,`Failed: {{value1}}`,{value1:e.failedDestinationIds.join(`, `)}),children:t(`backup.runsPanel.failedCount`,{count:i})})]})]})}function Qt({run:e,now:t}){let{t:n}=W();return e.state===`queued`?c(`span`,{children:n(`backup.runsPanel.queuedAgo`,{elapsed:en(t-e.requestedAt)})}):e.startedAt===void 0?c(`span`,{children:`—`}):e.finishedAt===void 0?c(`span`,{children:n(`backup.runsPanel.runningFor`,{elapsed:en(t-e.startedAt)})}):a(`div`,{className:`flex flex-col gap-0.5`,children:[c(`span`,{children:tn(e.finishedAt)}),c(`span`,{className:`text-[10px]`,children:n(`backup.runsPanel.took`,{elapsed:en(e.finishedAt-e.startedAt)})})]})}function $t(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function en(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function tn(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}e();var nn=[[`backup`,`list`]];function rn({initialDestinationId:e,initialArchiveId:i,onClose:o,onScheduled:l}){let{t:u}=W(),d=s(),[f,p]=r(e&&i?2:1),[m,h]=r(e),[g,_]=r(i),[b,x]=r(new Set),[S,C]=r(``),{data:w}=se(),E=w??[],{data:D,isLoading:O}=ie({destinationId:m??``},{enabled:!!m}),A=D??[];t(()=>{if(m!==void 0)return;let e=E.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,E]);let{data:j}=pe({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),M=n(()=>j?.locations??[],[j]);t(()=>{M.length!==0&&x(e=>e.size===0?new Set(M):e)},[M]);let N=ye({onSuccess:()=>{d.invalidateQueries({queryKey:nn}),l(),o()}}),P=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=A.find(e=>e.id===g),ee=F?.encryption!==void 0,L=mt(F?.databases,j?.sqliteSnapshots),R=ft(L),z=!!m&&!!g,te=R||b.size>0,ne=z&&te&&!N.isPending&&(!ee||S.trim().length>0),re=()=>{!m||!g||N.mutate({destinationId:m,backupId:g,...R?{}:{locations:[...b]},...ee?{backupSecretKey:S.trim()}:{}})};return c(me,{open:!0,onOpenChange:e=>!e&&o(),children:a(we,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(Fe,{children:[c(De,{children:u(`backup.restoreWizard.restoreBackup`,`Restore Backup`)}),c(`p`,{className:`text-xs text-foreground-subtle`,children:u(`backup.restoreWizard.stepOf`,{step:f,name:f===1?u(`backup.restoreWizard.pickSource`,`pick source`):f===2?u(`backup.restoreWizard.pickLocations`,`pick locations`):u(`backup.restoreWizard.confirmStep`)})})]}),a(I,{children:[f===1&&c(an,{destinations:E,destinationId:m,onPickDestination:e=>{h(e),_(void 0),x(new Set)},archives:A,archivesLoading:O,archiveId:g,onPickArchive:_}),f===2&&c(on,{locations:M,picked:b,onToggle:P,databases:L,snapshotsOnly:R}),f===3&&c(sn,{destinationName:E.find(e=>e.id===m)?.displayName??m??``,archive:F,picked:[...b],databases:L,snapshotsOnly:R}),f===3&&F?.encryption!==void 0&&c(cn,{keyId:F.encryption.keyId,value:S,onChange:C}),f===3&&N.error&&c(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:N.error.message})]}),a(Me,{className:`justify-between`,children:[c(`div`,{children:f>1&&a(B,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[c(v,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),a(`div`,{className:`flex items-center gap-2`,children:[c(B,{variant:`outline`,size:`sm`,onClick:o,children:u(`common.cancel`,`Cancel`)}),f<3?a(B,{size:`sm`,disabled:f===1&&!z||f===2&&!te,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),c(y,{className:`h-3 w-3`})]}):a(B,{size:`sm`,onClick:re,disabled:!ne,children:[N.isPending?c(T,{className:`h-3.5 w-3.5 animate-spin`}):c(k,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function an({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:o,onPickArchive:s}){let{t:l}=W(),u=e.filter(e=>e.restoreSupported);return a(`div`,{className:`p-4 space-y-3`,children:[a(`div`,{className:`space-y-1.5`,children:[c(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.destination`,`Destination`)}),c(_e,{value:t??``,onChange:e=>n(e.target.value),options:[{value:``,label:l(`backup.restoreWizard.selectDestination`,`Select destination…`)},...u.map(e=>({value:e.id,label:`${e.displayName} (${e.kind})`}))]})]}),a(`div`,{className:`space-y-1.5`,children:[c(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.archive`,`Archive`)}),!t&&c(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.pickADestinationFirst`,`Pick a destination first.`)}),t&&i&&c(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:l(`backup.restoreWizard.readingArchives`,`Reading archives…`)}),t&&!i&&r.length===0&&c(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.noArchivesAvailableAtThis`,`No archives available at this destination.`)}),t&&r.length>0&&c(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=o===e.id;return a(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>s(e.id),className:`accent-primary`}),a(`div`,{children:[a(`div`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[e.encryption!==void 0&&c(D,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.restoreWizard.encryptedKey`,`encrypted (key {{keyId}})`,{keyId:e.encryption.keyId})}),e.label??e.id]}),c(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()}),c(`div`,{className:`pt-1`,children:c(X,{databases:mt(e.databases,void 0)})})]})]}),c(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:G(e.sizeBytes)})]},e.id)})})]})]})}function on({locations:e,picked:t,onToggle:n,databases:r,snapshotsOnly:i}){let{t:o}=W();return i?a(`div`,{className:`space-y-3 p-4`,children:[a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),c(X,{databases:r})]}),c(`div`,{className:`rounded border border-info/30 bg-info/10 px-3 py-2 text-[11px] text-info`,children:o(`backup.restoreWizard.snapshotsOnlyRestoringThisArchive`,`Snapshots only: restoring this archive replaces just these databases. It does NOT touch configuration, addons, addon data or certificates.`)})]}):e.length===0?c(`div`,{className:`p-4`,children:c(`div`,{className:`text-xs text-foreground-subtle`,children:o(`backup.restoreWizard.loadingArchiveManifestIfThis`,`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`)})}):a(`div`,{className:`p-4 space-y-3`,children:[a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),c(X,{databases:r})]}),c(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:o(`backup.restoreWizard.selectedEntriesWillOverwriteLive`,`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`)}),a(`div`,{className:`space-y-1.5`,children:[c(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:o(`common.apply`,`Apply`)}),c(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>a(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[c(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),c(`span`,{className:`font-mono text-foreground`,children:e}),c(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:un(e)})]},e))})]})]})}function sn({destinationName:e,archive:t,picked:n,databases:r,snapshotsOnly:i}){let{t:o}=W();return a(`div`,{className:`p-4 space-y-3 text-xs`,children:[c(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-warning`,children:o(`backup.restoreWizard.restoreIsAppliedAtNext`,`Restore is applied at next server boot. Active connections will drop when you restart.`)}),a(`dl`,{className:`space-y-1.5`,children:[c($,{term:`Destination`,value:e}),c($,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&c($,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${G(t.sizeBytes)}`}),a(`div`,{className:`flex justify-between gap-3`,children:[c(`dt`,{className:`text-foreground-subtle`,children:`Databases`}),c(`dd`,{className:`text-right`,children:c(X,{databases:r})})]}),c($,{term:`Locations`,value:i?`none (configuration is not touched)`:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function cn({keyId:e,value:t,onChange:n}){let{t:r}=W();return a(`div`,{className:`space-y-1.5 px-4 pb-3`,children:[c(`label`,{htmlFor:`restore-backup-key`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:r(`backup.restoreWizard.backupKey`,`Backup key`)}),c(`input`,{id:`restore-backup-key`,type:`password`,autoComplete:`off`,spellCheck:!1,value:t,onChange:e=>n(e.target.value),placeholder:r(`backup.restoreWizard.camstackBackupSecretV1`,`camstack-backup-secret-v1:…`),className:`w-full rounded border border-border bg-background px-2 py-1.5 font-mono text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),c(`p`,{className:`text-[11px] text-foreground-subtle`,children:c(Ue,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:e},components:{mono:c(`span`,{className:`font-mono`})}})})]})}function $({term:e,value:t}){return a(`div`,{className:`flex justify-between gap-3`,children:[c(`dt`,{className:`text-foreground-subtle`,children:e}),c(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var ln={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function un(e){return ln[e]??``}e();function dn(){let{t:e}=W(),n=R(),i=Ne(),{state:o,openNew:s,openEdit:u,close:d}=je({editKey:`edit`,newKey:`new`}),f=Be(),p=f.data??[],[m,h]=r(null),[g,_]=r(!1),[v,y]=r(!1),[b,x]=r(!1),S=o.mode===`edit`?p.find(e=>e.id===o.id)??null:null;t(()=>{o.mode===`edit`&&!f.isLoading&&S===null&&d()},[o.mode,f.isLoading,S,d]);let C=o.mode===`new`||o.mode===`edit`&&S!==null,E=async()=>{await n({title:e(`system.backup.restartServerNow`,`Restart server now?`),message:e(`system.backup.activeConnectionsWillDropAnd`,`Active connections will drop and the apply-backup hook will run before boot.`),confirmLabel:e(`system.backup.restart`,`Restart`),variant:`warning`})&&i.mutate({confirm:!0})};return a(Ke,{embedded:!0,children:[a(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[a(B,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>x(!0),"data-testid":`backup-now`,children:[c(l,{className:`h-3.5 w-3.5`}),e(`system.backup.backUpNow`,`Back up now`)]}),a(B,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>_(!0),children:[c(k,{className:`h-3.5 w-3.5`}),e(`system.backup.restore`,`Restore…`)]}),a(B,{size:`sm`,type:`button`,onClick:s,"data-testid":`backup-new-entry`,children:[c(w,{className:`h-3.5 w-3.5`}),e(`system.backup.newEntry`,`New entry`)]})]}),v&&c(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2.5 text-xs text-warning`,children:a(`div`,{className:`flex items-center justify-between gap-3`,children:[a(`div`,{className:`flex items-center gap-2`,children:[c(k,{className:`h-3.5 w-3.5`}),c(`span`,{children:e(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),a(B,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{E()},disabled:i.isPending,children:[i.isPending?c(T,{className:`h-3.5 w-3.5 animate-spin`}):c(k,{className:`h-3.5 w-3.5`}),e(`system.backup.restartNow`,`Restart Now`)]})]})}),c(Pt,{}),c(Kt,{}),c(xt,{onEdit:e=>u(e.id),onOpenRestoreWizard:e=>h(e)}),C&&c(Ht,{entry:S,onClose:d,onSaved:d}),b&&c(jt,{onClose:()=>x(!1)}),(m||g)&&c(rn,{...m?{initialDestinationId:m.destinationId,initialArchiveId:m.archiveId}:{},onClose:()=>{h(null),_(!1)},onScheduled:()=>y(!0)})]})}e();function fn(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function pn(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function mn(){let{t:e}=W(),t=R(),n=fe(),[i,s]=r(null),[l,u]=r(null),d=async e=>{u(null);try{s(await n.mutateAsync({confirm:e}))}catch(e){u(e instanceof Error?e.message:String(e))}},f=async()=>{i===null||i.status!==`dry-run`||await t({title:e(`systemPage.deletedDevices.confirmTitle`,`Delete the data of deleted devices?`),message:i.devices.map(e=>`#${e.deviceId}: ${fn(e.stores)}`).join(`
|
|
2
|
-
`),confirmLabel:e(`systemPage.deletedDevices.confirmLabel`,`Delete`),variant:`danger`})&&await d(!0)},m=[{key:`device`,header:e(`systemPage.deletedDevices.device`,`Device`),render:e=>`#${e.deviceId}`},{key:`stores`,header:e(`systemPage.deletedDevices.stores`,`Data held`),nowrap:!1,render:e=>fn(e.stores)}];return a(`div`,{className:`space-y-4`,"data-testid":`deleted-devices-data`,children:[c(`p`,{className:`text-sm text-foreground-muted`,children:e(`systemPage.deletedDevices.intro`,`Data that still belongs to devices that were deleted before deletions were recorded: footage, events, history and per-addon settings. Scanning deletes nothing; deleting asks first and shows what goes.`)}),a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a(B,{variant:`outline`,onClick:()=>void d(!1),disabled:n.isPending,"data-testid":`deleted-devices-scan`,children:[n.isPending?c(T,{className:`mr-2 h-4 w-4 animate-spin`}):c(S,{className:`mr-2 h-4 w-4`}),e(`systemPage.deletedDevices.scan`,`Scan`)]}),i?.status===`dry-run`&&i.devices.length>0?a(B,{variant:`danger`,onClick:()=>void f(),disabled:n.isPending,"data-testid":`deleted-devices-delete`,children:[c(p,{className:`mr-2 h-4 w-4`}),e(`systemPage.deletedDevices.delete`,`Delete the data of {{count}} devices…`,{count:i.devices.length})]}):null]}),l===null?null:c(`p`,{className:`text-sm text-danger`,children:l}),i?.status===`skipped`?c(`p`,{className:`text-sm text-warning`,"data-testid":`deleted-devices-skipped`,children:e(`systemPage.deletedDevices.skipped`,`Nothing was listed or deleted: the device list could not be trusted ({{reason}}). Try again.`,{reason:i.reason??``})}):null,i!==null&&i.status!==`skipped`?a(o,{children:[c(`p`,{className:`text-sm`,"data-testid":`deleted-devices-summary`,children:i.status===`cleaned`?e(`systemPage.deletedDevices.cleaned`,`Deleted {{rows}} items of {{count}} devices.`,{rows:pn(i.devices),count:i.devices.length}):e(`systemPage.deletedDevices.found`,`{{count}} deleted devices still hold {{rows}} items.`,{rows:pn(i.devices),count:i.devices.length})}),c(Ee,{columns:m,rows:i.devices,rowKey:e=>e.deviceId,emptyMessage:e(`systemPage.deletedDevices.none`,`No data belongs to a deleted device.`)}),i.unreachable.length>0?c(`p`,{className:`text-xs text-foreground-muted`,children:e(`systemPage.deletedDevices.unreachable`,`Not asked (unreachable): {{names}}`,{names:i.unreachable.join(`, `)})}):null]}):null]})}var hn=`view`,gn=`kinds`,_n=`deleted-devices`;function vn(){let{t:e}=W(),[t,n]=We(),r=t.get(`view`)===`deleted-devices`?_n:gn;return a(`div`,{className:u,children:[a(`div`,{className:`mb-3 space-y-2`,children:[c(re,{appearance:`pills`,value:r,onValueChange:e=>{n(t=>{let n=new URLSearchParams(t);return e===`kinds`?n.delete(hn):n.set(hn,e),n},{replace:!0})},children:a(Ae,{className:`flex flex-wrap gap-1`,children:[c(L,{value:gn,children:e(`systemPage.data.viewKinds`,`Record kinds`)}),c(L,{value:_n,children:e(`systemPage.data.viewDeletedDevices`,`Deleted devices`)})]})}),r===`kinds`?c(`p`,{className:`text-xs text-foreground-muted`,children:e(`systemPage.data.recordsUnifiedIntro`,`Every declared record kind on this hub. Entry kinds can be added, edited and deleted; the rest are read-only. Secret fields are redacted.`)}):null]}),c(r===`kinds`?Se:mn,{})]})}var yn={entries:null,"deleted-devices":`deleted-devices`};function bn(){let{t:e}=W(),t=He(`/system/data`,{t:e,isAdmin:!0})??{icon:m,title:e(`system.data`,`Data`)},[n]=We(),r=yn[n.get(`tab`)??``];if(r!==void 0){let e=new URLSearchParams(n);return e.set(`tab`,`records`),r!==null&&e.set(`view`,r),c(Ve,{replace:!0,to:{search:e.toString()}})}return c(Ge,{icon:t.icon,title:t.title,defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`systemPage.data.storage`,`Storage`),content:c(nt,{})},{id:`records`,label:e(`systemPage.data.records`,`Records`),content:c(vn,{}),ownedParams:[`view`,`recordsOwner`,`recordsKind`,`entryNew`,`entryEdit`]},{id:`backup`,label:e(`systemPage.data.backup`,`Backup`),content:c(dn,{})}]})}export{bn as DataPage};
|