@camstack/addon-admin-ui 1.2.469 → 1.2.471

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 (138) hide show
  1. package/dist/assets/{AddonAssetIcon-BN_SqLNB.js → AddonAssetIcon-D4joXvAw.js} +1 -1
  2. package/dist/assets/Addons-BNo3Y3g8.js +4 -0
  3. package/dist/assets/{AdminPage-DpgHJ_lQ.js → AdminPage-92KQDOBy.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-BfaO7MK2.js → AdminSectionedPage-B-MH77Vx.js} +1 -1
  5. package/dist/assets/AiProfiles-CTHbBMUB.js +3 -0
  6. package/dist/assets/{BrokerForm-CR-FYodQ.js → BrokerForm-HjHrcv-P.js} +1 -1
  7. package/dist/assets/Build-Dlf7sJhk.js +40 -0
  8. package/dist/assets/Calendars-YnCFbUE7.js +1 -0
  9. package/dist/assets/Cluster-C4BsKola.js +1 -0
  10. package/dist/assets/CompositionCreateForm-D_Nmi2nG.js +1 -0
  11. package/dist/assets/{CompositionEditorPage-Bi49T0M9.js → CompositionEditorPage-CdJtfEi1.js} +1 -1
  12. package/dist/assets/Data-DkPbjXNV.js +2 -0
  13. package/dist/assets/DeviceDetail-BSWf6l6J.js +2 -0
  14. package/dist/assets/{DeviceDoActionFields-Dj3iwIxJ.js → DeviceDoActionFields-B7UlBxQ0.js} +1 -1
  15. package/dist/assets/{Devices-b30LmB9b.js → Devices-BAfbzc8b.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-ChjJRAKP.js → EmbedPlayerPage-CZM7W_SR.js} +1 -1
  17. package/dist/assets/History-BfD8lMf9.js +1 -0
  18. package/dist/assets/Identity-6QdzCJrT.js +1 -0
  19. package/dist/assets/IntegrationDetail-B4X-8vcl.js +1 -0
  20. package/dist/assets/IntegrationHub-DCSIyXBI.js +1 -0
  21. package/dist/assets/Integrations-JcvhEroF.js +1 -0
  22. package/dist/assets/Integrations-XcsYTI2I.js +1 -0
  23. package/dist/assets/{Library-BMuv5B5Y.js → Library-X3g7Mvql.js} +1 -1
  24. package/dist/assets/Locations-C--r0_cW.js +3 -0
  25. package/dist/assets/{Logs-DOCwfH5l.js → Logs-C7Z3D9TY.js} +1 -1
  26. package/dist/assets/{MaskShapeCanvas-CC7FQGtr.js → MaskShapeCanvas-wRO0Yeyg.js} +1 -1
  27. package/dist/assets/{MotionZonesSettings-dcIXFXNn.js → MotionZonesSettings-C8wTUqjQ.js} +1 -1
  28. package/dist/assets/{MyAccess-BAfQ0omi.js → MyAccess-Di7tv0VI.js} +1 -1
  29. package/dist/assets/{Network-CMwPBd3q.js → Network-3FZdyZoe.js} +1 -1
  30. package/dist/assets/NodeAddonsSettingsPanel-ivhHs40k.js +1 -0
  31. package/dist/assets/Notifications-D4LJlejx.js +1 -0
  32. package/dist/assets/{Pipeline-UmUovK0W.js → Pipeline-BMhn1YbR.js} +1 -1
  33. package/dist/assets/{PrivacyMaskSettings-CreIjx4O.js → PrivacyMaskSettings-DTetXxIV.js} +1 -1
  34. package/dist/assets/Recordings-Ct8JWW27.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-CJo685Vl.js → ScanNetworkModal-DPHdPawS.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-Dbzxlt43.js → SceneMonitorEditor-KPTdSp1h.js} +1 -1
  37. package/dist/assets/SessionsList-DrklEq9Z.js +2 -0
  38. package/dist/assets/{Showroom-Bpwjw60m.js → Showroom-2gQYW-h2.js} +1 -1
  39. package/dist/assets/{System-C-jh6PsN.js → System-CDHw7Mcx.js} +1 -1
  40. package/dist/assets/{Terminal-Bu3buJrm.js → Terminal-UXpMvEO1.js} +5 -5
  41. package/dist/assets/{Viewer-BOQnbvad.js → Viewer-ukAW_oJQ.js} +1 -1
  42. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BFYsDhiM.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-KG1b6CPN.js} +1 -1
  43. package/dist/assets/{addon-icons-context-BVn71jKb.js → addon-icons-context-gPkLZQ_G.js} +1 -1
  44. package/dist/assets/{archive-CDQuI03w.js → archive-CxbMF2yZ.js} +1 -1
  45. package/dist/assets/{assignment-candidates-grX3ScPd.js → assignment-candidates-CQGwwSSC.js} +1 -1
  46. package/dist/assets/{authed-media-cSR4diHc.js → authed-media-DpHGiSZS.js} +1 -1
  47. package/dist/assets/{bell-off-hTkIlZL4.js → bell-off-CAN5HeZI.js} +1 -1
  48. package/dist/assets/{board-model-Bj95FOjc.js → board-model-C6IplvmC.js} +1 -1
  49. package/dist/assets/{boxes-0BuMQdjm.js → boxes-BIYyTH0E.js} +1 -1
  50. package/dist/assets/circle-slash-BWtbQj2T.js +1 -0
  51. package/dist/assets/client-BnEPcD6s.js +358 -0
  52. package/dist/assets/{cloud-upload-DYU5_O7N.js → cloud-upload-DvGDSWZB.js} +1 -1
  53. package/dist/assets/crop-CDWciXWB.js +1 -0
  54. package/dist/assets/{device-integration-icon-DNoJ6Lw6.js → device-integration-icon-CRiv1vER.js} +1 -1
  55. package/dist/assets/device-picker-model-DPfjZqVB.js +1 -0
  56. package/dist/assets/{dist-dJmkuSsT.js → dist-BeSobRch.js} +1 -1
  57. package/dist/assets/dist-CMwJjIGP.js +358 -0
  58. package/dist/assets/{eraser-BUbQF_qS.js → eraser-CvXO1d9P.js} +1 -1
  59. package/dist/assets/event-targets-CIffOoYs.js +2 -0
  60. package/dist/assets/{format-DftZhYTz.js → format-Cz7vHmZ6.js} +1 -1
  61. package/dist/assets/{hard-drive-download-DP_8o52c.js → hard-drive-download-xDn3u92n.js} +1 -1
  62. package/dist/assets/{hostInit-BlSFN2dH.js → hostInit-Bcdd4neZ.js} +1 -1
  63. package/dist/assets/i18n-DsGcRtAk.js +1 -0
  64. package/dist/assets/{icons-Btlc6YJV.js → icons-Uf4a8HzM.js} +1 -1
  65. package/dist/assets/index-CgxpaFwe.js +4 -0
  66. package/dist/assets/{key-Cacr-75P.js → key-D63R1Jty.js} +1 -1
  67. package/dist/assets/{key-round-DCaU9cAg.js → key-round-BH39VAkM.js} +1 -1
  68. package/dist/assets/{layers-pVEq4fg_.js → layers-Cf6Xk9ts.js} +1 -1
  69. package/dist/assets/{linked-devices-model-C91IolQ1.js → linked-devices-model-DYRAb775.js} +1 -1
  70. package/dist/assets/{list-ordered-CNRSuCVQ.js → list-ordered-9heb6Myu.js} +1 -1
  71. package/dist/assets/{location-owned-usage-O8_VY4bA.js → location-owned-usage-DPBYs4L0.js} +1 -1
  72. package/dist/assets/{log-in-RS8mwxfB.js → log-in-D6jMFDmP.js} +1 -1
  73. package/dist/assets/{memory-stick-CInn2SBD.js → memory-stick-thjjQqgp.js} +1 -1
  74. package/dist/assets/{message-square-plus-DtxzVSIY.js → message-square-plus-RcviJHk6.js} +1 -1
  75. package/dist/assets/{mf-entry-bootstrap-0-a3d5bda4.js → mf-entry-bootstrap-0-cbb0c272.js} +2 -2
  76. package/dist/assets/{mic-off-eN_vb8k3.js → mic-off-DvjWBZuR.js} +1 -1
  77. package/dist/assets/{monitor-off-Eo26fk7G.js → monitor-off-DEBUzb17.js} +1 -1
  78. package/dist/assets/{monitor-smartphone-BXr9qaoG.js → monitor-smartphone-rIimQM0r.js} +1 -1
  79. package/dist/assets/mount-DPfjZqVB.js +1 -0
  80. package/dist/assets/{player-overlays-mwQ6DKjG.js → player-overlays-DDFLUcm1.js} +1 -1
  81. package/dist/assets/{recycle-C6G9GLaW.js → recycle-CaQYaqJP.js} +1 -1
  82. package/dist/assets/remoteEntry-DqDbkZhO.js +1 -0
  83. package/dist/assets/{scan-eye-Er9mPgXz.js → scan-eye-BxF3-BiI.js} +1 -1
  84. package/dist/assets/{scissors-iGcQwqM6.js → scissors-DecmVZUv.js} +1 -1
  85. package/dist/assets/{search-x-qRfGpZh7.js → search-x-CiS8b7vy.js} +1 -1
  86. package/dist/assets/{send-goxSirGI.js → send-9ZOtM3uh.js} +1 -1
  87. package/dist/assets/{settings-2-C2T9KfF-.js → settings-2-DVEGaYSK.js} +1 -1
  88. package/dist/assets/{speaker-DTlU5qdL.js → speaker-BLIN7g-W.js} +1 -1
  89. package/dist/assets/src-CWZRb0ia.js +67 -0
  90. package/dist/assets/step-inspector-model-B6Fs3NZo.js +1 -0
  91. package/dist/assets/{timer-reset-LdV1oKRJ.js → timer-reset-ESt9DRwd.js} +1 -1
  92. package/dist/assets/{ungroup-ClPDFNDo.js → ungroup-uBZnvhmn.js} +1 -1
  93. package/dist/assets/{unlink-CCWMkIgh.js → unlink-BK0Zya0K.js} +1 -1
  94. package/dist/assets/{usb-dwGmFjnn.js → usb--Z_ViOoE.js} +1 -1
  95. package/dist/assets/{use-scenes-feed-ByvAQxt_.js → use-scenes-feed-Dpe5Lc_e.js} +1 -1
  96. package/dist/assets/{use-stationary-objects-VkCTU14h.js → use-stationary-objects-D9diuPzc.js} +1 -1
  97. package/dist/assets/useEventInvalidation-DPfjZqVB.js +1 -0
  98. package/dist/assets/{useNodeUrlSelection-DFVjdzBt.js → useNodeUrlSelection-B-NA_JqT.js} +1 -1
  99. package/dist/assets/user-round-D2ADHRLF.js +1 -0
  100. package/dist/assets/{user-x-BtLDt7oR.js → user-x-HmMRNIMy.js} +1 -1
  101. package/dist/assets/{video-DJjbkBZD.js → video-BISLfAY2.js} +1 -1
  102. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-WuGvWsfR.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-w3oA3S6D.js} +2 -2
  103. package/dist/index.html +9 -9
  104. package/dist/server/addon.js +279 -423
  105. package/package.json +10 -1
  106. package/dist/assets/Addons-D4HEweDl.js +0 -4
  107. package/dist/assets/AiProfiles-4iPHownz.js +0 -3
  108. package/dist/assets/Build-CvxS-6Fl.js +0 -40
  109. package/dist/assets/Calendars-BEL2vZe4.js +0 -1
  110. package/dist/assets/Cluster-DNceBwTk.js +0 -1
  111. package/dist/assets/CompositionCreateForm-DRDUGbPO.js +0 -1
  112. package/dist/assets/Data-DNZ19S8x.js +0 -2
  113. package/dist/assets/DeviceDetail-DLdtY5JV.js +0 -2
  114. package/dist/assets/History-CR49b6FJ.js +0 -1
  115. package/dist/assets/Identity-D7lmTPbJ.js +0 -1
  116. package/dist/assets/IntegrationDetail-CWCcdpCz.js +0 -1
  117. package/dist/assets/IntegrationHub-FpZU6jWS.js +0 -1
  118. package/dist/assets/Integrations-DoyxOos9.js +0 -1
  119. package/dist/assets/Integrations-lVBfHk53.js +0 -1
  120. package/dist/assets/Locations-BgcB7ZnK.js +0 -3
  121. package/dist/assets/NodeAddonsSettingsPanel-Ck7AYA-1.js +0 -1
  122. package/dist/assets/Notifications-Bds4p5-3.js +0 -1
  123. package/dist/assets/Recordings-Cb_VFOLV.js +0 -1
  124. package/dist/assets/SessionsList-DgE-51ju.js +0 -2
  125. package/dist/assets/circle-slash-BNZPoK0U.js +0 -1
  126. package/dist/assets/client-CHpTazh3.js +0 -358
  127. package/dist/assets/crop-DOQmDtnO.js +0 -1
  128. package/dist/assets/device-picker-model-DoeAV03f.js +0 -1
  129. package/dist/assets/dist-CVdvfX2T.js +0 -358
  130. package/dist/assets/event-targets-Cfijpphw.js +0 -2
  131. package/dist/assets/i18n-CQ56JIQj.js +0 -1
  132. package/dist/assets/index-BgKj4CM9.js +0 -4
  133. package/dist/assets/mount-DoeAV03f.js +0 -1
  134. package/dist/assets/remoteEntry-BAoznONo.js +0 -1
  135. package/dist/assets/src-B5lceK9L.js +0 -67
  136. package/dist/assets/step-inspector-model-rJIkKDaR.js +0 -1
  137. package/dist/assets/useEventInvalidation-DoeAV03f.js +0 -1
  138. package/dist/assets/user-round-TUECAUsL.js +0 -1
@@ -0,0 +1,3 @@
1
+ import{$ as e,B as t,G as n,J as r,S as i,b as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{$i as c,Di as l,Fn as u,Gi as d,Hr as f,Ht as p,It as m,Lr as h,Mi as g,O as _,Pi as v,Pr as y,Ri as b,Rt as x,Ur as S,V as C,bn as w,cn as T,dt as E,ea as D,ei as O,en as k,fi as A,gr as j,k as M,kn as N,lr as P,pn as F,pt as I,rn as L,rr as R,ta as z,tr as ee,ur as B,ut as te,xi as ne,yi as V,z as H,zt as re}from"./player-overlays-DDFLUcm1.js";import{Br as ie,Rr as ae,vn as oe}from"./client-BnEPcD6s.js";import{t as se}from"./boxes-BIYyTH0E.js";import{n as ce,r as le,t as ue}from"./speaker-BLIN7g-W.js";import{t as U}from"./user-round-D2ADHRLF.js";import{Br as de,Do as fe,Eo as pe,Gr as me,Hn as W,Hr as G,Ju as K,L as he,La as ge,Ma as _e,Mo as ve,Na as ye,Pa as be,To as xe,Uu as q,Vn as Se,Xu as Ce,Yr as we,Yu as Te,_t as Ee,bn as J,bo as De,dn as Oe,do as ke,dr as Ae,hr as je,lo as Me,lr as Ne,mr as Pe,po as Fe,pr as Ie,so as Le,un as Re,uo as ze,ur as Be,vo as Ve,wo as He,xo as Ue,yo as We}from"./src-CWZRb0ia.js";import{t as Y}from"./i18n-DsGcRtAk.js";import{t as X}from"./useTranslation-D3Is_4B6.js";import{dr as Z,hr as Ge,m as Ke,pr as qe}from"./index-CgxpaFwe.js";import{t as Je}from"./AdminSectionedPage-B-MH77Vx.js";import{a as Ye,n as Xe,r as Ze}from"./linked-devices-model-DYRAb775.js";e();var Qe={camera:l,hub:ce,container:se,light:B,siren:L,switch:re,sensor:z,thermostat:p,climate:D,button:A,"event-emitter":te,update:le,notifier:b,script:F,automation:I,lock:R,cover:v,valve:S,humidifier:f,"water-heater":y,fan:h,"media-player":ue,"alarm-panel":T,control:k,presence:U,weather:O,vacuum:g,"lawn-mower":x,image:j,smoke:c};function Q({type:e,className:t}){return s(Qe[e]??A,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function $e({online:e,deviceName:t}){return s(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":Y.t(`locations.deviceGlyphs.aria`,{name:t,state:e?Y.t(`common.online`):Y.t(`common.offline`)}),title:e?Y.t(`common.online`):Y.t(`common.offline`)})}function et({open:e,title:n,items:a,listState:o,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=X(),[h,g]=r([]);t(()=>{e||g([])},[e]);let _=new Map(a.map(e=>[e.id,e.name])),v=(u?.ids??[]).filter(e=>_.has(e)&&!c.includes(e)),y=e=>g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return s(Ne,{open:e,onOpenChange:e=>e?void 0:p(),children:i(Ae,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":n,children:[s(Pe,{children:s(je,{children:n})}),i(Be,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[e&&u!==null&&v.length>0&&i(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[s(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),s(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>s(`button`,{type:`button`,"aria-pressed":h.includes(e),className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${h.includes(e)?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`}`,onClick:()=>y(e),children:_.get(e)},e))})]}),e&&s(he,{devices:a,listState:o,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),i(Ie,{children:[s(G,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),s(G,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}e();function tt({room:e,cameras:t,fleet:r}){let{t:i}=X(),a=n(()=>new Map(r.map(e=>[e.id,e])),[r]);return e===null?s(`p`,{className:`text-xs text-foreground-subtle`,children:i(`locations.links.noRoom`)}):s(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:t.length===0?s(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:i(`locations.links.noCameras`,{room:e})}):t.map(e=>s(rt,{camera:e,byId:a},e.id))})}function nt(e){return{id:e.deviceId,name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,type:e.type,location:e.location}}function rt({camera:e,byId:t}){let{t:n}=X(),a=o(),c=qe(),[l,u]=r(!1),[d,f]=r(null),p=ye({deviceId:e.id}),m=Ze({status:p.status,data:p.data,error:p.error===null||p.error===void 0?null:p.error}),h=be(),g=m.kind===`present`?m:null,v=_e({deviceId:e.id,slotRef:g?.slot.slotRef??``},{enabled:l&&g!==null}),y=g===null?[]:Xe(g.slot,g.value),b=y.map(e=>e.deviceId),x=(v.data?.candidates??[]).map(nt),S=new Set(x.map(e=>e.id)),C=b.filter(e=>!S.has(e)).map(e=>{let n=t.get(e);return{id:e,name:n?.name??`#${String(e)}`,...n===void 0?{}:{type:n.type,location:n.location}}}),w=[...x,...C],T=(v.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),E=async t=>{if(g!==null){f(null);try{await h.mutateAsync({deviceId:e.id,slotRef:g.slot.slotRef,value:Ye(g.value,t)}),await p.refetch(),await a.invalidateQueries({queryKey:[[`deviceManager`]]}),u(!1)}catch(e){f(e instanceof Error?e.message:String(e))}}},D=[{key:`device`,header:n(`locations.columns.device`),notSortableReason:n(`locations.columns.noSort`),render:e=>{let r=t.get(e.deviceId),a=e.name??r?.name??`#${String(e.deviceId)}`;return i(`span`,{className:`flex items-center gap-1.5`,children:[r!==void 0&&s(Q,{type:r.type}),s(Z,{to:`/devices/${String(e.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:a}),e.implied&&s(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`locations.links.implied`)})]})}},{key:`type`,header:n(`locations.columns.type`),notSortableReason:n(`locations.columns.noSort`),render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:t.get(e.deviceId)?.type??`—`})},{key:`status`,header:n(`locations.columns.status`),notSortableReason:n(`locations.columns.noSort`),render:e=>{let r=t.get(e.deviceId);return r===void 0?s(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:r.online,deviceName:r.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:r.online?n(`common.online`):n(`common.offline`)})]})}}];return i(`section`,{className:`min-w-0 ${_}`,"data-testid":`camera-links-${String(e.id)}`,children:[i(`header`,{className:`${M} flex min-h-9 items-center gap-1.5`,children:[s(Q,{type:e.type}),s(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e.name}),i(G,{variant:`ghost`,size:`sm`,onClick:()=>c(Ke(e.id)),children:[s(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`locations.links.edit`)]}),s(G,{variant:`outline`,size:`sm`,disabled:g===null,onClick:()=>u(!0),"aria-label":n(`locations.links.addNamed`,{camera:e.name}),children:n(`locations.room.add`)})]}),m.kind===`pending`&&s(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.loading`)}),m.kind===`unknown`&&s(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:n(`locations.links.unreadable`,{reason:m.reason})}),m.kind===`absent`&&s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.unsupported`)}),d!==null&&s(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:d}),g!==null&&(y.length===0?s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.none`)}):s(J,{columns:D,rows:y,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),s(et,{open:l,title:n(`locations.links.pickTitle`,{camera:e.name}),items:w,listState:v.status===`error`?`failed`:v.data===void 0?`pending`:`answered`,lockedIds:b,lockedNote:n(`locations.links.alreadyLinked`),suggestions:e.location===null?null:{heading:n(`locations.links.suggested`,{room:e.location}),ids:T},busy:h.isPending,onConfirm:e=>void E(e),onClose:()=>u(!1)})]})}e();function it({name:e,description:n,busy:a,onSave:o}){let{t:c}=X(),[l,u]=r(n??``);return t(()=>{u(n??``)},[n]),i(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[s(W,{htmlFor:`location-description-${e}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),s(`textarea`,{id:`location-description-${e}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(n??``)&&o(e.length===0?null:e)},disabled:a,rows:2,maxLength:400,placeholder:c(`locations.locationDescriptionField.surfacesBoundariesWhatIsNormally`,`Surfaces, boundaries, what is normally parked or stored here.`),className:`mt-1 w-full resize-y rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50`}),s(`p`,{className:`mt-1 ${H}`,children:c(`locations.locationDescriptionField.givenToTheAiWith`,`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`)})]})}function at(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var ot=` none`;function st({name:e,zones:t,zoneKey:n,busy:r,onChange:a}){let{t:o}=X();if(t.length===0)return null;let c=[{value:ot,label:o(`locations.locationZoneField.none`,`— none —`)},...t.map(e=>({value:e.zoneKey,label:e.label}))];return i(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[s(W,{htmlFor:`location-zone-${e}`,children:o(`locations.locationZoneField.zone`,`Zone`)}),s(q,{id:`location-zone-${e}`,value:n??ot,disabled:r,onChange:e=>{let n=e.target.value;if(n===ot){a(null);return}let r=t.find(e=>e.zoneKey===n);r!==void 0&&a(r.label)},options:c})]})}function ct(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function lt({name:e,icon:t,busy:n,onPick:r}){return s(Ce,{value:t,onPick:r,fallbackGlyph:ee,clearGlyph:d,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:n})}function ut(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:ie(n.icon)??`map-pin`}function $(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function dt(e,t){let n=$(t);return n===null?[]:e.filter(e=>$(e.location)===n)}function ft(e,t){let n=dt(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function pt(e,t){let n=$(e.location);return n===null||new Set(t.map(e=>$(e))).has(n)?null:e.location?.trim()??null}function mt(e,t){let n=$(e.location);return n!==null&&t.has(n)}function ht(e,t){let n=new Set(t.map(e=>$(e))),r=new Set(e.filter(e=>mt(e,n)).map(e=>e.id));return e.filter(e=>!(mt(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function gt(e,t){return ht(e,t).filter(e=>e.parentDeviceId===null)}function _t(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function vt(e,t){return _t(e,t).length}function yt(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function bt(e,t){return t.map(t=>({name:t,members:ft(e,t)}))}function xt(e){return`${e.kind}:${String(e.device.id)}`}function St(e,t,n){return e.flatMap(e=>{let r=yt(t,e.id),i=n.has(e.id),a={kind:`member`,device:e,accessories:r,open:i};return!i||r.length===0?[a]:[a,...r.map(t=>({kind:`accessory`,device:t,parent:e}))]})}e();function Ct({name:e,members:t,devices:o,busy:c,icon:l,description:d,onRename:f,onDelete:p,onRebuildLinks:h,onAddDevices:g,onPickIcon:v,onSaveDescription:y,zones:b,zoneKey:x,onChangeZone:S}){let{t:C}=X(),[T,D]=r(!1),[O,k]=r(e),A=Re(t,n(()=>({searchText:e=>[e.name,...yt(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[j,N]=r(()=>new Set),P=e=>N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),F=n(()=>St(A.rows,o,j),[A.rows,o,j]),I=[{key:`name`,header:C(`locations.columns.device`),notSortableReason:C(`locations.columns.noSort`),render:e=>e.kind===`member`?s(wt,{row:e,onToggle:()=>P(e.device.id)}):s(Tt,{row:e})},{key:`type`,header:C(`locations.columns.type`),notSortableReason:C(`locations.columns.noSort`),render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:C(`locations.columns.status`),notSortableReason:C(`locations.columns.noSort`),render:e=>i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:e.device.online,deviceName:e.device.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:e.device.online?C(`common.online`):C(`common.offline`)})]})}],L=()=>{k(e),D(!1)},R=async()=>{let t=O.trim();if(t.length===0||t===e){L();return}await f(t),D(!1)},z=[{id:`rename`,label:C(`locations.locationCard.rename`,`Rename`),icon:u,disabled:c,onClick:()=>{k(e),D(!0)}},{id:`rebuild-links`,label:C(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:w,separatorBefore:!0,disabled:c,onClick:()=>void h()},{id:`delete`,label:C(`common.delete`,`Delete`),icon:m,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void p()}];return i(`section`,{className:`min-w-0 ${_}`,children:[i(`header`,{className:`${M} flex min-h-9 items-center gap-1.5`,children:[s(lt,{name:e,icon:l,busy:c,onPick:v}),T?i(a,{children:[s(K,{value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&R(),e.key===`Escape`&&L()},"aria-label":C(`locations.locationCard.rename2`,`Rename {{name}}`,{name:e}),className:`min-w-0 flex-1`,autoFocus:!0}),s(G,{type:`button`,size:`sm`,onClick:()=>void R(),children:C(`common.save`,`Save`)}),s(Te,{type:`button`,variant:`ghost`,icon:E,onClick:L,"aria-label":C(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):i(a,{children:[s(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),s(G,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:g,"aria-label":C(`locations.room.addTo`,{room:e}),children:C(`locations.room.add`)}),s(Ee,{items:z,title:C(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:e}),triggerClassName:`p-1`})]})]}),s(st,{name:e,zones:b,zoneKey:x,busy:c,onChange:S}),s(it,{name:e,description:d,busy:c,onSave:y}),t.length>0&&s(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:s(Oe,{state:A.state,facets:A.facets,labels:{searchPlaceholder:C(`locations.filter.searchPlaceholder`),searchLabel:C(`locations.room.searchLabel`,{room:e}),facetsLabel:C(`locations.filter.typesLabel`),clearLabel:C(`locations.filter.clear`)},onSearch:A.setSearch,onToggleFacet:A.toggleFacet,onClear:A.clear})}),t.length===0?s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:C(`locations.locationCard.nothingHereYetAssignA`,`Nothing here yet — assign a device from the table below.`)}):s(J,{columns:I,rows:F,rowKey:xt,bordered:!1,minWidthPx:360,emptyMessage:C(`locations.filter.noMatch`)})]})}function wt({row:e,onToggle:t}){let{t:n}=X(),{device:r,accessories:a,open:o}=e,c=o?ne:V;return i(`span`,{className:`flex items-center gap-1.5`,children:[a.length>0?i(G,{type:`button`,variant:`ghost`,onClick:t,"aria-expanded":o,"aria-label":n(o?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:a.length,name:r.name}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[s(c,{className:`h-3 w-3`}),s(`span`,{className:`text-[10px] tabular-nums`,children:a.length})]}):s(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),s(Q,{type:r.type}),s(Z,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:r.name})]})}function Tt({row:e}){let{device:t}=e;return i(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[s(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),s(Q,{type:t.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),s(Z,{to:`/devices/${String(t.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:t.name})]})}e();function Et({zones:e,busy:t,onRename:n,onDelete:i,onPickIcon:a}){let{t:o}=X(),[c,l]=r(null),[u,d]=r(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await n(e,t)};return s(J,{columns:[{key:`icon`,header:o(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>s(lt,{name:e.label,icon:e.icon,busy:t,onPick:t=>a(e.label,t)})},{key:`name`,header:o(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?s(K,{value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(e.label),t.key===`Escape`&&l(null)},onBlur:()=>void f(e.label),"aria-label":o(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):s(G,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:o(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:o(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>s(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?o(`common.empty`):o(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:o(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>s(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void i(e.label),disabled:t,"aria-label":o(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:o(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:s(m,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:o(`locations.siteZonesPanel.noZonesYetAZone`,`No zones yet. A zone groups rooms — “Night zone” for the bedrooms — and shows up before them in the app’s camera filter.`)})}e();function Dt({busy:e,onCreate:t}){let{t:n}=X(),[a,o]=r(!1),[c,l]=r(``),u=()=>{l(``),o(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await t(e),u())};return a?i(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[s(K,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:n(`locations.newLocationButton.frontDoorHallKitchen`,`Front door, Hall, Kitchen…`),"aria-label":n(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),i(G,{size:`sm`,type:`submit`,disabled:c.trim().length===0||e,children:[s(N,{className:`h-3.5 w-3.5`}),n(`common.add`,`Add`)]}),s(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":n(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:s(E,{className:`h-3.5 w-3.5`})})]}):i(G,{size:`sm`,type:`button`,onClick:()=>o(!0),"data-testid":`new-location-button`,children:[s(N,{className:`h-3.5 w-3.5`}),n(`locations.newLocationButton.newLocation`,`New location`)]})}e();function Ot({busy:e,onCreate:t}){let{t:n}=X(),[a,o]=r(!1),[c,l]=r(``),u=()=>{l(``),o(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await t(e),u())};return a?i(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[s(K,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:n(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Night zone…`),"aria-label":n(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),i(G,{size:`sm`,type:`submit`,disabled:c.trim().length===0||e,children:[s(N,{className:`h-3.5 w-3.5`}),n(`common.add`,`Add`)]}),s(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":n(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:s(E,{className:`h-3.5 w-3.5`})})]}):i(G,{size:`sm`,type:`button`,onClick:()=>o(!0),"data-testid":`new-zone-button`,children:[s(N,{className:`h-3.5 w-3.5`}),n(`locations.newZoneButton.newZone`,`New zone`)]})}e();function kt(e,t,n,r){let i=e.map(e=>({value:e.name,label:`${e.name} · ${String(e.count)}`}));return t===void 0?i:[...i,{value:n,label:`${r} · ${String(t)}`}]}function At({rooms:e,unassignedCount:t,value:r,unassignedValue:i,onChange:a}){let{t:o}=X(),c=n(()=>kt(e,t,i,o(`locations.roomPicker.unassigned`)),[e,t,i,o]);return s(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:s(me,{mode:`single`,singleDisplay:`field`,label:o(`locations.roomPicker.label`),placeholder:o(`locations.roomPicker.placeholder`),options:c,value:r,onChange:a,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}e();var jt={searchText:e=>[e.name],facetValue:e=>e.type};function Mt({rows:e,fleet:t,locations:a,busy:o,emptyMessage:c,onAssign:l}){let{t:u}=X(),[d,f]=r([]),[p,m]=r(``),h=Re(e,jt),g=h.rows,_=n(()=>g.map(e=>e.id),[g]),v=n(()=>d.filter(e=>_.includes(e)),[d,_]),y=g.length>0&&v.length===g.length,b=n(()=>{let n=new Map;for(let r of e)n.set(r.id,vt(t,r.id));return n},[e,t]),x=v.reduce((e,t)=>e+(b.get(t)??0),0),S=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),w=()=>f(y?[]:_),T=()=>{p.length===0||v.length===0||(l(v,p),f([]),m(``))},E=a.map(e=>({value:e,label:e})),D=[{key:`select`,width:`w-8`,headerRender:()=>s(Se,{checked:y,onChange:w,"aria-label":y?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>s(Se,{checked:v.includes(e.id),onChange:()=>S(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:e.name})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:e=>{let t=pt(e,a);return i(`span`,{className:`flex items-center gap-1.5`,children:[s(Q,{type:e.type}),s(Z,{to:`/devices/${String(e.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:e.name}),t!==null&&s(we,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:t})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:e=>i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:e.online,deviceName:e.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:e.online?u(`common.online`):u(`common.offline`)})]})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>b.get(e.id)??0,render:e=>s(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:b.get(e.id)??0})},{key:`assign`,header:u(`locations.unassignedTable.assignTo`,`Assign to`),align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>s(q,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:e.name}),value:``,disabled:o||a.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...E]})}];return i(`section`,{className:`space-y-2`,children:[i(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[s(`h2`,{className:C,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),s(`p`,{className:H,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),e.length>0&&s(Oe,{state:h.state,facets:h.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:h.setSearch,onToggleFacet:h.toggleFacet,onClear:h.clear}),v.length>0&&i(`div`,{role:`group`,"aria-label":u(`locations.unassignedTable.bulkAssignment`,`Bulk assignment`),className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[i(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:v.length}),x>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:x})}`]}),s(q,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:p,onChange:e=>m(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...E]}),s(G,{type:`button`,size:`sm`,onClick:T,disabled:o||p.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),s(G,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>f([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),s(J,{columns:D,rows:g,rowKey:e=>e.id,minWidthPx:720,emptyMessage:h.active?u(`locations.filter.noMatch`):c})]})}function Nt(e){return{id:e.id,parentDeviceId:e.parentDeviceId,location:e.location,type:e.type,stableId:e.stableId??``,...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function Pt(e,t){let n=t.map(Nt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:oe({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var Ft=`device-manager:linked-devices`;function It(e){return{deviceId:e.deviceId,slotRef:Ft,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}e();var Lt=`__unassigned__`;function Rt(){let{t:e}=X(),t=o(),a=de(),{data:c,isLoading:l}=ke(),{data:u}=ze(),{data:d}=Me(),{data:f}=Fe(),{data:p,isLoading:m}=Le({projection:`slim`}),h=()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},g=ge({onSuccess:h}),_=Ve({onSuccess:h}),v=He({onSuccess:h}),y=De({onSuccess:h}),b=pe({onSuccess:h}),x=xe({onSuccess:h}),S=ve({onSuccess:h}),C=We({onSuccess:h}),w=Ue({onSuccess:h}),T=fe({onSuccess:h}),E=be(),D=n(()=>(p??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null})),[p]),O=c??[],k=n(()=>bt(D,O),[D,O]),[A,j]=Ge(),M=A.get(`tab`),N=M===`zones`||M===`camera-links`?M:`locations`,P=A.get(`room`),F=n(()=>gt(D,O),[D,O]),I=P===Lt,L=I?null:P!==null&&k.some(e=>e.name===P)?P:k[0]?.name??null,R=L===null?null:k.find(e=>e.name===L)??null,z=I?Lt:L??`__unassigned__`,B=L??k[0]?.name??null,te=n(()=>k.map(e=>({name:e.name,count:e.members.length})),[k]),ne=e=>{j(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},V=l||m,H=v.isPending||_.isPending||g.isPending||b.isPending,re=async e=>{await g.mutateAsync({name:e})},ie=async(e,t)=>{let n=t.trim();n.length===0||n===e||await y.mutateAsync({from:e,to:n})},oe=async t=>{let n=Pt(t,D);if(n.entries.length===0){await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:t}),confirmLabel:`OK`});return}let r=n.entries.map(t=>e(`locations.rebuildEntry`,{name:t.name,count:t.ids.length})).join(`
2
+ `);if(!await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.replaceTheLinkedDeviceList`,`Replace the linked-device list of every camera in “{{room}}” with what the room contains? {{lines}} Anything linked by hand that is not in this room is lost.`,{room:t,lines:r}),confirmLabel:e(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of n.entries)try{await E.mutateAsync(It(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}h(),i.length>0&&await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
3
+ `)}),confirmLabel:`OK`})},se=async(t,n)=>{let r=n>0?` ${String(n)} device(s) will become unassigned.`:``;await a({title:e(`locations.deleteLocation`,`Delete location`),message:e(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:t,extra:r}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&await _.mutateAsync({name:t,cascade:!0})},ce=async t=>{await a({title:e(`locations.deleteZone`,`Delete zone`),message:e(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:t}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&await C.mutateAsync({name:t})},le=async(e,t)=>{await b.mutateAsync({location:e,icon:t})},ue=async(e,t)=>{await x.mutateAsync({location:e,description:t})},U=f??[],me=async(e,t)=>{await T.mutateAsync({location:e,zone:t})},W=(e,t)=>{for(let n of e)v.mutate({deviceId:n,location:t})},[G,K]=r(null),he=n(()=>D.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[D]),_e=s(At,{rooms:te,...N===`locations`?{unassignedCount:F.length}:{},value:N===`locations`?z:B??``,unassignedValue:Lt,onChange:ne}),ye=i(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[V&&s(`p`,{className:`text-xs text-foreground-subtle`,children:e(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),_e,I||R===null?s(Mt,{rows:F,fleet:D,locations:O,busy:H,emptyMessage:V?e(`common.loading`,`Loading…`):e(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:W}):s(Ct,{name:R.name,members:R.members,devices:D,busy:H,icon:ut(u,ae(R.name)),onPickIcon:e=>le(R.name,e),description:at(d,ae(R.name)),onSaveDescription:e=>ue(R.name,e),zones:U,zoneKey:ct(U,ae(R.name)),onChangeZone:e=>me(R.name,e),onRename:e=>ie(R.name,e),onDelete:()=>se(R.name,dt(D,R.name).length),onRebuildLinks:()=>oe(R.name),onAddDevices:()=>K(R.name)},R.name),O.length===0&&!V&&s(`p`,{className:`text-xs text-foreground-subtle`,children:e(`locations.noLocationsYetAddFrontDoor`,`No locations yet. Add Front door, Hall, Kitchen…`)}),s(et,{open:G!==null,title:e(`locations.room.addDialogTitle`,{room:G??``}),items:he,listState:m?`pending`:`answered`,lockedIds:G===null?[]:(k.find(e=>e.name===G)?.members??[]).map(e=>e.id),lockedNote:e(`locations.room.alreadyHere`),suggestions:{heading:e(`locations.room.suggestedUnassigned`),ids:F.map(e=>e.id)},busy:v.isPending,onConfirm:e=>{G!==null&&W(e,G),K(null)},onClose:()=>K(null)})]}),q=i(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[_e,s(tt,{room:B,cameras:B===null?[]:dt(D,B).filter(e=>e.isCamera),fleet:D})]});return s(Je,{icon:ee,title:e(`locations.locations`,`Locations`),subtitle:e(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:N===`zones`?s(Ot,{busy:S.isPending,onCreate:e=>S.mutateAsync({name:e})}):s(Dt,{busy:g.isPending,onCreate:re}),sections:[{id:`locations`,label:e(`locations.locations`,`Locations`),content:ye},{id:`camera-links`,label:e(`locations.cameraLinks`,`Camera links`),content:q},{id:`zones`,label:e(`locations.zones`,`Zones`),content:s(Et,{zones:U,busy:H,onRename:(e,t)=>w.mutateAsync({from:e,to:t}),onDelete:ce,onPickIcon:(e,t)=>S.mutateAsync({name:e,icon:t})})}]})}export{Rt as LocationsPage};
@@ -1 +1 @@
1
- import{$ as e,G as t,J as n,S as r,x as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Di as a,Si as o,or as s,pn as c,ta as l}from"./player-overlays-mwQ6DKjG.js";import{n as u,t as d}from"./timer-reset-LdV1oKRJ.js";import{t as f}from"./layers-pVEq4fg_.js";import{Zt as p,ad as m,au as h,mi as g,nu as _,pi as v}from"./src-B5lceK9L.js";import{t as y}from"./useTranslation-D3Is_4B6.js";import{a as b,i as x,x as S}from"./index-BgKj4CM9.js";import{t as C}from"./AdminSectionedPage-BfaO7MK2.js";import{t as w}from"./AdminPage-DpgHJ_lQ.js";import{n as T,t as E}from"./IntegrationHub-FpZU6jWS.js";import{n as D,t as O}from"./addon-display-names-BkwMrExv.js";e();var k=5e3,A=`log-destination`,j={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function M(){let{t:e}=y(),n=g({capName:`log-destination`},{refetchInterval:k}),r=v(void 0,{refetchInterval:k}),a=t(()=>O(r.data??[]),[r.data]),o=t(()=>{let e=new Map;for(let t of r.data??[]){let n=t.description,r=t.id;typeof r==`string`&&typeof n==`string`&&n.length>0&&e.set(r,n)}return e},[r.data]),s=t(()=>(n.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive,caption:o.get(e.addonId)??j[e.addonId]??``})),[n.data,a,o]),l=[{id:A,label:e(`system.logging.logDestinations`,`Log destinations`),entries:s.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:u,...D(e.isActive),render:()=>i(T,{addonId:e.addonId,displayName:e.displayName,capName:A,isActive:e.isActive,badges:e.caption.length>0?i(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.caption}):null})}))}];return i(E,{embedded:!0,icon:c,title:e(`system.logging.destinations`,`Destinations`),subtitle:e(`system.logging.everyRegisteredLogDestinationEntries`,`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another.`),groups:l,isLoading:n.isLoading,emptyTitle:e(`system.logging.noLogDestinationsRegistered`,`No log destinations registered`),emptyDescription:e(`system.logging.thisShouldNotHappenThe`,`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`)})}e();var N=[12e4,3e5,6e5,18e5],P={"request-census":`Counts every tRPC call by TRANSPORT PLANE — http, ws, mesh — and by procedure, caller, address and user-agent. Subscriptions are counted apart from calls, so a long-lived stream cannot pass for a storm. Arm it, then restart: the deadline is persisted, so the window is still running when clients reconnect.`};function F(){let{t:e}=y(),t=_({},{refetchInterval:5e3}),a=h(),[o,c]=n(null),u=(e,n)=>{c(e),a.mutate({patch:{diagnostics:[{id:e,armMs:n}]}},{onSettled:()=>{c(null),t.refetch()}})},d=t.data?.activeWindows??[],f=t.data?.channels??[],p=t.data?.activeChannels??[],m=(e,n,r)=>{c(e),a.mutate({patch:{channels:[{channel:e,armMs:n,deviceIds:r}]}},{onSettled:()=>{c(null),t.refetch()}})};return r(w,{embedded:!0,icon:l,title:e(`logging.diagnostics.title`,`Diagnostics`),subtitle:e(`logging.diagnostics.subtitle`,`Diagnostics are armed for a window, never switched on. Each carries a deadline and expires by itself — one left running is an incident of its own.`),children:[t.isLoading?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(s,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>i(L,{window:e,busy:o===e.id,onArm:t=>u(e.id,t)},e.id))}),i(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:e(`logging.diagnostics.channels`,`Component channels`)}),i(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.channelsSubtitle`,`Declared by the addons that own them — this list is not maintained by hand. Arming a channel opens a window with a deadline; it closes by itself.`)}),f.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:f.map(e=>i(I,{channel:e,state:p.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>m(e.name,t,n)},e.name))})]})}function I({channel:e,state:t,busy:o,onArm:s}){let{t:c}=y(),[l,u]=n(``),f=t?.armed===!0,p=()=>{let e=l.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return r(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),f?r(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[i(d,{className:`h-3 w-3`}),c(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:R(t?.remainingMs??0)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.disarmed`,`disarmed`)}),f&&t?.deviceIds!==null&&t?.deviceIds!==void 0&&r(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[i(a,{className:`h-3 w-3`}),t.deviceIds.join(`, `)]}),!e.perDevice&&i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:e.description})]}),r(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[e.perDevice&&i(`input`,{type:`text`,inputMode:`numeric`,value:l,disabled:o,onChange:e=>u(e.target.value),placeholder:c(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),N.map(e=>i(`button`,{type:`button`,disabled:o,onClick:()=>s(e,p()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:R(e)},e)),i(`button`,{type:`button`,disabled:o||!f,onClick:()=>s(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:c(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function L({window:e,busy:t,onArm:n}){let{t:a}=y();return r(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.id}),e.armed?r(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[i(d,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:R(e.remainingMs)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),e.armed&&!e.persisted&&i(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:P[e.id]??``})]}),r(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[N.map(e=>i(`button`,{type:`button`,disabled:t,onClick:()=>n(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:R(e)},e)),i(`button`,{type:`button`,disabled:t||!e.armed,onClick:()=>n(0),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:a(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function R(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}e();var z=[`debug`,`info`,`warn`,`error`],B=``,V=``;function H(){let{t:e}=y(),[a,o]=n(B),[c,l]=n(V),{nodes:u}=m(),d=t(()=>u.map(e=>({id:e.id,label:e.name||e.id})),[u]),p=_({...a===B?{}:{scopeNodeId:a},...c===V?{}:{scopeComponent:c}},{refetchInterval:15e3}),g=h(),v=p.data,b=g.isPending||p.isFetching,x=v?.channels??[],S=(e,t)=>{g.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void p.refetch()})};return i(w,{embedded:!0,icon:f,title:e(`logging.levels.title`,`Levels`),subtitle:e(`logging.levels.subtitle`,`Cluster → node, most specific wins. The floor gates what reaches the log destinations; the in-memory viewer keeps every line either way.`),actions:r(`div`,{className:`flex flex-wrap items-center gap-3`,children:[r(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.scope`,`Scope`),r(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground disabled:opacity-50`,value:a,disabled:c!==V,onChange:e=>o(e.target.value),children:[i(`option`,{value:B,children:e(`logging.levels.cluster`,`Cluster`)}),d.map(e=>i(`option`,{value:e.id,children:e.label},e.id))]})]}),r(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.component`,`Component`),r(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground`,value:c,onChange:e=>l(e.target.value),children:[i(`option`,{value:V,children:e(`logging.levels.noComponent`,`None`)}),x.map(e=>i(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:p.isLoading||v===void 0?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(s,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):r(`div`,{className:`space-y-3`,children:[i(W,{level:v.effective.level,source:v.effective.levelSource,persisted:v.persisted}),i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:v.explicit.layers.map(e=>i(G,{layer:e,inForce:e.scope===v.effective.levelSource,busy:b,onSet:t=>S(e,t),onClear:()=>S(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),c!==V&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:x.find(e=>e.name===c)?.description??``}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.levels.componentNote`,`A component is a log channel an addon declared. Its level is cluster-wide and beats both the node and the cluster layer.`)}),i(U,{days:v.opsLogRetentionDays,busy:b,onSet:e=>g.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void p.refetch()})})]})})}function U({days:e,busy:t,onSet:n}){let{t:a}=y();return r(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[r(`label`,{className:`flex items-center justify-between gap-3`,children:[i(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),r(`span`,{className:`flex items-center gap-1.5`,children:[i(`input`,{type:`number`,min:0,max:3650,step:1,defaultValue:e,disabled:t,onBlur:t=>{let r=Number.parseInt(t.target.value,10);Number.isFinite(r)&&r!==e&&n(r)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`logging.levels.opsLogRetentionNote`,`How long the record of what retention deleted is kept. Cluster-wide, and deliberately longer than any camera window — it is the history of the sweep, not of the camera, and it is what makes a storage leak explainable after the fact. 0 keeps it forever.`)})]})}function W({level:e,source:t,persisted:n}){let{t:a}=y();return r(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[r(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),i(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:e}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:t==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:t})})]}),!n&&i(`p`,{className:`mt-1 text-[11px] text-warning`,children:a(`logging.levels.notPersisted`,`The settings store could not be read or written — what you see is live, but it would not survive a restart.`)})]})}function G({layer:e,inForce:t,busy:n,onSet:a,onClear:s}){let{t:c}=y();return r(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.scope===`cluster`?c(`logging.levels.cluster`,`Cluster`):e.scope===`component`?e.component??``:e.nodeId??``}),t&&r(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[i(o,{className:`h-3 w-3`}),c(`logging.levels.inForce`,`in force`)]})]}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:e.level===null?c(`logging.levels.inherits`,`inherits — nothing set at this layer`):c(`logging.levels.setHere`,`set here: {{level}}`,{level:e.level})})]}),r(`div`,{className:`flex shrink-0 items-center gap-1`,children:[z.map(t=>i(`button`,{type:`button`,disabled:n,onClick:()=>a(t),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${e.level===t?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:t},t)),i(`button`,{type:`button`,disabled:n||e.level===null,onClick:s,className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-40`,children:c(`logging.levels.clear`,`Clear`)})]})]})}function K(){return i(w,{embedded:!0,children:i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(p,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0})})})}function q(){let{t:e}=y(),t=S(`/system/logs`,{t:e,isAdmin:!0})??{icon:c,title:e(`system.logs`,`Logs`)};return i(C,{icon:t.icon,title:t.title,defaultSection:`viewer`,sectionsLabel:`${t.title} sections`,sections:[{id:`viewer`,label:e(`admin.system.logs.viewer`,`Viewer`),content:i(K,{})},{id:b.logging.tab,label:e(`admin.system.logs.destinations`,`Destinations`),content:i(M,{}),ownedParams:x},{id:`levels`,label:e(`admin.system.logs.levels`,`Levels`),content:i(H,{})},{id:`diagnostics`,label:e(`admin.system.logs.diagnostics`,`Diagnostics`),content:i(F,{})}]})}export{q as LogsPage};
1
+ import{$ as e,G as t,J as n,S as r,x as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Di as a,Si as o,or as s,pn as c,ta as l}from"./player-overlays-DDFLUcm1.js";import{n as u,t as d}from"./timer-reset-ESt9DRwd.js";import{t as f}from"./layers-Cf6Xk9ts.js";import{Qt as p,_i as m,ld as h,lu as g,ou as _,vi as v}from"./src-CWZRb0ia.js";import{t as y}from"./useTranslation-D3Is_4B6.js";import{a as b,i as x,x as S}from"./index-CgxpaFwe.js";import{t as C}from"./AdminSectionedPage-B-MH77Vx.js";import{t as w}from"./AdminPage-92KQDOBy.js";import{n as T,t as E}from"./IntegrationHub-DCSIyXBI.js";import{n as D,t as O}from"./addon-display-names-BkwMrExv.js";e();var k=5e3,A=`log-destination`,j={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function M(){let{t:e}=y(),n=v({capName:`log-destination`},{refetchInterval:k}),r=m(void 0,{refetchInterval:k}),a=t(()=>O(r.data??[]),[r.data]),o=t(()=>{let e=new Map;for(let t of r.data??[]){let n=t.description,r=t.id;typeof r==`string`&&typeof n==`string`&&n.length>0&&e.set(r,n)}return e},[r.data]),s=t(()=>(n.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive,caption:o.get(e.addonId)??j[e.addonId]??``})),[n.data,a,o]),l=[{id:A,label:e(`system.logging.logDestinations`,`Log destinations`),entries:s.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:u,...D(e.isActive),render:()=>i(T,{addonId:e.addonId,displayName:e.displayName,capName:A,isActive:e.isActive,badges:e.caption.length>0?i(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.caption}):null})}))}];return i(E,{embedded:!0,icon:c,title:e(`system.logging.destinations`,`Destinations`),subtitle:e(`system.logging.everyRegisteredLogDestinationEntries`,`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another.`),groups:l,isLoading:n.isLoading,emptyTitle:e(`system.logging.noLogDestinationsRegistered`,`No log destinations registered`),emptyDescription:e(`system.logging.thisShouldNotHappenThe`,`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`)})}e();var N=[12e4,3e5,6e5,18e5],P={"request-census":`Counts every tRPC call by TRANSPORT PLANE — http, ws, mesh — and by procedure, caller, address and user-agent. Subscriptions are counted apart from calls, so a long-lived stream cannot pass for a storm. Arm it, then restart: the deadline is persisted, so the window is still running when clients reconnect.`};function F(){let{t:e}=y(),t=_({},{refetchInterval:5e3}),a=g(),[o,c]=n(null),u=(e,n)=>{c(e),a.mutate({patch:{diagnostics:[{id:e,armMs:n}]}},{onSettled:()=>{c(null),t.refetch()}})},d=t.data?.activeWindows??[],f=t.data?.channels??[],p=t.data?.activeChannels??[],m=(e,n,r)=>{c(e),a.mutate({patch:{channels:[{channel:e,armMs:n,deviceIds:r}]}},{onSettled:()=>{c(null),t.refetch()}})};return r(w,{embedded:!0,icon:l,title:e(`logging.diagnostics.title`,`Diagnostics`),subtitle:e(`logging.diagnostics.subtitle`,`Diagnostics are armed for a window, never switched on. Each carries a deadline and expires by itself — one left running is an incident of its own.`),children:[t.isLoading?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(s,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>i(L,{window:e,busy:o===e.id,onArm:t=>u(e.id,t)},e.id))}),i(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:e(`logging.diagnostics.channels`,`Component channels`)}),i(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.channelsSubtitle`,`Declared by the addons that own them — this list is not maintained by hand. Arming a channel opens a window with a deadline; it closes by itself.`)}),f.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:f.map(e=>i(I,{channel:e,state:p.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>m(e.name,t,n)},e.name))})]})}function I({channel:e,state:t,busy:o,onArm:s}){let{t:c}=y(),[l,u]=n(``),f=t?.armed===!0,p=()=>{let e=l.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return r(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),f?r(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[i(d,{className:`h-3 w-3`}),c(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:R(t?.remainingMs??0)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.disarmed`,`disarmed`)}),f&&t?.deviceIds!==null&&t?.deviceIds!==void 0&&r(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[i(a,{className:`h-3 w-3`}),t.deviceIds.join(`, `)]}),!e.perDevice&&i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:e.description})]}),r(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[e.perDevice&&i(`input`,{type:`text`,inputMode:`numeric`,value:l,disabled:o,onChange:e=>u(e.target.value),placeholder:c(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),N.map(e=>i(`button`,{type:`button`,disabled:o,onClick:()=>s(e,p()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:R(e)},e)),i(`button`,{type:`button`,disabled:o||!f,onClick:()=>s(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:c(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function L({window:e,busy:t,onArm:n}){let{t:a}=y();return r(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.id}),e.armed?r(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[i(d,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:R(e.remainingMs)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),e.armed&&!e.persisted&&i(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:P[e.id]??``})]}),r(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[N.map(e=>i(`button`,{type:`button`,disabled:t,onClick:()=>n(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:R(e)},e)),i(`button`,{type:`button`,disabled:t||!e.armed,onClick:()=>n(0),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:a(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function R(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}e();var z=[`debug`,`info`,`warn`,`error`],B=``,V=``;function H(){let{t:e}=y(),[a,o]=n(B),[c,l]=n(V),{nodes:u}=h(),d=t(()=>u.map(e=>({id:e.id,label:e.name||e.id})),[u]),p=_({...a===B?{}:{scopeNodeId:a},...c===V?{}:{scopeComponent:c}},{refetchInterval:15e3}),m=g(),v=p.data,b=m.isPending||p.isFetching,x=v?.channels??[],S=(e,t)=>{m.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void p.refetch()})};return i(w,{embedded:!0,icon:f,title:e(`logging.levels.title`,`Levels`),subtitle:e(`logging.levels.subtitle`,`Cluster → node, most specific wins. The floor gates what reaches the log destinations; the in-memory viewer keeps every line either way.`),actions:r(`div`,{className:`flex flex-wrap items-center gap-3`,children:[r(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.scope`,`Scope`),r(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground disabled:opacity-50`,value:a,disabled:c!==V,onChange:e=>o(e.target.value),children:[i(`option`,{value:B,children:e(`logging.levels.cluster`,`Cluster`)}),d.map(e=>i(`option`,{value:e.id,children:e.label},e.id))]})]}),r(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.component`,`Component`),r(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground`,value:c,onChange:e=>l(e.target.value),children:[i(`option`,{value:V,children:e(`logging.levels.noComponent`,`None`)}),x.map(e=>i(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:p.isLoading||v===void 0?r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(s,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):r(`div`,{className:`space-y-3`,children:[i(W,{level:v.effective.level,source:v.effective.levelSource,persisted:v.persisted}),i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:v.explicit.layers.map(e=>i(G,{layer:e,inForce:e.scope===v.effective.levelSource,busy:b,onSet:t=>S(e,t),onClear:()=>S(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),c!==V&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:x.find(e=>e.name===c)?.description??``}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.levels.componentNote`,`A component is a log channel an addon declared. Its level is cluster-wide and beats both the node and the cluster layer.`)}),i(U,{days:v.opsLogRetentionDays,busy:b,onSet:e=>m.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void p.refetch()})})]})})}function U({days:e,busy:t,onSet:n}){let{t:a}=y();return r(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[r(`label`,{className:`flex items-center justify-between gap-3`,children:[i(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),r(`span`,{className:`flex items-center gap-1.5`,children:[i(`input`,{type:`number`,min:0,max:3650,step:1,defaultValue:e,disabled:t,onBlur:t=>{let r=Number.parseInt(t.target.value,10);Number.isFinite(r)&&r!==e&&n(r)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`logging.levels.opsLogRetentionNote`,`How long the record of what retention deleted is kept. Cluster-wide, and deliberately longer than any camera window — it is the history of the sweep, not of the camera, and it is what makes a storage leak explainable after the fact. 0 keeps it forever.`)})]})}function W({level:e,source:t,persisted:n}){let{t:a}=y();return r(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[r(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),i(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:e}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:t==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:t})})]}),!n&&i(`p`,{className:`mt-1 text-[11px] text-warning`,children:a(`logging.levels.notPersisted`,`The settings store could not be read or written — what you see is live, but it would not survive a restart.`)})]})}function G({layer:e,inForce:t,busy:n,onSet:a,onClear:s}){let{t:c}=y();return r(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.scope===`cluster`?c(`logging.levels.cluster`,`Cluster`):e.scope===`component`?e.component??``:e.nodeId??``}),t&&r(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[i(o,{className:`h-3 w-3`}),c(`logging.levels.inForce`,`in force`)]})]}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:e.level===null?c(`logging.levels.inherits`,`inherits — nothing set at this layer`):c(`logging.levels.setHere`,`set here: {{level}}`,{level:e.level})})]}),r(`div`,{className:`flex shrink-0 items-center gap-1`,children:[z.map(t=>i(`button`,{type:`button`,disabled:n,onClick:()=>a(t),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${e.level===t?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:t},t)),i(`button`,{type:`button`,disabled:n||e.level===null,onClick:s,className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-40`,children:c(`logging.levels.clear`,`Clear`)})]})]})}function K(){return i(w,{embedded:!0,children:i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(p,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0})})})}function q(){let{t:e}=y(),t=S(`/system/logs`,{t:e,isAdmin:!0})??{icon:c,title:e(`system.logs`,`Logs`)};return i(C,{icon:t.icon,title:t.title,defaultSection:`viewer`,sectionsLabel:`${t.title} sections`,sections:[{id:`viewer`,label:e(`admin.system.logs.viewer`,`Viewer`),content:i(K,{})},{id:b.logging.tab,label:e(`admin.system.logs.destinations`,`Destinations`),content:i(M,{}),ownedParams:x},{id:`levels`,label:e(`admin.system.logs.levels`,`Levels`),content:i(H,{})},{id:`diagnostics`,label:e(`admin.system.logs.diagnostics`,`Diagnostics`),content:i(F,{})}]})}export{q as LogsPage};
@@ -1 +1 @@
1
- import{$ as e,B as t,J as n,L as r,N as i,S as a,q as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{sa as c}from"./player-overlays-mwQ6DKjG.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-Cyj0Xie_.js";e();var _={rect:`#ef4444`,polygon:`#3b82f6`,grid:`#6366f1`,line:`#f59e0b`},v=`33`,y=`66`,b=`#6366f1`,x=3,S=2,C=12,w=16,T=9;function E(e,t,n){return{x:e.x*t,y:e.y*n}}function D(e,t,n){return{x:e.x/t,y:e.y/n}}function O(e,t,n){return e.flatMap(e=>[e.x*t,e.y*n])}function k(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function A(e){return e.color??_[e.shape.kind]}function j(e,t){let n=e[t],r=e[(t+1)%e.length];if(!n||!r)return[...e];let i={x:(n.x+r.x)/2,y:(n.y+r.y)/2};return[...e.slice(0,t+1),i,...e.slice(t+1)]}function M(e,t){return e.length===t.length?e.every((e,n)=>{let r=t[n];return Math.abs(e.x-r.x)<1e-6&&Math.abs(e.y-r.y)<1e-6}):!1}function N(e){return e.kind===`polygon`||e.kind===`line`}function P({items:e,selectedId:i,onSelect:f,onShapeChange:p,onDrawComplete:m,drawingKind:v,supportedShapes:y,transparent:j=!1,backdrop:P,polygonVertices:F,grid:I}){let B=c(),V=o(null),[H,ee]=n({w:800,h:450}),[U,W]=n([]),[G,K]=n(null),[te,ne]=n(null),[q,J]=n(null),Y=v!==null&&y.includes(v);t(()=>{if(!q)return;let t=e.find(e=>e.id===q.itemId);if(!t||!N(t.shape)){J(null);return}M(t.shape.points,q.points)&&J(null)},[e,q]),t(()=>{let e=V.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect;ee(j?{w:n,h:r}:{w:n,h:n*9/16})});return t.observe(e),()=>t.disconnect()},[j]),t(()=>{!Y&&G!==null&&K(null)},[Y,G]);let X=r(e=>{m(e),W([])},[m]),re=r(e=>{if(!Y||v===null){f(null);return}let t=e.target.getStage();if(!t)return;let n=t.getPointerPosition();if(!n)return;let r=D(n,H.w,H.h);if(v===`rect`){let e=k(r.x),t=k(r.y);X({kind:`rect`,x:e,y:t,width:Math.min(.2,1-e),height:Math.min(.2,1-t)});return}if(v===`grid`){let e=I?.width??w,t=I?.height??T;X({kind:`grid`,gridWidth:e,gridHeight:t,cells:Array.from({length:e*t},()=>!1)});return}if(v===`line`){if(U.length===0){W([r]);return}X({kind:`line`,points:[...U,r]});return}if(v===`polygon`){if(U.length===0){W([r]);return}if(U.length>=x){let e=E(U[0],H.w,H.h);if(Math.hypot(n.x-e.x,n.y-e.y)<C){X({kind:`polygon`,points:U});return}}W(e=>[...e,r])}},[Y,v,U,H,I,X,f]),ie=r(e=>{!Y||v!==`polygon`||U.length<x||(e.cancelBubble=!0,X({kind:`polygon`,points:U}))},[Y,v,U,X]),Z=o(null),Q=o(null);t(()=>()=>{Z.current!==null&&cancelAnimationFrame(Z.current)},[]);let ae=r(e=>{if(!Y)return;let t=e.target.getStage();t&&(Q.current=t.getPointerPosition()??null,Z.current===null&&(Z.current=requestAnimationFrame(()=>{Z.current=null,K(Q.current)})))},[Y]),oe=o(!1),se=o(!0),ce=o(new Set),le=r((e,t,n,r)=>{let i=t.gridWidth*t.gridHeight;if(n<0||n>=i||t.cells[n]===r)return;let a=[...t.cells];for(;a.length<i;)a.push(!1);a.length=i,a[n]=r,p(e,{...t,cells:a})},[p]),$=[];if(!j){for(let e=1;e<w;e++){let t=H.w/w*e;$.push(s(u,{points:[t,0,t,H.h],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gv-${e}`))}for(let e=1;e<T;e++){let t=H.h/T*e;$.push(s(u,{points:[0,t,H.w,t],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gh-${e}`))}}return a(`div`,{ref:V,className:j?`absolute inset-0`:`relative w-full bg-zinc-900 rounded-lg overflow-hidden`,style:{cursor:Y?`crosshair`:`default`},children:[P&&!j?s(`div`,{className:`absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover`,style:{width:H.w,height:H.h},children:P}):null,a(l,{width:H.w,height:H.h,onClick:re,onDblClick:ie,onMouseMove:ae,children:[a(g,{listening:!1,children:[s(u,{points:[0,0,H.w,0,H.w,H.h,0,H.h,0,0],stroke:`transparent`,strokeWidth:0}),$]}),s(g,{children:e.map(e=>{let t=e.id===i,n=e.enabled===!1,r=A(e),a=t&&!Y&&!n;if(e.shape.kind===`rect`)return s(L,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isDrawing:Y,size:H,onSelect:f,onShapeChange:p},e.id);if(e.shape.kind===`grid`)return s(R,{item:e,shape:e.shape,color:r,dimmed:n,editable:a,size:H,onSelect:f,paintingRef:oe,paintValueRef:se,paintedRef:ce,paintCell:le},e.id);let o=e.shape.kind===`line`,c=o?S:Math.max(x,F?.min??x),l=o?S:F?.max,u=q&&q.itemId===e.id?q.points:e.shape.points;return s(z,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isLine:o,isDrawing:Y,size:H,effectivePoints:u,minVertices:c,maxVertices:l,isDragging:te===e.id,onSelect:f,onShapeChange:p,setDragOverride:J,setDraggingItemId:ne},e.id)})}),s(g,{listening:!1,children:Y&&U.length>0&&a(d,{children:[v===`polygon`&&U.length>=2&&s(u,{points:O(U,H.w,H.h),stroke:b,strokeWidth:1.5,dash:[6,3],opacity:.8}),v===`line`&&U.length===1&&G&&s(u,{points:[U[0].x*H.w,U[0].y*H.h,G.x,G.y],stroke:_.line,strokeWidth:1.5,dash:[6,3],opacity:.7}),v===`polygon`&&G&&U.length>=1&&s(u,{points:[U[U.length-1].x*H.w,U[U.length-1].y*H.h,G.x,G.y],stroke:b,strokeWidth:1,dash:[4,4],opacity:.5}),U.map((e,t)=>{let n=E(e,H.w,H.h),r=t===0&&v===`polygon`&&U.length>=x;return s(h,{x:n.x,y:n.y,radius:r?7:4,fill:r?b:`#ffffff`,stroke:b,strokeWidth:1.5,opacity:.9},t)})]})})]}),Y?s(`div`,{className:`px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700`,children:v===`line`?B(`uiLibrary.maskShapeCanvas.hintLine`,`Click to set the start point, click again to complete the line`):v===`rect`?B(`uiLibrary.maskShapeCanvas.hintRect`,`Click to drop a rectangle, then drag the corner to resize`):v===`grid`?B(`uiLibrary.maskShapeCanvas.hintGrid`,`Click to add the grid, then paint cells`):U.length<x?B(`uiLibrary.maskShapeCanvas.hintPoints`,`Click to add points (min 3). Double-click or click the first point to close.`):B(`uiLibrary.maskShapeCanvas.hintMore`,`Continue adding points. Double-click or click the first point to close.`)}):null]})}var F=.02;function I(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.width-t.width)<1e-6&&Math.abs(e.height-t.height)<1e-6}function L({item:e,shape:r,color:i,selected:o,dimmed:c,editable:l,isDrawing:u,size:m,onSelect:g,onShapeChange:_}){let[b,x]=n(null),S={x:r.x,y:r.y,width:r.width,height:r.height};t(()=>{b&&I(S,b)&&x(null)},[r.x,r.y,r.width,r.height,b]);let C=b??S,w=C.x*m.w,T=C.y*m.h,E=C.width*m.w,D=C.height*m.h,O=c?.35:o?1:.85,A=t=>{x(t),_(e.id,{kind:`rect`,x:t.x,y:t.y,width:t.width,height:t.height})};return s(d,{onClick:t=>{t.cancelBubble=!0,u||g(e.id)},children:a(d,{draggable:l,dragBoundFunc:l?e=>({x:Math.max(-w,Math.min(m.w-(w+E),e.x)),y:Math.max(-T,Math.min(m.h-(T+D),e.y))}):void 0,onDragEnd:l?e=>{let t=e.target,n=t.x()/m.w,r=t.y()/m.h;if(t.position({x:0,y:0}),n===0&&r===0)return;let i=Math.min(Math.max(0,C.x+n),Math.max(0,1-C.width)),a=Math.min(Math.max(0,C.y+r),Math.max(0,1-C.height));A({...C,x:i,y:a})}:void 0,onMouseEnter:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=u?`crosshair`:`default`)},children:[s(p,{x:w,y:T,width:E,height:D,fill:i+(o?y:v),stroke:i,strokeWidth:o?2.5:1.5,opacity:O}),e.label?s(f,{x:w,y:T-16,text:e.label,fontSize:12,fill:i,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1}):null,l?s(h,{x:w+E,y:T+D,radius:6,fill:i,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,dragBoundFunc:e=>({x:Math.min(m.w,Math.max(w,e.x)),y:Math.min(m.h,Math.max(T,e.y))}),onDragStart:e=>{e.cancelBubble=!0},onDragMove:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);x({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onDragEnd:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);A({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onMouseEnter:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`nwse-resize`)},onMouseLeave:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`default`)}}):null]})})}function R({item:e,shape:t,color:n,dimmed:r,editable:i,size:a,onSelect:o,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:f}){let{gridWidth:m,gridHeight:h,cells:g}=t,_=a.w/m,v=a.h/h,b=m*h,x=r?.3:1,S=n=>{if(!i){o(e.id);return}let r=g[n]!==!0;c.current=!0,l.current=r,u.current=new Set([n]),f(e.id,t,n,r)},C=n=>{!c.current||!i||u.current.has(n)||(u.current.add(n),f(e.id,t,n,l.current))},w=()=>{c.current&&(c.current=!1,u.current=new Set)};return s(d,{opacity:x,onMouseUp:w,onMouseLeave:w,children:Array.from({length:b},(e,t)=>{let r=t%m,i=Math.floor(t/m),a=g[t]===!0;return s(p,{x:r*_,y:i*v,width:_,height:v,fill:a?n+y:`#ffffff10`,stroke:a?n:`#ffffff40`,strokeWidth:.5,onMouseDown:e=>{e.cancelBubble=!0,S(t)},onMouseEnter:()=>C(t)},t)})})}function z({item:e,shape:t,color:n,selected:r,dimmed:i,editable:o,isLine:c,isDrawing:l,size:p,effectivePoints:g,minVertices:_,maxVertices:b,isDragging:x,onSelect:S,onShapeChange:C,setDragOverride:w,setDraggingItemId:T}){let k=O(g,p.w,p.h),A=i?.35:r?1:c?.8:.85,M=e=>c?{kind:`line`,points:[...e]}:{kind:`polygon`,points:[...e]},N=g.map(e=>e.x*p.w),P=g.map(e=>e.y*p.h),F=N.length>0?Math.min(...N):0,I=N.length>0?Math.max(...N):0,L=P.length>0?Math.min(...P):0,R=P.length>0?Math.max(...P):0,z=e=>({x:Math.max(-F,Math.min(p.w-I,e.x)),y:Math.max(-L,Math.min(p.h-R,e.y))}),B=n=>{let r=n.target,i=r.x()/p.w,a=r.y()/p.h;if(r.position({x:0,y:0}),T(null),i===0&&a===0)return;let o=t.points.map(e=>({x:e.x+i,y:e.y+a}));w({itemId:e.id,points:o}),C(e.id,M(o))},V=!c&&g.length>_,H=!c&&(b===void 0||g.length<b);return a(d,{onClick:t=>{t.cancelBubble=!0,l||S(e.id)},children:[a(d,{draggable:o,dragBoundFunc:o?z:void 0,onDragStart:o?()=>T(e.id):void 0,onDragEnd:o?B:void 0,onMouseEnter:e=>{if(!o)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!o)return;let t=e.target.getStage();t&&(t.container().style.cursor=l?`crosshair`:`default`)},children:[c?s(m,{points:k,stroke:n,strokeWidth:r?3:2,fill:n,pointerLength:10,pointerWidth:8,opacity:A}):s(u,{points:k,closed:!0,fill:n+(r?y:v),stroke:n,strokeWidth:r?2.5:1.5,opacity:A}),e.label&&g.length>0?(()=>{let t=E({x:g.reduce((e,t)=>e+t.x,0)/g.length,y:g.reduce((e,t)=>e+t.y,0)/g.length},p.w,p.h),r=Math.max(40,e.label.length*11*.62);return s(f,{x:t.x-r/2,y:t.y-7,width:r,align:`center`,text:e.label,fontSize:12,fill:n,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1})})():null]}),o&&!x&&g.map((r,i)=>{let a=E(r,p.w,p.h);return s(h,{x:a.x,y:a.y,radius:5,fill:n,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,onDragMove:n=>{let r=D({x:n.target.x(),y:n.target.y()},p.w,p.h);w(n=>{let a=n&&n.itemId===e.id?n.points:t.points;return{itemId:e.id,points:a.map((e,t)=>t===i?r:e)}})},onDragEnd:n=>{let r=D({x:n.target.x(),y:n.target.y()},p.w,p.h),a=t.points.map((e,t)=>t===i?r:e);w({itemId:e.id,points:a}),C(e.id,M(a))},onContextMenu:n=>{n.evt.preventDefault(),n.cancelBubble=!0,V&&C(e.id,M(t.points.filter((e,t)=>t!==i)))}},`pt-${i}`)}),o&&!x&&H&&g.length>=2&&g.map((r,i)=>{let a=g[(i+1)%g.length],o=E({x:(r.x+a.x)/2,y:(r.y+a.y)/2},p.w,p.h);return s(h,{x:o.x,y:o.y,radius:4,fill:`#ffffff`,stroke:n,strokeWidth:1.5,opacity:.6,onMouseEnter:e=>{let t=e.target;t.to({radius:6,opacity:1,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=`copy`)},onMouseLeave:e=>{let t=e.target;t.to({radius:4,opacity:.6,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=l?`crosshair`:`default`)},onClick:n=>{n.cancelBubble=!0,C(e.id,M(j(t.points,i)))}},`mid-${i}`)})]})}var B=i(P);export{B as MaskShapeCanvas};
1
+ import{$ as e,B as t,J as n,L as r,N as i,S as a,q as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{sa as c}from"./player-overlays-DDFLUcm1.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-Cyj0Xie_.js";e();var _={rect:`#ef4444`,polygon:`#3b82f6`,grid:`#6366f1`,line:`#f59e0b`},v=`33`,y=`66`,b=`#6366f1`,x=3,S=2,C=12,w=16,T=9;function E(e,t,n){return{x:e.x*t,y:e.y*n}}function D(e,t,n){return{x:e.x/t,y:e.y/n}}function O(e,t,n){return e.flatMap(e=>[e.x*t,e.y*n])}function k(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function A(e){return e.color??_[e.shape.kind]}function j(e,t){let n=e[t],r=e[(t+1)%e.length];if(!n||!r)return[...e];let i={x:(n.x+r.x)/2,y:(n.y+r.y)/2};return[...e.slice(0,t+1),i,...e.slice(t+1)]}function M(e,t){return e.length===t.length?e.every((e,n)=>{let r=t[n];return Math.abs(e.x-r.x)<1e-6&&Math.abs(e.y-r.y)<1e-6}):!1}function N(e){return e.kind===`polygon`||e.kind===`line`}function P({items:e,selectedId:i,onSelect:f,onShapeChange:p,onDrawComplete:m,drawingKind:v,supportedShapes:y,transparent:j=!1,backdrop:P,polygonVertices:F,grid:I}){let B=c(),V=o(null),[H,ee]=n({w:800,h:450}),[U,W]=n([]),[G,K]=n(null),[te,ne]=n(null),[q,J]=n(null),Y=v!==null&&y.includes(v);t(()=>{if(!q)return;let t=e.find(e=>e.id===q.itemId);if(!t||!N(t.shape)){J(null);return}M(t.shape.points,q.points)&&J(null)},[e,q]),t(()=>{let e=V.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect;ee(j?{w:n,h:r}:{w:n,h:n*9/16})});return t.observe(e),()=>t.disconnect()},[j]),t(()=>{!Y&&G!==null&&K(null)},[Y,G]);let X=r(e=>{m(e),W([])},[m]),re=r(e=>{if(!Y||v===null){f(null);return}let t=e.target.getStage();if(!t)return;let n=t.getPointerPosition();if(!n)return;let r=D(n,H.w,H.h);if(v===`rect`){let e=k(r.x),t=k(r.y);X({kind:`rect`,x:e,y:t,width:Math.min(.2,1-e),height:Math.min(.2,1-t)});return}if(v===`grid`){let e=I?.width??w,t=I?.height??T;X({kind:`grid`,gridWidth:e,gridHeight:t,cells:Array.from({length:e*t},()=>!1)});return}if(v===`line`){if(U.length===0){W([r]);return}X({kind:`line`,points:[...U,r]});return}if(v===`polygon`){if(U.length===0){W([r]);return}if(U.length>=x){let e=E(U[0],H.w,H.h);if(Math.hypot(n.x-e.x,n.y-e.y)<C){X({kind:`polygon`,points:U});return}}W(e=>[...e,r])}},[Y,v,U,H,I,X,f]),ie=r(e=>{!Y||v!==`polygon`||U.length<x||(e.cancelBubble=!0,X({kind:`polygon`,points:U}))},[Y,v,U,X]),Z=o(null),Q=o(null);t(()=>()=>{Z.current!==null&&cancelAnimationFrame(Z.current)},[]);let ae=r(e=>{if(!Y)return;let t=e.target.getStage();t&&(Q.current=t.getPointerPosition()??null,Z.current===null&&(Z.current=requestAnimationFrame(()=>{Z.current=null,K(Q.current)})))},[Y]),oe=o(!1),se=o(!0),ce=o(new Set),le=r((e,t,n,r)=>{let i=t.gridWidth*t.gridHeight;if(n<0||n>=i||t.cells[n]===r)return;let a=[...t.cells];for(;a.length<i;)a.push(!1);a.length=i,a[n]=r,p(e,{...t,cells:a})},[p]),$=[];if(!j){for(let e=1;e<w;e++){let t=H.w/w*e;$.push(s(u,{points:[t,0,t,H.h],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gv-${e}`))}for(let e=1;e<T;e++){let t=H.h/T*e;$.push(s(u,{points:[0,t,H.w,t],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gh-${e}`))}}return a(`div`,{ref:V,className:j?`absolute inset-0`:`relative w-full bg-zinc-900 rounded-lg overflow-hidden`,style:{cursor:Y?`crosshair`:`default`},children:[P&&!j?s(`div`,{className:`absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover`,style:{width:H.w,height:H.h},children:P}):null,a(l,{width:H.w,height:H.h,onClick:re,onDblClick:ie,onMouseMove:ae,children:[a(g,{listening:!1,children:[s(u,{points:[0,0,H.w,0,H.w,H.h,0,H.h,0,0],stroke:`transparent`,strokeWidth:0}),$]}),s(g,{children:e.map(e=>{let t=e.id===i,n=e.enabled===!1,r=A(e),a=t&&!Y&&!n;if(e.shape.kind===`rect`)return s(L,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isDrawing:Y,size:H,onSelect:f,onShapeChange:p},e.id);if(e.shape.kind===`grid`)return s(R,{item:e,shape:e.shape,color:r,dimmed:n,editable:a,size:H,onSelect:f,paintingRef:oe,paintValueRef:se,paintedRef:ce,paintCell:le},e.id);let o=e.shape.kind===`line`,c=o?S:Math.max(x,F?.min??x),l=o?S:F?.max,u=q&&q.itemId===e.id?q.points:e.shape.points;return s(z,{item:e,shape:e.shape,color:r,selected:t,dimmed:n,editable:a,isLine:o,isDrawing:Y,size:H,effectivePoints:u,minVertices:c,maxVertices:l,isDragging:te===e.id,onSelect:f,onShapeChange:p,setDragOverride:J,setDraggingItemId:ne},e.id)})}),s(g,{listening:!1,children:Y&&U.length>0&&a(d,{children:[v===`polygon`&&U.length>=2&&s(u,{points:O(U,H.w,H.h),stroke:b,strokeWidth:1.5,dash:[6,3],opacity:.8}),v===`line`&&U.length===1&&G&&s(u,{points:[U[0].x*H.w,U[0].y*H.h,G.x,G.y],stroke:_.line,strokeWidth:1.5,dash:[6,3],opacity:.7}),v===`polygon`&&G&&U.length>=1&&s(u,{points:[U[U.length-1].x*H.w,U[U.length-1].y*H.h,G.x,G.y],stroke:b,strokeWidth:1,dash:[4,4],opacity:.5}),U.map((e,t)=>{let n=E(e,H.w,H.h),r=t===0&&v===`polygon`&&U.length>=x;return s(h,{x:n.x,y:n.y,radius:r?7:4,fill:r?b:`#ffffff`,stroke:b,strokeWidth:1.5,opacity:.9},t)})]})})]}),Y?s(`div`,{className:`px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700`,children:v===`line`?B(`uiLibrary.maskShapeCanvas.hintLine`,`Click to set the start point, click again to complete the line`):v===`rect`?B(`uiLibrary.maskShapeCanvas.hintRect`,`Click to drop a rectangle, then drag the corner to resize`):v===`grid`?B(`uiLibrary.maskShapeCanvas.hintGrid`,`Click to add the grid, then paint cells`):U.length<x?B(`uiLibrary.maskShapeCanvas.hintPoints`,`Click to add points (min 3). Double-click or click the first point to close.`):B(`uiLibrary.maskShapeCanvas.hintMore`,`Continue adding points. Double-click or click the first point to close.`)}):null]})}var F=.02;function I(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.width-t.width)<1e-6&&Math.abs(e.height-t.height)<1e-6}function L({item:e,shape:r,color:i,selected:o,dimmed:c,editable:l,isDrawing:u,size:m,onSelect:g,onShapeChange:_}){let[b,x]=n(null),S={x:r.x,y:r.y,width:r.width,height:r.height};t(()=>{b&&I(S,b)&&x(null)},[r.x,r.y,r.width,r.height,b]);let C=b??S,w=C.x*m.w,T=C.y*m.h,E=C.width*m.w,D=C.height*m.h,O=c?.35:o?1:.85,A=t=>{x(t),_(e.id,{kind:`rect`,x:t.x,y:t.y,width:t.width,height:t.height})};return s(d,{onClick:t=>{t.cancelBubble=!0,u||g(e.id)},children:a(d,{draggable:l,dragBoundFunc:l?e=>({x:Math.max(-w,Math.min(m.w-(w+E),e.x)),y:Math.max(-T,Math.min(m.h-(T+D),e.y))}):void 0,onDragEnd:l?e=>{let t=e.target,n=t.x()/m.w,r=t.y()/m.h;if(t.position({x:0,y:0}),n===0&&r===0)return;let i=Math.min(Math.max(0,C.x+n),Math.max(0,1-C.width)),a=Math.min(Math.max(0,C.y+r),Math.max(0,1-C.height));A({...C,x:i,y:a})}:void 0,onMouseEnter:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!l)return;let t=e.target.getStage();t&&(t.container().style.cursor=u?`crosshair`:`default`)},children:[s(p,{x:w,y:T,width:E,height:D,fill:i+(o?y:v),stroke:i,strokeWidth:o?2.5:1.5,opacity:O}),e.label?s(f,{x:w,y:T-16,text:e.label,fontSize:12,fill:i,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1}):null,l?s(h,{x:w+E,y:T+D,radius:6,fill:i,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,dragBoundFunc:e=>({x:Math.min(m.w,Math.max(w,e.x)),y:Math.min(m.h,Math.max(T,e.y))}),onDragStart:e=>{e.cancelBubble=!0},onDragMove:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);x({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onDragEnd:e=>{let t=e.target,n=k(t.x()/m.w-C.x),r=k(t.y()/m.h-C.y);A({...C,width:Math.max(F,Math.min(n,1-C.x)),height:Math.max(F,Math.min(r,1-C.y))})},onMouseEnter:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`nwse-resize`)},onMouseLeave:e=>{let t=e.target.getStage();t&&(t.container().style.cursor=`default`)}}):null]})})}function R({item:e,shape:t,color:n,dimmed:r,editable:i,size:a,onSelect:o,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:f}){let{gridWidth:m,gridHeight:h,cells:g}=t,_=a.w/m,v=a.h/h,b=m*h,x=r?.3:1,S=n=>{if(!i){o(e.id);return}let r=g[n]!==!0;c.current=!0,l.current=r,u.current=new Set([n]),f(e.id,t,n,r)},C=n=>{!c.current||!i||u.current.has(n)||(u.current.add(n),f(e.id,t,n,l.current))},w=()=>{c.current&&(c.current=!1,u.current=new Set)};return s(d,{opacity:x,onMouseUp:w,onMouseLeave:w,children:Array.from({length:b},(e,t)=>{let r=t%m,i=Math.floor(t/m),a=g[t]===!0;return s(p,{x:r*_,y:i*v,width:_,height:v,fill:a?n+y:`#ffffff10`,stroke:a?n:`#ffffff40`,strokeWidth:.5,onMouseDown:e=>{e.cancelBubble=!0,S(t)},onMouseEnter:()=>C(t)},t)})})}function z({item:e,shape:t,color:n,selected:r,dimmed:i,editable:o,isLine:c,isDrawing:l,size:p,effectivePoints:g,minVertices:_,maxVertices:b,isDragging:x,onSelect:S,onShapeChange:C,setDragOverride:w,setDraggingItemId:T}){let k=O(g,p.w,p.h),A=i?.35:r?1:c?.8:.85,M=e=>c?{kind:`line`,points:[...e]}:{kind:`polygon`,points:[...e]},N=g.map(e=>e.x*p.w),P=g.map(e=>e.y*p.h),F=N.length>0?Math.min(...N):0,I=N.length>0?Math.max(...N):0,L=P.length>0?Math.min(...P):0,R=P.length>0?Math.max(...P):0,z=e=>({x:Math.max(-F,Math.min(p.w-I,e.x)),y:Math.max(-L,Math.min(p.h-R,e.y))}),B=n=>{let r=n.target,i=r.x()/p.w,a=r.y()/p.h;if(r.position({x:0,y:0}),T(null),i===0&&a===0)return;let o=t.points.map(e=>({x:e.x+i,y:e.y+a}));w({itemId:e.id,points:o}),C(e.id,M(o))},V=!c&&g.length>_,H=!c&&(b===void 0||g.length<b);return a(d,{onClick:t=>{t.cancelBubble=!0,l||S(e.id)},children:[a(d,{draggable:o,dragBoundFunc:o?z:void 0,onDragStart:o?()=>T(e.id):void 0,onDragEnd:o?B:void 0,onMouseEnter:e=>{if(!o)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!o)return;let t=e.target.getStage();t&&(t.container().style.cursor=l?`crosshair`:`default`)},children:[c?s(m,{points:k,stroke:n,strokeWidth:r?3:2,fill:n,pointerLength:10,pointerWidth:8,opacity:A}):s(u,{points:k,closed:!0,fill:n+(r?y:v),stroke:n,strokeWidth:r?2.5:1.5,opacity:A}),e.label&&g.length>0?(()=>{let t=E({x:g.reduce((e,t)=>e+t.x,0)/g.length,y:g.reduce((e,t)=>e+t.y,0)/g.length},p.w,p.h),r=Math.max(40,e.label.length*11*.62);return s(f,{x:t.x-r/2,y:t.y-7,width:r,align:`center`,text:e.label,fontSize:12,fill:n,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1})})():null]}),o&&!x&&g.map((r,i)=>{let a=E(r,p.w,p.h);return s(h,{x:a.x,y:a.y,radius:5,fill:n,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,onDragMove:n=>{let r=D({x:n.target.x(),y:n.target.y()},p.w,p.h);w(n=>{let a=n&&n.itemId===e.id?n.points:t.points;return{itemId:e.id,points:a.map((e,t)=>t===i?r:e)}})},onDragEnd:n=>{let r=D({x:n.target.x(),y:n.target.y()},p.w,p.h),a=t.points.map((e,t)=>t===i?r:e);w({itemId:e.id,points:a}),C(e.id,M(a))},onContextMenu:n=>{n.evt.preventDefault(),n.cancelBubble=!0,V&&C(e.id,M(t.points.filter((e,t)=>t!==i)))}},`pt-${i}`)}),o&&!x&&H&&g.length>=2&&g.map((r,i)=>{let a=g[(i+1)%g.length],o=E({x:(r.x+a.x)/2,y:(r.y+a.y)/2},p.w,p.h);return s(h,{x:o.x,y:o.y,radius:4,fill:`#ffffff`,stroke:n,strokeWidth:1.5,opacity:.6,onMouseEnter:e=>{let t=e.target;t.to({radius:6,opacity:1,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=`copy`)},onMouseLeave:e=>{let t=e.target;t.to({radius:4,opacity:.6,duration:.1});let n=t.getStage();n&&(n.container().style.cursor=l?`crosshair`:`default`)},onClick:n=>{n.cancelBubble=!0,C(e.id,M(j(t.points,i)))}},`mid-${i}`)})]})}var B=i(P);export{B as MaskShapeCanvas};
@@ -1 +1 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Er as l,K as u,U as d,X as f,ia as p,n as m,ot as ee,sa as h,z as g}from"./player-overlays-mwQ6DKjG.js";import{MaskShapeCanvas as _}from"./MaskShapeCanvas-CC7FQGtr.js";e();var v=110,te=`motion-zones`,y=0,ne=[1,2,3],b=1,x=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,S=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function C(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function re(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function w(e,t){return Math.ceil(e/t)}function T(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function E(e,t,n,r){let i=w(t,r),a=w(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=T(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+T(n,t,i)]=!0)}return o}function D(e,t,n,r){let i=w(t,r),a=w(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=T(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+T(n,t,i)]===!0}return o}function O({deviceId:e}){let T=h(),O=u(ee().trpcClient,e),[k,A]=r(null),[j,M]=r(!1),[N,P]=r(null),[F,I]=r(null),[L,R]=r(b),[z,B]=r(!1),[V,H]=r(!1),U=s(!1);t(()=>{if(!O)return;let e=!1;return U.current=!1,A(null),M(!1),P(null),I(null),R(b),H(!1),(async()=>{try{let t=await O.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(A(t),U.current)return;let n=await O.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);U.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=C(r?r.shape.cells:[],t.grid.width,t.grid.height);I(i),P(E(i,t.grid.width,t.grid.height,b))}catch(t){if(e)return;d(t)?M(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[O]);let W=k?k.grid.width:0,G=k?k.grid.height:0,K=w(W,L),q=w(G,L),J=n(()=>N&&k?D(N,W,G,L):null,[N,k,W,G,L]),Y=n(()=>J!==null&&F!==null&&!re(J,F),[J,F]),ie=n(()=>J?J.reduce((e,t)=>t?e+1:e,0):0,[J]),ae=W*G,X=K*q,Z=i(e=>{X>0&&P(Array.from({length:X},()=>e))},[X]),oe=i(()=>{P(e=>e&&e.map(e=>!e))},[]),se=i(()=>{F&&k&&P(E(F,W,G,L))},[F,k,W,G,L]),ce=i(e=>{e===L||!k||P(t=>{if(!t)return R(e),t;let n=E(D(t,W,G,L),W,G,e);return R(e),n})},[L,k,W,G]),Q=n(()=>k&&N?[{id:y,shape:{kind:`grid`,gridWidth:K,gridHeight:q,cells:[...N]}}]:[],[k,N,K,q]),$=i((e,t)=>{t.kind===`grid`&&P(t.cells)},[]),le=i(async()=>{if(!(!O||!N||!k)){B(!0);try{let e=D(N,k.grid.width,k.grid.height,L),t={kind:`grid`,gridWidth:k.grid.width,gridHeight:k.grid.height,cells:e};await O.motionZones?.setZone({patch:{regions:[{id:y,enabled:!0,shape:t}]}});let n=await O.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=C(e?e.shape.cells:[],k.grid.width,k.grid.height);I(t),P(E(t,k.grid.width,k.grid.height,L))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{B(!1)}}},[O,N,k,L]);m(n(()=>V&&!j&&k&&N?{id:te,order:v,node:c(_,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:K,height:q},selectedId:y,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[V,j,k,N,Q,$,K,q]));let ue=!j&&k!==null&&N!==null;return O?c(f,{title:T(`uiLibrary.motionZones.title`,`Motion Zones`),icon:c(l,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:c(`div`,{className:`flex flex-col gap-3`,children:j?c(`p`,{className:`${g} leading-relaxed`,children:T(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ue?a(o,{children:[c(`p`,{className:`${g} leading-relaxed`,children:c(p,{uiKey:`uiLibrary.motionZones.intro`,fallback:`Toggle <0>Edit grid</0> to paint the region directly on the live frame, then <1>Save</1> to push the mask to the camera. Pick a bigger <2>Cell size</2> for quicker, broad-stroke painting — it's resampled to the camera's native {{width}}×{{height}} grid on save (×1 is the finest).`,components:[c(`strong`,{className:`text-foreground`},`e`),c(`strong`,{className:`text-foreground`},`s`),c(`strong`,{className:`text-foreground`},`c`)],values:{width:k.grid.width,height:k.grid.height}})}),a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[c(`button`,{type:`button`,onClick:()=>H(e=>!e),disabled:z,"aria-pressed":V,className:V?S:x,children:V?T(`uiLibrary.motionZones.doneEditing`,`Done editing`):T(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),c(`button`,{type:`button`,onClick:()=>Z(!0),disabled:z,className:x,children:T(`uiLibrary.motionZones.allOn`,`All on`)}),c(`button`,{type:`button`,onClick:()=>Z(!1),disabled:z,className:x,children:T(`uiLibrary.motionZones.allOff`,`All off`)}),c(`button`,{type:`button`,onClick:oe,disabled:z,className:x,children:T(`uiLibrary.motionZones.invert`,`Invert`)}),a(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":T(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[c(`span`,{className:`${g} mr-0.5`,children:T(`uiLibrary.motionZones.cellSize`,`Cell size`)}),ne.map(e=>a(`button`,{type:`button`,onClick:()=>ce(e),disabled:z,"aria-pressed":L===e,title:e===1?T(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:W,height:G}):T(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:w(W,e),height:w(G,e),factor:e}),className:L===e?S:x,children:[`×`,e]},e))]}),a(`span`,{className:`${g} ml-1 tabular-nums`,children:[T(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:ie,total:ae,width:k.grid.width,height:k.grid.height}),L===1?``:T(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:K,height:q})]}),c(`span`,{className:`flex-1`}),c(`button`,{type:`button`,onClick:se,disabled:z||!Y,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:T(`uiLibrary.motionZones.revert`,`Revert`)}),c(`button`,{type:`button`,onClick:()=>void le(),disabled:z||!Y,className:S,children:z?T(`uiLibrary.motionZones.saving`,`Saving…`):T(`uiLibrary.motionZones.save`,`Save`)})]})]}):c(`p`,{className:`${g} leading-relaxed`,children:T(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{O as MotionZonesSettings};
1
+ import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,q as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{Er as l,K as u,U as d,X as f,ia as p,n as m,ot as ee,sa as h,z as g}from"./player-overlays-DDFLUcm1.js";import{MaskShapeCanvas as _}from"./MaskShapeCanvas-wRO0Yeyg.js";e();var v=110,te=`motion-zones`,y=0,ne=[1,2,3],b=1,x=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,S=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function C(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function re(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function w(e,t){return Math.ceil(e/t)}function T(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function E(e,t,n,r){let i=w(t,r),a=w(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=T(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+T(n,t,i)]=!0)}return o}function D(e,t,n,r){let i=w(t,r),a=w(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=T(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+T(n,t,i)]===!0}return o}function O({deviceId:e}){let T=h(),O=u(ee().trpcClient,e),[k,A]=r(null),[j,M]=r(!1),[N,P]=r(null),[F,I]=r(null),[L,R]=r(b),[z,B]=r(!1),[V,H]=r(!1),U=s(!1);t(()=>{if(!O)return;let e=!1;return U.current=!1,A(null),M(!1),P(null),I(null),R(b),H(!1),(async()=>{try{let t=await O.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(A(t),U.current)return;let n=await O.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);U.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=C(r?r.shape.cells:[],t.grid.width,t.grid.height);I(i),P(E(i,t.grid.width,t.grid.height,b))}catch(t){if(e)return;d(t)?M(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[O]);let W=k?k.grid.width:0,G=k?k.grid.height:0,K=w(W,L),q=w(G,L),J=n(()=>N&&k?D(N,W,G,L):null,[N,k,W,G,L]),Y=n(()=>J!==null&&F!==null&&!re(J,F),[J,F]),ie=n(()=>J?J.reduce((e,t)=>t?e+1:e,0):0,[J]),ae=W*G,X=K*q,Z=i(e=>{X>0&&P(Array.from({length:X},()=>e))},[X]),oe=i(()=>{P(e=>e&&e.map(e=>!e))},[]),se=i(()=>{F&&k&&P(E(F,W,G,L))},[F,k,W,G,L]),ce=i(e=>{e===L||!k||P(t=>{if(!t)return R(e),t;let n=E(D(t,W,G,L),W,G,e);return R(e),n})},[L,k,W,G]),Q=n(()=>k&&N?[{id:y,shape:{kind:`grid`,gridWidth:K,gridHeight:q,cells:[...N]}}]:[],[k,N,K,q]),$=i((e,t)=>{t.kind===`grid`&&P(t.cells)},[]),le=i(async()=>{if(!(!O||!N||!k)){B(!0);try{let e=D(N,k.grid.width,k.grid.height,L),t={kind:`grid`,gridWidth:k.grid.width,gridHeight:k.grid.height,cells:e};await O.motionZones?.setZone({patch:{regions:[{id:y,enabled:!0,shape:t}]}});let n=await O.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=C(e?e.shape.cells:[],k.grid.width,k.grid.height);I(t),P(E(t,k.grid.width,k.grid.height,L))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{B(!1)}}},[O,N,k,L]);m(n(()=>V&&!j&&k&&N?{id:te,order:v,node:c(_,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:K,height:q},selectedId:y,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[V,j,k,N,Q,$,K,q]));let ue=!j&&k!==null&&N!==null;return O?c(f,{title:T(`uiLibrary.motionZones.title`,`Motion Zones`),icon:c(l,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:c(`div`,{className:`flex flex-col gap-3`,children:j?c(`p`,{className:`${g} leading-relaxed`,children:T(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ue?a(o,{children:[c(`p`,{className:`${g} leading-relaxed`,children:c(p,{uiKey:`uiLibrary.motionZones.intro`,fallback:`Toggle <0>Edit grid</0> to paint the region directly on the live frame, then <1>Save</1> to push the mask to the camera. Pick a bigger <2>Cell size</2> for quicker, broad-stroke painting — it's resampled to the camera's native {{width}}×{{height}} grid on save (×1 is the finest).`,components:[c(`strong`,{className:`text-foreground`},`e`),c(`strong`,{className:`text-foreground`},`s`),c(`strong`,{className:`text-foreground`},`c`)],values:{width:k.grid.width,height:k.grid.height}})}),a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[c(`button`,{type:`button`,onClick:()=>H(e=>!e),disabled:z,"aria-pressed":V,className:V?S:x,children:V?T(`uiLibrary.motionZones.doneEditing`,`Done editing`):T(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),c(`button`,{type:`button`,onClick:()=>Z(!0),disabled:z,className:x,children:T(`uiLibrary.motionZones.allOn`,`All on`)}),c(`button`,{type:`button`,onClick:()=>Z(!1),disabled:z,className:x,children:T(`uiLibrary.motionZones.allOff`,`All off`)}),c(`button`,{type:`button`,onClick:oe,disabled:z,className:x,children:T(`uiLibrary.motionZones.invert`,`Invert`)}),a(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":T(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[c(`span`,{className:`${g} mr-0.5`,children:T(`uiLibrary.motionZones.cellSize`,`Cell size`)}),ne.map(e=>a(`button`,{type:`button`,onClick:()=>ce(e),disabled:z,"aria-pressed":L===e,title:e===1?T(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:W,height:G}):T(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:w(W,e),height:w(G,e),factor:e}),className:L===e?S:x,children:[`×`,e]},e))]}),a(`span`,{className:`${g} ml-1 tabular-nums`,children:[T(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:ie,total:ae,width:k.grid.width,height:k.grid.height}),L===1?``:T(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:K,height:q})]}),c(`span`,{className:`flex-1`}),c(`button`,{type:`button`,onClick:se,disabled:z||!Y,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:T(`uiLibrary.motionZones.revert`,`Revert`)}),c(`button`,{type:`button`,onClick:()=>void le(),disabled:z||!Y,className:S,children:z?T(`uiLibrary.motionZones.saving`,`Saving…`):T(`uiLibrary.motionZones.save`,`Save`)})]})]}):c(`p`,{className:`${g} leading-relaxed`,children:T(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{O as MotionZonesSettings};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{$ as n,B as r,G as i,J as a,S as o,a as s,b as c,q as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{$t as f,Fn as p,Gi as m,It as h,Nt as g,Q as _,Rr as v,Zr as y,hi as b,lr as x,mi as S,mr as C,or as w,ot as T,rr as E,sa as D,sn as O}from"./player-overlays-mwQ6DKjG.js";import{Mr as k,Nr as A}from"./client-CHpTazh3.js";import{s as j}from"./video-DJjbkBZD.js";import{t as ee}from"./key-round-DCaU9cAg.js";import{t as te}from"./monitor-smartphone-BXr9qaoG.js";import{t as ne}from"./unlink-CCWMkIgh.js";import{Ir as M,Rr as N,Ss as re,bs as ie,dn as P,ir as F,kr as ae,rr as oe,ud as I,wt as se,zu as ce}from"./src-B5lceK9L.js";import{t as le}from"./i18n-CQ56JIQj.js";import{t as L}from"./useTranslation-D3Is_4B6.js";import"./mount-DoeAV03f.js";import{_ as ue,er as R,fr as z,g as B,hr as V,ur as H,v as U,y as W}from"./index-BgKj4CM9.js";import{t as de}from"./AdminSectionedPage-BfaO7MK2.js";import{t as fe}from"./AdminPage-DpgHJ_lQ.js";import{O as pe,T as me,_ as G,a as he,h as ge,k as _e,r as ve,t as K,v as ye}from"./SessionsList-DgE-51ju.js";n();var be=`${k}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function xe(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 A(e)}function Se(e){return e.startsWith(`https://`)}function Ce(e){let t=e.flatMap(e=>{let t=xe(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:Se(r),plausible:e.plausible}]))}function we(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 Te(e){let t=new URL(be);return t.searchParams.set(`hub`,e),t.toString()}var Ee=176,Y={scheme:`https`};function De(){let{t:e}=L(),t=re(Y),n=ie(Y).data?.roles.publicEndpoint.resolved??null;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?o(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[d(w,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?o(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[d(g,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),o(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[d(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),d(N,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):d(Oe,{candidates:Ce(t.data.endpoints),preferredOrigin:n})]})]})}function Oe({candidates:e,preferredOrigin:t}){let{t:n}=L(),[r,s]=a(null),c=we(e,r,t),l=i(()=>c?Te(c.origin):null,[c]);if(c===null||l===null)return d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.empty`)});let u=e=>n(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${u(e.tier)} — ${e.origin}`}));return o(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[d(oe,{value:l,size:Ee,alt:n(`connectPhone.qrAlt`),className:`self-start`}),o(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[o(`label`,{className:`block space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.addressLabel`)}),d(ce,{value:c.origin,options:f,onChange:e=>s(e.target.value)}),o(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[u(c.tier),` · `,c.label]})]}),!c.secure&&d(X,{text:n(`connectPhone.insecure`)}),!c.plausible&&d(X,{text:n(`connectPhone.implausible`)}),o(`div`,{className:`space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.linkLabel`)}),o(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[d(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:l}),d(P,{value:l,srLabel:n(`connectPhone.linkLabel`)})]})]}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.signInHint`)})]})]})}function X({text:e}){return o(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[d(g,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),d(`span`,{children:e})]})}n();function ke(e){return new Date(e).toLocaleDateString()}function Ae(){let{t:e}=L(),t=M(),n=I.useUtils(),i=I.auth.listLinkableProviders.useQuery(),s=I.auth.listOwnExternalIdentities.useQuery(),[c,u]=a(null),[f,p]=a(()=>W(window.location.search)),m=l(null),h=G(`Linking a sign-in account`),g=l(null);r(()=>()=>g.current?.(),[]);let[v,y]=a(null);r(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=I.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=m.current;if(m.current=null,t===null||t.closed){window.location.assign(e);return}let r=e=>{y(null),p(W(`?${e}`)),n.auth.listOwnExternalIdentities.invalidate()};g.current?.(),g.current=ue(t,{onReturn:e=>{e.target===`profile`&&r(e.query)},onDone:e=>{e.target===`profile`&&r(e.query)},onClosed:()=>{g.current?.(),g.current=null,n.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=_(U(e))},onError:e=>{m.current?.close(),m.current=null,y(null),u(e.message)}}),T=I.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void n.auth.listOwnExternalIdentities.invalidate(),onError:e=>u(e.message)}),E=i.data??[],D=s.data??[],O=v!==null&&D.some(e=>e.provider===v);if(r(()=>{!O||v===null||(y(null),p({kind:`linked`,provider:v}))},[O,v]),E.length===0&&D.length===0)return null;let k=new Set(D.map(e=>e.provider)),A=e=>E.find(t=>t.provider===e)?.label??e,j=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(u(null),T.mutate({provider:n.provider,subject:n.subject}))};return o(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[h.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(x,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[d(S,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:A(f.provider)})]}),(f?.kind===`error`||c)&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[d(b,{className:`h-3.5 w-3.5 shrink-0`}),c??(f?.kind===`error`?f.message:``)]}),D.length>0&&d(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:D.map(t=>{let n=t.providerLabel??t.provider;return o(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`font-medium text-foreground truncate`,children:[n,!t.available&&d(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),d(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:ke(t.linkedAt)})})]}),o(`button`,{onClick:()=>void j(t,n),disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d(ne,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),d(`div`,{className:`flex flex-wrap gap-2`,children:E.filter(e=>!k.has(e.provider)).map(t=>o(`button`,{onClick:()=>{u(null),p(null),h.requestProof().then(e=>{e!==null&&(m.current=B(null),y(m.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?d(w,{className:`h-3 w-3 animate-spin`}):d(x,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}n();function je({value:n,size:i=192}){let{t:s}=L(),[c,l]=a(null),[u,f]=a(null);if(r(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||l(e)}catch(e){r||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||f(`qrcode library not installed`)}),()=>{r=!0}},[n]),u)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:s(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!c)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:s(`users.totpQrCode.generating`,`Generating…`)});let p=c.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)c.modules.data[e*p+t]&&h.push(d(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return o(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[d(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}n();function Me(){let{t:e}=L(),t=T(),[n,r]=a(``),[i,s]=a(``),[c,l]=a(``),[f,p]=a(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),r(``),s(``),l(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=i.length>0&&c.length>0&&i!==c,g=i.length>0&&i.length<8,_=n.length>=1&&i.length>=8&&i===c;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:n,onChange:r,autoComplete:`current-password`}),d(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:i,onChange:s,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),d(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:c,onChange:l,autoComplete:`new-password`}),(h||g)&&d(`div`,{className:`text-[11px] text-danger`,children:h?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&o(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?d(S,{className:`h-3 w-3`}):d(b,{className:`h-3 w-3`}),f.msg]}),d(`div`,{className:`flex justify-end`,children:o(N,{onClick:()=>{p(null),m.mutate({currentPassword:n,newPassword:i})},disabled:!_||m.isPending,children:[m.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(E,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:n,autoComplete:r,hint:i}){return o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),i&&d(`div`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function Ne({username:e}){let{t}=L(),n=T(),l=s({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>n.getOwnTotpStatus()}),p=l.data,[m,h]=a(null),[g,_]=a(``),[v,x]=a(null),[C,E]=a(!1),D=u({mutationFn:()=>n.setupOwnTotp(),onSuccess:e=>{h({secret:e.secret,otpauthUrl:e.otpauthUrl}),_(``),x(null)},onError:e=>x(e instanceof Error?e.message:`Setup failed`)}),O=u({mutationFn:e=>n.confirmOwnTotp(e),onSuccess:()=>{h(null),_(``),x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=G(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:n.disableOwnTotp({reauthToken:e})},onSuccess:()=>{x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Disable failed`)});r(()=>{if(!C)return;let e=setTimeout(()=>E(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:m?`setup_in_progress`:p?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,p?.enabled,m]);return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&o(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(w,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&o(c,{children:[d(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),d(`div`,{className:`flex justify-end`,children:o(N,{onClick:()=>{x(null),D.mutate()},disabled:D.isPending,children:[D.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&m&&o(c,{children:[d(`div`,{className:`text-[11px] text-foreground-subtle`,children:d(H,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:d(`span`,{className:`font-mono`})}})}),o(`div`,{className:`flex flex-col items-center gap-3`,children:[d(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:d(je,{value:m.otpauthUrl,size:180})}),o(`div`,{className:`w-full`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),o(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[d(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:m.secret}),o(N,{variant:`ghost`,onClick:()=>{m&&navigator.clipboard.writeText(m.secret).then(()=>E(!0))},children:[C?d(S,{className:`h-3 w-3 text-success`}):d(y,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),d(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value: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&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(b,{className:`h-3 w-3`}),v]}),o(`div`,{className:`flex justify-end gap-2`,children:[d(N,{variant:`outline`,onClick:()=>{h(null),x(null),_(``)},children:t(`common.cancel`,`Cancel`)}),o(N,{onClick:()=>{x(null),O.mutate({code:g})},disabled:O.isPending||g.length!==6,children:[O.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(S,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&p&&o(c,{children:[o(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[d(S,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),o(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[d(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),d(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:p.confirmedAt?new Date(p.confirmedAt).toLocaleString():`—`})})]})]}),v&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(b,{className:`h-3 w-3`}),v]}),d(`div`,{className:`flex justify-end`,children:o(N,{variant:`danger`,onClick:()=>{x(null),A.mutate()},disabled:A.isPending,children:[A.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return ae(`auth-webauthn/passkey-enrollment`)?d(F,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}n();function Q(e){return e.message.length>0?e.message:le.t(`auth.authAuditSection.requestFailed`)}function Fe(){let{t:e}=L(),{logout:t}=R(),n=M(),r=I.useUtils(),i=I.auth.listOwnSessions.useQuery(),[s,c]=a(null),l=I.auth.revokeOwnSession.useMutation({onSuccess:()=>void r.auth.listOwnSessions.invalidate(),onError:e=>c(`Sign out failed: ${Q(e)}`)}),u=I.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>c(`Sign out failed: ${Q(e)}`)}),f=async t=>{await n({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ye(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(c(null),l.mutate({id:t.id}))},p=async()=>{await n({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(c(null),u.mutate({everywhere:!0}))};return o(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),s!==null&&d(`div`,{className:`text-[11px] text-danger`,children:s}),d(K,{sessions:i.data??[],isLoading:i.isLoading,loadError:i.isError?i.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:l.isPending?l.variables?.id??null:null}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[u.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(j,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}n();var Ie=`You`;function Le(){let{t:e}=L(),t=M(),n=I.useUtils(),r=I.auth.listOwnDeviceCredentials.useQuery(),[o,s]=a(null),c=I.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||s(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>s(`Revoke failed: ${e.message}`)}),l=i(()=>(r.data??[]).map(e=>ve(e,Ie)),[r.data]),u=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(s(null),c.mutate({id:n.id}))},p={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:m,isAvailable:he,onRun:e=>void u(e),busyId:c.isPending?c.variables?.id??null:null,disabled:c.isPending};return d(pe,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:f,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:_e(o),onDismissNotice:()=>s(null),children:d(me,{rows:l,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:p})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},Re=[`linked`,`linkError`],ze={view:{icon:v,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:p,cls:`bg-primary/15 text-primary`},delete:{icon:h,cls:`bg-danger/15 text-danger`}};function Be(){let{t:e}=L(),{user:t,logout:n}=R(),[r]=V(),i=e(`system.myAccess`,`My access`);if(!t)return d(fe,{icon:O,title:i,children:d(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(Re.some(e=>r.has(e))&&!r.has(`tab`)){let e=new URLSearchParams(r);return e.set(`tab`,$.signIn),d(z,{to:`?${e.toString()}`,replace:!0})}return d(de,{icon:O,title:i,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:o(N,{variant:`outline`,onClick:n,children:[d(j,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:d(Ve,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:o(`div`,{className:`space-y-4`,children:[d(Me,{}),d(Ne,{username:t.username}),d(Pe,{}),d(Ae,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:o(`div`,{className:`space-y-4`,children:[d(Fe,{}),d(Le,{}),d(De,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:d(ge,{ownOnly:!0})}]})}function Ve({user:e}){let{t}=L(),n=e.isAdmin,r=e.scopes??[];return o(`div`,{className:`space-y-4`,children:[o(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[d(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),o(`div`,{className:`flex-1 min-w-0`,children:[d(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,d(H,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:d(`span`,{className:`font-mono`})}})]})]})]}),n&&o(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[d(C,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),o(`div`,{children:[d(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),d(`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.`)})]})]}),r.length>0&&d(He,{scopes:r})]})}function He({scopes:e}){let{t}=L(),n=D();return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2 border-b border-border`,children:[d(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),d(`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.`)})]}),o(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[d(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),d(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),d(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),d(`ul`,{className:`divide-y divide-border`,children:e.map((e,r)=>o(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[d(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),d(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?se(e.selector,n):e.target}),d(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(n=>{let r=e.access.includes(n),{icon:i,cls:a}=ze[n];return o(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${r?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:r?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:n}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:n}),children:[d(i,{className:`h-3 w-3`}),n]},n)})})]},r))})]})}export{Be as MyAccessPage};
2
+ import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{$ as n,B as r,G as i,J as a,S as o,a as s,b as c,q as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{$t as f,Fn as p,Gi as m,It as h,Nt as g,Q as _,Rr as v,Zr as y,hi as b,lr as x,mi as S,mr as C,or as w,ot as T,rr as E,sa as D,sn as O}from"./player-overlays-DDFLUcm1.js";import{Mr as k,Nr as A}from"./client-BnEPcD6s.js";import{s as j}from"./video-BISLfAY2.js";import{t as ee}from"./key-round-BH39VAkM.js";import{t as te}from"./monitor-smartphone-rIimQM0r.js";import{t as ne}from"./unlink-BK0Zya0K.js";import{Br as M,Es as re,Hr as N,Nr as ie,Uu as P,cr as F,fn as ae,md as I,sr as oe,ws as se,wt as ce}from"./src-CWZRb0ia.js";import{t as le}from"./i18n-DsGcRtAk.js";import{t as L}from"./useTranslation-D3Is_4B6.js";import"./mount-DPfjZqVB.js";import{_ as ue,er as R,fr as z,g as B,hr as V,ur as H,v as U,y as W}from"./index-CgxpaFwe.js";import{t as de}from"./AdminSectionedPage-B-MH77Vx.js";import{t as fe}from"./AdminPage-92KQDOBy.js";import{O as pe,T as me,_ as G,a as he,h as ge,k as _e,r as ve,t as K,v as ye}from"./SessionsList-DrklEq9Z.js";n();var be=`${k}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function xe(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 A(e)}function Se(e){return e.startsWith(`https://`)}function Ce(e){let t=e.flatMap(e=>{let t=xe(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:Se(r),plausible:e.plausible}]))}function we(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 Te(e){let t=new URL(be);return t.searchParams.set(`hub`,e),t.toString()}var Ee=176,Y={scheme:`https`};function De(){let{t:e}=L(),t=re(Y),n=se(Y).data?.roles.publicEndpoint.resolved??null;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?o(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[d(w,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?o(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[d(g,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),o(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[d(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),d(N,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):d(Oe,{candidates:Ce(t.data.endpoints),preferredOrigin:n})]})]})}function Oe({candidates:e,preferredOrigin:t}){let{t:n}=L(),[r,s]=a(null),c=we(e,r,t),l=i(()=>c?Te(c.origin):null,[c]);if(c===null||l===null)return d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.empty`)});let u=e=>n(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${u(e.tier)} — ${e.origin}`}));return o(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[d(oe,{value:l,size:Ee,alt:n(`connectPhone.qrAlt`),className:`self-start`}),o(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[o(`label`,{className:`block space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.addressLabel`)}),d(P,{value:c.origin,options:f,onChange:e=>s(e.target.value)}),o(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[u(c.tier),` · `,c.label]})]}),!c.secure&&d(X,{text:n(`connectPhone.insecure`)}),!c.plausible&&d(X,{text:n(`connectPhone.implausible`)}),o(`div`,{className:`space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.linkLabel`)}),o(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[d(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:l}),d(ae,{value:l,srLabel:n(`connectPhone.linkLabel`)})]})]}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.signInHint`)})]})]})}function X({text:e}){return o(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[d(g,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),d(`span`,{children:e})]})}n();function ke(e){return new Date(e).toLocaleDateString()}function Ae(){let{t:e}=L(),t=M(),n=I.useUtils(),i=I.auth.listLinkableProviders.useQuery(),s=I.auth.listOwnExternalIdentities.useQuery(),[c,u]=a(null),[f,p]=a(()=>W(window.location.search)),m=l(null),h=G(`Linking a sign-in account`),g=l(null);r(()=>()=>g.current?.(),[]);let[v,y]=a(null);r(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=I.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=m.current;if(m.current=null,t===null||t.closed){window.location.assign(e);return}let r=e=>{y(null),p(W(`?${e}`)),n.auth.listOwnExternalIdentities.invalidate()};g.current?.(),g.current=ue(t,{onReturn:e=>{e.target===`profile`&&r(e.query)},onDone:e=>{e.target===`profile`&&r(e.query)},onClosed:()=>{g.current?.(),g.current=null,n.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=_(U(e))},onError:e=>{m.current?.close(),m.current=null,y(null),u(e.message)}}),T=I.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void n.auth.listOwnExternalIdentities.invalidate(),onError:e=>u(e.message)}),E=i.data??[],D=s.data??[],O=v!==null&&D.some(e=>e.provider===v);if(r(()=>{!O||v===null||(y(null),p({kind:`linked`,provider:v}))},[O,v]),E.length===0&&D.length===0)return null;let k=new Set(D.map(e=>e.provider)),A=e=>E.find(t=>t.provider===e)?.label??e,j=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(u(null),T.mutate({provider:n.provider,subject:n.subject}))};return o(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[h.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(x,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[d(S,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:A(f.provider)})]}),(f?.kind===`error`||c)&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[d(b,{className:`h-3.5 w-3.5 shrink-0`}),c??(f?.kind===`error`?f.message:``)]}),D.length>0&&d(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:D.map(t=>{let n=t.providerLabel??t.provider;return o(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`font-medium text-foreground truncate`,children:[n,!t.available&&d(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),d(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:ke(t.linkedAt)})})]}),o(`button`,{onClick:()=>void j(t,n),disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d(ne,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),d(`div`,{className:`flex flex-wrap gap-2`,children:E.filter(e=>!k.has(e.provider)).map(t=>o(`button`,{onClick:()=>{u(null),p(null),h.requestProof().then(e=>{e!==null&&(m.current=B(null),y(m.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?d(w,{className:`h-3 w-3 animate-spin`}):d(x,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}n();function je({value:n,size:i=192}){let{t:s}=L(),[c,l]=a(null),[u,f]=a(null);if(r(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||l(e)}catch(e){r||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||f(`qrcode library not installed`)}),()=>{r=!0}},[n]),u)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:s(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!c)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:s(`users.totpQrCode.generating`,`Generating…`)});let p=c.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)c.modules.data[e*p+t]&&h.push(d(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return o(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[d(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}n();function Me(){let{t:e}=L(),t=T(),[n,r]=a(``),[i,s]=a(``),[c,l]=a(``),[f,p]=a(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),r(``),s(``),l(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=i.length>0&&c.length>0&&i!==c,g=i.length>0&&i.length<8,_=n.length>=1&&i.length>=8&&i===c;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:n,onChange:r,autoComplete:`current-password`}),d(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:i,onChange:s,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),d(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:c,onChange:l,autoComplete:`new-password`}),(h||g)&&d(`div`,{className:`text-[11px] text-danger`,children:h?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&o(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?d(S,{className:`h-3 w-3`}):d(b,{className:`h-3 w-3`}),f.msg]}),d(`div`,{className:`flex justify-end`,children:o(N,{onClick:()=>{p(null),m.mutate({currentPassword:n,newPassword:i})},disabled:!_||m.isPending,children:[m.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(E,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:n,autoComplete:r,hint:i}){return o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),i&&d(`div`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function Ne({username:e}){let{t}=L(),n=T(),l=s({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>n.getOwnTotpStatus()}),p=l.data,[m,h]=a(null),[g,_]=a(``),[v,x]=a(null),[C,E]=a(!1),D=u({mutationFn:()=>n.setupOwnTotp(),onSuccess:e=>{h({secret:e.secret,otpauthUrl:e.otpauthUrl}),_(``),x(null)},onError:e=>x(e instanceof Error?e.message:`Setup failed`)}),O=u({mutationFn:e=>n.confirmOwnTotp(e),onSuccess:()=>{h(null),_(``),x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=G(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:n.disableOwnTotp({reauthToken:e})},onSuccess:()=>{x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Disable failed`)});r(()=>{if(!C)return;let e=setTimeout(()=>E(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:m?`setup_in_progress`:p?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,p?.enabled,m]);return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&o(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(w,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&o(c,{children:[d(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),d(`div`,{className:`flex justify-end`,children:o(N,{onClick:()=>{x(null),D.mutate()},disabled:D.isPending,children:[D.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&m&&o(c,{children:[d(`div`,{className:`text-[11px] text-foreground-subtle`,children:d(H,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:d(`span`,{className:`font-mono`})}})}),o(`div`,{className:`flex flex-col items-center gap-3`,children:[d(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:d(je,{value:m.otpauthUrl,size:180})}),o(`div`,{className:`w-full`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),o(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[d(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:m.secret}),o(N,{variant:`ghost`,onClick:()=>{m&&navigator.clipboard.writeText(m.secret).then(()=>E(!0))},children:[C?d(S,{className:`h-3 w-3 text-success`}):d(y,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),d(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value: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&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(b,{className:`h-3 w-3`}),v]}),o(`div`,{className:`flex justify-end gap-2`,children:[d(N,{variant:`outline`,onClick:()=>{h(null),x(null),_(``)},children:t(`common.cancel`,`Cancel`)}),o(N,{onClick:()=>{x(null),O.mutate({code:g})},disabled:O.isPending||g.length!==6,children:[O.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(S,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&p&&o(c,{children:[o(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[d(S,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),o(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[d(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),d(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:p.confirmedAt?new Date(p.confirmedAt).toLocaleString():`—`})})]})]}),v&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(b,{className:`h-3 w-3`}),v]}),d(`div`,{className:`flex justify-end`,children:o(N,{variant:`danger`,onClick:()=>{x(null),A.mutate()},disabled:A.isPending,children:[A.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return ie(`auth-webauthn/passkey-enrollment`)?d(F,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}n();function Q(e){return e.message.length>0?e.message:le.t(`auth.authAuditSection.requestFailed`)}function Fe(){let{t:e}=L(),{logout:t}=R(),n=M(),r=I.useUtils(),i=I.auth.listOwnSessions.useQuery(),[s,c]=a(null),l=I.auth.revokeOwnSession.useMutation({onSuccess:()=>void r.auth.listOwnSessions.invalidate(),onError:e=>c(`Sign out failed: ${Q(e)}`)}),u=I.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>c(`Sign out failed: ${Q(e)}`)}),f=async t=>{await n({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ye(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(c(null),l.mutate({id:t.id}))},p=async()=>{await n({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(c(null),u.mutate({everywhere:!0}))};return o(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),s!==null&&d(`div`,{className:`text-[11px] text-danger`,children:s}),d(K,{sessions:i.data??[],isLoading:i.isLoading,loadError:i.isError?i.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:l.isPending?l.variables?.id??null:null}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[u.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(j,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}n();var Ie=`You`;function Le(){let{t:e}=L(),t=M(),n=I.useUtils(),r=I.auth.listOwnDeviceCredentials.useQuery(),[o,s]=a(null),c=I.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||s(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>s(`Revoke failed: ${e.message}`)}),l=i(()=>(r.data??[]).map(e=>ve(e,Ie)),[r.data]),u=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(s(null),c.mutate({id:n.id}))},p={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:m,isAvailable:he,onRun:e=>void u(e),busyId:c.isPending?c.variables?.id??null:null,disabled:c.isPending};return d(pe,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:f,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:_e(o),onDismissNotice:()=>s(null),children:d(me,{rows:l,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:p})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},Re=[`linked`,`linkError`],ze={view:{icon:v,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:p,cls:`bg-primary/15 text-primary`},delete:{icon:h,cls:`bg-danger/15 text-danger`}};function Be(){let{t:e}=L(),{user:t,logout:n}=R(),[r]=V(),i=e(`system.myAccess`,`My access`);if(!t)return d(fe,{icon:O,title:i,children:d(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(Re.some(e=>r.has(e))&&!r.has(`tab`)){let e=new URLSearchParams(r);return e.set(`tab`,$.signIn),d(z,{to:`?${e.toString()}`,replace:!0})}return d(de,{icon:O,title:i,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:o(N,{variant:`outline`,onClick:n,children:[d(j,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:d(Ve,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:o(`div`,{className:`space-y-4`,children:[d(Me,{}),d(Ne,{username:t.username}),d(Pe,{}),d(Ae,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:o(`div`,{className:`space-y-4`,children:[d(Fe,{}),d(Le,{}),d(De,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:d(ge,{ownOnly:!0})}]})}function Ve({user:e}){let{t}=L(),n=e.isAdmin,r=e.scopes??[];return o(`div`,{className:`space-y-4`,children:[o(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[d(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),o(`div`,{className:`flex-1 min-w-0`,children:[d(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,d(H,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:d(`span`,{className:`font-mono`})}})]})]})]}),n&&o(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[d(C,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),o(`div`,{children:[d(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),d(`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.`)})]})]}),r.length>0&&d(He,{scopes:r})]})}function He({scopes:e}){let{t}=L(),n=D();return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2 border-b border-border`,children:[d(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),d(`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.`)})]}),o(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[d(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),d(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),d(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),d(`ul`,{className:`divide-y divide-border`,children:e.map((e,r)=>o(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[d(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),d(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ce(e.selector,n):e.target}),d(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(n=>{let r=e.access.includes(n),{icon:i,cls:a}=ze[n];return o(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${r?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:r?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:n}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:n}),children:[d(i,{className:`h-3 w-3`}),n]},n)})})]},r))})]})}export{Be as MyAccessPage};
@@ -1 +1 @@
1
- import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{An as l,Br as u,D as d,It as f,L as p,Nt as m,Si as h,Yt as g,Z as _,Zr as v,Zt as y,bn as b,dn as x,dt as S,hn as ee,ht as C,kn as w,on as T,or as E,ot as D,rr as O,yn as te,zn as k}from"./player-overlays-mwQ6DKjG.js";import{Ar as ne,Er as re,Jn as ie,jr as ae}from"./client-CHpTazh3.js";import{t as A}from"./boxes-0BuMQdjm.js";import{l as j,s as oe}from"./video-DJjbkBZD.js";import{t as se}from"./log-in-RS8mwxfB.js";import{As as ce,Bs as le,Ds as ue,Es as de,Fs as fe,Gr as M,Hs as pe,Is as me,Ln as he,Ls as ge,Ns as _e,Ps as ve,Rr as N,Su as ye,Vs as be,Wu as xe,_n as Se,bs as Ce,gn as we,ks as Te,mi as P,mn as Ee,mr as De,pi as F,ro as Oe,ws as ke,xs as Ae,yn as je,yr as Me,ys as Ne,zu as Pe}from"./src-B5lceK9L.js";import{t as I}from"./i18n-CQ56JIQj.js";import{t as L}from"./useTranslation-D3Is_4B6.js";import"./mount-DoeAV03f.js";import{a as R,dr as Fe,fr as Ie,hr as Le,i as z,x as Re}from"./index-BgKj4CM9.js";import{t as ze}from"./AdminSectionedPage-BfaO7MK2.js";import{t as B}from"./AdminPage-DpgHJ_lQ.js";import{t as Be}from"./NodeAddonsSettingsPanel-Ck7AYA-1.js";import{n as V,r as Ve,t as H}from"./IntegrationHub-FpZU6jWS.js";import{n as U,t as W}from"./addon-display-names-BkwMrExv.js";e();var G=5e3,K=`network-access`,He={connected:!1,endpoint:null};function Ue(){let{t:e}=L(),t=s(),i=P({capName:`network-access`},{refetchInterval:G}),a=F(void 0,{refetchInterval:G}),o=n(()=>W(a.data??[]),[a.data]),l=n(()=>(i.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[i.data,o]),[u,d]=r(null),[f,p]=r({}),m=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),d(null),p(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},h=(e,t)=>{d(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);p(e=>({...e,[n]:r}))},g=be({onSuccess:m,onError:h}),_=pe({onSuccess:m,onError:h}),v=[{id:K,label:e(`system.remoteAccess.remoteAccess`,`Remote access`),install:{capability:K,label:e(`system.remoteAccess.addTunnel`,`Add tunnel`)},entries:l.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:j,...U(e.isActive),render:()=>c(V,{addonId:e.addonId,displayName:e.displayName,capName:K,isActive:e.isActive,badges:c(Ge,{addonId:e.addonId}),error:f[e.addonId]??null,primaryAction:c(Ke,{addonId:e.addonId,busyId:u,onStart:e=>{d(e),g.mutate({addonId:e})},onStop:e=>{d(e),_.mutate({addonId:e})}})})}))}];return c(H,{embedded:!0,icon:j,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),groups:v,isLoading:i.isLoading,emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`)})}function We(e){let{data:t}=le({addonId:e},{refetchInterval:G,retry:!1}),n=t?re.safeParse(t):null;return n?.success?n.data:He}function Ge({addonId:e}){let{t}=L(),n=We(e);return a(o,{children:[c(M,{variant:n.connected?`success`:`default`,className:Ve,children:n.connected?t(`system.remoteAccess.connected`,`Connected`):t(`system.remoteAccess.disconnected`,`Disconnected`)}),n.endpoint&&a(`a`,{href:n.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[c(u,{className:`h-3 w-3`}),n.endpoint.url]})]})}function Ke({addonId:e,busyId:t,onStart:n,onStop:r}){let{t:i}=L(),o=We(e),s=t===e;return o.connected?a(N,{size:`sm`,variant:`secondary`,disabled:s,onClick:()=>r(e),children:[s?c(E,{className:`h-3 w-3 animate-spin`}):c(g,{className:`h-3 w-3`}),i(`system.remoteAccess.stop`,`Stop`)]}):a(N,{size:`sm`,variant:`primary`,disabled:s,onClick:()=>n(e),children:[s?c(E,{className:`h-3 w-3 animate-spin`}):c(l,{className:`h-3 w-3`}),i(`system.remoteAccess.start`,`Start`)]})}e();var qe=3e4,q=`turn-provider`;function Je(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function Ye(){let{t:e}=L(),t=P({capName:`turn-provider`},{refetchInterval:qe}),r=F(void 0,{refetchInterval:qe}),i=ye(),o=i.data??[],s=n(()=>W(r.data??[]),[r.data]),l=n(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:s.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,s]),u=[{id:q,label:e(`system.turnServers.turnProviders`,`TURN providers`),install:{capability:q,label:e(`system.turnServers.addProvider`,`Add provider`)},entries:l.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:k,...U(t.isActive),render:()=>c(V,{addonId:t.addonId,displayName:t.displayName,capName:q,isActive:t.isActive,panels:[{id:`ice-servers`,title:e(`system.turnServers.discoveredIceServers`,`Discovered ICE servers`),icon:k,content:c(Xe,{addonId:t.addonId,enabled:t.isActive})}]})}))}];return c(H,{embedded:!0,icon:k,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),groups:u,isLoading:t.isLoading,emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),trailing:c(Se,{headingId:`turn-combined-ice`,title:e(`system.turnServers.combinedIceServerListAll`,`Combined ICE server list — all enabled providers`),icon:k,actions:c(N,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:e(`common.refresh`,`Refresh`)}),children:c(`div`,{className:d,children:o.length===0?c(`div`,{className:`text-xs text-foreground-subtle`,children:e(`system.turnServers.noServersFromEnabledProviders`,`No servers from enabled providers.`)}):c(`div`,{className:`flex flex-col gap-3`,children:o.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return a(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&a(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&a(`span`,{children:[c(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,c(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&a(`span`,{children:[c(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,c(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),c(`ul`,{className:`divide-y divide-border`,children:n.map(e=>c(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})})})}function Xe({addonId:e,enabled:t}){let r=ye({addonId:e},{enabled:t,retry:!1}),i=n(()=>Je(r.data??[]),[r.data]),a=t?r.isLoading?`Loading…`:i.length===0?`This provider returned no servers.`:null:`Disabled — enable the provider to fetch its servers.`;return c(`div`,{className:`rounded-lg border border-border bg-surface p-2 sm:p-3`,children:a===null?c(`div`,{className:`flex flex-wrap gap-1`,children:i.map(e=>c(`span`,{className:`inline-block break-all rounded bg-foreground-subtle/10 px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e},e))}):c(`div`,{className:`text-xs text-foreground-subtle`,children:a})})}e();var Ze={lan:k,wifi:C,docker:A,vpn:O,loopback:x,other:x},Qe={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},$e=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function et(e){let{t}=L(),{interfaces:r,disabled:i,hideLoopback:o,ipv4Only:s,emptyMessage:l}=e,u=n(()=>r.filter(e=>!(o&&e.kind===`loopback`||s&&e.family!==`IPv4`)),[r,o,s]),d=n(()=>{let e=new Map;for(let t of u){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return $e.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[u]),f=t=>e.mode===`single`?e.value===t:e.value.includes(t),p=t=>{if(i||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let n=new Set(e.value);n.has(t.address)?n.delete(t.address):n.add(t.address),e.onChange([...n])};return u.length===0?c(`div`,{className:`text-xs text-foreground-subtle italic`,children:l??t(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):c(`div`,{className:`flex flex-col gap-3`,children:d.map(({kind:n,items:r})=>a(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[a(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[c(Ze[n]??x,{className:`h-3.5 w-3.5 text-foreground-subtle`}),c(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Qe[n]??n}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),c(`ul`,{className:`divide-y divide-border`,children:r.map(n=>{let r=f(n.address),o=n.kind===`loopback`,s=!n.plausible&&!o;return a(`li`,{className:`flex items-center gap-3 px-3 py-2 ${o?`opacity-60 cursor-not-allowed`:i?`opacity-60`:s?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>p(n),children:[c(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&c(h,{className:`h-3 w-3`})}),a(`div`,{className:`flex-1 min-w-0 ${s?`text-foreground-subtle`:``}`,children:[a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[c(`span`,{className:`font-mono text-xs font-semibold ${s?`text-foreground-subtle`:`text-foreground`}`,children:n.name}),c(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:n.family}),n.preferred&&c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:t(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),o&&c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:t(`shared.addressSelector.alwaysIncluded`,`Always included`)}),s&&a(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[c(m,{className:`h-2.5 w-2.5`}),t(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),a(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[n.address,n.cidr&&n.cidr!==n.address?` (${n.cidr})`:``]})]})]},`${n.name}-${n.family}-${n.address}`)})})]},n))})}var J=[{role:`appConnections`,get title(){return I.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return I.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return I.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return I.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return I.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.internalHelp`)}}],tt=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function Y(e,t){return e.inUse.includes(t)}function nt(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return Y(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&Y(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:ne}:{kind:`set`,input:n}}function rt(e){return J.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}e();var it={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function at({book:e,loading:t,saving:n,error:i,onSetRole:o,onAdd:s,onRemove:l}){let{t:u}=L(),[d,p]=r(``),[h,g]=r(``),[_,v]=r(null),[y,b]=r(null),x=()=>{let e=ae(d);if(!e.ok){v(e.reason);return}v(null),p(``),g(``),s(e.baseUrl,h.trim())},S=(e,t)=>{let n=nt(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),o(n.input)}},ee=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:t=>a(`div`,{className:`min-w-0 py-0.5`,children:[c(`div`,{className:`font-mono text-[12px] break-all ${t.plausible?`text-foreground`:`text-foreground-subtle`}`,children:t.baseUrl}),a(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[c(`span`,{children:t.label}),t.kind===`app-link`&&a(`span`,{className:`font-mono`,children:[`hub=`,` `,e?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),t.custom&&t.detected&&c(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),t.kind!==`custom`&&t.interfaceKind!==`lan`&&t.interfaceKind!==`public`&&t.interfaceKind!==`other`&&c(`span`,{className:`uppercase tracking-wide`,children:t.interfaceKind}),!t.plausible&&t.interfaceKind!==`loopback`&&a(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[c(m,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=it[e.kind]??it.loopback;return c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...J.map(e=>({key:e.role,headerRender:()=>c(`span`,{title:e.help,children:e.title}),align:`center`,nowrap:!0,width:`w-24`,render:t=>{let r=t.eligible.includes(e.role),i=t.flags.includes(e.role),o=Y(t,e.role);return a(`label`,{className:`inline-flex items-center justify-center gap-1 ${r?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:r?o&&!i?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:e.title,help:e.help}):e.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[c(he,{checked:r&&o,disabled:!r||n,onChange:()=>S(t,e),"aria-label":`${e.title}: ${t.baseUrl}`}),o&&!i&&r&&c(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?c(N,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:c(f,{className:`h-3 w-3`})}):null}],C=e===void 0?[]:rt(e);return a(De,{children:[a(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[a(`div`,{children:[c(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),c(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),a(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[c(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),c(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:J.map(e=>a(`div`,{className:`contents`,children:[c(`dt`,{className:`font-medium`,children:e.title}),c(`dd`,{className:`text-foreground-subtle`,children:e.help})]},e.role))}),c(`p`,{className:`mt-1.5 text-foreground-subtle`,children:tt})]})]}),C.length>0&&c(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:C.map(e=>a(`div`,{className:`contents`,children:[c(`span`,{className:`text-foreground-subtle`,children:e.title}),a(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${e.role}`,children:[e.inUse,c(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:e.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),e.automatic?c(`span`,{}):c(N,{size:`sm`,variant:`secondary`,disabled:n,onClick:()=>o({role:e.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},e.role))}),y!==null&&a(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[c(m,{className:`h-3.5 w-3.5 text-amber-600`}),c(`span`,{className:`flex-1 min-w-[220px]`,children:y.reason}),c(N,{size:`sm`,variant:`secondary`,onClick:()=>{o({...y.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),c(N,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),i!==null&&c(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:i})]}),c(je,{columns:ee,rows:e?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:t?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),a(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[a(`div`,{className:`flex-1 min-w-[220px]`,children:[c(xe,{value:d,onChange:e=>{p(e.target.value),v(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:n}),_!==null&&c(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:_})]}),c(`div`,{className:`w-48`,children:c(xe,{value:h,onChange:e=>g(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:n})}),a(N,{size:`sm`,variant:`secondary`,disabled:n||d.trim()===``,onClick:x,children:[c(w,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}e();function ot(){let{t:e}=L(),i=s(),o=()=>{i.invalidateQueries({queryKey:[[`localNetwork`]]})},l=ke(void 0,{refetchInterval:3e4}),u=Ae(void 0),f=ce({onSuccess:o}),p=ue({onSuccess:e=>{w(e.addresses),o()}}),m=n(()=>l.data?.interfaces??[],[l.data]),h=Ce({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),g=Te({onSuccess:o}),_=Ne({onSuccess:o}),v=de({onSuccess:o}),x=g.error?.message??_.error?.message??v.error?.message??null,S=g.isPending||_.isPending||v.isPending,[C,w]=r([]),[T,E]=r(!1);t(()=>{!T&&u.data&&(w(u.data.addresses),E(!0))},[u.data,T]);let D=u.data?.addresses??[],O=n(()=>{if(C.length!==D.length)return!0;let e=[...C].toSorted(),t=[...D].toSorted();return e.some((e,n)=>e!==t[n])},[C,D]);return a(B,{embedded:!0,children:[a(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[c(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:e(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),c(`div`,{className:`flex items-center gap-2 shrink-0`,children:a(N,{size:`sm`,variant:`secondary`,onClick:()=>{l.refetch(),u.refetch(),h.refetch()},disabled:l.isLoading,children:[c(b,{className:`h-3 w-3 ${l.isLoading?`animate-spin`:``}`}),e(`common.refresh`,`Refresh`)]})})]}),c(Se,{headingId:`network-allowed-addresses`,title:e(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:a(`div`,{className:`flex flex-wrap items-center gap-1`,children:[a(N,{size:`sm`,variant:`secondary`,onClick:()=>p.mutate(void 0),disabled:p.isPending||f.isPending,title:e(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[c(y,{className:`h-3 w-3`}),p.isPending?e(`system.networkAddresses.detecting`,`Detecting…`):e(`system.networkAddresses.bestMatch`,`Best match`)]}),a(N,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||f.isPending,children:[c(te,{className:`h-3 w-3`}),e(`system.networkAddresses.clear`,`Clear`)]}),O&&c(N,{size:`sm`,variant:`secondary`,onClick:()=>{w(D)},disabled:f.isPending,children:e(`system.networkAddresses.discard`,`Discard`)}),a(N,{size:`sm`,variant:`primary`,onClick:()=>{f.mutate({addresses:[...C]})},disabled:!O||f.isPending,children:[c(ee,{className:`h-3 w-3`}),f.isPending?e(`system.networkAddresses.saving`,`Saving…`):e(`common.save`,`Save`)]})]}),children:a(`div`,{className:d,children:[c(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?e(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):e(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),c(et,{mode:`multiple`,interfaces:m,value:C,onChange:w,disabled:f.isPending,emptyMessage:l.isLoading?e(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):e(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),c(at,{book:h.data,loading:h.isLoading,saving:S,error:x,onSetRole:e=>g.mutate({...e}),onAdd:(e,t)=>_.mutate({baseUrl:e,label:t}),onRemove:e=>v.mutate({baseUrl:e})})]})}e();var st={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},X=5e3,Z=`mesh-network`,ct=3e4,lt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function ut(){let{t:e}=L(),t=P({capName:`mesh-network`},{refetchInterval:X}),r=F(void 0,{refetchInterval:X}),i=n(()=>W(r.data??[]),[r.data]),a=n(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),o=[{id:Z,label:e(`system.meshNetworks.meshNetworks`,`Mesh networks`),install:{capability:Z,label:e(`system.meshNetworks.addMesh`,`Add mesh`)},entries:a.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:k,...U(t.isActive),render:()=>c(V,{addonId:t.addonId,displayName:t.displayName,capName:Z,isActive:t.isActive,badges:c(dt,{addonId:t.addonId}),primaryAction:c(ft,{addonId:t.addonId}),panels:[{id:`status`,title:e(`system.meshNetworks.status`,`Status`),icon:A,content:c(pt,{addonId:t.addonId})}]})}))}];return c(H,{embedded:!0,icon:A,title:e(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:e(`system.meshNetworks.privateVpnMeshesThatConnect`,`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`),groups:o,isLoading:t.isLoading,emptyTitle:e(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:e(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`)})}function Q(e){let{data:t,isLoading:n}=_e({addonId:e},{refetchInterval:X,retry:!1}),r=t?ie.safeParse(t):null;return{status:r?.success?r.data:lt,isLoading:n}}function dt({addonId:e}){let{t}=L(),{status:n}=Q(e);return a(o,{children:[c(M,{variant:n.joined?`success`:`default`,className:Ve,children:n.joined?t(`system.meshNetworks.joined`,`Joined`):t(`system.meshNetworks.notJoined`,`Not joined`)}),n.joined&&c(M,{className:`text-[10px]`,children:t(`common.peers`,{count:n.peerCount})})]})}function ft({addonId:e}){let{t}=L(),n=s(),[l,u]=r(!1),[d,f]=r(null),p=D(),{status:m}=Q(e),h=i(()=>{n.invalidateQueries({queryKey:[[`meshNetwork`]]})},[n]),g=ge(),_=ve({onSuccess:h}),v=me({onSuccess:h}),y=i(async()=>{u(!0);let t={cancelled:!1};f(t);try{let n=await g.mutateAsync({addonId:e});if(t.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!t.cancelled&&(await yt(2e3),!t.cancelled);){let t=await p.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),n=t?ie.safeParse(t):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[e,h,g,p]),b=i(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return c(o,{children:m.joined?a(o,{children:[a(N,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:e}),children:[_.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(oe,{className:`h-3 w-3`}),t(`system.meshNetworks.disconnect`,`Disconnect`)]}),a(N,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:e}),children:[v.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(T,{className:`h-3 w-3`}),t(`system.meshNetworks.logOut`,`Log out`)]})]}):l?a(N,{size:`sm`,variant:`ghost`,onClick:b,children:[c(S,{className:`h-3 w-3 mr-1`}),` `,t(`common.cancel`)]}):a(o,{children:[a(N,{size:`sm`,variant:`primary`,onClick:()=>void y(),children:[c(se,{className:`h-3 w-3`}),t(`system.meshNetworks.connect`,`Connect`)]}),a(N,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:e}),children:[v.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(T,{className:`h-3 w-3`}),t(`system.meshNetworks.logOut`,`Log out`)]})]})})}function pt({addonId:e}){let{t}=L(),{status:n}=Q(e),r=fe({addonId:e},{refetchInterval:ct,retry:!1});return a(`div`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[n.error&&c(Me,{message:n.error}),c(mt,{status:n}),n.endpoints.length>0&&a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:t(`system.meshNetworks.endpoints`,`Endpoints`)}),n.endpoints.map(e=>a(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[a(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${st[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?c(j,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),a(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[c(u,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),c(`div`,{className:`border-t border-border`,children:c(gt,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function mt({status:e}){let{t}=L();return c(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:t(`system.meshNetworks.tenant`,`Tenant`),value:e.tenantName||`—`},{label:t(`system.meshNetworks.user`,`User`),value:e.userLogin??`—`},{label:t(`system.meshNetworks.controlPlane`,`Control plane`),value:e.controlPlaneUrl||`—`},{label:t(`system.meshNetworks.meshIp`,`Mesh IP`),value:e.meshIp||`—`,mono:!0},{label:t(`system.meshNetworks.magicdns`,`MagicDNS`),value:e.magicDnsHostname||`—`,mono:!0},{label:t(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:e.magicDnsSuffix||`—`,mono:!0},{label:t(`system.meshNetworks.peers`,`Peers`),value:String(e.peerCount)},{label:t(`system.meshNetworks.keyExpiry`,`Key expiry`),value:e.keyExpiry?ht(e.keyExpiry):`—`}].map(e=>a(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[c(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),c(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function ht(e){let t=e-Date.now();if(t<0)return I.t(`system.meshNetworks.expiredAgo`,{when:$(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return I.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?I.t(`system.meshNetworks.expiryHours`,{count:r}):I.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function gt({peers:e,loading:t}){let{t:r}=L(),o=n(()=>e.map(e=>({...e,_id:e.id})),[e]),s=i(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=n(()=>[{key:`hostname`,header:r(`system.meshNetworks.hostname`,`Hostname`),render:e=>a(`div`,{className:`flex flex-col`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[c(`span`,{className:`font-medium text-foreground`,children:e.hostname||r(`system.meshNetworks.unknown`,`(unknown)`)}),e.isSelf&&c(M,{variant:`info`,children:r(`common.self`)}),e.exitNodeOption&&c(M,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&c(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:r(`system.meshNetworks.magicdns`,`MagicDNS`),render:e=>e.magicDns?a(`div`,{className:`flex items-center gap-1`,children:[c(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),c(`button`,{onClick:()=>s(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":r(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:c(v,{className:`h-3 w-3 text-foreground-subtle`})})]}):c(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?a(`div`,{className:`flex items-center gap-1`,children:[c(`span`,{className:`font-mono text-xs`,children:t}),c(`button`,{onClick:()=>s(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":r(`system.meshNetworks.copyIp`,`Copy IP`),children:c(v,{className:`h-3 w-3 text-foreground-subtle`})})]}):c(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:r(`system.meshNetworks.connection`,`Connection`),render:e=>a(`div`,{className:`flex items-center gap-1.5`,children:[c(M,{variant:_t(e.connection),children:e.connection}),e.relay&&c(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:r(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?c(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):c(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:r(`system.meshNetworks.txRx`,`TX / RX`),render:e=>a(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,vt(e.txBytes),` · ↓ `,vt(e.rxBytes)]})},{key:`lastSeen`,header:r(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>c(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?$(e.lastSeenMs):`—`})}],[s,r]);return t&&e.length===0?a(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[c(E,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,r(`systemPage.meshNetworks.loadingPeers`)]}):e.length===0?c(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:r(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):c(`div`,{className:`p-4`,children:c(je,{columns:l,rows:o,rowKey:e=>e._id,minWidthPx:820})})}function _t(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function vt(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function $(e){let t=Date.now()-e;return t<6e4?I.t(`system.meshNetworks.justNow`):t<36e5?I.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?I.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):I.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}function yt(e){return new Promise(t=>setTimeout(t,e))}var bt=`/system/identity?tab=certificates`;function xt(){let{t:e}=L();return c(B,{embedded:!0,children:a(`div`,{className:p,children:[c(Be,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:e(`system.localAccess.lanHttp`,`LAN HTTP`),description:e(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),a(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[e(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,c(Fe,{className:`underline`,to:bt,children:e(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}e();function St({value:e,onChange:t}){let{t:r}=L(),{data:i}=Oe({isCamera:!0,projection:`slim`}),o=n(()=>i===void 0?[{value:``,label:r(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:i.length===0?[{value:``,label:r(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:r(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...i.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[i,r]);return a(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[c(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.networkDiagnostics.camera`,`Camera`)}),c(Pe,{value:e===null?``:String(e),disabled:i===void 0||i.length===0,onChange:e=>t(e.target.value===``?null:Number(e.target.value)),options:o})]})}function Ct(){let e=D(),[t,n]=r(null);return c(B,{embedded:!0,children:a(`div`,{className:p,"data-testid":`network-diagnostics`,children:[c(we,{loadServers:i(async()=>e.trpcClient.turnProvider.getTurnServers.query(),[e])}),c(Ee,{trpc:e.trpcClient,serverUrl:_(),deviceId:t,cameraField:c(St,{value:t,onChange:n})})]})})}var wt=[`certificate`,`certificates`,`https`];function Tt(){let{t:e}=L(),[t]=Le();if(wt.includes(t.get(`tab`)??``))return c(Ie,{to:bt,replace:!0});let n=Re(`/system/network`,{t:e,isAdmin:!0})??{icon:j,title:e(`system.network`,`Network`)};return c(ze,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:c(xt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:c(ot,{})},{id:R.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:c(Ue,{}),ownedParams:z},{id:R.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:c(ut,{}),ownedParams:z},{id:R.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:c(Ye,{}),ownedParams:z},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:c(Ct,{})}]})}export{Tt as NetworkPage};
1
+ import{$ as e,B as t,G as n,J as r,L as i,S as a,b as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{An as l,Br as u,D as d,It as f,L as p,Nt as m,Si as h,Yt as g,Z as _,Zr as v,Zt as y,bn as b,dn as x,dt as S,hn as ee,ht as C,kn as w,on as T,or as E,ot as D,rr as O,yn as te,zn as k}from"./player-overlays-DDFLUcm1.js";import{Ar as ne,Er as re,Jn as ie,jr as ae}from"./client-BnEPcD6s.js";import{t as A}from"./boxes-BIYyTH0E.js";import{l as j,s as oe}from"./video-BISLfAY2.js";import{t as se}from"./log-in-D6jMFDmP.js";import{As as ce,Bs as le,Cr as ue,Cs as de,Eu as fe,Gs as pe,Hr as M,Ju as me,Ks as he,Ls as ge,Ns as _e,Os as ve,Ps as ye,Rs as be,Ts as xe,Uu as Se,Vn as Ce,Vs as we,Ws as Te,Yr as N,_i as P,_n as Ee,bn as De,hn as Oe,js as ke,so as Ae,vi as F,vn as je,vr as Me,ws as Ne,zs as Pe}from"./src-CWZRb0ia.js";import{t as I}from"./i18n-DsGcRtAk.js";import{t as L}from"./useTranslation-D3Is_4B6.js";import"./mount-DPfjZqVB.js";import{a as R,dr as Fe,fr as Ie,hr as Le,i as z,x as Re}from"./index-CgxpaFwe.js";import{t as ze}from"./AdminSectionedPage-B-MH77Vx.js";import{t as B}from"./AdminPage-92KQDOBy.js";import{t as Be}from"./NodeAddonsSettingsPanel-ivhHs40k.js";import{n as V,r as Ve,t as H}from"./IntegrationHub-DCSIyXBI.js";import{n as U,t as W}from"./addon-display-names-BkwMrExv.js";e();var G=5e3,K=`network-access`,He={connected:!1,endpoint:null};function Ue(){let{t:e}=L(),t=s(),i=F({capName:`network-access`},{refetchInterval:G}),a=P(void 0,{refetchInterval:G}),o=n(()=>W(a.data??[]),[a.data]),l=n(()=>(i.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[i.data,o]),[u,d]=r(null),[f,p]=r({}),m=(e,n)=>{let r=n?.addonId;t.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),d(null),p(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},h=(e,t)=>{d(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);p(e=>({...e,[n]:r}))},g=pe({onSuccess:m,onError:h}),_=he({onSuccess:m,onError:h}),v=[{id:K,label:e(`system.remoteAccess.remoteAccess`,`Remote access`),install:{capability:K,label:e(`system.remoteAccess.addTunnel`,`Add tunnel`)},entries:l.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:j,...U(e.isActive),render:()=>c(V,{addonId:e.addonId,displayName:e.displayName,capName:K,isActive:e.isActive,badges:c(Ge,{addonId:e.addonId}),error:f[e.addonId]??null,primaryAction:c(Ke,{addonId:e.addonId,busyId:u,onStart:e=>{d(e),g.mutate({addonId:e})},onStop:e=>{d(e),_.mutate({addonId:e})}})})}))}];return c(H,{embedded:!0,icon:j,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),groups:v,isLoading:i.isLoading,emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`)})}function We(e){let{data:t}=Te({addonId:e},{refetchInterval:G,retry:!1}),n=t?re.safeParse(t):null;return n?.success?n.data:He}function Ge({addonId:e}){let{t}=L(),n=We(e);return a(o,{children:[c(N,{variant:n.connected?`success`:`default`,className:Ve,children:n.connected?t(`system.remoteAccess.connected`,`Connected`):t(`system.remoteAccess.disconnected`,`Disconnected`)}),n.endpoint&&a(`a`,{href:n.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[c(u,{className:`h-3 w-3`}),n.endpoint.url]})]})}function Ke({addonId:e,busyId:t,onStart:n,onStop:r}){let{t:i}=L(),o=We(e),s=t===e;return o.connected?a(M,{size:`sm`,variant:`secondary`,disabled:s,onClick:()=>r(e),children:[s?c(E,{className:`h-3 w-3 animate-spin`}):c(g,{className:`h-3 w-3`}),i(`system.remoteAccess.stop`,`Stop`)]}):a(M,{size:`sm`,variant:`primary`,disabled:s,onClick:()=>n(e),children:[s?c(E,{className:`h-3 w-3 animate-spin`}):c(l,{className:`h-3 w-3`}),i(`system.remoteAccess.start`,`Start`)]})}e();var qe=3e4,q=`turn-provider`;function Je(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function Ye(){let{t:e}=L(),t=F({capName:`turn-provider`},{refetchInterval:qe}),r=P(void 0,{refetchInterval:qe}),i=fe(),o=i.data??[],s=n(()=>W(r.data??[]),[r.data]),l=n(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:s.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,s]),u=[{id:q,label:e(`system.turnServers.turnProviders`,`TURN providers`),install:{capability:q,label:e(`system.turnServers.addProvider`,`Add provider`)},entries:l.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:k,...U(t.isActive),render:()=>c(V,{addonId:t.addonId,displayName:t.displayName,capName:q,isActive:t.isActive,panels:[{id:`ice-servers`,title:e(`system.turnServers.discoveredIceServers`,`Discovered ICE servers`),icon:k,content:c(Xe,{addonId:t.addonId,enabled:t.isActive})}]})}))}];return c(H,{embedded:!0,icon:k,title:e(`system.turnServers.turnServers`,`TURN Servers`),subtitle:e(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),groups:u,isLoading:t.isLoading,emptyTitle:e(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:e(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),trailing:c(je,{headingId:`turn-combined-ice`,title:e(`system.turnServers.combinedIceServerListAll`,`Combined ICE server list — all enabled providers`),icon:k,actions:c(M,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:e(`common.refresh`,`Refresh`)}),children:c(`div`,{className:d,children:o.length===0?c(`div`,{className:`text-xs text-foreground-subtle`,children:e(`system.turnServers.noServersFromEnabledProviders`,`No servers from enabled providers.`)}):c(`div`,{className:`flex flex-col gap-3`,children:o.map((e,t)=>{let n=Array.isArray(e.urls)?e.urls:[e.urls];return a(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&a(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&a(`span`,{children:[c(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,c(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&a(`span`,{children:[c(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,c(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),c(`ul`,{className:`divide-y divide-border`,children:n.map(e=>c(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})})})}function Xe({addonId:e,enabled:t}){let r=fe({addonId:e},{enabled:t,retry:!1}),i=n(()=>Je(r.data??[]),[r.data]),a=t?r.isLoading?`Loading…`:i.length===0?`This provider returned no servers.`:null:`Disabled — enable the provider to fetch its servers.`;return c(`div`,{className:`rounded-lg border border-border bg-surface p-2 sm:p-3`,children:a===null?c(`div`,{className:`flex flex-wrap gap-1`,children:i.map(e=>c(`span`,{className:`inline-block break-all rounded bg-foreground-subtle/10 px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e},e))}):c(`div`,{className:`text-xs text-foreground-subtle`,children:a})})}e();var Ze={lan:k,wifi:C,docker:A,vpn:O,loopback:x,other:x},Qe={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},$e=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function et(e){let{t}=L(),{interfaces:r,disabled:i,hideLoopback:o,ipv4Only:s,emptyMessage:l}=e,u=n(()=>r.filter(e=>!(o&&e.kind===`loopback`||s&&e.family!==`IPv4`)),[r,o,s]),d=n(()=>{let e=new Map;for(let t of u){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return $e.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[u]),f=t=>e.mode===`single`?e.value===t:e.value.includes(t),p=t=>{if(i||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let n=new Set(e.value);n.has(t.address)?n.delete(t.address):n.add(t.address),e.onChange([...n])};return u.length===0?c(`div`,{className:`text-xs text-foreground-subtle italic`,children:l??t(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):c(`div`,{className:`flex flex-col gap-3`,children:d.map(({kind:n,items:r})=>a(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[a(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[c(Ze[n]??x,{className:`h-3.5 w-3.5 text-foreground-subtle`}),c(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Qe[n]??n}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),c(`ul`,{className:`divide-y divide-border`,children:r.map(n=>{let r=f(n.address),o=n.kind===`loopback`,s=!n.plausible&&!o;return a(`li`,{className:`flex items-center gap-3 px-3 py-2 ${o?`opacity-60 cursor-not-allowed`:i?`opacity-60`:s?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>p(n),children:[c(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&c(h,{className:`h-3 w-3`})}),a(`div`,{className:`flex-1 min-w-0 ${s?`text-foreground-subtle`:``}`,children:[a(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[c(`span`,{className:`font-mono text-xs font-semibold ${s?`text-foreground-subtle`:`text-foreground`}`,children:n.name}),c(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:n.family}),n.preferred&&c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:t(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),o&&c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:t(`shared.addressSelector.alwaysIncluded`,`Always included`)}),s&&a(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[c(m,{className:`h-2.5 w-2.5`}),t(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),a(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[n.address,n.cidr&&n.cidr!==n.address?` (${n.cidr})`:``]})]})]},`${n.name}-${n.family}-${n.address}`)})})]},n))})}var J=[{role:`appConnections`,get title(){return I.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return I.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return I.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return I.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return I.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.internalHelp`)}}],tt=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function Y(e,t){return e.inUse.includes(t)}function nt(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return Y(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&Y(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:ne}:{kind:`set`,input:n}}function rt(e){return J.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}e();var it={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function at({book:e,loading:t,saving:n,error:i,onSetRole:o,onAdd:s,onRemove:l}){let{t:u}=L(),[d,p]=r(``),[h,g]=r(``),[_,v]=r(null),[y,b]=r(null),x=()=>{let e=ae(d);if(!e.ok){v(e.reason);return}v(null),p(``),g(``),s(e.baseUrl,h.trim())},S=(e,t)=>{let n=nt(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),o(n.input)}},ee=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:t=>a(`div`,{className:`min-w-0 py-0.5`,children:[c(`div`,{className:`font-mono text-[12px] break-all ${t.plausible?`text-foreground`:`text-foreground-subtle`}`,children:t.baseUrl}),a(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[c(`span`,{children:t.label}),t.kind===`app-link`&&a(`span`,{className:`font-mono`,children:[`hub=`,` `,e?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),t.custom&&t.detected&&c(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),t.kind!==`custom`&&t.interfaceKind!==`lan`&&t.interfaceKind!==`public`&&t.interfaceKind!==`other`&&c(`span`,{className:`uppercase tracking-wide`,children:t.interfaceKind}),!t.plausible&&t.interfaceKind!==`loopback`&&a(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[c(m,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=it[e.kind]??it.loopback;return c(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...J.map(e=>({key:e.role,headerRender:()=>c(`span`,{title:e.help,children:e.title}),align:`center`,nowrap:!0,width:`w-24`,render:t=>{let r=t.eligible.includes(e.role),i=t.flags.includes(e.role),o=Y(t,e.role);return a(`label`,{className:`inline-flex items-center justify-center gap-1 ${r?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:r?o&&!i?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:e.title,help:e.help}):e.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[c(Ce,{checked:r&&o,disabled:!r||n,onChange:()=>S(t,e),"aria-label":`${e.title}: ${t.baseUrl}`}),o&&!i&&r&&c(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?c(M,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:c(f,{className:`h-3 w-3`})}):null}],C=e===void 0?[]:rt(e);return a(Me,{children:[a(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[a(`div`,{children:[c(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),c(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),a(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[c(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),c(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:J.map(e=>a(`div`,{className:`contents`,children:[c(`dt`,{className:`font-medium`,children:e.title}),c(`dd`,{className:`text-foreground-subtle`,children:e.help})]},e.role))}),c(`p`,{className:`mt-1.5 text-foreground-subtle`,children:tt})]})]}),C.length>0&&c(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:C.map(e=>a(`div`,{className:`contents`,children:[c(`span`,{className:`text-foreground-subtle`,children:e.title}),a(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${e.role}`,children:[e.inUse,c(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:e.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),e.automatic?c(`span`,{}):c(M,{size:`sm`,variant:`secondary`,disabled:n,onClick:()=>o({role:e.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},e.role))}),y!==null&&a(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[c(m,{className:`h-3.5 w-3.5 text-amber-600`}),c(`span`,{className:`flex-1 min-w-[220px]`,children:y.reason}),c(M,{size:`sm`,variant:`secondary`,onClick:()=>{o({...y.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),c(M,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),i!==null&&c(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:i})]}),c(De,{columns:ee,rows:e?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:t?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),a(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[a(`div`,{className:`flex-1 min-w-[220px]`,children:[c(me,{value:d,onChange:e=>{p(e.target.value),v(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:n}),_!==null&&c(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:_})]}),c(`div`,{className:`w-48`,children:c(me,{value:h,onChange:e=>g(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:n})}),a(M,{size:`sm`,variant:`secondary`,disabled:n||d.trim()===``,onClick:x,children:[c(w,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}e();function ot(){let{t:e}=L(),i=s(),o=()=>{i.invalidateQueries({queryKey:[[`localNetwork`]]})},l=ve(void 0,{refetchInterval:3e4}),u=xe(void 0),f=ye({onSuccess:o}),p=ke({onSuccess:e=>{w(e.addresses),o()}}),m=n(()=>l.data?.interfaces??[],[l.data]),h=Ne({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),g=_e({onSuccess:o}),_=de({onSuccess:o}),v=ce({onSuccess:o}),x=g.error?.message??_.error?.message??v.error?.message??null,S=g.isPending||_.isPending||v.isPending,[C,w]=r([]),[T,E]=r(!1);t(()=>{!T&&u.data&&(w(u.data.addresses),E(!0))},[u.data,T]);let D=u.data?.addresses??[],O=n(()=>{if(C.length!==D.length)return!0;let e=[...C].toSorted(),t=[...D].toSorted();return e.some((e,n)=>e!==t[n])},[C,D]);return a(B,{embedded:!0,children:[a(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[c(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:e(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),c(`div`,{className:`flex items-center gap-2 shrink-0`,children:a(M,{size:`sm`,variant:`secondary`,onClick:()=>{l.refetch(),u.refetch(),h.refetch()},disabled:l.isLoading,children:[c(b,{className:`h-3 w-3 ${l.isLoading?`animate-spin`:``}`}),e(`common.refresh`,`Refresh`)]})})]}),c(je,{headingId:`network-allowed-addresses`,title:e(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:a(`div`,{className:`flex flex-wrap items-center gap-1`,children:[a(M,{size:`sm`,variant:`secondary`,onClick:()=>p.mutate(void 0),disabled:p.isPending||f.isPending,title:e(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[c(y,{className:`h-3 w-3`}),p.isPending?e(`system.networkAddresses.detecting`,`Detecting…`):e(`system.networkAddresses.bestMatch`,`Best match`)]}),a(M,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||f.isPending,children:[c(te,{className:`h-3 w-3`}),e(`system.networkAddresses.clear`,`Clear`)]}),O&&c(M,{size:`sm`,variant:`secondary`,onClick:()=>{w(D)},disabled:f.isPending,children:e(`system.networkAddresses.discard`,`Discard`)}),a(M,{size:`sm`,variant:`primary`,onClick:()=>{f.mutate({addresses:[...C]})},disabled:!O||f.isPending,children:[c(ee,{className:`h-3 w-3`}),f.isPending?e(`system.networkAddresses.saving`,`Saving…`):e(`common.save`,`Save`)]})]}),children:a(`div`,{className:d,children:[c(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?e(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):e(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),c(et,{mode:`multiple`,interfaces:m,value:C,onChange:w,disabled:f.isPending,emptyMessage:l.isLoading?e(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):e(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),c(at,{book:h.data,loading:h.isLoading,saving:S,error:x,onSetRole:e=>g.mutate({...e}),onAdd:(e,t)=>_.mutate({baseUrl:e,label:t}),onRemove:e=>v.mutate({baseUrl:e})})]})}e();var st={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},X=5e3,Z=`mesh-network`,ct=3e4,lt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function ut(){let{t:e}=L(),t=F({capName:`mesh-network`},{refetchInterval:X}),r=P(void 0,{refetchInterval:X}),i=n(()=>W(r.data??[]),[r.data]),a=n(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),o=[{id:Z,label:e(`system.meshNetworks.meshNetworks`,`Mesh networks`),install:{capability:Z,label:e(`system.meshNetworks.addMesh`,`Add mesh`)},entries:a.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:k,...U(t.isActive),render:()=>c(V,{addonId:t.addonId,displayName:t.displayName,capName:Z,isActive:t.isActive,badges:c(dt,{addonId:t.addonId}),primaryAction:c(ft,{addonId:t.addonId}),panels:[{id:`status`,title:e(`system.meshNetworks.status`,`Status`),icon:A,content:c(pt,{addonId:t.addonId})}]})}))}];return c(H,{embedded:!0,icon:A,title:e(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:e(`system.meshNetworks.privateVpnMeshesThatConnect`,`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`),groups:o,isLoading:t.isLoading,emptyTitle:e(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:e(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`)})}function Q(e){let{data:t,isLoading:n}=ge({addonId:e},{refetchInterval:X,retry:!1}),r=t?ie.safeParse(t):null;return{status:r?.success?r.data:lt,isLoading:n}}function dt({addonId:e}){let{t}=L(),{status:n}=Q(e);return a(o,{children:[c(N,{variant:n.joined?`success`:`default`,className:Ve,children:n.joined?t(`system.meshNetworks.joined`,`Joined`):t(`system.meshNetworks.notJoined`,`Not joined`)}),n.joined&&c(N,{className:`text-[10px]`,children:t(`common.peers`,{count:n.peerCount})})]})}function ft({addonId:e}){let{t}=L(),n=s(),[l,u]=r(!1),[d,f]=r(null),p=D(),{status:m}=Q(e),h=i(()=>{n.invalidateQueries({queryKey:[[`meshNetwork`]]})},[n]),g=we(),_=be({onSuccess:h}),v=le({onSuccess:h}),y=i(async()=>{u(!0);let t={cancelled:!1};f(t);try{let n=await g.mutateAsync({addonId:e});if(t.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!t.cancelled&&(await yt(2e3),!t.cancelled);){let t=await p.trpcClient.meshNetwork.getStatus.query({addonId:e}).catch(()=>null),n=t?ie.safeParse(t):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[e,h,g,p]),b=i(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return c(o,{children:m.joined?a(o,{children:[a(M,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:e}),children:[_.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(oe,{className:`h-3 w-3`}),t(`system.meshNetworks.disconnect`,`Disconnect`)]}),a(M,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:e}),children:[v.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(T,{className:`h-3 w-3`}),t(`system.meshNetworks.logOut`,`Log out`)]})]}):l?a(M,{size:`sm`,variant:`ghost`,onClick:b,children:[c(S,{className:`h-3 w-3 mr-1`}),` `,t(`common.cancel`)]}):a(o,{children:[a(M,{size:`sm`,variant:`primary`,onClick:()=>void y(),children:[c(se,{className:`h-3 w-3`}),t(`system.meshNetworks.connect`,`Connect`)]}),a(M,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:e}),children:[v.isPending?c(E,{className:`h-3 w-3 animate-spin`}):c(T,{className:`h-3 w-3`}),t(`system.meshNetworks.logOut`,`Log out`)]})]})})}function pt({addonId:e}){let{t}=L(),{status:n}=Q(e),r=Pe({addonId:e},{refetchInterval:ct,retry:!1});return a(`div`,{className:`rounded-lg border border-border bg-surface`,children:[a(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[n.error&&c(ue,{message:n.error}),c(mt,{status:n}),n.endpoints.length>0&&a(`div`,{className:`space-y-1.5`,children:[c(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:t(`system.meshNetworks.endpoints`,`Endpoints`)}),n.endpoints.map(e=>a(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[a(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${st[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?c(j,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),a(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[c(u,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),c(`div`,{className:`border-t border-border`,children:c(gt,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function mt({status:e}){let{t}=L();return c(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:t(`system.meshNetworks.tenant`,`Tenant`),value:e.tenantName||`—`},{label:t(`system.meshNetworks.user`,`User`),value:e.userLogin??`—`},{label:t(`system.meshNetworks.controlPlane`,`Control plane`),value:e.controlPlaneUrl||`—`},{label:t(`system.meshNetworks.meshIp`,`Mesh IP`),value:e.meshIp||`—`,mono:!0},{label:t(`system.meshNetworks.magicdns`,`MagicDNS`),value:e.magicDnsHostname||`—`,mono:!0},{label:t(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:e.magicDnsSuffix||`—`,mono:!0},{label:t(`system.meshNetworks.peers`,`Peers`),value:String(e.peerCount)},{label:t(`system.meshNetworks.keyExpiry`,`Key expiry`),value:e.keyExpiry?ht(e.keyExpiry):`—`}].map(e=>a(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[c(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),c(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function ht(e){let t=e-Date.now();if(t<0)return I.t(`system.meshNetworks.expiredAgo`,{when:$(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return I.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?I.t(`system.meshNetworks.expiryHours`,{count:r}):I.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function gt({peers:e,loading:t}){let{t:r}=L(),o=n(()=>e.map(e=>({...e,_id:e.id})),[e]),s=i(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=n(()=>[{key:`hostname`,header:r(`system.meshNetworks.hostname`,`Hostname`),render:e=>a(`div`,{className:`flex flex-col`,children:[a(`div`,{className:`flex items-center gap-1.5`,children:[c(`span`,{className:`font-medium text-foreground`,children:e.hostname||r(`system.meshNetworks.unknown`,`(unknown)`)}),e.isSelf&&c(N,{variant:`info`,children:r(`common.self`)}),e.exitNodeOption&&c(N,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&c(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:r(`system.meshNetworks.magicdns`,`MagicDNS`),render:e=>e.magicDns?a(`div`,{className:`flex items-center gap-1`,children:[c(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),c(`button`,{onClick:()=>s(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":r(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:c(v,{className:`h-3 w-3 text-foreground-subtle`})})]}):c(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?a(`div`,{className:`flex items-center gap-1`,children:[c(`span`,{className:`font-mono text-xs`,children:t}),c(`button`,{onClick:()=>s(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":r(`system.meshNetworks.copyIp`,`Copy IP`),children:c(v,{className:`h-3 w-3 text-foreground-subtle`})})]}):c(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:r(`system.meshNetworks.connection`,`Connection`),render:e=>a(`div`,{className:`flex items-center gap-1.5`,children:[c(N,{variant:_t(e.connection),children:e.connection}),e.relay&&c(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:r(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?c(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):c(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:r(`system.meshNetworks.txRx`,`TX / RX`),render:e=>a(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,vt(e.txBytes),` · ↓ `,vt(e.rxBytes)]})},{key:`lastSeen`,header:r(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>c(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?$(e.lastSeenMs):`—`})}],[s,r]);return t&&e.length===0?a(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[c(E,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,r(`systemPage.meshNetworks.loadingPeers`)]}):e.length===0?c(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:r(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):c(`div`,{className:`p-4`,children:c(De,{columns:l,rows:o,rowKey:e=>e._id,minWidthPx:820})})}function _t(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function vt(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function $(e){let t=Date.now()-e;return t<6e4?I.t(`system.meshNetworks.justNow`):t<36e5?I.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?I.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):I.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}function yt(e){return new Promise(t=>setTimeout(t,e))}var bt=`/system/identity?tab=certificates`;function xt(){let{t:e}=L();return c(B,{embedded:!0,children:a(`div`,{className:p,children:[c(Be,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:e(`system.localAccess.lanHttp`,`LAN HTTP`),description:e(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),a(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[e(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,c(Fe,{className:`underline`,to:bt,children:e(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}e();function St({value:e,onChange:t}){let{t:r}=L(),{data:i}=Ae({isCamera:!0,projection:`slim`}),o=n(()=>i===void 0?[{value:``,label:r(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:i.length===0?[{value:``,label:r(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:r(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...i.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[i,r]);return a(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[c(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`system.networkDiagnostics.camera`,`Camera`)}),c(Se,{value:e===null?``:String(e),disabled:i===void 0||i.length===0,onChange:e=>t(e.target.value===``?null:Number(e.target.value)),options:o})]})}function Ct(){let e=D(),[t,n]=r(null);return c(B,{embedded:!0,children:a(`div`,{className:p,"data-testid":`network-diagnostics`,children:[c(Ee,{loadServers:i(async()=>e.trpcClient.turnProvider.getTurnServers.query(),[e])}),c(Oe,{trpc:e.trpcClient,serverUrl:_(),deviceId:t,cameraField:c(St,{value:t,onChange:n})})]})})}var wt=[`certificate`,`certificates`,`https`];function Tt(){let{t:e}=L(),[t]=Le();if(wt.includes(t.get(`tab`)??``))return c(Ie,{to:bt,replace:!0});let n=Re(`/system/network`,{t:e,isAdmin:!0})??{icon:j,title:e(`system.network`,`Network`)};return c(ze,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:c(xt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:c(ot,{})},{id:R.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:c(Ue,{}),ownedParams:z},{id:R.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:c(ut,{}),ownedParams:z},{id:R.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:c(Ye,{}),ownedParams:z},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:c(Ct,{})}]})}export{Tt as NetworkPage};