@camstack/addon-admin-ui 1.2.698 → 1.2.699
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/assets/{AccessSection-C3Z4VMbn.js → AccessSection-Cg9rzCY6.js} +1 -1
- package/dist/assets/Addons-qxSwlXcz.js +5 -0
- package/dist/assets/{AdminPage-C0rgqBg5.js → AdminPage-BrYobKfu.js} +1 -1
- package/dist/assets/{AdminSectionedPage-CrbDQuju.js → AdminSectionedPage-DMt3db7_.js} +1 -1
- package/dist/assets/AiProfiles-DOg54XLu.js +3 -0
- package/dist/assets/Archive-CVAb7ii-.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-CNwsceSk.js → BootstrapSettingsForm-X9cZi_Nt.js} +1 -1
- package/dist/assets/{Build-CLqFtQQF.js → Build-DxgTHExF.js} +4 -4
- package/dist/assets/{Calendars-fZrHEH0S.js → Calendars-D6WsgvTf.js} +1 -1
- package/dist/assets/Cluster-RtxW2bKJ.js +1 -0
- package/dist/assets/{CompositionBlockEditor-BAgVN8yN.js → CompositionBlockEditor-Cg3OItJ7.js} +2 -2
- package/dist/assets/CompositionEditorPage-Ber-Qx5p.js +1 -0
- package/dist/assets/Data-Cwpzr7cR.js +2 -0
- package/dist/assets/DeviceDetail-Folb0FGW.js +1 -0
- package/dist/assets/{Devices-C2_XrAsB.js → Devices-DMIjJ196.js} +1 -1
- package/dist/assets/{EmbedDevicePage-B-kXRzxP.js → EmbedDevicePage-Caafl7ZH.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BKlnHqN7.js → EmbedPlayerPage-Bi76rC5b.js} +1 -1
- package/dist/assets/{History-C8ZY-Ovj.js → History-CP79jWzy.js} +1 -1
- package/dist/assets/Identity-HvzyOfT2.js +1 -0
- package/dist/assets/InstancesTable-fl42p6i3.js +1 -0
- package/dist/assets/IntegrationDetail-CMMEdEjA.js +1 -0
- package/dist/assets/{Integrations-w_KbkNum.js → Integrations-CYaklItX.js} +2 -2
- package/dist/assets/Integrations-hvwXjb_k.js +1 -0
- package/dist/assets/Library-Opn5-0Wj.js +1 -0
- package/dist/assets/Locations-Db8-OTso.js +3 -0
- package/dist/assets/{Logs-CjVZvl-p.js → Logs-B9zTepXX.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-Crc7Vee0.js → MaskShapeCanvas-CeHsVkFB.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CPRbUvmE.js → MotionZonesSettings-adkc7eLP.js} +1 -1
- package/dist/assets/{MyAccess-CvFEb2P_.js → MyAccess-BPDq5d45.js} +1 -1
- package/dist/assets/{Network-BApaJTDv.js → Network-jSuufX_m.js} +1 -1
- package/dist/assets/{NewExportModal-B87f6wft.js → NewExportModal-BwmdfSbv.js} +1 -1
- package/dist/assets/NodeAddonsSettingsPanel-BcvIFJ-x.js +1 -0
- package/dist/assets/{Notifications-DXM5xtCq.js → Notifications-DUibmZHJ.js} +1 -1
- package/dist/assets/{PanelContent-D7u-ISFK.js → PanelContent-BCIeD6_U.js} +2 -2
- package/dist/assets/{Pipeline-Bujc9zjR.js → Pipeline-BvgwYZ8u.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-B1fiafV8.js → PrivacyMaskSettings-zs9fc3hQ.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-D7pxuNnv.js → SceneMonitorEditor-C3LeCTYJ.js} +1 -1
- package/dist/assets/{SessionsList-D6U14Yno.js → SessionsList-CLCT23El.js} +2 -2
- package/dist/assets/{Showroom-DU9iMIZh.js → Showroom-DrLRL9I1.js} +1 -1
- package/dist/assets/StorageLocationsTable-Bz9GAV5K.js +1 -0
- package/dist/assets/{System-1Jh6VozL.js → System-BbRrxjUU.js} +2 -2
- package/dist/assets/{TemplateEditorDialog-UOirN96h.js → TemplateEditorDialog-22h0K3yb.js} +1 -1
- package/dist/assets/{Terminal-DyWFdRWL.js → Terminal-BTsnnLaP.js} +5 -5
- package/dist/assets/{TrainingProviders-BG7DsUoT.js → TrainingProviders-YTsR5lC5.js} +1 -1
- package/dist/assets/{Viewer-Cu1fVuMh.js → Viewer-wJAA7rtL.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Y8Q6lecu.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C29DsQaz.js} +1 -1
- package/dist/assets/{action-draft-D0S-LJcp.js → action-draft-LMoJNqJ2.js} +1 -1
- package/dist/assets/{ai-page.helpers-DJ4SE1RA.js → ai-page.helpers-MSr4oAOr.js} +1 -1
- package/dist/assets/{assignment-candidates-FntpKIEo.js → assignment-candidates-lemE0qmp.js} +1 -1
- package/dist/assets/{authed-media-CkCP7Cpu.js → authed-media-CJkTsStS.js} +1 -1
- package/dist/assets/{board-model-CV7df4sG.js → board-model-BjTxORes.js} +1 -1
- package/dist/assets/{camera-block-model-DoWj--hc.js → camera-block-model-D98qHpXa.js} +1 -1
- package/dist/assets/client-DVowZZ0s.js +1122 -0
- package/dist/assets/{command-vocab-B1KZgOMw.js → command-vocab-BecctZqm.js} +1 -1
- package/dist/assets/{device-detail-QaaayAym.js → device-detail-D7Mllu4s.js} +1 -1
- package/dist/assets/{device-integration-icon-BMTwf3mF.js → device-integration-icon-BR10V6ne.js} +1 -1
- package/dist/assets/device-picker-model-DccEEZ6A.js +1 -0
- package/dist/assets/{dist-D7aUh2j3.js → dist-DO0_AccE.js} +1 -1
- package/dist/assets/dist-DhsssUoX.js +1122 -0
- package/dist/assets/{format-D2Wcm0QP.js → format-D6kgFpER.js} +1 -1
- package/dist/assets/{hostInit-4wcUPS8D.js → hostInit-CdUb3qyd.js} +1 -1
- package/dist/assets/i18n-CQiAPXio.js +1 -0
- package/dist/assets/{icons-DK3iI8sz.js → icons-S17PAUwl.js} +1 -1
- package/dist/assets/index-BFLHRK9f.js +6 -0
- package/dist/assets/{linked-devices-model-C7til7aR.js → linked-devices-model-E6YzvEnL.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-4aebb5a9.js → mf-entry-bootstrap-0-26099898.js} +2 -2
- package/dist/assets/mount-DccEEZ6A.js +1 -0
- package/dist/assets/{notification-rule-status-D5LkcHTp.js → notification-rule-status-Rco24I6e.js} +1 -1
- package/dist/assets/{player-overlays-BKicBNcF.js → player-overlays-DNV0OF87.js} +1 -1
- package/dist/assets/remoteEntry-CLeDuWWL.js +1 -0
- package/dist/assets/src-Dv0B4lHJ.js +279 -0
- package/dist/assets/{sso-popup-Ceq4Jz8a.js → sso-popup-F-KRTc0f.js} +1 -1
- package/dist/assets/{step-inspector-model-BzUVKPrw.js → step-inspector-model-drjYN2J-.js} +1 -1
- package/dist/assets/{use-scenes-feed-DA7UFRvT.js → use-scenes-feed-jdmupAkZ.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-JYfuB8v_.js → useAdminDeviceRemoval-CB-W9jkR.js} +1 -1
- package/dist/assets/useEventInvalidation-DccEEZ6A.js +1 -0
- package/dist/assets/{useNodeUrlSelection-CmeaBXTi.js → useNodeUrlSelection-BfsFEu9Z.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DXs1P_5w.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CSeKpPd2.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +178 -7
- package/package.json +2 -2
- package/dist/assets/Addons-CBfB4PwF.js +0 -5
- package/dist/assets/AiProfiles-Uzt6ITwV.js +0 -3
- package/dist/assets/Archive-KiES4AK1.js +0 -1
- package/dist/assets/Cluster-ZhXkbC8q.js +0 -1
- package/dist/assets/CompositionEditorPage-Cjdi12u4.js +0 -1
- package/dist/assets/Data-DkKT4kg4.js +0 -2
- package/dist/assets/DeviceDetail-DphkoMAH.js +0 -1
- package/dist/assets/Identity-BELn4_Lg.js +0 -1
- package/dist/assets/InstancesTable-Blgr9UwH.js +0 -1
- package/dist/assets/IntegrationDetail-Bv3DXRXC.js +0 -1
- package/dist/assets/Integrations-BNc3Xhbg.js +0 -1
- package/dist/assets/Library-CC-yVMZb.js +0 -1
- package/dist/assets/Locations-TgIsNyQs.js +0 -3
- package/dist/assets/NodeAddonsSettingsPanel-Dxp-6Ksw.js +0 -1
- package/dist/assets/StorageLocationsTable-B_F1eKHy.js +0 -1
- package/dist/assets/client-Dn4ym7AZ.js +0 -1122
- package/dist/assets/device-picker-model-C0oitxOP.js +0 -1
- package/dist/assets/dist-BZARORuz.js +0 -1122
- package/dist/assets/i18n-CsnSJSM7.js +0 -1
- package/dist/assets/index-FA3cRm59.js +0 -6
- package/dist/assets/mount-C0oitxOP.js +0 -1
- package/dist/assets/remoteEntry-3rv7Sz7o.js +0 -1
- package/dist/assets/src-CU6u_Uvz.js +0 -279
- package/dist/assets/useEventInvalidation-C0oitxOP.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$t as d,Bn as f,Et as p,Hi as m,Lr as h,Mi as g,Q as _,Qa as v,Tt as y,Va as b,Xa as x,Xr as S,Y as C,Yn as w,Yr as T,Z as E,Za as D,Zt as O,_a as k,aa as A,ar as j,ct as M,fa as N,ft as P,hi as F,hn as I,ki as L,ln as ee,mn as R,ot as te,pn as z,qr as ne,qt as B,sa as re,si as ie,t as ae,ti as oe,tn as se,ut as ce,wi as le,yt as ue,z as de,zr as V}from"./player-overlays-BKicBNcF.js";import{Oc as fe,cl as H,gt as pe,kc as me,ui as he}from"./client-Dn4ym7AZ.js";import{t as ge}from"./chevron-down-CBb-F8DT.js";import{_ as _e}from"./terminal-DZ5OZpgC.js";import{n as ve,r as ye,t as U}from"./scissors-DpiKUioV.js";import{t as be}from"./square-check-big-DAcFGNUN.js";import{Br as xe,Cr as Se,Da as W,Ep as Ce,Er as we,Ft as Te,Fu as Ee,Gi as De,Gu as Oe,Hi as ke,Ir as Ae,Ji as je,Kp as Me,Li as Ne,Md as Pe,Mr as Fe,Nd as Ie,Pd as Le,Ui as Re,Vp as ze,Vu as Be,Wi as Ve,Xi as He,Yi as Ue,Ys as We,_f as Ge,_p as Ke,aa as qe,ai as Je,au as Ye,cf as Xe,ci as Ze,cp as Qe,cu as $e,d as et,df as tt,du as nt,ea as rt,ff as it,fo as at,fu as ot,ga as st,gf as ct,gp as lt,hf as ut,hp as dt,hu as ft,ia as pt,iu as mt,jd as ht,jr as gt,ju as _t,ka as G,kr as vt,la as yt,lf as bt,lp as K,lu as xt,mf as St,mp as Ct,mr as wt,mu as Tt,na as Et,np as Dt,oi as Ot,ou as kt,pf as At,pu as jt,ql as Mt,ra as Nt,rp as Pt,si as Ft,sp as It,su as Lt,ta as Rt,tt as zt,uf as Bt,uu as Vt,vf as Ht,vp as Ut,wi as Wt,yf as Gt,zr as Kt}from"./src-CU6u_Uvz.js";import{r as qt,t as Jt}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{t as q}from"./i18n-CsnSJSM7.js";import{t as J}from"./useTranslation-BJr-n0es.js";import"./mount-C0oitxOP.js";import{Ci as Yt,Di as Xt,Ei as Zt,N as Qt,Si as $t,Ti as en,_i as tn,bi as nn,gi as rn,wi as an,yi as on}from"./index-FA3cRm59.js";import{t as sn}from"./AdminSectionedPage-CrbDQuju.js";import{a as cn,d as ln,f as un,i as dn,m as fn,n as pn,o as mn,p as hn,r as gn,s as _n,t as vn,u as yn}from"./NewExportModal-B87f6wft.js";import{a as bn,i as xn,r as Sn,t as Cn}from"./authed-media-CkCP7Cpu.js";import{a as wn,o as Tn}from"./PanelContent-D7u-ISFK.js";import{t as Y}from"./format-size-DIxKXxtj.js";import{a as En,i as Dn,n as On,o as kn,r as An,s as jn,t as Mn}from"./StorageLocationsTable-B_F1eKHy.js";c();var Nn={info:0,warning:1,critical:2},Pn={"motion-without-detections":`motion`,"detections-under-floor":`detection`,"inference-too-slow":`detection`,"frames-shed":`detection`,"inference-device-unusable":`detection`};function Fn(e){return{id:`op:${e.id}`,at:e.at,source:`operation`,severity:`info`,fn:e.domain===`recording`?`recording`:`events`,deviceId:e.deviceId,title:`${e.op} · ${e.reason}`,detail:e.detail}}function In(e,t){return{id:`finding:${e.id}`,at:t,source:`finding`,severity:e.severity,fn:Pn[e.kind],deviceId:e.subject.type===`camera`?e.subject.deviceId:null,title:e.what,detail:e.action}}function Ln(e,t){return e.filter(e=>t.deviceId===null||e.deviceId===t.deviceId).filter(e=>t.fn===null||e.fn===t.fn).filter(e=>t.minSeverity===null||Nn[e.severity]>=Nn[t.minSeverity]).toSorted((e,t)=>t.at-e.at)}var Rn=``,zn=[`recording`,`events`,`detection`,`motion`],Bn=[`info`,`warning`,`critical`];function Vn({data:t,deviceId:r}){let{t:a}=J(),s=Ie({},{refetchOnWindowFocus:!1}),c=Vt({},{refetchOnWindowFocus:!1}),[l,u]=o(Rn),[d,f]=o(Rn),[p,m]=o(Rn),h=n(()=>{let e=[...s.data??[],...c.data??[]].map(Fn),n=t.digestAtMs??0,r=(t.findings??[]).map(e=>In(e,n));return[...e,...r]},[s.data,c.data,t.findings,t.digestAtMs]),g=n(()=>({deviceId:r??(l===Rn?null:Number(l)),fn:zn.find(e=>e===d)??null,minSeverity:Bn.find(e=>e===p)??null}),[r,l,d,p]),_=n(()=>Ln(h,g),[h,g]),v=n(()=>new Map(t.cameras.map(e=>[e.id,e.name])),[t.cameras]),y=[];s.isError&&y.push(a(`archive.activity.footageLog`,`footage`)),c.isError&&y.push(a(`archive.activity.eventLog`,`event`));let b=n(()=>[{key:`at`,header:a(`archive.activity.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>i(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.at===0?`—`:new Date(e.at).toLocaleString()})},{key:`severity`,header:a(`archive.activity.severity`,`Severity`),nowrap:!0,sortValue:e=>e.severity,render:e=>i(`span`,{className:Hn[e.severity],children:a(`archive.severity.${e.severity}`,e.severity)})},{key:`camera`,header:a(`archive.activity.camera`,`Camera`),sortValue:e=>e.deviceId===null?``:v.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>i(`span`,{className:`text-foreground`,children:e.deviceId===null?a(`archive.activity.cluster`,`Cluster`):v.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`what`,header:a(`archive.activity.what`,`What`),render:t=>e(`div`,{className:`flex flex-col`,children:[i(`span`,{className:`text-foreground`,children:t.title}),t.detail!==null&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:t.detail})]})}],[a,v]);return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-activity`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r===void 0&&e(P,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>u(e.target.value),"aria-label":a(`archive.activity.filterCamera`,`Camera`),children:[i(`option`,{value:Rn,children:a(`archive.activity.allCameras`,`All cameras`)}),t.cameras.map(e=>i(`option`,{value:String(e.id),children:e.name},e.id))]}),e(P,{wrapperClassName:`inline-block w-auto`,value:d,onChange:e=>f(e.target.value),"aria-label":a(`archive.activity.filterFunction`,`Function`),children:[i(`option`,{value:Rn,children:a(`archive.activity.allFunctions`,`All functions`)}),zn.map(e=>i(`option`,{value:e,children:a(`archive.function.${e}`,e)},e))]}),e(P,{wrapperClassName:`inline-block w-auto`,value:p,onChange:e=>m(e.target.value),"aria-label":a(`archive.activity.filterSeverity`,`Severity`),children:[i(`option`,{value:Rn,children:a(`archive.activity.allSeverities`,`Any severity`)}),Bn.map(e=>i(`option`,{value:e,children:a(`archive.activity.atLeast`,`At least {{severity}}`,{severity:a(`archive.severity.${e}`,e)})},e))]})]}),y.length>0&&i(W,{variant:`warning`,message:a(`archive.activity.logUnread`,`The {{names}} log did not answer. This is not "nothing happened".`,{names:y.join(` / `)})}),_.length===0&&y.length===0?i(yt,{icon:x,title:a(`archive.activity.none`,`No activity`),description:a(`archive.activity.noneHint`,`Pruning, deletion and health findings show up here.`)}):i(Kt,{columns:b,rows:_,rowKey:e=>e.id,minWidthPx:640,maxBodyHeight:xe,pageSize:25})]})}var Hn={info:`text-foreground-subtle`,warning:`text-warning`,critical:`text-danger`},Un={recording:`recording`,motion:null,detection:`object-detection`,"event-media":`event-saving`},Wn={"motion-without-detections":`motion`,"detections-under-floor":`detection`,"inference-too-slow":`detection`,"frames-shed":`detection`,"inference-device-unusable":null},Gn={recording:`recording`,motion:null,detection:`detection`,"event-media":null},Kn=[`recording`,`motion`,`detection`,`event-media`];function qn(e,t){switch(e){case`recording`:return t.recording===null?null:t.recording.active?`ok`:`warning`;case`motion`:return t.motion===null?null:t.motion.enabled?`ok`:`off`;case`detection`:return t.detection===null?null:`ok`;case`event-media`:return`ok`}}function Jn(e){return e.some(e=>e.severity===`critical`)?`critical`:e.some(e=>e.severity===`warning`)?`warning`:`ok`}function Yn(e,t){return Kn.map(n=>{let r=t.filter(e=>Wn[e.kind]===n);if(e===void 0)return{fn:n,state:r.length>0?Jn(r):`unknown`,findings:r};let i=Un[n];if(i!==null&&e.switchedOff.includes(i))return{fn:n,state:`off`,findings:r};let a=Gn[n];return a!==null&&e.degraded.some(e=>e.stage===a)?{fn:n,state:r.length>0?Jn(r):`unknown`,findings:r}:r.length>0?{fn:n,state:Jn(r),findings:r}:n===`recording`&&e.recording?.mode===`off`?{fn:n,state:`off`,findings:r}:{fn:n,state:qn(n,e)??`unknown`,findings:r}})}var Xn=`recording`;function Zn(e,t){return(e??[]).filter(e=>e.subject.type===`camera`&&e.subject.deviceId===t)}function Qn(e){return e.filter(e=>e.severity!==`info`).length}function $n(e,t){return e===void 0?`unknown`:e.switchedOff.includes(Xn)||e.recording?.mode===`off`?`off`:e.degraded.some(e=>e.stage===`recording`||e.stage===`switches`)||e.recording===null?`unknown`:t>0||!e.recording.active?`degraded`:`recording`}function er(e){let t=new Map((e.footage??[]).map(e=>[e.deviceId,e])),n=new Map((e.events??[]).map(e=>[e.deviceId,e])),r=new Map((e.statuses??[]).map(e=>[e.deviceId,e]));return e.cameras.map(i=>{let a=Qn(Zn(e.findings,i.id)),o=r.get(i.id),s=t.get(i.id),c=n.get(i.id);return{deviceId:i.id,name:i.name,mode:o?.recording?.mode??null,state:$n(o,a),warnings:a,footageBytes:e.footage===null?null:s?.usedBytes??0,oldestMs:s?.oldestMs??null,eventRows:e.events===null?null:c?.rows??0,eventBytes:e.events===null?null:c?.bytes??0}})}function tr(e){let t=t=>e.filter(e=>e.state===t).length;return{recording:t(`recording`),degraded:t(`degraded`),off:t(`off`),unknown:t(`unknown`),warnings:e.reduce((e,t)=>e+t.warnings,0)}}var nr={ok:`success`,off:`default`,warning:`warning`,critical:`danger`,unknown:`default`};function rr(e,t){return e.statuses?.find(e=>e.deviceId===t)}function ir({data:t,deviceId:n}){let{t:r}=J(),a=Yn(rr(t,n),Zn(t.findings,n));return e(`div`,{className:`flex flex-col gap-4`,"data-testid":`archive-health`,children:[t.findings===null&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`archive.health.noDigest`,`The health digest has not run yet — findings are not available.`)}),i(`ul`,{className:`flex flex-col divide-y divide-border rounded-lg border border-border bg-surface`,children:a.map(t=>e(`li`,{className:`flex flex-col gap-1 p-3`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:r(`archive.function.${t.fn}`,t.fn)}),i(G,{variant:nr[t.state],children:r(`archive.functionState.${t.state}`,t.state)})]}),t.findings.map(t=>e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[i(`span`,{className:`text-foreground`,children:t.what}),` — `,t.action]},t.id))]},t.fn))}),e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`archive.health.logs`,`Camera log`)}),i(tn,{className:`text-xs text-primary hover:underline`,to:`/system/logs?deviceId=${String(n)}`,children:r(`archive.health.openLogs`,`Open in Logs`)})]}),i(`div`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:i(wt,{deviceId:n,limit:100,maxHeight:`max-h-80`,showFilters:!0})})]})]})}qt();function ar(e){let t=e.subLabel??e.label;if(t!==void 0)return t;let n=e.audioLabels?.[0]?.label;return n!==void 0&&n.length>0?n:void 0}var or=720*60*60*1e3;function sr(e){let t=[];for(let n of e)t.push(...n);return t}function cr(e,t){let n=[...e];return n.sort((e,n)=>t===`importance`?n.importance-e.importance:n.timestamp-e.timestamp),n}function lr(e,t){return e.filter(e=>!(e.importance<t.minImportance||t.cameras.size>0&&!t.cameras.has(e.deviceId)||t.classes.size>0&&!t.classes.has(e.className)))}function ur(e,t){return`${String(e)}:${t}`}function dr(e,t){let n=new Map,r=new Set;for(let i of e){let e=ur(i.deviceId,i.trackId);if(!t.has(e)||r.has(e))continue;r.add(e);let a=n.get(i.deviceId);a?a.push(i.trackId):n.set(i.deviceId,[i.trackId])}return n}function fr(e,t){return{since:e.fromMs??t-or,until:e.toMs??t}}var pr=typeof Ye==`function`,mr=`Track deletion arrives with the next server update`;function hr(){return{mutateAsync:async()=>{throw Error(`deleteTracks unavailable`)},isPending:!1}}var gr=pr?Ye:hr;c();var _r=3e4,vr=[];function yr(e){let t=ue(),r=e.deviceIds.length>0,i=[...e.deviceIds].sort((e,t)=>e-t),{data:a,isLoading:o}=s({queryKey:[`events-feed`,i,e.since,e.until,e.minImportance??null,e.classFilter??null],enabled:r,staleTime:_r,refetchInterval:_r,queryFn:async()=>(await t.trpcClient.pipelineAnalytics.getKeyEventsBatch.query({deviceIds:i,since:e.since,until:e.until,limit:200,...e.minImportance===void 0?{}:{minImportance:e.minImportance},...e.classFilter===void 0?{}:{classFilter:e.classFilter}})).map(e=>e.events.map(t=>({...t,deviceId:e.deviceId})))});return{rows:n(()=>cr(sr(a??vr),`importance`),[a]),isLoading:r&&o}}c();var br=[`events-feed`],xr=2e3;function Sr(e){let n=l(),i=e?.paused===!0,s=t(n);s.current=n;let c=t(i);c.current=i;let[u,d]=o(!1),f=r(()=>{s.current.invalidateQueries({queryKey:br})},[]),p=t(void 0);p.current||=fn({delayMs:xr,invalidate:()=>{c.current?d(!0):f()}}),a(()=>()=>p.current?.cancel(),[]),a(()=>{i||!u||(d(!1),f())},[i,u,f]);let m=r(()=>{d(!1),f()},[f]);return Me(H.PipelineAnalyticsDetectionEvent,()=>{p.current?.trigger()}),Me(H.PipelineAnalyticsTrackEnded,()=>{p.current?.trigger()}),{pending:u,refreshNow:m}}c();function Cr(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e])=>e)}function wr({classes:e,hidden:t,onChange:r}){let{t:a}=J(),o=n(()=>Cr(e).map(e=>({id:e,label:e})),[e]);return o.length<2?null:i(we,{chips:o,off:t,onChange:r,allLabel:a(`detectionIntelligence.eventClassChips.all`,`All classes`),ariaLabel:a(`detectionIntelligence.eventClassChips.label`,`Classes`),testId:`event-class-chips`})}var Tr=[0,1,2],Er=`camstack.archive.eventRowSize`,Dr={0:`w-[72px]`,1:`w-28`,2:`w-40`};function Or(e){return e===1||e===2?e:0}c();function kr({groups:t,selected:r,onChange:a,loading:s=!1}){let{t:c}=J(),l=Se(),[u,d]=o(!1),[p,m]=o(``),[h,g]=o(new Set),_=p.trim().toLowerCase(),v=e=>_.length===0||It(e,c).toLowerCase().includes(_),y=n(()=>t.map(e=>({macro:e.macro,subs:e.subs.filter(t=>v(t)||v(e.macro))})).filter(e=>v(e.macro)||e.subs.length>0),[t,_]),b=e=>g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),x=e=>{let t=new Set(r),n=r.has(e.macro.kind)&&e.subs.every(e=>r.has(e.kind)),i=[e.macro.kind,...e.subs.map(e=>e.kind)];if(n)for(let e of i)t.delete(e);else for(let e of i)t.add(e);a(t)},S=e=>{let t=new Set(r);t.has(e)?t.delete(e):t.add(e),a(t)},C=()=>a(new Set),w=r.size;return e(`div`,{className:`relative`,children:[e(K,{variant:`unstyled`,type:`button`,onClick:()=>d(e=>!e),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${w>0?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(ee,{className:`h-3.5 w-3.5`}),w>0?c(`detectionIntelligence.eventKindFilter.kinds`,`Kinds ({{value1}})`,{value1:String(w)}):c(`detectionIntelligence.eventKindFilter.kinds2`,`Kinds`),i(ge,{className:`h-3 w-3`})]}),u&&e(`div`,{className:`absolute z-20 mt-1 max-h-80 w-64 overflow-auto rounded-md border border-border bg-surface p-2 shadow-lg`,children:[e(`div`,{className:`mb-2 flex items-center gap-1 rounded border border-border px-1.5`,children:[i(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(Ke,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:c(`detectionIntelligence.eventKindFilter.searchKinds`,`Search kinds…`),className:`w-full bg-transparent py-1 text-xs outline-none`}),w>0&&i(K,{variant:`unstyled`,type:`button`,onClick:C,className:`text-[10px] text-foreground-subtle hover:text-foreground`,children:c(`detectionIntelligence.eventKindFilter.clear`,`Clear`)})]}),y.length===0&&i(`div`,{className:`px-1 py-2 text-[11px] text-foreground-subtle`,children:s?c(`detectionIntelligence.eventKindFilter.loadingKinds`,`Loading kinds…`):_.length>0?c(`detectionIntelligence.eventKindFilter.noKindMatchesThatSearch`,`No kind matches that search.`):c(`detectionIntelligence.eventKindFilter.theseCamerasAdvertiseNoEvent`,`These cameras advertise no event kinds.`)}),y.map(t=>{let n=Qe(t.macro.iconId),a=h.has(t.macro.kind)||_.length>0,o=r.has(t.macro.kind);return e(`div`,{className:`mb-0.5`,children:[e(`div`,{className:`flex items-center gap-1`,children:[t.subs.length>0?i(K,{variant:`unstyled`,type:`button`,onClick:()=>b(t.macro.kind),className:`text-foreground-subtle hover:text-foreground`,"aria-label":c(`detectionIntelligence.eventKindFilter.expand`,`Expand`),children:i(a?ge:A,{className:`h-3 w-3`})}):i(`span`,{className:`w-3`}),e(`label`,{className:`flex flex-1 cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-xs hover:bg-surface-hover`,children:[i(D,{checked:o,onChange:()=>x(t),className:`accent-primary`}),i(n,{className:`h-3.5 w-3.5`,style:{color:l(t.macro.kind)}}),i(`span`,{className:`font-medium`,children:It(t.macro,c)})]})]}),a&&t.subs.map(t=>{let n=Qe(t.iconId);return e(`label`,{className:`ml-5 flex cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-xs hover:bg-surface-hover`,children:[i(D,{checked:r.has(t.kind),onChange:()=>S(t.kind),className:`accent-primary`}),i(n,{className:`h-3.5 w-3.5`,style:{color:l(t.kind)}}),i(`span`,{children:It(t,c)})]},t.kind)})]},t.macro.kind)})]})]})}function Ar(e,t){let n=new Map;for(let r of e)if(!(t.size>0&&!t.has(r.deviceId)))for(let e of r.kinds)n.has(e.kind)||n.set(e.kind,e);return n}function jr(e,t){return{...t,kind:e,labelKey:`eventKind.${e}`,label:e.charAt(0).toUpperCase()+e.slice(1),iconId:e,parentKind:null,level:`macro`}}var Mr=new Set([`detection`,`package`]);function Nr(e,t){return[...Ar(e,t).values()].filter(e=>e.parentKind===null&&Mr.has(e.category)).sort((e,t)=>e.label.localeCompare(t.label))}function Pr(e,t){let n=Ar(e,t),r=new Map,i=new Map;for(let e of n.values()){if(e.parentKind===null){i.set(e.kind,e);continue}let t=r.get(e.parentKind);t===void 0?r.set(e.parentKind,[e]):t.push(e)}for(let[e,t]of r){if(i.has(e))continue;let n=t[0];n!==void 0&&i.set(e,jr(e,n))}return[...i.values()].map(e=>({macro:e,subs:[...r.get(e.kind)??[]].sort((e,t)=>e.label.localeCompare(t.label))})).sort((e,t)=>e.macro.label.localeCompare(t.macro.label))}c();var Fr=1400,Ir=`Admin-gated URL — opens only inside an authenticated session`;function Lr({label:t,value:n,title:s}){let{t:c}=J(),[l,u]=o(!1),d=ce();return a(()=>{if(!l)return;let e=setTimeout(()=>u(!1),Fr);return()=>clearTimeout(e)},[l]),e(K,{variant:`unstyled`,type:`button`,onClick:r(()=>{(async()=>{try{await navigator.clipboard.writeText(n),u(!0)}catch{await d({title:c(`detectionIntelligence.copyUrlChips.copyTheMediaUrl`,`Copy the media URL`),message:c(`detectionIntelligence.copyUrlChips.clipboardAccessWasRefusedSelect`,`Clipboard access was refused. Select the URL below and copy it manually.`),label:c(`detectionIntelligence.copyUrlChips.url`,`{{label}} URL`,{label:t}),defaultValue:n,readOnly:!0,cancelLabel:c(`common.close`,`Close`)})}})()},[n,t,d,c]),title:s,"aria-label":c(`detectionIntelligence.copyUrlChips.copyUrl`,`Copy {{label}} URL`,{label:t}),className:`flex min-w-0 items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${l?`border-success/40 bg-success/10 text-success`:`border-border text-foreground-subtle hover:border-primary hover:text-foreground`}`,children:[i(l?re:g,{className:`h-2.5 w-2.5 shrink-0`}),i(`span`,{className:`truncate`,children:l?c(`detectionIntelligence.copyUrlChips.copied`,`Copied`):t})]})}function Rr({localUrl:t,publicUrl:n}){let{t:r}=J();return e(`div`,{className:`flex flex-wrap gap-1`,children:[i(Lr,{label:r(`detectionIntelligence.copyUrlChips.local`,`Local`),value:t,title:r(`detectionIntelligence.copyUrlChips.copyLanUrl`,`Copy LAN URL — {{AUTH_HINT}}`,{AUTH_HINT:Ir})}),n&&i(Lr,{label:r(`detectionIntelligence.copyUrlChips.public`,`Public`),value:n,title:r(`detectionIntelligence.copyUrlChips.copyPublicUrl`,`Copy public URL — {{AUTH_HINT}}`,{AUTH_HINT:Ir})})]})}var zr={firstFrame:`First frame (track start)`,lastFrame:`Last frame (track end)`,thumbnail:`Best detection`,thumbnailSmall:`Best detection (480)`,snapshot:`Snapshot`,keyFrame:`Key frame (native-res)`,keyFrameSmall:`Key frame (960)`,crop:`Object crop`,fullFrame:`Full frame`,fullFrameBoxed:`Full frame (boxed)`,faceCrop:`Face crop`,plateCrop:`Plate crop`,confirmationCrop:`Confirmation crop (what the gate saw)`,debugCrop:`Debug crop (why this decision)`,sceneFrame:`Scene frame (clean)`,lastSceneFrame:`Last frame (clean)`};function Br(e){return e in zr}function Vr(e){return Br(e)?zr[e]:e}function Hr(e,t){return`${e}${t}`}var Ur=[`native`,`raster`,`standin`];function Wr(e){return Ur.some(t=>t===e)}function Gr(e){return e===`standin`?{label:q.t(`helpers.mediaProvenance.standin.label`),title:q.t(`helpers.mediaProvenance.standin.title`),tone:`warning`}:{label:q.t(`helpers.mediaProvenance.raster.label`),title:q.t(`helpers.mediaProvenance.raster.title`),tone:`info`}}function Kr(e){return e===`standin`?Gr(`standin`):e===`raster`?Gr(`raster`):null}var qr={"no-key-frame":`helpers.mediaProvenance.miss.noKeyFrame`,"no-best-seen-bbox":`helpers.mediaProvenance.miss.noBestSeenBbox`,"derive-returned-null":`helpers.mediaProvenance.miss.deriveReturnedNull`,"derive-threw":`helpers.mediaProvenance.miss.deriveThrew`,"derive-not-wired":`helpers.mediaProvenance.miss.deriveNotWired`,"no-media-store":`helpers.mediaProvenance.miss.noMediaStore`,"no-thumbnail":`helpers.mediaProvenance.miss.noThumbnail`,"standin-tile":`helpers.mediaProvenance.miss.standinTile`,"raster-tile":`helpers.mediaProvenance.miss.rasterTile`,"native-tile":`helpers.mediaProvenance.miss.nativeTile`};function Jr(e){if(e===void 0)return null;let t=e.trim();if(t.length===0)return null;let n=t.split(/\s+/),r=n[0]??t,i=[];for(let e of n.slice(1)){let t=e.indexOf(`=`);t===-1?i.push({key:e,value:null}):i.push({key:e.slice(0,t),value:e.slice(t+1)})}let a=qr[r];return{sentence:a===void 0?r:q.t(a),detail:i,raw:t}}c();var Yr=3e4;function Xr(e){let[t,n]=o(null),s=r(e=>{n(t=>t??e)},[]);return a(()=>{e||n(null)},[e]),{publicOrigin:t,probes:e?i(Zr,{onOrigin:s}):null}}function Zr({onOrigin:e}){let{data:t}=at({capName:`network-access`});return i(u,{children:(t??[]).map(t=>i(Qr,{addonId:t.addonId,onOrigin:e},t.addonId))})}function Qr({addonId:e,onOrigin:t}){let{data:n}=Mt({addonId:e},{refetchInterval:Yr,retry:!1});return a(()=>{let e=n?he.safeParse(n):null,r=e?.success?e.data.endpoint?.url:void 0;if(r)try{t(new URL(r).origin)}catch{}},[n,t]),null}var $r=typeof ft==`function`,ei=`Track flags arrive with the next server update`;function ti(){return{mutateAsync:async()=>{throw Error(`setTrackFlags unavailable`)},isPending:!1}}var ni=$r?ft:ti;function ri(e){if(typeof e!=`object`||!e||!(`trackId`in e)||!(`markForTrain`in e)||!(`debug`in e)||!(`favourited`in e))return null;let{trackId:t,markForTrain:n,debug:r,favourited:i}=e;return typeof t!=`string`||typeof n!=`boolean`||typeof r!=`boolean`||typeof i!=`boolean`?null:{trackId:t,markForTrain:n,debug:r,favourited:i}}c();function ii({label:t,hint:n,checked:r,disabled:a,title:o,icon:s,onToggle:c}){return e(K,{variant:`unstyled`,type:`button`,role:`switch`,"aria-checked":r,"aria-label":t,disabled:a,title:o,onClick:c,className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-left transition-colors disabled:opacity-50 ${r?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[i(`span`,{className:r?`text-primary`:`text-foreground-subtle`,children:s}),e(`span`,{className:`min-w-0 flex-1`,children:[i(`span`,{className:`block text-[11px] font-medium text-foreground`,children:t}),i(`span`,{className:`block text-[10px] text-foreground-subtle`,children:n})]}),i(`span`,{"aria-hidden":`true`,className:`h-4 w-7 shrink-0 rounded-full p-0.5 transition-colors ${r?`bg-primary`:`bg-border`}`,children:i(`span`,{className:`block h-3 w-3 rounded-full bg-white transition-transform ${r?`translate-x-3`:``}`})})]})}function ai({deviceId:t,trackId:n,markForTrain:r,debug:a,favourited:s,onChange:c}){let{t:l}=J(),u=ni(),d=te(),[f,p]=o(null),m=f?.markForTrain??r===!0,h=f?.debug??a===!0,g=f?.favourited??s===!0,_=!$r||u.isPending,v=$r?void 0:ei,y=e=>{_||(async()=>{try{let r=ri(await u.mutateAsync({deviceId:t,trackId:n,flags:e}));if(!r)return;p(r),c?.(r)}catch(e){let t=e instanceof Error?e.message:``;await d({title:l(`detectionIntelligence.trackFlagToggles.couldNotUpdateThisTrack`,`Could not update this track`),message:t===``?l(`detectionIntelligence.trackFlagToggles.couldNotUpdateThisTrack2`,`Could not update this track. Check the server logs.`):t,variant:`danger`})}})()};return e(`div`,{className:`grid gap-1.5 sm:grid-cols-2`,children:[i(ii,{label:l(`detectionIntelligence.trackFlagToggles.markForTraining`,`Mark for training`),hint:l(`detectionIntelligence.trackFlagToggles.keepsThisTrackAndIts`,`Keeps this track and its media past retention`),checked:m,disabled:_,...v===void 0?{}:{title:v},icon:i(ie,{className:`h-4 w-4`}),onToggle:()=>y({markForTrain:!m})}),i(ii,{label:l(`detectionIntelligence.trackFlagToggles.debug`,`Debug`),hint:l(`detectionIntelligence.trackFlagToggles.flagThisTrackForDiagnostic`,`Flag this track for diagnostic attention`),checked:h,disabled:_,...v===void 0?{}:{title:v},icon:i(k,{className:`h-4 w-4`}),onToggle:()=>y({debug:!h})}),i(ii,{label:l(`detectionIntelligence.trackFlagToggles.favourited`,`Favourited`),hint:l(`detectionIntelligence.trackFlagToggles.keepsThisTrackAndIts`,`Keeps this track and its media past retention`),checked:g,disabled:_,...v===void 0?{}:{title:v},icon:i(z,{className:`h-4 w-4`}),onToggle:()=>y({favourited:!g})})]})}function oi(e){let t=e.deviceKey===void 0?e.nodeId:`${e.nodeId} · ${e.deviceKey}`;return e.modelId===void 0?t:`${t} (${e.modelId})`}function si(e){let t=e?.openedPlacement,n=e?.closedPlacement;if(t!==void 0&&n!==void 0){let e=oi(t),r=oi(n);return e===r?[{kind:`detected`,value:e}]:[{kind:`opened`,value:e},{kind:`closed`,value:r}]}return t===void 0?n===void 0?[]:[{kind:`closed`,value:oi(n)}]:[{kind:`opened`,value:oi(t)}]}var ci=100,li={polyline:``,points:[],snapshots:[],start:null,end:null,peakBox:null},ui=e=>e<0?0:e>1?1:e,di=e=>Math.round(e*100)/100;function fi(e,t,n){if(e.length===0||t===null)return li;let{width:r,height:i}=t;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return li;let a=pe(e.map(e=>({x:e.x/r,y:e.y/i,w:e.bbox.w/r,h:e.bbox.h/i})),n?.maxPoints===void 0?void 0:{maxPoints:n.maxPoints}).nodes.map(e=>({x:di(e.x*ci),y:di(e.y*ci)})),o=a[0]??null,s=a[a.length-1]??null,c=a.length>=2?a.map(e=>`${e.x},${e.y}`).join(` `):``,l=(n?.snapshots??[]).map(e=>({x:di(ui(e.x/r)*ci),y:di(ui(e.y/i)*ci),mediaId:e.mediaId})),u=null,d=-1;for(let t of e){let e=ui(t.bbox.w/r)*ui(t.bbox.h/i);e>d&&(d=e,u=t)}return{polyline:c,points:a,snapshots:l,start:o,end:s,peakBox:u?{x:di(ui(u.bbox.x/r)*ci),y:di(ui(u.bbox.y/i)*ci),w:di(ui(u.bbox.w/r)*ci),h:di(ui(u.bbox.h/i)*ci)}:null}}c();var pi=15e3,mi=E();function hi({url:e,label:t}){let{src:n,failed:r}=bn(e);return n===null?i(`div`,{className:`flex h-full w-full items-center justify-center bg-surface-hover`,children:r?i(S,{className:`h-4 w-4 text-foreground-subtle opacity-60`}):i(V,{className:`h-4 w-4 animate-spin text-foreground-subtle opacity-70`})}):i(`img`,{src:n,alt:t,className:`h-full w-full object-cover`})}var gi=new Set([`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`]),_i=new Set([`keyFrame`,`fullFrame`,`fullFrameBoxed`,`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`,`sceneFrame`,`lastSceneFrame`]);function vi(e){let[t,n]=o(null);return a(()=>{if(n(null),!e)return;let t=!1,r=new Image;return r.onload=()=>{t||n({width:r.naturalWidth,height:r.naturalHeight})},r.src=e,()=>{t=!0,r.onload=null}},[e]),t}function yi({overlay:t,onPickSnapshot:n}){let{t:r}=J();return!t.polyline&&!t.peakBox&&t.snapshots.length===0?null:e(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`pointer-events-none absolute inset-0 h-full w-full`,children:[t.peakBox&&i(`rect`,{x:t.peakBox.x,y:t.peakBox.y,width:t.peakBox.w,height:t.peakBox.h,fill:`none`,stroke:`var(--color-warning)`,strokeWidth:2,vectorEffect:`non-scaling-stroke`,rx:1}),t.polyline&&i(`polyline`,{points:t.polyline,fill:`none`,stroke:`var(--color-info)`,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,strokeOpacity:.85,vectorEffect:`non-scaling-stroke`}),t.points.map((e,t)=>i(`circle`,{cx:e.x,cy:e.y,r:1,fill:`var(--color-info)`,fillOpacity:.6,vectorEffect:`non-scaling-stroke`},`${String(e.x)}-${String(e.y)}-${String(t)}`)),t.snapshots.map((e,t)=>i(`circle`,{cx:e.x,cy:e.y,r:1.9,fill:`var(--color-info)`,fillOpacity:.95,stroke:`var(--color-background)`,strokeWidth:.7,vectorEffect:`non-scaling-stroke`,className:n?`pointer-events-auto cursor-pointer`:void 0,onClick:n?t=>{t.stopPropagation(),n(e.mediaId)}:void 0,children:i(`title`,{children:r(`detectionIntelligence.eventDetailPanel.snapshotCheckpointClickToView`,`Snapshot checkpoint — click to view this frame`)})},`snap-${String(e.mediaId)}-${String(t)}`)),t.start&&i(`circle`,{cx:t.start.x,cy:t.start.y,r:2.4,fill:`var(--color-success)`,stroke:`var(--color-background)`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`}),t.end&&i(`circle`,{cx:t.end.x,cy:t.end.y,r:2.4,fill:`var(--color-danger)`,stroke:`var(--color-background)`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`})]})}function X({label:t,value:n,mono:r,wrap:a}){return e(`div`,{className:`flex items-baseline justify-between gap-3 border-b border-border/60 py-1.5 last:border-0`,children:[i(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:t}),i(`span`,{className:`min-w-0 ${a?`break-words`:`truncate`} text-right text-xs font-medium text-foreground ${r?`font-mono text-[11px]`:``}`,title:n,children:n})]})}function bi({row:t,cameraName:s,deleteAvailable:c,onClose:l,onDeleted:d,onFlagsChanged:f}){let{t:p}=J(),m=ue(),h=te(),g=M(),_=gr(),v=t!==null,y=t?.deviceId??0,b=t?.trackId??``,x=t?.timestamp??0,C=t?.windowMs??0,{data:w}=Lt({deviceId:y,trackId:b},{enabled:v}),{data:T}=nt({trackId:b,deviceId:y},{enabled:v}),E=w?.bestEventId===void 0?void 0:Number(w.bestEventId),{data:D}=xt({ownerType:`object`,eventId:E??0,deviceId:y},{enabled:v&&E!==void 0&&Number.isFinite(E)}),{data:O}=Pt({deviceId:y},{enabled:v}),k=(O??[]).find(e=>e.addonId!==void 0)?.addonId,{data:A}=Dt({deviceId:y,since:x-pi,until:x+C+pi,provider:k??``},{enabled:v&&k!==void 0}),[j,N]=o(null),[P,I]=o(!1),{publicOrigin:L,probes:ee}=Xr(v);a(()=>{N(null)},[y,b]);let R=n(()=>{let e=T??[],t=D??[];return e.find(e=>e.kind===`keyFrame`)||t.find(e=>e.kind===`fullFrameBoxed`)||([...t,...e].find(e=>e.kind===`crop`)??null)},[T,D]),z=j??R,ne=bn(z?z.url:void 0),B=n(()=>{let e=new Set,t=[];for(let n of[...D??[],...T??[]])e.has(n.mediaId)||(e.add(n.mediaId),t.push(n));return t},[D,T]),re=n(()=>B.find(e=>gi.has(e.kind))??null,[B]),ie=vi(bn(re?re.url:void 0).src),ae=n(()=>fi(w?.positions??[],ie,{snapshots:(w?.snapshots??[]).map(e=>({x:e.position.x,y:e.position.y,mediaId:e.mediaId}))}),[w?.positions,w?.snapshots,ie]),oe=r(e=>{let t=B.find(t=>t.mediaId===e);t&&N(t)},[B]);if(t===null)return null;let ce=ne.src,le=z?.kind,de=le!==void 0&&_i.has(le)&&ie!==null&&(w?.positions.length??0)>=2,fe=A&&A.length>0?A[0]:null,H=()=>{fe&&(I(!0),(async()=>{try{let e=await m.trpcClient.videoclips.getClipPlayback.query({deviceId:t.deviceId,clipId:fe.id});window.open(e.playbackUrl,`_blank`,`noopener`)}catch{h({title:p(`detectionIntelligence.eventDetailPanel.clipUnavailable`,`Clip unavailable`),message:p(`detectionIntelligence.eventDetailPanel.couldNotResolveClipPlayback`,`Could not resolve clip playback. Check the server logs.`),variant:`warning`})}finally{I(!1)}})())},pe=()=>{!c||_.isPending||(async()=>{if(await g({title:p(`detectionIntelligence.eventDetailPanel.deleteTrack`,`Delete track`),message:p(`detectionIntelligence.eventDetailPanel.deleteThisTrackAndEvery`,`Delete this track and every image and clip captured for it? This cannot be undone.`),confirmLabel:p(`common.delete`,`Delete`),variant:`danger`}))try{await _.mutateAsync({deviceId:t.deviceId,trackIds:[t.trackId]}),d()}catch{await h({title:p(`detectionIntelligence.eventDetailPanel.deleteFailed`,`Delete failed`),message:p(`detectionIntelligence.eventDetailPanel.failedToDeleteThisTrack`,`Failed to delete this track. Check the server logs.`),variant:`danger`})}})()},me=Math.round(t.importance*100),he=w?.importanceReason?`${String(me)}% · ${w.importanceReason}`:`${String(me)}%`,ge=w?.zonesVisited&&w.zonesVisited.length>0?w.zonesVisited.join(`, `):`—`,_e=w?.audioLabels&&w.audioLabels.length>0?w.audioLabels:t.audioLabels&&t.audioLabels.length>0?t.audioLabels:void 0,ve=_e===void 0?`—`:_e.map(e=>`${e.label} ×${String(e.count)} (${String(Math.round(e.peakScore*100))}%)`).join(` · `),ye=w?w.totalDistance.toFixed(2):`—`,U=Jr(w?.previewMissReason),be=un(w?w.firstSeen:x),xe=w?un(w.lastSeen):`—`,Se=si(w),W={detected:p(`detectionIntelligence.eventDetailPanel.detectedOn`,`Detected on`),opened:p(`detectionIntelligence.eventDetailPanel.openedOn`,`Opened on`),closed:p(`detectionIntelligence.eventDetailPanel.closedOn`,`Closed on`)};return i(Re,{open:!0,onOpenChange:e=>!e&&l(),children:e(De,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":p(`detectionIntelligence.eventDetailPanel.eventDetail`,`Event detail`),className:`flex h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:h-auto md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[i(`header`,{className:`flex shrink-0 items-start gap-2 border-b border-border py-3 pl-4 pr-10`,children:e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:[t.className,ar(t)?e(`span`,{className:`text-foreground-subtle`,children:[` · `,ar(t)]}):null]}),i(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:s})]})}),e(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[ce?i(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:i(dn,{src:ce,alt:p(`detectionIntelligence.eventDetailPanel.keyFrameFrom`,`Key frame from {{cameraName}}`,{cameraName:s}),fit:`natural`,className:`w-full`,overlay:de?i(yi,{overlay:ae,onPickSnapshot:oe}):void 0})}):i(`div`,{className:`flex aspect-video w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-surface-hover text-foreground-subtle`,children:ne.failed?e(u,{children:[i(S,{className:`h-8 w-8 opacity-60`}),i(`span`,{className:`text-[11px]`,children:p(`detectionIntelligence.eventDetailPanel.keyFrameMediaUnavailable`,`Key-frame media unavailable`)})]}):i(V,{className:`h-6 w-6 animate-spin opacity-70`})}),B.length>0&&i(`div`,{className:`-mx-1 flex gap-2 overflow-x-auto px-1 pb-1`,children:B.map(t=>{let n=Vr(t.kind),r=Hr(mi,t.url),a=L?Hr(L,t.url):null;return e(`figure`,{className:`flex w-32 shrink-0 flex-col gap-1`,children:[i(K,{variant:`unstyled`,type:`button`,onClick:()=>N(t),className:`relative h-16 w-full overflow-hidden rounded border border-border hover:border-primary`,title:`${n} · ${un(t.timestamp)}`,children:i(hi,{url:t.url,label:n})}),e(`figcaption`,{className:`min-w-0 px-0.5`,children:[i(`div`,{className:`truncate text-[10px] font-medium leading-tight text-foreground`,title:n,children:n}),i(`div`,{className:`text-[10px] leading-tight text-foreground-subtle`,title:un(t.timestamp),children:yn(t.timestamp)})]}),i(Rr,{localUrl:r,publicUrl:a})]},t.mediaId)})}),ee,fe&&e(K,{variant:`secondary`,onClick:H,disabled:P,children:[P?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(F,{className:`h-3.5 w-3.5`}),` `,p(`detectionIntelligence.eventDetailPanel.viewClip`,`View clip`)]}),i(ai,{deviceId:t.deviceId,trackId:t.trackId,...(w?.markForTrain??t.markForTrain)===void 0?{}:{markForTrain:w?.markForTrain??t.markForTrain},...(w?.debug??t.debug)===void 0?{}:{debug:w?.debug??t.debug},...(w?.favourited??t.favourited)===void 0?{}:{favourited:w?.favourited??t.favourited},onChange:f}),U!==null&&e(`div`,{className:`rounded-lg border border-warning/40 bg-warning/8 px-3 py-2`,children:[i(`p`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:p(`detectionIntelligence.eventDetailPanel.bestShot`,`Best shot`)}),i(`p`,{className:`mt-0.5 text-xs text-foreground`,children:U.sentence}),i(`code`,{className:`mt-1 block break-all font-mono text-[10px] text-foreground-subtle`,children:U.raw})]}),e(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[i(X,{label:p(`detectionIntelligence.eventDetailPanel.camera`,`Camera`),value:s}),Se.map(e=>i(X,{label:W[e.kind],value:e.value,mono:!0,wrap:!0},e.kind)),i(X,{label:p(`detectionIntelligence.eventDetailPanel.class`,`Class`),value:t.className}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.label`,`Label`),value:t.label??`—`}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.subLabel`,`Sub-label`),value:t.subLabel??`—`}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.importance`,`Importance`),value:he}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.zonesVisited`,`Zones visited`),value:ge}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.audioHeard`,`Audio heard`),value:ve}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.totalDistance`,`Total distance`),value:ye}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.firstSeen`,`First seen`),value:be}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.lastSeen`,`Last seen`),value:xe}),i(X,{label:p(`detectionIntelligence.eventDetailPanel.track`,`Track`),value:t.trackId,mono:!0})]})]}),i(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:i(`span`,{title:c?void 0:mr,children:e(K,{variant:`secondary`,onClick:pe,disabled:!c||_.isPending,children:[_.isPending?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(se,{className:`h-3.5 w-3.5`}),` `,p(`detectionIntelligence.eventDetailPanel.deleteTrack`,`Delete track`)]})})})]})})}function xi(e){if(e===void 0||!Number.isFinite(e)||e<=0)return``;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`${String(n)}m ${String(r).padStart(2,`0`)}s`}function Si({row:t,cameraName:n,nowMs:r,onOpenDetail:a,selected:o=!1,onToggleSelect:s,score:c,provenance:l,footer:u}){let{t:d}=J(),f=bn(t.mediaId===void 0?xn(`track`,t.trackId):Sn(t.mediaId)),p=Math.round(t.importance*100),m=c===void 0?void 0:Math.round(c*100),h=xi(t.windowMs),g=()=>a(t),_=Kr(l);return e(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${o?`border-primary ring-1 ring-primary`:`border-border`}`,children:[e(`div`,{className:`aspect-video relative overflow-hidden bg-surface-hover`,children:[f.src?i(`img`,{src:f.src,alt:d(`detectionIntelligence.eventCard.eventFrom`,`Event from {{cameraName}}`,{cameraName:n}),onClick:g,className:`h-full w-full cursor-zoom-in object-cover`}):i(K,{variant:`unstyled`,type:`button`,onClick:g,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-surface-hover text-foreground-subtle`,title:f.failed?d(`detectionIntelligence.eventCard.keyEventMediaUnavailable`,`Key-event media unavailable`):d(`detectionIntelligence.eventCard.noKeyEventMedia`,`No key-event media`),children:i(S,{className:`h-6 w-6 opacity-60`})}),s&&i(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),s(ur(t.deviceId,t.trackId))},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":o?d(`detectionIntelligence.eventCard.deselect`,`Deselect`):d(`detectionIntelligence.eventCard.select`,`Select`),children:o?i(be,{className:`h-4 w-4 text-primary`}):i(R,{className:`h-4 w-4`})}),m!==void 0&&e(`span`,{className:`absolute left-1 top-1 z-10 rounded bg-primary/85 px-1.5 py-0.5 text-[10px] font-semibold text-white tabular-nums`,title:d(`detectionIntelligence.eventCard.clipSemanticMatchScore`,`CLIP semantic-match score`),children:[String(m),`%`]}),p>0&&i(`span`,{className:`absolute right-1 top-1 z-10 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:String(p)}),_!==null&&i(`span`,{className:`absolute bottom-1 right-1 z-10 rounded px-1.5 py-0.5 text-[10px] font-semibold text-white ${_.tone===`warning`?`bg-warning/90`:`bg-black/70`}`,title:_.title,children:_.label}),(t.markForTrain===!0||t.retrainStatus===`trained`||t.debug===!0||t.favourited===!0)&&e(`span`,{className:`absolute bottom-1 left-1 z-10 flex gap-1`,children:[t.markForTrain===!0&&i(`span`,{className:`rounded bg-primary/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.markedForTraining`,`Marked for training`),"aria-label":d(`detectionIntelligence.eventCard.markedForTraining`,`Marked for training`),children:i(ie,{className:`h-3 w-3`})}),t.retrainStatus===`trained`&&t.markForTrain!==!0&&i(`span`,{className:`rounded bg-success/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.trainingComplete`,`Training complete`),"aria-label":d(`detectionIntelligence.eventCard.trainingComplete`,`Training complete`),"data-testid":`retrain-status-trained`,children:i(re,{className:`h-3 w-3`})}),t.debug===!0&&i(`span`,{className:`rounded bg-black/70 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.flaggedForDebug`,`Flagged for debug`),"aria-label":d(`detectionIntelligence.eventCard.flaggedForDebug`,`Flagged for debug`),children:i(k,{className:`h-3 w-3`})}),t.favourited===!0&&i(`span`,{className:`rounded bg-primary/85 p-0.5 text-white`,title:d(`detectionIntelligence.eventCard.favourited`,`Favourited`),"aria-label":d(`detectionIntelligence.eventCard.favourited`,`Favourited`),children:i(z,{className:`h-3 w-3`})})]})]}),e(K,{variant:`unstyled`,type:`button`,onClick:g,className:`min-w-0 px-2 py-1.5 text-left space-y-0.5`,children:[e(`p`,{className:`text-[11px] font-medium text-foreground truncate`,title:t.className,children:[t.className,ar(t)?e(`span`,{className:`text-foreground-subtle`,children:[` · `,ar(t)]}):null]}),i(`p`,{className:`text-[10px] text-foreground-subtle truncate`,title:n,children:n}),e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle truncate`,children:ln(t.timestamp,r)}),h&&i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:h})]})]}),u!==void 0&&i(`div`,{className:`px-2 pb-1.5`,children:u})]})}function Ci({row:t,onSeek:n,onOpenDetail:r,size:a=0,onToggleSelect:o,selected:s=!1}){let{t:c}=J(),l=bn(t.mediaId===void 0?xn(`track`,t.trackId):Sn(t.mediaId)),u=Math.round(t.importance*100),d=ar(t),f=new Date(t.timestamp).toLocaleTimeString();return e(`div`,{className:`flex w-full items-center gap-2 rounded-md border bg-surface hover:bg-surface-hover ${s?`border-primary ring-1 ring-primary`:`border-border`}`,"data-testid":`event-row`,children:[o&&i(D,{className:`ml-2 shrink-0`,checked:s,onChange:()=>o(ur(t.deviceId,t.trackId)),"aria-label":c(`detectionIntelligence.eventRow.select`,`Select {{className}} at {{time}}`,{className:t.className,time:f})}),i(K,{variant:`unstyled`,type:`button`,onClick:()=>r(t),className:`aspect-video ${Dr[a]} shrink-0 overflow-hidden rounded-l-md bg-surface-hover`,"aria-label":c(`detectionIntelligence.eventRow.openDetail`,`Open event details`),children:l.src?i(`img`,{src:l.src,alt:``,className:`h-full w-full object-cover`}):i(`span`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:i(S,{className:`h-4 w-4 opacity-60`})})}),e(K,{variant:`unstyled`,type:`button`,onClick:()=>n(t.timestamp),className:`flex min-w-0 flex-1 items-center gap-2 py-1 pr-2 text-left`,"aria-label":c(`detectionIntelligence.eventRow.seek`,`Play {{className}} at {{time}}`,{className:t.className,time:f}),children:[e(`span`,{className:`min-w-0 flex-1`,children:[e(`span`,{className:`block truncate text-[12px] font-medium text-foreground`,children:[t.className,d?e(`span`,{className:`text-foreground-subtle`,children:[` · `,d]}):null]}),i(`span`,{className:`block text-[11px] tabular-nums text-foreground-subtle`,children:f})]}),u>0&&i(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-semibold tabular-nums text-foreground-muted`,children:String(u)})]}),e(`div`,{className:`flex shrink-0 items-center gap-0.5 pr-1`,children:[i(wi,{icon:ne,label:c(`detectionIntelligence.eventRow.details`,`Details`),onClick:()=>r(t)}),i(wi,{icon:j,label:c(`detectionIntelligence.eventRow.play`,`Play`),onClick:()=>n(t.timestamp)})]})]})}function wi({icon:t,label:n,onClick:r}){return e(Ct,{children:[i(lt,{children:i(Ut,{variant:`ghost`,size:`sm`,icon:t,"aria-label":n,onClick:r})}),i(dt,{children:n})]})}var Ti=120*1e3;function Ei(e,t,n=Ti){let r=[...e].sort((e,n)=>t(n)-t(e)),i=[];for(let e of r){let r=i[i.length-1],a=t(e);r!==void 0&&r.fromMs-a<=n?(r.events.push(e),r.fromMs=a):i.push({fromMs:a,toMs:a,events:[e]})}return i}c();function Di(){let[e,n]=o(!1),i=t(null),[s,c]=o(0),l=r(e=>{i.current!==e&&(i.current=e,c(e=>e+1))},[]);return a(()=>{let e=i.current;if(!e||typeof IntersectionObserver>`u`){n(!1);return}let t=new IntersectionObserver(e=>{let t=e[e.length-1];t&&n(!t.isIntersecting)},{rootMargin:`64px 0px 0px 0px`,threshold:0});return t.observe(e),()=>t.disconnect()},[s]),{ref:l,scrolledPast:e}}c();var Oi=[`events-feed`],ki=60,Ai=[{value:`importance`,labelKey:`detectionIntelligence.eventsSection.sortImportance`,icon:ye},{value:`time`,labelKey:`detectionIntelligence.eventsSection.sortRecent`,icon:m}];function ji({deviceId:t,onSeek:r,window:s,rowFilter:c,onListChange:d,layout:f=`cards`,toolbarTarget:p}={}){let{t:m}=J(),h=l(),g=te(),_=M(),[b,S]=o(mn),[C,w]=o(new Set),[E,O]=o(new Set),[k,A]=o(new Set),[j,N]=Te({storageKey:Er,options:Tr,defaultSize:0}),P=Or(j),[F,I]=o(0),[L,ee]=o(`time`),[R,z]=o(new Set),[ne,B]=o(null),[re,ie]=o(()=>Date.now());a(()=>{let e=setInterval(()=>ie(Date.now()),6e4);return()=>clearInterval(e)},[]);let ae=n(()=>fr({fromMs:b.fromMs,toMs:b.toMs},re),[b.fromMs,b.toMs,re]),oe=s?.since??ae.since,ce=s?.until??ae.until,le=Di(),{pending:ue,refreshNow:de}=Sr({paused:ne!==null||R.size>0||le.scrolledPast}),{data:fe=[]}=We({isCamera:!0,projection:`slim`}),H=n(()=>t===void 0?fe:fe.filter(e=>e.id===t),[fe,t]),pe=n(()=>H.map(e=>e.id),[H]),{data:me,isLoading:he}=$e({deviceIds:pe},{enabled:pe.length>0,staleTime:5*6e4}),ge=n(()=>Pr(me??[],C),[me,C]),_e=gr(),ye=_e.isPending,{rows:U,isLoading:be}=yr({deviceIds:pe,since:oe,until:ce,minImportance:F>0?F:void 0,classFilter:E.size===1?[...E][0]:void 0}),xe=n(()=>{let e=new Map;for(let t of H??[])e.set(t.id,t.name);return e},[H]),Se=e=>xe.get(e)??m(`detectionIntelligence.cameraFallback`,{id:String(e)}),W=n(()=>_n(U).map(e=>({id:e,name:Se(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[U,xe]),Ce=n(()=>cr(lr(U,{cameras:C,classes:E,minImportance:F}).filter(e=>!k.has(e.className)&&(c===void 0||c(e))),L),[U,C,E,k,F,L,c]),we=n(()=>U.map(e=>e.className),[U]),Ee=E.size>0||k.size>0||F>0;a(()=>{d?.({rows:Ce,narrowed:Ee})},[Ce,Ee,d]);let De=pn(Ce,ki,n(()=>JSON.stringify([[...C].sort((e,t)=>e-t),[...E].sort(),[...k].sort(),F,L,oe,ce]),[C,E,k,F,L,oe,ce])),Oe=()=>{h.invalidateQueries({queryKey:Oi})},ke=()=>z(new Set),Ae=Ce.map(e=>ur(e.deviceId,e.trackId)),je=Ae.length>0&&Ae.every(e=>R.has(e)),Me=()=>z(je?new Set:new Set(Ae));function Ne(e){z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function Pe(){if(R.size===0||!pr)return;let e=dr(U,R),t=[...e.values()].reduce((e,t)=>e+t.length,0);t!==0&&(async()=>{await _({title:m(`detectionIntelligence.eventsSection.deleteTitle`,{count:t}),message:m(`detectionIntelligence.eventsSection.deleteMessage`,{count:t}),confirmLabel:m(`common.delete`,`Delete`),variant:`danger`})&&Fe(e)})()}function Fe(e){let t=[...e];Promise.allSettled(t.map(([e,t])=>_e.mutateAsync({deviceId:e,trackIds:t}))).then(e=>{Oe();let n=[],r=new Set;if(e.forEach((e,i)=>{let a=t[i];if(!a)return;let[o,s]=a;if(e.status===`fulfilled`)for(let e of s)r.add(ur(o,e));else n.push(o)}),z(e=>{let t=new Set(e);for(let e of r)t.delete(e);return t}),n.length>0){let e=n.map(e=>Se(e)).join(`, `);g({title:m(`detectionIntelligence.eventsSection.someTracksWereNotDeleted`,`Some tracks were not deleted`),message:m(`detectionIntelligence.eventsSection.failedToDeleteTracksOn`,`Failed to delete tracks on: {{names}}. They remain selected — retry, or check the server logs.`,{names:e}),variant:`danger`})}})}let Ie=n(()=>Ei(De.pageItems,e=>e.timestamp),[De.pageItems]),Le=Ce.length!==U.length,Re=t=>i(Si,{row:t,cameraName:Se(t.deviceId),nowMs:re,selected:R.has(ur(t.deviceId,t.trackId)),onToggleSelect:Ne,onOpenDetail:B,footer:r===void 0?void 0:e(K,{variant:`ghost`,onClick:()=>r(t.timestamp),children:[i(ve,{className:`h-3.5 w-3.5`}),m(`detectionIntelligence.eventsSection.showInReview`,`Show in Review`)]})},ur(t.deviceId,t.trackId)),ze=f===`rows`&&r!==void 0,Be=e=>ze?i(Ci,{row:e,onSeek:r,onOpenDetail:B,size:P,selected:R.has(ur(e.deviceId,e.trackId)),onToggleSelect:Ne},ur(e.deviceId,e.trackId)):Re(e),Ve=e=>ze?i(`div`,{className:`flex flex-col gap-1`,"data-testid":`events-grid`,children:e.map(Be)}):i(zt,{status:`ready`,testId:`events-grid`,children:e.map(Be)}),He=e(`div`,{className:p===void 0?`flex flex-wrap items-center gap-1.5`:`contents`,children:[s===void 0&&i(cn,{onChange:S}),t===void 0&&i(hn,{cameras:W,selected:C,onChange:w}),i(kr,{groups:ge,selected:E,onChange:O,loading:he}),ze&&i(wr,{classes:we,hidden:k,onChange:A}),e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:m(`detectionIntelligence.eventsSection.minScore`,`Min score`)}),i(v,{min:0,max:1,step:.05,value:F,onChange:e=>I(Number(e.target.value)),className:`h-1 w-24 cursor-pointer accent-primary`,"aria-label":m(`detectionIntelligence.eventsSection.minimumImportance`,`Minimum importance`)}),i(`span`,{className:`w-6 tabular-nums text-foreground`,children:Math.round(F*100)})]}),i(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:Ai.map(t=>{let n=t.icon;return e(`button`,{type:`button`,onClick:()=>ee(t.value),className:`flex items-center gap-1 rounded px-2 py-1 text-[11px] transition-colors ${L===t.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[i(n,{className:`h-3.5 w-3.5`}),` `,m(t.labelKey)]},t.value)})}),!be&&i(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Le?m(`detectionIntelligence.eventsSection.ofEvents`,`{{value1}} of {{value2}} events`,{value1:String(Ce.length),value2:String(U.length)}):m(`detectionIntelligence.eventsSection.eventCount`,{count:Ce.length})})]});return e(`div`,{className:`relative space-y-3`,children:[p===void 0?He:p!==null&&Jt(He,p),R.size>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:m(`common.selectedCount`,{count:R.size})}),e(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[i(`span`,{title:pr?void 0:`Track deletion arrives with the next server update`,children:e(K,{variant:`secondary`,onClick:Pe,disabled:!pr||ye,children:[ye?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(se,{className:`h-3.5 w-3.5`}),` `,m(`common.delete`,`Delete`)]})}),i(K,{variant:`ghost`,onClick:ke,disabled:ye,children:i(y,{className:`h-3.5 w-3.5`})})]})]}),ue&&i(`div`,{className:`sticky top-2 z-20 flex justify-center`,children:i(`button`,{type:`button`,onClick:de,className:`rounded-full border border-primary/40 bg-surface px-3 py-1 text-[11px] font-medium text-primary shadow-sm hover:bg-primary/10`,children:m(`detectionIntelligence.eventsSection.newEventsRefresh`,`New events — refresh`)})}),be?i(zt,{status:`pending`,pendingMessage:`Loading events…`,testId:`events-grid`}):Ce.length===0?i(yt,{icon:x,title:Le?m(`detectionIntelligence.eventsSection.nothingMatchesTheFilter`,`Nothing matches the filter`):m(`detectionIntelligence.eventsSection.noKeyEventsInThis`,`No key events in this window`),description:Le?m(`detectionIntelligence.eventsSection.widenTheDateRangeClear`,`Widen the date range, clear cameras or kinds, or lower the min score.`):m(`detectionIntelligence.eventsSection.capturedTracksAppearHereWhen`,`Captured tracks appear here when the pipeline scores a key event.`)}):e(u,{children:[i(`div`,{ref:le.ref,"aria-hidden":!0,className:`h-0`}),ze&&e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(D,{checked:je,onChange:Me,"data-testid":`event-rows-select-all`}),i(`span`,{children:m(`detectionIntelligence.eventsSection.selectAll`,`Select all ({{count}})`,{count:Ce.length})})]}),e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(T,{className:`h-3.5 w-3.5`}),i(`span`,{children:m(`detectionIntelligence.eventsSection.rowSize`,`Size`)}),i(v,{min:0,max:Tr.length-1,step:1,value:P,onChange:e=>N(Number(e.target.value)),className:`h-1 w-24 cursor-pointer accent-primary`,"data-testid":`event-row-size`,"aria-label":m(`detectionIntelligence.eventsSection.rowSizeLabel`,`Event row size`)})]})]}),!ze&&t!==void 0&&L===`time`?Ie.map(t=>e(`div`,{className:`space-y-1.5`,children:[i(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:m(`detectionIntelligence.eventsSection.clusterHeading`,{count:t.events.length,time:new Date(t.toMs).toLocaleString()})}),Ve(t.events)]},t.toMs)):Ve(De.pageItems),i(gn,{currentPage:De.page,totalItems:De.totalItems,pageSize:De.pageSize,onPageChange:De.setPage,itemNoun:`events`})]}),ne&&i(bi,{row:ne,cameraName:Se(ne.deviceId),deleteAvailable:pr,onClose:()=>B(null),onDeleted:()=>{Oe(),B(null)},onFlagsChanged:e=>{B(t=>t&&t.trackId===e.trackId?{...t,markForTrain:e.markForTrain,debug:e.debug,favourited:e.favourited}:t)}})]})}var Mi={zone:null,identity:`any`,debug:!1};function Ni(e){return new Map(e.map(e=>[e.trackId,e]))}function Pi(e){let t=new Set;for(let n of e)for(let e of n.zoneNames??[])t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function Fi(e,t){if(t===`any`)return!0;let n=e.classes??[];return t===`face`?e.hasFace===!0||n.includes(`face`):n.includes(`plate`)}function Ii(e,t){return n=>{if(e.debug&&n.debug!==!0)return!1;if(e.zone===null&&e.identity===`any`)return!0;let r=t.get(n.trackId);return r===void 0?!0:e.zone!==null&&!(r.zoneNames??[]).includes(e.zone)?!1:Fi(r,e.identity)}}function Li(e){return e.zone!==null||e.identity!==`any`}function Ri(e,t,n){return Li(t)?e.filter(e=>!n.has(e.trackId)).length:0}function zi(e){return e.map(e=>({atMs:e.timestamp,kind:e.className===`audio`?`audio`:`object`}))}var Bi=`/addon/training`;function Vi(){let{t}=J(),n=nn();return e(pt,{className:`flex flex-col gap-3 border-border bg-surface p-3 sm:flex-row sm:items-center sm:gap-4`,"data-testid":`events-feed-retrain-cta`,children:[e(`div`,{className:`flex min-w-0 flex-1 items-start gap-2.5`,children:[i(ie,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary`,"aria-hidden":!0}),e(`div`,{className:`min-w-0 space-y-0.5`,children:[i(`p`,{className:`text-xs font-medium text-foreground`,children:t(`detectionIntelligence.retrainTabCallout.trainingFromThisFeed`,`Training from this feed`)}),i(`p`,{className:`${de} leading-relaxed`,children:t(`detectionIntelligence.retrainTabCallout.markATrackWithThe`,`Mark a track with the graduation-cap control on its card. On Training you correct frames, build collections, and start cloud fine-tunes.`)})]})]}),i(K,{variant:`outline`,size:`sm`,className:`shrink-0 self-start sm:self-center`,onClick:()=>n(Bi),children:t(`detectionIntelligence.retrainTabCallout.openTraining`,`Open Training`)})]})}c();var Hi=50,Ui=350,Wi=[{value:`loose`,labelKey:`detectionIntelligence.semanticEventSearch.looseLabel`,titleKey:`detectionIntelligence.semanticEventSearch.looseTitle`},{value:`balanced`,labelKey:`detectionIntelligence.semanticEventSearch.balancedLabel`,titleKey:`detectionIntelligence.semanticEventSearch.balancedTitle`},{value:`strict`,labelKey:`detectionIntelligence.semanticEventSearch.strictLabel`,titleKey:`detectionIntelligence.semanticEventSearch.strictTitle`}];function Gi(e){let t=String(e.id);return{id:t,trackId:e.trackId??t,deviceId:e.deviceId,timestamp:e.timestamp,className:e.className,label:e.label,subLabel:e.subLabel,importance:e.importance??0,bestEventId:t,mediaId:e.keyFrameMediaId??e.mediaId,windowMs:void 0}}function Ki({deviceId:r}){let s=t(null);Ce(s);let{t:c}=J(),[l,u]=o(``),[d,p]=o(`loose`),[m,h]=o(null),[g,_]=o(null),v=r??g,[b,x]=o(null),S=Ne(l,Ui).trim(),C=S.length>0,[w,T]=o(()=>Date.now());a(()=>{let e=setInterval(()=>T(Date.now()),6e4);return()=>clearInterval(e)},[]);let{data:E=[]}=We({isCamera:!0,projection:`slim`}),D=n(()=>{let e=new Map;for(let t of E)e.set(t.id,t.name);return e},[E]),O=e=>D.get(e)??c(`detectionIntelligence.cameraFallback`,{id:String(e)}),k=n(()=>E.map(e=>e.id),[E]),{data:A}=$e({deviceIds:k},{enabled:k.length>0,staleTime:5*6e4}),j=n(()=>Nr(A??[],new Set(v===null?[]:[v])),[A,v]);a(()=>{m!==null&&(j.some(e=>e.kind===m)||h(null))},[j,m]);let{data:M,isFetching:N,isError:F,error:I}=Tt({text:S,strictness:d,limit:Hi,classFilter:m??void 0,deviceId:v??void 0},{enabled:C}),L=n(()=>[...M??[]].sort((e,t)=>t.score-e.score).map(e=>({...Gi(e),score:e.score})),[M]);function ee(e){h(t=>t===e?null:e)}return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`div`,{className:`relative min-w-[16rem] flex-1`,children:[i(f,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-foreground-subtle`}),i(Ke,{ref:s,type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:c(`detectionIntelligence.semanticEventSearch.semanticSearchDescribeWhatYou`,`Semantic search — describe what you're looking for…`),className:`h-9 w-full rounded-md border border-border bg-background pl-8 pr-8 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":c(`detectionIntelligence.semanticEventSearch.semanticEventSearch`,`Semantic event search`)}),l&&i(`button`,{type:`button`,onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":c(`detectionIntelligence.semanticEventSearch.clearSearch`,`Clear search`),children:i(y,{className:`h-3.5 w-3.5`})})]}),N&&C&&i(V,{className:`h-4 w-4 shrink-0 animate-spin text-foreground-subtle`})]}),e(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[i(`div`,{className:`flex items-center gap-1`,children:j.map(e=>i(`button`,{type:`button`,onClick:()=>ee(e.kind),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${m===e.kind?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:It(e)},e.kind))}),r===void 0&&e(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:c(`detectionIntelligence.semanticEventSearch.camera`,`Camera`)}),i(P,{value:v===null?``:String(v),onChange:e=>_(e.target.value===``?null:Number(e.target.value)),className:`h-7 text-xs`,"aria-label":c(`detectionIntelligence.semanticEventSearch.filterByCamera`,`Filter by camera`),options:[{value:``,label:c(`detectionIntelligence.semanticEventSearch.all`,`All`)},...E.map(e=>({value:String(e.id),label:e.name}))]})]}),e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:c(`detectionIntelligence.semanticEventSearch.match`,`Match`)}),i(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:Wi.map(e=>i(`button`,{type:`button`,onClick:()=>p(e.value),className:`rounded px-2 py-1 text-[11px] transition-colors ${d===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,title:c(e.titleKey),children:c(e.labelKey)},e.value))})]}),C&&!N&&!F&&i(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:c(`common.matches`,{count:L.length})})]})]}),C&&e(`div`,{className:`space-y-3`,children:[F&&e(`p`,{className:`py-4 text-xs text-danger`,children:[c(`detectionIntelligence.semanticEventSearch.searchFailed`,`Search failed:`),` `,I instanceof Error?I.message:c(`detectionIntelligence.semanticEventSearch.unknownError`,`unknown error`),`. Check that the CLIP embedding step is enabled.`]}),!F&&N&&L.length===0&&i(zt,{status:`pending`,pendingMessage:`Searching…`,testId:`semantic-events-grid`}),!F&&!N&&L.length===0&&i(zt,{status:`empty`,emptyMessage:c(`detectionIntelligence.semanticEventSearch.noSemanticMatchesForTry`,`No semantic matches for “{{debounced}}”. Try a looser match threshold or a different phrasing.`,{debounced:S}),testId:`semantic-events-grid`}),!F&&L.length>0&&i(zt,{status:`ready`,testId:`semantic-events-grid`,children:L.map(e=>i(Si,{row:e,cameraName:O(e.deviceId),nowMs:w,score:e.score,onOpenDetail:x},e.id))})]}),b&&i(bi,{row:b,cameraName:O(b.deviceId),deleteAvailable:pr,onClose:()=>x(null),onDeleted:()=>x(null)})]})}c();function qi(e,t){let n=Math.max(0,Math.round((e-t)/6e4));if(n<1)return q.t(`helpers.relativeTime.justNow`);if(n<60)return`${String(n)}m`;let r=Math.floor(n/60);return`${String(r)}h ${String(n%60)}m`}function Ji({row:t,cameraName:n,nowMs:r}){let{t:a}=J(),o=bn(t.keyFrameMediaId===void 0?void 0:Sn(t.keyFrameMediaId));return e(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-border bg-surface`,children:[e(`div`,{className:`relative aspect-video overflow-hidden bg-surface-hover`,children:[o.src?i(`img`,{src:o.src,alt:a(`detectionIntelligence.stationarySection.parkedOn`,`Parked {{className}} on {{cameraName}}`,{className:t.className,cameraName:n}),className:`h-full w-full object-cover`}):i(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:i(I,{className:`h-6 w-6`})}),i(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium capitalize text-white`,children:t.label??t.className})]}),e(`div`,{className:`flex flex-col gap-0.5 p-1.5`,children:[i(`span`,{className:`truncate text-[11px] text-foreground`,children:n}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`common.parkedSince`,{since:qi(r,t.becameStationaryAt)})})]})]})}function Yi({deviceId:t}={}){let{t:r}=J(),[a,s]=o(!1),c=Date.now(),{data:l=[]}=We({isCamera:!0,projection:`slim`}),u=n(()=>t===void 0?l.map(e=>e.id):[t],[l,t]),d=n(()=>{let e=new Map;for(let t of l)e.set(t.id,t.name);return e},[l]),{rows:f,unreadableCount:p}=Tn(u);return f.length===0&&p===0?null:e(`div`,{className:`rounded-md border border-border bg-surface/40`,children:[e(K,{variant:`unstyled`,type:`button`,onClick:()=>s(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[i(a?ge:A,{className:`h-4 w-4 text-foreground-subtle`}),i(I,{className:`h-4 w-4 text-foreground-subtle`}),i(`span`,{className:`text-sm font-semibold text-foreground`,children:r(`detectionIntelligence.stationarySection.stationary`,`Stationary`)}),i(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:f.length}),i(`span`,{className:`ml-2 text-[11px] text-foreground-subtle`,children:r(`detectionIntelligence.stationarySection.parkedObjectsKeptOutOf`,`Parked objects — kept out of the event feed`)}),p>0?i(`span`,{className:`ml-2 text-[11px] text-warning`,children:r(`detectionIntelligence.stationarySection.unreadable`,{count:p})}):null]}),a&&i(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))] gap-2 p-3 pt-0`,children:f.map(e=>i(Ji,{row:e,cameraName:d.get(e.deviceId)??`Camera #${String(e.deviceId)}`,nowMs:c},e.id))})]})}var Xi={status:`debug.tape.status`,promote:`debug.tape.promote`,list:`debug.tape.list`,tracks:`debug.tape.tracks`,review:`debug.tape.review`,release:`debug.tape.release`,remove:`debug.tape.delete`},Zi={setRelation:`debug.gt.setRelation`,setPurity:`debug.gt.setPurity`,list:`debug.gt.list`},Qi=_(`/addon/pipeline-analytics/tape-export`),$i=10*6e4;function ea(e){return`${Qi}?tapeId=${encodeURIComponent(e)}`}var ta=`The server answered in a shape this build does not understand.`;function na(e){return e instanceof Error?e.message:q.t(`helpers.eventsDebugTapes.actionFailed`)}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function ra(e,t){if(!(t in e))return;let n=e[t];return n===null?null:typeof n==`number`&&Number.isFinite(n)?n:void 0}function $(e,t){let n=e[t];return typeof n==`string`?n:null}function ia(e,t){let n=e[t];return typeof n==`boolean`?n:null}function aa(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e){let e=t(r);if(e===null)return null;n.push(e)}return n}function oa(e){return e===`off`||e===`recording`||e===`refused`||e===`failing`||e===`unknown`}function sa(e){if(!Z(e))return null;let t=Q(e,`deviceId`),n=e.state,r=Q(e,`gapsSinceArmed`),i=ra(e,`segmentsHeld`),a=ra(e,`bytesLastHour`),o=ra(e,`bytesHeld`);if(t===null||!oa(n)||r===null||i===void 0||a===void 0||o===void 0)return null;let s=$(e,`reason`),c=Q(e,`segmentOriginMs`),l=Q(e,`framesPerMin`),u=Q(e,`heldFromMs`),d=Q(e,`heldToMs`),f=$(e,`shelfError`);return{deviceId:t,state:n,gapsSinceArmed:r,segmentsHeld:i,bytesLastHour:a,bytesHeld:o,...s===null?{}:{reason:s},...c===null?{}:{segmentOriginMs:c},...l===null?{}:{framesPerMin:l},...u===null?{}:{heldFromMs:u},...d===null?{}:{heldToMs:d},...f===null?{}:{shelfError:f}}}function ca(e){return Z(e)?aa(e.cameras,sa):null}function la(e){if(!Z(e))return null;let t=$(e,`id`),n=Q(e,`deviceId`),r=$(e,`scenario`),i=e.lighting,a=Q(e,`fromMs`),o=Q(e,`toMs`),s=e.state,c=Q(e,`frames`),l=Q(e,`gaps`),u=Q(e,`bytes`),d=ia(e,`reviewed`),f=ia(e,`released`),p=aa(e.tracks,e=>typeof e==`string`?e:null),m=Q(e,`tracksStillStored`);return t===null||n===null||r===null||i!==`day`&&i!==`ir`||a===null||o===null||s!==`complete`&&s!==`incomplete`||c===null||l===null||u===null||d===null||f===null||p===null||m===null?null:{id:t,deviceId:n,scenario:r,note:$(e,`note`),lighting:i,fromMs:a,toMs:o,state:s,frames:c,gaps:l,bytes:u,reviewed:d,released:f,tracks:p,tracksStillStored:m}}function ua(e){return Z(e)?aa(e.tapes,la):null}function da(e){if(!Z(e))return null;let t=$(e,`trackId`),n=Q(e,`firstT`),r=Q(e,`lastT`),i=Q(e,`boundFrames`),a=$(e,`cls`),o=ia(e,`stillStored`);return t===null||n===null||r===null||i===null||a===null||o===null?null:{trackId:t,firstT:n,lastT:r,boundFrames:i,cls:a,stillStored:o}}function fa(e){if(!Z(e))return null;let t=$(e,`tapeId`),n=Q(e,`deviceId`),r=Q(e,`fromMs`),i=Q(e,`toMs`),a=ia(e,`reviewed`),o=aa(e.lanes,da);return t===null||n===null||r===null||i===null||a===null||o===null?null:{tapeId:t,deviceId:n,fromMs:r,toMs:i,reviewed:a,lanes:o}}function pa(e){if(!Z(e))return null;if(e.ok===!1){let t=$(e,`reason`),n=$(e,`detail`);return t===null||n===null?null:{ok:!1,reason:t,detail:n}}if(e.ok!==!0)return null;let t=$(e,`tapeId`),n=e.state,r=Q(e,`frames`),i=Q(e,`gaps`),a=Q(e,`pinnedTracks`),o=Q(e,`bytes`);return t===null||n!==`complete`&&n!==`incomplete`||r===null||i===null||a===null||o===null?null:{ok:!0,tapeId:t,state:n,frames:r,gaps:i,pinnedTracks:a,bytes:o}}function ma(e){if(!Z(e))return null;let t=e.status;if(t===`released`){let n=Q(e,`unpinned`),r=ia(e,`pinsSettled`);return n===null||r===null?null:{status:t,unpinned:n,pinsSettled:r}}if(t===`already-released`||t===`not-found`)return{status:t};if(t===`unavailable`){let n=$(e,`reason`);return n===null?null:{status:t,reason:n}}return null}function ha(e){if(!Z(e))return null;let t=e.status;if(t===`deleted`||t===`pins-owed`||t===`not-found`)return{status:t};if(t===`unavailable`){let n=$(e,`reason`);return n===null?null:{status:t,reason:n}}return null}function ga(e){switch(e.status){case`released`:case`deleted`:return null;case`already-released`:return q.t(`helpers.eventsDebugTapes.alreadyReleased`);case`not-found`:return q.t(`helpers.eventsDebugTapes.notFound`);case`pins-owed`:return q.t(`helpers.eventsDebugTapes.pinsOwed`);case`unavailable`:return q.t(`helpers.eventsDebugTapes.unavailable`,{reason:e.reason})}}function _a(e){if(!Z(e))return null;let t=$(e,`leftTrackId`),n=$(e,`rightTrackId`),r=e.relation,i=e.presence;return t===null||n===null||r!==`same-subject`&&r!==`different-subjects`?null:{leftTrackId:t,rightTrackId:n,relation:r,presence:i===`continuous`?`continuous`:null}}function va(e){if(!Z(e))return null;let t=$(e,`sourceTrackId`),n=e.purity;return t===null||n!==`mixed`&&n!==`not-a-subject`?null:{sourceTrackId:t,purity:n,switchAtMs:Q(e,`switchAtMs`)}}function ya(e){if(!Z(e))return null;let t=aa(e.relations,_a),n=aa(e.purities,va),r=ia(e,`truncated`);return t===null||n===null||r===null?null:{relations:t,purities:n,truncated:r}}function ba(e){if(!e.truncated)return null;let t=e.relations.length+e.purities.length;return q.t(`helpers.eventsDebugTapes.truncatedMarks`,{count:t})}function xa(e){return e.filter(e=>e.segmentsHeld===null||e.segmentsHeld>0).map(e=>({deviceId:e.deviceId,segmentsUnknown:e.segmentsHeld===null}))}function Sa(e){return e.slice(1).map((t,n)=>({trackId:e[n]??t,otherTrackId:t}))}function Ca(e){return e.flatMap((t,n)=>e.slice(n+1).map(e=>({trackId:t,otherTrackId:e})))}function wa(e,t){let n=[];for(let r of t.relations){let t=r.leftTrackId===e?r.rightTrackId:r.rightTrackId===e?r.leftTrackId:null;if(t===null)continue;let i=r.relation===`same-subject`?`same as`:`different from`;n.push(`${i} ${t}${r.presence===`continuous`?` (continuous)`:``}`)}for(let r of t.purities)r.sourceTrackId===e&&n.push(r.purity===`not-a-subject`?`not a subject`:r.switchAtMs===null?`mixed`:`mixed at switch`);return n}function Ta(e){switch(e.state){case`off`:return q.t(`helpers.eventsDebugTapes.statusOff`);case`recording`:return q.t(`helpers.eventsDebugTapes.statusRecording`);case`refused`:return q.t(`helpers.eventsDebugTapes.statusRefused`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)});case`failing`:return q.t(`helpers.eventsDebugTapes.statusFailing`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)});case`unknown`:return q.t(`helpers.eventsDebugTapes.statusUnknown`,{reason:e.reason??q.t(`helpers.eventsDebugTapes.unknownReason`)})}}var Ea={"window-too-long":`A promoted window is at most 30 minutes.`,"window-in-future":`The window ends in the future.`,"window-not-recorded":`No segment covers that window — the camera was not recording then, or it is older than 24 h.`,"invalid-scenario":`The scenario must be a slug: lowercase letters, digits and dashes, 3–64 characters.`,"promotion-budget":`A promotion budget is full (60 tapes, 1 GiB, 3 000 pinned tracks). Release or delete a tape already committed as a case first.`,"empty-window":`No frame was recorded in that window.`,"shelf-unreadable":`The camera's recorded segments could not be listed, so the window cannot be proven whole.`,"not-post-processing-node":`This node does not post-process frames, so it records no tracking tapes.`,"artifacts-elsewhere":`The artifacts storage location is on another node; tapes are recorded only where it lives.`,"tapes-not-started":`The tape recorder has not started on this node (or failed to).`};function Da(e,t){let n=Ea[e]??`Refused (${e}).`;return t.length>0?`${n} ${t}`:n}function Oa(e){if(e.length===0)return null;let t=new Date(e).getTime();return Number.isFinite(t)?t:null}function ka(e){return e<1024*1024?q.t(`helpers.eventsDebugTapes.sizeKb`,{value:(e/1024).toFixed(0)}):q.t(`helpers.eventsDebugTapes.sizeMb`,{value:(e/1024/1024).toFixed(1)})}function Aa(e){return e===null?`unknown`:ka(e)}function ja(e){return e===null?`unknown`:String(e)}function Ma(e,t){let n=t.trim();return e===404?q.t(`helpers.eventsDebugTapes.exportUnknown`):e===503?n.length>0?n:q.t(`helpers.eventsDebugTapes.tapesUnavailable`):e===500?n.length>0?n:q.t(`helpers.eventsDebugTapes.exportUnreadable`):q.t(`helpers.eventsDebugTapes.downloadFailed`,{status:e})}c();function Na({cameras:t,call:n,onPromoted:r}){let{t:a}=J(),[s,c]=o(``),[l,u]=o(``),[d,f]=o(``),[p,m]=o(``),[h,g]=o(``),[_,v]=o(`auto`),[y,b]=o(!1),[x,S]=o(null),C=async()=>{let e=Number.parseInt(s===``?t[0]?.value??``:s,10),i=Oa(l),a=Oa(d);if(!Number.isFinite(e)||i===null||a===null){S(`Pick a camera and both ends of the window.`);return}b(!0),S(null);try{let t=pa(await n(Xi.promote,{deviceId:e,fromMs:i,toMs:a,scenario:p,...h.trim().length>0?{note:h.trim()}:{},..._===`day`||_===`ir`?{lighting:_}:{}}));t===null?S(ta):t.ok?(S(`Promoted ${t.tapeId}: ${String(t.frames)} frames, ${ka(t.bytes)}, ${String(t.pinnedTracks)} tracks pinned`+(t.state===`incomplete`?` — incomplete (it has gaps) and cannot become a case.`:`.`)),r()):S(Da(t.reason,t.detail))}catch(e){S(na(e))}finally{b(!1)}};return e(`div`,{className:`flex flex-wrap items-end gap-2 rounded-md border border-border px-3 py-2`,children:[i(`div`,{className:`w-40`,children:i(P,{value:s,options:[...t],onChange:e=>c(e.target.value),"aria-label":a(`eventsDebugTapesPromoteForm.camera`,`Camera`)})}),i(Ke,{type:`datetime-local`,"aria-label":a(`eventsDebugTapesPromoteForm.from`,`From`),value:l,onChange:e=>u(e.target.value),className:`w-48`}),i(Ke,{type:`datetime-local`,"aria-label":a(`eventsDebugTapesPromoteForm.to`,`To`),value:d,onChange:e=>f(e.target.value),className:`w-48`}),i(Ke,{"aria-label":a(`eventsDebugTapesPromoteForm.scenario`,`Scenario`),placeholder:`101-door-groups`,value:p,onChange:e=>m(e.target.value),className:`w-44`}),i(Ke,{"aria-label":a(`eventsDebugTapesPromoteForm.note`,`Note`),placeholder:a(`eventsDebugTapesPromoteForm.optionalNote`,`optional note`),value:h,onChange:e=>g(e.target.value),className:`w-52`}),i(`div`,{className:`w-28`,children:i(P,{value:_,"aria-label":a(`eventsDebugTapesPromoteForm.lighting`,`Lighting`),options:[{value:`auto`,label:a(`eventsDebugTapesPromoteForm.lightingAuto`,`Lighting: auto`)},{value:`day`,label:a(`eventsDebugTapes.dayMode`)},{value:`ir`,label:`IR`}],onChange:e=>v(e.target.value)})}),e(K,{onClick:()=>void C(),disabled:y||t.length===0,children:[y?i(V,{className:`h-3.5 w-3.5 animate-spin`}):null,` `,a(`eventsDebugTapes.promoteWindow`)]}),i(`p`,{className:`w-full text-xs text-foreground-subtle`,children:a(`eventsDebugTapesPromoteForm.aPromotedTapeMayBe`,`A promoted tape may be shared as a test case — keep the scenario slug and note free of names or other personal data.`)}),x!==null&&i(`p`,{className:`w-full text-xs text-foreground`,children:x})]})}var Pa=`pipeline-analytics`,Fa=`debug.listTracks`,Ia=`debug.analyze`,La=_(`/addon/pipeline-analytics/debug-export`);function Ra(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function za(e,t){let n=e[t];return typeof n==`string`?n:null}function Ba(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function Va(e,t){let n=e[t];return typeof n==`boolean`?n:null}function Ha(e){return e===`error`||e===`warn`||e===`info`}function Ua(e){if(!Ra(e))return null;let t=za(e,`code`),n=za(e,`detail`),r=e.severity;return t===null||n===null||!Ha(r)?null:{code:t,severity:r,detail:n}}function Wa(e){if(!Ra(e))return null;let t=za(e,`trackId`),n=Ba(e,`deviceId`),r=za(e,`className`),i=Ba(e,`firstSeen`),a=Ba(e,`lastSeen`),o=Ba(e,`durationMs`),s=Va(e,`active`);if(t===null||n===null||r===null||i===null||a===null||o===null||s===null)return null;let c=za(e,`label`),l=za(e,`subLabel`),u=za(e,`previewMissReason`),d=Va(e,`markForTrain`),f=Va(e,`favourited`);return{trackId:t,deviceId:n,className:r,...c===null?{}:{label:c},...l===null?{}:{subLabel:l},firstSeen:i,lastSeen:a,durationMs:o,active:s,timestamp:i,windowMs:o,importance:Ba(e,`importance`)??0,bestEventId:za(e,`bestEventId`)??``,...d===null?{}:{markForTrain:d},...f===null?{}:{favourited:f},debug:!0,...u===null||u.length===0?{}:{previewMissReason:u}}}function Ga(e){let t=Wa(e);if(t===null||!Ra(e))return null;let n=Ba(e,`mediaCount`),r=Ba(e,`eventCount`),i=Ba(e,`positionCount`);if(n===null||r===null||i===null)return null;let a=e.mediaKinds,o=e.findings;if(!Array.isArray(a)||!Array.isArray(o))return null;let s=a.filter(e=>typeof e==`string`),c=[];for(let e of o){let t=Ua(e);t!==null&&c.push(t)}let l=e.thumbnailProvenance;return{...t,mediaCount:n,mediaKinds:s,eventCount:r,positionCount:i,findings:c,...Wr(l)?{thumbnailProvenance:l}:{}}}function Ka(e){if(!Ra(e))return null;let t=Va(e,`truncated`),n=e.tracks;if(t===null||!Array.isArray(n))return null;let r=[];for(let e of n){let t=Wa(e);if(t===null)return null;r.push(t)}return{tracks:r,truncated:t}}function qa(e){if(!Ra(e))return null;let t=e.reports,n=e.vanished;if(!Array.isArray(t)||!Array.isArray(n))return null;let r=[];for(let e of t){let t=Ga(e);if(t===null)return null;r.push(t)}return{reports:r,vanished:n.filter(e=>typeof e==`string`)}}var Ja={MEDIA_EVICTED_OR_NEVER:`no media`,MISSING_KEYFRAME:`no keyframe`,MISSING_FIRSTFRAME:`no first frame`,MISSING_LASTFRAME:`no last frame`,MISSING_THUMBNAIL:`no thumbnail`,MISSING_BEST_CROP:`no crop`,SHORT_TRACK:`very short`,ZERO_EVENTS:`no events`,ZERO_POSITIONS:`no trajectory`,NO_PERIODIC_SNAPSHOTS:`no snapshots`,LASTFRAME_STALE:`stale last frame`,MEDIA_STOPPED_EARLY:`media stopped early`,NO_BEST_EVENT:`no best event`,LOW_BEST_SCORE:`low score`,UNSCORED_LABEL:`unscored label`,BEST_SHOT_STANDIN:`stand-in best shot`,BEST_SHOT_RASTER:`low-res best shot`};function Ya(e){return Ja[e]??e}var Xa={error:0,warn:1,info:2};function Za(e){return e.toSorted((e,t)=>Xa[e.severity]-Xa[t.severity]||e.code.localeCompare(t.code))}function Qa(e){return e.length===0?La:`${La}?deviceIds=${e.join(`,`)}`}function $a(e){if(e<1e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.round(e/1e3);if(t<60)return`${String(t)}s`;let n=Math.floor(t/60);return`${String(n)}m ${String(t%60).padStart(2,`0`)}s`}function eo(e,t){return`${String(e)}:${t}`}function to(e,t){let n=[],r=new Set;for(let i of e){let e=eo(i.deviceId,i.trackId);!t.has(e)||r.has(e)||(r.add(e),n.push({deviceId:i.deviceId,trackId:i.trackId}))}return n}c();function no({tapeId:t,call:n,onClose:r,onChanged:a}){let{t:c}=J(),l=s({queryKey:[`events-debug`,`tapes`,`tracks`,t],queryFn:async()=>fa(await n(Xi.tracks,{tapeId:t}))}),u=l.data??null,d=s({queryKey:[`events-debug`,`tapes`,`marks`,t],enabled:u!==null,queryFn:async()=>u===null?null:ya(await n(Zi.list,{deviceId:u.deviceId,since:u.fromMs-$i,until:u.toMs+$i,limit:5e3}))}),[f,p]=o([]),[m,h]=o(``),[g,_]=o(null),v=e=>p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),y=async e=>{_(null);try{for(let[t,r]of e)await n(t,r);p([]),await d.refetch(),a()}catch(e){_(na(e))}};if(u===null)return l.isLoading?i(`p`,{className:`text-xs`,children:c(`eventsDebugTapesReview.loadingTheTape`,`Loading the tape…`)}):i(W,{message:ta});let b=u.deviceId,x=(e,t)=>y(e.map(e=>[Zi.setRelation,{deviceId:b,...e,relation:t}])),S=e=>{let t=Number.parseFloat(m),n=e===`mixed`&&Number.isFinite(t)?u.fromMs+t*1e3:void 0;return y(f.map(t=>[Zi.setPurity,{deviceId:b,trackId:t,purity:e,...n===void 0?{}:{switchAtMs:Math.round(n)}}]))},C=d.data==null?null:ba(d.data);return e(`div`,{className:`space-y-2 rounded-md border border-primary/40 px-3 py-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-xs font-medium`,children:c(`eventsDebugTapes.reviewLanes`,{id:u.tapeId,count:u.lanes.length})}),i(K,{disabled:f.length<2,onClick:()=>void x(Sa(f),`same-subject`),children:c(`eventsDebugTapesReview.sameSubject`,`Same subject`)}),i(K,{variant:`secondary`,disabled:f.length<2,onClick:()=>void x(Ca(f),`different-subjects`),children:c(`eventsDebugTapesReview.differentSubjects`,`Different subjects`)}),i(Ke,{"aria-label":c(`eventsDebugTapesReview.changedAtSFromTape`,`Changed at (s from tape start)`),placeholder:c(`eventsDebugTapesReview.changedAtS`,`changed at s`),value:m,onChange:e=>h(e.target.value),className:`w-28`}),i(K,{variant:`secondary`,disabled:f.length!==1,onClick:()=>void S(`mixed`),children:c(`eventsDebugTapesReview.mixed`,`Mixed`)}),i(K,{variant:`secondary`,disabled:f.length===0,onClick:()=>void S(`not-a-subject`),children:c(`eventsDebugTapesReview.notASubject`,`Not a subject`)}),i(K,{variant:u.reviewed?`secondary`:`primary`,onClick:()=>void y([[Xi.review,{tapeId:u.tapeId,reviewed:!u.reviewed}]]).then(()=>l.refetch()),children:u.reviewed?c(`eventsDebugTapesReview.markNotReviewed`,`Mark not reviewed`):c(`eventsDebugTapesReview.markReviewed`,`Mark reviewed`)}),i(K,{variant:`ghost`,onClick:r,children:c(`common.close`,`Close`)})]}),g!==null&&i(W,{message:g}),C!==null&&i(W,{variant:`warning`,message:C}),i(`ul`,{className:`space-y-1`,children:u.lanes.toSorted((e,t)=>e.firstT-t.firstT).map(e=>i(ro,{lane:e,marks:d.data===null||d.data===void 0?[]:wa(e.trackId,d.data),selected:f.includes(e.trackId),onToggle:()=>v(e.trackId)},e.trackId))})]})}function ro({lane:t,marks:n,selected:r,onToggle:a}){let{t:o}=J(),{src:s}=bn(t.stillStored?xn(`track`,t.trackId):void 0);return e(`li`,{className:`flex items-center gap-2 text-xs`,children:[i(D,{"aria-label":o(`eventsDebugTapesReview.select`,`select {{trackId}}`,{trackId:t.trackId}),checked:r,onChange:a}),s===null?i(`div`,{className:`h-10 w-10 rounded bg-surface-hover`}):i(`img`,{src:s,alt:t.trackId,className:`h-10 w-10 rounded object-cover`}),i(`span`,{className:`font-mono`,children:t.trackId}),i(`span`,{children:t.cls}),i(`span`,{className:`text-foreground-subtle`,children:o(`eventsDebugTapes.laneFrames`,{range:`${$a(t.firstT)} → ${$a(t.lastT)}`,count:t.boundFrames})}),!t.stillStored&&i(`span`,{className:`text-foreground-subtle`,children:o(`eventsDebugTapesReview.notStoredMarkedThroughThe`,`not stored — marked through the tape`)}),n.map(e=>i(G,{variant:`info`,children:e},e))]})}c();var io=`camstack_admin_token`;function ao(){let e=ue();return(t,n)=>e.trpcClient.addons.custom.mutate({addonId:Pa,action:t,input:n})}async function oo(e,t){let n=localStorage.getItem(io),r={};n!==null&&(r.Authorization=`Bearer ${n}`);let i=await fetch(ea(e),{headers:r});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(Ma(i.status,e))}let a=await i.blob(),o=i.headers.get(`content-disposition`),s=(o===null?null:/filename="?([^";]+)"?/i.exec(o))?.[1]?.trim()??t,c=URL.createObjectURL(a),l=document.createElement(`a`);l.href=c,l.download=s,l.click(),setTimeout(()=>URL.revokeObjectURL(c),6e4)}function so(){let{t:e}=J(),[t,n]=o(!1);return i(Wt,{expanded:t,onExpandedChange:n,header:i(`span`,{className:`text-sm font-medium text-foreground`,children:e(`eventsDebugTapes.trackingTapes`,`Tracking tapes`)}),children:i(co,{})})}function co(){let{t}=J(),r=ao(),a=We({isCamera:!0,projection:`slim`}),c=n(()=>{let e=new Map;for(let t of a.data??[])e.set(t.id,t.name);return n=>e.get(n)??t(`cameraLoad.deviceLabel`,{deviceId:n})},[a.data,t]),l=s({queryKey:[`events-debug`,`tapes`,`status`],queryFn:async()=>ca(await r(Xi.status,{}))}),u=s({queryKey:[`events-debug`,`tapes`,`list`],queryFn:async()=>ua(await r(Xi.list,{}))}),[d,f]=o(null),[p,m]=o(null),g=async e=>{m(null);try{await oo(e.id,`${e.scenario}.tape-bundle.json.gz`)}catch(e){m(na(e))}},_=async e=>{let t=ma(await r(Xi.release,{tapeId:e.id}));if(t===null)throw Error(ta);let n=ga(t);if(n!==null)throw Error(n);await u.refetch()},v=async e=>{let t=ha(await r(Xi.remove,{tapeId:e.id}));if(t===null)throw Error(ta);let n=ga(t);if(n!==null)throw Error(n);await u.refetch()};return e(`div`,{className:`space-y-3`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:i(rn,{i18nKey:`eventsDebugTapes.intro`,components:{b:i(`strong`,{}),code:i(`code`,{})}})}),p!==null&&i(W,{message:p}),l.isLoading&&i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`eventsDebugTapes.loadingCameraStatus`,`Loading camera status…`)}),l.data===null&&i(W,{message:`The server answered in a shape this build does not understand.`}),e(`table`,{className:`w-full text-xs`,children:[i(`thead`,{children:e(`tr`,{className:`text-left text-foreground-subtle`,children:[i(`th`,{children:t(`eventsDebugTapes.camera`,`Camera`)}),i(`th`,{children:t(`eventsDebugTapes.state`,`State`)}),i(`th`,{children:t(`eventsDebugTapes.framesMin`,`Frames/min`)}),i(`th`,{children:t(`eventsDebugTapes.lastHour`,`Last hour`)}),i(`th`,{children:t(`eventsDebugTapes.held`,`Held`)}),i(`th`,{children:t(`eventsDebugTapes.gaps`,`Gaps`)})]})}),i(`tbody`,{children:(l.data??[]).map(n=>e(`tr`,{children:[i(`td`,{children:c(n.deviceId)}),i(`td`,{children:i(G,{variant:n.state===`recording`?`success`:n.state===`off`?`default`:n.state===`unknown`?`warning`:`danger`,children:Ta(n)})}),i(`td`,{children:n.framesPerMin===void 0?`—`:String(Math.round(n.framesPerMin))}),i(`td`,{title:n.shelfError,children:Aa(n.bytesLastHour)}),i(`td`,{title:n.shelfError,children:t(`eventsDebugTapes.segsHeld`,{count:ja(n.segmentsHeld),size:Aa(n.bytesHeld)})}),i(`td`,{children:String(n.gapsSinceArmed)})]},n.deviceId))})]}),i(Na,{cameras:xa(l.data??[]).map(e=>({value:String(e.deviceId),label:e.segmentsUnknown?t(`eventsDebugTapes.segmentsUnknown`,`{{value1}} (segments unknown)`,{value1:c(e.deviceId)}):c(e.deviceId)})),call:r,onPromoted:()=>void u.refetch()}),u.isLoading&&i(`p`,{className:`text-xs text-foreground-subtle`,children:t(`eventsDebugTapes.loadingPromotedTapes`,`Loading promoted tapes…`)}),u.data===null&&i(W,{message:`The server answered in a shape this build does not understand.`}),e(`table`,{className:`w-full text-xs`,children:[i(`thead`,{children:e(`tr`,{className:`text-left text-foreground-subtle`,children:[i(`th`,{children:t(`eventsDebugTapes.scenario`,`Scenario`)}),i(`th`,{children:t(`eventsDebugTapes.camera`,`Camera`)}),i(`th`,{children:t(`eventsDebugTapes.window`,`Window`)}),i(`th`,{children:t(`eventsDebugTapes.state`,`State`)}),i(`th`,{children:t(`eventsDebugTapes.tracks`,`Tracks`)}),i(`th`,{})]})}),i(`tbody`,{children:(u.data??[]).map(n=>e(`tr`,{children:[i(`td`,{children:n.scenario}),i(`td`,{children:c(n.deviceId)}),e(`td`,{children:[new Date(n.fromMs).toLocaleString(),` · `,$a(n.toMs-n.fromMs),` `,`· `,n.lighting]}),e(`td`,{children:[i(G,{variant:n.state===`complete`?`success`:`warning`,children:n.state}),` `,n.reviewed&&i(G,{variant:`info`,children:t(`eventsDebugTapes.reviewed`)}),` `,n.released&&i(G,{children:t(`eventsDebugTapes.released`)})]}),i(`td`,{children:t(`eventsDebugTapes.storedOf`,{stored:String(n.tracksStillStored),total:String(n.tracks.length)})}),e(`td`,{className:`space-x-1 text-right`,children:[i(K,{variant:`secondary`,"aria-label":t(`eventsDebugTapes.review`,`Review {{scenario}}`,{scenario:n.scenario}),onClick:()=>f(n.id),children:t(`eventsDebugTapes.review2`,`Review`)}),i(K,{variant:`ghost`,"aria-label":t(`eventsDebugTapes.download`,`Download {{scenario}}`,{scenario:n.scenario}),onClick:()=>void g(n),children:i(le,{className:`h-3.5 w-3.5`})}),i(vt,{label:t(`eventsDebugTapes.release`,`Release`),icon:h,title:t(`eventsDebugTapes.release2`,`Release {{scenario}}?`,{scenario:n.scenario}),description:t(`eventsDebugTapes.releasingReturnsThisTapeS`,`Releasing returns this tape's pinned tracks to ordinary retention — they can be pruned from then on. The promoted bundle itself is kept until deleted.`),confirmLabel:t(`eventsDebugTapes.release`,`Release`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:n.released,action:()=>_(n)}),i(vt,{label:t(`common.delete`,`Delete`),icon:se,title:t(`eventsDebugTapes.delete`,`Delete {{scenario}}?`,{scenario:n.scenario}),description:t(`eventsDebugTapes.deletingRemovesThePromotedBundle`,`Deleting removes the promoted bundle and its index row for good. Its tracks' pins are released first — this cannot be undone.`),confirmLabel:t(`common.delete`,`Delete`),triggerVariant:`ghost`,confirmVariant:`danger`,action:()=>v(n)})]})]},n.id))})]}),d!==null&&i(no,{tapeId:d,call:r,onClose:()=>f(null),onChanged:()=>void u.refetch()})]})}c();var lo=`all`,uo=`The server answered in a shape this build does not understand.`,fo={error:`danger`,warn:`warning`,info:`info`};function po({findings:e}){let{t}=J();return e.length===0?i(G,{variant:`success`,children:t(`eventsDebug.noAnomalyFound`,`no anomaly found`)}):i(`div`,{className:`flex flex-wrap gap-1`,children:Za(e).map(e=>i(G,{variant:fo[e.severity],title:e.detail,children:Ya(e.code)},e.code))})}function mo({track:t,report:n,analyzing:r}){let{t:a}=J(),o=Jr(n?.previewMissReason??t.previewMissReason);return e(`div`,{className:`space-y-1 border-t border-border pt-1.5`,children:[n===void 0?i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r?a(`eventsDebug.analysing`,`analysing…`):a(`eventsDebug.notAnalysed`,`not analysed`)}):e(u,{children:[i(po,{findings:n.findings}),i(`p`,{className:`text-[10px] text-foreground-subtle`,title:n.mediaKinds.length>0?n.mediaKinds.join(`, `):a(`eventsDebug.noMediaOfAnyKind`,`no media of any kind`),children:a(`eventsDebug.reportCounts`,{media:String(n.mediaCount),events:String(n.eventCount),positions:String(n.positionCount)})})]}),o!==null&&i(`p`,{className:`text-[10px] text-foreground-subtle`,title:o.raw,children:o.sentence})]})}function ho({deviceId:t}={}){let{t:r}=J(),a=ue(),[c,l]=o(lo),u=t===void 0?c:String(t),[d,f]=o(!1),[p,m]=o(null),[h,g]=o(new Set),[_,v]=o(null),[b,x]=o(null),[S,C]=o(null),[T,E]=o([]),D=ni(),O=We({isCamera:!0,projection:`slim`}),A=n(()=>[{value:lo,label:r(`eventsDebug.allCameras`,`All cameras`)},...(O.data??[]).map(e=>({value:String(e.id),label:e.name}))],[O.data,r]),j=n(()=>{let e=new Map;for(let t of O.data??[])e.set(t.id,t.name);return e},[O.data]),M=e=>j.get(e)??r(`eventsDebug.cameraFallback`,{deviceId:e}),N=n(()=>u===lo?[]:[Number.parseInt(u,10)],[u]),F=s({queryKey:[`events-debug`,`list`,N],queryFn:async()=>Ka(await a.trpcClient.addons.custom.mutate({addonId:Pa,action:Fa,input:N.length===0?{}:{deviceIds:N}}))}),I=n(()=>(F.data?.tracks??[]).map(e=>e.trackId),[F.data]),L=s({queryKey:[`events-debug`,`analyze`,I],enabled:I.length>0,queryFn:async()=>qa(await a.trpcClient.addons.custom.mutate({addonId:Pa,action:Ia,input:{trackIds:I}}))}),ee=n(()=>{let e=new Map;for(let t of L.data?.reports??[])e.set(t.trackId,t);return e},[L.data]),R=F.data?.tracks??[],te=F.data===null||L.data===null,ne=()=>{F.refetch(),L.refetch()},ie=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ae=()=>{g(new Set(R.map(e=>eo(e.deviceId,e.trackId))))},oe=()=>g(new Set),se=async(e,t)=>{let n=e===`analyzed`?{debug:!1}:{favourited:!0},r=0,i=[];for(let e of t)try{await D.mutateAsync({deviceId:e.deviceId,trackId:e.trackId,flags:n}),r+=1}catch{i.push(e.trackId)}return{applied:r,refused:i}},ce=e=>{if(!$r||b!==null)return;let t=to(R,h);t.length!==0&&(x(e),C(null),(async()=>{let n=await se(e,t);x(null);let r=new Set(n.refused);g(new Set(t.filter(e=>r.has(e.trackId)).map(e=>eo(e.deviceId,e.trackId)))),e===`analyzed`&&E(t.filter(e=>!r.has(e.trackId))),n.refused.length>0&&C(`${String(n.refused.length)} of ${String(t.length)} were refused by the server and are still selected. Check the hub log.`),F.refetch()})())},de=()=>{let e=T;e.length===0||b!==null||(x(`analyzed`),C(null),(async()=>{for(let t of e)try{await D.mutateAsync({deviceId:t.deviceId,trackId:t.trackId,flags:{debug:!0}})}catch{C(`Some tracks could not be re-marked. Refresh and try again.`)}x(null),E([]),F.refetch()})())},fe=async()=>{f(!0),m(null);try{await Cn(Qa(N),`camstack-debug.zip`)}catch(e){m(e instanceof Error?e.message:`Export failed.`)}finally{f(!1)}},H=b!==null;return e(`section`,{className:`space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t===void 0&&i(`div`,{className:`w-44`,children:i(P,{value:u,options:A,onChange:e=>l(e.target.value)})}),e(K,{variant:`secondary`,onClick:ne,disabled:F.isFetching,children:[F.isFetching?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),r(`common.refresh`,`Refresh`)]}),e(K,{onClick:()=>void fe(),disabled:d||R.length===0,children:[d?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(le,{className:`h-3.5 w-3.5`}),r(`eventsDebug.exportAll`,{count:String(R.length)})]}),R.length>0&&h.size<R.length&&i(K,{variant:`ghost`,onClick:ae,children:r(`eventsDebug.selectAll`,`Select all`)})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(rn,{i18nKey:`eventsDebug.debugMarkNote`,components:{code:i(`code`,{}),strong:i(`strong`,{})}})}),i(so,{}),F.isError&&i(W,{message:r(`eventsDebug.couldNotLoadTheMarked`,`Could not load the marked tracks.`)}),te&&!F.isError&&i(W,{message:uo}),p!==null&&i(W,{message:p}),S!==null&&i(W,{message:S}),F.data?.truncated===!0&&i(W,{message:r(`eventsDebug.aCameraFilledThePer`,`A camera filled the per-camera cap — some marked tracks are not listed. Un-mark a few, or filter to one camera.`)}),(L.data?.vanished.length??0)>0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`eventsDebug.vanished`,{count:String(L.data?.vanished.length)})}),h.size>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:r(`common.selectedCount`,{count:h.size})}),e(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[i(`span`,{title:$r?void 0:`Track flags arrive with the next server update`,children:e(K,{variant:`secondary`,onClick:()=>ce(`keep`),disabled:!$r||H,children:[b===`keep`?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(z,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.keep`,`Keep`)]})}),i(`span`,{title:$r?void 0:`Track flags arrive with the next server update`,children:e(K,{onClick:()=>ce(`analyzed`),disabled:!$r||H,children:[b===`analyzed`?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(re,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.analyzed`,`Analyzed`)]})}),i(K,{variant:`ghost`,onClick:oe,disabled:H,children:i(y,{className:`h-3.5 w-3.5`})})]})]}),T.length>0&&e(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-border bg-surface px-3 py-2`,children:[i(`span`,{className:`text-xs text-foreground`,children:r(`eventsDebug.markedAnalyzed`,{count:String(T.length)})}),e(K,{variant:`ghost`,onClick:de,disabled:H,children:[i(B,{className:`h-3.5 w-3.5`}),` `,r(`eventsDebug.undo`)]}),i(K,{variant:`ghost`,onClick:()=>E([]),disabled:H,children:i(y,{className:`h-3.5 w-3.5`})})]}),F.isLoading?i(zt,{status:`pending`,pendingMessage:`Loading…`,testId:`debug-tracks-grid`}):R.length===0?i(yt,{icon:k,title:r(`eventsDebug.noTrackIsMarkedFor`,`No track is marked for debug`),description:r(`eventsDebug.markOneFromATrack`,`Mark one from a track's actions on the Feed to see it here.`)}):i(zt,{status:`ready`,testId:`debug-tracks-grid`,children:R.map(e=>{let t=ee.get(e.trackId);return i(Si,{row:e,cameraName:M(e.deviceId),nowMs:e.lastSeen,selected:h.has(eo(e.deviceId,e.trackId)),onToggleSelect:ie,onOpenDetail:v,...t?.thumbnailProvenance===void 0?{}:{provenance:t.thumbnailProvenance},footer:i(mo,{track:e,report:t,analyzing:L.isFetching})},eo(e.deviceId,e.trackId))})}),_&&i(bi,{row:_,cameraName:M(_.deviceId),deleteAvailable:pr,onClose:()=>v(null),onDeleted:()=>{v(null),F.refetch()},onFlagsChanged:e=>{e.debug||(v(null),F.refetch())}})]})}c();function go({deviceId:t,debug:n}){let{t:r}=J(),[a,s]=o(!1);return i(Wt,{expanded:a||n,onExpandedChange:s,header:e(`span`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[i(f,{className:`h-3.5 w-3.5`}),r(`archive.review.tools`,`Search, parked objects and debug`)]}),children:e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-review-tools`,children:[i(Vi,{}),i(Ki,{deviceId:t}),i(Yi,{deviceId:t}),n&&i(ho,{deviceId:t})]})})}var _o=``;function vo(e){return e===`any`||e===`face`||e===`plate`}function yo({filters:t,zones:n,onChange:r,unchecked:a=0}){let{t:o}=J();return e(`div`,{className:`contents`,"data-testid":`archive-review-filters`,children:[n.length>0&&e(P,{wrapperClassName:`inline-block w-auto`,"aria-label":o(`archive.review.zone`,`Zone`),value:t.zone??_o,onChange:e=>r({...t,zone:e.target.value===_o?null:e.target.value}),children:[i(`option`,{value:_o,children:o(`archive.review.allZones`,`All zones`)}),n.map(e=>i(`option`,{value:e,children:e},e))]}),e(P,{wrapperClassName:`inline-block w-auto`,"aria-label":o(`archive.review.identity`,`Face or plate`),value:t.identity,onChange:e=>{let n=e.target.value;vo(n)&&r({...t,identity:n})},children:[i(`option`,{value:`any`,children:o(`archive.review.identityAny`,`Any subject`)}),i(`option`,{value:`face`,children:o(`archive.review.identityFace`,`With a face`)}),i(`option`,{value:`plate`,children:o(`archive.review.identityPlate`,`With a plate`)})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(D,{checked:t.debug,onChange:e=>r({...t,debug:e.target.checked})}),o(`archive.camera.debugFilter`,`Debug-marked tracks only`)]}),a>0&&i(`span`,{className:`text-[11px] text-warning`,"data-testid":`archive-review-unchecked`,children:o(`archive.review.unchecked`,`Events not checked by this filter: {{count}}`,{count:a})})]})}c();function bo(){let e=Date.now(),t=new Date(e);return t.setHours(0,0,0,0),{fromMs:t.getTime(),toMs:e}}var xo=[];function So({deviceId:e}){return i(st,{deviceId:e,children:i(qe,{children:i(He,{children:i(ae,{children:i(et,{children:i(Co,{deviceId:e},e)})})})})})}function Co({deviceId:t}){let{t:a}=J(),[s,c]=o(bo),[l,u]=o(Mi),[d,f]=o(null),[p,m]=o(void 0),[h,g]=o(null),[_,v]=o(!1),[y,b]=o(null),[x,S]=o(null),[C,w]=o(`high`),[T,E]=o(null),[D,O]=o(null),k=Pt({deviceId:t}),A=n(()=>Rt(k.data??[]),[k.data]),j=y??Et(A,`recorder`),M=j===null||j===`recorder`,N=Fe(t,M?null:j,s),F=ot({deviceId:t,since:s.fromMs,until:s.toMs,limit:200,projection:`slim`}),I=F.data??xo,L=n(()=>Pi(I),[I]),ee=n(()=>Ni(I),[I]),R=n(()=>Ii(l,ee),[l,ee]),te=Li(l)||l.debug,z=n(()=>d===null?0:Ri(d.rows,l,ee),[d,l,ee]),ne=n(()=>d!==null&&(d.narrowed||te)?zi(d.rows):void 0,[d,te]),B=n(()=>({since:s.fromMs,until:s.toMs}),[s]),re=r(e=>c(e),[]),ie=r(e=>{if(E(null),M){S(null),m(t=>({atMs:e,nonce:(t?.nonce??0)+1}));return}let t=rt(N.clips,e);t===null&&E(e),S(t)},[M,N.clips]),ae=r((e,t)=>{if(b(e),E(null),e===`recorder`){S(null),m(e=>({atMs:t.timeRange.startMs,nonce:(e?.nonce??0)+1}));return}S(t)},[]),oe=k.status===`pending`?i(`span`,{className:`text-[11px] text-foreground-subtle`,role:`status`,children:a(`archive.review.sourcesLoading`,`Loading sources…`)}):k.status===`error`?i(`span`,{className:`text-[11px] text-danger`,role:`alert`,children:a(`archive.review.sourcesFailed`,`Sources could not be read — {{reason}}`,{reason:k.error?.message??a(`archive.review.noReason`,`no reason given`)})}):null,se=F.status===`error`?i(`span`,{className:`text-[11px] text-danger`,role:`alert`,"data-testid":`archive-review-tracks-failed`,children:a(`archive.review.tracksFailed`,`Track facts could not be read — {{reason}}`,{reason:F.error?.message??a(`archive.review.noReason`,`no reason given`)})}):null,ce=oe??(A.length>1?i(P,{wrapperClassName:`inline-block w-auto`,"aria-label":a(`archive.review.source`,`Source`),value:j??``,onChange:e=>{b(e.target.value),S(null),E(null)},children:A.map(e=>i(`option`,{value:e.value,children:e.label},e.value))}):null);return e(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,calc(40vh*16/9))_minmax(20rem,1fr)]`,children:[i(`div`,{className:`order-1 flex min-w-0 flex-col gap-2 lg:order-none lg:col-start-1 lg:row-start-1`,children:i(`div`,{className:`mx-auto aspect-video w-full max-w-[calc(40vh*16/9)] overflow-hidden rounded-lg border border-border bg-black`,"data-testid":`archive-review-player`,children:i(wn,{deviceId:t})})}),e(`div`,{className:`order-3 flex min-w-0 flex-col gap-2 lg:order-none lg:col-start-2 lg:row-start-1 lg:max-h-[40vh] lg:overflow-y-auto`,"data-testid":`archive-review-events`,children:[T!==null&&i(W,{variant:`warning`,message:a(`archive.review.noClipAt`,`This source holds no clip at {{time}}. Pick another source or another moment.`,{time:new Date(T).toLocaleTimeString()})}),x!==null&&j!==null&&i(Nt,{deviceId:t,clip:x,profile:C,onProfileChange:w}),i(ji,{deviceId:t,window:B,rowFilter:R,onListChange:f,onSeek:ie,layout:`rows`,toolbarTarget:D})]}),i(`div`,{className:`order-2 flex min-w-0 flex-col gap-2 lg:order-none lg:col-span-2 lg:row-start-2`,children:i(ke,{deviceId:t,seekTo:p,onExportRange:(e,t)=>{v(!1),g({fromMs:e,toMs:t})},onViewChange:re,densityPoints:ne,toolbar:e(`div`,{className:`contents`,"data-testid":`archive-review-bar`,children:[ce,_&&e(`span`,{className:`text-[11px] text-success`,role:`status`,children:[a(`archive.review.exportQueued`,`Export queued.`),` `,i(tn,{to:Xt(t),className:`font-medium underline`,children:a(`archive.review.openExports`,`Open Library → Exports`)})]}),i(`span`,{ref:O,className:`contents`}),i(yo,{filters:l,zones:L,onChange:u,unchecked:z}),se]}),lanes:i(gt,{deviceId:t,options:A,view:s,selectedProvider:j,onPickClip:ae})})}),i(`div`,{className:`order-4 min-w-0 lg:order-none lg:col-span-2 lg:row-start-3`,children:i(go,{deviceId:t,debug:l.debug})}),h!==null&&i(vn,{onClose:()=>g(null),onCreated:()=>{g(null),v(!0)},initialDeviceId:t,initialRange:h})]})}function wo({deviceId:e}){return i(st,{deviceId:e,children:i(Qt,{deviceId:e,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},e)}function To(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Eo(e,t){let n=To(e);return n.length===0?q.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Do(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:Eo(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>To(e).includes(n));return i===void 0?null:{label:Eo(i,t),exact:!1}}c();var Oo=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],ko=`—`;function Ao({data:t,row:a}){let{t:s}=J(),c=M(),u=l(),[d,f]=o(`retention`),p=Xe({}).data,m=r(()=>{u.invalidateQueries({queryKey:[[`recording`]]}),u.invalidateQueries({queryKey:[[`recordingArchive`]]}),u.invalidateQueries({queryKey:[[`pipelineAnalytics`]]})},[u]),h=Le({onSuccess:m}),g=ht({onSuccess:m}),_=mt({onSuccess:m}),v=n(()=>{let e=new Map((p??[]).map(e=>[e.id,e.displayName])),n=(p??[]).filter(e=>e.type===`recordings`),r=(n.find(e=>me(e)===`active`)??n[0])?.id??null;return Do(t.usage?.locations??[],e,r)},[p,t.usage?.locations]),y=r(async(e,t,n)=>c({title:e,message:t,confirmLabel:n,variant:`danger`}),[c]),b=async()=>{await y(s(`archive.space.pruneTitle`,`Apply retention to {{name}}?`,{name:a.name}),s(`archive.space.pruneMessage`,`Footage beyond the retention policy is permanently deleted.`),s(`archive.space.pruneNow`,`Prune now`))&&h.mutate({deviceId:a.deviceId,reason:d})},x=async()=>{await y(s(`archive.space.deleteFootageTitle`,`Delete all footage for {{name}}?`,{name:a.name}),s(`archive.space.deleteFootageMessage`,`Permanently deletes {{size}} of recorded footage. This cannot be undone.`,{size:a.footageBytes===null?ko:Y(a.footageBytes)}),s(`archive.space.deleteFootage`,`Delete footage`))&&g.mutate({deviceId:a.deviceId})},S=async()=>{await y(s(`archive.space.deleteEventsTitle`,`Delete all events for {{name}}?`,{name:a.name}),s(`archive.space.deleteEventsMessage`,`Permanently deletes the events and their media. This cannot be undone.`),s(`archive.space.deleteEvents`,`Delete events`))&&_.mutate({deviceId:a.deviceId})};return e(`div`,{className:`flex flex-col gap-4`,"data-testid":`archive-space`,children:[e(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[i(C,{label:s(`archive.space.footage`,`Footage`),icon:i(oe,{className:`h-3.5 w-3.5`}),footer:v===null?s(`archive.space.diskUnknown`,`Disk not reported`):v.exact?v.label:s(`archive.space.diskDefault`,`{{label}} (default)`,{label:v.label}),children:a.footageBytes===null?ko:Y(a.footageBytes)}),i(C,{label:s(`archive.space.events`,`Event storage`),footer:a.eventRows===null?void 0:s(`archive.space.eventRows`,`{{count}} events`,{count:a.eventRows}),children:a.eventBytes===null?ko:Y(a.eventBytes)}),i(C,{label:s(`archive.space.oldest`,`Oldest footage`),children:a.oldestMs===null?ko:new Date(a.oldestMs).toLocaleDateString()})]}),e(`div`,{className:`flex flex-col gap-2 rounded-lg border border-danger/40 p-3`,children:[i(`h3`,{className:`text-sm font-semibold text-danger`,children:s(`archive.space.danger`,`Danger zone`)}),e(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[i(`span`,{className:`text-foreground-subtle`,children:s(`recordings.storageSection.pruneReason`,`Prune reason`)}),i(P,{wrapperClassName:`inline-block w-auto`,value:d,"aria-label":s(`recordings.storageSection.pruneReason`,`Prune reason`),onChange:e=>{let t=Oo.find(t=>t.value===e.target.value);t&&f(t.value)},children:Oo.map(e=>i(`option`,{value:e.value,children:s(e.labelKey)},e.value))})]}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(K,{variant:`secondary`,onClick:()=>void b(),disabled:h.isPending,children:[i(U,{className:`h-3.5 w-3.5`}),s(`archive.space.applyRetention`,`Apply retention now`)]}),e(K,{variant:`secondary`,onClick:()=>void x(),disabled:g.isPending,children:[i(se,{className:`h-3.5 w-3.5`}),s(`archive.space.deleteFootage`,`Delete footage`)]}),e(K,{variant:`secondary`,onClick:()=>void S(),disabled:_.isPending,children:[i(se,{className:`h-3.5 w-3.5`}),s(`archive.space.deleteEvents`,`Delete events`)]})]})]})]})}c();var jo=[`review`,`health`,`settings`];function Mo(e){return jo.some(t=>t===e)}function No({data:t}){let{t:n}=J(),[a,o]=$t(),s=a.get(Yt),c=a.get(en),l=Mo(c)?c:`review`,u=s===null?t.cameras[0]?.id??null:Number(s),d=r((e,t)=>{o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0})},[o]);if(u===null||!Number.isFinite(u))return i(yt,{icon:N,title:n(`archive.camera.none`,`No cameras yet`),description:n(`archive.camera.noneHint`,`Cameras appear here once one is added.`)});let f=t.rows.find(e=>e.deviceId===u),p=Yn(rr(t,u),Zn(t.findings,u));return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`archive-camera-section`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(P,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>d(Yt,e.target.value),"aria-label":n(`archive.camera.picker`,`Camera`),children:t.cameras.map(e=>i(`option`,{value:e.id,children:e.name},e.id))}),p.map(t=>e(G,{variant:nr[t.state],children:[n(`archive.function.${t.fn}`,t.fn),` · `,n(`archive.functionState.${t.state}`,t.state)]},t.fn))]}),!t.isLoading&&f===void 0?i(yt,{icon:N,title:n(`archive.camera.unknown`,`Camera not found`),description:n(`archive.camera.unknownHint`,`This camera is not in the Archive. Pick one from the overview.`)}):e(Je,{appearance:`pills`,value:l,onValueChange:e=>d(en,e),className:`flex flex-col gap-3`,children:[e(Ft,{"aria-label":n(`archive.camera.sections`,`Camera sections`),children:[i(Ze,{value:`review`,children:n(`archive.camera.review`,`Review`)}),i(Ze,{value:`health`,children:n(`archive.camera.healthSpace`,`Health & space`)}),i(Ze,{value:`settings`,children:n(`archive.camera.settings`,`Settings`)})]}),i(Ot,{value:`review`,children:i(So,{deviceId:u})}),i(Ot,{value:`health`,children:e(`div`,{className:`flex flex-col gap-6`,children:[i(ir,{data:t,deviceId:u}),i(Vn,{data:t,deviceId:u}),f!==void 0&&i(Ao,{data:t,row:f})]})}),i(Ot,{value:`settings`,children:i(wo,{deviceId:u})})]})]})}c();var Po={recording:`success`,off:`default`,degraded:`warning`,unknown:`default`},Fo=`—`;function Io({rows:t,isLoading:r}){let{t:a}=J(),o=nn(),s=n(()=>[{key:`camera`,header:a(`archive.table.camera`,`Camera`),sortValue:e=>e.name,render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.name})},{key:`mode`,header:a(`archive.table.mode`,`Recording`),sortValue:e=>e.mode??``,render:e=>i(`span`,{className:`text-foreground-subtle`,children:e.mode===null?Fo:a(`archive.mode.${e.mode}`,e.mode)})},{key:`status`,header:a(`archive.table.status`,`Status`),sortValue:e=>e.state,render:t=>e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(G,{variant:Po[t.state],children:a(`archive.state.${t.state}`,t.state)}),t.warnings>0&&i(G,{variant:`warning`,children:a(`archive.table.warnings`,`{{count}} warning`,{count:t.warnings})})]})},{key:`footage`,header:a(`archive.table.footage`,`Footage`),align:`right`,nowrap:!0,sortValue:e=>e.footageBytes,render:e=>i(`span`,{className:`tabular-nums`,children:e.footageBytes===null?Fo:Y(e.footageBytes)})},{key:`events`,header:a(`archive.table.events`,`Events`),align:`right`,nowrap:!0,sortValue:e=>e.eventRows,render:e=>i(`span`,{className:`tabular-nums`,children:e.eventRows===null||e.eventBytes===null?Fo:`${e.eventRows.toLocaleString()} · ${Y(e.eventBytes)}`})},{key:`oldest`,header:a(`archive.table.oldest`,`Oldest footage`),align:`right`,nowrap:!0,sortValue:e=>e.oldestMs,render:e=>i(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.oldestMs===null?Fo:new Date(e.oldestMs).toLocaleDateString()})}],[a]);return!r&&t.length===0?i(yt,{icon:N,title:a(`archive.table.noCameras`,`No cameras`),description:a(`archive.table.addACamera`,`Add a camera first.`)}):i(Kt,{columns:s,rows:t,rowKey:e=>e.deviceId,onRowClick:e=>o(Zt(e.deviceId)),minWidthPx:720,maxBodyHeight:xe,defaultSort:{columnKey:`camera`,dir:`asc`}})}var Lo=1440*60*1e3;function Ro(e){if(e.footageBytes===null||e.oldestMs===null)return null;let t=e.nowMs-e.oldestMs;return t<Lo?null:e.footageBytes/(t/Lo)}function zo(e,t){return e===null||t===null||t<=0?null:e/t}function Bo(e){let t=null;for(let n of e)n.oldestMs!==null&&(t===null||n.oldestMs<t)&&(t=n.oldestMs);return t}c();var Vo=`—`;function Ho({data:t}){let{t:r}=J(),{usage:a,footprint:o,rows:s,totals:c}=t,l=a!==null&&a.devicesRead!==`unavailable`,u=n(()=>Ro({footageBytes:l?a.totalUsedBytes:null,oldestMs:Bo(s),nowMs:Date.now()}),[l,a,s]),f=zo(n(()=>{let e=jn(a?.locations??[]);return e===null||e.knownVolumes===0?null:e.freeBytes},[a?.locations]),u);return e(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-5`,"data-testid":`archive-key-numbers`,children:[i(C,{label:r(`archive.keyNumbers.footage`,`Footage`),icon:i(oe,{className:`h-3.5 w-3.5`}),footer:l?void 0:r(`archive.keyNumbers.footageUnread`,`The recorder did not answer`),children:l?Y(a.totalUsedBytes):Vo}),i(C,{label:r(`archive.keyNumbers.eventStorage`,`Event storage`),icon:i(L,{className:`h-3.5 w-3.5`}),footer:o===null?r(`archive.keyNumbers.eventsUnread`,`The event store did not answer`):r(`archive.keyNumbers.eventRows`,`{{count}} events`,{count:o.totalRows}),children:o===null?Vo:Y(o.totalBytes)}),i(C,{label:r(`archive.keyNumbers.growth`,`Growth per day`),icon:i(d,{className:`h-3.5 w-3.5`}),footer:u===null?r(`archive.keyNumbers.growthUnknown`,`Needs a day of footage`):f===null?r(`archive.keyNumbers.daysUnknown`,`Free space unknown`):r(`archive.keyNumbers.daysLeft`,`{{days}} days of space left`,{days:Math.floor(f)}),children:u===null?Vo:Y(u)}),i(C,{label:r(`archive.keyNumbers.cameras`,`Cameras`),icon:i(N,{className:`h-3.5 w-3.5`}),footer:r(`archive.keyNumbers.cameraStates`,`{{degraded}} degraded · {{off}} off`,{degraded:c.degraded,off:c.off}),children:r(`archive.keyNumbers.recordingOf`,`{{recording}} of {{total}} recording`,{recording:c.recording,total:s.length})}),i(C,{label:r(`archive.keyNumbers.warnings`,`Open warnings`),icon:i(O,{className:`h-3.5 w-3.5`}),footer:t.findings===null?r(`archive.keyNumbers.digestPending`,`No health digest yet`):void 0,children:t.findings===null?Vo:String(c.warnings)})]})}c();var Uo={active:`success`,readonly:`default`,drain:`warning`,disabled:`danger`};function Wo(){let{t}=J(),n=On(),[r,a]=o(null);return n.locations.length===0?i(yt,{icon:oe,title:t(`archive.storage.none`,`No storage locations`),description:t(`archive.storage.noneHint`,`Add a location to start storing footage and events.`)}):e(u,{children:[i(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3`,"data-testid":`archive-storage-cards`,children:n.locations.map(r=>{let o=En(r);return e(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`div`,{className:`truncate text-sm font-medium text-foreground`,children:r.displayName}),e(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r.type,r.nodeId===void 0?``:` · ${r.nodeId}`]})]}),i(G,{variant:Uo[o],children:Dn(o).label})]}),i(An,{location:r,ownedBytes:n.ownedBytesById.get(r.id)??null}),i(kn,{drain:n.drainOf(r)}),e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`span`,{className:`text-[11px] text-foreground-subtle`,children:o===`active`?t(`archive.storage.writing`,`Taking new writes`):t(`archive.storage.notWriting`,`Not taking new writes`)}),i(K,{variant:`ghost`,onClick:()=>a(r),children:t(`archive.storage.manage`,`Manage`)})]})]},r.id)})}),r!==null&&i(Re,{open:!0,onOpenChange:e=>!e&&a(null),children:e(De,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(je,{children:i(Ue,{children:r.displayName})}),i(Ve,{children:i(Mn,{kinds:[r.type]})})]})})]})}c();var Go=1440*60*1e3,Ko=[1,7,30,90],qo=30;function Jo(){let{t}=J(),n=M(),a=l(),[s,c]=o(qo),u=jt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]})}}),d=r(async()=>{await n({title:t(`recordings.eventsManagementSection.pruneTitle`,{count:s}),message:t(`recordings.eventsManagementSection.permanentlyDeletesEveryEventMotion`,`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`),confirmLabel:t(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&u.mutate({olderThanMs:Date.now()-s*Go,reason:`retention`})},[n,u,s,t]);return e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`prune-events-by-age`,children:[i(`span`,{className:`text-foreground-subtle`,children:t(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),i(P,{wrapperClassName:`inline-block w-auto`,value:s,onChange:e=>c(Number(e.target.value)),"aria-label":t(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`),children:Ko.map(e=>i(`option`,{value:e,children:t(`recordings.eventsManagementSection.ageDays`,{count:e})},e))}),e(K,{variant:`secondary`,onClick:()=>void d(),disabled:u.isPending,children:[u.isPending?i(V,{className:`h-3 w-3 animate-spin`}):i(U,{className:`h-3 w-3`}),t(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]})}var Yo=`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`;c();var Xo=`storage-migration`,Zo=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function Qo(e){return[`${e.orphansReclaimed} orphan rows (${Y(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${Y(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${Y(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function $o(){let{t:e}=J(),t=ze(Xo);return t===`pending`?null:t===`unknown`?i(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:e(`recordings.cleanupSection.couldNotCheckWhetherStorage`,`Could not check whether storage cleanup is installed on this hub.`)}):t===`present`?i(es,{}):null}function es(){let{t}=J(),n=M(),[r,a]=o(!1),[s,c]=o(null),l=it({},{refetchInterval:2e3}),u=l.data??null,d=u!==null&&Zo.has(u.phase),f=tt(),p=Bt(),m=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:r?t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd2`,`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`),confirmLabel:t(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){c(null);try{await f.mutateAsync({includeDebugMedia:r}),await l.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},h=async()=>{if(u&&await n({title:t(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:t(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:t(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await p.mutateAsync({jobId:u.jobId}),await l.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),i(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.cleanupSection.onePassOverLeftoverAnalytics`,`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`)}),e(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[i(D,{checked:r,disabled:d,onChange:e=>{a(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),i(`span`,{children:t(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),e(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[e(K,{variant:`unstyled`,type:`button`,disabled:d||f.isPending,onClick:()=>{m()},className:Yo,children:[(d||f.isPending)&&i(V,{className:`h-3 w-3 animate-spin`}),i(se,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),d&&i(K,{variant:`unstyled`,type:`button`,onClick:()=>{h()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:t(`common.cancel`,`Cancel`)})]}),s&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),u&&e(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[e(`p`,{className:`text-xs text-foreground`,children:[t(`recordings.cleanupSection.phase`,`Phase:`),` `,i(`span`,{className:`font-medium`,children:u.phase}),d&&i(V,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),u.detail&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:u.detail}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:Qo(u)}),u.error&&i(`p`,{className:`text-[11px] text-danger`,children:u.error})]})]})}c();var ts=2e3;function ns(){let{t}=J(),n=M(),r=l(),o=Oe(),s=Be(void 0,{refetchInterval:e=>e.state.data?.state===`running`?ts:!1}),c=s.data,u=c?.state===`running`,d=u||o.isPending;a(()=>{c?.state!==`done`||c.finishedAtMs===null||(r.invalidateQueries({queryKey:[[`recording`]]}),r.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[c?.state,c?.finishedAtMs,r]);let f=async()=>{await n({title:t(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:t(`recordings.diskReconcileSection.makesTheDatabaseMatchThe`,`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`),confirmLabel:t(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await o.mutateAsync(),await s.refetch())},p=u?c.total>0?`Reconciling ${String(c.completed)}/${String(c.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),i(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),e(`div`,{className:`mt-3 flex flex-col gap-2`,children:[e(K,{variant:`unstyled`,type:`button`,onClick:()=>void f(),disabled:d,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[d?i(V,{className:`h-3.5 w-3.5 animate-spin`}):i(oe,{className:`h-3.5 w-3.5`}),p]}),c?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(c.completed),tracks:String(c.tracks),events:String(c.events),media:String(c.mediaDropped)}),c.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(c.failed.length),value2:c.failed.join(`, `)}):``,`.`]}):null,c?.state===`error`&&c.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,c.error]}):null]})]})}var rs=1e3,is=60*rs,as=60*is;function os(e){return e.toLocaleString(`en-US`)}function ss(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=as){let t=Math.floor(e/as),n=Math.round(e%as/is);return`${t.toString()}h ${n.toString()}m`}if(e>=is){let t=Math.floor(e/is),n=Math.round(e%is/rs);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/rs)).toString()}s`}function cs(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${os(e.filesMoved)} files`:`${os(e.filesMoved)} / ${os(e.filesTotal)} files`,r=e.filesTotal===null||e.filesTotal===0?null:Math.min(1,e.filesMoved/e.filesTotal),i=t>0&&e.filesMoved>0,a=i?`${Y(e.bytesMoved/t*rs)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${ss(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${Y(e.bytesMoved)} moved`,rate:a,eta:s}}function ls(e){let t=cs(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}c();var us=`storage-migration`,ds=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],fs=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function ps(){let{t}=J(),n=ze(us);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[i(V,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?i(yt,{icon:O,title:t(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryDidNot`,`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`)}):n===`absent`?i(yt,{icon:b,title:t(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryAnsweredNo`,`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`)}):i(ms,{})}function ms(){let{t}=J(),r=M(),{data:a}=Xe({}),[s,c]=o({}),[l,u]=o({}),[d,f]=o(null),[p,m]=o(null),h=n(()=>{let e=new Map;for(let t of a??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[a]),g=n(()=>{let e=new Map;for(let t of a??[]){if(!fe(t))continue;let n=e.get(t.type);n?n.push(t.id):e.set(t.type,[t.id])}let t=new Map;for(let[n,r]of e)r.length===1&&t.set(n,r[0]);return t},[a]),_=Gt({},{refetchInterval:2e3}),v=_.data??null,x=v!==null&&fs.has(v.phase),S=n(()=>{let e={};for(let t of ds){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),C=n(()=>{let e={};for(let t of ds){if(!s[t.id])continue;let n=l[t.id]??g.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,l,g]),w=n(()=>({destinations:S??{},...C?{sources:C}:{}}),[S,C]),T=ct(w,{enabled:!1,retry:!1}),E=Ht(),D=bt(),O=async()=>{if(!S)return;m(null);let e=await T.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},k=async()=>{if(S&&await r({title:t(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:t(`migration.storageMigrationSection.copiesTheSelectedClassesFrom`,`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`),confirmLabel:t(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await E.mutateAsync(w),f(null),await _.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},A=async()=>{if(v&&await r({title:t(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:t(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:t(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await D.mutateAsync({jobId:v.jobId}),await _.refetch()}catch{}};return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[i(b,{className:`h-3.5 w-3.5`}),t(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),i(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`migration.storageMigrationSection.moveRecordingsLowResRecordings`,`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`)}),i(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:ds.map(n=>{let r=h.get(n.locationType)??[],a=g.get(n.locationType)??``;return e(`div`,{className:`space-y-2`,children:[i(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t(n.labelKey)}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`migration-from-${n.id}`,className:`text-[10px] text-foreground-subtle`,children:t(`recordings.storageMigrationSection.classFrom`,{label:t(n.labelKey)})}),i(P,{id:`migration-from-${n.id}`,value:l[n.id]??a,onChange:e=>{let t=e.target.value;u(e=>({...e,[n.id]:t}))},disabled:x,className:`w-full`,children:r.map(n=>e(`option`,{value:n.id,children:[n.displayName,fe(n)?``:` (${t(`recordings.storageMigrationSection.readOnly`)})`]},n.id))})]}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`migration-dest-${n.id}`,className:`text-[10px] text-foreground-subtle`,children:t(`recordings.storageMigrationSection.classTo`,{label:t(n.labelKey)})}),e(P,{id:`migration-dest-${n.id}`,value:s[n.id]??``,onChange:e=>{let t=e.target.value;c(e=>({...e,[n.id]:t}))},disabled:x,className:`w-full`,children:[i(`option`,{value:``,children:t(`migration.storageMigrationSection.skip`,`— skip —`)}),r.map(e=>i(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},n.id)})}),p&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(K,{variant:`unstyled`,type:`button`,onClick:()=>{O()},disabled:!S||T.isFetching||x,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[T.isFetching&&i(V,{className:`h-3 w-3 animate-spin`}),t(`migration.storageMigrationSection.plan`,`Plan`)]}),e(K,{variant:`unstyled`,type:`button`,onClick:()=>{k()},disabled:!S||E.isPending||x,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[E.isPending&&i(V,{className:`h-3 w-3 animate-spin`}),t(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&i(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?i(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:t(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.moves.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]},`${t.storageClass}-${t.toLocationId}`))}),v&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[i(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),x&&e(K,{variant:`unstyled`,type:`button`,onClick:()=>{A()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[i(y,{className:`h-3 w-3`}),t(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[t(`migration.storageMigrationSection.phase`,`Phase:`),` `,i(`span`,{className:`font-medium`,children:v.phase}),x&&i(V,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),v.error&&i(`p`,{className:`mt-1 text-[11px] text-danger`,children:v.error}),v.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[t(`migration.storageMigrationSection.paused`,`Paused:`),` `,v.pausedParticipants.join(`, `)]}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:v.moves.map(e=>i(hs,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),i(gs,{})]}),i(_s,{running:x}),i(ys,{})]})}function hs({move:t}){let{t:n}=J(),r=t.progress===null?null:cs(t.progress);return e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`flex items-center justify-between`,children:[e(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]}),e(`span`,{className:`text-foreground-subtle`,children:[t.state??n(`common.pending`),t.error?` (${t.error})`:``]})]}),t.progress!==null&&e(`div`,{className:`mt-1 space-y-1`,children:[r!==null&&r.fraction!==null&&i(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:i(`div`,{className:`h-full bg-primary`,style:{width:`${(r.fraction*100).toFixed(1)}%`}})}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:ls(t.progress)})]})]})}function gs(){let{t}=J(),{data:n}=St({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[i(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[i(`span`,{className:`font-medium text-foreground`,children:t.phase}),` · `,Object.entries(t.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(t.startedAt).toLocaleString()]},t.jobId))})]})}function _s({running:t}){let{t:n}=J(),r=M(),a=Ge({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=At(),[c,l]=o(null),u=a.data??[];if(u.length===0)return null;let d=async e=>{if(await r({title:n(`migration.storageMigrationSection.drainRemaining`,`Drain remaining {{storageClass}}?`,{storageClass:e.storageClass}),message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await s.mutateAsync({classes:[e.storageClass]}),await a.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(a.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),i(K,{variant:`unstyled`,type:`button`,onClick:()=>{a.refetch()},disabled:a.isFetching,className:`rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:a.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),i(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.aMigrationRepointsFirstAnd`,`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`)}),i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.thisCountIsTakenOn`,`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`)}),c&&i(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(r=>e(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[e(`span`,{className:`text-foreground`,children:[r.storageClass,`: `,r.fromLocationId,` → `,r.toLocationId,i(`span`,{className:`ml-2 text-foreground-subtle`,children:vs(r)})]}),i(K,{variant:`unstyled`,type:`button`,onClick:()=>{d(r)},disabled:t||s.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${r.storageClass}-${r.fromLocationId}`))})]})}function vs(e){if(e.items===null)return q.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?q.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):q.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:Y(e.bytes)})}function ys(){let{t}=J(),{data:n}=ut({},{refetchInterval:2e3}),r=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return r.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),i(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:r.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`text-foreground`,children:[t.lane,`: `,t.job.fromLocationId,` → `,t.job.toLocationId]}),i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:ls({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}c();function bs({openOnMount:t}){let{t:n}=J(),[r,s]=o(t);return a(()=>{t&&s(!0)},[t]),i(Wt,{expanded:r,onExpandedChange:s,header:e(`span`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[i(p,{className:`h-3.5 w-3.5`}),n(`archive.tools.title`,`Tools`),i(`span`,{className:`text-[11px] font-normal text-foreground-subtle`,children:n(`archive.tools.subtitle`,`Storage migration, prune events, cleanup, reconcile from disk`)})]}),children:e(`div`,{className:`flex flex-col gap-6`,"data-testid":`archive-tools`,children:[e(`section`,{className:`flex flex-col gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`archive.tools.migration`,`Move storage`)}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`archive.tools.migrationHint`,`Copy footage, low-res footage or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),i(ps,{})]}),e(`section`,{className:`flex flex-col gap-2`,children:[i(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`archive.tools.pruneEvents`,`Prune old events`)}),i(Jo,{})]}),i($o,{}),i(ns,{})]})})}c();function xs({data:t}){let{t:n}=J(),{hash:r}=on();return a(()=>{r.length>1&&document.getElementById(r.slice(1))?.scrollIntoView({block:`start`})},[r]),e(`div`,{className:`flex flex-col gap-4`,children:[i(Ho,{data:t}),i(Ae,{headingId:`archive-storage`,title:n(`archive.section.storage`,`Storage`),icon:oe,children:i(`div`,{className:`p-3`,children:i(Wo,{})})}),i(Ae,{headingId:`archive-cameras`,title:n(`archive.section.cameras`,`Cameras`),icon:N,children:i(Io,{rows:t.rows,isLoading:t.isLoading})}),i(`div`,{id:`activity`,children:i(Ae,{headingId:`archive-activity`,title:n(`archive.section.activity`,`Activity & health`),icon:x,children:i(`div`,{className:`p-3`,children:i(Vn,{data:t})})})}),i(`div`,{id:`tools`,children:i(bs,{openOnMount:r===`#tools`})})]})}c();function Ss(){let e=We({isCamera:!0,projection:`slim`}),t=Pe({},{refetchOnWindowFocus:!1}),r=kt({},{refetchOnWindowFocus:!1}),i=_t({},{refetchOnWindowFocus:!1}),a=Ee({history:1},{refetchOnWindowFocus:!1}),o=n(()=>(e.data??[]).map(e=>({id:e.id,name:e.name})).toSorted((e,t)=>e.name.localeCompare(t.name)),[e.data]),s=t.data??null,c=s!==null&&s.devicesRead!==`unavailable`,l=r.data??null,u=i.data??null,d=a.data?.latest??null,f=d===null?null:d.findings,p=n(()=>er({cameras:o,footage:c?s.devices:null,events:l===null?null:l.devices,statuses:u,findings:f}),[o,c,s,l,u,f]);return{cameras:o,rows:p,totals:n(()=>tr(p),[p]),usage:s,footprint:l,statuses:u,findings:f,digestAtMs:d===null?null:d.generatedAt,isLoading:e.isLoading||t.isLoading||r.isLoading}}function Cs(){let{t:e}=J(),t=Ss();return i(sn,{icon:_e,title:e(`nav.archive`,`Archive`),subtitle:e(`archive.subtitle`,`Recorded footage and captured events — what they occupy, where they are written, and how each camera is doing.`),paramName:an,defaultSection:`overview`,sectionsLabel:e(`archive.sections`,`Archive sections`),sections:[{id:`overview`,label:e(`archive.section.overview`,`Overview`),content:i(xs,{data:t})},{id:`cameras`,label:e(`archive.section.cameras`,`Cameras`),ownedParams:[Yt,en],content:i(No,{data:t})}]})}export{Cs as ArchivePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as u,Bn as d,D as f,Ga as p,Nn as m,Qn as h,Rn as g,Tt as _,Vn as v,Wi as y,Xi as b,Xn as x,Yn as S,Zt as C,_r as w,aa as T,ba as E,ci as D,ct as O,ft as k,ir as A,ji as j,qn as M,sa as N,tn as ee,ur as P,yi as te,yt as F,z as I,zr as L}from"./player-overlays-BKicBNcF.js";import{bc as ne,vc as re,wc as ie,yc as ae}from"./client-Dn4ym7AZ.js";import{t as oe}from"./chevron-down-CBb-F8DT.js";import{t as se}from"./hard-drive-download-C6N6tovA.js";import{t as ce}from"./memory-stick-BQrJMbEW.js";import{t as le}from"./unlink-D3-IGpS8.js";import{$d as ue,$l as de,Br as fe,Da as R,En as pe,Ep as me,Gi as he,Gl as ge,Hu as _e,Ir as ve,Ji as ye,Ki as be,Kl as xe,Kr as Se,Nu as Ce,Ql as we,Rr as z,Ui as Te,Up as Ee,Wi as De,Wp as B,Y as Oe,Yi as ke,Ys as Ae,Zu as je,_p as V,af as Me,ca as Ne,ct as Pe,di as Fe,ef as Ie,eu as Le,fi as Re,if as ze,ji as Be,ka as Ve,la as He,li as Ue,lp as H,mr as We,nf as Ge,pr as Ke,qi as qe,qp as U,rd as Je,rf as Ye,tf as Xe,tu as Ze,ui as Qe,ut as W,wf as $e,zr as G}from"./src-CU6u_Uvz.js";import{t as et}from"./i18n-CsnSJSM7.js";import{t as K}from"./useTranslation-BJr-n0es.js";import{Si as tt,d as nt}from"./index-FA3cRm59.js";import{t as q}from"./format-size-DIxKXxtj.js";import{t as rt}from"./NodeAddonsSettingsPanel-Dxp-6Ksw.js";import{n as it}from"./format-D2Wcm0QP.js";import{t as at}from"./AdminPage-C0rgqBg5.js";import{_ as ot,f as st,h as ct,p as lt}from"./board-model-CV7df4sG.js";import{n as ut,r as dt,t as ft}from"./useNodeUrlSelection-CmeaBXTi.js";s();var pt={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},mt=new Set([`paired`,`rejected`,`failed`,`expired`]);function J(e){return mt.has(e)}function ht(e){return e.replace(/\D/g,``).slice(0,6)}function gt(e){return e.length===6}function _t(e,t){let n=Math.max(0,Math.ceil((e-t)/1e3)),r=Math.floor(n/60),i=n%60;return`${r}:${String(i).padStart(2,`0`)}`}function vt(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function yt(e){return e.length<=23?e:`${e.slice(0,20)}…`}function bt({view:e,beginError:t}){if(e===null)return t===null?`sending`:`send-failed`;switch(e.state){case`paired`:return`paired`;case`rejected`:return`rejected`;case`failed`:return`failed`;case`expired`:return`expired`;case`completing`:return`completing`;case`awaiting-confirmation`:return e.hubConfirmed&&!e.agentConfirmed?`awaiting-agent`:e.agentConfirmed&&!e.hubConfirmed?`awaiting-hub`:`awaiting-both`}}function xt(e){return e===`awaiting-both`||e===`awaiting-hub`}var St={sending:`Sending the pairing offer to the agent…`,"send-failed":`The agent could not be reached`,"awaiting-both":`Waiting for both confirmations`,"awaiting-agent":`Confirmed here — waiting for the agent`,"awaiting-hub":`The agent is confirmed — now confirm here`,completing:`Issuing the node certificate…`,paired:`Paired`,rejected:`Pairing was rejected`,failed:`Pairing failed`,expired:`The pairing expired`},Ct=2e3,wt=1e3;function Tt(e){return e.message.length>0?e.message:et.t(`pairing.agentsFoundSection.requestFailed`)}function Et(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function Dt(e){let[t,n]=o(()=>Date.now());return a(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),wt);return()=>clearInterval(t)},[e]),t}function Ot({target:n,onClose:r,onSettled:s,onOpenNode:c}){let{t:u}=K(),[d,f]=o(null),[p,m]=o(null),[h,g]=o(``),[_,v]=o(null),y=t(null),b=U.agentPairing.beginPairing.useMutation(),x=U.agentPairing.confirmPairing.useMutation(),S=U.agentPairing.rejectPairing.useMutation();a(()=>{if(n===null){y.current=null,f(null),m(null),g(``),v(null);return}if(y.current!==n){if(y.current=n,n.pairingId!==void 0){f(n.pairingId);return}b.mutateAsync({host:n.host,port:n.port}).then(e=>{y.current===n&&f(e.pairingId)}).catch(e=>{y.current===n&&m(Tt(e))})}},[n]);let C=U.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&J(t)?!1:Ct}}),w=kt(x.data??S.data??null,C.data??null),T=bt({view:w,beginError:p}),E=w!==null&&J(w.state),D=t(!1);a(()=>{if(!E){D.current=!1;return}D.current||(D.current=!0,s())},[E,s]);let O=Dt(w!==null&&!E),k=()=>{d===null||!gt(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(Tt(e)),g(``)}}))};return i(Te,{open:n!==null,onOpenChange:e=>!e&&r(),children:e(he,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ye,{children:[i(ke,{children:u(`pairing.pairingDialog.title`,{node:n?.nodeId??``})}),i(be,{children:n===null?``:u(`pairing.pairingDialog.eachScreenShowsACode`,`Both screens show the same six digits. Check they match, then type the code you read on the agent. Agent at {{value1}}`,{value1:vt(n.host,n.port)})})]}),e(De,{className:`space-y-4`,children:[i(At,{phase:T}),T===`send-failed`&&p!==null&&i(R,{title:u(`pairing.pairingDialog.couldNotStartThePairing`,`Could not start the pairing`),message:p}),w!==null&&!E&&i(jt,{view:w,phase:T,now:O,typed:h,onType:e=>g(ht(e)),onSubmit:k,confirmError:_,busy:x.isPending}),T===`paired`&&w!==null&&i(Mt,{nodeId:w.nodeId,onOpenNode:c,onClose:r}),E&&T!==`paired`&&w?.failure!=null&&i(R,{message:w.failure})]}),i(qe,{children:E||T===`send-failed`?i(H,{type:`button`,variant:`outline`,onClick:r,children:u(`common.close`,`Close`)}):e(l,{children:[i(H,{type:`button`,variant:`outline`,disabled:S.isPending,onClick:()=>{if(d===null){r();return}S.mutate({pairingId:d},{onSettled:r})},children:u(`pairing.pairingDialog.reject`,`Reject`)}),xt(T)&&e(H,{type:`button`,disabled:!gt(h)||x.isPending,onClick:k,children:[x.isPending&&i(L,{className:`h-4 w-4 animate-spin`}),u(`common.confirm`,`Confirm`)]})]})})]})})}function kt(e,t){if(t===null)return e;if(e===null)return t;let n=e=>(J(e.state)?10:e.state===`completing`?5:0)+ +!!e.hubConfirmed+ +!!e.agentConfirmed;return n(e)>n(t)?e:t}function At({phase:t}){let n=t===`sending`||t===`completing`,r=t===`paired`,a=t===`rejected`||t===`failed`||t===`expired`||t===`send-failed`;return e(`p`,{role:`status`,className:`flex items-center gap-2 text-sm font-medium ${r?`text-success`:a?`text-danger`:`text-foreground`}`,children:[n&&i(L,{className:`h-4 w-4 animate-spin`}),r&&i(b,{className:`h-4 w-4`}),a&&i(y,{className:`h-4 w-4`}),St[t]]})}function jt({view:t,phase:n,now:r,typed:a,onType:o,onSubmit:s,confirmError:c,busy:l}){let{t:u}=K();return e(`div`,{className:`space-y-4`,children:[e(`section`,{"aria-label":u(`pairing.pairingDialog.codeOnThisHub`,`Code on this hub`),className:`rounded-md border border-border bg-surface p-3`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:u(`pairing.pairingDialog.codeOnThisHubRead`,`Code on this hub: the agent must show the same digits`)}),i(`p`,{"data-testid":`hub-code`,className:`mt-1 font-mono text-3xl font-semibold tracking-widest text-foreground`,children:Et(t.code)}),i(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:u(`pairing.pairingDialog.onTheAgentEnterThis`,`On the agent, enter this code and the agent’s local PIN (shown on the agent’s console or log, or on its own screen).`)})]}),xt(n)?i(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),s()},children:i(W,{label:u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),description:u(`pairing.pairingDialog.typeTheSixDigitsThe`,`Type the six digits you read on the agent; do not paste. If they differ from the code above, stop and press Reject.`),...c===null?{}:{error:c},children:i(V,{value:a,onChange:e=>o(e.target.value),inputMode:`numeric`,autoComplete:`off`,spellCheck:!1,placeholder:`000000`,maxLength:6,disabled:l,"aria-label":u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),className:`font-mono tracking-widest`})})}):i(`p`,{className:`text-xs text-foreground-muted`,children:n===`awaiting-agent`?u(`pairing.pairingDialog.youConfirmedHereTheAgent`,`You confirmed here. The agent still has to enter the hub code and its PIN.`):u(`pairing.pairingDialog.working`,`Working…`)}),e(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-foreground-muted`,children:[i(`li`,{children:t.hubConfirmed?u(`pairing.pairingDialog.hubConfirmed`,`Hub: confirmed`):u(`pairing.pairingDialog.hubNotConfirmed`,`Hub: not confirmed`)}),i(`li`,{children:t.agentConfirmed?u(`pairing.pairingDialog.agentConfirmed`,`Agent: confirmed`):u(`pairing.pairingDialog.agentNotConfirmed`,`Agent: not confirmed`)}),i(`li`,{"data-testid":`countdown`,children:u(`pairing.pairingDialog.expiresIn`,{countdown:_t(t.expiresAt,r)})})]})]})}function Mt({nodeId:t,onOpenNode:n,onClose:r}){let{t:a}=K(),{nodes:o}=Ee(),s=o?.some(e=>e.id===t&&e.isOnline)===!0;return e(`div`,{className:`space-y-2 rounded-md border border-success/40 bg-success/10 p-3 text-sm`,children:[e(`p`,{className:`flex items-center gap-2 text-success`,children:[i(m,{className:`h-4 w-4`}),s?a(`pairing.pairingDialog.joinedAndRegisteredItsCapabilities`,`{{nodeId}} joined and registered its capabilities.`,{nodeId:t}):a(`pairing.pairingDialog.holdsItsCertificateWaitingFor`,`{{nodeId}} holds its certificate. Waiting for it to connect and register its capabilities…`,{nodeId:t})]}),i(H,{type:`button`,size:`sm`,variant:`outline`,disabled:!s,onClick:()=>{r(),n(t)},children:a(`pairing.pairingDialog.openNode`,`Open node`)})]})}var Nt={paired:`success`,pending:`warning`,unpaired:`default`};function Pt({state:t,connected:n}){let{t:r}=K();return e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(Ve,{variant:Nt[t],className:`text-[10px]`,children:pt[t]}),t===`paired`&&i(`span`,{className:`text-[10px] text-foreground-muted`,children:n?r(`common.connected`):r(`pairing.agentStateBadge.notConnected`,`not connected`)})]})}s();var Y={pending:0,unpaired:1,paired:2};function Ft(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function It({onOpenNode:t}){let{t:r}=K(),a=O(),s=U.useUtils(),c=U.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[u,d]=o(null),[p,m]=o(null),[g,_]=o(!1),[v,y]=o(``),[b,x]=o(``),[C,w]=o(null),[T,E]=o(!1),D=()=>void s.agentPairing.listDiscoveredAgents.invalidate(),k=U.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{_(!1),y(``),x(``),w(null),D()},onError:e=>w(e.message)}),j=U.agentPairing.unpairAgent.useMutation({onSuccess:e=>{m({tone:`success`,message:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),D()},onError:e=>m({tone:`danger`,message:r(`pairing.agentsFoundSection.unpairFailed`,`Unpair failed: {{message}}`,{message:e.message})})}),M=n(()=>(c.data?.agents??[]).toSorted((e,t)=>Y[e.state]-Y[t.state]),[c.data]),N=async()=>{E(!0);try{await s.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),D()}finally{E(!1)}},ee=()=>{let e=Ft(b);if(e===null){w(`The port must be a whole number between 1 and 65535.`);return}w(null),k.mutate({host:v.trim(),...e===void 0?{}:{port:e}})},P=async e=>{await a({title:r(`pairing.agentsFoundSection.unpair`,`Unpair {{nodeId}}`,{nodeId:e.nodeId}),message:r(`pairing.agentsFoundSection.sCertificatesAreRevokedAt`,`{{nodeId}}'s certificates are revoked at once and it is disconnected from the mesh. It must be paired again before it can rejoin.`,{nodeId:e.nodeId}),confirmLabel:r(`pairing.agentsFoundSection.unpair2`,`Unpair`),variant:`danger`})&&(m(null),j.mutate({nodeId:e.nodeId}))},te=n(()=>[{key:`name`,header:r(`pairing.agentsFoundSection.name`,`Name`),render:e=>e.name??`—`,sortValue:e=>e.name},{key:`node`,header:r(`pairing.agentsFoundSection.node`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId}),sortValue:e=>e.nodeId},{key:`address`,header:r(`pairing.agentsFoundSection.address`,`Address`),render:e=>i(`span`,{className:`font-mono text-xs`,children:vt(e.host,e.port)}),sortValue:e=>e.host},{key:`version`,header:r(`pairing.agentsFoundSection.version`,`Version`),render:e=>e.version??`—`,sortValue:e=>e.version},{key:`state`,header:r(`pairing.agentsFoundSection.state`,`State`),render:e=>i(Pt,{state:e.state,connected:e.connected}),sortValue:e=>Y[e.state]},{key:`fingerprint`,header:r(`pairing.agentsFoundSection.certificate`,`Certificate`),render:e=>e.fingerprint===null?`—`:i(`span`,{className:`font-mono text-xs`,title:e.fingerprint,children:yt(e.fingerprint)}),sortValue:e=>e.fingerprint},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,render:e=>{let t=e.pairing;return e.state===`unpaired`?i(H,{type:`button`,size:`sm`,onClick:()=>d({nodeId:e.nodeId,host:e.host,port:e.port}),children:r(`pairing.agentsFoundSection.pair`,`Pair`)}):e.state===`paired`?i(H,{type:`button`,size:`sm`,variant:`outline`,disabled:j.isPending,onClick:()=>void P(e),children:r(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):e.state===`pending`&&t!==null?i(H,{type:`button`,size:`sm`,onClick:()=>d({nodeId:e.nodeId,host:e.host,port:e.port,pairingId:t.pairingId}),children:r(`pairing.agentsFoundSection.resume`,`Resume`)}):null}}],[j.isPending,r]);return e(ve,{headingId:`agents-found`,title:r(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:h,testId:`agents-found`,actions:e(l,{children:[e(H,{type:`button`,size:`sm`,variant:`outline`,disabled:T,onClick:()=>void N(),children:[T?i(L,{className:`h-3.5 w-3.5 animate-spin`}):i(S,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.scan`,`Scan`)]}),e(H,{type:`button`,size:`sm`,onClick:()=>_(e=>!e),children:[i(A,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.addByAddress`,`Add by address`)]})]}),children:[e(`div`,{className:`${f} space-y-3`,children:[i(`p`,{className:`text-[11px] leading-relaxed text-foreground-muted`,children:r(`pairing.agentsFoundSection.anAgentHoldsNoSecret`,`An agent holds no secret: pairing issues it a certificate after you confirm the same six digits on this page and on the agent. Discovery needs the agent on its own IP or host networking; a Docker bridge hides it — add it by address.`)}),g&&e(`form`,{"aria-label":r(`pairing.agentsFoundSection.addAgentByAddress`,`Add agent by address`),className:`flex flex-wrap items-start gap-2`,onSubmit:e=>{e.preventDefault(),v.trim().length>0&&!k.isPending&&ee()},children:[i(W,{label:r(`pairing.agentsFoundSection.address`,`Address`),description:r(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...C===null?{}:{error:C},children:i(V,{value:v,onChange:e=>y(e.target.value),placeholder:`192.0.2.20`,"aria-label":r(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),i(W,{label:r(`pairing.agentsFoundSection.port`,`Port`),description:r(`pairing.agentsFoundSection.optional`,`Optional.`),children:i(V,{value:b,onChange:e=>x(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":r(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),e(H,{type:`submit`,size:`sm`,className:`mt-5`,disabled:v.trim().length===0||k.isPending,children:[k.isPending&&i(L,{className:`h-3.5 w-3.5 animate-spin`}),r(`common.add`,`Add`)]})]}),p!==null&&i(`p`,{role:`status`,className:`rounded border px-3 py-2 text-xs ${p.tone===`success`?`border-success/30 text-foreground`:`border-danger/40 text-danger`}`,children:p.message}),c.isError?i(R,{title:r(`pairing.agentsFoundSection.couldNotListAgents`,`Could not list agents`),message:c.error?.message??r(`pairing.agentsFoundSection.requestFailed`,`Request failed`),onRetry:D}):c.isLoading?i(`p`,{className:`py-4 text-center text-xs text-foreground-muted`,children:r(`pairing.agentsFoundSection.lookingForAgents`,`Looking for agents…`)}):M.length===0?i(He,{icon:h,title:r(`pairing.agentsFoundSection.noAgentsFound`,`No agents found`),description:r(`pairing.agentsFoundSection.nothingIsAdvertisingOnThis`,`Nothing is advertising on this network. Start the agent on its own IP (or host networking), or add it by address.`)}):i(G,{columns:te,rows:M,rowKey:e=>e.nodeId,minWidthPx:720,defaultSort:{columnKey:`state`,dir:`asc`}})]}),i(Ot,{target:u,onClose:()=>d(null),onSettled:D,onOpenNode:t})]})}var Lt=`metrics-native`,Rt=`metrics-provider`;function zt(){let{t}=K(),n=F();return i(ve,{headingId:`cluster-metrics-collection`,icon:D,title:t(`cluster.metricsSettings.title`,`Metrics collection — all nodes`),children:e(`div`,{className:`${f} space-y-3`,children:[i(`p`,{className:I,children:t(`cluster.metricsSettings.hint`,`How often every node samples its CPU, memory and load, and how long the load history is kept.`)}),i(Be,{trpc:n.trpcClient,addonId:Lt,cap:Rt,scope:`cluster`,bare:!0})]})})}function Bt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){if(!Bt(e))return null;let t=e.ticket;if(typeof t!=`string`||t.length===0)return null;let n=e.dashboardUrl;return typeof n==`string`&&n.length>0?{ticket:t,dashboardUrl:n}:{ticket:t}}function Vt(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function Z(e){return e.startsWith(`172.17.`)}function Ht(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function Ut(e){if(e.startsWith(`10.`)||e.startsWith(`192.168.`))return!0;let t=/^172\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=16&&n<=31&&!Z(e)}function Wt(e,t){if(typeof t==`string`&&Vt(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!Z(e)&&!Ht(e)&&Ut(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!Z(e))return e;return null}function Gt(e){return`http://${e}:4444/`}function Kt(e,t){let n=new URL(Gt(e));return n.searchParams.set(`ticket`,t),n.toString()}function qt(){return window.open(`about:blank`,`_blank`)}function Jt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function Yt({node:t}){let{info:n}=nt();return!t.isHub||n===null?i(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}):e(l,{children:[i(`span`,{className:`text-sm font-semibold shrink-0`,"data-testid":`node-title-name`,children:n.name}),n.name!==t.id&&i(`span`,{className:`text-xs text-foreground-subtle shrink-0`,"data-testid":`node-title-id`,children:t.id})]})}s();function Xt(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Zt(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var Qt=[`trace`,`debug`,`info`,`warn`,`error`];function $t({proc:t,nodeId:n,defaultExpanded:r,activePanel:a,onTogglePanel:s}){let{t:c}=K(),l=t.services??[],u=l.length===1,[d,f]=o(u||r),[p,m]=o(null),[h,_]=o(`info`),y=t.name.includes(`(core)`),b=de(),S=Le(),C=Ze(),w=async e=>{m(e);try{await b.mutateAsync({nodeId:n,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},D=async()=>{m(t.name);try{await S.mutateAsync({nodeId:n,processName:t.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{m(null)}},O=async e=>{let r=`${n}/${t.name}`;try{await C.mutateAsync({nodeId:r,level:e}),_(e)}catch(e){console.error(`Failed to set log level:`,e)}};return e(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[e(`div`,{role:u?void 0:`button`,tabIndex:u?void 0:0,onClick:u?void 0:()=>f(!d),onKeyDown:u?void 0:e=>{(e.key===`Enter`||e.key===` `)&&f(!d)},className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${u?``:`hover:bg-muted/40 cursor-pointer`}`,children:[u?i(`span`,{className:`h-3 w-3 shrink-0`}):i(d?oe:T,{className:`h-3 w-3 text-muted-foreground shrink-0`}),y?i(g,{className:`h-3.5 w-3.5 text-primary shrink-0`}):i(E,{className:`h-3.5 w-3.5 text-warning shrink-0`}),i(`span`,{className:`text-xs font-semibold min-w-0 flex-1 basis-full truncate sm:basis-auto`,children:t.name}),e(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[`PID `,t.pid]}),i(Oe,{status:Zt(t.state),label:t.state}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:c(`cluster.forksTab.cpu`,{percent:t.cpuPercent})}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:q(t.memoryRss)}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:Xt(t.uptimeSeconds)}),!y&&e(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e(Ue,{children:[i(Re,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:c(`cluster.forksTab.setLogLevel`,`Set log level`),children:h}),i(Qe,{align:`end`,className:`min-w-[70px] py-0.5`,children:Qt.map(e=>i(Fe,{onClick:()=>O(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),i(H,{variant:`unstyled`,onClick:D,disabled:p===t.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restartProcess`,`Restart process`),children:i(M,{className:`h-3 w-3 ${p===t.name?`animate-spin`:``}`})})]})]}),d&&l.length>0&&i(`div`,{className:`divide-y divide-border/30`,children:l.map(t=>e(`div`,{children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[i(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${t.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),i(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:t.addonId}),t.capabilities.length>0&&e(`div`,{className:`flex gap-1 flex-shrink-0`,children:[t.capabilities.slice(0,3).map(e=>i(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),t.capabilities.length>3&&e(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,t.capabilities.length-3]})]}),e(`div`,{className:`flex items-center gap-1 shrink-0`,children:[i(H,{variant:`unstyled`,onClick:()=>s(t.addonId,`logs`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showLogsFor`,`Show logs for {{addonId}}`,{addonId:t.addonId}),children:i(v,{className:`h-3 w-3`})}),i(H,{variant:`unstyled`,onClick:()=>s(t.addonId,`events`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showEventsFor`,`Show events for {{addonId}}`,{addonId:t.addonId}),children:i(x,{className:`h-3 w-3`})}),i(H,{variant:`unstyled`,onClick:()=>w(t.addonId),disabled:p===t.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restart`,`Restart {{addonId}}`,{addonId:t.addonId}),children:i(M,{className:`h-3 w-3 ${p===t.addonId?`animate-spin`:``}`})})]})]}),a?.addonId===t.addonId&&a.type===`logs`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(We,{addonId:t.addonId,agentId:n,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>s(t.addonId,`logs`)})}),a?.addonId===t.addonId&&a.type===`events`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(Ke,{addonId:t.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>s(t.addonId,`events`)})})]},t.addonId))}),d&&l.length===0&&i(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:c(`cluster.forksTab.noServices`,`No services`)})]})}function en({nodeId:e,processes:t}){let{t:n}=K(),[r,a]=o(null),s=(e,t)=>{a(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.forksTab.noProcessesOnThisNode`,`No processes on this node`)}):i(`div`,{className:`space-y-2 py-1`,children:t.map((t,n)=>i($t,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:s},t.name))})}var tn={system:0,managed:1,root:2};s();function nn(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function rn(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function an({nodeId:t}){let{t:r}=K(),a=c(),o=B(`metrics.node-processes-snapshot`,e=>e.nodeId===t),{data:s}=xe({nodeId:t}),l=o?.processes??s,u=n(()=>l?[...l]:[],[l]),d=n(()=>[{key:`classification`,header:r(`cluster.processesTab.class`,`Class`),sortValue:e=>tn[e.classification],render:e=>i(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-info/20 text-info`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>i(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>i(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:r(`cluster.processesTab.addon`,`Addon`),sortValue:e=>e.addonId,render:e=>i(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:r(`cluster.processesTab.command`,`Command`),nowrap:!1,render:e=>i(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:rn(e.command)})},{key:`cpuPercent`,header:r(`cluster.processesTab.cpu`,`CPU%`),align:`right`,sortValue:e=>e.cpuPercent,render:e=>e.cpuPercent.toFixed(1)},{key:`memoryRssBytes`,header:`RSS`,align:`right`,sortValue:e=>e.memoryRssBytes,render:e=>q(e.memoryRssBytes)},{key:`uptimeSec`,header:r(`cluster.processesTab.uptime`,`Uptime`),align:`right`,sortValue:e=>e.uptimeSec,render:e=>i(`span`,{className:`text-foreground-subtle`,children:nn(e.uptimeSec)})}],[r]);return e(`div`,{className:`space-y-4`,children:[i(`div`,{className:`flex items-start justify-end gap-4`,children:e(H,{variant:`unstyled`,type:`button`,onClick:()=>a.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[i(S,{className:`h-3 w-3`}),` `,r(`common.refresh`)]})}),i(G,{columns:d,rows:u,rowKey:e=>e.pid,minWidthPx:880,maxBodyHeight:fe,emptyMessage:r(`cluster.processesTab.scanning`,`Scanning…`)})]})}s();var on=96;function sn({title:e,points:t,mainLabel:r,gcLabel:a,formatValue:o,emptyMessage:s,gapMs:c}){return i(pe,{title:e,series:n(()=>[{id:`main`,label:r,unit:`%`,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.main}))},{id:`gc`,label:a,unit:`%`,colorIndex:1,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.gc}))}],[t,r,a,c]),stacked:!0,height:on,formatValue:e=>o(e),axisFor:()=>({floor:25}),emptyMessage:s})}function Q({title:e,points:t,formatValue:r,emptyMessage:a,axisFloor:o,axisScale:s=`linear`,gapMs:c}){return i(pe,{title:e,series:n(()=>[{id:`value`,label:e,unit:s===`bytes`?`B`:null,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.value}))}],[t,e,s,c]),height:on,formatValue:e=>r(e),axisFor:()=>({floor:o,scale:s}),emptyMessage:a})}function cn(e,t){let n=e.at(-1);return n===void 0?[t]:t.atMs>n.atMs?[...e,t]:e.some(e=>e.atMs===t.atMs)?e:[...e,t].toSorted((e,t)=>e.atMs-t.atMs)}function ln(e,t,n,r){let i=e.get(t),a=cn(i?.points??[],r);if(i!==void 0&&a===i.points)return e;let o=new Map(e);return o.set(t,{key:t,kind:n,points:a.slice(Math.max(0,a.length-720))}),o}function un(e,t,n){let r=e;for(let e of ie(t,n))r=ln(r,e.key,e.kind,e.point);return r}function dn(e,t){let n=e;for(let e of t)for(let t of e.points)n=ln(n,e.key,e.kind,t);return n}function fn(e){let t=null;for(let n of e.values()){let e=n.points.at(-1);e!==void 0&&(t===null||e.atMs>t)&&(t=e.atMs)}return t}var pn=12e4;function mn(e,t){return e===null?!1:t-e>pn}function hn(e){let t=e=>{let t=e.points.at(-1);return t===void 0?-1:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.key.localeCompare(n.key):r})}function gn(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var _n={key:`cpu`,dir:`desc`};function vn(e){let t=e.points.at(-1);return t===void 0?null:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent}function yn(e){return e.points.at(-1)?.memoryRssBytes??null}function bn(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function xn(e,t){return t===`memory`?yn(e):vn(e)}function Sn(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:bn(n(e),e.key,t.search)),i=(e,t)=>e.key.localeCompare(t.key);return[...r].toSorted((e,r)=>{if(t.sort.key===`name`){let a=n(e).localeCompare(n(r)),o=t.sort.dir===`asc`?a:-a;return o===0?i(e,r):o}let a=xn(e,t.sort.key),o=xn(r,t.sort.key);if(a===null&&o===null)return i(e,r);if(a===null)return 1;if(o===null)return-1;let s=t.sort.dir===`desc`?o-a:a-o;return s===0?i(e,r):s})}s();function Cn(e,n=720){let r=B(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,s]=o(new Map),[c,l]=o(void 0),u=t(null),{data:d,isPending:f}=ge({forNodeId:e,sinceMs:c,maxPoints:n});a(()=>{d!==void 0&&s(e=>{let t=dn(e,d.series);return u.current=fn(t),t})},[d]);let p=r?.timestamp;a(()=>{r==null||p===void 0||(mn(u.current,p)&&l(u.current??0),s(e=>{let t=un(e,r.processes,p);return u.current=fn(t),t}))},[p]),a(()=>{s(new Map),l(void 0),u.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:hn(i),sampleCount:m,threadSplitAvailable:gn(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var wn=`__unclaimed__`;function Tn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function En(e,t){return{key:e,kind:t.kind,deviceId:t.deviceId,cpuSeconds:t.cpuKnown?Math.round(t.cpu*100)/100:null,rssBytes:t.rssKnown?t.rss:null,unitCount:t.count,roles:[...t.roles].sort()}}function Dn(e,t){let n=new Map,r=new Set;for(let t of e){t.pid!==void 0&&r.add(t.pid);let e=t.deviceId!==null&&t.attribution!==`unattributable`,i=e?`device:${t.deviceId}`:`shared:${t.role}`,a=n.get(i)??Tn(e?`camera`:`shared`,e?t.deviceId:null);a.count+=1,a.roles.add(t.role),t.cpuSeconds===void 0?a.cpuKnown=!1:a.cpu+=t.cpuSeconds,t.rssBytes===void 0?a.rssKnown=!1:a.rss+=t.rssBytes,n.set(i,a)}let i=[...n.entries()].map(([e,t])=>En(e,t));if(t===void 0)return i;let a=t.filter(e=>!r.has(e.pid));if(a.length===0)return i;let o=Tn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,En(wn,o)]}var On=[{family:`decode`,attribution:`measured`,unit:`one forked decode-worker child per decode SESSION`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:118`,`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:131`,`packages/addon-pipeline/src/pipeline-runner/index.ts:2765`,`packages/types/src/process/child-cost-registry.ts:188`]},{family:`transcode`,attribution:`measured`,unit:`one ffmpeg child per (camera, encode plan)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/egress-transcode-manager.ts:960`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:282`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:324`,`packages/types/src/ffmpeg/sharing-key.ts:139`]},{family:`recording`,attribution:`measured`,unit:`one passthrough ffmpeg per (camera, profile)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:33`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:217`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:279`,`packages/addon-pipeline/src/recorder/addon/recording-controller.ts:1710`]},{family:`detection`,attribution:`accounted`,unit:`a SHARED inference pool per (node, runtime, device) — no per-camera process`,perCamera:!1,wiredToday:!0,missingLink:"Nothing is missing for COUNTING — per-camera inference milliseconds, processed/shed frames and bytes-to-pool are already accumulated. What is missing is any basis for CPU seconds: `deviceId` reaches the pool as a diagnostic label and selects nothing, so cost can only ever be apportioned, never measured. Since 2026-08-27 the pool DECLARES this itself, contributing `deviceId: null` + `attribution: unattributable` rather than leaving an observer to infer it — the renunciation is data, and it is still refused by the chart gate.",evidence:[`packages/addon-pipeline/src/detection-pipeline/provider.ts:540`,`packages/addon-pipeline/src/detection-pipeline/engine/shared-inference-pool.ts:413`,`packages/types/src/interfaces/inference-engine.ts:24`,`packages/addon-pipeline/src/pipeline-runner/timing-sampler.ts:63`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:353`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:849`,`packages/addon-pipeline/src/pipeline-runner/frame-lazy-metrics.ts:100`]},{family:`streaming`,attribution:`measured`,unit:"one StreamBroker per `${deviceId}/${camStreamId}`, with an exact RTP ring byte counter",perCamera:!0,wiredToday:!1,missingLink:"The ffmpeg-backed ingest is now reported per camera, but that is the minority path. `rtpRingBytes` — the exact figure for the in-process case — is maintained on every push and drop and is still private and absent from `getStats()`. The three `EncodedRingBuffer`s track packets and duration and have no byte accumulator at all; the only byte figure they offer is `preRollBudgetBytes`, which is a BUDGET, not an occupancy.",evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2895`,`packages/addon-pipeline/src/stream-broker/rtsp/ffmpeg-push-reader.ts:189`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:494`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:498`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2505`,`packages/addon-pipeline/src/stream-broker/stream-broker/pre-roll.ts:269`]}];function kn(e){return e.attribution===`measured`&&e.wiredToday}function An(){let e=new Set;for(let t of On)kn(t)&&e.add(t.family);return e}var jn=An();function Mn(e){return!jn.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function Nn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function Pn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function Fn(e,t,n){if(t.cpuSeconds===void 0)return null;if(e===void 0)return t.startedAtMs===void 0||t.startedAtMs<n?null:t.cpuSeconds;if(e.cpuSeconds===void 0||e.startedAtMs===void 0||t.startedAtMs===void 0||e.startedAtMs!==t.startedAtMs)return null;let r=t.cpuSeconds-e.cpuSeconds;return r<0?null:r}function In(e){return Math.round(e*10)/10}function Ln(e,t){let n=t.atMs-e.atMs;if(n<=0)return[];let r=n/1e3,i=new Map;for(let t of e.entries)Mn(t)&&i.set(Nn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!Mn(n)||n.deviceId===null)continue;let t=Nn(n);o.add(t);let r=a.get(n.deviceId)??Pn();r.unitCount+=1,r.roles.add(n.role);let s=Fn(i.get(t),n,e.atMs);s===null?r.cpuKnown=!1:r.cpuSeconds+=s,n.rssBytes===void 0?r.rssKnown=!1:r.rssBytes+=n.rssBytes,a.set(n.deviceId,r)}for(let[e,t]of i){if(o.has(e)||t.deviceId===null)continue;let n=a.get(t.deviceId);n!==void 0&&(n.cpuKnown=!1)}return[...a.entries()].map(([e,n])=>({deviceId:e,point:{atMs:t.atMs,cpuPercent:n.cpuKnown?In(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function Rn(e,t){if(t.length===0)return e;let n=new Map(e);for(let e of t){let t=n.get(e.deviceId),r=t?.points.at(-1);if(r!==void 0&&e.point.atMs<=r.atMs)continue;let i=[...t?.points??[],e.point];n.set(e.deviceId,{deviceId:e.deviceId,points:i.slice(Math.max(0,i.length-720))})}return n}function zn(e){let t=e=>{for(let t=e.points.length-1;t>=0;t--){let n=e.points[t]?.cpuPercent;if(n!=null)return n}return-1};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.deviceId-n.deviceId:r})}function Bn(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function Vn(e,t){let n=Bn(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Hn(e,t){return e.filter(e=>Vn(e.addonId,t))}s();function Un(e){let n=B(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=$e(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,s]=o(new Map),c=t(null),l=t(r.refetch);l.current=r.refetch;let u=n?.timestamp;a(()=>{u!==void 0&&l.current()},[u]),a(()=>{s(new Map),c.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;a(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:Hn(d,e)},n=c.current;if(c.current=t,n===null)return;let r=Ln(n,t);r.length!==0&&s(e=>Rn(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Hn(d,e),m=n?.processes,h=Dn(p,m);return{series:zn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Wn(e){let t=new Map;for(let n of e){let e=n.name?.trim();e===void 0||e===``||t.set(n.id,e)}return t}var Gn=25,Kn=64*1024*1024,qn=1e4;function Jn({scope:t,cadenceMs:n}){let{t:r}=K(),a=Un(t),{data:o=[]}=Ae({isCamera:!0,projection:`slim`}),s=Wn(o),c=Ne(n??qn);return e(`section`,{className:`space-y-3`,children:[a.error!==null&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[i(C,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:r(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:a.error})})]}),i(Xn,{unclaimed:a.unclaimed}),a.series.length===0&&a.error===null&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:a.loading?r(`cameraLoad.loading`,`Reading what the addons report…`):r(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),i(`div`,{className:`space-y-3`,children:a.series.map(t=>e(`div`,{className:`rounded-lg border border-border p-3`,children:[e(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[i(Yn,{deviceId:t.deviceId,name:s.get(t.deviceId)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:t.points.at(-1)?.unitCount??0,roles:(t.points.at(-1)?.roles??[]).join(`, `)})})]}),e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[i(Q,{title:r(`cameraLoad.cpuTitle`,`CPU % of one core (delta)`),points:t.points.map(e=>({atMs:e.atMs,value:e.cpuPercent})),formatValue:e=>`${e.toFixed(1)}%`,axisFloor:Gn,gapMs:c,emptyMessage:r(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),i(Q,{title:r(`cameraLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:q,axisFloor:Kn,axisScale:`bytes`,gapMs:c,emptyMessage:r(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},t.deviceId))})]})}function Yn({deviceId:t,name:n}){let{t:r}=K();return n===void 0?i(`span`,{className:`text-xs font-medium text-foreground`,children:r(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:t})}):e(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),e(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,t]})]})}function Xn({unclaimed:e}){let{t}=K();return e===null||e.unitCount===0?null:i(`div`,{className:`flex items-center gap-2`,children:i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full bg-warning/10 text-warning font-medium tabular-nums`,children:t(`cameraLoad.unclaimedBadge`,`{{count}} unclaimed · {{rss}}`,{count:e.unitCount,rss:e.rssBytes===null?`—`:q(e.rssBytes)})})})}s();var Zn=256*1024*1024,Qn=1e4;function $n({nodeId:r,isHub:a}){let s=t(null);me(s);let{t:c}=K(),{series:l,sampleCount:u,threadSplitAvailable:f,loadingRetained:p,bucketMs:m,cadenceMs:h}=Cn(r),[g,v]=o(``),[y,b]=o(new Set),[x,S]=o(_n),w=e=>e.key===`__root__`?c(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?c(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,T=Ne(m??h??Qn),E=n(()=>Sn(l,{search:g,selectedKeys:y,sort:x},w),[l,g,y,x]),D=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return e(`div`,{className:`space-y-4`,children:[i(er,{bucketMs:m,cadenceMs:h}),!f&&u>0&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/40 bg-warning/5 px-3 py-2 text-[11px] text-warning`,children:[i(C,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:c(`clusterLoad.noThreadSplit`,`No thread-level CPU split on this node — /proc/<pid>/task is Linux-only, and the first sample after a restart has no window to measure. CPU below falls back to the ps lifetime AVERAGE, which is not a rate.`)})]}),u===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:p?c(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):c(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),l.length>0&&e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`relative flex-1 min-w-[160px]`,children:[i(d,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),i(V,{ref:s,type:`search`,value:g,onChange:e=>v(e.target.value),placeholder:c(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":c(`clusterLoad.searchLabel`,`Find a runner`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle`})]}),i(tr,{sort:x,onChange:S})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[l.map(e=>{let t=y.has(e.key);return i(H,{variant:`unstyled`,type:`button`,"aria-pressed":t,onClick:()=>D(e.key),className:`rounded-full border px-2 py-0.5 text-[10px] transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:w(e)},e.key)}),y.size>0&&e(H,{variant:`unstyled`,type:`button`,onClick:()=>b(new Set),className:`inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:[i(_,{className:`h-2.5 w-2.5`}),c(`clusterLoad.clearFilter`,`All runners`)]})]})]}),l.length>0&&E.length===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:c(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:l.length})}),i(`div`,{className:`space-y-3`,children:E.map(t=>e(`div`,{className:`rounded-lg border border-border p-3`,children:[e(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:w(t)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`clusterLoad.processCount`,`{{count}} process(es)`,{count:t.points.at(-1)?.processCount??0})})]}),e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[i(sn,{title:f?c(`clusterLoad.cpuTitle`,`CPU % of one core`):c(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:c(`clusterLoad.seriesMain`,`Main threads`),gcLabel:c(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:t.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:T,emptyMessage:c(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(t.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),i(Q,{title:c(`clusterLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:q,axisFloor:Zn,axisScale:`bytes`,gapMs:T,emptyMessage:c(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},t.key))}),i(Jn,{scope:{nodeId:r,isHub:a},cadenceMs:h})]})}function er({bucketMs:e,cadenceMs:t}){let{t:n}=K();return e===null?null:i(`p`,{className:`text-[10px] text-foreground-subtle`,children:t!==null&&e>t?n(`clusterLoad.captionBucket`,`1 point = {{bucket}}s (bucket MAXIMUM, not a mean)`,{bucket:Math.round(e/1e3)}):n(`clusterLoad.captionRaw`,`1 point = 1 snapshot`)})}function tr({sort:t,onChange:n}){let{t:r}=K(),a=[{key:`cpu`,label:r(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:r(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:r(`clusterLoad.sortName`,`Name`)}];return e(`div`,{className:`flex items-center gap-1`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`clusterLoad.sortBy`,`Sort by`)}),a.map(r=>{let i=t.key===r.key;return e(H,{variant:`unstyled`,type:`button`,"aria-pressed":i,onClick:()=>n(i?{key:r.key,dir:t.dir===`desc`?`asc`:`desc`}:{key:r.key,dir:r.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[r.label,i&&(t.dir===`desc`?` ↓`:` ↑`)]},r.key)})]})}var nr=`No per-node settings on this node. Every other setting these addons expose is one value for the whole cluster — edit those in System → Settings, not here.`;function rr({nodeId:e,addonIds:t}){let{t:n}=K();return t.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.nodeDetailSettingsTab.noAddonsOnThisNode`,`No addons on this node`)}):i(`div`,{className:`w-full py-2`,children:i(rt,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:nr,selfTabbed:!0})})}s();function ir({nodeId:e,addons:t}){let{t:r}=K(),a=c(),{data:o,isLoading:s}=Ce({nodeId:e}),l=n(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),u=Je({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return l.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:r(`cluster.nodeDetailCapabilitiesTab.noCapabilitiesOnThisNode`,`No capabilities on this node`)}):i(G,{columns:[{key:`capName`,header:r(`cluster.nodeDetailCapabilitiesTab.capability`,`Capability`),width:`w-1/2`,sortValue:e=>e.capName,render:e=>i(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:r(`cluster.nodeDetailCapabilitiesTab.boundProvider`,`Bound provider`),render:t=>{let n=o?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return i(k,{value:n,onChange:n=>u.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||u.isPending||s,className:`w-full`,title:a?r(`cluster.nodeDetailCapabilitiesTab.onlyOneProviderInstalledChoice`,`Only one provider installed — choice becomes available once a second addon registers this capability`):void 0,children:t.providers.map(e=>i(`option`,{value:e,children:e},e))})}}],rows:l,rowKey:e=>e.capName,minWidthPx:520,maxBodyHeight:fe})}s();function ar(e){if(e==null)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:`${i}m`}function or(t){let{t:n}=K(),[r,a]=o(!1),[s,l]=o(t.name),u=c(),d=we({onSuccess:()=>{u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),f=(t.localIps??[]).filter(e=>!e.includes(`:`)),p=(t.localIps??[]).filter(e=>e.includes(`:`)),m=async()=>{if(!s.trim()||s===t.name){a(!1);return}try{await d.mutateAsync({nodeId:t.nodeId,name:s.trim()}),a(!1)}catch(e){console.error(`Rename failed:`,e)}},h=[[`Node ID`,i(`span`,{className:`font-mono text-xs`,children:t.nodeId})],[`Display Name`,r?e(`div`,{className:`flex items-center gap-1.5`,children:[i(V,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:s,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&a(!1)},disabled:d.isPending,autoFocus:!0}),i(H,{variant:`unstyled`,onClick:()=>void m(),disabled:d.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:n(`common.save`,`Save`),children:i(N,{className:`h-3.5 w-3.5`})}),i(H,{variant:`unstyled`,onClick:()=>a(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:n(`common.cancel`,`Cancel`),children:i(_,{className:`h-3.5 w-3.5`})})]}):e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-xs`,children:t.name}),!t.isHub&&i(H,{variant:`unstyled`,onClick:()=>{l(t.name),a(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:n(`cluster.nodeInfoTab.rename`,`Rename`),children:i(P,{className:`h-3 w-3`})})]})],[`Hostname`,i(`span`,{className:`text-xs`,children:t.hostname})],[`Role`,t.isHub?i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:n(`cluster.nodeInfoTab.hub`,`Hub`)}):i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:n(`cluster.nodeInfoTab.agent`,`Agent`)})],[`Root Package`,t.rootPackage?e(`span`,{className:`font-mono text-xs`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}):i(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,e(`span`,{className:`text-xs`,children:[t.platform,` / `,t.arch]})],[`CPU`,e(`span`,{className:`text-xs`,children:[t.cpuModel??`—`,` (`,n(`cluster.nodeInfoTab.cores`,{count:t.cpuCores}),`)`]})],[`Memory`,i(`span`,{className:`text-xs`,children:t.memoryMB>0?n(`cluster.nodeInfoTab.gb`,`{{value1}} GB`,{value1:(t.memoryMB/1024).toFixed(1)}):`—`})],[`Uptime`,i(`span`,{className:`text-xs`,children:ar(t.uptime)})],[n(`cluster.nodeInfoTab.installedRuntimes`,`Installed runtimes`),t.engines.length>0?i(`div`,{className:`flex flex-wrap gap-1`,title:n(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e))}):i(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return f.length>0&&h.push([`IPv4`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>i(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),p.length>0&&h.push([`IPv6`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map((e,t)=>i(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),i(`div`,{className:`py-2`,children:i(`table`,{className:`w-full text-sm`,children:i(`tbody`,{children:h.map(([t,n],r)=>e(`tr`,{className:r%2==0?`bg-muted/20`:``,children:[i(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:t}),i(`td`,{className:`py-1.5 px-2`,children:n})]},t))})})})}s();function sr({nodeId:t,value:n,detectedHosts:r,status:s,errorMessage:c,onCommit:l}){let{t:d}=K(),[f,p]=o(n??``);a(()=>{p(n??``)},[n]);let m=r[0],h=m===void 0?`auto-detect`:`auto: ${m}`,g=s===`pending`,_=f.trim(),v=_!==(n??``),y=v&&!g,b=()=>{y&&l(t,_.length>0?_:null)};return e(`div`,{className:`flex items-center gap-1.5`,children:[i(V,{"aria-label":d(`placementBoard.reachableHostInput.reachableHostFor`,`Reachable host for {{nodeId}}`,{nodeId:t}),type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:h,value:f,disabled:g,onChange:e=>p(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&b(),e.key===`Escape`&&p(n??``)},className:`w-36`}),e(H,{variant:`outline`,size:`sm`,onClick:b,disabled:!y,"aria-label":d(`placementBoard.reachableHostInput.saveReachableHostFor`,`Save reachable host for {{nodeId}}`,{nodeId:t}),title:d(`placementBoard.reachableHostInput.saveReachableHost`,`Save reachable host`),children:[g?i(L,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):i(N,{className:`h-3 w-3`,"aria-hidden":`true`}),d(`common.save`,`Save`)]}),!v&&!g&&s===`success`&&i(N,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":d(`placementBoard.reachableHostInput.saved`,`Saved`),role:`img`}),s===`error`&&i(`span`,{title:c??d(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),children:i(u,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":c??d(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),role:`img`})})]})}s();function cr(e){let t=ae.safeParse(ct(e,`color`));return t.success?t.data:null}function lr(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function ur({nodeId:t,detectedHosts:r}){let{t:a}=K(),o=c(),s=_e(void 0),l=je({onSuccess:()=>st(o)}),u=je({onSuccess:()=>st(o)}),d=n(()=>s.data?.find(e=>e.nodeId===t)?.settings,[s.data,t]),f=cr(d)??(s.isLoading?null:ne(t)),p=ot(d,`reachableHost`),m=lr(t,l),h=m===`error`?lt(l.error):null,g=r.filter(e=>!e.includes(`:`)),_=e=>{e!==f&&u.mutate({agentNodeId:t,color:e})};return e(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[i(z,{label:a(`nodes.general.nodeColour`,`Node colour`),children:i(`div`,{role:`group`,"aria-label":a(`nodes.general.nodeColourGroup`,`Node colour`),className:`flex flex-wrap gap-2`,children:re.map(e=>{let t=f===e;return i(H,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":e,variant:`outline`,size:`sm`,disabled:s.isLoading||u.isPending,title:e,onClick:()=>_(e),className:`h-6 w-6 min-w-6 shrink-0 rounded-full border-0 p-0 ${Se(e)} ${t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:`opacity-80 hover:opacity-100`}`,children:i(`span`,{className:`sr-only`,children:e})},e)})})}),i(z,{label:a(`nodes.general.reachableHost`,`Reachable host`),children:i(sr,{nodeId:t,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{l.mutate({agentNodeId:e,reachableHost:t})}})})]})}s();var dr=512,fr=65536,pr=[[`serverManagement`,`getLaunchOverrides`]];function mr(e){let t=e.trim();if(t===``)return null;if(!/^[0-9]+$/.test(t))return;let n=Number(t);return n>=dr&&n<=fr?n:void 0}var hr=e=>e==null?``:String(e);function gr({node:t}){let{t:n}=K(),r=c(),s=t.isHub?void 0:{nodeId:t.id},l=Xe(s,{enabled:t.isOnline,retry:1}),u=Me({onSuccess:()=>{r.invalidateQueries({queryKey:pr})}}),[d,f]=o(``),[p,m]=o(``),[h,g]=o(null),_=l.data;a(()=>{_!==void 0&&(f(hr(_.heapMb)),m(hr(_.rssBudgetMb)))},[_]);let v=async()=>{let e=mr(d),r=t.isHub?mr(p):null;if(e===void 0||r===void 0){g(n(`nodes.launch.invalid`,`Enter a whole number between {{min}} and {{max}} MB, or leave the field empty.`,{min:dr,max:fr}));return}g(null);try{g((await u.mutateAsync({...s,heapMb:e,...t.isHub?{rssBudgetMb:r}:{}})).restartRequired?n(`nodes.launch.saved`,`Saved. Takes effect on restart.`):n(`nodes.launch.savedNow`,`Saved.`))}catch(e){g(e instanceof Error?e.message:n(`nodes.launch.failed`,`Save failed.`))}};return e(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[i(z,{label:n(`nodes.launch.heap`,`Heap ceiling (MB)`),children:i(V,{type:`number`,inputMode:`numeric`,"aria-label":n(`nodes.launch.heap`,`Heap ceiling (MB)`),placeholder:n(`nodes.launch.default`,`Default`),value:d,onChange:e=>f(e.target.value),disabled:!t.isOnline||l.isLoading})}),t.isHub&&i(z,{label:n(`nodes.launch.rss`,`RSS budget (MB)`),children:i(V,{type:`number`,inputMode:`numeric`,"aria-label":n(`nodes.launch.rss`,`RSS budget (MB)`),placeholder:n(`nodes.launch.default`,`Default`),value:p,onChange:e=>m(e.target.value),disabled:!t.isOnline||l.isLoading})}),i(z,{label:n(`nodes.launch.restartNote`,`Takes effect on restart`),actions:i(H,{type:`button`,size:`sm`,onClick:()=>void v(),disabled:!t.isOnline||u.isPending,children:n(`common.save`,`Save`)}),children:h??``})]})}s();var _r=3*6e4,vr={neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-success/15 text-success`,info:`bg-info/15 text-info`,warn:`bg-warning/15 text-warning`,error:`bg-danger/15 text-danger`};function yr({desktopApp:t,nodeName:n,routingInput:s,onSettled:c}){let{t:l}=K(),u=O(),d=Ye({onSettled:c}),[f,p]=o(null),[m,h]=o(!1),[g,_]=o(null);a(()=>{f!=null&&t.version!==f.fromVersion&&(p(null),h(!1))},[t.version,f]),a(()=>{if(f==null)return;let e=Math.max(0,f.startedAtMs+_r-Date.now()),t=setTimeout(()=>h(!0),e);return()=>clearTimeout(t)},[f]);let v=r(e=>{switch(e){case`not-electron`:return l(`serverManagement.desktopRefusedNotElectron`,`This node does not run inside the desktop app.`);case`no-app-state`:return l(`serverManagement.desktopRefusedNoState`,`The desktop app has not reported its state yet.`);case`app-state-stale`:return l(`serverManagement.desktopRefusedStale`,`The desktop app stopped reporting — it is probably not running.`);case`not-downloaded`:return l(`serverManagement.desktopRefusedNotDownloaded`,`No update is downloaded yet.`)}},[l]),y=r(async()=>{if(await u({title:l(`serverManagement.desktopConfirmTitle`,`Install desktop app update`),message:l(`serverManagement.desktopConfirmBody`,`Install {{version}} on "{{node}}" and restart the desktop app? The node is offline while it restarts.`,{version:t.update.version??``,node:n}),confirmLabel:l(`serverManagement.desktopInstallAction`,`Install update & restart`),variant:`warning`})){_(null),h(!1);try{let e=await d.mutateAsync(s);e.accepted?p({fromVersion:t.version,startedAtMs:Date.now()}):e.reason!=null&&_(v(e.reason))}catch(e){_(e instanceof Error?e.message:String(e))}}},[u,t,d,n,v,s,l]),b=f!=null&&!m,{update:x}=t,S=null;t.stale?S={label:l(`serverManagement.desktopStale`,`app state unknown (last seen {{when}})`,{when:it(t.stateAtMs)}),tone:`warn`}:x.downloaded?S={label:l(`serverManagement.desktopReady`,`update {{version}} ready`,{version:x.version??``}),tone:`ok`}:x.available?S={label:l(`serverManagement.desktopDownloading`,`update {{version}} available — downloading`,{version:x.version??``}),tone:`info`}:x.checking?S={label:l(`serverManagement.stateChecking`,`checking…`),tone:`info`}:x.error??(S={label:l(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`});let C=!t.stale&&x.downloaded&&!b&&!d.isPending;return e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-sm`,children:[e(`span`,{className:`inline-flex items-baseline gap-1`,children:[i(`span`,{className:`text-foreground-subtle`,children:l(`serverManagement.desktopApp`,`Desktop app`)}),i(`span`,{className:`font-mono text-foreground`,children:t.version})]}),S!=null&&i(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${vr[S.tone]}`,children:S.label})]}),!t.stale&&x.error!=null&&i(`p`,{className:`text-xs text-danger`,children:l(`serverManagement.desktopUpdateError`,`Update check failed: {{error}}`,{error:x.error})}),C&&e(H,{size:`sm`,onClick:()=>void y(),children:[i(M,{className:`h-3.5 w-3.5`}),l(`serverManagement.desktopInstallAction`,`Install update & restart`)]}),(d.isPending||b)&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(L,{className:`h-4 w-4 animate-spin`}),l(`serverManagement.desktopRestarting`,`The desktop app is restarting to install the update…`)]}),f!=null&&m&&i(`p`,{role:`status`,className:`text-xs text-warning`,children:l(`serverManagement.desktopRestartTimeout`,`The desktop app has not come back with a new version after 3 minutes. Check the machine.`)}),g!=null&&i(`p`,{role:`status`,className:`text-xs text-warning`,children:g})]})}s();var br=[[`serverManagement`,`getServerPackageStatus`]];function xr({label:e,tone:t}){return i(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${{neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-success/15 text-success`,info:`bg-info/15 text-info`,warn:`bg-warning/15 text-warning`,error:`bg-danger/15 text-danger`}[t]}`,children:e})}function $({label:t,value:n}){return e(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[i(`span`,{className:`text-foreground-subtle`,children:t}),i(`span`,{className:`font-mono text-foreground`,children:n??`—`})]})}function Sr({runningVersion:t,latestVersion:n,seedVersion:r,nodeRuntimeVersion:a,labelRunning:o,labelLatest:s,labelSeed:c,labelRuntime:l}){return i(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[{key:`running`,label:o,value:t},{key:`latest`,label:s,value:n},{key:`seed`,label:c,value:r},{key:`runtime`,label:l,value:a}].map(({key:t,label:n,value:r})=>e(`span`,{className:`inline-flex items-baseline gap-1`,children:[i(`span`,{className:`text-foreground-subtle`,children:n}),i(`span`,{className:`font-mono text-foreground`,children:r??`—`})]},t))})}var Cr={ok:`border-success/40 bg-success/10 text-success`,warn:`border-warning/40 bg-warning/10 text-warning`,error:`border-danger/40 bg-danger/10 text-danger`};function wr(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function Tr(e,t){let n=t instanceof Error?t.message:String(t);return`${e(`serverManagement.outcomeDropped`,`The connection dropped and the result could not be confirmed. The node may be restarting — re-check the version above.`)} — ${n}`}function Er({node:t}){let{t:n}=K(),a=c(),s=O(),[l,u]=o(!1),[d,f]=o(null),m=t.isHub?void 0:{nodeId:t.id},h=Ge(m,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),g=h.data??null,_=r(()=>{a.invalidateQueries({queryKey:br})},[a]),v=Ie({onSettled:_}),y=ue({onSettled:_}),b=ze({onSettled:_}),x=r(async()=>{if(g?.latestVersion==null){f({tone:`warn`,text:n(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await s({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:g.packageName,version:g.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await y.mutateAsync({version:g.latestVersion,...m});f({tone:wr(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Tr(n,e)})}}},[y,s,t.name,m,g,n]),C=r(async()=>{if(await s({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await b.mutateAsync(m);f({tone:wr(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Tr(n,e)})}}},[s,t.name,b,m,n]),w=()=>{switch(g?.bootMode){case`data-root`:return{label:n(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:n(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:n(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},T=()=>{if(g==null)return null;switch(g.updateState){case`checking`:return{label:n(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:n(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:n(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return g.restartRequired===!0?{label:n(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:g.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},E=g?.bootMode===`workspace`,D=t.isOnline&&g!=null&&!E&&g.updateAvailable&&g.updateState===`idle`&&!y.isPending,k=t.isOnline&&g!=null&&g.updateState===`idle`&&!b.isPending,A=t.isOnline?T():null;return e(`div`,{className:`space-y-4 py-2`,children:[e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-2 min-w-0`,children:[i(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:g?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&g!=null&&i(xr,{...w()})]}),A!=null&&i(xr,{...A})]}),!t.isOnline&&i($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&h.isLoading&&e(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[i(L,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&h.isError&&e(`div`,{className:`space-y-1.5`,children:[i(`p`,{className:`text-sm text-danger`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&i($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&g!=null&&e(`div`,{className:`space-y-1.5`,children:[i(Sr,{runningVersion:g.runningVersion,latestVersion:g.latestVersion,seedVersion:g.seedVersion,nodeRuntimeVersion:g.nodeRuntimeVersion,labelRunning:n(`serverManagement.runningVersionShort`,`Running`),labelLatest:n(`serverManagement.latestVersionShort`,`Latest`),labelSeed:n(`serverManagement.imageSeedShort`,`Seed`),labelRuntime:n(`serverManagement.nodeRuntimeVersionShort`,`Node.js`)}),g.desktopApp!=null&&i(yr,{desktopApp:g.desktopApp,nodeName:t.name,routingInput:m,onSettled:_}),g.pendingVersion!=null&&i($,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:g.pendingVersion}),g.installedVersion!=null&&g.installedVersion!==g.runningVersion&&i($,{label:n(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:g.installedVersion})]}),t.isOnline&&g?.imageContract?.state===`behind-series`&&e(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs leading-relaxed text-danger`,children:[i(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),i(`p`,{children:g.imageContract.message})]}),t.isOnline&&E&&i(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&i(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${Cr[d.tone]}`,children:d.text}),l&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(L,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&e(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[e(H,{variant:`unstyled`,type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:v.isPending||g?.updateState===`staging`,onClick:()=>v.mutate(m),children:[v.isPending?i(L,{className:`h-3.5 w-3.5 animate-spin`}):i(S,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),D&&e(H,{variant:`unstyled`,type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void x(),children:[y.isPending?i(L,{className:`h-3.5 w-3.5 animate-spin`}):i(p,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:g?.latestVersion??``})]}),e(H,{variant:`unstyled`,type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!k,onClick:()=>void C(),children:[b.isPending?i(L,{className:`h-3.5 w-3.5 animate-spin`}):i(M,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&g?.lastCheckedAtMs!=null&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(se,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(g.lastCheckedAtMs).toLocaleString()})]})]})}s();function Dr(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`reachableHost`);return typeof t==`string`&&t.length>0?t:null}function Or({node:t}){let{t:a}=K(),s=F(),u=c(),d=O(),[f,p]=o(!1),[m,h]=o(`info`),[g,_]=o(!1),[v,y]=o(null),b=t.processes??[],x=t.addons.map(e=>e.id),S=_e(void 0),C=n(()=>{let e=S.data?.find(e=>e.nodeId===t.id);return Dr(e?.settings)},[S.data,t.id]),[w,T]=o(!1),[E,D]=o(null),[k,A]=o(null),M=r(async()=>{if(w||t.isHub)return;let e=Wt(t.localIps??[],C);if(e===null){D(`No LAN IPv4 on this node — open its :4444 URL by hand.`),A(null);return}let n=qt();T(!0),D(null),A(null);try{let r=X(await s.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:Gt(e)}})),i=r===null?null:r.dashboardUrl??Kt(e,r.ticket);if(i===null){n?.close(),D(`Hub did not return an unlock ticket.`);return}Jt(n,i)||(A(i),D(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){n?.close(),D(e instanceof Error?e.message:String(e))}finally{T(!1)}},[t.id,t.isHub,t.localIps,w,C,s.trpcClient]),N=async()=>{if(!g){_(!0),y(null);try{await s.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await s.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});y({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){y({tone:`warn`,text:a(`cluster.nodeCard.forgetFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{_(!1)}}},P=async()=>{if(!f&&await d({title:a(`cluster.nodeCard.unpair`,`Unpair {{name}}`,{name:t.name}),message:a(`cluster.nodeCard.unpairItDisconnectsAndMust`,`Unpair {{name}}? It disconnects and must be paired again.`,{name:t.name}),confirmLabel:a(`cluster.nodeCard.unpair2`,`Unpair`),variant:`danger`})){p(!0),y(null);try{let e=await s.trpcClient.agentPairing.unpairAgent.mutate({nodeId:t.id});y({tone:e.agentNotified?`ok`:`warn`,text:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){y({tone:`warn`,text:a(`cluster.nodeCard.unpairFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{p(!1)}}},I=t.isHub?null:e(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void P(),disabled:f,title:a(`cluster.nodeCard.unpairThisNodeRevokesIts`,`Unpair this node — revokes its certificates; it must be paired again to rejoin`),children:[i(le,{className:`h-3 w-3`,"aria-hidden":!0}),f?a(`cluster.nodeCard.unpairing`,`Unpairing…`):a(`cluster.nodeCard.unpair2`,`Unpair`)]});return t.isOnline?e(`div`,{className:`border border-border rounded-xl`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[e(`div`,{className:`flex min-w-0 flex-1 basis-full items-center gap-x-2 gap-y-1 sm:basis-auto sm:flex-initial`,children:[i(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),i(Yt,{node:t}),e(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?a(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]})]}),t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,title:a(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:e},e)),e(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-1 text-xs text-muted-foreground w-full sm:ml-auto sm:w-auto`,children:[!t.isHub&&e(H,{variant:`unstyled`,type:`button`,onClick:()=>void M(),disabled:w,title:a(`cluster.nodeCard.openThisAgentSStatus`,`Open this agent's status dashboard (unlocks with a short-lived hub ticket)`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[i(te,{className:`h-3 w-3`}),w?a(`cluster.nodeCard.opening`,`Opening…`):a(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),I,e(`span`,{className:`flex items-center gap-1`,children:[i(j,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),e(`span`,{className:`flex items-center gap-1`,children:[i(ce,{className:`h-3 w-3`}),` `,t.memoryPercent===null?a(`cluster.memoryUnknown`):`${t.memoryPercent}%`]})]})]}),v!=null&&i(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${v.tone===`ok`?`text-success`:`text-warning`}`,children:v.text}),(E!==null||k!==null)&&e(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[E,k!==null&&e(l,{children:[` `,i(`a`,{href:k,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:a(`cluster.nodeCard.openDashboard`,`Open dashboard`)})]})]}),i(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>i(H,{variant:`unstyled`,onClick:()=>h(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${m===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?a(`cluster.nodeCard.general`,`General`):e===`forks`?a(`cluster.nodeCard.forks`,`Forks ({{length}})`,{length:b.length}):e===`processes`?a(`cluster.nodeCard.processes`,`Processes`):e===`load`?a(`cluster.nodeCard.load`,`Load`):e===`settings`?a(`cluster.nodeCard.settings`,`Settings`):a(`cluster.nodeCard.capabilities`,`Capabilities`)},e))}),e(`div`,{className:`px-4 py-2`,children:[m===`info`&&e(`div`,{className:`space-y-3`,children:[i(or,{nodeId:t.id,name:t.name,hostname:t.hostname,platform:t.platform,arch:t.arch,cpuModel:t.cpuModel,cpuCores:t.cpuCores,memoryMB:t.memoryMB,engines:t.engines,isHub:t.isHub,uptime:t.uptime,localIps:t.localIps,rootPackage:t.rootPackage}),i(ur,{nodeId:t.id,detectedHosts:t.localIps??[]}),i(`div`,{className:`border-t border-border pt-1`,children:i(Er,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})}),i(gr,{node:{id:t.id,isHub:t.isHub,isOnline:t.isOnline}})]}),m===`forks`&&i(en,{nodeId:t.id,processes:b}),m===`processes`&&i(an,{nodeId:t.id}),m===`load`&&i($n,{nodeId:t.id,isHub:t.isHub}),m===`settings`&&i(rr,{nodeId:t.id,addonIds:x}),m===`capabilities`&&i(ir,{nodeId:t.id,addons:t.addons})]})]}):e(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30`,children:[i(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive shrink-0`}),i(Yt,{node:t}),e(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?a(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]}),t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,title:a(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:e},e)),t.rootPackage&&e(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}),i(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:a(`common.offline`)})]}),e(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[e(`span`,{className:`text-xs text-muted-foreground`,children:[t.lastSeen?i(`span`,{className:`mr-1`,children:a(`cluster.nodeCard.lastSeen`,{when:new Date(t.lastSeen).toLocaleString()})}):null,a(`cluster.nodeCard.addonsAssigned`,{count:t.addons.length})]}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[I,e(H,{variant:`unstyled`,type:`button`,onClick:()=>void N(),disabled:g,title:a(`cluster.nodeCard.forgetThisNodeRemovesIts`,`Forget this node — removes its saved history and pipeline assignments`),className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[i(ee,{className:`h-3 w-3`}),g?a(`cluster.nodeCard.forgetting`,`Forgetting…`):a(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),v!=null&&i(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${v.tone===`ok`?`text-success`:`text-warning`}`,children:v.text})]})}s();function kr(){let{nodes:e,isLoading:t}=Ee(),r=n(()=>e??[],[e]);return{nodes:r,isLoading:t&&r.length===0}}function Ar(){let{t}=K(),{nodes:r,isLoading:s}=kr(),[c,u]=tt(),{selection:d,selectNode:f}=ft(r),m=d.node,h=n(()=>r.filter(e=>e.isOnline),[r]).length,g=r.filter(e=>!e.isOnline).length,_=F(),[v,y]=o(!1),b=c.get(`unlockNode`),x=c.get(`returnTo`),[S,C]=o(null);return a(()=>{if(b===null||x===null)return;let e=!1;return(async()=>{try{let t=await _.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:b,dashboardBaseUrl:x}});if(e)return;let n=X(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(x);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){C(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(c);i.delete(`unlockNode`),i.delete(`returnTo`),u(i,{replace:!0}),window.location.assign(r)}catch(t){e||C(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[b,x,c,u,_.trpcClient]),e(at,{icon:w,title:t(`nav.nodes`,`Nodes`),subtitle:t(`cluster.subtitle`,`One node at a time — topology and packages. Agents join by pairing (certificate, no shared secret).`),actions:e(l,{children:[h>0&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:t(`common.onlineCount`,{count:h})}),g>0&&i(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:t(`common.offlineCount`,{count:g})}),e(H,{type:`button`,size:`sm`,title:t(`clusterUpdate.updateAllHint`,`Preview the hub plan, then follow the same job the CLI uses.`),onClick:()=>y(!0),children:[i(p,{className:`h-3.5 w-3.5`}),t(`clusterUpdate.updateAll`,`Update all nodes`)]})]}),children:[i(dt,{open:v,onOpenChange:y}),S!==null&&e(`p`,{role:`alert`,className:`rounded border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:[t(`system.cluster.unlockFromAgentFailed`,`Unlock from agent failed:`),` `,S]}),i(It,{onOpenNode:f}),s?i(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:t(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):m===null?i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-foreground-subtle`,children:t(`cluster.noNodes`,`No nodes in this cluster yet.`)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(ut,{staleNodeId:d.staleNodeId,shownNodeName:m.name}),i(Pe,{selectedNodeId:m.id,onSelect:f,allowOffline:!0,alwaysShow:!0}),i(Or,{node:m})]}),i(zt,{})]})}export{Ar as ClusterPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,S as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{ya as n}from"./player-overlays-BKicBNcF.js";import{pa as r}from"./client-Dn4ym7AZ.js";import{lp as i,os as a}from"./src-CU6u_Uvz.js";import{t as o}from"./useTranslation-BJr-n0es.js";import{_i as s,bi as c,m as l,v as u,vi as d,xi as f}from"./index-FA3cRm59.js";import{t as p}from"./CompositionBlockEditor-BAgVN8yN.js";import{t as m}from"./AdminPage-C0rgqBg5.js";var h=`rounded-lg border border-border bg-surface p-4`,g=`new`;function _(){let{blockId:_}=f(),{t:v}=o(),y=c(),b=_===void 0||_===g,x=a({blockId:_??``},{enabled:!b}),S=e=>t(m,{icon:n,title:v(`compositionEditor.pageTitle`),children:e});if(b)return t(d,{to:`${l}&new=helper`,replace:!0});if(x.status===`success`&&x.data.state===`loaded`&&x.data.view!==null){let e=x.data.view;if(r(e.block)?.target.kind===`existing`){let n=e.state.kind===`answered`?e.state.state?.deviceId??null:null;if(n!==null)return S(t(`section`,{className:h,children:t(s,{className:`text-primary text-sm`,to:u(n),children:v(`compositionEditor.openOnDevice`)})}))}}return S(e(`section`,{className:`${h} flex flex-col gap-2`,children:[t(i,{variant:`ghost`,size:`sm`,onClick:()=>y(l),children:v(`compositionEditor.cancel`)}),t(p,{blockId:_??``})]}))}export{_ as CompositionEditorPage};
|