@camstack/addon-admin-ui 1.1.38 → 1.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/assets/{AddLocationWizard-6UQCTSu4.js → AddLocationWizard-DH1zgXau.js} +1 -1
  2. package/dist/assets/AddonCollectionPage-C8P99b0n.js +1 -0
  3. package/dist/assets/Addons-ql4qAeON.js +1 -0
  4. package/dist/assets/{AdminTabs-Bn5jDw8C.js → AdminTabs-BFmViSgF.js} +1 -1
  5. package/dist/assets/{BrokerForm-E7__Uhl9.js → BrokerForm-ClAXJAT9.js} +1 -1
  6. package/dist/assets/{Capabilities-DWu3W2I3.js → Capabilities-BUUnmipR.js} +1 -1
  7. package/dist/assets/{CapabilityBadges-D4uPGt_S.js → CapabilityBadges-DJ4Ez0Qj.js} +1 -1
  8. package/dist/assets/Cluster-_sIDv3Dx.js +1 -0
  9. package/dist/assets/{Dashboard-DRARX0g8.js → Dashboard-DkWFR-RK.js} +1 -1
  10. package/dist/assets/Data-B9S8aoV6.js +1 -0
  11. package/dist/assets/DetectionIntelligence-Db0D7-gq.js +1 -0
  12. package/dist/assets/DeviceDetail-MyRno8pF.js +2 -0
  13. package/dist/assets/{Devices-BFoz2HIh.js → Devices-CYdjYNMa.js} +1 -1
  14. package/dist/assets/{EmbedPlayerPage-BY9eFyyg.js → EmbedPlayerPage-BxhfuZxm.js} +1 -1
  15. package/dist/assets/{FormBuilder-CJrUV3p4.js → FormBuilder-CzGQp2IN.js} +1 -1
  16. package/dist/assets/Identity-VBuwkiW_.js +1 -0
  17. package/dist/assets/IntegrationDetail-Bv6r0j-e.js +1 -0
  18. package/dist/assets/{Integrations-Bj35Jpxj.js → Integrations-34-SopSE.js} +1 -1
  19. package/dist/assets/Integrations-VR6uvQtU.js +1 -0
  20. package/dist/assets/{Logs-B2WAadmI.js → Logs-Bd6dsQiy.js} +1 -1
  21. package/dist/assets/{MotionZonesSettings-3tt6mBQ0.js → MotionZonesSettings-CblR7zDg.js} +1 -1
  22. package/dist/assets/MyAccess-D9wXYE6f.js +2 -0
  23. package/dist/assets/Network-B4UJnXGJ.js +1 -0
  24. package/dist/assets/{NodeAddonsSettingsPanel-DTzycFzS.js → NodeAddonsSettingsPanel-DTo_3cuU.js} +1 -1
  25. package/dist/assets/{NotificationTargets-C3VSwqNL.js → NotificationTargets-BgoTGaHZ.js} +1 -1
  26. package/dist/assets/Pipeline-0vYb0c3Q.js +1 -0
  27. package/dist/assets/{PrivacyMaskSettings-temQSWYL.js → PrivacyMaskSettings-BvyW7gZf.js} +1 -1
  28. package/dist/assets/ProviderIcon-CS5qVLX5.js +1 -0
  29. package/dist/assets/{ScanNetworkModal-C6OLnfky.js → ScanNetworkModal-D8l7vvfO.js} +1 -1
  30. package/dist/assets/ServerManagement-CU7yGbqi.js +1 -0
  31. package/dist/assets/{Settings-BmZ2YcWY.js → Settings-afXspnHv.js} +1 -1
  32. package/dist/assets/{Showroom-CHFvHOSL.js → Showroom-ByFNrd3B.js} +1 -1
  33. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-xXz7MEuT.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DmurZU5p.js} +1 -1
  34. package/dist/assets/addon-display-names-DvSEQty-.js +1 -0
  35. package/dist/assets/{build-cluster-graph-DIgt00ch.js → build-cluster-graph-BPT-sggI.js} +2 -2
  36. package/dist/assets/circle-check-big-CTwHEGsR.js +1 -0
  37. package/dist/assets/{copy-CpT57v81.js → copy-Dyvl96ei.js} +1 -1
  38. package/dist/assets/dist-ClgrIx6c.js +7 -0
  39. package/dist/assets/{dist-B8dNOlY9.js → dist-Udv3GGFK.js} +1 -1
  40. package/dist/assets/{download-fsWmKUMh.js → download-BFNY5_CW.js} +1 -1
  41. package/dist/assets/{hostInit-sp7Rf71V.js → hostInit-CagYACyE.js} +1 -1
  42. package/dist/assets/index-3DCschCe.js +4 -0
  43. package/dist/assets/index-BNTiPmxL.css +2 -0
  44. package/dist/assets/{key-round-0X280kmV.js → key-round-Bi4e5-k8.js} +1 -1
  45. package/dist/assets/{mf-entry-bootstrap-0-2b967ba8.js → mf-entry-bootstrap-0-b7b22ad0.js} +2 -2
  46. package/dist/assets/{pencil-BlQGw-pI.js → pencil-DedPunTk.js} +1 -1
  47. package/dist/assets/{player-overlays-CpsGl45o.js → player-overlays-BrMuuVRR.js} +1 -1
  48. package/dist/assets/plus-r3Kz9Nsb.js +1 -0
  49. package/dist/assets/{radio-DO0Dq2MF.js → radio-BM7T2fMm.js} +1 -1
  50. package/dist/assets/{refresh-cw-CMRlnF-M.js → refresh-cw-CC8OysCP.js} +1 -1
  51. package/dist/assets/remoteEntry-D9u56wxx.js +1 -0
  52. package/dist/assets/{rotate-ccw-CaH5zDeG.js → rotate-ccw-hTTLi20Q.js} +1 -1
  53. package/dist/assets/rotate-cw-BHsfPq8X.js +1 -0
  54. package/dist/assets/search-GJrj432A.js +1 -0
  55. package/dist/assets/{sparkles-D1oHkgOm.js → sparkles-DURbj_l0.js} +1 -1
  56. package/dist/assets/square-DXUXUdD9.js +1 -0
  57. package/dist/assets/{square-check-big-D7lGfpqc.js → square-check-big-B5WFnMH6.js} +1 -1
  58. package/dist/assets/src-D5vrhmeM.js +7 -0
  59. package/dist/assets/src-ojhqTnBF.js +67 -0
  60. package/dist/assets/{upload-7zSY3rlx.js → upload-DM5RHvd4.js} +1 -1
  61. package/dist/assets/{useDevice-BwzYPnLK.js → useDevice-BQkNwlm7.js} +1 -1
  62. package/dist/assets/{useEventInvalidation-CETyyXeZ.js → useEventInvalidation-BBDMvWpm.js} +1 -1
  63. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DkH43QoX.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BbV1VRd0.js} +2 -2
  64. package/dist/assets/{wifi-BeF9XXWL.js → wifi-Cr9H7WCZ.js} +1 -1
  65. package/dist/assets/{zap-abOrEOMQ.js → zap-BWxQNiSd.js} +1 -1
  66. package/dist/index.html +6 -6
  67. package/dist/server/addon.js +308 -92
  68. package/package.json +1 -1
  69. package/dist/assets/AddonCollectionPage-C7y1Xqv4.js +0 -1
  70. package/dist/assets/Addons-BMHA1UvX.js +0 -1
  71. package/dist/assets/Cluster-dHKbt5S3.js +0 -1
  72. package/dist/assets/Data-Cgi4uVIl.js +0 -1
  73. package/dist/assets/DetectionIntelligence-B-VvnmfI.js +0 -1
  74. package/dist/assets/DeviceDetail-DiuVtjgW.js +0 -2
  75. package/dist/assets/Identity-B0ygozcS.js +0 -1
  76. package/dist/assets/IntegrationDetail-Brj01VUG.js +0 -1
  77. package/dist/assets/Integrations-DpfC2qld.js +0 -1
  78. package/dist/assets/MyAccess-DXmHi-4Y.js +0 -2
  79. package/dist/assets/Network-CaKLSIvm.js +0 -1
  80. package/dist/assets/Pipeline-Cp7B8YFG.js +0 -1
  81. package/dist/assets/ProviderIcon-DwFpv01K.js +0 -1
  82. package/dist/assets/circle-check-big-wzEehng2.js +0 -1
  83. package/dist/assets/dist-DRenWL4F.js +0 -7
  84. package/dist/assets/index-CY52lvbZ.js +0 -4
  85. package/dist/assets/index-_8k1nh07.css +0 -2
  86. package/dist/assets/plus-DSiRMRVx.js +0 -1
  87. package/dist/assets/remoteEntry-BTav0B7H.js +0 -1
  88. package/dist/assets/rotate-cw-CCcZjC0U.js +0 -1
  89. package/dist/assets/search-CN_ccU_h.js +0 -1
  90. package/dist/assets/server-CaW_paWO.js +0 -1
  91. package/dist/assets/square-DWukmPnU.js +0 -1
  92. package/dist/assets/src-BXL7z3gT.js +0 -7
  93. package/dist/assets/src-BZ1dd5LI.js +0 -67
@@ -1 +0,0 @@
1
- import{Ct as e,Dt as t,Et as n,Fr as r,Ot as i,Qi as a,St as o,_t as s,bt as c,ct as l,dt as u,ft as d,g as f,gt as p,ia as m,kr as h,kt as ee,lt as g,m as _,mt as v,pt as te,st as ne,ta as re,ut as ie,v as ae,vt as y,wt as oe,yt as se}from"./src-BZ1dd5LI.js";import{I as b,K as x,Q as S,R as ce,S as C,W as w,b as le,o as ue,q as T,x as E,z as D}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as O}from"./src-BXL7z3gT.js";import{p as de}from"./player-overlays-CpsGl45o.js";import{t as k}from"./download-fsWmKUMh.js";import{t as fe}from"./plus-DSiRMRVx.js";import{t as A}from"./refresh-cw-CMRlnF-M.js";import{t as j}from"./search-CN_ccU_h.js";import{t as M}from"./upload-7zSY3rlx.js";import{A as pe,F as N,G as P,P as F,U as me,V as I,f as he,h as L,i as ge,o as R,p as z,s as _e,x as B}from"./index-CY52lvbZ.js";import{t as V}from"./AdminPage-BwmGKnRf.js";import{t as ve}from"./NodeAddonsSettingsPanel-DTzycFzS.js";var ye=I(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),H=I(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),U=I(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),be=I(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),W=I(`skip-forward`,[[`polygon`,{points:`5 4 15 12 5 20 5 4`,key:`16p6eg`}],[`line`,{x1:`19`,x2:`19`,y1:`5`,y2:`19`,key:`futhcm`}]]);S();var G=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),K=new Set([`done`,`failed`,`skipped`]);function q(e){return!K.has(e.phase)&&!G.has(e.jobState)}function J(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=G.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 Y(){let{data:e}=s({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=m(O.AddonsJobProgress,e=>e.job.jobId);return w(()=>{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 J([...n.values()],Date.now())},[e,t])}var X={queued:{icon:H,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:B,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:B,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:B,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:B,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:B,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:B,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:N,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:U,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:W,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function xe({progress:e}){let t=X[e.phase],n=t.icon,r=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return C(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${t.cls}`,title:r,children:[E(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,C(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Se({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:i,onSelect:a,selectedVersion:o}){let s=n===`upload`||n===`local`,{data:c,isLoading:l}=d({name:e});return C(`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:[C(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[E(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),E(`button`,{type:`button`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:E(ge,{className:`h-3 w-3`})})]}),s&&C(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[E(M,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),C(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[C(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,E(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),l&&C(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[E(B,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),c&&E(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:c.map(e=>{let n=e.version===t,i=a!==void 0&&e.version===o,c=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),l=C(le,{children:[E(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:c?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&E(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:`current`}),e.distTags.map(e=>E(`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)),e.deprecated&&E(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),E(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return a?C(`button`,{type:`button`,"aria-label":`Select ${e.version}`,onClick:()=>a(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${i?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[l,i?E(N,{className:`h-3 w-3 text-primary shrink-0`}):E(`span`,{className:`w-3 shrink-0`})]},e.version):C(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[l,n&&!s?E(N,{className:`h-3 w-3 text-primary shrink-0`}):E(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?`Re-install ${e.version} from npm`:`Install ${e.version}`,children:E(k,{className:`h-3 w-3`})})]},e.version)})}),c&&c.length===0&&E(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}var Z={queued:{icon:H,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:B,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:A,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:N,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:U,bg:`bg-danger/10 text-danger`,label:`failed`}};function Ce({item:e}){let t=Z[e.status],n=t.icon;return C(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[E(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}S();var we=`device-export`;function Te(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===we)}function Ee({isBundle:e,installSource:t,addonId:n,iconPath:r,color:i}){let[a,o]=T(!1),s=i?{backgroundColor:`${i.startsWith(`#`)?i:`#${i}`}26`}:void 0,c=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,l=n&&r?`/api/addon-assets/${n}/${r}`:null,u=!!l&&!a;return C(`div`,{className:`relative flex-shrink-0`,children:[E(`div`,{className:`h-9 w-9 rounded-lg flex items-center justify-center ${s?``:c}`,style:s,children:u?E(`img`,{src:l,alt:n,className:`h-5 w-5`,onError:()=>o(!0)}):E(e?be:L,{className:`h-4 w-4`})}),t===`local`&&E(`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`}),t===`npm`&&E(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:E(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:E(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&E(`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:E(M,{className:`h-2.5 w-2.5 text-white`})})]})}function De({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:i,disabled:a,onUpdate:o,onOpenPicker:s,children:c}){if(r)return C(`span`,{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[E(B,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return C(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[o&&C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},disabled:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 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:`Update to ${r}`,children:[E(k,{className:`h-3 w-3`}),`Update`]}),C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:a,"aria-label":`Select version to install`,title:`Installed ${e} — update available. Selected ${r}; tap to choose another version.`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 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:[E(`span`,{className:`font-normal opacity-70`,children:e}),E(`span`,{className:`font-normal opacity-70`,children:`→`}),r,E(F,{className:`h-3 w-3`})]}),c]})}return C(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:a,className:[`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,i===`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:`Version ${e} — tap to view all versions`,children:[e,E(F,{className:`h-3 w-3 opacity-50`})]}),c]})}function Oe({addonId:e}){let t=ue(),{data:n=`inherit`}=g({addonId:e}),r=oe({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return E(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>E(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}function ke({addon:e,agents:n=[],clusterStatus:r,hideVersion:i,availableUpdate:s,onUpdate:l,isUpdating:u,jobProgress:d,bundle:p,bulkItem:m,disabledByBulk:h,isSystem:ee}){let[g,v]=T(!1),[ne,re]=T(!1),[ie,y]=T(!1),[oe,se]=T(null);D(()=>{se(null)},[s]);let b=oe??s,[x,S]=T(!1),[ce,w]=T(!1),[O,k]=T(`logs`),j=ue(),M=de(),pe=me(),N=a(),{manifest:P}=e,I=e.installedOn??[],L=!p&&!P.protected&&P.removable!==!1,R=!!p,B=p?.displayName??P.name,V=p?.packageName??P.packageName,H=p?.version??P.packageVersion??P.version,W=p?.installSource??e.installSource,G=p?p.bundle?.description??p.addons[0]?.manifest.description:P.description,K=t({onSuccess:()=>{j.invalidateQueries({queryKey:[[`addons`]]}),j.invalidateQueries({queryKey:[[`addonPages`]]}),j.invalidateQueries({queryKey:[[`capabilities`]]})}}),q=c({onSuccess:()=>{j.invalidateQueries({queryKey:[[`addons`]]})}}),J=te({onSuccess:()=>{j.invalidateQueries({queryKey:[[`addons`]]}),j.invalidateQueries({queryKey:[[`addonPages`]]}),j.invalidateQueries({queryKey:[[`capabilities`]]}),j.invalidateQueries({queryKey:[[`integrations`]]})}}),Y=o({onSuccess:()=>{j.invalidateQueries({queryKey:[[`addons`]]}),j.invalidateQueries({queryKey:[[`alerts`]]})}}),X=e.health,Z=X?.phase===`failed`&&!X.inGracePeriod,we=Z&&X?.nextRetryAt&&!X.retrying;return C(`div`,{className:`rounded-lg border bg-surface overflow-hidden ${Z?`border-red-500/50`:`border-border`}`,children:[Z&&X&&C(`div`,{className:`bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5`,children:[E(U,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),C(`div`,{className:`flex-1 min-w-0`,children:[C(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,X.retryCount,`)`]}),E(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:X.lastError?.message??`Unknown error`}),we&&X.nextRetryAt&&C(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(X.nextRetryAt).toLocaleTimeString()]})]}),C(`button`,{type:`button`,disabled:Y.isPending||X.retrying,onClick:e=>{e.stopPropagation(),Y.mutate({packageName:V})},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:`Reset retry counter and force immediate reload`,children:[E(A,{className:`h-3 w-3 ${Y.isPending||X.retrying?`animate-spin`:``}`}),`Retry now`]})]}),C(`div`,{className:`flex items-start gap-3 px-4 py-3`,children:[E(Ee,{isBundle:R||!!P.components&&P.components.length>1,installSource:W,addonId:R?p.addons[0]?.manifest.id:P.id,iconPath:R?p.bundle?.icon??p.addons[0]?.manifest.icon:P.icon,color:R?p.addons[0]?.manifest.color:P.color}),C(`div`,{className:`flex-1 min-w-0`,children:[C(`div`,{className:`flex items-start justify-between gap-2`,children:[E(`span`,{className:`text-sm font-semibold text-foreground truncate min-w-0`,children:B}),!i&&E(De,{version:H,availableUpdate:s,...b===void 0?{}:{selectedVersion:b},isUpdating:u,installSource:W,disabled:h,...l&&b!==void 0?{onUpdate:()=>l(b)}:{},onOpenPicker:()=>y(e=>!e),children:ie&&E(Se,{packageName:V,currentVersion:H,...W?{installSource:W}:{},...s!==void 0&&b!==void 0?{selectedVersion:b,onSelect:e=>{se(e),y(!1)}}:{},onInstall:e=>{y(!1),J.mutate({packageName:V,version:e})},onClose:()=>y(!1)})})]}),C(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[V!==B&&E(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:V}),R&&C(`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:[E(be,{className:`h-3 w-3`}),p.addons.length]}),ee&&C(`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:`System package — updating restarts the hub`,children:[E(A,{className:`h-3 w-3`}),`System`]}),m!=null&&E(Ce,{item:m}),d!=null&&E(xe,{progress:d})]}),G&&E(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:G}),!R&&e.process&&C(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[E(`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`?`forked`:`in-process`}),e.process.pid!=null&&C(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),E(`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`:e.process.state===`crashed`||e.process.state===`failed`?`bg-red-500/15 text-red-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.state})]})]})]}),!R&&C(`div`,{className:`flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20`,children:[C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),q.mutate({addonId:P.id})},disabled:q.isPending||h,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 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:[E(A,{className:`h-3 w-3 ${q.isPending?`animate-spin`:``}`}),`Restart`]}),C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${x?`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:[E(z,{className:`h-3 w-3`}),`Logs`]}),!R&&C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),w(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${ce?`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:[E(he,{className:`h-3 w-3`}),`Settings`]}),E(`div`,{className:`flex-1`}),L&&C(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await N({title:`Uninstall ${P.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&K.mutate({packageName:P.packageName})},disabled:K.isPending||h,className:`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`,children:[E(_e,{className:`h-3 w-3`}),K.isPending?`Removing...`:`Uninstall`]})]}),r&&r.nodes.length>1&&!R&&C(`div`,{className:`border-t border-border px-4 py-2 bg-muted/10`,children:[E(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),E(`div`,{className:`space-y-1`,children:r.nodes.map(e=>C(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[E(`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`}`}),E(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),E(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&E(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:`outdated`}),e.status===`offline`&&E(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&E(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),x&&!R&&C(`div`,{className:`border-t border-border`,children:[C(`div`,{className:`flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50`,children:[C(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[E(`button`,{type:`button`,onClick:()=>k(`logs`),className:`px-2 py-0.5 transition-colors ${O===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),E(`button`,{type:`button`,onClick:()=>k(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${O===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),E(`div`,{className:`flex-1`}),E(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S(!1)},className:`text-foreground-subtle hover:text-foreground`,children:E(ge,{className:`h-3.5 w-3.5`})})]}),O===`logs`&&E(f,{addonId:P.id,maxHeight:`max-h-64`,showFilters:!1}),O===`events`&&E(_,{addonId:P.id,category:`addon.*`,maxHeight:`max-h-64`})]}),R&&C(le,{children:[E(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:E(g?ye:F,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),g&&E(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:p.addons.map(e=>E(ke,{addon:e,agents:n,hideVersion:!0},e.manifest.id))})]}),ce&&!R&&E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>w(!1),children:C(`div`,{className:`w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[C(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0`,children:[C(`div`,{className:`flex items-center gap-2`,children:[E(he,{className:`h-4 w-4 text-primary`}),C(`h2`,{className:`text-sm font-semibold text-foreground`,children:[B,` Settings`]})]}),E(`button`,{onClick:()=>w(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:E(ge,{className:`h-4 w-4`})})]}),C(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[E(ve,{nodeId:`hub`,addonIds:[P.id],level:`global`}),Te(P)&&C(`div`,{children:[E(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),E(ae,{addonId:P.id,trpc:M.trpcClient,onOpenDevice:e=>pe(`/devices/${e}`)})]}),W===`npm`&&C(`div`,{children:[E(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),E(Oe,{addonId:P.id})]}),P.components&&P.components.length>0&&C(`div`,{children:[C(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,P.components.length,`)`]}),E(`div`,{className:`flex flex-wrap gap-1`,children:P.components.map(e=>E(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),n.length>=2&&C(`div`,{children:[E(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),C(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[I.length===0&&E(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),I.map(e=>E(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),C(`div`,{className:`relative`,children:[C(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),re(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:`Install on more agents`,children:[E(fe,{className:`h-3 w-3`}),`Add agent`]}),ne&&C(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[n.filter(e=>!e.isHub&&!I.includes(e.name)).map(e=>E(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),re(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),n.filter(e=>!e.isHub&&!I.includes(e.name)).length===0&&E(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),E(`div`,{className:`flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0`,children:E(`button`,{type:`button`,onClick:()=>w(!1),className:`rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:`Close`})})]})})]})}S();var Ae=`.tgz,.tar.gz,.zip`;function je({onUploadSuccess:e}){let[t,n]=T(!1),r=x(null),i=b(async t=>{n(!0);let r=new FormData;r.append(`file`,t);let i=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(`/api/addons/upload`,{method:`POST`,headers:{Authorization:`Bearer ${i}`},body:r})).json()).success&&e()}finally{n(!1)}},[e]);return C(le,{children:[E(`input`,{ref:r,type:`file`,accept:Ae,onChange:b(e=>{let t=e.target.files?.[0];t&&i(t),e.target.value=``},[i]),className:`hidden`}),C(`button`,{type:`button`,onClick:()=>r.current?.click(),disabled:t,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:[t?E(B,{className:`w-3.5 h-3.5 animate-spin`}):E(M,{className:`w-3.5 h-3.5`}),t?`Uploading...`:`Upload`]})]})}function Me({pending:e,onCancel:t,onConfirm:n,isPending:r,error:i}){return E(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:C(`div`,{className:`bg-surface border border-border rounded-md shadow-xl p-5 max-w-md w-full mx-4 space-y-3`,children:[C(`div`,{className:`flex items-center gap-2`,children:[E(R,{className:`w-4 h-4 text-amber-700`}),E(`h3`,{className:`text-sm font-medium text-foreground`,children:`Update system package?`})]}),C(`div`,{className:`space-y-2 text-[11px] text-foreground-subtle`,children:[C(`div`,{children:[E(`span`,{className:`font-mono text-foreground`,children:e.packageName}),E(`span`,{className:`mx-1`,children:`·`}),C(`span`,{className:`font-mono`,children:[`v`,e.fromVersion]}),E(`span`,{className:`mx-1`,children:`→`}),C(`span`,{className:`font-mono text-amber-700`,children:[`v`,e.toVersion]})]}),E(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 p-2 text-amber-800`,children:`The hub will restart immediately after the install. Any in-flight requests will be dropped. The reconnect typically takes ~10 seconds.`}),i!==null&&E(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-2 text-danger`,children:i})]}),C(`div`,{className:`flex justify-end gap-2 pt-1`,children:[E(`button`,{type:`button`,onClick:t,disabled:r,className:`px-3 py-1.5 text-[11px] rounded bg-surface hover:bg-surface-hover border border-border disabled:opacity-50`,children:`Cancel`}),C(`button`,{type:`button`,onClick:n,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] rounded bg-amber-500/20 text-amber-800 hover:bg-amber-500/30 border border-amber-500/40 font-medium disabled:opacity-50`,children:[r?E(B,{className:`w-3 h-3 animate-spin`}):E(k,{className:`w-3 h-3`}),`Update & restart`]})]})]})})}S();function Ne(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Q(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Pe(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function Fe({addons:t,clusterStatus:r,selectedNode:o,onRefresh:s,isRefreshing:c}){let l=ue(),[d,f]=T(``),m=ce(d),[h,g]=T(!1),_=x(null);D(()=>{if(!h)return;let e=e=>{_.current&&!_.current.contains(e.target)&&g(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h]);let{data:v}=y({nodeId:o.id}),re=w(()=>{let e=new Map;for(let t of v??[])e.set(t.name,t.latestVersion);return e},[v]),[ae,oe]=T(()=>new Set),[se,S]=T(()=>new Map),le=b(e=>{oe(t=>new Set(t).add(e))},[]),O=b(e=>{oe(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),de=b((e,t)=>{S(n=>new Map(n).set(e,t))},[]),fe=b(e=>{S(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),M=ee({onMutate:e=>{le(e.name),fe(e.name)},onSuccess:(e,t)=>{O(t.name);let n=e;if(n&&n.success===!1){de(t.name,n.error??`Update failed (no error message returned by server)`);return}l.invalidateQueries({queryKey:[[`addons`]]}),l.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{O(t.name),de(t.name,e instanceof Error?e.message:String(e))}}),F=Y(),me=x(new Set);D(()=>{let e=new Set;for(let[t,n]of F)q(n)&&e.add(t);let t=[...me.current].some(t=>!e.has(t));me.current=e,t&&(l.invalidateQueries({queryKey:[[`addons`]]}),l.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[F,l]);let{data:I}=ie(void 0),he=ne({onSuccess:()=>{l.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:L,isFetching:ge}=e({query:m||void 0},{enabled:h}),R=n(),{data:z}=u(void 0),_e=z?.requestedAt,[V,ve]=T(null),[ye,H]=T(!1);D(()=>{if(z?.kind===`framework-bulk-update`&&z.requestedAt!==V){ve(z.requestedAt),H(!0);let e=window.setTimeout(()=>H(!1),6e3);return()=>window.clearTimeout(e)}},[_e,V,z]);let{data:U}=p(void 0),be=w(()=>new Map((U??[]).map(e=>[e.packageName,e])),[U]),[W,G]=T(null),[K,J]=T(null),X=i({onSuccess:()=>{G(null),l.invalidateQueries({queryKey:[[`addons`]]})},onError:e=>{J(e instanceof Error?e.message:String(e))}}),xe=a(),Se=b(async()=>{let e=v??[];e.length!==0&&(e.some(e=>e.isSystem)&&!await xe({title:`Update all — includes a system package`,message:`This batch updates a system package (@camstack/system). The hub will restart automatically once the framework update completes. In-flight requests are dropped; reconnect typically takes ~10 seconds.`,confirmLabel:`Update all & restart`,variant:`warning`})||await R.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[o.id]}))},[v,o.id,R,xe]),Z=te({onSuccess:()=>{l.invalidateQueries({queryKey:[[`addons`]]}),l.invalidateQueries({queryKey:[[`addonPages`]]}),l.invalidateQueries({queryKey:[[`capabilities`]]}),l.invalidateQueries({queryKey:[[`integrations`]]})}}),[Ce,we]=T(`type`),[Te,Ee]=T(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),De=e=>{Ee(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[Oe,Ae]=P(),Q=Oe.get(`capability`),Fe=w(()=>{let e=o.isHub?t:t.filter(e=>Ne(e.placement,o.isHub));return Q&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Q))),e},[t,o.isHub,Q]),Ie=()=>{let e=new URLSearchParams(Oe);e.delete(`capability`),Ae(e,{replace:!0})},Le=Te===`flat`?Fe:Pe(Fe),Re=w(()=>{let e=[...Le];switch(Ce){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Le,Ce]);return C(`div`,{className:`space-y-4`,children:[[...se.entries()].map(([e,t])=>E(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]`,children:C(`div`,{className:`flex items-start justify-between gap-3`,children:[C(`div`,{className:`space-y-0.5`,children:[C(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),E(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),E(`button`,{type:`button`,onClick:()=>fe(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),C(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[C(`div`,{className:`flex items-center gap-1.5`,children:[E(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),C(`select`,{value:Ce,onChange:e=>we(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[E(`option`,{value:`type`,children:`Bundles first`}),E(`option`,{value:`name`,children:`Name`}),E(`option`,{value:`source`,children:`Install source`})]})]}),C(`div`,{className:`flex items-center gap-1.5`,children:[E(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),E(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>E(`button`,{type:`button`,onClick:()=>De(e),className:`px-2.5 py-1.5 transition-colors capitalize ${Te===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?`Group multi-addon packages into a bundle card`:`Show every addon as its own card`,children:e},e))})]}),o.isHub&&C(`div`,{className:`flex items-center gap-1.5`,children:[E(A,{className:`h-3 w-3 text-foreground-subtle`}),E(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),E(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>E(`button`,{type:`button`,onClick:()=>he.mutate({channel:e}),disabled:he.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${I?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),(v?.length??0)>0&&C(`button`,{type:`button`,onClick:()=>void Se(),disabled:R.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[R.isPending?E(B,{className:`w-3 h-3 animate-spin`}):E(k,{className:`w-3 h-3`}),R.isPending?`Updating…`:`Update All (${v.length})`]}),C(`button`,{type:`button`,onClick:s,disabled:c||R.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[E(A,{className:`w-3 h-3 ${c?`animate-spin`:``}`}),`Refresh`]})]}),C(`div`,{className:`flex items-center gap-3`,children:[C(`div`,{className:`relative flex-1 min-w-[200px]`,ref:_,children:[E(j,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),E(`input`,{type:`text`,value:d,onChange:e=>{f(e.target.value),g(!0)},onFocus:()=>g(!0),placeholder:`Search addons on npm...`,disabled:R.isPending,className:`w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`}),ge&&E(B,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),h&&L&&L.length>0&&C(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,children:[L.length>0&&C(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[`npm results (`,L.length,`)`]}),L&&L.length>0&&E(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:L.map(e=>C(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[E(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),C(`div`,{className:`flex-1 min-w-0`,children:[C(`div`,{className:`flex items-center gap-2`,children:[E(`span`,{className:`text-[11px] font-semibold truncate`,children:e.name}),C(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`v`,e.version]})]}),e.description&&E(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?C(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0`,children:[E(N,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):C(`button`,{type:`button`,onClick:()=>Z.mutate({packageName:e.name}),disabled:Z.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[Z.isPending?E(B,{className:`h-3 w-3 animate-spin`}):E(k,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),E(je,{onUploadSuccess:()=>{l.invalidateQueries({queryKey:[[`addons`]]}),s()}})]}),Q&&C(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm`,children:[E(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),E(`span`,{className:`font-mono text-primary font-semibold`,children:Q}),E(`button`,{type:`button`,onClick:Ie,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),ye&&C(`div`,{className:`fixed top-4 right-4 z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[E(pe,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),C(`div`,{children:[E(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),E(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),Fe.length===0&&E(`div`,{className:`text-xs text-foreground-subtle`,children:t.length===0?`No addons installed`:Q?`No installed addons declare the "${Q}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${o.name} (placement filter active)`}),E(`div`,{className:`space-y-2`,children:Re.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=re.get(t),i=$(e)?e.representative:e,a=be.has(t),s=n?a?e=>G({packageName:t,fromVersion:be.get(t)?.currentVersion??i.manifest.packageVersion??i.manifest.version,toVersion:e}):e=>M.mutate({name:t,version:e,nodeId:o.id}):void 0,c=F.get(t)??null,l=c!==null&&q(c);return E(ke,{addon:i,clusterStatus:r?.[i.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:ae.has(t)||l,jobProgress:c,onUpdate:s,isSystem:a,disabledByBulk:R.isPending},$(e)?t:e.manifest.id)})}),W!==null&&E(Me,{pending:W,onCancel:()=>{G(null),J(null)},onConfirm:()=>{J(null),X.mutate({packageName:W.packageName,version:W.toVersion})},isPending:X.isPending,error:K})]})}function Ie(){let e=ue(),{data:t,isLoading:n,isError:i}=v(),{data:a}=h(void 0),{data:o}=r(void 0,{refetchInterval:1e4}),s=w(()=>{let e=new Map;e.set(`hub`,{id:`hub`,name:`Hub`,isHub:!0});for(let t of o??[]){let n=String(t.id??``);n&&e.set(n,{id:n,name:String(t.name??n),isHub:!!t.isHub})}return[...e.values()]},[o]),[c,u]=T(`hub`),d=s.find(e=>e.id===c)??s[0],f=l(),p=se(),m=f.isPending||p.isPending,ee=async()=>{await f.mutateAsync({nodeId:c}),await p.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},g=x(f);g.current=f,D(()=>{g.current.mutate({nodeId:`hub`})},[]);let _=(t??[]).map(Q).filter(e=>e!==null);return C(V,{children:[C(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[E(re,{selectedNodeId:c,onSelect:u}),C(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[!n&&!i&&C(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[_.length,` installed`]}),C(`button`,{type:`button`,onClick:()=>void ee(),disabled:m,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:`Re-fetch addons + check npm for new versions`,children:[E(A,{className:`w-3 h-3 ${m?`animate-spin`:``}`}),`Check for updates`]})]})]}),!d.isHub&&C(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[`Showing only addons compatible with`,` `,E(`span`,{className:`font-medium text-foreground`,children:d.name}),` — agents only run`,` `,E(`code`,{className:`font-mono`,children:`agent-only`}),` and`,` `,E(`code`,{className:`font-mono`,children:`any-node`}),` addons. Install / uninstall is hub-driven; agents auto-sync from the hub.`]}),n&&E(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),i&&E(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!n&&!i&&E(Fe,{addons:_,clusterStatus:a,selectedNode:d,onRefresh:()=>void ee(),isRefreshing:m})]})}export{Ie as AddonsPage};
@@ -1 +0,0 @@
1
- import{Ar as e,Cr as t,Fr as n,Ir as r,Mr as i,Nr as a,Pr as o,Qi as s,_a as c,_i as l,aa as u,ba as d,g as f,jr as p,m,ni as h,ra as g,va as _,wr as v,ya as y}from"./src-BZ1dd5LI.js";import{I as b,K as x,Q as S,S as C,W as w,o as T,q as E,x as D,z as O}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{p as k}from"./player-overlays-CpsGl45o.js";import{t as A}from"./pencil-BlQGw-pI.js";import{t as j}from"./radio-DO0Dq2MF.js";import{t as M}from"./refresh-cw-CMRlnF-M.js";import{t as N}from"./rotate-cw-CCcZjC0U.js";import{t as P}from"./server-CaW_paWO.js";import{t as F}from"./upload-7zSY3rlx.js";import{F as I,L,M as R,P as z,V as B,i as V,k as H,o as U,p as W,s as G,x as K}from"./index-CY52lvbZ.js";import{n as q,t as J}from"./build-cluster-graph-DIgt00ch.js";import{t as Y}from"./format-size-CO9d3C3-.js";import{t as X}from"./NodeAddonsSettingsPanel-DTzycFzS.js";var Z=B(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Q=B(`memory-stick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),$=B(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),ee=B(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]);S();function te(e){let t=new FormData;return t.append(`file`,e.file,e.file.name),t.append(`nodeId`,e.nodeId),e.addonId&&t.append(`addonId`,e.addonId),new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`POST`,`/api/addons/upload`),e.token&&i.setRequestHeader(`Authorization`,`Bearer ${e.token}`),i.upload.addEventListener(`progress`,t=>{t.lengthComputable&&e.onProgress(Math.round(t.loaded/t.total*100))}),i.addEventListener(`load`,()=>{let e;try{e=JSON.parse(i.responseText)}catch{r(Error(`HTTP ${i.status}`));return}i.status>=200&&i.status<300?n(e):r(Error(e.error??`HTTP ${i.status}`))}),i.addEventListener(`error`,()=>r(Error(`Network error during upload`))),i.addEventListener(`abort`,()=>r(Error(`Upload aborted`))),i.send(t)})}function ne({nodeId:t,addons:n,isHub:a}){let o=T(),c=s(),[l,u]=E(null),[d,f]=E(null),[p,m]=E(!1),[h,g]=E(null),[_,v]=E(0),y=x(null),b=i(),S=r(),w=e({nodeId:t}),O=w.data??[],k=new Map(n.map(e=>[e.id,e.capabilities])),A=O.length>0?O.map(e=>({id:e.id,status:e.status,capabilities:k.get(e.id)??[],version:e.version,packageName:e.packageName})):n.map(e=>({id:e.id,status:e.status,capabilities:e.capabilities,version:void 0,packageName:void 0})),j=()=>{o.invalidateQueries({queryKey:[[`nodes`,`topology`]]}),w.refetch()},M=async e=>{u(e);try{await b.mutateAsync({nodeId:t,addonId:e}),j()}catch(e){console.error(`Failed to restart addon:`,e)}finally{u(null)}},P=async e=>{if(await c({title:`Uninstall addon`,message:`Remove "${e}" from ${t}? The addon directory will be deleted on disk.`,confirmLabel:`Uninstall`,variant:`danger`})){f(e);try{await S.mutateAsync({nodeId:t,addonId:e}),j()}catch(e){console.error(`Failed to uninstall addon:`,e)}finally{f(null)}}},I=C(`div`,{className:`flex items-center gap-2 mb-2`,children:[D(`input`,{ref:y,type:`file`,accept:`.tgz,.tar.gz`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(n){e.target.value=``,g(null),m(!0),v(0);try{await te({file:n,nodeId:t,token:localStorage.getItem(`camstack_admin_token`),onProgress:v}),j()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1),v(0)}}}}),C(`button`,{onClick:()=>y.current?.click(),disabled:p,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[p?D(K,{className:`h-3 w-3 animate-spin`}):D(F,{className:`h-3 w-3`}),p?`Uploading… ${_}%`:`Upload addon (.tgz)`]}),p&&D(`div`,{className:`flex-1 h-1 rounded-full bg-muted overflow-hidden max-w-[140px]`,children:D(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${_}%`}})}),h&&D(`span`,{className:`text-[10px] text-destructive`,children:h})]});return A.length===0?C(`div`,{children:[I,D(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:w.isLoading?`Loading addons…`:`No addons on this node`})]}):C(`div`,{children:[I,C(`table`,{className:`w-full text-xs`,children:[D(`thead`,{children:C(`tr`,{className:`text-muted-foreground text-left`,children:[D(`th`,{className:`py-2 font-medium`,children:`Addon`}),D(`th`,{className:`py-2 font-medium`,children:`Version`}),D(`th`,{className:`py-2 font-medium`,children:`Capabilities`}),D(`th`,{className:`py-2 font-medium`,children:`Status`}),D(`th`,{className:`py-2 font-medium w-16`})]})}),D(`tbody`,{children:A.map(e=>C(`tr`,{className:`border-t border-border/50`,children:[C(`td`,{className:`py-2 font-medium`,children:[D(`div`,{children:e.id}),e.packageName&&D(`div`,{className:`text-[9px] text-muted-foreground`,children:e.packageName})]}),D(`td`,{className:`py-2 text-muted-foreground`,children:e.version??`—`}),D(`td`,{className:`py-2`,children:D(`div`,{className:`flex flex-wrap gap-1`,children:e.capabilities.length>0?e.capabilities.map(e=>D(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400`,children:e},e)):D(`span`,{className:`text-muted-foreground`,children:`—`})})}),D(`td`,{className:`py-2`,children:D(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e.status===`running`?`bg-success/10 text-success`:e.status===`error`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e.status})}),D(`td`,{className:`py-2`,children:C(`div`,{className:`flex items-center gap-1 justify-end`,children:[D(`button`,{onClick:()=>M(e.id),disabled:l===e.id||d===e.id,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.id}`,children:D(N,{className:`h-3 w-3 ${l===e.id?`animate-spin`:``}`})}),D(`button`,{onClick:()=>P(e.id),disabled:l===e.id||d===e.id,className:`p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50`,title:`Uninstall ${e.id}`,children:d===e.id?D(K,{className:`h-3 w-3 animate-spin`}):D(G,{className:`h-3 w-3`})})]})})]},e.id))})]})]})}S();function re(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function ie({state:e}){return D(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e===`running`?`bg-success/10 text-success`:e===`crashed`||e===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e})}var ae=[`trace`,`debug`,`info`,`warn`,`error`];function oe({proc:e,nodeId:t,defaultExpanded:n,activePanel:r,onTogglePanel:s}){let l=e.services??[],u=l.length===1,[p,h]=E(u||n),[g,v]=E(null),[b,x]=E(`info`),S=e.name.includes(`(core)`),w=i(),T=a(),O=o(),k=async e=>{v(e);try{await w.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{v(null)}},A=async()=>{v(e.name);try{await T.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{v(null)}},M=async n=>{let r=`${t}/${e.name}`;try{await O.mutateAsync({nodeId:r,level:n}),x(n)}catch(e){console.error(`Failed to set log level:`,e)}};return C(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[C(`div`,{role:u?void 0:`button`,tabIndex:u?void 0:0,onClick:u?void 0:()=>h(!p),onKeyDown:u?void 0:e=>{(e.key===`Enter`||e.key===` `)&&h(!p)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${u?``:`hover:bg-muted/40 cursor-pointer`}`,children:[u?D(`span`,{className:`h-3 w-3 shrink-0`}):D(p?z:R,{className:`h-3 w-3 text-muted-foreground shrink-0`}),S?D(P,{className:`h-3.5 w-3.5 text-primary shrink-0`}):D(L,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),D(`span`,{className:`text-xs font-semibold flex-1`,children:e.name}),C(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,e.pid]}),D(ie,{state:e.state}),C(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.cpuPercent,`% CPU`]}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:Y(e.memoryRss)}),D(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:re(e.uptimeSeconds)}),!S&&C(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[C(c,{children:[D(d,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:`Set log level`,children:b}),D(_,{align:`end`,className:`min-w-[70px] py-0.5`,children:ae.map(e=>D(y,{onClick:()=>M(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===b?`text-primary font-semibold`:``}`,children:e},e))})]}),D(`button`,{onClick:A,disabled:g===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:D(N,{className:`h-3 w-3 ${g===e.name?`animate-spin`:``}`})})]})]}),p&&l.length>0&&D(`div`,{className:`divide-y divide-border/30`,children:l.map(e=>C(`div`,{children:[C(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[D(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),D(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&C(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>D(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&C(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),C(`div`,{className:`flex items-center gap-1 shrink-0`,children:[D(`button`,{onClick:()=>s(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${r?.addonId===e.addonId&&r.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:D(W,{className:`h-3 w-3`})}),D(`button`,{onClick:()=>s(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${r?.addonId===e.addonId&&r.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:D(j,{className:`h-3 w-3`})}),D(`button`,{onClick:()=>k(e.addonId),disabled:g===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:D(N,{className:`h-3 w-3 ${g===e.addonId?`animate-spin`:``}`})})]})]}),r?.addonId===e.addonId&&r.type===`logs`&&D(`div`,{className:`border-t border-border/40 bg-muted/5`,children:D(f,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>s(e.addonId,`logs`)})}),r?.addonId===e.addonId&&r.type===`events`&&D(`div`,{className:`border-t border-border/40 bg-muted/5`,children:D(m,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>s(e.addonId,`events`)})})]},e.addonId))}),p&&l.length===0&&D(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function se({nodeId:e,processes:t}){let[n,r]=E(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?D(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):D(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>D(oe,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}S();function ce(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function le(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function ue({nodeId:e}){let n=T(),r=s(),[i,a]=E(`all`),o=g(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:c}=v({nodeId:e}),l=o?.processes??c,u=w(()=>l?[...l]:[],[l]),d=w(()=>i===`ghost`?u.filter(e=>e.classification===`ghost`):u,[u,i]),f=w(()=>{let e=u.filter(e=>e.classification===`ghost`),t=new Map;for(let n of e)t.has(n.ppid)||t.set(n.ppid,[]),t.get(n.ppid).push(n);return[...t.entries()].filter(([,e])=>e.length>1).map(([e,t])=>({ppid:e,children:t})).toSorted((e,t)=>t.children.length-e.children.length)},[u]),p=t({onSettled:()=>{n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]})}}),m=w(()=>{let e=new Map;for(let t of u)e.set(t.pid,t.classification);return e},[u]),h=async(t,n)=>{if(t.classification===`root`||t.classification===`system`)return;let i=t.classification===`ghost`?`ghost`:t.addonId??`process`,a=n?`SIGKILL`:`SIGTERM`;await r({title:`Send ${a}?`,message:`Target pid ${t.pid} (${i}) on node ${e}.`,confirmLabel:`Send ${a}`,variant:`danger`})&&p.mutate({nodeId:e,pid:t.pid,force:n})},_=async(t,n)=>{try{await p.mutateAsync({nodeId:e,pid:t,force:n})}catch{}},y=async t=>{let i=m.get(t.ppid);if(i===`root`||i===`system`){await r({title:`Cannot kill protected ancestor`,message:i===`root`?`pid ${t.ppid} is the current node supervisor. Restart the node via the cluster page instead.`:`pid ${t.ppid} is a system ancestor (concurrently / vite / npm wrapper). Killing it would tear down the dev tree.`,confirmLabel:`OK`,cancelLabel:`Close`,variant:`warning`});return}await r({title:`Kill ghost parent + ${t.children.length} child(ren)?`,message:`SIGKILL parent pid ${t.ppid} and SIGTERM ${t.children.length} ghost child(ren) on node ${e}.`,confirmLabel:`Kill all`,variant:`danger`})&&(await Promise.all([_(t.ppid,!0),...t.children.map(e=>_(e.pid,!1))]),n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}))},b=async()=>{let t=u.filter(e=>e.classification===`ghost`);t.length!==0&&await r({title:`Kill all ${t.length} ghost process(es)?`,message:`SIGKILL ${t.length} ghost process(es) on node ${e}. This is irreversible.`,confirmLabel:`Kill all`,variant:`danger`})&&(await Promise.all(t.map(e=>_(e.pid,!0))),n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}))},x=u.filter(e=>e.classification===`ghost`).length,S=u.filter(e=>e.classification===`managed`).length,O=u.filter(e=>e.classification===`root`).length,k=u.filter(e=>e.classification===`system`).length;return C(`div`,{className:`space-y-4`,children:[C(`div`,{className:`flex items-start justify-between gap-4`,children:[C(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`ps`," scan + kernel `$process.list` cross-reference. Ghosts = camstack-shaped commands with no managed binding (usually orphaned to ppid=1). Refreshes every 10s."]}),C(`button`,{type:`button`,onClick:()=>n.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[D(M,{className:`h-3 w-3`}),` Refresh`]})]}),C(`div`,{className:`grid grid-cols-4 gap-3`,children:[C(`div`,{className:`rounded-lg border border-border p-3`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Root`}),D(`div`,{className:`text-xl font-semibold text-foreground`,children:O})]}),C(`div`,{className:`rounded-lg border border-border p-3`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Managed`}),D(`div`,{className:`text-xl font-semibold text-foreground`,children:S})]}),C(`div`,{className:`rounded-lg border border-border p-3`,children:[D(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`System`}),D(`div`,{className:`text-xl font-semibold text-foreground`,children:k})]}),C(`div`,{className:`rounded-lg border p-3 ${x>0?`border-destructive/40 bg-destructive/5`:`border-border`}`,children:[C(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle flex items-center gap-1`,children:[x>0&&D($,{className:`h-3 w-3 text-destructive`}),` Ghosts`]}),D(`div`,{className:`text-xl font-semibold ${x>0?`text-destructive`:`text-foreground`}`,children:x})]})]}),f.length>0&&C(`div`,{className:`rounded-lg border border-amber-500/40 bg-amber-500/5 p-3`,children:[C(`div`,{className:`flex items-center gap-1 text-[11px] font-semibold text-amber-400 mb-2`,children:[D(U,{className:`h-3 w-3`}),` Recurring ghost parents (`,f.length,`)`]}),D(`div`,{className:`space-y-1.5`,children:f.map(e=>C(`div`,{className:`text-[11px] text-foreground flex items-center justify-between gap-2`,children:[C(`div`,{className:`flex items-center gap-2`,children:[C(`span`,{className:`font-mono text-foreground-subtle`,children:[`ppid `,e.ppid]}),C(`span`,{children:[`→ `,e.children.length,` ghost(s)`]})]}),C(`button`,{type:`button`,disabled:p.isPending,onClick:()=>{y(e)},className:`inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] text-amber-400 hover:bg-amber-500/20 disabled:opacity-30`,children:[D($,{className:`h-3 w-3`}),` Kill parent + `,e.children.length]})]},e.ppid))})]}),C(`div`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[C(`div`,{className:`flex items-center gap-2`,children:[D(`span`,{className:`text-foreground-subtle`,children:`Filter:`}),C(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${i===`all`?`bg-primary text-primary-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>a(`all`),children:[`All (`,u.length,`)`]}),C(`button`,{type:`button`,className:`px-2 py-0.5 rounded ${i===`ghost`?`bg-destructive text-destructive-foreground`:`border border-border text-foreground hover:bg-surface-hover`}`,onClick:()=>a(`ghost`),children:[`Ghost only (`,x,`)`]})]}),x>0&&C(`button`,{type:`button`,disabled:p.isPending,onClick:()=>{b()},className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20 disabled:opacity-30`,children:[D($,{className:`h-3 w-3`}),` Kill all `,x,` ghost(s)`]})]}),D(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:C(`table`,{className:`w-full text-xs`,children:[D(`thead`,{className:`bg-surface`,children:C(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[D(`th`,{className:`text-left px-3 py-2`,children:`Class`}),D(`th`,{className:`text-right px-3 py-2`,children:`PID`}),D(`th`,{className:`text-right px-3 py-2`,children:`PPID`}),D(`th`,{className:`text-left px-3 py-2`,children:`Addon`}),D(`th`,{className:`text-left px-3 py-2`,children:`Command`}),D(`th`,{className:`text-right px-3 py-2`,children:`CPU%`}),D(`th`,{className:`text-right px-3 py-2`,children:`RSS`}),D(`th`,{className:`text-right px-3 py-2`,children:`Uptime`}),D(`th`,{className:`w-44`})]})}),C(`tbody`,{children:[d.length===0&&D(`tr`,{children:D(`td`,{colSpan:9,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:i===`ghost`?`No ghost processes detected.`:`Scanning…`})}),d.map(e=>C(`tr`,{className:`border-t border-border ${e.classification===`ghost`?`bg-destructive/5`:``}`,children:[D(`td`,{className:`px-3 py-2`,children:D(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`ghost`?`bg-destructive/20 text-destructive`:e.classification===`root`?`bg-sky-500/20 text-sky-400`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})}),D(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.pid}),C(`td`,{className:`px-3 py-2 text-right font-mono text-foreground-subtle`,children:[e.ppid,e.orphaned?` ⚠`:``]}),D(`td`,{className:`px-3 py-2 text-foreground-subtle text-[11px]`,children:e.addonId??`—`}),D(`td`,{className:`px-3 py-2 font-mono text-[10px] text-foreground-subtle break-all`,children:le(e.command)}),D(`td`,{className:`px-3 py-2 text-right text-foreground`,children:e.cpuPercent.toFixed(1)}),D(`td`,{className:`px-3 py-2 text-right text-foreground`,children:Y(e.memoryRssBytes)}),D(`td`,{className:`px-3 py-2 text-right text-foreground-subtle`,children:ce(e.uptimeSec)}),D(`td`,{className:`px-3 py-2 text-right`,children:C(`div`,{className:`inline-flex gap-1`,children:[C(`button`,{type:`button`,disabled:p.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{h(e,!1)},title:`SIGTERM`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-border text-[10px] text-foreground hover:bg-surface-hover disabled:opacity-30`,children:[D(G,{className:`h-3 w-3`}),` Term`]}),C(`button`,{type:`button`,disabled:p.isPending||e.classification===`root`||e.classification===`system`,onClick:()=>{h(e,!0)},title:`SIGKILL`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-destructive/30 text-[10px] text-destructive hover:bg-destructive/10 disabled:opacity-30`,children:[D($,{className:`h-3 w-3`}),` Kill`]})]})})]},e.pid))]})]})}),p.isError&&C(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,p.error instanceof Error?p.error.message:`unknown`]})]})}function de({nodeId:e,addonIds:t}){return t.length===0?D(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No addons on this node`}):D(`div`,{className:`w-full py-2`,children:D(X,{nodeId:e,addonIds:t,level:`global`})})}S();function fe({nodeId:e,addons:t}){let n=T(),{data:r,isLoading:i}=h({nodeId:e}),a=w(()=>{let e=new Map;for(let n of t)for(let t of n.capabilities){let r=e.get(t)??[];r.push(n.id),e.set(t,r)}return[...e.entries()].toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({capName:e,providers:t}))},[t]),o=l({onSuccess:()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCapabilityBindings`]]})}});return a.length===0?D(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No capabilities on this node`}):C(`table`,{className:`w-full text-xs`,children:[D(`thead`,{children:C(`tr`,{className:`text-muted-foreground text-left`,children:[D(`th`,{className:`py-2 font-medium w-1/2`,children:`Capability`}),D(`th`,{className:`py-2 font-medium`,children:`Bound provider`})]})}),D(`tbody`,{children:a.map(({capName:t,providers:n})=>{let a=r?.[t]??n[0]??``,s=n.length===1;return C(`tr`,{className:`border-t border-border/50`,children:[D(`td`,{className:`py-2 font-medium`,children:t}),D(`td`,{className:`py-2`,children:D(`select`,{value:a,onChange:n=>o.mutate({nodeId:e,capName:t,addonId:n.target.value}),disabled:s||o.isPending||i,className:`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-60`,title:s?`Only one provider installed — choice becomes available once a second addon registers this capability`:void 0,children:n.map(e=>D(`option`,{value:e,children:e},e))})})]},t)})})]})}S();function pe(e){if(e==null)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h ${i}m`:r>0?`${r}h ${i}m`:`${i}m`}function me(e){let[t,n]=E(!1),[r,i]=E(e.name),a=T(),o=p({onSuccess:()=>{a.invalidateQueries({queryKey:[[`nodes`,`topology`]]})}}),s=(e.localIps??[]).filter(e=>!e.includes(`:`)),c=(e.localIps??[]).filter(e=>e.includes(`:`)),l=async()=>{if(!r.trim()||r===e.name){n(!1);return}try{await o.mutateAsync({nodeId:e.nodeId,name:r.trim()}),n(!1)}catch(e){console.error(`Rename failed:`,e)}},u=[[`Node ID`,D(`span`,{className:`font-mono text-xs`,children:e.nodeId})],[`Display Name`,t?C(`div`,{className:`flex items-center gap-1.5`,children:[D(`input`,{type:`text`,className:`flex-1 px-2 py-0.5 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l(),e.key===`Escape`&&n(!1)},disabled:o.isPending,autoFocus:!0}),D(`button`,{onClick:()=>void l(),disabled:o.isPending,className:`p-0.5 text-success hover:bg-success/10 rounded`,title:`Save`,children:D(I,{className:`h-3.5 w-3.5`})}),D(`button`,{onClick:()=>n(!1),className:`p-0.5 text-muted-foreground hover:bg-muted rounded`,title:`Cancel`,children:D(V,{className:`h-3.5 w-3.5`})})]}):C(`div`,{className:`flex items-center gap-1.5`,children:[D(`span`,{className:`text-xs`,children:e.name}),!e.isHub&&D(`button`,{onClick:()=>{i(e.name),n(!0)},className:`p-0.5 text-muted-foreground hover:text-primary rounded`,title:`Rename`,children:D(A,{className:`h-3 w-3`})})]})],[`Hostname`,D(`span`,{className:`text-xs`,children:e.hostname})],[`Role`,e.isHub?D(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium`,children:`Hub`}):D(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-medium`,children:`Agent`})],[`Platform`,C(`span`,{className:`text-xs`,children:[e.platform,` / `,e.arch]})],[`CPU`,C(`span`,{className:`text-xs`,children:[e.cpuModel??`—`,` (`,e.cpuCores,` cores)`]})],[`Memory`,D(`span`,{className:`text-xs`,children:e.memoryMB>0?`${(e.memoryMB/1024).toFixed(1)} GB`:`—`})],[`Uptime`,D(`span`,{className:`text-xs`,children:pe(e.uptime)})],[`Engines`,e.engines.length>0?D(`div`,{className:`flex flex-wrap gap-1`,children:e.engines.map(e=>D(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e))}):D(`span`,{className:`text-xs text-muted-foreground`,children:`—`})]];return s.length>0&&u.push([`IPv4`,D(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map((e,t)=>D(`span`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:e},`${e}-${t}`))})]),c.length>0&&u.push([`IPv6`,D(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map((e,t)=>D(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted truncate max-w-[280px]`,title:e,children:e},`${e}-${t}`))})]),D(`div`,{className:`py-2`,children:D(`table`,{className:`w-full text-sm`,children:D(`tbody`,{children:u.map(([e,t],n)=>C(`tr`,{className:n%2==0?`bg-muted/20`:``,children:[D(`td`,{className:`py-1.5 px-2 text-xs font-medium text-muted-foreground w-28 align-top whitespace-nowrap`,children:e}),D(`td`,{className:`py-1.5 px-2`,children:t})]},e))})})})}S();function he({node:e}){let t=k(),[n,r]=E(`info`),[i,a]=E(!1),o=e.processes??[],s=e.addons.map(e=>e.id),c=async()=>{if(!i){a(!0);try{await Promise.allSettled([t.trpcClient.pipelineOrchestrator.removeAgentSettings.mutate({agentNodeId:e.id}),t.trpcClient.clusterNodes.forgetNode.mutate({nodeId:e.id})])}finally{a(!1)}}};return e.isOnline?C(`div`,{className:`border border-border rounded-xl overflow-hidden`,children:[C(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30 border-b border-border`,children:[D(`div`,{className:`w-2.5 h-2.5 rounded-full bg-success`}),D(`span`,{className:`text-sm font-semibold`,children:e.name}),C(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>D(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),C(`div`,{className:`ml-auto flex gap-3 text-xs text-muted-foreground`,children:[C(`span`,{className:`flex items-center gap-1`,children:[D(H,{className:`h-3 w-3`}),` `,e.cpuPercent,`%`]}),C(`span`,{className:`flex items-center gap-1`,children:[D(Q,{className:`h-3 w-3`}),` `,e.memoryPercent,`%`]})]})]}),D(`div`,{className:`flex border-b border-border px-4`,children:[`info`,`addons`,`forks`,`processes`,`settings`,`capabilities`].map(t=>D(`button`,{onClick:()=>r(t),className:`px-3 py-2 text-xs font-medium border-b-2 transition-colors ${n===t?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:t===`info`?`Info`:t===`addons`?`Addons (${e.addons.length})`:t===`forks`?`Forks (${o.length})`:t===`processes`?`Processes`:t===`settings`?`Settings`:`Capabilities`},t))}),C(`div`,{className:`px-4 py-2`,children:[n===`info`&&D(me,{nodeId:e.id,name:e.name,hostname:e.hostname,platform:e.platform,arch:e.arch,cpuModel:e.cpuModel,cpuCores:e.cpuCores,memoryMB:e.memoryMB,engines:e.engines,isHub:e.isHub,uptime:e.uptime,localIps:e.localIps}),n===`addons`&&D(ne,{nodeId:e.id,addons:e.addons,isHub:e.isHub}),n===`forks`&&D(se,{nodeId:e.id,processes:o}),n===`processes`&&D(ue,{nodeId:e.id}),n===`settings`&&D(de,{nodeId:e.id,addonIds:s}),n===`capabilities`&&D(fe,{nodeId:e.id,addons:e.addons})]})]}):C(`div`,{className:`border border-border rounded-xl overflow-hidden opacity-60`,children:[C(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-muted/30`,children:[D(`div`,{className:`w-2.5 h-2.5 rounded-full bg-destructive`}),D(`span`,{className:`text-sm font-semibold`,children:e.name}),C(`span`,{className:`text-xs text-muted-foreground`,children:[e.cpuModel??e.platform,` ·`,` `,e.memoryMB>0?`${Math.round(e.memoryMB/1024)}GB`:``,` · `,e.arch]}),e.engines.map(e=>D(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-purple-500/10 text-purple-400 font-medium`,children:e},e)),D(`span`,{className:`ml-auto text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`})]}),C(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[C(`span`,{className:`text-xs text-muted-foreground`,children:[e.lastSeen?`Last seen ${new Date(e.lastSeen).toLocaleString()} — `:``,e.addons.length,` addon`,e.addons.length===1?``:`s`,` assigned; will resume when node reconnects`]}),C(`button`,{type:`button`,onClick:()=>void c(),disabled:i,title:`Forget this node — removes its saved history and pipeline assignments`,className:`flex items-center gap-1 text-xs px-2 py-1 rounded-md border border-border text-muted-foreground hover:text-destructive hover:border-destructive/50 disabled:opacity-50 transition-colors`,children:[D(G,{className:`h-3 w-3`}),i?`Forgetting…`:`Forget node`]})]})]})}S();function ge({nodes:e,focusNodeId:t,focusNonce:n}){let r=[...e].toSorted((e,t)=>e.isHub?-1:t.isHub?1:e.isOnline&&!t.isOnline?-1:!e.isOnline&&t.isOnline?1:e.name.localeCompare(t.name)),i=x(null);return O(()=>{if(!t)return;let e=i.current?.querySelector(`#node-card-${CSS.escape(t)}`);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},[t,n]),D(`div`,{ref:i,className:`flex flex-col gap-4`,children:r.map(e=>D(`div`,{id:`node-card-${e.id}`,children:D(he,{node:e})},e.id))})}S();function _e(e){let[t,n]=E(()=>typeof window<`u`?window.matchMedia(e).matches:!1);return O(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function ve(){let{data:e,isLoading:t}=n(void 0,{staleTime:1/0}),[r,i]=E(null);return u(`cluster.topology-snapshot`,e=>{let t=e.data?.nodes;Array.isArray(t)&&i(t)}),{nodes:w(()=>r??e??[],[r,e]),isLoading:t&&!r}}function ye(){let[e,t]=E(`table`),[n,r]=E(void 0),[i,a]=E(0),o=_e(`(max-width: 767px)`),s=o&&e===`graph`?`table`:e,{nodes:c,isLoading:l}=ve(),u=w(()=>J(c),[c]),d=c.filter(e=>e.isOnline).length,f=c.filter(e=>!e.isOnline).length,p=b(e=>{t(`table`),r(e),a(e=>e+1)},[]),m=(n,r,i)=>C(`button`,{onClick:()=>t(n),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${e===n?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[D(i,{className:`h-3.5 w-3.5`}),r]});return C(`div`,{className:`flex flex-col h-full gap-4 p-4`,children:[C(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[C(`div`,{className:`flex items-center gap-2`,children:[d>0&&C(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-success/10 text-success`,children:[d,` online`]}),f>0&&C(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:[f,` offline`]})]}),C(`div`,{className:`flex gap-0.5 p-1 rounded-lg bg-muted`,children:[m(`table`,`Table`,ee),!o&&m(`graph`,`Graph`,Z)]})]}),l?D(`div`,{className:`flex items-center justify-center flex-1 text-muted-foreground`,children:`Loading cluster topology...`}):s===`graph`?D(q,{graph:u,onOpenNodeDetail:p}):D(`div`,{className:`flex-1 overflow-auto`,children:D(ge,{nodes:c,focusNodeId:n,focusNonce:i})})]})}export{ye as ClusterPage};
@@ -1 +0,0 @@
1
- import{Bt as e,Di as t,Ei as n,Gt as r,Ht as i,Lt as a,Qi as o,Rt as s,Ti as c,Ut as l,Vt as u,Wt as d,ia as f,ki as p,xt as m,zt as h}from"./src-BZ1dd5LI.js";import{I as g,Q as _,S as v,W as y,b,o as x,q as S,x as C,z as w}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as T}from"./src-BXL7z3gT.js";import{t as E}from"./download-fsWmKUMh.js";import{i as D,n as O,r as k,t as A}from"./AddLocationWizard-6UQCTSu4.js";import{t as j}from"./plus-DSiRMRVx.js";import{t as M}from"./rotate-cw-CCcZjC0U.js";import{M as N,P,V as F,i as I,s as L,x as R,z as ee}from"./index-CY52lvbZ.js";import{t as z}from"./AdminPage-BwmGKnRf.js";import{t as B}from"./format-size-CO9d3C3-.js";import{t as V}from"./AdminTabs-Bn5jDw8C.js";var H=F(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),te=F(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),ne=F(`calendar-clock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]);_();function U(){let e=x(),r=o(),{data:i,isLoading:a,isError:s}=t({}),l=n(),u=y(()=>l.data??[],[l.data]),[d,f]=S(null),[m,h]=S(null),g=c({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),_=p({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),b=e=>{e.isDefault||_.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},w=async e=>{if(e.isDefault){await r({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another location as default first, then delete this one.`,confirmLabel:`OK`,variant:`warning`});return}await r({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`})&&g.mutate({id:e.id})},T=y(()=>{let e=new Map;for(let t of i??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[i]),E=a||l.isLoading,D=s||l.isError;return v(z,{children:[E&&C(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),D&&C(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!E&&!D&&v(`div`,{className:`space-y-3`,children:[u.length===0&&C(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),u.map(e=>C(k,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:T.get(e.id)??[],onAdd:e=>f(e),onEdit:e=>h(e),onDelete:e=>{w(e)},onSetDefault:e=>b(e)},e.id))]}),d!==null&&C(A,{initialType:d,onClose:()=>f(null),onCreated:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),f(null)}}),m!==null&&C(O,{location:m,onClose:()=>h(null),onSaved:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),h(null)}})]})}_();var W=[[`backup`,`listDestinations`]],G=[`backup`,`listArchives`];function K({destinationId:e,restoreSupported:t,onOpenRestoreWizard:n}){let r=x(),i=o(),{data:s,isLoading:c,isError:l}=h({destinationId:e}),u=s??[],d=a({onSuccess:()=>{r.invalidateQueries({queryKey:[[...G]]}),r.invalidateQueries({queryKey:W})}}),f=g(async t=>{await i({title:`Delete this archive?`,message:`Permanently deletes "${t.label??t.id}" and frees ${B(t.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&d.mutate({destinationId:e,backupId:t.id})},[i,e,d]),[p,m]=S(null),_=g(async t=>{m(t.id);try{let n=localStorage.getItem(`camstack_admin_token`),r={};n&&(r.Authorization=`Bearer ${n}`);let i=await fetch(q(e,t.id),{headers:r});if(!i.ok)throw Error(`download failed: ${i.status} ${i.statusText}`);let a=await i.blob(),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`${t.label??t.id}.tar.gz`,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}finally{m(null)}},[e]),b=y(()=>[...u].toSorted((e,t)=>t.createdAt-e.createdAt),[u]);return c?C(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):l?C(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):b.length===0?C(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):C(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:v(`table`,{className:`w-full text-xs min-w-[640px]`,children:[C(`thead`,{children:v(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[C(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),C(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),C(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),C(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),C(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),C(`tbody`,{children:b.map(r=>v(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[C(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:J(r.createdAt)}),C(`td`,{className:`px-3 py-1.5 text-foreground`,children:r.label??C(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),C(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:r.locations.join(`, `)}),C(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:B(r.sizeBytes)}),C(`td`,{className:`px-3 py-1.5`,children:v(`div`,{className:`flex items-center justify-end gap-1`,children:[v(`button`,{onClick:()=>{_(r)},disabled:p===r.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[p===r.id?C(R,{className:`h-3 w-3 animate-spin`}):C(E,{className:`h-3 w-3`}),`Download`]}),t&&n&&v(`button`,{onClick:()=>n({destinationId:e,archiveId:r.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[C(M,{className:`h-3 w-3`}),`Restore`]}),C(`button`,{onClick:()=>{f(r)},disabled:d.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:d.isPending?C(R,{className:`h-3 w-3 animate-spin`}):C(L,{className:`h-3 w-3`})})]})})]},r.id))})]})})}function q(e,t){return`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function J(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}_();var Y=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function X(e){let t=e.trim();for(let e of Y)if(e.cron===t)return e.id;return`custom`}function Z({value:e,onChange:t,previewCount:n=5,disabled:r=!1}){let a=X(e),[o,s]=S(a===`custom`);w(()=>{a!==`custom`&&s(!1)},[a]);let c=ae(e,250),l=i({cron:c,count:n},{enabled:c.trim().length>0}),u=l.data??null,d=e=>{s(!1),t(e.cron)},f=o||a===`custom`;return v(`div`,{className:`space-y-3`,children:[v(`div`,{className:`space-y-1`,children:[C(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:[Y.map(e=>C(`button`,{type:`button`,onClick:()=>d(e),disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!o&&a===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),C(`button`,{type:`button`,onClick:()=>{s(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:r,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(f?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),f&&v(`div`,{className:`space-y-1`,children:[C(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),C(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:r,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,C(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),C(re,{cron:c,preview:u,loading:l.isFetching})]})}function re({cron:e,preview:t,loading:n}){return n&&t===null?v(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[C(R,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?C(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):v(`div`,{className:`space-y-1`,children:[C(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),C(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>v(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[C(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),C(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:ie(e)})]},`${e}-${t}`))})]}):C(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function ie(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function ae(e,t){let[n,r]=S(e),i=y(()=>e,[e]);return w(()=>{let e=setTimeout(()=>r(i),t);return()=>clearTimeout(e)},[i,t]),n}_();var oe=[[`backup`,`listDestinations`]];function se({onCreateAt:t,onOpenRestoreWizard:n}){let{data:r,isLoading:i,isError:a}=e(),o=r??[],[s,c]=S(null),l=e=>{c(t=>t===e?null:e)},u=fe();return i?C(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading destinations…`}):a?C(`div`,{className:`text-xs text-danger`,children:`Failed to load destinations`}):o.length===0?C(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:C(`p`,{className:`text-xs text-foreground-subtle`,children:"No `backups`-typed storage locations registered. Add one in Settings → Storage to begin."})}):C(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:v(`table`,{className:`w-full text-xs min-w-[720px]`,children:[C(`thead`,{children:v(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[C(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),C(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Destination`}),C(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),C(`th`,{className:`text-left px-3 py-2 font-medium w-28`,children:`Retention`}),C(`th`,{className:`text-left px-3 py-2 font-medium w-56`,children:`Schedule`}),C(`th`,{className:`text-left px-3 py-2 font-medium w-44`,children:`Last success`}),C(`th`,{className:`text-right px-3 py-2 font-medium w-44`,children:`Actions`})]})}),C(`tbody`,{children:o.map(e=>{let r=u.get(e.id);return C(ce,{row:e,isOpen:s===e.id,onToggle:()=>l(e.id),onCreateAt:t,liveLastSuccessAt:r?.at,liveLastSuccessSizeBytes:r?.sizeBytes,...n?{onOpenRestoreWizard:n}:{}},e.id)})})]})})}function ce({row:e,isOpen:t,onToggle:n,onCreateAt:i,onOpenRestoreWizard:a,liveLastSuccessAt:o,liveLastSuccessSizeBytes:s}){let c=x(),l=r({onSuccess:()=>{c.invalidateQueries({queryKey:oe})}}),[u,d]=S(String(e.retentionCount));w(()=>{d(String(e.retentionCount))},[e.retentionCount]);let[f,p]=S(!1),m=g(t=>{l.mutate({locationId:e.id,enabled:t,retentionCount:e.retentionCount,...e.label===void 0?{}:{label:e.label},...e.cron===void 0?{}:{cron:e.cron}})},[l,e.id,e.retentionCount,e.label,e.cron]),h=g(()=>{let t=Number.parseInt(u,10);if(Number.isNaN(t)||t<1){d(String(e.retentionCount));return}t!==e.retentionCount&&l.mutate({locationId:e.id,enabled:e.enabled,retentionCount:t,...e.label===void 0?{}:{label:e.label},...e.cron===void 0?{}:{cron:e.cron}})},[l,u,e.id,e.enabled,e.retentionCount,e.label,e.cron]),_=g(t=>{l.mutate({locationId:e.id,enabled:e.enabled,retentionCount:e.retentionCount,...e.label===void 0?{}:{label:e.label},cron:t},{onSuccess:()=>{p(!1)}})},[l,e.id,e.enabled,e.retentionCount,e.label]);return v(b,{children:[v(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[C(`td`,{className:`px-2 py-2`,children:C(`button`,{onClick:n,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:t?`Hide archives`:`Show archives`,children:C(t?P:N,{className:`h-3.5 w-3.5`})})}),C(`td`,{className:`px-3 py-2`,children:v(`button`,{onClick:n,className:`text-left hover:underline focus:outline-none`,title:`View archives`,children:[C(`div`,{className:`text-foreground font-medium`,children:e.displayName}),v(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[C(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5`,children:e.kind}),C(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]})}),C(`td`,{className:`px-3 py-2`,children:C(`label`,{className:`inline-flex items-center cursor-pointer`,children:C(`input`,{type:`checkbox`,className:`accent-primary`,checked:e.enabled,disabled:l.isPending,onChange:e=>m(e.target.checked)})})}),C(`td`,{className:`px-3 py-2`,children:C(`input`,{type:`number`,min:1,max:1e3,value:u,disabled:l.isPending,onChange:e=>d(e.target.value),onBlur:h,onKeyDown:t=>{t.key===`Enter`&&t.target.blur(),t.key===`Escape`&&d(String(e.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),C(`td`,{className:`px-3 py-2`,children:C(le,{cron:e.cron,nextRunAt:e.nextRunAt,onEdit:()=>p(!0),disabled:l.isPending})}),C(`td`,{className:`px-3 py-2 text-foreground-subtle`,children:(()=>{let t=pe(o,e.lastSuccessAt),n=t===o?s:e.lastSuccessSizeBytes;return t===void 0?C(`span`,{className:`italic`,children:`Never`}):C(me,{at:t,sizeBytes:n})})()}),C(`td`,{className:`px-3 py-2`,children:C(`div`,{className:`flex items-center justify-end gap-1.5`,children:e.triggerSupported&&v(`button`,{onClick:()=>i(e),className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90`,children:[C(j,{className:`h-3 w-3`}),`Create here`]})})})]}),t&&C(`tr`,{className:`border-t border-border bg-background/30`,children:C(`td`,{colSpan:7,className:`px-4 py-3`,children:C(K,{destinationId:e.id,restoreSupported:e.restoreSupported,...a?{onOpenRestoreWizard:a}:{}})})}),f&&C(de,{destinationName:e.displayName,currentCron:e.cron??``,onSave:_,onClose:()=>p(!1),saving:l.isPending,saveError:l.error instanceof Error?l.error.message:null})]})}function le({cron:e,nextRunAt:t,onEdit:n,disabled:r}){let i=typeof e==`string`&&e.trim().length>0;return v(`button`,{type:`button`,onClick:n,disabled:r,className:`group flex flex-col items-start gap-0.5 text-left rounded px-1.5 py-1 -mx-1.5 hover:bg-primary/5 disabled:opacity-50`,title:`Edit schedule`,children:[v(`div`,{className:`flex items-center gap-1.5`,children:[C(ne,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),C(`span`,{className:i?`font-mono text-foreground`:`italic text-foreground-subtle`,children:i?e:`Manual`})]}),i&&t!==void 0&&v(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[`next `,ue(t)]})]})}function ue(e){let t=e-Date.now();if(t<=0)return`imminent`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function de({destinationName:e,currentCron:t,onSave:n,onClose:r,saving:i,saveError:a}){let[o,s]=S(t);return C(`tr`,{children:C(`td`,{colSpan:7,className:`p-0`,children:C(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:v(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[v(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[v(`div`,{className:`space-y-0.5`,children:[C(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Schedule`}),v(`p`,{className:`text-xs text-foreground-subtle`,children:[`→ `,e]})]}),C(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,title:`Close`,children:C(I,{className:`h-4 w-4`})})]}),v(`div`,{className:`p-4`,children:[C(Z,{value:o,onChange:s,disabled:i}),a!==null&&C(`div`,{className:`mt-3 rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:a})]}),v(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[C(`button`,{onClick:r,disabled:i,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground disabled:opacity-50`,children:`Cancel`}),C(`button`,{onClick:()=>n(o.trim()),disabled:i||o.trim()===t.trim(),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:i?`Saving…`:`Save`})]})]})})})})}function fe(){let{map:e}=f(T.BackupCompleted,e=>e.destinationId);return y(()=>{let t=new Map;for(let[n,r]of e)t.set(n,{at:Date.now(),sizeBytes:r.sizeMB*1024*1024});return t},[e])}function pe(e,t){return e===void 0?t:t===void 0||e>t?e:t}function me({at:e,sizeBytes:t}){let n=he(e);return v(`span`,{title:y(()=>new Date(e).toLocaleString(),[e]),className:`text-foreground tabular-nums`,children:[n,t!==void 0&&v(`span`,{className:`ml-1 text-foreground-subtle`,children:[`· `,B(t)]})]})}function he(e){let[,t]=S(0);return w(()=>{let e=setInterval(()=>t(e=>e+1),3e4);return()=>clearInterval(e)},[]),ge(e)}function ge(e){let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<30)return`${a}d ago`;let o=Math.floor(a/30);return o<12?`${o}mo ago`:`${Math.floor(a/365)}y ago`}_();var _e=[[`backup`,`list`]];function ve({initialDestinationId:t,initialArchiveId:n,onClose:r,onScheduled:i}){let a=x(),[o,c]=S(t&&n?2:1),[u,d]=S(t),[f,p]=S(n),[m,g]=S(new Set),{data:_}=e(),b=_??[],{data:T,isLoading:E}=h({destinationId:u??``},{enabled:!!u}),D=T??[];w(()=>{if(u!==void 0)return;let e=b.filter(e=>e.restoreSupported);e.length===1&&d(e[0].id)},[u,b]);let{data:O}=s({destinationId:u??``,backupId:f??``},{enabled:!!u&&!!f}),k=y(()=>O?.locations??[],[O]);w(()=>{k.length!==0&&g(e=>e.size===0?new Set(k):e)},[k]);let A=l({onSuccess:()=>{a.invalidateQueries({queryKey:_e}),i(),r()}}),j=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},N=!!u&&!!f,P=m.size>0,F=N&&P&&!A.isPending,L=()=>{!u||!f||A.mutate({destinationId:u,backupId:f,locations:[...m]})};return C(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:v(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[v(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[v(`div`,{className:`space-y-0.5`,children:[C(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),v(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,o,` of 3 —`,` `,o===1?`pick source`:o===2?`pick locations`:`confirm`]})]}),C(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:C(I,{className:`h-4 w-4`})})]}),o===1&&C(ye,{destinations:b,destinationId:u,onPickDestination:e=>{d(e),p(void 0),g(new Set)},archives:D,archivesLoading:E,archiveId:f,onPickArchive:p}),o===2&&C(be,{locations:k,picked:m,onToggle:j}),o===3&&C(xe,{destinationName:b.find(e=>e.id===u)?.displayName??u??``,archive:D.find(e=>e.id===f),picked:[...m]}),v(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[C(`div`,{children:o>1&&v(`button`,{onClick:()=>c(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[C(ee,{className:`h-3 w-3`}),`Back`]})}),v(`div`,{className:`flex items-center gap-2`,children:[C(`button`,{onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),o<3?v(`button`,{disabled:o===1&&!N||o===2&&!P,onClick:()=>c(e=>e===1?2:3),className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[`Next`,C(te,{className:`h-3 w-3`})]}):v(`button`,{onClick:L,disabled:!F,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[A.isPending?C(R,{className:`h-3.5 w-3.5 animate-spin`}):C(M,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function ye({destinations:e,destinationId:t,onPickDestination:n,archives:r,archivesLoading:i,archiveId:a,onPickArchive:o}){let s=e.filter(e=>e.restoreSupported);return v(`div`,{className:`p-4 space-y-3`,children:[v(`div`,{className:`space-y-1.5`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),v(`select`,{value:t??``,onChange:e=>n(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[C(`option`,{value:``,disabled:!0,children:`Select destination…`}),s.map(e=>v(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),v(`div`,{className:`space-y-1.5`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&C(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&i&&C(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!i&&r.length===0&&C(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&r.length>0&&C(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:r.map(e=>{let t=a===e.id;return v(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[v(`div`,{className:`flex items-center gap-2`,children:[C(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>o(e.id),className:`accent-primary`}),v(`div`,{children:[C(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),C(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),C(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:B(e.sizeBytes)})]},e.id)})})]})]})}function be({locations:e,picked:t,onToggle:n}){return e.length===0?C(`div`,{className:`p-4`,children:C(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):v(`div`,{className:`p-4 space-y-3`,children:[C(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),v(`div`,{className:`space-y-1.5`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),C(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>v(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[C(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>n(e),className:`accent-primary`}),C(`span`,{className:`font-mono text-foreground`,children:e}),C(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Ce(e)})]},e))})]})]})}function xe({destinationName:e,archive:t,picked:n}){return v(`div`,{className:`p-4 space-y-3 text-xs`,children:[C(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),v(`dl`,{className:`space-y-1.5`,children:[C(Q,{term:`Destination`,value:e}),C(Q,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&C(Q,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${B(t.sizeBytes)}`}),C(Q,{term:`Locations`,value:n.length>0?n.join(`, `):`— (full archive)`})]})]})}function Q({term:e,value:t}){return v(`div`,{className:`flex justify-between gap-3`,children:[C(`dt`,{className:`text-foreground-subtle`,children:e}),C(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Se={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function Ce(e){return Se[e]??``}_();var $=[[`backup`,`list`]],we=[[`backup`,`listLocations`]];function Te(){let e=x(),t=o(),{data:n}=u(),r=d({onSuccess:()=>{e.invalidateQueries({queryKey:$}),e.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),e.invalidateQueries({queryKey:[[`backup`,`listArchives`]]})}}),i=m(),[a,s]=S(null),[c,l]=S(null),[f,p]=S(!1),[h,g]=S(!1),[_,y]=S(!1),b=async()=>{await t({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&i.mutate({confirm:!0})};return v(z,{children:[v(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[v(`button`,{onClick:()=>p(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[C(M,{className:`h-3.5 w-3.5`}),`Restore…`]}),v(`button`,{onClick:()=>y(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[C(j,{className:`h-3.5 w-3.5`}),`Add destination`]})]}),h&&C(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:v(`div`,{className:`flex items-center justify-between gap-3`,children:[v(`div`,{className:`flex items-center gap-2`,children:[C(M,{className:`h-3.5 w-3.5`}),C(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),v(`button`,{onClick:()=>{b()},disabled:i.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[i.isPending?C(R,{className:`h-3.5 w-3.5 animate-spin`}):C(M,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),C(se,{onCreateAt:e=>s(e),onOpenRestoreWizard:e=>l(e)}),a&&C(Ee,{destination:a,locations:n??[],onClose:()=>s(null),onSubmit:(t,n)=>{r.mutate({destinations:[a.id],locations:t,label:n||void 0},{onSuccess:()=>{s(null),e.invalidateQueries({queryKey:we})}})},submitting:r.isPending}),(c||f)&&C(ve,{...c?{initialDestinationId:c.destinationId,initialArchiveId:c.archiveId}:{},onClose:()=>{l(null),p(!1)},onScheduled:()=>g(!0)}),_&&C(A,{initialType:`backups`,onClose:()=>y(!1),onCreated:()=>{y(!1),e.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]})}})]})}function Ee({destination:e,locations:t,onClose:n,onSubmit:r,submitting:i}){let a=t.filter(e=>e.present),[o,s]=S(``),[c,l]=S(()=>new Set(a.map(e=>e.name))),u=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return C(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:n,children:v(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[v(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[v(`div`,{className:`space-y-0.5`,children:[C(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Create Backup`}),v(`p`,{className:`text-xs text-foreground-subtle`,children:[`→ `,e.displayName]})]}),C(`button`,{onClick:n,className:`text-foreground-subtle hover:text-foreground`,children:C(I,{className:`h-4 w-4`})})]}),v(`div`,{className:`p-4 space-y-3`,children:[v(`div`,{className:`space-y-1`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Label (optional)`}),C(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`pre-upgrade`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),v(`div`,{className:`space-y-1.5`,children:[C(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Include`}),v(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:[a.length===0&&C(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle italic`,children:`Nothing to back up.`}),a.map(e=>v(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[v(`div`,{className:`flex items-center gap-2`,children:[C(`input`,{type:`checkbox`,checked:c.has(e.name),onChange:()=>u(e.name),className:`accent-primary`}),C(`span`,{className:`font-mono text-foreground`,children:e.name})]}),v(`div`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[B(e.sizeBytes),` · `,e.fileCount,` files`]})]},e.name))]})]})]}),v(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[C(`button`,{onClick:n,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),v(`button`,{onClick:()=>r(Array.from(c),o.trim()),disabled:i||c.size===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[i?C(R,{className:`h-3.5 w-3.5 animate-spin`}):C(H,{className:`h-3.5 w-3.5`}),i?`Creating…`:`Create`]})]})]})})}function De(){return C(`div`,{className:`flex flex-col p-4`,children:C(V,{tabs:[{id:`storage`,label:`Storage`,icon:D,content:C(U,{})},{id:`backup`,label:`Backup`,icon:H,content:C(Te,{})}]})})}export{De as DataPage};
@@ -1 +0,0 @@
1
- import{$n as e,Aa as t,Ca as n,Ea as r,Gn as i,Hn as a,Jn as o,Kn as s,Oa as c,Qn as l,Sa as u,Ta as d,Un as f,Wn as p,Xn as m,Yn as h,Zn as g,ja as _,qn as v,wa as y,xa as b}from"./src-BZ1dd5LI.js";import{Q as x,S,W as C,b as w,o as T,q as E,x as D}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{t as O}from"./pencil-BlQGw-pI.js";import{t as k}from"./plus-DSiRMRVx.js";import{t as A}from"./sparkles-D1oHkgOm.js";import{t as j}from"./square-check-big-D7lGfpqc.js";import{t as M}from"./square-DWukmPnU.js";import{F as N,M as P,P as F,V as I,i as L,m as R,s as z,x as B}from"./index-CY52lvbZ.js";import{t as V}from"./AdminPage-BwmGKnRf.js";var H=I(`user-check`,[[`path`,{d:`m16 11 2 2 4-4`,key:`9rsbq5`}],[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),U=I(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),W=I(`user-x`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`17`,x2:`22`,y1:`8`,y2:`13`,key:`3nzzx3`}],[`line`,{x1:`22`,x2:`17`,y1:`8`,y2:`13`,key:`1swrse`}]]);x();var G=[[`faceGallery`]];function K({identityId:e}){let t=T(),{data:n,isLoading:r}=v({identityId:e}),i=h();function a(n){i.mutate({identityId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:G})}})}return r?S(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[D(B,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!n||n.length===0?D(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):D(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:n.map(e=>S(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?D(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):D(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:D(U,{className:`h-6 w-6`})}),D(`button`,{type:`button`,onClick:()=>a(e),disabled:i.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:D(L,{className:`h-4 w-4 text-white`})})]},e.id))})}function q({identity:e,expanded:a,onToggle:o}){let s=T(),[l,f]=E(``),[p,h]=E(!1),[g,v]=E(!1),x=m(),C=i();function k(){f(e.name),h(!0)}function A(){h(!1),f(``)}function j(){let t=l.trim();if(!t||t===e.name){A();return}x.mutate({id:e.id,name:t},{onSettled:()=>{s.invalidateQueries({queryKey:G}),A()}})}function M(){C.mutate({id:e.id},{onSettled:()=>{s.invalidateQueries({queryKey:G}),v(!1)}})}return S(`div`,{className:`rounded-md border border-border bg-surface`,children:[S(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[D(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?D(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):D(`div`,{className:`flex h-full w-full items-center justify-center`,children:D(U,{className:`h-4 w-4 text-foreground-subtle`})})}),D(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:p?S(w,{children:[D(c,{value:l,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j(),e.key===`Escape`&&A()},className:`h-6 text-xs`,autoFocus:!0}),D(`button`,{type:`button`,onClick:j,disabled:x.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:D(N,{className:`h-3.5 w-3.5`})}),D(`button`,{type:`button`,onClick:A,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:D(L,{className:`h-3.5 w-3.5`})})]}):D(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),D(t,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!p&&S(`div`,{className:`flex items-center gap-1`,children:[D(`button`,{type:`button`,onClick:k,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:D(O,{className:`h-3.5 w-3.5`})}),D(`button`,{type:`button`,onClick:()=>v(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:D(z,{className:`h-3.5 w-3.5`})})]}),D(`button`,{type:`button`,onClick:o,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":a?`Collapse`:`Expand`,children:D(a?F:P,{className:`h-3.5 w-3.5`})})]}),a&&D(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:D(K,{identityId:e.id})}),D(b,{open:g,onOpenChange:e=>!e&&v(!1),children:S(u,{children:[S(d,{children:[D(r,{children:`Delete person`}),S(n,{children:[`Delete `,D(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),S(y,{children:[D(_,{variant:`secondary`,onClick:()=>v(!1),children:`Cancel`}),S(_,{variant:`danger`,onClick:M,disabled:C.isPending,children:[C.isPending?D(B,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function J(){let e=T(),[t,n]=E(``),r=f();function i(){let i=t.trim();i&&r.mutate({name:i},{onSettled:()=>{e.invalidateQueries({queryKey:G}),n(``)}})}return S(`div`,{className:`flex items-center gap-2 pt-2`,children:[D(c,{placeholder:`New person name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},className:`h-7 text-xs flex-1`}),S(_,{variant:`primary`,size:`sm`,onClick:i,disabled:r.isPending||!t.trim(),children:[r.isPending?D(B,{className:`h-3.5 w-3.5 animate-spin`}):D(k,{className:`h-3.5 w-3.5`}),`Add`]})]})}function Y(){let{data:e,isLoading:t}=s(),[n,r]=E(null);function i(e){r(t=>t===e?null:e)}return t?S(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[D(B,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):S(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&D(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>D(q,{identity:e,expanded:n===e.id,onToggle:()=>i(e.id)},e.id)),D(J,{})]})}x();var X=[[`faceGallery`]];function Z({faceIds:e,identities:t,onDone:i}){let o=T(),s=a(),l=f(),[p,m]=E(``),[h,g]=E(!1),[v,x]=E(null),C=e!==null&&e.length>0,w=e?.length??0;function O(){g(!1),m(``),x(null)}function k(){O(),i()}function A(t){!e||e.length===0||s.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{o.invalidateQueries({queryKey:X}),k()}})}function j(){!e||!p.trim()||l.mutate({name:p.trim()},{onSuccess:e=>{e?.id&&A(e.id)},onError:()=>{o.invalidateQueries({queryKey:X}),k()}})}let M=s.isPending||l.isPending;return D(b,{open:C,onOpenChange:e=>!e&&k(),children:S(u,{children:[S(d,{children:[D(r,{children:w>1?`Assign ${w} faces to person`:`Assign face to person`}),D(n,{children:`Select an existing person or create a new one.`})]}),D(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:t.map(e=>S(`button`,{type:`button`,onClick:()=>x(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${v===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[D(`span`,{className:`font-medium`,children:e.name}),S(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),h?D(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:D(c,{placeholder:`New person name…`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()},autoFocus:!0,className:`flex-1`})}):D(`button`,{type:`button`,onClick:()=>{x(null),g(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),S(y,{children:[D(_,{variant:`secondary`,onClick:k,disabled:M,children:`Cancel`}),h?S(_,{variant:`primary`,onClick:j,disabled:M||!p.trim(),children:[M&&D(B,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):S(_,{variant:`primary`,onClick:()=>v&&A(v),disabled:M||!v,children:[M&&D(B,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,w>1?` ${w}`:``]})]})]})})}function Q({face:e,selected:t,onToggleSelect:n,onAssign:r}){let i=T(),a=l(),o=p(),s=()=>{i.invalidateQueries({queryKey:X})};return S(`div`,{className:`group relative flex flex-col gap-1 rounded-md border bg-surface overflow-hidden ${t?`border-primary ring-1 ring-primary`:`border-border`}`,children:[S(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[e.base64?D(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Face`,className:`h-full w-full object-cover`}):D(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:D(U,{className:`h-8 w-8`})}),D(`button`,{type:`button`,onClick:()=>n(e.faceId),className:`absolute left-1 top-1 rounded bg-black/40 p-0.5 text-white hover:bg-black/60`,"aria-label":t?`Deselect`:`Select`,children:t?D(j,{className:`h-3.5 w-3.5 text-primary`}):D(M,{className:`h-3.5 w-3.5`})}),S(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 bg-black/50 opacity-0 transition-opacity group-hover:opacity-100`,children:[e.assigned?D(`button`,{type:`button`,onClick:()=>a.mutate({faceId:e.faceId},{onSettled:s}),disabled:a.isPending,className:`rounded-full bg-warning/80 p-1.5 text-white hover:bg-warning disabled:opacity-50`,title:`Detach`,children:a.isPending?D(B,{className:`h-3.5 w-3.5 animate-spin`}):D(W,{className:`h-3.5 w-3.5`})}):D(`button`,{type:`button`,onClick:()=>r(e.faceId),className:`rounded-full bg-primary/80 p-1.5 text-white hover:bg-primary`,title:`Assign to person`,children:D(H,{className:`h-3.5 w-3.5`})}),D(`button`,{type:`button`,onClick:()=>o.mutate({faceId:e.faceId},{onSettled:s}),disabled:o.isPending,className:`rounded-full bg-danger/80 p-1.5 text-white hover:bg-danger disabled:opacity-50`,title:`Delete face`,children:o.isPending?D(B,{className:`h-3.5 w-3.5 animate-spin`}):D(z,{className:`h-3.5 w-3.5`})})]})]}),S(`div`,{className:`px-2 pb-2 space-y-0.5`,children:[D(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.deviceId}),e.identityName&&D(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]})]})}var $=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function ee(){let t=T(),[n,r]=E(`all`),[i,c]=E(new Set),[l,u]=E(null),[d,f]=E(!1),{data:m,isLoading:h}=o({limit:100,filter:n}),{data:v=[]}=s(),{data:y,isFetching:b}=g({threshold:.5,minClusterSize:2,limit:20},{enabled:d}),x=a(),w=e(),O=p(),k=m??[],j=C(()=>new Map(k.map(e=>[e.faceId,e])),[k]),M=()=>{t.invalidateQueries({queryKey:X})},N=()=>c(new Set);function P(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function F(e){c(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}let I=[...i],R=x.isPending||w.isPending||O.isPending;function V(){I.length!==0&&w.mutate({faceIds:I},{onSettled:()=>{M(),N()}})}function G(){I.length!==0&&Promise.allSettled(I.map(e=>O.mutateAsync({faceId:e}))).then(()=>{M(),N()})}return S(`div`,{className:`space-y-3`,children:[S(`div`,{className:`flex items-center gap-1`,children:[$.map(e=>D(`button`,{type:`button`,onClick:()=>r(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${n===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value)),S(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`ml-2 flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${d?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[D(A,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!h&&S(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:[k.length,` face`,k.length===1?``:`s`]})]}),i.size>0&&S(`div`,{className:`flex items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[S(`span`,{className:`text-xs font-medium text-foreground`,children:[i.size,` selected`]}),S(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[S(_,{variant:`primary`,onClick:()=>u(I),disabled:R,children:[D(H,{className:`h-3.5 w-3.5`}),` Assign`]}),S(_,{variant:`secondary`,onClick:V,disabled:R,children:[w.isPending?D(B,{className:`h-3.5 w-3.5 animate-spin`}):D(W,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),S(_,{variant:`secondary`,onClick:G,disabled:R,children:[D(z,{className:`h-3.5 w-3.5`}),` Delete`]}),D(_,{variant:`ghost`,onClick:N,disabled:R,children:D(L,{className:`h-3.5 w-3.5`})})]})]}),d&&S(`div`,{className:`rounded-md border border-border bg-surface p-3`,children:[D(`p`,{className:`mb-2 text-xs font-medium text-foreground`,children:`Look-alike groups`}),b?S(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[D(B,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):!y||y.length===0?D(`p`,{className:`text-xs text-foreground-subtle`,children:`No look-alike groups found among unassigned faces.`}):D(`div`,{className:`space-y-2`,children:y.map(e=>S(`div`,{className:`flex items-center gap-2 rounded-md bg-surface-hover/50 p-2`,children:[D(`div`,{className:`flex -space-x-1.5`,children:e.faceIds.slice(0,6).map(e=>{let t=j.get(e);return D(`div`,{className:`h-8 w-8 overflow-hidden rounded border border-border bg-surface`,children:t?.base64?D(`img`,{src:`data:image/jpeg;base64,${t.base64}`,alt:``,className:`h-full w-full object-cover`}):D(U,{className:`h-full w-full p-1.5 text-foreground-subtle`})},e)})}),S(`span`,{className:`text-xs text-foreground-subtle`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]}),S(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[D(_,{variant:`secondary`,onClick:()=>F(e.faceIds),children:`Select group`}),S(_,{variant:`primary`,onClick:()=>u(e.faceIds),children:[D(H,{className:`h-3.5 w-3.5`}),` Assign all`]})]})]},e.representativeFaceId))})]}),h&&S(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[D(B,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!h&&k.length===0&&D(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:`No faces found for this filter.`}),!h&&k.length>0&&D(`div`,{className:`grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8 lg:grid-cols-10`,children:k.map(e=>D(Q,{face:e,selected:i.has(e.faceId),onToggleSelect:P,onAssign:e=>u([e])},e.faceId))}),D(Z,{faceIds:l,identities:v,onDone:()=>{u(null),N()}})]})}function te(){return D(V,{icon:R,title:`Detection Intelligence`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:S(`section`,{className:`space-y-3`,children:[S(`div`,{children:[D(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),D(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),D(Y,{})]}),S(`div`,{className:`pt-4 border-t border-border`,children:[D(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),D(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),D(ee,{})]})]})})}export{te as DetectionIntelligencePage};
@@ -1,2 +0,0 @@
1
- import{$r as e,Ai as t,B as n,Bn as r,Br as i,Cn as a,D as o,Dn as s,E as c,En as l,Fn as u,Fr as d,G as f,Ia as p,In as m,It as h,J as g,K as _,La as v,Ln as y,M as b,Mn as x,N as S,Nn as C,O as w,On as T,Or as E,Pn as D,Q as O,Qi as k,R as A,Rn as j,Si as ee,Sn as M,T as te,Tn as ne,U as re,Vn as N,W as P,X as F,Xi as ie,Y as ae,Yi as oe,a as se,bt as ce,ca as I,da as le,dn as ue,dr as de,et as fe,f as pe,fa as L,fr as me,g as he,ga as ge,hi as _e,i as ve,ii as ye,in as be,ir as xe,j as Se,ji as Ce,jn as we,l as Te,m as Ee,n as De,nt as Oe,o as ke,oi as R,p as Ae,pa as je,pn as Me,q as Ne,r as Pe,rn as Fe,sa as Ie,tt as Le,u as Re,ua as ze,ur as Be,vn as Ve,wi as He,wn as Ue,y as We,yn as Ge,z as Ke,zn as qe}from"./src-BZ1dd5LI.js";import{I as z,K as B,Q as V,S as H,W as U,a as Je,b as W,o as G,q as K,t as Ye,x as q,z as J}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{A as Xe,D as Ze,E as Qe,I as $e,N as et,O as tt,S as nt,T as rt,b as it,g as at,k as ot,w as Y,y as st}from"./src-BXL7z3gT.js";import{c as ct,k as lt,p as X,r as ut,t as dt,u as ft}from"./player-overlays-CpsGl45o.js";import{t as pt}from"./CapabilityBadges-D4uPGt_S.js";import{n as mt,t as ht}from"./rotate-ccw-CaH5zDeG.js";import{t as gt}from"./ProviderIcon-DwFpv01K.js";import{i as _t,n as vt,t as yt}from"./useDevice-BwzYPnLK.js";import{t as bt}from"./pencil-BlQGw-pI.js";import{t as xt}from"./plus-DSiRMRVx.js";import{t as St}from"./refresh-cw-CMRlnF-M.js";import{t as Ct}from"./rotate-cw-CCcZjC0U.js";import{t as wt}from"./server-CaW_paWO.js";import{t as Tt}from"./wifi-BeF9XXWL.js";import{B as Et,F as Dt,G as Ot,I as kt,O as At,R as jt,U as Mt,V as Nt,W as Pt,_ as Ft,a as It,c as Lt,i as Rt,k as zt,p as Bt,r as Vt,s as Ht,t as Ut,v as Wt,x as Gt}from"./index-CY52lvbZ.js";import{t as Kt}from"./StatusBadge-Dcr2bw58.js";import{t as qt}from"./useEventInvalidation-CETyyXeZ.js";import{n as Jt,r as Yt,t as Xt}from"./SchemaTabBar-DhsmEGyn.js";import{t as Zt}from"./FormBuilder-CJrUV3p4.js";var Qt=Nt(`circle-help`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),$t=Nt(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),en=Nt(`link-2-off`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7`,key:`10o201`}],[`path`,{d:`M15 7h2a5 5 0 0 1 4 8`,key:`1d3206`}],[`line`,{x1:`8`,x2:`12`,y1:`12`,y2:`12`,key:`rvw6j4`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),tn=Nt(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),nn=Nt(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),rn=Nt(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),an=Nt(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]);V();function on({parentDeviceId:e}){let{t}=Ut(),n=Mt(),r=X(),{data:i,isLoading:a,isError:o}=vt(e),{data:s}=M({deviceId:e},{enabled:Number.isFinite(e)});if(a)return q(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:q(`p`,{className:`text-[10px] text-foreground-subtle`,children:t(`common.loading`,{defaultValue:`Loading…`})})});if(o)return q(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:q(`p`,{className:`text-[10px] text-warning`,children:t(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let c=(i??[]).filter(e=>e.display?.hidden!==!0);if(c.length===0)return null;let l=f(s?.stableId??``,c,s?.childLayout),u=l.ungrouped,d=e=>n(`/devices/${String(e)}`),p=s?.name??``,m=(e,t)=>q(re,{trpc:r.trpcClient,device:{...t,name:ae(t,p)},variant:`minimal`,onNavigate:d},e),h=u.some(e=>!!e.role),g=u.some(e=>!e.role),_=h&&!g?t(`device.accessories`,{defaultValue:`Accessories`}):!h&&g?t(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):t(`device.children`,{defaultValue:`Children`}),v=u.length>0?H(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[q(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:_}),q(`div`,{className:`space-y-1`,children:u.map(e=>m(e.id,e))})]}):null,y=l.disabledSection===void 0?null:q(P,{title:t(`device.disabledSection`,{defaultValue:`Disabled`}),count:l.disabledSection.children.length,defaultOpen:!1,children:q(`div`,{className:`opacity-60 space-y-1`,children:l.disabledSection.children.map(e=>m(e.id,e))})},l.disabledSection.title);return l.sections.length===0?y===null?v:H(`div`,{className:`space-y-2`,children:[v,y]}):H(`div`,{className:`space-y-2`,children:[l.sections.map(e=>q(P,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>m(e.id,e))},e.title)),v,y]})}function sn({deviceName:e,deviceType:t,provider:n,isOnline:r,features:i}){return H(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center`,children:[q(gt,{type:n,size:`lg`}),H(`div`,{children:[q(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),q(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),H(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[q(Kt,{status:r?`online`:`offline`}),i.length>0&&q(pt,{capabilities:i})]}),q(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:`No live view for this device type. Use the Config tab or the shortcut row to interact.`})]})}function cn({deviceId:e}){let t=G(),n=Fe({deviceId:e},{refetchInterval:1e4,retry:!1}),r=be({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),i=U(()=>ln(n.data??[]),[n.data]);return H(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[H(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[q(un,{label:`Discovered`,value:i.total,icon:q(Ft,{className:`h-3.5 w-3.5`})}),q(un,{label:`Adopted`,value:i.adopted,accent:`success`}),q(un,{label:`Available`,value:i.available,accent:i.available>0?`primary`:void 0}),H(`button`,{type:`button`,onClick:()=>{r.mutateAsync({deviceId:e}).catch(()=>{})},disabled:r.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0`,children:[r.isPending?q(Gt,{className:`h-3.5 w-3.5 animate-spin`}):q(St,{className:`h-3.5 w-3.5`}),q(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),H(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2`,children:[q(dn,{icon:q(Tt,{className:`h-3 w-3 text-emerald-500`}),label:`${i.online} online`}),q(dn,{icon:q(Wt,{className:`h-3 w-3 text-amber-500`}),label:`${i.sleeping} sleeping`}),q(dn,{icon:q(It,{className:`h-3 w-3 text-destructive`}),label:`${i.offline} offline`}),i.unknown>0?q(dn,{icon:q(Qt,{className:`h-3 w-3 text-foreground-subtle`}),label:`${i.unknown} unknown`}):null]})]})}function ln(e){let t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(let n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function un({label:e,value:t,icon:n,accent:r}){return H(`div`,{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${r===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:r===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[H(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[n,q(`span`,{className:`truncate`,children:e})]}),q(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:t})]})}function dn({icon:e,label:t}){return H(`span`,{className:`inline-flex items-center gap-1`,children:[e,q(`span`,{children:t})]})}function fn({deviceId:e,features:t}){return q(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:q(ie,{trpc:X().trpcClient,deviceId:e,features:t})})}function pn({deviceId:e,features:t}){return q(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:q(oe,{trpc:X().trpcClient,deviceId:e,features:t})})}function Z({deviceId:e,deviceType:t,features:r}){let i=X(),a=Le(t)?.HeroCard??oe,o=ft(ct(i.trpcClient,e)?.state.deviceStatus),s=o!==void 0&&o.online===!1,c=s?o.lastChangedAt:null;return H(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[s?q(`div`,{className:`flex justify-center`,children:q(n,{lastChangedAt:c})}):null,q(a,{trpc:i.trpcClient,deviceId:e,features:r})]})}function mn({deviceId:e}){let t=X(),{data:n,isLoading:r}=yt(e),{data:i,isLoading:a}=vt(e),o=r||a,s=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,features:e.features,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),c=typeof n?.linkDeviceId==`number`?n.linkDeviceId:null,l=typeof n?.primaryChildEntityId==`string`?n.primaryChildEntityId:null;return o?q(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):q(`div`,{className:`flex h-full w-full flex-col`,children:q(Ke,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l})})}var hn={[Y.Switch]:Z,[Y.Siren]:Z,[Y.Light]:Z,[Y.Sensor]:Z,[Y.Button]:Z,[Y.Hub]:cn,[Y.Cover]:fn,[Y.Valve]:Z,[Y.Humidifier]:Z,[Y.WaterHeater]:Z,[Y.Container]:mn,[Y.Lock]:Z,[Y.Fan]:Z,[Y.Thermostat]:Z,[Y.Climate]:Z,[Y.MediaPlayer]:Z,[Y.Control]:Z,[Y.AlarmPanel]:pn,[Y.EventEmitter]:pn,[Y.Notifier]:pn,[Y.Script]:pn,[Y.Automation]:pn,[Y.Presence]:Z,[Y.Update]:Z,[Y.Vacuum]:Z,[Y.LawnMower]:Z,[Y.Weather]:Z,[Y.Image]:Z,[Y.PetFeeder]:Z};function gn(e){return q(hn[e.deviceType]??sn,{...e})}function _n(e){return se(X().trpcClient,e)}V();function vn(e){let[t,n]=K(`idle`),[r,i]=K(null),a=B(null),o=B(null),s=B(null),c=B(!0),l=de(),u=Be(),d=me(),f=z(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}s.current=null},[]),p=z(async()=>{if(t===`idle`)return;n(`stopping`);let r=s.current;if(r&&e!==null)try{await Promise.race([d.mutateAsync({deviceId:e,sessionId:r}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}f(),c.current&&(n(`idle`),i(null))},[t,e,d,f]),m=z(async()=>{if(e===null||t!==`idle`&&t!==`error`)return;i(null);let r=null,f=null,m=null;try{n(`requesting-mic`),r=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),o.current=r,n(`starting`);let t=await l.mutateAsync({deviceId:e});m=t.sessionId,s.current=m,n(`connecting`),f=new RTCPeerConnection,a.current=f,f.oniceconnectionstatechange=()=>{if(!c.current)return;let e=f.iceConnectionState;e===`connected`||e===`completed`?n(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&c.current&&(i(e===`failed`?`WebRTC connection failed`:null),p())};for(let e of r.getAudioTracks())f.addTrack(e,r);await f.setRemoteDescription({type:`offer`,sdp:t.sdpOffer});let d=await f.createAnswer();await f.setLocalDescription(d);let h=f.localDescription?.sdp??d.sdp??``;await u.mutateAsync({deviceId:e,sessionId:m,sdpAnswer:h})}catch(t){let l=t instanceof Error?t.message:String(t);if(console.warn(`[intercom] start failed`,t),f)try{f.close()}catch{}if(r)for(let e of r.getTracks())try{e.stop()}catch{}if(a.current=null,o.current=null,m!==null)try{await d.mutateAsync({deviceId:e,sessionId:m})}catch{}s.current=null,c.current&&(i(l),n(`error`))}},[e,t,l,u,d,p]);return J(()=>(c.current=!0,()=>{c.current=!1;let t=s.current;if(t!==null&&e!==null&&d.mutate({deviceId:e,sessionId:t}),a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}s.current=null}),[e]),{state:t,error:r,start:m,stop:p,isTalking:t===`talking`}}V();var yn=0;function Q(){return++yn}function bn(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function xn(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function Sn(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.percentage < 20).length`,` sm.mapState('battery', s => s.percentage)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function Cn(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.percentage < 20)`,` sm.mapState('battery', s => s.percentage)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.percentage`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ percentage: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function wn({scope:e,greeting:t,className:n}){let r=X(),[i,a]=K(()=>{let n=[];return t&&n.push({id:Q(),kind:`info`,text:t}),n.push({id:Q(),kind:`info`,text:`scope: ${bn(e)} — type help or context for available commands`}),n}),[o,s]=K(``),[c,l]=K([]),[u,d]=K(-1),f=B(null),p=B(null);J(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[i]);let m=z(()=>{f.current?.focus()},[]),h=Ye({mutationFn:t=>r.trpcClient.repl.execute.mutate({code:t,scope:e}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;a(e=>[...e,{id:Q(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);a(e=>[...e,{id:Q(),kind:`error`,text:t}])}});function g(t){let n=t.trim();if(n){if(n===`clear`){a([{id:Q(),kind:`info`,text:`scope: ${bn(e)}`}]),s(``);return}if(n===`help`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...xn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`context`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...Cn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`examples`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...Sn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}l(e=>[...e,n]),d(-1),a(e=>[...e,{id:Q(),kind:`input`,text:`> ${n}`}]),s(``),h.mutate(n)}}function _(t){if(t.key===`Enter`){t.preventDefault(),g(o);return}if(t.key===`ArrowUp`){if(t.preventDefault(),c.length===0)return;let e=u===-1?c.length-1:Math.max(0,u-1);d(e),s(c[e]??``);return}if(t.key===`ArrowDown`){if(t.preventDefault(),u===-1)return;let e=u+1;e>=c.length?(d(-1),s(``)):(d(e),s(c[e]??``));return}t.ctrlKey&&t.key===`l`&&(t.preventDefault(),a([{id:Q(),kind:`info`,text:`scope: ${bn(e)}`}]))}let v={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return H(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??``}`,onClick:m,children:[H(`div`,{ref:p,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[i.map(e=>q(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${v[e.kind]}`,children:e.text},e.id)),h.isPending&&q(`span`,{className:`text-zinc-500 animate-pulse`,children:`…thinking`})]}),H(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[q(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:`>`}),q(`input`,{ref:f,value:o,onChange:e=>s(e.target.value),onKeyDown:_,disabled:h.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}function Tn({deviceId:e,intercomAvailable:t=!1}){let n=X(),r=typeof window<`u`?window.location.origin:``,i=Number.isFinite(e),a=_n(i?e:null),{streams:o,pipelineMetrics:s,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h}=ve(n.trpcClient,i?e:null),g=Ne(n.trpcClient,i?e:null),_=vn(i&&t?e:null),v=_.state===`requesting-mic`||_.state===`starting`||_.state===`connecting`||_.state===`stopping`,y=_.isTalking||v,b=()=>{_.state===`idle`||_.state===`error`?_.start():_.state!==`stopping`&&_.stop()},x=ut(),S=w(),C=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,T=x.length>0?q(W,{children:x.map(e=>q(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return q(We,{serverUrl:r,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h,...S.request?{playbackUrl:S.request.url,playbackAuthToken:C,...S.request.label?{playbackLabel:S.request.label}:{},onExitPlayback:()=>S.clear()}:{},streams:o,pipelineMetrics:s,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:g.src,...g.src?{posterUrl:g.src}:{},snapshotLoading:g.loading,onRefreshSnapshot:g.refresh,intercomAvailable:t,intercomShown:y,onIntercomToggle:b,extraOverlay:T,chromeless:!0,className:`h-full`})}function En({deviceId:e,containerDeviceId:t}){return Number.isFinite(e)?q(`div`,{className:`flex flex-col h-full`,children:q(he,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function Dn({deviceId:e}){if(!Number.isFinite(e))return H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]});let t=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
2
- `);return q(wn,{scope:{type:`device`,deviceId:e},greeting:t,className:`h-full border-0 rounded-none`})}function On({deviceId:e}){return Number.isFinite(e)?q(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:q(Ee,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function kn({deviceId:e}){return Number.isFinite(e)?q(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:q(pe,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function An({deviceId:e}){let t=G(),n=Number.isFinite(e),{data:r}=M({deviceId:e},{enabled:n}),i=typeof r?.type==`string`?r.type:`camera`;qt([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:a,isLoading:o,isError:c,error:l}=Ge({deviceId:e},{enabled:n}),{data:u}=s({deviceType:i},{enabled:!!i}),d=qe({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(o)return q(`div`,{className:`p-4`,children:q(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(c)return H(`div`,{className:`p-4 text-xs text-red-400`,children:[`Failed to load bindings: `,l instanceof Error?l.message:String(l)]});let f=new Map,p={};for(let e of u??[])p[e.capName]=e.wrappers;for(let e of a?.entries??[])f.set(e.capName,{...e,wrappers:p[e.capName]??[]});for(let e of u??[])f.has(e.capName)||f.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let m=[...f.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(m.length===0)return H(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[q(mt,{className:`h-8 w-8 opacity-40`}),q(`p`,{className:`text-xs`,children:`No capability providers applicable to this device yet.`}),q(`p`,{className:`text-[10px] opacity-60`,children:`Native providers show up here as soon as the owning addon registers them.`})]});let h=m.filter(e=>e.kind!==`unbound`).length;return H(`div`,{className:`flex flex-col gap-3 p-1`,children:[H(`div`,{className:`text-[11px] text-foreground-subtle`,children:[q(`span`,{className:`font-medium text-foreground`,children:h}),` of `,m.length,` capabilit`,m.length===1?`y`:`ies`,` bound — rows marked `,q(`em`,{children:`unbound`}),` have a wrapper available you can activate.`]}),q(L,{columns:[{key:`capability`,header:`Capability`,render:e=>q(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:`Kind`,render:e=>q(jn,{kind:e.kind})},{key:`provider`,header:`Active Provider`,render:e=>q(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||q(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:`Node`,render:e=>e.providerNodeId?q(Mn,{nodeId:e.providerNodeId}):q(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:`Native`,render:e=>q(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||q(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:`Wrapper`,render:t=>{let n=t.kind===`wrapped`?t.providerAddonId:null;return q(Nn,{wrappers:t.wrappers,activeWrapperId:n,disabled:d.isPending,onPick:r=>{let i=n===r;d.mutate({deviceId:e,capName:t.capName,wrapperAddonId:r,active:!i})}})}}],rows:m,rowKey:e=>e.capName,minWidthPx:720})]})}function jn({kind:e}){return e===`native`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[q(wt,{className:`h-3 w-3`}),`native`]}):e===`wrapped`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[q($t,{className:`h-3 w-3`}),`wrapped`]}):e===`linked`?H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-warning/30 text-warning bg-warning/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[q(tn,{className:`h-3 w-3`}),`linked`]}):H(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium`,children:[q(_t,{className:`h-3 w-3`}),`unbound`]})}function Mn({nodeId:e}){return q(`span`,{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e===`hub`?`text-foreground-subtle`:`text-foreground`}`,children:e})}function Nn({wrappers:e,activeWrapperId:t,disabled:n,onPick:r}){return e.length===0?q(`span`,{className:`text-[10px] opacity-40`,children:`none available`}):q(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>{let i=e===t;return H(`button`,{disabled:n,onClick:()=>r(e),title:i?`Click to deactivate (revert to native)`:`Activate wrapper ${e}`,className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${i?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[q(i?Dt:ht,{className:`h-3 w-3`}),e]},e)})})}V();function Pn({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:o,disabled:s,activeSubTab:c,onSubTabChange:l,flattenTabs:u=!1}){let d=e.tabs??[],f=U(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),p=new Set(d.map(e=>e.id)),m=[...d,...[...f.keys()].filter(e=>!p.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],h=m[0]?.id??`general`,[g,_]=K(h),v=l!==void 0,y=new Set(m.map(e=>e.id)),b=v?c&&y.has(c)?c:h:y.has(g)?g:h,x=e=>{v?l(e):_(e)},S=f.get(b)??[],C={sections:S.length<=1?S.length===1?[{...S[0],title:``}]:S:S.every(e=>!e.title)?[{...S[0],title:``,fields:S.flatMap(e=>e.fields)}]:S},w=q(Jt,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>o(n),saving:s});if(u||m.length<=1)return H(`div`,{className:`flex flex-col gap-3`,children:[q(Zt,{schema:e,values:t,onChange:r,onAction:i,disabled:s}),w]});let T=new Map,E=new Map;for(let[e,t]of f){T.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&E.set(e,a)}return H(`div`,{className:`flex flex-col gap-3`,children:[q(Xt,{tabs:m.map(e=>({id:e.id,label:e.label})),activeId:b,onChange:x,countByTab:T,pendingByTab:E}),q(Zt,{schema:C,values:t,onChange:r,onAction:i,disabled:s}),w]})}var Fn=`device-export`,In=`export`,Ln=`Export`;function Rn(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(Rn):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(Rn)):e.writerCapName===Fn}function zn(e){return e.fields.some(Rn)}V();function Bn(e,t){return t&&t===`admin`?e:!0}function Vn(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?zn(e)&&zn(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function Hn(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`}function Un(e){return e.key}function Wn(e){if(!Hn(e))return e.value}function Gn(e){return Hn(e)?null:e}function Kn(e,t){for(let n of e)if(t(n),n.type===`group`)Kn(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)Kn(e.fields,t)}function qn(e){if(!e)return{};let t={};for(let n of e.sections)Kn(n.fields,e=>{let n=Un(e);n!==null&&(t[n]=Wn(e))});return t}function Jn(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(Kn(r.fields,e=>{if(n!==null||Un(e)!==t)return;let r=Gn(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function Yn(e){return{...e,fields:e.fields.map(Xn)}}function Xn(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function Zn(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=Gn(e);return n?Bn(t,n.minRole)?e:Xn(e):e})}))}}function Qn({deviceId:e,sectionFilter:n,activeSubTab:i,onSubTabChange:o,flattenSubTabs:s}){let c=G(),{user:l}=Vt(),u=l?.isAdmin===!0,d=B(!1),{data:f,isLoading:p}=a({deviceId:e},{refetchInterval:()=>d.current?!1:2500,enabled:Number.isFinite(e)}),{data:m}=M({deviceId:e},{enabled:Number.isFinite(e)}),h=f?.settings??null,g=f?.live??null,_=U(()=>{if(!h&&!g)return null;let e=h?.sections??[],t=(g?.sections??[]).map(Yn),r=[...e,...t],i=n?r.filter(n):r.filter(e=>e.location!==`top-tab`&&!zn(e));if(i.length===0)return null;let a=new Set;for(let e of i)a.add(e.tab??`general`);let o=[...h?.tabs??[],...(g?.tabs??[]).filter(e=>!(h?.tabs??[]).some(t=>t.id===e.id))].filter(e=>a.has(e.id));return o.length>0?{tabs:o,sections:i}:{sections:i}},[h,g,n]),v=U(()=>Vn(_),[_]),y=U(()=>Zn(v,u),[v,u]),b=U(()=>qn(y),[y]),S=Ce(),C=t(),w=r(),T=x(),E=N({onSuccess:()=>{c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),D={isPending:E.isPending,mutate:t=>{E.mutate({deviceId:e,changes:[...t]})}},O=Yt({schema:y,serverValues:b,onImmediateSave:z(e=>{let t=Object.entries(e).map(([e,t])=>{let n=Jn(y,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&D.mutate(t)},[y,D]),onDeferredSave:z(e=>{let t=Object.entries(e).map(([e,t])=>{let n=Jn(y,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&D.mutate(t)},[y,D])}),{values:k,pendingKeys:A,handleChange:j,handleSave:ee,handleDiscard:te}=O;if(d.current=O.editingPaused,p)return H(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[q(Gt,{className:`h-4 w-4 animate-spin mr-2`}),q(`span`,{className:`text-xs`,children:`Loading device aggregate…`})]});if(!y||y.sections.length===0)return q(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:`No aggregate contributions for this device.`});async function ne(t,n,r){if(t===`regenerate-rtsp-token`){let t=[`rtspUrl:`,`regenerateToken:`].find(e=>n.startsWith(e));if(!t)throw Error(`regenerate-rtsp-token: unrecognised key "${n}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let r=n.slice(t.length);if(!r)throw Error(`regenerate-rtsp-token: key "${n}" has no streamId after prefix`);let i=et(e,r);await S.mutateAsync({brokerId:i}),c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(t===`test-probe`){if(!m)return{status:`error`,error:`Device metadata not loaded yet`};try{return await w.mutateAsync({addonId:m.addonId,type:m.type,key:n,value:r})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(t===`refresh-probe`){if(!n.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${n}" (expected "probedInfo:<streamId>")`);let t=n.slice(11);if(!t)throw Error(`refresh-probe: key "${n}" has no streamId after prefix`);let r=et(e,t),i=await C.mutateAsync({brokerId:r});return c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(t===`device-custom-action`){let t=await T.mutateAsync({deviceId:e,action:n,input:r});return c.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),t}throw Error(`[device-aggregate] unknown action "${t}"`)}return q(Pn,{schema:y,values:k,pendingKeys:A,onChange:j,onAction:ne,onSave:ee,onDiscard:te,disabled:D.isPending,activeSubTab:i,onSubTabChange:o,flattenTabs:s})}function $n({deviceId:e,activeSubTab:t,onSubTabChange:n}){return q(`div`,{className:`flex flex-col gap-3`,children:q(Qn,{deviceId:e,activeSubTab:t,onSubTabChange:n})})}V();function er(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function tr(e){return e?e.enabled!==void 0||e.modelId!==void 0||e.settings!==void 0:!1}function nr(e,t){return t?{enabled:t.enabled??e.enabled,modelId:t.modelId??e.modelId,settings:t.settings??e.settings}:e}function rr({agents:e,currentAgent:t,onPick:n,hint:r}){let[i,a]=K(!1),o=e.filter(e=>e!==t);return o.length===0?null:H(`div`,{className:`relative`,children:[q(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:()=>a(e=>!e),children:`Mirror from ▾`}),r&&q(`div`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r}),i&&q(`div`,{className:`absolute top-full left-0 mt-1 min-w-[140px] bg-surface border border-border rounded shadow-lg z-10`,children:o.map(e=>q(`button`,{type:`button`,className:`w-full text-left px-3 py-1.5 text-xs hover:bg-muted`,onClick:()=>{a(!1),n(e)},children:e},e))})]})}function ir({deviceId:t,refreshToken:n}){let r=G(),a=X().trpcClient,[o,s]=K(null),[c,l]=K(null),[u,f]=K(null),p=e({deviceId:t},{refetchOnMount:`always`}),m=R(void 0,{refetchOnMount:`always`});qt([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let h=d(void 0,{refetchOnMount:`always`}),g=U(()=>{let e=new Set;for(let t of h.data??[])t.isOnline&&e.add(t.id);return e},[h.data]),_=U(()=>(m.data??[]).filter(e=>g.has(e.nodeId)).map(e=>e.nodeId),[m.data,g]),y=_[0]??``,b=i({nodeId:y},{enabled:y!==``,refetchOnMount:`always`}),x=Je({enabled:_.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`device-step-formats`,_.join(`,`),n],queryFn:async()=>{let e={};for(let t of _)try{e[t]=(await a.pipelineExecutor.getSchema.query({nodeId:t})).selectedEngine.format}catch{e[t]=`coreml`}return e}}),S=_e({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]})}}),C=U(()=>b.data?ze(b.data):[],[b.data]),w=U(()=>{let e=m.data??[];return(g.size===0?[]:e.filter(e=>g.has(e.nodeId))).map(e=>({agentNodeId:e.nodeId,engineLabel:x.data?.[e.nodeId]??`(engine unknown)`}))},[m.data,x.data,g]),T=(e,t)=>(m.data?.find(t=>t.nodeId===e))?.settings.addonDefaults[t]??null,E=(e,t,n)=>e?.stepOverridesByAgent?.[t]?.[n]??null,D=(e,t)=>{let n=x.data?.[t];if(!er(b.data??null,e)?.models.some(e=>n!==void 0&&!!e.formats[n]))return{kind:`na`};let r=T(t,e);if(!r)return{kind:`na`};let i=E(p.data??null,t,e),a=tr(i),o=nr(r,i);return o.enabled?{kind:`enabled`,modelId:o.modelId??`Auto`,overridden:a}:{kind:`disabled`,overridden:a}},O=o&&b.data?er(b.data,o.addonId):null,k=o?T(o.agentNodeId,o.addonId):null,A=o?x.data?.[o.agentNodeId]??`coreml`:`coreml`,j=o?tr(E(p.data??null,o.agentNodeId,o.addonId)):!1,ee=()=>{s(null),l(null),f(null)},M=(e,t)=>{s({addonId:e,agentNodeId:t}),l(E(p.data??null,t,e)),f(null)},te=e=>{if(!o||!b.data||!m.data)return;let t=m.data.find(t=>t.nodeId===e),n=m.data.find(e=>e.nodeId===o.agentNodeId);if(!t||!n)return;let[r]=v({source:{nodeId:t.nodeId,engine:{format:A},defaults:t.settings.addonDefaults},target:{nodeId:n.nodeId,engine:{format:A},defaults:n.settings.addonDefaults},catalog:b.data,addonIds:[o.addonId]});if(!r){f(`no mirror result`);return}if(r.outcome===`skip`){f(`skipped: ${r.reason??`no candidate`}`);return}l(r.patch),f(`${r.outcome} from ${e}`)},ne=()=>{o&&S.mutate({deviceId:t,agentNodeId:o.agentNodeId,addonId:o.addonId,patch:c},{onSuccess:ee})},re=()=>{o&&S.mutate({deviceId:t,agentNodeId:o.agentNodeId,addonId:o.addonId,patch:null},{onSuccess:ee})};if(m.isLoading||y!==``&&b.isLoading)return q(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(w.length===0)return q(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`No online agents.`});if(!b.data)return q(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let N=o!==null&&O!==null&&k!==null,P=(m.data??[]).map(e=>e.nodeId);return H(`div`,{className:`relative h-full w-full space-y-3`,children:[H(`div`,{className:`flex items-center gap-3 text-[10px] text-foreground-subtle`,children:[H(`span`,{className:`inline-flex items-center gap-1`,children:[q(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`}),` inherited`]}),H(`span`,{className:`inline-flex items-center gap-1`,children:[q(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-500`}),` override`]}),q(`span`,{children:`Click a cell to override this camera's step for that agent.`})]}),q(`div`,{className:N?`pr-[360px]`:``,children:C.length>0?q(Ie,{tree:C,agents:w,getCellState:D,onCellClick:M,selectedCell:o}):q(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),q(le,{open:N,onClose:ee,title:O?.name??``,subtitle:o?`${o.agentNodeId} · ${A}`:``,footer:H(W,{children:[q(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle disabled:opacity-50`,disabled:!j||S.isPending,onClick:re,children:`Clear override`}),q(`div`,{className:`flex-1`}),q(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:ee,children:`Cancel`}),q(`button`,{type:`button`,disabled:!o||S.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:ne,children:S.isPending?`Saving…`:`Save`})]}),children:O&&k&&o&&H(`div`,{className:`space-y-4`,children:[q(rr,{agents:P,currentAgent:o.agentNodeId,onPick:te,hint:u}),q(I,{mode:`device`,addon:O,agentDefault:k,agentNodeId:o.agentNodeId,currentPatch:c,engineFormat:A,onChangePatch:l})]})})]})}function $({label:e,value:t}){return H(`div`,{className:`${lt} flex items-start gap-2 sm:gap-3`,children:[q(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),q(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}V();function ar({deviceId:e,initialName:t}){let n=G(),[r,i]=K(!1),[a,o]=K(t),[s,c]=K(!1),l=B(null);J(()=>{r||o(t)},[t,r]),J(()=>{r&&l.current?.focus()},[r]);let u=m({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),d=async()=>{let n=a.trim();if(n.length===0||n===t){i(!1),o(t);return}c(!0);try{await u.mutateAsync({deviceId:e,name:n}),i(!1)}catch{}finally{c(!1)}},f=()=>{o(t),i(!1)};return r?q($,{label:`Name`,value:H(`div`,{className:`flex items-center gap-1`,children:[q(`input`,{ref:l,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?d():e.key===`Escape`&&f()},disabled:s,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),q(`button`,{type:`button`,onClick:()=>void d(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:q(Dt,{className:`h-3 w-3`})}),q(`button`,{type:`button`,onClick:f,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:q(Rt,{className:`h-3 w-3`})})]})}):q($,{label:`Name`,value:H(`div`,{className:`flex items-center gap-2 group`,children:[q(`span`,{className:`truncate`,children:t}),q(`button`,{type:`button`,onClick:()=>i(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit name`,children:q(bt,{className:`h-3.5 w-3.5`})})]})})}V();function or({deviceId:e,initialLocation:t}){let n=G(),[r,i]=K(!1),[a,o]=K(t??``),[s,c]=K(!1),l=B(null),{data:d}=T(void 0,{enabled:r}),f=d??[];J(()=>{r||o(t??``)},[t,r]),J(()=>{r&&l.current?.focus()},[r]);let p=u({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]})}}),m=U(()=>{let e=a.trim().toLowerCase();return e.length===0?f:f.filter(t=>t.toLowerCase()!==e&&t.toLowerCase().includes(e))},[f,a]),h=a.trim().length>0&&!f.some(e=>e.toLowerCase()===a.trim().toLowerCase()),g=async n=>{let r=(n??a).trim(),o=r.length===0?null:r;if(o===(t??null)){i(!1);return}c(!0);try{await p.mutateAsync({deviceId:e,location:o}),i(!1)}catch{}finally{c(!1)}},_=()=>{o(t??``),i(!1)};return r?q($,{label:`Location`,value:H(`div`,{className:`relative`,children:[H(`div`,{className:`flex items-center gap-1`,children:[q(`input`,{ref:l,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?g():e.key===`Escape`&&_()},disabled:s,placeholder:`Room / area (or leave empty to clear)`,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),q(`button`,{type:`button`,onClick:()=>void g(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:q(Dt,{className:`h-3 w-3`})}),q(`button`,{type:`button`,onClick:_,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:q(Rt,{className:`h-3 w-3`})})]}),(m.length>0||h)&&H(`div`,{className:`absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md`,children:[m.map(e=>H(`button`,{type:`button`,onClick:()=>{o(e),g(e)},className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[q(nn,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),q(`span`,{className:`truncate`,children:e})]},e)),h&&H(`button`,{type:`button`,onClick:()=>void g(),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border`,children:[q(`span`,{className:`text-foreground-subtle`,children:`Create`}),H(`span`,{className:`font-medium truncate`,children:[`"`,a.trim(),`"`]})]})]})]})}):q($,{label:`Location`,value:H(`div`,{className:`flex items-center gap-2 group`,children:[t?q(`span`,{className:`truncate`,children:t}):q(`span`,{className:`italic text-foreground-subtle`,children:`unset`}),q(`button`,{type:`button`,onClick:()=>i(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit location`,children:q(bt,{className:`h-3.5 w-3.5`})})]})})}V();function sr({deviceId:e}){let t=G(),{data:n}=yt(e),{data:r}=vt(e),[i,a]=K(null),o=y({onSuccess:()=>{a(null),t.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{a(`Could not change primary child: ${e.message}`)}});if(n==null||String(n.type??``)!==Y.Container)return null;let s=(r??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(s.length<=1)return null;let c=fe(s,typeof n.linkDeviceId==`number`?n.linkDeviceId:null,typeof n.primaryChildEntityId==`string`?n.primaryChildEntityId:null);return H(W,{children:[q($,{label:`Primary child`,value:q(A,{childrenList:s,selectedId:c===null?s[0].id:c.id,onSetPrimary:t=>o.mutate({deviceId:e,primaryChildEntityId:t}),disabled:o.isPending})}),i!==null&&q(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:i})]})}V();var cr=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function lr(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function ur(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function dr(){let e=b(),t=S(),{data:n}=M({deviceId:e??0},{enabled:e!==null}),{data:r}=Ge({deviceId:e??0},{enabled:e!==null}),i=n??t??null,[a,o]=K(`identity`);if(e===null||!i)return null;let s=String(i.stableId??``),c=String(i.name??``),l=String(i.type??``),u=String(i.addonId??``),d=i.features??[],f=new Set([`device-status`,`feature-probe`,`device-ops`]),p=(r?.entries??[]).filter(e=>e.kind===`native`&&!f.has(e.capName)).map(e=>e.capName),m=d.length>0?d:p,h=i.location??null,g=i.metadata??null,_=g!==null&&Object.keys(g).length>0;return H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[H(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[q(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:`Device Info`}),_&&H(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[q(fr,{active:a===`identity`,onClick:()=>o(`identity`),label:`Identity`}),q(fr,{active:a===`hardware`,onClick:()=>o(`hardware`),label:`Hardware`})]})]}),(!_||a===`identity`)&&H(`div`,{className:`divide-y divide-border`,children:[q($,{label:`ID`,value:H(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${e}`,H(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,s,`)`]})]})}),q(ar,{deviceId:e,initialName:c}),q(or,{deviceId:e,initialLocation:h}),q(sr,{deviceId:e}),q($,{label:`Type`,value:l}),q($,{label:`Provider`,value:q(gt,{type:u,size:`sm`,showLabel:!0})}),q($,{label:`Capabilities`,value:m.length>0?q(pt,{capabilities:m,showLabels:!0}):q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`None`})})]}),_&&a===`hardware`&&q(pr,{metadata:g})]})}function fr({active:e,onClick:t,label:n}){return q(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function pr({metadata:e}){let t=cr.filter(t=>t in e),n=Object.keys(e).filter(e=>!cr.includes(e)).toSorted(),r=[...t,...n];return H(`div`,{children:[q(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:`Auto-populated by the driver on every connect. Read-only.`}),q(`div`,{className:`divide-y divide-border`,children:r.map(t=>q($,{label:lr(t),value:q(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:ur(e[t])})},t))})]})}V();function mr({deviceId:e}){let[t,n]=K(null),r=ue({onSuccess:e=>{n(e.changed?`Re-aligned with source — ${e.rebuiltChildren} child${e.rebuiltChildren===1?``:`ren`} rebuilt.`:`Already up to date.`)},onError:e=>n(`Re-sync failed: ${e.message}`)});return H(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[H(`div`,{className:`flex items-center justify-between gap-3`,children:[H(`div`,{children:[q(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:`Re-sync`}),q(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:`Re-align this device's type, role, capabilities and units with its source.`})]}),H(`button`,{type:`button`,disabled:r.isPending,onClick:()=>{n(null),r.mutate({camDeviceId:e})},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[q(St,{className:`h-3 w-3 ${r.isPending?`animate-spin`:``}`}),r.isPending?`Re-syncing…`:`Re-sync`]})]}),t!==null&&q(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:t})]})}V();var hr={icon:``,label:``,unit:``,precision:``,hidden:!1};function gr(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function _r(e){if(typeof e!=`object`||!e)return;let t=e.unit;return typeof t==`string`?t:void 0}function vr(e){let t=e.precision.trim()===``?void 0:Number.parseInt(e.precision,10),n={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...t!==void 0&&Number.isFinite(t)?{precision:t}:{},...e.hidden?{hidden:!0}:{}};return Object.keys(n).length===0?null:n}function yr({deviceId:e}){let t=X(),n=G(),{data:r}=M({deviceId:e},{enabled:e>0}),i=typeof r?.role==`string`?r.role:null,a=i===null?void 0:Oe[i],o=a?.kind===`numeric`,s=De(t.trpcClient,e,i??``),c=a?.kind===`numeric`?a.canonicalUnit:void 0,l=_r(s)??c,u=l===void 0?void 0:st(l),d=U(()=>u===void 0?[]:it(u),[u]),[f,p]=K(null),m=f??gr(r?.display),h=D({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),{data:g}=Ue({},{staleTime:6e4}),_=j({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}});if(r===void 0||i===null)return null;let v=e=>{p({...m,...e})},y=()=>{h.mutate({deviceId:e,display:vr(m)})},b=()=>{p(hr),h.mutate({deviceId:e,display:null})},x=()=>{let e={...m.icon===``?{}:{icon:m.icon},...m.unit===``?{}:{unit:m.unit},...m.precision.trim()!==``&&Number.isFinite(Number.parseInt(m.precision,10))?{precision:Number.parseInt(m.precision,10)}:{}},t={...g?.defaults??{},[i]:e};_.mutate({defaults:t})},S=O(i).label,C=Object.keys(F);return H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[q(`div`,{className:`border-b border-border px-4 py-2`,children:q(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Display`})}),H(`div`,{className:`p-4 space-y-3`,children:[H(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Icon`}),H(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:m.icon,onChange:e=>v({icon:e.target.value}),children:[H(`option`,{value:``,children:[`Default (`,S,`)`]}),C.map(e=>q(`option`,{value:e,children:e},e))]})]}),H(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Label`}),q(`input`,{type:`text`,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:S,value:m.label,onChange:e=>v({label:e.target.value})})]}),o&&H(`div`,{className:`grid grid-cols-2 gap-3`,children:[H(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Unit`}),H(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:m.unit,onChange:e=>v({unit:e.target.value}),disabled:d.length===0,children:[H(`option`,{value:``,children:[`Source`,l?` (${l})`:``]}),d.map(e=>q(`option`,{value:e,children:e},e))]})]}),H(`label`,{className:`block`,children:[q(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Precision`}),q(`input`,{type:`number`,min:0,max:10,step:1,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:`inherit`,value:m.precision,onChange:e=>v({precision:e.target.value})})]})]}),H(`label`,{className:`flex items-center gap-2`,children:[q(`input`,{type:`checkbox`,checked:m.hidden,onChange:e=>v({hidden:e.target.checked})}),q(`span`,{className:`text-sm text-foreground`,children:`Hide from device lists`})]}),H(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[q(`button`,{type:`button`,className:`rounded bg-primary px-3 py-1 text-sm font-medium text-primary-foreground disabled:opacity-50`,onClick:y,disabled:h.isPending,children:`Save`}),q(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:b,disabled:h.isPending,children:`Reset`}),H(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:x,disabled:_.isPending,title:`Apply this unit / precision / icon as the default for every ${S} sensor`,children:[`Set as default for all `,S,` sensors`]})]})]})]})}function br(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function xr({device:e}){let t=Mt(),n=typeof e.id==`number`?e.id:null,r=String(e.type??``),i=r===Y.Camera,a=r===Y.Hub,o=typeof e.role==`string`&&e.role.length>0,s=e.features??[],c=s.includes(nt.Resyncable),{data:l}=E({deviceId:n??0},{enabled:n!==null&&i,refetchInterval:5e3}),u=l?.streams??{},d=Object.entries(u),f=s.includes(nt.DoorbellButton),p=Pe(f?{deviceId:n??void 0,historyLimit:10}:void 0),m=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return H(`div`,{className:`space-y-5`,children:[a&&n!==null&&q(Ae,{deviceId:n,onOpenChild:e=>t(`/devices/${e}`)}),c&&n!==null&&q(mr,{deviceId:n}),i&&n!==null&&q(te,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:n}),f&&q(Re,{history:p.history,latestIsFresh:m}),i&&n!==null&&q(te,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:n}),i&&d.length>0&&H(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[q(`div`,{className:`border-b border-border px-4 py-2`,children:q(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Stream Network`})}),q(`div`,{className:`divide-y divide-border`,children:d.map(([e,t])=>H(`div`,{className:`px-4 py-2.5`,children:[H(`div`,{className:`flex items-center gap-2 mb-2`,children:[q(Tt,{className:`h-3 w-3 text-foreground-subtle`}),q(`span`,{className:`text-[11px] font-medium text-foreground`,children:e})]}),H(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[q(Sr,{label:`Nominal`,value:br(t.nominalBitrateKbps??0)}),q(Sr,{label:`Observed`,value:br(t.observedBitrateKbps??0)}),q(Sr,{label:`Peak`,value:br(t.peakBitrateKbps??0)}),q(Sr,{label:`Packet Loss`,value:`${(t.packetLossPercent??0).toFixed(2)}%`,warning:(t.packetLossPercent??0)>1})]})]},e))})]}),q(dr,{}),o&&n!==null&&q(yr,{deviceId:n})]})}function Sr({label:e,value:t,warning:n}){return H(`div`,{children:[q(`p`,{className:`text-[10px] text-foreground-subtle`,children:e}),q(`p`,{className:`text-xs font-medium ${n?`text-warning`:`text-foreground`}`,children:t})]})}V();function Cr(e,t){if(t===`number`){let t=Number(e);return Number.isNaN(t)?e:t}return t===`boolean`?e===`true`:e}function wr(e,t){let n={};for(let r of e)r.key!==``&&r.value!==``&&(n[r.key]=Cr(r.value,t));return n}function Tr(e,t){return e?.kind===`enum-map`?Object.entries(e.mapping).map(([e,t])=>({key:e,value:String(t)})):t?.kind===`enum`&&t.enumValues?t.enumValues.map(e=>({key:e,value:``})):[{key:``,value:``}]}function Er(e){return e?.kind===`linear`?{scale:String(e.scale),offset:String(e.offset),clampMin:e.clamp?String(e.clamp[0]):``,clampMax:e.clamp?String(e.clamp[1]):``,useClamp:e.clamp!=null}:{scale:`1`,offset:`0`,clampMin:``,clampMax:``,useClamp:!1}}function Dr(e){return e==null?`identity`:e.kind}function Or({value:e,onChange:t,sourceField:n,targetKind:r}){let[i,a]=K(()=>Dr(e)),[o,s]=K(()=>Tr(e,n)),[c,l]=K(()=>e?.kind===`enum-map`&&e.fallback!=null?String(e.fallback):``),[u,d]=K(()=>Er(e));J(()=>{if(i===`enum-map`&&n?.kind===`enum`&&n.enumValues){let e=n.enumValues;s(t=>e.map(e=>({key:e,value:t.find(t=>t.key===e)?.value??``})))}},[n,i]),J(()=>{if(i===`identity`){t(void 0);return}if(i===`enum-map`){let e=wr(o,r),n=c===``?void 0:Cr(c,r);t({kind:`enum-map`,mapping:e,...n===void 0?{}:{fallback:n}});return}if(i===`linear`){let e=Number(u.scale),n=Number(u.offset);if(Number.isNaN(e)||Number.isNaN(n))return;let r=Number(u.clampMin),i=Number(u.clampMax),a=u.useClamp&&!Number.isNaN(r)&&!Number.isNaN(i)?[r,i]:void 0;t({kind:`linear`,scale:e,offset:n,...a?{clamp:a}:{}})}},[i,o,c,u,r,t]);let f=e=>{a(e),e===`enum-map`&&s(Tr(void 0,n)),e===`linear`&&d(Er(void 0))},p=(e,t,n)=>{s(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},m=()=>s(e=>[...e,{key:``,value:``}]),h=e=>s(t=>t.filter((t,n)=>n!==e));return H(`div`,{className:`flex flex-col gap-3`,children:[H(`div`,{children:[q(`p`,{className:`text-[11px] font-medium text-foreground-subtle mb-1.5`,children:`Transform`}),q(`div`,{className:`flex items-center gap-4`,children:[`identity`,`enum-map`,`linear`].map(e=>H(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[q(`input`,{type:`radio`,name:`transform-kind`,value:e,checked:i===e,onChange:()=>f(e),className:`accent-primary`}),e===`identity`?`None`:e]},e))})]}),i===`enum-map`&&H(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[q(`p`,{className:`text-[10px] font-medium text-foreground-subtle/70 uppercase tracking-wide`,children:`Key → Value mapping`}),o.map((e,t)=>H(`div`,{className:`flex items-center gap-1.5`,children:[q(`input`,{"aria-label":`enum key ${t}`,type:`text`,value:e.key,readOnly:n?.kind===`enum`,onChange:e=>p(t,`key`,e.target.value),placeholder:`source value`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs font-mono text-foreground focus:border-primary outline-none read-only:opacity-70`}),q(`span`,{className:`text-foreground-subtle/50 text-xs`,children:`→`}),r===`boolean`?H(`select`,{"aria-label":`enum value ${t}`,value:e.value,onChange:e=>p(t,`value`,e.target.value),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`,children:[q(`option`,{value:``,children:`—`}),q(`option`,{value:`true`,children:`true`}),q(`option`,{value:`false`,children:`false`})]}):q(`input`,{"aria-label":`enum value ${t}`,type:r===`number`?`number`:`text`,value:e.value,onChange:e=>p(t,`value`,e.target.value),placeholder:`target value`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs font-mono text-foreground focus:border-primary outline-none`}),n?.kind!==`enum`&&q(`button`,{type:`button`,onClick:()=>h(t),className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] border border-border/80 text-foreground-subtle hover:text-danger hover:border-danger/50 transition-colors`,children:`✕`})]},t)),n?.kind!==`enum`&&q(`button`,{type:`button`,onClick:m,className:`self-start text-[10px] text-primary/70 hover:text-primary transition-colors`,children:`+ Add row`}),H(`div`,{className:`flex items-center gap-2 pt-1 border-t border-border/50`,children:[q(`label`,{className:`text-[10px] text-foreground-subtle/70 whitespace-nowrap`,children:`Fallback:`}),q(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`(leave empty for none)`,className:`flex-1 rounded border border-border bg-background px-2 py-0.5 text-xs font-mono text-foreground focus:border-primary outline-none`})]})]}),i===`linear`&&H(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-3`,children:[q(`p`,{className:`text-[10px] font-medium text-foreground-subtle/70 uppercase tracking-wide`,children:`Linear: value × scale + offset`}),H(`div`,{className:`grid grid-cols-2 gap-2`,children:[H(`label`,{className:`flex flex-col gap-0.5`,children:[q(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Scale`}),q(`input`,{type:`number`,value:u.scale,onChange:e=>d(t=>({...t,scale:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]}),H(`label`,{className:`flex flex-col gap-0.5`,children:[q(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Offset`}),q(`input`,{type:`number`,value:u.offset,onChange:e=>d(t=>({...t,offset:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]})]}),H(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[q(`input`,{type:`checkbox`,checked:u.useClamp,onChange:e=>d(t=>({...t,useClamp:e.target.checked})),className:`accent-primary`}),q(`span`,{className:`text-foreground-subtle`,children:`Clamp output`})]}),u.useClamp&&H(`div`,{className:`grid grid-cols-2 gap-2`,children:[H(`label`,{className:`flex flex-col gap-0.5`,children:[q(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Min`}),q(`input`,{type:`number`,value:u.clampMin,onChange:e=>d(t=>({...t,clampMin:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]}),H(`label`,{className:`flex flex-col gap-0.5`,children:[q(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Max`}),q(`input`,{type:`number`,value:u.clampMax,onChange:e=>d(t=>({...t,clampMax:e.target.value})),className:`rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:border-primary outline-none`})]})]})]})]})}var kr=`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none disabled:opacity-50`;function Ar({mode:e,idPrefix:t,labelPrefix:n,pickerDevices:r,value:i,onChange:a,search:o,onSearchChange:s}){let{data:c}=ne({deviceId:i.sourceId??0},{enabled:i.sourceId!=null}),l=c?.caps??[],u=l.find(e=>e.cap===i.cap)?.fields??[],d=e=>{a(e,(l.find(t=>t.cap===e.cap)?.fields??[]).find(t=>t.path===e.fieldPath))},f=e=>{d({sourceId:e===``?null:Number(e),cap:``,fieldPath:``})},p=e=>{d({sourceId:i.sourceId,cap:e,fieldPath:``})},m=e=>{d({sourceId:i.sourceId,cap:i.cap,fieldPath:e})};return H(W,{children:[e===`global`&&s&&H(`div`,{children:[q(`label`,{htmlFor:`${t}-search`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Search devices`}),q(`input`,{id:`${t}-search`,type:`text`,value:o??``,placeholder:`Filter by name, stable id or #id`,onChange:e=>s(e.target.value),className:kr})]}),H(`div`,{children:[H(`label`,{htmlFor:`${t}-device`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:[n,` device`]}),H(`select`,{id:`${t}-device`,value:i.sourceId??``,onChange:e=>f(e.target.value),className:kr,children:[q(`option`,{value:``,children:`— select a device —`}),r.map(e=>H(`option`,{value:e.id,children:[e.name??e.stableId,` (#`,e.id,`)`]},e.id))]})]}),H(`div`,{children:[H(`label`,{htmlFor:`${t}-cap`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:[n,` cap`]}),H(`select`,{id:`${t}-cap`,value:i.cap,disabled:i.sourceId==null,onChange:e=>p(e.target.value),className:kr,children:[q(`option`,{value:``,children:`— select a cap —`}),l.map(e=>q(`option`,{value:e.cap,children:e.cap},e.cap))]})]}),H(`div`,{children:[H(`label`,{htmlFor:`${t}-field`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:[n,` field`]}),H(`select`,{id:`${t}-field`,value:i.fieldPath,disabled:i.cap===``,onChange:e=>m(e.target.value),className:kr,children:[q(`option`,{value:``,children:`— select a field —`}),u.map(e=>H(`option`,{value:e.path,children:[e.path,` (`,e.kind,`)`]},e.path))]})]})]})}function jr(e,t){switch(e){case`null`:return{value:null};case`string`:return t===``?null:{value:t};case`number`:{if(t.trim()===``)return null;let e=Number(t);return Number.isFinite(e)?{value:e}:null}case`boolean`:return t===`true`?{value:!0}:t===`false`?{value:!1}:null}}function Mr(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`boolean`?`boolean`:`string`}function Nr(e){return e===null?``:String(e)}V();var Pr=`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none disabled:opacity-50`,Fr=`min, max, abs, round, floor, ceil, sqrt, pow, clamp, avg, sum, coalesce, age, convert`,Ir=0;function Lr(){return Ir+=1,`b${Ir}`}function Rr(e){return{key:Lr(),name:e,mode:`sibling`,sourceId:null,cap:``,fieldPath:``,search:``,literalType:`number`,literalText:``,sampleText:``}}function zr(e,t,n){if(e===null)return[Rr(`a`)];let r=[];for(let[i,a]of Object.entries(e.bindings)){if(a.kind===`literal`){r.push({...Rr(i),mode:`literal`,literalType:Mr(a.value),literalText:Nr(a.value)});continue}if(a.kind===`global`){r.push({...Rr(i),mode:`global`,sourceId:t.find(e=>e.stableId===a.sourceStableId)?.id??null,cap:a.cap,fieldPath:a.fieldPath});continue}r.push({...Rr(i),mode:`sibling`,sourceId:t.find(e=>e.stableId===`${n}-${a.sourceKey}`)?.id??null,cap:a.cap,fieldPath:a.fieldPath})}return r.length>0?r:[Rr(`a`)]}function Br(e,t,n){if(e.mode===`literal`){let t=jr(e.literalType,e.literalText);return t===null?null:{kind:`literal`,value:t.value}}let r=t.find(t=>t.id===e.sourceId);if(!r||e.cap===``||e.fieldPath===``)return null;if(e.mode===`global`)return{kind:`global`,sourceStableId:r.stableId,cap:e.cap,fieldPath:e.fieldPath};let i=`${n}-`,a=r.stableId.startsWith(i)?r.stableId.slice(i.length):``;return a===``?null:{kind:`field`,sourceKey:a,cap:e.cap,fieldPath:e.fieldPath}}function Vr(e){if(e.mode===`literal`)return jr(e.literalType,e.literalText)?.value??null;let t=e.sampleText.trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:e.sampleText}function Hr({devices:e,siblings:t,targetDeviceId:n,containerStableId:r,initial:i,onChange:a}){let[o,s]=K(i?.expr??``),[c,l]=K(()=>zr(i,e,r)),u=U(()=>{let t={},n=c.length>0,i=new Set;for(let a of c){let o=a.name.trim();if(o===``||i.has(o)){n=!1;continue}i.add(o);let s=Br(a,e,r);if(s===null){n=!1;continue}t[o]=s}return{source:{kind:`expression`,expr:o,bindings:t},complete:n}},[c,o,e,r]),d=U(()=>Qe({expr:u.source.expr,bindings:u.source.bindings}),[u.source]),f=U(()=>{if(o.trim()===``)return null;let e=Ze(o);return e.ok?null:e.error},[o]),p=U(()=>{if(u.source.expr.trim()===``)return null;let e={};for(let t of c){let n=t.name.trim();n!==``&&(e[n]=Vr(t))}return rt(u.source.expr,e,Date.now())},[u.source.expr,c]),m=u.complete&&d===null&&o.trim()!==``;J(()=>{a(m?u.source:null)},[m?JSON.stringify(u.source):`null`]);let h=e=>{let t=e.name.trim();return t===``?`required`:ot.test(t)?Xe.has(t)?`reserved`:tt.has(t)?`shadows builtin`:c.filter(e=>e.name.trim()===t).length>1?`duplicate`:null:`invalid name`},g=(e,t)=>{l(n=>n.map(n=>n.key===e?{...n,...t}:n))},_=()=>{c.length>=32||l(e=>[...e,Rr(Ur(e))])},v=e=>{l(t=>t.length<=1?t:t.filter(t=>t.key!==e))};return H(`div`,{className:`flex flex-col gap-3`,children:[H(`div`,{className:`flex flex-col gap-2`,children:[q(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Bindings`}),c.map((r,i)=>q(Wr,{row:r,ordinal:i+1,devices:e,siblings:t,targetDeviceId:n,nameError:h(r),onPatch:e=>g(r.key,e),onRemove:()=>v(r.key),canRemove:c.length>1},r.key)),q(`button`,{type:`button`,onClick:_,disabled:c.length>=32,className:`self-start px-2 py-1 rounded-md text-[11px] font-medium border border-border text-foreground-subtle hover:bg-surface-hover disabled:opacity-50`,children:`+ Add binding`})]}),H(`div`,{children:[q(`label`,{htmlFor:`link-expr-input`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Expression`}),q(`textarea`,{id:`link-expr-input`,value:o,rows:2,spellCheck:!1,placeholder:`e.g. clamp(avg(a, b) + 5, 0, 100)`,onChange:e=>s(e.target.value),className:`${Pr} font-mono resize-y`}),H(`p`,{className:`mt-1 text-[10px] text-foreground-subtle/60`,children:[`Functions: `,Fr]}),f&&q(`p`,{className:`mt-1 text-[10px] text-danger`,children:f}),f===null&&d&&q(`p`,{className:`mt-1 text-[10px] text-danger`,children:d})]}),H(`div`,{className:`rounded-md border border-border bg-surface/50 px-2 py-1.5`,children:[q(`span`,{className:`text-[10px] uppercase tracking-widest text-foreground-subtle/60`,children:`Preview`}),` `,p===null?q(`span`,{className:`text-[11px] text-foreground-subtle/60`,children:`enter an expression`}):p.ok?q(`span`,{className:`font-mono text-[11px] text-foreground`,children:JSON.stringify(p.value)}):q(`span`,{className:`font-mono text-[11px] text-danger`,children:p.error})]})]})}function Ur(e){let t=new Set(e.map(e=>e.name.trim()));for(let e=0;e<26;e++){let n=String.fromCharCode(97+e);if(!t.has(n))return n}return`b${e.length+1}`}function Wr({row:e,ordinal:t,devices:n,siblings:r,targetDeviceId:i,nameError:a,onPatch:o,onRemove:s,canRemove:c}){let l=e.search.trim().toLowerCase(),u=n.filter(e=>e.id===i?!1:l===``?!0:e.name.toLowerCase().includes(l)||e.stableId.toLowerCase().includes(l)||String(e.id).includes(l)),d=e.mode===`global`?u:r;return H(`div`,{className:`flex flex-col gap-2 rounded-md border border-border/60 p-2`,children:[H(`div`,{className:`flex items-center gap-2`,children:[q(`input`,{type:`text`,"aria-label":`binding ${t} name`,value:e.name,placeholder:`name`,onChange:e=>o({name:e.target.value}),className:`${Pr} max-w-[8rem] font-mono`}),H(`select`,{"aria-label":`binding ${t} mode`,value:e.mode,onChange:e=>{let t=e.target.value;(t===`sibling`||t===`global`||t===`literal`)&&o({mode:t,sourceId:null,cap:``,fieldPath:``,search:``})},className:`${Pr} max-w-[9rem]`,children:[q(`option`,{value:`sibling`,children:`Sibling`}),q(`option`,{value:`global`,children:`Any device`}),q(`option`,{value:`literal`,children:`Literal`})]}),c&&q(`button`,{type:`button`,"aria-label":`remove binding ${t}`,onClick:s,className:`px-2 py-1 rounded-md text-[11px] text-danger hover:bg-surface-hover`,children:`✕`})]}),a&&H(`span`,{className:`text-[10px] text-danger`,children:[`name: `,a]}),e.mode===`literal`?H(`div`,{className:`flex items-center gap-2`,children:[H(`select`,{"aria-label":`binding ${t} literal type`,value:e.literalType,onChange:e=>{let t=e.target.value;(t===`string`||t===`number`||t===`boolean`||t===`null`)&&o({literalType:t,literalText:t===`boolean`?`true`:``})},className:`${Pr} max-w-[7rem]`,children:[q(`option`,{value:`string`,children:`string`}),q(`option`,{value:`number`,children:`number`}),q(`option`,{value:`boolean`,children:`boolean`}),q(`option`,{value:`null`,children:`null`})]}),e.literalType!==`null`&&q(`input`,{type:`text`,"aria-label":`binding ${t} literal value`,value:e.literalText,placeholder:e.literalType===`number`?`e.g. 42`:`value`,onChange:e=>o({literalText:e.target.value}),className:Pr})]}):H(W,{children:[q(Ar,{mode:e.mode,idPrefix:`binding-${t}`,labelPrefix:`Binding`,pickerDevices:d,value:{sourceId:e.sourceId,cap:e.cap,fieldPath:e.fieldPath},onChange:e=>o({sourceId:e.sourceId,cap:e.cap,fieldPath:e.fieldPath}),search:e.search,onSearchChange:e=>o({search:e})}),q(`input`,{type:`text`,"aria-label":`binding ${t} sample`,value:e.sampleText,placeholder:`sample value (preview only)`,onChange:e=>o({sampleText:e.target.value}),className:`${Pr} text-[10px]`})]})]})}V();function Gr(e,t,n){return(n===void 0?[e,t]:[e,n,t]).map(e=>e.replace(/[^a-z0-9]/gi,`-`)).join(`-`)}function Kr(e,t,n){let r=`${t}-${e}`;return n.find(e=>e.stableId===r)?.id??null}function qr(e,t){return t.find(t=>t.stableId===e)?.id??null}function Jr(e){return e==null?`sibling`:e.source.kind===`literal`?`literal`:e.source.kind===`global`?`global`:e.source.kind===`expression`?`expression`:`sibling`}function Yr(e){return e==null||e.source.kind!==`literal`?`string`:Mr(e.source.value)}function Xr(e){return e==null||e.source.kind!==`literal`?``:Nr(e.source.value)}function Zr({deviceId:e,parentDeviceId:t,deviceStableId:n,initial:r,onSave:i,onCancel:a}){let{data:o}=l({}),s=o??[],c=t==null?n:s.find(e=>e.id===t)?.stableId??n,u=s.filter(n=>n.parentDeviceId===t&&n.id!==e),{data:d}=ne({deviceId:e,includeSynthesizable:!0}),f=d?.caps??[],p=r!=null&&(r.source.kind===void 0||r.source.kind===`field`)?r.source:null,m=r!=null&&r.source.kind===`global`?r.source:null,h=r!=null&&r.source.kind===`expression`?r.source:null,g=p==null?m==null?null:qr(m.sourceStableId,s):Kr(p.sourceKey,c,s),[_,v]=K(Jr(r)),[y,b]=K(r?.target.cap??``),[x,S]=K(r?.target.fieldPath??``),[C,w]=K(r?.target.itemKey??``),[T,E]=K(g),[D,O]=K((p??m)?.cap??``),[k,A]=K((p??m)?.fieldPath??``),[j,ee]=K(void 0),[M,te]=K(``),[re,N]=K(Yr(r)),[P,F]=K(Xr(r)),[ie,ae]=K(h),[oe,se]=K(r?.transform);J(()=>{if((p??m)==null||T!==null||s.length===0)return;let e=p==null?m==null?null:qr(m.sourceStableId,s):Kr(p.sourceKey,c,s);e!==null&&E(e)},[p,m,T,s,c]);let ce=f.find(e=>e.cap===y)?.fields??[],I=ce.find(e=>e.path===x),le=I?.item===!0,ue=M.trim().toLowerCase(),de=s.filter(t=>t.id===e?!1:ue===``?!0:t.name.toLowerCase().includes(ue)||t.stableId.toLowerCase().includes(ue)||String(t.id).includes(ue)),fe=_===`global`?de:u,pe=e=>{b(e),S(``),w(``)},L=e=>{e!==`sibling`&&e!==`global`&&e!==`literal`&&e!==`expression`||(v(e),E(null),O(``),A(``),ee(void 0),te(``))},me=jr(re,P),he=_===`literal`?me!==null:_===`expression`?ie!==null:T!=null&&D!==``&&k!==``,ge=y!==``&&x!==``&&(!le||C.trim()!==``)&&he,_e=()=>{if(_===`literal`)return me===null?null:{kind:`literal`,value:me.value};if(_===`expression`)return ie;let e=s.find(e=>e.id===T);if(!e||D===``||k===``)return null;if(_===`global`)return{kind:`global`,sourceStableId:e.stableId,cap:D,fieldPath:k};let t=`${c}-`;return{sourceKey:e.stableId.startsWith(t)?e.stableId.slice(t.length):``,cap:D,fieldPath:k}},ve=()=>{if(!ge)return;let e=_e();if(e===null)return;let t=le?C.trim():void 0;i({id:r?.id??Gr(y,x,t),source:e,target:{cap:y,fieldPath:x,...t===void 0?{}:{itemKey:t}},...oe==null?{}:{transform:oe}})},ye=`w-full rounded-md border border-border bg-surface px-2 py-1.5 text-foreground text-xs focus:border-primary outline-none disabled:opacity-50`;return H(`div`,{className:`flex flex-col gap-4 p-3`,children:[H(`fieldset`,{className:`flex flex-col gap-3`,children:[q(`legend`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/70 mb-1`,children:`Target (this device)`}),H(`div`,{children:[q(`label`,{htmlFor:`link-target-cap`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Target cap`}),H(`select`,{id:`link-target-cap`,value:y,onChange:e=>pe(e.target.value),className:ye,children:[q(`option`,{value:``,children:`— select a cap —`}),f.map(e=>q(`option`,{value:e.cap,children:e.cap},e.cap))]})]}),H(`div`,{children:[q(`label`,{htmlFor:`link-target-field`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Target field`}),H(`select`,{id:`link-target-field`,value:x,disabled:y===``,onChange:e=>S(e.target.value),className:ye,children:[q(`option`,{value:``,children:`— select a field —`}),ce.map(e=>q(`option`,{value:e.path,children:e.item===!0?`${e.path} (per item, ${e.kind})`:`${e.path} (${e.kind})`},e.path))]})]}),le&&H(`div`,{children:[q(`label`,{htmlFor:`link-target-item-key`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Item key`}),q(`input`,{id:`link-target-item-key`,type:`text`,value:C,placeholder:`e.g. main-brush`,onChange:e=>w(e.target.value),className:ye}),q(`p`,{className:`mt-1 text-[10px] text-foreground-subtle/60`,children:`Links sharing the same item key build one item (e.g. one consumable).`})]})]}),H(`fieldset`,{className:`flex flex-col gap-3`,children:[q(`legend`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/70 mb-1`,children:`Source`}),H(`div`,{children:[q(`label`,{htmlFor:`link-source-mode`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Source mode`}),H(`select`,{id:`link-source-mode`,value:_,onChange:e=>L(e.target.value),className:ye,children:[q(`option`,{value:`sibling`,children:`Sibling device (same container)`}),q(`option`,{value:`global`,children:`Any device`}),q(`option`,{value:`literal`,children:`Literal constant`}),q(`option`,{value:`expression`,children:`Expression (computed)`})]})]}),_===`literal`&&H(W,{children:[H(`div`,{children:[q(`label`,{htmlFor:`link-literal-type`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Literal type`}),H(`select`,{id:`link-literal-type`,value:re,onChange:e=>{let t=e.target.value;(t===`string`||t===`number`||t===`boolean`||t===`null`)&&(N(t),t===`boolean`&&F(`true`),t===`null`&&F(``))},className:ye,children:[q(`option`,{value:`string`,children:`string`}),q(`option`,{value:`number`,children:`number`}),q(`option`,{value:`boolean`,children:`boolean`}),q(`option`,{value:`null`,children:`null`})]})]}),re!==`null`&&(re===`boolean`?H(`div`,{children:[q(`label`,{htmlFor:`link-literal-value`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Literal value`}),H(`select`,{id:`link-literal-value`,value:P,onChange:e=>F(e.target.value),className:ye,children:[q(`option`,{value:`true`,children:`true`}),q(`option`,{value:`false`,children:`false`})]})]}):H(`div`,{children:[q(`label`,{htmlFor:`link-literal-value`,className:`block text-[11px] font-medium text-foreground-subtle mb-1`,children:`Literal value`}),q(`input`,{id:`link-literal-value`,type:`text`,value:P,placeholder:re===`number`?`e.g. 42`:`e.g. main-brush`,onChange:e=>F(e.target.value),className:ye})]}))]}),_===`expression`&&q(Hr,{devices:s,siblings:u,targetDeviceId:e,containerStableId:c,initial:h,onChange:ae}),(_===`sibling`||_===`global`)&&q(Ar,{mode:_,idPrefix:`link-source`,labelPrefix:`Source`,pickerDevices:fe,value:{sourceId:T,cap:D,fieldPath:k},onChange:(e,t)=>{E(e.sourceId),O(e.cap),A(e.fieldPath),ee(t)},search:M,onSearchChange:te})]}),q(Or,{value:oe,onChange:se,sourceField:_===`literal`||_===`expression`?void 0:j,targetKind:I?.kind}),H(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t border-border`,children:[q(`button`,{type:`button`,onClick:a,className:`px-3 py-1.5 rounded-md text-xs font-medium border border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors`,children:`Cancel`}),q(`button`,{type:`button`,disabled:!ge,onClick:ve,className:`px-3 py-1.5 rounded-md text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:`Save`})]})]})}V();function Qr({deviceId:e}){let t=X(),n=G(),r=Number.isFinite(e),{data:i,isLoading:a}=M({deviceId:e},{enabled:r,refetchInterval:1e4}),{data:o}=ne({deviceId:e,includeSynthesizable:!0},{enabled:r}),s=new Map;for(let e of o?.caps??[])e.itemArray&&s.set(e.cap,e.itemArray);let c=C({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),l=i?.deviceLinks??[],u=typeof i?.parentDeviceId==`number`?i.parentDeviceId:null,d=typeof i?.stableId==`string`?i.stableId:``,[f,p]=K(null),m=t=>{c.mutate({deviceId:e,deviceLinks:l.filter(e=>e.id!==t)})};return a?q(`div`,{className:`p-4`,children:q(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})}):f===null?H(`div`,{className:`flex flex-col gap-3 p-1`,children:[H(`div`,{className:`flex items-center justify-between`,children:[q(`h3`,{className:`text-xs font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Wiring`}),H(`button`,{type:`button`,onClick:()=>p(`new`),title:`Add a cross-device link`,className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[q(xt,{className:`h-3 w-3`}),`Add link`]})]}),l.length===0?H(`div`,{className:`flex flex-col items-center justify-center gap-2 py-8 text-foreground-subtle`,children:[q(en,{className:`h-8 w-8 opacity-30`}),q(`p`,{className:`text-xs`,children:`No links yet.`}),q(`p`,{className:`text-[10px] opacity-60`,children:`Cross-device field wirings will appear here once authored.`})]}):q(`div`,{className:`flex flex-col divide-y divide-border rounded-lg border border-border overflow-hidden`,children:l.map(n=>q(ei,{deviceId:e,link:n,itemArray:s.get(n.target.cap),trpcClient:t.trpcClient,onDelete:()=>m(n.id),onEdit:()=>p(n),isPending:c.isPending},n.id))})]}):H(`div`,{className:`flex flex-col gap-3 p-1`,children:[q(`div`,{className:`flex items-center justify-between`,children:q(`h3`,{className:`text-xs font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:f===`new`?`Add link`:`Edit link`})}),q(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:q(Zr,{deviceId:e,parentDeviceId:u,deviceStableId:d,initial:f===`new`?null:f,onSave:t=>{let n=l.some(e=>e.id===t.id)?l.map(e=>e.id===t.id?t:e):[...l,t];c.mutate({deviceId:e,deviceLinks:n}),p(null)},onCancel:()=>{p(null)}})})]})}function $r(e,t,n,r){let i=at(e,t.path);if(!Array.isArray(i))return;let a=i.find(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Reflect.get(e,t.keyField)===n);return a===void 0?void 0:at(a,r)}function ei({deviceId:e,link:t,itemArray:n,trpcClient:r,onDelete:i,onEdit:a,isPending:o}){let s=De(r,e,t.target.cap),c=t.target.itemKey,l=s===void 0?void 0:c!==void 0&&n!==void 0?$r(s,n,c,t.target.fieldPath):c===void 0?at(s,t.target.fieldPath):void 0,u=l==null?`—`:String(l);return H(`div`,{className:`flex items-center gap-3 px-3 py-2.5 bg-surface hover:bg-surface-hover transition-colors`,children:[q(tn,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle/40`}),H(`div`,{className:`min-w-0 flex-1 flex flex-col gap-0.5`,children:[H(`div`,{className:`flex items-baseline gap-1 flex-wrap`,children:[q(`span`,{className:`font-mono text-[11px] font-medium text-foreground`,children:t.target.cap}),q(`span`,{className:`text-[10px] text-foreground-subtle/60`,children:`.`}),q(`span`,{className:`font-mono text-[11px] text-foreground-subtle`,children:t.target.fieldPath}),c!==void 0&&q(`span`,{className:`rounded bg-surface-hover px-1 py-px font-mono text-[9px] text-foreground-subtle`,title:`Item key — links sharing it build one array item`,children:c})]}),H(`div`,{className:`flex items-baseline gap-1 flex-wrap text-[10px] text-foreground-subtle/70`,children:[q(`span`,{children:`←`}),t.source.kind===`literal`?H(`span`,{className:`font-mono`,children:[`literal: `,String(t.source.value)]}):t.source.kind===`expression`?H(W,{children:[H(`span`,{className:`font-mono`,title:t.source.expr,children:[`ƒ`,` `,t.source.expr.length>40?`${t.source.expr.slice(0,40)}…`:t.source.expr]}),H(`span`,{className:`rounded bg-surface-hover px-1 py-px font-mono text-[9px] text-foreground-subtle`,title:`Number of source bindings`,children:[Object.keys(t.source.bindings).length,` bindings`]})]}):H(W,{children:[q(`span`,{className:`font-mono`,children:t.source.kind===`global`?t.source.sourceStableId:t.source.sourceKey}),q(`span`,{className:`opacity-60`,children:`/`}),q(`span`,{className:`font-mono`,children:t.source.cap}),q(`span`,{className:`opacity-60`,children:`.`}),q(`span`,{className:`font-mono`,children:t.source.fieldPath})]})]})]}),t.transform&&q(ti,{kind:t.transform.kind}),q(`span`,{className:`font-mono text-[11px] tabular-nums min-w-[2.5rem] text-right text-foreground-subtle`,title:`Live resolved value (from this device's runtime-state slice)`,children:u}),q(`button`,{type:`button`,"aria-label":`Edit link`,title:`Edit this link`,disabled:o,onClick:a,className:`shrink-0 inline-flex items-center gap-1 rounded-md border border-border/80 px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:`Edit`}),q(`button`,{type:`button`,"aria-label":`Delete link`,title:`Remove this link`,disabled:o,onClick:i,className:`shrink-0 inline-flex items-center gap-1 rounded-md border border-border/80 px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:text-danger hover:border-danger/50 hover:bg-danger/5 transition-colors disabled:opacity-50`,children:`Delete`})]})}function ti({kind:e}){return q(`span`,{className:`inline-flex items-center rounded-md border border-primary/20 bg-primary/5 px-1.5 py-0.5 font-mono text-[10px] text-primary/80 shrink-0`,children:e})}V();var ni=[{id:`overview`,label:`Overview`,cameraOnly:!1},{id:`config`,label:`Config`,cameraOnly:!1},{id:`pipeline`,label:`Pipeline steps`,cameraOnly:!0},{id:`bindings`,label:`Bindings`,cameraOnly:!0},{id:`wiring`,label:`Wiring`,cameraOnly:!1}];function ri(e){let t=e===Y.Camera;return ni.filter(e=>t||!e.cameraOnly).map(({id:e,label:t})=>({id:e,label:t}))}var ii=[{id:`logs`,icon:Bt,label:`Logs`},{id:`repl`,icon:Lt,label:`REPL`},{id:`events`,icon:jt,label:`Events`},{id:`state`,icon:At,label:`State`}];function ai(){let e=Pt(),t=Number(e.deviceId),n=Number.isFinite(t),r=Mt(),i=G(),s=k(),l=X(),[u,d]=Ot(),f=u.get(`tab`)??`overview`,p=u.get(`sub`),[m,v]=K(`logs`),y=`device-detail.left-col-width-px`,[b,x]=K(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(y),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),S=B(b);S.current=b;function C(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??b??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{x(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=S.current;if(e!==null)try{window.localStorage.setItem(y,String(Math.round(e)))}catch{}document.body.style.userSelect=``,document.body.style.cursor=``};document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)}let{data:w,isLoading:T,isError:E}=M({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:D}=a({deviceId:t},{enabled:n}),O=U(()=>{let e=D?.settings?.sections??[],t=D?.live?.sections??[],n=[...e,...t],r=new Set;for(let e of n)e.location===`top-tab`&&e.tab&&r.add(e.tab===`zones`?`detection-pipeline`:e.tab);return n.some(zn)&&r.add(In),[...r].map(e=>e===`export`?{id:e,label:Ln,isAddonContrib:!0}:{id:e,label:$e[e]?.label??e,isAddonContrib:!0})},[D]),A=w,j=String(A?.name??e.deviceId??`Device`),te=A?.online===!0,re=te?`online`:`offline`,N=String(A?.addonId??`rtsp`),P=A?.features??[],F=A?.type,ie=F===Y.Camera,{data:ae}=vt(n?t:0),oe=F===Y.Container,se=U(()=>(ae??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[ae]),I=U(()=>oe?fe(se,typeof A?.linkDeviceId==`number`?A.linkDeviceId:null,typeof A?.primaryChildEntityId==`string`?A.primaryChildEntityId:null)?.id??null:null,[oe,se,A?.linkDeviceId,A?.primaryChildEntityId]),{data:le}=a({deviceId:I??0},{enabled:I!==null}),ue=U(()=>{if(I===null)return[];let e=le?.settings?.sections??[],t=le?.live?.sections??[],n=new Set;for(let r of[...e,...t])r.location===`top-tab`&&r.tab&&n.add(r.tab);return[...n].map(e=>({id:e,label:$e[e]?.label??e,isAddonContrib:!0,childDeviceId:I}))},[I,le]),de=typeof A?.parentDeviceId==`number`?A.parentDeviceId:null,{data:pe}=M({deviceId:de??0},{enabled:de!==null}),L=ge(),me=A?.disabled!==!0,{data:he}=ne({deviceId:t},{enabled:n}),_e=(he?.caps.length??0)>0,ve=U(()=>{let e=new Set,t=[];for(let n of[...ri(F),...O,...ue])e.has(n.id)||(e.add(n.id),!(n.id===`wiring`&&!_e)&&t.push(n));return t},[F,O,ue,_e]),be=U(()=>ve.some(e=>e.id===f)?f:`overview`,[ve,f]),Ce=z(e=>{d(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`),n},{replace:!0})},[d]),Ee=z(e=>{d(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[d]),De=(ae??[]).length>0,Oe=U(()=>ii.filter(({featureGate:e})=>!e||P.includes(e)),[P]),{data:R}=xe({addonId:N},{enabled:!!N&&N!==`rtsp`}),Ae=we({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]}),r(R?.id?`/integrations/${R.id}`:`/integrations`)}}),Ne=Ve({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Pe=Me({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Fe=He(),Ie=ce({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Le=P.includes(nt.Rebootable),Re=P.includes(nt.BatteryOperated),ze=g(l.trpcClient,Re&&n?t:null),[Be,Ue]=K(!1),We=ct(l.trpcClient,n?t:null),Ge=async()=>{if(!(Be||!We)){Ue(!0);try{await We.snapshot?.invalidateCache({});let e=await We.snapshot?.getSnapshot({});if(!e)return;let t=`data:${e.contentType};base64,${e.base64}`,n=e.contentType.includes(`png`)?`png`:`jpg`,r=j.replace(/[^a-zA-Z0-9_.-]+/g,`_`),i=new Date().toISOString().replace(/[:.]/g,`-`),a=document.createElement(`a`);a.href=t,a.download=`${r}-${i}.${n}`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}finally{Ue(!1)}}},Ke=Ne.isPending||Pe.isPending,{data:qe}=ye({deviceId:t},{enabled:n,refetchInterval:1e4}),V=qe?.agentNodeId??null,Je=typeof V==`string`&&V.length>0&&!V.startsWith(`addon:`)?V:void 0,{data:W}=ee({deviceId:t,...Je?{nodeId:Je}:{}},{enabled:n,refetchInterval:3e3,retry:!1}),{data:Ye}=h({deviceId:t},{enabled:n,refetchInterval:3e3,retry:!1}),J=Ye?.level?.dbfs??null;function Xe(){if(!n)return null;switch(be){case`overview`:return q(xr,{device:A??{}});case`config`:return q($n,{deviceId:t,activeSubTab:p,onSubTabChange:Ee});case`pipeline`:return q(ir,{deviceId:t,refreshToken:0});case`bindings`:return q(An,{deviceId:t});case`wiring`:return q(Qr,{deviceId:t});default:{let e=be,n=O.some(t=>t.id===e),r=ue.find(t=>t.id===e);if(!n&&r===void 0)return null;let i=r?.childDeviceId??t;if(e===`export`)return q(Qn,{deviceId:t,sectionFilter:zn,activeSubTab:p,onSubTabChange:Ee});let a=q(Qn,{deviceId:i,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),flattenSubTabs:e===`detection-pipeline`,activeSubTab:p,onSubTabChange:Ee});return r!==void 0&&i!==t?q(Se,{deviceId:i,children:a}):a}}}return n?T?H(`div`,{className:`flex flex-col h-full`,children:[H(`div`,{className:`border-b border-border bg-surface px-6 py-4`,children:[q(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),q(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),q(`div`,{className:`flex-1 p-6`,children:q(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):E||!w?H(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[q(`p`,{className:`text-lg font-semibold text-foreground`,children:`Device not found`}),H(`p`,{className:`text-xs`,children:[`No device with ID`,` `,H(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:[`#`,t]})]}),q(`button`,{onClick:()=>r(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]}):H(`div`,{className:`absolute inset-0 flex flex-col overflow-hidden`,children:[H(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[q(`div`,{className:`mb-2`,children:q(je,{items:[{label:`Integrations`,onClick:()=>r(`/integrations`)},{label:R?.name??N,onClick:()=>R?.id&&r(`/integrations/${R.id}`)},{label:j}]})}),H(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[q(gt,{type:N,size:`lg`}),H(`div`,{className:`min-w-0 flex-1`,children:[H(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[q(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:j}),q(Kt,{status:re}),Re&&q(_,{status:ze,variant:`full`})]}),de!==null&&pe&&H(`button`,{type:`button`,onClick:()=>r(`/devices/${de}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:`Open parent device ${pe.name}`,children:[q(`span`,{children:`↑`}),q(`span`,{className:`truncate`,children:String(pe.name??`Device #${de}`)})]}),q(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:P.length>0&&q(pt,{capabilities:P})})]}),W&&q(`div`,{className:`hidden lg:flex`,children:q(oi,{metrics:W,dbfs:J})}),H(`div`,{className:`flex items-center gap-1 shrink-0`,children:[H(`button`,{onClick:async()=>{me?await s({title:`Disable "${j}"?`,message:`The device will stop processing streams and events. You can re-enable it later.`,confirmLabel:`Disable`,variant:`danger`})&&Pe.mutate({deviceId:t}):Ne.mutate({deviceId:t})},disabled:Ke,title:me?`Disable device`:`Enable device`,className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 ${me?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[q(rn,{className:`h-3.5 w-3.5`}),q(`span`,{className:`hidden sm:inline`,children:Ke?`Updating…`:me?`Enabled`:`Disabled`})]}),q(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),q(Te,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:`Take snapshot`,description:`Fetch a fresh frame and download it.`,icon:kt,disabled:Be,onClick:()=>{Ge()}},{id:`reboot`,label:`Reboot device`,description:`Camera goes offline for ~30 seconds.`,icon:Ct,hidden:!Le,disabled:Fe.isPending,danger:!0,onClick:async()=>{await s({title:`Reboot "${j}"?`,message:`The camera will go offline for around 30 seconds while the firmware reboots.`,confirmLabel:`Reboot`,variant:`danger`})&&Fe.mutate({deviceId:t})}},{id:`restart-addon`,label:`Restart addon`,description:`Bounces every device served by ${R?.name??N}.`,icon:St,disabled:Ie.isPending,danger:!0,onClick:async()=>{await s({title:`Restart "${R?.name??N}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${j}"). Streams will reconnect automatically.`,confirmLabel:`Restart`,variant:`danger`})&&Ie.mutate({addonId:N})}},{id:`delete`,label:`Delete device`,description:`Remove the device and all its settings.`,icon:Ht,separatorBefore:!0,disabled:Ae.isPending,danger:!0,onClick:async()=>{await s({title:`Delete "${j}"?`,message:`This will remove the device and all its settings. This action cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&Ae.mutate({deviceId:t})}}]})]})]})]}),q(Se,{deviceId:t,device:A??void 0,children:q(o,{children:q(c,{children:q(dt,{children:q(ke,{children:H(`main`,{className:L?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[H(`div`,{className:L?`flex flex-col bg-surface`:`${b===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!L&&b!==null?{width:`${String(b)}px`}:void 0,children:[q(`div`,{className:ie?`flex-shrink-0 border-b border-border-subtle bg-black`:L?`flex-shrink-0 border-b border-border-subtle bg-surface`:`max-h-[55%] shrink-0 overflow-y-auto border-b border-border-subtle bg-surface`,children:ie?q(Tn,{deviceId:t,intercomAvailable:P.includes(nt.TwoWayAudio)}):q(gn,{deviceId:t,deviceName:j,deviceType:F??`unknown`,provider:N,isOnline:te,features:P})}),H(`div`,{className:L?`flex flex-col border-b border-border`:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[q(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:q(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:Oe.map(({id:e,label:t,icon:n})=>H(`button`,{onClick:()=>v(e),title:t,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${m===e?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[q(n,{className:`h-3 w-3`}),t]},e))})}),H(`div`,{className:L?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[m===`logs`&&q(En,{deviceId:t,containerDeviceId:F===`container`?t:void 0}),m===`repl`&&q(Dn,{deviceId:t}),m===`events`&&q(On,{deviceId:t}),m===`state`&&q(kn,{deviceId:t})]})]})]}),!L&&q(`div`,{role:`separator`,"aria-orientation":`vertical`,title:`Drag to resize`,onMouseDown:C,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:q(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),H(`div`,{className:L?`flex flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[q(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-4`,children:q(`div`,{className:`flex flex-nowrap overflow-x-auto md:flex-wrap md:overflow-x-visible items-center gap-0`,children:ve.map(e=>{let t=be===e.id;return H(`button`,{onClick:()=>Ce(e.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${t?`text-primary`:`text-foreground-subtle hover:text-foreground`}`,children:[e.label,t&&q(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},e.id)})})}),H(`div`,{className:L?`p-3 flex flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3`,children:[be===`overview`&&De&&q(on,{parentDeviceId:t}),Xe()]})]})]})})})})})})]}):H(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[q(`p`,{className:`text-lg font-semibold text-foreground`,children:`Invalid device id`}),H(`p`,{className:`text-xs`,children:[`The URL segment`,` `,q(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:e.deviceId}),` `,`is not a number.`]}),q(`button`,{onClick:()=>r(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]})}function oi({metrics:e,dbfs:t}){let n=p(e.phase??`idle`);return H(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[H(`div`,{className:`flex items-center gap-1.5`,children:[q(`span`,{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),q(`span`,{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),q(`div`,{className:`h-3 w-px bg-border`}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[q(Et,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:(e.actualFps??0).toFixed(1)}),q(`span`,{children:`fps`})]}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[q(zt,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:(e.avgInferenceTimeMs??0).toFixed(0)}),q(`span`,{children:`ms`})]}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:`Current audio level (dBFS)`,children:[q(an,{className:`h-3 w-3`}),q(`span`,{className:`text-foreground tabular-nums`,children:t==null?`—`:t.toFixed(0)}),q(`span`,{children:`dB`})]}),(e.queueDepth??0)>0&&H(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,e.queueDepth]})]})}export{ai as DeviceDetailPage};