@camstack/addon-admin-ui 1.2.509 → 1.2.510

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 (118) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/assets/{AddonAssetIcon-BI2lRuoS.js → AddonAssetIcon-C9hAoKXu.js} +1 -1
  3. package/dist/assets/{Addons-aixytO1O.js → Addons-RWj1BxGY.js} +1 -1
  4. package/dist/assets/{AdminPage-CoK_jJGS.js → AdminPage-DlYf-2bp.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-DhFW0QuY.js → AdminSectionedPage-BZCKp3Ch.js} +1 -1
  6. package/dist/assets/{AiProfiles-Hta21yBZ.js → AiProfiles-JSlQDV72.js} +1 -1
  7. package/dist/assets/{BrokerEditorDialog-gOoxFZhc.js → BrokerEditorDialog-Bd04efEw.js} +1 -1
  8. package/dist/assets/{Build-DeHUkf81.js → Build-BZi_niS-.js} +1 -1
  9. package/dist/assets/{Calendars-Bc2nNcs2.js → Calendars-DP9Bg77f.js} +1 -1
  10. package/dist/assets/{Cluster-VtNbtY9D.js → Cluster-Dd_vu_bM.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-ClF4WE8b.js → CompositionBlockEditor-CH-GMXbq.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-BbTxuNsy.js → CompositionEditorPage-Csnltw_A.js} +1 -1
  13. package/dist/assets/{Data-jsug18s-.js → Data-uCQZVzY1.js} +1 -1
  14. package/dist/assets/{DeviceDetail-joS1oAlZ.js → DeviceDetail-BxIy7-Dm.js} +1 -1
  15. package/dist/assets/{DeviceDoActionFields-HDaDny9u.js → DeviceDoActionFields-CK01sDyF.js} +1 -1
  16. package/dist/assets/{Devices-auu9DUkM.js → Devices-CVsltbg0.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-CIhSpElZ.js → EmbedPlayerPage-C5TPel_z.js} +1 -1
  18. package/dist/assets/{HelperWizard-BgJngxXm.js → HelperWizard-BPhC2XoW.js} +1 -1
  19. package/dist/assets/{History-6YEHunH9.js → History-B20ge-W7.js} +1 -1
  20. package/dist/assets/{Identity-Dv-KAkrQ.js → Identity-DPilvdr-.js} +1 -1
  21. package/dist/assets/{IntegrationDetail-9gEegPuj.js → IntegrationDetail-QFz0_FYR.js} +1 -1
  22. package/dist/assets/{IntegrationHub-CMzk8_M7.js → IntegrationHub-B1kSbU1F.js} +1 -1
  23. package/dist/assets/{Integrations-BmMpmuUr.js → Integrations-DL3TkBVs.js} +1 -1
  24. package/dist/assets/{Integrations-4H8b5m-o.js → Integrations-DZSqPZJX.js} +1 -1
  25. package/dist/assets/{Library-DCJLo-8C.js → Library-lJCalEoT.js} +1 -1
  26. package/dist/assets/{Locations-DcE-odlA.js → Locations-B0jWaHF6.js} +1 -1
  27. package/dist/assets/{Logs-CPkwmk1L.js → Logs-DQLPAUyF.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-Bc_okYTu.js → MaskShapeCanvas-CFljj6Sk.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-C-3oW42G.js → MotionZonesSettings-B8TBt4dC.js} +1 -1
  30. package/dist/assets/{MyAccess-aKBp7TFc.js → MyAccess-CZG0q7Mt.js} +1 -1
  31. package/dist/assets/{Network-BZRPnSCn.js → Network-BBrgIFOt.js} +1 -1
  32. package/dist/assets/{NodeAddonsSettingsPanel-D2vtVm6t.js → NodeAddonsSettingsPanel-CeHG4O24.js} +1 -1
  33. package/dist/assets/{Notifications-DRe4l7tP.js → Notifications-3RTWnoyO.js} +1 -1
  34. package/dist/assets/{Pipeline-CciPr0pg.js → Pipeline-CGdO9F0O.js} +1 -1
  35. package/dist/assets/{PrivacyMaskSettings-BOI5MbOP.js → PrivacyMaskSettings-BJlCR0a3.js} +1 -1
  36. package/dist/assets/{Recordings-BzsdLv6y.js → Recordings-CURYqqF0.js} +1 -1
  37. package/dist/assets/{ScanNetworkModal-DvfjnJfb.js → ScanNetworkModal-ojXdkkOk.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-BP10OuX_.js → SceneMonitorEditor-CNgXiExG.js} +1 -1
  39. package/dist/assets/{SessionsList-CPeF55_J.js → SessionsList-Bd4yBLfB.js} +1 -1
  40. package/dist/assets/{Showroom-otBl581k.js → Showroom-Df0D9oOc.js} +1 -1
  41. package/dist/assets/{System-CSJNNYl2.js → System-DQkvS75J.js} +1 -1
  42. package/dist/assets/{Terminal-CjxtMAdp.js → Terminal-BhUVowlr.js} +1 -1
  43. package/dist/assets/{Viewer-CDe6m77J.js → Viewer-B4P4Bkxo.js} +1 -1
  44. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DmDesblz.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cze0rRAV.js} +1 -1
  45. package/dist/assets/{addon-icons-context-C1MOrZ0k.js → addon-icons-context-fZFRR8Jh.js} +1 -1
  46. package/dist/assets/{archive-DfRpKbmd.js → archive-B0Gb92Md.js} +1 -1
  47. package/dist/assets/{assignment-candidates-CZXvnTmb.js → assignment-candidates-CLAnrBak.js} +1 -1
  48. package/dist/assets/{authed-media-acRzkBVq.js → authed-media-BZXVXyjI.js} +1 -1
  49. package/dist/assets/{bell-off-BDtTHYf7.js → bell-off-BFI_PtFI.js} +1 -1
  50. package/dist/assets/{board-model-DmsaBGD6.js → board-model-Cb9TF016.js} +1 -1
  51. package/dist/assets/{boxes-Dg0SsuKi.js → boxes-C9rq6GsW.js} +1 -1
  52. package/dist/assets/circle-slash-CrgSHCu9.js +1 -0
  53. package/dist/assets/client-CwJGlpR9.js +674 -0
  54. package/dist/assets/{cloud-upload-D5gzNxtI.js → cloud-upload-kAMSz6c0.js} +1 -1
  55. package/dist/assets/crop-DKZuvuZ0.js +1 -0
  56. package/dist/assets/{device-integration-icon-DYxz_sNP.js → device-integration-icon-a0pkysxV.js} +1 -1
  57. package/dist/assets/device-picker-model-BTGIE40h.js +1 -0
  58. package/dist/assets/{dist-DU6BvfF_.js → dist-CG2a7mCH.js} +1 -1
  59. package/dist/assets/dist-D4krkzk0.js +674 -0
  60. package/dist/assets/{eraser-DatAKBqr.js → eraser-De_DOv3l.js} +1 -1
  61. package/dist/assets/{format-BXqfrshG.js → format-7HUlrbym.js} +1 -1
  62. package/dist/assets/{hard-drive-download-BMn4pcLF.js → hard-drive-download-DKm5p-Le.js} +1 -1
  63. package/dist/assets/{hostInit-SgUIaQcR.js → hostInit-Ct3ew837.js} +1 -1
  64. package/dist/assets/i18n-9jE1YKjd.js +1 -0
  65. package/dist/assets/{icons-CfQXaR2o.js → icons-3VtN4bSW.js} +1 -1
  66. package/dist/assets/{index-B6a27fav.js → index-DG07MiZm.js} +3 -3
  67. package/dist/assets/{key-0qodB2RW.js → key-VHIrojXx.js} +1 -1
  68. package/dist/assets/{key-round-EDiKxWDb.js → key-round-Bfq08tmQ.js} +1 -1
  69. package/dist/assets/{layers-BuqS0QUs.js → layers-C2a0eh6-.js} +1 -1
  70. package/dist/assets/{linked-devices-model-fUmE1zN_.js → linked-devices-model-D3jOXb7G.js} +1 -1
  71. package/dist/assets/{list-ordered-5xX0c-4M.js → list-ordered-Da2mHuCu.js} +1 -1
  72. package/dist/assets/{location-owned-usage-C90h2IYf.js → location-owned-usage-DqvEUneY.js} +1 -1
  73. package/dist/assets/{log-in-DfGAqbts.js → log-in-eLGFJBOn.js} +1 -1
  74. package/dist/assets/{memory-stick-Cw-HmXQN.js → memory-stick-DnKI7rwN.js} +1 -1
  75. package/dist/assets/{message-square-plus-Cimd4hIM.js → message-square-plus-C6KwcZuQ.js} +1 -1
  76. package/dist/assets/{mf-entry-bootstrap-0-6f836b4a.js → mf-entry-bootstrap-0-98f2c3e4.js} +2 -2
  77. package/dist/assets/{mic-off-BaeJlMpU.js → mic-off-D983qPJH.js} +1 -1
  78. package/dist/assets/{monitor-off-B5ZegpCN.js → monitor-off-BxsFOOUC.js} +1 -1
  79. package/dist/assets/{monitor-smartphone-GrRvroYr.js → monitor-smartphone-CVLLvvgV.js} +1 -1
  80. package/dist/assets/mount-BTGIE40h.js +1 -0
  81. package/dist/assets/{player-overlays-CzZYPO2s.js → player-overlays-g9d3qYrr.js} +1 -1
  82. package/dist/assets/{recycle-C0Za7XIk.js → recycle-DO_1Mgmd.js} +1 -1
  83. package/dist/assets/remoteEntry-CpKU5IE2.js +1 -0
  84. package/dist/assets/{scan-eye-DBcVKkv9.js → scan-eye-CyJ3ozW9.js} +1 -1
  85. package/dist/assets/{scissors-ClBtIo8F.js → scissors-BNMtq6Ob.js} +1 -1
  86. package/dist/assets/{search-x-vzCWLMzU.js → search-x-DDY8MfL6.js} +1 -1
  87. package/dist/assets/{send-C2xLiGxd.js → send-Ch2Il08w.js} +1 -1
  88. package/dist/assets/{settings-2-CE18osa2.js → settings-2-DuqbBWmE.js} +1 -1
  89. package/dist/assets/{sigma-BzZ_sr1s.js → sigma-C3PEOK_Y.js} +1 -1
  90. package/dist/assets/{speaker-DPhQgEkP.js → speaker-DkdRIL1K.js} +1 -1
  91. package/dist/assets/{src-DytYtgEw.js → src-DwNoxp86.js} +3 -3
  92. package/dist/assets/{step-inspector-model-BpPknRH5.js → step-inspector-model-DQUr_7uJ.js} +1 -1
  93. package/dist/assets/{table-2-Ca1maW_p.js → table-2-DoxvwhSo.js} +1 -1
  94. package/dist/assets/{timer-reset-DLwEAlTU.js → timer-reset-DVNN3Abc.js} +1 -1
  95. package/dist/assets/{unlink-Bdb8-xwF.js → unlink-C-2ouMww.js} +1 -1
  96. package/dist/assets/{usb-DxqbvFPc.js → usb-PSQjoR7w.js} +1 -1
  97. package/dist/assets/{use-scenes-feed-YVkY4_qr.js → use-scenes-feed-B_j7CFbm.js} +1 -1
  98. package/dist/assets/{use-stationary-objects-FD4-OqJN.js → use-stationary-objects-Drf9XXJR.js} +1 -1
  99. package/dist/assets/useEventInvalidation-BTGIE40h.js +1 -0
  100. package/dist/assets/{useNodeUrlSelection-Kb4BvUIw.js → useNodeUrlSelection-Cg0TPdbH.js} +1 -1
  101. package/dist/assets/user-round-Z0QH_kjR.js +1 -0
  102. package/dist/assets/{user-x-BQ6msuOU.js → user-x-BRStn-V-.js} +1 -1
  103. package/dist/assets/{variable-mkIJuabT.js → variable-vFOxYqY7.js} +1 -1
  104. package/dist/assets/{video-O02NyJP7.js → video-BFmrpvc7.js} +1 -1
  105. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CVBjsL5d.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-JzLE6zuc.js} +2 -2
  106. package/dist/index.html +9 -9
  107. package/dist/server/addon.js +13 -1
  108. package/package.json +1 -1
  109. package/dist/assets/circle-slash-vr6zT4n3.js +0 -1
  110. package/dist/assets/client-BRyxs6lT.js +0 -674
  111. package/dist/assets/crop-CGtgnf44.js +0 -1
  112. package/dist/assets/device-picker-model-D0GfTZgv.js +0 -1
  113. package/dist/assets/dist-CPWJTJFO.js +0 -674
  114. package/dist/assets/i18n-CNMsurg3.js +0 -1
  115. package/dist/assets/mount-D0GfTZgv.js +0 -1
  116. package/dist/assets/remoteEntry-BNJLevTL.js +0 -1
  117. package/dist/assets/useEventInvalidation-D0GfTZgv.js +0 -1
  118. package/dist/assets/user-round-D5DJkFym.js +0 -1
@@ -1,3 +1,3 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et 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-CEyXHAdg.js";import{Bi as c,Br as l,Di as u,En as d,Fn as f,Gt as p,Ht as m,Jr as h,Jt as g,Ni as _,O as v,Ri as y,Sr as b,Ti as x,Ur as S,V as C,Vn as w,Wi as T,Wt as E,Yr as D,Zi as O,aa as k,gr as A,gt as ee,hr as j,ht as M,k as N,ln as P,lr as F,mn as I,oa as L,oi as te,on as R,sa as ne,sr as re,st as ie,vi as ae,vt as z,yn as B,z as oe}from"./player-overlays-CzZYPO2s.js";import{$r as se,ti as ce,yn as le}from"./client-BRyxs6lT.js";import{t as ue}from"./boxes-Dg0SsuKi.js";import{n as de,r as fe,t as pe}from"./speaker-DPhQgEkP.js";import{t as V}from"./user-round-D5DJkFym.js";import{$a as me,Ao as he,Bo as ge,Do as _e,Fr as H,Go as ve,Ko as ye,Lr as U,No as be,Nr as W,Pr as xe,Qa as Se,Qo as Ce,Qr as we,R as Te,Ro as Ee,Sn as G,Un as De,Vo as Oe,Vr as ke,Wn as Ae,Wo as je,Yr as K,_d as Me,_r as Ne,dd as Pe,dr as Fe,eo as Ie,fn as Le,fr as Re,gd as q,gr as ze,hr as Be,jo as Ve,ko as He,pn as Ue,pr as We,qo as Ge,ri as Ke,ro as qe,vd as Je,yt as Ye,zo as Xe}from"./src-DytYtgEw.js";import{t as J}from"./i18n-CNMsurg3.js";import{t as Y}from"./useTranslation-BJr-n0es.js";import{_r as Ze,m as Qe,mr as X,yr as $e}from"./index-B6a27fav.js";import{t as et}from"./AdminSectionedPage-DhFW0QuY.js";import{a as tt,n as nt,r as rt}from"./linked-devices-model-fUmE1zN_.js";a();function Z(e){return{id:e.id,name:e.name,type:e.type,stableId:e.stableId??``,parentDeviceId:e.parentDeviceId,location:e.location,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.primaryChildEntityId!==void 0&&e.primaryChildEntityId!==null?{primaryChildEntityId:e.primaryChildEntityId}:{}}}function Q(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function it(e,t){let n=Q(t);return n===null?[]:e.filter(e=>Q(e.location)===n)}function at(e,t){let n=it(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function ot(e,t){let n=Q(e.location);return n===null||new Set(t.map(e=>Q(e))).has(n)?null:e.location?.trim()??null}function st(e,t){let n=Q(e.location);return n!==null&&t.has(n)}function ct(e,t){let n=new Set(t.map(e=>Q(e))),r=new Set(e.filter(e=>st(e,n)).map(e=>e.id));return e.filter(e=>!(st(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function lt(e,t){return ct(e,t).filter(e=>e.parentDeviceId===null)}function ut(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 dt(e,t){return ut(e,t).length}function ft(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function pt(e,t){return t.map(t=>({name:t,members:at(e,t)}))}var mt={camera:_,hub:de,container:ue,light:A,siren:P,switch:p,sensor:ne,thermostat:g,climate:L,button:ae,"event-emitter":M,update:fe,notifier:T,script:B,automation:z,lock:F,cover:c,valve:D,humidifier:h,"water-heater":l,fan:S,"media-player":pe,"alarm-panel":I,control:R,presence:V,weather:te,vacuum:y,"lawn-mower":E,image:b,smoke:k};function $({type:e,className:t}){return n(mt[e]??ae,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function ht({device:e}){let t=H(Z(e),`compact`);return n(gt,{online:e.online,deviceName:t})}function gt({online:e,deviceName:t}){return n(`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":J.t(`locations.deviceGlyphs.aria`,{name:t,state:e?J.t(`common.online`):J.t(`common.offline`)}),title:e?J.t(`common.online`):J.t(`common.offline`)})}function _t({open:t,title:a,items:o,listState:s,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=Y(),[h,g]=i([]);r(()=>{t||g([])},[t]);let _=new Map(o.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 n(Fe,{open:t,onOpenChange:e=>e?void 0:p(),children:e(We,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":a,children:[n(ze,{children:n(Ne,{children:a})}),e(Re,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[t&&u!==null&&v.length>0&&e(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[n(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),n(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>n(`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))})]}),t&&n(Te,{devices:o,listState:s,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),e(Be,{children:[n(K,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),n(K,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}a();function vt({room:e,cameras:r,fleet:i}){let{t:a}=Y(),o=t(()=>new Map(i.map(e=>[e.id,e])),[i]);return e===null?n(`p`,{className:`text-xs text-foreground-subtle`,children:a(`locations.links.noRoom`)}):n(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:r.length===0?n(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:a(`locations.links.noCameras`,{room:e})}):r.map(e=>n(bt,{camera:e,byId:o},e.id))})}function yt(e){return{id:e.deviceId,name:e.name,type:e.type,location:e.location}}function bt({camera:t,byId:r}){let{t:a}=Y(),s=H(Z(t),`full`),c=o(),l=Ze(),[u,d]=i(!1),[f,p]=i(null),m=me({deviceId:t.id}),h=rt({status:m.status,data:m.data,error:m.error===null||m.error===void 0?null:m.error}),g=Ie(),_=h.kind===`present`?h:null,y=Se({deviceId:t.id,slotRef:_?.slot.slotRef??``},{enabled:u&&_!==null}),b=_===null?[]:nt(_.slot,_.value),x=b.map(e=>e.deviceId),S=(y.data?.candidates??[]).map(yt),C=new Set(S.map(e=>e.id)),w=x.filter(e=>!C.has(e)).map(e=>{let t=r.get(e);return{id:e,name:t?.name??`#${String(e)}`,...t===void 0?{}:{type:t.type,location:t.location}}}),T=[...S,...w],E=(y.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),D=async e=>{if(_!==null){p(null);try{await g.mutateAsync({deviceId:t.id,slotRef:_.slot.slotRef,value:tt(_.value,e)}),await m.refetch(),await c.invalidateQueries({queryKey:[[`deviceManager`]]}),d(!1)}catch(e){p(e instanceof Error?e.message:String(e))}}},O=[{key:`device`,header:a(`locations.columns.device`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId),o=t.name??i?.name??`#${String(t.deviceId)}`;return e(`span`,{className:`flex items-center gap-1.5`,children:[i!==void 0&&n($,{type:i.type}),n(X,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:i===void 0?o:n(W,{device:Z(i),form:`compact`})}),t.implied&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`locations.links.implied`)})]})}},{key:`type`,header:a(`locations.columns.type`),notSortableReason:a(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:r.get(e.deviceId)?.type??`—`})},{key:`status`,header:a(`locations.columns.status`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId);return i===void 0?n(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:i}),n(`span`,{className:`text-xs text-foreground-muted`,children:i.online?a(`common.online`):a(`common.offline`)})]})}}];return e(`section`,{className:`min-w-0 ${v}`,"data-testid":`camera-links-${String(t.id)}`,children:[e(`header`,{className:`${N} flex min-h-9 items-center gap-1.5`,children:[n($,{type:t.type}),n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:n(W,{device:Z(t),form:`full`})}),e(K,{variant:`ghost`,size:`sm`,onClick:()=>l(Qe(t.id)),children:[n(j,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`locations.links.edit`)]}),n(K,{variant:`outline`,size:`sm`,disabled:_===null,onClick:()=>d(!0),"aria-label":a(`locations.links.addNamed`,{camera:s}),children:a(`locations.room.add`)})]}),h.kind===`pending`&&n(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.loading`)}),h.kind===`unknown`&&n(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:a(`locations.links.unreadable`,{reason:h.reason})}),h.kind===`absent`&&n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.unsupported`)}),f!==null&&n(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:f}),_!==null&&(b.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.none`)}):n(G,{columns:O,rows:b,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),n(_t,{open:u,title:a(`locations.links.pickTitle`,{camera:s}),items:T,listState:y.status===`error`?`failed`:y.data===void 0?`pending`:`answered`,lockedIds:x,lockedNote:a(`locations.links.alreadyLinked`),suggestions:t.location===null?null:{heading:a(`locations.links.suggested`,{room:t.location}),ids:E},busy:g.isPending,onConfirm:e=>void D(e),onClose:()=>d(!1)})]})}a();function xt({name:t,description:a,busy:o,onSave:s}){let{t:c}=Y(),[l,u]=i(a??``);return r(()=>{u(a??``)},[a]),e(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[n(Ae,{htmlFor:`location-description-${t}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),n(`textarea`,{id:`location-description-${t}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(a??``)&&s(e.length===0?null:e)},disabled:o,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`}),n(`p`,{className:`mt-1 ${oe}`,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 St(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var Ct=` none`;function wt({name:t,zones:r,zoneKey:i,busy:a,onChange:o}){let{t:s}=Y();if(r.length===0)return null;let c=[{value:Ct,label:s(`locations.locationZoneField.none`,`— none —`)},...r.map(e=>({value:e.zoneKey,label:e.label}))];return e(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[n(Ae,{htmlFor:`location-zone-${t}`,children:s(`locations.locationZoneField.zone`,`Zone`)}),n(Pe,{id:`location-zone-${t}`,value:i??Ct,disabled:a,onChange:e=>{let t=e.target.value;if(t===Ct){o(null);return}let n=r.find(e=>e.zoneKey===t);n!==void 0&&o(n.label)},options:c})]})}function Tt(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function Et({name:e,icon:t,busy:r,onPick:i}){return n(Je,{value:t,onPick:i,fallbackGlyph:re,clearGlyph:O,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:r})}function Dt(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:ce(n.icon)??`map-pin`}function Ot(e){return`${e.kind}:${String(e.device.id)}`}function kt(e,t,n){return e.flatMap(e=>{let r=ft(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}))]})}a();function At({name:r,members:a,devices:o,busy:c,icon:l,description:u,onRename:f,onDelete:p,onRebuildLinks:h,onAddDevices:g,onPickIcon:_,onSaveDescription:y,zones:b,zoneKey:x,onChangeZone:S}){let{t:C}=Y(),[T,E]=i(!1),[D,O]=i(r),k=Le(a,t(()=>({searchText:e=>[e.name,...ft(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[A,j]=i(()=>new Set),M=e=>j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),P=t(()=>kt(k.rows,o,A),[k.rows,o,A]),F=[{key:`name`,header:C(`locations.columns.device`),notSortableReason:C(`locations.columns.noSort`),render:e=>e.kind===`member`?n(jt,{row:e,onToggle:()=>M(e.device.id)}):n(Mt,{row:e})},{key:`type`,header:C(`locations.columns.type`),notSortableReason:C(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:C(`locations.columns.status`),notSortableReason:C(`locations.columns.noSort`),render:t=>e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:t.device}),n(`span`,{className:`text-xs text-foreground-muted`,children:t.device.online?C(`common.online`):C(`common.offline`)})]})}],I=()=>{O(r),E(!1)},L=async()=>{let e=D.trim();if(e.length===0||e===r){I();return}await f(e),E(!1)},te=[{id:`rename`,label:C(`locations.locationCard.rename`,`Rename`),icon:w,disabled:c,onClick:()=>{O(r),E(!0)}},{id:`rebuild-links`,label:C(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:d,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 e(`section`,{className:`min-w-0 ${v}`,children:[e(`header`,{className:`${N} flex min-h-9 items-center gap-1.5`,children:[n(Et,{name:r,icon:l,busy:c,onPick:_}),T?e(s,{children:[n(q,{value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&L(),e.key===`Escape`&&I()},"aria-label":C(`locations.locationCard.rename2`,`Rename {{name}}`,{name:r}),className:`min-w-0 flex-1`,autoFocus:!0}),n(K,{type:`button`,size:`sm`,onClick:()=>void L(),children:C(`common.save`,`Save`)}),n(Me,{type:`button`,variant:`ghost`,icon:ee,onClick:I,"aria-label":C(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):e(s,{children:[n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:r}),n(K,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:g,"aria-label":C(`locations.room.addTo`,{room:r}),children:C(`locations.room.add`)}),n(Ye,{items:te,title:C(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:r}),triggerClassName:`p-1`})]})]}),n(wt,{name:r,zones:b,zoneKey:x,busy:c,onChange:S}),n(xt,{name:r,description:u,busy:c,onSave:y}),a.length>0&&n(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:n(Ue,{state:k.state,facets:k.facets,labels:{searchPlaceholder:C(`locations.filter.searchPlaceholder`),searchLabel:C(`locations.room.searchLabel`,{room:r}),facetsLabel:C(`locations.filter.typesLabel`),clearLabel:C(`locations.filter.clear`)},onSearch:k.setSearch,onToggleFacet:k.toggleFacet,onClear:k.clear})}),a.length===0?n(`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.`)}):n(G,{columns:F,rows:P,rowKey:Ot,bordered:!1,minWidthPx:360,emptyMessage:C(`locations.filter.noMatch`)})]})}function jt({row:t,onToggle:r}){let{t:i}=Y(),{device:a,accessories:o,open:s}=t,c=H(Z(a),`compact`),l=s?u:x;return e(`span`,{className:`flex items-center gap-1.5`,children:[o.length>0?e(K,{type:`button`,variant:`ghost`,onClick:r,"aria-expanded":s,"aria-label":i(s?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:o.length,name:c}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[n(l,{className:`h-3 w-3`}),n(`span`,{className:`text-[10px] tabular-nums`,children:o.length})]}):n(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),n($,{type:a.type}),n(X,{to:`/devices/${String(a.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:n(W,{device:Z(a),form:`compact`})})]})}function Mt({row:t}){let{device:r,parent:i}=t;return e(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[n(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),n($,{type:r.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),n(X,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:n(W,{device:Z(r),form:`nested`,parent:Z(i)})})]})}a();function Nt({zones:e,busy:t,onRename:r,onDelete:a,onPickIcon:o}){let{t:s}=Y(),[c,l]=i(null),[u,d]=i(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await r(e,t)};return n(G,{columns:[{key:`icon`,header:s(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>n(Et,{name:e.label,icon:e.icon,busy:t,onPick:t=>o(e.label,t)})},{key:`name`,header:s(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?n(q,{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":s(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):n(K,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:s(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:s(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>n(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?s(`common.empty`):s(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:s(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>n(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void a(e.label),disabled:t,"aria-label":s(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:s(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:n(m,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:s(`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.`)})}a();function Pt({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(q,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newLocationButton.frontDoorHallKitchen`,`Front door, Hall, Kitchen…`),"aria-label":a(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(f,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:n(ee,{className:`h-3.5 w-3.5`})})]}):e(K,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-location-button`,children:[n(f,{className:`h-3.5 w-3.5`}),a(`locations.newLocationButton.newLocation`,`New location`)]})}a();function Ft({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(q,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Night zone…`),"aria-label":a(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(f,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:n(ee,{className:`h-3.5 w-3.5`})})]}):e(K,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-zone-button`,children:[n(f,{className:`h-3.5 w-3.5`}),a(`locations.newZoneButton.newZone`,`New zone`)]})}a();function It(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 Lt({rooms:e,unassignedCount:r,value:i,unassignedValue:a,onChange:o}){let{t:s}=Y(),c=t(()=>It(e,r,a,s(`locations.roomPicker.unassigned`)),[e,r,a,s]);return n(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:n(we,{mode:`single`,singleDisplay:`field`,label:s(`locations.roomPicker.label`),placeholder:s(`locations.roomPicker.placeholder`),options:c,value:i,onChange:o,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}a();var Rt={searchText:e=>[e.name],facetValue:e=>e.type};function zt({rows:r,fleet:a,locations:o,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=Y(),d=ke(),f=U(),p=e=>d===null?e.name:xe(Z(e),`compact`,d,f),[m,h]=i([]),[g,_]=i(``),v=Le(r,Rt),y=v.rows,b=t(()=>y.map(e=>e.id),[y]),x=t(()=>m.filter(e=>b.includes(e)),[m,b]),S=y.length>0&&x.length===y.length,w=t(()=>{let e=new Map;for(let t of r)e.set(t.id,dt(a,t.id));return e},[r,a]),T=x.reduce((e,t)=>e+(w.get(t)??0),0),E=e=>h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),D=()=>h(S?[]:b),O=()=>{g.length===0||x.length===0||(l(x,g),h([]),_(``))},k=o.map(e=>({value:e,label:e})),A=[{key:`select`,width:`w-8`,headerRender:()=>n(De,{checked:S,onChange:D,"aria-label":S?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>n(De,{checked:x.includes(e.id),onChange:()=>E(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:p(e)})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:t=>{let r=ot(t,o);return e(`span`,{className:`flex items-center gap-1.5`,children:[n($,{type:t.type}),n(X,{to:`/devices/${String(t.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:n(W,{device:Z(t),form:`compact`})}),r!==null&&n(Ke,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:r})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:t=>e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:t}),n(`span`,{className:`text-xs text-foreground-muted`,children:t.online?u(`common.online`):u(`common.offline`)})]})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>w.get(e.id)??0,render:e=>n(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:w.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=>n(Pe,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:p(e)}),value:``,disabled:s||o.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...k]})}];return e(`section`,{className:`space-y-2`,children:[e(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[n(`h2`,{className:C,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),n(`p`,{className:oe,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),r.length>0&&n(Ue,{state:v.state,facets:v.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onClear:v.clear}),x.length>0&&e(`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:[e(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:x.length}),T>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:T})}`]}),n(Pe,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:g,onChange:e=>_(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...k]}),n(K,{type:`button`,size:`sm`,onClick:O,disabled:s||g.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),n(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>h([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),n(G,{columns:A,rows:y,rowKey:e=>e.id,minWidthPx:720,emptyMessage:v.active?u(`locations.filter.noMatch`):c})]})}function Bt(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 Vt(e,t){let n=t.map(Bt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:le({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var Ht=`device-manager:linked-devices`;function Ut(e){return{deviceId:e.deviceId,slotRef:Ht,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}a();var Wt=`__unassigned__`;function Gt(){let{t:r}=Y(),a=o(),s=ie(),{data:c,isLoading:l}=Ve(),{data:u}=he(),{data:d}=He(),{data:f}=be(),{data:p,isLoading:m}=_e({projection:`slim`}),h=()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},g=qe({onSuccess:h}),_=Ee({onSuccess:h}),v=je({onSuccess:h}),y=ge({onSuccess:h}),b=ye({onSuccess:h}),x=ve({onSuccess:h}),S=Ce({onSuccess:h}),C=Xe({onSuccess:h}),w=Oe({onSuccess:h}),T=Ge({onSuccess:h}),E=Ie(),D=t(()=>(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=t(()=>pt(D,O),[D,O]),[A,ee]=$e(),j=A.get(`tab`),M=j===`zones`||j===`camera-links`?j:`locations`,N=A.get(`room`),P=t(()=>lt(D,O),[D,O]),F=N===Wt,I=F?null:N!==null&&k.some(e=>e.name===N)?N:k[0]?.name??null,L=I===null?null:k.find(e=>e.name===I)??null,te=F?Wt:I??`__unassigned__`,R=I??k[0]?.name??null,ne=t(()=>k.map(e=>({name:e.name,count:e.members.length})),[k]),ae=e=>{ee(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},z=l||m,B=v.isPending||_.isPending||g.isPending||b.isPending,oe=async e=>{await g.mutateAsync({name:e})},ce=async(e,t)=>{let n=t.trim();n.length===0||n===e||await y.mutateAsync({from:e,to:n})},le=async e=>{let t=Vt(e,D);if(t.entries.length===0){await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:e}),confirmLabel:`OK`});return}let n=t.entries.map(e=>r(`locations.rebuildEntry`,{name:e.name,count:e.ids.length})).join(`
1
+ import{C as e,K as t,S as n,V as r,Y as i,et 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-CEyXHAdg.js";import{Bi as c,Br as l,Di as u,En as d,Fn as f,Gt as p,Ht as m,Jr as h,Jt as g,Ni as _,O as v,Ri as y,Sr as b,Ti as x,Ur as S,V as C,Vn as w,Wi as T,Wt as E,Yr as D,Zi as O,aa as k,gr as A,gt as ee,hr as j,ht as M,k as N,ln as P,lr as F,mn as I,oa as L,oi as te,on as R,sa as ne,sr as re,st as ie,vi as ae,vt as z,yn as B,z as oe}from"./player-overlays-g9d3qYrr.js";import{$r as se,ti as ce,yn as le}from"./client-CwJGlpR9.js";import{t as ue}from"./boxes-C9rq6GsW.js";import{n as de,r as fe,t as pe}from"./speaker-DkdRIL1K.js";import{t as V}from"./user-round-Z0QH_kjR.js";import{$a as me,Ao as he,Bo as ge,Do as _e,Fr as H,Go as ve,Ko as ye,Lr as U,No as be,Nr as W,Pr as xe,Qa as Se,Qo as Ce,Qr as we,R as Te,Ro as Ee,Sn as G,Un as De,Vo as Oe,Vr as ke,Wn as Ae,Wo as je,Yr as K,_d as Me,_r as Ne,dd as Pe,dr as Fe,eo as Ie,fn as Le,fr as Re,gd as q,gr as ze,hr as Be,jo as Ve,ko as He,pn as Ue,pr as We,qo as Ge,ri as Ke,ro as qe,vd as Je,yt as Ye,zo as Xe}from"./src-DwNoxp86.js";import{t as J}from"./i18n-9jE1YKjd.js";import{t as Y}from"./useTranslation-BJr-n0es.js";import{_r as Ze,m as Qe,mr as X,yr as $e}from"./index-DG07MiZm.js";import{t as et}from"./AdminSectionedPage-BZCKp3Ch.js";import{a as tt,n as nt,r as rt}from"./linked-devices-model-D3jOXb7G.js";a();function Z(e){return{id:e.id,name:e.name,type:e.type,stableId:e.stableId??``,parentDeviceId:e.parentDeviceId,location:e.location,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.primaryChildEntityId!==void 0&&e.primaryChildEntityId!==null?{primaryChildEntityId:e.primaryChildEntityId}:{}}}function Q(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function it(e,t){let n=Q(t);return n===null?[]:e.filter(e=>Q(e.location)===n)}function at(e,t){let n=it(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function ot(e,t){let n=Q(e.location);return n===null||new Set(t.map(e=>Q(e))).has(n)?null:e.location?.trim()??null}function st(e,t){let n=Q(e.location);return n!==null&&t.has(n)}function ct(e,t){let n=new Set(t.map(e=>Q(e))),r=new Set(e.filter(e=>st(e,n)).map(e=>e.id));return e.filter(e=>!(st(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function lt(e,t){return ct(e,t).filter(e=>e.parentDeviceId===null)}function ut(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 dt(e,t){return ut(e,t).length}function ft(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function pt(e,t){return t.map(t=>({name:t,members:at(e,t)}))}var mt={camera:_,hub:de,container:ue,light:A,siren:P,switch:p,sensor:ne,thermostat:g,climate:L,button:ae,"event-emitter":M,update:fe,notifier:T,script:B,automation:z,lock:F,cover:c,valve:D,humidifier:h,"water-heater":l,fan:S,"media-player":pe,"alarm-panel":I,control:R,presence:V,weather:te,vacuum:y,"lawn-mower":E,image:b,smoke:k};function $({type:e,className:t}){return n(mt[e]??ae,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function ht({device:e}){let t=H(Z(e),`compact`);return n(gt,{online:e.online,deviceName:t})}function gt({online:e,deviceName:t}){return n(`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":J.t(`locations.deviceGlyphs.aria`,{name:t,state:e?J.t(`common.online`):J.t(`common.offline`)}),title:e?J.t(`common.online`):J.t(`common.offline`)})}function _t({open:t,title:a,items:o,listState:s,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=Y(),[h,g]=i([]);r(()=>{t||g([])},[t]);let _=new Map(o.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 n(Fe,{open:t,onOpenChange:e=>e?void 0:p(),children:e(We,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":a,children:[n(ze,{children:n(Ne,{children:a})}),e(Re,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[t&&u!==null&&v.length>0&&e(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[n(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),n(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>n(`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))})]}),t&&n(Te,{devices:o,listState:s,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),e(Be,{children:[n(K,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),n(K,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}a();function vt({room:e,cameras:r,fleet:i}){let{t:a}=Y(),o=t(()=>new Map(i.map(e=>[e.id,e])),[i]);return e===null?n(`p`,{className:`text-xs text-foreground-subtle`,children:a(`locations.links.noRoom`)}):n(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:r.length===0?n(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:a(`locations.links.noCameras`,{room:e})}):r.map(e=>n(bt,{camera:e,byId:o},e.id))})}function yt(e){return{id:e.deviceId,name:e.name,type:e.type,location:e.location}}function bt({camera:t,byId:r}){let{t:a}=Y(),s=H(Z(t),`full`),c=o(),l=Ze(),[u,d]=i(!1),[f,p]=i(null),m=me({deviceId:t.id}),h=rt({status:m.status,data:m.data,error:m.error===null||m.error===void 0?null:m.error}),g=Ie(),_=h.kind===`present`?h:null,y=Se({deviceId:t.id,slotRef:_?.slot.slotRef??``},{enabled:u&&_!==null}),b=_===null?[]:nt(_.slot,_.value),x=b.map(e=>e.deviceId),S=(y.data?.candidates??[]).map(yt),C=new Set(S.map(e=>e.id)),w=x.filter(e=>!C.has(e)).map(e=>{let t=r.get(e);return{id:e,name:t?.name??`#${String(e)}`,...t===void 0?{}:{type:t.type,location:t.location}}}),T=[...S,...w],E=(y.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),D=async e=>{if(_!==null){p(null);try{await g.mutateAsync({deviceId:t.id,slotRef:_.slot.slotRef,value:tt(_.value,e)}),await m.refetch(),await c.invalidateQueries({queryKey:[[`deviceManager`]]}),d(!1)}catch(e){p(e instanceof Error?e.message:String(e))}}},O=[{key:`device`,header:a(`locations.columns.device`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId),o=t.name??i?.name??`#${String(t.deviceId)}`;return e(`span`,{className:`flex items-center gap-1.5`,children:[i!==void 0&&n($,{type:i.type}),n(X,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:i===void 0?o:n(W,{device:Z(i),form:`compact`})}),t.implied&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`locations.links.implied`)})]})}},{key:`type`,header:a(`locations.columns.type`),notSortableReason:a(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:r.get(e.deviceId)?.type??`—`})},{key:`status`,header:a(`locations.columns.status`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId);return i===void 0?n(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:i}),n(`span`,{className:`text-xs text-foreground-muted`,children:i.online?a(`common.online`):a(`common.offline`)})]})}}];return e(`section`,{className:`min-w-0 ${v}`,"data-testid":`camera-links-${String(t.id)}`,children:[e(`header`,{className:`${N} flex min-h-9 items-center gap-1.5`,children:[n($,{type:t.type}),n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:n(W,{device:Z(t),form:`full`})}),e(K,{variant:`ghost`,size:`sm`,onClick:()=>l(Qe(t.id)),children:[n(j,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`locations.links.edit`)]}),n(K,{variant:`outline`,size:`sm`,disabled:_===null,onClick:()=>d(!0),"aria-label":a(`locations.links.addNamed`,{camera:s}),children:a(`locations.room.add`)})]}),h.kind===`pending`&&n(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.loading`)}),h.kind===`unknown`&&n(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:a(`locations.links.unreadable`,{reason:h.reason})}),h.kind===`absent`&&n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.unsupported`)}),f!==null&&n(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:f}),_!==null&&(b.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.none`)}):n(G,{columns:O,rows:b,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),n(_t,{open:u,title:a(`locations.links.pickTitle`,{camera:s}),items:T,listState:y.status===`error`?`failed`:y.data===void 0?`pending`:`answered`,lockedIds:x,lockedNote:a(`locations.links.alreadyLinked`),suggestions:t.location===null?null:{heading:a(`locations.links.suggested`,{room:t.location}),ids:E},busy:g.isPending,onConfirm:e=>void D(e),onClose:()=>d(!1)})]})}a();function xt({name:t,description:a,busy:o,onSave:s}){let{t:c}=Y(),[l,u]=i(a??``);return r(()=>{u(a??``)},[a]),e(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[n(Ae,{htmlFor:`location-description-${t}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),n(`textarea`,{id:`location-description-${t}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(a??``)&&s(e.length===0?null:e)},disabled:o,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`}),n(`p`,{className:`mt-1 ${oe}`,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 St(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var Ct=` none`;function wt({name:t,zones:r,zoneKey:i,busy:a,onChange:o}){let{t:s}=Y();if(r.length===0)return null;let c=[{value:Ct,label:s(`locations.locationZoneField.none`,`— none —`)},...r.map(e=>({value:e.zoneKey,label:e.label}))];return e(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[n(Ae,{htmlFor:`location-zone-${t}`,children:s(`locations.locationZoneField.zone`,`Zone`)}),n(Pe,{id:`location-zone-${t}`,value:i??Ct,disabled:a,onChange:e=>{let t=e.target.value;if(t===Ct){o(null);return}let n=r.find(e=>e.zoneKey===t);n!==void 0&&o(n.label)},options:c})]})}function Tt(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function Et({name:e,icon:t,busy:r,onPick:i}){return n(Je,{value:t,onPick:i,fallbackGlyph:re,clearGlyph:O,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:r})}function Dt(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:ce(n.icon)??`map-pin`}function Ot(e){return`${e.kind}:${String(e.device.id)}`}function kt(e,t,n){return e.flatMap(e=>{let r=ft(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}))]})}a();function At({name:r,members:a,devices:o,busy:c,icon:l,description:u,onRename:f,onDelete:p,onRebuildLinks:h,onAddDevices:g,onPickIcon:_,onSaveDescription:y,zones:b,zoneKey:x,onChangeZone:S}){let{t:C}=Y(),[T,E]=i(!1),[D,O]=i(r),k=Le(a,t(()=>({searchText:e=>[e.name,...ft(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[A,j]=i(()=>new Set),M=e=>j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),P=t(()=>kt(k.rows,o,A),[k.rows,o,A]),F=[{key:`name`,header:C(`locations.columns.device`),notSortableReason:C(`locations.columns.noSort`),render:e=>e.kind===`member`?n(jt,{row:e,onToggle:()=>M(e.device.id)}):n(Mt,{row:e})},{key:`type`,header:C(`locations.columns.type`),notSortableReason:C(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:C(`locations.columns.status`),notSortableReason:C(`locations.columns.noSort`),render:t=>e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:t.device}),n(`span`,{className:`text-xs text-foreground-muted`,children:t.device.online?C(`common.online`):C(`common.offline`)})]})}],I=()=>{O(r),E(!1)},L=async()=>{let e=D.trim();if(e.length===0||e===r){I();return}await f(e),E(!1)},te=[{id:`rename`,label:C(`locations.locationCard.rename`,`Rename`),icon:w,disabled:c,onClick:()=>{O(r),E(!0)}},{id:`rebuild-links`,label:C(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:d,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 e(`section`,{className:`min-w-0 ${v}`,children:[e(`header`,{className:`${N} flex min-h-9 items-center gap-1.5`,children:[n(Et,{name:r,icon:l,busy:c,onPick:_}),T?e(s,{children:[n(q,{value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&L(),e.key===`Escape`&&I()},"aria-label":C(`locations.locationCard.rename2`,`Rename {{name}}`,{name:r}),className:`min-w-0 flex-1`,autoFocus:!0}),n(K,{type:`button`,size:`sm`,onClick:()=>void L(),children:C(`common.save`,`Save`)}),n(Me,{type:`button`,variant:`ghost`,icon:ee,onClick:I,"aria-label":C(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):e(s,{children:[n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:r}),n(K,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:g,"aria-label":C(`locations.room.addTo`,{room:r}),children:C(`locations.room.add`)}),n(Ye,{items:te,title:C(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:r}),triggerClassName:`p-1`})]})]}),n(wt,{name:r,zones:b,zoneKey:x,busy:c,onChange:S}),n(xt,{name:r,description:u,busy:c,onSave:y}),a.length>0&&n(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:n(Ue,{state:k.state,facets:k.facets,labels:{searchPlaceholder:C(`locations.filter.searchPlaceholder`),searchLabel:C(`locations.room.searchLabel`,{room:r}),facetsLabel:C(`locations.filter.typesLabel`),clearLabel:C(`locations.filter.clear`)},onSearch:k.setSearch,onToggleFacet:k.toggleFacet,onClear:k.clear})}),a.length===0?n(`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.`)}):n(G,{columns:F,rows:P,rowKey:Ot,bordered:!1,minWidthPx:360,emptyMessage:C(`locations.filter.noMatch`)})]})}function jt({row:t,onToggle:r}){let{t:i}=Y(),{device:a,accessories:o,open:s}=t,c=H(Z(a),`compact`),l=s?u:x;return e(`span`,{className:`flex items-center gap-1.5`,children:[o.length>0?e(K,{type:`button`,variant:`ghost`,onClick:r,"aria-expanded":s,"aria-label":i(s?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:o.length,name:c}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[n(l,{className:`h-3 w-3`}),n(`span`,{className:`text-[10px] tabular-nums`,children:o.length})]}):n(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),n($,{type:a.type}),n(X,{to:`/devices/${String(a.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:n(W,{device:Z(a),form:`compact`})})]})}function Mt({row:t}){let{device:r,parent:i}=t;return e(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[n(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),n($,{type:r.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),n(X,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:n(W,{device:Z(r),form:`nested`,parent:Z(i)})})]})}a();function Nt({zones:e,busy:t,onRename:r,onDelete:a,onPickIcon:o}){let{t:s}=Y(),[c,l]=i(null),[u,d]=i(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await r(e,t)};return n(G,{columns:[{key:`icon`,header:s(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>n(Et,{name:e.label,icon:e.icon,busy:t,onPick:t=>o(e.label,t)})},{key:`name`,header:s(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?n(q,{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":s(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):n(K,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:s(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:s(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>n(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?s(`common.empty`):s(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:s(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>n(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void a(e.label),disabled:t,"aria-label":s(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:s(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:n(m,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:s(`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.`)})}a();function Pt({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(q,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newLocationButton.frontDoorHallKitchen`,`Front door, Hall, Kitchen…`),"aria-label":a(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(f,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:n(ee,{className:`h-3.5 w-3.5`})})]}):e(K,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-location-button`,children:[n(f,{className:`h-3.5 w-3.5`}),a(`locations.newLocationButton.newLocation`,`New location`)]})}a();function Ft({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(q,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Night zone…`),"aria-label":a(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(f,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:n(ee,{className:`h-3.5 w-3.5`})})]}):e(K,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-zone-button`,children:[n(f,{className:`h-3.5 w-3.5`}),a(`locations.newZoneButton.newZone`,`New zone`)]})}a();function It(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 Lt({rooms:e,unassignedCount:r,value:i,unassignedValue:a,onChange:o}){let{t:s}=Y(),c=t(()=>It(e,r,a,s(`locations.roomPicker.unassigned`)),[e,r,a,s]);return n(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:n(we,{mode:`single`,singleDisplay:`field`,label:s(`locations.roomPicker.label`),placeholder:s(`locations.roomPicker.placeholder`),options:c,value:i,onChange:o,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}a();var Rt={searchText:e=>[e.name],facetValue:e=>e.type};function zt({rows:r,fleet:a,locations:o,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=Y(),d=ke(),f=U(),p=e=>d===null?e.name:xe(Z(e),`compact`,d,f),[m,h]=i([]),[g,_]=i(``),v=Le(r,Rt),y=v.rows,b=t(()=>y.map(e=>e.id),[y]),x=t(()=>m.filter(e=>b.includes(e)),[m,b]),S=y.length>0&&x.length===y.length,w=t(()=>{let e=new Map;for(let t of r)e.set(t.id,dt(a,t.id));return e},[r,a]),T=x.reduce((e,t)=>e+(w.get(t)??0),0),E=e=>h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),D=()=>h(S?[]:b),O=()=>{g.length===0||x.length===0||(l(x,g),h([]),_(``))},k=o.map(e=>({value:e,label:e})),A=[{key:`select`,width:`w-8`,headerRender:()=>n(De,{checked:S,onChange:D,"aria-label":S?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>n(De,{checked:x.includes(e.id),onChange:()=>E(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:p(e)})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:t=>{let r=ot(t,o);return e(`span`,{className:`flex items-center gap-1.5`,children:[n($,{type:t.type}),n(X,{to:`/devices/${String(t.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:n(W,{device:Z(t),form:`compact`})}),r!==null&&n(Ke,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:r})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:t=>e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:t}),n(`span`,{className:`text-xs text-foreground-muted`,children:t.online?u(`common.online`):u(`common.offline`)})]})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>w.get(e.id)??0,render:e=>n(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:w.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=>n(Pe,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:p(e)}),value:``,disabled:s||o.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...k]})}];return e(`section`,{className:`space-y-2`,children:[e(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[n(`h2`,{className:C,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),n(`p`,{className:oe,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),r.length>0&&n(Ue,{state:v.state,facets:v.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onClear:v.clear}),x.length>0&&e(`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:[e(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:x.length}),T>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:T})}`]}),n(Pe,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:g,onChange:e=>_(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...k]}),n(K,{type:`button`,size:`sm`,onClick:O,disabled:s||g.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),n(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>h([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),n(G,{columns:A,rows:y,rowKey:e=>e.id,minWidthPx:720,emptyMessage:v.active?u(`locations.filter.noMatch`):c})]})}function Bt(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 Vt(e,t){let n=t.map(Bt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:le({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var Ht=`device-manager:linked-devices`;function Ut(e){return{deviceId:e.deviceId,slotRef:Ht,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}a();var Wt=`__unassigned__`;function Gt(){let{t:r}=Y(),a=o(),s=ie(),{data:c,isLoading:l}=Ve(),{data:u}=he(),{data:d}=He(),{data:f}=be(),{data:p,isLoading:m}=_e({projection:`slim`}),h=()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},g=qe({onSuccess:h}),_=Ee({onSuccess:h}),v=je({onSuccess:h}),y=ge({onSuccess:h}),b=ye({onSuccess:h}),x=ve({onSuccess:h}),S=Ce({onSuccess:h}),C=Xe({onSuccess:h}),w=Oe({onSuccess:h}),T=Ge({onSuccess:h}),E=Ie(),D=t(()=>(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=t(()=>pt(D,O),[D,O]),[A,ee]=$e(),j=A.get(`tab`),M=j===`zones`||j===`camera-links`?j:`locations`,N=A.get(`room`),P=t(()=>lt(D,O),[D,O]),F=N===Wt,I=F?null:N!==null&&k.some(e=>e.name===N)?N:k[0]?.name??null,L=I===null?null:k.find(e=>e.name===I)??null,te=F?Wt:I??`__unassigned__`,R=I??k[0]?.name??null,ne=t(()=>k.map(e=>({name:e.name,count:e.members.length})),[k]),ae=e=>{ee(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},z=l||m,B=v.isPending||_.isPending||g.isPending||b.isPending,oe=async e=>{await g.mutateAsync({name:e})},ce=async(e,t)=>{let n=t.trim();n.length===0||n===e||await y.mutateAsync({from:e,to:n})},le=async e=>{let t=Vt(e,D);if(t.entries.length===0){await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:e}),confirmLabel:`OK`});return}let n=t.entries.map(e=>r(`locations.rebuildEntry`,{name:e.name,count:e.ids.length})).join(`
2
2
  `);if(!await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`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:e,lines:n}),confirmLabel:r(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of t.entries)try{await E.mutateAsync(Ut(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}h(),i.length>0&&await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
3
3
  `)}),confirmLabel:`OK`})},ue=async(e,t)=>{let n=t>0?` ${String(t)} device(s) will become unassigned.`:``;await s({title:r(`locations.deleteLocation`,`Delete location`),message:r(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:e,extra:n}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await _.mutateAsync({name:e,cascade:!0})},de=async e=>{await s({title:r(`locations.deleteZone`,`Delete zone`),message:r(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:e}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await C.mutateAsync({name:e})},fe=async(e,t)=>{await b.mutateAsync({location:e,icon:t})},pe=async(e,t)=>{await x.mutateAsync({location:e,description:t})},V=f??[],me=async(e,t)=>{await T.mutateAsync({location:e,zone:t})},H=(e,t)=>{for(let n of e)v.mutate({deviceId:n,location:t})},[U,W]=i(null),xe=t(()=>D.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[D]),Se=n(Lt,{rooms:ne,...M===`locations`?{unassignedCount:P.length}:{},value:M===`locations`?te:R??``,unassignedValue:Wt,onChange:ae}),we=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[z&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),Se,F||L===null?n(zt,{rows:P,fleet:D,locations:O,busy:B,emptyMessage:z?r(`common.loading`,`Loading…`):r(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:H}):n(At,{name:L.name,members:L.members,devices:D,busy:B,icon:Dt(u,se(L.name)),onPickIcon:e=>fe(L.name,e),description:St(d,se(L.name)),onSaveDescription:e=>pe(L.name,e),zones:V,zoneKey:Tt(V,se(L.name)),onChangeZone:e=>me(L.name,e),onRename:e=>ce(L.name,e),onDelete:()=>ue(L.name,it(D,L.name).length),onRebuildLinks:()=>le(L.name),onAddDevices:()=>W(L.name)},L.name),O.length===0&&!z&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.noLocationsYetAddFrontDoor`,`No locations yet. Add Front door, Hall, Kitchen…`)}),n(_t,{open:U!==null,title:r(`locations.room.addDialogTitle`,{room:U??``}),items:xe,listState:m?`pending`:`answered`,lockedIds:U===null?[]:(k.find(e=>e.name===U)?.members??[]).map(e=>e.id),lockedNote:r(`locations.room.alreadyHere`),suggestions:{heading:r(`locations.room.suggestedUnassigned`),ids:P.map(e=>e.id)},busy:v.isPending,onConfirm:e=>{U!==null&&H(e,U),W(null)},onClose:()=>W(null)})]}),Te=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[Se,n(vt,{room:R,cameras:R===null?[]:it(D,R).filter(e=>e.isCamera),fleet:D})]});return n(et,{icon:re,title:r(`locations.locations`,`Locations`),subtitle:r(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:M===`zones`?n(Ft,{busy:S.isPending,onCreate:e=>S.mutateAsync({name:e})}):n(Pt,{busy:g.isPending,onCreate:oe}),sections:[{id:`locations`,label:r(`locations.locations`,`Locations`),content:we},{id:`camera-links`,label:r(`locations.cameraLinks`,`Camera links`),content:Te},{id:`zones`,label:r(`locations.zones`,`Zones`),content:n(Nt,{zones:V,busy:B,onRename:(e,t)=>w.mutateAsync({from:e,to:t}),onDelete:de,onPickIcon:(e,t)=>S.mutateAsync({name:e,icon:t})})}]})}export{Gt as LocationsPage};
@@ -1 +1 @@
1
- import{C as e,K as t,S as n,Y as r,et as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ni as a,Oi as o,fr as s,sa as c,yn as l}from"./player-overlays-CzZYPO2s.js";import{n as u,t as d}from"./timer-reset-DLwEAlTU.js";import{t as f}from"./layers-BuqS0QUs.js";import{Au as p,Du as m,Fd as h,Fi as g,Pi as _,en as v}from"./src-DytYtgEw.js";import{t as y}from"./useTranslation-BJr-n0es.js";import{T as b,a as x,i as S}from"./index-B6a27fav.js";import{t as C}from"./AdminSectionedPage-DhFW0QuY.js";import{t as w}from"./AdminPage-CoK_jJGS.js";import{n as T,t as E}from"./IntegrationHub-CMzk8_M7.js";import{n as D,t as O}from"./addon-display-names-BkwMrExv.js";i();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(),r=g({capName:`log-destination`},{refetchInterval:k}),i=_(void 0,{refetchInterval:k}),a=t(()=>O(i.data??[]),[i.data]),o=t(()=>{let e=new Map;for(let t of i.data??[]){let n=t.description,r=t.id;typeof r==`string`&&typeof n==`string`&&n.length>0&&e.set(r,n)}return e},[i.data]),s=t(()=>(r.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive,caption:o.get(e.addonId)??j[e.addonId]??``})),[r.data,a,o]),c=[{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:()=>n(T,{addonId:e.addonId,displayName:e.displayName,capName:A,isActive:e.isActive,badges:e.caption.length>0?n(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.caption}):null})}))}];return n(E,{embedded:!0,icon:l,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:c,isLoading:r.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.`)})}i();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}=y(),i=m({},{refetchInterval:5e3}),a=p(),[o,l]=r(null),u=(e,t)=>{l(e),a.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{l(null),i.refetch()}})},d=i.data?.activeWindows??[],f=i.data?.channels??[],h=i.data?.activeChannels??[],g=(e,t,n)=>{l(e),a.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:n}]}},{onSettled:()=>{l(null),i.refetch()}})};return e(w,{embedded:!0,icon:c,title:t(`logging.diagnostics.title`,`Diagnostics`),subtitle:t(`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:[i.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(s,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.loading`,`Loading…`)]}):n(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>n(L,{window:e,busy:o===e.id,onArm:t=>u(e.id,t)},e.id))}),n(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:t(`logging.diagnostics.channels`,`Component channels`)}),n(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:t(`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?n(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):n(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:f.map(e=>n(I,{channel:e,state:h.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>g(e.name,t,n)},e.name))})]})}function I({channel:t,state:i,busy:o,onArm:s}){let{t:c}=y(),[l,u]=r(``),f=i?.armed===!0,p=()=>{let e=l.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),f?e(`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:[n(d,{className:`h-3 w-3`}),c(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:R(i?.remainingMs??0)})]}):n(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.disarmed`,`disarmed`)}),f&&i?.deviceIds!==null&&i?.deviceIds!==void 0&&e(`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:[n(a,{className:`h-3 w-3`}),i.deviceIds.join(`, `)]}),!t.perDevice&&n(`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`)})]}),n(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:t.description})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[t.perDevice&&n(`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=>n(`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)),n(`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:t,busy:r,onArm:i}){let{t:a}=y();return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-sm font-medium text-foreground`,children:t.id}),t.armed?e(`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:[n(d,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:R(t.remainingMs)})]}):n(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),t.armed&&!t.persisted&&n(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),n(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:P[t.id]??``})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[N.map(e=>n(`button`,{type:`button`,disabled:r,onClick:()=>i(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)),n(`button`,{type:`button`,disabled:r||!t.armed,onClick:()=>i(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`}i();var z=[`debug`,`info`,`warn`,`error`],B=``,V=``;function H(){let{t:i}=y(),[a,o]=r(B),[c,l]=r(V),{nodes:u}=h(),d=t(()=>u.map(e=>({id:e.id,label:e.name||e.id})),[u]),g=m({...a===B?{}:{scopeNodeId:a},...c===V?{}:{scopeComponent:c}},{refetchInterval:15e3}),_=p(),v=g.data,b=_.isPending||g.isFetching,x=v?.channels??[],S=(e,t)=>{_.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void g.refetch()})};return n(w,{embedded:!0,icon:f,title:i(`logging.levels.title`,`Levels`),subtitle:i(`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:e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(`logging.levels.scope`,`Scope`),e(`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:[n(`option`,{value:B,children:i(`logging.levels.cluster`,`Cluster`)}),d.map(e=>n(`option`,{value:e.id,children:e.label},e.id))]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(`logging.levels.component`,`Component`),e(`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:[n(`option`,{value:V,children:i(`logging.levels.noComponent`,`None`)}),x.map(e=>n(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:g.isLoading||v===void 0?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(s,{className:`h-3.5 w-3.5 animate-spin`}),i(`common.loading`,`Loading…`)]}):e(`div`,{className:`space-y-3`,children:[n(W,{level:v.effective.level,source:v.effective.levelSource,persisted:v.persisted}),n(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:v.explicit.layers.map(e=>n(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&&n(`p`,{className:`text-[11px] text-foreground-subtle`,children:x.find(e=>e.name===c)?.description??``}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:i(`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.`)}),n(U,{days:v.opsLogRetentionDays,busy:b,onSet:e=>_.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void g.refetch()})})]})})}function U({days:t,busy:r,onSet:i}){let{t:a}=y();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[e(`label`,{className:`flex items-center justify-between gap-3`,children:[n(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),e(`span`,{className:`flex items-center gap-1.5`,children:[n(`input`,{type:`number`,min:0,max:3650,step:1,defaultValue:t,disabled:r,onBlur:e=>{let n=Number.parseInt(e.target.value,10);Number.isFinite(n)&&n!==t&&i(n)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),n(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),n(`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:t,source:r,persisted:i}){let{t:a}=y();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),n(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:t}),n(`span`,{className:`text-[11px] text-foreground-subtle`,children:r==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:r})})]}),!i&&n(`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:t,inForce:r,busy:i,onSet:a,onClear:s}){let{t:c}=y();return e(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-sm font-medium text-foreground`,children:t.scope===`cluster`?c(`logging.levels.cluster`,`Cluster`):t.scope===`component`?t.component??``:t.nodeId??``}),r&&e(`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:[n(o,{className:`h-3 w-3`}),c(`logging.levels.inForce`,`in force`)]})]}),n(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:t.level===null?c(`logging.levels.inherits`,`inherits — nothing set at this layer`):c(`logging.levels.setHere`,`set here: {{level}}`,{level:t.level})})]}),e(`div`,{className:`flex shrink-0 items-center gap-1`,children:[z.map(e=>n(`button`,{type:`button`,disabled:i,onClick:()=>a(e),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${t.level===e?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:e},e)),n(`button`,{type:`button`,disabled:i||t.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 n(w,{embedded:!0,children:n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:n(v,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0})})})}function q(){let{t:e}=y(),t=b(`/system/logs`,{t:e,isAdmin:!0})??{icon:l,title:e(`system.logs`,`Logs`)};return n(C,{icon:t.icon,title:t.title,defaultSection:`viewer`,sectionsLabel:`${t.title} sections`,sections:[{id:`viewer`,label:e(`admin.system.logs.viewer`,`Viewer`),content:n(K,{})},{id:x.logging.tab,label:e(`admin.system.logs.destinations`,`Destinations`),content:n(M,{}),ownedParams:S},{id:`levels`,label:e(`admin.system.logs.levels`,`Levels`),content:n(H,{})},{id:`diagnostics`,label:e(`admin.system.logs.diagnostics`,`Diagnostics`),content:n(F,{})}]})}export{q as LogsPage};
1
+ import{C as e,K as t,S as n,Y as r,et as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ni as a,Oi as o,fr as s,sa as c,yn as l}from"./player-overlays-g9d3qYrr.js";import{n as u,t as d}from"./timer-reset-DVNN3Abc.js";import{t as f}from"./layers-C2a0eh6-.js";import{Au as p,Du as m,Fd as h,Fi as g,Pi as _,en as v}from"./src-DwNoxp86.js";import{t as y}from"./useTranslation-BJr-n0es.js";import{T as b,a as x,i as S}from"./index-DG07MiZm.js";import{t as C}from"./AdminSectionedPage-BZCKp3Ch.js";import{t as w}from"./AdminPage-DlYf-2bp.js";import{n as T,t as E}from"./IntegrationHub-B1kSbU1F.js";import{n as D,t as O}from"./addon-display-names-BkwMrExv.js";i();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(),r=g({capName:`log-destination`},{refetchInterval:k}),i=_(void 0,{refetchInterval:k}),a=t(()=>O(i.data??[]),[i.data]),o=t(()=>{let e=new Map;for(let t of i.data??[]){let n=t.description,r=t.id;typeof r==`string`&&typeof n==`string`&&n.length>0&&e.set(r,n)}return e},[i.data]),s=t(()=>(r.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive,caption:o.get(e.addonId)??j[e.addonId]??``})),[r.data,a,o]),c=[{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:()=>n(T,{addonId:e.addonId,displayName:e.displayName,capName:A,isActive:e.isActive,badges:e.caption.length>0?n(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.caption}):null})}))}];return n(E,{embedded:!0,icon:l,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:c,isLoading:r.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.`)})}i();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}=y(),i=m({},{refetchInterval:5e3}),a=p(),[o,l]=r(null),u=(e,t)=>{l(e),a.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{l(null),i.refetch()}})},d=i.data?.activeWindows??[],f=i.data?.channels??[],h=i.data?.activeChannels??[],g=(e,t,n)=>{l(e),a.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:n}]}},{onSettled:()=>{l(null),i.refetch()}})};return e(w,{embedded:!0,icon:c,title:t(`logging.diagnostics.title`,`Diagnostics`),subtitle:t(`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:[i.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(s,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.loading`,`Loading…`)]}):n(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>n(L,{window:e,busy:o===e.id,onArm:t=>u(e.id,t)},e.id))}),n(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:t(`logging.diagnostics.channels`,`Component channels`)}),n(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:t(`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?n(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):n(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:f.map(e=>n(I,{channel:e,state:h.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>g(e.name,t,n)},e.name))})]})}function I({channel:t,state:i,busy:o,onArm:s}){let{t:c}=y(),[l,u]=r(``),f=i?.armed===!0,p=()=>{let e=l.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),f?e(`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:[n(d,{className:`h-3 w-3`}),c(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:R(i?.remainingMs??0)})]}):n(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.disarmed`,`disarmed`)}),f&&i?.deviceIds!==null&&i?.deviceIds!==void 0&&e(`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:[n(a,{className:`h-3 w-3`}),i.deviceIds.join(`, `)]}),!t.perDevice&&n(`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`)})]}),n(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:t.description})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[t.perDevice&&n(`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=>n(`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)),n(`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:t,busy:r,onArm:i}){let{t:a}=y();return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-sm font-medium text-foreground`,children:t.id}),t.armed?e(`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:[n(d,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:R(t.remainingMs)})]}):n(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),t.armed&&!t.persisted&&n(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),n(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:P[t.id]??``})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[N.map(e=>n(`button`,{type:`button`,disabled:r,onClick:()=>i(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)),n(`button`,{type:`button`,disabled:r||!t.armed,onClick:()=>i(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`}i();var z=[`debug`,`info`,`warn`,`error`],B=``,V=``;function H(){let{t:i}=y(),[a,o]=r(B),[c,l]=r(V),{nodes:u}=h(),d=t(()=>u.map(e=>({id:e.id,label:e.name||e.id})),[u]),g=m({...a===B?{}:{scopeNodeId:a},...c===V?{}:{scopeComponent:c}},{refetchInterval:15e3}),_=p(),v=g.data,b=_.isPending||g.isFetching,x=v?.channels??[],S=(e,t)=>{_.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void g.refetch()})};return n(w,{embedded:!0,icon:f,title:i(`logging.levels.title`,`Levels`),subtitle:i(`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:e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(`logging.levels.scope`,`Scope`),e(`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:[n(`option`,{value:B,children:i(`logging.levels.cluster`,`Cluster`)}),d.map(e=>n(`option`,{value:e.id,children:e.label},e.id))]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(`logging.levels.component`,`Component`),e(`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:[n(`option`,{value:V,children:i(`logging.levels.noComponent`,`None`)}),x.map(e=>n(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:g.isLoading||v===void 0?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(s,{className:`h-3.5 w-3.5 animate-spin`}),i(`common.loading`,`Loading…`)]}):e(`div`,{className:`space-y-3`,children:[n(W,{level:v.effective.level,source:v.effective.levelSource,persisted:v.persisted}),n(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:v.explicit.layers.map(e=>n(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&&n(`p`,{className:`text-[11px] text-foreground-subtle`,children:x.find(e=>e.name===c)?.description??``}),n(`p`,{className:`text-[11px] text-foreground-subtle`,children:i(`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.`)}),n(U,{days:v.opsLogRetentionDays,busy:b,onSet:e=>_.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void g.refetch()})})]})})}function U({days:t,busy:r,onSet:i}){let{t:a}=y();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[e(`label`,{className:`flex items-center justify-between gap-3`,children:[n(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),e(`span`,{className:`flex items-center gap-1.5`,children:[n(`input`,{type:`number`,min:0,max:3650,step:1,defaultValue:t,disabled:r,onBlur:e=>{let n=Number.parseInt(e.target.value,10);Number.isFinite(n)&&n!==t&&i(n)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),n(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),n(`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:t,source:r,persisted:i}){let{t:a}=y();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),n(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:t}),n(`span`,{className:`text-[11px] text-foreground-subtle`,children:r==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:r})})]}),!i&&n(`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:t,inForce:r,busy:i,onSet:a,onClear:s}){let{t:c}=y();return e(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[n(`span`,{className:`text-sm font-medium text-foreground`,children:t.scope===`cluster`?c(`logging.levels.cluster`,`Cluster`):t.scope===`component`?t.component??``:t.nodeId??``}),r&&e(`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:[n(o,{className:`h-3 w-3`}),c(`logging.levels.inForce`,`in force`)]})]}),n(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:t.level===null?c(`logging.levels.inherits`,`inherits — nothing set at this layer`):c(`logging.levels.setHere`,`set here: {{level}}`,{level:t.level})})]}),e(`div`,{className:`flex shrink-0 items-center gap-1`,children:[z.map(e=>n(`button`,{type:`button`,disabled:i,onClick:()=>a(e),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${t.level===e?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:e},e)),n(`button`,{type:`button`,disabled:i||t.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 n(w,{embedded:!0,children:n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:n(v,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0})})})}function q(){let{t:e}=y(),t=b(`/system/logs`,{t:e,isAdmin:!0})??{icon:l,title:e(`system.logs`,`Logs`)};return n(C,{icon:t.icon,title:t.title,defaultSection:`viewer`,sectionsLabel:`${t.title} sections`,sections:[{id:`viewer`,label:e(`admin.system.logs.viewer`,`Viewer`),content:n(K,{})},{id:x.logging.tab,label:e(`admin.system.logs.destinations`,`Destinations`),content:n(M,{}),ownedParams:S},{id:`levels`,label:e(`admin.system.logs.levels`,`Levels`),content:n(H,{})},{id:`diagnostics`,label:e(`admin.system.logs.diagnostics`,`Diagnostics`),content:n(F,{})}]})}export{q as LogsPage};
@@ -1 +1 @@
1
- import{C as e,J as t,P as n,R as r,S as i,V as a,Y as o,et as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{pa as c}from"./player-overlays-CzZYPO2s.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-BjdR__nc.js";s();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:n,selectedId:s,onSelect:f,onShapeChange:p,onDrawComplete:m,drawingKind:v,supportedShapes:y,transparent:j=!1,backdrop:P,polygonVertices:F,grid:I}){let B=c(),V=t(null),[H,ee]=o({w:800,h:450}),[U,W]=o([]),[G,K]=o(null),[te,ne]=o(null),[q,J]=o(null),Y=v!==null&&y.includes(v);a(()=>{if(!q)return;let e=n.find(e=>e.id===q.itemId);if(!e||!N(e.shape)){J(null);return}M(e.shape.points,q.points)&&J(null)},[n,q]),a(()=>{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]),a(()=>{!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=t(null),Q=t(null);a(()=>()=>{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=t(!1),se=t(!0),ce=t(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(i(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(i(u,{points:[0,t,H.w,t],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gh-${e}`))}}return e(`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?i(`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,e(l,{width:H.w,height:H.h,onClick:re,onDblClick:ie,onMouseMove:ae,children:[e(g,{listening:!1,children:[i(u,{points:[0,0,H.w,0,H.w,H.h,0,H.h,0,0],stroke:`transparent`,strokeWidth:0}),$]}),i(g,{children:n.map(e=>{let t=e.id===s,n=e.enabled===!1,r=A(e),a=t&&!Y&&!n;if(e.shape.kind===`rect`)return i(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 i(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 i(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)})}),i(g,{listening:!1,children:Y&&U.length>0&&e(d,{children:[v===`polygon`&&U.length>=2&&i(u,{points:O(U,H.w,H.h),stroke:b,strokeWidth:1.5,dash:[6,3],opacity:.8}),v===`line`&&U.length===1&&G&&i(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&&i(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 i(h,{x:n.x,y:n.y,radius:r?7:4,fill:r?b:`#ffffff`,stroke:b,strokeWidth:1.5,opacity:.9},t)})]})})]}),Y?i(`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:t,shape:n,color:r,selected:s,dimmed:c,editable:l,isDrawing:u,size:m,onSelect:g,onShapeChange:_}){let[b,x]=o(null),S={x:n.x,y:n.y,width:n.width,height:n.height};a(()=>{b&&I(S,b)&&x(null)},[n.x,n.y,n.width,n.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:s?1:.85,A=e=>{x(e),_(t.id,{kind:`rect`,x:e.x,y:e.y,width:e.width,height:e.height})};return i(d,{onClick:e=>{e.cancelBubble=!0,u||g(t.id)},children:e(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:[i(p,{x:w,y:T,width:E,height:D,fill:r+(s?y:v),stroke:r,strokeWidth:s?2.5:1.5,opacity:O}),t.label?i(f,{x:w,y:T-16,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1}):null,l?i(h,{x:w+E,y:T+D,radius:6,fill:r,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:a,size:o,onSelect:s,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:f}){let{gridWidth:m,gridHeight:h,cells:g}=t,_=o.w/m,v=o.h/h,b=m*h,x=r?.3:1,S=n=>{if(!a){s(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||!a||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 i(d,{opacity:x,onMouseUp:w,onMouseLeave:w,children:Array.from({length:b},(e,t)=>{let r=t%m,a=Math.floor(t/m),o=g[t]===!0;return i(p,{x:r*_,y:a*v,width:_,height:v,fill:o?n+y:`#ffffff10`,stroke:o?n:`#ffffff40`,strokeWidth:.5,onMouseDown:e=>{e.cancelBubble=!0,S(t)},onMouseEnter:()=>C(t)},t)})})}function z({item:t,shape:n,color:r,selected:a,dimmed:o,editable:s,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=o?.35:a?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=e=>{let r=e.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=n.points.map(e=>({x:e.x+i,y:e.y+a}));w({itemId:t.id,points:o}),C(t.id,M(o))},V=!c&&g.length>_,H=!c&&(b===void 0||g.length<b);return e(d,{onClick:e=>{e.cancelBubble=!0,l||S(t.id)},children:[e(d,{draggable:s,dragBoundFunc:s?z:void 0,onDragStart:s?()=>T(t.id):void 0,onDragEnd:s?B:void 0,onMouseEnter:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=l?`crosshair`:`default`)},children:[c?i(m,{points:k,stroke:r,strokeWidth:a?3:2,fill:r,pointerLength:10,pointerWidth:8,opacity:A}):i(u,{points:k,closed:!0,fill:r+(a?y:v),stroke:r,strokeWidth:a?2.5:1.5,opacity:A}),t.label&&g.length>0?(()=>{let e=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),n=Math.max(40,t.label.length*11*.62);return i(f,{x:e.x-n/2,y:e.y-7,width:n,align:`center`,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1})})():null]}),s&&!x&&g.map((e,a)=>{let o=E(e,p.w,p.h);return i(h,{x:o.x,y:o.y,radius:5,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,onDragMove:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h);w(e=>{let i=e&&e.itemId===t.id?e.points:n.points;return{itemId:t.id,points:i.map((e,t)=>t===a?r:e)}})},onDragEnd:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h),i=n.points.map((e,t)=>t===a?r:e);w({itemId:t.id,points:i}),C(t.id,M(i))},onContextMenu:e=>{e.evt.preventDefault(),e.cancelBubble=!0,V&&C(t.id,M(n.points.filter((e,t)=>t!==a)))}},`pt-${a}`)}),s&&!x&&H&&g.length>=2&&g.map((e,a)=>{let o=g[(a+1)%g.length],s=E({x:(e.x+o.x)/2,y:(e.y+o.y)/2},p.w,p.h);return i(h,{x:s.x,y:s.y,radius:4,fill:`#ffffff`,stroke:r,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:e=>{e.cancelBubble=!0,C(t.id,M(j(n.points,a)))}},`mid-${a}`)})]})}var B=n(P);export{B as MaskShapeCanvas};
1
+ import{C as e,J as t,P as n,R as r,S as i,V as a,Y as o,et as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{pa as c}from"./player-overlays-g9d3qYrr.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-BjdR__nc.js";s();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:n,selectedId:s,onSelect:f,onShapeChange:p,onDrawComplete:m,drawingKind:v,supportedShapes:y,transparent:j=!1,backdrop:P,polygonVertices:F,grid:I}){let B=c(),V=t(null),[H,ee]=o({w:800,h:450}),[U,W]=o([]),[G,K]=o(null),[te,ne]=o(null),[q,J]=o(null),Y=v!==null&&y.includes(v);a(()=>{if(!q)return;let e=n.find(e=>e.id===q.itemId);if(!e||!N(e.shape)){J(null);return}M(e.shape.points,q.points)&&J(null)},[n,q]),a(()=>{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]),a(()=>{!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=t(null),Q=t(null);a(()=>()=>{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=t(!1),se=t(!0),ce=t(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(i(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(i(u,{points:[0,t,H.w,t],stroke:`#ffffff`,strokeWidth:.5,opacity:.08},`gh-${e}`))}}return e(`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?i(`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,e(l,{width:H.w,height:H.h,onClick:re,onDblClick:ie,onMouseMove:ae,children:[e(g,{listening:!1,children:[i(u,{points:[0,0,H.w,0,H.w,H.h,0,H.h,0,0],stroke:`transparent`,strokeWidth:0}),$]}),i(g,{children:n.map(e=>{let t=e.id===s,n=e.enabled===!1,r=A(e),a=t&&!Y&&!n;if(e.shape.kind===`rect`)return i(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 i(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 i(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)})}),i(g,{listening:!1,children:Y&&U.length>0&&e(d,{children:[v===`polygon`&&U.length>=2&&i(u,{points:O(U,H.w,H.h),stroke:b,strokeWidth:1.5,dash:[6,3],opacity:.8}),v===`line`&&U.length===1&&G&&i(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&&i(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 i(h,{x:n.x,y:n.y,radius:r?7:4,fill:r?b:`#ffffff`,stroke:b,strokeWidth:1.5,opacity:.9},t)})]})})]}),Y?i(`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:t,shape:n,color:r,selected:s,dimmed:c,editable:l,isDrawing:u,size:m,onSelect:g,onShapeChange:_}){let[b,x]=o(null),S={x:n.x,y:n.y,width:n.width,height:n.height};a(()=>{b&&I(S,b)&&x(null)},[n.x,n.y,n.width,n.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:s?1:.85,A=e=>{x(e),_(t.id,{kind:`rect`,x:e.x,y:e.y,width:e.width,height:e.height})};return i(d,{onClick:e=>{e.cancelBubble=!0,u||g(t.id)},children:e(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:[i(p,{x:w,y:T,width:E,height:D,fill:r+(s?y:v),stroke:r,strokeWidth:s?2.5:1.5,opacity:O}),t.label?i(f,{x:w,y:T-16,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1}):null,l?i(h,{x:w+E,y:T+D,radius:6,fill:r,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:a,size:o,onSelect:s,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:f}){let{gridWidth:m,gridHeight:h,cells:g}=t,_=o.w/m,v=o.h/h,b=m*h,x=r?.3:1,S=n=>{if(!a){s(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||!a||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 i(d,{opacity:x,onMouseUp:w,onMouseLeave:w,children:Array.from({length:b},(e,t)=>{let r=t%m,a=Math.floor(t/m),o=g[t]===!0;return i(p,{x:r*_,y:a*v,width:_,height:v,fill:o?n+y:`#ffffff10`,stroke:o?n:`#ffffff40`,strokeWidth:.5,onMouseDown:e=>{e.cancelBubble=!0,S(t)},onMouseEnter:()=>C(t)},t)})})}function z({item:t,shape:n,color:r,selected:a,dimmed:o,editable:s,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=o?.35:a?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=e=>{let r=e.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=n.points.map(e=>({x:e.x+i,y:e.y+a}));w({itemId:t.id,points:o}),C(t.id,M(o))},V=!c&&g.length>_,H=!c&&(b===void 0||g.length<b);return e(d,{onClick:e=>{e.cancelBubble=!0,l||S(t.id)},children:[e(d,{draggable:s,dragBoundFunc:s?z:void 0,onDragStart:s?()=>T(t.id):void 0,onDragEnd:s?B:void 0,onMouseEnter:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=`move`)},onMouseLeave:e=>{if(!s)return;let t=e.target.getStage();t&&(t.container().style.cursor=l?`crosshair`:`default`)},children:[c?i(m,{points:k,stroke:r,strokeWidth:a?3:2,fill:r,pointerLength:10,pointerWidth:8,opacity:A}):i(u,{points:k,closed:!0,fill:r+(a?y:v),stroke:r,strokeWidth:a?2.5:1.5,opacity:A}),t.label&&g.length>0?(()=>{let e=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),n=Math.max(40,t.label.length*11*.62);return i(f,{x:e.x-n/2,y:e.y-7,width:n,align:`center`,text:t.label,fontSize:12,fill:r,stroke:`#000000`,strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:`bold`,listening:!1})})():null]}),s&&!x&&g.map((e,a)=>{let o=E(e,p.w,p.h);return i(h,{x:o.x,y:o.y,radius:5,fill:r,stroke:`#ffffff`,strokeWidth:1.5,draggable:!0,onDragMove:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h);w(e=>{let i=e&&e.itemId===t.id?e.points:n.points;return{itemId:t.id,points:i.map((e,t)=>t===a?r:e)}})},onDragEnd:e=>{let r=D({x:e.target.x(),y:e.target.y()},p.w,p.h),i=n.points.map((e,t)=>t===a?r:e);w({itemId:t.id,points:i}),C(t.id,M(i))},onContextMenu:e=>{e.evt.preventDefault(),e.cancelBubble=!0,V&&C(t.id,M(n.points.filter((e,t)=>t!==a)))}},`pt-${a}`)}),s&&!x&&H&&g.length>=2&&g.map((e,a)=>{let o=g[(a+1)%g.length],s=E({x:(e.x+o.x)/2,y:(e.y+o.y)/2},p.w,p.h);return i(h,{x:s.x,y:s.y,radius:4,fill:`#ffffff`,stroke:r,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:e=>{e.cancelBubble=!0,C(t.id,M(j(n.points,a)))}},`mid-${a}`)})]})}var B=n(P);export{B as MaskShapeCanvas};
@@ -1 +1 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{K as te,Mr as c,U as l,X as u,dt as ne,n as re,pa as d,ua as f,z as p}from"./player-overlays-CzZYPO2s.js";import{MaskShapeCanvas as m}from"./MaskShapeCanvas-Bc_okYTu.js";s();var ie=110,h=`motion-zones`,g=0,_=[1,2,3],v=1,y=`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`,b=`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 x(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 S(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 C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:s}){let w=d(),D=te(ne().trpcClient,s),[O,k]=o(null),[A,j]=o(!1),[M,N]=o(null),[P,F]=o(null),[I,L]=o(v),[R,z]=o(!1),[B,V]=o(!1),H=t(!1);a(()=>{if(!D)return;let e=!1;return H.current=!1,k(null),j(!1),N(null),F(null),L(v),V(!1),(async()=>{try{let t=await D.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(k(t),H.current)return;let n=await D.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);H.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=x(r?r.shape.cells:[],t.grid.width,t.grid.height);F(i),N(T(i,t.grid.width,t.grid.height,v))}catch(t){if(e)return;l(t)?j(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[D]);let U=O?O.grid.width:0,W=O?O.grid.height:0,G=C(U,I),K=C(W,I),q=n(()=>M&&O?E(M,U,W,I):null,[M,O,U,W,I]),J=n(()=>q!==null&&P!==null&&!S(q,P),[q,P]),ae=n(()=>q?q.reduce((e,t)=>t?e+1:e,0):0,[q]),oe=U*W,Y=G*K,X=r(e=>{Y>0&&N(Array.from({length:Y},()=>e))},[Y]),se=r(()=>{N(e=>e&&e.map(e=>!e))},[]),Z=r(()=>{P&&O&&N(T(P,U,W,I))},[P,O,U,W,I]),ce=r(e=>{e===I||!O||N(t=>{if(!t)return L(e),t;let n=T(E(t,U,W,I),U,W,e);return L(e),n})},[I,O,U,W]),Q=n(()=>O&&M?[{id:g,shape:{kind:`grid`,gridWidth:G,gridHeight:K,cells:[...M]}}]:[],[O,M,G,K]),$=r((e,t)=>{t.kind===`grid`&&N(t.cells)},[]),le=r(async()=>{if(!(!D||!M||!O)){z(!0);try{let e=E(M,O.grid.width,O.grid.height,I),t={kind:`grid`,gridWidth:O.grid.width,gridHeight:O.grid.height,cells:e};await D.motionZones?.setZone({patch:{regions:[{id:g,enabled:!0,shape:t}]}});let n=await D.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],O.grid.width,O.grid.height);F(t),N(T(t,O.grid.width,O.grid.height,I))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{z(!1)}}},[D,M,O,I]);re(n(()=>B&&!A&&O&&M?{id:h,order:ie,node:i(m,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:G,height:K},selectedId:g,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[B,A,O,M,Q,$,G,K]));let ue=!A&&O!==null&&M!==null;return D?i(u,{title:w(`uiLibrary.motionZones.title`,`Motion Zones`),icon:i(c,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:i(`div`,{className:`flex flex-col gap-3`,children:A?i(`p`,{className:`${p} leading-relaxed`,children:w(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ue?e(ee,{children:[i(`p`,{className:`${p} leading-relaxed`,children:i(f,{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:[i(`strong`,{className:`text-foreground`},`e`),i(`strong`,{className:`text-foreground`},`s`),i(`strong`,{className:`text-foreground`},`c`)],values:{width:O.grid.width,height:O.grid.height}})}),e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`button`,{type:`button`,onClick:()=>V(e=>!e),disabled:R,"aria-pressed":B,className:B?b:y,children:B?w(`uiLibrary.motionZones.doneEditing`,`Done editing`):w(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),i(`button`,{type:`button`,onClick:()=>X(!0),disabled:R,className:y,children:w(`uiLibrary.motionZones.allOn`,`All on`)}),i(`button`,{type:`button`,onClick:()=>X(!1),disabled:R,className:y,children:w(`uiLibrary.motionZones.allOff`,`All off`)}),i(`button`,{type:`button`,onClick:se,disabled:R,className:y,children:w(`uiLibrary.motionZones.invert`,`Invert`)}),e(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":w(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[i(`span`,{className:`${p} mr-0.5`,children:w(`uiLibrary.motionZones.cellSize`,`Cell size`)}),_.map(t=>e(`button`,{type:`button`,onClick:()=>ce(t),disabled:R,"aria-pressed":I===t,title:t===1?w(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:U,height:W}):w(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:C(U,t),height:C(W,t),factor:t}),className:I===t?b:y,children:[`×`,t]},t))]}),e(`span`,{className:`${p} ml-1 tabular-nums`,children:[w(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:ae,total:oe,width:O.grid.width,height:O.grid.height}),I===1?``:w(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:G,height:K})]}),i(`span`,{className:`flex-1`}),i(`button`,{type:`button`,onClick:Z,disabled:R||!J,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:w(`uiLibrary.motionZones.revert`,`Revert`)}),i(`button`,{type:`button`,onClick:()=>void le(),disabled:R||!J,className:b,children:R?w(`uiLibrary.motionZones.saving`,`Saving…`):w(`uiLibrary.motionZones.save`,`Save`)})]})]}):i(`p`,{className:`${p} leading-relaxed`,children:w(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{D as MotionZonesSettings};
1
+ import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{K as te,Mr as c,U as l,X as u,dt as ne,n as re,pa as d,ua as f,z as p}from"./player-overlays-g9d3qYrr.js";import{MaskShapeCanvas as m}from"./MaskShapeCanvas-CFljj6Sk.js";s();var ie=110,h=`motion-zones`,g=0,_=[1,2,3],v=1,y=`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`,b=`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 x(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 S(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 C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:s}){let w=d(),D=te(ne().trpcClient,s),[O,k]=o(null),[A,j]=o(!1),[M,N]=o(null),[P,F]=o(null),[I,L]=o(v),[R,z]=o(!1),[B,V]=o(!1),H=t(!1);a(()=>{if(!D)return;let e=!1;return H.current=!1,k(null),j(!1),N(null),F(null),L(v),V(!1),(async()=>{try{let t=await D.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(k(t),H.current)return;let n=await D.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);H.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=x(r?r.shape.cells:[],t.grid.width,t.grid.height);F(i),N(T(i,t.grid.width,t.grid.height,v))}catch(t){if(e)return;l(t)?j(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[D]);let U=O?O.grid.width:0,W=O?O.grid.height:0,G=C(U,I),K=C(W,I),q=n(()=>M&&O?E(M,U,W,I):null,[M,O,U,W,I]),J=n(()=>q!==null&&P!==null&&!S(q,P),[q,P]),ae=n(()=>q?q.reduce((e,t)=>t?e+1:e,0):0,[q]),oe=U*W,Y=G*K,X=r(e=>{Y>0&&N(Array.from({length:Y},()=>e))},[Y]),se=r(()=>{N(e=>e&&e.map(e=>!e))},[]),Z=r(()=>{P&&O&&N(T(P,U,W,I))},[P,O,U,W,I]),ce=r(e=>{e===I||!O||N(t=>{if(!t)return L(e),t;let n=T(E(t,U,W,I),U,W,e);return L(e),n})},[I,O,U,W]),Q=n(()=>O&&M?[{id:g,shape:{kind:`grid`,gridWidth:G,gridHeight:K,cells:[...M]}}]:[],[O,M,G,K]),$=r((e,t)=>{t.kind===`grid`&&N(t.cells)},[]),le=r(async()=>{if(!(!D||!M||!O)){z(!0);try{let e=E(M,O.grid.width,O.grid.height,I),t={kind:`grid`,gridWidth:O.grid.width,gridHeight:O.grid.height,cells:e};await D.motionZones?.setZone({patch:{regions:[{id:g,enabled:!0,shape:t}]}});let n=await D.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],O.grid.width,O.grid.height);F(t),N(T(t,O.grid.width,O.grid.height,I))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{z(!1)}}},[D,M,O,I]);re(n(()=>B&&!A&&O&&M?{id:h,order:ie,node:i(m,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:G,height:K},selectedId:g,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[B,A,O,M,Q,$,G,K]));let ue=!A&&O!==null&&M!==null;return D?i(u,{title:w(`uiLibrary.motionZones.title`,`Motion Zones`),icon:i(c,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:i(`div`,{className:`flex flex-col gap-3`,children:A?i(`p`,{className:`${p} leading-relaxed`,children:w(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ue?e(ee,{children:[i(`p`,{className:`${p} leading-relaxed`,children:i(f,{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:[i(`strong`,{className:`text-foreground`},`e`),i(`strong`,{className:`text-foreground`},`s`),i(`strong`,{className:`text-foreground`},`c`)],values:{width:O.grid.width,height:O.grid.height}})}),e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`button`,{type:`button`,onClick:()=>V(e=>!e),disabled:R,"aria-pressed":B,className:B?b:y,children:B?w(`uiLibrary.motionZones.doneEditing`,`Done editing`):w(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),i(`button`,{type:`button`,onClick:()=>X(!0),disabled:R,className:y,children:w(`uiLibrary.motionZones.allOn`,`All on`)}),i(`button`,{type:`button`,onClick:()=>X(!1),disabled:R,className:y,children:w(`uiLibrary.motionZones.allOff`,`All off`)}),i(`button`,{type:`button`,onClick:se,disabled:R,className:y,children:w(`uiLibrary.motionZones.invert`,`Invert`)}),e(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":w(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[i(`span`,{className:`${p} mr-0.5`,children:w(`uiLibrary.motionZones.cellSize`,`Cell size`)}),_.map(t=>e(`button`,{type:`button`,onClick:()=>ce(t),disabled:R,"aria-pressed":I===t,title:t===1?w(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:U,height:W}):w(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:C(U,t),height:C(W,t),factor:t}),className:I===t?b:y,children:[`×`,t]},t))]}),e(`span`,{className:`${p} ml-1 tabular-nums`,children:[w(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:ae,total:oe,width:O.grid.width,height:O.grid.height}),I===1?``:w(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:G,height:K})]}),i(`span`,{className:`flex-1`}),i(`button`,{type:`button`,onClick:Z,disabled:R||!J,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:w(`uiLibrary.motionZones.revert`,`Revert`)}),i(`button`,{type:`button`,onClick:()=>void le(),disabled:R||!J,className:b,children:R?w(`uiLibrary.motionZones.saving`,`Saving…`):w(`uiLibrary.motionZones.save`,`Save`)})]})]}):i(`p`,{className:`${p} leading-relaxed`,children:w(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{D 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{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ht as f,Q as p,Vn as m,Wr as h,Zi as g,an as _,bi as v,br as y,dt as b,fr as x,hr as S,lr as C,pa as w,pn as T,ri as E,st as D,xi as O,zt as k}from"./player-overlays-CzZYPO2s.js";import{Jr as A,qr as j}from"./client-BRyxs6lT.js";import{s as M}from"./video-O02NyJP7.js";import{t as N}from"./key-round-EDiKxWDb.js";import{t as ee}from"./monitor-smartphone-GrRvroYr.js";import{t as te}from"./unlink-Bdb8-xwF.js";import{Bd as P,Et as ne,Ks as re,Wr as F,Ws as I,Yr as L,dd as ie,lr as ae,mn as oe,ur as se}from"./src-DytYtgEw.js";import{t as ce}from"./i18n-CNMsurg3.js";import{t as R}from"./useTranslation-BJr-n0es.js";import"./mount-D0GfTZgv.js";import{_ as le,b as z,hr as B,pr as V,rr as H,v as U,y as W,yr as ue}from"./index-B6a27fav.js";import{t as de}from"./AdminSectionedPage-DhFW0QuY.js";import{t as fe}from"./AdminPage-CoK_jJGS.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-CPeF55_J.js";l();var be=`${j}/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}=R(),t=re(Y),r=I(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(k,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(L,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(Oe,{candidates:Ce(t.data.endpoints),preferredOrigin:r})]})]})}function Oe({candidates:e,preferredOrigin:t}){let{t:r}=R(),[o,c]=s(null),l=we(e,o,t),u=i(()=>l?Te(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(ae,{value:u,size:Ee,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(ie,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(oe,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[a(k,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function ke(e){return new Date(e).toLocaleDateString()}function Ae(){let{t:e}=R(),t=D(),i=P.useUtils(),c=P.auth.listLinkableProviders.useQuery(),l=P.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,m]=s(()=>z(window.location.search)),h=r(null),g=G(`Linking a sign-in account`),_=r(null);o(()=>()=>_.current?.(),[]);let[y,b]=s(null);o(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=P.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=h.current;if(h.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{b(null),m(z(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};_.current?.(),_.current=U(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{_.current?.(),_.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=p(W(e))},onError:e=>{h.current?.close(),h.current=null,b(null),d(e.message)}}),w=P.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),T=c.data??[],E=l.data??[],k=y!==null&&E.some(e=>e.provider===y);if(o(()=>{!k||y===null||(b(null),m({kind:`linked`,provider:y}))},[k,y]),T.length===0&&E.length===0)return null;let A=new Set(E.map(e=>e.provider)),j=e=>T.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(d(null),w.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[g.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(S,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[a(v,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(O,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),E.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:E.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:ke(t.linkedAt)})})]}),n(`button`,{onClick:()=>void M(t,r),disabled:w.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a(te,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>!A.has(e.provider)).map(t=>n(`button`,{onClick:()=>{d(null),m(null),g.requestProof().then(e=>{e!==null&&(h.current=le(null),b(h.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?a(x,{className:`h-3 w-3 animate-spin`}):a(S,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function je({value:r,size:i=192}){let{t:c}=R(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Me(){let{t:e}=R(),t=b(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[f,p]=s(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=o.length>0&&l.length>0&&o!==l,g=o.length>0&&o.length<8,_=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(N,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(h||g)&&a(`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&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?a(v,{className:`h-3 w-3`}):a(O,{className:`h-3 w-3`}),f.msg]}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{p(null),m.mutate({currentPassword:r,newPassword:o})},disabled:!_||m.isPending,children:[m.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(C,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(`input`,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Ne({username:e}){let{t}=R(),r=b(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),f=l.data,[p,m]=s(null),[h,g]=s(``),[y,S]=s(null),[C,w]=s(!1),T=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),g(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),D=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{m(null),g(``),S(null),l.refetch()},onError:e=>S(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:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,f?.enabled,p]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{S(null),T.mutate()},disabled:T.isPending,children:[T.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&p&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(V,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(je,{value:p.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),n(L,{variant:`ghost`,onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>w(!0))},children:[C?a(v,{className:`h-3 w-3 text-success`}):a(E,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:h,onChange:e=>g(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),y]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(L,{variant:`outline`,onClick:()=>{m(null),S(null),g(``)},children:t(`common.cancel`,`Cancel`)}),n(L,{onClick:()=>{S(null),D.mutate({code:h})},disabled:D.isPending||h.length!==6,children:[D.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(v,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&f&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(v,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`})})]})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),y]}),a(`div`,{className:`flex justify-end`,children:n(L,{variant:`danger`,onClick:()=>{S(null),A.mutate()},disabled:A.isPending,children:[A.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return F(`auth-webauthn/passkey-enrollment`)?a(se,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Fe(){let{t:e}=R(),{logout:t}=H(),r=D(),i=P.useUtils(),o=P.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=P.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=P.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ye(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},p=async()=>{await r({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>void p(),disabled:d.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(M,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Ie=`You`;function Le(){let{t:e}=R(),t=D(),n=P.useUtils(),r=P.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=P.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ve(e,Ie)),[r.data]),d=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:g,isAvailable:he,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(pe,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:_,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:()=>c(null),children:a(me,{rows:u,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},Re=[`linked`,`linkError`],ze={view:{icon:h,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:m,cls:`bg-primary/15 text-primary`},delete:{icon:f,cls:`bg-danger/15 text-danger`}};function Be(){let{t:e}=R(),{user:t,logout:r}=H(),[i]=ue(),o=e(`system.myAccess`,`My access`);if(!t)return a(fe,{icon:T,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(Re.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(B,{to:`?${e.toString()}`,replace:!0})}return a(de,{icon:T,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(L,{variant:`outline`,onClick:r,children:[a(M,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(Ve,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Me,{}),a(Ne,{username:t.username}),a(Pe,{}),a(Ae,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Fe,{}),a(Le,{}),a(De,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ge,{ownOnly:!0})}]})}function Ve({user:e}){let{t}=R(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(V,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[a(y,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(He,{scopes:i})]})}function He({scopes:e}){let{t}=R(),r=w();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ne(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=ze[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Be as MyAccessPage};
2
+ import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ht as f,Q as p,Vn as m,Wr as h,Zi as g,an as _,bi as v,br as y,dt as b,fr as x,hr as S,lr as C,pa as w,pn as T,ri as E,st as D,xi as O,zt as k}from"./player-overlays-g9d3qYrr.js";import{Jr as A,qr as j}from"./client-CwJGlpR9.js";import{s as M}from"./video-BFmrpvc7.js";import{t as N}from"./key-round-Bfq08tmQ.js";import{t as ee}from"./monitor-smartphone-CVLLvvgV.js";import{t as te}from"./unlink-C-2ouMww.js";import{Bd as P,Et as ne,Ks as re,Wr as F,Ws as I,Yr as L,dd as ie,lr as ae,mn as oe,ur as se}from"./src-DwNoxp86.js";import{t as ce}from"./i18n-9jE1YKjd.js";import{t as R}from"./useTranslation-BJr-n0es.js";import"./mount-BTGIE40h.js";import{_ as le,b as z,hr as B,pr as V,rr as H,v as U,y as W,yr as ue}from"./index-DG07MiZm.js";import{t as de}from"./AdminSectionedPage-BZCKp3Ch.js";import{t as fe}from"./AdminPage-DlYf-2bp.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-Bd4yBLfB.js";l();var be=`${j}/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}=R(),t=re(Y),r=I(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(k,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(L,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(Oe,{candidates:Ce(t.data.endpoints),preferredOrigin:r})]})]})}function Oe({candidates:e,preferredOrigin:t}){let{t:r}=R(),[o,c]=s(null),l=we(e,o,t),u=i(()=>l?Te(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(ae,{value:u,size:Ee,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(ie,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(oe,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[a(k,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function ke(e){return new Date(e).toLocaleDateString()}function Ae(){let{t:e}=R(),t=D(),i=P.useUtils(),c=P.auth.listLinkableProviders.useQuery(),l=P.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,m]=s(()=>z(window.location.search)),h=r(null),g=G(`Linking a sign-in account`),_=r(null);o(()=>()=>_.current?.(),[]);let[y,b]=s(null);o(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=P.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=h.current;if(h.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{b(null),m(z(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};_.current?.(),_.current=U(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{_.current?.(),_.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=p(W(e))},onError:e=>{h.current?.close(),h.current=null,b(null),d(e.message)}}),w=P.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),T=c.data??[],E=l.data??[],k=y!==null&&E.some(e=>e.provider===y);if(o(()=>{!k||y===null||(b(null),m({kind:`linked`,provider:y}))},[k,y]),T.length===0&&E.length===0)return null;let A=new Set(E.map(e=>e.provider)),j=e=>T.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(d(null),w.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[g.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(S,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[a(v,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(O,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),E.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:E.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:ke(t.linkedAt)})})]}),n(`button`,{onClick:()=>void M(t,r),disabled:w.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a(te,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>!A.has(e.provider)).map(t=>n(`button`,{onClick:()=>{d(null),m(null),g.requestProof().then(e=>{e!==null&&(h.current=le(null),b(h.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?a(x,{className:`h-3 w-3 animate-spin`}):a(S,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function je({value:r,size:i=192}){let{t:c}=R(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Me(){let{t:e}=R(),t=b(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[f,p]=s(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=o.length>0&&l.length>0&&o!==l,g=o.length>0&&o.length<8,_=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(N,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(h||g)&&a(`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&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?a(v,{className:`h-3 w-3`}):a(O,{className:`h-3 w-3`}),f.msg]}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{p(null),m.mutate({currentPassword:r,newPassword:o})},disabled:!_||m.isPending,children:[m.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(C,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(`input`,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Ne({username:e}){let{t}=R(),r=b(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),f=l.data,[p,m]=s(null),[h,g]=s(``),[y,S]=s(null),[C,w]=s(!1),T=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),g(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),D=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{m(null),g(``),S(null),l.refetch()},onError:e=>S(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:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,f?.enabled,p]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{S(null),T.mutate()},disabled:T.isPending,children:[T.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&p&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(V,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(je,{value:p.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),n(L,{variant:`ghost`,onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>w(!0))},children:[C?a(v,{className:`h-3 w-3 text-success`}):a(E,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:h,onChange:e=>g(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),y]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(L,{variant:`outline`,onClick:()=>{m(null),S(null),g(``)},children:t(`common.cancel`,`Cancel`)}),n(L,{onClick:()=>{S(null),D.mutate({code:h})},disabled:D.isPending||h.length!==6,children:[D.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(v,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&f&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(v,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`})})]})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),y]}),a(`div`,{className:`flex justify-end`,children:n(L,{variant:`danger`,onClick:()=>{S(null),A.mutate()},disabled:A.isPending,children:[A.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return F(`auth-webauthn/passkey-enrollment`)?a(se,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Fe(){let{t:e}=R(),{logout:t}=H(),r=D(),i=P.useUtils(),o=P.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=P.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=P.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ye(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},p=async()=>{await r({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>void p(),disabled:d.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(M,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Ie=`You`;function Le(){let{t:e}=R(),t=D(),n=P.useUtils(),r=P.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=P.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ve(e,Ie)),[r.data]),d=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:g,isAvailable:he,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(pe,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:_,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:()=>c(null),children:a(me,{rows:u,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},Re=[`linked`,`linkError`],ze={view:{icon:h,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:m,cls:`bg-primary/15 text-primary`},delete:{icon:f,cls:`bg-danger/15 text-danger`}};function Be(){let{t:e}=R(),{user:t,logout:r}=H(),[i]=ue(),o=e(`system.myAccess`,`My access`);if(!t)return a(fe,{icon:T,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(Re.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(B,{to:`?${e.toString()}`,replace:!0})}return a(de,{icon:T,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(L,{variant:`outline`,onClick:r,children:[a(M,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(Ve,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Me,{}),a(Ne,{username:t.username}),a(Pe,{}),a(Ae,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Fe,{}),a(Le,{}),a(De,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ge,{ownOnly:!0})}]})}function Ve({user:e}){let{t}=R(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(V,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[a(y,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(He,{scopes:i})]})}function He({scopes:e}){let{t}=R(),r=w();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ne(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=ze[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Be as MyAccessPage};