@camstack/addon-admin-ui 1.2.4 → 1.2.5
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-DLLHOb0V.js → AddLocationWizard-BMp3_ArA.js} +1 -1
- package/dist/assets/{AddonCollectionPage-CXdK5DVw.js → AddonCollectionPage-DXPJ4IsQ.js} +1 -1
- package/dist/assets/{Addons-BnRDPdAO.js → Addons-B8OcsvV3.js} +1 -1
- package/dist/assets/{AdminTabs-CKPXrh5g.js → AdminTabs-DO-Sr4Tn.js} +1 -1
- package/dist/assets/{AiProfiles-DF8Iwimr.js → AiProfiles-Ch4iQ3B5.js} +1 -1
- package/dist/assets/{BrokerForm-DBtI4fqS.js → BrokerForm-CQDxUGHE.js} +1 -1
- package/dist/assets/{Capabilities-D3zJXzep.js → Capabilities-MVkRHmqG.js} +1 -1
- package/dist/assets/{CapabilityBadges-sS8fUNXn.js → CapabilityBadges-Cfo1bKEC.js} +1 -1
- package/dist/assets/{Cluster-T-806lzA.js → Cluster-CTZ6NmZH.js} +1 -1
- package/dist/assets/{ClusterRecordingTab-D0VZTHnd.js → ClusterRecordingTab-XOXRgw3i.js} +1 -1
- package/dist/assets/{Dashboard-rBBckYg9.js → Dashboard-CqoVTR8j.js} +1 -1
- package/dist/assets/{Data-DEqDIJTg.js → Data-k2164crS.js} +1 -1
- package/dist/assets/DetectionIntelligence-OyCdr-l6.js +1 -0
- package/dist/assets/DeviceDetail-B1oypwPh.js +2 -0
- package/dist/assets/{Devices-8CZGDYo9.js → Devices-Chs4dn95.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-CE--T7vg.js → EmbedPlayerPage-DzbToLzX.js} +1 -1
- package/dist/assets/{Events-CW__khXF.js → Events-Ra5oWcAW.js} +1 -1
- package/dist/assets/{FormBuilder-CnPrIKl8.js → FormBuilder-DwiLYaBh.js} +1 -1
- package/dist/assets/Identity-BENlLATs.js +1 -0
- package/dist/assets/IntegrationDetail-ClHi8qin.js +1 -0
- package/dist/assets/{Integrations-B_qmTEZh.js → Integrations-DKaDwP5n.js} +1 -1
- package/dist/assets/{Integrations-Dx8tC9xn.js → Integrations-ZpqED3It.js} +1 -1
- package/dist/assets/{Logs-DRbHjutH.js → Logs-HW__FOKu.js} +1 -1
- package/dist/assets/{MotionZonesSettings-B04ag-FD.js → MotionZonesSettings-B8JW1fby.js} +1 -1
- package/dist/assets/{MyAccess-bbxTNufh.js → MyAccess-BzQfqfKG.js} +1 -1
- package/dist/assets/{Network-4paolRh4.js → Network-DFmblT51.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CbaGVYOT.js → NodeAddonsSettingsPanel-BuWZzBM3.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-B6npLWB6.js → NodeInferenceDevices-DL5frrfI.js} +1 -1
- package/dist/assets/{NotificationTargets-UnTU733T.js → NotificationTargets-CKImIUO1.js} +1 -1
- package/dist/assets/Pipeline-DENQvEkZ.js +1 -0
- package/dist/assets/{Plates-CZhfugSP.js → Plates-CYfYUSbU.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-BPvNIK5B.js → PrivacyMaskSettings-x8jlVyJq.js} +1 -1
- package/dist/assets/{ProviderIcon-BZnqn8uZ.js → ProviderIcon-wnMfbQy4.js} +1 -1
- package/dist/assets/{Recordings-CiQdp6va.js → Recordings-OiR9CZFY.js} +1 -1
- package/dist/assets/{ScanNetworkModal-9pywCJxI.js → ScanNetworkModal-1Q-_HgV7.js} +1 -1
- package/dist/assets/{Settings-Ds4B4oUQ.js → Settings-zUCdAuEc.js} +1 -1
- package/dist/assets/{Showroom-DaDoarT-.js → Showroom-C9TUeqec.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BtpHmZeh.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-MYM_DFPB.js} +1 -1
- package/dist/assets/{build-cluster-graph-rSheiRDR.js → build-cluster-graph-DFtjBwVv.js} +1 -1
- package/dist/assets/circle-check-big-W-N893Qq.js +1 -0
- package/dist/assets/clock-BV9uesj_.js +1 -0
- package/dist/assets/{copy-DqakY9L9.js → copy-6aAUV8Mk.js} +1 -1
- package/dist/assets/{debounced-invalidate-BaWy1MGf.js → debounced-invalidate-BMlW3lc0.js} +1 -1
- package/dist/assets/dist-66GfYkbI.js +7 -0
- package/dist/assets/{dist-BkamvsUd.js → dist-CEYXvLds.js} +1 -1
- package/dist/assets/{download-Cgk9aG5o.js → download-DSBNUTk-.js} +1 -1
- package/dist/assets/{face-bbox-DfMx6dB8.js → face-bbox-D9kGh3_L.js} +1 -1
- package/dist/assets/{hostInit-O7eY8s8B.js → hostInit-CHyZb2jR.js} +1 -1
- package/dist/assets/index-CqPUI4oB.js +4 -0
- package/dist/assets/{key-round-i8ES8hck.js → key-round-Cstot2GS.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-2e3f4d44.js → mf-entry-bootstrap-0-c9057dc3.js} +2 -2
- package/dist/assets/{pencil-y2nsLD1K.js → pencil-Bko5beeH.js} +1 -1
- package/dist/assets/{player-overlays-CkvkdCY0.js → player-overlays-BKrLqfAl.js} +1 -1
- package/dist/assets/plus-S9U4mORX.js +1 -0
- package/dist/assets/{radio-SL276jOL.js → radio-DVfJmyYr.js} +1 -1
- package/dist/assets/{refresh-cw-MeV_G-fS.js → refresh-cw-Cnkkn0UW.js} +1 -1
- package/dist/assets/remoteEntry-DZ0wTuWP.js +1 -0
- package/dist/assets/{rotate-ccw-9DElWl1O.js → rotate-ccw-DDJ9B3KX.js} +1 -1
- package/dist/assets/rotate-cw-CcMz09b3.js +1 -0
- package/dist/assets/search-bAcYqDxO.js +1 -0
- package/dist/assets/{send-BA7AmaE8.js → send-ea1mmeKQ.js} +1 -1
- package/dist/assets/{server-Cg5TxTo9.js → server-B33eaAVX.js} +1 -1
- package/dist/assets/square-CasTblrl.js +1 -0
- package/dist/assets/{square-check-big-Bghaf-FM.js → square-check-big-BipJcw1N.js} +1 -1
- package/dist/assets/{src-CS6t478y.js → src-CwIdcVoz.js} +10 -10
- package/dist/assets/src-awTRXPIW.js +7 -0
- package/dist/assets/{upload-CMECam4K.js → upload-B33Dg1HW.js} +1 -1
- package/dist/assets/{useEventInvalidation-e7U4PVdx.js → useEventInvalidation-CJRYaSHm.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Ci7j-Bp5.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DQyAd46J.js} +2 -2
- package/dist/assets/{wifi-BrO0lnZN.js → wifi-13IJJu3_.js} +1 -1
- package/dist/assets/{zap-PR1_l4is.js → zap-BKYskYDR.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +25 -3
- package/package.json +1 -1
- package/dist/assets/DetectionIntelligence-zizgqWm8.js +0 -1
- package/dist/assets/DeviceDetail-1YcSca5P.js +0 -2
- package/dist/assets/Identity-Bwol_luT.js +0 -1
- package/dist/assets/IntegrationDetail-Dqiu-mEE.js +0 -1
- package/dist/assets/Pipeline-BFP9xqX-.js +0 -1
- package/dist/assets/circle-check-big-DUpEI8pg.js +0 -1
- package/dist/assets/clock-D9qIgXEd.js +0 -1
- package/dist/assets/dist-C9qj5V_V.js +0 -7
- package/dist/assets/index-C3HbZT6b.js +0 -4
- package/dist/assets/plus-BMJjznU2.js +0 -1
- package/dist/assets/remoteEntry-CEmFRK6K.js +0 -1
- package/dist/assets/rotate-cw-C3ZRlyDn.js +0 -1
- package/dist/assets/search-D1RCNP2F.js +0 -1
- package/dist/assets/square-BsDohB3h.js +0 -1
- package/dist/assets/src-lbvXy3B8.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ra as e,S as t,bo as n,do as r,go as i,ho as a,mo as o,po as s,uo as c,vo as l,yo as u}from"./src-CS6t478y.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-CkvkdCY0.js";import{t as y}from"./circle-check-big-DUpEI8pg.js";import{t as b}from"./pencil-y2nsLD1K.js";import{t as x}from"./plus-BMJjznU2.js";import{t as S}from"./search-D1RCNP2F.js";import{t as C}from"./send-BA7AmaE8.js";import{N as w,S as T,V as E,s as D}from"./index-C3HbZT6b.js";import{t as O}from"./AdminPage-BwmGKnRf.js";d();var k=e=>typeof e==`string`&&e.length>0;function A(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 j(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function M(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];k(i)&&n.push({mediaType:r,url:i})}return n}function N(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=k(r.label),i=k(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 P(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=M(e,t.attachmentUrls),i=N(e,t.actions),a=e.ttl&&k(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:j(e,t.format),priority:F(t.priority),...k(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&k(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&k(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...k(t.tag)?{tag:t.tag}:{}}}function F(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function I(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 L(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var R={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 z(e,t){let n=L(e);switch(t){case`minimal`:return{...n,body:`Test notification`};case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)};case`critical`:{let t=I(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]=R[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 B=[{id:`minimal`,label:`Minimal (body only)`},{id:`everything`,label:`Everything supported`},{id:`overflow`,label:`Overflow`},{id:`critical`,label:`Critical`}],V=`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`,H=`block text-[11px] font-medium text-foreground mb-1`;function U({target:e,kind:t,open:i,onClose:l}){let d=v(),m=p(()=>A(t.caps),[t.caps]),[y,b]=h(()=>L(t.caps)),[x,S]=h(null),w=p(()=>P(t.caps,y),[t.caps,y]),E=y.body.length,D=E>m.bodyMaxLen,O=e=>b(t=>({...t,...e})),k=g({mutationFn:()=>d.trpcClient.notificationOutput.testTarget.mutate({addonId:e.addonId,targetId:e.id,sample:P(t.caps,y)}),onMutate:()=>S(null),onSuccess:e=>S(e),onError:e=>S({success:!1,error:e instanceof Error?e.message:`Test failed`})}),j=e=>{b(z(t.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},O({actions:r})};return _(c,{open:i,onOpenChange:e=>!e&&l(),children:f(r,{width:`lg`,className:`!max-w-2xl`,children:[_(o,{children:f(a,{children:[`Test "`,e.name,`" (`,t.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:B.map(e=>_(n,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>j(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:H,children:`Level`}),f(`select`,{className:V,value:y.level,onChange:e=>O({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&&_(u,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&_(u,{variant:`info`,children:`silent`}),e.flags?.noPush&&_(u,{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:H,children:[`Priority (ordinal): `,y.priority]}),_(`input`,{type:`range`,min:1,max:5,step:1,value:y.priority,onChange:e=>O({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),m.formats.length>0&&f(`div`,{children:[_(`label`,{className:H,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:()=>O({format:e})}),e]},e))})]}),f(`div`,{children:[_(`label`,{className:H,children:`Title`}),_(`input`,{className:V,value:y.title,onChange:e=>O({title:e.target.value})})]}),f(`div`,{children:[f(`label`,{className:H,children:[`Body`,` `,f(`span`,{className:D?`text-danger`:`text-foreground-subtle`,children:[`(`,E,`/`,m.bodyMaxLen,D?` — overflow`:``,`)`]})]}),_(`textarea`,{className:`${V} min-h-[80px] resize-y`,value:y.body,onChange:e=>O({body:e.target.value})})]}),m.attachmentSlots.length>0&&f(`div`,{children:[f(`label`,{className:H,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:V,placeholder:`${e} URL`,value:y.attachmentUrls[e]??``,onChange:t=>O({attachmentUrls:{...y.attachmentUrls,[e]:t.target.value}})})]},e))})]}),m.showActions&&f(`div`,{children:[f(`label`,{className:H,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:V,placeholder:`label`,value:y.actions[t]?.label??``,onChange:e=>M(t,`label`,e.target.value)}),_(`input`,{className:V,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:H,children:`Click URL`}),_(`input`,{className:V,value:y.clickUrl,onChange:e=>O({clickUrl:e.target.value})})]}),m.showSound&&f(`div`,{children:[_(`label`,{className:H,children:`Sound`}),_(`input`,{className:V,value:y.sound,onChange:e=>O({sound:e.target.value})})]}),m.showTtl&&f(`div`,{children:[_(`label`,{className:H,children:`TTL (seconds)`}),_(`input`,{className:V,type:`number`,value:y.ttl,onChange:e=>O({ttl:e.target.value})})]}),m.showTag&&f(`div`,{children:[_(`label`,{className:H,children:`Tag`}),_(`input`,{className:V,value:y.tag,onChange:e=>O({tag:e.target.value})})]})]}),x&&_(W,{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(w,null,2)})]})]}),f(s,{children:[_(n,{variant:`secondary`,size:`sm`,type:`button`,onClick:l,children:`Close`}),f(n,{size:`sm`,type:`button`,disabled:k.isPending||y.body.length===0,onClick:()=>k.mutate(),children:[k.isPending?_(T,{className:`h-3.5 w-3.5 animate-spin`}):_(C,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function W({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`}):_(w,{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 G(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 K(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 q(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 J(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 Y=[`notificationOutput`,`listTargets`],X=[`notificationOutput`,`listTargetKinds`];function Z({kind:e,imgClassName:t,fallbackClassName:n}){return e?.iconUrl?_(`img`,{src:e.iconUrl,alt:e.label,className:t,loading:`lazy`,draggable:!1}):_(`span`,{className:n,children:e?.icon??`🔔`})}function Q(){let t=v(),[r,a]=h({mode:`closed`}),[o,s]=h(null),c=m({queryKey:Y,queryFn:()=>t.trpcClient.notificationOutput.listTargets.query({})}),d=m({queryKey:X,queryFn:async()=>(await t.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>{let t=e.iconUrl;return{...e,configSchema:e.configSchema,iconUrl:t}})}),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:e=>t.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:e.target.addonId,targetId:e.target.id,enabled:e.enabled}),onSuccess:()=>void c.refetch()}),k=g({mutationFn:e=>t.trpcClient.notificationOutput.deleteTarget.mutate({addonId:e.addonId,targetId:e.id}),onSuccess:()=>void c.refetch()}),A=o?S.get(o.kind):void 0;return f(O,{icon:E,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(n,{size:`sm`,type:`button`,onClick:()=>a({mode:`pick-kind`}),children:[_(x,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[c.isLoading&&_(`div`,{className:`flex items-center justify-center py-16`,children:_(T,{className:`h-6 w-6 animate-spin text-primary`})}),c.isError&&!c.isLoading&&_(e,{title:`Failed to load targets`,message:c.error instanceof Error?c.error.message:`Unknown error`,onRetry:()=>void c.refetch()}),!c.isLoading&&!c.isError&&(c.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.`}),(c.data??[]).length>0&&_(l,{children:_(`ul`,{className:`divide-y divide-border`,children:(c.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:_(Z,{kind:t,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:``})}),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&&_(u,{variant:`warning`,children:`disabled`}),_(i,{checked:e.enabled,onCheckedChange:t=>w.mutate({target:e,enabled:t}),"aria-label":`toggle ${e.name}`}),_(n,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>s(e),title:`Test`,children:_(C,{className:`h-3.5 w-3.5`})}),_(n,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>t&&a({mode:`form`,kind:t,target:e}),title:`Edit`,children:_(b,{className:`h-3.5 w-3.5`})}),_(n,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>k.mutate(e),title:`Delete`,children:_(D,{className:`h-3.5 w-3.5 text-danger`})})]},e.id)})})}),r.mode===`pick-kind`&&_($,{kinds:y,onCancel:()=>a({mode:`closed`}),onPick:e=>a({mode:`form`,kind:e,target:null})}),r.mode===`form`&&_(ee,{kind:r.kind,target:r.target,onCancel:()=>a({mode:`closed`}),onSaved:()=>{a({mode:`closed`}),c.refetch()}}),o&&A&&_(U,{target:o,kind:A,open:!0,onClose:()=>s(null)})]})}function $({kinds:e,onPick:t,onCancel:r}){let i=p(()=>G(e),[e]);return f(l,{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`}),_(n,{size:`sm`,variant:`ghost`,type:`button`,onClick:r,children:`Cancel`})]}),i.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.`}),i.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(n=>f(`button`,{type:`button`,onClick:()=>t(n),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:[_(Z,{kind:n,imgClassName:`h-7 w-7 object-contain`,fallbackClassName:`text-lg leading-7`}),_(`span`,{className:`font-medium text-foreground`,children:n.label}),n.supportsDiscovery&&_(u,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${n.kind}`))})]},e.addonId))]})}function ee({kind:e,target:r,onSaved:i,onCancel:a}){let o=v(),s=p(()=>K(e.configSchema),[e.configSchema]),c=p(()=>r?.config??{},[r]),[u,d]=h(r?.name??e.label),[m,y]=h(()=>r?J(r.config,s):{}),[b,x]=h(null),[C,w]=h(null),E=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`)}),D=g({mutationFn:()=>{let t=q(m,c,s),n={id:r?.id??`${e.kind}-${Date.now()}`,name:u,kind:e.kind,addonId:e.addonId,enabled:r?.enabled??!0,config:t};return o.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:n})},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(l,{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:[_(Z,{kind:e,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:`text-lg`}),r?`Edit ${r.name}`:`Add ${e.label} target`]}),_(n,{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(n,{size:`sm`,variant:`outline`,type:`button`,disabled:E.isPending,onClick:()=>{w(null),E.mutate()},children:[E.isPending?_(T,{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&&r&&_(`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.`}),_(t,{schema:e.configSchema,values:m,onChange:y}),f(`div`,{className:`flex justify-end gap-2`,children:[_(n,{variant:`secondary`,size:`sm`,type:`button`,onClick:a,children:`Cancel`}),f(n,{size:`sm`,type:`button`,disabled:D.isPending||u.trim().length===0,onClick:()=>{w(null),D.mutate()},children:[D.isPending&&_(T,{className:`h-3.5 w-3.5 animate-spin`}),r?`Save changes`:`Create target`]})]})]})}export{Q as NotificationTargetsPage,Q as default};
|
|
1
|
+
import{Ra as e,S as t,_o as n,bo as r,do as i,fo as a,go as o,ho as s,mo as c,xo as l,yo as u}from"./src-CwIdcVoz.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-BKrLqfAl.js";import{t as y}from"./circle-check-big-W-N893Qq.js";import{t as b}from"./pencil-Bko5beeH.js";import{t as x}from"./plus-S9U4mORX.js";import{t as S}from"./search-bAcYqDxO.js";import{t as C}from"./send-ea1mmeKQ.js";import{N as w,S as T,V as E,s as D}from"./index-CqPUI4oB.js";import{t as O}from"./AdminPage-BwmGKnRf.js";d();var k=e=>typeof e==`string`&&e.length>0;function A(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 j(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function M(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];k(i)&&n.push({mediaType:r,url:i})}return n}function N(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=k(r.label),i=k(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 P(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=M(e,t.attachmentUrls),i=N(e,t.actions),a=e.ttl&&k(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:j(e,t.format),priority:F(t.priority),...k(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&k(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&k(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...k(t.tag)?{tag:t.tag}:{}}}function F(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function I(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 L(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var R={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 z(e,t){let n=L(e);switch(t){case`minimal`:return{...n,body:`Test notification`};case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)};case`critical`:{let t=I(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]=R[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 B=[{id:`minimal`,label:`Minimal (body only)`},{id:`everything`,label:`Everything supported`},{id:`overflow`,label:`Overflow`},{id:`critical`,label:`Critical`}],V=`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`,H=`block text-[11px] font-medium text-foreground mb-1`;function U({target:e,kind:t,open:n,onClose:u}){let d=v(),m=p(()=>A(t.caps),[t.caps]),[y,b]=h(()=>L(t.caps)),[x,S]=h(null),w=p(()=>P(t.caps,y),[t.caps,y]),E=y.body.length,D=E>m.bodyMaxLen,O=e=>b(t=>({...t,...e})),k=g({mutationFn:()=>d.trpcClient.notificationOutput.testTarget.mutate({addonId:e.addonId,targetId:e.id,sample:P(t.caps,y)}),onMutate:()=>S(null),onSuccess:e=>S(e),onError:e=>S({success:!1,error:e instanceof Error?e.message:`Test failed`})}),j=e=>{b(z(t.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},O({actions:r})};return _(i,{open:n,onOpenChange:e=>!e&&u(),children:f(a,{width:`lg`,className:`!max-w-2xl`,children:[_(s,{children:f(o,{children:[`Test "`,e.name,`" (`,t.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:B.map(e=>_(l,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>j(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:H,children:`Level`}),f(`select`,{className:V,value:y.level,onChange:e=>O({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&&_(r,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&_(r,{variant:`info`,children:`silent`}),e.flags?.noPush&&_(r,{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:H,children:[`Priority (ordinal): `,y.priority]}),_(`input`,{type:`range`,min:1,max:5,step:1,value:y.priority,onChange:e=>O({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),m.formats.length>0&&f(`div`,{children:[_(`label`,{className:H,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:()=>O({format:e})}),e]},e))})]}),f(`div`,{children:[_(`label`,{className:H,children:`Title`}),_(`input`,{className:V,value:y.title,onChange:e=>O({title:e.target.value})})]}),f(`div`,{children:[f(`label`,{className:H,children:[`Body`,` `,f(`span`,{className:D?`text-danger`:`text-foreground-subtle`,children:[`(`,E,`/`,m.bodyMaxLen,D?` — overflow`:``,`)`]})]}),_(`textarea`,{className:`${V} min-h-[80px] resize-y`,value:y.body,onChange:e=>O({body:e.target.value})})]}),m.attachmentSlots.length>0&&f(`div`,{children:[f(`label`,{className:H,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:V,placeholder:`${e} URL`,value:y.attachmentUrls[e]??``,onChange:t=>O({attachmentUrls:{...y.attachmentUrls,[e]:t.target.value}})})]},e))})]}),m.showActions&&f(`div`,{children:[f(`label`,{className:H,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:V,placeholder:`label`,value:y.actions[t]?.label??``,onChange:e=>M(t,`label`,e.target.value)}),_(`input`,{className:V,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:H,children:`Click URL`}),_(`input`,{className:V,value:y.clickUrl,onChange:e=>O({clickUrl:e.target.value})})]}),m.showSound&&f(`div`,{children:[_(`label`,{className:H,children:`Sound`}),_(`input`,{className:V,value:y.sound,onChange:e=>O({sound:e.target.value})})]}),m.showTtl&&f(`div`,{children:[_(`label`,{className:H,children:`TTL (seconds)`}),_(`input`,{className:V,type:`number`,value:y.ttl,onChange:e=>O({ttl:e.target.value})})]}),m.showTag&&f(`div`,{children:[_(`label`,{className:H,children:`Tag`}),_(`input`,{className:V,value:y.tag,onChange:e=>O({tag:e.target.value})})]})]}),x&&_(W,{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(w,null,2)})]})]}),f(c,{children:[_(l,{variant:`secondary`,size:`sm`,type:`button`,onClick:u,children:`Close`}),f(l,{size:`sm`,type:`button`,disabled:k.isPending||y.body.length===0,onClick:()=>k.mutate(),children:[k.isPending?_(T,{className:`h-3.5 w-3.5 animate-spin`}):_(C,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function W({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`}):_(w,{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 G(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 K(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 q(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 J(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 Y=[`notificationOutput`,`listTargets`],X=[`notificationOutput`,`listTargetKinds`];function Z({kind:e,imgClassName:t,fallbackClassName:n}){return e?.iconUrl?_(`img`,{src:e.iconUrl,alt:e.label,className:t,loading:`lazy`,draggable:!1}):_(`span`,{className:n,children:e?.icon??`🔔`})}function Q(){let t=v(),[i,a]=h({mode:`closed`}),[o,s]=h(null),c=m({queryKey:Y,queryFn:()=>t.trpcClient.notificationOutput.listTargets.query({})}),d=m({queryKey:X,queryFn:async()=>(await t.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>{let t=e.iconUrl;return{...e,configSchema:e.configSchema,iconUrl:t}})}),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:e=>t.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:e.target.addonId,targetId:e.target.id,enabled:e.enabled}),onSuccess:()=>void c.refetch()}),k=g({mutationFn:e=>t.trpcClient.notificationOutput.deleteTarget.mutate({addonId:e.addonId,targetId:e.id}),onSuccess:()=>void c.refetch()}),A=o?S.get(o.kind):void 0;return f(O,{icon:E,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(l,{size:`sm`,type:`button`,onClick:()=>a({mode:`pick-kind`}),children:[_(x,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[c.isLoading&&_(`div`,{className:`flex items-center justify-center py-16`,children:_(T,{className:`h-6 w-6 animate-spin text-primary`})}),c.isError&&!c.isLoading&&_(e,{title:`Failed to load targets`,message:c.error instanceof Error?c.error.message:`Unknown error`,onRetry:()=>void c.refetch()}),!c.isLoading&&!c.isError&&(c.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.`}),(c.data??[]).length>0&&_(u,{children:_(`ul`,{className:`divide-y divide-border`,children:(c.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:_(Z,{kind:t,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:``})}),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&&_(r,{variant:`warning`,children:`disabled`}),_(n,{checked:e.enabled,onCheckedChange:t=>w.mutate({target:e,enabled:t}),"aria-label":`toggle ${e.name}`}),_(l,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>s(e),title:`Test`,children:_(C,{className:`h-3.5 w-3.5`})}),_(l,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t,onClick:()=>t&&a({mode:`form`,kind:t,target:e}),title:`Edit`,children:_(b,{className:`h-3.5 w-3.5`})}),_(l,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>k.mutate(e),title:`Delete`,children:_(D,{className:`h-3.5 w-3.5 text-danger`})})]},e.id)})})}),i.mode===`pick-kind`&&_($,{kinds:y,onCancel:()=>a({mode:`closed`}),onPick:e=>a({mode:`form`,kind:e,target:null})}),i.mode===`form`&&_(ee,{kind:i.kind,target:i.target,onCancel:()=>a({mode:`closed`}),onSaved:()=>{a({mode:`closed`}),c.refetch()}}),o&&A&&_(U,{target:o,kind:A,open:!0,onClose:()=>s(null)})]})}function $({kinds:e,onPick:t,onCancel:n}){let i=p(()=>G(e),[e]);return f(u,{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`}),_(l,{size:`sm`,variant:`ghost`,type:`button`,onClick:n,children:`Cancel`})]}),i.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.`}),i.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(n=>f(`button`,{type:`button`,onClick:()=>t(n),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:[_(Z,{kind:n,imgClassName:`h-7 w-7 object-contain`,fallbackClassName:`text-lg leading-7`}),_(`span`,{className:`font-medium text-foreground`,children:n.label}),n.supportsDiscovery&&_(r,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${n.kind}`))})]},e.addonId))]})}function ee({kind:e,target:n,onSaved:r,onCancel:i}){let a=v(),o=p(()=>K(e.configSchema),[e.configSchema]),s=p(()=>n?.config??{},[n]),[c,d]=h(n?.name??e.label),[m,y]=h(()=>n?J(n.config,o):{}),[b,x]=h(null),[C,w]=h(null),E=g({mutationFn:()=>a.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`)}),D=g({mutationFn:()=>{let t=q(m,s,o),r={id:n?.id??`${e.kind}-${Date.now()}`,name:c,kind:e.kind,addonId:e.addonId,enabled:n?.enabled??!0,config:t};return a.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:r})},onSuccess:r,onError:e=>w(e instanceof Error?e.message:`Save failed`)}),O=e=>{d(e.suggestedName),y(t=>({...t,...e.config})),x(null)};return f(u,{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:[_(Z,{kind:e,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:`text-lg`}),n?`Edit ${n.name}`:`Add ${e.label} target`]}),_(l,{size:`sm`,variant:`ghost`,type:`button`,onClick:i,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:c,onChange:e=>d(e.target.value)})]}),e.supportsDiscovery&&f(`div`,{className:`space-y-2`,children:[f(l,{size:`sm`,variant:`outline`,type:`button`,disabled:E.isPending,onClick:()=>{w(null),E.mutate()},children:[E.isPending?_(T,{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}`))})]}),o.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.`}),_(t,{schema:e.configSchema,values:m,onChange:y}),f(`div`,{className:`flex justify-end gap-2`,children:[_(l,{variant:`secondary`,size:`sm`,type:`button`,onClick:i,children:`Cancel`}),f(l,{size:`sm`,type:`button`,disabled:D.isPending||c.trim().length===0,onClick:()=>{w(null),D.mutate()},children:[D.isPending&&_(T,{className:`h-3.5 w-3.5 animate-spin`}),n?`Save changes`:`Create target`]})]})]})}export{Q as NotificationTargetsPage,Q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$r as e,Ci as t,Do as n,Ei as r,Eo as i,Ha as a,Ii as o,Ja as s,Ka as c,La as l,Mi as u,Ni as d,Pi as f,Qr as p,Si as m,T as h,Ti as g,Ua as _,Va as v,Vr as y,Wa as b,Xa as x,Za as S,_ as C,_i as w,ai as T,bi as E,bo as D,ci as O,di as k,ei as ee,ft as A,g as j,gi as M,ii as te,ji as N,li as ne,lt as re,mi as ie,ni as ae,oi as oe,qa as se,ri as ce,si as le,ti as ue,ut as de,vi as fe,wi as pe,xi as me,yi as he}from"./src-CwIdcVoz.js";import{I as ge,K as _e,Q as P,S as F,T as ve,W as I,b as L,o as R,q as z,x as B,z as V}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{G as ye,K as be,X as xe}from"./src-awTRXPIW.js";import{c as Se,n as H,o as Ce,r as we,s as Te,t as Ee}from"./NodeInferenceDevices-DL5frrfI.js";import{t as De}from"./download-DSBNUTk-.js";import{i as Oe}from"./AddLocationWizard-BMp3_ArA.js";import{n as ke,r as Ae,t as je}from"./zap-BKYskYDR.js";import{t as Me}from"./pencil-Bko5beeH.js";import{t as Ne}from"./plus-S9U4mORX.js";import{t as Pe}from"./radio-DVfJmyYr.js";import{t as Fe}from"./refresh-cw-Cnkkn0UW.js";import{t as Ie}from"./search-bAcYqDxO.js";import{t as Le}from"./server-B33eaAVX.js";import{t as Re}from"./square-check-big-BipJcw1N.js";import{t as ze}from"./square-CasTblrl.js";import{E as Be,I as Ve,J as He,L as U,M as Ue,N as We,P as Ge,S as W,T as Ke,W as qe,i as Je,j as G,o as Ye,s as Xe}from"./index-CqPUI4oB.js";import{t as Ze}from"./AdminPage-BwmGKnRf.js";import{t as Qe}from"./useEventInvalidation-CJRYaSHm.js";import{r as $e,t as et}from"./build-cluster-graph-DFtjBwVv.js";import{n as tt}from"./format-size-CO9d3C3-.js";import{t as nt}from"./NodeAddonsSettingsPanel-BuWZzBM3.js";import{n as rt,t as it}from"./ClusterRecordingTab-XOXRgw3i.js";var at=qe(`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`}]]),ot=qe(`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`}]]),st=qe(`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`}]]);P();function ct(e){return e}function lt(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ut(e,t){return typeof e==`boolean`?e:ct(t)}function dt(e,t){return{pipeline:ut(lt(e,`detect`),t),audio:ut(lt(e,`audio`),t),ingest:ut(lt(e,`ingest`),t)}}function ft(e,t,n){let r=e?.find(e=>e.nodeId===t);return dt(r?.settings,n)}function pt({selectedNodeId:e,onSelect:t,refreshToken:r}){let{data:i}=y(void 0),{data:a}=M(void 0),{data:o}=fe(void 0),s=new Map;for(let e of a??[])s.set(e.agentNodeId,(s.get(e.agentNodeId)??0)+1);let c=i??[],l=c.filter(e=>e.isOnline).length,u=c.filter(e=>!e.isOnline).length;return F(`div`,{className:`flex flex-col h-full`,children:[F(`button`,{type:`button`,onClick:()=>t(br),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:[B(Ke,{className:`h-4 w-4 flex-shrink-0`}),F(`div`,{className:`min-w-0 flex-1`,children:[B(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),B(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),B(`div`,{className:`flex-1 overflow-y-auto`,children:c.map(r=>{let i=e===r.id,a=s.get(r.id)??0,c=r.isHub?Le:G,l=ft(o,r.id,r.isHub),u=r.isOnline?null:n($e(r.lastSeen));return F(`button`,{type:`button`,onClick:()=>t(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[B(c,{className:`h-4 w-4 flex-shrink-0`}),F(`div`,{className:`min-w-0 flex-1`,children:[F(`div`,{className:`flex items-center gap-2`,children:[B(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&B(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!r.isOnline&&B(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),r.isOnline&&B(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),F(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[F(`span`,{children:[r.cpuCores,` cores`]}),B(`span`,{children:`•`}),F(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a>0&&F(L,{children:[B(`span`,{children:`•`}),F(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[B(ke,{className:`h-2.5 w-2.5`}),a]})]}),!r.isOnline&&F(L,{children:[B(`span`,{children:`•`}),F(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),F(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[B(D,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),B(D,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},r.id)})}),F(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[F(`span`,{children:[l,` online`]}),u>0&&F(`span`,{className:`text-destructive`,children:[u,` offline`]})]})]})}function mt({nodeId:e,refreshToken:t}){let{data:n}=y(void 0),r=n?.find(t=>t.id===e),i=a(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?F(`div`,{className:`px-6 py-4 border-b border-border`,children:[F(`div`,{className:`flex items-center gap-2 mb-1`,children:[B(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?B(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):B(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&B(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),F(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[B(`span`,{children:r.cpuModel??`CPU`}),B(`span`,{children:`•`}),F(`span`,{children:[r.cpuCores,` cores`]}),B(`span`,{children:`•`}),F(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),i&&F(L,{children:[B(`span`,{children:`•`}),F(`span`,{children:[i.attachedCameras,` cameras (`,i.activeCameras,` active)`]}),B(`span`,{children:`•`}),F(`span`,{children:[i.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),B(`span`,{children:`•`}),F(`span`,{children:[`queue `,i.queueDepthTotal]}),i.hardware.hasGpu&&F(L,{children:[B(`span`,{children:`•`}),B(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):B(`div`,{className:`px-6 py-4 border-b border-border`,children:F(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function ht({refreshToken:e,nodeId:t}){let[n,r]=z(new Map),{nodes:i}=v();b(`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}=ne(void 0),o=I(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=I(()=>{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=I(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=I(()=>{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 F(`div`,{className:`@container/liveload`,children:[B(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),F(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[B(K,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),B(K,{label:`Active / Attached`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),B(K,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),B(K,{label:`Queue`,value:e?String(e.queueDepth):`—`}),B(K,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let u=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return F(`div`,{className:`@container/liveload`,children:[B(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),F(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[B(K,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),B(K,{label:`Active / Attached`,value:`${l.activeCameras}/${l.attachedCameras}`}),B(K,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),B(K,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),B(K,{label:`Queue depth`,value:String(l.queueDepth)})]}),B(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:F(`table`,{className:`w-full text-xs min-w-[480px]`,children:[B(`thead`,{className:`bg-surface`,children:F(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[B(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),B(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),B(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),B(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),B(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),B(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),F(`tbody`,{children:[u.map(([e,t])=>F(`tr`,{className:`border-t border-border`,children:[B(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),B(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),B(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),B(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),B(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),B(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),u.length===0&&B(`tr`,{children:B(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function K({label:e,value:t}){return F(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[B(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),B(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}P();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:G,decoder:Be,audio:Ae},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=R(),[i,a]=z(null),[o,s]=z(null),[c,l]=z(new Map);Qe([`pipelineOrchestrator`,`getPipelineAssignments`],_t),Qe([`pipelineOrchestrator`,`getAudioAssignments`],_t),Qe([`pipelineOrchestrator`,`getCameraStatuses`],_t);let{data:f}=M(void 0),{data:p}=O(void 0),{data:m}=k({},{enabled:e===`agent`}),{nodes:g}=v(),{data:_}=Ce();b(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&l(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),V(()=>{if(c.size===0)return;let e=setInterval(()=>{l(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)},[c.size]);let y=I(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),x=I(()=>{if(e===`agent`){let e=[];for(let n of m??[]){let r=n.assignment,i=(e,n,r)=>({active:e!==null&&e===t,pinned:n,nodeId:e,reason:r??``}),a=i(r.detectionNodeId,r.pinned.detection,r.reasons.detection),o=i(r.decoderNodeId,r.pinned.decoder,r.reasons.decoder),s=i(r.audioNodeId,r.pinned.audio,r.reasons.audio);!a.active&&!o.active&&!s.active||e.push({deviceId:n.deviceId,deviceName:y.get(n.deviceId)??`Device ${n.deviceId}`,pipeline:a,decoder:o,audio:s})}return e.sort((e,t)=>e.deviceId-t.deviceId),e}let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:y.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:!0,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``},decoder:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:!1,nodeId:i.agentNodeId,reason:`co-located`}})}for(let e of p??[]){let t=r(e.deviceId);n.set(e.deviceId,{...t,audio:{active:!0,pinned:e.pinned,nodeId:e.nodeId,reason:`capacity`}})}let i=[...n.values()];return i.sort((e,t)=>e.deviceId-t.deviceId),i},[f,p,m,y,e,t]),S=I(()=>(g??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[g]),C=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},w=oe({onSuccess:C}),E=d({onSuccess:C}),D=T({onSuccess:C}),ee=u({onSuccess:C}),A=(e,t,n)=>{t===`pipeline`?w.mutate({deviceId:e,agentNodeId:n}):D.mutate({deviceId:e,nodeId:n}),a(null)},j=(e,t)=>{t===`pipeline`?E.mutate({deviceId:e}):ee.mutate({deviceId:e}),a(null)};return B(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:F(`table`,{className:`w-full text-xs min-w-[760px] table-fixed`,children:[B(`thead`,{className:`bg-surface`,children:F(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&B(`th`,{className:`w-10`}),B(`th`,{className:`min-w-[200px] text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?F(L,{children:[B(`th`,{className:`w-[168px] text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),B(`th`,{className:`w-[188px] text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):F(L,{children:[B(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Pipeline`}),B(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Decoder`}),B(`th`,{className:`w-[120px] text-left px-3 py-2 align-middle`,children:`Audio`})]}),B(`th`,{className:`w-[132px] text-left px-3 py-2 align-middle`,children:`Status`})]})}),F(`tbody`,{children:[x.map(t=>{let r=c.get(t.deviceId),l=o===t.deviceId;return F(ve.Fragment,{children:[F(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&B(`td`,{className:`px-2 py-2 align-middle`,children:B(`button`,{type:`button`,onClick:()=>s(l?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":l?`Collapse broker details`:`Expand broker details`,children:B(l?Ve:Ge,{className:`h-3.5 w-3.5`})})}),F(`td`,{className:`px-3 py-2 align-middle min-w-0`,children:[B(`div`,{className:`text-foreground font-medium leading-tight line-clamp-2 break-words`,title:t.deviceName,children:t.deviceName}),F(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?F(L,{children:[B(`td`,{className:`px-3 py-2 align-middle`,children:B(St,{state:t.pipeline,onlineNodes:S,pending:w.isPending||E.isPending,onChange:e=>{e===`auto`?j(t.deviceId,`pipeline`):A(t.deviceId,`pipeline`,e)}})}),B(`td`,{className:`px-3 py-2 align-middle`,children:B(Ct,{state:t.pipeline})})]}):F(L,{children:[B(wt,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:S,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`pipeline`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>a(null),onMove:e=>A(t.deviceId,`pipeline`,e),onUnpin:()=>j(t.deviceId,`pipeline`)}),B(wt,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:S,readOnly:!0,isMenuOpen:!1,onToggleMenu:()=>void 0,onCloseMenu:()=>void 0,onMove:()=>void 0,onUnpin:()=>void 0}),B(wt,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:S,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`audio`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>a(null),onMove:e=>A(t.deviceId,`audio`,e),onUnpin:()=>j(t.deviceId,`audio`)})]}),B(`td`,{className:`px-3 py-2 align-middle`,children:B(Ot,{snap:r})})]}),l&&!n&&F(`tr`,{className:`bg-surface/50`,children:[B(`td`,{}),F(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2 space-y-3`,children:[t.pipeline.nodeId&&B(xt,{deviceId:t.deviceId,nodeId:t.pipeline.nodeId}),B(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)}),x.length===0&&B(`tr`,{children:B(`td`,{colSpan:n?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function xt({deviceId:e,nodeId:t}){let n=R(),{data:r}=ie({nodeId:t}),{data:i}=w({deviceId:e}),a=N({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineDevicePin`]]})}}),o=r?.devices??[],s=i?.deviceKey??`auto`,c=s!==`auto`&&!o.some(e=>e.key===s);return F(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[B(`span`,{className:`shrink-0 font-medium text-foreground`,children:`Inference device`}),F(`select`,{value:s,disabled:a.isPending,"aria-label":`Inference device pin`,onChange:t=>a.mutate({deviceId:e,deviceKey:t.target.value}),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[B(`option`,{value:`auto`,children:`Auto (balanced)`}),c&&F(`option`,{value:s,children:[`Pin → `,s,` (not on this node)`]}),o.map(e=>F(`option`,{value:e.key,children:[`Pin → `,e.key,e.available?``:` (unavailable)`]},e.key))]}),a.isPending&&B(`span`,{className:`text-[10px] opacity-70`,children:`saving…`})]})}function St({state:e,onlineNodes:t,pending:n,onChange:r}){let i=e.pinned&&e.nodeId?e.nodeId:`auto`,a=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return F(`select`,{value:i,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[B(`option`,{value:`auto`,children:`Auto`}),a.map(e=>F(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function Ct({state:e}){if(!e.active||!e.nodeId)return B(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let t=e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`;return F(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[B(`span`,{className:`font-mono text-[11px] text-foreground truncate`,title:e.nodeId,children:e.nodeId}),B(`span`,{className:`truncate ${e.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`}`,title:t,children:t})]})}function wt({role:e,state:t,mode:n,onlineNodes:r,readOnly:i=!1,isMenuOpen:a,onToggleMenu:o,onCloseMenu:s,onMove:c,onUnpin:l}){let u=vt[e],d=r.filter(e=>e.id!==(t.nodeId??``)),f=!i&&(t.active||n===`cluster`)&&(d.length>0||t.pinned);return F(`td`,{className:`px-3 py-2 align-middle relative min-w-0`,children:[F(`div`,{className:`flex items-center gap-2 min-w-0`,children:[B(n===`agent`?Tt:Et,{state:t,Icon:u}),B(`div`,{className:`ml-auto shrink-0`,children:f&&B(`button`,{type:`button`,onClick:o,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${yt[e]} actions`,children:B(at,{className:`h-3 w-3 text-foreground-subtle`})})})]}),a&&f&&B(kt,{title:yt[e],targets:d,pinned:t.pinned,onMove:c,onUnpin:l,onClose:s})]})}function Tt({state:e,Icon:t}){return F(`div`,{className:`flex items-center gap-1.5`,children:[B(e.active?Re:ze,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),B(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&B(st,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Et({state:e,Icon:t}){return!e.active||!e.nodeId?F(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[B(t,{className:`h-3 w-3`}),B(`span`,{className:`text-[10px] italic`,children:`—`})]}):F(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[B(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),F(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[B(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),B(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?F(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[B(st,{className:`h-2.5 w-2.5`}),` manual`]}):F(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}var Dt=`min-h-[3.25rem]`;function Ot({snap:e}){if(!e)return B(`div`,{className:`flex items-center ${Dt}`,children:B(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`})});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:a,configuredFps:o,droppedFrames:s}=e.metrics,c=i(t);return F(`div`,{className:`flex flex-col justify-center gap-0.5 font-mono text-[10px] tabular-nums leading-tight min-w-0 ${Dt}`,children:[F(`span`,{className:`inline-flex items-center gap-1 min-w-0 ${c.textColor}`,children:[B(C,{phase:t,className:`h-2.5 w-2.5 shrink-0`}),B(`span`,{className:`font-semibold uppercase tracking-wider truncate`,children:c.label})]}),F(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[B(`span`,{className:`text-foreground`,children:n.toFixed(1)}),F(`span`,{children:[`/`,o.toFixed(0),` fps`]})]}),F(`span`,{className:`text-foreground-subtle whitespace-nowrap truncate`,children:[B(`span`,{className:`text-foreground`,children:r.toFixed(0)}),B(`span`,{children:` ms`}),a>0&&F(`span`,{className:`text-warning ml-1`,children:[`q`,a]})]}),F(`span`,{className:`whitespace-nowrap truncate ${s>0?`text-warning`:`text-foreground-subtle`}`,children:[`drops `,B(`span`,{className:`text-foreground`,children:s})]})]})}function kt({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=_e(null);return V(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),F(`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:[B(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&B(`div`,{className:`py-1`,children:t.map(e=>F(`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&&F(`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&&B(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function At({nodeId:e,refreshToken:t}){return F(`div`,{className:`space-y-6`,children:[B(ht,{refreshToken:t,nodeId:e}),F(`div`,{children:[B(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),F(`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.`]})]}),B(bt,{mode:`agent`,nodeId:e,compact:!0})]})}P();function jt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function Mt({nodeId:e,refreshToken:t}){let n=R(),r=ce({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:i}=te({nodeId:e}),s=a(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??i??null,c=s===null;Qe([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:l}=o({nodeId:e}),{values:u}=_(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),d=I(()=>u.filter(e=>e.metrics.phase===`active`).length,[u]),f=t=>{let n=l??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||r.mutate({nodeId:e,engine:t,force:n.length>0})};return F(`div`,{className:`space-y-6`,children:[F(`div`,{children:[B(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),F(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(s??[]).length,` engine(s) resident in RAM. `,(l??[]).length,` `,`camera(s) attached, `,d,` actively dispatching frames. Refreshes every 5s.`]})]}),B(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:F(`table`,{className:`w-full text-xs min-w-[640px]`,children:[B(`thead`,{className:`bg-surface`,children:F(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[B(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),B(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),B(`th`,{className:`text-left px-3 py-2`,children:`Models`}),B(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),B(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),B(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),B(`th`,{className:`w-20`})]})}),F(`tbody`,{children:[c&&B(`tr`,{children:B(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!c&&(s??[]).map(e=>{let t=e.kind===`warm-override`,n=e.kind===`device-pool`;return F(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:n?`bg-primary/[0.05]`:``}`,children:[B(`td`,{className:`px-3 py-2`,children:F(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:n?`bg-primary/15 text-primary`:`bg-success/15 text-success`}`,children:[B(t?ot:n?Se:G,{className:`h-3 w-3`}),t?`warm`:n?`pool`:`runtime`]})}),B(`td`,{className:`px-3 py-2`,children:F(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[B(je,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),B(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?B(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):B(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>B(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),B(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),B(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?B(`span`,{className:`text-foreground-subtle`,children:jt(e.idleMs,e.idleTtlMs)}):B(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),B(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(l??[]).length}),B(`td`,{className:`px-3 py-2 text-right`,children:n?B(`span`,{className:`text-[11px] text-foreground-subtle`,children:`auto`}):F(`button`,{type:`button`,disabled:r.isPending,onClick:()=>f(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[B(Xe,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!c&&(s??[]).length===0&&B(`tr`,{children:B(`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.`})})]})]})}),F(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[B(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,B(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`,` `,B(`strong`,{className:`text-foreground`,children:`pool`}),`: a per-device balanced inference pool (one per enabled accelerator, running concurrently); reaper-managed on its own idle TTL.`]}),r.isError&&F(`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`]})]})}P();var Nt=new Set(xe);function Pt(e){return Nt.has(e)}function Ft(e,t,n){return`${e}/${t}/${n}`}function It(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Lt(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 Rt(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 zt({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?F(`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:[B(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),F(`div`,{className:`flex-1 min-w-0`,children:[F(`div`,{className:`flex items-center gap-2`,children:[B(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),F(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&F(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[B(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:B(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),F(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),B(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:tt(c.sizeMB)}),a&&F(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[B(We,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?F(`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?B(W,{className:`h-3 w-3 animate-spin`}):B(Xe,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):F(`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?B(W,{className:`h-3 w-3 animate-spin`}):B(De,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function Bt({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=z(!1);return F(`div`,{className:`relative`,children:[F(`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:[B(G,{className:`h-4 w-4 text-primary shrink-0`}),F(`div`,{className:`flex-1 min-w-0`,children:[F(`div`,{className:`flex items-center gap-2`,children:[B(`span`,{className:`text-sm font-medium text-foreground`,children:It(n)}),q(n)===q(t)&&B(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),B(`div`,{className:`text-[10px] text-foreground-subtle`,children:Lt(n)})]}),B(Ve,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&B(`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 F(`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:[B(G,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),F(`div`,{className:`flex-1`,children:[F(`div`,{className:`flex items-center gap-2`,children:[B(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:It(e)}),o&&B(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),B(`div`,{className:`text-[10px] text-foreground-subtle`,children:Lt(e)})]}),i&&B(Ue,{className:`h-4 w-4 text-primary shrink-0`})]},q(e))})})]})}function Vt({embedded:t=!1,nodeId:n}={}){let r=R(),i=n??`hub`,[a,o]=z(null),[s,c]=z(new Set),[l,u]=z(new Map),[d,f]=z(new Map),[m,h]=z(``),{data:g=[]}=ee({nodeId:i}),_=g.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:v}=ae({nodeId:i}),y=v,{data:x,isLoading:S}=ue({nodeId:i}),C=e(),w=p();b(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,i=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||i===void 0||(u(e=>{let t=new Map(e);return i===100||i===-1?t.delete(n):t.set(n,{modelId:n,progress:i,totalMB:a}),t}),i===100&&r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let T=y??{runtime:`node`,backend:`cpu`,format:`onnx`},E=_.find(e=>e.format===a)??T,D=E.format,O=x?.slots??[],k=O.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[D]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),A=Rt(k,D),j=ge(async(e,t,n)=>{if(!Pt(n))return;let a=Ft(e,t,n);c(e=>new Set([...e,a])),f(e=>{let t=new Map(e);return t.delete(a),t});try{await C.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){f(t=>new Map([...t,[a,e instanceof Error?e.message:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[C,r,i]),M=ge(async(e,t,n)=>{if(!Pt(n))return;let a=Ft(e,t,n);c(e=>new Set([...e,a])),f(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){f(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[w,r,i]),te=ge(e=>{o(e.format)},[]),N=m.trim()?k.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(m.toLowerCase())||t.id.toLowerCase().includes(m.toLowerCase())||e.name.toLowerCase().includes(m.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):k,ne=F(L,{children:[S&&B(`div`,{className:`flex items-center justify-center py-16`,children:B(W,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!S&&O.length===0&&F(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[B(Oe,{className:`h-8 w-8 mb-3 opacity-30`}),B(`span`,{className:`text-sm`,children:`No pipeline steps available`}),B(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!S&&O.length>0&&F(L,{children:[B(Bt,{engines:_,activeEngine:T,viewEngine:E,onSelect:te}),F(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[F(`span`,{children:[B(`span`,{className:`font-semibold text-foreground tabular-nums`,children:A.total}),B(`span`,{className:`ml-1`,children:`compatible models`})]}),B(`span`,{className:`text-border`,children:`|`}),F(`span`,{children:[B(`span`,{className:`font-semibold text-success tabular-nums`,children:A.downloaded}),B(`span`,{className:`ml-1`,children:`downloaded`})]}),B(`span`,{className:`text-border`,children:`|`}),F(`span`,{className:`tabular-nums`,children:[tt(A.downloadedSizeMB),B(`span`,{className:`ml-1`,children:`on disk`})]})]}),A.total>5&&F(`div`,{className:`relative`,children:[B(Ie,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),B(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),N.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+t.models.filter(e=>e.formats[D]?.downloaded).length,0);return F(`div`,{children:[F(`div`,{className:`flex items-center gap-2 mb-2`,children:[B(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),B(`div`,{className:`flex-1 h-px bg-border`}),F(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),B(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=Ft(e.id,t.id,D);return B(zt,{addonId:e.id,model:t,format:D,isActive:s.has(n),progress:l.get(t.id),errorMsg:d.get(n),onDownload:()=>j(e.id,t.id,D),onDelete:()=>M(e.id,t.id,D)},`${e.id}/${t.id}`)}))})]},e.id)}),N.length===0&&B(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:m.trim()?F(L,{children:[`No models matching “`,m,`”`]}):F(L,{children:[`No models available for `,It(E),` format`]})})]})]});return t?B(`div`,{className:`space-y-4`,children:ne}):B(Ze,{children:ne})}function Ht({nodeId:e,refreshToken:t}){return B(Vt,{embedded:!0,nodeId:e})}var Ut=`pipeline-runner`,Wt=200;function Gt({nodeId:e}){return F(`div`,{className:`flex flex-col gap-3`,children:[F(`div`,{children:[B(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Runner logs`}),F(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`pipeline-runner activity on `,e,` — camera attach/detach, engine phases and pipeline errors. Streaming live; the device chip on a line tells which camera it refers to.`]})]}),B(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:B(j,{agentId:e,addonId:Ut,limit:Wt,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}P(),P();function Kt({nodeId:e,title:t}){let{data:n}=Ce(),{data:r}=M(void 0),a=I(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),o=I(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[s,c]=z(new Map);b(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||c(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),V(()=>{if(s.size===0)return;let e=setInterval(()=>{c(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)},[s.size]);let l=I(()=>{let e=[];for(let t of s.values())o&&!o.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[s,o]);return l.length===0?F(`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`]}):F(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[F(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[B(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),B(`span`,{className:`text-[10px] text-foreground-subtle`,children:l.length})]}),B(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map(e=>{let t=a.get(e.deviceId)??`#${e.deviceId}`,n=i(e.metrics.phase);return F(`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:[B(C,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),B(`span`,{className:`font-medium text-foreground/90 max-w-[220px] truncate`,children:t}),B(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),B(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}P();function J(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 qt(e){if(!e)return null;let t=e.modelId!==void 0&&e.modelId!==``?e.modelId:void 0,n=e.settings&&Object.keys(e.settings).length>0?e.settings:void 0;return t===void 0&&n===void 0?null:{...t===void 0?{}:{modelId:t},...n===void 0?{}:{settings:n}}}function Jt({nodeId:e,refreshToken:t}){let n=R(),[r,i]=z(null),[a,o]=z(null),[l,u]=z(``),[d,f]=z(null),p=ie({nodeId:e},{refetchOnMount:`always`}),m=ue({nodeId:e},{refetchOnMount:`always`}),h=p.data?.devices??[],_=g({onSuccess:()=>{n.invalidateQueries({queryKey:[`pipelineOrchestrator`,`getNodeInferenceDevices`]})}}),v=I(()=>m.data?x(m.data):[],[m.data]),y=I(()=>h.map(t=>({agentNodeId:e,engineLabel:t.format,deviceKey:t.key,deviceLabel:H(t).label})),[h,e]),b=e=>h.find(t=>t.key===e)??null,C=I(()=>h.filter(e=>e.enabled),[h]),w=C.length>=2,T=(e,t)=>{let n=J(m.data??null,e),r=t?.format;return n?.models.some(e=>r!==void 0&&!!e.formats[r])??!1},E=e=>{let t=b(e);return t?H(t).label:e},D=(e,t)=>C.filter(n=>n.key!==t&&T(e,n)).toSorted((e,t)=>e.key<t.key?-1:+(e.key>t.key))[0]??null,O=e=>{let t=J(m.data??null,e)?.enabledByDefault??!0;return{kind:`gate`,effectiveOn:t,defaultOn:t,explicit:!1}},k=(e,t)=>{let n=J(m.data??null,e),r=t?.format;if(!(!n||r===void 0))return(n.slot===`detector`?t?.defaultModelId:void 0)??c(n,r)},ee=(e,t)=>{let n=O(e),r=n.kind===`gate`?n.effectiveOn:!1,i=J(m.data??null,e),a=t.deviceKey===void 0?null:b(t.deviceKey),o=a?.format,s=i?.models.some(e=>o!==void 0&&!!e.formats[o])??!1,c=a?.steps?.[e];if(!s){if(!r)return{kind:`na`};let n=c?.jumpDeviceKey,i=n!==void 0&&C.some(e=>e.key===n)?n:t.deviceKey===void 0?void 0:D(e,t.deviceKey)?.key;return i===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:E(i)}}return{kind:`enabled`,modelId:c?.modelId??k(e,a)??`Auto`,...c?.jumpDeviceKey!==void 0&&C.some(e=>e.key===c.jumpDeviceKey)?{jumpTo:E(c.jumpDeviceKey)}:{}}},A=r&&m.data?J(m.data,r.addonId):null,j=r?b(r.deviceKey):null,M=j?.format??`coreml`,te=r?k(r.addonId,j):void 0,N=()=>{i(null),o(null),u(``)},ne=(e,t)=>{if(t.deviceKey===void 0)return;let n=b(t.deviceKey)?.steps?.[e];i({addonId:e,deviceKey:t.deviceKey}),o({enabled:!0,...n?.modelId===void 0?{}:{modelId:n.modelId},settings:n?.settings??{}}),u(n?.jumpDeviceKey??``)},re=()=>{if(!r)return;let t=qt(a),n=l!==``&&l!==r.deviceKey?l:void 0,i=t||n!==void 0?{...t,...n===void 0?{}:{jumpDeviceKey:n}}:null,o={};for(let e of h){if(!e.enabled&&e.key!==r.deviceKey)continue;let t={...e.steps};e.key===r.deviceKey&&(i?t[r.addonId]=i:delete t[r.addonId]);let n=Object.keys(t).length>0;o[e.key]={enabled:!0,weight:Math.max(1,e.weight),...e.maxSessions!=null&&e.maxSessions>0?{maxSessions:e.maxSessions}:{},...n?{steps:t}:{}}}_.mutate({agentNodeId:e,inferenceDevices:o},{onSuccess:N})};if(p.isLoading||m.isLoading)return B(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(h.length===0)return B(`div`,{className:`rounded-md border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`});if(!m.data)return B(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let ae=r!==null&&A!==null&&j!==null;return F(`div`,{className:`relative h-full w-full space-y-3`,children:[F(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[`Each column is one of this node's inference accelerators. A cell shows the`,` `,B(`span`,{className:`font-medium text-foreground`,children:`base model`}),` every camera landing on that accelerator runs; click to change it. Whether a camera runs a step is set per-camera on that camera's Detection pipeline tab — there is no gate here.`]}),B(`div`,{className:ae?`md:pr-[360px]`:``,children:v.length>0?B(se,{tree:v,agents:y,gateFor:O,getCellState:ee,onCellClick:ne,selectedCell:r?{addonId:r.addonId,agentNodeId:e,deviceKey:r.deviceKey}:null,onSetGate:()=>{},fallbackNodeId:d,onFallbackNodeChange:f,hideGate:!0}):B(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),B(S,{open:ae,onClose:N,title:A?.name??``,subtitle:r&&j?`${e} · ${H(j).label} · ${j.format}`:``,footer:F(L,{children:[B(`div`,{className:`flex-1`}),B(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:N,children:`Cancel`}),B(`button`,{type:`button`,disabled:!r||!a||_.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:re,children:_.isPending?`Saving…`:`Save`})]}),children:A&&r&&a?F(`div`,{className:`space-y-3`,children:[w&&F(`div`,{className:`rounded-md border border-border bg-muted/10 px-3 py-2 space-y-1`,children:[B(`label`,{className:`block text-[11px] font-medium text-foreground`,children:`Run on`}),F(`select`,{className:`w-full rounded border border-border bg-surface px-2 py-1 text-xs`,value:l,onChange:e=>u(e.target.value),children:[B(`option`,{value:``,children:`Auto (this device, or auto-jump if unsupported)`}),C.filter(e=>e.key!==r.deviceKey).map(e=>F(`option`,{value:e.key,children:[H(e).label,` · `,e.format]},e.key))]}),B(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:`Route this step (and its child steps) to another accelerator on this node.`})]}),B(s,{mode:`agent`,addon:A,agentDefault:a,agentNodeId:e,engineFormat:M,effectiveModelId:te,onChangeAgentConfig:o})]}):B(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300`,children:`This accelerator is no longer reported by the node, so there is nothing to provision here.`})})]})}P();var Yt=[`pipeline-orchestrator`],Xt=[`decoder`],Zt=!1;function Qt({nodeId:e,refreshToken:t}){let n=l(),[r,i]=z(null),[a,o]=z(null),s=(y(void 0).data??[]).find(t=>t.id===e),c=s?.name??e,u=s?.isOnline??!1,d=me({onSuccess:e=>{o(e.effectiveModelId===null?`Reset done — model config cleared (node offline: effective model resolves on reconnect)`:`Reset done — effective detection model: ${e.effectiveModelId} (Auto)`)}}),f=async()=>{await n({title:`Reset ${c} to hardware-aware defaults?`,message:`This clears every per-device model default on this node (back to the format default) and every per-camera step override scoped to it. Existing per-camera customisations on this node are lost.`,confirmLabel:`Reset`,variant:`danger`})&&(o(null),d.mutate({agentNodeId:e}))};return F(`div`,{className:`relative h-full w-full space-y-3`,children:[F(`div`,{className:`flex items-center justify-end gap-2 text-xs`,children:[a&&B(`span`,{className:`text-emerald-400`,children:a}),d.isError&&B(`span`,{className:`text-red-400`,children:d.error instanceof Error?d.error.message:`Reset failed`}),B(`button`,{type:`button`,onClick:()=>{f()},disabled:d.isPending,className:`rounded border border-amber-500/40 bg-surface px-2 py-0.5 text-amber-300 hover:bg-surface-hover disabled:opacity-50`,title:`Clear this node's per-device model defaults + per-camera overrides scoped to this node`,children:d.isPending?`Resetting…`:`Reset to default`})]}),B(Kt,{nodeId:e}),B(nt,{nodeId:e,addonIds:Yt,level:`global`,sectionIds:Xt}),Zt,Zt,F(`div`,{children:[B(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices — default model per accelerator`}),B(Ee,{nodeId:e,nodeName:c,isOnline:u})]}),F(`div`,{children:[B(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection steps — model per accelerator`}),B(Jt,{nodeId:e,refreshToken:t})]})]})}var $t=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],en=`decoder-nodeav`;function tn({nodeId:e,refreshToken:t}){let{data:n}=y(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??en,i=[...$t,r];return F(`div`,{className:`flex flex-col h-full`,children:[B(mt,{nodeId:e,refreshToken:t}),B(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:B(nt,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:B(At,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:B(Qt,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:B(Mt,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:B(Ht,{nodeId:e,refreshToken:t})},{id:`logs`,label:`Logs`,order:300,content:B(Gt,{nodeId:e})}]})})]})}var nn=`pipeline-orchestrator`,rn=`recorder`,an=`recordingNodeId`,on=[`ingestNode`,`recordingNode`,`audioNode`,`motionNode`],sn=[{key:`detect`,label:`Detect`,hint:`Runs the detection pipeline (decode + inference) for assigned cameras`}];function cn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function ln(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function un(e,t,n){let r=cn(e,t);return typeof r==`string`&&r.length>0?r:n}function dn(e,t,n){let r=cn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function fn(e,t){let n=ln(e,t);return typeof n==`number`&&Number.isFinite(n)?n:null}function pn(e,t){let n=ln(e,t);return typeof n==`string`&&n.length>0?n:null}function mn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:e===`audioNode`?`Audio`:`Motion Node`}function hn(e){return e===`ingestNode`?`Node that terminates default camera ingest`:e===`recordingNode`?`Node that owns the recorder (recording-node)`:e===`audioNode`?`Node that runs singleton audio work`:`Runs software (analyzer) motion-watch. Onboard cameras are unaffected.`}function gn(e,t){switch(t){case`detect`:return e.pipeline}}function _n(e){return e instanceof Error?e.message:`Failed to save`}function vn(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function yn({capability:e,label:t,hint:n,nodeId:r,active:i,pending:a,layout:o,onToggle:s}){let c=i?`border-success/30 bg-success/15 text-success hover:bg-success/25`:`border-border bg-surface-hover text-foreground-subtle hover:bg-surface hover:text-foreground`,l=o===`card`?`w-full justify-center px-3 py-2 text-xs`:`px-2.5 py-1 text-[11px]`,u=i?U:Te;return F(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":`${t} capability for ${r}`,title:`${t} — ${n}`,disabled:a,onClick:()=>s(e,!i),className:`inline-flex items-center gap-1.5 rounded-full border font-medium transition-colors disabled:opacity-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${c} ${l}`,children:[B(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),B(`span`,{children:t})]})}function bn({node:e,emphasis:t=!1}){let n=e.isHub?Le:G;return F(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[B(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${e.isOnline?`bg-success`:`bg-danger`}`,"aria-hidden":`true`}),B(n,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":`true`}),F(`div`,{className:`min-w-0`,children:[F(`div`,{className:`flex items-center gap-1.5 ${t?`text-sm`:`text-xs`} font-semibold text-foreground`,children:[B(`span`,{className:`truncate`,children:e.name}),e.isHub&&B(D,{variant:`info`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`hub`}),!e.isOnline&&B(D,{variant:`danger`,className:`px-1.5 py-0 text-[9px] uppercase tracking-wider`,children:`offline`})]}),B(`div`,{className:`font-mono text-[10px] text-foreground-subtle truncate`,children:e.id})]})]})}P();function xn({nodeId:e,value:t,detectedHosts:n,status:r,errorMessage:i,onCommit:a}){let[o,s]=z(t??``);V(()=>{s(t??``)},[t]);let c=n[0],l=c===void 0?`auto-detect`:`auto: ${c}`,u=r===`pending`,d=o.trim(),f=d!==(t??``),p=f&&!u,m=()=>{p&&a(e,d.length>0?d:null)};return F(`div`,{className:`flex items-center gap-1.5`,children:[B(`input`,{"aria-label":`Reachable host for ${e}`,type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:l,value:o,disabled:u,onChange:e=>s(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&s(t??``)},className:`w-40 rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none disabled:opacity-50`}),F(`button`,{type:`button`,onClick:m,disabled:!p,"aria-label":`Save reachable host for ${e}`,title:`Save reachable host`,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed`,children:[u?B(W,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):B(U,{className:`h-3 w-3`,"aria-hidden":`true`}),`Save`]}),!f&&!u&&r===`success`&&B(U,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`,"aria-label":`Saved`,role:`img`}),r===`error`&&B(`span`,{title:i??`Failed to save reachable host`,children:B(We,{className:`h-3.5 w-3.5 shrink-0 text-red-400`,"aria-label":i??`Failed to save reachable host`,role:`img`})})]})}function Sn({label:e,children:t}){return F(`div`,{className:`flex items-center justify-between gap-3`,children:[B(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-foreground-subtle`,children:e}),t]})}function Cn({node:e,actions:t}){return F(`div`,{className:`rounded-xl border border-border bg-background p-4 space-y-4 ${e.isOnline?``:`opacity-60`}`,children:[B(bn,{node:e,emphasis:!0}),B(`div`,{className:`grid grid-cols-2 gap-2`,children:sn.map(n=>B(yn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:gn(e.effective,n.key),pending:t.capabilityPending,layout:`card`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)},n.key))}),B(`div`,{className:`space-y-3 border-t border-border pt-3`,children:B(Sn,{label:`Reachable host`,children:B(xn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})})]})}function wn(){return F(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-foreground-subtle`,children:[F(`span`,{className:`inline-flex items-center gap-1.5`,children:[B(`span`,{className:`h-2.5 w-2.5 rounded-full border border-success/30 bg-success/15`}),`Active capability`]}),F(`span`,{className:`inline-flex items-center gap-1.5`,children:[B(`span`,{className:`h-2.5 w-2.5 rounded-full border border-border bg-surface-hover`}),`Idle`]}),F(`span`,{className:`inline-flex items-center gap-1.5`,children:[B(`span`,{className:`h-2 w-2 rounded-full bg-success`}),`Node online`]}),F(`span`,{className:`inline-flex items-center gap-1.5`,children:[B(`span`,{className:`h-2 w-2 rounded-full bg-danger`}),`Node offline`]})]})}function Tn({nodes:e,actions:t}){return B(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:F(`table`,{className:`w-full min-w-[720px] border-collapse text-sm`,children:[B(`thead`,{children:F(`tr`,{className:`border-b border-border bg-background text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[B(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Node`}),sn.map(e=>B(`th`,{className:`px-3 py-3 text-center font-semibold`,children:e.label},e.key)),B(`th`,{className:`px-4 py-3 text-left font-semibold`,children:`Reachable host`})]})}),B(`tbody`,{children:e.map(e=>F(`tr`,{className:`border-b border-border last:border-b-0 transition-colors hover:bg-surface-hover/40 ${e.isOnline?``:`opacity-60`}`,children:[B(`td`,{className:`px-4 py-3 align-middle`,children:B(bn,{node:e})}),sn.map(n=>B(`td`,{className:`px-3 py-3 text-center align-middle`,children:B(yn,{capability:n.key,label:n.label,hint:n.hint,nodeId:e.id,active:gn(e.effective,n.key),pending:t.capabilityPending,layout:`cell`,onToggle:(n,r)=>t.onToggleCapability(e.id,n,r)})},n.key)),B(`td`,{className:`px-4 py-3 align-middle`,children:B(xn,{nodeId:e.id,value:e.reachableHost,detectedHosts:e.detectedHosts,status:t.reachableHostStatus(e.id),errorMessage:t.reachableHostErrorMessage(e.id),onCommit:t.onCommitReachableHost})})]},e.id))})]})})}function En({role:e,value:t,options:n,pending:r,onChange:i}){return F(`label`,{className:`flex flex-col gap-1.5 rounded-lg border border-border bg-background p-3`,children:[B(`span`,{className:`text-xs font-semibold text-foreground`,children:mn(e)}),B(`select`,{value:t,disabled:r,onChange:t=>i(e,t.target.value),className:`rounded-md border border-border bg-surface px-2.5 py-1.5 text-sm text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,children:n.map(e=>B(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),B(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:hn(e)})]})}function Dn({roleValues:e,options:t,pending:n,lowFpsEnabled:r,fpsMinThreshold:i,onRoleChange:a,onLowFpsToggle:o}){return F(`div`,{className:`grid gap-3 @lg/clustertab:grid-cols-2 @3xl/clustertab:grid-cols-4`,children:[on.map(r=>B(En,{role:r,value:e[r],options:t,pending:n,onChange:a},r)),F(`label`,{className:`flex items-start gap-2.5 rounded-lg border border-border bg-background p-3 text-sm text-foreground`,children:[B(`input`,{type:`checkbox`,checked:r,disabled:n,onChange:e=>o(e.target.checked),className:`mt-0.5 h-4 w-4 shrink-0 accent-primary`}),F(`span`,{className:`flex flex-col gap-0.5`,children:[B(`span`,{className:`text-xs font-semibold`,children:`Low-fps relocate/shed`}),F(`span`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:[`fpsMinThreshold `,r?`${i} fps`:`disabled`]})]})]})]})}P();function On(){let e=R(),{nodes:n}=v(),i=fe(void 0),a=de({addonId:nn}),o=de({addonId:rn}),s=()=>vn(e),c=t({onSuccess:s}),l=pe(),u=r({onSuccess:s}),d=A({onSuccess:s}),[f,p]=z(!1),m=I(()=>{let e=new Map;for(let t of i.data??[])e.set(t.nodeId,t.settings);return e},[i.data]),h=I(()=>n.map(e=>{let t=m.get(e.id),n=dt(t,e.isHub),r=fn(t,`detectWeight`);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:r??1,maxCameras:fn(t,`maxCameras`),reachableHost:pn(t,`reachableHost`),detectedHosts:e.localIps}}),[n,m]),g=h.filter(e=>e.effective.pipeline),_={ingestNode:un(a.data,`ingestNode`,`hub`),recordingNode:un(o.data,an,`hub`),audioNode:un(a.data,`audioNode`,`hub`),motionNode:un(a.data,`motionNode`,`hub`)},y=I(()=>{let e=n.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...on.map(e=>_[e]),...e])].filter(e=>e.length>0)},[n,_]),b=dn(a.data,`fpsMinThreshold`,0),x=b>0,S=i.isLoading||a.isLoading||o.isLoading,C=(e,t,n)=>{c.mutate({agentNodeId:e,[t]:n})},w=(e,t)=>{if(e===`recordingNode`){d.mutate({addonId:rn,patch:{[an]:t}});return}d.mutate({addonId:nn,patch:{[e]:t}})},T=e=>{d.mutate({addonId:nn,patch:{fpsMinThreshold:e?Math.max(1,b):0}})},E=e=>u.variables?.agentNodeId===e?u.isPending?`pending`:u.isError?`error`:u.isSuccess?`success`:`idle`:`idle`,D=e=>E(e)===`error`?_n(u.error):null,O=async e=>{p(!0);try{for(let t of e)await l.mutateAsync({agentNodeId:t.nodeId,detectWeight:t.weight})}finally{p(!1),s()}},k={capabilityPending:c.isPending,onToggleCapability:C,onCommitReachableHost:(e,t)=>u.mutate({agentNodeId:e,reachableHost:t}),reachableHostStatus:E,reachableHostErrorMessage:D};return F(`section`,{className:`rounded-xl border border-border bg-surface p-5 @3xl/clustertab:p-6 space-y-6`,children:[F(`header`,{className:`flex items-start justify-between gap-4`,children:[F(`div`,{className:`space-y-1`,children:[B(`h3`,{className:`text-base font-semibold text-foreground`,children:`Pipeline placement`}),B(`p`,{className:`max-w-prose text-xs leading-relaxed text-foreground-subtle`,children:`Toggle which node runs each pipeline capability, distribute detection weight across detect-capable nodes, and choose the singleton cluster roles.`})]}),S&&B(W,{className:`h-5 w-5 shrink-0 animate-spin text-foreground-subtle`,"aria-label":`Loading`})]}),F(`div`,{className:`space-y-3`,children:[B(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Singleton cluster roles`}),B(Dn,{roleValues:_,options:y,pending:d.isPending,lowFpsEnabled:x,fpsMinThreshold:b,onRoleChange:w,onLowFpsToggle:T})]}),F(`div`,{className:`space-y-3`,children:[F(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[B(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Per-node capabilities`}),B(wn,{})]}),h.length===0?B(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No cluster nodes reporting yet.`}):F(L,{children:[B(`div`,{className:`grid gap-4 @xl/clustertab:grid-cols-2 @3xl/clustertab:hidden`,children:h.map(e=>B(Cn,{node:e,actions:k},e.id))}),B(`div`,{className:`hidden @3xl/clustertab:block`,children:B(Tn,{nodes:h,actions:k})})]})]}),F(`div`,{className:`space-y-3`,children:[B(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Detection weight`}),B(we,{nodes:g,pending:f,onCommitWeights:e=>void O(e)})]}),F(`div`,{className:`space-y-3`,children:[B(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Inference devices`}),g.length===0?B(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No detect-capable nodes — enable detection on a node above to configure its accelerators.`}):B(`div`,{className:`space-y-2`,children:g.map(e=>B(Ee,{nodeId:e.id,nodeName:e.name,isOnline:e.isOnline},e.id))})]})]})}P();var kn=!1;function An({refreshToken:e}){let t=R(),{data:n}=y(void 0);I(()=>et(n??[]),[n]);let r=E({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return F(`div`,{className:`space-y-6`,children:[B(Kt,{title:`Cluster cameras`}),B(ht,{refreshToken:e}),B(On,{}),kn,F(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[F(`div`,{className:`min-w-0`,children:[B(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),B(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · audio assignments per camera (decode always runs co-located with the pipeline). Click the kebab to pin / unpin / move a role; expand the chevron for the per-camera broker drill-down.`})]}),F(`button`,{type:`button`,onClick:()=>r.mutate(void 0),disabled:r.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[B(je,{className:`h-3.5 w-3.5`}),r.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),B(bt,{mode:`cluster`})]})}var jn=[`pipeline-orchestrator`];function Mn({refreshToken:e}){return B(`div`,{className:`space-y-4 max-w-3xl`,children:B(nt,{nodeId:`hub`,addonIds:jn,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.`})})}P();function Nn({refreshToken:e}){let t=R(),{data:n,isLoading:r}=he(),[i,a]=z(null),[o,s]=z(``),[c,l]=z(``),u=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},d=f({onSuccess:()=>{a(null),u()}}),p=le({onSuccess:u}),m=e=>{a(e.id),s(e.name),l(e.description??``)},h=()=>{a(null),s(``),l(``)},g=()=>{if(!i)return;let e=c.trim();d.mutate({id:i,name:o.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return B(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return B(`div`,{className:`space-y-6 max-w-4xl`,children:F(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[F(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[F(`div`,{children:[B(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),B(`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.`})]}),F(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?F(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[B(Ne,{className:`h-6 w-6 opacity-40`}),B(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):B(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return B(`li`,{className:`px-4 py-3 text-xs`,children:F(`div`,{className:`flex items-start gap-3`,children:[B(`div`,{className:`flex-1 min-w-0`,children:t?F(`div`,{className:`space-y-2`,children:[B(`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}),B(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:c,onChange:e=>l(e.target.value),placeholder:`Description (optional)`})]}):F(L,{children:[B(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&B(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),F(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,F(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),B(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?F(L,{children:[F(`button`,{type:`button`,onClick:g,disabled:d.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:[B(U,{className:`h-3 w-3`}),`Save`]}),F(`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:[B(Je,{className:`h-3 w-3`}),`Cancel`]})]}):F(L,{children:[B(`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:B(Me,{className:`h-3 w-3`})}),B(`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:B(Xe,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}P();var Pn=`pipeline-analytics`;function Fn(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 In(){let e=R(),{data:t}=y(void 0),{data:n,isLoading:r}=de({addonId:Pn}),i=Fn(n),a=A({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),o=I(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return F(`div`,{className:`flex flex-col gap-6`,children:[F(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[B(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),B(`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.`}),F(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?B(W,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):B(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:Pn,patch:{postProcessingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:o.map(e=>B(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&B(W,{className:`h-4 w-4 animate-spin text-primary`})]})]}),F(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[B(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),B(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),B(rt,{types:[`eventMedia`]})]})]})}var Ln=`pipeline-orchestrator`,Rn=200;function zn(){return F(`div`,{className:`flex flex-col gap-3`,children:[F(`div`,{children:[B(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Orchestrator logs`}),B(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Dispatch decisions, balancer moves and failover events from the pipeline orchestrator. Streaming live; the device chip on a line tells which camera it refers to.`})]}),B(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:B(j,{addonId:Ln,limit:Rn,maxHeight:`max-h-[calc(100vh-360px)]`,showScope:!0,showDeviceChip:!0,showFilters:!1})})]})}P();var Bn=[{id:`assignments`,label:`Assignments`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`},{id:`logs`,label:`Logs`}];function Vn({refreshToken:e}){let[t,n]=z(`assignments`);return F(`div`,{className:`flex flex-col h-full`,children:[F(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[B(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),B(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),B(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Bn.map(e=>B(`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))}),F(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&B(An,{refreshToken:e}),t===`events`&&B(In,{}),t===`recording`&&B(it,{}),t===`settings`&&B(Mn,{refreshToken:e}),t===`templates`&&B(Nn,{refreshToken:e}),t===`logs`&&B(zn,{})]})]})}function Hn(e){let t=[],n=[],{assignment:r,detection:i,decoder:a,broker:o}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?`Engine provisioning failed: ${i.provisioning.error}`:`Engine provisioning failed on the detection node`}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:`Detection phase is ACTIVE but 0 fps are being processed — frames are not reaching the detector (cross-node black-hole signature)`}),i!==null&&i.phase===`active`&&a!==null&&a.shm.framesWritten===0&&t.push({code:`decoder-black-hole`,severity:`error`,message:`Decoder on ${a.nodeId} has written 0 frames to the shared-memory plane while detection is active — the decode path is stalled`}),r.detectionNodeId===null&&i===null&&n.push({code:`unassigned`,severity:`warning`,message:`Not placed on any detection node — no pipeline is running for this camera`});for(let e of o?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:`Broker profile "${e.profile}" reports streaming but 0 in-fps — the source pull may be stalled`});return[...t,...n]}function Un(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){return typeof e==`string`&&e.length>0?e:null}function Wn(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Gn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Kn(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var qn={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function Jn(e){if(!Un(e)||!Array.isArray(e.sections))return qn;let t=ye(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)Kn(n.value,n.default)&&r.add(e);return{detectionMode:Y(n(`detectionMode`)),detectionStreamProfile:Y(n(`detectionStreamProfile`)),detectionFps:Wn(n(`detectionFps`)),motionSources:Gn(n(`motionSources`)),motionFps:Wn(n(`motionFps`)),motionCooldownMs:Wn(n(`motionCooldownMs`)),motionStreamProfile:Y(n(`motionStreamProfile`)),audioMode:Y(n(`audioMode`)),pipelineNodeId:Y(n(`pipelineNodeId`)),decoderNodeId:Y(n(`decoderNodeId`)),audioNodeId:Y(n(`audioNodeId`)),overriddenKeys:r}}function Yn(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...Yn(r.children,t+1));return n}function Xn(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function X({title:e,children:t}){return F(`div`,{className:`bg-background px-3.5 py-3 min-w-0`,children:[B(`div`,{className:`text-[9px] font-semibold uppercase tracking-[0.14em] text-foreground-subtle mb-2`,children:e}),B(`div`,{className:`flex flex-col gap-1 min-w-0`,children:t})]})}function Z({label:e,children:t,overridden:n=!1}){return F(`div`,{className:`flex items-baseline gap-2 text-[11px] leading-snug min-w-0`,children:[B(`span`,{className:`text-foreground-subtle shrink-0 w-24 truncate`,title:e,children:e}),B(`span`,{className:`font-mono tabular-nums text-foreground min-w-0 truncate flex-1`,children:t}),n&&B(Zn,{})]})}function Zn(){return B(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0 self-center`,title:`Device-level override active`,"aria-label":`Device-level override active`,role:`img`})}var Qn={neutral:`border-border text-foreground-muted`,success:`border-success/40 text-success`,warning:`border-warning/40 text-warning`,danger:`border-danger/40 text-danger`,info:`border-info/40 text-info`};function Q({tone:e=`neutral`,children:t,title:n}){return B(`span`,{title:n,className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-medium leading-tight whitespace-nowrap ${Qn[e]}`,children:t})}function $({children:e}){return B(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e})}function $n({icon:e,label:t,nodeId:n,pinned:r,reason:i,overridden:a}){return F(`div`,{className:`flex items-center gap-2 text-[11px] leading-snug min-w-0`,children:[B(e,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),B(`span`,{className:`text-foreground-subtle w-[4.5rem] shrink-0`,children:t}),n===null?B(`span`,{className:`text-foreground-subtle italic`,children:`unassigned`}):F(L,{children:[B(`span`,{className:`font-mono text-foreground truncate`,title:n,children:n}),r?F(`span`,{className:`inline-flex items-center gap-0.5 text-[10px] text-warning shrink-0`,title:`Manually pinned`,children:[B(st,{className:`h-2.5 w-2.5`}),` manual`]}):F(`span`,{className:`text-[10px] text-foreground-subtle shrink-0 truncate`,children:[`auto · `,i!==void 0&&i.length>0?i:`capacity`]}),a&&B(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-warning shrink-0`,title:`Persisted settings pin for this role`})]})]})}function er({assignment:e,settings:t,onlineNodes:n,pinPending:r,onDetectionPinChange:i}){let a=e.pinned.detection&&e.detectionNodeId!==null?e.detectionNodeId:`auto`,o=[...new Set([...e.detectionNodeId===null?[]:[e.detectionNodeId],...n.map(e=>e.id)])];return F(X,{title:`Where it runs`,children:[B($n,{icon:G,label:`Detection`,nodeId:e.detectionNodeId,pinned:e.pinned.detection,reason:e.reasons.detection,overridden:t.overriddenKeys.has(`pipelineNodeId`)}),B($n,{icon:Be,label:`Decoder`,nodeId:e.decoderNodeId,pinned:e.pinned.decoder,reason:e.reasons.decoder,overridden:t.overriddenKeys.has(`decoderNodeId`)}),B($n,{icon:Ae,label:`Audio`,nodeId:e.audioNodeId,pinned:e.pinned.audio,reason:e.reasons.audio,overridden:t.overriddenKeys.has(`audioNodeId`)}),B($n,{icon:Pe,label:`Source`,nodeId:e.sourceNodeId,pinned:!1,reason:`ingest owner`,overridden:!1}),B(`div`,{className:`mt-1.5`,children:F(`select`,{value:a,disabled:r,"aria-label":`Detection placement pin`,onChange:e=>i(e.target.value),className:`w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground disabled:opacity-50`,children:[B(`option`,{value:`auto`,children:`Auto (load balanced)`}),o.map(e=>F(`option`,{value:e,children:[`Pin detection → `,n.find(t=>t.id===e)?.name??e]},e))]})})]})}function tr(e){return`${e.width}×${e.height} ${e.codec} @${e.fps}fps`}function nr(e,t){if(!(t===null||e===void 0))return e.find(e=>e.profile===t)}function rr(e){return e===null?`default`:e===0?`native (no throttle)`:`${e} fps`}function ir({streams:e,brokerProfiles:t,settings:n,motionEnabled:r,motionFpsLive:i}){let a=nr(t,n.detectionStreamProfile),o=nr(t,n.motionStreamProfile),s=n.motionSources.includes(`analyzer`);return F(X,{title:`Streams & motion`,children:[F(Z,{label:`Detect stream`,overridden:n.overriddenKeys.has(`detectionStreamProfile`),children:[n.detectionStreamProfile??`—`,a!==void 0&&` · ${a.width}×${a.height} ${a.codec}`]}),B(Z,{label:`Detect FPS`,overridden:n.overriddenKeys.has(`detectionFps`),children:rr(n.detectionFps)}),F(Z,{label:`Motion src`,overridden:n.overriddenKeys.has(`motionSources`),children:[n.motionSources.length>0?n.motionSources.join(` + `):`none`,r===!1&&` · inactive`]}),s&&F(L,{children:[F(Z,{label:`Motion stream`,overridden:n.overriddenKeys.has(`motionStreamProfile`),children:[n.motionStreamProfile??`—`,o!==void 0&&` · ${o.width}×${o.height} ${o.codec}`]}),F(Z,{label:`Motion FPS`,overridden:n.overriddenKeys.has(`motionFps`),children:[rr(n.motionFps),i!==null&&` · live ${i.toFixed(1)}`]})]}),B(Z,{label:`Cooldown`,overridden:n.overriddenKeys.has(`motionCooldownMs`),children:n.motionCooldownMs===null?`default`:`${n.motionCooldownMs/1e3}s`}),B(`div`,{className:`mt-1.5 flex flex-col gap-0.5`,children:e.length===0?B($,{children:`No streams registered`}):e.map(e=>F(`div`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,title:e.camStreamId,children:[B(`span`,{className:`text-foreground-muted`,children:e.kind}),` `,tr(e)]},e.camStreamId))})]})}function ar({steps:e,audioModelId:t,audioEnabled:n,audioMode:r}){return F(X,{title:`Pipeline steps`,children:[e===void 0?B($,{children:`Resolving…`}):e.length===0?B($,{children:`No steps configured`}):B(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>B(Q,{tone:e.enabled&&e.depth===0?`info`:`neutral`,title:e.modelId??e.addonId,children:F(`span`,{className:e.enabled?``:`line-through opacity-60`,children:[e.depth>0&&B(`span`,{className:`opacity-50`,children:`↳ `}),e.addonId,e.modelId!==null&&F(`span`,{className:`font-mono opacity-75`,children:[` · `,e.modelId]})]})},`${e.addonId}-${t}`))}),B(`div`,{className:`mt-1`,children:F(Z,{label:`Audio class.`,children:[r??`—`,n!==null&&(n?` · running`:` · off`),t!==null&&` · ${t}`]})})]})}var or={ready:`success`,installing:`info`,verifying:`info`,idle:`neutral`,failed:`danger`};function sr({detection:e,live:t,detectionMode:n,modeOverridden:r}){if(e===null)return F(X,{title:`Detection runtime`,children:[B(Z,{label:`Mode`,overridden:r,children:n??`—`}),B($,{children:`Detection stage inactive or unreachable`})]});let a=t?.phase??e.phase,o=t?.actualFps??e.actualFps,s=t?.configuredFps??e.configuredFps,c=t?.avgInferenceTimeMs??e.avgInferenceMs,l=t?.queueDepth??e.queueDepth,u=i(a),d=a===`active`&&o===0;return F(X,{title:`Detection runtime`,children:[F(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:[F(`span`,{className:`inline-flex items-center gap-1 rounded border px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider ${u.badgeClass}`,children:[B(C,{phase:a,className:`h-2.5 w-2.5`}),u.label]}),t!==void 0&&B(`span`,{className:`text-[9px] text-foreground-subtle uppercase tracking-wider`,children:`live`})]}),B(Z,{label:`Mode`,overridden:r,children:n??`—`}),F(Z,{label:`FPS`,children:[B(`span`,{className:d?`text-danger font-semibold`:``,children:o.toFixed(1)}),F(`span`,{className:`text-foreground-subtle`,children:[` / `,s.toFixed(0),` configured`]})]}),F(Z,{label:`Inference`,children:[c.toFixed(0),` ms`,l>0&&F(`span`,{className:`text-warning`,children:[` · queue `,l]}),t!==void 0&&t.droppedFrames>0&&F(`span`,{className:`text-warning`,children:[` · drops `,t.droppedFrames]})]}),F(Z,{label:`Engine`,children:[e.engine.backend,` · `,e.engine.device]}),F(Z,{label:`Provisioning`,children:[B(Q,{tone:or[e.provisioning.state]??`neutral`,children:e.provisioning.state}),e.provisioning.error!==void 0&&F(`span`,{className:`text-danger text-[10px]`,children:[` `,e.provisioning.error]})]})]})}function cr({broker:e}){return e===null?B(X,{title:`Stream broker`,children:B($,{children:`Broker stage inactive or unreachable`})}):F(X,{title:`Stream broker`,children:[e.profiles.length===0?B($,{children:`No broker profiles`}):B(`div`,{className:`flex flex-col gap-1`,children:e.profiles.map(e=>{let t=e.status===`streaming`,n=t&&e.inFps===0;return F(`div`,{className:`flex items-center gap-2 text-[11px] font-mono tabular-nums min-w-0`,children:[B(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full shrink-0 ${n?`bg-danger`:t?`bg-success animate-pulse`:`bg-border`}`,title:e.status}),B(`span`,{className:`text-foreground w-10 shrink-0 truncate`,title:e.profile,children:e.profile}),F(`span`,{className:`text-foreground-subtle truncate`,children:[e.width,`×`,e.height,` `,e.codec]}),F(`span`,{className:`ml-auto shrink-0 ${n?`text-danger`:`text-foreground`}`,children:[e.inFps.toFixed(0),`→`,e.outFps.toFixed(0),`fps`]}),F(`span`,{className:`text-foreground-subtle shrink-0`,title:`Subscribers`,children:[`×`,e.subscribers]})]},e.profile)})}),F(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[F(Q,{tone:e.webrtcSessions>0?`info`:`neutral`,children:[`WebRTC `,e.webrtcSessions]}),F(Q,{tone:e.rtspRestream?`success`:`neutral`,children:[`restream `,e.rtspRestream?`on`:`off`]})]})]})}function lr({decoder:e,detectionActive:t}){if(e===null)return B(X,{title:`Decoder`,children:B($,{children:`Decoder stage inactive or unreachable`})});let n=t&&e.shm.framesWritten===0;return F(X,{title:`Decoder`,children:[B(Z,{label:`Node`,children:e.nodeId}),B(Z,{label:`Sessions`,children:e.sessionCount}),F(Z,{label:`SHM frames`,children:[B(`span`,{className:n?`text-danger font-semibold`:``,children:e.shm.framesWritten}),B(`span`,{className:`text-foreground-subtle`,children:` written`})]}),F(Z,{label:`SHM reads`,children:[e.shm.getFrameHits,` hits`,e.shm.getFrameMisses>0&&F(`span`,{className:`text-warning`,children:[` · `,e.shm.getFrameMisses,` misses`]})]}),F(Z,{label:`SHM budget`,children:[e.shm.budgetMb,` MB`]}),e.formats.length>0&&B(Z,{label:`Formats`,children:e.formats.join(`, `)})]})}P();var ur=`pipeline-orchestrator`,dr={healthy:`bg-success`,idle:`bg-warning`,error:`bg-danger`},fr={healthy:`Healthy`,idle:`Idle`,error:`Error`};function pr({problems:e}){return B(`div`,{role:`alert`,className:`flex flex-col border-b border-border`,children:e.map(e=>F(`div`,{className:`flex items-start gap-2 px-4 py-1.5 text-[11px] font-medium ${e.severity===`error`?`bg-danger/10 text-danger`:`bg-warning/10 text-warning`}`,children:[B(Ye,{className:`h-3.5 w-3.5 shrink-0 mt-px`}),B(`span`,{className:`min-w-0`,children:e.message})]},e.code))})}function mr({deviceId:e,name:t,online:n,status:r,live:i,onlineNodes:a}){let o=R(),{data:s}=re({addonId:ur,deviceId:e,nodeId:`hub`},{staleTime:3e4}),{data:c}=m({deviceId:e},{staleTime:3e4}),l=I(()=>Jn(s),[s]),u=I(()=>c===void 0?void 0:Yn(c.steps),[c]),f=I(()=>r===void 0?[]:Hn(r),[r]),p=()=>{o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]}),o.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]})},h=oe({onSuccess:p}),g=d({onSuccess:p}),_=t=>{t===`auto`?g.mutate({deviceId:e}):h.mutate({deviceId:e,agentNodeId:t})},v=r===void 0?`idle`:Xn(r),y=f.some(e=>e.severity===`error`),b=f.length>0,x=y?`border-danger/50`:b?`border-warning/40`:`border-border`;return F(`article`,{"aria-label":`${t} pipeline status`,className:`rounded-lg border ${x} bg-background overflow-hidden`,children:[F(`header`,{className:`flex items-center gap-2.5 px-4 py-2.5 border-b border-border bg-surface/50 min-w-0`,children:[B(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${y?`bg-danger`:dr[v]}`,title:y?`Error`:fr[v],"aria-label":y?`Error`:fr[v],role:`img`}),B(`h3`,{className:`text-[13px] font-semibold text-foreground truncate`,title:t,children:t}),F(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`#`,e]}),!n&&B(Q,{tone:`danger`,children:`offline`}),F(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[l.detectionMode!==null&&B(Q,{tone:l.detectionMode===`disabled`?`warning`:l.detectionMode===`always-on`?`info`:`neutral`,title:`Object detection mode`,children:l.detectionMode===`disabled`?`detection off`:l.detectionMode}),r?.recording!=null&&(r.recording.active?F(Q,{tone:`danger`,title:`Recording (${r.recording.mode})`,children:[B(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-danger animate-pulse`}),`REC`]}):r.recording.mode!==`off`&&F(Q,{tone:`neutral`,title:`Recording mode`,children:[`rec `,r.recording.mode]}))]})]}),f.length>0&&B(pr,{problems:f}),r===void 0?B(`div`,{className:`px-4 py-5 text-[11px] text-foreground-subtle italic`,children:`No pipeline status yet — the orchestrator has not composed a snapshot for this camera.`}):F(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-px bg-border`,children:[B(er,{assignment:r.assignment,settings:l,onlineNodes:a,pinPending:h.isPending||g.isPending,onDetectionPinChange:_}),B(sr,{detection:r.detection,live:i,detectionMode:l.detectionMode,modeOverridden:l.overriddenKeys.has(`detectionMode`)}),B(ar,{steps:u,audioModelId:c?.audio?.modelId??null,audioEnabled:r.audio?.enabled??c?.audio?.enabled??null,audioMode:l.audioMode}),B(ir,{streams:r.source.streams,brokerProfiles:r.broker?.profiles,settings:l,motionEnabled:r.motion?.enabled??null,motionFpsLive:r.motion?.fps??null}),B(cr,{broker:r.broker}),B(lr,{decoder:r.decoder,detectionActive:r.detection?.phase===`active`})]})]})}P();var hr=5e3,gr=1e4,_r=5e3;function vr(e){let t=R(),{data:n,isLoading:r}=Ce(),{data:i,isLoading:a}=k({},{refetchInterval:hr}),{nodes:o}=v();V(()=>{e!==0&&t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStatuses`]]})},[e,t]);let[s,c]=z(new Map);b(be.PipelineCameraMetricsSnapshot,e=>{let t=e.data;typeof t.deviceId==`number`&&c(e=>{let n=new Map(e);return n.set(t.deviceId,{phase:t.metrics.phase,configuredFps:t.metrics.configuredFps,actualFps:t.metrics.actualFps,queueDepth:t.metrics.queueDepth,avgInferenceTimeMs:t.metrics.avgInferenceTimeMs,droppedFrames:t.metrics.droppedFrames,timestamp:t.timestamp}),n})}),V(()=>{if(s.size===0)return;let e=setInterval(()=>{c(e=>{let t=Date.now()-gr,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},_r);return()=>clearInterval(e)},[s.size]);let l=I(()=>{let e=new Map;for(let t of i??[])e.set(t.deviceId,t);return e},[i]);return{rows:I(()=>(n??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,online:e.online,status:l.get(e.id)})).sort((e,t)=>e.name.localeCompare(t.name)),[n,l]),liveMetrics:s,onlineNodes:I(()=>(o??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[o]),isLoading:r||a}}P();function yr({refreshToken:e}){let{rows:t,liveMetrics:n,onlineNodes:r,isLoading:i}=vr(e),a=I(()=>[...t.map(e=>{let t=e.status===void 0?[]:Hn(e.status);return{row:e,errorCount:t.filter(e=>e.severity===`error`).length,warningCount:t.filter(e=>e.severity===`warning`).length}})].sort((e,t)=>e.errorCount===t.errorCount?e.warningCount===t.warningCount?0:t.warningCount-e.warningCount:t.errorCount-e.errorCount),[t]),o=I(()=>{let e=0,t=0;for(let r of a)(r.errorCount>0||r.warningCount>0)&&(t+=1),(n.get(r.row.deviceId)?.phase??r.row.status?.detection?.phase)===`active`&&(e+=1);return{total:a.length,active:e,issues:t}},[a,n]);return i&&t.length===0?B(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Loading camera pipelines…`}):t.length===0?B(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`No cameras found`}):B(`div`,{className:`h-full overflow-y-auto`,children:F(`div`,{className:`max-w-6xl mx-auto flex flex-col gap-3 px-4 py-4`,children:[F(`div`,{className:`flex items-center gap-4 text-[11px] text-foreground-subtle px-1`,children:[F(`span`,{children:[B(`span`,{className:`font-semibold text-foreground`,children:o.total}),` cameras`]}),F(`span`,{children:[B(`span`,{className:`font-semibold text-success`,children:o.active}),` actively inferring`]}),F(`span`,{children:[B(`span`,{className:`font-semibold ${o.issues>0?`text-danger`:`text-foreground`}`,children:o.issues}),` `,`with issues`]}),B(`span`,{className:`ml-auto hidden sm:inline text-[10px]`,children:`polled every 5 s · detection metrics live at 1 Hz`})]}),a.map(({row:e})=>B(mr,{deviceId:e.deviceId,name:e.name,online:e.online,status:e.status,live:n.get(e.deviceId),onlineNodes:r},e.deviceId))]})})}P();var br=`__cluster__`;function xr(e){return e===`cameras`?`cameras`:`nodes`}function Sr(){let[e,t]=He(),n=xr(e.get(`view`)),r=e.get(`node`)??`__cluster__`,[i,a]=z(0),[o,s]=z(!1);return V(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:br},{replace:!0})},[n,e,t]),F(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[F(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[F(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[B(`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`}),B(`button`,{type:`button`,onClick:()=>{t({view:`cameras`},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),F(`button`,{type:`button`,onClick:()=>a(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[B(Fe,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),n===`nodes`&&F(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[F(`span`,{children:[o?`Hide`:`Show`,` node list`]}),B(Ve,{className:[`h-4 w-4 transition-transform`,o?`rotate-180`:``].join(` `)})]}),B(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?F(L,{children:[B(`aside`,{className:[o?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:B(pt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),s(!1)},refreshToken:i})}),B(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?B(Vn,{refreshToken:i}):B(tn,{nodeId:r,refreshToken:i})})]}):B(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:B(yr,{refreshToken:i})})})]})}export{Sr as PipelinePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Bi as e,Gi as t,Hi as n,Ji as r,Ki as i,Li as a,Ri as o,Ui as s,Vi as c,Wa as l,Wi as u,Yi as d,_o as f,bo as p,do as m,fo as h,ho as g,jn as _,mo as v,po as y,qi as b,uo as x,yo as S,zi as C}from"./src-CS6t478y.js";import{K as w,Q as T,S as E,W as D,b as O,o as k,q as A,x as j,z as M}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as N}from"./src-lbvXy3B8.js";import{a as P,i as ee,n as F,r as te,t as I}from"./face-bbox-DfMx6dB8.js";import{a as L,c as R,f as z,i as B,l as ne,m as V,n as re,o as ie,p as ae,r as H,s as oe,t as U,u as se}from"./debounced-invalidate-BaWy1MGf.js";import{t as W}from"./pencil-y2nsLD1K.js";import{t as G}from"./plus-BMJjznU2.js";import{t as ce}from"./square-check-big-Bghaf-FM.js";import{t as K}from"./square-BsDohB3h.js";import{I as q,L as le,P as ue,R as J,S as Y,W as de,i as X,s as Z}from"./index-C3HbZT6b.js";import{t as fe}from"./AdminPage-BwmGKnRf.js";import{n as pe,t as me}from"./authed-media-XfBD4Ma-.js";var he=de(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]);T();var Q=[[`plateGallery`]];function ge({vehicleId:e}){let t=k(),{data:n,isLoading:r}=u({vehicleId:e}),a=i();function o(n){a.mutate({vehicleId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:Q})}})}return r?E(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[j(Y,{className:`h-3.5 w-3.5 animate-spin`}),`Loading plates…`]}):!n||n.length===0?j(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No plates yet.`}):j(`div`,{className:`mt-2 grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-6`,children:n.map(e=>E(`div`,{className:`group relative overflow-hidden rounded-md border border-border bg-surface`,children:[E(`div`,{className:`relative aspect-[2/1] overflow-hidden bg-surface-hover`,children:[e.base64?j(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:e.text,className:`h-full w-full object-cover`}):j(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:j(J,{className:`h-6 w-6`})}),j(`button`,{type:`button`,onClick:()=>o(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove plate sample`,children:j(X,{className:`h-4 w-4 text-white`})})]}),j(`p`,{className:`truncate px-1.5 py-1 text-center font-mono text-[11px] font-semibold tracking-wide text-foreground`,title:e.text,children:e.text})]},e.id))})}function _e({vehicle:e,expanded:t,onToggle:n}){let r=k(),[i,a]=A(``),[o,s]=A(!1),[l,u]=A(!1),d=b(),_=c();function C(){a(e.name),s(!0)}function w(){s(!1),a(``)}function T(){let t=i.trim();if(!t||t===e.name){w();return}d.mutate({id:e.id,name:t},{onSettled:()=>{r.invalidateQueries({queryKey:Q}),w()}})}function D(){_.mutate({id:e.id},{onSettled:()=>{r.invalidateQueries({queryKey:Q}),u(!1)}})}return E(`div`,{className:`rounded-md border border-border bg-surface`,children:[E(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[j(`div`,{className:`h-8 w-12 shrink-0 overflow-hidden rounded border border-border bg-surface-hover`,children:e.coverBase64?j(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):j(`div`,{className:`flex h-full w-full items-center justify-center`,children:j(J,{className:`h-4 w-4 text-foreground-subtle`})})}),j(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:o?E(O,{children:[j(f,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(),e.key===`Escape`&&w()},className:`h-6 text-xs`,autoFocus:!0}),j(`button`,{type:`button`,onClick:T,disabled:d.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:j(le,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:w,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:j(X,{className:`h-3.5 w-3.5`})})]}):j(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),j(S,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!o&&E(`div`,{className:`flex items-center gap-1`,children:[j(`button`,{type:`button`,onClick:C,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:j(W,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:()=>u(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:j(Z,{className:`h-3.5 w-3.5`})})]}),j(`button`,{type:`button`,onClick:n,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":t?`Collapse`:`Expand`,children:j(t?q:ue,{className:`h-3.5 w-3.5`})})]}),t&&j(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:j(ge,{vehicleId:e.id})}),j(x,{open:l,onOpenChange:e=>!e&&u(!1),children:E(m,{children:[E(v,{children:[j(g,{children:`Delete vehicle`}),E(h,{children:[`Delete `,j(`strong`,{children:e.name}),` and all its plate samples? This cannot be undone.`]})]}),E(y,{children:[j(p,{variant:`secondary`,onClick:()=>u(!1),children:`Cancel`}),E(p,{variant:`danger`,onClick:D,disabled:_.isPending,children:[_.isPending?j(Y,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function ve(){let e=k(),[t,n]=A(``),r=C();function i(){let i=t.trim();i&&r.mutate({name:i},{onSettled:()=>{e.invalidateQueries({queryKey:Q}),n(``)}})}return E(`div`,{className:`flex items-center gap-2 pt-2`,children:[j(f,{placeholder:`New vehicle name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},className:`h-7 text-xs flex-1`}),E(p,{variant:`primary`,size:`sm`,onClick:i,disabled:r.isPending||!t.trim(),children:[r.isPending?j(Y,{className:`h-3.5 w-3.5 animate-spin`}):j(G,{className:`h-3.5 w-3.5`}),`Add`]})]})}function ye(){let{data:e,isLoading:n}=t(),[r,i]=A(null);function a(e){i(t=>t===e?null:e)}return n?E(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[j(Y,{className:`h-4 w-4 animate-spin`}),`Loading vehicles…`]}):E(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&j(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No vehicles enrolled yet. Add one below.`}),e?.map(e=>j(_e,{vehicle:e,expanded:r===e.id,onToggle:()=>a(e.id)},e.id)),j(ve,{})]})}T();var be=[[`plateGallery`]];function xe(e){let[t,n]=A(null),[r,i]=A(null),[a,o]=A(!1);return M(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await pe(`${me}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),M(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function Se(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|plate/i.test(e.kind))??t[0]}function $({label:e,value:t,mono:n}){return E(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[j(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),j(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground ${n?`font-mono`:``}`,title:t,children:t})]})}function Ce({box:e}){return j(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:j(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Plate`})})}function we({plate:e,cameraName:t,onClose:r,onAssign:i,onUnassign:a,onDelete:s,actionsPending:c}){let l=k(),{data:u,isFetching:d}=n({plateId:e?.plateId??``},{enabled:e!==null}),h=o(),[g,_]=A(`frame`),[v,y]=A(!1),[b,S]=A(``),{frameSrc:C,naturalWidth:w,naturalHeight:T,failed:O}=xe(e?.keyFrameMediaKey);M(()=>{y(!1),S(``),_(`frame`)},[e?.plateId]);let N=D(()=>{let t=Se(u??[]);return t?`data:image/jpeg;base64,${t.base64}`:e?.base64?`data:image/jpeg;base64,${e.base64}`:null},[u,e]),L=D(()=>!e?.plateBbox||w===null||T===null?null:I(e.plateBbox,w,T),[e?.plateBbox,w,T]);if(e===null)return null;let R=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!O,z=R&&g===`frame`,ne=e.assigned?e.vehicleName??`Assigned`:e.recognizedVehicleId?`${e.vehicleName??`Recognized`} (suggested)`:`Unassigned`,re=`${String(Math.round(e.score*100))}%${e.corrected?` · corrected`:``}`;function ie(){e&&(S(e.text),y(!0))}function H(){if(!e)return;let t=b.trim().toUpperCase();if(!t||t===e.text){y(!1);return}h.mutate({plateId:e.plateId,text:t},{onSettled:()=>{l.invalidateQueries({queryKey:be}),y(!1)}})}return j(x,{open:!0,onOpenChange:e=>!e&&r(),children:E(m,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Plate detail`,className:`flex h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:h-auto md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[E(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[E(`div`,{className:`min-w-0`,children:[j(`div`,{className:`truncate font-mono text-sm font-semibold tracking-wide text-foreground`,children:e.text||`Plate detail`}),j(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),j(`button`,{type:`button`,onClick:r,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:j(X,{className:`h-4 w-4`})})]}),E(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[R&&E(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[E(`button`,{type:`button`,onClick:()=>_(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${g===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[j(ee,{className:`h-3.5 w-3.5`}),` Full frame`]}),E(`button`,{type:`button`,onClick:()=>_(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${g===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[j(P,{className:`h-3.5 w-3.5`}),` Crop`]})]}),z&&C?j(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:j(B,{src:C,alt:`Full frame with detected plate`,fit:`natural`,className:`w-full`,overlay:L?j(Ce,{box:L}):void 0})}):N?E(`div`,{className:`relative aspect-[2/1] w-full overflow-hidden rounded-lg border border-border bg-background`,children:[j(B,{src:N,alt:`Detected plate`,className:`h-full w-full`}),d&&j(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:j(Y,{className:`h-3.5 w-3.5 animate-spin`})})]}):E(`div`,{className:`flex aspect-[2/1] w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[j(V,{className:`h-8 w-8 text-warning/70`}),j(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),j(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this plate could not be resolved. Safe to delete.`})]}),j(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-2`,children:E(`div`,{className:`flex items-center justify-between gap-3`,children:[j(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:`Plate text`}),v?E(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-1.5`,children:[j(f,{value:b,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&H(),e.key===`Escape`&&y(!1)},className:`h-7 max-w-[10rem] text-right font-mono text-xs uppercase`,autoFocus:!0}),j(`button`,{type:`button`,onClick:H,disabled:h.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Save corrected text`,children:h.isPending?j(Y,{className:`h-3.5 w-3.5 animate-spin`}):j(le,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:()=>y(!1),className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel`,children:j(X,{className:`h-3.5 w-3.5`})})]}):E(`button`,{type:`button`,onClick:ie,className:`group flex min-w-0 items-center gap-1.5`,title:`Correct the OCR reading`,children:[j(`span`,{className:`truncate font-mono text-sm font-semibold tracking-wide text-foreground`,children:e.text||`—`}),j(W,{className:`h-3 w-3 shrink-0 text-foreground-subtle group-hover:text-foreground`})]})]})}),E(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[j($,{label:`Camera`,value:t}),j($,{label:`Captured`,value:ae(e.timestamp)}),j($,{label:`Confidence`,value:re}),j($,{label:`Vehicle`,value:ne}),j($,{label:`Track`,value:e.trackId,mono:!0})]})]}),E(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?E(p,{variant:`secondary`,onClick:()=>a(e.plateId),disabled:c,children:[j(F,{className:`h-3.5 w-3.5`}),` Detach`]}):E(p,{variant:`primary`,onClick:()=>i(e.plateId),disabled:c,children:[j(te,{className:`h-3.5 w-3.5`}),` Assign`]}),E(p,{variant:`secondary`,onClick:()=>s(e.plateId),disabled:c,children:[j(Z,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}T();var Te=[[`plateGallery`]];function Ee({plateIds:e,vehicles:t,onDone:n}){let r=k(),i=a(),o=C(),[s,c]=A(``),[l,u]=A(!1),[d,_]=A(null),b=e!==null&&e.length>0,S=e?.length??0;function w(){u(!1),c(``),_(null)}function T(){w(),n()}function D(t){!e||e.length===0||i.mutate({plateIds:[...e],vehicleId:t},{onSettled:()=>{r.invalidateQueries({queryKey:Te}),T()}})}function O(){!e||!s.trim()||o.mutate({name:s.trim()},{onSuccess:e=>{e?.id&&D(e.id)},onError:()=>{r.invalidateQueries({queryKey:Te}),T()}})}let M=i.isPending||o.isPending;return j(x,{open:b,onOpenChange:e=>!e&&T(),children:E(m,{children:[E(v,{children:[j(g,{children:S>1?`Assign ${String(S)} plates to vehicle`:`Assign plate to vehicle`}),j(h,{children:`Select an existing vehicle or create a new one.`})]}),j(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:t.map(e=>E(`button`,{type:`button`,onClick:()=>_(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${d===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[j(`span`,{className:`font-medium`,children:e.name}),E(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` plates`]})]},e.id))}),l?j(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:j(f,{placeholder:`New vehicle name…`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):j(`button`,{type:`button`,onClick:()=>{_(null),u(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New vehicle…`}),E(y,{children:[j(p,{variant:`secondary`,onClick:T,disabled:M,children:`Cancel`}),l?E(p,{variant:`primary`,onClick:O,disabled:M||!s.trim(),children:[M&&j(Y,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):E(p,{variant:`primary`,onClick:()=>d&&D(d),disabled:M||!d,children:[M&&j(Y,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,S>1?` ${String(S)}`:``]})]})]})})}T();var De=[[`plateGallery`]],Oe=500,ke=120;function Ae({plate:t,cameraName:n,nowMs:i,selected:a,onToggleSelect:o,onAssign:s,onOpenDetail:c}){let l=k(),u=r(),d=e(),f=()=>{l.invalidateQueries({queryKey:De})},p=()=>c(t.plateId);return E(`div`,{className:`relative flex flex-col overflow-hidden rounded-md border bg-surface ${a?`border-primary ring-1 ring-primary`:`border-border`}`,children:[E(`div`,{className:`relative aspect-[2/1] overflow-hidden bg-surface-hover`,children:[t.base64?j(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:`Plate ${t.text} from ${n}`,onClick:p,className:`h-full w-full cursor-zoom-in object-cover`}):E(`button`,{type:`button`,onClick:p,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the plate's crop media is missing. Safe to delete.`,children:[j(V,{className:`h-7 w-7 text-warning/70`}),j(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),j(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(t.plateId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":a?`Deselect`:`Select`,children:a?j(ce,{className:`h-4 w-4 text-primary`}):j(K,{className:`h-4 w-4`})}),t.corrected&&E(`span`,{className:`absolute right-0 top-0 z-10 flex items-center gap-0.5 rounded-bl-md bg-primary/80 px-1 py-0.5 text-[8px] font-semibold uppercase tracking-wide text-white`,title:`Manually corrected`,children:[j(he,{className:`h-3 w-3`}),` Fixed`]})]}),E(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[j(`p`,{className:`truncate font-mono text-xs font-bold tracking-wide text-foreground`,title:t.text,children:t.text||`—`}),j(`p`,{className:`truncate text-[10px] text-foreground-subtle`,title:n,children:n}),j(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:z(t.timestamp,i)}),t.vehicleName&&j(`p`,{className:`truncate text-[10px] font-medium text-primary`,title:t.vehicleName,children:t.vehicleName})]}),E(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[t.assigned?j(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u.mutate({plateId:t.plateId},{onSettled:f})},disabled:u.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach plate`,title:`Detach`,children:u.isPending?j(Y,{className:`h-4 w-4 animate-spin`}):j(F,{className:`h-4 w-4`})}):j(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s(t.plateId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign plate to vehicle`,title:`Assign to vehicle`,children:j(te,{className:`h-4 w-4`})}),j(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),d.mutate({plateId:t.plateId},{onSettled:f})},disabled:d.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete plate`,title:`Delete plate`,children:d.isPending?j(Y,{className:`h-4 w-4 animate-spin`}):j(Z,{className:`h-4 w-4`})})]})]})}var je=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Assigned`,value:`assigned`}];function Me(e,t){return t===`unassigned`?e.filter(e=>!e.assigned):t===`assigned`?e.filter(e=>e.assigned):e}function Ne(){let n=k(),[i,a]=A(`all`),[o,c]=A(oe),[l,u]=A(new Set),[f,m]=A(new Set),[h,g]=A(null),[v,y]=A(null),{data:b,isLoading:x}=s({limit:Oe},{refetchInterval:3e4}),{data:S=[]}=t(),{data:C}=_({}),w=r(),T=d(),M=e(),N=Date.now(),P=b??[],ee=D(()=>{let e=new Map;for(let t of C??[])e.set(t.id,t.name);return e},[C]),I=e=>ee.get(e)??`Camera #${String(e)}`,z=D(()=>R(P).map(e=>({id:e,name:I(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[P,ee]),B=D(()=>ne(se(Me(P,i),o),l),[P,i,o,l]),V=re(B,ke,D(()=>JSON.stringify([i,o.fromMs,o.toMs,[...l].sort((e,t)=>e-t)]),[i,o.fromMs,o.toMs,l])),ae=D(()=>new Map(P.map(e=>[e.plateId,e])),[P]),U=v===null?null:ae.get(v)??null,W=()=>{n.invalidateQueries({queryKey:De})},G=()=>m(new Set);function ce(e){m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let K=[...f],q=T.isPending||M.isPending,le=w.isPending||M.isPending;function ue(){K.length!==0&&T.mutate({plateIds:K},{onSettled:()=>{W(),G()}})}function J(){K.length!==0&&Promise.allSettled(K.map(e=>M.mutateAsync({plateId:e}))).then(()=>{W(),G()})}function de(e){y(null),g([e])}function fe(e){w.mutate({plateId:e},{onSettled:W}),y(null)}function pe(e){M.mutate({plateId:e},{onSettled:W}),y(null)}let me=B.length!==P.length;return E(`div`,{className:`relative space-y-3`,children:[E(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[j(`div`,{className:`flex items-center gap-1`,children:je.map(e=>j(`button`,{type:`button`,onClick:()=>a(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),j(L,{onChange:c}),j(ie,{cameras:z,selected:l,onChange:u}),!x&&j(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:me?`${String(B.length)} of ${String(P.length)} plates`:`${String(B.length)} plate${B.length===1?``:`s`}`})]}),f.size>0&&E(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[E(`span`,{className:`text-xs font-medium text-foreground`,children:[f.size,` selected`]}),E(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[E(p,{variant:`primary`,onClick:()=>g(K),disabled:q,children:[j(te,{className:`h-3.5 w-3.5`}),` Assign`]}),E(p,{variant:`secondary`,onClick:ue,disabled:q,children:[T.isPending?j(Y,{className:`h-3.5 w-3.5 animate-spin`}):j(F,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),E(p,{variant:`secondary`,onClick:J,disabled:q,children:[j(Z,{className:`h-3.5 w-3.5`}),` Delete`]}),j(p,{variant:`ghost`,onClick:G,disabled:q,children:j(X,{className:`h-3.5 w-3.5`})})]})]}),x&&E(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[j(Y,{className:`h-4 w-4 animate-spin`}),` Loading plates…`]}),!x&&B.length===0&&j(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:P.length>0?`No plates match the current filters.`:`No plates recognized yet.`}),!x&&B.length>0&&E(O,{children:[j(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))] gap-2`,children:V.pageItems.map(e=>j(Ae,{plate:e,cameraName:I(e.deviceId),nowMs:N,selected:f.has(e.plateId),onToggleSelect:ce,onAssign:e=>g([e]),onOpenDetail:y},e.plateId))}),j(H,{currentPage:V.page,totalItems:V.totalItems,pageSize:V.pageSize,onPageChange:V.setPage,itemNoun:`plates`})]}),j(we,{plate:U,cameraName:U?I(U.deviceId):``,onClose:()=>y(null),onAssign:de,onUnassign:fe,onDelete:pe,actionsPending:le}),j(Ee,{plateIds:h,vehicles:S,onDone:()=>{g(null),G()}})]})}T();var Pe=[[`plateGallery`]],Fe=2e3;function Ie(){let e=k(),t=w(e);t.current=e;let n=w(void 0);n.current||=U({delayMs:Fe,invalidate:()=>{t.current.invalidateQueries({queryKey:Pe})}}),M(()=>()=>n.current?.cancel(),[]),l(N.PipelineAnalyticsPlateGalleryChanged,()=>{n.current?.trigger()})}function Le(){return Ie(),j(fe,{icon:J,title:`Plates`,subtitle:`Manage enrolled vehicles and assign recognized license plates to them.`,children:E(`section`,{className:`space-y-3`,children:[E(`div`,{children:[j(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Vehicles`}),j(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled vehicle identities used for plate recognition. Expand a row to view or remove plate samples.`}),j(ye,{})]}),E(`div`,{className:`pt-4 border-t border-border`,children:[j(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent recognized plates`}),j(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`License plates read by the detection pipeline. Assign them to a vehicle, correct the OCR text, or delete.`}),j(Ne,{})]})]})})}export{Le as PlatesPage};
|
|
1
|
+
import{Bi as e,Gi as t,Hi as n,Ji as r,Ki as i,Li as a,Ri as o,Ui as s,Vi as c,Wa as l,Wi as u,Yi as d,bo as f,do as p,fo as m,go as h,ho as g,jn as _,mo as v,po as y,qi as b,vo as x,xo as S,zi as C}from"./src-CwIdcVoz.js";import{K as w,Q as T,S as E,W as D,b as O,o as k,q as A,x as j,z as M}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as N}from"./src-awTRXPIW.js";import{a as P,i as ee,n as F,r as te,t as I}from"./face-bbox-D9kGh3_L.js";import{a as L,c as R,f as z,i as B,l as ne,m as V,n as re,o as ie,p as ae,r as H,s as oe,t as U,u as se}from"./debounced-invalidate-BMlW3lc0.js";import{t as W}from"./pencil-Bko5beeH.js";import{t as G}from"./plus-S9U4mORX.js";import{t as ce}from"./square-check-big-BipJcw1N.js";import{t as K}from"./square-CasTblrl.js";import{I as q,L as le,P as ue,R as J,S as Y,W as de,i as X,s as Z}from"./index-CqPUI4oB.js";import{t as fe}from"./AdminPage-BwmGKnRf.js";import{n as pe,t as me}from"./authed-media-XfBD4Ma-.js";var he=de(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]);T();var Q=[[`plateGallery`]];function ge({vehicleId:e}){let t=k(),{data:n,isLoading:r}=u({vehicleId:e}),a=i();function o(n){a.mutate({vehicleId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:Q})}})}return r?E(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[j(Y,{className:`h-3.5 w-3.5 animate-spin`}),`Loading plates…`]}):!n||n.length===0?j(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No plates yet.`}):j(`div`,{className:`mt-2 grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-6`,children:n.map(e=>E(`div`,{className:`group relative overflow-hidden rounded-md border border-border bg-surface`,children:[E(`div`,{className:`relative aspect-[2/1] overflow-hidden bg-surface-hover`,children:[e.base64?j(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:e.text,className:`h-full w-full object-cover`}):j(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:j(J,{className:`h-6 w-6`})}),j(`button`,{type:`button`,onClick:()=>o(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove plate sample`,children:j(X,{className:`h-4 w-4 text-white`})})]}),j(`p`,{className:`truncate px-1.5 py-1 text-center font-mono text-[11px] font-semibold tracking-wide text-foreground`,title:e.text,children:e.text})]},e.id))})}function _e({vehicle:e,expanded:t,onToggle:n}){let r=k(),[i,a]=A(``),[o,s]=A(!1),[l,u]=A(!1),d=b(),_=c();function C(){a(e.name),s(!0)}function w(){s(!1),a(``)}function T(){let t=i.trim();if(!t||t===e.name){w();return}d.mutate({id:e.id,name:t},{onSettled:()=>{r.invalidateQueries({queryKey:Q}),w()}})}function D(){_.mutate({id:e.id},{onSettled:()=>{r.invalidateQueries({queryKey:Q}),u(!1)}})}return E(`div`,{className:`rounded-md border border-border bg-surface`,children:[E(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[j(`div`,{className:`h-8 w-12 shrink-0 overflow-hidden rounded border border-border bg-surface-hover`,children:e.coverBase64?j(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):j(`div`,{className:`flex h-full w-full items-center justify-center`,children:j(J,{className:`h-4 w-4 text-foreground-subtle`})})}),j(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:o?E(O,{children:[j(x,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(),e.key===`Escape`&&w()},className:`h-6 text-xs`,autoFocus:!0}),j(`button`,{type:`button`,onClick:T,disabled:d.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:j(le,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:w,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:j(X,{className:`h-3.5 w-3.5`})})]}):j(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),j(f,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!o&&E(`div`,{className:`flex items-center gap-1`,children:[j(`button`,{type:`button`,onClick:C,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:j(W,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:()=>u(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:j(Z,{className:`h-3.5 w-3.5`})})]}),j(`button`,{type:`button`,onClick:n,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":t?`Collapse`:`Expand`,children:j(t?q:ue,{className:`h-3.5 w-3.5`})})]}),t&&j(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:j(ge,{vehicleId:e.id})}),j(p,{open:l,onOpenChange:e=>!e&&u(!1),children:E(m,{children:[E(g,{children:[j(h,{children:`Delete vehicle`}),E(y,{children:[`Delete `,j(`strong`,{children:e.name}),` and all its plate samples? This cannot be undone.`]})]}),E(v,{children:[j(S,{variant:`secondary`,onClick:()=>u(!1),children:`Cancel`}),E(S,{variant:`danger`,onClick:D,disabled:_.isPending,children:[_.isPending?j(Y,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function ve(){let e=k(),[t,n]=A(``),r=C();function i(){let i=t.trim();i&&r.mutate({name:i},{onSettled:()=>{e.invalidateQueries({queryKey:Q}),n(``)}})}return E(`div`,{className:`flex items-center gap-2 pt-2`,children:[j(x,{placeholder:`New vehicle name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},className:`h-7 text-xs flex-1`}),E(S,{variant:`primary`,size:`sm`,onClick:i,disabled:r.isPending||!t.trim(),children:[r.isPending?j(Y,{className:`h-3.5 w-3.5 animate-spin`}):j(G,{className:`h-3.5 w-3.5`}),`Add`]})]})}function ye(){let{data:e,isLoading:n}=t(),[r,i]=A(null);function a(e){i(t=>t===e?null:e)}return n?E(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[j(Y,{className:`h-4 w-4 animate-spin`}),`Loading vehicles…`]}):E(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&j(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No vehicles enrolled yet. Add one below.`}),e?.map(e=>j(_e,{vehicle:e,expanded:r===e.id,onToggle:()=>a(e.id)},e.id)),j(ve,{})]})}T();var be=[[`plateGallery`]];function xe(e){let[t,n]=A(null),[r,i]=A(null),[a,o]=A(!1);return M(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await pe(`${me}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),M(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function Se(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|plate/i.test(e.kind))??t[0]}function $({label:e,value:t,mono:n}){return E(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[j(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),j(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground ${n?`font-mono`:``}`,title:t,children:t})]})}function Ce({box:e}){return j(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:j(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Plate`})})}function we({plate:e,cameraName:t,onClose:r,onAssign:i,onUnassign:a,onDelete:s,actionsPending:c}){let l=k(),{data:u,isFetching:d}=n({plateId:e?.plateId??``},{enabled:e!==null}),f=o(),[h,g]=A(`frame`),[_,v]=A(!1),[y,b]=A(``),{frameSrc:C,naturalWidth:w,naturalHeight:T,failed:O}=xe(e?.keyFrameMediaKey);M(()=>{v(!1),b(``),g(`frame`)},[e?.plateId]);let N=D(()=>{let t=Se(u??[]);return t?`data:image/jpeg;base64,${t.base64}`:e?.base64?`data:image/jpeg;base64,${e.base64}`:null},[u,e]),L=D(()=>!e?.plateBbox||w===null||T===null?null:I(e.plateBbox,w,T),[e?.plateBbox,w,T]);if(e===null)return null;let R=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!O,z=R&&h===`frame`,ne=e.assigned?e.vehicleName??`Assigned`:e.recognizedVehicleId?`${e.vehicleName??`Recognized`} (suggested)`:`Unassigned`,re=`${String(Math.round(e.score*100))}%${e.corrected?` · corrected`:``}`;function ie(){e&&(b(e.text),v(!0))}function H(){if(!e)return;let t=y.trim().toUpperCase();if(!t||t===e.text){v(!1);return}f.mutate({plateId:e.plateId,text:t},{onSettled:()=>{l.invalidateQueries({queryKey:be}),v(!1)}})}return j(p,{open:!0,onOpenChange:e=>!e&&r(),children:E(m,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Plate detail`,className:`flex h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:h-auto md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[E(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[E(`div`,{className:`min-w-0`,children:[j(`div`,{className:`truncate font-mono text-sm font-semibold tracking-wide text-foreground`,children:e.text||`Plate detail`}),j(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),j(`button`,{type:`button`,onClick:r,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:j(X,{className:`h-4 w-4`})})]}),E(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[R&&E(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[E(`button`,{type:`button`,onClick:()=>g(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${h===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[j(ee,{className:`h-3.5 w-3.5`}),` Full frame`]}),E(`button`,{type:`button`,onClick:()=>g(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${h===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[j(P,{className:`h-3.5 w-3.5`}),` Crop`]})]}),z&&C?j(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:j(B,{src:C,alt:`Full frame with detected plate`,fit:`natural`,className:`w-full`,overlay:L?j(Ce,{box:L}):void 0})}):N?E(`div`,{className:`relative aspect-[2/1] w-full overflow-hidden rounded-lg border border-border bg-background`,children:[j(B,{src:N,alt:`Detected plate`,className:`h-full w-full`}),d&&j(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:j(Y,{className:`h-3.5 w-3.5 animate-spin`})})]}):E(`div`,{className:`flex aspect-[2/1] w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[j(V,{className:`h-8 w-8 text-warning/70`}),j(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),j(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this plate could not be resolved. Safe to delete.`})]}),j(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-2`,children:E(`div`,{className:`flex items-center justify-between gap-3`,children:[j(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:`Plate text`}),_?E(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-1.5`,children:[j(x,{value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&H(),e.key===`Escape`&&v(!1)},className:`h-7 max-w-[10rem] text-right font-mono text-xs uppercase`,autoFocus:!0}),j(`button`,{type:`button`,onClick:H,disabled:f.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Save corrected text`,children:f.isPending?j(Y,{className:`h-3.5 w-3.5 animate-spin`}):j(le,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:()=>v(!1),className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel`,children:j(X,{className:`h-3.5 w-3.5`})})]}):E(`button`,{type:`button`,onClick:ie,className:`group flex min-w-0 items-center gap-1.5`,title:`Correct the OCR reading`,children:[j(`span`,{className:`truncate font-mono text-sm font-semibold tracking-wide text-foreground`,children:e.text||`—`}),j(W,{className:`h-3 w-3 shrink-0 text-foreground-subtle group-hover:text-foreground`})]})]})}),E(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[j($,{label:`Camera`,value:t}),j($,{label:`Captured`,value:ae(e.timestamp)}),j($,{label:`Confidence`,value:re}),j($,{label:`Vehicle`,value:ne}),j($,{label:`Track`,value:e.trackId,mono:!0})]})]}),E(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?E(S,{variant:`secondary`,onClick:()=>a(e.plateId),disabled:c,children:[j(F,{className:`h-3.5 w-3.5`}),` Detach`]}):E(S,{variant:`primary`,onClick:()=>i(e.plateId),disabled:c,children:[j(te,{className:`h-3.5 w-3.5`}),` Assign`]}),E(S,{variant:`secondary`,onClick:()=>s(e.plateId),disabled:c,children:[j(Z,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}T();var Te=[[`plateGallery`]];function Ee({plateIds:e,vehicles:t,onDone:n}){let r=k(),i=a(),o=C(),[s,c]=A(``),[l,u]=A(!1),[d,f]=A(null),_=e!==null&&e.length>0,b=e?.length??0;function w(){u(!1),c(``),f(null)}function T(){w(),n()}function D(t){!e||e.length===0||i.mutate({plateIds:[...e],vehicleId:t},{onSettled:()=>{r.invalidateQueries({queryKey:Te}),T()}})}function O(){!e||!s.trim()||o.mutate({name:s.trim()},{onSuccess:e=>{e?.id&&D(e.id)},onError:()=>{r.invalidateQueries({queryKey:Te}),T()}})}let M=i.isPending||o.isPending;return j(p,{open:_,onOpenChange:e=>!e&&T(),children:E(m,{children:[E(g,{children:[j(h,{children:b>1?`Assign ${String(b)} plates to vehicle`:`Assign plate to vehicle`}),j(y,{children:`Select an existing vehicle or create a new one.`})]}),j(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:t.map(e=>E(`button`,{type:`button`,onClick:()=>f(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${d===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[j(`span`,{className:`font-medium`,children:e.name}),E(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` plates`]})]},e.id))}),l?j(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:j(x,{placeholder:`New vehicle name…`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):j(`button`,{type:`button`,onClick:()=>{f(null),u(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New vehicle…`}),E(v,{children:[j(S,{variant:`secondary`,onClick:T,disabled:M,children:`Cancel`}),l?E(S,{variant:`primary`,onClick:O,disabled:M||!s.trim(),children:[M&&j(Y,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):E(S,{variant:`primary`,onClick:()=>d&&D(d),disabled:M||!d,children:[M&&j(Y,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,b>1?` ${String(b)}`:``]})]})]})})}T();var De=[[`plateGallery`]],Oe=500,ke=120;function Ae({plate:t,cameraName:n,nowMs:i,selected:a,onToggleSelect:o,onAssign:s,onOpenDetail:c}){let l=k(),u=r(),d=e(),f=()=>{l.invalidateQueries({queryKey:De})},p=()=>c(t.plateId);return E(`div`,{className:`relative flex flex-col overflow-hidden rounded-md border bg-surface ${a?`border-primary ring-1 ring-primary`:`border-border`}`,children:[E(`div`,{className:`relative aspect-[2/1] overflow-hidden bg-surface-hover`,children:[t.base64?j(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:`Plate ${t.text} from ${n}`,onClick:p,className:`h-full w-full cursor-zoom-in object-cover`}):E(`button`,{type:`button`,onClick:p,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the plate's crop media is missing. Safe to delete.`,children:[j(V,{className:`h-7 w-7 text-warning/70`}),j(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),j(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(t.plateId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":a?`Deselect`:`Select`,children:a?j(ce,{className:`h-4 w-4 text-primary`}):j(K,{className:`h-4 w-4`})}),t.corrected&&E(`span`,{className:`absolute right-0 top-0 z-10 flex items-center gap-0.5 rounded-bl-md bg-primary/80 px-1 py-0.5 text-[8px] font-semibold uppercase tracking-wide text-white`,title:`Manually corrected`,children:[j(he,{className:`h-3 w-3`}),` Fixed`]})]}),E(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[j(`p`,{className:`truncate font-mono text-xs font-bold tracking-wide text-foreground`,title:t.text,children:t.text||`—`}),j(`p`,{className:`truncate text-[10px] text-foreground-subtle`,title:n,children:n}),j(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:z(t.timestamp,i)}),t.vehicleName&&j(`p`,{className:`truncate text-[10px] font-medium text-primary`,title:t.vehicleName,children:t.vehicleName})]}),E(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[t.assigned?j(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u.mutate({plateId:t.plateId},{onSettled:f})},disabled:u.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach plate`,title:`Detach`,children:u.isPending?j(Y,{className:`h-4 w-4 animate-spin`}):j(F,{className:`h-4 w-4`})}):j(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s(t.plateId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign plate to vehicle`,title:`Assign to vehicle`,children:j(te,{className:`h-4 w-4`})}),j(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),d.mutate({plateId:t.plateId},{onSettled:f})},disabled:d.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete plate`,title:`Delete plate`,children:d.isPending?j(Y,{className:`h-4 w-4 animate-spin`}):j(Z,{className:`h-4 w-4`})})]})]})}var je=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Assigned`,value:`assigned`}];function Me(e,t){return t===`unassigned`?e.filter(e=>!e.assigned):t===`assigned`?e.filter(e=>e.assigned):e}function Ne(){let n=k(),[i,a]=A(`all`),[o,c]=A(oe),[l,u]=A(new Set),[f,p]=A(new Set),[m,h]=A(null),[g,v]=A(null),{data:y,isLoading:b}=s({limit:Oe},{refetchInterval:3e4}),{data:x=[]}=t(),{data:C}=_({}),w=r(),T=d(),M=e(),N=Date.now(),P=y??[],ee=D(()=>{let e=new Map;for(let t of C??[])e.set(t.id,t.name);return e},[C]),I=e=>ee.get(e)??`Camera #${String(e)}`,z=D(()=>R(P).map(e=>({id:e,name:I(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[P,ee]),B=D(()=>ne(se(Me(P,i),o),l),[P,i,o,l]),V=re(B,ke,D(()=>JSON.stringify([i,o.fromMs,o.toMs,[...l].sort((e,t)=>e-t)]),[i,o.fromMs,o.toMs,l])),ae=D(()=>new Map(P.map(e=>[e.plateId,e])),[P]),U=g===null?null:ae.get(g)??null,W=()=>{n.invalidateQueries({queryKey:De})},G=()=>p(new Set);function ce(e){p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let K=[...f],q=T.isPending||M.isPending,le=w.isPending||M.isPending;function ue(){K.length!==0&&T.mutate({plateIds:K},{onSettled:()=>{W(),G()}})}function J(){K.length!==0&&Promise.allSettled(K.map(e=>M.mutateAsync({plateId:e}))).then(()=>{W(),G()})}function de(e){v(null),h([e])}function fe(e){w.mutate({plateId:e},{onSettled:W}),v(null)}function pe(e){M.mutate({plateId:e},{onSettled:W}),v(null)}let me=B.length!==P.length;return E(`div`,{className:`relative space-y-3`,children:[E(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[j(`div`,{className:`flex items-center gap-1`,children:je.map(e=>j(`button`,{type:`button`,onClick:()=>a(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),j(L,{onChange:c}),j(ie,{cameras:z,selected:l,onChange:u}),!b&&j(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:me?`${String(B.length)} of ${String(P.length)} plates`:`${String(B.length)} plate${B.length===1?``:`s`}`})]}),f.size>0&&E(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[E(`span`,{className:`text-xs font-medium text-foreground`,children:[f.size,` selected`]}),E(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[E(S,{variant:`primary`,onClick:()=>h(K),disabled:q,children:[j(te,{className:`h-3.5 w-3.5`}),` Assign`]}),E(S,{variant:`secondary`,onClick:ue,disabled:q,children:[T.isPending?j(Y,{className:`h-3.5 w-3.5 animate-spin`}):j(F,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),E(S,{variant:`secondary`,onClick:J,disabled:q,children:[j(Z,{className:`h-3.5 w-3.5`}),` Delete`]}),j(S,{variant:`ghost`,onClick:G,disabled:q,children:j(X,{className:`h-3.5 w-3.5`})})]})]}),b&&E(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[j(Y,{className:`h-4 w-4 animate-spin`}),` Loading plates…`]}),!b&&B.length===0&&j(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:P.length>0?`No plates match the current filters.`:`No plates recognized yet.`}),!b&&B.length>0&&E(O,{children:[j(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))] gap-2`,children:V.pageItems.map(e=>j(Ae,{plate:e,cameraName:I(e.deviceId),nowMs:N,selected:f.has(e.plateId),onToggleSelect:ce,onAssign:e=>h([e]),onOpenDetail:v},e.plateId))}),j(H,{currentPage:V.page,totalItems:V.totalItems,pageSize:V.pageSize,onPageChange:V.setPage,itemNoun:`plates`})]}),j(we,{plate:U,cameraName:U?I(U.deviceId):``,onClose:()=>v(null),onAssign:de,onUnassign:fe,onDelete:pe,actionsPending:le}),j(Ee,{plateIds:m,vehicles:x,onDone:()=>{h(null),G()}})]})}T();var Pe=[[`plateGallery`]],Fe=2e3;function Ie(){let e=k(),t=w(e);t.current=e;let n=w(void 0);n.current||=U({delayMs:Fe,invalidate:()=>{t.current.invalidateQueries({queryKey:Pe})}}),M(()=>()=>n.current?.cancel(),[]),l(N.PipelineAnalyticsPlateGalleryChanged,()=>{n.current?.trigger()})}function Le(){return Ie(),j(fe,{icon:J,title:`Plates`,subtitle:`Manage enrolled vehicles and assign recognized license plates to them.`,children:E(`section`,{className:`space-y-3`,children:[E(`div`,{children:[j(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Vehicles`}),j(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled vehicle identities used for plate recognition. Expand a row to view or remove plate samples.`}),j(ye,{})]}),E(`div`,{className:`pt-4 border-t border-border`,children:[j(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent recognized plates`}),j(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`License plates read by the detection pipeline. Assign them to a vehicle, correct the OCR text, or delete.`}),j(Ne,{})]})]})})}export{Le as PlatesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Co as e,So as t,
|
|
1
|
+
import{Co as e,So as t,wo as n}from"./src-CwIdcVoz.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-BKrLqfAl.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(n,{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(n=>{let r=I===n.id,i=n.shape.kind===`polygon`?ne:e;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(n.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 `,n.id]}),u(`span`,{className:`text-foreground-faint capitalize`,children:n.shape.kind})]}),u(`button`,{type:`button`,onClick:()=>ae(n.id),disabled:M,"aria-label":`Delete zone ${String(n.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(t,{className:`h-3.5 w-3.5`})})]},n.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-DVfJmyYr.js";import{t as a}from"./server-B33eaAVX.js";import{t as o}from"./wifi-13IJJu3_.js";import{W as s}from"./index-CqPUI4oB.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$i as e,Kr as t,La as n,Qi as r,Ua as i,Ur as a,Xr as o,Yr as s,Za as c,Zi as l,ea as u,jn as d,na as f,ra as p,ta as m,za as h}from"./src-CS6t478y.js";import{I as g,Q as _,S as v,W as y,o as b,q as x,x as S,z as C}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as w}from"./src-lbvXy3B8.js";import{o as T,p as E}from"./player-overlays-CkvkdCY0.js";import{t as D}from"./download-Cgk9aG5o.js";import{i as O}from"./AddLocationWizard-DLLHOb0V.js";import{A as k,E as A,S as j,U as M,W as N,s as P}from"./index-C3HbZT6b.js";import{t as F}from"./AdminPage-BwmGKnRf.js";import{n as I}from"./authed-media-XfBD4Ma-.js";import{t as L}from"./format-size-CO9d3C3-.js";import{t as ee}from"./ClusterRecordingTab-D0VZTHnd.js";import{t as R}from"./AdminTabs-CKPXrh5g.js";var z=N(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),B=N(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]);_();function V(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function H(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function U(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${H(e)} · ${o}`}function W(e,t){let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/6e4);if(r<60)return`in ${String(r)}m`;let i=Math.floor(r/60);return i<24?`in ${String(i)}h`:`in ${String(Math.floor(i/24))}d`}function G(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}var K=[[`recordingExport`]],q={queued:{cls:`bg-muted text-foreground-subtle`,label:`queued`},rendering:{cls:`bg-primary/10 text-primary`,label:`rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,label:`ready`},failed:{cls:`bg-danger/10 text-danger`,label:`failed`},expired:{cls:`bg-muted text-foreground-subtle`,label:`expired`},deleted:{cls:`bg-muted text-foreground-subtle`,label:`deleted`}};function J(){let{data:e,isLoading:t}=u({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:n}=i(w.RecordingExportProgress,e=>e.exportId),{map:r}=i(w.RecordingExportCompleted,e=>e.exportId),{map:a}=i(w.RecordingExportFailed,e=>e.exportId);return{rows:y(()=>G(e??[],n,r,a),[e,n,r,a]),isLoading:t}}function Y(e){let[t,n]=x(()=>Date.now());return C(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function X(){let t=b(),i=n(),a=E().trpcClient,o=Y(6e4),{rows:s,isLoading:l}=J(),{data:u}=d({}),f=y(()=>{let e=new Map;for(let t of u??[])e.set(t.id,t.name);return e},[u]),p=g(()=>{t.invalidateQueries({queryKey:K})},[t]),m=r({onSuccess:p}),_=e({onSuccess:p}),[C,w]=x(null),T=g(async e=>{w(e.id);try{let{url:t}=await a.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await I(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),p()}finally{w(null)}},[a,p]),O=g(async e=>{await i({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&m.mutate({exportId:e.id})},[i,m]),k=g(async e=>{await i({title:`Delete this export?`,message:`Permanently removes the rendered file and its history row.`,confirmLabel:`Delete`,variant:`danger`})&&_.mutate({exportId:e.id})},[i,_]),M=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:f.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:U(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>S(`span`,{className:`text-foreground-subtle`,children:V(e.options)})},{key:`state`,header:`State`,render:e=>{let t=q[e.state];return v(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${t.cls}`,children:[t.spin&&S(j,{className:`h-2.5 w-2.5 animate-spin`}),t.label,e.state===`rendering`&&e.progressPct!==null&&v(`span`,{className:`tabular-nums`,children:[e.progressPct,`%`]})]})}},{key:`expiry`,header:`Expires`,nowrap:!0,render:e=>e.state===`deleted`?S(`span`,{className:`text-foreground-subtle`,children:`—`}):S(`span`,{className:`text-foreground-subtle tabular-nums`,children:W(e.expiresAt,o)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:L(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:e=>{let t=e.state===`ready`,n=e.state===`queued`||e.state===`rendering`,r=e.state!==`deleted`;return v(`div`,{className:`flex items-center justify-end gap-1`,children:[t&&v(`button`,{onClick:()=>{T(e)},disabled:C===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:`Download MP4`,children:[C===e.id?S(j,{className:`h-3 w-3 animate-spin`}):S(D,{className:`h-3 w-3`}),`Download`]}),n&&v(`button`,{onClick:()=>{O(e)},disabled:m.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Cancel render`,children:[S(z,{className:`h-3 w-3`}),`Cancel`]}),r&&S(`button`,{onClick:()=>{k(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete export`,children:S(P,{className:`h-3 w-3`})})]})}}],[f,o,C,m.isPending,_.isPending,T,O,k]);return l&&s.length===0?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):s.length===0?S(h,{icon:A,title:`No exports yet`,description:`Export a footage range from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`}):S(c,{columns:M,rows:s,rowKey:e=>e.id,minWidthPx:720})}_();var Z=[[`recording`]],Q=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}];function te(e){return e.totalBytes===null||e.totalBytes<=0?null:Math.min(1,Math.max(0,e.usedBytes/e.totalBytes))}function ne(){let e=b(),t=n(),[r,i]=x(`retention`),{data:a,isLoading:o}=m({},{refetchOnWindowFocus:!1}),{data:s}=d({}),u=y(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),f=g(()=>{e.invalidateQueries({queryKey:Z})},[e]),_=p({onSuccess:f}),C=l({onSuccess:f}),w=g(async e=>{await t({title:`Prune ${u.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Applies the retention policy now (reason: ${r}). Footage beyond the policy is permanently deleted.`,confirmLabel:`Prune now`,variant:`danger`})&&_.mutate({deviceId:e.deviceId,reason:r})},[t,_,r,u]),E=g(async e=>{await t({title:`Delete all footage for ${u.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${L(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${L(e.usedBytes)}`,variant:`danger`})&&C.mutate({deviceId:e.deviceId})},[t,C,u]),D=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:u.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:L(e.usedBytes)})},{key:`actions`,header:``,align:`right`,render:e=>v(`div`,{className:`flex items-center justify-end gap-1`,children:[v(`button`,{onClick:()=>{w(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Apply retention policy now`,children:[S(B,{className:`h-3 w-3`}),`Prune`]}),v(`button`,{onClick:()=>{E(e)},disabled:C.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all footage`,children:[S(P,{className:`h-3 w-3`}),`Delete`]})]})}],[u,w,E,_.isPending,C.isPending]);if(o&&!a)return v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!a)return S(h,{icon:O,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let k=a.devices.length;return v(`div`,{className:`flex flex-col gap-6`,children:[v(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[S(T,{label:`Total used`,icon:S(O,{className:`h-3 w-3`}),footer:`${String(k)} camera${k===1?``:`s`} on ${a.nodeId}`,children:L(a.totalUsedBytes)}),a.locations.map(e=>{let t=te(e),n=e.locationId??`default`;return S(T,{label:`Disk ${n}`,footer:e.availableBytes===null?`${L(e.usedBytes)} used (capacity unknown)`:`${L(e.availableBytes)} free${e.totalBytes===null?``:` of ${L(e.totalBytes)}`}`,children:t===null?S(`span`,{className:`tabular-nums`,children:L(e.usedBytes)}):v(`div`,{className:`flex items-center gap-2`,children:[S(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:S(`div`,{className:`h-full rounded ${t>.9?`bg-danger`:t>.75?`bg-amber-500`:`bg-primary`}`,style:{width:`${String(Math.round(t*100))}%`}})}),v(`span`,{className:`tabular-nums text-xs`,children:[Math.round(t*100),`%`]})]})},n)})]}),v(`section`,{className:`flex items-center gap-2 text-xs`,children:[S(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:`Prune reason`}),S(`select`,{id:`prune-reason`,value:r,onChange:e=>{let t=Q.find(t=>t.value===e.target.value);t&&i(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Q.map(e=>S(`option`,{value:e.value,children:e.label},e.value))})]}),k===0?S(h,{icon:O,title:`No recorded footage`,description:`No camera has recorded footage on this node yet.`}):S(c,{columns:D,rows:[...a.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}_();var re=[[`pipelineAnalytics`]],ie=1440*60*1e3,ae=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function oe(){let e=b(),r=n(),[i,s]=x(30),{data:l,isLoading:u}=t({},{refetchOnWindowFocus:!1}),{data:f}=d({}),p=y(()=>{let e=new Map;for(let t of f??[])e.set(t.id,t.name);return e},[f]),m=g(()=>{e.invalidateQueries({queryKey:re})},[e]),_=o({onSuccess:m}),C=a({onSuccess:m}),w=g(async()=>{await r({title:`Prune events older than ${String(i)} day${i===1?``:`s`}?`,message:`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`,confirmLabel:`Prune events`,variant:`danger`})&&_.mutate({olderThanMs:Date.now()-i*ie,reason:`retention`})},[r,_,i]),E=g(async e=>{await r({title:`Delete all events for ${p.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${L(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})&&C.mutate({deviceId:e.deviceId})},[r,C,p]),D=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:p.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`rows`,header:`Events`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:`Media`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:L(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>v(`button`,{onClick:()=>{E(e)},disabled:C.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all events for this camera`,children:[S(P,{className:`h-3 w-3`}),`Delete`]})}],[p,E,C.isPending]);return u&&!l?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):l?v(`div`,{className:`flex flex-col gap-6`,children:[v(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[S(T,{label:`Total events`,icon:S(k,{className:`h-3 w-3`}),footer:`across ${String(l.devices.length)} camera${l.devices.length===1?``:`s`}`,children:l.totalRows.toLocaleString()}),S(T,{label:`Event media on disk`,children:L(l.totalBytes)})]}),v(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[S(`span`,{className:`text-foreground-subtle`,children:`Prune events older than`}),S(`select`,{value:i,onChange:e=>s(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:ae.map(e=>S(`option`,{value:e.days,children:e.label},e.days))}),v(`button`,{onClick:()=>{w()},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,children:[_.isPending?S(j,{className:`h-3 w-3 animate-spin`}):S(B,{className:`h-3 w-3`}),`Prune now`]})]}),l.devices.length===0?S(h,{icon:k,title:`No stored events`,description:`No camera has persisted events yet.`}):S(c,{columns:D,rows:[...l.devices],rowKey:e=>e.deviceId,minWidthPx:480})]}):S(h,{icon:k,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}_();var $=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],se={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`};function ce(e){return new Date(e).toLocaleString()}function le(){let[e,t]=x(`all`),{data:n,isLoading:r}=f({},{refetchOnWindowFocus:!1}),{data:i,isLoading:a}=s({},{refetchOnWindowFocus:!1}),{data:o}=d({}),l=y(()=>{let e=new Map;for(let t of o??[])e.set(t.id,t.name);return e},[o]),u=y(()=>{let t=[...n??[],...i??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[n,i,e]),p=y(()=>[{key:`at`,header:`When`,nowrap:!0,render:e=>S(`span`,{className:`text-foreground-subtle tabular-nums`,children:ce(e.at)})},{key:`domain`,header:`Domain`,render:e=>S(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${se[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,render:e=>S(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,render:e=>S(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,render:e=>e.deviceId===null?S(`span`,{className:`text-foreground-subtle`,children:`cluster`}):S(`span`,{className:`text-foreground`,children:l.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?L(e.bytesReclaimed):`—`})}],[l]),m=r||a;return v(`div`,{className:`flex flex-col gap-4`,children:[S(`div`,{className:`flex items-center gap-1`,children:$.map(n=>S(`button`,{onClick:()=>t(n.value),className:`rounded px-2 py-1 text-xs font-medium ${e===n.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n.label},n.value))}),m&&u.length===0?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):u.length===0?S(h,{icon:M,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):S(c,{columns:p,rows:u,rowKey:e=>e.id,minWidthPx:720})]})}function ue(){return S(F,{icon:A,title:`Recordings`,subtitle:`Recording node & storage, event-store management, exported clips, and an activity log.`,children:S(R,{tabs:[{id:`recordings`,label:`Recordings`,icon:O,content:S(ee,{})},{id:`storage`,label:`Storage`,icon:O,content:S(ne,{})},{id:`events`,label:`Events`,icon:k,content:S(oe,{})},{id:`exports`,label:`Exports`,icon:A,content:S(X,{})},{id:`activity`,label:`Activity`,icon:M,content:S(le,{})}]})})}export{ue as RecordingsPage};
|
|
1
|
+
import{$i as e,Kr as t,La as n,Qa as r,Qi as i,Ua as a,Ur as o,Xr as s,Yr as c,Zi as l,ea as u,jn as d,na as f,ra as p,ta as m,za as h}from"./src-CwIdcVoz.js";import{I as g,Q as _,S as v,W as y,o as b,q as x,x as S,z as C}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as w}from"./src-awTRXPIW.js";import{o as T,p as E}from"./player-overlays-BKrLqfAl.js";import{t as D}from"./download-DSBNUTk-.js";import{i as O}from"./AddLocationWizard-BMp3_ArA.js";import{A as k,E as A,S as j,U as M,W as N,s as P}from"./index-CqPUI4oB.js";import{t as F}from"./AdminPage-BwmGKnRf.js";import{n as I}from"./authed-media-XfBD4Ma-.js";import{t as L}from"./format-size-CO9d3C3-.js";import{t as ee}from"./ClusterRecordingTab-XOXRgw3i.js";import{t as R}from"./AdminTabs-DO-Sr4Tn.js";var z=N(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),B=N(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]);_();function V(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function H(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function U(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${H(e)} · ${o}`}function W(e,t){let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/6e4);if(r<60)return`in ${String(r)}m`;let i=Math.floor(r/60);return i<24?`in ${String(i)}h`:`in ${String(Math.floor(i/24))}d`}function G(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}var K=[[`recordingExport`]],q={queued:{cls:`bg-muted text-foreground-subtle`,label:`queued`},rendering:{cls:`bg-primary/10 text-primary`,label:`rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,label:`ready`},failed:{cls:`bg-danger/10 text-danger`,label:`failed`},expired:{cls:`bg-muted text-foreground-subtle`,label:`expired`},deleted:{cls:`bg-muted text-foreground-subtle`,label:`deleted`}};function J(){let{data:e,isLoading:t}=u({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:n}=a(w.RecordingExportProgress,e=>e.exportId),{map:r}=a(w.RecordingExportCompleted,e=>e.exportId),{map:i}=a(w.RecordingExportFailed,e=>e.exportId);return{rows:y(()=>G(e??[],n,r,i),[e,n,r,i]),isLoading:t}}function Y(e){let[t,n]=x(()=>Date.now());return C(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function X(){let t=b(),a=n(),o=E().trpcClient,s=Y(6e4),{rows:c,isLoading:l}=J(),{data:u}=d({}),f=y(()=>{let e=new Map;for(let t of u??[])e.set(t.id,t.name);return e},[u]),p=g(()=>{t.invalidateQueries({queryKey:K})},[t]),m=i({onSuccess:p}),_=e({onSuccess:p}),[C,w]=x(null),T=g(async e=>{w(e.id);try{let{url:t}=await o.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await I(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),p()}finally{w(null)}},[o,p]),O=g(async e=>{await a({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&m.mutate({exportId:e.id})},[a,m]),k=g(async e=>{await a({title:`Delete this export?`,message:`Permanently removes the rendered file and its history row.`,confirmLabel:`Delete`,variant:`danger`})&&_.mutate({exportId:e.id})},[a,_]),M=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:f.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:U(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>S(`span`,{className:`text-foreground-subtle`,children:V(e.options)})},{key:`state`,header:`State`,render:e=>{let t=q[e.state];return v(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${t.cls}`,children:[t.spin&&S(j,{className:`h-2.5 w-2.5 animate-spin`}),t.label,e.state===`rendering`&&e.progressPct!==null&&v(`span`,{className:`tabular-nums`,children:[e.progressPct,`%`]})]})}},{key:`expiry`,header:`Expires`,nowrap:!0,render:e=>e.state===`deleted`?S(`span`,{className:`text-foreground-subtle`,children:`—`}):S(`span`,{className:`text-foreground-subtle tabular-nums`,children:W(e.expiresAt,s)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:L(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:e=>{let t=e.state===`ready`,n=e.state===`queued`||e.state===`rendering`,r=e.state!==`deleted`;return v(`div`,{className:`flex items-center justify-end gap-1`,children:[t&&v(`button`,{onClick:()=>{T(e)},disabled:C===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:`Download MP4`,children:[C===e.id?S(j,{className:`h-3 w-3 animate-spin`}):S(D,{className:`h-3 w-3`}),`Download`]}),n&&v(`button`,{onClick:()=>{O(e)},disabled:m.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Cancel render`,children:[S(z,{className:`h-3 w-3`}),`Cancel`]}),r&&S(`button`,{onClick:()=>{k(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete export`,children:S(P,{className:`h-3 w-3`})})]})}}],[f,s,C,m.isPending,_.isPending,T,O,k]);return l&&c.length===0?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):c.length===0?S(h,{icon:A,title:`No exports yet`,description:`Export a footage range from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`}):S(r,{columns:M,rows:c,rowKey:e=>e.id,minWidthPx:720})}_();var Z=[[`recording`]],Q=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}];function te(e){return e.totalBytes===null||e.totalBytes<=0?null:Math.min(1,Math.max(0,e.usedBytes/e.totalBytes))}function ne(){let e=b(),t=n(),[i,a]=x(`retention`),{data:o,isLoading:s}=m({},{refetchOnWindowFocus:!1}),{data:c}=d({}),u=y(()=>{let e=new Map;for(let t of c??[])e.set(t.id,t.name);return e},[c]),f=g(()=>{e.invalidateQueries({queryKey:Z})},[e]),_=p({onSuccess:f}),C=l({onSuccess:f}),w=g(async e=>{await t({title:`Prune ${u.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Applies the retention policy now (reason: ${i}). Footage beyond the policy is permanently deleted.`,confirmLabel:`Prune now`,variant:`danger`})&&_.mutate({deviceId:e.deviceId,reason:i})},[t,_,i,u]),E=g(async e=>{await t({title:`Delete all footage for ${u.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${L(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${L(e.usedBytes)}`,variant:`danger`})&&C.mutate({deviceId:e.deviceId})},[t,C,u]),D=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:u.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:L(e.usedBytes)})},{key:`actions`,header:``,align:`right`,render:e=>v(`div`,{className:`flex items-center justify-end gap-1`,children:[v(`button`,{onClick:()=>{w(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Apply retention policy now`,children:[S(B,{className:`h-3 w-3`}),`Prune`]}),v(`button`,{onClick:()=>{E(e)},disabled:C.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all footage`,children:[S(P,{className:`h-3 w-3`}),`Delete`]})]})}],[u,w,E,_.isPending,C.isPending]);if(s&&!o)return v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!o)return S(h,{icon:O,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let k=o.devices.length;return v(`div`,{className:`flex flex-col gap-6`,children:[v(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[S(T,{label:`Total used`,icon:S(O,{className:`h-3 w-3`}),footer:`${String(k)} camera${k===1?``:`s`} on ${o.nodeId}`,children:L(o.totalUsedBytes)}),o.locations.map(e=>{let t=te(e),n=e.locationId??`default`;return S(T,{label:`Disk ${n}`,footer:e.availableBytes===null?`${L(e.usedBytes)} used (capacity unknown)`:`${L(e.availableBytes)} free${e.totalBytes===null?``:` of ${L(e.totalBytes)}`}`,children:t===null?S(`span`,{className:`tabular-nums`,children:L(e.usedBytes)}):v(`div`,{className:`flex items-center gap-2`,children:[S(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:S(`div`,{className:`h-full rounded ${t>.9?`bg-danger`:t>.75?`bg-amber-500`:`bg-primary`}`,style:{width:`${String(Math.round(t*100))}%`}})}),v(`span`,{className:`tabular-nums text-xs`,children:[Math.round(t*100),`%`]})]})},n)})]}),v(`section`,{className:`flex items-center gap-2 text-xs`,children:[S(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:`Prune reason`}),S(`select`,{id:`prune-reason`,value:i,onChange:e=>{let t=Q.find(t=>t.value===e.target.value);t&&a(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Q.map(e=>S(`option`,{value:e.value,children:e.label},e.value))})]}),k===0?S(h,{icon:O,title:`No recorded footage`,description:`No camera has recorded footage on this node yet.`}):S(r,{columns:D,rows:[...o.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}_();var re=[[`pipelineAnalytics`]],ie=1440*60*1e3,ae=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function oe(){let e=b(),i=n(),[a,c]=x(30),{data:l,isLoading:u}=t({},{refetchOnWindowFocus:!1}),{data:f}=d({}),p=y(()=>{let e=new Map;for(let t of f??[])e.set(t.id,t.name);return e},[f]),m=g(()=>{e.invalidateQueries({queryKey:re})},[e]),_=s({onSuccess:m}),C=o({onSuccess:m}),w=g(async()=>{await i({title:`Prune events older than ${String(a)} day${a===1?``:`s`}?`,message:`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`,confirmLabel:`Prune events`,variant:`danger`})&&_.mutate({olderThanMs:Date.now()-a*ie,reason:`retention`})},[i,_,a]),E=g(async e=>{await i({title:`Delete all events for ${p.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${L(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})&&C.mutate({deviceId:e.deviceId})},[i,C,p]),D=y(()=>[{key:`camera`,header:`Camera`,render:e=>S(`span`,{className:`text-foreground`,children:p.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`rows`,header:`Events`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:`Media`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:L(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>v(`button`,{onClick:()=>{E(e)},disabled:C.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all events for this camera`,children:[S(P,{className:`h-3 w-3`}),`Delete`]})}],[p,E,C.isPending]);return u&&!l?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):l?v(`div`,{className:`flex flex-col gap-6`,children:[v(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[S(T,{label:`Total events`,icon:S(k,{className:`h-3 w-3`}),footer:`across ${String(l.devices.length)} camera${l.devices.length===1?``:`s`}`,children:l.totalRows.toLocaleString()}),S(T,{label:`Event media on disk`,children:L(l.totalBytes)})]}),v(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[S(`span`,{className:`text-foreground-subtle`,children:`Prune events older than`}),S(`select`,{value:a,onChange:e=>c(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:ae.map(e=>S(`option`,{value:e.days,children:e.label},e.days))}),v(`button`,{onClick:()=>{w()},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,children:[_.isPending?S(j,{className:`h-3 w-3 animate-spin`}):S(B,{className:`h-3 w-3`}),`Prune now`]})]}),l.devices.length===0?S(h,{icon:k,title:`No stored events`,description:`No camera has persisted events yet.`}):S(r,{columns:D,rows:[...l.devices],rowKey:e=>e.deviceId,minWidthPx:480})]}):S(h,{icon:k,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}_();var $=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],se={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`};function ce(e){return new Date(e).toLocaleString()}function le(){let[e,t]=x(`all`),{data:n,isLoading:i}=f({},{refetchOnWindowFocus:!1}),{data:a,isLoading:o}=c({},{refetchOnWindowFocus:!1}),{data:s}=d({}),l=y(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),u=y(()=>{let t=[...n??[],...a??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[n,a,e]),p=y(()=>[{key:`at`,header:`When`,nowrap:!0,render:e=>S(`span`,{className:`text-foreground-subtle tabular-nums`,children:ce(e.at)})},{key:`domain`,header:`Domain`,render:e=>S(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${se[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,render:e=>S(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,render:e=>S(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,render:e=>e.deviceId===null?S(`span`,{className:`text-foreground-subtle`,children:`cluster`}):S(`span`,{className:`text-foreground`,children:l.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,render:e=>S(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?L(e.bytesReclaimed):`—`})}],[l]),m=i||o;return v(`div`,{className:`flex flex-col gap-4`,children:[S(`div`,{className:`flex items-center gap-1`,children:$.map(n=>S(`button`,{onClick:()=>t(n.value),className:`rounded px-2 py-1 text-xs font-medium ${e===n.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n.label},n.value))}),m&&u.length===0?v(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[S(j,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):u.length===0?S(h,{icon:M,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):S(r,{columns:p,rows:u,rowKey:e=>e.id,minWidthPx:720})]})}function ue(){return S(F,{icon:A,title:`Recordings`,subtitle:`Recording node & storage, event-store management, exported clips, and an activity log.`,children:S(R,{tabs:[{id:`recordings`,label:`Recordings`,icon:O,content:S(ee,{})},{id:`storage`,label:`Storage`,icon:O,content:S(ne,{})},{id:`events`,label:`Events`,icon:k,content:S(oe,{})},{id:`exports`,label:`Exports`,icon:A,content:S(X,{})},{id:`activity`,label:`Activity`,icon:M,content:S(le,{})}]})})}export{ue as RecordingsPage};
|