@camstack/addon-admin-ui 1.2.702 → 1.2.703

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 (108) hide show
  1. package/CHANGELOG.md +8 -2
  2. package/dist/assets/{AccessSection-CNgvvC6Q.js → AccessSection-BGohJFsQ.js} +1 -1
  3. package/dist/assets/Addons-BDlFntTI.js +5 -0
  4. package/dist/assets/{AdminPage-BkxgjFWW.js → AdminPage-fCxxHmc-.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-bGVBepbw.js → AdminSectionedPage-DDqDbMM3.js} +1 -1
  6. package/dist/assets/AiProfiles-BFi1Kn6N.js +3 -0
  7. package/dist/assets/Archive-ChqpFwH8.js +1 -0
  8. package/dist/assets/{BootstrapSettingsForm-jBRoUiPn.js → BootstrapSettingsForm-BLWj6csX.js} +1 -1
  9. package/dist/assets/{Build-BoiB-nPA.js → Build-DfHu8hDx.js} +4 -4
  10. package/dist/assets/{Calendars-BBTnm6OG.js → Calendars-Cxw9P8Uq.js} +1 -1
  11. package/dist/assets/Cluster-BwIvlnpz.js +1 -0
  12. package/dist/assets/{CompositionBlockEditor-BloGManS.js → CompositionBlockEditor-DyGQ4aIz.js} +2 -2
  13. package/dist/assets/{CompositionEditorPage-C5pNxu2M.js → CompositionEditorPage-DRISSQzb.js} +1 -1
  14. package/dist/assets/Data-B1NgedRI.js +2 -0
  15. package/dist/assets/DeviceDetail-BzGdZ7Q_.js +1 -0
  16. package/dist/assets/{Devices-BJRvDHiT.js → Devices-CdmWPr7S.js} +1 -1
  17. package/dist/assets/EmbedDevicePage-CfSj9caC.js +1 -0
  18. package/dist/assets/{EmbedPlayerPage-BsxSpEcY.js → EmbedPlayerPage-DEP8gdti.js} +1 -1
  19. package/dist/assets/History-Bg9tQAqJ.js +1 -0
  20. package/dist/assets/Identity-Oyg78Wgg.js +1 -0
  21. package/dist/assets/InstancesTable-CItURWVx.js +1 -0
  22. package/dist/assets/IntegrationDetail-B05HfycS.js +1 -0
  23. package/dist/assets/{Integrations-BUOpFqfh.js → Integrations-Bpw7S0et.js} +2 -2
  24. package/dist/assets/{Integrations-Dpb2V2yu.js → Integrations-wpQtKhSO.js} +1 -1
  25. package/dist/assets/Library-afeuqgc6.js +1 -0
  26. package/dist/assets/Locations-DPd9tJpI.js +3 -0
  27. package/dist/assets/Logs-DSnFwEPX.js +1 -0
  28. package/dist/assets/{MaskShapeCanvas-D57fCIme.js → MaskShapeCanvas-DATKwWoi.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-w1kFM_O4.js → MotionZonesSettings-BrUyigty.js} +1 -1
  30. package/dist/assets/{MyAccess-D87gqxHt.js → MyAccess-DTWeghN4.js} +1 -1
  31. package/dist/assets/{Network-L7e5c9RP.js → Network-CzBJb8Ro.js} +1 -1
  32. package/dist/assets/{NewExportModal-CHwUJ26P.js → NewExportModal-DC6qeg0K.js} +1 -1
  33. package/dist/assets/NodeAddonsSettingsPanel-DwR6THxT.js +1 -0
  34. package/dist/assets/Notifications-8WkrgioY.js +1 -0
  35. package/dist/assets/{PanelContent-PhbemYUY.js → PanelContent-Cqel4gq_.js} +2 -2
  36. package/dist/assets/Pipeline-Dlg9wnRY.js +1 -0
  37. package/dist/assets/{PrivacyMaskSettings-BS29zGkX.js → PrivacyMaskSettings-jcKOGH_r.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-CosxkmPM.js → SceneMonitorEditor-HfoxsYJf.js} +1 -1
  39. package/dist/assets/SessionsList-CIOmkBhu.js +2 -0
  40. package/dist/assets/{Showroom-0iJ0CCe5.js → Showroom-BgfY_eRn.js} +1 -1
  41. package/dist/assets/StorageLocationsTable-CbwL3VQY.js +1 -0
  42. package/dist/assets/System-DXC-3shW.js +2 -0
  43. package/dist/assets/{TemplateEditorDialog-8D78AUfO.js → TemplateEditorDialog-DXIGdBCR.js} +1 -1
  44. package/dist/assets/{Terminal-Cvw2rPrb.js → Terminal-Di7l31qa.js} +5 -5
  45. package/dist/assets/{TrainingProviders-DcThiLnE.js → TrainingProviders-aXqehRmF.js} +1 -1
  46. package/dist/assets/{Viewer-BUfnqb0c.js → Viewer-C71XpHjW.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CNNET8uz.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DRUBvLQE.js} +1 -1
  48. package/dist/assets/{action-draft-BTVZLATm.js → action-draft-qcGhRMv4.js} +1 -1
  49. package/dist/assets/{ai-page.helpers-qxf7BP-v.js → ai-page.helpers-CEBa_im9.js} +1 -1
  50. package/dist/assets/{assignment-candidates-d-6NU8po.js → assignment-candidates-DdSU1Zo6.js} +1 -1
  51. package/dist/assets/{authed-media-Bqh0pB9D.js → authed-media-BZy-JJ_o.js} +1 -1
  52. package/dist/assets/{board-model-CPA2IZpg.js → board-model-DIWwdMST.js} +1 -1
  53. package/dist/assets/{camera-block-model-CJ0e2m0o.js → camera-block-model-Bq_R4oG5.js} +1 -1
  54. package/dist/assets/{client-Cng2SeYA.js → client-DLuByuRa.js} +1 -1
  55. package/dist/assets/{command-vocab-BzBhzE7i.js → command-vocab-CvGdlD2o.js} +1 -1
  56. package/dist/assets/{device-integration-icon-VMxiVsqd.js → device-integration-icon-Dd9uw4UF.js} +1 -1
  57. package/dist/assets/device-picker-model-PIGdnO_G.js +1 -0
  58. package/dist/assets/{dist-D7Gew3v3.js → dist-CDyYOITf.js} +1 -1
  59. package/dist/assets/{dist-CxrdebAP.js → dist-CFXBYJXQ.js} +1 -1
  60. package/dist/assets/{format-BopmTOzZ.js → format-CrKdqqCK.js} +1 -1
  61. package/dist/assets/{hostInit-DuH1KOuD.js → hostInit-CYHcdoYA.js} +1 -1
  62. package/dist/assets/i18n-CLov6T90.js +1 -0
  63. package/dist/assets/{icons-bi-mcO5N.js → icons-BLtyw4fH.js} +1 -1
  64. package/dist/assets/index-CFJEFXwr.js +6 -0
  65. package/dist/assets/{linked-devices-model-Bnz1douR.js → linked-devices-model-BPZYWQoj.js} +1 -1
  66. package/dist/assets/{mf-entry-bootstrap-0-ddbe056c.js → mf-entry-bootstrap-0-129d9964.js} +2 -2
  67. package/dist/assets/mount-PIGdnO_G.js +1 -0
  68. package/dist/assets/{notification-rule-status-ai5zWyzt.js → notification-rule-status-DeN2cEgy.js} +1 -1
  69. package/dist/assets/{player-overlays-fpbPSPqT.js → player-overlays-CgADEsQt.js} +1 -1
  70. package/dist/assets/remoteEntry-Cc7yyabb.js +1 -0
  71. package/dist/assets/{src-eL0OacoB.js → src-CA2_9YJD.js} +20 -20
  72. package/dist/assets/{sso-popup-Za4GwQBP.js → sso-popup-BXELI2t0.js} +1 -1
  73. package/dist/assets/{step-inspector-model-BAgxIyNV.js → step-inspector-model-BFq40l6S.js} +1 -1
  74. package/dist/assets/{use-scenes-feed-BTNdL7JV.js → use-scenes-feed-DyQPnSjQ.js} +1 -1
  75. package/dist/assets/{useAdminDeviceRemoval-COlTnaF7.js → useAdminDeviceRemoval-CKwvXhAP.js} +1 -1
  76. package/dist/assets/useEventInvalidation-PIGdnO_G.js +1 -0
  77. package/dist/assets/{useNodeUrlSelection-DhtJZEtx.js → useNodeUrlSelection-cFOr6zMH.js} +1 -1
  78. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-R-1W8c6C.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-HQVwzuiB.js} +2 -2
  79. package/dist/index.html +8 -8
  80. package/dist/server/addon.js +10 -3
  81. package/package.json +2 -2
  82. package/dist/assets/Addons-Dtx3xcZ2.js +0 -5
  83. package/dist/assets/AiProfiles-BLj-ic5N.js +0 -3
  84. package/dist/assets/Archive-y1aPYCx8.js +0 -1
  85. package/dist/assets/Cluster-DN0Cwciw.js +0 -1
  86. package/dist/assets/Data-LT-PQ05n.js +0 -2
  87. package/dist/assets/DeviceDetail-DAvmtNN2.js +0 -1
  88. package/dist/assets/EmbedDevicePage-CyKS-rmB.js +0 -1
  89. package/dist/assets/History-BPF9alct.js +0 -1
  90. package/dist/assets/Identity-dLFVHYZR.js +0 -1
  91. package/dist/assets/InstancesTable-LVQWfz07.js +0 -1
  92. package/dist/assets/IntegrationDetail-C_vN9X7q.js +0 -1
  93. package/dist/assets/Library-D4-BDy54.js +0 -1
  94. package/dist/assets/Locations-DGZ_lrp3.js +0 -3
  95. package/dist/assets/Logs-CUV00qxb.js +0 -1
  96. package/dist/assets/NodeAddonsSettingsPanel-Kqe8X8RH.js +0 -1
  97. package/dist/assets/Notifications-CucZNxjj.js +0 -1
  98. package/dist/assets/Pipeline-9O3YfaWk.js +0 -1
  99. package/dist/assets/SessionsList-OHo3GJ72.js +0 -2
  100. package/dist/assets/StorageLocationsTable-DqTWO4k1.js +0 -1
  101. package/dist/assets/System-DZXA2QSs.js +0 -2
  102. package/dist/assets/device-detail-Cg2Zt8FL.js +0 -1
  103. package/dist/assets/device-picker-model-B-FI9413.js +0 -1
  104. package/dist/assets/i18n--GTAj4mB.js +0 -1
  105. package/dist/assets/index-DbXFHmBJ.js +0 -6
  106. package/dist/assets/mount-B-FI9413.js +0 -1
  107. package/dist/assets/remoteEntry-g0NfB_lk.js +0 -1
  108. package/dist/assets/useEventInvalidation-B-FI9413.js +0 -1
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$i as u,Bn as d,D as f,Ka as p,Nn as m,Qn as h,Rn as g,Tt as _,Vn as v,Wi as y,Xi as b,Xn as x,Yn as S,Zt as C,_r as w,aa as T,ba as E,ci as D,ct as O,ft as k,ir as A,ji as j,qn as M,sa as N,tn as ee,ur as P,yi as te,yt as F,z as I,zr as L}from"./player-overlays-fpbPSPqT.js";import{Tc as ne,bc as re,xc as ie,yc as ae}from"./client-Cng2SeYA.js";import{t as oe}from"./chevron-down-CBb-F8DT.js";import{t as se}from"./hard-drive-download-C6N6tovA.js";import{t as ce}from"./memory-stick-BQrJMbEW.js";import{t as le}from"./unlink-D3-IGpS8.js";import{Br as ue,Da as R,En as de,Gi as fe,Ir as pe,Ji as me,Jp as he,Ki as ge,Kr as _e,Qp as z,Rr as B,Ru as ve,Sp as V,Ui as ye,Wi as be,Xl as xe,Y as Se,Yi as Ce,Yp as H,Zl as we,Zs as Te,af as Ee,au as De,ca as Oe,cd as ke,cf as Ae,ct as je,di as Me,fi as Ne,if as Pe,iu as Fe,ji as Ie,jp as Le,ka as Re,kf as ze,la as Be,lf as Ve,li as He,mp as U,mr as Ue,nd as We,of as Ge,ou as Ke,pr as qe,qi as Je,qu as Ye,ru as Xe,sf as Ze,uf as Qe,ui as $e,ut as W,zr as G}from"./src-eL0OacoB.js";import{t as et}from"./i18n--GTAj4mB.js";import{t as K}from"./useTranslation-BJr-n0es.js";import{d as tt,wi as nt}from"./index-DbXFHmBJ.js";import{t as q}from"./format-size-DIxKXxtj.js";import{t as rt}from"./NodeAddonsSettingsPanel-Kqe8X8RH.js";import{n as it}from"./format-BopmTOzZ.js";import{t as at}from"./AdminPage-BkxgjFWW.js";import{_ as ot,f as st,h as ct,p as lt}from"./board-model-CPA2IZpg.js";import{n as ut,r as dt,t as ft}from"./useNodeUrlSelection-DhtJZEtx.js";s();var pt={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},mt=new Set([`paired`,`rejected`,`failed`,`expired`]);function J(e){return mt.has(e)}function ht(e){return e.replace(/\D/g,``).slice(0,6)}function gt(e){return e.length===6}function _t(e,t){let n=Math.max(0,Math.ceil((e-t)/1e3)),r=Math.floor(n/60),i=n%60;return`${r}:${String(i).padStart(2,`0`)}`}function vt(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function yt(e){return e.length<=23?e:`${e.slice(0,20)}…`}function bt({view:e,beginError:t}){if(e===null)return t===null?`sending`:`send-failed`;switch(e.state){case`paired`:return`paired`;case`rejected`:return`rejected`;case`failed`:return`failed`;case`expired`:return`expired`;case`completing`:return`completing`;case`awaiting-confirmation`:return e.hubConfirmed&&!e.agentConfirmed?`awaiting-agent`:e.agentConfirmed&&!e.hubConfirmed?`awaiting-hub`:`awaiting-both`}}function xt(e){return e===`awaiting-both`||e===`awaiting-hub`}var St={sending:`Sending the pairing offer to the agent…`,"send-failed":`The agent could not be reached`,"awaiting-both":`Waiting for both confirmations`,"awaiting-agent":`Confirmed here — waiting for the agent`,"awaiting-hub":`The agent is confirmed — now confirm here`,completing:`Issuing the node certificate…`,paired:`Paired`,rejected:`Pairing was rejected`,failed:`Pairing failed`,expired:`The pairing expired`},Ct=2e3,wt=1e3;function Tt(e){return e.message.length>0?e.message:et.t(`pairing.agentsFoundSection.requestFailed`)}function Et(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function Dt(e){let[t,n]=o(()=>Date.now());return a(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),wt);return()=>clearInterval(t)},[e]),t}function Ot({target:n,onClose:r,onSettled:s,onOpenNode:c}){let{t:u}=K(),[d,f]=o(null),[p,m]=o(null),[h,g]=o(``),[_,v]=o(null),y=t(null),b=z.agentPairing.beginPairing.useMutation(),x=z.agentPairing.confirmPairing.useMutation(),S=z.agentPairing.rejectPairing.useMutation();a(()=>{if(n===null){y.current=null,f(null),m(null),g(``),v(null);return}if(y.current!==n){if(y.current=n,n.pairingId!==void 0){f(n.pairingId);return}b.mutateAsync({host:n.host,port:n.port}).then(e=>{y.current===n&&f(e.pairingId)}).catch(e=>{y.current===n&&m(Tt(e))})}},[n]);let C=z.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&J(t)?!1:Ct}}),w=kt(x.data??S.data??null,C.data??null),T=bt({view:w,beginError:p}),E=w!==null&&J(w.state),D=t(!1);a(()=>{if(!E){D.current=!1;return}D.current||(D.current=!0,s())},[E,s]);let O=Dt(w!==null&&!E),k=()=>{d===null||!gt(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(Tt(e)),g(``)}}))};return i(ye,{open:n!==null,onOpenChange:e=>!e&&r(),children:e(fe,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(me,{children:[i(Ce,{children:u(`pairing.pairingDialog.title`,{node:n?.nodeId??``})}),i(ge,{children:n===null?``:u(`pairing.pairingDialog.eachScreenShowsACode`,`Both screens show the same six digits. Check they match, then type the code you read on the agent. Agent at {{value1}}`,{value1:vt(n.host,n.port)})})]}),e(be,{className:`space-y-4`,children:[i(At,{phase:T}),T===`send-failed`&&p!==null&&i(R,{title:u(`pairing.pairingDialog.couldNotStartThePairing`,`Could not start the pairing`),message:p}),w!==null&&!E&&i(jt,{view:w,phase:T,now:O,typed:h,onType:e=>g(ht(e)),onSubmit:k,confirmError:_,busy:x.isPending}),T===`paired`&&w!==null&&i(Mt,{nodeId:w.nodeId,onOpenNode:c,onClose:r}),E&&T!==`paired`&&w?.failure!=null&&i(R,{message:w.failure})]}),i(Je,{children:E||T===`send-failed`?i(U,{type:`button`,variant:`outline`,onClick:r,children:u(`common.close`,`Close`)}):e(l,{children:[i(U,{type:`button`,variant:`outline`,disabled:S.isPending,onClick:()=>{if(d===null){r();return}S.mutate({pairingId:d},{onSettled:r})},children:u(`pairing.pairingDialog.reject`,`Reject`)}),xt(T)&&e(U,{type:`button`,disabled:!gt(h)||x.isPending,onClick:k,children:[x.isPending&&i(L,{className:`h-4 w-4 animate-spin`}),u(`common.confirm`,`Confirm`)]})]})})]})})}function kt(e,t){if(t===null)return e;if(e===null)return t;let n=e=>(J(e.state)?10:e.state===`completing`?5:0)+ +!!e.hubConfirmed+ +!!e.agentConfirmed;return n(e)>n(t)?e:t}function At({phase:t}){let n=t===`sending`||t===`completing`,r=t===`paired`,a=t===`rejected`||t===`failed`||t===`expired`||t===`send-failed`;return e(`p`,{role:`status`,className:`flex items-center gap-2 text-sm font-medium ${r?`text-success`:a?`text-danger`:`text-foreground`}`,children:[n&&i(L,{className:`h-4 w-4 animate-spin`}),r&&i(b,{className:`h-4 w-4`}),a&&i(y,{className:`h-4 w-4`}),St[t]]})}function jt({view:t,phase:n,now:r,typed:a,onType:o,onSubmit:s,confirmError:c,busy:l}){let{t:u}=K();return e(`div`,{className:`space-y-4`,children:[e(`section`,{"aria-label":u(`pairing.pairingDialog.codeOnThisHub`,`Code on this hub`),className:`rounded-md border border-border bg-surface p-3`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:u(`pairing.pairingDialog.codeOnThisHubRead`,`Code on this hub: the agent must show the same digits`)}),i(`p`,{"data-testid":`hub-code`,className:`mt-1 font-mono text-3xl font-semibold tracking-widest text-foreground`,children:Et(t.code)}),i(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:u(`pairing.pairingDialog.onTheAgentEnterThis`,`On the agent, enter this code and the agent’s local PIN (shown on the agent’s console or log, or on its own screen).`)})]}),xt(n)?i(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),s()},children:i(W,{label:u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),description:u(`pairing.pairingDialog.typeTheSixDigitsThe`,`Type the six digits you read on the agent; do not paste. If they differ from the code above, stop and press Reject.`),...c===null?{}:{error:c},children:i(V,{value:a,onChange:e=>o(e.target.value),inputMode:`numeric`,autoComplete:`off`,spellCheck:!1,placeholder:`000000`,maxLength:6,disabled:l,"aria-label":u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),className:`font-mono tracking-widest`})})}):i(`p`,{className:`text-xs text-foreground-muted`,children:n===`awaiting-agent`?u(`pairing.pairingDialog.youConfirmedHereTheAgent`,`You confirmed here. The agent still has to enter the hub code and its PIN.`):u(`pairing.pairingDialog.working`,`Working…`)}),e(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-foreground-muted`,children:[i(`li`,{children:t.hubConfirmed?u(`pairing.pairingDialog.hubConfirmed`,`Hub: confirmed`):u(`pairing.pairingDialog.hubNotConfirmed`,`Hub: not confirmed`)}),i(`li`,{children:t.agentConfirmed?u(`pairing.pairingDialog.agentConfirmed`,`Agent: confirmed`):u(`pairing.pairingDialog.agentNotConfirmed`,`Agent: not confirmed`)}),i(`li`,{"data-testid":`countdown`,children:u(`pairing.pairingDialog.expiresIn`,{countdown:_t(t.expiresAt,r)})})]})]})}function Mt({nodeId:t,onOpenNode:n,onClose:r}){let{t:a}=K(),{nodes:o}=he(),s=o?.some(e=>e.id===t&&e.isOnline)===!0;return e(`div`,{className:`space-y-2 rounded-md border border-success/40 bg-success/10 p-3 text-sm`,children:[e(`p`,{className:`flex items-center gap-2 text-success`,children:[i(m,{className:`h-4 w-4`}),s?a(`pairing.pairingDialog.joinedAndRegisteredItsCapabilities`,`{{nodeId}} joined and registered its capabilities.`,{nodeId:t}):a(`pairing.pairingDialog.holdsItsCertificateWaitingFor`,`{{nodeId}} holds its certificate. Waiting for it to connect and register its capabilities…`,{nodeId:t})]}),i(U,{type:`button`,size:`sm`,variant:`outline`,disabled:!s,onClick:()=>{r(),n(t)},children:a(`pairing.pairingDialog.openNode`,`Open node`)})]})}var Nt={paired:`success`,pending:`warning`,unpaired:`default`};function Pt({state:t,connected:n}){let{t:r}=K();return e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(Re,{variant:Nt[t],className:`text-[10px]`,children:pt[t]}),t===`paired`&&i(`span`,{className:`text-[10px] text-foreground-muted`,children:n?r(`common.connected`):r(`pairing.agentStateBadge.notConnected`,`not connected`)})]})}s();var Y={pending:0,unpaired:1,paired:2};function Ft(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function It({onOpenNode:t}){let{t:r}=K(),a=O(),s=z.useUtils(),c=z.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[u,d]=o(null),[p,m]=o(null),[g,_]=o(!1),[v,y]=o(``),[b,x]=o(``),[C,w]=o(null),[T,E]=o(!1),D=()=>void s.agentPairing.listDiscoveredAgents.invalidate(),k=z.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{_(!1),y(``),x(``),w(null),D()},onError:e=>w(e.message)}),j=z.agentPairing.unpairAgent.useMutation({onSuccess:e=>{m({tone:`success`,message:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),D()},onError:e=>m({tone:`danger`,message:r(`pairing.agentsFoundSection.unpairFailed`,`Unpair failed: {{message}}`,{message:e.message})})}),M=n(()=>(c.data?.agents??[]).toSorted((e,t)=>Y[e.state]-Y[t.state]),[c.data]),N=async()=>{E(!0);try{await s.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),D()}finally{E(!1)}},ee=()=>{let e=Ft(b);if(e===null){w(`The port must be a whole number between 1 and 65535.`);return}w(null),k.mutate({host:v.trim(),...e===void 0?{}:{port:e}})},P=async e=>{await a({title:r(`pairing.agentsFoundSection.unpair`,`Unpair {{nodeId}}`,{nodeId:e.nodeId}),message:r(`pairing.agentsFoundSection.sCertificatesAreRevokedAt`,`{{nodeId}}'s certificates are revoked at once and it is disconnected from the mesh. It must be paired again before it can rejoin.`,{nodeId:e.nodeId}),confirmLabel:r(`pairing.agentsFoundSection.unpair2`,`Unpair`),variant:`danger`})&&(m(null),j.mutate({nodeId:e.nodeId}))},te=n(()=>[{key:`name`,header:r(`pairing.agentsFoundSection.name`,`Name`),render:e=>e.name??`—`,sortValue:e=>e.name},{key:`node`,header:r(`pairing.agentsFoundSection.node`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId}),sortValue:e=>e.nodeId},{key:`address`,header:r(`pairing.agentsFoundSection.address`,`Address`),render:e=>i(`span`,{className:`font-mono text-xs`,children:vt(e.host,e.port)}),sortValue:e=>e.host},{key:`version`,header:r(`pairing.agentsFoundSection.version`,`Version`),render:e=>e.version??`—`,sortValue:e=>e.version},{key:`state`,header:r(`pairing.agentsFoundSection.state`,`State`),render:e=>i(Pt,{state:e.state,connected:e.connected}),sortValue:e=>Y[e.state]},{key:`fingerprint`,header:r(`pairing.agentsFoundSection.certificate`,`Certificate`),render:e=>e.fingerprint===null?`—`:i(`span`,{className:`font-mono text-xs`,title:e.fingerprint,children:yt(e.fingerprint)}),sortValue:e=>e.fingerprint},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,render:e=>{let t=e.pairing;return e.state===`unpaired`?i(U,{type:`button`,size:`sm`,onClick:()=>d({nodeId:e.nodeId,host:e.host,port:e.port}),children:r(`pairing.agentsFoundSection.pair`,`Pair`)}):e.state===`paired`?i(U,{type:`button`,size:`sm`,variant:`outline`,disabled:j.isPending,onClick:()=>void P(e),children:r(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):e.state===`pending`&&t!==null?i(U,{type:`button`,size:`sm`,onClick:()=>d({nodeId:e.nodeId,host:e.host,port:e.port,pairingId:t.pairingId}),children:r(`pairing.agentsFoundSection.resume`,`Resume`)}):null}}],[j.isPending,r]);return e(pe,{headingId:`agents-found`,title:r(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:h,testId:`agents-found`,actions:e(l,{children:[e(U,{type:`button`,size:`sm`,variant:`outline`,disabled:T,onClick:()=>void N(),children:[T?i(L,{className:`h-3.5 w-3.5 animate-spin`}):i(S,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.scan`,`Scan`)]}),e(U,{type:`button`,size:`sm`,onClick:()=>_(e=>!e),children:[i(A,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.addByAddress`,`Add by address`)]})]}),children:[e(`div`,{className:`${f} space-y-3`,children:[i(`p`,{className:`text-[11px] leading-relaxed text-foreground-muted`,children:r(`pairing.agentsFoundSection.anAgentHoldsNoSecret`,`An agent holds no secret: pairing issues it a certificate after you confirm the same six digits on this page and on the agent. Discovery needs the agent on its own IP or host networking; a Docker bridge hides it — add it by address.`)}),g&&e(`form`,{"aria-label":r(`pairing.agentsFoundSection.addAgentByAddress`,`Add agent by address`),className:`flex flex-wrap items-start gap-2`,onSubmit:e=>{e.preventDefault(),v.trim().length>0&&!k.isPending&&ee()},children:[i(W,{label:r(`pairing.agentsFoundSection.address`,`Address`),description:r(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...C===null?{}:{error:C},children:i(V,{value:v,onChange:e=>y(e.target.value),placeholder:`192.0.2.20`,"aria-label":r(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),i(W,{label:r(`pairing.agentsFoundSection.port`,`Port`),description:r(`pairing.agentsFoundSection.optional`,`Optional.`),children:i(V,{value:b,onChange:e=>x(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":r(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),e(U,{type:`submit`,size:`sm`,className:`mt-5`,disabled:v.trim().length===0||k.isPending,children:[k.isPending&&i(L,{className:`h-3.5 w-3.5 animate-spin`}),r(`common.add`,`Add`)]})]}),p!==null&&i(`p`,{role:`status`,className:`rounded border px-3 py-2 text-xs ${p.tone===`success`?`border-success/30 text-foreground`:`border-danger/40 text-danger`}`,children:p.message}),c.isError?i(R,{title:r(`pairing.agentsFoundSection.couldNotListAgents`,`Could not list agents`),message:c.error?.message??r(`pairing.agentsFoundSection.requestFailed`,`Request failed`),onRetry:D}):c.isLoading?i(`p`,{className:`py-4 text-center text-xs text-foreground-muted`,children:r(`pairing.agentsFoundSection.lookingForAgents`,`Looking for agents…`)}):M.length===0?i(Be,{icon:h,title:r(`pairing.agentsFoundSection.noAgentsFound`,`No agents found`),description:r(`pairing.agentsFoundSection.nothingIsAdvertisingOnThis`,`Nothing is advertising on this network. Start the agent on its own IP (or host networking), or add it by address.`)}):i(G,{columns:te,rows:M,rowKey:e=>e.nodeId,minWidthPx:720,defaultSort:{columnKey:`state`,dir:`asc`}})]}),i(Ot,{target:u,onClose:()=>d(null),onSettled:D,onOpenNode:t})]})}var Lt=`metrics-native`,Rt=`metrics-provider`;function zt(){let{t}=K(),n=F();return i(pe,{headingId:`cluster-metrics-collection`,icon:D,title:t(`cluster.metricsSettings.title`,`Metrics collection — all nodes`),children:e(`div`,{className:`${f} space-y-3`,children:[i(`p`,{className:I,children:t(`cluster.metricsSettings.hint`,`How often every node samples its CPU, memory and load, and how long the load history is kept.`)}),i(Ie,{trpc:n.trpcClient,addonId:Lt,cap:Rt,scope:`cluster`,bare:!0})]})})}function Bt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){if(!Bt(e))return null;let t=e.ticket;if(typeof t!=`string`||t.length===0)return null;let n=e.dashboardUrl;return typeof n==`string`&&n.length>0?{ticket:t,dashboardUrl:n}:{ticket:t}}function Vt(e){let t=e.trim();return!(t.length===0||t.includes(`/`)||t.includes(`?`)||t.includes(`#`)||t.includes(`@`)||t.includes(`:`))}function Z(e){return e.startsWith(`172.17.`)}function Ht(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function Ut(e){if(e.startsWith(`10.`)||e.startsWith(`192.168.`))return!0;let t=/^172\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=16&&n<=31&&!Z(e)}function Wt(e,t){if(typeof t==`string`&&Vt(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!Z(e)&&!Ht(e)&&Ut(e));if(r!==void 0)return r;for(let e of n)if(!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!Z(e))return e;return null}function Gt(e){return`http://${e}:4444/`}function Kt(e,t){let n=new URL(Gt(e));return n.searchParams.set(`ticket`,t),n.toString()}function qt(){return window.open(`about:blank`,`_blank`)}function Jt(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function Yt({node:t}){let{info:n}=tt();return!t.isHub||n===null?i(`span`,{className:`text-sm font-semibold shrink-0`,children:t.name}):e(l,{children:[i(`span`,{className:`text-sm font-semibold shrink-0`,"data-testid":`node-title-name`,children:n.name}),n.name!==t.id&&i(`span`,{className:`text-xs text-foreground-subtle shrink-0`,"data-testid":`node-title-id`,children:t.id})]})}s();function Xt(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function Zt(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var Qt=[`trace`,`debug`,`info`,`warn`,`error`];function $t({proc:t,nodeId:n,defaultExpanded:r,activePanel:a,onTogglePanel:s}){let{t:c}=K(),l=t.services??[],u=l.length===1,[d,f]=o(u||r),[p,m]=o(null),[h,_]=o(`info`),y=t.name.includes(`(core)`),b=Fe(),S=De(),C=Ke(),w=async e=>{m(e);try{await b.mutateAsync({nodeId:n,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},D=async()=>{m(t.name);try{await S.mutateAsync({nodeId:n,processName:t.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{m(null)}},O=async e=>{let r=`${n}/${t.name}`;try{await C.mutateAsync({nodeId:r,level:e}),_(e)}catch(e){console.error(`Failed to set log level:`,e)}};return e(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[e(`div`,{role:u?void 0:`button`,tabIndex:u?void 0:0,onClick:u?void 0:()=>f(!d),onKeyDown:u?void 0:e=>{(e.key===`Enter`||e.key===` `)&&f(!d)},className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${u?``:`hover:bg-muted/40 cursor-pointer`}`,children:[u?i(`span`,{className:`h-3 w-3 shrink-0`}):i(d?oe:T,{className:`h-3 w-3 text-muted-foreground shrink-0`}),y?i(g,{className:`h-3.5 w-3.5 text-primary shrink-0`}):i(E,{className:`h-3.5 w-3.5 text-warning shrink-0`}),i(`span`,{className:`text-xs font-semibold min-w-0 flex-1 basis-full truncate sm:basis-auto`,children:t.name}),e(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:[`PID `,t.pid]}),i(Se,{status:Zt(t.state),label:t.state}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:c(`cluster.forksTab.cpu`,{percent:t.cpuPercent})}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:q(t.memoryRss)}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:Xt(t.uptimeSeconds)}),!y&&e(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e(He,{children:[i(Ne,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:c(`cluster.forksTab.setLogLevel`,`Set log level`),children:h}),i($e,{align:`end`,className:`min-w-[70px] py-0.5`,children:Qt.map(e=>i(Me,{onClick:()=>O(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),i(U,{variant:`unstyled`,onClick:D,disabled:p===t.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restartProcess`,`Restart process`),children:i(M,{className:`h-3 w-3 ${p===t.name?`animate-spin`:``}`})})]})]}),d&&l.length>0&&i(`div`,{className:`divide-y divide-border/30`,children:l.map(t=>e(`div`,{children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[i(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${t.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),i(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:t.addonId}),t.capabilities.length>0&&e(`div`,{className:`flex gap-1 flex-shrink-0`,children:[t.capabilities.slice(0,3).map(e=>i(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-info/10 text-info truncate max-w-[80px]`,children:e},e)),t.capabilities.length>3&&e(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,t.capabilities.length-3]})]}),e(`div`,{className:`flex items-center gap-1 shrink-0`,children:[i(U,{variant:`unstyled`,onClick:()=>s(t.addonId,`logs`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showLogsFor`,`Show logs for {{addonId}}`,{addonId:t.addonId}),children:i(v,{className:`h-3 w-3`})}),i(U,{variant:`unstyled`,onClick:()=>s(t.addonId,`events`),className:`p-0.5 rounded transition-colors ${a?.addonId===t.addonId&&a.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:c(`cluster.forksTab.showEventsFor`,`Show events for {{addonId}}`,{addonId:t.addonId}),children:i(x,{className:`h-3 w-3`})}),i(U,{variant:`unstyled`,onClick:()=>w(t.addonId),disabled:p===t.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:c(`cluster.forksTab.restart`,`Restart {{addonId}}`,{addonId:t.addonId}),children:i(M,{className:`h-3 w-3 ${p===t.addonId?`animate-spin`:``}`})})]})]}),a?.addonId===t.addonId&&a.type===`logs`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(Ue,{addonId:t.addonId,agentId:n,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>s(t.addonId,`logs`)})}),a?.addonId===t.addonId&&a.type===`events`&&i(`div`,{className:`border-t border-border/40 bg-muted/5`,children:i(qe,{addonId:t.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>s(t.addonId,`events`)})})]},t.addonId))}),d&&l.length===0&&i(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:c(`cluster.forksTab.noServices`,`No services`)})]})}function en({nodeId:e,processes:t}){let{t:n}=K(),[r,a]=o(null),s=(e,t)=>{a(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.forksTab.noProcessesOnThisNode`,`No processes on this node`)}):i(`div`,{className:`space-y-2 py-1`,children:t.map((t,n)=>i($t,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:s},t.name))})}var tn={system:0,managed:1,root:2};s();function nn(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function rn(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function an({nodeId:t}){let{t:r}=K(),a=c(),o=H(`metrics.node-processes-snapshot`,e=>e.nodeId===t),{data:s}=we({nodeId:t}),l=o?.processes??s,u=n(()=>l?[...l]:[],[l]),d=n(()=>[{key:`classification`,header:r(`cluster.processesTab.class`,`Class`),sortValue:e=>tn[e.classification],render:e=>i(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-info/20 text-info`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>i(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>i(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:r(`cluster.processesTab.addon`,`Addon`),sortValue:e=>e.addonId,render:e=>i(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:r(`cluster.processesTab.command`,`Command`),nowrap:!1,render:e=>i(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:rn(e.command)})},{key:`cpuPercent`,header:r(`cluster.processesTab.cpu`,`CPU%`),align:`right`,sortValue:e=>e.cpuPercent,render:e=>e.cpuPercent.toFixed(1)},{key:`memoryRssBytes`,header:`RSS`,align:`right`,sortValue:e=>e.memoryRssBytes,render:e=>q(e.memoryRssBytes)},{key:`uptimeSec`,header:r(`cluster.processesTab.uptime`,`Uptime`),align:`right`,sortValue:e=>e.uptimeSec,render:e=>i(`span`,{className:`text-foreground-subtle`,children:nn(e.uptimeSec)})}],[r]);return e(`div`,{className:`space-y-4`,children:[i(`div`,{className:`flex items-start justify-end gap-4`,children:e(U,{variant:`unstyled`,type:`button`,onClick:()=>a.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[i(S,{className:`h-3 w-3`}),` `,r(`common.refresh`)]})}),i(G,{columns:d,rows:u,rowKey:e=>e.pid,minWidthPx:880,maxBodyHeight:ue,emptyMessage:r(`cluster.processesTab.scanning`,`Scanning…`)})]})}s();var on=96;function sn({title:e,points:t,mainLabel:r,gcLabel:a,formatValue:o,emptyMessage:s,gapMs:c}){return i(de,{title:e,series:n(()=>[{id:`main`,label:r,unit:`%`,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.main}))},{id:`gc`,label:a,unit:`%`,colorIndex:1,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.gc}))}],[t,r,a,c]),stacked:!0,height:on,formatValue:e=>o(e),axisFor:()=>({floor:25}),emptyMessage:s})}function Q({title:e,points:t,formatValue:r,emptyMessage:a,axisFloor:o,axisScale:s=`linear`,gapMs:c}){return i(de,{title:e,series:n(()=>[{id:`value`,label:e,unit:s===`bytes`?`B`:null,colorIndex:0,gapMs:c,points:t.map(e=>({t:e.atMs,v:e.value}))}],[t,e,s,c]),height:on,formatValue:e=>r(e),axisFor:()=>({floor:o,scale:s}),emptyMessage:a})}function cn(e,t){let n=e.at(-1);return n===void 0?[t]:t.atMs>n.atMs?[...e,t]:e.some(e=>e.atMs===t.atMs)?e:[...e,t].toSorted((e,t)=>e.atMs-t.atMs)}function ln(e,t,n,r){let i=e.get(t),a=cn(i?.points??[],r);if(i!==void 0&&a===i.points)return e;let o=new Map(e);return o.set(t,{key:t,kind:n,points:a.slice(Math.max(0,a.length-720))}),o}function un(e,t,n){let r=e;for(let e of ne(t,n))r=ln(r,e.key,e.kind,e.point);return r}function dn(e,t){let n=e;for(let e of t)for(let t of e.points)n=ln(n,e.key,e.kind,t);return n}function fn(e){let t=null;for(let n of e.values()){let e=n.points.at(-1);e!==void 0&&(t===null||e.atMs>t)&&(t=e.atMs)}return t}var pn=12e4;function mn(e,t){return e===null?!1:t-e>pn}function hn(e){let t=e=>{let t=e.points.at(-1);return t===void 0?-1:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.key.localeCompare(n.key):r})}function gn(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var _n={key:`cpu`,dir:`desc`};function vn(e){let t=e.points.at(-1);return t===void 0?null:t.cpuMainPercent!==null&&t.cpuGcPercent!==null?t.cpuMainPercent+t.cpuGcPercent:t.cpuLifetimePercent}function yn(e){return e.points.at(-1)?.memoryRssBytes??null}function bn(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function xn(e,t){return t===`memory`?yn(e):vn(e)}function Sn(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:bn(n(e),e.key,t.search)),i=(e,t)=>e.key.localeCompare(t.key);return[...r].toSorted((e,r)=>{if(t.sort.key===`name`){let a=n(e).localeCompare(n(r)),o=t.sort.dir===`asc`?a:-a;return o===0?i(e,r):o}let a=xn(e,t.sort.key),o=xn(r,t.sort.key);if(a===null&&o===null)return i(e,r);if(a===null)return 1;if(o===null)return-1;let s=t.sort.dir===`desc`?o-a:a-o;return s===0?i(e,r):s})}s();function Cn(e,n=720){let r=H(`metrics.node-processes-snapshot`,t=>t.nodeId===e),[i,s]=o(new Map),[c,l]=o(void 0),u=t(null),{data:d,isPending:f}=xe({forNodeId:e,sinceMs:c,maxPoints:n});a(()=>{d!==void 0&&s(e=>{let t=dn(e,d.series);return u.current=fn(t),t})},[d]);let p=r?.timestamp;a(()=>{r==null||p===void 0||(mn(u.current,p)&&l(u.current??0),s(e=>{let t=un(e,r.processes,p);return u.current=fn(t),t}))},[p]),a(()=>{s(new Map),l(void 0),u.current=null},[e]);let m=0;for(let e of i.values())m=Math.max(m,e.points.length);return{series:hn(i),sampleCount:m,threadSplitAvailable:gn(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var wn=`__unclaimed__`;function Tn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function En(e,t){return{key:e,kind:t.kind,deviceId:t.deviceId,cpuSeconds:t.cpuKnown?Math.round(t.cpu*100)/100:null,rssBytes:t.rssKnown?t.rss:null,unitCount:t.count,roles:[...t.roles].sort()}}function Dn(e,t){let n=new Map,r=new Set;for(let t of e){t.pid!==void 0&&r.add(t.pid);let e=t.deviceId!==null&&t.attribution!==`unattributable`,i=e?`device:${t.deviceId}`:`shared:${t.role}`,a=n.get(i)??Tn(e?`camera`:`shared`,e?t.deviceId:null);a.count+=1,a.roles.add(t.role),t.cpuSeconds===void 0?a.cpuKnown=!1:a.cpu+=t.cpuSeconds,t.rssBytes===void 0?a.rssKnown=!1:a.rss+=t.rssBytes,n.set(i,a)}let i=[...n.entries()].map(([e,t])=>En(e,t));if(t===void 0)return i;let a=t.filter(e=>!r.has(e.pid));if(a.length===0)return i;let o=Tn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,En(wn,o)]}var On=[{family:`decode`,attribution:`measured`,unit:`one forked decode-worker child per decode SESSION`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:118`,`packages/addon-pipeline/src/session-decode/fork-decode-worker.ts:131`,`packages/addon-pipeline/src/pipeline-runner/index.ts:2765`,`packages/types/src/process/child-cost-registry.ts:188`]},{family:`transcode`,attribution:`measured`,unit:`one ffmpeg child per (camera, encode plan)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/egress-transcode-manager.ts:960`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:282`,`packages/addon-pipeline/src/stream-broker/stream-broker/transcode-egress.ts:324`,`packages/types/src/ffmpeg/sharing-key.ts:139`]},{family:`recording`,attribution:`measured`,unit:`one passthrough ffmpeg per (camera, profile)`,perCamera:!0,wiredToday:!0,missingLink:``,evidence:[`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:33`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:217`,`packages/addon-pipeline/src/recorder/addon/segment-writer.ts:279`,`packages/addon-pipeline/src/recorder/addon/recording-controller.ts:1710`]},{family:`detection`,attribution:`accounted`,unit:`a SHARED inference pool per (node, runtime, device) — no per-camera process`,perCamera:!1,wiredToday:!0,missingLink:"Nothing is missing for COUNTING — per-camera inference milliseconds, processed/shed frames and bytes-to-pool are already accumulated. What is missing is any basis for CPU seconds: `deviceId` reaches the pool as a diagnostic label and selects nothing, so cost can only ever be apportioned, never measured. Since 2026-08-27 the pool DECLARES this itself, contributing `deviceId: null` + `attribution: unattributable` rather than leaving an observer to infer it — the renunciation is data, and it is still refused by the chart gate.",evidence:[`packages/addon-pipeline/src/detection-pipeline/provider.ts:540`,`packages/addon-pipeline/src/detection-pipeline/engine/shared-inference-pool.ts:413`,`packages/types/src/interfaces/inference-engine.ts:24`,`packages/addon-pipeline/src/pipeline-runner/timing-sampler.ts:63`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:353`,`packages/addon-pipeline/src/pipeline-runner/runner.ts:849`,`packages/addon-pipeline/src/pipeline-runner/frame-lazy-metrics.ts:100`]},{family:`streaming`,attribution:`measured`,unit:"one StreamBroker per `${deviceId}/${camStreamId}`, with an exact RTP ring byte counter",perCamera:!0,wiredToday:!1,missingLink:"The ffmpeg-backed ingest is now reported per camera, but that is the minority path. `rtpRingBytes` — the exact figure for the in-process case — is maintained on every push and drop and is still private and absent from `getStats()`. The three `EncodedRingBuffer`s track packets and duration and have no byte accumulator at all; the only byte figure they offer is `preRollBudgetBytes`, which is a BUDGET, not an occupancy.",evidence:[`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2895`,`packages/addon-pipeline/src/stream-broker/rtsp/ffmpeg-push-reader.ts:189`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:494`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:498`,`packages/addon-pipeline/src/stream-broker/stream-broker/stream-broker.ts:2505`,`packages/addon-pipeline/src/stream-broker/stream-broker/pre-roll.ts:269`]}];function kn(e){return e.attribution===`measured`&&e.wiredToday}function An(){let e=new Set;for(let t of On)kn(t)&&e.add(t.family);return e}var jn=An();function Mn(e){return!jn.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function Nn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function Pn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function Fn(e,t,n){if(t.cpuSeconds===void 0)return null;if(e===void 0)return t.startedAtMs===void 0||t.startedAtMs<n?null:t.cpuSeconds;if(e.cpuSeconds===void 0||e.startedAtMs===void 0||t.startedAtMs===void 0||e.startedAtMs!==t.startedAtMs)return null;let r=t.cpuSeconds-e.cpuSeconds;return r<0?null:r}function In(e){return Math.round(e*10)/10}function Ln(e,t){let n=t.atMs-e.atMs;if(n<=0)return[];let r=n/1e3,i=new Map;for(let t of e.entries)Mn(t)&&i.set(Nn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!Mn(n)||n.deviceId===null)continue;let t=Nn(n);o.add(t);let r=a.get(n.deviceId)??Pn();r.unitCount+=1,r.roles.add(n.role);let s=Fn(i.get(t),n,e.atMs);s===null?r.cpuKnown=!1:r.cpuSeconds+=s,n.rssBytes===void 0?r.rssKnown=!1:r.rssBytes+=n.rssBytes,a.set(n.deviceId,r)}for(let[e,t]of i){if(o.has(e)||t.deviceId===null)continue;let n=a.get(t.deviceId);n!==void 0&&(n.cpuKnown=!1)}return[...a.entries()].map(([e,n])=>({deviceId:e,point:{atMs:t.atMs,cpuPercent:n.cpuKnown?In(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function Rn(e,t){if(t.length===0)return e;let n=new Map(e);for(let e of t){let t=n.get(e.deviceId),r=t?.points.at(-1);if(r!==void 0&&e.point.atMs<=r.atMs)continue;let i=[...t?.points??[],e.point];n.set(e.deviceId,{deviceId:e.deviceId,points:i.slice(Math.max(0,i.length-720))})}return n}function zn(e){let t=e=>{for(let t=e.points.length-1;t>=0;t--){let n=e.points[t]?.cpuPercent;if(n!=null)return n}return-1};return[...e.values()].toSorted((e,n)=>{let r=t(n)-t(e);return r===0?e.deviceId-n.deviceId:r})}function Bn(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function Vn(e,t){let n=Bn(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function Hn(e,t){return e.filter(e=>Vn(e.addonId,t))}s();function Un(e){let n=H(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=ze(void 0,{staleTime:1/0,refetchOnWindowFocus:!1}),[i,s]=o(new Map),c=t(null),l=t(r.refetch);l.current=r.refetch;let u=n?.timestamp;a(()=>{u!==void 0&&l.current()},[u]),a(()=>{s(new Map),c.current=null},[e.nodeId,e.isHub]);let d=r.data,f=r.dataUpdatedAt;a(()=>{if(d===void 0||f===0)return;let t={atMs:f,entries:Hn(d,e)},n=c.current;if(c.current=t,n===null)return;let r=Ln(n,t);r.length!==0&&s(e=>Rn(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:Hn(d,e),m=n?.processes,h=Dn(p,m);return{series:zn(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function Wn(e){let t=new Map;for(let n of e){let e=n.name?.trim();e===void 0||e===``||t.set(n.id,e)}return t}var Gn=25,Kn=64*1024*1024,qn=1e4;function Jn({scope:t,cadenceMs:n}){let{t:r}=K(),a=Un(t),{data:o=[]}=Te({isCamera:!0,projection:`slim`}),s=Wn(o),c=Oe(n??qn);return e(`section`,{className:`space-y-3`,children:[a.error!==null&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[i(C,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:r(`cameraLoad.readFailed`,`Could not read the load contributions: {{error}}. This is a failed read, NOT an idle cluster.`,{error:a.error})})]}),i(Xn,{unclaimed:a.unclaimed}),a.series.length===0&&a.error===null&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:a.loading?r(`cameraLoad.loading`,`Reading what the addons report…`):r(`cameraLoad.waitingWindow`,`No per-camera window yet.`)}),i(`div`,{className:`space-y-3`,children:a.series.map(t=>e(`div`,{className:`rounded-lg border border-border p-3`,children:[e(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[i(Yn,{deviceId:t.deviceId,name:s.get(t.deviceId)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`cameraLoad.unitCount`,`{{count}} unit(s): {{roles}}`,{count:t.points.at(-1)?.unitCount??0,roles:(t.points.at(-1)?.roles??[]).join(`, `)})})]}),e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[i(Q,{title:r(`cameraLoad.cpuTitle`,`CPU % of one core (delta)`),points:t.points.map(e=>({atMs:e.atMs,value:e.cpuPercent})),formatValue:e=>`${e.toFixed(1)}%`,axisFloor:Gn,gapMs:c,emptyMessage:r(`cameraLoad.cpuUnavailable`,`No measurable window yet.`)}),i(Q,{title:r(`cameraLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.rssBytes})),formatValue:q,axisFloor:Kn,axisScale:`bytes`,gapMs:c,emptyMessage:r(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},t.deviceId))})]})}function Yn({deviceId:t,name:n}){let{t:r}=K();return n===void 0?i(`span`,{className:`text-xs font-medium text-foreground`,children:r(`cameraLoad.deviceLabel`,`Camera {{deviceId}}`,{deviceId:t})}):e(`span`,{className:`flex items-baseline gap-1.5 min-w-0`,children:[i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n}),e(`span`,{className:`shrink-0 text-[10px] font-mono text-foreground-subtle`,children:[`#`,t]})]})}function Xn({unclaimed:e}){let{t}=K();return e===null||e.unitCount===0?null:i(`div`,{className:`flex items-center gap-2`,children:i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full bg-warning/10 text-warning font-medium tabular-nums`,children:t(`cameraLoad.unclaimedBadge`,`{{count}} unclaimed · {{rss}}`,{count:e.unitCount,rss:e.rssBytes===null?`—`:q(e.rssBytes)})})})}s();var Zn=256*1024*1024,Qn=1e4;function $n({nodeId:r,isHub:a}){let s=t(null);Le(s);let{t:c}=K(),{series:l,sampleCount:u,threadSplitAvailable:f,loadingRetained:p,bucketMs:m,cadenceMs:h}=Cn(r),[g,v]=o(``),[y,b]=o(new Set),[x,S]=o(_n),w=e=>e.key===`__root__`?c(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?c(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,T=Oe(m??h??Qn),E=n(()=>Sn(l,{search:g,selectedKeys:y,sort:x},w),[l,g,y,x]),D=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return e(`div`,{className:`space-y-4`,children:[i(er,{bucketMs:m,cadenceMs:h}),!f&&u>0&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/40 bg-warning/5 px-3 py-2 text-[11px] text-warning`,children:[i(C,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:c(`clusterLoad.noThreadSplit`,`No thread-level CPU split on this node — /proc/<pid>/task is Linux-only, and the first sample after a restart has no window to measure. CPU below falls back to the ps lifetime AVERAGE, which is not a rate.`)})]}),u===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:p?c(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):c(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),l.length>0&&e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(`label`,{className:`relative flex-1 min-w-[160px]`,children:[i(d,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),i(V,{ref:s,type:`search`,value:g,onChange:e=>v(e.target.value),placeholder:c(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":c(`clusterLoad.searchLabel`,`Find a runner`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle`})]}),i(tr,{sort:x,onChange:S})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[l.map(e=>{let t=y.has(e.key);return i(U,{variant:`unstyled`,type:`button`,"aria-pressed":t,onClick:()=>D(e.key),className:`rounded-full border px-2 py-0.5 text-[10px] transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:w(e)},e.key)}),y.size>0&&e(U,{variant:`unstyled`,type:`button`,onClick:()=>b(new Set),className:`inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground`,children:[i(_,{className:`h-2.5 w-2.5`}),c(`clusterLoad.clearFilter`,`All runners`)]})]})]}),l.length>0&&E.length===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:c(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:l.length})}),i(`div`,{className:`space-y-3`,children:E.map(t=>e(`div`,{className:`rounded-lg border border-border p-3`,children:[e(`div`,{className:`flex items-baseline justify-between gap-2 mb-2`,children:[i(`span`,{className:`text-xs font-medium text-foreground`,children:w(t)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`clusterLoad.processCount`,`{{count}} process(es)`,{count:t.points.at(-1)?.processCount??0})})]}),e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[i(sn,{title:f?c(`clusterLoad.cpuTitle`,`CPU % of one core`):c(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:c(`clusterLoad.seriesMain`,`Main threads`),gcLabel:c(`clusterLoad.seriesGc`,`GC / V8 helpers`),points:t.points.map(e=>({atMs:e.atMs,main:e.cpuMainPercent,gc:e.cpuGcPercent})),formatValue:e=>`${e.toFixed(0)}%`,gapMs:T,emptyMessage:c(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(t.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),i(Q,{title:c(`clusterLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:q,axisFloor:Zn,axisScale:`bytes`,gapMs:T,emptyMessage:c(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},t.key))}),i(Jn,{scope:{nodeId:r,isHub:a},cadenceMs:h})]})}function er({bucketMs:e,cadenceMs:t}){let{t:n}=K();return e===null?null:i(`p`,{className:`text-[10px] text-foreground-subtle`,children:t!==null&&e>t?n(`clusterLoad.captionBucket`,`1 point = {{bucket}}s (bucket MAXIMUM, not a mean)`,{bucket:Math.round(e/1e3)}):n(`clusterLoad.captionRaw`,`1 point = 1 snapshot`)})}function tr({sort:t,onChange:n}){let{t:r}=K(),a=[{key:`cpu`,label:r(`clusterLoad.sortCpu`,`CPU`)},{key:`memory`,label:r(`clusterLoad.sortMemory`,`Memory`)},{key:`name`,label:r(`clusterLoad.sortName`,`Name`)}];return e(`div`,{className:`flex items-center gap-1`,children:[i(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`clusterLoad.sortBy`,`Sort by`)}),a.map(r=>{let i=t.key===r.key;return e(U,{variant:`unstyled`,type:`button`,"aria-pressed":i,onClick:()=>n(i?{key:r.key,dir:t.dir===`desc`?`asc`:`desc`}:{key:r.key,dir:r.key===`name`?`asc`:`desc`}),className:`rounded border px-1.5 py-0.5 text-[10px] transition-colors ${i?`border-primary bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground`}`,children:[r.label,i&&(t.dir===`desc`?` ↓`:` ↑`)]},r.key)})]})}var nr=`No per-node settings on this node. Every other setting these addons expose is one value for the whole cluster — edit those in System → Settings, not here.`;function rr({nodeId:e,addonIds:t}){let{t:n}=K();return t.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:n(`cluster.nodeDetailSettingsTab.noAddonsOnThisNode`,`No addons on this node`)}):i(`div`,{className:`w-full py-2`,children:i(rt,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:nr,selfTabbed:!0})})}s();function ir({nodeId:e,addons:t}){let{t:r}=K(),a=c(),{data:o,isLoading:s}=ve({nodeId:e}),l=n(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),u=ke({onSuccess:()=>{a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return l.length===0?i(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:r(`cluster.nodeDetailCapabilitiesTab.noCapabilitiesOnThisNode`,`No capabilities on this node`)}):i(G,{columns:[{key:`capName`,header:r(`cluster.nodeDetailCapabilitiesTab.capability`,`Capability`),width:`w-1/2`,sortValue:e=>e.capName,render:e=>i(`span`,{className:`font-medium`,children:e.capName})},{key:`provider`,header:r(`cluster.nodeDetailCapabilitiesTab.boundProvider`,`Bound provider`),render:t=>{let n=o?.[t.capName]??t.providers[0]??``,a=t.providers.length===1;return i(k,{value:n,onChange:n=>u.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||u.isPending||s,className:`w-full`,title:a?r(`cluster.nodeDetailCapabilitiesTab.onlyOneProviderInstalledChoice`,`Only one provider installed — choice becomes available once a second addon registers this capability`):void 0,children:t.providers.map(e=>i(`option`,{value:e,children:e},e))})}}],rows:l,rowKey:e=>e.capName,minWidthPx:520,maxBodyHeight:ue})}s();function ar(e){if(e==null)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:`${i}m`}function or(t){let{t:n}=K(),[r,a]=o(!1),[s,l]=o(t.name),u=c(),d=Xe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),f=(t.localIps??[]).filter(e=>!e.includes(`:`)),p=(t.localIps??[]).filter(e=>e.includes(`:`)),m=async()=>{if(!s.trim()||s===t.name){a(!1);return}try{await d.mutateAsync({nodeId:t.nodeId,name:s.trim()}),a(!1)}catch(e){console.error(`Rename failed:`,e)}},h=[[`Node ID`,i(`span`,{className:`font-mono text-xs`,children:t.nodeId})],[`Display Name`,r?e(`div`,{className:`flex items-center gap-1.5`,children:[i(V,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:s,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&a(!1)},disabled:d.isPending,autoFocus:!0}),i(U,{variant:`unstyled`,onClick:()=>void m(),disabled:d.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:n(`common.save`,`Save`),children:i(N,{className:`h-3.5 w-3.5`})}),i(U,{variant:`unstyled`,onClick:()=>a(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:n(`common.cancel`,`Cancel`),children:i(_,{className:`h-3.5 w-3.5`})})]}):e(`div`,{className:`flex items-center gap-1.5`,children:[i(`span`,{className:`text-xs`,children:t.name}),!t.isHub&&i(U,{variant:`unstyled`,onClick:()=>{l(t.name),a(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:n(`cluster.nodeInfoTab.rename`,`Rename`),children:i(P,{className:`h-3 w-3`})})]})],[`Hostname`,i(`span`,{className:`text-xs`,children:t.hostname})],[`Role`,t.isHub?i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:n(`cluster.nodeInfoTab.hub`,`Hub`)}):i(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:n(`cluster.nodeInfoTab.agent`,`Agent`)})],[`Root Package`,t.rootPackage?e(`span`,{className:`font-mono text-xs`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}):i(`span`,{className:`text-xs text-muted-foreground`,children:`—`})],[`Platform`,e(`span`,{className:`text-xs`,children:[t.platform,` / `,t.arch]})],[`CPU`,e(`span`,{className:`text-xs`,children:[t.cpuModel??`—`,` (`,n(`cluster.nodeInfoTab.cores`,{count:t.cpuCores}),`)`]})],[`Memory`,i(`span`,{className:`text-xs`,children:t.memoryMB>0?n(`cluster.nodeInfoTab.gb`,`{{value1}} GB`,{value1:(t.memoryMB/1024).toFixed(1)}):`—`})],[`Uptime`,i(`span`,{className:`text-xs`,children:ar(t.uptime)})],[n(`cluster.nodeInfoTab.installedRuntimes`,`Installed runtimes`),t.engines.length>0?i(`div`,{className:`flex flex-wrap gap-1`,title:n(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:e},e))}):i(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return f.length>0&&h.push([`IPv4`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map((e,t)=>i(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),p.length>0&&h.push([`IPv6`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map((e,t)=>i(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),i(`div`,{className:`py-2`,children:i(`table`,{className:`w-full text-sm`,children:i(`tbody`,{children:h.map(([t,n],r)=>e(`tr`,{className:r%2==0?`bg-muted/20`:``,children:[i(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:t}),i(`td`,{className:`py-1.5 px-2`,children:n})]},t))})})})}s();function sr({nodeId:t,value:n,detectedHosts:r,status:s,errorMessage:c,onCommit:l}){let{t:d}=K(),[f,p]=o(n??``);a(()=>{p(n??``)},[n]);let m=r[0],h=m===void 0?`auto-detect`:`auto: ${m}`,g=s===`pending`,_=f.trim(),v=_!==(n??``),y=v&&!g,b=()=>{y&&l(t,_.length>0?_:null)};return e(`div`,{className:`flex items-center gap-1.5`,children:[i(V,{"aria-label":d(`placementBoard.reachableHostInput.reachableHostFor`,`Reachable host for {{nodeId}}`,{nodeId:t}),type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:h,value:f,disabled:g,onChange:e=>p(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&b(),e.key===`Escape`&&p(n??``)},className:`w-36`}),e(U,{variant:`outline`,size:`sm`,onClick:b,disabled:!y,"aria-label":d(`placementBoard.reachableHostInput.saveReachableHostFor`,`Save reachable host for {{nodeId}}`,{nodeId:t}),title:d(`placementBoard.reachableHostInput.saveReachableHost`,`Save reachable host`),children:[g?i(L,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):i(N,{className:`h-3 w-3`,"aria-hidden":`true`}),d(`common.save`,`Save`)]}),!v&&!g&&s===`success`&&i(N,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":d(`placementBoard.reachableHostInput.saved`,`Saved`),role:`img`}),s===`error`&&i(`span`,{title:c??d(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),children:i(u,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":c??d(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),role:`img`})})]})}s();function cr(e){let t=re.safeParse(ct(e,`color`));return t.success?t.data:null}function lr(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function ur({nodeId:t,detectedHosts:r}){let{t:a}=K(),o=c(),s=Ye(void 0),l=We({onSuccess:()=>st(o)}),u=We({onSuccess:()=>st(o)}),d=n(()=>s.data?.find(e=>e.nodeId===t)?.settings,[s.data,t]),f=cr(d)??(s.isLoading?null:ie(t)),p=ot(d,`reachableHost`),m=lr(t,l),h=m===`error`?lt(l.error):null,g=r.filter(e=>!e.includes(`:`)),_=e=>{e!==f&&u.mutate({agentNodeId:t,color:e})};return e(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[i(B,{label:a(`nodes.general.nodeColour`,`Node colour`),children:i(`div`,{role:`group`,"aria-label":a(`nodes.general.nodeColourGroup`,`Node colour`),className:`flex flex-wrap gap-2`,children:ae.map(e=>{let t=f===e;return i(U,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":e,variant:`outline`,size:`sm`,disabled:s.isLoading||u.isPending,title:e,onClick:()=>_(e),className:`h-6 w-6 min-w-6 shrink-0 rounded-full border-0 p-0 ${_e(e)} ${t?`ring-2 ring-primary ring-offset-2 ring-offset-background`:`opacity-80 hover:opacity-100`}`,children:i(`span`,{className:`sr-only`,children:e})},e)})})}),i(B,{label:a(`nodes.general.reachableHost`,`Reachable host`),children:i(sr,{nodeId:t,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{l.mutate({agentNodeId:e,reachableHost:t})}})})]})}s();var dr=512,fr=65536,pr=[[`serverManagement`,`getLaunchOverrides`]];function mr(e){let t=e.trim();if(t===``)return null;if(!/^[0-9]+$/.test(t))return;let n=Number(t);return n>=dr&&n<=fr?n:void 0}var hr=e=>e==null?``:String(e);function gr({node:t}){let{t:n}=K(),r=c(),s=t.isHub?void 0:{nodeId:t.id},l=Ge(s,{enabled:t.isOnline,retry:1}),u=Qe({onSuccess:()=>{r.invalidateQueries({queryKey:pr})}}),[d,f]=o(``),[p,m]=o(``),[h,g]=o(null),_=l.data;a(()=>{_!==void 0&&(f(hr(_.heapMb)),m(hr(_.rssBudgetMb)))},[_]);let v=async()=>{let e=mr(d),r=t.isHub?mr(p):null;if(e===void 0||r===void 0){g(n(`nodes.launch.invalid`,`Enter a whole number between {{min}} and {{max}} MB, or leave the field empty.`,{min:dr,max:fr}));return}g(null);try{g((await u.mutateAsync({...s,heapMb:e,...t.isHub?{rssBudgetMb:r}:{}})).restartRequired?n(`nodes.launch.saved`,`Saved. Takes effect on restart.`):n(`nodes.launch.savedNow`,`Saved.`))}catch(e){g(e instanceof Error?e.message:n(`nodes.launch.failed`,`Save failed.`))}};return e(`div`,{className:`rounded-lg border border-border bg-surface/40 divide-y divide-border px-3`,children:[i(B,{label:n(`nodes.launch.heap`,`Heap ceiling (MB)`),children:i(V,{type:`number`,inputMode:`numeric`,"aria-label":n(`nodes.launch.heap`,`Heap ceiling (MB)`),placeholder:n(`nodes.launch.default`,`Default`),value:d,onChange:e=>f(e.target.value),disabled:!t.isOnline||l.isLoading})}),t.isHub&&i(B,{label:n(`nodes.launch.rss`,`RSS budget (MB)`),children:i(V,{type:`number`,inputMode:`numeric`,"aria-label":n(`nodes.launch.rss`,`RSS budget (MB)`),placeholder:n(`nodes.launch.default`,`Default`),value:p,onChange:e=>m(e.target.value),disabled:!t.isOnline||l.isLoading})}),i(B,{label:n(`nodes.launch.restartNote`,`Takes effect on restart`),actions:i(U,{type:`button`,size:`sm`,onClick:()=>void v(),disabled:!t.isOnline||u.isPending,children:n(`common.save`,`Save`)}),children:h??``})]})}s();var _r=3*6e4,vr={neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-success/15 text-success`,info:`bg-info/15 text-info`,warn:`bg-warning/15 text-warning`,error:`bg-danger/15 text-danger`};function yr({desktopApp:t,nodeName:n,routingInput:s,onSettled:c}){let{t:l}=K(),u=O(),d=Ae({onSettled:c}),[f,p]=o(null),[m,h]=o(!1),[g,_]=o(null);a(()=>{f!=null&&t.version!==f.fromVersion&&(p(null),h(!1))},[t.version,f]),a(()=>{if(f==null)return;let e=Math.max(0,f.startedAtMs+_r-Date.now()),t=setTimeout(()=>h(!0),e);return()=>clearTimeout(t)},[f]);let v=r(e=>{switch(e){case`not-electron`:return l(`serverManagement.desktopRefusedNotElectron`,`This node does not run inside the desktop app.`);case`no-app-state`:return l(`serverManagement.desktopRefusedNoState`,`The desktop app has not reported its state yet.`);case`app-state-stale`:return l(`serverManagement.desktopRefusedStale`,`The desktop app stopped reporting — it is probably not running.`);case`not-downloaded`:return l(`serverManagement.desktopRefusedNotDownloaded`,`No update is downloaded yet.`)}},[l]),y=r(async()=>{if(await u({title:l(`serverManagement.desktopConfirmTitle`,`Install desktop app update`),message:l(`serverManagement.desktopConfirmBody`,`Install {{version}} on "{{node}}" and restart the desktop app? The node is offline while it restarts.`,{version:t.update.version??``,node:n}),confirmLabel:l(`serverManagement.desktopInstallAction`,`Install update & restart`),variant:`warning`})){_(null),h(!1);try{let e=await d.mutateAsync(s);e.accepted?p({fromVersion:t.version,startedAtMs:Date.now()}):e.reason!=null&&_(v(e.reason))}catch(e){_(e instanceof Error?e.message:String(e))}}},[u,t,d,n,v,s,l]),b=f!=null&&!m,{update:x}=t,S=null;t.stale?S={label:l(`serverManagement.desktopStale`,`app state unknown (last seen {{when}})`,{when:it(t.stateAtMs)}),tone:`warn`}:x.downloaded?S={label:l(`serverManagement.desktopReady`,`update {{version}} ready`,{version:x.version??``}),tone:`ok`}:x.available?S={label:l(`serverManagement.desktopDownloading`,`update {{version}} available — downloading`,{version:x.version??``}),tone:`info`}:x.checking?S={label:l(`serverManagement.stateChecking`,`checking…`),tone:`info`}:x.error??(S={label:l(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`});let C=!t.stale&&x.downloaded&&!b&&!d.isPending;return e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-sm`,children:[e(`span`,{className:`inline-flex items-baseline gap-1`,children:[i(`span`,{className:`text-foreground-subtle`,children:l(`serverManagement.desktopApp`,`Desktop app`)}),i(`span`,{className:`font-mono text-foreground`,children:t.version})]}),S!=null&&i(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${vr[S.tone]}`,children:S.label})]}),!t.stale&&x.error!=null&&i(`p`,{className:`text-xs text-danger`,children:l(`serverManagement.desktopUpdateError`,`Update check failed: {{error}}`,{error:x.error})}),C&&e(U,{size:`sm`,onClick:()=>void y(),children:[i(M,{className:`h-3.5 w-3.5`}),l(`serverManagement.desktopInstallAction`,`Install update & restart`)]}),(d.isPending||b)&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(L,{className:`h-4 w-4 animate-spin`}),l(`serverManagement.desktopRestarting`,`The desktop app is restarting to install the update…`)]}),f!=null&&m&&i(`p`,{role:`status`,className:`text-xs text-warning`,children:l(`serverManagement.desktopRestartTimeout`,`The desktop app has not come back with a new version after 3 minutes. Check the machine.`)}),g!=null&&i(`p`,{role:`status`,className:`text-xs text-warning`,children:g})]})}s();var br=[[`serverManagement`,`getServerPackageStatus`]];function xr({label:e,tone:t}){return i(`span`,{className:`inline-flex items-center rounded px-2 py-0.5 text-[11px] font-medium ${{neutral:`bg-surface-muted text-foreground-subtle`,ok:`bg-success/15 text-success`,info:`bg-info/15 text-info`,warn:`bg-warning/15 text-warning`,error:`bg-danger/15 text-danger`}[t]}`,children:e})}function $({label:t,value:n}){return e(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[i(`span`,{className:`text-foreground-subtle`,children:t}),i(`span`,{className:`font-mono text-foreground`,children:n??`—`})]})}function Sr({runningVersion:t,latestVersion:n,seedVersion:r,nodeRuntimeVersion:a,labelRunning:o,labelLatest:s,labelSeed:c,labelRuntime:l}){return i(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[{key:`running`,label:o,value:t},{key:`latest`,label:s,value:n},{key:`seed`,label:c,value:r},{key:`runtime`,label:l,value:a}].map(({key:t,label:n,value:r})=>e(`span`,{className:`inline-flex items-baseline gap-1`,children:[i(`span`,{className:`text-foreground-subtle`,children:n}),i(`span`,{className:`font-mono text-foreground`,children:r??`—`})]},t))})}var Cr={ok:`border-success/40 bg-success/10 text-success`,warn:`border-warning/40 bg-warning/10 text-warning`,error:`border-danger/40 bg-danger/10 text-danger`};function wr(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function Tr(e,t){let n=t instanceof Error?t.message:String(t);return`${e(`serverManagement.outcomeDropped`,`The connection dropped and the result could not be confirmed. The node may be restarting — re-check the version above.`)} — ${n}`}function Er({node:t}){let{t:n}=K(),a=c(),s=O(),[l,u]=o(!1),[d,f]=o(null),m=t.isHub?void 0:{nodeId:t.id},h=Ze(m,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),g=h.data??null,_=r(()=>{a.invalidateQueries({queryKey:br})},[a]),v=Ee({onSettled:_}),y=Pe({onSettled:_}),b=Ve({onSettled:_}),x=r(async()=>{if(g?.latestVersion==null){f({tone:`warn`,text:n(`serverManagement.outcomeNoTarget`,`No target version is known for this node — run "Check for update" first.`)});return}if(await s({title:n(`serverManagement.confirmUpdateTitle`,`Update node root package`),message:n(`serverManagement.confirmUpdateBody`,`Install {{pkg}}@{{version}} on "{{node}}" and restart to apply.`,{pkg:g.packageName,version:g.latestVersion,node:t.name}),confirmLabel:n(`serverManagement.confirmUpdateAction`,`Update & restart`)})){f(null);try{let e=await y.mutateAsync({version:g.latestVersion,...m});f({tone:wr(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Tr(n,e)})}}},[y,s,t.name,m,g,n]),C=r(async()=>{if(await s({title:n(`serverManagement.confirmRestartTitle`,`Restart node`),message:n(`serverManagement.confirmRestartBody`,`Restart "{{node}}"? In-flight requests to this node are dropped.`,{node:t.name}),confirmLabel:n(`serverManagement.confirmRestartAction`,`Restart`),variant:`warning`})){f(null);try{let e=await b.mutateAsync(m);f({tone:wr(e),text:e.message}),e.restarting&&u(!0)}catch(e){f({tone:`warn`,text:Tr(n,e)})}}},[s,t.name,b,m,n]),w=()=>{switch(g?.bootMode){case`data-root`:return{label:n(`serverManagement.bootDataRoot`,`runtime-updatable`),tone:`ok`};case`workspace`:return{label:n(`serverManagement.bootWorkspace`,`dev workspace`),tone:`info`};default:return{label:n(`serverManagement.bootBaked`,`baked image seed`),tone:`neutral`}}},T=()=>{if(g==null)return null;switch(g.updateState){case`checking`:return{label:n(`serverManagement.stateChecking`,`checking…`),tone:`info`};case`staging`:return{label:n(`serverManagement.stateStaging`,`updating…`),tone:`info`};case`pending-restart`:return{label:n(`serverManagement.statePending`,`restart pending`),tone:`warn`};default:return g.restartRequired===!0?{label:n(`serverManagement.stateRestartRequired`,`restart required`),tone:`warn`}:g.updateAvailable?{label:n(`serverManagement.stateUpdateAvailable`,`update available`),tone:`warn`}:{label:n(`serverManagement.stateUpToDate`,`up to date`),tone:`ok`}}},E=g?.bootMode===`workspace`,D=t.isOnline&&g!=null&&!E&&g.updateAvailable&&g.updateState===`idle`&&!y.isPending,k=t.isOnline&&g!=null&&g.updateState===`idle`&&!b.isPending,A=t.isOnline?T():null;return e(`div`,{className:`space-y-4 py-2`,children:[e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-2 min-w-0`,children:[i(`span`,{className:`font-mono text-xs text-foreground-subtle truncate`,children:g?.packageName??t.rootPackage?.name??`@camstack/server`}),t.isOnline&&g!=null&&i(xr,{...w()})]}),A!=null&&i(xr,{...A})]}),!t.isOnline&&i($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage?.version??null}),t.isOnline&&h.isLoading&&e(`div`,{className:`flex items-center gap-2 text-sm text-foreground-subtle`,children:[i(L,{className:`h-4 w-4 animate-spin`}),n(`common.loading`,`Loading…`)]}),t.isOnline&&h.isError&&e(`div`,{className:`space-y-1.5`,children:[i(`p`,{className:`text-sm text-danger`,children:n(`serverManagement.loadError`,`Could not load the node root-package status.`)}),t.rootPackage!=null&&i($,{label:n(`serverManagement.lastReportedVersion`,`Last reported version`),value:t.rootPackage.version})]}),t.isOnline&&g!=null&&e(`div`,{className:`space-y-1.5`,children:[i(Sr,{runningVersion:g.runningVersion,latestVersion:g.latestVersion,seedVersion:g.seedVersion,nodeRuntimeVersion:g.nodeRuntimeVersion,labelRunning:n(`serverManagement.runningVersionShort`,`Running`),labelLatest:n(`serverManagement.latestVersionShort`,`Latest`),labelSeed:n(`serverManagement.imageSeedShort`,`Seed`),labelRuntime:n(`serverManagement.nodeRuntimeVersionShort`,`Node.js`)}),g.desktopApp!=null&&i(yr,{desktopApp:g.desktopApp,nodeName:t.name,routingInput:m,onSettled:_}),g.pendingVersion!=null&&i($,{label:n(`serverManagement.pendingVersion`,`Staged (applies on restart)`),value:g.pendingVersion}),g.installedVersion!=null&&g.installedVersion!==g.runningVersion&&i($,{label:n(`serverManagement.installedVersion`,`Installed on disk (runs after restart)`),value:g.installedVersion})]}),t.isOnline&&g?.imageContract?.state===`behind-series`&&e(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs leading-relaxed text-danger`,children:[i(`p`,{className:`mb-0.5 font-semibold`,children:n(`serverManagement.imageContractDiverged`,`Container image diverges from the deployment contract`)}),i(`p`,{children:g.imageContract.message})]}),t.isOnline&&E&&i(`p`,{className:`text-xs text-foreground-subtle`,children:n(`serverManagement.workspaceNote`,`Development workspace detected — runtime updates are disabled (the dev loop resolves code from the workspace).`)}),d!=null&&i(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${Cr[d.tone]}`,children:d.text}),l&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(L,{className:`h-4 w-4 animate-spin`}),n(`serverManagement.nodeRestarting`,`The node is restarting to apply the change…`)]}),t.isOnline&&e(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[e(U,{variant:`unstyled`,type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:v.isPending||g?.updateState===`staging`,onClick:()=>v.mutate(m),children:[v.isPending?i(L,{className:`h-3.5 w-3.5 animate-spin`}):i(S,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),D&&e(U,{variant:`unstyled`,type:`button`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground hover:opacity-90 disabled:opacity-50`,onClick:()=>void x(),children:[y.isPending?i(L,{className:`h-3.5 w-3.5 animate-spin`}):i(p,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:g?.latestVersion??``})]}),e(U,{variant:`unstyled`,type:`button`,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-surface-muted disabled:opacity-50`,disabled:!k,onClick:()=>void C(),children:[b.isPending?i(L,{className:`h-3.5 w-3.5 animate-spin`}):i(M,{className:`h-3.5 w-3.5`}),n(`serverManagement.restart`,`Restart`)]})]}),t.isOnline&&g?.lastCheckedAtMs!=null&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(se,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(g.lastCheckedAtMs).toLocaleString()})]})]})}s();function Dr(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`reachableHost`);return typeof t==`string`&&t.length>0?t:null}function Or({node:t}){let{t:a}=K(),s=F(),u=c(),d=O(),[f,p]=o(!1),[m,h]=o(`info`),[g,_]=o(!1),[v,y]=o(null),b=t.processes??[],x=t.addons.map(e=>e.id),S=Ye(void 0),C=n(()=>{let e=S.data?.find(e=>e.nodeId===t.id);return Dr(e?.settings)},[S.data,t.id]),[w,T]=o(!1),[E,D]=o(null),[k,A]=o(null),M=r(async()=>{if(w||t.isHub)return;let e=Wt(t.localIps??[],C);if(e===null){D(`No LAN IPv4 on this node — open its :4444 URL by hand.`),A(null);return}let n=qt();T(!0),D(null),A(null);try{let r=X(await s.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:Gt(e)}})),i=r===null?null:r.dashboardUrl??Kt(e,r.ticket);if(i===null){n?.close(),D(`Hub did not return an unlock ticket.`);return}Jt(n,i)||(A(i),D(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){n?.close(),D(e instanceof Error?e.message:String(e))}finally{T(!1)}},[t.id,t.isHub,t.localIps,w,C,s.trpcClient]),N=async()=>{if(!g){_(!0),y(null);try{await s.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:t.id}).catch(()=>void 0);let e=await s.trpcClient.clusterNodes.forgetNode.mutate({nodeId:t.id});y({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){y({tone:`warn`,text:a(`cluster.nodeCard.forgetFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{_(!1)}}},P=async()=>{if(!f&&await d({title:a(`cluster.nodeCard.unpair`,`Unpair {{name}}`,{name:t.name}),message:a(`cluster.nodeCard.unpairItDisconnectsAndMust`,`Unpair {{name}}? It disconnects and must be paired again.`,{name:t.name}),confirmLabel:a(`cluster.nodeCard.unpair2`,`Unpair`),variant:`danger`})){p(!0),y(null);try{let e=await s.trpcClient.agentPairing.unpairAgent.mutate({nodeId:t.id});y({tone:e.agentNotified?`ok`:`warn`,text:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){y({tone:`warn`,text:a(`cluster.nodeCard.unpairFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{p(!1)}}},I=t.isHub?null:e(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void P(),disabled:f,title:a(`cluster.nodeCard.unpairThisNodeRevokesIts`,`Unpair this node — revokes its certificates; it must be paired again to rejoin`),children:[i(le,{className:`h-3 w-3`,"aria-hidden":!0}),f?a(`cluster.nodeCard.unpairing`,`Unpairing…`):a(`cluster.nodeCard.unpair2`,`Unpair`)]});return t.isOnline?e(`div`,{className:`border border-border rounded-xl`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30 border-b border-border rounded-t-xl`,children:[e(`div`,{className:`flex min-w-0 flex-1 basis-full items-center gap-x-2 gap-y-1 sm:basis-auto sm:flex-initial`,children:[i(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success shrink-0`}),i(Yt,{node:t}),e(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?a(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]})]}),t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium shrink-0`,title:a(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:e},e)),e(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-3 gap-y-1 text-xs text-muted-foreground w-full sm:ml-auto sm:w-auto`,children:[!t.isHub&&e(U,{variant:`unstyled`,type:`button`,onClick:()=>void M(),disabled:w,title:a(`cluster.nodeCard.openThisAgentSStatus`,`Open this agent's status dashboard (unlocks with a short-lived hub ticket)`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[i(te,{className:`h-3 w-3`}),w?a(`cluster.nodeCard.opening`,`Opening…`):a(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),I,e(`span`,{className:`flex items-center gap-1`,children:[i(j,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),e(`span`,{className:`flex items-center gap-1`,children:[i(ce,{className:`h-3 w-3`}),` `,t.memoryPercent===null?a(`cluster.memoryUnknown`):`${t.memoryPercent}%`]})]})]}),v!=null&&i(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${v.tone===`ok`?`text-success`:`text-warning`}`,children:v.text}),(E!==null||k!==null)&&e(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[E,k!==null&&e(l,{children:[` `,i(`a`,{href:k,target:`_blank`,rel:`noreferrer`,className:`underline text-foreground`,children:a(`cluster.nodeCard.openDashboard`,`Open dashboard`)})]})]}),i(`div`,{className:`sticky top-0 z-20 flex border-b border-border px-4 bg-background overflow-x-auto`,children:[`info`,`forks`,`processes`,`load`,`settings`,`capabilities`].map(e=>i(U,{variant:`unstyled`,onClick:()=>h(e),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${m===e?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e===`info`?a(`cluster.nodeCard.general`,`General`):e===`forks`?a(`cluster.nodeCard.forks`,`Forks ({{length}})`,{length:b.length}):e===`processes`?a(`cluster.nodeCard.processes`,`Processes`):e===`load`?a(`cluster.nodeCard.load`,`Load`):e===`settings`?a(`cluster.nodeCard.settings`,`Settings`):a(`cluster.nodeCard.capabilities`,`Capabilities`)},e))}),e(`div`,{className:`px-4 py-2`,children:[m===`info`&&e(`div`,{className:`space-y-3`,children:[i(or,{nodeId:t.id,name:t.name,hostname:t.hostname,platform:t.platform,arch:t.arch,cpuModel:t.cpuModel,cpuCores:t.cpuCores,memoryMB:t.memoryMB,engines:t.engines,isHub:t.isHub,uptime:t.uptime,localIps:t.localIps,rootPackage:t.rootPackage}),i(ur,{nodeId:t.id,detectedHosts:t.localIps??[]}),i(`div`,{className:`border-t border-border pt-1`,children:i(Er,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})}),i(gr,{node:{id:t.id,isHub:t.isHub,isOnline:t.isOnline}})]}),m===`forks`&&i(en,{nodeId:t.id,processes:b}),m===`processes`&&i(an,{nodeId:t.id}),m===`load`&&i($n,{nodeId:t.id,isHub:t.isHub}),m===`settings`&&i(rr,{nodeId:t.id,addonIds:x}),m===`capabilities`&&i(ir,{nodeId:t.id,addons:t.addons})]})]}):e(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-4 py-3 bg-muted/30`,children:[i(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive shrink-0`}),i(Yt,{node:t}),e(`span`,{className:`text-xs text-muted-foreground min-w-0 truncate`,children:[t.cpuModel??t.platform,` ·`,` `,t.memoryMB>0?a(`cluster.nodeCard.gb`,`{{value1}}GB`,{value1:Math.round(t.memoryMB/1024)}):``,` `,`· `,t.arch]}),t.engines.map(e=>i(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,title:a(`cluster.nodeInfoTab.installedRuntimesHint`,`Inference runtimes installed on this node. Its live inference devices are on Pipeline → Load balancing.`),children:e},e)),t.rootPackage&&e(`span`,{className:`text-[10px] font-mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[t.rootPackage.name,`@`,t.rootPackage.version]}),i(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:a(`common.offline`)})]}),e(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[e(`span`,{className:`text-xs text-muted-foreground`,children:[t.lastSeen?i(`span`,{className:`mr-1`,children:a(`cluster.nodeCard.lastSeen`,{when:new Date(t.lastSeen).toLocaleString()})}):null,a(`cluster.nodeCard.addonsAssigned`,{count:t.addons.length})]}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[I,e(U,{variant:`unstyled`,type:`button`,onClick:()=>void N(),disabled:g,title:a(`cluster.nodeCard.forgetThisNodeRemovesIts`,`Forget this node — removes its saved history and pipeline assignments`),className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[i(ee,{className:`h-3 w-3`}),g?a(`cluster.nodeCard.forgetting`,`Forgetting…`):a(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),v!=null&&i(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${v.tone===`ok`?`text-success`:`text-warning`}`,children:v.text})]})}s();function kr(){let{nodes:e,isLoading:t}=he(),r=n(()=>e??[],[e]);return{nodes:r,isLoading:t&&r.length===0}}function Ar(){let{t}=K(),{nodes:r,isLoading:s}=kr(),[c,u]=nt(),{selection:d,selectNode:f}=ft(r),m=d.node,h=n(()=>r.filter(e=>e.isOnline),[r]).length,g=r.filter(e=>!e.isOnline).length,_=F(),[v,y]=o(!1),b=c.get(`unlockNode`),x=c.get(`returnTo`),[S,C]=o(null);return a(()=>{if(b===null||x===null)return;let e=!1;return(async()=>{try{let t=await _.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:b,dashboardBaseUrl:x}});if(e)return;let n=X(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(x);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){C(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(c);i.delete(`unlockNode`),i.delete(`returnTo`),u(i,{replace:!0}),window.location.assign(r)}catch(t){e||C(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[b,x,c,u,_.trpcClient]),e(at,{icon:w,title:t(`nav.nodes`,`Nodes`),subtitle:t(`cluster.subtitle`,`One node at a time — topology and packages. Agents join by pairing (certificate, no shared secret).`),actions:e(l,{children:[h>0&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:t(`common.onlineCount`,{count:h})}),g>0&&i(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:t(`common.offlineCount`,{count:g})}),e(U,{type:`button`,size:`sm`,title:t(`clusterUpdate.updateAllHint`,`Preview the hub plan, then follow the same job the CLI uses.`),onClick:()=>y(!0),children:[i(p,{className:`h-3.5 w-3.5`}),t(`clusterUpdate.updateAll`,`Update all nodes`)]})]}),children:[i(dt,{open:v,onOpenChange:y}),S!==null&&e(`p`,{role:`alert`,className:`rounded border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:[t(`system.cluster.unlockFromAgentFailed`,`Unlock from agent failed:`),` `,S]}),i(It,{onOpenNode:f}),s?i(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:t(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):m===null?i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-xs text-foreground-subtle`,children:t(`cluster.noNodes`,`No nodes in this cluster yet.`)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(ut,{staleNodeId:d.staleNodeId,shownNodeName:m.name}),i(je,{selectedNodeId:m.id,onSelect:f,allowOffline:!0,alwaysShow:!0}),i(Or,{node:m})]}),i(zt,{})]})}export{Ar as ClusterPage};
@@ -1,2 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as l,D as u,Hi as d,Ia as f,Ir as p,Lr as m,Mi as h,Nn as g,Q as _,Qa as v,Rn as y,Ua as b,Va as x,Wi as S,Xi as C,Zt as w,_i as T,aa as ee,ar as E,ct as D,eo as O,er as k,ft as A,ir as te,ki as j,ma as M,oa as ne,ot as N,qn as P,qr as re,tn as F,ur as ie,ut as ae,wi as oe,zr as I}from"./player-overlays-fpbPSPqT.js";import{Oi as se}from"./client-Cng2SeYA.js";import{t as ce}from"./chevron-down-CBb-F8DT.js";import{i as le,l as ue}from"./terminal-DZ5OZpgC.js";import{t as de}from"./circle-slash-Duh934sZ.js";import{n as fe,t as pe}from"./database-zap-DHuELz_w.js";import{t as me}from"./hard-drive-download-C6N6tovA.js";import{$ as he,Bo as ge,Br as _e,Cl as ve,Cp as ye,Da as be,Dr as xe,El as Se,Fo as Ce,Gi as L,Go as we,Ho as Te,Io as Ee,Ir as De,Ji as R,Jo as Oe,Ki as ke,Ko as Ae,Kp as je,Lo as Me,Ns as Ne,Oa as Pe,Or as Fe,Po as Ie,Qp as Le,Ro as Re,Sl as ze,Sp as z,Tl as Be,Tr as Ve,Ui as B,Uo as He,Vo as Ue,Wi as We,Wo as Ge,Yi as V,Yo as Ke,_l as qe,ai as Je,bl as Ye,ci as Xe,gl as Ze,hp as Qe,ka as H,la as $e,mp as U,nt as et,oi as tt,qi as W,qo as nt,rt,si as it,ut as G,vl as at,vo as ot,wl as st,xl as ct,yl as lt,zo as ut,zr as K}from"./src-eL0OacoB.js";import{t as q}from"./i18n--GTAj4mB.js";import{t as J}from"./useTranslation-BJr-n0es.js";import"./mount-B-FI9413.js";import{T as dt,b as ft,bi as pt,vi as mt,wi as ht}from"./index-DbXFHmBJ.js";import{t as gt}from"./AdminSectionedPage-bGVBepbw.js";import{n as _t}from"./authed-media-Bqh0pB9D.js";import{t as Y}from"./format-size-DIxKXxtj.js";import{t as vt}from"./StorageLocationsTable-DqTWO4k1.js";import{n as yt}from"./InstancesTable-LVQWfz07.js";import{t as bt}from"./AdminPage-BkxgjFWW.js";function xt(){return r(bt,{embedded:!0,children:r(vt,{})})}o();var St={settings:{labelKey:`helpers.backupDatabases.settings.label`,descriptionKey:`helpers.backupDatabases.settings.description`,shortKey:`helpers.backupDatabases.settings.short`},events:{labelKey:`helpers.backupDatabases.events.label`,descriptionKey:`helpers.backupDatabases.events.description`,shortKey:`helpers.backupDatabases.events.short`},history:{labelKey:`helpers.backupDatabases.history.label`,descriptionKey:`helpers.backupDatabases.history.description`,shortKey:`helpers.backupDatabases.history.short`}},Ct=Object.keys(St),wt=[`settings`];function Tt(){return q.t(`helpers.backupDatabases.notCreated`)}function Et(e){return q.t(St[e].labelKey)}function Dt(e){return q.t(St[e].shortKey)}function Ot(e){return q.t(St[e].descriptionKey)}function X(e){let t=new Set(e);return Ct.filter(e=>t.has(e))}function kt(e){return e!==void 0&&e.length>0?X(e):wt}function At(e){return X(e)}function jt(e,t){return t===void 0||!t.answered?`unknown`:t.databases.includes(e)?`present`:`absent`}function Mt(e,t,n){return jt(e,t)===`absent`&&!n.has(e)}function Nt(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Pt(e){return!e.includes(`settings`)}function Ft(e){return{databases:[...At(e)]}}function It(e,t){return e!==void 0&&e.length>0?X(e):t!==void 0&&t.length>0?X(t.map(e=>e.databaseId??`settings`)):wt}function Z({databases:e}){return r(`span`,{className:`text-xs font-medium uppercase tracking-wide text-foreground-muted`,"data-testid":`backup-database-badges`,children:e.map(e=>Dt(e)).join(` · `)})}var Lt=[[`backup`,`listDestinations`]],Rt=[`backup`,`listArchives`];function zt({destinationId:i,restoreSupported:o,onOpenRestoreWizard:c}){let{t:l}=J(),u=s(),d=D(),{data:f,isLoading:m,isError:h}=ge({destinationId:i}),g=f??[],_=Ce({onSuccess:()=>{u.invalidateQueries({queryKey:[[...Rt]]}),u.invalidateQueries({queryKey:Lt})}}),v=n(async e=>{await d({title:l(`backup.archiveList.deleteThisArchive`,`Delete this archive?`),message:l(`backup.archiveList.permanentlyDeletesAndFrees`,`Permanently deletes "{{value1}}" and frees {{value2}}.`,{value1:e.label??e.id,value2:Y(e.sizeBytes)}),confirmLabel:l(`common.delete`,`Delete`),variant:`danger`})&&_.mutate({destinationId:i,backupId:e.id})},[d,i,_,l]),[y,b]=a(null),x=n(async e=>{b(e.id);try{let t=await _t(Bt(i,e.id)),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.label??e.id}.tar.gz${e.encryption===void 0?``:`.csbk`}`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}finally{b(null)}},[i]),S=t(()=>[...g].toSorted((e,t)=>t.createdAt-e.createdAt),[g]);return m?r(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:l(`backup.archiveList.loadingArchives`,`Loading archives…`)}):h?r(`div`,{className:`text-xs text-danger py-2`,children:l(`backup.archiveList.failedToReadManifestFor`,`Failed to read manifest for this destination`)}):S.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)}):r(K,{columns:[{key:`when`,header:l(`backup.archiveList.when`,`When`),sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`tabular-nums`,children:Vt(e.createdAt)})},{key:`label`,header:l(`backup.archiveList.label`,`Label`),sortValue:e=>e.label??null,render:t=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.encryption!==void 0&&r(p,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.archiveList.encryptedRestoreNeedsBackupKey`,`encrypted — restore needs backup key {{keyId}}`,{keyId:t.encryption.keyId})}),t.label??r(`span`,{className:`text-foreground-subtle italic`,children:`—`})]})},{key:`databases`,header:l(`backup.archiveList.databases`,`Databases`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:kt(e.databases)})},{key:`includes`,header:l(`backup.archiveList.files`,`Files`),nowrap:!1,notSortableReason:`Location list`,render:e=>e.locations.length>0?r(`span`,{className:`text-foreground-subtle`,children:e.locations.join(`, `)}):r(`span`,{className:`text-foreground-subtle italic`,children:l(`common.none`)})},{key:`size`,header:l(`backup.archiveList.size`,`Size`),align:`right`,sortValue:e=>e.sizeBytes,render:e=>r(`span`,{className:`tabular-nums`,children:Y(e.sizeBytes)})},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:t=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[e(U,{variant:`ghost`,size:`sm`,onClick:()=>{x(t)},disabled:y===t.id,title:l(`backup.archiveList.downloadArchive`,`Download archive`),children:[y===t.id?r(I,{className:`h-3 w-3 animate-spin`}):r(oe,{className:`h-3 w-3`}),l(`backup.archiveList.download`,`Download`)]}),o&&c&&e(U,{variant:`ghost`,size:`sm`,onClick:()=>c({destinationId:i,archiveId:t.id}),title:l(`backup.archiveList.restoreFromThisArchive`,`Restore from this archive`),children:[r(P,{className:`h-3 w-3`}),l(`backup.archiveList.restore`,`Restore`)]}),r(ye,{variant:`ghost`,size:`sm`,icon:F,"aria-label":l(`backup.archiveList.delete`,`Delete {{value1}}`,{value1:t.label??t.id}),disabled:_.isPending,onClick:()=>{v(t)}})]})}],rows:S,rowKey:e=>e.id,minWidthPx:760,emptyMessage:l(`backup.archiveList.noArchivesAtThisDestination`,`No archives at this destination yet.`)})}function Bt(e,t){return _(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function Vt(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}o();var Ht=[[`backup`,`listSchedules`]];function Ut({onEdit:i,onOpenRestoreWizard:o}){let{t:s}=J(),{data:c,isLoading:l,isError:u,error:d,refetch:f}=Ge(),p=c??[],m=Te().data??[],h=t(()=>{let e=new Map;for(let t of m)e.set(t.id,t);return e},[m]),[g,_]=a(null),v=n(e=>{_(t=>t===e?null:e)},[]),y=t(()=>Wt({destById:h,expandedId:g,onToggleExpand:v,onEdit:i}),[h,g,v,i]);return l?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle animate-pulse`,children:[r(I,{className:`h-3.5 w-3.5 animate-spin`}),s(`backup.backupEntriesTable.loadingBackupEntries`,`Loading backup entries…`)]}):u?r(be,{title:s(`backup.backupEntriesTable.failedToLoadBackupEntries`,`Failed to load backup entries`),message:d instanceof Error?d.message:s(`backup.backupEntriesTable.unknownError`,`Unknown error`),onRetry:()=>void f()}):p.length===0?r($e,{icon:M,title:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),description:s(`backup.backupEntriesTable.createOneToScheduleBackups`,`Create one to schedule backups across one or more storage locations.`)}):r(K,{columns:y,rows:p,rowKey:e=>e.id,minWidthPx:980,maxBodyHeight:_e,emptyMessage:s(`backup.backupEntriesTable.noBackupEntriesYet`,`No backup entries yet`),onRowClick:e=>i(e),isExpanded:e=>e.id===g,renderExpanded:e=>r(Zt,{row:e,destById:h,...o?{onOpenRestoreWizard:o}:{}})})}function Wt(t){return[{key:`expand`,header:``,width:`w-8`,nowrap:!0,notSortableReason:`Expand control`,render:e=>{let n=t.expandedId===e.id;return r(ye,{variant:`ghost`,size:`sm`,icon:n?ce:ee,"aria-label":n?q.t(`backup.backupEntriesTable.hideArchives`,`Hide archives`):q.t(`backup.backupEntriesTable.showArchives`,`Show archives`),"aria-expanded":n,onClick:n=>{n.stopPropagation(),t.onToggleExpand(e.id)}})}},{key:`entry`,header:q.t(`backup.backupEntriesTable.entry`,`Entry`),sortValue:e=>e.label,render:t=>e(`span`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate font-medium text-foreground`,children:t.label||q.t(`backup.backupEntriesTable.unnamed`,`(unnamed)`)}),t.lastRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:q.t(`backup.backupEntriesTable.lastRun`,{when:new Date(t.lastRunAt).toLocaleString()})})]})},{key:`enabled`,header:q.t(`backup.backupEntriesTable.enabled`,`Enabled`),width:`w-20`,nowrap:!0,sortValue:e=>+!!e.enabled,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Jt,{row:e})})},{key:`databases`,header:q.t(`backup.backupEntriesTable.backsUp`,`Backs up`),nowrap:!1,notSortableReason:`Database badges`,render:e=>r(Z,{databases:kt(e.databases)})},{key:`locations`,header:q.t(`backup.backupEntriesTable.locations`,`Locations`),nowrap:!1,notSortableReason:`Location chips`,render:e=>r(Gt,{row:e,destById:t.destById})},{key:`retention`,header:q.t(`backup.backupEntriesTable.retention`,`Retention`),width:`w-24`,nowrap:!0,sortValue:e=>e.retentionCount,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Yt,{row:e})})},{key:`schedule`,header:q.t(`backup.backupEntriesTable.schedule`,`Schedule`),width:`w-48`,nowrap:!0,sortValue:e=>e.cron,render:e=>r(Kt,{row:e})},{key:`actions`,header:``,align:`right`,nowrap:!0,notSortableReason:`Actions`,render:e=>r(`span`,{onClick:e=>e.stopPropagation(),children:r(Xt,{row:e,onEdit:()=>t.onEdit(e)})})}]}function Gt({row:e,destById:t}){let{t:n}=J();return e.locationIds.length===0?r(`span`,{className:`text-[11px] italic text-danger`,children:n(`backup.backupEntriesTable.noLocations`,`No locations`)}):r(`span`,{className:`flex flex-wrap gap-1`,children:e.locationIds.map(e=>r(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:t.get(e)?.displayName??e},e))})}function Kt({row:t}){let{t:n}=J(),i=t.cron.trim().length>0;return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[e(`span`,{className:`inline-flex items-center gap-1`,children:[r(M,{className:`h-3 w-3 text-foreground-subtle`}),r(`span`,{className:`font-mono text-[11px] text-foreground`,children:i?t.cron:n(`backup.backupEntriesTable.manual`,`Manual`)})]}),i&&t.nextRunAt!==void 0&&r(`span`,{className:`text-[10px] text-foreground-subtle`,children:q.t(`common.nextRun`,{when:new Date(t.nextRunAt).toLocaleString()})})]})}function qt(e){return t(()=>({id:e.id,label:e.label,cron:e.cron,locationIds:[...e.locationIds],retentionCount:e.retentionCount,...e.dataSources?{dataSources:[...e.dataSources]}:{},...e.databases?{databases:[...e.databases]}:{}}),[e])}function Jt({row:e}){let{t}=J(),n=s(),i=Ke({onSuccess:()=>{n.invalidateQueries({queryKey:Ht})}}),a=qt(e);return r(`label`,{className:`inline-flex cursor-pointer items-center`,children:r(v,{className:`accent-primary`,checked:e.enabled,disabled:i.isPending,onChange:e=>i.mutate({...a,enabled:e.target.checked}),"aria-label":t(`backup.backupEntriesTable.enable`,`Enable {{value1}}`,{value1:e.label||e.id})})})}function Yt({row:e}){let{t}=J(),n=s(),o=Ke({onSuccess:()=>{n.invalidateQueries({queryKey:Ht})}}),c=qt(e),[l,u]=a(String(e.retentionCount));return i(()=>{u(String(e.retentionCount))},[e.retentionCount]),r(z,{type:`number`,min:1,max:1e3,value:l,disabled:o.isPending,onChange:e=>u(e.target.value),onBlur:()=>{let t=Number.parseInt(l,10);if(Number.isNaN(t)||t<1){u(String(e.retentionCount));return}t!==e.retentionCount&&o.mutate({...c,enabled:e.enabled,retentionCount:t})},onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&u(String(e.retentionCount))},className:`w-16`,"aria-label":t(`backup.backupEntriesTable.retentionFor`,`Retention for {{value1}}`,{value1:e.label||e.id})})}function Xt({row:t,onEdit:n}){let{t:i}=J(),a=s(),o=D(),c=Ee({onSuccess:()=>{a.invalidateQueries({queryKey:Ht})}}),l=Oe({onMutate:()=>{a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{a.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),a.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),a.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),u=()=>{t.locationIds.length!==0&&l.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount,databases:[...kt(t.databases)]})},d=async()=>{await o({title:i(`backup.backupEntriesTable.deleteBackupEntry`,`Delete backup entry?`),message:i(`backup.backupEntriesTable.willStopRunningExistingArchives`,`"{{value1}}" will stop running. Existing archives are kept.`,{value1:t.label||t.id}),confirmLabel:i(`common.delete`,`Delete`),variant:`warning`})&&c.mutate({id:t.id})};return e(`span`,{className:`flex items-center justify-end gap-1.5`,children:[e(U,{size:`sm`,type:`button`,onClick:u,disabled:l.isPending||t.locationIds.length===0,title:i(`backup.backupEntriesTable.runThisEntryNow`,`Run this entry now`),children:[l.isPending?r(I,{className:`h-3 w-3 animate-spin`}):r(E,{className:`h-3 w-3`}),i(`backup.backupEntriesTable.runNow`,`Run now`)]}),r(ye,{variant:`ghost`,size:`sm`,icon:ie,"aria-label":i(`backup.backupEntriesTable.edit`,`Edit {{value1}}`,{value1:t.label||t.id}),onClick:n}),r(ye,{variant:`ghost`,size:`sm`,icon:F,"aria-label":i(`backup.backupEntriesTable.delete`,`Delete {{value1}}`,{value1:t.label||t.id}),disabled:c.isPending,onClick:()=>{d()}})]})}function Zt({row:t,destById:n,onOpenRestoreWizard:i}){let{t:a}=J();return e(`div`,{className:`space-y-4 rounded-lg border border-border bg-background/30 px-4 py-3`,children:[r(`p`,{className:`text-[11px] font-medium text-foreground-subtle`,children:a(`backup.backupEntriesTable.archivesFor`,{name:t.label||t.id})}),t.locationIds.length===0&&r(`p`,{className:`text-xs italic text-foreground-subtle`,children:a(`backup.backupEntriesTable.thisEntryHasNoLocations`,`This entry has no locations selected.`)}),t.locationIds.map(t=>e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:n.get(t)?.displayName??t}),r(zt,{destinationId:t,restoreSupported:n.get(t)?.restoreSupported??!0,...i?{onOpenRestoreWizard:i}:{}})]},t))]})}function Qt({selected:t,onChange:n,disabled:i=!1,testId:a=`backup-databases`}){let{t:o}=J(),s=Ue().data,c=t.size>0&&Pt(X(t)),l=t.size===0?`Pick at least one.`:c?`Snapshots only: configuration and files are not part of this backup.`:null;return r(G,{label:o(`backup.backupDatabasePicker.whatToBackUp`,`What to back up`),required:!0,...l===null?{}:{description:l},children:r(`div`,{className:`divide-y divide-border rounded border border-border bg-background`,"data-testid":a,children:Ct.map(o=>{let c=jt(o,s),l=i||Mt(o,s,t);return e(`label`,{className:`flex items-start gap-2 px-3 py-2 text-xs ${l?`opacity-60`:`cursor-pointer hover:bg-primary/5`}`,children:[r(v,{checked:t.has(o),disabled:l,onChange:()=>n(Nt(t,o)),"data-testid":`${a}-${o}`}),e(`span`,{className:`min-w-0 flex-1`,children:[r(`span`,{className:`flex flex-wrap items-center gap-1.5 text-foreground`,children:Et(o)}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:c===`absent`?Tt():Ot(o)})]})]},o)})})})}o();function $t({onClose:t}){let{t:n}=J(),i=s(),[o,c]=a(new Set(wt)),l=Oe({onMutate:()=>{i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{i.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),i.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),i.invalidateQueries({queryKey:[[`backup`,`listRuns`]]}),t()}});return r(B,{open:!0,onOpenChange:e=>!e&&t(),children:e(L,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(R,{children:[r(V,{children:n(`backup.backupNowDialog.backUpNow`,`Back up now`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`backup.backupNowDialog.runsOnceAndWritesThe`,`Runs once and writes the archive to every enabled backup location.`)})]}),r(We,{children:e(`div`,{className:`p-4`,children:[r(Qt,{selected:o,onChange:c,disabled:l.isPending,testId:`backup-now-databases`}),l.error&&r(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:l.error.message})]})}),e(W,{children:[r(U,{variant:`outline`,size:`sm`,onClick:t,children:n(`common.cancel`,`Cancel`)}),e(U,{size:`sm`,onClick:()=>{o.size!==0&&l.mutate(Ft(o))},disabled:o.size===0||l.isPending,"data-testid":`backup-now-run`,children:[l.isPending?r(I,{className:`h-3.5 w-3.5 animate-spin`}):r(E,{className:`h-3.5 w-3.5`}),n(`backup.backupNowDialog.backUpNow`,`Back up now`)]})]})]})})}o();function en(e){return e===null?`—`:new Date(e).toLocaleString()}function tn(e){let t=new Blob([`${e.secretKey}\n`],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`camstack-backup-key-${e.keyId}.txt`,r.click(),URL.revokeObjectURL(n)}function nn({revealed:t,onDone:n}){let{t:i}=J(),[o,s]=a(!1),[c,l]=a(!1);return r(B,{open:!0,onOpenChange:e=>!e&&o&&n(),children:e(L,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`border-danger/40`,"aria-labelledby":`backup-key-title`,children:[r(R,{children:r(V,{id:`backup-key-title`,children:i(`backup.encryptionCard.yourKey`,{keyId:t.keyId})})}),e(We,{className:`space-y-3`,children:[e(`p`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 p-2 text-xs text-foreground`,children:[r(w,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),r(`span`,{children:i(`backup.backupEncryptionCard.thisKeyIsShownOnly`,`This key is shown only once. CamStack does not keep it — not the hub, not its database, not its backups. Without it, an encrypted backup cannot be restored by anyone, including you. Store it in a password manager or print it, away from this server.`)})]}),r(`div`,{className:`break-all rounded-md border border-border bg-background p-2 font-mono text-xs text-foreground select-all`,children:t.secretKey}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(U,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard?.writeText(t.secretKey).then(()=>l(!0))},children:[r(h,{className:`mr-1 h-3.5 w-3.5`}),c?i(`backup.backupEncryptionCard.copied`,`Copied`):i(`common.copy`,`Copy`)]}),e(U,{size:`sm`,variant:`outline`,onClick:()=>tn(t),children:[r(oe,{className:`mr-1 h-3.5 w-3.5`}),i(`backup.backupEncryptionCard.downloadAsFile`,`Download as file`)]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[r(v,{checked:o,onChange:e=>s(e.target.checked),className:`accent-primary`}),i(`backup.backupEncryptionCard.iHaveStoredThisKey`,`I have stored this key somewhere safe, off this server.`)]})]}),r(W,{children:r(U,{size:`sm`,disabled:!o,onClick:n,children:i(`backup.backupEncryptionCard.iHaveStoredIt`,`I have stored it`)})})]})})}function rn(){let{t}=J(),n=Re(),i=nt(),o=Me(),s=D(),[l,u]=a(null),[d,f]=a(null),h=n.data?.enabled??!1,g=n.data?.active??null,_=(n.data?.keys??[]).filter(e=>e.retiredAt!==null),v=async()=>{if(await s({title:h?t(`backup.backupEncryptionCard.replaceTheBackupKey`,`Replace the backup key`):t(`backup.backupEncryptionCard.encryptBackups`,`Encrypt backups`),message:h?t(`backup.backupEncryptionCard.aNewKeyIsGenerated`,`A new key is generated and shown once; new backups are encrypted to it. Older backups keep needing the key they were made with — keep that one too.`):t(`backup.backupEncryptionCard.aBackupKeyIsGenerated`,`A backup key is generated and shown once. Every new backup is encrypted to it, and restoring one will ask for it. Existing backups stay as they are.`),confirmLabel:h?t(`backup.backupEncryptionCard.generateANewKey`,`Generate a new key`):t(`backup.backupEncryptionCard.generateTheKey`,`Generate the key`),variant:`warning`})){f(null);try{let e=await i.mutateAsync({});u({keyId:e.keyId,secretKey:e.secretKey})}catch(e){f(e instanceof Error?e.message:String(e))}}},y=async()=>{if(await s({title:t(`backup.backupEncryptionCard.turnBackupEncryptionOff`,`Turn backup encryption off`),message:t(`backup.backupEncryptionCard.newBackupsWillBeWritten`,`New backups will be written unencrypted. Existing encrypted backups still need their key to be restored.`),confirmLabel:t(`backup.backupEncryptionCard.turnOff`,`Turn off`),variant:`danger`})){f(null);try{await o.mutateAsync({}),n.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}};return e(`div`,{className:`space-y-2 rounded-lg border border-border bg-surface p-4`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[h?r(p,{className:`h-4 w-4 text-success`}):r(m,{className:`h-4 w-4 text-foreground-subtle`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`backup.backupEncryptionCard.encryption`,`Encryption`)}),r(`span`,{className:`text-xs text-foreground-subtle`,children:h&&g!==null?t(`backup.backupEncryptionCard.onKeySince`,`On — key {{keyId}}, since {{value2}}`,{keyId:g.keyId,value2:en(g.createdAt)}):t(`backup.backupEncryptionCard.offBackupsAreNotEncrypted`,`Off — backups are not encrypted`)})]}),r(`div`,{className:`flex gap-2`,children:h?e(c,{children:[r(U,{size:`sm`,variant:`outline`,disabled:i.isPending,onClick:()=>void v(),children:t(`backup.backupEncryptionCard.replaceKey`,`Replace key`)}),r(U,{size:`sm`,variant:`outline`,disabled:o.isPending,onClick:()=>void y(),children:t(`backup.backupEncryptionCard.turnOff`,`Turn off`)})]}):r(U,{size:`sm`,disabled:i.isPending,onClick:()=>void v(),children:t(`backup.backupEncryptionCard.enableEncryption`,`Enable encryption`)})})]}),r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`backup.backupEncryptionCard.archivesAreEncryptedOnThis`,`Archives are encrypted on this server before they reach any destination. The server keeps only a public key, so it can encrypt scheduled backups but cannot decrypt them — only your backup key can. Covers the database snapshot, addon data (HomeKit pairing, Matter fabric, Tailscale state) and TLS.`)}),_.length>0&&e(`div`,{className:`text-xs`,children:[r(`p`,{className:`text-foreground-subtle`,children:t(`backup.backupEncryptionCard.olderKeysBackupsMadeWith`,`Older keys (backups made with them still need them):`)}),r(`ul`,{className:`font-mono text-foreground`,children:_.map(t=>e(`li`,{children:[t.keyId,` · `,en(t.createdAt),` → `,en(t.retiredAt)]},t.keyId))})]}),d!==null&&r(`p`,{className:`text-xs text-danger`,children:d}),l!==null&&r(nn,{revealed:l,onDone:()=>{u(null),n.refetch()}})]})}o();var an=[{id:`manual`,labelKey:`backup.cronEditor.presetManual`,cron:``},{id:`hourly`,labelKey:`backup.cronEditor.presetHourly`,cron:`0 * * * *`,descriptionKey:`backup.cronEditor.presetHourlyDesc`},{id:`every-3h`,labelKey:`backup.cronEditor.preset3h`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,labelKey:`backup.cronEditor.preset6h`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,labelKey:`backup.cronEditor.presetDaily`,cron:`0 3 * * *`,descriptionKey:`backup.cronEditor.presetDailyDesc`},{id:`weekly-sun`,labelKey:`backup.cronEditor.presetWeekly`,cron:`0 3 * * 0`,descriptionKey:`backup.cronEditor.presetWeeklyDesc`}];function on(e){let t=e.trim();for(let e of an)if(e.cron===t)return e.id;return`custom`}function sn({value:t,onChange:n,previewCount:o=5,disabled:s=!1}){let{t:c}=J(),l=on(t),[u,d]=a(l===`custom`);i(()=>{l!==`custom`&&d(!1)},[l]);let f=un(t,250),p=we({cron:f,count:o},{enabled:f.trim().length>0}),m=p.data??null,h=e=>{d(!1),n(e.cron)},g=u||l===`custom`;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.schedulePreset`,`Schedule preset`)}),e(`div`,{className:`flex flex-wrap gap-1.5`,children:[an.map(e=>r(U,{variant:`unstyled`,type:`button`,onClick:()=>h(e),disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!u&&l===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.descriptionKey===void 0?e.description??c(e.labelKey):c(e.descriptionKey),children:c(e.labelKey)},e.id)),r(U,{variant:`unstyled`,type:`button`,onClick:()=>{d(!0),t.trim().length===0&&n(`0 3 * * *`)},disabled:s,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(g?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:c(`backup.cronEditor.custom`,`Custom…`)})]})]}),g&&e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`backup.cronEditor.cronExpression5FieldPosix`,`Cron expression (5-field POSIX)`)}),r(z,{type:`text`,value:t,onChange:e=>n(e.target.value),disabled:s,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`backup.cronEditor.format`,`Format:`),` `,r(mt,{i18nKey:`backup.cronEditor.formatLine`,components:{code:r(`span`,{className:`font-mono`})}})]})]}),r(cn,{cron:f,preview:m,loading:p.isFetching})]})}function cn({cron:t,preview:n,loading:i}){let{t:a}=J();return i&&n===null?e(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(I,{className:`h-3 w-3 animate-spin`}),a(`backup.cronEditor.validating`,`Validating…`)]}):n===null?null:n.ok?n.nextRuns.length===0?r(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:a(`backup.cronEditor.noFutureRunsMatchThis`,`No future runs match this expression.`)}):e(`div`,{className:`space-y-1`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.cronEditor.nextRuns`,`Next runs`)}),r(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:n.nextRuns.map((t,n)=>e(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[r(`span`,{className:`text-foreground tabular-nums`,children:new Date(t).toLocaleString()}),r(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:ln(t)})]},`${t}-${n}`))})]}):r(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:n.error??a(`backup.cronEditor.invalidCronExpression`,`Invalid cron expression`)})}function ln(e){let t=e-Date.now();if(t<=0)return q.t(`helpers.relativeTime.now`);let n=Math.floor(t/1e3);if(n<60)return q.t(`helpers.relativeTime.inSeconds`,{count:n});let r=Math.floor(n/60);if(r<60)return q.t(`helpers.relativeTime.inMinutes`,{count:r});let i=Math.floor(r/60);if(i<24)return q.t(`helpers.relativeTime.inHours`,{count:i});let a=Math.floor(i/24);return q.t(`helpers.relativeTime.inDays`,{count:a})}function un(e,n){let[r,o]=a(e),s=t(()=>e,[e]);return i(()=>{let e=setTimeout(()=>o(s),n);return()=>clearTimeout(e)},[s,n]),r}o();var dn=[[`backup`,`listSchedules`]];function fn({entry:n,onClose:i,onSaved:o}){let{t:c}=J(),l=s(),u=Te(),d=u.data??[],[f,p]=a(n?.label??``),[m,h]=a(n?.cron??`0 3 * * *`),[g,_]=a(n?.enabled??!0),[y,b]=a(String(n?.retentionCount??7)),[x,S]=a(new Set(n?.locationIds??[])),[C,w]=a(new Set(n===null?wt:kt(n.databases))),T=Ke({onSuccess:()=>{l.invalidateQueries({queryKey:dn}),o()}}),ee=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},E=Number.parseInt(y,10),D=t(()=>f.trim().length>0&&x.size>0&&C.size>0&&!Number.isNaN(E)&&E>=1&&E<=1e3,[f,x,C,E]),O=()=>{D&&T.mutate({...n?{id:n.id}:{},label:f.trim(),cron:m.trim(),enabled:g,locationIds:Array.from(x),retentionCount:E,databases:[...At(C)]})},k=T.error instanceof Error?T.error.message:null;return r(rt,{open:!0,onClose:i,title:n?c(`backup.backupEntryModal.editBackupEntry`,`Edit backup entry`):c(`backup.backupEntryModal.newBackupEntry`,`New backup entry`),icon:M,error:k,width:`lg`,testId:`backup-entry-form`,footer:e(U,{size:`sm`,type:`button`,onClick:O,disabled:!D||T.isPending,children:[T.isPending?r(I,{className:`h-3.5 w-3.5 animate-spin`}):null,n?c(`common.save`,`Save`):c(`backup.backupEntryModal.createEntry`,`Create entry`)]}),children:e(`div`,{className:`space-y-4`,children:[r(G,{label:c(`backup.backupEntryModal.name`,`Name`),required:!0,children:r(z,{value:f,onChange:e=>p(e.target.value),placeholder:c(`backup.backupEntryModal.nightlyOffsite`,`Nightly offsite`),autoFocus:!0,"data-testid":`backup-entry-name`})}),e(G,{label:c(`backup.backupEntryModal.locationsSelected`,`Locations ({{value1}} selected)`,{value1:String(x.size)}),required:!0,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[r(I,{className:`h-3.5 w-3.5 animate-spin`}),c(`backup.backupEntryModal.loadingLocations`,`Loading locations…`)]}),!u.isLoading&&d.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:c(`backup.backupEntryModal.noBackupsStorageLocationsConfigured`,"No `backups` storage locations configured. Add one in Settings → Storage first.")}),d.length>0&&r(`div`,{className:`max-h-52 divide-y divide-border overflow-y-auto rounded border border-border bg-background`,children:d.map(t=>e(`label`,{className:`flex cursor-pointer items-center justify-between px-3 py-2 text-xs hover:bg-primary/5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(v,{checked:x.has(t.id),onChange:()=>ee(t.id),className:`accent-primary`}),r(`span`,{className:`text-foreground`,children:t.displayName})]}),e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t.kind}),r(`span`,{className:`font-mono text-[10px] text-foreground-subtle`,children:t.id})]})]},t.id))})]}),r(Qt,{selected:C,onChange:w,disabled:T.isPending,testId:`backup-entry-databases`}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(G,{label:c(`backup.backupEntryModal.retentionArchivesKept`,`Retention (archives kept)`),required:!0,children:r(z,{type:`number`,min:1,max:1e3,value:y,onChange:e=>b(e.target.value),"data-testid":`backup-entry-retention`})}),r(G,{label:c(`backup.backupEntryModal.enabled`,`Enabled`),description:c(`backup.backupEntryModal.runOnScheduleWhenChecked`,`Run on schedule when checked.`),children:e(`label`,{className:`inline-flex cursor-pointer items-center gap-2 py-1.5 text-xs text-foreground`,children:[r(v,{checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`,"data-testid":`backup-entry-enabled`}),r(`span`,{children:c(`backup.backupEntryModal.runOnSchedule`,`Run on schedule`)})]})})]}),r(G,{label:c(`backup.backupEntryModal.schedule`,`Schedule`),children:r(sn,{value:m,onChange:h,disabled:T.isPending})})]})})}o();var pn=2e3,mn=5e3;function hn(e){return e.state===`queued`||e.state===`running`}function gn(e){if(e.state===`queued`)return{title:q.t(`backup.backupRunsPanel.cancelQueuedBackupRun`,`Cancel queued backup run?`),message:q.t(`backup.backupRunsPanel.thisRunHasNotStarted`,`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`),confirmLabel:q.t(`backup.backupRunsPanel.cancelRun`,`Cancel run`),variant:`warning`};let t=e.completedDestinationIds.length,n=t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`;return{title:q.t(`backup.backupRunsPanel.stopThisBackupRun`,`Stop this backup run?`),message:q.t(`backup.backupRunsPanel.theHalfWrittenStagingArchive`,`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. {{keptSentence}}`,{keptSentence:n}),confirmLabel:q.t(`backup.backupRunsPanel.stopRun`,`Stop run`),variant:`danger`}}function _n(){let e=D(),[t,i]=a(null),o=He(void 0,{refetchInterval:e=>(e.state.data??[]).some(hn)?pn:mn}),s=Ie({onSettled:()=>{i(null),o.refetch()}}),c=n(async t=>{await e(gn(t))&&(i(t.id),s.mutate({runId:t.id}))},[e,s]);return r(vn,{queryState:o.isError?`error`:o.data===void 0?`pending`:`ready`,runs:o.data??[],cancelingId:t,onCancelRequest:e=>{c(e)},now:Date.now()})}function vn({queryState:t,runs:n,cancelingId:i,onCancelRequest:a,now:o}){let{t:s}=J(),c=t===`ready`&&n.some(hn),l=n.filter(e=>e.state===`running`),u=n.filter(e=>e.state===`queued`),d=n.filter(e=>!hn(e)),f=[...l,...u,...d];return e(`section`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[r(`h2`,{className:`text-xs font-semibold text-foreground`,children:s(`backup.backupRunsPanel.runs`,`Runs`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:s(`backup.backupRunsPanel.aBackupRunIsIn`,`A backup run is in progress`),children:[r(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),s(`backup.runsPanel.live`)]}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:s(`backup.backupRunsPanel.oneRunExecutesAtA`,`One run executes at a time — queued runs wait in line.`)})]}),t===`pending`&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:s(`backup.backupRunsPanel.checkingForBackupRuns`,`Checking for backup runs…`)}),t===`error`&&r(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:s(`backup.backupRunsPanel.couldNotReadBackupRuns`,`Could not read backup runs — the orchestrator did not answer.`)}),t===`ready`&&n.length===0&&r(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:s(`backup.backupRunsPanel.noBackupRunsYetRuns`,`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`)}),t===`ready`&&n.length>0&&r(`div`,{className:`overflow-x-auto`,children:e(`table`,{className:`w-full text-xs min-w-[720px]`,children:[r(`thead`,{children:e(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.run`,`Run`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.state`,`State`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.progress`,`Progress`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.destinations`,`Destinations`)}),r(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:s(`backup.backupRunsPanel.timing`,`Timing`)}),r(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:s(`backup.backupRunsPanel.actions`,`Actions`)})]})}),r(`tbody`,{children:f.map(e=>r(yn,{run:e,canceling:i===e.id,onCancelRequest:a,now:o},e.id))})]})})]})}function yn({run:t,canceling:n,onCancelRequest:i,now:a}){let{t:o}=J(),s=hn(t);return e(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`text-foreground`,title:t.id,children:t.label??r(`span`,{className:`text-foreground-subtle italic`,children:o(`backup.runsPanel.manual`)})})}),e(`td`,{className:`px-3 py-2`,children:[r(bn,{run:t}),t.state===`failed`&&t.error!==void 0&&r(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:t.error,children:t.error})]}),r(`td`,{className:`px-3 py-2`,children:r(xn,{run:t})}),r(`td`,{className:`px-3 py-2`,children:r(Sn,{run:t})}),r(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:r(Cn,{run:t,now:a})}),r(`td`,{className:`px-3 py-2`,children:r(`div`,{className:`flex justify-end`,children:s&&e(U,{variant:`unstyled`,onClick:()=>i(t),disabled:n,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:t.state===`queued`?o(`backup.backupRunsPanel.removeThisRunFromThe`,`Remove this run from the queue before it starts`):o(`backup.backupRunsPanel.stopThisRunTheHalf`,`Stop this run — the half-written archive is discarded`),children:[n?r(I,{className:`h-3 w-3 animate-spin`}):r(f,{className:`h-3 w-3`}),t.state===`queued`?o(`common.cancel`,`Cancel`):o(`backup.backupRunsPanel.stop`,`Stop`)]})})})]})}function bn({run:t}){let{t:n}=J();switch(t.state){case`queued`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[r(d,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.queued`,`Queued`)]});case`running`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[r(I,{className:`h-3 w-3 animate-spin`}),t.phase===`uploading`?n(`backup.backupRunsPanel.uploading`,`Uploading`):n(`backup.backupRunsPanel.buildingArchive`,`Building archive`)]});case`succeeded`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[r(C,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.succeeded`,`Succeeded`)]});case`failed`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[r(S,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.failed`,`Failed`)]});case`cancelled`:return e(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:n(`backup.backupRunsPanel.stoppedBeforeCompletingEveryDestination`,`Stopped before completing every destination — not a success`),children:[r(de,{className:`h-3 w-3`}),n(`backup.backupRunsPanel.stopped`,`Stopped`)]})}}function xn({run:t}){let{t:n}=J();if(t.state===`queued`)return r(`span`,{className:`text-foreground-subtle`,children:t.queuePosition===void 0?r(`span`,{className:`italic`,children:n(`backup.backupRunsPanel.waitingItsTurn`,`waiting its turn`)}):e(`span`,{className:`inline-flex items-center gap-1`,children:[r(`span`,{className:t.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:wn(t.queuePosition)}),n(`backup.backupRunsPanel.inLine`,`in line`)]})});if(t.state===`running`&&t.phase===`building`)return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(me,{className:`h-3 w-3 text-primary`}),r(`span`,{className:`tabular-nums font-medium animate-pulse`,children:Y(t.stagedBytes)}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.stagedSoFar`,`staged so far`)})]});if(t.state===`running`){let i=t.archiveSizeBytes;return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[r(fe,{className:`h-3 w-3 text-primary`}),e(`span`,{className:`tabular-nums font-medium`,children:[Y(t.uploadedBytes),i===void 0?``:` / ${Y(i)}`]}),r(`span`,{className:`text-foreground-subtle`,children:n(`backup.backupRunsPanel.toCurrentDestination`,`to current destination`)})]})}let i=t.archiveSizeBytes??(t.stagedBytes>0?t.stagedBytes:void 0);return i===void 0?r(`span`,{className:`text-foreground-subtle italic`,children:`—`}):r(`span`,{className:`tabular-nums text-foreground`,children:n(`backup.runsPanel.archiveSize`,{size:Y(i)})})}function Sn({run:t}){let{t:n}=J(),i=t.destinationIds.length,a=t.completedDestinationIds.length,o=t.failedDestinationIds.length;return i===0?r(`span`,{className:`text-foreground-subtle italic`,children:n(`backup.backupRunsPanel.notResolvedYet`,`not resolved yet`)}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{className:`text-foreground-subtle`,title:t.destinationIds.join(`, `),children:n(`backup.runsPanel.targets`,{count:i})}),e(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[a>0&&r(`span`,{className:`text-success`,title:n(`backup.backupRunsPanel.keptTheirArchive`,`Kept their archive: {{value1}}`,{value1:t.completedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.completed`,{count:a})}),o>0&&r(`span`,{className:`text-danger`,title:n(`backup.backupRunsPanel.failed2`,`Failed: {{value1}}`,{value1:t.failedDestinationIds.join(`, `)}),children:n(`backup.runsPanel.failedCount`,{count:o})})]})]})}function Cn({run:t,now:n}){let{t:i}=J();return t.state===`queued`?r(`span`,{children:i(`backup.runsPanel.queuedAgo`,{elapsed:Tn(n-t.requestedAt)})}):t.startedAt===void 0?r(`span`,{children:`—`}):t.finishedAt===void 0?r(`span`,{children:i(`backup.runsPanel.runningFor`,{elapsed:Tn(n-t.startedAt)})}):e(`div`,{className:`flex flex-col gap-0.5`,children:[r(`span`,{children:En(t.finishedAt)}),r(`span`,{className:`text-[10px]`,children:i(`backup.runsPanel.took`,{elapsed:Tn(t.finishedAt-t.startedAt)})})]})}function wn(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function Tn(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function En(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}o();var Dn=[[`backup`,`list`]];function On({initialDestinationId:n,initialArchiveId:o,onClose:c,onScheduled:l}){let{t:u}=J(),d=s(),[f,p]=a(n&&o?2:1),[m,h]=a(n),[g,_]=a(o),[v,y]=a(new Set),[S,C]=a(``),{data:w}=Te(),T=w??[],{data:ee,isLoading:E}=ge({destinationId:m??``},{enabled:!!m}),D=ee??[];i(()=>{if(m!==void 0)return;let e=T.filter(e=>e.restoreSupported);e.length===1&&h(e[0].id)},[m,T]);let{data:O}=ut({destinationId:m??``,backupId:g??``},{enabled:!!m&&!!g}),k=t(()=>O?.locations??[],[O]);i(()=>{k.length!==0&&y(e=>e.size===0?new Set(k):e)},[k]);let A=Ae({onSuccess:()=>{d.invalidateQueries({queryKey:Dn}),l(),c()}}),te=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},j=D.find(e=>e.id===g),M=j?.encryption!==void 0,ne=It(j?.databases,O?.sqliteSnapshots),N=Pt(ne),re=!!m&&!!g,F=N||v.size>0,ie=re&&F&&!A.isPending&&(!M||S.trim().length>0),ae=()=>{!m||!g||A.mutate({destinationId:m,backupId:g,...N?{}:{locations:[...v]},...M?{backupSecretKey:S.trim()}:{}})};return r(B,{open:!0,onOpenChange:e=>!e&&c(),children:e(L,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(R,{children:[r(V,{children:u(`backup.restoreWizard.restoreBackup`,`Restore Backup`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:u(`backup.restoreWizard.stepOf`,{step:f,name:f===1?u(`backup.restoreWizard.pickSource`,`pick source`):f===2?u(`backup.restoreWizard.pickLocations`,`pick locations`):u(`backup.restoreWizard.confirmStep`)})})]}),e(We,{children:[f===1&&r(kn,{destinations:T,destinationId:m,onPickDestination:e=>{h(e),_(void 0),y(new Set)},archives:D,archivesLoading:E,archiveId:g,onPickArchive:_}),f===2&&r(An,{locations:k,picked:v,onToggle:te,databases:ne,snapshotsOnly:N}),f===3&&r(jn,{destinationName:T.find(e=>e.id===m)?.displayName??m??``,archive:j,picked:[...v],databases:ne,snapshotsOnly:N}),f===3&&j?.encryption!==void 0&&r(Mn,{keyId:j.encryption.keyId,value:S,onChange:C}),f===3&&A.error&&r(`p`,{role:`alert`,className:`px-4 pb-2 text-xs text-danger`,children:A.error.message})]}),e(W,{className:`justify-between`,children:[r(`div`,{children:f>1&&e(U,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e===3?2:1),children:[r(b,{className:`h-3 w-3`}),u(`common.back`,`Back`)]})}),e(`div`,{className:`flex items-center gap-2`,children:[r(U,{variant:`outline`,size:`sm`,onClick:c,children:u(`common.cancel`,`Cancel`)}),f<3?e(U,{size:`sm`,disabled:f===1&&!re||f===2&&!F,onClick:()=>p(e=>e===1?2:3),children:[u(`common.next`,`Next`),r(x,{className:`h-3 w-3`})]}):e(U,{size:`sm`,onClick:ae,disabled:!ie,children:[A.isPending?r(I,{className:`h-3.5 w-3.5 animate-spin`}):r(P,{className:`h-3.5 w-3.5`}),u(`backup.restoreWizard.scheduleRestore`,`Schedule Restore`)]})]})]})]})})}function kn({destinations:t,destinationId:n,onPickDestination:i,archives:a,archivesLoading:o,archiveId:s,onPickArchive:c}){let{t:l}=J(),u=t.filter(e=>e.restoreSupported);return e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.destination`,`Destination`)}),r(A,{value:n??``,onChange:e=>i(e.target.value),options:[{value:``,label:l(`backup.restoreWizard.selectDestination`,`Select destination…`)},...u.map(e=>({value:e.id,label:`${e.displayName} (${e.kind})`}))]})]}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:l(`backup.restoreWizard.archive`,`Archive`)}),!n&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.pickADestinationFirst`,`Pick a destination first.`)}),n&&o&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:l(`backup.restoreWizard.readingArchives`,`Reading archives…`)}),n&&!o&&a.length===0&&r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l(`backup.restoreWizard.noArchivesAvailableAtThis`,`No archives available at this destination.`)}),n&&a.length>0&&r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:a.map(t=>{let n=s===t.id;return e(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${n?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(Pe,{name:`archive`,checked:n,onChange:()=>c(t.id),className:`accent-primary`}),e(`div`,{children:[e(`div`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[t.encryption!==void 0&&r(p,{className:`h-3 w-3 text-success`,"aria-label":l(`backup.restoreWizard.encryptedKey`,`encrypted (key {{keyId}})`,{keyId:t.encryption.keyId})}),t.label??t.id]}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(t.createdAt).toLocaleString()}),r(`div`,{className:`pt-1`,children:r(Z,{databases:It(t.databases,void 0)})})]})]}),r(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:Y(t.sizeBytes)})]},t.id)})})]})]})}function An({locations:t,picked:n,onToggle:i,databases:a,snapshotsOnly:o}){let{t:s}=J();return o?e(`div`,{className:`space-y-3 p-4`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Z,{databases:a})]}),r(`div`,{className:`rounded border border-info/30 bg-info/10 px-3 py-2 text-[11px] text-info`,children:s(`backup.restoreWizard.snapshotsOnlyRestoringThisArchive`,`Snapshots only: restoring this archive replaces just these databases. It does NOT touch configuration, addons, addon data or certificates.`)})]}):t.length===0?r(`div`,{className:`p-4`,children:r(`div`,{className:`text-xs text-foreground-subtle`,children:s(`backup.restoreWizard.loadingArchiveManifestIfThis`,`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`)})}):e(`div`,{className:`p-4 space-y-3`,children:[e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`backup.restoreWizard.databasesInThisArchive`,`Databases in this archive`)}),r(Z,{databases:a})]}),r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[11px] text-warning`,children:s(`backup.restoreWizard.selectedEntriesWillOverwriteLive`,`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`)}),e(`div`,{className:`space-y-1.5`,children:[r(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:s(`common.apply`,`Apply`)}),r(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:t.map(t=>e(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[r(v,{checked:n.has(t),onChange:()=>i(t),className:`accent-primary`}),r(`span`,{className:`font-mono text-foreground`,children:t}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Fn(t)})]},t))})]})]})}function jn({destinationName:t,archive:n,picked:i,databases:a,snapshotsOnly:o}){let{t:s}=J();return e(`div`,{className:`p-4 space-y-3 text-xs`,children:[r(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-warning`,children:s(`backup.restoreWizard.restoreIsAppliedAtNext`,`Restore is applied at next server boot. Active connections will drop when you restart.`)}),e(`dl`,{className:`space-y-1.5`,children:[r(Nn,{term:`Destination`,value:t}),r(Nn,{term:`Archive`,value:n?.label??n?.id??`—`}),n&&r(Nn,{term:`Created`,value:`${new Date(n.createdAt).toLocaleString()} · ${Y(n.sizeBytes)}`}),e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:s(`backup.restoreWizard.databases`,`Databases`)}),r(`dd`,{className:`text-right`,children:r(Z,{databases:a})})]}),r(Nn,{term:`Locations`,value:o?`none (configuration is not touched)`:i.length>0?i.join(`, `):`— (full archive)`})]})]})}function Mn({keyId:t,value:n,onChange:i}){let{t:a}=J();return e(`div`,{className:`space-y-1.5 px-4 pb-3`,children:[r(`label`,{htmlFor:`restore-backup-key`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:a(`backup.restoreWizard.backupKey`,`Backup key`)}),r(z,{id:`restore-backup-key`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>i(e.target.value),placeholder:a(`backup.restoreWizard.camstackBackupSecretV1`,`camstack-backup-secret-v1:…`),className:`w-full rounded border border-border bg-background px-2 py-1.5 font-mono text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(mt,{i18nKey:`backup.restoreWizard.encryptedTo`,values:{keyId:t},components:{mono:r(`span`,{className:`font-mono`})}})})]})}function Nn({term:t,value:n}){return e(`div`,{className:`flex justify-between gap-3`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`text-foreground font-mono text-right truncate`,children:n})]})}var Pn={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function Fn(e){return Pn[e]??``}o();function In(){let{t}=J(),n=D(),o=ot(),{state:s,openNew:c,openEdit:l,close:u}=et({editKey:`edit`,newKey:`new`}),d=Ge(),f=d.data??[],[p,m]=a(null),[h,g]=a(!1),[_,v]=a(!1),[y,b]=a(!1),x=s.mode===`edit`?f.find(e=>e.id===s.id)??null:null;i(()=>{s.mode===`edit`&&!d.isLoading&&x===null&&u()},[s.mode,d.isLoading,x,u]);let S=s.mode===`new`||s.mode===`edit`&&x!==null,C=async()=>{await n({title:t(`system.backup.restartServerNow`,`Restart server now?`),message:t(`system.backup.activeConnectionsWillDropAnd`,`Active connections will drop and the apply-backup hook will run before boot.`),confirmLabel:t(`system.backup.restart`,`Restart`),variant:`warning`})&&o.mutate({confirm:!0})};return e(bt,{embedded:!0,children:[e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,"data-testid":`backup-actions`,children:[e(U,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>b(!0),"data-testid":`backup-now`,children:[r(E,{className:`h-3.5 w-3.5`}),t(`system.backup.backUpNow`,`Back up now`)]}),e(U,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>g(!0),children:[r(P,{className:`h-3.5 w-3.5`}),t(`system.backup.restore`,`Restore…`)]}),e(U,{size:`sm`,type:`button`,onClick:c,"data-testid":`backup-new-entry`,children:[r(te,{className:`h-3.5 w-3.5`}),t(`system.backup.newEntry`,`New entry`)]})]}),_&&r(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2.5 text-xs text-warning`,children:e(`div`,{className:`flex items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(P,{className:`h-3.5 w-3.5`}),r(`span`,{children:t(`system.backup.restoreScheduledRestartTheServer`,`Restore scheduled. Restart the server to apply.`)})]}),e(U,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{C()},disabled:o.isPending,children:[o.isPending?r(I,{className:`h-3.5 w-3.5 animate-spin`}):r(P,{className:`h-3.5 w-3.5`}),t(`system.backup.restartNow`,`Restart Now`)]})]})}),r(rn,{}),r(_n,{}),r(Ut,{onEdit:e=>l(e.id),onOpenRestoreWizard:e=>m(e)}),S&&r(fn,{entry:x,onClose:u,onSaved:u}),y&&r($t,{onClose:()=>b(!1)}),(p||h)&&r(On,{...p?{initialDestinationId:p.destinationId,initialArchiveId:p.archiveId}:{},onClose:()=>{m(null),g(!1)},onScheduled:()=>v(!0)})]})}var Ln=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Rn={"key-missing":`helpers.keychainNotices.lockedKeyMissing`,"wrong-key":`helpers.keychainNotices.lockedWrongKey`,"key-file-unreadable":`helpers.keychainNotices.lockedKeyFileUnreadable`,"store-unavailable":`helpers.keychainNotices.lockedStoreUnavailable`,"not-initialized":`helpers.keychainNotices.lockedNotInitialized`,"decrypt-failed":`helpers.keychainNotices.lockedDecryptFailed`};function zn(e){let t=Rn[e];return t===void 0?e:q.t(t)}function Bn({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:q.t(`helpers.keychainNotices.locked`,{reason:zn(e.keychain.reason)})}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?q.t(`helpers.keychainNotices.resetPending`,{count:n}):q.t(`helpers.keychainNotices.resetDone`)}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:q.t(`helpers.keychainNotices.sharesBackup`)}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:q.t(`helpers.keychainNotices.recoveryKey`)}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:q.t(`helpers.keychainNotices.rotationPending`)}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:q.t(`helpers.keychainNotices.orphans`,{count:r})}),[...o].sort((e,t)=>Ln.indexOf(e.id)-Ln.indexOf(t.id))}var Vn={dateStyle:`short`,timeStyle:`short`};function Q(e){return e===null?`—`:new Date(e).toLocaleString(void 0,Vn)}function Hn({value:t,copyValue:n,srLabel:i,maxWidthClass:a,className:o}){let s=n??t;return e(`span`,{className:O(`flex min-w-0 items-center gap-0.5`,a),children:[r(`span`,{className:O(`min-w-0 truncate font-mono`,o),title:s,children:t}),r(Fe,{value:s,srLabel:i,className:`h-6 shrink-0 px-1.5`})]})}o();var Un=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]);function Wn(e){return[{key:`at`,header:e(`system.keychainAuditTable.colWhen`),render:e=>Q(e.at)},{key:`action`,header:e(`system.keychainAuditTable.colAction`),render:e=>r(H,{variant:Un.has(e.action)?`warning`:`default`,children:e.action})},{key:`actor`,header:e(`system.keychainAuditTable.colActor`),render:e=>r(`span`,{className:`font-mono`,children:e.actor})},{key:`ref`,header:e(`system.keychainAuditTable.colRef`),render:e=>e.ref===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(Hn,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{key:`detail`,header:e(`system.keychainAuditTable.colDetail`),render:e=>r(`span`,{className:`text-foreground-muted`,children:e.detail??``})}]}function Gn({entries:n}){let{t:i}=J(),[o,s]=a(0),c=t(()=>Wn(i),[i]);if(n===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:i(`common.loading`,`Loading…`)});let l=Math.max(1,Math.ceil(n.length/25)),u=Math.min(o,l-1),d=u*25,f=n.slice(d,d+25);return e(`div`,{className:`space-y-2`,children:[r(K,{columns:c,rows:f,rowKey:e=>e.id,minWidthPx:760,emptyMessage:i(`secrets.keychainAuditTable.nothingHasBeenAuditedYet`,`Nothing has been audited yet.`)}),n.length>25&&e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:i(n.length>=500?`system.keychainAuditTable.rangeRecent`:`system.keychainAuditTable.range`,{from:d+1,to:d+f.length,total:n.length})}),e(`span`,{className:`inline-flex items-center gap-1`,children:[r(U,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:u===0,onClick:()=>s(u-1),children:r(ne,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),e(`span`,{className:`tabular-nums`,children:[u+1,` / `,l]}),r(U,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:u>=l-1,onClick:()=>s(u+1),children:r(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function Kn(e,t){switch(e){case`locked`:return r(U,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:q.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return r(U,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:q.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return r(U,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:q.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return r(U,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:q.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return r(U,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:q.t(`secrets.keychainNoticeContent.review`,`Review`)});case`shares-backup`:return null}}function qn(e,t){switch(e){case`locked`:return r(`p`,{children:q.t(`secrets.keychainNoticeContent.noValueCanBeRead`,`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`)});case`reset`:return t.reset===null?null:r(Jn,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return r(`p`,{children:r(mt,{i18nKey:`secrets.keychainNoticeContent.backupKeyFile`,components:{code:r(`code`,{className:`font-mono`})}})});case`recovery-key`:return r(`p`,{children:q.t(`secrets.keychainNoticeContent.withoutACopyOfThe`,`Without a copy of the master key, the stored values cannot be recovered.`)});case`rotation-pending`:return r(`p`,{children:q.t(`secrets.keychainNoticeContent.theKeychainUnlockedWithA`,`The keychain unlocked with a previous key. Rotate to move onto the configured one.`)});case`orphans`:return null}}function Jn({reset:t,pending:n}){let{t:i}=J(),a=t.actor===`trigger-file`?i(`secrets.keychainNoticeContent.resetByTrigger`):i(`secrets.keychainNoticeContent.resetByAdmin`,{actor:t.actor});return e(`div`,{className:`space-y-1.5`,children:[r(`p`,{children:i(`secrets.keychainNoticeContent.resetDetail`,{when:Q(t.at),by:a,archived:t.archived})}),n.length>0&&r(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:n.map(t=>e(`li`,{className:`break-all`,children:[t.owner,` · `,t.scope,` · `,t.fieldPath]},t.ref))})]})}o();var Yn=2,Xn={danger:{icon:le,text:`text-danger`,border:`border-danger/40`},warning:{icon:w,text:`text-warning`,border:`border-warning/40`},info:{icon:re,text:`text-info`,border:`border-border`}};function Zn({notices:t,renderAction:n,renderDetail:i}){let{t:o}=J(),[s,c]=a(!1),l=t[0];if(l===void 0)return null;let u=t.length>Yn,d=u&&!s?t.slice(0,1):t,f=t.length-d.length;return e(`section`,{"aria-label":o(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:O(`rounded-lg border bg-surface`,Xn[l.tone].border),children:[r(`ul`,{className:`divide-y divide-border`,children:d.map(e=>r(Qn,{notice:e,action:n(e.id),detail:i(e.id)},e.id))}),u&&r(`div`,{className:`border-t border-border px-3 py-1`,children:e(U,{size:`sm`,variant:`ghost`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[r(ce,{className:O(`h-3.5 w-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0}),s?o(`secrets.keychainNotices.showLess`,`Show less`):o(`secrets.keychainNotices.more`,`{{hidden}} more`,{hidden:f})]})})]})}function Qn({notice:t,action:n,detail:i}){let{t:o}=J(),[s,c]=a(!1),l=Xn[t.tone],u=l.icon,d=i!=null,f=`keychain-notice-${t.id}`;return e(`li`,{className:`px-3 py-2`,children:[e(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[e(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[r(u,{className:O(`mt-0.5 h-3.5 w-3.5 shrink-0`,l.text),"aria-hidden":!0}),r(`span`,{className:`min-w-0 break-words`,children:t.title})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[d&&r(U,{size:`sm`,variant:`ghost`,"aria-expanded":s,"aria-controls":f,onClick:()=>c(e=>!e),children:o(`secrets.keychainNotices.details`,`Details`)}),n]})]}),d&&s&&r(`div`,{id:f,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:i})]})}var $n={"mounted-file":`Mounted key file (/run/secrets)`,"previous-mounted-file":`Previous mounted key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},er=8;function tr({status:t,busy:n,onDownload:i,onRotate:a,onPurge:o}){let{t:s}=J(),c=t.keychain.state===`locked`,l=t.keySource??t.configuredSource;return r(De,{headingId:`keychain-status`,title:s(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:ue,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[t.retiredWraps>0&&r(U,{size:`sm`,variant:`ghost`,disabled:n||c,onClick:o,children:s(`secrets.keychainStatusCard.purge`,{count:t.retiredWraps})}),r(U,{size:`sm`,variant:`outline`,disabled:n||c,onClick:a,children:s(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),r(U,{size:`sm`,variant:`outline`,disabled:n||c,onClick:i,children:s(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:e(`dl`,{className:`${u} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[e(nr,{label:s(`secrets.keychainStatusCard.state`,`State`),children:[c?e(H,{variant:`danger`,className:`gap-1`,children:[r(p,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.locked`,`Locked`)]}):e(H,{variant:`success`,className:`gap-1`,children:[r(g,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.unlocked`,`Unlocked`)]}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:s(`common.stored`,{count:t.secretCount})})]}),e(nr,{label:s(`secrets.keychainStatusCard.keySource`,`Key source`),children:[r(`span`,{className:`block`,children:$n[l.kind]}),l.path!==void 0&&r(Hn,{value:l.path,srLabel:`key path`})]}),r(nr,{label:s(`secrets.keychainStatusCard.fingerprint`,`Fingerprint`),children:t.fingerprint===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:`inline-flex items-center gap-0.5`,children:[r(`span`,{className:`font-mono`,title:t.fingerprint,children:t.fingerprint.slice(0,er)}),r(Fe,{value:t.fingerprint,srLabel:`fingerprint`})]})}),r(nr,{label:s(`secrets.keychainStatusCard.recoveryKey`,`Recovery key`),children:t.recoveryKeyDownloadedAt===null?r(H,{variant:`warning`,children:s(`secrets.keychainStatusCard.notTaken`,`Not taken`)}):r(`span`,{children:s(`secrets.keychainStatusCard.taken`,{when:Q(t.recoveryKeyDownloadedAt)})})})]})})}function nr({label:t,children:n}){return e(`div`,{className:`min-w-0 text-xs`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:n})]})}o();var rr=1e3;function ir({revealed:t,onClose:n}){let{t:o}=J(),[s,l]=a(Qe);i(()=>{if(t===null)return;let e=Date.now();l(Qe);let r=setTimeout(n,Qe),i=setInterval(()=>l(Math.max(0,Qe-(Date.now()-e))),rr);return()=>{clearTimeout(r),clearInterval(i)}},[t,n]);let u=Math.ceil(s/1e3);return r(B,{open:t!==null,onOpenChange:e=>!e&&n(),children:r(L,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(c,{children:[e(R,{children:[r(V,{className:`break-all`,children:t.entry.fieldPath}),e(ke,{className:`break-all`,children:[t.entry.owner,` · `,t.entry.scope]})]}),r(We,{children:r(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:t.value})}),e(W,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`secrets.revealDialog.recorded`,{seconds:u})}),e(`div`,{className:`flex justify-end gap-2`,children:[r(Fe,{value:t.value,label:o(`common.copy`,`Copy`),srLabel:`revealed value`}),r(U,{size:`sm`,variant:`outline`,onClick:n,children:o(`secrets.revealDialog.hide`,`Hide`)})]})]})]})})})}var ar={orphan:{labelKey:`secrets.secretsTableState.usageOrphan`,variant:`warning`,hintKey:`secrets.secretsTableState.usageOrphanHint`,rank:0},unknown:{labelKey:`secrets.secretsTableState.usageUnknown`,variant:`default`,hintKey:`secrets.secretsTableState.usageUnknownHint`,rank:1},"in-use":{labelKey:`secrets.secretsTableState.usageInUse`,variant:`success`,hintKey:`secrets.secretsTableState.usageInUseHint`,rank:2}},or=[{id:`all`,labelKey:`common.all`},{id:`in-use`,labelKey:`secrets.secretsTableState.usageInUse`},{id:`orphan`,labelKey:`secrets.secretsTableState.filterOrphans`},{id:`unknown`,labelKey:`secrets.secretsTableState.usageUnknown`}],sr=`system`;function cr(t){let{t:n}=J(),{secrets:i,filter:a,onFilterChange:o,onDeleteOrphans:s,deleting:c,locked:l}=t;if(i===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`common.loading`,`Loading…`)});let u=e=>e===`all`?i.length:i.filter(t=>t.usage===e).length,d=i.filter(e=>e.usage===`orphan`).map(e=>e.ref),f=a===`all`?i:i.filter(e=>e.usage===a);return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":n(`secrets.secretsTable.filterByUsage`,`Filter by usage`),children:or.map(t=>e(U,{size:`sm`,variant:a===t.id?`secondary`:`ghost`,"aria-pressed":a===t.id,className:a===t.id?`ring-1 ring-border`:void 0,onClick:()=>o(t.id),children:[n(t.labelKey),r(`span`,{className:`text-foreground-subtle tabular-nums`,children:u(t.id)})]},t.id))}),d.length>0&&e(U,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:c||l,onClick:()=>s(d),children:[r(F,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),r(K,{columns:ur(t),rows:f,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:_e,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:i.length===0?n(`secrets.secretsTable.noValueIsStoredIn`,`No value is stored in the keychain yet.`):n(`secrets.secretsTable.noStoredValueMatchesThis`,`No stored value matches this filter.`)})]})}function lr({owner:t}){let{t:n}=J();return e(`span`,{className:`flex items-center gap-2`,children:[r(yt,{addonId:t,fallback:t===sr?y:k,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),r(`span`,{className:`font-medium`,children:t===sr?n(`secrets.secretsTable.hubSystem`,`Hub (system)`):t})]})}function ur({locked:t,onReveal:n,revealing:i}){return[{key:`owner`,header:q.t(`secrets.secretsTable.owner`,`Owner`),render:e=>r(lr,{owner:e.owner}),sortValue:e=>e.owner},{key:`scope`,header:q.t(`secrets.secretsTable.scope`,`Scope`),render:e=>r(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{key:`field`,header:q.t(`secrets.secretsTable.field`,`Field`),render:e=>r(Hn,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{key:`updated`,header:q.t(`secrets.secretsTable.updated`,`Updated`),render:e=>Q(e.updatedAt),sortValue:e=>e.updatedAt},{key:`last-read`,header:q.t(`secrets.secretsTable.lastRead`,`Last read`),render:e=>Q(e.lastReadAt),sortValue:e=>e.lastReadAt},{key:`status`,header:q.t(`secrets.secretsTable.status`,`Status`),render:e=>r(H,{variant:ar[e.usage].variant,title:q.t(ar[e.usage].hintKey),children:q.t(ar[e.usage].labelKey)}),sortValue:e=>ar[e.usage].rank},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:a=>e(U,{size:`sm`,variant:`ghost`,disabled:t||i,"aria-label":q.t(`secrets.secretsTable.reveal`,`Reveal {{fieldPath}}`,{fieldPath:a.fieldPath}),title:t?q.t(`secrets.secretsTable.theKeychainIsLocked`,`The keychain is locked`):q.t(`secrets.secretsTable.revealAudited`,`Reveal (audited)`),onClick:()=>n(a),children:[r(T,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),q.t(`secrets.secretsTable.reveal2`,`Reveal`)]})}]}function dr(e){return e instanceof Error?e.message:String(e)}function fr(e){let{t}=J(),n=D(),r=N(),i=ae(),a=at(),o=Be(),s=ct(),c=ze(),l=Ze(),u=qe(),d=async(t,n)=>{try{await n()}catch(e){await r({title:t,message:dr(e),variant:`danger`})}e()};return{busy:a.isPending||o.isPending||s.isPending||c.isPending,deleting:u.isPending,download:async()=>{await n({title:t(`secrets.useKeychainActions.downloadTitle`),message:t(`secrets.useKeychainActions.downloadMessage`),confirmLabel:t(`secrets.useKeychainActions.downloadConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.downloadRefused`),async()=>{let e=await a.mutateAsync({});await i({title:t(`secrets.useKeychainActions.recoveryTitle`,{fingerprint:e.fingerprint}),message:t(`secrets.useKeychainActions.recoveryMessage`),defaultValue:e.key,readOnly:!0,confirmLabel:t(`secrets.useKeychainActions.recoveryDone`)})})},rotate:async()=>{await n({title:t(`secrets.useKeychainActions.rotateTitle`),message:t(`secrets.useKeychainActions.rotateMessage`),confirmLabel:t(`secrets.useKeychainActions.rotateConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.rotateRefused`),async()=>{let e=await o.mutateAsync({});await r({title:t(`secrets.useKeychainActions.rotatedTitle`),message:t(`secrets.useKeychainActions.rotatedMessage`,{fingerprint:e.fingerprint})})})},purge:async()=>{await n({title:t(`secrets.useKeychainActions.purgeTitle`),message:t(`secrets.useKeychainActions.purgeMessage`),confirmLabel:t(`secrets.useKeychainActions.purgeConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.purgeRefused`),async()=>{await s.mutateAsync({})})},reset:async()=>{await i({title:t(`secrets.useKeychainActions.resetTitle`),message:t(`secrets.useKeychainActions.resetMessage`,{confirmation:`RESET KEYCHAIN`}),confirmLabel:t(`secrets.useKeychainActions.resetConfirm`),validate:e=>e===`RESET KEYCHAIN`?null:t(`secrets.useKeychainActions.resetMismatch`)})===`RESET KEYCHAIN`&&await d(t(`secrets.useKeychainActions.resetRefused`),async()=>{await c.mutateAsync({confirm:se})})},acknowledgeReset:async()=>{await d(t(`secrets.useKeychainActions.dismissFailed`),async()=>{await l.mutateAsync({})})},deleteOrphans:async e=>{await n({title:t(`secrets.useKeychainActions.orphansTitle`,{count:e.length}),message:t(`secrets.useKeychainActions.orphansMessage`),confirmLabel:t(`secrets.useKeychainActions.orphansConfirm`),variant:`danger`})&&await d(t(`secrets.useKeychainActions.orphansRefused`),async()=>{let n=await u.mutateAsync({refs:[...e]});n.kept.length>0&&await r({title:t(`secrets.useKeychainActions.keptTitle`),message:t(`secrets.useKeychainActions.keptMessage`,{deleted:n.deleted.length,kept:n.kept.length})})})}}}o();var pr=`secretsView`;function mr(){let[e,t]=ht();return[e.get(pr)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(pr):r.set(pr,n),t(r,{replace:!0})}]}function hr(){let{t:i}=J(),o=Se({}),s=Ye({}),c=lt({limit:500}),l=ve({}),u=st(),d=N(),[f,p]=mr(),[m,h]=a(`all`),[g,_]=a(null),v=fr(()=>{o.refetch(),s.refetch(),c.refetch(),l.refetch()}),y=o.data?.keychain.state===`locked`,b=t(()=>(s.data??[]).filter(e=>e.usage===`orphan`).length,[s.data]),x=t(()=>o.data===void 0?[]:Bn({status:o.data,reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry.length??0,orphans:b}),[o.data,l.data,b]),S={reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry??[],busy:v.busy,onReset:()=>void v.reset(),onAcknowledgeReset:()=>void v.acknowledgeReset(),onDownload:()=>void v.download(),onRotate:()=>void v.rotate(),onShowOrphans:()=>{h(`orphan`),p(`values`)}},C=async e=>{try{_({entry:e,value:(await u.mutateAsync({ref:e.ref})).value}),s.refetch()}catch(e){await d({title:i(`admin.system.secrets.revealRefused`,`Reveal refused`),message:dt(e),variant:`danger`})}},w=n(()=>_(null),[]);return e(bt,{embedded:!0,icon:ue,title:i(`admin.system.secrets.secrets`,`Secrets`),subtitle:i(`admin.system.secrets.passwordsTokensAndKeysEncrypted`,`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`),children:[r(Zn,{notices:x,renderAction:e=>Kn(e,S),renderDetail:e=>qn(e,S)}),o.data!==void 0&&r(tr,{status:o.data,busy:v.busy,onDownload:S.onDownload,onRotate:S.onRotate,onPurge:()=>void v.purge()}),e(Je,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[e(it,{children:[r(Xe,{value:`values`,children:i(`admin.system.secrets.storedValues`,`Stored values`)}),r(Xe,{value:`audit`,children:i(`admin.system.secrets.audit`,`Audit`)})]}),r(tt,{value:`values`,children:r(cr,{secrets:s.data,locked:y,filter:m,onFilterChange:h,onReveal:e=>void C(e),revealing:u.isPending,onDeleteOrphans:e=>void v.deleteOrphans(e),deleting:v.deleting})}),r(tt,{value:`audit`,children:r(Gn,{entries:c.data})})]}),r(ir,{revealed:g,onClose:w})]})}o();function gr(e){return Object.entries(e).map(([e,t])=>`${e} ${t}`).join(` · `)}function _r(e){return e.reduce((e,t)=>e+Object.values(t.stores).reduce((e,t)=>e+t,0),0)}function vr(){let{t}=J(),n=D(),i=Ne(),[o,s]=a(null),[u,d]=a(null),f=async e=>{d(null);try{s(await i.mutateAsync({confirm:e}))}catch(e){d(e instanceof Error?e.message:String(e))}},p=async()=>{o===null||o.status!==`dry-run`||await n({title:t(`systemPage.deletedDevices.confirmTitle`,`Delete the data of deleted devices?`),message:o.devices.map(e=>`#${e.deviceId}: ${gr(e.stores)}`).join(`
2
- `),confirmLabel:t(`systemPage.deletedDevices.confirmLabel`,`Delete`),variant:`danger`})&&await f(!0)},m=[{key:`device`,header:t(`systemPage.deletedDevices.device`,`Device`),render:e=>`#${e.deviceId}`},{key:`stores`,header:t(`systemPage.deletedDevices.stores`,`Data held`),nowrap:!1,render:e=>gr(e.stores)}];return e(`div`,{className:`space-y-4`,"data-testid":`deleted-devices-data`,children:[r(`p`,{className:`text-sm text-foreground-muted`,children:t(`systemPage.deletedDevices.intro`,`Data that still belongs to devices that were deleted before deletions were recorded: footage, events, history and per-addon settings. Scanning deletes nothing; deleting asks first and shows what goes.`)}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(U,{variant:`outline`,onClick:()=>void f(!1),disabled:i.isPending,"data-testid":`deleted-devices-scan`,children:[i.isPending?r(I,{className:`mr-2 h-4 w-4 animate-spin`}):r(l,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.scan`,`Scan`)]}),o?.status===`dry-run`&&o.devices.length>0?e(U,{variant:`danger`,onClick:()=>void p(),disabled:i.isPending,"data-testid":`deleted-devices-delete`,children:[r(F,{className:`mr-2 h-4 w-4`}),t(`systemPage.deletedDevices.delete`,`Delete the data of {{count}} devices…`,{count:o.devices.length})]}):null]}),u===null?null:r(`p`,{className:`text-sm text-danger`,children:u}),o?.status===`skipped`?r(`p`,{className:`text-sm text-warning`,"data-testid":`deleted-devices-skipped`,children:t(`systemPage.deletedDevices.skipped`,`Nothing was listed or deleted: the device list could not be trusted ({{reason}}). Try again.`,{reason:o.reason??``})}):null,o!==null&&o.status!==`skipped`?e(c,{children:[r(`p`,{className:`text-sm`,"data-testid":`deleted-devices-summary`,children:o.status===`cleaned`?t(`systemPage.deletedDevices.cleaned`,`Deleted {{rows}} items of {{count}} devices.`,{rows:_r(o.devices),count:o.devices.length}):t(`systemPage.deletedDevices.found`,`{{count}} deleted devices still hold {{rows}} items.`,{rows:_r(o.devices),count:o.devices.length})}),r(K,{columns:m,rows:o.devices,rowKey:e=>e.deviceId,emptyMessage:t(`systemPage.deletedDevices.none`,`No data belongs to a deleted device.`)}),o.unreachable.length>0?r(`p`,{className:`text-xs text-foreground-muted`,children:t(`systemPage.deletedDevices.unreachable`,`Not asked (unreachable): {{names}}`,{names:o.unreachable.join(`, `)})}):null]}):null]})}var yr=`view`,br=`kinds`,xr=`deleted-devices`;function Sr(){let{t}=J(),[n,i]=ht(),a=n.get(`view`)===`deleted-devices`?xr:br;return e(`div`,{className:u,children:[e(`div`,{className:`mb-3 space-y-2`,children:[r(Je,{appearance:`pills`,value:a,onValueChange:e=>{i(t=>{let n=new URLSearchParams(t);return e===`kinds`?n.delete(yr):n.set(yr,e),n},{replace:!0})},children:e(it,{className:`flex flex-wrap gap-1`,children:[r(Xe,{value:br,children:t(`systemPage.data.viewKinds`,`Record kinds`)}),r(Xe,{value:xr,children:t(`systemPage.data.viewDeletedDevices`,`Deleted devices`)})]})}),a===`kinds`?r(`p`,{className:`text-xs text-foreground-muted`,children:t(`systemPage.data.recordsUnifiedIntro`,`Every declared record kind on this hub. Entry kinds can be added, edited and deleted; the rest are read-only. Secret fields are redacted.`)}):null]}),r(a===`kinds`?he:vr,{})]})}var Cr={applied:`success`,failed:`danger`,blocked:`warning`,held:`warning`,running:`info`,pending:`default`,"skipped-newer":`neutral`},wr={applied:`migrations.status.applied`,failed:`migrations.status.failed`,blocked:`migrations.status.blocked`,held:`migrations.status.held`,running:`migrations.status.running`,pending:`migrations.status.pending`,"skipped-newer":`migrations.status.skippedNewer`};function Tr({status:e}){let{t}=J();return r(H,{variant:Cr[e],className:`text-[10px]`,children:t(wr[e])})}var Er=[`failed`,`blocked`,`held`,`running`,`pending`,`applied`,`skipped-newer`];function Dr(e){return Er.indexOf(e)}function Or(e,t){let n=new Map(t.map(e=>[e.meta.id,e])),r=new Map;for(let t of e){let e=n.get(t.id)??null;r.set(t.id,{id:t.id,owner:t.owner,status:t.status,meta:t.meta??e?.meta??null,ledger:t,pending:e,database:t.database,seq:t.seq,appliedAt:t.appliedAt,reason:t.reason??e?.reason??null,error:t.error})}for(let e of t)r.has(e.meta.id)||r.set(e.meta.id,{id:e.meta.id,owner:e.meta.owner,status:e.state===`pending`?`pending`:e.state,meta:e.meta,ledger:null,pending:e,database:e.database,seq:e.meta.seq,appliedAt:null,reason:e.reason,error:null});return[...r.values()]}function kr(e){return e.owner===`hub`&&e.meta!==null&&e.meta.bodyKind!==`procedure`}o();var Ar={searchText:e=>[e.id,e.owner,e.meta?.description??``],facetGroups:[{id:`owner`,value:e=>e.owner},{id:`status`,value:e=>e.status}]};function jr(e){if(e===null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function Mr({rows:n,onOpen:i}){let{t:a}=J(),o=Ve(n,Ar),s=t(()=>[{key:`id`,header:a(`migrations.col.id`,`Migration`),sortValue:e=>e.id,render:t=>e(`div`,{className:`min-w-0 max-w-[22rem]`,children:[r(`div`,{className:`truncate font-mono text-xs text-foreground`,title:t.id,children:t.id}),t.meta!==null&&r(`div`,{className:`truncate text-[10px] text-foreground-subtle`,title:t.meta.description,children:t.meta.description})]})},{key:`owner`,header:a(`migrations.col.owner`,`Owner`),sortValue:e=>e.owner,render:e=>e.owner},{key:`status`,header:a(`migrations.col.status`,`Status`),sortValue:e=>Dr(e.status),render:e=>r(Tr,{status:e.status})},{key:`level`,header:a(`migrations.col.level`,`Level`),sortValue:e=>e.meta?.level??null,render:e=>e.meta?.level??`—`},{key:`body`,header:a(`migrations.col.body`,`Body`),sortValue:e=>e.meta?.bodyKind??null,render:e=>e.meta?.bodyKind??`—`},{key:`applied`,header:a(`migrations.col.applied`,`Applied`),sortValue:e=>e.appliedAt,render:e=>r(`span`,{className:`text-foreground-subtle`,children:jr(e.appliedAt)})}],[a]),c=a(`migrations.label`,`migrations`);return e(`div`,{className:`space-y-3`,children:[r(xe,{state:o.state,facets:o.facets,groups:o.groups.map(e=>({...e,label:e.id===`owner`?a(`migrations.col.owner`):a(`migrations.col.status`),...e.id===`status`?{facetLabel:e=>a(wr[e])}:{}})),labels:{searchPlaceholder:a(`migrations.searchPlaceholder`,`Search migrations`),searchLabel:a(`migrations.searchLabel`,`Search migrations`),facetsLabel:a(`migrations.facetsLabel`,`Filter migrations`),clearLabel:a(`migrations.clearFilters`,`Clear filters`)},onSearch:o.setSearch,onToggleFacet:o.toggleFacet,onToggleGroupFacet:o.toggleGroupFacet,onClear:o.clear}),r(K,{columns:s,rows:o.rows,rowKey:e=>e.id,minWidthPx:820,maxBodyHeight:_e,defaultSort:{columnKey:`status`,dir:`asc`},pageSize:25,onRowClick:e=>i(e.id),paginationLabels:{navLabel:a(`migrations.pagesLabel`,`Migration pages`),previous:a(`migrations.previousPage`,`Previous`),next:a(`migrations.nextPage`,`Next`),range:(e,t,n)=>a(`migrations.range`,`{{from}}–{{to}} of {{total}}`,{from:e,to:t,total:n})},emptyMessage:o.active?a(`migrations.noMatch`,`No {{label}} match the filters.`,{label:c}):a(`migrations.empty`,`No migrations.`)})]})}function $({label:t,children:n}){return e(`div`,{className:`grid gap-0.5 py-1.5 sm:grid-cols-[10rem_1fr] sm:gap-3`,children:[r(`dt`,{className:`text-xs text-foreground-muted`,children:t}),r(`dd`,{className:`min-w-0 break-words text-sm text-foreground`,children:n})]})}function Nr({value:e}){return e===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`pre`,{className:`max-h-40 overflow-auto rounded-md bg-surface p-2 font-mono text-xs text-foreground`,children:JSON.stringify(e,null,2)})}function Pr({id:t}){let{t:n}=J(),i=Le.migrations.dryRun.useQuery({id:t},{enabled:!1});return e(`div`,{className:`space-y-2`,children:[e(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),disabled:i.isFetching,children:[i.isFetching&&r(I,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),n(`migrations.detail.dryRun`,`Run a dry run`)]}),r(`p`,{className:`text-xs text-foreground-muted`,children:n(`migrations.detail.dryRunHint`,`Runs the migration in a transaction and rolls it back. Nothing is written.`)}),i.isError&&r(be,{title:n(`migrations.detail.dryRunFailed`,`The dry run could not run`),message:i.error.message}),i.data!==void 0&&e(`div`,{className:`space-y-1 text-xs`,"data-testid":`dry-run-result`,children:[r(`div`,{className:`text-foreground`,children:i.data.ok?n(`migrations.detail.dryRunOk`,`Would change {{count}} rows`,{count:i.data.rowsChanged}):i.data.error??n(`migrations.detail.dryRunThrows`,`It would fail`)}),i.data.tables.map(t=>e(`div`,{className:`font-mono text-foreground-muted`,children:[t.table,`: `,t.before,` → `,t.after]},t.table))]})]})}function Fr({row:t,knownIds:n,onOpenRow:i,onClose:a}){let{t:o}=J(),s=r(`span`,{className:`text-foreground-subtle`,children:`—`}),l=t?.meta??null,u=t?.ledger??null;return r(B,{open:t!==null,onOpenChange:e=>!e&&a(),children:r(L,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(c,{children:[e(R,{children:[r(V,{className:`break-all font-mono text-base`,children:t.id}),r(ke,{children:l?.description??o(`migrations.detail.noMeta`,`No catalogue on this hub lists this migration.`)})]}),e(We,{children:[e(`dl`,{className:`divide-y divide-border-subtle`,children:[r($,{label:o(`migrations.col.status`,`Status`),children:r(Tr,{status:t.status})}),t.error!==null&&r($,{label:o(`migrations.detail.error`,`Error`),children:r(`span`,{className:`text-danger`,"data-testid":`migration-error`,children:t.error})}),t.reason!==null&&r($,{label:o(`migrations.detail.reason`,`Reason`),children:t.reason}),r($,{label:o(`migrations.col.owner`,`Owner`),children:t.owner}),r($,{label:o(`migrations.col.level`,`Level`),children:l?.level??s}),r($,{label:o(`migrations.col.body`,`Body`),children:l?.bodyKind??s}),e($,{label:o(`migrations.detail.store`,`Store`),children:[l?.store??s,` · `,t.database]}),r($,{label:o(`migrations.detail.scope`,`Scope`),children:l?.scope??s}),r($,{label:o(`migrations.detail.onFailure`,`On failure`),children:l?.onFailure??s}),r($,{label:o(`migrations.detail.seq`,`Sequence in owner`),children:t.seq}),r($,{label:o(`migrations.detail.fixtureMark`,`Fixture mark`),children:l?.fixtureMark??s}),r($,{label:o(`migrations.detail.dependsOn`,`Depends on`),children:l===null||l.dependsOn.length===0?s:r(`div`,{className:`flex flex-wrap gap-1.5`,children:l.dependsOn.map(e=>n.has(e)?r(U,{type:`button`,variant:`outline`,size:`sm`,className:`font-mono text-xs`,onClick:()=>i(e),children:e},e):r(H,{variant:`neutral`,className:`font-mono text-xs`,children:e},e))})}),r($,{label:o(`migrations.col.applied`,`Applied`),children:jr(t.appliedAt)}),r($,{label:o(`migrations.detail.attempts`,`Attempts`),children:u?.attempts??s}),r($,{label:o(`migrations.detail.codeVersion`,`Code version`),children:u?.codeVersion??s}),r($,{label:o(`migrations.detail.node`,`Node`),children:u?.nodeId??s}),r($,{label:o(`migrations.detail.boot`,`Boot (snapshot id prefix)`),children:r(`span`,{className:`font-mono text-xs`,children:u?.bootId??s})}),r($,{label:o(`migrations.detail.planSummary`,`Rows changed`),children:r(Nr,{value:u?.planSummary??null})}),r($,{label:o(`migrations.detail.progress`,`Progress`),children:r(Nr,{value:u?.progress??null})})]}),kr(t)&&r(Pr,{id:t.id},t.id)]}),r(W,{children:r(U,{type:`button`,variant:`outline`,onClick:a,children:o(`migrations.detail.close`,`Close`)})})]})})})}o();var Ir=`migration`;function Lr(){let{t:n}=J(),i=je(`migrations`),a=i===`present`,o=Le.migrations.listLedger.useQuery({},{enabled:a}),s=Le.migrations.listPending.useQuery({},{enabled:a}),[c,l]=ht(),d=c.get(Ir),f=t(()=>o.data===void 0||s.data===void 0?null:Or(o.data.entries,s.data.pending),[o.data,s.data]),p=t(()=>new Set((f??[]).map(e=>e.id)),[f]),m=f?.find(e=>e.id===d)??null,h=e=>l(t=>{let n=new URLSearchParams(t);return e===null?n.delete(Ir):n.set(Ir,e),n},{replace:!0}),g;return g=i===`pending`?r(Rr,{label:n(`migrations.loading`,`Loading migrations…`)}):i===`unknown`?r(be,{title:n(`migrations.unknownTitle`,`Could not check the migration ledger`),message:n(`migrations.unknownBody`,`The hub did not answer. Try again in a moment.`)}):i===`absent`?r($e,{icon:pe,title:n(`migrations.absentTitle`,`No migration ledger on this hub`),description:n(`migrations.absentBody`,`Nothing on this hub provides the migrations capability.`)}):o.isError||s.isError?r(be,{title:n(`migrations.loadFailed`,`Could not load the migrations`),message:(o.error??s.error)?.message??``}):f===null?r(Rr,{label:n(`migrations.loading`,`Loading migrations…`)}):f.length===0?r($e,{icon:pe,title:n(`migrations.empty`,`No migrations.`),description:n(`migrations.emptyBody`,`The ledger and the catalogues are both empty.`)}):r(Mr,{rows:f,onOpen:h}),e(`div`,{className:u,children:[r(`p`,{className:`mb-3 text-xs text-foreground-muted`,children:n(`migrations.intro`,`Every data migration this hub knows: what ran, what is waiting and what failed. Read-only.`)}),g,r(Fr,{row:m,knownIds:p,onOpenRow:h,onClose:()=>h(null)})]})}function Rr({label:t}){return e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,role:`status`,children:[r(I,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),t]})}var zr={entries:null,"deleted-devices":`deleted-devices`};function Br(){let{t:e}=J(),t=ft(`/system/data`,{t:e,isAdmin:!0})??{icon:j,title:e(`system.data`,`Data`)},[n]=ht(),i=zr[n.get(`tab`)??``];if(i!==void 0){let e=new URLSearchParams(n);return e.set(`tab`,`records`),i!==null&&e.set(`view`,i),r(pt,{replace:!0,to:{search:e.toString()}})}return r(gt,{icon:t.icon,title:t.title,defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`systemPage.data.storage`,`Storage`),content:r(xt,{})},{id:`records`,label:e(`systemPage.data.records`,`Records`),content:r(Sr,{}),ownedParams:[`view`,`recordsOwner`,`recordsKind`,`entryNew`,`entryEdit`]},{id:`backup`,label:e(`systemPage.data.backup`,`Backup`),content:r(In,{})},{id:`secrets`,label:e(`systemPage.data.secrets`,`Secrets`),content:r(hr,{}),ownedParams:[`secretsView`]},{id:`migrations`,label:e(`systemPage.data.migrations`,`Migrations`),content:r(Lr,{}),ownedParams:[`migration`]}]})}export{Br as DataPage};