@camstack/addon-admin-ui 1.2.528 → 1.2.529

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 (56) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/assets/{Addons-jOEeQSpu.js → Addons-CZ_5JUVc.js} +1 -1
  3. package/dist/assets/{AdminSectionedPage-DuWHEheV.js → AdminSectionedPage-B_tSbkIV.js} +1 -1
  4. package/dist/assets/{AiProfiles-BEeNwF2L.js → AiProfiles-W2ByefcY.js} +1 -1
  5. package/dist/assets/{Build-Co5ZdxuK.js → Build-BesaIcQt.js} +1 -1
  6. package/dist/assets/{Calendars-BtDHWxd-.js → Calendars-PHb_rEbJ.js} +1 -1
  7. package/dist/assets/{Cluster-BIBo49N1.js → Cluster-CnMcgkaB.js} +1 -1
  8. package/dist/assets/{ComposedDeviceEditDialog-B4GFluaT.js → ComposedDeviceEditDialog-DlxMQhZP.js} +1 -1
  9. package/dist/assets/{CompositionBlockEditor-BpvjitmC.js → CompositionBlockEditor-Ctx6d-qx.js} +1 -1
  10. package/dist/assets/{CompositionEditorPage-dKqEx-JR.js → CompositionEditorPage-CVp1OM-C.js} +1 -1
  11. package/dist/assets/{Data-RjeL53U1.js → Data-OpXlBhEa.js} +1 -1
  12. package/dist/assets/{DeviceDetail-eIrghHfV.js → DeviceDetail-CUzPIb4E.js} +1 -1
  13. package/dist/assets/{DeviceDoActionFields-NGMXRetO.js → DeviceDoActionFields-D1rhgn3I.js} +1 -1
  14. package/dist/assets/{Devices-BGUXCPk6.js → Devices-DFfVPHVt.js} +1 -1
  15. package/dist/assets/{FormBuilder-C-ti9Mun.js → FormBuilder-BvQZWKCS.js} +1 -1
  16. package/dist/assets/{History-DFE__TwY.js → History-BLJJzgUt.js} +1 -1
  17. package/dist/assets/{Identity-xGpm6dM2.js → Identity-B_TiHuO-.js} +1 -1
  18. package/dist/assets/IntegrationDetail-DtTxTigM.js +1 -0
  19. package/dist/assets/{IntegrationHub-zoj_qUVu.js → IntegrationHub-BvDB6bjh.js} +1 -1
  20. package/dist/assets/{Integrations-BgOMB--y.js → Integrations-CK3qys8g.js} +1 -1
  21. package/dist/assets/{Integrations-Dnahdxh6.js → Integrations-Xub2OY5T.js} +1 -1
  22. package/dist/assets/{Library-Dta_WXbr.js → Library-CO10lVu2.js} +1 -1
  23. package/dist/assets/{Locations-qtdnIjEQ.js → Locations-CaL7Y2a3.js} +1 -1
  24. package/dist/assets/{Logs-DY8msvrb.js → Logs-Bu40SOPP.js} +1 -1
  25. package/dist/assets/{MyAccess-ayWZOTHE.js → MyAccess-CNQzuYsW.js} +1 -1
  26. package/dist/assets/{Network-DDRo1U4A.js → Network-BBm6sZIX.js} +1 -1
  27. package/dist/assets/{NodeAddonsSettingsPanel-Bin3whKR.js → NodeAddonsSettingsPanel-DZwxKBXw.js} +1 -1
  28. package/dist/assets/{Notifications-DxWf70ir.js → Notifications-BS4cbFH2.js} +1 -1
  29. package/dist/assets/{Pipeline-B1zEi2hO.js → Pipeline-BhNYn1U-.js} +1 -1
  30. package/dist/assets/{Recordings-BQZ9OaK2.js → Recordings-B8VQL_Ik.js} +1 -1
  31. package/dist/assets/{ScanNetworkModal-DNtPeZ2B.js → ScanNetworkModal-SyHjZF2T.js} +1 -1
  32. package/dist/assets/{SessionsList-DqDv9LKK.js → SessionsList-BD87Vhfu.js} +1 -1
  33. package/dist/assets/{Showroom-D8Shgmh7.js → Showroom-BS88iBLb.js} +1 -1
  34. package/dist/assets/{System-Cl5e6KJW.js → System-D-Xj3jc0.js} +1 -1
  35. package/dist/assets/{Terminal-BBAoUjfs.js → Terminal-DhbVA89N.js} +5 -5
  36. package/dist/assets/{Trans-DvLMqjNd.js → Trans-Bsz5Pghy.js} +1 -1
  37. package/dist/assets/{assignment-candidates-YAud75JK.js → assignment-candidates-DWivr3bV.js} +1 -1
  38. package/dist/assets/{board-model-BgDnb_No.js → board-model-CCD7fB3T.js} +1 -1
  39. package/dist/assets/{device-integration-icon-Dxf6i9YB.js → device-integration-icon-D-OosuOg.js} +1 -1
  40. package/dist/assets/{format-D6gOZRRr.js → format-ChSVChsY.js} +1 -1
  41. package/dist/assets/i18n-Bg2ooh3q.js +1 -0
  42. package/dist/assets/index-CyqhCHax.css +2 -0
  43. package/dist/assets/{index-CoVcMsxX.js → index-DMMw81r0.js} +3 -3
  44. package/dist/assets/{linked-devices-model-CPj1sFzr.js → linked-devices-model-D9m6pafu.js} +1 -1
  45. package/dist/assets/{location-owned-usage-BhWswowa.js → location-owned-usage-DasgH3RR.js} +1 -1
  46. package/dist/assets/{mf-entry-bootstrap-0-bba9c01e.js → mf-entry-bootstrap-0-dd19d57d.js} +1 -1
  47. package/dist/assets/{notification-schedule-field-XRy8SQoM.js → notification-schedule-field-B7FdiF_t.js} +1 -1
  48. package/dist/assets/{sso-popup-BYo1cU_K.js → sso-popup-BjTl8T6g.js} +1 -1
  49. package/dist/assets/{step-inspector-model-DG2Cy9_m.js → step-inspector-model-DINPtCNq.js} +1 -1
  50. package/dist/assets/{useNodeUrlSelection-Pafi-8p7.js → useNodeUrlSelection-A-NDcCsx.js} +1 -1
  51. package/dist/index.html +8 -8
  52. package/dist/server/addon.js +1 -1
  53. package/package.json +1 -1
  54. package/dist/assets/IntegrationDetail-BV550NaL.js +0 -1
  55. package/dist/assets/i18n-C02pTNTJ.js +0 -1
  56. package/dist/assets/index-BrupW6X6.css +0 -2
package/dist/index.html CHANGED
@@ -136,22 +136,22 @@
136
136
  })
137
137
  })()
138
138
  </script>
139
- <script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-bba9c01e.js"></script>
139
+ <script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-dd19d57d.js"></script>
140
140
  <link rel="modulepreload" crossorigin href="./assets/__vite-browser-external-BCAtXlNQ.js">
141
141
  <link rel="modulepreload" crossorigin href="./assets/client-BvflqtP1.js">
142
142
  <link rel="modulepreload" crossorigin href="./assets/player-overlays-DpZIxQHp.js">
143
143
  <link rel="modulepreload" crossorigin href="./assets/src-KDhMZ5Ob.js">
144
144
  <link rel="modulepreload" crossorigin href="./assets/useTranslation-BJr-n0es.js">
145
- <link rel="modulepreload" crossorigin href="./assets/i18n-C02pTNTJ.js">
146
- <link rel="modulepreload" crossorigin href="./assets/Trans-DvLMqjNd.js">
145
+ <link rel="modulepreload" crossorigin href="./assets/i18n-Bg2ooh3q.js">
146
+ <link rel="modulepreload" crossorigin href="./assets/Trans-Bsz5Pghy.js">
147
147
  <link rel="modulepreload" crossorigin href="./assets/video-D0guHpd1.js">
148
- <link rel="modulepreload" crossorigin href="./assets/notification-schedule-field-XRy8SQoM.js">
149
- <link rel="modulepreload" crossorigin href="./assets/FormBuilder-C-ti9Mun.js">
148
+ <link rel="modulepreload" crossorigin href="./assets/notification-schedule-field-B7FdiF_t.js">
149
+ <link rel="modulepreload" crossorigin href="./assets/FormBuilder-BvQZWKCS.js">
150
150
  <link rel="modulepreload" crossorigin href="./assets/mount-2dkiqOI6.js">
151
151
  <link rel="modulepreload" crossorigin href="./assets/addon-icons-context-DZZCjo9x.js">
152
- <link rel="modulepreload" crossorigin href="./assets/sso-popup-BYo1cU_K.js">
153
- <link rel="stylesheet" crossorigin href="./assets/index-BrupW6X6.css">
154
- <link rel="modulepreload" crossorigin href="./assets/hostInit-DR1ykbVx.js"><link rel="modulepreload" crossorigin href="./assets/index-CoVcMsxX.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-CD4F7fE2.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CmowmspB.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js"></head>
152
+ <link rel="modulepreload" crossorigin href="./assets/sso-popup-BjTl8T6g.js">
153
+ <link rel="stylesheet" crossorigin href="./assets/index-CyqhCHax.css">
154
+ <link rel="modulepreload" crossorigin href="./assets/hostInit-DR1ykbVx.js"><link rel="modulepreload" crossorigin href="./assets/index-DMMw81r0.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-CD4F7fE2.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CmowmspB.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js"></head>
155
155
  <body>
156
156
  <div id="root"></div>
157
157
  <!-- Lock the app shell at 1x zoom. iOS Safari ignores `user-scalable=no`
@@ -86787,7 +86787,7 @@ var AdminUIAddon = class extends BaseAddon {
86787
86787
  capability: adminUiCapability,
86788
86788
  provider: {
86789
86789
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
86790
- getVersion: async () => ({ version: "1.2.528" })
86790
+ getVersion: async () => ({ version: "1.2.529" })
86791
86791
  }
86792
86792
  }];
86793
86793
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.528",
3
+ "version": "1.2.529",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -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 ee}from"./client-BvflqtP1.js";import{t as k}from"./search-x-DE4DxdsF.js";import{Ai as A,Co as j,Cr as te,Do as ne,Er as re,Fa as M,Fs as N,Ft as P,Go as F,Io as ie,Is as I,Lt as ae,Mn as L,Ms as R,Na as z,Ns as B,Oo as oe,Pr as V,Ps as H,Pt as se,Rs as U,Sn as ce,So as le,Sr as ue,Tr as de,Yi as fe,Yn as pe,Zn as me,_o as W,bo as he,br as ge,cn as _e,ef as ve,fr as G,go as K,ho as q,if as ye,ii as J,ja as Y,ji as be,jo as X,js as xe,mo as Se,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-DvLMqjNd.js";import{t as Q}from"./useTranslation-BJr-n0es.js";import{t as Ae}from"./FormBuilder-C-ti9Mun.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-CoVcMsxX.js";import{t as ze}from"./device-integration-icon-Dxf6i9YB.js";import{i as Be,r as Ve,t as He}from"./ScanNetworkModal-DNtPeZ2B.js";import{t as Ue}from"./NodeAddonsSettingsPanel-Bin3whKR.js";s();function We(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...We(n.fields));return t}function Ge(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...We(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 Ke(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(...Ke(n.fields));return t}function qe(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function Je(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){Je(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function $(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Ye({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($),S=F({addonId:l},{enabled:t}),C=S.data?.deviceType??null,E=X({addonId:l,type:C??ee.Camera},{enabled:t&&S.isSuccess&&C!==null}),k=E.data??null;a(()=>{t&&(m(k?Je(k.sections.flatMap(e=>e.fields)):{}),x($()),g(!1),y(null))},[t,s,k]);let A=n(()=>({...p,_probeRequestId:b}),[p,b]),j=le({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),te=Te(),ne=r(async(e,t)=>{g(!0);let n=await te.mutateAsync({addonId:l,type:C??ee.Camera,key:e,value:t,formValues:A});return n.status===`ok`&&n.suggestedValues&&m(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))qe(e[i])&&!qe(a)&&(r[i]=a,t=!0);return t?r:e}),n},[te,l,A,C]),{testAllStatus:M,hasProbeFields:N,probeResults:P,handleTestAll:ie,clearProbeResult:I}=Ge(k??{sections:[]},p,ne);async function ae(e){y(null);try{await j.mutateAsync({addonId:l,type:C??ee.Camera,config:p,integrationId:s}),e?m(k?Je(k.sections.flatMap(e=>e.fields)):{}):u()}catch(e){y(e instanceof Error?e.message:String(e))}}if(!t)return null;let L=Ke((k?.sections??[]).flatMap(e=>e.fields)).filter(e=>qe(p[e])),R=L.length===0,z=S.isLoading||C!==null&&E.isLoading,B=S.isError||S.isSuccess&&C===null||E.isError||E.isSuccess&&k===null;return i(ge,{open:!0,onOpenChange:e=>{e||u()},children:e(ue,{width:`lg`,scroll:`body`,children:[i(de,{children:i(re,{children:d(`integrations.addDevice`)})}),i(Oe,{className:`space-y-3`,children:z?i(`div`,{className:`flex items-center justify-center py-8`,children:i(T,{className:`h-5 w-5 animate-spin text-primary`})}):B?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:k,values:p,onChange:m,onTestField:ne,probeResults:P,onClearProbe:I})}),!B&&!z&&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(_e,{addonId:l,requestId:b,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!B&&!z&&(_||L.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:L.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`)}),!B&&N&&e(`button`,{type:`button`,onClick:ie,disabled:M===`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:[M===`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:()=>ae(!0),disabled:B||!R||j.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:()=>ae(!1),disabled:B||!R||j.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:j.isPending?d(`integrations.saving`):d(`integrations.save`)})]})]})]})})}s();var Xe=`matter`,Ze=[`discovering`,`pase`,`commissioning`,`done`];function Qe(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function $e(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 et({onClose:t,onCommissioned:n}){let{t:r}=Q(),s=z({kind:Xe}),[c,l]=o(null),u=s.data?.length??0,d=c??s.data?.[0]?.id??null,f=M(),[p,m]=o(``),[h,g]=o({phase:`idle`,failure:null,message:null}),_=h.phase===`discovering`||h.phase===`pase`||h.phase===`commissioning`,v=Y({brokerId:d??``,key:`commission`},{enabled:d!==null&&_,refetchInterval:_?400:!1});a(()=>{_&&Qe(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`?$e(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(ge,{open:!0,onOpenChange:e=>!e&&t(),children:e(ue,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(de,{children:i(re,{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(me,{children:r(`integrations.addMatter.broker`,{defaultValue:`Matter fabric`})}),i(Pe,{kind:Xe,value:d,onChange:l})]}),!S&&e(`div`,{className:`space-y-1.5`,children:[i(me,{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:Ze.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(V,{message:x})]}),e(De,{children:[i(J,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),h.phase===`done`?i(J,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(J,{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 tt=1500;function nt({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=Q(),s=Se(),c=(W({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?tt:!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 rt(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 it=`devices`;function at(e){return{id:it,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var ot=2e4,st=100;function ct({addonId:n,integrationId:s,onClose:u}){let d=x(),{t:f}=Q(),p=c(),[m,h]=o(new Set),[g,v]=o(new Set),[y,b]=o(new Map),[S,C]=o(null),{data:w}=B(),E=(w??[]).find(e=>e.addonId===n)?.supportsLocationImport??!1,[D,ee]=o(!0),k=q({addonId:n,integrationId:s}).data?.filters,A=k&&k.length>0?k:[at(f)],[j,ne]=o(A.find(e=>e.isDefault)?.id??(A.some(e=>e.id===it)?it:A[0].id)),M=j!==it,N=Ee(),P=K({addonId:n,integrationId:s,page:1,pageSize:ot,filter:j}),F=P.refetch,ie=N.mutate,I=r(()=>{ie({addonId:n,integrationId:s},{onSettled:()=>{F()}})},[ie,n,s,F]),ae=t(null);a(()=>{let e=`${n}::${s}`;ae.current===e||P.isLoading||(ae.current=e,(P.data?.candidates.length??0)===0&&I())},[n,s,P.isLoading,P.data,I]);let L=N.isPending,R=N.isError?N.error instanceof Error?N.error.message:String(N.error):null,z=typeof N.data?.lastError==`string`&&N.data.lastError.length>0?N.data.lastError:null,oe=P.data?.candidates??[],V=P.isError?P.error instanceof Error?P.error.message:String(P.error):null,H=he(),[U,ce]=o(null),le=r(e=>{e.alreadyAdopted||h(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),fe=r(e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pe=r((e,t)=>{b(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})},[]),me=r(e=>{let t={};for(let n of e){let e=y.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[y]),W=r(async()=>{C(null);let e=[...m];if(e.length!==0)try{let t=me(e),{jobId:r}=await H.mutateAsync({addonId:n,integrationId:s,filter:j,childNativeIds:e,...t?{perCandidate:t}:{},...E?{importLocations:D}:{}});ce(r),h(new Set),b(new Map)}catch(e){C(e instanceof Error?e.message:String(e))}},[m,me,H,n,s,j,E,D]),_e=t(null),G=r(()=>{U===null||_e.current===U||(_e.current=U,F(),p.invalidateQueries({queryKey:[[`integrations`]]}),p.invalidateQueries({queryKey:[[`deviceManager`]]}))},[U,F,p]),Y=r(e=>{ne(e),h(new Set),v(new Set),b(new Map),C(null)},[]),be=m.size,X=U!==null&&be===0&&!H.isPending;return i(ge,{open:!0,onOpenChange:e=>{e||u()},children:e(ue,{width:`xl`,scroll:`body`,className:`md:h-[85vh]`,children:[e(de,{children:[i(re,{children:f(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),i(te,{children:f(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})}),E&&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:D,onChange:e=>ee(e.target.checked),className:`accent-primary`}),f(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]})]}),e(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2 overflow-hidden`,children:[(R??V??z)&&oe.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:f(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:R??V??z})]})]})}),A.length>1&&i(lt,{filters:A,activeFilter:j,onSelect:Y}),i(`div`,{className:`flex-1 min-h-0`,children:i(se,{mode:`generic`,items:oe,pageSize:st,getKey:e=>e.childNativeId,getSearchText:rt,getFilterType:e=>e.type,filterOptions:ve(d),filterLabel:f(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:P.isLoading||L&&oe.length===0,searchPlaceholder:f(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(R??V??z)&&oe.length===0?``:f(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(`button`,{type:`button`,onClick:I,disabled:L,title:f(`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 ${L?`animate-spin`:``}`}),f(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:f(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>i(ut,{candidate:e,expandable:!M,expanded:g.has(e.childNativeId),onToggleExpand:()=>fe(e.childNativeId),adoptedLabel:f(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:f(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=ye(t.type,d),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:()=>le(e),disabled:e.alreadyAdopted,"aria-label":m.has(e.childNativeId)?f(`integrations.adoptDevicesModal.deselect`,`Deselect`):f(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${m.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:m.has(e.childNativeId)&&i(l,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!M&&g.has(e.childNativeId),renderExpanded:M?void 0:e=>i(dt,{candidate:e,hiddenChildIds:y.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>pe(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:m.has(e.childNativeId)?`bg-primary/5`:``})})]}),S&&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:S})]})}),U!==null&&i(nt,{addonId:n,integrationId:s,jobId:U,onFinished:G}),e(De,{children:[i(J,{variant:`outline`,size:`sm`,onClick:u,children:f(`integrations.cancel`,{defaultValue:`Cancel`})}),e(J,{variant:`primary`,size:`sm`,onClick:X?u:W,disabled:!X&&(be===0||H.isPending),children:[H.isPending&&i(T,{className:`h-3.5 w-3.5 animate-spin`}),X?f(`integrations.close`,{defaultValue:`Close`}):f(`integrations.addSelected`,{defaultValue:`Add selected`}),!X&&be>0?` (${be})`:``]})]})]})})}function lt({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 ut({candidate:t,expandable:n,expanded:r,onToggleExpand:a,adoptedLabel:o}){let{t:s}=Q(),c=(t.children??[]).length;return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[n&&c>0?e(`button`,{type:`button`,onClick:a,"aria-label":r?s(`integrations.adoptDevicesModal.collapse`,`Collapse`):s(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":r,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(r?w:d,{className:`h-3.5 w-3.5`}),c]}):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}),t.alreadyAdopted&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:o})]})}function dt({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 ft(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...ft(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function pt(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>ft(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function mt(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 ht({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}=H({id:t},{enabled:s===`account`||s===`broker`}),_=n(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:y}=A({addonId:r,nodeId:`hub`},{enabled:s===`account`}),b=n(()=>v?mt(v):null,[v]),x=I(),S=(e,n)=>{x.mutate({id:t,settings:e,...n?{secretKeys:[...n]}:{}},{onSuccess:()=>{m.invalidateQueries(),f()}})};return i(ge,{open:!0,onOpenChange:e=>!e&&f(),children:e(ue,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(de,{children:e(re,{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(Be,{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(Ve,{addonId:r,configSchema:b,canTest:u,initialName:a,initialConfig:pt(b,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e,secretKeys:t})=>S(e,t),onBack:f}):i(G,{trpc:d,addonId:r,nodeId:`hub`,title:a})})]})})}function gt(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}s();function _t(){let{addonId:e=``}=Me();return i(yt,{addonId:e})}function vt(){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 yt({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),ee=r(e=>{O(!1),d(`/integrations`,{state:{integrationSeed:e}})},[d]),[te,M]=o(!1),[F,I]=o(!1),{data:z}=N(void 0),V=n(()=>(z??[]).filter(e=>e.addonId===t),[z,t]),H=Re(p.get(`instance`),V)??``,le=r(e=>{g(t=>{let n=new URLSearchParams(t);return n.set(Fe,e),n},{replace:!0})},[g]),me=n(()=>V.map(e=>({value:e.id,label:e.name})),[V]),{data:W,isLoading:he}=R({id:H},{enabled:!!H}),{data:ve}=A({addonId:W?.addonId??``,nodeId:`hub`},{enabled:!!W?.addonId}),{data:G,isSuccess:K}=B(),q=n(()=>{let e=W?.addonId;return!e||!K?null:(G??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[G,W?.addonId,K]),{data:ye}=ne({}),J=n(()=>(ye?.providers??[]).some(e=>e.addonId===W?.addonId),[ye,W?.addonId]),Y=q!==null,X=W?.info?.fixed===!0,Se=n(()=>{let e=W?.addonId;return!e||!K?null:(G??[]).find(t=>t.addonId===e)?.brokerKind??null},[G,W?.addonId,K]),Te=Se===`matter`,Ee=Y?Te?s(`integrations.addMatter.title`,{defaultValue:`Add Matter device`}):q===`device-adoption`?s(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):s(`integrations.addDevice`):s(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),De=n(()=>{let e=W?.addonId;return!e||!K?!1:(G??[]).find(t=>t.addonId===e)?.canTest===!0},[G,W?.addonId,K]),Z=n(()=>{let e=W?.addonId;return!e||!K?null:(G??[]).find(t=>t.addonId===e)?.mode??null},[G,W?.addonId,K]);a(()=>{p.get(`add`)===`1`&&Y&&(w(!1),x(!0),g(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[p,Y,g]);let ke=ve!=null&&Array.isArray(ve.sections)&&ve.sections.some(e=>e.fields.length>0),{data:Ae}=be({addonId:W?.addonId??``,nodeId:`hub`},{enabled:!!W?.addonId&&Z!==`account`}),je=Z!==null&&Z!==`account`&&gt(Ae),Me=n(()=>W?.addonId?[W.addonId]:[],[W?.addonId]),{data:Pe}=ie({projection:`slim`},{refetchInterval:3e4}),Be=[[`integrations`,`get`],{input:{id:H},type:`query`}],Ve=U({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`]]})}}),We=xe({onSuccess:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]}),d(V.length>1?Le(t):`/integrations`)}}),Ge=fe({onSuccess:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ke=Ce({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),qe=j({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Je=oe({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),$=n(()=>Pe??[],[Pe]),Xe=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=>Xe.get(e)??null,[Xe]),Qe=n(()=>P(z),[z]),$e=r(e=>d(`/devices/${String(e)}`),[d]),tt=n(()=>$.filter(e=>{let t=Qe(e);return t.kind===`resolved`&&t.integration.id===H}),[$,H,Qe]),nt=n(()=>z===void 0?null:ae(tt).length,[z,tt])??`…`;if(he||z===void 0)return i(vt,{});let rt=(G??[]).find(e=>e.addonId===t)?.name??W?.name??t;return W?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(L,{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(bt,{addonId:W.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:[J&&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`)]}),!X&&e(`button`,{onClick:()=>{w(!1),x(!0)},disabled:!Y,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`:``} ${W.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:s(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(pe,{checked:W.enabled,onCheckedChange:e=>Ve.mutate({id:H,enabled:e}),disabled:Ve.isPending,"aria-label":W.enabled?s(`integrationDetail.disableIntegration`,`Disable integration`):s(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${W.enabled?`text-success`:`text-foreground-subtle`}`,children:W.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||q===`device-adoption`)&&e(`button`,{onClick:()=>M(!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:()=>I(!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:W.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:W.addonId})}),!X&&H&&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:W.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:We.isPending,action:()=>We.mutateAsync({id:H})})]})]}),V.length>1&&i(`div`,{className:`max-w-sm`,children:i(we,{mode:`single`,singleDisplay:`field`,label:s(`integrationDetail.instances`,`Integration`),options:me,value:H,onChange:le,testId:`integration-instance-picker`,optionTestIdPrefix:`integration-instance`})}),je&&i(Ue,{nodeId:null,addonIds:Me,level:`global`,surface:`integration`,title:s(`integrations.settings`,{defaultValue:`Settings`})}),i(se,{context:`integration-detail`,devices:$,trpc:_.trpcClient,integrationOf:Qe,forceIntegrationId:H,urlScope:`root`,lsKey:`integration-detail:${W.addonId}`,resolveIntegrationIcon:ze,resolveParent:Ze,onNavigate:$e,batchActions:{remove:Ke.mutate,disable:qe.mutate,enable:Je.mutate},...X?{}:{onDeleteDevice:e=>Ke.mutate({deviceId:e.id})}}),v&&H&&Te&&!S&&i(et,{onClose:()=>x(!1),onCommissioned:()=>w(!0)}),v&&H&&q===`device-adoption`&&(!Te||S)&&i(ct,{addonId:W.addonId,integrationId:H,onClose:()=>{x(!1),w(!1)}}),v&&H&&q===`device-provider`&&i(Ye,{open:v,integrationId:H,addonId:W.addonId,onClose:()=>x(!1)}),E&&W&&i(He,{open:E,scope:{addonId:W.addonId,label:W.name},onClose:()=>O(!1),onSetupIntegration:ee}),te&&H&&q!==null&&Z!==null&&i(ht,{integrationId:H,addonId:W.addonId,name:W.name,kind:q,mode:Z,brokerKind:Se,canTest:De,trpc:_.trpcClient,onClose:()=>M(!1)}),F&&i(ge,{open:!0,onOpenChange:e=>!e&&I(!1),children:e(ue,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(de,{className:`mb-0`,children:e(re,{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:W.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[W.addonId,H?` · ${H}`:``]})]})}),i(Oe,{className:`min-h-0 overflow-hidden p-0`,children:i(_e,{addonId:W.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(k,{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 bt({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{_t as IntegrationDetailPage};