@camstack/addon-admin-ui 1.2.369 → 1.2.370
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddonAssetIcon-rRcZQtEA.js → AddonAssetIcon-rNUHK9wc.js} +1 -1
- package/dist/assets/{AddonIntegrationBody-EbUl8tUN.js → AddonIntegrationBody-C5wKwiTM.js} +1 -1
- package/dist/assets/Addons-MDKsHDDm.js +4 -0
- package/dist/assets/{AdminTabs-wu-aryGN.js → AdminTabs-B7mqaGod.js} +1 -1
- package/dist/assets/AiProfiles-DaN2f1Go.js +3 -0
- package/dist/assets/{BrokerForm-BKrrZCZh.js → BrokerForm-DjytVdo-.js} +1 -1
- package/dist/assets/Build-CHz1FqbZ.js +40 -0
- package/dist/assets/{Calendars-Cu9XHV92.js → Calendars-B9H9vgS2.js} +1 -1
- package/dist/assets/Cluster-Dn986Tn1.js +1 -0
- package/dist/assets/ClusterStepModel-Bg7jOAJE.js +1 -0
- package/dist/assets/{CompositionEditor-IHtDmqNg.js → CompositionEditor-QsBcjtRo.js} +1 -1
- package/dist/assets/{CompositionEditorPage-DC8vTjNi.js → CompositionEditorPage-CZRgABku.js} +1 -1
- package/dist/assets/Data-CCQ5NT9z.js +1 -0
- package/dist/assets/DetectionIntelligence-C6APwggP.js +1 -0
- package/dist/assets/DeviceDetail-4Wa8zL39.js +2 -0
- package/dist/assets/{DeviceDoActionFields-CDcT9AGH.js → DeviceDoActionFields-DgRa8wUB.js} +1 -1
- package/dist/assets/{Devices-BQlncmWJ.js → Devices-BiwjNBIq.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-tOXvPyWI.js → EmbedPlayerPage-Cg8N_mi7.js} +1 -1
- package/dist/assets/Events-C8u59wdS.js +1 -0
- package/dist/assets/Identity-tue9lGgH.js +1 -0
- package/dist/assets/IntegrationDetail-DItHIF-n.js +1 -0
- package/dist/assets/Integrations-14od7JhH.js +1 -0
- package/dist/assets/Integrations-BfRNaP7l.js +1 -0
- package/dist/assets/Locations-DS0EKKOB.js +3 -0
- package/dist/assets/{Logs-CwotbBSR.js → Logs-C_MmssVj.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DWw3QpEU.js → MotionZonesSettings-CbRr_Mbo.js} +1 -1
- package/dist/assets/MyAccess-wao27sRf.js +2 -0
- package/dist/assets/Network-oQcNkgTu.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-Bb9dwuSU.js → NodeAddonsSettingsPanel-BMxvR3AQ.js} +1 -1
- package/dist/assets/Notifications-BB99xksI.js +1 -0
- package/dist/assets/{Plates-BiXyRHLs.js → Plates-YkdrGkW8.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DCTAX66L.js → PrivacyMaskSettings-B-zzCFDy.js} +1 -1
- package/dist/assets/Recordings-B1ihCXnh.js +1 -0
- package/dist/assets/{ScanNetworkModal-C4IaFGug.js → ScanNetworkModal-BtSkDnst.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CQ2pi_Hj.js → SceneMonitorEditor-_QUTCAdW.js} +1 -1
- package/dist/assets/{Scenes-BLFLAgHy.js → Scenes-Cxsst6jH.js} +1 -1
- package/dist/assets/SessionsList-K0gNSKrq.js +2 -0
- package/dist/assets/{Showroom-I56ibw6k.js → Showroom-CTGDj91m.js} +1 -1
- package/dist/assets/System-CMAwUkxP.js +1 -0
- package/dist/assets/{Terminal-5SL5NSD1.js → Terminal-PyG5NErD.js} +5 -5
- package/dist/assets/{Viewer-C9zzDTPh.js → Viewer-Dt2_oVeL.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C2fbuZJL.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DX05vs51.js} +1 -1
- package/dist/assets/{archive-Dkte8Y8a.js → archive-MsQRiIew.js} +1 -1
- package/dist/assets/{authed-media-Bi2u1rSm.js → authed-media-DmDTbsLa.js} +1 -1
- package/dist/assets/board-model-Bmts6hrg.js +1 -0
- package/dist/assets/{boxes-CG60qRZo.js → boxes-CBxcgWPC.js} +1 -1
- package/dist/assets/circle-slash-CGPkHspT.js +1 -0
- package/dist/assets/client-BBcQuaON.js +357 -0
- package/dist/assets/crop-DEIlVeIH.js +1 -0
- package/dist/assets/{debounced-invalidate-CxaRFTpC.js → debounced-invalidate-CC0VQLjV.js} +1 -1
- package/dist/assets/{device-integration-icon-JFsHsv7_.js → device-integration-icon-DbGFErfk.js} +1 -1
- package/dist/assets/device-picker-model-C9R5gyah.js +1 -0
- package/dist/assets/dist-DP9oVJm0.js +357 -0
- package/dist/assets/{dist-DflVZo7O.js → dist-DrV2uaDZ.js} +1 -1
- package/dist/assets/{face-bbox-zC_kw0CX.js → face-bbox-B9dID2jY.js} +1 -1
- package/dist/assets/format-size-DKWzYrUJ.js +1 -0
- package/dist/assets/{history-Bsb3o8Ph.js → history-Dcle7WpC.js} +1 -1
- package/dist/assets/{hostInit-D-dSFNov.js → hostInit-Cf3_Ewlc.js} +1 -1
- package/dist/assets/index-BKZRl3KT.css +2 -0
- package/dist/assets/index-BsZjL5HO.js +4 -0
- package/dist/assets/{layers-BiHKkPFk.js → layers-DSe93_v-.js} +1 -1
- package/dist/assets/location-owned-usage-CtdITciE.js +1 -0
- package/dist/assets/{mf-entry-bootstrap-0-76e50126.js → mf-entry-bootstrap-0-625c8410.js} +2 -2
- package/dist/assets/{monitor-smartphone-DCj4MFCV.js → monitor-smartphone-CiL6wFjy.js} +1 -1
- package/dist/assets/mount-C9R5gyah.js +1 -0
- package/dist/assets/notification-schedule-field-DUWbH7XG.js +1 -0
- package/dist/assets/{octagon-alert-uq_xpLNT.js → octagon-alert-DHfOXsQN.js} +1 -1
- package/dist/assets/{player-overlays-D9aoM64J.js → player-overlays-B7T46vDu.js} +1 -1
- package/dist/assets/remoteEntry-BkONRtCr.js +1 -0
- package/dist/assets/{send-BoWu8sC3.js → send-Cx-d7NnY.js} +1 -1
- package/dist/assets/{settings-2-vAZgfnrs.js → settings-2-CnRox-F8.js} +1 -1
- package/dist/assets/src-B06iwqFQ.js +67 -0
- package/dist/assets/{use-scenes-feed-B67D8SNJ.js → use-scenes-feed-BN5zl7un.js} +1 -1
- package/dist/assets/{use-stationary-objects-B5PewW7U.js → use-stationary-objects-CICValw3.js} +1 -1
- package/dist/assets/useEventInvalidation-C9R5gyah.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DyMwFYyx.js → useNodeUrlSelection-Dcp64NLR.js} +1 -1
- package/dist/assets/user-round-9bUOIzu8.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DDHU33sX.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CDvKve-V.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +247 -132
- package/package.json +1 -1
- package/dist/assets/Addons-DGr0dCVs.js +0 -4
- package/dist/assets/AiProfiles-BeoeH8Zu.js +0 -3
- package/dist/assets/Build-B6IaaCld.js +0 -40
- package/dist/assets/Cluster-Cy5X6Uvg.js +0 -1
- package/dist/assets/ClusterStepModel-naRCh9Gl.js +0 -1
- package/dist/assets/Data-DYW0abTi.js +0 -1
- package/dist/assets/DetectionIntelligence-Dql2v1Z-.js +0 -1
- package/dist/assets/DeviceDetail-DnI-UCZh.js +0 -2
- package/dist/assets/Events-BHrs4V4o.js +0 -1
- package/dist/assets/Identity-B0o5qgSj.js +0 -1
- package/dist/assets/IntegrationDetail-C5FRSBKl.js +0 -1
- package/dist/assets/Integrations-Y_7v1rC_.js +0 -1
- package/dist/assets/Integrations-kpJ44y4z.js +0 -1
- package/dist/assets/Locations-CcEjNLL3.js +0 -3
- package/dist/assets/MyAccess-FYgj8K8r.js +0 -2
- package/dist/assets/Network-CAm0gAZJ.js +0 -1
- package/dist/assets/Notifications--kHXBEqD.js +0 -1
- package/dist/assets/Recordings-DrcwnpEB.js +0 -1
- package/dist/assets/Retrain-BrINvPPp.js +0 -1
- package/dist/assets/SessionsList-Yg5gVfMg.js +0 -2
- package/dist/assets/System-BVjDuAwr.js +0 -1
- package/dist/assets/circle-slash-C3W4jvTj.js +0 -1
- package/dist/assets/client-DX0rAC3X.js +0 -357
- package/dist/assets/crop-BBN3JEL7.js +0 -1
- package/dist/assets/device-picker-model-BTxjd_Y8.js +0 -1
- package/dist/assets/dist-DK6qWoSo.js +0 -357
- package/dist/assets/format-size-DIxKXxtj.js +0 -1
- package/dist/assets/hard-drive-download-C9ll-Tud.js +0 -1
- package/dist/assets/index-BfUAV0Tt.css +0 -2
- package/dist/assets/index-D7yeH_53.js +0 -4
- package/dist/assets/location-owned-usage-DQxXKxXh.js +0 -1
- package/dist/assets/mount-BTxjd_Y8.js +0 -1
- package/dist/assets/notification-schedule-field-B3G1sjYy.js +0 -1
- package/dist/assets/remoteEntry-CKbF9NAW.js +0 -1
- package/dist/assets/src-B-IRCQFw.js +0 -67
- package/dist/assets/useEventInvalidation-BTxjd_Y8.js +0 -1
- package/dist/assets/user-round-bqX4ogd_.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,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-DhP-Lgiq.js";import{J as l,_t as u,at as d,st as f,vt as p}from"./player-overlays-D9aoM64J.js";import{$c as m,As as h,Cu as g,En as _,Eu as v,Fn as y,In as b,It as x,Jc as S,Kc as C,Kn as w,Lt as T,Mu as E,Nn as D,Qc as O,Qd as k,Qf as A,Sn as j,Tn as M,Ud as N,Vn as P,Xc as ee,Yc as te,Zc as ne,_l as re,af as F,as as ie,bf as ae,bl as oe,bn as se,ca as I,dl as ce,ff as le,fl as ue,fr as de,gl as fe,hl as pe,il as me,ll as he,lr as L,mf as R,ml as ge,oc as _e,ol as ve,pl as ye,qc as z,qu as B,sl as V,uc as be,ul as xe,us as Se,vl as Ce,vs as we,wn as Te,xn as Ee,yl as De}from"./src-B-IRCQFw.js";import{c as Oe,i as ke,l as Ae,n as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie}from"./location-owned-usage-DQxXKxXh.js";import{t as Le}from"./settings-2-vAZgfnrs.js";import{hi as H}from"./client-DX0rAC3X.js";import{D as Re}from"./index-D7yeH_53.js";import{t as ze}from"./AdminPage-BSFohA3i.js";import{n as Be}from"./authed-media-Bi2u1rSm.js";import{t as Ve}from"./AdminTabs-wu-aryGN.js";import{t as U}from"./format-size-DIxKXxtj.js";var W=p(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),G=p(`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`}]]);t();var He=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],Ue={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},We={columnKey:`at`,dir:`desc`};function Ge(e){return new Date(e).toLocaleString()}function Ke(){let[e,t]=o(`all`),{data:a,isLoading:c,isError:l}=S({},{refetchOnWindowFocus:!1}),{data:u,isLoading:d,isError:f}=we({},{refetchOnWindowFocus:!1}),{data:p}=I({isCamera:!0,projection:`slim`}),m=r(()=>{let e=new Map;for(let t of p??[])e.set(t.id,t.name);return e},[p]),h=r(()=>{let t=[...a??[],...u??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[a,u,e]),g=r(()=>{let t=[];return l&&e!==`events`&&t.push(`Recordings`),f&&e!==`recording`&&t.push(`Events`),t},[l,f,e]),_=r(()=>[{key:`at`,header:`When`,nowrap:!0,sortValue:e=>e.at,render:e=>s(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ge(e.at)})},{key:`domain`,header:`Domain`,sortValue:e=>e.domain,render:e=>s(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Ue[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,sortValue:e=>e.op,render:e=>s(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,sortValue:e=>e.reason,render:e=>s(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,sortValue:e=>e.deviceId===null?`cluster`:m.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?s(`span`,{className:`text-foreground-subtle`,children:`cluster`}):s(`span`,{className:`text-foreground`,children:m.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>s(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>s(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?U(e.bytesReclaimed):`—`})}],[m]),v=c||d;return n(`div`,{className:`flex flex-col gap-4`,children:[s(`div`,{className:`flex items-center gap-1`,children:He.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))}),v&&h.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(N,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):h.length===0?g.length>0?s(D,{icon:B,title:`Activity could not be read`,description:`The ${g.join(` and `)} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`}):s(D,{icon:A,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):n(i,{children:[g.length>0&&n(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[s(B,{className:`h-3 w-3 shrink-0`}),g.join(` and `),` did not answer — rows from`,` `,g.length===1?`that domain`:`those domains`,` are missing below.`]}),s(x,{columns:_,rows:h,rowKey:e=>e.id,minWidthPx:720,mobileMode:`scroll`,maxBodyHeight:T,defaultSort:We})]})]})}t();function qe(){let e=I({isCamera:!0,projection:`slim`}),t=r(()=>(e.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[e.data]),[i,a]=o(null),c=i??t[0]?.id??null;return!e.isLoading&&t.length===0?s(D,{icon:u,title:`No cameras`,description:`Add a camera first.`}):n(`div`,{className:`space-y-3`,children:[n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Per-camera recording & retention`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Recording mode, schedule bands and the retention policy for one camera — the same controls as the camera's own Recording tab. Retention is one policy over footage and analytics; per-camera event deletion lives on the Events tab.`})]}),n(`div`,{className:`flex items-center gap-2`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),s(`select`,{value:c??``,onChange:e=>a(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:t.map(e=>s(`option`,{value:e.id,children:e.name},e.id))})]}),c!==null&&s(P,{deviceId:c,children:s(Re,{deviceId:c,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},c)]})}t();function Je({types:e}){let t=a(),i=w(),{data:c}=V({}),l=ve(),u=r(()=>l.data??[],[l.data]),{data:d}=z({},{refetchOnWindowFocus:!1}),f=r(()=>Fe(c??[],d?.locations),[c,d?.locations]),[p,m]=o(null),[h,g]=o(null),_=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},v=oe({onSuccess:_}),y=me({onSuccess:_}),b=r(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),x=async(e,t)=>{Ae(t)&&!await i({title:`Disable "${e.displayName}"?`,message:`${Oe(t).consequence}\n\nNothing is deleted — set the location back to Read-only or Active to bring its footage back.`,confirmLabel:`Disable`,variant:`danger`})||v.mutate(Pe(e,{mode:t}))},S=async e=>{if(await i({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`}))try{await y.mutateAsync({id:e.id})}catch(t){await i({title:`Delete anyway?`,message:`${t instanceof Error?t.message:String(t)}\n\nForcing removes the record only. Anything still on that location becomes unreachable.`,confirmLabel:`Force delete`,variant:`danger`})&&y.mutate({id:e.id,force:!0})}},C=e.map(e=>u.find(t=>t.id===e)).filter(e=>e!==void 0);return n(`div`,{className:`space-y-3`,children:[C.length===0?s(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):C.map(e=>s(je,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:b.get(e.id)??[],onAdd:e=>m(e),onEdit:e=>g(e),onDelete:e=>{S(e)},ownedBytesById:f,onSetMode:(e,t)=>{x(e,t)}},e.id)),p!==null&&s(Ie,{initialType:p,onClose:()=>m(null),onCreated:()=>{_(),m(null)}}),h!==null&&s(Me,{location:h,onClose:()=>g(null),onSaved:()=>{_(),g(null)}})]})}t();var Ye=`pipeline-analytics`;function Xe(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 Ze(){let e=a(),{nodes:t}=g(),{data:i,isLoading:o}=L({addonId:Ye}),c=Xe(i),l=de({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),s(`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.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?s(N,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):s(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Ye,patch:{postProcessingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>s(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&s(N,{className:`h-4 w-4 animate-spin text-primary`})]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),s(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),s(Je,{types:[`eventMedia`]})]})]})}t();var Qe=[[`pipelineAnalytics`]],$e=1440*60*1e3;function et(e,t){return t.get(e)??`Removed camera #${String(e)}`}var tt=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function nt(){let t=a(),i=w(),[c,u]=o(30),[d,p]=o(null),{data:m,isLoading:g}=Se({},{refetchOnWindowFocus:!1}),{data:_}=I({isCamera:!0,projection:`slim`}),v=r(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),y=e(()=>{t.invalidateQueries({queryKey:Qe})},[t]),b=h({onSuccess:y}),S=ie(),C=e(async()=>{await i({title:`Prune events older than ${String(c)} day${c===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`})&&b.mutate({olderThanMs:Date.now()-c*$e,reason:`retention`})},[i,b,c]),T=e(async e=>{let t=et(e.deviceId,v);if(await i({title:`Delete all events for ${t}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${U(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})){p(null);try{let n=await S.mutateAsync({deviceId:e.deviceId});y();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){p(`0 events deleted for ${t}. Media still listed (${U(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}p(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){p(e instanceof Error?e.message:String(e))}}},[i,S,v,y]),E=r(()=>[{key:`camera`,header:`Camera`,render:e=>s(`span`,{className:`text-foreground`,children:et(e.deviceId,v)})},{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:U(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`button`,{onClick:()=>{T(e)},disabled:S.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(f,{className:`h-3 w-3`}),`Delete`]})}],[v,T,S.isPending]);return g&&!m?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(N,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):m?n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[s(l,{label:`Total events`,icon:s(R,{className:`h-3 w-3`}),footer:`across ${String(m.devices.length)} camera${m.devices.length===1?``:`s`}`,children:m.totalRows.toLocaleString()}),s(l,{label:`Event media on disk`,children:U(m.totalBytes)})]}),n(`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:c,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:tt.map(e=>s(`option`,{value:e.days,children:e.label},e.days))}),n(`button`,{onClick:()=>{C()},disabled:b.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-warning/10 hover:text-warning disabled:opacity-50`,children:[b.isPending?s(N,{className:`h-3 w-3 animate-spin`}):s(G,{className:`h-3 w-3`}),`Prune now`]})]}),m.devices.length===0?s(D,{icon:R,title:`No stored events`,description:`No camera has persisted events yet.`}):s(x,{columns:E,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480}),d===null?null:s(`p`,{className:d.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:d})]}):s(D,{icon:R,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}function rt(){return n(`div`,{className:`flex flex-col gap-8`,children:[n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Event store`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`}),s(`div`,{className:`mt-3`,children:s(nt,{})})]}),n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node & folders`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that writes event crops, and the storage location they land in.`}),s(`div`,{className:`mt-3`,children:s(Ze,{})})]})]})}function it(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 at(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function ot(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`${at(e)} · ${o}`}function st(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 ct(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})}t();var lt=[`high`,`mid`,`low`],ut=[{value:1,label:`Real time (1×)`},{value:2,label:`2×`},{value:4,label:`4×`},{value:8,label:`8×`},{value:16,label:`16×`}],dt=10080*60*1e3;function ft(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function pt({onClose:e,onCreated:t}){let i=I({isCamera:!0,projection:`slim`}),a=r(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[c,l]=o(``),[u,d]=o(`high`),[f,p]=o(ft(60)),[m,h]=o(ft(0)),[g,v]=o(1),[b,x]=o(!0),[S,C]=o(``),[w,T]=o(null),E=c===``?a[0]?.id??null:c,D=new Date(f).getTime(),O=new Date(m).getTime(),k=Number.isFinite(D)&&Number.isFinite(O)&&D<O,A=ne({onSuccess:()=>{t(),e()},onError:e=>T(e instanceof Error?e.message:String(e))});return s(se,{open:!0,onOpenChange:t=>!t&&e(),children:n(j,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[s(M,{children:n(_,{className:`flex items-center gap-1.5`,children:[s(F,{className:`h-3.5 w-3.5`}),`New export`]})}),n(Ee,{className:`space-y-3`,children:[n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),s(`select`,{value:E??``,onChange:e=>l(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:a.map(e=>s(`option`,{value:e.id,children:e.name},e.id))})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Profile`}),s(`select`,{value:u,onChange:e=>d(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:lt.map(e=>s(`option`,{value:e,children:e},e))})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`From`}),s(`input`,{type:`datetime-local`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`To`}),s(`input`,{type:`datetime-local`,value:m,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Speed`}),s(`select`,{value:g,onChange:e=>v(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:ut.map(e=>s(`option`,{value:e.value,children:e.label},e.value))})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Title (optional)`}),s(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`e.g. courier at the gate`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),n(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:b,disabled:g!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),`Include audio`,g===1?``:` (real-time only)`]}),!k&&s(`p`,{className:`text-[11px] text-danger`,children:`"From" must be before "To".`}),w&&s(`p`,{className:`text-[11px] text-danger`,children:w})]}),n(Te,{children:[s(y,{variant:`outline`,size:`sm`,onClick:e,children:`Cancel`}),s(y,{size:`sm`,onClick:()=>{if(E===null||!k)return;T(null);let e=S.trim();A.mutate({deviceId:E,profile:u,fromMs:D,toMs:O,options:{includeAudio:b,maxLifeMs:dt,deleteAfterDownload:!1,...g===1?{}:{speed:g},...e.length>0?{title:e}:{}}})},disabled:E===null||!k||A.isPending,children:A.isPending?`Queuing…`:`Create export`})]})]})})}t();var mt=[[`recordingExport`]],ht={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 gt(){let{data:e,isLoading:t}=m({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:n}=v(H.RecordingExportProgress,e=>e.exportId),{map:i}=v(H.RecordingExportCompleted,e=>e.exportId),{map:a}=v(H.RecordingExportFailed,e=>e.exportId);return{rows:r(()=>ct(e??[],n,i,a),[e,n,i,a]),isLoading:t}}function _t(e){let[t,n]=o(()=>Date.now());return c(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function vt(){let t=a(),[i,c]=o(!1),l=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},u=w(),p=d().trpcClient,m=_t(6e4),{rows:h,isLoading:g}=gt(),{data:_}=I({isCamera:!0,projection:`slim`}),v=r(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),y=e(()=>{t.invalidateQueries({queryKey:mt})},[t]),b=ee({onSuccess:y}),S=O({onSuccess:y}),[C,T]=o(null),E=e(async e=>{T(e.id);try{let{url:t}=await p.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Be(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),y()}finally{T(null)}},[p,y]),k=e(async e=>{await u({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&b.mutate({exportId:e.id})},[u,b]),A=e(async e=>{await u({title:`Delete this export?`,message:`Permanently removes the rendered file and its history row.`,confirmLabel:`Delete`,variant:`danger`})&&S.mutate({exportId:e.id})},[u,S]),j=r(()=>[{key:`camera`,header:`Camera`,render:e=>s(`span`,{className:`text-foreground`,children:v.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums`,children:ot(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>s(`span`,{className:`text-foreground-subtle`,children:it(e.options)})},{key:`state`,header:`State`,render:e=>{let t=ht[e.state];return n(`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(N,{className:`h-2.5 w-2.5 animate-spin`}),t.label,e.state===`rendering`&&e.progressPct!==null&&n(`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:st(e.expiresAt,m)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:U(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:e=>{let t=e.state===`ready`,r=e.state===`queued`||e.state===`rendering`,i=e.state!==`deleted`;return n(`div`,{className:`flex items-center justify-end gap-1`,children:[t&&n(`button`,{onClick:()=>{E(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(N,{className:`h-3 w-3 animate-spin`}):s(le,{className:`h-3 w-3`}),`Download`]}),r&&n(`button`,{onClick:()=>{k(e)},disabled:b.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(ae,{className:`h-3 w-3`}),`Cancel`]}),i&&s(`button`,{onClick:()=>{A(e)},disabled:S.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(f,{className:`h-3 w-3`})})]})}}],[v,m,C,b.isPending,S.isPending,E,k,A]);return g&&h.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(N,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):n(`div`,{className:`space-y-3`,children:[s(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>c(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[s(F,{className:`h-3.5 w-3.5`}),`New export`]})}),h.length===0?s(D,{icon:F,title:`No exports yet`,description:`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`}):s(x,{columns:j,rows:h,rowKey:e=>e.id,minWidthPx:720}),i&&s(pt,{onClose:()=>c(!1),onCreated:l})]})}var yt=`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`;t();var bt=`storage-migration`,xt=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function St(e){return[`${e.orphansReclaimed} orphan rows (${U(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${U(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${U(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function Ct(){let e=b(bt);return e===`pending`?null:e===`unknown`?s(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`Could not check whether storage cleanup is installed on this hub.`}):e===`present`?s(wt,{}):null}function wt(){let e=w(),[t,r]=o(!1),[i,a]=o(null),c=ue({},{refetchInterval:2e3}),l=c.data??null,u=l!==null&&xt.has(l.phase),d=ce(),p=xe(),m=async()=>{if(await e({title:`Run storage cleanup?`,message:t?`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`:`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`,confirmLabel:`Run cleanup`,variant:`danger`})){a(null);try{await d.mutateAsync({includeDebugMedia:t}),await c.refetch()}catch(e){a(e instanceof Error?e.message:String(e))}}},h=async()=>{if(l&&await e({title:`Cancel cleanup?`,message:`Stops after the current step. Work already done stays done.`,confirmLabel:`Cancel cleanup`,variant:`danger`}))try{await p.mutateAsync({jobId:l.jobId}),await c.refetch()}catch{}};return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Cleanup`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`}),n(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[s(`input`,{type:`checkbox`,checked:t,disabled:u,onChange:e=>{r(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),s(`span`,{children:`Also remove debug media (motion stills and track filmstrips)`})]}),n(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[n(`button`,{type:`button`,disabled:u||d.isPending,onClick:()=>{m()},className:yt,children:[(u||d.isPending)&&s(N,{className:`h-3 w-3 animate-spin`}),s(f,{className:`h-3 w-3`}),`Run cleanup`]}),u&&s(`button`,{type:`button`,onClick:()=>{h()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:`Cancel`})]}),i&&s(`p`,{className:`mt-2 text-[11px] text-danger`,children:i}),l&&n(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[n(`p`,{className:`text-xs text-foreground`,children:[`Phase: `,s(`span`,{className:`font-medium`,children:l.phase}),u&&s(N,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),l.detail&&s(`p`,{className:`text-[11px] text-foreground-subtle`,children:l.detail}),s(`p`,{className:`text-[11px] text-foreground-subtle`,children:St(l)}),l.error&&s(`p`,{className:`text-[11px] text-danger`,children:l.error})]})]})}t();var Tt=2e3;function Et(){let e=w(),t=a(),r=be(),i=_e(void 0,{refetchInterval:e=>e.state.data?.state===`running`?Tt:!1}),o=i.data,l=o?.state===`running`,u=l||r.isPending;c(()=>{o?.state!==`done`||o.finishedAtMs===null||(t.invalidateQueries({queryKey:[[`recording`]]}),t.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[o?.state,o?.finishedAtMs,t]);let d=async()=>{await e({title:`Reconcile storage from disk?`,message:`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`,confirmLabel:`Reconcile`,variant:`warning`})&&(await r.mutateAsync(),await i.refetch())},f=l?o.total>0?`Reconciling ${String(o.completed)}/${String(o.total)}…`:`Reconciling…`:r.isPending?`Reconciling…`:`Reconcile from disk`;return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Disk reconcile`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Deletes database rows whose files are gone. Enrolled identities stay.`}),n(`div`,{className:`mt-3 flex flex-col gap-2`,children:[n(`button`,{type:`button`,onClick:()=>void d(),disabled:u,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[u?s(N,{className:`h-3.5 w-3.5 animate-spin`}):s(k,{className:`h-3.5 w-3.5`}),f]}),o?.state===`done`?n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Last run: `,String(o.completed),` camera(s) — dropped `,String(o.tracks),` tracks,`,` `,String(o.events),` events, `,String(o.mediaDropped),` media`,o.failed.length>0?`, ${String(o.failed.length)} failed (${o.failed.join(`, `)})`:``,`.`]}):null,o?.state===`error`&&o.error!==null?n(`p`,{className:`text-[11px] text-destructive`,children:[`Reconcile failed: `,o.error]}):null]})]})}var K=1e3,q=60*K,J=60*q;function Y(e){return e.toLocaleString(`en-US`)}function Dt(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=J){let t=Math.floor(e/J),n=Math.round(e%J/q);return`${t.toString()}h ${n.toString()}m`}if(e>=q){let t=Math.floor(e/q),n=Math.round(e%q/K);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/K)).toString()}s`}function Ot(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${Y(e.filesMoved)} files`:`${Y(e.filesMoved)} / ${Y(e.filesTotal)} files`,r=e.filesTotal===null||e.filesTotal===0?null:Math.min(1,e.filesMoved/e.filesTotal),i=t>0&&e.filesMoved>0,a=i?`${U(e.bytesMoved/t*K)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${Dt(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${U(e.bytesMoved)} moved`,rate:a,eta:s}}function kt(e){let t=Ot(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}t();var At=`storage-migration`,X=[{id:`recordings`,label:`Recordings`,locationType:`recordings`},{id:`recordingsLow`,label:`Low-res recordings`,locationType:`recordingsLow`},{id:`eventMedia`,label:`Event media`,locationType:`eventMedia`}],jt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Mt(){let e=b(At);return e===`pending`?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(N,{className:`h-4 w-4 animate-spin`}),`Checking whether storage migration is installed…`]}):e===`unknown`?s(D,{icon:B,title:`Couldn't check whether storage migration is installed`,description:`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`}):e===`absent`?s(D,{icon:W,title:`Storage migration not installed`,description:`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`}):s(Nt,{})}function Nt(){let e=w(),{data:t}=V({}),[i,a]=o({}),[c,l]=o({}),[u,d]=o(null),[f,p]=o(null),m=r(()=>{let e=new Map;for(let n of t??[]){let t=e.get(n.type);t?t.push(n):e.set(n.type,[n])}return e},[t]),h=r(()=>{let e=new Map;for(let n of t??[]){if(n.enabled===!1)continue;let t=e.get(n.type);t?t.push(n.id):e.set(n.type,[n.id])}let n=new Map;for(let[t,r]of e)r.length===1&&n.set(t,r[0]);return n},[t]),g=De({},{refetchInterval:2e3}),_=g.data??null,v=_!==null&&jt.has(_.phase),y=r(()=>{let e={};for(let t of X){let n=i[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[i]),b=r(()=>{let e={};for(let t of X){if(!i[t.id])continue;let n=c[t.id]??h.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[i,c,h]),x=r(()=>({destinations:y??{},...b?{sources:b}:{}}),[y,b]),S=fe(x,{enabled:!1,retry:!1}),C=Ce(),T=he(),D=async()=>{if(!y)return;p(null);let e=await S.refetch();if(e.error){p(e.error instanceof Error?e.error.message:String(e.error));return}d(e.data??null)},O=async()=>{if(y&&await e({title:`Start storage migration?`,message:`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`,confirmLabel:`Start migration`,variant:`danger`})){p(null);try{await C.mutateAsync(x),d(null),await g.refetch()}catch(e){p(e instanceof Error?e.message:String(e))}}},k=async()=>{if(_&&await e({title:`Cancel migration?`,message:`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`,confirmLabel:`Cancel migration`,variant:`danger`}))try{await T.mutateAsync({jobId:_.jobId}),await g.refetch()}catch{}};return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[s(W,{className:`h-3.5 w-3.5`}),`Storage migration`]}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`}),s(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:X.map(e=>{let t=m.get(e.locationType)??[],r=h.get(e.locationType)??``;return n(`div`,{className:`space-y-2`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.label}),n(`div`,{className:`space-y-1`,children:[n(`label`,{htmlFor:`migration-from-${e.id}`,className:`text-[10px] text-foreground-subtle`,children:[e.label,` from`]}),s(`select`,{id:`migration-from-${e.id}`,value:c[e.id]??r,onChange:t=>{let n=t.target.value;l(t=>({...t,[e.id]:n}))},disabled:v,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:t.map(e=>n(`option`,{value:e.id,children:[e.displayName,e.enabled===!1?` (read-only)`:``]},e.id))})]}),n(`div`,{className:`space-y-1`,children:[n(`label`,{htmlFor:`migration-dest-${e.id}`,className:`text-[10px] text-foreground-subtle`,children:[e.label,` to`]}),n(`select`,{id:`migration-dest-${e.id}`,value:i[e.id]??``,onChange:t=>{let n=t.target.value;a(t=>({...t,[e.id]:n}))},disabled:v,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[s(`option`,{value:``,children:`— skip —`}),t.map(e=>s(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},e.id)})}),f&&s(`p`,{className:`mt-2 text-[11px] text-danger`,children:f}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[n(`button`,{type:`button`,onClick:()=>{D()},disabled:!y||S.isFetching||v,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[S.isFetching&&s(N,{className:`h-3 w-3 animate-spin`}),`Plan`]}),n(`button`,{type:`button`,onClick:()=>{O()},disabled:!y||C.isPending||v,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[C.isPending&&s(N,{className:`h-3 w-3 animate-spin`}),`Start migration`]})]}),u&&s(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:u.moves.length===0?s(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:`Nothing to move — selected destinations match the current defaults.`}):u.moves.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]},`${e.storageClass}-${e.toLocationId}`))}),_&&n(`div`,{className:`mt-4 border-t border-border pt-3`,children:[n(`div`,{className:`flex items-center justify-between`,children:[s(`h4`,{className:`text-xs font-semibold text-foreground`,children:`Migration status`}),v&&n(`button`,{type:`button`,onClick:()=>{k()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[s(E,{className:`h-3 w-3`}),`Cancel`]})]}),n(`p`,{className:`mt-1 text-xs text-foreground`,children:[`Phase: `,s(`span`,{className:`font-medium`,children:_.phase}),v&&s(N,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),_.error&&s(`p`,{className:`mt-1 text-[11px] text-danger`,children:_.error}),_.pausedParticipants.length>0&&n(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[`Paused: `,_.pausedParticipants.join(`, `)]}),s(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:_.moves.map(e=>s(Pt,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),s(Ft,{})]}),s(It,{running:v}),s(Rt,{})]})}function Pt({move:e}){let t=e.progress===null?null:Ot(e.progress);return n(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[n(`div`,{className:`flex items-center justify-between`,children:[n(`span`,{className:`text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]}),n(`span`,{className:`text-foreground-subtle`,children:[e.state??`pending`,e.error?` (${e.error})`:``]})]}),e.progress!==null&&n(`div`,{className:`mt-1 space-y-1`,children:[t!==null&&t.fraction!==null&&s(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:s(`div`,{className:`h-full bg-primary`,style:{width:`${(t.fraction*100).toFixed(1)}%`}})}),s(`p`,{className:`text-[10px] text-foreground-subtle`,children:kt(e.progress)})]})]})}function Ft(){let{data:e}=ge({});return!e||e.length===0?null:n(`div`,{className:`mt-4 border-t border-border pt-3`,children:[s(`h4`,{className:`text-xs font-semibold text-foreground`,children:`Migration history`}),s(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:e.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[s(`span`,{className:`font-medium text-foreground`,children:e.phase}),` · `,Object.entries(e.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(e.startedAt).toLocaleString()]},e.jobId))})]})}function It({running:e}){let t=w(),r=re({},{staleTime:1/0,refetchOnWindowFocus:!1}),i=ye(),[a,c]=o(null),l=r.data??[];if(l.length===0)return null;let u=async e=>{if(await t({title:`Drain remaining ${e.storageClass}?`,message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:`Drain remaining`,variant:`danger`})){c(null);try{await i.mutateAsync({classes:[e.storageClass]}),await r.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}};return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`div`,{className:`flex items-start justify-between gap-2`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Left on the old location`}),n(`div`,{className:`flex shrink-0 items-center gap-2`,children:[s(`span`,{className:`text-[10px] text-foreground-subtle`,children:r.dataUpdatedAt>0?`Measured ${new Date(r.dataUpdatedAt).toLocaleTimeString()}`:`Measured — never`}),s(`button`,{type:`button`,onClick:()=>{r.refetch()},disabled:r.isFetching,className:`rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:r.isFetching?`Counting…`:`Refresh`})]})]}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`}),s(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`}),a&&s(`p`,{className:`mt-2 text-[11px] text-danger`,children:a}),s(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:l.map(t=>n(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[n(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId,s(`span`,{className:`ml-2 text-foreground-subtle`,children:Lt(t)})]}),s(`button`,{type:`button`,onClick:()=>{u(t)},disabled:e||i.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:`Drain remaining`})]},`${t.storageClass}-${t.fromLocationId}`))})]})}function Lt(e){if(e.items===null)return`amount unknown — the archive could not be read`;let t=e.items.toLocaleString(`en-US`);return e.bytes===null?`${t} rows`:`${t} segments · ${U(e.bytes)}`}function Rt(){let{data:e}=pe({},{refetchInterval:2e3}),t=(e??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return t.length===0?null:n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Movers running outside a migration`}),s(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[n(`div`,{className:`text-foreground`,children:[e.lane,`: `,e.job.fromLocationId,` → `,e.job.toLocationId]}),s(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:kt({filesMoved:e.job.filesMoved,filesTotal:e.job.filesTotal,bytesMoved:e.job.bytesMoved,startedAt:e.job.startedAt,observedAt:e.observedAt})})]},e.job.jobId))})]})}function zt(){return n(`div`,{className:`flex flex-col gap-4`,children:[s(Ct,{}),s(Et,{}),n(`section`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Move storage`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`}),s(`div`,{className:`mt-3`,children:s(Mt,{})})]})]})}t();var Bt=`recorder`;function Vt(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function Ht(){let e=a(),{nodes:t}=g(),{data:i,isLoading:o}=L({addonId:Bt}),c=Vt(i,`recordingNodeId`,`hub`),l=de({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?s(N,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):s(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Bt,patch:{recordingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>s(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&s(N,{className:`h-4 w-4 animate-spin text-primary`})]}),c!==`hub`&&n(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,s(`span`,{className:`font-medium`,children:c}),`. If the auto-derived host doesn't work, set the recorder's`,s(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[s(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),s(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),s(Je,{types:[`recordings`,`recordingsLow`]})]})]})}function Z(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Ut(e,t){let n=Z(e);return n.length===0?`default root`:n.map(e=>t.get(e)??e).join(` + `)}function Wt(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:Ut(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Z(e).includes(n));return i===void 0?null:{label:Ut(i,t),exact:!1}}t();var Gt=[[`recording`]],Kt=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}],qt={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Q={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Jt(e){return e==null?`—`:new Date(e).toLocaleString()}function Yt(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):`default root`:e.root}function Xt(){let t=a(),i=w(),[c,u]=o(`retention`),{data:d,isLoading:p}=z({},{refetchOnWindowFocus:!1}),{data:m}=I({isCamera:!0,projection:`slim`}),{data:h}=V({}),g=r(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),_=r(()=>{let e=new Map;for(let t of h??[])e.set(t.id,t.displayName);return e},[h]),v=r(()=>{let e=h??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[h]),y=r(()=>d?.locations??[],[d?.locations]),b=r(()=>Wt(y,_,v),[y,_,v]),S=r(()=>ke(y),[y]),T=e(()=>{t.invalidateQueries({queryKey:Gt})},[t]),E=te({onSuccess:T}),O=C({onSuccess:T}),A=e(async e=>{await i({title:`Prune ${g.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Applies the retention policy now (reason: ${c}). Footage beyond the policy is permanently deleted.`,confirmLabel:`Prune now`,variant:`danger`})&&E.mutate({deviceId:e.deviceId,reason:c})},[i,E,c,g]),j=e(async e=>{await i({title:`Delete all footage for ${g.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${U(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${U(e.usedBytes)}`,variant:`danger`})&&O.mutate({deviceId:e.deviceId})},[i,O,g]),M=r(()=>[{key:`camera`,header:`Camera`,render:e=>s(`span`,{className:`text-foreground`,children:g.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:`Disk`,nowrap:!0,render:()=>b===null?s(`span`,{className:`text-foreground-subtle`,children:`—`}):n(`span`,{className:b.exact?`text-foreground`:`text-foreground-subtle`,title:b.exact?`The only recordings volume on this node — this camera can only be here.`:`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`,children:[b.label,!b.exact&&s(`span`,{className:`ml-1 text-foreground-subtle`,children:`(default)`})]})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums`,children:U(e.usedBytes)})},{key:`oldest`,header:`Oldest footage`,align:`right`,nowrap:!0,render:e=>s(`span`,{className:`tabular-nums text-foreground-subtle`,title:`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`,children:Jt(e.oldestMs)})},{key:`actions`,header:``,align:`right`,render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[n(`button`,{onClick:()=>{A(e)},disabled:E.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(G,{className:`h-3 w-3`}),`Prune`]}),n(`button`,{onClick:()=>{j(e)},disabled:O.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(f,{className:`h-3 w-3`}),`Delete`]})]})}],[g,b,A,j,E.isPending,O.isPending]);if(p&&!d)return n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[s(N,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!d)return s(D,{icon:k,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let P=d.devices.length;return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[s(l,{label:`Total used`,icon:s(k,{className:`h-3 w-3`}),footer:`${String(P)} camera${P===1?``:`s`} on ${d.nodeId}`,children:U(d.totalUsedBytes)}),S!==null&&S.severity!==null&&s(l,{label:`Free on recordings volumes`,icon:s(k,{className:`h-3 w-3`}),footer:`across ${String(S.knownVolumes)} volume${S.knownVolumes===1?``:`s`} of ${U(S.totalBytes)}`+(S.unknownVolumes>0?` · ${String(S.unknownVolumes)} did not report capacity`:``),children:s(`span`,{className:`tabular-nums ${Q[S.severity]}`,children:U(S.freeBytes)})}),y.map(e=>{let t=Ne(e),r=e.locationId??e.root??`default`;return s(l,{label:`Disk: ${Yt(e,_)}`,footer:t===null?`${U(e.usedBytes)} of recordings · volume capacity unknown`:`${U(t.freeBytes)} free of ${U(t.totalBytes)} · ${U(e.usedBytes)} recordings (${$(t.recordingsFraction)})`,children:t===null?s(`span`,{className:`tabular-nums`,children:U(e.usedBytes)}):n(`div`,{className:`flex items-center gap-2`,title:`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`,children:[s(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:s(`div`,{className:`h-full rounded ${qt[t.severity]}`,style:{width:$(t.fraction)}})}),s(`span`,{className:`tabular-nums text-xs ${Q[t.severity]}`,children:$(t.fraction)})]})},r)})]}),n(`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:c,onChange:e=>{let t=Kt.find(t=>t.value===e.target.value);t&&u(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Kt.map(e=>s(`option`,{value:e.value,children:e.label},e.value))})]}),P===0?s(D,{icon:k,title:d.devicesRead===`unavailable`?`Per-camera usage unavailable`:`No recorded footage`,description:d.devicesRead===`unavailable`?`This recording node has no footage ledger, so it refused to answer the per-camera table rather than report what it happens to hold in memory. The disk totals above are unaffected.`:`No camera has recorded footage on this node yet.`}):s(x,{columns:M,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Zt(){return n(`div`,{className:`flex flex-col gap-8`,children:[n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Footage on disk`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`}),s(`div`,{className:`mt-3`,children:s(Xt,{})})]}),n(`div`,{children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Recording node & folders`}),s(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records and serves playback, and the storage locations footage is written to.`}),s(`div`,{className:`mt-3`,children:s(Ht,{})})]})]})}function Qt(){return s(ze,{icon:F,title:`Recordings`,subtitle:`Recorded footage and the durable event store — what each occupies, where it is written, and the operations that move or reconcile both.`,children:s(Ve,{tabs:[{id:`storage`,label:`Recordings`,icon:k,content:s(Zt,{})},{id:`events`,label:`Events`,icon:R,content:s(rt,{})},{id:`cameras`,label:`Cameras`,icon:u,content:s(qe,{})},{id:`exports`,label:`Export`,icon:F,content:s(vt,{})},{id:`activity`,label:`Activity`,icon:A,content:s(Ke,{})},{id:`management`,label:`Management`,icon:Le,content:s(zt,{})}]})})}export{Qt as RecordingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,U as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as d,_t as f,at as p,ft as m,st as h,vt as g}from"./player-overlays-D9aoM64J.js";import{$d as _,$t as v,At as y,Au as b,Cn as x,Cs as S,Ds as C,En as w,Fn as T,Fs as E,Gt as D,Gu as O,Is as k,It as A,Jt as j,Kt as M,Ms as N,Mu as P,N as F,Ns as I,Os as L,Pn as R,Rs as z,Sn as ee,Ss as B,Tn as V,Ts as te,Ud as H,Ut as U,Wf as W,Xd as G,Xs as ne,Yd as K,Yt as re,af as ie,bn as ae,bs as oe,ca as se,dd as ce,ds as le,du as ue,er as q,fc as de,ff as fe,fs as pe,fu as me,hs as he,is as J,jd as Y,js as ge,kf as _e,ks as ve,ku as ye,ls as be,ms as xe,mu as X,nd as Se,ns as Ce,os as we,pu as Te,qt as Ee,rs as De,sn as Oe,ss as ke,tc as Ae,tf as je,ts as Me,wf as Ne,wn as Pe,ws as Fe,xs as Ie,yn as Le,ys as Re,zs as ze}from"./src-B-IRCQFw.js";import{t as Be}from"./layers-BiHKkPFk.js";import"./mount-BTxjd_Y8.js";import{$ as Ve,ot as He}from"./index-D7yeH_53.js";import{t as Ue}from"./AdminPage-BSFohA3i.js";import{t as We}from"./authed-media-Bi2u1rSm.js";import{t as Ge}from"./format-size-DIxKXxtj.js";var Ke=g(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),qe=g(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Je=g(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ye=g(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Xe=g(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Ze=g(`list-video`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M10 12H3`,key:`1ulcyk`}],[`path`,{d:`M10 19H3`,key:`108z41`}],[`path`,{d:`M15 12.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997a1 1 0 0 1-1.517-.86z`,key:`ms4nik`}]]),Qe=g(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),$e=g(`package-plus`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`M16 17h6`,key:`1ook5g`}],[`path`,{d:`M19 14v6`,key:`1ckrd5`}],[`path`,{d:`M21 10.535V8a2 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.729l7 4a2 2 0 0 0 2 .001l1.675-.955`,key:`28k6lz`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),et=g(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),tt=g(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]);n();function nt({frameId:e,onAdded:t}){let n=Me(),[i,a]=c(null),[o,s]=c(null),u=async()=>{if(i===null)return;let r=await n.mutateAsync({collectionId:i,frameIds:[e]});s(r.added>0?`Added.`:r.alreadyMember>0?`Already in that collection.`:`That frame or collection no longer exists.`),await t()};return r(Ee,{children:[r(re,{className:`mt-1 flex items-center gap-1 text-foreground-muted hover:text-foreground`,"aria-label":`Add this frame to a collection`,children:[l(Ye,{className:`h-3 w-3`}),`collection`]}),r(j,{className:`w-72 space-y-2 p-3`,children:[l(Le,{value:i,onChange:a}),r(`div`,{className:`flex items-center justify-between gap-2`,children:[l(`span`,{className:`text-[11px] text-foreground-subtle`,children:o}),l(T,{size:`sm`,disabled:i===null||n.isPending,onClick:()=>void u(),children:`Add`})]})]})]})}function rt(e){let t=e.capturedAt??e.copiedAt;return new Date(t).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function it({frames:e,isLoading:t,activeFrameId:n,deviceNames:i,onOpen:a,onRemove:o}){return e.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:t?`Reading the collection…`:`This collection is empty. Add frames with "Send frame to training" on a camera’s recording timeline, or "Add to collection" on a track’s copied frame.`}):l(`ul`,{className:`flex flex-wrap gap-2`,children:e.map(e=>l(`li`,{children:r(`div`,{className:`rounded-md border px-2 py-1.5 text-[11px] flex items-start gap-1.5 ${e.frameId===n?`border-primary bg-surface-hover`:`border-border`}`,children:[r(`button`,{type:`button`,className:`flex items-center gap-1.5 text-left`,onClick:()=>{a(e.frameId)},children:[e.origin===`recording`?l(ie,{className:`h-3 w-3 text-info`,"aria-label":`From the recording`}):l(Ze,{className:`h-3 w-3 text-success`,"aria-label":`From a track`}),l(`span`,{className:`font-medium text-foreground`,children:i.get(e.deviceId)??`Camera ${String(e.deviceId)}`}),l(`span`,{className:`text-foreground-subtle`,children:rt(e)}),e.complete&&l(q,{variant:`success`,children:`complete`})]}),l(`button`,{type:`button`,"aria-label":`Remove from this collection`,title:e.origin===`recording`?`Remove from this collection. If no other collection holds it, the frame and its boxes leave the dataset.`:`Remove from this collection. The frame stays in the dataset with its track.`,className:`text-foreground-muted hover:text-danger`,onClick:()=>{o(e)},children:l(P,{className:`h-3 w-3`})})]})},e.frameId))})}n();function at({collections:e,isLoading:t,selectedId:n,onSelect:i,onCreate:a,onRename:s,onDelete:u}){let[d,f]=c(``),[p,m]=c(null),[g,_]=c(null),v=async()=>{let e=await a(d);m(e),e===null&&f(``)},b=async()=>{if(g===null)return;let e=await s(g.id,g.name);m(e),e===null&&_(null)};return r(`div`,{className:`divide-y divide-border`,children:[r(`div`,{className:`p-2 space-y-1.5`,children:[r(`div`,{className:`flex items-center gap-1.5`,children:[l(X,{className:`flex-1`,"aria-label":`New collection name`,placeholder:`New collection`,value:d,onChange:e=>{f(e.target.value)}}),l(T,{size:`sm`,disabled:d.trim()===``,onClick:()=>void v(),children:`Create`})]}),p!==null&&l(`p`,{className:`text-[11px] text-danger`,children:p})]}),e.length===0?l(`p`,{className:`p-3 text-[11px] text-foreground-subtle`,children:t?`Reading the collections…`:`No collection yet. Create one here, or use "Send frame to training" on a camera’s recording timeline.`}):l(`ul`,{className:`divide-y divide-border`,children:e.map(e=>l(`li`,{className:`px-3 py-2 flex items-center gap-2 text-xs ${e.id===n?`bg-surface-hover`:``}`,children:g?.id===e.id?r(o,{children:[l(X,{className:`flex-1`,"aria-label":`Collection name`,value:g.name,onChange:t=>{_({id:e.id,name:t.target.value})}}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Save the name`,onClick:()=>void b(),children:l(_e,{className:`h-3 w-3`})}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Cancel renaming`,onClick:()=>{_(null)},children:l(P,{className:`h-3 w-3`})})]}):r(o,{children:[l(`button`,{type:`button`,className:`flex-1 min-w-0 text-left truncate text-foreground`,onClick:()=>{i(e)},children:e.name}),l(q,{children:e.frameCount}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Rename ${e.name}`,onClick:()=>{_({id:e.id,name:e.name})},children:l(Y,{className:`h-3 w-3`})}),l(y,{label:`Delete`,icon:h,triggerVariant:`ghost`,size:`sm`,title:`Delete "${e.name}"?`,description:`Frames taken from the recording that are in no other collection are deleted with their boxes. Frames copied from tracks stay in the dataset.`,confirmLabel:`Delete`,confirmVariant:`danger`,action:()=>u(e.id)})]})},e.id))})]})}function ot(e,t){let n=0,r=0,i=0;for(let t of e)n+=t.frameCount,r+=t.annotationCount,t.frameCount>0&&t.annotationCount>0&&(i+=1);let a=0;for(let e of t)a+=e.frameCount;return{tracks:e.length,frames:n,annotations:r,ready:i,collectionFrames:a}}function st(e,t){return t===null?e:e.filter(e=>e.deviceId===t)}function ct(e,t){let n=new Map;for(let t of e)n.set(t.deviceId,(n.get(t.deviceId)??0)+1);return[...n.entries()].map(([e,n])=>({deviceId:e,name:t.get(e)??`Camera ${String(e)}`,trackCount:n})).sort((e,t)=>e.name.localeCompare(t.name))}function lt({counts:e,cameras:t,selectedDeviceId:n,onSelectDevice:i}){return r(`div`,{className:`space-y-3`,"data-testid":`retrain-corpus-bar`,children:[e!==null&&r(`div`,{className:`grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4`,children:[l(F,{icon:Be,label:`Staging tracks`,value:e.tracks,subtext:`${String(e.ready)} ready to complete`}),l(F,{icon:G,label:`Copied frames`,value:e.frames,subtext:`in the dataset from tracks`}),l(F,{icon:Ne,label:`Subjects annotated`,value:e.annotations,subtext:`across staging copies`}),l(F,{icon:f,label:`Collection frames`,value:e.collectionFrames,subtext:`recording stills + track copies`})]}),t.length>1&&r(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":`Filter by camera`,children:[l(ut,{on:n===null,label:`All cameras`,onClick:()=>{i(null)}}),t.map(e=>l(ut,{on:n===e.deviceId,label:`${e.name} (${String(e.trackCount)})`,onClick:()=>{i(e.deviceId)}},e.deviceId))]})]})}function ut({on:e,label:t,onClick:n}){return l(T,{type:`button`,size:`sm`,variant:e?`secondary`:`ghost`,"aria-pressed":e,className:`h-auto rounded-full px-2 py-0.5 text-[11px] ${e?`border border-primary text-primary`:`border border-border text-foreground-muted`}`,onClick:n,children:t})}n();var dt={"empty-name":`Give the version a name.`,"duplicate-name":`A version with that name already exists.`,"no-frames":`This selection holds no annotated or complete frame — nothing to freeze.`},ft=e=>`${String(Math.round(e*100))}%`;function pt(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function mt({on:e,label:t,onClick:n}){return l(`button`,{type:`button`,"aria-pressed":e,className:`rounded-full border px-2 py-0.5 text-[11px] ${e?`border-primary text-primary`:`border-border text-foreground-muted hover:text-foreground`}`,onClick:n,children:t})}function ht({stats:e,deviceNames:t}){let n=e=>t.get(e)??`Camera ${String(e)}`;return r(`div`,{className:`space-y-2`,"data-testid":`retrain-dataset-stats`,children:[r(`div`,{className:`flex flex-wrap gap-1.5 text-[11px]`,children:[r(q,{children:[e.frames,` frames`]}),r(q,{variant:e.completeness>=.9?`success`:`warning`,children:[ft(e.completeness),` complete (`,e.completeFrames,`)`]}),r(q,{children:[e.subjects,` boxes`]}),r(q,{variant:`danger`,children:[e.modelErrors,` model errors`]}),r(q,{variant:`info`,children:[e.hardNegatives,` hard negatives`]}),e.cameras.map(e=>r(q,{children:[n(e.deviceId),`: `,e.frames,` ·`,` `,ft(e.frames>0?e.completeFrames/e.frames:0),` complete`]},e.deviceId))]}),l(A,{columns:[{key:`class`,header:`Class`,render:e=>e.macroClass,sortValue:e=>e.macroClass},{key:`camera`,header:`Camera`,render:e=>n(e.deviceId),sortValue:e=>n(e.deviceId)},{key:`light`,header:`Light`,render:e=>e.lighting,sortValue:e=>e.lighting},{key:`subjects`,header:`Boxes`,align:`right`,render:e=>e.subjects,sortValue:e=>e.subjects},{key:`frames`,header:`Frames`,align:`right`,render:e=>e.frames,sortValue:e=>e.frames}],rows:e.cells,rowKey:e=>`${e.macroClass}-${String(e.deviceId)}-${e.lighting}`,emptyMessage:`No box in this selection.`,minWidthPx:360})]})}function gt({id:e}){let[t,n]=c(!1),i=z({id:e},{enabled:t});return t?i.data===void 0?l(H,{className:`h-3 w-3 animate-spin`}):i.data.matches?l(q,{variant:`success`,children:`unchanged`}):r(q,{variant:`warning`,children:[`changed`,i.data.missingFrames>0?` · ${String(i.data.missingFrames)} missing`:``]}):r(T,{variant:`ghost`,size:`sm`,onClick:()=>n(!0),children:[l(ce,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:`Verify`})]})}function _t({deviceNames:e,collections:t,pickedFrameIds:n,onClearPicked:i}){let a=s(),o=p(),[u,f]=c([]),[m,g]=c([]),[_,b]=c(!1),[x,w]=c(!1),[E,D]=c(`frames`),[O,k]=c(``),[j,M]=c(null),[N,P]=c(null),F={...u.length>0?{deviceIds:[...u]}:{},...m.length>0?{collectionIds:[...m]}:{},..._&&n.length>0?{frameIds:[...n]}:{}},I=C({selection:F,completeOnly:x}),L=S({}),z=J(),ee=ke(),B=async()=>{M(null);let e=await z.mutateAsync({name:O,selection:F,layout:E,completeOnly:x});if(e.kind===`refused`){M(dt[e.reason]??e.reason);return}k(``),M(`Version "${e.version.name}" frozen: ${String(e.version.frameCount)} frames.`),await L.refetch()},V=async e=>{P(e.id);try{let{url:t}=await o.trpcClient.pipelineAnalytics.getRetrainExportUrl.query({datasetVersionId:e.id,layout:e.layout});await We(d(t),`camstack-dataset-${e.name.replace(/[^a-z0-9_-]+/gi,`-`)}.tar`)}catch(e){M(`Download failed: ${e instanceof Error?e.message:String(e)}`)}finally{P(null)}},te=[...e.keys()].toSorted((e,t)=>e-t);return r(`div`,{className:`space-y-3`,children:[r(`div`,{className:`rounded-md border border-border bg-surface p-3 space-y-2`,children:[l(`h2`,{className:`text-xs font-semibold text-foreground`,children:`New dataset version`}),r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[l(`span`,{className:`text-[11px] text-foreground-subtle w-20`,children:`Cameras`}),u.length===0&&l(q,{children:`all`}),te.map(t=>l(mt,{on:u.includes(t),label:e.get(t)??String(t),onClick:()=>f(e=>pt(e,t))},t))]}),r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[l(`span`,{className:`text-[11px] text-foreground-subtle w-20`,children:`Collections`}),m.length===0&&l(q,{children:`any frame`}),t.map(e=>l(mt,{on:m.includes(e.id),label:`${e.name} · ${String(e.frameCount)}`,onClick:()=>g(t=>pt(t,e.id))},e.id))]}),r(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px]`,children:[r(`label`,{className:`flex items-center gap-1.5`,children:[l(v,{"aria-label":`Only the frames picked in the workbench`,checked:_,disabled:n.length===0,onChange:e=>b(e.target.checked)}),`Only the `,n.length,` picked frame`,n.length===1?``:`s`]}),n.length>0&&l(T,{variant:`ghost`,size:`sm`,onClick:i,children:`Clear picks`}),r(`label`,{className:`flex items-center gap-1.5`,children:[l(v,{"aria-label":`Only complete frames`,checked:x,onChange:e=>w(e.target.checked)}),`Only frames marked "all subjects boxed"`]}),l(R,{className:`w-36`,"aria-label":`Layout`,value:E,options:[{value:`frames`,label:`Frames (detector)`},{value:`crops`,label:`Frames + crops (classifier)`}],onChange:e=>D(e.target.value===`crops`?`crops`:`frames`)})]}),I.data===void 0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:I.isError?`The selection could not be counted.`:`Counting the selection…`}):l(ht,{stats:I.data,deviceNames:e}),r(`div`,{className:`flex items-center gap-2`,children:[l(X,{className:`flex-1`,"aria-label":`Version name`,placeholder:`Version name (e.g. night person v1)`,value:O,onChange:e=>k(e.target.value)}),l(T,{size:`sm`,disabled:O.trim()===``||z.isPending||(I.data?.frames??0)===0,onClick:()=>void B(),children:`Freeze version`})]}),j!==null&&l(`p`,{className:`text-[11px] text-foreground`,children:j})]}),r(`div`,{className:`rounded-md border border-border bg-surface p-3 space-y-2`,children:[l(`h2`,{className:`text-xs font-semibold text-foreground`,children:`Versions`}),l(A,{columns:[{key:`name`,header:`Version`,render:e=>e.name,sortValue:e=>e.name},{key:`created`,header:`Frozen`,render:e=>new Date(e.createdAt).toLocaleString(),sortValue:e=>e.createdAt},{key:`frames`,header:`Frames`,align:`right`,render:e=>e.frameCount,sortValue:e=>e.frameCount},{key:`boxes`,header:`Boxes`,align:`right`,render:e=>e.stats.subjects,sortValue:e=>e.stats.subjects},{key:`complete`,header:`Complete`,align:`right`,render:e=>ft(e.stats.completeness),sortValue:e=>e.stats.completeness},{key:`layout`,header:`Layout`,render:e=>e.layout},{key:`hash`,header:`Hash`,render:e=>l(`code`,{title:e.annotationHash,children:e.annotationHash.slice(0,10)})},{key:`actions`,header:``,render:e=>r(`div`,{className:`flex items-center gap-1 justify-end`,children:[l(gt,{id:e.id}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Download ${e.name}`,disabled:N!==null,onClick:()=>void V(e),children:N===e.id?l(H,{className:`h-3 w-3 animate-spin`}):l(fe,{className:`h-3 w-3`})}),l(y,{label:`Delete`,icon:h,triggerVariant:`ghost`,size:`sm`,title:`Delete version "${e.name}"?`,description:`The version's record goes. Its frames stay in the dataset.`,confirmLabel:`Delete`,action:async()=>{await ee.mutateAsync({id:e.id}),await a.invalidateQueries()}})]})}],rows:L.data??[],rowKey:e=>e.id,emptyMessage:L.isLoading?`Reading the versions…`:`No version frozen yet.`,minWidthPx:640})]})]})}n();function vt(){let e=xe({}),t=B({}),[n,i]=c([]),a=le(n.length>0?{collectionIds:[...n]}:{}),o=he({}),[s,u]=c(null),[f,p]=c(null),m=async(e,t,n)=>{u(e),p(null);try{await We(d(t),n)}catch(e){p(e instanceof Error?e.message:String(e))}finally{u(null)}},h=e.data,g=h!==void 0&&h.trackCount===0;return r(`div`,{className:`rounded-md border border-border bg-surface p-3 space-y-2`,children:[r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[l(`h2`,{className:`text-xs font-semibold text-foreground flex-1`,children:`Export dataset`}),r(T,{variant:`secondary`,size:`sm`,disabled:a.data===void 0||s!==null,onClick:()=>{a.data!==void 0&&m(`annotated`,a.data.url,`camstack-retrain-export.tar`)},children:[s===`annotated`?l(H,{className:`h-3 w-3 animate-spin`}):l(fe,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:`Annotated dataset`})]}),r(T,{variant:`secondary`,size:`sm`,disabled:o.data===void 0||g||s!==null,onClick:()=>{o.data!==void 0&&m(`marked`,o.data.url,`camstack-training-export.tar`)},children:[s===`marked`?l(H,{className:`h-3 w-3 animate-spin`}):l(fe,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:`Marked media`})]})]}),(t.data??[]).length>0&&r(`div`,{className:`flex items-center gap-1.5 flex-wrap text-[11px]`,children:[l(`span`,{className:`text-foreground-subtle`,children:`Annotated dataset from:`}),n.length===0&&l(q,{children:`every collection and track`}),(t.data??[]).map(e=>{let t=n.includes(e.id);return r(`button`,{type:`button`,"aria-pressed":t,className:`rounded-full border px-2 py-0.5 ${t?`border-primary text-primary`:`border-border text-foreground-muted hover:text-foreground`}`,onClick:()=>{i(n=>t?n.filter(t=>t!==e.id):[...n,e.id])},children:[e.name,` · `,e.frameCount]},e.id)})]}),l(`p`,{className:`text-[11px] text-foreground-subtle`,children:e.isError?`The export summary could not be read, so the size of the marked set is unknown — not zero.`:h===void 0?`Measuring the marked set…`:g?`No track is marked for training: the marked-media archive would be empty. The annotated dataset can still hold frames from tracks already completed — this count does not measure those.`:`${String(h.trackCount)} marked track${h.trackCount===1?``:`s`} · ${String(h.fileCount)} file${h.fileCount===1?``:`s`} · ${Ge(h.byteCount)}${h.truncated?` · more marked tracks exist than one pass carries`:``}`}),(a.isError||o.isError)&&l(`p`,{className:`text-[11px] text-danger`,children:`An export data plane is not available on the node that answered — no archive can be streamed from here.`}),f!==null&&r(`p`,{className:`text-[11px] text-danger`,children:[`Download failed: `,f]})]})}function yt(e){return e>=1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.round(e/1e3)} KB`}function bt({candidates:e,copies:t,activeFrameId:n,refusals:i,isSelecting:a,onSelectCandidate:o,onOpenCopy:s,onRemoveCopy:c,renderCopyActions:u}){let d=new Set(t.map(e=>e.sourceMediaId)),f=e.filter(e=>!d.has(e.mediaId));return r(`div`,{className:`space-y-3`,children:[r(`section`,{children:[r(`h3`,{className:`text-xs font-semibold text-foreground mb-1.5`,children:[`In the dataset (`,t.length,`)`]}),t.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No frame copied yet. Selecting a frame copies it into retrain storage immediately — the dataset stops depending on the track's own media from that moment.`}):l(`ul`,{className:`flex flex-wrap gap-2`,children:t.map(e=>l(`li`,{children:r(`div`,{className:`rounded-md border px-2 py-1.5 text-[11px] ${e.frameId===n?`border-primary bg-surface-hover`:`border-border`}`,children:[r(`button`,{type:`button`,className:`flex items-center gap-1.5 text-left`,onClick:()=>{s(e.frameId)},children:[l(_e,{className:`h-3 w-3 text-success`}),l(`span`,{className:`font-medium text-foreground`,children:e.sourceKind}),r(`span`,{className:`text-foreground-subtle`,children:[e.width,`×`,e.height,` · `,yt(e.sizeBytes)]}),e.complete&&l(q,{variant:`success`,children:`complete`})]}),r(`button`,{type:`button`,"aria-label":`Remove this frame from the dataset`,className:`mt-1 flex items-center gap-1 text-foreground-muted hover:text-danger`,onClick:()=>{c(e.frameId)},children:[l(h,{className:`h-3 w-3`}),`remove`]}),u?.(e)]})},e.frameId))})]}),r(`section`,{children:[r(`h3`,{className:`text-xs font-semibold text-foreground mb-1.5`,children:[`Available frames (`,f.length,`)`]}),f.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:e.length===0?`This track has no whole, unannotated frame left — its media aged out before it was marked. Anything already copied above is still usable.`:`Every available frame is already in the dataset.`}):l(`ul`,{className:`flex flex-wrap gap-2`,children:f.map(e=>{let t=i.get(e.mediaId);return r(`li`,{children:[r(T,{variant:`secondary`,size:`sm`,disabled:a||t!==void 0,onClick:()=>{o(e.mediaId)},children:[a?l(H,{className:`h-3 w-3 animate-spin`}):l(t===void 0?Je:m,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:e.kind}),l(`span`,{className:`ml-1 text-foreground-subtle`,children:yt(e.sizeBytes)})]}),t!==void 0&&l(q,{variant:`danger`,className:`ml-1`,children:t})]},e.mediaId)})})]})]})}function xt(e){return e.frameCount===0?`untouched`:e.annotationCount===0?`started`:`ready`}var St={untouched:{icon:qe,label:`to do`,variant:`default`},started:{icon:Ke,label:`frames only`,variant:`info`},ready:{icon:Ne,label:`annotated`,variant:`success`}};function Ct(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function wt({tracks:e,isLoading:t,selectedTrackId:n,deviceNames:i,onSelect:a}){return t?r(`div`,{className:`flex items-center gap-2 p-4 text-xs text-foreground-subtle`,children:[l(H,{className:`h-3.5 w-3.5 animate-spin`}),`Loading staging tracks…`]}):e.length===0?l(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`Nothing in staging. Mark a track for training from the viewer or the Library feed and it appears here.`}):l(`ul`,{className:`divide-y divide-border`,children:e.map(e=>{let t=St[xt(e)],o=t.icon;return l(`li`,{children:r(`button`,{type:`button`,onClick:()=>{a(e)},className:`w-full text-left px-3 py-2 flex items-start gap-2 hover:bg-surface-hover ${e.trackId===n?`bg-surface-hover`:``}`,children:[l(o,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),r(`span`,{className:`min-w-0 flex-1`,children:[r(`span`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`text-xs font-medium text-foreground truncate`,children:e.label??e.className}),l(q,{variant:t.variant,children:t.label})]}),r(`span`,{className:`block text-[11px] text-foreground-subtle truncate`,children:[i.get(e.deviceId)??`Camera ${String(e.deviceId)}`,` ·`,` `,Ct(e.lastSeen)]}),r(`span`,{className:`block text-[11px] text-foreground-muted`,children:[e.frameCount,` frame`,e.frameCount===1?``:`s`,` ·`,` `,e.annotationCount,` subject`,e.annotationCount===1?``:`s`]})]})]})},e.trackId)})})}function Z(e){return{deviceId:e.deviceId,...e.trackId===void 0?{}:{trackId:e.trackId},frameId:e.frameId}}var Tt=`object-detection`;function Et(e,t){for(let n of e){if(n.addonId===t)return n;let e=n.children===void 0?void 0:Et(n.children,t);if(e!==void 0)return e}}function Dt(e,t){for(let n of e.slots){let e=n.addons.find(e=>e.id===t);if(e!==void 0)return e}}function Ot(e){let{status:t,nodeDevices:n,schema:r,resolvedSteps:i}=e;if(t===void 0)return{kind:`unknown`,gap:`pending`};if(t.detection===null)return{kind:`unknown`,gap:t.degraded.some(e=>e.stage===`detection`)?`placement-unreadable`:`detection-off`};let a=t.detection;if(n===void 0||r===void 0||i===void 0)return{kind:`unknown`,gap:`pending`};if(!n.reachable)return{kind:`unknown`,gap:`node-unreachable`};let o=n.devices.find(e=>e.backend===a.engine.backend&&e.device===a.engine.device);if(o===void 0)return{kind:`unknown`,gap:`device-unknown`};let s=Dt(r,Tt);if(s===void 0)return{kind:`unknown`,gap:`step-unknown`};let c=Oe({catalog:s,device:o,override:Et(i,Tt)?.modelId,base:o.steps?.[Tt]?.modelId});return c===void 0?{kind:`unknown`,gap:`no-model`}:{kind:`resolved`,nodeId:a.nodeId,modelId:c,minScore:s.models.find(e=>e.id===c)?.defaultConfidence??s.defaultConfidence}}function kt(e,t){let n=Math.max(0,Math.min(e.x+e.w,t.x+t.w)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.h,t.y+t.h)-Math.max(e.y,t.y)),r=e.w*e.h+t.w*t.h-n;return r>0?n/r:0}function At(e,t){let n=e.nextKey;return{boxes:t.map(e=>{let t=`b${String(n)}`;return n+=1,{...e,key:t}}),nextKey:n}}function jt(e){return{bbox:e.bbox,macroClass:e.macroClass,...e.label===void 0?{}:{label:e.label},...e.subLabel===void 0?{}:{subLabel:e.subLabel},kind:e.kind,source:e.source,...e.assistModelId===void 0?{}:{assistModelId:e.assistModelId},...e.assistScore===void 0?{}:{assistScore:e.assistScore},draft:!1}}function Mt(e){return e.map(e=>({bbox:e.bbox,macroClass:e.macroClass,...e.label===void 0?{}:{label:e.label},...e.subLabel===void 0?{}:{subLabel:e.subLabel},kind:`subject`,source:`pipeline`,...e.modelId===void 0?{}:{assistModelId:e.modelId},...e.score===void 0?{}:{assistScore:e.score},draft:!0,note:e.basis===`subject-box`?`The box the pipeline recorded on this very frame.`:`The pipeline's track position ${String(Math.round(e.deltaMs))} ms from this frame.`}))}var Nt={boxes:[],selectedKey:null,nextKey:0};function Pt(e,t){let n=At(Nt,e.map(jt));return Ft({boxes:n.boxes,selectedKey:null,nextKey:n.nextKey},Mt(t)).state}function Ft(e,t){let n=[],r=0;for(let i of t){if([...e.boxes,...n].some(e=>kt(e.bbox,i.bbox)>=.8)){r+=1;continue}n.push({...i,draft:!0})}let i=At(e,n);return{state:{...e,boxes:[...e.boxes,...i.boxes],nextKey:i.nextKey},skipped:r}}function It(e,t,n){let r=At(e,[{bbox:t,macroClass:n,kind:`subject`,source:`operator`,draft:!1}]),i=r.boxes[0];return i===void 0?e:{boxes:[...e.boxes,i],selectedKey:i.key,nextKey:r.nextKey}}function Lt(e,t,n){return{...e,boxes:e.boxes.map(e=>e.key===t?n(e):e)}}function Rt(e,t,n){return Lt(e,t,e=>({...e,...n,draft:!1}))}function zt(e,t){return Lt(e,t,e=>({...e,draft:!1}))}function Bt(e){return{...e,boxes:e.boxes.map(e=>e.draft?{...e,draft:!1}:e)}}function Vt(e,t){return Lt(e,t,e=>({...e,kind:e.kind===`model_error`?`subject`:`model_error`,draft:!1}))}function Ht(e,t){return{...e,boxes:e.boxes.filter(e=>e.key!==t),selectedKey:e.selectedKey===t?null:e.selectedKey}}function Ut(e,t){return{...e,selectedKey:t}}function Wt(e,t){return{...e,boxes:e.boxes.map(e=>{let n=t.get(e.key);return n===void 0?e:{...e,flag:n}})}}function Gt(e,t){return new Map(e.map(e=>[e.ref,{verdict:e.verdict,reason:e.reason,by:t,...e.suggestedClass===void 0?{}:{suggestedClass:e.suggestedClass}}]))}function Kt(e){return e.boxes.filter(e=>e.draft).length}function qt(e){let t=e?.trim();return t===void 0||t===``?void 0:t}function Jt(e){return e.boxes.filter(e=>!e.draft).map(e=>{let t=qt(e.label),n=qt(e.subLabel);return{bbox:e.bbox,macroClass:e.macroClass,...t===void 0?{}:{label:t},...n===void 0?{}:{subLabel:n},kind:e.kind,source:e.source,...e.assistModelId===void 0?{}:{assistModelId:e.assistModelId},...e.assistScore===void 0?{}:{assistScore:e.assistScore}}})}var Yt=[`person`,`vehicle`,`animal`,`package`,`face`,`plate`],Xt=new Set(Yt),Zt={operator:`drawn`,pipeline:`pipeline`,assist:`detector`,llm:`AI vision`};function Qt(e){let t=e?.trim().toLowerCase();return t===void 0||t===``?null:Xt.has(t)?`"${t}" is a macro class, not a label — person / postman / Marco are three different tiers`:null}function $t(e){if(e.source===`operator`)return null;let t=[Zt[e.source]];return e.assistModelId!==void 0&&t.push(e.assistModelId),e.assistScore!==void 0&&t.push(e.assistScore.toFixed(2)),t.join(` · `)}function en({boxes:e,selectedKey:t,onSelect:n,onChange:i,onAccept:a,onToggleModelError:o,onDelete:s}){return e.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle p-3`,children:[`No subject on this frame yet. Drag on the image to draw one, or ask for a proposal. Annotate`,` `,l(`strong`,{children:`every`}),` subject — a frame with one box and three unlabelled people teaches the model that two thirds of the people in it are background.`]}):l(`ul`,{className:`divide-y divide-border`,children:e.map(e=>{let c=e.key===t,u=Qt(e.label),d=Qt(e.subLabel),f=$t(e);return r(`li`,{"data-testid":`retrain-row-${e.key}`,className:`p-2.5 space-y-1.5 ${c?`bg-surface-hover`:``}`,onFocus:()=>{n(e.key)},onClick:()=>{n(e.key)},children:[r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[l(R,{className:`w-28`,"aria-label":`Class`,value:e.macroClass,options:Yt.map(e=>({value:e,label:e})),onChange:t=>{let n=Yt.find(e=>e===t.target.value);n!==void 0&&i(e.key,{macroClass:n})}}),e.draft&&l(q,{variant:`warning`,children:`draft`}),e.kind===`model_error`&&l(q,{variant:`danger`,children:`model error`}),f!==null&&l(q,{variant:`info`,children:f}),(e.note!==void 0||e.flag!==void 0)&&r(ue,{children:[l(Te,{children:l(K,{className:`h-3.5 w-3.5 ${e.flag!==void 0&&e.flag.verdict!==`confirmed`?`text-warning`:`text-foreground-subtle`}`,"aria-label":`Why this box is here`})}),r(me,{className:`whitespace-normal w-64 text-left`,children:[e.note!==void 0&&l(`p`,{children:e.note}),e.flag!==void 0&&r(`p`,{children:[e.flag.by,`: `,e.flag.verdict,e.flag.suggestedClass===void 0?``:` (suggests ${e.flag.suggestedClass})`,` `,`— `,e.flag.reason]})]})]}),l(`span`,{className:`flex-1`}),e.draft&&l(T,{variant:`secondary`,size:`sm`,"aria-label":`Accept this proposal`,onClick:()=>{a(e.key)},children:l(_e,{className:`h-3 w-3`})}),l(T,{variant:`ghost`,size:`sm`,"aria-label":e.kind===`model_error`?`This is a real subject`:`Mark as model error`,onClick:()=>{o(e.key)},children:l(W,{className:`h-3 w-3`})}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Delete this subject`,onClick:()=>{s(e.key)},children:l(h,{className:`h-3 w-3`})})]}),r(`div`,{className:`flex items-center gap-2`,children:[l(X,{className:`flex-1`,placeholder:`label (postman, van, cat…)`,value:e.label??``,onChange:t=>{i(e.key,{label:t.target.value})}}),l(X,{className:`flex-1`,placeholder:`sub-label (a name, a plate…)`,value:e.subLabel??``,onChange:t=>{i(e.key,{subLabel:t.target.value})}})]}),u!==null&&l(`p`,{className:`text-[11px] text-danger`,children:u}),d!==null&&l(`p`,{className:`text-[11px] text-danger`,children:d})]},e.key)})})}function tn(e){return e.filter(e=>!e.draft).every(e=>Qt(e.label)===null&&Qt(e.subLabel)===null&&Xt.has(e.macroClass))}var nn=.25;function rn(e,t){if(e===void 0)return[];let n=e.selectedEngine.format,r=e.slots.flatMap(e=>e.addons).find(e=>e.id===Tt);if(r===void 0)return[];let i=r.models.filter(e=>e.legacy!==!0&&e.provider===void 0).flatMap(e=>{let t=e.formats[n];return t===void 0?[]:[{modelId:e.id,name:e.name,sizeMB:t.sizeMB??0}]}),a=i.find(e=>e.modelId===t);return i.filter(e=>e.modelId!==t&&(a===void 0||e.sizeMB>a.sizeMB)).toSorted((e,t)=>t.sizeMB-e.sizeMB)}n();var an=[{value:`teacher`,label:`Bigger detector`},{value:`llm`,label:`AI vision`},{value:`both`,label:`Both`}],on=[`person`,`vehicle`,`animal`,`package`],sn=[`person`,`vehicle`,`animal`,`package`,`face`,`plate`],cn={"unknown-frame":`The frame is no longer in the dataset.`,"unreadable-frame":`The frame copy could not be read.`,"unknown-profile":`That AI profile no longer exists.`,"profile-disabled":`That AI profile is disabled.`,"no-vision":`That AI profile cannot read images.`,"cloud-not-confirmed":`The frame was not sent: sending it outside the house needs your confirmation.`,"llm-error":`The AI model call failed.`,"malformed-answer":`The AI answered in a shape that cannot be trusted, so nothing was drawn.`};function ln({frame:e,history:n,detector:i,schema:o,setNotice:s}){let u=oe({},{retry:!1}),d=L(),f=ve(),[p,m]=c(`teacher`),h=a(()=>rn(o,i.kind===`resolved`?i.modelId:void 0),[o,i]),[g,_]=c(null),v=h.find(e=>e.modelId===g)??h[0],[y,b]=c(nn),[S,C]=c(null),E=(u.data??[]).find(e=>e.id===S)??u.data?.[0],[D,O]=c(on),[k,A]=c(!1),[j,M]=c(!1),N=t(n.editor);N.current=n.editor;let P=p!==`llm`,F=p!==`teacher`,I=i.kind===`resolved`&&v!==void 0,z=E!==void 0&&D.length>0,B=(!P||I)&&(!F||z),te=async()=>{if(i.kind!==`resolved`||v===void 0)return``;let t=await d.mutateAsync({...Z(e),subject:{kind:`objects`,modelId:v.modelId,minScore:y},nodeId:i.nodeId});if(t.kind===`refused`)return`${v.name} refused: ${t.reason}${t.detail===void 0?``:` — ${t.detail}`}.`;let r=Ft(N.current,t.proposals.map(e=>({bbox:e.bbox,macroClass:e.macroClass,...e.label===void 0?{}:{label:e.label},kind:e.kind,source:`assist`,...e.assistModelId===void 0?{}:{assistModelId:e.assistModelId},...e.assistScore===void 0?{}:{assistScore:e.assistScore},draft:!0,note:`Proposed by the larger detector ${t.modelId} on ${i.nodeId}.`})));N.current=r.state,n.setEditor(r.state);let a=t.proposals.length-r.skipped;return`${v.name}: ${String(a)} new draft${a===1?``:`s`}${r.skipped>0?`, ${String(r.skipped)} already on the frame`:``}.`},U=async t=>{if(E===void 0)return``;let r=N.current,i=await f.mutateAsync({...Z(e),profileId:E.id,classes:[...D],boxes:r.boxes.slice(0,50).map(e=>({ref:e.key,bbox:e.bbox,macroClass:e.macroClass,...e.label!==void 0&&e.label!==``?{label:e.label}:{}})),allowCloud:t});if(i.kind===`refused`)return`${cn[i.reason]??i.reason}${i.detail===void 0?``:` (${i.detail})`}`;let a=i.proposals.map(e=>({bbox:e.bbox,macroClass:e.macroClass,...e.label===void 0?{}:{label:e.label},kind:`subject`,source:`llm`,...e.assistModelId===void 0?{}:{assistModelId:e.assistModelId},...e.assistScore===void 0?{}:{assistScore:e.assistScore},draft:!0,note:`${i.model}: ${e.reason}`})),o=Gt(i.reviews,i.model),s=Ft(N.current,a);n.setEditor(e=>Wt(Ft(e,a).state,o));let c=i.proposals.length-s.skipped,l=i.reviews.filter(e=>e.verdict!==`confirmed`).length;return`${E.name}: ${String(c)} new draft${c===1?``:`s`}, ${String(l)} box${l===1?``:`es`} questioned${i.rejected>0?`, ${String(i.rejected)} unusable item${i.rejected===1?``:`s`} dropped`:``}.`},W=async e=>{A(!1),M(!0),s(null);try{let t=[];P&&t.push(await te()),F&&t.push(await U(e)),s(`${t.filter(e=>e!==``).join(` `)} Drafts are not saved until you accept or correct them.`)}catch(e){s(`The assist failed: ${e instanceof Error?e.message:String(e)}`)}finally{M(!1)}};return r(`div`,{className:`px-3 py-2 border-b border-border space-y-2 text-[11px]`,"data-testid":`retrain-assist`,children:[r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[l(`span`,{className:`font-semibold text-foreground`,children:`Assist`}),l(R,{className:`w-36`,"aria-label":`Assist engine`,value:p,options:an.map(e=>({value:e.value,label:e.label})),onChange:e=>{let t=an.find(t=>t.value===e.target.value);t!==void 0&&m(t.value)}}),l(`span`,{className:`flex-1`}),r(T,{size:`sm`,variant:`secondary`,disabled:!B||j,onClick:()=>{if(F&&E?.leavesHouse===!0){A(!0);return}W(!1)},children:[j?l(H,{className:`h-3 w-3 animate-spin`}):l(tt,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:`Run`})]})]}),P&&(h.length===0||i.kind!==`resolved`?l(`p`,{className:`text-foreground-subtle`,children:i.kind===`resolved`?`The detection node’s catalog has no detector larger than this camera’s for its format.`:`The camera’s detection node is not known, so no larger detector can be run there.`}):r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[l(R,{className:`flex-1 min-w-40`,"aria-label":`Larger detector`,value:v?.modelId??``,options:h.map(e=>({value:e.modelId,label:`${e.name} (${String(Math.round(e.sizeMB))} MB)`})),onChange:e=>{_(e.target.value)}}),l(X,{className:`w-20`,"aria-label":`Minimum score`,type:`number`,min:.05,max:.95,step:.05,value:y,onChange:e=>{let t=Number.parseFloat(e.target.value);Number.isFinite(t)&&b(Math.min(.95,Math.max(.05,t)))}}),r(`span`,{className:`text-foreground-subtle`,children:[`on `,i.nodeId]})]})),F&&((u.data??[]).length===0?l(`p`,{className:`text-foreground-subtle`,children:u.isError?`The AI profiles could not be read.`:`No enabled AI profile can read images. Add one under AI settings.`}):r(`div`,{className:`space-y-1.5`,children:[l(R,{"aria-label":`AI profile`,value:E?.id??``,options:(u.data??[]).map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.leavesHouse?` · cloud`:` · local`}`})),onChange:e=>{C(e.target.value)}}),E?.leavesHouse===!0&&l(`p`,{className:`text-warning`,children:`This profile sends the frame outside your home, to a cloud service. Each run asks first.`}),r(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[l(`span`,{className:`text-foreground-subtle`,children:`Look for:`}),sn.map(e=>{let t=D.includes(e);return l(`button`,{type:`button`,"aria-pressed":t,className:`rounded-full border px-2 py-0.5 ${t?`border-primary text-primary`:`border-border text-foreground-muted`}`,onClick:()=>{O(n=>t?n.filter(t=>t!==e):[...n,e])},children:e},e)})]})]})),l(ae,{open:k,onOpenChange:A,children:r(ee,{children:[r(V,{children:[l(w,{children:`Send this frame outside your home?`}),l(x,{children:`The frame from ${e.origin===`recording`?`the recording`:`this track`} will be sent to ${E?.name??`the AI profile`} (${E?.kind??`cloud`}, model ${E?.model??``}), a service outside your network, to be analysed. Only this frame, for this run.`})]}),r(Pe,{children:[l(T,{variant:`ghost`,size:`sm`,onClick:()=>{A(!1)},children:`Cancel`}),l(T,{size:`sm`,onClick:()=>void W(!0),children:`Send this frame`})]})]})})]})}function un(e,t,n,r){if(!(e>0)||!(t>0)||!(n>0)||!(r>0))return null;let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{left:(e-a)/2,top:(t-o)/2,width:a,height:o}}function dn(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}}var fn=.01;function pn(e){return e.w>=.01&&e.h>=.01}function mn(e,t){let n=-1,r=1/0;return e.forEach((e,i)=>{if(!(t.x>=e.x&&t.x<=e.x+e.w&&t.y>=e.y&&t.y<=e.y+e.h))return;let a=e.w*e.h;a<r&&(n=i,r=a)}),n}var hn=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`];function gn(e,t,n){return{x:Math.min(Math.max(0,e.x+t),Math.max(0,1-e.w)),y:Math.min(Math.max(0,e.y+n),Math.max(0,1-e.h)),w:e.w,h:e.h}}function _n(e,t,n,r){if(n){let e=Math.min(Math.max(0,r),t-fn);return{start:e,size:t-e}}return{start:e,size:Math.max(Math.min(1,r),e+fn)-e}}function vn(e,t,n){let r=t.includes(`w`)||t.includes(`e`)?_n(e.x,e.x+e.w,t.includes(`w`),n.x):{start:e.x,size:e.w},i=t.includes(`n`)||t.includes(`s`)?_n(e.y,e.y+e.h,t.includes(`n`),n.y):{start:e.y,size:e.h};return{x:r.start,y:i.start,w:r.size,h:i.size}}function yn(e,t){return{x:t.includes(`w`)?e.x:t.includes(`e`)?e.x+e.w:e.x+e.w/2,y:t.includes(`n`)?e.y:t.includes(`s`)?e.y+e.h:e.y+e.h/2}}function bn(e,t,n){let r=(e,t,n)=>Math.abs(e-t)<=n,i=r(t.x,e.x,n.x),a=r(t.x,e.x+e.w,n.x),o=r(t.y,e.y,n.y),s=r(t.y,e.y+e.h,n.y),c=t.x>=e.x-n.x&&t.x<=e.x+e.w+n.x,l=t.y>=e.y-n.y&&t.y<=e.y+e.h+n.y;return!c||!l?null:o&&i?`nw`:o&&a?`ne`:s&&i?`sw`:s&&a?`se`:o?`n`:s?`s`:i?`w`:a?`e`:t.x>=e.x&&t.x<=e.x+e.w&&t.y>=e.y&&t.y<=e.y+e.h?`body`:null}var xn={x:0,y:0,w:1,h:1},Sn=1.5;function Q(e,t,n){return e<t?t:e>n?n:e}function Cn(e){return 1/e.w}function $(e,t,n,r){return{x:Q(r.x+(e-n.left)/n.width*r.w,0,1),y:Q(r.y+(t-n.top)/n.height*r.h,0,1)}}function wn(e,t,n){return{x:t.left+(e.x-n.x)/n.w*t.width,y:t.top+(e.y-n.y)/n.h*t.height}}function Tn(e,t,n){let r=wn(e,t,n);return{left:r.x,top:r.y,width:e.w/n.w*t.width,height:e.h/n.h*t.height}}function En(e,t){return{left:e.left-t.x/t.w*e.width,top:e.top-t.y/t.h*e.height,width:e.width/t.w,height:e.height/t.h}}function Dn(e,t,n){let r=Q(e.w/n,1/16,1),i=r/e.w;return{x:Q(t.x-(t.x-e.x)*i,0,1-r),y:Q(t.y-(t.y-e.y)*i,0,1-r),w:r,h:r}}function On(e,t,n){return{x:Q(e.x+t,0,1-e.w),y:Q(e.y+n,0,1-e.h),w:e.w,h:e.h}}function kn(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}var An=[`person`,`vehicle`,`animal`,`package`,`face`,`plate`];function jn(e){if(typeof e!=`object`||!e||!(`tagName`in e))return!1;let t=String(e.tagName).toUpperCase();return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`?!0:`isContentEditable`in e&&e.isContentEditable===!0}function Mn(e){let t=e.ctrlKey||e.metaKey,n=e.key.toLowerCase();if(t&&!e.altKey)return n===`s`&&!e.shiftKey?{kind:`save`}:e.typing?null:n===`z`?e.shiftKey?{kind:`redo`}:{kind:`undo`}:n===`y`&&!e.shiftKey?{kind:`redo`}:null;if(e.typing||t||e.altKey)return null;switch(e.key){case`ArrowRight`:return{kind:`next-frame`};case`ArrowLeft`:return{kind:`prev-frame`};case`Delete`:case`Backspace`:return{kind:`delete`};case`Escape`:return{kind:`deselect`};case`Tab`:return e.shiftKey?{kind:`select-prev`}:{kind:`select-next`};case`+`:case`=`:return{kind:`zoom-in`};case`-`:case`_`:return{kind:`zoom-out`};case`0`:return{kind:`zoom-fit`};default:break}let r=Number.parseInt(e.key,10);if(Number.isInteger(r)&&r>=1&&r<=An.length){let e=An[r-1];return e===void 0?null:{kind:`set-class`,macroClass:e}}return n===`a`?e.shiftKey?{kind:`accept-all`}:{kind:`accept`}:n===`e`&&!e.shiftKey?{kind:`toggle-model-error`}:n===`c`&&!e.shiftKey?{kind:`toggle-complete`}:null}var Nn=[{keys:`← / →`,does:`Previous / next frame`},{keys:`Drag on empty frame`,does:`Draw a box`},{keys:`Drag a box / its handles`,does:`Move / resize it`},{keys:`Delete, Backspace`,does:`Delete the selected box`},{keys:`1 – 6`,does:`Class: person, vehicle, animal, package, face, plate`},{keys:`A`,does:`Accept the selected draft`},{keys:`Shift + A`,does:`Accept every draft`},{keys:`E`,does:`Mark / unmark the selected box as a model error`},{keys:`C`,does:`Toggle "all subjects boxed"`},{keys:`Tab / Shift + Tab`,does:`Select the next / previous box`},{keys:`Esc`,does:`Deselect`},{keys:`Ctrl/⌘ + Z`,does:`Undo`},{keys:`Ctrl/⌘ + Shift + Z, Ctrl/⌘ + Y`,does:`Redo`},{keys:`Ctrl/⌘ + S`,does:`Save the frame`},{keys:`+ / − / 0, wheel, pinch`,does:`Zoom in / out / fit`},{keys:`Space + drag, middle drag, two fingers`,does:`Pan`}];n();var Pn=.0015,Fn={pipeline:`var(--color-foreground-muted)`,assist:`var(--color-info)`,llm:`var(--color-warning)`,operator:`var(--color-success)`};function In(e,t){return e.kind===`model_error`?{color:`var(--color-danger)`,dashed:!0,opacity:1}:t?{color:`var(--color-primary)`,dashed:e.draft,opacity:1}:e.draft?{color:Fn[e.source],dashed:!0,opacity:.8}:{color:`var(--color-success)`,dashed:!1,opacity:1}}function Ln(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Rn(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function zn({imageSrc:n,imageWidth:a,imageHeight:o,boxes:s,selectedKey:d,viewport:f,onViewportChange:p,panMode:m,onSelect:h,onDraw:g,onGestureStart:_,onGestureBox:v,onGestureEnd:y}){let b=t(null),[x,S]=c({w:0,h:0}),[C,w]=c(null),[T,E]=c(!1),D=t(new Map),O=t({mode:`none`});i(()=>{let e=b.current;if(e===null)return;let t=()=>S({w:e.clientWidth,h:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[]);let k=un(x.w,x.h,a,o);u(()=>{let e=e=>{e.key!==` `||jn(e.target)||(e.preventDefault(),E(!0))},t=e=>{e.key===` `&&E(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]);let A=t({image:k,viewport:f,onViewportChange:p});A.current={image:k,viewport:f,onViewportChange:p},u(()=>{let e=b.current;if(e===null)return;let t=t=>{let{image:n,viewport:r,onViewportChange:i}=A.current;if(n===null)return;t.preventDefault();let a=e.getBoundingClientRect();i(Dn(r,$(t.clientX-a.left,t.clientY-a.top,n,r),Math.exp(-t.deltaY*Pn)))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>{e.removeEventListener(`wheel`,t)}},[]);let j=e(e=>{let t=b.current?.getBoundingClientRect();return{x:e.clientX-(t?.left??0),y:e.clientY-(t?.top??0)}},[]),M=e(e=>k===null?null:$(e.x,e.y,k,f),[k,f]),N=e(()=>{let e=O.current;(e.mode===`move`||e.mode===`resize`)&&y(),e.mode===`draw`&&w(null),O.current={mode:`none`}},[y]),P=e=>{if(k===null)return;let t=j(e);if(D.current.set(e.pointerId,t),e.currentTarget.setPointerCapture?.(e.pointerId),D.current.size===2){N();let[e,t]=[...D.current.values()];if(e===void 0||t===void 0)return;let n=Rn(e,t);O.current={mode:`pinch`,startDistance:Math.max(1,Ln(e,t)),anchor:$(n.x,n.y,k,f),from:f};return}if(D.current.size>2)return;if(e.button===1||T||m){e.preventDefault(),O.current={mode:`pan`,startPx:t,from:f};return}if(e.button!==0)return;let n=$(t.x,t.y,k,f),r={x:12/k.width*f.w,y:12/k.height*f.h},i=s.find(e=>e.key===d);if(i!==void 0){let e=bn(i.bbox,n,r);if(e!==null&&e!==`body`){_(),O.current={mode:`resize`,key:i.key,handle:e,from:i.bbox};return}}let a=s[mn(s.map(e=>e.bbox),n)];if(a!==void 0){a.key!==d&&h(a.key),_(),O.current={mode:`move`,key:a.key,start:n,from:a.bbox};return}O.current={mode:`draw`,start:n},w(dn(n,n))},F=e=>{if(!D.current.has(e.pointerId)||k===null)return;let t=j(e);D.current.set(e.pointerId,t);let n=O.current;switch(n.mode){case`pinch`:{let[e,t]=[...D.current.values()];if(e===void 0||t===void 0)return;let r=Dn(n.from,n.anchor,Ln(e,t)/n.startDistance),i=Rn(e,t),a=$(i.x,i.y,k,r);p(On(r,n.anchor.x-a.x,n.anchor.y-a.y));return}case`pan`:{let e=(t.x-n.startPx.x)/k.width*n.from.w,r=(t.y-n.startPx.y)/k.height*n.from.h;p(On(n.from,-e,-r));return}case`move`:{let e=$(t.x,t.y,k,f);v(n.key,gn(n.from,e.x-n.start.x,e.y-n.start.y));return}case`resize`:{let e=$(t.x,t.y,k,f);v(n.key,vn(n.from,n.handle,e));return}case`draw`:{let e=$(t.x,t.y,k,f);w(dn(n.start,e));return}default:return}},I=e=>{if(!D.current.has(e.pointerId))return;D.current.delete(e.pointerId);let t=O.current;if(t.mode===`pinch`){D.current.size<2&&(O.current={mode:`none`});return}if(t.mode===`draw`){let n=M(j(e)),r=n===null?null:dn(t.start,n);w(null),O.current={mode:`none`},r!==null&&pn(r)?g(r):h(null);return}N()},L=s.find(e=>e.key===d),R=T||m,z=k===null?null:En(k,f);return r(`div`,{ref:b,"data-testid":`retrain-canvas`,className:`relative w-full h-full min-h-[280px] bg-surface-sunken select-none touch-none overflow-hidden`,style:{cursor:R?`grab`:`crosshair`},onPointerDown:P,onPointerMove:F,onPointerUp:I,onPointerCancel:I,children:[z!==null&&l(`img`,{src:n,alt:`Frame being annotated`,draggable:!1,className:`absolute max-w-none pointer-events-none`,style:z}),k!==null&&s.map(e=>{let t=Tn(e.bbox,k,f),n=e.key===d,i=In(e,n);return l(`div`,{"data-testid":`retrain-box-${e.key}`,"data-draft":e.draft?`true`:`false`,"data-source":e.source,className:`absolute pointer-events-none`,style:{left:t.left,top:t.top,width:t.width,height:t.height,border:`${n?`2px`:`1px`} ${i.dashed?`dashed`:`solid`} ${i.color}`,opacity:i.opacity},children:r(`span`,{className:`absolute -top-4 left-0 text-[10px] px-1 rounded whitespace-nowrap text-background`,style:{background:i.color},children:[e.label??e.macroClass,e.kind===`model_error`?` ✕`:``,e.draft?` ?`:``,e.flag!==void 0&&e.flag.verdict!==`confirmed`?` !`:``]})},e.key)}),k!==null&&L!==void 0&&hn.map(e=>{let t=wn(yn(L.bbox,e),k,f);return l(`div`,{"data-testid":`retrain-handle-${e}`,className:`absolute h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rounded-sm border border-background bg-primary pointer-events-none`,style:{left:t.x,top:t.y}},e)}),C!==null&&k!==null&&l(`div`,{className:`absolute border border-dashed border-primary pointer-events-none`,style:Tn(C,k,f)})]})}n();function Bn(){let[t,n]=c(xn),[r,i]=c(!1);return{viewport:t,setViewport:n,zoomIn:e(()=>{n(e=>Dn(e,kn(e),Sn))},[]),zoomOut:e(()=>{n(e=>Dn(e,kn(e),1/Sn))},[]),fit:e(()=>{n(xn)},[]),panMode:r,togglePan:e(()=>{i(e=>!e)},[])}}function Vn({view:e,canUndo:t,canRedo:n,onUndo:i,onRedo:a}){let o=Cn(e.viewport);return r(`div`,{className:`flex items-center gap-1 px-2 py-1 border-b border-border bg-surface`,children:[l(T,{variant:`ghost`,size:`sm`,"aria-label":`Zoom out`,onClick:e.zoomOut,children:l(ye,{className:`h-3.5 w-3.5`})}),r(`span`,{className:`w-12 text-center text-[11px] tabular-nums text-foreground-subtle`,children:[Math.round(o*100),`%`]}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Zoom in`,onClick:e.zoomIn,children:l(b,{className:`h-3.5 w-3.5`})}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Fit the whole frame`,disabled:o<=1,onClick:e.fit,children:l(Qe,{className:`h-3.5 w-3.5`})}),l(T,{variant:e.panMode?`secondary`:`ghost`,size:`sm`,"aria-label":`Pan tool`,"aria-pressed":e.panMode,onClick:e.togglePan,children:l(_,{className:`h-3.5 w-3.5`})}),l(`span`,{className:`flex-1`}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Undo`,disabled:!t,onClick:i,children:l(O,{className:`h-3.5 w-3.5`})}),l(T,{variant:`ghost`,size:`sm`,"aria-label":`Redo`,disabled:!n,onClick:a,children:l(et,{className:`h-3.5 w-3.5`})}),r(Ee,{children:[l(re,{"aria-label":`Keyboard shortcuts`,className:`inline-flex h-7 items-center rounded-md px-2 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:l(Xe,{className:`h-3.5 w-3.5`})}),r(j,{className:`w-80`,children:[l(`h3`,{className:`mb-2 text-xs font-semibold text-foreground`,children:`Keyboard and gestures`}),l(`table`,{className:`w-full text-[11px]`,children:l(`tbody`,{children:Nn.map(e=>r(`tr`,{className:`align-top`,children:[l(`td`,{className:`py-0.5 pr-2 font-mono whitespace-nowrap text-foreground`,children:e.keys}),l(`td`,{className:`py-0.5 text-foreground-subtle`,children:e.does})]},e.keys))})})]})]})]})}function Hn(e){return{past:[],present:e,future:[],gestureBase:null}}function Un(e,t){let n=[...e,t];return n.length>100?n.slice(n.length-100):n}function Wn(e,t){return t===e.present?e:{past:Un(e.past,e.present),present:t,future:[],gestureBase:null}}function Gn(e,t){return{...e,present:t}}function Kn(e){let t=e.past[e.past.length-1];return t===void 0?e:{past:e.past.slice(0,-1),present:t,future:[e.present,...e.future],gestureBase:null}}function qn(e){let[t,...n]=e.future;return t===void 0?e:{past:Un(e.past,e.present),present:t,future:n,gestureBase:null}}function Jn(e){return{...e,gestureBase:e.present}}function Yn(e,t){return{...e,present:t}}function Xn(e){let t=e.gestureBase;return t===null?e:t===e.present?{...e,gestureBase:null}:{past:Un(e.past,t),present:e.present,future:[],gestureBase:null}}function Zn(e){return e.past.length>0}function Qn(e){return e.future.length>0}n();function $n(e,t){return typeof e==`function`?e(t):e}function er(t){let[n,r]=c(()=>Hn(t())),i=e(e=>{r(t=>Wn(t,$n(e,t.present)))},[]),a=e(e=>{r(Hn(e))},[]),o=e(e=>{r(t=>Gn(t,$n(e,t.present)))},[]),s=e(()=>{r(e=>Jn(e))},[]),l=e(e=>{r(t=>Yn(t,$n(e,t.present)))},[]),u=e(()=>{r(e=>Xn(e))},[]),d=e(()=>{r(e=>Kn(e))},[]),f=e(()=>{r(e=>qn(e))},[]);return{editor:n.present,setEditor:i,resetEditor:a,selectOnly:o,beginGesture:s,updateGesture:l,endGesture:u,undo:d,redo:f,canUndo:Zn(n),canRedo:Qn(n)}}n();function tr(e,t){let n=e.boxes.length;if(n===0)return null;let r=e.boxes.findIndex(t=>t.key===e.selectedKey),i=r<0?t===1?0:n-1:(r+t+n)%n;return e.boxes[i]?.key??null}function nr(e,t){let{history:n}=t,r=n.editor.selectedKey;switch(e.kind){case`next-frame`:return t.onNextFrame();case`prev-frame`:return t.onPrevFrame();case`toggle-complete`:return t.onToggleComplete();case`save`:return t.onSave();case`undo`:return n.canUndo?(n.undo(),!0):!1;case`redo`:return n.canRedo?(n.redo(),!0):!1;case`zoom-in`:return t.onZoomIn(),!0;case`zoom-out`:return t.onZoomOut(),!0;case`zoom-fit`:return t.onZoomFit(),!0;case`accept-all`:return n.setEditor(e=>Bt(e)),!0;case`select-next`:case`select-prev`:{let t=tr(n.editor,e.kind===`select-next`?1:-1);return t===null?!1:(n.selectOnly(e=>Ut(e,t)),!0)}case`deselect`:return r===null?!1:(n.selectOnly(e=>Ut(e,null)),!0);default:break}if(r===null)return!1;switch(e.kind){case`delete`:return n.setEditor(e=>Ht(e,r)),!0;case`set-class`:return n.setEditor(t=>Rt(t,r,{macroClass:e.macroClass})),!0;case`accept`:return n.setEditor(e=>zt(e,r)),!0;case`toggle-model-error`:return n.setEditor(e=>Vt(e,r)),!0;default:return!1}}function rr(e,n){let r=t(n);r.current=n,u(()=>{if(!e)return;let t=e=>{if(e.defaultPrevented||e.isComposing)return;let t=Mn({key:e.key,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,typing:jn(e.target)});t!==null&&nr(t,r.current)&&e.preventDefault()};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e])}n();var ir=`person`,ar={pending:`Reading which detector this camera runs…`,"placement-unreadable":`The detection stage of this camera could not be read, so the model it runs is unknown — not absent.`,"detection-off":`This camera runs no object detector, so there is no proposal to mirror.`,"node-unreachable":`The node that detects for this camera did not answer about its accelerators.`,"device-unknown":`The node does not list the accelerator this camera detects on — asking another one would propose with a different model.`,"step-unknown":`That node carries no object-detection step in its catalog.`,"no-model":`No object-detection model on that accelerator can be resolved for this camera.`};function or({frames:n,activeFrameId:i,onActiveFrame:o,onFramesChanged:s,onSaved:d,setNotice:f,picked:p=!1,onTogglePick:m}){let h=n.find(e=>e.frameId===i),g=h?.deviceId??null,_=er(()=>Pt([],[])),{editor:y,setEditor:b,resetEditor:x,selectOnly:S}=_,C=Bn(),w=Re({frameIds:[i]}),E=pe({frameId:i}),D=L(),O=I(),A=k(),j=ne({deviceIds:g===null?[]:[g]},{enabled:g!==null,staleTime:3e4}),M=j.data?.[0]?.detection?.nodeId??null,N=Ae({nodeId:M??``},{enabled:M!==null,staleTime:3e4}),P=ze({nodeId:M??``},{enabled:M!==null,staleTime:3e4}),F=de({deviceId:g??0},{enabled:g!==null,staleTime:3e4}),R=a(()=>Ot({status:j.data?.[0],nodeDevices:N.data,schema:P.data,resolvedSteps:F.data?.steps}),[j.data,N.data,P.data,F.data]),z=t({stored:w.data,copy:h});z.current={stored:w.data,copy:h};let ee=h!==void 0;u(()=>{C.fit();let{stored:e,copy:t}=z.current;x(Pt((e??[]).filter(e=>e.mediaKey===i),t?.pipelineBoxes??[]))},[i,w.dataUpdatedAt,ee,x,C.fit]);let B=e(async e=>{h!==void 0&&(await A.mutateAsync({...Z(h),complete:e}),await s())},[h,A,s]),V=e(async e=>{if(h===void 0)return;if(f(null),R.kind!==`resolved`){f(ar[R.gap]);return}let t=await D.mutateAsync({...Z(h),subject:e===`package`?{kind:`package`}:{kind:`objects`,modelId:R.modelId,minScore:R.minScore},nodeId:R.nodeId});if(t.kind===`refused`){f(t.reason===`no-zone`?`A package proposal runs on the zone crop only — this camera has no zone, and running the detector on the whole frame at 0.35 proposes furniture.`:`The pipeline refused: ${t.reason}${t.detail===void 0?``:` — ${t.detail}`}`);return}let n=Ft(y,t.proposals.map(e=>({bbox:e.bbox,macroClass:e.macroClass,...e.label===void 0?{}:{label:e.label},kind:e.kind,source:e.source,...e.assistModelId===void 0?{}:{assistModelId:e.assistModelId},...e.assistScore===void 0?{}:{assistScore:e.assistScore},draft:!0})));b(n.state),f(`${t.proposals.length} proposal${t.proposals.length===1?``:`s`} from ${t.modelId}`+(n.skipped>0?` — ${n.skipped} already on the frame`:``)+(t.belowThreshold>0?` — ${t.belowThreshold} more were below ${t.minScore.toFixed(2)}`:``)+`. Accept or correct each one; drafts are not saved.`)},[h,D,R,y,b,f]),te=e(e=>{b(t=>It(t,e,ir))},[b]),[U,W]=c(!1),G=e(async()=>{if(h===void 0)return;let e=Kt(y);W(!0);try{await O.mutateAsync({...Z(h),annotations:[...Jt(y)]}),await w.refetch()}finally{W(!1)}await d?.(),f(e>0?`Annotations saved. ${String(e)} unconfirmed draft${e===1?` was`:`s were`} not saved.`:`Annotations saved.`)},[h,y,O,w,d,f]),K=E.data,re=tn(y.boxes)&&h!==void 0,ie=Kt(y),ae=n.map(e=>e.frameId),oe=e=>{let t=ae.indexOf(i),n=ae[t+e];return t<0||n===void 0?!1:(o(n),!0)};return rr(!U,{history:_,onNextFrame:()=>oe(1),onPrevFrame:()=>oe(-1),onToggleComplete:()=>h===void 0||A.isPending?!1:(B(!h.complete),!0),onSave:()=>!re||U?!1:(G(),!0),onZoomIn:C.zoomIn,onZoomOut:C.zoomOut,onZoomFit:C.fit}),r(`div`,{className:`grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_minmax(0,380px)] gap-3 ${U?`pointer-events-none opacity-70`:``}`,"aria-busy":U,children:[r(`div`,{className:`rounded-md border border-border overflow-hidden flex flex-col`,children:[l(Vn,{view:C,canUndo:_.canUndo,canRedo:_.canRedo,onUndo:_.undo,onRedo:_.redo}),K===void 0?r(`div`,{className:`flex items-center gap-2 p-6 text-xs text-foreground-subtle`,children:[l(H,{className:`h-3.5 w-3.5 animate-spin`}),`Loading the frame…`]}):l(zn,{imageSrc:`data:image/jpeg;base64,${K.base64}`,imageWidth:K.width,imageHeight:K.height,boxes:y.boxes,selectedKey:y.selectedKey,viewport:C.viewport,onViewportChange:C.setViewport,panMode:C.panMode,onSelect:e=>{S(t=>Ut(t,e))},onDraw:te,onGestureStart:_.beginGesture,onGestureBox:(e,t)=>{_.updateGesture(n=>Rt(n,e,{bbox:t}))},onGestureEnd:_.endGesture})]}),r(`div`,{className:`rounded-md border border-border bg-surface flex flex-col min-h-0`,children:[r(`div`,{className:`px-3 py-2 border-b border-border flex items-center gap-2 flex-wrap`,children:[l(`h2`,{className:`text-xs font-semibold text-foreground flex-1`,children:`Subjects`}),h?.origin===`recording`&&l(q,{variant:`info`,children:`from the recording`}),m!==void 0&&r(T,{variant:p?`primary`:`ghost`,size:`sm`,"aria-pressed":p,title:`Pick this frame for a dataset version (Datasets tab)`,onClick:m,children:[l($e,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:p?`Picked`:`Pick for dataset`})]}),r(T,{variant:`secondary`,size:`sm`,disabled:D.isPending||R.kind!==`resolved`,onClick:()=>void V(`objects`),children:[l(Se,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:`Propose`})]}),r(T,{variant:`secondary`,size:`sm`,disabled:D.isPending||R.kind!==`resolved`,onClick:()=>void V(`package`),children:[l(Se,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:`Packages`})]})]}),l(`div`,{className:`px-3 py-1 border-b border-border text-[11px] text-foreground-subtle`,children:R.kind===`resolved`?`Proposals come from ${R.modelId} at ${R.minScore.toFixed(2)}, on ${R.nodeId} — what this camera really runs.`:ar[R.gap]}),h!==void 0&&l(ln,{frame:h,history:_,detector:R,schema:P.data,setNotice:f}),l(`div`,{className:`flex-1 overflow-y-auto`,children:l(en,{boxes:y.boxes,selectedKey:y.selectedKey,onSelect:e=>{S(t=>Ut(t,e))},onChange:(e,t)=>{b(n=>Rt(n,e,t))},onAccept:e=>{b(t=>zt(t,e))},onToggleModelError:e=>{b(t=>Vt(t,e))},onDelete:e=>{b(t=>Ht(t,e))}})}),r(`label`,{className:`px-3 py-2 border-t border-border flex items-center gap-2 text-[11px] text-foreground`,children:[l(v,{"aria-label":`All subjects in this frame are boxed`,checked:h?.complete===!0,disabled:h===void 0||A.isPending,onChange:e=>void B(e.target.checked)}),r(`span`,{className:`flex-1`,children:[`All subjects boxed`,l(`span`,{className:`block text-foreground-subtle`,children:`Detector evaluation uses only these frames — an unboxed person counts as a false alarm. A frame with nothing in it, ticked, is a negative example.`})]})]}),ie>0&&r(`div`,{className:`px-3 py-2 border-t border-border flex items-center gap-2 text-[11px] text-warning`,children:[r(`span`,{className:`flex-1`,children:[ie,` draft`,ie===1?``:`s`,` not confirmed — a draft is never saved. Accept, correct or delete each one.`]}),r(T,{variant:`secondary`,size:`sm`,onClick:()=>{b(e=>Bt(e))},children:[l(He,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:`Accept all`})]})]}),r(`div`,{className:`px-3 py-2 border-t border-border flex items-center justify-between`,children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:[y.boxes.filter(e=>e.kind===`model_error`).length,` marked as model errors`]}),l(T,{size:`sm`,disabled:!re||U,onClick:()=>void G(),children:`Save frame`})]})]})]})}n();var sr={"empty-name":`Give the collection a name.`,"duplicate-name":`A collection with that name already exists.`,"unknown-collection":`That collection no longer exists.`};function cr(){let[t,n]=Ve(),[i,s]=c(`tracks`),[d,f]=c(null),[p,m]=c(null),[h,g]=c(null),[_,v]=c(new Map),[y,b]=c(null),[x,S]=c([]),C=t.get(`camera`),w=a(()=>{if(C===null||C===``)return null;let e=Number(C);return Number.isFinite(e)?e:null},[C]),O=e(e=>{n(t=>{let n=new URLSearchParams(t);return e===null?n.delete(`camera`):n.set(`camera`,String(e)),n},{replace:!0})},[n]),k=se({projection:`slim`,isCamera:!0}),A=a(()=>{let e=new Map;for(let t of k.data??[])e.set(t.id,t.name);return e},[k.data]),j=te({}),P=Fe({trackId:d?.trackId??``},{enabled:i===`tracks`&&d!==null}),F=E(),I=be(),L=Ce(),R=B({}),z=Ie({collectionId:p?.id??``},{enabled:i===`collections`&&p!==null}),ee=De(),V=N(),H=we(),W=ge(),G=i===`tracks`?P.data?.copies??[]:z.data??[],ne=e(()=>i===`tracks`?P.refetch():z.refetch(),[i,P,z]);u(()=>{h===null&&G.length>0&&g(G[0].frameId)},[G,h]);let K=e(()=>{g(null),v(new Map),b(null)},[]),re=e(e=>{f(e),K()},[K]),ie=e(e=>{m(e),K()},[K]),ae=e(async e=>{if(d===null)return;let t=await F.mutateAsync({deviceId:d.deviceId,trackId:d.trackId,mediaIds:[e]});if(t.refused.length>0){let e=new Map(_);for(let n of t.refused)e.set(n.sourceMediaId,n.reason);v(e)}t.copied.length>0&&g(t.copied[0].frameId),await P.refetch(),await j.refetch()},[d,F,_,P,j]),oe=e(async e=>{let t=(P.data?.copies??[]).find(t=>t.frameId===e);t!==void 0&&(await I.mutateAsync(Z(t)),h===e&&g(null),await P.refetch(),await j.refetch(),await R.refetch())},[P,I,h,j,R]),ce=e(async()=>{if(d===null)return;let e=await L.mutateAsync({deviceId:d.deviceId,trackId:d.trackId});b(e.changed?`Track completed — it is now trained, and its own media is evictable again.`:e.reason===`no-frames-copied`?`Refused: no frame was ever copied into the dataset. Completing would let retention delete material nothing was extracted from.`:`Refused: ${e.reason??`unknown`}`),await j.refetch(),e.changed&&f(null)},[d,L,j]),le=e(async e=>{let t=await ee.mutateAsync({name:e});return await R.refetch(),t.kind===`refused`?sr[t.reason]??t.reason:(m(t.collection),K(),null)},[ee,R,K]),ue=e(async(e,t)=>{let n=await V.mutateAsync({id:e,name:t});return await R.refetch(),n.kind===`refused`?sr[n.reason]??n.reason:(p?.id===e&&m(n.collection),null)},[V,R,p]),de=e(async e=>{let t=await H.mutateAsync({id:e});p?.id===e&&(m(null),K()),await R.refetch(),b(t.deleted?`Collection deleted${t.removedFrames>0?` — ${String(t.removedFrames)} recording frame${t.removedFrames===1?``:`s`} no other collection held left the dataset`:``}.`:`That collection no longer existed.`)},[H,p,R,K]),fe=e(async e=>{if(p===null)return;let t=await W.mutateAsync({collectionId:p.id,frameId:e.frameId});h===e.frameId&&g(null),await z.refetch(),await R.refetch(),b(t.deletedFrame?`Removed — it was a recording frame no other collection held, so it left the dataset with its boxes.`:`Removed from the collection.`)},[p,W,h,z,R]),pe=e(async()=>{await j.refetch()},[j]),me=i===`tracks`?d!==null:p!==null,he=G.some(e=>e.frameId===h),J=j.data,Y=R.data,_e=a(()=>J===void 0||Y===void 0?null:ot(J,Y),[J,Y]),ve=a(()=>J===void 0?[]:ct(J,A),[J,A]),ye=a(()=>J===void 0?[]:st(J,w),[J,w]);return u(()=>{d!==null&&(ye.some(e=>e.trackId===d.trackId)||(f(null),K()))},[ye,d,K]),r(Ue,{icon:je,title:`Retrain`,subtitle:`Turn marked tracks and frames sent from recordings into an annotated dataset. Every frame is a copy the dataset owns — it never depends on media that can be swept.`,actions:i===`tracks`&&d!==null?r(T,{size:`sm`,onClick:()=>void ce(),children:[l(je,{className:`h-3 w-3`}),l(`span`,{className:`ml-1`,children:`Complete track`})]}):null,children:[y!==null&&l(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-xs text-foreground`,children:y}),l(lt,{counts:_e,cameras:ve,selectedDeviceId:w,onSelectDevice:O}),l(vt,{}),r(`div`,{className:`grid grid-cols-1 lg:grid-cols-[minmax(0,260px)_minmax(0,1fr)] gap-4`,children:[r(`aside`,{className:`rounded-md border border-border bg-surface overflow-hidden`,children:[l(U,{value:i,onValueChange:e=>{s(e===`collections`||e===`datasets`?e:`tracks`),K()},children:r(D,{className:`px-2 pt-2`,children:[r(M,{value:`tracks`,children:[`Tracks `,l(q,{className:`ml-1`,children:ye.length})]}),r(M,{value:`collections`,children:[`Collections `,l(q,{className:`ml-1`,children:Y?.length??0})]}),l(M,{value:`datasets`,children:`Datasets`})]})}),i===`tracks`?l(wt,{tracks:ye,isLoading:j.isLoading,selectedTrackId:d?.trackId??null,deviceNames:A,onSelect:re}):i===`datasets`?l(`p`,{className:`p-3 text-[11px] text-foreground-subtle`,children:`A dataset version freezes the frames a selection of cameras, collections and picked frames yields, with the hash of their boxes, so a training run can name exactly what it learned from. Pick frames with "Pick for dataset" in the frame workbench.`}):l(at,{collections:R.data??[],isLoading:R.isLoading,selectedId:p?.id??null,onSelect:ie,onCreate:le,onRename:ue,onDelete:de})]}),l(`section`,{className:`space-y-3 min-w-0`,children:i===`datasets`?l(_t,{deviceNames:A,collections:R.data??[],pickedFrameIds:x,onClearPicked:()=>{S([])}}):me?r(o,{children:[l(`div`,{className:`rounded-md border border-border bg-surface p-3`,children:i===`tracks`?l(bt,{candidates:P.data?.candidates??[],copies:P.data?.copies??[],activeFrameId:h,refusals:_,isSelecting:F.isPending,onSelectCandidate:e=>void ae(e),onOpenCopy:g,onRemoveCopy:e=>void oe(e),renderCopyActions:e=>l(nt,{frameId:e.frameId,onAdded:()=>R.refetch()})}):l(it,{frames:z.data??[],isLoading:z.isLoading,activeFrameId:h,deviceNames:A,onOpen:g,onRemove:e=>void fe(e)})}),h!==null&&he&&l(or,{frames:G,activeFrameId:h,onActiveFrame:g,onFramesChanged:ne,onSaved:pe,setNotice:b,picked:x.includes(h),onTogglePick:()=>{S(e=>e.includes(h)?e.filter(e=>e!==h):[...e,h])}})]}):l(`p`,{className:`text-xs text-foreground-subtle`,children:i===`tracks`?`Pick a track from the staging list to start annotating it.`:`Pick or create a collection.`})})]})]})}export{cr as RetrainPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{E as s,at as c,st as l,vt as u}from"./player-overlays-D9aoM64J.js";import{$l as d,Cn as f,Dt as p,En as m,Fn as h,Ft as g,Id as _,It as v,Jd as y,Kn as b,Lt as x,Mn as S,Mu as C,Ot as w,Ou as T,Sn as ee,Tn as te,Ud as E,bn as ne,ca as D,er as re,gu as O,hu as ie,mu as ae,pd as k,qn as oe,wf as se,wn as ce}from"./src-B-IRCQFw.js";import{t as le}from"./octagon-alert-uq_xpLNT.js";import{R as ue,a as de,rt as fe}from"./index-D7yeH_53.js";var pe=u(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]);n();function A({id:e,title:t,icon:n,description:i,actions:a,tone:c=`default`,notice:l=null,onDismissNotice:u,children:d}){return o(g,{headingId:`access-${e}`,title:t,icon:n,actions:a,testId:`access-${e}`,children:r(`div`,{className:`${s} space-y-3`,children:[o(`div`,{className:O(`text-[11px] leading-relaxed`,c===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:i}),l!==null&&o(he,{notice:l,onDismiss:u}),d]})})}var me={success:{icon:se,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:le,line:`border-danger/40 text-danger`,mark:`text-danger`}};function he({notice:e,onDismiss:t}){let n=me[e.tone],i=n.icon;return r(`div`,{role:e.tone===`danger`?`alert`:`status`,className:O(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,n.line),children:[o(i,{className:O(`mt-0.5 h-3.5 w-3.5 shrink-0`,n.mark),"aria-hidden":!0}),o(`span`,{className:`min-w-0 flex-1`,children:e.message}),t!==void 0&&o(ie,{type:`button`,variant:`ghost`,size:`sm`,icon:C,"aria-label":`Dismiss`,onClick:t,className:`-my-1 h-5 w-5`})]})}function j(){let{data:e}=d();return i(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function M(e,t=null){return e===null?t:{tone:`danger`,message:e}}var N={active:`Active`,expired:`Expired`,revoked:`Revoked`,current:`This session`},ge={active:`success`,expired:`warning`,revoked:`default`,current:`info`},P={current:0,active:1,expired:2,revoked:3};function F(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function I({status:e}){return o(re,{variant:ge[e],className:`text-[10px]`,children:N[e]})}function L({row:e,action:t}){if(!t.isAvailable(e))return null;let n=t.icon,i=t.busyId===e.id;return r(h,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t.onRun(e),disabled:t.disabled,"aria-label":`${t.label} ${e.name}`,className:`text-danger hover:bg-danger/10`,children:[i?o(E,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):o(n,{className:`h-3 w-3`,"aria-hidden":!0}),t.label]})}function _e(e){return[{key:`name`,header:`Name`,sortValue:e=>e.name.toLowerCase(),render:e=>r(`div`,{className:`min-w-0 max-w-[18rem]`,children:[o(`div`,{className:`truncate font-medium text-foreground`,title:e.name,children:e.name}),e.detail!==null&&o(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:e.detail,children:e.detail})]})},e.hideOwner?null:{key:`owner`,header:`Owner`,sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:`Kind / scope`,sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:e=>r(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[o(`div`,{className:`text-foreground`,children:e.kind}),e.scope!==null&&o(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:e.scope,children:e.scope})]})},{key:`status`,header:`Status`,sortValue:e=>P[e.status],render:e=>o(I,{status:e.status})},{key:`created`,header:`Created`,sortValue:e=>e.createdAt,render:e=>o(`span`,{className:`text-foreground-subtle`,children:F(e.createdAt,`—`)})},{key:`lastUsed`,header:`Last used`,sortValue:e=>e.lastUsedAt,render:e=>o(`span`,{className:`text-foreground-subtle`,children:F(e.lastUsedAt,`Never`)})},{key:`expires`,header:`Expires`,sortValue:e=>e.expiresAt,render:t=>o(`span`,{className:`text-foreground-subtle`,children:F(t.expiresAt,e.expiresNone)})},e.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e.action===null?null:o(L,{row:t,action:e.action})}].filter(e=>e!==null)}n();var R=6,ve={"current-session":`your current session`,"not-active":`already gone`};function z(e,t){return`${String(e)} ${e===1?t.one:t.many}`}function ye(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>`${String(t)} ${N[e].toLowerCase()}`).join(`, `)}function be(e,t){let n=e.slice(0,R).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>R?[`…and ${String(e.length-R)} more`]:[];return[`${z(e.length,t)} (${ye(e)}) stop working at once. This cannot be undone.`,``,...n,...r].join(`
|
|
2
|
-
`)}function B(e,t,n){let r=oe(),i=T.auth.revokeCredentials.useMutation(),[o,s]=a(null);return{run:async a=>{if(a.length===0)return!1;let o=String(a.length),c=await r({title:`Revoke ${z(a.length,t)}?`,message:be(a,t),label:`Type ${o} to confirm`,placeholder:o,confirmLabel:`Revoke ${o}`,variant:`danger`,validate:e=>e.trim()===o?null:`Type ${o} — the number of ${t.many} selected`});if(c===null||c.trim()!==o)return!1;s(null);try{let n=await i.mutateAsync({kind:e,ids:a.map(e=>e.id),confirmCount:a.length}),r=n.skipped.map(e=>ve[e.reason]??e.reason);return s({tone:`success`,message:`Revoked ${z(n.revoked.length,t)}.`+(r.length>0?` Skipped ${String(r.length)}: ${[...new Set(r)].join(`, `)}.`:``)}),!0}catch(e){return s({tone:`danger`,message:`The revoke failed: ${e instanceof Error?e.message:`request failed`}. The list below is reloaded — check what is left.`}),!1}finally{n()}},busy:i.isPending,outcome:o,dismiss:()=>s(null)}}n();var xe={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},V={status:`Status`,owner:`Owner`,kind:`Kind`},Se=e=>e.status!==`current`;function H({rows:e,label:t,isLoading:n,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u=`Never`,action:d,bulk:f}){let m=p(e,xe),[h,g]=a(()=>new Set),_=i(()=>_e({hideOwner:l,expiresNone:u,action:d??null}),[l,u,d]),y=i(()=>f===void 0?()=>!1:e=>Se(e)&&f.isSelectable(e),[f]),b=i(()=>m.rows.filter(e=>h.has(e.id)&&y(e)),[m.rows,h,y]);return n?r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[o(E,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),`Loading `,t,`…`]}):s===null?r(`div`,{className:`space-y-3`,children:[o(w,{state:m.state,facets:m.facets,groups:m.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:V[e.id]??e.id,...e.id===`status`?{facetLabel:e=>N[e]??e}:{}})),labels:{searchPlaceholder:`Search ${t}…`,searchLabel:`Search ${t}`,facetsLabel:`Filter ${t}`,clearLabel:`Clear filters`},onSearch:m.setSearch,onToggleFacet:m.toggleFacet,onToggleGroupFacet:m.toggleGroupFacet,onClear:m.clear}),f!==void 0&&o(Ce,{bulk:f,shown:m.rows.filter(y),targets:b,onSelect:g}),o(v,{columns:_,rows:m.rows,rowKey:e=>e.id,minWidthPx:l?760:860,mobileMode:`scroll`,maxBodyHeight:x,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:`${t} pages`,previous:`Previous page`,next:`Next page`,range:(e,t,n)=>`${e}–${t} of ${n}`},emptyMessage:m.active?`No ${t} match the filters.`:c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...f===void 0?{}:{selection:{selected:h,onChange:g,isSelectable:y,rowLabel:e=>`Select ${e.name} (${e.ownerName})`,pageLabel:`Select every ${f.noun.one} on this page`}}})]}):o(S,{title:`Could not load ${t}`,message:s})}function Ce({bulk:e,shown:t,targets:n,onSelect:i}){let{revoke:a,noun:s}=e,c=(e.quickSelect??[]).map(e=>({...e,rows:t.filter(e.match)})).filter(e=>e.rows.length>0),u=async()=>{await a.run(n)&&i(new Set)};return r(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[t.length>0&&r(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(new Set(t.map(e=>e.id))),children:[`Select all `,String(t.length),` shown`]}),c.map(e=>r(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(new Set(e.rows.map(e=>e.id))),children:[e.label,` (`,String(e.rows.length),`)`]},e.label)),n.length>0&&r(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[r(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:[z(n.length,s),` selected`]}),r(h,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>i(new Set),children:[o(C,{className:`h-3 w-3`,"aria-hidden":!0}),`Clear selection`]}),r(h,{type:`button`,variant:`danger`,size:`sm`,disabled:a.busy,onClick:()=>void u(),children:[a.busy?o(E,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):o(l,{className:`h-3 w-3`,"aria-hidden":!0}),`Revoke `,z(n.length,s),`…`]})]})]})}var U=(e,t)=>t===null?`—`:e.get(t)??t;function W(e,t){return e!=null&&e<=t?`expired`:`active`}function we(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:U(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Te(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}function Ee(e,t,n,r,i){let a=[...new Set(e.scopes.map(e=>e.type))].toSorted();return{id:e.id,name:e.name,detail:`${e.tokenPrefix}…`,ownerId:t,ownerName:U(n,t),kind:a.length===0?`none`:a.join(` + `),scope:r,status:W(e.expiresAt,i),createdAt:e.createdAt,lastUsedAt:e.lastUsedAt??null,expiresAt:e.expiresAt??null}}function De(e,t,n){return{id:e.id,name:e.name,detail:`${e.tokenPrefix}…`,ownerId:e.createdBy,ownerName:U(t,e.createdBy),kind:`Full administrator`,scope:null,status:e.revokedAt===null?W(e.expiresAt,n):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}var Oe={"grid-view":`Grid`,"events-view":`Events`};function ke(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function Ae(e,t,n,r){let i=Oe[e.scope.kind];return{id:e.id,name:`${i} · ${String(e.scope.deviceIds.length)} camera${e.scope.deviceIds.length===1?``:`s`}`,detail:`${e.tokenPrefix}…`,ownerId:e.userId,ownerName:U(t,e.userId),kind:e.scope.talk===!0?`${i} + talk`:i,scope:ke(e.scope.deviceIds,n),status:W(e.expiresAt,r),createdAt:e.createdAt,lastUsedAt:e.lastUsedAt??null,expiresAt:e.expiresAt}}function G(e){return`${e.provider}\u0000${e.subject}`}function je(e,t){return{id:G(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:U(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}function Me(e,t){let n=e.allowedProviders;return{id:e.id,name:e.label,detail:`${e.tokenPrefix}…`,ownerId:e.userId??null,ownerName:U(t,e.userId??null),kind:e.isAdmin===!0?`Admin`:`Regular`,scope:n===void 0||n===`*`?`All providers`:n.join(`, `)||`All providers`,status:`active`,createdAt:e.createdAt??null,lastUsedAt:e.lastUsedAt??null,expiresAt:null}}var K=40,Ne=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],Pe=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],Fe=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function q(e,t){return e.find(e=>e.test.test(t))?.name??null}function Ie(e){return e.length<=K?e:`${e.slice(0,K)}…`}function J(e){if(e===null||e.trim().length===0)return{label:`Unknown device`,raw:null};let t=e.trim(),n=q(Fe,t);if(n!==null)return{label:n,raw:t};let r=q(Ne,t),i=q(Pe,t);return r!==null&&i!==null?{label:`${r} on ${i}`,raw:t}:r===null?{label:Ie(t),raw:t}:{label:r,raw:t}}var Le={password:`Password`,passkey:`Passkey`,sso:`Single sign-on`,handoff:`App hand-off`,exchange:`Session exchange`};function Y(e){return Le[e]??e}function X(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}n();function Z(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function Re(n){let i=c(),[s,l]=a(!1),[u,d]=a(``),[p,g]=a(null),[_,v]=a(null),b=t(null),x=e(e=>{b.current?.(e),b.current=null,l(!1),d(``),g(null),v(null)},[]),S=e(()=>new Promise(e=>{b.current?.(null),b.current=e,v(null),l(!0)}),[]),C=async()=>{g(`password`),v(null);try{let{reauthToken:e}=await i.reauthenticate({password:u});x(e)}catch(e){v(Z(e,`Password is incorrect`)),g(null)}},w=async()=>{g(`passkey`),v(null);try{let{optionsJSON:e}=await i.reauthBeginPasskey(),t=await de({optionsJSON:e}),{reauthToken:n}=await i.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});x(n)}catch(e){v(Z(e,`Passkey verification failed`)),g(null)}};return{requestProof:S,dialog:o(ne,{open:s,onOpenChange:e=>!e&&x(null),children:r(ee,{children:[r(te,{children:[o(m,{children:`Confirm it’s you`}),r(f,{children:[n,` needs your password or a passkey, even though you are signed in.`]})]}),r(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&p===null&&C()},children:[o(ae,{type:`password`,autoComplete:`current-password`,placeholder:`Current password`,value:u,onChange:e=>d(e.target.value),"aria-label":`Current password`}),_!==null&&o(`p`,{role:`alert`,className:`text-xs text-danger`,children:_}),r(ce,{className:`flex flex-wrap gap-2`,children:[r(h,{type:`button`,variant:`outline`,disabled:p!==null,onClick:()=>void w(),children:[p===`passkey`?o(E,{className:`h-4 w-4 animate-spin`}):o(y,{className:`h-4 w-4`}),`Use a passkey`]}),r(h,{type:`submit`,disabled:u.length===0||p!==null,children:[p===`password`&&o(E,{className:`h-4 w-4 animate-spin`}),`Confirm`]})]})]})]})})}}n();var Q={one:`share link`,many:`share links`};function $(e){let t=b(),n=T.useUtils(),r=T.auth.listShareTokens.useQuery({owner:e}),o=j(),{data:s}=D({isCamera:!0,projection:`slim`}),[c,u]=a(null),d=()=>void n.auth.listShareTokens.invalidate(),f=T.auth.revokeShareToken.useMutation({onSuccess:d,onError:e=>u(`Revoke failed: ${e.message}`)}),p=i(()=>{let e=new Map;for(let t of s??[])e.set(t.id,t.name);return e},[s]),m=Date.now(),h=(r.data??[]).map(e=>Ae(e,o,p,m)),g=async e=>{await t({title:`Revoke share link`,message:`Anyone holding this link to ${e.scope??e.name} loses access immediately. This cannot be undone.`,confirmLabel:`Revoke`,variant:`danger`})&&(u(null),f.mutate({id:e.id}))};return{rows:h,refresh:d,error:c,clearError:()=>u(null),isLoading:r.isLoading,loadError:r.isError?r.error?.message??`Request failed`:null,action:{label:`Revoke`,icon:l,isAvailable:()=>!0,onRun:e=>void g(e),busyId:f.isPending?f.variables?.id??null:null,disabled:f.isPending}}}function ze(){let e=$(`self`);return o(A,{notice:M(e.error),onDismissNotice:e.clearError,id:`my-share-links`,title:`Share links`,icon:k,description:`View-only links you created in the viewer app to share a grid or the events of some cameras. Revoking a link stops it working everywhere it was sent.`,children:o(H,{rows:e.rows,label:`share links`,isLoading:e.isLoading,loadError:e.loadError,emptyText:`You have no share links.`,hideOwner:!0,action:e.action})})}function Be(){let{user:e}=ue();return e?.isAdmin?o(Ve,{}):null}function Ve(){let e=$(`all`),t=B(`share-link`,Q,e.refresh);return o(A,{notice:M(e.error,t.outcome),onDismissNotice:()=>{e.clearError(),t.dismiss()},id:`share-links`,title:`Share links`,icon:k,description:`Every user's view-only share links. Revoking one stops it working for whoever it was sent to — a revoked link is deleted and cannot be restored.`,children:o(H,{rows:e.rows,label:`share links`,isLoading:e.isLoading,loadError:e.loadError,emptyText:`No user has any share links.`,action:{...e.action,disabled:e.action.disabled||t.busy},bulk:{revoke:t,noun:Q,isSelectable:()=>!0,quickSelect:[{label:`Select expired`,match:e=>e.status===`expired`}]}})})}function He({sessions:e,isLoading:t,loadError:n,emptyText:i,onRevoke:a,revokingId:s}){return t?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(E,{className:`h-3.5 w-3.5 animate-spin`}),`Loading sessions…`]}):n===null?e.length===0?o(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:i}):o(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(Ue,{session:e,revoking:s===e.id,onRevoke:()=>a(e)},e.id))}):r(`div`,{className:`text-[11px] text-danger`,children:[`Could not load sessions: `,n]})}function Ue({session:e,revoking:t,onRevoke:n}){let i=J(e.client);return r(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[o(_,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),r(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o(`span`,{className:`font-medium text-foreground truncate`,title:i.raw??void 0,children:i.label}),e.current&&o(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:`This device`})]}),r(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[o(`span`,{children:Y(e.method)}),o(`span`,{className:`font-mono`,children:e.ip??`IP unknown`}),r(`span`,{children:[`Last active `,X(e.lastUsedAt)]}),r(`span`,{children:[`Expires `,X(e.expiresAt)]})]})]}),!e.current&&r(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[t?o(E,{className:`h-3 w-3 animate-spin`}):o(fe,{className:`h-3 w-3`}),`Sign out`]})]})}export{A as _,J as a,pe as b,De as c,je as d,Te as f,B as g,H as h,Re as i,Me as l,Ee as m,Be as n,Y as o,we as p,ze as r,X as s,He as t,G as u,M as v,j as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,a as i,b as a,o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{E as d,at as f,gt as p,ht as m,st as h}from"./player-overlays-D9aoM64J.js";import{Cd as g,Cl as _,Cn as v,Cu as y,Ed as b,Ef as x,El as S,En as C,Fn as w,Ft as ee,Gn as T,Gt as te,It as E,Jd as D,Kn as ne,Kt as O,Lt as k,Mn as re,Of as ie,Ol as ae,Sn as oe,Tf as A,Tn as se,Ud as ce,Ut as le,Vd as ue,Wt as j,Yd as de,_o as fe,bn as pe,cf as me,dd as he,do as ge,er as M,fo as _e,go as ve,gu as N,hd as P,ho as F,kn as ye,kt as I,lo as be,lu as L,md as R,mo as xe,mu as z,od as B,po as Se,qn as Ce,qu as we,uo as Te,vo as Ee,wn as De,xn as Oe,yo as ke,zd as Ae}from"./src-B-IRCQFw.js";import{t as je}from"./octagon-alert-uq_xpLNT.js";import{ir as Me}from"./client-DX0rAC3X.js";import{$ as Ne,T as Pe}from"./index-D7yeH_53.js";import{t as V}from"./AdminPage-BSFohA3i.js";import{t as Fe}from"./NodeAddonsSettingsPanel-Bb9dwuSU.js";import{t as Ie}from"./AdminTabs-wu-aryGN.js";import{t as Le}from"./AddonAssetIcon-rRcZQtEA.js";t();var Re={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},ze={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function Be({entry:e,actions:t}){let r=e.name.toLowerCase(),i=Re[r]??`border-primary`,a=ze[r]??`bg-primary/5`,o=e.providers.find(e=>e.active),s=t?.pendingCapability===e.name;return n(`div`,{className:`rounded-lg border-t-2 border border-border ${i} ${a} p-3 space-y-2`,children:[n(`div`,{className:`flex items-center justify-between gap-2`,children:[n(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[e.name,s&&l(ce,{className:`h-3 w-3 animate-spin text-primary`})]}),l(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${e.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:e.mode})]}),e.mode===`singleton`?l(Ve,{entry:e,actions:t,activeProvider:o,isPending:s}):l(He,{entry:e,actions:t,isPending:s})]})}function Ve({entry:e,actions:t,activeProvider:r,isPending:i}){if(!t)return l(`div`,{children:r?n(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[l(A,{className:`h-3 w-3 text-green-400 shrink-0`}),l(`span`,{className:`font-medium`,children:r.addonName}),l(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):l(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No active provider`})});if(e.providers.length===0)return l(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});let a=`__inherit__`;return n(`div`,{className:`space-y-2`,children:[l(`div`,{className:`space-y-1`,children:e.providers.map(r=>{let a=r.active;return n(`button`,{type:`button`,disabled:i||a,onClick:()=>t.onSelectSingleton(e.name,r.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${a?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[l(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${a?`border-green-400 bg-green-400`:`border-border`}`}),l(`span`,{className:`font-medium truncate`,children:r.addonName}),a&&l(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},r.addonId)})}),e.perNode&&e.perNode.length>0&&l(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:e.perNode.map(r=>{let o=r.hasOverride&&r.resolvedActive?r.resolvedActive:a,s=[{value:a,label:`Inherit global${r.resolvedActive?` (${r.resolvedActive})`:``}`},...r.providers.map(e=>({value:e,label:e}))],c=n=>{n===a?t.onClearNodeSingleton(e.name,r.nodeId):t.onSelectNodeSingleton(e.name,r.nodeId,n)},u=i;return n(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[r.nodeId,r.hasOverride&&l(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:`override`})]}),s.map(e=>{let t=o===e.value;return n(`button`,{type:`button`,disabled:u||t,onClick:()=>c(e.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${t?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[l(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${t?`border-green-400 bg-green-400`:`border-border`}`}),l(`span`,{className:`font-medium truncate`,children:e.label}),t&&e.value!==a&&l(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},e.value)})]},r.nodeId)})})]})}function He({entry:e,actions:t,isPending:r}){if(e.providers.length===0)return l(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});if(!t)return l(`div`,{className:`space-y-1`,children:e.providers.map(e=>n(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[l(`span`,{className:`text-foreground-subtle`,children:e.addonName}),e.active&&l(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},e.addonId))});let i=e.providers.filter(e=>e.active).map(e=>e.addonId),a=(n,r)=>{let a=r?[...new Set([...i,n])]:i.filter(e=>e!==n);t.onToggleCollection(e.name,a)};return l(`div`,{className:`space-y-1`,children:e.providers.map(e=>n(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${r?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[n(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[l(`input`,{type:`checkbox`,checked:e.active,disabled:r,onChange:t=>a(e.addonId,t.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),l(`span`,{className:`text-foreground truncate`,children:e.addonName})]}),e.active&&l(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},e.addonId))})}function H({capabilities:e,actions:t}){return e.length===0?l(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:`No capabilities registered`}):l(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>l(Be,{entry:e,actions:t},e.name))})}var Ue=[`capabilities`,`listCapabilities`];function We(e){return e===`singleton`||e===`collection`}function Ge(e){let t=e.indexOf(`@`);return t===-1?`${e} (hub)`:`${e.slice(0,t)} (${e.slice(t+1)})`}function Ke(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:Ge(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function qe(){let e=f(),[t,a]=s(null),[o,u]=s(null),d=i({queryKey:Ue,queryFn:()=>e.trpcClient.capabilities.listCapabilities.query()}),p=r(()=>{let e=(d.data??[]).flatMap(e=>We(e.mode)?[Ke(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[d.data]),m=r(()=>p.filter(e=>e.mode===`singleton`),[p]),h=r(()=>p.filter(e=>e.mode===`collection`),[p]),g=c({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId}),onMutate:e=>{a(e.capName),u(null)},onSuccess:async(e,t)=>{u({kind:`success`,message:`${t.capName} → ${t.addonId} is now active.`}),await d.refetch()},onError:(e,t)=>{u({kind:`error`,message:`Failed to set ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>a(null)}),_=c({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId,nodeId:t.nodeId}),onMutate:e=>{a(e.capName),u(null)},onSuccess:async(e,t)=>{u({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await d.refetch()},onError:(e,t)=>{u({kind:`error`,message:`Failed to set ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>a(null)}),v=c({mutationFn:t=>e.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:t.capName,nodeId:t.nodeId}),onMutate:e=>{a(e.capName),u(null)},onSuccess:async(e,t)=>{u({kind:`success`,message:`${t.capName} @ ${t.nodeId} now inherits the global default.`}),await d.refetch()},onError:(e,t)=>{u({kind:`error`,message:`Failed to clear ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>a(null)}),y=c({mutationFn:t=>e.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:t.capName,enabledAddonIds:[...t.enabledAddonIds]}),onMutate:e=>{a(e.capName),u(null)},onSuccess:async(e,t)=>{u({kind:`success`,message:`${t.capName}: ${t.enabledAddonIds.length} provider(s) enabled.`}),await d.refetch()},onError:(e,t)=>{u({kind:`error`,message:`Failed to update ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>a(null)}),b={onSelectSingleton:(e,t)=>g.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>_.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>v.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>y.mutate({capName:e,enabledAddonIds:t}),pendingCapability:t};return n(V,{icon:B,title:`Capabilities`,subtitle:`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`,children:[o&&n(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${o.kind===`success`?`border-success/30 bg-success/10 text-success`:`border-danger/40 bg-danger/10 text-danger`}`,children:[o.kind===`success`?l(A,{className:`h-3.5 w-3.5 shrink-0`}):l(x,{className:`h-3.5 w-3.5 shrink-0`}),l(`span`,{children:o.message})]}),d.isLoading&&l(`div`,{className:`flex items-center justify-center py-16`,children:l(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),d.isError&&!d.isLoading&&l(re,{title:`Failed to load capabilities`,message:d.error instanceof Error?d.error.message:`Unknown error`,onRetry:()=>void d.refetch()}),!d.isLoading&&!d.isError&&p.length===0&&l(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No capabilities registered.`}),!d.isLoading&&!d.isError&&p.length>0&&n(`div`,{className:`space-y-6`,children:[m.length>0&&n(`section`,{className:`space-y-2`,children:[l(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Singleton — pick one provider`}),l(H,{capabilities:m,actions:b})]}),h.length>0&&n(`section`,{className:`space-y-2`,children:[l(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Collection — enable a set`}),l(H,{capabilities:h,actions:b})]})]})]})}var U=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Je={"key-missing":`no master key could be loaded`,"wrong-key":`the master key does not match`,"key-file-unreadable":`the key file cannot be read`,"store-unavailable":`the keychain tables cannot be read`,"not-initialized":`still starting`,"decrypt-failed":`a value did not decrypt`};function Ye(e){return Je[e]??e}function W(e,t,n){return`${e} ${e===1?t:n}`}function Xe({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:`Keychain locked: ${Ye(e.keychain.reason)}`}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?`Keychain was reset: ${W(n,`field`,`fields`)} to re-enter`:`Keychain was reset: every archived field holds a value again`}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:`The master key sits next to the database in whole-volume backups`}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:`No recovery copy of the master key has been taken`}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:`The configured master key is not in use yet`}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:`${W(r,`stored value`,`stored values`)} no setting points at`}),[...o].sort((e,t)=>U.indexOf(e.id)-U.indexOf(t.id))}var Ze={dateStyle:`short`,timeStyle:`short`};function G(e){return e===null?`—`:new Date(e).toLocaleString(void 0,Ze)}function K({value:e,copyValue:t,srLabel:r,maxWidthClass:i,className:a}){let o=t??e;return n(`span`,{className:N(`flex min-w-0 items-center gap-0.5`,i),children:[l(`span`,{className:N(`min-w-0 truncate font-mono`,a),title:o,children:e}),l(I,{value:o,srLabel:r,className:`h-6 shrink-0 px-1.5`})]})}t();var Qe=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]),$e=[{key:`at`,header:`When`,render:e=>G(e.at)},{key:`action`,header:`Action`,render:e=>l(M,{variant:Qe.has(e.action)?`warning`:`default`,children:e.action})},{key:`actor`,header:`Actor`,render:e=>l(`span`,{className:`font-mono`,children:e.actor})},{key:`ref`,header:`Ref`,render:e=>e.ref===null?l(`span`,{className:`text-foreground-subtle`,children:`—`}):l(K,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{key:`detail`,header:`Detail`,render:e=>l(`span`,{className:`text-foreground-muted`,children:e.detail??``})}];function et({entries:e}){let[t,r]=s(0);if(e===void 0)return l(`p`,{className:`text-xs text-foreground-subtle`,children:`Loading…`});let i=Math.max(1,Math.ceil(e.length/25)),a=Math.min(t,i-1),o=a*25,c=e.slice(o,o+25);return n(`div`,{className:`space-y-2`,children:[l(E,{columns:$e,rows:c,rowKey:e=>e.id,minWidthPx:760,mobileMode:`scroll`,emptyMessage:`Nothing has been audited yet.`}),e.length>25&&n(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:[o+1,`–`,o+c.length,` of `,e.length,e.length>=500?` most recent`:``]}),n(`span`,{className:`inline-flex items-center gap-1`,children:[l(w,{size:`sm`,variant:`outline`,"aria-label":`Previous page`,disabled:a===0,onClick:()=>r(a-1),children:l(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),n(`span`,{className:`tabular-nums`,children:[a+1,` / `,i]}),l(w,{size:`sm`,variant:`outline`,"aria-label":`Next page`,disabled:a>=i-1,onClick:()=>r(a+1),children:l(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function tt(e,t){switch(e){case`locked`:return l(w,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:`Reset keychain`});case`reset`:return l(w,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:`Dismiss`});case`recovery-key`:return l(w,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:`Download`});case`rotation-pending`:return l(w,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:`Rotate`});case`orphans`:return l(w,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:`Review`});case`shares-backup`:return null}}function nt(e,t){switch(e){case`locked`:return l(`p`,{children:`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`});case`reset`:return t.reset===null?null:l(rt,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return n(`p`,{children:[`CamStack’s own backups leave the key out, but a backup of the whole data directory (an appdata tar) carries both. Point `,l(`code`,{className:`font-mono`,children:`keychain.keyFile`}),` in config.yaml at a file outside the data volume, keep the old one as`,` `,l(`code`,{className:`font-mono`,children:`keychain.previousKeyFile`}),`, restart, then rotate.`]});case`recovery-key`:return l(`p`,{children:`Without a copy of the master key, the stored values cannot be recovered.`});case`rotation-pending`:return l(`p`,{children:`The keychain unlocked with a previous key. Rotate to move onto the configured one.`});case`orphans`:return null}}function rt({reset:e,pending:t}){let r=e.actor===`trigger-file`?`the RESET_KEYCHAIN trigger file`:`an admin (${e.actor})`;return n(`div`,{className:`space-y-1.5`,children:[n(`p`,{children:[`Reset on `,G(e.at),` by `,r,`. `,e.archived,` stored value(s) were archived — unreadable without the lost master key. Everyone was signed out once.`]}),e.clearedSettingsKeys.includes(`cluster.clusterSecret`)&&l(`p`,{children:`The cluster secret was cleared. If your agents used one, set it again in System → Cluster; until then any node may register.`}),t.length>0&&l(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t.map(e=>n(`li`,{className:`break-all`,children:[e.owner,` · `,e.scope,` · `,e.fieldPath]},e.ref))})]})}t();var it=2,q={danger:{icon:je,text:`text-danger`,border:`border-danger/40`},warning:{icon:we,text:`text-warning`,border:`border-warning/40`},info:{icon:de,text:`text-info`,border:`border-border`}};function at({notices:e,renderAction:t,renderDetail:r}){let[i,a]=s(!1),o=e[0];if(o===void 0)return null;let c=e.length>it,u=c&&!i?e.slice(0,1):e,d=e.length-u.length;return n(`section`,{"aria-label":`Keychain notices`,className:N(`rounded-lg border bg-surface`,q[o.tone].border),children:[l(`ul`,{className:`divide-y divide-border`,children:u.map(e=>l(ot,{notice:e,action:t(e.id),detail:r(e.id)},e.id))}),c&&l(`div`,{className:`border-t border-border px-3 py-1`,children:n(w,{size:`sm`,variant:`ghost`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[l(p,{className:N(`h-3.5 w-3.5 transition-transform`,i&&`rotate-180`),"aria-hidden":!0}),i?`Show less`:`${d} more`]})})]})}function ot({notice:e,action:t,detail:r}){let[i,a]=s(!1),o=q[e.tone],c=o.icon,u=r!=null,d=`keychain-notice-${e.id}`;return n(`li`,{className:`px-3 py-2`,children:[n(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[n(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[l(c,{className:N(`mt-0.5 h-3.5 w-3.5 shrink-0`,o.text),"aria-hidden":!0}),l(`span`,{className:`min-w-0 break-words`,children:e.title})]}),n(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[u&&l(w,{size:`sm`,variant:`ghost`,"aria-expanded":i,"aria-controls":d,onClick:()=>a(e=>!e),children:`Details`}),t]})]}),u&&i&&l(`div`,{id:d,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:r})]})}var st={"config-file":`Key file (config.yaml)`,"previous-config-file":`Previous key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},ct=8;function lt({status:e,busy:t,onDownload:r,onRotate:i,onPurge:a}){let o=e.keychain.state===`locked`,s=e.keySource??e.configuredSource;return l(ee,{headingId:`keychain-status`,title:`Keychain`,icon:D,actions:n(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.retiredWraps>0&&n(w,{size:`sm`,variant:`ghost`,disabled:t||o,onClick:a,children:[`Purge `,e.retiredWraps,` retired wrap`,e.retiredWraps===1?``:`s`]}),l(w,{size:`sm`,variant:`outline`,disabled:t||o,onClick:i,children:`Rotate key`}),l(w,{size:`sm`,variant:`outline`,disabled:t||o,onClick:r,children:`Download recovery key`})]}),children:n(`dl`,{className:`${d} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[n(J,{label:`State`,children:[o?n(M,{variant:`danger`,className:`gap-1`,children:[l(ue,{className:`h-3 w-3`,"aria-hidden":!0}),`Locked`]}):n(M,{variant:`success`,className:`gap-1`,children:[l(he,{className:`h-3 w-3`,"aria-hidden":!0}),`Unlocked`]}),n(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.secretCount,` stored`]})]}),n(J,{label:`Key source`,children:[l(`span`,{className:`block`,children:st[s.kind]}),s.path!==void 0&&l(K,{value:s.path,srLabel:`key path`})]}),l(J,{label:`Fingerprint`,children:e.fingerprint===null?l(`span`,{className:`text-foreground-subtle`,children:`—`}):n(`span`,{className:`inline-flex items-center gap-0.5`,children:[l(`span`,{className:`font-mono`,title:e.fingerprint,children:e.fingerprint.slice(0,ct)}),l(I,{value:e.fingerprint,srLabel:`fingerprint`})]})}),l(J,{label:`Recovery key`,children:e.recoveryKeyDownloadedAt===null?l(M,{variant:`warning`,children:`Not taken`}):n(`span`,{children:[`Taken `,G(e.recoveryKeyDownloadedAt)]})})]})})}function J({label:e,children:t}){return n(`div`,{className:`min-w-0 text-xs`,children:[l(`dt`,{className:`text-foreground-subtle`,children:e}),l(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:t})]})}t();var ut=1e3;function dt({revealed:e,onClose:t}){let[r,i]=s(L);u(()=>{if(e===null)return;let n=Date.now();i(L);let r=setTimeout(t,L),a=setInterval(()=>i(Math.max(0,L-(Date.now()-n))),ut);return()=>{clearTimeout(r),clearInterval(a)}},[e,t]);let o=Math.ceil(r/1e3);return l(pe,{open:e!==null,onOpenChange:e=>!e&&t(),children:l(oe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:e!==null&&n(a,{children:[n(se,{children:[l(C,{className:`break-all`,children:e.entry.fieldPath}),n(v,{className:`break-all`,children:[e.entry.owner,` · `,e.entry.scope]})]}),l(Oe,{children:l(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:e.value})}),n(De,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`This reveal is recorded in the keychain audit. Hides in `,o,`s.`]}),n(`div`,{className:`flex justify-end gap-2`,children:[l(I,{value:e.value,label:`Copy`,srLabel:`revealed value`}),l(w,{size:`sm`,variant:`outline`,onClick:t,children:`Hide`})]})]})]})})})}var Y={orphan:{label:`Orphan`,variant:`warning`,hint:`No setting points at this value any more.`,rank:0},unknown:{label:`Unavailable`,variant:`default`,hint:`Its owner's settings could not be read, so whether it is in use is unknown. Never deleted as an orphan.`,rank:1},"in-use":{label:`In use`,variant:`success`,hint:`A setting points at this value.`,rank:2}},ft=[{id:`all`,label:`All`},{id:`in-use`,label:`In use`},{id:`orphan`,label:`Orphans`},{id:`unknown`,label:`Unavailable`}],X=`system`;function pt(e){let{secrets:t,filter:r,onFilterChange:i,onDeleteOrphans:a,deleting:o,locked:s}=e;if(t===void 0)return l(`p`,{className:`text-xs text-foreground-subtle`,children:`Loading…`});let c=e=>e===`all`?t.length:t.filter(t=>t.usage===e).length,u=t.filter(e=>e.usage===`orphan`).map(e=>e.ref),d=r===`all`?t:t.filter(e=>e.usage===r);return n(`div`,{className:`space-y-2`,children:[n(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[l(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Filter by usage`,children:ft.map(e=>n(w,{size:`sm`,variant:r===e.id?`secondary`:`ghost`,"aria-pressed":r===e.id,className:r===e.id?`ring-1 ring-border`:void 0,onClick:()=>i(e.id),children:[e.label,l(`span`,{className:`text-foreground-subtle tabular-nums`,children:c(e.id)})]},e.id))}),u.length>0&&n(w,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:o||s,onClick:()=>a(u),children:[l(h,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Delete `,u.length,` orphan`,u.length===1?``:`s`]})]}),l(E,{columns:ht(e),rows:d,rowKey:e=>e.ref,minWidthPx:860,mobileMode:`scroll`,maxBodyHeight:k,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:t.length===0?`No value is stored in the keychain yet.`:`No stored value matches this filter.`})]})}function mt({owner:e}){return n(`span`,{className:`flex items-center gap-2`,children:[l(Le,{addonId:e,fallback:e===X?P:b,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),l(`span`,{className:`font-medium`,children:e===X?`Hub (system)`:e})]})}function ht({locked:e,onReveal:t,revealing:r}){return[{key:`owner`,header:`Owner`,render:e=>l(mt,{owner:e.owner}),sortValue:e=>e.owner},{key:`scope`,header:`Scope`,render:e=>l(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{key:`field`,header:`Field`,render:e=>l(K,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{key:`updated`,header:`Updated`,render:e=>G(e.updatedAt),sortValue:e=>e.updatedAt},{key:`last-read`,header:`Last read`,render:e=>G(e.lastReadAt),sortValue:e=>e.lastReadAt},{key:`status`,header:`Status`,render:e=>l(M,{variant:Y[e.usage].variant,title:Y[e.usage].hint,children:Y[e.usage].label}),sortValue:e=>Y[e.usage].rank},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:i=>n(w,{size:`sm`,variant:`ghost`,disabled:e||r,"aria-label":`Reveal ${i.fieldPath}`,title:e?`The keychain is locked`:`Reveal (audited)`,onClick:()=>t(i),children:[l(me,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Reveal`]})}]}function gt(e){return e instanceof Error?e.message:String(e)}function _t(e){let t=ne(),n=T(),r=Ce(),i=ge(),a=Ee(),o=xe(),s=F(),c=be(),l=Te(),u=async(t,r)=>{try{await r()}catch(e){await n({title:t,message:gt(e),variant:`danger`})}e()};return{busy:i.isPending||a.isPending||o.isPending||s.isPending,deleting:l.isPending,download:async()=>{await t({title:`Download the recovery key`,message:`This shows the MASTER key. Anyone holding it and a copy of the database can read every secret. Store it in a password manager, not on this machine.`,confirmLabel:`Show the key`,variant:`warning`})&&await u(`Download refused`,async()=>{let e=await i.mutateAsync({});await r({title:`Recovery key (fingerprint ${e.fingerprint})`,message:`Copy it now. It is not shown again until you ask for it again (audited).`,defaultValue:e.key,readOnly:!0,confirmLabel:`Done`})})},rotate:async()=>{await t({title:`Rotate the master key`,message:`The data key is re-wrapped under the configured master key; no value is re-encrypted. The previous wrap is kept until you purge it.`,confirmLabel:`Rotate`,variant:`warning`})&&await u(`Rotation refused`,async()=>{await n({title:`Rotated`,message:`New fingerprint ${(await a.mutateAsync({})).fingerprint}. Take a new recovery copy.`})})},purge:async()=>{await t({title:`Purge retired key wraps`,message:`Copies of the data key wrapped under a previous master key are deleted. After this, the previous master key opens nothing.`,confirmLabel:`Purge`,variant:`warning`})&&await u(`Purge refused`,async()=>{await o.mutateAsync({})})},reset:async()=>{await r({title:`Reset the keychain`,message:`Every stored value is archived (unreadable without the lost key) and every secret field reads "not set". A new session signing key signs everyone out, and the cluster secret is cleared. Type RESET KEYCHAIN to confirm.`,confirmLabel:`Reset`,validate:e=>e===`RESET KEYCHAIN`?null:`Type the confirmation exactly`})===`RESET KEYCHAIN`&&await u(`Reset refused`,async()=>{await s.mutateAsync({confirm:Me})})},acknowledgeReset:async()=>{await u(`Could not dismiss`,async()=>{await c.mutateAsync({})})},deleteOrphans:async e=>{await t({title:`Delete ${e.length} orphaned value${e.length===1?``:`s`}`,message:`No setting points at these values any more. The hub checks each one again before deleting; anything found in use is kept.`,confirmLabel:`Delete`,variant:`danger`})&&await u(`Delete refused`,async()=>{let t=await l.mutateAsync({refs:[...e]});t.kept.length>0&&await n({title:`Some values were kept`,message:`${t.deleted.length} deleted; ${t.kept.length} kept because they are in use again or their owner could not be read.`})})}}}t();var Z=`view`;function vt(){let[e,t]=Ne();return[e.get(Z)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(Z):r.set(Z,n),t(r,{replace:!0})}]}function yt(){let t=ke({}),i=Se({}),a=_e({limit:500}),o=ve({}),c=fe(),u=T(),[d,f]=vt(),[p,m]=s(`all`),[h,g]=s(null),_=_t(()=>{t.refetch(),i.refetch(),a.refetch(),o.refetch()}),v=t.data?.keychain.state===`locked`,y=r(()=>(i.data??[]).filter(e=>e.usage===`orphan`).length,[i.data]),b=r(()=>t.data===void 0?[]:Xe({status:t.data,reset:o.data?.reset??null,pendingReentry:o.data?.pendingReentry.length??0,orphans:y}),[t.data,o.data,y]),x={reset:o.data?.reset??null,pendingReentry:o.data?.pendingReentry??[],busy:_.busy,onReset:()=>void _.reset(),onAcknowledgeReset:()=>void _.acknowledgeReset(),onDownload:()=>void _.download(),onRotate:()=>void _.rotate(),onShowOrphans:()=>{m(`orphan`),f(`values`)}},S=async e=>{try{g({entry:e,value:(await c.mutateAsync({ref:e.ref})).value}),i.refetch()}catch(e){await u({title:`Reveal refused`,message:Pe(e),variant:`danger`})}},C=e(()=>g(null),[]);return n(V,{icon:D,title:`Secrets`,subtitle:`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`,children:[l(at,{notices:b,renderAction:e=>tt(e,x),renderDetail:e=>nt(e,x)}),t.data!==void 0&&l(lt,{status:t.data,busy:_.busy,onDownload:x.onDownload,onRotate:x.onRotate,onPurge:()=>void _.purge()}),n(le,{value:d,onValueChange:e=>f(e===`audit`?`audit`:`values`),children:[n(te,{children:[l(O,{value:`values`,children:`Stored values`}),l(O,{value:`audit`,children:`Audit`})]}),l(j,{value:`values`,children:l(pt,{secrets:i.data,locked:v,filter:p,onFilterChange:m,onReveal:e=>void S(e),revealing:c.isPending,onDeleteOrphans:e=>void _.deleteOrphans(e),deleting:_.deleting})}),l(j,{value:`audit`,children:l(et,{entries:a.data})})]}),l(dt,{revealed:h,onClose:C})]})}t();var Q=[[`system`]];function $(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function bt(){let e=o(),t=S(),r=ae(),i=_(),[a,c]=s(``),[d,f]=s(``),[p,m]=s(null),h=t.data?.location??null;u(()=>{c(h===null?``:$(h.latitude)),f(h===null?``:$(h.longitude))},[h]);let v=async()=>{await e.invalidateQueries({queryKey:Q})},y=async e=>{e.preventDefault();let t=Number(a),n=Number(d);if(a.trim()===``||d.trim()===``){m(`Enter both a latitude and a longitude, or press Clear.`);return}if(!Number.isFinite(t)||t<-90||t>90){m(`Latitude must be between -90 and 90 decimal degrees.`);return}if(!Number.isFinite(n)||n<-180||n>180){m(`Longitude must be between -180 and 180 decimal degrees.`);return}m(null),await r.mutateAsync({latitude:t,longitude:n}),await v()},b=async()=>{m(null),await r.mutateAsync(null),await v()},x=async()=>{m(null),await i.mutateAsync(),await v()},C=r.isPending||i.isPending||t.isLoading;return n(ye,{className:`space-y-3`,children:[n(`div`,{className:`flex items-start justify-between gap-3`,children:[n(`div`,{className:`flex items-start gap-2`,children:[l(Ae,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),l(`div`,{children:l(`h3`,{className:`text-sm font-medium`,children:`Site location`})})]}),h===null?l(M,{variant:`warning`,children:`Not configured`}):l(M,{variant:h.source===`operator-set`?`success`:`info`,children:h.source===`operator-set`?`Set by you`:`Derived from IP`})]}),h?.label!==void 0&&h.label!==``?n(`p`,{className:`text-xs text-muted-foreground`,children:[`Detected near `,h.label,`.`]}):null,h===null&&t.data?.derivationAttemptedAt!==null?n(`p`,{className:`text-xs text-warning`,children:[`Automatic detection from the public IP did not succeed`,t.data?.derivationError!==null&&t.data?.derivationError!==void 0?`: ${t.data.derivationError}`:`.`,` `,`It is not retried on its own — enter the coordinates, or press Detect.`]}):null,n(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:y,children:[n(`label`,{className:`flex flex-col gap-1 text-xs`,children:[l(`span`,{className:`text-muted-foreground`,children:`Latitude`}),l(z,{className:`w-40`,value:a,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>c(e.target.value),"aria-label":`Latitude`})]}),n(`label`,{className:`flex flex-col gap-1 text-xs`,children:[l(`span`,{className:`text-muted-foreground`,children:`Longitude`}),l(z,{className:`w-40`,value:d,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>f(e.target.value),"aria-label":`Longitude`})]}),l(w,{type:`submit`,disabled:C,children:`Save`}),n(w,{type:`button`,variant:`ghost`,disabled:C,onClick:x,children:[l(g,{className:`h-3.5 w-3.5 mr-1`}),`Detect from IP`]}),h===null?null:l(w,{type:`button`,variant:`ghost`,disabled:C,onClick:b,children:`Clear`})]}),p===null?null:l(`p`,{className:`text-xs text-danger`,children:p}),l(`p`,{className:`text-xs text-muted-foreground`,children:`WGS84 decimal degrees. Detect asks a public geo-IP service once and will not overwrite a value you typed — clear it first.`})]})}function xt(){let{nodes:e,isLoading:t}=y(),r=e.find(e=>e.isHub&&e.isOnline),i=r?.addons.map(e=>e.addonId)??[];return n(V,{children:[l(bt,{}),t?l(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:`Loading hub topology…`}):r?i.length===0?l(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:`No addons installed on the hub yet.`}):l(Fe,{nodeId:r.id,addonIds:i,level:`global`}):n(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12`,children:[l(R,{className:`h-8 w-8 opacity-30`}),l(`p`,{children:`No online hub node found.`}),l(`p`,{className:`text-xs`,children:`Settings will appear once the hub is reachable.`})]})]})}function St(){return l(`div`,{className:`flex flex-col p-2 sm:p-4`,children:l(Ie,{defaultTab:`settings`,tabs:[{id:`settings`,label:`Settings`,icon:R,content:l(xt,{})},{id:`secrets`,label:`Secrets`,icon:D,content:l(yt,{}),ownedParams:[`view`]},{id:`capabilities`,label:`Capabilities`,icon:B,content:l(qe,{})}]})})}export{St as SystemPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{vt as e}from"./player-overlays-D9aoM64J.js";var t=e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]);export{t};
|