@camstack/addon-admin-ui 1.2.686 → 1.2.687

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 (86) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/{Addons-3ySgTmpY.js → Addons-BB8thmUr.js} +1 -1
  3. package/dist/assets/{AdminPage-CnX4g1T5.js → AdminPage-pZDCIqxE.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-g35Q-Y2m.js → AdminSectionedPage-D_3Smhz4.js} +1 -1
  5. package/dist/assets/{AiProfiles-DYwZNixm.js → AiProfiles-CTHfmMI3.js} +1 -1
  6. package/dist/assets/{BootstrapSettingsForm-Cp6otL6N.js → BootstrapSettingsForm-fA1qw8jv.js} +1 -1
  7. package/dist/assets/Build-DGfc1DVn.js +42 -0
  8. package/dist/assets/{Calendars-C5fFB9bh.js → Calendars-AL7FX-JB.js} +1 -1
  9. package/dist/assets/{CameraGrids-kx6_btHO.js → CameraGrids-C0mzirSs.js} +1 -1
  10. package/dist/assets/{Cluster-D7lgp_3H.js → Cluster-BlRDcovj.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-BMUKDIQZ.js → CompositionBlockEditor-DmcDcnzk.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-Cgz2acUm.js → CompositionEditorPage-DfQ5fc3y.js} +1 -1
  13. package/dist/assets/{Data-L7OAyBm7.js → Data-D5zW63oa.js} +1 -1
  14. package/dist/assets/DeviceDetail-BqHDJCDT.js +2 -0
  15. package/dist/assets/{Devices-C3wsrK5K.js → Devices-Bd1Jl5m0.js} +1 -1
  16. package/dist/assets/{EmbedDevicePage-CJWLs0h9.js → EmbedDevicePage-DwEsXdVy.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-Ugf7qZrN.js → EmbedPlayerPage-DGp_0UWo.js} +1 -1
  18. package/dist/assets/{History-Bkb8SS6s.js → History-BUOnc8ZM.js} +1 -1
  19. package/dist/assets/{Identity-YEkh2m1V.js → Identity-eBvRzK4z.js} +1 -1
  20. package/dist/assets/{InstancesTable-B9vZgE2z.js → InstancesTable-By92ZqOw.js} +1 -1
  21. package/dist/assets/{IntegrationDetail-Eapr8HN5.js → IntegrationDetail-NK8FV49x.js} +1 -1
  22. package/dist/assets/{Integrations-DB2t-nuf.js → Integrations-BFf5NlbB.js} +1 -1
  23. package/dist/assets/{Integrations-Bm4bpdow.js → Integrations-yC-3Hdw4.js} +1 -1
  24. package/dist/assets/{Library-CTe2FjiB.js → Library-D7i9Qieo.js} +1 -1
  25. package/dist/assets/{Locations-DLZ0eCiE.js → Locations-EJD_zuN_.js} +1 -1
  26. package/dist/assets/{Logs-Dan6AcA1.js → Logs-DQzJfvwk.js} +1 -1
  27. package/dist/assets/{MyAccess-BT46dFoa.js → MyAccess-4mkEkpXB.js} +1 -1
  28. package/dist/assets/{Network-CYFPVX5D.js → Network-BWQpQ3n5.js} +1 -1
  29. package/dist/assets/{NodeAddonsSettingsPanel-C2HPI8cn.js → NodeAddonsSettingsPanel-C_TK4qDO.js} +1 -1
  30. package/dist/assets/{Notifications-ByVhaz5L.js → Notifications-D5ULVDrM.js} +1 -1
  31. package/dist/assets/{Pipeline-C_L_mlb3.js → Pipeline-DWPoeujN.js} +1 -1
  32. package/dist/assets/{Recordings-HRQgg-mT.js → Recordings-T3aJz1M5.js} +1 -1
  33. package/dist/assets/{ServerShell-CdxVT-o4.js → ServerShell-C6VBeatt.js} +1 -1
  34. package/dist/assets/{SessionsList-CIDhJh-a.js → SessionsList-CY1YjimZ.js} +1 -1
  35. package/dist/assets/{Showroom-BOQOATEQ.js → Showroom-fcx-JGCE.js} +1 -1
  36. package/dist/assets/{StorageLocationsTable-CbWGX5p5.js → StorageLocationsTable-CLEB5vQn.js} +1 -1
  37. package/dist/assets/{System-DFXhaqKS.js → System-E07ppx-8.js} +1 -1
  38. package/dist/assets/TemplateEditorDialog-DUO4bE0v.js +1 -0
  39. package/dist/assets/{Terminal-DeTRjM9E.js → Terminal-DkzDdNEx.js} +1 -1
  40. package/dist/assets/{TerminalPanel-CBZjJ8Dr.js → TerminalPanel-BmrPY108.js} +1 -1
  41. package/dist/assets/{TrainingProviders-BGB7X7Yd.js → TrainingProviders-CnB8QFbq.js} +1 -1
  42. package/dist/assets/{Viewer-xOVMdQTo.js → Viewer-Dg-oDdOT.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DhWElKZO.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cz4oDxbU.js} +1 -1
  44. package/dist/assets/action-draft-BdWIjGK-.js +1 -0
  45. package/dist/assets/{ai-page.helpers-BZHkaFn5.js → ai-page.helpers-CLp_BM_b.js} +1 -1
  46. package/dist/assets/{assignment-candidates-BT4pxrk1.js → assignment-candidates-DmONfQt7.js} +1 -1
  47. package/dist/assets/{authed-media-2LK5_j6R.js → authed-media-CYvYbnCi.js} +1 -1
  48. package/dist/assets/{board-model-CyYeClho.js → board-model-CEczoawG.js} +1 -1
  49. package/dist/assets/{device-detail-Bc52Y0_7.js → device-detail-ByzfE37H.js} +1 -1
  50. package/dist/assets/{device-integration-icon-YW7LMTlM.js → device-integration-icon-BpEyaNNm.js} +1 -1
  51. package/dist/assets/device-picker-model-avI94rid.js +1 -0
  52. package/dist/assets/{format-BLZTgKwl.js → format-BqZcr5Z7.js} +1 -1
  53. package/dist/assets/{hostInit-C2kdHdJb.js → hostInit-DLrPtXCY.js} +1 -1
  54. package/dist/assets/i18n-CmzYiG85.js +1 -0
  55. package/dist/assets/{icons-DFEHzatv.js → icons-_1fwK_Xw.js} +1 -1
  56. package/dist/assets/{index-B_SQlUTy.js → index-CAD0_JTV.js} +3 -3
  57. package/dist/assets/{index-sBLhF1qi.css → index-CJG5kQrR.css} +1 -1
  58. package/dist/assets/{linked-devices-model-DxVYGr4v.js → linked-devices-model-DN4c8QM1.js} +1 -1
  59. package/dist/assets/{mf-entry-bootstrap-0-f413d948.js → mf-entry-bootstrap-0-e45e9e1a.js} +2 -2
  60. package/dist/assets/mount-avI94rid.js +1 -0
  61. package/dist/assets/{notification-rule-status-C1FwwgLk.js → notification-rule-status-ikR-6LJe.js} +1 -1
  62. package/dist/assets/remoteEntry--50_xNtD.js +1 -0
  63. package/dist/assets/{scan-eye-DQQVMuam.js → scan-eye-C862nWtV.js} +1 -1
  64. package/dist/assets/shapes-D4IRNSXI.js +1 -0
  65. package/dist/assets/{src-B6L3EZPZ.js → src-JMmlGk-Y.js} +5 -5
  66. package/dist/assets/{sso-popup-DhV33whD.js → sso-popup-Dd0yy6b3.js} +1 -1
  67. package/dist/assets/{step-inspector-model-C_ZtNeXt.js → step-inspector-model-WZk2xDUO.js} +1 -1
  68. package/dist/assets/{use-scenes-feed-wH8tJH0x.js → use-scenes-feed-DjTd4H1D.js} +1 -1
  69. package/dist/assets/{use-stationary-objects-CA3H_5u_.js → use-stationary-objects-C49tIeOS.js} +1 -1
  70. package/dist/assets/{useAdminDeviceRemoval-C6hXBea3.js → useAdminDeviceRemoval-CO7rS4dm.js} +1 -1
  71. package/dist/assets/useEventInvalidation-avI94rid.js +1 -0
  72. package/dist/assets/{useNodeUrlSelection-BgovsIjz.js → useNodeUrlSelection-L9_7D0fD.js} +1 -1
  73. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Qh7JMlhu.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C2U0saQW.js} +2 -2
  74. package/dist/index.html +7 -7
  75. package/dist/server/addon.js +1 -1
  76. package/package.json +2 -2
  77. package/dist/assets/Build-BHMQT3nj.js +0 -44
  78. package/dist/assets/DeviceDetail-Dg8P-ST8.js +0 -2
  79. package/dist/assets/action-draft-DOLYOpcx.js +0 -1
  80. package/dist/assets/device-picker-model-DMQzZ8k0.js +0 -1
  81. package/dist/assets/i18n-DJdnRrxy.js +0 -1
  82. package/dist/assets/mount-DMQzZ8k0.js +0 -1
  83. package/dist/assets/remoteEntry-wJk-wuAb.js +0 -1
  84. package/dist/assets/shapes-BPdkDjXe.js +0 -1
  85. package/dist/assets/useEventInvalidation-DMQzZ8k0.js +0 -1
  86. package/dist/assets/useTemplateSave-CqHBkGA2.js +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.687] - 2026-11-16
11
+
12
+ ### Changed
13
+
14
+ - Build your system: tags are now edited in one shared Quick edit dialog (row action, and right after a new item is saved) instead of inside each editor, and every editor is an in-page section with a pinned header and footer
15
+
10
16
  ## [1.2.686] - 2026-11-16
11
17
 
12
18
  ### Changed
@@ -1,4 +1,4 @@
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{$i as d,Bn as f,Gi as p,Gt as m,In as h,Li as g,Lr as _,Q as v,Tn as y,Tt as b,Vn as x,Yn as S,Zt as C,ct as ee,er as w,ft as te,hr as T,na as E,ot as ne,tn as D,xi as re}from"./player-overlays-BLoaiapp.js";import{Xc as O}from"./client-BzNa5PJa.js";import{t as ie}from"./chevron-down-CBb-F8DT.js";import{i as k,u as A}from"./terminal-DU-tvcEm.js";import{$a as ae,Ga as oe,Gc as se,Hi as ce,Ja as le,Li as ue,Mp as de,Qa as j,Ri as fe,Ui as pe,Vi as me,Xa as he,Xf as M,Ya as N,Za as ge,ao as P,co as F,ct as _e,do as I,ei as L,eo as R,fr as ve,ho as ye,io as z,ip as be,kp as B,li as V,lo as xe,mo as H,ni as U,no as Se,oo as Ce,po as W,pr as we,qa as Te,ri as Ee,ro as De,ti as Oe,uo as ke,va as Ae,vt as G,zi as je,zl as Me}from"./src-B6L3EZPZ.js";import{t as K}from"./useTranslation-BJr-n0es.js";import"./mount-DMQzZ8k0.js";import{gi as Ne,mi as Pe,ot as Fe,st as Ie,ui as Le}from"./index-B_SQlUTy.js";import{t as q}from"./AdminPage-CnX4g1T5.js";import{i as Re,r as ze,t as Be}from"./addon-kind-filter-CEGKkC1O.js";import{t as J}from"./NodeAddonsSettingsPanel-C2HPI8cn.js";import{n as Y,r as Ve,t as He}from"./useNodeUrlSelection-BgovsIjz.js";function Ue(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 We={queued:{icon:g,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:_,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:S,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:E,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:k,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function X({item:e}){let{t:n}=K(),r=We[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 Z=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Ge=new Set([`done`,`failed`,`skipped`]);function Ke(e){return!Ge.has(e.phase)&&!Z.has(e.jobState)}function qe(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Z.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 Je(){let{data:e}=De({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=de(O.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 qe([...n.values()],Date.now())},[e,t])}var Ye={queued:{icon:g,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:_,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:E,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:k,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:y,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Xe({progress:e}){let{t:n}=K(),r=Ye[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 Ze(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 Qe(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function $e(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(Qe)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
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{$i as d,Bn as f,Gi as p,Gt as m,In as h,Li as g,Lr as _,Q as v,Tn as y,Tt as b,Vn as x,Yn as S,Zt as C,ct as ee,er as w,ft as te,hr as T,na as E,ot as ne,tn as D,xi as re}from"./player-overlays-BLoaiapp.js";import{Xc as O}from"./client-BzNa5PJa.js";import{t as ie}from"./chevron-down-CBb-F8DT.js";import{i as k,u as A}from"./terminal-DU-tvcEm.js";import{$a as ae,Ga as oe,Gc as se,Hi as ce,Ja as le,Li as ue,Mp as de,Qa as j,Ri as fe,Ui as pe,Vi as me,Xa as he,Xf as M,Ya as N,Za as ge,ao as P,co as F,ct as _e,do as I,ei as L,eo as R,fr as ve,ho as ye,io as z,ip as be,kp as B,li as V,lo as xe,mo as H,ni as U,no as Se,oo as Ce,po as W,pr as we,qa as Te,ri as Ee,ro as De,ti as Oe,uo as ke,va as Ae,vt as G,zi as je,zl as Me}from"./src-JMmlGk-Y.js";import{t as K}from"./useTranslation-BJr-n0es.js";import"./mount-avI94rid.js";import{gi as Ne,mi as Pe,ot as Fe,st as Ie,ui as Le}from"./index-CAD0_JTV.js";import{t as q}from"./AdminPage-pZDCIqxE.js";import{i as Re,r as ze,t as Be}from"./addon-kind-filter-CEGKkC1O.js";import{t as J}from"./NodeAddonsSettingsPanel-C_TK4qDO.js";import{n as Y,r as Ve,t as He}from"./useNodeUrlSelection-L9_7D0fD.js";function Ue(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 We={queued:{icon:g,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:_,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:S,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:E,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:k,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function X({item:e}){let{t:n}=K(),r=We[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 Z=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Ge=new Set([`done`,`failed`,`skipped`]);function Ke(e){return!Ge.has(e.phase)&&!Z.has(e.jobState)}function qe(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Z.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 Je(){let{data:e}=De({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=de(O.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 qe([...n.values()],Date.now())},[e,t])}var Ye={queued:{icon:g,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:_,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:_,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:E,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:k,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:y,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Xe({progress:e}){let{t:n}=K(),r=Ye[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 Ze(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 Qe(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function $e(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(Qe)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
2
  `)}function Q(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
3
  `)}var et={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function tt(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)}: ${et[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
4
4
  `)}var nt={},rt=3e4,it=`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 at({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=K(),c=l(),u=ee(),d=ne(),f=Se(nt,{staleTime:rt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),h=Ze(p,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),_=H({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),v=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:tt(e,g),variant:e.success?`default`:`danger`})},y=async t=>{try{await v(await _.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`})}},b=async()=>{let e=h.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:Q(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await y(r.isHub?{}:{nodeId:r.id})},x=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=Ze(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:$e(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await y({everywhere:!0})},S=_.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(M,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:S,className:it,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(D,{className:`h-3 w-3`}),_.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(h.length>1||i===!0||m.length>0)&&t(M,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:S,className:it,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(A,{className:`h-3 w-3`}),h.length>0?s(`addons.uninstallControls.everywhereCount`,{count:h.length}):s(`addons.uninstallControls.everywhere`)]})]})}function ot(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function st(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!ot(e))}function ct(e){return e.length-st(e,!1).length}c();function lt({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=K(),f=r===`upload`||r===`local`,[p,h]=s(!1),{data:g,isLoading:v,isError:y}=j({name:e}),x=g?st(g,p):[],S=g?ct(g):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:d(`addons.versionPicker.versions`,`Versions`)}),a(M,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(b,{className:`h-3 w-3`})})]}),f&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(m,{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:d(`addons.versionPicker.inPlace`,{kind:r===`upload`?d(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):d(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(Le,{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(_,{className:`h-3.5 w-3.5 animate-spin`}),d(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),y&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:d(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),x.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:x.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),f=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:d(`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)),ot(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:d(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(M,{variant:`unstyled`,type:`button`,"aria-label":d(`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:[f,o?a(E,{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:[f,a(M,{variant:`unstyled`,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?d(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):d(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(re,{className:`h-3 w-3`})})]},e.version)})}),!v&&!y&&g&&g.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:d(`addons.versionPicker.noVersionsFound`,`No versions found`)}),S>0&&a(M,{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:()=>h(e=>!e),children:p?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:S})})]})}c();var ut=`device-export`;function dt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===ut)}function ft(e){return e!==`local`&&e!==`upload`}function pt({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`,f=r&&i?v(`/api/addon-assets/${r}/${i}`):null,p=!!f&&!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:p?a(`img`,{src:f,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?T:w,{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`}),ft(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(m,{className:`h-2.5 w-2.5 text-white`})})]})}function mt({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=K();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(_,{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(M,{variant:`unstyled`,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(re,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(M,{variant:`unstyled`,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(ie,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(M,{variant:`unstyled`,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(ie,{className:`h-3 w-3 opacity-50`})]}),u]})}function ht({addonId:e}){let t=l(),{data:n=`inherit`}=le({addonId:e}),r=ke({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(M,{variant:`unstyled`,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 gt={id:`hub`,name:`Hub`,isHub:!0};function _t({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdateServer:f,onUpdate:p,isUpdating:m,jobProgress:g,bundle:_,bulkItem:v,disabledByBulk:y,isSystem:C,selectedNode:ee}){let{t:w}=K(),[te,E]=s(!1),[ne,D]=s(!1),[re,O]=s(null);o(()=>{O(null)},[i]);let A=re??i,[oe,se]=s(!1),[le,de]=s(!1),[j,he]=s(`logs`),N=l(),ge=Pe(),{manifest:P}=e,_e=!_&&!P.protected&&P.removable!==!1,I=!!_,L=_?.displayName??P.name,R=_?.packageName??P.packageName,ye=_?.version??P.packageVersion??P.version,z=_?.installSource??e.installSource,be=_?_.bundle?.description??_.addons[0]?.manifest.description:P.description,B=Ce({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]})}}),V=ae({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`addonPages`]]}),N.invalidateQueries({queryKey:[[`capabilities`]]}),N.invalidateQueries({queryKey:[[`integrations`]]})}}),xe=F({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`alerts`]]})}}),H=e.health,U=H?.phase===`failed`&&!H.inGracePeriod,Se=U&&H?.nextRetryAt&&!H.retrying,W=Ue(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${U?`border-red-500/50`:`border-border`}`,children:[U&&H&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{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:w(`addons.addonCard.failedToLoad`,{attempt:H.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:H.lastError?.message??w(`addons.addonCard.unknownError`,`Unknown error`)}),Se&&H.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:w(`addons.addonCard.autoRetryAt`,{time:new Date(H.nextRetryAt).toLocaleTimeString()})})]}),t(M,{variant:`unstyled`,type:`button`,disabled:xe.isPending||H.retrying,onClick:e=>{e.stopPropagation(),xe.mutate({packageName:R})},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:w(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(S,{className:`h-3 w-3 ${xe.isPending||H.retrying?`animate-spin`:``}`}),w(`addons.addonCard.retryNow`,`Retry now`)]})]}),W!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{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:w(`addons.addonCard.processProblem.${W.kind}`)}),W.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:W.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(pt,{isBundle:I||!!P.components&&P.components.length>1,installSource:z,addonId:I?_.addons[0]?.manifest.id:P.id,iconPath:I?_.bundle?.icon??_.addons[0]?.manifest.icon:P.icon,color:I?_.addons[0]?.manifest.color:P.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:L}),!r&&a(mt,{version:ye,availableUpdate:i,...A===void 0?{}:{selectedVersion:A},isUpdating:m,installSource:z,disabled:y,...p&&A!==void 0?{onUpdate:()=>p(A)}:{},onOpenPicker:()=>D(e=>!e),children:ne&&a(lt,{packageName:R,currentVersion:ye,...z?{installSource:z}:{},...i!==void 0&&A!==void 0?{selectedVersion:A,onSelect:e=>{O(e),D(!1)}}:{},onInstall:e=>{D(!1),V.mutate({packageName:R,version:e})},onClose:()=>D(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[R!==L&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:R}),I&&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(T,{className:`h-3 w-3`}),_.addons.length]}),C&&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:w(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(S,{className:`h-3 w-3`}),w(`addons.addonCard.system`,`System`)]}),v!=null&&a(X,{item:v}),c!==void 0&&a(Ae,{variant:`warning`,title:w(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:w(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),c!==void 0&&f!==void 0&&a(M,{type:`button`,size:`sm`,variant:`secondary`,onClick:f,children:w(`clusterUpdate.updateServer`,`Update server`)}),g!=null&&a(Xe,{progress:g})]}),be&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:be}),!I&&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`?w(`addons.addonCard.forked`):w(`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`:W===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!I&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(M,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),B.mutate({addonId:P.id})},disabled:B.isPending||y,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(S,{className:`h-3 w-3 ${B.isPending?`animate-spin`:``}`}),w(`addons.addonCard.restart`,`Restart`)]}),t(M,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),se(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${oe?`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(x,{className:`h-3 w-3`}),w(`addons.addonCard.logs`,`Logs`)]}),!I&&t(M,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),de(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${le?`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(h,{className:`h-3 w-3`}),w(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),_e&&a(at,{packageName:P.packageName,displayName:P.name,selectedNode:ee??gt,disabled:y})]}),n&&n.nodes.length>1&&!I&&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:w(`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:w(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:w(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:w(`common.synced`)})]},e.nodeId))})]}),oe&&!I&&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(M,{variant:`unstyled`,type:`button`,onClick:()=>he(`logs`),className:`px-2 py-0.5 transition-colors ${j===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.logs`,`Logs`)}),a(M,{variant:`unstyled`,type:`button`,onClick:()=>he(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${j===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(M,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),se(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(b,{className:`h-3.5 w-3.5`})})]}),j===`logs`&&a(we,{addonId:P.id,maxHeight:`max-h-64`,showFilters:!1}),j===`events`&&a(ve,{addonId:P.id,category:`addon.*`,maxHeight:`max-h-64`})]}),I&&t(u,{children:[a(M,{variant:`unstyled`,type:`button`,onClick:()=>E(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(te?d:ie,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),te&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:_.addons.map(e=>a(_t,{addon:e,hideVersion:!0},e.manifest.id))})]}),le&&!I&&a(ue,{open:!0,onOpenChange:e=>!e&&de(!1),children:t(je,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ce,{children:t(pe,{className:`flex items-center gap-2`,children:[a(h,{className:`h-4 w-4 text-primary`}),w(`addons.addonCard.settingsTitle`,{name:L})]})}),t(fe,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:w(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(J,{nodeId:null,addonIds:[P.id],level:`global`,fieldScope:`cluster`,emptyMessage:w(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),dt(P)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.deviceExport`,`Device export`)}),a(G,{addonId:P.id,onOpenDevice:e=>ge(`/devices/${e}`)})]}),ft(z)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(ht,{addonId:P.id})]}),P.components&&P.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.components`,{count:P.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:P.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(me,{children:a(M,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>de(!1),children:w(`common.close`,`Close`)})})]})})]})}c();var vt=`.tgz,.tar.gz,.zip`;function yt({onUploadSuccess:e}){let{t:r}=K(),[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(v(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(V,{ref:l,accept:vt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(M,{variant:`unstyled`,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(_,{className:`w-3.5 h-3.5 animate-spin`}):a(m,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var bt=/```[^\n]*\n([\s\S]*?)```/g;function xt(e){let t=[],n=0;for(let r of e.matchAll(bt)){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 St(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function Ct(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?St(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 wt(e,t){let n=e.split(`
@@ -1 +1 @@
1
- import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{st as n}from"./src-B6L3EZPZ.js";function r({icon:r,title:i,subtitle:a,actions:o,nav:s,embedded:c=!1,children:l}){return c?e(t,{children:l}):e(n,{icon:r,title:i,subtitle:a,actions:o,nav:s,children:l})}export{r as t};
1
+ import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{st as n}from"./src-JMmlGk-Y.js";function r({icon:r,title:i,subtitle:a,actions:o,nav:s,embedded:c=!1,children:l}){return c?e(t,{children:l}):e(n,{icon:r,title:i,subtitle:a,actions:o,nav:s,children:l})}export{r as t};
@@ -1 +1 @@
1
- import{R as e,S as t,et as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{it as r}from"./src-B6L3EZPZ.js";import{gi as i}from"./index-B_SQlUTy.js";n();function a({paramName:n=`tab`,defaultSection:a,sections:o,...s}){let[c,l]=i(),u=a??o[0]?.id??``,d=c.get(n),f=o.some(e=>e.id===d)?d??u:u,p=e((e,t)=>{l(r=>{let i=new URLSearchParams(r);for(let e of t)i.delete(e);return i.set(n,e),i},{replace:!0})},[n,l]);return t(r,{...s,paramName:n,defaultSection:a,sections:o,activeSection:f,onSectionChange:p})}export{a as t};
1
+ import{R as e,S as t,et as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{it as r}from"./src-JMmlGk-Y.js";import{gi as i}from"./index-CAD0_JTV.js";n();function a({paramName:n=`tab`,defaultSection:a,sections:o,...s}){let[c,l]=i(),u=a??o[0]?.id??``,d=c.get(n),f=o.some(e=>e.id===d)?d??u:u,p=e((e,t)=>{l(r=>{let i=new URLSearchParams(r);for(let e of t)i.delete(e);return i.set(n,e),i},{replace:!0})},[n,l]);return t(r,{...s,paramName:n,defaultSection:a,sections:o,activeSection:f,onSectionChange:p})}export{a as t};
@@ -1,3 +1,3 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as d,D as f,G as p,L as m,Lr as h,Q as g,Rn as _,Tt as v,ft as y,ha as b,mn as x,oi as S,sa as C,tn as w,xi as T,yn as E,yt as D,zn as O}from"./player-overlays-BLoaiapp.js";import{xi as k}from"./client-BzNa5PJa.js";import{t as A}from"./flask-conical-D7tbJQpj.js";import{t as j}from"./message-square-plus-_aGccjyj.js";import{$i as M,Fr as N,Ls as P,Mr as F,Op as ee,Pr as te,Ta as ne,Xf as I,ap as re,da as L,di as ie,fa as R,ga as z,ip as ae,q as oe,ut as B,va as V,ya as H}from"./src-B6L3EZPZ.js";import{t as U}from"./i18n-DJdnRrxy.js";import{t as W}from"./useTranslation-BJr-n0es.js";import"./mount-DMQzZ8k0.js";import{b as G,gi as K,pt as q}from"./index-B_SQlUTy.js";import{t as J}from"./AdminSectionedPage-g35Q-Y2m.js";import{t as se}from"./AdminPage-CnX4g1T5.js";import{t as ce}from"./InstancesTable-B9vZgE2z.js";import{a as le,c as ue,d as de,f as fe,i as pe,l as Y,n as me,o as he,p as ge,r as _e,s as X,t as ve,u as ye}from"./ai-page.helpers-BZHkaFn5.js";c();function be(){let{t}=W(),n=D(),r=R({functionCap:`llm`}).data??[],a=s({queryKey:me,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=u({mutationFn:e=>n.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??``,l=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return i(F,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${f} grid gap-4 sm:grid-cols-2`,children:_e.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(Y):r,u=c(n),d=r.find(e=>e.id===u);return e(`div`,{children:[i(ie,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:l(n)}),i(y,{id:`llm-default-${n}`,"aria-label":l(n),value:u,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...u!==``&&!s.some(e=>e.id===u)?[{value:u,label:d?.name??u}]:[],...s.map(e=>({value:e.id,label:X(e)===``?e.name:`${e.name} · ${X(e)}`}))]}),u!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:t(`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:t(`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)})]},n)})})})}var xe=2e3;function Z(e){return U.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function Se(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Ce({nodeId:t,value:r,onChange:a}){let{t:c}=W(),l=D(),[f,p]=o(``),[m,g]=o(null),[_,v]=o(!1),b=s({queryKey:ve,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),x=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),S=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{g(e),v(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),C=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{v(!0),x.refetch()}}),w=s({queryKey:pe,enabled:C.isPending,refetchInterval:C.isPending?xe:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,E=n(()=>{let e=(b.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Z(e.sizeBytes)}`})),n=(x.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:Z(e.sizeBytes),node:t})})),r=m?.ok===!0?[{value:`custom`,label:`${m.label} · ${Z(m.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[b.data,x.data,m,t,c]),O=e=>{if(e===``){a(null);return}if(e===`custom`){if(m?.ok!==!0)return;a({model:m.model,modelId:m.label,supportsVision:m.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=b.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=x.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{f.trim()!==``&&S.mutate({ref:f.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(B,{label:c(`ai.model`,`Model`),required:!0,children:i(y,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:Se(r),options:E,onChange:e=>O(e.target.value)})}),i(B,{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:f,onChange:e=>p(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(),k())}}),e(I,{size:`sm`,variant:`secondary`,type:`button`,disabled:f.trim()===``||S.isPending,onClick:()=>k(),children:[S.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):i(d,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),S.isError&&i(z,{message:S.error instanceof Error?S.error.message:c(`common.error`,`Error`)}),m?.ok===!1&&i(z,{message:m.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(m.candidates??[]).map(e=>i(I,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${f.trim().split(`:`)[0]??``}:${e}`;p(t),S.mutate({ref:t})},children:e},e)),m.requiredBytes!==void 0&&i(I,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(m.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Z(m.requiredBytes)})})]})}),m?.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:m.label}),i(V,{variant:m.purpose===`vision`?`info`:`default`,children:m.purpose}),i(V,{variant:`default`,children:Z(m.totalBytes)})]}),m.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:m.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(I,{size:`sm`,type:`button`,disabled:C.isPending||_,onClick:()=>C.mutate(m.model),children:[C.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):i(T,{className:`h-3.5 w-3.5`}),_?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),w!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:w.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:w.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:w.file,index:w.fileIndex,count:w.fileCount,done:Z(w.downloadedBytes),total:w.totalBytes===void 0?``:` / ${Z(w.totalBytes)}`})})]}),C.isError&&i(z,{message:C.error instanceof Error?C.error.message:c(`common.error`,`Error`)})]})]})}function we({value:t,onChange:n}){let{t:r}=W(),a=D(),o=s({queryKey:pe,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(h,{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=he(a),s=o.nodeId===t;return e(I,{variant:`unstyled`,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(V,{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 Te(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Ee({providerConfig:e,onProviderConfigChange:t}){return i(we,{value:Te(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function De({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=k.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Ce,{nodeId:Te(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 Oe=new Map([[`ai/apple-node`,Ee],[`ai/managed-model`,De]]);function ke(e){return Oe.get(e)??null}c();function Q(e,t){let n=e[t];return typeof n==`string`?n:``}function Ae({row:a}){let{t:c}=W(),d=D(),f=l(),p=s({queryKey:n(()=>[q,a.addonId,`ai-lead`,a.id],[a]),queryFn:async()=>{let e=d.trpcClient.integrationInstances,[t,n]=await Promise.all([e.describe.query({addonId:a.addonId}),e.getInstance.query({addonId:a.addonId,id:a.id})]);return{description:t,instance:n}}}),[m,g]=o({}),_=t({}),v=t(!1),b=u({mutationFn:e=>d.trpcClient.integrationInstances.updateInstance.mutate({addonId:a.addonId,id:a.id,values:e}),onSuccess:async()=>{await f.invalidateQueries({queryKey:[q]}),await f.invalidateQueries({queryKey:[L]}),g({})}}),x=r(e=>{_.current={..._.current,...e},g(t=>({...t,...e})),!v.current&&(v.current=!0,queueMicrotask(()=>{let e=_.current;_.current={},v.current=!1,b.mutate(e)}))},[b]),S=p.data?.description.kinds?.find(e=>e.id===a.kindId),C=p.data?.instance?.formValues,w=n(()=>({...C,...m}),[C,m]),T=S?.widgets??[],E=T.some(e=>e.placement===`model`),O=n(()=>({...Q(w,`nodeId`)===``?{}:{nodeId:Q(w,`nodeId`)},...typeof w.modelRef==`object`&&w.modelRef!==null?{model:w.modelRef}:{}}),[w]),k={id:Q(w,`model`),supportsVision:w.supportsVision===!0},A=u({mutationFn:()=>d.trpcClient.llm.listModels.mutate({addonId:a.addonId,kind:a.kindId??``,profileId:a.id})});if(p.isPending)return null;if(p.isError)return i(z,{variant:`warning`,message:p.error.message});let j=A.data?.ok===!0?A.data.models:[],M=A.data?.ok===!1?A.data:null,N=e=>{let t=j.find(t=>t.id===e);x({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[T.map(({id:e})=>{let t=ke(e);return t===null?i(z,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:O,onProviderConfigChange:e=>x({...Q(e,`nodeId`)===Q(O,`nodeId`)?{}:{nodeId:Q(e,`nodeId`)},...e.model!==void 0&&e.model!==O.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>x({model:e.id,supportsVision:e.supportsVision})},e)}),!E&&e(B,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(I,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(y,{"aria-label":c(`ai.model`,`Model`),value:k.id,onChange:e=>N(e.target.value),options:[...j.some(e=>e.id===k.id)||k.id===``?[]:[{value:k.id,label:k.id}],...j.map(e=>({value:e.id,label:e.label??e.id}))]})]}),M!==null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:M.message}),A.isError&&i(`p`,{className:`mt-1 text-xs text-danger`,children:A.error.message})]}),b.isError&&i(z,{variant:`warning`,message:b.error.message})]})}c();var je=5e3;function Me(e){return U.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Ne(){let{t}=W(),r=D(),a=s({queryKey:pe,refetchInterval:je,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(V,{variant:ge(n),children:t(fe(n))}),n.status?.downloadProgress!==void 0&&i(V,{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?`—`:Me(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=de(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(V,{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(F,{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(H,{className:`h-8 w-full`}),i(H,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:f,children:i(z,{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(M,{icon:_,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(te,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:N})})}var Pe=g(`/addon/ai/test-chat`),Fe=g(`/addon/ai/test-chat/chats`),Ie=6e5;function Le(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Ie)}function Re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(e){if(!Re(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 Be=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Ve(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Re(t))return null;switch(t.kind){case`status`:{let e=Be.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:ze(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:U.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*He(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(`
1
+ import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as d,D as f,G as p,L as m,Lr as h,Q as g,Rn as _,Tt as v,ft as y,ha as b,mn as x,oi as S,sa as C,tn as w,xi as T,yn as E,yt as D,zn as O}from"./player-overlays-BLoaiapp.js";import{xi as k}from"./client-BzNa5PJa.js";import{t as A}from"./flask-conical-D7tbJQpj.js";import{t as j}from"./message-square-plus-_aGccjyj.js";import{$i as M,Fr as N,Ls as P,Mr as F,Op as ee,Pr as te,Ta as ne,Xf as I,ap as re,da as L,di as ie,fa as R,ga as z,ip as ae,q as oe,ut as B,va as V,ya as H}from"./src-JMmlGk-Y.js";import{t as U}from"./i18n-CmzYiG85.js";import{t as W}from"./useTranslation-BJr-n0es.js";import"./mount-avI94rid.js";import{b as G,gi as K,pt as q}from"./index-CAD0_JTV.js";import{t as J}from"./AdminSectionedPage-D_3Smhz4.js";import{t as se}from"./AdminPage-pZDCIqxE.js";import{t as ce}from"./InstancesTable-By92ZqOw.js";import{a as le,c as ue,d as de,f as fe,i as pe,l as Y,n as me,o as he,p as ge,r as _e,s as X,t as ve,u as ye}from"./ai-page.helpers-CLp_BM_b.js";c();function be(){let{t}=W(),n=D(),r=R({functionCap:`llm`}).data??[],a=s({queryKey:me,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=u({mutationFn:e=>n.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??``,l=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return i(F,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${f} grid gap-4 sm:grid-cols-2`,children:_e.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(Y):r,u=c(n),d=r.find(e=>e.id===u);return e(`div`,{children:[i(ie,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:l(n)}),i(y,{id:`llm-default-${n}`,"aria-label":l(n),value:u,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...u!==``&&!s.some(e=>e.id===u)?[{value:u,label:d?.name??u}]:[],...s.map(e=>({value:e.id,label:X(e)===``?e.name:`${e.name} · ${X(e)}`}))]}),u!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:t(`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:t(`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)})]},n)})})})}var xe=2e3;function Z(e){return U.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function Se(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Ce({nodeId:t,value:r,onChange:a}){let{t:c}=W(),l=D(),[f,p]=o(``),[m,g]=o(null),[_,v]=o(!1),b=s({queryKey:ve,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),x=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),S=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{g(e),v(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),C=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{v(!0),x.refetch()}}),w=s({queryKey:pe,enabled:C.isPending,refetchInterval:C.isPending?xe:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,E=n(()=>{let e=(b.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Z(e.sizeBytes)}`})),n=(x.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:Z(e.sizeBytes),node:t})})),r=m?.ok===!0?[{value:`custom`,label:`${m.label} · ${Z(m.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[b.data,x.data,m,t,c]),O=e=>{if(e===``){a(null);return}if(e===`custom`){if(m?.ok!==!0)return;a({model:m.model,modelId:m.label,supportsVision:m.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=b.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=x.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{f.trim()!==``&&S.mutate({ref:f.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(B,{label:c(`ai.model`,`Model`),required:!0,children:i(y,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:Se(r),options:E,onChange:e=>O(e.target.value)})}),i(B,{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:f,onChange:e=>p(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(),k())}}),e(I,{size:`sm`,variant:`secondary`,type:`button`,disabled:f.trim()===``||S.isPending,onClick:()=>k(),children:[S.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):i(d,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),S.isError&&i(z,{message:S.error instanceof Error?S.error.message:c(`common.error`,`Error`)}),m?.ok===!1&&i(z,{message:m.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(m.candidates??[]).map(e=>i(I,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${f.trim().split(`:`)[0]??``}:${e}`;p(t),S.mutate({ref:t})},children:e},e)),m.requiredBytes!==void 0&&i(I,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(m.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Z(m.requiredBytes)})})]})}),m?.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:m.label}),i(V,{variant:m.purpose===`vision`?`info`:`default`,children:m.purpose}),i(V,{variant:`default`,children:Z(m.totalBytes)})]}),m.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:m.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(I,{size:`sm`,type:`button`,disabled:C.isPending||_,onClick:()=>C.mutate(m.model),children:[C.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):i(T,{className:`h-3.5 w-3.5`}),_?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),w!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:w.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:w.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:w.file,index:w.fileIndex,count:w.fileCount,done:Z(w.downloadedBytes),total:w.totalBytes===void 0?``:` / ${Z(w.totalBytes)}`})})]}),C.isError&&i(z,{message:C.error instanceof Error?C.error.message:c(`common.error`,`Error`)})]})]})}function we({value:t,onChange:n}){let{t:r}=W(),a=D(),o=s({queryKey:pe,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(h,{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=he(a),s=o.nodeId===t;return e(I,{variant:`unstyled`,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(V,{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 Te(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Ee({providerConfig:e,onProviderConfigChange:t}){return i(we,{value:Te(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function De({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=k.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Ce,{nodeId:Te(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 Oe=new Map([[`ai/apple-node`,Ee],[`ai/managed-model`,De]]);function ke(e){return Oe.get(e)??null}c();function Q(e,t){let n=e[t];return typeof n==`string`?n:``}function Ae({row:a}){let{t:c}=W(),d=D(),f=l(),p=s({queryKey:n(()=>[q,a.addonId,`ai-lead`,a.id],[a]),queryFn:async()=>{let e=d.trpcClient.integrationInstances,[t,n]=await Promise.all([e.describe.query({addonId:a.addonId}),e.getInstance.query({addonId:a.addonId,id:a.id})]);return{description:t,instance:n}}}),[m,g]=o({}),_=t({}),v=t(!1),b=u({mutationFn:e=>d.trpcClient.integrationInstances.updateInstance.mutate({addonId:a.addonId,id:a.id,values:e}),onSuccess:async()=>{await f.invalidateQueries({queryKey:[q]}),await f.invalidateQueries({queryKey:[L]}),g({})}}),x=r(e=>{_.current={..._.current,...e},g(t=>({...t,...e})),!v.current&&(v.current=!0,queueMicrotask(()=>{let e=_.current;_.current={},v.current=!1,b.mutate(e)}))},[b]),S=p.data?.description.kinds?.find(e=>e.id===a.kindId),C=p.data?.instance?.formValues,w=n(()=>({...C,...m}),[C,m]),T=S?.widgets??[],E=T.some(e=>e.placement===`model`),O=n(()=>({...Q(w,`nodeId`)===``?{}:{nodeId:Q(w,`nodeId`)},...typeof w.modelRef==`object`&&w.modelRef!==null?{model:w.modelRef}:{}}),[w]),k={id:Q(w,`model`),supportsVision:w.supportsVision===!0},A=u({mutationFn:()=>d.trpcClient.llm.listModels.mutate({addonId:a.addonId,kind:a.kindId??``,profileId:a.id})});if(p.isPending)return null;if(p.isError)return i(z,{variant:`warning`,message:p.error.message});let j=A.data?.ok===!0?A.data.models:[],M=A.data?.ok===!1?A.data:null,N=e=>{let t=j.find(t=>t.id===e);x({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[T.map(({id:e})=>{let t=ke(e);return t===null?i(z,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:O,onProviderConfigChange:e=>x({...Q(e,`nodeId`)===Q(O,`nodeId`)?{}:{nodeId:Q(e,`nodeId`)},...e.model!==void 0&&e.model!==O.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>x({model:e.id,supportsVision:e.supportsVision})},e)}),!E&&e(B,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(I,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(y,{"aria-label":c(`ai.model`,`Model`),value:k.id,onChange:e=>N(e.target.value),options:[...j.some(e=>e.id===k.id)||k.id===``?[]:[{value:k.id,label:k.id}],...j.map(e=>({value:e.id,label:e.label??e.id}))]})]}),M!==null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:M.message}),A.isError&&i(`p`,{className:`mt-1 text-xs text-danger`,children:A.error.message})]}),b.isError&&i(z,{variant:`warning`,message:b.error.message})]})}c();var je=5e3;function Me(e){return U.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Ne(){let{t}=W(),r=D(),a=s({queryKey:pe,refetchInterval:je,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(V,{variant:ge(n),children:t(fe(n))}),n.status?.downloadProgress!==void 0&&i(V,{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?`—`:Me(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=de(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(V,{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(F,{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(H,{className:`h-8 w-full`}),i(H,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:f,children:i(z,{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(M,{icon:_,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(te,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:N})})}var Pe=g(`/addon/ai/test-chat`),Fe=g(`/addon/ai/test-chat/chats`),Ie=6e5;function Le(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Ie)}function Re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(e){if(!Re(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 Be=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Ve(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Re(t))return null;switch(t.kind){case`status`:{let e=Be.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:ze(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:U.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*He(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
2
  `);for(;a>=0;){let e=r.slice(0,a).trim();if(r=r.slice(a+1),e.length>0){let t=Ve(e);t!==null&&(yield t)}a=r.indexOf(`
3
3
  `)}}let e=r.trim();if(e.length>0){let t=Ve(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Ue(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function We(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function Ge(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 Ke(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 qe(e,t){switch(e){case`resolving-image`:return U.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return U.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?U.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):U.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return U.t(`helpers.aiTestChat.phaseAnswering`)}}c();var Je=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Ye=360*60*1e3,Xe=40,Ze=160,$={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Qe(){let{t:s}=W();D();let[c,l]=o(``),[u,d]=o(``),[p,h]=o(``),[g,_]=o([]),[S,T]=o(null),[E,k]=o(`none`),[A,M]=o(`throwaway`),[N,P]=o(null),[ee,te]=o([]),[ne,L]=o(null),[B,V]=o(null),H=t(null);a(()=>()=>H.current?.abort(),[]);let U=r(async()=>{let e=await fetch(Fe,{credentials:`same-origin`});e.ok&&te((await e.json()).chats??[])},[]);a(()=>{A===`persistent`&&U()},[A,U]);let G=R({functionCap:`llm`}),K=n(()=>(G.data??[]).filter(e=>e.enabled),[G.data]),q=K.find(e=>e.id===c)??null,J=B!==null,se=r(async(e,t)=>{let n=new AbortController;H.current=n,L(null);let r=Le(q===null?{}:ye(q));V({...$,firstTokenTimeoutMs:r??0});let i=``,a=null,o,l=null,d=null,f;try{let s=await fetch(Pe,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:c,messages:e,...u.trim()===``?{}:{system:u.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...A===`persistent`?{persist:!0,...N===null?{}:{conversationId:N}}:{}})});if(!s.ok||s.body===null){let e=await s.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(s.status)}`)}for await(let e of He(s.body))switch(e.kind){case`status`:V(t=>({...t??$,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,V(t=>({...t??$,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,V(e=>({...e??$,text:i}));break;case`done`:d={outputTokens:e.outputTokens,latencyMs:e.latencyMs},f=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||L(e instanceof Error?e.message:s(`common.error`,`Error`))}finally{H.current=null,V(null)}f!==void 0&&(P(f),U());let p=n.signal.aborted&&i.length>0;l===null&&i.length===0&&!p||_(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??i,...l===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&l===null?{model:o}:{},...d===null?{}:d}])},[A,N,q,c,U,u,s]),ce=r(()=>{let e=p.trim();if(e===``||c===``||J)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...S===null?{}:{attachmentLabel:S.label,attachmentKind:S.ref.kind}},n=[...g,t];_(n),h(``);let r=S?.ref;T(null),k(`none`),se(A===`persistent`&&N!==null?[{role:`user`,content:e}]:Ue(n),r)},[A,N,p,S,c,se,J,g]),le=()=>H.current?.abort(),ue=()=>{H.current?.abort(),_([]),T(null),h(``),L(null),V(null),P(null)},de=async e=>{H.current?.abort();let t=await fetch(`${Fe}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();P(e),_(Ge(n)),V(null),L(null)};return e(`div`,{className:m,children:[i(F,{headingId:`ai-test-setup`,title:s(`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(ie,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:s(`ai.profile`,`Profile`)}),i(y,{id:`ai-test-profile`,value:c,onChange:e=>l(e.target.value),options:[{value:``,label:s(`ai.selectProfile`,`Select a profile…`)},...K.map(e=>({value:e.id,label:`${e.name} · ${X(e)}${Y(e)?` · vision`:``}`}))]}),K.length===0&&!G.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:s(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(ie,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:s(`ai.systemPrompt`,`System prompt (optional)`)}),i(ae,{id:`ai-test-system`,value:u,onChange:e=>d(e.target.value),placeholder:s(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(oe,{label:s(`ai.chatMode`,`Conversation mode`),value:A,options:[{value:`throwaway`,label:s(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:s(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{M(e),e===`throwaway`&&P(null)}}),A===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(I,{size:`sm`,variant:`secondary`,type:`button`,onClick:ue,children:[i(j,{className:`h-3.5 w-3.5`}),s(`ai.newChat`,`New chat`)]}),ee.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:ee.map(e=>i(`button`,{type:`button`,onClick:()=>void de(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===N?`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:s(`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.`)}),q!==null&&!Y(q)&&i(`p`,{className:`text-xs text-warning`,children:s(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),ne!==null&&i(z,{title:s(`ai.chatFailed`,`The test call failed`),message:ne}),e(F,{headingId:`ai-test-conversation`,title:s(`ai.testConversation`,`Conversation`),actions:e(I,{size:`sm`,variant:`ghost`,type:`button`,disabled:g.length===0&&S===null,onClick:ue,children:[i(w,{className:`h-3.5 w-3.5`}),s(`ai.clearChat`,`Clear`)]}),children:[i($e,{turns:g,live:B}),e(`div`,{className:`${f} space-y-2 border-t border-border`,children:[S!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[S.ref.kind===`snapshot`?i(C,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:S.label}),i(re,{size:`sm`,variant:`ghost`,type:`button`,icon:v,"aria-label":s(`ai.removeAttachment`,`Remove attachment`),onClick:()=>T(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(I,{size:`sm`,variant:E===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>k(E===`snapshot`?`none`:`snapshot`),children:[i(C,{className:`h-3.5 w-3.5`}),s(`ai.attachSnapshot`,`Camera snapshot`)]}),e(I,{size:`sm`,variant:E===`track`?`primary`:`outline`,type:`button`,onClick:()=>k(E===`track`?`none`:`track`),children:[i(b,{className:`h-3.5 w-3.5`}),s(`ai.attachTrack`,`Recent track`)]})]}),E===`snapshot`&&i(nt,{onPick:(e,t)=>{T({ref:{kind:`snapshot`,deviceId:e.id},label:s(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),k(`none`)}}),E===`track`&&i(it,{onPick:(e,t)=>{T({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:s(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),k(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(ae,{value:p,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ce())},placeholder:s(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":s(`ai.message`,`Message`)}),J?e(I,{size:`sm`,variant:`secondary`,type:`button`,onClick:le,children:[i(x,{className:`h-3.5 w-3.5`}),s(`ai.stop`,`Stop`)]}):e(I,{size:`sm`,type:`button`,disabled:p.trim()===``||c===``,onClick:ce,children:[i(O,{className:`h-3.5 w-3.5`}),s(`ai.send`,`Send`)]})]})]})]})]})}function $e({turns:t,live:n}){let{t:r}=W();return t.length===0&&n===null?i(M,{icon:A,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(et,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(tt,{attachment:n.mediaSent}),n.text.length>0&&i(et,{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(h,{className:`h-3.5 w-3.5 animate-spin`}),qe(n.phase,n.firstTokenTimeoutMs)]})]})]})}function et({turn:t,streaming:n=!1}){let{t:r}=W(),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(tt,{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(b,{className:`h-3 w-3`}):i(C,{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(C,{className:`h-3 w-3`}):i(b,{className:`h-3 w-3`}),Ke(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 tt({attachment:e}){let{t}=W(),n=We(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 nt({onPick:e}){let{t}=W(),n=P({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(h,{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(rt,{device:t,onPick:e},t.id))})}function rt({device:t,onPick:n}){let{t:r}=W(),a=ne(t,`compact`),{src:o}=p(t.id,{width:Ze});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(V,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function it({onPick:t}){let{t:r}=W(),a=D(),o=P({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:[...Je,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Ye,limit:Xe,projection:`slim`})});if(o.isLoading||u.isLoading)return i(h,{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(b,{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 at=1440*60*1e3,ot=[1,7,30,90];function st(){let{t}=W(),r=D(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*at},[a]),u=R({functionCap:`llm`}),d=s({queryKey:[...le,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(y,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:ot.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(F,{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(H,{className:`h-8 w-full`}),i(H,{className:`h-8 w-full`}),i(H,{className:`h-8 w-full`})]}):d.isError?i(`div`,{className:f,children:i(z,{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(M,{icon:S,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(te,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:N})})}c();var ct=`llm`,lt=[`profiles`,`runtimes`,`usage`,`test`],ut=[`instance`,`instance-new`];function dt(e){return lt.some(t=>t===e)}function ft(){let{t:e}=W(),t=ee(ct),[n]=K(),r=G(`/system/ai`,{t:e,isAdmin:!0})??{icon:E,title:e(`system.ai`,`AI`)};if(t!==`present`)return i(se,{icon:r.icon,title:r.title,children:i(gt,{presence:t})});let a=n.get(`tab`),o=dt(a)?a:`profiles`,s={profiles:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:e(`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:e(`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:e(`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.`)};return i(J,{icon:r.icon,title:r.title,subtitle:s[o],defaultSection:`profiles`,sectionsLabel:`${r.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:i(ht,{}),ownedParams:ut},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:i(Ne,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:i(st,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:i(Qe,{})}]})}function pt(e,t,n){let r=e.kind===`instance`?t.get(e.id):void 0;return r===void 0?void 0:n(r)}function mt(e,t){let n=t=>pt(t,e,X)??``,r=t=>pt(t,e,Y)??!1,a=t=>pt(t,e,ue)??``;return[{key:`model`,header:t(`ai.colModel`,`Model`),sortValue:n,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:n(e)||`—`})},{key:`vision`,header:t(`ai.colVision`,`Vision`),sortValue:e=>+!!r(e),render:e=>r(e)?i(V,{variant:`info`,children:t(`ai.vision`,`vision`)}):null},{key:`node`,header:t(`ai.colNode`,`Node`),sortValue:a,render:e=>i(`span`,{className:`text-xs text-foreground-muted`,children:a(e)||`—`})}]}function ht(){let{t}=W(),r=R({functionCap:ct}),a=n(()=>new Map((r.data??[]).map(e=>[e.id,e])),[r.data]),o=n(()=>mt(a,t),[a,t]);return e(`div`,{className:m,children:[i(be,{}),i(ce,{functionCap:ct,icon:E,title:t(`ai.profilesList`,`Profiles`),subtitle:t(`ai.profilesTableSubtitle`,`Each profile is one model endpoint; switch one off to keep it without using it.`),emptyTitle:t(`ai.noProfilesTitle`,`No AI profiles yet`),emptyDescription:t(`ai.noProfilesDescription`,`Add a profile to give features a model to talk to.`),addLabel:t(`ai.addProfile`,`Add profile`),extraColumns:o,lead:e=>i(Ae,{row:e})})]})}function gt({presence:t}){let{t:n}=W();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(H,{className:`h-8 w-64`}),i(H,{className:`h-40 w-full`})]}):t===`unknown`?i(z,{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(M,{icon:E,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{ft as AiProfilesPage,ft as default};
@@ -1 +1 @@
1
- import{C as e,K as t,R as n,S 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{t as o}from"./useTranslation-BJr-n0es.js";import{N as s,Nt as c,P as l,v as u,y as d}from"./index-B_SQlUTy.js";import{n as f}from"./NodeAddonsSettingsPanel-C2HPI8cn.js";a();function p(e,t){if(e.type===`group`){for(let n of e.fields)p(n,t);return}if(e.type===`sub-tabs`){for(let n of e.tabs)for(let e of n.fields)p(e,t);return}`value`in e&&(t[e.key]=e.value)}function m(e){let t={};for(let n of e.sections)for(let e of n.fields)p(e,t);return t}var h=`system-config-auth`;function g({sectionIds:e,omitSectionIds:n,hideSectionChrome:i,emptyMessage:a}){let o=u(),s=t(()=>{if(o.data===void 0)return null;let t=o.data.sections.filter(t=>!(e!==void 0&&!e.includes(t.id)||n?.includes(t.id)===!0||e===void 0&&t.id===`system-config-auth`));return{...o.data,sections:f(t,{...i===!0?{hideSectionChrome:i}:{}})}},[o.data,e,n,i]);return o.isPending?null:s===null||o.isError?r(`p`,{className:`text-sm text-foreground-muted`,children:a}):s.sections.length===0?null:r(_,{schema:s})}function _({schema:a}){let{t:u}=o(),f=d(),[p,h]=i(null),g=t(()=>m(a),[a]),_=n(async e=>{h(null);try{await f.mutateAsync({patch:e})}catch(e){throw h(e instanceof Error&&e.message.length>0?e.message:u(`system.bootstrapForm.saveFailed`,`Could not save`)),e}},[f,u]),v=l({schema:a,serverValues:g,onImmediateSave:e=>void _(e).catch(()=>void 0),onDeferredSave:_});return e(`div`,{className:`flex flex-col gap-3`,children:[p!==null&&r(`div`,{role:`alert`,className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:p}),r(c,{schema:a,values:v.values,onChange:v.handleChange,disabled:f.isPending}),r(s,{pendingCount:v.pendingKeys.length,onSave:()=>v.handleSave(v.pendingKeys),onDiscard:()=>v.handleDiscard(v.pendingKeys),saving:f.isPending})]})}export{h as n,g as t};
1
+ import{C as e,K as t,R as n,S 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{t as o}from"./useTranslation-BJr-n0es.js";import{N as s,Nt as c,P as l,v as u,y as d}from"./index-CAD0_JTV.js";import{n as f}from"./NodeAddonsSettingsPanel-C_TK4qDO.js";a();function p(e,t){if(e.type===`group`){for(let n of e.fields)p(n,t);return}if(e.type===`sub-tabs`){for(let n of e.tabs)for(let e of n.fields)p(e,t);return}`value`in e&&(t[e.key]=e.value)}function m(e){let t={};for(let n of e.sections)for(let e of n.fields)p(e,t);return t}var h=`system-config-auth`;function g({sectionIds:e,omitSectionIds:n,hideSectionChrome:i,emptyMessage:a}){let o=u(),s=t(()=>{if(o.data===void 0)return null;let t=o.data.sections.filter(t=>!(e!==void 0&&!e.includes(t.id)||n?.includes(t.id)===!0||e===void 0&&t.id===`system-config-auth`));return{...o.data,sections:f(t,{...i===!0?{hideSectionChrome:i}:{}})}},[o.data,e,n,i]);return o.isPending?null:s===null||o.isError?r(`p`,{className:`text-sm text-foreground-muted`,children:a}):s.sections.length===0?null:r(_,{schema:s})}function _({schema:a}){let{t:u}=o(),f=d(),[p,h]=i(null),g=t(()=>m(a),[a]),_=n(async e=>{h(null);try{await f.mutateAsync({patch:e})}catch(e){throw h(e instanceof Error&&e.message.length>0?e.message:u(`system.bootstrapForm.saveFailed`,`Could not save`)),e}},[f,u]),v=l({schema:a,serverValues:g,onImmediateSave:e=>void _(e).catch(()=>void 0),onDeferredSave:_});return e(`div`,{className:`flex flex-col gap-3`,children:[p!==null&&r(`div`,{role:`alert`,className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:p}),r(c,{schema:a,values:v.values,onChange:v.handleChange,disabled:f.isPending}),r(s,{pendingCount:v.pendingKeys.length,onSave:()=>v.handleSave(v.pendingKeys),onDiscard:()=>v.handleDiscard(v.pendingKeys),saving:f.isPending})]})}export{h as n,g as t};