@camstack/addon-admin-ui 1.2.710 → 1.2.712
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.
- package/CHANGELOG.md +14 -0
- package/dist/assets/{AccessSection-Cgv04lJf.js → AccessSection-BMHyeXXs.js} +1 -1
- package/dist/assets/{Addons-BJL6WRKD.js → Addons-Czq7HK5o.js} +1 -1
- package/dist/assets/{AdminPage-CFltVUtJ.js → AdminPage-DgcMq51y.js} +1 -1
- package/dist/assets/{AdminSectionedPage-DfZeI0TS.js → AdminSectionedPage-BKAltoSC.js} +1 -1
- package/dist/assets/{AiProfiles-DW29u0zA.js → AiProfiles-C3dVuuEs.js} +1 -1
- package/dist/assets/Archive-DD70ZFMv.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-DKjedbyR.js → BootstrapSettingsForm-DNIVKIZZ.js} +1 -1
- package/dist/assets/Build-B0vH9mDa.js +40 -0
- package/dist/assets/{Calendars-Bfl32yKa.js → Calendars-B1cBJoa1.js} +1 -1
- package/dist/assets/{Cluster-BT8yE3Jd.js → Cluster-BMZ_3SCr.js} +1 -1
- package/dist/assets/CompositionBlockEditor-Bj14wly_.js +2 -0
- package/dist/assets/{CompositionEditorPage-DAZ2EbrI.js → CompositionEditorPage-sUNp8qe7.js} +1 -1
- package/dist/assets/{Data-CCLq4I9_.js → Data-DcunBcmb.js} +1 -1
- package/dist/assets/DeviceDetail-CUJRNGTx.js +1 -0
- package/dist/assets/{Devices-BbWkqyWN.js → Devices-DxX8ybfM.js} +1 -1
- package/dist/assets/{EmbedDevicePage-C3hraaEM.js → EmbedDevicePage-G-VhlNDT.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-RHniI2xA.js → EmbedPlayerPage-CVF9_4Ua.js} +1 -1
- package/dist/assets/{History-B5SE1vph.js → History-DhTpectV.js} +1 -1
- package/dist/assets/{Identity-COMelIL5.js → Identity-BhsJ_1aP.js} +1 -1
- package/dist/assets/{InstancesTable-Gi6mvKws.js → InstancesTable-w-0XwFaG.js} +1 -1
- package/dist/assets/{IntegrationDetail-BJgK3HQZ.js → IntegrationDetail-jDFoyrP9.js} +1 -1
- package/dist/assets/{Integrations-DBIDhCAF.js → Integrations-C28hBhrU.js} +1 -1
- package/dist/assets/{Integrations-BAxIjtmf.js → Integrations-C9wh6FxD.js} +1 -1
- package/dist/assets/{Library-j-P8SKgP.js → Library-Cia1655I.js} +1 -1
- package/dist/assets/{Locations-BPRZSbLT.js → Locations-C1F9DRbX.js} +1 -1
- package/dist/assets/Logs-D24n8jj9.js +1 -0
- package/dist/assets/{MaskShapeCanvas-BN6ufTmt.js → MaskShapeCanvas-mnq8FU_f.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DsM7FPZE.js → MotionZonesSettings-D7_18_A_.js} +1 -1
- package/dist/assets/{MyAccess-B3gTfVDq.js → MyAccess-CHM9pog8.js} +1 -1
- package/dist/assets/{Network-CBAabM0h.js → Network-dIj7QC_n.js} +1 -1
- package/dist/assets/{NewExportModal-DGq6CWpy.js → NewExportModal-94DuvHcM.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-DCa3tgOb.js → NodeAddonsSettingsPanel-D_zP_si3.js} +1 -1
- package/dist/assets/Notifications-BtDiQ8BU.js +1 -0
- package/dist/assets/{PanelContent-CVkHXftN.js → PanelContent-_kL0sZaa.js} +1 -1
- package/dist/assets/{Pipeline-CdKKet5N.js → Pipeline-Cz-2Qr0F.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-m809AVSj.js → PrivacyMaskSettings-D4w4a5Cj.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BRoTpS7V.js → SceneMonitorEditor-CUpdk172.js} +1 -1
- package/dist/assets/{SessionsList-Dqh1pfhl.js → SessionsList-DoB89UjE.js} +1 -1
- package/dist/assets/{Showroom-DO5dhVVy.js → Showroom-Bc0RMx1T.js} +1 -1
- package/dist/assets/{StorageLocationsTable-DjJKdT5E.js → StorageLocationsTable-DdQZaTIL.js} +1 -1
- package/dist/assets/System-xU_4F1qj.js +2 -0
- package/dist/assets/TemplateEditorDialog-DFNJgsxk.js +1 -0
- package/dist/assets/{Terminal-AxKgimJQ.js → Terminal-CF3uGeFD.js} +1 -1
- package/dist/assets/{TrainingProviders-DqSWU0Ff.js → TrainingProviders-B_G3A6On.js} +1 -1
- package/dist/assets/{Viewer-BBtW52-D.js → Viewer-WyKz0Azc.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CnAAoU-a.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CkUFXaiW.js} +1 -1
- package/dist/assets/{action-draft-xWZeLJBc.js → action-draft-CwJf5eW2.js} +1 -1
- package/dist/assets/{ai-page.helpers-DutvjEb-.js → ai-page.helpers-BHBXHNQI.js} +1 -1
- package/dist/assets/{assignment-candidates-BJPEmgFZ.js → assignment-candidates-DRmDIzIf.js} +1 -1
- package/dist/assets/{authed-media-BTPD9Rqy.js → authed-media-DQnc3x5u.js} +1 -1
- package/dist/assets/{board-model-p3qXSelJ.js → board-model-CAPxQYkg.js} +1 -1
- package/dist/assets/{camera-block-model-BmK3dL9c.js → camera-block-model-Cvhw1ACQ.js} +1 -1
- package/dist/assets/{client-D93RkunP.js → client-CU9hiVrv.js} +12 -12
- package/dist/assets/{command-vocab-DGcpiUvY.js → command-vocab-3vo0YGZY.js} +1 -1
- package/dist/assets/{device-integration-icon-Cfi7eokn.js → device-integration-icon-CZX0mESs.js} +1 -1
- package/dist/assets/device-picker-model-BoRMX84w.js +1 -0
- package/dist/assets/{dist-SwLD2DK1.js → dist-BWrpV4hP.js} +1 -1
- package/dist/assets/dist-LYFPq0g9.js +1125 -0
- package/dist/assets/{format-Dzip80Uj.js → format-kIcasnZL.js} +1 -1
- package/dist/assets/{hostInit-C3sYu6u4.js → hostInit-BZDzYAHr.js} +1 -1
- package/dist/assets/i18n-B5Xm3ktp.js +1 -0
- package/dist/assets/{icons-C4C8iPI_.js → icons-Cnaoe6qZ.js} +1 -1
- package/dist/assets/{index-BZLBXpx-.js → index-ByN-VTu-.js} +4 -4
- package/dist/assets/index-CaKMKRxP.css +2 -0
- package/dist/assets/{linked-devices-model-ChJFxnJQ.js → linked-devices-model-B9Gz49sE.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-31325a3f.js → mf-entry-bootstrap-0-ac9760ea.js} +2 -2
- package/dist/assets/mount-BoRMX84w.js +1 -0
- package/dist/assets/{notification-rule-status-BWxeQ-_D.js → notification-rule-status-CFjuiCT9.js} +1 -1
- package/dist/assets/{player-overlays-hLBmOC8C.js → player-overlays-C-OmGoqt.js} +1 -1
- package/dist/assets/remoteEntry-ComxP4sU.js +1 -0
- package/dist/assets/src-BL1KpPQ2.js +279 -0
- package/dist/assets/{sso-popup-D5c1Dbz3.js → sso-popup-D9gVafKd.js} +1 -1
- package/dist/assets/{step-inspector-model-kpUIIlrE.js → step-inspector-model-zgo3LXy6.js} +1 -1
- package/dist/assets/{use-scenes-feed-D60vwQnn.js → use-scenes-feed-C4jyU72L.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-DHZF8Bhc.js → useAdminDeviceRemoval-B5adL9sz.js} +1 -1
- package/dist/assets/useEventInvalidation-BoRMX84w.js +1 -0
- package/dist/assets/{useNodeUrlSelection-CxldmcjV.js → useNodeUrlSelection-vqyOWkjs.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DgZGj8av.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DV6hhcvX.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +22 -1
- package/package.json +2 -2
- package/dist/assets/Archive-DJk2nZPq.js +0 -1
- package/dist/assets/Build-CaXtQUh_.js +0 -40
- package/dist/assets/CompositionBlockEditor-DmYv5ln7.js +0 -2
- package/dist/assets/DeviceDetail-DNKg72IG.js +0 -1
- package/dist/assets/Logs-RCKlFer4.js +0 -1
- package/dist/assets/Notifications-DccqInu6.js +0 -1
- package/dist/assets/System-nfPLxCLF.js +0 -2
- package/dist/assets/TemplateEditorDialog-eOBMrmCP.js +0 -1
- package/dist/assets/device-picker-model-Bbj8t_iL.js +0 -1
- package/dist/assets/dist-ClyHN0ce.js +0 -1125
- package/dist/assets/i18n-ILINfI4k.js +0 -1
- package/dist/assets/index-BFuQYqWe.css +0 -2
- package/dist/assets/mount-Bbj8t_iL.js +0 -1
- package/dist/assets/remoteEntry-9sIn-FFM.js +0 -1
- package/dist/assets/src-CR4MjS0h.js +0 -279
- package/dist/assets/useEventInvalidation-Bbj8t_iL.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.712] - 2026-11-20
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Energy card strings for the day selector and the centre circle (en, it)
|
|
15
|
+
|
|
16
|
+
## [1.2.711] - 2026-11-19
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- API explorer groups methods into collapsible macro groups with counts, de-emphasises the call type, and fills the input through typed controls (device picker, selects, bounded numbers, switches)
|
|
21
|
+
- Automation editor: a run's values and errors now show inside the When rows and Then steps, not in a separate box; adding a Then step no longer crashes the page
|
|
22
|
+
- Logs: the Watch tab is merged into Diagnostics — one list of log channels grouped by addon, with a camera picker per channel
|
|
23
|
+
|
|
10
24
|
## [1.2.710] - 2026-11-19
|
|
11
25
|
|
|
12
26
|
### Changed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as i,Tt as a,Xi as o,to as s}from"./player-overlays-
|
|
1
|
+
import{C as e,K as t,S as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as i,Tt as a,Xi as o,to as s}from"./player-overlays-C-OmGoqt.js";import{i as c}from"./terminal-DZ5OZpgC.js";import{Lr as l,Op as u,op as d}from"./src-BL1KpPQ2.js";import{t as f}from"./useTranslation-BJr-n0es.js";r();function p({id:t,title:r,icon:a,description:o,actions:c,tone:u=`default`,notice:d=null,onDismissNotice:f,children:p}){return n(l,{headingId:`access-${t}`,title:r,icon:a,actions:c,testId:`access-${t}`,children:e(`div`,{className:`${i} space-y-3`,children:[n(`div`,{className:s(`text-[11px] leading-relaxed`,u===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:o}),d!==null&&n(h,{notice:d,onDismiss:f}),p]})})}var m={success:{icon:o,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:c,line:`border-danger/40 text-danger`,mark:`text-danger`}};function h({notice:t,onDismiss:r}){let{t:i}=f(),o=m[t.tone],c=o.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:s(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,o.line),children:[n(c,{className:s(`mt-0.5 h-3.5 w-3.5 shrink-0`,o.mark),"aria-hidden":!0}),n(`span`,{className:`min-w-0 flex-1`,children:t.message}),r!==void 0&&n(u,{type:`button`,variant:`ghost`,size:`sm`,icon:a,"aria-label":i(`access.accessSection.dismiss`,`Dismiss`),onClick:r,className:`-my-1 h-5 w-5`})]})}function g(){let{data:e}=d();return t(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function _(e,t=null){return e===null?t:{tone:`danger`,message:e}}export{_ as n,g as r,p as t};
|
|
@@ -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{Bn as d,Gt as f,Hi as p,In as m,Q as h,Tn as g,Tt as _,Vn as v,Xi as y,Yn as b,Zt as x,ct as ee,er as S,ft as C,hr as te,ia as ne,ot as w,sa as T,tn as E,wi as D,zr as O}from"./player-overlays-
|
|
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{Bn as d,Gt as f,Hi as p,In as m,Q as h,Tn as g,Tt as _,Vn as v,Xi as y,Yn as b,Zt as x,ct as ee,er as S,ft as C,hr as te,ia as ne,ot as w,sa as T,tn as E,wi as D,zr as O}from"./player-overlays-C-OmGoqt.js";import{dl as k}from"./client-CU9hiVrv.js";import{t as re}from"./chevron-down-CBb-F8DT.js";import{i as A,u as j}from"./terminal-DZ5OZpgC.js";import{Aa as ie,Co as ae,Do as oe,Dp as se,Eo as ce,Gi as le,Ji as ue,Ki as de,Qp as M,So as fe,To as N,Wi as pe,Xi as me,Yi as he,_o as P,ao as F,bo as ge,ci as I,co as L,ct as _e,do as ve,fo as R,go as ye,hi as z,ho as be,hr as xe,li as B,ll as Se,lo as Ce,mo as V,mr as we,oi as H,oo as Te,ro as U,ru as Ee,si as De,so as Oe,tm as ke,uo as W,vo as Ae,xo as je,yp as G,yt as Me}from"./src-BL1KpPQ2.js";import{t as K}from"./useTranslation-BJr-n0es.js";import"./mount-BoRMX84w.js";import{Ci as Ne,_i as Pe,gt as Fe,ht as Ie,xi as Le}from"./index-ByN-VTu-.js";import{t as q}from"./NodeAddonsSettingsPanel-D_zP_si3.js";import{t as J}from"./AdminPage-DgcMq51y.js";import{i as Re,r as ze,t as Be}from"./addon-kind-filter-CEGKkC1O.js";import{n as Y,r as Ve,t as He}from"./useNodeUrlSelection-vqyOWkjs.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 X=`a singleton role: Roles & nodes is the one picker for it`,Z=[{cap:`pipeline-orchestrator`,addonId:`pipeline-orchestrator`,surface:`pipeline`,sectionIds:[`cluster-step-models`,`face-rescore`,`detail-crop`,`native-lease`,`load`,`failover`]},{cap:`pipeline-orchestrator`,addonId:`pipeline-orchestrator`,surface:`pipeline-roles`,fieldKeys:[`ingestNode`,`audioNode`,`motionNode`],reason:X},{cap:`face-gallery`,addonId:`pipeline-analytics`,surface:`pipeline`},{cap:`stream-broker`,addonId:`stream-broker`,surface:`pipeline`},{cap:`snapshot`,addonId:`snapshot`,surface:`pipeline`},{cap:`recording`,addonId:`recorder`,surface:`pipeline`},{cap:`recording`,addonId:`recorder`,surface:`pipeline-roles`,fieldKeys:[`recordingNodeId`],reason:X},{cap:`embedding-encoder`,addonId:`embedding-encoder`,surface:`pipeline`},{cap:`device-history`,addonId:`device-history`,surface:`history`},{cap:`alerts`,addonId:`alert-center`,surface:`notifications`},{cap:`metrics-provider`,addonId:`metrics-native`,surface:`nodes`},{cap:`login-method`,addonId:`auth-webauthn`,surface:`provider-page`},{cap:`llm`,addonId:`ai`,surface:`provider-page`},{cap:`log-destination`,addonId:`console-logging`,surface:`provider-page`},{cap:`core-blocks`,addonId:`core-blocks`,surface:`provider-page`},{cap:`custom-model-registry`,addonId:`model-studio`,surface:`addon-card`},{cap:`osd-manager`,addonId:`osd-manager`,surface:`addon-card`},{cap:`pipeline-analytics`,addonId:`pipeline-analytics`,surface:`addon-card`},{cap:`pipeline-analytics`,addonId:`pipeline-analytics`,surface:`pipeline-roles`,fieldKeys:[`postProcessingNodeId`],reason:X},{cap:`detection-pipeline`,addonId:`detection-pipeline`,surface:`addon-card`}],Q={pipeline:`/system/pipeline?view=nodes&node=__cluster__&ctab=settings`,"pipeline-roles":`/system/pipeline?view=nodes&node=__cluster__&ctab=roles-nodes`,history:`/system/history`,notifications:`/system/notifications?tab=settings`,nodes:`/system/nodes`};function We(e){return e.sectionIds===void 0&&e.fieldKeys===void 0}function Ge(e){return Z.filter(t=>t.addonId===e&&Q[t.surface]!==void 0)}function Ke(e){let t=Z.filter(t=>t.addonId===e),n=new Set(t.filter(e=>e.surface===`addon-card`&&We(e)).map(e=>e.cap));return{capabilities:[...new Set(t.map(e=>e.cap))].filter(e=>!n.has(e)),fieldKeys:t.filter(e=>n.has(e.cap)&&e.surface!==`addon-card`).flatMap(e=>e.fieldKeys??[])}}function qe({addonId:e,onOpen:n}){let{t:r}=K(),i=Ke(e),o=Ge(e).length>0;return t(u,{children:[a(Je,{addonId:e,onOpen:n}),a(q,{nodeId:null,addonIds:[e],level:`global`,fieldScope:`cluster`,omitCapabilities:i.capabilities,omitFieldKeys:i.fieldKeys,emptyMessage:o?r(`addons.addonCard.allClusterSettingsElsewhere`,`Its cluster-wide settings are on the page linked above.`):r(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)})]})}function Je({addonId:e,onOpen:n}){let{t:r}=K(),i=[...new Set(Ge(e).map(e=>e.surface))];if(i.length===0)return null;let o=e=>{switch(e){case`pipeline`:return r(`addons.addonCard.surface.pipeline`,`Pipeline → Settings`);case`pipeline-roles`:return r(`addons.addonCard.surface.pipelineRoles`,`Pipeline → Roles & nodes`);case`history`:return r(`addons.addonCard.surface.history`,`History`);case`notifications`:return r(`addons.addonCard.surface.notifications`,`Notifications → Settings`);case`nodes`:return r(`addons.addonCard.surface.nodes`,`Nodes`);default:return e}};return t(`div`,{className:`mb-2 flex flex-wrap items-center gap-2 text-[10px] text-foreground-subtle`,children:[a(`span`,{children:r(`addons.addonCard.settingsElsewhere`,`More of this addon's settings are on:`)}),i.map(e=>{let t=Q[e];return t===void 0?null:a(G,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>n(t),children:o(e)},e)})]})}var Ye={queued:{icon:p,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:O,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:b,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:T,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:A,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Xe({item:e}){let{t:n}=K(),r=Ye[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 Ze=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Qe=new Set([`done`,`failed`,`skipped`]);function $e(e){return!Qe.has(e.phase)&&!Ze.has(e.jobState)}function et(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ze.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 tt(){let{data:e}=be({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=ke(k.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 et([...n.values()],Date.now())},[e,t])}var nt={queued:{icon:p,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:O,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:T,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:A,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:g,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function rt({progress:e}){let{t:n}=K(),r=nt[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 it(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 at(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function ot(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(at)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
|
|
2
2
|
`)}function st(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 ct={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function lt(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)}: ${ct[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 ut={},dt=3e4,ft=`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 pt({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=K(),c=l(),u=ee(),d=w(),f=V(ut,{staleTime:dt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),h=it(p,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),_=ce({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:lt(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:st(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=it(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:ot(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(G,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:S,className:ft,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(E,{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(G,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:S,className:ft,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(j,{className:`h-3 w-3`}),h.length>0?s(`addons.uninstallControls.everywhereCount`,{count:h.length}):s(`addons.uninstallControls.everywhere`)]})]})}function mt(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function ht(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!mt(e))}function gt(e){return e.length-ht(e,!1).length}c();function _t({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=K(),p=r===`upload`||r===`local`,[m,h]=s(!1),{data:g,isLoading:v,isError:y}=W({name:e}),b=g?ht(g,m):[],x=g?gt(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(G,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(_,{className:`h-3 w-3`})})]}),p&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(f,{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(Pe,{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(O,{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.`)}),b.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:b.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)),mt(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(G,{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(T,{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(G,{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(D,{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`)}),x>0&&a(G,{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:m?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:x})})]})}c();var vt=`device-export`;function yt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===vt)}function bt(e){return e!==`local`&&e!==`upload`}function xt({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=r&&i?h(`/api/addon-assets/${r}/${i}`):null,m=!!p&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:m?a(`img`,{src:p,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?te:S,{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`}),bt(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(f,{className:`h-2.5 w-2.5 text-white`})})]})}function St({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(O,{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(G,{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(D,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(G,{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(re,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(G,{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(re,{className:`h-3 w-3 opacity-50`})]}),u]})}function Ct({addonId:e}){let t=l(),{data:n=`inherit`}=Te({addonId:e}),r=fe({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(G,{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 wt={id:`hub`,name:`Hub`,isHub:!0};function Tt({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdateServer:d,onUpdate:f,isUpdating:p,jobProgress:h,bundle:g,bulkItem:y,disabledByBulk:x,isSystem:ee,selectedNode:S}){let{t:C}=K(),[w,T]=s(!1),[E,D]=s(!1),[O,k]=s(null);o(()=>{k(null)},[i]);let j=O??i,[ae,oe]=s(!1),[se,ce]=s(!1),[M,fe]=s(`logs`),N=l(),P=Le(),{manifest:F}=e,I=!g&&!F.protected&&F.removable!==!1,L=!!g,_e=g?.displayName??F.name,R=g?.packageName??F.packageName,ye=g?.version??F.packageVersion??F.version,z=g?.installSource??e.installSource,be=g?g.bundle?.description??g.addons[0]?.manifest.description:F.description,B=Ae({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]})}}),Se=ve({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`addonPages`]]}),N.invalidateQueries({queryKey:[[`capabilities`]]}),N.invalidateQueries({queryKey:[[`integrations`]]})}}),Ce=ge({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`alerts`]]})}}),V=e.health,H=V?.phase===`failed`&&!V.inGracePeriod,Te=H&&V?.nextRetryAt&&!V.retrying,U=Ue(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${H?`border-red-500/50`:`border-border`}`,children:[H&&V&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(A,{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:C(`addons.addonCard.failedToLoad`,{attempt:V.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:V.lastError?.message??C(`addons.addonCard.unknownError`,`Unknown error`)}),Te&&V.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:C(`addons.addonCard.autoRetryAt`,{time:new Date(V.nextRetryAt).toLocaleTimeString()})})]}),t(G,{variant:`unstyled`,type:`button`,disabled:Ce.isPending||V.retrying,onClick:e=>{e.stopPropagation(),Ce.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:C(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(b,{className:`h-3 w-3 ${Ce.isPending||V.retrying?`animate-spin`:``}`}),C(`addons.addonCard.retryNow`,`Retry now`)]})]}),U!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(A,{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:C(`addons.addonCard.processProblem.${U.kind}`)}),U.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:U.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(xt,{isBundle:L||!!F.components&&F.components.length>1,installSource:z,addonId:L?g.addons[0]?.manifest.id:F.id,iconPath:L?g.bundle?.icon??g.addons[0]?.manifest.icon:F.icon,color:L?g.addons[0]?.manifest.color:F.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:_e}),!r&&a(St,{version:ye,availableUpdate:i,...j===void 0?{}:{selectedVersion:j},isUpdating:p,installSource:z,disabled:x,...f&&j!==void 0?{onUpdate:()=>f(j)}:{},onOpenPicker:()=>D(e=>!e),children:E&&a(_t,{packageName:R,currentVersion:ye,...z?{installSource:z}:{},...i!==void 0&&j!==void 0?{selectedVersion:j,onSelect:e=>{k(e),D(!1)}}:{},onInstall:e=>{D(!1),Se.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!==_e&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:R}),L&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(te,{className:`h-3 w-3`}),g.addons.length]}),ee&&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:C(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(b,{className:`h-3 w-3`}),C(`addons.addonCard.system`,`System`)]}),y!=null&&a(Xe,{item:y}),c!==void 0&&a(ie,{variant:`warning`,title:C(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:C(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),c!==void 0&&d!==void 0&&a(G,{type:`button`,size:`sm`,variant:`secondary`,onClick:d,children:C(`clusterUpdate.updateServer`,`Update server`)}),h!=null&&a(rt,{progress:h})]}),be&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:be}),!L&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?C(`addons.addonCard.forked`):C(`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`:U===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!L&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(G,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),B.mutate({addonId:F.id})},disabled:B.isPending||x,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(b,{className:`h-3 w-3 ${B.isPending?`animate-spin`:``}`}),C(`addons.addonCard.restart`,`Restart`)]}),t(G,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),oe(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ae?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(v,{className:`h-3 w-3`}),C(`addons.addonCard.logs`,`Logs`)]}),!L&&t(G,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),ce(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${se?`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(m,{className:`h-3 w-3`}),C(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),I&&a(pt,{packageName:F.packageName,displayName:F.name,selectedNode:S??wt,disabled:x})]}),n&&n.nodes.length>1&&!L&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:C(`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:C(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:C(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:C(`common.synced`)})]},e.nodeId))})]}),ae&&!L&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(G,{variant:`unstyled`,type:`button`,onClick:()=>fe(`logs`),className:`px-2 py-0.5 transition-colors ${M===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:C(`addons.addonCard.logs`,`Logs`)}),a(G,{variant:`unstyled`,type:`button`,onClick:()=>fe(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${M===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:C(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(G,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),oe(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(_,{className:`h-3.5 w-3.5`})})]}),M===`logs`&&a(xe,{addonId:F.id,maxHeight:`max-h-64`,showFilters:!1}),M===`events`&&a(we,{addonId:F.id,category:`addon.*`,maxHeight:`max-h-64`})]}),L&&t(u,{children:[a(G,{variant:`unstyled`,type:`button`,onClick:()=>T(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(w?ne:re,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),w&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>a(Tt,{addon:e,hideVersion:!0},e.manifest.id))})]}),se&&!L&&a(pe,{open:!0,onOpenChange:e=>!e&&ce(!1),children:t(de,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(he,{children:t(me,{className:`flex items-center gap-2`,children:[a(m,{className:`h-4 w-4 text-primary`}),C(`addons.addonCard.settingsTitle`,{name:_e})]})}),t(le,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:C(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(qe,{addonId:F.id,onOpen:e=>P(e)}),yt(F)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.deviceExport`,`Device export`)}),a(Me,{addonId:F.id,onOpenDevice:e=>P(`/devices/${e}`)})]}),bt(z)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(Ct,{addonId:F.id})]}),F.components&&F.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.components`,{count:F.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:F.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(ue,{children:a(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>ce(!1),children:C(`common.close`,`Close`)})})]})})]})}c();var Et=`.tgz,.tar.gz,.zip`;function Dt({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(h(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(z,{ref:l,accept:Et,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(G,{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(O,{className:`w-3.5 h-3.5 animate-spin`}):a(f,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var Ot=/```[^\n]*\n([\s\S]*?)```/g;function kt(e){let t=[],n=0;for(let r of e.matchAll(Ot)){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 At(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function jt(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?At(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 Mt(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-
|
|
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-BL1KpPQ2.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-
|
|
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-BL1KpPQ2.js";import{Ci as i}from"./index-ByN-VTu-.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,Q as h,Rn as g,Tt as _,ba as v,ci as y,fa as b,ft as x,mn as S,tn as C,wi as w,yn as T,yt as E,zn as D,zr as O}from"./player-overlays-hLBmOC8C.js";import{Oi as k}from"./client-D93RkunP.js";import{t as A}from"./flask-conical-D7tbJQpj.js";import{t as j}from"./message-square-plus-_aGccjyj.js";import{Aa as M,Br as N,Ca as P,Dp as ee,La as te,Lr as F,Oa as I,Op as ne,Qs as re,Vr as L,Zp as R,_i as ie,dt as z,ja as B,q as ae,ua as V,wa as H,yp as U}from"./src-CR4MjS0h.js";import{t as W}from"./i18n-ILINfI4k.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-Bbj8t_iL.js";import{Ci as K,St as q,b as J}from"./index-BZLBXpx-.js";import{t as Y}from"./AdminSectionedPage-DfZeI0TS.js";import{t as oe}from"./InstancesTable-Gi6mvKws.js";import{t as se}from"./AdminPage-CFltVUtJ.js";import{a as ce,c as le,d as ue,f as de,i as fe,l as X,n as pe,o as me,p as he,r as ge,s as Z,t as _e,u as ve}from"./ai-page.helpers-DutvjEb-.js";c();function ye(){let{t}=G(),n=E(),r=H({functionCap:`llm`}).data??[],a=s({queryKey:pe,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:ge.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(X):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(x,{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:Z(e)===``?e.name:`${e.name} · ${Z(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 be=2e3;function Q(e){return W.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function xe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Se({nodeId:t,value:r,onChange:a}){let{t:c}=G(),l=E(),[f,p]=o(``),[m,h]=o(null),[g,_]=o(!1),v=s({queryKey:_e,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),y=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),b=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),S=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{_(!0),y.refetch()}}),C=s({queryKey:fe,enabled:S.isPending,refetchInterval:S.isPending?be:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,T=n(()=>{let e=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Q(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:Q(e.sizeBytes),node:t})})),r=m?.ok===!0?[{value:`custom`,label:`${m.label} · ${Q(m.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[v.data,y.data,m,t,c]),D=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=v.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=y.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{f.trim()!==``&&b.mutate({ref:f.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(z,{label:c(`ai.model`,`Model`),required:!0,children:i(x,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:xe(r),options:T,onChange:e=>D(e.target.value)})}),i(z,{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(ee,{"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(U,{size:`sm`,variant:`secondary`,type:`button`,disabled:f.trim()===``||b.isPending,onClick:()=>k(),children:[b.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(d,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),b.isError&&i(I,{message:b.error instanceof Error?b.error.message:c(`common.error`,`Error`)}),m?.ok===!1&&i(I,{message:m.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(m.candidates??[]).map(e=>i(U,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${f.trim().split(`:`)[0]??``}:${e}`;p(t),b.mutate({ref:t})},children:e},e)),m.requiredBytes!==void 0&&i(U,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(m.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Q(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(M,{variant:m.purpose===`vision`?`info`:`default`,children:m.purpose}),i(M,{variant:`default`,children:Q(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(U,{size:`sm`,type:`button`,disabled:S.isPending||g,onClick:()=>S.mutate(m.model),children:[S.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),g?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),C!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:C.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:C.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:C.file,index:C.fileIndex,count:C.fileCount,done:Q(C.downloadedBytes),total:C.totalBytes===void 0?``:` / ${Q(C.totalBytes)}`})})]}),S.isError&&i(I,{message:S.error instanceof Error?S.error.message:c(`common.error`,`Error`)})]})]})}function Ce({value:t,onChange:n}){let{t:r}=G(),a=E(),o=s({queryKey:fe,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(O,{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=me(a),s=o.nodeId===t;return e(U,{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(M,{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 we(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Te({providerConfig:e,onProviderConfigChange:t}){return i(Ce,{value:we(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function Ee({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(Se,{nodeId:we(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 De=new Map([[`ai/apple-node`,Te],[`ai/managed-model`,Ee]]);function Oe(e){return De.get(e)??null}c();function $(e,t){let n=e[t];return typeof n==`string`?n:``}function ke({row:a}){let{t:c}=G(),d=E(),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,h]=o({}),g=t({}),_=t(!1),v=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:[P]}),h({})}}),y=r(e=>{g.current={...g.current,...e},h(t=>({...t,...e})),!_.current&&(_.current=!0,queueMicrotask(()=>{let e=g.current;g.current={},_.current=!1,v.mutate(e)}))},[v]),b=p.data?.description.kinds?.find(e=>e.id===a.kindId),S=p.data?.instance?.formValues,C=n(()=>({...S,...m}),[S,m]),w=b?.widgets??[],T=w.some(e=>e.placement===`model`),D=n(()=>({...$(C,`nodeId`)===``?{}:{nodeId:$(C,`nodeId`)},...typeof C.modelRef==`object`&&C.modelRef!==null?{model:C.modelRef}:{}}),[C]),k={id:$(C,`model`),supportsVision:C.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(I,{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);y({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[w.map(({id:e})=>{let t=Oe(e);return t===null?i(I,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:D,onProviderConfigChange:e=>y({...$(e,`nodeId`)===$(D,`nodeId`)?{}:{nodeId:$(e,`nodeId`)},...e.model!==void 0&&e.model!==D.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>y({model:e.id,supportsVision:e.supportsVision})},e)}),!T&&e(z,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(U,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(x,{"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})]}),v.isError&&i(I,{variant:`warning`,message:v.error.message})]})}c();var Ae=5e3;function je(e){return W.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Me(){let{t}=G(),r=E(),a=s({queryKey:fe,refetchInterval:Ae,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(M,{variant:he(n),children:t(de(n))}),n.status?.downloadProgress!==void 0&&i(M,{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?`—`:je(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=ue(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(M,{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(B,{className:`h-8 w-full`}),i(B,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:f,children:i(I,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(V,{icon:g,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(N,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:L})})}var Ne=h(`/addon/ai/test-chat`),Pe=h(`/addon/ai/test-chat/chats`),Fe=6e5;function Ie(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Fe)}function Le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Re(e){if(!Le(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 ze=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Be(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Le(t))return null;switch(t.kind){case`status`:{let e=ze.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:Re(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:W.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Ve(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,Q as h,Rn as g,Tt as _,ba as v,ci as y,fa as b,ft as x,mn as S,tn as C,wi as w,yn as T,yt as E,zn as D,zr as O}from"./player-overlays-C-OmGoqt.js";import{Oi as k}from"./client-CU9hiVrv.js";import{t as A}from"./flask-conical-D7tbJQpj.js";import{t as j}from"./message-square-plus-_aGccjyj.js";import{Aa as M,Br as N,Ca as P,Dp as ee,La as te,Lr as F,Oa as I,Op as ne,Qs as re,Vr as L,Zp as R,_i as ie,dt as z,ja as B,q as ae,ua as V,wa as H,yp as U}from"./src-BL1KpPQ2.js";import{t as W}from"./i18n-B5Xm3ktp.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-BoRMX84w.js";import{Ci as K,St as q,b as J}from"./index-ByN-VTu-.js";import{t as Y}from"./AdminSectionedPage-BKAltoSC.js";import{t as oe}from"./InstancesTable-w-0XwFaG.js";import{t as se}from"./AdminPage-DgcMq51y.js";import{a as ce,c as le,d as ue,f as de,i as fe,l as X,n as pe,o as me,p as he,r as ge,s as Z,t as _e,u as ve}from"./ai-page.helpers-BHBXHNQI.js";c();function ye(){let{t}=G(),n=E(),r=H({functionCap:`llm`}).data??[],a=s({queryKey:pe,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:ge.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(X):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(x,{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:Z(e)===``?e.name:`${e.name} · ${Z(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 be=2e3;function Q(e){return W.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function xe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Se({nodeId:t,value:r,onChange:a}){let{t:c}=G(),l=E(),[f,p]=o(``),[m,h]=o(null),[g,_]=o(!1),v=s({queryKey:_e,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),y=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),b=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),S=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{_(!0),y.refetch()}}),C=s({queryKey:fe,enabled:S.isPending,refetchInterval:S.isPending?be:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,T=n(()=>{let e=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Q(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:Q(e.sizeBytes),node:t})})),r=m?.ok===!0?[{value:`custom`,label:`${m.label} · ${Q(m.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[v.data,y.data,m,t,c]),D=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=v.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=y.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{f.trim()!==``&&b.mutate({ref:f.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(z,{label:c(`ai.model`,`Model`),required:!0,children:i(x,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:xe(r),options:T,onChange:e=>D(e.target.value)})}),i(z,{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(ee,{"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(U,{size:`sm`,variant:`secondary`,type:`button`,disabled:f.trim()===``||b.isPending,onClick:()=>k(),children:[b.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(d,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),b.isError&&i(I,{message:b.error instanceof Error?b.error.message:c(`common.error`,`Error`)}),m?.ok===!1&&i(I,{message:m.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(m.candidates??[]).map(e=>i(U,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${f.trim().split(`:`)[0]??``}:${e}`;p(t),b.mutate({ref:t})},children:e},e)),m.requiredBytes!==void 0&&i(U,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(m.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Q(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(M,{variant:m.purpose===`vision`?`info`:`default`,children:m.purpose}),i(M,{variant:`default`,children:Q(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(U,{size:`sm`,type:`button`,disabled:S.isPending||g,onClick:()=>S.mutate(m.model),children:[S.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),g?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),C!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:C.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:C.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:C.file,index:C.fileIndex,count:C.fileCount,done:Q(C.downloadedBytes),total:C.totalBytes===void 0?``:` / ${Q(C.totalBytes)}`})})]}),S.isError&&i(I,{message:S.error instanceof Error?S.error.message:c(`common.error`,`Error`)})]})]})}function Ce({value:t,onChange:n}){let{t:r}=G(),a=E(),o=s({queryKey:fe,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(O,{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=me(a),s=o.nodeId===t;return e(U,{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(M,{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 we(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Te({providerConfig:e,onProviderConfigChange:t}){return i(Ce,{value:we(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function Ee({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(Se,{nodeId:we(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 De=new Map([[`ai/apple-node`,Te],[`ai/managed-model`,Ee]]);function Oe(e){return De.get(e)??null}c();function $(e,t){let n=e[t];return typeof n==`string`?n:``}function ke({row:a}){let{t:c}=G(),d=E(),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,h]=o({}),g=t({}),_=t(!1),v=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:[P]}),h({})}}),y=r(e=>{g.current={...g.current,...e},h(t=>({...t,...e})),!_.current&&(_.current=!0,queueMicrotask(()=>{let e=g.current;g.current={},_.current=!1,v.mutate(e)}))},[v]),b=p.data?.description.kinds?.find(e=>e.id===a.kindId),S=p.data?.instance?.formValues,C=n(()=>({...S,...m}),[S,m]),w=b?.widgets??[],T=w.some(e=>e.placement===`model`),D=n(()=>({...$(C,`nodeId`)===``?{}:{nodeId:$(C,`nodeId`)},...typeof C.modelRef==`object`&&C.modelRef!==null?{model:C.modelRef}:{}}),[C]),k={id:$(C,`model`),supportsVision:C.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(I,{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);y({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[w.map(({id:e})=>{let t=Oe(e);return t===null?i(I,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:D,onProviderConfigChange:e=>y({...$(e,`nodeId`)===$(D,`nodeId`)?{}:{nodeId:$(e,`nodeId`)},...e.model!==void 0&&e.model!==D.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>y({model:e.id,supportsVision:e.supportsVision})},e)}),!T&&e(z,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(U,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(x,{"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})]}),v.isError&&i(I,{variant:`warning`,message:v.error.message})]})}c();var Ae=5e3;function je(e){return W.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Me(){let{t}=G(),r=E(),a=s({queryKey:fe,refetchInterval:Ae,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(M,{variant:he(n),children:t(de(n))}),n.status?.downloadProgress!==void 0&&i(M,{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?`—`:je(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=ue(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(M,{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(B,{className:`h-8 w-full`}),i(B,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:f,children:i(I,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(V,{icon:g,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(N,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:L})})}var Ne=h(`/addon/ai/test-chat`),Pe=h(`/addon/ai/test-chat/chats`),Fe=6e5;function Ie(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Fe)}function Le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Re(e){if(!Le(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 ze=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Be(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Le(t))return null;switch(t.kind){case`status`:{let e=ze.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:Re(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:W.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Ve(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=Be(e);t!==null&&(yield t)}a=r.indexOf(`
|
|
3
3
|
`)}}let e=r.trim();if(e.length>0){let t=Be(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function He(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Ue(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function We(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 Ge(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 Ke(e,t){switch(e){case`resolving-image`:return W.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return W.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?W.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):W.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return W.t(`helpers.aiTestChat.phaseAnswering`)}}c();var qe=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Je=360*60*1e3,Ye=40,Xe=160,Ze={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Qe(){let{t:s}=G();E();let[c,l]=o(``),[u,d]=o(``),[p,h]=o(``),[g,y]=o([]),[w,T]=o(null),[O,k]=o(`none`),[A,M]=o(`throwaway`),[N,P]=o(null),[te,re]=o([]),[L,R]=o(null),[z,B]=o(null),V=t(null);a(()=>()=>V.current?.abort(),[]);let W=r(async()=>{let e=await fetch(Pe,{credentials:`same-origin`});e.ok&&re((await e.json()).chats??[])},[]);a(()=>{A===`persistent`&&W()},[A,W]);let K=H({functionCap:`llm`}),q=n(()=>(K.data??[]).filter(e=>e.enabled),[K.data]),J=q.find(e=>e.id===c)??null,Y=z!==null,oe=r(async(e,t)=>{let n=new AbortController;V.current=n,R(null);let r=Ie(J===null?{}:ve(J));B({...Ze,firstTokenTimeoutMs:r??0});let i=``,a=null,o,l=null,d=null,f;try{let s=await fetch(Ne,{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 Ve(s.body))switch(e.kind){case`status`:B(t=>({...t??Ze,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,B(t=>({...t??Ze,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,B(e=>({...e??Ze,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||R(e instanceof Error?e.message:s(`common.error`,`Error`))}finally{V.current=null,B(null)}f!==void 0&&(P(f),W());let p=n.signal.aborted&&i.length>0;l===null&&i.length===0&&!p||y(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,J,c,W,u,s]),se=r(()=>{let e=p.trim();if(e===``||c===``||Y)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...w===null?{}:{attachmentLabel:w.label,attachmentKind:w.ref.kind}},n=[...g,t];y(n),h(``);let r=w?.ref;T(null),k(`none`),oe(A===`persistent`&&N!==null?[{role:`user`,content:e}]:He(n),r)},[A,N,p,w,c,oe,Y,g]),ce=()=>V.current?.abort(),le=()=>{V.current?.abort(),y([]),T(null),h(``),R(null),B(null),P(null)},ue=async e=>{V.current?.abort();let t=await fetch(`${Pe}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();P(e),y(We(n)),B(null),R(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(x,{id:`ai-test-profile`,value:c,onChange:e=>l(e.target.value),options:[{value:``,label:s(`ai.selectProfile`,`Select a profile…`)},...q.map(e=>({value:e.id,label:`${e.name} · ${Z(e)}${X(e)?` · vision`:``}`}))]}),q.length===0&&!K.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(ee,{id:`ai-test-system`,value:u,onChange:e=>d(e.target.value),placeholder:s(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(ae,{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(U,{size:`sm`,variant:`secondary`,type:`button`,onClick:le,children:[i(j,{className:`h-3.5 w-3.5`}),s(`ai.newChat`,`New chat`)]}),te.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:te.map(e=>i(`button`,{type:`button`,onClick:()=>void ue(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.`)}),J!==null&&!X(J)&&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.`)})]})}),L!==null&&i(I,{title:s(`ai.chatFailed`,`The test call failed`),message:L}),e(F,{headingId:`ai-test-conversation`,title:s(`ai.testConversation`,`Conversation`),actions:e(U,{size:`sm`,variant:`ghost`,type:`button`,disabled:g.length===0&&w===null,onClick:le,children:[i(C,{className:`h-3.5 w-3.5`}),s(`ai.clearChat`,`Clear`)]}),children:[i($e,{turns:g,live:z}),e(`div`,{className:`${f} space-y-2 border-t border-border`,children:[w!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[w.ref.kind===`snapshot`?i(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:w.label}),i(ne,{size:`sm`,variant:`ghost`,type:`button`,icon:_,"aria-label":s(`ai.removeAttachment`,`Remove attachment`),onClick:()=>T(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(U,{size:`sm`,variant:O===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>k(O===`snapshot`?`none`:`snapshot`),children:[i(b,{className:`h-3.5 w-3.5`}),s(`ai.attachSnapshot`,`Camera snapshot`)]}),e(U,{size:`sm`,variant:O===`track`?`primary`:`outline`,type:`button`,onClick:()=>k(O===`track`?`none`:`track`),children:[i(v,{className:`h-3.5 w-3.5`}),s(`ai.attachTrack`,`Recent track`)]})]}),O===`snapshot`&&i(nt,{onPick:(e,t)=>{T({ref:{kind:`snapshot`,deviceId:e.id},label:s(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),k(`none`)}}),O===`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(ee,{value:p,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se())},placeholder:s(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":s(`ai.message`,`Message`)}),Y?e(U,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[i(S,{className:`h-3.5 w-3.5`}),s(`ai.stop`,`Stop`)]}):e(U,{size:`sm`,type:`button`,disabled:p.trim()===``||c===``,onClick:se,children:[i(D,{className:`h-3.5 w-3.5`}),s(`ai.send`,`Send`)]})]})]})]})]})}function $e({turns:t,live:n}){let{t:r}=G();return t.length===0&&n===null?i(V,{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(O,{className:`h-3.5 w-3.5 animate-spin`}),Ke(n.phase,n.firstTokenTimeoutMs)]})]})]})}function et({turn:t,streaming:n=!1}){let{t:r}=G(),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(v,{className:`h-3 w-3`}):i(b,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(b,{className:`h-3 w-3`}):i(v,{className:`h-3 w-3`}),Ge(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}=G(),n=Ue(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}=G(),n=re({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(O,{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}=G(),a=te(t,`compact`),{src:o}=p(t.id,{width:Xe});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(M,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function it({onPick:t}){let{t:r}=G(),a=E(),o=re({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:[...qe,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Je,limit:Ye,projection:`slim`})});if(o.isLoading||u.isLoading)return i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(v,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var at=1440*60*1e3,ot=[1,7,30,90];function st(){let{t}=G(),r=E(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*at},[a]),u=H({functionCap:`llm`}),d=s({queryKey:[...ce,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(x,{"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(B,{className:`h-8 w-full`}),i(B,{className:`h-8 w-full`}),i(B,{className:`h-8 w-full`})]}):d.isError?i(`div`,{className:f,children:i(I,{title:t(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:t(`common.error`,`Error`),onRetry:()=>void d.refetch()})}):h.length===0?i(V,{icon:y,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(N,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:L})})}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}=G(),t=R(ct),[n]=K(),r=J(`/system/ai`,{t:e,isAdmin:!0})??{icon:T,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(Y,{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(Me,{})},{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,Z)??``,r=t=>pt(t,e,X)??!1,a=t=>pt(t,e,le)??``;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(M,{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}=G(),r=H({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(ye,{}),i(oe,{functionCap:ct,icon:T,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(ke,{row:e})})]})}function gt({presence:t}){let{t:n}=G();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(B,{className:`h-8 w-64`}),i(B,{className:`h-40 w-full`})]}):t===`unknown`?i(I,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(V,{icon:T,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};
|