@camstack/addon-admin-ui 1.2.489 → 1.2.490

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.
Files changed (124) hide show
  1. package/dist/assets/{AddonAssetIcon-C0cWByHj.js → AddonAssetIcon-D-9BDtpk.js} +1 -1
  2. package/dist/assets/{Addons-DtmmHLxt.js → Addons-51TvRwwb.js} +1 -1
  3. package/dist/assets/{AdminPage-D6Yva5zf.js → AdminPage-CdT4_4OP.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-ytDsnoAA.js → AdminSectionedPage-p7IoxWdQ.js} +1 -1
  5. package/dist/assets/AiProfiles-WM5GT1_g.js +3 -0
  6. package/dist/assets/{BrokerEditorDialog-CTEagRft.js → BrokerEditorDialog-C9R9WJ5j.js} +1 -1
  7. package/dist/assets/Build-DmG4Bqo3.js +40 -0
  8. package/dist/assets/{Calendars-BzsJnrEA.js → Calendars-CNjiX8AQ.js} +1 -1
  9. package/dist/assets/{Cluster-C2D1ovUW.js → Cluster-Cs8jI_us.js} +1 -1
  10. package/dist/assets/{CompositionBlockEditor-CYmfatQE.js → CompositionBlockEditor-DM8TH06u.js} +1 -1
  11. package/dist/assets/{CompositionEditorPage-B5Cgu9cj.js → CompositionEditorPage-7ZGq3V5I.js} +1 -1
  12. package/dist/assets/{Data-ChStbBhF.js → Data-B4v6EPpd.js} +1 -1
  13. package/dist/assets/DeviceDetail-DN1pAPt3.js +2 -0
  14. package/dist/assets/{DeviceDoActionFields-GHZBRE4Q.js → DeviceDoActionFields-Bug4MwQJ.js} +1 -1
  15. package/dist/assets/{Devices-Bzyikktm.js → Devices-KmaQ-LCF.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-ClpQaFoO.js → EmbedPlayerPage-BY2XhLHQ.js} +1 -1
  17. package/dist/assets/HelperWizard-Drtw6fE7.js +2 -0
  18. package/dist/assets/{History-C6N6VRgs.js → History-Cki8lIL-.js} +1 -1
  19. package/dist/assets/{Identity-CvFSqL46.js → Identity-BtyNBp3O.js} +1 -1
  20. package/dist/assets/{IntegrationDetail-AVnEA7GO.js → IntegrationDetail-CDuDFjTz.js} +1 -1
  21. package/dist/assets/{IntegrationHub-BqWPAkYu.js → IntegrationHub-MVJMjpE_.js} +1 -1
  22. package/dist/assets/{Integrations-BYiw8_da.js → Integrations-DK3VNmwY.js} +1 -1
  23. package/dist/assets/{Integrations-CBEyPYvE.js → Integrations-DylF9Lra.js} +1 -1
  24. package/dist/assets/{Library-BcuUHsq3.js → Library-CThT-nC_.js} +1 -1
  25. package/dist/assets/{Locations-BrPK_nfE.js → Locations-hoUXKzbY.js} +1 -1
  26. package/dist/assets/{Logs-D_Jnlf_J.js → Logs-CuZNCBMH.js} +1 -1
  27. package/dist/assets/{MaskShapeCanvas-C1WSjh5s.js → MaskShapeCanvas-H8Uoh2Rl.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-BB6LidaW.js → MotionZonesSettings-D0q6jZRy.js} +1 -1
  29. package/dist/assets/{MyAccess-DjL1Z681.js → MyAccess-DJ_NSf4z.js} +1 -1
  30. package/dist/assets/{Network-DjKf4STc.js → Network-D2CWuowx.js} +1 -1
  31. package/dist/assets/{NodeAddonsSettingsPanel-ivvFi7qU.js → NodeAddonsSettingsPanel-ByFvh4Ya.js} +1 -1
  32. package/dist/assets/Notifications-PhkAhPCl.js +1 -0
  33. package/dist/assets/Pipeline-CezBMByn.js +1 -0
  34. package/dist/assets/{PrivacyMaskSettings-CSdKuS75.js → PrivacyMaskSettings-fx9Jt4aq.js} +1 -1
  35. package/dist/assets/{Recordings-Ce8DTG1O.js → Recordings-DR4bIAm9.js} +1 -1
  36. package/dist/assets/{ScanNetworkModal-81xkyJSk.js → ScanNetworkModal-BqRIkfLs.js} +1 -1
  37. package/dist/assets/{SceneMonitorEditor-ucsduhsM.js → SceneMonitorEditor-B1yZ0Eu1.js} +1 -1
  38. package/dist/assets/{SessionsList-Dgrg9zT1.js → SessionsList-BgP3ZBPl.js} +1 -1
  39. package/dist/assets/{Showroom-CkHdCDH1.js → Showroom-H799SxeX.js} +1 -1
  40. package/dist/assets/{System-HvIXTTB1.js → System-CAQNJeVw.js} +1 -1
  41. package/dist/assets/{Terminal-CwE2WbSi.js → Terminal-CJDf-QFe.js} +1 -1
  42. package/dist/assets/{Viewer-B6suHwLq.js → Viewer-bvftBy-T.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BkS64PhS.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-B7Juvi98.js} +1 -1
  44. package/dist/assets/{addon-icons-context-BY_MClqz.js → addon-icons-context-CZDtt3fG.js} +1 -1
  45. package/dist/assets/{archive-DSecC29S.js → archive-C0MjJGmq.js} +1 -1
  46. package/dist/assets/{assignment-candidates-CCD35Rpj.js → assignment-candidates--urRZfaK.js} +1 -1
  47. package/dist/assets/{authed-media-Dow1_6zk.js → authed-media-CQZkp0uZ.js} +1 -1
  48. package/dist/assets/{bell-off-kKEnaAlY.js → bell-off-B11l1KzS.js} +1 -1
  49. package/dist/assets/{board-model-CGmvb_0S.js → board-model-BnBpDyVJ.js} +1 -1
  50. package/dist/assets/{boxes-D29FuJd_.js → boxes-B-VqzPaN.js} +1 -1
  51. package/dist/assets/circle-slash-DpPZDUlw.js +1 -0
  52. package/dist/assets/client-BXtMEX7J.js +358 -0
  53. package/dist/assets/{cloud-upload-CNHrN4UO.js → cloud-upload--LDpDxLV.js} +1 -1
  54. package/dist/assets/crop-8n46w7Ev.js +1 -0
  55. package/dist/assets/{device-integration-icon-Dg_7SOuH.js → device-integration-icon-DcyxPquH.js} +1 -1
  56. package/dist/assets/device-picker-model-BQTVmtuR.js +1 -0
  57. package/dist/assets/dist-DhXv40Tk.js +358 -0
  58. package/dist/assets/{dist-pyNtUJBC.js → dist-oBKSec40.js} +1 -1
  59. package/dist/assets/{eraser-DQdA4r-4.js → eraser-DolDpTaf.js} +1 -1
  60. package/dist/assets/{format-CvRuKl82.js → format-pVRrtm44.js} +1 -1
  61. package/dist/assets/{hard-drive-download-BWtxkXEP.js → hard-drive-download-Dxd7SImQ.js} +1 -1
  62. package/dist/assets/{hostInit-C4zImIaq.js → hostInit-CXxiiIY9.js} +1 -1
  63. package/dist/assets/i18n-CI5vBtLY.js +1 -0
  64. package/dist/assets/{icons-CeHJ12H1.js → icons-BXkvTO6P.js} +1 -1
  65. package/dist/assets/{index-4kmzPYxW.js → index-T3VEitv1.js} +3 -3
  66. package/dist/assets/{key-ibd36DX6.js → key-BBVN8veo.js} +1 -1
  67. package/dist/assets/{key-round-Cx5S95mB.js → key-round-DFWP4tGQ.js} +1 -1
  68. package/dist/assets/{layers-f2rCYTNI.js → layers-VCbN12xK.js} +1 -1
  69. package/dist/assets/{linked-devices-model-DBaDc0Fe.js → linked-devices-model-BuZsJyfK.js} +1 -1
  70. package/dist/assets/{list-ordered-DVEuSX72.js → list-ordered-Bnu2an56.js} +1 -1
  71. package/dist/assets/{location-owned-usage-D20qY7jM.js → location-owned-usage-CWqIQnLv.js} +1 -1
  72. package/dist/assets/{log-in-YSzSSnpb.js → log-in-QKfmNI9M.js} +1 -1
  73. package/dist/assets/{memory-stick-BxkFX9Lp.js → memory-stick-ByO8UQ_K.js} +1 -1
  74. package/dist/assets/{message-square-plus-CReLm1AI.js → message-square-plus-DiTP4R_X.js} +1 -1
  75. package/dist/assets/{mf-entry-bootstrap-0-3901d897.js → mf-entry-bootstrap-0-4541da62.js} +2 -2
  76. package/dist/assets/{mic-off-CzIbHCeE.js → mic-off-C0mR7Yh9.js} +1 -1
  77. package/dist/assets/{monitor-off-D6AnJas6.js → monitor-off-D4PWqGzI.js} +1 -1
  78. package/dist/assets/{monitor-smartphone-BYEnK_6t.js → monitor-smartphone-CfagfDx-.js} +1 -1
  79. package/dist/assets/mount-BQTVmtuR.js +1 -0
  80. package/dist/assets/{player-overlays-nQJCQERn.js → player-overlays-BiCGuJYq.js} +1 -1
  81. package/dist/assets/{recycle-CWMxz1Q3.js → recycle-By0RJmi2.js} +1 -1
  82. package/dist/assets/remoteEntry-QPteGTQh.js +1 -0
  83. package/dist/assets/{scan-eye-t_4fVxI4.js → scan-eye-BiviIx2-.js} +1 -1
  84. package/dist/assets/{scissors-DL5nVl1a.js → scissors-M9cnfGNe.js} +1 -1
  85. package/dist/assets/{search-x-CbPl9Xi3.js → search-x-BpDq9t4w.js} +1 -1
  86. package/dist/assets/{send-BQl_zLK4.js → send-CeinPhnc.js} +1 -1
  87. package/dist/assets/{settings-2-7F6aVC_u.js → settings-2-D03xdo5Y.js} +1 -1
  88. package/dist/assets/{sigma-kEBBYTCa.js → sigma-BZFLmOnk.js} +1 -1
  89. package/dist/assets/{speaker-CkI0pe60.js → speaker-BhDPU-6o.js} +1 -1
  90. package/dist/assets/src-BjL-Slsn.js +67 -0
  91. package/dist/assets/{step-inspector-model-HSCaPOVt.js → step-inspector-model-BIqRCy44.js} +1 -1
  92. package/dist/assets/{table-2-Cukv2oib.js → table-2-CgTH2D0_.js} +1 -1
  93. package/dist/assets/{timer-reset-hysIbh2s.js → timer-reset-kr9YJtPF.js} +1 -1
  94. package/dist/assets/{ungroup-D4Nql8ck.js → ungroup-DfwG9mBj.js} +1 -1
  95. package/dist/assets/{unlink-DNVVxO6S.js → unlink-BPmdzYDS.js} +1 -1
  96. package/dist/assets/{usb-DNmhv4AW.js → usb-DXw4Me1_.js} +1 -1
  97. package/dist/assets/{use-scenes-feed-BUQTm5ig.js → use-scenes-feed-B9V1zhs9.js} +1 -1
  98. package/dist/assets/{use-stationary-objects-B4f1cFoy.js → use-stationary-objects-ClCDS30T.js} +1 -1
  99. package/dist/assets/useEventInvalidation-BQTVmtuR.js +1 -0
  100. package/dist/assets/{useNodeUrlSelection-BKSL_pMO.js → useNodeUrlSelection-BWBjwQx2.js} +1 -1
  101. package/dist/assets/user-round-Uear1YP1.js +1 -0
  102. package/dist/assets/{user-x-DGZKKLZG.js → user-x-Dv1oqFyS.js} +1 -1
  103. package/dist/assets/{video-DEeXGFHo.js → video-C46Ugbpc.js} +1 -1
  104. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CF1E4s_B.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bi73_PFJ.js} +2 -2
  105. package/dist/index.html +9 -9
  106. package/dist/server/addon.js +21 -5
  107. package/package.json +1 -1
  108. package/dist/assets/AiProfiles-Dr62eghf.js +0 -3
  109. package/dist/assets/Build-B8CmNZth.js +0 -40
  110. package/dist/assets/DeviceDetail-B4rdvagQ.js +0 -2
  111. package/dist/assets/HelperWizard-C9VjtAAi.js +0 -2
  112. package/dist/assets/Notifications-Ck0_YzEY.js +0 -1
  113. package/dist/assets/Pipeline-4J5lhNWd.js +0 -1
  114. package/dist/assets/circle-slash-BEdaE_jf.js +0 -1
  115. package/dist/assets/client-CdHPjeIs.js +0 -358
  116. package/dist/assets/crop-E8rhIxyE.js +0 -1
  117. package/dist/assets/device-picker-model-CdWcoivb.js +0 -1
  118. package/dist/assets/dist-CMh2DitE.js +0 -358
  119. package/dist/assets/i18n-Dgilx0WT.js +0 -1
  120. package/dist/assets/mount-CdWcoivb.js +0 -1
  121. package/dist/assets/remoteEntry-BNS8ga8f.js +0 -1
  122. package/dist/assets/src-DzfpPZrG.js +0 -67
  123. package/dist/assets/useEventInvalidation-CdWcoivb.js +0 -1
  124. package/dist/assets/user-round-I0Uty2ao.js +0 -1
@@ -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{Cr as l,Gr as u,Ir as d,Lt as f,Oi as p,Pt as m,Y as h,Yr as g,ci as _,dt as v,na as y,ot as b,sr as x}from"./player-overlays-nQJCQERn.js";import{Qa as S}from"./client-CdHPjeIs.js";import{n as C,t as w}from"./scissors-DL5nVl1a.js";import{$r as T,Cc as E,Cn as D,Dc as O,Dr as k,Er as A,Gl as j,Hl as M,Jl as N,Kl as ee,Kr as P,Od as F,Sn as I,Td as L,Ul as te,Wl as ne,Yl as re,Zr as R,_r as ie,au as ae,cu as oe,dr as se,du as ce,eu as le,fr as ue,fu as de,gi as z,gr as fe,gu as pe,hr as me,hu as he,kc as ge,lu as _e,mu as ve,nl as ye,nu as be,ol as xe,ou as Se,pr as Ce,pu as we,ql as Te,ru as B,su as Ee,uu as De,xc as Oe,xo as V,yi as H}from"./src-DzfpPZrG.js";import{t as U}from"./i18n-Dgilx0WT.js";import{t as W}from"./useTranslation-BJr-n0es.js";import{E as ke,S as Ae,ur as je}from"./index-4kmzPYxW.js";import{t as Me}from"./AdminSectionedPage-ytDsnoAA.js";import{n as Ne}from"./authed-media-Dow1_6zk.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-D20qY7jM.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}=ne({},{refetchOnWindowFocus:!1}),{data:f,isLoading:p,isError:h}=O({},{refetchOnWindowFocus:!1}),{data:g}=V({isCamera:!0,projection:`slim`}),_=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),v=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`)),h&&o!==`recording`&&e.push(n(`common.events`)),e},[d,h,o,n]),S=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`:_.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:_.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):`—`})}],[_,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&&v.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):v.length===0?b.length>0?r(A,{icon:m,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:S})}):r(A,{icon:y,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(m,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:b.length,names:S})]}),r(I,{columns:C,rows:v,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:D,defaultSort:Ge})]})]})}o();function Je(){let{t:n}=W(),i=V({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(A,{icon:p,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(P,{deviceId:l,children:r(ke,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}o();function K({types:n}){let{t:i}=W(),o=s(),c=R(),{data:l}=B({}),u=be(),d=t(()=>u.data??[],[u.data]),{data:f}=te({},{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=pe({onSuccess:v}),b=le({onSuccess:v}),x=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]),S=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}))},C=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 b.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`})&&b.mutate({id:e.id,force:!0})}},w=n.map(e=>d.find(t=>t.id===e)).filter(e=>e!==void 0);return e(`div`,{className:`space-y-3`,children:[w.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:i(`pipeline.storageLocationsPanel.noStorageLocationsDeclaredFor`,`No storage locations declared for this purpose.`)}):w.map(e=>r(Le,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:x.get(e.id)??[],onAdd:e=>h(e),onEdit:e=>_(e),onDelete:e=>{C(e)},ownedBytesById:p,onSetMode:(e,t)=>{S(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 q=`pipeline-analytics`;function Ye(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 Xe(){let{t:n}=W(),i=s(),{nodes:a}=L(),{data:o,isLoading:c}=z({addonId:q}),l=Ye(o),u=H({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(x,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:q,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(x,{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(K,{types:[`eventMedia`]})]})]})}o();var Ze=[[`pipelineAnalytics`]],Qe=1440*60*1e3;function $e(e,t){return t.get(e)??U.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var et=[{days:1},{days:7},{days:30},{days:90}];function tt(){let{t:i}=W(),o=s(),c=R(),[l,u]=a(30),[d,p]=a(null),{data:m,isLoading:_}=E({},{refetchOnWindowFocus:!1}),{data:v}=V({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),b=n(()=>{o.invalidateQueries({queryKey:Ze})},[o]),S=ge({onSuccess:b}),C=Oe(),T=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:l}),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`})&&S.mutate({olderThanMs:Date.now()-l*Qe,reason:`retention`})},[c,S,l,i]),D=n(async e=>{let t=$e(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`})){p(null);try{let n=await C.mutateAsync({deviceId:e.deviceId});b();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){p(`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}p(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){p(e instanceof Error?e.message:String(e))}}},[c,C,y,b,i]),O=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:$e(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:C.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(f,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[y,D,C.isPending,i]);return _&&!m?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):m?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(h,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(g,{className:`h-3 w-3`}),footer:`across ${String(m.devices.length)} camera${m.devices.length===1?``:`s`}`,children:m.totalRows.toLocaleString()}),r(h,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:G(m.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:l,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:et.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(`button`,{onClick:()=>{T()},disabled:S.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:[S.isPending?r(x,{className:`h-3 w-3 animate-spin`}):r(w,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),m.devices.length===0?r(A,{icon:g,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(I,{columns:O,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480}),d===null?null:r(`p`,{className:d.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:d})]}):r(A,{icon:g,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function nt(){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(tt,{})})]}),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(Xe,{})})]})]})}function rt(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 it(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function at(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`${it(e)} · ${o}`}function ot(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 st(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 ct=[`high`,`mid`,`low`],lt=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],ut=10080*60*1e3;function dt(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 ft({onClose:n,onCreated:i}){let{t:o}=W(),s=V({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[l,u]=a(``),[f,p]=a(`high`),[m,h]=a(dt(60)),[g,_]=a(dt(0)),[v,y]=a(1),[b,x]=a(!0),[S,C]=a(``),[w,E]=a(null),D=l===``?c[0]?.id??null:l,O=new Date(m).getTime(),k=new Date(g).getTime(),A=Number.isFinite(O)&&Number.isFinite(k)&&O<k,j=Te({onSuccess:()=>{i(),n()},onError:e=>E(e instanceof Error?e.message:String(e))});return r(se,{open:!0,onOpenChange:e=>!e&&n(),children:e(Ce,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(fe,{children:e(ie,{className:`flex items-center gap-1.5`,children:[r(d,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(ue,{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:D??``,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:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:ct.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:lt.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`)]}),!A&&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(me,{children:[r(T,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(T,{size:`sm`,onClick:()=>{if(D===null||!A)return;E(null);let e=S.trim();j.mutate({deviceId:D,profile:f,fromMs:O,toMs:k,options:{includeAudio:b,maxLifeMs:ut,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:D===null||!A||j.isPending,children:j.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var pt=[[`recordingExport`]],mt={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 ht(){let{data:e,isLoading:n}=re({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=F(S.RecordingExportProgress,e=>e.exportId),{map:i}=F(S.RecordingExportCompleted,e=>e.exportId),{map:a}=F(S.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>st(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function gt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function _t(){let{t:i}=W(),o=s(),[c,l]=a(!1),p=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},m=R(),h=b().trpcClient,g=gt(6e4),{rows:v,isLoading:y}=ht(),{data:S}=V({isCamera:!0,projection:`slim`}),C=t(()=>{let e=new Map;for(let t of S??[])e.set(t.id,t.name);return e},[S]),w=n(()=>{o.invalidateQueries({queryKey:pt})},[o]),T=ee({onSuccess:w}),E=N({onSuccess:w}),[D,O]=a(null),k=n(async e=>{O(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),w()}finally{O(null)}},[h,w]),j=n(async e=>{await m({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`})&&T.mutate({exportId:e.id})},[m,T,i]),M=n(async e=>{await m({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`})&&E.mutate({exportId:e.id})},[m,E,i]),P=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:C.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:at(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:rt(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=mt[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(x,{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:ot(e.expiresAt,g)})},{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:()=>{k(t)},disabled:D===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:[D===t.id?r(x,{className:`h-3 w-3 animate-spin`}):r(u,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(`button`,{onClick:()=>{j(t)},disabled:T.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(_,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(`button`,{onClick:()=>{M(t)},disabled:E.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(f,{className:`h-3 w-3`})})]})}}],[C,g,D,T.isPending,E.isPending,k,j,M,i]);return y&&v.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{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:()=>l(!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(d,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),v.length===0?r(A,{icon:d,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(I,{columns:P,rows:v,rowKey:e=>e.id,minWidthPx:720}),c&&r(ft,{onClose:()=>l(!1),onCreated:p})]})}var vt=`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 yt=`storage-migration`,bt=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function xt(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 St(){let{t:e}=W(),t=k(yt);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(Ct,{}):null}function Ct(){let{t}=W(),n=R(),[i,o]=a(!1),[s,c]=a(null),l=oe({},{refetchInterval:2e3}),u=l.data??null,d=u!==null&&bt.has(u.phase),p=Ee(),m=Se(),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 l.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},g=async()=>{if(u&&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:u.jobId}),await l.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:d,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:d||p.isPending,onClick:()=>{h()},className:vt,children:[(d||p.isPending)&&r(x,{className:`h-3 w-3 animate-spin`}),r(f,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),d&&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}),u&&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:u.phase}),d&&r(x,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),u.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:u.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:xt(u)}),u.error&&r(`p`,{className:`text-[11px] text-danger`,children:u.error})]})]})}o();var wt=2e3;function Tt(){let{t}=W(),n=R(),a=s(),o=xe(),c=ye(void 0,{refetchInterval:e=>e.state.data?.state===`running`?wt:!1}),u=c.data,d=u?.state===`running`,f=d||o.isPending;i(()=>{u?.state!==`done`||u.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[u?.state,u?.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?u.total>0?`Reconciling ${String(u.completed)}/${String(u.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(x,{className:`h-3.5 w-3.5 animate-spin`}):r(l,{className:`h-3.5 w-3.5`}),m]}),u?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(u.completed),tracks:String(u.tracks),events:String(u.events),media:String(u.mediaDropped)}),u.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(u.failed.length),value2:u.failed.join(`, `)}):``,`.`]}):null,u?.state===`error`&&u.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,u.error]}):null]})]})}var J=1e3,Y=60*J,X=60*Y;function Z(e){return e.toLocaleString(`en-US`)}function Et(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=X){let t=Math.floor(e/X),n=Math.round(e%X/Y);return`${t.toString()}h ${n.toString()}m`}if(e>=Y){let t=Math.floor(e/Y),n=Math.round(e%Y/J);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/J)).toString()}s`}function Dt(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${Z(e.filesMoved)} files`:`${Z(e.filesMoved)} / ${Z(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*J)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${Et(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${G(e.bytesMoved)} moved`,rate:a,eta:s}}function Ot(e){let t=Dt(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var kt=`storage-migration`,Q=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],At=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function jt(){let{t}=W(),n=k(kt);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(A,{icon:m,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(A,{icon:C,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(Mt,{})}function Mt(){let{t:n}=W(),i=R(),{data:o}=B({}),[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]),_=he({},{refetchInterval:2e3}),y=_.data??null,b=y!==null&&At.has(y.phase),S=t(()=>{let e={};for(let t of Q){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),w=t(()=>{let e={};for(let t of Q){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]),T=t(()=>({destinations:S??{},...w?{sources:w}:{}}),[S,w]),E=de(T,{enabled:!1,retry:!1}),D=ve(),O=ae(),k=async()=>{if(!S)return;m(null);let e=await E.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},A=async()=>{if(S&&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 D.mutateAsync(T),f(null),await _.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},j=async()=>{if(y&&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 O.mutateAsync({jobId:y.jobId}),await _.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(C,{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:Q.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:b,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:b,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:()=>{k()},disabled:!S||E.isFetching||b,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:[E.isFetching&&r(x,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(`button`,{type:`button`,onClick:()=>{A()},disabled:!S||D.isPending||b,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:[D.isPending&&r(x,{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}`))}),y&&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`)}),b&&e(`button`,{type:`button`,onClick:()=>{j()},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:y.phase}),b&&r(x,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),y.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:y.error}),y.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,y.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:y.moves.map(e=>r(Nt,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(Pt,{})]}),r(Ft,{running:b}),r(Lt,{})]})}function Nt({move:t}){let{t:n}=W(),i=t.progress===null?null:Dt(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:Ot(t.progress)})]})]})}function Pt(){let{t}=W(),{data:n}=De({});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 Ft({running:t}){let{t:n}=W(),i=R(),o=we({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=_e(),[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:It(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 It(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 Lt(){let{t}=W(),{data:n}=ce({},{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:Ot({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function Rt(){let{t}=W();return e(`div`,{className:`flex flex-col gap-4`,children:[r(St,{}),r(Tt,{}),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(jt,{})})]})]})}o();var zt=`recorder`;function Bt(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 Vt(){let{t:n}=W(),i=s(),{nodes:a}=L(),{data:o,isLoading:c}=z({addonId:zt}),l=Bt(o,`recordingNodeId`,`hub`),u=H({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(x,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:zt,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(x,{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(K,{types:[`recordings`,`recordingsLow`]})]})]})}function Ht(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Ut(e,t){let n=Ht(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=>Ht(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=R(),[u,d]=a(`retention`),{data:p,isLoading:m}=te({},{refetchOnWindowFocus:!1}),{data:g}=V({isCamera:!0,projection:`slim`}),{data:_}=B({}),v=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),y=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.displayName);return e},[_]),b=t(()=>{let e=_??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[_]),S=t(()=>p?.locations??[],[p?.locations]),C=t(()=>Wt(S,y,b),[S,y,b]),T=t(()=>Fe(S),[S]),E=n(()=>{o.invalidateQueries({queryKey:Gt})},[o]),D=j({onSuccess:E}),O=M({onSuccess:E}),k=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:v.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:u}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&D.mutate({deviceId:e.deviceId,reason:u})},[c,D,u,v,i]),N=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:v.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`})&&O.mutate({deviceId:e.deviceId})},[c,O,v,i]),ee=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:v.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>C===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:C.exact?`text-foreground`:`text-foreground-subtle`,title:C.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:[C.label,!C.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:()=>{k(t)},disabled:D.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(w,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(`button`,{onClick:()=>{N(t)},disabled:O.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(f,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[v,C,k,N,D.isPending,O.isPending,i]);if(m&&!p)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!p)return r(A,{icon:l,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let P=p.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(h,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(l,{className:`h-3 w-3`}),footer:`${String(P)} camera${P===1?``:`s`} on ${p.nodeId}`,children:G(p.totalUsedBytes)}),T!==null&&T.severity!==null&&r(h,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(l,{className:`h-3 w-3`}),footer:`across ${String(T.knownVolumes)} volume${T.knownVolumes===1?``:`s`} of ${G(T.totalBytes)}`+(T.unknownVolumes>0?` · ${String(T.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Jt[T.severity]}`,children:G(T.freeBytes)})}),S.map(t=>{let n=ze(t),a=t.locationId??t.root??`default`;return r(h,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Xt(t,y)}),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:u,onChange:e=>{let t=Kt.find(t=>t.value===e.target.value);t&&d(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))})]}),P===0?r(A,{icon:l,title:p.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:p.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(I,{columns:ee,rows:[...p.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(Vt,{})})]})]})}function $t(){let{t:e}=W(),t=Ae(`/recordings`,{t:e,isAdmin:!0})??{icon:d,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(nt,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Je,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(_t,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(qe,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(Rt,{})}]})}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{Cr as l,Gr as u,Ir as d,Lt as f,Oi as p,Pt as m,Y as h,Yr as g,ci as _,dt as v,na as y,ot as b,sr as x}from"./player-overlays-BiCGuJYq.js";import{no as S}from"./client-BXtMEX7J.js";import{n as C,t as w}from"./scissors-M9cnfGNe.js";import{$r as T,Cc as E,Cn as D,Dc as O,Dr as k,Er as A,Gl as j,Hl as M,Jl as N,Kl as ee,Kr as P,Od as F,Sn as I,Td as L,Ul as te,Wl as ne,Yl as re,Zr as R,_r as ie,au as ae,cu as oe,dr as se,du as ce,eu as le,fr as ue,fu as de,gi as z,gr as fe,gu as pe,hr as me,hu as he,kc as ge,lu as _e,mu as ve,nl as ye,nu as be,ol as xe,ou as Se,pr as Ce,pu as we,ql as Te,ru as B,su as Ee,uu as De,xc as Oe,xo as V,yi as H}from"./src-BjL-Slsn.js";import{t as U}from"./i18n-CI5vBtLY.js";import{t as W}from"./useTranslation-BJr-n0es.js";import{E as ke,S as Ae,ur as je}from"./index-T3VEitv1.js";import{t as Me}from"./AdminSectionedPage-p7IoxWdQ.js";import{n as Ne}from"./authed-media-CQZkp0uZ.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-CWqIQnLv.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}=ne({},{refetchOnWindowFocus:!1}),{data:f,isLoading:p,isError:h}=O({},{refetchOnWindowFocus:!1}),{data:g}=V({isCamera:!0,projection:`slim`}),_=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),v=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`)),h&&o!==`recording`&&e.push(n(`common.events`)),e},[d,h,o,n]),S=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`:_.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:_.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):`—`})}],[_,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&&v.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):v.length===0?b.length>0?r(A,{icon:m,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:S})}):r(A,{icon:y,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(m,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:b.length,names:S})]}),r(I,{columns:C,rows:v,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:D,defaultSort:Ge})]})]})}o();function Je(){let{t:n}=W(),i=V({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(A,{icon:p,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(P,{deviceId:l,children:r(ke,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}o();function K({types:n}){let{t:i}=W(),o=s(),c=R(),{data:l}=B({}),u=be(),d=t(()=>u.data??[],[u.data]),{data:f}=te({},{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=pe({onSuccess:v}),b=le({onSuccess:v}),x=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]),S=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}))},C=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 b.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`})&&b.mutate({id:e.id,force:!0})}},w=n.map(e=>d.find(t=>t.id===e)).filter(e=>e!==void 0);return e(`div`,{className:`space-y-3`,children:[w.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:i(`pipeline.storageLocationsPanel.noStorageLocationsDeclaredFor`,`No storage locations declared for this purpose.`)}):w.map(e=>r(Le,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:x.get(e.id)??[],onAdd:e=>h(e),onEdit:e=>_(e),onDelete:e=>{C(e)},ownedBytesById:p,onSetMode:(e,t)=>{S(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 q=`pipeline-analytics`;function Ye(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 Xe(){let{t:n}=W(),i=s(),{nodes:a}=L(),{data:o,isLoading:c}=z({addonId:q}),l=Ye(o),u=H({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(x,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:q,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(x,{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(K,{types:[`eventMedia`]})]})]})}o();var Ze=[[`pipelineAnalytics`]],Qe=1440*60*1e3;function $e(e,t){return t.get(e)??U.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var et=[{days:1},{days:7},{days:30},{days:90}];function tt(){let{t:i}=W(),o=s(),c=R(),[l,u]=a(30),[d,p]=a(null),{data:m,isLoading:_}=E({},{refetchOnWindowFocus:!1}),{data:v}=V({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),b=n(()=>{o.invalidateQueries({queryKey:Ze})},[o]),S=ge({onSuccess:b}),C=Oe(),T=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:l}),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`})&&S.mutate({olderThanMs:Date.now()-l*Qe,reason:`retention`})},[c,S,l,i]),D=n(async e=>{let t=$e(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`})){p(null);try{let n=await C.mutateAsync({deviceId:e.deviceId});b();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){p(`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}p(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){p(e instanceof Error?e.message:String(e))}}},[c,C,y,b,i]),O=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:$e(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:C.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(f,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[y,D,C.isPending,i]);return _&&!m?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):m?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(h,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(g,{className:`h-3 w-3`}),footer:`across ${String(m.devices.length)} camera${m.devices.length===1?``:`s`}`,children:m.totalRows.toLocaleString()}),r(h,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:G(m.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:l,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:et.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(`button`,{onClick:()=>{T()},disabled:S.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:[S.isPending?r(x,{className:`h-3 w-3 animate-spin`}):r(w,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),m.devices.length===0?r(A,{icon:g,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(I,{columns:O,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480}),d===null?null:r(`p`,{className:d.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:d})]}):r(A,{icon:g,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function nt(){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(tt,{})})]}),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(Xe,{})})]})]})}function rt(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 it(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function at(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`${it(e)} · ${o}`}function ot(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 st(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 ct=[`high`,`mid`,`low`],lt=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],ut=10080*60*1e3;function dt(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 ft({onClose:n,onCreated:i}){let{t:o}=W(),s=V({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[l,u]=a(``),[f,p]=a(`high`),[m,h]=a(dt(60)),[g,_]=a(dt(0)),[v,y]=a(1),[b,x]=a(!0),[S,C]=a(``),[w,E]=a(null),D=l===``?c[0]?.id??null:l,O=new Date(m).getTime(),k=new Date(g).getTime(),A=Number.isFinite(O)&&Number.isFinite(k)&&O<k,j=Te({onSuccess:()=>{i(),n()},onError:e=>E(e instanceof Error?e.message:String(e))});return r(se,{open:!0,onOpenChange:e=>!e&&n(),children:e(Ce,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(fe,{children:e(ie,{className:`flex items-center gap-1.5`,children:[r(d,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(ue,{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:D??``,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:f,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:ct.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:lt.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`)]}),!A&&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(me,{children:[r(T,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(T,{size:`sm`,onClick:()=>{if(D===null||!A)return;E(null);let e=S.trim();j.mutate({deviceId:D,profile:f,fromMs:O,toMs:k,options:{includeAudio:b,maxLifeMs:ut,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:D===null||!A||j.isPending,children:j.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var pt=[[`recordingExport`]],mt={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 ht(){let{data:e,isLoading:n}=re({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=F(S.RecordingExportProgress,e=>e.exportId),{map:i}=F(S.RecordingExportCompleted,e=>e.exportId),{map:a}=F(S.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>st(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function gt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function _t(){let{t:i}=W(),o=s(),[c,l]=a(!1),p=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},m=R(),h=b().trpcClient,g=gt(6e4),{rows:v,isLoading:y}=ht(),{data:S}=V({isCamera:!0,projection:`slim`}),C=t(()=>{let e=new Map;for(let t of S??[])e.set(t.id,t.name);return e},[S]),w=n(()=>{o.invalidateQueries({queryKey:pt})},[o]),T=ee({onSuccess:w}),E=N({onSuccess:w}),[D,O]=a(null),k=n(async e=>{O(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),w()}finally{O(null)}},[h,w]),j=n(async e=>{await m({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`})&&T.mutate({exportId:e.id})},[m,T,i]),M=n(async e=>{await m({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`})&&E.mutate({exportId:e.id})},[m,E,i]),P=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:C.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:at(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:rt(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=mt[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(x,{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:ot(e.expiresAt,g)})},{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:()=>{k(t)},disabled:D===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:[D===t.id?r(x,{className:`h-3 w-3 animate-spin`}):r(u,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(`button`,{onClick:()=>{j(t)},disabled:T.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(_,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(`button`,{onClick:()=>{M(t)},disabled:E.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(f,{className:`h-3 w-3`})})]})}}],[C,g,D,T.isPending,E.isPending,k,j,M,i]);return y&&v.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{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:()=>l(!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(d,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),v.length===0?r(A,{icon:d,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(I,{columns:P,rows:v,rowKey:e=>e.id,minWidthPx:720}),c&&r(ft,{onClose:()=>l(!1),onCreated:p})]})}var vt=`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 yt=`storage-migration`,bt=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function xt(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 St(){let{t:e}=W(),t=k(yt);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(Ct,{}):null}function Ct(){let{t}=W(),n=R(),[i,o]=a(!1),[s,c]=a(null),l=oe({},{refetchInterval:2e3}),u=l.data??null,d=u!==null&&bt.has(u.phase),p=Ee(),m=Se(),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 l.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},g=async()=>{if(u&&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:u.jobId}),await l.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:d,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:d||p.isPending,onClick:()=>{h()},className:vt,children:[(d||p.isPending)&&r(x,{className:`h-3 w-3 animate-spin`}),r(f,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),d&&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}),u&&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:u.phase}),d&&r(x,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),u.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:u.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:xt(u)}),u.error&&r(`p`,{className:`text-[11px] text-danger`,children:u.error})]})]})}o();var wt=2e3;function Tt(){let{t}=W(),n=R(),a=s(),o=xe(),c=ye(void 0,{refetchInterval:e=>e.state.data?.state===`running`?wt:!1}),u=c.data,d=u?.state===`running`,f=d||o.isPending;i(()=>{u?.state!==`done`||u.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[u?.state,u?.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?u.total>0?`Reconciling ${String(u.completed)}/${String(u.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(x,{className:`h-3.5 w-3.5 animate-spin`}):r(l,{className:`h-3.5 w-3.5`}),m]}),u?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(u.completed),tracks:String(u.tracks),events:String(u.events),media:String(u.mediaDropped)}),u.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(u.failed.length),value2:u.failed.join(`, `)}):``,`.`]}):null,u?.state===`error`&&u.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,u.error]}):null]})]})}var J=1e3,Y=60*J,X=60*Y;function Z(e){return e.toLocaleString(`en-US`)}function Et(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=X){let t=Math.floor(e/X),n=Math.round(e%X/Y);return`${t.toString()}h ${n.toString()}m`}if(e>=Y){let t=Math.floor(e/Y),n=Math.round(e%Y/J);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/J)).toString()}s`}function Dt(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${Z(e.filesMoved)} files`:`${Z(e.filesMoved)} / ${Z(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*J)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${Et(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${G(e.bytesMoved)} moved`,rate:a,eta:s}}function Ot(e){let t=Dt(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var kt=`storage-migration`,Q=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],At=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function jt(){let{t}=W(),n=k(kt);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(A,{icon:m,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(A,{icon:C,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(Mt,{})}function Mt(){let{t:n}=W(),i=R(),{data:o}=B({}),[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]),_=he({},{refetchInterval:2e3}),y=_.data??null,b=y!==null&&At.has(y.phase),S=t(()=>{let e={};for(let t of Q){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),w=t(()=>{let e={};for(let t of Q){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]),T=t(()=>({destinations:S??{},...w?{sources:w}:{}}),[S,w]),E=de(T,{enabled:!1,retry:!1}),D=ve(),O=ae(),k=async()=>{if(!S)return;m(null);let e=await E.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},A=async()=>{if(S&&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 D.mutateAsync(T),f(null),await _.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},j=async()=>{if(y&&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 O.mutateAsync({jobId:y.jobId}),await _.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(C,{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:Q.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:b,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:b,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:()=>{k()},disabled:!S||E.isFetching||b,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:[E.isFetching&&r(x,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(`button`,{type:`button`,onClick:()=>{A()},disabled:!S||D.isPending||b,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:[D.isPending&&r(x,{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}`))}),y&&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`)}),b&&e(`button`,{type:`button`,onClick:()=>{j()},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:y.phase}),b&&r(x,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),y.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:y.error}),y.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,y.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:y.moves.map(e=>r(Nt,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(Pt,{})]}),r(Ft,{running:b}),r(Lt,{})]})}function Nt({move:t}){let{t:n}=W(),i=t.progress===null?null:Dt(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:Ot(t.progress)})]})]})}function Pt(){let{t}=W(),{data:n}=De({});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 Ft({running:t}){let{t:n}=W(),i=R(),o=we({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=_e(),[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:It(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 It(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 Lt(){let{t}=W(),{data:n}=ce({},{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:Ot({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function Rt(){let{t}=W();return e(`div`,{className:`flex flex-col gap-4`,children:[r(St,{}),r(Tt,{}),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(jt,{})})]})]})}o();var zt=`recorder`;function Bt(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 Vt(){let{t:n}=W(),i=s(),{nodes:a}=L(),{data:o,isLoading:c}=z({addonId:zt}),l=Bt(o,`recordingNodeId`,`hub`),u=H({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(x,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:zt,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(x,{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(K,{types:[`recordings`,`recordingsLow`]})]})]})}function Ht(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Ut(e,t){let n=Ht(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=>Ht(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=R(),[u,d]=a(`retention`),{data:p,isLoading:m}=te({},{refetchOnWindowFocus:!1}),{data:g}=V({isCamera:!0,projection:`slim`}),{data:_}=B({}),v=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),y=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.displayName);return e},[_]),b=t(()=>{let e=_??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[_]),S=t(()=>p?.locations??[],[p?.locations]),C=t(()=>Wt(S,y,b),[S,y,b]),T=t(()=>Fe(S),[S]),E=n(()=>{o.invalidateQueries({queryKey:Gt})},[o]),D=j({onSuccess:E}),O=M({onSuccess:E}),k=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:v.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:u}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&D.mutate({deviceId:e.deviceId,reason:u})},[c,D,u,v,i]),N=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:v.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`})&&O.mutate({deviceId:e.deviceId})},[c,O,v,i]),ee=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:v.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>C===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:C.exact?`text-foreground`:`text-foreground-subtle`,title:C.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:[C.label,!C.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:()=>{k(t)},disabled:D.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(w,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(`button`,{onClick:()=>{N(t)},disabled:O.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(f,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[v,C,k,N,D.isPending,O.isPending,i]);if(m&&!p)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(x,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!p)return r(A,{icon:l,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let P=p.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(h,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(l,{className:`h-3 w-3`}),footer:`${String(P)} camera${P===1?``:`s`} on ${p.nodeId}`,children:G(p.totalUsedBytes)}),T!==null&&T.severity!==null&&r(h,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(l,{className:`h-3 w-3`}),footer:`across ${String(T.knownVolumes)} volume${T.knownVolumes===1?``:`s`} of ${G(T.totalBytes)}`+(T.unknownVolumes>0?` · ${String(T.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Jt[T.severity]}`,children:G(T.freeBytes)})}),S.map(t=>{let n=ze(t),a=t.locationId??t.root??`default`;return r(h,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Xt(t,y)}),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:u,onChange:e=>{let t=Kt.find(t=>t.value===e.target.value);t&&d(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))})]}),P===0?r(A,{icon:l,title:p.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:p.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(I,{columns:ee,rows:[...p.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(Vt,{})})]})]})}function $t(){let{t:e}=W(),t=Ae(`/recordings`,{t:e,isAdmin:!0})??{icon:d,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(nt,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Je,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(_t,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(qe,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(Rt,{})}]})}export{$t as RecordingsPage};
@@ -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{An as c,Ci as l,Gr as u,Pt as d,dt as f,sr as p,wn as m,xi as h,xn as g}from"./player-overlays-nQJCQERn.js";import{Ja as _,Za as v}from"./client-CdHPjeIs.js";import{$r as y,Ao as b,Qa as x,Tr as S,do as C,lo as w,oi as T,xi as E,xo as D,xs as O,ya as k}from"./src-DzfpPZrG.js";import{t as A}from"./useTranslation-BJr-n0es.js";import{P as j}from"./index-4kmzPYxW.js";import{n as M,t as N}from"./BrokerEditorDialog-CTEagRft.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,l]=a(!1),u=k({kind:t}),d=M(u.data).filter(e=>e.kind===t);return e(`div`,{className:`space-y-2`,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(p,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),u.isError&&r(S,{message:o(`brokers.picker.loadFailed`,{message:u.error instanceof Error?u.error.message:o(`common.unknownError`)})}),!u.isLoading&&!u.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(y,{variant:`outline`,size:`sm`,onClick:()=>l(!0),children:[r(c,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),s&&r(N,{kind:t,onClose:()=>l(!1),onSaved:e=>{l(!1),i(e)}})]})}o();function I({kind:t,onResolved:n,onBack:i}){let{t:o}=A(),[s,c]=a(null);return e(`div`,{className:`space-y-4`,children:[e(y,{variant:`ghost`,size:`sm`,onClick:i,children:[r(h,{className:`h-3.5 w-3.5`}),` `,o(`common.back`)]}),r(F,{kind:t,value:s,onChange:c}),r(`div`,{className:`flex justify-end pt-1`,children:r(y,{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=O({onSuccess:e=>b(L(e)),onError:e=>b({status:`inconclusive`,error:String(e)})}),S=E(),C=!i||y?.status===`validated`,w=!l&&p.trim().length===0,T=!w&&C;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":w,"aria-describedby":w?`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 ${w?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),w&&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 S.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:[w&&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:()=>{w||u({name:p,config:v(n,h),secretKeys:[..._(n)]})},disabled:!T,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:d}=A(),h=x(),[g,_]=a(new Set),[v,y]=a(new Set),{data:b}=D({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 h.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})}},[h,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(l,{className:`h-3.5 w-3.5`}),` `,a?d(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):d(`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(p,{className:`h-3.5 w-3.5 animate-spin`}):r(u,{className:`h-3.5 w-3.5`}),d(`common.add`,`Add`)]})]},n.stableId)},[g,v,S,C,d]);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(m,{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(f,{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(),l=w(),u=n(()=>{o(),l.mutate({})},[l,o]);i(()=>{!l.isPending&&!l.data&&u()},[]);let d=t(()=>(l.data?.groups??[]).filter(e=>e.candidates.length>0),[l.data]),f=t(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);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:u,disabled:l.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(g,{className:`h-3.5 w-3.5 ${l.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:[l.isPending&&r(K,{label:c(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!l.isPending&&l.isError&&r(q,{}),!l.isPending&&l.data&&d.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.`)}),!l.isPending&&d.length>0&&r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.found`,{count:f})}),!l.isPending&&d.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({}),f=C(),h=n(()=>{o(),f.mutate({addonId:t.addonId,params:u})},[f,t.addonId,u,o]),g=f.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:h,disabled:f.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:[f.isPending?r(p,{className:`h-3.5 w-3.5 animate-spin`}):r(m,{className:`h-3.5 w-3.5`}),f.isPending?c(`integrations.scanNetworkModal.scanning`,`Scanning…`):c(`integrations.scanNetworkModal.scan`,`Scan`)]}),f.isError&&r(q,{}),!f.isPending&&f.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.`)}),!f.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(p,{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(d,{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{An as c,Ci as l,Gr as u,Pt as d,dt as f,sr as p,wn as m,xi as h,xn as g}from"./player-overlays-BiCGuJYq.js";import{Qa as _,to as v}from"./client-BXtMEX7J.js";import{$r as y,Ao as b,Qa as x,Tr as S,do as C,lo as w,oi as T,xi as E,xo as D,xs as O,ya as k}from"./src-BjL-Slsn.js";import{t as A}from"./useTranslation-BJr-n0es.js";import{P as j}from"./index-T3VEitv1.js";import{n as M,t as N}from"./BrokerEditorDialog-C9R9WJ5j.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,l]=a(!1),u=k({kind:t}),d=M(u.data).filter(e=>e.kind===t);return e(`div`,{className:`space-y-2`,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(p,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),u.isError&&r(S,{message:o(`brokers.picker.loadFailed`,{message:u.error instanceof Error?u.error.message:o(`common.unknownError`)})}),!u.isLoading&&!u.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(y,{variant:`outline`,size:`sm`,onClick:()=>l(!0),children:[r(c,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),s&&r(N,{kind:t,onClose:()=>l(!1),onSaved:e=>{l(!1),i(e)}})]})}o();function I({kind:t,onResolved:n,onBack:i}){let{t:o}=A(),[s,c]=a(null);return e(`div`,{className:`space-y-4`,children:[e(y,{variant:`ghost`,size:`sm`,onClick:i,children:[r(h,{className:`h-3.5 w-3.5`}),` `,o(`common.back`)]}),r(F,{kind:t,value:s,onChange:c}),r(`div`,{className:`flex justify-end pt-1`,children:r(y,{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=O({onSuccess:e=>b(L(e)),onError:e=>b({status:`inconclusive`,error:String(e)})}),S=E(),C=!i||y?.status===`validated`,w=!l&&p.trim().length===0,T=!w&&C;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":w,"aria-describedby":w?`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 ${w?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),w&&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 S.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:[w&&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:()=>{w||u({name:p,config:v(n,h),secretKeys:[..._(n)]})},disabled:!T,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:d}=A(),h=x(),[g,_]=a(new Set),[v,y]=a(new Set),{data:b}=D({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 h.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})}},[h,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(l,{className:`h-3.5 w-3.5`}),` `,a?d(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):d(`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(p,{className:`h-3.5 w-3.5 animate-spin`}):r(u,{className:`h-3.5 w-3.5`}),d(`common.add`,`Add`)]})]},n.stableId)},[g,v,S,C,d]);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(m,{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(f,{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(),l=w(),u=n(()=>{o(),l.mutate({})},[l,o]);i(()=>{!l.isPending&&!l.data&&u()},[]);let d=t(()=>(l.data?.groups??[]).filter(e=>e.candidates.length>0),[l.data]),f=t(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);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:u,disabled:l.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(g,{className:`h-3.5 w-3.5 ${l.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:[l.isPending&&r(K,{label:c(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!l.isPending&&l.isError&&r(q,{}),!l.isPending&&l.data&&d.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.`)}),!l.isPending&&d.length>0&&r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.found`,{count:f})}),!l.isPending&&d.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({}),f=C(),h=n(()=>{o(),f.mutate({addonId:t.addonId,params:u})},[f,t.addonId,u,o]),g=f.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:h,disabled:f.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:[f.isPending?r(p,{className:`h-3.5 w-3.5 animate-spin`}):r(m,{className:`h-3.5 w-3.5`}),f.isPending?c(`integrations.scanNetworkModal.scanning`,`Scanning…`):c(`integrations.scanNetworkModal.scan`,`Scan`)]}),f.isError&&r(q,{}),!f.isPending&&f.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.`)}),!f.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(p,{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(d,{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{G as l,J as u,K as d,Lt as f,Oi as p,Q as m,U as h,aa as g,bn as _,c as v,ca as y,d as ee,f as te,l as b,ot as x,p as S,s as C,vr as w,z as T}from"./player-overlays-nQJCQERn.js";import{t as E}from"./settings-2-7F6aVC_u.js";import{MaskShapeCanvas as D}from"./MaskShapeCanvas-C1WSjh5s.js";s();var O=m(`/addon/pipeline-analytics/event-media`);function k(e){return`${O}/m/${e}`}function A(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 j(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var M=`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=y(),s=A(t),c=j(t),[l,u]=o(null);return s.length===0?i(`p`,{className:`${T} 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:s.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:[S(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let s=`${o.stateId}:${String(o.index)}`,d=c===1,p=l===s;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(N,{reference:o.reference}),i(`span`,{className:`${T} tabular-nums`,children:P(o.reference.capturedAt)}),e(`button`,{type:`button`,className:M,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:S(t.condition,a).toLowerCase(),date:P(o.reference.capturedAt)}),onClick:()=>{if(d&&!p){u(s);return}u(null),r({stateId:o.stateId,index:o.index})},children:[i(f,{className:`mr-1 inline h-3 w-3`}),p?a(`uiLibrary.sceneReferenceGallery.confirm`,`Confirm`):a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]}),p&&i(`p`,{className:`text-[10px] leading-snug text-warning`,children: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.`)})]},s)})})]},t.condition))})}function N({reference:t}){let n=y(),[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(w,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:k(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function P(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var F=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,I=`text-[10px] font-medium text-foreground-subtle`,L=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,R=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,z=5,B=3600;function V(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 H(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 U(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 W({monitor:t,disabled:n,onPatch:r}){let s=y(),[l,u]=o(()=>U(t)),[d,f]=o(!1);a(()=>{d||u(U(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,_=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:L,children:[i(`p`,{className:R,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:I,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:l.label,disabled:n,className:F,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:I,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:T,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:I,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(`select`,{value:t.triggerMode,disabled:n,className:F,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:T,children:V(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:I,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:z,max:B,value:l.checkIntervalSec,disabled:n,className:F,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=G(l.checkIntervalSec,z,B);e===t.checkIntervalSec?f(!1):p({checkIntervalSec:e})}})]}),i(`p`,{className:T,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:L,children:[i(`p`,{className:R,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:I,children:i(g,{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===_?f(!1):p({check:m({threshold:l.threshold})})},onBlur:()=>{l.threshold===_?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:I,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:F,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=G(l.hysteresisCount,1,10);e===t.check.hysteresisCount?f(!1):p({check:m({hysteresisCount:e})})}})]}),i(`p`,{className:T,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:I,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:F,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=G(l.quietSeconds,0,3600);e===t.quietSeconds?f(!1):p({quietSeconds:e})}})]}),i(`p`,{className:T,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:I,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:F,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=G(l.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?f(!1):p({minObservationSpacingSec:e})}})]}),i(`p`,{className:T,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:L,children:[i(`p`,{className:R,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:I,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(`select`,{value:t.onUncoveredCondition,disabled:n,className:F,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:T,children:H(t.onUncoveredCondition,s)})]}),e(`div`,{className:L,children:[i(`p`,{className:R,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:I,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(`select`,{value:t.emit,disabled:n,className:F,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:T,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:I,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:T,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:L,children:[i(`p`,{className:R,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:{...K(l.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:I,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:I,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:F,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:{...K(e),enabled:h}}):f(!1)}})]}),i(`p`,{className:T,children:i(g,{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 G(e,t,n){return Math.min(n,Math.max(t,e))}function K(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var q=`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`,J=`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 Y({deviceId:s}){let m=y(),g=d(x().trpcClient,s),w=u(g?.state.sceneMonitor),O=l(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,G]=o(null),[K,Y]=o(``),X=t(!0);a(()=>(X.current=!0,()=>{X.current=!1}),[]);let Z=r(async()=>{if(g)try{let e=await g.sceneMonitor?.listScenes({});if(!X.current)return;e&&A(e)}catch(e){if(!X.current)return;h(e)?M(!0):I(e instanceof Error?e.message:String(e))}},[g]);a(()=>{A(null),M(!1),I(null),Z()},[Z]);let Q=w?.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:m(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,U,m]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){G(t);return}$(`roi-${String(e)}`,async()=>g?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[g,$]),ue=r(e=>{e.kind===`rect`&&G(e)},[]),de=r(async()=>{U===null||K.trim().length===0||(await $(`create`,async()=>{await g?.sceneMonitor?.createScene({label:K.trim(),roi:U,check:{mode:`similarity`,threshold:ae,hysteresisCount:oe}})}),G(null),Y(``),H(!1))},[g,U,K,$]);return g?i(`div`,{className:`flex flex-col gap-3`,children:j?i(`p`,{className:`${T} leading-relaxed`,children:m(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${T} leading-relaxed`,children:m(`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(D,{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:O.src===null?null:i(`img`,{src:O.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?J:q,"aria-pressed":V,onClick:()=>{H(e=>!e),G(null)},disabled:N!==null,children:V?m(`uiLibrary.sceneMonitor.cancel`,`Cancel`):m(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:q,onClick:O.refresh,disabled:N!==null,children:m(`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?m(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):m(`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:m(`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=>Y(e.target.value),placeholder:m(`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:J,onClick:()=>void de(),disabled:U===null||K.trim().length===0||N!==null,children:m(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),F!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:F}),Q.length===0?i(`p`,{className:`${T} leading-relaxed`,children:m(`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,m);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:`${T} leading-relaxed`,children:te(t,se,m)}),i(`p`,{className:`${T} tabular-nums`,children:b(t,m)}),i(ne,{monitor:t,disabled:N!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>g.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[C.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:q,disabled:N!==null,title:r?m(`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.`):m(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:S(n,m).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>g.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(p,{className:`mr-1 inline h-3 w-3`}),m(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:S(n,m).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:m(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:J,disabled:N!==null||t.states.length===0,title:m(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>g.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(_,{className:`mr-1 inline h-3 w-3`}),m(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:q,disabled:N!==null,onClick:()=>void $(`check-${t.id}`,async()=>g.sceneMonitor?.recheckNow({monitorId:t.id})),children:m(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?J:q,"aria-pressed":z===t.id,"aria-label":m(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:N!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(E,{className:`mr-1 inline h-3 w-3`}),m(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:re,disabled:N!==null,onClick:()=>void $(`del-${t.id}`,async()=>g.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(f,{className:`h-3 w-3`})})]}),z===t.id&&i(W,{monitor:t,disabled:N!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>g.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{Y 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{G as l,J as u,K as d,Lt as f,Oi as p,Q as m,U as h,aa as g,bn as _,c as v,ca as y,d as ee,f as te,l as b,ot as x,p as S,s as C,vr as w,z as T}from"./player-overlays-BiCGuJYq.js";import{t as E}from"./settings-2-D03xdo5Y.js";import{MaskShapeCanvas as D}from"./MaskShapeCanvas-H8Uoh2Rl.js";s();var O=m(`/addon/pipeline-analytics/event-media`);function k(e){return`${O}/m/${e}`}function A(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 j(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var M=`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=y(),s=A(t),c=j(t),[l,u]=o(null);return s.length===0?i(`p`,{className:`${T} 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:s.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:[S(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let s=`${o.stateId}:${String(o.index)}`,d=c===1,p=l===s;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(N,{reference:o.reference}),i(`span`,{className:`${T} tabular-nums`,children:P(o.reference.capturedAt)}),e(`button`,{type:`button`,className:M,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:S(t.condition,a).toLowerCase(),date:P(o.reference.capturedAt)}),onClick:()=>{if(d&&!p){u(s);return}u(null),r({stateId:o.stateId,index:o.index})},children:[i(f,{className:`mr-1 inline h-3 w-3`}),p?a(`uiLibrary.sceneReferenceGallery.confirm`,`Confirm`):a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]}),p&&i(`p`,{className:`text-[10px] leading-snug text-warning`,children: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.`)})]},s)})})]},t.condition))})}function N({reference:t}){let n=y(),[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(w,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:k(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function P(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var F=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,I=`text-[10px] font-medium text-foreground-subtle`,L=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,R=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,z=5,B=3600;function V(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 H(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 U(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 W({monitor:t,disabled:n,onPatch:r}){let s=y(),[l,u]=o(()=>U(t)),[d,f]=o(!1);a(()=>{d||u(U(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,_=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:L,children:[i(`p`,{className:R,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:I,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:l.label,disabled:n,className:F,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:I,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:T,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:I,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(`select`,{value:t.triggerMode,disabled:n,className:F,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:T,children:V(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:I,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:z,max:B,value:l.checkIntervalSec,disabled:n,className:F,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=G(l.checkIntervalSec,z,B);e===t.checkIntervalSec?f(!1):p({checkIntervalSec:e})}})]}),i(`p`,{className:T,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:L,children:[i(`p`,{className:R,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:I,children:i(g,{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===_?f(!1):p({check:m({threshold:l.threshold})})},onBlur:()=>{l.threshold===_?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:I,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:F,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=G(l.hysteresisCount,1,10);e===t.check.hysteresisCount?f(!1):p({check:m({hysteresisCount:e})})}})]}),i(`p`,{className:T,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:I,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:F,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=G(l.quietSeconds,0,3600);e===t.quietSeconds?f(!1):p({quietSeconds:e})}})]}),i(`p`,{className:T,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:I,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:F,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=G(l.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?f(!1):p({minObservationSpacingSec:e})}})]}),i(`p`,{className:T,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:L,children:[i(`p`,{className:R,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:I,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(`select`,{value:t.onUncoveredCondition,disabled:n,className:F,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:T,children:H(t.onUncoveredCondition,s)})]}),e(`div`,{className:L,children:[i(`p`,{className:R,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:I,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(`select`,{value:t.emit,disabled:n,className:F,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:T,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:I,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:T,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:L,children:[i(`p`,{className:R,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:{...K(l.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:I,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:I,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:F,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:{...K(e),enabled:h}}):f(!1)}})]}),i(`p`,{className:T,children:i(g,{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 G(e,t,n){return Math.min(n,Math.max(t,e))}function K(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var q=`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`,J=`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 Y({deviceId:s}){let m=y(),g=d(x().trpcClient,s),w=u(g?.state.sceneMonitor),O=l(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,G]=o(null),[K,Y]=o(``),X=t(!0);a(()=>(X.current=!0,()=>{X.current=!1}),[]);let Z=r(async()=>{if(g)try{let e=await g.sceneMonitor?.listScenes({});if(!X.current)return;e&&A(e)}catch(e){if(!X.current)return;h(e)?M(!0):I(e instanceof Error?e.message:String(e))}},[g]);a(()=>{A(null),M(!1),I(null),Z()},[Z]);let Q=w?.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:m(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,U,m]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){G(t);return}$(`roi-${String(e)}`,async()=>g?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[g,$]),ue=r(e=>{e.kind===`rect`&&G(e)},[]),de=r(async()=>{U===null||K.trim().length===0||(await $(`create`,async()=>{await g?.sceneMonitor?.createScene({label:K.trim(),roi:U,check:{mode:`similarity`,threshold:ae,hysteresisCount:oe}})}),G(null),Y(``),H(!1))},[g,U,K,$]);return g?i(`div`,{className:`flex flex-col gap-3`,children:j?i(`p`,{className:`${T} leading-relaxed`,children:m(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${T} leading-relaxed`,children:m(`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(D,{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:O.src===null?null:i(`img`,{src:O.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?J:q,"aria-pressed":V,onClick:()=>{H(e=>!e),G(null)},disabled:N!==null,children:V?m(`uiLibrary.sceneMonitor.cancel`,`Cancel`):m(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:q,onClick:O.refresh,disabled:N!==null,children:m(`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?m(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):m(`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:m(`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=>Y(e.target.value),placeholder:m(`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:J,onClick:()=>void de(),disabled:U===null||K.trim().length===0||N!==null,children:m(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),F!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:F}),Q.length===0?i(`p`,{className:`${T} leading-relaxed`,children:m(`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,m);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:`${T} leading-relaxed`,children:te(t,se,m)}),i(`p`,{className:`${T} tabular-nums`,children:b(t,m)}),i(ne,{monitor:t,disabled:N!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>g.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[C.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:q,disabled:N!==null,title:r?m(`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.`):m(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:S(n,m).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>g.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(p,{className:`mr-1 inline h-3 w-3`}),m(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:S(n,m).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:m(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:J,disabled:N!==null||t.states.length===0,title:m(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>g.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(_,{className:`mr-1 inline h-3 w-3`}),m(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:q,disabled:N!==null,onClick:()=>void $(`check-${t.id}`,async()=>g.sceneMonitor?.recheckNow({monitorId:t.id})),children:m(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?J:q,"aria-pressed":z===t.id,"aria-label":m(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:N!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(E,{className:`mr-1 inline h-3 w-3`}),m(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:re,disabled:N!==null,onClick:()=>void $(`del-${t.id}`,async()=>g.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(f,{className:`h-3 w-3`})})]}),z===t.id&&i(W,{monitor:t,disabled:N!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>g.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{Y as SceneMonitorEditor};
@@ -1,2 +1,2 @@
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}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,Lt as l,ca as u,cn as d,dt as f,ln as p,mi as m,ot as h,sr as g,zr as _}from"./player-overlays-nQJCQERn.js";import{a as v,i as y,s as b}from"./video-DEeXGFHo.js";import{t as x}from"./key-round-Cx5S95mB.js";import{$r as S,Ad as C,Bn as w,Cn as T,Et as E,Ju as D,Qr as O,Rn as k,Sn as A,Tr as j,Vn as M,Wn as N,Zr as P,_d as F,_r as I,bn as L,ct as R,dr as z,fn as B,fr as V,ft as ee,gr as H,hr as U,id as W,ld as G,mn as te,mr as K,mt as ne,oi as q,pn as J,pr as re,si as ie,st as ae,ud as oe,xo as se}from"./src-DzfpPZrG.js";import{t as Y}from"./i18n-Dgilx0WT.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{er as ce,n as Z,t as le,ur as ue}from"./index-4kmzPYxW.js";s();function de({id:t,title:n,icon:r,description:a,actions:o,tone:s=`default`,notice:l=null,onDismissNotice:u,children:d}){return i(L,{headingId:`access-${t}`,title:n,icon:r,actions:o,testId:`access-${t}`,children:e(`div`,{className:`${c} space-y-3`,children:[i(`div`,{className:F(`text-[11px] leading-relaxed`,s===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),l!==null&&i(pe,{notice:l,onDismiss:u}),d]})})}var fe={success:{icon:m,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:y,line:`border-danger/40 text-danger`,mark:`text-danger`}};function pe({notice:t,onDismiss:n}){let{t:r}=X(),a=fe[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:F(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[i(o,{className:F(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),i(`span`,{className:`min-w-0 flex-1`,children:t.message}),n!==void 0&&i(oe,{type:`button`,variant:`ghost`,size:`sm`,icon:f,"aria-label":r(`access.accessSection.dismiss`,`Dismiss`),onClick:n,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=D();return n(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function he(e,t=null){return e===null?t:{tone:`danger`,message:e}}var ge={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function _e(e){return Y.t(ge[e])}var ve={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ye={current:0,active:1,expired:2,revoked:3};function be(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function xe({status:e}){return i(q,{variant:ve[e],className:`text-[10px]`,children:_e(e)})}function Se({row:t,action:n}){if(!n.isAvailable(t))return null;let r=n.icon,a=n.busyId===t.id;return e(S,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n.onRun(t),disabled:n.disabled,"aria-label":Y.t(`access.credentialColumns.actionOn`,{action:n.label,name:t.name}),className:n.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?i(g,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(r,{className:`h-3 w-3`,"aria-hidden":!0}),n.label]})}function Ce(t){return[{key:`name`,header:Y.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[i(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&i(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:Y.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:Y.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[i(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&i(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:Y.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ye[e.status],render:e=>i(xe,{status:e.status})},{key:`created`,header:Y.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.createdAt,`—`)})},{key:`lastUsed`,header:Y.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.lastUsedAt,Y.t(`access.credentialColumns.never`))})},{key:`expires`,header:Y.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:Y.t(`access.credentialColumns.actionsHeader`),render:e=>i(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:i(Se,{row:e,action:t},t.label))})}].filter(e=>e!==null)}s();var we=6,Te={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Ee(e){let t=Te[e];return t===void 0?e:Y.t(t)}function De(e,t){return Y.t(t.key,{count:e})}function Q(e,t){return Y.t(`access.bulk.countOf`,{count:e,noun:De(e,t)})}function Oe(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>Y.t(`access.bulk.statusCount`,{count:t,status:_e(e).toLowerCase()})).join(`, `)}function ke(e,t){let n=e.slice(0,we).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>we?[Y.t(`access.bulk.previewMore`,{count:e.length-we})]:[];return[Y.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:Oe(e)}),``,...n,...r].join(`
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}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,Lt as l,ca as u,cn as d,dt as f,ln as p,mi as m,ot as h,sr as g,zr as _}from"./player-overlays-BiCGuJYq.js";import{a as v,i as y,s as b}from"./video-C46Ugbpc.js";import{t as x}from"./key-round-DFWP4tGQ.js";import{$r as S,Ad as C,Bn as w,Cn as T,Et as E,Ju as D,Qr as O,Rn as k,Sn as A,Tr as j,Vn as M,Wn as N,Zr as P,_d as F,_r as I,bn as L,ct as R,dr as z,fn as B,fr as V,ft as ee,gr as H,hr as U,id as W,ld as G,mn as te,mr as K,mt as ne,oi as q,pn as J,pr as re,si as ie,st as ae,ud as oe,xo as se}from"./src-BjL-Slsn.js";import{t as Y}from"./i18n-CI5vBtLY.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{er as ce,n as Z,t as le,ur as ue}from"./index-T3VEitv1.js";s();function de({id:t,title:n,icon:r,description:a,actions:o,tone:s=`default`,notice:l=null,onDismissNotice:u,children:d}){return i(L,{headingId:`access-${t}`,title:n,icon:r,actions:o,testId:`access-${t}`,children:e(`div`,{className:`${c} space-y-3`,children:[i(`div`,{className:F(`text-[11px] leading-relaxed`,s===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),l!==null&&i(pe,{notice:l,onDismiss:u}),d]})})}var fe={success:{icon:m,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:y,line:`border-danger/40 text-danger`,mark:`text-danger`}};function pe({notice:t,onDismiss:n}){let{t:r}=X(),a=fe[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:F(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[i(o,{className:F(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),i(`span`,{className:`min-w-0 flex-1`,children:t.message}),n!==void 0&&i(oe,{type:`button`,variant:`ghost`,size:`sm`,icon:f,"aria-label":r(`access.accessSection.dismiss`,`Dismiss`),onClick:n,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=D();return n(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function he(e,t=null){return e===null?t:{tone:`danger`,message:e}}var ge={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function _e(e){return Y.t(ge[e])}var ve={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ye={current:0,active:1,expired:2,revoked:3};function be(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function xe({status:e}){return i(q,{variant:ve[e],className:`text-[10px]`,children:_e(e)})}function Se({row:t,action:n}){if(!n.isAvailable(t))return null;let r=n.icon,a=n.busyId===t.id;return e(S,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n.onRun(t),disabled:n.disabled,"aria-label":Y.t(`access.credentialColumns.actionOn`,{action:n.label,name:t.name}),className:n.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?i(g,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(r,{className:`h-3 w-3`,"aria-hidden":!0}),n.label]})}function Ce(t){return[{key:`name`,header:Y.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[i(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&i(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:Y.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:Y.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[i(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&i(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:Y.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ye[e.status],render:e=>i(xe,{status:e.status})},{key:`created`,header:Y.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.createdAt,`—`)})},{key:`lastUsed`,header:Y.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.lastUsedAt,Y.t(`access.credentialColumns.never`))})},{key:`expires`,header:Y.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:Y.t(`access.credentialColumns.actionsHeader`),render:e=>i(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:i(Se,{row:e,action:t},t.label))})}].filter(e=>e!==null)}s();var we=6,Te={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Ee(e){let t=Te[e];return t===void 0?e:Y.t(t)}function De(e,t){return Y.t(t.key,{count:e})}function Q(e,t){return Y.t(`access.bulk.countOf`,{count:e,noun:De(e,t)})}function Oe(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>Y.t(`access.bulk.statusCount`,{count:t,status:_e(e).toLowerCase()})).join(`, `)}function ke(e,t){let n=e.slice(0,we).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>we?[Y.t(`access.bulk.previewMore`,{count:e.length-we})]:[];return[Y.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:Oe(e)}),``,...n,...r].join(`
2
2
  `)}async function Ae(e,t,n){let r=String(t.length),i=await e({title:Y.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:ke(t,n),label:Y.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:Y.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:Y.t(`access.bulk.confirmMismatch`,{expected:r,noun:De(2,n)})});return i!==null&&i.trim()===r}function je(e,t){let n=O(),r=C.auth.revokeCredentials.useMutation(),[i,a]=o(null);return{run:async i=>{if(i.length===0||!await Ae(n,i,e))return!1;a(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>Ee(e.reason));return a({tone:`success`,message:n.length>0?Y.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):Y.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return a({tone:`danger`,message:Y.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:Y.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:i,dismiss:()=>a(null)}}function Me(e,t,n){let r=O(),[i,a]=o(!1),[s,c]=o(null);return{run:async i=>{if(i.length===0||!await Ae(r,i,e))return!1;c(null),a(!0);let o=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){o.push(`${e.name}: ${t instanceof Error?t.message:Y.t(`access.bulk.requestFailed`)}`)}return a(!1),n(),o.length===0?(c({tone:`success`,message:Y.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:Y.t(o.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:o.length,details:o.slice(0,3).join(`; `)})}),s>0)},busy:i,outcome:s,dismiss:()=>c(null)}}s();var Ne={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Pe={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Fe=e=>e.status!==`current`,Ie=[`active`,`current`];function Le({rows:t,label:r,isLoading:a,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:d,extraActions:f,bulk:p,defaultStatus:m=Ie}){let{t:h}=X(),[_]=o(()=>m.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...m]}}),v=B(t,Ne,_),[y,b]=o(()=>new Set),x=u??h(`access.credentialColumns.never`),S=n(()=>Ce({hideOwner:l,expiresNone:x,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,x,d,f,h]),C=n(()=>p===void 0?()=>!1:e=>Fe(e)&&p.isSelectable(e),[p]),w=n(()=>v.rows.filter(e=>y.has(e.id)&&C(e)),[v.rows,y,C]);return a?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[i(g,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),h(`access.credentialTable.loading`,{label:r})]}):s===null?e(`div`,{className:`space-y-3`,children:[i(J,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Pe[e.id]===void 0?e.id:h(Pe[e.id]),...e.id===`status`?{facetLabel:e=>_e(e)}:{}})),labels:{searchPlaceholder:h(`access.credentialTable.searchPlaceholder`,{label:r}),searchLabel:h(`access.credentialTable.searchLabel`,{label:r}),facetsLabel:h(`access.credentialTable.facetsLabel`,{label:r}),clearLabel:h(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),p!==void 0&&i(Re,{bulk:p,shown:v.rows.filter(C),targets:w,onSelect:b}),i(A,{columns:S,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:T,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:h(`access.credentialTable.pagesLabel`,{label:r}),previous:h(`access.credentialTable.previousPage`),next:h(`access.credentialTable.nextPage`),range:(e,t,n)=>h(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?h(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:r}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...p===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:C,rowLabel:e=>h(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:h(`access.credentialTable.pageLabel`,{noun:De(1,p.noun)})}}})]}):i(j,{title:h(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:r}),message:s})}function Re({bulk:t,shown:n,targets:r,onSelect:a}){let{t:o}=X(),{revoke:s,noun:c}=t,u=(t.quickSelect??[]).map(e=>({...e,rows:n.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(r)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[n.length>0&&i(S,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(n.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:n.length})}),u.map(t=>e(S,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),r.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(r.length,c)})}),e(S,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[i(f,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(S,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?i(g,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(l,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(r.length,c)})]})]})]})}var ze=(e,t)=>t===null?`—`:e.get(t)??t;function Be(e,t){return e!=null&&e<=t?`expired`:`active`}function Ve(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:ze(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function He(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var Ue=`All permissions`,We=`View link`,Ge=`Scoped`,Ke={"grid-view":`Grid`,"events-view":`Events`};function qe(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function Je(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Ye(e,t,n){return e===`*`?Ue:Je(e)?`${`${Ke[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${qe(e.grant.deviceIds,t)}`:n(e)}function Xe(e){return e.includes(`*`)?Ue:e.some(Je)?We:Ge}function Ze(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:ze(t,e.subjectId),kind:Xe(e.scopes),scope:n,status:e.revokedAt===null?Be(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Qe(e){return`${e.provider}\u0000${e.subject}`}function $e(e,t){return{id:Qe(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:ze(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var et=40,tt=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],nt=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],rt=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function it(e,t){return e.find(e=>e.test.test(t))?.name??null}function at(e){return e.length<=et?e:`${e.slice(0,et)}…`}function ot(e){if(e===null||e.trim().length===0)return{label:Y.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=it(rt,t);if(n!==null)return{label:n,raw:t};let r=it(tt,t),i=it(nt,t);return r!==null&&i!==null?{label:Y.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:at(t),raw:t}:{label:r,raw:t}}var st={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,exchange:`helpers.sessionClient.method.exchange`};function ct(e){let t=st[e];return t===void 0?e:Y.t(t)}function lt(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}s();function ut(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function dt(n){let{t:a}=X(),s=h(),[c,l]=o(!1),[u,d]=o(``),[f,p]=o(null),[m,_]=o(null),v=t(null),y=r(e=>{v.current?.(e),v.current=null,l(!1),d(``),p(null),_(null)},[]),b=r(()=>new Promise(e=>{v.current?.(null),v.current=e,_(null),l(!0)}),[]),C=async()=>{p(`password`),_(null);try{let{reauthToken:e}=await s.reauthenticate({password:u});y(e)}catch(e){_(ut(e,`Password is incorrect`)),p(null)}},w=async()=>{p(`passkey`),_(null);try{let{optionsJSON:e}=await s.reauthBeginPasskey();if(!le(e))throw Error(`passkey authentication options missing challenge`);let t=await Z({optionsJSON:e}),{reauthToken:n}=await s.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});y(n)}catch(e){_(ut(e,`Passkey verification failed`)),p(null)}};return{requestProof:b,dialog:i(z,{open:c,onOpenChange:e=>!e&&y(null),children:e(re,{children:[e(H,{children:[i(I,{children:a(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),i(K,{children:a(`auth.reauthDialog.needsPassword`,{action:n})})]}),e(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&f===null&&C()},children:[i(G,{type:`password`,autoComplete:`current-password`,placeholder:a(`auth.reauthDialog.currentPassword`,`Current password`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`auth.reauthDialog.currentPassword`,`Current password`)}),m!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:m}),e(U,{className:`flex flex-wrap gap-2`,children:[e(S,{type:`button`,variant:`outline`,disabled:f!==null,onClick:()=>void w(),children:[f===`passkey`?i(g,{className:`h-4 w-4 animate-spin`}):i(x,{className:`h-4 w-4`}),a(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),e(S,{type:`submit`,disabled:u.length===0||f!==null,children:[f===`password`&&i(g,{className:`h-4 w-4 animate-spin`}),a(`common.confirm`,`Confirm`)]})]})]})]})})}}function ft({token:t,label:n,onClose:r}){let{t:a}=X();return i(z,{open:!0,onOpenChange:e=>!e&&r(),children:e(re,{width:`md`,scroll:`body`,children:[i(H,{children:i(I,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:n})})}),e(V,{className:`space-y-3`,children:[i(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),i(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(U,{children:[i(te,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),i(S,{type:`button`,variant:`primary`,size:`sm`,onClick:r,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var pt={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};s();var mt=80,$=86400,ht=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],gt={type:`device-multiselect`,key:`cameras`,deviceFilter:{types:[`camera`]},maxItems:64},_t={type:`capability`,target:``,access:[`view`,`create`]};function vt({open:t,users:r,onClose:s,onSubmit:c,submitting:l,formError:f,awaitingProof:m}){let{t:h}=X(),v=u(),{user:y}=ce(),b=y?.isAdmin===!0,C=b?null:y?.scopes??[],[T,E]=o(`scopes`),[D,O]=o(y?.id??``),[A,j]=o(``),[P,F]=o([_t]),[I,L]=o([]),[z,B]=o(`grid-view`),[V,ee]=o(!1),[H,U]=o(`30`);a(()=>{t||(E(`scopes`),O(y?.id??``),j(``),F([_t]),L([]),B(`grid-view`),ee(!1),U(`30`))},[t,y?.id]),a(()=>{T!==`view-link`&&H===`never`&&U(`30`)},[T,H]);let te=n(()=>ht.filter(e=>e.seconds!==`never`||T===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?h(`access.createTokenModal.never`,`Never (until revoked)`):h(`access.createTokenModal.days`,{count:Number(e.value)})})),[T,h]),K=A.trim(),q=T===`scopes`?R(P,v):null,J=I.map(Number).filter(e=>Number.isInteger(e)&&e>=0),re=ht.find(e=>e.value===H)?.seconds??30*$,oe=()=>T===`all`?[`*`]:T===`view-link`?[{type:`share-view`,grant:{kind:z,deviceIds:J,...V?{talk:!0}:{}}}]:P,se=K.length>0&&K.length<=mt&&!l&&!m&&(T===`all`?b:T===`view-link`?J.length>0:P.length>0&&q===null),Y=()=>{if(!se)return;let e=b&&T!==`all`&&D!==``&&D!==y?.id;c({scopes:oe(),expiresIn:re,label:K,...e?{subjectId:D}:{}})},Z=T===`all`,le=Z?p:d;return i(ne,{open:t,onClose:s,title:h(`access.createTokenModal.createToken`,`Create token`),icon:Z?p:x,error:f,width:`md`,testId:`create-token-dialog`,footer:e(S,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:Y,disabled:!se,"data-testid":`create-token-submit`,children:[l||m?i(g,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):i(le,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),h(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[i(N,{children:h(`access.createTokenModal.whatItMayDo`,`What it may do`)}),i(k,{appearance:`pills`,value:T,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&E(e)},children:e(w,{"aria-label":h(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(M,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[i(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(M,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[i(_,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachViewLink`,`View link`)]}),b?e(M,{value:`all`,"data-testid":`token-reach-all`,children:[i(p,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?i(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:i(`p`,{children:i(ue,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:i(`strong`,{})}})})}):null,b&&T!==`all`&&r.length>1?e(`div`,{className:`space-y-1`,children:[i(N,{htmlFor:`token-user`,children:h(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),i(W,{id:`token-user`,value:D,onChange:e=>O(e.target.value),options:r.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[i(N,{htmlFor:`token-name`,children:h(`access.createTokenModal.label`,`Label`)}),i(G,{id:`token-name`,value:A,maxLength:mt,required:!0,onChange:e=>j(e.target.value),placeholder:T===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),T===`scopes`?e(`div`,{className:`space-y-1`,children:[i(N,{children:h(`access.createTokenModal.scopes`,`Scopes`)}),i(ae,{value:P,onChange:F,clampToParent:C}),q&&i(`p`,{className:`text-[10px] text-danger`,children:q}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:h(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,T===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[i(N,{children:h(`access.createTokenModal.cameras`,`Cameras`)}),i(ie,{field:{...gt,label:h(`access.createTokenModal.cameras`,`Cameras`)},value:I,onChange:e=>L(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])})]}),e(`div`,{className:`space-y-1`,children:[i(N,{htmlFor:`token-view-kind`,children:h(`access.createTokenModal.viewKind`,`Shows`)}),i(W,{id:`token-view-kind`,value:z,onChange:e=>B(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:h(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:h(`access.createTokenModal.viewEvents`,`Events`)}]})]}),z===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[i(`input`,{type:`checkbox`,className:`mt-0.5`,checked:V,onChange:e=>ee(e.target.checked),"data-testid":`token-view-talk`}),i(`span`,{children:h(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[i(N,{htmlFor:`token-lifetime`,children:h(`access.createTokenModal.expires`,`Expires after`)}),i(W,{id:`token-lifetime`,value:H,onChange:e=>U(e.target.value),options:te})]})]})})}s();var yt={key:`access.nouns.token`};function bt(e){return typeof e==`object`&&!!e&&`kind`in e}function xt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${bt(e.selector)?E(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function St({headerOwnsCreate:t=!1,createRequested:r=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:d}=X(),f=u(),{user:p}=ce(),m=P(),h=C.useUtils(),g=me(),{data:_}=D(),v=n(()=>_??[],[_]),{data:y}=se({}),b=n(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),w=C.auth.listTokens.useQuery(void 0),{requestProof:T,dialog:E}=dt(`Creating a token with all permissions`),{state:O,openNew:k,close:A}=ee({newKey:pt.token}),[j,M]=o(null),[N,F]=o(null),[I,L]=o(!1),[R,z]=o(null),[B,V]=o(null);a(()=>{r&&(k(),s?.())},[r,k,s]);let H=()=>{h.auth.listTokens.invalidate(),h.auth.listAuthAudit.invalidate()},U=C.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{H(),A(),F(null),L(!1),z({token:e,label:t.label})},onError:e=>{F(`Create failed: ${e.message}`),L(!1)}}),W=C.auth.revokeToken.useMutation({onSuccess:()=>{V(null),H()},onError:e=>{V(null),M(`Revoke failed: ${e.message}`)}}),G=je(yt,H),te=Date.now(),K=(w.data??[]).filter(e=>!c||e.subjectId===p?.id).map(e=>Ze(e,g,e.scopes.includes(`*`)?null:e.scopes.map(e=>Ye(e,b,e=>xt(e,f))).join(`, `),te)),ne=async e=>{await m({title:d(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?d(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):d(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:d(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(M(null),V(e.id),W.mutate({id:e.id}))},q=e=>{(async()=>{M(null),F(null);let t;if(e.scopes.includes(`*`)){L(!0);let e=await T();if(L(!1),e===null)return;t=e}U.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[E,i(de,{notice:he(j,G.outcome),onDismissNotice:()=>{M(null),G.dismiss()},id:c?`my-tokens`:`tokens`,title:c?d(`access.tokensSection.myTokens`,`My tokens`):d(`access.tokensSection.tokens`,`Tokens`),icon:x,actions:t?void 0:e(S,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:k,children:[i(x,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),d(`system.access.newToken`,`New token`)]}),description:d(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:i(Le,{rows:K,label:d(`common.tokensLabel`),isLoading:w.isLoading,loadError:w.isError?w.error?.message??`Request failed`:null,emptyText:d(`access.tokensSection.noTokens`,`No tokens.`),action:{label:d(`access.tokensSection.revoke2`,`Revoke`),icon:l,isAvailable:e=>e.status===`active`,onRun:e=>void ne(e),busyId:B,disabled:G.busy||B!==null},...p?.isAdmin===!0?{bulk:{revoke:G,noun:yt,isSelectable:e=>e.status===`active`}}:{}})}),i(vt,{open:O.mode===`new`,users:v.map(e=>({id:e.id,username:e.username})),onClose:()=>{A(),F(null),L(!1)},submitting:U.isPending,formError:N,awaitingProof:I,onSubmit:q}),R&&i(ft,{token:R.token,label:R.label,onClose:()=>z(null)})]})}var Ct=864e5,wt={qr:`QR (by an admin)`,self:`Self-enrolled`},Tt={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function Et(e){return e.status===`revoked`}function Dt(e){return e.status!==`revoked`}function Ot(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function kt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/Ct)}function At(e,t){let n=kt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function jt(e,t){let n=kt(e,t);return n===null?Y.t(`helpers.certificateModel.unknown`):n===0?Y.t(`helpers.certificateModel.today`):n>0?Y.t(`helpers.certificateModel.inDays`,{count:n}):Y.t(`helpers.certificateModel.daysAgo`,{count:-n})}function Mt(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Nt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Pt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Ft(e){if(!e.online)return{allowed:!1,reason:Y.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var It={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Lt(e){if(e.ok)return{tone:`success`,message:Y.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Pt(e.newSerial)})};let t=e.keptPreviousLeaf?Y.t(`helpers.certificateModel.keptPrevious`):Y.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:Y.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:Y.t(It[e.stage]),reason:e.reason,kept:t})}}function Rt(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var zt=11;function Bt(e,t){let n=e.slice(0,zt);return t===null?n:`${n} · ${t}`}function Vt(e){return{id:e.id,name:e.deviceName,detail:Bt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:Tt[e.platform],scope:wt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ht(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:Tt[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ut({sessions:t,isLoading:n,loadError:r,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=X();return n?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(g,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):r===null?t.length===0?i(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>i(Wt,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,r]})}function Wt({session:t,revoking:n,onRevoke:r}){let{t:a}=X(),o=ot(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[i(v,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&i(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:ct(t.method)}),i(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),i(`span`,{children:a(`auth.sessionsList.lastActive`,{when:lt(t.lastUsedAt)})}),i(`span`,{children:a(`auth.sessionsList.expires`,{when:lt(t.expiresAt)})})]})]}),!t.current&&e(`button`,{onClick:r,disabled:n,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[n?i(g,{className:`h-3 w-3 animate-spin`}):i(b,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{me as A,He as C,Me as D,je as E,de as O,$e as S,Le as T,dt as _,Dt as a,lt as b,jt as c,Ot as d,Ft as f,pt as g,St as h,Et as i,he as k,Lt as l,Pt as m,Vt as n,Rt as o,Nt as p,Ht as r,Mt as s,Ut as t,At as u,ot as v,Ve as w,Qe as x,ct as y};