@camstack/addon-admin-ui 1.2.520 → 1.2.521
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/assets/{AddonAssetIcon-Do54wTZ7.js → AddonAssetIcon-DIfNr6QF.js} +1 -1
- package/dist/assets/{Addons-B1OJ_ktZ.js → Addons-D8e5UEhk.js} +1 -1
- package/dist/assets/{AdminPage-BmoKOToB.js → AdminPage-DPm4iuSn.js} +1 -1
- package/dist/assets/{AdminSectionedPage-O0ffiJOS.js → AdminSectionedPage-B1FFlzAp.js} +1 -1
- package/dist/assets/AiProfiles-_jjOpe29.js +3 -0
- package/dist/assets/{BrokerEditorDialog-CcvbGDox.js → BrokerEditorDialog-CMa1f8kC.js} +1 -1
- package/dist/assets/Build-SkecHiHh.js +40 -0
- package/dist/assets/{Calendars-DeDcWHS-.js → Calendars-BncAsHLV.js} +1 -1
- package/dist/assets/{Cluster-CZB476Cv.js → Cluster-BtPubX4s.js} +1 -1
- package/dist/assets/{ComposedDeviceEditDialog-DiO4bitz.js → ComposedDeviceEditDialog-BHCTUKU-.js} +1 -1
- package/dist/assets/CompositionBlockEditor-ImrFV2Gk.js +2 -0
- package/dist/assets/{CompositionEditorPage-caLz4h3I.js → CompositionEditorPage-D4Sj47wU.js} +1 -1
- package/dist/assets/{Data-Cpi9Lb2k.js → Data-DGUMhXre.js} +1 -1
- package/dist/assets/{DeviceDetail-SAboiNCE.js → DeviceDetail-CwB8tpfD.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-C5Oeqy94.js → DeviceDoActionFields-B08_5fN_.js} +1 -1
- package/dist/assets/{Devices-DArtILxr.js → Devices-B-o-SYft.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-B-NlJHwD.js → EmbedPlayerPage-BCAMYXmH.js} +1 -1
- package/dist/assets/{History-B_xZFQt7.js → History-CkZOzm2S.js} +1 -1
- package/dist/assets/{Identity-Cawa92L2.js → Identity-D-mKJp3i.js} +1 -1
- package/dist/assets/{IntegrationDetail-D6gLTapX.js → IntegrationDetail-Ba7jt4aH.js} +1 -1
- package/dist/assets/{IntegrationHub-vZ23z1RD.js → IntegrationHub-D3NNWcI3.js} +1 -1
- package/dist/assets/{Integrations-BLhvc6uB.js → Integrations-DfCvoh1h.js} +1 -1
- package/dist/assets/{Integrations-Bt-5ZNBV.js → Integrations-DzVbMY51.js} +1 -1
- package/dist/assets/{Library-K2waPmh-.js → Library-CIdnKcUl.js} +1 -1
- package/dist/assets/{Locations-GaQ-Vlg2.js → Locations-BMUiqhX7.js} +1 -1
- package/dist/assets/{Logs-8qT_HE5j.js → Logs-Cr5Ev4Yn.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-B599Qff8.js → MaskShapeCanvas-Bv7J_UVF.js} +1 -1
- package/dist/assets/{MotionZonesSettings-kGwQFrli.js → MotionZonesSettings-BZxXQ1bq.js} +1 -1
- package/dist/assets/{MyAccess-A5l6WoMd.js → MyAccess-egWpZOj7.js} +1 -1
- package/dist/assets/{Network-B_HZ4sjm.js → Network-DQwRnVG_.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-Ccww7SgZ.js → NodeAddonsSettingsPanel-B9vvxBEQ.js} +1 -1
- package/dist/assets/Notifications-B7GkPWCE.js +1 -0
- package/dist/assets/{Pipeline-7I-tbGWA.js → Pipeline-L7YohUe9.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-D3OKCG5L.js → PrivacyMaskSettings-Bic1_gT9.js} +1 -1
- package/dist/assets/{Recordings-Dqxrdll7.js → Recordings-CNhL7oIf.js} +1 -1
- package/dist/assets/{RemoteGrid-BC7RcI7j.js → RemoteGrid-Ttvy6q8V.js} +1 -1
- package/dist/assets/{ScanNetworkModal-De1BMqEu.js → ScanNetworkModal-B6vWwCe8.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BWwBdarY.js → SceneMonitorEditor-Bd7aOOIg.js} +1 -1
- package/dist/assets/{SessionsList-DK9sBB3z.js → SessionsList--VxRl_LS.js} +1 -1
- package/dist/assets/{Showroom-bS5UisOb.js → Showroom-UkIbrPnX.js} +1 -1
- package/dist/assets/{System-CoCWu43h.js → System-QDZtQXm_.js} +1 -1
- package/dist/assets/{Templates-DIMuzzu_.js → Templates-C43xppeu.js} +1 -1
- package/dist/assets/{Terminal-CaIDL65f.js → Terminal-5v2dzxpg.js} +1 -1
- package/dist/assets/{Viewer-BzxcMFB5.js → Viewer-B92j2D9F.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DvIAWVsR.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DugEb7xj.js} +1 -1
- package/dist/assets/{addon-icons-context-D-3KCr36.js → addon-icons-context-CDyNgrka.js} +1 -1
- package/dist/assets/{archive-sIPC64K9.js → archive-BKuD6-O9.js} +1 -1
- package/dist/assets/{assignment-candidates-C_UoiwJK.js → assignment-candidates-CvlbrbgK.js} +1 -1
- package/dist/assets/{authed-media-BE3neYoh.js → authed-media-DxWmG5JA.js} +1 -1
- package/dist/assets/{bell-off-DBYFNI8u.js → bell-off-7L6K5pJk.js} +1 -1
- package/dist/assets/{board-model-CeWFKx9n.js → board-model-CZOb3LmO.js} +1 -1
- package/dist/assets/{boxes-5j10egHw.js → boxes-BYgmIZEw.js} +1 -1
- package/dist/assets/circle-slash-DSfcxndq.js +1 -0
- package/dist/assets/client-Clemlz5W.js +674 -0
- package/dist/assets/{cloud-upload-CUkN17bl.js → cloud-upload-C40Dp7qu.js} +1 -1
- package/dist/assets/crop-CnSchINM.js +1 -0
- package/dist/assets/{device-integration-icon-DUQvGDM8.js → device-integration-icon-CLK4k1ae.js} +1 -1
- package/dist/assets/device-picker-model-ojy8FewR.js +1 -0
- package/dist/assets/dist-B-uSoSKi.js +674 -0
- package/dist/assets/{dist-dCyhYCji.js → dist-CJ9iy42m.js} +1 -1
- package/dist/assets/{file-up-DF9281zn.js → file-up-DhY5nof7.js} +1 -1
- package/dist/assets/{format-Ctn7h3o7.js → format-CvKyF2QM.js} +1 -1
- package/dist/assets/{hard-drive-download-YoDQjZ6G.js → hard-drive-download-gFidUJGC.js} +1 -1
- package/dist/assets/{hostInit-BqZN7ExA.js → hostInit-CDWllEW4.js} +1 -1
- package/dist/assets/i18n-C1QctlOB.js +1 -0
- package/dist/assets/{icons-CUtj9rug.js → icons-DrXFX-WI.js} +1 -1
- package/dist/assets/{index-s2JBApLj.js → index-D3Yx0Smp.js} +3 -3
- package/dist/assets/{key-BpA5yjS5.js → key-CKmpBvKe.js} +1 -1
- package/dist/assets/{key-round-BbwlZYgP.js → key-round-DMWVlifP.js} +1 -1
- package/dist/assets/{layers-Bxrx5612.js → layers-Bo1tC_4O.js} +1 -1
- package/dist/assets/{linked-devices-model-4X2JNgtv.js → linked-devices-model-D9TIS2pY.js} +1 -1
- package/dist/assets/{list-ordered-BQZRweJv.js → list-ordered-BAebxGoz.js} +1 -1
- package/dist/assets/{location-owned-usage-Dwc8i-A6.js → location-owned-usage-B3nr7gWQ.js} +1 -1
- package/dist/assets/{log-in-BFtLVkKt.js → log-in-CUgGOn9k.js} +1 -1
- package/dist/assets/{memory-stick-65f0Nh--.js → memory-stick-CsWM7ppk.js} +1 -1
- package/dist/assets/{message-square-plus-Cz97-8Ea.js → message-square-plus-C-LDprie.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-bfee715d.js → mf-entry-bootstrap-0-e1103afa.js} +2 -2
- package/dist/assets/{mic-off-C90AfhxH.js → mic-off-BmNdC4XW.js} +1 -1
- package/dist/assets/{monitor-off-Kj0KouMn.js → monitor-off-DhTBAYUp.js} +1 -1
- package/dist/assets/{monitor-smartphone-dJjQFha0.js → monitor-smartphone-6kCGO3r1.js} +1 -1
- package/dist/assets/mount-ojy8FewR.js +1 -0
- package/dist/assets/{player-overlays-Cl9fdVyE.js → player-overlays-C_WpL6a6.js} +1 -1
- package/dist/assets/{recycle-B_n3HNql.js → recycle-Di1EQ0Qy.js} +1 -1
- package/dist/assets/remoteEntry-B3Z2iNH7.js +1 -0
- package/dist/assets/{ruler-DFksgfFc.js → ruler-cSAzAdF0.js} +1 -1
- package/dist/assets/{scan-eye-Dcs85qj4.js → scan-eye-6vO-dwZC.js} +1 -1
- package/dist/assets/{scissors-DpVQCMjY.js → scissors-MIPuZwTY.js} +1 -1
- package/dist/assets/{search-x-BUboqisx.js → search-x-Jgy5Olce.js} +1 -1
- package/dist/assets/{send-i8_gi4Wv.js → send-CnArxdfm.js} +1 -1
- package/dist/assets/{settings-2-BuOeZPiK.js → settings-2-Cc7_8hT4.js} +1 -1
- package/dist/assets/{shapes-DGstG7DR.js → shapes-B6yDXStU.js} +1 -1
- package/dist/assets/{sigma-B0KIxXLC.js → sigma-q5eaqxJ5.js} +1 -1
- package/dist/assets/{speaker-C7Ctczma.js → speaker-CbeO5md6.js} +1 -1
- package/dist/assets/src-BuD4BDe3.js +67 -0
- package/dist/assets/{step-inspector-model-Du5MgFTI.js → step-inspector-model-Dm1vwliM.js} +1 -1
- package/dist/assets/{table-2-Bi2N6ehZ.js → table-2-Dl4UBoV9.js} +1 -1
- package/dist/assets/{timer-reset-C-DbgYsd.js → timer-reset-Bp1VJ4jU.js} +1 -1
- package/dist/assets/{unlink-DOrqvhrS.js → unlink-DoHrrlyB.js} +1 -1
- package/dist/assets/{usb-D21IcPqp.js → usb-uGk5FuUX.js} +1 -1
- package/dist/assets/{use-device-bound-caps-DUbLU0h-.js → use-device-bound-caps-Di0CbhM4.js} +1 -1
- package/dist/assets/{use-scenes-feed-Cc_FfCf0.js → use-scenes-feed-hWCFwCtN.js} +1 -1
- package/dist/assets/{use-stationary-objects-C9cIQpEH.js → use-stationary-objects-DJ9JfRWk.js} +1 -1
- package/dist/assets/useEventInvalidation-ojy8FewR.js +1 -0
- package/dist/assets/{useNodeUrlSelection-B-iNHDOR.js → useNodeUrlSelection-CW3xhZq4.js} +1 -1
- package/dist/assets/user-round-BdixCoAv.js +1 -0
- package/dist/assets/{user-x-dk19_EsK.js → user-x-KqDnAcpq.js} +1 -1
- package/dist/assets/{variable-jCYthbGt.js → variable-vSgKlDpd.js} +1 -1
- package/dist/assets/{video-BbvU47vV.js → video-DgFhEP51.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DOT_MvML.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CmMSAYDD.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +519 -62
- package/package.json +1 -1
- package/dist/assets/AiProfiles-koWE1ekm.js +0 -3
- package/dist/assets/Build-DkW1vw1Z.js +0 -40
- package/dist/assets/CompositionBlockEditor-BQbgk5OR.js +0 -2
- package/dist/assets/Notifications-DxoAS5SX.js +0 -1
- package/dist/assets/circle-slash-VFJ46qWN.js +0 -1
- package/dist/assets/client-BmfSvq-t.js +0 -674
- package/dist/assets/crop-DwwjG8X9.js +0 -1
- package/dist/assets/device-picker-model-C2rxDYB3.js +0 -1
- package/dist/assets/dist-CGa31Bpn.js +0 -674
- package/dist/assets/i18n-CWf2gqjI.js +0 -1
- package/dist/assets/mount-C2rxDYB3.js +0 -1
- package/dist/assets/remoteEntry-Bgu2wj6M.js +0 -1
- package/dist/assets/src-Cjqv1L1_.js +0 -67
- package/dist/assets/useEventInvalidation-C2rxDYB3.js +0 -1
- package/dist/assets/user-round-CCHLAyrG.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Gr as te,Ht as ne,K as re,U as ie,X as ae,da as oe,dt as se,ma as ce,n as le,nr as ue,tn as de,z as c}from"./player-overlays-Cl9fdVyE.js";import{n as fe,t as pe}from"./mic-off-C90AfhxH.js";import{MaskShapeCanvas as me}from"./MaskShapeCanvas-B599Qff8.js";s();var l=`Microphone`,u=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function he(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:l,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:u}}function ge(e){return!e.available||e.on===null?null:{enabled:!e.on}}var d=120,_e=`privacy-mask`,f=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,p=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function m(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function ve(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function ye(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function h({deviceId:s}){let l=ce(),u=re(se().trpcClient,s),[h,g]=o(null),[_,v]=o(!1),[y,b]=o(!1),[x,S]=o(null),[C,w]=o(null),[T,E]=o(!1),[D,O]=o(!1),[k,A]=o(null),[j,M]=o(null),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),z=t(!1);a(()=>{if(!u)return;let e=!1;return z.current=!1,g(null),v(!1),b(!1),S(null),w(null),O(!1),A(null),M(null),P(null),I(null),R(null),(async()=>{try{let t=await u.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(g(t),z.current)return;let n=await u.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){b(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};w(r),S(r),P(n.audioEnabled)}catch(t){if(e)return;ie(t)?v(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[u]);let B=n(()=>x!==null&&C!==null&&(x.enabled!==C.enabled||!ye(x.regions,C.regions)),[x,C]),V=x?x.regions.length:0,H=h?h.maxRegions:0,U=t(0);a(()=>{U.current=H},[H]);let W=H>0&&V>=H,be=r(()=>{S(e=>e&&{...e,enabled:!e.enabled})},[]),G=r(e=>{A(typeof e==`number`?e:null)},[]),K=n(()=>x?x.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:l(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})})):[],[x,l]),q=r((e,t)=>{let n=m(t);n&&S(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=r(e=>{let t=m(e);t&&(M(null),S(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=ve(e.regions),i={id:r,enabled:!0,shape:t};return A(r),{...e,regions:[...e.regions,i]}}))},[]),Y=r(e=>{O(!0),A(null),M(e)},[]),xe=r(e=>{O(!0),M(null),A(e)},[]),Se=r(e=>{A(t=>t===e?null:t),S(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),Ce=r(()=>{M(null),A(null),C&&S({enabled:C.enabled,regions:C.regions})},[C]),we=r(async()=>{if(!(!u||!x)){E(!0);try{await u.privacyMask?.setMask({patch:{enabled:x.enabled,regions:[...x.regions]}});let e=await u.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};w(t),S(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{E(!1)}}},[u,x]),X=he({supportsAudioMute:h===null?null:h.supportsAudioMute,audioEnabled:N,pendingOn:F}),Z=r(async()=>{let e=ge(X);if(!(!u||e===null)){I(e.enabled),R(null);try{await u.privacyMask?.setAudioEnabled(e);let t=await u.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[u,X]),Te=r(()=>{O(e=>(e&&(M(null),A(null)),!e))},[]),Q=h?.supportedShapes??[];le(n(()=>D&&!_&&h&&x?{id:_e,order:d,node:i(me,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:h.polygonVertices,selectedId:k,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:j})}:null,[D,_,h,x,K,Q,k,G,q,J,j]));let Ee=h?.supportedShapes.includes(`rect`)??!1,De=h?.supportedShapes.includes(`polygon`)??!1,$=h!==null&&(h.maxRegions<=0||h.supportedShapes.length===0),Oe=!_&&!$&&!y&&h!==null&&x!==null;return u?i(ae,{title:l(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:i(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:e(`div`,{className:`flex flex-col gap-3`,children:[_||$?i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.unsupported`,`This camera doesn't support an on-board privacy mask.`)}):y?i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.unreadable`,`This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable.`)}):Oe?e(ee,{children:[i(`p`,{className:`${c} leading-relaxed`,children:i(oe,{uiKey:`uiLibrary.privacyMaskSettings.help`,fallback:`Toggle <0>Edit mask</0> to draw blanked-out zones on the live frame, then <1>Save</1> to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`,components:[i(`strong`,{className:`text-foreground`},`edit`),i(`strong`,{className:`text-foreground`},`save`)]})}),e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`button`,{type:`button`,onClick:Te,disabled:T,"aria-pressed":D,className:D?p:f,children:D?l(`uiLibrary.privacyMaskSettings.doneEditing`,`Done editing`):l(`uiLibrary.privacyMaskSettings.editMask`,`Edit mask`)}),i(`button`,{type:`button`,onClick:be,disabled:T,"aria-pressed":x.enabled,className:x.enabled?p:f,children:x.enabled?l(`uiLibrary.privacyMaskSettings.maskOn`,`Mask on`):l(`uiLibrary.privacyMaskSettings.maskOff`,`Mask off`)}),Ee&&i(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:T||W,"aria-pressed":j===`rect`,className:j===`rect`?p:f,title:W?l(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):l(`uiLibrary.privacyMaskSettings.addRect`,`Add a rectangle zone`),children:l(`uiLibrary.privacyMaskSettings.rectButton`,`+ Rect`)}),De&&i(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:T||W,"aria-pressed":j===`polygon`,className:j===`polygon`?p:f,title:W?l(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):l(`uiLibrary.privacyMaskSettings.addPolygon`,`Add a polygon zone`),children:l(`uiLibrary.privacyMaskSettings.polygonButton`,`+ Polygon`)}),i(`span`,{className:`${c} ml-1 tabular-nums`,children:l(`uiLibrary.privacyMaskSettings.zoneCount`,`{{active}} / {{max}} zones`,{active:V,max:H})}),i(`span`,{className:`flex-1`}),i(`button`,{type:`button`,onClick:Ce,disabled:T||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:l(`uiLibrary.privacyMaskSettings.revert`,`Revert`)}),i(`button`,{type:`button`,onClick:()=>void we(),disabled:T||!B,className:p,children:T?l(`uiLibrary.privacyMaskSettings.saving`,`Saving…`):l(`uiLibrary.privacyMaskSettings.save`,`Save`)})]}),V>0?i(`div`,{className:`flex flex-col gap-1`,children:x.regions.map(t=>{let n=k===t.id,r=t.shape.kind===`polygon`?fe:de;return e(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${n?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[e(`button`,{type:`button`,onClick:()=>xe(t.id),disabled:T,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),i(`span`,{children:l(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:t.id})}),i(`span`,{className:`text-foreground-faint capitalize`,children:t.shape.kind})]}),i(`button`,{type:`button`,onClick:()=>Se(t.id),disabled:T,"aria-label":l(`uiLibrary.privacyMaskSettings.deleteZoneN`,`Delete zone {{id}}`,{id:t.id}),title:l(`uiLibrary.privacyMaskSettings.deleteZone`,`Delete zone`),className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:i(ne,{className:`h-3.5 w-3.5`})})]},t.id)})}):null]}):i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.loading`,`Loading the camera's privacy mask…`)}),X.supported&&e(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[i(`button`,{type:`button`,role:`switch`,"aria-label":X.label,"aria-checked":X.on===!0,disabled:!X.available||F!==null,onClick:()=>void Z(),title:X.on===null?l(`uiLibrary.privacyMaskSettings.micTitleUnknown`,`Microphone — state unknown; the camera did not answer.`):X.on?l(`uiLibrary.privacyMaskSettings.micTitleOn`,`The camera is capturing sound. Turning it off: {{cost}}`,{cost:X.costWhenOff}):l(`uiLibrary.privacyMaskSettings.micTitleOff`,`The camera is silent. {{cost}}`,{cost:X.costWhenOff}),className:X.on===!1||X.on===null?f:p,children:e(`span`,{className:`inline-flex items-center gap-1.5`,children:[X.on===!1?i(pe,{className:`h-3.5 w-3.5`}):i(ue,{className:`h-3.5 w-3.5`}),X.on===null?l(`uiLibrary.privacyMaskSettings.micUnknown`,`Microphone unknown`):X.on?l(`uiLibrary.privacyMaskSettings.micOn`,`Microphone on`):l(`uiLibrary.privacyMaskSettings.micOff`,`Microphone off`)]})}),i(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?X.on===null?l(`uiLibrary.privacyMaskSettings.micNotReported`,`The camera did not report its microphone, so this state is unknown.`):X.costWhenOff:l(`uiLibrary.privacyMaskSettings.writeFailed`,`Write failed: {{reason}}`,{reason:L})})]})]})}):null}export{h as PrivacyMaskSettings};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Gr as te,Ht as ne,K as re,U as ie,X as ae,da as oe,dt as se,ma as ce,n as le,nr as ue,tn as de,z as c}from"./player-overlays-C_WpL6a6.js";import{n as fe,t as pe}from"./mic-off-BmNdC4XW.js";import{MaskShapeCanvas as me}from"./MaskShapeCanvas-Bv7J_UVF.js";s();var l=`Microphone`,u=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function he(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:l,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:u}}function ge(e){return!e.available||e.on===null?null:{enabled:!e.on}}var d=120,_e=`privacy-mask`,f=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,p=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function m(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function ve(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function ye(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function h({deviceId:s}){let l=ce(),u=re(se().trpcClient,s),[h,g]=o(null),[_,v]=o(!1),[y,b]=o(!1),[x,S]=o(null),[C,w]=o(null),[T,E]=o(!1),[D,O]=o(!1),[k,A]=o(null),[j,M]=o(null),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),z=t(!1);a(()=>{if(!u)return;let e=!1;return z.current=!1,g(null),v(!1),b(!1),S(null),w(null),O(!1),A(null),M(null),P(null),I(null),R(null),(async()=>{try{let t=await u.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(g(t),z.current)return;let n=await u.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){b(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};w(r),S(r),P(n.audioEnabled)}catch(t){if(e)return;ie(t)?v(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[u]);let B=n(()=>x!==null&&C!==null&&(x.enabled!==C.enabled||!ye(x.regions,C.regions)),[x,C]),V=x?x.regions.length:0,H=h?h.maxRegions:0,U=t(0);a(()=>{U.current=H},[H]);let W=H>0&&V>=H,be=r(()=>{S(e=>e&&{...e,enabled:!e.enabled})},[]),G=r(e=>{A(typeof e==`number`?e:null)},[]),K=n(()=>x?x.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:l(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})})):[],[x,l]),q=r((e,t)=>{let n=m(t);n&&S(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=r(e=>{let t=m(e);t&&(M(null),S(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=ve(e.regions),i={id:r,enabled:!0,shape:t};return A(r),{...e,regions:[...e.regions,i]}}))},[]),Y=r(e=>{O(!0),A(null),M(e)},[]),xe=r(e=>{O(!0),M(null),A(e)},[]),Se=r(e=>{A(t=>t===e?null:t),S(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),Ce=r(()=>{M(null),A(null),C&&S({enabled:C.enabled,regions:C.regions})},[C]),we=r(async()=>{if(!(!u||!x)){E(!0);try{await u.privacyMask?.setMask({patch:{enabled:x.enabled,regions:[...x.regions]}});let e=await u.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};w(t),S(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{E(!1)}}},[u,x]),X=he({supportsAudioMute:h===null?null:h.supportsAudioMute,audioEnabled:N,pendingOn:F}),Z=r(async()=>{let e=ge(X);if(!(!u||e===null)){I(e.enabled),R(null);try{await u.privacyMask?.setAudioEnabled(e);let t=await u.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[u,X]),Te=r(()=>{O(e=>(e&&(M(null),A(null)),!e))},[]),Q=h?.supportedShapes??[];le(n(()=>D&&!_&&h&&x?{id:_e,order:d,node:i(me,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:h.polygonVertices,selectedId:k,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:j})}:null,[D,_,h,x,K,Q,k,G,q,J,j]));let Ee=h?.supportedShapes.includes(`rect`)??!1,De=h?.supportedShapes.includes(`polygon`)??!1,$=h!==null&&(h.maxRegions<=0||h.supportedShapes.length===0),Oe=!_&&!$&&!y&&h!==null&&x!==null;return u?i(ae,{title:l(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:i(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:e(`div`,{className:`flex flex-col gap-3`,children:[_||$?i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.unsupported`,`This camera doesn't support an on-board privacy mask.`)}):y?i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.unreadable`,`This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable.`)}):Oe?e(ee,{children:[i(`p`,{className:`${c} leading-relaxed`,children:i(oe,{uiKey:`uiLibrary.privacyMaskSettings.help`,fallback:`Toggle <0>Edit mask</0> to draw blanked-out zones on the live frame, then <1>Save</1> to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`,components:[i(`strong`,{className:`text-foreground`},`edit`),i(`strong`,{className:`text-foreground`},`save`)]})}),e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`button`,{type:`button`,onClick:Te,disabled:T,"aria-pressed":D,className:D?p:f,children:D?l(`uiLibrary.privacyMaskSettings.doneEditing`,`Done editing`):l(`uiLibrary.privacyMaskSettings.editMask`,`Edit mask`)}),i(`button`,{type:`button`,onClick:be,disabled:T,"aria-pressed":x.enabled,className:x.enabled?p:f,children:x.enabled?l(`uiLibrary.privacyMaskSettings.maskOn`,`Mask on`):l(`uiLibrary.privacyMaskSettings.maskOff`,`Mask off`)}),Ee&&i(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:T||W,"aria-pressed":j===`rect`,className:j===`rect`?p:f,title:W?l(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):l(`uiLibrary.privacyMaskSettings.addRect`,`Add a rectangle zone`),children:l(`uiLibrary.privacyMaskSettings.rectButton`,`+ Rect`)}),De&&i(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:T||W,"aria-pressed":j===`polygon`,className:j===`polygon`?p:f,title:W?l(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):l(`uiLibrary.privacyMaskSettings.addPolygon`,`Add a polygon zone`),children:l(`uiLibrary.privacyMaskSettings.polygonButton`,`+ Polygon`)}),i(`span`,{className:`${c} ml-1 tabular-nums`,children:l(`uiLibrary.privacyMaskSettings.zoneCount`,`{{active}} / {{max}} zones`,{active:V,max:H})}),i(`span`,{className:`flex-1`}),i(`button`,{type:`button`,onClick:Ce,disabled:T||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:l(`uiLibrary.privacyMaskSettings.revert`,`Revert`)}),i(`button`,{type:`button`,onClick:()=>void we(),disabled:T||!B,className:p,children:T?l(`uiLibrary.privacyMaskSettings.saving`,`Saving…`):l(`uiLibrary.privacyMaskSettings.save`,`Save`)})]}),V>0?i(`div`,{className:`flex flex-col gap-1`,children:x.regions.map(t=>{let n=k===t.id,r=t.shape.kind===`polygon`?fe:de;return e(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${n?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[e(`button`,{type:`button`,onClick:()=>xe(t.id),disabled:T,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),i(`span`,{children:l(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:t.id})}),i(`span`,{className:`text-foreground-faint capitalize`,children:t.shape.kind})]}),i(`button`,{type:`button`,onClick:()=>Se(t.id),disabled:T,"aria-label":l(`uiLibrary.privacyMaskSettings.deleteZoneN`,`Delete zone {{id}}`,{id:t.id}),title:l(`uiLibrary.privacyMaskSettings.deleteZone`,`Delete zone`),className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:i(ne,{className:`h-3.5 w-3.5`})})]},t.id)})}):null]}):i(`p`,{className:`${c} leading-relaxed`,children:l(`uiLibrary.privacyMaskSettings.loading`,`Loading the camera's privacy mask…`)}),X.supported&&e(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[i(`button`,{type:`button`,role:`switch`,"aria-label":X.label,"aria-checked":X.on===!0,disabled:!X.available||F!==null,onClick:()=>void Z(),title:X.on===null?l(`uiLibrary.privacyMaskSettings.micTitleUnknown`,`Microphone — state unknown; the camera did not answer.`):X.on?l(`uiLibrary.privacyMaskSettings.micTitleOn`,`The camera is capturing sound. Turning it off: {{cost}}`,{cost:X.costWhenOff}):l(`uiLibrary.privacyMaskSettings.micTitleOff`,`The camera is silent. {{cost}}`,{cost:X.costWhenOff}),className:X.on===!1||X.on===null?f:p,children:e(`span`,{className:`inline-flex items-center gap-1.5`,children:[X.on===!1?i(pe,{className:`h-3.5 w-3.5`}):i(ue,{className:`h-3.5 w-3.5`}),X.on===null?l(`uiLibrary.privacyMaskSettings.micUnknown`,`Microphone unknown`):X.on?l(`uiLibrary.privacyMaskSettings.micOn`,`Microphone on`):l(`uiLibrary.privacyMaskSettings.micOff`,`Microphone off`)]})}),i(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?X.on===null?l(`uiLibrary.privacyMaskSettings.micNotReported`,`The camera did not report its microphone, so this state is unknown.`):X.costWhenOff:l(`uiLibrary.privacyMaskSettings.writeFailed`,`Write failed: {{reason}}`,{reason:L})})]})]})}):null}export{h as PrivacyMaskSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ht as l,Or as u,Pi as d,Vr as f,Y as p,Zr as m,ca as h,dt as g,fr as _,gt as v,mi as y,st as b,ti as x,zt as S}from"./player-overlays-Cl9fdVyE.js";import{jo as C}from"./client-BmfSvq-t.js";import{n as w,t as T}from"./scissors-DpVQCMjY.js";import{Au as E,Cu as D,Dn as O,Du as k,Ei as A,Eu as j,Fc as M,Mo as N,Mr as P,Mu as F,Nc as ee,Nu as te,On as ne,Ou as re,Sr as ie,Su as ae,Tu as oe,Vc as se,Zd as I,Zr as ce,_r as le,_u as ue,au as de,br as fe,bu as L,ef as R,ei as z,eu as pe,gr as me,iu as he,jr as B,ju as ge,ki as V,ku as _e,ml as ve,nu as ye,ou as be,ru as xe,su as Se,tu as H,vl as Ce,vr as we,wu as Te,xr as Ee,yu as De,zc as Oe}from"./src-Cjqv1L1_.js";import{t as U}from"./i18n-CWf2gqjI.js";import{t as W}from"./useTranslation-BJr-n0es.js";import{T as ke,k as Ae,pr as je}from"./index-s2JBApLj.js";import{t as Me}from"./AdminSectionedPage-O0ffiJOS.js";import{n as Ne}from"./authed-media-BE3neYoh.js";import{t as G}from"./format-size-DIxKXxtj.js";import{c as Pe,i as Fe,l as Ie,n as Le,o as Re,r as ze,s as Be,t as Ve,u as He}from"./location-owned-usage-Dwc8i-A6.js";o();var Ue=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],We={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Ge={columnKey:`at`,dir:`desc`};function Ke(e){return new Date(e).toLocaleString()}function qe(){let{t:n,i18n:i}=W(),[o,s]=a(`all`),{data:l,isLoading:u,isError:d}=ye({},{refetchOnWindowFocus:!1}),{data:f,isLoading:p,isError:m}=Oe({},{refetchOnWindowFocus:!1}),{data:g}=N({isCamera:!0,projection:`slim`}),v=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),y=t(()=>{let e=[...l??[],...f??[]];return(o===`all`?e:e.filter(e=>e.domain===o)).toSorted((e,t)=>t.at-e.at)},[l,f,o]),b=t(()=>{let e=[];return d&&o!==`events`&&e.push(n(`recordings.activitySection.domainRecordings`)),m&&o!==`recording`&&e.push(n(`common.events`)),e},[d,m,o,n]),x=t(()=>new Intl.ListFormat(i.language,{type:`conjunction`}).format(b),[b,i.language]),C=t(()=>[{key:`at`,header:n(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ke(e.at)})},{key:`domain`,header:n(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>r(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${We[e.domain]}`,children:e.domain})},{key:`op`,header:n(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>r(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:n(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>r(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:n(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:v.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?r(`span`,{className:`text-foreground-subtle`,children:n(`common.cluster`)}):r(`span`,{className:`text-foreground`,children:v.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:n(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>r(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:n(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>r(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?G(e.bytesReclaimed):`—`})}],[v,n]),w=u||p;return e(`div`,{className:`flex flex-col gap-4`,children:[r(`div`,{className:`flex items-center gap-1`,children:Ue.map(e=>r(`button`,{onClick:()=>s(e.value),className:`rounded px-2 py-1 text-xs font-medium ${o===e.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n(e.labelKey)},e.value))}),w&&y.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):y.length===0?b.length>0?r(B,{icon:S,title:n(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:n(`recordings.activitySection.theOpsLogDidNot`,`The {{value1}} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`,{value1:x})}):r(B,{icon:h,title:n(`recordings.activitySection.noActivityYet`,`No activity yet`),description:n(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):e(c,{children:[b.length>0&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[r(S,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:b.length,names:x})]}),r(O,{columns:C,rows:y,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:ne,defaultSort:Ge})]})]})}o();function Je(){let{t:n}=W(),i=N({isCamera:!0,projection:`slim`}),o=t(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[s,c]=a(null),l=s??o[0]?.id??null;return!i.isLoading&&o.length===0?r(B,{icon:d,title:n(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:n(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.recordingModeScheduleBandsAnd`,`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.`)})]}),e(`div`,{className:`flex items-center gap-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),r(`select`,{value:l??``,onChange:e=>c(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:o.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),l!==null&&r(ce,{deviceId:l,children:r(Ae,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}o();function Ye({types:n}){let{t:i}=W(),o=s(),c=b(),{data:l}=L({}),u=De(),d=t(()=>u.data??[],[u.data]),{data:f}=H({},{refetchOnWindowFocus:!1}),p=t(()=>Ve(l??[],f?.locations),[l,f?.locations]),[m,h]=a(null),[g,_]=a(null),v=()=>{o.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},y=te({onSuccess:v}),x=ue({onSuccess:v}),S=t(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[l]),C=async(e,t)=>{Ie(t)&&!await c({title:i(`pipeline.storageLocationsPanel.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:i(`pipeline.storageLocationsPanel.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Pe(t).consequence}),confirmLabel:i(`common.disable`,`Disable`),variant:`danger`})||y.mutate(Be(e,{mode:t}))},w=async e=>{if(await c({title:i(`pipeline.storageLocationsPanel.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:i(`pipeline.storageLocationsPanel.removesTheRecordFilesOn`,`Removes the record; files on disk are untouched.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`}))try{await x.mutateAsync({id:e.id})}catch(t){await c({title:i(`pipeline.storageLocationsPanel.deleteAnyway`,`Delete anyway?`),message:i(`pipeline.storageLocationsPanel.forcingNote`,{error:t instanceof Error?t.message:String(t)}),confirmLabel:i(`pipeline.storageLocationsPanel.forceDelete`,`Force delete`),variant:`danger`})&&x.mutate({id:e.id,force:!0})}},T=n.map(e=>d.find(t=>t.id===e)).filter(e=>e!==void 0);return e(`div`,{className:`space-y-3`,children:[T.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:i(`pipeline.storageLocationsPanel.noStorageLocationsDeclaredFor`,`No storage locations declared for this purpose.`)}):T.map(e=>r(Le,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:S.get(e.id)??[],onAdd:e=>h(e),onEdit:e=>_(e),onDelete:e=>{w(e)},ownedBytesById:p,onSetMode:(e,t)=>{C(e,t)}},e.id)),m!==null&&r(He,{initialType:m,onClose:()=>h(null),onCreated:()=>{v(),h(null)}}),g!==null&&r(Re,{location:g,onClose:()=>_(null),onSaved:()=>{v(),_(null)}})]})}o();var Xe=`pipeline-analytics`;function Ze(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 Qe(){let{t:n}=W(),i=s(),{nodes:a}=I(),{data:o,isLoading:c}=A({addonId:Xe}),l=Ze(o),u=V({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[a,l]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.theSingleNodeThatRuns`,`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.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Xe,patch:{postProcessingNodeId:e.target.value}})},disabled:u.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:d.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):e},e))}),u.isPending&&r(_,{className:`h-4 w-4 animate-spin text-primary`})]})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),r(Ye,{types:[`eventMedia`]})]})]})}o();var $e=[[`pipelineAnalytics`]],et=1440*60*1e3;function tt(e,t){return t.get(e)??U.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var nt=[{days:1},{days:7},{days:30},{days:90}];function rt(){let{t:i}=W(),o=s(),c=b(),[u,d]=a(30),[f,m]=a(null),{data:h,isLoading:g}=M({},{refetchOnWindowFocus:!1}),{data:v}=N({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),S=n(()=>{o.invalidateQueries({queryKey:$e})},[o]),C=se({onSuccess:S}),w=ee(),E=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:u}),message:i(`recordings.eventsManagementSection.permanentlyDeletesEveryEventMotion`,`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`),confirmLabel:i(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&C.mutate({olderThanMs:Date.now()-u*et,reason:`retention`})},[c,C,u,i]),D=n(async e=>{let t=tt(e.deviceId,y);if(await c({title:i(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:t}),message:i(`recordings.eventsManagementSection.deleteRowsMessage`,{count:e.rows,size:G(e.bytes)}),confirmLabel:i(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){m(null);try{let n=await w.mutateAsync({deviceId:e.deviceId});S();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){m(`0 events deleted for ${t}. Media still listed (${G(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}m(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){m(e instanceof Error?e.message:String(e))}}},[c,w,y,S,i]),k=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:tt(e.deviceId,y)})},{key:`rows`,header:i(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:i(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:G(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>e(`button`,{onClick:()=>{D(t)},disabled:w.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:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(l,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[y,D,w.isPending,i]);return g&&!h?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):h?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(p,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(x,{className:`h-3 w-3`}),footer:`across ${String(h.devices.length)} camera${h.devices.length===1?``:`s`}`,children:h.totalRows.toLocaleString()}),r(p,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:G(h.totalBytes)})]}),e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[r(`span`,{className:`text-foreground-subtle`,children:i(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),r(`select`,{value:u,onChange:e=>d(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:nt.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(`button`,{onClick:()=>{E()},disabled:C.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:[C.isPending?r(_,{className:`h-3 w-3 animate-spin`}):r(T,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),h.devices.length===0?r(B,{icon:x,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(O,{columns:k,rows:[...h.devices],rowKey:e=>e.deviceId,minWidthPx:480}),f===null?null:r(`p`,{className:f.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:f})]}):r(B,{icon:x,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function it(){let{t}=W();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.eventStore`,`Event store`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),r(`div`,{className:`mt-3`,children:r(rt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),r(`div`,{className:`mt-3`,children:r(Qe,{})})]})]})}function at(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 ot(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function st(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`${ot(e)} · ${o}`}function ct(e,t){let n=e-t;if(n<=0)return U.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return U.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?U.t(`helpers.exportFormat.inHours`,{n:String(i)}):U.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function lt(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})}o();var ut=[`high`,`mid`,`low`],dt=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],ft=10080*60*1e3;function pt(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 mt({onClose:n,onCreated:i}){let{t:o}=W(),s=N({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[l,u]=a(``),[d,p]=a(`high`),[m,h]=a(pt(60)),[g,_]=a(pt(0)),[v,y]=a(1),[b,x]=a(!0),[S,C]=a(``),[w,T]=a(null),E=l===``?c[0]?.id??null:l,D=new Date(m).getTime(),O=new Date(g).getTime(),k=Number.isFinite(D)&&Number.isFinite(O)&&D<O,A=de({onSuccess:()=>{i(),n()},onError:e=>T(e instanceof Error?e.message:String(e))});return r(me,{open:!0,onOpenChange:e=>!e&&n(),children:e(we,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(Ee,{children:e(ie,{className:`flex items-center gap-1.5`,children:[r(f,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(le,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.camera`,`Camera`)}),r(`select`,{value:E??``,onChange:e=>u(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:c.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.profile`,`Profile`)}),r(`select`,{value:d,onChange:e=>p(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=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.from`,`From`)}),r(`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`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.to`,`To`)}),r(`input`,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.speed`,`Speed`)}),r(`select`,{value:v,onChange:e=>y(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:dt.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:o(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:o(`recordings.newExportModal.eGCourierAtThe`,`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`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(`input`,{type:`checkbox`,checked:b,disabled:v!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),o(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!k&&r(`p`,{className:`text-[11px] text-danger`,children:o(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),w&&r(`p`,{className:`text-[11px] text-danger`,children:w})]}),e(fe,{children:[r(z,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(z,{size:`sm`,onClick:()=>{if(E===null||!k)return;T(null);let e=S.trim();A.mutate({deviceId:E,profile:d,fromMs:D,toMs:O,options:{includeAudio:b,maxLifeMs:ft,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:E===null||!k||A.isPending,children:A.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var ht=[[`recordingExport`]],gt={queued:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.queued`},rendering:{cls:`bg-primary/10 text-primary`,labelKey:`recordings.exportsSection.rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,labelKey:`recordings.exportsSection.ready`},failed:{cls:`bg-danger/10 text-danger`,labelKey:`recordings.exportsSection.failed`},expired:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.expired`},deleted:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.deleted`}};function _t(){let{data:e,isLoading:n}=Se({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=R(C.RecordingExportProgress,e=>e.exportId),{map:i}=R(C.RecordingExportCompleted,e=>e.exportId),{map:a}=R(C.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>lt(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function vt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function yt(){let{t:i}=W(),o=s(),[c,u]=a(!1),d=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=b(),h=g().trpcClient,v=vt(6e4),{rows:x,isLoading:S}=_t(),{data:C}=N({isCamera:!0,projection:`slim`}),w=t(()=>{let e=new Map;for(let t of C??[])e.set(t.id,t.name);return e},[C]),T=n(()=>{o.invalidateQueries({queryKey:ht})},[o]),E=he({onSuccess:T}),D=be({onSuccess:T}),[k,A]=a(null),j=n(async e=>{A(e.id);try{let{url:t}=await h.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Ne(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),T()}finally{A(null)}},[h,T]),M=n(async e=>{await p({title:i(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:i(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:i(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&E.mutate({exportId:e.id})},[p,E,i]),P=n(async e=>{await p({title:i(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:i(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`})&&D.mutate({exportId:e.id})},[p,D,i]),F=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:w.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:st(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:at(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=gt[t.state];return e(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&r(_,{className:`h-2.5 w-2.5 animate-spin`}),i(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&e(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:i(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`span`,{className:`text-foreground-subtle tabular-nums`,children:ct(e.expiresAt,v)})},{key:`size`,header:i(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:G(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,a=t.state===`queued`||t.state===`rendering`,o=t.state!==`deleted`;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&e(`button`,{onClick:()=>{j(t)},disabled:k===t.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:i(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[k===t.id?r(_,{className:`h-3 w-3 animate-spin`}):r(m,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(`button`,{onClick:()=>{M(t)},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:i(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[r(y,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(`button`,{onClick:()=>{P(t)},disabled:D.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:i(`recordings.exportsSection.deleteExport`,`Delete export`),children:r(l,{className:`h-3 w-3`})})]})}}],[w,v,k,E.isPending,D.isPending,j,M,P,i]);return S&&x.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),i(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):e(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex justify-end`,children:e(`button`,{onClick:()=>u(!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:[r(f,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),x.length===0?r(B,{icon:f,title:i(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:i(`recordings.exportsSection.createOneHereNewExport`,`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`)}):r(O,{columns:F,rows:x,rowKey:e=>e.id,minWidthPx:720}),c&&r(mt,{onClose:()=>u(!1),onCreated:d})]})}var bt=`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`;o();var xt=`storage-migration`,St=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function Ct(e){return[`${e.orphansReclaimed} orphan rows (${G(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${G(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${G(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function wt(){let{t:e}=W(),t=P(xt);return t===`pending`?null:t===`unknown`?r(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:e(`recordings.cleanupSection.couldNotCheckWhetherStorage`,`Could not check whether storage cleanup is installed on this hub.`)}):t===`present`?r(Tt,{}):null}function Tt(){let{t}=W(),n=b(),[i,o]=a(!1),[s,c]=a(null),u=oe({},{refetchInterval:2e3}),d=u.data??null,f=d!==null&&St.has(d.phase),p=Te(),m=D(),h=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:i?t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd2`,`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`),confirmLabel:t(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){c(null);try{await p.mutateAsync({includeDebugMedia:i}),await u.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},g=async()=>{if(d&&await n({title:t(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:t(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:t(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await m.mutateAsync({jobId:d.jobId}),await u.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.cleanupSection.onePassOverLeftoverAnalytics`,`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`)}),e(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[r(`input`,{type:`checkbox`,checked:i,disabled:f,onChange:e=>{o(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),r(`span`,{children:t(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),e(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[e(`button`,{type:`button`,disabled:f||p.isPending,onClick:()=>{h()},className:bt,children:[(f||p.isPending)&&r(_,{className:`h-3 w-3 animate-spin`}),r(l,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&r(`button`,{type:`button`,onClick:()=>{g()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:t(`common.cancel`,`Cancel`)})]}),s&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),d&&e(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[e(`p`,{className:`text-xs text-foreground`,children:[t(`recordings.cleanupSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:d.phase}),f&&r(_,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),d.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:d.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:Ct(d)}),d.error&&r(`p`,{className:`text-[11px] text-danger`,children:d.error})]})]})}o();var Et=2e3;function Dt(){let{t}=W(),n=b(),a=s(),o=Ce(),c=ve(void 0,{refetchInterval:e=>e.state.data?.state===`running`?Et:!1}),l=c.data,d=l?.state===`running`,f=d||o.isPending;i(()=>{l?.state!==`done`||l.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[l?.state,l?.finishedAtMs,a]);let p=async()=>{await n({title:t(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:t(`recordings.diskReconcileSection.makesTheDatabaseMatchThe`,`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`),confirmLabel:t(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await o.mutateAsync(),await c.refetch())},m=d?l.total>0?`Reconciling ${String(l.completed)}/${String(l.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),e(`div`,{className:`mt-3 flex flex-col gap-2`,children:[e(`button`,{type:`button`,onClick:()=>void p(),disabled:f,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:[f?r(_,{className:`h-3.5 w-3.5 animate-spin`}):r(u,{className:`h-3.5 w-3.5`}),m]}),l?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(l.completed),tracks:String(l.tracks),events:String(l.events),media:String(l.mediaDropped)}),l.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(l.failed.length),value2:l.failed.join(`, `)}):``,`.`]}):null,l?.state===`error`&&l.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,l.error]}):null]})]})}var K=1e3,q=60*K,J=60*q;function Y(e){return e.toLocaleString(`en-US`)}function Ot(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 X(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?`${G(e.bytesMoved/t*K)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${Ot(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${G(e.bytesMoved)} moved`,rate:a,eta:s}}function kt(e){let t=X(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var At=`storage-migration`,Z=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],jt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Mt(){let{t}=W(),n=P(At);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(B,{icon:S,title:t(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryDidNot`,`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`)}):n===`absent`?r(B,{icon:w,title:t(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryAnsweredNo`,`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`)}):r(Nt,{})}function Nt(){let{t:n}=W(),i=b(),{data:o}=L({}),[s,c]=a({}),[l,u]=a({}),[d,f]=a(null),[p,m]=a(null),h=t(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),g=t(()=>{let e=new Map;for(let t of o??[]){if(t.enabled===!1)continue;let n=e.get(t.type);n?n.push(t.id):e.set(t.type,[t.id])}let t=new Map;for(let[n,r]of e)r.length===1&&t.set(n,r[0]);return t},[o]),y=F({},{refetchInterval:2e3}),x=y.data??null,S=x!==null&&jt.has(x.phase),C=t(()=>{let e={};for(let t of Z){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),T=t(()=>{let e={};for(let t of Z){if(!s[t.id])continue;let n=l[t.id]??g.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,l,g]),E=t(()=>({destinations:C??{},...T?{sources:T}:{}}),[C,T]),D=_e(E,{enabled:!1,retry:!1}),O=ge(),k=ae(),A=async()=>{if(!C)return;m(null);let e=await D.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},j=async()=>{if(C&&await i({title:n(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:n(`migration.storageMigrationSection.copiesTheSelectedClassesFrom`,`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`),confirmLabel:n(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await O.mutateAsync(E),f(null),await y.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},M=async()=>{if(x&&await i({title:n(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:n(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:n(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await k.mutateAsync({jobId:x.jobId}),await y.refetch()}catch{}};return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[r(w,{className:`h-3.5 w-3.5`}),n(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.moveRecordingsLowResRecordings`,`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`)}),r(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Z.map(t=>{let i=h.get(t.locationType)??[],a=g.get(t.locationType)??``;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(t.labelKey)}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classFrom`,{label:n(t.labelKey)})}),r(`select`,{id:`migration-from-${t.id}`,value:l[t.id]??a,onChange:e=>{let n=e.target.value;u(e=>({...e,[t.id]:n}))},disabled:S,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:i.map(t=>e(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${n(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classTo`,{label:n(t.labelKey)})}),e(`select`,{id:`migration-dest-${t.id}`,value:s[t.id]??``,onChange:e=>{let n=e.target.value;c(e=>({...e,[t.id]:n}))},disabled:S,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[r(`option`,{value:``,children:n(`migration.storageMigrationSection.skip`,`— skip —`)}),i.map(e=>r(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),p&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(`button`,{type:`button`,onClick:()=>{A()},disabled:!C||D.isFetching||S,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:[D.isFetching&&r(_,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(`button`,{type:`button`,onClick:()=>{j()},disabled:!C||O.isPending||S,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:[O.isPending&&r(_,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&r(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?r(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.moves.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]},`${t.storageClass}-${t.toLocationId}`))}),x&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),S&&e(`button`,{type:`button`,onClick:()=>{M()},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:[r(v,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[n(`migration.storageMigrationSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:x.phase}),S&&r(_,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),x.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:x.error}),x.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,x.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:x.moves.map(e=>r(Pt,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(Ft,{})]}),r(It,{running:S}),r(Rt,{})]})}function Pt({move:t}){let{t:n}=W(),i=t.progress===null?null:X(t.progress);return e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`flex items-center justify-between`,children:[e(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]}),e(`span`,{className:`text-foreground-subtle`,children:[t.state??n(`common.pending`),t.error?` (${t.error})`:``]})]}),t.progress!==null&&e(`div`,{className:`mt-1 space-y-1`,children:[i!==null&&i.fraction!==null&&r(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:r(`div`,{className:`h-full bg-primary`,style:{width:`${(i.fraction*100).toFixed(1)}%`}})}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:kt(t.progress)})]})]})}function Ft(){let{t}=W(),{data:n}=k({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.phase}),` · `,Object.entries(t.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(t.startedAt).toLocaleString()]},t.jobId))})]})}function It({running:t}){let{t:n}=W(),i=b(),o=E({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=j(),[c,l]=a(null),u=o.data??[];if(u.length===0)return null;let d=async e=>{if(await i({title:n(`migration.storageMigrationSection.drainRemaining`,`Drain remaining {{storageClass}}?`,{storageClass:e.storageClass}),message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await s.mutateAsync({classes:[e.storageClass]}),await o.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(o.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),r(`button`,{type:`button`,onClick:()=>{o.refetch()},disabled:o.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:o.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.aMigrationRepointsFirstAnd`,`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`)}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.thisCountIsTakenOn`,`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`)}),c&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(i=>e(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[e(`span`,{className:`text-foreground`,children:[i.storageClass,`: `,i.fromLocationId,` → `,i.toLocationId,r(`span`,{className:`ml-2 text-foreground-subtle`,children:Lt(i)})]}),r(`button`,{type:`button`,onClick:()=>{d(i)},disabled:t||s.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${i.storageClass}-${i.fromLocationId}`))})]})}function Lt(e){if(e.items===null)return U.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?U.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):U.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:G(e.bytes)})}function Rt(){let{t}=W(),{data:n}=re({},{refetchInterval:2e3}),i=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return i.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:i.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`text-foreground`,children:[t.lane,`: `,t.job.fromLocationId,` → `,t.job.toLocationId]}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:kt({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function zt(){let{t}=W();return e(`div`,{className:`flex flex-col gap-4`,children:[r(wt,{}),r(Dt,{}),e(`section`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),r(`div`,{className:`mt-3`,children:r(Mt,{})})]})]})}o();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{t:n}=W(),i=s(),{nodes:a}=I(),{data:o,isLoading:c}=A({addonId:Bt}),l=Vt(o,`recordingNodeId`,`hub`),u=V({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[a,l]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.theSingleNodeThatRecords`,`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Bt,patch:{recordingNodeId:e.target.value}})},disabled:u.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:d.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):e},e))}),u.isPending&&r(_,{className:`h-4 w-4 animate-spin text-primary`})]}),l!==`hub`&&r(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:r(je,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:l},components:{b:r(`span`,{className:`font-medium`})}})})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.whereRecordingsAreStoredMulti`,`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.`)}),r(Ye,{types:[`recordings`,`recordingsLow`]})]})]})}function Q(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Ut(e,t){let n=Q(e);return n.length===0?U.t(`helpers.cameraDisk.defaultRoot`):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=>Q(e).includes(n));return i===void 0?null:{label:Ut(i,t),exact:!1}}o();var Gt=[[`recording`]],Kt=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],qt={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Jt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Yt(e){return e==null?`—`:new Date(e).toLocaleString()}function Xt(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(` + `):U.t(`recordings.storageSection.defaultRoot`):e.root}function Zt(){let{t:i}=W(),o=s(),c=b(),[d,f]=a(`retention`),{data:m,isLoading:h}=H({},{refetchOnWindowFocus:!1}),{data:g}=N({isCamera:!0,projection:`slim`}),{data:v}=L({}),y=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),x=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.displayName);return e},[v]),S=t(()=>{let e=v??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[v]),C=t(()=>m?.locations??[],[m?.locations]),w=t(()=>Wt(C,x,S),[C,x,S]),E=t(()=>Fe(C),[C]),D=n(()=>{o.invalidateQueries({queryKey:Gt})},[o]),k=xe({onSuccess:D}),A=pe({onSuccess:D}),j=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:d}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&k.mutate({deviceId:e.deviceId,reason:d})},[c,k,d,y,i]),M=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:G(e.usedBytes)}),confirmLabel:i(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:G(e.usedBytes)}),variant:`danger`})&&A.mutate({deviceId:e.deviceId})},[c,A,y,i]),P=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>w===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:w.exact?`text-foreground`:`text-foreground-subtle`,title:w.exact?i(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):i(`recordings.storageSection.theRecordingsDefaultThisNode`,`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:[w.label,!w.exact&&r(`span`,{className:`ml-1 text-foreground-subtle`,children:i(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:i(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:G(e.usedBytes)})},{key:`oldest`,header:i(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums text-foreground-subtle`,title:i(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Yt(e.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>e(`div`,{className:`flex items-center justify-end gap-1`,children:[e(`button`,{onClick:()=>{j(t)},disabled:k.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:i(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[r(T,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(`button`,{onClick:()=>{M(t)},disabled:A.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:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(l,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[y,w,j,M,k.isPending,A.isPending,i]);if(h&&!m)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!m)return r(B,{icon:u,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let F=m.devices.length;return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[r(p,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(u,{className:`h-3 w-3`}),footer:`${String(F)} camera${F===1?``:`s`} on ${m.nodeId}`,children:G(m.totalUsedBytes)}),E!==null&&E.severity!==null&&r(p,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(u,{className:`h-3 w-3`}),footer:`across ${String(E.knownVolumes)} volume${E.knownVolumes===1?``:`s`} of ${G(E.totalBytes)}`+(E.unknownVolumes>0?` · ${String(E.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Jt[E.severity]}`,children:G(E.freeBytes)})}),C.map(t=>{let n=ze(t),a=t.locationId??t.root??`default`;return r(p,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Xt(t,x)}),footer:n===null?`${G(t.usedBytes)} of recordings · volume capacity unknown`:`${G(n.freeBytes)} free of ${G(n.totalBytes)} · ${G(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?r(`span`,{className:`tabular-nums`,children:G(t.usedBytes)}):e(`div`,{className:`flex items-center gap-2`,title:i(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[r(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:r(`div`,{className:`h-full rounded ${qt[n.severity]}`,style:{width:$(n.fraction)}})}),r(`span`,{className:`tabular-nums text-xs ${Jt[n.severity]}`,children:$(n.fraction)})]})},a)})]}),e(`section`,{className:`flex items-center gap-2 text-xs`,children:[r(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:i(`recordings.storageSection.pruneReason`,`Prune reason`)}),r(`select`,{id:`prune-reason`,value:d,onChange:e=>{let t=Kt.find(t=>t.value===e.target.value);t&&f(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Kt.map(e=>r(`option`,{value:e.value,children:i(e.labelKey)},e.value))})]}),F===0?r(B,{icon:u,title:m.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:m.devicesRead===`unavailable`?i(`recordings.storageSection.thisRecordingNodeHasNo`,`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.`):i(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):r(O,{columns:P,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Qt(){let{t}=W();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),r(`div`,{className:`mt-3`,children:r(Zt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),r(`div`,{className:`mt-3`,children:r(Ht,{})})]})]})}function $t(){let{t:e}=W(),t=ke(`/recordings`,{t:e,isAdmin:!0})??{icon:f,title:e(`nav.recordings`,`Recordings`)};return r(Me,{icon:t.icon,title:t.title,subtitle:e(`recordings.recordedFootageAndTheDurable`,`Recorded footage and the durable event store — what each occupies, where it is written, and the operations that move or reconcile both.`),defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`recordings.recordings`,`Recordings`),content:r(Qt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:r(it,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Je,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(yt,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(qe,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(zt,{})}]})}export{$t as RecordingsPage};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ht as l,Or as u,Pi as d,Vr as f,Y as p,Zr as m,ca as h,dt as g,fr as _,gt as v,mi as y,st as b,ti as x,zt as S}from"./player-overlays-C_WpL6a6.js";import{Mo as C}from"./client-Clemlz5W.js";import{n as w,t as T}from"./scissors-MIPuZwTY.js";import{Au as E,Cu as D,Dn as O,Du as k,Ei as A,Eu as j,Fc as M,Mo as N,Mr as P,Mu as F,Nc as ee,Nu as te,On as ne,Ou as re,Sr as ie,Su as ae,Tu as oe,Vc as se,Zd as I,Zr as ce,_r as le,_u as ue,au as de,br as fe,bu as L,ef as R,ei as z,eu as pe,gr as me,iu as he,jr as B,ju as ge,ki as V,ku as _e,ml as ve,nu as ye,ou as be,ru as xe,su as Se,tu as H,vl as Ce,vr as we,wu as Te,xr as Ee,yu as De,zc as Oe}from"./src-BuD4BDe3.js";import{t as U}from"./i18n-C1QctlOB.js";import{t as W}from"./useTranslation-BJr-n0es.js";import{T as ke,k as Ae,pr as je}from"./index-D3Yx0Smp.js";import{t as Me}from"./AdminSectionedPage-B1FFlzAp.js";import{n as Ne}from"./authed-media-DxWmG5JA.js";import{t as G}from"./format-size-DIxKXxtj.js";import{c as Pe,i as Fe,l as Ie,n as Le,o as Re,r as ze,s as Be,t as Ve,u as He}from"./location-owned-usage-B3nr7gWQ.js";o();var Ue=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],We={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Ge={columnKey:`at`,dir:`desc`};function Ke(e){return new Date(e).toLocaleString()}function qe(){let{t:n,i18n:i}=W(),[o,s]=a(`all`),{data:l,isLoading:u,isError:d}=ye({},{refetchOnWindowFocus:!1}),{data:f,isLoading:p,isError:m}=Oe({},{refetchOnWindowFocus:!1}),{data:g}=N({isCamera:!0,projection:`slim`}),v=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),y=t(()=>{let e=[...l??[],...f??[]];return(o===`all`?e:e.filter(e=>e.domain===o)).toSorted((e,t)=>t.at-e.at)},[l,f,o]),b=t(()=>{let e=[];return d&&o!==`events`&&e.push(n(`recordings.activitySection.domainRecordings`)),m&&o!==`recording`&&e.push(n(`common.events`)),e},[d,m,o,n]),x=t(()=>new Intl.ListFormat(i.language,{type:`conjunction`}).format(b),[b,i.language]),C=t(()=>[{key:`at`,header:n(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ke(e.at)})},{key:`domain`,header:n(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>r(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${We[e.domain]}`,children:e.domain})},{key:`op`,header:n(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>r(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:n(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>r(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:n(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:v.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?r(`span`,{className:`text-foreground-subtle`,children:n(`common.cluster`)}):r(`span`,{className:`text-foreground`,children:v.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:n(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>r(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:n(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>r(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?G(e.bytesReclaimed):`—`})}],[v,n]),w=u||p;return e(`div`,{className:`flex flex-col gap-4`,children:[r(`div`,{className:`flex items-center gap-1`,children:Ue.map(e=>r(`button`,{onClick:()=>s(e.value),className:`rounded px-2 py-1 text-xs font-medium ${o===e.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n(e.labelKey)},e.value))}),w&&y.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):y.length===0?b.length>0?r(B,{icon:S,title:n(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:n(`recordings.activitySection.theOpsLogDidNot`,`The {{value1}} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`,{value1:x})}):r(B,{icon:h,title:n(`recordings.activitySection.noActivityYet`,`No activity yet`),description:n(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):e(c,{children:[b.length>0&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[r(S,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:b.length,names:x})]}),r(O,{columns:C,rows:y,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:ne,defaultSort:Ge})]})]})}o();function Je(){let{t:n}=W(),i=N({isCamera:!0,projection:`slim`}),o=t(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[s,c]=a(null),l=s??o[0]?.id??null;return!i.isLoading&&o.length===0?r(B,{icon:d,title:n(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:n(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.recordingModeScheduleBandsAnd`,`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.`)})]}),e(`div`,{className:`flex items-center gap-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),r(`select`,{value:l??``,onChange:e=>c(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:o.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),l!==null&&r(ce,{deviceId:l,children:r(Ae,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}o();function Ye({types:n}){let{t:i}=W(),o=s(),c=b(),{data:l}=L({}),u=De(),d=t(()=>u.data??[],[u.data]),{data:f}=H({},{refetchOnWindowFocus:!1}),p=t(()=>Ve(l??[],f?.locations),[l,f?.locations]),[m,h]=a(null),[g,_]=a(null),v=()=>{o.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},y=te({onSuccess:v}),x=ue({onSuccess:v}),S=t(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[l]),C=async(e,t)=>{Ie(t)&&!await c({title:i(`pipeline.storageLocationsPanel.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:i(`pipeline.storageLocationsPanel.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Pe(t).consequence}),confirmLabel:i(`common.disable`,`Disable`),variant:`danger`})||y.mutate(Be(e,{mode:t}))},w=async e=>{if(await c({title:i(`pipeline.storageLocationsPanel.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:i(`pipeline.storageLocationsPanel.removesTheRecordFilesOn`,`Removes the record; files on disk are untouched.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`}))try{await x.mutateAsync({id:e.id})}catch(t){await c({title:i(`pipeline.storageLocationsPanel.deleteAnyway`,`Delete anyway?`),message:i(`pipeline.storageLocationsPanel.forcingNote`,{error:t instanceof Error?t.message:String(t)}),confirmLabel:i(`pipeline.storageLocationsPanel.forceDelete`,`Force delete`),variant:`danger`})&&x.mutate({id:e.id,force:!0})}},T=n.map(e=>d.find(t=>t.id===e)).filter(e=>e!==void 0);return e(`div`,{className:`space-y-3`,children:[T.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:i(`pipeline.storageLocationsPanel.noStorageLocationsDeclaredFor`,`No storage locations declared for this purpose.`)}):T.map(e=>r(Le,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:S.get(e.id)??[],onAdd:e=>h(e),onEdit:e=>_(e),onDelete:e=>{w(e)},ownedBytesById:p,onSetMode:(e,t)=>{C(e,t)}},e.id)),m!==null&&r(He,{initialType:m,onClose:()=>h(null),onCreated:()=>{v(),h(null)}}),g!==null&&r(Re,{location:g,onClose:()=>_(null),onSaved:()=>{v(),_(null)}})]})}o();var Xe=`pipeline-analytics`;function Ze(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 Qe(){let{t:n}=W(),i=s(),{nodes:a}=I(),{data:o,isLoading:c}=A({addonId:Xe}),l=Ze(o),u=V({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[a,l]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.theSingleNodeThatRuns`,`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.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Xe,patch:{postProcessingNodeId:e.target.value}})},disabled:u.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:d.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):e},e))}),u.isPending&&r(_,{className:`h-4 w-4 animate-spin text-primary`})]})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),r(Ye,{types:[`eventMedia`]})]})]})}o();var $e=[[`pipelineAnalytics`]],et=1440*60*1e3;function tt(e,t){return t.get(e)??U.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var nt=[{days:1},{days:7},{days:30},{days:90}];function rt(){let{t:i}=W(),o=s(),c=b(),[u,d]=a(30),[f,m]=a(null),{data:h,isLoading:g}=M({},{refetchOnWindowFocus:!1}),{data:v}=N({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),S=n(()=>{o.invalidateQueries({queryKey:$e})},[o]),C=se({onSuccess:S}),w=ee(),E=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:u}),message:i(`recordings.eventsManagementSection.permanentlyDeletesEveryEventMotion`,`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`),confirmLabel:i(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&C.mutate({olderThanMs:Date.now()-u*et,reason:`retention`})},[c,C,u,i]),D=n(async e=>{let t=tt(e.deviceId,y);if(await c({title:i(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:t}),message:i(`recordings.eventsManagementSection.deleteRowsMessage`,{count:e.rows,size:G(e.bytes)}),confirmLabel:i(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){m(null);try{let n=await w.mutateAsync({deviceId:e.deviceId});S();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){m(`0 events deleted for ${t}. Media still listed (${G(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}m(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){m(e instanceof Error?e.message:String(e))}}},[c,w,y,S,i]),k=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:tt(e.deviceId,y)})},{key:`rows`,header:i(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:i(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:G(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>e(`button`,{onClick:()=>{D(t)},disabled:w.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:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(l,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[y,D,w.isPending,i]);return g&&!h?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):h?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(p,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(x,{className:`h-3 w-3`}),footer:`across ${String(h.devices.length)} camera${h.devices.length===1?``:`s`}`,children:h.totalRows.toLocaleString()}),r(p,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:G(h.totalBytes)})]}),e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[r(`span`,{className:`text-foreground-subtle`,children:i(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),r(`select`,{value:u,onChange:e=>d(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:nt.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(`button`,{onClick:()=>{E()},disabled:C.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:[C.isPending?r(_,{className:`h-3 w-3 animate-spin`}):r(T,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),h.devices.length===0?r(B,{icon:x,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(O,{columns:k,rows:[...h.devices],rowKey:e=>e.deviceId,minWidthPx:480}),f===null?null:r(`p`,{className:f.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:f})]}):r(B,{icon:x,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function it(){let{t}=W();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.eventStore`,`Event store`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),r(`div`,{className:`mt-3`,children:r(rt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),r(`div`,{className:`mt-3`,children:r(Qe,{})})]})]})}function at(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 ot(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function st(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`${ot(e)} · ${o}`}function ct(e,t){let n=e-t;if(n<=0)return U.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return U.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?U.t(`helpers.exportFormat.inHours`,{n:String(i)}):U.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function lt(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})}o();var ut=[`high`,`mid`,`low`],dt=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],ft=10080*60*1e3;function pt(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 mt({onClose:n,onCreated:i}){let{t:o}=W(),s=N({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[l,u]=a(``),[d,p]=a(`high`),[m,h]=a(pt(60)),[g,_]=a(pt(0)),[v,y]=a(1),[b,x]=a(!0),[S,C]=a(``),[w,T]=a(null),E=l===``?c[0]?.id??null:l,D=new Date(m).getTime(),O=new Date(g).getTime(),k=Number.isFinite(D)&&Number.isFinite(O)&&D<O,A=de({onSuccess:()=>{i(),n()},onError:e=>T(e instanceof Error?e.message:String(e))});return r(me,{open:!0,onOpenChange:e=>!e&&n(),children:e(we,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(Ee,{children:e(ie,{className:`flex items-center gap-1.5`,children:[r(f,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(le,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.camera`,`Camera`)}),r(`select`,{value:E??``,onChange:e=>u(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:c.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.profile`,`Profile`)}),r(`select`,{value:d,onChange:e=>p(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=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.from`,`From`)}),r(`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`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.to`,`To`)}),r(`input`,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.speed`,`Speed`)}),r(`select`,{value:v,onChange:e=>y(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:dt.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:o(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:o(`recordings.newExportModal.eGCourierAtThe`,`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`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(`input`,{type:`checkbox`,checked:b,disabled:v!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),o(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!k&&r(`p`,{className:`text-[11px] text-danger`,children:o(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),w&&r(`p`,{className:`text-[11px] text-danger`,children:w})]}),e(fe,{children:[r(z,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(z,{size:`sm`,onClick:()=>{if(E===null||!k)return;T(null);let e=S.trim();A.mutate({deviceId:E,profile:d,fromMs:D,toMs:O,options:{includeAudio:b,maxLifeMs:ft,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:E===null||!k||A.isPending,children:A.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var ht=[[`recordingExport`]],gt={queued:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.queued`},rendering:{cls:`bg-primary/10 text-primary`,labelKey:`recordings.exportsSection.rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,labelKey:`recordings.exportsSection.ready`},failed:{cls:`bg-danger/10 text-danger`,labelKey:`recordings.exportsSection.failed`},expired:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.expired`},deleted:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.deleted`}};function _t(){let{data:e,isLoading:n}=Se({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=R(C.RecordingExportProgress,e=>e.exportId),{map:i}=R(C.RecordingExportCompleted,e=>e.exportId),{map:a}=R(C.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>lt(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function vt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function yt(){let{t:i}=W(),o=s(),[c,u]=a(!1),d=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=b(),h=g().trpcClient,v=vt(6e4),{rows:x,isLoading:S}=_t(),{data:C}=N({isCamera:!0,projection:`slim`}),w=t(()=>{let e=new Map;for(let t of C??[])e.set(t.id,t.name);return e},[C]),T=n(()=>{o.invalidateQueries({queryKey:ht})},[o]),E=he({onSuccess:T}),D=be({onSuccess:T}),[k,A]=a(null),j=n(async e=>{A(e.id);try{let{url:t}=await h.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Ne(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),T()}finally{A(null)}},[h,T]),M=n(async e=>{await p({title:i(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:i(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:i(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&E.mutate({exportId:e.id})},[p,E,i]),P=n(async e=>{await p({title:i(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:i(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`})&&D.mutate({exportId:e.id})},[p,D,i]),F=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:w.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:st(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:at(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=gt[t.state];return e(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&r(_,{className:`h-2.5 w-2.5 animate-spin`}),i(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&e(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:i(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`span`,{className:`text-foreground-subtle tabular-nums`,children:ct(e.expiresAt,v)})},{key:`size`,header:i(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:G(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,a=t.state===`queued`||t.state===`rendering`,o=t.state!==`deleted`;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&e(`button`,{onClick:()=>{j(t)},disabled:k===t.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:i(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[k===t.id?r(_,{className:`h-3 w-3 animate-spin`}):r(m,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(`button`,{onClick:()=>{M(t)},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:i(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[r(y,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(`button`,{onClick:()=>{P(t)},disabled:D.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:i(`recordings.exportsSection.deleteExport`,`Delete export`),children:r(l,{className:`h-3 w-3`})})]})}}],[w,v,k,E.isPending,D.isPending,j,M,P,i]);return S&&x.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),i(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):e(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex justify-end`,children:e(`button`,{onClick:()=>u(!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:[r(f,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),x.length===0?r(B,{icon:f,title:i(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:i(`recordings.exportsSection.createOneHereNewExport`,`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`)}):r(O,{columns:F,rows:x,rowKey:e=>e.id,minWidthPx:720}),c&&r(mt,{onClose:()=>u(!1),onCreated:d})]})}var bt=`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`;o();var xt=`storage-migration`,St=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function Ct(e){return[`${e.orphansReclaimed} orphan rows (${G(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${G(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${G(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function wt(){let{t:e}=W(),t=P(xt);return t===`pending`?null:t===`unknown`?r(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:e(`recordings.cleanupSection.couldNotCheckWhetherStorage`,`Could not check whether storage cleanup is installed on this hub.`)}):t===`present`?r(Tt,{}):null}function Tt(){let{t}=W(),n=b(),[i,o]=a(!1),[s,c]=a(null),u=oe({},{refetchInterval:2e3}),d=u.data??null,f=d!==null&&St.has(d.phase),p=Te(),m=D(),h=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:i?t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd2`,`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`),confirmLabel:t(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){c(null);try{await p.mutateAsync({includeDebugMedia:i}),await u.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},g=async()=>{if(d&&await n({title:t(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:t(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:t(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await m.mutateAsync({jobId:d.jobId}),await u.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.cleanupSection.onePassOverLeftoverAnalytics`,`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`)}),e(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[r(`input`,{type:`checkbox`,checked:i,disabled:f,onChange:e=>{o(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),r(`span`,{children:t(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),e(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[e(`button`,{type:`button`,disabled:f||p.isPending,onClick:()=>{h()},className:bt,children:[(f||p.isPending)&&r(_,{className:`h-3 w-3 animate-spin`}),r(l,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&r(`button`,{type:`button`,onClick:()=>{g()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:t(`common.cancel`,`Cancel`)})]}),s&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),d&&e(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[e(`p`,{className:`text-xs text-foreground`,children:[t(`recordings.cleanupSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:d.phase}),f&&r(_,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),d.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:d.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:Ct(d)}),d.error&&r(`p`,{className:`text-[11px] text-danger`,children:d.error})]})]})}o();var Et=2e3;function Dt(){let{t}=W(),n=b(),a=s(),o=Ce(),c=ve(void 0,{refetchInterval:e=>e.state.data?.state===`running`?Et:!1}),l=c.data,d=l?.state===`running`,f=d||o.isPending;i(()=>{l?.state!==`done`||l.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[l?.state,l?.finishedAtMs,a]);let p=async()=>{await n({title:t(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:t(`recordings.diskReconcileSection.makesTheDatabaseMatchThe`,`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`),confirmLabel:t(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await o.mutateAsync(),await c.refetch())},m=d?l.total>0?`Reconciling ${String(l.completed)}/${String(l.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),e(`div`,{className:`mt-3 flex flex-col gap-2`,children:[e(`button`,{type:`button`,onClick:()=>void p(),disabled:f,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:[f?r(_,{className:`h-3.5 w-3.5 animate-spin`}):r(u,{className:`h-3.5 w-3.5`}),m]}),l?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(l.completed),tracks:String(l.tracks),events:String(l.events),media:String(l.mediaDropped)}),l.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(l.failed.length),value2:l.failed.join(`, `)}):``,`.`]}):null,l?.state===`error`&&l.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,l.error]}):null]})]})}var K=1e3,q=60*K,J=60*q;function Y(e){return e.toLocaleString(`en-US`)}function Ot(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 X(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?`${G(e.bytesMoved/t*K)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${Ot(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${G(e.bytesMoved)} moved`,rate:a,eta:s}}function kt(e){let t=X(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var At=`storage-migration`,Z=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],jt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Mt(){let{t}=W(),n=P(At);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(B,{icon:S,title:t(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryDidNot`,`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`)}):n===`absent`?r(B,{icon:w,title:t(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryAnsweredNo`,`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`)}):r(Nt,{})}function Nt(){let{t:n}=W(),i=b(),{data:o}=L({}),[s,c]=a({}),[l,u]=a({}),[d,f]=a(null),[p,m]=a(null),h=t(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),g=t(()=>{let e=new Map;for(let t of o??[]){if(t.enabled===!1)continue;let n=e.get(t.type);n?n.push(t.id):e.set(t.type,[t.id])}let t=new Map;for(let[n,r]of e)r.length===1&&t.set(n,r[0]);return t},[o]),y=F({},{refetchInterval:2e3}),x=y.data??null,S=x!==null&&jt.has(x.phase),C=t(()=>{let e={};for(let t of Z){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),T=t(()=>{let e={};for(let t of Z){if(!s[t.id])continue;let n=l[t.id]??g.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,l,g]),E=t(()=>({destinations:C??{},...T?{sources:T}:{}}),[C,T]),D=_e(E,{enabled:!1,retry:!1}),O=ge(),k=ae(),A=async()=>{if(!C)return;m(null);let e=await D.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},j=async()=>{if(C&&await i({title:n(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:n(`migration.storageMigrationSection.copiesTheSelectedClassesFrom`,`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`),confirmLabel:n(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await O.mutateAsync(E),f(null),await y.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},M=async()=>{if(x&&await i({title:n(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:n(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:n(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await k.mutateAsync({jobId:x.jobId}),await y.refetch()}catch{}};return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[r(w,{className:`h-3.5 w-3.5`}),n(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.moveRecordingsLowResRecordings`,`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`)}),r(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Z.map(t=>{let i=h.get(t.locationType)??[],a=g.get(t.locationType)??``;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(t.labelKey)}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classFrom`,{label:n(t.labelKey)})}),r(`select`,{id:`migration-from-${t.id}`,value:l[t.id]??a,onChange:e=>{let n=e.target.value;u(e=>({...e,[t.id]:n}))},disabled:S,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:i.map(t=>e(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${n(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classTo`,{label:n(t.labelKey)})}),e(`select`,{id:`migration-dest-${t.id}`,value:s[t.id]??``,onChange:e=>{let n=e.target.value;c(e=>({...e,[t.id]:n}))},disabled:S,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[r(`option`,{value:``,children:n(`migration.storageMigrationSection.skip`,`— skip —`)}),i.map(e=>r(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),p&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(`button`,{type:`button`,onClick:()=>{A()},disabled:!C||D.isFetching||S,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:[D.isFetching&&r(_,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(`button`,{type:`button`,onClick:()=>{j()},disabled:!C||O.isPending||S,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:[O.isPending&&r(_,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&r(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?r(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.moves.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]},`${t.storageClass}-${t.toLocationId}`))}),x&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),S&&e(`button`,{type:`button`,onClick:()=>{M()},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:[r(v,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[n(`migration.storageMigrationSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:x.phase}),S&&r(_,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),x.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:x.error}),x.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,x.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:x.moves.map(e=>r(Pt,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(Ft,{})]}),r(It,{running:S}),r(Rt,{})]})}function Pt({move:t}){let{t:n}=W(),i=t.progress===null?null:X(t.progress);return e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`flex items-center justify-between`,children:[e(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]}),e(`span`,{className:`text-foreground-subtle`,children:[t.state??n(`common.pending`),t.error?` (${t.error})`:``]})]}),t.progress!==null&&e(`div`,{className:`mt-1 space-y-1`,children:[i!==null&&i.fraction!==null&&r(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:r(`div`,{className:`h-full bg-primary`,style:{width:`${(i.fraction*100).toFixed(1)}%`}})}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:kt(t.progress)})]})]})}function Ft(){let{t}=W(),{data:n}=k({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.phase}),` · `,Object.entries(t.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(t.startedAt).toLocaleString()]},t.jobId))})]})}function It({running:t}){let{t:n}=W(),i=b(),o=E({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=j(),[c,l]=a(null),u=o.data??[];if(u.length===0)return null;let d=async e=>{if(await i({title:n(`migration.storageMigrationSection.drainRemaining`,`Drain remaining {{storageClass}}?`,{storageClass:e.storageClass}),message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await s.mutateAsync({classes:[e.storageClass]}),await o.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(o.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),r(`button`,{type:`button`,onClick:()=>{o.refetch()},disabled:o.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:o.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.aMigrationRepointsFirstAnd`,`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`)}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.thisCountIsTakenOn`,`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`)}),c&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(i=>e(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[e(`span`,{className:`text-foreground`,children:[i.storageClass,`: `,i.fromLocationId,` → `,i.toLocationId,r(`span`,{className:`ml-2 text-foreground-subtle`,children:Lt(i)})]}),r(`button`,{type:`button`,onClick:()=>{d(i)},disabled:t||s.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${i.storageClass}-${i.fromLocationId}`))})]})}function Lt(e){if(e.items===null)return U.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?U.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):U.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:G(e.bytes)})}function Rt(){let{t}=W(),{data:n}=re({},{refetchInterval:2e3}),i=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return i.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:i.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`text-foreground`,children:[t.lane,`: `,t.job.fromLocationId,` → `,t.job.toLocationId]}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:kt({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function zt(){let{t}=W();return e(`div`,{className:`flex flex-col gap-4`,children:[r(wt,{}),r(Dt,{}),e(`section`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),r(`div`,{className:`mt-3`,children:r(Mt,{})})]})]})}o();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{t:n}=W(),i=s(),{nodes:a}=I(),{data:o,isLoading:c}=A({addonId:Bt}),l=Vt(o,`recordingNodeId`,`hub`),u=V({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[a,l]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.theSingleNodeThatRecords`,`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Bt,patch:{recordingNodeId:e.target.value}})},disabled:u.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:d.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):e},e))}),u.isPending&&r(_,{className:`h-4 w-4 animate-spin text-primary`})]}),l!==`hub`&&r(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:r(je,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:l},components:{b:r(`span`,{className:`font-medium`})}})})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.whereRecordingsAreStoredMulti`,`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.`)}),r(Ye,{types:[`recordings`,`recordingsLow`]})]})]})}function Q(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Ut(e,t){let n=Q(e);return n.length===0?U.t(`helpers.cameraDisk.defaultRoot`):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=>Q(e).includes(n));return i===void 0?null:{label:Ut(i,t),exact:!1}}o();var Gt=[[`recording`]],Kt=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],qt={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Jt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Yt(e){return e==null?`—`:new Date(e).toLocaleString()}function Xt(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(` + `):U.t(`recordings.storageSection.defaultRoot`):e.root}function Zt(){let{t:i}=W(),o=s(),c=b(),[d,f]=a(`retention`),{data:m,isLoading:h}=H({},{refetchOnWindowFocus:!1}),{data:g}=N({isCamera:!0,projection:`slim`}),{data:v}=L({}),y=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),x=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.displayName);return e},[v]),S=t(()=>{let e=v??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[v]),C=t(()=>m?.locations??[],[m?.locations]),w=t(()=>Wt(C,x,S),[C,x,S]),E=t(()=>Fe(C),[C]),D=n(()=>{o.invalidateQueries({queryKey:Gt})},[o]),k=xe({onSuccess:D}),A=pe({onSuccess:D}),j=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:d}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&k.mutate({deviceId:e.deviceId,reason:d})},[c,k,d,y,i]),M=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:G(e.usedBytes)}),confirmLabel:i(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:G(e.usedBytes)}),variant:`danger`})&&A.mutate({deviceId:e.deviceId})},[c,A,y,i]),P=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>w===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:w.exact?`text-foreground`:`text-foreground-subtle`,title:w.exact?i(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):i(`recordings.storageSection.theRecordingsDefaultThisNode`,`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:[w.label,!w.exact&&r(`span`,{className:`ml-1 text-foreground-subtle`,children:i(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:i(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:G(e.usedBytes)})},{key:`oldest`,header:i(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums text-foreground-subtle`,title:i(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Yt(e.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>e(`div`,{className:`flex items-center justify-end gap-1`,children:[e(`button`,{onClick:()=>{j(t)},disabled:k.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:i(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[r(T,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(`button`,{onClick:()=>{M(t)},disabled:A.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:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(l,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[y,w,j,M,k.isPending,A.isPending,i]);if(h&&!m)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(_,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!m)return r(B,{icon:u,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let F=m.devices.length;return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[r(p,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(u,{className:`h-3 w-3`}),footer:`${String(F)} camera${F===1?``:`s`} on ${m.nodeId}`,children:G(m.totalUsedBytes)}),E!==null&&E.severity!==null&&r(p,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(u,{className:`h-3 w-3`}),footer:`across ${String(E.knownVolumes)} volume${E.knownVolumes===1?``:`s`} of ${G(E.totalBytes)}`+(E.unknownVolumes>0?` · ${String(E.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Jt[E.severity]}`,children:G(E.freeBytes)})}),C.map(t=>{let n=ze(t),a=t.locationId??t.root??`default`;return r(p,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Xt(t,x)}),footer:n===null?`${G(t.usedBytes)} of recordings · volume capacity unknown`:`${G(n.freeBytes)} free of ${G(n.totalBytes)} · ${G(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?r(`span`,{className:`tabular-nums`,children:G(t.usedBytes)}):e(`div`,{className:`flex items-center gap-2`,title:i(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[r(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:r(`div`,{className:`h-full rounded ${qt[n.severity]}`,style:{width:$(n.fraction)}})}),r(`span`,{className:`tabular-nums text-xs ${Jt[n.severity]}`,children:$(n.fraction)})]})},a)})]}),e(`section`,{className:`flex items-center gap-2 text-xs`,children:[r(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:i(`recordings.storageSection.pruneReason`,`Prune reason`)}),r(`select`,{id:`prune-reason`,value:d,onChange:e=>{let t=Kt.find(t=>t.value===e.target.value);t&&f(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:Kt.map(e=>r(`option`,{value:e.value,children:i(e.labelKey)},e.value))})]}),F===0?r(B,{icon:u,title:m.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:m.devicesRead===`unavailable`?i(`recordings.storageSection.thisRecordingNodeHasNo`,`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.`):i(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):r(O,{columns:P,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Qt(){let{t}=W();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),r(`div`,{className:`mt-3`,children:r(Zt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),r(`div`,{className:`mt-3`,children:r(Ht,{})})]})]})}function $t(){let{t:e}=W(),t=ke(`/recordings`,{t:e,isAdmin:!0})??{icon:f,title:e(`nav.recordings`,`Recordings`)};return r(Me,{icon:t.icon,title:t.title,subtitle:e(`recordings.recordedFootageAndTheDurable`,`Recorded footage and the durable event store — what each occupies, where it is written, and the operations that move or reconcile both.`),defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`recordings.recordings`,`Recordings`),content:r(Qt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:r(it,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Je,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(yt,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(qe,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(zt,{})}]})}export{$t as RecordingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{
|
|
1
|
+
import{C as e,S as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Sr as n,_r as r,vr as i,yr as a}from"./client-Clemlz5W.js";import{Wd as o,ei as s}from"./src-BuD4BDe3.js";import{t as c}from"./useTranslation-BJr-n0es.js";function l(){return{columns:3,rows:4,buttons:[]}}var u=e=>({status:`refused`,reason:e}),d=e=>({status:`ok`,grid:e});function f(e,t){return t.row>=0&&t.col>=0&&t.row+t.rowSpan<=e.rows&&t.col+t.colSpan<=e.columns}function p(e,t){return e.row<t.row+t.rowSpan&&t.row<e.row+e.rowSpan&&e.col<t.col+t.colSpan&&t.col<e.col+e.colSpan}function m(e,t,n){return t.rowSpan<1||t.colSpan<1?`invalid-size`:f(e,t)?e.buttons.some(e=>e.id!==n&&p(e,t))?`overlap`:null:`outside`}function h(e,t){let n=m(e,t,t.id);return n===null?d({...e,buttons:e.buttons.map(e=>e.id===t.id?t:e)}):u(n)}function g(e,t){return e.buttons.find(e=>e.id===t)}function _(e){let t=new Set(e.buttons.map(e=>e.id));for(let n=e.buttons.length+1;;n+=1)if(!t.has(`b${n}`))return`b${n}`}function v(e){for(let t=0;t<e.rows;t+=1)for(let n=0;n<e.columns;n+=1)if(m(e,{id:``,row:t,col:n,rowSpan:1,colSpan:1,role:`power`},null)===null)return{row:t,col:n};return null}function y(e,t){if(e.buttons.length>=200)return u(`outside`);let n=v(e);if(n===null)return u(`outside`);let r={id:_(e),row:n.row,col:n.col,rowSpan:1,colSpan:1,role:t};return d({...e,buttons:[...e.buttons,r]})}function b(e,t,n,r){let i=g(e,t);return i===void 0?u(`unknown-button`):h(e,{...i,row:n,col:r})}function x(e,t,n,r){let i=g(e,t);return i===void 0?u(`unknown-button`):b(e,t,i.row+n,i.col+r)}function S(e,t,n,r){let i=g(e,t);return i===void 0?u(`unknown-button`):h(e,{...i,rowSpan:n,colSpan:r})}function C(e,t,n){let r=g(e,t);if(r===void 0)return u(`unknown-button`);let i=n.icon===void 0?r.icon:n.icon??void 0,a=n.label===void 0?r.label:n.label??void 0,o=a===void 0||a.trim()===``?void 0:a,s={id:r.id,row:r.row,col:r.col,rowSpan:r.rowSpan,colSpan:r.colSpan,role:n.role??r.role,...i===void 0?{}:{icon:i},...o===void 0?{}:{label:o}};return d({...e,buttons:e.buttons.map(e=>e.id===t?s:e)})}function w(e,t){return{...e,buttons:e.buttons.filter(e=>e.id!==t)}}function T(e,t,n){let r=e=>!Number.isInteger(e)||e<1||e>24;if(r(t)||r(n))return u(`invalid-size`);let i={...e,columns:t,rows:n};return e.buttons.some(e=>!f(i,e))?u(`would-drop-buttons`):d(i)}function E(e){let t=r.safeParse(e);return t.success?t.data:null}function D(e){let t=r.safeParse(e);return t.success?t.data:l()}var O=[`power`,`volume`,`channel`,`navigation`,`playback`,`digits`,`other`];function k(e){return e.startsWith(`power`)?`power`:e.startsWith(`volume`)||e===`mute`?`volume`:e.startsWith(`channel`)?`channel`:e.startsWith(`digit_`)?`digits`:[`up`,`down`,`left`,`right`,`ok`,`back`,`home`,`menu`,`exit`].includes(e)?`navigation`:[`play`,`pause`,`play_pause`,`stop`,`next`,`previous`,`fast_forward`,`rewind`].includes(e)?`playback`:`other`}function A(e){return i.filter(t=>k(t)===e)}function j(e){let t=a(e),n=(t??e).replace(/_/g,` `);return t===null?n.charAt(0).toUpperCase()+n.slice(1):n}function M(e){return a(e)!==null&&!n(e)}function N(e){let t=new Set;for(let n of e.buttons)for(let e=n.row;e<n.row+n.rowSpan;e+=1)for(let r=n.col;r<n.col+n.colSpan;r+=1)t.add(`${e}:${r}`);return t}function P({button:n}){let{t:r}=c(),i=o(),a=n.icon===void 0?void 0:i(n.icon),s=n.label??(a===void 0?r(`remote.role.${n.role}`,j(n.role)):null);return e(`span`,{className:`flex flex-col items-center justify-center gap-0.5 leading-none`,children:[a!==void 0&&t(a,{className:`h-4 w-4`,"aria-hidden":!0}),s!==null&&t(`span`,{className:`max-w-full truncate text-[11px]`,children:s})]})}function F({grid:n,label:r,selectedId:i=null,onSelect:a,boundRoles:o,showEmptyCells:c=!1}){let l=N(n),u=[];if(c)for(let e=0;e<n.rows;e+=1)for(let t=0;t<n.columns;t+=1)l.has(`${e}:${t}`)||u.push({row:e,col:t});return e(`div`,{role:`group`,"aria-label":r,"data-testid":`remote-grid`,className:`grid auto-rows-[2.75rem] gap-1.5`,style:{gridTemplateColumns:`repeat(${n.columns}, minmax(0, 1fr))`},children:[u.map(({row:e,col:n})=>t(`div`,{"aria-hidden":!0,className:`rounded-md border border-dashed border-border-subtle`,style:{gridRow:`${e+1}`,gridColumn:`${n+1}`}},`e${e}:${n}`)),n.buttons.map(e=>{let n=e.id===i,r=o===void 0||o.has(e.role);return t(s,{type:`button`,size:`sm`,variant:n?`primary`:r?`secondary`:`outline`,"aria-pressed":a===void 0?void 0:n,"data-testid":`remote-grid-button-${e.id}`,className:`h-full min-w-0 px-1`,style:{gridRow:`${e.row+1} / span ${e.rowSpan}`,gridColumn:`${e.col+1} / span ${e.colSpan}`},onClick:a===void 0?void 0:()=>a(e.id),children:t(P,{button:e})},e.id)})]})}export{l as a,A as c,S as d,T as f,E as i,D as l,x as m,O as n,j as o,C as p,y as r,M as s,F as t,w as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Di as c,En as l,Fn as u,Zr as d,fr as f,gt as p,ki as m,kn as h,zt as g}from"./player-overlays-Cl9fdVyE.js";import{Ao as _,Do as v}from"./client-BmfSvq-t.js";import{Ar as y,Ho as b,Mo as x,Ns as S,So as C,bo as w,ci as T,ei as E,ji as D,ka as O,lo as k}from"./src-Cjqv1L1_.js";import{t as A}from"./useTranslation-BJr-n0es.js";import{L as j}from"./index-s2JBApLj.js";import{n as M,t as N}from"./BrokerEditorDialog-CcvbGDox.js";o();var P={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function F({kind:t,value:n,onChange:i}){let{t:o}=A(),[s,c]=a(!1),l=O({kind:t}),d=M(l.data).filter(e=>e.kind===t);return e(`div`,{className:`space-y-2`,children:[l.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(f,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),l.isError&&r(y,{message:o(`brokers.picker.loadFailed`,{message:l.error instanceof Error?l.error.message:o(`common.unknownError`)})}),!l.isLoading&&!l.isError&&d.length===0&&r(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:o(`brokers.picker.none`)}),d.map(t=>e(`button`,{type:`button`,"aria-pressed":n===t.id,onClick:()=>i(t.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${n===t.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[r(`span`,{className:`text-xs font-semibold text-foreground`,children:t.name}),r(T,{variant:P[t.status],className:`text-[10px]`,children:t.status})]},t.id)),e(E,{variant:`outline`,size:`sm`,onClick:()=>c(!0),children:[r(u,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),s&&r(N,{kind:t,onClose:()=>c(!1),onSaved:e=>{c(!1),i(e)}})]})}o();function I({kind:t,onResolved:n,onBack:i}){let{t:o}=A(),[s,l]=a(null);return e(`div`,{className:`space-y-4`,children:[e(E,{variant:`ghost`,size:`sm`,onClick:i,children:[r(c,{className:`h-3.5 w-3.5`}),` `,o(`common.back`)]}),r(F,{kind:t,value:s,onChange:l}),r(`div`,{className:`flex justify-end pt-1`,children:r(E,{variant:`primary`,size:`sm`,disabled:s===null,onClick:()=>s!==null&&n(s),children:o(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}o();function L(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var R={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function z({addonId:t,configSchema:n,canTest:i=!0,initialName:o,initialConfig:s,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=A(),[p,m]=a(o??``),[h,g]=a(s??{}),[y,b]=a(null),x=S({onSuccess:e=>b(L(e)),onError:e=>b({status:`inconclusive`,error:String(e)})}),C=D(),w=!i||y?.status===`validated`,T=!l&&p.trim().length===0,E=!T&&w;return e(`div`,{className:`space-y-4`,children:[!l&&e(`div`,{children:[r(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),r(`input`,{id:`integration-name`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),"aria-invalid":T,"aria-describedby":T?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${T?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),T&&r(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:f(`integrations.nameRequired`,`Name is required`)})]}),n&&r(j,{schema:n,values:h,onChange:e=>{g(e),b(null)},onAction:async(e,r,a)=>{let o=await C.mutateAsync({addonId:t,action:e,input:a??{}});if(i&&typeof o==`object`&&o){let e=o;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return o;let r={...h};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=_(n,r);g(i),b(null),x.mutate({addonId:t,settings:i})}return o}}),y&&r(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${R[y.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(y)}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[r(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>x.mutate({addonId:t,settings:_(n,h)}),disabled:x.isPending||!i,title:i?void 0:f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[T&&r(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:f(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),r(`button`,{onClick:()=>{T||u({name:p,config:_(n,h),secretKeys:[...v(n)]})},disabled:!E,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:c??f(`integrations.forward`)})]})]})]})]})}function B(e,t){if(t.prefilledConfig.setupIntegration!==!0)return null;let n=t.prefilledConfig.host;return typeof n!=`string`||n.trim().length===0?null:{addonId:e,name:t.suggestedName,config:{host:n.trim()}}}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e){if(!V(e)||!V(e.integrationSeed))return null;let t=e.integrationSeed,n=t.addonId,r=t.name,i=t.config;if(typeof n!=`string`||n.length===0||typeof r!=`string`||!V(i))return null;let a={};for(let[e,t]of Object.entries(i))a[e]=t;return{addonId:n,name:r,config:a}}o();function U({open:i,onClose:o,scope:s,onSetupIntegration:c}){let{t:l}=A(),u=k(),[g,_]=a(new Set),[v,y]=a(new Set),{data:b}=x({projection:`slim`}),S=t(()=>new Set((b??[]).map(e=>e.stableId)),[b]),C=n(async(e,t)=>{let n=B(e,t);if(n!==null){c?.(n),o();return}y(e=>new Set(e).add(t.stableId));try{await u.mutateAsync({addonId:e,candidate:t}),_(e=>new Set(e).add(t.stableId))}catch{}finally{y(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[u,o,c]),w=n((t,n)=>{let i=typeof n.prefilledConfig.host==`string`?n.prefilledConfig.host:null,a=S.has(n.stableId),o=g.has(n.stableId)||a,s=v.has(n.stableId);return e(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0`,children:[r(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),i&&r(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:i})]}),o?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[r(m,{className:`h-3.5 w-3.5`}),` `,a?l(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):l(`integrations.scanNetworkModal.added`,`Added`)]}):e(`button`,{type:`button`,onClick:()=>void C(t,n),disabled:s,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[s?r(f,{className:`h-3.5 w-3.5 animate-spin`}):r(d,{className:`h-3.5 w-3.5`}),l(`common.add`,`Add`)]})]},n.stableId)},[g,v,S,C,l]);if(!i)return null;let T=s?`Scan network — ${s.label}`:`Scan network for devices`;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[r(`div`,{className:`absolute inset-0 bg-black/60`,onClick:o}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(h,{className:`h-4 w-4 text-primary`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:T})]}),r(`button`,{onClick:o,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:r(p,{className:`h-4 w-4`})})]}),s?r(G,{scope:s,onAdopt:w,onReset:()=>_(new Set)}):r(W,{onAdopt:w,onReset:()=>_(new Set)})]})]})}function W({onAdopt:a,onReset:o}){let{t:c}=A(),u=w(),d=n(()=>{o(),u.mutate({})},[u,o]);i(()=>{!u.isPending&&!u.data&&d()},[]);let f=t(()=>(u.data?.groups??[]).filter(e=>e.candidates.length>0),[u.data]),p=t(()=>f.reduce((e,t)=>e+t.candidates.length,0),[f]);return e(s,{children:[r(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:e(`button`,{onClick:d,disabled:u.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[r(l,{className:`h-3.5 w-3.5 ${u.isPending?`animate-spin`:``}`}),c(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[u.isPending&&r(K,{label:c(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!u.isPending&&u.isError&&r(q,{}),!u.isPending&&u.data&&f.length===0&&r(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!u.isPending&&f.length>0&&r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.found`,{count:p})}),!u.isPending&&f.map(t=>e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-[11px] font-semibold text-foreground`,children:t.label}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,t.candidates.length,`)`]})]}),t.candidates.map(e=>a(t.addonId,e))]},t.addonId))]})]})}function G({scope:t,onAdopt:i,onReset:o}){let{t:c}=A(),l=b({addonId:t.addonId}).data??null,[u,d]=a({}),p=C(),m=n(()=>{o(),p.mutate({addonId:t.addonId,params:u})},[p,t.addonId,u,o]),g=p.data?.candidates??[];return r(s,{children:e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&r(j,{schema:l,values:u,onChange:d}),e(`button`,{onClick:m,disabled:p.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[p.isPending?r(f,{className:`h-3.5 w-3.5 animate-spin`}):r(h,{className:`h-3.5 w-3.5`}),p.isPending?c(`integrations.scanNetworkModal.scanning`,`Scanning…`):c(`integrations.scanNetworkModal.scan`,`Scan`)]}),p.isError&&r(q,{}),!p.isPending&&p.data&&g.length===0&&r(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!p.isPending&&g.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.foundShort`,{count:g.length})}),g.map(e=>i(t.addonId,e))]})]})})}function K({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[r(f,{className:`h-6 w-6 animate-spin text-primary`}),r(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function q(){let{t}=A();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[r(g,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),r(`p`,{className:`text-xs text-destructive`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{F as a,I as i,H as n,z as r,U as t};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Di as c,En as l,Fn as u,Zr as d,fr as f,gt as p,ki as m,kn as h,zt as g}from"./player-overlays-C_WpL6a6.js";import{Oo as _,jo as v}from"./client-Clemlz5W.js";import{Ar as y,Ho as b,Mo as x,Ns as S,So as C,bo as w,ci as T,ei as E,ji as D,ka as O,lo as k}from"./src-BuD4BDe3.js";import{t as A}from"./useTranslation-BJr-n0es.js";import{L as j}from"./index-D3Yx0Smp.js";import{n as M,t as N}from"./BrokerEditorDialog-CMa1f8kC.js";o();var P={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function F({kind:t,value:n,onChange:i}){let{t:o}=A(),[s,c]=a(!1),l=O({kind:t}),d=M(l.data).filter(e=>e.kind===t);return e(`div`,{className:`space-y-2`,children:[l.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(f,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),l.isError&&r(y,{message:o(`brokers.picker.loadFailed`,{message:l.error instanceof Error?l.error.message:o(`common.unknownError`)})}),!l.isLoading&&!l.isError&&d.length===0&&r(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:o(`brokers.picker.none`)}),d.map(t=>e(`button`,{type:`button`,"aria-pressed":n===t.id,onClick:()=>i(t.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${n===t.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[r(`span`,{className:`text-xs font-semibold text-foreground`,children:t.name}),r(T,{variant:P[t.status],className:`text-[10px]`,children:t.status})]},t.id)),e(E,{variant:`outline`,size:`sm`,onClick:()=>c(!0),children:[r(u,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),s&&r(N,{kind:t,onClose:()=>c(!1),onSaved:e=>{c(!1),i(e)}})]})}o();function I({kind:t,onResolved:n,onBack:i}){let{t:o}=A(),[s,l]=a(null);return e(`div`,{className:`space-y-4`,children:[e(E,{variant:`ghost`,size:`sm`,onClick:i,children:[r(c,{className:`h-3.5 w-3.5`}),` `,o(`common.back`)]}),r(F,{kind:t,value:s,onChange:l}),r(`div`,{className:`flex justify-end pt-1`,children:r(E,{variant:`primary`,size:`sm`,disabled:s===null,onClick:()=>s!==null&&n(s),children:o(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}o();function L(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var R={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function z({addonId:t,configSchema:n,canTest:i=!0,initialName:o,initialConfig:s,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=A(),[p,m]=a(o??``),[h,g]=a(s??{}),[y,b]=a(null),x=S({onSuccess:e=>b(L(e)),onError:e=>b({status:`inconclusive`,error:String(e)})}),C=D(),w=!i||y?.status===`validated`,T=!l&&p.trim().length===0,E=!T&&w;return e(`div`,{className:`space-y-4`,children:[!l&&e(`div`,{children:[r(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),r(`input`,{id:`integration-name`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),"aria-invalid":T,"aria-describedby":T?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${T?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),T&&r(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:f(`integrations.nameRequired`,`Name is required`)})]}),n&&r(j,{schema:n,values:h,onChange:e=>{g(e),b(null)},onAction:async(e,r,a)=>{let o=await C.mutateAsync({addonId:t,action:e,input:a??{}});if(i&&typeof o==`object`&&o){let e=o;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return o;let r={...h};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=v(n,r);g(i),b(null),x.mutate({addonId:t,settings:i})}return o}}),y&&r(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${R[y.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(y)}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[r(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>x.mutate({addonId:t,settings:v(n,h)}),disabled:x.isPending||!i,title:i?void 0:f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[T&&r(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:f(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),r(`button`,{onClick:()=>{T||u({name:p,config:v(n,h),secretKeys:[..._(n)]})},disabled:!E,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:c??f(`integrations.forward`)})]})]})]})]})}function B(e,t){if(t.prefilledConfig.setupIntegration!==!0)return null;let n=t.prefilledConfig.host;return typeof n!=`string`||n.trim().length===0?null:{addonId:e,name:t.suggestedName,config:{host:n.trim()}}}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e){if(!V(e)||!V(e.integrationSeed))return null;let t=e.integrationSeed,n=t.addonId,r=t.name,i=t.config;if(typeof n!=`string`||n.length===0||typeof r!=`string`||!V(i))return null;let a={};for(let[e,t]of Object.entries(i))a[e]=t;return{addonId:n,name:r,config:a}}o();function U({open:i,onClose:o,scope:s,onSetupIntegration:c}){let{t:l}=A(),u=k(),[g,_]=a(new Set),[v,y]=a(new Set),{data:b}=x({projection:`slim`}),S=t(()=>new Set((b??[]).map(e=>e.stableId)),[b]),C=n(async(e,t)=>{let n=B(e,t);if(n!==null){c?.(n),o();return}y(e=>new Set(e).add(t.stableId));try{await u.mutateAsync({addonId:e,candidate:t}),_(e=>new Set(e).add(t.stableId))}catch{}finally{y(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[u,o,c]),w=n((t,n)=>{let i=typeof n.prefilledConfig.host==`string`?n.prefilledConfig.host:null,a=S.has(n.stableId),o=g.has(n.stableId)||a,s=v.has(n.stableId);return e(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0`,children:[r(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),i&&r(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:i})]}),o?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[r(m,{className:`h-3.5 w-3.5`}),` `,a?l(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):l(`integrations.scanNetworkModal.added`,`Added`)]}):e(`button`,{type:`button`,onClick:()=>void C(t,n),disabled:s,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[s?r(f,{className:`h-3.5 w-3.5 animate-spin`}):r(d,{className:`h-3.5 w-3.5`}),l(`common.add`,`Add`)]})]},n.stableId)},[g,v,S,C,l]);if(!i)return null;let T=s?`Scan network — ${s.label}`:`Scan network for devices`;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[r(`div`,{className:`absolute inset-0 bg-black/60`,onClick:o}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(h,{className:`h-4 w-4 text-primary`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:T})]}),r(`button`,{onClick:o,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:r(p,{className:`h-4 w-4`})})]}),s?r(G,{scope:s,onAdopt:w,onReset:()=>_(new Set)}):r(W,{onAdopt:w,onReset:()=>_(new Set)})]})]})}function W({onAdopt:a,onReset:o}){let{t:c}=A(),u=w(),d=n(()=>{o(),u.mutate({})},[u,o]);i(()=>{!u.isPending&&!u.data&&d()},[]);let f=t(()=>(u.data?.groups??[]).filter(e=>e.candidates.length>0),[u.data]),p=t(()=>f.reduce((e,t)=>e+t.candidates.length,0),[f]);return e(s,{children:[r(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:e(`button`,{onClick:d,disabled:u.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[r(l,{className:`h-3.5 w-3.5 ${u.isPending?`animate-spin`:``}`}),c(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[u.isPending&&r(K,{label:c(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!u.isPending&&u.isError&&r(q,{}),!u.isPending&&u.data&&f.length===0&&r(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!u.isPending&&f.length>0&&r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.found`,{count:p})}),!u.isPending&&f.map(t=>e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-[11px] font-semibold text-foreground`,children:t.label}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,t.candidates.length,`)`]})]}),t.candidates.map(e=>a(t.addonId,e))]},t.addonId))]})]})}function G({scope:t,onAdopt:i,onReset:o}){let{t:c}=A(),l=b({addonId:t.addonId}).data??null,[u,d]=a({}),p=C(),m=n(()=>{o(),p.mutate({addonId:t.addonId,params:u})},[p,t.addonId,u,o]),g=p.data?.candidates??[];return r(s,{children:e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&r(j,{schema:l,values:u,onChange:d}),e(`button`,{onClick:m,disabled:p.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[p.isPending?r(f,{className:`h-3.5 w-3.5 animate-spin`}):r(h,{className:`h-3.5 w-3.5`}),p.isPending?c(`integrations.scanNetworkModal.scanning`,`Scanning…`):c(`integrations.scanNetworkModal.scan`,`Scan`)]}),p.isError&&r(q,{}),!p.isPending&&p.data&&g.length===0&&r(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!p.isPending&&g.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.foundShort`,{count:g.length})}),g.map(e=>i(t.addonId,e))]})]})})}function K({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[r(f,{className:`h-6 w-6 animate-spin text-primary`}),r(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function q(){let{t}=A();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[r(g,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),r(`p`,{className:`text-xs text-destructive`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{F as a,I as i,H as n,z as r,U as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cr as l,G as u,Ht as d,J as f,K as p,Pi as m,Q as h,Tn as g,U as _,c as v,d as ee,da as y,dt as b,f as x,l as S,ma as C,p as w,s as T,st as E,z as D}from"./player-overlays-Cl9fdVyE.js";import{t as O}from"./settings-2-BuOeZPiK.js";import{MaskShapeCanvas as te}from"./MaskShapeCanvas-B599Qff8.js";s();var k=h(`/addon/pipeline-analytics/event-media`);function A(e){return`${k}/m/${e}`}function j(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function M(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var N=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function ne({monitor:t,disabled:n,onDelete:r}){let a=C(),o=j(t),s=M(t),c=E();return o.length===0?i(`p`,{className:`${D} leading-relaxed`,children:a(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):i(`div`,{className:`flex flex-col gap-2`,children:o.map(t=>e(`div`,{className:`flex flex-col gap-1`,children:[e(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[w(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let l=`${o.stateId}:${String(o.index)}`,u=s===1;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(P,{reference:o.reference}),i(`span`,{className:`${D} tabular-nums`,children:F(o.reference.capturedAt)}),e(`button`,{type:`button`,className:N,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:w(t.condition,a).toLowerCase(),date:F(o.reference.capturedAt)}),onClick:()=>{(async()=>{u&&!await c({title:a(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:a(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`),confirmLabel:a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:o.stateId,index:o.index})})()},children:[i(d,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function P({reference:t}){let n=C(),[r,a]=o(!1),s=t.thumbnailMediaId;return s===void 0||r?e(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[i(l,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:A(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function F(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var I=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,L=`text-[10px] font-medium text-foreground-subtle`,R=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,z=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,B=5,V=3600;function H(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function U(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function W(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function G({monitor:t,disabled:n,onPatch:r}){let s=C(),[l,u]=o(()=>W(t)),[d,f]=o(!1);a(()=>{d||u(W(t))},[t,d]);let p=e=>{f(!1),r(e)},m=e=>t.check.mode===`similarity`?{mode:`similarity`,threshold:e.threshold??t.check.threshold,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount}:{...t.check,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount},h=t.confirm?.enabled===!0,g=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:l.label,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,label:e.target.value})),onBlur:()=>{let e=l.label.trim();e.length>0&&e!==t.label?p({label:e}):f(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:t.enabled,disabled:n,onChange:e=>p({enabled:e.target.checked})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(`select`,{value:t.triggerMode,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&p({triggerMode:t})},children:[i(`option`,{value:`both`,children:s(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),i(`option`,{value:`periodic`,children:s(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),i(`option`,{value:`on-motion`,children:s(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),i(`p`,{className:D,children:H(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:B,max:V,value:l.checkIntervalSec,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.checkIntervalSec,B,V);e===t.checkIntervalSec?f(!1):p({checkIntervalSec:e})}})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),t.check.mode===`similarity`&&e(c,{children:[e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:i(y,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:l.threshold.toFixed(2)}})}),i(`input`,{type:`range`,min:.3,max:.99,step:.01,value:l.threshold,disabled:n,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.threshold})})},onBlur:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.threshold})})}})]}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:l.hysteresisCount,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=K(l.hysteresisCount,1,10);e===t.check.hysteresisCount?f(!1):p({check:m({hysteresisCount:e})})}})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.quietSeconds,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.quietSeconds,0,3600);e===t.quietSeconds?f(!1):p({quietSeconds:e})}})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.minObservationSpacingSec,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?f(!1):p({minObservationSpacingSec:e})}})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(`select`,{value:t.onUncoveredCondition,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&p({onUncoveredCondition:t})},children:[i(`option`,{value:`skip`,children:s(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),i(`option`,{value:`judge-anyway`,children:s(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),i(`p`,{className:D,children:U(t.onUncoveredCondition,s)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(`select`,{value:t.emit,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&p({emit:t})},children:[i(`option`,{value:`latched`,children:s(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),i(`option`,{value:`live`,children:s(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:t.autoRestore,disabled:n,onChange:e=>p({autoRestore:e.target.checked})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:h,disabled:n||l.confirmPrompt.trim().length===0,onChange:e=>p(e.target.checked?{confirm:{...q(l.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:l.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=l.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?p({confirm:{...q(e),enabled:h}}):f(!1)}})]}),i(`p`,{className:D,children:i(y,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[i(`strong`,{},`only`)]})})]})]})}function K(e,t,n){return Math.min(n,Math.max(t,e))}function q(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var J=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,Y=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,re=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,ie={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},ae=.8,oe=3;function X({deviceId:s}){let l=C(),h=p(b().trpcClient,s),y=f(h?.state.sceneMonitor),E=u(s,{width:640}),[k,A]=o(null),[j,M]=o(!1),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[K,q]=o(``),X=t(!0);a(()=>(X.current=!0,()=>{X.current=!1}),[]);let Z=r(async()=>{if(h)try{let e=await h.sceneMonitor?.listScenes({});if(!X.current)return;e&&A(e)}catch(e){if(!X.current)return;_(e)?M(!0):I(e instanceof Error?e.message:String(e))}},[h]);a(()=>{A(null),M(!1),I(null),Z()},[Z]);let Q=y?.monitors??k?.monitors??[],se=Date.now(),$=r(async(e,t)=>{P(e),I(null);try{await t(),await Z()}catch(e){X.current&&I(e instanceof Error?e.message:String(e))}finally{X.current&&P(null)}},[Z]),ce=n(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:l(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,U,l]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>h?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[h,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||K.trim().length===0||(await $(`create`,async()=>{await h?.sceneMonitor?.createScene({label:K.trim(),roi:U,check:{mode:`similarity`,threshold:ae,hysteresisCount:oe}})}),W(null),q(``),H(!1))},[h,U,K,$]);return h?i(`div`,{className:`flex flex-col gap-3`,children:j?i(`p`,{className:`${D} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${D} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),i(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:i(te,{items:ce,supportedShapes:[`rect`],selectedId:L??(U===null?null:`__draft__`),onSelect:e=>R(e===null?null:String(e)),onShapeChange:le,onDrawComplete:ue,drawingKind:V&&U===null?`rect`:null,backdrop:E.src===null?null:i(`img`,{src:E.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`button`,{type:`button`,className:V?Y:J,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:N!==null,children:V?l(`uiLibrary.sceneMonitor.cancel`,`Cancel`):l(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:J,onClick:E.refresh,disabled:N!==null,children:l(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),V&&e(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U===null?l(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):l(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&ee(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:l(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`text`,value:K,onChange:e=>q(e.target.value),placeholder:l(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),i(`button`,{type:`button`,className:Y,onClick:()=>void de(),disabled:U===null||K.trim().length===0||N!==null,children:l(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),F!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:F}),Q.length===0?i(`p`,{className:`${D} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Q.map(t=>{let n=v(t,l);return e(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${L===t.id?`border-primary/50`:`border-border`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>R(t.id),children:t.label}),i(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${ie[n.tone]}`,children:n.text})]}),i(`p`,{className:`${D} leading-relaxed`,children:x(t,se,l)}),i(`p`,{className:`${D} tabular-nums`,children:S(t,l)}),i(ne,{monitor:t,disabled:N!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>h.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[T.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:J,disabled:N!==null,title:r?l(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):l(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:w(n,l).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>h.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(m,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:w(n,l).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:l(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:Y,disabled:N!==null||t.states.length===0,title:l(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>h.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(g,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:J,disabled:N!==null,onClick:()=>void $(`check-${t.id}`,async()=>h.sceneMonitor?.recheckNow({monitorId:t.id})),children:l(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?Y:J,"aria-pressed":z===t.id,"aria-label":l(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:N!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(O,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:re,disabled:N!==null,onClick:()=>void $(`del-${t.id}`,async()=>h.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(d,{className:`h-3 w-3`})})]}),z===t.id&&i(G,{monitor:t,disabled:N!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>h.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{X as SceneMonitorEditor};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cr as l,G as u,Ht as d,J as f,K as p,Pi as m,Q as h,Tn as g,U as _,c as v,d as ee,da as y,dt as b,f as x,l as S,ma as C,p as w,s as T,st as E,z as D}from"./player-overlays-C_WpL6a6.js";import{t as O}from"./settings-2-Cc7_8hT4.js";import{MaskShapeCanvas as te}from"./MaskShapeCanvas-Bv7J_UVF.js";s();var k=h(`/addon/pipeline-analytics/event-media`);function A(e){return`${k}/m/${e}`}function j(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function M(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var N=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function ne({monitor:t,disabled:n,onDelete:r}){let a=C(),o=j(t),s=M(t),c=E();return o.length===0?i(`p`,{className:`${D} leading-relaxed`,children:a(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):i(`div`,{className:`flex flex-col gap-2`,children:o.map(t=>e(`div`,{className:`flex flex-col gap-1`,children:[e(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[w(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let l=`${o.stateId}:${String(o.index)}`,u=s===1;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(P,{reference:o.reference}),i(`span`,{className:`${D} tabular-nums`,children:F(o.reference.capturedAt)}),e(`button`,{type:`button`,className:N,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:w(t.condition,a).toLowerCase(),date:F(o.reference.capturedAt)}),onClick:()=>{(async()=>{u&&!await c({title:a(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:a(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`),confirmLabel:a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:o.stateId,index:o.index})})()},children:[i(d,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function P({reference:t}){let n=C(),[r,a]=o(!1),s=t.thumbnailMediaId;return s===void 0||r?e(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[i(l,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:A(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function F(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var I=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,L=`text-[10px] font-medium text-foreground-subtle`,R=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,z=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,B=5,V=3600;function H(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function U(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function W(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function G({monitor:t,disabled:n,onPatch:r}){let s=C(),[l,u]=o(()=>W(t)),[d,f]=o(!1);a(()=>{d||u(W(t))},[t,d]);let p=e=>{f(!1),r(e)},m=e=>t.check.mode===`similarity`?{mode:`similarity`,threshold:e.threshold??t.check.threshold,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount}:{...t.check,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount},h=t.confirm?.enabled===!0,g=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:l.label,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,label:e.target.value})),onBlur:()=>{let e=l.label.trim();e.length>0&&e!==t.label?p({label:e}):f(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:t.enabled,disabled:n,onChange:e=>p({enabled:e.target.checked})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(`select`,{value:t.triggerMode,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&p({triggerMode:t})},children:[i(`option`,{value:`both`,children:s(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),i(`option`,{value:`periodic`,children:s(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),i(`option`,{value:`on-motion`,children:s(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),i(`p`,{className:D,children:H(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:B,max:V,value:l.checkIntervalSec,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.checkIntervalSec,B,V);e===t.checkIntervalSec?f(!1):p({checkIntervalSec:e})}})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),t.check.mode===`similarity`&&e(c,{children:[e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:i(y,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:l.threshold.toFixed(2)}})}),i(`input`,{type:`range`,min:.3,max:.99,step:.01,value:l.threshold,disabled:n,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.threshold})})},onBlur:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.threshold})})}})]}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:l.hysteresisCount,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=K(l.hysteresisCount,1,10);e===t.check.hysteresisCount?f(!1):p({check:m({hysteresisCount:e})})}})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.quietSeconds,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.quietSeconds,0,3600);e===t.quietSeconds?f(!1):p({quietSeconds:e})}})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.minObservationSpacingSec,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?f(!1):p({minObservationSpacingSec:e})}})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(`select`,{value:t.onUncoveredCondition,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&p({onUncoveredCondition:t})},children:[i(`option`,{value:`skip`,children:s(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),i(`option`,{value:`judge-anyway`,children:s(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),i(`p`,{className:D,children:U(t.onUncoveredCondition,s)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(`select`,{value:t.emit,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&p({emit:t})},children:[i(`option`,{value:`latched`,children:s(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),i(`option`,{value:`live`,children:s(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:t.autoRestore,disabled:n,onChange:e=>p({autoRestore:e.target.checked})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:D,children:s(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:h,disabled:n||l.confirmPrompt.trim().length===0,onChange:e=>p(e.target.checked?{confirm:{...q(l.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:l.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=l.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?p({confirm:{...q(e),enabled:h}}):f(!1)}})]}),i(`p`,{className:D,children:i(y,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[i(`strong`,{},`only`)]})})]})]})}function K(e,t,n){return Math.min(n,Math.max(t,e))}function q(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var J=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,Y=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,re=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,ie={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},ae=.8,oe=3;function X({deviceId:s}){let l=C(),h=p(b().trpcClient,s),y=f(h?.state.sceneMonitor),E=u(s,{width:640}),[k,A]=o(null),[j,M]=o(!1),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[K,q]=o(``),X=t(!0);a(()=>(X.current=!0,()=>{X.current=!1}),[]);let Z=r(async()=>{if(h)try{let e=await h.sceneMonitor?.listScenes({});if(!X.current)return;e&&A(e)}catch(e){if(!X.current)return;_(e)?M(!0):I(e instanceof Error?e.message:String(e))}},[h]);a(()=>{A(null),M(!1),I(null),Z()},[Z]);let Q=y?.monitors??k?.monitors??[],se=Date.now(),$=r(async(e,t)=>{P(e),I(null);try{await t(),await Z()}catch(e){X.current&&I(e instanceof Error?e.message:String(e))}finally{X.current&&P(null)}},[Z]),ce=n(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:l(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,U,l]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>h?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[h,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||K.trim().length===0||(await $(`create`,async()=>{await h?.sceneMonitor?.createScene({label:K.trim(),roi:U,check:{mode:`similarity`,threshold:ae,hysteresisCount:oe}})}),W(null),q(``),H(!1))},[h,U,K,$]);return h?i(`div`,{className:`flex flex-col gap-3`,children:j?i(`p`,{className:`${D} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${D} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),i(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:i(te,{items:ce,supportedShapes:[`rect`],selectedId:L??(U===null?null:`__draft__`),onSelect:e=>R(e===null?null:String(e)),onShapeChange:le,onDrawComplete:ue,drawingKind:V&&U===null?`rect`:null,backdrop:E.src===null?null:i(`img`,{src:E.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`button`,{type:`button`,className:V?Y:J,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:N!==null,children:V?l(`uiLibrary.sceneMonitor.cancel`,`Cancel`):l(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:J,onClick:E.refresh,disabled:N!==null,children:l(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),V&&e(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U===null?l(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):l(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&ee(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:l(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`text`,value:K,onChange:e=>q(e.target.value),placeholder:l(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),i(`button`,{type:`button`,className:Y,onClick:()=>void de(),disabled:U===null||K.trim().length===0||N!==null,children:l(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),F!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:F}),Q.length===0?i(`p`,{className:`${D} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Q.map(t=>{let n=v(t,l);return e(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${L===t.id?`border-primary/50`:`border-border`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>R(t.id),children:t.label}),i(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${ie[n.tone]}`,children:n.text})]}),i(`p`,{className:`${D} leading-relaxed`,children:x(t,se,l)}),i(`p`,{className:`${D} tabular-nums`,children:S(t,l)}),i(ne,{monitor:t,disabled:N!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>h.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[T.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:J,disabled:N!==null,title:r?l(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):l(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:w(n,l).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>h.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(m,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:w(n,l).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:l(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:Y,disabled:N!==null||t.states.length===0,title:l(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>h.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(g,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:J,disabled:N!==null,onClick:()=>void $(`check-${t.id}`,async()=>h.sceneMonitor?.recheckNow({monitorId:t.id})),children:l(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?Y:J,"aria-pressed":z===t.id,"aria-label":l(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:N!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(O,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:re,disabled:N!==null,onClick:()=>void $(`del-${t.id}`,async()=>h.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(d,{className:`h-3 w-3`})})]}),z===t.id&&i(G,{monitor:t,disabled:N!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>h.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{X as SceneMonitorEditor};
|