@camstack/addon-admin-ui 1.2.604 → 1.2.606

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 (142) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/assets/Addons-DwdVdYn5.js +5 -0
  3. package/dist/assets/{AdminPage-B9sdR6yD.js → AdminPage-qR6elCnl.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-Di2VI8A1.js → AdminSectionedPage-6893SaIU.js} +1 -1
  5. package/dist/assets/{AiProfiles-DwQZldFN.js → AiProfiles-qBmxjey8.js} +2 -2
  6. package/dist/assets/{Authentication-CMBgIYCp.js → Authentication-CDgdDuh0.js} +1 -1
  7. package/dist/assets/{Build-BPF-jpLK.js → Build-DaOoHR-6.js} +3 -3
  8. package/dist/assets/{Calendars-lddz6ZEe.js → Calendars-BGQ8HwrY.js} +1 -1
  9. package/dist/assets/CameraGrids-UIVs5OTB.js +1 -0
  10. package/dist/assets/{Cluster-De1RL3Fs.js → Cluster-D2l7vSfX.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-B0oU4gJG.js → CompositionBlockEditor-CSCK2rCI.js} +2 -2
  12. package/dist/assets/{CompositionEditorPage-o4_rUh83.js → CompositionEditorPage-D2LWLo3H.js} +1 -1
  13. package/dist/assets/{Data-BrdEF29B.js → Data-BVrTjAgG.js} +2 -2
  14. package/dist/assets/{DeviceDetail-BZUd-DAf.js → DeviceDetail-CDHbp6Im.js} +2 -2
  15. package/dist/assets/{DeviceDoActionFields-BPsB-f31.js → DeviceDoActionFields-NY7wB-VN.js} +1 -1
  16. package/dist/assets/{Devices-DmDA_J0U.js → Devices-BPiNbgT8.js} +1 -1
  17. package/dist/assets/{EditTemplateButton-Bazz4Pt4.js → EditTemplateButton-B8SCTea8.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-B28rSWqV.js → EmbedPlayerPage--uqLrJXG.js} +1 -1
  19. package/dist/assets/History-BP-AB2nV.js +1 -0
  20. package/dist/assets/Identity-CocJq58e.js +1 -0
  21. package/dist/assets/InstancesTable-CgR4OQbD.js +1 -0
  22. package/dist/assets/IntegrationDetail-puYzC2ri.js +1 -0
  23. package/dist/assets/{IntegrationHub-DwJAPbKr.js → IntegrationHub-50C35JXv.js} +1 -1
  24. package/dist/assets/{Integrations-Be3dLjNq.js → Integrations-DJpMIOMj.js} +1 -1
  25. package/dist/assets/{Integrations-BWF9wcWz.js → Integrations-qPptabot.js} +2 -2
  26. package/dist/assets/{Library-CvnIw7kn.js → Library-BJHez0dz.js} +1 -1
  27. package/dist/assets/{Locations-BMg1Zl7f.js → Locations-BAf5NoRS.js} +1 -1
  28. package/dist/assets/{Logs-CLzySzHb.js → Logs-LsCNqILy.js} +1 -1
  29. package/dist/assets/{MaskShapeCanvas-DfSAMcgB.js → MaskShapeCanvas-D1jjdVSr.js} +1 -1
  30. package/dist/assets/{MotionZonesSettings-lq8C670W.js → MotionZonesSettings-DiIPf88t.js} +1 -1
  31. package/dist/assets/MyAccess-D4Hu1xA1.js +2 -0
  32. package/dist/assets/{Network-whsaEkOS.js → Network-CRa159Fl.js} +1 -1
  33. package/dist/assets/{NodeAddonsSettingsPanel-B8UxjFBZ.js → NodeAddonsSettingsPanel-hPglGkot.js} +1 -1
  34. package/dist/assets/{Notifications-CurhviRP.js → Notifications-CLYFpSJP.js} +1 -1
  35. package/dist/assets/{Pipeline-C2akOMKR.js → Pipeline-CawM5bRg.js} +1 -1
  36. package/dist/assets/{PrivacyMaskSettings-Cp5Q0GE2.js → PrivacyMaskSettings-tg9GXaVS.js} +1 -1
  37. package/dist/assets/Recordings-CRp_FkXE.js +1 -0
  38. package/dist/assets/{ScanSubnetEditor-lKcDCgXF.js → ScanSubnetEditor-DN3Ie7Og.js} +1 -1
  39. package/dist/assets/{SceneMonitorEditor-D4HtqSC1.js → SceneMonitorEditor-CINJ-4Mp.js} +1 -1
  40. package/dist/assets/SessionsList-DwHQoi9f.js +2 -0
  41. package/dist/assets/{Showroom-C25UNaak.js → Showroom-DMiHvqBS.js} +1 -1
  42. package/dist/assets/StorageLocationsTable-Cd_oXHgn.js +1 -0
  43. package/dist/assets/{System-DXfDAESB.js → System-C4UGj5Nu.js} +1 -1
  44. package/dist/assets/{Templates-C-6WUOdi.js → Templates-mjnjZIoX.js} +1 -1
  45. package/dist/assets/{Terminal-DNZoAT74.js → Terminal-BRS-F-xZ.js} +3 -5
  46. package/dist/assets/{TrainingProviders-CRP4iTuX.js → TrainingProviders-Sy1iY23E.js} +1 -1
  47. package/dist/assets/{Viewer-CVu0k37l.js → Viewer-D8XgtpH4.js} +1 -1
  48. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-PiMYY04-.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Dx3SvE4V.js} +1 -1
  49. package/dist/assets/{addon-icons-context-DzG39awM.js → addon-icons-context-DihpM3HF.js} +1 -1
  50. package/dist/assets/{ai-page.helpers-tWf2BKhe.js → ai-page.helpers-BrgCvprD.js} +1 -1
  51. package/dist/assets/{archive-7oqv5c2w.js → archive-B2eCCknS.js} +1 -1
  52. package/dist/assets/{assignment-candidates-B8uBn9td.js → assignment-candidates-C6YdocP-.js} +1 -1
  53. package/dist/assets/{authed-media-BsEr81QN.js → authed-media-C1aRt5ci.js} +1 -1
  54. package/dist/assets/{bell-off-CGgJclc7.js → bell-off-CHS3Aly3.js} +1 -1
  55. package/dist/assets/{board-model-UxhF05M4.js → board-model-C14bsdrK.js} +1 -1
  56. package/dist/assets/{boxes-B_Y4V3Ek.js → boxes-DftcHvx4.js} +1 -1
  57. package/dist/assets/{calendar-clock-B0-YSjGo.js → calendar-clock-DHLZaiyj.js} +1 -1
  58. package/dist/assets/circle-slash-C5yZWtgS.js +1 -0
  59. package/dist/assets/client-DTyBaAoV.js +809 -0
  60. package/dist/assets/{create-composition-DhUup0uF.js → create-composition-gstr8g_x.js} +2 -2
  61. package/dist/assets/crop-CvVxDKo4.js +1 -0
  62. package/dist/assets/{database-zap-BC8v5Gc5.js → database-zap-B8fphlJj.js} +1 -1
  63. package/dist/assets/{device-integration-icon-Cvjh6ihp.js → device-integration-icon-Cap0VdNl.js} +1 -1
  64. package/dist/assets/device-picker-model-DgL25n41.js +1 -0
  65. package/dist/assets/dist-B57q2s8O.js +809 -0
  66. package/dist/assets/{dist-BZOmaLJ2.js → dist-CIX_FLwE.js} +1 -1
  67. package/dist/assets/{eraser-BN9Jm7v9.js → eraser-DnVOOBJ7.js} +1 -1
  68. package/dist/assets/{file-up-D3z4d_SX.js → file-up-CS3QVGu0.js} +1 -1
  69. package/dist/assets/{format-kc3FiPSl.js → format-Ch0AKvVb.js} +1 -1
  70. package/dist/assets/{grip-vertical-CVi57Mnf.js → grip-vertical-Dx0Aqv-v.js} +1 -1
  71. package/dist/assets/{hard-drive-download-XJqU5Yhh.js → hard-drive-download-BL7h_atC.js} +1 -1
  72. package/dist/assets/{hostInit-D412Cho_.js → hostInit-BpnP417g.js} +1 -1
  73. package/dist/assets/i18n-BETemoOB.js +1 -0
  74. package/dist/assets/{icons-DZNWg00W.js → icons-C5yBX8zj.js} +1 -1
  75. package/dist/assets/index-Cr7bUFvd.js +4 -0
  76. package/dist/assets/{key-CXhExtg1.js → key-KMleps0f.js} +1 -1
  77. package/dist/assets/{key-square-OYFlMu43.js → key-square-CknpM0L_.js} +1 -1
  78. package/dist/assets/{layers-B8emxX0I.js → layers-CA0xrUXV.js} +1 -1
  79. package/dist/assets/{link-2-off-C4UZJh-L.js → link-2-off-I79TL553.js} +1 -1
  80. package/dist/assets/{linked-devices-model-DIyr-r0R.js → linked-devices-model-Di0tfcU-.js} +1 -1
  81. package/dist/assets/{list-ordered-COE9JhoK.js → list-ordered-H5cpKqfQ.js} +1 -1
  82. package/dist/assets/{memory-stick-DxMJDVF9.js → memory-stick-BYu3Pl2-.js} +1 -1
  83. package/dist/assets/{message-square-plus-mfEtoXqX.js → message-square-plus-C-VzE-nz.js} +1 -1
  84. package/dist/assets/{mf-entry-bootstrap-0-4af06987.js → mf-entry-bootstrap-0-09df2f33.js} +2 -2
  85. package/dist/assets/{mic-off-chy45-le.js → mic-off-BB0y3SKK.js} +1 -1
  86. package/dist/assets/{monitor-off-CYZktw89.js → monitor-off-CeTiFn5M.js} +1 -1
  87. package/dist/assets/{monitor-smartphone-Cla2sWWl.js → monitor-smartphone-DiwqWkLr.js} +1 -1
  88. package/dist/assets/mount-DgL25n41.js +1 -0
  89. package/dist/assets/{notification-rule-status-CX6NUm4f.js → notification-rule-status-BaNEQqyB.js} +1 -1
  90. package/dist/assets/{player-overlays-Dikds8gI.js → player-overlays-BDeIsXux.js} +1 -1
  91. package/dist/assets/remoteEntry-C_e5pzbe.js +1 -0
  92. package/dist/assets/{ruler-Bc_pxTOp.js → ruler-Cuy2zovK.js} +1 -1
  93. package/dist/assets/{scan-eye-BUPnUTKr.js → scan-eye-BuWxqByv.js} +1 -1
  94. package/dist/assets/{scissors-DdbRlSDX.js → scissors-BJTb03-b.js} +1 -1
  95. package/dist/assets/{search-x-eS925uQD.js → search-x-D8VnLXBR.js} +1 -1
  96. package/dist/assets/{send-BHWiY78y.js → send-B00RXUVi.js} +1 -1
  97. package/dist/assets/{settings-2-CyRa-bUA.js → settings-2-C90cMzQT.js} +1 -1
  98. package/dist/assets/{shapes-C9UDTqdB.js → shapes-CBF9943U.js} +1 -1
  99. package/dist/assets/{sigma-D5JGGdP2.js → sigma-CJJT2Cam.js} +1 -1
  100. package/dist/assets/{speaker-Cl3Koi46.js → speaker-B5S7k0DT.js} +1 -1
  101. package/dist/assets/src-Da4HIMZv.js +100 -0
  102. package/dist/assets/{sso-popup-BaK-NY5x.js → sso-popup-DF07jkOe.js} +1 -1
  103. package/dist/assets/{step-inspector-model-BDAJBL2T.js → step-inspector-model-Czc1qNL0.js} +1 -1
  104. package/dist/assets/{table-2-BV86FpaK.js → table-2-l7PUi3h6.js} +1 -1
  105. package/dist/assets/{timer-reset-CQFbOsih.js → timer-reset-DqOUz58T.js} +1 -1
  106. package/dist/assets/{unlink-CO3ZHU5X.js → unlink-Bj6T0cfp.js} +1 -1
  107. package/dist/assets/{usb-Ib0Kj-IW.js → usb-7d2iIO7E.js} +1 -1
  108. package/dist/assets/{use-device-bound-caps-WSOdDrrB.js → use-device-bound-caps-Davivnb7.js} +1 -1
  109. package/dist/assets/{use-scenes-feed-BydEv6TD.js → use-scenes-feed-DpaATilO.js} +1 -1
  110. package/dist/assets/{use-stationary-objects-CcgUGmNJ.js → use-stationary-objects-Cu-P84Mj.js} +1 -1
  111. package/dist/assets/{useAdminDeviceRemoval-BdSgd4AO.js → useAdminDeviceRemoval-COqvh6I9.js} +1 -1
  112. package/dist/assets/useEventInvalidation-DgL25n41.js +1 -0
  113. package/dist/assets/{useNodeUrlSelection-mzzzEn3T.js → useNodeUrlSelection-DSNzRVoI.js} +1 -1
  114. package/dist/assets/user-round-BvKrqouP.js +1 -0
  115. package/dist/assets/{user-x-CUrAwpls.js → user-x-CK_55Ufn.js} +1 -1
  116. package/dist/assets/{variable-COKKMJbR.js → variable-qhs89ABT.js} +1 -1
  117. package/dist/assets/{video-BSNDvfCe.js → video-BMbZ77OA.js} +1 -1
  118. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-De1PJyhy.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-tmFYPP3M.js} +2 -2
  119. package/dist/index.html +10 -10
  120. package/dist/server/addon.js +3 -72
  121. package/package.json +2 -2
  122. package/dist/assets/Addons-cMrauTBc.js +0 -5
  123. package/dist/assets/History-BQYmqLbi.js +0 -1
  124. package/dist/assets/Identity-DZe6EnfF.js +0 -1
  125. package/dist/assets/InstancesTable-tMHEIn4o.js +0 -1
  126. package/dist/assets/IntegrationDetail-DbyHZmhw.js +0 -1
  127. package/dist/assets/MyAccess-nVzeQLPF.js +0 -2
  128. package/dist/assets/Recordings-k9xWpSTi.js +0 -1
  129. package/dist/assets/SessionsList-CxJU6jkU.js +0 -2
  130. package/dist/assets/StorageLocationsTable-BeMq-Y4a.js +0 -1
  131. package/dist/assets/circle-slash-CeIIQW23.js +0 -1
  132. package/dist/assets/client-C3Nr53Gn.js +0 -809
  133. package/dist/assets/crop-BCtCO5Qk.js +0 -1
  134. package/dist/assets/device-picker-model-TeZnNAB7.js +0 -1
  135. package/dist/assets/dist-Du8dfILw.js +0 -809
  136. package/dist/assets/i18n-ChjX2Pvm.js +0 -1
  137. package/dist/assets/index-Bec3SQjl.js +0 -4
  138. package/dist/assets/mount-TeZnNAB7.js +0 -1
  139. package/dist/assets/remoteEntry-4sXHM_Xw.js +0 -1
  140. package/dist/assets/src-VAvW-zoJ.js +0 -100
  141. package/dist/assets/useEventInvalidation-TeZnNAB7.js +0 -1
  142. package/dist/assets/user-round-C9-NR3Al.js +0 -1
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o 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-CEyXHAdg.js";import{$r as f,Fn as p,Ii as m,Kt as h,Li as g,Oi as _,Pi as v,Rn as y,Sa as b,Si as x,Sn as S,Tn as C,Ut as w,Wn as T,ai as E,da as D,ei as O,ht as k,jn as A,wt as j,xr as M}from"./player-overlays-Dikds8gI.js";import{fo as N,ts as P}from"./client-C3Nr53Gn.js";import{t as F}from"./search-x-eS925uQD.js";import{$s as I,Br as L,Co as R,Do as ee,Eo as z,Er as B,Fo as V,Fr as H,Gs as U,Io as W,Ir as te,Jr as G,Ka as K,Ko as ne,Kt as re,Mo as ie,Nf as ae,Pr as q,Qs as J,Ro as oe,Rr as Y,So as se,To as ce,Ut as le,Vn as ue,Vo as de,Wt as fe,Xs as pe,Yo as me,Ys as he,Zs as ge,_n as _e,df as ve,er as X,i as ye,ir as be,jn as xe,jo as Se,kf as Ce,ko as we,lr as Te,nr as Ee,ns as Z,pa as De,qa as Oe,qi as ke,r as Ae,rr as je,rs as Me,tr as Ne,ur as Pe,vi as Q,wo as Fe,xi as Ie,xs as Le,zr as Re}from"./src-VAvW-zoJ.js";import{t as $}from"./useTranslation-BJr-n0es.js";import{n as ze}from"./addon-icons-context-DzG39awM.js";import{Fr as Be,Nr as Ve,Pr as He,W as Ue,X as We,_ as Ge,at as Ke,ct as qe,kr as Je,v as Ye,y as Xe}from"./index-Bec3SQjl.js";import{t as Ze}from"./useAdminDeviceRemoval-BdSgd4AO.js";import{t as Qe}from"./device-integration-icon-Cvjh6ihp.js";import{n as $e,o as et,t as tt}from"./ScanSubnetEditor-lKcDCgXF.js";import{t as nt}from"./NodeAddonsSettingsPanel-B8UxjFBZ.js";c();function rt(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...rt(n.fields));return t}function it(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...rt(n.fields));return t},[e]),d=u.length>0&&i!==void 0,f=r(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:r(async()=>{if(!i)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await i(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),s(`idle`)},[i,u,t]),clearProbeResult:f}}c();function at(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...at(n.fields));return t}function ot(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function st(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){st(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function ct(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function lt(e,t){let n=Z({addonId:e,integrationId:t}),r=n.data?.deviceType??null,i=de({addonId:e,integrationId:t,type:r??N.Camera},{enabled:n.isSuccess&&r!==null});return n.isError?`unavailable`:n.isLoading?`loading`:r===null||i.isError?`unavailable`:i.isLoading||!i.isSuccess?`loading`:((i.data??null)?.sections??[]).some(e=>e.fields.length>0)?`available`:`unavailable`}function ut({integrationId:t,addonId:s,onClose:c}){let{t:u}=$(),f=l(),[p,h]=o({}),[g,_]=o(!1),[v,y]=o(null),[b,x]=o(ct),S=Z({addonId:s,integrationId:t},{enabled:!0}),T=S.data?.deviceType??null,E=de({addonId:s,integrationId:t,type:T??N.Camera},{enabled:S.isSuccess&&T!==null}),D=E.data??null;a(()=>{h(D?st(D.sections.flatMap(e=>e.fields)):{}),x(ct()),_(!1),y(null)},[!0,t,D]);let O=n(()=>({...p,_probeRequestId:b}),[p,b]),k=Se({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),A=Le(),P=r(async(e,t)=>{_(!0);let n=await A.mutateAsync({addonId:s,type:T??N.Camera,key:e,value:t,formValues:O});return n.status===`ok`&&n.suggestedValues&&h(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))ot(e[i])&&!ot(a)&&(r[i]=a,t=!0);return t?r:e}),n},[A,s,O,T]),{testAllStatus:F,hasProbeFields:I,probeResults:L,handleTestAll:R,clearProbeResult:ee}=it(D??{sections:[]},p,P);async function z(e){y(null);try{await k.mutateAsync({addonId:s,type:T??N.Camera,config:p,integrationId:t}),e?h(D?st(D.sections.flatMap(e=>e.fields)):{}):c()}catch(e){y(e instanceof Error?e.message:String(e))}}let B=at((D?.sections??[]).flatMap(e=>e.fields)).filter(e=>ot(p[e])),V=B.length===0,U=S.isLoading||T!==null&&E.isLoading,W=S.isError||S.isSuccess&&T===null||E.isError||E.isSuccess&&D===null;return e(d,{children:[i(H,{className:`space-y-3`,children:U?i(`div`,{className:`flex items-center justify-center py-8`,children:i(M,{className:`h-5 w-5 animate-spin text-primary`})}):W?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[i(w,{className:`h-4 w-4 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:u(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(Je,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:s},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(qe,{schema:D,values:p,onChange:h,onTestField:P,probeResults:L,onClearProbe:ee})}),!W&&!U&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(Q,{variant:`unstyled`,type:`button`,onClick:()=>_(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(C,{className:`h-3.5 w-3.5`}),u(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:b.slice(0,14)})]}),i(m,{className:`h-3.5 w-3.5 transition-transform ${g?`rotate-180`:``}`})]}),g&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(_e,{addonId:s,requestId:b,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!W&&!U&&(v||B.length>0)&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(w,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:v||u(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:B.join(`, `)})})]})}),e(Y,{className:`justify-between`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(Q,{variant:`unstyled`,onClick:c,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:u(`integrations.cancel`)}),!W&&I&&e(Q,{variant:`unstyled`,type:`button`,onClick:R,disabled:F===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[F===`testing`?i(M,{className:`h-3.5 w-3.5 animate-spin`}):i(j,{className:`h-3.5 w-3.5`}),u(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(Q,{variant:`unstyled`,onClick:()=>z(!0),disabled:W||!V||k.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:u(`integrations.saveAndNew`)}),i(Q,{variant:`unstyled`,onClick:()=>z(!1),disabled:W||!V||k.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:k.isPending?u(`integrations.saving`):u(`integrations.save`)})]})]})]})}var dt=1500;function ft({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=$(),s=R(),c=(z({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?dt:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,d=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let f=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&f.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&f.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&f.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let p=f.join(` · `);return e(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[l?i(M,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(w,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(x,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(_,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:p}),l&&i(Q,{variant:`unstyled`,onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),c.results.filter(e=>e.outcome===`failed`).slice(0,5).map(t=>e(`p`,{className:`text-[11px] text-destructive`,children:[t.childNativeId,`: `,t.error]},t.childNativeId))]})}function pt(e){let t=e.map(e=>({...e,stableId:e.childNativeId})),n=new Map(e.map(e=>[e.childNativeId,e])),r=(e,t,i)=>e.flatMap(e=>{let a=n.get(e.candidate.childNativeId);return a===void 0?[]:[{candidate:a,depth:t,...i===void 0?{}:{parentName:i}},...r(e.children,t+1,a.name)]});return r(et(t),0)}function mt(e){let t=e.metadata?.model,n=e.childNativeId.split(`:`).pop()??``;return[typeof t==`string`?t:``,n].filter(e=>e.length>0).join(` · `)}function ht(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}c();var gt=`devices`;function _t(e){return{id:gt,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var vt=2e4,yt=100;function bt({addonId:s,integrationId:c,onClose:u}){let f=b(),{t:p}=$(),m=l(),[h,_]=o(new Set),[v,y]=o(new Set),[x,S]=o(new Map),[C,T]=o(null),{data:E}=ge(),D=(E??[]).find(e=>e.addonId===s)?.supportsLocationImport??!1,[O,k]=o(!0),j=Fe({addonId:s,integrationId:c}).data?.filters,N=j&&j.length>0?j:[_t(p)],[P,F]=o(N.find(e=>e.isDefault)?.id??(N.some(e=>e.id===gt)?gt:N[0].id)),I=P!==gt,L=ee(),R=ce({addonId:s,integrationId:c,page:1,pageSize:vt,filter:P}),z=R.refetch,B=L.mutate,V=r(()=>{B({addonId:s,integrationId:c},{onSettled:()=>{z()}})},[B,s,c,z]),H=t(null);a(()=>{let e=`${s}::${c}`;H.current===e||R.isLoading||(H.current=e,(R.data?.candidates.length??0)===0&&V())},[s,c,R.isLoading,R.data,V]);let U=L.isPending,W=L.isError?L.error instanceof Error?L.error.message:String(L.error):null,te=typeof L.data?.lastError==`string`&&L.data.lastError.length>0?L.data.lastError:null,G=R.data?.candidates??[],K=n(()=>pt(G),[G]),ne=n(()=>new Map(K.map(e=>[e.candidate.childNativeId,e.depth])),[K]),re=n(()=>new Map(K.map(e=>[e.candidate.childNativeId,e.parentName])),[K]),ie=R.isError?R.error instanceof Error?R.error.message:String(R.error):null,q=we(),[J,oe]=o(null),se=r(e=>{e.alreadyAdopted||_(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),ue=r(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),de=r((e,t)=>{S(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),fe=r(e=>{let t={};for(let n of e){let e=x.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[x]),pe=r(async()=>{T(null);let e=[...h];if(e.length!==0)try{let t=fe(e),{jobId:n}=await q.mutateAsync({addonId:s,integrationId:c,filter:P,childNativeIds:e,...t?{perCandidate:t}:{},...D?{importLocations:O}:{}});oe(n),_(new Set),S(new Map)}catch(e){T(e instanceof Error?e.message:String(e))}},[h,fe,q,s,c,P,D,O]),me=t(null),he=r(()=>{J===null||me.current===J||(me.current=J,z(),m.invalidateQueries({queryKey:[[`integrations`]]}),m.invalidateQueries({queryKey:[[`deviceManager`]]}))},[J,z,m]),_e=r(e=>{F(e),_(new Set),y(new Set),S(new Map),T(null)},[]),ve=h.size,X=J!==null&&ve===0&&!q.isPending;return e(d,{children:[D&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(Te,{checked:O,onChange:e=>k(e.target.checked),className:`accent-primary`}),p(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),e(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2 overflow-hidden`,children:[(W??ie??te)&&G.length===0&&i(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(w,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:p(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-danger/90 mt-0.5`,children:W??ie??te})]})]})}),N.length>1&&i(xt,{filters:N,activeFilter:P,onSelect:_e}),i(`div`,{className:`flex-1 min-h-0`,children:i(le,{mode:`generic`,items:K.map(e=>e.candidate),pageSize:yt,getKey:e=>e.childNativeId,getSearchText:ht,getFilterType:e=>e.type,filterOptions:Ce(f),filterLabel:p(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:R.isLoading||U&&G.length===0,searchPlaceholder:p(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(W??ie??te)&&G.length===0?``:p(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(Q,{variant:`unstyled`,type:`button`,onClick:V,disabled:U,title:p(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(A,{className:`h-3.5 w-3.5 ${U?`animate-spin`:``}`}),p(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:p(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-full sm:w-[55%]`,cellClassName:`max-w-0`,cell:e=>i(St,{candidate:e,depth:ne.get(e.childNativeId)??0,...re.get(e.childNativeId)===void 0?{}:{containerName:re.get(e.childNativeId)},expandable:!I,expanded:v.has(e.childNativeId),onToggleExpand:()=>ue(e.childNativeId),adoptedLabel:p(`integrations.adoptAlready`,{defaultValue:`Adopted`}),typeLabel:ae(e.type,f).label})},{key:`type`,header:p(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=ae(t.type,f),r=n.icon;return e(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),n.label]})}},{key:`select`,header:``,headerClassName:`w-10 sm:w-[15%] text-right`,cellClassName:`text-right`,cell:e=>i(`div`,{className:`flex items-center justify-end`,children:i(Q,{variant:`unstyled`,onClick:()=>se(e),disabled:e.alreadyAdopted,"aria-label":h.has(e.childNativeId)?p(`integrations.adoptDevicesModal.deselect`,`Deselect`):p(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${h.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:h.has(e.childNativeId)&&i(g,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!I&&v.has(e.childNativeId),renderExpanded:I?void 0:e=>i(Ct,{candidate:e,hiddenChildIds:x.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>de(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:h.has(e.childNativeId)?`bg-primary/5`:``})})]}),C&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(w,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:C})]})}),J!==null&&i(ft,{addonId:s,integrationId:c,jobId:J,onFinished:he}),e(Y,{children:[i(Q,{variant:`outline`,size:`sm`,onClick:u,children:p(`integrations.cancel`,{defaultValue:`Cancel`})}),e(Q,{variant:`primary`,size:`sm`,onClick:X?u:pe,disabled:!X&&(ve===0||q.isPending),children:[q.isPending&&i(M,{className:`h-3.5 w-3.5 animate-spin`}),X?p(`integrations.close`,{defaultValue:`Close`}):p(`integrations.addSelected`,{defaultValue:`Add selected`}),!X&&ve>0?` (${ve})`:``]})]})]})}function xt({filters:e,activeFilter:t,onSelect:n}){let{t:r}=$();return i(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return i(Q,{variant:`unstyled`,type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function St({candidate:t,depth:n,containerName:r,expandable:a,expanded:o,onToggleExpand:s,adoptedLabel:c,typeLabel:l}){let{t:u}=$(),d=(t.children??[]).length,f=mt(t);return e(`div`,{className:`flex items-center gap-2.5 min-w-0 ${n>0?`pl-5`:``}`,children:[a&&d>0?e(Q,{variant:`unstyled`,type:`button`,onClick:s,"aria-label":o?u(`integrations.adoptDevicesModal.collapse`,`Collapse`):u(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":o,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[i(o?m:v,{className:`h-3.5 w-3.5`}),d]}):a?i(`span`,{className:`h-5 w-5 flex-shrink-0`,"aria-hidden":`true`}):null,e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`truncate text-xs font-medium text-foreground`,"data-testid":`candidate-name`,children:t.name}),f.length>0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-subtitle`,children:f}),r!==void 0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-container`,children:u(`integrations.adoptDevicesModal.inContainer`,`in {{name}}`,{name:r})}),i(`div`,{className:`truncate text-[10px] text-foreground-subtle sm:hidden`,children:l})]}),t.alreadyAdopted&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:c})]})}function Ct({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=$(),o=t.children??[];return o.length===0?null:i(`div`,{className:`space-y-1 py-1`,children:o.map(t=>{let o=n.has(t.childNativeId),s=t.capabilities??[];return e(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${o?`opacity-50`:``}`,children:[i(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:t.name}),s.length>0&&i(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:s.join(`, `)}),i(Q,{variant:`unstyled`,onClick:()=>r(t.childNativeId),"aria-label":o?a(`integrations.adoptDevicesModal.showChild`,`Show child`):a(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:o?a(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):a(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:i(o?O:f,{className:`h-3 w-3`})})]},t.childNativeId)})})}function wt(e){let t=e.host;return typeof t==`string`&&t.length>0?t.toLowerCase():null}function Tt(e){return e===null?[]:[`host:${e}`]}function Et(e){let t=[],n=new Map,r=(e,r)=>{let i=e.map(e=>n.get(e)).find(e=>e!==void 0),a=i??r();i===void 0&&t.push(a);for(let t of e)a.ids.add(t),n.set(t,a);return a},i=(e,t)=>{e.sources.includes(t)||e.sources.push(t)};for(let t of e.adoption){let e=r([t.childNativeId],()=>({key:t.childNativeId,ids:new Set,name:t.name,address:null,sources:[],hit:null,adoptionId:t.childNativeId,proposalId:null,alreadyAdded:!1,addedName:null,needsParams:[],parentId:t.parentStableId??null}));i(e,`adoption`),e.adoptionId=t.childNativeId,t.alreadyAdopted===!0&&(e.alreadyAdded=!0)}let a=(t,n,a)=>{let o=wt(t.prefilledConfig),s=r([t.stableId,...Tt(o)],()=>({key:t.stableId,ids:new Set,name:t.suggestedName,address:o,sources:[],hit:null,adoptionId:null,proposalId:null,alreadyAdded:!1,addedName:null,needsParams:[],parentId:null}));i(s,n),(s.hit===null||n===`scan`)&&(s.hit=t),s.name=t.suggestedName,s.address=o??s.address,a!==null&&(s.proposalId=a),s.parentId=t.parentStableId??s.parentId,s.needsParams=t.needsParams??s.needsParams,(t.alreadyOnboarded===!0||t.onboardedDeviceId!==void 0||e.existingStableIds.has(t.stableId))&&(s.alreadyAdded=!0,s.addedName=t.onboardedName??s.addedName)};for(let t of e.scan)a(t,`scan`,null);for(let t of e.proposals)a(t.candidate,`proposal`,t.id);for(let n of t)[...n.ids].some(t=>e.existingStableIds.has(t))&&(n.alreadyAdded=!0);return t.map(e=>{let t=e.parentId===null?void 0:n.get(e.parentId);return{key:e.key,name:e.name,address:e.address,sources:e.sources,hit:e.hit,adoptionId:e.adoptionId,proposalId:e.proposalId,alreadyAdded:e.alreadyAdded,addedName:e.addedName,needsParams:e.needsParams,parentKey:t!==void 0&&t!==e?t.key:null}})}c();var Dt=500;function Ot(e){return e instanceof Error?e.message:String(e)}function kt(e,t){let n={};for(let t of e?.sections??[])for(let e of t.fields)`key`in e&&e.key&&`default`in e&&e.default!==void 0&&(n[e.key]=e.default);return{...n,...t}}function At({addonId:t,integrationId:a,onClose:s,onSetupIntegration:c,alongsideAdoption:u=!1}){let{t:f}=$(),p=l(),m=Me({addonId:t}).data??null,[h,g]=o({}),_=V(),v=me({}),b=ce({addonId:t,integrationId:a,page:1,pageSize:Dt},{retry:!1}),{data:x}=ne({projection:`slim`}),S=se(),C=we(),[w,T]=o(new Set),[E,D]=o(new Set),[O,k]=o(null),[A,j]=o(null),N=n(()=>{let e=(b.data?.candidates??[]).map(e=>({childNativeId:e.childNativeId,name:e.name,alreadyAdopted:e.alreadyAdopted,parentStableId:e.parentStableId})),n=(v.data?.proposals??[]).filter(e=>e.addonId===t).map(e=>({id:e.id,candidate:e.candidate}));return Et({adoption:e,scan:_.data?.candidates??[],proposals:n,existingStableIds:new Set((x??[]).map(e=>e.stableId))})},[b.data,v.data,_.data,x,t]),P=e=>e.hit!==null&&(e.needsParams.length>0||e.hit.setupIntegration===!0),F=n(()=>u?N.filter(e=>!e.sources.includes(`adoption`)||P(e)):N,[N,u]),I=u?N.filter(e=>e.sources.includes(`adoption`)&&e.hit!==null&&!F.includes(e)).length:0,L=r(e=>{let t=new Map(F.map(e=>[e.key,e])),n=0,r=e;for(;r?.parentKey!=null&&n<8&&(r=t.get(r.parentKey),r!==void 0);)n+=1;return n},[F]),R=r(()=>{k(null),_.mutate({addonId:t,params:h})},[_,t,h]),ee=r(async(e,t)=>{T(t=>new Set(t).add(e)),k(null);try{await t(),D(t=>new Set(t).add(e)),p.invalidateQueries({queryKey:[[`deviceManager`]]}),p.invalidateQueries({queryKey:[[`integrations`]]})}catch(e){k(Ot(e))}finally{T(t=>{let n=new Set(t);return n.delete(e),n})}},[p]),z=r(async(e,n)=>{let r=e.hit;if(r!==null){let i=$e(t,r);if(i!==null){c?.(i),s();return}await ee(e.key,async()=>{await S.mutateAsync({addonId:t,integrationId:a,candidate:{...r,prefilledConfig:{...r.prefilledConfig,...n}}}),j(null)});return}if(e.adoptionId!==null){let n=e.adoptionId;await ee(e.key,async()=>{await C.mutateAsync({addonId:t,integrationId:a,childNativeIds:[n]})})}},[S,C,t,a,s,c,ee]),B=r(e=>{if(e.needsParams.length>0&&e.hit!==null){k(null),j(e);return}z(e)},[z]);if(A!==null&&A.hit!==null)return i(Nt,{addonId:t,integrationId:a,row:A,found:A.hit.prefilledConfig,busy:w.has(A.key),error:O,embedded:u,onBack:()=>j(null),onSubmit:e=>void z(A,e)});let U=F.length===0,W=e(d,{children:[i(tt,{}),m&&i(qe,{schema:m,values:h,onChange:g}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e(`p`,{className:`text-xs text-foreground-subtle`,children:[_.isPending?f(`integrations.addDeviceModal.scanning`,`Scanning the local network…`):F.length>0?f(`integrations.addDeviceModal.found`,{defaultValue_one:`{{count}} device found`,defaultValue_other:`{{count}} devices found`,count:F.length}):``,!_.isPending&&I>0?` · ${f(`integrations.addDeviceModal.alsoAdopted`,{defaultValue_one:`{{count}} also in the adoption list`,defaultValue_other:`{{count}} also in the adoption list`,count:I})}`:``]}),e(Q,{variant:`outline`,size:`sm`,onClick:R,disabled:_.isPending,children:[_.isPending?i(M,{className:`h-3.5 w-3.5 animate-spin`}):i(y,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceModal.scanNow`,`Scan now`)]})]}),_.isError&&i(jt,{text:f(`integrations.addDeviceModal.scanFailed`,`The scan failed. Try again.`)}),O!==null&&i(jt,{text:O}),U&&!_.isPending&&i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:_.data?f(`integrations.addDeviceModal.nothingFound`,`No devices responded to the scan.`):f(`integrations.addDeviceModal.scanHint`,`Scan the network to find devices to add.`)}),i(`div`,{className:u?`max-h-48 space-y-1.5 overflow-y-auto`:`space-y-1.5`,"data-testid":`network-candidates`,children:F.map(e=>i(Mt,{row:e,depth:L(e),busy:w.has(e.key),added:E.has(e.key),onPick:B},e.key))})]});return u?i(`div`,{className:`shrink-0 space-y-3 border-b border-border pb-3`,children:W}):e(d,{children:[i(H,{className:`space-y-3`,children:W}),i(Y,{children:i(Q,{variant:`outline`,size:`sm`,onClick:s,children:f(`integrations.close`,`Close`)})})]})}function jt({text:t}){return e(`div`,{className:`flex items-start gap-2 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2`,children:[i(w,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-danger`}),i(`p`,{className:`text-xs text-danger`,children:t})]})}function Mt({row:t,depth:n,busy:r,added:a,onPick:o}){let{t:s}=$(),c=t.alreadyAdded||a,l=t.hit!==null&&$e(``,t.hit)!==null,u=t.hit?.selectable!==!1,d=t.needsParams.length>0;return e(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2 ${n>0?`ml-4`:``}`,"data-testid":`network-row-${t.key}`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.name}),t.address!==null&&i(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:t.address}),c&&t.addedName!==null&&i(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addedName})]}),c?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[i(g,{className:`h-3.5 w-3.5`}),t.alreadyAdded?s(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):s(`integrations.scanNetworkModal.added`,`Added`)]}):u?e(Q,{size:`sm`,variant:l||d?`outline`:`primary`,onClick:()=>o(t),disabled:r,children:[r?i(M,{className:`h-3.5 w-3.5 animate-spin`}):l||d?null:i(E,{className:`h-3.5 w-3.5`}),l?s(`integrations.scanNetworkModal.setUp`,`Set up`):d?s(`integrations.addDeviceModal.enterDetails`,`Enter details`):s(`common.add`,`Add`)]}):null]})}function Nt({addonId:t,integrationId:n,row:r,found:a,busy:s,error:c,onBack:l,onSubmit:u,embedded:f}){let{t:p}=$(),m=Z({addonId:t,integrationId:n}),h=m.data?.deviceType??null,g=de({addonId:t,integrationId:n,type:h??N.Camera},{enabled:m.isSuccess&&h!==null}),_=g.data??null,[v,y]=o(null),b=v??kt(_,a),x=m.error??g.error,S=m.isSuccess&&h===null,C=_!==null,w=C?i(qe,{schema:_,values:b,onChange:y}):x?i(jt,{text:Ot(x)}):S?i(`p`,{className:`text-xs text-foreground-muted`,children:p(`integrations.addDeviceModal.noCreationType`,`This integration cannot create a device from this candidate.`)}):i(M,{className:`mx-auto h-5 w-5 animate-spin text-primary`}),T=e(d,{children:[e(Q,{variant:`ghost`,size:`sm`,onClick:l,children:[i(D,{className:`h-3.5 w-3.5`}),p(`integrations.addDeviceModal.back`,`Back to the list`)]}),i(`p`,{className:`text-xs font-medium text-foreground`,children:r.name}),w,c!==null&&i(jt,{text:c})]}),E=e(d,{children:[i(Q,{variant:`outline`,size:`sm`,onClick:l,children:p(`integrations.cancel`,`Cancel`)}),e(Q,{variant:`primary`,size:`sm`,onClick:()=>u(b),disabled:s||!C,children:[s&&i(M,{className:`h-3.5 w-3.5 animate-spin`}),p(`common.add`,`Add`)]})]});return f?e(`div`,{className:`shrink-0 space-y-3 border-b border-border pb-3`,children:[T,i(`div`,{className:`flex justify-end gap-2`,children:E})]}):e(d,{children:[i(H,{className:`space-y-3`,children:T}),i(Y,{children:E})]})}c();function Pt(e){return e===`manual`?`manual`:e===`pairing`?`pairing`:`network`}function Ft({addonId:t,integrationId:n,kind:r,canScan:a,onClose:s,pairing:c,onSetupIntegration:l}){let{t:u}=$(),f=lt(t,n),p=r===`device-adoption`&&a===null,m=r===`device-adoption`||a===!0,h=f===`available`,[g,_]=o(null),v=g??(c===void 0?m?`network`:`manual`:`pairing`),y=[m,h,c!==void 0].filter(Boolean).length,b=p?i(H,{children:i(M,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):r===`device-adoption`?e(d,{children:[a===!0&&i(At,{addonId:t,integrationId:n,onClose:s,alongsideAdoption:!0,...l?{onSetupIntegration:l}:{}}),i(bt,{addonId:t,integrationId:n,onClose:s})]}):i(At,{addonId:t,integrationId:n,onClose:s,...l?{onSetupIntegration:l}:{}}),x=i(ut,{integrationId:n,addonId:t,onClose:s});return i(q,{open:!0,onOpenChange:e=>{e||s()},children:e(te,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,className:r===`device-adoption`?`md:h-[85vh]`:void 0,children:[i(Re,{children:i(L,{children:u(`integrations.addDevice`,`Add device`)})}),y>1?e(X,{value:v,onValueChange:e=>_(Pt(e)),children:[e(Ee,{children:[m&&i(je,{value:`network`,children:u(`integrations.addDeviceModal.tabNetwork`,`Found on the network`)}),h&&i(je,{value:`manual`,children:u(`integrations.addDeviceModal.tabManual`,`Enter parameters`)}),c!==void 0&&i(je,{value:`pairing`,children:c.label})]}),m&&i(Ne,{value:`network`,children:b}),h&&i(Ne,{value:`manual`,children:x}),c!==void 0&&i(`div`,{role:`tabpanel`,id:`tabpanel-pairing`,hidden:v!==`pairing`,className:`pt-3`,children:c.render({onPaired:()=>_(`network`)})})]}):c!==void 0&&!m&&!h?c.render({onPaired:()=>_(`network`)}):m?b:h?x:f===`loading`?i(H,{children:i(M,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):i(H,{children:i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:u(`integrations.addDeviceModal.nothingToAdd`,`This integration has no way to add a device from here.`)})})]})})}c();var It=`matter`,Lt=[`discovering`,`pase`,`commissioning`,`done`];function Rt(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function zt(e,t){return e===`code-expired`||t?.includes(`matter-commission:code-expired`)?{key:`integrations.addMatter.failure.expired`,defaultValue:`The pairing code expired. Share the device again and paste the new code.`}:e===`device-not-found`||t?.includes(`matter-commission:device-not-found`)?{key:`integrations.addMatter.failure.notFound`,defaultValue:`No Matter device with that code was found on the network.`}:e===`wrong-code`||t?.includes(`matter-commission:wrong-code`)?{key:`integrations.addMatter.failure.wrongCode`,defaultValue:`The pairing code was rejected.`}:e===`invalid-code`||t?.includes(`invalid pairing code`)?{key:`integrations.addMatter.failure.invalid`,defaultValue:`Enter an 11-digit or 21-digit manual code, or a code that starts with MT:.`}:{key:`integrations.addMatter.failure.unknown`,defaultValue:t??`Commissioning failed.`}}function Bt({onClose:t,onCommissioned:n}){let{t:r}=$(),s=ye({kind:It}),[c,l]=o(null),u=Ae(s.data??[],c),f=u.length,p=c??u[0]?.id??null,m=Oe(),[h,g]=o(``),[_,v]=o({phase:`idle`,failure:null,message:null}),y=_.phase===`discovering`||_.phase===`pase`||_.phase===`commissioning`,b=K({brokerId:p??``,key:`commission`},{enabled:p!==null&&y,refetchInterval:y?400:!1});a(()=>{y&&Rt(b.data)&&b.data.phase!==`idle`&&v({phase:b.data.phase,failure:typeof b.data.failure==`string`?b.data.failure:null,message:typeof b.data.message==`string`?b.data.message:null})},[y,b.data]);let x=()=>{p!==null&&(v({phase:`discovering`,failure:null,message:null}),m.mutate({brokerId:p,target:{action:`commissionNode`},payload:{pairingCode:h.trim()}},{onSuccess:()=>v({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;v({phase:`failed`,failure:t.includes(`matter-commission:`)?t.split(`matter-commission:`)[1]?.split(`:`)[0]??`unknown`:t.includes(`invalid pairing code`)?`invalid-code`:`unknown`,message:t})}}))},S=_.phase===`failed`?zt(_.failure,_.message):null,C=S===null?null:r(S.key,{defaultValue:S.defaultValue}),w=(s.isSuccess===!0||s.data!==void 0)&&p===null;return e(d,{children:[e(H,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.addMatter.help`,{defaultValue:`In Home Assistant, open the device and choose Share device. Paste the numeric code or the MT: code here. The device stays in Home Assistant.`})}),(w||f>1)&&!y&&_.phase!==`done`&&e(`div`,{className:`space-y-1.5`,children:[i(Pe,{children:r(`integrations.addMatter.broker`,{defaultValue:`Matter fabric`})}),i(Ue,{kind:It,value:p,onChange:l})]}),!w&&e(`div`,{className:`space-y-1.5`,children:[i(Pe,{htmlFor:`matter-pairing-code`,children:r(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(ve,{id:`matter-pairing-code`,value:h,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:y||_.phase===`done`,onChange:e=>g(e.target.value)})]}),_.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":r(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:Lt.map(t=>{let n=_.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&y?i(M,{className:`mr-1 inline h-3 w-3 animate-spin`}):null,r(`integrations.addMatter.phase.${t}`,{defaultValue:t===`discovering`?`Discovering`:t===`pase`?`PASE`:t===`commissioning`?`Commissioning`:`Done`})]},t)})}),C!==null&&i(G,{message:C})]}),e(Y,{children:[i(Q,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),_.phase===`done`?i(Q,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(Q,{size:`sm`,disabled:y||w||h.trim().length===0,onClick:x,children:y?r(`integrations.addMatter.working`,{defaultValue:`Adding…`}):r(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})}c();function Vt(e){return typeof e!=`object`||!e||!(`sections`in e)?!1:Array.isArray(Reflect.get(e,`sections`))}function Ht(e){if(typeof e!=`object`||!e||!(`formValues`in e))return{};let t=Reflect.get(e,`formValues`);return typeof t!=`object`||!t||Array.isArray(t)?{}:{...t}}function Ut({integrationId:t,addonId:n,name:r,kind:a,mode:o,brokerKind:c,canTest:u=!1,onClose:d}){let{t:f}=$(),p=k(),m=l(),h=s({queryKey:[`integration-instance-form`,n,t],queryFn:()=>p.trpcClient.integrationInstances.instanceFormSchema.query({addonId:n,id:t})}),g=s({queryKey:[`integration-instance`,n,t],queryFn:()=>p.trpcClient.integrationInstances.getInstance.query({addonId:n,id:t})}),_=Ht(g.data),v=Vt(h.data)?h.data:null,y=h.isSuccess&&g.isSuccess;return i(q,{open:!0,onOpenChange:e=>!e&&d(),children:e(te,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(Re,{children:e(L,{children:[f(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,r]})}),i(H,{children:h.isError||g.isError?i(`p`,{className:`text-[11px] text-danger`,children:f(`integrations.loadFailed`,{defaultValue:`Could not load this integration.`})}):y?v===null?i(`p`,{className:`text-[11px] text-foreground-muted`,children:f(`integrations.noInstanceForm`,{defaultValue:`This integration has no configuration form.`})}):i(Wt,{addonId:n,integrationId:t,name:r,schema:v,stored:_,onClose:d,onSaved:()=>{m.invalidateQueries()}}):e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(M,{className:`h-3 w-3 animate-spin`}),f(`integrations.loading`,{defaultValue:`Loading…`})]})})]})})}function Wt({addonId:t,integrationId:n,name:r,schema:a,stored:s,onClose:c,onSaved:l}){let{t:d}=$(),f=k(),[p,m]=o({...s}),h=P(a,{...s}),g=u({mutationFn:async()=>{let e=We(s,p);await f.trpcClient.integrationInstances.updateInstance.mutate({addonId:t,id:n,values:e})},onSuccess:()=>{l(),Ke({title:d(`integrations.saved`,{defaultValue:`Configuration saved`}),message:r,severity:`info`}),c()},onError:e=>{Ke({title:d(`integrations.saveFailed`,{defaultValue:`Could not save the configuration`}),message:`${r}: ${e.message}`,severity:`critical`})}});return e(`div`,{className:`space-y-3`,children:[i(B,{schema:h,values:p,onChange:m}),e(`div`,{className:`flex justify-end gap-2`,children:[i(Q,{size:`sm`,variant:`outline`,type:`button`,onClick:c,children:d(`common.cancel`,{defaultValue:`Cancel`})}),e(Q,{size:`sm`,type:`button`,disabled:g.isPending,onClick:()=>g.mutate(),children:[g.isPending?i(M,{className:`h-3 w-3 animate-spin`}):null,d(`integrations.save`,{defaultValue:`Save`})]})]})]})}function Gt(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}c();function Kt(){let{addonId:e=``}=He();return i(Jt,{addonId:e})}function qt(){return e(`div`,{className:`p-4`,children:[i(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),i(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]})}function Jt({addonId:t}){let{t:c}=$(),u=l(),d=Ve(),[f,m]=Be(),g=k(),[_,v]=o(!1),y=r(e=>{v(!1),d(`/integrations`,{state:{integrationSeed:e}})},[d]),[b,x]=o(!1),[w,E]=o(!1),{data:O}=J(void 0),A=n(()=>(O??[]).filter(e=>e.addonId===t),[O,t]),j=Xe(f.get(`instance`),A)??``,N=r(e=>{m(t=>{let n=new URLSearchParams(t);return n.set(Ge,e),n},{replace:!0})},[m]),P=n(()=>A.map(e=>({value:e.id,label:e.name})),[A]),{data:R,isLoading:ee}=pe({id:j},{enabled:!!j}),{data:z,isSuccess:B}=ge(),V=n(()=>{let e=R?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[z,R?.addonId,B]),{data:G,isPending:K}=W({}),ae=n(()=>K?null:(G?.providers??[]).some(e=>e.addonId===R?.addonId),[K,G,R?.addonId]),Y=V!==null,se=R?.info?.fixed===!0,ce=n(()=>{let e=R?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.brokerKind??null},[z,R?.addonId,B]),de=ce===`matter`,me=Y?c(`integrations.addDevice`,`Add device`):c(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),ve=n(()=>{let e=R?.addonId;return!e||!B?!1:(z??[]).find(t=>t.addonId===e)?.canTest===!0},[z,R?.addonId,B]),X=n(()=>{let e=R?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.mode??null},[z,R?.addonId,B]);a(()=>{f.get(`add`)===`1`&&Y&&(v(!0),m(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[f,Y,m]);let{data:ye}=s({queryKey:[`integration-instance-form`,R?.addonId,R?.id],enabled:!!R?.addonId&&!!R?.id,queryFn:()=>g.trpcClient.integrationInstances.instanceFormSchema.query({addonId:R?.addonId??``,id:R?.id??``})}),Se=ye!=null&&Array.isArray(ye.sections)&&ye.sections.some(e=>e.fields.length>0),{data:Ce}=ke({addonId:R?.addonId??``,nodeId:`hub`},{enabled:!!R?.addonId&&X!==`account`}),we=X!==null&&X!==`account`&&Gt(Ce),Te=n(()=>R?.addonId?[R.addonId]:[],[R?.addonId]),{data:Ee}=ne({projection:`slim`},{refetchInterval:3e4}),Z=[[`integrations`,`get`],{input:{id:j},type:`query`}],Oe={onMutate:async e=>{await u.cancelQueries({queryKey:Z});let t=u.getQueryData(Z);return t!=null&&u.setQueryData(Z,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&u.setQueryData(Z,r.previous)},onSettled:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}},Ae=I(Oe),je=U(Oe),Me={isPending:Ae.isPending||je.isPending,mutate:e=>se?Ae.mutate(e):je.mutate({...e,addonId:R?.addonId})},Ne=he({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]}),d(A.length>1?Ye(t):`/integrations`)}}),Pe=De({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Fe=Ze(),Le=ie({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ze=oe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),He=n(()=>Ee??[],[Ee]),Ue=n(()=>{let e=new Map;for(let t of He)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[He]),We=r(e=>Ue.get(e)??null,[Ue]),Ke=n(()=>fe(O),[O]),qe=r(e=>d(`/devices/${String(e)}`),[d]),Je=n(()=>He.filter(e=>{let t=Ke(e);return t.kind===`resolved`&&t.integration.id===j}),[He,j,Ke]),$e=n(()=>O===void 0?null:re(Je).length,[O,Je])??`…`;if(ee||O===void 0)return i(qt,{});let et=(z??[]).find(e=>e.addonId===t)?.name??R?.name??t;return R?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(ue,{items:[{label:c(`integrationDetail.integrations`,`Integrations`),onClick:()=>d(`/integrations`)},{label:et}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(Yt,{addonId:R.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:et}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[$e,` `,c(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!se&&e(Q,{variant:`unstyled`,onClick:()=>{v(!0)},disabled:!Y,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:me,children:[i(T,{className:`h-3.5 w-3.5`}),me]}),e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Me.isPending?`opacity-60`:``} ${R.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:c(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(be,{checked:R.enabled,onCheckedChange:e=>Me.mutate({id:j,enabled:e}),disabled:Me.isPending,"aria-label":R.enabled?c(`integrationDetail.disableIntegration`,`Disable integration`):c(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${R.enabled?`text-success`:`text-foreground-subtle`}`,children:R.enabled?c(`integrationDetail.enabled`,`Enabled`):c(`integrationDetail.disabled`,`Disabled`)}),Me.isPending&&i(M,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),X!==`standalone`&&(Se||V===`device-adoption`)&&e(Q,{variant:`unstyled`,onClick:()=>x(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[i(S,{className:`h-3 w-3`}),c(`integrations.config`)]}),e(Q,{variant:`unstyled`,onClick:()=>E(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:c(`integrations.logs`,{defaultValue:`View logs`}),children:[i(C,{className:`h-3 w-3`}),c(`integrations.logs`,{defaultValue:`Logs`})]}),i(xe,{label:c(`integrationDetail.restart`,`Restart`),icon:p,title:c(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:R.name}),description:c(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:$e}),confirmLabel:c(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Pe.isPending,action:()=>Pe.mutateAsync({addonId:R.addonId})}),!se&&j&&i(xe,{label:c(`integrations.delete`,{defaultValue:`Delete`}),icon:h,title:c(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:c(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:R.name,count:$e}),confirmLabel:c(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:Ne.isPending,action:()=>Ne.mutateAsync({id:j})})]})]}),A.length>1&&i(`div`,{className:`max-w-sm`,children:i(Ie,{mode:`single`,singleDisplay:`field`,label:c(`integrationDetail.instances`,`Integration`),options:P,value:j,onChange:N,testId:`integration-instance-picker`,optionTestIdPrefix:`integration-instance`})}),we&&i(nt,{nodeId:null,addonIds:Te,level:`global`,surface:`integration`,title:c(`integrations.settings`,{defaultValue:`Settings`})}),i(le,{context:`integration-detail`,devices:He,trpc:g.trpcClient,integrationOf:Ke,forceIntegrationId:j,urlScope:`root`,lsKey:`integration-detail:${R.addonId}`,resolveIntegrationIcon:Qe,resolveParent:We,onNavigate:qe,rowOperation:Fe.rowOperation,batchActions:{remove:Fe.remove,disable:Le.mutate,enable:ze.mutate},...se?{}:{onDeleteDevice:e=>Fe.remove({deviceId:e.id})}}),_&&j&&V!==null&&i(Ft,{addonId:R.addonId,integrationId:j,kind:V,canScan:ae,onSetupIntegration:y,...de?{pairing:{label:c(`integrations.addMatter.tab`,`Pairing code`),render:({onPaired:e})=>i(Bt,{onClose:()=>v(!1),onCommissioned:e})}}:{},onClose:()=>v(!1)}),b&&j&&V!==null&&X!==null&&i(Ut,{integrationId:j,addonId:R.addonId,name:R.name,kind:V,mode:X,brokerKind:ce,canTest:ve,onClose:()=>x(!1)}),w&&i(q,{open:!0,onOpenChange:e=>!e&&E(!1),children:e(te,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(Re,{className:`mb-0`,children:e(L,{className:`flex items-center gap-2 min-w-0`,children:[i(C,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:R.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[R.addonId,j?` · ${j}`:``]})]})}),i(H,{className:`min-h-0 overflow-hidden p-0`,children:i(_e,{addonId:R.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(F,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:c(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:c(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:t})})]}),e(Q,{variant:`unstyled`,onClick:()=>d(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[i(D,{className:`h-3 w-3`}),c(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function Yt({addonId:e}){let t=ze(e),[n,r]=o(!1);return!t||n?null:i(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>r(!0)})}export{Kt as IntegrationDetailPage};
@@ -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{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et 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-CEyXHAdg.js";import{$r as f,Ai as p,Kt as m,Q as h,Sa as g,Ut as _,Xn as v,ct as y,fi as b,ht as x,ki as S,kr as C,oa as w,un as T,ut as E,vr as D,wr as O,xr as k,yn as A}from"./player-overlays-Dikds8gI.js";import{Qr as j,Zr as M}from"./client-C3Nr53Gn.js";import{c as N,f as ee}from"./video-BSNDvfCe.js";import{t as te}from"./monitor-smartphone-Cla2sWWl.js";import{t as ne}from"./unlink-CO3ZHU5X.js";import{An as re,Mr as ie,Nr as ae,_c as P,df as F,hc as oe,pi as se,vi as I,zf as L,zt as ce}from"./src-VAvW-zoJ.js";import{t as le}from"./i18n-ChjX2Pvm.js";import{t as R}from"./useTranslation-BJr-n0es.js";import"./mount-TeZnNAB7.js";import{c as ue,i as de,l as z,s as B}from"./sso-popup-BaK-NY5x.js";import{Fr as V,P as H,jr as U,kr as W,n as G}from"./index-Bec3SQjl.js";import{t as fe}from"./AdminSectionedPage-Di2VI8A1.js";import{t as pe}from"./AdminPage-B9sdR6yD.js";import{D as me,O as he,_ as ge,a as _e,h as ve,r as ye,t as K,w as be}from"./SessionsList-CxJU6jkU.js";l();var xe=`${M}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function Se(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 j(e)}function Ce(e){return e.startsWith(`https://`)}function we(e){let t=e.flatMap(e=>{let t=Se(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:Ce(r),plausible:e.plausible}]))}function Te(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 Ee(e){let t=new URL(xe);return t.searchParams.set(`hub`,e),t.toString()}var De=176,Y={scheme:`https`};function Oe(){let{t:e}=R(),t=P(Y),r=oe(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(T,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(k,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(_,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(I,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(ke,{candidates:we(t.data.endpoints),preferredOrigin:r})]})]})}function ke({candidates:e,preferredOrigin:t}){let{t:r}=R(),[o,c]=s(null),l=Te(e,o,t),u=i(()=>l?Ee(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(ie,{value:u,size:De,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(E,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(re,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`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:[a(_,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function Ae(e){return new Date(e).toLocaleDateString()}function je(){let{t:e}=R(),t=y(),i=L.useUtils(),c=L.auth.listLinkableProviders.useQuery(),l=L.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,m]=s(()=>z(window.location.search)),g=r(null),_=G(`Linking a sign-in account`),v=r(null);o(()=>()=>v.current?.(),[]);let[b,x]=s(null);o(()=>{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=L.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=g.current;if(g.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{x(null),m(z(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};v.current?.(),v.current=B(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{v.current?.(),v.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=h(ue(e))},onError:e=>{g.current?.close(),g.current=null,x(null),d(e.message)}}),w=L.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),T=c.data??[],E=l.data??[],D=b!==null&&E.some(e=>e.provider===b);if(o(()=>{!D||b===null||(x(null),m({kind:`linked`,provider:b}))},[D,b]),T.length===0&&E.length===0)return null;let A=new Set(E.map(e=>e.provider)),j=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`})&&(d(null),w.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[_.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(O,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`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`&&n(`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:[a(S,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`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:[a(p,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),E.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:E.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`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`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:Ae(t.linkedAt)})})]}),n(I,{variant:`unstyled`,onClick:()=>void M(t,r),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:[a(ne,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>!A.has(e.provider)).map(t=>n(I,{variant:`unstyled`,onClick:()=>{d(null),m(null),_.requestProof().then(e=>{e!==null&&(g.current=de(null),x(g.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?a(k,{className:`h-3 w-3 animate-spin`}):a(O,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function Me({value:r,size:i=192}){let{t:c}=R(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Ne(){let{t:e}=R(),t=x(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[f,m]=s(null),h=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{m({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{m({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),g=o.length>0&&l.length>0&&o!==l,_=o.length>0&&o.length<8,v=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(g||_)&&a(`div`,{className:`text-[11px] text-danger`,children:g?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?a(S,{className:`h-3 w-3`}):a(p,{className:`h-3 w-3`}),f.msg]}),a(`div`,{className:`flex justify-end`,children:n(I,{onClick:()=>{m(null),h.mutate({currentPassword:r,newPassword:o})},disabled:!v||h.isPending,children:[h.isPending?a(k,{className:`h-3 w-3 animate-spin`}):a(D,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(F,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,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`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Pe({username:e}){let{t}=R(),r=x(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),f=l.data,[m,h]=s(null),[g,_]=s(``),[v,y]=s(null),[C,w]=s(!1),E=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{h({secret:e.secret,otpauthUrl:e.otpauthUrl}),_(``),y(null)},onError:e=>y(e instanceof Error?e.message:`Setup failed`)}),D=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{h(null),_(``),y(null),l.refetch()},onError:e=>y(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=G(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await O.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{y(null),l.refetch()},onError:e=>y(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:m?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,f?.enabled,m]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[O.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(T,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(k,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`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.`)}),a(`div`,{className:`flex justify-end`,children:n(I,{onClick:()=>{y(null),E.mutate()},disabled:E.isPending,children:[E.isPending?a(k,{className:`h-3 w-3 animate-spin`}):a(T,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&m&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(W,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(Me,{value:m.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:m.secret}),n(I,{variant:`ghost`,onClick:()=>{m&&navigator.clipboard.writeText(m.secret).then(()=>w(!0))},children:[C?a(S,{className:`h-3 w-3 text-success`}):a(b,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(F,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:g,onChange:e=>_(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`})]}),v&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(p,{className:`h-3 w-3`}),v]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(I,{variant:`outline`,onClick:()=>{h(null),y(null),_(``)},children:t(`common.cancel`,`Cancel`)}),n(I,{onClick:()=>{y(null),D.mutate({code:g})},disabled:D.isPending||g.length!==6,children:[D.isPending?a(k,{className:`h-3 w-3 animate-spin`}):a(S,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&f&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(S,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`})})]})]}),v&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(p,{className:`h-3 w-3`}),v]}),a(`div`,{className:`flex justify-end`,children:n(I,{variant:`danger`,onClick:()=>{y(null),A.mutate()},disabled:A.isPending,children:[A.isPending?a(k,{className:`h-3 w-3 animate-spin`}):a(T,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Fe(){return se(`auth-webauthn/passkey-enrollment`)?a(ae,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:le.t(`auth.authAuditSection.requestFailed`)}function Ie(){let{t:e}=R(),{logout:t}=H(),r=y(),i=L.useUtils(),o=L.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=L.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=L.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ge(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},p=async()=>{await r({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`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`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.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(I,{variant:`unstyled`,onClick:()=>void p(),disabled:d.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:[d.isPending?a(k,{className:`h-3 w-3 animate-spin`}):a(N,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Le=`You`;function Re(){let{t:e}=R(),t=y(),n=L.useUtils(),r=L.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=L.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ye(e,Le)),[r.data]),d=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`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:w,isAvailable:_e,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(me,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:T,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:he(o),onDismissNotice:()=>c(null),children:a(be,{rows:u,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:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},ze=[`linked`,`linkError`],Be={view:{icon:f,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:v,cls:`bg-primary/15 text-primary`},delete:{icon:m,cls:`bg-danger/15 text-danger`}};function Ve(){let{t:e}=R(),{user:t,logout:r}=H(),[i]=V(),o=e(`system.myAccess`,`My access`);if(!t)return a(pe,{icon:A,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(i.get(`tab`)===`preferences`)return a(U,{to:`/system/settings`,replace:!0});if(ze.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(U,{to:`?${e.toString()}`,replace:!0})}return a(fe,{icon:A,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(I,{variant:`outline`,onClick:r,children:[a(N,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(He,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Ne,{}),a(Pe,{username:t.username}),a(Fe,{}),a(je,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Ie,{}),a(Re,{}),a(Oe,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ve,{ownOnly:!0})}]})}function He({user:e}){let{t}=R(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(W,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`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:[a(C,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(Ue,{scopes:i})]})}function Ue({scopes:e}){let{t}=R(),r=g();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`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:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ce(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=Be[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Ve as MyAccessPage};
@@ -1 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hi as l,Kt as u,Lr as d,Si as f,Ut as p,Xr as m,Y as h,ai as g,bt as _,ct as v,ga as y,ht as b,li as x,ut as S,xr as C}from"./player-overlays-Dikds8gI.js";import{us as w}from"./client-C3Nr53Gn.js";import{n as T,t as E}from"./scissors-DdbRlSDX.js";import{Au as D,Br as O,Du as k,Eu as A,Fl as j,Fr as M,Ir as N,Ji as P,Ko as F,Lf as I,Mu as ee,Ou as te,Pf as L,Pr as ne,Rn as R,Rr as re,Tu as ie,Xr as z,Yr as B,Zi as ae,ad as oe,cd as se,cl as ce,dd as le,df as V,el as ue,fd as de,hi as fe,id as pe,ju as me,ku as he,ld as ge,lr as H,nd as _e,nl as ve,od as ye,ol as be,rd as xe,sd as Se,td as U,ud as Ce,vi as W,zl as we,zn as Te,zr as Ee}from"./src-VAvW-zoJ.js";import{t as G}from"./i18n-ChjX2Pvm.js";import{t as K}from"./useTranslation-BJr-n0es.js";import{T as De,b as Oe,kr as ke}from"./index-Bec3SQjl.js";import{t as Ae}from"./AdminSectionedPage-Di2VI8A1.js";import{n as je}from"./authed-media-BsEr81QN.js";import{t as q}from"./format-size-DIxKXxtj.js";import{n as Me,r as Ne,t as Pe}from"./StorageLocationsTable-BeMq-Y4a.js";o();var Fe=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],Ie={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Le={columnKey:`at`,dir:`desc`};function Re(e){return new Date(e).toLocaleString()}function ze(){let{t:n,i18n:i}=K(),[o,s]=a(`all`),{data:l,isLoading:u,isError:d}=k({},{refetchOnWindowFocus:!1}),{data:f,isLoading:m,isError:h}=be({},{refetchOnWindowFocus:!1}),{data:g}=F({isCamera:!0,projection:`slim`}),_=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),v=t(()=>{let e=[...l??[],...f??[]];return(o===`all`?e:e.filter(e=>e.domain===o)).toSorted((e,t)=>t.at-e.at)},[l,f,o]),b=t(()=>{let e=[];return d&&o!==`events`&&e.push(n(`recordings.activitySection.domainRecordings`)),h&&o!==`recording`&&e.push(n(`common.events`)),e},[d,h,o,n]),x=t(()=>new Intl.ListFormat(i.language,{type:`conjunction`}).format(b),[b,i.language]),S=t(()=>[{key:`at`,header:n(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:Re(e.at)})},{key:`domain`,header:n(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>r(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Ie[e.domain]}`,children:e.domain})},{key:`op`,header:n(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>r(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:n(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>r(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:n(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:_.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?r(`span`,{className:`text-foreground-subtle`,children:n(`common.cluster`)}):r(`span`,{className:`text-foreground`,children:_.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:n(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>r(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:n(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>r(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?q(e.bytesReclaimed):`—`})}],[_,n]),w=u||m;return e(`div`,{className:`flex flex-col gap-4`,children:[r(`div`,{className:`flex items-center gap-1`,children:Fe.map(e=>r(W,{variant:`unstyled`,onClick:()=>s(e.value),className:`rounded px-2 py-1 text-xs font-medium ${o===e.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n(e.labelKey)},e.value))}),w&&v.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(C,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):v.length===0?b.length>0?r(B,{icon:p,title:n(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:n(`recordings.activitySection.theOpsLogDidNot`,`The {{value1}} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`,{value1:x})}):r(B,{icon:y,title:n(`recordings.activitySection.noActivityYet`,`No activity yet`),description:n(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):e(c,{children:[b.length>0&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[r(p,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:b.length,names:x})]}),r(R,{columns:S,rows:v,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:Te,defaultSort:Le})]})]})}o();function Be(){let{t:n}=K(),i=F({isCamera:!0,projection:`slim`}),o=t(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[s,c]=a(null),u=s??o[0]?.id??null;return!i.isLoading&&o.length===0?r(B,{icon:l,title:n(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:n(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.recordingModeScheduleBandsAnd`,`Recording mode, schedule bands and the retention policy for one camera — the same controls as the camera's own Recording tab. Retention is one policy over footage and analytics; per-camera event deletion lives on the Events tab.`)})]}),e(`div`,{className:`flex items-center gap-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),r(S,{wrapperClassName:`inline-block w-auto`,value:u??``,onChange:e=>c(Number(e.target.value)),children:o.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),u!==null&&r(fe,{deviceId:u,children:r(De,{deviceId:u,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},u)]})}function Ve({types:e}){return r(Pe,{kinds:e})}o();var He=`pipeline-analytics`,Ue=`pipeline-analytics`;function We(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 Ge(){let{t:n}=K(),i=s(),{nodes:a}=L(),{data:o,isLoading:c}=P({addonId:He,cap:Ue,scope:`cluster`}),l=We(o),u=ae({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),d=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[a,l]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.theSingleNodeThatRuns`,`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(C,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(S,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:He,cap:Ue,scope:`cluster`,patch:{postProcessingNodeId:e.target.value}})},disabled:u.isPending,children:d.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):e},e))}),u.isPending&&r(C,{className:`h-4 w-4 animate-spin text-primary`})]})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),r(Ve,{types:[`eventMedia`]})]})]})}o();var Ke=[[`pipelineAnalytics`]],qe=1440*60*1e3;function Je(e,t){return t.get(e)??G.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var Ye=[{days:1},{days:7},{days:30},{days:90}];function Xe(){let{t:i}=K(),o=s(),c=v(),[l,d]=a(30),[f,p]=a(null),{data:m,isLoading:g}=ve({},{refetchOnWindowFocus:!1}),{data:_}=F({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),b=n(()=>{o.invalidateQueries({queryKey:Ke})},[o]),w=ce({onSuccess:b}),T=ue(),D=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:l}),message:i(`recordings.eventsManagementSection.permanentlyDeletesEveryEventMotion`,`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`),confirmLabel:i(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&w.mutate({olderThanMs:Date.now()-l*qe,reason:`retention`})},[c,w,l,i]),O=n(async e=>{let t=Je(e.deviceId,y);if(await c({title:i(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:t}),message:i(`recordings.eventsManagementSection.deleteRowsMessage`,{count:e.rows,size:q(e.bytes)}),confirmLabel:i(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){p(null);try{let n=await T.mutateAsync({deviceId:e.deviceId});b();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){p(`0 events deleted for ${t}. Media still listed (${q(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}p(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){p(e instanceof Error?e.message:String(e))}}},[c,T,y,b,i]),k=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:Je(e.deviceId,y)})},{key:`rows`,header:i(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:i(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:q(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>e(W,{variant:`unstyled`,onClick:()=>{O(t)},disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(u,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[y,O,T.isPending,i]);return g&&!m?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(C,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):m?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(h,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(x,{className:`h-3 w-3`}),footer:`across ${String(m.devices.length)} camera${m.devices.length===1?``:`s`}`,children:m.totalRows.toLocaleString()}),r(h,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:q(m.totalBytes)})]}),e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[r(`span`,{className:`text-foreground-subtle`,children:i(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),r(S,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>d(Number(e.target.value)),children:Ye.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(W,{variant:`unstyled`,onClick:()=>{D()},disabled:w.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:[w.isPending?r(C,{className:`h-3 w-3 animate-spin`}):r(E,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),m.devices.length===0?r(B,{icon:x,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(R,{columns:k,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480}),f===null?null:r(`p`,{className:f.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:f})]}):r(B,{icon:x,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function Ze(){let{t}=K();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.eventStore`,`Event store`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),r(`div`,{className:`mt-3`,children:r(Xe,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),r(`div`,{className:`mt-3`,children:r(Ge,{})})]})]})}function Qe(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 $e(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function et(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`${$e(e)} · ${o}`}function tt(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 nt(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}o();var rt=[`high`,`mid`,`low`],it=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],at=10080*60*1e3;function ot(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 st({onClose:n,onCreated:i}){let{t:o}=K(),s=F({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[l,u]=a(``),[d,f]=a(`high`),[p,h]=a(ot(60)),[g,_]=a(ot(0)),[v,y]=a(1),[b,x]=a(!0),[C,w]=a(``),[T,E]=a(null),k=l===``?c[0]?.id??null:l,A=new Date(p).getTime(),j=new Date(g).getTime(),P=Number.isFinite(A)&&Number.isFinite(j)&&A<j,I=D({onSuccess:()=>{i(),n()},onError:e=>E(e instanceof Error?e.message:String(e))});return r(ne,{open:!0,onOpenChange:e=>!e&&n(),children:e(N,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(Ee,{children:e(O,{className:`flex items-center gap-1.5`,children:[r(m,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(M,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.camera`,`Camera`)}),r(S,{value:k??``,onChange:e=>u(Number(e.target.value)),className:`w-full`,children:c.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.profile`,`Profile`)}),r(S,{value:d,onChange:e=>f(e.target.value),className:`w-full`,children:rt.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.from`,`From`)}),r(V,{type:`datetime-local`,value:p,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.to`,`To`)}),r(V,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.speed`,`Speed`)}),r(S,{value:v,onChange:e=>y(Number(e.target.value)),className:`w-full`,children:it.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:o(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(V,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:o(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(H,{checked:b,disabled:v!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),o(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!P&&r(`p`,{className:`text-[11px] text-danger`,children:o(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),T&&r(`p`,{className:`text-[11px] text-danger`,children:T})]}),e(re,{children:[r(W,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(W,{size:`sm`,onClick:()=>{if(k===null||!P)return;E(null);let e=C.trim();I.mutate({deviceId:k,profile:d,fromMs:A,toMs:j,options:{includeAudio:b,maxLifeMs:at,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:k===null||!P||I.isPending,children:I.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var ct=[[`recordingExport`]],lt={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 ut(){let{data:e,isLoading:n}=ee({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=I(w.RecordingExportProgress,e=>e.exportId),{map:i}=I(w.RecordingExportCompleted,e=>e.exportId),{map:a}=I(w.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>nt(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function dt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ft(){let{t:i}=K(),o=s(),[c,l]=a(!1),d=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=v(),h=b().trpcClient,_=dt(6e4),{rows:y,isLoading:x}=ut(),{data:S}=F({isCamera:!0,projection:`slim`}),w=t(()=>{let e=new Map;for(let t of S??[])e.set(t.id,t.name);return e},[S]),T=n(()=>{o.invalidateQueries({queryKey:ct})},[o]),E=he({onSuccess:T}),D=me({onSuccess:T}),[O,k]=a(null),A=n(async e=>{k(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),T()}finally{k(null)}},[h,T]),j=n(async e=>{await p({title:i(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:i(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:i(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&E.mutate({exportId:e.id})},[p,E,i]),M=n(async e=>{await p({title:i(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:i(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`})&&D.mutate({exportId:e.id})},[p,D,i]),N=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:w.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:et(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:Qe(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=lt[t.state];return e(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&r(C,{className:`h-2.5 w-2.5 animate-spin`}),i(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&e(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:i(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`span`,{className:`text-foreground-subtle tabular-nums`,children:tt(e.expiresAt,_)})},{key:`size`,header:i(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:q(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,a=t.state===`queued`||t.state===`rendering`,o=t.state!==`deleted`;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&e(W,{variant:`unstyled`,onClick:()=>{A(t)},disabled:O===t.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:i(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[O===t.id?r(C,{className:`h-3 w-3 animate-spin`}):r(g,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(W,{variant:`unstyled`,onClick:()=>{j(t)},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[r(f,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(W,{variant:`unstyled`,onClick:()=>{M(t)},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.exportsSection.deleteExport`,`Delete export`),children:r(u,{className:`h-3 w-3`})})]})}}],[w,_,O,E.isPending,D.isPending,A,j,M,i]);return x&&y.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(C,{className:`h-4 w-4 animate-spin`}),i(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):e(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex justify-end`,children:e(W,{variant:`unstyled`,onClick:()=>l(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[r(m,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),y.length===0?r(B,{icon:m,title:i(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:i(`recordings.exportsSection.createOneHereNewExport`,`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`)}):r(R,{columns:N,rows:y,rowKey:e=>e.id,minWidthPx:720}),c&&r(st,{onClose:()=>l(!1),onCreated:d})]})}var pt=`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`;o();var mt=`storage-migration`,ht=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function gt(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 _t(){let{t:e}=K(),t=z(mt);return t===`pending`?null:t===`unknown`?r(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:e(`recordings.cleanupSection.couldNotCheckWhetherStorage`,`Could not check whether storage cleanup is installed on this hub.`)}):t===`present`?r(vt,{}):null}function vt(){let{t}=K(),n=v(),[i,o]=a(!1),[s,c]=a(null),l=oe({},{refetchInterval:2e3}),d=l.data??null,f=d!==null&&ht.has(d.phase),p=pe(),m=xe(),h=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:i?t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd2`,`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`),confirmLabel:t(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){c(null);try{await p.mutateAsync({includeDebugMedia:i}),await l.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},g=async()=>{if(d&&await n({title:t(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:t(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:t(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await m.mutateAsync({jobId:d.jobId}),await l.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.cleanupSection.onePassOverLeftoverAnalytics`,`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`)}),e(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[r(H,{checked:i,disabled:f,onChange:e=>{o(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),r(`span`,{children:t(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),e(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[e(W,{variant:`unstyled`,type:`button`,disabled:f||p.isPending,onClick:()=>{h()},className:pt,children:[(f||p.isPending)&&r(C,{className:`h-3 w-3 animate-spin`}),r(u,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&r(W,{variant:`unstyled`,type:`button`,onClick:()=>{g()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:t(`common.cancel`,`Cancel`)})]}),s&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),d&&e(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[e(`p`,{className:`text-xs text-foreground`,children:[t(`recordings.cleanupSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:d.phase}),f&&r(C,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),d.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:d.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:gt(d)}),d.error&&r(`p`,{className:`text-[11px] text-danger`,children:d.error})]})]})}o();var yt=2e3;function bt(){let{t}=K(),n=v(),a=s(),o=we(),c=j(void 0,{refetchInterval:e=>e.state.data?.state===`running`?yt:!1}),l=c.data,u=l?.state===`running`,f=u||o.isPending;i(()=>{l?.state!==`done`||l.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[l?.state,l?.finishedAtMs,a]);let p=async()=>{await n({title:t(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:t(`recordings.diskReconcileSection.makesTheDatabaseMatchThe`,`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`),confirmLabel:t(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await o.mutateAsync(),await c.refetch())},m=u?l.total>0?`Reconciling ${String(l.completed)}/${String(l.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),e(`div`,{className:`mt-3 flex flex-col gap-2`,children:[e(W,{variant:`unstyled`,type:`button`,onClick:()=>void p(),disabled:f,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[f?r(C,{className:`h-3.5 w-3.5 animate-spin`}):r(d,{className:`h-3.5 w-3.5`}),m]}),l?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(l.completed),tracks:String(l.tracks),events:String(l.events),media:String(l.mediaDropped)}),l.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(l.failed.length),value2:l.failed.join(`, `)}):``,`.`]}):null,l?.state===`error`&&l.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,l.error]}):null]})]})}var J=1e3,Y=60*J,X=60*Y;function Z(e){return e.toLocaleString(`en-US`)}function xt(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 St(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:`~${xt(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${q(e.bytesMoved)} moved`,rate:a,eta:s}}function Ct(e){let t=St(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var wt=`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`}],Tt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Et(){let{t}=K(),n=z(wt);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(C,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(B,{icon:p,title:t(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryDidNot`,`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`)}):n===`absent`?r(B,{icon:T,title:t(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryAnsweredNo`,`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`)}):r(Dt,{})}function Dt(){let{t:n}=K(),i=v(),{data:o}=U({}),[s,c]=a({}),[l,u]=a({}),[d,f]=a(null),[p,m]=a(null),h=t(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),g=t(()=>{let e=new Map;for(let t of o??[]){if(t.enabled===!1)continue;let n=e.get(t.type);n?n.push(t.id):e.set(t.type,[t.id])}let t=new Map;for(let[n,r]of e)r.length===1&&t.set(n,r[0]);return t},[o]),y=de({},{refetchInterval:2e3}),b=y.data??null,x=b!==null&&Tt.has(b.phase),w=t(()=>{let e={};for(let t of Q){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),E=t(()=>{let e={};for(let t of Q){if(!s[t.id])continue;let n=l[t.id]??g.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,l,g]),D=t(()=>({destinations:w??{},...E?{sources:E}:{}}),[w,E]),O=ge(D,{enabled:!1,retry:!1}),k=le(),A=_e(),j=async()=>{if(!w)return;m(null);let e=await O.refetch();if(e.error){m(e.error instanceof Error?e.error.message:String(e.error));return}f(e.data??null)},M=async()=>{if(w&&await i({title:n(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:n(`migration.storageMigrationSection.copiesTheSelectedClassesFrom`,`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`),confirmLabel:n(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){m(null);try{await k.mutateAsync(D),f(null),await y.refetch()}catch(e){m(e instanceof Error?e.message:String(e))}}},N=async()=>{if(b&&await i({title:n(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:n(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:n(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await A.mutateAsync({jobId:b.jobId}),await y.refetch()}catch{}};return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[r(T,{className:`h-3.5 w-3.5`}),n(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.moveRecordingsLowResRecordings`,`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`)}),r(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Q.map(t=>{let i=h.get(t.locationType)??[],a=g.get(t.locationType)??``;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(t.labelKey)}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classFrom`,{label:n(t.labelKey)})}),r(S,{id:`migration-from-${t.id}`,value:l[t.id]??a,onChange:e=>{let n=e.target.value;u(e=>({...e,[t.id]:n}))},disabled:x,className:`w-full`,children:i.map(t=>e(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${n(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classTo`,{label:n(t.labelKey)})}),e(S,{id:`migration-dest-${t.id}`,value:s[t.id]??``,onChange:e=>{let n=e.target.value;c(e=>({...e,[t.id]:n}))},disabled:x,className:`w-full`,children:[r(`option`,{value:``,children:n(`migration.storageMigrationSection.skip`,`— skip —`)}),i.map(e=>r(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),p&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:p}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(W,{variant:`unstyled`,type:`button`,onClick:()=>{j()},disabled:!w||O.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:[O.isFetching&&r(C,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(W,{variant:`unstyled`,type:`button`,onClick:()=>{M()},disabled:!w||k.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:[k.isPending&&r(C,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),d&&r(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:d.moves.length===0?r(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):d.moves.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]},`${t.storageClass}-${t.toLocationId}`))}),b&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),x&&e(W,{variant:`unstyled`,type:`button`,onClick:()=>{N()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[r(_,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[n(`migration.storageMigrationSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:b.phase}),x&&r(C,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),b.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:b.error}),b.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,b.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:b.moves.map(e=>r(Ot,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(kt,{})]}),r(At,{running:x}),r(Mt,{})]})}function Ot({move:t}){let{t:n}=K(),i=t.progress===null?null:St(t.progress);return e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`flex items-center justify-between`,children:[e(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]}),e(`span`,{className:`text-foreground-subtle`,children:[t.state??n(`common.pending`),t.error?` (${t.error})`:``]})]}),t.progress!==null&&e(`div`,{className:`mt-1 space-y-1`,children:[i!==null&&i.fraction!==null&&r(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:r(`div`,{className:`h-full bg-primary`,style:{width:`${(i.fraction*100).toFixed(1)}%`}})}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ct(t.progress)})]})]})}function kt(){let{t}=K(),{data:n}=Se({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.phase}),` · `,Object.entries(t.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(t.startedAt).toLocaleString()]},t.jobId))})]})}function At({running:t}){let{t:n}=K(),i=v(),o=Ce({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=ye(),[c,l]=a(null),u=o.data??[];if(u.length===0)return null;let d=async e=>{if(await i({title:n(`migration.storageMigrationSection.drainRemaining`,`Drain remaining {{storageClass}}?`,{storageClass:e.storageClass}),message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await s.mutateAsync({classes:[e.storageClass]}),await o.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(o.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),r(W,{variant:`unstyled`,type:`button`,onClick:()=>{o.refetch()},disabled:o.isFetching,className:`rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:o.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.aMigrationRepointsFirstAnd`,`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`)}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.thisCountIsTakenOn`,`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`)}),c&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(i=>e(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[e(`span`,{className:`text-foreground`,children:[i.storageClass,`: `,i.fromLocationId,` → `,i.toLocationId,r(`span`,{className:`ml-2 text-foreground-subtle`,children:jt(i)})]}),r(W,{variant:`unstyled`,type:`button`,onClick:()=>{d(i)},disabled:t||s.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${i.storageClass}-${i.fromLocationId}`))})]})}function jt(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 Mt(){let{t}=K(),{data:n}=se({},{refetchInterval:2e3}),i=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return i.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:i.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`text-foreground`,children:[t.lane,`: `,t.job.fromLocationId,` → `,t.job.toLocationId]}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:Ct({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function Nt(){let{t}=K();return e(`div`,{className:`flex flex-col gap-4`,children:[r(_t,{}),r(bt,{}),e(`section`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),r(`div`,{className:`mt-3`,children:r(Et,{})})]})]})}o();var Pt=`recorder`,Ft=`recording`;function It(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 Lt(){let{t:n}=K(),i=s(),{nodes:a}=L(),{data:o,isLoading:c}=P({addonId:Pt,cap:Ft,scope:`cluster`}),l=It(o,`recordingNodeId`,`hub`),u=ae({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),d=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,l,...e])].filter(Boolean)},[a,l]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.theSingleNodeThatRecords`,`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(C,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(S,{wrapperClassName:`inline-block w-auto`,value:l,onChange:e=>{e.target.value!==l&&u.mutate({addonId:Pt,cap:Ft,scope:`cluster`,patch:{recordingNodeId:e.target.value}})},disabled:u.isPending,children:d.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):e},e))}),u.isPending&&r(C,{className:`h-4 w-4 animate-spin text-primary`})]}),l!==`hub`&&r(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:r(ke,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:l},components:{b:r(`span`,{className:`font-medium`})}})})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.whereRecordingsAreStoredMulti`,`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`)}),r(Ve,{types:[`recordings`,`recordingsLow`]})]})]})}function Rt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function zt(e,t){let n=Rt(e);return n.length===0?G.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Bt(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:zt(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Rt(e).includes(n));return i===void 0?null:{label:zt(i,t),exact:!1}}o();var Vt=[[`recording`]],Ht=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],Ut={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Wt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Gt(e){return e==null?`—`:new Date(e).toLocaleString()}function Kt(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 qt(){let{t:i}=K(),o=s(),c=v(),[l,f]=a(`retention`),{data:p,isLoading:m}=A({},{refetchOnWindowFocus:!1}),{data:g}=F({isCamera:!0,projection:`slim`}),{data:_}=U({}),y=t(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),b=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.displayName);return e},[_]),x=t(()=>{let e=_??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[_]),w=t(()=>p?.locations??[],[p?.locations]),T=t(()=>Bt(w,b,x),[w,b,x]),D=t(()=>Ne(w),[w]),O=n(()=>{o.invalidateQueries({queryKey:Vt})},[o]),k=te({onSuccess:O}),j=ie({onSuccess:O}),M=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:l}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&k.mutate({deviceId:e.deviceId,reason:l})},[c,k,l,y,i]),N=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:q(e.usedBytes)}),confirmLabel:i(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:q(e.usedBytes)}),variant:`danger`})&&j.mutate({deviceId:e.deviceId})},[c,j,y,i]),P=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>T===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:T.exact?`text-foreground`:`text-foreground-subtle`,title:T.exact?i(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):i(`recordings.storageSection.theRecordingsDefaultThisNode`,`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`),children:[T.label,!T.exact&&r(`span`,{className:`ml-1 text-foreground-subtle`,children:i(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:i(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:q(e.usedBytes)})},{key:`oldest`,header:i(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums text-foreground-subtle`,title:i(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Gt(e.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>e(`div`,{className:`flex items-center justify-end gap-1`,children:[e(W,{variant:`unstyled`,onClick:()=>{M(t)},disabled:k.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[r(E,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(W,{variant:`unstyled`,onClick:()=>{N(t)},disabled:j.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(u,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[y,T,M,N,k.isPending,j.isPending,i]);if(m&&!p)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(C,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!p)return r(B,{icon:d,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let I=p.devices.length;return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[r(h,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(d,{className:`h-3 w-3`}),footer:`${String(I)} camera${I===1?``:`s`} on ${p.nodeId}`,children:q(p.totalUsedBytes)}),D!==null&&D.severity!==null&&r(h,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(d,{className:`h-3 w-3`}),footer:`across ${String(D.knownVolumes)} volume${D.knownVolumes===1?``:`s`} of ${q(D.totalBytes)}`+(D.unknownVolumes>0?` · ${String(D.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Wt[D.severity]}`,children:q(D.freeBytes)})}),w.map(t=>{let n=Me(t),a=t.locationId??t.root??`default`;return r(h,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Kt(t,b)}),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?r(`span`,{className:`tabular-nums`,children:q(t.usedBytes)}):e(`div`,{className:`flex items-center gap-2`,title:i(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[r(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:r(`div`,{className:`h-full rounded ${Ut[n.severity]}`,style:{width:$(n.fraction)}})}),r(`span`,{className:`tabular-nums text-xs ${Wt[n.severity]}`,children:$(n.fraction)})]})},a)})]}),e(`section`,{className:`flex items-center gap-2 text-xs`,children:[r(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:i(`recordings.storageSection.pruneReason`,`Prune reason`)}),r(S,{wrapperClassName:`inline-block w-auto`,id:`prune-reason`,value:l,onChange:e=>{let t=Ht.find(t=>t.value===e.target.value);t&&f(t.value)},children:Ht.map(e=>r(`option`,{value:e.value,children:i(e.labelKey)},e.value))})]}),I===0?r(B,{icon:d,title:p.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:p.devicesRead===`unavailable`?i(`recordings.storageSection.thisRecordingNodeHasNo`,`This recording node has no footage ledger, so it refused to answer the per-camera table rather than report what it happens to hold in memory. The disk totals above are unaffected.`):i(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):r(R,{columns:P,rows:[...p.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Jt(){let{t}=K();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),r(`div`,{className:`mt-3`,children:r(qt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),r(`div`,{className:`mt-3`,children:r(Lt,{})})]})]})}function Yt(){let{t:e}=K(),t=Oe(`/recordings`,{t:e,isAdmin:!0})??{icon:m,title:e(`nav.recordings`,`Recordings`)};return r(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:r(Jt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:r(Ze,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Be,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(ft,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(ze,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(Nt,{})}]})}export{Yt as RecordingsPage};
@@ -1,2 +0,0 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$r as o,D as s,Kt as c,Oi as l,Sa as u,bn as d,bt as f,ct as p,dt as m,lt as h,ut as g,xr as _,yn as v}from"./player-overlays-Dikds8gI.js";import{a as y,c as b,f as x,o as S}from"./video-BSNDvfCe.js";import{An as C,Br as w,Ei as T,Et as ee,Fr as E,In as D,Ir as O,Jr as k,Ko as A,On as j,Pr as M,Rn as N,Rr as P,Yd as F,bt as I,df as L,er as te,ff as R,ki as z,kn as B,lr as ne,nr as V,rr as H,ur as U,vi as W,wt as G,yt as re,zf as K,zn as ie,zr as q,zt as J}from"./src-VAvW-zoJ.js";import{t as Y}from"./i18n-ChjX2Pvm.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{P as ae,kr as oe,n as se}from"./index-Bec3SQjl.js";a();function ce({id:t,title:r,icon:i,description:a,actions:o,tone:c=`default`,notice:l=null,onDismissNotice:u,children:d}){return n(D,{headingId:`access-${t}`,title:r,icon:i,actions:o,testId:`access-${t}`,children:e(`div`,{className:`${s} space-y-3`,children:[n(`div`,{className:m(`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:a}),l!==null&&n(ue,{notice:l,onDismiss:u}),d]})})}var le={success:{icon:l,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:y,line:`border-danger/40 text-danger`,mark:`text-danger`}};function ue({notice:t,onDismiss:r}){let{t:i}=X(),a=le[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:m(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[n(o,{className:m(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),n(`span`,{className:`min-w-0 flex-1`,children:t.message}),r!==void 0&&n(R,{type:`button`,variant:`ghost`,size:`sm`,icon:f,"aria-label":i(`access.accessSection.dismiss`,`Dismiss`),onClick:r,className:`-my-1 h-5 w-5`})]})}function Z(){let{data:e}=F();return t(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function de(e,t=null){return e===null?t:{tone:`danger`,message:e}}var fe={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function pe(e){return Y.t(fe[e])}var me={active:`success`,expired:`warning`,revoked:`default`,current:`info`},he={current:0,active:1,expired:2,revoked:3};function ge(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function _e({status:e}){return n(T,{variant:me[e],className:`text-[10px]`,children:pe(e)})}function ve({row:t,action:r}){if(!r.isAvailable(t))return null;let i=r.icon,a=r.busyId===t.id;return e(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.onRun(t),disabled:r.disabled,"aria-label":Y.t(`access.credentialColumns.actionOn`,{action:r.label,name:t.name}),className:r.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(i,{className:`h-3 w-3`,"aria-hidden":!0}),r.label]})}function ye(t){return[{key:`name`,header:Y.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[n(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&n(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:Y.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:Y.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[n(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&n(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:Y.t(`access.credentialColumns.status`,`Status`),sortValue:e=>he[e.status],render:e=>n(_e,{status:e.status})},{key:`created`,header:Y.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:ge(e.createdAt,`—`)})},{key:`lastUsed`,header:Y.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:ge(e.lastUsedAt,Y.t(`access.credentialColumns.never`))})},{key:`expires`,header:Y.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:ge(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:Y.t(`access.credentialColumns.actionsHeader`),render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:n(ve,{row:e,action:t},t.label))})}].filter(e=>e!==null)}a();var be=6,xe={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Se(e){let t=xe[e];return t===void 0?e:Y.t(t)}function Ce(e,t){return Y.t(t.key,{count:e})}function Q(e,t){return Y.t(`access.bulk.countOf`,{count:e,noun:Ce(e,t)})}function we(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>Y.t(`access.bulk.statusCount`,{count:t,status:pe(e).toLowerCase()})).join(`, `)}function Te(e,t){let n=e.slice(0,be).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>be?[Y.t(`access.bulk.previewMore`,{count:e.length-be})]:[];return[Y.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:we(e)}),``,...n,...r].join(`
2
- `)}async function Ee(e,t,n){let r=String(t.length),i=await e({title:Y.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:Te(t,n),label:Y.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:Y.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:Y.t(`access.bulk.confirmMismatch`,{expected:r,noun:Ce(2,n)})});return i!==null&&i.trim()===r}function De(e,t){let n=h(),r=K.auth.revokeCredentials.useMutation(),[a,o]=i(null);return{run:async i=>{if(i.length===0||!await Ee(n,i,e))return!1;o(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>Se(e.reason));return o({tone:`success`,message:n.length>0?Y.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):Y.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return o({tone:`danger`,message:Y.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:Y.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:a,dismiss:()=>o(null)}}function Oe(e,t,n){let r=h(),[a,o]=i(!1),[s,c]=i(null);return{run:async i=>{if(i.length===0||!await Ee(r,i,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){a.push(`${e.name}: ${t instanceof Error?t.message:Y.t(`access.bulk.requestFailed`)}`)}return o(!1),n(),a.length===0?(c({tone:`success`,message:Y.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:Y.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}a();var ke={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}]},Ae={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},je=e=>e.status!==`current`,Me=[`active`,`current`];function Ne({rows:r,label:a,isLoading:o,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:d,extraActions:f,bulk:p,defaultStatus:m=Me}){let{t:h}=X(),[g]=i(()=>m.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...m]}}),v=j(r,ke,g),[y,b]=i(()=>new Set),x=u??h(`access.credentialColumns.never`),S=t(()=>ye({hideOwner:l,expiresNone:x,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,x,d,f,h]),C=t(()=>p===void 0?()=>!1:e=>je(e)&&p.isSelectable(e),[p]),w=t(()=>v.rows.filter(e=>y.has(e.id)&&C(e)),[v.rows,y,C]);return o?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[n(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),h(`access.credentialTable.loading`,{label:a})]}):s===null?e(`div`,{className:`space-y-3`,children:[n(B,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Ae[e.id]===void 0?e.id:h(Ae[e.id]),...e.id===`status`?{facetLabel:e=>pe(e)}:{}})),labels:{searchPlaceholder:h(`access.credentialTable.searchPlaceholder`,{label:a}),searchLabel:h(`access.credentialTable.searchLabel`,{label:a}),facetsLabel:h(`access.credentialTable.facetsLabel`,{label:a}),clearLabel:h(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),p!==void 0&&n(Pe,{bulk:p,shown:v.rows.filter(C),targets:w,onSelect:b}),n(N,{columns:S,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:ie,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:h(`access.credentialTable.pagesLabel`,{label:a}),previous:h(`access.credentialTable.previousPage`),next:h(`access.credentialTable.nextPage`),range:(e,t,n)=>h(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?h(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:a}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...p===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:C,rowLabel:e=>h(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:h(`access.credentialTable.pageLabel`,{noun:Ce(1,p.noun)})}}})]}):n(k,{title:h(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:a}),message:s})}function Pe({bulk:t,shown:r,targets:i,onSelect:a}){let{t:o}=X(),{revoke:s,noun:l}=t,u=(t.quickSelect??[]).map(e=>({...e,rows:r.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(i)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[r.length>0&&n(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(r.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:r.length})}),u.map(t=>e(W,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),i.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(i.length,l)})}),e(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[n(f,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(W,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?n(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(c,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(i.length,l)})]})]})]})}var Fe=(e,t)=>t===null?`—`:e.get(t)??t;function Ie(e,t){return e!=null&&e<=t?`expired`:`active`}function Le(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:Fe(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 Re(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 ze=`All permissions`,Be=`View link`,Ve=`Scoped`,He={"grid-view":`Grid`,"events-view":`Events`};function Ue(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function We(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Ge(e,t,n){return e===`*`?ze:We(e)?`${`${He[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${Ue(e.grant.deviceIds,t)}`:n(e)}function Ke(e){return e.includes(`*`)?ze:e.some(We)?Be:Ve}function qe(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:Fe(t,e.subjectId),kind:Ke(e.scopes),scope:n,status:e.revokedAt===null?Ie(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Je(e){return`${e.provider}\u0000${e.subject}`}function Ye(e,t){return{id:Je(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:Fe(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var Xe=40,Ze=[{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`}],Qe=[{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`}],$e=[{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 et(e,t){return e.find(e=>e.test.test(t))?.name??null}function tt(e){return e.length<=Xe?e:`${e.slice(0,Xe)}…`}function nt(e){if(e===null||e.trim().length===0)return{label:Y.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=et($e,t);if(n!==null)return{label:n,raw:t};let r=et(Ze,t),i=et(Qe,t);return r!==null&&i!==null?{label:Y.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:tt(t),raw:t}:{label:r,raw:t}}var rt={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,"cli-approval":`helpers.sessionClient.method.cliApproval`,exchange:`helpers.sessionClient.method.exchange`};function it(e){let t=rt[e];return t===void 0?e:Y.t(t)}function at(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function ot({token:t,label:r,onClose:i}){let{t:a}=X();return n(M,{open:!0,onOpenChange:e=>!e&&i(),children:e(O,{width:`md`,scroll:`body`,children:[n(q,{children:n(w,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:r})})}),e(E,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),n(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(P,{children:[n(C,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),n(W,{type:`button`,variant:`primary`,size:`sm`,onClick:i,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var st={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};a();var ct=80,$=86400,lt=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],ut={type:`device-multiselect`,key:`cameras`,deviceFilter:{types:[`camera`]},maxItems:64},dt={type:`capability`,target:``,access:[`view`,`create`]};function ft({open:a,users:s,onClose:c,onSubmit:l,submitting:f,formError:p,awaitingProof:m}){let{t:h}=X(),y=u(),{user:b}=ae(),S=b?.isAdmin===!0,C=S?null:b?.scopes??[],[w,T]=i(`scopes`),[E,D]=i(b?.id??``),[O,k]=i(``),[A,j]=i([dt]),[M,N]=i([]),[P,F]=i(`grid-view`),[R,B]=i(!1),[G,K]=i(`30`);r(()=>{a||(T(`scopes`),D(b?.id??``),k(``),j([dt]),N([]),F(`grid-view`),B(!1),K(`30`))},[a,b?.id]),r(()=>{w!==`view-link`&&G===`never`&&K(`30`)},[w,G]);let ie=t(()=>lt.filter(e=>e.seconds!==`never`||w===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?h(`access.createTokenModal.never`,`Never (until revoked)`):h(`access.createTokenModal.days`,{count:Number(e.value)})})),[w,h]),q=O.trim(),J=w===`scopes`?I(A,y):null,Y=M.map(Number).filter(e=>Number.isInteger(e)&&e>=0),se=lt.find(e=>e.value===G)?.seconds??30*$,ce=()=>w===`all`?[`*`]:w===`view-link`?[{type:`share-view`,grant:{kind:P,deviceIds:Y,...R?{talk:!0}:{}}}]:A,le=q.length>0&&q.length<=ct&&!f&&!m&&(w===`all`?S:w===`view-link`?Y.length>0:A.length>0&&J===null),ue=()=>{if(!le)return;let e=S&&w!==`all`&&E!==``&&E!==b?.id;l({scopes:ce(),expiresIn:se,label:q,...e?{subjectId:E}:{}})},Z=w===`all`,de=Z?d:v;return n(ee,{open:a,onClose:c,title:h(`access.createTokenModal.createToken`,`Create token`),icon:Z?d:x,error:p,width:`md`,testId:`create-token-dialog`,footer:e(W,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:ue,disabled:!le,"data-testid":`create-token-submit`,children:[f||m?n(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):n(de,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),h(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[n(U,{children:h(`access.createTokenModal.whatItMayDo`,`What it may do`)}),n(te,{appearance:`pills`,value:w,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&T(e)},children:e(V,{"aria-label":h(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(H,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[n(v,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(H,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[n(o,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachViewLink`,`View link`)]}),S?e(H,{value:`all`,"data-testid":`token-reach-all`,children:[n(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),h(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?n(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:n(`p`,{children:n(oe,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:n(`strong`,{})}})})}):null,S&&w!==`all`&&s.length>1?e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-user`,children:h(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),n(g,{id:`token-user`,value:E,onChange:e=>D(e.target.value),options:s.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-name`,children:h(`access.createTokenModal.label`,`Label`)}),n(L,{id:`token-name`,value:O,maxLength:ct,required:!0,onChange:e=>k(e.target.value),placeholder:w===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),w===`scopes`?e(`div`,{className:`space-y-1`,children:[n(U,{children:h(`access.createTokenModal.scopes`,`Scopes`)}),n(re,{value:A,onChange:j,clampToParent:C}),J&&n(`p`,{className:`text-[10px] text-danger`,children:J}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:h(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,w===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[n(U,{children:h(`access.createTokenModal.cameras`,`Cameras`)}),n(z,{field:{...ut,label:h(`access.createTokenModal.cameras`,`Cameras`)},value:M,onChange:e=>N(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])})]}),e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-view-kind`,children:h(`access.createTokenModal.viewKind`,`Shows`)}),n(g,{id:`token-view-kind`,value:P,onChange:e=>F(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:h(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:h(`access.createTokenModal.viewEvents`,`Events`)}]})]}),P===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[n(ne,{className:`mt-0.5`,checked:R,onChange:e=>B(e.target.checked),"data-testid":`token-view-talk`}),n(`span`,{children:h(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[n(U,{htmlFor:`token-lifetime`,children:h(`access.createTokenModal.expires`,`Expires after`)}),n(g,{id:`token-lifetime`,value:G,onChange:e=>K(e.target.value),options:ie})]})]})})}a();var pt={key:`access.nouns.token`};function mt(e){return typeof e==`object`&&!!e&&`kind`in e}function ht(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${mt(e.selector)?J(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function gt({headerOwnsCreate:a=!1,createRequested:o=!1,onCreateConsumed:s,ownOnly:l=!1}){let{t:d}=X(),f=u(),{user:m}=ae(),h=p(),g=K.useUtils(),_=Z(),{data:v}=F(),y=t(()=>v??[],[v]),{data:b}=A({}),S=t(()=>{let e=new Map;for(let t of b??[])e.set(t.id,t.name);return e},[b]),C=K.auth.listTokens.useQuery(void 0),{requestProof:w,dialog:T}=se(`Creating a token with all permissions`),{state:ee,openNew:E,close:D}=G({newKey:st.token}),[O,k]=i(null),[j,M]=i(null),[N,P]=i(!1),[I,L]=i(null),[te,R]=i(null);r(()=>{o&&(E(),s?.())},[o,E,s]);let z=()=>{g.auth.listTokens.invalidate(),g.auth.listAuthAudit.invalidate()},B=K.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{z(),D(),M(null),P(!1),L({token:e,label:t.label})},onError:e=>{M(`Create failed: ${e.message}`),P(!1)}}),ne=K.auth.revokeToken.useMutation({onSuccess:()=>{R(null),z()},onError:e=>{R(null),k(`Revoke failed: ${e.message}`)}}),V=De(pt,z),H=Date.now(),U=(C.data??[]).filter(e=>!l||e.subjectId===m?.id).map(e=>qe(e,_,e.scopes.includes(`*`)?null:e.scopes.map(e=>Ge(e,S,e=>ht(e,f))).join(`, `),H)),re=async e=>{await h({title:d(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?d(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):d(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:d(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(k(null),R(e.id),ne.mutate({id:e.id}))},ie=e=>{(async()=>{k(null),M(null);let t;if(e.scopes.includes(`*`)){P(!0);let e=await w();if(P(!1),e===null)return;t=e}B.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[T,n(ce,{notice:de(O,V.outcome),onDismissNotice:()=>{k(null),V.dismiss()},id:l?`my-tokens`:`tokens`,title:l?d(`access.tokensSection.myTokens`,`My tokens`):d(`access.tokensSection.tokens`,`Tokens`),icon:x,actions:a?void 0:e(W,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:E,children:[n(x,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),d(`system.access.newToken`,`New token`)]}),description:d(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:n(Ne,{rows:U,label:d(`common.tokensLabel`),isLoading:C.isLoading,loadError:C.isError?C.error?.message??`Request failed`:null,emptyText:d(`access.tokensSection.noTokens`,`No tokens.`),action:{label:d(`access.tokensSection.revoke2`,`Revoke`),icon:c,isAvailable:e=>e.status===`active`,onRun:e=>void re(e),busyId:te,disabled:V.busy||te!==null},...m?.isAdmin===!0?{bulk:{revoke:V,noun:pt,isSelectable:e=>e.status===`active`}}:{}})}),n(ft,{open:ee.mode===`new`,users:y.map(e=>({id:e.id,username:e.username})),onClose:()=>{D(),M(null),P(!1)},submitting:B.isPending,formError:j,awaitingProof:N,onSubmit:ie}),I&&n(ot,{token:I.token,label:I.label,onClose:()=>L(null)})]})}var _t=864e5,vt={qr:`QR (by an admin)`,self:`Self-enrolled`},yt={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function bt(e){return e.status===`revoked`}function xt(e){return e.status!==`revoked`}function St(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function Ct(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/_t)}function wt(e,t){let n=Ct(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function Tt(e,t){let n=Ct(e,t);return n===null?Y.t(`helpers.certificateModel.unknown`):n===0?Y.t(`helpers.certificateModel.today`):n>0?Y.t(`helpers.certificateModel.inDays`,{count:n}):Y.t(`helpers.certificateModel.daysAgo`,{count:-n})}function Et(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Dt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Ot(e){return e.length<=10?e:`${e.slice(0,10)}…`}function kt(e){if(!e.online)return{allowed:!1,reason:Y.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var At={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 jt(e){if(e.ok)return{tone:`success`,message:Y.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Ot(e.newSerial)})};let t=e.keptPreviousLeaf?Y.t(`helpers.certificateModel.keptPrevious`):Y.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:Y.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:Y.t(At[e.stage]),reason:e.reason,kept:t})}}function Mt(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 Nt=11;function Pt(e,t){let n=e.slice(0,Nt);return t===null?n:`${n} · ${t}`}function Ft(e){return{id:e.id,name:e.deviceName,detail:Pt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:yt[e.platform],scope:vt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function It(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:yt[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Lt({sessions:t,isLoading:r,loadError:i,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=X();return r?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(_,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):i===null?t.length===0?n(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):n(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(Rt,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,i]})}function Rt({session:t,revoking:r,onRevoke:i}){let{t:a}=X(),o=nt(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[n(S,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&n(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:it(t.method)}),n(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),n(`span`,{children:a(`auth.sessionsList.lastActive`,{when:at(t.lastUsedAt)})}),n(`span`,{children:a(`auth.sessionsList.expires`,{when:at(t.expiresAt)})})]})]}),!t.current&&e(W,{variant:`unstyled`,onClick:i,disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r?n(_,{className:`h-3 w-3 animate-spin`}):n(b,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{Le as C,ce as D,Oe as E,de as O,Re as S,De as T,nt as _,xt as a,Je as b,Tt as c,St as d,kt as f,st as g,gt as h,bt as i,Z as k,jt as l,Ot as m,Ft as n,Mt as o,Dt as p,It as r,Et as s,Lt as t,wt as u,it as v,Ne as w,Ye as x,at as y};
@@ -1 +0,0 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et as a,o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ii as s,Lr as c,Vn as l,bt as u,ct as d,ei as f,vn as p,xr as m}from"./player-overlays-Dikds8gI.js";import{Po as h}from"./client-C3Nr53Gn.js";import{t as g}from"./archive-7oqv5c2w.js";import{t as _}from"./eraser-BN9Jm7v9.js";import{t as v}from"./hard-drive-download-XJqU5Yhh.js";import{$i as y,$u as b,Ei as x,Eu as S,ed as C,ff as w,qs as ee,td as te,vi as T}from"./src-VAvW-zoJ.js";import{t as E}from"./i18n-ChjX2Pvm.js";import{t as D}from"./useTranslation-BJr-n0es.js";import{K as O,at as k}from"./index-Bec3SQjl.js";import{t as A}from"./format-size-DIxKXxtj.js";import{t as ne}from"./InstancesTable-tMHEIn4o.js";a();var re=`forceDeleteLocation`;function ie({row:e}){let{t}=D(),r=d(),i=o(),a=y(),s=async()=>{if(await r({title:t(`system.storage.forceDeleteTitle`,`Force delete "{{name}}"?`,{name:e.name}),message:t(`system.storage.forceDeleteNote`,`Removes the record only, without checking what is on the location. Anything still stored there becomes unreachable — index rows naming it stop resolving, and playback of those segments goes silently black rather than erroring.`),confirmLabel:t(`system.storage.forceDelete`,`Force delete`),variant:`danger`}))try{await a.mutateAsync({addonId:e.addonId,action:re,input:{id:e.id}}),await i.invalidateQueries({queryKey:[O]}),await i.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}catch(n){k({title:t(`providerInstances.deleteFailed`,`Could not delete`),message:`${e.name}: ${n instanceof Error?n.message:String(n)}`,severity:`critical`})}};return n(w,{icon:p,variant:`ghost`,size:`sm`,disabled:a.isPending,"aria-label":t(`system.storage.forceDeleteRow`,`Force delete {{name}}`,{name:e.name}),onClick:()=>void s()})}function ae(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function oe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function se({drain:t}){let{t:r}=D();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return n(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:r(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:r(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return n(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:r(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:r(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&n(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":r(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:n(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[r(`storage.drainProgressLine.left`,{size:ae(t.bytesRemaining)}),i!==null&&` · ${r(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?n(`span`,{"data-testid":`drain-eta-absent`,title:r(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:r(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,r(`storage.drainProgressLine.empty`,{when:oe(t.estimatedEmptyAtMs)})]})]})}var j=[`ok`,`warn`,`critical`];function M(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function N(e){return Math.min(1,Math.max(0,e))}function P(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=N((n-t)/n);return{fraction:r,severity:M(r),recordingsFraction:N(e.usedBytes/n),freeBytes:t,totalBytes:n}}function ce(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=P(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||j.indexOf(e.severity)>j.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function F(e){return Math.min(1,Math.max(0,e))}function I(e){return Math.round(F(e)*1e3)/10}function L(e){return`${String(Math.round(F(e)*100))}%`}function le(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:A(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?E.t(`helpers.locationCapacityBar.unknownSummary`):E.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=P({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?F(o/r):m.fraction,g=m===null?M(h):m.severity,_=f===null?null:m===null?F(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:F((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:A(r),freeTotal:A(a),freeTotalPercent:L(a/r),used:A(p),usedPercent:L(p/r),free:A(u),freePercent:L(u/r),reserve:s===0?null:E.t(`helpers.locationCapacityBar.reserveKept`,{size:A(s)}),owned:f===null||_===null?null:E.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:A(f),percent:L(_)}),cap:v===null?null:v.reason===`drain`?E.t(`helpers.locationCapacityBar.capDrain`,{size:A(v.bytes)}):E.t(`helpers.locationCapacityBar.capCap`,{size:A(v.bytes)})},S=[E.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:E.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?E.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?E.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:E.t(`helpers.locationCapacityBar.legendKeptFree`),value:A(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:E.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?E.t(`helpers.locationCapacityBar.legendUsed`):E.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:E.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?E.t(`helpers.locationCapacityBar.legendDrainTarget`):E.t(`helpers.locationCapacityBar.legendCap`),value:E.t(`helpers.locationCapacityBar.legendCapValue`,{size:A(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:I(c/r),ownedPercent:f===null?null:I(f/r),usedPercent:I(p/r),freePercent:I(u/r),capPercent:y===null?null:I(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}function R(e){return h(e)}function z(e){return e===`active`}var B=[{mode:`active`,get label(){return E.t(`helpers.locationMode.activeLabel`)},get consequence(){return E.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return E.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return E.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return E.t(`helpers.locationMode.drainLabel`)},get consequence(){return E.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return E.t(`helpers.locationMode.disabledLabel`)},get consequence(){return E.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function V(e){return B.find(t=>t.mode===e)??B[0]}function ue(e){return V(e).requiresConfirmation}var de=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function H(e,t,n){return z(n)||!z(R(e))||t.some(t=>t.id!==e.id&&z(R(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(e,t){return{active:H(e,t,`active`).reason,readonly:H(e,t,`readonly`).reason,drain:H(e,t,`drain`).reason,disabled:H(e,t,`disabled`).reason}}var pe=1024**3;function U(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function me(e){let t=U(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=U(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function he(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*pe;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function ge(e,t){let n=U(e.maxUsedGb);return n===null||n<0?null:{bytes:n*pe,reason:t===`drain`?`drain`:`legacy`}}var W={ok:`bg-primary`,warn:`bg-warning`,critical:`bg-danger`},G={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function _e(e,t){return e===`used`?W[t]:G[e]}function K({location:t,ownedBytes:r}){let{t:i}=D(),a=t.capacity??null,o=he(me(t.config),a?.totalBytes??null),s=le({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:r??null,cap:ge(t.config,R(t))});return s.kind===`unknown`?n(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&n(`div`,{className:G.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&n(`div`,{className:G.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),n(`div`,{className:W[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),n(`div`,{className:G.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&n(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:G.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),n(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[n(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${_e(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var ve={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},ye={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},be=`storage.discardLocation`,q=`storage.discardLocationStatus`,xe=`storage.discardLocationCancel`;function Se(e){return ve[e]??null}function Ce(e){return ye[e]??null}function we(e){return!z(R(e))}function Te(e,t){return Se(e.type)===null||!we(e)?!1:t.some(t=>t.id!==e.id&&z(R(t)))}var Ee=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function J(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Y(e){return typeof e==`string`?e:null}function X(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!Ee.has(n))return null;let r=J(t.camerasTotal),i=J(t.camerasDone),a=J(t.foldersRemoved),o=J(t.dbRowsDeleted),s=J(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:Y(t.locationId),jobId:Y(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:Y(t.detail)??``,startedAtMs:J(t.startedAtMs),finishedAtMs:J(t.finishedAtMs),error:Y(t.error)}}function De(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}var Oe=2e3;function ke({location:e,siblings:t}){return Te(e,t)?n(Ae,{location:e}):null}function Ae({location:t}){let{t:a}=D(),o=d(),s=y(),c=Ce(t.type),[l,f]=i(null),[p,h]=i(null),[g,v]=i(!1);if(r(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:q,input:{}});if(e)return;f(X(t))}catch{}};t();let n=setInterval(()=>void t(),Oe);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let b=l!==null&&l.locationId===t.id,x=b&&l.running,S=b&&l.phase!==`idle`,C=async()=>{if(await o({title:a(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:a(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:a(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){h(null),v(!0);try{await s.mutateAsync({addonId:c,action:be,input:{locationId:t.id}}),f(X(await s.mutateAsync({addonId:c,action:q,input:{}})))}catch(e){h(e instanceof Error?e.message:String(e))}finally{v(!1)}}},w=async()=>{try{await s.mutateAsync({addonId:c,action:xe,input:{}})}catch(e){h(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[x?e(T,{variant:`unstyled`,type:`button`,onClick:()=>void w(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[n(u,{className:`h-3 w-3`}),a(`common.cancel`,`Cancel`)]}):e(T,{variant:`unstyled`,type:`button`,onClick:()=>void C(),disabled:g,title:a(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[g?n(m,{className:`h-3 w-3 animate-spin`}):n(_,{className:`h-3 w-3`}),a(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),S&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:n(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${De(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${a(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${a(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(p||b&&l?.error)&&n(`p`,{className:`text-[10px] text-danger leading-tight`,children:p??l?.error})]})}a();var Z={active:l,readonly:g,drain:v,disabled:f},je={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function Me({mode:t,open:r,onToggle:i}){let{t:a}=D(),o=V(t),c=Z[t];return e(T,{variant:`unstyled`,type:`button`,"aria-expanded":r,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${je[t]}`,children:[n(c,{className:`h-3 w-3`}),o.label,n(s,{className:`h-3 w-3 ${r?`rotate-180`:``}`})]})}function Ne({mode:t,blockedReasons:i,onSelect:a,onDismiss:o}){let{t:s}=D();return r(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[n(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),n(T,{variant:`unstyled`,type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:n(u,{className:`h-3 w-3`})})]}),B.map(r=>{let c=i[r.mode],l=c!==``,u=Z[r.mode],d=r.mode===t;return e(T,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":d,"aria-label":r.label,disabled:l,onClick:()=>{l||(o(),d||a(r.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[n(u,{className:`h-3 w-3`}),r.label,d&&n(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),n(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:r.consequence}),l&&n(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},r.mode)})]})}function Pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Fe(e){if(!Pe(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=Q(e.startedAtMs),r=Q(e.startBytes),i=Q(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:Q(e.estimatedEmptyAtMs)}}function Ie(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=Fe(n);e!==null&&t.set(e.locationId,e)}return t}function Le(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Re(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Le(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function ze(e){return e.mode===`drain`?!0:e.config.readOnly===!0}var Be=[`recordings`,`recordingsLow`];function Ve(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function He(e,t){if(t===void 0||!Be.includes(e.type))return null;let n=t.find(t=>Ve(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function Ue(e,t){let n=new Map;for(let r of e){let e=He(r,t);e!==null&&n.set(r.id,e)}return n}a();var We=[];function $(){let e=te({}),n=S({},{refetchOnWindowFocus:!1}),r=b({},{refetchOnWindowFocus:!1}),i=e.data??We,a=t(()=>Ue(i,n.data?.locations),[i,n.data?.locations]),o=t(()=>Ie(r.data),[r.data]);return t(()=>({locations:i,ownedBytesById:a,drainOf:e=>Re(ze(e),o.get(e.id))}),[i,a,o])}a();function Ge({row:t}){let{t:r}=D(),a=d(),s=o(),c=$(),[l,u]=i(!1),f=ee({onSuccess:()=>{s.invalidateQueries({queryKey:[O]}),s.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),u(!1)},onError:e=>k({title:r(`system.storage.modeFailed`,`Could not change the state`),message:`${t.name}: ${e.message}`,severity:`critical`})}),p=c.locations.find(e=>e.id===t.id);if(p===void 0)return null;let m=c.locations.filter(e=>e.type===p.type),h=R(p),g=c.drainOf(p),_=async e=>{ue(e)&&!await a({title:r(`system.storage.disable`,`Disable "{{displayName}}"?`,{displayName:p.displayName}),message:r(`system.storage.nothingIsDeletedSetThe`,`{{consequence}} Nothing is deleted — set the location back to Read-only or Active to bring its footage back.`,{consequence:V(e).consequence}),confirmLabel:r(`common.disable`,`Disable`),variant:`danger`})||f.mutate({addonId:t.addonId,id:t.id,values:{mode:e}})};return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`min-w-0 flex-1 basis-60`,children:[n(K,{location:p,ownedBytes:c.ownedBytesById.get(p.id)??null}),g.kind!==`idle`&&n(se,{drain:g})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[n(ke,{location:p,siblings:m}),n(Me,{mode:h,open:l,onToggle:()=>u(e=>!e)})]}),l&&n(Ne,{mode:h,blockedReasons:fe(p,m),onSelect:e=>void _(e),onDismiss:()=>u(!1)})]})}function Ke({row:t}){let r=$();if(t.kind!==`instance`)return null;let i=r.locations.find(e=>e.id===t.id);if(i===void 0)return null;let a=r.drainOf(i);return e(`div`,{className:`min-w-48`,children:[n(K,{location:i,ownedBytes:r.ownedBytesById.get(i.id)??null}),a.kind!==`idle`&&n(se,{drain:a})]})}function qe({row:e}){let t=$();if(e.kind!==`instance`)return null;let r=t.locations.find(t=>t.id===e.id);if(r===void 0)return null;let i=R(r);return n(x,{variant:i===`active`?`success`:i===`disabled`?`danger`:`default`,children:V(i).label})}function Je(e){return[{key:`capacity`,header:e.capacity,notSortableReason:e.capacity,render:e=>n(Ke,{row:e})},{key:`mode`,header:e.mode,nowrap:!0,notSortableReason:e.mode,render:e=>n(qe,{row:e})}]}function Ye(e,t,n){return!(n===`single`||t.length<=1||z(R(e))&&t.filter(e=>z(R(e))).length<=1)}a();var Xe=`storage`;function Ze({kinds:e}){let{t:r}=D(),{locations:i}=$(),a=C({}).data,o=e=>{let t=i.find(t=>t.id===e.id),n=a?.find(e=>e.id===t?.type);return t===void 0||n===void 0?!1:Ye(t,i.filter(e=>e.type===t.type),n.cardinality)},s=t(()=>Je({capacity:r(`system.storage.colCapacity`,`Capacity`),mode:r(`system.storage.colMode`,`State`)}),[r]),l=t(()=>e===void 0?void 0:t=>t.kind===`instance`&&t.kindId!==void 0&&e.includes(t.kindId),[e]);return n(ne,{functionCap:Xe,icon:c,title:r(`system.storage.title`,`Storage locations`),subtitle:r(`system.storage.subtitle`,`Where recordings, event media, artifacts and backups are kept. Each location is one kind on one provider; the state decides whether it takes writes, is only read, drains or is left alone.`),emptyTitle:r(`system.storage.emptyTitle`,`No storage locations yet`),emptyDescription:r(`system.storage.noStorageLocationsDeclaredBy`,`No storage locations declared by any installed addon.`),addLabel:r(`system.storage.addLocation`,`Add location`),extraColumns:s,lead:e=>n(Ge,{row:e}),canDelete:o,rowActions:e=>o(e)?n(ie,{row:e}):null,...l===void 0?{}:{rowFilter:l}})}export{P as n,ce as r,Ze as t};
@@ -1 +0,0 @@
1
- import{_a as e}from"./player-overlays-Dikds8gI.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};