@camstack/addon-admin-ui 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddLocationWizard-DS7BizJv.js → AddLocationWizard-BUZLYS9B.js} +1 -1
- package/dist/assets/{AddonCollectionPage-D7lHEbwI.js → AddonCollectionPage-NfeoRVeH.js} +1 -1
- package/dist/assets/{Addons-D6z52udO.js → Addons-D3RKmRkc.js} +1 -1
- package/dist/assets/{AdminTabs-ZprmiCN3.js → AdminTabs-BeE7vFXY.js} +1 -1
- package/dist/assets/{AiProfiles-Z7ksIPFF.js → AiProfiles-RaGAP8Nc.js} +1 -1
- package/dist/assets/{BrokerForm-DbfBwy1x.js → BrokerForm-ChaPsPjJ.js} +1 -1
- package/dist/assets/{Capabilities-BeYEhvPF.js → Capabilities-BIXW_Ga9.js} +1 -1
- package/dist/assets/{CapabilityBadges-DXbYtBuK.js → CapabilityBadges-NaS_0tz_.js} +1 -1
- package/dist/assets/{Cluster-CC5_CGJA.js → Cluster-hVMK905J.js} +1 -1
- package/dist/assets/{ClusterRecordingTab-BSJTZsGS.js → ClusterRecordingTab-C7LKAooC.js} +1 -1
- package/dist/assets/{Dashboard-B44hFAIO.js → Dashboard-C0NPmEIi.js} +1 -1
- package/dist/assets/{Data-o2lHojn-.js → Data-BbM44EXq.js} +1 -1
- package/dist/assets/{DetectionIntelligence-CBn9zwCs.js → DetectionIntelligence-tnS0257Q.js} +1 -1
- package/dist/assets/{DeviceDetail-CiJPK_Hg.js → DeviceDetail-B59yD6vi.js} +1 -1
- package/dist/assets/{Devices-CuAPCnH8.js → Devices-BEaWNpfJ.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-C8Qwuzjd.js → EmbedPlayerPage-DNgZhMMs.js} +1 -1
- package/dist/assets/Events-DxtQPnv7.js +1 -0
- package/dist/assets/{FormBuilder-2eKUDBn_.js → FormBuilder-DyqMc0j5.js} +1 -1
- package/dist/assets/{Identity-BKqc54Et.js → Identity-CCdcJAoi.js} +1 -1
- package/dist/assets/{IntegrationDetail-BRX1Cgc7.js → IntegrationDetail-BcSErlZv.js} +1 -1
- package/dist/assets/{Integrations-CAdnay5c.js → Integrations-BAo0S-9M.js} +1 -1
- package/dist/assets/{Integrations-GzRXWJY0.js → Integrations-BJcO7MGt.js} +1 -1
- package/dist/assets/{Logs-DBBumaMc.js → Logs-BthwRvlo.js} +1 -1
- package/dist/assets/{MotionZonesSettings-rxIHdY6l.js → MotionZonesSettings-pcWaoAVF.js} +1 -1
- package/dist/assets/{MyAccess-BbPpIYRJ.js → MyAccess-D6-5Jebn.js} +1 -1
- package/dist/assets/{Network-C5ZntFKl.js → Network-DWMfVxk3.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-KR29Oo7P.js → NodeAddonsSettingsPanel-BDSIElAE.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-BowEeg99.js → NodeInferenceDevices-BgBC_-Cf.js} +1 -1
- package/dist/assets/{NotificationTargets-f-LdcumZ.js → NotificationTargets-TE6_iLcU.js} +1 -1
- package/dist/assets/Pipeline-hh2khsgO.js +1 -0
- package/dist/assets/{Plates-re0O5v8R.js → Plates-Da185yp9.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DB5GYkOu.js → PrivacyMaskSettings-CSsJbEdX.js} +1 -1
- package/dist/assets/{ProviderIcon-CYHRodqA.js → ProviderIcon-CyOY3SC_.js} +1 -1
- package/dist/assets/{Recordings-Cshnuw6r.js → Recordings-7iXCD5JG.js} +1 -1
- package/dist/assets/{ScanNetworkModal-DAkm1Fdk.js → ScanNetworkModal-zgudMIyq.js} +1 -1
- package/dist/assets/{Settings-KX75IP58.js → Settings-itFB5Gut.js} +1 -1
- package/dist/assets/{Showroom-Dztrxiso.js → Showroom-064ewzXv.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-G3thYr_7.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-VoROYd3V.js} +1 -1
- package/dist/assets/{build-cluster-graph-DUCV6DVF.js → build-cluster-graph-Dit34nK-.js} +1 -1
- package/dist/assets/circle-check-big-D11ThkmF.js +1 -0
- package/dist/assets/clock-Cw5ClbHv.js +1 -0
- package/dist/assets/{copy-C11dg8eq.js → copy-Dz32pMtz.js} +1 -1
- package/dist/assets/{debounced-invalidate-C_DB9sqL.js → debounced-invalidate-DwbIZ08l.js} +1 -1
- package/dist/assets/dist-CQeoCeJU.js +7 -0
- package/dist/assets/{dist-CYW0dAGQ.js → dist-QVC0BJnI.js} +1 -1
- package/dist/assets/{download-DshuRjOL.js → download-Bc8d-g48.js} +1 -1
- package/dist/assets/{face-bbox-D4Ljg5be.js → face-bbox-CubbsV2M.js} +1 -1
- package/dist/assets/{hostInit-DnViVaCH.js → hostInit-BpmWQVYV.js} +1 -1
- package/dist/assets/{index-PRd5ZDug.js → index-BCFljrfG.js} +3 -3
- package/dist/assets/index-C-ZEPJCU.css +2 -0
- package/dist/assets/{key-round-DQuSsH_p.js → key-round-5_oC6dcR.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-3b353fa3.js → mf-entry-bootstrap-0-dd174550.js} +2 -2
- package/dist/assets/{pencil-DoH-KTcO.js → pencil-BvNo3Yub.js} +1 -1
- package/dist/assets/{player-overlays-BfnV1C0Q.js → player-overlays-Djl5iftN.js} +1 -1
- package/dist/assets/plus-CiOwSyE3.js +1 -0
- package/dist/assets/{radio-nxBAF-O0.js → radio-D23Jj6A6.js} +1 -1
- package/dist/assets/{refresh-cw-Bh7jR0Ir.js → refresh-cw-Cvia6aKe.js} +1 -1
- package/dist/assets/remoteEntry-C42iyWi2.js +1 -0
- package/dist/assets/{rotate-ccw-RKms_9rY.js → rotate-ccw-SbtRX_0U.js} +1 -1
- package/dist/assets/rotate-cw-BPP25HnF.js +1 -0
- package/dist/assets/search-zeT3R6EQ.js +1 -0
- package/dist/assets/{send-h8PoRj0P.js → send-FPJ3Liuf.js} +1 -1
- package/dist/assets/{server-D6u4qxlr.js → server-CkHtY3VL.js} +1 -1
- package/dist/assets/square-DrCaLNjr.js +1 -0
- package/dist/assets/{square-check-big-COxvcZ2K.js → square-check-big-BHwbUmpR.js} +1 -1
- package/dist/assets/{src-DKAxBIDH.js → src-41Op1K3V.js} +5 -5
- package/dist/assets/src-DzsfEeqU.js +7 -0
- package/dist/assets/{upload-cX_3Ogx3.js → upload-CjgkY_m4.js} +1 -1
- package/dist/assets/{useEventInvalidation-DMfSVBY-.js → useEventInvalidation-Ol-S4lud.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BBpdMDOB.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Cc6uQWF9.js} +2 -2
- package/dist/assets/{wifi-Bk03mxTw.js → wifi-dfru7VMS.js} +1 -1
- package/dist/assets/{zap-B7VEvais.js → zap-BUeyVPwp.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +87 -10
- package/package.json +1 -1
- package/dist/assets/Events-De1MNcJg.js +0 -1
- package/dist/assets/Pipeline-BUL-ABEL.js +0 -1
- package/dist/assets/circle-check-big-Ctn01sEf.js +0 -1
- package/dist/assets/clock-CdqW_Msl.js +0 -1
- package/dist/assets/dist-D7nNU2QV.js +0 -7
- package/dist/assets/index-BKBKdGDb.css +0 -2
- package/dist/assets/plus-CIHjZPFg.js +0 -1
- package/dist/assets/remoteEntry-Bk3nWhnN.js +0 -1
- package/dist/assets/rotate-cw-64smQO88.js +0 -1
- package/dist/assets/search-C0Kh9F13.js +0 -1
- package/dist/assets/square-BtiVHmLU.js +0 -1
- package/dist/assets/src-CCZM6rtM.js +0 -7
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e,Gr as t,Jr as n,Na as r,Wa as i,Wr as a,Zr as o,bo as s,do as c,jn as l,jr as u,q as d,qr as f,uo as p,xt as m,z as h}from"./src-DKAxBIDH.js";import{I as g,K as _,Q as v,S as y,W as b,b as x,i as S,o as C,q as w,x as T,z as E}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{E as D,K as O,P as k,s as A}from"./src-CCZM6rtM.js";import{p as j}from"./player-overlays-BfnV1C0Q.js";import{t as M}from"./clock-CdqW_Msl.js";import{t as N}from"./copy-C11dg8eq.js";import{a as ee,c as te,d as P,f as F,i as ne,m as I,n as re,o as ie,p as L,r as ae,s as R,t as z}from"./debounced-invalidate-C_DB9sqL.js";import{t as B}from"./search-C0Kh9F13.js";import{t as V}from"./square-check-big-COxvcZ2K.js";import{t as oe}from"./square-BtiVHmLU.js";import{E as se,I as H,L as U,P as ce,S as W,U as G,W as K,i as le,s as ue,t as de}from"./index-PRd5ZDug.js";import{t as fe}from"./AdminPage-BwmGKnRf.js";import{r as pe,t as q}from"./authed-media-XfBD4Ma-.js";var me=K(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),he=K(`square-parking`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 17V7h4a3 3 0 0 1 0 6H9`,key:`1dfk2c`}]]),ge=K(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]);v();var _e=720*60*60*1e3;function ve(e){let t=[];for(let n of e)t.push(...n);return t}function ye(e,t){let n=[...e];return n.sort((e,n)=>t===`importance`?n.importance-e.importance:n.timestamp-e.timestamp),n}function be(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 J(e,t){return`${String(e)}:${t}`}function xe(e,t){let n=new Map,r=new Set;for(let i of e){let e=J(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 Se(e,t){return{since:e.fromMs??t-_e,until:e.toMs??t}}var Y=typeof a==`function`,Ce=`Track deletion arrives with the next server update`;function we(){return{mutateAsync:async()=>{throw Error(`deleteTracks unavailable`)},isPending:!1}}var Te=Y?a:we,Ee=200,De=3e4;function Oe(e){let t=j(),n=S({queries:e.deviceIds.map(n=>({queryKey:[`events-feed`,n,e.since,e.until,e.minImportance??null,e.classFilter??null],staleTime:De,refetchInterval:De,queryFn:async()=>(await t.trpcClient.pipelineAnalytics.getKeyEvents.query({deviceId:n,since:e.since,until:e.until,limit:Ee,...e.minImportance===void 0?{}:{minImportance:e.minImportance},...e.classFilter===void 0?{}:{classFilter:e.classFilter}})).map(e=>({...e,deviceId:n}))}))});return{rows:ye(ve(n.map(e=>e.data??[])),`importance`),isLoading:n.some(e=>e.isLoading)}}var ke=[`events-feed`],Ae=2e3;function je(){let e=C(),t=_(e);t.current=e;let n=_(void 0);n.current||=z({delayMs:Ae,invalidate:()=>{t.current.invalidateQueries({queryKey:ke})}}),E(()=>()=>n.current?.cancel(),[]),i(O.PipelineAnalyticsDetectionEvent,()=>{n.current?.trigger()}),i(O.PipelineAnalyticsTrackEnded,()=>{n.current?.trigger()})}v();function Me(){return Object.values(k).filter(e=>e.level===`macro`).map(e=>({macro:e,subs:Object.values(k).filter(t=>t.parentKind===e.kind).sort((e,t)=>e.label.localeCompare(t.label))})).sort((e,t)=>e.macro.label.localeCompare(t.macro.label))}function Ne({selected:t,onChange:n}){let{t:r}=de(),[i,a]=w(!1),[o,s]=w(``),[c,l]=w(new Set),u=b(Me,[]),d=o.trim().toLowerCase(),f=e=>d.length===0||h(e,r).toLowerCase().includes(d),p=b(()=>u.map(e=>({macro:e.macro,subs:e.subs.filter(t=>f(t)||f(e.macro))})).filter(e=>f(e.macro)||e.subs.length>0),[u,d]),m=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),g=e=>{let r=new Set(t),i=t.has(e.macro.kind)&&e.subs.every(e=>t.has(e.kind)),a=[e.macro.kind,...e.subs.map(e=>e.kind)];if(i)for(let e of a)r.delete(e);else for(let e of a)r.add(e);n(r)},_=e=>{let r=new Set(t);r.has(e)?r.delete(e):r.add(e),n(r)},v=()=>n(new Set),x=t.size;return y(`div`,{className:`relative`,children:[y(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${x>0?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[T(ge,{className:`h-3.5 w-3.5`}),x>0?`Kinds (${String(x)})`:`Kinds`,T(H,{className:`h-3 w-3`})]}),i&&y(`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:[y(`div`,{className:`mb-2 flex items-center gap-1 rounded border border-border px-1.5`,children:[T(B,{className:`h-3.5 w-3.5 text-foreground-subtle`}),T(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`Search kinds…`,className:`w-full bg-transparent py-1 text-xs outline-none`}),x>0&&T(`button`,{type:`button`,onClick:v,className:`text-[10px] text-foreground-subtle hover:text-foreground`,children:`Clear`})]}),p.map(n=>{let i=e(n.macro.iconId),a=c.has(n.macro.kind)||d.length>0,o=t.has(n.macro.kind);return y(`div`,{className:`mb-0.5`,children:[y(`div`,{className:`flex items-center gap-1`,children:[n.subs.length>0?T(`button`,{type:`button`,onClick:()=>m(n.macro.kind),className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Expand`,children:T(a?H:ce,{className:`h-3 w-3`})}):T(`span`,{className:`w-3`}),y(`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:[T(`input`,{type:`checkbox`,checked:o,onChange:()=>g(n),className:`accent-primary`}),T(i,{className:`h-3.5 w-3.5`,style:{color:n.macro.color}}),T(`span`,{className:`font-medium`,children:h(n.macro,r)})]})]}),a&&n.subs.map(n=>{let i=e(n.iconId);return y(`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:[T(`input`,{type:`checkbox`,checked:t.has(n.kind),onChange:()=>_(n.kind),className:`accent-primary`}),T(i,{className:`h-3.5 w-3.5`,style:{color:n.color}}),T(`span`,{children:h(n,r)})]},n.kind)})]},n.macro.kind)})]})]})}var X=100,Pe=120,Fe={polyline:``,points:[],snapshots:[],start:null,end:null,peakBox:null},Z=e=>e<0?0:e>1?1:e,Q=e=>Math.round(e*100)/100;function Ie(e,t){if(e.length<=t)return[...e];let n=(e.length-1)/(t-1),r=[];for(let i=0;i<t;i++)r.push(e[Math.round(i*n)]);return r[r.length-1]=e[e.length-1],r}function Le(e,t,n){if(e.length===0||t===null)return Fe;let{width:r,height:i}=t;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return Fe;let a=Ie(e,n?.maxPoints??Pe).map(e=>({x:Q(Z(e.x/r)*X),y:Q(Z(e.y/i)*X)})),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:Q(Z(e.x/r)*X),y:Q(Z(e.y/i)*X),mediaKey:e.mediaKey})),u=null,d=-1;for(let t of e){let e=Z(t.bbox.w/r)*Z(t.bbox.h/i);e>d&&(d=e,u=t)}return{polyline:c,points:a,snapshots:l,start:o,end:s,peakBox:u?{x:Q(Z(u.bbox.x/r)*X),y:Q(Z(u.bbox.y/i)*X),w:Q(Z(u.bbox.w/r)*X),h:Q(Z(u.bbox.h/i)*X)}:null}}var Re={firstFrame:`First frame (track start)`,lastFrame:`Last frame (track end)`,thumbnail:`Best detection`,snapshot:`Snapshot`,keyFrame:`Key frame (native-res)`,crop:`Object crop`,fullFrame:`Full frame`,fullFrameBoxed:`Full frame (boxed)`,faceCrop:`Face crop`,plateCrop:`Plate crop`};function ze(e){return e in Re}function Be(e){return ze(e)?Re[e]:e}function Ve(e,t){return`${e}${q}/${encodeURIComponent(t)}`}v();var He=1400,Ue=`Admin-gated URL — opens only inside an authenticated session`;function We({label:e,value:t,title:n}){let[r,i]=w(!1);return E(()=>{if(!r)return;let e=setTimeout(()=>i(!1),He);return()=>clearTimeout(e)},[r]),y(`button`,{type:`button`,onClick:g(()=>{(async()=>{try{await navigator.clipboard.writeText(t),i(!0)}catch{window.prompt(`Copy the media URL:`,t)}})()},[t]),title:n,"aria-label":`Copy ${e} URL`,className:`flex min-w-0 items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${r?`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`border-border text-foreground-subtle hover:border-primary hover:text-foreground`}`,children:[T(r?U:N,{className:`h-2.5 w-2.5 shrink-0`}),T(`span`,{className:`truncate`,children:r?`Copied`:e})]})}function Ge({localUrl:e,publicUrl:t}){return y(`div`,{className:`flex flex-wrap gap-1`,children:[T(We,{label:`Local`,value:e,title:`Copy LAN URL — ${Ue}`}),t&&T(We,{label:`Public`,value:t,title:`Copy public URL — ${Ue}`})]})}v();var Ke=3e4;function qe(e){let[t,n]=w(null),r=g(e=>{n(t=>t??e)},[]);return E(()=>{e||n(null)},[e]),{publicOrigin:t,probes:e?T(Je,{onOrigin:r}):null}}function Je({onOrigin:e}){let{data:t}=m({capName:`network-access`});return T(x,{children:(t??[]).map(t=>T(Ye,{addonId:t.addonId,onOrigin:e},t.addonId))})}function Ye({addonId:e,onOrigin:t}){let{data:n}=u({addonId:e},{refetchInterval:Ke,retry:!1});return E(()=>{let e=n?A.safeParse(n):null,r=e?.success?e.data.endpoint?.url:void 0;if(r)try{t(new URL(r).origin)}catch{}},[n,t]),null}v();var Xe=15e3,Ze=window.location.origin,Qe=new Set([`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`]),$e=new Set([`keyFrame`,`fullFrame`,`fullFrameBoxed`,`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`]);function et(e){let[t,n]=w(null);return E(()=>{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 tt({overlay:e,onPickSnapshot:t}){return!e.polyline&&!e.peakBox&&e.snapshots.length===0?null:y(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`pointer-events-none absolute inset-0 h-full w-full`,children:[e.peakBox&&T(`rect`,{x:e.peakBox.x,y:e.peakBox.y,width:e.peakBox.w,height:e.peakBox.h,fill:`none`,stroke:`#f59e0b`,strokeWidth:2,vectorEffect:`non-scaling-stroke`,rx:1}),e.polyline&&T(`polyline`,{points:e.polyline,fill:`none`,stroke:`#38bdf8`,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,strokeOpacity:.85,vectorEffect:`non-scaling-stroke`}),e.points.map((e,t)=>T(`circle`,{cx:e.x,cy:e.y,r:1,fill:`#38bdf8`,fillOpacity:.6,vectorEffect:`non-scaling-stroke`},`${String(e.x)}-${String(e.y)}-${String(t)}`)),e.snapshots.map((e,n)=>T(`circle`,{cx:e.x,cy:e.y,r:1.9,fill:`#0ea5e9`,fillOpacity:.95,stroke:`#082f49`,strokeWidth:.7,vectorEffect:`non-scaling-stroke`,className:t?`pointer-events-auto cursor-pointer`:void 0,onClick:t?n=>{n.stopPropagation(),t(e.mediaKey)}:void 0,children:T(`title`,{children:`Snapshot checkpoint — click to view this frame`})},`snap-${e.mediaKey}-${String(n)}`)),e.start&&T(`circle`,{cx:e.start.x,cy:e.start.y,r:2.4,fill:`#22c55e`,stroke:`#052e16`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`}),e.end&&T(`circle`,{cx:e.end.x,cy:e.end.y,r:2.4,fill:`#ef4444`,stroke:`#450a0a`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`})]})}function $({label:e,value:t,mono:n}){return y(`div`,{className:`flex items-baseline justify-between gap-3 border-b border-border/60 py-1.5 last:border-0`,children:[T(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),T(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground ${n?`font-mono text-[11px]`:``}`,title:t,children:t})]})}function nt({row:e,cameraName:i,deleteAvailable:a,onClose:o,onDeleted:l}){let u=j(),d=Te(),m=e!==null,h=e?.deviceId??0,_=e?.trackId??``,v=e?.bestEventId??``,S=e?.timestamp??0,C=e?.windowMs??0,{data:D}=f({deviceId:h,trackId:_},{enabled:m}),{data:O}=n({trackId:_},{enabled:m}),{data:k}=t({eventId:v},{enabled:m&&v!==``}),{data:A}=r({deviceId:h,since:S-Xe,until:S+C+Xe},{enabled:m}),[M,N]=w(null),[ee,te]=w(!1),{publicOrigin:F,probes:re}=qe(m);E(()=>{N(null)},[h,_]);let ie=b(()=>{let e=O??[],t=k??[];return e.find(e=>e.kind===`keyFrame`)||t.find(e=>e.kind===`fullFrameBoxed`)||([...t,...e].find(e=>e.kind===`crop`)??null)},[O,k]),ae=pe(ie?`${q}/${encodeURIComponent(ie.key)}`:void 0),R=b(()=>{let e=new Set,t=[];for(let n of[...k??[],...O??[]])!n.base64||e.has(n.key)||(e.add(n.key),t.push(n));return t},[k,O]),z=b(()=>R.find(e=>Qe.has(e.kind))??null,[R]),B=et(z?`data:image/jpeg;base64,${z.base64}`:null),V=b(()=>Le(D?.positions??[],B,{snapshots:(D?.snapshots??[]).map(e=>({x:e.position.x,y:e.position.y,mediaKey:e.mediaKey}))}),[D?.positions,D?.snapshots,B]),oe=g(e=>{let t=R.find(t=>t.key===e);t&&N(t)},[R]);if(e===null)return null;let H=M?`data:image/jpeg;base64,${M.base64}`:ae.src,U=M?.kind??ie?.kind,ce=U!==void 0&&$e.has(U)&&B!==null&&(D?.positions.length??0)>=2,G=A&&A.length>0?A[0]:null,K=()=>{G&&(te(!0),(async()=>{try{let t=await u.trpcClient.videoclips.getClipPlayback.query({deviceId:e.deviceId,clipId:G.id});window.open(t.playbackUrl,`_blank`,`noopener`)}catch{window.alert(`Could not resolve clip playback. Check the server logs.`)}finally{te(!1)}})())},de=()=>{!a||d.isPending||window.confirm(`Delete this track and all its media? This cannot be undone.`)&&(async()=>{try{await d.mutateAsync({deviceId:e.deviceId,trackIds:[e.trackId]}),l()}catch{window.alert(`Failed to delete this track. Check the server logs.`)}})()},fe=Math.round(e.importance*100),me=D?.importanceReason?`${String(fe)}% · ${D.importanceReason}`:`${String(fe)}%`,he=D?.zonesVisited&&D.zonesVisited.length>0?D.zonesVisited.join(`, `):`—`,ge=D?.audioLabels&&D.audioLabels.length>0?D.audioLabels.map(e=>`${e.label} ×${String(e.count)} (${String(Math.round(e.peakScore*100))}%)`).join(` · `):`—`,_e=D?D.totalDistance.toFixed(2):`—`,ve=L(D?D.firstSeen:S),ye=D?L(D.lastSeen):`—`;return T(p,{open:!0,onOpenChange:e=>!e&&o(),children:y(c,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`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:[y(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[y(`div`,{className:`min-w-0`,children:[y(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:[e.className,e.label?y(`span`,{className:`text-foreground-subtle`,children:[` · `,e.label]}):null]}),T(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:i})]}),T(`button`,{type:`button`,onClick:o,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:T(le,{className:`h-4 w-4`})})]}),y(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[H?T(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:T(ne,{src:H,alt:`Key frame from ${i}`,fit:`natural`,className:`w-full`,overlay:ce?T(tt,{overlay:V,onPickSnapshot:oe}):void 0})}):T(`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:ae.failed?y(x,{children:[T(I,{className:`h-8 w-8 opacity-60`}),T(`span`,{className:`text-[11px]`,children:`Key-frame media unavailable`})]}):T(W,{className:`h-6 w-6 animate-spin opacity-70`})}),R.length>0&&T(`div`,{className:`-mx-1 flex gap-2 overflow-x-auto px-1 pb-1`,children:R.map(e=>{let t=`data:image/jpeg;base64,${e.base64}`,n=Be(e.kind),r=Ve(Ze,e.key),i=F?Ve(F,e.key):null;return y(`figure`,{className:`flex w-32 shrink-0 flex-col gap-1`,children:[T(`button`,{type:`button`,onClick:()=>N(e),className:`relative h-16 w-full overflow-hidden rounded border border-border hover:border-primary`,title:`${n} · ${L(e.timestamp)}`,children:T(`img`,{src:t,alt:n,className:`h-full w-full object-cover`})}),y(`figcaption`,{className:`min-w-0 px-0.5`,children:[T(`div`,{className:`truncate text-[10px] font-medium leading-tight text-foreground`,title:n,children:n}),T(`div`,{className:`text-[10px] leading-tight text-foreground-subtle`,title:L(e.timestamp),children:P(e.timestamp)})]}),T(Ge,{localUrl:r,publicUrl:i})]},e.key)})}),re,G&&y(s,{variant:`secondary`,onClick:K,disabled:ee,children:[ee?T(W,{className:`h-3.5 w-3.5 animate-spin`}):T(se,{className:`h-3.5 w-3.5`}),` `,`View clip`]}),y(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[T($,{label:`Camera`,value:i}),T($,{label:`Class`,value:e.className}),T($,{label:`Label`,value:e.label??`—`}),T($,{label:`Importance`,value:me}),T($,{label:`Zones visited`,value:he}),T($,{label:`Audio heard`,value:ge}),T($,{label:`Total distance`,value:_e}),T($,{label:`First seen`,value:ve}),T($,{label:`Last seen`,value:ye}),T($,{label:`Track`,value:e.trackId,mono:!0})]})]}),T(`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:T(`span`,{title:a?void 0:Ce,children:y(s,{variant:`secondary`,onClick:de,disabled:!a||d.isPending,children:[d.isPending?T(W,{className:`h-3.5 w-3.5 animate-spin`}):T(ue,{className:`h-3.5 w-3.5`}),` `,`Delete track`]})})})]})})}function rt(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 it({row:e,cameraName:t,nowMs:n,onOpenDetail:r,selected:i=!1,onToggleSelect:a,score:o}){let s=pe(e.bestEventId?`${q}/${e.bestEventId}`:void 0),c=Math.round(e.importance*100),l=o===void 0?void 0:Math.round(o*100),u=rt(e.windowMs),d=()=>r(e);return y(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${i?`border-primary ring-1 ring-primary`:`border-border`}`,children:[y(`div`,{className:`aspect-video relative overflow-hidden bg-surface-hover`,children:[s.src?T(`img`,{src:s.src,alt:`Event from ${t}`,onClick:d,className:`h-full w-full cursor-zoom-in object-cover`}):T(`button`,{type:`button`,onClick:d,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-surface-hover text-foreground-subtle`,title:s.failed?`Key-event media unavailable`:`No key-event media`,children:T(I,{className:`h-6 w-6 opacity-60`})}),a&&T(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(J(e.deviceId,e.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":i?`Deselect`:`Select`,children:i?T(V,{className:`h-4 w-4 text-primary`}):T(oe,{className:`h-4 w-4`})}),l!==void 0&&y(`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:`CLIP semantic-match score`,children:[String(l),`%`]}),c>0&&T(`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(c)})]}),y(`button`,{type:`button`,onClick:d,className:`min-w-0 px-2 py-1.5 text-left space-y-0.5`,children:[y(`p`,{className:`text-[11px] font-medium text-foreground truncate`,title:e.className,children:[e.className,e.label?y(`span`,{className:`text-foreground-subtle`,children:[` · `,e.label]}):null]}),T(`p`,{className:`text-[10px] text-foreground-subtle truncate`,title:t,children:t}),y(`div`,{className:`flex items-center justify-between gap-2`,children:[T(`span`,{className:`text-[10px] text-foreground-subtle truncate`,children:F(e.timestamp,n)}),u&&T(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:u})]})]})]})}v();var at=[`events-feed`],ot=60,st=[{value:`importance`,label:`Importance`,icon:me},{value:`time`,label:`Recent`,icon:M}];function ct(){let e=C(),[t,n]=w(R),[r,i]=w(new Set),[a,o]=w(new Set),[c,u]=w(0),[d,f]=w(`time`),[p,m]=w(new Set),[h,g]=w(null),[_,v]=w(()=>Date.now());E(()=>{let e=setInterval(()=>v(Date.now()),6e4);return()=>clearInterval(e)},[]);let{since:S,until:O}=b(()=>Se({fromMs:t.fromMs,toMs:t.toMs},_),[t.fromMs,t.toMs,_]);je();let{data:k}=l({}),A=b(()=>(k??[]).filter(e=>e.type===D.Camera),[k]),j=b(()=>A.map(e=>e.id),[A]),M=Te(),N=M.isPending,{rows:P,isLoading:F}=Oe({deviceIds:j,since:S,until:O,minImportance:c>0?c:void 0,classFilter:a.size===1?[...a][0]:void 0}),ne=b(()=>{let e=new Map;for(let t of A??[])e.set(t.id,t.name);return e},[A]),I=e=>ne.get(e)??`Camera #${String(e)}`,L=b(()=>te(P).map(e=>({id:e,name:I(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[P,ne]),z=b(()=>ye(be(P,{cameras:r,classes:a,minImportance:c}),d),[P,r,a,c,d]),B=re(z,ot,b(()=>JSON.stringify([[...r].sort((e,t)=>e-t),[...a].sort(),c,d,S,O]),[r,a,c,d,S,O])),V=()=>{e.invalidateQueries({queryKey:at})},oe=()=>m(new Set);function se(e){m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function H(){if(p.size===0||!Y)return;let e=xe(P,p),t=[...e.values()].reduce((e,t)=>e+t.length,0);if(t===0||!window.confirm(`Delete ${String(t)} track${t===1?``:`s`} and all their media? This cannot be undone.`))return;let n=[...e];Promise.allSettled(n.map(([e,t])=>M.mutateAsync({deviceId:e,trackIds:t}))).then(e=>{V();let t=[],r=new Set;if(e.forEach((e,i)=>{let a=n[i];if(!a)return;let[o,s]=a;if(e.status===`fulfilled`)for(let e of s)r.add(J(o,e));else t.push(o)}),m(e=>{let t=new Set(e);for(let e of r)t.delete(e);return t}),t.length>0){let e=t.map(e=>I(e)).join(`, `);window.alert(`Failed to delete tracks on: ${e}. They remain selected — retry, or check the server logs.`)}})}let U=z.length!==P.length;return y(`div`,{className:`relative space-y-3`,children:[y(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[T(ee,{onChange:n}),T(ie,{cameras:L,selected:r,onChange:i}),T(Ne,{selected:a,onChange:o}),y(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[T(`span`,{children:`Min score`}),T(`input`,{type:`range`,min:0,max:1,step:.05,value:c,onChange:e=>u(Number(e.target.value)),className:`h-1 w-24 cursor-pointer accent-primary`,"aria-label":`Minimum importance`}),T(`span`,{className:`w-6 tabular-nums text-foreground`,children:Math.round(c*100)})]}),T(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:st.map(e=>{let t=e.icon;return y(`button`,{type:`button`,onClick:()=>f(e.value),className:`flex items-center gap-1 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`}`,children:[T(t,{className:`h-3.5 w-3.5`}),` `,e.label]},e.value)})}),!F&&T(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:U?`${String(z.length)} of ${String(P.length)} events`:`${String(z.length)} event${z.length===1?``:`s`}`})]}),p.size>0&&y(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[y(`span`,{className:`text-xs font-medium text-foreground`,children:[p.size,` selected`]}),y(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[T(`span`,{title:Y?void 0:`Track deletion arrives with the next server update`,children:y(s,{variant:`secondary`,onClick:H,disabled:!Y||N,children:[N?T(W,{className:`h-3.5 w-3.5 animate-spin`}):T(ue,{className:`h-3.5 w-3.5`}),` `,`Delete`]})}),T(s,{variant:`ghost`,onClick:oe,disabled:N,children:T(le,{className:`h-3.5 w-3.5`})})]})]}),F&&y(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[T(W,{className:`h-4 w-4 animate-spin`}),` Loading events…`]}),!F&&z.length===0&&T(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:`No key events in this window.`}),!F&&z.length>0&&y(x,{children:[T(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(11rem,1fr))] gap-2`,children:B.pageItems.map(e=>T(it,{row:e,cameraName:I(e.deviceId),nowMs:_,selected:p.has(J(e.deviceId,e.trackId)),onToggleSelect:se,onOpenDetail:g},J(e.deviceId,e.trackId)))}),T(ae,{currentPage:B.page,totalItems:B.totalItems,pageSize:B.pageSize,onPageChange:B.setPage,itemNoun:`events`})]}),h&&T(nt,{row:h,cameraName:I(h.deviceId),deleteAvailable:Y,onClose:()=>g(null),onDeleted:()=>{V(),g(null)}})]})}v();var lt=50,ut=350,dt=[`person`,`vehicle`,`animal`],ft=[{value:.2,label:`Loose`},{value:.25,label:`Balanced`},{value:.3,label:`Strict`}];function pt(e){return{id:e.id,trackId:e.trackId??e.id,deviceId:e.deviceId,timestamp:e.timestamp,className:e.className,label:e.label,importance:e.importance??0,bestEventId:e.mediaKey??e.trackId??e.id,windowMs:void 0}}function mt({onActiveChange:e}){let[t,n]=w(``),[r,i]=w(.2),[a,s]=w(null),[c,u]=w(null),[f,p]=w(null),m=d(t,ut).trim(),h=m.length>0;E(()=>{e(h)},[h,e]);let[g,_]=w(()=>Date.now());E(()=>{let e=setInterval(()=>_(Date.now()),6e4);return()=>clearInterval(e)},[]);let{data:v}=l({}),x=b(()=>(v??[]).filter(e=>e.type===D.Camera),[v]),S=b(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),C=e=>S.get(e)??`Camera #${String(e)}`,{data:O,isFetching:k,isError:A,error:j}=o({text:m,minScore:r,limit:lt,classFilter:a??void 0,deviceId:c??void 0},{enabled:h}),M=b(()=>[...O??[]].sort((e,t)=>t.score-e.score).map(e=>({...pt(e),score:e.score})),[O]);function N(e){s(t=>t===e?null:e)}return y(`div`,{className:`space-y-3`,children:[y(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-3`,children:[y(`div`,{className:`flex flex-wrap items-center gap-2`,children:[y(`div`,{className:`relative min-w-[16rem] flex-1`,children:[T(B,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-foreground-subtle`}),T(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`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":`Semantic event search`}),t&&T(`button`,{type:`button`,onClick:()=>n(``),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":`Clear search`,children:T(le,{className:`h-3.5 w-3.5`})})]}),k&&h&&T(W,{className:`h-4 w-4 shrink-0 animate-spin text-foreground-subtle`})]}),y(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[T(`div`,{className:`flex items-center gap-1`,children:dt.map(e=>T(`button`,{type:`button`,onClick:()=>N(e),className:`rounded-md px-2.5 py-1 text-xs capitalize transition-colors ${a===e?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e},e))}),y(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[T(`span`,{children:`Camera`}),y(`select`,{value:c===null?``:String(c),onChange:e=>u(e.target.value===``?null:Number(e.target.value)),className:`h-7 rounded-md border border-border bg-background px-1.5 text-xs text-foreground focus:border-primary focus:outline-none`,"aria-label":`Filter by camera`,children:[T(`option`,{value:``,children:`All`}),x.map(e=>T(`option`,{value:String(e.id),children:e.name},e.id))]})]}),y(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[T(`span`,{children:`Match`}),T(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:ft.map(e=>T(`button`,{type:`button`,onClick:()=>i(e.value),className:`rounded px-2 py-1 text-[11px] transition-colors ${r===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,title:`Minimum CLIP score ${e.value.toFixed(2)}`,children:e.label},e.value))})]}),h&&!k&&!A&&y(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:[M.length,` match`,M.length===1?``:`es`]})]})]}),h&&y(`div`,{className:`space-y-3`,children:[A&&y(`p`,{className:`py-4 text-xs text-danger`,children:[`Search failed: `,j instanceof Error?j.message:`unknown error`,`. Check that the CLIP embedding step is enabled.`]}),!A&&k&&M.length===0&&y(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[T(W,{className:`h-4 w-4 animate-spin`}),` Searching…`]}),!A&&!k&&M.length===0&&y(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:[`No semantic matches for “`,m,`”. Try a looser match threshold or a different phrasing.`]}),!A&&M.length>0&&T(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(11rem,1fr))] gap-2`,children:M.map(e=>T(it,{row:e,cameraName:C(e.deviceId),nowMs:g,score:e.score,onOpenDetail:p},e.id))})]}),f&&T(nt,{row:f,cameraName:C(f.deviceId),deleteAvailable:Y,onClose:()=>p(null),onDeleted:()=>p(null)})]})}var ht=15e3;function gt(e){let t=j(),n=S({queries:e.map(e=>({queryKey:[`stationary-objects`,e],staleTime:ht,refetchInterval:ht,queryFn:async()=>((await t.trpcClient.zoneAnalytics.getCurrentSnapshot.query({deviceId:e}))?.stationaryObjects??[]).map(t=>({...t,deviceId:e}))}))});return{rows:n.flatMap(e=>e.data??[]).toSorted((e,t)=>t.becameStationaryAt-e.becameStationaryAt),isLoading:n.some(e=>e.isLoading)}}v();function _t(e,t){let n=Math.max(0,Math.round((e-t)/6e4));if(n<1)return`just now`;if(n<60)return`${String(n)}m`;let r=Math.floor(n/60);return`${String(r)}h ${String(n%60)}m`}function vt({row:e,cameraName:t,nowMs:n}){let r=e.keyFrameMediaKey?.startsWith(`track:`)?e.keyFrameMediaKey.split(`:`)[1]:e.keyFrameMediaKey,i=pe(r?`${q}/${r}`:void 0);return y(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-border bg-surface`,children:[y(`div`,{className:`relative aspect-video overflow-hidden bg-surface-hover`,children:[i.src?T(`img`,{src:i.src,alt:`Parked ${e.className} on ${t}`,className:`h-full w-full object-cover`}):T(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:T(he,{className:`h-6 w-6`})}),T(`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:e.label??e.className})]}),y(`div`,{className:`flex flex-col gap-0.5 p-1.5`,children:[T(`span`,{className:`truncate text-[11px] text-foreground`,children:t}),y(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`parked `,_t(n,e.becameStationaryAt)]})]})]})}function yt(){let[e,t]=w(!1),n=Date.now(),{data:r}=l({}),i=b(()=>(r??[]).filter(e=>e.type===D.Camera),[r]),a=b(()=>i.map(e=>e.id),[i]),o=b(()=>{let e=new Map;for(let t of i)e.set(t.id,t.name);return e},[i]),{rows:s}=gt(a);return s.length===0?null:y(`div`,{className:`rounded-md border border-border bg-surface/40`,children:[y(`button`,{type:`button`,onClick:()=>t(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[T(e?H:ce,{className:`h-4 w-4 text-foreground-subtle`}),T(he,{className:`h-4 w-4 text-foreground-subtle`}),T(`span`,{className:`text-sm font-semibold text-foreground`,children:`Stationary`}),T(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s.length}),T(`span`,{className:`ml-2 text-[11px] text-foreground-subtle`,children:`Parked objects — kept out of the event feed`})]}),e&&T(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))] gap-2 p-3 pt-0`,children:s.map(e=>T(vt,{row:e,cameraName:o.get(e.deviceId)??`Camera #${String(e.deviceId)}`,nowMs:n},e.id))})]})}v();function bt(){je();let[e,t]=w(!1);return T(fe,{icon:G,title:`Events`,subtitle:`Every captured key event across all cameras — trajectory, media, and clips.`,children:y(`section`,{className:`space-y-3`,children:[T(mt,{onActiveChange:t}),!e&&T(yt,{}),!e&&T(ct,{})]})})}export{bt as EventsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$r as e,Ci as t,Ei as n,Eo as r,Ha as i,Ii as a,Ka as o,La as s,Mi as c,Ni as l,Pi as u,Qr as d,Si as f,T as p,Ti as m,To as h,Ua as g,Va as _,Vr as v,Wa as y,Xa as b,Ya as x,_ as S,_i as C,ai as w,bi as T,ci as E,di as D,ei as O,ft as k,g as A,gi as j,ii as M,ji as N,li as ee,lt as te,mi as P,ni as ne,oi as re,qa as ie,ri as ae,si as oe,ti as se,ut as ce,vi as le,wi as ue,xi as de,yi as fe,yo as F}from"./src-DKAxBIDH.js";import{I as pe,K as me,Q as I,S as L,T as he,W as R,b as z,o as B,q as V,x as H,z as U}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{G as ge,K as _e,X as ve}from"./src-CCZM6rtM.js";import{c as ye,n as be,o as xe,r as Se,s as Ce,t as we}from"./NodeInferenceDevices-BowEeg99.js";import{t as Te}from"./download-DshuRjOL.js";import{i as Ee}from"./AddLocationWizard-DS7BizJv.js";import{n as De,r as Oe,t as ke}from"./zap-B7VEvais.js";import{t as Ae}from"./pencil-DoH-KTcO.js";import{t as je}from"./plus-CIHjZPFg.js";import{t as Me}from"./radio-nxBAF-O0.js";import{t as Ne}from"./refresh-cw-Bh7jR0Ir.js";import{t as Pe}from"./search-C0Kh9F13.js";import{t as Fe}from"./server-D6u4qxlr.js";import{t as Ie}from"./square-check-big-COxvcZ2K.js";import{t as Le}from"./square-BtiVHmLU.js";import{E as Re,I as ze,J as Be,L as W,M as Ve,N as He,P as Ue,S as G,T as We,W as Ge,i as Ke,j as K,o as qe,s as Je}from"./index-PRd5ZDug.js";import{t as Ye}from"./AdminPage-BwmGKnRf.js";import{t as Xe}from"./useEventInvalidation-DMfSVBY-.js";import{r as Ze,t as Qe}from"./build-cluster-graph-DUCV6DVF.js";import{n as $e}from"./format-size-CO9d3C3-.js";import{t as et}from"./NodeAddonsSettingsPanel-KR29Oo7P.js";import{n as tt,t as nt}from"./ClusterRecordingTab-BSJTZsGS.js";var rt=Ge(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),it=Ge(`flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),at=Ge(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);I();function ot(e){return e}function st(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ct(e,t){return typeof e==`boolean`?e:ot(t)}function lt(e,t){return{pipeline:ct(st(e,`detect`),t),audio:ct(st(e,`audio`),t),ingest:ct(st(e,`ingest`),t)}}function ut(e,t,n){let r=e?.find(e=>e.nodeId===t);return lt(r?.settings,n)}function dt({selectedNodeId:e,onSelect:t,refreshToken:n}){let{data:i}=v(void 0),{data:a}=j(void 0),{data:o}=le(void 0),s=new Map;for(let e of a??[])s.set(e.agentNodeId,(s.get(e.agentNodeId)??0)+1);let c=i??[],l=c.filter(e=>e.isOnline).length,u=c.filter(e=>!e.isOnline).length;return L(`div`,{className:`flex flex-col h-full`,children:[L(`button`,{type:`button`,onClick:()=>t(yr),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${e===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[H(We,{className:`h-4 w-4 flex-shrink-0`}),L(`div`,{className:`min-w-0 flex-1`,children:[H(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),H(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),H(`div`,{className:`flex-1 overflow-y-auto`,children:c.map(n=>{let i=e===n.id,a=s.get(n.id)??0,c=n.isHub?Fe:K,l=ut(o,n.id,n.isHub),u=n.isOnline?null:r(Ze(n.lastSeen));return L(`button`,{type:`button`,onClick:()=>t(n.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[H(c,{className:`h-4 w-4 flex-shrink-0`}),L(`div`,{className:`min-w-0 flex-1`,children:[L(`div`,{className:`flex items-center gap-2`,children:[H(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&H(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!n.isOnline&&H(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&H(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),L(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[L(`span`,{children:[n.cpuCores,` cores`]}),H(`span`,{children:`•`}),L(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),a>0&&L(z,{children:[H(`span`,{children:`•`}),L(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[H(De,{className:`h-2.5 w-2.5`}),a]})]}),!n.isOnline&&L(z,{children:[H(`span`,{children:`•`}),L(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),L(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[H(F,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),H(F,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},n.id)})}),L(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[L(`span`,{children:[l,` online`]}),u>0&&L(`span`,{className:`text-destructive`,children:[u,` offline`]})]})]})}function ft({nodeId:e,refreshToken:t}){let{data:n}=v(void 0),r=n?.find(t=>t.id===e),a=i(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?L(`div`,{className:`px-6 py-4 border-b border-border`,children:[L(`div`,{className:`flex items-center gap-2 mb-1`,children:[H(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?H(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):H(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&H(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),L(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[H(`span`,{children:r.cpuModel??`CPU`}),H(`span`,{children:`•`}),L(`span`,{children:[r.cpuCores,` cores`]}),H(`span`,{children:`•`}),L(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a&&L(z,{children:[H(`span`,{children:`•`}),L(`span`,{children:[a.attachedCameras,` cameras (`,a.activeCameras,` active)`]}),H(`span`,{children:`•`}),L(`span`,{children:[a.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),H(`span`,{children:`•`}),L(`span`,{children:[`queue `,a.queueDepthTotal]}),a.hardware.hasGpu&&L(z,{children:[H(`span`,{children:`•`}),H(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):H(`div`,{className:`px-6 py-4 border-b border-border`,children:L(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function pt({refreshToken:e,nodeId:t}){let[n,r]=V(new Map),{nodes:i}=_();y(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:a}=ee(void 0),o=R(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=R(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),c=R(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=R(()=>{let e=0,t=0,n=0,r=0,a=0;for(let i of s.values())e+=i.attachedCameras,t+=i.activeCameras,n+=i.totalFps,r+=i.totalInferenceWeighted,a+=i.queueDepth;let o=e>0?r/e:0;return{totalAgents:i.length,onlineAgents:i.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:a,totalFps:n}},[s,i]);if(t){let e=s.get(t);return L(`div`,{className:`@container/liveload`,children:[H(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),L(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[H(q,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),H(q,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),H(q,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),H(q,{label:`Queue`,value:e?String(e.queueDepth):`—`}),H(q,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let u=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return L(`div`,{className:`@container/liveload`,children:[H(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),L(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[H(q,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),H(q,{label:`Active / Attached`,value:`${l.activeCameras}/${l.attachedCameras}`}),H(q,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),H(q,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),H(q,{label:`Queue depth`,value:String(l.queueDepth)})]}),H(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:L(`table`,{className:`w-full text-xs min-w-[480px]`,children:[H(`thead`,{className:`bg-surface`,children:L(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[H(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),H(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),H(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),H(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),H(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),H(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),L(`tbody`,{children:[u.map(([e,t])=>L(`tr`,{className:`border-t border-border`,children:[H(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),H(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),H(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),H(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),H(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),H(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),u.length===0&&H(`tr`,{children:H(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function q({label:e,value:t}){return L(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[H(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),H(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}I();var mt={active:!1,pinned:!1,nodeId:null,reason:``},ht=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],gt={pipeline:K,decoder:Re,audio:Oe},_t={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function vt({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let r=B(),[i,a]=V(null),[o,s]=V(null),[u,d]=V(new Map);Xe([`pipelineOrchestrator`,`getPipelineAssignments`],ht),Xe([`pipelineOrchestrator`,`getAudioAssignments`],ht),Xe([`pipelineOrchestrator`,`getCameraStatuses`],ht);let{data:f}=j(void 0),{data:m}=E(void 0),{data:h}=D({},{enabled:e===`agent`}),{nodes:g}=_(),{data:v}=xe();y(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&d(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),U(()=>{if(u.size===0)return;let e=setInterval(()=>{d(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[u.size]);let b=R(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),x=R(()=>{if(e===`agent`){let e=[];for(let n of h??[]){let r=n.assignment,i=(e,n,r)=>({active:e!==null&&e===t,pinned:n,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:n.deviceId,deviceName:b.get(n.deviceId)??`Device ${n.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:b.get(e)??`Device ${e}`,pipeline:mt,decoder:mt,audio:mt};return n.set(e,r),r};for(let i of f??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of m??[]){let t=r(e.deviceId);n.set(e.deviceId,{...t,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...n.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[f,m,h,b,e,t]),S=R(()=>(g??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[g]),C=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},T=re({onSuccess:C}),O=l({onSuccess:C}),k=w({onSuccess:C}),A=c({onSuccess:C}),M=(e,t,n)=>{t===`pipeline`?T.mutate({deviceId:e,agentNodeId:n}):k.mutate({deviceId:e,nodeId:n}),a(null)},N=(e,t)=>{t===`pipeline`?O.mutate({deviceId:e}):A.mutate({deviceId:e}),a(null)};return H(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:L(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[H(`thead`,{className:`bg-surface`,children:L(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&H(`th`,{className:`w-10`}),H(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?L(z,{children:[H(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),H(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):L(z,{children:[H(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),H(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),H(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),H(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),L(`tbody`,{children:[x.map(t=>{let r=u.get(t.deviceId),c=o===t.deviceId;return L(he.Fragment,{children:[L(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&H(`td`,{className:`px-2 py-2 align-middle`,children:H(`button`,{type:`button`,onClick:()=>s(c?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":c?`Collapse broker details`:`Expand broker details`,children:H(c?ze:Ue,{className:`h-3.5 w-3.5`})})}),L(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[H(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),L(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?L(z,{children:[H(`td`,{className:`px-3 py-2 align-middle`,children:H(bt,{state:t.pipeline,onlineNodes:S,pending:T.isPending||O.isPending,onChange:e=>{e===`auto`?N(t.deviceId,`pipeline`):M(t.deviceId,`pipeline`,e)}})}),H(`td`,{className:`px-3 py-2 align-middle`,children:H(xt,{state:t.pipeline})})]}):L(z,{children:[H(St,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:S,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`pipeline`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>a(null),onMove:e=>M(t.deviceId,`pipeline`,e),onUnpin:()=>N(t.deviceId,`pipeline`)}),H(St,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:S,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),H(St,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:S,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`audio`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>a(null),onMove:e=>M(t.deviceId,`audio`,e),onUnpin:()=>N(t.deviceId,`audio`)})]}),H(`td`,{className:`px-3 py-2 align-middle`,children:H(Et,{snap:r})})]}),c&&!n&&L(`tr`,{className:`bg-surface/50`,children:[H(`td`,{}),L(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2 space-y-3`,children:[t.pipeline.nodeId&&H(yt,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),H(p,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})]})]})]},t.deviceId)}),x.length===0&&H(`tr`,{children:H(`td`,{colSpan:n?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function yt({deviceId:e,nodeId:t}){let n=B(),{data:r}=P({nodeId:t}),{data:i}=C({deviceId:e}),a=N({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}}),o=r?.devices??[],s=i?.deviceKey??`auto`,c=s!==`auto`&&!o.some(e=>e.key===s);return L(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[H(`span`,{className:`shrink-0 font-medium text-foreground`,children:`Inference device`}),L(`select`,{value:s,disabled:a.isPending,"aria-label":`Inference device pin`,onChange:t=>a.mutate({deviceId:e,deviceKey:t.target.value}),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[H(`option`,{value:`auto`,children:`Auto (balanced)`}),c&&L(`option`,{value:s,children:[`Pin → `,s,` (not on this node)`]}),o.map(e=>L(`option`,{value:e.key,children:[`Pin → `,e.key,e.available?``:` (unavailable)`]},e.key))]}),a.isPending&&H(`span`,{className:`text-[10px] opacity-70`,children:`saving…`})]})}function bt({state:e,onlineNodes:t,pending:n,onChange:r}){let i=e.pinned&&e.nodeId?e.nodeId:`auto`,a=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return L(`select`,{value:i,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[H(`option`,{value:`auto`,children:`Auto`}),a.map(e=>L(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function xt({state:e}){if(!e.active||!e.nodeId)return H(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let t=e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`;return L(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[H(`span`,{className:`font-mono text-[11px] text-foreground truncate`,title:e.nodeId,children:e.nodeId}),H(`span`,{className:`truncate ${e.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:t,children:t})]})}function St({role:e,state:t,mode:n,onlineNodes:r,readOnly:i=!1,isMenuOpen:a,onToggleMenu:o,onCloseMenu:s,onMove:c,onUnpin:l}){let u=gt[e],d=r.filter(e=>e.id!==(t.nodeId??``)),f=!i&&(t.active||n===`cluster`)&&(d.length>0||t.pinned);return L(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[L(`div`,{className:`flex items-center gap-2 min-w-0`,children:[H(n===`agent`?Ct:wt,{state:t,Icon:u}),H(`div`,{className:`ml-auto shrink-0`,children:f&&H(`button`,{type:`button`,onClick:o,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${_t[e]} actions`,children:H(rt,{className:`h-3 w-3 text-foreground-subtle`})})})]}),a&&f&&H(Dt,{title:_t[e],targets:d,pinned:t.pinned,onMove:c,onUnpin:l,onClose:s})]})}function Ct({state:e,Icon:t}){return L(`div`,{className:`flex items-center gap-1.5`,children:[H(e.active?Ie:Le,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),H(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&H(at,{className:`h-2.5 w-2.5 text-amber-400`})]})}function wt({state:e,Icon:t}){return!e.active||!e.nodeId?L(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[H(t,{className:`h-3 w-3`}),H(`span`,{className:`text-[10px] italic`,children:`—`})]}):L(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[H(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),L(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[H(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),H(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?L(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[H(at,{className:`h-2.5 w-2.5`}),` manual`]}):L(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var Tt=`min-h-[3.25rem]`;function Et({snap:e}){if(!e)return H(`div`,{className:`flex items-center ${Tt}`,children:H(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:i,configuredFps:a,droppedFrames:o}=e.metrics,s=h(t);return L(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Tt}`,children:[L(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${s.textColor}`,children:[H(S,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),H(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:s.label})]}),L(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[H(`span`,{className:`text-foreground`,children:n.toFixed(1)}),L(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),L(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[H(`span`,{className:`text-foreground`,children:r.toFixed(0)}),H(`span`,{children:` ms`}),i>0&&L(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]}),L(`span`,{className:`whitespace-nowrap truncate ${o>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,H(`span`,{className:`text-foreground`,children:o})]})]})}function Dt({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=me(null);return U(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),L(`div`,{ref:o,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[H(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&H(`div`,{className:`py-1`,children:t.map(e=>L(`button`,{type:`button`,onClick:()=>r(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),n&&L(`button`,{type:`button`,onClick:i,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),t.length===0&&!n&&H(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Ot({nodeId:e,refreshToken:t}){return L(`div`,{className:`space-y-6`,children:[H(pt,{refreshToken:t,nodeId:e}),L(`div`,{children:[H(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),L(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),H(vt,{mode:`agent`,nodeId:e,compact:!0})]})}I();function kt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function At({nodeId:e,refreshToken:t}){let n=B(),r=ae({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:o}=M({nodeId:e}),s=i(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??o??null,c=s===null;Xe([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:l}=a({nodeId:e}),{values:u}=g(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),d=R(()=>u.filter(e=>e.metrics.phase===`active`).length,[u]),f=t=>{let n=l??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||r.mutate({nodeId:e,engine:t,force:n.length>0})};return L(`div`,{className:`space-y-6`,children:[L(`div`,{children:[H(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),L(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(s??[]).length,` engine(s) resident in RAM. `,(l??[]).length,` `,`camera(s) attached, `,d,` actively dispatching frames. Refreshes every 5s.`]})]}),H(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:L(`table`,{className:`w-full text-xs min-w-[640px]`,children:[H(`thead`,{className:`bg-surface`,children:L(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[H(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),H(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),H(`th`,{className:`text-left px-3 py-2`,children:`Models`}),H(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),H(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),H(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),H(`th`,{className:`w-20`})]})}),L(`tbody`,{children:[c&&H(`tr`,{children:H(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!c&&(s??[]).map(e=>{let t=e.kind===`warm-override`,n=e.kind===`device-pool`;return L(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:n?`bg-primary/[0.05]`:``}`,children:[H(`td`,{className:`px-3 py-2`,children:L(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[H(t?it:n?ye:K,{className:`h-3 w-3`}),t?`warm`:n?`pool`:`runtime`]})}),H(`td`,{className:`px-3 py-2`,children:L(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[H(ke,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),H(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?H(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):H(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>H(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),H(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),H(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?H(`span`,{className:`text-foreground-subtle`,children:kt(e.idleMs,e.idleTtlMs)}):H(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),H(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(l??[]).length}),H(`td`,{className:`px-3 py-2 text-right`,children:n?H(`span`,{className:`text-[11px] text-foreground-subtle`,children:`auto`}):L(`button`,{type:`button`,disabled:r.isPending,onClick:()=>f(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[H(Je,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!c&&(s??[]).length===0&&H(`tr`,{children:H(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),L(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[H(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,H(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,H(`strong`,{className:`text-foreground`,children:`pool`}),`: a per-device balanced inference pool (one per enabled accelerator, running concurrently); reaper-managed on its own idle TTL.`]}),r.isError&&L(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,r.error instanceof Error?r.error.message:`unknown`]})]})}I();var jt=new Set(ve);function Mt(e){return jt.has(e)}function Nt(e,t,n){return`${e}/${t}/${n}`}function Pt(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Ft(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function J(e){return e.format}function It(e,t){let n=0,r=0,i=0;for(let a of e)for(let e of a.addons)for(let a of e.models){let e=a.formats[t];e&&(n++,e.downloaded&&(r++,i+=e.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:i}}function Lt({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?L(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[H(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),L(`div`,{className:`flex-1 min-w-0`,children:[L(`div`,{className:`flex items-center gap-2`,children:[H(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),L(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&L(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[H(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:H(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),L(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),H(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:$e(c.sizeMB)}),a&&L(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[H(He,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?L(`button`,{onClick:s,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[r?H(G,{className:`h-3 w-3 animate-spin`}):H(Je,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):L(`button`,{onClick:o,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[r?H(G,{className:`h-3 w-3 animate-spin`}):H(Te,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function Rt({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=V(!1);return L(`div`,{className:`relative`,children:[L(`button`,{type:`button`,onClick:()=>a(!i),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[H(K,{className:`h-4 w-4 text-primary shrink-0`}),L(`div`,{className:`flex-1 min-w-0`,children:[L(`div`,{className:`flex items-center gap-2`,children:[H(`span`,{className:`text-sm font-medium text-foreground`,children:Pt(n)}),J(n)===J(t)&&H(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),H(`div`,{className:`text-[10px] text-foreground-subtle`,children:Ft(n)})]}),H(ze,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&H(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=J(e)===J(n),o=J(e)===J(t);return L(`button`,{type:`button`,onClick:()=>{r(e),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${i?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[H(K,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),L(`div`,{className:`flex-1`,children:[L(`div`,{className:`flex items-center gap-2`,children:[H(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:Pt(e)}),o&&H(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),H(`div`,{className:`text-[10px] text-foreground-subtle`,children:Ft(e)})]}),i&&H(Ve,{className:`h-4 w-4 text-primary shrink-0`})]},J(e))})})]})}function zt({embedded:t=!1,nodeId:n}={}){let r=B(),i=n??`hub`,[a,o]=V(null),[s,c]=V(new Set),[l,u]=V(new Map),[f,p]=V(new Map),[m,h]=V(``),{data:g=[]}=O({nodeId:i}),_=g.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:v}=ne({nodeId:i}),b=v,{data:x,isLoading:S}=se({nodeId:i}),C=e(),w=d();y(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,i=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||i===void 0||(u(e=>{let t=new Map(e);return i===100||i===-1?t.delete(n):t.set(n,{modelId:n,progress:i,totalMB:a}),t}),i===100&&r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let T=b??{runtime:`node`,backend:`cpu`,format:`onnx`},E=_.find(e=>e.format===a)??T,D=E.format,k=x?.slots??[],A=k.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[D]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),j=It(A,D),M=pe(async(e,t,n)=>{if(!Mt(n))return;let a=Nt(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await C.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[C,r,i]),N=pe(async(e,t,n)=>{if(!Mt(n))return;let a=Nt(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await w.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[w,r,i]),ee=pe(e=>{o(e.format)},[]),te=m.trim()?A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(m.toLowerCase())||t.id.toLowerCase().includes(m.toLowerCase())||e.name.toLowerCase().includes(m.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):A,P=L(z,{children:[S&&H(`div`,{className:`flex items-center justify-center py-16`,children:H(G,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!S&&k.length===0&&L(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[H(Ee,{className:`h-8 w-8 mb-3 opacity-30`}),H(`span`,{className:`text-sm`,children:`No pipeline steps available`}),H(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!S&&k.length>0&&L(z,{children:[H(Rt,{engines:_,activeEngine:T,viewEngine:E,onSelect:ee}),L(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[L(`span`,{children:[H(`span`,{className:`font-semibold text-foreground tabular-nums`,children:j.total}),H(`span`,{className:`ml-1`,children:`compatible models`})]}),H(`span`,{className:`text-border`,children:`|`}),L(`span`,{children:[H(`span`,{className:`font-semibold text-success tabular-nums`,children:j.downloaded}),H(`span`,{className:`ml-1`,children:`downloaded`})]}),H(`span`,{className:`text-border`,children:`|`}),L(`span`,{className:`tabular-nums`,children:[$e(j.downloadedSizeMB),H(`span`,{className:`ml-1`,children:`on disk`})]})]}),j.total>5&&L(`div`,{className:`relative`,children:[H(Pe,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),H(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),te.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+t.models.filter(e=>e.formats[D]?.downloaded).length,0);return L(`div`,{children:[L(`div`,{className:`flex items-center gap-2 mb-2`,children:[H(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),H(`div`,{className:`flex-1 h-px bg-border`}),L(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=Nt(e.id,t.id,D);return H(Lt,{addonId:e.id,model:t,format:D,isActive:s.has(n),progress:l.get(t.id),errorMsg:f.get(n),onDownload:()=>M(e.id,t.id,D),onDelete:()=>N(e.id,t.id,D)},`${e.id}/${t.id}`)}))})]},e.id)}),te.length===0&&H(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:m.trim()?L(z,{children:[`No models matching “`,m,`”`]}):L(z,{children:[`No models available for `,Pt(E),` format`]})})]})]});return t?H(`div`,{className:`space-y-4`,children:P}):H(Ye,{children:P})}function Bt({nodeId:e,refreshToken:t}){return H(zt,{embedded:!0,nodeId:e})}var Vt=`pipeline-runner`,Ht=200;function Ut({nodeId:e}){return L(`div`,{className:`flex flex-col gap-3`,children:[L(`div`,{children:[H(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),L(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. Streaming live; the device chip on a line tells which camera it refers to.`]})]}),H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:H(A,{agentId:e,addonId:Vt,limit:Ht,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}I(),I();function Wt({nodeId:e,title:t}){let{data:n}=xe(),{data:r}=j(void 0),i=R(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=R(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[o,s]=V(new Map);y(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||s(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),U(()=>{if(o.size===0)return;let e=setInterval(()=>{s(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[o.size]);let c=R(()=>{let e=[];for(let t of o.values())a&&!a.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[o,a]);return c.length===0?L(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):L(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[L(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[H(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),H(`span`,{className:`text-[10px] text-foreground-subtle`,children:c.length})]}),H(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=h(e.metrics.phase);return L(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[H(S,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),H(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),H(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),H(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}I();function Gt(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function Kt(e){if(!e)return null;let t=e.modelId!==void 0&&e.modelId!==``?e.modelId:void 0,n=e.settings&&Object.keys(e.settings).length>0?e.settings:void 0;return t===void 0&&n===void 0?null:{...t===void 0?{}:{modelId:t},...n===void 0?{}:{settings:n}}}function qt({nodeId:e,refreshToken:t}){let n=B(),[r,i]=V(null),[a,s]=V(null),[c,l]=V(null),u=P({nodeId:e},{refetchOnMount:`always`}),d=se({nodeId:e},{refetchOnMount:`always`}),f=u.data?.devices??[],p=m({onSuccess:()=>{n.invalidateQueries({queryKey:[`pipelineOrchestrator`,`getNodeInferenceDevices`]})}}),h=R(()=>d.data?x(d.data):[],[d.data]),g=R(()=>f.map(t=>({agentNodeId:e,engineLabel:t.format,deviceKey:t.key,deviceLabel:be(t).label})),[f,e]),_=e=>f.find(t=>t.key===e)??null,v=e=>{let t=Gt(d.data??null,e)?.enabledByDefault??!0;return{kind:`gate`,effectiveOn:t,defaultOn:t,explicit:!1}},y=(e,t)=>{let n=v(e),r=n.kind===`gate`?n.effectiveOn:!1,i=Gt(d.data??null,e),a=t.deviceKey===void 0?null:_(t.deviceKey),o=a?.format;return i?.models.some(e=>o!==void 0&&!!e.formats[o])??!1?{kind:`enabled`,modelId:a?.steps?.[e]?.modelId??a?.defaultModelId??`Auto`}:r?{kind:`skip`}:{kind:`na`}},S=r&&d.data?Gt(d.data,r.addonId):null,C=r?_(r.deviceKey):null,w=C?.format??`coreml`,T=()=>{i(null),s(null)},E=(e,t)=>{if(t.deviceKey===void 0)return;let n=_(t.deviceKey)?.steps?.[e];i({addonId:e,deviceKey:t.deviceKey}),s({enabled:!0,...n?.modelId===void 0?{}:{modelId:n.modelId},settings:n?.settings??{}})},D=()=>{if(!r)return;let t=Kt(a),n={};for(let e of f){if(!e.enabled&&e.key!==r.deviceKey)continue;let i={...e.steps??{}};e.key===r.deviceKey&&(t?i[r.addonId]=t:delete i[r.addonId]);let a=Object.keys(i).length>0;n[e.key]={enabled:!0,weight:Math.max(1,e.weight),...e.maxSessions!=null&&e.maxSessions>0?{maxSessions:e.maxSessions}:{},...a?{steps:i}:{}}}p.mutate({agentNodeId:e,inferenceDevices:n},{onSuccess:T})};if(u.isLoading||d.isLoading)return H(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(f.length===0)return H(`div`,{className:`rounded-md border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`});if(!d.data)return H(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let O=r!==null&&S!==null&&C!==null;return L(`div`,{className:`relative h-full w-full space-y-3`,children:[L(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[`Each column is one of this node's inference accelerators. A cell shows the`,` `,H(`span`,{className:`font-medium text-foreground`,children:`base model`}),` every camera landing on that accelerator runs; click to change it. Whether a camera runs a step is set per-camera on that camera's Detection pipeline tab — there is no gate here.`]}),H(`div`,{className:O?`md:pr-[360px]`:``,children:h.length>0?H(o,{tree:h,agents:g,gateFor:v,getCellState:y,onCellClick:E,selectedCell:r?{addonId:r.addonId,agentNodeId:e,deviceKey:r.deviceKey}:null,onSetGate:()=>{},fallbackNodeId:c,onFallbackNodeChange:l,hideGate:!0}):H(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),H(b,{open:O,onClose:T,title:S?.name??``,subtitle:r&&C?`${e} · ${be(C).label} · ${C.format}`:``,footer:L(z,{children:[H(`div`,{className:`flex-1`}),H(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:T,children:`Cancel`}),H(`button`,{type:`button`,disabled:!r||!a||p.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:D,children:p.isPending?`Saving…`:`Save`})]}),children:S&&r&&a?H(ie,{mode:`agent`,addon:S,agentDefault:a,agentNodeId:e,engineFormat:w,onChangeAgentConfig:s}):H(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300`,children:`This accelerator is no longer reported by the node, so there is nothing to provision here.`})})]})}I();var Jt=[`pipeline-orchestrator`],Yt=[`decoder`],Xt=!1;function Zt({nodeId:e,refreshToken:t}){let n=s(),[r,i]=V(null),[a,o]=V(null),c=(v(void 0).data??[]).find(t=>t.id===e),l=c?.name??e,u=c?.isOnline??!1,d=de({onSuccess:e=>{o(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),f=async()=>{await n({title:`Reset ${l} to hardware-aware defaults?`,message:`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(o(null),d.mutate({agentNodeId:e}))};return L(`div`,{className:`relative h-full w-full space-y-3`,children:[L(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[a&&H(`span`,{className:`text-emerald-400`,children:a}),d.isError&&H(`span`,{className:`text-red-400`,children:d.error instanceof Error?d.error.message:`Reset failed`}),H(`button`,{type:`button`,onClick:()=>{f()},disabled:d.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's per-device model defaults + per-camera overrides scoped to this node`,children:d.isPending?`Resetting…`:`Reset to default`})]}),H(Wt,{nodeId:e}),H(et,{nodeId:e,addonIds:Jt,level:`global`,sectionIds:Yt}),Xt,Xt,L(`div`,{children:[H(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices — default model per accelerator`}),H(we,{nodeId:e,nodeName:l,isOnline:u})]}),L(`div`,{children:[H(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection steps — model per accelerator`}),H(qt,{nodeId:e,refreshToken:t})]})]})}var Qt=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],$t=`decoder-nodeav`;function en({nodeId:e,refreshToken:t}){let{data:n}=v(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??$t,i=[...Qt,r];return L(`div`,{className:`flex flex-col h-full`,children:[H(ft,{nodeId:e,refreshToken:t}),H(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:H(et,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:H(Ot,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:H(Zt,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:H(At,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:H(Bt,{nodeId:e,refreshToken:t})},{id:`logs`,label:`Logs`,order:300,content:H(Ut,{nodeId:e})}]})})]})}var tn=`pipeline-orchestrator`,nn=`recorder`,rn=`recordingNodeId`,an=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`],on=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function sn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function cn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ln(e,t,n){let r=sn(e,t);return typeof r==`string`&&r.length>0?r:n}function un(e,t,n){let r=sn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function dn(e,t){let n=cn(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function fn(e,t){let n=cn(e,t);return typeof n==`string`&&n.length>0?n:null}function pn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:`Motion Node`}function mn(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:e===`audioNode`?`Node that runs singleton audio work`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function hn(e,t){switch(t){case`detect`:return e.pipeline}}function gn(e){return e instanceof Error?e.message:`Failed to save`}function _n(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function vn({capability:e,label:t,hint:n,nodeId:r,active:i,pending:a,layout:o,onToggle:s}){let c=i?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,l=o===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,u=i?W:Ce;return L(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} capability for ${r}`,title:`${t} — ${n}`,disabled:a,onClick:()=>s(e,!i),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${c} ${l}`,children:[H(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),H(`span`,{children:t})]})}function yn({node:e,emphasis:t=!1}){let n=e.isHub?Fe:K;return L(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[H(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),H(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),L(`div`,{className:`min-w-0`,children:[L(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[H(`span`,{className:`truncate`,children:e.name}),e.isHub&&H(F,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&H(F,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),H(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}I();function bn({nodeId:e,value:t,detectedHosts:n,status:r,errorMessage:i,onCommit:a}){let[o,s]=V(t??``);U(()=>{s(t??``)},[t]);let c=n[0],l=c===void 0?`auto-detect`:`auto: ${c}`,u=r===`pending`,d=o.trim(),f=d!==(t??``),p=f&&!u,m=()=>{p&&a(e,d.length>0?d:null)};return L(`div`,{className:`flex items-center gap-1.5`,children:[H(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:l,value:o,disabled:u,onChange:e=>s(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&s(t??``)},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`}),L(`button`,{type:`button`,onClick:m,disabled:!p,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[u?H(G,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):H(W,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!f&&!u&&r===`success`&&H(W,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),r===`error`&&H(`span`,{title:i??`Failed to save reachable host`,children:H(He,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":i??`Failed to save reachable host`,role:`img`})})]})}function xn({label:e,children:t}){return L(`div`,{className:`flex items-center justify-between gap-3`,children:[H(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function Sn({node:e,actions:t}){return L(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[H(yn,{node:e,emphasis:!0}),H(`div`,{className:`grid grid-cols-2 gap-2`,children:on.map(n=>H(vn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:hn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),H(`div`,{className:`space-y-3 border-t border-border pt-3`,children:H(xn,{label:`Reachable host`,children:H(bn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function Cn(){return L(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[L(`span`,{className:`inline-flex items-center gap-1.5`,children:[H(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),L(`span`,{className:`inline-flex items-center gap-1.5`,children:[H(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),L(`span`,{className:`inline-flex items-center gap-1.5`,children:[H(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),L(`span`,{className:`inline-flex items-center gap-1.5`,children:[H(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function wn({nodes:e,actions:t}){return H(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:L(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[H(`thead`,{children:L(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[H(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),on.map(e=>H(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),H(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),H(`tbody`,{children:e.map(e=>L(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[H(`td`,{className:`px-4 py-3 align-middle`,children:H(yn,{node:e})}),on.map(n=>H(`td`,{className:`px-3 py-3 text-center align-middle`,children:H(vn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:hn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),H(`td`,{className:`px-4 py-3 align-middle`,children:H(bn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})]},e.id))})]})})}function Tn({role:e,value:t,options:n,pending:r,onChange:i}){return L(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[H(`span`,{className:`text-xs font-semibold text-foreground`,children:pn(e)}),H(`select`,{value:t,disabled:r,onChange:t=>i(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:n.map(e=>H(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),H(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:mn(e)})]})}function En({roleValues:e,options:t,pending:n,lowFpsEnabled:r,fpsMinThreshold:i,onRoleChange:a,onLowFpsToggle:o}){return L(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[an.map(r=>H(Tn,{role:r,value:e[r],options:t,pending:n,onChange:a},r)),L(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[H(`input`,{type:`checkbox`,checked:r,disabled:n,onChange:e=>o(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),L(`span`,{className:`flex flex-col gap-0.5`,children:[H(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),L(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,r?`${i} fps`:`disabled`]})]})]})]})}I();function Dn(){let e=B(),{nodes:r}=_(),i=le(void 0),a=ce({addonId:tn}),o=ce({addonId:nn}),s=()=>_n(e),c=t({onSuccess:s}),l=ue(),u=n({onSuccess:s}),d=k({onSuccess:s}),[f,p]=V(!1),m=R(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),h=R(()=>r.map(e=>{let t=m.get(e.id),n=lt(t,e.isHub),r=dn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:dn(t,`maxCameras`),reachableHost:fn(t,`reachableHost`),detectedHosts:e.localIps}}),[r,m]),g=h.filter(e=>e.effective.pipeline),v={ingestNode:ln(a.data,`ingestNode`,`hub`),recordingNode:ln(o.data,rn,`hub`),audioNode:ln(a.data,`audioNode`,`hub`),motionNode:ln(a.data,`motionNode`,`hub`)},y=R(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...an.map(e=>v[e]),...e])].filter(e=>e.length>0)},[r,v]),b=un(a.data,`fpsMinThreshold`,0),x=b>0,S=i.isLoading||a.isLoading||o.isLoading,C=(e,t,n)=>{c.mutate({agentNodeId:e,[t]:n})},w=(e,t)=>{if(e===`recordingNode`){d.mutate({addonId:nn,patch:{[rn]:t}});return}d.mutate({addonId:tn,patch:{[e]:t}})},T=e=>{d.mutate({addonId:tn,patch:{fpsMinThreshold:e?Math.max(1,b):0}})},E=e=>u.variables?.agentNodeId===e?u.isPending?`pending`:u.isError?`error`:u.isSuccess?`success`:`idle`:`idle`,D=e=>E(e)===`error`?gn(u.error):null,O=async e=>{p(!0);try{for(let t of e)await l.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{p(!1),s()}},A={capabilityPending:c.isPending,onToggleCapability:C,onCommitReachableHost:(e,t)=>u.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:E,reachableHostErrorMessage:D};return L(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[L(`header`,{className:`flex items-start justify-between gap-4`,children:[L(`div`,{className:`space-y-1`,children:[H(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),H(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),S&&H(G,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),L(`div`,{className:`space-y-3`,children:[H(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),H(En,{roleValues:v,options:y,pending:d.isPending,lowFpsEnabled:x,fpsMinThreshold:b,onRoleChange:w,onLowFpsToggle:T})]}),L(`div`,{className:`space-y-3`,children:[L(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[H(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),H(Cn,{})]}),h.length===0?H(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No cluster nodes reporting yet.`}):L(z,{children:[H(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:h.map(e=>H(Sn,{node:e,actions:A},e.id))}),H(`div`,{className:`hidden @3xl/clustertab:block`,children:H(wn,{nodes:h,actions:A})})]})]}),L(`div`,{className:`space-y-3`,children:[H(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),H(Se,{nodes:g,pending:f,onCommitWeights:e=>void O(e)})]}),L(`div`,{className:`space-y-3`,children:[H(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices`}),g.length===0?H(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No detect-capable nodes — enable detection on a node above to configure its accelerators.`}):H(`div`,{className:`space-y-2`,children:g.map(e=>H(we,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline},e.id))})]})]})}I();var On=!1;function kn({refreshToken:e}){let t=B(),{data:n}=v(void 0);R(()=>Qe(n??[]),[n]);let r=T({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return L(`div`,{className:`space-y-6`,children:[H(Wt,{title:`Cluster cameras`}),H(pt,{refreshToken:e}),H(Dn,{}),On,L(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[L(`div`,{className:`min-w-0`,children:[H(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),H(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Click the kebab to pin / unpin / move a role; expand the chevron for the per-camera broker drill-down.`})]}),L(`button`,{type:`button`,onClick:()=>r.mutate(void 0),disabled:r.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[H(ke,{className:`h-3.5 w-3.5`}),r.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),H(vt,{mode:`cluster`})]})}var An=[`pipeline-orchestrator`];function jn({refreshToken:e}){return H(`div`,{className:`space-y-4 max-w-3xl`,children:H(et,{nodeId:`hub`,addonIds:An,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})})}I();function Mn({refreshToken:e}){let t=B(),{data:n,isLoading:r}=fe(),[i,a]=V(null),[o,s]=V(``),[c,l]=V(``),d=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},f=u({onSuccess:()=>{a(null),d()}}),p=oe({onSuccess:d}),m=e=>{a(e.id),s(e.name),l(e.description??``)},h=()=>{a(null),s(``),l(``)},g=()=>{if(!i)return;let e=c.trim();f.mutate({id:i,name:o.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return H(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return H(`div`,{className:`space-y-6 max-w-4xl`,children:L(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[L(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[L(`div`,{children:[H(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),H(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),L(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?L(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[H(je,{className:`h-6 w-6 opacity-40`}),H(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):H(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return H(`li`,{className:`px-4 py-3 text-xs`,children:L(`div`,{className:`flex items-start gap-3`,children:[H(`div`,{className:`flex-1 min-w-0`,children:t?L(`div`,{className:`space-y-2`,children:[H(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:o,onChange:e=>s(e.target.value),placeholder:`Template name`,autoFocus:!0}),H(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:c,onChange:e=>l(e.target.value),placeholder:`Description (optional)`})]}):L(z,{children:[H(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&H(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),L(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,L(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),H(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?L(z,{children:[L(`button`,{type:`button`,onClick:g,disabled:f.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[H(W,{className:`h-3 w-3`}),`Save`]}),L(`button`,{type:`button`,onClick:h,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[H(Ke,{className:`h-3 w-3`}),`Cancel`]})]}):L(z,{children:[H(`button`,{type:`button`,onClick:()=>m(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:H(Ae,{className:`h-3 w-3`})}),H(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&p.mutate({id:e.id})},disabled:p.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:H(Je,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}I();var Nn=`pipeline-analytics`;function Pn(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Fn(){let e=B(),{data:t}=v(void 0),{data:n,isLoading:r}=ce({addonId:Nn}),i=Pn(n),a=k({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),o=R(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return L(`div`,{className:`flex flex-col gap-6`,children:[L(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[H(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),H(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),L(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?H(G,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):H(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:Nn,patch:{postProcessingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:o.map(e=>H(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&H(G,{className:`h-4 w-4 animate-spin text-primary`})]})]}),L(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[H(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),H(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),H(tt,{types:[`eventMedia`]})]})]})}var In=`pipeline-orchestrator`,Ln=200;function Rn(){return L(`div`,{className:`flex flex-col gap-3`,children:[L(`div`,{children:[H(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),H(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`})]}),H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:H(A,{addonId:In,limit:Ln,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}I();var zn=[{id:`assignments`,label:`Assignments`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function Bn({refreshToken:e}){let[t,n]=V(`assignments`);return L(`div`,{className:`flex flex-col h-full`,children:[L(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[H(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),H(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),H(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:zn.map(e=>H(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),L(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&H(kn,{refreshToken:e}),t===`events`&&H(Fn,{}),t===`recording`&&H(nt,{}),t===`settings`&&H(jn,{refreshToken:e}),t===`templates`&&H(Mn,{refreshToken:e}),t===`logs`&&H(Rn,{})]})]})}function Vn(e){let t=[],n=[],{assignment:r,detection:i,decoder:a,broker:o}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?`Engine provisioning failed: ${i.provisioning.error}`:`Engine provisioning failed on the detection node`}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:`Detection phase is ACTIVE but 0 fps are being processed — frames are not reaching the detector (cross-node black-hole signature)`}),i!==null&&i.phase===`active`&&a!==null&&a.shm.framesWritten===0&&t.push({code:`decoder-black-hole`,severity:`error`,message:`Decoder on ${a.nodeId} has written 0 frames to the shared-memory plane while detection is active — the decode path is stalled`}),r.detectionNodeId===null&&i===null&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});for(let e of o?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function Hn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Un(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Wn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Gn(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var Kn={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function qn(e){if(!Hn(e)||!Array.isArray(e.sections))return Kn;let t=ge(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)Gn(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Un(n(`detectionFps`)),motionSources:Wn(n(`motionSources`)),motionFps:Un(n(`motionFps`)),motionCooldownMs:Un(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function Jn(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...Jn(r.children,t+1));return n}function Yn(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function X({title:e,children:t}){return L(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[H(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),H(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return L(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[H(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),H(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&H(Xn,{})]})}function Xn(){return H(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:`Device-level override active`,"aria-label":`Device-level override active`,role:`img`})}var Zn={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return H(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${Zn[e]}`,children:t})}function $({children:e}){return H(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function Qn({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){return L(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[H(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),H(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?H(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):L(z,{children:[H(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?L(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[H(at,{className:`h-2.5 w-2.5`}),` manual`]}):L(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,i!==void 0&&i.length>0?i:`capacity`]}),a&&H(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function $n({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let a=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,o=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return L(X,{title:`Where it runs`,children:[H(Qn,{icon:K,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),H(Qn,{icon:Re,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),H(Qn,{icon:Oe,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),H(Qn,{icon:Me,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),H(`div`,{className:`mt-1.5`,children:L(`select`,{value:a,disabled:r,"aria-label":`Detection placement pin`,onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[H(`option`,{value:`auto`,children:`Auto (load balanced)`}),o.map(e=>L(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function er(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function tr(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function nr(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function rr({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i}){let a=tr(t,n.detectionStreamProfile),o=tr(t,n.motionStreamProfile),s=n.motionSources.includes(`analyzer`);return L(X,{title:`Streams & motion`,children:[L(Z,{label:`Detect stream`,overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,a!==void 0&&` · ${a.width}×${a.height} ${a.codec}`]}),H(Z,{label:`Detect FPS`,overridden:n.overriddenKeys.has(`detectionFps`),children:nr(n.detectionFps)}),L(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.join(` + `):`none`,r===!1&&` · inactive`]}),s&&L(z,{children:[L(Z,{label:`Motion stream`,overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,o!==void 0&&` · ${o.width}×${o.height} ${o.codec}`]}),L(Z,{label:`Motion FPS`,overridden:n.overriddenKeys.has(`motionFps`),children:[nr(n.motionFps),i!==null&&` · live ${i.toFixed(1)}`]})]}),H(Z,{label:`Cooldown`,overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),H(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?H($,{children:`No streams registered`}):e.map(e=>L(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[H(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,er(e)]},e.camStreamId))})]})}function ir({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){return L(X,{title:`Pipeline steps`,children:[e===void 0?H($,{children:`Resolving…`}):e.length===0?H($,{children:`No steps configured`}):H(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>H(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:L(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&H(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&L(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),H(`div`,{className:`mt-1`,children:L(Z,{label:`Audio class.`,children:[r??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var ar={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function or({detection:e,live:t,detectionMode:n,modeOverridden:r}){if(e===null)return L(X,{title:`Detection runtime`,children:[H(Z,{label:`Mode`,overridden:r,children:n??`—`}),H($,{children:`Detection stage inactive or unreachable`})]});let i=t?.phase??e.phase,a=t?.actualFps??e.actualFps,o=t?.configuredFps??e.configuredFps,s=t?.avgInferenceTimeMs??e.avgInferenceMs,c=t?.queueDepth??e.queueDepth,l=h(i),u=i===`active`&&a===0;return L(X,{title:`Detection runtime`,children:[L(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[L(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${l.badgeClass}`,children:[H(S,{phase:i,className:`h-2.5 w-2.5`}),l.label]}),t!==void 0&&H(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),H(Z,{label:`Mode`,overridden:r,children:n??`—`}),L(Z,{label:`FPS`,children:[H(`span`,{className:u?`text-danger font-semibold`:``,children:a.toFixed(1)}),L(`span`,{className:`text-foreground-subtle`,children:[` / `,o.toFixed(0),` configured`]})]}),L(Z,{label:`Inference`,children:[s.toFixed(0),` ms`,c>0&&L(`span`,{className:`text-warning`,children:[` · queue `,c]}),t!==void 0&&t.droppedFrames>0&&L(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),L(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),L(Z,{label:`Provisioning`,children:[H(Q,{tone:ar[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&L(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function sr({broker:e}){return e===null?H(X,{title:`Stream broker`,children:H($,{children:`Broker stage inactive or unreachable`})}):L(X,{title:`Stream broker`,children:[e.profiles.length===0?H($,{children:`No broker profiles`}):H(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,n=t&&e.inFps===0;return L(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[H(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${n?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),H(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),L(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),L(`span`,{className:`ml-auto shrink-0 ${n?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),L(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),L(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[L(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),L(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function cr({decoder:e,detectionActive:t}){if(e===null)return H(X,{title:`Decoder`,children:H($,{children:`Decoder stage inactive or unreachable`})});let n=t&&e.shm.framesWritten===0;return L(X,{title:`Decoder`,children:[H(Z,{label:`Node`,children:e.nodeId}),H(Z,{label:`Sessions`,children:e.sessionCount}),L(Z,{label:`SHM frames`,children:[H(`span`,{className:n?`text-danger font-semibold`:``,children:e.shm.framesWritten}),H(`span`,{className:`text-foreground-subtle`,children:` written`})]}),L(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&L(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),L(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&H(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}I();var lr=`pipeline-orchestrator`,ur={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},dr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function fr({problems:e}){return H(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>L(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[H(qe,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),H(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function pr({deviceId:e,name:t,online:n,status:r,live:i,onlineNodes:a}){let o=B(),{data:s}=te({addonId:lr,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:c}=f({deviceId:e},{staleTime:3e4}),u=R(()=>qn(s),[s]),d=R(()=>c===void 0?void 0:Jn(c.steps),[c]),p=R(()=>r===void 0?[]:Vn(r),[r]),m=()=>{o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},h=re({onSuccess:m}),g=l({onSuccess:m}),_=t=>{t===`auto`?g.mutate({deviceId:e}):h.mutate({deviceId:e,agentNodeId:t})},v=r===void 0?`idle`:Yn(r),y=p.some(e=>e.severity===`error`),b=p.length>0,x=y?`border-danger/50`:b?`border-warning/40`:`border-border`;return L(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${x} bg-background overflow-hidden`,children:[L(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[H(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${y?`bg-danger`:ur[v]}`,title:y?`Error`:dr[v],"aria-label":y?`Error`:dr[v],role:`img`}),H(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),L(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&H(Q,{tone:`danger`,children:`offline`}),L(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[u.detectionMode!==null&&H(Q,{tone:u.detectionMode===`disabled`?`warning`:u.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:u.detectionMode===`disabled`?`detection off`:u.detectionMode}),r?.recording!=null&&(r.recording.active?L(Q,{tone:`danger`,title:`Recording (${r.recording.mode})`,children:[H(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):r.recording.mode!==`off`&&L(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,r.recording.mode]}))]})]}),p.length>0&&H(fr,{problems:p}),r===void 0?H(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`}):L(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[H($n,{assignment:r.assignment,settings:u,onlineNodes:a,pinPending:h.isPending||g.isPending,onDetectionPinChange:_}),H(or,{detection:r.detection,live:i,detectionMode:u.detectionMode,modeOverridden:u.overriddenKeys.has(`detectionMode`)}),H(ir,{steps:d,audioModelId:c?.audio?.modelId??null,audioEnabled:r.audio?.enabled??c?.audio?.enabled??null,audioMode:u.audioMode}),H(rr,{streams:r.source.streams,brokerProfiles:r.broker?.profiles,settings:u,motionEnabled:r.motion?.enabled??null,motionFpsLive:r.motion?.fps??null}),H(sr,{broker:r.broker}),H(cr,{decoder:r.decoder,detectionActive:r.detection?.phase===`active`})]})]})}I();var mr=5e3,hr=1e4,gr=5e3;function _r(e){let t=B(),{data:n,isLoading:r}=xe(),{data:i,isLoading:a}=D({},{refetchInterval:mr}),{nodes:o}=_();U(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[s,c]=V(new Map);y(_e.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&c(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),U(()=>{if(s.size===0)return;let e=setInterval(()=>{c(e=>{let t=Date.now()-hr,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},gr);return()=>clearInterval(e)},[s.size]);let l=R(()=>{let e=new Map;for(let t of i??[])e.set(t.deviceId,t);return e},[i]);return{rows:R(()=>(n??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:l.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[n,l]),liveMetrics:s,onlineNodes:R(()=>(o??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[o]),isLoading:r||a}}I();function vr({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:r,isLoading:i}=_r(e),a=R(()=>[...t.map(e=>{let t=e.status===void 0?[]:Vn(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[t]),o=R(()=>{let e=0,t=0;for(let r of a)(r.errorCount>0||r.warningCount>0)&&(t+=1),(n.get(r.row.deviceId)?.phase??r.row.status?.detection?.phase)===`active`&&(e+=1);return{total:a.length,active:e,issues:t}},[a,n]);return i&&t.length===0?H(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?H(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):H(`div`,{className:`h-full overflow-y-auto`,children:L(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[L(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[L(`span`,{children:[H(`span`,{className:`font-semibold text-foreground`,children:o.total}),` cameras`]}),L(`span`,{children:[H(`span`,{className:`font-semibold text-success`,children:o.active}),` actively inferring`]}),L(`span`,{children:[H(`span`,{className:`font-semibold ${o.issues>0?`text-danger`:`text-foreground`}`,children:o.issues}),` `,`with issues`]}),H(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),a.map(({row:e})=>H(pr,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:r},e.deviceId))]})})}I();var yr=`__cluster__`;function br(e){return e===`cameras`?`cameras`:`nodes`}function xr(){let[e,t]=Be(),n=br(e.get(`view`)),r=e.get(`node`)??`__cluster__`,[i,a]=V(0),[o,s]=V(!1);return U(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:yr},{replace:!0})},[n,e,t]),L(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[L(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[L(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[H(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),H(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),L(`button`,{type:`button`,onClick:()=>a(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[H(Ne,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),n===`nodes`&&L(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[L(`span`,{children:[o?`Hide`:`Show`,` node list`]}),H(ze,{className:[`h-4 w-4 transition-transform`,o?`rotate-180`:``].join(` `)})]}),H(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?L(z,{children:[H(`aside`,{className:[o?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:H(dt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),s(!1)},refreshToken:i})}),H(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?H(Bn,{refreshToken:i}):H(en,{nodeId:r,refreshToken:i})})]}):H(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:H(vr,{refreshToken:i})})})]})}export{xr as PipelinePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as e}from"./index-PRd5ZDug.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as e}from"./index-PRd5ZDug.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]);export{t};
|