@camstack/addon-admin-ui 1.2.429 → 1.2.431

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 (128) hide show
  1. package/dist/assets/{AddonAssetIcon-DR35yt0E.js → AddonAssetIcon-CngGyUbH.js} +1 -1
  2. package/dist/assets/{Addons-gkGgGpTC.js → Addons-COSbX7Q1.js} +2 -2
  3. package/dist/assets/{AdminPage-DAO24U0w.js → AdminPage-BFQa1eDk.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-B-qoE6ra.js → AdminSectionedPage-Bb00eMTj.js} +1 -1
  5. package/dist/assets/AiProfiles-DGok1qYw.js +3 -0
  6. package/dist/assets/{BrokerForm-B3xs9aBj.js → BrokerForm-NDMOvAlu.js} +1 -1
  7. package/dist/assets/{Build-DeMAJfjN.js → Build-BPgFXVbn.js} +4 -4
  8. package/dist/assets/{Calendars-VPH-vy-o.js → Calendars-DLuwgZXW.js} +1 -1
  9. package/dist/assets/Cluster-BUBVih9A.js +1 -0
  10. package/dist/assets/ClusterStepModel-DzduELev.js +1 -0
  11. package/dist/assets/{CompositionEditor-BrtLjoSu.js → CompositionEditor-DTgOmFqj.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-D51jS9td.js → CompositionEditorPage-D73l3mqU.js} +1 -1
  13. package/dist/assets/Data-Wqos-WHl.js +2 -0
  14. package/dist/assets/{DeviceDetail-D1qU_p1k.js → DeviceDetail-CwmpXUmk.js} +2 -2
  15. package/dist/assets/{DeviceDoActionFields-B62Nv4K7.js → DeviceDoActionFields-DKOJoFJc.js} +1 -1
  16. package/dist/assets/{Devices-Cf5Exjsk.js → Devices-D_SKAo6X.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-CnEcSJ8D.js → EmbedPlayerPage-DI4ac8Wo.js} +1 -1
  18. package/dist/assets/Identity-C25gG2Mh.js +1 -0
  19. package/dist/assets/IntegrationDetail-L73oZLMf.js +1 -0
  20. package/dist/assets/{IntegrationHub-DdjWEObX.js → IntegrationHub-DuVgrEey.js} +1 -1
  21. package/dist/assets/{Integrations-CU7Ll9U_.js → Integrations-CUPpCCtl.js} +1 -1
  22. package/dist/assets/{Integrations-uZB2ozhn.js → Integrations-Cgm8qaox.js} +1 -1
  23. package/dist/assets/{Library-DSuCaXt6.js → Library-Dm0AivX3.js} +1 -1
  24. package/dist/assets/Locations-B2TjRBpQ.js +3 -0
  25. package/dist/assets/{Logs-cm-1R2Z4.js → Logs-CeX1xx9_.js} +1 -1
  26. package/dist/assets/{MaskShapeCanvas-CM9D4FOf.js → MaskShapeCanvas-GZ2ZMDcz.js} +1 -1
  27. package/dist/assets/{MotionZonesSettings-DqS8ndiK.js → MotionZonesSettings-B5gIoLVC.js} +1 -1
  28. package/dist/assets/MyAccess-DJvaTHrq.js +2 -0
  29. package/dist/assets/Network-D0uak4Dc.js +1 -0
  30. package/dist/assets/{NodeAddonsSettingsPanel-BMat4ckt.js → NodeAddonsSettingsPanel-kmgNnVID.js} +1 -1
  31. package/dist/assets/{Notifications-EPQiEZ1t.js → Notifications-DP0iwqUM.js} +1 -1
  32. package/dist/assets/{PrivacyMaskSettings-Bis0PO01.js → PrivacyMaskSettings-DWCvE7XZ.js} +1 -1
  33. package/dist/assets/Recordings-r5KE18a6.js +1 -0
  34. package/dist/assets/{ScanNetworkModal-dHWFmbFe.js → ScanNetworkModal-CHWsBmiM.js} +1 -1
  35. package/dist/assets/{SceneMonitorEditor-SFMMIopn.js → SceneMonitorEditor-BNFYspNy.js} +1 -1
  36. package/dist/assets/SessionsList-OvrBa2rd.js +2 -0
  37. package/dist/assets/{Showroom-Er-hes9K.js → Showroom-DNgHGmg0.js} +1 -1
  38. package/dist/assets/{System-BDXxfgsq.js → System-CcDzJj6C.js} +1 -1
  39. package/dist/assets/{Terminal-B70jnm8e.js → Terminal-DpGR-56V.js} +5 -5
  40. package/dist/assets/{Viewer-BsGL5Dfa.js → Viewer-vqCH_LqM.js} +1 -1
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C7iEnSHU.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DR_v3lvi.js} +1 -1
  42. package/dist/assets/{addon-icons-context--6Hi3qRW.js → addon-icons-context-B2Gmu49a.js} +1 -1
  43. package/dist/assets/{archive-DtcjevJM.js → archive-CoV271Ga.js} +1 -1
  44. package/dist/assets/{authed-media-LCmlAEZ5.js → authed-media-BSx10sm9.js} +1 -1
  45. package/dist/assets/{bell-off-eQBpwamg.js → bell-off-CQHJCxaC.js} +1 -1
  46. package/dist/assets/{board-model-wzCmdEKJ.js → board-model-lagHZiI7.js} +1 -1
  47. package/dist/assets/{boxes-DikDfAoo.js → boxes-DKr2EDaB.js} +1 -1
  48. package/dist/assets/circle-slash-D1CG5tRc.js +1 -0
  49. package/dist/assets/client-CqsEJzhO.js +358 -0
  50. package/dist/assets/{cloud-upload-DI9XunFf.js → cloud-upload-D3IJwdmA.js} +1 -1
  51. package/dist/assets/crop-sD8BDahL.js +1 -0
  52. package/dist/assets/{device-integration-icon-D2lWVDM2.js → device-integration-icon-BHf83qVT.js} +1 -1
  53. package/dist/assets/device-picker-model-JBC8n4FU.js +1 -0
  54. package/dist/assets/dist-C3lDDHVX.js +358 -0
  55. package/dist/assets/{dist-ChQzskeX.js → dist-Dlrgg5It.js} +1 -1
  56. package/dist/assets/{eraser-Dl5ROV0l.js → eraser-BRuYxYS4.js} +1 -1
  57. package/dist/assets/{hard-drive-download-B1ard6ym.js → hard-drive-download-B14E8eTo.js} +1 -1
  58. package/dist/assets/{history-BMhP0SFG.js → history-Dn2pnfaZ.js} +1 -1
  59. package/dist/assets/{hostInit-FCvre9AW.js → hostInit-3qW3eaSU.js} +1 -1
  60. package/dist/assets/i18n-B-IeyHf7.js +1 -0
  61. package/dist/assets/icons-CvJTX54k.js +1 -0
  62. package/dist/assets/{index-DvOECbab.js → index-mBJW996X.js} +3 -3
  63. package/dist/assets/key-EeG_L4W9.js +1 -0
  64. package/dist/assets/{key-round-yCDTbIQb.js → key-round-C9pPg55h.js} +1 -1
  65. package/dist/assets/{layers-c960YTPf.js → layers-DhxisKd7.js} +1 -1
  66. package/dist/assets/{linked-devices-model-CB7qgVjI.js → linked-devices-model-CTfAwc1p.js} +1 -1
  67. package/dist/assets/{list-ordered-C7hEwAd1.js → list-ordered-Ckqq8GR7.js} +1 -1
  68. package/dist/assets/{location-owned-usage-D28vwYJT.js → location-owned-usage-eDtNCANy.js} +1 -1
  69. package/dist/assets/{log-in-DFfxcqYz.js → log-in-CAiH8-Mq.js} +1 -1
  70. package/dist/assets/{memory-stick-BBfIGrWx.js → memory-stick-Bir-K-V7.js} +1 -1
  71. package/dist/assets/{message-square-plus-D8ZUT6rz.js → message-square-plus-B_0WwbBk.js} +1 -1
  72. package/dist/assets/{mf-entry-bootstrap-0-3035e647.js → mf-entry-bootstrap-0-c62ae51c.js} +2 -2
  73. package/dist/assets/{mic-off-w2mFOBi3.js → mic-off-D5kT_DDX.js} +1 -1
  74. package/dist/assets/{monitor-off-DPi_gm_c.js → monitor-off-DzKNd6eJ.js} +1 -1
  75. package/dist/assets/{monitor-smartphone-9Ife1Trw.js → monitor-smartphone-D3ZPy75c.js} +1 -1
  76. package/dist/assets/mount-JBC8n4FU.js +1 -0
  77. package/dist/assets/{notification-schedule-field-BuLfSYLZ.js → notification-schedule-field-DaKiveMR.js} +1 -1
  78. package/dist/assets/{octagon-alert-C-jH7VH_.js → octagon-alert-BYNvsZ0Q.js} +1 -1
  79. package/dist/assets/{player-overlays-D0U2dNvn.js → player-overlays-DFTWiQ8-.js} +1 -1
  80. package/dist/assets/{recycle-Bbki65G2.js → recycle-DJUuC9xt.js} +1 -1
  81. package/dist/assets/remoteEntry-BhYjusn-.js +1 -0
  82. package/dist/assets/{scan-eye-AfIM_Dlr.js → scan-eye-_otUiDbW.js} +1 -1
  83. package/dist/assets/{scissors-CnL6g0BO.js → scissors-BU04yNa7.js} +1 -1
  84. package/dist/assets/{search-x-eqJd3G8u.js → search-x-Djycej4Y.js} +1 -1
  85. package/dist/assets/{send-B72RQ9UL.js → send-BNY2bJqA.js} +1 -1
  86. package/dist/assets/{settings-2-CXZ6DVRg.js → settings-2-BxpLi7pY.js} +1 -1
  87. package/dist/assets/{speaker-CcCWWecW.js → speaker-BspD0ixN.js} +1 -1
  88. package/dist/assets/src-CE3hNyCx.js +67 -0
  89. package/dist/assets/{timer-reset-B9Lihcw9.js → timer-reset-CPRU92uv.js} +1 -1
  90. package/dist/assets/{ungroup-D753owNE.js → ungroup-oYlFn3LE.js} +1 -1
  91. package/dist/assets/{unlink-DzoLNfsq.js → unlink-D0eJ5vAc.js} +1 -1
  92. package/dist/assets/{usb-CuSU-_EY.js → usb-C24Ua3ty.js} +1 -1
  93. package/dist/assets/{use-scenes-feed-CZjJNxfD.js → use-scenes-feed-DzzIer2d.js} +1 -1
  94. package/dist/assets/{use-stationary-objects-BoGqWyLV.js → use-stationary-objects-C-l1Z5zI.js} +1 -1
  95. package/dist/assets/useEventInvalidation-JBC8n4FU.js +1 -0
  96. package/dist/assets/{useNodeUrlSelection-BA6CgjTU.js → useNodeUrlSelection-Ba-ed7zb.js} +1 -1
  97. package/dist/assets/user-round-JzUTTasm.js +1 -0
  98. package/dist/assets/{user-x-PK8sSsso.js → user-x-CdpX6b_D.js} +1 -1
  99. package/dist/assets/{video-BBtESt54.js → video-vLKHp9E_.js} +1 -1
  100. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BKfTL-9e.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D83o1ikp.js} +2 -2
  101. package/dist/index.html +10 -10
  102. package/dist/server/addon.js +192 -30
  103. package/package.json +1 -1
  104. package/dist/assets/AiProfiles-BXcreqZP.js +0 -3
  105. package/dist/assets/Cluster-B-k0M79z.js +0 -1
  106. package/dist/assets/ClusterStepModel-DaAc_6nI.js +0 -1
  107. package/dist/assets/Data-IfJuKcwc.js +0 -2
  108. package/dist/assets/Identity-DNE80jdX.js +0 -1
  109. package/dist/assets/IntegrationDetail-LKbiJFU3.js +0 -1
  110. package/dist/assets/Locations-BeaznsZS.js +0 -3
  111. package/dist/assets/MyAccess-Dxb11B6h.js +0 -2
  112. package/dist/assets/Network-BCDUHSB0.js +0 -1
  113. package/dist/assets/Recordings-BCeoXxL4.js +0 -1
  114. package/dist/assets/SessionsList-BRTwG3uv.js +0 -2
  115. package/dist/assets/circle-slash-YVgGJTpJ.js +0 -1
  116. package/dist/assets/client-DYbvGOid.js +0 -358
  117. package/dist/assets/crop-CxZbpOyK.js +0 -1
  118. package/dist/assets/device-picker-model-C4w1vbly.js +0 -1
  119. package/dist/assets/dist-CPO0KWoy.js +0 -358
  120. package/dist/assets/file-up-WS3s_T9x.js +0 -1
  121. package/dist/assets/i18n-Vb3uBp7P.js +0 -1
  122. package/dist/assets/icons-DocdgFuy.js +0 -1
  123. package/dist/assets/key-B1M6i1mf.js +0 -1
  124. package/dist/assets/mount-C4w1vbly.js +0 -1
  125. package/dist/assets/remoteEntry-DYVoozgD.js +0 -1
  126. package/dist/assets/src-CGxdJN_f.js +0 -67
  127. package/dist/assets/useEventInvalidation-C4w1vbly.js +0 -1
  128. package/dist/assets/user-round-CMg3Ndlt.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{$ as n,B as r,G as i,J as a,S as o,a as s,b as c,q as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Hi as f,Ir as p,It as m,Nt as h,Pn as g,Q as _,Qt as v,Yr as y,ar as b,cr as x,fi as S,ia as C,nr as w,ot as T,pi as E,pr as D}from"./player-overlays-D0U2dNvn.js";import{o as O}from"./video-BBtESt54.js";import{t as k}from"./key-round-yCDTbIQb.js";import{t as A}from"./monitor-smartphone-9Ife1Trw.js";import{t as j}from"./unlink-DzoLNfsq.js";import{Jn as M,Yn as ee}from"./client-DYbvGOid.js";import{Ao as te,Bn as ne,Cn as re,Ft as ie,Oo as N,Wn as P,Z as ae,Zn as F,ql as oe,vu as I,wn as se}from"./src-CGxdJN_f.js";import{t as ce}from"./i18n-Vb3uBp7P.js";import{t as L}from"./useTranslation-D3Is_4B6.js";import"./mount-C4w1vbly.js";import{Y as R,i as z,n as B,r as V,t as H,z as U}from"./index-DvOECbab.js";import{t as W}from"./AdminPage-DAO24U0w.js";import{N as G,P as le,_ as K,a as ue,g as de,k as fe,r as pe,t as me,v as he}from"./SessionsList-BRTwG3uv.js";n();function ge({value:n,size:i=192}){let{t:s}=L(),[c,l]=a(null),[u,f]=a(null);if(r(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||l(e)}catch(e){r||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||f(`qrcode library not installed`)}),()=>{r=!0}},[n]),u)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:s(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!c)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:s(`users.totpQrCode.generating`,`Generating…`)});let p=c.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)c.modules.data[e*p+t]&&h.push(d(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return o(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[d(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}var _e=`${M}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function ve(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function J(e){return ee(e)}function ye(e){return e.startsWith(`https://`)}function be(e){let t=e.flatMap(e=>{let t=ve(e),n=J(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>q[e.tier]-q[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:ye(r),plausible:e.plausible}]))}function xe(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=J(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function Se(e){let t=new URL(_e);return t.searchParams.set(`hub`,e),t.toString()}n();var Ce=176,Y={scheme:`https`};function we(){let{t:e}=L(),t=te(Y),n=N(Y).data?.roles.publicEndpoint.resolved??null;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?o(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[d(b,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?o(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[d(h,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),o(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[d(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),d(ne,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):d(Te,{candidates:be(t.data.endpoints),preferredOrigin:n})]})]})}function Te({candidates:e,preferredOrigin:t}){let{t:n}=L(),[r,s]=a(null),c=xe(e,r,t),l=i(()=>c?Se(c.origin):null,[c]);if(c===null||l===null)return d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.empty`)});let u=e=>n(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${u(e.tier)} — ${e.origin}`}));return o(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[d(re,{value:l,size:Ce,alt:n(`connectPhone.qrAlt`),className:`self-start`}),o(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[o(`label`,{className:`block space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.addressLabel`)}),d(oe,{value:c.origin,options:f,onChange:e=>s(e.target.value)}),o(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[u(c.tier),` · `,c.label]})]}),!c.secure&&d(X,{text:n(`connectPhone.insecure`)}),!c.plausible&&d(X,{text:n(`connectPhone.implausible`)}),o(`div`,{className:`space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.linkLabel`)}),o(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[d(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:l}),d(ie,{value:l,srLabel:n(`connectPhone.linkLabel`)})]})]}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.signInHint`)})]})]})}function X({text:e}){return o(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[d(h,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),d(`span`,{children:e})]})}n();function Ee(e){return new Date(e).toLocaleDateString()}function De(){let{t:e}=L(),t=F(),n=I.useUtils(),i=I.auth.listLinkableProviders.useQuery(),s=I.auth.listOwnExternalIdentities.useQuery(),[c,u]=a(null),[f,p]=a(()=>z(window.location.search)),m=l(null),h=K(`Linking a sign-in account`),g=l(null);r(()=>()=>g.current?.(),[]);let[v,y]=a(null);r(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=I.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=m.current;if(m.current=null,t===null||t.closed){window.location.assign(e);return}let r=e=>{y(null),p(z(`?${e}`)),n.auth.listOwnExternalIdentities.invalidate()};g.current?.(),g.current=B(t,{onReturn:e=>{e.target===`profile`&&r(e.query)},onDone:e=>{e.target===`profile`&&r(e.query)},onClosed:()=>{g.current?.(),g.current=null,n.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=_(V(e))},onError:e=>{m.current?.close(),m.current=null,y(null),u(e.message)}}),w=I.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void n.auth.listOwnExternalIdentities.invalidate(),onError:e=>u(e.message)}),T=i.data??[],D=s.data??[],O=v!==null&&D.some(e=>e.provider===v);if(r(()=>{!O||v===null||(y(null),p({kind:`linked`,provider:v}))},[O,v]),T.length===0&&D.length===0)return null;let k=new Set(D.map(e=>e.provider)),A=e=>T.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(u(null),w.mutate({provider:n.provider,subject:n.subject}))};return o(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[h.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(x,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[d(S,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:A(f.provider)})]}),(f?.kind===`error`||c)&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[d(E,{className:`h-3.5 w-3.5 shrink-0`}),c??(f?.kind===`error`?f.message:``)]}),D.length>0&&d(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:D.map(t=>{let n=t.providerLabel??t.provider;return o(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`font-medium text-foreground truncate`,children:[n,!t.available&&d(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),d(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:Ee(t.linkedAt)})})]}),o(`button`,{onClick:()=>void M(t,n),disabled:w.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d(j,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),d(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>!k.has(e.provider)).map(t=>o(`button`,{onClick:()=>{u(null),p(null),h.requestProof().then(e=>{e!==null&&(m.current=H(null),y(m.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?d(b,{className:`h-3 w-3 animate-spin`}):d(x,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}n();function Z(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Oe(){let{t:e}=L(),{logout:t}=U(),n=F(),r=I.useUtils(),i=I.auth.listOwnSessions.useQuery(),[s,c]=a(null),l=I.auth.revokeOwnSession.useMutation({onSuccess:()=>void r.auth.listOwnSessions.invalidate(),onError:e=>c(`Sign out failed: ${Z(e)}`)}),u=I.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>c(`Sign out failed: ${Z(e)}`)}),f=async t=>{await n({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:he(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(c(null),l.mutate({id:t.id}))},p=async()=>{await n({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(c(null),u.mutate({everywhere:!0}))};return o(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(A,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),s!==null&&d(`div`,{className:`text-[11px] text-danger`,children:s}),d(me,{sessions:i.data??[],isLoading:i.isLoading,loadError:i.isError?i.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:l.isPending?l.variables?.id??null:null}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[u.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(O,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}n();var Q=`You`;function ke(){let{t:e}=L(),t=F(),n=I.useUtils(),r=I.auth.listOwnDeviceCredentials.useQuery(),[o,s]=a(null),c=I.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||s(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>s(`Revoke failed: ${e.message}`)}),l=i(()=>(r.data??[]).map(e=>pe(e,Q)),[r.data]),u=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(s(null),c.mutate({id:n.id}))},p={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:f,isAvailable:ue,onRun:e=>void u(e),busyId:c.isPending?c.variables?.id??null:null,disabled:c.isPending};return d(G,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:v,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:le(o),onDismissNotice:()=>s(null),children:d(fe,{rows:l,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:p})})}n();var Ae={view:{icon:p,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:g,cls:`bg-primary/15 text-primary`},delete:{icon:m,cls:`bg-danger/15 text-danger`}};function je(){let{t:e}=L(),t=C(),{user:n,logout:r}=U();if(!n)return d(W,{children:d(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});let i=n.isAdmin,a=n.scopes??[];return o(W,{children:[o(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[d(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:n.username.slice(0,1).toUpperCase()}),o(`div`,{className:`flex-1 min-w-0`,children:[d(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:n.username}),o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[i?e(`systemPage.myAccess.administrator`,`Administrator`):e(`systemPage.myAccess.user`,`User`),` `,d(R,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:n.id.slice(0,8)},components:{mono:d(`span`,{className:`font-mono`})}})]})]})]}),i&&o(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[d(D,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),o(`div`,{children:[d(`div`,{className:`font-semibold text-foreground`,children:e(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),d(`p`,{className:`text-foreground-subtle mt-0.5`,children:e(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),d(Me,{}),d(Ne,{username:n.username}),d(Pe,{}),d(De,{}),d(de,{}),d(Oe,{}),d(ke,{}),d(we,{}),a.length>0&&o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2 border-b border-border`,children:[d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:e(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),o(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[d(`div`,{children:e(`systemPage.myAccess.type`,`Type`)}),d(`div`,{children:e(`systemPage.myAccess.target`,`Target`)}),d(`div`,{children:e(`systemPage.myAccess.access`,`Access`)})]}),d(`ul`,{className:`divide-y divide-border`,children:a.map((n,r)=>o(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[d(`span`,{className:`font-mono text-foreground-subtle`,children:n.type}),d(`span`,{className:`font-mono text-foreground`,children:n.type===`device`?ae(n.selector,t):n.target}),d(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(t=>{let r=n.access.includes(t),{icon:i,cls:a}=Ae[t];return o(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${r?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:r?e(`systemPage.myAccess.can`,`Can {{a}}`,{a:t}):e(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:t}),children:[d(i,{className:`h-3 w-3`}),t]},t)})})]},r))})]}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:r,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground transition-colors`,children:[d(O,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]})})]})}function Me(){let{t:e}=L(),t=T(),[n,r]=a(``),[i,s]=a(``),[c,l]=a(``),[f,p]=a(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),r(``),s(``),l(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=i.length>0&&c.length>0&&i!==c,g=i.length>0&&i.length<8,_=n.length>=1&&i.length>=8&&i===c;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(k,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d($,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:n,onChange:r,autoComplete:`current-password`}),d($,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:i,onChange:s,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),d($,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:c,onChange:l,autoComplete:`new-password`}),(h||g)&&d(`div`,{className:`text-[11px] text-danger`,children:h?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&o(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-emerald-500`:`text-danger`}`,children:[f.kind===`success`?d(S,{className:`h-3 w-3`}):d(E,{className:`h-3 w-3`}),f.msg]}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>{p(null),m.mutate({currentPassword:n,newPassword:i})},disabled:!_||m.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[m.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(w,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function $({label:e,value:t,onChange:n,autoComplete:r,hint:i}){return o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),i&&d(`div`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function Ne({username:e}){let{t}=L(),n=T(),l=s({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>n.getOwnTotpStatus()}),f=l.data,[p,m]=a(null),[h,g]=a(``),[_,x]=a(null),[C,w]=a(!1),D=u({mutationFn:()=>n.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),g(``),x(null)},onError:e=>x(e instanceof Error?e.message:`Setup failed`)}),O=u({mutationFn:e=>n.confirmOwnTotp(e),onSuccess:()=>{m(null),g(``),x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=K(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:n.disableOwnTotp({reauthToken:e})},onSuccess:()=>{x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Disable failed`)});r(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,f?.enabled,p]);return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&o(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(b,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&o(c,{children:[d(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>{x(null),D.mutate()},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[D.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(v,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&p&&o(c,{children:[d(`div`,{className:`text-[11px] text-foreground-subtle`,children:d(R,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:d(`span`,{className:`font-mono`})}})}),o(`div`,{className:`flex flex-col items-center gap-3`,children:[d(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:d(ge,{value:p.otpauthUrl,size:180})}),o(`div`,{className:`w-full`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),o(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[d(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),o(`button`,{onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>w(!0))},className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle hover:text-foreground`,children:[C?d(S,{className:`h-3 w-3 text-emerald-500`}):d(y,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),d(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:h,onChange:e=>g(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),_&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(E,{className:`h-3 w-3`}),_]}),o(`div`,{className:`flex justify-end gap-2`,children:[d(`button`,{onClick:()=>{m(null),x(null),g(``)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:t(`common.cancel`,`Cancel`)}),o(`button`,{onClick:()=>{x(null),O.mutate({code:h})},disabled:O.isPending||h.length!==6,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[O.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(S,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&f&&o(c,{children:[o(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[d(S,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),o(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[d(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),d(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`})})]})]}),_&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(E,{className:`h-3 w-3`}),_]}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>{x(null),A.mutate()},disabled:A.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[A.isPending?d(b,{className:`h-3 w-3 animate-spin`}):d(v,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return P(`auth-webauthn/passkey-enrollment`)?d(se,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}export{je as MyAccessPage};
@@ -1 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,q as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as u,It as d,Jt as f,L as p,Nt as m,On as h,Rn as g,Rr as _,Xt as v,Yr as y,Z as b,an as x,ar as S,bi as C,dt as w,ht as T,in as E,kn as D,mn as ee,nr as te,ot as ne,un as O,vn as re,yn as ie}from"./player-overlays-D0U2dNvn.js";import{t as k}from"./boxes-DikDfAoo.js";import{c as A,o as ae}from"./video-BBtESt54.js";import{t as oe}from"./file-up-WS3s_T9x.js";import{t as se}from"./log-in-DFfxcqYz.js";import{Kn as ce,Un as le,_n as ue,qn as de}from"./client-DYbvGOid.js";import{Bn as j,Bo as fe,Bt as pe,Do as me,Dr as M,El as he,Er as N,Fo as ge,Ho as _e,Io as ve,It as ye,Jo as be,Ln as P,Lo as xe,Mo as Se,No as Ce,Oo as we,Pn as Te,Po as Ee,Ql as De,Ro as Oe,Rt as ke,Uo as Ae,Ut as je,Vo as Me,Vt as F,Wo as Ne,Yo as Pe,an as Fe,ar as I,ha as Ie,jo as Le,ko as Re,ql as ze,qo as Be,zo as Ve}from"./src-CGxdJN_f.js";import{t as L}from"./i18n-Vb3uBp7P.js";import{t as R}from"./useTranslation-D3Is_4B6.js";import"./mount-C4w1vbly.js";import{C as He,c as z,s as B}from"./index-DvOECbab.js";import{t as Ue}from"./AdminSectionedPage-B-qoE6ra.js";import{t as V}from"./AdminPage-DAO24U0w.js";import{t as We}from"./NodeAddonsSettingsPanel-BMat4ckt.js";import{n as H,r as Ge,t as U}from"./IntegrationHub-DdjWEObX.js";import{n as W,t as G}from"./addon-display-names-BkwMrExv.js";e();var K=5e3,q=`network-access`,Ke={connected:!1,endpoint:null};function qe(){let{t:e}=R(),t=s(),i=M({capName:`network-access`},{refetchInterval:K}),a=N(void 0,{refetchInterval:K}),o=n(()=>G(a.data??[]),[a.data]),c=n(()=>(i.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[i.data,o]),[u,d]=r(null),[f,p]=r({}),m=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),d(null),p(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},h=(e,t)=>{d(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);p(e=>({...e,[n]:r}))},g=be({onSuccess:m,onError:h}),_=Pe({onSuccess:m,onError:h}),v=[{id:q,label:e(`system.remoteAccess.remoteAccess`,`Remote access`),install:{capability:q,label:e(`system.remoteAccess.addTunnel`,`Add tunnel`)},entries:c.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:A,...W(e.isActive),render:()=>l(H,{addonId:e.addonId,displayName:e.displayName,capName:q,isActive:e.isActive,badges:l(Ye,{addonId:e.addonId}),error:f[e.addonId]??null,primaryAction:l(Xe,{addonId:e.addonId,busyId:u,onStart:e=>{d(e),g.mutate({addonId:e})},onStop:e=>{d(e),_.mutate({addonId:e})}})})}))}];return l(U,{embedded:!0,icon:A,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),groups:v,isLoading:i.isLoading,emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`)})}function Je(e){let{data:t}=Be({addonId:e},{refetchInterval:K,retry:!1}),n=t?le.safeParse(t):null;return n?.success?n.data:Ke}function Ye({addonId:e}){let{t}=R(),n=Je(e);return a(o,{children:[l(I,{variant:n.connected?`success`:`default`,className:Ge,children:n.connected?t(`system.remoteAccess.connected`,`Connected`):t(`system.remoteAccess.disconnected`,`Disconnected`)}),n.endpoint&&a(`a`,{href:n.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[l(_,{className:`h-3 w-3`}),n.endpoint.url]})]})}function Xe({addonId:e,busyId:t,onStart:n,onStop:r}){let{t:i}=R(),o=Je(e),s=t===e;return o.connected?a(j,{size:`sm`,variant:`secondary`,disabled:s,onClick:()=>r(e),children:[s?l(S,{className:`h-3 w-3 animate-spin`}):l(f,{className:`h-3 w-3`}),i(`system.remoteAccess.stop`,`Stop`)]}):a(j,{size:`sm`,variant:`primary`,disabled:s,onClick:()=>n(e),children:[s?l(S,{className:`h-3 w-3 animate-spin`}):l(D,{className:`h-3 w-3`}),i(`system.remoteAccess.start`,`Start`)]})}e();var Ze=3e4,J=`turn-provider`;function Qe(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function $e(){let{t:e}=R(),t=M({capName:`turn-provider`},{refetchInterval:Ze}),r=N(void 0,{refetchInterval:Ze}),i=he(),o=i.data??[],s=n(()=>G(r.data??[]),[r.data]),c=n(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:s.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,s]),d=[{id:J,label:e(`system.turnServers.turnProviders`,`TURN providers`),install:{capability:J,label:e(`system.turnServers.addProvider`,`Add provider`)},entries:c.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:g,...W(t.isActive),render:()=>l(H,{addonId:t.addonId,displayName:t.displayName,capName:J,isActive:t.isActive,panels:[{id:`ice-servers`,title:e(`system.turnServers.discoveredIceServers`,`Discovered ICE servers`),icon:g,content:l(et,{addonId:t.addonId,enabled:t.isActive})}]})}))}];return l(U,{embedded:!0,icon:g,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),groups:d,isLoading:t.isLoading,emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),trailing:l(F,{headingId:`turn-combined-ice`,title:e(`system.turnServers.combinedIceServerListAll`,`Combined ICE server list — all enabled providers`),icon:g,actions:l(j,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:e(`common.refresh`,`Refresh`)}),children:l(`div`,{className:u,children:o.length===0?l(`div`,{className:`text-xs text-foreground-subtle`,children:e(`system.turnServers.noServersFromEnabledProviders`,`No servers from enabled providers.`)}):l(`div`,{className:`flex flex-col gap-3`,children:o.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return a(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&a(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&a(`span`,{children:[l(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,l(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&a(`span`,{children:[l(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,l(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),l(`ul`,{className:`divide-y divide-border`,children:n.map(e=>l(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})})})}function et({addonId:e,enabled:t}){let r=he({addonId:e},{enabled:t,retry:!1}),i=n(()=>Qe(r.data??[]),[r.data]),a=t?r.isLoading?`Loading…`:i.length===0?`This provider returned no servers.`:null:`Disabled — enable the provider to fetch its servers.`;return l(`div`,{className:`rounded-lg border border-border bg-surface p-2 sm:p-3`,children:a===null?l(`div`,{className:`flex flex-wrap gap-1`,children:i.map(e=>l(`span`,{className:`inline-block break-all rounded bg-foreground-subtle/10 px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e},e))}):l(`div`,{className:`text-xs text-foreground-subtle`,children:a})})}e();var tt={lan:g,wifi:T,docker:k,vpn:te,loopback:O,other:O},nt={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},rt=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function it(e){let{t}=R(),{interfaces:r,disabled:i,hideLoopback:o,ipv4Only:s,emptyMessage:c}=e,u=n(()=>r.filter(e=>!(o&&e.kind===`loopback`||s&&e.family!==`IPv4`)),[r,o,s]),d=n(()=>{let e=new Map;for(let t of u){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return rt.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[u]),f=t=>e.mode===`single`?e.value===t:e.value.includes(t),p=t=>{if(i||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let n=new Set(e.value);n.has(t.address)?n.delete(t.address):n.add(t.address),e.onChange([...n])};return u.length===0?l(`div`,{className:`text-xs text-foreground-subtle italic`,children:c??t(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):l(`div`,{className:`flex flex-col gap-3`,children:d.map(({kind:n,items:r})=>a(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[a(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[l(tt[n]??O,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:nt[n]??n}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),l(`ul`,{className:`divide-y divide-border`,children:r.map(n=>{let r=f(n.address),o=n.kind===`loopback`,s=!n.plausible&&!o;return a(`li`,{className:`flex items-center gap-3 px-3 py-2 ${o?`opacity-60 cursor-not-allowed`:i?`opacity-60`:s?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>p(n),children:[l(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&l(C,{className:`h-3 w-3`})}),a(`div`,{className:`flex-1 min-w-0 ${s?`text-foreground-subtle`:``}`,children:[a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[l(`span`,{className:`font-mono text-xs font-semibold ${s?`text-foreground-subtle`:`text-foreground`}`,children:n.name}),l(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:n.family}),n.preferred&&l(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:t(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),o&&l(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:t(`shared.addressSelector.alwaysIncluded`,`Always included`)}),s&&a(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[l(m,{className:`h-2.5 w-2.5`}),t(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),a(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[n.address,n.cidr&&n.cidr!==n.address?` (${n.cidr})`:``]})]})]},`${n.name}-${n.family}-${n.address}`)})})]},n))})}var Y=[{role:`appConnections`,get title(){return L.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return L.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return L.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return L.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return L.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return L.t(`helpers.addressTableModel.internalHelp`)}}],at=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function X(e,t){return e.inUse.includes(t)}function ot(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return X(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&X(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:ce}:{kind:`set`,input:n}}function st(e){return Y.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}e();var ct={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function lt({book:e,loading:t,saving:n,error:i,onSetRole:o,onAdd:s,onRemove:c}){let{t:u}=R(),[f,p]=r(``),[g,_]=r(``),[v,y]=r(null),[b,x]=r(null),S=()=>{let e=de(f);if(!e.ok){y(e.reason);return}y(null),p(``),_(``),s(e.baseUrl,g.trim())},C=(e,t)=>{let n=ot(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){x({input:n.input,reason:n.reason});return}x(null),o(n.input)}},w=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:t=>a(`div`,{className:`min-w-0 py-0.5`,children:[l(`div`,{className:`font-mono text-[12px] break-all ${t.plausible?`text-foreground`:`text-foreground-subtle`}`,children:t.baseUrl}),a(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(`span`,{children:t.label}),t.kind===`app-link`&&a(`span`,{className:`font-mono`,children:[`hub=`,` `,e?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),t.custom&&t.detected&&l(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),t.kind!==`custom`&&t.interfaceKind!==`lan`&&t.interfaceKind!==`public`&&t.interfaceKind!==`other`&&l(`span`,{className:`uppercase tracking-wide`,children:t.interfaceKind}),!t.plausible&&t.interfaceKind!==`loopback`&&a(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[l(m,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=ct[e.kind]??ct.loopback;return l(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...Y.map(e=>({key:e.role,headerRender:()=>l(`span`,{title:e.help,children:e.title}),align:`center`,nowrap:!0,width:`w-24`,render:t=>{let r=t.eligible.includes(e.role),i=t.flags.includes(e.role),o=X(t,e.role);return a(`label`,{className:`inline-flex items-center justify-center gap-1 ${r?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:r?o&&!i?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:e.title,help:e.help}):e.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[l(Fe,{checked:r&&o,disabled:!r||n,onChange:()=>C(t,e),"aria-label":`${e.title}: ${t.baseUrl}`}),o&&!i&&r&&l(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?l(j,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>c(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:l(d,{className:`h-3 w-3`})}):null}],T=e===void 0?[]:st(e);return a(Te,{children:[a(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[a(`div`,{children:[l(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),l(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),a(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[l(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),l(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:Y.map(e=>a(`div`,{className:`contents`,children:[l(`dt`,{className:`font-medium`,children:e.title}),l(`dd`,{className:`text-foreground-subtle`,children:e.help})]},e.role))}),l(`p`,{className:`mt-1.5 text-foreground-subtle`,children:at})]})]}),T.length>0&&l(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:T.map(e=>a(`div`,{className:`contents`,children:[l(`span`,{className:`text-foreground-subtle`,children:e.title}),a(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${e.role}`,children:[e.inUse,l(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:e.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),e.automatic?l(`span`,{}):l(j,{size:`sm`,variant:`secondary`,disabled:n,onClick:()=>o({role:e.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},e.role))}),b!==null&&a(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[l(m,{className:`h-3.5 w-3.5 text-amber-600`}),l(`span`,{className:`flex-1 min-w-[220px]`,children:b.reason}),l(j,{size:`sm`,variant:`secondary`,onClick:()=>{o({...b.input,acceptInsecureHttp:!0}),x(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),l(j,{size:`sm`,variant:`ghost`,onClick:()=>x(null),children:u(`common.cancel`,`Cancel`)})]}),i!==null&&l(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:i})]}),l(je,{columns:w,rows:e?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:t?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),a(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[a(`div`,{className:`flex-1 min-w-[220px]`,children:[l(De,{value:f,onChange:e=>{p(e.target.value),y(null)},placeholder:`https://cams.example.com or https://192.168.1.50:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:n}),v!==null&&l(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:v})]}),l(`div`,{className:`w-48`,children:l(De,{value:g,onChange:e=>_(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:n})}),a(j,{size:`sm`,variant:`secondary`,disabled:n||f.trim()===``,onClick:S,children:[l(h,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}e();function ut(){let{t:e}=R(),i=s(),o=()=>{i.invalidateQueries({queryKey:[[`localNetwork`]]})},c=Se(void 0,{refetchInterval:3e4}),d=Re(void 0),f=Oe({onSuccess:o}),p=ge({onSuccess:e=>{C(e.addresses),o()}}),m=n(()=>c.data?.interfaces??[],[c.data]),h=we({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),g=xe({onSuccess:o}),_=me({onSuccess:o}),y=Ee({onSuccess:o}),b=g.error?.message??_.error?.message??y.error?.message??null,x=g.isPending||_.isPending||y.isPending,[S,C]=r([]),[w,T]=r(!1);t(()=>{!w&&d.data&&(C(d.data.addresses),T(!0))},[d.data,w]);let E=d.data?.addresses??[],D=n(()=>{if(S.length!==E.length)return!0;let e=[...S].toSorted(),t=[...E].toSorted();return e.some((e,n)=>e!==t[n])},[S,E]);return a(V,{embedded:!0,children:[a(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[l(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:e(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),l(`div`,{className:`flex items-center gap-2 shrink-0`,children:a(j,{size:`sm`,variant:`secondary`,onClick:()=>{c.refetch(),d.refetch(),h.refetch()},disabled:c.isLoading,children:[l(ie,{className:`h-3 w-3 ${c.isLoading?`animate-spin`:``}`}),e(`common.refresh`,`Refresh`)]})})]}),l(F,{headingId:`network-allowed-addresses`,title:e(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:a(`div`,{className:`flex flex-wrap items-center gap-1`,children:[a(j,{size:`sm`,variant:`secondary`,onClick:()=>p.mutate(void 0),disabled:p.isPending||f.isPending,title:e(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[l(v,{className:`h-3 w-3`}),p.isPending?e(`system.networkAddresses.detecting`,`Detecting…`):e(`system.networkAddresses.bestMatch`,`Best match`)]}),a(j,{size:`sm`,variant:`secondary`,onClick:()=>{C([])},disabled:S.length===0||f.isPending,children:[l(re,{className:`h-3 w-3`}),e(`system.networkAddresses.clear`,`Clear`)]}),D&&l(j,{size:`sm`,variant:`secondary`,onClick:()=>{C(E)},disabled:f.isPending,children:e(`system.networkAddresses.discard`,`Discard`)}),a(j,{size:`sm`,variant:`primary`,onClick:()=>{f.mutate({addresses:[...S]})},disabled:!D||f.isPending,children:[l(ee,{className:`h-3 w-3`}),f.isPending?e(`system.networkAddresses.saving`,`Saving…`):e(`common.save`,`Save`)]})]}),children:a(`div`,{className:u,children:[l(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:S.length===0?e(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):e(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(S.length)})}),l(it,{mode:`multiple`,interfaces:m,value:S,onChange:C,disabled:f.isPending,emptyMessage:c.isLoading?e(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):e(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),l(lt,{book:h.data,loading:h.isLoading,saving:x,error:b,onSetRole:e=>g.mutate({...e}),onAdd:(e,t)=>_.mutate({baseUrl:e,label:t}),onRemove:e=>y.mutate({baseUrl:e})})]})}e();var dt={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Z=5e3,ft=`mesh-network`,pt=3e4,mt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function ht(){let{t:e}=R(),t=M({capName:`mesh-network`},{refetchInterval:Z}),r=N(void 0,{refetchInterval:Z}),i=n(()=>G(r.data??[]),[r.data]),a=n(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),o=[{id:ft,label:e(`system.meshNetworks.meshNetworks`,`Mesh networks`),install:{capability:ft,label:e(`system.meshNetworks.addMesh`,`Add mesh`)},entries:a.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:g,...W(t.isActive),render:()=>l(H,{addonId:t.addonId,displayName:t.displayName,capName:ft,isActive:t.isActive,badges:l(_t,{addonId:t.addonId}),primaryAction:l(vt,{addonId:t.addonId}),panels:[{id:`status`,title:e(`system.meshNetworks.status`,`Status`),icon:k,content:l(yt,{addonId:t.addonId})}]})}))}];return l(U,{embedded:!0,icon:k,title:e(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:e(`system.meshNetworks.privateVpnMeshesThatConnect`,`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`),groups:o,isLoading:t.isLoading,emptyTitle:e(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:e(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`)})}function gt(e){let{data:t,isLoading:n}=fe({addonId:e},{refetchInterval:Z,retry:!1}),r=t?ue.safeParse(t):null;return{status:r?.success?r.data:mt,isLoading:n}}function _t({addonId:e}){let{t}=R(),{status:n}=gt(e);return a(o,{children:[l(I,{variant:n.joined?`success`:`default`,className:Ge,children:n.joined?t(`system.meshNetworks.joined`,`Joined`):t(`system.meshNetworks.notJoined`,`Not joined`)}),n.joined&&l(I,{className:`text-[10px]`,children:t(`common.peers`,{count:n.peerCount})})]})}function vt({addonId:e}){let{t}=R(),n=s(),[c,u]=r(!1),[d,f]=r(null),p=ne(),{status:m}=gt(e),h=i(()=>{n.invalidateQueries({queryKey:[[`meshNetwork`]]})},[n]),g=Ne(),_=Me({onSuccess:h}),v=Ae({onSuccess:h}),y=i(async()=>{u(!0);let t={cancelled:!1};f(t);try{let n=await g.mutateAsync({addonId:e});if(t.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!t.cancelled&&(await Et(2e3),!t.cancelled);){let t=await p.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),n=t?ue.safeParse(t):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[e,h,g,p]),b=i(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return l(o,{children:m.joined?a(o,{children:[a(j,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:e}),children:[_.isPending?l(S,{className:`h-3 w-3 animate-spin`}):l(ae,{className:`h-3 w-3`}),t(`system.meshNetworks.disconnect`,`Disconnect`)]}),a(j,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:e}),children:[v.isPending?l(S,{className:`h-3 w-3 animate-spin`}):l(x,{className:`h-3 w-3`}),t(`system.meshNetworks.logOut`,`Log out`)]})]}):c?a(j,{size:`sm`,variant:`ghost`,onClick:b,children:[l(w,{className:`h-3 w-3 mr-1`}),` `,t(`common.cancel`)]}):a(o,{children:[a(j,{size:`sm`,variant:`primary`,onClick:()=>void y(),children:[l(se,{className:`h-3 w-3`}),t(`system.meshNetworks.connect`,`Connect`)]}),a(j,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:e}),children:[v.isPending?l(S,{className:`h-3 w-3 animate-spin`}):l(x,{className:`h-3 w-3`}),t(`system.meshNetworks.logOut`,`Log out`)]})]})})}function yt({addonId:e}){let{t}=R(),{status:n}=gt(e),r=_e({addonId:e},{refetchInterval:pt,retry:!1});return a(`div`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[n.error&&l(P,{message:n.error}),l(bt,{status:n}),n.endpoints.length>0&&a(`div`,{className:`space-y-1.5`,children:[l(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:t(`system.meshNetworks.endpoints`,`Endpoints`)}),n.endpoints.map(e=>a(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[a(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${dt[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?l(A,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),a(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[l(_,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),l(`div`,{className:`border-t border-border`,children:l(St,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function bt({status:e}){let{t}=R();return l(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:t(`system.meshNetworks.tenant`,`Tenant`),value:e.tenantName||`—`},{label:t(`system.meshNetworks.user`,`User`),value:e.userLogin??`—`},{label:t(`system.meshNetworks.controlPlane`,`Control plane`),value:e.controlPlaneUrl||`—`},{label:t(`system.meshNetworks.meshIp`,`Mesh IP`),value:e.meshIp||`—`,mono:!0},{label:t(`system.meshNetworks.magicdns`,`MagicDNS`),value:e.magicDnsHostname||`—`,mono:!0},{label:t(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:e.magicDnsSuffix||`—`,mono:!0},{label:t(`system.meshNetworks.peers`,`Peers`),value:String(e.peerCount)},{label:t(`system.meshNetworks.keyExpiry`,`Key expiry`),value:e.keyExpiry?xt(e.keyExpiry):`—`}].map(e=>a(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[l(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),l(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function xt(e){let t=e-Date.now();if(t<0)return L.t(`system.meshNetworks.expiredAgo`,{when:Tt(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return L.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?L.t(`system.meshNetworks.expiryHours`,{count:r}):L.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function St({peers:e,loading:t}){let{t:r}=R(),o=n(()=>e.map(e=>({...e,_id:e.id})),[e]),s=i(e=>{e&&navigator.clipboard?.writeText(e)},[]),c=n(()=>[{key:`hostname`,header:r(`system.meshNetworks.hostname`,`Hostname`),render:e=>a(`div`,{className:`flex flex-col`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`font-medium text-foreground`,children:e.hostname||r(`system.meshNetworks.unknown`,`(unknown)`)}),e.isSelf&&l(I,{variant:`info`,children:r(`common.self`)}),e.exitNodeOption&&l(I,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:r(`system.meshNetworks.magicdns`,`MagicDNS`),render:e=>e.magicDns?a(`div`,{className:`flex items-center gap-1`,children:[l(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),l(`button`,{onClick:()=>s(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":r(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:l(y,{className:`h-3 w-3 text-foreground-subtle`})})]}):l(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?a(`div`,{className:`flex items-center gap-1`,children:[l(`span`,{className:`font-mono text-xs`,children:t}),l(`button`,{onClick:()=>s(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":r(`system.meshNetworks.copyIp`,`Copy IP`),children:l(y,{className:`h-3 w-3 text-foreground-subtle`})})]}):l(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:r(`system.meshNetworks.connection`,`Connection`),render:e=>a(`div`,{className:`flex items-center gap-1.5`,children:[l(I,{variant:Ct(e.connection),children:e.connection}),e.relay&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:r(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?l(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):l(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:r(`system.meshNetworks.txRx`,`TX / RX`),render:e=>a(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,wt(e.txBytes),` · ↓ `,wt(e.rxBytes)]})},{key:`lastSeen`,header:r(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>l(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Tt(e.lastSeenMs):`—`})}],[s,r]);return t&&e.length===0?a(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[l(S,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,r(`systemPage.meshNetworks.loadingPeers`)]}):e.length===0?l(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:r(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):l(`div`,{className:`p-4`,children:l(je,{columns:c,rows:o,rowKey:e=>e._id,minWidthPx:820})})}function Ct(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function wt(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function Tt(e){let t=Date.now()-e;return t<6e4?L.t(`system.meshNetworks.justNow`):t<36e5?L.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?L.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):L.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}function Et(e){return new Promise(t=>setTimeout(t,e))}var Dt=/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/,Ot=/-----BEGIN ((?:RSA |EC |ENCRYPTED )?PRIVATE KEY)-----[\s\S]+?-----END \1-----/,kt={certificate:`.pem,.crt,.cer`,privateKey:`.pem,.key`,ca:`.pem,.crt,.cer`};function Q(e,t){if(t.trim()===``)return null;if(e===`privateKey`){let e=Ot.exec(t);return e===null?Dt.test(t)?L.t(`helpers.pemFile.isCert`):L.t(`helpers.pemFile.notKey`):e[1]===`ENCRYPTED PRIVATE KEY`?L.t(`helpers.pemFile.encrypted`):null}return Dt.test(t)?e===`certificate`&&Ot.test(t)?L.t(`helpers.pemFile.certHasKey`):null:Ot.test(t)?L.t(`helpers.pemFile.isKey`):L.t(`helpers.pemFile.notCert`)}function At(e){return e.text()}e();function $({kind:e,label:t,value:n,onChange:i,rows:o=6}){let{t:s}=R(),u=c(null),[d,f]=r(null),[p,m]=r(null),h=p??Q(e,n),g=`pem-${e}`,_=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t!==void 0){f(t.name);try{let e=await At(t);m(null),i(e)}catch(e){m(`Could not read ${t.name}: ${e instanceof Error?e.message:String(e)}`)}}};return a(`div`,{className:`space-y-1`,children:[a(`div`,{className:`flex items-center justify-between gap-2`,children:[l(`label`,{htmlFor:g,className:`text-[11px] text-foreground-subtle`,children:t}),a(`div`,{className:`flex min-w-0 items-center gap-2`,children:[d!==null&&l(`span`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,"data-testid":`${g}-file-name`,children:d}),l(`input`,{ref:u,type:`file`,accept:kt[e],onChange:e=>void _(e),className:`hidden`,"data-testid":`${g}-file`}),a(j,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>u.current?.click(),children:[l(oe,{className:`mr-1 h-3 w-3`}),s(`system.pemField.chooseFile`,`Choose file`)]})]})]}),l(`textarea`,{id:g,value:n,onChange:e=>{f(null),m(null),i(e.target.value)},rows:o,"aria-invalid":h!==null,className:`w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`}),h!==null&&l(`p`,{className:`text-[11px] text-danger`,role:`alert`,children:h})]})}e();function jt(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function Mt(){let{t:e}=R(),t=s(),n=Le(void 0,{refetchInterval:15e3}),i=Ce({onSuccess:()=>void t.invalidateQueries({queryKey:[[`localNetwork`]]})}),o=ve({onSuccess:()=>void t.invalidateQueries({queryKey:[[`localNetwork`]]})}),c=Ve({onSuccess:()=>{m(!1),g(``),v(``),b(``),t.invalidateQueries({queryKey:[[`localNetwork`]]})}}),d=n.data,[f,m]=r(!1),[h,g]=r(``),[_,v]=r(``),[y,b]=r(``),x=()=>{if(!d?.caCertPem)return;let e=new Blob([d.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`camstack-ca.crt`,n.click(),URL.revokeObjectURL(t)},S=d?.mode===`uploaded`?`Uploaded`:d?.mode===`generated`?`Generated local CA`:`TLS disabled`;return l(V,{embedded:!0,children:a(`div`,{className:p,children:[l(We,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:e(`system.localAccess.lanHttp`,`LAN HTTP`),description:e(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),l(F,{headingId:`local-access-certificate`,title:e(`system.localAccess.certificate`,`Certificate`),icon:E,children:a(`div`,{className:`${u} space-y-3`,children:[n.isError&&l(`p`,{className:`text-xs text-danger`,children:e(`system.localAccess.couldNotReadTlsStatus`,`Could not read TLS status.`)}),d?.reissueError&&l(P,{variant:`warning`,title:e(`system.localAccess.certificateReissue`,`Certificate reissue`),message:d.reissueError}),d?.restartRequired&&l(P,{variant:`warning`,title:e(`system.localAccess.restartRequired`,`Restart required`),message:e(`system.localAccess.theHttpsListenerStillServes`,`The HTTPS listener still serves the previous certificate. Restart the hub to apply it.`)}),a(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[a(`div`,{children:[l(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.mode`,`Mode`)}),l(`dd`,{className:`font-medium`,children:S})]}),a(`div`,{children:[l(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.validTo`,`Valid to`)}),l(`dd`,{className:`font-mono`,children:d?.validTo?new Date(d.validTo).toLocaleString():`—`})]}),a(`div`,{children:[l(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.leafSha256`,`Leaf SHA-256`)}),l(`dd`,{className:`font-mono`,title:d?.leafFingerprintSha256??void 0,children:jt(d?.leafFingerprintSha256??null)})]}),a(`div`,{children:[l(`dt`,{className:`text-foreground-subtle`,children:e(`system.localAccess.caSha256`,`CA SHA-256`)}),l(`dd`,{className:`font-mono`,title:d?.caFingerprintSha256??void 0,children:d?.mode===`uploaded`&&d.caFingerprintSha256===null?l(`span`,{className:`font-sans text-foreground-subtle`,children:e(`system.localAccess.issuerNotIncludedInThe`,`Issuer not included in the upload (not the local CA)`)}):jt(d?.caFingerprintSha256??null)})]})]}),d&&d.sans.length>0&&l(`div`,{className:`flex flex-wrap gap-1`,children:d.sans.map(e=>l(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),a(`div`,{className:`flex flex-wrap gap-2`,children:[l(ye,{label:e(`system.localAccess.regenerate`,`Regenerate`),title:e(`system.localAccess.issueANewLeaf`,`Issue a new leaf?`),description:e(`system.localAccess.issuesANewLeafUnder`,`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`),confirmLabel:e(`system.localAccess.regenerate`,`Regenerate`),disabled:d?.mode===`uploaded`||i.isPending,action:()=>i.mutateAsync({})}),l(j,{size:`sm`,variant:`outline`,onClick:()=>m(e=>!e),children:e(`system.localAccess.upload`,`Upload`)}),d?.caCertPem&&l(j,{size:`sm`,variant:`outline`,onClick:x,children:e(`system.localAccess.downloadCa`,`Download CA`)}),d?.mode===`uploaded`&&l(ye,{label:e(`system.localAccess.revertToGenerated`,`Revert to generated`),title:e(`system.localAccess.dropTheUploadedCertificate`,`Drop the uploaded certificate?`),description:e(`system.localAccess.deletesTheUploadedPairAnd`,`Deletes the uploaded pair and returns to the generated local CA.`),confirmLabel:e(`system.localAccess.revert`,`Revert`),confirmVariant:`danger`,disabled:o.isPending,action:()=>o.mutateAsync({})})]}),f&&a(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[l($,{kind:`certificate`,label:e(`system.localAccess.certificateOrFullChainPem`,`Certificate or full chain (PEM)`),value:h,onChange:g}),l($,{kind:`privateKey`,label:e(`system.localAccess.privateKeyPem`,`Private key (PEM)`),value:_,onChange:v}),l($,{kind:`ca`,label:e(`system.localAccess.caPemOptional`,`CA (PEM, optional)`),value:y,onChange:b,rows:4}),l(j,{size:`sm`,disabled:!h.trim()||!_.trim()||Q(`certificate`,h)!==null||Q(`privateKey`,_)!==null||Q(`ca`,y)!==null||c.isPending,onClick:()=>c.mutate({certPem:h,keyPem:_,...y.trim()?{caPem:y}:{}}),children:e(`system.localAccess.saveCertificate`,`Save certificate`)}),c.isError&&l(`p`,{className:`text-xs text-danger`,children:c.error instanceof Error?c.error.message:e(`system.localAccess.uploadFailed`,`Upload failed`)})]})]})})]})})}e();function Nt({value:e,onChange:t}){let{t:r}=R(),{data:i}=Ie({isCamera:!0,projection:`slim`}),o=n(()=>i===void 0?[{value:``,label:r(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:i.length===0?[{value:``,label:r(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:r(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...i.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[i,r]);return a(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[l(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.networkDiagnostics.camera`,`Camera`)}),l(ze,{value:e===null?``:String(e),disabled:i===void 0||i.length===0,onChange:e=>t(e.target.value===``?null:Number(e.target.value)),options:o})]})}function Pt(){let e=ne(),[t,n]=r(null);return l(V,{embedded:!0,children:a(`div`,{className:p,"data-testid":`network-diagnostics`,children:[l(pe,{loadServers:i(async()=>e.trpcClient.turnProvider.getTurnServers.query(),[e])}),l(ke,{trpc:e.trpcClient,serverUrl:b(),deviceId:t,cameraField:l(Nt,{value:t,onChange:n})})]})})}function Ft(){let{t:e}=R(),t=He(`/system/network`,{t:e,isAdmin:!0})??{icon:A,title:e(`system.network`,`Network`)};return l(Ue,{icon:t.icon,title:t.title,defaultSection:`addresses`,sectionsLabel:`${t.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:l(Mt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:l(ut,{})},{id:z.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:l(qe,{}),ownedParams:B},{id:z.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:l(ht,{}),ownedParams:B},{id:z.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:l($e,{}),ownedParams:B},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:l(Pt,{})}]})}export{Ft as NetworkPage};
@@ -1 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,b 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-CEHpkaJP.js";import{Hr as l,It as u,Kr as d,Nr as f,Nt as p,Qi as m,Y as h,ai as g,ar as _,dt as v,ot as y,wi as b,yr as x}from"./player-overlays-D0U2dNvn.js";import{n as S,t as C}from"./scissors-CnL6g0BO.js";import{Ti as w}from"./client-DYbvGOid.js";import{$c as T,Ac as E,An as D,Bn as O,Dc as k,Dn as A,En as j,Gc as M,Gs as N,Hc as P,Jc as F,Kc as ee,Kn as te,Mc as ne,Nc as re,Oc as I,Pc as ie,Qc as ae,Rn as L,Tn as oe,Ut as R,Vc as se,Vn as z,Vs as ce,Wc as le,Wt as ue,Xc as de,Yc as fe,Zc as pe,Zn as B,_r as V,cs as me,el as he,gs as ge,gu as H,ha as U,jc as _e,jn as ve,kc as ye,kn as be,mr as W,ms as xe,pu as Se,qc as Ce,tl as we,us as Te,zc as Ee}from"./src-CGxdJN_f.js";import{t as G}from"./i18n-Vb3uBp7P.js";import{t as K}from"./useTranslation-D3Is_4B6.js";import{C as De,Y as Oe,k as ke}from"./index-DvOECbab.js";import{t as Ae}from"./AdminSectionedPage-B-qoE6ra.js";import{n as je}from"./authed-media-LCmlAEZ5.js";import{t as q}from"./format-size-DIxKXxtj.js";import{c as Me,i as Ne,l as Pe,n as Fe,o as Ie,r as Le,s as Re,t as ze,u as Be}from"./location-owned-usage-D28vwYJT.js";e();var Ve=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],He={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Ue={columnKey:`at`,dir:`desc`};function We(e){return new Date(e).toLocaleString()}function Ge(){let{t:e,i18n:t}=K(),[i,s]=r(`all`),{data:l,isLoading:u,isError:d}=ye({},{refetchOnWindowFocus:!1}),{data:f,isLoading:h,isError:g}=xe({},{refetchOnWindowFocus:!1}),{data:v}=U({isCamera:!0,projection:`slim`}),y=n(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),b=n(()=>{let e=[...l??[],...f??[]];return(i===`all`?e:e.filter(e=>e.domain===i)).toSorted((e,t)=>t.at-e.at)},[l,f,i]),x=n(()=>{let t=[];return d&&i!==`events`&&t.push(e(`recordings.activitySection.domainRecordings`)),g&&i!==`recording`&&t.push(e(`common.events`)),t},[d,g,i,e]),S=n(()=>new Intl.ListFormat(t.language,{type:`conjunction`}).format(x),[x,t.language]),C=n(()=>[{key:`at`,header:e(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>c(`span`,{className:`text-foreground-subtle tabular-nums`,children:We(e.at)})},{key:`domain`,header:e(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>c(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${He[e.domain]}`,children:e.domain})},{key:`op`,header:e(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>c(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:e(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>c(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:e(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:y.get(e.deviceId)??`#${String(e.deviceId)}`,render:t=>t.deviceId===null?c(`span`,{className:`text-foreground-subtle`,children:e(`common.cluster`)}):c(`span`,{className:`text-foreground`,children:y.get(t.deviceId)??`#${String(t.deviceId)}`})},{key:`items`,header:e(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>c(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:e(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>c(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?q(e.bytesReclaimed):`—`})}],[y,e]),w=u||h;return a(`div`,{className:`flex flex-col gap-4`,children:[c(`div`,{className:`flex items-center gap-1`,children:Ve.map(t=>c(`button`,{onClick:()=>s(t.value),className:`rounded px-2 py-1 text-xs font-medium ${i===t.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:e(t.labelKey)},t.value))}),w&&b.length===0?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(_,{className:`h-4 w-4 animate-spin`}),e(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):b.length===0?x.length>0?c(L,{icon:p,title:e(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:e(`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})}):c(L,{icon:m,title:e(`recordings.activitySection.noActivityYet`,`No activity yet`),description:e(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):a(o,{children:[x.length>0&&a(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[c(p,{className:`h-3 w-3 shrink-0`}),e(`recordings.activitySection.domainsMissing`,{count:x.length,names:S})]}),c(R,{columns:C,rows:b,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:ue,defaultSort:Ue})]})]})}e();function Ke(){let{t:e}=K(),t=U({isCamera:!0,projection:`slim`}),i=n(()=>(t.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[t.data]),[o,s]=r(null),l=o??i[0]?.id??null;return!t.isLoading&&i.length===0?c(L,{icon:b,title:e(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:e(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):a(`div`,{className:`space-y-3`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)})]}),a(`div`,{className:`flex items-center gap-2`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),c(`select`,{value:l??``,onChange:e=>s(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:i.map(e=>c(`option`,{value:e.id,children:e.name},e.id))})]}),l!==null&&c(te,{deviceId:l,children:c(ke,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}e();function qe({types:e}){let{t}=K(),i=s(),o=B(),{data:l}=P({}),u=se(),d=n(()=>u.data??[],[u.data]),{data:f}=I({},{refetchOnWindowFocus:!1}),p=n(()=>ze(l??[],f?.locations),[l,f?.locations]),[m,h]=r(null),[g,_]=r(null),v=()=>{i.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},y=we({onSuccess:v}),b=Ee({onSuccess:v}),x=n(()=>{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,n)=>{Pe(n)&&!await o({title:t(`pipeline.storageLocationsPanel.disable`,`Disable "{{displayName}}"?`,{displayName:e.displayName}),message:t(`pipeline.storageLocationsPanel.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:Me(n).consequence}),confirmLabel:t(`common.disable`,`Disable`),variant:`danger`})||y.mutate(Re(e,{mode:n}))},C=async e=>{if(await o({title:t(`pipeline.storageLocationsPanel.deleteLocation`,`Delete location "{{displayName}}"?`,{displayName:e.displayName}),message:t(`pipeline.storageLocationsPanel.removesTheRecordFilesOn`,`Removes the record; files on disk are untouched.`),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`}))try{await b.mutateAsync({id:e.id})}catch(n){await o({title:t(`pipeline.storageLocationsPanel.deleteAnyway`,`Delete anyway?`),message:t(`pipeline.storageLocationsPanel.forcingNote`,{error:n instanceof Error?n.message:String(n)}),confirmLabel:t(`pipeline.storageLocationsPanel.forceDelete`,`Force delete`),variant:`danger`})&&b.mutate({id:e.id,force:!0})}},w=e.map(e=>d.find(t=>t.id===e)).filter(e=>e!==void 0);return a(`div`,{className:`space-y-3`,children:[w.length===0?c(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:t(`pipeline.storageLocationsPanel.noStorageLocationsDeclaredFor`,`No storage locations declared for this purpose.`)}):w.map(e=>c(Fe,{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&&c(Be,{initialType:m,onClose:()=>h(null),onCreated:()=>{v(),h(null)}}),g!==null&&c(Ie,{location:g,onClose:()=>_(null),onSaved:()=>{v(),_(null)}})]})}e();var Je=`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:e}=K(),t=s(),{nodes:r}=Se(),{data:i,isLoading:o}=W({addonId:Je}),l=Ye(i),u=V({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=n(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[r,l]);return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?c(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):c(`select`,{value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Je,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(t=>c(`option`,{value:t,children:t===`hub`?e(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):t},t))}),u.isPending&&c(_,{className:`h-4 w-4 animate-spin text-primary`})]})]}),a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:e(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),c(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:e(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),c(qe,{types:[`eventMedia`]})]})]})}e();var Ze=[[`pipelineAnalytics`]],Qe=1440*60*1e3;function $e(e,t){return t.get(e)??G.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var et=[{days:1},{days:7},{days:30},{days:90}];function tt(){let{t:e}=K(),t=s(),o=B(),[l,f]=r(30),[p,m]=r(null),{data:g,isLoading:v}=Te({},{refetchOnWindowFocus:!1}),{data:y}=U({isCamera:!0,projection:`slim`}),b=n(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),x=i(()=>{t.invalidateQueries({queryKey:Ze})},[t]),S=ge({onSuccess:x}),w=me(),T=i(async()=>{await o({title:e(`recordings.eventsManagementSection.pruneTitle`,{count:l}),message:e(`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:e(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&S.mutate({olderThanMs:Date.now()-l*Qe,reason:`retention`})},[o,S,l,e]),E=i(async t=>{let n=$e(t.deviceId,b);if(await o({title:e(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:n}),message:e(`recordings.eventsManagementSection.deleteRowsMessage`,{count:t.rows,size:q(t.bytes)}),confirmLabel:e(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){m(null);try{let e=await w.mutateAsync({deviceId:t.deviceId});x();let r=e.motion+e.object+e.audio;if(r===0&&t.bytes>0){m(`0 events deleted for ${n}. Media still listed (${q(t.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}m(`Deleted ${String(r)} event${r===1?``:`s`} for ${n}.`)}catch(e){m(e instanceof Error?e.message:String(e))}}},[o,w,b,x,e]),D=n(()=>[{key:`camera`,header:e(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:$e(e.deviceId,b)})},{key:`rows`,header:e(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:e(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:q(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>a(`button`,{onClick:()=>{E(t)},disabled:w.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:e(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[c(u,{className:`h-3 w-3`}),e(`common.delete`,`Delete`)]})}],[b,E,w.isPending,e]);return v&&!g?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(_,{className:`h-4 w-4 animate-spin`}),e(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):g?a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[c(h,{label:e(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:c(d,{className:`h-3 w-3`}),footer:`across ${String(g.devices.length)} camera${g.devices.length===1?``:`s`}`,children:g.totalRows.toLocaleString()}),c(h,{label:e(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:q(g.totalBytes)})]}),a(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[c(`span`,{className:`text-foreground-subtle`,children:e(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),c(`select`,{value:l,onChange:e=>f(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:et.map(t=>c(`option`,{value:t.days,children:e(`recordings.eventsManagementSection.ageDays`,{count:t.days})},t.days))}),a(`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?c(_,{className:`h-3 w-3 animate-spin`}):c(C,{className:`h-3 w-3`}),e(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),g.devices.length===0?c(L,{icon:d,title:e(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:e(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):c(R,{columns:D,rows:[...g.devices],rowKey:e=>e.deviceId,minWidthPx:480}),p===null?null:c(`p`,{className:p.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:p})]}):c(L,{icon:d,title:e(`recordings.eventsManagementSection.noEventData`,`No event data`),description:e(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function nt(){let{t:e}=K();return a(`div`,{className:`flex flex-col gap-8`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.eventsSection.eventStore`,`Event store`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),c(`div`,{className:`mt-3`,children:c(tt,{})})]}),a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),c(`div`,{className:`mt-3`,children:c(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 G.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return G.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?G.t(`helpers.exportFormat.inHours`,{n:String(i)}):G.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})}e();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:e,onCreated:t}){let{t:i}=K(),o=U({isCamera:!0,projection:`slim`}),s=n(()=>(o.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[o.data]),[l,u]=r(``),[d,p]=r(`high`),[m,h]=r(dt(60)),[g,_]=r(dt(0)),[v,y]=r(1),[b,x]=r(!0),[S,C]=r(``),[w,T]=r(null),E=l===``?s[0]?.id??null:l,k=new Date(m).getTime(),M=new Date(g).getTime(),N=Number.isFinite(k)&&Number.isFinite(M)&&k<M,P=ne({onSuccess:()=>{t(),e()},onError:e=>T(e instanceof Error?e.message:String(e))});return c(oe,{open:!0,onOpenChange:t=>!t&&e(),children:a(A,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[c(D,{children:a(ve,{className:`flex items-center gap-1.5`,children:[c(f,{className:`h-3.5 w-3.5`}),i(`recordings.newExportModal.newExport`,`New export`)]})}),a(j,{className:`space-y-3`,children:[a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.camera`,`Camera`)}),c(`select`,{value:E??``,onChange:e=>u(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:s.map(e=>c(`option`,{value:e.id,children:e.name},e.id))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.profile`,`Profile`)}),c(`select`,{value:d,onChange:e=>p(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:ct.map(e=>c(`option`,{value:e,children:e},e))})]})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.from`,`From`)}),c(`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`})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.to`,`To`)}),c(`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`})]})]}),a(`div`,{className:`grid grid-cols-2 gap-3`,children:[a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.speed`,`Speed`)}),c(`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=>c(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:i(e.labelKey)},e.value))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),c(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:i(`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`})]})]}),a(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[c(`input`,{type:`checkbox`,checked:b,disabled:v!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),i(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!N&&c(`p`,{className:`text-[11px] text-danger`,children:i(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),w&&c(`p`,{className:`text-[11px] text-danger`,children:w})]}),a(be,{children:[c(O,{variant:`outline`,size:`sm`,onClick:e,children:i(`common.cancel`,`Cancel`)}),c(O,{size:`sm`,onClick:()=>{if(E===null||!N)return;T(null);let e=S.trim();P.mutate({deviceId:E,profile:d,fromMs:k,toMs:M,options:{includeAudio:b,maxLifeMs:ut,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:E===null||!N||P.isPending,children:P.isPending?i(`recordings.newExportModal.queuing`,`Queuing…`):i(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}e();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:t}=ie({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=H(w.RecordingExportProgress,e=>e.exportId),{map:i}=H(w.RecordingExportCompleted,e=>e.exportId),{map:a}=H(w.RecordingExportFailed,e=>e.exportId);return{rows:n(()=>st(e??[],r,i,a),[e,r,i,a]),isLoading:t}}function gt(e){let[n,i]=r(()=>Date.now());return t(()=>{let t=setInterval(()=>i(Date.now()),e);return()=>clearInterval(t)},[e]),n}function _t(){let{t:e}=K(),t=s(),[o,d]=r(!1),p=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},m=B(),h=y().trpcClient,v=gt(6e4),{rows:b,isLoading:x}=ht(),{data:S}=U({isCamera:!0,projection:`slim`}),C=n(()=>{let e=new Map;for(let t of S??[])e.set(t.id,t.name);return e},[S]),w=i(()=>{t.invalidateQueries({queryKey:pt})},[t]),T=_e({onSuccess:w}),E=re({onSuccess:w}),[D,O]=r(null),k=i(async e=>{O(e.id);try{let{url:t}=await h.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await je(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]),A=i(async t=>{await m({title:e(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:e(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:e(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&T.mutate({exportId:t.id})},[m,T,e]),j=i(async t=>{await m({title:e(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:e(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&E.mutate({exportId:t.id})},[m,E,e]),M=n(()=>[{key:`camera`,header:e(`recordings.exportsSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:C.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:e(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:at(e.fromMs,e.toMs)})},{key:`variant`,header:e(`recordings.exportsSection.variant`,`Variant`),render:e=>c(`span`,{className:`text-foreground-subtle`,children:rt(e.options)})},{key:`state`,header:e(`recordings.exportsSection.state`,`State`),render:t=>{let n=mt[t.state];return a(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&c(_,{className:`h-2.5 w-2.5 animate-spin`}),e(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&a(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:e(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?c(`span`,{className:`text-foreground-subtle`,children:`—`}):c(`span`,{className:`text-foreground-subtle tabular-nums`,children:ot(e.expiresAt,v)})},{key:`size`,header:e(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:q(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,r=t.state===`queued`||t.state===`rendering`,i=t.state!==`deleted`;return a(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&a(`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:e(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[D===t.id?c(_,{className:`h-3 w-3 animate-spin`}):c(l,{className:`h-3 w-3`}),e(`recordings.exportsSection.download`,`Download`)]}),r&&a(`button`,{onClick:()=>{A(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:e(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[c(g,{className:`h-3 w-3`}),e(`common.cancel`,`Cancel`)]}),i&&c(`button`,{onClick:()=>{j(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:e(`recordings.exportsSection.deleteExport`,`Delete export`),children:c(u,{className:`h-3 w-3`})})]})}}],[C,v,D,T.isPending,E.isPending,k,A,j,e]);return x&&b.length===0?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(_,{className:`h-4 w-4 animate-spin`}),e(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):a(`div`,{className:`space-y-3`,children:[c(`div`,{className:`flex justify-end`,children:a(`button`,{onClick:()=>d(!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:[c(f,{className:`h-3.5 w-3.5`}),e(`recordings.exportsSection.newExport`,`New export`)]})}),b.length===0?c(L,{icon:f,title:e(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:e(`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.`)}):c(R,{columns:M,rows:b,rowKey:e=>e.id,minWidthPx:720}),o&&c(ft,{onClose:()=>d(!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`;e();var yt=`storage-migration`,bt=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function xt(e){return[`${e.orphansReclaimed} orphan rows (${q(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${q(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${q(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function St(){let{t:e}=K(),t=z(yt);return t===`pending`?null:t===`unknown`?c(`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`?c(Ct,{}):null}function Ct(){let{t:e}=K(),t=B(),[n,i]=r(!1),[o,s]=r(null),l=Ce({},{refetchInterval:2e3}),d=l.data??null,f=d!==null&&bt.has(d.phase),p=ee(),m=M(),h=async()=>{if(await t({title:e(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:n?e(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):e(`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:e(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){s(null);try{await p.mutateAsync({includeDebugMedia:n}),await l.refetch()}catch(e){s(e instanceof Error?e.message:String(e))}}},g=async()=>{if(d&&await t({title:e(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:e(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:e(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await m.mutateAsync({jobId:d.jobId}),await l.refetch()}catch{}};return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.cleanupSection.cleanup`,`Cleanup`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[c(`input`,{type:`checkbox`,checked:n,disabled:f,onChange:e=>{i(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),c(`span`,{children:e(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),a(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[a(`button`,{type:`button`,disabled:f||p.isPending,onClick:()=>{h()},className:vt,children:[(f||p.isPending)&&c(_,{className:`h-3 w-3 animate-spin`}),c(u,{className:`h-3 w-3`}),e(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&c(`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:e(`common.cancel`,`Cancel`)})]}),o&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:o}),d&&a(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[a(`p`,{className:`text-xs text-foreground`,children:[e(`recordings.cleanupSection.phase`,`Phase:`),` `,c(`span`,{className:`font-medium`,children:d.phase}),f&&c(_,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),d.detail&&c(`p`,{className:`text-[11px] text-foreground-subtle`,children:d.detail}),c(`p`,{className:`text-[11px] text-foreground-subtle`,children:xt(d)}),d.error&&c(`p`,{className:`text-[11px] text-danger`,children:d.error})]})]})}e();var wt=2e3;function Tt(){let{t:e}=K(),n=B(),r=s(),i=N(),o=ce(void 0,{refetchInterval:e=>e.state.data?.state===`running`?wt:!1}),l=o.data,u=l?.state===`running`,d=u||i.isPending;t(()=>{l?.state!==`done`||l.finishedAtMs===null||(r.invalidateQueries({queryKey:[[`recording`]]}),r.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[l?.state,l?.finishedAtMs,r]);let f=async()=>{await n({title:e(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:e(`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:e(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await i.mutateAsync(),await o.refetch())},p=u?l.total>0?`Reconciling ${String(l.completed)}/${String(l.total)}…`:`Reconciling…`:i.isPending?`Reconciling…`:`Reconcile from disk`;return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),a(`div`,{className:`mt-3 flex flex-col gap-2`,children:[a(`button`,{type:`button`,onClick:()=>void f(),disabled:d,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:[d?c(_,{className:`h-3.5 w-3.5 animate-spin`}):c(x,{className:`h-3.5 w-3.5`}),p]}),l?.state===`done`?a(`p`,{className:`text-[11px] text-foreground-subtle`,children:[e(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,e(`recordings.diskReconcileSection.summary`,{completed:String(l.completed),tracks:String(l.tracks),events:String(l.events),media:String(l.mediaDropped)}),l.failed.length>0?e(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(l.failed.length),value2:l.failed.join(`, `)}):``,`.`]}):null,l?.state===`error`&&l.error!==null?a(`p`,{className:`text-[11px] text-destructive`,children:[e(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,l.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?`${q(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:`${q(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(` · `)}e();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:e}=K(),t=z(kt);return t===`pending`?a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(_,{className:`h-4 w-4 animate-spin`}),e(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):t===`unknown`?c(L,{icon:p,title:e(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:e(`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.`)}):t===`absent`?c(L,{icon:S,title:e(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:e(`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.`)}):c(Mt,{})}function Mt(){let{t:e}=K(),t=B(),{data:i}=P({}),[o,s]=r({}),[l,u]=r({}),[d,f]=r(null),[p,m]=r(null),h=n(()=>{let e=new Map;for(let t of i??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[i]),g=n(()=>{let e=new Map;for(let t of i??[]){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},[i]),y=he({},{refetchInterval:2e3}),b=y.data??null,x=b!==null&&At.has(b.phase),C=n(()=>{let e={};for(let t of Q){let n=o[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[o]),w=n(()=>{let e={};for(let t of Q){if(!o[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},[o,l,g]),E=n(()=>({destinations:C??{},...w?{sources:w}:{}}),[C,w]),D=pe(E,{enabled:!1,retry:!1}),O=T(),k=le(),A=async()=>{if(!C)return;m(null);let e=await D.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},j=async()=>{if(C&&await t({title:e(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:e(`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:e(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await O.mutateAsync(E),f(null),await y.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},M=async()=>{if(b&&await t({title:e(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:e(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:e(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await k.mutateAsync({jobId:b.jobId}),await y.refetch()}catch{}};return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[a(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[c(S,{className:`h-3.5 w-3.5`}),e(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),c(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Q.map(t=>{let n=h.get(t.locationType)??[],r=g.get(t.locationType)??``;return a(`div`,{className:`space-y-2`,children:[c(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e(t.labelKey)}),a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:e(`recordings.storageMigrationSection.classFrom`,{label:e(t.labelKey)})}),c(`select`,{id:`migration-from-${t.id}`,value:l[t.id]??r,onChange:e=>{let n=e.target.value;u(e=>({...e,[t.id]:n}))},disabled:x,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:n.map(t=>a(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${e(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),a(`div`,{className:`space-y-1`,children:[c(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:e(`recordings.storageMigrationSection.classTo`,{label:e(t.labelKey)})}),a(`select`,{id:`migration-dest-${t.id}`,value:o[t.id]??``,onChange:e=>{let n=e.target.value;s(e=>({...e,[t.id]:n}))},disabled:x,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[c(`option`,{value:``,children:e(`migration.storageMigrationSection.skip`,`— skip —`)}),n.map(e=>c(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),p&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[a(`button`,{type:`button`,onClick:()=>{A()},disabled:!C||D.isFetching||x,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[D.isFetching&&c(_,{className:`h-3 w-3 animate-spin`}),e(`migration.storageMigrationSection.plan`,`Plan`)]}),a(`button`,{type:`button`,onClick:()=>{j()},disabled:!C||O.isPending||x,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[O.isPending&&c(_,{className:`h-3 w-3 animate-spin`}),e(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&c(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?c(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:e(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.moves.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]},`${e.storageClass}-${e.toLocationId}`))}),b&&a(`div`,{className:`mt-4 border-t border-border pt-3`,children:[a(`div`,{className:`flex items-center justify-between`,children:[c(`h4`,{className:`text-xs font-semibold text-foreground`,children:e(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),x&&a(`button`,{type:`button`,onClick:()=>{M()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[c(v,{className:`h-3 w-3`}),e(`common.cancel`,`Cancel`)]})]}),a(`p`,{className:`mt-1 text-xs text-foreground`,children:[e(`migration.storageMigrationSection.phase`,`Phase:`),` `,c(`span`,{className:`font-medium`,children:b.phase}),x&&c(_,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),b.error&&c(`p`,{className:`mt-1 text-[11px] text-danger`,children:b.error}),b.pausedParticipants.length>0&&a(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[e(`migration.storageMigrationSection.paused`,`Paused:`),` `,b.pausedParticipants.join(`, `)]}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:b.moves.map(e=>c(Nt,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),c(Pt,{})]}),c(Ft,{running:x}),c(Lt,{})]})}function Nt({move:e}){let{t}=K(),n=e.progress===null?null:Dt(e.progress);return a(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[a(`div`,{className:`flex items-center justify-between`,children:[a(`span`,{className:`text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]}),a(`span`,{className:`text-foreground-subtle`,children:[e.state??t(`common.pending`),e.error?` (${e.error})`:``]})]}),e.progress!==null&&a(`div`,{className:`mt-1 space-y-1`,children:[n!==null&&n.fraction!==null&&c(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:c(`div`,{className:`h-full bg-primary`,style:{width:`${(n.fraction*100).toFixed(1)}%`}})}),c(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ot(e.progress)})]})]})}function Pt(){let{t:e}=K(),{data:t}=fe({});return!t||t.length===0?null:a(`div`,{className:`mt-4 border-t border-border pt-3`,children:[c(`h4`,{className:`text-xs font-semibold text-foreground`,children:e(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:t.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[c(`span`,{className:`font-medium text-foreground`,children:e.phase}),` · `,Object.entries(e.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(e.startedAt).toLocaleString()]},e.jobId))})]})}function Ft({running:e}){let{t}=K(),n=B(),i=ae({},{staleTime:1/0,refetchOnWindowFocus:!1}),o=F(),[s,l]=r(null),u=i.data??[];if(u.length===0)return null;let d=async e=>{if(await n({title:t(`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:t(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await o.mutateAsync({classes:[e.storageClass]}),await i.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[a(`div`,{className:`flex items-start justify-between gap-2`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),a(`div`,{className:`flex shrink-0 items-center gap-2`,children:[c(`span`,{className:`text-[10px] text-foreground-subtle`,children:i.dataUpdatedAt>0?t(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(i.dataUpdatedAt).toLocaleTimeString()}):t(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),c(`button`,{type:`button`,onClick:()=>{i.refetch()},disabled:i.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:i.isFetching?t(`migration.storageMigrationSection.counting`,`Counting…`):t(`common.refresh`,`Refresh`)})]})]}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`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.`)}),c(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:t(`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.`)}),s&&c(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(n=>a(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[a(`span`,{className:`text-foreground`,children:[n.storageClass,`: `,n.fromLocationId,` → `,n.toLocationId,c(`span`,{className:`ml-2 text-foreground-subtle`,children:It(n)})]}),c(`button`,{type:`button`,onClick:()=>{d(n)},disabled:e||o.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:t(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${n.storageClass}-${n.fromLocationId}`))})]})}function It(e){if(e.items===null)return G.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?G.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):G.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:q(e.bytes)})}function Lt(){let{t:e}=K(),{data:t}=de({},{refetchInterval:2e3}),n=(t??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return n.length===0?null:a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),c(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(e=>a(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[a(`div`,{className:`text-foreground`,children:[e.lane,`: `,e.job.fromLocationId,` → `,e.job.toLocationId]}),c(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:Ot({filesMoved:e.job.filesMoved,filesTotal:e.job.filesTotal,bytesMoved:e.job.bytesMoved,startedAt:e.job.startedAt,observedAt:e.observedAt})})]},e.job.jobId))})]})}function Rt(){let{t:e}=K();return a(`div`,{className:`flex flex-col gap-4`,children:[c(St,{}),c(Tt,{}),a(`section`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),c(`div`,{className:`mt-3`,children:c(jt,{})})]})]})}e();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:e}=K(),t=s(),{nodes:r}=Se(),{data:i,isLoading:o}=W({addonId:zt}),l=Bt(i,`recordingNodeId`,`hub`),u=V({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),d=n(()=>{let e=r.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[r,l]);return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`text-sm font-semibold text-foreground`,children:e(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`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.`)}),a(`div`,{className:`mt-3 flex items-center gap-2`,children:[o?c(_,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):c(`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(t=>c(`option`,{value:t,children:t===`hub`?e(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):t},t))}),u.isPending&&c(_,{className:`h-4 w-4 animate-spin text-primary`})]}),l!==`hub`&&c(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:c(Oe,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:l},components:{b:c(`span`,{className:`font-medium`})}})})]}),a(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[c(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:e(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),c(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:e(`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.`)}),c(qe,{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?G.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}}e();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(` + `):G.t(`recordings.storageSection.defaultRoot`):e.root}function Zt(){let{t:e}=K(),t=s(),o=B(),[l,d]=r(`retention`),{data:f,isLoading:p}=I({},{refetchOnWindowFocus:!1}),{data:m}=U({isCamera:!0,projection:`slim`}),{data:g}=P({}),v=n(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),y=n(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.displayName);return e},[g]),b=n(()=>{let e=g??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[g]),S=n(()=>f?.locations??[],[f?.locations]),w=n(()=>Wt(S,y,b),[S,y,b]),T=n(()=>Ne(S),[S]),D=i(()=>{t.invalidateQueries({queryKey:Gt})},[t]),O=E({onSuccess:D}),A=k({onSuccess:D}),j=i(async t=>{await o({title:e(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:v.get(t.deviceId)??`#${String(t.deviceId)}`}),message:e(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:l}),confirmLabel:e(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&O.mutate({deviceId:t.deviceId,reason:l})},[o,O,l,v,e]),M=i(async t=>{await o({title:e(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:v.get(t.deviceId)??`#${String(t.deviceId)}`}),message:e(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:q(t.usedBytes)}),confirmLabel:e(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:q(t.usedBytes)}),variant:`danger`})&&A.mutate({deviceId:t.deviceId})},[o,A,v,e]),N=n(()=>[{key:`camera`,header:e(`recordings.storageSection.camera`,`Camera`),render:e=>c(`span`,{className:`text-foreground`,children:v.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:e(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>w===null?c(`span`,{className:`text-foreground-subtle`,children:`—`}):a(`span`,{className:w.exact?`text-foreground`:`text-foreground-subtle`,title:w.exact?e(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):e(`recordings.storageSection.theRecordingsDefaultThisNode`,`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`),children:[w.label,!w.exact&&c(`span`,{className:`ml-1 text-foreground-subtle`,children:e(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:e(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>c(`span`,{className:`tabular-nums`,children:q(e.usedBytes)})},{key:`oldest`,header:e(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:t=>c(`span`,{className:`tabular-nums text-foreground-subtle`,title:e(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Yt(t.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>a(`div`,{className:`flex items-center justify-end gap-1`,children:[a(`button`,{onClick:()=>{j(t)},disabled:O.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:e(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[c(C,{className:`h-3 w-3`}),e(`recordings.storageSection.prune2`,`Prune`)]}),a(`button`,{onClick:()=>{M(t)},disabled:A.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:e(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[c(u,{className:`h-3 w-3`}),e(`common.delete`,`Delete`)]})]})}],[v,w,j,M,O.isPending,A.isPending,e]);if(p&&!f)return a(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(_,{className:`h-4 w-4 animate-spin`}),e(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!f)return c(L,{icon:x,title:e(`recordings.storageSection.noStorageData`,`No storage data`),description:e(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let F=f.devices.length;return a(`div`,{className:`flex flex-col gap-6`,children:[a(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[c(h,{label:e(`recordings.storageSection.totalUsed`,`Total used`),icon:c(x,{className:`h-3 w-3`}),footer:`${String(F)} camera${F===1?``:`s`} on ${f.nodeId}`,children:q(f.totalUsedBytes)}),T!==null&&T.severity!==null&&c(h,{label:e(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:c(x,{className:`h-3 w-3`}),footer:`across ${String(T.knownVolumes)} volume${T.knownVolumes===1?``:`s`} of ${q(T.totalBytes)}`+(T.unknownVolumes>0?` · ${String(T.unknownVolumes)} did not report capacity`:``),children:c(`span`,{className:`tabular-nums ${Jt[T.severity]}`,children:q(T.freeBytes)})}),S.map(t=>{let n=Le(t),r=t.locationId??t.root??`default`;return c(h,{label:e(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Xt(t,y)}),footer:n===null?`${q(t.usedBytes)} of recordings · volume capacity unknown`:`${q(n.freeBytes)} free of ${q(n.totalBytes)} · ${q(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?c(`span`,{className:`tabular-nums`,children:q(t.usedBytes)}):a(`div`,{className:`flex items-center gap-2`,title:e(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[c(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:c(`div`,{className:`h-full rounded ${qt[n.severity]}`,style:{width:$(n.fraction)}})}),c(`span`,{className:`tabular-nums text-xs ${Jt[n.severity]}`,children:$(n.fraction)})]})},r)})]}),a(`section`,{className:`flex items-center gap-2 text-xs`,children:[c(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:e(`recordings.storageSection.pruneReason`,`Prune reason`)}),c(`select`,{id:`prune-reason`,value:l,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(t=>c(`option`,{value:t.value,children:e(t.labelKey)},t.value))})]}),F===0?c(L,{icon:x,title:f.devicesRead===`unavailable`?e(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):e(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:f.devicesRead===`unavailable`?e(`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.`):e(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):c(R,{columns:N,rows:[...f.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Qt(){let{t:e}=K();return a(`div`,{className:`flex flex-col gap-8`,children:[a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),c(`div`,{className:`mt-3`,children:c(Zt,{})})]}),a(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:e(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:e(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),c(`div`,{className:`mt-3`,children:c(Vt,{})})]})]})}function $t(){let{t:e}=K(),t=De(`/recordings`,{t:e,isAdmin:!0})??{icon:f,title:e(`nav.recordings`,`Recordings`)};return c(Ae,{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:c(Qt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:c(nt,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:c(Ke,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:c(_t,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:c(Ge,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:c(Rt,{})}]})}export{$t as RecordingsPage};
@@ -1,2 +0,0 @@
1
- import{$ as e,G as t,J as n,L as r,S as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{D as s,It as c,ar as l,cn as u,di as d,dt as f,ot as p}from"./player-overlays-D0U2dNvn.js";import{i as m,o as h}from"./video-BBtESt54.js";import{t as g}from"./key-round-yCDTbIQb.js";import{t as _}from"./octagon-alert-C-jH7VH_.js";import{$l as v,An as y,Bn as b,Dn as x,Fl as S,Ln as C,Nt as w,On as T,Pt as E,Ql as D,Qn as O,Tn as ee,Ut as te,Vt as ne,Wt as re,Zn as ie,ar as ae,ha as oe,jn as se,kn as ce,ou as k,vu as A}from"./src-CGxdJN_f.js";import{t as j}from"./i18n-Vb3uBp7P.js";import{t as M}from"./useTranslation-D3Is_4B6.js";import{a as le,z as ue}from"./index-DvOECbab.js";e();function N({id:e,title:t,icon:n,description:r,actions:a,tone:c=`default`,notice:l=null,onDismissNotice:u,children:d}){return o(ne,{headingId:`access-${e}`,title:t,icon:n,actions:a,testId:`access-${e}`,children:i(`div`,{className:`${s} space-y-3`,children:[o(`div`,{className:k(`text-[11px] leading-relaxed`,c===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:r}),l!==null&&o(fe,{notice:l,onDismiss:u}),d]})})}var de={success:{icon:d,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:_,line:`border-danger/40 text-danger`,mark:`text-danger`}};function fe({notice:e,onDismiss:t}){let{t:n}=M(),r=de[e.tone],a=r.icon;return i(`div`,{role:e.tone===`danger`?`alert`:`status`,className:k(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,r.line),children:[o(a,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.mark),"aria-hidden":!0}),o(`span`,{className:`min-w-0 flex-1`,children:e.message}),t!==void 0&&o(v,{type:`button`,variant:`ghost`,size:`sm`,icon:f,"aria-label":n(`access.accessSection.dismiss`,`Dismiss`),onClick:t,className:`-my-1 h-5 w-5`})]})}function P(){let{data:e}=S();return t(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function F(e,t=null){return e===null?t:{tone:`danger`,message:e}}var pe={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function I(e){return j.t(pe[e])}var me={active:`success`,expired:`warning`,revoked:`default`,current:`info`},he={current:0,active:1,expired:2,revoked:3};function L(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function ge({status:e}){return o(ae,{variant:me[e],className:`text-[10px]`,children:I(e)})}function _e({row:e,action:t}){if(!t.isAvailable(e))return null;let n=t.icon,r=t.busyId===e.id;return i(b,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>t.onRun(e),disabled:t.disabled,"aria-label":j.t(`access.credentialColumns.actionOn`,{action:t.label,name:e.name}),className:t.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[r?o(l,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):o(n,{className:`h-3 w-3`,"aria-hidden":!0}),t.label]})}function ve(e){return[{key:`name`,header:j.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:e=>i(`div`,{className:`min-w-0 max-w-[18rem]`,children:[o(`div`,{className:`truncate font-medium text-foreground`,title:e.name,children:e.name}),e.detail!==null&&o(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:e.detail,children:e.detail})]})},e.hideOwner?null:{key:`owner`,header:j.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:j.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:e=>i(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[o(`div`,{className:`text-foreground`,children:e.kind}),e.scope!==null&&o(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:e.scope,children:e.scope})]})},{key:`status`,header:j.t(`access.credentialColumns.status`,`Status`),sortValue:e=>he[e.status],render:e=>o(ge,{status:e.status})},{key:`created`,header:j.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>o(`span`,{className:`text-foreground-subtle`,children:L(e.createdAt,`—`)})},{key:`lastUsed`,header:j.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>o(`span`,{className:`text-foreground-subtle`,children:L(e.lastUsedAt,j.t(`access.credentialColumns.never`))})},{key:`expires`,header:j.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:t=>o(`span`,{className:`text-foreground-subtle`,children:L(t.expiresAt,e.expiresNone)})},e.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:j.t(`access.credentialColumns.actionsHeader`),render:t=>o(`div`,{className:`flex items-center justify-end gap-1`,children:[...e.extraActions??[],e.action].map(e=>e===null?null:o(_e,{row:t,action:e},e.label))})}].filter(e=>e!==null)}e();var R=6,ye={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function z(e){let t=ye[e];return t===void 0?e:j.t(t)}function B(e,t){return j.t(t.key,{count:e})}function V(e,t){return j.t(`access.bulk.countOf`,{count:e,noun:B(e,t)})}function be(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])=>j.t(`access.bulk.statusCount`,{count:t,status:I(e).toLowerCase()})).join(`, `)}function xe(e,t){let n=e.slice(0,R).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>R?[j.t(`access.bulk.previewMore`,{count:e.length-R})]:[];return[j.t(`access.bulk.previewIntro`,{what:V(e.length,t),breakdown:be(e)}),``,...n,...r].join(`
2
- `)}async function H(e,t,n){let r=String(t.length),i=await e({title:j.t(`access.bulk.confirmTitle`,{what:V(t.length,n)}),message:xe(t,n),label:j.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:j.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:j.t(`access.bulk.confirmMismatch`,{expected:r,noun:B(2,n)})});return i!==null&&i.trim()===r}function U(e,t,r){let i=O(),a=A.auth.revokeCredentials.useMutation(),[o,s]=n(null);return{run:async n=>{if(n.length===0||!await H(i,n,t))return!1;s(null);try{let r=await a.mutateAsync({kind:e,ids:n.map(e=>e.id),confirmCount:n.length}),i=r.skipped.map(e=>z(e.reason));return s({tone:`success`,message:i.length>0?j.t(`access.bulk.revokedSkipped`,{what:V(r.revoked.length,t),count:i.length,reasons:[...new Set(i)].join(`, `)}):j.t(`access.bulk.revoked`,{what:V(r.revoked.length,t)})}),!0}catch(e){return s({tone:`danger`,message:j.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:j.t(`access.bulk.requestFailed`)})}),!1}finally{r()}},busy:a.isPending,outcome:o,dismiss:()=>s(null)}}function Se(e,t){let r=O(),i=A.auth.revokeCredentials.useMutation(),[a,o]=n(null);return{run:async n=>{if(n.length===0||!await H(r,n,e))return!1;o(null);let a=n.filter(e=>e.kind===`Scoped`).map(e=>e.id),s=n.filter(e=>e.kind===`Admin`).map(e=>e.id);try{let t=[],n=[];if(a.length>0){let e=await i.mutateAsync({kind:`scoped-token`,ids:a,confirmCount:a.length});t.push(...e.revoked),n.push(...e.skipped)}if(s.length>0){let e=await i.mutateAsync({kind:`admin-token`,ids:s,confirmCount:s.length});t.push(...e.revoked),n.push(...e.skipped)}let r=n.map(e=>z(e.reason));return o({tone:`success`,message:r.length>0?j.t(`access.bulk.revokedSkipped`,{what:V(t.length,e),count:r.length,reasons:[...new Set(r)].join(`, `)}):j.t(`access.bulk.revoked`,{what:V(t.length,e)})}),!0}catch(e){return o({tone:`danger`,message:j.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:j.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:i.isPending,outcome:a,dismiss:()=>o(null)}}function Ce(e,t,r){let i=O(),[a,o]=n(!1),[s,c]=n(null);return{run:async n=>{if(n.length===0||!await H(i,n,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of n)try{await t(e.id),s+=1}catch(t){a.push(`${e.name}: ${t instanceof Error?t.message:j.t(`access.bulk.requestFailed`)}`)}return o(!1),r(),a.length===0?(c({tone:`success`,message:j.t(`access.bulk.revoked`,{what:V(s,e)})}),!0):(c({tone:`danger`,message:j.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:V(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}e();var we={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}]},W={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Te=e=>e.status!==`current`,Ee=[`active`,`current`];function G({rows:e,label:r,isLoading:a,loadError:s,emptyText:c,hideOwner:u=!1,expiresNone:d,action:f,extraActions:p,bulk:m,defaultStatus:h=Ee}){let{t:g}=M(),[_]=n(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),v=w(e,we,_),[y,b]=n(()=>new Set),x=d??g(`access.credentialColumns.never`),S=t(()=>ve({hideOwner:u,expiresNone:x,action:f??null,...p===void 0?{}:{extraActions:p}}),[u,x,f,p,g]),T=t(()=>m===void 0?()=>!1:e=>Te(e)&&m.isSelectable(e),[m]),D=t(()=>v.rows.filter(e=>y.has(e.id)&&T(e)),[v.rows,y,T]);return a?i(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[o(l,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:r})]}):s===null?i(`div`,{className:`space-y-3`,children:[o(E,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(u&&e.id===`owner`)).map(e=>({...e,label:W[e.id]===void 0?e.id:g(W[e.id]),...e.id===`status`?{facetLabel:e=>I(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:r}),searchLabel:g(`access.credentialTable.searchLabel`,{label:r}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:r}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),m!==void 0&&o(De,{bulk:m,shown:v.rows.filter(T),targets:D,onSelect:b}),o(te,{columns:S,rows:v.rows,rowKey:e=>e.id,minWidthPx:u?760:860,maxBodyHeight:re,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:r}),previous:g(`access.credentialTable.previousPage`),next:g(`access.credentialTable.nextPage`),range:(e,t,n)=>g(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?g(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:r}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:T,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:B(1,m.noun)})}}})]}):o(C,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:r}),message:s})}function De({bulk:e,shown:t,targets:n,onSelect:r}){let{t:a}=M(),{revoke:s,noun:u}=e,d=(e.quickSelect??[]).map(e=>({...e,rows:t.filter(e.match)})).filter(e=>e.rows.length>0),p=async()=>{await s.run(n)&&r(new Set)};return i(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[t.length>0&&o(b,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(new Set(t.map(e=>e.id))),children:a(`access.credentialTable.selectAllShown`,{count:t.length})}),d.map(e=>i(b,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(new Set(e.rows.map(e=>e.id))),children:[e.label,` (`,String(e.rows.length),`)`]},e.label)),n.length>0&&i(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[o(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:a(`access.credentialTable.selectedLabel`,{what:V(n.length,u)})}),i(b,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r(new Set),children:[o(f,{className:`h-3 w-3`,"aria-hidden":!0}),a(`access.credentialTable.clearSelection`,`Clear selection`)]}),i(b,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void p(),children:[s.busy?o(l,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):o(c,{className:`h-3 w-3`,"aria-hidden":!0}),a(`access.credentialTable.revoke`,{what:V(n.length,u)})]})]})]})}var K=(e,t)=>t===null?`—`:e.get(t)??t;function q(e,t){return e!=null&&e<=t?`expired`:`active`}function Oe(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:K(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 ke(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 Ae=`Scoped`,J=`Admin`;function je(e,t,n,r,i){return{id:e.id,name:e.name,detail:`${e.tokenPrefix}…`,ownerId:t,ownerName:K(n,t),kind:Ae,scope:r,status:q(e.expiresAt,i),createdAt:e.createdAt,lastUsedAt:e.lastUsedAt??null,expiresAt:e.expiresAt??null}}function Me(e,t,n){return{id:e.id,name:e.name,detail:`${e.tokenPrefix}…`,ownerId:e.createdBy,ownerName:K(t,e.createdBy),kind:J,scope:`Full administrator`,status:e.revokedAt===null?q(e.expiresAt,n):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}var Ne={"grid-view":`Grid`,"events-view":`Events`};function Pe(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function Fe(e,t,n,r){let i=Ne[e.scope.kind];return{id:e.id,name:`${i} · ${String(e.scope.deviceIds.length)} camera${e.scope.deviceIds.length===1?``:`s`}`,detail:`${e.tokenPrefix}…`,ownerId:e.userId,ownerName:K(t,e.userId),kind:e.scope.talk===!0?`${i} + talk`:i,scope:Pe(e.scope.deviceIds,n),status:q(e.expiresAt,r),createdAt:e.createdAt,lastUsedAt:e.lastUsedAt??null,expiresAt:e.expiresAt}}function Y(e){return`${e.provider}\u0000${e.subject}`}function Ie(e,t){return{id:Y(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:K(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}function Le(e,t){let n=e.allowedProviders;return{id:e.id,name:e.label,detail:`${e.tokenPrefix}…`,ownerId:e.userId??null,ownerName:K(t,e.userId??null),kind:e.isAdmin===!0?`Admin`:`Regular`,scope:n===void 0||n===`*`?`All providers`:n.join(`, `)||`All providers`,status:`active`,createdAt:e.createdAt??null,lastUsedAt:e.lastUsedAt??null,expiresAt:null}}var X=40,Re=[{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`}],ze=[{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`}],Be=[{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 Z(e,t){return e.find(e=>e.test.test(t))?.name??null}function Ve(e){return e.length<=X?e:`${e.slice(0,X)}…`}function He(e){if(e===null||e.trim().length===0)return{label:j.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=Z(Be,t);if(n!==null)return{label:n,raw:t};let r=Z(Re,t),i=Z(ze,t);return r!==null&&i!==null?{label:j.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:Ve(t),raw:t}:{label:r,raw:t}}var Ue={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 We(e){let t=Ue[e];return t===void 0?e:j.t(t)}function Q(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}e();function Ge(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function Ke(e){let{t}=M(),s=p(),[c,u]=n(!1),[d,f]=n(``),[m,h]=n(null),[_,v]=n(null),S=a(null),C=r(e=>{S.current?.(e),S.current=null,u(!1),f(``),h(null),v(null)},[]),w=r(()=>new Promise(e=>{S.current?.(null),S.current=e,v(null),u(!0)}),[]),E=async()=>{h(`password`),v(null);try{let{reauthToken:e}=await s.reauthenticate({password:d});C(e)}catch(e){v(Ge(e,`Password is incorrect`)),h(null)}},O=async()=>{h(`passkey`),v(null);try{let{optionsJSON:e}=await s.reauthBeginPasskey(),t=await le({optionsJSON:e}),{reauthToken:n}=await s.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});C(n)}catch(e){v(Ge(e,`Passkey verification failed`)),h(null)}};return{requestProof:w,dialog:o(ee,{open:c,onOpenChange:e=>!e&&C(null),children:i(x,{children:[i(y,{children:[o(se,{children:t(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),o(T,{children:t(`auth.reauthDialog.needsPassword`,{action:e})})]}),i(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),d.length>0&&m===null&&E()},children:[o(D,{type:`password`,autoComplete:`current-password`,placeholder:t(`auth.reauthDialog.currentPassword`,`Current password`),value:d,onChange:e=>f(e.target.value),"aria-label":t(`auth.reauthDialog.currentPassword`,`Current password`)}),_!==null&&o(`p`,{role:`alert`,className:`text-xs text-danger`,children:_}),i(ce,{className:`flex flex-wrap gap-2`,children:[i(b,{type:`button`,variant:`outline`,disabled:m!==null,onClick:()=>void O(),children:[m===`passkey`?o(l,{className:`h-4 w-4 animate-spin`}):o(g,{className:`h-4 w-4`}),t(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),i(b,{type:`submit`,disabled:d.length===0||m!==null,children:[m===`password`&&o(l,{className:`h-4 w-4 animate-spin`}),t(`common.confirm`,`Confirm`)]})]})]})]})})}}e();var qe={key:`access.nouns.shareLink`};function Je(e){let{t:r}=M(),i=ie(),a=A.useUtils(),o=A.auth.listShareTokens.useQuery({owner:e}),s=P(),{data:l}=oe({isCamera:!0,projection:`slim`}),[u,d]=n(null),f=()=>void a.auth.listShareTokens.invalidate(),p=A.auth.revokeShareToken.useMutation({onSuccess:f,onError:e=>d(`Revoke failed: ${e.message}`)}),m=t(()=>{let e=new Map;for(let t of l??[])e.set(t.id,t.name);return e},[l]),h=Date.now(),g=(o.data??[]).map(e=>Fe(e,s,m,h)),_=async e=>{await i({title:r(`users.shareLinksSection.revokeShareLink`,`Revoke share link`),message:r(`users.shareLinksSection.anyoneHoldingThisLinkTo`,`Anyone holding this link to {{value1}} loses access immediately. This cannot be undone.`,{value1:e.scope??e.name}),confirmLabel:r(`users.shareLinksSection.revoke`,`Revoke`),variant:`danger`})&&(d(null),p.mutate({id:e.id}))};return{rows:g,refresh:f,error:u,clearError:()=>d(null),isLoading:o.isLoading,loadError:o.isError?o.error?.message??`Request failed`:null,action:{label:r(`users.shareLinksSection.revoke`,`Revoke`),icon:c,isAvailable:()=>!0,onRun:e=>void _(e),busyId:p.isPending?p.variables?.id??null:null,disabled:p.isPending}}}function Ye(){let{t:e}=M(),t=Je(`self`);return o(N,{notice:F(t.error),onDismissNotice:t.clearError,id:`my-share-links`,title:e(`users.shareLinksSection.shareLinks`,`Share links`),icon:u,description:e(`users.shareLinksSection.viewOnlyLinksYouCreated`,`View-only links you created in the viewer app to share a grid or the events of some cameras. Revoking a link stops it working everywhere it was sent.`),children:o(G,{rows:t.rows,label:e(`users.shareLinksSection.shareLinks2`,`share links`),isLoading:t.isLoading,loadError:t.loadError,emptyText:`You have no share links.`,hideOwner:!0,action:t.action})})}function Xe(){let{user:e}=ue();return e?.isAdmin?o(Ze,{}):null}function Ze(){let{t:e}=M(),t=Je(`all`),n=U(`share-link`,qe,t.refresh);return o(N,{notice:F(t.error,n.outcome),onDismissNotice:()=>{t.clearError(),n.dismiss()},id:`share-links`,title:e(`users.shareLinksSection.shareLinks`,`Share links`),icon:u,description:e(`users.shareLinksSection.everyUserSViewOnly`,`Every user's view-only share links. Revoking one stops it working for whoever it was sent to — a revoked link is deleted and cannot be restored.`),children:o(G,{rows:t.rows,label:e(`users.shareLinksSection.shareLinks2`,`share links`),isLoading:t.isLoading,loadError:t.loadError,emptyText:`No user has any share links.`,action:{...t.action,disabled:t.action.disabled||n.busy},bulk:{revoke:n,noun:qe,isSelectable:()=>!0,quickSelect:[{label:e(`users.shareLinksSection.selectExpired`,`Select expired`),match:e=>e.status===`expired`}]}})})}var Qe=864e5,$e={qr:`QR (by an admin)`,self:`Self-enrolled`},et={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function tt(e){return e.status===`revoked`}function nt(e){return e.status!==`revoked`}function rt(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function it(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/Qe)}function at(e,t){let n=it(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function ot(e,t){let n=it(e,t);return n===null?j.t(`helpers.certificateModel.unknown`):n===0?j.t(`helpers.certificateModel.today`):n>0?j.t(`helpers.certificateModel.inDays`,{count:n}):j.t(`helpers.certificateModel.daysAgo`,{count:-n})}function st(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function ct(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function $(e){return e.length<=10?e:`${e.slice(0,10)}…`}function lt(e){if(!e.online)return{allowed:!1,reason:j.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:j.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:j.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var ut={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 dt(e){if(e.ok)return{tone:`success`,message:j.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:$(e.newSerial)})};let t=e.keptPreviousLeaf?j.t(`helpers.certificateModel.keptPrevious`):j.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:j.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:j.t(ut[e.stage]),reason:e.reason,kept:t})}}function ft(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 pt=11;function mt(e,t){let n=e.slice(0,pt);return t===null?n:`${n} · ${t}`}function ht(e){return{id:e.id,name:e.deviceName,detail:mt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:et[e.platform],scope:$e[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function gt(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:et[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function _t({sessions:e,isLoading:t,loadError:n,emptyText:r,onRevoke:a,revokingId:s}){let{t:c}=M();return t?i(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(l,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):n===null?e.length===0?o(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:r}):o(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:e.map(e=>o(vt,{session:e,revoking:s===e.id,onRevoke:()=>a(e)},e.id))}):i(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,n]})}function vt({session:e,revoking:t,onRevoke:n}){let{t:r}=M(),a=He(e.client);return i(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[o(m,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),i(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o(`span`,{className:`font-medium text-foreground truncate`,title:a.raw??void 0,children:a.label}),e.current&&o(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:r(`auth.sessionsList.thisDevice`,`This device`)})]}),i(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[o(`span`,{children:We(e.method)}),o(`span`,{className:`font-mono`,children:e.ip??r(`auth.sessionsList.ipUnknown`,`IP unknown`)}),o(`span`,{children:r(`auth.sessionsList.lastActive`,{when:Q(e.lastUsedAt)})}),o(`span`,{children:r(`auth.sessionsList.expires`,{when:Q(e.expiresAt)})})]})]}),!e.current&&i(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[t?o(l,{className:`h-3 w-3 animate-spin`}):o(h,{className:`h-3 w-3`}),r(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{U as A,Le as C,Oe as D,ke as E,P as F,Se as M,N,je as O,F as P,Me as S,Ie as T,Ke as _,nt as a,Q as b,ot as c,rt as d,lt as f,Ye as g,Xe as h,tt as i,Ce as j,G as k,dt as l,$ as m,ht as n,ft as o,ct as p,gt as r,st as s,_t as t,at as u,He as v,Y as w,J as x,We as y};
@@ -1 +0,0 @@
1
- import{$i as e}from"./player-overlays-D0U2dNvn.js";var t=e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]);export{t};