@camstack/addon-admin-ui 1.2.487 → 1.2.489

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 (136) hide show
  1. package/dist/assets/{AddonAssetIcon-C_RF_2Yp.js → AddonAssetIcon-C0cWByHj.js} +1 -1
  2. package/dist/assets/Addons-DtmmHLxt.js +5 -0
  3. package/dist/assets/{AdminPage-Qn0NDZXK.js → AdminPage-D6Yva5zf.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-xGVLV1j3.js → AdminSectionedPage-ytDsnoAA.js} +1 -1
  5. package/dist/assets/AiProfiles-Dr62eghf.js +3 -0
  6. package/dist/assets/BrokerEditorDialog-CTEagRft.js +1 -0
  7. package/dist/assets/{Build-BhxXDEVz.js → Build-B8CmNZth.js} +4 -4
  8. package/dist/assets/{Calendars-v8J_zj4w.js → Calendars-BzsJnrEA.js} +1 -1
  9. package/dist/assets/Cluster-C2D1ovUW.js +1 -0
  10. package/dist/assets/{CompositionBlockEditor-BK2Or4Pz.js → CompositionBlockEditor-CYmfatQE.js} +1 -1
  11. package/dist/assets/{CompositionEditorPage-CTPdWS1m.js → CompositionEditorPage-B5Cgu9cj.js} +1 -1
  12. package/dist/assets/Data-ChStbBhF.js +2 -0
  13. package/dist/assets/{DeviceDetail-DGJeLN9c.js → DeviceDetail-B4rdvagQ.js} +2 -2
  14. package/dist/assets/{DeviceDoActionFields-OU-F7_Md.js → DeviceDoActionFields-GHZBRE4Q.js} +1 -1
  15. package/dist/assets/{Devices-C9LPgFce.js → Devices-Bzyikktm.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-8ilkZLox.js → EmbedPlayerPage-ClpQaFoO.js} +1 -1
  17. package/dist/assets/{HelperWizard-Dq94Geed.js → HelperWizard-C9VjtAAi.js} +2 -2
  18. package/dist/assets/History-C6N6VRgs.js +1 -0
  19. package/dist/assets/{Identity-DOSuuL8C.js → Identity-CvFSqL46.js} +1 -1
  20. package/dist/assets/IntegrationDetail-AVnEA7GO.js +1 -0
  21. package/dist/assets/IntegrationHub-BqWPAkYu.js +1 -0
  22. package/dist/assets/Integrations-BYiw8_da.js +1 -0
  23. package/dist/assets/Integrations-CBEyPYvE.js +1 -0
  24. package/dist/assets/{Library-DzwP0Wnj.js → Library-BcuUHsq3.js} +1 -1
  25. package/dist/assets/Locations-BrPK_nfE.js +3 -0
  26. package/dist/assets/{Logs-BlImwaLa.js → Logs-D_Jnlf_J.js} +1 -1
  27. package/dist/assets/{MaskShapeCanvas-Cs9lGzkk.js → MaskShapeCanvas-C1WSjh5s.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-5ocz0RHa.js → MotionZonesSettings-BB6LidaW.js} +1 -1
  29. package/dist/assets/MyAccess-DjL1Z681.js +2 -0
  30. package/dist/assets/Network-DjKf4STc.js +1 -0
  31. package/dist/assets/{NodeAddonsSettingsPanel-AvBI4Evv.js → NodeAddonsSettingsPanel-ivvFi7qU.js} +1 -1
  32. package/dist/assets/{Notifications-H77YTWdJ.js → Notifications-Ck0_YzEY.js} +1 -1
  33. package/dist/assets/{Pipeline-pHUqWRzY.js → Pipeline-4J5lhNWd.js} +1 -1
  34. package/dist/assets/{PrivacyMaskSettings-UQH7zTTO.js → PrivacyMaskSettings-CSdKuS75.js} +1 -1
  35. package/dist/assets/Recordings-Ce8DTG1O.js +1 -0
  36. package/dist/assets/ScanNetworkModal-81xkyJSk.js +1 -0
  37. package/dist/assets/{SceneMonitorEditor-PrBW7EMG.js → SceneMonitorEditor-ucsduhsM.js} +1 -1
  38. package/dist/assets/SessionsList-Dgrg9zT1.js +2 -0
  39. package/dist/assets/{Showroom-mL9KRe6u.js → Showroom-CkHdCDH1.js} +1 -1
  40. package/dist/assets/{System-CW6fpBto.js → System-HvIXTTB1.js} +1 -1
  41. package/dist/assets/{Terminal-CLB_5tnQ.js → Terminal-CwE2WbSi.js} +5 -5
  42. package/dist/assets/{Viewer-CVsr_E-j.js → Viewer-B6suHwLq.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CK4gM4oq.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BkS64PhS.js} +1 -1
  44. package/dist/assets/{addon-icons-context-BKk0-b-B.js → addon-icons-context-BY_MClqz.js} +1 -1
  45. package/dist/assets/{archive-BR503Bgl.js → archive-DSecC29S.js} +1 -1
  46. package/dist/assets/{assignment-candidates-Bt36QoWU.js → assignment-candidates-CCD35Rpj.js} +1 -1
  47. package/dist/assets/{authed-media-B5-BZoAQ.js → authed-media-Dow1_6zk.js} +1 -1
  48. package/dist/assets/{bell-off-3JXpdmf4.js → bell-off-kKEnaAlY.js} +1 -1
  49. package/dist/assets/{board-model-B0Q2QBXn.js → board-model-CGmvb_0S.js} +1 -1
  50. package/dist/assets/{boxes-0Xg4N6GT.js → boxes-D29FuJd_.js} +1 -1
  51. package/dist/assets/circle-slash-BEdaE_jf.js +1 -0
  52. package/dist/assets/client-CdHPjeIs.js +358 -0
  53. package/dist/assets/{cloud-upload-BgVc9mNQ.js → cloud-upload-CNHrN4UO.js} +1 -1
  54. package/dist/assets/crop-E8rhIxyE.js +1 -0
  55. package/dist/assets/{device-integration-icon-CxktyXD5.js → device-integration-icon-Dg_7SOuH.js} +1 -1
  56. package/dist/assets/device-picker-model-CdWcoivb.js +1 -0
  57. package/dist/assets/dist-CMh2DitE.js +358 -0
  58. package/dist/assets/{dist-BCJVDfA5.js → dist-pyNtUJBC.js} +1 -1
  59. package/dist/assets/{eraser-xkgMNpsn.js → eraser-DQdA4r-4.js} +1 -1
  60. package/dist/assets/{format-6k9X14Bz.js → format-CvRuKl82.js} +1 -1
  61. package/dist/assets/{hard-drive-download-CUmPIudl.js → hard-drive-download-BWtxkXEP.js} +1 -1
  62. package/dist/assets/{hostInit-DcyTvfcE.js → hostInit-C4zImIaq.js} +1 -1
  63. package/dist/assets/i18n-Dgilx0WT.js +1 -0
  64. package/dist/assets/{icons-D7uD703E.js → icons-CeHJ12H1.js} +1 -1
  65. package/dist/assets/{index-Cgn0pmzp.js → index-4kmzPYxW.js} +3 -3
  66. package/dist/assets/index-DTd1apaT.css +2 -0
  67. package/dist/assets/{key-VxuVSDcq.js → key-ibd36DX6.js} +1 -1
  68. package/dist/assets/{key-round-DOAkaBGK.js → key-round-Cx5S95mB.js} +1 -1
  69. package/dist/assets/{layers-hN2OAslg.js → layers-f2rCYTNI.js} +1 -1
  70. package/dist/assets/{linked-devices-model-m3azqStw.js → linked-devices-model-DBaDc0Fe.js} +1 -1
  71. package/dist/assets/{list-ordered-B7_m7mQG.js → list-ordered-DVEuSX72.js} +1 -1
  72. package/dist/assets/{location-owned-usage-D-K-peZa.js → location-owned-usage-D20qY7jM.js} +1 -1
  73. package/dist/assets/{log-in-CyzfmKrH.js → log-in-YSzSSnpb.js} +1 -1
  74. package/dist/assets/{memory-stick-Bh-D1JrM.js → memory-stick-BxkFX9Lp.js} +1 -1
  75. package/dist/assets/{message-square-plus-Jq5Qx-ZG.js → message-square-plus-CReLm1AI.js} +1 -1
  76. package/dist/assets/{mf-entry-bootstrap-0-01ed437f.js → mf-entry-bootstrap-0-3901d897.js} +2 -2
  77. package/dist/assets/{mic-off-HMWnEzre.js → mic-off-CzIbHCeE.js} +1 -1
  78. package/dist/assets/{monitor-off-jWwMgNhA.js → monitor-off-D6AnJas6.js} +1 -1
  79. package/dist/assets/{monitor-smartphone-CR32s5N4.js → monitor-smartphone-BYEnK_6t.js} +1 -1
  80. package/dist/assets/mount-CdWcoivb.js +1 -0
  81. package/dist/assets/{player-overlays-BT3xIHAn.js → player-overlays-nQJCQERn.js} +1 -1
  82. package/dist/assets/{recycle-DZmrkdVl.js → recycle-CWMxz1Q3.js} +1 -1
  83. package/dist/assets/remoteEntry-BNS8ga8f.js +1 -0
  84. package/dist/assets/{scan-eye-B5rZ7zGT.js → scan-eye-t_4fVxI4.js} +1 -1
  85. package/dist/assets/{scissors-DwAZ3q7Q.js → scissors-DL5nVl1a.js} +1 -1
  86. package/dist/assets/{search-x-B-oRfcQP.js → search-x-CbPl9Xi3.js} +1 -1
  87. package/dist/assets/{send-ZjS8CwTz.js → send-BQl_zLK4.js} +1 -1
  88. package/dist/assets/{settings-2-5VaXifkQ.js → settings-2-7F6aVC_u.js} +1 -1
  89. package/dist/assets/{sigma-Do3DgNJ1.js → sigma-kEBBYTCa.js} +1 -1
  90. package/dist/assets/{speaker-TZvdN1cH.js → speaker-CkI0pe60.js} +1 -1
  91. package/dist/assets/{src-DX_JbsFG.js → src-DzfpPZrG.js} +10 -10
  92. package/dist/assets/step-inspector-model-HSCaPOVt.js +1 -0
  93. package/dist/assets/{table-2-Dqcebk-T.js → table-2-Cukv2oib.js} +1 -1
  94. package/dist/assets/{timer-reset-y8kv-UE8.js → timer-reset-hysIbh2s.js} +1 -1
  95. package/dist/assets/{ungroup-Cy8_Al2f.js → ungroup-D4Nql8ck.js} +1 -1
  96. package/dist/assets/{unlink-Db_gKOzw.js → unlink-DNVVxO6S.js} +1 -1
  97. package/dist/assets/{usb-B0VgCbP1.js → usb-DNmhv4AW.js} +1 -1
  98. package/dist/assets/{use-scenes-feed-BX2r5CSu.js → use-scenes-feed-BUQTm5ig.js} +1 -1
  99. package/dist/assets/{use-stationary-objects-B6gvXwen.js → use-stationary-objects-B4f1cFoy.js} +1 -1
  100. package/dist/assets/useEventInvalidation-CdWcoivb.js +1 -0
  101. package/dist/assets/{useNodeUrlSelection-cuUDxmhY.js → useNodeUrlSelection-BKSL_pMO.js} +1 -1
  102. package/dist/assets/user-round-I0Uty2ao.js +1 -0
  103. package/dist/assets/{user-x-CgHtIGhf.js → user-x-DGZKKLZG.js} +1 -1
  104. package/dist/assets/{video-DYC_GW17.js → video-DEeXGFHo.js} +1 -1
  105. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-HxO7Tlud.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CF1E4s_B.js} +2 -2
  106. package/dist/index.html +10 -10
  107. package/dist/server/addon.js +17 -2
  108. package/package.json +1 -1
  109. package/dist/assets/Addons-kSjXhQba.js +0 -5
  110. package/dist/assets/AiProfiles-C7RRiZ-Y.js +0 -3
  111. package/dist/assets/BrokerForm-pprTt8-v.js +0 -1
  112. package/dist/assets/Cluster-dhAPfJv6.js +0 -1
  113. package/dist/assets/Data-CPdzZaQ6.js +0 -2
  114. package/dist/assets/History-CTyWzxbJ.js +0 -1
  115. package/dist/assets/IntegrationDetail-Bj2o8Gyl.js +0 -1
  116. package/dist/assets/IntegrationHub-D-BT1i-q.js +0 -1
  117. package/dist/assets/Integrations-CKR4hJyA.js +0 -1
  118. package/dist/assets/Integrations-Dn8CFiTq.js +0 -1
  119. package/dist/assets/Locations-BYPw-b2Z.js +0 -3
  120. package/dist/assets/MyAccess-VP7h9O7-.js +0 -2
  121. package/dist/assets/Network-Bla9sJtL.js +0 -1
  122. package/dist/assets/Recordings-BDCMjtre.js +0 -1
  123. package/dist/assets/ScanNetworkModal-B59m4nHs.js +0 -1
  124. package/dist/assets/SessionsList-CSJK-M1F.js +0 -2
  125. package/dist/assets/circle-slash-bfqjP0sy.js +0 -1
  126. package/dist/assets/client-CgAb3Nw-.js +0 -358
  127. package/dist/assets/crop-DYBE_kWG.js +0 -1
  128. package/dist/assets/device-picker-model-DF4u2b9z.js +0 -1
  129. package/dist/assets/dist-BJ8kdWPh.js +0 -358
  130. package/dist/assets/i18n-Zscg3Dkf.js +0 -1
  131. package/dist/assets/index-D4id__eL.css +0 -2
  132. package/dist/assets/mount-DF4u2b9z.js +0 -1
  133. package/dist/assets/remoteEntry-HwnLQWmW.js +0 -1
  134. package/dist/assets/step-inspector-model-Cge4IaLZ.js +0 -1
  135. package/dist/assets/useEventInvalidation-DF4u2b9z.js +0 -1
  136. package/dist/assets/user-round-84cYKzbg.js +0 -1
@@ -1,5 +0,0 @@
1
- import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ci as d,En as f,Gr as p,Lt as m,Pt as h,Q as g,Si as _,dn as v,dt as y,kt as b,mi as x,mn as S,nn as C,oi as w,pn as ee,sr as T,xn as E,yi as te,zn as ne}from"./player-overlays-BT3xIHAn.js";import{Qa as re}from"./client-CgAb3Nw-.js";import{i as D,l as ie}from"./video-DYC_GW17.js";import{Ad as O,Ai as ae,Bi as k,Bn as A,Ci as j,Dd as M,Di as N,Ei as P,Fi as oe,Gi as F,Hn as I,Ii as se,Mi as L,Ni as R,Oi as z,Ot as B,Pi as ce,Qr as V,Ri as H,Ti as le,Ui as ue,Vi as de,Vn as U,Wi as W,Zr as fe,_r as pe,dc as me,dd as G,ei as K,en as he,fr as ge,gr as _e,ki as ve,mr as ye,od as be,pr as q,si as xe,tn as Se,vr as Ce,wi as we,xi as Te,yt as Ee,zi as De,zn as J}from"./src-DX_JbsFG.js";import{t as Y}from"./useTranslation-BJr-n0es.js";import"./mount-DF4u2b9z.js";import{gr as Oe,mr as X,ur as Z}from"./index-Cgn0pmzp.js";import{t as ke}from"./AdminPage-Qn0NDZXK.js";import{t as Ae}from"./NodeAddonsSettingsPanel-AvBI4Evv.js";import{n as Q,t as je}from"./useNodeUrlSelection-cuUDxmhY.js";function Me(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var Ne={queued:{icon:w,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:T,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:E,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:d,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:D,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Pe({item:e}){let{t:n}=Y(),r=Ne[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Fe=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Ie=new Set([`done`,`failed`,`skipped`]);function Le(e){return!Ie.has(e.phase)&&!Fe.has(e.jobState)}function Re(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Fe.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function ze(){let{data:e}=R({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=O(re.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return Re([...n.values()],Date.now())},[e,t])}var Be={queued:{icon:w,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:T,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:d,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:D,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:C,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Ve({progress:e}){let{t:n}=Y(),r=Be[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function He(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function Ue(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function We(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(Ue)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Ge(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
3
- `)}var Ke={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function qe(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${Ke[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
4
- `)}var Je={},Ye=3e4,Xe=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function Ze({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=Y(),c=l(),u=V(),d=fe(),f=L(Je,{staleTime:Ye}),p=f.data?.installations??[],h=(f.data?.unreachable??[]).map(e=>e.nodeId),g=He(p,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),v=W({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:qe(e,_),variant:e.success?`default`:`danger`})},b=async t=>{try{await y(await v.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:Ge(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(r.isHub?{}:{nodeId:r.id})},S=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=He(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:We(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},C=v.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:C,className:Xe,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(m,{className:`h-3 w-3`}),v.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||i===!0||h.length>0)&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:C,className:Xe,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(ie,{className:`h-3 w-3`}),g.length>0?s(`addons.uninstallControls.everywhereCount`,{count:g.length}):s(`addons.uninstallControls.everywhere`)]})]})}function Qe(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function $e(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!Qe(e))}function et(e){return e.length-$e(e,!1).length}c();function tt({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:f}=Y(),m=r===`upload`||r===`local`,[h,g]=s(!1),{data:_,isLoading:v,isError:x}=z({name:e}),S=_?$e(_,h):[],C=_?et(_):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:f(`addons.versionPicker.versions`,`Versions`)}),a(`button`,{type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(y,{className:`h-3 w-3`})})]}),m&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(b,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:f(`addons.versionPicker.inPlace`,{kind:r===`upload`?f(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):f(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(Z,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),v&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(T,{className:`h-3.5 w-3.5 animate-spin`}),f(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),x&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:f(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),S.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:S.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),m=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:f(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),Qe(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:f(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(`button`,{type:`button`,"aria-label":f(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[m,o?a(d,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[m,a(`button`,{type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?f(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):f(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(p,{className:`h-3 w-3`})})]},e.version)})}),!v&&!x&&_&&_.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:f(`addons.versionPicker.noVersionsFound`,`No versions found`)}),C>0&&a(K,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>g(e=>!e),children:h?f(`addons.versionPicker.hideOlder`,`Hide older versions`):f(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:C})})]})}c();var nt=`device-export`;function rt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===nt)}function it(e){return e!==`local`&&e!==`upload`}function at({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=r&&i?g(`/api/addon-assets/${r}/${i}`):null,m=!!p&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:m?a(`img`,{src:p,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?ne:f,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),it(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(b,{className:`h-2.5 w-2.5 text-white`})})]})}function ot({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=Y();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(T,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(p,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(_,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(_,{className:`h-3 w-3 opacity-50`})]}),u]})}function st({addonId:e}){let t=l(),{data:n=`inherit`}=we({addonId:e}),r=k({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var ct={id:`hub`,name:`Hub`,isHub:!0};function lt({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,onUpdate:c,isUpdating:d,jobProgress:f,bundle:p,bulkItem:m,disabledByBulk:h,isSystem:g,selectedNode:b}){let{t:x}=Y(),[C,w]=s(!1),[ee,T]=s(!1),[re,ie]=s(null);o(()=>{ie(null)},[i]);let O=re??i,[ae,k]=s(!1),[A,j]=s(!1),[M,N]=s(`logs`),P=l(),oe=X(),{manifest:F}=e,I=!p&&!F.protected&&F.removable!==!1,L=!!p,R=p?.displayName??F.name,z=p?.packageName??F.packageName,ce=p?.version??F.packageVersion??F.version,V=p?.installSource??e.installSource,le=p?p.bundle?.description??p.addons[0]?.manifest.description:F.description,ue=se({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]})}}),de=ve({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]}),P.invalidateQueries({queryKey:[[`integrations`]]})}}),U=H({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`alerts`]]})}}),W=e.health,fe=W?.phase===`failed`&&!W.inGracePeriod,me=fe&&W?.nextRetryAt&&!W.retrying,G=Me(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${fe?`border-red-500/50`:`border-border`}`,children:[fe&&W&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(D,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:x(`addons.addonCard.failedToLoad`,{attempt:W.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:W.lastError?.message??x(`addons.addonCard.unknownError`,`Unknown error`)}),me&&W.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:x(`addons.addonCard.autoRetryAt`,{time:new Date(W.nextRetryAt).toLocaleTimeString()})})]}),t(`button`,{type:`button`,disabled:U.isPending||W.retrying,onClick:e=>{e.stopPropagation(),U.mutate({packageName:z})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:x(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(E,{className:`h-3 w-3 ${U.isPending||W.retrying?`animate-spin`:``}`}),x(`addons.addonCard.retryNow`,`Retry now`)]})]}),G!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(D,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:x(`addons.addonCard.processProblem.${G.kind}`)}),G.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:G.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(at,{isBundle:L||!!F.components&&F.components.length>1,installSource:V,addonId:L?p.addons[0]?.manifest.id:F.id,iconPath:L?p.bundle?.icon??p.addons[0]?.manifest.icon:F.icon,color:L?p.addons[0]?.manifest.color:F.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:R}),!r&&a(ot,{version:ce,availableUpdate:i,...O===void 0?{}:{selectedVersion:O},isUpdating:d,installSource:V,disabled:h,...c&&O!==void 0?{onUpdate:()=>c(O)}:{},onOpenPicker:()=>T(e=>!e),children:ee&&a(tt,{packageName:z,currentVersion:ce,...V?{installSource:V}:{},...i!==void 0&&O!==void 0?{selectedVersion:O,onSelect:e=>{ie(e),T(!1)}}:{},onInstall:e=>{T(!1),de.mutate({packageName:z,version:e})},onClose:()=>T(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[z!==R&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:z}),L&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(ne,{className:`h-3 w-3`}),p.addons.length]}),g&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:x(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(E,{className:`h-3 w-3`}),x(`addons.addonCard.system`,`System`)]}),m!=null&&a(Pe,{item:m}),f!=null&&a(Ve,{progress:f})]}),le&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:le}),!L&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?x(`addons.addonCard.forked`):x(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:G===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!L&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ue.mutate({addonId:F.id})},disabled:ue.isPending||h,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(E,{className:`h-3 w-3 ${ue.isPending?`animate-spin`:``}`}),x(`addons.addonCard.restart`,`Restart`)]}),t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ae?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(S,{className:`h-3 w-3`}),x(`addons.addonCard.logs`,`Logs`)]}),!L&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),j(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${A?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(v,{className:`h-3 w-3`}),x(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),I&&a(Ze,{packageName:F.packageName,displayName:F.name,selectedNode:b??ct,disabled:h})]}),n&&n.nodes.length>1&&!L&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:x(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:x(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:x(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:x(`common.synced`)})]},e.nodeId))})]}),ae&&!L&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(`button`,{type:`button`,onClick:()=>N(`logs`),className:`px-2 py-0.5 transition-colors ${M===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:x(`addons.addonCard.logs`,`Logs`)}),a(`button`,{type:`button`,onClick:()=>N(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${M===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:x(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(y,{className:`h-3.5 w-3.5`})})]}),M===`logs`&&a(Se,{addonId:F.id,maxHeight:`max-h-64`,showFilters:!1}),M===`events`&&a(he,{addonId:F.id,category:`addon.*`,maxHeight:`max-h-64`})]}),L&&t(u,{children:[a(`button`,{type:`button`,onClick:()=>w(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(C?te:_,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),C&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:p.addons.map(e=>a(lt,{addon:e,hideVersion:!0},e.manifest.id))})]}),A&&!L&&a(ge,{open:!0,onOpenChange:e=>!e&&j(!1),children:t(ye,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(pe,{children:t(Ce,{className:`flex items-center gap-2`,children:[a(v,{className:`h-4 w-4 text-primary`}),x(`addons.addonCard.settingsTitle`,{name:R})]})}),t(q,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:x(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(Ae,{nodeId:null,addonIds:[F.id],level:`global`,fieldScope:`cluster`,emptyMessage:x(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),rt(F)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:x(`addons.addonCard.deviceExport`,`Device export`)}),a(B,{addonId:F.id,onOpenDevice:e=>oe(`/devices/${e}`)})]}),it(V)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:x(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(st,{addonId:F.id})]}),F.components&&F.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:x(`addons.addonCard.components`,{count:F.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:F.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(_e,{children:a(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>j(!1),children:x(`common.close`,`Close`)})})]})})]})}c();var ut=`.tgz,.tar.gz,.zip`;function dt({onUploadSuccess:e}){let{t:r}=Y(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(g(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(`input`,{ref:l,type:`file`,accept:ut,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(`button`,{type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(T,{className:`w-3.5 h-3.5 animate-spin`}):a(b,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var ft=/```[^\n]*\n([\s\S]*?)```/g;function pt(e){let t=[],n=0;for(let r of e.matchAll(ft)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function mt(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function ht(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?mt(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function gt(e,t){let n=e.split(`
5
- `),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:ht(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:ht(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=ht(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function _t({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:pt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:gt(e.body,`b${t}`)},`text-${t}`))})}c();function vt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function yt(e,t,n){let r=$e(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function bt({pending:e,failed:n,body:r,missing:i}){let{t:o}=Y();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(T,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(_t,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function xt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=Y(),[l,u]=s(e.version),[d,f]=s(!1),p=z({name:e.name}),m=N({name:e.name,version:l}),h=p.data??[],g=et(h),_=yt(h,l,d),v=m.data;return a(ge,{open:!0,onOpenChange:e=>!e&&i(),children:t(ye,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(pe,{children:a(Ce,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:vt(e.name)})})}),t(q,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(be,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:Qe(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(K,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(J,{defaultValue:`readme`,children:[t(U,{children:[a(I,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(I,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(A,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(bt,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(A,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(bt,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(_e,{children:[a(K,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(K,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(T,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}var St=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function Ct(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||St.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function wt({selectedNode:e}){let{t:n}=Y(),{data:r}=L(Je,{staleTime:Ye});if(r===void 0)return null;let i=Ct(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(h,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(Ze,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function Tt({addon:e,installing:n,onInstall:r}){let{t:i}=Y();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(xe,{variant:`success`,icon:a(d,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(K,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(T,{className:`h-3 w-3 animate-spin`}):a(p,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Et({capability:e,installing:n,onInstall:r}){let{t:i}=Y(),{data:o,isPending:s,isError:c}=De({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(T,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(Tt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Dt(e){return e===`npm`||e===`dev`?e:null}var Ot=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,kt=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,At=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],jt=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function Mt(e){return e!==void 0&&jt.has(e)}var Nt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Pt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Ft(e){return e===`local`?`dev`:`npm`}function It(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Lt(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function Rt({addons:c,clusterStatus:u,selectedNode:d,onRefresh:f,listPhase:m}){let{t:h}=Y(),g=l(),[_,v]=s(``),y=e(_),[b,S]=s(!1),C=n(null);o(()=>{if(!b)return;let e=e=>{C.current&&!C.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[b]);let{data:w}=ce({nodeId:d.id}),te=r(()=>{let e=new Map;for(let t of w??[])e.set(t.name,t.latestVersion);return e},[w]),ne=r(()=>(w??[]).filter(e=>!e.isSystem).length,[w]),[re,D]=s(()=>new Set),[ie,O]=s(()=>new Map),ae=i(e=>{D(t=>new Set(t).add(e))},[]),k=i(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),A=i((e,t)=>{O(n=>new Map(n).set(e,t))},[]),j=i(e=>{O(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),M=F({onMutate:e=>{ae(e.name),j(e.name)},onSuccess:(e,t)=>{k(t.name);let n=e;if(n&&n.success===!1){A(t.name,n.error??`Update failed (no error message returned by server)`);return}g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{k(t.name),A(t.name,e instanceof Error?e.message:String(e))}}),N=ze(),oe=n(new Set);o(()=>{let e=new Set;for(let[t,n]of N)Le(n)&&e.add(t);let t=[...oe.current].some(t=>!e.has(t));oe.current=e,t&&(g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[N,g]);let{data:I}=le(void 0),se=Te({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),L=de({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:R,isFetching:z}=De({query:y||void 0},{enabled:b}),B=ue(),{data:H}=P(void 0),U=H?.requestedAt,[W,fe]=s(null),[pe,me]=s(!1);o(()=>{if(H?.kind===`framework-bulk-update`&&H.requestedAt!==W){fe(H.requestedAt),me(!0);let e=window.setTimeout(()=>me(!1),6e3);return()=>window.clearTimeout(e)}},[U,W,H]),V();let K=i(async()=>{let e=(w??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await M.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await B.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[w,d.id,d.isHub,B,M]),[he,ge]=s(null),[_e,ye]=s(null),be=e=>{ye(null),ge(e)},q=ve({onSuccess:()=>{ge(null),ye(null),g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addonPages`]]}),g.invalidateQueries({queryKey:[[`capabilities`]]}),g.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{ye(e instanceof Error?e.message:`Install failed`)}}),[xe,Se]=s(`type`),[Ce,we]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Ee=e=>{we(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[J,X]=Oe(),Z=J.get(`capability`),ke=J.get(`updatable`)===`1`,Ae=J.get(`error`)===`1`,Q=Dt(J.get(`source`)),je=i(e=>{let t=new URLSearchParams(J);e?t.set(`updatable`,`1`):t.delete(`updatable`),X(t,{replace:!0})},[J,X]),Ne=i(e=>{let t=new URLSearchParams(J);e?t.set(`error`,`1`):t.delete(`error`),X(t,{replace:!0})},[J,X]),Pe=i(e=>{let t=new URLSearchParams(J);e===null?t.delete(`source`):t.set(`source`,e),X(t,{replace:!0})},[J,X]),Fe=r(()=>c.filter(e=>Me(e.process)!==null).length,[c]),Ie=r(()=>{let e=c.filter(e=>!Mt(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Pt(e.placement,d.isHub))),Z&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Z))),ke&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&te.has(t)})),Q!==null&&(e=e.filter(e=>Ft(e.installSource)===Q)),Ae&&(e=e.filter(e=>Me(e.process)!==null)),e},[c,d.isHub,Z,ke,Q,Ae,te]),Re=()=>{let e=new URLSearchParams(J);e.delete(`capability`),X(e,{replace:!0})},Be=Ce===`flat`?Ie:Lt(Ie),Ve=r(()=>{let e=[...Be];switch(xe){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Be,xe]);return t(`div`,{className:`space-y-3`,children:[[...ie.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:h(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(`button`,{type:`button`,onClick:()=>j(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:h(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.sort`,`Sort:`)}),t(`select`,{value:xe,onChange:e=>Se(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[a(`option`,{value:`type`,children:h(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:h(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:h(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(`button`,{type:`button`,onClick:()=>Ee(e),className:`px-2 py-1 transition-colors capitalize ${Ce===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?h(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):h(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(E,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(`button`,{type:`button`,onClick:()=>se.mutate({channel:e}),disabled:se.isPending,className:`px-2 py-1 transition-colors capitalize ${I?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.checkEvery`,`Check every:`)}),a(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:I?.updateCheckIntervalSeconds??21600,disabled:L.isPending||I===void 0,onChange:e=>{I!==void 0&&L.mutate({channel:I.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:At.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ne>0&&t(`button`,{type:`button`,onClick:()=>void K(),disabled:B.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[B.isPending?a(T,{className:`w-3 h-3 animate-spin`}):a(p,{className:`w-3 h-3`}),B.isPending?h(`admin.system.addons.updating`,`Updating…`):h(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:ne})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":h(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.filter`,`Filter:`)}),[{id:`updatable`,label:h(`admin.system.addons.updatable`,`Updatable`),pressed:ke,toggle:()=>je(!ke)},{id:`error`,label:h(`admin.system.addons.inError`,`In error ({{count}})`,{count:Fe}),pressed:Ae,toggle:()=>Ne(!Ae)},{id:`npm`,label:`npm`,pressed:Q===`npm`,toggle:()=>Pe(Q===`npm`?null:`npm`)},{id:`dev`,label:h(`admin.system.addons.dev`,`Dev`),pressed:Q===`dev`,toggle:()=>Pe(Q===`dev`?null:`dev`)}].map(e=>a(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Ot:kt,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:C,children:[a(G,{type:`text`,value:_,onChange:e=>{v(e.target.value),S(!0)},onFocus:()=>S(!0),placeholder:h(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":h(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:B.isPending,leftSlot:a(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:z?a(T,{className:`h-3 w-3 animate-spin`}):void 0}),b&&R&&R.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[R.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:h(`systemPage.addons.npmResults`,{count:R.length})}),R&&R.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:R.map(e=>a(Tt,{addon:e,installing:q.isPending,onInstall:e=>be({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(dt,{onUploadSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),Z&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:h(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:Z}),a(`button`,{type:`button`,onClick:Re,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:h(`admin.system.addons.clear`,`Clear`)})]}),Z&&a(Et,{capability:Z,installing:q.isPending,onInstall:e=>be({name:e.name,version:e.version,description:e.description})}),Z&&Ie.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:h(`admin.system.addons.installed`,`Installed`)}),pe&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[a(x,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:h(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:h(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),m===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(T,{className:`h-3 w-3 animate-spin`}),h(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),m===`error`&&a(`div`,{className:`text-xs text-danger`,children:h(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),m===`ready`&&Ie.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?h(`admin.system.addons.noAddonsInstalled`,`No addons installed`):Z?h(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:Z}):h(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),a(`div`,{className:`space-y-1.5`,children:m===`ready`&&Ve.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=te.get(t),r=$(e)?e.representative:e,i=n?e=>M.mutate({name:t,version:e,nodeId:d.id}):void 0,o=N.get(t)??null,s=o!==null&&Le(o);return a(lt,{addon:r,clusterStatus:u?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:re.has(t)||s,jobProgress:o,onUpdate:i,disabledByBulk:B.isPending,selectedNode:d},$(e)?t:e.manifest.id)})}),he!==null&&a(xt,{target:he,installing:q.isPending,installError:_e,onClose:()=>ge(null),onInstall:(e,t)=>q.mutate({packageName:e,version:t})})]})}function zt(){let{t:e}=Y(),r=l(),{data:i}=me(void 0),{nodes:s}=M(),{selection:c,selectNode:u,requestedNodeId:d}=je(s.length>0?s:[Nt]),f=c.node??Nt,p=f.id,m=s.length>0?c.staleNodeId:null,{data:h,isLoading:g,isError:_}=ae({nodeId:p}),v=j(),y=oe(),b=v.isPending||y.isPending,x=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},S=n(v);S.current=v;let C=n(d??`hub`);o(()=>{S.current.mutate({nodeId:C.current})},[]);let w=(h??[]).map(It).filter(e=>e!==null);return t(ke,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(Ee,{selectedNodeId:p,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:w.length})}),t(`button`,{type:`button`,onClick:()=>void x(),disabled:b,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(E,{className:`w-3 h-3 ${b?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(Q,{staleNodeId:m,shownNodeName:f.name}),a(wt,{selectedNode:f}),a(Rt,{addons:w,clusterStatus:i,selectedNode:f,onRefresh:()=>void x(),listPhase:g?`pending`:_?`error`:`ready`})]})}export{zt as AddonsPage};
@@ -1,3 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as d,D as f,G as p,Gr as m,In as h,L as g,Lt as _,Mi as v,Ni as y,Oi as b,Q as x,Qt as S,Xt as C,Zi as w,Zr as T,dt as ee,ei as E,fn as D,kn as O,kr as k,ot as A,pn as j,sr as M,xn as N}from"./player-overlays-BT3xIHAn.js";import{Fr as P,Ir as F,Ya as I}from"./client-CgAb3Nw-.js";import{n as L,t as R}from"./send-ZjS8CwTz.js";import{t as te}from"./message-square-plus-Jq5Qx-ZG.js";import{$n as z,Cn as B,Dr as V,Er as H,Gn as U,Ir as ne,Or as re,Qr as W,So as G,St as K,Un as ie,dd as ae,ei as q,fd as oe,ht as se,kr as J,od as ce,pt as le,rt as ue,si as Y,sr as de,wn as fe,xn as X,xt as pe}from"./src-DX_JbsFG.js";import{t as Z}from"./i18n-Zscg3Dkf.js";import{t as Q}from"./useTranslation-BJr-n0es.js";import"./mount-DF4u2b9z.js";import{S as me,gr as he}from"./index-Cgn0pmzp.js";import{t as ge}from"./AdminSectionedPage-xGVLV1j3.js";import{t as _e}from"./AdminPage-Qn0NDZXK.js";c();var ve=`__redacted__`,ye=[`llm`,`listProfiles`],be=[`llm`,`listProfileKinds`],xe=[`llm`,`getDefaults`],Se=[`llm`,`listRuntimeNodes`],Ce=[`llm`,`listModelCatalog`],we=[`llm`,`getUsage`],Te=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],Ee=new Map([[`cloud`,E],[`plug`,O],[`cpu`,T],[`server`,D],[`sparkles`,S]]);function De(e){return Ee.get(e)??y}function Oe(e){return typeof e==`string`&&e.length>0?e:void 0}function ke(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Ae(e){return e===!0}function je(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return[...t.entries()].map(([e,t])=>({addonId:e,kinds:t}))}var Me={deviceNotEligible:{key:`ai.appleNotEligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,tone:`danger`}};function Ne(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:Z.t(`ai.appleUnknown`),detail:t,tone:`default`});if(!e.reachable)return t(e.error??null);let n=e.apple;if(n===void 0)return t(null);switch(n.state){case`available`:return{nodeId:e.nodeId,selectable:!0,labelKey:`ai.appleAvailable`,labelDefault:Z.t(`ai.appleAvailable`),detail:Z.t(n.imageInput?`helpers.aiPage.appleDetailImages`:`helpers.aiPage.appleDetailText`,{version:n.osVersion}),tone:`success`};case`unavailable`:{let t=Me[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:Z.t(t.key),detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:Z.t(`ai.appleNotMac`),detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var Pe={ready:`success`,downloading:`info`,starting:`info`,stopped:`danger`,crashed:`danger`,failed:`danger`};function Fe(e){return e.reachable?e.status===void 0?`success`:Pe[e.status.state]:`danger`}function Ie(e){if(!e.reachable)return[];let t=[],n=e.apple;if(n?.state===`available`)t.push({id:`apple`,labelKey:`ai.featureApple`,tone:`success`,detail:Ne(e).detail}),n.imageInput&&t.push({id:`apple-images`,labelKey:`ai.featureAppleImages`,tone:`success`,detail:null});else if(n?.state===`unavailable`){let n=Ne(e);t.push({id:`apple`,labelKey:`ai.featureApple`,tone:n.tone,detail:n.labelDefault})}let r=e.status?.vramBytes;return r!==void 0&&r>0&&t.push({id:`gpu`,labelKey:`ai.featureGpu`,tone:`info`,detail:null}),t}function Le(){return{temperature:[{type:`slider`,key:`temperature`,label:Z.t(`helpers.aiProfileForm.temperature`),min:0,max:2,step:.1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`,description:Z.t(`helpers.aiProfileForm.temperatureHint`)}],topP:[{type:`slider`,key:`topP`,label:Z.t(`helpers.aiProfileForm.topP`),min:0,max:1,step:.05,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`}],topK:[{type:`number`,key:`topK`,label:Z.t(`helpers.aiProfileForm.topK`),min:1}],maxTokens:[{type:`number`,key:`maxTokens`,label:Z.t(`helpers.aiProfileForm.maxTokens`),min:1}],contextLength:[{type:`number`,key:`contextLength`,label:Z.t(`helpers.aiProfileForm.contextLength`),min:512,unit:`tokens`,description:Z.t(`helpers.aiProfileForm.contextLengthHint`)}],systemPrompt:[{type:`textarea`,key:`systemPrompt`,label:Z.t(`helpers.aiProfileForm.systemPrompt`),rows:4,maxLength:4e3,span:2,description:Z.t(`helpers.aiProfileForm.systemPromptHint`)}],timeoutMs:[{type:`number`,key:`timeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutTotal`),min:1e3,default:F.totalMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutTotalHint`)}],connectTimeoutMs:[{type:`number`,key:`connectTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutConnect`),min:500,default:F.connectMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutConnectHint`)}],firstTokenTimeoutMs:[{type:`number`,key:`firstTokenTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutFirstToken`),min:1e3,default:F.firstTokenMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutFirstTokenHint`)}],idleTimeoutMs:[{type:`number`,key:`idleTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutIdle`),min:1e3,default:F.idleMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutIdleHint`)}],retry:[{type:`boolean`,key:`retryEnabled`,label:Z.t(`helpers.aiProfileForm.retry`),description:Z.t(`helpers.aiProfileForm.retryHint`)},{type:`number`,key:`retryMaxAttempts`,label:Z.t(`helpers.aiProfileForm.retryMaxAttempts`),min:1,max:5,default:1,showWhen:{field:`retryEnabled`,equals:!0}}],toolsEnabled:[{type:`boolean`,key:`toolsEnabled`,label:Z.t(`helpers.aiProfileForm.toolsEnabled`),description:Z.t(`helpers.aiProfileForm.toolsEnabledHint`)}]}}var Re=[`temperature`,`topP`,`topK`,`maxTokens`,`contextLength`,`systemPrompt`],ze=[`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`];function Be(e,t){let n=Le();return t.filter(t=>e.includes(t)).flatMap(e=>n[e])}function Ve(e){let t=Be(e,Re);return t.length===0?null:{sections:[{id:`generation`,title:Z.t(`helpers.aiProfileForm.generation`),fields:t}]}}function He(e){let t=Be(e,ze);return t.length===0?null:{sections:[{id:`bounds`,title:Z.t(`helpers.aiProfileForm.bounds`),fields:t}]}}function Ue(e){return e===null?{}:{temperature:e.temperature,topP:e.topP,topK:e.topK,maxTokens:e.maxTokens,contextLength:e.contextLength,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,connectTimeoutMs:e.connectTimeoutMs,firstTokenTimeoutMs:e.firstTokenTimeoutMs,idleTimeoutMs:e.idleTimeoutMs,retryEnabled:e.retry.enabled,retryMaxAttempts:e.retry.maxAttempts,toolsEnabled:e.toolsEnabled}}function We(e,t){return{...e.features,...t?.features}}function Ge(e,t){return t===null?e.modelCatalog===`static`?e.staticModels??[]:[]:t}function Ke(e,t,n){let r=e.profileFields,i=n.common,a=(e,t,n)=>r.includes(e)?ke(i[e])??t:n??t,o=e=>r.includes(e)?ke(i[e]):t?.[e],s=o(`temperature`),c=o(`topP`),l=o(`topK`),u=o(`maxTokens`),d=o(`contextLength`),f=r.includes(`systemPrompt`)?Oe(i.systemPrompt):t?.systemPrompt;return{id:t?.id??crypto.randomUUID(),name:n.name,kind:e.kind,addonId:e.addonId.length>0?e.addonId:`ai`,enabled:t?.enabled??!0,model:n.model,supportsVision:n.supportsVision,timeoutMs:a(`timeoutMs`,F.totalMs,t?.timeoutMs),connectTimeoutMs:a(`connectTimeoutMs`,F.connectMs,t?.connectTimeoutMs),firstTokenTimeoutMs:a(`firstTokenTimeoutMs`,F.firstTokenMs,t?.firstTokenTimeoutMs),idleTimeoutMs:a(`idleTimeoutMs`,F.idleMs,t?.idleTimeoutMs),retry:r.includes(`retry`)?{enabled:Ae(i.retryEnabled),maxAttempts:ke(i.retryMaxAttempts)??1}:t?.retry??{enabled:!1,maxAttempts:1},toolsEnabled:r.includes(`toolsEnabled`)?Ae(i.toolsEnabled):t?.toolsEnabled??!1,...s===void 0?{}:{temperature:s},...c===void 0?{}:{topP:c},...l===void 0?{}:{topK:l},...u===void 0?{}:{maxTokens:u},...d===void 0?{}:{contextLength:d},...f===void 0?{}:{systemPrompt:f},providerConfig:n.providerConfig}}var qe=2e3;function $(e){return Z.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function Je(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Ye({nodeId:t,value:r,onChange:a}){let{t:c}=Q(),u=A(),[d,f]=o(``),[p,h]=o(null),[g,_]=o(!1),v=s({queryKey:Ce,queryFn:()=>u.trpcClient.llm.listModelCatalog.query({})}),y=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>u.trpcClient.llm.listNodeModels.query({nodeId:t})}),b=l({mutationFn:e=>u.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),x=l({mutationFn:e=>u.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{_(!0),y.refetch()}}),S=s({queryKey:Se,enabled:x.isPending,refetchInterval:x.isPending?qe:!1,queryFn:()=>u.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,C=n(()=>{let e=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${$(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:$(e.sizeBytes),node:t})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${$(p.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[v.data,y.data,p,t,c]),w=e=>{if(e===``){a(null);return}if(e===`custom`){if(p?.ok!==!0)return;a({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=v.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=y.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},T=e=>{d.trim()!==``&&b.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(K,{label:c(`ai.model`,`Model`),required:!0,children:i(ce,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:Je(r),options:C,onChange:e=>w(e.target.value)})}),i(K,{label:c(`ai.hfTitle`,`Add a model from Hugging Face`),description:c(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`),children:e(`div`,{className:`flex gap-2`,children:[i(ae,{"aria-label":c(`ai.hfTitle`,`Add a model from Hugging Face`),value:d,onChange:e=>f(e.target.value),placeholder:c(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())}}),e(q,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||b.isPending,onClick:()=>T(),children:[b.isPending?i(M,{className:`h-3.5 w-3.5 animate-spin`}):i(j,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),b.isError&&i(H,{message:b.error instanceof Error?b.error.message:c(`common.error`,`Error`)}),p?.ok===!1&&i(H,{message:p.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(p.candidates??[]).map(e=>i(q,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),b.mutate({ref:t})},children:e},e)),p.requiredBytes!==void 0&&i(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>T(p.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:$(p.requiredBytes)})})]})}),p?.ok===!0&&e(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),i(Y,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),i(Y,{variant:`default`,children:$(p.totalBytes)})]}),p.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(q,{size:`sm`,type:`button`,disabled:x.isPending||g,onClick:()=>x.mutate(p.model),children:[x.isPending?i(M,{className:`h-3.5 w-3.5 animate-spin`}):i(m,{className:`h-3.5 w-3.5`}),g?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),S!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:S.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:S.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:S.file,index:S.fileIndex,count:S.fileCount,done:$(S.downloadedBytes),total:S.totalBytes===void 0?``:` / ${$(S.totalBytes)}`})})]}),x.isError&&i(H,{message:x.error instanceof Error?x.error.message:c(`common.error`,`Error`)})]})]})}function Xe({value:t,onChange:n}){let{t:r}=Q(),a=A(),o=s({queryKey:Se,queryFn:()=>a.trpcClient.llm.listRuntimeNodes.query({})});return e(`div`,{children:[i(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:r(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(M,{className:`h-3.5 w-3.5 animate-spin`}),r(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&i(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:r(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&i(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(a=>{let o=Ne(a),s=o.nodeId===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":s,disabled:!o.selectable&&!s,onClick:()=>n(o.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${s?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block font-medium text-foreground`,children:o.nodeId}),o.detail!==null&&i(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:o.detail})]}),i(Y,{variant:o.tone,children:r(o.labelKey,o.labelDefault)})]},o.nodeId)})}),i(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:r(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}function Ze(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Qe({providerConfig:e,onProviderConfigChange:t}){return i(Xe,{value:Ze(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function $e({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=P.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Ye,{nodeId:Ze(e,`nodeId`)??`hub`,value:o,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var et=new Map([[`ai/apple-node`,Qe],[`ai/managed-model`,$e]]);function tt(e){return et.get(e)??null}c();function nt({kind:e,className:t}){return i(De(e.icon),{className:t,"aria-hidden":!0})}function rt({kinds:e,onPick:t,onCancel:r}){let{t:a}=Q(),o=n(()=>je(e),[e]),s=n(()=>new Map(e.map(e=>[`${e.addonId}:${e.kind}`,e])),[e]);return i(se,{open:!0,onClose:r,title:a(`ai.chooseKind`,`Choose a profile type`),width:`lg`,testId:`ai-kind-picker`,children:i(pe,{emptyMessage:a(`ai.noKinds`,`No AI provider is installed.`),onPick:e=>{let n=s.get(e);n!==void 0&&t(n)},groups:o.map(e=>({id:e.addonId,label:e.addonId,tiles:e.kinds.map(t=>({key:`${e.addonId}:${t.kind}`,label:t.label,testId:`ai-kind-${t.kind}`,icon:i(nt,{kind:t,className:`h-5 w-5 text-foreground-subtle`})}))}))})})}function it(e){return(e?.sections??[]).flatMap(e=>e.fields)}function at(...e){let t={};for(let n of e)for(let e of it(n))`default`in e&&e.default!==void 0&&(t[e.key]=e.default);return t}function ot(e){return e==null?!1:typeof e==`string`?e.trim().length>0:!0}function st(e,t){return it(e).filter(e=>`required`in e&&e.required===!0&&!ot(t[e.key])).map(e=>`label`in e&&typeof e.label==`string`?e.label:e.key)}var ct={auth:{key:`ai.listAuth`,fallback:`Credentials refused`},network:{key:`ai.listNetwork`,fallback:`Endpoint unreachable`},unsupported:{key:`ai.listUnsupported`,fallback:`No model list`},invalid:{key:`ai.listInvalid`,fallback:`Connection incomplete`}};function lt(e,t){if(t!==null)return{id:t.model,supportsVision:t.supportsVision};let n=e.modelCatalog===`static`&&e.staticModels?.length===1?e.staticModels?.[0]:void 0;return{id:n?.id??``,supportsVision:We(e,n).vision}}function ut({kind:t,existing:r,onSave:a,onCancel:s,onChangeKind:c,saving:d,error:p}){let{t:m}=Q(),h=A(),[_,v]=o(r?.name??t.label),[y,b]=o(()=>r===null?at(t.connectionSchema,t.advancedSchema):{...r.providerConfig}),[x,S]=o(()=>Ue(r)),[C,T]=o(()=>lt(t,r)),[ee,E]=o(!1),D=t.providerWidgets??[],O=D.filter(e=>e.placement===`connection`),k=D.find(e=>e.placement===`model`)??null,j=n(()=>[...I(t.connectionSchema)].some(e=>r?.providerConfig[e]===ve),[r,t.connectionSchema]),P=l({mutationFn:()=>h.trpcClient.llm.listModels.mutate({addonId:t.addonId,kind:t.kind,connection:y,...r===null?{}:{profileId:r.id}}),onSuccess:e=>{e.ok&&T(n=>{let r=e.models.find(e=>e.id===n.id);return r===void 0?n:{id:n.id,supportsVision:We(t,r).vision}})}}),F=Ge(t,P.data?.ok===!0?P.data.models:null),L=F.find(e=>e.id===C.id),R=We(t,L),te=Ve(t.profileFields),B=He(t.profileFields),V=st(t.connectionSchema,y),U=D.some(e=>(e.requires??[]).some(e=>!ot(y[e]))),ne=t.modelCatalog===`fetch`&&k===null,re=it(t.connectionSchema).length>0||O.length>0,W=e=>{T({id:e,supportsVision:We(t,F.find(t=>t.id===e)).vision})},G=d||_.trim()===``||C.id.trim()===``||V.length>0||U,oe=()=>{a(Ke(t,r,{name:_.trim(),model:C.id.trim(),supportsVision:t.visionEditable?C.supportsVision:!1,common:x,providerConfig:y}))},J=r===null?m(`ai.newProfile`,`New {{kind}} profile`,{kind:t.label}):m(`ai.editProfile`,`Edit {{name}}`,{name:r.name}),le=e=>{let n=tt(e);return n===null?i(H,{variant:`warning`,message:m(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})}):i(n,{descriptor:t,providerConfig:y,onProviderConfigChange:b,model:C,onModelChange:T},e)};return i(se,{open:!0,onClose:s,title:J,error:p,width:`lg`,testId:`ai-profile-editor`,footer:e(u,{children:[V.length>0&&i(Y,{variant:`warning`,children:m(`ai.missingRequired`,`required: {{fields}}`,{fields:V.join(`, `)})}),V.length===0&&U&&i(Y,{variant:`warning`,children:m(`ai.completeProvider`,`complete the provider settings`)}),V.length===0&&!U&&C.id.trim()===``&&i(Y,{variant:`warning`,children:m(`ai.pickModelFirst`,`pick a model`)}),e(q,{size:`sm`,type:`button`,disabled:G,onClick:oe,children:[d&&i(M,{className:`h-3.5 w-3.5 animate-spin`}),r===null?m(`ai.createProfile`,`Create profile`):m(`ai.saveChanges`,`Save changes`)]})]}),children:e(`div`,{className:g,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`ai-editor-provider`,children:[i(nt,{kind:t,className:`h-4 w-4 text-foreground-subtle`}),i(`span`,{className:`text-xs font-medium text-foreground`,children:t.label}),i(Y,{variant:`neutral`,children:t.addonId}),c!==void 0&&e(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:c,children:[i(w,{className:`h-3.5 w-3.5`}),m(`ai.changeKind`,`Change type`)]})]}),i(K,{label:m(`ai.name`,`Name`),required:!0,children:i(ae,{id:`ai-profile-name`,"aria-label":m(`ai.name`,`Name`),value:_,onChange:e=>v(e.target.value),placeholder:t.label})}),re&&i(X,{headingId:`ai-editor-connection`,title:m(`ai.sectionConnection`,`Connection`),actions:ne?e(q,{size:`sm`,variant:`secondary`,type:`button`,disabled:P.isPending,onClick:()=>P.mutate(),"data-testid":`ai-verify-models`,children:[P.isPending?i(M,{className:`h-3.5 w-3.5 animate-spin`}):i(N,{className:`h-3.5 w-3.5`}),m(`ai.verifyModels`,`Verify & load models`)]}):void 0,children:e(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[it(t.connectionSchema).length>0&&i(de,{bare:!0,schema:t.connectionSchema,values:y,onChange:b}),O.map(e=>le(e.id)),j&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:m(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)}),P.data?.ok===!0&&i(Y,{variant:`success`,"data-testid":`ai-models-found`,children:m(`ai.modelsFound`,`{{count}} models found`,{count:P.data.models.length})}),P.data?.ok===!1&&i(H,{title:m(ct[P.data.code]?.key??`ai.listNetwork`,ct[P.data.code]?.fallback??`Endpoint unreachable`),message:P.data.message}),P.isError&&i(H,{message:P.error instanceof Error?P.error.message:m(`common.error`,`Error`)})]})}),i(X,{headingId:`ai-editor-model`,title:m(`ai.sectionModel`,`Model`),children:e(`div`,{className:`${f} space-y-3`,children:[k===null?e(u,{children:[F.length>0&&i(ce,{id:`ai-model-pick`,"aria-label":m(`ai.selectModel`,`Select a model…`),value:L===void 0?``:L.id,options:[{value:``,label:m(`ai.selectModel`,`Select a model…`)},...F.map(e=>({value:e.id,label:e.label??e.id}))],onChange:e=>{e.target.value!==``&&W(e.target.value)}}),i(K,{label:m(`ai.customModel`,`Model id`),description:m(`ai.customModelHint`,`Pick one from the list, or type any model id the provider accepts.`),required:!0,children:i(ae,{id:`ai-model-id`,"aria-label":m(`ai.customModel`,`Model id`),value:C.id,onChange:e=>T({...C,id:e.target.value}),placeholder:F[0]?.id??`model-id`})})]}):le(k.id),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`ai-model-features`,children:[(C.supportsVision||!t.visionEditable&&R.vision)&&i(Y,{variant:`info`,children:m(`ai.featureVision`,`vision`)}),R.tools&&i(Y,{variant:`neutral`,children:m(`ai.featureTools`,`tools`)}),R.streaming&&i(Y,{variant:`neutral`,children:m(`ai.featureStreaming`,`streaming`)})]}),t.visionEditable&&i(K,{orientation:`horizontal`,label:m(`ai.supportsVision`,`Supports vision`),description:m(`ai.supportsVisionHint`,`A vision call against a text-only profile is refused, never downgraded.`),children:i(ie,{checked:C.supportsVision,onCheckedChange:e=>T({...C,supportsVision:e}),"aria-label":m(`ai.supportsVision`,`Supports vision`)})})]})}),te!==null&&i(X,{headingId:`ai-editor-generation`,title:m(`ai.sectionGeneration`,`Generation`),children:i(`div`,{className:`p-2 sm:p-3 lg:p-4`,children:i(de,{bare:!0,schema:te,values:x,onChange:S})})}),(B!==null||t.advancedSchema!==void 0)&&i(z,{expanded:ee,onExpandedChange:E,header:i(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:m(`ai.sectionAdvanced`,`Advanced`)}),children:e(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[B!==null&&i(de,{bare:!0,schema:B,values:x,onChange:S}),t.advancedSchema!==void 0&&i(de,{bare:!0,schema:t.advancedSchema,values:y,onChange:b})]})})]})})}c();function dt(t){return[{key:`name`,header:t.t(`ai.colProfile`,`Profile`),render:n=>{let r=t.kindByName.get(n.kind);return e(`span`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:r?.label??n.kind,children:r===void 0?i(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):i(nt,{kind:r,className:`h-4 w-4 text-foreground-subtle`})}),e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block truncate font-medium text-foreground`,children:n.name}),t.testResult?.id===n.id&&i(`span`,{className:`block truncate ${t.testResult.ok?`text-success`:`text-danger`}`,children:t.testResult.text})]})]})}},{key:`kind`,header:t.t(`ai.colKind`,`Kind`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground-muted`,children:t.kindByName.get(e.kind)?.label??e.kind})},{key:`model`,header:t.t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.model})},{key:`vision`,header:t.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:e=>e.supportsVision?i(Y,{variant:`info`,style:`outline`,children:t.t(`ai.vision`,`vision`)}):i(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`node`,header:t.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>typeof e.providerConfig.nodeId==`string`?i(Y,{variant:`default`,children:e.providerConfig.nodeId}):i(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`enabled`,header:t.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:e=>i(ie,{checked:e.enabled,onCheckedChange:()=>t.onToggle(e),"aria-label":Z.t(`system.aiProfilesTab.toggle`,`toggle {{name}}`,{name:e.name})})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:n=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[i(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>t.onTest(n),"aria-label":t.t(`ai.test`,`Test`),title:t.t(`ai.test`,`Test`),children:t.testingId===n.id?i(M,{className:`h-3.5 w-3.5 animate-spin`}):i(R,{className:`h-3.5 w-3.5`})}),i(q,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t.kindByName.has(n.kind),onClick:()=>t.onEdit(n),"aria-label":t.t(`common.edit`,`Edit`),title:t.t(`common.edit`,`Edit`),children:i(h,{className:`h-3.5 w-3.5`})}),i(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>t.onDelete(n),"aria-label":t.t(`common.delete`,`Delete`),title:t.t(`common.delete`,`Delete`),children:i(_,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function ft(){let{t}=Q(),c=A(),{state:u,openEdit:d,close:p}=le(),m=W(),[h,_]=o(null),[v,y]=o(null),[b,x]=o(null),C=s({queryKey:ye,queryFn:()=>c.trpcClient.llm.listProfiles.query({})}),w=s({queryKey:be,queryFn:async()=>(await c.trpcClient.llm.listProfileKinds.query({})).map(({connectionSchema:e,advancedSchema:t,...n})=>({...n,connectionSchema:e,...t===void 0?{}:{advancedSchema:t}}))}),T=()=>{C.refetch()},ee=r(()=>{_(null),x(null),p()},[p]);a(()=>{u.mode===`closed`&&_(null)},[u.mode]);let E=l({mutationFn:e=>c.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{ee(),T()},onError:e=>x(e instanceof Error?e.message:t(`ai.saveFailed`,`Save failed`))}),D=l({mutationFn:e=>c.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:T}),O=l({mutationFn:e=>c.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>y({id:t.id,ok:e.ok,text:e.ok?Z.t(`system.aiProfilesTab.testOk`,{text:e.text,tokens:e.usage.outputTokens,ms:e.latencyMs}):`${e.code}: ${e.message}`})}),k=C.data??[],j=n(()=>w.data??[],[w.data]),M=n(()=>{let e=new Map;for(let t of j)e.set(t.kind,t);return e},[j]),N=u.mode===`edit`?k.find(e=>e.id===u.id)??null:null,P=N===null?null:M.get(N.kind)??null,F=u.mode===`new`&&h===null,I=u.mode===`new`?h:P,L=u.mode===`edit`?N:null,R=I!==null&&(u.mode===`new`||L!==null),te=async e=>{await m({title:t(`ai.deleteProfileTitle`,`Delete profile?`),message:t(`ai.deleteProfileMessage`,`Delete "{{name}}". Features that name it will no longer get an answer from it.`,{name:e.name}),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`})&&D.mutate(e)};return e(`div`,{className:g,children:[i(pt,{profiles:k}),i(X,{headingId:`ai-profiles-list`,title:t(`ai.profilesList`,`Profiles`),children:C.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-profiles-loading`,children:[i(J,{className:`h-8 w-full`}),i(J,{className:`h-8 w-full`}),i(J,{className:`h-8 w-full`})]}):C.isError?i(`div`,{className:f,children:i(H,{title:t(`ai.loadFailed`,`Failed to load profiles`),message:C.error instanceof Error?C.error.message:t(`common.error`,`Error`),onRetry:()=>void C.refetch()})}):k.length===0?i(V,{icon:S,title:t(`ai.noProfilesTitle`,`No AI profiles yet`),description:t(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}):i(B,{columns:dt({kindByName:M,testResult:v,testingId:O.isPending?O.variables?.id??null:null,t,onToggle:e=>E.mutate({...e,enabled:!e.enabled}),onTest:e=>O.mutate(e),onEdit:e=>{M.has(e.kind)&&(x(null),_(null),d(e.id))},onDelete:e=>void te(e)}),rows:k,rowKey:e=>e.id,minWidthPx:760,bordered:!1,maxBodyHeight:fe})}),F&&i(rt,{kinds:j,onCancel:ee,onPick:e=>{x(null),_(e)}}),R&&I!==null&&i(ut,{kind:I,existing:L,saving:E.isPending,error:b,onSave:e=>E.mutate(e),onCancel:ee,...u.mode===`new`?{onChangeKind:()=>{x(null),_(null)}}:{}})]})}function pt({profiles:t}){let{t:n}=Q(),r=A(),a=s({queryKey:xe,queryFn:()=>r.trpcClient.llm.getDefaults.query({})}),o=l({mutationFn:e=>r.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{a.refetch()}}),c=e=>(a.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,u=e=>e===`vision`?n(`ai.defaultVision`,`Default vision profile`):n(`ai.defaultText`,`Default text profile`);return i(X,{headingId:`ai-profiles-defaults`,title:n(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${f} grid gap-4 sm:grid-cols-2`,children:Te.map(({purpose:r,visionOnly:a})=>{let s=a?t.filter(e=>e.supportsVision):t,l=c(r),d=t.find(e=>e.id===l);return e(`div`,{children:[i(U,{className:`mb-1 block`,htmlFor:`llm-default-${r}`,children:u(r)}),i(ce,{id:`llm-default-${r}`,"aria-label":u(r),value:l,onChange:e=>o.mutate({purpose:r,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:n(`ai.none`,`None`)},...l!==``&&!s.some(e=>e.id===l)?[{value:l,label:d?.name??l}]:[],...s.map(e=>({value:e.id,label:`${e.name} · ${e.model}`}))]}),l!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:n(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&i(`p`,{className:`mt-1 text-xs text-warning`,children:n(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:String(o.error)})]},r)})})})}c();var mt=5e3;function ht(e){return Z.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function gt(){let{t}=Q(),r=A(),a=s({queryKey:Se,refetchInterval:mt,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})}),o=n(()=>[{key:`node`,header:t(`ai.colNode`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:t(`ai.colState`,`State`),nowrap:!0,render:n=>e(`span`,{className:`flex items-center gap-1.5`,children:[i(Y,{variant:Fe(n),children:n.reachable?n.status?.state??t(`ai.ready`,`ready`):t(`ai.unreachable`,`unreachable`)}),n.status?.downloadProgress!==void 0&&i(Y,{variant:`info`,children:`${String(Math.round(n.status.downloadProgress*100))}%`})]})},{key:`model`,header:t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:t(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:ht(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeatures`,`Features`),render:n=>{let r=Ie(n);if(r.length===0)return i(`span`,{className:`text-foreground-subtle`,children:`—`});let a=r.flatMap(e=>e.detail===null?[]:[e.detail]);return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[i(`span`,{className:`flex flex-wrap gap-1`,children:r.map(e=>i(Y,{variant:e.tone,children:t(e.labelKey)},e.id))}),a.length>0&&i(`span`,{className:`text-foreground-subtle`,children:a.join(` · `)})]})}},{key:`error`,header:t(`ai.colError`,`Error`),render:e=>e.error===void 0?i(`span`,{className:`text-foreground-subtle`,children:`—`}):i(`span`,{className:`text-danger`,children:e.error})}],[t]),c=a.data??[];return i(X,{headingId:`ai-runtimes-list`,title:t(`ai.runtimesList`,`Nodes`),children:a.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[i(J,{className:`h-8 w-full`}),i(J,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:f,children:i(H,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(V,{icon:D,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(B,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:fe})})}var _t=x(`/addon/ai/test-chat`),vt=x(`/addon/ai/test-chat/chats`),yt=6e5;function bt(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),yt)}function xt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function St(e){if(!xt(e))return null;let t=e.kind;return t!==`snapshot`&&t!==`track`||typeof e.mimeType!=`string`||typeof e.sizeBytes!=`number`?null:{kind:t,mimeType:e.mimeType,sizeBytes:e.sizeBytes,...typeof e.mediaKind==`string`?{mediaKind:e.mediaKind}:{},...typeof e.capturedAt==`number`?{capturedAt:e.capturedAt}:{},...typeof e.thumbnailBase64==`string`?{thumbnailBase64:e.thumbnailBase64}:{}}}var Ct=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function wt(e){let t;try{t=JSON.parse(e)}catch{return null}if(!xt(t))return null;switch(t.kind){case`status`:{let e=Ct.find(e=>e===t.phase);return e===void 0?null:{kind:`status`,phase:e}}case`meta`:return typeof t.profileName!=`string`||typeof t.model!=`string`?null:{kind:`meta`,profileName:t.profileName,model:t.model,mediaSent:St(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:Z.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Tt(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
2
- `);for(;a>=0;){let e=r.slice(0,a).trim();if(r=r.slice(a+1),e.length>0){let t=wt(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=wt(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Et(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Dt(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function Ot(e){return e.messages.map((t,n)=>{let r=t.mediaSent??void 0;return{id:`${e.id}-${String(n)}`,role:t.role,content:t.content,...t.attachment===void 0?{}:{attachmentRef:t.attachment,attachmentKind:t.attachment.kind},...r===void 0?{}:{attachment:r}}})}function kt(e){let t=e.sizeBytes<1024*1024?`${(e.sizeBytes/1024).toFixed(0)} KB`:`${(e.sizeBytes/(1024*1024)).toFixed(1)} MB`,n=[e.kind===`snapshot`?`camera snapshot`:`track best-shot`,t];return e.mediaKind!==void 0&&n.push(e.mediaKind),e.capturedAt!==void 0&&n.push(new Date(e.capturedAt).toLocaleTimeString()),n.join(` · `)}function At(e,t){switch(e){case`resolving-image`:return Z.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return Z.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?Z.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):Z.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return Z.t(`helpers.aiTestChat.phaseAnswering`)}}c();var jt=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Mt=360*60*1e3,Nt=40,Pt=160,Ft={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function It(){let{t:c}=Q(),l=A(),[u,d]=o(``),[p,m]=o(``),[h,y]=o(``),[x,S]=o([]),[w,T]=o(null),[E,D]=o(`none`),[O,k]=o(`throwaway`),[j,M]=o(null),[N,P]=o([]),[F,I]=o(null),[L,z]=o(null),B=t(null);a(()=>()=>B.current?.abort(),[]);let V=r(async()=>{let e=await fetch(vt,{credentials:`same-origin`});e.ok&&P((await e.json()).chats??[])},[]);a(()=>{O===`persistent`&&V()},[O,V]);let ne=s({queryKey:ye,queryFn:()=>l.trpcClient.llm.listProfiles.query({})}),re=n(()=>(ne.data??[]).filter(e=>e.enabled),[ne.data]),W=re.find(e=>e.id===u)??null,G=L!==null,K=r(async(e,t)=>{let n=new AbortController;B.current=n,I(null);let r=bt(W??{});z({...Ft,firstTokenTimeoutMs:r??0});let i=``,a=null,o,s=null,l=null,d;try{let c=await fetch(_t,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:u,messages:e,...p.trim()===``?{}:{system:p.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...O===`persistent`?{persist:!0,...j===null?{}:{conversationId:j}}:{}})});if(!c.ok||c.body===null){let e=await c.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(c.status)}`)}for await(let e of Tt(c.body))switch(e.kind){case`status`:z(t=>({...t??Ft,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,z(t=>({...t??Ft,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,z(e=>({...e??Ft,text:i}));break;case`done`:l={outputTokens:e.outputTokens,latencyMs:e.latencyMs},d=e.conversationId;break;case`error`:s=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||I(e instanceof Error?e.message:c(`common.error`,`Error`))}finally{B.current=null,z(null)}d!==void 0&&(M(d),V());let f=n.signal.aborted&&i.length>0;s===null&&i.length===0&&!f||S(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:s??i,...s===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&s===null?{model:o}:{},...l===null?{}:l}])},[O,j,W,u,V,p,c]),ie=r(()=>{let e=h.trim();if(e===``||u===``||G)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...w===null?{}:{attachmentLabel:w.label,attachmentKind:w.ref.kind}},n=[...x,t];S(n),y(``);let r=w?.ref;T(null),D(`none`),K(O===`persistent`&&j!==null?[{role:`user`,content:e}]:Et(n),r)},[O,j,h,w,u,K,G,x]),se=()=>B.current?.abort(),J=()=>{B.current?.abort(),S([]),T(null),y(``),I(null),z(null),M(null)},le=async e=>{B.current?.abort();let t=await fetch(`${vt}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();M(e),S(Ot(n)),z(null),I(null)};return e(`div`,{className:g,children:[i(X,{headingId:`ai-test-setup`,title:c(`ai.testSetup`,`Setup`),children:e(`div`,{className:`${f} space-y-3`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e(`div`,{children:[i(U,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:c(`ai.profile`,`Profile`)}),i(ce,{id:`ai-test-profile`,value:u,onChange:e=>d(e.target.value),options:[{value:``,label:c(`ai.selectProfile`,`Select a profile…`)},...re.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),re.length===0&&!ne.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:c(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(U,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:c(`ai.systemPrompt`,`System prompt (optional)`)}),i(ae,{id:`ai-test-system`,value:p,onChange:e=>m(e.target.value),placeholder:c(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(ue,{label:c(`ai.chatMode`,`Conversation mode`),value:O,options:[{value:`throwaway`,label:c(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:c(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{k(e),e===`throwaway`&&M(null)}}),O===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:c(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:J,children:[i(te,{className:`h-3.5 w-3.5`}),c(`ai.newChat`,`New chat`)]}),N.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:N.map(e=>i(`button`,{type:`button`,onClick:()=>void le(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===j?`bg-primary/10`:``}`,children:i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:c(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),W!==null&&!W.supportsVision&&i(`p`,{className:`text-xs text-warning`,children:c(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),F!==null&&i(H,{title:c(`ai.chatFailed`,`The test call failed`),message:F}),e(X,{headingId:`ai-test-conversation`,title:c(`ai.testConversation`,`Conversation`),actions:e(q,{size:`sm`,variant:`ghost`,type:`button`,disabled:x.length===0&&w===null,onClick:J,children:[i(_,{className:`h-3.5 w-3.5`}),c(`ai.clearChat`,`Clear`)]}),children:[i(Lt,{turns:x,live:L}),e(`div`,{className:`${f} space-y-2 border-t border-border`,children:[w!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[w.ref.kind===`snapshot`?i(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:w.label}),i(oe,{size:`sm`,variant:`ghost`,type:`button`,icon:ee,"aria-label":c(`ai.removeAttachment`,`Remove attachment`),onClick:()=>T(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(q,{size:`sm`,variant:E===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>D(E===`snapshot`?`none`:`snapshot`),children:[i(b,{className:`h-3.5 w-3.5`}),c(`ai.attachSnapshot`,`Camera snapshot`)]}),e(q,{size:`sm`,variant:E===`track`?`primary`:`outline`,type:`button`,onClick:()=>D(E===`track`?`none`:`track`),children:[i(v,{className:`h-3.5 w-3.5`}),c(`ai.attachTrack`,`Recent track`)]})]}),E===`snapshot`&&i(Bt,{onPick:(e,t)=>{T({ref:{kind:`snapshot`,deviceId:e.id},label:c(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),D(`none`)}}),E===`track`&&i(Ht,{onPick:(e,t)=>{T({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:c(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),D(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(ae,{value:h,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ie())},placeholder:c(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":c(`ai.message`,`Message`)}),G?e(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:se,children:[i(C,{className:`h-3.5 w-3.5`}),c(`ai.stop`,`Stop`)]}):e(q,{size:`sm`,type:`button`,disabled:h.trim()===``||u===``,onClick:ie,children:[i(R,{className:`h-3.5 w-3.5`}),c(`ai.send`,`Send`)]})]})]})]})]})}function Lt({turns:t,live:n}){let{t:r}=Q();return t.length===0&&n===null?i(V,{icon:L,title:r(`ai.chatEmptyTitle`,`No messages yet`),description:r(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):e(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${f}`,children:[t.map(e=>i(Rt,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(zt,{attachment:n.mediaSent}),n.text.length>0&&i(Rt,{turn:{id:`live`,role:`assistant`,content:n.text},streaming:!0}),e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(M,{className:`h-3.5 w-3.5 animate-spin`}),At(n.phase,n.firstTokenTimeoutMs)]})]})]})}function Rt({turn:t,streaming:n=!1}){let{t:r}=Q(),a=t.role===`user`,o=t.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return i(`div`,{className:`flex ${a?`justify-end`:`justify-start`}`,children:e(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${a?`border-primary/40 bg-primary/10`:o}`,children:[e(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[t.content,n&&i(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),t.attachment!==void 0&&i(zt,{attachment:t.attachment}),t.attachmentLabel!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachmentKind===`track`?i(v,{className:`h-3 w-3`}):i(b,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(b,{className:`h-3 w-3`}):i(v,{className:`h-3 w-3`}),kt(t.attachment)]}),t.model!==void 0&&i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:t.model,value2:String(t.outputTokens??0),value3:String(t.latencyMs??0)})})]})})}function zt({attachment:e}){let{t}=Q(),n=Dt(e);return n===null?null:i(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function Bt({onPick:e}){let{t}=Q(),n=G({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(M,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):i(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>i(Vt,{device:t,onPick:e},t.id))})}function Vt({device:t,onPick:n}){let{t:r}=Q(),a=ne(t,`compact`),{src:o}=p(t.id,{width:Pt});return e(`button`,{type:`button`,onClick:()=>n(t,a),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[i(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:o!==null&&i(`img`,{src:o,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),e(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!t.online&&i(Y,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function Ht({onPick:t}){let{t:r}=Q(),a=A(),o=G({isCamera:!0,projection:`slim`}),c=n(()=>(o.data??[]).map(e=>e.id),[o.data]),l=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=s({queryKey:[...jt,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Mt,limit:Nt,projection:`slim`})});if(o.isLoading||u.isLoading)return i(M,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(v,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var Ut=1440*60*1e3,Wt=[1,7,30,90];function Gt(){let{t}=Q(),r=A(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*Ut},[a]),u=s({queryKey:ye,queryFn:()=>r.trpcClient.llm.listProfiles.query({})}),d=s({queryKey:[...we,a],queryFn:()=>r.trpcClient.llm.getUsage.query({since:l})}),p=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=n(()=>[{key:`day`,header:t(`ai.colDay`,`Day`),nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:t(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:t(`ai.colProfile`,`Profile`),render:e=>i(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:t(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:t(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:t(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:t(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,t]),h=d.data??[],g=i(`div`,{className:`w-36`,children:i(ce,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:Wt.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(X,{headingId:`ai-usage-list`,title:t(`ai.usageList`,`Rollup`),actions:g,children:d.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-usage-loading`,children:[i(J,{className:`h-8 w-full`}),i(J,{className:`h-8 w-full`}),i(J,{className:`h-8 w-full`})]}):d.isError?i(`div`,{className:f,children:i(H,{title:t(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:t(`common.error`,`Error`),onRetry:()=>void d.refetch()})}):h.length===0?i(V,{icon:k,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(B,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:fe})})}var Kt=`llm`,qt=[`profiles`,`runtimes`,`usage`,`test`],Jt=[`new`,`edit`];function Yt(e){return qt.some(t=>t===e)}function Xt(){let{t}=Q(),n=re(Kt),[r]=he(),{openNew:a}=le(),o=me(`/system/ai`,{t,isAdmin:!0})??{icon:S,title:t(`system.ai`,`AI`)};if(n!==`present`)return i(_e,{icon:o.icon,title:o.title,children:i(Zt,{presence:n})});let s=r.get(`tab`),c=Yt(s)?s:`profiles`,l={profiles:t(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:t(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),usage:t(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),test:t(`ai.testSubtitle`,`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`)},u=c===`profiles`?e(q,{size:`sm`,type:`button`,"data-testid":`ai-add-profile`,onClick:a,children:[i(d,{className:`h-3.5 w-3.5`}),t(`ai.addProfile`,`Add profile`)]}):void 0;return i(ge,{icon:o.icon,title:o.title,subtitle:l[c],actions:u,defaultSection:`profiles`,sectionsLabel:`${o.title} sections`,sections:[{id:`profiles`,label:t(`ai.tabProfiles`,`Profiles`),content:i(ft,{}),ownedParams:Jt},{id:`runtimes`,label:t(`ai.tabRuntimes`,`Runtimes`),content:i(gt,{})},{id:`usage`,label:t(`ai.tabUsage`,`Usage`),content:i(Gt,{})},{id:`test`,label:t(`ai.tabTest`,`Test`),content:i(It,{})}]})}function Zt({presence:t}){let{t:n}=Q();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(J,{className:`h-8 w-64`}),i(J,{className:`h-40 w-full`})]}):t===`unknown`?i(H,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(V,{icon:S,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{Xt as AiProfilesPage,Xt as default};
@@ -1 +0,0 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{sr as o}from"./player-overlays-BT3xIHAn.js";import{Ha as s}from"./client-CgAb3Nw-.js";import{Ea as c,_a as l,ei as u,lr as d}from"./src-DX_JbsFG.js";import{t as f}from"./useTranslation-BJr-n0es.js";import{P as p,ur as m}from"./index-Cgn0pmzp.js";a();function h(e,t){let n=e=>e.map(e=>e.type===`group`?{...e,fields:n(e.fields)}:e.type===`sub-tabs`?{...e,tabs:e.tabs.map(e=>({...e,fields:n(e.fields)}))}:e.type===`info`&&typeof e.content==`string`?{...e,content:e.content.split(`{{brokerId}}`).join(t)}:e);return{...e,sections:e.sections.map(e=>({...e,fields:n(e.fields)}))}}function g(e,t){if(!e)return t;let n=new Set;for(let r of e.sections){let e=r.fields;for(let r of e)!(`key`in r)||typeof r.key!=`string`||d(r,t,e)&&n.add(r.key)}let r={};for(let[e,i]of Object.entries(t))n.has(e)&&(r[e]=i);return r}function _({kind:a,addonId:d,brokerId:_,initialValues:v,onSubmit:y,onCancel:b,submitLabel:x,disabled:S}){let{t:C}=f(),[w,T]=i(v??{}),[E,D]=i(null),O=l({kind:a,...d===void 0?{}:{addonId:d}}),k=t(()=>{let e=O.data;if(e&&typeof e==`object`&&`sections`in e&&Array.isArray(e.sections)){let t=e;return s(_===void 0?t:h(t,_),w)}},[O.data,_,w]);r(()=>{v!==void 0&&T(v)},[v]);let A=c(),j=async()=>{D(null);let e=g(k,w);try{let t=await A.mutateAsync({kind:a,settings:e,...d===void 0?{}:{addonId:d}});D(t.ok?{ok:!0}:{ok:!1,error:t.error})}catch(e){D({ok:!1,error:e instanceof Error?e.message:String(e)})}};return e(`div`,{className:`space-y-3`,children:[O.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(o,{className:`h-3.5 w-3.5 animate-spin`}),` `,C(`brokers.brokerForm.loadingSchema`)]}),k&&n(p,{schema:k,values:w,onChange:T}),O.isError&&e(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[C(`brokers.brokerForm.failedToLoadSettingsSchema`,`Failed to load settings schema:`),` `,O.error instanceof Error?O.error.message:C(`brokers.brokerForm.unknownError`,`Unknown error`)]}),!k&&!O.isLoading&&!O.isError&&n(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:n(m,{i18nKey:`brokers.brokerForm.noSchema`,values:{kind:a},components:{code:n(`code`,{className:`font-mono`})}})}),E&&n(`div`,{className:`rounded border px-3 py-2 text-[11px] ${E.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:E.ok?C(`brokers.brokerForm.connectionOk`,`Connection OK.`):C(`brokers.brokerForm.testFailed`,`Test failed: {{value1}}`,{value1:E.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[n(u,{variant:`outline`,size:`sm`,onClick:b,children:C(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[n(u,{variant:`outline`,size:`sm`,onClick:()=>{j()},disabled:A.isPending||!k,children:A.isPending?C(`brokers.brokerForm.testing`,`Testing…`):C(`brokers.brokerForm.testConnection`,`Test connection`)}),n(u,{variant:`primary`,size:`sm`,onClick:()=>{let{_calendarCatalog:e,...t}=g(k,w);y(t)},disabled:!k||S,children:x??C(`common.save`,`Save`)})]})]})]})}export{_ as t};
@@ -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,An as d,Bn as f,Ci as p,D as m,In as h,Lt as g,Mi as _,Pt as v,Si as y,Sn as b,Vr as x,Zr as S,bi as C,ci as w,cn as T,dt as E,fn as D,gi as O,mi as k,mn as A,ot as j,pn as M,sr as N,wn as P,xn as F,yn as I}from"./player-overlays-BT3xIHAn.js";import{ba as L,ga as ee,ha as te,ma as ne}from"./client-CgAb3Nw-.js";import{t as re}from"./hard-drive-download-CUmPIudl.js";import{t as ie}from"./memory-stick-Bh-D1JrM.js";import{t as ae}from"./unlink-Db_gKOzw.js";import{$l as oe,An as se,Cn as R,Dr as ce,Er as z,Md as B,Od as le,P as ue,Ql as de,Qr as V,Sn as fe,So as pe,St as H,Su as me,Tr as he,Xc as ge,_r as _e,ac as ve,at as ye,dd as U,di as be,ei as W,en as xe,eu as Se,fc as Ce,fi as we,fr as Te,gr as Ee,hc as De,hr as Oe,il as ke,kd as G,mc as Ae,mi as je,mr as Me,oc as Ne,pc as Pe,pi as Fe,pl as Ie,pr as Le,si as Re,tn as ze,tu as Be,vr as Ve,wn as He,xn as Ue,yl as We,yt as Ge}from"./src-DX_JbsFG.js";import{t as K}from"./i18n-Zscg3Dkf.js";import{t as q}from"./useTranslation-BJr-n0es.js";import{gr as Ke,x as qe}from"./index-Cgn0pmzp.js";import{t as Je}from"./AdminPage-Qn0NDZXK.js";import{t as Ye}from"./NodeAddonsSettingsPanel-AvBI4Evv.js";import{f as Xe,l as Ze,m as Qe,u as $e}from"./board-model-B0Q2QBXn.js";import{t as J}from"./format-size-DIxKXxtj.js";import{n as et,t as tt}from"./useNodeUrlSelection-cuUDxmhY.js";s();var nt={unpaired:`Not paired`,pending:`Pairing…`,paired:`Paired`},rt=new Set([`paired`,`rejected`,`failed`,`expired`]);function Y(e){return rt.has(e)}function it(e){return e.replace(/\D/g,``).slice(0,6)}function at(e){return e.length===6}function ot(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 st(e,t){return e.includes(`:`)?`[${e}]:${t}`:`${e}:${t}`}function ct(e){return e.length<=23?e:`${e.slice(0,20)}…`}function lt({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 ut(e){return e===`awaiting-both`||e===`awaiting-hub`}var dt={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`},ft=2e3,pt=1e3;function mt(e){return e.message.length>0?e.message:K.t(`pairing.agentsFoundSection.requestFailed`)}function ht(e){return e.length===6?`${e.slice(0,3)} ${e.slice(3)}`:e}function gt(e){let[t,n]=o(()=>Date.now());return a(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),pt);return()=>clearInterval(t)},[e]),t}function _t({target:n,onClose:r,onSettled:s,onOpenNode:c}){let{t:u}=q(),[d,f]=o(null),[p,m]=o(null),[h,g]=o(``),[_,v]=o(null),y=t(null),b=B.agentPairing.beginPairing.useMutation(),x=B.agentPairing.confirmPairing.useMutation(),S=B.agentPairing.rejectPairing.useMutation();a(()=>{if(n===null){y.current=null,f(null),m(null),g(``),v(null);return}y.current!==n&&(y.current=n,b.mutateAsync({host:n.host,port:n.port}).then(e=>{y.current===n&&f(e.pairingId)}).catch(e=>{y.current===n&&m(mt(e))}))},[n]);let C=B.agentPairing.getPairing.useQuery({pairingId:d??``},{enabled:d!==null,refetchInterval:e=>{let t=e.state.data?.state;return t!==void 0&&Y(t)?!1:ft}}),w=vt(x.data??S.data??null,C.data??null),T=lt({view:w,beginError:p}),E=w!==null&&Y(w.state),D=t(!1);a(()=>{if(!E){D.current=!1;return}D.current||(D.current=!0,s())},[E,s]);let O=gt(w!==null&&!E),k=()=>{d===null||!at(h)||(v(null),x.mutate({pairingId:d,code:h},{onError:e=>{v(mt(e)),g(``)}}))};return i(Te,{open:n!==null,onOpenChange:e=>!e&&r(),children:e(Me,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(_e,{children:[i(Ve,{children:u(`pairing.pairingDialog.title`,{node:n?.nodeId??``})}),i(Oe,{children:n===null?``:u(`pairing.pairingDialog.eachScreenShowsACode`,`Each screen shows a code; you type the code from the OTHER screen. Agent at {{value1}}`,{value1:st(n.host,n.port)})})]}),e(Le,{className:`space-y-4`,children:[i(yt,{phase:T}),T===`send-failed`&&p!==null&&i(z,{title:u(`pairing.pairingDialog.couldNotStartThePairing`,`Could not start the pairing`),message:p}),w!==null&&!E&&i(bt,{view:w,phase:T,now:O,typed:h,onType:e=>g(it(e)),onSubmit:k,confirmError:_,busy:x.isPending}),T===`paired`&&w!==null&&i(xt,{nodeId:w.nodeId,onOpenNode:c,onClose:r}),E&&T!==`paired`&&w?.failure!=null&&i(z,{message:w.failure})]}),i(Ee,{children:E||T===`send-failed`?i(W,{type:`button`,variant:`outline`,onClick:r,children:u(`common.close`,`Close`)}):e(l,{children:[i(W,{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`)}),ut(T)&&e(W,{type:`button`,disabled:!at(h)||x.isPending,onClick:k,children:[x.isPending&&i(N,{className:`h-4 w-4 animate-spin`}),u(`common.confirm`,`Confirm`)]})]})})]})})}function vt(e,t){if(t===null)return e;if(e===null)return t;let n=e=>(Y(e.state)?10:e.state===`completing`?5:0)+ +!!e.hubConfirmed+ +!!e.agentConfirmed;return n(e)>n(t)?e:t}function yt({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(N,{className:`h-4 w-4 animate-spin`}),r&&i(k,{className:`h-4 w-4`}),a&&i(w,{className:`h-4 w-4`}),dt[t]]})}function bt({view:t,phase:n,now:r,typed:a,onType:o,onSubmit:s,confirmError:c,busy:l}){let{t:u}=q();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 — read it out to the agent`)}),i(`p`,{"data-testid":`hub-code`,className:`mt-1 font-mono text-3xl font-semibold tracking-widest text-foreground`,children:ht(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).`)})]}),ut(n)?i(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),s()},children:i(H,{label:u(`pairing.pairingDialog.codeShownOnTheAgent`,`Code shown on the agent`),description:u(`pairing.pairingDialog.typeTheSixDigitsThe`,`Type the six digits the agent displays. Do not copy the code above.`),...c===null?{}:{error:c},children:i(U,{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:ot(t.expiresAt,r)})})]})]})}function xt({nodeId:t,onOpenNode:n,onClose:r}){let{t:a}=q(),{nodes:o}=le(),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(T,{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(W,{type:`button`,size:`sm`,variant:`outline`,disabled:!s,onClick:()=>{r(),n(t)},children:a(`pairing.pairingDialog.openNode`,`Open node`)})]})}var St={paired:`success`,pending:`warning`,unpaired:`default`};function Ct({state:t,connected:n}){let{t:r}=q();return e(`span`,{className:`inline-flex items-center gap-1.5`,children:[i(Re,{variant:St[t],className:`text-[10px]`,children:nt[t]}),t===`paired`&&i(`span`,{className:`text-[10px] text-foreground-muted`,children:n?r(`common.connected`):r(`pairing.agentStateBadge.notConnected`,`not connected`)})]})}s();var X={pending:0,unpaired:1,paired:2};function wt(e){if(e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function Tt({onOpenNode:t}){let{t:r}=q(),a=V(),s=B.useUtils(),c=B.agentPairing.listDiscoveredAgents.useQuery(void 0,{refetchInterval:15e3}),[u,f]=o(null),[p,h]=o(null),[g,_]=o(!1),[v,y]=o(``),[b,x]=o(``),[S,C]=o(null),[w,T]=o(!1),E=()=>void s.agentPairing.listDiscoveredAgents.invalidate(),D=B.agentPairing.addAgentByAddress.useMutation({onSuccess:()=>{_(!1),y(``),x(``),C(null),E()},onError:e=>C(e.message)}),O=B.agentPairing.unpairAgent.useMutation({onSuccess:e=>{h({tone:`success`,message:`${e.nodeId}: ${e.next}${e.agentNotified?``:` The agent could not be told; forget the hub on its own page.`}`}),E()},onError:e=>h({tone:`danger`,message:r(`pairing.agentsFoundSection.unpairFailed`,`Unpair failed: {{message}}`,{message:e.message})})}),k=n(()=>(c.data?.agents??[]).toSorted((e,t)=>X[e.state]-X[t.state]),[c.data]),A=async()=>{T(!0);try{await s.agentPairing.listDiscoveredAgents.fetch({refresh:!0}),E()}finally{T(!1)}},j=()=>{let e=wt(b);if(e===null){C(`The port must be a whole number between 1 and 65535.`);return}C(null),D.mutate({host:v.trim(),...e===void 0?{}:{port:e}})},M=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`})&&(h(null),O.mutate({nodeId:e.nodeId}))},I=n(()=>[{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:st(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(Ct,{state:e.state,connected:e.connected}),sortValue:e=>X[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:ct(e.fingerprint)}),sortValue:e=>e.fingerprint},{key:`actions`,header:``,align:`right`,notSortableReason:`Row actions`,render:e=>e.state===`unpaired`?i(W,{type:`button`,size:`sm`,onClick:()=>f({nodeId:e.nodeId,host:e.host,port:e.port}),children:r(`pairing.agentsFoundSection.pair`,`Pair`)}):e.state===`paired`?i(W,{type:`button`,size:`sm`,variant:`outline`,disabled:O.isPending,onClick:()=>void M(e),children:r(`pairing.agentsFoundSection.unpair2`,`Unpair`)}):null}],[O.isPending,r]);return e(Ue,{headingId:`agents-found`,title:r(`pairing.agentsFoundSection.agentsFoundOnTheNetwork`,`Agents found on the network`),icon:P,testId:`agents-found`,actions:e(l,{children:[e(W,{type:`button`,size:`sm`,variant:`outline`,disabled:w,onClick:()=>void A(),children:[w?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(F,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.scan`,`Scan`)]}),e(W,{type:`button`,size:`sm`,onClick:()=>_(e=>!e),children:[i(d,{className:`h-3.5 w-3.5`}),r(`pairing.agentsFoundSection.addByAddress`,`Add by address`)]})]}),children:[e(`div`,{className:`${m} 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&&!D.isPending&&j()},children:[i(H,{label:r(`pairing.agentsFoundSection.address`,`Address`),description:r(`pairing.agentsFoundSection.aPrivateOrLocalAddress`,`A private or local address only.`),...S===null?{}:{error:S},children:i(U,{value:v,onChange:e=>y(e.target.value),placeholder:`192.0.2.20`,"aria-label":r(`pairing.agentsFoundSection.agentAddress`,`Agent address`),autoComplete:`off`})}),i(H,{label:r(`pairing.agentsFoundSection.port`,`Port`),description:r(`pairing.agentsFoundSection.optional`,`Optional.`),children:i(U,{value:b,onChange:e=>x(e.target.value),placeholder:`4444`,inputMode:`numeric`,"aria-label":r(`pairing.agentsFoundSection.agentPort`,`Agent port`),className:`w-24`})}),e(W,{type:`submit`,size:`sm`,className:`mt-5`,disabled:v.trim().length===0||D.isPending,children:[D.isPending&&i(N,{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(z,{title:r(`pairing.agentsFoundSection.couldNotListAgents`,`Could not list agents`),message:c.error?.message??r(`pairing.agentsFoundSection.requestFailed`,`Request failed`),onRetry:E}):c.isLoading?i(`p`,{className:`py-4 text-center text-xs text-foreground-muted`,children:r(`pairing.agentsFoundSection.lookingForAgents`,`Looking for agents…`)}):k.length===0?i(ce,{icon:P,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(R,{columns:I,rows:k,rowKey:e=>e.nodeId,minWidthPx:720,defaultSort:{columnKey:`state`,dir:`asc`}})]}),i(_t,{target:u,onClose:()=>f(null),onSettled:E,onOpenNode:t})]})}function Et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Dt(e){if(!Et(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 Ot(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 kt(e){let t=/^100\.(\d+)\./.exec(e);if(t===null)return!1;let n=Number(t[1]);return n>=64&&n<=127}function At(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 jt(e,t){if(typeof t==`string`&&Ot(t))return t.trim();let n=e.filter(e=>!e.includes(`:`)),r=n.find(e=>!e.startsWith(`127.`)&&!e.startsWith(`169.254.`)&&!Z(e)&&!kt(e)&&At(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 Mt(e){return`http://${e}:4444/`}function Nt(e,t){let n=new URL(Mt(e));return n.searchParams.set(`ticket`,t),n.toString()}function Pt(){return window.open(`about:blank`,`_blank`)}function Ft(e,t){return e===null||e.closed?!1:(e.location.href=t,!0)}function It({node:t}){let{info:n}=qe();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 Lt(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 Rt(e){return e===`running`?`running`:e===`crashed`||e===`failed`?`error`:`stopped`}var zt=[`trace`,`debug`,`info`,`warn`,`error`];function Bt({proc:t,nodeId:n,defaultExpanded:r,activePanel:a,onTogglePanel:s}){let{t:c}=q(),l=t.services??[],u=l.length===1,[d,f]=o(u||r),[p,m]=o(null),[h,g]=o(`info`),v=t.name.includes(`(core)`),x=Pe(),S=Ae(),w=De(),T=async e=>{m(e);try{await x.mutateAsync({nodeId:n,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{m(null)}},E=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 w.mutateAsync({nodeId:r,level:e}),g(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?y:C,{className:`h-3 w-3 text-muted-foreground shrink-0`}),v?i(D,{className:`h-3.5 w-3.5 text-primary shrink-0`}):i(_,{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(ye,{status:Rt(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:J(t.memoryRss)}),i(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0`,children:Lt(t.uptimeSeconds)}),!v&&e(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e(be,{children:[i(je,{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(we,{align:`end`,className:`min-w-[70px] py-0.5`,children:zt.map(e=>i(Fe,{onClick:()=>O(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===h?`text-primary font-semibold`:``}`,children:e},e))})]}),i(`button`,{onClick:E,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(I,{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(`button`,{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(A,{className:`h-3 w-3`})}),i(`button`,{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(b,{className:`h-3 w-3`})}),i(`button`,{onClick:()=>T(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(I,{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(ze,{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(xe,{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 Vt({nodeId:e,processes:t}){let{t:n}=q(),[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(Bt,{proc:t,nodeId:e,defaultExpanded:n===0,activePanel:r,onTogglePanel:s},t.name))})}var Ht={system:0,managed:1,root:2};s();function Ut(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 Wt(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Gt({nodeId:t}){let{t:r}=q(),a=c(),o=G(`metrics.node-processes-snapshot`,e=>e.nodeId===t),{data:s}=Ne({nodeId:t}),l=o?.processes??s,u=n(()=>l?[...l]:[],[l]),d=n(()=>[{key:`classification`,header:r(`cluster.processesTab.class`,`Class`),sortValue:e=>Ht[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:Wt(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=>J(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:Ut(e.uptimeSec)})}],[r]);return e(`div`,{className:`space-y-4`,children:[i(`div`,{className:`flex items-start justify-end gap-4`,children:e(`button`,{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(F,{className:`h-3 w-3`}),` `,r(`common.refresh`)]})}),i(R,{columns:d,rows:u,rowKey:e=>e.pid,minWidthPx:880,maxBodyHeight:He,emptyMessage:r(`cluster.processesTab.scanning`,`Scanning…`)})]})}s();var Kt=96;function qt({title:e,points:t,mainLabel:r,gcLabel:a,formatValue:o,emptyMessage:s,gapMs:c}){return i(ue,{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:Kt,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(ue,{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:Kt,formatValue:e=>r(e),axisFor:()=>({floor:o,scale:s}),emptyMessage:a})}function Jt(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 Yt(e,t,n,r){let i=e.get(t),a=Jt(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 Xt(e,t,n){let r=e;for(let e of L(t,n))r=Yt(r,e.key,e.kind,e.point);return r}function Zt(e,t){let n=e;for(let e of t)for(let t of e.points)n=Yt(n,e.key,e.kind,t);return n}function Qt(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 $t=12e4;function en(e,t){return e===null?!1:t-e>$t}function tn(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 nn(e){for(let t of e.values()){let e=t.points.at(-1);if(e&&e.cpuMainPercent!==null)return!0}return!1}var rn={key:`cpu`,dir:`desc`};function an(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 on(e){return e.points.at(-1)?.memoryRssBytes??null}function sn(e,t,n){let r=n.trim().toLowerCase();return r===``?!0:e.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function cn(e,t){return t===`memory`?on(e):an(e)}function ln(e,t,n){let r=e.filter(e=>t.selectedKeys.size>0&&!t.selectedKeys.has(e.key)?!1:sn(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=cn(e,t.sort.key),o=cn(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 un(e,n=720){let r=G(`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}=ve({forNodeId:e,sinceMs:c,maxPoints:n});a(()=>{d!==void 0&&s(e=>{let t=Zt(e,d.series);return u.current=Qt(t),t})},[d]);let p=r?.timestamp;a(()=>{r==null||p===void 0||(en(u.current,p)&&l(u.current??0),s(e=>{let t=Xt(e,r.processes,p);return u.current=Qt(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:tn(i),sampleCount:m,threadSplitAvailable:nn(i),loadingRetained:f,durable:d?.durable??null,bucketMs:d?.bucketMs??null,cadenceMs:d?.cadenceMs??null,retainedSamples:d?.retainedSamples??null}}var dn=`__unclaimed__`;function fn(e,t){return{kind:e,deviceId:t,cpu:0,cpuKnown:!0,rss:0,rssKnown:!0,count:0,roles:new Set}}function pn(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 mn(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)??fn(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])=>pn(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=fn(`unclaimed`,null);for(let e of a)o.count+=1,o.rss+=e.memoryRssBytes;return o.cpuKnown=!1,[...i,pn(dn,o)]}var hn=[{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 gn(e){return e.attribution===`measured`&&e.wiredToday}function _n(){let e=new Set;for(let t of hn)gn(t)&&e.add(t.family);return e}var vn=_n();function yn(e){return!vn.has(e.role)||e.deviceId===null?!1:e.attribution===`measured`}function bn(e){return`${e.addonId}${e.role}${e.unit}${e.pid??`-`}`}function xn(){return{cpuSeconds:0,cpuKnown:!0,rssBytes:0,rssKnown:!0,unitCount:0,roles:new Set}}function Sn(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 Cn(e){return Math.round(e*10)/10}function wn(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)yn(t)&&i.set(bn(t),t);let a=new Map,o=new Set;for(let n of t.entries){if(!yn(n)||n.deviceId===null)continue;let t=bn(n);o.add(t);let r=a.get(n.deviceId)??xn();r.unitCount+=1,r.roles.add(n.role);let s=Sn(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?Cn(n.cpuSeconds/r*100):null,rssBytes:n.rssKnown?n.rssBytes:null,unitCount:n.unitCount,roles:[...n.roles].toSorted()}}))}function Tn(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 En(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 Dn(e){let t=e.indexOf(`@`);return t===-1?{addonId:e,nodeId:null}:{addonId:e.slice(0,t),nodeId:e.slice(t+1)}}function On(e,t){let n=Dn(e);return n.nodeId===null?t.isHub:n.nodeId===t.nodeId}function kn(e,t){return e.filter(e=>On(e.addonId,t))}s();function An(e){let n=G(`metrics.node-processes-snapshot`,t=>t.nodeId===e.nodeId),r=me(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:kn(d,e)},n=c.current;if(c.current=t,n===null)return;let r=wn(n,t);r.length!==0&&s(e=>Tn(e,r))},[d,f,e.nodeId,e.isHub]);let p=d===void 0?[]:kn(d,e),m=n?.processes,h=mn(p,m);return{series:En(i),unclaimed:h.find(e=>e.kind===`unclaimed`)??null,loading:r.isPending,error:r.error===null?null:r.error.message}}function jn(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 Mn=25,Nn=64*1024*1024,Pn=1e4;function Fn({scope:t,cadenceMs:n}){let{t:r}=q(),a=An(t),{data:o=[]}=pe({isCamera:!0,projection:`slim`}),s=jn(o),c=he(n??Pn);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(v,{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(Ln,{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(In,{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:Mn,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:J,axisFloor:Nn,axisScale:`bytes`,gapMs:c,emptyMessage:r(`cameraLoad.memoryUnavailable`,`No memory reported.`)})]})]},t.deviceId))})]})}function In({deviceId:t,name:n}){let{t:r}=q();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 Ln({unclaimed:e}){let{t}=q();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?`—`:J(e.rssBytes)})})})}s();var Rn=256*1024*1024,zn=1e4;function Bn({nodeId:t,isHub:r}){let{t:a}=q(),{series:s,sampleCount:c,threadSplitAvailable:l,loadingRetained:u,bucketMs:d,cadenceMs:f}=un(t),[p,m]=o(``),[h,g]=o(new Set),[_,y]=o(rn),b=e=>e.key===`__root__`?a(`clusterLoad.bucketRoot`,`Node supervisor`):e.key===`__unattributed__`?a(`clusterLoad.bucketUnattributed`,`Unattributed processes`):e.key,x=he(d??f??zn),S=n(()=>ln(s,{search:p,selectedKeys:h,sort:_},b),[s,p,h,_]),C=e=>{g(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(Vn,{bucketMs:d,cadenceMs:f}),!l&&c>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(v,{className:`h-3 w-3 mt-0.5 shrink-0`}),i(`span`,{children:a(`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.`)})]}),c===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:u?a(`clusterLoad.loadingRetained`,`Reading the retained series from this node…`):a(`clusterLoad.waitingFirstSample`,`No retained samples for this node — waiting for the next snapshot (up to 20s). The chart needs two to draw a rate.`)}),s.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(M,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),i(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:a(`clusterLoad.searchPlaceholder`,`Find a runner…`),"aria-label":a(`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(Hn,{sort:_,onChange:y})]}),e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[s.map(e=>{let t=h.has(e.key);return i(`button`,{type:`button`,"aria-pressed":t,onClick:()=>C(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:b(e)},e.key)}),h.size>0&&e(`button`,{type:`button`,onClick:()=>g(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(E,{className:`h-2.5 w-2.5`}),a(`clusterLoad.clearFilter`,`All runners`)]})]})]}),s.length>0&&S.length===0&&i(`div`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:a(`clusterLoad.noMatches`,`No runner matches this search on {{count}} present. The node is reporting — the filter is hiding them.`,{count:s.length})}),i(`div`,{className:`space-y-3`,children:S.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:b(t)}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`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(qt,{title:l?a(`clusterLoad.cpuTitle`,`CPU % of one core`):a(`clusterLoad.cpuTitleLifetime`,`CPU % (ps lifetime average)`),mainLabel:a(`clusterLoad.seriesMain`,`Main threads`),gcLabel:a(`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:x,emptyMessage:a(`clusterLoad.cpuUnavailable`,`No thread split on this node. Lifetime average: {{avg}}%`,{avg:(t.points.at(-1)?.cpuLifetimePercent??0).toFixed(1)})}),i(Q,{title:a(`clusterLoad.memoryTitle`,`Memory RSS`),points:t.points.map(e=>({atMs:e.atMs,value:e.memoryRssBytes})),formatValue:J,axisFloor:Rn,axisScale:`bytes`,gapMs:x,emptyMessage:a(`clusterLoad.memoryUnavailable`,`No memory samples yet.`)})]})]},t.key))}),i(Fn,{scope:{nodeId:t,isHub:r},cadenceMs:f})]})}function Vn({bucketMs:e,cadenceMs:t}){let{t:n}=q();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 Hn({sort:t,onChange:n}){let{t:r}=q(),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(`button`,{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 Un=`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 Wn({nodeId:e,addonIds:t}){let{t:n}=q();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(Ye,{nodeId:e,addonIds:t,level:`global`,fieldScope:`perNode`,emptyMessage:Un,selfTabbed:!0})})}s();function Gn({nodeId:e,addons:t}){let{t:r}=q(),a=c(),{data:o,isLoading:s}=ge({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=We({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(R,{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(`select`,{value:n,onChange:n=>u.mutate({nodeId:e,capName:t.capName,addonId:n.target.value}),disabled:a||u.isPending||s,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,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:He})}s();function Kn(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 qn(t){let{t:n}=q(),[r,a]=o(!1),[s,l]=o(t.name),u=c(),d=Ce({onSuccess:()=>{u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),f=(t.localIps??[]).filter(e=>!e.includes(`:`)),m=(t.localIps??[]).filter(e=>e.includes(`:`)),g=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)}},_=[[`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(`input`,{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`&&g(),e.key===`Escape`&&a(!1)},disabled:d.isPending,autoFocus:!0}),i(`button`,{onClick:()=>void g(),disabled:d.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:n(`common.save`,`Save`),children:i(p,{className:`h-3.5 w-3.5`})}),i(`button`,{onClick:()=>a(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:n(`common.cancel`,`Cancel`),children:i(E,{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(`button`,{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(h,{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:Kn(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&&_.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}`))})]),m.length>0&&_.push([`IPv6`,i(`div`,{className:`flex flex-wrap gap-1.5`,children:m.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:_.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 Jn({nodeId:t,value:n,detectedHosts:r,status:s,errorMessage:c,onCommit:l}){let{t:u}=q(),[d,f]=o(n??``);a(()=>{f(n??``)},[n]);let m=r[0],h=m===void 0?`auto-detect`:`auto: ${m}`,g=s===`pending`,_=d.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(U,{"aria-label":u(`placementBoard.reachableHostInput.reachableHostFor`,`Reachable host for {{nodeId}}`,{nodeId:t}),type:`text`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:h,value:d,disabled:g,onChange:e=>f(e.target.value),onBlur:b,onKeyDown:e=>{e.key===`Enter`&&b(),e.key===`Escape`&&f(n??``)},className:`w-36`}),e(W,{variant:`outline`,size:`sm`,onClick:b,disabled:!y,"aria-label":u(`placementBoard.reachableHostInput.saveReachableHostFor`,`Save reachable host for {{nodeId}}`,{nodeId:t}),title:u(`placementBoard.reachableHostInput.saveReachableHost`,`Save reachable host`),children:[g?i(N,{className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):i(p,{className:`h-3 w-3`,"aria-hidden":`true`}),u(`common.save`,`Save`)]}),!v&&!g&&s===`success`&&i(p,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-label":u(`placementBoard.reachableHostInput.saved`,`Saved`),role:`img`}),s===`error`&&i(`span`,{title:c??u(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),children:i(O,{className:`h-3.5 w-3.5 shrink-0 text-danger`,"aria-label":c??u(`placementBoard.reachableHostInput.failedToSaveReachableHost`,`Failed to save reachable host`),role:`img`})})]})}s();function Yn(e){let t=te.safeParse(Xe(e,`color`));return t.success?t.data:null}function Xn(e,t){return t.variables?.agentNodeId===e?t.isPending?`pending`:t.isError?`error`:t.isSuccess?`success`:`idle`:`idle`}function Zn({nodeId:t,detectedHosts:r}){let{t:a}=q(),o=c(),s=ke(void 0),l=Ie({onSuccess:()=>Ze(o)}),u=Ie({onSuccess:()=>Ze(o)}),d=n(()=>s.data?.find(e=>e.nodeId===t)?.settings,[s.data,t]),f=Yn(d)??(s.isLoading?null:ee(t)),p=Qe(d,`reachableHost`),m=Xn(t,l),h=m===`error`?$e(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(fe,{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:ne.map(e=>{let t=f===e;return i(W,{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 ${se(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(fe,{label:a(`nodes.general.reachableHost`,`Reachable host`),children:i(Jn,{nodeId:t,value:p,detectedHosts:g,status:m,errorMessage:h,onCommit:(e,t)=>{l.mutate({agentNodeId:e,reachableHost:t})}})})]})}s();var Qn=[[`serverManagement`,`getServerPackageStatus`]];function $n({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 er({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 tr={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 nr(e){return e.outcome===`failed`?`error`:(e.outcome,e.accepted?`ok`:`warn`)}function rr(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 ir({node:t}){let{t:n}=q(),a=c(),s=V(),[l,d]=o(!1),[f,p]=o(null),m=t.isHub?void 0:{nodeId:t.id},h=Se(m,{refetchInterval:1e4,enabled:t.isOnline,retry:1}),g=h.data??null,_=r(()=>{a.invalidateQueries({queryKey:Qn})},[a]),v=oe({onSettled:_}),y=de({onSettled:_}),b=Be({onSettled:_}),x=r(async()=>{if(g?.latestVersion==null){p({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`)})){p(null);try{let e=await y.mutateAsync({version:g.latestVersion,...m});p({tone:nr(e),text:e.message}),e.restarting&&d(!0)}catch(e){p({tone:`warn`,text:rr(n,e)})}}},[y,s,t.name,m,g,n]),S=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`})){p(null);try{let e=await b.mutateAsync(m);p({tone:nr(e),text:e.message}),e.restarting&&d(!0)}catch(e){p({tone:`warn`,text:rr(n,e)})}}},[s,t.name,b,m,n]),C=()=>{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`}}},w=()=>{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`}}},T=g?.bootMode===`workspace`,E=t.isOnline&&g!=null&&!T&&g.updateAvailable&&g.updateState===`idle`&&!y.isPending,D=t.isOnline&&g!=null&&g.updateState===`idle`&&!b.isPending,O=t.isOnline?w():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($n,{...C()})]}),O!=null&&i($n,{...O})]}),!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(N,{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(er,{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.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&&T&&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).`)}),f!=null&&i(`p`,{role:`status`,className:`rounded border px-2 py-1.5 text-xs leading-relaxed ${tr[f.tone]}`,children:f.text}),l&&e(`div`,{className:`flex items-center gap-2 text-sm text-warning`,children:[i(N,{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(`button`,{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(N,{className:`h-3.5 w-3.5 animate-spin`}):i(F,{className:`h-3.5 w-3.5`}),n(`serverManagement.checkForUpdate`,`Check for update`)]}),E&&e(`button`,{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(N,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),n(`serverManagement.updateTo`,`Update to {{version}}`,{version:g?.latestVersion??``})]}),e(`button`,{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:!D,onClick:()=>void S(),children:[b.isPending?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(I,{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(re,{className:`h-3 w-3`}),n(`serverManagement.lastChecked`,`Last checked: {{when}}`,{when:new Date(g.lastCheckedAtMs).toLocaleString()})]})]})}s();function ar(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}=q(),s=j(),u=c(),d=V(),[f,p]=o(!1),[m,h]=o(`info`),[_,v]=o(!1),[y,b]=o(null),C=t.processes??[],w=t.addons.map(e=>e.id),T=ke(void 0),E=n(()=>{let e=T.data?.find(e=>e.nodeId===t.id);return ar(e?.settings)},[T.data,t.id]),[D,O]=o(!1),[k,A]=o(null),[M,N]=o(null),P=r(async()=>{if(D||t.isHub)return;let e=jt(t.localIps??[],E);if(e===null){A(`No LAN IPv4 on this node — open its :4444 URL by hand.`),N(null);return}let n=Pt();O(!0),A(null),N(null);try{let r=Dt(await s.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:t.id,dashboardBaseUrl:Mt(e)}})),i=r===null?null:r.dashboardUrl??Nt(e,r.ticket);if(i===null){n?.close(),A(`Hub did not return an unlock ticket.`);return}Ft(n,i)||(N(i),A(`Browser blocked the new tab — click the link below (or allow popups for this site).`))}catch(e){n?.close(),A(e instanceof Error?e.message:String(e))}finally{O(!1)}},[t.id,t.isHub,t.localIps,D,E,s.trpcClient]),F=async()=>{if(!_){v(!0),b(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});b({tone:e.stillListed?`warn`:`ok`,text:e.message}),e.stillListed||u.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}catch(e){b({tone:`warn`,text:a(`cluster.nodeCard.forgetFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{v(!1)}}},I=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),b(null);try{let e=await s.trpcClient.agentPairing.unpairAgent.mutate({nodeId:t.id});b({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){b({tone:`warn`,text:a(`cluster.nodeCard.unpairFailed`,{error:e instanceof Error?e.message:String(e)})})}finally{p(!1)}}},L=t.isHub?null:e(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void I(),disabled:f,title:a(`cluster.nodeCard.unpairThisNodeRevokesIts`,`Unpair this node — revokes its certificates; it must be paired again to rejoin`),children:[i(ae,{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(It,{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(`button`,{type:`button`,onClick:()=>void P(),disabled:D,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(x,{className:`h-3 w-3`}),D?a(`cluster.nodeCard.opening`,`Opening…`):a(`cluster.nodeCard.openDashboard`,`Open dashboard`)]}),L,e(`span`,{className:`flex items-center gap-1`,children:[i(S,{className:`h-3 w-3`}),` `,t.cpuPercent,`%`]}),e(`span`,{className:`flex items-center gap-1`,children:[i(ie,{className:`h-3 w-3`}),` `,t.memoryPercent,`%`]})]})]}),y!=null&&i(`p`,{role:`status`,className:`px-4 pt-2 text-xs ${y.tone===`ok`?`text-success`:`text-warning`}`,children:y.text}),(k!==null||M!==null)&&e(`p`,{role:`status`,className:`px-4 pt-2 text-xs text-warning`,children:[k,M!==null&&e(l,{children:[` `,i(`a`,{href:M,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(`button`,{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:C.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(qn,{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(Zn,{nodeId:t.id,detectedHosts:t.localIps??[]}),i(`div`,{className:`border-t border-border pt-1`,children:i(ir,{node:{id:t.id,name:t.name,isHub:t.isHub,isOnline:t.isOnline,rootPackage:t.rootPackage??null}})})]}),m===`forks`&&i(Vt,{nodeId:t.id,processes:C}),m===`processes`&&i(Gt,{nodeId:t.id}),m===`load`&&i(Bn,{nodeId:t.id,isHub:t.isHub}),m===`settings`&&i(Wn,{nodeId:t.id,addonIds:w}),m===`capabilities`&&i(Gn,{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(It,{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:[L,e(`button`,{type:`button`,onClick:()=>void F(),disabled:_,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(g,{className:`h-3 w-3`}),_?a(`cluster.nodeCard.forgetting`,`Forgetting…`):a(`cluster.nodeCard.forgetNode`,`Forget node`)]})]})]}),y!=null&&i(`p`,{role:`status`,className:`px-4 pb-3 text-xs leading-relaxed ${y.tone===`ok`?`text-success`:`text-warning`}`,children:y.text})]})}var sr=3,cr=7e3;function lr(e){return[...e].sort((e,t)=>e.isHub===t.isHub?0:e.isHub?1:-1)}function ur(e){return e.isHub?{}:{nodeId:e.id}}function dr(e){return e.updateState===`staging`||e.updateState===`pending-restart`||e.pendingVersion!==null?!0:!e.updateAvailable}async function fr(e,t){let n=ur(e),r=K.t(`helpers.clusterUpdateAll.noAnswer`);for(let i=1;i<=sr;i+=1)try{let r=await t.readStatus(n);return dr(r)?{nodeId:e.id,nodeName:e.name,outcome:`applied`,detail:K.t(`helpers.clusterUpdateAll.landed`,{state:r.updateState,version:r.runningVersion??K.t(`helpers.clusterUpdateAll.unknown`)})}:{nodeId:e.id,nodeName:e.name,outcome:`failed`,detail:K.t(`helpers.clusterUpdateAll.unchanged`,{version:r.runningVersion??K.t(`helpers.clusterUpdateAll.unknown`)})}}catch(e){r=e instanceof Error?e.message:String(e),i<sr&&await t.wait(cr)}return{nodeId:e.id,nodeName:e.name,outcome:`unconfirmed`,detail:K.t(`helpers.clusterUpdateAll.unconfirmed`,{attempts:sr,error:r})}}function pr(e){return e.accepted?`applied`:e.outcome===`failed`?`failed`:`refused`}async function mr(e,t){let n=[];for(let r of lr(e))try{let e=await t.apply(ur(r));n.push({nodeId:r.id,nodeName:r.name,outcome:pr(e),detail:e.message})}catch{n.push(await fr(r,t))}return n}s();function hr(){let{nodes:e,isLoading:t}=le(),r=n(()=>e??[],[e]);return{nodes:r,isLoading:t&&r.length===0}}var gr={applied:`border-success/40 bg-success/10 text-success`,refused:`border-warning/40 bg-warning/10 text-warning`,failed:`border-danger/40 bg-danger/10 text-danger`,unconfirmed:`border-warning/40 bg-warning/10 text-warning`};function _r(){let{t}=q(),s=V(),{nodes:c,isLoading:d}=hr(),[p,m]=Ke(),{selection:h,selectNode:g}=tt(c),_=h.node,v=n(()=>c.filter(e=>e.isOnline),[c]),y=v.length,b=c.filter(e=>!e.isOnline).length,x=de(),S=j(),[C,w]=o(!1),[T,E]=o([]),D=p.get(`unlockNode`),O=p.get(`returnTo`),[k,A]=o(null);a(()=>{if(D===null||O===null)return;let e=!1;return(async()=>{try{let t=await S.trpcClient.addons.custom.mutate({addonId:`system-config`,action:`mintAgentUiUnlockTicket`,input:{nodeId:D,dashboardBaseUrl:O}});if(e)return;let n=Dt(t),r=n===null?null:n.dashboardUrl??(()=>{let e=new URL(O);return e.searchParams.set(`ticket`,n.ticket),e.toString()})();if(r===null){A(`Could not mint an unlock ticket.`);return}let i=new URLSearchParams(p);i.delete(`unlockNode`),i.delete(`returnTo`),m(i,{replace:!0}),window.location.assign(r)}catch(t){e||A(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[D,O,p,m,S.trpcClient]);let M=r(async()=>{let e=v.map(e=>({id:e.id,name:e.name,isHub:e.isHub}));if(await s({title:t(`serverManagement.confirmUpdateAllTitle`,`Update all nodes`),message:t(`serverManagement.confirmUpdateAllBody`,`Update and restart every online node, agents first, hub last. Up-to-date nodes are skipped; this page reconnects when the hub comes back.`),confirmLabel:t(`serverManagement.confirmUpdateAllAction`,`Update all & restart`),variant:`warning`})){w(!0),E([]);try{E(await mr(e,{apply:e=>x.mutateAsync(e),readStatus:e=>S.trpcClient.serverManagement.getServerPackageStatus.query(e),wait:e=>new Promise(t=>setTimeout(t,e))}))}finally{w(!1)}}},[x,s,v,S,t]);return e(Je,{icon:f,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:[y>0&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs text-success`,children:t(`common.onlineCount`,{count:y})}),b>0&&i(`span`,{className:`rounded-full bg-destructive/10 px-2 py-0.5 text-xs text-destructive`,children:t(`common.offlineCount`,{count:b})}),y>1&&e(W,{type:`button`,size:`sm`,disabled:C,title:t(`serverManagement.updateAllHint`,`Sequenced agents-first, hub-last — up-to-date nodes are skipped.`),onClick:()=>void M(),children:[C?i(N,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),t(`serverManagement.updateAll`,`Update all nodes`)]})]}),children:[T.length>0&&i(`ul`,{"aria-label":`update-all-report`,className:`flex flex-col gap-1 text-xs`,children:T.map(t=>e(`li`,{"data-outcome":t.outcome,className:`rounded border px-2 py-1 ${gr[t.outcome]}`,children:[i(`span`,{className:`font-medium`,children:t.nodeName}),i(`span`,{className:`mx-1 uppercase tracking-wide`,children:t.outcome}),i(`span`,{className:`opacity-80`,children:t.detail})]},t.nodeId))}),k!==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:`),` `,k]}),i(Tt,{onOpenNode:g}),d?i(`div`,{className:`flex items-center justify-center py-12 text-muted-foreground`,children:t(`system.cluster.loadingClusterTopology`,`Loading cluster topology...`)}):_===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(et,{staleNodeId:h.staleNodeId,shownNodeName:_.name}),i(Ge,{selectedNodeId:_.id,onSelect:g,allowOffline:!0,alwaysShow:!0}),i(or,{node:_})]})]})}export{_r as ClusterPage};