@camstack/addon-admin-ui 1.1.25 → 1.1.27
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-nxOBMjA5.js → AddLocationWizard-CINm21H1.js} +1 -1
- package/dist/assets/{AddonCollectionPage-CrIh5g8-.js → AddonCollectionPage-BkUO0Tru.js} +1 -1
- package/dist/assets/{Addons-DN9Lxrok.js → Addons-6GwyCrFZ.js} +1 -1
- package/dist/assets/{AdminTabs-DZ_jxB9c.js → AdminTabs-mgvEpBDZ.js} +1 -1
- package/dist/assets/{BrokerForm-DXkhYPiN.js → BrokerForm-1o4dgBsn.js} +1 -1
- package/dist/assets/{Capabilities-DfS2xLIB.js → Capabilities-Hll85kIK.js} +1 -1
- package/dist/assets/{CapabilityBadges-DJIPro8S.js → CapabilityBadges-D7EsQrNT.js} +1 -1
- package/dist/assets/{Cluster-CLVfnrQj.js → Cluster-J7bWxCyF.js} +1 -1
- package/dist/assets/{Dashboard-DellJ1bd.js → Dashboard-CJnGC7ye.js} +1 -1
- package/dist/assets/{Data-DYlhiJL8.js → Data-CcoeTmaj.js} +1 -1
- package/dist/assets/{DetectionIntelligence-DORusa41.js → DetectionIntelligence-DV0-5hhZ.js} +1 -1
- package/dist/assets/{DeviceDetail-CqVOgzNP.js → DeviceDetail-Cg4_si18.js} +1 -1
- package/dist/assets/{Devices-Bj_pD2M6.js → Devices-BetTA0QM.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-CanuO_TA.js → EmbedPlayerPage-DC8HQG9A.js} +1 -1
- package/dist/assets/{FormBuilder-BYpwuMQM.js → FormBuilder-CL6dlXwQ.js} +1 -1
- package/dist/assets/{Identity-D1q3Vjy5.js → Identity-Cnr-q0hs.js} +1 -1
- package/dist/assets/{IntegrationDetail-Dj2pVbGK.js → IntegrationDetail-CyVsgPEp.js} +1 -1
- package/dist/assets/{Integrations-pQp1qzWx.js → Integrations-B9NKf_18.js} +1 -1
- package/dist/assets/{Integrations-CG5wA0Pv.js → Integrations-m0TAjBFs.js} +1 -1
- package/dist/assets/{Logs-t2ZIKJm-.js → Logs-NBZRysED.js} +1 -1
- package/dist/assets/{MotionZonesSettings-Cr5A0bd3.js → MotionZonesSettings-XX_gd-OU.js} +1 -1
- package/dist/assets/{MyAccess-FV_YMz55.js → MyAccess-MnFNVCPV.js} +1 -1
- package/dist/assets/{Network-C-IkVtu4.js → Network-BnuGSw90.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-2bieWYkX.js → NodeAddonsSettingsPanel-5OLeCWWK.js} +1 -1
- package/dist/assets/{NotificationTargets-Bw5180qn.js → NotificationTargets-DcnKusHA.js} +1 -1
- package/dist/assets/{Pipeline-5q0nJito.js → Pipeline-Dl9S29Wb.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DYFTw_Gn.js → PrivacyMaskSettings-BdV7p1W_.js} +1 -1
- package/dist/assets/{ProviderIcon-B7zraaHo.js → ProviderIcon-AXlCHsTd.js} +1 -1
- package/dist/assets/{ScanNetworkModal-2v8SY7yw.js → ScanNetworkModal-tDFKEL2L.js} +1 -1
- package/dist/assets/{Settings-DCkdkh9Q.js → Settings-Cq9lEA2q.js} +1 -1
- package/dist/assets/{Showroom-CqLwW4Ya.js → Showroom-Bgf-mV2W.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DTfChhSB.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CUYaV0wb.js} +1 -1
- package/dist/assets/circle-check-big-6ez5bWMa.js +1 -0
- package/dist/assets/{copy-u60IhaFr.js → copy-BwY737s-.js} +1 -1
- package/dist/assets/{dist-DBwmv4oI.js → dist-7sVMyhkP.js} +1 -1
- package/dist/assets/dist-Bp7iSHw-.js +7 -0
- package/dist/assets/{download-CFV7QDL_.js → download-CDTSR7Xa.js} +1 -1
- package/dist/assets/{hostInit-BGdKqsfs.js → hostInit-C_DOKr_T.js} +1 -1
- package/dist/assets/{index-BCcCsZl6.js → index-Da6GKRLl.js} +3 -3
- package/dist/assets/{index-rzKyP5Rc.css → index-DgnLfnMW.css} +1 -1
- package/dist/assets/{key-round-C4dxiYfZ.js → key-round-CRs7h4JP.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-1b9f590c.js → mf-entry-bootstrap-0-f15090ce.js} +2 -2
- package/dist/assets/{pencil-BuYLF-Dt.js → pencil-DR7yGacK.js} +1 -1
- package/dist/assets/{player-overlays-CpxC1ZVd.js → player-overlays-CqpHdvYF.js} +1 -1
- package/dist/assets/plus-CekuJPnw.js +1 -0
- package/dist/assets/{radio-D0DYybFo.js → radio-Bzq_SNgq.js} +1 -1
- package/dist/assets/{refresh-cw-D3Nl7ilp.js → refresh-cw-DH7JcsAT.js} +1 -1
- package/dist/assets/remoteEntry-DCvysifo.js +1 -0
- package/dist/assets/{rotate-ccw-BlNTonpM.js → rotate-ccw-C9Gcb3tJ.js} +1 -1
- package/dist/assets/rotate-cw-CTrqUHcp.js +1 -0
- package/dist/assets/search-B5TMrljD.js +1 -0
- package/dist/assets/{server-CjSdmPve.js → server-Crr45iTm.js} +1 -1
- package/dist/assets/{sparkles-Cgha8FyL.js → sparkles-C5A0sFZJ.js} +1 -1
- package/dist/assets/{square-check-big-BP3iBLFG.js → square-check-big-B8Q-LJXA.js} +1 -1
- package/dist/assets/square-jObXvdFU.js +1 -0
- package/dist/assets/{src-ypI5eXyJ.js → src-9Nw_7MUt.js} +10 -10
- package/dist/assets/src-DYcadIAu.js +7 -0
- package/dist/assets/{upload-Dz-5-BUh.js → upload-BWN1zN1a.js} +1 -1
- package/dist/assets/{use-persisted-flow-layout-trU12L8v.js → use-persisted-flow-layout-DuQZXkHq.js} +1 -1
- package/dist/assets/{useDevice-CAFOrYD_.js → useDevice-LyxwBrYX.js} +1 -1
- package/dist/assets/{useEventInvalidation-CJ7VfCpl.js → useEventInvalidation-CoNLHhyv.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D--9iyFd.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BMXZuPDZ.js} +2 -2
- package/dist/assets/{wifi-BGbntemX.js → wifi-G6nDQGOi.js} +1 -1
- package/dist/assets/{zap-D-2xLc5Z.js → zap-JlTWX6I9.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +39 -2
- package/package.json +1 -1
- package/dist/assets/circle-check-big-CztQkuEc.js +0 -1
- package/dist/assets/dist-BBSYPQfM.js +0 -7
- package/dist/assets/plus-Ctxyu4I_.js +0 -1
- package/dist/assets/remoteEntry-DWYulF9l.js +0 -1
- package/dist/assets/rotate-cw-DybW6ijV.js +0 -1
- package/dist/assets/search-BtGNzHJL.js +0 -1
- package/dist/assets/square-C2kfS0ug.js +0 -1
- package/dist/assets/src-BB7sQJiE.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ca as e,Da as t,Oa as n,S as r,Sa as i,Ta as a,Zi as o,ba as s,ka as c,wa as l,ya as u}from"./src-ypI5eXyJ.js";import{Q as d,S as f,W as p,a as m,q as h,t as g,x as _}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as v}from"./player-overlays-CpxC1ZVd.js";import{t as y}from"./circle-check-big-CztQkuEc.js";import{t as b}from"./pencil-BuYLF-Dt.js";import{t as x}from"./plus-Ctxyu4I_.js";import{t as S}from"./search-BtGNzHJL.js";import{R as C,V as w,j as T,s as E,x as D}from"./index-BCcCsZl6.js";import{t as O}from"./AdminPage-BwmGKnRf.js";var k=w(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]);d();var A=e=>typeof e==`string`&&e.length>0;function j(e){return{levels:e.levels,formats:e.format,bodyMaxLen:e.bodyMaxLen,attachmentSlots:e.attachments.mediaTypes,attachmentMode:e.attachments.mode,attachmentMax:e.attachments.max,attachmentMaxBytes:e.attachments.maxBytes,maxActions:e.actions,showActions:e.actions>0,showClickUrl:e.clickUrl,showSound:e.sound,showTtl:e.ttl,showTag:!0}}function M(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function N(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];A(i)&&n.push({mediaType:r,url:i})}return n}function P(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=A(r.label),i=A(r.url);!t&&!i||n.push({id:`test-${n.length+1}`,label:t?r.label:`Action ${n.length+1}`,...i?{url:r.url}:{}})}return n}function F(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=N(e,t.attachmentUrls),i=P(e,t.actions),a=e.ttl&&A(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:M(e,t.format),priority:I(t.priority),...A(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&A(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&A(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...A(t.tag)?{tag:t.tag}:{}}}function I(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function L(e){return e.levels.find(e=>e.flags?.critical===!0)||e.levels.filter(e=>typeof e.ordinal==`number`).sort((e,t)=>t.ordinal-e.ordinal)[0]}function R(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var z={image:`https://example.com/sample.jpg`,video:`https://example.com/sample.mp4`,gif:`https://example.com/sample.gif`,audio:`https://example.com/sample.mp3`,icon:`https://example.com/icon.png`};function B(e,t){let n=R(e);switch(t){case`minimal`:return{...n,body:`Test notification`};case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)};case`critical`:{let t=L(e);return{...n,body:`Critical test notification`,priority:5,level:t?.id??``}}case`everything`:{let t={},n=0;for(let r of e.attachments.mediaTypes){if(n>=e.attachments.max)break;t[r]=z[r],n+=1}let r=Array.from({length:e.actions},(e,t)=>({label:`Action ${t+1}`,url:`https://example.com/action/${t+1}`}));return{level:``,priority:4,format:e.format.includes(`markdown`)?`markdown`:e.format.includes(`html`)?`html`:e.format[0]??`text`,title:`Everything the kind supports`,body:`This sample fills every control the kind advertises.`,attachmentUrls:t,actions:r,clickUrl:e.clickUrl?`https://example.com/open`:``,sound:e.sound?`default`:``,ttl:e.ttl?`3600`:``,tag:`camstack-test`}}}}var V=[{id:`minimal`,label:`Minimal (body only)`},{id:`everything`,label:`Everything supported`},{id:`overflow`,label:`Overflow`},{id:`critical`,label:`Critical`}],H=`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,U=`block text-[11px] font-medium text-foreground mb-1`;function W({target:t,kind:r,open:a,onClose:o}){let d=v(),m=p(()=>j(r.caps),[r.caps]),[y,b]=h(()=>R(r.caps)),[x,S]=h(null),C=p(()=>F(r.caps,y),[r.caps,y]),w=y.body.length,T=w>m.bodyMaxLen,E=e=>b(t=>({...t,...e})),O=g({mutationFn:()=>d.trpcClient.notificationOutput.testTarget.mutate({addonId:t.addonId,targetId:t.id,sample:F(r.caps,y)}),onMutate:()=>S(null),onSuccess:e=>S(e),onError:e=>S({success:!1,error:e instanceof Error?e.message:`Test failed`})}),A=e=>{b(B(r.caps,e)),S(null)},M=(e,t,n)=>{let r=y.actions.length>0?[...y.actions]:[];for(;r.length<=e;)r.push({label:``,url:``});r[e]={...r[e],[t]:n},E({actions:r})};return _(u,{open:a,onOpenChange:e=>!e&&o(),children:f(s,{width:`lg`,className:`!max-w-2xl`,children:[_(e,{children:f(l,{children:[`Test "`,t.name,`" (`,r.label,`)`]})}),f(`div`,{className:`space-y-4 max-h-[60vh] overflow-y-auto pr-1`,children:[_(`div`,{className:`flex flex-wrap gap-1.5`,children:V.map(e=>_(c,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>A(e.id),children:e.label},e.id))}),f(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m.levels.length>0&&f(`div`,{children:[_(`label`,{className:U,children:`Level`}),f(`select`,{className:H,value:y.level,onChange:e=>E({level:e.target.value}),children:[_(`option`,{value:``,children:`— derive from priority —`}),m.levels.map(e=>f(`option`,{value:e.id,children:[e.label,e.ordinal===null?` (qualitative)`:` (p${e.ordinal})`]},e.id))]}),(()=>{let e=m.levels.find(e=>e.id===y.level);return e?f(`div`,{className:`mt-1 space-y-1`,children:[e.description&&_(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.description}),f(`div`,{className:`flex flex-wrap gap-1`,children:[e.flags?.critical&&_(n,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&_(n,{variant:`info`,children:`silent`}),e.flags?.noPush&&_(n,{variant:`warning`,children:`no-push`})]}),e.requires&&e.requires.length>0&&f(`p`,{className:`text-[10px] text-warning`,children:[`Requires target config: `,e.requires.join(`, `)]})]}):null})()]}),f(`div`,{children:[f(`label`,{className:U,children:[`Priority (ordinal): `,y.priority]}),_(`input`,{type:`range`,min:1,max:5,step:1,value:y.priority,onChange:e=>E({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),m.formats.length>0&&f(`div`,{children:[_(`label`,{className:U,children:`Format`}),_(`div`,{className:`flex flex-wrap gap-2`,children:m.formats.map(e=>f(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[_(`input`,{type:`radio`,name:`format`,className:`accent-primary`,checked:y.format===e,onChange:()=>E({format:e})}),e]},e))})]}),f(`div`,{children:[_(`label`,{className:U,children:`Title`}),_(`input`,{className:H,value:y.title,onChange:e=>E({title:e.target.value})})]}),f(`div`,{children:[f(`label`,{className:U,children:[`Body`,` `,f(`span`,{className:T?`text-danger`:`text-foreground-subtle`,children:[`(`,w,`/`,m.bodyMaxLen,T?` — overflow`:``,`)`]})]}),_(`textarea`,{className:`${H} min-h-[80px] resize-y`,value:y.body,onChange:e=>E({body:e.target.value})})]}),m.attachmentSlots.length>0&&f(`div`,{children:[f(`label`,{className:U,children:[`Attachments`,` `,f(`span`,{className:`text-foreground-subtle`,children:[`(mode: `,m.attachmentMode,`, max `,m.attachmentMax,m.attachmentMaxBytes?`, ≤${Math.round(m.attachmentMaxBytes/1024/1024)}MB`:``,`)`]})]}),_(`div`,{className:`space-y-1.5`,children:m.attachmentSlots.map(e=>f(`div`,{className:`flex items-center gap-2`,children:[_(`span`,{className:`text-[10px] w-12 shrink-0 text-foreground-subtle`,children:e}),_(`input`,{className:H,placeholder:`${e} URL`,value:y.attachmentUrls[e]??``,onChange:t=>E({attachmentUrls:{...y.attachmentUrls,[e]:t.target.value}})})]},e))})]}),m.showActions&&f(`div`,{children:[f(`label`,{className:U,children:[`Actions (up to `,m.maxActions,`)`]}),_(`div`,{className:`space-y-1.5`,children:Array.from({length:Math.min(m.maxActions,3)},(e,t)=>f(`div`,{className:`flex items-center gap-2`,children:[_(`input`,{className:H,placeholder:`label`,value:y.actions[t]?.label??``,onChange:e=>M(t,`label`,e.target.value)}),_(`input`,{className:H,placeholder:`url`,value:y.actions[t]?.url??``,onChange:e=>M(t,`url`,e.target.value)})]},t))})]}),f(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m.showClickUrl&&f(`div`,{children:[_(`label`,{className:U,children:`Click URL`}),_(`input`,{className:H,value:y.clickUrl,onChange:e=>E({clickUrl:e.target.value})})]}),m.showSound&&f(`div`,{children:[_(`label`,{className:U,children:`Sound`}),_(`input`,{className:H,value:y.sound,onChange:e=>E({sound:e.target.value})})]}),m.showTtl&&f(`div`,{children:[_(`label`,{className:U,children:`TTL (seconds)`}),_(`input`,{className:H,type:`number`,value:y.ttl,onChange:e=>E({ttl:e.target.value})})]}),m.showTag&&f(`div`,{children:[_(`label`,{className:U,children:`Tag`}),_(`input`,{className:H,value:y.tag,onChange:e=>E({tag:e.target.value})})]})]}),x&&_(G,{result:x}),f(`details`,{className:`text-[10px]`,children:[_(`summary`,{className:`cursor-pointer text-foreground-subtle`,children:`Payload preview`}),_(`pre`,{className:`mt-1 overflow-x-auto rounded bg-surface p-2 text-foreground-subtle`,children:JSON.stringify(C,null,2)})]})]}),f(i,{children:[_(c,{variant:`secondary`,size:`sm`,type:`button`,onClick:o,children:`Close`}),f(c,{size:`sm`,type:`button`,disabled:O.isPending||y.body.length===0,onClick:()=>O.mutate(),children:[O.isPending?_(D,{className:`h-3.5 w-3.5 animate-spin`}):_(k,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function G({result:e}){let t=e.renderedAs;return f(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e.success?`border-success/40 bg-success/10`:`border-danger/40 bg-danger/10`}`,"data-testid":`test-result`,children:[f(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.success?_(y,{className:`h-3.5 w-3.5 text-success`}):_(T,{className:`h-3.5 w-3.5 text-danger`}),_(`span`,{children:e.success?`Delivered`:`Failed`})]}),e.error&&_(`p`,{className:`mt-1 text-danger`,children:e.error}),t&&f(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle`,children:[_(`dt`,{children:`Resolved level`}),_(`dd`,{className:`text-foreground`,children:t.level}),_(`dt`,{children:`Format sent`}),_(`dd`,{className:`text-foreground`,children:t.format}),_(`dt`,{children:`Attachments sent`}),_(`dd`,{className:`text-foreground`,children:t.attachmentsSent}),_(`dt`,{children:`Actions sent`}),_(`dd`,{className:`text-foreground`,children:t.actionsSent}),_(`dt`,{children:`Truncated`}),_(`dd`,{className:`text-foreground`,children:t.truncated?`yes`:`no`}),_(`dt`,{children:`Dropped`}),_(`dd`,{className:`text-foreground`,children:t.dropped.length>0?t.dropped.join(`, `):`—`})]})]})}function K(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.addonId);e?e.push(r):(n.set(r.addonId,[r]),t.push(r.addonId))}return t.map(e=>({addonId:e,kinds:n.get(e)??[]}))}function q(e){let t=[],n=e=>{for(let r of e){if(r.type===`password`){t.push(r.key);continue}if(r.type===`group`){n(r.fields);continue}if(r.type===`sub-tabs`)for(let e of r.tabs)n(e.fields)}};for(let t of e.sections)n(t.fields);return t}function J(e,t,n){let r=new Set(n),i={};for(let[n,a]of Object.entries(e)){if(!r.has(n)){i[n]=a;continue}a==null||a===``||a!==t[n]&&(i[n]=a)}return i}function Y(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))r[t]=n.has(t)?``:i;return r}d();var X=[`notificationOutput`,`listTargets`],Z=[`notificationOutput`,`listTargetKinds`];function Q(){let e=v(),[r,i]=h({mode:`closed`}),[s,l]=h(null),u=m({queryKey:X,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),d=m({queryKey:Z,queryFn:async()=>(await e.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),y=p(()=>d.data??[],[d.data]),S=p(()=>{let e=new Map;for(let t of y)e.set(t.kind,t);return e},[y]),w=g({mutationFn:t=>e.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:t.target.addonId,targetId:t.target.id,enabled:t.enabled}),onSuccess:()=>void u.refetch()}),T=g({mutationFn:t=>e.trpcClient.notificationOutput.deleteTarget.mutate({addonId:t.addonId,targetId:t.id}),onSuccess:()=>void u.refetch()}),A=s?S.get(s.kind):void 0;return f(O,{icon:C,title:`Notification Targets`,subtitle:`Deliver notifications to ntfy, Pushover, Telegram, Home Assistant and more. Each target's kind declares its capabilities; the test panel shows exactly what a message degrades to.`,actions:f(c,{size:`sm`,type:`button`,onClick:()=>i({mode:`pick-kind`}),children:[_(x,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[u.isLoading&&_(`div`,{className:`flex items-center justify-center py-16`,children:_(D,{className:`h-6 w-6 animate-spin text-primary`})}),u.isError&&!u.isLoading&&_(o,{title:`Failed to load targets`,message:u.error instanceof Error?u.error.message:`Unknown error`,onRetry:()=>void u.refetch()}),!u.isLoading&&!u.isError&&(u.data??[]).length===0&&_(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification targets yet. Click "Add target" to configure one.`}),(u.data??[]).length>0&&_(t,{children:_(`ul`,{className:`divide-y divide-border`,children:(u.data??[]).map(e=>{let t=S.get(e.kind);return f(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[_(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface text-xs`,title:t?.label??e.kind,children:t?.icon??`🔔`}),f(`div`,{className:`min-w-0 flex-1`,children:[_(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),_(`div`,{className:`text-[11px] text-foreground-subtle`,children:t?.label??e.kind})]}),!e.enabled&&_(n,{variant:`warning`,children:`disabled`}),_(a,{checked:e.enabled,onCheckedChange:t=>w.mutate({target:e,enabled:t}),"aria-label":`toggle ${e.name}`}),_(c,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>l(e),title:`Test`,children:_(k,{className:`h-3.5 w-3.5`})}),_(c,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>t&&i({mode:`form`,kind:t,target:e}),title:`Edit`,children:_(b,{className:`h-3.5 w-3.5`})}),_(c,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>T.mutate(e),title:`Delete`,children:_(E,{className:`h-3.5 w-3.5 text-danger`})})]},e.id)})})}),r.mode===`pick-kind`&&_($,{kinds:y,onCancel:()=>i({mode:`closed`}),onPick:e=>i({mode:`form`,kind:e,target:null})}),r.mode===`form`&&_(ee,{kind:r.kind,target:r.target,onCancel:()=>i({mode:`closed`}),onSaved:()=>{i({mode:`closed`}),u.refetch()}}),s&&A&&_(W,{target:s,kind:A,open:!0,onClose:()=>l(null)})]})}function $({kinds:e,onPick:r,onCancel:i}){let a=p(()=>K(e),[e]);return f(t,{className:`p-4 space-y-4`,children:[f(`div`,{className:`flex items-center justify-between`,children:[_(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Choose a notification kind`}),_(c,{size:`sm`,variant:`ghost`,type:`button`,onClick:i,children:`Cancel`})]}),a.length===0&&_(`p`,{className:`text-xs text-foreground-subtle`,children:`No notification providers are installed. Install the notifiers addon (or connect Home Assistant) to add targets.`}),a.map(e=>f(`div`,{children:[_(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:e.addonId}),_(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2`,children:e.kinds.map(t=>f(`button`,{type:`button`,onClick:()=>r(t),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors`,children:[_(`span`,{className:`text-lg`,children:t.icon}),_(`span`,{className:`font-medium text-foreground`,children:t.label}),t.supportsDiscovery&&_(n,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${t.kind}`))})]},e.addonId))]})}function ee({kind:e,target:n,onSaved:i,onCancel:a}){let o=v(),s=p(()=>q(e.configSchema),[e.configSchema]),l=p(()=>n?.config??{},[n]),[u,d]=h(n?.name??e.label),[m,y]=h(()=>n?Y(n.config,s):{}),[b,x]=h(null),[C,w]=h(null),T=g({mutationFn:()=>o.trpcClient.notificationOutput.discoverTargets.query({addonId:e.addonId,kind:e.kind,config:m}),onSuccess:e=>x(e),onError:e=>w(e instanceof Error?e.message:`Discovery failed`)}),E=g({mutationFn:()=>{let t=J(m,l,s),r={id:n?.id??`${e.kind}-${Date.now()}`,name:u,kind:e.kind,addonId:e.addonId,enabled:n?.enabled??!0,config:t};return o.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:r})},onSuccess:i,onError:e=>w(e instanceof Error?e.message:`Save failed`)}),O=e=>{d(e.suggestedName),y(t=>({...t,...e.config})),x(null)};return f(t,{className:`p-4 space-y-4`,children:[f(`div`,{className:`flex items-center justify-between`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[_(`span`,{className:`text-lg`,children:e.icon}),n?`Edit ${n.name}`:`Add ${e.label} target`]}),_(c,{size:`sm`,variant:`ghost`,type:`button`,onClick:a,children:`Cancel`})]}),C&&_(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:C}),f(`div`,{children:[_(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),_(`input`,{className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,value:u,onChange:e=>d(e.target.value)})]}),e.supportsDiscovery&&f(`div`,{className:`space-y-2`,children:[f(c,{size:`sm`,variant:`outline`,type:`button`,disabled:T.isPending,onClick:()=>{w(null),T.mutate()},children:[T.isPending?_(D,{className:`h-3.5 w-3.5 animate-spin`}):_(S,{className:`h-3.5 w-3.5`}),`Discover`]}),b&&b.length===0&&_(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No candidates discovered.`}),b&&b.length>0&&_(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:b.map((e,t)=>f(`button`,{type:`button`,onClick:()=>O(e),className:`flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-surface-hover`,children:[_(`span`,{className:`text-foreground`,children:e.suggestedName}),_(`span`,{className:`text-[10px] text-primary`,children:`use`})]},`${e.suggestedName}-${t}`))})]}),s.length>0&&n&&_(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Secret fields are hidden. Leave them blank to keep the stored value; type a new value to replace it.`}),_(r,{schema:e.configSchema,values:m,onChange:y}),f(`div`,{className:`flex justify-end gap-2`,children:[_(c,{variant:`secondary`,size:`sm`,type:`button`,onClick:a,children:`Cancel`}),f(c,{size:`sm`,type:`button`,disabled:E.isPending||u.trim().length===0,onClick:()=>{w(null),E.mutate()},children:[E.isPending&&_(D,{className:`h-3.5 w-3.5 animate-spin`}),n?`Save changes`:`Create target`]})]})]})}export{Q as NotificationTargetsPage,Q as default};
|
|
1
|
+
import{Ca as e,Da as t,Oa as n,S as r,Sa as i,Ta as a,Zi as o,ba as s,ka as c,wa as l,ya as u}from"./src-9Nw_7MUt.js";import{Q as d,S as f,W as p,a as m,q as h,t as g,x as _}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as v}from"./player-overlays-CqpHdvYF.js";import{t as y}from"./circle-check-big-6ez5bWMa.js";import{t as b}from"./pencil-DR7yGacK.js";import{t as x}from"./plus-CekuJPnw.js";import{t as S}from"./search-B5TMrljD.js";import{R as C,V as w,j as T,s as E,x as D}from"./index-Da6GKRLl.js";import{t as O}from"./AdminPage-BwmGKnRf.js";var k=w(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]);d();var A=e=>typeof e==`string`&&e.length>0;function j(e){return{levels:e.levels,formats:e.format,bodyMaxLen:e.bodyMaxLen,attachmentSlots:e.attachments.mediaTypes,attachmentMode:e.attachments.mode,attachmentMax:e.attachments.max,attachmentMaxBytes:e.attachments.maxBytes,maxActions:e.actions,showActions:e.actions>0,showClickUrl:e.clickUrl,showSound:e.sound,showTtl:e.ttl,showTag:!0}}function M(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function N(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];A(i)&&n.push({mediaType:r,url:i})}return n}function P(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=A(r.label),i=A(r.url);!t&&!i||n.push({id:`test-${n.length+1}`,label:t?r.label:`Action ${n.length+1}`,...i?{url:r.url}:{}})}return n}function F(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=N(e,t.attachmentUrls),i=P(e,t.actions),a=e.ttl&&A(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:M(e,t.format),priority:I(t.priority),...A(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&A(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&A(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...A(t.tag)?{tag:t.tag}:{}}}function I(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function L(e){return e.levels.find(e=>e.flags?.critical===!0)||e.levels.filter(e=>typeof e.ordinal==`number`).sort((e,t)=>t.ordinal-e.ordinal)[0]}function R(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var z={image:`https://example.com/sample.jpg`,video:`https://example.com/sample.mp4`,gif:`https://example.com/sample.gif`,audio:`https://example.com/sample.mp3`,icon:`https://example.com/icon.png`};function B(e,t){let n=R(e);switch(t){case`minimal`:return{...n,body:`Test notification`};case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)};case`critical`:{let t=L(e);return{...n,body:`Critical test notification`,priority:5,level:t?.id??``}}case`everything`:{let t={},n=0;for(let r of e.attachments.mediaTypes){if(n>=e.attachments.max)break;t[r]=z[r],n+=1}let r=Array.from({length:e.actions},(e,t)=>({label:`Action ${t+1}`,url:`https://example.com/action/${t+1}`}));return{level:``,priority:4,format:e.format.includes(`markdown`)?`markdown`:e.format.includes(`html`)?`html`:e.format[0]??`text`,title:`Everything the kind supports`,body:`This sample fills every control the kind advertises.`,attachmentUrls:t,actions:r,clickUrl:e.clickUrl?`https://example.com/open`:``,sound:e.sound?`default`:``,ttl:e.ttl?`3600`:``,tag:`camstack-test`}}}}var V=[{id:`minimal`,label:`Minimal (body only)`},{id:`everything`,label:`Everything supported`},{id:`overflow`,label:`Overflow`},{id:`critical`,label:`Critical`}],H=`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,U=`block text-[11px] font-medium text-foreground mb-1`;function W({target:t,kind:r,open:a,onClose:o}){let d=v(),m=p(()=>j(r.caps),[r.caps]),[y,b]=h(()=>R(r.caps)),[x,S]=h(null),C=p(()=>F(r.caps,y),[r.caps,y]),w=y.body.length,T=w>m.bodyMaxLen,E=e=>b(t=>({...t,...e})),O=g({mutationFn:()=>d.trpcClient.notificationOutput.testTarget.mutate({addonId:t.addonId,targetId:t.id,sample:F(r.caps,y)}),onMutate:()=>S(null),onSuccess:e=>S(e),onError:e=>S({success:!1,error:e instanceof Error?e.message:`Test failed`})}),A=e=>{b(B(r.caps,e)),S(null)},M=(e,t,n)=>{let r=y.actions.length>0?[...y.actions]:[];for(;r.length<=e;)r.push({label:``,url:``});r[e]={...r[e],[t]:n},E({actions:r})};return _(u,{open:a,onOpenChange:e=>!e&&o(),children:f(s,{width:`lg`,className:`!max-w-2xl`,children:[_(e,{children:f(l,{children:[`Test "`,t.name,`" (`,r.label,`)`]})}),f(`div`,{className:`space-y-4 max-h-[60vh] overflow-y-auto pr-1`,children:[_(`div`,{className:`flex flex-wrap gap-1.5`,children:V.map(e=>_(c,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>A(e.id),children:e.label},e.id))}),f(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m.levels.length>0&&f(`div`,{children:[_(`label`,{className:U,children:`Level`}),f(`select`,{className:H,value:y.level,onChange:e=>E({level:e.target.value}),children:[_(`option`,{value:``,children:`— derive from priority —`}),m.levels.map(e=>f(`option`,{value:e.id,children:[e.label,e.ordinal===null?` (qualitative)`:` (p${e.ordinal})`]},e.id))]}),(()=>{let e=m.levels.find(e=>e.id===y.level);return e?f(`div`,{className:`mt-1 space-y-1`,children:[e.description&&_(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.description}),f(`div`,{className:`flex flex-wrap gap-1`,children:[e.flags?.critical&&_(n,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&_(n,{variant:`info`,children:`silent`}),e.flags?.noPush&&_(n,{variant:`warning`,children:`no-push`})]}),e.requires&&e.requires.length>0&&f(`p`,{className:`text-[10px] text-warning`,children:[`Requires target config: `,e.requires.join(`, `)]})]}):null})()]}),f(`div`,{children:[f(`label`,{className:U,children:[`Priority (ordinal): `,y.priority]}),_(`input`,{type:`range`,min:1,max:5,step:1,value:y.priority,onChange:e=>E({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),m.formats.length>0&&f(`div`,{children:[_(`label`,{className:U,children:`Format`}),_(`div`,{className:`flex flex-wrap gap-2`,children:m.formats.map(e=>f(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[_(`input`,{type:`radio`,name:`format`,className:`accent-primary`,checked:y.format===e,onChange:()=>E({format:e})}),e]},e))})]}),f(`div`,{children:[_(`label`,{className:U,children:`Title`}),_(`input`,{className:H,value:y.title,onChange:e=>E({title:e.target.value})})]}),f(`div`,{children:[f(`label`,{className:U,children:[`Body`,` `,f(`span`,{className:T?`text-danger`:`text-foreground-subtle`,children:[`(`,w,`/`,m.bodyMaxLen,T?` — overflow`:``,`)`]})]}),_(`textarea`,{className:`${H} min-h-[80px] resize-y`,value:y.body,onChange:e=>E({body:e.target.value})})]}),m.attachmentSlots.length>0&&f(`div`,{children:[f(`label`,{className:U,children:[`Attachments`,` `,f(`span`,{className:`text-foreground-subtle`,children:[`(mode: `,m.attachmentMode,`, max `,m.attachmentMax,m.attachmentMaxBytes?`, ≤${Math.round(m.attachmentMaxBytes/1024/1024)}MB`:``,`)`]})]}),_(`div`,{className:`space-y-1.5`,children:m.attachmentSlots.map(e=>f(`div`,{className:`flex items-center gap-2`,children:[_(`span`,{className:`text-[10px] w-12 shrink-0 text-foreground-subtle`,children:e}),_(`input`,{className:H,placeholder:`${e} URL`,value:y.attachmentUrls[e]??``,onChange:t=>E({attachmentUrls:{...y.attachmentUrls,[e]:t.target.value}})})]},e))})]}),m.showActions&&f(`div`,{children:[f(`label`,{className:U,children:[`Actions (up to `,m.maxActions,`)`]}),_(`div`,{className:`space-y-1.5`,children:Array.from({length:Math.min(m.maxActions,3)},(e,t)=>f(`div`,{className:`flex items-center gap-2`,children:[_(`input`,{className:H,placeholder:`label`,value:y.actions[t]?.label??``,onChange:e=>M(t,`label`,e.target.value)}),_(`input`,{className:H,placeholder:`url`,value:y.actions[t]?.url??``,onChange:e=>M(t,`url`,e.target.value)})]},t))})]}),f(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[m.showClickUrl&&f(`div`,{children:[_(`label`,{className:U,children:`Click URL`}),_(`input`,{className:H,value:y.clickUrl,onChange:e=>E({clickUrl:e.target.value})})]}),m.showSound&&f(`div`,{children:[_(`label`,{className:U,children:`Sound`}),_(`input`,{className:H,value:y.sound,onChange:e=>E({sound:e.target.value})})]}),m.showTtl&&f(`div`,{children:[_(`label`,{className:U,children:`TTL (seconds)`}),_(`input`,{className:H,type:`number`,value:y.ttl,onChange:e=>E({ttl:e.target.value})})]}),m.showTag&&f(`div`,{children:[_(`label`,{className:U,children:`Tag`}),_(`input`,{className:H,value:y.tag,onChange:e=>E({tag:e.target.value})})]})]}),x&&_(G,{result:x}),f(`details`,{className:`text-[10px]`,children:[_(`summary`,{className:`cursor-pointer text-foreground-subtle`,children:`Payload preview`}),_(`pre`,{className:`mt-1 overflow-x-auto rounded bg-surface p-2 text-foreground-subtle`,children:JSON.stringify(C,null,2)})]})]}),f(i,{children:[_(c,{variant:`secondary`,size:`sm`,type:`button`,onClick:o,children:`Close`}),f(c,{size:`sm`,type:`button`,disabled:O.isPending||y.body.length===0,onClick:()=>O.mutate(),children:[O.isPending?_(D,{className:`h-3.5 w-3.5 animate-spin`}):_(k,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function G({result:e}){let t=e.renderedAs;return f(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e.success?`border-success/40 bg-success/10`:`border-danger/40 bg-danger/10`}`,"data-testid":`test-result`,children:[f(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.success?_(y,{className:`h-3.5 w-3.5 text-success`}):_(T,{className:`h-3.5 w-3.5 text-danger`}),_(`span`,{children:e.success?`Delivered`:`Failed`})]}),e.error&&_(`p`,{className:`mt-1 text-danger`,children:e.error}),t&&f(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle`,children:[_(`dt`,{children:`Resolved level`}),_(`dd`,{className:`text-foreground`,children:t.level}),_(`dt`,{children:`Format sent`}),_(`dd`,{className:`text-foreground`,children:t.format}),_(`dt`,{children:`Attachments sent`}),_(`dd`,{className:`text-foreground`,children:t.attachmentsSent}),_(`dt`,{children:`Actions sent`}),_(`dd`,{className:`text-foreground`,children:t.actionsSent}),_(`dt`,{children:`Truncated`}),_(`dd`,{className:`text-foreground`,children:t.truncated?`yes`:`no`}),_(`dt`,{children:`Dropped`}),_(`dd`,{className:`text-foreground`,children:t.dropped.length>0?t.dropped.join(`, `):`—`})]})]})}function K(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.addonId);e?e.push(r):(n.set(r.addonId,[r]),t.push(r.addonId))}return t.map(e=>({addonId:e,kinds:n.get(e)??[]}))}function q(e){let t=[],n=e=>{for(let r of e){if(r.type===`password`){t.push(r.key);continue}if(r.type===`group`){n(r.fields);continue}if(r.type===`sub-tabs`)for(let e of r.tabs)n(e.fields)}};for(let t of e.sections)n(t.fields);return t}function J(e,t,n){let r=new Set(n),i={};for(let[n,a]of Object.entries(e)){if(!r.has(n)){i[n]=a;continue}a==null||a===``||a!==t[n]&&(i[n]=a)}return i}function Y(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))r[t]=n.has(t)?``:i;return r}d();var X=[`notificationOutput`,`listTargets`],Z=[`notificationOutput`,`listTargetKinds`];function Q(){let e=v(),[r,i]=h({mode:`closed`}),[s,l]=h(null),u=m({queryKey:X,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),d=m({queryKey:Z,queryFn:async()=>(await e.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),y=p(()=>d.data??[],[d.data]),S=p(()=>{let e=new Map;for(let t of y)e.set(t.kind,t);return e},[y]),w=g({mutationFn:t=>e.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:t.target.addonId,targetId:t.target.id,enabled:t.enabled}),onSuccess:()=>void u.refetch()}),T=g({mutationFn:t=>e.trpcClient.notificationOutput.deleteTarget.mutate({addonId:t.addonId,targetId:t.id}),onSuccess:()=>void u.refetch()}),A=s?S.get(s.kind):void 0;return f(O,{icon:C,title:`Notification Targets`,subtitle:`Deliver notifications to ntfy, Pushover, Telegram, Home Assistant and more. Each target's kind declares its capabilities; the test panel shows exactly what a message degrades to.`,actions:f(c,{size:`sm`,type:`button`,onClick:()=>i({mode:`pick-kind`}),children:[_(x,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[u.isLoading&&_(`div`,{className:`flex items-center justify-center py-16`,children:_(D,{className:`h-6 w-6 animate-spin text-primary`})}),u.isError&&!u.isLoading&&_(o,{title:`Failed to load targets`,message:u.error instanceof Error?u.error.message:`Unknown error`,onRetry:()=>void u.refetch()}),!u.isLoading&&!u.isError&&(u.data??[]).length===0&&_(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification targets yet. Click "Add target" to configure one.`}),(u.data??[]).length>0&&_(t,{children:_(`ul`,{className:`divide-y divide-border`,children:(u.data??[]).map(e=>{let t=S.get(e.kind);return f(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[_(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface text-xs`,title:t?.label??e.kind,children:t?.icon??`🔔`}),f(`div`,{className:`min-w-0 flex-1`,children:[_(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),_(`div`,{className:`text-[11px] text-foreground-subtle`,children:t?.label??e.kind})]}),!e.enabled&&_(n,{variant:`warning`,children:`disabled`}),_(a,{checked:e.enabled,onCheckedChange:t=>w.mutate({target:e,enabled:t}),"aria-label":`toggle ${e.name}`}),_(c,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>l(e),title:`Test`,children:_(k,{className:`h-3.5 w-3.5`})}),_(c,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>t&&i({mode:`form`,kind:t,target:e}),title:`Edit`,children:_(b,{className:`h-3.5 w-3.5`})}),_(c,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>T.mutate(e),title:`Delete`,children:_(E,{className:`h-3.5 w-3.5 text-danger`})})]},e.id)})})}),r.mode===`pick-kind`&&_($,{kinds:y,onCancel:()=>i({mode:`closed`}),onPick:e=>i({mode:`form`,kind:e,target:null})}),r.mode===`form`&&_(ee,{kind:r.kind,target:r.target,onCancel:()=>i({mode:`closed`}),onSaved:()=>{i({mode:`closed`}),u.refetch()}}),s&&A&&_(W,{target:s,kind:A,open:!0,onClose:()=>l(null)})]})}function $({kinds:e,onPick:r,onCancel:i}){let a=p(()=>K(e),[e]);return f(t,{className:`p-4 space-y-4`,children:[f(`div`,{className:`flex items-center justify-between`,children:[_(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Choose a notification kind`}),_(c,{size:`sm`,variant:`ghost`,type:`button`,onClick:i,children:`Cancel`})]}),a.length===0&&_(`p`,{className:`text-xs text-foreground-subtle`,children:`No notification providers are installed. Install the notifiers addon (or connect Home Assistant) to add targets.`}),a.map(e=>f(`div`,{children:[_(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:e.addonId}),_(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2`,children:e.kinds.map(t=>f(`button`,{type:`button`,onClick:()=>r(t),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors`,children:[_(`span`,{className:`text-lg`,children:t.icon}),_(`span`,{className:`font-medium text-foreground`,children:t.label}),t.supportsDiscovery&&_(n,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${t.kind}`))})]},e.addonId))]})}function ee({kind:e,target:n,onSaved:i,onCancel:a}){let o=v(),s=p(()=>q(e.configSchema),[e.configSchema]),l=p(()=>n?.config??{},[n]),[u,d]=h(n?.name??e.label),[m,y]=h(()=>n?Y(n.config,s):{}),[b,x]=h(null),[C,w]=h(null),T=g({mutationFn:()=>o.trpcClient.notificationOutput.discoverTargets.query({addonId:e.addonId,kind:e.kind,config:m}),onSuccess:e=>x(e),onError:e=>w(e instanceof Error?e.message:`Discovery failed`)}),E=g({mutationFn:()=>{let t=J(m,l,s),r={id:n?.id??`${e.kind}-${Date.now()}`,name:u,kind:e.kind,addonId:e.addonId,enabled:n?.enabled??!0,config:t};return o.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:r})},onSuccess:i,onError:e=>w(e instanceof Error?e.message:`Save failed`)}),O=e=>{d(e.suggestedName),y(t=>({...t,...e.config})),x(null)};return f(t,{className:`p-4 space-y-4`,children:[f(`div`,{className:`flex items-center justify-between`,children:[f(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[_(`span`,{className:`text-lg`,children:e.icon}),n?`Edit ${n.name}`:`Add ${e.label} target`]}),_(c,{size:`sm`,variant:`ghost`,type:`button`,onClick:a,children:`Cancel`})]}),C&&_(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:C}),f(`div`,{children:[_(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),_(`input`,{className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,value:u,onChange:e=>d(e.target.value)})]}),e.supportsDiscovery&&f(`div`,{className:`space-y-2`,children:[f(c,{size:`sm`,variant:`outline`,type:`button`,disabled:T.isPending,onClick:()=>{w(null),T.mutate()},children:[T.isPending?_(D,{className:`h-3.5 w-3.5 animate-spin`}):_(S,{className:`h-3.5 w-3.5`}),`Discover`]}),b&&b.length===0&&_(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No candidates discovered.`}),b&&b.length>0&&_(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:b.map((e,t)=>f(`button`,{type:`button`,onClick:()=>O(e),className:`flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-surface-hover`,children:[_(`span`,{className:`text-foreground`,children:e.suggestedName}),_(`span`,{className:`text-[10px] text-primary`,children:`use`})]},`${e.suggestedName}-${t}`))})]}),s.length>0&&n&&_(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Secret fields are hidden. Leave them blank to keep the stored value; type a new value to replace it.`}),_(r,{schema:e.configSchema,values:m,onChange:y}),f(`div`,{className:`flex justify-end gap-2`,children:[_(c,{variant:`secondary`,size:`sm`,type:`button`,onClick:a,children:`Cancel`}),f(c,{size:`sm`,type:`button`,disabled:E.isPending||u.trim().length===0,onClick:()=>{w(null),E.mutate()},children:[E.isPending&&_(D,{className:`h-3.5 w-3.5 animate-spin`}),n?`Save changes`:`Create target`]})]})]})}export{Q as NotificationTargetsPage,Q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Br as e,C as t,Ci as n,Di as r,Fr as i,Gr as a,Hr as o,Ia as s,Jr as c,Kr as l,Lr as u,Oa as d,Pa as f,Qr as p,Rr as m,T as h,Ti as g,Ur as _,Vr as v,Xi as y,Xr as b,Zr as x,_ as S,_i as C,aa as w,ai as T,ca as E,ci as D,di as O,ea as k,ei as A,gi as j,it as M,la as N,na as P,oa as F,oi as I,ot as ee,qr as te,ra as L,ri as ne,si as re,ta as ie,ti as ae,ui as oe,vi as se,wi as ce,xi as le,yi as ue,zr as de}from"./src-ypI5eXyJ.js";import{I as fe,K as pe,Q as R,S as z,T as me,W as B,a as he,b as V,o as H,q as U,x as W,z as G}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as K,R as ge}from"./src-BB7sQJiE.js";import{p as _e}from"./player-overlays-CpxC1ZVd.js";import{t as ve}from"./download-CFV7QDL_.js";import{i as ye,n as be,r as xe,t as Se}from"./AddLocationWizard-nxOBMjA5.js";import{n as Ce,r as we,t as Te}from"./zap-D-2xLc5Z.js";import{t as Ee}from"./pencil-BuYLF-Dt.js";import{t as De}from"./plus-Ctxyu4I_.js";import{t as Oe}from"./refresh-cw-D3Nl7ilp.js";import{t as ke}from"./search-BtGNzHJL.js";import{t as Ae}from"./server-CjSdmPve.js";import{t as je}from"./square-check-big-BP3iBLFG.js";import{t as Me}from"./square-C2kfS0ug.js";import{A as Ne,F as Pe,G as Fe,M as Ie,P as Le,V as Re,i as ze,j as Be,k as q,o as Ve,s as He,w as Ue,x as J}from"./index-BCcCsZl6.js";import{t as We}from"./AdminPage-BwmGKnRf.js";import{r as Ge}from"./useDevice-CAFOrYD_.js";import{t as Ke}from"./useEventInvalidation-CJ7VfCpl.js";import{a as qe,i as Y,n as Je,o as X,r as Ye,s as Xe,t as Ze}from"./use-persisted-flow-layout-trU12L8v.js";import{n as Qe}from"./format-size-CO9d3C3-.js";import{t as $e}from"./NodeAddonsSettingsPanel-2bieWYkX.js";var et=Re(`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`}]]),tt=Re(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),nt=Re(`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`}]]),rt=Re(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);R();var it=`enabledDecoderNodes`,at=`enabledNodes`,ot=`enabledAudioNodes`,st=[`hub`];function ct(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function lt(e){let t=e.sections;if(!Array.isArray(t))return e;let n={};for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.fields;if(Array.isArray(t))for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.key;typeof t==`string`&&(t in n||(n[t]=e.value))}}return n}function ut(e,t,n){let r=e[t];return(ct(r)?r:st).includes(n)}function dt(e,t){if(e==null)return{decode:!0,pipeline:!0,audio:!0};let n=lt(e);return{decode:ut(n,it,t),pipeline:ut(n,at,t),audio:ut(n,ot,t)}}var ft=`pipeline-orchestrator`;function pt({selectedNodeId:e,onSelect:t,refreshToken:n}){let{data:r}=i(void 0),{data:a}=T(void 0),{data:o}=M({addonId:ft}),c=new Map;for(let e of a??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=r??[],u=l.filter(e=>e.isOnline).length,f=l.filter(e=>!e.isOnline).length;return z(`div`,{className:`flex flex-col h-full`,children:[z(`button`,{type:`button`,onClick:()=>t(tr),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:[W(Ue,{className:`h-4 w-4 flex-shrink-0`}),z(`div`,{className:`min-w-0 flex-1`,children:[W(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),W(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(n=>{let r=e===n.id,i=c.get(n.id)??0,a=n.isHub?Ae:q,l=dt(o,n.id),u=n.isOnline?null:s(Xe(n.lastSeen));return z(`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 ${r?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[W(a,{className:`h-4 w-4 flex-shrink-0`}),z(`div`,{className:`min-w-0 flex-1`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&W(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!n.isOnline&&W(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&W(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),z(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[z(`span`,{children:[n.cpuCores,` cores`]}),W(`span`,{children:`•`}),z(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),i>0&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[W(Ce,{className:`h-2.5 w-2.5`}),i]})]}),!n.isOnline&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),z(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[W(d,{variant:l.decode?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.decode?`Decode: enabled`:`Decode: not enabled (enabledDecoderNodes)`,children:`Dec`}),W(d,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (enabledNodes)`,children:`Pipe`}),W(d,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (enabledAudioNodes)`,children:`Aud`})]})]})]},n.id)})}),z(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[z(`span`,{children:[u,` online`]}),f>0&&z(`span`,{className:`text-destructive`,children:[f,` offline`]})]})]})}function mt({nodeId:e,refreshToken:t}){let{data:n}=i(void 0),r=n?.find(t=>t.id===e),a=ie(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?z(`div`,{className:`px-6 py-4 border-b border-border`,children:[z(`div`,{className:`flex items-center gap-2 mb-1`,children:[W(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?W(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):W(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&W(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),z(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[W(`span`,{children:r.cpuModel??`CPU`}),W(`span`,{children:`•`}),z(`span`,{children:[r.cpuCores,` cores`]}),W(`span`,{children:`•`}),z(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{children:[a.attachedCameras,` cameras (`,a.activeCameras,` active)`]}),W(`span`,{children:`•`}),z(`span`,{children:[a.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),W(`span`,{children:`•`}),z(`span`,{children:[`queue `,a.queueDepthTotal]}),a.hardware.hasGpu&&z(V,{children:[W(`span`,{children:`•`}),W(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):W(`div`,{className:`px-6 py-4 border-b border-border`,children:z(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function ht({refreshToken:e,nodeId:t}){let[n,r]=U(new Map),{nodes:i}=k();L(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:a}=p(void 0),o=B(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=B(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),c=B(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=B(()=>{let e=0,t=0,n=0,r=0,a=0;for(let i of s.values())e+=i.attachedCameras,t+=i.activeCameras,n+=i.totalFps,r+=i.totalInferenceWeighted,a+=i.queueDepth;let o=e>0?r/e:0;return{totalAgents:i.length,onlineAgents:i.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:a,totalFps:n}},[s,i]);if(t){let e=s.get(t);return z(`div`,{className:`@container/liveload`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),z(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[W(Z,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),W(Z,{label:`Cameras`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),W(Z,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),W(Z,{label:`Queue`,value:e?String(e.queueDepth):`—`}),W(Z,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let u=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return z(`div`,{className:`@container/liveload`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),z(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[W(Z,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),W(Z,{label:`Cameras`,value:`${l.activeCameras}/${l.attachedCameras}`}),W(Z,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),W(Z,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),W(Z,{label:`Queue depth`,value:String(l.queueDepth)})]}),W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[480px]`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[W(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),W(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),W(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),W(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),W(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),W(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),z(`tbody`,{children:[u.map(([e,t])=>z(`tr`,{className:`border-t border-border`,children:[W(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),u.length===0&&W(`tr`,{children:W(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function Z({label:e,value:t}){return z(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[W(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),W(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}R();var gt={active:!1,pinned:!1,nodeId:null,reason:``},_t=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],vt={pipeline:q,decoder:tt,audio:we},yt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function bt({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let r=H(),[i,o]=U(null),[s,c]=U(null),[u,d]=U(new Map);Ke([`pipelineOrchestrator`,`getPipelineAssignments`],_t),Ke([`pipelineOrchestrator`,`getDecoderAssignments`],_t),Ke([`pipelineOrchestrator`,`getAudioAssignments`],_t);let{data:f}=T(void 0),{data:p}=ne(void 0),{data:m}=x(void 0),{nodes:g}=k(),{data:_}=Ge();L(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&d(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),G(()=>{if(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 v=B(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),y=B(()=>{let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:v.get(e)??`Device ${e}`,pipeline:gt,decoder:gt,audio:gt};return n.set(e,r),r};for(let i of f??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``}})}for(let i of p??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,decoder:{active:e===`cluster`?!0:i.decoderNodeId===t,pinned:i.pinned,nodeId:i.decoderNodeId,reason:i.reason??``}})}for(let i of m??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,audio:{active:e===`cluster`?!0:i.nodeId===t,pinned:i.pinned,nodeId:i.nodeId,reason:`capacity`}})}let i=[...n.values()];return e===`agent`&&(i=i.filter(e=>e.pipeline.active||e.decoder.active||e.audio.active)),i.sort((e,t)=>e.deviceId-t.deviceId),i},[f,p,m,v,e,t]),b=B(()=>(g??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[g]),S=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},w=te({onSuccess:S}),E=se({onSuccess:S}),D=l({onSuccess:S}),O=C({onSuccess:S}),A=a({onSuccess:S}),M=j({onSuccess:S}),N=(e,t,n)=>{t===`pipeline`?w.mutate({deviceId:e,agentNodeId:n}):t===`decoder`?D.mutate({deviceId:e,nodeId:n}):A.mutate({deviceId:e,nodeId:n}),o(null)},P=(e,t)=>{t===`pipeline`?E.mutate({deviceId:e}):t===`decoder`?O.mutate({deviceId:e}):M.mutate({deviceId:e}),o(null)};return W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[640px]`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&W(`th`,{className:`w-6`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Camera`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Pipeline`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Decoder`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Audio`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Status`})]})}),z(`tbody`,{children:[y.map(t=>{let r=u.get(t.deviceId),a=s===t.deviceId;return z(me.Fragment,{children:[z(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&W(`td`,{className:`px-2 py-2 align-middle`,children:W(`button`,{type:`button`,onClick:()=>c(a?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":a?`Collapse broker details`:`Expand broker details`,children:W(a?Le:Ie,{className:`h-3.5 w-3.5`})})}),z(`td`,{className:`px-3 py-2 align-middle`,children:[W(`div`,{className:`text-foreground font-medium leading-tight`,children:t.deviceName}),z(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),W(xt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`pipeline`,onToggleMenu:()=>o(i?.deviceId===t.deviceId&&i.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>o(null),onMove:e=>N(t.deviceId,`pipeline`,e),onUnpin:()=>P(t.deviceId,`pipeline`)}),W(xt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`decoder`,onToggleMenu:()=>o(i?.deviceId===t.deviceId&&i.role===`decoder`?null:{deviceId:t.deviceId,role:`decoder`}),onCloseMenu:()=>o(null),onMove:e=>N(t.deviceId,`decoder`,e),onUnpin:()=>P(t.deviceId,`decoder`)}),W(xt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`audio`,onToggleMenu:()=>o(i?.deviceId===t.deviceId&&i.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>o(null),onMove:e=>N(t.deviceId,`audio`,e),onUnpin:()=>P(t.deviceId,`audio`)}),W(`td`,{className:`px-3 py-2 align-middle`,children:W(wt,{snap:r})})]}),a&&!n&&z(`tr`,{className:`bg-surface/50`,children:[W(`td`,{}),W(`td`,{colSpan:5,className:`px-3 py-2`,children:W(h,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})})]})]},t.deviceId)}),y.length===0&&W(`tr`,{children:W(`td`,{colSpan:n?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 xt({role:e,state:t,mode:n,onlineNodes:r,isMenuOpen:i,onToggleMenu:a,onCloseMenu:o,onMove:s,onUnpin:c}){let l=vt[e],u=r.filter(e=>e.id!==(t.nodeId??``)),d=(t.active||n===`cluster`)&&(u.length>0||t.pinned);return z(`td`,{className:`px-3 py-2 align-middle relative`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(n===`agent`?St:Ct,{state:t,Icon:l}),W(`div`,{className:`ml-auto`,children:d&&W(`button`,{type:`button`,onClick:a,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${yt[e]} actions`,children:W(et,{className:`h-3 w-3 text-foreground-subtle`})})})]}),i&&d&&W(Tt,{title:yt[e],targets:u,pinned:t.pinned,onMove:s,onUnpin:c,onClose:o})]})}function St({state:e,Icon:t}){return z(`div`,{className:`flex items-center gap-1.5`,children:[W(e.active?je:Me,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),W(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&W(rt,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Ct({state:e,Icon:t}){return!e.active||!e.nodeId?z(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[W(t,{className:`h-3 w-3`}),W(`span`,{className:`text-[10px] italic`,children:`—`})]}):z(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[W(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),z(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[W(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),W(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?z(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[W(rt,{className:`h-2.5 w-2.5`}),` manual`]}):z(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}function wt({snap:e}){if(!e)return W(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:i,configuredFps:a}=e.metrics,o=f(t);return z(`div`,{className:`flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight`,children:[z(`span`,{className:`inline-flex items-center gap-1 ${o.textColor}`,children:[W(S,{phase:t,className:`h-2.5 w-2.5`}),W(`span`,{className:`font-semibold uppercase tracking-wider`,children:o.label})]}),z(`span`,{className:`text-foreground-subtle`,children:[W(`span`,{className:`text-foreground`,children:n.toFixed(1)}),z(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),z(`span`,{className:`text-foreground-subtle`,children:[W(`span`,{className:`text-foreground`,children:r.toFixed(0)}),W(`span`,{children:` ms`}),i>0&&z(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]})]})}function Tt({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=pe(null);return G(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),z(`div`,{ref:o,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[W(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&W(`div`,{className:`py-1`,children:t.map(e=>z(`button`,{type:`button`,onClick:()=>r(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),n&&z(`button`,{type:`button`,onClick:i,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),t.length===0&&!n&&W(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Et({nodeId:e,refreshToken:t}){return z(`div`,{className:`space-y-6`,children:[W(ht,{refreshToken:t,nodeId:e}),z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),W(bt,{mode:`agent`,nodeId:e,compact:!0})]})}R();function Dt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Ot({nodeId:e,refreshToken:t}){let n=H(),r=o({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:i}=_({nodeId:e}),a=ie(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??i??null,s=a===null;Ke([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:c}=le({nodeId:e}),{values:l}=P(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),u=B(()=>l.filter(e=>e.metrics.phase===`active`).length,[l]),d=t=>{let n=c??[];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 z(`div`,{className:`space-y-6`,children:[z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(a??[]).length,` engine(s) resident in RAM. `,(c??[]).length,` `,`camera(s) attached, `,u,` actively dispatching frames. Refreshes every 5s.`]})]}),W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[640px]`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[W(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),W(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),W(`th`,{className:`text-left px-3 py-2`,children:`Models`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),W(`th`,{className:`w-20`})]})}),z(`tbody`,{children:[s&&W(`tr`,{children:W(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!s&&(a??[]).map(e=>{let t=e.kind===`warm-override`;return z(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:``}`,children:[W(`td`,{className:`px-3 py-2`,children:z(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:`bg-success/15 text-success`}`,children:[W(t?nt:q,{className:`h-3 w-3`}),t?`warm`:`runtime`]})}),W(`td`,{className:`px-3 py-2`,children:z(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[W(Te,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),W(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?W(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):W(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>W(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),W(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),W(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?W(`span`,{className:`text-foreground-subtle`,children:Dt(e.idleMs,e.idleTtlMs)}):W(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(c??[]).length}),W(`td`,{className:`px-3 py-2 text-right`,children:z(`button`,{type:`button`,disabled:r.isPending,onClick:()=>d(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[W(He,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!s&&(a??[]).length===0&&W(`tr`,{children:W(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),z(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[W(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,W(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`]}),r.isError&&z(`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`]})]})}R();var kt=new Set(ge);function At(e){return kt.has(e)}function jt(e,t,n){return`${e}/${t}/${n}`}function Mt(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Nt(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function Q(e){return e.format}function Pt(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 Ft({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?z(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[W(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),z(`div`,{className:`flex-1 min-w-0`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),z(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&z(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[W(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:W(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),z(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),W(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:Qe(c.sizeMB)}),a&&z(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[W(Be,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?z(`button`,{onClick:s,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[r?W(J,{className:`h-3 w-3 animate-spin`}):W(He,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):z(`button`,{onClick:o,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[r?W(J,{className:`h-3 w-3 animate-spin`}):W(ve,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function It({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=U(!1);return z(`div`,{className:`relative`,children:[z(`button`,{type:`button`,onClick:()=>a(!i),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[W(q,{className:`h-4 w-4 text-primary shrink-0`}),z(`div`,{className:`flex-1 min-w-0`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium text-foreground`,children:Mt(n)}),Q(n)===Q(t)&&W(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:Nt(n)})]}),W(Le,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&W(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=Q(e)===Q(n),o=Q(e)===Q(t);return z(`button`,{type:`button`,onClick:()=>{r(e),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${i?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[W(q,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),z(`div`,{className:`flex-1`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:Mt(e)}),o&&W(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:Nt(e)})]}),i&&W(Ne,{className:`h-4 w-4 text-primary shrink-0`})]},Q(e))})})]})}function Lt({embedded:t=!1,nodeId:n}={}){let r=H(),i=n??`hub`,[a,o]=U(null),[s,c]=U(new Set),[l,d]=U(new Map),[f,p]=U(new Map),[h,g]=U(``),{data:_=[]}=de({nodeId:i}),y=_.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:b}=v({nodeId:i}),x=b,{data:S,isLoading:C}=e({nodeId:i}),w=m(),T=u();L(`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||(d(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 E=x??{runtime:`node`,backend:`cpu`,format:`onnx`},D=y.find(e=>e.format===a)??E,O=D.format,k=S?.slots??[],A=k.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[O]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),j=Pt(A,O),M=fe(async(e,t,n)=>{if(!At(n))return;let a=jt(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:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[w,r,i]),N=fe(async(e,t,n)=>{if(!At(n))return;let a=jt(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await T.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[T,r,i]),P=fe(e=>{o(e.format)},[]),F=h.trim()?A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(h.toLowerCase())||t.id.toLowerCase().includes(h.toLowerCase())||e.name.toLowerCase().includes(h.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):A,I=z(V,{children:[C&&W(`div`,{className:`flex items-center justify-center py-16`,children:W(J,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!C&&k.length===0&&z(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[W(ye,{className:`h-8 w-8 mb-3 opacity-30`}),W(`span`,{className:`text-sm`,children:`No pipeline steps available`}),W(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!C&&k.length>0&&z(V,{children:[W(It,{engines:y,activeEngine:E,viewEngine:D,onSelect:P}),z(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[z(`span`,{children:[W(`span`,{className:`font-semibold text-foreground tabular-nums`,children:j.total}),W(`span`,{className:`ml-1`,children:`compatible models`})]}),W(`span`,{className:`text-border`,children:`|`}),z(`span`,{children:[W(`span`,{className:`font-semibold text-success tabular-nums`,children:j.downloaded}),W(`span`,{className:`ml-1`,children:`downloaded`})]}),W(`span`,{className:`text-border`,children:`|`}),z(`span`,{className:`tabular-nums`,children:[Qe(j.downloadedSizeMB),W(`span`,{className:`ml-1`,children:`on disk`})]})]}),j.total>5&&z(`div`,{className:`relative`,children:[W(ke,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),W(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),F.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[O]?.downloaded).length,0);return z(`div`,{children:[z(`div`,{className:`flex items-center gap-2 mb-2`,children:[W(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),W(`div`,{className:`flex-1 h-px bg-border`}),z(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),W(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=jt(e.id,t.id,O);return W(Ft,{addonId:e.id,model:t,format:O,isActive:s.has(n),progress:l.get(t.id),errorMsg:f.get(n),onDownload:()=>M(e.id,t.id,O),onDelete:()=>N(e.id,t.id,O)},`${e.id}/${t.id}`)}))})]},e.id)}),F.length===0&&W(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:h.trim()?z(V,{children:[`No models matching “`,h,`”`]}):z(V,{children:[`No models available for `,Mt(D),` format`]})})]})]});return t?W(`div`,{className:`space-y-4`,children:I}):W(We,{children:I})}function Rt({nodeId:e,refreshToken:t}){return W(Lt,{embedded:!0,nodeId:e})}var zt=[{concern:`pipeline`,label:`Pipeline`,advisory:!1},{concern:`audio`,label:`Audio`,advisory:!1},{concern:`decode`,label:`Decode`,advisory:!0,advisoryNote:`Advisory: decode currently runs co-located with the stream source (hub). Pins are stored and take effect with Phase-2 stream load-balancing.`}];function Bt(e,t){return e.filter(e=>e.currentNodeId!==t)}var Vt=`This node is not decoder-enabled (enabledDecoderNodes). Pinning detection here strands frames (0 fps) until frame-source-aware placement ships. Enable decode on this node first, or pick a decoder-enabled node.`;function Ht(e,t,n){return t.includes(e)?{verdict:`ok`}:n?{verdict:`warn`,reason:Vt}:{verdict:`block`,reason:Vt}}R();var Ut=`pipeline-orchestrator`,Wt=`enabledDecoderNodes`;function Gt(e,t){if(!e||typeof e!=`object`)return;let n=e.sections;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e.fields;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(n.key!==t)continue;let r=n.value;return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0}}}function Kt({nodeId:e,nodeName:t,concern:n,open:r,onClose:i}){let o=H(),s=Ge(),c=T(void 0),u=ne(void 0),d=x(void 0),f=M({addonId:Ut}),p=te(),m=l(),h=a(),[g,_]=U(new Set),[v,y]=U(!1),[b,S]=U(null),[C,w]=U([]),[E,D]=U(null),O=zt.find(e=>e.concern===n),k=B(()=>{let e=new Map;if(n===`pipeline`)for(let t of c.data??[])e.set(t.deviceId,t.agentNodeId);else if(n===`decode`)for(let t of u.data??[])e.set(t.deviceId,t.decoderNodeId);else for(let t of d.data??[])e.set(t.deviceId,t.nodeId);return e},[n,c.data,u.data,d.data]),A=B(()=>(s.data??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,currentNodeId:k.get(e.id)??null})),[s.data,k]),j=B(()=>Bt(A,e),[A,e]),N=Gt(f.data,Wt),P=n===`pipeline`?Ht(e,N??[],!1):{verdict:`ok`},[F,I]=U(!1);if(!r)return null;let ee=P.verdict===`block`,L=P.verdict===`warn`&&!F,re=g.size>0&&!v&&!ee&&!L,ie=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ae=j.length>0&&j.every(e=>g.has(e.deviceId)),oe=()=>{_(ae?new Set:new Set(j.map(e=>e.deviceId)))},se=async t=>{n===`pipeline`?await p.mutateAsync({deviceId:t,agentNodeId:e}):n===`decode`?await m.mutateAsync({deviceId:t,nodeId:e}):await h.mutateAsync({deviceId:t,nodeId:e})},ce=new Map(A.map(e=>[e.deviceId,e.name]));return z(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[W(`div`,{className:`absolute inset-0 bg-black/60`,onClick:i}),z(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col h-[80vh] rounded-xl border border-border bg-background shadow-2xl`,children:[z(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[z(`div`,{className:`min-w-0`,children:[z(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Batch assign `,O?.label??n,` → `,t]}),z(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:[`Pick the cameras whose `,O?.label.toLowerCase()??n,` should run on this node.`]})]}),W(`button`,{type:`button`,onClick:i,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,"aria-label":`Close`,children:W(ze,{className:`h-4 w-4`})})]}),z(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[O?.advisory&&O.advisoryNote&&W(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2 shrink-0`,children:z(`div`,{className:`flex items-start gap-2`,children:[W(Ve,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),W(`p`,{className:`text-[11px] text-warning`,children:O.advisoryNote})]})}),P.verdict!==`ok`&&W(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2 shrink-0`,children:z(`div`,{className:`flex items-start gap-2`,children:[W(Ve,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),z(`div`,{className:`min-w-0`,children:[W(`p`,{className:`text-[11px] text-destructive`,children:P.reason}),P.verdict===`warn`&&z(`label`,{className:`mt-1 flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[W(`input`,{type:`checkbox`,checked:F,onChange:e=>I(e.target.checked),className:`accent-primary`}),`I understand — assign anyway`]})]})]})}),j.length>0&&z(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle shrink-0`,children:[W(`input`,{type:`checkbox`,"aria-label":`Select all`,checked:ae,onChange:oe,className:`accent-primary`}),`Select all (`,j.length,`)`]}),W(`div`,{className:`flex-1 min-h-0 overflow-y-auto rounded-lg border border-border divide-y divide-border`,children:j.length===0?z(`div`,{className:`px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:[`No eligible cameras — all cameras are already assigned to `,t,`.`]}):j.map(e=>z(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground hover:bg-surface-hover cursor-pointer`,children:[W(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:g.has(e.deviceId),onChange:()=>ie(e.deviceId),className:`accent-primary`}),W(`span`,{className:`truncate`,children:e.name}),e.currentNodeId&&z(`span`,{className:`ml-auto text-[10px] text-foreground-subtle shrink-0`,children:[`on `,e.currentNodeId]})]},e.deviceId))}),(E!==null||C.length>0)&&z(`div`,{className:`space-y-1 text-[10px] shrink-0`,children:[E!==null&&E>0&&z(`p`,{className:`text-success`,children:[`Assigned `,E,` camera(s) to `,t,`.`]}),C.map(e=>z(`p`,{className:`text-destructive`,children:[e.name,`: `,e.message]},e.deviceId))]})]}),z(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[W(`span`,{className:`text-[10px] text-foreground-subtle`,children:v&&b?`${b.done} / ${b.total}…`:``}),z(`div`,{className:`flex items-center gap-2`,children:[W(`button`,{type:`button`,onClick:i,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),z(`button`,{type:`button`,onClick:async()=>{let e=[...g];if(e.length===0)return;y(!0),w([]),D(null),S({done:0,total:e.length});let t=[],n=0;for(let r=0;r<e.length;r+=1){let i=e[r];try{await se(i),n+=1}catch(e){t.push({deviceId:i,name:ce.get(i)??String(i),message:e instanceof Error?e.message:String(e)})}S({done:r+1,total:e.length})}y(!1),w(t),D(n),_(new Set),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},disabled:!re,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50 disabled:cursor-not-allowed`,children:[v&&W(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign `,g.size,` to `,t]})]})]})]})]})}R();function qt({nodeId:e,title:t}){let{data:n}=Ge(),{data:r}=T(void 0),i=B(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=B(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[o,s]=U(new Map);L(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||s(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),G(()=>{if(o.size===0)return;let e=setInterval(()=>{s(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[o.size]);let c=B(()=>{let e=[];for(let t of o.values())a&&!a.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[o,a]);return c.length===0?z(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):z(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[z(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[W(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),W(`span`,{className:`text-[10px] text-foreground-subtle`,children:c.length})]}),W(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=f(e.metrics.phase);return z(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[W(S,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),W(`span`,{className:`font-medium text-foreground/90 max-w-[120px] truncate`,children:t}),W(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),W(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}var Jt={key:`maxCameras`,type:`slider`,label:`Max cameras`,description:`Hard cap on cameras the balancer may assign to this node.`,min:1,max:64,step:1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Unlimited`};R();var Yt=350;function Xt(e){return typeof e==`number`&&e>0?Math.floor(e):null}function Zt({value:e,pending:n,errorMessage:r,onCommit:i}){let[a,o]=U(e);G(()=>{o(e)},[e]);let s=pe(i);return s.current=i,G(()=>{if(a===e)return;let t=setTimeout(()=>s.current(a),Yt);return()=>clearTimeout(t)},[a,e]),z(`div`,{className:`flex items-center gap-3 text-xs text-foreground`,children:[W(`div`,{className:`max-w-md flex-1`,children:W(t,{field:Jt,values:{maxCameras:a},disabled:n,onChange:(e,t)=>o(Xt(t))})}),n&&W(`span`,{className:`text-[10px] text-muted-foreground animate-pulse`,children:`Saving…`}),r&&z(`span`,{className:`text-[10px] text-destructive`,children:[`Save failed: `,r]})]})}R();function Qt(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 $t({nodeId:t,refreshToken:n}){let r=H(),[a,o]=U(null),[s,c]=U(null),[l,u]=U(null),d=(i(void 0).data??[]).find(e=>e.id===t)?.name??t,f=e({nodeId:t},{refetchOnMount:`always`}),p=b({agentNodeId:t},{refetchOnMount:`always`}),m=()=>{r.invalidateQueries({queryKey:[[`addonSettings`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]})},h=oe({onSuccess:m}),g=O({onSuccess:m}),_=f.data??null,v=p.data,y=_?.selectedEngine.format??`coreml`,x=B(()=>_?E(_):[],[_]),S=B(()=>[{agentNodeId:t,engineLabel:y}],[t,y]),C=(e,t)=>{let n=v?.addonDefaults[e];return!Qt(_,e)?.models.some(e=>!!e.formats[y])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId}:{kind:`disabled`}},T=a&&_?Qt(_,a.addonId):null,D=e=>{let n=v?.addonDefaults[e]??null;o({addonId:e,agentNodeId:t}),c(n)},k=(e,n)=>{if(!v)return;let r=v.addonDefaults[e],i=Qt(_,e);if(!r&&!i)return;let a={enabled:n,modelId:r?.modelId??i?.defaultModelId??``,settings:r?.settings??{}};h.mutate({agentNodeId:t,defaults:{...v.addonDefaults,[e]:a}})},A=()=>{o(null),c(null)},j=()=>{!s||!a||!v||h.mutate({agentNodeId:t,defaults:{...v.addonDefaults,[a.addonId]:s}},{onSuccess:A})};if(f.isLoading||p.isLoading)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading pipeline…`});if(f.error)return z(`div`,{className:`text-xs text-red-400`,children:[`Failed to load catalog: `,String(f.error)]});if(!_)return W(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog unavailable for this node (runner offline?).`});let M=a!==null&&T!==null&&s!==null,P=p.data?.maxCameras??null;return z(`div`,{className:`relative h-full w-full space-y-3`,children:[W(qt,{nodeId:t}),W(Zt,{value:P,pending:g.isPending,errorMessage:g.isError?g.error instanceof Error?g.error.message:`Unknown error`:null,onCommit:e=>g.mutate({agentNodeId:t,maxCameras:e})}),z(`div`,{className:`flex items-center gap-2 text-xs`,children:[W(`span`,{className:`font-medium text-muted-foreground`,children:`Batch assign:`}),W(`button`,{type:`button`,onClick:()=>u(`pipeline`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Pipeline…`}),W(`button`,{type:`button`,onClick:()=>u(`audio`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Audio…`}),W(`button`,{type:`button`,onClick:()=>u(`decode`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs text-foreground-subtle hover:bg-surface-hover`,children:`Decode… (advisory)`})]}),l&&W(Kt,{nodeId:t,nodeName:d,concern:l,open:l!==null,onClose:()=>u(null)}),W(`div`,{className:M?`pr-[360px]`:``,children:x.length>0?W(w,{tree:x,agents:S,getCellState:C,onCellClick:D,selectedCell:a,onToggleEnabled:k}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),W(N,{open:M,onClose:A,title:T?.name??``,subtitle:a?`${a.agentNodeId} · ${y}`:``,footer:z(V,{children:[W(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:A,children:`Cancel`}),W(`button`,{type:`button`,disabled:!s||!a||h.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:j,children:h.isPending?`Saving…`:`Save`})]}),children:T&&s&&a&&W(F,{mode:`agent`,addon:T,agentDefault:s,agentNodeId:a.agentNodeId,engineFormat:y,onChangeAgentConfig:e=>c(e)})})]})}var en=[`detection-pipeline`,`decoder-nodeav`,`audio-analyzer`,`pipeline-runner`];function tn({nodeId:e,refreshToken:t}){return z(`div`,{className:`flex flex-col h-full`,children:[W(mt,{nodeId:e,refreshToken:t}),W(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:W($e,{nodeId:e,addonIds:en,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:W(Et,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:W($t,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:W(Ot,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:W(Rt,{nodeId:e,refreshToken:t})}]})})]})}function nn({refreshToken:e}){let t=H(),n=D({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return z(`div`,{className:`space-y-6`,children:[W(ht,{refreshToken:e}),z(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[z(`div`,{className:`min-w-0`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),W(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · decoder · audio assignments per camera. Click the kebab to pin / unpin / move any role; expand the chevron for the per-camera broker drill-down.`})]}),z(`button`,{type:`button`,onClick:()=>n.mutate(void 0),disabled:n.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[W(Te,{className:`h-3.5 w-3.5`}),n.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),W(bt,{mode:`cluster`})]})}function rn({nodeId:e,nodeName:t,isHub:n,isOnline:r,value:i,onCommitted:a}){let o=O({onSuccess:a});return z(`div`,{className:`space-y-1.5 ${r?``:`opacity-50`}`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-xs font-medium text-foreground`,children:t}),n&&W(`span`,{className:`rounded bg-muted px-1 py-0.5 text-[10px] text-foreground-subtle`,children:`hub`}),!r&&W(`span`,{className:`text-[10px] text-foreground-subtle`,children:`offline`})]}),W(Zt,{value:i,pending:o.isPending,errorMessage:o.isError?o.error instanceof Error?o.error.message:`Unknown error`:null,onCommit:t=>o.mutate({agentNodeId:e,maxCameras:t})})]})}function an(){let e=H(),t=i(void 0),n=I(void 0),r=t.data??[],a=new Map((n.data??[]).map(e=>[e.nodeId,e.settings.maxCameras])),o=()=>{e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})};return z(`div`,{className:`rounded-lg border border-border bg-surface p-4 space-y-3`,children:[z(`div`,{children:[W(`h3`,{className:`text-xs font-semibold text-foreground`,children:`Max cameras — per node`}),W(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Set each cluster node's camera cap independently. Unlimited (no cap) unless you set a value; changes commit per node.`})]}),t.isLoading?W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading nodes…`}):r.length===0?W(`div`,{className:`text-xs text-foreground-subtle`,children:`No cluster nodes.`}):W(`div`,{className:`space-y-3`,children:r.map(e=>W(rn,{nodeId:e.id,nodeName:e.name,isHub:e.isHub,isOnline:e.isOnline,value:a.get(e.id)??null,onCommitted:o},e.id))})]})}var on=[`pipeline-orchestrator`];function sn({refreshToken:e}){return z(`div`,{className:`space-y-4 max-w-3xl`,children:[W(an,{}),W($e,{nodeId:`hub`,addonIds:on,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})]})}R();function cn({refreshToken:e}){let t=H(),{data:n,isLoading:r}=re(),[i,a]=U(null),[o,s]=U(``),[l,u]=U(``),d=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},f=ue({onSuccess:()=>{a(null),d()}}),p=c({onSuccess:d}),m=e=>{a(e.id),s(e.name),u(e.description??``)},h=()=>{a(null),s(``),u(``)},g=()=>{if(!i)return;let e=l.trim();f.mutate({id:i,name:o.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return W(`div`,{className:`space-y-6 max-w-4xl`,children:z(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[z(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),W(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),z(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?z(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[W(De,{className:`h-6 w-6 opacity-40`}),W(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):W(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return W(`li`,{className:`px-4 py-3 text-xs`,children:z(`div`,{className:`flex items-start gap-3`,children:[W(`div`,{className:`flex-1 min-w-0`,children:t?z(`div`,{className:`space-y-2`,children:[W(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:o,onChange:e=>s(e.target.value),placeholder:`Template name`,autoFocus:!0}),W(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:l,onChange:e=>u(e.target.value),placeholder:`Description (optional)`})]}):z(V,{children:[W(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&W(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),z(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[`engine `,e.config.engine.runtime,`/`,e.config.engine.backend,` ·`,` `,e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,z(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),W(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?z(V,{children:[z(`button`,{type:`button`,onClick: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:[W(Pe,{className:`h-3 w-3`}),`Save`]}),z(`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:[W(ze,{className:`h-3 w-3`}),`Cancel`]})]}):z(V,{children:[W(`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:W(Ee,{className:`h-3 w-3`})}),W(`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:W(He,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}R();function ln(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 un({nodeId:t,refreshToken:n}){let r=H(),a=_e().trpcClient,[o,s]=U(null),[c,l]=U(null),u=I(void 0,{refetchOnMount:`always`});Ke([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`,`addon.updated`]);let d=i(void 0,{refetchOnMount:`always`}),f=B(()=>{let e=new Set;for(let t of d.data??[])t.isOnline&&e.add(t.id);return e},[d.data]),p=e({nodeId:t},{refetchOnMount:`always`}),m=B(()=>(u.data??[]).filter(e=>f.has(e.nodeId)).map(e=>e.nodeId),[u.data,f]),h=he({enabled:m.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`schema-by-agent`,m.join(`,`),n],queryFn:async()=>{let e={};for(let t of m)try{e[t]=(await a.pipelineExecutor.getSchema.query({nodeId:t})).selectedEngine.format}catch{e[t]=`coreml`}return e}}),g=oe({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]}),r.invalidateQueries({queryKey:[[`addonSettings`]]})}}),_=B(()=>p.data?E(p.data):[],[p.data]),v=B(()=>{let e=u.data??[],t=f;return(t.size===0?[]:e.filter(e=>t.has(e.nodeId))).map(e=>{let t=h.data?.[e.nodeId];return{agentNodeId:e.nodeId,engineLabel:t??`(engine unknown)`}})},[u.data,h.data,f]),y=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e],r=h.data?.[t];return!ln(p.data??null,e)?.models.some(e=>r!==void 0&&!!e.formats[r])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId}:{kind:`disabled`}},b=o?u.data?.find(e=>e.nodeId===o.agentNodeId)??null:null,x=o&&p.data?ln(p.data,o.addonId):null,S=o?h.data?.[o.agentNodeId]??`coreml`:`coreml`,C=()=>{s(null),l(null)},T=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e]??null;s({addonId:e,agentNodeId:t}),l(n)},D=()=>{!c||!o||!b||g.mutate({agentNodeId:o.agentNodeId,defaults:{...b.settings.addonDefaults,[o.addonId]:c}},{onSuccess:C})};if(u.isLoading||p.isLoading)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading agents…`});if(!p.data)return z(`div`,{className:`text-xs text-foreground-subtle`,children:[`Catalog unavailable for `,t,`.`]});let O=o!==null&&x!==null&&c!==null;return z(`div`,{className:`relative h-full w-full space-y-3`,children:[W(qt,{title:`Cluster cameras`}),W(`div`,{className:O?`pr-[360px]`:``,children:_.length>0&&v.length>0?W(w,{tree:_,agents:v,getCellState:y,onCellClick:T,selectedCell:o}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`No agents or catalog empty.`})}),W(N,{open:O,onClose:C,title:x?.name??``,subtitle:o?`${o.agentNodeId} · ${S}`:``,footer:z(V,{children:[W(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:C,children:`Cancel`}),W(`button`,{type:`button`,disabled:!c||!o||g.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:D,children:g.isPending?`Saving…`:`Save`})]}),children:x&&c&&o&&W(F,{mode:`agent`,addon:x,agentDefault:c,agentNodeId:o.agentNodeId,engineFormat:S,onChangeAgentConfig:e=>l(e)})})]})}R();function dn({types:e}){let t=H(),i=y(),{data:a}=g({}),o=ce(),s=B(()=>o.data??[],[o.data]),[c,l]=U(null),[u,d]=U(null),f=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},p=r({onSuccess:f}),m=n({onSuccess:f}),h=B(()=>{let e=new Map;for(let t of a??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[a]),_=e=>{e.isDefault||p.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},v=async e=>{if(e.isDefault){await i({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await i({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&m.mutate({id:e.id})},b=e.map(e=>s.find(t=>t.id===e)).filter(e=>e!==void 0);return z(`div`,{className:`space-y-3`,children:[b.length===0?W(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):b.map(e=>W(xe,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:h.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>d(e),onDelete:e=>{v(e)},onSetDefault:e=>_(e)},e.id)),c!==null&&W(Se,{initialType:c,onClose:()=>l(null),onCreated:()=>{f(),l(null)}}),u!==null&&W(be,{location:u,onClose:()=>d(null),onSaved:()=>{f(),d(null)}})]})}R();var fn=`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 mn(){let e=H(),{data:t}=i(void 0),{data:n,isLoading:r}=M({addonId:fn}),a=pn(n),o=ee({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=B(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,a,...e])].filter(Boolean)},[t,a]);return z(`div`,{className:`flex flex-col gap-6`,children:[z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),W(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),z(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?W(J,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):W(`select`,{value:a,onChange:e=>{e.target.value!==a&&o.mutate({addonId:fn,patch:{postProcessingNodeId:e.target.value}})},disabled:o.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>W(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),o.isPending&&W(J,{className:`h-4 w-4 animate-spin text-primary`})]})]}),z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),W(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),W(dn,{types:[`eventMedia`]})]})]})}R();var hn=`recorder`;function gn(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function _n(){let e=H(),{data:t}=i(void 0),{data:n,isLoading:r}=M({addonId:hn}),a=gn(n,`recordingNodeId`,`hub`),o=ee({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=B(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,a,...e])].filter(Boolean)},[t,a]);return z(`div`,{className:`flex flex-col gap-6`,children:[z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),W(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),z(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?W(J,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):W(`select`,{value:a,onChange:e=>{e.target.value!==a&&o.mutate({addonId:hn,patch:{recordingNodeId:e.target.value}})},disabled:o.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>W(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),o.isPending&&W(J,{className:`h-4 w-4 animate-spin text-primary`})]}),a!==`hub`&&z(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,W(`span`,{className:`font-medium`,children:a}),`. If the auto-derived host doesn't work, set the recorder's`,W(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),W(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),W(dn,{types:[`recordings`,`recordingsLow`]})]})]})}R();var vn=[{id:`assignments`,label:`Assignments`},{id:`pipeline`,label:`Pipeline`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`}];function yn({refreshToken:e}){let[t,n]=U(`assignments`),{data:r}=i(void 0),a=r?.find(e=>e.isHub&&e.isOnline)?.id??r?.find(e=>e.isOnline)?.id??null;return z(`div`,{className:`flex flex-col h-full`,children:[z(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[W(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),W(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),W(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:vn.map(e=>W(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),z(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&W(nn,{refreshToken:e}),t===`pipeline`&&(a?W(un,{nodeId:a,refreshToken:e}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`No online node available — schema unreachable.`})),t===`events`&&W(mn,{}),t===`recording`&&W(_n,{}),t===`settings`&&W(sn,{refreshToken:e}),t===`templates`&&W(cn,{refreshToken:e})]})]})}function bn(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}R();var xn={healthy:`bg-green-500`,idle:`bg-yellow-400`,error:`bg-red-500`},Sn={healthy:`Healthy`,idle:`Idle`,error:`Error`};function Cn({health:e}){return W(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${xn[e]}`,title:Sn[e],"aria-label":Sn[e],role:`img`})}function wn({selectedDeviceId:e,onSelect:t}){let{data:n}=Ge(),{data:r}=ae({}),i=B(()=>{let e=new Map;for(let t of r??[])e.set(t.deviceId,t);return e},[r]),a=B(()=>(n??[]).filter(e=>e.isCamera).map(e=>{let t=i.get(e.id);return{deviceId:e.id,name:e.name,health:t===void 0?`idle`:bn(t)}}),[n,i]);return a.length===0?W(`div`,{className:`px-4 py-6 text-center text-[11px] text-foreground-subtle italic`,children:`No cameras found`}):W(`ul`,{className:`divide-y divide-border`,children:a.map(n=>{let r=n.deviceId===e;return W(`li`,{children:z(`button`,{type:`button`,onClick:()=>t(n.deviceId),className:[`w-full flex items-center gap-2.5 px-4 py-3 text-left transition-colors`,r?`bg-surface-active text-foreground`:`hover:bg-surface-hover text-foreground-subtle hover:text-foreground`].join(` `),"aria-pressed":r,children:[W(Cn,{health:n.health}),z(`span`,{className:`flex-1 min-w-0`,children:[W(`span`,{className:`block truncate text-[12px] font-medium leading-tight`,children:n.name}),z(`span`,{className:`block text-[10px] text-foreground-subtle leading-tight mt-0.5`,children:[`#`,n.deviceId]})]})]})},n.deviceId)})})}var $={camera:0,source:200,broker:400,decoder:600,motion:800,detection:800,audio:800,recorder:800},Tn=120;function En(e,t){return e===null||t===null?!1:e!==t}function Dn(e){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.reduce((e,t)=>e+t.inFps,0),r=e.profiles.reduce((e,t)=>e+t.outFps,0);return`${t} subs · ${n.toFixed(1)}→${r.toFixed(1)} fps`}function On(e){return`${e.actualFps.toFixed(1)} fps · q${e.queueDepth} · ${e.avgInferenceMs.toFixed(1)}ms`}function kn(e){return`shm ${e.shm.getFrameHits+e.shm.getFrameMisses>0?Math.round(e.shm.getFrameHits/(e.shm.getFrameHits+e.shm.getFrameMisses)*100):0}% hit`}function An(e){let t=[],n=[],r={id:`camera`,kind:`camera`,nodeId:null,data:{deviceId:e.deviceId},position:{x:$.camera,y:0}};t.push(r);let i={id:`source`,kind:`source`,nodeId:null,data:{streams:e.source.streams},position:{x:$.source,y:0}};t.push(i),n.push({id:`camera->source`,source:`camera`,target:`source`,crossNode:!1});let a=e.broker;if(a!==null){let e={id:`broker`,kind:`broker`,nodeId:null,data:{profiles:a.profiles,webrtcSessions:a.webrtcSessions,rtspRestream:a.rtspRestream},position:{x:$.broker,y:0}};t.push(e),n.push({id:`source->broker`,source:`source`,target:`broker`,crossNode:!1})}let o=e.decoder;if(o!==null){let r={id:`decoder`,kind:`decoder`,nodeId:o.nodeId,data:{nodeId:o.nodeId,formats:o.formats,sessionCount:o.sessionCount,shm:o.shm},position:{x:$.decoder,y:0}};t.push(r);let i=a===null?`source`:`broker`,s=a===null?void 0:Dn(a),c=a===null?kn(o):s;n.push({id:`${i}->decoder`,source:i,target:`decoder`,crossNode:En(null,o.nodeId),...c===void 0?{}:{label:c}});let l=0,u=e.motion;if(u!==null){let e={id:`motion`,kind:`motion`,nodeId:null,data:{enabled:u.enabled,fps:u.fps},position:{x:$.motion,y:l*Tn}};t.push(e),n.push({id:`decoder->motion`,source:`decoder`,target:`motion`,crossNode:!1}),l++}let d=e.detection;if(d!==null){let e={id:`detection`,kind:`detection`,nodeId:d.nodeId,data:{nodeId:d.nodeId,engine:d.engine,phase:d.phase,configuredFps:d.configuredFps,actualFps:d.actualFps,queueDepth:d.queueDepth,avgInferenceMs:d.avgInferenceMs,provisioning:d.provisioning},position:{x:$.detection,y:l*Tn}};t.push(e),n.push({id:`decoder->detection`,source:`decoder`,target:`detection`,crossNode:En(o.nodeId,d.nodeId),label:On(d)}),l++}let f=e.audio;if(f!==null){let e={id:`audio`,kind:`audio`,nodeId:f.nodeId,data:{nodeId:f.nodeId,enabled:f.enabled},position:{x:$.audio,y:l*Tn}};t.push(e),n.push({id:`decoder->audio`,source:`decoder`,target:`audio`,crossNode:En(o.nodeId,f.nodeId)}),l++}let p=e.recording;if(p!==null){let e={id:`recorder`,kind:`recorder`,nodeId:null,data:{mode:p.mode,active:p.active,storageBytes:p.storageBytes},position:{x:$.recorder,y:l*Tn}};t.push(e),n.push({id:`decoder->recorder`,source:`decoder`,target:`recorder`,crossNode:!1})}}return{nodes:t,edges:n}}R();function jn(e){let{data:t,isLoading:n}=A({deviceId:e}),[r,i]=U(void 0);return G(()=>{t!==void 0&&i(t)},[t]),L(K.PipelineCameraMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.detection===null?e:{...e,detection:{...e.detection,phase:n.metrics.phase,actualFps:n.metrics.actualFps,queueDepth:n.metrics.queueDepth,avgInferenceMs:n.metrics.avgInferenceTimeMs}})}),L(K.PipelineEngineProvisioning,e=>{let t=e.data;i(n=>{if(n===void 0||n.detection===null)return n;let r=n.detection.nodeId??n.assignment?.detectionNodeId??null;return r===null||e.source.type!==`node`||e.source.id!==r?n:{...n,detection:{...n.detection,provisioning:{state:t.state,error:t.error}}}})}),L(K.MotionAnalysis,t=>{t.source.type!==`device`||t.source.id!==e||i(e=>e===void 0||e.motion===null?e:{...e,motion:{...e.motion,enabled:!0}})}),L(K.StreamBrokerMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.broker===null?e:{...e,broker:{...e.broker,profiles:e.broker.profiles.map(e=>e.profile===n.profile?{...e,subscribers:n.stats.encodedSubscribers+n.stats.decodedSubscribers,inFps:n.stats.inputFps,outFps:n.stats.decodeFps}:e)}})}),L(K.PipelineAudioInferenceResult,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.audio===null?e:{...e,audio:{...e.audio,enabled:!0}})}),L(K.RecordingStarted,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!0}})}),L(K.RecordingStopped,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!1}})}),{status:r,isLoading:n}}function Mn({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`source`,position:X.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full bg-green-500 shrink-0`,"aria-label":`healthy`}),z(`span`,{className:`text-sm font-semibold truncate`,children:[`Camera #`,e.deviceId]})]}),W(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`source`})]})}function Nn(e){return e>0?`bg-green-500`:`bg-yellow-500`}function Pn({data:e}){let t=e.streams[0],n=e.streams.length;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`target`,position:X.Left}),W(Y,{type:`source`,position:X.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Nn(n)}`,"aria-label":n>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Source`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[n,` streams`]})]}),t!==void 0&&z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t.codec,` `,t.width,`×`,t.height,` `,t.fps,`fps`]})]})}function Fn(e){return e>0?`bg-green-500`:`bg-yellow-500`}function In({data:e}){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.length;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`target`,position:X.Left}),W(Y,{type:`source`,position:X.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Fn(t)}`,"aria-label":t>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Broker`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[n,` profiles`]})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t,` subs · WebRTC `,e.webrtcSessions,e.rtspRestream&&` · RTSP`]})]})}function Ln(e){return e>0?`bg-green-500`:`bg-yellow-500`}function Rn(e,t){let n=e+t;return n>0?Math.round(e/n*100):0}function zn({data:e}){let t=Rn(e.shm.getFrameHits,e.shm.getFrameMisses),n=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${n?` opacity-50`:``}`,children:[W(Y,{type:`target`,position:X.Left}),W(Y,{type:`source`,position:X.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Ln(e.sessionCount)}`,"aria-label":e.sessionCount>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Decoder`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),n&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.formats.join(`, `),` · `,e.sessionCount,` sessions`]}),z(`div`,{className:`text-xs text-muted-foreground`,children:[`shm `,t,`% hit`]})]})}function Bn(e){return e?`bg-green-500`:`bg-yellow-500`}function Vn({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`target`,position:X.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Bn(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),W(`span`,{className:`text-sm font-semibold`,children:`Motion`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.enabled?`enabled`:`disabled`,` · `,e.fps,` fps`]})]})}function Hn(e){return e.provisioning.state===`failed`?`bg-red-500`:e.phase===`active`?`bg-green-500`:(e.phase,`bg-yellow-500`)}function Un(e){return e===`ready`?`bg-green-500 text-white`:e===`failed`?`bg-red-500 text-white`:`bg-yellow-500 text-white`}function Wn({data:e}){let t=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[180px] px-3 py-2${t?` opacity-50`:``}`,children:[W(Y,{type:`target`,position:X.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Hn(e)}`,"aria-label":e.phase}),W(`span`,{className:`text-sm font-semibold`,children:`Detection`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.engine.backend,`·`,e.engine.device,` · `,e.phase]}),z(`div`,{className:`text-xs text-muted-foreground`,children:[e.actualFps.toFixed(1),`/`,e.configuredFps,` fps · q`,e.queueDepth,` ·`,` `,e.avgInferenceMs.toFixed(1),`ms`]}),z(`div`,{className:`flex items-center gap-1 mt-1`,children:[W(`span`,{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded ${Un(e.provisioning.state)}`,"aria-label":`provisioning ${e.provisioning.state}`,children:e.provisioning.state}),e.provisioning.state===`failed`&&e.provisioning.error!==void 0&&W(`span`,{className:`text-[10px] text-red-500 truncate`,children:e.provisioning.error})]})]})}function Gn(e){return e?`bg-green-500`:`bg-yellow-500`}function Kn({data:e}){let t=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${t?` opacity-50`:``}`,children:[W(Y,{type:`target`,position:X.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Gn(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),W(`span`,{className:`text-sm font-semibold`,children:`Audio`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),W(`div`,{className:`text-xs text-muted-foreground mt-1`,children:e.enabled?`enabled`:`disabled`})]})}function qn(e){return e.mode===`off`?`bg-red-500`:e.active?`bg-green-500`:`bg-yellow-500`}function Jn(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:`${(e/1048576).toFixed(1)} MB`}function Yn({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`target`,position:X.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${qn(e)}`,"aria-label":e.active?`active`:e.mode===`off`?`off`:`inactive`}),W(`span`,{className:`text-sm font-semibold`,children:`Recorder`}),W(`span`,{className:`text-xs text-muted-foreground`,children:e.mode})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.active?`active`:`inactive`,` · `,Jn(e.storageBytes)]})]})}R();var Xn={camera:Mn,source:Pn,broker:In,decoder:zn,motion:Vn,detection:Wn,audio:Kn,recorder:Yn},Zn={stroke:`#f59e0b`,strokeWidth:2},Qn={strokeWidth:1.5},$n=`camstack-pipeline-flow-layout`;function er({deviceId:e}){let{status:t,isLoading:n}=jn(e),{data:r}=i(void 0),a=B(()=>{let e=new Set;for(let t of r??[])t.isOnline||e.add(t.id);return e},[r]),{computedNodes:o,rfEdges:s}=B(()=>{if(t===void 0)return{computedNodes:[],rfEdges:[]};let e=An(t);return{computedNodes:e.nodes.map(e=>({id:e.id,type:e.kind,position:{x:e.position.x,y:e.position.y},data:{...e.data,offline:e.nodeId!==null&&a.has(e.nodeId)}})),rfEdges:e.edges.map(e=>({id:e.id,source:e.source,target:e.target,animated:e.crossNode,style:e.crossNode?Zn:Qn,label:e.label}))}},[t,a]),{nodes:c,onNodesChange:l,resetLayout:u}=Ze($n,o);return n?W(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`Loading…`}):t===void 0?W(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`No pipeline data`}):z(`div`,{className:`w-full h-full relative`,children:[W(`button`,{type:`button`,onClick:u,className:`absolute top-2 right-2 z-10 text-xs px-2 py-1 rounded border border-border bg-background hover:bg-muted`,title:`Restore the automatic layout, discarding dragged positions`,children:`Reset layout`}),z(qe,{nodes:c,edges:s,onNodesChange:l,nodesDraggable:!0,nodeTypes:Xn,fitView:!0,proOptions:{hideAttribution:!0},children:[W(Je,{gap:20,size:1}),W(Ye,{showInteractive:!1})]})]})}R();var tr=`__cluster__`;function nr(e){return e===`cameras`?`cameras`:`nodes`}function rr(){let[e,t]=Fe(),n=nr(e.get(`view`)),r=e.get(`node`)??`__cluster__`,i=e.get(`camera`),a=i===null?null:parseInt(i,10),[o,s]=U(0);return G(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:tr},{replace:!0})},[n,e,t]),z(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[z(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[z(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[W(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),W(`button`,{type:`button`,onClick:()=>{let e={view:`cameras`};a!==null&&(e.camera=String(a)),t(e,{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),z(`button`,{type:`button`,onClick:()=>s(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[W(Oe,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),W(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?z(V,{children:[W(`aside`,{className:`w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border overflow-y-auto`,children:W(pt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0})},refreshToken:o})}),W(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?W(yn,{refreshToken:o}):W(tn,{nodeId:r,refreshToken:o})})]}):z(V,{children:[W(`aside`,{className:`w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border overflow-y-auto`,children:W(wn,{selectedDeviceId:a,onSelect:e=>{t({view:`cameras`,camera:String(e)},{replace:!0})}})}),W(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:a!==null&&Number.isFinite(a)&&!Number.isNaN(a)?W(er,{deviceId:a}):W(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Select a camera to view its pipeline flow`})})]})})]})}export{rr as PipelinePage};
|
|
1
|
+
import{Br as e,C as t,Ci as n,Di as r,Fr as i,Gr as a,Hr as o,Ia as s,Jr as c,Kr as l,Lr as u,Oa as d,Pa as f,Qr as p,Rr as m,T as h,Ti as g,Ur as _,Vr as v,Xi as y,Xr as b,Zr as x,_ as S,_i as C,aa as w,ai as T,ca as E,ci as D,di as O,ea as k,ei as A,gi as j,it as M,la as N,na as P,oa as F,oi as I,ot as ee,qr as te,ra as L,ri as ne,si as re,ta as ie,ti as ae,ui as oe,vi as se,wi as ce,xi as le,yi as ue,zr as de}from"./src-9Nw_7MUt.js";import{I as fe,K as pe,Q as R,S as z,T as me,W as B,a as he,b as V,o as H,q as U,x as W,z as G}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as K,R as ge}from"./src-DYcadIAu.js";import{p as _e}from"./player-overlays-CqpHdvYF.js";import{t as ve}from"./download-CDTSR7Xa.js";import{i as ye,n as be,r as xe,t as Se}from"./AddLocationWizard-CINm21H1.js";import{n as Ce,r as we,t as Te}from"./zap-JlTWX6I9.js";import{t as Ee}from"./pencil-DR7yGacK.js";import{t as De}from"./plus-CekuJPnw.js";import{t as Oe}from"./refresh-cw-DH7JcsAT.js";import{t as ke}from"./search-B5TMrljD.js";import{t as Ae}from"./server-Crr45iTm.js";import{t as je}from"./square-check-big-B8Q-LJXA.js";import{t as Me}from"./square-jObXvdFU.js";import{A as Ne,F as Pe,G as Fe,M as Ie,P as Le,V as Re,i as ze,j as Be,k as q,o as Ve,s as He,w as Ue,x as J}from"./index-Da6GKRLl.js";import{t as We}from"./AdminPage-BwmGKnRf.js";import{r as Ge}from"./useDevice-LyxwBrYX.js";import{t as Ke}from"./useEventInvalidation-CoNLHhyv.js";import{a as qe,i as Y,n as Je,o as X,r as Ye,s as Xe,t as Ze}from"./use-persisted-flow-layout-DuQZXkHq.js";import{n as Qe}from"./format-size-CO9d3C3-.js";import{t as $e}from"./NodeAddonsSettingsPanel-5OLeCWWK.js";var et=Re(`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`}]]),tt=Re(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),nt=Re(`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`}]]),rt=Re(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);R();var it=`enabledDecoderNodes`,at=`enabledNodes`,ot=`enabledAudioNodes`,st=[`hub`];function ct(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function lt(e){let t=e.sections;if(!Array.isArray(t))return e;let n={};for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.fields;if(Array.isArray(t))for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.key;typeof t==`string`&&(t in n||(n[t]=e.value))}}return n}function ut(e,t,n){let r=e[t];return(ct(r)?r:st).includes(n)}function dt(e,t){if(e==null)return{decode:!0,pipeline:!0,audio:!0};let n=lt(e);return{decode:ut(n,it,t),pipeline:ut(n,at,t),audio:ut(n,ot,t)}}var ft=`pipeline-orchestrator`;function pt({selectedNodeId:e,onSelect:t,refreshToken:n}){let{data:r}=i(void 0),{data:a}=T(void 0),{data:o}=M({addonId:ft}),c=new Map;for(let e of a??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=r??[],u=l.filter(e=>e.isOnline).length,f=l.filter(e=>!e.isOnline).length;return z(`div`,{className:`flex flex-col h-full`,children:[z(`button`,{type:`button`,onClick:()=>t(tr),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:[W(Ue,{className:`h-4 w-4 flex-shrink-0`}),z(`div`,{className:`min-w-0 flex-1`,children:[W(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),W(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(n=>{let r=e===n.id,i=c.get(n.id)??0,a=n.isHub?Ae:q,l=dt(o,n.id),u=n.isOnline?null:s(Xe(n.lastSeen));return z(`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 ${r?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${n.isOnline?``:` opacity-60`}`,children:[W(a,{className:`h-4 w-4 flex-shrink-0`}),z(`div`,{className:`min-w-0 flex-1`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-xs font-semibold truncate`,children:n.name}),n.isHub&&W(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!n.isOnline&&W(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),n.isOnline&&W(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),z(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[z(`span`,{children:[n.cpuCores,` cores`]}),W(`span`,{children:`•`}),z(`span`,{children:[Math.round(n.memoryMB/1024),` GB`]}),i>0&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[W(Ce,{className:`h-2.5 w-2.5`}),i]})]}),!n.isOnline&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),z(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[W(d,{variant:l.decode?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.decode?`Decode: enabled`:`Decode: not enabled (enabledDecoderNodes)`,children:`Dec`}),W(d,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (enabledNodes)`,children:`Pipe`}),W(d,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (enabledAudioNodes)`,children:`Aud`})]})]})]},n.id)})}),z(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[z(`span`,{children:[u,` online`]}),f>0&&z(`span`,{className:`text-destructive`,children:[f,` offline`]})]})]})}function mt({nodeId:e,refreshToken:t}){let{data:n}=i(void 0),r=n?.find(t=>t.id===e),a=ie(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?z(`div`,{className:`px-6 py-4 border-b border-border`,children:[z(`div`,{className:`flex items-center gap-2 mb-1`,children:[W(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?W(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):W(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&W(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),z(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[W(`span`,{children:r.cpuModel??`CPU`}),W(`span`,{children:`•`}),z(`span`,{children:[r.cpuCores,` cores`]}),W(`span`,{children:`•`}),z(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a&&z(V,{children:[W(`span`,{children:`•`}),z(`span`,{children:[a.attachedCameras,` cameras (`,a.activeCameras,` active)`]}),W(`span`,{children:`•`}),z(`span`,{children:[a.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),W(`span`,{children:`•`}),z(`span`,{children:[`queue `,a.queueDepthTotal]}),a.hardware.hasGpu&&z(V,{children:[W(`span`,{children:`•`}),W(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):W(`div`,{className:`px-6 py-4 border-b border-border`,children:z(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function ht({refreshToken:e,nodeId:t}){let[n,r]=U(new Map),{nodes:i}=k();L(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:a}=p(void 0),o=B(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=B(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),c=B(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=B(()=>{let e=0,t=0,n=0,r=0,a=0;for(let i of s.values())e+=i.attachedCameras,t+=i.activeCameras,n+=i.totalFps,r+=i.totalInferenceWeighted,a+=i.queueDepth;let o=e>0?r/e:0;return{totalAgents:i.length,onlineAgents:i.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:a,totalFps:n}},[s,i]);if(t){let e=s.get(t);return z(`div`,{className:`@container/liveload`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),z(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[W(Z,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),W(Z,{label:`Cameras`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),W(Z,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),W(Z,{label:`Queue`,value:e?String(e.queueDepth):`—`}),W(Z,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let u=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return z(`div`,{className:`@container/liveload`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),z(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[W(Z,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),W(Z,{label:`Cameras`,value:`${l.activeCameras}/${l.attachedCameras}`}),W(Z,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),W(Z,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),W(Z,{label:`Queue depth`,value:String(l.queueDepth)})]}),W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[480px]`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[W(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),W(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),W(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),W(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),W(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),W(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),z(`tbody`,{children:[u.map(([e,t])=>z(`tr`,{className:`border-t border-border`,children:[W(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),u.length===0&&W(`tr`,{children:W(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function Z({label:e,value:t}){return z(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[W(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),W(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}R();var gt={active:!1,pinned:!1,nodeId:null,reason:``},_t=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],vt={pipeline:q,decoder:tt,audio:we},yt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function bt({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let r=H(),[i,o]=U(null),[s,c]=U(null),[u,d]=U(new Map);Ke([`pipelineOrchestrator`,`getPipelineAssignments`],_t),Ke([`pipelineOrchestrator`,`getDecoderAssignments`],_t),Ke([`pipelineOrchestrator`,`getAudioAssignments`],_t);let{data:f}=T(void 0),{data:p}=ne(void 0),{data:m}=x(void 0),{nodes:g}=k(),{data:_}=Ge();L(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&d(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),G(()=>{if(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 v=B(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),y=B(()=>{let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:v.get(e)??`Device ${e}`,pipeline:gt,decoder:gt,audio:gt};return n.set(e,r),r};for(let i of f??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``}})}for(let i of p??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,decoder:{active:e===`cluster`?!0:i.decoderNodeId===t,pinned:i.pinned,nodeId:i.decoderNodeId,reason:i.reason??``}})}for(let i of m??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,audio:{active:e===`cluster`?!0:i.nodeId===t,pinned:i.pinned,nodeId:i.nodeId,reason:`capacity`}})}let i=[...n.values()];return e===`agent`&&(i=i.filter(e=>e.pipeline.active||e.decoder.active||e.audio.active)),i.sort((e,t)=>e.deviceId-t.deviceId),i},[f,p,m,v,e,t]),b=B(()=>(g??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[g]),S=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},w=te({onSuccess:S}),E=se({onSuccess:S}),D=l({onSuccess:S}),O=C({onSuccess:S}),A=a({onSuccess:S}),M=j({onSuccess:S}),N=(e,t,n)=>{t===`pipeline`?w.mutate({deviceId:e,agentNodeId:n}):t===`decoder`?D.mutate({deviceId:e,nodeId:n}):A.mutate({deviceId:e,nodeId:n}),o(null)},P=(e,t)=>{t===`pipeline`?E.mutate({deviceId:e}):t===`decoder`?O.mutate({deviceId:e}):M.mutate({deviceId:e}),o(null)};return W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[640px]`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&W(`th`,{className:`w-6`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Camera`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Pipeline`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Decoder`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Audio`}),W(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Status`})]})}),z(`tbody`,{children:[y.map(t=>{let r=u.get(t.deviceId),a=s===t.deviceId;return z(me.Fragment,{children:[z(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&W(`td`,{className:`px-2 py-2 align-middle`,children:W(`button`,{type:`button`,onClick:()=>c(a?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":a?`Collapse broker details`:`Expand broker details`,children:W(a?Le:Ie,{className:`h-3.5 w-3.5`})})}),z(`td`,{className:`px-3 py-2 align-middle`,children:[W(`div`,{className:`text-foreground font-medium leading-tight`,children:t.deviceName}),z(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),W(xt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`pipeline`,onToggleMenu:()=>o(i?.deviceId===t.deviceId&&i.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>o(null),onMove:e=>N(t.deviceId,`pipeline`,e),onUnpin:()=>P(t.deviceId,`pipeline`)}),W(xt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`decoder`,onToggleMenu:()=>o(i?.deviceId===t.deviceId&&i.role===`decoder`?null:{deviceId:t.deviceId,role:`decoder`}),onCloseMenu:()=>o(null),onMove:e=>N(t.deviceId,`decoder`,e),onUnpin:()=>P(t.deviceId,`decoder`)}),W(xt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`audio`,onToggleMenu:()=>o(i?.deviceId===t.deviceId&&i.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>o(null),onMove:e=>N(t.deviceId,`audio`,e),onUnpin:()=>P(t.deviceId,`audio`)}),W(`td`,{className:`px-3 py-2 align-middle`,children:W(wt,{snap:r})})]}),a&&!n&&z(`tr`,{className:`bg-surface/50`,children:[W(`td`,{}),W(`td`,{colSpan:5,className:`px-3 py-2`,children:W(h,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})})]})]},t.deviceId)}),y.length===0&&W(`tr`,{children:W(`td`,{colSpan:n?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 xt({role:e,state:t,mode:n,onlineNodes:r,isMenuOpen:i,onToggleMenu:a,onCloseMenu:o,onMove:s,onUnpin:c}){let l=vt[e],u=r.filter(e=>e.id!==(t.nodeId??``)),d=(t.active||n===`cluster`)&&(u.length>0||t.pinned);return z(`td`,{className:`px-3 py-2 align-middle relative`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(n===`agent`?St:Ct,{state:t,Icon:l}),W(`div`,{className:`ml-auto`,children:d&&W(`button`,{type:`button`,onClick:a,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${yt[e]} actions`,children:W(et,{className:`h-3 w-3 text-foreground-subtle`})})})]}),i&&d&&W(Tt,{title:yt[e],targets:u,pinned:t.pinned,onMove:s,onUnpin:c,onClose:o})]})}function St({state:e,Icon:t}){return z(`div`,{className:`flex items-center gap-1.5`,children:[W(e.active?je:Me,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),W(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&W(rt,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Ct({state:e,Icon:t}){return!e.active||!e.nodeId?z(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[W(t,{className:`h-3 w-3`}),W(`span`,{className:`text-[10px] italic`,children:`—`})]}):z(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[W(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),z(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[W(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),W(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?z(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[W(rt,{className:`h-2.5 w-2.5`}),` manual`]}):z(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}function wt({snap:e}){if(!e)return W(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:i,configuredFps:a}=e.metrics,o=f(t);return z(`div`,{className:`flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight`,children:[z(`span`,{className:`inline-flex items-center gap-1 ${o.textColor}`,children:[W(S,{phase:t,className:`h-2.5 w-2.5`}),W(`span`,{className:`font-semibold uppercase tracking-wider`,children:o.label})]}),z(`span`,{className:`text-foreground-subtle`,children:[W(`span`,{className:`text-foreground`,children:n.toFixed(1)}),z(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),z(`span`,{className:`text-foreground-subtle`,children:[W(`span`,{className:`text-foreground`,children:r.toFixed(0)}),W(`span`,{children:` ms`}),i>0&&z(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]})]})}function Tt({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=pe(null);return G(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),z(`div`,{ref:o,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[W(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&W(`div`,{className:`py-1`,children:t.map(e=>z(`button`,{type:`button`,onClick:()=>r(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),n&&z(`button`,{type:`button`,onClick:i,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),t.length===0&&!n&&W(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Et({nodeId:e,refreshToken:t}){return z(`div`,{className:`space-y-6`,children:[W(ht,{refreshToken:t,nodeId:e}),z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),W(bt,{mode:`agent`,nodeId:e,compact:!0})]})}R();function Dt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Ot({nodeId:e,refreshToken:t}){let n=H(),r=o({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:i}=_({nodeId:e}),a=ie(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??i??null,s=a===null;Ke([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:c}=le({nodeId:e}),{values:l}=P(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),u=B(()=>l.filter(e=>e.metrics.phase===`active`).length,[l]),d=t=>{let n=c??[];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 z(`div`,{className:`space-y-6`,children:[z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),z(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(a??[]).length,` engine(s) resident in RAM. `,(c??[]).length,` `,`camera(s) attached, `,u,` actively dispatching frames. Refreshes every 5s.`]})]}),W(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:z(`table`,{className:`w-full text-xs min-w-[640px]`,children:[W(`thead`,{className:`bg-surface`,children:z(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[W(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),W(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),W(`th`,{className:`text-left px-3 py-2`,children:`Models`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),W(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),W(`th`,{className:`w-20`})]})}),z(`tbody`,{children:[s&&W(`tr`,{children:W(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!s&&(a??[]).map(e=>{let t=e.kind===`warm-override`;return z(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:``}`,children:[W(`td`,{className:`px-3 py-2`,children:z(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:`bg-success/15 text-success`}`,children:[W(t?nt:q,{className:`h-3 w-3`}),t?`warm`:`runtime`]})}),W(`td`,{className:`px-3 py-2`,children:z(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[W(Te,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),W(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?W(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):W(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>W(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),W(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),W(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?W(`span`,{className:`text-foreground-subtle`,children:Dt(e.idleMs,e.idleTtlMs)}):W(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),W(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(c??[]).length}),W(`td`,{className:`px-3 py-2 text-right`,children:z(`button`,{type:`button`,disabled:r.isPending,onClick:()=>d(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[W(He,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!s&&(a??[]).length===0&&W(`tr`,{children:W(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),z(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[W(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,W(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`]}),r.isError&&z(`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`]})]})}R();var kt=new Set(ge);function At(e){return kt.has(e)}function jt(e,t,n){return`${e}/${t}/${n}`}function Mt(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Nt(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function Q(e){return e.format}function Pt(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 Ft({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?z(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[W(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),z(`div`,{className:`flex-1 min-w-0`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),z(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&z(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[W(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:W(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),z(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),W(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:Qe(c.sizeMB)}),a&&z(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[W(Be,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?z(`button`,{onClick:s,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[r?W(J,{className:`h-3 w-3 animate-spin`}):W(He,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):z(`button`,{onClick:o,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[r?W(J,{className:`h-3 w-3 animate-spin`}):W(ve,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function It({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=U(!1);return z(`div`,{className:`relative`,children:[z(`button`,{type:`button`,onClick:()=>a(!i),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[W(q,{className:`h-4 w-4 text-primary shrink-0`}),z(`div`,{className:`flex-1 min-w-0`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium text-foreground`,children:Mt(n)}),Q(n)===Q(t)&&W(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:Nt(n)})]}),W(Le,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&W(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=Q(e)===Q(n),o=Q(e)===Q(t);return z(`button`,{type:`button`,onClick:()=>{r(e),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${i?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[W(q,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),z(`div`,{className:`flex-1`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:Mt(e)}),o&&W(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),W(`div`,{className:`text-[10px] text-foreground-subtle`,children:Nt(e)})]}),i&&W(Ne,{className:`h-4 w-4 text-primary shrink-0`})]},Q(e))})})]})}function Lt({embedded:t=!1,nodeId:n}={}){let r=H(),i=n??`hub`,[a,o]=U(null),[s,c]=U(new Set),[l,d]=U(new Map),[f,p]=U(new Map),[h,g]=U(``),{data:_=[]}=de({nodeId:i}),y=_.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:b}=v({nodeId:i}),x=b,{data:S,isLoading:C}=e({nodeId:i}),w=m(),T=u();L(`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||(d(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 E=x??{runtime:`node`,backend:`cpu`,format:`onnx`},D=y.find(e=>e.format===a)??E,O=D.format,k=S?.slots??[],A=k.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[O]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),j=Pt(A,O),M=fe(async(e,t,n)=>{if(!At(n))return;let a=jt(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:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[w,r,i]),N=fe(async(e,t,n)=>{if(!At(n))return;let a=jt(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await T.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[T,r,i]),P=fe(e=>{o(e.format)},[]),F=h.trim()?A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(h.toLowerCase())||t.id.toLowerCase().includes(h.toLowerCase())||e.name.toLowerCase().includes(h.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):A,I=z(V,{children:[C&&W(`div`,{className:`flex items-center justify-center py-16`,children:W(J,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!C&&k.length===0&&z(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[W(ye,{className:`h-8 w-8 mb-3 opacity-30`}),W(`span`,{className:`text-sm`,children:`No pipeline steps available`}),W(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!C&&k.length>0&&z(V,{children:[W(It,{engines:y,activeEngine:E,viewEngine:D,onSelect:P}),z(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[z(`span`,{children:[W(`span`,{className:`font-semibold text-foreground tabular-nums`,children:j.total}),W(`span`,{className:`ml-1`,children:`compatible models`})]}),W(`span`,{className:`text-border`,children:`|`}),z(`span`,{children:[W(`span`,{className:`font-semibold text-success tabular-nums`,children:j.downloaded}),W(`span`,{className:`ml-1`,children:`downloaded`})]}),W(`span`,{className:`text-border`,children:`|`}),z(`span`,{className:`tabular-nums`,children:[Qe(j.downloadedSizeMB),W(`span`,{className:`ml-1`,children:`on disk`})]})]}),j.total>5&&z(`div`,{className:`relative`,children:[W(ke,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),W(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),F.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[O]?.downloaded).length,0);return z(`div`,{children:[z(`div`,{className:`flex items-center gap-2 mb-2`,children:[W(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),W(`div`,{className:`flex-1 h-px bg-border`}),z(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),W(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=jt(e.id,t.id,O);return W(Ft,{addonId:e.id,model:t,format:O,isActive:s.has(n),progress:l.get(t.id),errorMsg:f.get(n),onDownload:()=>M(e.id,t.id,O),onDelete:()=>N(e.id,t.id,O)},`${e.id}/${t.id}`)}))})]},e.id)}),F.length===0&&W(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:h.trim()?z(V,{children:[`No models matching “`,h,`”`]}):z(V,{children:[`No models available for `,Mt(D),` format`]})})]})]});return t?W(`div`,{className:`space-y-4`,children:I}):W(We,{children:I})}function Rt({nodeId:e,refreshToken:t}){return W(Lt,{embedded:!0,nodeId:e})}var zt=[{concern:`pipeline`,label:`Pipeline`,advisory:!1},{concern:`audio`,label:`Audio`,advisory:!1},{concern:`decode`,label:`Decode`,advisory:!0,advisoryNote:`Advisory: decode currently runs co-located with the stream source (hub). Pins are stored and take effect with Phase-2 stream load-balancing.`}];function Bt(e,t){return e.filter(e=>e.currentNodeId!==t)}var Vt=`This node is not decoder-enabled (enabledDecoderNodes). Pinning detection here strands frames (0 fps) until frame-source-aware placement ships. Enable decode on this node first, or pick a decoder-enabled node.`;function Ht(e,t,n){return t.includes(e)?{verdict:`ok`}:n?{verdict:`warn`,reason:Vt}:{verdict:`block`,reason:Vt}}R();var Ut=`pipeline-orchestrator`,Wt=`enabledDecoderNodes`;function Gt(e,t){if(!e||typeof e!=`object`)return;let n=e.sections;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e.fields;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(n.key!==t)continue;let r=n.value;return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0}}}function Kt({nodeId:e,nodeName:t,concern:n,open:r,onClose:i}){let o=H(),s=Ge(),c=T(void 0),u=ne(void 0),d=x(void 0),f=M({addonId:Ut}),p=te(),m=l(),h=a(),[g,_]=U(new Set),[v,y]=U(!1),[b,S]=U(null),[C,w]=U([]),[E,D]=U(null),O=zt.find(e=>e.concern===n),k=B(()=>{let e=new Map;if(n===`pipeline`)for(let t of c.data??[])e.set(t.deviceId,t.agentNodeId);else if(n===`decode`)for(let t of u.data??[])e.set(t.deviceId,t.decoderNodeId);else for(let t of d.data??[])e.set(t.deviceId,t.nodeId);return e},[n,c.data,u.data,d.data]),A=B(()=>(s.data??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,currentNodeId:k.get(e.id)??null})),[s.data,k]),j=B(()=>Bt(A,e),[A,e]),N=Gt(f.data,Wt),P=n===`pipeline`?Ht(e,N??[],!1):{verdict:`ok`},[F,I]=U(!1);if(!r)return null;let ee=P.verdict===`block`,L=P.verdict===`warn`&&!F,re=g.size>0&&!v&&!ee&&!L,ie=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ae=j.length>0&&j.every(e=>g.has(e.deviceId)),oe=()=>{_(ae?new Set:new Set(j.map(e=>e.deviceId)))},se=async t=>{n===`pipeline`?await p.mutateAsync({deviceId:t,agentNodeId:e}):n===`decode`?await m.mutateAsync({deviceId:t,nodeId:e}):await h.mutateAsync({deviceId:t,nodeId:e})},ce=new Map(A.map(e=>[e.deviceId,e.name]));return z(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[W(`div`,{className:`absolute inset-0 bg-black/60`,onClick:i}),z(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col h-[80vh] rounded-xl border border-border bg-background shadow-2xl`,children:[z(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[z(`div`,{className:`min-w-0`,children:[z(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Batch assign `,O?.label??n,` → `,t]}),z(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:[`Pick the cameras whose `,O?.label.toLowerCase()??n,` should run on this node.`]})]}),W(`button`,{type:`button`,onClick:i,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,"aria-label":`Close`,children:W(ze,{className:`h-4 w-4`})})]}),z(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[O?.advisory&&O.advisoryNote&&W(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2 shrink-0`,children:z(`div`,{className:`flex items-start gap-2`,children:[W(Ve,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),W(`p`,{className:`text-[11px] text-warning`,children:O.advisoryNote})]})}),P.verdict!==`ok`&&W(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2 shrink-0`,children:z(`div`,{className:`flex items-start gap-2`,children:[W(Ve,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),z(`div`,{className:`min-w-0`,children:[W(`p`,{className:`text-[11px] text-destructive`,children:P.reason}),P.verdict===`warn`&&z(`label`,{className:`mt-1 flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[W(`input`,{type:`checkbox`,checked:F,onChange:e=>I(e.target.checked),className:`accent-primary`}),`I understand — assign anyway`]})]})]})}),j.length>0&&z(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle shrink-0`,children:[W(`input`,{type:`checkbox`,"aria-label":`Select all`,checked:ae,onChange:oe,className:`accent-primary`}),`Select all (`,j.length,`)`]}),W(`div`,{className:`flex-1 min-h-0 overflow-y-auto rounded-lg border border-border divide-y divide-border`,children:j.length===0?z(`div`,{className:`px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:[`No eligible cameras — all cameras are already assigned to `,t,`.`]}):j.map(e=>z(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground hover:bg-surface-hover cursor-pointer`,children:[W(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:g.has(e.deviceId),onChange:()=>ie(e.deviceId),className:`accent-primary`}),W(`span`,{className:`truncate`,children:e.name}),e.currentNodeId&&z(`span`,{className:`ml-auto text-[10px] text-foreground-subtle shrink-0`,children:[`on `,e.currentNodeId]})]},e.deviceId))}),(E!==null||C.length>0)&&z(`div`,{className:`space-y-1 text-[10px] shrink-0`,children:[E!==null&&E>0&&z(`p`,{className:`text-success`,children:[`Assigned `,E,` camera(s) to `,t,`.`]}),C.map(e=>z(`p`,{className:`text-destructive`,children:[e.name,`: `,e.message]},e.deviceId))]})]}),z(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[W(`span`,{className:`text-[10px] text-foreground-subtle`,children:v&&b?`${b.done} / ${b.total}…`:``}),z(`div`,{className:`flex items-center gap-2`,children:[W(`button`,{type:`button`,onClick:i,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),z(`button`,{type:`button`,onClick:async()=>{let e=[...g];if(e.length===0)return;y(!0),w([]),D(null),S({done:0,total:e.length});let t=[],n=0;for(let r=0;r<e.length;r+=1){let i=e[r];try{await se(i),n+=1}catch(e){t.push({deviceId:i,name:ce.get(i)??String(i),message:e instanceof Error?e.message:String(e)})}S({done:r+1,total:e.length})}y(!1),w(t),D(n),_(new Set),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},disabled:!re,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50 disabled:cursor-not-allowed`,children:[v&&W(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign `,g.size,` to `,t]})]})]})]})]})}R();function qt({nodeId:e,title:t}){let{data:n}=Ge(),{data:r}=T(void 0),i=B(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=B(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[o,s]=U(new Map);L(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||s(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),G(()=>{if(o.size===0)return;let e=setInterval(()=>{s(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[o.size]);let c=B(()=>{let e=[];for(let t of o.values())a&&!a.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[o,a]);return c.length===0?z(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):z(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[z(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[W(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),W(`span`,{className:`text-[10px] text-foreground-subtle`,children:c.length})]}),W(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=f(e.metrics.phase);return z(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[W(S,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),W(`span`,{className:`font-medium text-foreground/90 max-w-[120px] truncate`,children:t}),W(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),W(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}var Jt={key:`maxCameras`,type:`slider`,label:`Max cameras`,description:`Hard cap on cameras the balancer may assign to this node.`,min:1,max:64,step:1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Unlimited`};R();var Yt=350;function Xt(e){return typeof e==`number`&&e>0?Math.floor(e):null}function Zt({value:e,pending:n,errorMessage:r,onCommit:i}){let[a,o]=U(e);G(()=>{o(e)},[e]);let s=pe(i);return s.current=i,G(()=>{if(a===e)return;let t=setTimeout(()=>s.current(a),Yt);return()=>clearTimeout(t)},[a,e]),z(`div`,{className:`flex items-center gap-3 text-xs text-foreground`,children:[W(`div`,{className:`max-w-md flex-1`,children:W(t,{field:Jt,values:{maxCameras:a},disabled:n,onChange:(e,t)=>o(Xt(t))})}),n&&W(`span`,{className:`text-[10px] text-muted-foreground animate-pulse`,children:`Saving…`}),r&&z(`span`,{className:`text-[10px] text-destructive`,children:[`Save failed: `,r]})]})}R();function Qt(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 $t({nodeId:t,refreshToken:n}){let r=H(),[a,o]=U(null),[s,c]=U(null),[l,u]=U(null),d=(i(void 0).data??[]).find(e=>e.id===t)?.name??t,f=e({nodeId:t},{refetchOnMount:`always`}),p=b({agentNodeId:t},{refetchOnMount:`always`}),m=()=>{r.invalidateQueries({queryKey:[[`addonSettings`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]})},h=oe({onSuccess:m}),g=O({onSuccess:m}),_=f.data??null,v=p.data,y=_?.selectedEngine.format??`coreml`,x=B(()=>_?E(_):[],[_]),S=B(()=>[{agentNodeId:t,engineLabel:y}],[t,y]),C=(e,t)=>{let n=v?.addonDefaults[e];return!Qt(_,e)?.models.some(e=>!!e.formats[y])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId}:{kind:`disabled`}},T=a&&_?Qt(_,a.addonId):null,D=e=>{let n=v?.addonDefaults[e]??null;o({addonId:e,agentNodeId:t}),c(n)},k=(e,n)=>{if(!v)return;let r=v.addonDefaults[e],i=Qt(_,e);if(!r&&!i)return;let a={enabled:n,modelId:r?.modelId??i?.defaultModelId??``,settings:r?.settings??{}};h.mutate({agentNodeId:t,defaults:{...v.addonDefaults,[e]:a}})},A=()=>{o(null),c(null)},j=()=>{!s||!a||!v||h.mutate({agentNodeId:t,defaults:{...v.addonDefaults,[a.addonId]:s}},{onSuccess:A})};if(f.isLoading||p.isLoading)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading pipeline…`});if(f.error)return z(`div`,{className:`text-xs text-red-400`,children:[`Failed to load catalog: `,String(f.error)]});if(!_)return W(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog unavailable for this node (runner offline?).`});let M=a!==null&&T!==null&&s!==null,P=p.data?.maxCameras??null;return z(`div`,{className:`relative h-full w-full space-y-3`,children:[W(qt,{nodeId:t}),W(Zt,{value:P,pending:g.isPending,errorMessage:g.isError?g.error instanceof Error?g.error.message:`Unknown error`:null,onCommit:e=>g.mutate({agentNodeId:t,maxCameras:e})}),z(`div`,{className:`flex items-center gap-2 text-xs`,children:[W(`span`,{className:`font-medium text-muted-foreground`,children:`Batch assign:`}),W(`button`,{type:`button`,onClick:()=>u(`pipeline`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Pipeline…`}),W(`button`,{type:`button`,onClick:()=>u(`audio`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Audio…`}),W(`button`,{type:`button`,onClick:()=>u(`decode`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs text-foreground-subtle hover:bg-surface-hover`,children:`Decode… (advisory)`})]}),l&&W(Kt,{nodeId:t,nodeName:d,concern:l,open:l!==null,onClose:()=>u(null)}),W(`div`,{className:M?`pr-[360px]`:``,children:x.length>0?W(w,{tree:x,agents:S,getCellState:C,onCellClick:D,selectedCell:a,onToggleEnabled:k}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),W(N,{open:M,onClose:A,title:T?.name??``,subtitle:a?`${a.agentNodeId} · ${y}`:``,footer:z(V,{children:[W(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:A,children:`Cancel`}),W(`button`,{type:`button`,disabled:!s||!a||h.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:j,children:h.isPending?`Saving…`:`Save`})]}),children:T&&s&&a&&W(F,{mode:`agent`,addon:T,agentDefault:s,agentNodeId:a.agentNodeId,engineFormat:y,onChangeAgentConfig:e=>c(e)})})]})}var en=[`detection-pipeline`,`decoder-ffmpeg`,`audio-analyzer`,`pipeline-runner`];function tn({nodeId:e,refreshToken:t}){return z(`div`,{className:`flex flex-col h-full`,children:[W(mt,{nodeId:e,refreshToken:t}),W(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:W($e,{nodeId:e,addonIds:en,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:W(Et,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:W($t,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:W(Ot,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:W(Rt,{nodeId:e,refreshToken:t})}]})})]})}function nn({refreshToken:e}){let t=H(),n=D({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return z(`div`,{className:`space-y-6`,children:[W(ht,{refreshToken:e}),z(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[z(`div`,{className:`min-w-0`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),W(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · decoder · audio assignments per camera. Click the kebab to pin / unpin / move any role; expand the chevron for the per-camera broker drill-down.`})]}),z(`button`,{type:`button`,onClick:()=>n.mutate(void 0),disabled:n.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[W(Te,{className:`h-3.5 w-3.5`}),n.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),W(bt,{mode:`cluster`})]})}function rn({nodeId:e,nodeName:t,isHub:n,isOnline:r,value:i,onCommitted:a}){let o=O({onSuccess:a});return z(`div`,{className:`space-y-1.5 ${r?``:`opacity-50`}`,children:[z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`text-xs font-medium text-foreground`,children:t}),n&&W(`span`,{className:`rounded bg-muted px-1 py-0.5 text-[10px] text-foreground-subtle`,children:`hub`}),!r&&W(`span`,{className:`text-[10px] text-foreground-subtle`,children:`offline`})]}),W(Zt,{value:i,pending:o.isPending,errorMessage:o.isError?o.error instanceof Error?o.error.message:`Unknown error`:null,onCommit:t=>o.mutate({agentNodeId:e,maxCameras:t})})]})}function an(){let e=H(),t=i(void 0),n=I(void 0),r=t.data??[],a=new Map((n.data??[]).map(e=>[e.nodeId,e.settings.maxCameras])),o=()=>{e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]})};return z(`div`,{className:`rounded-lg border border-border bg-surface p-4 space-y-3`,children:[z(`div`,{children:[W(`h3`,{className:`text-xs font-semibold text-foreground`,children:`Max cameras — per node`}),W(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Set each cluster node's camera cap independently. Unlimited (no cap) unless you set a value; changes commit per node.`})]}),t.isLoading?W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading nodes…`}):r.length===0?W(`div`,{className:`text-xs text-foreground-subtle`,children:`No cluster nodes.`}):W(`div`,{className:`space-y-3`,children:r.map(e=>W(rn,{nodeId:e.id,nodeName:e.name,isHub:e.isHub,isOnline:e.isOnline,value:a.get(e.id)??null,onCommitted:o},e.id))})]})}var on=[`pipeline-orchestrator`];function sn({refreshToken:e}){return z(`div`,{className:`space-y-4 max-w-3xl`,children:[W(an,{}),W($e,{nodeId:`hub`,addonIds:on,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})]})}R();function cn({refreshToken:e}){let t=H(),{data:n,isLoading:r}=re(),[i,a]=U(null),[o,s]=U(``),[l,u]=U(``),d=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},f=ue({onSuccess:()=>{a(null),d()}}),p=c({onSuccess:d}),m=e=>{a(e.id),s(e.name),u(e.description??``)},h=()=>{a(null),s(``),u(``)},g=()=>{if(!i)return;let e=l.trim();f.mutate({id:i,name:o.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return W(`div`,{className:`space-y-6 max-w-4xl`,children:z(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[z(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[z(`div`,{children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),W(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),z(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?z(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[W(De,{className:`h-6 w-6 opacity-40`}),W(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):W(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return W(`li`,{className:`px-4 py-3 text-xs`,children:z(`div`,{className:`flex items-start gap-3`,children:[W(`div`,{className:`flex-1 min-w-0`,children:t?z(`div`,{className:`space-y-2`,children:[W(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:o,onChange:e=>s(e.target.value),placeholder:`Template name`,autoFocus:!0}),W(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:l,onChange:e=>u(e.target.value),placeholder:`Description (optional)`})]}):z(V,{children:[W(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&W(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),z(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[`engine `,e.config.engine.runtime,`/`,e.config.engine.backend,` ·`,` `,e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,z(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),W(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?z(V,{children:[z(`button`,{type:`button`,onClick: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:[W(Pe,{className:`h-3 w-3`}),`Save`]}),z(`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:[W(ze,{className:`h-3 w-3`}),`Cancel`]})]}):z(V,{children:[W(`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:W(Ee,{className:`h-3 w-3`})}),W(`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:W(He,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}R();function ln(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 un({nodeId:t,refreshToken:n}){let r=H(),a=_e().trpcClient,[o,s]=U(null),[c,l]=U(null),u=I(void 0,{refetchOnMount:`always`});Ke([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`,`addon.updated`]);let d=i(void 0,{refetchOnMount:`always`}),f=B(()=>{let e=new Set;for(let t of d.data??[])t.isOnline&&e.add(t.id);return e},[d.data]),p=e({nodeId:t},{refetchOnMount:`always`}),m=B(()=>(u.data??[]).filter(e=>f.has(e.nodeId)).map(e=>e.nodeId),[u.data,f]),h=he({enabled:m.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`schema-by-agent`,m.join(`,`),n],queryFn:async()=>{let e={};for(let t of m)try{e[t]=(await a.pipelineExecutor.getSchema.query({nodeId:t})).selectedEngine.format}catch{e[t]=`coreml`}return e}}),g=oe({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]}),r.invalidateQueries({queryKey:[[`addonSettings`]]})}}),_=B(()=>p.data?E(p.data):[],[p.data]),v=B(()=>{let e=u.data??[],t=f;return(t.size===0?[]:e.filter(e=>t.has(e.nodeId))).map(e=>{let t=h.data?.[e.nodeId];return{agentNodeId:e.nodeId,engineLabel:t??`(engine unknown)`}})},[u.data,h.data,f]),y=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e],r=h.data?.[t];return!ln(p.data??null,e)?.models.some(e=>r!==void 0&&!!e.formats[r])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId}:{kind:`disabled`}},b=o?u.data?.find(e=>e.nodeId===o.agentNodeId)??null:null,x=o&&p.data?ln(p.data,o.addonId):null,S=o?h.data?.[o.agentNodeId]??`coreml`:`coreml`,C=()=>{s(null),l(null)},T=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e]??null;s({addonId:e,agentNodeId:t}),l(n)},D=()=>{!c||!o||!b||g.mutate({agentNodeId:o.agentNodeId,defaults:{...b.settings.addonDefaults,[o.addonId]:c}},{onSuccess:C})};if(u.isLoading||p.isLoading)return W(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading agents…`});if(!p.data)return z(`div`,{className:`text-xs text-foreground-subtle`,children:[`Catalog unavailable for `,t,`.`]});let O=o!==null&&x!==null&&c!==null;return z(`div`,{className:`relative h-full w-full space-y-3`,children:[W(qt,{title:`Cluster cameras`}),W(`div`,{className:O?`pr-[360px]`:``,children:_.length>0&&v.length>0?W(w,{tree:_,agents:v,getCellState:y,onCellClick:T,selectedCell:o}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`No agents or catalog empty.`})}),W(N,{open:O,onClose:C,title:x?.name??``,subtitle:o?`${o.agentNodeId} · ${S}`:``,footer:z(V,{children:[W(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:C,children:`Cancel`}),W(`button`,{type:`button`,disabled:!c||!o||g.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:D,children:g.isPending?`Saving…`:`Save`})]}),children:x&&c&&o&&W(F,{mode:`agent`,addon:x,agentDefault:c,agentNodeId:o.agentNodeId,engineFormat:S,onChangeAgentConfig:e=>l(e)})})]})}R();function dn({types:e}){let t=H(),i=y(),{data:a}=g({}),o=ce(),s=B(()=>o.data??[],[o.data]),[c,l]=U(null),[u,d]=U(null),f=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},p=r({onSuccess:f}),m=n({onSuccess:f}),h=B(()=>{let e=new Map;for(let t of a??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[a]),_=e=>{e.isDefault||p.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},v=async e=>{if(e.isDefault){await i({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await i({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&m.mutate({id:e.id})},b=e.map(e=>s.find(t=>t.id===e)).filter(e=>e!==void 0);return z(`div`,{className:`space-y-3`,children:[b.length===0?W(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):b.map(e=>W(xe,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:h.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>d(e),onDelete:e=>{v(e)},onSetDefault:e=>_(e)},e.id)),c!==null&&W(Se,{initialType:c,onClose:()=>l(null),onCreated:()=>{f(),l(null)}}),u!==null&&W(be,{location:u,onClose:()=>d(null),onSaved:()=>{f(),d(null)}})]})}R();var fn=`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 mn(){let e=H(),{data:t}=i(void 0),{data:n,isLoading:r}=M({addonId:fn}),a=pn(n),o=ee({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=B(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,a,...e])].filter(Boolean)},[t,a]);return z(`div`,{className:`flex flex-col gap-6`,children:[z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),W(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),z(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?W(J,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):W(`select`,{value:a,onChange:e=>{e.target.value!==a&&o.mutate({addonId:fn,patch:{postProcessingNodeId:e.target.value}})},disabled:o.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>W(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),o.isPending&&W(J,{className:`h-4 w-4 animate-spin text-primary`})]})]}),z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),W(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),W(dn,{types:[`eventMedia`]})]})]})}R();var hn=`recorder`;function gn(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function _n(){let e=H(),{data:t}=i(void 0),{data:n,isLoading:r}=M({addonId:hn}),a=gn(n,`recordingNodeId`,`hub`),o=ee({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=B(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,a,...e])].filter(Boolean)},[t,a]);return z(`div`,{className:`flex flex-col gap-6`,children:[z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),W(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),z(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?W(J,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):W(`select`,{value:a,onChange:e=>{e.target.value!==a&&o.mutate({addonId:hn,patch:{recordingNodeId:e.target.value}})},disabled:o.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>W(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),o.isPending&&W(J,{className:`h-4 w-4 animate-spin text-primary`})]}),a!==`hub`&&z(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,W(`span`,{className:`font-medium`,children:a}),`. If the auto-derived host doesn't work, set the recorder's`,W(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),z(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[W(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),W(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),W(dn,{types:[`recordings`,`recordingsLow`]})]})]})}R();var vn=[{id:`assignments`,label:`Assignments`},{id:`pipeline`,label:`Pipeline`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`}];function yn({refreshToken:e}){let[t,n]=U(`assignments`),{data:r}=i(void 0),a=r?.find(e=>e.isHub&&e.isOnline)?.id??r?.find(e=>e.isOnline)?.id??null;return z(`div`,{className:`flex flex-col h-full`,children:[z(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[W(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),W(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),W(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:vn.map(e=>W(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),z(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&W(nn,{refreshToken:e}),t===`pipeline`&&(a?W(un,{nodeId:a,refreshToken:e}):W(`div`,{className:`text-xs text-foreground-subtle`,children:`No online node available — schema unreachable.`})),t===`events`&&W(mn,{}),t===`recording`&&W(_n,{}),t===`settings`&&W(sn,{refreshToken:e}),t===`templates`&&W(cn,{refreshToken:e})]})]})}function bn(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}R();var xn={healthy:`bg-green-500`,idle:`bg-yellow-400`,error:`bg-red-500`},Sn={healthy:`Healthy`,idle:`Idle`,error:`Error`};function Cn({health:e}){return W(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${xn[e]}`,title:Sn[e],"aria-label":Sn[e],role:`img`})}function wn({selectedDeviceId:e,onSelect:t}){let{data:n}=Ge(),{data:r}=ae({}),i=B(()=>{let e=new Map;for(let t of r??[])e.set(t.deviceId,t);return e},[r]),a=B(()=>(n??[]).filter(e=>e.isCamera).map(e=>{let t=i.get(e.id);return{deviceId:e.id,name:e.name,health:t===void 0?`idle`:bn(t)}}),[n,i]);return a.length===0?W(`div`,{className:`px-4 py-6 text-center text-[11px] text-foreground-subtle italic`,children:`No cameras found`}):W(`ul`,{className:`divide-y divide-border`,children:a.map(n=>{let r=n.deviceId===e;return W(`li`,{children:z(`button`,{type:`button`,onClick:()=>t(n.deviceId),className:[`w-full flex items-center gap-2.5 px-4 py-3 text-left transition-colors`,r?`bg-surface-active text-foreground`:`hover:bg-surface-hover text-foreground-subtle hover:text-foreground`].join(` `),"aria-pressed":r,children:[W(Cn,{health:n.health}),z(`span`,{className:`flex-1 min-w-0`,children:[W(`span`,{className:`block truncate text-[12px] font-medium leading-tight`,children:n.name}),z(`span`,{className:`block text-[10px] text-foreground-subtle leading-tight mt-0.5`,children:[`#`,n.deviceId]})]})]})},n.deviceId)})})}var $={camera:0,source:200,broker:400,decoder:600,motion:800,detection:800,audio:800,recorder:800},Tn=120;function En(e,t){return e===null||t===null?!1:e!==t}function Dn(e){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.reduce((e,t)=>e+t.inFps,0),r=e.profiles.reduce((e,t)=>e+t.outFps,0);return`${t} subs · ${n.toFixed(1)}→${r.toFixed(1)} fps`}function On(e){return`${e.actualFps.toFixed(1)} fps · q${e.queueDepth} · ${e.avgInferenceMs.toFixed(1)}ms`}function kn(e){return`shm ${e.shm.getFrameHits+e.shm.getFrameMisses>0?Math.round(e.shm.getFrameHits/(e.shm.getFrameHits+e.shm.getFrameMisses)*100):0}% hit`}function An(e){let t=[],n=[],r={id:`camera`,kind:`camera`,nodeId:null,data:{deviceId:e.deviceId},position:{x:$.camera,y:0}};t.push(r);let i={id:`source`,kind:`source`,nodeId:null,data:{streams:e.source.streams},position:{x:$.source,y:0}};t.push(i),n.push({id:`camera->source`,source:`camera`,target:`source`,crossNode:!1});let a=e.broker;if(a!==null){let e={id:`broker`,kind:`broker`,nodeId:null,data:{profiles:a.profiles,webrtcSessions:a.webrtcSessions,rtspRestream:a.rtspRestream},position:{x:$.broker,y:0}};t.push(e),n.push({id:`source->broker`,source:`source`,target:`broker`,crossNode:!1})}let o=e.decoder;if(o!==null){let r={id:`decoder`,kind:`decoder`,nodeId:o.nodeId,data:{nodeId:o.nodeId,formats:o.formats,sessionCount:o.sessionCount,shm:o.shm},position:{x:$.decoder,y:0}};t.push(r);let i=a===null?`source`:`broker`,s=a===null?void 0:Dn(a),c=a===null?kn(o):s;n.push({id:`${i}->decoder`,source:i,target:`decoder`,crossNode:En(null,o.nodeId),...c===void 0?{}:{label:c}});let l=0,u=e.motion;if(u!==null){let e={id:`motion`,kind:`motion`,nodeId:null,data:{enabled:u.enabled,fps:u.fps},position:{x:$.motion,y:l*Tn}};t.push(e),n.push({id:`decoder->motion`,source:`decoder`,target:`motion`,crossNode:!1}),l++}let d=e.detection;if(d!==null){let e={id:`detection`,kind:`detection`,nodeId:d.nodeId,data:{nodeId:d.nodeId,engine:d.engine,phase:d.phase,configuredFps:d.configuredFps,actualFps:d.actualFps,queueDepth:d.queueDepth,avgInferenceMs:d.avgInferenceMs,provisioning:d.provisioning},position:{x:$.detection,y:l*Tn}};t.push(e),n.push({id:`decoder->detection`,source:`decoder`,target:`detection`,crossNode:En(o.nodeId,d.nodeId),label:On(d)}),l++}let f=e.audio;if(f!==null){let e={id:`audio`,kind:`audio`,nodeId:f.nodeId,data:{nodeId:f.nodeId,enabled:f.enabled},position:{x:$.audio,y:l*Tn}};t.push(e),n.push({id:`decoder->audio`,source:`decoder`,target:`audio`,crossNode:En(o.nodeId,f.nodeId)}),l++}let p=e.recording;if(p!==null){let e={id:`recorder`,kind:`recorder`,nodeId:null,data:{mode:p.mode,active:p.active,storageBytes:p.storageBytes},position:{x:$.recorder,y:l*Tn}};t.push(e),n.push({id:`decoder->recorder`,source:`decoder`,target:`recorder`,crossNode:!1})}}return{nodes:t,edges:n}}R();function jn(e){let{data:t,isLoading:n}=A({deviceId:e}),[r,i]=U(void 0);return G(()=>{t!==void 0&&i(t)},[t]),L(K.PipelineCameraMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.detection===null?e:{...e,detection:{...e.detection,phase:n.metrics.phase,actualFps:n.metrics.actualFps,queueDepth:n.metrics.queueDepth,avgInferenceMs:n.metrics.avgInferenceTimeMs}})}),L(K.PipelineEngineProvisioning,e=>{let t=e.data;i(n=>{if(n===void 0||n.detection===null)return n;let r=n.detection.nodeId??n.assignment?.detectionNodeId??null;return r===null||e.source.type!==`node`||e.source.id!==r?n:{...n,detection:{...n.detection,provisioning:{state:t.state,error:t.error}}}})}),L(K.MotionAnalysis,t=>{t.source.type!==`device`||t.source.id!==e||i(e=>e===void 0||e.motion===null?e:{...e,motion:{...e.motion,enabled:!0}})}),L(K.StreamBrokerMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.broker===null?e:{...e,broker:{...e.broker,profiles:e.broker.profiles.map(e=>e.profile===n.profile?{...e,subscribers:n.stats.encodedSubscribers+n.stats.decodedSubscribers,inFps:n.stats.inputFps,outFps:n.stats.decodeFps}:e)}})}),L(K.PipelineAudioInferenceResult,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.audio===null?e:{...e,audio:{...e.audio,enabled:!0}})}),L(K.RecordingStarted,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!0}})}),L(K.RecordingStopped,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!1}})}),{status:r,isLoading:n}}function Mn({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`source`,position:X.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full bg-green-500 shrink-0`,"aria-label":`healthy`}),z(`span`,{className:`text-sm font-semibold truncate`,children:[`Camera #`,e.deviceId]})]}),W(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`source`})]})}function Nn(e){return e>0?`bg-green-500`:`bg-yellow-500`}function Pn({data:e}){let t=e.streams[0],n=e.streams.length;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`target`,position:X.Left}),W(Y,{type:`source`,position:X.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Nn(n)}`,"aria-label":n>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Source`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[n,` streams`]})]}),t!==void 0&&z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t.codec,` `,t.width,`×`,t.height,` `,t.fps,`fps`]})]})}function Fn(e){return e>0?`bg-green-500`:`bg-yellow-500`}function In({data:e}){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.length;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`target`,position:X.Left}),W(Y,{type:`source`,position:X.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Fn(t)}`,"aria-label":t>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Broker`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[n,` profiles`]})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t,` subs · WebRTC `,e.webrtcSessions,e.rtspRestream&&` · RTSP`]})]})}function Ln(e){return e>0?`bg-green-500`:`bg-yellow-500`}function Rn(e,t){let n=e+t;return n>0?Math.round(e/n*100):0}function zn({data:e}){let t=Rn(e.shm.getFrameHits,e.shm.getFrameMisses),n=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${n?` opacity-50`:``}`,children:[W(Y,{type:`target`,position:X.Left}),W(Y,{type:`source`,position:X.Right}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Ln(e.sessionCount)}`,"aria-label":e.sessionCount>0?`healthy`:`idle`}),W(`span`,{className:`text-sm font-semibold`,children:`Decoder`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),n&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.formats.join(`, `),` · `,e.sessionCount,` sessions`]}),z(`div`,{className:`text-xs text-muted-foreground`,children:[`shm `,t,`% hit`]})]})}function Bn(e){return e?`bg-green-500`:`bg-yellow-500`}function Vn({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`target`,position:X.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Bn(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),W(`span`,{className:`text-sm font-semibold`,children:`Motion`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.enabled?`enabled`:`disabled`,` · `,e.fps,` fps`]})]})}function Hn(e){return e.provisioning.state===`failed`?`bg-red-500`:e.phase===`active`?`bg-green-500`:(e.phase,`bg-yellow-500`)}function Un(e){return e===`ready`?`bg-green-500 text-white`:e===`failed`?`bg-red-500 text-white`:`bg-yellow-500 text-white`}function Wn({data:e}){let t=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[180px] px-3 py-2${t?` opacity-50`:``}`,children:[W(Y,{type:`target`,position:X.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Hn(e)}`,"aria-label":e.phase}),W(`span`,{className:`text-sm font-semibold`,children:`Detection`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.engine.backend,`·`,e.engine.device,` · `,e.phase]}),z(`div`,{className:`text-xs text-muted-foreground`,children:[e.actualFps.toFixed(1),`/`,e.configuredFps,` fps · q`,e.queueDepth,` ·`,` `,e.avgInferenceMs.toFixed(1),`ms`]}),z(`div`,{className:`flex items-center gap-1 mt-1`,children:[W(`span`,{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded ${Un(e.provisioning.state)}`,"aria-label":`provisioning ${e.provisioning.state}`,children:e.provisioning.state}),e.provisioning.state===`failed`&&e.provisioning.error!==void 0&&W(`span`,{className:`text-[10px] text-red-500 truncate`,children:e.provisioning.error})]})]})}function Gn(e){return e?`bg-green-500`:`bg-yellow-500`}function Kn({data:e}){let t=e.offline===!0;return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${t?` opacity-50`:``}`,children:[W(Y,{type:`target`,position:X.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Gn(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),W(`span`,{className:`text-sm font-semibold`,children:`Audio`}),z(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&W(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),W(`div`,{className:`text-xs text-muted-foreground mt-1`,children:e.enabled?`enabled`:`disabled`})]})}function qn(e){return e.mode===`off`?`bg-red-500`:e.active?`bg-green-500`:`bg-yellow-500`}function Jn(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:`${(e/1048576).toFixed(1)} MB`}function Yn({data:e}){return z(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[W(Y,{type:`target`,position:X.Left}),z(`div`,{className:`flex items-center gap-2`,children:[W(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${qn(e)}`,"aria-label":e.active?`active`:e.mode===`off`?`off`:`inactive`}),W(`span`,{className:`text-sm font-semibold`,children:`Recorder`}),W(`span`,{className:`text-xs text-muted-foreground`,children:e.mode})]}),z(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.active?`active`:`inactive`,` · `,Jn(e.storageBytes)]})]})}R();var Xn={camera:Mn,source:Pn,broker:In,decoder:zn,motion:Vn,detection:Wn,audio:Kn,recorder:Yn},Zn={stroke:`#f59e0b`,strokeWidth:2},Qn={strokeWidth:1.5},$n=`camstack-pipeline-flow-layout`;function er({deviceId:e}){let{status:t,isLoading:n}=jn(e),{data:r}=i(void 0),a=B(()=>{let e=new Set;for(let t of r??[])t.isOnline||e.add(t.id);return e},[r]),{computedNodes:o,rfEdges:s}=B(()=>{if(t===void 0)return{computedNodes:[],rfEdges:[]};let e=An(t);return{computedNodes:e.nodes.map(e=>({id:e.id,type:e.kind,position:{x:e.position.x,y:e.position.y},data:{...e.data,offline:e.nodeId!==null&&a.has(e.nodeId)}})),rfEdges:e.edges.map(e=>({id:e.id,source:e.source,target:e.target,animated:e.crossNode,style:e.crossNode?Zn:Qn,label:e.label}))}},[t,a]),{nodes:c,onNodesChange:l,resetLayout:u}=Ze($n,o);return n?W(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`Loading…`}):t===void 0?W(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`No pipeline data`}):z(`div`,{className:`w-full h-full relative`,children:[W(`button`,{type:`button`,onClick:u,className:`absolute top-2 right-2 z-10 text-xs px-2 py-1 rounded border border-border bg-background hover:bg-muted`,title:`Restore the automatic layout, discarding dragged positions`,children:`Reset layout`}),z(qe,{nodes:c,edges:s,onNodesChange:l,nodesDraggable:!0,nodeTypes:Xn,fitView:!0,proOptions:{hideAttribution:!0},children:[W(Je,{gap:20,size:1}),W(Ye,{showInteractive:!1})]})]})}R();var tr=`__cluster__`;function nr(e){return e===`cameras`?`cameras`:`nodes`}function rr(){let[e,t]=Fe(),n=nr(e.get(`view`)),r=e.get(`node`)??`__cluster__`,i=e.get(`camera`),a=i===null?null:parseInt(i,10),[o,s]=U(0),[c,l]=U(!1);return G(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:tr},{replace:!0})},[n,e,t]),z(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[z(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[z(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[W(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),W(`button`,{type:`button`,onClick:()=>{let e={view:`cameras`};a!==null&&(e.camera=String(a)),t(e,{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),z(`button`,{type:`button`,onClick:()=>s(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[W(Oe,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),z(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[z(`span`,{children:[c?`Hide`:`Show`,` `,n===`nodes`?`node list`:`camera list`]}),W(Le,{className:[`h-4 w-4 transition-transform`,c?`rotate-180`:``].join(` `)})]}),W(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?z(V,{children:[W(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:W(pt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),l(!1)},refreshToken:o})}),W(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?W(yn,{refreshToken:o}):W(tn,{nodeId:r,refreshToken:o})})]}):z(V,{children:[W(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:W(wn,{selectedDeviceId:a,onSelect:e=>{t({view:`cameras`,camera:String(e)},{replace:!0}),l(!1)}})}),W(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:a!==null&&Number.isFinite(a)&&!Number.isNaN(a)?W(er,{deviceId:a}):W(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Select a camera to view its pipeline flow`})})]})})]})}export{rr as PipelinePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Aa as e,Ma as t,ja as n}from"./src-
|
|
1
|
+
import{Aa as e,Ma as t,ja as n}from"./src-9Nw_7MUt.js";import{I as r,K as i,Q as a,S as o,W as s,b as c,q as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as f,V as p,c as ee,g as m,n as h,p as g,s as te}from"./player-overlays-CqpHdvYF.js";import{MaskShapeCanvas as _}from"./MaskShapeCanvas-pGn6MKOi.js";var ne=m(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]);a();var v=120,y=`privacy-mask`,b=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,x=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function S(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function re(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function C(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function w({deviceId:a}){let m=ee(g().trpcClient,a),[w,T]=l(null),[E,D]=l(!1),[O,k]=l(null),[A,j]=l(null),[M,N]=l(!1),[P,F]=l(!1),[I,L]=l(null),[R,z]=l(null),B=i(!1);d(()=>{if(!m)return;let e=!1;return B.current=!1,T(null),D(!1),k(null),j(null),F(!1),L(null),z(null),(async()=>{try{let t=await m.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(T(t),B.current)return;let n=await m.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);B.current=!0;let r={enabled:n.enabled,regions:n.regions};j(r),k(r)}catch(t){if(e)return;p(t)?D(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[m]);let V=s(()=>O!==null&&A!==null&&(O.enabled!==A.enabled||!C(O.regions,A.regions)),[O,A]),H=O?O.regions.length:0,U=w?w.maxRegions:0,W=i(0);d(()=>{W.current=U},[U]);let G=U>0&&H>=U,K=r(()=>{k(e=>e&&{...e,enabled:!e.enabled})},[]),q=r(e=>{L(typeof e==`number`?e:null)},[]),J=s(()=>O?O.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:`Zone ${String(e.id)}`})):[],[O]),Y=r((e,t)=>{let n=S(t);n&&k(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),X=r(e=>{let t=S(e);t&&(z(null),k(e=>{if(!e)return e;let n=W.current;if(n>0&&e.regions.length>=n)return e;let r=re(e.regions),i={id:r,enabled:!0,shape:t};return L(r),{...e,regions:[...e.regions,i]}}))},[]),Z=r(e=>{F(!0),L(null),z(e)},[]),ie=r(e=>{F(!0),z(null),L(e)},[]),ae=r(e=>{L(t=>t===e?null:t),k(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),oe=r(()=>{z(null),L(null),A&&k({enabled:A.enabled,regions:A.regions})},[A]),se=r(async()=>{if(!(!m||!O)){N(!0);try{await m.privacyMask?.setMask({patch:{enabled:O.enabled,regions:[...O.regions]}});let e=await m.privacyMask?.getStatus({});if(e){let t={enabled:e.enabled,regions:e.regions};j(t),k(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{N(!1)}}},[m,O]),ce=r(()=>{F(e=>(e&&(z(null),L(null)),!e))},[]),Q=w?.supportedShapes??[];h(s(()=>P&&!E&&w&&O?{id:y,order:v,node:u(_,{transparent:!0,items:J,supportedShapes:Q,polygonVertices:w.polygonVertices,selectedId:I,onSelect:q,onShapeChange:Y,onDrawComplete:X,drawingKind:R})}:null,[P,E,w,O,J,Q,I,q,Y,X,R]));let le=w?.supportedShapes.includes(`rect`)??!1,ue=w?.supportedShapes.includes(`polygon`)??!1,$=w!==null&&(w.maxRegions<=0||w.supportedShapes.length===0);return m?u(te,{title:`Privacy Mask`,icon:u(t,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:u(`div`,{className:`flex flex-col gap-3`,children:E||$?u(`p`,{className:`${f} leading-relaxed`,children:`This camera doesn't support an on-board privacy mask.`}):!E&&!$&&w!==null&&O!==null?o(c,{children:[o(`p`,{className:`${f} leading-relaxed`,children:[`Toggle `,u(`strong`,{className:`text-foreground`,children:`Edit mask`}),` to draw blanked-out zones on the live frame, then `,u(`strong`,{className:`text-foreground`,children:`Save`}),` to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`]}),o(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[u(`button`,{type:`button`,onClick:ce,disabled:M,"aria-pressed":P,className:P?x:b,children:P?`Done editing`:`Edit mask`}),u(`button`,{type:`button`,onClick:K,disabled:M,"aria-pressed":O.enabled,className:O.enabled?x:b,children:O.enabled?`Mask on`:`Mask off`}),le&&u(`button`,{type:`button`,onClick:()=>Z(`rect`),disabled:M||G,"aria-pressed":R===`rect`,className:R===`rect`?x:b,title:G?`Maximum zones reached`:`Add a rectangle zone`,children:`+ Rect`}),ue&&u(`button`,{type:`button`,onClick:()=>Z(`polygon`),disabled:M||G,"aria-pressed":R===`polygon`,className:R===`polygon`?x:b,title:G?`Maximum zones reached`:`Add a polygon zone`,children:`+ Polygon`}),o(`span`,{className:`${f} ml-1 tabular-nums`,children:[H,` / `,U,` zones`]}),u(`span`,{className:`flex-1`}),u(`button`,{type:`button`,onClick:oe,disabled:M||!V,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:`Revert`}),u(`button`,{type:`button`,onClick:()=>void se(),disabled:M||!V,className:x,children:M?`Saving…`:`Save`})]}),H>0?u(`div`,{className:`flex flex-col gap-1`,children:O.regions.map(t=>{let r=I===t.id,i=t.shape.kind===`polygon`?ne:n;return o(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${r?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[o(`button`,{type:`button`,onClick:()=>ie(t.id),disabled:M,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[u(i,{className:`h-3.5 w-3.5 shrink-0`}),o(`span`,{children:[`Zone `,t.id]}),u(`span`,{className:`text-foreground-faint capitalize`,children:t.shape.kind})]}),u(`button`,{type:`button`,onClick:()=>ae(t.id),disabled:M,"aria-label":`Delete zone ${String(t.id)}`,title:`Delete zone`,className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:u(e,{className:`h-3.5 w-3.5`})})]},t.id)})}):null]}):u(`p`,{className:`${f} leading-relaxed`,children:`Loading the camera's privacy mask…`})})}):null}export{w as PrivacyMaskSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,q as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as i}from"./radio-
|
|
1
|
+
import{Q as e,S as t,q as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as i}from"./radio-Bzq_SNgq.js";import{t as a}from"./server-Crr45iTm.js";import{t as o}from"./wifi-G6nDQGOi.js";import{V as s}from"./index-Da6GKRLl.js";var c=s(`cctv`,[[`path`,{d:`M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97`,key:`ir91b5`}],[`path`,{d:`M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z`,key:`jlp8i1`}],[`path`,{d:`M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15`,key:`19bib8`}],[`path`,{d:`M2 21v-4`,key:`l40lih`}],[`path`,{d:`M7 9h.01`,key:`19b3jx`}]]),l=s(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]);e();var u={frigate:{icon:c,color:`#3b82f6`,label:`Frigate`},scrypted:{icon:a,color:`#a855f7`,label:`Scrypted`},reolink:{icon:i,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:l,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:o,color:`#78716c`,label:`RTSP`},onvif:{icon:o,color:`#78716c`,label:`ONVIF`}},d={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`},f={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`};function p(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function m(e){return u[p(e)]??{icon:c,color:`#78716c`,label:e}}function h(e){let t=p(e);return`/api/addon-assets/${e.toLowerCase().startsWith(`provider-`)?e:`provider-${t}`}/assets/icon.svg`}function g({type:e,size:i=`md`,showLabel:a}){let o=m(e),s=o.icon,[c,l]=n(!1),u=h(e);return t(`div`,{className:`flex items-center gap-2`,children:[r(`div`,{className:`flex items-center justify-center rounded-lg ${f[i]}`,style:{backgroundColor:`${o.color}15`},children:c?r(s,{className:d[i],style:{color:o.color}}):r(`img`,{src:u,alt:o.label,className:d[i],onError:()=>l(!0)})}),a&&r(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:o.label})]})}export{g as t};
|