@camstack/addon-admin-ui 1.2.529 → 1.2.531

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 (134) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/assets/{AddonAssetIcon-B1rn0DLw.js → AddonAssetIcon-Cp5zLEvD.js} +1 -1
  3. package/dist/assets/Addons-BES3OMn0.js +5 -0
  4. package/dist/assets/{AdminPage-DmkuRREx.js → AdminPage-D2S65e6Q.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-B_tSbkIV.js → AdminSectionedPage-CKX5JkdQ.js} +1 -1
  6. package/dist/assets/{AiProfiles-W2ByefcY.js → AiProfiles-BIQHK5vc.js} +1 -1
  7. package/dist/assets/{Build-BesaIcQt.js → Build-DjlUwtu8.js} +3 -3
  8. package/dist/assets/{Calendars-PHb_rEbJ.js → Calendars-Brkz06fF.js} +1 -1
  9. package/dist/assets/{Cluster-CnMcgkaB.js → Cluster-BtvDTlfe.js} +1 -1
  10. package/dist/assets/{ComposedDeviceEditDialog-DlxMQhZP.js → ComposedDeviceEditDialog-UYQVMVk7.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-Ctx6d-qx.js → CompositionBlockEditor-CYd3iEcq.js} +2 -2
  12. package/dist/assets/{CompositionEditorPage-CVp1OM-C.js → CompositionEditorPage-GtC8DYG6.js} +1 -1
  13. package/dist/assets/{Data-OpXlBhEa.js → Data-39SL2gbC.js} +1 -1
  14. package/dist/assets/{DeviceDetail-CUzPIb4E.js → DeviceDetail-C9eCLTmW.js} +2 -2
  15. package/dist/assets/{DeviceDoActionFields-D1rhgn3I.js → DeviceDoActionFields-Ca2TmJDn.js} +1 -1
  16. package/dist/assets/{Devices-DFfVPHVt.js → Devices-DwFifk2g.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-D0lVyXps.js → EmbedPlayerPage-D91A6i3P.js} +1 -1
  18. package/dist/assets/{FormBuilder-BvQZWKCS.js → FormBuilder-C01MTb_b.js} +1 -1
  19. package/dist/assets/{History-BLJJzgUt.js → History-OBh3harZ.js} +1 -1
  20. package/dist/assets/{Identity-B_TiHuO-.js → Identity-Bx-Ja-MP.js} +1 -1
  21. package/dist/assets/IntegrationDetail-TLO47L5-.js +1 -0
  22. package/dist/assets/{IntegrationHub-BvDB6bjh.js → IntegrationHub-C--hpDK-.js} +1 -1
  23. package/dist/assets/{Integrations-CK3qys8g.js → Integrations-Cm9BV3o8.js} +1 -1
  24. package/dist/assets/{Integrations-Xub2OY5T.js → Integrations-GHsM_7uc.js} +1 -1
  25. package/dist/assets/{Library-CO10lVu2.js → Library-D2EugVqE.js} +1 -1
  26. package/dist/assets/{Locations-CaL7Y2a3.js → Locations-Cb8RSNkt.js} +1 -1
  27. package/dist/assets/{Logs-Bu40SOPP.js → Logs-Gsq1EPYC.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-HJuLPIJP.js → MaskShapeCanvas-4rUt1muq.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-COMPKhfx.js → MotionZonesSettings-D8frKIxI.js} +1 -1
  30. package/dist/assets/{MyAccess-CNQzuYsW.js → MyAccess-WsIYje4M.js} +1 -1
  31. package/dist/assets/{Network-BBm6sZIX.js → Network-CjuJ-PkF.js} +1 -1
  32. package/dist/assets/{NodeAddonsSettingsPanel-DZwxKBXw.js → NodeAddonsSettingsPanel-DYEAw_0K.js} +1 -1
  33. package/dist/assets/{Notifications-BS4cbFH2.js → Notifications-DcpvQo5d.js} +1 -1
  34. package/dist/assets/Pipeline-CoNbGWDs.js +1 -0
  35. package/dist/assets/{PrivacyMaskSettings-C88JqmdE.js → PrivacyMaskSettings-LVUmj3W4.js} +1 -1
  36. package/dist/assets/Recordings-DeZnE3O5.js +1 -0
  37. package/dist/assets/RemoteGrid-CjSx3Aah.js +1 -0
  38. package/dist/assets/{ScanNetworkModal-SyHjZF2T.js → ScanNetworkModal-CvlBpDgq.js} +1 -1
  39. package/dist/assets/{SceneMonitorEditor-mE7W6emU.js → SceneMonitorEditor-CUgqZlLF.js} +1 -1
  40. package/dist/assets/SessionsList-CPlqGJSE.js +2 -0
  41. package/dist/assets/{Showroom-BS88iBLb.js → Showroom-CoWYMVAI.js} +1 -1
  42. package/dist/assets/{System-D-Xj3jc0.js → System-CqV_BBXI.js} +1 -1
  43. package/dist/assets/Templates-CMETwZM5.js +1 -0
  44. package/dist/assets/{Terminal-DhbVA89N.js → Terminal-BiuPjGjh.js} +5 -5
  45. package/dist/assets/{Trans-Bsz5Pghy.js → Trans-DlVN2FAm.js} +1 -1
  46. package/dist/assets/{Viewer-BTxcZ-BR.js → Viewer-VFeL3oiK.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CmowmspB.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BzI5prAS.js} +1 -1
  48. package/dist/assets/{addon-icons-context-DZZCjo9x.js → addon-icons-context-D_SbgBlL.js} +1 -1
  49. package/dist/assets/{archive-Bu9T4BL0.js → archive-BdOuJA6D.js} +1 -1
  50. package/dist/assets/{assignment-candidates-DWivr3bV.js → assignment-candidates-FrlfxULJ.js} +1 -1
  51. package/dist/assets/{authed-media-yW7W_8pm.js → authed-media-Cdlj2yED.js} +1 -1
  52. package/dist/assets/{bell-off-E0Abr7jJ.js → bell-off-DE260sCQ.js} +1 -1
  53. package/dist/assets/{board-model-CCD7fB3T.js → board-model-C8M8reLO.js} +1 -1
  54. package/dist/assets/{boxes-BkzsIUkw.js → boxes-ncBMqqF7.js} +1 -1
  55. package/dist/assets/circle-slash-bDMoAvuJ.js +1 -0
  56. package/dist/assets/{client-BvflqtP1.js → client-3nhKn2xf.js} +1 -1
  57. package/dist/assets/{cloud-upload-BIjzjy_K.js → cloud-upload-xWhkZB2K.js} +1 -1
  58. package/dist/assets/crop-BZhdHvRT.js +1 -0
  59. package/dist/assets/{device-integration-icon-D-OosuOg.js → device-integration-icon-DXsx1ovH.js} +1 -1
  60. package/dist/assets/device-picker-model-yyadLjpT.js +1 -0
  61. package/dist/assets/{dist-DoqhrZoo.js → dist-CxGqD88j.js} +1 -1
  62. package/dist/assets/{dist-Gm_hHBN2.js → dist-dKXZSA43.js} +1 -1
  63. package/dist/assets/{file-up-Cyg6A2qN.js → file-up-DSkaqgrs.js} +1 -1
  64. package/dist/assets/{format-ChSVChsY.js → format-5kuRrylR.js} +1 -1
  65. package/dist/assets/{grip-vertical-CLVyc1HC.js → grip-vertical-oBh5I9hk.js} +1 -1
  66. package/dist/assets/{hard-drive-download-Cd122TYb.js → hard-drive-download-BJ9Vaf4q.js} +1 -1
  67. package/dist/assets/{hostInit-DR1ykbVx.js → hostInit-ClzsOBVS.js} +1 -1
  68. package/dist/assets/{i18n-Bg2ooh3q.js → i18n-BTbD-8vc.js} +1 -1
  69. package/dist/assets/icons-B7ZVbtoQ.js +1 -0
  70. package/dist/assets/index-BGL4RiB2.css +2 -0
  71. package/dist/assets/{index-DMMw81r0.js → index-BoU7NTPo.js} +3 -3
  72. package/dist/assets/{key-D_zqd1r-.js → key-5z5CPQqC.js} +1 -1
  73. package/dist/assets/{key-round-pNw827HU.js → key-round-DE61GWtp.js} +1 -1
  74. package/dist/assets/{layers-CFNXRt4j.js → layers-DUXoEBYs.js} +1 -1
  75. package/dist/assets/{linked-devices-model-D9m6pafu.js → linked-devices-model-D76tAwE6.js} +1 -1
  76. package/dist/assets/{list-ordered-Dy6tCUD8.js → list-ordered-DSox6EY0.js} +1 -1
  77. package/dist/assets/{location-owned-usage-DasgH3RR.js → location-owned-usage-BSaNp20e.js} +1 -1
  78. package/dist/assets/{memory-stick-Bt2KoB-0.js → memory-stick-f2B4Aw1x.js} +1 -1
  79. package/dist/assets/{message-square-plus-rkd_X0vs.js → message-square-plus-DUwM59NW.js} +1 -1
  80. package/dist/assets/{mf-entry-bootstrap-0-dd19d57d.js → mf-entry-bootstrap-0-167f91f2.js} +2 -2
  81. package/dist/assets/{mic-off-DWb36TX2.js → mic-off-DpDwbFnF.js} +1 -1
  82. package/dist/assets/{monitor-off-B2GWMMt_.js → monitor-off-Cevi7ihB.js} +1 -1
  83. package/dist/assets/{monitor-smartphone-DJzvbVtx.js → monitor-smartphone-DPzM2qXf.js} +1 -1
  84. package/dist/assets/mount-yyadLjpT.js +1 -0
  85. package/dist/assets/{notification-schedule-field-B7FdiF_t.js → notification-schedule-field-B_Y6t98m.js} +1 -1
  86. package/dist/assets/{player-overlays-DpZIxQHp.js → player-overlays-D0HsTHUG.js} +1 -1
  87. package/dist/assets/{recycle-BWLoavmg.js → recycle-CK0-gO9v.js} +1 -1
  88. package/dist/assets/remoteEntry-CURqqH0d.js +1 -0
  89. package/dist/assets/{ruler-C1SbVRl3.js → ruler-C_9y2OuS.js} +1 -1
  90. package/dist/assets/{scan-eye-Bv4PGTFl.js → scan-eye-Cqs3dsDB.js} +1 -1
  91. package/dist/assets/{scissors-BsEkbrx_.js → scissors-BomV8klv.js} +1 -1
  92. package/dist/assets/{search-x-DE4DxdsF.js → search-x-Ck_vydrn.js} +1 -1
  93. package/dist/assets/{send-Dd0BBamd.js → send-B8Po_JT_.js} +1 -1
  94. package/dist/assets/{settings-2-z3X6U2eo.js → settings-2-CyAo_nYh.js} +1 -1
  95. package/dist/assets/shapes-CuqJ7CA_.js +1 -0
  96. package/dist/assets/{sigma-CxBVWJ85.js → sigma-YkVVm5dQ.js} +1 -1
  97. package/dist/assets/{speaker-Dy79a571.js → speaker-iL5Ep2q1.js} +1 -1
  98. package/dist/assets/{src-KDhMZ5Ob.js → src-D1j-98hX.js} +14 -14
  99. package/dist/assets/{sso-popup-BjTl8T6g.js → sso-popup-aQr_3YWW.js} +1 -1
  100. package/dist/assets/{step-inspector-model-DINPtCNq.js → step-inspector-model-gcGmLTWD.js} +1 -1
  101. package/dist/assets/{table-2-IUuOvuT8.js → table-2-Bx38akVK.js} +1 -1
  102. package/dist/assets/{timer-reset-D1H0hoMf.js → timer-reset-Z1XvH6K-.js} +1 -1
  103. package/dist/assets/{unlink-DTu1e00O.js → unlink-Dx9zRmL9.js} +1 -1
  104. package/dist/assets/{usb-CFK8z-TS.js → usb-_-9JyMyy.js} +1 -1
  105. package/dist/assets/{use-device-bound-caps-DS4FtJtN.js → use-device-bound-caps-BR0aNe6v.js} +1 -1
  106. package/dist/assets/{use-scenes-feed-CE-KFGxN.js → use-scenes-feed-CNxJKI3Y.js} +1 -1
  107. package/dist/assets/{use-stationary-objects-CFLRkxjx.js → use-stationary-objects-CFFufETF.js} +1 -1
  108. package/dist/assets/useEventInvalidation-yyadLjpT.js +1 -0
  109. package/dist/assets/{useNodeUrlSelection-A-NDcCsx.js → useNodeUrlSelection-zNi606-l.js} +1 -1
  110. package/dist/assets/user-round-BnFLdVEf.js +1 -0
  111. package/dist/assets/{user-x-KWsBR0tG.js → user-x-DCKuWnFc.js} +1 -1
  112. package/dist/assets/{variable-BG_qKWYf.js → variable-pzTTvzbo.js} +1 -1
  113. package/dist/assets/{video-D0guHpd1.js → video-Dn2Lqozt.js} +1 -1
  114. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-FCSZ5q7m.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-o917suSb.js} +2 -2
  115. package/dist/index.html +14 -14
  116. package/dist/server/addon.js +9 -2
  117. package/package.json +4 -1
  118. package/dist/assets/Addons-CZ_5JUVc.js +0 -5
  119. package/dist/assets/IntegrationDetail-DtTxTigM.js +0 -1
  120. package/dist/assets/Pipeline-BhNYn1U-.js +0 -1
  121. package/dist/assets/Recordings-B8VQL_Ik.js +0 -1
  122. package/dist/assets/RemoteGrid-CF92aN64.js +0 -1
  123. package/dist/assets/SessionsList-BD87Vhfu.js +0 -2
  124. package/dist/assets/Templates-D0V7IdcS.js +0 -1
  125. package/dist/assets/circle-slash-pdaivo-U.js +0 -1
  126. package/dist/assets/crop-CZJDrMcX.js +0 -1
  127. package/dist/assets/device-picker-model-2dkiqOI6.js +0 -1
  128. package/dist/assets/icons-BSJCF6qM.js +0 -1
  129. package/dist/assets/index-CyqhCHax.css +0 -2
  130. package/dist/assets/mount-2dkiqOI6.js +0 -1
  131. package/dist/assets/remoteEntry-CD4F7fE2.js +0 -1
  132. package/dist/assets/shapes-D-IaC6en.js +0 -1
  133. package/dist/assets/useEventInvalidation-2dkiqOI6.js +0 -1
  134. package/dist/assets/user-round-BSVSJsjB.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.529",
3
+ "version": "1.2.531",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -32,6 +32,9 @@
32
32
  "addons": [
33
33
  {
34
34
  "id": "admin-ui",
35
+ "execution": {
36
+ "placement": "hub-only"
37
+ },
35
38
  "category": "system",
36
39
  "name": "Admin UI",
37
40
  "icon": "assets/icon.svg",
@@ -1,5 +0,0 @@
1
- import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ai as d,Dn as f,Ei as p,Gn as m,Ht as h,Mn as g,Pt as _,Q as v,Qr as y,gn as b,gt as x,ki as S,ot as C,pi as w,pr as T,sn as E,st as ee,vn as D,xi as te,yn as ne,zt as re}from"./player-overlays-DpZIxQHp.js";import{Zo as O}from"./client-BvflqtP1.js";import{d as ie,i as k}from"./video-D0guHpd1.js";import{$i as ae,Bi as A,Ct as j,Er as oe,Gi as M,Gn as N,Hi as se,Ii as P,Ji as F,Jn as I,Ki as ce,Kn as L,Li as R,Mt as z,Oc as B,Pd as le,Pi as V,Qi as ue,Ri as de,Sr as fe,Tr as pe,Ui as me,Vi as H,Yi as he,Zi as ge,af as U,br as _e,cf as W,cn as ve,ea as ye,fi as G,ia as be,ii as K,na as xe,qi as Se,qn as Ce,ra as we,sn as Te,wr as Ee,xr as q,zd as De,zi as Oe}from"./src-KDhMZ5Ob.js";import{t as J}from"./Trans-Bsz5Pghy.js";import{t as Y}from"./useTranslation-BJr-n0es.js";import"./mount-2dkiqOI6.js";import{Q as X,et as ke}from"./index-DMMw81r0.js";import{t as Z}from"./AdminPage-DmkuRREx.js";import{t as Ae}from"./NodeAddonsSettingsPanel-DZwxKBXw.js";import{t as je}from"./framework-packages-B7oma9J4.js";import{n as Q,t as Me}from"./useNodeUrlSelection-A-NDcCsx.js";function Ne(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var Pe={queued:{icon:w,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:T,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:f,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:d,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:k,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Fe({item:e}){let{t:n}=Y(),r=Pe[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Ie=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Le=new Set([`done`,`failed`,`skipped`]);function Re(e){return!Le.has(e.phase)&&!Ie.has(e.jobState)}function ze(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ie.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 Be(){let{data:e}=ce({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=W(O.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return ze([...n.values()],Date.now())},[e,t])}var Ve={queued:{icon:w,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:T,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:T,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:d,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:k,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:E,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function He({progress:e}){let{t:n}=Y(),r=Ve[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Ue(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function We(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Ge(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(We)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Ke(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
3
- `)}var qe={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function Je(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${qe[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
4
- `)}var Ye={},Xe=3e4,Ze=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function Qe({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=Y(),c=l(),u=ee(),d=C(),f=M(Ye,{staleTime:Xe}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),g=Ue(p,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),v=we({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:Je(e,_),variant:e.success?`default`:`danger`})},b=async t=>{try{await y(await v.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:Ke(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(r.isHub?{}:{nodeId:r.id})},S=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Ue(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:Ge(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},w=v.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:w,className:Ze,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(h,{className:`h-3 w-3`}),v.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||i===!0||m.length>0)&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:w,className:Ze,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(ie,{className:`h-3 w-3`}),g.length>0?s(`addons.uninstallControls.everywhereCount`,{count:g.length}):s(`addons.uninstallControls.everywhere`)]})]})}function $e(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function et(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!$e(e))}function tt(e){return e.length-et(e,!1).length}c();function nt({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:f}=Y(),p=r===`upload`||r===`local`,[m,h]=s(!1),{data:g,isLoading:v,isError:b}=H({name:e}),S=g?et(g,m):[],C=g?tt(g):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:f(`addons.versionPicker.versions`,`Versions`)}),a(`button`,{type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(x,{className:`h-3 w-3`})})]}),p&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(_,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:f(`addons.versionPicker.inPlace`,{kind:r===`upload`?f(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):f(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(J,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),v&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(T,{className:`h-3.5 w-3.5 animate-spin`}),f(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),b&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:f(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),S.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:S.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),p=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:f(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),$e(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:f(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(`button`,{type:`button`,"aria-label":f(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[p,o?a(d,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[p,a(`button`,{type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?f(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):f(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(y,{className:`h-3 w-3`})})]},e.version)})}),!v&&!b&&g&&g.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:f(`addons.versionPicker.noVersionsFound`,`No versions found`)}),C>0&&a(K,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>h(e=>!e),children:m?f(`addons.versionPicker.hideOlder`,`Hide older versions`):f(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:C})})]})}c();var rt=`device-export`;function it(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===rt)}function at(e){return e!==`local`&&e!==`upload`}function ot({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,f=r&&i?v(`/api/addon-assets/${r}/${i}`):null,p=!!f&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:p?a(`img`,{src:f,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?m:g,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),at(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(_,{className:`h-2.5 w-2.5 text-white`})})]})}function st({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=Y();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(T,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(y,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(S,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(S,{className:`h-3 w-3 opacity-50`})]}),u]})}function ct({addonId:e}){let t=l(),{data:n=`inherit`}=R({addonId:e}),r=ae({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var lt={id:`hub`,name:`Hub`,isHub:!0};function ut({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,onUpdate:c,isUpdating:d,jobProgress:h,bundle:g,bulkItem:_,disabledByBulk:v,isSystem:y,selectedNode:C}){let{t:w}=Y(),[T,E]=s(!1),[ee,D]=s(!1),[te,re]=s(null);o(()=>{re(null)},[i]);let O=te??i,[ie,ae]=s(!1),[A,j]=s(!1),[M,N]=s(`logs`),P=l(),F=X(),{manifest:I}=e,ce=!g&&!I.protected&&I.removable!==!1,L=!!g,R=g?.displayName??I.name,B=g?.packageName??I.packageName,le=g?.version??I.packageVersion??I.version,V=g?.installSource??e.installSource,ue=g?g.bundle?.description??g.addons[0]?.manifest.description:I.description,de=he({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]})}}),me=se({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]}),P.invalidateQueries({queryKey:[[`integrations`]]})}}),H=ge({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`alerts`]]})}}),U=e.health,W=U?.phase===`failed`&&!U.inGracePeriod,ye=W&&U?.nextRetryAt&&!U.retrying,G=Ne(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${W?`border-red-500/50`:`border-border`}`,children:[W&&U&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:w(`addons.addonCard.failedToLoad`,{attempt:U.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:U.lastError?.message??w(`addons.addonCard.unknownError`,`Unknown error`)}),ye&&U.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:w(`addons.addonCard.autoRetryAt`,{time:new Date(U.nextRetryAt).toLocaleTimeString()})})]}),t(`button`,{type:`button`,disabled:H.isPending||U.retrying,onClick:e=>{e.stopPropagation(),H.mutate({packageName:B})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:w(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(f,{className:`h-3 w-3 ${H.isPending||U.retrying?`animate-spin`:``}`}),w(`addons.addonCard.retryNow`,`Retry now`)]})]}),G!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:w(`addons.addonCard.processProblem.${G.kind}`)}),G.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:G.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(ot,{isBundle:L||!!I.components&&I.components.length>1,installSource:V,addonId:L?g.addons[0]?.manifest.id:I.id,iconPath:L?g.bundle?.icon??g.addons[0]?.manifest.icon:I.icon,color:L?g.addons[0]?.manifest.color:I.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:R}),!r&&a(st,{version:le,availableUpdate:i,...O===void 0?{}:{selectedVersion:O},isUpdating:d,installSource:V,disabled:v,...c&&O!==void 0?{onUpdate:()=>c(O)}:{},onOpenPicker:()=>D(e=>!e),children:ee&&a(nt,{packageName:B,currentVersion:le,...V?{installSource:V}:{},...i!==void 0&&O!==void 0?{selectedVersion:O,onSelect:e=>{re(e),D(!1)}}:{},onInstall:e=>{D(!1),me.mutate({packageName:B,version:e})},onClose:()=>D(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[B!==R&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:B}),L&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(m,{className:`h-3 w-3`}),g.addons.length]}),y&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:w(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(f,{className:`h-3 w-3`}),w(`addons.addonCard.system`,`System`)]}),_!=null&&a(Fe,{item:_}),h!=null&&a(He,{progress:h})]}),ue&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:ue}),!L&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?w(`addons.addonCard.forked`):w(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:G===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!L&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),de.mutate({addonId:I.id})},disabled:de.isPending||v,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(f,{className:`h-3 w-3 ${de.isPending?`animate-spin`:``}`}),w(`addons.addonCard.restart`,`Restart`)]}),t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ae(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ie?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(ne,{className:`h-3 w-3`}),w(`addons.addonCard.logs`,`Logs`)]}),!L&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),j(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${A?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(b,{className:`h-3 w-3`}),w(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),ce&&a(Qe,{packageName:I.packageName,displayName:I.name,selectedNode:C??lt,disabled:v})]}),n&&n.nodes.length>1&&!L&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:w(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:w(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:w(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:w(`common.synced`)})]},e.nodeId))})]}),ie&&!L&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(`button`,{type:`button`,onClick:()=>N(`logs`),className:`px-2 py-0.5 transition-colors ${M===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.logs`,`Logs`)}),a(`button`,{type:`button`,onClick:()=>N(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${M===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ae(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(x,{className:`h-3.5 w-3.5`})})]}),M===`logs`&&a(ve,{addonId:I.id,maxHeight:`max-h-64`,showFilters:!1}),M===`events`&&a(Te,{addonId:I.id,category:`addon.*`,maxHeight:`max-h-64`})]}),L&&t(u,{children:[a(`button`,{type:`button`,onClick:()=>E(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(T?p:S,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),T&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>a(ut,{addon:e,hideVersion:!0},e.manifest.id))})]}),A&&!L&&a(_e,{open:!0,onOpenChange:e=>!e&&j(!1),children:t(fe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(pe,{children:t(oe,{className:`flex items-center gap-2`,children:[a(b,{className:`h-4 w-4 text-primary`}),w(`addons.addonCard.settingsTitle`,{name:R})]})}),t(q,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:w(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(Ae,{nodeId:null,addonIds:[I.id],level:`global`,fieldScope:`cluster`,emptyMessage:w(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),it(I)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.deviceExport`,`Device export`)}),a(z,{addonId:I.id,onOpenDevice:e=>F(`/devices/${e}`)})]}),at(V)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(ct,{addonId:I.id})]}),I.components&&I.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.components`,{count:I.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:I.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(Ee,{children:a(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>j(!1),children:w(`common.close`,`Close`)})})]})})]})}c();var dt=`.tgz,.tar.gz,.zip`;function ft({onUploadSuccess:e}){let{t:r}=Y(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(v(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(`input`,{ref:l,type:`file`,accept:dt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(`button`,{type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(T,{className:`w-3.5 h-3.5 animate-spin`}):a(_,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var pt=/```[^\n]*\n([\s\S]*?)```/g;function mt(e){let t=[],n=0;for(let r of e.matchAll(pt)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function ht(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function gt(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?ht(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function _t(e,t){let n=e.split(`
5
- `),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:gt(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:gt(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=gt(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function vt({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:mt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:_t(e.body,`b${t}`)},`text-${t}`))})}c();function yt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function bt(e,t,n){let r=et(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function xt({pending:e,failed:n,body:r,missing:i}){let{t:o}=Y();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(T,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(vt,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function St({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=Y(),[l,u]=s(e.version),[d,f]=s(!1),p=H({name:e.name}),m=A({name:e.name,version:l}),h=p.data??[],g=tt(h),_=bt(h,l,d),v=m.data;return a(_e,{open:!0,onOpenChange:e=>!e&&i(),children:t(fe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(pe,{children:a(oe,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:yt(e.name)})})}),t(q,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(le,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:$e(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(K,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(N,{defaultValue:`readme`,children:[t(Ce,{children:[a(I,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(I,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(L,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(xt,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(L,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(xt,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(Ee,{children:[a(K,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(K,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(T,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}var Ct=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function wt(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||Ct.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function Tt({selectedNode:e}){let{t:n}=Y(),{data:r}=M(Ye,{staleTime:Xe});if(r===void 0)return null;let i=wt(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(re,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(Qe,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function Et({addon:e,installing:n,onInstall:r}){let{t:i}=Y();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(G,{variant:`success`,icon:a(d,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(K,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(T,{className:`h-3 w-3 animate-spin`}):a(y,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Dt({capability:e,installing:n,onInstall:r}){let{t:i}=Y(),{data:o,isPending:s,isError:c}=ue({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(T,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(Et,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Ot(e){return e===`npm`||e===`dev`?e:null}var kt=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,At=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,jt=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Mt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Nt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Pt(e){return e===`local`?`dev`:`npm`}function Ft(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function It(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 Lt({addons:c,clusterStatus:u,selectedNode:d,onRefresh:p,listPhase:m}){let{t:h}=Y(),g=l(),[_,v]=s(``),b=e(_),[x,S]=s(!1),C=n(null);o(()=>{if(!x)return;let e=e=>{C.current&&!C.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]);let{data:w}=Se({nodeId:d.id}),E=r(()=>{let e=new Map;for(let t of w??[])e.set(t.name,t.latestVersion);return e},[w]),ne=r(()=>(w??[]).filter(e=>!e.isSystem).length,[w]),[re,O]=s(()=>new Set),[ie,k]=s(()=>new Map),ae=i(e=>{O(t=>new Set(t).add(e))},[]),A=i(e=>{O(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),j=i((e,t)=>{k(n=>new Map(n).set(e,t))},[]),oe=i(e=>{k(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),M=be({onMutate:e=>{ae(e.name),oe(e.name)},onSuccess:(e,t)=>{A(t.name);let n=e;if(n&&n.success===!1){j(t.name,n.error??`Update failed (no error message returned by server)`);return}g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{A(t.name),j(t.name,e instanceof Error?e.message:String(e))}}),N=Be(),P=n(new Set);o(()=>{let e=new Set;for(let[t,n]of N)Re(n)&&e.add(t);let t=[...P.current].some(t=>!e.has(t));P.current=e,t&&(g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[N,g]);let{data:F}=de(void 0),I=V({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),ce=ye({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:L,isFetching:R}=ue({query:b||void 0},{enabled:x}),z=xe(),{data:B}=Oe(void 0),le=B?.requestedAt,[fe,pe]=s(null),[me,H]=s(!1);o(()=>{if(B?.kind===`framework-bulk-update`&&B.requestedAt!==fe){pe(B.requestedAt),H(!0);let e=window.setTimeout(()=>H(!1),6e3);return()=>window.clearTimeout(e)}},[le,fe,B]),ee();let he=i(async()=>{let e=(w??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await M.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await z.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[w,d.id,d.isHub,z,M]),[ge,U]=s(null),[_e,W]=s(null),ve=e=>{W(null),U(e)},G=se({onSuccess:()=>{U(null),W(null),g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addonPages`]]}),g.invalidateQueries({queryKey:[[`capabilities`]]}),g.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{W(e instanceof Error?e.message:`Install failed`)}}),[K,Ce]=s(`type`),[we,Te]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Ee=e=>{Te(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[q,J]=ke(),X=q.get(`capability`),Z=q.get(`updatable`)===`1`,Ae=q.get(`error`)===`1`,Q=Ot(q.get(`source`)),Me=i(e=>{let t=new URLSearchParams(q);e?t.set(`updatable`,`1`):t.delete(`updatable`),J(t,{replace:!0})},[q,J]),Pe=i(e=>{let t=new URLSearchParams(q);e?t.set(`error`,`1`):t.delete(`error`),J(t,{replace:!0})},[q,J]),Fe=i(e=>{let t=new URLSearchParams(q);e===null?t.delete(`source`):t.set(`source`,e),J(t,{replace:!0})},[q,J]),Ie=r(()=>c.filter(e=>Ne(e.process)!==null).length,[c]),Le=r(()=>{let e=c.filter(e=>!je(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Nt(e.placement,d.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Z&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&E.has(t)})),Q!==null&&(e=e.filter(e=>Pt(e.installSource)===Q)),Ae&&(e=e.filter(e=>Ne(e.process)!==null)),e},[c,d.isHub,X,Z,Q,Ae,E]),ze=()=>{let e=new URLSearchParams(q);e.delete(`capability`),J(e,{replace:!0})},Ve=we===`flat`?Le:It(Le),He=r(()=>{let e=[...Ve];switch(K){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},[Ve,K]);return t(`div`,{className:`space-y-3`,children:[[...ie.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:h(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(`button`,{type:`button`,onClick:()=>oe(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:h(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.sort`,`Sort:`)}),t(`select`,{value:K,onChange:e=>Ce(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[a(`option`,{value:`type`,children:h(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:h(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:h(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(`button`,{type:`button`,onClick:()=>Ee(e),className:`px-2 py-1 transition-colors capitalize ${we===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?h(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):h(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(f,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(`button`,{type:`button`,onClick:()=>I.mutate({channel:e}),disabled:I.isPending,className:`px-2 py-1 transition-colors capitalize ${F?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.checkEvery`,`Check every:`)}),a(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:F?.updateCheckIntervalSeconds??21600,disabled:ce.isPending||F===void 0,onChange:e=>{F!==void 0&&ce.mutate({channel:F.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:jt.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ne>0&&t(`button`,{type:`button`,onClick:()=>void he(),disabled:z.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[z.isPending?a(T,{className:`w-3 h-3 animate-spin`}):a(y,{className:`w-3 h-3`}),z.isPending?h(`admin.system.addons.updating`,`Updating…`):h(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:ne})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":h(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.filter`,`Filter:`)}),[{id:`updatable`,label:h(`admin.system.addons.updatable`,`Updatable`),pressed:Z,toggle:()=>Me(!Z)},{id:`error`,label:h(`admin.system.addons.inError`,`In error ({{count}})`,{count:Ie}),pressed:Ae,toggle:()=>Pe(!Ae)},{id:`npm`,label:`npm`,pressed:Q===`npm`,toggle:()=>Fe(Q===`npm`?null:`npm`)},{id:`dev`,label:h(`admin.system.addons.dev`,`Dev`),pressed:Q===`dev`,toggle:()=>Fe(Q===`dev`?null:`dev`)}].map(e=>a(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?kt:At,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:C,children:[a(De,{type:`text`,searchHotkey:!0,value:_,onChange:e=>{v(e.target.value),S(!0)},onFocus:()=>S(!0),placeholder:h(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":h(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:z.isPending,leftSlot:a(D,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:R?a(T,{className:`h-3 w-3 animate-spin`}):void 0}),x&&L&&L.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[L.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:h(`systemPage.addons.npmResults`,{count:L.length})}),L&&L.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:L.map(e=>a(Et,{addon:e,installing:G.isPending,onInstall:e=>ve({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(ft,{onUploadSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),p()}})]}),X&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:h(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:X}),a(`button`,{type:`button`,onClick:ze,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:h(`admin.system.addons.clear`,`Clear`)})]}),X&&a(Dt,{capability:X,installing:G.isPending,onInstall:e=>ve({name:e.name,version:e.version,description:e.description})}),X&&Le.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:h(`admin.system.addons.installed`,`Installed`)}),me&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[a(te,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:h(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:h(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),m===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(T,{className:`h-3 w-3 animate-spin`}),h(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),m===`error`&&a(`div`,{className:`text-xs text-danger`,children:h(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),m===`ready`&&Le.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?h(`admin.system.addons.noAddonsInstalled`,`No addons installed`):X?h(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:X}):h(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),a(`div`,{className:`space-y-1.5`,children:m===`ready`&&He.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=E.get(t),r=$(e)?e.representative:e,i=n?e=>M.mutate({name:t,version:e,nodeId:d.id}):void 0,o=N.get(t)??null,s=o!==null&&Re(o);return a(ut,{addon:r,clusterStatus:u?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:re.has(t)||s,jobProgress:o,onUpdate:i,disabledByBulk:z.isPending,selectedNode:d},$(e)?t:e.manifest.id)})}),ge!==null&&a(St,{target:ge,installing:G.isPending,installError:_e,onClose:()=>U(null),onInstall:(e,t)=>G.mutate({packageName:e,version:t})})]})}function Rt(){let{t:e}=Y(),r=l(),{data:i}=B(void 0),{nodes:s}=U(),{selection:c,selectNode:u,requestedNodeId:d}=Me(s.length>0?s:[Mt]),p=c.node??Mt,m=p.id,h=s.length>0?c.staleNodeId:null,{data:g,isLoading:_,isError:v}=me({nodeId:m}),y=P(),b=F(),x=y.isPending||b.isPending,S=async()=>{await y.mutateAsync({nodeId:m}),await b.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},C=n(y);C.current=y;let w=n(d??`hub`);o(()=>{C.current.mutate({nodeId:w.current})},[]);let T=(g??[]).map(Ft).filter(e=>e!==null);return t(Z,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(j,{selectedNodeId:m,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!_&&!v&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:T.length})}),t(`button`,{type:`button`,onClick:()=>void S(),disabled:x,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(f,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(Q,{staleNodeId:h,shownNodeName:p.name}),a(Tt,{selectedNode:p}),a(Lt,{addons:T,clusterStatus:i,selectedNode:p,onRefresh:()=>void S(),listPhase:_?`pending`:v?`error`:`ready`})]})}export{Rt as AddonsPage};
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ai as l,An as u,Di as d,Dn as f,Gr as p,Ht as m,In as h,Kr as g,Tn as _,bt as v,dt as y,gn as b,ha as x,hi as S,ia as C,ki as w,pr as T,xi as E,yn as D,zt as O}from"./player-overlays-DpZIxQHp.js";import{eo as k}from"./client-BvflqtP1.js";import{t as A}from"./search-x-DE4DxdsF.js";import{Ai as j,Co as M,Cr as ee,Do as N,Er as te,Fa as ne,Fs as re,Ft as P,Go as F,Io as I,Is as L,Lt as R,Mn as z,Ms as ie,Na as B,Ns as V,Oo as ae,Pr as H,Ps as U,Pt as oe,Rs as se,Sn as ce,So as W,Sr as le,Tr as ue,Yi as G,Yn as de,Zn as fe,_o as K,bo as pe,br as me,cn as he,ef as ge,fr as q,go as J,ho as Y,if as _e,ii as ve,ja as ye,ji as be,jo as xe,js as Se,mo as X,qo as Ce,si as we,us as Te,vo as Ee,wr as De,xr as Oe,zd as Z}from"./src-KDhMZ5Ob.js";import{t as ke}from"./Trans-Bsz5Pghy.js";import{t as Q}from"./useTranslation-BJr-n0es.js";import{t as Ae}from"./FormBuilder-BvQZWKCS.js";import{n as je}from"./addon-icons-context-DZZCjo9x.js";import{$ as Me,Q as Ne,W as Pe,_ as Fe,et as Ie,v as Le,y as Re}from"./index-DMMw81r0.js";import{t as ze}from"./device-integration-icon-D-OosuOg.js";import{a as Be,i as Ve,r as He,t as Ue}from"./ScanNetworkModal-SyHjZF2T.js";import{t as We}from"./NodeAddonsSettingsPanel-DZwxKBXw.js";s();function Ge(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Ge(n.fields));return t}function Ke(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...Ge(n.fields));return t},[e]),d=u.length>0&&i!==void 0,f=r(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:r(async()=>{if(!i)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await i(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),s(`idle`)},[i,u,t]),clearProbeResult:f}}s();function qe(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...qe(n.fields));return t}function Je(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function $(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){$(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function Ye(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Xe({open:t,integrationId:s,addonId:l,onClose:u}){let{t:d}=Q(),f=c(),[p,m]=o({}),[h,g]=o(!1),[_,y]=o(null),[b,x]=o(Ye),S=F({addonId:l},{enabled:t}),C=S.data?.deviceType??null,E=xe({addonId:l,type:C??k.Camera},{enabled:t&&S.isSuccess&&C!==null}),A=E.data??null;a(()=>{t&&(m(A?$(A.sections.flatMap(e=>e.fields)):{}),x(Ye()),g(!1),y(null))},[t,s,A]);let j=n(()=>({...p,_probeRequestId:b}),[p,b]),M=W({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ee=Te(),N=r(async(e,t)=>{g(!0);let n=await ee.mutateAsync({addonId:l,type:C??k.Camera,key:e,value:t,formValues:j});return n.status===`ok`&&n.suggestedValues&&m(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))Je(e[i])&&!Je(a)&&(r[i]=a,t=!0);return t?r:e}),n},[ee,l,j,C]),{testAllStatus:ne,hasProbeFields:re,probeResults:P,handleTestAll:I,clearProbeResult:L}=Ke(A??{sections:[]},p,N);async function R(e){y(null);try{await M.mutateAsync({addonId:l,type:C??k.Camera,config:p,integrationId:s}),e?m(A?$(A.sections.flatMap(e=>e.fields)):{}):u()}catch(e){y(e instanceof Error?e.message:String(e))}}if(!t)return null;let z=qe((A?.sections??[]).flatMap(e=>e.fields)).filter(e=>Je(p[e])),ie=z.length===0,B=S.isLoading||C!==null&&E.isLoading,V=S.isError||S.isSuccess&&C===null||E.isError||E.isSuccess&&A===null;return i(me,{open:!0,onOpenChange:e=>{e||u()},children:e(le,{width:`lg`,scroll:`body`,children:[i(ue,{children:i(te,{children:d(`integrations.addDevice`)})}),i(Oe,{className:`space-y-3`,children:B?i(`div`,{className:`flex items-center justify-center py-8`,children:i(T,{className:`h-5 w-5 animate-spin text-primary`})}):V?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[i(O,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs font-medium text-destructive`,children:d(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(ke,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:l},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Ae,{schema:A,values:p,onChange:m,onTestField:N,probeResults:P,onClearProbe:L})}),!V&&!B&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(D,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:b.slice(0,14)})]}),i(w,{className:`h-3.5 w-3.5 transition-transform ${h?`rotate-180`:``}`})]}),h&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(he,{addonId:l,requestId:b,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!V&&!B&&(_||z.length>0)&&i(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(O,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:_||d(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:z.join(`, `)})})]})}),e(De,{className:`justify-between`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:u,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:d(`integrations.cancel`)}),!V&&re&&e(`button`,{type:`button`,onClick:I,disabled:ne===`testing`,className:`inline-flex items-center gap-1.5 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 disabled:opacity-50`,children:[ne===`testing`?i(T,{className:`h-3.5 w-3.5 animate-spin`}):i(v,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:()=>R(!0),disabled:V||!ie||M.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:d(`integrations.saveAndNew`)}),i(`button`,{onClick:()=>R(!1),disabled:V||!ie||M.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:M.isPending?d(`integrations.saving`):d(`integrations.save`)})]})]})]})})}s();var Ze=`matter`,Qe=[`discovering`,`pase`,`commissioning`,`done`];function $e(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function et(e,t){return e===`code-expired`||t?.includes(`matter-commission:code-expired`)?{key:`integrations.addMatter.failure.expired`,defaultValue:`The pairing code expired. Share the device again and paste the new code.`}:e===`device-not-found`||t?.includes(`matter-commission:device-not-found`)?{key:`integrations.addMatter.failure.notFound`,defaultValue:`No Matter device with that code was found on the network.`}:e===`wrong-code`||t?.includes(`matter-commission:wrong-code`)?{key:`integrations.addMatter.failure.wrongCode`,defaultValue:`The pairing code was rejected.`}:e===`invalid-code`||t?.includes(`invalid pairing code`)?{key:`integrations.addMatter.failure.invalid`,defaultValue:`Enter an 11-digit or 21-digit manual code, or a code that starts with MT:.`}:{key:`integrations.addMatter.failure.unknown`,defaultValue:t??`Commissioning failed.`}}function tt({onClose:t,onCommissioned:n}){let{t:r}=Q(),s=B({kind:Ze}),[c,l]=o(null),u=s.data?.length??0,d=c??s.data?.[0]?.id??null,f=ne(),[p,m]=o(``),[h,g]=o({phase:`idle`,failure:null,message:null}),_=h.phase===`discovering`||h.phase===`pase`||h.phase===`commissioning`,v=ye({brokerId:d??``,key:`commission`},{enabled:d!==null&&_,refetchInterval:_?400:!1});a(()=>{_&&$e(v.data)&&v.data.phase!==`idle`&&g({phase:v.data.phase,failure:typeof v.data.failure==`string`?v.data.failure:null,message:typeof v.data.message==`string`?v.data.message:null})},[_,v.data]);let y=()=>{d!==null&&(g({phase:`discovering`,failure:null,message:null}),f.mutate({brokerId:d,target:{action:`commissionNode`},payload:{pairingCode:p.trim()}},{onSuccess:()=>g({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;g({phase:`failed`,failure:t.includes(`matter-commission:`)?t.split(`matter-commission:`)[1]?.split(`:`)[0]??`unknown`:t.includes(`invalid pairing code`)?`invalid-code`:`unknown`,message:t})}}))},b=h.phase===`failed`?et(h.failure,h.message):null,x=b===null?null:r(b.key,{defaultValue:b.defaultValue}),S=(s.isSuccess===!0||s.data!==void 0)&&d===null;return i(me,{open:!0,onOpenChange:e=>!e&&t(),children:e(le,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(ue,{children:i(te,{children:r(`integrations.addMatter.title`,{defaultValue:`Add Matter device`})})}),e(Oe,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.addMatter.help`,{defaultValue:`In Home Assistant, open the device and choose Share device. Paste the numeric code or the MT: code here. The device stays in Home Assistant.`})}),(S||u>1)&&!_&&h.phase!==`done`&&e(`div`,{className:`space-y-1.5`,children:[i(fe,{children:r(`integrations.addMatter.broker`,{defaultValue:`Matter fabric`})}),i(Pe,{kind:Ze,value:d,onChange:l})]}),!S&&e(`div`,{className:`space-y-1.5`,children:[i(fe,{htmlFor:`matter-pairing-code`,children:r(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(Z,{id:`matter-pairing-code`,value:p,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:_||h.phase===`done`,onChange:e=>m(e.target.value)})]}),h.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":r(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:Qe.map(t=>{let n=h.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&_?i(T,{className:`mr-1 inline h-3 w-3 animate-spin`}):null,r(`integrations.addMatter.phase.${t}`,{defaultValue:t===`discovering`?`Discovering`:t===`pase`?`PASE`:t===`commissioning`?`Commissioning`:`Done`})]},t)})}),x!==null&&i(H,{message:x})]}),e(De,{children:[i(ve,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),h.phase===`done`?i(ve,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(ve,{size:`sm`,disabled:_||S||p.trim().length===0,onClick:y,children:_?r(`integrations.addMatter.working`,{defaultValue:`Adding…`}):r(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})})}var nt=1500;function rt({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=Q(),s=X(),c=(K({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?nt:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,d=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let f=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&f.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&f.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&f.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let p=f.join(` · `);return e(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[l?i(T,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(O,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(S,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(E,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:p}),l&&i(`button`,{onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),c.results.filter(e=>e.outcome===`failed`).slice(0,5).map(t=>e(`p`,{className:`text-[11px] text-destructive`,children:[t.childNativeId,`: `,t.error]},t.childNativeId))]})}function it(e){let t=e.map(e=>({...e,stableId:e.childNativeId})),n=new Map(e.map(e=>[e.childNativeId,e])),r=(e,t)=>e.flatMap(e=>{let i=n.get(e.candidate.childNativeId);return i===void 0?[]:[{candidate:i,depth:t},...r(e.children,t+1)]});return r(Be(t),0)}function at(e){let t=e.metadata?.model,n=e.childNativeId.split(`:`).pop()??``;return[typeof t==`string`?t:``,n].filter(e=>e.length>0).join(` · `)}function ot(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}s();var st=`devices`;function ct(e){return{id:st,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var lt=2e4,ut=100;function dt({addonId:s,integrationId:u,onClose:d}){let f=x(),{t:p}=Q(),m=c(),[h,g]=o(new Set),[v,y]=o(new Set),[b,S]=o(new Map),[C,w]=o(null),{data:E}=V(),D=(E??[]).find(e=>e.addonId===s)?.supportsLocationImport??!1,[k,A]=o(!0),j=Y({addonId:s,integrationId:u}).data?.filters,M=j&&j.length>0?j:[ct(p)],[N,ne]=o(M.find(e=>e.isDefault)?.id??(M.some(e=>e.id===st)?st:M[0].id)),re=N!==st,P=Ee(),F=J({addonId:s,integrationId:u,page:1,pageSize:lt,filter:N}),I=F.refetch,L=P.mutate,R=r(()=>{L({addonId:s,integrationId:u},{onSettled:()=>{I()}})},[L,s,u,I]),z=t(null);a(()=>{let e=`${s}::${u}`;z.current===e||F.isLoading||(z.current=e,(F.data?.candidates.length??0)===0&&R())},[s,u,F.isLoading,F.data,R]);let ie=P.isPending,B=P.isError?P.error instanceof Error?P.error.message:String(P.error):null,ae=typeof P.data?.lastError==`string`&&P.data.lastError.length>0?P.data.lastError:null,H=F.data?.candidates??[],U=n(()=>it(H),[H]),se=n(()=>new Map(U.map(e=>[e.candidate.childNativeId,e.depth])),[U]),ce=F.isError?F.error instanceof Error?F.error.message:String(F.error):null,W=pe(),[G,de]=o(null),fe=r(e=>{e.alreadyAdopted||g(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),K=r(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),he=r((e,t)=>{S(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),q=r(e=>{let t={};for(let n of e){let e=b.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[b]),ye=r(async()=>{w(null);let e=[...h];if(e.length!==0)try{let t=q(e),{jobId:n}=await W.mutateAsync({addonId:s,integrationId:u,filter:N,childNativeIds:e,...t?{perCandidate:t}:{},...D?{importLocations:k}:{}});de(n),g(new Set),S(new Map)}catch(e){w(e instanceof Error?e.message:String(e))}},[h,q,W,s,u,N,D,k]),be=t(null),xe=r(()=>{G===null||be.current===G||(be.current=G,I(),m.invalidateQueries({queryKey:[[`integrations`]]}),m.invalidateQueries({queryKey:[[`deviceManager`]]}))},[G,I,m]),Se=r(e=>{ne(e),g(new Set),y(new Set),S(new Map),w(null)},[]),X=h.size,Ce=G!==null&&X===0&&!W.isPending;return i(me,{open:!0,onOpenChange:e=>{e||d()},children:e(le,{width:`xl`,scroll:`body`,className:`md:h-[85vh]`,children:[e(ue,{children:[i(te,{children:p(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),i(ee,{children:p(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})}),D&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(`input`,{type:`checkbox`,checked:k,onChange:e=>A(e.target.checked),className:`accent-primary`}),p(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]})]}),e(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2 overflow-hidden`,children:[(B??ce??ae)&&H.length===0&&i(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(O,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-destructive`,children:p(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:B??ce??ae})]})]})}),M.length>1&&i(ft,{filters:M,activeFilter:N,onSelect:Se}),i(`div`,{className:`flex-1 min-h-0`,children:i(oe,{mode:`generic`,items:U.map(e=>e.candidate),pageSize:ut,getKey:e=>e.childNativeId,getSearchText:ot,getFilterType:e=>e.type,filterOptions:ge(f),filterLabel:p(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:F.isLoading||ie&&H.length===0,searchPlaceholder:p(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(B??ce??ae)&&H.length===0?``:p(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(`button`,{type:`button`,onClick:R,disabled:ie,title:p(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(_,{className:`h-3.5 w-3.5 ${ie?`animate-spin`:``}`}),p(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:p(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>i(pt,{candidate:e,depth:se.get(e.childNativeId)??0,expandable:!re,expanded:v.has(e.childNativeId),onToggleExpand:()=>K(e.childNativeId),adoptedLabel:p(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:p(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=_e(t.type,f),r=n.icon;return e(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),n.label]})}},{key:`select`,header:``,headerClassName:`w-[15%] text-right`,cellClassName:`text-right`,cell:e=>i(`div`,{className:`flex items-center justify-end`,children:i(`button`,{onClick:()=>fe(e),disabled:e.alreadyAdopted,"aria-label":h.has(e.childNativeId)?p(`integrations.adoptDevicesModal.deselect`,`Deselect`):p(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${h.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:h.has(e.childNativeId)&&i(l,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!re&&v.has(e.childNativeId),renderExpanded:re?void 0:e=>i(mt,{candidate:e,hiddenChildIds:b.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>he(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:h.has(e.childNativeId)?`bg-primary/5`:``})})]}),C&&i(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(O,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:C})]})}),G!==null&&i(rt,{addonId:s,integrationId:u,jobId:G,onFinished:xe}),e(De,{children:[i(ve,{variant:`outline`,size:`sm`,onClick:d,children:p(`integrations.cancel`,{defaultValue:`Cancel`})}),e(ve,{variant:`primary`,size:`sm`,onClick:Ce?d:ye,disabled:!Ce&&(X===0||W.isPending),children:[W.isPending&&i(T,{className:`h-3.5 w-3.5 animate-spin`}),Ce?p(`integrations.close`,{defaultValue:`Close`}):p(`integrations.addSelected`,{defaultValue:`Add selected`}),!Ce&&X>0?` (${X})`:``]})]})]})})}function ft({filters:e,activeFilter:t,onSelect:n}){let{t:r}=Q();return i(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return i(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function pt({candidate:t,depth:n,expandable:r,expanded:a,onToggleExpand:o,adoptedLabel:s}){let{t:c}=Q(),l=(t.children??[]).length,u=at(t);return e(`div`,{className:`flex items-center gap-2.5 min-w-0 ${n>0?`pl-5`:``}`,children:[r&&l>0?e(`button`,{type:`button`,onClick:o,"aria-label":a?c(`integrations.adoptDevicesModal.collapse`,`Collapse`):c(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":a,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[i(a?w:d,{className:`h-3.5 w-3.5`}),l]}):i(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center text-foreground-subtle/40`,children:`—`}),i(`span`,{className:`truncate text-xs font-medium text-foreground`,children:t.name}),u.length>0&&i(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:u}),t.alreadyAdopted&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:s})]})}function mt({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=Q(),o=t.children??[];return o.length===0?null:i(`div`,{className:`space-y-1 py-1`,children:o.map(t=>{let o=n.has(t.childNativeId),s=t.capabilities??[];return e(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${o?`opacity-50`:``}`,children:[i(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:t.name}),s.length>0&&i(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:s.join(`, `)}),i(`button`,{onClick:()=>r(t.childNativeId),"aria-label":o?a(`integrations.adoptDevicesModal.showChild`,`Show child`):a(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:o?a(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):a(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:i(o?g:p,{className:`h-3 w-3`})})]},t.childNativeId)})})}s();function ht(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...ht(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function gt(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>ht(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function _t(e){return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{if(`value`in e){let{value:t,...n}=e;return n}return e})}))}}function vt({integrationId:t,addonId:r,name:a,kind:o,mode:s,brokerKind:l,canTest:u=!1,trpc:d,onClose:f}){let{t:p}=Q(),m=c(),{data:h,isLoading:g}=U({id:t},{enabled:s===`account`||s===`broker`}),_=n(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:y}=j({addonId:r,nodeId:`hub`},{enabled:s===`account`}),b=n(()=>v?_t(v):null,[v]),x=L(),S=(e,n)=>{x.mutate({id:t,settings:e,...n?{secretKeys:[...n]}:{}},{onSuccess:()=>{m.invalidateQueries(),f()}})};return i(me,{open:!0,onOpenChange:e=>!e&&f(),children:e(le,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(ue,{children:e(te,{children:[p(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,a]})}),i(Oe,{children:s===`broker`?l?e(`div`,{className:`space-y-3`,children:[i(`p`,{className:`text-[11px] text-foreground-subtle`,children:p(`integrations.relinkBrokerHelp`,{defaultValue:`Choose the broker this integration connects through. Picking a different broker re-points it and restarts the addon.`})}),_&&e(`p`,{className:`text-[11px] text-foreground`,children:[p(`integrations.currentBroker`,{defaultValue:`Current broker`}),`:`,` `,i(`span`,{className:`font-mono text-foreground-subtle`,children:_})]}),x.isPending?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(T,{className:`h-3 w-3 animate-spin`}),p(`integrations.saving`,{defaultValue:`Saving…`})]}):i(Ve,{kind:l,onResolved:e=>{S({brokerId:e})},onBack:f}),x.isError&&i(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.relinkFailed`,{defaultValue:`Failed to update broker link.`})})]}):i(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.noBrokerKind`,{defaultValue:`This integration declares device-adoption but its addon manifest has no brokerKind.`})}):s===`account`?g||y?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(T,{className:`h-3 w-3 animate-spin`}),p(`integrations.loading`,{defaultValue:`Loading…`})]}):i(He,{addonId:r,configSchema:b,canTest:u,initialName:a,initialConfig:gt(b,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e,secretKeys:t})=>S(e,t),onBack:f}):i(q,{trpc:d,addonId:r,nodeId:`hub`,title:a})})]})})}function yt(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}s();function bt(){let{addonId:e=``}=Me();return i(St,{addonId:e})}function xt(){return e(`div`,{className:`p-4`,children:[i(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),i(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]})}function St({addonId:t}){let{t:s}=Q(),l=c(),d=Ne(),[p,g]=Ie(),_=y(),[v,x]=o(!1),[S,w]=o(!1),[E,O]=o(!1),k=r(e=>{O(!1),d(`/integrations`,{state:{integrationSeed:e}})},[d]),[ee,ne]=o(!1),[F,L]=o(!1),{data:B}=re(void 0),H=n(()=>(B??[]).filter(e=>e.addonId===t),[B,t]),U=Re(p.get(`instance`),H)??``,W=r(e=>{g(t=>{let n=new URLSearchParams(t);return n.set(Fe,e),n},{replace:!0})},[g]),fe=n(()=>H.map(e=>({value:e.id,label:e.name})),[H]),{data:K,isLoading:pe}=ie({id:U},{enabled:!!U}),{data:ge}=j({addonId:K?.addonId??``,nodeId:`hub`},{enabled:!!K?.addonId}),{data:q,isSuccess:J}=V(),Y=n(()=>{let e=K?.addonId;return!e||!J?null:(q??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[q,K?.addonId,J]),{data:_e}=N({}),ve=n(()=>(_e?.providers??[]).some(e=>e.addonId===K?.addonId),[_e,K?.addonId]),ye=Y!==null,xe=K?.info?.fixed===!0,X=n(()=>{let e=K?.addonId;return!e||!J?null:(q??[]).find(t=>t.addonId===e)?.brokerKind??null},[q,K?.addonId,J]),Te=X===`matter`,Ee=ye?Te?s(`integrations.addMatter.title`,{defaultValue:`Add Matter device`}):Y===`device-adoption`?s(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):s(`integrations.addDevice`):s(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),De=n(()=>{let e=K?.addonId;return!e||!J?!1:(q??[]).find(t=>t.addonId===e)?.canTest===!0},[q,K?.addonId,J]),Z=n(()=>{let e=K?.addonId;return!e||!J?null:(q??[]).find(t=>t.addonId===e)?.mode??null},[q,K?.addonId,J]);a(()=>{p.get(`add`)===`1`&&ye&&(w(!1),x(!0),g(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[p,ye,g]);let ke=ge!=null&&Array.isArray(ge.sections)&&ge.sections.some(e=>e.fields.length>0),{data:Ae}=be({addonId:K?.addonId??``,nodeId:`hub`},{enabled:!!K?.addonId&&Z!==`account`}),je=Z!==null&&Z!==`account`&&yt(Ae),Me=n(()=>K?.addonId?[K.addonId]:[],[K?.addonId]),{data:Pe}=I({projection:`slim`},{refetchInterval:3e4}),Be=[[`integrations`,`get`],{input:{id:U},type:`query`}],Ve=se({onMutate:async e=>{await l.cancelQueries({queryKey:Be});let t=l.getQueryData(Be);return t!=null&&l.setQueryData(Be,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&l.setQueryData(Be,r.previous)},onSettled:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),He=Se({onSuccess:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]}),d(H.length>1?Le(t):`/integrations`)}}),Ge=G({onSuccess:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ke=Ce({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),qe=M({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Je=ae({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),$=n(()=>Pe??[],[Pe]),Ye=n(()=>{let e=new Map;for(let t of $)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[$]),Ze=r(e=>Ye.get(e)??null,[Ye]),Qe=n(()=>P(B),[B]),$e=r(e=>d(`/devices/${String(e)}`),[d]),et=n(()=>$.filter(e=>{let t=Qe(e);return t.kind===`resolved`&&t.integration.id===U}),[$,U,Qe]),nt=n(()=>B===void 0?null:R(et).length,[B,et])??`…`;if(pe||B===void 0)return i(xt,{});let rt=(q??[]).find(e=>e.addonId===t)?.name??K?.name??t;return K?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(z,{items:[{label:s(`integrationDetail.integrations`,`Integrations`),onClick:()=>d(`/integrations`)},{label:rt}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(Ct,{addonId:K.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:rt}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[nt,` `,s(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[ve&&e(`button`,{onClick:()=>O(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:s(`integrationDetail.scanTheNetworkForDevices`,`Scan the network for devices (incl. a different subnet)`),children:[i(u,{className:`h-3.5 w-3.5`}),s(`integrationDetail.scanNetwork`,`Scan network`)]}),!xe&&e(`button`,{onClick:()=>{w(!1),x(!0)},disabled:!ye,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:Ee,children:[i(h,{className:`h-3.5 w-3.5`}),Ee]}),e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ve.isPending?`opacity-60`:``} ${K.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:s(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(de,{checked:K.enabled,onCheckedChange:e=>Ve.mutate({id:U,enabled:e}),disabled:Ve.isPending,"aria-label":K.enabled?s(`integrationDetail.disableIntegration`,`Disable integration`):s(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${K.enabled?`text-success`:`text-foreground-subtle`}`,children:K.enabled?s(`integrationDetail.enabled`,`Enabled`):s(`integrationDetail.disabled`,`Disabled`)}),Ve.isPending&&i(T,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),Z!==`standalone`&&(ke||Y===`device-adoption`)&&e(`button`,{onClick:()=>ne(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[i(b,{className:`h-3 w-3`}),s(`integrations.config`)]}),e(`button`,{onClick:()=>L(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:s(`integrations.logs`,{defaultValue:`View logs`}),children:[i(D,{className:`h-3 w-3`}),s(`integrations.logs`,{defaultValue:`Logs`})]}),i(ce,{label:s(`integrationDetail.restart`,`Restart`),icon:f,title:s(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:K.name}),description:s(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:nt}),confirmLabel:s(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Ge.isPending,action:()=>Ge.mutateAsync({addonId:K.addonId})}),!xe&&U&&i(ce,{label:s(`integrations.delete`,{defaultValue:`Delete`}),icon:m,title:s(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:s(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:K.name,count:nt}),confirmLabel:s(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:He.isPending,action:()=>He.mutateAsync({id:U})})]})]}),H.length>1&&i(`div`,{className:`max-w-sm`,children:i(we,{mode:`single`,singleDisplay:`field`,label:s(`integrationDetail.instances`,`Integration`),options:fe,value:U,onChange:W,testId:`integration-instance-picker`,optionTestIdPrefix:`integration-instance`})}),je&&i(We,{nodeId:null,addonIds:Me,level:`global`,surface:`integration`,title:s(`integrations.settings`,{defaultValue:`Settings`})}),i(oe,{context:`integration-detail`,devices:$,trpc:_.trpcClient,integrationOf:Qe,forceIntegrationId:U,urlScope:`root`,lsKey:`integration-detail:${K.addonId}`,resolveIntegrationIcon:ze,resolveParent:Ze,onNavigate:$e,batchActions:{remove:Ke.mutate,disable:qe.mutate,enable:Je.mutate},...xe?{}:{onDeleteDevice:e=>Ke.mutate({deviceId:e.id})}}),v&&U&&Te&&!S&&i(tt,{onClose:()=>x(!1),onCommissioned:()=>w(!0)}),v&&U&&Y===`device-adoption`&&(!Te||S)&&i(dt,{addonId:K.addonId,integrationId:U,onClose:()=>{x(!1),w(!1)}}),v&&U&&Y===`device-provider`&&i(Xe,{open:v,integrationId:U,addonId:K.addonId,onClose:()=>x(!1)}),E&&K&&i(Ue,{open:E,scope:{addonId:K.addonId,label:K.name},onClose:()=>O(!1),onSetupIntegration:k}),ee&&U&&Y!==null&&Z!==null&&i(vt,{integrationId:U,addonId:K.addonId,name:K.name,kind:Y,mode:Z,brokerKind:X,canTest:De,trpc:_.trpcClient,onClose:()=>ne(!1)}),F&&i(me,{open:!0,onOpenChange:e=>!e&&L(!1),children:e(le,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(ue,{className:`mb-0`,children:e(te,{className:`flex items-center gap-2 min-w-0`,children:[i(D,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:K.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[K.addonId,U?` · ${U}`:``]})]})}),i(Oe,{className:`min-h-0 overflow-hidden p-0`,children:i(he,{addonId:K.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(A,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:s(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:t})})]}),e(`button`,{onClick:()=>d(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[i(C,{className:`h-3 w-3`}),s(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function Ct({addonId:e}){let t=je(e),[n,r]=o(!1);return!t||n?null:i(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>r(!0)})}export{bt as IntegrationDetailPage};